sandforge 1.83.0 → 1.84.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/chunk-23SEDORH.mjs +11 -0
- package/lib/{chunk-I5C4O3VA.mjs → chunk-24RFOFYT.mjs} +1 -1
- package/lib/chunk-26POJDIT.mjs +7 -0
- package/lib/{chunk-WJAZ5LHL.mjs → chunk-2AZQHBEF.mjs} +1 -1
- package/lib/{chunk-IHGYJZZ2.mjs → chunk-2HVOZUM4.mjs} +1 -1
- package/lib/{chunk-3V4YH5KO.mjs → chunk-2JDAOWUW.mjs} +1 -1
- package/lib/{chunk-BNKT3R3F.mjs → chunk-2METQHGG.mjs} +1 -1
- package/lib/chunk-2WFIVO4F.mjs +13 -0
- package/lib/chunk-2YHZBUZE.mjs +7 -0
- package/lib/{chunk-7DPHZWA4.mjs → chunk-326AJTIU.mjs} +14 -14
- package/lib/{chunk-UIR77ZJD.mjs → chunk-36JOHEJL.mjs} +1 -1
- package/lib/chunk-3PVRGTVK.mjs +7 -0
- package/lib/{chunk-2WMKJVD2.mjs → chunk-3Q353S2R.mjs} +1 -1
- package/lib/chunk-3TZSBHEY.mjs +7 -0
- package/lib/{chunk-T36DZJPH.mjs → chunk-43TOMFV4.mjs} +1 -1
- package/lib/{chunk-XAMMIPZ4.mjs → chunk-4CVUUVGJ.mjs} +1 -1
- package/lib/{chunk-6YC2ELCU.mjs → chunk-4EOHEDFP.mjs} +1 -1
- package/lib/{chunk-ZB5E7NHU.mjs → chunk-4JE4BYXK.mjs} +1 -1
- package/lib/{chunk-JREKJO3D.mjs → chunk-54WZUS7J.mjs} +1 -1
- package/lib/{chunk-CGZGL6VT.mjs → chunk-5CRLRHOJ.mjs} +1 -1
- package/lib/{chunk-UOHZW2L4.mjs → chunk-5IZTFMJM.mjs} +1 -1
- package/lib/{chunk-6VOQFISN.mjs → chunk-5M5FQ7RP.mjs} +1 -1
- package/lib/{chunk-U4YFYSF3.mjs → chunk-5SMWFNE7.mjs} +1 -1
- package/lib/{chunk-HQZUQXDC.mjs → chunk-5XTUSN72.mjs} +1 -1
- package/lib/chunk-6I6TWNV5.mjs +7 -0
- package/lib/{chunk-QLRWU3MB.mjs → chunk-6JWWSDM6.mjs} +1 -1
- package/lib/chunk-6O222PW6.mjs +7 -0
- package/lib/{chunk-J3TIHLWG.mjs → chunk-6PD6K7LP.mjs} +1 -1
- package/lib/{chunk-ISAUCWYK.mjs → chunk-6QE6R6RL.mjs} +1 -1
- package/lib/{chunk-2KTGDYUH.mjs → chunk-6WX5ZU7Q.mjs} +1 -1
- package/lib/{chunk-XAUQXYPW.mjs → chunk-6YL7BNYD.mjs} +1 -1
- package/lib/chunk-6ZLKIT3H.mjs +7 -0
- package/lib/{chunk-XKFHTBAB.mjs → chunk-7QYHEHMA.mjs} +1 -1
- package/lib/chunk-7SQSWVAU.mjs +9 -0
- package/lib/{chunk-NNV7IGM7.mjs → chunk-7UVKIWKV.mjs} +1 -1
- package/lib/{chunk-RZKJQOOC.mjs → chunk-7WATA4SB.mjs} +1 -1
- package/lib/{chunk-DMT5SCO3.mjs → chunk-7YNM6KFZ.mjs} +1 -1
- package/lib/{chunk-TMIESDE5.mjs → chunk-A3MYSOOC.mjs} +1 -1
- package/lib/chunk-AL4C3GFT.mjs +7 -0
- package/lib/chunk-B3FBHVNN.mjs +21 -0
- package/lib/{chunk-CDWZGQAJ.mjs → chunk-B63POIPQ.mjs} +1 -1
- package/lib/{chunk-YEVB7LVK.mjs → chunk-BAWCOKRW.mjs} +1 -1
- package/lib/{chunk-FVLFO2S6.mjs → chunk-BBRWFKS5.mjs} +1 -1
- package/lib/chunk-BEA27DLS.mjs +7 -0
- package/lib/chunk-BRY3PLIZ.mjs +7 -0
- package/lib/chunk-CBH3TOWK.mjs +341 -0
- package/lib/{chunk-7V2UYZ6S.mjs → chunk-CPQIZGG5.mjs} +1 -1
- package/lib/chunk-CVHNXJH3.mjs +7 -0
- package/lib/{chunk-ZOSESZ22.mjs → chunk-D4GF4FAB.mjs} +1 -1
- package/lib/chunk-DGDRQRCW.mjs +7 -0
- package/lib/{chunk-2N73W63D.mjs → chunk-DPMRIMUC.mjs} +1 -1
- package/lib/chunk-DUN2EPRC.mjs +7 -0
- package/lib/chunk-E3A3LOCY.mjs +7 -0
- package/lib/{chunk-KWAVSZ2B.mjs → chunk-EAC5QCE3.mjs} +1 -1
- package/lib/{chunk-JUOQUG7U.mjs → chunk-EC72TIEG.mjs} +1 -1
- package/lib/chunk-EPFCERGL.mjs +7 -0
- package/lib/{chunk-6KOUYHEY.mjs → chunk-ETDCBLGU.mjs} +1 -1
- package/lib/{chunk-2R6GFNKF.mjs → chunk-F3AQW6IU.mjs} +1 -1
- package/lib/{chunk-AHUGG3WU.mjs → chunk-FITPY3L4.mjs} +1 -1
- package/lib/chunk-FNJ4SGWO.mjs +7 -0
- package/lib/{chunk-EOQON3E5.mjs → chunk-FP7CYB2F.mjs} +1 -1
- package/lib/{chunk-262TP6UU.mjs → chunk-GKY2JMHY.mjs} +1 -1
- package/lib/{chunk-JBWJ6UEZ.mjs → chunk-GMIGWR6U.mjs} +1 -1
- package/lib/{chunk-OS5GE52G.mjs → chunk-GNRSF65U.mjs} +1 -1
- package/lib/chunk-GOOVPVWX.mjs +7 -0
- package/lib/{chunk-DB5RVDC5.mjs → chunk-GWZRR3MM.mjs} +1 -1
- package/lib/{chunk-SX6QWYCQ.mjs → chunk-H2BHESDA.mjs} +2 -2
- package/lib/chunk-H4CGM6YO.mjs +7 -0
- package/lib/{chunk-NFEBX75O.mjs → chunk-HCGXK7G7.mjs} +1 -1
- package/lib/{chunk-4X5D3MSV.mjs → chunk-HIDW7FNV.mjs} +1 -1
- package/lib/chunk-HSBXRQTI.mjs +7 -0
- package/lib/chunk-HUZPBE47.mjs +7 -0
- package/lib/{chunk-F5SBGJWW.mjs → chunk-HV7VPEXP.mjs} +1 -1
- package/lib/chunk-I6E6T6YY.mjs +7 -0
- package/lib/chunk-IUM4NFKI.mjs +10 -0
- package/lib/chunk-IVFVNNGB.mjs +37 -0
- package/lib/{chunk-L4MSL4U7.mjs → chunk-IZGCEOYO.mjs} +1 -1
- package/lib/{chunk-E3RQ575Y.mjs → chunk-J3DND3BC.mjs} +1 -1
- package/lib/{chunk-MJD6CPZZ.mjs → chunk-JAEDM4SI.mjs} +1 -1
- package/lib/chunk-JCFBFF4Y.mjs +7 -0
- package/lib/{chunk-U2CTKIPE.mjs → chunk-JE6SCT6R.mjs} +1 -1
- package/lib/{chunk-XJICAOAQ.mjs → chunk-JGZPD4IM.mjs} +1 -1
- package/lib/{chunk-XCJUNX63.mjs → chunk-JKJ74BX5.mjs} +1 -1
- package/lib/{chunk-WAYQLQAD.mjs → chunk-JLSIWO4Z.mjs} +1 -1
- package/lib/{chunk-D7XUNWWU.mjs → chunk-JSAJS3MY.mjs} +1 -1
- package/lib/chunk-JTJK2D36.mjs +7 -0
- package/lib/{chunk-OTJH6AEA.mjs → chunk-KAZS5Z6W.mjs} +1 -1
- package/lib/chunk-KB4ZHM4Q.mjs +10 -0
- package/lib/{chunk-N2HYG3BL.mjs → chunk-KGU4SVIT.mjs} +1 -1
- package/lib/{chunk-FKCIGJOI.mjs → chunk-KJWFYBMU.mjs} +2 -2
- package/lib/{chunk-KXUOHACP.mjs → chunk-KZTZDC7H.mjs} +1 -1
- package/lib/{chunk-S4PRKKGC.mjs → chunk-L2E5WBGD.mjs} +1 -1
- package/lib/{chunk-X2XZQ434.mjs → chunk-L53JWJ3S.mjs} +1 -1
- package/lib/{chunk-CQAFVEKP.mjs → chunk-LA4KIATH.mjs} +6 -6
- package/lib/chunk-LC3NDW4N.mjs +7 -0
- package/lib/{chunk-4V3QO7HF.mjs → chunk-LKTNQEBS.mjs} +1 -1
- package/lib/chunk-M2ABR4JM.mjs +7 -0
- package/lib/{chunk-3CM7LAPE.mjs → chunk-M4BLK6HJ.mjs} +1 -1
- package/lib/{chunk-Z3MGN42K.mjs → chunk-M6K34KGF.mjs} +1 -1
- package/lib/{chunk-TUPZY2QJ.mjs → chunk-MDMPJEV3.mjs} +1 -1
- package/lib/{chunk-BVZ5H3N4.mjs → chunk-MJZU3U5O.mjs} +68 -63
- package/lib/{chunk-OUU47Y7A.mjs → chunk-MSIEU5MR.mjs} +1 -1
- package/lib/{chunk-QQDZQCO2.mjs → chunk-N4WPCWJO.mjs} +1 -1
- package/lib/{chunk-MTM4KG3T.mjs → chunk-NCZKWSC7.mjs} +1 -1
- package/lib/{chunk-Y7YUNRKK.mjs → chunk-NED4MBIM.mjs} +1 -1
- package/lib/{chunk-QKJXIY6L.mjs → chunk-NOBQTEQD.mjs} +1 -1
- package/lib/{chunk-WBELLGNE.mjs → chunk-NSQWI7ZY.mjs} +1 -1
- package/lib/{chunk-BPHTA6KP.mjs → chunk-O677VOGO.mjs} +1 -1
- package/lib/chunk-OFTT7J2M.mjs +7 -0
- package/lib/{chunk-JH4ZTVQN.mjs → chunk-OLCVHL7I.mjs} +1 -1
- package/lib/chunk-OM5NORJG.mjs +7 -0
- package/lib/{chunk-QP3JLFIO.mjs → chunk-OMNMLKDT.mjs} +1 -1
- package/lib/{chunk-WABXKL4N.mjs → chunk-OPMO6I45.mjs} +1 -1
- package/lib/{chunk-7ZBDACVG.mjs → chunk-OUZQPYT3.mjs} +1 -1
- package/lib/chunk-OVNMB6Q2.mjs +7 -0
- package/lib/{chunk-DKDKCGXV.mjs → chunk-PAXNWTYK.mjs} +1 -1
- package/lib/{chunk-GLN4PI5P.mjs → chunk-PBY2O6OF.mjs} +1 -1
- package/lib/chunk-PEDQPM2P.mjs +926 -0
- package/lib/chunk-PH7SP4YK.mjs +21 -0
- package/lib/{chunk-BT43WSOS.mjs → chunk-PMN4PAC3.mjs} +1 -1
- package/lib/chunk-PMWAFDUB.mjs +48 -0
- package/lib/chunk-PPLVFX6N.mjs +7 -0
- package/lib/{chunk-L3I6DAHX.mjs → chunk-PR3XCSPO.mjs} +1 -1
- package/lib/{chunk-WZN36ACK.mjs → chunk-PR42EZSR.mjs} +1 -1
- package/lib/{chunk-NDFFIJL5.mjs → chunk-PWRJRL5U.mjs} +1 -1
- package/lib/{chunk-NS6ONPWL.mjs → chunk-Q7GIJBCD.mjs} +1 -1
- package/lib/chunk-Q7TLC3I2.mjs +7 -0
- package/lib/{chunk-ALBY5SOH.mjs → chunk-QAFPQ3YB.mjs} +1 -1
- package/lib/{chunk-KKS2KFBT.mjs → chunk-QKEKG2LD.mjs} +1 -1
- package/lib/{chunk-OOIDCHBQ.mjs → chunk-QO53K5W2.mjs} +2 -2
- package/lib/{chunk-HVX2AFYW.mjs → chunk-QTG6LUZT.mjs} +1 -1
- package/lib/{chunk-K7G3W7XH.mjs → chunk-RE7RYF3B.mjs} +1 -1
- package/lib/{chunk-JIPT5FUD.mjs → chunk-RGBGUCJA.mjs} +1 -1
- package/lib/{chunk-GT5ZKU6V.mjs → chunk-RGUQOSBU.mjs} +1 -1
- package/lib/{chunk-VXZ5PTOM.mjs → chunk-RHNTHGNU.mjs} +1 -1
- package/lib/chunk-RKTFFCNS.mjs +7 -0
- package/lib/chunk-RMFU4BAL.mjs +28 -0
- package/lib/{chunk-DNQKVCUV.mjs → chunk-ROV3QXEF.mjs} +11 -11
- package/lib/chunk-RT47RKLY.mjs +7 -0
- package/lib/{chunk-ISOSTAJR.mjs → chunk-S42RBRH2.mjs} +1 -1
- package/lib/{chunk-27BBEGUD.mjs → chunk-SI267LYR.mjs} +1 -1
- package/lib/chunk-T3G6VZNS.mjs +7 -0
- package/lib/chunk-TNT27RBG.mjs +7 -0
- package/lib/chunk-UBIKR5VO.mjs +7 -0
- package/lib/chunk-UI3JQVRU.mjs +8 -0
- package/lib/{chunk-RVCPQVKM.mjs → chunk-UIOMAX56.mjs} +1 -1
- package/lib/chunk-UX3BVH2Y.mjs +7 -0
- package/lib/{chunk-L4RJX7DG.mjs → chunk-VCUXCK36.mjs} +1 -1
- package/lib/chunk-VINGECAJ.mjs +10 -0
- package/lib/chunk-VOXJHJIE.mjs +7 -0
- package/lib/chunk-W6PN6TJG.mjs +7 -0
- package/lib/{chunk-D6JT4PAB.mjs → chunk-WAPSSYMT.mjs} +1 -1
- package/lib/{chunk-7BQMBXKX.mjs → chunk-WUUKFE2U.mjs} +1 -1
- package/lib/chunk-WWTCWWZI.mjs +7 -0
- package/lib/chunk-WXDLQT2O.mjs +10 -0
- package/lib/{chunk-TCEXCHXR.mjs → chunk-WY5V5PR3.mjs} +1 -1
- package/lib/chunk-X4BXESMQ.mjs +7 -0
- package/lib/chunk-XBQGZGWR.mjs +7 -0
- package/lib/{chunk-AXFD2OH6.mjs → chunk-XGGOUNPP.mjs} +1 -1
- package/lib/chunk-XKWW3GKF.mjs +7 -0
- package/lib/{chunk-PDRXM5WN.mjs → chunk-Y2DRK37K.mjs} +1 -1
- package/lib/{chunk-ZXOUWHYE.mjs → chunk-YA6ATMTB.mjs} +1 -1
- package/lib/{chunk-54HYHHVL.mjs → chunk-YDXMTWAT.mjs} +1 -1
- package/lib/chunk-YHR4WQPR.mjs +7 -0
- package/lib/{chunk-LWES2KZE.mjs → chunk-YTLUYSMF.mjs} +1 -1
- package/lib/{chunk-2K5BYZQM.mjs → chunk-YWEQQL3C.mjs} +1 -1
- package/lib/{chunk-C6RKM4BB.mjs → chunk-Z4LKKOFY.mjs} +1 -1
- package/lib/chunk-ZBAWJUG2.mjs +7 -0
- package/lib/{chunk-446GBKAC.mjs → chunk-ZJW6YOMV.mjs} +1 -1
- package/lib/chunk-ZQQXSCVI.mjs +7 -0
- package/lib/{chunk-L6CLN664.mjs → chunk-ZQWIVYVM.mjs} +1 -1
- package/lib/{chunk-CXKZ6TYV.mjs → chunk-ZV7ZFQQC.mjs} +1 -1
- package/lib/sandforge-autopilot.mjs +25 -25
- package/lib/sandforge-backup.mjs +1 -1
- package/lib/sandforge-checkpoint.mjs +1 -1
- package/lib/sandforge-cleanup.mjs +1 -1
- package/lib/sandforge-clone.mjs +1 -1
- package/lib/sandforge-compare.mjs +52 -21
- package/lib/sandforge-dataops.mjs +1 -1
- package/lib/sandforge-empty.mjs +1 -1
- package/lib/sandforge-env.mjs +95 -95
- package/lib/sandforge-frozen.mjs +1 -1
- package/lib/sandforge-mcp.mjs +12 -12
- package/lib/sandforge-monitor.mjs +1 -1
- package/lib/sandforge-pipeline.mjs +1 -1
- package/lib/sandforge-seed.mjs +1 -1
- package/lib/sandforge-sync.mjs +1 -1
- package/lib/sandforge-users.mjs +1 -1
- package/lib/sandforge.mjs +1 -1
- package/lib/sf/sandforge/compare.mjs +2 -2
- package/lib/sfPlugin.mjs +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/lib/chunk-2ADSD5WK.mjs +0 -7
- package/lib/chunk-2GSMHGIV.mjs +0 -7
- package/lib/chunk-36Y225OM.mjs +0 -7
- package/lib/chunk-3OVTKRS4.mjs +0 -7
- package/lib/chunk-4GCYGQXD.mjs +0 -7
- package/lib/chunk-4JKR4PTZ.mjs +0 -8
- package/lib/chunk-5OGNK3JP.mjs +0 -37
- package/lib/chunk-6QSHWIZI.mjs +0 -48
- package/lib/chunk-77IVKH7R.mjs +0 -7
- package/lib/chunk-77MZRBWX.mjs +0 -7
- package/lib/chunk-7WSQ65WG.mjs +0 -9
- package/lib/chunk-A32ISQ6M.mjs +0 -28
- package/lib/chunk-AG24QMSY.mjs +0 -7
- package/lib/chunk-BH76USTQ.mjs +0 -11
- package/lib/chunk-BZ24IAP5.mjs +0 -7
- package/lib/chunk-CN5HGFG4.mjs +0 -7
- package/lib/chunk-CTPLYUXA.mjs +0 -7
- package/lib/chunk-DIGUC7S4.mjs +0 -341
- package/lib/chunk-DSR2MSBH.mjs +0 -7
- package/lib/chunk-ETNQHIDI.mjs +0 -9
- package/lib/chunk-FBXH4VRQ.mjs +0 -7
- package/lib/chunk-FYWNSMOZ.mjs +0 -10
- package/lib/chunk-GEEWPTV5.mjs +0 -7
- package/lib/chunk-GTRU5AV5.mjs +0 -7
- package/lib/chunk-I3ZO76LL.mjs +0 -21
- package/lib/chunk-ISA2NYJV.mjs +0 -7
- package/lib/chunk-IXIY6Q4M.mjs +0 -7
- package/lib/chunk-JAV6F6OA.mjs +0 -7
- package/lib/chunk-JYUMD357.mjs +0 -7
- package/lib/chunk-L47JCNP3.mjs +0 -7
- package/lib/chunk-LI2XNV7F.mjs +0 -7
- package/lib/chunk-LP2D3JJP.mjs +0 -7
- package/lib/chunk-LYOGCIYD.mjs +0 -925
- package/lib/chunk-N5UIE4IR.mjs +0 -7
- package/lib/chunk-O7GCCRPW.mjs +0 -7
- package/lib/chunk-OO24ZYYJ.mjs +0 -7
- package/lib/chunk-OS6HFJ7L.mjs +0 -7
- package/lib/chunk-P6WRYJN3.mjs +0 -7
- package/lib/chunk-PGRY365W.mjs +0 -7
- package/lib/chunk-PPGDAUEQ.mjs +0 -7
- package/lib/chunk-Q4PPI3KG.mjs +0 -7
- package/lib/chunk-QFTF2PGS.mjs +0 -21
- package/lib/chunk-QO4MPHZD.mjs +0 -7
- package/lib/chunk-QXB6U3ZP.mjs +0 -7
- package/lib/chunk-R3OM3X4L.mjs +0 -8
- package/lib/chunk-R7GKMAT4.mjs +0 -7
- package/lib/chunk-SCKUIE3R.mjs +0 -7
- package/lib/chunk-SU65Z2BA.mjs +0 -7
- package/lib/chunk-T7DDS4UQ.mjs +0 -7
- package/lib/chunk-TQJ5NPRC.mjs +0 -7
- package/lib/chunk-VZLJZEV2.mjs +0 -7
- package/lib/chunk-W3BQGMTR.mjs +0 -7
- package/lib/chunk-WXU6ZJIV.mjs +0 -7
- package/lib/chunk-X4HZD5U2.mjs +0 -7
- package/lib/chunk-X6XNTOGO.mjs +0 -7
- package/lib/chunk-XMQ5R6TC.mjs +0 -10
- package/lib/chunk-XPXEQKLR.mjs +0 -7
- package/lib/chunk-YBZIDW6W.mjs +0 -7
- package/lib/chunk-ZCOSME6P.mjs +0 -7
- package/lib/chunk-ZTHC42X6.mjs +0 -7
|
@@ -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}from"./chunk-
|
|
7
|
+
import{a,b}from"./chunk-RE7RYF3B.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as describedFieldsOf,b as requiredForAccountKinds};
|
|
@@ -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 c}from"./chunk-
|
|
7
|
+
import{a as c}from"./chunk-2HVOZUM4.mjs";import{ke as a,le as b}from"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{c as ConditionalRouter,a as conditionDefect,b as evaluateCondition};
|
|
@@ -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{f as l,g as m,h as f,i as c,j as h}from"./chunk-FQGHL7GR.mjs";import{Ma as d,Oa as g}from"./chunk-
|
|
7
|
+
import{f as l,g as m,h as f,i as c,j as h}from"./chunk-FQGHL7GR.mjs";import{Ma as d,Oa as g}from"./chunk-PMWAFDUB.mjs";var x=50,A="en_US",$=["Contact details must reach nobody:","- every email address uses example.com, example.net, example.org, or a domain ending in .example, .invalid or .test, such as jane.doe@acme.example;",`- every phone number takes one of these forms, X being any digit: ${Object.values(l).map(t=>t.phoneFormats[0]).join(", ")}.`],u=class{callAI;constructor(e){this.callAI=e}async generate(e,i,r){if(i<=0||e.length===0)return[];let o=[],n=i,s=new Set(e.filter(p=>p.fieldType?.toLowerCase()==="phone").map(p=>p.fieldApiName)),a=E();for(;n>0;){let p=Math.min(n,x),R=_(e,p,r),w=await this.callAI(R),y=O(w);o.push(...y.map(N=>I(N,s,a))),n-=p}return o.slice(0,i)}};function E(){let t=0;return e=>h(f(e)??A,t++)}function _(t,e,i){let r=t.map(n=>{let s=[`- ${n.fieldApiName} (${n.ruleType})`];return n.config.aiPrompt&&s.push(`: ${n.config.aiPrompt}`),(n.config.minValue!==void 0||n.config.maxValue!==void 0)&&s.push(` [range: ${n.config.minValue??""}..${n.config.maxValue??""}]`),(n.config.minLength!==void 0||n.config.maxLength!==void 0)&&s.push(` [length: ${n.config.minLength??""}..${n.config.maxLength??""}]`),s.join("")}),o=[];return i&&(o.push(`Persona: ${i}`),o.push("")),o.push(`Generate exactly ${e} JSON objects with these fields:`),o.push(...r),o.push(""),o.push(...$),o.push(""),o.push("Return ONLY a JSON array of objects. No markdown, no explanation."),o.join(`
|
|
8
8
|
`)}function O(t){return d(g,t)}var P=new RegExp("(?<![\\p{L}\\p{N}._%+-])([\\p{L}\\p{N}._%+-]+)@((?:[\\p{L}\\p{N}](?:[\\p{L}\\p{N}-]{0,61}[\\p{L}\\p{N}])?\\.)+\\p{L}{2,63})(?![\\p{L}\\p{N}-])","gu"),S=/phone|mobile|fax|telef|^tel$/i,b=/^\+?[\d ()./-]+$/,D=/(?<![\w+.@-])(?<!\d )(?:(?:\+\d+|\(\d{1,4}\)|0\d*)(?:[ ./-]?\(\d+\)|[ ./-]\d+|(?<=\))\d+)*|\d{3}[ .-]\d{3}[ .-]\d{4}|(?<![€$£¥] ?)(?:[6-9]\d{2}(?<sep>[ .-])\d{3}\k<sep>\d{3}|[6-9]\d{2} \d{2} \d{2} \d{2}|[1-9]{2} (?:9 ?)?\d{4}-\d{4})(?![ ./,-]?\d| ?[€$£¥%]))(?![\w@])/g,F=/^\d{1,4}[./-]\d{1,2}[./-]\d{1,4}$/,L={least:8,most:15};function I(t,e,i){let r={};for(let[o,n]of Object.entries(t))r[o]=k(o,n,e,i);return r}function k(t,e,i,r){let o=i.has(t)||S.test(t.replace(/__p?c$/i,"")),n=typeof e=="number"?String(e):typeof e=="string"?e:void 0;return o&&n!==void 0&&/\d/.test(n)&&b.test(n.trim())?c(n)?e:r(n):typeof e!="string"?e:e.replace(P,(s,a,p)=>m(p)?s:`${a}@${T(p)}`).replace(D,s=>C(s)&&!c(s)?r(s):s)}function C(t){let e=t.replace(/\D/g,"").length;return e>=L.least&&e<=L.most&&!F.test(t)}function T(t){return`${t.split(".").slice(0,-1).join(".")}.example`}export{u as a,E as b,_ as c,O as d,I as e};
|
|
@@ -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,d,e,f,g,h}from"./chunk-GNRSF65U.mjs";import"./chunk-O677VOGO.mjs";import"./chunk-JE6SCT6R.mjs";import"./chunk-PWRJRL5U.mjs";import"./chunk-24RFOFYT.mjs";import"./chunk-UIOMAX56.mjs";import"./chunk-KJWFYBMU.mjs";import"./chunk-Z4LKKOFY.mjs";import"./chunk-2HVOZUM4.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-WB2RIVO3.mjs";import"./chunk-XGGOUNPP.mjs";import"./chunk-L53JWJ3S.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-OFTT7J2M.mjs";import"./chunk-HIDW7FNV.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-VINGECAJ.mjs";import"./chunk-H4CGM6YO.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-YDXMTWAT.mjs";import"./chunk-QIRO4HTE.mjs";import"./chunk-PMN4PAC3.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-FP7CYB2F.mjs";import"./chunk-NED4MBIM.mjs";import"./chunk-UI3JQVRU.mjs";import"./chunk-KGU4SVIT.mjs";import"./chunk-JAEDM4SI.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-MSIEU5MR.mjs";import"./chunk-LC3NDW4N.mjs";import"./chunk-KB4ZHM4Q.mjs";import"./chunk-23SEDORH.mjs";import"./chunk-W6PN6TJG.mjs";import"./chunk-3Q353S2R.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-RHNTHGNU.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-Q7TLC3I2.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-D4GF4FAB.mjs";import"./chunk-CVHNXJH3.mjs";import"./chunk-YA6ATMTB.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-M6K34KGF.mjs";import"./chunk-TNT27RBG.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-S42RBRH2.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-WUUKFE2U.mjs";import"./chunk-EAC5QCE3.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{d as CheckpointTakeStopped,a as DEFAULT_MAX_TOTAL,b as OBJECT_ROWS_MAX,f as holdingLimit,e as pastTheLimit,g as scopeCheckpoint,h as takeCheckpoint,c as takeOrgOf};
|
|
@@ -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{b as a,c as b,d as c}from"./chunk-X4BXESMQ.mjs";import"./chunk-YHR4WQPR.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-YDXMTWAT.mjs";import"./chunk-26POJDIT.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-D4GF4FAB.mjs";import"./chunk-CVHNXJH3.mjs";import"./chunk-TNT27RBG.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-S42RBRH2.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{c as CycleFkPass,b as RecordsOwingAcrossParts,a as patchCycleFkUpdates};
|
|
@@ -0,0 +1,341 @@
|
|
|
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 Kr}from"./chunk-INIQ23K6.mjs";import{a as Yr}from"./chunk-6PD6K7LP.mjs";import{$ as Qr,C as Br,F as zr,G as Jr,H as Hr,V as Vr,W as bt,X as Rt,Y as Xr,Z as Zr,aa as kt,ba as eo,c as Er,e as Tr,f as Fr,h as Pr,j as Nr,k as Mr,u as _r,x as Wr}from"./chunk-6I6TWNV5.mjs";import{b as Lr,g as Dr}from"./chunk-QAFPQ3YB.mjs";import{a as qr,f as Gr}from"./chunk-4EOHEDFP.mjs";import{e as yt,m as Ur}from"./chunk-UX3BVH2Y.mjs";import{c as en}from"./chunk-7SQSWVAU.mjs";import{Ab as Or,Bb as jr,Cb as gt,Db as Cr,Eb as xr,Fb as Ir,Xa as Ue,Y as yr,d as lt,db as br,e as dr,eb as We,f as cr,g as ur,h as lr,i as ft,j as fr,k as hr,l as pr,mb as Rr,n as gr,nb as kr,p as mr,qb as ht,rb as Be,sb as Sr,tb as pt,ub as vr,yb as $r,zb as Ar}from"./chunk-PEDQPM2P.mjs";import{k as Wn,n as Bn}from"./chunk-OM5NORJG.mjs";import{a as Le,j as ut,k as rr}from"./chunk-2METQHGG.mjs";import{b as Ie,e as Ze}from"./chunk-RKTFFCNS.mjs";import{a as tn,b as nn,c as Fe,d as rn,e as on,g as sn,h as an,j as dn}from"./chunk-6FARZYMJ.mjs";import{a as mt,c as wt}from"./chunk-QTG6LUZT.mjs";import{B as bn,Gc as _n,x as wn,y as yn,yc as Pn}from"./chunk-XGGOUNPP.mjs";import{h as at,i as dt}from"./chunk-L53JWJ3S.mjs";import{Xa as or,Ya as sr,cb as ir,eb as ar,n as De}from"./chunk-IVFVNNGB.mjs";import{k as nr}from"./chunk-6JWWSDM6.mjs";import{b as An,m as Mn}from"./chunk-VINGECAJ.mjs";import{B as vn,M as Pe,P as $n,a as cn}from"./chunk-H4CGM6YO.mjs";import{a as et,b as On,c as Cn,f as xn,h as tt,k as In,l as En,n as nt,o as Tn,p as rt,s as ot,u as st,x as Fn}from"./chunk-PMN4PAC3.mjs";import{c as it,d as Nn}from"./chunk-FP7CYB2F.mjs";import{a as qt}from"./chunk-AL4C3GFT.mjs";import{b as xe,c as $e}from"./chunk-OUZQPYT3.mjs";import{b as Ln,c as Dn}from"./chunk-LC3NDW4N.mjs";import{Dc as Qn,Pa as Gn,Qa as zn,Sc as er,Tc as tr,Zb as Yn,c as Qe,gb as Jn,hb as Hn,i as Ne,j as Me,jc as Vn,mb as Kn,mc as ct,p as Un,pb as fe,q as _e,qc as Xn,s as le,sa as qn,wc as Zn}from"./chunk-KB4ZHM4Q.mjs";import{a as ve,b as Zt,f as Xe}from"./chunk-W6PN6TJG.mjs";import{i as un}from"./chunk-INIT2UKJ.mjs";import{h as kn}from"./chunk-D4GF4FAB.mjs";import{c as Sn}from"./chunk-CVHNXJH3.mjs";import{b as mo}from"./chunk-MS4FJDFD.mjs";import{D as ue,F as mn,p as hn}from"./chunk-YA6ATMTB.mjs";import{b as Qt,d as Ee,f as Te,h as wr}from"./chunk-LCDPCUXS.mjs";import{a as ne}from"./chunk-EADHKH3A.mjs";import{j as Rn}from"./chunk-S42RBRH2.mjs";import{j as ln,w as fn}from"./chunk-ICIYL45C.mjs";import{a as gn}from"./chunk-WUUKFE2U.mjs";import{a as pn}from"./chunk-EAC5QCE3.mjs";import{d as jn}from"./chunk-TUACWKIH.mjs";import{Vc as zt,Wc as Ve,Wd as Yt,Yd as Vt,Zc as Jt,Zd as Xt,ld as Ht,md as Kt,vc as Gt}from"./chunk-PMWAFDUB.mjs";import{A as R}from"./chunk-WZQEK4WT.mjs";import{d as go}from"./chunk-NTOVCTRS.mjs";var Co=go(mo());import{randomUUID as So}from"node:crypto";import{existsSync as Ae,mkdirSync as vo,readFileSync as he,renameSync as $o,writeFileSync as Ao}from"node:fs";import{dirname as Oo,join as pe,resolve as jo}from"node:path";var xo=`sandforge sync \u2014 run a Sync between two orgs, without the editor.
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
npx sandforge sync \\
|
|
11
|
+
--source <alias> --target <alias> --object <ApiName> [options]
|
|
12
|
+
|
|
13
|
+
Required:
|
|
14
|
+
--source <alias> sf CLI alias of the source org
|
|
15
|
+
--target <alias> sf CLI alias of the target org
|
|
16
|
+
--object <ApiName> object to sync; repeat for more. The run writes the
|
|
17
|
+
parents their lookups name first, and keeps the
|
|
18
|
+
order given otherwise.
|
|
19
|
+
Append ":<Field>" to match on an external Id, which
|
|
20
|
+
turns that object's operation into an upsert.
|
|
21
|
+
|
|
22
|
+
Options:
|
|
23
|
+
--operation <op> insert | upsert | update (default: insert)
|
|
24
|
+
Per-object ":<Field>" wins over this.
|
|
25
|
+
--where <obj=clause> SOQL WHERE for one object (repeatable)
|
|
26
|
+
e.g. --where "Account=BillingCountry = 'France'"
|
|
27
|
+
--batch-size <n> records per write call (default: 200)
|
|
28
|
+
--dry-run simulate: read both orgs and say what the run
|
|
29
|
+
would insert, update, skip or refuse, writing
|
|
30
|
+
nothing (default: off)
|
|
31
|
+
--max-records-per-object <n>
|
|
32
|
+
the most records of one object the run reads, from
|
|
33
|
+
1 to 50000; an object with more is read up to it, and
|
|
34
|
+
the run says so on stderr and under readCut with
|
|
35
|
+
--json, and ends partial (default: 50000)
|
|
36
|
+
--files copy the files of the records each object writes:
|
|
37
|
+
Salesforce Files and legacy attachments, 10 MB each
|
|
38
|
+
and 100 MB a run at most unless --max-file-mb and
|
|
39
|
+
--max-run-mb say otherwise, as a configuration that
|
|
40
|
+
copies files does. The command keeps no record of
|
|
41
|
+
the files it copied: run again, it copies them
|
|
42
|
+
again (default: off)
|
|
43
|
+
--max-file-mb <n> with --files, the largest file copied, from 1 to 35;
|
|
44
|
+
a larger one is left out and counted (default: 10)
|
|
45
|
+
--max-run-mb <n> with --files, the most a run copies, from 1 to 2000;
|
|
46
|
+
the files past it are left out and counted
|
|
47
|
+
(default: 100)
|
|
48
|
+
--keep-contact-points write emails and phone numbers as read. Without
|
|
49
|
+
it, as in the panel, every address is written
|
|
50
|
+
under .invalid and every phone number as a
|
|
51
|
+
fictional one (default: off)
|
|
52
|
+
--json emit the run summary as JSON (default: off)
|
|
53
|
+
Saved to a file, it is what --remove takes the
|
|
54
|
+
run back from: it names what the run created.
|
|
55
|
+
The run's file does too, whatever becomes of the
|
|
56
|
+
run (see SANDFORGE_JOURNAL_DIR). A dry run's names
|
|
57
|
+
under wouldBeRefused what a real run would be
|
|
58
|
+
refused for, the code of each under
|
|
59
|
+
wouldBeRefusedCodes, as its line names it. A real
|
|
60
|
+
run refused before its first write prints
|
|
61
|
+
"refused": {"code", "message"} instead, the code its
|
|
62
|
+
line names: refused (CODE): ..., each other reason
|
|
63
|
+
of its gate under "alsoRefused", on a line of its own.
|
|
64
|
+
--fail-on-partial exit 3, not 0, when the run wrote some records and
|
|
65
|
+
the target refused others, or read an object up to
|
|
66
|
+
--max-records-per-object, a dry run's read
|
|
67
|
+
included (default: off)
|
|
68
|
+
--mute-automation mute the target's automation for the run through
|
|
69
|
+
its own bypass: assign the user the run writes as,
|
|
70
|
+
for the run alone, the permission sets holding the
|
|
71
|
+
custom permissions its flows, processes and
|
|
72
|
+
workflow rules test to stay quiet, and take them
|
|
73
|
+
back as it ends; what no bypass keeps quiet still
|
|
74
|
+
runs, and is named. Refused on a production org and
|
|
75
|
+
for a user who cannot assign permission sets, exit
|
|
76
|
+
1; with --dry-run, says what would be muted and
|
|
77
|
+
assigns nothing (default: off)
|
|
78
|
+
--accept-emails write although the target delivers the emails its
|
|
79
|
+
flows, processes and workflow rules send as the run
|
|
80
|
+
writes (Setup > Deliverability: All email), or would
|
|
81
|
+
not say whether it does. Read only when something
|
|
82
|
+
that still runs sends one, with one line of
|
|
83
|
+
anonymous Apex that sends nothing; without the flag
|
|
84
|
+
the run is refused, exit 1 (EMAILS_NOT_ACCEPTED),
|
|
85
|
+
nothing written. On System email only or No access
|
|
86
|
+
it is not needed. --mute-automation keeps quiet what
|
|
87
|
+
tests the org's bypass; what an Apex trigger sends is
|
|
88
|
+
read nowhere (default: off)
|
|
89
|
+
${dr({run:"the run",simulation:"--dry-run"})}
|
|
90
|
+
--help this text
|
|
91
|
+
|
|
92
|
+
Run a saved configuration:
|
|
93
|
+
npx sandforge sync \\
|
|
94
|
+
--config-file <config.json> --store <dir> --source <alias> --target <alias> \\
|
|
95
|
+
[--dry-run] [--json]
|
|
96
|
+
|
|
97
|
+
--config-file <file> a Sync configuration as the panel saves one, checked
|
|
98
|
+
as the panel checks it: its objects, filters,
|
|
99
|
+
mappings, add-ons, mode, and whether it copies files.
|
|
100
|
+
It runs between the two orgs given, whatever orgs it
|
|
101
|
+
names. In delta mode, each object reads only what the
|
|
102
|
+
source changed since its last good run. A transform
|
|
103
|
+
rule that names no field is refused before any org is
|
|
104
|
+
reached, exit 1: it would change every field of every
|
|
105
|
+
record.
|
|
106
|
+
--store <dir> where the configuration is kept between runs, with
|
|
107
|
+
its watermarks, the files it copied and which record
|
|
108
|
+
of the target each source record it wrote became, as
|
|
109
|
+
the panel keeps them beside it: give every run of it
|
|
110
|
+
the same directory, and --remove too. A later run
|
|
111
|
+
points a lookup at the copy an earlier run wrote.
|
|
112
|
+
--object, --where, --operation, --batch-size, --files, --max-file-mb,
|
|
113
|
+
--max-run-mb and --keep-contact-points come from the file (files,
|
|
114
|
+
keepContactPoints), and are refused with it. A legacy attachment the source changed since it was copied is
|
|
115
|
+
replaced, its earlier copy deleted, on a sandbox or a Developer Edition org,
|
|
116
|
+
as in the panel; a production org keeps the copy.
|
|
117
|
+
|
|
118
|
+
Remove what a run created:
|
|
119
|
+
npx sandforge sync \\
|
|
120
|
+
--remove <summary.json | run file | run id> --target <alias>
|
|
121
|
+
[--include-changed] [--accept-automation] [--store <dir>]
|
|
122
|
+
[--sweep | --sweep-list] [--sweep-late] [--sweep-untied] [--json]
|
|
123
|
+
|
|
124
|
+
--remove <file | id> the summary a run printed with --json, saved to a
|
|
125
|
+
file; or the run's file, which it names as it
|
|
126
|
+
begins, or its run id. Deletes from the target what
|
|
127
|
+
the run created: the records it inserted, or
|
|
128
|
+
upserted where the target held none, the last object
|
|
129
|
+
written first, into the target's recycle bin. Before
|
|
130
|
+
that, gives the records it wrote over \u2014 an update,
|
|
131
|
+
an upsert that found the record \u2014 the values they
|
|
132
|
+
held before the run, of the fields it wrote, which
|
|
133
|
+
the run kept first in <dir>/backups (below); one
|
|
134
|
+
changed since the run stays as it is unless
|
|
135
|
+
--include-changed. First of all, what a delta run
|
|
136
|
+
deleted as the source had is brought back from the
|
|
137
|
+
target's recycle bin, while it is there. A run
|
|
138
|
+
another process still writes is refused, exit 1.
|
|
139
|
+
From its file, a run killed,
|
|
140
|
+
stopped or ended by an error is taken back too: a
|
|
141
|
+
Bulk API job it had under way, which ran on in the
|
|
142
|
+
target, is read back by its id first, and its
|
|
143
|
+
records go with the rest.
|
|
144
|
+
--target <alias> the org the run wrote to, and no other. It must be a
|
|
145
|
+
sandbox or a Developer Edition org.
|
|
146
|
+
--include-changed remove also the records changed since the run, which
|
|
147
|
+
are kept otherwise, and give back their values from
|
|
148
|
+
before the run to the records it wrote over that
|
|
149
|
+
were changed since
|
|
150
|
+
--accept-automation remove although the target runs flows, Apex
|
|
151
|
+
triggers, processes or workflow rules as the removal
|
|
152
|
+
brings records back from the recycle bin, gives them
|
|
153
|
+
their values back, sets them back to Draft or
|
|
154
|
+
deletes them, those --sweep deletes included, or
|
|
155
|
+
could not say what it runs. Each is named before
|
|
156
|
+
anything is written; without the flag the removal
|
|
157
|
+
then writes nothing, exit 1 (default: off)
|
|
158
|
+
--mute-automation mute the target's automation for the removal through
|
|
159
|
+
its own bypass, as for a run; what no bypass keeps
|
|
160
|
+
quiet still needs --accept-automation (default: off)
|
|
161
|
+
--store <dir> for a run of a saved configuration: its store, which
|
|
162
|
+
the removal tells what it took, so that the next
|
|
163
|
+
delta run reads those objects whole and copies the
|
|
164
|
+
files it deleted again
|
|
165
|
+
--sweep before the run's records go, delete too what the
|
|
166
|
+
target's automation made for the run, that the run did
|
|
167
|
+
not write: what the run's user created under the
|
|
168
|
+
records it created or wrote over, what they point
|
|
169
|
+
at, or what hangs from those, three links at most, at
|
|
170
|
+
most a minute after the record it is tied to \u2014 in the
|
|
171
|
+
objects whose records it created and their children,
|
|
172
|
+
tasks, events, feed, email messages, notes, case
|
|
173
|
+
comments, and the objects the target's flows create.
|
|
174
|
+
What a record of the run points at by a lookup the
|
|
175
|
+
org refuses the delete for goes once that record is
|
|
176
|
+
gone. The window runs from a second
|
|
177
|
+
before the run's first write \u2014 its first call, an
|
|
178
|
+
update before anything was created included, which
|
|
179
|
+
the summary dates by this machine's clock, read on
|
|
180
|
+
the org's \u2014 to a minute after its last write: the
|
|
181
|
+
last record it created, read back from the org, or
|
|
182
|
+
a later call, an update included, as the summary
|
|
183
|
+
dates it. Listed and kept: what is tied to the run
|
|
184
|
+
but came later, up to 15 minutes, or as the org's
|
|
185
|
+
Automated Process user; and what the run's user
|
|
186
|
+
created in the window tied to nothing of the run.
|
|
187
|
+
What anyone changed more than 2 s after the run's
|
|
188
|
+
last write, and after its own creation, stays \u2014 the
|
|
189
|
+
run's user and its automation too \u2014 unless
|
|
190
|
+
--include-changed, and the sweep then ends partial,
|
|
191
|
+
exit 3; a change made before the run's last write
|
|
192
|
+
reads as unchanged
|
|
193
|
+
(default: off)
|
|
194
|
+
--sweep-late with --sweep, take too what it lists as made late;
|
|
195
|
+
with --sweep-list, say what it would take
|
|
196
|
+
--sweep-untied with --sweep, take too what it lists as tied to
|
|
197
|
+
nothing of the run; with --sweep-list, say what it
|
|
198
|
+
would take; refused when another run of this
|
|
199
|
+
machine wrote to the target in the window, or when
|
|
200
|
+
that user created records in the window on objects
|
|
201
|
+
neither the run nor the automation reaches (hand
|
|
202
|
+
work, likely)
|
|
203
|
+
--sweep-list list what --sweep would delete, per object with a few
|
|
204
|
+
names and how many it ties to the run, and delete
|
|
205
|
+
nothing, the run's records included; exit 3, as a
|
|
206
|
+
refused --sweep, when it says the sweep is refused.
|
|
207
|
+
What a sweep leaves: what another user created; what
|
|
208
|
+
is tied to nothing, unless --sweep-untied; what came
|
|
209
|
+
more than 15 minutes after its record, or after the
|
|
210
|
+
removal began; what anyone changed after the run's
|
|
211
|
+
last write, the run's own user included, unless
|
|
212
|
+
--include-changed; what the automation changed
|
|
213
|
+
rather than created; what left the org; and what the
|
|
214
|
+
panel or another machine wrote
|
|
215
|
+
--leave-undeletable remove the rest when the user the removal runs as
|
|
216
|
+
may not delete the records of some objects of the
|
|
217
|
+
run, leaving those with what they hang from; without
|
|
218
|
+
it the removal stops before its first delete and
|
|
219
|
+
names them (default: off)
|
|
220
|
+
--json print the removal as JSON; refused before its first
|
|
221
|
+
write, "refused": {"code", "message"}, the code its
|
|
222
|
+
line names: refused (CODE): ... \u2014 a production org
|
|
223
|
+
(PRODUCTION_TARGET), what fires as it writes
|
|
224
|
+
(AUTOMATION_NOT_ACCEPTED), its mute (MUTE_PRODUCTION,
|
|
225
|
+
MUTE_NO_RIGHT, MUTE_FAILED), objects its user may not
|
|
226
|
+
delete (UNDELETABLE_NOT_LEFT), an org that is not the
|
|
227
|
+
one the run wrote to (OTHER_ORG), a run still writing
|
|
228
|
+
(RUN_WRITING)
|
|
229
|
+
|
|
230
|
+
What the removal left on the run's records is kept beside the summary, in
|
|
231
|
+
<summary>.removals.json, or beside the run's file, in <run id>.removal.json,
|
|
232
|
+
and the next --remove of the same summary or file reads it.
|
|
233
|
+
|
|
234
|
+
Environment:
|
|
235
|
+
SANDFORGE_JOURNAL_DIR=<dir>
|
|
236
|
+
where every run that writes keeps its file, in
|
|
237
|
+
<dir>/sync-runs/<run id>.ndjson (default: ~/.sandforge),
|
|
238
|
+
said as it begins: what it created, its calls as
|
|
239
|
+
they went and answered, a Bulk API job's id once the
|
|
240
|
+
org opened it, and how it ended. Ids and dates only.
|
|
241
|
+
What a run writes over \u2014 an update, an upsert that
|
|
242
|
+
finds the record \u2014 is read from the target first and
|
|
243
|
+
kept in <dir>/backups, readable by you alone, as
|
|
244
|
+
sandforge backup keeps a snapshot: the values the
|
|
245
|
+
records held, of the fields the run writes, which
|
|
246
|
+
--remove gives back. A call whose values cannot be
|
|
247
|
+
kept is not sent, its rows refused with why.
|
|
248
|
+
|
|
249
|
+
Before its first write, a run counts the records it writes under each filter,
|
|
250
|
+
and is refused, with nothing written, when they would take more data storage
|
|
251
|
+
than the target has left, or make the target's automation send more emails
|
|
252
|
+
than it has left today; --dry-run says what it would meet. A run of a saved
|
|
253
|
+
configuration leaves as they are the records an earlier run of it copied that
|
|
254
|
+
are still in the target, and inserts the others.
|
|
255
|
+
|
|
256
|
+
Exit codes: 0 the run finished, some of its records refused included (read
|
|
257
|
+
the summary for per-object failures), or the removal took every record it set
|
|
258
|
+
out to; 1 the run or the removal could not be started, either was refused
|
|
259
|
+
before it wrote anything \u2014 a production target among the reasons; for the
|
|
260
|
+
run, more data storage than the target has left, more emails or API requests
|
|
261
|
+
than it has left today, emails it delivers without --accept-emails
|
|
262
|
+
(EMAILS_NOT_ACCEPTED), a checkpoint asked first refused or not taken
|
|
263
|
+
(CHECKPOINT_REFUSED); for the removal, what the target runs as it writes,
|
|
264
|
+
without --accept-automation \u2014 or the run produced only failures, or it
|
|
265
|
+
stopped on an error (its file keeps what it created); 2 a bad command line,
|
|
266
|
+
or a summary or a file --remove cannot take a run back from; 3 the removal
|
|
267
|
+
left records of the run in the target, or its sweep was refused or did not
|
|
268
|
+
take all it was asked to (a --sweep-untied refused included), or the run was
|
|
269
|
+
partial \u2014 records refused, or an object read up to --max-records-per-object,
|
|
270
|
+
a dry run's read among them \u2014 and --fail-on-partial was given; 130 a Ctrl-C
|
|
271
|
+
stopped the run, 143 a SIGTERM (a CI job cancelled or timed out), 129 a
|
|
272
|
+
SIGHUP: its file keeps what it created.
|
|
273
|
+
`,Io=["--object","--where","--operation","--batch-size","--files","--max-file-mb","--max-run-mb","--keep-contact-points"],L=/^[A-Za-z][A-Za-z0-9_]{0,79}$/,Eo=new Set(["SYNC_TARGET_UNWRITABLE",fe,ct]),To={switches:["--dry-run","--files","--keep-contact-points","--json","--fail-on-partial","--mute-automation","--accept-emails",...lt.switches],values:["--source","--target","--object","--operation","--where","--batch-size","--max-records-per-object","--max-file-mb","--max-run-mb","--config-file","--store",...lt.values]};function St(t,r,e,n){if(t===void 0)return n;let s=Number(t);return(!/^\d+$/.test(t)||s<e.min||s>e.max)&&(process.stderr.write(`${r} takes a whole number from ${e.min} to ${e.max}, not "${t}".
|
|
274
|
+
`),process.exit(2)),s}function Fo(t){let r=t.slice(2);(r.includes("--help")||r.includes("-h"))&&(process.stdout.write(xo),process.exit(0)),Qt(r,To);let e=(v,$)=>{let k=r.indexOf(v);return k>=0&&k+1<r.length?r[k+1]:$},n=v=>{let $=[];for(let k=0;k<r.length;k++)r[k]===v&&k+1<r.length&&$.push(r[k+1]);return $},s=v=>r.includes(v),i=cr(r),d=i!==void 0?{checkpointFirst:i}:{},u=St(e("--max-records-per-object"),"--max-records-per-object",{min:1,max:5e4},5e4),l=e("--source"),a=e("--target");if(s("--config-file")){let v=e("--config-file"),$=e("--store");(!v||!$||!l||!a)&&(process.stderr.write(`--config-file wants the file, --store <dir> where it is kept between runs, --source and --target. Run with --help.
|
|
275
|
+
`),process.exit(2));let k=Io.filter(s);return k.length>0&&(process.stderr.write(`--config-file takes its objects, filters and files from the file: ${k.join(", ")} cannot be given with it.
|
|
276
|
+
`),process.exit(2)),{source:l,target:a,objects:[],operation:"insert",where:{},batchSize:200,dryRun:s("--dry-run"),files:!1,maxRecordsPerObject:u,keepContactPoints:!1,json:s("--json"),failOnPartial:s("--fail-on-partial"),muteAutomation:s("--mute-automation"),acceptEmails:s("--accept-emails"),...d,configFile:v,store:$}}s("--store")&&(process.stderr.write(`--store keeps a saved configuration between runs: give it with --config-file.
|
|
277
|
+
`),process.exit(2));let h=n("--object");(!l||!a||h.length===0)&&(process.stderr.write(`Missing --source, --target or --object. Run with --help.
|
|
278
|
+
`),process.exit(2));let g=h.map(v=>{let[$,k]=v.split(":");return L.test($)||(process.stderr.write(`Not an SObject API name: "${$}"
|
|
279
|
+
`),process.exit(2)),wn($)&&(process.stderr.write(`${yn($,"give --files")}
|
|
280
|
+
`),process.exit(2)),k!==void 0&&!L.test(k)&&(process.stderr.write(`Not a field API name: "${k}"
|
|
281
|
+
`),process.exit(2)),{objectApiName:$,externalIdField:k}}),m=e("--operation","insert")??"insert";m!=="insert"&&m!=="upsert"&&m!=="update"&&(process.stderr.write(`--operation takes insert, upsert or update, not "${m}".
|
|
282
|
+
`),process.exit(2));let b={};for(let v of n("--where")){let $=v.indexOf("="),k=$>0?v.slice(0,$):"";L.test(k)||(process.stderr.write(`--where wants "Object=clause", not "${v}".
|
|
283
|
+
`),process.exit(2)),b[k]=v.slice($+1)}let S=e("--batch-size","200")??"200",C=Number(S);(!Number.isInteger(C)||C<1||C>1e4)&&(process.stderr.write(`--batch-size takes a whole number between 1 and 10000.
|
|
284
|
+
`),process.exit(2)),!s("--files")&&(s("--max-file-mb")||s("--max-run-mb"))&&(process.stderr.write(`--max-file-mb and --max-run-mb go with --files.
|
|
285
|
+
`),process.exit(2));let I=St(e("--max-file-mb"),"--max-file-mb",{min:1,max:35}),W=St(e("--max-run-mb"),"--max-run-mb",{min:1,max:2e3});return{source:l,target:a,objects:g,operation:m,where:b,batchSize:C,dryRun:s("--dry-run"),files:s("--files"),...I!==void 0?{maxFileMB:I}:{},...W!==void 0?{maxRunMB:W}:{},maxRecordsPerObject:u,keepContactPoints:s("--keep-contact-points"),json:s("--json"),failOnPartial:s("--fail-on-partial"),muteAutomation:s("--mute-automation"),acceptEmails:s("--accept-emails"),...d}}function Po(t){let r=new Date().toISOString(),e=t.objects.map((n,s)=>({objectApiName:n.objectApiName,externalIdField:n.externalIdField,operation:n.externalIdField?"upsert":t.operation,fieldMappings:[],transformRules:[],excludedFields:[],addOnFields:[],batchSize:t.batchSize,where:t.where[n.objectApiName],insertOrder:s}));return{id:`cli-${Date.now()}`,name:"sandforge-sync",description:"Headless run",sourceOrgId:t.source,targetOrgId:t.target,direction:"source_to_target",mode:"full",objects:e,conflictStrategy:"source_wins",enableRollback:!1,createdAt:r,updatedAt:r,...t.files?{files:{maxFileSizeMB:t.maxFileMB??10,maxRunMB:t.maxRunMB??100}}:{},...t.keepContactPoints?{keepContactPoints:!0}:{}}}function No(t,r){let e;try{e=JSON.parse(t)}catch{return{refusal:"is not JSON: give a Sync configuration as the panel saves one."}}if(typeof e!="object"||e===null||Array.isArray(e))return{refusal:"is not a Sync configuration: it holds no object."};let n=bn.safeParse({config:{...e,sourceOrgId:r.source,targetOrgId:r.target}});if(!n.success){let d=n.error.issues[0];return{refusal:`is not a configuration a run takes (${d.path.slice(1).join(".")||"configuration"}: ${d.message})`}}let s=n.data.config;if(s.id===void 0)return{refusal:"names no id: a saved configuration keeps its watermarks and the files it copied under its id."};let i=new Date().toISOString();return{config:{...s,id:s.id,createdAt:s.createdAt??i,updatedAt:s.updatedAt??i,objects:s.objects.map(d=>({...d,batchSize:d.batchSize??200}))}}}function oo(t){return vo(t,{recursive:!0}),new Pr(De(pe(t,"configStore.json")))}function Mo(t,r,e,n,s=!1,i=5e4){let d=a=>({query:async h=>a.query(h),queryMore:async h=>a.queryMore(h)}),u=a=>({pages:d(a),transport:a,create:async(h,g)=>a.sobject(h).create(g,{headers:Gt()})}),l=new Map;return{copy:Fr({[t.sourceOrgId]:u(r),[t.targetOrgId]:u(e)}),sourceIds:async(a,h)=>{let g=a.objectApiName;if(!L.test(g))throw new Error(`Not an SObject API name: ${g}`);let m=ue(a.where,h),{records:b}=await ne(d(r),`SELECT Id FROM ${g}${m?` WHERE ${m}`:""}`,i);return b.flatMap(S=>typeof S.Id=="string"?[S.Id]:[])},store:n??{load:()=>l.size===0?{kind:"none"}:{kind:"stored",map:{version:1,entries:[...l.values()]}},record:(a,h)=>{l.set(`${h.sourceOrgId}|${h.targetOrgId}|${h.sourceId}`,h)}},...s?{deleteFromTarget:async(a,h)=>Rn(await e.sobject(a).destroy(h),a).map(g=>({id:g.id,success:g.success,errors:g.errors}))}:{}}}function _o(t){let r=Ve({isSandbox:t.sandbox,edition:t.edition});return Tr(new Mn,t.id,{orgType:r})}function so(t){return t.filter(r=>r.type!=="address"&&r.type!=="location").map(r=>r.name)}function to(t,r=5e4,e){return async(n,s,i)=>{let d=s.objectApiName;if(!L.test(d))throw new Error(`Not an SObject API name: ${d}`);let u=ue(s.where,i?.changedSince),l=u?` WHERE ${u}`:"",a={query:async S=>t.query(S),queryMore:async S=>t.queryMore(S)},h=await t.sobject(d).describe(),g=so(h.fields),m=!1,b=await un(`SELECT ${(g.length>0?g:["Id"]).join(", ")} FROM ${d}${l}`,async S=>{let C=await ne(a,S,r);return m||=C.truncated,C.records});return m&&(i?.onBoundReached?.(),e?.(d,b.length)),b}}function Lo(t,r){let e=`${qt("clone")} --depth all --source ${r.source} --target ${r.target} --fit share --dry-run`;return t.map(n=>`${n.objectApiName}: the read of the source stopped at ${n.read} records (--max-records-per-object ${n.bound}): this run copied part of the object. `+Br("source",n.bound,{raise:"--max-records-per-object",sample:e}))}function vt(t,r){return t==="success"&&r.length>0?"partial":t}function Do(t,r){return async(e,n,s)=>{let i=n.objectApiName;if(!L.test(i))throw new Error(`Not an SObject API name: ${i}`);let d=ue(n.where,s?.changedSince),{totalSize:u}=await t.query(`SELECT COUNT() FROM ${i}${d?` WHERE ${d}`:""}`);return r===void 0?u:Math.min(u,r)}}function Uo(t){return async(r,e)=>{let n=r.objectApiName;if(!L.test(n))return 0;let s=ue(r.where,e?.changedSince);try{return(await t.query(`SELECT COUNT() FROM ${n} WHERE IsPersonAccount = true`+(s?` AND (${s})`:""))).totalSize}catch{return 0}}}function Wo(t){return async r=>{let e=r.objectApiName;if(!L.test(e))throw new Error(`Not an SObject API name: ${e}`);let n=ue(r.where,void 0),{records:s}=await ne({query:async i=>t.query(i),queryMore:async i=>t.queryMore(i)},`SELECT Id FROM ${e}${n?` WHERE ${n}`:""}`);return s.flatMap(i=>typeof i.Id=="string"?[i.Id]:[])}}function no(t){if(t.go||t.code!==fe&&t.code!==Qe)return t;let{code:r,message:e,refusal:n}=t;return{...t,message:hr({code:r,message:e,...n?{refusal:n}:{}})}}var Bo={notInTarget:"it has no such object, or the user the run writes as cannot see it",notCreateable:"the user the run writes as may not create its records",notUpdateable:"the user the run writes as may not edit its records",unread:"it did not describe the object",notAKey:"its upsert matches on a field that is neither an External ID nor an idLookup field"};function $t(t,r){return{...t??{},sent:r}}function io(t,r){let e=t.notWritten??0,n=t.total>0?t.total:e,s=[`write gate: ${n-e} record(s) to write to ${r}, about ${Zn(t.storage.estimateMB)} MB of data storage`];for(let a of t.objects)s.push(` ${a.objectApiName.padEnd(42)}${String(a.rows).padStart(8)}`);e>0&&s.push(` of the ${n} a run counts from the source, ${e} would not be written: held back or refused, as each object says; what follows is measured on all of them`),t.alreadyCopied>0&&s.push(` not counted: ${t.alreadyCopied} record(s) an earlier run of this configuration copied, still in the target, left as they are`),(t.alreadyLinked??0)>0&&s.push(` not counted: ${t.alreadyLinked} record(s) an earlier run of this configuration linked to records the target held, left as they are`),(t.overwrites??0)>0&&s.push(` of them, up to ${t.overwrites} written by an update or an upsert over records ${r} holds: their values are kept first, and --remove puts them back`),(t.rolesLinked??0)>0&&s.push(` not counted: ${t.rolesLinked} OpportunityContactRole record(s) the platform writes itself with the opportunities the run creates, for their contact: the run links each and does not send it`),(t.rolesByThePlatform??0)>0&&s.push(` of them, up to ${t.rolesByThePlatform} OpportunityContactRole record(s) the platform writes itself with the opportunities the run creates, for their contact: the run links each and does not send it`);let{storage:i}=t;i.verdict==="unread"?s.push(` the data storage ${r} has left could not be read (${i.unread??""}): whether the records fit is not known`):i.remainingMB!==void 0&&i.maxMB!==void 0&&s.push(` data storage of ${r}: ${i.remainingMB} MB left of ${i.maxMB} MB`+(i.verdict==="exceeds"?": the records do not fit":i.verdict==="near"?": the records take more than 80 % of it":""));for(let a of t.emails){let h=a.objects.map(m=>`${m.perRecord} per ${m.objectApiName}`).join("; "),g=` emails: these records make ${r} send about ${Vn(a.emails,a.limit)} (${h})`+(a.alertsCounted?", its email alerts among them, as a Developer Edition counts them":"");s.push(a.verdict==="unread"?`${g}; what it has left today could not be read (${a.unread??""})`:a.verdict==="fits"?`${g}; it has ${a.remaining??"?"} of ${a.max??"?"} left today`:`${g}, more than the ${a.remaining??"?"} of ${a.max??"?"} it has left today`)}t.emailsUnread!==void 0&&s.push(` emails: not counted, ${t.emailsUnread} could not be read`),t.deliverability&&s.push(` ${Xn(t.deliverability.reading)}`);let d=t.apiRequests;d&&(s.push(d.verdict==="unread"?` API requests: about ${d.estimate}; what ${r} has left today could not be read (${d.unread??""})`:` API requests: about ${d.estimate}, of the ${d.remaining??"?"} ${r} has left of its ${d.max??"?"} a day`+(d.verdict==="exceeds"?": more than it has left":d.verdict==="near"?": it would leave less than a tenth of them":"")),s.push(` ${Sn}`));for(let a of t.unwritable??[])s.push(` ${a.objectApiName}: ${a.rows} record(s) ${r} takes none of \u2014 ${Bo[a.why]}${a.key!==void 0?` (${a.key})`:""}`);let u=new Set((t.unwritable??[]).map(({objectApiName:a})=>a)),l=({parent:a,field:h})=>`${h} names ${a} records ${u.has(a)?"left out":"held back"}`;for(let a of t.heldBack??[]){let h=a.parents??[a];s.push(` ${a.objectApiName}: ${a.rows} record(s) held back, not written \u2014 `+(h.length===1?`their ${l(h[0])}`:h.map(g=>`${g.rows} whose ${l(g)}`).join("; ")))}return t.aboveRecords!==void 0&&s.push(` more than ${t.aboveRecords} records: the panel asks before it writes (sandforge.safety.confirmAboveRecords)`),s}function ao(t,r,e=!1){let n=t.flatMap(i=>i.recordTypeGiven?[i.recordTypeGiven]:[]),s=yr(n,r);return s.length>0&&r&&e&&s.push(" the permission sets a real run assigns to mute the automation may open other record types to the user it writes as: it reads them again once assigned, and its summary says what the target gave"),s}function co(t){return`${t} already linked by an earlier run of this configuration to records the target held, left as they are`}function qo(t,r="the target",e=!1,n,s){let i=[`
|
|
286
|
+
simulation: ${t.objects.length} object(s), nothing written`];if(t.writeOrder){i.push(` write order: ${t.writeOrder.objects.join(", ")}`);for(let d of t.writeOrder.moved)i.push(` ${d.objectApiName} after ${d.after}: its ${d.field} names one`);for(let d of t.writeOrder.cycles)i.push(` ${d.join(", ")} name each other: in this order, the lookup at the one written later is left empty`)}if(t.writeCheck){for(let u of io(t.writeCheck,r))i.push(` ${u}`);for(let u of t.checkpoint?ft(t.checkpoint):[])i.push(` ${u}`);if(t.writeCheck.verdict==="refused"){let u=t.writeCheck,[l,a]=(u.unwritable??[]).length>0?["SYNC_TARGET_UNWRITABLE","the target takes none of the records of an object it writes"]:n!==void 0?[fe,n]:u.storage.verdict==="exceeds"?["SYNC_STORAGE_EXCEEDED","the records do not fit"]:u.apiRequests?.verdict==="exceeds"?[Kn,"it takes more API requests than the target has left today"]:[fe,u.checkpointUnread??"the checkpoint asked first is refused"];i.push(` a run would be refused before it writes (${l}): ${a}`)}else(t.writeCheck.unwritable??[]).length>0&&i.push(" a run of the command would be refused before it writes (SYNC_TARGET_UNWRITABLE): the target takes none of the records of an object it writes; leave it out of the configuration");let d=t.writeCheck.emails.some(u=>u.verdict==="exceeds");t.writeCheck.verdict!=="refused"&&d?i.push(" a run of the command would be refused before it writes (SYNC_EMAILS_EXCEEDED): past a daily email limit"):t.writeCheck.verdict!=="refused"&&s!==void 0&&i.push(` a run of the command would be refused before it writes (${ct}): `+s)}t.writeCheckUnread!==void 0&&i.push(` the records to write could not be counted: ${t.writeCheckUnread}`);for(let d of t.objects){i.push(` ${d.objectApiName} (${d.operation}): ${d.read} read, would insert ${d.insert}, update ${d.update}, delete ${d.delete}, skip ${d.skipped}, refuse ${d.refused}`+(t.direction==="bidirectional"?`, ${d.conflicts} in conflict`:"")),d.alreadyCopied!==void 0&&i.push(` ${d.alreadyCopied} already copied by an earlier run of this configuration, left as they are`),d.alreadyLinked!==void 0&&i.push(` ${co(d.alreadyLinked)}`),(d.encryptedLeftOut??[]).length>0&&i.push(` ${uo(d.encryptedLeftOut??[])}`),d.conflictFields.length>0&&i.push(` differ on: ${d.conflictFields.join(", ")}`),d.files&&i.push(` files: would copy ${d.files.copied}, add ${d.files.versions} version(s), ${d.files.unchanged} unchanged, ${d.files.tooLarge+d.files.pastRunCap} skipped past the caps`);for(let u of d.notes)i.push(` ${u}`);if(d.validationRules&&d.validationRules.length>0){i.push(` ${d.validationRules.length} active validation rule(s) of the target, which a simulation cannot evaluate \u2014 a record one of them refuses is counted as written:`);for(let u of d.validationRules)i.push(` ${u.name}${u.field?` (${u.field})`:""}: ${u.message||"(no message)"}`)}}t.validationRulesUnread&&i.push(` the target's validation rules could not be listed (${t.validationRulesUnread}): any of them may refuse a record counted as written`);for(let d of ao(t.objects,!0,e))i.push(` ${d}`);return t.cancelled&&i.push(" stopped by a cancel before its last object"),t.error&&i.push(` stopped at ${t.failedObject??"an object"}: ${t.error}`),i}var Go=/^(PARENT_REFUSED|RECORD_TYPE_UNAVAILABLE|RECORD_TYPE_UNMAPPED):/;function zo(t){let r=t.slice(0,3);for(let e of t.slice(3))Go.test(e)&&r.push(e);return r}var Jo={notInTarget:": the lookup held an id from the source org that the target does not have.",ownerRefusedEarlier:", left out from the start: the target refused the same owner earlier in this run, an id from the source org that the target does not have.",parentRefused:": the record it names, written after them, was refused in this run.",notSet:": the target refused setting it once the record it names was written",notReached:": the run was stopped before it was set, once the record it names was written."},Ho={"validation-rule":"a validation rule of the target refused it","restricted-picklist":"a restricted picklist of the target refused its value","lookup-filter":"a lookup filter of the target refused the record it names","inactive-owner":"the target holds the owner it names inactive"};function Ko(t){let r=Yo(t),e=Math.max(0,(t.skipped??0)-r);return`${t.objectApiName}: ${t.processed??0} processed, ${t.success??0} succeeded, ${t.failed??0} failed, ${e} skipped`+(r>0?`, ${r} linked`:"")}function Yo(t){return(t.writtenByThePlatform?.records??0)+(t.linkedToExisting?.records??0)}function Vo(t){let r=[];(t.encryptedLeftOut??[]).length>0&&r.push(uo(t.encryptedLeftOut??[]));let e=t.linkedToExisting;e&&r.push(`${e.records} record(s) linked to a record the target holds, not written: the target refused them as a duplicate of it${e.refusal?` (${e.refusal})`:""}; what the run writes under them points at that record.`);let n=t.writtenByThePlatform;n&&r.push(`${n.records} record(s) linked to the contact role the platform wrote with their opportunity, for its contact, not written; ${n.given} given the source's fields ${n.given===1?"it":"they"} lacked`+(n.refusal?`, the others left as the platform wrote them (${n.refusal}).`:"."));for(let{records:d,fields:u,reason:l,refusal:a}of t.lookupsLeftOut??[]){let h=l==="notSet"?`${a?` (${a})`:""}.`:"";r.push(`${d} record(s) written without ${u.join(", ")}${Jo[l]}${h}`)}let s=t.lookupsSetAfter;s&&r.push(`${s.records} record(s) given ${s.fields.join(", ")} by a second write once ${s.after.join(", ")} ${s.after.length===1?"was":"were"} written: the objects name each other, and no order writes both first.`);let i=t.writtenWithoutFields;return i&&r.push(`${i.rows} record(s) written again without the fields the target refused them on:`,...i.fields.map(({field:d,rows:u,refusedBy:l="validation-rule",reason:a})=>` ${u} without ${d}: ${Ho[l]}, ${a}`)),r}function uo(t){return`${t.join(", ")}: encrypted, and read masked by the user the source is read as (it lacks View Encrypted Data): left out of every record written, never copied as masks`}function Xo(t){return t?t.neutralized?[`emails and phone numbers: ${t.values} value(s) in ${t.fields.length} field(s) neutralized, addresses under .invalid and numbers fictional, so what the target's automation sends to them reaches no one`,...t.fields.map(({objectApiName:r,field:e,values:n})=>` ${r}.${e} ${n}`),...t.numbersExhausted?[` ${t.numbersExhausted} phone number(s) left out, their field empty: the 10 000 fictional numbers were all given to other numbers of the run`]:[]]:["emails and phone numbers: written as read (--keep-contact-points): the target's automation may have emailed or texted the people the records name"]:[]}function Zo(t){return(t??[]).map(r=>`${fn(r)}.`)}function Qo(t,r=!1){return[...r?[Gr]:[],...nr(t??[]).map(e=>`${e}.`)]}function es(t){let r=t.read==="delta"?`delta: ${t.changed} record(s) changed since ${t.since??"the last run"}`:`delta: read whole (${t.reason??"no watermark"}), ${t.changed} record(s)`,e=t.deletionsChecked?`, ${t.deleted} deleted as the source deleted them`+(t.deleteFailed>0?`, ${t.deleteFailed} refused`:""):"",n=t.recorded!==void 0?"; watermark recorded":"; watermark kept as it was: the next run reads from the same point",s=(t.lookupsOwed??0)>0?`, ${t.lookupsOwed} record(s) left without a lookup this run was to set among them`:"";return`${r}${e}${n}${s}`}function ts(t){let r=new Map,e=new Tn,n=new Map,s=new Set,i,d,u,l=a=>{if(a<=0)return;let h=new Date().toISOString();d??=h,u=h};return{runId:t,sending:(a,h)=>l(h),writing:(a,h)=>l(h),answered:()=>{u=new Date().toISOString()},note:(a,h)=>{if(h.length===0)return;let g=h.filter(m=>{let b=m.slice(0,15);return s.has(b)?!1:(s.add(b),!0)});g.length>0&&r.set(a,[...r.get(a)??[],...g]),i=new Date().toISOString(),d??=i,u=i},touched:(a,h)=>{h<=0||(i=new Date().toISOString(),u=i)},overwriting:(a,h,g)=>{g.length!==0&&(e.candidates(a,h,g),l(g.length))},overwrote:(a,h)=>{e.answer(a,h),u=new Date().toISOString()},deleted:(a,h)=>{if(h.length===0)return;let g=n.get(a)??new Map;for(let m of h)g.has(m.slice(0,15))||g.set(m.slice(0,15),m);n.set(a,g),l(h.length)},overwrittenCount:()=>e.count,flush:async()=>{},created:()=>[...r].map(([a,h])=>({objectApiName:a,ids:[...h]})),lastWrittenAt:()=>i,firstWrittenAt:()=>d,lastWriteAt:()=>u,overwritten:()=>e.read(),deletions:()=>[...n].map(([a,h])=>({objectApiName:a,ids:[...h.values()]}))}}function ns(t,r){return r?{runId:t.runId,note:(e,n,s)=>{t.note(e,n,s),r.note(e,n,s)},noteUnanswered:(e,n)=>{t.note(e,n),r.noteUnanswered?r.noteUnanswered(e,n):r.note(e,n)},sending:(e,n,s)=>{t.sending?.(e,n,s),r.sending?.(e,n,s)},answered:(e,n)=>{t.answered?.(e,n),r.answered?.(e,n)},writing:(e,n)=>{t.writing?.(e,n),r.writing?.(e,n)},touched:(e,n)=>{t.touched?.(e,n),r.touched?.(e,n)},overwriting:(e,n,s,i)=>{t.overwriting?.(e,n,s),r.overwriting?.(e,n,s,i)},overwrote:(e,n)=>{t.overwrote?.(e,n),r.overwrote?.(e,n)},deleted:(e,n)=>{t.deleted?.(e,n),r.deleted?.(e,n)},checkpoint:e=>{t.checkpoint?.(e),r.checkpoint?.(e)},overwrittenCount:()=>t.overwrittenCount?.()??r.overwrittenCount?.()??0,flush:async()=>await t.flush()??await r.flush()}:t}var At="sandforge-sync";function rs(t,r){let e=new Set(r);return{...t,objectsRead:t.objectsRead.filter(n=>e.has(n)),objects:t.objects.filter(n=>e.has(n.objectApiName))}}async function os(t){try{let e=(await t.query("SELECT Id FROM Organization LIMIT 1")).records[0]?.Id;return typeof e=="string"?e:void 0}catch{return}}async function ss(t=process.argv){if(t.slice(2).includes("--remove"))return $s(t);let r=Date.now(),e=Fo(t),n=o=>{e.json||process.stdout.write(`${o}
|
|
287
|
+
`)},s=o=>{process[e.json?"stderr":"stdout"].write(`${o}
|
|
288
|
+
`)},i,d;if(e.configFile!==void 0&&e.store!==void 0){let o;try{o=he(e.configFile,"utf8")}catch(y){process.stderr.write(`--config-file ${e.configFile} cannot be read: ${y instanceof Error?y.message:String(y)}
|
|
289
|
+
`),process.exit(2)}let c=No(o,e);"refusal"in c&&(process.stderr.write(`--config-file ${e.configFile} ${c.refusal}
|
|
290
|
+
`),process.exit(2));let p=Ht(c.config.objects);p.length>0&&(process.stderr.write(`--config-file ${e.configFile}: ${Kt(p)} Nothing was read or written.
|
|
291
|
+
`),process.exit(1)),i=c.config,d=oo(e.store),d.save(i)}else i=Po(e);n(`sandforge sync ${e.source} -> ${e.target}`),n(`objects: ${i.objects.map(o=>o.objectApiName).join(", ")}`+(d?` (configuration ${i.id}, ${i.mode})`:""));let u=$e(await xe(e.source)),l=await xe(e.target),a=$e(l),h=[Xe(a)],g=()=>h.reduce((o,c)=>o+c(),0),m=new Map,b=new AbortController,S=e.dryRun?await ve(a).catch(()=>{}):await en(a,e.target,{tool:"sandforge sync",action:"write",readOnly:"--dry-run"}),C=`sandforge-sync-${So()}`,I=ts(C),W=e.dryRun?void 0:tt(Le()),v=W?.recorder({runId:C,configId:d?i.id:At,configName:d?i.name:At,sourceOrgId:e.source,targetOrgId:S?.id??e.target,targetAlias:e.target,...S?{targetOrganizationId:S.id}:{}}),$;ar(v&&{runUser:o=>{$=o,v.runUser?.(o)}},()=>a.identity(),"sandforge sync");let k=!1,J=()=>{let o=W?.pathOf(C);k||o===void 0||(k=!0,s(`run file: ${o} (--remove ${o} takes back what the run creates)`))},N=ns(I,v),X=v?{...N,note:(o,c,p)=>{J(),N.note(o,c,p)},sending:(o,c,p)=>{J(),N.sending?.(o,c,p)}}:N,B=e.checkpointFirst?lr({module:"sync",operationId:C,request:e.checkpointFirst,session:l,org:ur(l,S??await ve(a)),connect:o=>{let c=$e(o);return h.push(Xe(c)),c},journalDir:Le(),say:s,own:{runId:C}}):void 0,T=async o=>{let c=m.get(o);if(c)return c;let p=await a.sobject(o).describe(),y=yt(p);return m.set(o,y),y},ge=i.objects.some(o=>o.operation==="update"||o.operation==="upsert"),q=mt(),M;if(!e.dryRun&&ge){let o=wt(q);o!==void 0&&(process.stderr.write(`${o} What the run would write over could not be kept, so nothing was written.
|
|
292
|
+
`),process.exit(1)),M=Lr({runId:C,orgId:e.target,...S?{organizationId:S.id}:{},files:new dt(at(q)),meta:De(pe(q,"snapshots.json"))})}let re=async o=>(await ne({query:async c=>a.query(c),queryMore:async c=>a.queryMore(c)},o)).records,Z=M?Dr({query:re,backup:M,recorder:X,describe:o=>T(o),viewsEncrypted:it(re)}):void 0,oe=new kn,F=new Jr({connection:a,bulkExecutor:oe,bulkManager:new cn,retryConfig:{},signal:b.signal,onProgress:(o,c,p)=>n(` ${p}: ${o}/${c}`),log:n,calls:zr(X,Z)}),j=!1,G=async(o,c,p,y,P)=>{if(e.dryRun)throw new Error(`A dry run writes nothing: ${o} ${c} refused.`);return J(),p.length>0&&(j=!0),o==="delete"?F.delete(c,p,y):o==="upsert"?F.upsert(c,P??"Id",p,y):o==="update"?F.update(c,p,y):F.insert(c,p,y)},H=new Date().toISOString(),se,_,me,D,Q=Vr(i,async o=>(await a.query(o)).totalSize),we,ye=!1,be=o=>{if(!ye){ye=!0,n("");for(let c of o)n(c)}},U={readStorage:()=>Jn(a),readApiBudget:()=>Hn(a),readAutomation:async o=>{try{let c=await Ue(a).read(e.target,o);return we??=c,be(Gn(c,e.target,{mayMute:ut("--mute-automation"),mayApplyAssignmentRules:!1})),c}catch(c){throw be([`target automation: what ${e.target} runs on the objects the run writes could not be read (${c instanceof Error?c.message:String(c)})`]),c}},readLimits:()=>Yn(a),readDeliverability:async()=>Zt(S??await ve(a))?Ln:Dn(a),emails:{target:e.target,accepted:e.acceptEmails,keepsAddresses:i.keepContactPoints===!0,mayMute:!e.muteAutomation},confirmAboveRecords:zn,sentBefore:()=>g()+(e.dryRun?ir:0),...Q?{countTarget:Q}:{},targetFields:async o=>so((await T(o)).fields??[]),...B?{checkpointFirst:{scope:async(o,c)=>(se={written:o,running:c},_=await B.scope(se),_),take:async o=>{if(!se)throw new Error("its scope was not read");let c=await B.take(se,o,{signal:b.signal});if(c.taken){me=c.checkpoint,X.checkpoint?.(c.checkpoint);for(let p of pr(c.checkpoint,e.target,e.muteAutomation))s(p)}return c}}}:{}},Oe=S?Jt({orgType:Ve({isSandbox:S.sandbox,edition:S.edition}),metadata:{edition:S.edition}}):"production",f,w,O,A=[],x=[],ee=o=>{let c=no({go:!1,...o});return c.go?o:{code:c.code,message:c.message}},K=(o,c)=>({measure:async p=>{let y=await bt(p,{...U,readAutomation:o,...c?{mutePlan:c}:{}});w=y.checkpointFailed,O=y.runEmails?.gate.stop;let P=Rt(y,{policy:"refuse",org:e.target});return A=P.filter(V=>!Eo.has(V.code)).map(({code:V,message:Se})=>({code:V,message:Se})),e.dryRun||(x=P.map(ee)),y.check},hold:async p=>{let y=await bt(p,{...U,readAutomation:o,...c?{mutePlan:c}:{}});f=y.check,n("");for(let ce of io(y.check,e.target))n(ce);for(let ce of y.checkpoint?ft(y.checkpoint):[])s(ce);let P=await Xr(y,{policy:"refuse",org:e.target,orgTier:Oe}),[V,...Se]=Rt(y,{policy:"refuse",org:e.target});return x=!P.go&&V?.code===P.code?Se.map(ee):[],{check:y.check,answer:no(await Qr(y,P,U.checkpointFirst))}}}),ie=e.muteAutomation&&!e.dryRun?eo(K,U.readAutomation,async o=>{let c=await _e(async()=>Ne(a),o,{writes:kt});for(let p of le(c.muted,e.target))n(` ${p}`);return c},`sandforge sync ${C}`,{target:e.target}):void 0,E,jt,Ct=()=>E??=(async()=>{let o=i.objects.map(p=>p.objectApiName),c=await U.readAutomation(o).catch(p=>({unread:p instanceof Error?p.message:String(p)}));try{let p=await _e(async()=>Ne(a),c,{writes:kt});for(let y of le(p.muted,e.target))n(y);return jt=p,{planned:p}}catch(p){if(!Me(p))throw p;return n(rn(p.refusal)),{refused:p.refusal}}})(),lo=async o=>{let c=(await Ct()).planned?.automation;return c&&o.every(p=>c.objectsRead.includes(p))?rs(c,o):U.readAutomation(o)},xt=ie?.gate??(e.dryRun&&e.muteAutomation?K(lo,()=>jt?.plan):K(U.readAutomation)),fo={measure:o=>xt.measure(o),hold:async o=>{let c=await xt.hold(o);return c.answer.go&&J(),c}},Re,ae;if(i.files!==void 0){let o=S?_o(S):!1;ae=Mo(i,u,a,d?.fileStore(),o,e.maxRecordsPerObject),e.dryRun&&ae.deleteFromTarget&&(ae={...ae,deleteFromTarget:async c=>{throw new Error(`A dry run writes nothing: delete ${c} refused.`)}})}let te=new Map,It=()=>{let o=Lo([...te.values()],e);o.length>0&&process.stderr.write(`${o.join(`
|
|
293
|
+
`)}
|
|
294
|
+
`)},Et=()=>te.size>0?{readCut:[...te.values()]}:{},Tt=new Hr({...e.dryRun?{}:{creations:X},signal:b.signal,...ae?{files:ae}:{},...d&&e.store!==void 0?{idMap:On(et(e.store),o=>d.isSaved(o))}:{},...d?{deltaStore:d.deltaStore(),deltaReads:mn({query:async(o,c)=>u.query(o,c),queryMore:async o=>u.queryMore(o)},{query:async o=>a.query(o),queryMore:async o=>a.queryMore(o)},b.signal)}:{},dataSync:new Ur({insert:(o,c,p)=>G("insert",o,c,p),update:(o,c,p)=>G("update",o,c,p),upsert:(o,c,p,y)=>G("upsert",o,p,y,c),delete:(o,c,p)=>G("delete",o,c,p),describeTargetFields:T}),conflictResolver:new Kr,fieldMapping:new gn,transformPipeline:new pn,querySource:to(u,e.maxRecordsPerObject,(o,c)=>{te.set(o,{objectApiName:o,read:c,bound:e.maxRecordsPerObject})}),queryTarget:to(a,e.maxRecordsPerObject),maskedSourceFields:Nn(it(async o=>(await ne({query:async c=>u.query(c),queryMore:async c=>u.queryMore(c)},o)).records),o=>u.sobject(o).describe()),findInTarget:hn({query:async o=>a.query(o),queryMore:async o=>a.queryMore(o)}),bulkThreshold:oe.getThreshold(),describeTargetFields:T,describeTargetFieldsAgain:async o=>yt(await a.sobject(o).describe()),leaseOfTheGate:()=>ie?.lease(),queryTargetRows:re,countSource:Do(u,e.maxRecordsPerObject),countPersonAccounts:Uo(u),readSourceIds:Wo(u),writeGate:fo,readValidationRules:Bn(async o=>(await ne({query:async c=>a.tooling.query(c),queryMore:async c=>a.tooling.queryMore(c)},o)).records,Wn(a),qn(a)),currencies:()=>ln(async o=>(await u.query(o)).records,async o=>(await a.query(o)).records,{source:async o=>(await u.tooling.query(o)).records,target:async o=>(await a.tooling.query(o)).records}),standardPricebooks:()=>qr(async o=>(await u.query(o)).records,async o=>(await a.query(o)).records),recordTypes:()=>Yr({query:async o=>u.query(o),queryMore:async o=>u.queryMore(o)},{query:async o=>a.query(o),queryMore:async o=>a.queryMore(o)})});if(e.dryRun){n(`
|
|
295
|
+
simulating\u2026 (DRY-RUN: nothing is written)`);let c={...await Tt.simulate(i),..._?{checkpoint:_}:{}},{planned:p,refused:y}=e.muteAutomation?await Ct():{},P=w??(_?.refusal?fr(_.refusal):void 0),V=c.writeCheck?.unwritable??[],Se=[y,V.length>0?{code:"SYNC_TARGET_UNWRITABLE",message:Zr(V,e.target,c.writeCheck?.heldBack)}:void 0,P!==void 0?{code:fe,message:P}:void 0,...A,O].filter(Ye=>Ye!==void 0),ce=Date.now()-r;if(It(),Te(Ee(vt("success",[...te.values()]),e.failOnPartial)),e.json){process.stdout.write(`${JSON.stringify({tool:"sandforge-sync",source:e.source,target:e.target,dryRun:!0,simulation:c,...we?{targetAutomation:we}:{},...Et(),...Un(p),..._?{checkpoint:_}:{},apiRequests:$t(c.writeCheck?.apiRequests,g()),...on(Se),elapsedMs:ce},null,2)}
|
|
296
|
+
`);return}let po=(p?.plan?.assign.length??0)>0;for(let Ye of qo(c,e.target,po,P,O?.message))n(Ye);n(`
|
|
297
|
+
done in ${ce}ms`);return}n(`
|
|
298
|
+
executing\u2026 (REAL)`);let Y=W?.pathOf(C),de,ho=Ze(o=>{de=o,process.stderr.write(`
|
|
299
|
+
interrupted: the run stops before its next call, and its file keeps what it created (Ctrl-C again ends it at once)
|
|
300
|
+
`),b.abort()}),Ft=async()=>{!B||!me||D||(D=await gr(B,me,j,e.target,s))},z,Je={status:"failure"};try{z=await Tt.execute(i).finally(async()=>{Re=await ie?.release()}),Re&&(z={...z,mutedAutomation:Re}),Je={status:vt(z.status,[...te.values()]),...z.cancelled?{cancelled:!0}:{}},await Ft()}catch(o){if(M?.close(),await Ft(),!(o instanceof Wr))throw await v?.end(Je),Y!==void 0&&Ae(Y)&&process.stderr.write(`the run stopped on an error; what it created is kept in ${Y}, and --remove ${Y} takes it back
|
|
301
|
+
`),o;let c=o.code===Qe,p=c?[]:x;e.json?(c||process.stderr.write(`${[o,...p].map(Fe).join(`
|
|
302
|
+
`)}
|
|
303
|
+
`),process.stdout.write(`${JSON.stringify({tool:"sandforge-sync",source:e.source,target:e.target,dryRun:!1,refused:{code:o.code,message:o.message},...p.length>0?{alsoRefused:p}:{},...f?{writeCheck:f}:{},...D?{checkpoint:D}:{},apiRequests:$t(f?.apiRequests,g()),elapsedMs:Date.now()-r},null,2)}
|
|
304
|
+
`)):n(c?`
|
|
305
|
+
${o.message}`:`
|
|
306
|
+
${[o,...p].map(Fe).join(`
|
|
307
|
+
`)}`),process.exit(c?Ie(de??"SIGINT"):1)}finally{ho()}await v?.end(Je),M?.close();let Pt=await v?.flush();Pt!==void 0&&process.stderr.write(`what the run created could not all be written to ${Y??"its file"} (${Pt}): --remove takes it back from the --json summary
|
|
308
|
+
`);let Nt=Date.now()-r,He=I.created(),Mt=I.lastWrittenAt(),_t=I.firstWrittenAt(),Lt=I.lastWriteAt(),je=I.overwritten(),Ke=I.deletions(),Dt=He.length>0||je.length>0||Ke.length>0?S?.id??await os(a):void 0,ke=Y!==void 0&&Ae(Y)?Y:void 0;It();let Ce=vt(z.status,[...te.values()]);if(e.json){process.stdout.write(`${JSON.stringify({tool:"sandforge-sync",source:e.source,target:e.target,...Dt?{targetOrgId:Dt}:{},...d?{configId:i.id}:{},dryRun:e.dryRun,startedAt:H,finishedAt:new Date().toISOString(),result:{...z,status:Ce,...$!==void 0?{runUserId:$}:{}},...Et(),...D?{checkpoint:D}:{},apiRequests:$t(f?.apiRequests,g()),created:{runId:I.runId,...Mt?{lastWrittenAt:Mt}:{},..._t?{firstWrittenAt:_t}:{},...Lt?{lastWriteAt:Lt}:{},...ke?{runFile:ke}:{},objects:He,...je.length>0?{overwritten:je}:{},...Ke.length>0?{deleted:Ke}:{}},elapsedMs:Nt},null,2)}
|
|
309
|
+
`),de&&process.exit(Ie(de)),Te(Ee(Ce,e.failOnPartial));return}let Ut=z.objectResults??[];n(`
|
|
310
|
+
status: ${Ce}`);for(let o of Re?le(Re,e.target):[])n(o);for(let o of Ut){n(` ${Ko(o)}`),typeof o.alreadyCopied=="number"&&n(` ${o.alreadyCopied} already copied by an earlier run of this configuration, left as they are`),typeof o.alreadyLinked=="number"&&n(` ${co(o.alreadyLinked)}`);for(let y of zo(o.errors??[]))n(` ${y}`);for(let y of Vo(o))n(` ${y}`);for(let y of Zo(o.currenciesReplaced))n(` ${y}`);for(let y of Qo(o.pricesSettled,o.standardPricebookMatched===!0))n(` ${y}`);let c=o.files;c&&n(` files: ${c.copied??0} copied, ${c.versions??0} version(s) added, ${c.failed??0} failed`);let p=o.delta;p&&n(` ${es(p)}`)}for(let o of ao(Ut,!1))n(` ${o}`);for(let o of Xo(z.contactPoints))n(` ${o}`);let Wt=He.reduce((o,c)=>o+c.ids.length,0),Bt=je.reduce((o,c)=>o+c.ids.length,0);Bt>0&&n(`
|
|
311
|
+
wrote over ${Bt} record(s) of ${e.target}, their values from before kept in ${pe(q,"backups")}: --remove ${ke??"with the --json summary"} gives them back`),Wt>0&&n(`
|
|
312
|
+
created ${Wt} record(s) and file(s) in ${e.target}: `+(ke!==void 0?`--remove ${ke} takes them back`:"run with --json and save the summary to a file, and --remove takes them back from it")),n(`
|
|
313
|
+
done in ${Nt}ms`),de&&process.exit(Ie(de)),Te(Ee(Ce,e.failOnPartial))}var qe=new Set(["--remove","--target","--include-changed","--accept-automation","--mute-automation","--store","--sweep","--sweep-list",...$r,"--leave-undeletable","--json"]),is=new Set(["--remove","--target","--store"]);function as(t){let r=t.slice(2);for(let u=0;u<r.length;u++){let l=r[u];if(is.has(l)){u++;continue}qe.has(l)||(process.stderr.write(`--remove takes --target, --include-changed, --accept-automation, --mute-automation, --store, --sweep, --sweep-late, --sweep-untied, --sweep-list, --leave-undeletable and --json, not "${l}". Run with --help.
|
|
314
|
+
`),process.exit(2))}let e=u=>{let l=r.indexOf(u);return l>=0&&l+1<r.length?r[l+1]:void 0},n=e("--remove"),s=e("--target"),i=e("--store");r.includes("--store")&&(!i||qe.has(i))&&(process.stderr.write(`--store wants the directory the configuration of the run is kept in.
|
|
315
|
+
`),process.exit(2)),(!n||!s||qe.has(n)||qe.has(s))&&(process.stderr.write(`--remove takes the file a run printed its --json summary to, or the run file it named as it began, or its run id, and --target the org the run wrote to. Run with --help.
|
|
316
|
+
`),process.exit(2)),r.includes("--sweep")&&r.includes("--sweep-list")&&(process.stderr.write(`--sweep deletes and --sweep-list only lists: give one of them. Run with --help.
|
|
317
|
+
`),process.exit(2));let d=Ar(r);return"refusal"in d&&(process.stderr.write(`${d.refusal} Run with --help.
|
|
318
|
+
`),process.exit(2)),{summaryPath:n,target:s,includeChanged:r.includes("--include-changed"),acceptAutomation:r.includes("--accept-automation"),muteAutomation:r.includes("--mute-automation"),json:r.includes("--json"),...i!==void 0?{store:i}:{},sweep:r.includes("--sweep"),sweepList:r.includes("--sweep-list"),...d,leaveUndeletable:r.includes("--leave-undeletable")}}var Ge=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,ds=R.object({tool:R.literal("sandforge-sync"),source:R.string().min(1),target:R.string().min(1),targetOrgId:R.string().regex(Ge).optional(),configId:R.string().min(1).max(200).optional(),dryRun:R.boolean().optional(),startedAt:R.string().min(1).max(40).optional(),finishedAt:R.string().min(1).max(40).optional(),result:R.object({status:R.enum(["success","partial","failure"])}).loose(),created:R.object({runId:R.string().min(1).max(200),lastWrittenAt:R.string().min(1).max(40).optional(),firstWrittenAt:R.string().min(1).max(40).optional(),lastWriteAt:R.string().min(1).max(40).optional(),runFile:R.string().min(1).max(4096).optional(),objects:R.array(R.object({objectApiName:R.string().regex(L),ids:R.array(R.string().regex(Ge))})),overwritten:R.array(R.object({objectApiName:R.string().regex(L),backup:In,ids:R.array(R.string().regex(Ge))})).optional(),deleted:R.array(R.object({objectApiName:R.string().regex(L),ids:R.array(R.string().regex(Ge))})).optional()}).optional()}).loose();function cs(t){let r;try{r=JSON.parse(t)}catch{return{refusal:"is not JSON: save the output of a run printed with --json."}}let e=an(r,"sandforge-sync");if(e)return{refusal:dn(e)};let n=ds.safeParse(r);if(!n.success){let s=n.error.issues[0];return{refusal:`is not the summary of a sandforge sync run (${s.path.join(".")||"summary"}: ${s.message}).`}}return n.data.dryRun===!0?{refusal:"is the summary of a dry run, which wrote nothing: there is nothing to remove."}:n.data.created?{summary:n.data}:{refusal:"names nothing the run created: it was printed before runs named what they created, so its records cannot be told from the ones it updated."}}function us(t){return/\.json$/i.test(t)?t.replace(/\.json$/i,".removals.json"):`${t}.removals.json`}function ls(t,r){let e=t.created,n=t.finishedAt??e?.lastWrittenAt??new Date().toISOString();return{runId:e?.runId??"sandforge-sync",configId:t.configId??"sandforge-sync",configName:t.configId??"sandforge-sync",sourceOrgId:t.source,targetOrgId:t.target,startedAt:t.startedAt??n,end:{at:n,status:t.result.status},...e?.lastWrittenAt?{lastWrittenAt:e.lastWrittenAt}:{},...e?.firstWrittenAt?{firstWrittenAt:e.firstWrittenAt}:{},...e?.lastWriteAt?{lastWriteAt:e.lastWriteAt}:{},created:(e?.objects??[]).filter(s=>s.ids.length>0),...(e?.overwritten??[]).some(s=>s.ids.length>0)?{overwritten:(e?.overwritten??[]).filter(s=>s.ids.length>0)}:{},...(e?.deleted??[]).some(s=>s.ids.length>0)?{deleted:(e?.deleted??[]).filter(s=>s.ids.length>0)}:{},...r?{removal:r}:{}}}function fs(t,r,e="sandforge sync"){if(r.sandbox||zt(r.edition))return;let n=r.edition?`IsSandbox false, edition ${r.edition}`:"IsSandbox false, and no edition";return`${t} is a production org (its Organization record says ${n}): ${e} removes records from sandboxes and Developer Edition orgs only. Nothing was deleted.`}function hs(t,r){let e=n=>[n.deleted>0?`${n.deleted} deleted`:"",n.alreadyGone>0?`${n.alreadyGone} already gone`:"",(n.notVisible??0)>0?`${n.notVisible} not visible`:"",n.keptChanged>0?`${n.keptChanged} kept, changed since the run`:"",n.keptDependents>0?`${n.keptDependents} kept, records that stay depend on them`:"",n.refused>0?`${n.refused} refused`:"",(n.notReached??0)>0?`${n.notReached} not reached`:""].filter(Boolean).join(", ");return[`removal: ${t.toUpperCase()}`,...r.flatMap(n=>[` ${n.objectApiName}: ${e(n)||"nothing"} of ${n.planned}${Rr(n)}`,...kr(n),...n.reasons.map(s=>` ${s}`)])]}function ps(t){return t.flatMap(r=>{let e=[r.keptChanged>0?`${r.keptChanged} left as they are, changed since the run`:"",r.alreadyGone>0?`${r.alreadyGone} no longer in the org`:"",r.refused>0?`${r.refused} refused`:"",r.notKept>0?`${r.notKept} whose values from before are no longer kept (their backup was deleted, or past its retention)`:"",(r.notReached??0)>0?`${r.notReached} not reached`:"",(r.restoredWithout??0)>0?`${r.restoredWithout} given back but for fields the org no longer takes, which keep the run's values`:""].filter(Boolean);return[` ${r.objectApiName}: ${r.restored} of ${r.planned} given back their values from before the run${e.length>0?`; ${e.join(", ")}`:""}`,...r.reasons.map(n=>` ${n}`)]})}function gs(t){return t.flatMap(r=>{let e=[r.alreadyBack>0?`${r.alreadyBack} back in the org already`:"",r.goneForGood>0?`${r.goneForGood} no longer in the recycle bin, gone for good`:"",r.refused>0?`${r.refused} refused`:"",(r.notReached??0)>0?`${r.notReached} not reached`:""].filter(Boolean);return[` ${r.objectApiName}: ${r.undeleted} of ${r.planned} the run deleted brought back from the recycle bin${e.length>0?`; ${e.join(", ")}`:""}`,...r.reasons.map(n=>` ${n}`)]})}function ms(t,r){return t===void 0?[]:[...r.readWhole&&r.readWhole.length>0?[`configuration ${t}: its next run reads ${r.readWhole.join(", ")} whole`]:[],...(r.filesForgotten??0)>0?[`configuration ${t}: ${r.filesForgotten} copied file(s) forgotten, copied again by its next run`]:[],...(r.linksForgotten??0)>0?[`configuration ${t}: ${r.linksForgotten} record(s) forgotten, which no later run points a lookup at`]:[]]}var ro=3,ws=/^[A-Za-z0-9][A-Za-z0-9_-]{0,199}$/;function ys(t,r=Le(),e=Cn){if(Ae(t)){let s;try{s=he(t,"utf8").split(`
|
|
319
|
+
`).find(d=>d.trim()!=="")}catch{return}let i;try{i=JSON.parse(s??"")}catch{return}return typeof i=="object"&&i!==null&&"run"in i?jo(t):void 0}if(!ws.test(t))return;let n=pe(r,e,`${t}.ndjson`);return Ae(n)?n:void 0}function bs(t){let r=We(t.runUserId),e=br.safeParse(t.mutedAutomation);return{...r?{runUserId:r}:{},...e.success?{muted:e.data}:{}}}function Rs(t,r,e){if(t===void 0||r===void 0)return;let n;try{n=nt(he(t,"utf8"))}catch{return}if(!(!n||n.runId!==r)&&!(e!==void 0&&n.configId!==e))return We(n.runUserId)}function ks(t,r){let e;try{e=he(t.summaryPath,"utf8")}catch(m){process.stderr.write(`--remove ${t.summaryPath} cannot be read: ${m instanceof Error?m.message:String(m)}
|
|
320
|
+
`),process.exit(2)}let n=cs(e);"refusal"in n&&(process.stderr.write(`--remove ${t.summaryPath} ${n.refusal}
|
|
321
|
+
`),process.exit(2));let{summary:s}=n;s.targetOrgId===void 0&&s.target!==t.target&&(process.stderr.write(`The run wrote to ${s.target}, and what it created is removed from that org only: give --target ${s.target}.
|
|
322
|
+
`),process.exit(2));let i=us(t.summaryPath),d,u;try{u=he(i,"utf8")}catch(m){m?.code!=="ENOENT"&&(process.stderr.write(`${i} cannot be read: ${m instanceof Error?m.message:String(m)}
|
|
323
|
+
`),process.exit(2))}if(u!==void 0){let m;try{m=JSON.parse(u)}catch{m=void 0}let b=m?.runId;d=b===s.created?.runId?En(m):void 0,b!==s.created?.runId?r(`${i} is of another run: it is not read, and this removal's takes its place`):d||(process.stderr.write(`${i} does not read as what earlier removals did.
|
|
324
|
+
`),process.exit(2))}let l=ls(s,d),a=d??{},h=bs(s.result),g=h.runUserId??Rs(s.created?.runFile,s.created?.runId);return{run:l,...s.configId!==void 0?{configId:s.configId}:{},...s.targetOrgId!==void 0?{targetOrgId:s.targetOrgId}:{},...d?{earlier:d}:{},...h,...g!==void 0?{runUserId:g}:{},updateRemoval:async m=>{a=m(a);let b=`${i}.${process.pid}.tmp`;Ao(b,`${JSON.stringify({version:1,runId:l.runId,...a},null,2)}
|
|
325
|
+
`),$o(b,i)}}}async function Ss(t,r){let e=tt(Oo(t),""),n;try{n=nt(he(t,"utf8"))}catch(d){process.stderr.write(`--remove ${t} cannot be read: ${d instanceof Error?d.message:String(d)}
|
|
326
|
+
`),process.exit(2)}n||(process.stderr.write(`--remove ${t} names no run of sandforge sync.
|
|
327
|
+
`),process.exit(2)),e.pathOf(n.runId)!==t&&(process.stderr.write(`--remove ${t} is the file of the run ${n.runId} under another name: give it as ${e.pathOf(n.runId)}, where what its removals did is kept beside it.
|
|
328
|
+
`),process.exit(2));let s=await e.get(n.runId)??n;s.targetOrganizationId===void 0&&s.targetOrgId!==r.target&&(process.stderr.write(`The run wrote to ${s.targetOrgId}, and what it created is removed from that org only: give --target ${s.targetOrgId}.
|
|
329
|
+
`),process.exit(2));let i=We(s.runUserId);return{run:s,...s.configId!==At?{configId:s.configId}:{},...s.targetOrganizationId!==void 0?{targetOrgId:s.targetOrganizationId}:{},...s.removal?{earlier:s.removal}:{},updateRemoval:d=>e.updateRemoval(s.runId,d),runs:e,...i?{runUserId:i}:{}}}function vs(t,r){return t.map(({job:e,objectApiName:n,read:s})=>{let i=` Bulk API job ${e} (${n})`;switch(s.state){case"ended":return`${i}: the run's file holds no answer of it; it ended in ${r}, and the ${s.created.length} record(s) it created are removed with the rest`;case"never-closed":return`${i}: never closed, it wrote nothing`;case"running":return`${i}: still running in ${r}: what it creates stays, and the next --remove of the run reads it again`;default:return`${i}: could not be read back (${s.reason}): what it created stays`}})}async function $s(t=process.argv){let r=Date.now(),e=as(t),n=f=>{process[e.json?"stderr":"stdout"].write(`${f}
|
|
330
|
+
`)},s=ys(e.summaryPath),i=s!==void 0?await Ss(s,e):ks(e,n),{earlier:d}=i,u;e.store!==void 0&&(i.configId===void 0&&(process.stderr.write(`--store tells the configuration a run was of what its removal took, and ${e.summaryPath} names none: the run was not of a saved configuration (--config-file).
|
|
331
|
+
`),process.exit(2)),u=Ae(pe(e.store,"configStore.json"))?oo(e.store):void 0,u?.isSaved(i.configId)||(process.stderr.write(`${e.store} holds no configuration ${i.configId}: give the --store the run was made with.
|
|
332
|
+
`),process.exit(2)));let l=i.run;jn(l)&&Z({code:nn,message:`The run is still writing, in process ${l.writer?.pid??"?"}: remove it once it has ended. Nothing was deleted.`});let a,h=(f,w,O,A={},x,ee,K,ie)=>{if(e.json){process.stdout.write(`${JSON.stringify({tool:"sandforge-sync",action:"remove",summary:e.summaryPath,target:e.target,includeChanged:e.includeChanged,result:{status:f,planned:O,objects:w,...A,...x?{sweep:x}:{},...a?{sweepListing:a}:{},...ee?{restored:ee}:{},...K?{undeleted:K}:{},...ie?{mutedAutomation:ie}:{}},elapsedMs:Date.now()-r},null,2)}
|
|
333
|
+
`);for(let E of pt(w,e))n(E);return}for(let E of x?vr(x):[])n(E);for(let E of hs(f,w))n(E);for(let E of pt(w,e))n(E);for(let E of K?gs(K):[])n(E);for(let E of ee?ps(ee):[])n(E);for(let E of ms(i.configId,A))n(E);n(`
|
|
334
|
+
done in ${Date.now()-r}ms`)},g=i.runs!==void 0&&(l.jobs??[]).length>0;if(rt(l).length===0&&ot(l).length===0&&st(l).length===0&&!g&&!e.sweep&&!e.sweepList){let f=d?.undo?.removedAt??d?.restoredAt??d?.undeletedAt;n(f!==void 0?`what the run created was removed already, on ${f}`:"The run created nothing: there is nothing of it to remove."),h("success",[],0);return}let m=await xe(e.target),b=$e(m),S=await ve(b),C=e.sweepList?void 0:fs(e.target,S);if(C&&Z({code:"PRODUCTION_TARGET",message:C}),i.targetOrgId!==void 0&&i.targetOrgId.slice(0,15)!==S.id.slice(0,15)&&Z({code:tn,message:`${e.target} is not the org the run wrote to (${i.targetOrgId}), and what it created is removed from that org only. Nothing was deleted.`}),g&&i.runs){let f=i.runs,w=await Er(f,l,b,()=>Pe(b,"sandforge sync --remove").serverTime());for(let O of vs(w,e.target))n(O);w.some(O=>O.answered)&&(l=await f.get(l.runId)??l)}!l.end&&l.inFlight&&l.inFlight.job===void 0&&n(` the run stopped during a call of ${l.inFlight.rows} ${l.inFlight.objectApiName} row(s): those ${e.target} took are not in its file, and stay; ${ht("--sweep-list")} shows what the run's user created in the run's window`);let I=rt(l),W=async f=>{let w;try{w=await Ue(b).read(e.target,[...new Set([...l.created,...l.overwritten??[]].map(x=>x.objectApiName).filter(x=>!xn.includes(x)))])}catch(x){w={error:x instanceof Error?x.message:String(x)}}let O=Pe(b,"sandforge sync --sweep"),A=Ir({otherRuns:await xr({organizationId:S.id,alias:e.target,span:Cr(l),own:{runId:l.runId,ids:l.created.flatMap(x=>x.ids)}}),...i.muted?{muted:i.muted}:{},...d?.removalSpans?{removalSpans:d.removalSpans}:{},...d?.madeEarlier?{made:d.madeEarlier}:{},...d?.lateEarlier?{late:d.lateEarlier}:{}});return Mr(O,l.created,w,f,l.firstWrittenAt!==void 0?{at:l.firstWrittenAt,...l.lastWriteAt!==void 0?{lastAt:l.lastWriteAt}:{},serverTime:()=>O.serverTime()}:void 0,l.overwritten??[],{...i.runUserId?{runUserId:i.runUserId}:{},ties:A})};if(e.sweepList){let f=await or(gt(b,"sandforge sync --sweep-list"),await W(),d?.removalSpans??[]);for(let w of Be(f,e.target,e,!0))n(w);e.json?process.stdout.write(`${JSON.stringify({tool:"sandforge-sync",action:"sweep-list",summary:e.summaryPath,target:e.target,listing:f,elapsedMs:Date.now()-r},null,2)}
|
|
335
|
+
`):n(`
|
|
336
|
+
done in ${Date.now()-r}ms`),f.refusal!==void 0&&process.exit(ro);return}let v=ot(l),$,k={kept:[...v],notKept:0};if(v.length>0){let f=mt(),w=wt(f);if(w!==void 0)n(w);else{$=new dt(at(f));let O=De(pe(f,"snapshots.json"));k=_n(v,A=>O.get(`backup:${A}`),30)}}n(`sandforge sync --remove ${e.summaryPath} from ${e.target}`);for(let{objectApiName:f,ids:w}of k.kept)n(` ${f}: ${w.length} to give back their values from before the run`);k.notKept>0&&n(` values from before no longer kept (past sandforge.backup.maxAgeDays, or deleted): ${k.notKept} record(s) the run wrote over keep its values`),k.keptUntil!==void 0&&k.kept.length>0&&n(` values from before kept until ${k.keptUntil}, at the default retention`);let J=st(l);for(let{objectApiName:f,ids:w}of J)n(` ${f}: ${w.length} the run deleted, as the source had, to bring back from the recycle bin`);for(let{objectApiName:f,ids:w}of I)n(` ${f}: ${w.length} to remove`);I.length===0&&v.length===0&&J.length===0&&n("nothing left of the run to remove"),e.sweep&&n(`before them, a sweep deletes what the target's automation made for the run, as the run's user, tied to its records \u2014 run ${ht("--sweep-list")} to see what`);let N=new AbortController,X=Ze(()=>N.abort()),B=d??{},T=e.sweep?sr(gt(b,"sandforge sync --sweep",N.signal),await W(N.signal),{includeChanged:e.includeChanged,removalSpans:B.removalSpans??[],...Or(e),approve:async f=>{a=f,n("");for(let w of Be(f,e.target,e))n(w)}}):void 0;await T?.ask();let ge=Sr(T,a);if(ge){a=ge,n("");for(let f of Be(ge,e.target,e))n(f)}let q=f=>[...new Set(f.map(({objectApiName:w})=>w))],M=Yt({bringBack:q(J),giveBack:q(k.kept),setToDraft:vn(q(I)),delete:$n(q(I),[],{userKept:i.runUserId!==void 0})},T?.takes??[]),re=[...new Set(Object.values(M).flat())];function Z(f){return process.stderr.write(`${Fe(f)}
|
|
337
|
+
`),e.json&&process.stdout.write(sn({tool:"sandforge-sync",summary:e.summaryPath,target:e.target,elapsedMs:Date.now()-r},f)),process.exit(1)}let oe=f=>(X(),Z(f)),F;if(re.length>0&&!N.signal.aborted){let f=await Ue(b).read(e.target,re,{undeletes:!0});n("");for(let A of er(f,e.target,M))n(A);if(e.muteAutomation)try{F=await _e(async()=>Ne(b),f,{writes:Vt(M)});for(let A of le(F.muted,e.target))n(` ${A}`)}catch(A){if(!Me(A))throw A;oe(A.refusal)}let w=F?.automation??f,O=tr(w,e.target,{steps:M,assign:Qn(w,Xt(w,M)),mayMute:F===void 0&&ut("--mute-automation")});O&&!e.acceptAutomation&&oe({code:"AUTOMATION_NOT_ACCEPTED",message:O})}let j,G,H=F?.muted,se=async()=>{!F?.prepared||N.signal.aborted||(G=await F.prepared.acquire(`sandforge sync --remove ${l.runId}`).catch(f=>{if(!Me(f))throw f;return oe(f.refusal)}),H=G.outcome)},_=Pe(b,"sandforge sync --remove"),me=await Nr(_,l.created),D;try{j=await Pn({run:l,org:_,includeChanged:e.includeChanged,...jr(T),...i.runUserId?{runUserId:i.runUserId}:{},onUndeletable:mr(e.leaveUndeletable,e.target,f=>{D=f}),beforeFirstWrite:se,signal:N.signal,...u&&e.store!==void 0?{configs:u,links:et(e.store)}:{},...$?{backups:$}:{},undelete:f=>b.soap.undelete(f),...i.runs?{earlierRuns:Fn(l,await i.runs.list())}:{},store:{updateRemoval:(f,w)=>f!==l.runId&&i.runs?i.runs.updateRemoval(f,w):i.updateRemoval(O=>(B=w(O),B))}})}finally{X();let f=T?.made??new Set,w=T?.late??new Set,O=T?.gone??new Set;if((f.size>0||w.size>0||O.size>0)&&await i.updateRemoval(A=>_r(A,f,w,O)).catch(A=>{process.stderr.write(`What the sweep found made for the run could not be kept (${A instanceof Error?A.message:String(A)}): a later --sweep may list it as tied to nothing.
|
|
338
|
+
`)}),G){H=await G.release();for(let A of le(H,e.target))n(A)}}H&&(j={...j,result:{...j.result,mutedAutomation:H}}),j.stoppedForUndeletable&&(D&&Z(D),process.exit(1));let Q=j.result.status==="cancelled"?{}:await me.take(j.duplicateSets);for(let f of[...j.notes,...Q.note?[Q.note]:[]])process.stderr.write(`${f}
|
|
339
|
+
`);let we=j.result.objects.some(f=>f.deleted+f.alreadyGone>0);i.configId!==void 0&&!u&&we&&process.stderr.write(`The run was of the saved configuration ${i.configId}, and its store was not given: its next delta run is not told what this removal took, and a later run may point a lookup at a record it deleted. Give ${rr("--store")} with the next removal, or run the configuration full next time.
|
|
340
|
+
`);let{readWhole:ye,filesForgotten:be}=j.result,ze=T?.result(),U=An(j.result.status,ze),Oe=Q.object?[...j.result.objects,Q.object]:j.result.objects;h(U,Oe,Oe.reduce((f,w)=>f+w.planned,0),{...ye?{readWhole:ye}:{},...be!==void 0?{filesForgotten:be}:{},...j.linksForgotten!==void 0?{linksForgotten:j.linksForgotten}:{}},ze,j.result.restored,j.result.undeleted,H),U!=="success"&&process.exit(ro)}process.argv[1]?.includes("sandforge-sync")&&(wr(),ss().then(()=>process.exit(process.exitCode??0)).catch(t=>{process.stderr.write(`${t instanceof Error?t.message:String(t)}
|
|
341
|
+
`),process.exit(1)}));export{Co as a,Fo as b,Po as c,No as d,oo as e,Mo as f,_o as g,to as h,Lo as i,vt as j,Do as k,Uo as l,Wo as m,no as n,$t as o,io as p,ao as q,co as r,qo as s,zo as t,Ko as u,Vo as v,uo as w,Xo as x,Zo as y,Qo as z,es as A,ts as B,ns as C,At as D,ss as E,as as F,cs as G,us as H,ls as I,fs as J,hs as K,ps as L,gs as M,ms as N,ys as O,Rs as P,vs as Q,$s as R};
|
|
@@ -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{Hb as h,Kb as D,Lb as R,dd as O}from"./chunk-
|
|
7
|
+
import{Hb as h,Kb as D,Lb as R,dd as O}from"./chunk-PMWAFDUB.mjs";function P(t,f){return t.previousOrganizationId??(t.organizationId===void 0?f?.(t.orgId):void 0)??t.detectedAt}function x(t){let f=(i,s)=>{let o=R.safeParse(t.configStore.get(D(i,P(s,t.organizationIdOf))));return o.success&&o.data.finishedAt!==void 0};return{progressOf(i){let s=t.orgOf(i);if(s?.orgType!=="Sandbox")return;let[o]=t.refreshesOf(i);if(!(o===void 0||f(i,o)))return{orgId:i,alias:O(s,s.username),detectedAt:o.detectedAt,done:0,total:h}}}}var b=3e4;function A(t){let f=x(t),i=t.ttlMs??b,s=t.now??(()=>Date.now()),o=new Map,g=new Map,a=new Map,u=new Set,l=new Set,p=()=>{for(let e of[...l])try{e()}catch(r){t.log?.(`[recovery] a listener of the progress failed: ${String(r)}`)}},v=(e,r)=>{if(u.has(e))return;let n=g.get(e);if(n!==void 0&&s()-n<i)return;let c=a.get(e)??0;u.add(e),t.statusOf(e).then(d=>{if(u.delete(e),g.delete(e),(a.get(e)??0)!==c){v(e,r);return}let S=o.get(e),m=S!==void 0&&S.detectedAt===r.detectedAt?S:r;if(d===void 0){o.delete(e);return}o.set(e,{...d,detectedAt:r.detectedAt,at:s()}),(m.done!==d.done||m.total!==d.total)&&p()},d=>{u.delete(e),g.set(e,s()),t.log?.(`[recovery] the steps of ${e} could not be deduced: ${d instanceof Error?d.message:String(d)}`)})};return{progressOf(e){let r=f.progressOf(e);if(r===void 0)return;let n=o.get(e),c=n!==void 0&&n.detectedAt===r.detectedAt;return(!c||s()-n.at>=i)&&v(e,r),c?{...r,done:n.done,total:n.total}:r},onDidChange(e){return l.add(e),{dispose:()=>l.delete(e)}},invalidate(e){let r=e!==void 0?[e]:[...o.keys()];for(let n of r){a.set(n,(a.get(n)??0)+1),g.delete(n);let c=o.get(n);c!==void 0&&o.set(n,{...c,at:Number.NEGATIVE_INFINITY})}p()}}}export{P as a,A as b};
|
|
@@ -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
|
+
var u=class{config;constructor(e){this.config={maxRetries:e?.maxRetries??3,initialDelay:e?.initialDelay??1e3,maxDelay:e?.maxDelay??3e4,backoffMultiplier:e?.backoffMultiplier??2,jitter:e?.jitter??!0}}calculateDelay(e){let r=this.config.initialDelay*Math.pow(this.config.backoffMultiplier,e),o=Math.min(r,this.config.maxDelay);if(!this.config.jitter)return o;let n=o/2;return Math.floor(n+Math.random()*n)}async execute(e){let r,o=0;for(let n=0;n<=this.config.maxRetries;n++)try{return{success:!0,result:await e(),attempts:n+1,totalDelay:o}}catch(a){if(r=a instanceof Error?a:new Error(String(a)),n<this.config.maxRetries){let l=this.calculateDelay(n);o+=l,await new Promise(i=>setTimeout(i,l))}}return{success:!1,error:r,attempts:this.config.maxRetries+1,totalDelay:o}}shouldRetry(e){return e<this.config.maxRetries}getConfig(){return{...this.config}}};var b="UNABLE_TO_LOCK_ROW",c=3,p=2e3,h=200,k=`Rows the target refuses for a record lock go again on their own, up to ${c} times each: up to ${c} more requests for every ${h} of them, which no estimate made before the write can count.`,x=`rows the target refuses for a record lock go again, up to ${c} times each: up to ${c} more requests for every ${h} of them, not counted above`,y="CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY",R=/\bfirst error: UNABLE_TO_LOCK_ROW\b/,E=/^([A-Z][A-Z0-9_]*):\s*([\s\S]*)$/;function g(t,e){return t===b||t===y&&R.test(e)}function A(t,e){return e&&e.length>0?e.every(r=>g(r.statusCode,r.message)):t.length>0&&t.every(r=>{let o=E.exec(r.trim());return o!==null&&g(o[1],o[2])})}var _=new u({initialDelay:p});function O(t){return _.calculateDelay(t)}function S(t,e){return new Promise(r=>{if(e?.aborted){r();return}let o=()=>{clearTimeout(n),e?.removeEventListener("abort",o),r()},n=setTimeout(o,t);e?.addEventListener("abort",o,{once:!0})})}function L(t){return`sent again ${t===1?"once":`${t} times`}, waiting longer each time: the target still could not lock a record the write needed`}function T(t,e){return`${t} \u2014 ${L(e)}`}async function C(t){let e=[...t.outcomes],r=new Map,o=e.flatMap((i,s)=>t.locked(i)?[s]:[]),n=o.length;for(let i=0;o.length>0&&i<c&&(await t.wait(O(i)),!t.stopped());i++){let s=o,f=await t.send(s);if(f.slice(0,s.length).forEach((m,d)=>{e[s[d]]=m,r.set(s[d],(r.get(s[d])??0)+1)}),f.length<s.length)break;o=s.filter(m=>t.locked(e[m]))}let a=0,l=0;for(let[i,s]of r)t.written(e[i])?a++:t.locked(e[i])&&(l++,e[i]=t.note(e[i],s));return{outcomes:e,refused:n,sentAgain:r.size,written:a,stillLocked:l,notSentAgain:n-r.size}}function $(t,e){if(e.refused===0)return;let r=e.sentAgain-e.written-e.stillLocked,o=[`${e.written} written`,...e.stillLocked>0?[`${e.stillLocked} still refused for the lock`]:[],...r>0?[`${r} refused for another reason`]:[],...e.notSentAgain>0?[`${e.notSentAgain} not sent again: the run was stopped`]:[]];return`${e.refused} ${t} refused because the target could not lock a record their write needed (${b}), sent again up to ${c} times, waiting longer each time: ${o.join(", ")}`}export{u as a,k as b,x as c,A as d,S as e,T as f,C as g,$ as h};
|
|
@@ -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-S42RBRH2.mjs";import{k as S}from"./chunk-PMWAFDUB.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};
|
|
@@ -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{xe as c}from"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";var y=[{type:"seed",label:"Seed Data",description:"Seed an org with a template saved on the Seed page or shipped with SandForge, never a production org; its records are taken back from Seed\u2019s History",category:"data",icon:"database",configSchema:{orgId:{type:"string"},templateId:{type:"string"}}},{type:"sync",label:"Sync Data",description:"Run a Sync configuration saved on the Sync page; a target Production Guard asks about, a production org or a sandbox marked Staging, needs an Approval step before it",category:"data",icon:"sync",configSchema:{configId:{type:"string"}}},{type:"backup",label:"Backup",description:"Take a DataOps snapshot of the listed objects into local storage",category:"data",icon:"archive",configSchema:{orgId:{type:"string"},objects:{type:"array"}}},{type:"restore",label:"Restore",description:"Restore data from a previous backup snapshot",category:"data",icon:"history",configSchema:{backupId:{type:"string"}}},{type:"anonymize",label:"Anonymize",description:"Mask an org with a DataOps template, after a snapshot of the values it writes over, never a production org",category:"data",icon:"shield",configSchema:{orgId:{type:"string"},templateId:{type:"string"},object:{type:"string",optional:!0},where:{type:"string",optional:!0},acceptAutomation:{type:"boolean",default:!1},acceptEmails:{type:"boolean",default:!1},muteAutomation:{type:"boolean",default:!1}}},{type:"delete",label:"Delete",description:"Delete records matching specified criteria",category:"data",icon:"trash",configSchema:{objectName:{type:"string"},where:{type:"string"}}},{type:"checkpoint",label:"Checkpoint",description:"Take a checkpoint of a sandbox, a scratch org or a Developer Edition org, kept on this machine",category:"data",icon:"bookmark",configSchema:{orgId:{type:"string"},mode:{type:"string",default:"everything"},objects:{type:"array",optional:!0},excluded:{type:"array",optional:!0},name:{type:"string",optional:!0},keepDays:{type:"number",default:c},maxTotal:{type:"number",optional:!0},ignoredFields:{type:"array",optional:!0}}},{type:"rewind",label:"Rewind",description:"Put an org back to a checkpoint kept on this machine, once confirmed by typing the org\u2019s alias, at most maxRecords records",category:"data",icon:"history",configSchema:{orgId:{type:"string"},checkpointId:{type:"string"},objects:{type:"array",optional:!0},acceptAutomation:{type:"boolean",default:!1},acceptEmails:{type:"boolean",default:!1},muteAutomation:{type:"boolean",default:!1},acceptNoUndo:{type:"boolean",default:!1},acceptRecreate:{type:"boolean",default:!1},acceptOutside:{type:"boolean",default:!1},acceptUnseen:{type:"boolean",default:!1},maxRecords:{type:"number",required:!0},refuseWhenActive:{type:"boolean",default:!0}}},{type:"compare",label:"Compare Orgs",description:"Compare the metadata of two orgs, as the Compare page does",category:"quality",icon:"git-compare",configSchema:{sourceOrgId:{type:"string"},targetOrgId:{type:"string"},types:{type:"array"}}},{type:"precheck",label:"Pre-check",description:"Read an org\u2019s API usage, storage, error logs or failed jobs as the Monitor does; the run stops on a critical reading",category:"quality",icon:"check-circle",configSchema:{orgId:{type:"string"},checks:{type:"array"}}},{type:"condition",label:"Condition",description:"Branch pipeline execution based on conditions",category:"control",icon:"git-branch",configSchema:{field:{type:"string"},operator:{type:"string"},value:{type:"string"}}},{type:"delay",label:"Delay",description:"Wait for a specified duration before continuing",category:"control",icon:"clock",configSchema:{durationMs:{type:"number"}}},{type:"approval",label:"Approval",description:"Pauses the run until someone approves it in VS Code; a rejection, or no answer in time, stops it",category:"control",icon:"user-check",configSchema:{message:{type:"string"},timeoutMinutes:{type:"number"}}},{type:"notification",label:"Notification",description:"Shows its message as a VS Code notification",category:"notification",icon:"bell",configSchema:{message:{type:"string"}}}],p=class{registry;constructor(){this.registry=new Map(y.map(e=>[e.type,e]))}getStepTypes(){return[...this.registry.values()]}getStepType(e){return this.registry.get(e)}getDefaultConfig(e){let r=this.registry.get(e);if(!r)return{};let o={};for(let[t,a]of Object.entries(r.configSchema)){let n=a;if(!(n.optional===!0||n.required===!0)){if("default"in n){o[t]=n.default;continue}switch(n.type){case"string":o[t]="";break;case"number":o[t]=0;break;case"array":o[t]=[];break;case"boolean":o[t]=!1;break;default:o[t]=null}}}return o}validateStepConfig(e,r){let o=this.registry.get(e);if(!o)return[`Unknown step type: ${e}`];let t=[];for(let[a,n]of Object.entries(o.configSchema)){let l=n,i=r[a],s=l.type;i!=null&&(s==="array"&&!Array.isArray(i)?t.push(`Field "${a}" must be an array`):s==="string"&&typeof i!="string"?t.push(`Field "${a}" must be a string`):s==="number"&&typeof i!="number"?t.push(`Field "${a}" must be a number`):s==="boolean"&&typeof i!="boolean"&&t.push(`Field "${a}" must be a boolean`))}return t}getStepCategories(){let e=new Set;for(let r of this.registry.values())e.add(r.category);return[...e]}};export{p as StepLibrary};
|