sandforge 1.84.1 → 1.86.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/{chunk-S42RBRH2.mjs → chunk-22L43JMK.mjs} +1 -1
- package/lib/{chunk-Y2DRK37K.mjs → chunk-2LSGWTWX.mjs} +1 -1
- package/lib/{chunk-24RFOFYT.mjs → chunk-2YJJTQNC.mjs} +1 -1
- package/lib/chunk-34SMB5PA.mjs +10 -0
- package/lib/chunk-35B73566.mjs +7 -0
- package/lib/{chunk-3TZSBHEY.mjs → chunk-35IJ4WEU.mjs} +1 -1
- package/lib/chunk-3EHPAFKV.mjs +7 -0
- package/lib/{chunk-6YL7BNYD.mjs → chunk-3HAVVEXF.mjs} +1 -1
- package/lib/{chunk-6JWWSDM6.mjs → chunk-3I6FXFCN.mjs} +1 -1
- package/lib/{chunk-WUUKFE2U.mjs → chunk-3KJCSYXY.mjs} +1 -1
- package/lib/{chunk-2HVOZUM4.mjs → chunk-3L6DVNCR.mjs} +1 -1
- package/lib/chunk-3LRFPGYZ.mjs +7 -0
- package/lib/{chunk-GWZRR3MM.mjs → chunk-3MVWGL5A.mjs} +1 -1
- package/lib/{chunk-KGU4SVIT.mjs → chunk-4CSBZZAL.mjs} +1 -1
- package/lib/{chunk-JE6SCT6R.mjs → chunk-4NSXPONF.mjs} +1 -1
- package/lib/{chunk-UIOMAX56.mjs → chunk-4VLP6RHC.mjs} +1 -1
- package/lib/{chunk-YA6ATMTB.mjs → chunk-4XROG5CT.mjs} +1 -1
- package/lib/chunk-54V4FVEY.mjs +7 -0
- package/lib/chunk-55OJJT2Q.mjs +7 -0
- package/lib/{chunk-6QE6R6RL.mjs → chunk-5EHHQ5UX.mjs} +1 -1
- package/lib/{chunk-FITPY3L4.mjs → chunk-5JMQXHJ2.mjs} +1 -1
- package/lib/{chunk-W6PN6TJG.mjs → chunk-65AMXOQU.mjs} +1 -1
- package/lib/{chunk-3Q353S2R.mjs → chunk-6HHSAPIM.mjs} +1 -1
- package/lib/chunk-6KVBCFVS.mjs +7 -0
- package/lib/chunk-6NG7C2U3.mjs +476 -0
- package/lib/chunk-6ROL3KBM.mjs +7 -0
- package/lib/{chunk-2JDAOWUW.mjs → chunk-72AWCN7U.mjs} +1 -1
- package/lib/{chunk-JLSIWO4Z.mjs → chunk-7KHA5UIQ.mjs} +1 -1
- package/lib/chunk-7O6EFNQS.mjs +10 -0
- package/lib/{chunk-WWTCWWZI.mjs → chunk-A2CH2QGX.mjs} +1 -1
- package/lib/chunk-A2TXLAC3.mjs +276 -0
- package/lib/chunk-ALWVNR34.mjs +7 -0
- package/lib/{chunk-D4GF4FAB.mjs → chunk-ATBQIE2V.mjs} +1 -1
- package/lib/{chunk-NED4MBIM.mjs → chunk-ATQML7ZK.mjs} +1 -1
- package/lib/chunk-AVY742BJ.mjs +7 -0
- package/lib/{chunk-YWEQQL3C.mjs → chunk-AXTB2HJS.mjs} +1 -1
- package/lib/chunk-BBZUGKBZ.mjs +10 -0
- package/lib/chunk-BIDXK7KA.mjs +7 -0
- package/lib/{chunk-O677VOGO.mjs → chunk-BLMJ4WVI.mjs} +1 -1
- package/lib/{chunk-RE7RYF3B.mjs → chunk-BNHJCJJM.mjs} +1 -1
- package/lib/{chunk-5M5FQ7RP.mjs → chunk-BNPQEQXC.mjs} +1 -1
- package/lib/chunk-C5AUNG6T.mjs +37 -0
- package/lib/{chunk-ETDCBLGU.mjs → chunk-C5EQ7GFC.mjs} +1 -1
- package/lib/{chunk-MJZU3U5O.mjs → chunk-C7CKDZMC.mjs} +61 -61
- package/lib/{chunk-HCGXK7G7.mjs → chunk-CB4U22NR.mjs} +1 -1
- package/lib/chunk-CJAWKLAL.mjs +7 -0
- package/lib/chunk-CL75DEMQ.mjs +9 -0
- package/lib/{chunk-VCUXCK36.mjs → chunk-CLUNF4FK.mjs} +1 -1
- package/lib/chunk-CSMGP53U.mjs +7 -0
- package/lib/{chunk-7YNM6KFZ.mjs → chunk-CT324C7I.mjs} +1 -1
- package/lib/{chunk-7UVKIWKV.mjs → chunk-CZXDJXQP.mjs} +1 -1
- package/lib/{chunk-43TOMFV4.mjs → chunk-D2X6U3MS.mjs} +1 -1
- package/lib/{chunk-M6K34KGF.mjs → chunk-DAUX63UB.mjs} +1 -1
- package/lib/chunk-DB7JNALQ.mjs +10 -0
- package/lib/chunk-DDNCJVZ2.mjs +17 -0
- package/lib/{chunk-FP7CYB2F.mjs → chunk-DLSU66MY.mjs} +1 -1
- package/lib/{chunk-JKJ74BX5.mjs → chunk-DO6PSHQZ.mjs} +1 -1
- package/lib/{chunk-MDMPJEV3.mjs → chunk-DUBECLZV.mjs} +1 -1
- package/lib/{chunk-KZTZDC7H.mjs → chunk-DYHF6DNT.mjs} +1 -1
- package/lib/chunk-E5FSPXYH.mjs +930 -0
- package/lib/{chunk-Q7GIJBCD.mjs → chunk-EGL3I3IX.mjs} +1 -1
- package/lib/chunk-EIYMQPMG.mjs +7 -0
- package/lib/{chunk-RHNTHGNU.mjs → chunk-EUIALBMX.mjs} +1 -1
- package/lib/{chunk-NCZKWSC7.mjs → chunk-FI3R5ZOQ.mjs} +1 -1
- package/lib/{chunk-PAXNWTYK.mjs → chunk-FM4QCTO7.mjs} +1 -1
- package/lib/{chunk-HV7VPEXP.mjs → chunk-FRSIEASH.mjs} +1 -1
- package/lib/{chunk-QAFPQ3YB.mjs → chunk-FV6MOSHD.mjs} +1 -1
- package/lib/chunk-FYG47CNA.mjs +7 -0
- package/lib/chunk-GB6W4Q56.mjs +7 -0
- package/lib/chunk-GEV2DCMK.mjs +7 -0
- package/lib/{chunk-NSQWI7ZY.mjs → chunk-GFB2DNCB.mjs} +1 -1
- package/lib/chunk-GFGMGFSH.mjs +7 -0
- package/lib/{chunk-RGUQOSBU.mjs → chunk-GIFQXB2Q.mjs} +1 -1
- package/lib/{chunk-JAEDM4SI.mjs → chunk-GP5J3DGS.mjs} +1 -1
- package/lib/chunk-GQZEX7LH.mjs +231 -0
- package/lib/{chunk-JSAJS3MY.mjs → chunk-GYDTM62J.mjs} +1 -1
- package/lib/{chunk-OPMO6I45.mjs → chunk-GYFIXUJG.mjs} +1 -1
- package/lib/chunk-GZW2GNFK.mjs +7 -0
- package/lib/chunk-H6BHWAX7.mjs +8 -0
- package/lib/{chunk-EAC5QCE3.mjs → chunk-HDDJ3CVN.mjs} +1 -1
- package/lib/{chunk-5SMWFNE7.mjs → chunk-HDWB4ZOG.mjs} +1 -1
- package/lib/chunk-HGVPBJR6.mjs +7 -0
- package/lib/{chunk-BBRWFKS5.mjs → chunk-HLROVOR6.mjs} +1 -1
- package/lib/{chunk-LKTNQEBS.mjs → chunk-HUOR4M2L.mjs} +1 -1
- package/lib/chunk-HZCS6EED.mjs +8 -0
- package/lib/{chunk-36JOHEJL.mjs → chunk-HZUI56KZ.mjs} +1 -1
- package/lib/chunk-IAB5H7WN.mjs +7 -0
- package/lib/{chunk-X4BXESMQ.mjs → chunk-IQ5UKRHU.mjs} +1 -1
- package/lib/{chunk-54WZUS7J.mjs → chunk-IRQ4WANV.mjs} +1 -1
- package/lib/{chunk-5IZTFMJM.mjs → chunk-IT3DGX37.mjs} +1 -1
- package/lib/chunk-J347SPU6.mjs +49 -0
- package/lib/{chunk-QO53K5W2.mjs → chunk-JANBNTR5.mjs} +1 -1
- package/lib/chunk-JFXQZPRY.mjs +9 -0
- package/lib/{chunk-KAZS5Z6W.mjs → chunk-JRLYWVF4.mjs} +1 -1
- package/lib/{chunk-GKY2JMHY.mjs → chunk-JSNMUTY6.mjs} +1 -1
- package/lib/chunk-JTNJKSAA.mjs +7 -0
- package/lib/{chunk-7WATA4SB.mjs → chunk-JV2LAKWQ.mjs} +1 -1
- package/lib/{chunk-WAPSSYMT.mjs → chunk-JV7K2ZHK.mjs} +1 -1
- package/lib/{chunk-ZBAWJUG2.mjs → chunk-K4TQ7YHX.mjs} +1 -1
- package/lib/chunk-K5PUMHZU.mjs +7 -0
- package/lib/chunk-KH4KLCYG.mjs +7 -0
- package/lib/{chunk-OLCVHL7I.mjs → chunk-KQVLZVOP.mjs} +1 -1
- package/lib/chunk-KWUS7UAV.mjs +19 -0
- package/lib/{chunk-JGZPD4IM.mjs → chunk-L6G73FXM.mjs} +1 -1
- package/lib/{chunk-BAWCOKRW.mjs → chunk-LG466Q5H.mjs} +1 -1
- package/lib/{chunk-GMIGWR6U.mjs → chunk-LHNAR6FC.mjs} +1 -1
- package/lib/chunk-LT4GHEI2.mjs +7 -0
- package/lib/{chunk-EC72TIEG.mjs → chunk-MR262Y3B.mjs} +1 -1
- package/lib/{chunk-LA4KIATH.mjs → chunk-NCCHOV2N.mjs} +1 -1
- package/lib/chunk-NICRSGLS.mjs +7 -0
- package/lib/chunk-NV5QA2HY.mjs +7 -0
- package/lib/{chunk-PR3XCSPO.mjs → chunk-O3GIN5TU.mjs} +1 -1
- package/lib/chunk-O6FHK6NQ.mjs +13 -0
- package/lib/{chunk-M4BLK6HJ.mjs → chunk-O7YIEFG7.mjs} +1 -1
- package/lib/chunk-OCUVAA5E.mjs +7 -0
- package/lib/chunk-OLCS7JCT.mjs +14 -0
- package/lib/chunk-ON7Y63FK.mjs +9 -0
- package/lib/{chunk-N4WPCWJO.mjs → chunk-OO2WY3UB.mjs} +1 -1
- package/lib/{chunk-MSIEU5MR.mjs → chunk-OT2NHL2V.mjs} +1 -1
- package/lib/{chunk-6WX5ZU7Q.mjs → chunk-P2M5ZXWU.mjs} +1 -1
- package/lib/{chunk-GNRSF65U.mjs → chunk-P4YOHLZ4.mjs} +1 -1
- package/lib/chunk-PBHDPTT6.mjs +343 -0
- package/lib/chunk-PE7CHD2W.mjs +7 -0
- package/lib/{chunk-PBY2O6OF.mjs → chunk-PIQ2I67B.mjs} +1 -1
- package/lib/chunk-PKYDNZJK.mjs +7 -0
- package/lib/chunk-PVZ72OOQ.mjs +7 -0
- package/lib/chunk-QACFTHJM.mjs +8 -0
- package/lib/{chunk-J3DND3BC.mjs → chunk-QGVL5EW3.mjs} +1 -1
- package/lib/chunk-QHE2RUWX.mjs +7 -0
- package/lib/{chunk-QKEKG2LD.mjs → chunk-RCW5BZNW.mjs} +1 -1
- package/lib/{chunk-4JE4BYXK.mjs → chunk-RJ6HHG7J.mjs} +1 -1
- package/lib/{chunk-ZQWIVYVM.mjs → chunk-RPTEEI4R.mjs} +1 -1
- package/lib/chunk-RQW5S67A.mjs +7 -0
- package/lib/chunk-RTCMYMED.mjs +7 -0
- package/lib/chunk-RWVX7XSD.mjs +7 -0
- package/lib/{chunk-WY5V5PR3.mjs → chunk-RZOINFNL.mjs} +1 -1
- package/lib/chunk-SOOTWGMQ.mjs +7 -0
- package/lib/chunk-STQ2JMIZ.mjs +7 -0
- package/lib/{chunk-6PD6K7LP.mjs → chunk-SUIPDW5O.mjs} +1 -1
- package/lib/{chunk-TNT27RBG.mjs → chunk-SZOJ7BEJ.mjs} +1 -1
- package/lib/{chunk-4EOHEDFP.mjs → chunk-T542Z54E.mjs} +1 -1
- package/lib/chunk-TAN2CIRI.mjs +21 -0
- package/lib/{chunk-A3MYSOOC.mjs → chunk-TCNBINOG.mjs} +1 -1
- package/lib/chunk-TFDF3DBN.mjs +7 -0
- package/lib/chunk-TICZXC53.mjs +9 -0
- package/lib/chunk-TLX45X5U.mjs +7 -0
- package/lib/{chunk-QTG6LUZT.mjs → chunk-TMIV3IWH.mjs} +1 -1
- package/lib/chunk-TQ6HEJ73.mjs +11 -0
- package/lib/chunk-TTU5EQZ6.mjs +7 -0
- package/lib/chunk-TYUYPFDJ.mjs +7 -0
- package/lib/chunk-TZXYVMZC.mjs +7 -0
- package/lib/chunk-UCUFLFNK.mjs +7 -0
- package/lib/chunk-UK3QLBHW.mjs +7 -0
- package/lib/{chunk-IZGCEOYO.mjs → chunk-UM2B4GR7.mjs} +1 -1
- package/lib/chunk-UZFTTNOP.mjs +7 -0
- package/lib/chunk-V3AXSKSU.mjs +7 -0
- package/lib/chunk-VA6EEI6X.mjs +21 -0
- package/lib/{chunk-OFTT7J2M.mjs → chunk-VFKG2G37.mjs} +1 -1
- package/lib/chunk-VJNEW5MQ.mjs +7 -0
- package/lib/{chunk-L53JWJ3S.mjs → chunk-VKREON6Q.mjs} +1 -1
- package/lib/{chunk-NOBQTEQD.mjs → chunk-VNNDYPBL.mjs} +1 -1
- package/lib/{chunk-ZJW6YOMV.mjs → chunk-VRBETPHY.mjs} +1 -1
- package/lib/{chunk-EPFCERGL.mjs → chunk-VT6P3X6R.mjs} +1 -1
- package/lib/{chunk-ZV7ZFQQC.mjs → chunk-VUTQY76O.mjs} +1 -1
- package/lib/chunk-WF5S4FW5.mjs +7 -0
- package/lib/{chunk-Z4LKKOFY.mjs → chunk-WJGK6VGU.mjs} +1 -1
- package/lib/{chunk-5CRLRHOJ.mjs → chunk-WJHMB3SL.mjs} +1 -1
- package/lib/{chunk-OUZQPYT3.mjs → chunk-WQCXOZEJ.mjs} +1 -1
- package/lib/{chunk-L2E5WBGD.mjs → chunk-WVVFR4E3.mjs} +1 -1
- package/lib/{chunk-PWRJRL5U.mjs → chunk-XBYXT74L.mjs} +1 -1
- package/lib/chunk-XJE3LJHP.mjs +7 -0
- package/lib/{chunk-CPQIZGG5.mjs → chunk-XV4CVZYD.mjs} +1 -1
- package/lib/chunk-Y37ED7AS.mjs +7 -0
- package/lib/{chunk-YTLUYSMF.mjs → chunk-YGBNZYT4.mjs} +1 -1
- package/lib/{chunk-4CVUUVGJ.mjs → chunk-YGTOX7IL.mjs} +1 -1
- package/lib/{chunk-OMNMLKDT.mjs → chunk-YJ27WHKR.mjs} +1 -1
- package/lib/chunk-YRULC27A.mjs +7 -0
- package/lib/{chunk-RMFU4BAL.mjs → chunk-YSVAHT4Q.mjs} +4 -4
- package/lib/chunk-YTOTMJTY.mjs +15 -0
- package/lib/{chunk-B63POIPQ.mjs → chunk-YZKZC62O.mjs} +1 -1
- package/lib/{chunk-DPMRIMUC.mjs → chunk-YZQN7BRB.mjs} +1 -1
- package/lib/{chunk-7SQSWVAU.mjs → chunk-Z5IUK2QO.mjs} +1 -1
- package/lib/{chunk-M2ABR4JM.mjs → chunk-ZEGSMW5A.mjs} +1 -1
- package/lib/{chunk-PR42EZSR.mjs → chunk-ZIKLQZBG.mjs} +1 -1
- package/lib/chunk-ZVU7MD2S.mjs +7 -0
- package/lib/sandforge-autopilot.mjs +33 -27
- package/lib/sandforge-backup.mjs +19 -19
- 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 +32 -14
- package/lib/sandforge-dataops.mjs +1 -1
- package/lib/sandforge-empty.mjs +11 -13
- package/lib/sandforge-env.mjs +105 -105
- package/lib/sandforge-frozen.mjs +1 -1
- package/lib/sandforge-mcp.mjs +2 -2
- package/lib/sandforge-monitor.mjs +1 -1
- package/lib/sandforge-pipeline.mjs +13 -13
- package/lib/sandforge-seed.mjs +1 -1
- package/lib/sandforge-sync.mjs +1 -1
- package/lib/sandforge-users.mjs +13 -15
- package/lib/sandforge.mjs +1 -1
- package/lib/sf/sandforge/dataops.mjs +2 -2
- package/lib/sfPlugin.mjs +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/lib/chunk-23SEDORH.mjs +0 -11
- package/lib/chunk-26POJDIT.mjs +0 -7
- package/lib/chunk-2AZQHBEF.mjs +0 -7
- package/lib/chunk-2METQHGG.mjs +0 -7
- package/lib/chunk-2WFIVO4F.mjs +0 -13
- package/lib/chunk-2YHZBUZE.mjs +0 -7
- package/lib/chunk-326AJTIU.mjs +0 -272
- package/lib/chunk-3PVRGTVK.mjs +0 -7
- package/lib/chunk-5XTUSN72.mjs +0 -8
- package/lib/chunk-6I6TWNV5.mjs +0 -7
- package/lib/chunk-6O222PW6.mjs +0 -7
- package/lib/chunk-6ZLKIT3H.mjs +0 -7
- package/lib/chunk-7QYHEHMA.mjs +0 -9
- package/lib/chunk-B3FBHVNN.mjs +0 -21
- package/lib/chunk-BEA27DLS.mjs +0 -7
- package/lib/chunk-BRY3PLIZ.mjs +0 -7
- package/lib/chunk-CBH3TOWK.mjs +0 -341
- package/lib/chunk-CVHNXJH3.mjs +0 -7
- package/lib/chunk-DGDRQRCW.mjs +0 -7
- package/lib/chunk-DUN2EPRC.mjs +0 -7
- package/lib/chunk-E3A3LOCY.mjs +0 -7
- package/lib/chunk-F2424IKX.mjs +0 -7
- package/lib/chunk-F3AQW6IU.mjs +0 -7
- package/lib/chunk-FNJ4SGWO.mjs +0 -7
- package/lib/chunk-GOOVPVWX.mjs +0 -7
- package/lib/chunk-H2BHESDA.mjs +0 -9
- package/lib/chunk-H4CGM6YO.mjs +0 -7
- package/lib/chunk-HIDW7FNV.mjs +0 -9
- package/lib/chunk-HSBXRQTI.mjs +0 -7
- package/lib/chunk-HUZPBE47.mjs +0 -7
- package/lib/chunk-I6E6T6YY.mjs +0 -7
- package/lib/chunk-IUM4NFKI.mjs +0 -10
- package/lib/chunk-IVFVNNGB.mjs +0 -37
- package/lib/chunk-JCFBFF4Y.mjs +0 -7
- package/lib/chunk-JTJK2D36.mjs +0 -7
- package/lib/chunk-KB4ZHM4Q.mjs +0 -10
- package/lib/chunk-KJWFYBMU.mjs +0 -15
- package/lib/chunk-LC3NDW4N.mjs +0 -7
- package/lib/chunk-OM5NORJG.mjs +0 -7
- package/lib/chunk-OVNMB6Q2.mjs +0 -7
- package/lib/chunk-PEDQPM2P.mjs +0 -926
- package/lib/chunk-PH7SP4YK.mjs +0 -21
- package/lib/chunk-PMN4PAC3.mjs +0 -19
- package/lib/chunk-PMWAFDUB.mjs +0 -48
- package/lib/chunk-PPLVFX6N.mjs +0 -7
- package/lib/chunk-PZBZ7MNC.mjs +0 -7
- package/lib/chunk-QROPNEGY.mjs +0 -14
- package/lib/chunk-RGBGUCJA.mjs +0 -156
- package/lib/chunk-RKTFFCNS.mjs +0 -7
- package/lib/chunk-ROV3QXEF.mjs +0 -475
- package/lib/chunk-RT47RKLY.mjs +0 -7
- package/lib/chunk-SI267LYR.mjs +0 -8
- package/lib/chunk-SRPWW4A2.mjs +0 -10
- package/lib/chunk-T3G6VZNS.mjs +0 -7
- package/lib/chunk-T63U4OZJ.mjs +0 -7
- package/lib/chunk-TEIBWMJM.mjs +0 -7
- package/lib/chunk-TW3N6W5Z.mjs +0 -7
- package/lib/chunk-UBIKR5VO.mjs +0 -7
- package/lib/chunk-UI3JQVRU.mjs +0 -8
- package/lib/chunk-UX3BVH2Y.mjs +0 -7
- package/lib/chunk-VINGECAJ.mjs +0 -10
- package/lib/chunk-VOXJHJIE.mjs +0 -7
- package/lib/chunk-WB2RIVO3.mjs +0 -7
- package/lib/chunk-WXDLQT2O.mjs +0 -10
- package/lib/chunk-XBQGZGWR.mjs +0 -7
- package/lib/chunk-XGGOUNPP.mjs +0 -7
- package/lib/chunk-XKWW3GKF.mjs +0 -7
- package/lib/chunk-YHR4WQPR.mjs +0 -7
- package/lib/chunk-ZQQXSCVI.mjs +0 -7
- package/lib/chunk-ZRUDYB7O.mjs +0 -7
|
@@ -0,0 +1,7 @@
|
|
|
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 je}from"./chunk-EGL3I3IX.mjs";import{a as Me,b as Le,c as De,d as qe,f as Ie}from"./chunk-M6P5ZZLE.mjs";import{u as Te}from"./chunk-35B73566.mjs";import{e as Oe}from"./chunk-TYUYPFDJ.mjs";import{Ga as We,Ha as Ke,Ma as ze,Oa as Q,Pa as Ze,Ra as He,ha as Be,ra as Ve,ta as Ue,va as Qe,za as U}from"./chunk-OLCS7JCT.mjs";import{b as G}from"./chunk-CA5NAXSU.mjs";import{O as Ae,Q as Ne,R as _e,S as Ce,T as Ee,U as Se,V as Ge,W as $e,ka as xe,oe as Pe}from"./chunk-J347SPU6.mjs";import{e as X,l as ee}from"./chunk-WZQEK4WT.mjs";var v=class extends Error{};function tt(e){let r=[],n=0;for(;n<e.length;){let t=e.slice(n),s=/^\s+/.exec(t);if(s){n+=s[0].length;continue}if(t.startsWith("/*")){let f=e.indexOf("*/",n+2);if(f<0)throw new v("an unclosed comment");n=f+2;continue}let a=t[0];if(a==="'"||a==='"'){let f=1;for(;f<t.length&&t[f]!==a;)f+=t[f]==="\\"?2:1;if(f>=t.length)throw new v("an unclosed text");r.push(t.slice(0,f+1)),n+=f+1;continue}let c=/^(?:\d+(?:\.\d+)?|[A-Za-z_$][A-Za-z0-9_$.]*)/.exec(t);if(c){r.push(c[0]),n+=c[0].length;continue}let p=/^(?:&&|\|\||==|!=|<>|<=|>=|[=<>+\-*/^&!(),])/.exec(t);if(!p)throw new v(`an unexpected character: ${t[0]}`);r.push(p[0]),n+=p[0].length}return r}var Ye=[new Set(["||"]),new Set(["&&"]),new Set(["=","==","<>","!=","<",">","<=",">="]),new Set(["+","-","&"]),new Set(["*","/"]),new Set(["^"])];function gt(e){let r=tt(e),n=0,t=()=>r[n],s=l=>{if(r[n]!==l)throw new v(`${l} expected`);n++},a=l=>{if(l>=Ye.length)return c();let o=a(l+1);for(let u=t();u!==void 0&&Ye[l].has(u);u=t())n++,o={kind:"binary",op:u,left:o,right:a(l+1)};return o},c=()=>{if(t()==="!")return n++,{kind:"not",arg:c()};if(t()==="-"||t()==="+"){let l=r[n++],o=c();return l==="-"?{kind:"negative",arg:o}:o}return p()},p=()=>{let l=r[n++];if(l===void 0)throw new v("the formula ends early");if(l==="("){let u=a(0);return s(")"),u}if(l.startsWith("'")||l.startsWith('"'))return{kind:"literal",value:`text:${l.slice(1,-1)}`};if(/^\d/.test(l))return{kind:"literal",value:`number:${Number(l)}`};if(!/^[A-Za-z_$]/.test(l))throw new v(`${l} out of place`);if(t()==="("){n++;let u=[];if(t()!==")")for(u.push(a(0));t()===",";)n++,u.push(a(0));return s(")"),{kind:"call",name:l.toUpperCase(),args:u}}let o=l.toUpperCase();return o==="TRUE"||o==="FALSE"||o==="NULL"?{kind:"literal",value:o.toLowerCase()}:{kind:"reference",name:l.toLowerCase()}},f=a(0);if(n!==r.length)throw new v(`${r[n]} out of place`);return f}function $(e){switch(e.kind){case"call":return e.name==="PRIORVALUE"&&e.args.length===1?$(e.args[0]):{...e,args:e.args.map($)};case"binary":return{...e,left:$(e.left),right:$(e.right)};case"not":case"negative":return{...e,arg:$(e.arg)};default:return e}}function _(e){switch(e.kind){case"call":return`${e.name}(${e.args.map(_).join(",")})`;case"binary":{let r=e.op==="=="?"=":e.op==="!="?"<>":e.op,n=[_(e.left),_(e.right)];return(r==="="||r==="<>")&&n.sort(),`(${n[0]} ${r} ${n[1]})`}case"not":return`NOT(${_(e.arg)})`;case"negative":return`-(${_(e.arg)})`;case"literal":return e.value;case"reference":return e.name}}var Je=e=>e==="true"?"false":e==="false"?"true":"unknown";function L(e){return e.kind==="call"&&e.name==="AND"?e.args.flatMap(L):e.kind==="binary"&&e.op==="&&"?[...L(e.left),...L(e.right)]:[e]}function D(e){return e.kind==="call"&&e.name==="OR"?e.args.flatMap(D):e.kind==="binary"&&e.op==="||"?[...D(e.left),...D(e.right)]:[e]}function te(e){if(e.kind==="not"){let r=te(e.arg);return{condition:r.condition,holds:!r.holds}}if(e.kind==="call"&&e.name==="NOT"&&e.args.length===1){let r=te(e.args[0]);return{condition:r.condition,holds:!r.holds}}return e.kind==="binary"&&(e.op==="<>"||e.op==="!=")?{condition:_({...e,op:"="}),holds:!1}:{condition:_(e),holds:!0}}function ne(e){if(e.kind==="literal"){if(e.value==="true")return"true";if(e.value==="false")return"false"}}function k(e){let r=ne(e);if(r)return r;if(e.kind==="not")return Je(k(e.arg));if(e.kind==="call")switch(e.name){case"ISCHANGED":return"false";case"ISNEW":return"true";case"NOT":return e.args.length===1?Je(k(e.args[0])):"unknown";case"AND":return Xe(L(e));case"OR":return et(D(e));case"IF":{if(e.args.length!==3)return"unknown";let[n,t,s]=e.args,a=k(n);if(a==="true")return k(t);if(a==="false")return k(s);let c=k(t);return c===k(s)?c:"unknown"}default:return"unknown"}return e.kind==="binary"?e.op==="&&"?Xe(L(e)):e.op==="||"?et(D(e)):mt(e):"unknown"}function Xe(e){let r=e.map(k);if(r.includes("false"))return"false";let n=new Map;for(let t of e){let{condition:s,holds:a}=te(t),c=n.get(s);if(c!==void 0&&c!==a)return"false";n.set(s,a)}return r.every(t=>t==="true")?"true":"unknown"}function et(e){let r=e.map(k);return r.includes("true")?"true":r.every(n=>n==="false")?"false":"unknown"}function mt(e){let r=e.op==="="||e.op==="==",n=e.op==="<>"||e.op==="!=";if(_(e.left)===_(e.right))return n||e.op==="<"||e.op===">"?"false":"unknown";if(!r&&!n)return"unknown";let t=ne(e.left)??k(e.left),s=ne(e.right)??k(e.right);return t==="unknown"||s==="unknown"?"unknown":t===s===r?"true":"false"}function nt(e){try{return k($(gt(e)))==="false"}catch(r){if(r instanceof v)return!1;throw r}}function re(e){let r;try{r=tt(e)}catch(t){if(t instanceof v)return;throw t}let n=new Map;return r.forEach((t,s)=>{if(!/^[A-Za-z_]/.test(t)||t.includes(".")||r[s+1]==="(")return;let a=t.toUpperCase();if(a==="TRUE"||a==="FALSE"||a==="NULL")return;let c=t.toLowerCase();n.has(c)||n.set(c,t)}),[...n.values()]}var ot=25,K=20,ae=K*Be,P=4,rt=10,ht=2e3,yt=.8,st=["validationRules","validationRuleFormulas","duplicateRules","duplicateRuleActions","userPermissions","permissionSets","targetFields","sourceFields","apiBudget"];function wt(e){return typeof e!="object"||e===null?null:{optional:e.optionalFilter===!0}}function Ht(e){return{name:e.name,type:String(e.type),createable:e.createable===!0,nillable:e.nillable!==!1,defaultedOnCreate:e.defaultedOnCreate===!0,referenceTo:(e.referenceTo??[]).filter(r=>typeof r=="string"),picklistValues:(e.picklistValues??[]).filter(r=>r?.active!==!1&&typeof r?.value=="string").map(r=>r?.value),lookupFilter:wt(e.filteredLookupInfo)}}function oe(e){return`SELECT Id, ValidationName, NamespacePrefix, ErrorDisplayField, ErrorMessage, EntityDefinition.QualifiedApiName FROM ValidationRule WHERE Active = true AND EntityDefinition.QualifiedApiName IN (${e.map(n=>`'${n}'`).join(", ")})`}function bt(e){return`SELECT QualifiedApiName, Label FROM FieldDefinition WHERE EntityDefinition.QualifiedApiName = '${O.test(e)?e:""}'`}function I(e){return`SELECT Metadata FROM ValidationRule WHERE Id = '${e}'`}var Rt="SELECT DeveloperName, MasterLabel, NamespacePrefix, SobjectType FROM DuplicateRule WHERE IsActive = true",le=/^[A-Za-z0-9]{15}([A-Za-z0-9]{3})?$/,O=/^[A-Za-z][A-Za-z0-9_]{0,79}$/,kt=ee({DailyApiRequests:ee({Max:X(),Remaining:X()}).loose()}).loose(),m=e=>typeof e=="string"?e:"";function ue(e){if(typeof e!="object"||e===null)return;let r=e.QualifiedApiName;return typeof r=="string"&&r!==""?r:void 0}function W(e,r){return e?`${e}__${r}`:r}function x(e){return typeof e=="string"?[e]:Array.isArray(e)?e.filter(r=>typeof r=="string"):[]}function Ft(e){return{...e,nodes:e.nodes.map(r=>r.leftOutByUser===!0?{...r,included:!0}:r)}}function ie(e,r){let n=m(e).trim(),t=n.slice(n.lastIndexOf(".")+1);if(O.test(t))return r?r.find(s=>s.name.toLowerCase()===t.toLowerCase())?.name:t}function ce(e){let r=We({filterFormula:e}).filter(t=>t.bypass).map(t=>t.name),n=Ke(e).map(t=>t.value===void 0?t.reference:`${t.reference} = '${t.value}'`);return{bypasses:[...r.map(t=>`$Permission.${t}`),...n],permissions:r}}function vt(e,r={}){let n=r.maxRecordsPerObject,t=e.nodes.filter(f=>f.included),s=xe(r)?"atMost":"exact",a=t.map(f=>f.recordCountUnknown===!0?(n===void 0?s="unknown":s==="exact"&&(s="atMost"),{...f,recordCount:n??0}):{...f,recordCount:n===void 0?f.recordCount:Math.min(f.recordCount,n)}),c=new je().generate({...e,nodes:a}).totalApiCalls,p=a.reduce((f,l)=>f+Math.max(1,Math.ceil(l.recordCount/ht)),0);return{writes:c,reads:p,bound:s}}function T(e){let{idValue:r,...n}=e;return{id:Ae(e.kind,e.objectApiName,e.field,e.recordType,r??e.value),source:"metadata",rows:0,...n}}function de(e){return e?{field:e}:{}}function Yt(e){return async r=>Qe(await e.request({method:"POST",url:"/tooling/composite",body:JSON.stringify(Ue(`/services/data/v${e.version}`,r)),headers:{"Content-Type":"application/json"}}),r.length)}async function At(e,r,n,t={}){let s=e.filter(({id:a})=>le.test(a));s.length!==0&&await U(r,[{queries:s.map(({id:a,rule:c})=>({soql:I(a),retrieve:{sobject:"ValidationRule",id:a},take:p=>{let f=p[0]?.Metadata,l=typeof f=="object"&&f!==null?f.errorConditionFormula:void 0;if(typeof l!="string")return;nt(l)&&(c.onChangeOnly=!0),t.liftedBy&&(c.liftedBy=ce(l).permissions);let o=t.reads?re(l):void 0;o&&o.length>0&&(c.reads=o)},refused:()=>{}})),requests:K}],P,n)}async function Nt(e,r,n,t,s,a={}){let c=[...new Set(r)].filter(y=>O.test(y));if(c.length===0)return[];let p=new Map(c.map(y=>[y.toLowerCase(),y])),f=new Map(c.map((y,R)=>[y,R])),l=await e(oe(c)),o=new Map,u=async(y,R)=>{let A=ie(R,void 0);if(!n)return A;let F=o.get(y);F||(F=n(y).catch(()=>[]),o.set(y,F));let N=m(R).trim().toLowerCase();if(!N)return;let B=A?.toLowerCase(),E=await F;return E.length===0?A:E.find(C=>C.name.toLowerCase()===B)?.name??E.find(C=>C.label?.trim().toLowerCase()===N)?.name},b=(await Promise.all(l.map(async y=>{let R=ue(y.EntityDefinition),A=R===void 0?void 0:p.get(R.toLowerCase()),F=m(y.ValidationName);return!A||!F?[]:[{id:m(y.Id),rule:{objectApiName:A,name:W(m(y.NamespacePrefix),F),message:m(y.ErrorMessage),...de(await u(A,y.ErrorDisplayField))}}]}))).flat().sort((y,R)=>(f.get(y.rule.objectApiName)??0)-(f.get(R.rule.objectApiName)??0)||y.rule.name.localeCompare(R.rule.name));return t&&await At(b,t,s,a),b.map(({rule:y})=>y)}async function Jt(e,r,n,t){let s=[...new Set(r)].filter(u=>O.test(u));if(s.length===0)return{rules:[],notRead:0,requests:0};let a=new Map(s.map(u=>[u.toLowerCase(),u])),c=await e(oe(s)),p=c.requests,f=c.records.flatMap(u=>{let h=ue(u.EntityDefinition),b=h===void 0?void 0:a.get(h.toLowerCase()),y=m(u.ValidationName);return!b||!y?[]:[{id:m(u.Id),objectApiName:b,name:W(m(u.NamespacePrefix),y),read:!1,permissions:[]}]}),l=f.filter(u=>le.test(u.id)),o=(u,h)=>{let b=typeof h=="object"&&h!==null?h.errorConditionFormula:void 0;typeof b=="string"&&(u.read=!0,u.permissions=ce(b).permissions)};return n?p+=await U(n,[{queries:l.slice(0,ae).map(u=>({soql:I(u.id),retrieve:{sobject:"ValidationRule",id:u.id},take:h=>o(u,h[0]?.Metadata),refused:()=>{}})),requests:K}],P,t):await Q(l.slice(0,ot).map(u=>async()=>{try{let h=await e(I(u.id));p+=h.requests,o(u,h.records[0]?.Metadata)}catch{p++}}),P),{rules:f.filter(u=>u.permissions.length>0).map(({objectApiName:u,name:h,permissions:b})=>({objectApiName:u,name:h,permissions:b})),notRead:f.filter(u=>!u.read).length,requests:p}}function Xt(e,r,n,t={}){let s=async a=>(await e(bt(a))).flatMap(c=>typeof c.QualifiedApiName=="string"?[{name:c.QualifiedApiName,...typeof c.Label=="string"?{label:c.Label}:{}}]:[]);return a=>Nt(e,a,s,r,n,t)}var it=class{deps;constructor(r){this.deps=r}async read(r,n,t,s={}){let a=new Set(s.excludedObjects??[]),c=Ze(Ft(t),a),p=[];if(c.length===0)return{gaps:[],unread:[],requests:0};let f=0,l=(i,d,g)=>{p.push({part:i,reason:d,...g!==void 0?{objectApiName:g}:{}})},o=new Map(c.map(i=>[i.toLowerCase(),i])),u=i=>i===void 0?void 0:o.get(i.toLowerCase()),h=new Map(c.map((i,d)=>[i,d])),b=c.filter(i=>O.test(i)),y=[],R=[],A,F,N=new Map,B=new Map,E=new Set,C=(i,d,g)=>async()=>{try{let w=await d();f+=w.requests,g(w.records)}catch(w){f++,l(i,G(w))}},fe=(i,d,g,w)=>async()=>{try{let{fields:S,sent:ft,createable:pt}=await this.deps.describeFields(i,d);ft&&f++,w.set(d,S),w===N&&pt===!1&&E.add(d)}catch(S){f++,l(g,`${d}: ${G(S)}`,d)}};await Q([...b.length>0?[C("validationRules",()=>this.deps.toolingQuery(n,oe(b)),i=>{y=i})]:[],C("duplicateRules",()=>this.deps.query(n,Rt),i=>{R=i}),async()=>{try{f++,A=await this.deps.readLimits(n)}catch(i){F=G(i)}},...c.flatMap(i=>[fe(n,i,"targetFields",N),fe(r,i,"sourceFields",B)])],P);let j=y.flatMap(i=>{let d=u(ue(i.EntityDefinition)),g=m(i.ValidationName);if(!d||!g)return[];let w=m(i.Id);return[{id:le.test(w)?w:null,name:W(m(i.NamespacePrefix),g),objectApiName:d,...de(ie(i.ErrorDisplayField,N.get(d))),message:m(i.ErrorMessage),formula:"notRead",bypasses:[],permissions:[]}]}).sort((i,d)=>(h.get(i.objectApiName)??0)-(h.get(d.objectApiName)??0)||i.name.localeCompare(d.name)),{toolingQueries:M,toolingRetrieves:pe}=this.deps,z=j.filter(i=>i.id!==null).slice(0,M?ae:ot);for(let i of j)i.id===null&&(i.formula="unreadable");let Z=R.flatMap(i=>{let d=u(m(i.SobjectType)),g=W(m(i.NamespacePrefix),m(i.DeveloperName));return!d||!m(i.DeveloperName)?[]:[{objectApiName:d,developerName:g,label:m(i.MasterLabel)||g,fullName:`${m(i.SobjectType)}.${g}`}]}),ge=new Map,me=[];for(let i=0;i<Z.length;i+=rt)me.push(Z.slice(i,i+rt).map(d=>d.fullName));let V,H,he=(i,d)=>{let g=typeof d=="object"&&d!==null?d.errorConditionFormula:void 0;if(typeof g!="string"){i.formula="unreadable";return}i.formula="read",Object.assign(i,ce(g));let w=re(g);w&&w.length>0&&(i.reads=w);let S=ie(d.errorDisplayField,N.get(i.objectApiName));S&&(i.field=S)},ut=async()=>{if(!M||z.length===0)return;let i=await U(d=>M(n,d),[{queries:z.map(d=>({soql:I(d.id),retrieve:{sobject:"ValidationRule",id:d.id},take:g=>he(d,g[0]?.Metadata),refused:g=>{d.formula="unreadable",V??=g}})),requests:K}],P,pe&&(d=>pe(n,d)));f+=i},ye=new Map,Y={},we=[...E].filter(i=>O.test(i)),ct=async()=>{let[i,d]=await Promise.all([qe((g,w)=>this.deps.toolingQuery(g,w),n,we),this.deps.createFacts?this.deps.createFacts(n).then(g=>({facts:g,requests:0})).catch(()=>({facts:{},requests:0})):De(this.deps,n)]);f+=i.requests+d.requests;for(let[g,w]of i.answered)ye.set(g,w);Y=d.facts};await Q([...we.length>0?[ct]:[],...M?[ut]:[],...(M?[]:z).map(i=>async()=>{try{let d=await this.deps.toolingQuery(n,I(i.id));f+=d.requests,he(i,d.records[0]?.Metadata)}catch(d){f++,i.formula="unreadable",V??=G(d)}}),...me.map(i=>async()=>{try{f++;for(let d of await this.deps.readDuplicateRules(n,i)){if(typeof d!="object"||d===null)continue;let g=d,w=m(g.fullName);w&&ge.set(w.toLowerCase(),g)}}catch(d){H??=G(d)}})],P),V!==void 0&&l("validationRuleFormulas",V),H!==void 0&&l("duplicateRuleActions",H);let J=new Set,be=!1;j.some(i=>i.permissions.length>0)&&await C("userPermissions",()=>this.deps.query(n,Ve),i=>{be=!0;for(let d of i)J.add(ze(m(d.NamespacePrefix),m(d.DeveloperName)))})();let Re=[...new Set(j.flatMap(i=>i.permissions.filter(d=>!J.has(d.toLowerCase()))))],dt=Re.length>0?await He(Re,async i=>{let d=[];return await C("permissionSets",()=>this.deps.query(n,i),g=>{d=g})(),d},()=>p.some(i=>i.part==="permissionSets")):void 0,ke=[...j.map(i=>Gt(i,be?J:void 0,dt,s.keepContactPoints===!0?[]:St(i,N.get(i.objectApiName)))),...Z.map(i=>$t(i,ge.get(i.fullName.toLowerCase()))),...c.flatMap(i=>{if(E.has(i))return[Et(i,Me(i,Y,ye.get(i.toLowerCase())),N.get(i)??[],Y)];let d=N.get(i),g=B.get(i);return d&&g?xt(i,d,g,s):[]})],Fe=kt.safeParse(A),ve=F===void 0&&Fe.success?Fe.data.DailyApiRequests:void 0;return ve||l("apiBudget",F??"the limits the org answered hold no DailyApiRequests"),ke.push(Pt(t,s,c[0],ve)),{gaps:Ee(ke),unread:_t(p,h),requests:f}}};function _t(e,r){let n=t=>t===void 0?-1:r.get(t)??r.size;return[...e].sort((t,s)=>n(t.objectApiName)-n(s.objectApiName)||st.indexOf(t.part)-st.indexOf(s.part)||(t.reason<s.reason?-1:t.reason>s.reason?1:0)).map(({part:t,reason:s})=>({part:t,reason:s}))}var Ct={platform:"object_platform_only",setup:"object_setup_only",feature:"object_feature_off",parent:"object_through_parent",user:"object_not_createable"};function Et(e,r,n,t){let s=r==="parent"?Ie(n,t):[];return T({kind:Ct[r],severity:Le(r)?"info":"blocking",objectApiName:e,...s.length>0?{detail:{editOn:s}}:{},decisions:["exclude_object"]})}function St(e,r){if(!e.reads||!r)return[];let n=new Map(r.map(s=>[s.name.toLowerCase(),s])),t=[];for(let s of e.reads){let a=n.get(s.toLowerCase());a&&Oe(a.name,a.type)&&!t.includes(a.name)&&t.push(a.name)}return t}function Gt(e,r,n,t=[]){let s=r?e.permissions.filter(p=>r.has(p.toLowerCase())):[],a=s.length>0?[]:e.permissions.flatMap(p=>{let f=n?.find(l=>l.permission.toLowerCase()===p.toLowerCase());return f?[Se(f)]:[]}),c=e.field?["leave_empty","ignore"]:["ignore"];return T({kind:"validation_rule",severity:s.length>0?"info":"warning",objectApiName:e.objectApiName,...de(e.field),idValue:e.name,detail:{rule:e.name,message:e.message,formula:e.formula,...e.bypasses.length>0?{bypasses:e.bypasses}:{},...s.length>0?{heldBypasses:s}:{},...a.length>0?{assign:a}:{},...t.length>0?{readsUnreachable:[...t]}:{}},decisions:c,...e.field?{defaultDecision:"leave_empty"}:{}})}function $t(e,r){let n=m(r?.actionOnInsert).toLowerCase(),t=n==="block"||n==="allow"?n:"unknown",s=x(r?.operationsOnInsert).map(c=>c.toLowerCase());return T({kind:"duplicate_rule",severity:t==="allow"?"info":"warning",objectApiName:e.objectApiName,idValue:e.developerName,detail:{rule:e.label,developerName:e.developerName,action:t,...t==="allow"?{alert:s.includes("alert")}:{},...t==="allow"?{report:s.includes("report")}:{}},decisions:t==="allow"?["ignore"]:["ignore","exclude_object"],...t==="allow"?{defaultDecision:"ignore"}:{}})}function xt(e,r,n,t){let s=o=>o.toLowerCase(),a=new Set((t.fieldExclusions?.[e]??[]).map(s)),c=new Map(Object.entries(t.fieldMappings?.[e]??{}).map(([o,u])=>[s(o),s(u)])),p=new Set([...c].filter(([o])=>!a.has(o)).map(([,o])=>o)),f=new Map(n.map(o=>[s(o.name),o])),l=o=>{let u=s(o);if(p.has(u))return;let h=f.get(u);return h?a.has(u)||c.has(u)?"excluded":h.createable?void 0:"notCreateableInSource":"notInSource"};return r.flatMap(o=>{let u=l(o.name);if(o.createable&&!o.nillable&&!o.defaultedOnCreate&&u)return[T({kind:"required_field_missing",severity:"blocking",objectApiName:e,field:o.name,detail:{type:o.type,reason:u,...o.referenceTo.length>0?{referenceTo:o.referenceTo}:{},...o.picklistValues.length>0?{values:o.picklistValues}:{}},decisions:["set_default","exclude_object"]})];if(o.type==="reference"&&o.lookupFilter&&!u){let h=o.nillable;return[T({kind:"lookup_filter",severity:"warning",objectApiName:e,field:o.name,detail:{referenceTo:o.referenceTo,optional:h,filterOptional:o.lookupFilter.optional},decisions:h?["leave_empty","ignore"]:["ignore","exclude_object"],...h?{defaultDecision:"leave_empty"}:{}})]}return[]})}function Pt(e,r,n,t){let s=e.nodes[0]?.objectApiName??n,a=vt(e,r),c=a.writes+a.reads,p="warning";if(t&&a.bound!=="unknown"){let f=c>t.Remaining,l=t.Max-t.Remaining+c>yt*t.Max;p=f&&a.bound==="exact"?"blocking":f||l?"warning":"info"}return T({kind:"api_budget",severity:p,objectApiName:s,detail:{calls:c,writes:a.writes,reads:a.reads,estimate:a.bound,...t?{max:t.Max,remaining:t.Remaining}:{budgetRead:!1}},decisions:["ignore"]})}var Ot={blocking:"BLOCKING",warning:"warning",info:"info"},Tt=new Set(["picklist_value_refused","dependent_value_invalid","picklist_value_absent","currency_inactive"]),jt=new Set(["record_type_unmapped","record_type_unavailable"]);function lt(e,r,n=[e.id]){if(Ne(r.ignoredGaps,e.id,n)!==void 0)return"left as it is";let t=e.objectApiName;if(r.excludedObjects?.includes(t))return`${t} left out of the run`;let s=new Set(e.decisions),{field:a,value:c}=e;if(s.has("skip_rows")&&_e((r.skippedRows??[]).filter(o=>o.object===t),e.id,n))return"these rows held back";if(Tt.has(e.kind)&&a!==void 0&&c!==void 0&&(s.has("map_value")||s.has("leave_empty"))){let o=(r.picklistValueMappings??[]).filter(h=>h.object===t&&h.field===a&&h.from===c),u=Ce(o,e,n);if(u?.to===null&&s.has("leave_empty"))return"the field left empty in these rows";if(u&&u.to!==null&&s.has("map_value"))return`written as "${u.to}"`}let p=jt.has(e.kind)?e.value??e.recordType:void 0;if(p!==void 0&&s.has("map_record_type")){let o=r.recordTypeMappings?.find(u=>u.object===t&&u.from===p);if(o)return o.to===null?"written with the object's default record type":`written as record type ${o.to}`}if(a===void 0)return;let f=o=>o.object===t&&o.field===a,l=s.has("set_default")?r.defaultValues?.find(f):void 0;if(l)return`default "${String(l.value)}"`;if(s.has("truncate")&&r.truncateFields?.some(f))return"cut to the field's length";if(s.has("leave_empty")&&r.fieldExclusions?.[t]?.includes(a))return"the field left out of the rows"}function en(e,r){let n=e.gaps.map(t=>t.id);return{...e,gaps:e.gaps.map(t=>{let s=lt(t,r,n);return s===void 0?t:{...t,answeredBy:s}})}}function at(e,r,n,t){if(t)return`the mute lifts it (${t.permission}, in ${t.permissionSet}): ${se(e,!0)}`;let s=r?lt(e,r,n):void 0;return s===void 0?`${Ot[e.severity]}: ${se(e)}`:`answered by the run's decision: ${s} \u2014 ${se(e)}`}var Mt={validationRules:"the validation rules",validationRuleFormulas:"the formulas of some validation rules",duplicateRules:"the duplicate rules",duplicateRuleActions:"what the duplicate rules do on insert",userPermissions:"the custom permissions of the user the run writes as",permissionSets:"the permission sets that hold a bypass of a validation rule the user the run writes as does not",targetFields:"the fields of an object in the target",sourceFields:"the fields of an object in the source",apiBudget:"the daily API requests left"},Lt={notInSource:"the source has no such field",notCreateableInSource:"the source cannot give it",excluded:"the run leaves it out"},q=e=>typeof e=="number"?String(e):"?";function se(e,r=!1){let n=e.detail??{};switch(e.kind){case"required_field_missing":return`required field ${e.field??""} (${m(n.type)}): only the target requires it, and the run does not write it (${Lt[m(n.reason)]??m(n.reason)}): every row is refused unless it is given a value`;case"validation_rule":{let t=e.field?` on ${e.field}`:"",s=x(n.readsUnreachable),a=[...x(n.bypasses).map(p=>`not when ${p}`),...x(n.heldBypasses).length>0?[`kept quiet for this run: the user it writes as holds ${x(n.heldBypasses).join(", ")}`]:[],...n.formula==="notRead"?["formula not read"]:[],...n.formula==="unreadable"?["formula unreadable"]:[],...s.length>0&&!r?[Te(s.map(p=>({field:p})))]:[],...e.field&&!r&&!s.includes(e.field)?[`a row it refuses goes again without ${e.field}`]:[]],c=m(n.message)?`: "${m(n.message)}"`:"";return`validation rule "${m(n.rule)}"${t}${c}${a.length>0?` (${a.join("; ")})`:""}`}case"duplicate_rule":{let t=`duplicate rule "${m(n.rule)}"`;if(n.action==="block")return`${t}: blocks an insert it matches: a row it matches is refused, whatever allowSave says`;if(n.action==="allow"){let s=[n.alert===!0?"an alert":"",n.report===!0?"a report":""].filter(Boolean).join(" and ");return`${t}: allows an insert it matches${s?`, with ${s}`:""}: the run saves it (allowSave=true)`}return`${t}: what it does on insert was not read: a rule that blocks refuses a row it matches`}case"lookup_filter":return`lookup filter on ${e.field??""}: not checked before the run; `+(n.optional===!0?"a lookup it refuses is left empty":"the lookup is required, and a row it refuses is refused");case"object_not_createable":return"the user the run writes as may not create its records in the target: every row is skipped, after the objects written before it, unless the object is left out";case"object_platform_only":return"no user can create its records in the target, the platform writes them itself: the run skips every row of it";case"object_setup_only":return"no user can create its records in the target, not even one with Modify All Data, and no permission set gives Create on it: setup the org keeps as records, or the platform's own; the run skips every row of it";case"object_feature_off":return"even a user with Modify All Data may not create its records in the target, though a permission set can give Create on it: a feature or licence the target has not turned on for that user keeps it closed; turn it on, or every row is skipped, after the objects written before it, unless the object is left out";case"object_through_parent":{let t=x(n.editOn);return`no permission set gives Create on it: ${t.length>0?`the user the run writes as creates its records with Edit on ${t.join(" and ")}, which they hang from, or no user can`:"the records they hang from may open it to the user the run writes as, or no user can: read as a user with Modify All Data, the target would tell"}; every row is skipped, after the objects written before it, unless the object is left out`}case"api_budget":{let t=`about ${q(n.calls)} call(s) (${q(n.writes)} write(s) of 200 rows, ${q(n.reads)} read(s))`,s=n.estimate==="atMost"?`at most ${t}, counted on whole tables`:n.estimate==="unknown"?"an unknown number of calls: an object was never counted":t,a=n.budgetRead===!1?"the daily requests left could not be read":`${q(n.remaining)} of ${q(n.max)} daily requests left`;return`API budget: the run takes ${s}; ${a}`}default:return e.kind}}function Dt(e,r,n){return Ge(e).map(({permission:t,permissionSet:s,others:a})=>{if(!s)return` ${t}: no permission set of ${r} holds it: an admin creates one that includes it`;let c=a.length>0?`; also held by ${a.map(f=>f.name).join(", ")}`:"",p=n?`: ${Pe(s.name,r,n)}`:"";return` ${t}: held by permission set ${s.name}, the smallest${c}${p}`})}function tn(e,r,n={}){let t=[`target gaps: what ${r} holds against the rows, read from its metadata`],s=e.gaps.map(l=>l.id),a=e.gaps.filter(l=>l.kind==="api_budget"),c=e.gaps.filter(l=>l.kind!=="api_budget"),p=[...new Set(c.map(l=>l.objectApiName))].sort((l,o)=>l.localeCompare(o));for(let l of p){t.push(` ${l}`);for(let o of c.filter(u=>u.objectApiName===l)){let u=$e(o,n.lifted);t.push(` ${at(o,n.decisions,s,u)}`),u||t.push(...Dt(o,r,n.username))}}c.length===0&&t.push(e.unread.length>0?" nothing found in what could be read":" no validation rule, duplicate rule, field only the target requires or lookup filter");for(let l of a)t.push(` ${at(l,n.decisions,s)}`);let f=c.filter(l=>l.detail?.formula==="notRead").length;f>0&&t.push(` ${f} validation rule formula(s) not read: the read takes ${n.formulasBound??ae} at most`);for(let{part:l,reason:o}of e.unread)t.push(` ${Mt[l]??l} could not be read: ${o}`);return t.push(` read in ${e.requests} request(s) to ${r}`),t}export{ot as a,K as b,ae as c,Ht as d,oe as e,bt as f,I as g,Rt as h,ce as i,vt as j,Yt as k,Nt as l,Jt as m,Xt as n,it as o,lt as p,en as q,tn as r};
|
|
@@ -4,7 +4,7 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a as _}from"./chunk-
|
|
7
|
+
import{a as _}from"./chunk-22L43JMK.mjs";import{k as S}from"./chunk-J347SPU6.mjs";var x="#N/A";function I(e,t,r){let n=[],o=new Map,a=t.map(u=>{let m=new Map;for(let[b,h]of D(e,u)){let p=b.toLowerCase(),i=o.get(p);i===void 0&&(i=n.push(b)-1,o.set(p,i)),m.set(i,$(h))}return m}).map(u=>n.map((m,b)=>u.get(b)??"")),l=[n.map(C).join(",")];for(let u of a)l.push(u.length===1&&u[0]===""?'""':u.map(C).join(","));return{text:`${l.join(`
|
|
8
8
|
`)}
|
|
9
9
|
`,columns:n,rows:a,identity:U(e,n,r)}}function y(e,t,r){let n=r==="exact"?E:A;return JSON.stringify(t.map(o=>n(e[o]??"")))}function ue(e){let t=new Map,r=new Set;return e.rows.forEach((n,o)=>{let c=y(n,e.identity,"canonical"),a=t.get(c);a===void 0?t.set(c,o):(r.add(a),r.add(o))}),r}function ie(e){let t=[];for(let[r,n]of e){let o=A(n);o!==""&&t.push(`${r.toLowerCase()}${o}`)}return t.sort().join("")}function J(e,t){return e.map(r=>{let n=t[r];return typeof n=="string"?n:n==null?"":String(n)})}function D(e,t){if(e==="delete"||e==="hardDelete")return[["Id",t.Id]];let r=[];for(let[n,o]of Object.entries(t))n==="attributes"||n==="type"||e==="insert"&&n.toLowerCase()==="id"||O(n,o,r);return r}function O(e,t,r){if(!N(t)){r.push([e,t]);return}for(let[n,o]of Object.entries(t))n!=="attributes"&&O(`${e}.${n}`,o,r)}function N(e){if(e===null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function $(e){return e===void 0?"":e===null?x:typeof e=="string"?e:e instanceof Date?Number.isNaN(e.getTime())?"":e.toISOString():typeof e=="object"?JSON.stringify(e):String(e)}function C(e){return/[",\r\n]/.test(e)?`"${e.replaceAll('"','""')}"`:e}function U(e,t,r){let n=e==="insert"?void 0:e==="upsert"?r:"Id",o=n===void 0?-1:t.findIndex(c=>c.toLowerCase()===n.toLowerCase());return o>=0?[o]:t.map((c,a)=>a)}function E(e){return e===x?"":e.replace(/\r\n?/g,`
|
|
10
10
|
`)}var T=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/,v=/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/;function A(e){let t=E(e),r=t.toLowerCase();if(r==="true"||r==="false")return r;if(T.test(t))return String(Number(t));let n=v.exec(t);if(n){let o=t.includes("T")&&n[1]===void 0,c=Date.parse(o?`${t}Z`:t);if(!Number.isNaN(c))return`@${c}`}return _(t)??t}var F="No result returned by Bulk API job",K="Record not processed by Bulk API job",B=10,w=5e3;function H(e){if(e===!0||e==="true")return!0;if(e===!1||e==="false")return!1}function z(e,t,r){let n=t.rows.length,o=[],c=[],a=0,l=[],u=new Array(n).fill(!1),m=(i,s,g)=>{s>=0&&s<n&&!u[s]?(u[s]=!0,o.push({recordIndex:s,id:i,success:!0,...g!==void 0?{created:g}:{}})):(a++,i!==void 0&&c.push(i))},b=(i,s,g)=>{s>=0&&s<n&&!u[s]?(u[s]=!0,o.push({recordIndex:s,success:!1,error:i,...g?{state:g}:{}})):l.push(i)},h=r?` (${r})`:"";if(Array.isArray(e))e.forEach((i,s)=>{i.success?m(i.id,s):b(i.errors?.join(", ")??"Unknown error",s)});else{let i=[];for(let f of e.successfulResults??[]){let k=typeof f.sf__Id=="string"?f.sf__Id:void 0,R=H(f.sf__Created);i.push({row:f,settle:d=>m(k,d,R),orphan:()=>m(k,-1)})}for(let f of e.failedResults??[]){let k=typeof f.sf__Error=="string"&&f.sf__Error.length>0?f.sf__Error:"Unknown error";i.push({row:f,settle:R=>b(k,R),orphan:()=>b(k,-1)})}let s=e.unprocessedRecords;for(let f of Array.isArray(s)?s:[]){let k=`${K}${h}`;i.push({row:f,settle:R=>b(k,R,"unprocessed"),orphan:()=>b(k,-1)})}let g=i;for(let f of["exact","canonical"])g.length>0&&(g=W(f,g,t,u));for(let f of g)f.orphan()}let p=`${F}${h}${Z(c,l)}`;for(let i=0;i<n;i++)u[i]||b(p,i,"no-result");return o.sort((i,s)=>i.recordIndex-s.recordIndex),{outcomes:o,unattributedSuccessIds:c,unattributedSuccesses:a,unattributedFailures:l}}function W(e,t,r,n){let o=new Map;r.rows.forEach((a,l)=>{if(n[l])return;let u=y(a,r.identity,e),m=o.get(u);m?m.push(l):o.set(u,[l])});let c=[];for(let a of t){let l=y(J(r.columns,a.row),r.identity,e),u=o.get(l)?.shift();u===void 0?c.push(a):a.settle(u)}return c}function Z(e,t){let r=[];if(e.length>0){let n=e.slice(0,B).join(", "),o=e.length>B?` and ${e.length-B} more`:"";r.push(`wrote ${e.length} record(s) no row was matched to: ${n}${o}`)}return t.length>0&&r.push(`did not write ${t.length} row(s) no row was matched to, the first for: ${t[0]}`),r.length>0?`; the job ${r.join("; it ")}`:""}function V(e){let t;try{t=e.id}catch{return}return typeof t=="string"&&/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/.test(t)?t:void 0}function q(e){if(e.state!=="JobComplete")return e.errorMessage||`job ${e.state}`}async function X(e){try{await e.abort()}catch{}}var P=class{threshold;constructor(t=S.REST_API_BATCH_SIZE){this.threshold=t}shouldUseBulkApi(t){return t>this.threshold}getThreshold(){return this.threshold}async executeBulk(t,r,n,o,c){if(!t.bulkManager.canStartNewJob())throw new Error("Maximum concurrent bulk jobs reached");let a=I(n,o,c),l=t.connection.bulk2.createJob({operation:n,object:r,...c?{externalIdFieldName:c}:{}}),u=l.id??`bulk-${crypto.randomUUID()}`,m={id:u,operation:n,object:r,state:"UploadComplete",numberRecordsProcessed:0,numberRecordsFailed:0,totalProcessingTime:0,createdDate:new Date().toISOString()};t.bulkManager.registerJob(m);try{await l.open();let b=V(l);b!==void 0&&t.onOpened?.(b);let h=0;if(t.signal?.aborted||(await l.uploadData(a.text),h=o.length),t.signal?.aborted)return await X(l),t.bulkManager.updateJobState(u,"Aborted"),{totalRecords:h,successCount:0,failureCount:0,failures:[],jobId:u,usedBulkApi:!0,successIds:[],outcomes:[],aborted:!0};await l.close();let p=await l.check();for(let d=0;p.state==="InProgress"||p.state==="UploadComplete";d++){t.bulkManager.updateJobState(u,p.state),t.onProgress?.(p.numberRecordsProcessed??0,o.length);let M=t.pollIntervalMs?.(d)??w;await new Promise(j=>setTimeout(j,M)),p=await l.check()}let i=await l.getAllResults(),s=z(i,a,q(p)),g=s.outcomes.filter(d=>!d.success).map(d=>({recordIndex:d.recordIndex,error:d.error??"Unknown error"}));for(let d of s.unattributedFailures)g.push({recordIndex:-1,error:d});let f=s.outcomes.filter(d=>d.success&&d.id!==void 0).map(d=>d.id).concat(s.unattributedSuccessIds),k=s.outcomes.filter(d=>d.success).length+s.unattributedSuccessIds.length,R=p.state==="JobComplete"?"JobComplete":"Failed";return t.bulkManager.updateJobState(u,R),t.bulkManager.updateJobCounts(u,p.numberRecordsProcessed??o.length,g.length),{totalRecords:o.length,successCount:k,failureCount:g.length,failures:g,jobId:u,usedBulkApi:!0,successIds:f,outcomes:s.outcomes,...s.unattributedSuccessIds.length>0?{unmatchedIds:s.unattributedSuccessIds}:{},...s.unattributedSuccesses>0?{unmatchedWrites:s.unattributedSuccesses}:{}}}catch(b){throw t.bulkManager.updateJobState(u,"Failed"),b}}};var G=3,Q=3,Y=24,ee=750,L=()=>w,be=e=>[5e3,1e4,2e4][e]??3e4,te=60;function ne(e){return Q+e.stateReads+(e.resultReads??G)}function re(e,t="delete"){let r=t==="save"?te:ee;return Y+Math.max(0,e)/r}function oe(e,t=L,r="delete"){let n=re(e,r)*1e3,o=0,c=0;for(;o<n;)o+=Math.max(1,t(c)),c++;return 1+c}function ge(e){return ne({stateReads:oe(e,L,"save")})}export{I as a,ue as b,ie as c,z as d,V as e,q as f,X as g,P as h,G as i,be as j,ne as k,re as l,oe as m,ge as n};
|
|
@@ -4,6 +4,6 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{
|
|
7
|
+
import{q as m}from"./chunk-H6BHWAX7.mjs";import{H as d,d as w,z as b}from"./chunk-4CSBZZAL.mjs";import{$c as u}from"./chunk-J347SPU6.mjs";import{b as R,e as A,k as j,l as p,v as P}from"./chunk-WZQEK4WT.mjs";import{randomBytes as O}from"node:crypto";import{createReadStream as T}from"node:fs";import{appendFile as C,open as $,readFile as D,rename as F,rm as _}from"node:fs/promises";import{join as k}from"node:path";import{createInterface as M}from"node:readline";var U=2e3,a=15,x=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,W=2e3,z="spool.json",h="a rewind";function v(r){return typeof r=="string"&&x.test(r)?r.slice(0,a):void 0}var g=class{bytes=Buffer.alloc(a*1024);flags=new Uint16Array(1024);slots=new Uint32Array(2048);used=0;get size(){return this.used}find(t){let e=this.slots.length-1;for(let s=m(t)&e;;s=s+1&e){let n=this.slots[s];if(n===0)return-1;if(this.holds(n-1,t))return n-1}}holds(t,e){let s=t*a;for(let n=0;n<a;n++)if(this.bytes[s+n]!==e.charCodeAt(n))return!1;return!0}keyAt(t){let e=t*a;return this.bytes.toString("latin1",e,e+a)}place(t,e){let s=this.slots.length-1,n=m(e)&s;for(;this.slots[n]!==0;)n=n+1&s;this.slots[n]=t+1}add(t,e=0){let s=v(t);if(s===void 0)throw new RangeError(`Not a Salesforce id: ${String(t)}`);let n=this.find(s);if(n>=0)return this.flags[n]|=e,!1;if((this.used+1)*2>this.slots.length){let o=this.slots;this.slots=new Uint32Array(o.length*2);for(let i of o)i!==0&&this.place(i-1,this.keyAt(i-1))}if((this.used+1)*a>this.bytes.length){let o=Buffer.alloc(this.bytes.length*2);this.bytes.copy(o),this.bytes=o;let i=new Uint16Array(this.flags.length*2);i.set(this.flags),this.flags=i}return this.bytes.write(s,this.used*a,a,"latin1"),this.flags[this.used]=e,this.place(this.used,s),this.used++,!0}has(t){let e=v(t);return e!==void 0&&this.find(e)>=0}count(t){let e=0;for(let s=0;s<this.used;s++)t(this.flags[s])&&e++;return e}flagsOf(t){let e=v(t);if(e===void 0)return 0;let s=this.find(e);return s<0?0:this.flags[s]}},B=p({version:P(1),objects:j(p({objectApiName:R().min(1),count:A().int().nonnegative()}))});function S(r,t){return k(r,`${u(t)}.ids`)}async function G(r,t){let e=`${r}.${process.pid}-${O(4).toString("hex")}.tmp`,s=await $(e,"wx",w);try{try{await s.writeFile(t,"utf8"),await s.sync()}finally{await s.close()}await F(e,r)}catch(n){throw await _(e,{force:!0}),n}}async function J(r){let t=await $(r,"r+");try{await t.sync()}finally{await t.close()}}async function L(r,t,e=h){for(let{objectApiName:s,count:n}of t)n>0&&await J(S(r,s));return await G(k(r,z),`${JSON.stringify({version:1,objects:t})}
|
|
8
8
|
`),new y(r,t,e)}var I=class{constructor(t,e=h){this.dir=t;this.act=e}dir;act;order=[];counts=new Map;lines=new Map;written=new Set;keys=new g;made=!1;async add(t,e){if(!this.keys.add(e))return!1;let s=this.lines.get(t);return s||(u(t),s=[],this.lines.set(t,s),this.order.push(t)),s.push(e),this.counts.set(t,(this.counts.get(t)??0)+1),s.length>=W&&await this.flush(t),!0}async flush(t){let e=this.lines.get(t)??[];this.made||(await b(this.dir),this.made=!0);let s=!this.written.has(t);e.length===0&&!s||(await C(S(this.dir,t),e.map(n=>`${n}
|
|
9
9
|
`).join(""),{encoding:"utf8",mode:w,flag:s?"w":"a"}),this.written.add(t),this.lines.set(t,[]))}get objects(){return this.order.map(t=>({objectApiName:t,count:this.counts.get(t)??0}))}async finish(t){this.made||(await b(this.dir),this.made=!0);for(let e of this.order)await this.flush(e);return L(this.dir,t?t(this.objects):this.objects,this.act)}},y=class r{constructor(t,e,s=h){this.dir=t;this.objects=e;this.act=s}dir;objects;act;get count(){return this.objects.reduce((t,e)=>t+e.count,0)}static async open(t,e=h){let s;try{s=JSON.parse(await D(k(t,z),"utf8"))}catch{throw new d("damaged",`The list of what ${e} sets out to do is not on this machine.`)}let n=B.safeParse(s);if(!n.success)throw new d("damaged",`The list of what ${e} sets out to do does not read as one.`);for(let{objectApiName:o}of n.data.objects)u(o);return new r(t,n.data.objects,e)}async*pages(t,e=U){let s=this.objects.find(c=>c.objectApiName===t);if(!s||s.count===0)return;let n=()=>new d("damaged",`The ${t} records ${this.act} sets out to act on are not as they were written.`),o=Math.max(1,Math.floor(e)),i=T(S(this.dir,t),{encoding:"utf8"}),f=M({input:i,crlfDelay:1/0}),E=0,l=[];try{for await(let c of f)if(c!==""){if(!x.test(c))throw n();E++,l.push(c),l.length>=o&&(yield l,l=[])}}catch(c){throw c.code==="ENOENT"?n():c}finally{f.close(),i.destroy()}if(E!==s.count)throw n();l.length>0&&(yield l)}},N=class r{constructor(t,e){this.spool=t;this.keys=e}spool;keys;static async of(t,e){return new r(await t.finish(e),t.keys)}static async open(t,e=h){let s=await y.open(t,e),n=new g;for(let{objectApiName:o}of s.objects)for await(let i of s.pages(o))for(let f of i)n.add(f);return new r(s,n)}get objects(){return this.spool.objects}pages(t){return this.spool.pages(t)}has(t){return this.keys.has(t)}};export{U as a,g as b,S as c,L as d,I as e,y as f,N as g};
|
|
@@ -0,0 +1,7 @@
|
|
|
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{l as p}from"./chunk-35B73566.mjs";import{e as m}from"./chunk-TYUYPFDJ.mjs";import{createHash as M,randomBytes as z}from"node:crypto";import{createHash as y,createHmac as S}from"node:crypto";var h="SANDFORGE_FROZEN_SALT",B=["keep","clear","firstName","lastName","companyName","phoneE164","email","registrationSIV","contractNumber","postalCodeGeneralize","dateMonthStart","dateShift","geoRound1","kmRound10"],g=class extends Error{constructor(){super(`No pseudonymization salt. In VS Code, the first extraction makes one and keeps it in the editor's secret storage, which could not keep it here. On the command line, give it with --salt-file <file>, or set ${h} (bash or zsh: export ${h}="<salt>"; PowerShell: $env:${h} = "<salt>") and start VS Code from that shell. Use the salt the dataset was built with: another one gives the same records other pseudonyms.`),this.name="MissingSaltError"}},O=["Alix","Camille","Dominique","\xC9loi","Faustine","Gabin","H\xE9lo\xEFse","Ibrahim","Jasmine","Kylian","L\xE9a","Mathis","Nour","Oc\xE9ane","Paul","Quitterie","Rayan","Salom\xE9","Th\xE9o","Ursule","Victor","Wendy","Xavier","Yasmine","Zacharie","Ambre","Bastien","Chlo\xE9","Dorian","Emma","Fabien","Gabrielle","Hugo","In\xE8s","Jules","Klara","Louis","Manon","No\xE9","Oph\xE9lie"],L=["Arnaud","Berthelot","Chevallier","Deschamps","Etcheverry","Fontaine","Guibert","Hamonic","Imbert","Jacquin","Kermarrec","Lefebvre","Mignard","Noirot","Ollivier","Perrin","Quentin","Rochefort","Seguin","Thibault","Uberti","Vasseur","Wagner","Xuereb","Yverneau","Zimmermann","Aubry","Barbier","Charpentier","Delattre","Esnault","Fournier","Gosselin","Hervieux","Leloup","Marchand","Navarro","Pasquier","Renard","Sauvage"],b=["Aster","Boreal","C\xE9drat","Delta","Ellipse","Fulmen","Granit","Halcyon","Isatis","Jaspe","Kelvin","Lumen","M\xE9ridien","Noroit","Obsidienne","Pulsar"],F=["Conseil","Services","Industries","Solutions","Groupe","SAS","Partenaires","Logistique"],N="ABCDEFGHJKLMNPRSTUVWXYZ",E=/^(\d{4})-(\d{2})-(\d{2})$/,$=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d{1,3})?(Z|[+-]\d{2}:?\d{2})$/;function T(a){return Date.parse(a.replace(/([+-]\d{2})(\d{2})$/,"$1:$2"))}var k=864e5,l=class{salt;constructor(e){if(!e)throw new g;this.salt=e}get saltFingerprint(){return y("sha256").update(this.salt).digest("hex").slice(0,12)}get dateShiftDays(){return 200+y("sha256").update(`${this.salt}|dateShift-offset`).digest().readUInt32BE(0)%201}pseudonymize(e,t){if(t==null)return t;switch(e){case"keep":return t;case"clear":return"";case"firstName":return this.pick(e,String(t),O);case"lastName":return this.pick(e,String(t),L);case"companyName":return this.companyName(String(t));case"phoneE164":return this.phoneE164(String(t));case"email":return this.email(String(t));case"registrationSIV":return this.registrationSIV(String(t));case"contractNumber":return this.contractNumber(String(t));case"postalCodeGeneralize":return this.postalCodeGeneralize(String(t));case"dateMonthStart":return this.dateMonthStart(String(t));case"dateShift":return this.dateShift(t);case"geoRound1":return this.roundNumber(t,1);case"kmRound10":return this.roundTo(t,10)}}digest(e,t){return S("sha256",this.salt).update(`${e}|${t}`).digest()}*bytes(e,t){let n=this.digest(e,t),r=0;for(;;){for(let i of n)yield i;r+=1,n=S("sha256",this.salt).update(`${e}|${t}|#${r}`).digest()}}pick(e,t,n){let r=this.digest(e,t);return n[r.readUInt32BE(0)%n.length]}companyName(e){let t=this.digest("companyName",e),n=b[t.readUInt32BE(0)%b.length],r=F[t.readUInt32BE(4)%F.length];return`${n} ${r}`}phoneE164(e){let t=this.bytes("phoneE164",e),n="";for(let r=0;r<4;r++)n+=String(t.next().value%10);return`+3363998${n}`}email(e){return`user-${this.digest("email",e).subarray(0,4).toString("hex")}@example.invalid`}registrationSIV(e){let t=this.bytes("registrationSIV",e),n=()=>N[t.next().value%N.length],r=()=>String(t.next().value%10);return`${n()}${n()}-${r()}${r()}${r()}-${n()}${n()}`}contractNumber(e){let t=this.bytes("contractNumber",e),n="";for(let r of e)r>="0"&&r<="9"?n+=String(t.next().value%10):r>="A"&&r<="Z"?n+=String.fromCharCode(65+t.next().value%26):r>="a"&&r<="z"?n+=String.fromCharCode(97+t.next().value%26):n+=r;return n}postalCodeGeneralize(e){let t=e.trim();if(t.length<=2)return t;if(/^\d+$/.test(t))return t.slice(0,2)+"0".repeat(t.length-2);let n=t.slice(0,2);for(let r of t.slice(2))r>="0"&&r<="9"?n+="0":r>="A"&&r<="Z"||r>="a"&&r<="z"?n+="X":n+=r;return n}dateMonthStart(e){let t=E.exec(e)??$.exec(e);return t?`${t[1]}-${t[2]}-01`:""}dateShift(e){if(typeof e=="string"&&E.test(e))return new Date(Date.parse(`${e}T00:00:00Z`)-this.dateShiftDays*k).toISOString().slice(0,10);if(typeof e=="string"&&$.test(e)){let t=T(e);if(Number.isFinite(t))return new Date(t-this.dateShiftDays*k).toISOString()}return""}roundNumber(e,t){let n=typeof e=="number"?e:Number(String(e).trim());if(!Number.isFinite(n))return"";let r=10**t,i=Math.round(n*r)/r;return typeof e=="number"?i:String(i)}roundTo(e,t){let n=typeof e=="number"?e:Number(String(e).trim());if(!Number.isFinite(n))return"";let r=Math.round(n/t)*t;return typeof e=="number"?r:String(r)}};var P=80,G=40,w=1e4,v=64,x=".invalid",f=p,I=/[A-Za-z0-9.!#$%&'*+/=?^_`{|}~-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+/g,U=/\+?(?<!\d)\d(?:[\s.()/-]{0,2}\d){6,}/g;function R(a){return/^(?:(?:00)?330?|0)63998\d{4}$/.test(a.replace(/\D/g,""))}function C(a){return`+3363998${a.replace(/\D/g,"").slice(-4)}`}var K=/^[\d\s.()/+-]+$/;function A(a,e){if(!K.test(a))return null;let t=e.slice(3),n=/^[\s(]*\+/.test(a)?[`33${t}`,`330${t}`]:[`0${t}`,`33${t}`,`330${t}`,`0033${t}`,`00330${t}`],r=a.replace(/\D/g,"").length,i=n.find(o=>o.length===r);if(i===void 0)return null;let s=0;return a.replace(/\d/g,()=>i[s++])}function _(a,e={}){let t=[];for(let n of a){let r=(n.type??"").toLowerCase(),i=m(n.name,r);if(!i)continue;let s=r==="email"||r==="phone",o=r==="email"?P:r==="phone"?G:0,d=n.length!==void 0&&n.length>0?n.length:o;t.push({name:e[n.name]??n.name,kind:i,typed:s,...d>0?{maxLength:d}:{},...n.externalId===!0?{key:!0}:{}})}return t}function q(a,e={}){let t=new Map(_(a,e).map(n=>[n.name.toLowerCase(),n]));return n=>{let r=t.get(n.toLowerCase());if(r)return{kind:r.kind,...r.maxLength!==void 0?{maxLength:r.maxLength}:{}}}}var D=class{pseudonymizer;upsertKeys;drawnFor=new Map;taken=new Set;exhausted=0;counted=new Map;refusedForms=new Map;constructor(e=z(32).toString("hex"),t={}){this.pseudonymizer=new l(e),this.upsertKeys=t.upsertKeys===!0}forObject(e,t,n={}){let r=_(t,n);if(r.length!==0)return i=>{for(let s of r){let o=i[s.name];if(typeof o!="string")continue;let d=this.neutralize(s,o);d!==o&&(d===null?delete i[s.name]:i[s.name]=d,this.count(e,s))}}}email(e,t=P,n=!1){let r=e.trim();if(r===""||f.test(r))return e;let i=`${r}${x}`;if(i.length<=t)return i;let s=this.shortAddress(r,n);return s.length<=t?s:null}phone(e,t){return/\d/.test(e)?R(e)?(this.taken.add(C(e)),e):this.fictional(e,t):e}countForms(e,t){for(let{field:n,kind:r,how:i}of t){let s=`${e}\0${n}`,o=this.refusedForms.get(s)??{objectApiName:e,field:n,kind:r,otherForm:0,withoutField:0};o[i]+=1,this.refusedForms.set(s,o)}}report(){let e=[],t=0;for(let[n,r]of this.counted)for(let[i,{kind:s,values:o}]of r)e.push({objectApiName:n,field:i,kind:s,values:o}),t+=o;return{neutralized:!0,fields:e,values:t,...this.exhausted>0?{numbersExhausted:this.exhausted}:{},...this.refusedForms.size>0?{refusedForms:[...this.refusedForms.values()].map(n=>({...n}))}:{}}}neutralize(e,t){let n=this.upsertKeys&&e.key===!0;return e.typed?e.kind==="email"?this.email(t,e.maxLength,n):this.phone(t,e.maxLength):e.kind==="email"?this.addressesIn(t,e.maxLength,n):this.numbersIn(t,e.maxLength)}addressesIn(e,t,n=!1){let r=o=>t===void 0||o.length<=t,i=e.replace(I,o=>f.test(o)?o:`${o}${x}`);if(i===e||r(i))return i;let s=e.replace(I,o=>f.test(o)?o:this.shortAddress(o,n));return r(s)?s:null}numbersIn(e,t){let n=d=>t===void 0||d.length<=t,r=!1,i=d=>e.replace(U,u=>{if(R(u))return this.taken.add(C(u)),u;let c=this.drawnNumber(u);return c===null?(r=!0,u):A(u,c)??(d?`0${c.slice(3)}`:c)}),s=i(!1);if(r)return null;if(s===e||n(s))return s;let o=i(!0);return n(o)?o:null}fictional(e,t){let n=this.drawnNumber(e);if(n===null)return null;let r=A(e,n);if(r!==null&&(t===void 0||r.length<=t))return r;if(t===void 0||n.length<=t)return n;let i=`0${n.slice(3)}`;return i.length<=t?i:null}drawnNumber(e){let t=e.replace(/[^\d+]/g,""),n=this.drawnFor.get(t);if(n!==void 0)return n;if(this.taken.size>=w)return this.exhausted+=1,null;let r=s=>String(this.pseudonymizer.pseudonymize("phoneE164",s)),i=r(t);for(let s=1;this.taken.has(i)&&s<=v;s+=1)i=r(`${t}#${s}`);for(let s=Number(i.slice(-4));this.taken.has(i);)s=(s+1)%w,i=`+3363998${String(s).padStart(4,"0")}`;return this.drawnFor.set(t,i),this.taken.add(i),i}shortAddress(e,t=!1){let n=e.toLowerCase();return t?`user-${M("sha256").update(n).digest("hex").slice(0,16)}@example.invalid`:String(this.pseudonymizer.pseudonymize("email",n))}count(e,t){let n=this.counted.get(e)??new Map,r=n.get(t.name)??{kind:t.kind,values:0};r.values+=1,n.set(t.name,r),this.counted.set(e,n)}};export{h as a,B as b,g as c,l as d,P as e,w as f,_ as g,q as h,D as i};
|
|
@@ -4,5 +4,5 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{g as s}from"./chunk-
|
|
7
|
+
import{g as s}from"./chunk-SZOJ7BEJ.mjs";function d(e){return e.map(({objectApiName:t,why:o,count:i})=>({objectApiName:t,count:i,note:s(i,o)}))}var a=/^\d+\.\d+\.\d+$/,u=/^[0-9a-f]{12}$/,r=class extends Error{constructor(t){super(t),this.name="ManifestError"}};function l(e){let t=(e.now?.()??new Date).toISOString(),o={version:e.version,status:"frozen",frozenAt:t,source:e.source,saltFingerprint:e.saltFingerprint,rulesVersion:e.rulesVersion,volumetry:e.volumetry,controls:{nonReidentification:e.nonReidentification,dryRunLoad:null,author:e.author,date:t},...e.coverage?{coverage:e.coverage}:{}};return n(o),o}function n(e){if(!a.test(e.version))throw new r(`version must be semver, got ${JSON.stringify(e.version)}`);if(e.status!=="frozen")throw new r(`status must be "frozen", got ${JSON.stringify(e.status)}`);if(!e.frozenAt)throw new r("frozenAt is required");if(!e.source?.orgId||!e.source.decisionDate)throw new r("source.orgId and source.decisionDate are required");if(!u.test(e.saltFingerprint))throw new r("saltFingerprint must be 12 lowercase hex chars of the salt SHA-256");if(!a.test(e.rulesVersion))throw new r(`rulesVersion must be semver, got ${JSON.stringify(e.rulesVersion)}`);if(typeof e.volumetry?.budgetMax!="number"||!e.volumetry.measured)throw new r("volumetry.budgetMax and volumetry.measured are required");if(!e.controls?.nonReidentification)throw new r("controls.nonReidentification is required");if(!e.controls.author||!e.controls.date)throw new r("controls.author and controls.date are required");let t=e.coverage;if(t!==void 0&&(typeof t.objects!="number"||typeof t.truncated!="boolean"||typeof t.maxNodes!="number"||!Array.isArray(t.unboundedObjects)||!Array.isArray(t.filesLeftOut)||t.leftToThePlatform!==void 0&&!Array.isArray(t.leftToThePlatform)||t.exclusionCosts!==void 0&&!Array.isArray(t.exclusionCosts)||t.requiredLeftEmpty!==void 0&&!Array.isArray(t.requiredLeftEmpty)||t.keptWithoutARule!==void 0&&!Array.isArray(t.keptWithoutARule)||t.encryptedNotKept!==void 0&&!Array.isArray(t.encryptedNotKept)))throw new r("coverage, when present, needs objects, truncated, maxNodes, unboundedObjects and filesLeftOut, and a list of what it left to the platform, of what its exclusions cost, of the required fields the rules leave empty, of the fields kept without a rule, or of the encrypted fields not kept, if it names any")}function c(e){return n(e),`${JSON.stringify(e,null,2)}
|
|
8
8
|
`}function g(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new r("Manifest must be a JSON object");let t=e;return n(t),t}export{d as a,l as b,c,g as d};
|
|
@@ -0,0 +1,10 @@
|
|
|
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 Mt,d as Ft}from"./chunk-4NSXPONF.mjs";import{a as rn,c as jn,d as De,e as Nt,f as jt,g as Lt,h as vt,j as Bt,l as Hn,m as Kn}from"./chunk-XBYXT74L.mjs";import{d as un,f as kn,g as bt,h as At,i as Rt,k as Ot,l as Nn,m as zn}from"./chunk-4VLP6RHC.mjs";import{a as xn}from"./chunk-VKREON6Q.mjs";import{B as Wn}from"./chunk-3LRFPGYZ.mjs";import{A as qn,B as ae,C as Pt,E as Re,F as bn,G as Dt,e as ut,i as se,l as sn,p as Un,q as yt,r as He,s as kt,t as Ct,x as St,y as It,z as xe}from"./chunk-DLSU66MY.mjs";import{b as Z,e as Ke,g as Gn}from"./chunk-ATQML7ZK.mjs";import{J as mt,a as gt,b as ht,d as ln,o as wt,x as pt,z as Dn}from"./chunk-4CSBZZAL.mjs";import{b as yn,d as We,e as lt}from"./chunk-GP5J3DGS.mjs";import{i as ft}from"./chunk-INIT2UKJ.mjs";import{E as fn}from"./chunk-4XROG5CT.mjs";import{f as ct,g as le,h as Se,i as dt,p as Pn}from"./chunk-DAUX63UB.mjs";import{a as Me,q as In,r as ie}from"./chunk-SZOJ7BEJ.mjs";import{h as Sn}from"./chunk-TZE3Y7IQ.mjs";import{b as Be}from"./chunk-CA5NAXSU.mjs";import{$c as Ae}from"./chunk-J347SPU6.mjs";import{b as at,k as On,l as Cn}from"./chunk-WZQEK4WT.mjs";import{randomBytes as Pi}from"node:crypto";import{appendFile as Di,readdir as Ni,rm as ji}from"node:fs/promises";import{join as $n}from"node:path";import{appendFile as To,rm as ot}from"node:fs/promises";import{join as _o}from"node:path";import{appendFile as Ro}from"node:fs/promises";import{join as Oo}from"node:path";var En=ut*10,Co=2e3,So="005",Io=["Id","IsDeleted","CreatedDate","LastModifiedById","LastModifiedDate","LatestPublishedVersionId","ContentSize"],zt=1,qt=2,Ht=4,Et=8,Qn=16,vn=32,Bn=64,Tt=1,_t=2,$t=4,Ln=32768,Mn={toDelete:["createdSince","broughtBackSince"],comesBack:["inBin","withParent","deletedWhileTaken"],lost:["goneForGood","toRecreate"]},Vn={toDelete:["createdSince","broughtBackSince","comesBackWithParent"],comesBack:["inBin","withParent","deletedWhileTaken"],lost:["goneForGood","deletedWithCreatedParent","deletedWithParentOutside"]};function Ue(e){return typeof e=="string"&&e.length>=15?e.slice(0,15):void 0}function Zn(e){return`${e.ContentDocumentId.slice(0,15)}${e.LinkedEntityId.slice(0,15)}`}function Kt(e){return`${e.ShareType}/${e.Visibility}`}async function*An(e){try{for await(let n of ae(e))yield n}catch(n){if(n.code==="ENOENT")return;throw n}}function Wt(e){return typeof e=="string"&&/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/.test(e)?e:null}function Jn(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:null}function Po(e){let n=fn(e);return n===null?Number.NaN:Date.parse(n)}var Ve=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>=Co&&await this.flush()}async flush(){if(this.lines.length===0)return;let n=this.lines.join("");this.lines=[],await Ro(this.file,n,{encoding:"utf8",mode:ln,flag:"a"})}};function xt(e,n,t){let o=Ae(n);return Oo(e,`${o}.links${t===void 0?"":`.${t}`}.ndjson`)}function*Vt(e,n){let t=[];for(let o of e)t.push(o),t.length>=n&&(yield t,t=[]);t.length>0&&(yield t)}var Do=Cn({sobjects:On(ct)}).loose(),Xn=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)&Ht)!==0}anchoredThen(n){return(this.files.flagsOf(n)&qt)!==0}sharingAt(n){let t=this.sharings.indexOf(n);return t>=0?t:(this.sharings.push(n),this.sharings.length-1)}};function No(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 ${Se} 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*jo(e,n){let t=await He.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 ae(o.live.file))typeof s.Id=="string"&&!t.has(s.Id)&&(yield s.Id)}async function Lo(e,n){let{reader:t,previewDir:o,signal:s}=e,i=n.map(l=>({...vt(l),file:xt(o,l)})),r=await qn(t,i,s),c=[];for(let[l,h]of r.entries()){let p=n[l];if(h.read){c.push({objectApiName:p,file:i[l].file});continue}let u=0,k=jo(e,p);for await(let d of vo(k,rn*En)){let g=[...Vt(d,rn)].map(D=>({...Bt(p,D),file:xt(o,p,u++)})),R=(await qn(t,g,s)).find(D=>!D.read);if(R&&!R.read)throw new Error(`The links of the files of ${p} could not be read whole: ${h.reason}; read by the ids of its records, ${R.reason}`);for(let D of g)c.push({objectApiName:p,file:D.file})}}return c}async function*vo(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 Jt(e){let n=Do.safeParse(await e.describeGlobal());if(!n.success)throw new Error("The org\u2019s global describe does not read as one.");let t=jt(n.data.sobjects,e.objects.map(({objectApiName:c})=>c)),o=No(e,await e.linkDescribe),s=await Lo(e,o),i=new Xn(t,s);for await(let c of Kn(e.folder))i.files.add(c.Id,zt|(c.anchored?qt:0));let r=await Un.read(e.folder);for await(let c of Hn(e.folder))i.held.set(Zn(Qt(c,r)),i.sharingAt(Kt(c)));for(let{file:c}of s)for await(let l of ae(c))typeof l.ContentDocumentId=="string"&&i.files.add(l.ContentDocumentId,Ht);return i}function Qt(e,n){let t=Ue(e.LinkedEntityId),o=t===void 0?void 0:n.currentOf(t);return o===void 0?e:{...e,LinkedEntityId:o}}async function Fn(e,n,t,o,s){for(let i of o)for await(let r of An(n(t,i)))typeof r.Id=="string"&&e.add(r.Id,s)}async function Ut(e){let n=0;for await(let t of An(e))typeof t.Id=="string"&&n++;return n}async function Gt(e,n,t){let o=new Map;if(n.length===0)return o;let s=We([...n],rn).map(c=>({objectApiName:le,soql:`SELECT ${Io.join(", ")} FROM ${le} WHERE Id IN (${c})`,scanAll:!0})),r=(await xe(e,s,(c,l)=>{for(let h of l){let p=Ue(h.Id);p!==void 0&&o.set(p,h)}},t)).find(c=>!c.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 Bo(e,n){return n===void 0||n.version===null||e.LatestPublishedVersionId===null?!1:Ue(n.version)!==Ue(e.LatestPublishedVersionId)}async function Zt(e){let{anchors:n,reader:t,classFileOf:o,signal:s}=e,i=n.files,r=le;await Fn(i,o,r,Mn.toDelete,Qn),await Fn(i,o,r,Mn.comesBack,vn),await Fn(i,o,r,Mn.lost,Bn);let c=new Map,l=e.fileChanges;if(!("unread"in l)){for(let L of[l.live,l.deleted])if(L!==void 0)for await(let x of ae(L.file)){let C=Ue(x.Id);C!==void 0&&(i.add(String(x.Id),Et),c.set(C,{version:Wt(x.LatestPublishedVersionId),size:Jn(x.ContentSize)}))}}let h=await He.read(e.folder,e.snapshotId,r),p=L=>(i.flagsOf(L)&Et)===0&&!h.has(L),u=new Ve(o(r,"createdSince")),k=new Ve(o(r,"deletedWhileTaken")),d=new Ve(o(r,"goneForGood")),f=new Ve(o(r,"newFileVersion")),g=0,A=0,R=async L=>{let x=await Gt(t,L.filter(C=>C.anchored&&p(C.Id)).map(C=>C.Id),s);for(let C of L){if(!C.anchored)continue;let q=Ue(C.Id)??"",H=c.get(q);if(p(C.Id)){let _=x.get(q);if(_===void 0){i.add(C.Id,Bn),await d.add({Id:C.Id});continue}H={version:Wt(_.LatestPublishedVersionId),size:Jn(_.ContentSize)},_.IsDeleted===!0&&(i.add(C.Id,vn),await k.add({Id:C.Id}))}let ne=i.flagsOf(C.Id);(ne&Bn)===0&&((ne&vn)!==0&&(g+=H?.size??C.ContentSize??0),Bo(C,H)&&await f.add({Id:C.Id}))}},D=[];for await(let L of Kn(e.folder))D.push(L),D.length>=rn*En&&(await R(D),D=[]);await R(D);let I=new Z,F=[],O=async L=>{let x=await Gt(t,L,s);for(let C of L){let q=x.get(Ue(C)??"");q===void 0||q.IsDeleted===!0||Po(q.CreatedDate)>=e.t0s&&(i.add(C,Qn),await u.add({Id:C}),F.push(q))}},v=[];for(let{file:L}of n.now)for await(let x of ae(L)){let C=x.ContentDocumentId;typeof C!="string"||(i.flagsOf(C)&zt)!==0||!p(C)||I.add(C)&&(v.push(C),v.length>=rn*En&&(await O(v),v=[]))}await O(v);for await(let L of An(o(r,"createdSince"))){let x=Ue(L.Id);x!==void 0&&(A+=c.get(x)?.size??0)}for await(let L of An(o(r,"broughtBackSince")))A+=c.get(Ue(L.Id)??"")?.size??0;for(let L of F)A+=Jn(L.ContentSize)??0;for(let L of[u,k,d,f])await L.flush();return{files:{...await Mo(e),outsideAdded:await Ut(o(r,"outsideAdded")),outsideDeleted:await Ut(o(r,"outsideDeleted")),storage:{bringBack:g,undo:A},...e.queryAllFiles?{}:{blindSpot:!0}},createdSince:u.count,deletedWhileTaken:k.count,goneForGood:d.count,newFileVersion:f.count,changedBy:F}}async function Mo(e){let{anchors:n,classFileOf:t}=e,o=new Z,s=new Set;for(let{objectApiName:u}of e.objects){if(u.toLowerCase()===le.toLowerCase())continue;if(!e.told.has(u)){for(let[d,f]of n.prefixes)f.toLowerCase()===u.toLowerCase()&&s.add(d);continue}let k=(d,f)=>Fn(o,t,u,d,f);await k(Vn.toDelete,Tt),await k(Vn.comesBack,_t),await k(Vn.lost,$t)}let i=u=>s.has(u.LinkedEntityId.slice(0,3)),r=u=>new Ve(De(e.previewDir,u)),c=r("linkAdded"),l=r("linkRemoved"),h=r("linkChanged");for(let{file:u}of n.now)for await(let k of ae(u)){let d=jn.safeParse(k);if(!d.success)throw new Error(`The org answered a link that does not read as one: ${d.error.message}`);let f=d.data,g=Zn(f),A=n.held.get(g);if(A!==void 0){if(n.held.set(g,A|Ln),i(f)||n.sharings[A&~Ln]===Kt(f))continue;let[R,D]=(n.sharings[A&~Ln]??"").split("/"),I={...f,ShareType:R,Visibility:D,now:{ShareType:f.ShareType,Visibility:f.Visibility}};await h.add(I);continue}i(f)||(n.files.flagsOf(f.ContentDocumentId)&Qn)===0&&(o.flagsOf(f.LinkedEntityId)&Tt)===0&&await c.add(f)}let p=await Un.read(e.folder);for await(let u of Hn(e.folder)){let k=Qt(u,p);((n.held.get(Zn(k))??0)&Ln)!==0||i(k)||(n.files.flagsOf(k.ContentDocumentId)&(vn|Bn))===0&&(o.flagsOf(k.LinkedEntityId)&(_t|$t))===0&&await l.add(k)}for(let u of[c,l,h])await u.flush();return{unlink:c.count,relink:l.count,updateLinks:h.count}}async function Xt(e){let{anchors:n,reader:t,classFileOf:o,signal:s}=e,i=[];for(let l of Mn.toDelete)for await(let h of An(o(le,l)))typeof h.Id=="string"&&i.push(h.Id);if(i.length===0)return{links:0,files:0};let r=new Map,c=0;for(let l of Vt(We(i,rn),En)){let h=l.map(k=>({objectApiName:Se,soql:`SELECT Id, ContentDocumentId, LinkedEntityId FROM ${Se} WHERE ContentDocumentId IN (${k})`,scanAll:!1})),u=(await xe(t,h,(k,d)=>{for(let f of d){let g=f.LinkedEntityId,A=f.ContentDocumentId;typeof g!="string"||typeof A!="string"||g.startsWith(So)||Lt({LinkedEntityId:g},n.prefixes)===void 0&&(c++,r.set(A.slice(0,15),A))}},s)).find(k=>!k.read);if(u&&!u.read)throw new Error(`The links of the files to delete to what the checkpoint does not hold could not be read: ${u.reason}`)}if(r.size>0){let l=new Ve(o(le,"outsideParents"));for(let h of r.values())await l.add({Id:h});await l.flush()}return{links:c,files:r.size}}var et=Object.freeze({kind:"org",notHeld:new Map,heldAs:()=>"org",unseenOf:()=>Promise.resolve([]),requests:()=>0,diffAccess:()=>({kind:"org"})});function Yn(e){return e.slice(0,15)}function Fo(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 ws(e){let{grants:n,reader:t}=e;if(n.kind==="org"||e.userId===void 0)return et;let o=e.checkpoint.objects,s=o.filter(f=>f.customSetting!==void 0).map(f=>f.objectApiName),i=new Map,r=n.requests,c=async f=>{let g=[...new Set(f)].filter(D=>!i.has(D.toLowerCase()));if(g.length===0)return;let A=t.calls(),R=await Promise.allSettled(g.map(D=>t.describe(D)));r+=t.calls()-A,R.forEach((D,I)=>{if(D.status==="rejected"&&D.reason instanceof se)throw D.reason;let F=D.status==="fulfilled"&&"body"in D.value?D.value.body:void 0,O=un.safeParse(F);i.set(g[I].toLowerCase(),O.success?O.data:void 0)})},l=()=>[...i.values()].filter(f=>f!==void 0),h=async f=>{let g=f.filter(R=>!n.objects.has(R.toLowerCase()));await c(g);let A={grants:n.objects,describes:l(),customSettings:s};return await c(Mt(f,A)),Ft(f,{...A,describes:l()})},p=await h(o.map(f=>f.objectApiName)),u=Yn(e.userId)===Yn(e.checkpoint.takenBy.userId)?"no longer has":"doesn't have",k=new Map,d=new Map;for(let[f,g]of p)"access"in g?k.set(f,g.access):d.set(f,Fo(f,g,e.username,u));return{kind:"perObject",userKey:Yn(e.userId),notHeld:d,heldAs:f=>k.get(f),unseenOf:async f=>{let g=await h(f);return f.filter(A=>{let R=g.get(A);return R===void 0||!("access"in R)})},requests:()=>r,diffAccess:()=>({kind:"perObject",requests:r})}}var $o=["giveBack","touched","createdSince","broughtBackSince","comesBackWithParent","unexplained","inBin","withParent","deletedWhileTaken","toRecreate","goneForGood","convertedLead","activatedContract","carrier","deletedWithCreatedParent","deletedWithParentOutside","deletedByOther","outOfReach","undoCannot","outsideParents","outsideAdded","outsideDeleted","newFileVersion"],Wo="Lead",xo="IsConverted",Uo="Contract",Go="Status",Yt="StatusCode",zo="Activated",qo=["createdSince","broughtBackSince"];function X(e,n,t){return _o(e,`${Ae(n)}.${t}.ndjson`)}var Tn=1e3,Ho=1440*6e4,Ko=60*6e4,Vo=100,Jo=2e3,oo=["LastModifiedById","LastModifiedDate"];function ee(e){return typeof e=="string"&&e.length>=15?e.slice(0,15):void 0}function Ie(e){let n=fn(e);return n===null?Number.NaN:Date.parse(n)}function it(e){return e.toLowerCase()===le.toLowerCase()}function Qo(e){return e==null||e===""}function Fe(e,n){let t=n.toLowerCase();return e.find(o=>o.toLowerCase()===t)}function Zo(e){return!e.leftOutFields.some(n=>n.reason==="base64")}var Rn=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>=Jo&&await this.flush()}async flush(){if(this.lines.length===0)return;let n=this.lines.join("");this.lines=[],await To(this.file,n,{encoding:"utf8",mode:ln,flag:this.written?"a":"w"}),this.written=!0}async discard(){this.lines=[],this.written&&await ot(this.file,{force:!0})}};async function st(e,n){await Promise.all($o.map(t=>ot(X(e,n,t),{force:!0})))}var nt=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),Ie(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 io(e,n){let t,o=async()=>{let s=new Set;try{for await(let i of ae(wt(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 Xo(e,n,t,o){let s=Ae(n.objectApiName),i=n.readMode==="scanAllLive",r=i?" AND IsDeleted = false":"",c=async p=>{let u=e.lane(),k=[];try{let d=await It(u,{objectApiName:s,soql:p,scanAll:i},f=>{k.push(...f)});if(!d.read)throw new Error(d.reason);return k}finally{u.close()}},l=t.length>Vo?yn/4:yn,h=new Map;for(let p of We(o,l)){let u=await ft(`SELECT ${t.join(", ")} FROM ${s} WHERE Id IN (${p})${r}`,c,{stamp:"SystemModstamp",...i?{idsWhere:"IsDeleted = false"}:{}});for(let k of u){let d=ee(k.Id);d!==void 0&&h.set(d,k)}}return h}var Yo=/__(?:c|pc|s)$/i,ei=/^(.+)__[A-Za-z]+__s$/i,ni=/^(.+)__pc$/i,ti=/^[A-Za-z][A-Za-z0-9_]*$/,oi=200;function ii(e,n){if(!Yo.test(n)||!ti.test(n))return;let t=ni.exec(n);if(t)return{entity:ie,name:`${t[1]}__c`};let o=ei.exec(n);return o?{entity:e,name:`${o[1]}__c`}:{entity:e,name:n}}var si=On(Cn({QualifiedApiName:at()}).loose());function ri(e,n){let t=`SELECT QualifiedApiName FROM FieldDefinition WHERE EntityDefinition.QualifiedApiName = '${Ae(e)}' AND QualifiedApiName IN (`,o=r=>`${t}${r.map(c=>`'${c}'`).join(", ")})`,s=[],i=[];for(let r of n){let c=[...i,r],l=c.length>oi||encodeURIComponent(o(c)).length>14e3;i.length>0&&l?(s.push({soql:o(i),names:i}),i=[r]):i=c}return i.length>0&&s.push({soql:o(i),names:i}),s}async function ai(e,n){let t=new Map,o=new Map;for(let[r,c]of n){let l={removed:[],hidden:[]};t.set(r,l);for(let h of c){let p=ii(r,h);if(p===void 0){l.hidden.push(h);continue}let u=o.get(p.entity)??new Map;o.set(p.entity,u);let k=p.name.toLowerCase(),d=u.get(k)??{name:p.name,fields:[]};u.set(k,d),d.fields.push({objectApiName:r,field:h})}}let s=0,i=new Map;for(let[r,c]of o){let l=new Set,h=new Map,p=ri(r,[...c.values()].map(({name:u})=>u));for(let u of p){s++;try{let k=await e.tooling(u.soql);if(!k.done)throw new Error("FieldDefinition answered more than one page");let d=si.safeParse(k.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(k){if(k instanceof se)throw k;let d=Be(k);for(let f of u.names)h.set(f.toLowerCase(),d)}}for(let[u,{fields:k}]of c){let d=h.get(u);for(let{objectApiName:f,field:g}of k){let A=t.get(f);if(A!==void 0)if(d!==void 0){let R=i.get(f)??{fields:[],reasons:[]};i.set(f,R),R.fields.push(g),R.reasons.includes(d)||R.reasons.push(d)}else l.has(u)?A.hidden.push(g):A.removed.push(g)}}}for(let[r,c]of t){c.removed.sort(),c.hidden.sort();let l=i.get(r);l!==void 0&&(c.uncertain={fields:l.fields.sort(),...l.reasons.length>0?{reason:l.reasons.join("; ")}:{}})}return{gone:t,requests:s}}async function eo(e,n,t){let{checkpoint:o,folder:s,reader:i}=e,r=new Date(Date.parse(o.readFrom)-Ho).toISOString(),c=await Promise.allSettled(n.map(({objectApiName:g})=>i.describe(g,r))),l,h=new Map,p=new Map;for(let[g,A]of c.entries()){let R=n[g].objectApiName;if(A.status==="rejected"){if(A.reason instanceof se)throw A.reason;h.set(R,{unread:`The org did not answer the describe of ${R}: ${Be(A.reason)}`});continue}if("notModified"in A.value){h.set(R,{gone:new Set});continue}let D=un.safeParse(A.value.body);if(!D.success){h.set(R,{unread:`The describe of ${R} does not read as one.`});continue}t.set(R,D.data);try{let I=(await(l??=mt(s,o.objects))).get(R);if(I===void 0)throw new Error(`The checkpoint holds no field prints of ${R}.`);p.set(R,ht(I,gt(D.data.fields)))}catch(I){h.set(R,{unread:Be(I)})}}let u=new Map(n.map(g=>[g.objectApiName,new Set(Nn(g.objectApiName,g.fields,o.ignoredFields).map(A=>A.toLowerCase()))])),k=(g,A)=>A.filter(R=>u.get(g)?.has(R.toLowerCase())===!0),d=new Map([...p].map(([g,A])=>[g,k(g,A.removed)]).filter(([,g])=>g.length>0)),f=d.size>0?await ai(i,d):{gone:new Map,requests:0};for(let[g,{removed:A,added:R,changed:D}]of p){let I=f.gone.get(g);h.set(g,{...k(g,A).length+R.length+D.length>0?{drift:{removed:I?.removed??[],added:R,changed:D,...I!==void 0&&I.hidden.length>0?{hidden:I.hidden}:{},...I?.uncertain!==void 0?{uncertain:I.uncertain}:{}}}:{},gone:new Set(A.map(F=>F.toLowerCase()))})}return{now:h,requests:f.requests}}function ci(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===ie),s=o!==void 0&&Fe(o.fields,kn)!==void 0&&t(ie);return e.filter(({objectApiName:i})=>t(i)||s&&i===In)}function di(e,n){let t=[...e.cascadeParents,...e.restrictParents??[]].filter(s=>!n.has(s.toLowerCase()));if(e.customSetting!==void 0){let s=Fe(e.fields,Pn(e.customSetting));s!==void 0&&!n.has(s.toLowerCase())&&!t.includes(s)&&t.push(s)}if(it(e.objectApiName))for(let s of bt){let i=Fe(e.fields,s);i!==void 0&&!n.has(i.toLowerCase())&&t.push(i)}let o=Fe(e.fields,kn);if(e.objectApiName===ie&&o!==void 0){let s=Fe(e.fields,"AccountId");for(let i of[o,s])i!==void 0&&!n.has(i.toLowerCase())&&t.push(i)}return[...t,...oo]}async function fi(e,n,t){let{folder:o,checkpoint:s}=e.input,i=new Map,r=new Map;for(let{objectApiName:c,cascadeParents:l,restrictParents:h=[]}of n){let p=t.get(c);if(!p||"unread"in p||!p.deleted||p.deleted.rows===0)continue;let u=new Map,k=new Map;try{let d=await He.read(o,s.snapshotId,c),f=io(o,c);for await(let g of ae(p.deleted.file)){let A=ee(g.Id);if(A===void 0)continue;let R=F=>F.map(O=>ee(g[O])).filter(O=>O!==void 0&&O!==A),D=ee(g.LastModifiedById),I=()=>({objectApiName:c,id:String(g.Id),stamp:Ie(g.SystemModstamp),parents:R(l),restricts:R(h),...D!==void 0?{by:D}:{}});if(!d.retired(g.Id)){if(!d.has(g.Id)){if(await f(A)){k.set(A,I());continue}if(Ie(g.CreatedDate)>=e.t0s&&k.set(A,I()),!(Ie(g.CreatedDate)<e.t0s))continue}u.set(A,I())}}}catch(d){if(d instanceof se)throw d;continue}for(let[d,f]of u)i.set(d,f);for(let[d,f]of k)r.set(d,f)}return{back:i,gone:r}}function li(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 tt(o,e,n),o}function tt(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,c]of i){if(e.has(r))continue;c.parents.some(h=>e.has(h)&&o(h)===c.stamp)&&(e.add(r),s=!0)}}for(let s of e)n.delete(s)}function ui(e,n){if(n===void 0)return new Set;let t=[...e].filter(([,o])=>o.by!==n).map(([o])=>o);return so(t,e)}function so(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(c=>t.has(c)&&n.get(c)?.stamp===i.stamp)&&(t.add(s),o=!0)}}return t}function gi(e,n,t){let o=new Map(e.map(l=>[l.objectApiName,l.undeletable])),s=new Set,i=new Set,r=(l,h)=>l.parents.find(p=>!h.has(p)&&t.get(p)?.stamp===l.stamp),c=l=>l.parents.some(h=>n.get(h)?.stamp===l.stamp);for(let l of[...n.values()]){if(c(l))continue;let h=new Set,p=[],u=r(l,h),k=!1;for(;u!==void 0;){h.add(u),p.push(u);let g=t.get(u);if(!g)break;if(c(g)){k=!0;break}u=r(g,h)}let d=p[p.length-1];if(d===void 0||k)continue;let f=t.get(d);if(!(!f||o.get(f.objectApiName)!==!0)){s.add(d);for(let g of p.slice(0,-1))i.add(g)}}for(let l of[...s,...i]){let h=t.get(l);h&&n.set(l,h)}return s}function hi(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(c=>!e.has(c)&&n.get(c)?.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 c=r.parents.find(h=>o.has(h)&&e.get(h)?.stamp===r.stamp),l=c===void 0?void 0:o.get(c);l!==void 0&&(o.set(i,l),s=!0)}}for(let s of o.keys())e.delete(s);return o}async function wi(e,n,t,o,s,i){let r=new Set,c=new Set,l=new Set(n.map(({objectApiName:d})=>d.toLowerCase())),h=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(A=>(t.get(A)??o.get(A))?.stamp===f.stamp)||p.set(f.objectApiName,[...p.get(f.objectApiName)??[],f]);if(p.size===0)return{outside:r,stuck:c,requests:0};let u=e.reader.calls(),k=async d=>{try{return await i(d)}catch(f){if(f instanceof se)throw f;return}};for(let[d,f]of p){let g=h.get(d),A=await k(d);if(!g||!A)continue;let R=new Set([...g.cascadeParents,...g.restrictParents??[]].map(N=>N.toLowerCase())),D=A.fields.filter(N=>N.type==="reference"&&!R.has(N.name.toLowerCase())&&(N.referenceTo??[]).some(z=>!l.has(z.toLowerCase())));if(D.length===0)continue;let I=[...new Set(D.flatMap(N=>(N.referenceTo??[]).filter(z=>!l.has(z.toLowerCase()))))],F=await Promise.all(I.map(k)),O=new Map;if(F.forEach((N,z)=>{if(!N)return;let Y=N.keyPrefix;for(let K of N.childRelationships??[]){if(K.cascadeDelete!==!0||K.childSObject.toLowerCase()!==d.toLowerCase())continue;let oe=D.find(ce=>ce.name.toLowerCase()===K.field.toLowerCase());oe&&O.set(oe.name,[...O.get(oe.name)??[],{object:I[z],...typeof Y=="string"?{prefix:Y}:{}}])}}),O.size===0)continue;let v=[...O.keys()].map(Sn),B=Ae(d),L=f.map(N=>N.id),x=new Map,C=We(L).map(N=>({objectApiName:B,soql:`SELECT Id, ${v.join(", ")} FROM ${B} WHERE Id IN (${N}) AND IsDeleted = true`,scanAll:!0}));if((await xe(e.reader,C,(N,z)=>{for(let Y of z){let K=ee(Y.Id);if(K!==void 0)for(let[oe,ce]of O){let re=Y[oe];if(typeof re!="string"||ee(re)===void 0)continue;let Ee=ce.length===1?ce[0]:ce.find(pe=>pe.prefix!==void 0&&re.startsWith(pe.prefix));Ee&&x.set(K,[...x.get(K)??[],{object:Ee.object,id:re}])}}},e.signal)).some(N=>!N.read))continue;let H=new Map;for(let N of x.values())for(let{object:z,id:Y}of N)H.set(z,[...H.get(z)??[],Y]);let ne=[];for(let[N,z]of H){let Y=Ae(N);for(let K of We([...new Set(z)]))ne.push({object:N,read:{objectApiName:Y,soql:`SELECT Id, IsDeleted, SystemModstamp FROM ${Y} WHERE Id IN (${K})`,scanAll:!0}})}let _=new Map;await xe(e.reader,ne.map(({read:N})=>N),(N,z)=>{for(let Y of z){let K=ee(Y.Id);K!==void 0&&Y.IsDeleted===!0&&_.set(K,Ie(Y.SystemModstamp))}},e.signal);for(let N of f){let z=ee(N.id);if(z!==void 0)for(let{id:Y}of x.get(z)??[]){let K=_.get(ee(Y)??"");K!==void 0&&(K===N.stamp?r.add(z):K>N.stamp&&c.add(z))}}}return{outside:r,stuck:c,requests:e.reader.calls()-u}}async function pi(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])),c=new Map;for(let[l,h]of i.entries()){if(h.status==="rejected"){if(h.reason instanceof se)throw h.reason;let p=s[l];o.set(p,Be(h.reason));for(let[u,k]of e)k.objectApiName===p&&e.delete(u);continue}for(let p of h.value.childRelationships??[]){let u=r.get(p.childSObject.toLowerCase());if(u===void 0)continue;let k=Fe(n.get(u)??[],p.field);if(k===void 0)continue;let d=c.get(u);d||(d=new Set,c.set(u,d)),d.add(k)}}return new Map([...c].map(([l,h])=>[l,[...h]]))}async function mi(e,n){let t=new Set,o=e.find(({objectApiName:i})=>i===ie);if(!o||Fe(o.fields,kn)===void 0)return t;let s=n.get(ie);if(!s||"unread"in s||!s.live)return t;try{for await(let i of ae(s.live.file)){let r=ee(i.AccountId);r!==void 0&&zn(ie,i)&&t.add(r)}}catch{return new Set}return t}async function yi(e,n,t,o){if("unread"in t)return{unread:t.unread};let{input:s,previewDir:i,t0s:r,back:c,carriers:l,stranded:h,stuck:p,others:u,personAccounts:k}=e,{folder:d,reader:f,checkpoint:g,signal:A}=s,R=n.objectApiName,D=it(R)?e.files:void 0,I=C=>D===void 0||D.anchoredThen(C),F=new Map,O=C=>{let q=F.get(C);return q||(q=new Rn(X(i,R,C)),F.set(C,q)),q},v=C=>F.get(C)?.count??0,B=new nt(e.activeFrom),L=[],x=new Map;try{let C=await He.read(d,g.snapshotId,R),q=io(d,R),{gone:H}=o,ne=Ot(R,g.ignoredFields),_=Nn(R,n.fields,[]),N=a=>ne.has(a.toLowerCase())||H.has(a.toLowerCase()),z=_.filter(a=>!N(a)).map(Sn),Y=_.filter(N),K=R===Wo?Fe(n.fields,xo):void 0,oe=K!==void 0&&!H.has(K.toLowerCase())?K:void 0,ce=R===Uo?Fe(n.fields,Go):void 0,re=ce!==void 0&&z.includes(ce)?ce:void 0,Ee=["Id","SystemModstamp",...oo,...z,...oe!==void 0&&!z.includes(oe)?[oe]:[],...re!==void 0?[Yt]:[]],pe=n.cascadeParents.filter(a=>!H.has(a.toLowerCase())),Oe=(n.restrictParents??[]).filter(a=>!H.has(a.toLowerCase())),Ce=R===ie&&Fe(n.fields,kn)!==void 0,me=a=>Ce&&zn(R,a),Te=Zo(n)?"toRecreate":"goneForGood",ue=e.access.heldAs(R)==="parent"?"outOfReach":Te,ye=r-Tn,ge={fields:0,cleared:0,liveNotHeld:0,deletedHeld:0},he=a=>{let m=ee(a.Id);if(m===void 0)throw new Error(`${R} answered a record without its Id.`);return{id:String(a.Id),key:m}},je=(a,m,y)=>a.map(S=>ee(m[S])).filter(S=>S!==void 0&&S!==y),Je=(a,m)=>je(pe,a,m),Qe=(a,m)=>{let y=Ie(a.SystemModstamp);return Je(a,m).some(S=>c.get(S)?.stamp===y)},ze=Date.parse(g.takenAt),Ze=Date.parse(s.readAt)-Tn,fe=(a,m,y,S)=>{B.add(a);let P=Je(a,y),M=je(Oe,a,y),U=S&&Ie(a.LastModifiedDate)<=Ze,W=U&&Ie(a.CreatedDate)>=ze,j=R===ie&&S?ee(a.AccountId):void 0;j!==void 0&&x.set(y,j);let T=ee(a.ContactId),$=ee(a.AccountId),Q=R===Me&&U&&!W&&T!==void 0&&$!==void 0?{contact:T,account:$}:void 0;n.undeletable&&P.length+M.length===0||L.push({id:m,parents:P,restricts:M,goesAlong:W,undeletable:n.undeletable,...Q?{relation:Q}:{}})},Le=new Map,Xe=e.lookups.get(R)??[];if(Xe.length>0&&C.size>0)for await(let a of C.records()){if(me(a))continue;let m=ee(a.Id);if(m===void 0)continue;let y=Xe.filter(S=>{let P=ee(a[S]);return P!==void 0&&c.has(P)});y.length>0&&Le.set(m,{id:String(a.Id),fields:y})}let cn=async a=>{if(a.length===0)return;if(z.length===0){for(let M of a)M.stamp!==M.held&&await O("touched").add({Id:M.id});return}let m=a.map(M=>M.id),y=new Map,S=await C.chunk(m).batches(g.snapshotId,R,yn);for await(let M of S??[])for(let U of M){let W=ee(U.Id);W!==void 0&&y.set(W,U)}if(A?.aborted)throw new se;let P=await Xo(f,n,Ee,m);for(let M of a){let U=P.get(M.key);if(!U)continue;let W=y.get(M.key);if(!W)throw new Error(`The checkpoint\u2019s snapshot of ${R} does not hold record ${M.id}, which its index names.`);if(oe!==void 0&&W[oe]!==!0&&U[oe]===!0){await O("convertedLead").add({Id:M.id});continue}if(re!==void 0&&U[Yt]===zo&&!xn(W[re],U[re])){await O("activatedContract").add({Id:M.id});continue}let j=z.filter(T=>!xn(W[T],U[T]));if(j.length>0){ge.fields+=j.length;let T=(M.cleared??[]).filter($=>j.includes($)&&Qo(U[$]));T.length>0&&ge.cleared++,await O("giveBack").add({Id:M.id,fields:j,...T.length>0?{cleared:T}:{}}),B.add(U)}else Ie(U.SystemModstamp)!==M.held&&await O("touched").add({Id:M.id})}},Pe=[],_e=async a=>{Pe.push(a),Pe.length>=sn&&(await cn(Pe),Pe=[])};if(t.live)for await(let a of ae(t.live.file)){let{id:m,key:y}=he(a),S=me(a),P=C.stampOf(m);if(P!==void 0){if(S||!I(m))continue;let U=Le.get(y)?.fields;U&&Le.delete(y);let W=R===In&&k.delete(y),j=Ie(a.SystemModstamp);(U||W||j!==P||P>=ye)&&await _e({id:m,key:y,held:P,stamp:j,...U?{cleared:U}:{}});continue}if(ge.liveNotHeld++,S)continue;let M=await q(y)?"broughtBackSince":Ie(a.CreatedDate)>=r?"createdSince":void 0;M===void 0?await O("unexplained").add({Id:m}):D!==void 0&&!D.anchoredNow(m)?await O("outsideAdded").add({Id:m}):(await O(M).add({Id:m}),fe(a,m,y,!0))}for(let[a,m]of Le){let y=C.stampOf(m.id);y!==void 0&&await _e({id:m.id,key:a,held:y,stamp:y,cleared:m.fields})}if(R===In)for(let a of k){let m=C.rowOf(a);if(m<0||(k.delete(a),Le.has(a)))continue;let y=C.idAt(m),S=C.stampOf(y);S!==void 0&&await _e({id:y,key:a,held:S,stamp:S})}if(await cn(Pe),t.deleted)for await(let a of ae(t.deleted.file)){let{id:m,key:y}=he(a);if(C.retired(m))continue;let S=me(a);if(C.has(m)){if(ge.deletedHeld++,S)continue;if(!I(m)){await O("outsideDeleted").add({Id:m});continue}let P=h.get(y);u.has(y)?await O("deletedByOther").add({Id:m}):p.has(y)?await O(e.answeredGone.has(y)?ue:Te).add({Id:m}):P!==void 0?await O(P).add({Id:m}):Qe(a,y)?await O("withParent").add({Id:m}):n.undeletable?await O("inBin").add({Id:m}):await O(Te).add({Id:m});continue}if(l.has(y)&&!S){await O("carrier").add({Id:m});continue}if(!(S||await q(y)))if(Ie(a.CreatedDate)<r){let P=h.get(y),M=I(m)?u.has(y)?"deletedByOther":p.has(y)?"goneForGood":P??"deletedWhileTaken":"outsideDeleted";await O(M).add({Id:m})}else Qe(a,y)&&(await O("comesBackWithParent").add({Id:m}),fe(a,m,y,!1))}let Ye=t.count;if(C.size>0&&Ye===void 0)throw new Error(`The org gave no count of the ${R} records it holds.`);if(C.size-((Ye??0)-ge.liveNotHeld)-ge.deletedHeld>0){let a=new kt(C);if(t.deleted)for await(let P of ae(t.deleted.file))a.mark(P.Id);let[m]=await xe(f,[St(R,n.readMode)],(P,M)=>{for(let U of M)a.mark(U.Id)},A);if(!m.read)throw new Error(m.reason);let y=[],S=async()=>{let P=new Set;if(Ce){let M=await C.chunk(y).batches(g.snapshotId,R,yn);for await(let U of M??[])for(let W of U){let j=ee(W.Id);j!==void 0&&me(W)&&P.add(j)}}for(let M of y)P.has(M.slice(0,15))||await O(I(M)?ue:"outsideDeleted").add({Id:M});y=[]};for(let P of a.ids())y.push(P),y.length>=sn&&await S();await S()}for(let a of F.values())await a.flush();let qe=v("toRecreate"),b=v("goneForGood"),E=v("convertedLead"),V=v("activatedContract"),J=v("deletedWithCreatedParent"),ke=v("deletedWithParentOutside"),dn=v("deletedByOther"),wn=v("outOfReach"),pn=v("carrier");return{told:{diff:{objectApiName:R,toDelete:{createdSince:v("createdSince"),broughtBackSince:v("broughtBackSince"),comesBackWithParent:v("comesBackWithParent")},toGiveBack:{records:v("giveBack"),fields:ge.fields,clearedLookups:ge.cleared},toBringBack:{inBin:v("inBin"),withParent:v("withParent"),deletedWhileTaken:v("deletedWhileTaken"),...pn>0?{carriers:pn}:{}},...qe>0?{toRecreate:qe}:{},cannotUndo:[...b>0?[{reason:"goneForGood",count:b}]:[],...E>0?[{reason:"convertedLead",count:E}]:[],...V>0?[{reason:"activatedContract",count:V}]:[],...J>0?[{reason:"deletedWithCreatedParent",count:J}]:[],...ke>0?[{reason:"deletedWithParentOutside",count:ke}]:[],...dn>0?[{reason:"deletedByOther",count:dn}]:[],...wn>0?[{reason:"outOfReach",count:wn}]:[]],outside:[],touched:v("touched"),unexplained:v("unexplained"),lastChangedBy:B.byUser(),...o.drift?{schemaDrift:o.drift}:{},notCompared:Y},people:B,pending:L,...x.size>0?{accounts:x}:{}}}}catch(C){for(let q of F.values())await q.discard();if(C instanceof se)throw C;return{unread:Be(C)}}}async function*ro(e,n){let t=[];for(let o of qo)if(n.diff.toDelete[o]!==0)for await(let s of ae(X(e,n.diff.objectApiName,o)))typeof s.Id=="string"&&(t.push(s.Id),t.length>=sn&&(yield t,t=[]));t.length>0&&(yield t)}async function ki(e,n,t,o,s){let{input:i,previewDir:r}=e,c=n.diff.objectApiName,h=((await t(c)).childRelationships??[]).filter(I=>I.cascadeDelete===!0&&!s.has(I.childSObject.toLowerCase()));if(h.length===0)return[];let p=await o(),u=h.filter(I=>p.has(I.childSObject));if(u.length===0)return[];let k=new Set(await e.access.unseenOf([...new Set(u.map(({childSObject:I})=>I))])),d=u.filter(({childSObject:I})=>!k.has(I));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 g=Ct(Math.ceil(f/Tn)*Tn),A=new Map,R=new Map,D=new Map;for await(let I of ro(r,n)){let F=d;for(;F.length>0;){let O=[];for(let L of F){let x=Ae(L.childSObject),C=Sn(L.field),q=At(x)==="scanAllLive",H=D.get(x)??"CreatedDate";for(let ne of We(I))O.push({child:x,field:C,read:{objectApiName:x,soql:`SELECT Id, ${C} FROM ${x} WHERE ${C} IN (${ne}) AND ${H} >= ${g}${q?" AND IsDeleted = false":""}`,scanAll:q}})}let v=await xe(i.reader,O.map(({read:L})=>L),(L,x)=>{let{child:C,field:q}=O[L],H=A.get(C);H||(H={records:new Set,parents:new Set},A.set(C,H));for(let ne of x){let _=ee(ne.Id),N=ee(ne[q]);_!==void 0&&H.records.add(_),N!==void 0&&(H.parents.add(N),R.set(N,String(ne[q])))}},i.signal),B=new Set;v.forEach((L,x)=>{if(L.read)return;let{child:C}=O[x];if(!D.has(C)&&/No such column 'CreatedDate'/.test(L.reason)){B.add(C);return}throw new Error(`The ${L.objectApiName} records its deletion would take along could not be read: `+L.reason)});for(let L of B)D.set(L,"SystemModstamp");F=F.filter(L=>B.has(Ae(L.childSObject)))}}if(R.size>0){let I=new Rn(X(r,c,"outsideParents"));for(let F of R.values())await I.add({Id:F});await I.flush()}return[...A].filter(([,{records:I}])=>I.size>0).sort(([I],[F])=>I<F?-1:I>F?1:0).map(([I,{records:F,parents:O}])=>({objectApiName:I,count:F.size,parents:O.size}))}async function bi(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 h=await o(),p=[...new Set(l.filter(d=>h.has(d)))].sort(),k=[...p.length>0?await e.unseenOf(p):[]].sort((d,f)=>+!no.has(d)-+!no.has(f));return k.length>0?{objectApiName:s,children:k,records:r}:void 0}var no=new Set(["Event","Task"]);async function Ai(e,n){let t=new Set(n.flatMap(({pending:d})=>d.flatMap(({parents:f,restricts:g})=>[...f,...g]))),o=new Set;if(t.size>0)for(let d of n)for await(let f of ro(e,d))for(let g of f){let A=g.slice(0,15);t.has(A)&&o.add(A)}let s=new Map(n.flatMap(({pending:d})=>d.map(f=>[f.id.slice(0,15),f]))),i=new Map(n.flatMap(({accounts:d})=>[...d??[]])),r=({relation:d})=>d!==void 0&&o.has(d.contact)&&i.get(d.contact)===d.account,c=d=>d.goesAlong||r(d)?d.parents.find(f=>o.has(f)):void 0,l=(d,f=new Set)=>{let g=s.get(d),A=g&&!f.has(d)?c(g):void 0;return A===void 0?d:l(A,new Set([...f,d]))},h=new Map,p=(d,f)=>{let g=h.get(d);if(g!==void 0)return g;h.set(d,!1);let A=l(d),R=f.restricts.some(D=>o.has(D)&&l(D)!==A)||f.parents.some(D=>{let I=s.get(D);return I!==void 0&&c(I)!==void 0&&p(D,I)});return h.set(d,R),R},u=[],k=[];for(let{diff:d,pending:f}of n){let g=d.objectApiName,A=B=>c(B)!==void 0&&!p(B.id.slice(0,15),B),R=f.filter(A).length;R>0&&k.push({objectApiName:g,count:R});let D=f.filter(B=>!A(B)),I=D.filter(B=>[...B.parents,...B.restricts].some(L=>o.has(L))),F=new Set(I.map(({id:B})=>B)),O=D.filter(B=>!B.undeletable&&!F.has(B.id));if(O.length+I.length===0)continue;let v=new Rn(X(e,g,"undoCannot"));for(let{id:B}of O)await v.add({Id:B});for(let{id:B}of I)await v.add({Id:B,reason:"deletedBeforeParent"});await v.flush(),O.length>0&&u.push({objectApiName:g,count:O.length}),I.length>0&&u.push({objectApiName:g,count:I.length,reason:"deletedBeforeParent"})}return{undoCannot:u,withParentDeleted:k}}async function Ri(e,n,t){let o={};if(n.length===0)return o;let s=We([...n].sort()).map(i=>({objectApiName:"User",soql:`SELECT Id, Name FROM User WHERE Id IN (${i})`,scanAll:!1}));return await xe(e,s,(i,r)=>{for(let c of r)typeof c.Id=="string"&&typeof c.Name=="string"&&(o[c.Id]=c.Name)},t),o}function to(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 Oi(e){let n=await e.describe(Se),t=un.safeParse("body"in n?n.body:null);if(!t.success)throw new Error(`The org gave no describe of ${Se}.`);return t.data}function ao(e){return(n,t)=>X(e,n,t)}async function Ci(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 Jt({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 se)throw s;return{unread:"The links of its files to the records of the checkpoint could not be read: "+Be(s)}}}async function co(e){await Promise.all(["linkAdded","linkRemoved","linkChanged"].map(n=>ot(De(e,n),{force:!0})))}async function Si(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 Zt({anchors:n.anchors,reader:e.reader,folder:e.folder,snapshotId:e.checkpoint.snapshotId,t0s:n.t0s,objects:n.ordered,fileChanges:s,told:i,classFileOf:ao(n.previewDir),previewDir:n.previewDir,queryAllFiles:e.checkpoint.takenBy?.queryAllFiles===!0&&e.queryAllFiles!==!1,...e.signal?{signal:e.signal}:{}}),{diff:c,people:l}=o.told;c.toDelete.createdSince+=r.createdSince,c.toBringBack.deletedWhileTaken+=r.deletedWhileTaken;for(let k of r.changedBy)l.add(k);c.lastChangedBy=l.byUser();let h=r.goneForGood,p=r.newFileVersion,u=c.cannotUndo.find(k=>k.reason==="goneForGood");return u!==void 0?u.count+=h:h>0&&c.cannotUndo.unshift({reason:"goneForGood",count:h}),c.cannotUndo.push(...p>0?[{reason:"newFileVersion",count:p}]:[]),r.files}catch(r){if(r instanceof se)throw r;await st(n.previewDir,t),await co(n.previewDir),n.outcomes.set(t,{unread:Be(r)});return}}async function Ii(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 Xt({anchors:n.anchors,reader:e.reader,classFileOf:ao(n.previewDir),...e.signal?{signal:e.signal}:{}});if(i===0)return;s.outside=[...s.outside.filter(({objectApiName:c})=>c!==Se),{objectApiName:Se,count:i,parents:r}].sort((c,l)=>c.objectApiName<l.objectApiName?-1:c.objectApiName>l.objectApiName?1:0)}catch(i){if(i instanceof se)throw i;await st(n.previewDir,t),await co(n.previewDir),n.outcomes.set(t,{unread:Be(i)})}}async function Ts(e){let{checkpoint:n,folder:t,reader:o,previewId:s,readAt:i,signal:r}=e,c=Date.parse(n.readFrom);if(!Number.isFinite(c))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 se;let h=c-(c%1e3+1e3)%1e3,p=pt(t,s);await Dn(p);let u=[...n.objects].sort((b,E)=>b.readOrder-E.readOrder),k=e.access??et,d=u.filter(({objectApiName:b})=>!k.notHeld.has(b)),f=new Map,g=n.files!==void 0?d.find(({objectApiName:b})=>it(b)):void 0,A=await Pt(o,d.map(({objectApiName:b})=>b),n.readFrom,r),R=new Map(d.map(({objectApiName:b},E)=>[b,A[E]])),D=ci(d,R),I=g!==void 0?Oi(o):void 0;I?.catch(()=>{});let F=await eo(e,D,f),O=F.requests,v=new Map,B=new Set,L=[];for(let b of u){let E=b.objectApiName,V=k.notHeld.get(E);if(V!==void 0){v.set(E,V);continue}let J=R.get(E);if(J===void 0||"unread"in J){v.set(E,J?.unread??"Its newest record was not read.");continue}let ke=F.now.get(E);ke===void 0?(B.add(E),L.push({object:b,fields:{gone:new Set},check:J})):"unread"in ke?v.set(E,ke.unread):L.push({object:b,fields:ke,check:J})}let x=await Dt(o,L.map(({object:b,fields:E})=>({objectApiName:b.objectApiName,readMode:b.readMode,held:b.records>0,fields:di(b,E.gone)})),n.readFrom,p,r,L.map(({check:b})=>b)),C=new Map(L.map(({object:b},E)=>[b.objectApiName,x[E]])),q=L.filter(({object:b})=>{if(!B.has(b.objectApiName))return!1;let E=C.get(b.objectApiName);return E!==void 0&&!("unread"in E)&&E.count!==void 0&&E.count<b.records});if(q.length>0){let b=await eo(e,q.map(({object:E})=>E),f);O+=b.requests;for(let E of q){let V=E.object.objectApiName;B.delete(V);let J=b.now.get(V);J===void 0||"unread"in J?v.set(V,J?.unread??"Its describe was not read."):E.fields=J}}let H=new Map,ne=b=>{let E=f.get(b);if(E)return Promise.resolve(E);let V=H.get(b);return V||(V=(async()=>{let J=await o.describe(b),ke=un.safeParse("body"in J?J.body:null);if(!ke.success)throw new Error(`The org gave no describe of ${b}.`);return ke.data})(),H.set(b,V)),V},{back:_,gone:N}=await fi({input:e,t0s:h},u,C),z=ui(_,k.userKey),Y=new Map([...N,..._]),K=li(_,N),oe=await yt.read(t);for(let b of oe.keys())(_.has(b)||N.has(b))&&K.add(b);let ce=so([...oe.keys()].filter(b=>Y.has(b)),Y);tt(K,_,N);for(let b of z)_.delete(b),K.delete(b);let re=gi(u,_,N),Ee=new Map(L.map(({object:b,fields:E})=>[b.objectApiName,Nn(b.objectApiName,b.fields,n.ignoredFields).filter(V=>!E.gone.has(V.toLowerCase()))])),pe=await pi(_,Ee,ne,v),Oe=await wi(e,L.map(({object:b})=>b),_,N,re,ne);for(let b of Oe.stuck)K.add(b);tt(K,_,N);for(let b of[...re])_.has(b)||re.delete(b);let Ce=hi(_,N,Oe.outside),me=0,Te=o.calls(),ue=g!==void 0&&I!==void 0?await Ci(e,{previewDir:p,ordered:u,changes:C,linkDescribe:I,fileObject:g,unread:v}):void 0;me+=o.calls()-Te;let ye=ue!==void 0&&"anchors"in ue?ue.anchors:void 0,ge={input:e,previewDir:p,t0s:h,activeFrom:l-Ko,back:_,carriers:re,stranded:Ce,stuck:K,answeredGone:ce,others:z,access:k,lookups:pe,personAccounts:await mi(u,C),...ye!==void 0?{files:ye}:{}},he=new Map;for(let{object:b,fields:E}of L){if(r?.aborted)throw new se;let V=v.get(b.objectApiName)??(ue!==void 0&&"unread"in ue&&b===g?ue.unread:void 0),J=C.get(b.objectApiName);he.set(b.objectApiName,V!==void 0||J===void 0?{unread:V??"Its changes were not read."}:await yi(ge,b,J,E))}let je;if(ye!==void 0&&g!==void 0){let b=o.calls();je=await Si(e,{anchors:ye,fileObject:g,changes:C,outcomes:he,ordered:u,previewDir:p,t0s:h}),me+=o.calls()-b}let Je=new Set(u.map(({objectApiName:b})=>b.toLowerCase()));if(n.files!==void 0&&g!==void 0)for(let b of[Se,dt])Je.add(b.toLowerCase());let Qe,ze=()=>Qe??=lt({describeGlobal:e.describeGlobal}),Ze=[];for(let[b,E]of he){if(!("told"in E))continue;let{toDelete:V}=E.told.diff;if(V.createdSince+V.broughtBackSince!==0)try{E.told.diff.outside=await ki(ge,E.told,ne,ze,Je);let J=await bi(k,E.told,ne,ze);J!==void 0&&Ze.push(J)}catch(J){if(J instanceof se)throw J;await st(p,b),he.set(b,{unread:Be(J)})}}if(ye!==void 0&&g!==void 0){let b=o.calls();await Ii(e,{anchors:ye,fileObject:g,outcomes:he,previewDir:p}),me+=o.calls()-b,"told"in(he.get(g.objectApiName)??{unread:""})||(je=void 0)}let fe=u.flatMap(({objectApiName:b})=>{let E=he.get(b);return E&&"told"in E?[E.told]:[]}),{undoCannot:Le,withParentDeleted:Xe}=await Ai(p,fe),cn=new Set(fe.map(({diff:b})=>b.objectApiName)),Pe=Ze.filter(({objectApiName:b})=>cn.has(b)),_e=[...new Set(fe.flatMap(({diff:b})=>Object.keys(b.lastChangedBy)))],Ye=await Ri(o,_e,r),hn=new Set(fe.flatMap(({people:b})=>[...b.active])),qe=fe.filter(({diff:b})=>B.has(b.objectApiName)&&!to(b)).length;return{checkpointId:n.checkpointId,previewId:s,readAt:i,objects:fe.map(({diff:b})=>b).filter(to),undoCannot:Le,...Xe.length>0?{withParentDeleted:Xe}:{},...Oe.requests>0?{parentsOutsideRequests:Oe.requests}:{},...O>0?{fieldsRequests:O}:{},described:{first:D.length,later:q.length},...qe>0?{fieldsNotChecked:qe}:{},...je!==void 0?{files:je}:{},...g!==void 0?{filesRequests:me}:{},access:k.diffAccess(),...Pe.length>0?{unseen:Pe}:{},unread:u.flatMap(({objectApiName:b})=>{let E=he.get(b),V=E&&"unread"in E?E.unread:E?void 0:v.get(b);return V===void 0?[]:[{objectApiName:b,reason:V}]}),userNames:Ye,activeLastHour:[...hn].sort()}}var Li=1e3,vi=25,Bi=2e3,we=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,fo=["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},lo=32768,Mi={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},gn=new Set(["createdSince","broughtBackSince"]),Ne={changedSincePreview:1,changedDuringRewind:2,outsideNotAccepted:4,holdsLeft:8,noUndoNotAccepted:16,beforeParentNotAccepted:32,recreateNotAccepted:64,keyTaken:128,needsUnpickedParent:256,heldByUnpicked:512,contactKept:1024},Fi=[{cls:"linkAdded",as:"unlink"},{cls:"linkRemoved",as:"relink"},{cls:"linkChanged",as:"share"}];function nr(e,n){return[n,e.automatedProcessUserId].filter(t=>typeof t=="string"&&t!=="")}function tr(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 Ge(e){let n=fn(e);return n===null?Number.NaN:Date.parse(n)}function te(e,n){let t=e.Id;if(typeof t!="string"||!we.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*G(e){try{for await(let n of ae(e))yield n}catch(n){if(n.code!=="ENOENT")throw n}}function Ei(e,n){return $n(e,`${Ae(n)}.beforeParent.ndjson`)}function Ti(e,n){return $n(e,`${Ae(n)}.along.ndjson`)}var an=class{constructor(n){this.file=n}file;lines=[];written=!1;async add(n){this.lines.push(`${JSON.stringify(n)}
|
|
10
|
+
`),this.lines.length>=Bi&&await this.flush()}async flush(){if(this.lines.length===0)return;let n=this.lines.join("");this.lines=[],await Di(this.file,n,{encoding:"utf8",mode:ln,flag:this.written?"a":"w"}),this.written=!0}},rt=class{entries=new Map;add(n,t,o,s,i){let r=`${n}\0${t}\0${s??""}\0${i??""}`,c=this.entries.get(r);c||(c={objectApiName:n,reason:t,...s!==void 0?{by:s}:{},...i!==void 0?{needs:i}:{},count:0,ids:[]},this.entries.set(r,c)),c.count++,c.ids.length<vi&&c.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 uo(e,n){if(!(typeof n!="string"||n===""))return e==="SetupOwnerId"&&we.test(n)?n.slice(0,15):n}async function _i(e,n,t,o){let s=new Z;if(e.customSetting===void 0)return s;let i=Pn(e.customSetting).toLowerCase(),r=e.fields.find(h=>h.toLowerCase()===i);if(r===void 0)return s;let c=new Z;for(let h of o){let p=X(t,e.objectApiName,h);for await(let u of G(p))c.add(te(u,p))}if(c.size===0)return s;let l=new Set;for await(let h of G(Re(n,e.objectApiName))){let p=uo(r,h[r]);p!==void 0&&l.add(p)}if(l.size===0)return s;for await(let h of G(bn(n,e.objectApiName))){if(typeof h.Id!="string"||!c.has(h.Id))continue;let p=uo(r,h[r]);p!==void 0&&l.has(p)&&s.add(h.Id)}return s}function go(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 $i(e){return Object.entries(e).some(([n,t])=>n!=="objectApiName"&&t!==0)}function ho(e){return`${e.ContentDocumentId.slice(0,15)}:${e.LinkedEntityId.slice(0,15)}`}function wo(e,n,t){let s=(n==="linkChanged"?Nt:jn).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 yo(e){return{unlink:{file:De(e,"linkAdded"),count:0},relink:{file:De(e,"linkRemoved"),count:0},share:{file:De(e,"linkChanged"),count:0}}}async function Wi(e){let n={};for(let{cls:o,as:s}of Fi){let i=new Set,r=De(e.confirmedDir,o);for await(let p of G(r))i.add(ho(wo(p,o,r)));let c=De(e.freshDir,o),l=new an(De(e.dir,o)),h=0;for await(let p of G(c)){let u=wo(p,o,c);if(e.deleted(u.ContentDocumentId)||e.deleted(u.LinkedEntityId))continue;let k=e.pass===2&&o==="linkRemoved"&&(e.earlier(u.ContentDocumentId)||e.earlier(u.LinkedEntityId));if(!i.has(ho(u))&&!k){e.left.add(Se,"changedSincePreview",u.Id);continue}await l.add(p),h++}await l.flush(),n[s]={file:l.file,count:h}}let t=yo(e.dir);return{unlink:n.unlink??t.unlink,relink:n.relink??t.relink,share:n.share??t.share}}var xi=["inBin","withParent","deletedWhileTaken","carrier"],Ui=new Set(["id","createdbyid","lastmodifiedbyid","systemmodstamp","createddate","lastmodifieddate"]);function Gi(e,n){return e.flatMap(t=>{let o=n[t];return typeof o=="string"&&we.test(o)?[o.slice(0,15)]:[]})}function po(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(Ui.has(r)||o!==void 0&&!o.has(r))return[];if(typeof i!="string"||!we.test(i))return[];let c=i.slice(0,15);return n.has(c)?[{field:s,needs:n.get(c)}]:[]})}async function zi(e,n,t){let{freshDir:o,heldRows:s}=e,i=new Map,r=new Map;for(let d of n)for(let f of[...xi,"toRecreate","comesBackWithParent"]){let g=X(o,d.objectApiName,f);for await(let A of G(g)){let R=te(A,g).slice(0,15);i.set(R,d.objectApiName),r.set(R,f)}}let c=new Map;for(let d of n)if(d.cascadeParents.length!==0)for await(let f of G(bn(o,d.objectApiName))){if(typeof f.Id!="string"||!we.test(f.Id))continue;let g=f.Id.slice(0,15),A=r.get(g);(A==="withParent"||A==="comesBackWithParent")&&c.set(g,Gi(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,g]of c)l.has(f)||!g.some(A=>l.has(A))||(l.add(f),d=!0)}let h=(d,f=new Set)=>{let g=i.get(d);if(!(g===void 0||f.has(d))){if(!t(g))return g;f.add(d);for(let A of c.get(d)??[]){if(l.has(A))continue;let R=h(A,f);if(R!==void 0)return R}}},p=new Map,u=new Map;for(let[d,f]of r){if(l.has(d)||f==="comesBackWithParent")continue;let g=i.get(d)??"";if(!t(g))p.set(d,g);else if(f==="withParent"){let A=h(d);u.set(d,A),p.set(d,A)}}let k=new Map;if(s===void 0)return{comes:l,left:u,fields:k};for(let d of[...n].reverse()){let f=d.objectApiName;if(!t(f))continue;let g=new Set(d.cascadeParents.map(F=>F.toLowerCase())),A=[],R=X(o,f,"toRecreate");for await(let F of G(R))A.push(te(F,R));if(A.length>0)for await(let F of s(f,A)){if(typeof F.Id!="string"||!we.test(F.Id))continue;let O=F.Id.slice(0,15),v=po(F,p,void 0);if(v.length===0)continue;let B=v.find(({field:L})=>g.has(L.toLowerCase()));B!==void 0?(u.set(O,B.needs),p.set(O,B.needs)):k.set(O,{fields:v.map(({field:L})=>L),needs:v[0].needs})}let D=new Map,I=X(o,f,"giveBack");for await(let F of G(I)){let O=te(F,I),v=Array.isArray(F.fields)?F.fields.filter(B=>typeof B=="string"):void 0;D.set(O.slice(0,15),{id:O,differ:v})}for(let F of["inBin","withParent"]){let O=X(o,f,F);for await(let v of G(O)){let B=te(v,O);l.has(B.slice(0,15))&&D.set(B.slice(0,15),{id:B,differ:void 0})}}if(D.size!==0)for await(let F of s(f,[...D.values()].map(({id:O})=>O))){if(typeof F.Id!="string"||!we.test(F.Id))continue;let O=F.Id.slice(0,15),v=D.get(O);if(v===void 0)continue;let B=po(F,p,v.differ);B.length>0&&k.set(O,{fields:B.map(({field:L})=>L),needs:B[0].needs})}}return{comes:l,left:u,fields:k}}function qi(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}`;case"contactKept":return`Kept: the relation of a contact made since to its own account, which Salesforce deletes only with the contact, and this rewind leaves the contact (${o}).${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 Hi(e){let{checkpoint:n,pass:t,confirmedDir:o,freshDir:s,dir:i,signal:r}=e,c=Date.parse(n.takenAt);if(!Number.isFinite(c))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 h=l-Li;if(await Dn(i),(await Ni(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 se},u=[...n.objects].map(Rt).sort((w,a)=>w.readOrder-a.readOrder),k=new Map(u.map(({objectApiName:w},a)=>[w,a])),d=new Map(u.map(({objectApiName:w})=>[w,go(w)])),f=w=>d.get(w)??go(w),g=new Set(e.ownWriters.map(w=>w.slice(0,15))),A=new Map(Object.entries(e.removalStamps??{}).map(([w,a])=>[w.slice(0,15),Ge(a)])),R=w=>ko(w,h,g,A),D=(w,a)=>w.flatMap(m=>{let y=a[m];return typeof y=="string"&&we.test(y)?[y]:[]}),I=(w,a)=>D(w.cascadeParents,a),F=(w,a)=>D(w.restrictParents??[],a),O=new rt,v=w=>e.objects===void 0||e.objects.has(w),B=e.objects!==void 0?await zi(e,u,v):void 0,L=new Map,x=new Map,C=new an($n(i,"leftFields.ndjson")),q=0,H=(w,a,m,y)=>{if(O.add(w,a,m,void 0,y),L.set(m.slice(0,15),qi(a,y)),y===void 0)return;let S=x.get(y);S||(S=new Z,x.set(y,S)),S.add(m)},ne=new Z,_=new Z,N=new Z,z=new Z,Y=new Z,K=new Z,oe=[];for(let w of u){p();let a=w.objectApiName,m=v(a),y=(k.get(a)??0)+1,S=f(a),P=new Z;for(let j of fo){let T=X(o,a,j);for await(let $ of G(T))P.add(te($,T),de[j])}let M=t===2?await Xi(s,a,h,g,A,oe):void 0,U=new Map,W=j=>{let T=U.get(j);return T||(T=new an(X(i,a,j)),U.set(j,T)),T};for(let j of fo){if(!m&&j!=="comesBackWithParent"&&j!=="createdSince")continue;let T=X(s,a,j);for await(let $ of G(T)){let Q=te($,T),$e=(P.flagsOf(Q)&Mi[j])!==0;if(!m&&!(t===2?$e:j==="comesBackWithParent"&&$e&&B?.comes.has(Q.slice(0,15))))continue;$e&&P.add(Q,lo),$e&&gn.has(j)&&(P.flagsOf(Q)&de.carrier)!==0&&K.add(Q);let mn=M?.other.flagsOf(Q)??0,en=m&&M?.own.has(Q)===!0;if(mn>0||!($e||en)){let ve=mn>0?"changedDuringRewind":"changedSincePreview";O.add(a,ve,Q,mn>0?oe[mn-1]:void 0),gn.has(j)&&N.add(Q,Ne[ve]);continue}if(B!==void 0&&m){let ve=Q.slice(0,15);if(j==="comesBackWithParent"&&!B.comes.has(ve))continue;if((j==="withParent"||j==="toRecreate")&&B.left.has(ve)){H(a,"needsUnpickedParent",Q,B.left.get(ve));continue}let be=B.fields.get(ve);if(be!==void 0&&(j==="giveBack"||j==="toRecreate"||j==="inBin"||j==="withParent")){H(a,"needsUnpickedParent",Q,be.needs),await C.add({Id:Q,fields:be.fields}),q++;let nn=Array.isArray($.fields)?$.fields:[],tn=nn.filter(on=>typeof on=="string"&&!be.fields.some(bo=>bo.toLowerCase()===on.toLowerCase()));if(j==="giveBack"&&nn.length>0&&tn.length===0)continue}}if(j==="toRecreate"&&!e.acceptRecreate){O.add(a,"recreateNotAccepted",Q);continue}await W(j).add(j==="giveBack"?$:{Id:Q}),j==="giveBack"&&B!==void 0&&ne.add(Q,y),gn.has(j)?_.add(Q,y):j==="comesBackWithParent"?(z.add(Q),S.nextPassDeleted++):j==="carrier"?(z.add(Q),Y.add(Q),S.carriers=(S.carriers??0)+1,S.nextPassDeleted++):j==="inBin"||j==="deletedWhileTaken"?S.broughtBack++:j==="withParent"?S.backWithParent++:j==="toRecreate"&&S.recreated++,(j==="inBin"||j==="withParent")&&await W("giveBack").add({Id:Q})}}for(let j of U.values())await j.flush();S.skipped=m?P.count(j=>(j&lo)===0):0}await C.flush();let ce=new Map,re=new Z;if(B!==void 0){let w=new Z;for(let a of u){let m=a.objectApiName;if(v(m)||a.cascadeParents.length===0)continue;let y=new Z;for(let P of gn){let M=X(s,m,P);for await(let U of G(M))y.add(te(U,M))}let S=m===Me?await mo(s,P=>_.has(P)):void 0;for await(let P of G(Re(s,m))){if(typeof P.Id!="string"||!we.test(P.Id)||_.has(P.Id))continue;let M=y.has(P.Id),U=M&&(Ge(P.CreatedDate)>=c||S!==void 0&&_n(P,S))&&Ge(P.LastModifiedDate)<=h;U&&e.acceptOutside&&re.add(P.Id);for(let W of I(a,P)){let j=_.flagsOf(W);if(j>0){if(N.has(W)||U&&e.acceptOutside)continue;let $=u[j-1].objectApiName;ce.set(W.slice(0,15),m),U?(N.add(W,Ne.outsideNotAccepted),H($,"outsideNotAccepted",W,m)):N.add(W,Ne.holdsLeft);continue}let T=ne.flagsOf(W);M&&T>0&&w.add(W)&&H(u[T-1].objectApiName,"heldByUnpicked",W,m)}}}}if(n.scope.mode==="picked"&&!e.acceptOutside)for(let w of u){let a=X(s,w.objectApiName,"outsideParents");for await(let m of G(a)){let y=te(m,a);!_.has(y)||N.has(y)||K.has(y)||(N.add(y,Ne.outsideNotAccepted),O.add(w.objectApiName,"outsideNotAccepted",y))}}for await(let{row:w,by:a}of Zi(s,k,_,N,h)){let m=te(w,Re(s,Me));Ge(w.LastModifiedDate)<=(A.get(m.slice(0,15))??Number.NaN)||(N.add(m,Ne.changedDuringRewind),O.add(Me,"changedDuringRewind",m,a))}let Ee=u.map(w=>({object:w,file:Re(s,w.objectApiName)}));for(let w=N.size>0;w;){p(),w=!1;for(let{object:a,file:m}of Ee)for await(let y of G(m)){if(!N.has(y.Id))continue;let S=ce.get(String(y.Id).slice(0,15));for(let P of I(a,y))!_.has(P)||N.has(P)||(N.add(P,Ne.holdsLeft),S!==void 0&&ce.set(P.slice(0,15),S),w=!0)}}for(let{object:w,file:a}of Ee)for await(let m of G(a))if(_.has(m.Id)&&N.flagsOf(m.Id)===Ne.holdsLeft){let y=te(m,a),S=ce.get(y.slice(0,15));S!==void 0?H(w.objectApiName,"holdsLeft",y,S):O.add(w.objectApiName,"holdsLeft",y)}let pe=new Z,Oe=w=>_.has(w)&&!N.has(w),Ce=w=>Oe(w)||pe.has(w),me=new Map,Te=new Map,ue=w=>{let a=w.slice(0,15);return Te.get(a)??a},ye=new Z,ge=[...u].reverse(),he=[],je=[],Je=async()=>{let w=new Z;for(let m of gn){let y=X(s,ie,m);for await(let S of G(y))w.add(te(S,y))}let a=new Map;if(w.size===0)return a;for await(let m of G(Re(s,ie))){let y=typeof m.Id=="string"?m.Id:"";if(!w.has(y)||Oe(y)||pe.has(y))continue;let S=m.AccountId;typeof S=="string"&&we.test(S)&&a.set(y.slice(0,15),S.slice(0,15))}return a};for(let w of ge){p();let a=w.objectApiName,m=Re(s,a),y=new an(Ei(i,a)),S=new an(Ti(i,a)),P=0,M=0,U=B!==void 0&&!v(a),W=a===Me?await Je():void 0,j=a===Me?await mo(s,T=>Ce(T)):void 0;for await(let T of G(m)){let $=typeof T.Id=="string"?T.Id:"";if(!Oe($)){if(U&&re.has($)){let be=I(w,T).filter(Ce);if(be.length===0)continue;let nn=ue(be[0]);if(be.some(on=>ye.has(on))||F(w,T).some(on=>Ce(on)&&ue(on)!==nn)){ye.add($),e.acceptNoUndo?(_.add($,(k.get(a)??0)+1),f(a).undoCannot++,await y.add({Id:$,parents:[...be,...F(w,T).filter(Ce)]}),P++):(N.add($,Ne.beforeParentNotAccepted),O.add(a,"beforeParentNotAccepted",$));continue}pe.add($),Te.set($.slice(0,15),nn),f(a).withParentDeleted++,await S.add({Id:$,parent:nn}),M++,Wn([a]).length>0&&me.set(a,[...me.get(a)??[],$])}continue}let Q=Ge(T.LastModifiedDate),$e=I(w,T).filter(Ce);if($e.length>0&&(Ge(T.CreatedDate)>=c||j!==void 0&&_n(T,j))&&(Q<=h||Q<=(A.get($.slice(0,15))??Number.NaN))){let be=ue($e[0]);if(!($e.some(tn=>ye.has(tn))||F(w,T).some(tn=>Ce(tn)&&ue(tn)!==be))){pe.add($),Te.set($.slice(0,15),be),f(a).withParentDeleted++,await S.add({Id:$,parent:be}),M++;continue}ye.add($)}let en=[...I(w,T),...F(w,T)].filter(Ce);if(en.length===0&&W!==void 0&&_n(T,W)){N.add($,Ne.contactKept),B!==void 0&&!v(ie)?H(a,"contactKept",$,ie):O.add(a,"contactKept",$);continue}if(w.undeletable&&en.length===0)continue;let ve=en.length>0?"beforeParentNotAccepted":"noUndoNotAccepted";e.acceptNoUndo?(f(a).undoCannot++,en.length>0&&(await y.add({Id:$,parents:en}),P++)):(N.add($,Ne[ve]),O.add(a,ve,$))}await y.flush(),P>0&&he.push({objectApiName:a,count:P,file:y.file}),await S.flush(),M>0&&je.push({objectApiName:a,count:M,file:S.file})}let Qe=new Ke(`${i}/deletes`),ze=new Ke(`${i}/along-to-draft`),Ze={},fe=new Z,Le=0;for(let w of u){p();let a=w.objectApiName,m=Re(s,a);for(let S of me.get(a)??[])await ze.add(a,S);let y=0;for await(let S of G(m)){let P=typeof S.Id=="string"?S.Id:"";if(_.has(P)&&(Le++,!N.has(P))){for(let M of I(w,S))fe.has(M)||fe.add(M,(k.get(a)??0)+1);if(pe.has(P)){Wn([a]).length>0&&await ze.add(a,P);continue}await Qe.add(a,P),y++,t===2&&R(S)&&typeof S.LastModifiedDate=="string"&&(Ze[P]=S.LastModifiedDate)}}f(a).deleted=y}if(Le!==_.size)throw new Error("The fresh diff's reads do not hold every record its classes name to delete.");let Xe=await Gn.of(Qe),cn=await Gn.of(ze),Pe=new Z;if(t===1&&z.size>0){for(let w of u)for await(let a of G(bn(s,w.objectApiName)))if(z.has(a.Id))for(let m of I(w,a))Pe.add(m)}let _e=new Map;for(let w of u){let a=await _i(w,s,i,["inBin","deletedWhileTaken"]);if(a.size===0)continue;_e.set(w.objectApiName,a);let m=f(w.objectApiName);m.broughtBack-=a.size,m.keyTaken=a.size;for(let y of["inBin","deletedWhileTaken"]){let S=X(i,w.objectApiName,y);for await(let P of G(S)){let M=te(P,S);a.has(M)&&O.add(w.objectApiName,"keyTaken",M)}}}let Ye=new Ke(`${i}/giveBackFirst`),hn=new Ke(`${i}/giveBackAfter`),qe=[];for(let w of u){p();let a=w.objectApiName,m=X(i,a,"giveBack"),y=!1;for await(let W of G(m))if(fe.has(W.Id)){y=!0;break}let S=new Z;if(y)for await(let W of G(Re(s,a)))fe.has(W.Id)&&I(w,W).some(Oe)&&S.add(String(W.Id));let P=f(a),M=new Set,U=_e.get(a);for await(let W of G(m)){let j=te(W,m);if(U?.has(j)===!0)continue;let T=fe.flagsOf(j),$=S.has(j);if(T>0){if(await hn.add(a,j),P.givenBackAfter++,M.add(u[T-1].objectApiName),!$)continue}else if(!$&&Pe.has(j)){P.givenBackNextPass++;continue}await Ye.add(a,j),P.givenBackFirst++}M.size>0&&qe.push({objectApiName:a,by:[...M]})}let b=new Ke(`${i}/bringBack`),E=new Ke(`${i}/recreate`);for(let w of ge){let a=_e.get(w.objectApiName);for(let y of["carrier","inBin","deletedWhileTaken"]){let S=X(i,w.objectApiName,y);for await(let P of G(S)){let M=te(P,S);a?.has(M)!==!0&&await b.add(w.objectApiName,M)}}let m=X(i,w.objectApiName,"toRecreate");for await(let y of G(m))await E.add(w.objectApiName,te(y,m))}let V=new Z;if(t===2)for(let w of u)for(let a of["inBin","withParent","deletedWhileTaken","carrier","toRecreate"]){let m=X(o,w.objectApiName,a);for await(let y of G(m))V.add(te(y,m))}let J=n.files===void 0||!v(le)?yo(i):await Wi({confirmedDir:o,freshDir:s,dir:i,pass:t,deleted:w=>we.test(w)&&Oe(w),earlier:w=>we.test(w)&&(V.has(w)||V.has(e.recreated?.originalOf(w.slice(0,15))??w)),left:O}),ke=new Ke(`${i}/unlinkFrom`);for(let w of gn){let a=X(i,le,w);for await(let m of G(a)){let y=te(m,a);(N.flagsOf(y)&Ne.outsideNotAccepted)!==0&&await ke.add(le,y)}}let dn={...e.removalStamps,...Ze},wn=Object.keys(dn).length>0,pn=u.map(({objectApiName:w})=>f(w)).filter($i);return{pass:t,dir:i,deletes:Xe,removal:{runStartedAt:new Date(c),runEndedAt:new Date(h),includeChanged:!1,...wn?{removalStamps:dn}:{},...e.removalSpans&&e.removalSpans.length>0?{removalSpans:[...e.removalSpans]}:{}},bringBack:await b.finish(),carriers:Y,goesAlong:pe,along:je.reverse(),alongToDraft:cn,recreate:await E.finish(),giveBack:{beforeDeletes:await Ye.finish(),afterDeletes:await hn.finish(),heldBy:qe},restore:{changedAfter:e.readAt,ownWriters:[...e.ownWriters],includeChanged:!1,...wn?{stamps:dn}:{}},objects:pn,undoCannot:pn.filter(w=>w.undoCannot>0).map(({objectApiName:w,undoCannot:a})=>({objectApiName:w,count:a})),beforeParent:he.reverse(),left:O.all(k),links:{...J,unlinkFrom:await ke.finish()},...B!==void 0?{limited:{objects:u.map(({objectApiName:w})=>w).filter(v),needs:[...x].sort(([w],[a])=>(k.get(w)??0)-(k.get(a)??0)).map(([w,a])=>({objectApiName:w,records:a.size})),why:L,leftFields:{file:C.file,count:q}}}:{}}}function or(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 Ki=200;function ir(e,n){return async function*(t,o){if(o.length===0)return;let s=await He.read(n,e.snapshotId,t);for(let i=0;i<o.length;i+=sn){let r=await s.chunk(o.slice(i,i+sn)).batches(e.snapshotId,t,Ki);for await(let c of r??[])yield*c}}}var Vi=new Set(["needsUnpickedParent","heldByUnpicked","outsideNotAccepted","holdsLeft","contactKept","keyTaken"]);async function Ji(e,n){let t=0;for await(let o of G(X(e,n,"giveBack")))Array.isArray(o.fields)&&t++;return t}async function Qi(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),...i.withParentDeleted>0?{withParent:i.withParentDeleted}:{},toGiveBack:await Ji(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)||!Vi.has(i.reason))continue;let r=`${i.objectApiName}\0${i.reason}`,c=o.get(r);c?c.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 c=e.beforeParent.find(h=>h.objectApiName===i),l=r-(c?.count??0);return[...l>0?[{objectApiName:i,count:l}]:[],...c!==void 0&&c.count>0?[{objectApiName:i,count:c.count,reason:"deletedBeforeParent"}]:[]]});return{objects:[...n],acts:t,left:[...o.values()],needs:e.limited?.needs??[],undoCannot:s}}async function sr(e){let n=$n(e.previewDir,`selection-${Pi(4).toString("hex")}`);try{let t=await Hi({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 Qi(t)}finally{await ji(n,{recursive:!0,force:!0})}}function _n(e,n){let{ContactId:t,AccountId:o}=e;if(typeof t!="string"||typeof o!="string")return!1;let s=n.get(t.slice(0,15));return s!==void 0&&s===o.slice(0,15)}async function mo(e,n){let t=new Map;for await(let o of G(Re(e,ie))){if(typeof o.Id!="string"||!n(o.Id))continue;let s=o.AccountId;typeof s=="string"&&we.test(s)&&t.set(o.Id.slice(0,15),s.slice(0,15))}return t}async function*Zi(e,n,t,o,s){if(!n.has(Me)||!n.has(ie))return;let i=new Map;for await(let r of G(Re(e,ie))){if(!t.has(r.Id)||o.has(r.Id))continue;let c=r.AccountId;typeof c=="string"&&we.test(c)&&i.set(String(r.Id).slice(0,15),c.slice(0,15))}if(i.size!==0)for await(let r of G(Re(e,Me))){if(!t.has(r.Id)||o.has(r.Id)||!_n(r,i)||!(Ge(r.LastModifiedDate)>s))continue;let c=typeof r.LastModifiedById=="string"?r.LastModifiedById:void 0;yield{row:r,by:c}}}function ko(e,n,t,o){let s=Ge(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 Xi(e,n,t,o,s,i){let r={own:new Z,other:new Z};for(let c of[Re(e,n),bn(e,n)])for await(let l of G(c)){if(!(Ge(l.LastModifiedDate)>t))continue;let p=te(l,c);if(ko(l,t,o,s)){r.own.add(p);continue}let u=typeof l.LastModifiedById=="string"?l.LastModifiedById:"",k=i.indexOf(u);k<0&&(i.push(u),k=i.length-1),r.other.add(p,k+1)}return r}export{et as a,ws as b,X as c,Zo as d,Ts as e,nr as f,tr as g,Hi as h,or as i,ir as j,Qi as k,sr as l};
|
|
@@ -0,0 +1,7 @@
|
|
|
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}from"./chunk-SOOTWGMQ.mjs";import"./chunk-O6FHK6NQ.mjs";import"./chunk-GFB2DNCB.mjs";import"./chunk-JFXQZPRY.mjs";import"./chunk-BBZUGKBZ.mjs";import"./chunk-P4YOHLZ4.mjs";import"./chunk-BLMJ4WVI.mjs";import"./chunk-4NSXPONF.mjs";import"./chunk-XBYXT74L.mjs";import"./chunk-2YJJTQNC.mjs";import"./chunk-4VLP6RHC.mjs";import"./chunk-FV6MOSHD.mjs";import"./chunk-YTOTMJTY.mjs";import"./chunk-WJGK6VGU.mjs";import"./chunk-3L6DVNCR.mjs";import"./chunk-54V4FVEY.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-TZXYVMZC.mjs";import"./chunk-CJAWKLAL.mjs";import"./chunk-PE7CHD2W.mjs";import"./chunk-VKREON6Q.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-VFKG2G37.mjs";import"./chunk-CL75DEMQ.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-7O6EFNQS.mjs";import"./chunk-3LRFPGYZ.mjs";import"./chunk-KWUS7UAV.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-NV5QA2HY.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-YDXMTWAT.mjs";import"./chunk-PVZ72OOQ.mjs";import"./chunk-QIRO4HTE.mjs";import"./chunk-TYUYPFDJ.mjs";import"./chunk-DLSU66MY.mjs";import"./chunk-ATQML7ZK.mjs";import"./chunk-H6BHWAX7.mjs";import"./chunk-4CSBZZAL.mjs";import"./chunk-GP5J3DGS.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-OT2NHL2V.mjs";import"./chunk-ZVU7MD2S.mjs";import"./chunk-OLCS7JCT.mjs";import"./chunk-TQ6HEJ73.mjs";import"./chunk-65AMXOQU.mjs";import"./chunk-6HHSAPIM.mjs";import"./chunk-K5PUMHZU.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-EUIALBMX.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-Q7TLC3I2.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-ATBQIE2V.mjs";import"./chunk-UCUFLFNK.mjs";import"./chunk-4XROG5CT.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-DAUX63UB.mjs";import"./chunk-SZOJ7BEJ.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-22L43JMK.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-3KJCSYXY.mjs";import"./chunk-HDDJ3CVN.mjs";import"./chunk-J347SPU6.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{b as UNDO_AUTOMATION_LIFTED_BY,a as UndoStopped,c as undoCheckpoint};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a as P,b as $}from"./chunk-
|
|
7
|
+
import{a as P,b as $}from"./chunk-4NSXPONF.mjs";import{a as O,b,d as E,e as D}from"./chunk-65AMXOQU.mjs";import{b as S}from"./chunk-CA5NAXSU.mjs";import{A as m,fd as R}from"./chunk-J347SPU6.mjs";var y=[{field:"PermissionsViewAllData",label:"View All Data"},{field:"PermissionsModifyAllData",label:"Modify All Data"}],I="PermissionsQueryAllFiles",T="PermissionsCustomizeApplication",d="No record was read or written.";function c(e,t){return{allowed:!1,refusal:{code:e,message:t}}}function w(e,t){return c("PRODUCTION",`${e} is a production org, or cannot be told from one: ${t}. Checkpoints are for sandboxes, scratch orgs and Developer Edition orgs: SandForge never takes a checkpoint of, or rewinds, a production org. ${d}`)}function N(e){return e.edition?`its Organization record says IsSandbox false, edition ${e.edition}`:"its Organization record says IsSandbox false, and no edition"}function j(e,t){return e.slice(0,15)===t.slice(0,15)}function V(e,t){return e.orgType==="Scratch"?"scratch":t.sandbox?"sandbox":"developer"}var z={take:"A checkpoint needs a user with View All Data and Modify All Data: a rewind to it must",preview:"A preview needs a user with View All Data and Modify All Data: a record the user cannot see would read as deleted since, and the rewind it shows must",rewind:"Rewind needs a user with View All Data and Modify All Data: it must",undo:"Undo needs a user with View All Data and Modify All Data: it must",import:"An import needs a user with View All Data and Modify All Data: SandForge never keeps on this machine records its user could not see in the org, and a rewind to it must"},F={take:"Leave the custom settings out of the checkpoint, or give the user Customize Application.",preview:"This checkpoint holds custom settings: give the user Customize Application.",rewind:"This checkpoint holds custom settings: give the user Customize Application.",undo:"This checkpoint holds custom settings: give the user Customize Application.",import:"This checkpoint holds custom settings: give the user Customize Application."};function x(e){return c("PERMISSIONS",`${e.username} needs Customize Application to keep and rewind custom settings, and doesn't have it: View All Custom Settings lets a user read them, never write them. ${F[e.act]} ${d}`)}async function _(e,t){let r=[...y.map(n=>n.field),...t?[T]:[]],i=async n=>(await e.query(`SELECT ${n.join(", ")} FROM UserPermissionAccess`)).records[0],o;try{o=await i([...r,I])}catch{try{o=await i(r)}catch(n){return{unread:n instanceof Error?n.message:String(n)}}}return{missing:y.filter(n=>o?.[n.field]!==!0).map(n=>n.label),viewAllData:o?.PermissionsViewAllData===!0,modifyAllData:o?.PermissionsModifyAllData===!0,queryAllFiles:o?.[I]===!0,customizeApplication:o?.[T]===!0}}var q=/^005[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/,L=/^0PG[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/,M="SobjectType, PermissionsViewAllRecords, PermissionsModifyAllRecords";async function A(e,t){let r=await e.query(t),i=1,o=[...r.records];for(;!r.done;){let n=r.nextRecordsUrl;if(n===void 0||e.queryMore===void 0)throw new Error(`the org answered ${o.length} rows of ${r.totalSize}, and no next page`);r=await e.queryMore(n),i++,o.push(...r.records)}return{rows:o,requests:i}}async function U(e,t){let r=0;try{let i=await t();if(r++,!q.test(i))throw new Error(`the org named the user ${JSON.stringify(i)}`);let o=await A(e,`SELECT ${M} FROM ObjectPermissions WHERE ParentId IN (SELECT PermissionSetId FROM PermissionSetAssignment WHERE AssigneeId = '${i}' AND PermissionSetGroupId = null)`);r+=o.requests;let n=await A(e,`SELECT PermissionSetGroupId FROM PermissionSetAssignment WHERE AssigneeId = '${i}' AND PermissionSetGroupId != null`);r+=n.requests;let l=[...new Set(n.rows.map(a=>a.PermissionSetGroupId).filter(a=>typeof a=="string"&&L.test(a)))],s=[...o.rows];if(l.length>0){let a=await A(e,`SELECT ${M} FROM ObjectPermissions WHERE Parent.PermissionSetGroupId IN (${l.map(u=>`'${u}'`).join(", ")})`);r+=a.requests,s.push(...a.rows)}return{grants:P(s),requests:r}}catch(i){return{unread:S(i)}}}var v={take:"A checkpoint needs a user with View All Data and Modify All Data, or with View All and Modify All on each object it holds: a rewind to it must see and put back what everyone changed there.",preview:"A preview needs a user with View All Data and Modify All Data, or with View All and Modify All on each object it reads: a record the user cannot see would read as deleted since.",rewind:"Rewind needs a user with View All Data and Modify All Data, or with View All and Modify All on each object it puts back: it must see and put back what everyone changed there.",undo:"Undo needs a user with View All Data and Modify All Data, or with View All and Modify All on each object it takes back: it must see and put back what everyone changed there."};async function Y(e,t,r={}){let{orgName:i,registered:o}=t;if(o===void 0)return w(i,"SandForge has no record of what kind of org it is");if(!R(o))return w(i,"SandForge has it registered as a production org");let n;try{n=await O(e)}catch(p){let C=E(p);if(C!==void 0)return c("ORG_UNTYPED",`${D(i,p,C)} SandForge takes a checkpoint of no org it cannot tell from a production one. ${d}`);let G=p instanceof Error?p.message:String(p);return w(i,`it did not say what org it is (${G})`)}if(b(n))return w(i,N(n));if(t.act!=="take"&&!j(n.id,t.organizationId))return c("OTHER_ORG",t.act==="import"?`${i} is another org than the one this file holds a checkpoint of: it is imported for the org it was taken of alone, under any alias of it. ${m} Replay the file in ${i} instead. Nothing was imported.`:`${i} is another org than the one this checkpoint was taken of: its Organization Id has changed, as a sandbox's does when it is refreshed. This checkpoint is of the org before it, and no longer rewinds. ${m} `+d);let l=t.customSettings===!0,s=await _(e,l),a=`${z[t.act]} see and put back what everyone changed.`;if("unread"in s)return c("PERMISSIONS",`${a} SandForge could not read whether ${t.username} has them (${s.unread}), and takes an org that will not say for a user who has neither. `+d);let u=s.missing.length===y.length?"them":s.missing.join(" and "),g=t.act,f=g==="import"?void 0:r.userId;if(s.missing.length>0&&f===void 0)return c("PERMISSIONS",`${a} ${t.username} doesn't have ${u}. ${d}`);if(l&&!s.customizeApplication)return x(t);let k={allowed:!0,org:n,tier:V(o,n),queryAllFiles:s.queryAllFiles};if(s.missing.length===0||f===void 0||g==="import")return{...k,grants:{kind:"org"}};let h=await U(e,f);return"unread"in h?c("PERMISSIONS",`${v[g]} ${t.username} doesn't have ${u}, and SandForge could not read which objects they have View All and Modify All on (${h.unread}). View Setup and Configuration lets a user read their own permissions; with View All Data and Modify All Data, nothing needs reading. `+d):$(h.grants)?{...k,grants:{kind:"perObject",viewAllData:s.viewAllData,modifyAllData:s.modifyAllData,objects:h.grants,requests:h.requests}}:c("PERMISSIONS",`${v[g]} ${t.username} doesn't have ${u}, nor View All and Modify All on any object. Give the user View All and Modify All on the objects to hold, or View All Data and Modify All Data. ${d}`)}export{U as a,Y as b};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{
|
|
7
|
+
import{mc as o,qd as d}from"./chunk-J347SPU6.mjs";var u=new Set(["picklist","multipicklist"]);function c(a){return(a.picklistValues??[]).filter(s=>s.active!==!1&&typeof s.value=="string"&&s.value!=="").map(s=>s.value)}function m(a){let s=new Map,r=i=>{let t=s.get(i);return t||(t=a(i),s.set(i,t)),t};return{async createable(i){let{fields:t}=await r(i);return new Set(t.filter(e=>e.createable===!0).map(e=>e.name))},async visible(i){let{fields:t}=await r(i);return new Set(t.map(e=>e.name))},async computed(i){let{fields:t}=await r(i);return new Set(t.filter(e=>e.calculated===!0||e.autoNumber===!0).map(e=>e.name))},async picklistValues(i){let{fields:t}=await r(i),e=new Map;for(let n of t){if(!u.has(n.type??""))continue;let l=c(n);l.length>0&&e.set(n.name,l)}return e},async keyPrefix(i){let{keyPrefix:t}=await r(i);return typeof t=="string"&&t.length===3?t:void 0},async lengths(i){let{fields:t}=await r(i);return new Map(t.flatMap(e=>typeof e.length=="number"&&e.length>0?[[e.name,e.length]]:[]))},async unset(i){let{fields:t}=await r(i),e=n=>n.type==="reference"||(n.referenceTo??[]).length>0;return{empty:new Set(t.filter(n=>e(n)&&n.nillable===!0&&n.defaultedOnCreate!==!0).map(n=>n.name)),filled:new Set(t.filter(n=>n.nillable===!1||n.defaultedOnCreate===!0).map(n=>n.name))}},async required(i){let{fields:t}=await r(i);return t.filter(e=>e.createable===!0&&e.nillable===!1&&e.defaultedOnCreate!==!0&&(e.referenceTo??[]).length===0).map(e=>({fieldApiName:e.name,type:e.type??"string",picklistValues:c(e),referenceTo:[],length:e.length??0,integerDigits:o({...e,type:e.type??"string"}),objectApiName:i,required:!0}))}}}function p(a,s){return async r=>(await a.required(r)).filter(i=>!d(r,i.fieldApiName,s.includes(r)?"person":"business"))}export{m as a,p as b};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}from"./chunk-
|
|
7
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}from"./chunk-YJ27WHKR.mjs";import"./chunk-VUTQY76O.mjs";import"./chunk-UV74P4H2.mjs";import"./chunk-4CSBZZAL.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-22L43JMK.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-J347SPU6.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{p as ObservedUsersRunStore,c as RECOVERY_CATEGORY,h as USERS_RUN_NOT_FOUND,i as USERS_RUN_REPLACED,a as awaitingAddressesOf,m as changingUsersOf,k as choicesKeyOf,l as planSignatureOf,f as readSavedTesters,d as recoveryTestersKey,b as recoveryUsersOf,j as replacedRunOf,g as saveTesters,e as savedTestersSchema,o as usersAuditObjectsOf,n as usersDoneOf};
|