sandforge 1.81.0 → 1.82.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/README.md +48 -0
  2. package/bin/sandforge-users.mjs +12 -0
  3. package/lib/{chunk-C4YGSK6W.mjs → chunk-27Z76O2O.mjs} +1 -1
  4. package/lib/{chunk-TKQQVB2D.mjs → chunk-2JZGCCPG.mjs} +1 -1
  5. package/lib/{chunk-TPHXRHOA.mjs → chunk-2UU42PTD.mjs} +1 -1
  6. package/lib/{chunk-ZWZXQTAK.mjs → chunk-32EUNQT6.mjs} +14 -14
  7. package/lib/{chunk-HYOOJVR6.mjs → chunk-3C2ZZIFN.mjs} +1 -1
  8. package/lib/{chunk-AELFEK3G.mjs → chunk-3CX7GPCR.mjs} +1 -1
  9. package/lib/{chunk-YJEXE6HZ.mjs → chunk-3HEMJTAP.mjs} +2 -2
  10. package/lib/{chunk-DQR5NDMI.mjs → chunk-3HROD5RE.mjs} +1 -1
  11. package/lib/{chunk-D7P7DTWL.mjs → chunk-3MGMNK3Q.mjs} +1 -1
  12. package/lib/{chunk-MNITSYI2.mjs → chunk-3SKLBRPL.mjs} +1 -1
  13. package/lib/{chunk-MAHZMPMZ.mjs → chunk-3XG25GTF.mjs} +1 -1
  14. package/lib/{chunk-N7J6NJQ6.mjs → chunk-42BFLWHR.mjs} +1 -1
  15. package/lib/chunk-466F37VD.mjs +7 -0
  16. package/lib/chunk-47UHTN3Q.mjs +7 -0
  17. package/lib/{chunk-DHGPDSXS.mjs → chunk-52EXDVPN.mjs} +1 -1
  18. package/lib/{chunk-5344TZBT.mjs → chunk-5K2I2DMP.mjs} +1 -1
  19. package/lib/{chunk-2OZG6GRW.mjs → chunk-6GQUZ4IP.mjs} +1 -1
  20. package/lib/{chunk-SW2NUKQL.mjs → chunk-6KP6WETK.mjs} +1 -1
  21. package/lib/{chunk-FSZTXLNW.mjs → chunk-6VSZNZHH.mjs} +1 -1
  22. package/lib/{chunk-6NADW3OI.mjs → chunk-7CVDVBEE.mjs} +1 -1
  23. package/lib/{chunk-67CC7RAE.mjs → chunk-7EYQYZJP.mjs} +1 -1
  24. package/lib/{chunk-IBURU7T7.mjs → chunk-7LKI7OAS.mjs} +1 -1
  25. package/lib/{chunk-CULAOP3U.mjs → chunk-7PY3VQP3.mjs} +1 -1
  26. package/lib/chunk-7SDZR6SR.mjs +7 -0
  27. package/lib/{chunk-V4RKM4QZ.mjs → chunk-7WSLT5VX.mjs} +1 -1
  28. package/lib/chunk-A32ISQ6M.mjs +28 -0
  29. package/lib/{chunk-K77NR3UK.mjs → chunk-A65ADTCR.mjs} +1 -1
  30. package/lib/chunk-A7JJWOLT.mjs +7 -0
  31. package/lib/{chunk-MWLFFVQV.mjs → chunk-AUS6NFLZ.mjs} +1 -1
  32. package/lib/{chunk-NWPQF5XR.mjs → chunk-BMTNTBBM.mjs} +1 -1
  33. package/lib/{chunk-FTA5LOVX.mjs → chunk-BN33LVPQ.mjs} +1 -1
  34. package/lib/chunk-BNKT3R3F.mjs +7 -0
  35. package/lib/{chunk-WM5JI4JI.mjs → chunk-C2N2TNEU.mjs} +1 -1
  36. package/lib/{chunk-5UT2ZBGF.mjs → chunk-C3LNYAVJ.mjs} +1 -1
  37. package/lib/{chunk-GYKNCYES.mjs → chunk-CBL42DUU.mjs} +1 -1
  38. package/lib/{chunk-W2AAGIZF.mjs → chunk-CCEH7L53.mjs} +1 -1
  39. package/lib/{chunk-WWTXRWNZ.mjs → chunk-CELEBWEZ.mjs} +1 -1
  40. package/lib/{chunk-D62KWDDT.mjs → chunk-CV47FDQW.mjs} +1 -1
  41. package/lib/{chunk-AJPSGVMD.mjs → chunk-CZLJZQCS.mjs} +1 -1
  42. package/lib/{chunk-YIGFYZQY.mjs → chunk-DBBPDSFN.mjs} +1 -1
  43. package/lib/{chunk-T5VAULLQ.mjs → chunk-DIL62SUN.mjs} +1 -1
  44. package/lib/chunk-DIS254AN.mjs +7 -0
  45. package/lib/{chunk-GK7VEYFM.mjs → chunk-DJCGURW7.mjs} +1 -1
  46. package/lib/{chunk-MHW6DV6T.mjs → chunk-DT3T7FRD.mjs} +1 -1
  47. package/lib/{chunk-PYUEHBA6.mjs → chunk-DWMRIWV5.mjs} +1 -1
  48. package/lib/{chunk-E2OBAWSH.mjs → chunk-EEFUE2ES.mjs} +1 -1
  49. package/lib/{chunk-MKNAZPOT.mjs → chunk-EOFO3PHS.mjs} +1 -1
  50. package/lib/{chunk-UUSLTW5V.mjs → chunk-FA4ZKDCU.mjs} +1 -1
  51. package/lib/{chunk-DHIW4IO5.mjs → chunk-FKK5YBGZ.mjs} +1 -1
  52. package/lib/{chunk-BZFIOZS3.mjs → chunk-FOIWWK7G.mjs} +1 -1
  53. package/lib/chunk-FZF23M6R.mjs +7 -0
  54. package/lib/{chunk-XIZ5LMQM.mjs → chunk-G2JR3F63.mjs} +1 -1
  55. package/lib/{chunk-2Z54GB6X.mjs → chunk-GBGHJTPC.mjs} +1 -1
  56. package/lib/{chunk-2NAIUKVL.mjs → chunk-GCGHHN4K.mjs} +1 -1
  57. package/lib/{chunk-TQM2XJ27.mjs → chunk-GGNUACTY.mjs} +1 -1
  58. package/lib/{chunk-2IB7I3IQ.mjs → chunk-GGUOIDWP.mjs} +1 -1
  59. package/lib/chunk-GHPR5UVV.mjs +7 -0
  60. package/lib/{chunk-YHIOS2PU.mjs → chunk-GJ6SZVHT.mjs} +1 -1
  61. package/lib/{chunk-WI4HYWV6.mjs → chunk-H4JUYUSL.mjs} +1 -1
  62. package/lib/{chunk-5WGA5CZB.mjs → chunk-H4OBZIX3.mjs} +1 -1
  63. package/lib/{chunk-KRNFVAGC.mjs → chunk-HFUDCNU5.mjs} +1 -1
  64. package/lib/{chunk-OIIL4NVI.mjs → chunk-HIHCYMSL.mjs} +1 -1
  65. package/lib/chunk-HKUWHVI7.mjs +9 -0
  66. package/lib/chunk-HQQVANWQ.mjs +20 -0
  67. package/lib/{chunk-V2QO6KOE.mjs → chunk-IRZJU2PG.mjs} +14 -11
  68. package/lib/{chunk-CAFUNR6D.mjs → chunk-ISSP2FZ5.mjs} +1 -1
  69. package/lib/{chunk-OEHVAJAB.mjs → chunk-IVZJSDJD.mjs} +1 -1
  70. package/lib/{chunk-E2YJVSX6.mjs → chunk-J24TIGSI.mjs} +1 -1
  71. package/lib/{chunk-YCSFP6ER.mjs → chunk-JESRFE2Z.mjs} +1 -1
  72. package/lib/{chunk-KOQV4WXC.mjs → chunk-JFNLKHY6.mjs} +2 -2
  73. package/lib/{chunk-NJ3EOEHS.mjs → chunk-JH27IKCO.mjs} +1 -1
  74. package/lib/{chunk-DXOXLUZA.mjs → chunk-JJITOWZK.mjs} +1 -1
  75. package/lib/{chunk-KNIRA333.mjs → chunk-JKT5YAQ2.mjs} +1 -1
  76. package/lib/{chunk-J6G23RUI.mjs → chunk-JLZRZL5E.mjs} +1 -1
  77. package/lib/{chunk-6FMLW7PH.mjs → chunk-JPEVIXNH.mjs} +1 -1
  78. package/lib/{chunk-6IGEASOF.mjs → chunk-JQZTMFO7.mjs} +1 -1
  79. package/lib/{chunk-55LQD3Y3.mjs → chunk-KIMQQ6JQ.mjs} +1 -1
  80. package/lib/{chunk-EH5YUA5W.mjs → chunk-KJYEQHYP.mjs} +1 -1
  81. package/lib/chunk-KKOA62S4.mjs +474 -0
  82. package/lib/{chunk-56MPPWLA.mjs → chunk-KP5G6FUC.mjs} +1 -1
  83. package/lib/{chunk-EAFLDSQ2.mjs → chunk-L4INJ5TZ.mjs} +1 -1
  84. package/lib/{chunk-MO3N5XVV.mjs → chunk-LAUOSXMN.mjs} +2 -2
  85. package/lib/{chunk-HVC5CYIB.mjs → chunk-LHU6CPGE.mjs} +1 -1
  86. package/lib/{chunk-7PK5QDQI.mjs → chunk-LXDSRP2W.mjs} +1 -1
  87. package/lib/{chunk-YOGMP72T.mjs → chunk-MKTXJCXN.mjs} +1 -1
  88. package/lib/{chunk-VSU74RQ3.mjs → chunk-MUEQRIK7.mjs} +1 -1
  89. package/lib/{chunk-UCHAZ4ZU.mjs → chunk-NLB3RGIY.mjs} +1 -1
  90. package/lib/{chunk-OVOLG3AL.mjs → chunk-NWOI25WY.mjs} +1 -1
  91. package/lib/{chunk-6SEDOIO3.mjs → chunk-O2PUGRNW.mjs} +1 -1
  92. package/lib/chunk-O4BROUGM.mjs +7 -0
  93. package/lib/{chunk-KGYXLSQ5.mjs → chunk-P55MKIZX.mjs} +1 -1
  94. package/lib/{chunk-KE2PGD6C.mjs → chunk-P63WJMXQ.mjs} +1 -1
  95. package/lib/chunk-PBE44M2Y.mjs +7 -0
  96. package/lib/{chunk-OMZJ37JI.mjs → chunk-PE435FVH.mjs} +2 -2
  97. package/lib/{chunk-GR3NGDVM.mjs → chunk-PPHVWUFY.mjs} +1 -1
  98. package/lib/{chunk-ZUA5BNAO.mjs → chunk-PR74GYVI.mjs} +1 -1
  99. package/lib/{chunk-43K2C6H2.mjs → chunk-PWVDNN2C.mjs} +1 -1
  100. package/lib/{chunk-DMBR24CK.mjs → chunk-PYRZFUVU.mjs} +1 -1
  101. package/lib/{chunk-OXKZ4Y3B.mjs → chunk-Q3DY7TO2.mjs} +1 -1
  102. package/lib/{chunk-EOSEMFPU.mjs → chunk-Q6SXNKV2.mjs} +1 -1
  103. package/lib/chunk-QAPVKPEC.mjs +7 -0
  104. package/lib/chunk-QROPNEGY.mjs +14 -0
  105. package/lib/{chunk-6CDIIFNX.mjs → chunk-RCYEBY42.mjs} +1 -1
  106. package/lib/chunk-RLWB7F26.mjs +7 -0
  107. package/lib/{chunk-X2ZVSQ54.mjs → chunk-RTWYLOCA.mjs} +1 -1
  108. package/lib/chunk-RYRMUPMY.mjs +7 -0
  109. package/lib/{chunk-ETT5GP4P.mjs → chunk-SAMWHL22.mjs} +1 -1
  110. package/lib/{chunk-LO527YLT.mjs → chunk-SFGZFB4F.mjs} +1 -1
  111. package/lib/{chunk-33ZX3A56.mjs → chunk-SNEOKYV7.mjs} +1 -1
  112. package/lib/{chunk-GTIXJCGS.mjs → chunk-STRMWSIQ.mjs} +1 -1
  113. package/lib/{chunk-OQQHNYR7.mjs → chunk-SZGGFST2.mjs} +2 -2
  114. package/lib/{chunk-OU5W7SCB.mjs → chunk-T7WREYA5.mjs} +1 -1
  115. package/lib/{chunk-FLNLG43R.mjs → chunk-TCBAE65A.mjs} +1 -1
  116. package/lib/{chunk-RKALOKAU.mjs → chunk-TMA34QMA.mjs} +1 -1
  117. package/lib/{chunk-WEZLXE34.mjs → chunk-TWV4A5RK.mjs} +1 -1
  118. package/lib/{chunk-ONMBSACW.mjs → chunk-UHFLKP26.mjs} +1 -1
  119. package/lib/chunk-UV74P4H2.mjs +7 -0
  120. package/lib/{chunk-HYBH5PFM.mjs → chunk-V3R45ZWT.mjs} +1 -1
  121. package/lib/{chunk-BNO5GIJ6.mjs → chunk-VPDEJGPS.mjs} +1 -1
  122. package/lib/{chunk-3AOKLIVE.mjs → chunk-VQJMP3DC.mjs} +1 -1
  123. package/lib/{chunk-742SSN7I.mjs → chunk-VYOYXTCU.mjs} +1 -1
  124. package/lib/{chunk-GWRKS3AL.mjs → chunk-VZT4E2OJ.mjs} +1 -1
  125. package/lib/{chunk-2OIRJEYE.mjs → chunk-VZVICK7Q.mjs} +1 -1
  126. package/lib/chunk-WEMLDUQA.mjs +7 -0
  127. package/lib/{chunk-FDGFUEK3.mjs → chunk-WOOUISSO.mjs} +1 -1
  128. package/lib/{chunk-UIUPPEFB.mjs → chunk-WSUKC2U3.mjs} +1 -1
  129. package/lib/{chunk-XC2QKQT5.mjs → chunk-WT3SCUHS.mjs} +1 -1
  130. package/lib/{chunk-UT27HXE7.mjs → chunk-XFU3HRUV.mjs} +1 -1
  131. package/lib/{chunk-5VQNKDFU.mjs → chunk-XK5W7BVE.mjs} +1 -1
  132. package/lib/{chunk-OZNLOV4U.mjs → chunk-XO5FBOQF.mjs} +1 -1
  133. package/lib/{chunk-FSDO4DJA.mjs → chunk-XSKPYGMT.mjs} +1 -1
  134. package/lib/{chunk-AITNZWLB.mjs → chunk-XU25YA46.mjs} +1 -1
  135. package/lib/{chunk-XEB6HZ34.mjs → chunk-XZISAZA6.mjs} +1 -1
  136. package/lib/chunk-Y4TDVDP2.mjs +13 -0
  137. package/lib/{chunk-4L7FBOJS.mjs → chunk-YAIIRFKJ.mjs} +1 -1
  138. package/lib/{chunk-T3PLRQ2T.mjs → chunk-YAJQS3OL.mjs} +1 -1
  139. package/lib/{chunk-Y5ZCPY36.mjs → chunk-YGJF55VJ.mjs} +1 -1
  140. package/lib/chunk-YH4DYI6D.mjs +7 -0
  141. package/lib/{chunk-R6TF26V4.mjs → chunk-YMDFF657.mjs} +1 -1
  142. package/lib/{chunk-JU2XEKEO.mjs → chunk-YT22LMF7.mjs} +1 -1
  143. package/lib/{chunk-NWVVCZUK.mjs → chunk-Z42PHCVZ.mjs} +1 -1
  144. package/lib/{chunk-O6ADMP36.mjs → chunk-ZHIZY3ZC.mjs} +1 -1
  145. package/lib/chunk-ZQO5PDX5.mjs +48 -0
  146. package/lib/{chunk-QXLZINZB.mjs → chunk-ZUBBEP75.mjs} +1 -1
  147. package/lib/{chunk-SQGP46QS.mjs → chunk-ZUOPC4W2.mjs} +1 -1
  148. package/lib/{chunk-3B5H24ZG.mjs → chunk-ZUTUYBNW.mjs} +1 -1
  149. package/lib/{chunk-K55LH4ZQ.mjs → chunk-ZXFL2MSN.mjs} +1 -1
  150. package/lib/sandforge-autopilot.mjs +1 -1
  151. package/lib/sandforge-backup.mjs +1 -1
  152. package/lib/sandforge-checkpoint.mjs +1 -1
  153. package/lib/sandforge-cleanup.mjs +1 -1
  154. package/lib/sandforge-clone.mjs +1 -1
  155. package/lib/sandforge-compare.mjs +1 -1
  156. package/lib/sandforge-dataops.mjs +1 -1
  157. package/lib/sandforge-empty.mjs +1 -1
  158. package/lib/sandforge-env.mjs +185 -139
  159. package/lib/sandforge-frozen.mjs +1 -1
  160. package/lib/sandforge-mcp.mjs +14 -14
  161. package/lib/sandforge-monitor.mjs +1 -1
  162. package/lib/sandforge-pipeline.mjs +1 -1
  163. package/lib/sandforge-seed.mjs +1 -1
  164. package/lib/sandforge-sync.mjs +1 -1
  165. package/lib/sandforge-users.mjs +157 -0
  166. package/lib/sandforge.mjs +1 -22
  167. package/lib/sf/sandforge/autopilot.mjs +20 -0
  168. package/lib/sf/sandforge/backup.mjs +20 -0
  169. package/lib/sf/sandforge/checkpoint.mjs +20 -0
  170. package/lib/sf/sandforge/cleanup.mjs +20 -0
  171. package/lib/sf/sandforge/clone.mjs +20 -0
  172. package/lib/sf/sandforge/compare.mjs +20 -0
  173. package/lib/sf/sandforge/dataops.mjs +20 -0
  174. package/lib/sf/sandforge/empty.mjs +20 -0
  175. package/lib/sf/sandforge/env.mjs +20 -0
  176. package/lib/sf/sandforge/frozen.mjs +20 -0
  177. package/lib/sf/sandforge/hardis-commands.mjs +20 -0
  178. package/lib/sf/sandforge/index.mjs +20 -0
  179. package/lib/sf/sandforge/mcp.mjs +20 -0
  180. package/lib/sf/sandforge/monitor.mjs +20 -0
  181. package/lib/sf/sandforge/pipeline.mjs +20 -0
  182. package/lib/sf/sandforge/seed.mjs +20 -0
  183. package/lib/sf/sandforge/sync.mjs +20 -0
  184. package/lib/sf/sandforge/users.mjs +20 -0
  185. package/lib/sfHelpHook.mjs +7 -0
  186. package/lib/sfPlugin.mjs +11 -0
  187. package/oclif.manifest.json +1 -0
  188. package/package.json +17 -3
  189. package/lib/chunk-2ZMGVBLW.mjs +0 -7
  190. package/lib/chunk-5C5XEVZN.mjs +0 -11
  191. package/lib/chunk-5CKWGZX4.mjs +0 -9
  192. package/lib/chunk-5ZKCLBTN.mjs +0 -474
  193. package/lib/chunk-7DALDJMO.mjs +0 -7
  194. package/lib/chunk-DPYTG6DM.mjs +0 -48
  195. package/lib/chunk-G4VXPS3A.mjs +0 -7
  196. package/lib/chunk-GF247DA7.mjs +0 -7
  197. package/lib/chunk-IKGHRYCN.mjs +0 -7
  198. package/lib/chunk-IM2XA6JI.mjs +0 -7
  199. package/lib/chunk-K5HV4YRO.mjs +0 -7
  200. package/lib/chunk-N6HHNR6J.mjs +0 -7
  201. package/lib/chunk-O7DAFE6M.mjs +0 -14
  202. package/lib/chunk-R2BJWO5N.mjs +0 -20
  203. package/lib/chunk-T26C576X.mjs +0 -9
  204. package/lib/chunk-V473C7LY.mjs +0 -7
  205. package/lib/chunk-WD47PGUS.mjs +0 -10
  206. package/lib/chunk-XC54KKKC.mjs +0 -7
  207. package/lib/chunk-XGKSSCW7.mjs +0 -7
  208. package/lib/chunk-ZWCRWF7E.mjs +0 -7
@@ -1,474 +0,0 @@
1
- import { createRequire as __sandforgeRequire } from 'node:module';
2
- import { fileURLToPath as __sandforgePath } from 'node:url';
3
- import { dirname as __sandforgeDirname } from 'node:path';
4
- const require = __sandforgeRequire(import.meta.url);
5
- const __filename = __sandforgePath(import.meta.url);
6
- const __dirname = __sandforgeDirname(__filename);
7
- import{b as Lt}from"./chunk-OIIL4NVI.mjs";import{b as Nt,n as xt}from"./chunk-YCSFP6ER.mjs";import{a as Ot,b as se,c as St,d as ae,f as Et,i as It,k as Se}from"./chunk-GYKNCYES.mjs";import{f as Ct}from"./chunk-YOGMP72T.mjs";import{a as Ce,b as G,c as yt,f as bt}from"./chunk-MWLFFVQV.mjs";import{y as zt}from"./chunk-OQQHNYR7.mjs";import{q as Mt}from"./chunk-R2BJWO5N.mjs";import{u as Bt,v as ke}from"./chunk-V2QO6KOE.mjs";import{f as Tt,g as Ie,h as Ft,i as _t}from"./chunk-5CKWGZX4.mjs";import{e as Y,i as Pt,k as Ee,l as Dt}from"./chunk-5344TZBT.mjs";import{a as Ut}from"./chunk-TW3N6W5Z.mjs";import{d as ee,f as vt,xb as Rt,yb as jt}from"./chunk-YJEXE6HZ.mjs";import{l as $t,m as Oe,n as we}from"./chunk-O7DAFE6M.mjs";import{b as pe,e as st}from"./chunk-BZ24IAP5.mjs";import{a as U}from"./chunk-SCKUIE3R.mjs";import{c as re}from"./chunk-6FARZYMJ.mjs";import{$a as dt,hb as ht}from"./chunk-CAFUNR6D.mjs";import{a as ft,n as pt,o as mt}from"./chunk-GWRKS3AL.mjs";import{C as lt}from"./chunk-ZWCRWF7E.mjs";import{I as kt,L as ge,e as H,i as je,k as gt,z as wt}from"./chunk-E2YJVSX6.mjs";import{a as rt}from"./chunk-HVC5CYIB.mjs";import{B as me,r as ot,v as ut}from"./chunk-T26C576X.mjs";import{mc as Q}from"./chunk-KOQV4WXC.mjs";import{b as it,f as q,h as At}from"./chunk-LCDPCUXS.mjs";import{da as at}from"./chunk-55LQD3Y3.mjs";import{k as ct}from"./chunk-EAFLDSQ2.mjs";import{A as Ae,Hc as tt,Ra as fe,Va as Qe,cb as et,wd as Re,zd as nt}from"./chunk-DPYTG6DM.mjs";import{mkdtempSync as Eo,readFileSync as Io,rmSync as No}from"node:fs";import{tmpdir as xo}from"node:os";import{join as sn,resolve as _e}from"node:path";import{existsSync as qn,readFileSync as Hn}from"node:fs";import{hostname as Gn}from"node:os";import{join as qt,resolve as Ne}from"node:path";var Yn=["--custom-settings","--mask","--keep-contact-points","--no-real-data"],Kn=["--objects","--exclude-object","--owners","--owner-map","--link","--replay-config"],Jn=["--again","--accept-emails","--max-records",...ee.switches,...ee.values],Vn=["--preview","--sweep","--sweep-list",...Rt,"--include-changed"],Zn=/^[A-Za-z][A-Za-z0-9_]{0,79}$/,ce=/^00D[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/,Ht=e=>fe.safeParse(e).success,Xn={ownerMap:"--owner-map",objects:"--objects",excluded:"--exclude-object",link:"--link"};function Gt(e,t){let n=w=>e.includes(w),o=w=>{let R=[];for(let L=1;L<e.length;L++){if(e[L]!==w)continue;let x=e[L+1];if(x===void 0||x.startsWith("--"))return t(`${w} wants a value.`);R.push(x),L++}return R},i=w=>{let R=o(w);return R.length>1&&t(`${w} is given ${R.length} times: give it once.`),R[0]},s=w=>{let R=i(w);if(R!==void 0)return/^\d{1,15}$/.test(R)||t(`${w} takes a whole number, not "${R}".`),Number(R)},c=["--dry-run","--verify","--remove"].filter(n);c.length>1&&t(`Give one of --dry-run, --verify and --remove, not ${c.join(" and ")}. Nothing was run.`);let r=n("--dry-run")?"dryRun":n("--verify")?"verify":n("--remove")?"remove":"replay",a=w=>w.filter(n);if(r==="verify"||r==="remove"){let w=a([...Yn,...Kn]);w.length>0&&t(`${w.join(", ")} ${w.length===1?"is a choice":"are choices"} of a replay and its dry run: --verify reads the choices its last replay was made with, and --remove takes back what it wrote. Nothing was run.`);let R=a(Jn);R.length>0&&t(`${R.join(", ")} goes with a replay or its dry run, not with --${r}. Nothing was run.`)}if(r!=="remove"){let w=a(Vn);w.length>0&&t(`${w.join(", ")} goes with --remove. Nothing was run.`)}n("--sweep")&&n("--sweep-list")&&t("--sweep deletes and --sweep-list only lists: give one of them. Nothing was run."),n("--preview")&&n("--sweep-list")&&t("--preview deletes nothing, and --sweep-list lists what a sweep would take: give --preview without it, or with --sweep. Nothing was run.");let u=jt(e);if("refusal"in u&&t(`${u.refusal} Nothing was run.`),r==="verify"){let w=a(["--mute-automation","--accept-automation"]);w.length>0&&t(`${w.join(", ")} goes with a replay or its removal: a verification only reads. Nothing was run.`)}let g=i("--checkpoint"),m=i("--file");if(g===void 0&&m===void 0)return t("replay needs --checkpoint <id|name> (list names them) or --file <.sfcheckpoint>. Run with --help.");g!==void 0&&m!==void 0&&t("Give --checkpoint or --file, not both. Nothing was run.");let y=i("--from");if(y!==void 0&&g===void 0&&t("--from goes with --checkpoint <name>: it names the org the checkpoint was taken of."),g!==void 0&&!Ht(g)&&y===void 0&&t(`--checkpoint '${g}' is not a checkpoint's id: a name names one of an org's checkpoints, so give --from <alias|username|00D\u2026>, the org it was taken of, or its id ("${U("checkpoint")} list" names them). Nothing was run.`),m===void 0){let w=a(["--key-env","--keep-days"]);w.length>0&&t(`${w.join(" and ")} goes with --file. Nothing was run.`)}let k=i("--target")??t("replay needs --target <alias>, the org the checkpoint's records go into. Run with --help."),d=o("--objects").flatMap(w=>w.split(",").map(R=>R.trim()).filter(R=>R!=="")),h=o("--exclude-object");for(let[w,R]of[["--objects",d],["--exclude-object",h]]){let L=R.find(x=>!Zn.test(x));L!==void 0&&t(`${w} takes objects' API names, not "${L}".`)}let b=w=>w.filter((R,L)=>w.findIndex(x=>x.toLowerCase()===R.toLowerCase())===L),$=i("--owners")??"same";$!=="same"&&$!=="me"&&t(`--owners takes same or me, not "${$}".`);let l=o("--link").map(w=>{let R=/^([A-Za-z][A-Za-z0-9_]*)=([A-Za-z0-9_,]+)$/.exec(w);return R?{objectApiName:R[1],fields:R[2].split(",").filter(L=>L!=="")}:t(`--link takes Object=Field or Object=Field,Field \u2014 the fields a record of the other org is found by \u2014, not "${w}".`)}),f=i("--owner-map"),C=f!==void 0?Kt("--owner-map",f,t):void 0,O={owners:$,...C!==void 0?{ownerMap:C}:{},customSettings:n("--custom-settings"),mask:n("--mask"),contactPoints:n("--keep-contact-points")?"kept":"neutralized",objects:b(d),excluded:b(h),link:l,...n("--no-real-data")?{noRealData:!0}:{}},S=et.safeParse(O);if(!S.success){let w=S.error.issues[0],R=String(w?.path[0]??"");return t(`${Xn[R]??R}: ${w?.message??"not read"}. Nothing was run.`)}let M=S.data,B=i("--replay-config"),D=B!==void 0?Qn(B,M,t):void 0,F=s("--max-records");F===0&&t('--max-records takes a whole number of 1 or more, not "0". Nothing was run.');let T=eo(i("--key-env"),t),Z=vt(e);return{action:r,...g!==void 0?{checkpoint:g}:{},...y!==void 0?{from:y}:{},...m!==void 0?{file:Ne(m)}:{},...T!==void 0?{keyEnv:T}:{},keepDays:s("--keep-days")??H,target:k,choices:M,...f!==void 0?{ownerMapFile:Ne(f)}:{},...D!==void 0?{config:D}:{},...B!==void 0?{configFile:Ne(B)}:{},again:n("--again"),muteAutomation:n("--mute-automation"),acceptAutomation:n("--accept-automation"),acceptEmails:n("--accept-emails"),...Z!==void 0?{checkpointFirst:Z}:{},...F!==void 0?{maxRecords:F}:{},preview:n("--preview"),sweep:n("--sweep"),sweepList:n("--sweep-list"),...u,includeChanged:n("--include-changed"),yes:n("--yes")}}function Yt(e,t){let n=e.flatMap((i,s)=>i==="--target"?[e[s+1]]:[]);n.length>1&&t(`--target is given ${n.length} times: give it once.`);let o=n[0];return o!==void 0?{target:o}:{}}function Kt(e,t,n){try{return JSON.parse(Hn(t,"utf8"))}catch(o){return n(`${e}: ${t} does not read as JSON (${o instanceof Error?o.message:String(o)}). Nothing was run.`)}}function Qn(e,t,n){let o=Kt("--replay-config",e,n),i=dt.safeParse({targetOrgId:"command-line",replay:{organizationId:"00D000000000000AAA",checkpointId:"ck-20000101-000000-0000",choices:t,config:o}});if(!i.success){let s=i.error.issues[0],c=(s?.path??[]).slice(2).join(".");return n(`--replay-config: ${c!==""?`${c}: `:""}${s?.message??"not read"}. It takes the load\u2019s part of a Frozen project\u2019s configuration: requiredFieldDefaults, requiredLookupPlaceholders, picklistRules, defaultPicklistRule, identityKeys, undeletableObjects, duplicateErrorPatterns, mockDetection, protectedOrgIds. Nothing was run.`)}return o}function eo(e,t){if(e!==void 0)return!/^[A-Za-z_][A-Za-z0-9_]{0,127}$/.test(e)||Y(e)!==void 0?t("--key-env takes the name of an environment variable that holds the key, never the key: a key on the command line stays in the shell\u2019s history and the list of processes. Nothing was run."):e}var to="cli-store.json";function De(e,t){return t?qt(e,".replays"):Tt()}var N=class extends Error{constructor(n,o=1){super(n.message);this.refusal=n;this.code=o;this.name="ReplayStop"}refusal;code};function Jt(e){try{return new Ie({root:e})}catch(t){throw new N({code:"STORE_REFUSED",message:`The replays cannot be kept in ${e}: ${t instanceof Error?t.message:String(t)} Name a store outside any repository with --store <folder>. Nothing was read or written.`})}}function Pe(e,t){let n=Ee(e);if(!qn(n))return;let o=ge({root:n,...t!==void 0?{locksDir:t}:{}});return"store"in o?o.store:void 0}function ye(e){return/^[\w./:@+-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function Vt(e,t){return`${U("checkpoint")} replay --file ${ye(e)} --target ${t}`}function X(e,t,n){return`${U("checkpoint")} replay --checkpoint ${e} --target ${t}`+(n!==void 0?` --store ${ye(n)}`:"")}var j=e=>e.toLocaleString("en-US");function te(e){let t=new Date(Date.parse(e)).toISOString();return`${t.slice(0,10)} ${t.slice(11,16)} UTC`}function xe(e,t=8){return e.length<=t?e.join(", "):`${e.slice(0,t).join(", ")} and ${j(e.length-t)} more`}function no(e){return{run:"replay",done:"replayed",source:e,recordedIn:"for this checkpoint on this machine",remove:"--remove",module:"replay",again:"again",againSubject:{purge:"replayAgain",sweep:"replayAgainSweep"},maybeMasks:"the checkpoint does not say whether its take read them unmasked, so they may hold the masks a user without View Encrypted Data reads, such as ****1234"}}var oo={fileContentNotKept:()=>"a checkpoint keeps no file's content",notInTarget:(e,t)=>`${t} has no such object: deploy it there, or leave it out (--exclude-object ${e})`,notCreateable:(e,t)=>`${t} lets no one create its records`,excluded:()=>"left out as asked"},io={objectNotReplayed:e=>`the checkpoint holds the records it names and does not replay them: add ${e.split(".")[0]}'s target with --objects`,objectNotHeld:(e,t)=>`the checkpoint does not hold what it names, and ${t} has no record of that Id`,userNotInTarget:(e,t)=>`${t} has no active standard user for it`},ro={requiredLookupMissing:"a required lookup names a record neither replayed nor in the other org",parentRefused:"a parent of theirs is refused, and no orphan is written",personAccountsUnsupported:"the other org has not turned person accounts on",inactiveCurrency:"their currency is not active in the other org",recordTypeUnavailable:"their record type is one the user who replays may not create"},so={byName:"found by its name",byId:"found by its Id",default:"the other org's default for the user who replays"};function ao(e){let{summary:t}=e,n=e.target.name,o=[],{records:i}=t;i.linkedById>0&&o.push(`${j(i.linkedById)} record(s) ${n} holds under the same Id \u2014 a sandbox copied from the same production \u2014: linked, not changed`),i.linkedByKey>0&&o.push(`${j(i.linkedByKey)} record(s) found in ${n} by the fields --link names: linked, not created`);let s=t.owners,c=[s.reasons.notInTarget>0?`their user is not in ${n}: ${j(s.reasons.notInTarget)}`:"",s.reasons.inactive>0?`their user is inactive in ${n}: ${j(s.reasons.inactive)}`:"",s.reasons.queueMissing>0?`their queue is not in ${n}: ${j(s.reasons.queueMissing)}`:""].filter(Boolean);o.push(`owners: ${j(s.kept)} kept, ${j(s.toRunningUser)} to the user who replays`+(c.length>0?` \u2014 ${c.join("; ")}`:""));for(let r of t.recordTypes)o.push(`record type ${r.object}.${r.recordType}: ${so[r.outcome]} \u2014 ${j(r.records)} record(s)`);for(let r of t.refused)o.push(`refused before anything is written: ${r.object} ${j(r.records)} \u2014 ${ro[r.reason]}${r.path?`: ${r.path}`:""}`);for(let r of t.notReplayed)o.push(`not replayed: ${r.object} ${j(r.records)} \u2014 `+oo[r.reason](r.object,n));e.filesLeft.length>0&&o.push(`${j(e.filesLeft.length)} file(s) left where they were, a checkpoint keeping no file's content:`,...e.filesLeft.map(r=>` ${r.objectApiName}${r.name!==void 0?` '${r.name}'`:""}`));for(let r of t.lookupsEmptied)o.push(`${r.field}: emptied on ${j(r.records)} record(s) \u2014 `+io[r.reason](r.field,n));for(let r of t.fieldsNotInTarget)o.push(`${r.object}: ${xe(r.fields)} left out \u2014 ${n} does not have them`);t.customSettings&&o.push(`custom settings: ${j(t.customSettings.inserted)} row(s) set up, ${j(t.customSettings.alreadyThere)} already in ${n}, kept as they are`);for(let r of t.currencies.refused)o.push(`${r.code}: ${j(r.records)} record(s) refused \u2014 the currency is not active in ${n}: activate it there, or leave those records out`);if(t.currencies.singleCurrencyTarget&&o.push(`${n} has one currency: amounts are kept as they are, in its currency`),t.standardPricebook==="deduced"?o.push("standard price book: told from the price book entries, the checkpoint naming none"):t.standardPricebook==="ambiguous"&&o.push("standard price book: the price book entries do not tell which it was, and those that need it are refused"),t.masked.fields.length>0&&o.push(`masked: ${xe(t.masked.fields)}`),(t.masked.unmaskedFreeText??[]).length>0&&o.push(`not masked, free text the masking does not read: ${xe(t.masked.unmaskedFreeText??[])}`),o.push(t.contactPoints==="neutralized"?"emails and phone numbers made unreachable (.invalid, numbers that ring nobody); --keep-contact-points keeps them":"emails and phone numbers kept as they are: they reach the people they name"),(t.archivedActivities??0)>0&&o.push(`${j(t.archivedActivities??0)} archived task(s) and event(s) replayed, which ${n} holds live`),t.degraded.length>0&&o.push((e.checkpoint.annex?`its take could not read ${t.degraded.join(", ")}`:"taken before SandForge 1.81, it keeps no record types, users, queues nor standard price book")+`: the records they name get what ${n} gives them, each said above`),o.push("created and modified dates and users are the replay's own: the platform sets them"),e.storage){let{storage:r}=e;o.push(`data storage: about ${Q(r.estimateMB)} MB of the ${Q(r.remainingMB)} MB ${n} has left of ${Q(r.maxMB)} MB`)}return o}var co=new Set(["REPLAY_SAME_ORG","REPLAY_REAL_DATA","REPLAY_COPY_UNKNOWN","REPLAY_TOO_MANY","REPLAY_NOTHING","REPLAY_CHECKPOINT_UNUSABLE","REPLAY_NO_PILOT","CHECKPOINT_NOT_FOUND","OWNER_MAP_INACTIVE","OWNER_MAP_UNKNOWN","GUARD_REFUSED","NO_LOAD","TARGET_REFRESHED","LOAD_REMOVED","LOAD_STOPPED"]);function ho(e){let t=String(e.type??""),n=e.payload?.code;if(!(!t.endsWith(":error")||typeof n!="string")&&co.has(n))return{code:n,message:String(e.payload?.message??"")}}function lo(e,t,n,o={}){switch(e){case"TARGET_REFRESHED":if(/dataset/i.test(t))return`${n} was refreshed after the last replay: the records it created went with the refresh. Replay the checkpoint again, then verify.`;break;case"LOAD_REMOVED":{let i=/removal of (\S+) took part/.exec(t);if(i)return`The removal of ${i[1]} took part of the records the last replay created and left ${j(Number(o.left??0))} in ${n}: a verification would read the ones it took as missing. Remove what is left (--remove), or replay again (--again), which purges or finds it again; then verify.`;let s=/removed on (\S+?)\.(?:\s|$)/.exec(t);return`The records the last replay created were removed${s?` on ${s[1]}`:""}. Replay the checkpoint again, then verify.`}case"LOAD_STOPPED":return"The last replay stopped part way \u2014 it was cancelled, or failed once it had written \u2014 and wrote no counting contract: a verification would judge it by the one before. Replay it again (--again), which purges or finds again what the stopped replay wrote, or take it back (--remove); then verify.";case"NO_LOAD":if(/dataset|\bsas\b/i.test(t))return`No replay of this checkpoint into ${n} is recorded on this machine: nothing names the records to verify. Replay it there, then verify.`;break;case"MAX_RECORDS":{let i=/insert (\d+) record\(s\), more than the (\d+)/.exec(t);if(i)return`This replay would create ${j(Number(i[1]))} record(s), more than the ${j(Number(i[2]))} it may: nothing was written. The checkpoint's records or ${n} changed since that count was taken: run its dry run again, and replay with the count it gives (--max-records).`;break}case"REPLACE_LEAVES_RECORDS":{let i=/would leave (\d+) of their records in the org — (.*?): loaded again/.exec(t);if(i)return`Taking back what the replays before created in ${n} would leave ${i[1]} of their records there \u2014 ${i[2]}: replayed again, the checkpoint's records would stand beside them. Nothing was written. Take the replay back first (--remove; --include-changed takes too what was changed since, and what was added under it since), then replay it again.`;break}case"GUARD_REFUSED":if(o.guard==="non-sandbox")return`A replay goes into a sandbox, a scratch org or a Developer Edition org, never into a production org nor a sandbox marked Staging, which hold real data: ${n} is ${o.tier==="staging"?"a sandbox marked Staging":"a production org"}. Nothing was read or written.`;break}return/dataset/i.test(t)?t.replace(/frozen-dataset load/gi,"replay").replace(/the frozen dataset/gi,"the checkpoint").replace(/the dataset/gi,"the checkpoint").replace(/datasets?/gi,"checkpoint"):t}async function Zt(e,t){let n=Jt(De(t.storeRoot,t.storeNamed)),o=Pe(t.storeRoot,t.locksDir);o!==void 0&&await po(o,t.say);let i=e.file!==void 0?await ko(e,t):await mo(e,t,n),s=n.folderOf(i.organizationId,i.checkpointId);await wt(n.root);let c={checkpoints:()=>[t.store,...[Pe(t.storeRoot,t.locksDir)].filter(m=>m!==void 0)],replays:n},r=t.storeNamed?t.storeRoot:void 0,a=X(i.checkpointId,e.target,r),u=i.name!==void 0?`checkpoint '${i.name}'`:`checkpoint ${i.checkpointId}`,g={request:{organizationId:i.organizationId,checkpointId:i.checkpointId,choices:e.choices,...e.config!==void 0?{config:e.config}:{}},stores:c,folder:s,auditStore:qt(n.root,to),words:no(u),refusalOf:ho,reword:(m,y,k)=>lo(m,y,e.target,k),lines:(m,y)=>Ao(m,y,{asked:e,chosen:i,again:a}),question:m=>`Replay ${u} into ${e.target}, creating ${j(uo(m))} record(s) there${e.again?" once what its replays before created there is purged":""}?`,dryRunEnd:m=>m.length>0?[]:[`To replay it: ${a}${Ro(e)}`],answer:(m,y)=>Co(m,y,{asked:e,chosen:i,again:a})};await zt(fo(e,t.json),g)}function uo(e){return e.perObject.reduce((t,n)=>t+n.toInsert,0)}function fo(e,t){return{step:e.action==="verify"?"verify":e.action==="remove"?"remove":"load",target:e.target,pilot:!1,reload:e.again,dryRun:e.action==="dryRun",writeEncrypted:!1,muteAutomation:e.muteAutomation,acceptAutomation:e.acceptAutomation,...e.checkpointFirst!==void 0?{checkpointFirst:e.checkpointFirst}:{},includeChanged:e.includeChanged,acceptEmails:e.acceptEmails,sweep:e.sweep,sweepList:e.sweepList,...e.sweepLate?{sweepLate:!0}:{},...e.sweepUntied?{sweepUntied:!0}:{},preview:e.preview,...e.maxRecords!==void 0?{maxTotal:e.maxRecords}:{},yes:e.yes,json:t}}async function po(e,t){let n=await e.sweep().catch(()=>{});for(let o of n?.checkpoints??[])t(`deleted the checkpoint '${o.name}' (${o.checkpointId}) of a file received, kept until ${te(o.expiresAt)}: its replays stay, and still take back with --remove`)}async function mo(e,t,n){let o=e.checkpoint??"",i=Pe(t.storeRoot,t.locksDir),s=new Set,c=[...await t.listAll(),...await i?.list()??[]].filter(y=>{let k=`${y.organizationId.slice(0,15)}/${y.checkpointId}`;return s.has(k)?!1:(s.add(k),!0)}),r=y=>({organizationId:y.organizationId,checkpointId:y.checkpointId,...y.checkpoint?{name:y.checkpoint.name}:{},of:wo(y)}),a=e.from;if(Ht(o)){let y=c.filter(h=>h.checkpointId===o&&(a===void 0||!ce.test(a)||Wt(h.organizationId,a)));if(y.length===1)return r(y[0]);let k=(await n.list({checkpointId:o})).filter(h=>a===void 0||!ce.test(a)||Wt(h.sourceOrganizationId,a)),d=[...new Set(k.map(h=>h.sourceOrganizationId))];if(y.length===0&&d.length===1){let h=k[0];return{organizationId:h.sourceOrganizationId,checkpointId:o,...h.checkpointName!==void 0?{name:h.checkpointName}:{}}}if(y.length+d.length>1){let h=[...new Set([...y.map(b=>b.organizationId),...d])];throw new N({code:"AMBIGUOUS",message:`Checkpoints of ${h.length} orgs have the id ${o}: name the org it was taken of with --from (${h.join(", ")}). Nothing was run.`},2)}throw new N({code:"NOT_FOUND",message:`No checkpoint ${o} is kept on this machine, nor a replay of it. `+go(t.storeNamed)})}let u=a??"",g=t.checkpointsOf(c,u,ce.test(u)?u:void 0),m=t.resolve(c,g,o,u);if("entry"in m)return r(m.entry);throw"ambiguous"in m?new N({code:"AMBIGUOUS",message:m.ambiguous},2):new N({code:"NOT_FOUND",message:m.none})}function Wt(e,t){return e.slice(0,15)===t.slice(0,15)}function go(e){return`"${U("checkpoint")} list" names the checkpoints kept, and "${U("checkpoint")} replays" the replays.${e?"":" One kept in another folder is read with --store <folder>."} A file a teammate sent replays with --file <.sfcheckpoint>.`}function wo(e){let t=e.checkpoint?.org;if(t===void 0)return;let n=t.alias??t.username;return e.why==="refreshed"?`${n} before its refresh${e.refreshedAt?` on ${e.refreshedAt.slice(0,10)}`:""}`:e.why==="scratchExpired"?`${n}, a scratch org expired since`:n}async function ko(e,t){let n=e.file??"",o=await Pt(n);if("refusal"in o)throw new N(o.refusal);let{header:i}=o.read;t.say(`the file holds checkpoint ${i.checkpointId} of org ${i.organizationId}, taken ${te(i.takenAt)}: ${j(i.records)} record(s) of ${j(i.objects)} object(s), exported by SandForge ${i.sandforgeVersion}`);let s={organizationId:i.organizationId,checkpointId:i.checkpointId,file:{path:n,header:i}};if(e.action==="remove")return s;if(e.action!=="verify"){let u=yo(i,e);if(u!==void 0)throw new N(u)}let c=e.keyEnv!==void 0?bo(e.keyEnv):await $o(),r=await Dt({storeRoot:t.storeRoot,...t.locksDir!==void 0?{locksDir:t.locksDir}:{},file:n,key:c,keepDays:e.keepDays,takenOn:{host:Gn(),pid:process.pid}});if(!r.imported)throw new N(r.refusal);let{checkpoint:a}=r;return t.say(r.outcome==="imported"?`kept checkpoint '${a.name}' of the file on this machine, apart from those it rewinds, to replay it: ${Ee(t.storeRoot)}, `+(a.expiresAt===null?"until it is deleted":`until ${te(a.expiresAt)} (--keep-days)`):`checkpoint '${a.name}' of the file is kept on this machine already, the same`),{...s,name:a.name,of:a.org.alias??a.org.username}}function yo(e,t){if(t.choices.mask)return;let n=Bt({tier:e.orgTier,...e.dataStorageMaxMB!==void 0?{dataStorageMaxMB:e.dataStorageMaxMB}:{},...e.staging?{staging:!0}:{}}),o=`The file holds checkpoint ${e.checkpointId}`;if(n.kind==="real")return{code:"REPLAY_REAL_DATA",message:`${o} of ${n.why==="staging"?"a sandbox marked Staging":`a Partial Copy or Full sandbox, by its data storage (${j(n.dataStorageMaxMB??0)} MB)`}, which may hold real data: it goes into another org masked only. To replay it into ${t.target}, ${ke.mask}. Its key was not read, and nothing was kept, read or written.`};if(n.kind==="unknown"&&t.choices.noRealData!==!0)return{code:"REPLAY_COPY_UNKNOWN",message:`${o} of a sandbox, and does not say which: made before SandForge 1.81, it keeps no data storage, and a Partial Copy or a Full sandbox holds production\u2019s records. To replay it into ${t.target}, ${ke.mask}, or ${ke.noRealData}. Its key was not read, and nothing was kept, read or written.`}}function bo(e){let t=process.env[e];if(t===void 0||t.trim()==="")throw new N({code:"NO_KEY",message:`${e} is not set: it holds no key. Nothing was run.`},2);let n=Y(t);if(n===void 0)throw new N({code:"NO_KEY",message:`${e} holds no key SandForge reads: 52 letters and digits, in groups of four as an export shows one. Nothing was run.`},2);return n}async function $o(){let e=await we("Key of the file (not shown as you type it):","give --key-env VAR, the name of an environment variable that holds the key");if(e===void 0||e.trim()==="")throw new N({code:"DECLINED",message:"No key was typed. Nothing was run."});let t=Y(e);if(t===void 0)throw new N({code:"IMPORT_KEY",message:"That is not a key SandForge draws: 52 letters and digits, in groups of four as the export showed it. Nothing was run."});return t}function vo(e){let t=e.payload?.replay;return typeof t=="object"&&t!==null?t:void 0}function Ao(e,t,n){let o=vo(e);if(o===void 0)return t;let{again:i}=n,s=o.target.name,c=o.filesLeft.length>0?` ${j(o.filesLeft.length)} file(s) are not replayed: a checkpoint keeps no file's content.`:"";if(e.type==="frozen:load:preview:response"){let r=n.chosen.of??o.checkpoint.alias??o.checkpoint.organizationId;return[`A replay of checkpoint '${o.checkpoint.name}' (of ${r}, taken ${te(o.checkpoint.takenAt)}) into ${s} would create copies of ${j(o.summary.records.toCreate)} of its records there, parents first, with new Ids; nothing ${s} holds is changed or deleted.${c}`,...t,...ao(o)]}return e.type==="frozen:load:response"?[...t,`To take it back: ${i} --remove`]:t}function Ro(e){let{choices:t}=e,n=e.checkpointFirst;return[t.objects.length>0?` --objects ${t.objects.join(",")}`:"",...t.excluded.map(o=>` --exclude-object ${o}`),t.owners!=="same"?` --owners ${t.owners}`:"",e.ownerMapFile!==void 0?` --owner-map ${ye(e.ownerMapFile)}`:"",...t.link.map(o=>` --link ${o.objectApiName}=${o.fields.join(",")}`),t.customSettings?" --custom-settings":"",t.mask?" --mask":"",t.contactPoints==="kept"?" --keep-contact-points":"",t.noRealData?" --no-real-data":"",e.configFile!==void 0?` --replay-config ${ye(e.configFile)}`:"",e.again?" --again":"",e.muteAutomation?" --mute-automation":"",e.acceptAutomation?" --accept-automation":"",e.acceptEmails?" --accept-emails":"",n!==void 0?" --checkpoint-first":"",n?.keepDays!==void 0?` --checkpoint-keep-days ${n.keepDays}`:"",...(n?.excluded??[]).map(o=>` --checkpoint-exclude-object ${o}`),e.maxRecords!==void 0?` --max-records ${e.maxRecords}`:""].join("")}function Le(e,t){return e.filter(n=>n.type===t).at(-1)?.payload}var jo=new Set(["tool","step","posted","dataset","checkpoint"]);function Co(e,t,n){let{asked:o,chosen:i,again:s}=n,c=Le(e.posted,"frozen:load:preview:response"),r=Le(e.posted,"frozen:load:response"),a=r?.replay??c?.replay,u=c?.plan,g=r?.report,m=Le(e.posted,"frozen:remove:response")?.result,y=Object.fromEntries(Object.entries(e).filter(([h])=>!jo.has(h))),k=e.checkpoint,d=a?.target.organizationId??t.targetOrgId;return{command:"replay",action:o.action,dryRun:o.action==="dryRun",checkpoint:a?{id:a.checkpoint.checkpointId,name:a.checkpoint.name,organizationId:a.checkpoint.organizationId,takenAt:a.checkpoint.takenAt,tier:a.checkpoint.tier,annex:a.checkpoint.annex}:{id:i.checkpointId,...i.name!==void 0?{name:i.name}:{},organizationId:i.organizationId},target:{alias:o.target,...d!==void 0?{organizationId:gt(d)}:{}},...o.action==="replay"||o.action==="dryRun"?{choices:a?.choices??o.choices}:{},...i.file?{file:i.file.path}:{},...u?{plan:u}:{},...a?{replay:{...a.summary,filesLeft:a.filesLeft,...a.storage?{storage:a.storage}:{},requests:a.requests}}:{},...g?{result:g}:{},...m!==void 0?{removal:m}:{},...y,...k?{checkpointFirst:k}:{},removeWith:`${s} --remove`,...t.refused?{refused:t.refused}:{},...t.ended?{ended:t.ended}:{},exit:t.exit}}function Te(e,t){return{checkpointId:e.checkpointId,...e.checkpointName!==void 0?{checkpointName:e.checkpointName}:{},sourceOrganizationId:e.sourceOrganizationId,...e.takenAt!==void 0?{takenAt:e.takenAt}:{},target:e.target,...e.choices!==void 0?{choices:e.choices}:{},...e.replayedAt!==void 0?{replayedAt:e.replayedAt}:{},inPlace:e.inPlace,inPlaceByObject:e.inPlaceByObject,...e.removed?{removed:!0}:{},removeWith:`${X(e.checkpointId,e.target.name??"<alias>",t)} --remove`}}function Oo(e,t,n,o){return e.length===0?[`No replay${n!==void 0?` into ${n}`:""} is kept in ${t}.`]:e.flatMap(i=>{let s=i.target.name??i.target.organizationId,c=i.inPlaceByObject.map(r=>`${r.objectApiName} ${j(r.records)}`).join(", ");return[`${i.checkpointId} ${i.checkpointName!==void 0?`'${i.checkpointName}' `:""}of ${i.sourceOrganizationId}${i.takenAt!==void 0?`, taken ${te(i.takenAt)}`:""} into ${s} (${i.target.organizationId})`+(i.replayedAt!==void 0?` replayed ${te(i.replayedAt)}`:""),i.inPlace>0?` ${j(i.inPlace)} record(s) in place: ${c}`:i.removed?" removed: none of its records is left there":" none of its records is left there",...i.inPlace>0?[` to take it back: ${X(i.checkpointId,i.target.name??"<alias>",o)} --remove`]:[]]})}async function Xt(e,t){let n=Jt(De(t.storeRoot,t.storeNamed)),o=await n.list(e!==void 0&&ce.test(e)?{targetOrganizationId:e}:{}),i=e!==void 0&&!ce.test(e)?o.filter(c=>c.target.name===e):o,s=t.storeNamed?t.storeRoot:void 0;for(let c of Oo(i,n.root,e,s))t.say(c);t.answerJson(i.map(c=>Te(c,s)))}async function Fe(e,t){let n;try{n=new Ie({root:De(t.storeRoot,t.storeNamed)})}catch{return{lines:[],entries:[]}}let o=t.storeNamed?t.storeRoot:void 0,i=[],s=[];for(let c of e){let r=await n.replaysOf(c.organizationId,c.checkpointId).catch(()=>[]),a=_t(r);if(a!==void 0){i.push(` ${a}`);for(let u of Ft(r))i.push(` to take it back: ${X(u.checkpointId,u.target.name??"<alias>",o)} --remove`),s.push(u)}}return{lines:i,entries:s}}var Lo=`sandforge checkpoint \u2014 take a checkpoint of an org's data, and rewind the org to it, without the editor.
8
-
9
- Usage:
10
- npx sandforge checkpoint <command> --org <alias> [options]
11
-
12
- Commands:
13
- take read the org's records and keep them as a checkpoint on this machine
14
- list name the checkpoints kept, newest first, with what a rewind and an undo can still reach
15
- preview say what a rewind would delete, give back and bring back, who last changed it, and what
16
- it and an undo cannot take back; writes nothing
17
- rewind return the org to a checkpoint: bring back from the recycle bin the records deleted
18
- since, give the records changed since their values back, delete the records created
19
- since, and put the files attached to its records back as they were \u2014 whoever made the
20
- changes; keep what it changes so it can be undone; then read the org again
21
- undo take back the org's last rewind: bring back what it deleted, give back what it wrote
22
- over, send back to the bin what it brought back; what anyone changed since the rewind
23
- stays, and is said
24
- delete delete a checkpoint from this machine; the org is not touched
25
- export write a checkpoint to a .sfcheckpoint file, encrypted, for a teammate who rewinds the
26
- same org from another machine; the org is not contacted
27
- import keep a .sfcheckpoint file a teammate exported as a checkpoint of the org on this
28
- machine, once the org answers that it is the file's, and its user sees all data
29
- replay set a checkpoint's records up again in another org, with new Ids \u2014 the sandbox its
30
- org became once refreshed, another sandbox, a scratch org \u2014, its own org never
31
- reached: its dry run first, then a question; nothing the other org holds is changed
32
- or deleted, and --remove takes it back
33
- replays name the replays kept on this machine, and what each left in its org; no org is
34
- contacted
35
-
36
- Required:
37
- --org <alias> sf CLI alias of the org (list: every org of the store without it;
38
- replay names --target instead)
39
-
40
- take:
41
- --name <text> what it is called (default: the date and time)
42
- --object <ApiName> an object to keep; repeat for more (default: every object people
43
- work in, empty ones included, setup and log objects left out)
44
- --exclude-object <ApiName> leave an object out; repeat for more
45
- --custom-setting <ApiName|all> keep a custom setting, or all of them, which a checkpoint leaves
46
- out unless named: a rewind sets their rows back, an integration's
47
- endpoint or an admin's switch among them; repeat for more; needs
48
- Customize Application
49
- --ignore-field <Object.Field> do not compare a field, nor write it back (one your automation sets
50
- on every save); repeat for more
51
- --max-total <n> refuse, before reading, more than <n> records (default: ${Ce},
52
- ${G} at most)
53
- --keep-days <n> when it expires (default: ${H}; 0 keeps it until deleted)
54
- --estimate say the records, API requests, time and disk it would take, then stop
55
- preview, rewind, undo, delete, export:
56
- --checkpoint <id|name|latest> which one (default: latest, for undo the one the last rewind went
57
- back to; rewind and undo with --yes need it named, by id or name)
58
- preview, rewind:
59
- --object <ApiName> limit the rewind to an object of the checkpoint; repeat for more
60
- (default: every object). It writes the others only to delete again
61
- the records made since that come back with a record it brings
62
- back, and never adds what the objects named depend on: what it
63
- leaves of them for that is said, with the --object to add
64
- preview:
65
- --fail-on-change exit 3 when the org differs from the checkpoint
66
- rewind:
67
- --dry-run the preview, then stop
68
- --accept-automation rewind even when the org runs flows, Apex triggers, processes or
69
- workflow rules as records are updated, deleted or brought back;
70
- without it such a rewind writes nothing, exit 1
71
- --accept-emails rewind even when the org delivers every email its automation
72
- sends (Setup > Deliverability: All email), or would not say
73
- whether it does, and what still runs as it writes sends some:
74
- they go to the addresses the records and the alerts name, and to
75
- the records' owners. Without it such a rewind writes nothing,
76
- exit 1. --accept-automation never stands for it. Read with one
77
- line of anonymous Apex that sends nothing, only when something
78
- that still runs sends an email; what Apex triggers send is not
79
- read
80
- --mute-automation mute the org's automation for the rewind through its own bypass:
81
- assign the user it writes as, for the rewind alone, the permission
82
- sets holding the custom permissions its flows, processes and
83
- workflow rules test to stay quiet, and take them back as it ends;
84
- what no bypass keeps quiet still runs, and still needs
85
- --accept-automation. Refused on a production org and for a user
86
- who cannot assign permission sets, exit 1; with --dry-run, says
87
- what would be muted, or why it would be refused, and assigns
88
- nothing
89
- --accept-no-undo rewind even when undo could not bring back some records it deletes
90
- (objects Salesforce undeletes only with their parent, such as
91
- OpportunityLineItem); without it such a rewind writes nothing, exit 1
92
- --accept-recreate make again, with new Ids, the records deleted since that the
93
- recycle bin no longer gives back: what outside Salesforce names
94
- their old Ids no longer finds them; without it a rewind that
95
- counts such records writes nothing, exit 1, and one Salesforce
96
- answers is no longer in the bin as it brings it back is left,
97
- named
98
- --accept-outside (a checkpoint of picked objects) also delete the records outside it
99
- created under records it deletes, and the files it deletes that are
100
- attached outside it too; without it those parents stay, and those
101
- files are only removed from its records
102
- --accept-unseen (a user without View All Data and Modify All Data) delete records
103
- whose delete takes along records of objects the user is not
104
- proven to see whole \u2014 tasks and events always: the preview names
105
- those objects, and no count holds what goes with them; without it
106
- such a rewind writes nothing, exit 1
107
- --max-records <n> refuse, before it writes, a rewind that would delete, give back,
108
- bring back and make again more than <n> records together, exit 1:
109
- with --yes in a cron job or a CI step, what stands in for reading
110
- the preview
111
- --refuse-when-active refuse, before it writes, a rewind of an org where anyone but the
112
- user it writes as and the org's Automated Process changed records
113
- of the checkpoint's objects in the hour before it read the org,
114
- whose work it would take back, exit 1; the refusal says how many
115
- people. Where people sign in as the user SandForge connects as,
116
- their changes are that user's, and are not told apart
117
- --ignore-field <Object.Field> stop comparing a field from now on; kept in the checkpoint
118
- --yes do not ask before writing; without it and with no terminal \u2014 a CI
119
- step \u2014 it stops at its question, exit 2, having written nothing
120
- undo:
121
- --accept-automation as for rewind
122
- --accept-emails as for rewind
123
- --mute-automation as for rewind
124
- --yes as for rewind
125
- delete:
126
- --all every checkpoint of the org
127
- --yes do not ask
128
- export:
129
- --out <file> the file to write; refused when one is there already
130
- --key-env <VAR> encrypt under the key this environment variable holds, one an
131
- export showed (a CI step's secret); without it a new key is
132
- drawn and shown once, on stderr
133
- import:
134
- --file <file> the .sfcheckpoint file
135
- --key-env <VAR> read the key from this environment variable; without it the key
136
- is asked on the terminal, not echoed, and with no terminal it
137
- stops, exit 2, having imported nothing
138
- --keep-days <n> when it expires on this machine (default: ${H}; 0 keeps it until
139
- deleted)
140
- replay:
141
- --checkpoint <id|name|latest> which one: by its id, wherever it is kept (list names it); by its
142
- name, or latest, with --from
143
- --from <alias|username|00D\u2026> the org it was taken of, as list names it; refreshed or expired
144
- since, it is not reached
145
- --file <file> a .sfcheckpoint file a teammate sent, in place of --checkpoint:
146
- replayed without its org, the key standing for the teammate's
147
- consent; its checkpoint is kept on this machine apart from those
148
- it rewinds. A file of a Partial Copy, a Full or a Staging sandbox
149
- is refused unmasked before its key is read
150
- --key-env <VAR> with --file: the environment variable that holds its key; without
151
- it the key is asked on the terminal, not echoed, and with no
152
- terminal it stops, exit 2
153
- --keep-days <n> with --file: when its checkpoint expires here (default: ${H}; 0 keeps
154
- it until deleted)
155
- --target <alias> the org the records go into: a sandbox, a scratch org or a
156
- Developer Edition org; never a production org, a sandbox marked
157
- Staging, nor the checkpoint's own org, which rewind brings back
158
- --dry-run say what it would create, link, leave and refuse, and write
159
- nothing
160
- --objects <A,B> replay these objects alone (default: every object it holds);
161
- separate with commas, or repeat
162
- --exclude-object <ApiName> leave an object out; repeat for more
163
- --owners same|me same (default): a record keeps its owner where the other org has
164
- that user active \u2014 by its Id, or by its username without a
165
- sandbox's suffix \u2014, and goes to the user who replays otherwise;
166
- me: every record to the user who replays
167
- --owner-map <file.json> {"<user Id there>": "<user Id here>"}: who owns the records of
168
- each user of the checkpoint's org, an active user of the other org
169
- --link <Object=Field[,Field]> link to the records of an object the other org holds with the
170
- same values of these fields, rather than create them; repeat
171
- --custom-settings set up the custom settings the checkpoint holds too; a row the
172
- other org has already is kept, never written over
173
- --mask mask personal data, as Forge's anonymization does; required of a
174
- checkpoint of a Partial Copy, a Full or a Staging sandbox, told by
175
- its data storage and its mark; the free text it does not read is
176
- named
177
- --no-real-data declare that a sandbox's checkpoint taken before SandForge 1.81,
178
- which does not say which sandbox, holds no real data: replayed
179
- unmasked, the declaration kept in the audit trail
180
- --keep-contact-points keep emails and phone numbers as they are (default: made
181
- unreachable, addresses in .invalid and numbers that ring nobody)
182
- --replay-config <file.json> the load's part of a Frozen project's configuration: required field
183
- defaults, lookup placeholders, picklist rules, identity keys, \u2026
184
- --again replay over what the replays before created there, which goes
185
- first; what they linked stays
186
- --max-records <n> the most records it may create (default: the count of the dry run
187
- it reads first)
188
- --mute-automation mute what the other org runs as the replay writes, or as --remove
189
- deletes, through its own bypass, for that run alone, as a Frozen
190
- load does; what no bypass keeps quiet still needs
191
- --accept-automation
192
- --accept-automation write, or delete, although the other org runs flows, Apex
193
- triggers, processes or workflow rules as it does: named first,
194
- and without it such a replay writes nothing, exit 1
195
- --accept-emails write although the other org delivers the emails what still runs
196
- sends, or would not say: without it such a replay writes nothing,
197
- exit 1
198
- --checkpoint-first take a checkpoint of what the replay writes in the other org
199
- before its first write: a rewind to it takes the replay back, and
200
- the work of anyone else on those objects since
201
- --checkpoint-keep-days <n> the days that checkpoint is kept on this machine (default: 7)
202
- --checkpoint-exclude-object <ApiName>
203
- leave an object out of that checkpoint; repeat for more
204
- --yes do not ask before it writes, nor before --remove deletes; without
205
- it and with no terminal, it stops at its question, exit 2
206
- --verify verify the last replay into the other org: what it created there,
207
- counted against what it said it created
208
- --remove delete from the other org what the replays created there, children
209
- first, the checkpoint kept or not; --preview says what it would
210
- delete; --sweep takes too what the other org's automation made for
211
- them, and --sweep-list lists it and deletes nothing;
212
- --include-changed takes too what was changed since
213
- --sweep-late with --sweep: take too what it lists as made late; with
214
- --sweep-list, say what it would take
215
- --sweep-untied with --sweep: take too what it lists as tied to nothing of the
216
- replay, refused when another run of this machine wrote to the
217
- other org meanwhile; with --sweep-list, say what it would take
218
- replays:
219
- --target <alias|00D\u2026> the replays into this org alone
220
- Options:
221
- --store <dir> where checkpoints live (default: ~/.sandforge/checkpoints, or
222
- checkpoints/ in the folder SANDFORGE_JOURNAL_DIR names); the
223
- replays of its checkpoints are kept in it too, in .replays
224
- --json the answer alone on stdout, every other line on stderr
225
- --help this text
226
-
227
- A production org is refused before anything is read or written, exit 1. No flag lifts it.
228
- With View All Data and Modify All Data, the user the alias connects as sees every record and
229
- rewinds whoever changed it; import needs both. Without them, take holds only the objects the
230
- user has View All and Modify All on, or, for an object with no permissions of its own, on every
231
- record it hangs from \u2014 never tasks and events, products and price books, files or custom
232
- settings \u2014 and preview, rewind and undo read those permissions again: an object no longer held
233
- is not read, and is left as it is; what another user deleted since stays in the recycle bin,
234
- named; undo takes back the user's own rewind alone. A checkpoint that keeps custom settings
235
- needs Customize Application too: View All Custom Settings reads them, never writes them.
236
- A checkpoint holds the records' values as the org held them, personal data among them,
237
- unencrypted, in files only you can read (on Windows: in your user profile). Expired checkpoints
238
- are deleted as any command starts, each named.
239
- list and delete read this machine alone and never contact the org. An org's checkpoints are the
240
- ones taken under its alias or username, and the others kept of the same Organization Id.
241
- export never writes a checkpoint unencrypted: AES-256-GCM, under a key of 52 letters and digits
242
- shown once and kept nowhere. Anyone who has the file and its key reads every record it holds:
243
- send the key another way than the file, and only to people who already see all data in the org.
244
- The file does not expire: delete it once it has served. It carries neither the journals of
245
- rewinds nor their undo, which stay on this machine.
246
- import reads the file's header, then asks the org: another org, a production org, a user without
247
- View All Data and Modify All Data, a file a newer SandForge made, are each refused before the key
248
- is asked. A wrong key, or a file changed since it was exported, is refused before anything is
249
- kept. A checkpoint kept already the same is left as it is, exit 0; another of its id is refused.
250
- The lock against two rewinds at once is per machine: agree on who rewinds the org.
251
- replay never reaches the checkpoint's own org. It reads the other org, then creates copies of
252
- the checkpoint's records there, parents first, with new Ids, and changes or deletes nothing that
253
- org holds. A checkpoint keeps no file's content: files, attachments and documents are never
254
- replayed, each named. Owners, record types, currencies, person accounts and the standard price
255
- book are read from the other org, and every record that does not go across as it was is said,
256
- with why: a checkpoint taken before SandForge 1.81 keeps no record types, users or price book,
257
- and its records get the other org's. Its created and modified dates and users are the replay's.
258
- A replay runs its dry run first, asks, then creates no more than that dry run counted. What it
259
- wrote is kept on this machine apart from the checkpoint (replays/ beside checkpoints/, or .replays
260
- in the folder --store names), and --remove takes it back once the checkpoint is deleted. A
261
- checkpoint of a Partial Copy, a Full or a Staging sandbox replays masked only, but into that
262
- sandbox refreshed; delete names the replays a checkpoint leaves in place.
263
- rewind shows its preview and asks you to type the org's alias exactly as --org gives it before it
264
- writes, then rewinds from that preview as it read the org: a record someone changes after it read
265
- is left as they made it, and said. undo says what it takes back and asks the same before it
266
- writes. A take, a rewind or an undo of the org under way on this machine, in the editor or in
267
- another command line, refuses a rewind and an undo; other runs writing to the org are not seen
268
- here, and what one of them changes after the preview read the org is left and said the same way.
269
- Ctrl-C stops a take between two reads, and nothing of it is kept; a second Ctrl-C ends it at once,
270
- and leaves a checkpoint listed as never taken, which delete removes. Ctrl-C stops a rewind or an
271
- undo before its next call to the org, and leaves its journal: rewind again takes up from what still
272
- differs, and undo still returns the org to how it was before the rewind. A rewind stopped before
273
- it sent anything leaves none, and the undo of the rewind before it stays offered.
274
-
275
- A record deleted since that the recycle bin no longer gives back is made again from the
276
- checkpoint, with a new Id, once --accept-recreate says so: the lookups the checkpoint holds that
277
- named it name the new Id, and undo deletes it again. Salesforce still lists a record emptied from
278
- the bin as deleted, for minutes to hours, and says the bin no longer holds it only as the rewind
279
- asks it back: such a record, with what was to come back with it, is made again then, or left
280
- and named without --accept-recreate.
281
- A record the checkpoint does not hold that took records of it along when it was deleted since is
282
- brought back for a moment with them, then deleted again with what came back with it.
283
- A custom setting is kept only when --custom-setting names it. A rewind brings a row of one back
284
- only once no other row holds its owner (a hierarchy: the org's default, a profile, a user) or
285
- its name (a list): it deletes the row made since first, then brings the row back with its Id.
286
- A checkpoint holds the files attached to its records, Salesforce Files and classic attachments:
287
- which records each is attached to, its latest version and its size, never its content. A rewind
288
- deletes the files attached to them since, brings back those deleted since with their links,
289
- removes the links added since and puts back those removed since, under new Ids; a file
290
- attached to no record of the checkpoint, a user's own or a library's, is left and counted.
291
- Bringing files back from the recycle bin takes file storage again: a rewind or an undo that would
292
- take more than the org has left is refused before it writes. Without Query All Files, other
293
- users' files that no record of the checkpoint is attached to are not seen.
294
- What a rewind cannot undo: a file deleted since and no longer in the recycle bin, whose body the
295
- checkpoint does not hold, a file given a new version since, which keeps it, a lead converted
296
- since, a contract activated since, a record deleted with a parent created since that Salesforce
297
- does not undelete on its own, or with its parent of an object the checkpoint does not hold
298
- (preview counts them); without View All Data and Modify All Data, a record another user deleted
299
- since, and a record of an object held through what it hangs from that the recycle bin does not
300
- show the user (preview counts them too); a field added since, deleted since, or hidden since from
301
- the user by field-level security, which the preview tells apart and names in an object something
302
- changed in since \u2014 in an object nothing changed in, which a rewind writes nothing to, the fields
303
- are not checked, and the preview counts those objects; the values the org computes or keeps
304
- itself (formulas, roll-ups, auto-numbers, created and modified dates); what left the org
305
- (emails, callouts, outbound messages, platform events); metadata; the files of a checkpoint taken
306
- before SandForge 1.70, which holds none. A record the org refuses to put back, or to make again,
307
- is named by rewind, with its words.
308
-
309
- JSON (--json), one value on stdout:
310
- list [{id, name, org, organizationId, takenAt, records, bytes, expiresAt,
311
- expiresSoon, binReachSince, lastRewind?, valid, why?, refreshedAt?,
312
- replayWith?}]
313
- (name, org, takenAt, records and bytes are null for a damaged checkpoint;
314
- expiresAt is null for one kept until deleted; replayWith, of one that no
315
- longer rewinds its org, the dry run of its replay)
316
- take {checkpoint, requests?, estimate}: the checkpoint as kept (its
317
- checkpoint.json; files?, {documents, links, anchored, readByIds?}, for one
318
- that holds files); requests, {total, byPhase}, the API requests the take sent
319
- the org, SOAP calls among them; estimate, what it said before reading a record
320
- take --estimate {mode, objects, leftOut, estimate, refusal?, files?, customSettings?}:
321
- estimate.requestsByPhase splits the requests over a take's phases as
322
- requests.byPhase does: guard, scope, start, counts, bin, snapshot, stability;
323
- files, {held, queryAllFiles, addedToPicked}; customSettings, every custom
324
- setting of the org, kept or not, [{objectApiName, label, kind?, records?}],
325
- kind hierarchy or list, and objects[].customSetting for one kept; {mode,
326
- refusal} for a take refused before its scope is read (a production org, a
327
- user without the permissions)
328
- preview {checkpoint: {id, name, takenAt, org}, toDelete, toGiveBack, toBringBack,
329
- toRecreate, carriers, differs, diff, estimate, automation?, emails?,
330
- emailsUncounted?, deliverability?, refusal?}: carriers, the records
331
- brought back for a moment and deleted again, in none of the other numbers;
332
- diff, estimate
333
- and automation as the extension answers them; refusal, the first a rewind
334
- given no flag would meet now, of those its lines name with what lifts
335
- each, as rewind --dry-run lists them: the extension's own (the org's lock,
336
- a run writing, the day's API requests or emails, file storage), then an
337
- acceptance it needs (NO_UNDO, RECREATE, UNSEEN, AUTOMATION,
338
- EMAILS_DELIVERED, in that order); emails, one per daily limit its writes send
339
- against: {limit, emails, verdict, remaining?, max?, alertsCounted?,
340
- objects: [{objectApiName, write, records, perRecord, sentBy}]};
341
- emailsUncounted, what sends emails as it writes that could not be read \u2014 a
342
- flow whose definition was refused, a package's, which no user reads \u2014 its
343
- emails not counted, which --accept-automation covers; deliverability,
344
- when something that still runs may send an email: {reading: {level: all
345
- or withheld} or {unread}, senders: [{objectApiName, kind, name, why}]},
346
- which --accept-emails answers for all and unread;
347
- diff.objects[].schemaDrift, of an object whose fields changed since:
348
- {removed, added, changed, hidden?, uncertain?: {fields, reason?}}, removed
349
- the custom fields deleted since, hidden those field-level security hides
350
- from the user, uncertain those the org would not say which of;
351
- diff.described, {first, later}, the objects it described again, asked
352
- whether their fields changed since the take: first those something moved
353
- in, later those nothing moved in that hold fewer records than the
354
- checkpoint; diff.fieldsNotChecked, the objects nothing changed in whose
355
- fields it did not describe: a rewind writes nothing there, and a field
356
- deleted or hidden since in one of them is not known; diff.files,
357
- for a checkpoint that holds files: {unlink, relink, updateLinks,
358
- outsideAdded, outsideDeleted, storage: {bringBack, remaining?, undo},
359
- blindSpot?}, the links to remove, put back and give their sharing back, the
360
- files left, and file storage in bytes; diff.access, {kind, requests?}, org
361
- for a user with View All Data and Modify All Data, perObject for one read
362
- object by object, with the API requests that read; diff.unseen, read
363
- object by object: [{objectApiName, children, records}], of the records to
364
- delete of an object, the objects whose records their delete takes along
365
- out of the user's sight; with --object, objects, the objects named, and
366
- selection, {objects, acts: [{objectApiName, picked, toDelete, toGiveBack,
367
- toBringBack, toRecreate}], left: [{objectApiName, reason, count}], needs:
368
- [{objectApiName, records}], undoCannot}, what a rewind of them alone would
369
- do and leave \u2014 reason needsUnpickedParent, heldByUnpicked,
370
- outsideNotAccepted, holdsLeft or keyTaken \u2014 and the objects to add; the
371
- numbers, differs and estimate are then the rewind's of those objects,
372
- diff the whole diff; of a checkpoint of picked objects whose records
373
- outside it were made since under records a rewind would delete, kept:
374
- [{objectApiName, reason, count}], what a rewind without --accept-outside
375
- keeps for them \u2014 reason outsideNotAccepted or holdsLeft \u2014, the numbers
376
- then those of what it writes, differs the whole diff's (preview previews
377
- that rewind)
378
- rewind --dry-run as preview, with wouldBeRefused: ["refused (CODE): message"] and
379
- wouldBeRefusedCodes: ["CODE"], one for each refusal a rewind with these
380
- flags would meet, in order; asked to mute, emails and deliverability are
381
- of what still runs, with mutedAutomation and mutePlan
382
- rewind {checkpoint: {id, name, takenAt, org}, rewindId, status, deleted, givenBack,
383
- broughtBack, recreated (each {planned, done, left}), cannotUndo: [{object,
384
- reason, count}], carriers?: [{object, count}], draftsLeft?: [{object,
385
- count, ids}], undo?: {until, cannot: [{object, count, reason?}]}, verify:
386
- {differences, stable, passes, notCompared}, residual: [{object, reason,
387
- by?, count, message?}], unread: [{object, reason}], objects: [{object,
388
- deleted, givenBack, broughtBack, refused}], apiRequests: {used,
389
- leftToday}, result}:
390
- status success, partial, unstable, failure or cancelled; result as the
391
- extension answers it; undo.cannot's reason deletedBeforeParent: deleted
392
- before a record they point at, which the rewind deleted next; carriers, of
393
- what it brought back and deleted, the records brought back for a moment;
394
- draftsLeft, of a rewind stopped part way, the orders and contracts it made
395
- again as drafts and had not given their status back yet, by their new Ids;
396
- files?: {unlinked, relinked, linksUpdated, linksRefused}, the links between
397
- files and records it wrote, when it wrote one; with --object, limitedTo,
398
- the objects named, and notRewound, {objects, records}, the objects not
399
- named that still differ and their records that do, which the status
400
- does not count
401
- undo as rewind, without recreated, cannotUndo, carriers, draftsLeft and undo,
402
- with carriedAlone?: [{object, count}], the records sent back to the
403
- recycle bin on their own that had gone there with a record the rewind
404
- brought back for a moment
405
- delete {deleted: [id], kept: [id], replaysInPlace?}: replaysInPlace, as replays
406
- lists them, those of the checkpoints deleted that left records in their org
407
- replay {command, action, dryRun, checkpoint: {id, name, organizationId, takenAt,
408
- tier, annex}, target: {alias, organizationId}, choices?, file?, plan?,
409
- replay?: {records, owners, recordTypes, notReplayed, filesLeft,
410
- lookupsEmptied, refused, fieldsNotInTarget, customSettings?, currencies,
411
- standardPricebook?, masked, contactPoints, archivedActivities?,
412
- degraded, auditDates, storage?, requests}, result?, removal?, objects?,
413
- status?, verdict?, mapping?, refusals?, refusalCodes?, refused?,
414
- mutedAutomation?, mutePlan?, checkpointFirst?, removeWith, ended?, exit}:
415
- plan, result and removal as a Frozen load and its removal answer them;
416
- objects, status, verdict and refusals as a Frozen step gives them
417
- replays [{checkpointId, checkpointName?, sourceOrganizationId, takenAt?, target:
418
- {organizationId, name?}, choices?, replayedAt?, inPlace, inPlaceByObject,
419
- removed?, removeWith}]
420
- export {checkpoint: {id, name, takenAt, org}, file, bytes, sha256, records, objects,
421
- keyShown}: keyShown, whether a new key was drawn and shown on stderr; never
422
- the key itself
423
- import {outcome, checkpoint: {id, name, takenAt, org}, records, objects, expiresAt,
424
- warnings}: outcome imported, or alreadyKept for the same checkpoint kept here
425
- already
426
- refused or failed {refusal: {code, message}}; a rewind or an undo refused before it wrote
427
- for more than one reason adds wouldBeRefused and wouldBeRefusedCodes, as
428
- rewind --dry-run gives them: every refusal, the first among them, each other
429
- also on a line of its own, refused (CODE): message
430
- A bad command line (exit 2) prints nothing on stdout.
431
-
432
- replay ends as a Frozen load ends: 0 its dry run said, or the replay done and verified; 1 refused
433
- before it wrote (REPLAY_SAME_ORG, REPLAY_REAL_DATA, REPLAY_COPY_UNKNOWN, REPLAY_TOO_MANY,
434
- REPLAY_NOTHING, a target refused, what it runs or sends unanswered) or failed; 2 a bad line or a
435
- question with no terminal; 3 done with records refused or left, or its verification PARTIAL.
436
- Exit codes: 0 done (take: every record of its objects is kept; rewind and undo: read again, the
437
- org matches among the objects and fields compared \u2014 with --object, among the objects named,
438
- whatever still differs in the others; preview, rewind --dry-run and list answered;
439
- delete: every checkpoint named is deleted; export: the file is written; import: the checkpoint is
440
- kept, or was already); 1 refused before it read or wrote (a production org,
441
- missing permissions, automation without --accept-automation, emails the org delivers or would not
442
- say it withholds without --accept-emails (refusal code EMAILS_DELIVERED), deletions undo could not
443
- bring back without --accept-no-undo, records to make again with new Ids without --accept-recreate,
444
- deletions taking along records the user is not proven to see without --accept-unseen, more than
445
- --max-total records, more records to rewind than --max-records, people working in the org in the
446
- hour before with --refuse-when-active, more API requests or emails than the org
447
- has left today, files to bring back taking more file storage than it has left, a checkpoint of
448
- the org before a refresh or of an expired scratch org, a SandForge run writing to it; an import
449
- of another org's file, with the wrong key, of a file changed since its export), or nothing
450
- done; 2 a bad command line, a --checkpoint name several checkpoints
451
- have, an --object the checkpoint does not hold,
452
- rewind or undo with --yes and no checkpoint named, or a question with no terminal (give
453
- --yes; import's key: --key-env); 3 partial (rewind and undo: records still differ, each said
454
- with why; with
455
- --fail-on-change, the org differs: records to delete, give back, bring back or make again,
456
- links between files and records to remove, put back or give their sharing back, records the
457
- rewind cannot take back or the checkpoint does not hold although they are dated before it, files
458
- added or deleted since that no record of it is attached to, a field it compares deleted or
459
- hidden since in an object something moved in, an object that could not be read; delete: some
460
- were kept, each said with why); 4 unstable (someone else changed
461
- records during the rewind or the undo: left as they made them); 130, 143, 129 Ctrl-C, SIGTERM or
462
- SIGHUP stopped it \u2014 run rewind again: it takes up from what still differs, and undo still reaches
463
- the state before it.
464
- `,Po=["take","list","preview","rewind","undo","delete","export","import","replay","replays"],Do=e=>Po.includes(e),P={switches:["--json"],values:["--org","--store"]},To={take:{words:1,switches:[...P.switches,"--estimate"],values:[...P.values,"--name","--object","--exclude-object","--custom-setting","--ignore-field","--max-total","--keep-days"]},list:{words:1,...P},preview:{words:1,switches:[...P.switches,"--fail-on-change"],values:[...P.values,"--checkpoint","--object"]},rewind:{words:1,switches:[...P.switches,"--dry-run","--accept-automation","--accept-emails","--mute-automation","--accept-no-undo","--accept-recreate","--accept-outside","--accept-unseen","--refuse-when-active","--yes"],values:[...P.values,"--checkpoint","--ignore-field","--object","--max-records"]},undo:{words:1,switches:[...P.switches,"--accept-automation","--accept-emails","--mute-automation","--yes"],values:[...P.values,"--checkpoint"]},delete:{words:1,switches:[...P.switches,"--all","--yes"],values:[...P.values,"--checkpoint"]},export:{words:1,switches:P.switches,values:[...P.values,"--checkpoint","--out","--key-env"]},import:{words:1,switches:P.switches,values:[...P.values,"--file","--key-env","--keep-days"]},replay:{words:1,switches:["--json","--dry-run","--verify","--remove","--preview","--sweep","--sweep-list","--sweep-late","--sweep-untied","--include-changed","--custom-settings","--mask","--keep-contact-points","--no-real-data","--again","--mute-automation","--accept-automation","--accept-emails","--yes",...ee.switches],values:["--store","--checkpoint","--from","--file","--key-env","--keep-days","--target","--objects","--exclude-object","--owners","--owner-map","--link","--replay-config","--max-records",...ee.values]},replays:{words:1,switches:["--json"],values:["--store","--target"]}},Fo={name:"--name",objects:"--object",excluded:"--exclude-object",customSettings:"--custom-setting",ignoredFields:"--ignore-field",maxTotal:"--max-total",keepDays:"--keep-days"},_o=/^[A-Za-z][A-Za-z0-9_]{0,79}$/;function I(e){process.stderr.write(`${e}
465
- `),process.exit(2)}function Bo(e){let t=e.toISOString();return`${t.slice(0,10)} ${t.slice(11,16)} UTC`}function Mo(e,t=new Date){let n=e.slice(2);(n.includes("--help")||n.includes("-h"))&&(process.stdout.write(Lo),process.exit(0));let o=n[0];if(o===void 0||o.startsWith("-"))return I("Name the command first: take, list, preview, rewind, undo, delete, export, import, replay or replays. Run with --help.");if(!Do(o))return I(`"${o}" is not a command of sandforge checkpoint: take, list, preview, rewind, undo, delete, export, import, replay or replays. Nothing was run. Run with --help.`);it(n,To[o]);let i=k=>{let d=[];for(let h=1;h<n.length;h++){if(n[h]!==k)continue;let b=n[h+1];if(b===void 0||b.startsWith("--"))return I(`${k} wants a value.`);d.push(b),h++}return d},s=k=>{let d=i(k);return d.length>1&&I(`${k} is given ${d.length} times: give it once.`),d[0]},c=k=>{let d=s(k);if(d!==void 0)return/^\d{1,15}$/.test(d)||I(`${k} takes a whole number, not "${d}".`),Number(d)},r=s("--store"),a={storeRoot:r!==void 0?_e(r):je(),...r!==void 0?{storeNamed:!0}:{},json:n.includes("--json")},u=s("--org"),g=()=>u??I(`${o} needs --org. Run with --help.`),m=k=>{n.includes("--yes")&&(k===void 0&&I(`${o} --yes needs --checkpoint <id|name>: one that does not ask is told which checkpoint it acts on. Nothing was run.`),k==="latest"&&I(`${o} --yes needs the checkpoint named by its id or its name, not latest: a checkpoint taken since would be the one it acts on. Nothing was run.`))},y=()=>{let k=i("--object"),d=k.find(h=>!_o.test(h));return d!==void 0&&I(`--object takes an object's API name, not "${d}".`),k.filter((h,b)=>k.findIndex($=>$.toLowerCase()===h.toLowerCase())===b)};switch(o){case"list":return{...a,command:o,...u!==void 0?{org:u}:{}};case"replay":return{...a,command:o,replay:Gt(n,I)};case"replays":return{...a,command:o,...Yt(n,I)};case"take":{let k=g(),d=i("--object"),h=i("--exclude-object"),b=i("--custom-setting"),$=b.includes("all")?"all":b,l=i("--ignore-field"),f=c("--max-total"),C={name:s("--name")??Bo(t),mode:d.length>0?"picked":"everything",...d.length>0?{objects:d}:{},...h.length>0?{excluded:h}:{},...$.length>0?{customSettings:$}:{},...l.length>0?{ignoredFields:l}:{},...f!==void 0?{maxTotal:f}:{},keepDays:c("--keep-days")??H},O=ht.safeParse({...C,orgId:"command-line"});if(!O.success){let S=O.error.issues[0],M=String(S?.path[0]??"");return I(`${Fo[M]??M}: ${S?.message??"not read"}. Nothing was run.`)}return{...a,command:o,org:k,take:{...C,name:O.data.name},estimate:n.includes("--estimate")}}case"preview":return{...a,command:o,org:g(),checkpoint:s("--checkpoint")??"latest",failOnChange:n.includes("--fail-on-change"),objects:y()};case"rewind":{let k=g(),d=s("--checkpoint");m(d);let h=i("--ignore-field"),b=Qe.safeParse(h);if(!b.success)return I(`--ignore-field: ${b.error.issues[0]?.message??"not read"}. Nothing was run.`);let $=c("--max-records");return $===0&&I('--max-records takes a whole number of 1 or more, not "0". Nothing was run.'),{...a,command:o,org:k,checkpoint:d??"latest",objects:y(),dryRun:n.includes("--dry-run"),acceptAutomation:n.includes("--accept-automation"),acceptEmails:n.includes("--accept-emails"),muteAutomation:n.includes("--mute-automation"),acceptNoUndo:n.includes("--accept-no-undo"),acceptRecreate:n.includes("--accept-recreate"),acceptOutside:n.includes("--accept-outside"),acceptUnseen:n.includes("--accept-unseen"),...$!==void 0?{maxRecords:$}:{},refuseWhenActive:n.includes("--refuse-when-active"),ignoreFields:h,yes:n.includes("--yes")}}case"undo":{let k=g(),d=s("--checkpoint");return m(d),{...a,command:o,org:k,...d!==void 0?{checkpoint:d}:{},acceptAutomation:n.includes("--accept-automation"),acceptEmails:n.includes("--accept-emails"),muteAutomation:n.includes("--mute-automation"),yes:n.includes("--yes")}}case"delete":{let k=g(),d=s("--checkpoint"),h=n.includes("--all");return h&&d!==void 0&&I("Give --checkpoint or --all, not both."),{...a,command:o,org:k,...h?{}:{checkpoint:d??"latest"},all:h,yes:n.includes("--yes")}}case"export":{let k=g(),d=s("--out")??I("export needs --out <file>. Run with --help."),h=Qt(s("--key-env"));return{...a,command:o,org:k,checkpoint:s("--checkpoint")??"latest",out:_e(d),...h!==void 0?{keyEnv:h}:{}}}case"import":{let k=g(),d=s("--file")??I("import needs --file <file>. Run with --help."),h=Qt(s("--key-env"));return{...a,command:o,org:k,file:_e(d),...h!==void 0?{keyEnv:h}:{},keepDays:c("--keep-days")??H}}}}function Qt(e){if(e!==void 0)return!/^[A-Za-z_][A-Za-z0-9_]{0,127}$/.test(e)||Y(e)!==void 0?I("--key-env takes the name of an environment variable that holds the key, never the key: a key on the command line stays in the shell\u2019s history and the list of processes. Nothing was run."):e}function an(e,t){return e!==void 0&&t!==void 0&&e.length>=15&&e.slice(0,15)===t.slice(0,15)}function K(e,t,n){let o=n!==void 0?[n]:[];for(let i of e){let s=i.checkpoint?.org;s!==void 0&&(s.alias===t||s.username.toLowerCase()===t.toLowerCase())&&o.push(i.organizationId)}return e.filter(i=>o.some(s=>an(s,i.organizationId)))}var cn="One kept in another folder is read with --store <folder>, or with SANDFORGE_JOURNAL_DIR set as when it was taken \u2014 in a CI job, a folder its cache restores; one taken on another machine comes here by export there, then import here.";function be(e){return`"${U("checkpoint")} list --org ${e}" names those it holds. ${cn}`}function ne(e,t,n,o){if(fe.safeParse(n).success){let s=e.find(c=>c.checkpointId===n);return s?{entry:s}:{none:`No checkpoint ${n} is kept in the folder read. ${be(o)}`}}if(n==="latest"){let s=t[0];return s?{entry:s}:{none:`No checkpoint of ${o} is kept in the folder read. ${be(o)}`}}let i=t.filter(s=>s.checkpoint?.name===n);return i.length===1?{entry:i[0]}:i.length===0?{none:`No checkpoint of ${o} named '${n}' is kept in the folder read. `+be(o)}:{ambiguous:`${i.length} checkpoints of ${o} are named '${n}': give the id of the one you mean with --checkpoint (${i.map(s=>s.checkpointId).join(", ")}).`}}function qe(e){if(e.valid)return;let t=e.checkpoint?`'${e.checkpoint.name}'`:e.checkpointId;switch(e.why){case"damaged":return{code:"DAMAGED",message:`The file of checkpoint ${e.checkpointId} cannot be read: it can only be deleted.`};case"taking":return{code:"TAKING",message:`The checkpoint ${t} is being taken, or its take never ended: it can be previewed once taken, or deleted.`};case"failed":return{code:"FAILED",message:`The take of checkpoint ${t} failed: it can only be deleted.`};case"refreshed":return{code:"OTHER_ORG",message:`This sandbox was refreshed${e.refreshedAt?` on ${e.refreshedAt.slice(0,10)}`:""}: it is another org now, and the checkpoint ${t} is of the org before it. It no longer rewinds. ${en(e)}`};case"scratchExpired":return{code:"SCRATCH_EXPIRED",message:`The scratch org of checkpoint ${t} has expired: its checkpoints no longer rewind it. ${en(e)}`};default:return{code:"INVALID",message:`The checkpoint ${t} cannot be previewed.`}}}function He(e){let t=e.checkpoint?.org,n=e.why==="refreshed"&&t!==void 0?t.alias??t.username:"<alias>";return`${X(e.checkpointId,n)} --dry-run`}function en(e){return`${Ae.replace(/\.$/,"")}: ${He(e)}`}function dn(e){return!e.valid&&(e.why==="refreshed"||e.why==="scratchExpired")}var p=e=>e.toLocaleString("en-US");function _(e){let t=new Date(Date.parse(e)).toISOString();return`${t.slice(0,10)} ${t.slice(11,16)} UTC`}function Be(e){let t=new Date(Date.parse(e)).toISOString();return`${t.slice(0,10)} ${t.slice(11,19)} UTC`}var J=e=>`${Q(e/(1024*1024))} MB`;function A(e,t=8){if(e.length===0)return"\u2014";let n=e.slice(0,t).join(", ");return e.length>t?`${n} \u2026 (+${e.length-t})`:n}function he(e){return e.objects.reduce((t,n)=>t+n.records,0)}function Ge(e){return e===null?"kept until you delete it":`kept until ${_(e)}`}function oe(e){return e.org.alias??e.org.username}var Uo=/^Left out(?::\s*|\s+(?=as asked\b))/;function hn(e,t){let n=[...t,...e.flatMap(({code:s,records:c})=>s==="pastTheLimit"&&c!==void 0?[c]:[])],o=n.filter(s=>s<=G).reduce((s,c)=>s+c,0),i=new Map;for(let{objectApiName:s,reason:c,code:r,records:a}of e){let u=c;if(r==="pastTheLimit"&&a!==void 0&&a<=G){let g=bt(n,a);u=g>G?`${c} With it, every object no larger is kept, more than ${G} records in all, past any --max-total: --exclude-object <ApiName> leaves some out.`:`${c} --max-total ${g}${g===o?" or more":""} holds it.`}i.set(u,[...i.get(u)??[],s])}return[...i].map(([s,c])=>` left out: ${A(c)} \u2014 ${s.replace(Uo,"")}`)}var zo={fls:"hidden from the user SandForge connects as by field-level security: Rewind won\u2019t put them back",encrypted:"encrypted, and the user SandForge connects as can\u2019t view encrypted data: Rewind won\u2019t touch them",base64:"the content of files and other binary values, which a checkpoint doesn\u2019t hold",compound:"compound fields, kept through the fields they are made of"};function ln(e){let t=new Map;for(let n of e)for(let{field:o,reason:i}of n.leftOutFields)t.set(i,[...t.get(i)??[],`${n.objectApiName}.${o}`]);return[...t].map(([n,o])=>` fields left out (${o.length}): ${A(o)} \u2014 ${zo[n]??n}`)}function un(e){let t=e.filter(n=>!n.undeletable).map(n=>n.objectApiName);return t.length===0?[]:[` deleted ${A(t)} records come back from the recycle bin only with their parent`]}function fn(e){return` about ${p(e.seconds)} s \xB7 about ${p(e.apiRequests)} API requests of the ${p(e.apiRequestsLeft)} left today`+(e.bytes>0?` \xB7 about ${J(e.bytes)} on this machine`:"")}var tn={damaged:"its file cannot be read: it can only be deleted",taking:"being taken, or its take never ended: it can only be deleted unless it ends",failed:"its take failed: it can only be deleted",refreshed:"of the org before its refresh: it no longer rewinds, and replays into another org",scratchExpired:"its scratch org has expired: it no longer rewinds, and replays into another org"};function Wo(e,t,n){if(e.length===0&&n!==void 0){let i=n.kept===0?"":`, which keeps ${n.kept===1?"1 of another org":`${n.kept} of other orgs`}: "${U("checkpoint")} list" names ${n.kept===1?"it":"them"}`;return[`No checkpoint of ${n.org} is kept in ${t}${i}. ${cn}`]}if(e.length===0)return[`No checkpoint is kept in ${t}.`];let o=[];for(let i of e){let s=i.checkpoint;if(!s){o.push(`${i.checkpointId} ${tn.damaged}`);continue}if(o.push(`${i.checkpointId} '${s.name}' ${oe(s)} taken ${_(s.takenAt)} ${p(he(s))} records in ${s.objects.length} objects ${J(s.bytes)} `+Ge(s.expiresAt)),!i.valid){let c=i.why==="refreshed"&&i.refreshedAt?`refreshed on ${i.refreshedAt.slice(0,10)}: `:"";o.push(` ${c}${tn[i.why??""]??"it cannot be previewed"}`),dn(i)&&(o.push(` replay it: ${He(i)}`),s.expiresAt!==null&&o.push(` deleted from this machine on ${_(s.expiresAt)}: to replay it after, Keep it in the editor, or export it and replay the file`))}i.scratchExpiresSoon&&s.org.scratchExpiresAt!==void 0&&o.push(` its scratch org expires on ${s.org.scratchExpiresAt.slice(0,10)}: its checkpoints then no longer rewind it, whatever --keep-days said, and still replay into another org`),i.expiresSoon&&s.expiresAt!==null&&o.push(` expires on ${_(s.expiresAt)}: take a new one, or keep this one in the editor`),i.binReachSince&&o.push(` records deleted before ${i.binReachSince.slice(0,10)} can't come back with their Id (recycle bin), sooner if the bin fills: a rewind makes them again, with new Ids`),i.undo&&o.push(` rewound: the rewind can be undone until ${_(i.undo.until)}`)}return o}function qo(e){let t=e.checkpoint;return{id:e.checkpointId,name:t?.name??null,org:t?oe(t):null,organizationId:e.organizationId,takenAt:t?.takenAt??null,records:t?he(t):null,bytes:t?.bytes??null,expiresAt:t?t.expiresAt:null,expiresSoon:e.expiresSoon===!0,scratchExpiresSoon:e.scratchExpiresSoon===!0,binReachSince:e.binReachSince??null,...t?.lastRewind?{lastRewind:{...t.lastRewind,undoable:e.undo!==void 0}}:{},valid:e.valid,...e.why!==void 0?{why:e.why}:{},...e.refreshedAt!==void 0?{refreshedAt:e.refreshedAt}:{},...dn(e)?{replayWith:He(e)}:{}}}function pn(e){return e.refusal!==void 0&&e.objects.length===0&&e.leftOut.length===0}function Ho(e){return pn(e)?{mode:e.mode,refusal:e.refusal}:{...e}}function Me(e){if(e.code!=="TOO_MANY_RECORDS")return e;let t="pick fewer objects (--exclude-object <ApiName> leaves one out)",n=`(${p(Ce)} unless given)`,o=e.holdingLimit,i=o===void 0?`${t}, or raise the limit with --max-total <n> ${n}`:o>G?`${t}: no --max-total holds them all, ${p(G)} at most`:`${t}, or raise the limit with --max-total ${o} ${n}`;return{...e,message:e.message.replace(/: pick fewer objects\./,`: ${i}.`)}}function Go(e,t){if(pn(t))return[`refused: ${t.refusal.message}`];let n=t.objects.filter(i=>i.records>0).length,o=new Map;for(let{namespace:i}of t.objects)i!==void 0&&o.set(i,(o.get(i)??0)+1);return[`a checkpoint of ${e} would keep ${t.objects.length} objects (${n} hold records; ${t.objects.length-n} are empty \u2014 what is created there later is caught too), about ${p(t.estimate.records)} records`,...[...o].map(([i,s])=>` includes ${s} objects of the ${i} package`),fn(t.estimate),...hn(t.leftOut,t.objects.map(i=>i.records)),...ln(t.objects),...un(t.objects),...t.files?Ko(t.files):[],...Yo(t),...t.refusal?[`refused: ${Me(t.refusal).message}`]:[]]}function mn(e){let t=e.records===void 0?void 0:`${p(e.records)} ${e.records===1?"row":"rows"}`,n=[e.kind,t].filter(o=>o!==void 0);return n.length>0?`${e.objectApiName} (${n.join(", ")})`:e.objectApiName}function gn(e){return mn({objectApiName:e.objectApiName,...e.customSetting!==void 0?{kind:e.customSetting}:{},records:e.records})}function Yo(e){let t=e.objects.filter(i=>i.customSetting!==void 0),n=new Set(t.map(i=>i.objectApiName)),o=(e.customSettings??[]).filter(i=>!n.has(i.objectApiName));return[...t.length>0?[` custom settings kept: ${A(t.map(gn))} \u2014 a rewind sets their rows back as the checkpoint holds them, whoever changed them since`]:[],...o.length>0?[` custom settings not kept: ${A(o.map(mn))} \u2014 --custom-setting <ApiName|all> keeps them`]:[]]}function Ko(e){return e.held?[" files: it keeps which files are attached to its records (Salesforce Files, classic attachments) and each file's latest version, not its content; a rewind deletes the files attached to them since and brings back those deleted since. A file attached to no record it holds, a user's own or a library's, is left as it is",...wn(e.addedToPicked),...e.queryAllFiles?[]:[Ye]]:[" files: not kept \u2014 a rewind leaves the files attached since as they are"]}function wn(e){return e.length>0?[` added to the objects picked: ${e.join(", ")} \u2014 without them a rewind would leave the files attached since as they are`]:[]}var Ye=" the user the alias connects as doesn't have Query All Files: other users' files that no record of the checkpoint is attached to (in a library the user is not a member of, say) are not seen, nor counted among the files left; files attached to its records are seen";function Jo(e,t,n=[]){let o=e.movedWhileTaken,i=o.changed+o.deleted+o.created;return[`taken '${e.name}' (${e.checkpointId}) of ${oe(e)}: ${p(he(e))} records in ${e.objects.length} objects, ${J(e.bytes)} on this machine, ${Ge(e.expiresAt)}`,` of ${Be(e.readFrom)}, read until ${Be(e.takenAt)} on the org's clock`,...i>0?[` ${p(i)} records changed while it was taken (${o.changed} changed, ${o.deleted} deleted, ${o.created} created): it holds them as they were read, and a rewind treats them as changed since. Take checkpoints when nobody works in the org.`]:[],...hn(e.scope.leftOut,e.objects.map(s=>s.records)),...ln(e.objects),...e.ignoredFields.length>0?[` not compared, nor written back (you chose): ${e.ignoredFields.join(", ")}`]:[],...un(e.objects),...Vo(e.objects),...e.files?Zo(e,e.files,n):[],` it holds the records' values unencrypted, in files only you can read: ${t}`]}function Vo(e){let t=e.filter(n=>n.customSetting!==void 0);return t.length===0?[]:[` custom settings kept: ${A(t.map(gn))} \u2014 a rewind sets their rows back as the checkpoint holds them`]}function Zo(e,t,n){let o=t.readByIds??[],i=new Set(n.map(r=>r.toLowerCase())),s=new Set(e.objects.map(({objectApiName:r})=>r.toLowerCase())),c=e.scope.mode==="picked"?ct.filter(r=>s.has(r.toLowerCase())&&!i.has(r.toLowerCase())):[];return[` files: ${p(t.anchored)} attached to its records by ${p(t.links)} link(s): a rewind takes back what is attached to them since`,...wn(c),...o.length>0?[` the links of ${A(o)} were read by lists of record Ids: ${oe(e)} refused one query, or answered too late`]:[],...e.takenBy.queryAllFiles===!1?[Ye]:[]]}function Xo(e,t){let n=Object.entries(e.byPhase).map(([i,s])=>{let c=t?.requestsByPhase?.[i];return c===void 0||c===s?`${i} ${s}`:`${i} ${s} (${c})`}),o=t?`, about ${p(t.apiRequests)} estimated`:"";return` sent ${p(e.total)} API requests to the org${o}: ${n.join(", ")}`}var nn=e=>e.toDelete.createdSince+e.toDelete.broughtBackSince+e.toDelete.comesBackWithParent,ie=e=>e.toBringBack.inBin+e.toBringBack.withParent+e.toBringBack.deletedWhileTaken,Ue=e=>e.cannotUndo.reduce((t,n)=>t+n.count,0),de=e=>e.toRecreate??0,$e=e=>e.toBringBack.carriers??0;function kn(e){let t=e.files;return t===void 0?0:t.unlink+t.relink+t.updateLinks}function Qo(e){let t=e.files;return t===void 0?0:t.outsideAdded+t.outsideDeleted}function ei(e){let t=e.schemaDrift;return t===void 0?0:t.removed.length+(t.hidden?.length??0)+(t.uncertain?.fields.length??0)}function Ke(e){let t=se(e);return t.toDelete+t.toGiveBack+t.toBringBack+t.toRecreate>0||kn(e)+Qo(e)>0||e.objects.some(n=>Ue(n)>0||n.unexplained>0||ei(n)>0)||e.unread.length>0}var ti={goneForGood:"deleted since and no longer in the recycle bin, and not made again \u2014 a file, whose body the checkpoint does not hold, or a record deleted while it was taken: they can\u2019t come back",convertedLead:"leads converted since: Salesforce can\u2019t unconvert a lead",activatedContract:"contracts activated since: Salesforce won\u2019t set them back to Draft",deletedWithCreatedParent:"deleted with a parent created since that Salesforce does not undelete on its own: they come back with that parent only",deletedWithParentOutside:"deleted with their parent, a record of an object the checkpoint does not hold: they come back with that parent only, which a checkpoint that holds its object brings back",newFileVersion:"files given a new version since: Salesforce deletes no version and won\u2019t make an older one the latest again, so they keep their new content; the content each had is still in its version history, and their titles are given back",deletedByOther:"deleted since by another user: only View All Data and Modify All Data restore those; they stay in the recycle bin, never made again",outOfReach:"out of reach: without View All Data and Modify All Data, nothing shows what others deleted of an object held through the records it hangs from; they may be in the recycle bin out of sight, and are never made again"},ni=[{reason:"onlyWithParent",preview:"Salesforce undeletes them only with their parent, and their parent stays",result:"Salesforce undeletes them only with their parent"},{reason:"deletedBeforeParent",preview:"deleted before a record they point at, which the rewind deletes next: Salesforce cannot bring them back after that",result:"deleted before a record they point at, which the rewind deleted next: Salesforce cannot bring them back after that"}];function yn(e){return ni.flatMap(t=>{let n=e.filter(o=>(o.reason??"onlyWithParent")===t.reason);return n.length>0?[{words:t,of:n}]:[]})}function oi(e,t){let{automation:n,deliverability:o}=t;if(!n||!o)return[];let i=ae(t.diff),{line:s}=mt({act:"rewind",orgName:e,automation:n,steps:i,accepted:!0,mayMute:!1,...pt({automation:n,steps:i}),reading:o.reading}).gate;return s!==void 0?[` ${s}`]:[]}function ii(e,t){return t.map(n=>{let o=[...new Set(n.objects.flatMap(s=>s.sentBy))],i=` emails: ${e}'s automation sends about ${ft(n.emails,n.limit)} as the rewind writes (${A(o,4)})`+(n.alertsCounted?`, its email alerts among them: ${e} counts them against its single emails, as a Developer Edition does`:"");return n.verdict==="unread"?`${i}; what it has left today could not be read (${n.unread??""})`:n.verdict==="fits"?`${i}; ${n.remaining??0} of ${n.max??0} left today`:`${i}, more than the ${n.remaining??0} of ${n.max??0} left today: a rewind is refused`})}function ri(e,t){if(!e||t.length===0)return"";let n=Re(e,{giveBack:t}).map(o=>`${o.objectApiName}: '${o.name}'`);return n.length>0?`, on which runs ${A(n,4)}`:""}function si(e,t,n=[]){let o=e.objects.filter(r=>at[r.objectApiName]!==void 0),i=o.filter(r=>de(r)>0),s=o.filter(r=>ie(r)>0&&!n.includes(r.objectApiName)),c=[];return i.length>0&&c.push(` made as drafts first: ${A(i.map(r=>`${r.objectApiName} ${p(de(r))}`))} \u2014 Salesforce refuses an order or a contract made past Draft, and an order takes its products only as a draft: one past Draft at the checkpoint is made at the org's Draft status, the records under it next, then given its status back, an update`+ri(t,i.map(r=>r.objectApiName))),s.length>0&&c.push(` if Salesforce answers that an order or a contract to bring back is no longer in the recycle bin, --accept-recreate makes it again as a draft, then gives it its status back, an update: ${A(s.map(r=>`${r.objectApiName} ${p(ie(r))}`))}`),c}function ai(e,t,n=!1){if(!t)return{objects:[],fired:[]};let o=ae(e),i=[],s=new Set;for(let c of e.objects){if(ie(c)===0)continue;let r=Et(t,o,[c.objectApiName],n);if(!(r.fired.length===0&&!r.blind)){i.push(c.objectApiName);for(let a of r.fired)s.add(`${a.objectApiName}: '${a.name}'`)}}return{objects:i,fired:[...s]}}function ci(e,t,n){let o=Re(t,n),i=[];for(let c of t.objects){let r=o.filter(m=>m.objectApiName===c.objectApiName),a=[...new Set(r.filter(m=>m.kind!=="trigger").map(m=>`'${m.name}'`))],u=[...new Set(r.filter(m=>m.kind==="trigger").map(m=>m.name))],g=[...a.length>0?[`${a.length} flow(s) or rule(s): ${A(a,4)}`]:[],...u.length>0?[`${u.length} Apex trigger(s): ${A(u,4)}`]:[]];g.length>0&&i.push(` ${c.objectApiName}: ${g.join("; ")}`)}return[...i.length>0?[` what ${e} runs as a rewind writes (updates, deletes, records brought back):`]:[],...i,...t.unread.map(c=>` not read of its automation: ${c.part} \u2014 ${c.reason}`)]}function bn(e,t,n,o="the user SandForge connects as",i=!1){let{diff:s}=n,c=se(s),r=[`Rewind ${e} to '${t.name}' (${_(t.takenAt)}), read at ${Be(s.readAt)}:`,` ${p(c.toDelete)} to delete \xB7 ${p(c.toGiveBack)} to give back \xB7 ${p(c.toBringBack)} to bring back`+(c.toRecreate>0?` \xB7 ${p(c.toRecreate)} to make again`:"")];!Ke(s)&&!s.objects.some(l=>l.outside.length>0)&&r.push(` ${e} is as it was at '${t.name}' among the objects and fields it holds: nothing to rewind.`);let a=s.objects.filter(l=>nn(l)+l.toGiveBack.records+ie(l)+de(l)+Ue(l)>0);if(a.length>0){let l=Math.max(6,...a.map(f=>f.objectApiName.length));r.push(` ${"Object".padEnd(l)} ${"Delete".padStart(8)} ${"Give back".padStart(9)} ${"Bring back".padStart(10)} ${"Can't undo".padStart(10)}`);for(let f of a)r.push(` ${f.objectApiName.padEnd(l)} ${p(nn(f)).padStart(8)} ${p(f.toGiveBack.records).padStart(9)} ${p(ie(f)).padStart(10)} ${p(Ue(f)).padStart(10)}`)}let u=new Map;for(let l of s.objects)for(let[f,C]of Object.entries(l.lastChangedBy))u.set(f,(u.get(f)??0)+C);u.size>0&&r.push(` last changed by: ${[...u].sort((l,f)=>f[1]-l[1]).map(([l,f])=>`${s.userNames[l]??l} ${p(f)}`).join(" \xB7 ")}`),s.activeLastHour.length>0&&r.push(` people working in ${e} in the last hour: ${s.activeLastHour.map(l=>s.userNames[l]??l).join(", ")}`);let g=s.objects.filter(l=>l.touched>0);g.length>0&&r.push(` touched since but holding their checkpoint values: ${A(g.map(l=>`${l.objectApiName} ${p(l.touched)}`))}`);let m=s.objects.filter(l=>$e(l)>0);m.length>0&&r.push(` brought back for a moment: ${A(m.map(l=>`${l.objectApiName} ${p($e(l))}`))} \u2014 records the checkpoint does not hold that took records of it along when deleted since: Salesforce gives those back with them only, so they come back, then go back to the recycle bin with what came back with them; what the org runs on them runs twice`);let y=new Map;for(let l of s.objects)for(let f of l.cannotUndo)f.count!==0&&y.set(f.reason,[...y.get(f.reason)??[],`${l.objectApiName} ${p(f.count)}`]);for(let[l,f]of y)r.push(` can't be taken back: ${A(f)} \u2014 ${ti[l]??l}`);let k=s.objects.filter(l=>de(l)>0);k.length>0&&r.push(` to make again, with new Ids: ${A(k.map(l=>`${l.objectApiName} ${p(de(l))}`))} \u2014 deleted since and no longer in the recycle bin: made again from the checkpoint, the lookups it holds that named them naming the new Ids; anything outside Salesforce that names their old Ids no longer finds them`);let d=c.toBringBack>0?ai(s,n.automation,i):void 0;if(d){let l=d.fired.length>0?`making them again runs ${A(d.fired,4)}`:"what runs as they are made again could not all be read";r.push(" if Salesforce answers that a record to bring back is no longer in the recycle bin \u2014 it still lists one emptied from it as deleted \u2014, --accept-recreate makes it again with a new Id, with what was to come back with it; without it, the rewind leaves them and names them"+(d.objects.length>0?`; ${A(d.objects)} records it leaves all the same, with what was to come back with them, and names them: ${l}, which this rewind does not ask about \u2014 a rewind after it counts them to make again, and asks`:""))}r.push(...si(s,n.automation,d?.objects));let h=s.objects.filter(l=>l.unexplained>0);h.length>0&&r.push(` left as they are: ${A(h.map(l=>`${l.objectApiName} ${p(l.unexplained)}`))} \u2014 records the checkpoint doesn't hold although they're dated before it (a load with back-dated creation dates?); a rewind deletes nothing it cannot prove was created since`);for(let{words:l,of:f}of yn(s.undoCannot))r.push(` undo couldn't bring back: ${A(f.map(C=>`${C.objectApiName} ${p(C.count)}`))} \u2014 ${l.preview}`);for(let{objectApiName:l,children:f,records:C}of s.unseen??[])r.push(` also deleted with them, out of sight: deleting ${p(C)} ${l} also deletes what ${o} can't see under them in ${A(f)}; Rewind can't count those, and deletes them only with --accept-unseen`);for(let l of s.objects)for(let f of l.outside)r.push(l.objectApiName===$n&&f.objectApiName===di?` also attached outside the checkpoint: ${p(f.parents)} file(s) it deletes, by ${p(f.count)} link(s) to a library, a group or a record of another object \u2014 deleting them removes them from there as well`:` also deleted with them, outside the checkpoint: ${p(f.count)} ${f.objectApiName} created under ${p(f.parents)} ${l.objectApiName}`);r.push(...hi(e,s));let b=s.objects.flatMap(l=>{let f=l.schemaDrift,C=new Set([...f?.removed??[],...f?.hidden??[],...f?.uncertain?.fields??[]]);return l.notCompared.filter(O=>!C.has(O)).map(O=>`${l.objectApiName}.${O}`)});b.length>0&&r.push(` not compared (you chose): ${A(b)}`);for(let l of s.objects){let f=l.schemaDrift;if(!f)continue;let C=O=>O.map(S=>`${l.objectApiName}.${S}`);f.removed.length>0&&r.push(` fields deleted since: ${A(C(f.removed))} \u2014 restore them from Deleted Fields, then rewind`),(f.hidden??[]).length>0&&r.push(` fields hidden from ${o} by field-level security since: ${A(C(f.hidden??[]))} \u2014 rewind does not put them back; give ${o} read and edit access to them, then rewind again`),f.uncertain!==void 0&&f.uncertain.fields.length>0&&r.push(` fields gone from what ${e} shows ${o}: ${A(C(f.uncertain.fields))} \u2014 deleted since (restore them from Deleted Fields within 15 days), or hidden by field-level security (give ${o} read and edit access); rewind does not put them back`+(f.uncertain.reason!==void 0?` (which, ${e} would not say: ${f.uncertain.reason})`:"")),f.added.length>0&&r.push(` fields added since, their values left alone: ${A(C(f.added))}`),f.changed.length>0&&r.push(` fields changed since, tried one by one: ${A(C(f.changed))}`)}let $=s.fieldsNotChecked??0;$>0&&r.push(` fields not checked for changes in ${p($)} objects nothing changed in: a rewind writes nothing there`);for(let l of s.unread)r.push(` could not be read: ${l.objectApiName} \u2014 ${l.reason} (never taken for unchanged)`);return n.automation&&r.push(...ci(e,n.automation,ae(s))),n.emails&&r.push(...ii(e,n.emails)),n.emailsUncounted!==void 0&&r.push(` emails: not counted, ${n.emailsUncounted} could not be read \u2014 what they send as the rewind writes is not known; --accept-automation covers it`),r.push(...oi(e,n)),r.push(fn(n.estimate)),n.refusal&&r.push(` a rewind now would be refused (${n.refusal.code}): ${n.refusal.message}`),r}var $n="ContentDocument",di="ContentDocumentLink";function hi(e,t){let n=t.files;if(n===void 0)return[];let o=[];n.unlink>0&&o.push(` links to remove: ${p(n.unlink)} added since between a file and a record that both stay \u2014 the file stays, no longer attached to that record`),n.relink>0&&o.push(` links to put back: ${p(n.relink)} removed since between a file and a record that both stay, each under a new Id: Salesforce keeps no removed link in the recycle bin`),n.updateLinks>0&&o.push(` links to give their sharing back: ${p(n.updateLinks)} \u2014 who sees the file from the record, and with what access; a link to an account keeps its access, which Salesforce doesn't let change`),n.outsideAdded>0&&o.push(` kept: ${p(n.outsideAdded)} file(s) added since, as no record of this checkpoint links to them (a user's own, a library's)`),n.outsideDeleted>0&&o.push(` left in the recycle bin: ${p(n.outsideDeleted)} file(s) deleted since, as no record of this checkpoint linked to them`);let i=t.objects.find(r=>r.objectApiName===$n),s=i===void 0?0:ie(i),{storage:c}=n;return s>0&&c.bringBack>0&&o.push(` file storage: bringing back ${p(s)} file(s) takes ${J(c.bringBack)} again; `+(c.remaining===void 0?`${e} did not say how much it has left`:`${e} has ${J(c.remaining)} left`)),c.undo>0&&o.push(` undo would bring back the files this rewind deletes: ${J(c.undo)} of file storage again`),n.blindSpot&&o.push(Ye),o}function vn(e,t,n,o,i){let s=o?.diff??i?.diff??n.diff;return{checkpoint:{id:t.checkpointId,name:t.name,takenAt:t.takenAt,org:e},...o?{objects:[...o.plan.objects]}:{},...se(s),carriers:s.objects.reduce((c,r)=>c+$e(r),0),differs:Ke(o?.diff??n.diff),...o?{selection:o.plan}:{},...i?{kept:i.plan.left}:{},diff:n.diff,estimate:n.estimate,...n.automation?{automation:n.automation}:{},...n.emails?{emails:n.emails}:{},...n.emailsUncounted!==void 0?{emailsUncounted:n.emailsUncounted}:{},...n.deliverability?{deliverability:n.deliverability}:{},...n.refusal?{refusal:n.refusal}:{}}}function li(e,t){return t&&Ke(e)?3:0}var An={needsUnpickedParent:"they come back only with a parent this rewind leaves deleted, or look up a record it leaves deleted, which Salesforce refuses: those lookups are left, the rest written",heldByUnpicked:"records of an object not named made since hang from them and hold some of their values in place: given back but for those",outsideNotAccepted:"records of an object not named made since hang from them, which their deletion would take along: kept, unless --accept-outside",holdsLeft:"records this rewind leaves as they are hang from them, which their deletion would take along: kept",keyTaken:"rows of a custom setting whose owner or name a row made since holds: brought back once it is gone"};function Rn(e){let t=[` limited to ${e.objects.join(", ")}: the other objects are left as they are, and what still differs in them is counted apart`],n=e.acts.filter(o=>!o.picked&&o.toDelete>0);n.length>0&&t.push(` also deletes again ${A(n.map(o=>`${o.objectApiName} ${p(o.toDelete)}`))} \u2014 made since, they come back with a record it brings back: leaving them would make a state that never existed`);for(let o of e.left)t.push(` left: ${p(o.count)} ${o.objectApiName} record(s) \u2014 ${An[o.reason]}`);return e.needs.length>0&&t.push(` to rewind those too, add ${e.needs.map(o=>`--object ${o.objectApiName} (${p(o.records)} record(s) need it)`).join(", ")}`),e.acts.some(o=>o.picked&&o.toDelete>0)&&t.push(" a record of an object not named that looks up a record it deletes has that lookup emptied by Salesforce, and is dated that second"),t}function jn(e,t,n){return!n&&e.scope.mode==="picked"&&t.objects.some(o=>o.outside.length>0)}function Cn(e){return e.left.map(t=>` kept: ${p(t.count)} ${t.objectApiName} record(s) \u2014 `+(t.reason==="outsideNotAccepted"?"records outside the checkpoint made since hang from them, which their deletion would take along: kept, unless --accept-outside":An[t.reason]))}async function On(e,t,n,o){if(!jn(t,n,o))return;let i=t.objects.map(({objectApiName:s})=>s);return Je(e,n,i,!1)}function Sn(e,t){let n=new Map(e.objects.map(({objectApiName:i})=>[i.toLowerCase(),i])),o=t.filter(i=>!n.has(i.toLowerCase()));if(o.length>0)throw new v({code:"NOT_HELD",message:`--object: '${e.name}' holds no ${o.join(", ")}. It holds ${A(e.objects.map(i=>i.objectApiName))}. Nothing was run.`},2);return t.flatMap(i=>n.get(i.toLowerCase())??[])}async function Je(e,t,n,o){let i=await e.request({type:"checkpoint:plan-selection",payload:{checkpointId:t.checkpointId,previewId:t.previewId,objects:[...n],acceptOutside:o},timeoutMs:ve});if(i.outcome!=="answered")throw new v(W(i,"The plan of the objects named"));let s=z(i).plan;return{plan:s,diff:St(t,s)}}var le={limit:e=>`--max-records ${e}`,mutes:!0,lift:{acceptAutomation:"give --accept-automation to rewind all the same",acceptEmails:"add --accept-emails to rewind all the same",acceptNoUndo:"give --accept-no-undo to rewind all the same",acceptRecreate:"give --accept-recreate to rewind all the same",acceptUnseen:"give --accept-unseen to rewind all the same",maxRecords:"read its preview (--dry-run), then give a --max-records that holds it",refuseWhenActive:"rewind once they are done, or without --refuse-when-active"}};function ui(e){return e.code==="AUTOMATION"?{...e,message:e.message.replace(xt,le.lift.acceptAutomation)}:e}function fi(e){return e.code==="AUTOMATION"?{...e,message:e.message.replace(Lt,"give --accept-automation to undo the rewind all the same")}:e}function Nr(e,t,n,o="the user SandForge connects as"){return It(e,t,n,le.lift,o,le.mutes)}var pi={acceptAutomation:!1,acceptNoUndo:!1,acceptRecreate:!1};function En(e,t){return[...e?[e]:[],...t.filter(n=>n.code!==e?.code)]}function mi(e,t,n,o){let i=o!==void 0&&o.length>0?`${o.join(", ")} of ${e}`:e,s=se(n),c=s.toRecreate>0?`, and makes ${p(s.toRecreate)} record(s) the recycle bin no longer holds again, with new Ids`:"",r=n.objects.reduce((m,y)=>m+$e(y),0),a=r>0?`, with ${p(r)} record(s) brought back for a moment that had taken records of the checkpoint along, then deleted again`:"",u=kn(n),g=u>0?`, and puts ${p(u)} link(s) between files and records back as they were`:"";return`Rewind ${i} to '${t.name}': it deletes the ${p(s.toDelete)} record(s) created since ${_(t.takenAt)}, gives ${p(s.toGiveBack)} record(s) their values from then back, and brings back ${p(s.toBringBack)} record(s) from the recycle bin${a}${c}${g} \u2014 whoever made these changes. What it changes is kept, so it can be undone. Type ${e} to rewind it:`}var E=(e,t)=>e.reduce((n,o)=>n+t(o),0);function Ve(e){let t=E(e.deleted,r=>r.deleted),n=E(e.deleted,r=>r.planned),o=E(e.restored,r=>r.restored+(r.restoredWithout??0)),i=E(e.restored,r=>r.planned),s=E(e.undeleted,r=>r.undeleted+r.alreadyBack),c=E(e.undeleted,r=>r.planned);return{deleted:{planned:n,done:t,left:Math.max(0,n-t-E(e.deleted,r=>r.alreadyGone))},givenBack:{planned:i,done:o,left:Math.max(0,i-o-E(e.restored,r=>r.alreadyGone))},broughtBack:{planned:c,done:s,left:Math.max(0,c-s)}}}function In(e){let t=e.recreated??[],n=E(t,i=>i.planned),o=E(t,i=>i.created);return{planned:n,done:o,left:Math.max(0,n-o)}}function gi(e){return(e.remade??[]).reduce((t,n)=>{let o=E(e.deleted.filter(i=>i.objectApiName===n.objectApiName),i=>i.deleted);return t+Math.min(o,n.count)},0)}function Nn(e,t){return e===void 0?"another user":t[e]??e}function wi(e,t,n){switch(t.reason){case"automation":return e==="rewind"?"kept by your automation, which sets them again on save: rewind --ignore-field <Object.Field> stops comparing such a field":"set again on save by your automation, since the undo gave them back their values";case"changedDuringRewind":return`changed during the ${e} by ${Nn(t.by,n)}: left as they made them`;case"changedSincePreview":return"changed since the preview: rewind again to take them";case"refused":return`refused: ${t.message??"the org gave no reason"}`;case"notInBin":return"no longer in the recycle bin \u2014 emptied from it, or kept there for good \u2014: Salesforce still lists them as deleted but will not bring them back; --accept-recreate makes them again with new Ids";case"goneForGood":return"deleted since and no longer in the recycle bin, and not made again (a file, whose body the checkpoint does not hold, or a record deleted while it was taken): they can't come back";case"kept":return t.message??"kept as they are"}}function xn(e,t){return`Stopped before it wrote anything: ${e} is as it was before this rewind. Rewind again to rewind it to '${t}'.`}function ki(e,t,n,o={},i){let s=E(n.residual,d=>d.count),c=n.residual.filter(d=>d.reason==="changedDuringRewind"),r={success:`${e} is back at '${t.name}': read again, nothing differs among the objects and fields it holds.`,partial:`${e} is back at '${t.name}' but for ${p(s)} record(s) that still differ, each said with why:`,unstable:`Someone kept writing to ${e} during the rewind: ${[...new Set(c.map(d=>Nn(d.by,o)))].join(", ")} changed ${p(E(c,d=>d.count))} record(s), left as they made them. Rewind again once they have stopped.`,failure:`Nothing of the rewind of ${e} to '${t.name}' went through: what still differs is said with why:`,cancelled:n.undo===void 0?xn(e,t.name):`Stopped part way: ${e} is between '${t.name}' and now. Rewind again to finish: it takes up from what still differs, and undo still returns ${e} to how it was before the rewind.`},a=n.scope;a!==void 0&&n.status==="success"&&(r.success=`${a.objects.join(", ")} of ${e} ${a.objects.length>1?"are":"is"} back at '${t.name}': read again, nothing differs among them.`);let u=Ve(n),g=E(n.undeleted,d=>d.alreadyBack),m=[r[n.status]];if(a!==void 0){let{objects:d,records:h}=a.notRewound;m.push(h>0?` not rewound: ${p(h)} record(s) of ${A(d)} still differ, left as they are \u2014 the rewind was limited to the objects named; add them with --object`:" the objects not named match the checkpoint too")}u.deleted.done>0&&m.push(` deleted ${p(u.deleted.done)} record(s) added since the checkpoint \u2014 created, or brought back from the recycle bin they were in when it was taken \u2014 (in the recycle bin for up to 15 days)`),u.givenBack.done>0&&m.push(` gave ${p(u.givenBack.done)} record(s) back their checkpoint values`),u.broughtBack.done>0&&m.push(` brought back ${p(u.broughtBack.done-g)} record(s) deleted since the checkpoint, with their original Ids`+(g>0?`, and ${p(g)} that came back with them`:""));let y=n.status==="failure"?[]:n.carriers??[];if(y.length>0){let d=A(y.map(h=>`${h.objectApiName} ${p(h.count)}`));m.push(n.status==="cancelled"?` of them, brought back for a moment: ${d} \u2014 records the checkpoint does not hold that had taken records of it along; stopped before it was through, those it had not deleted again yet are still in the org: rewind again deletes them, with what came back with them`:` of them, brought back for a moment and deleted again: ${d} \u2014 records the checkpoint does not hold that had taken records of it along, back in the recycle bin with what came back with them`)}let k=In(n);k.done>0&&m.push(` made again ${p(k.done)} record(s) the recycle bin no longer held, with new Ids`);for(let d of n.draftsLeft??[])m.push(` left as drafts: ${d.objectApiName} ${p(d.count)} (${A(d.ids,3)}) \u2014 made again as drafts, the rewind stopped before it gave them back the status the checkpoint holds: rewind again gives it back to them, an update`);if(m.push(...Pn("rewind",e,n)),m.push(...Dn("rewind",n,o)),n.undo){m.push(` undo it until ${_(n.undo.until)}, sooner if the recycle bin fills: ${U("checkpoint")} undo --org ${e} --checkpoint ${t.checkpointId}`+(i!==void 0?` --store ${i}`:""));for(let{words:d,of:h}of yn(n.undo.cannot))m.push(` undo couldn't bring back: ${A(h.map(b=>`${b.objectApiName} ${p(b.count)}`))} \u2014 ${d.result}`)}for(let d of n.removedJournals??[])m.push(` removed the journal of rewind ${d.rewindId} of '${d.name}': undo reaches the last rewind of the org alone`);return m.push(Tn(n)),m}function Ln(e){return`Stopped before it wrote anything: ${e} is as the rewind left it, and the rewind can still be undone.`}function yi(e,t,n){let o=E(n.restored,d=>d.keptChanged)+E(n.deleted,d=>d.keptChanged),i=E([...n.deleted,...n.restored,...n.undeleted],d=>d.refused),s=E(n.residual,d=>d.count)+i,c=`${e} is back as it was before its rewind to '${t.name}'`,r={success:`${c}.`,partial:o>0&&s===0?`${c}, except ${p(o)} record(s) changed since the rewind, left as they are now.`:`${c}, except ${p(s+o)} record(s), each said with why:`,unstable:`Someone changed records of ${e} during the undo: left as they made them, each said below.`,failure:`Nothing of the undo of ${e}'s rewind went through: its reasons are said below.`,cancelled:tt(n)?Ln(e):`Stopped part way: ${e} is between the rewind and how it was before it. Undo again to finish: it takes up what this one left.`},a=Ve(n),u=[r[n.status]],g=gi(n),m=E(n.wentAlong??[],d=>d.count),y=a.deleted.done-g-m;y>0&&u.push(` sent back to the recycle bin ${p(y)} record(s) the rewind brought back`+(m>0?", with what came back with them":"")),g>0&&u.push(` deleted again ${p(g)} record(s) the rewind made again, with what went with them`);let k=n.carriedAlone??[];return k.length>0&&u.push(` of them, back in the recycle bin on their own: ${A(k.map(d=>`${d.objectApiName} ${p(d.count)}`))} \u2014 they had gone there with a record the rewind brought back for a moment, which stays there; they come back alone, under the parent the checkpoint gave them`),a.broughtBack.done>0&&u.push(` brought back ${p(a.broughtBack.done)} record(s) the rewind deleted`),a.givenBack.done>0&&u.push(` gave ${p(a.givenBack.done)} record(s) back the values they had before the rewind`),o>0&&u.push(` kept ${p(o)} record(s) changed since the rewind: undo leaves them as they are now`),u.push(...Pn("undo",e,n)),u.push(...Dn("undo",n,{})),u.push(Tn(n)),u}function Pn(e,t,n){let o=n.files;if(o===void 0)return[];let i=e==="rewind"?{unlinked:"removed {n} link(s) added since between files and records: the files stay",relinked:"put back {n} link(s) removed since between files and records, under new Ids",linksUpdated:"gave {n} link(s) between files and records their sharing back"}:{unlinked:"removed again {n} link(s) between files and records the rewind put back",relinked:"put back {n} link(s) between files and records the rewind removed, under new Ids",linksUpdated:"gave {n} link(s) between files and records back the sharing they had before the rewind"},s=["unlinked","relinked","linksUpdated"].filter(c=>o[c]>0).map(c=>` ${i[c].replace("{n}",p(o[c]))}`);return o.linksRefused>0&&s.push(` ${t} refused to write ${p(o.linksRefused)} link(s) between files and records`),s}function Dn(e,t,n){let o=t.residual.map(i=>` ${i.objectApiName} ${p(i.count)} \u2014 ${wi(e,i,n)}`);if(e==="undo")for(let i of[...t.deleted,...t.restored,...t.undeleted])i.refused!==0&&o.push(` ${i.objectApiName} ${p(i.refused)} \u2014 refused: ${i.reasons[0]??"the org gave no reason"}`);for(let i of t.unread??[])o.push(` could not be read again: ${i.objectApiName} \u2014 ${i.reason} (never taken for unchanged)`);return o}function Tn(e){return` sent ${p(e.apiRequests.used)} API requests to the org; ${p(e.apiRequests.leftToday)} left today`}function Fn(e,t,n,o,i){let s=new Map,c=a=>{let u=s.get(a);return u||(u={object:a,deleted:0,givenBack:0,broughtBack:0,refused:0},s.set(a,u)),u};for(let a of o.deleted)c(a.objectApiName).deleted+=a.deleted,c(a.objectApiName).refused+=a.refused;for(let a of o.restored)c(a.objectApiName).givenBack+=a.restored+(a.restoredWithout??0),c(a.objectApiName).refused+=a.refused;for(let a of o.undeleted)c(a.objectApiName).broughtBack+=a.undeleted+a.alreadyBack,c(a.objectApiName).refused+=a.refused;for(let a of o.recreated??[])c(a.objectApiName).refused+=a.refused;let r=(o.unread??[]).map(a=>({object:a.objectApiName,reason:a.reason}));return{checkpoint:{id:n.checkpointId,name:n.name,takenAt:n.takenAt,org:t},rewindId:o.rewindId,status:o.status,...o.scope?{limitedTo:[...o.scope.objects],notRewound:{...o.scope.notRewound}}:{},...Ve(o),...e==="rewind"?{recreated:In(o),cannotUndo:(i?.objects??[]).flatMap(a=>a.cannotUndo.filter(u=>u.count>0).map(u=>({object:a.objectApiName,reason:u.reason,count:u.count})))}:{},...e==="rewind"&&(o.carriers??[]).length>0?{carriers:(o.carriers??[]).map(a=>({object:a.objectApiName,count:a.count}))}:{},...e==="rewind"&&(o.draftsLeft??[]).length>0?{draftsLeft:(o.draftsLeft??[]).map(a=>({object:a.objectApiName,count:a.count,ids:[...a.ids]}))}:{},...e==="undo"&&(o.carriedAlone??[]).length>0?{carriedAlone:(o.carriedAlone??[]).map(a=>({object:a.objectApiName,count:a.count}))}:{},...o.files?{files:{...o.files}}:{},...o.undo?{undo:{until:o.undo.until,cannot:o.undo.cannot.map(a=>({object:a.objectApiName,count:a.count,...a.reason!==void 0?{reason:a.reason}:{}}))}}:{},verify:{differences:E(o.residual,a=>a.count)+r.length,stable:o.status!=="unstable",passes:o.passes,notCompared:[...n.ignoredFields]},residual:o.residual.map(a=>({object:a.objectApiName,reason:a.reason,...a.by!==void 0?{by:a.by}:{},count:a.count,...a.message!==void 0?{message:a.message}:{}})),unread:r,objects:[...s.values()],apiRequests:o.apiRequests,result:o}}function _n(e,t){switch(e){case"success":return 0;case"partial":return 3;case"unstable":return 4;case"failure":return 1;case"cancelled":return t!==void 0?pe(t):1}}var bi=10*6e4,$i=720*6e4,Bn=60*6e4,ve=5*6e4,on=200,v=class extends Error{constructor(n,o=1,i=[]){super(n.message);this.refusal=n;this.code=o;this.also=i;this.name="Stop"}refusal;code;also};function vi(e){let t=[e.refusal,...e.also];return{refusal:e.refusal,...e.also.length>0?{wouldBeRefused:t.map(n=>re(n)),wouldBeRefusedCodes:t.map(n=>n.code)}:{}}}function z(e){return e.message?.payload??{}}function W(e,t){let n=z(e);if(e.outcome==="unanswered")return{code:"UNANSWERED",message:`${t}: no answer came in time.`};let o=typeof n.message=="string"?n.message:JSON.stringify(n),i=typeof n.code=="string"?n.code:e.outcome.toUpperCase(),{holdingLimit:s}=n;return{code:i,message:o,...typeof s=="number"?{holdingLimit:s}:{}}}function Ai(e){let t=z(e).alsoRefused;return e.outcome!=="failed"||!Array.isArray(t)?[]:t.flatMap(n=>{let{code:o,message:i}=n??{};return typeof o=="string"&&typeof i=="string"?[{code:o,message:i}]:[]})}async function Ri(e=process.argv,t={}){let n=Mo(e),o=d=>{process[n.json?"stderr":"stdout"].write(`${d}
466
- `)},i=d=>{n.json&&process.stdout.write(`${JSON.stringify(d,null,2)}
467
- `)},s=ge({root:n.storeRoot,...t.locksDir!==void 0?{locksDir:t.locksDir}:{}});if("refusal"in s){let d=`The checkpoints cannot be kept in ${s.refusal.path}: `+kt(s.refusal,n.storeRoot,"--store <folder>");process.stderr.write(`${d}
468
- `),i({refusal:{code:"STORE_REFUSED",message:d}}),q(1);return}let c=s.store,r=Eo(sn(xo(),"sandforge-checkpoint-")),a=new Ut,u=!1,g,m=()=>Promise.resolve(),y,k;try{let d=(t.createHost??Mt)({storeDir:r,log:l=>{u&&l.startsWith("[INFO] ")?o(l.slice(7)):l.startsWith("[WARN] ")&&o(`warning: ${l.slice(7)}`)},compose:l=>{l.handlers.setCheckpointStore(c),l.handlers.rewindCheckpointsFromPreviewsAnswered(),l.handlers.setInfraServices({backgroundRegistry:a}),m=()=>l.handlers.sweepCheckpoints(),y=l.handlers,k=l},onPost:l=>{if(l.type!=="operation:progress")return;let f=l.payload?.currentStep;typeof f!="string"||f===g||(g=f,o(` ${f}`))}});u=!0;try{await m()}finally{u=!1}let h=async()=>{let l=await d.request({type:"checkpoint:list",timeoutMs:ve});if(l.outcome!=="answered")throw new v(W(l,"The list of checkpoints"));return z(l).checkpoints??[]},b=async l=>{try{return await d.connect(l)}catch(f){throw new v({code:"NOT_CONNECTED",message:f instanceof rt?f.message:`${l} could not be reached: ${f instanceof Error?f.message:String(f)}`})}},$=async l=>{if(k===void 0)throw new Error("The host composed no handlers.");return yt(await ot(l.id,k.orgRegistry,k.orgManager)).userId()};switch(n.command){case"list":{let l=await h(),f=n.org!==void 0?K(l,n.org):l,C=n.org!==void 0?{org:n.org,kept:l.length}:void 0;for(let O of Wo(f,c.root,C))o(O);i(f.map(qo));return}case"take":await Ei(n,d,await b(n.org),c,a,o,i);return;case"preview":{let l=await h(),f=ue(ne(l,K(l,n.org),n.checkpoint,n.org)),C=qe(f);if(C)throw new v(C);let O=f.checkpoint,S=n.objects.length>0?Sn(O,n.objects):void 0,M=await b(n.org);Ze(M,f,O,n.org,"preview");let B=await d.request({type:"checkpoint:preview",payload:{checkpointId:f.checkpointId,...S?{objects:S}:{},acceptOutside:!1},timeoutMs:Bn});if(B.outcome!=="answered")throw new v(W(B,"The preview"));let D=z(B),F=S?await Je(d,D.diff,S,!1):void 0,T=S?void 0:await On(d,O,D.diff,!1),Z=F??T,w=Z?{...D,diff:Z.diff}:D,R=En(D.refusal,await Se({orgName:n.org,preview:w,bounds:{refuseWhenActive:!1},accepted:pi,writers:()=>Promise.resolve([]),words:le,user:M.username})),[L]=R;for(let x of bn(n.org,O,w,M.username))o(x);for(let x of F?Rn(F.plan):[])o(x);for(let x of T?Cn(T.plan):[])o(x);for(let x of R.slice(D.refusal?1:0))o(` a rewind now would be refused (${x.code}): ${x.message}`);i(vn(n.org,O,{...D,...L?{refusal:L}:{}},F,T)),q(li(F?.diff??D.diff,n.failOnChange));return}case"rewind":case"undo":{let l={host:d,registry:a,store:c,listAll:h,connect:b,userIdOf:$,say:o,answerJson:i};n.command==="rewind"?await Ni(n,l):await Pi(n,l);return}case"delete":await Ii(n,d,h,o,i);return;case"export":await Ci(n,{transfers:rn(y),listAll:h,say:o,answerJson:i});return;case"import":await Oi(n,{transfers:rn(y),connect:b,say:o,answerJson:i});return;case"replay":await Zt(n.replay,{storeRoot:n.storeRoot,storeNamed:n.storeNamed===!0,store:c,...t.locksDir!==void 0?{locksDir:t.locksDir}:{},listAll:h,checkpointsOf:K,resolve:ne,say:o,json:n.json});return;case"replays":await Xt(n.target,{storeRoot:n.storeRoot,storeNamed:n.storeNamed===!0,say:o,answerJson:i});return}}catch(d){let h=d instanceof v?d:d instanceof N?new v(d.refusal,d.code):new v({code:"FAILED",message:d instanceof Error?d.message:String(d)});process.stderr.write(`${d instanceof N?re(d.refusal):h.message}
469
- `);for(let b of h.also)process.stderr.write(`${re(b)}
470
- `);h.code!==2&&i(vi(h)),q(h.code)}finally{a.dispose(),No(r,{recursive:!0,force:!0})}}function rn(e){if(e===void 0)throw new Error("The host composed no handlers.");return e}function ji(){try{let e=JSON.parse(Io(sn(__dirname,"..","package.json"),"utf8"));return typeof e.version=="string"?e.version:"0.0.0"}catch{return"0.0.0"}}function Mn(e){let t=process.env[e];if(t===void 0||t.trim()==="")throw new v({code:"NO_KEY",message:`${e} is not set: it holds no key. Nothing was run.`},2);let n=Y(t);if(n===void 0)throw new v({code:"NO_KEY",message:`${e} holds no key SandForge reads: 52 letters and digits, in groups of four as an export shows one. Nothing was run.`},2);return n}function Un(e,t){return{id:e.checkpointId,name:e.name,takenAt:e.takenAt,org:t}}async function Ci(e,t){let{say:n,answerJson:o}=t,i=e.keyEnv!==void 0?Mn(e.keyEnv):void 0,s=await t.listAll(),c=ue(ne(s,K(s,e.org),e.checkpoint,e.org)),r=await t.transfers.exportCheckpoint({checkpointId:c.checkpointId,out:e.out,...i!==void 0?{key:i}:{},sandforgeVersion:ji()});if(!r.exported)throw new v(r.refusal);let{checkpoint:a,header:u}=r;n(`exported '${a.name}' (${a.checkpointId}) of ${e.org}, taken ${_(a.takenAt)}: ${p(u.records)} record(s) of ${p(u.objects)} object(s), ${J(r.bytes)}, to ${e.out}`),n(` sha256 ${r.sha256}`),r.key!==void 0&&process.stderr.write(` key, shown this once and kept nowhere: ${r.key}
471
- `),n(` Anyone who has this file and its key can read the ${p(u.records)} records it holds of ${e.org}, personal data among them. Send the key another way than the file, and only to people who already see all data in ${e.org}.`),n(" The file does not expire: delete it once it has served."),o({checkpoint:Un(a,e.org),file:e.out,bytes:r.bytes,sha256:r.sha256,records:u.records,objects:u.objects,keyShown:r.key!==void 0})}async function Oi(e,t){let{say:n,answerJson:o}=t,i=e.keyEnv!==void 0?Mn(e.keyEnv):void 0,s=await t.connect(e.org),c=await t.transfers.readCheckpointImport({orgId:s.id,file:e.file});if(c.header!==void 0){let{header:g}=c;n(`the file holds checkpoint ${g.checkpointId}, taken ${_(g.takenAt)}: ${p(g.records)} record(s) of ${p(g.objects)} object(s), ${J(g.bytes)}, exported by SandForge ${g.sandforgeVersion}`)}if(!c.allowed)throw new v(c.refusal.code==="OTHER_ORG"?{...c.refusal,message:`${c.refusal.message} Its replay into ${e.org}: ${Vt(e.file,e.org)} --dry-run`}:c.refusal);let r=i??await Si(),a=await t.transfers.importCheckpoint({orgId:s.id,file:e.file,key:r,keepDays:e.keepDays});if(!a.imported)throw new v(a.refusal);let{checkpoint:u}=a;n(a.outcome==="imported"?`imported '${u.name}' (${u.checkpointId}) of ${e.org}: ${p(he(u))} record(s) of ${p(u.objects.length)} object(s), ${Ge(u.expiresAt)}`:`'${u.name}' (${u.checkpointId}) is kept on this machine already, the same: left as it is`);for(let g of a.warnings)n(` ${g}`);o({outcome:a.outcome,checkpoint:Un(u,e.org),records:he(u),objects:u.objects.length,expiresAt:u.expiresAt,warnings:a.warnings})}async function Si(){let e=await we("Key of the file (not shown as you type it):","give --key-env VAR, the name of an environment variable that holds the key");if(e===void 0||e.trim()==="")throw new v({code:"DECLINED",message:"No key was typed. Nothing was imported."});let t=Y(e);if(t===void 0)throw new v({code:"IMPORT_KEY",message:"That is not a key SandForge draws: 52 letters and digits, in groups of four as the export showed it. Nothing was imported."});return t}function ue(e){if("entry"in e)return e.entry;throw"ambiguous"in e?new v({code:"AMBIGUOUS",message:e.ambiguous},2):new v({code:"NOT_FOUND",message:e.none})}async function Ei(e,t,n,o,i,s,c){let{take:r}=e;if(e.estimate){let h={orgId:n.id,mode:r.mode,...r.objects?{objects:r.objects}:{},...r.excluded?{excluded:r.excluded}:{},...r.customSettings?{customSettings:r.customSettings}:{},...r.maxTotal!==void 0?{maxTotal:r.maxTotal}:{}},b=await t.request({type:"checkpoint:scope",payload:h,timeoutMs:bi});if(b.outcome!=="answered")throw new v(W(b,"The estimate"));let $=z(b),l={mode:$.mode,objects:$.objects,leftOut:$.leftOut,estimate:$.estimate,...$.refusal?{refusal:Me($.refusal)}:{},...$.files?{files:$.files}:{},...$.customSettings?{customSettings:$.customSettings}:{}};for(let f of Go(e.org,l))s(f);c(Ho(l)),q(l.refusal?1:0);return}s(`taking a checkpoint of ${e.org}: it reads every record of its objects (Ctrl-C stops it, and nothing of it is kept)`);let{answer:a,stoppedBy:u}=await Xe(i,"the take stops after the read under way, and keeps nothing",()=>t.request({type:"checkpoint:take",payload:{orgId:n.id,...r},timeoutMs:$i}));if(a.outcome!=="answered"){let h=Me(W(a,"The take"));throw u!==void 0&&h.code==="CANCELLED"?new v(h,pe(u)):new v(h)}let g=z(a),m=g.checkpoint,y=g.requests,k=g.estimate,d=o.folderOf(m.org.organizationId,m.checkpointId).dir;for(let h of Jo(m,d,r.objects??[]))s(h);y&&s(Xo(y,k)),c({checkpoint:m,...y?{requests:y}:{},...k?{estimate:k}:{}})}async function Ii(e,t,n,o,i){let s=await n(),c=K(s,e.org),r=e.checkpoint===void 0?c:[ue(ne(s,c,e.checkpoint,e.org))];if(r.length===0)throw new v({code:"NOT_FOUND",message:`No checkpoint of ${e.org} is kept in the folder read. ${be(e.org)} Nothing was deleted.`});let a=h=>h.checkpoint?`'${h.checkpoint.name}' (${h.checkpointId})`:h.checkpointId;if(!e.yes){let h=r.filter(f=>f.undo!==void 0),b=r.length===1?`Delete ${a(r[0])}${r[0].checkpoint?`, taken ${_(r[0].checkpoint.takenAt)},`:""} from this machine? ${e.org} can no longer be rewound to it`:`Delete the ${r.length} checkpoints of ${e.org} from this machine (${A(r.map(a),4)})? ${e.org} can no longer be rewound to them`,$=(await Fe(r,{storeRoot:e.storeRoot,storeNamed:e.storeNamed===!0})).entries,l=`${b}${h.length>0?", and its last rewind can no longer be undone":""}. The org is not touched`+($.length>0?`, nor the ${$.length===1?"org it was":"orgs they were"} replayed into (${A($.map(f=>f.target.name??f.target.organizationId),4)}), each replay still taken back with --remove`:"")+".";if(!await $t(l))throw new v({code:"DECLINED",message:"Nothing was deleted."})}let u=r.map(h=>h.checkpointId);for(let h=0;h<u.length;h+=on){let b=await t.request({type:"checkpoint:delete",payload:{checkpointIds:u.slice(h,h+on)},timeoutMs:ve});if(b.outcome!=="answered"){let $=W(b,"The delete");if(h===0)throw new v($);o(`refused: ${$.message}`);break}}let g=new Set((await n()).map(h=>h.checkpointId)),m=r.filter(h=>!g.has(h.checkpointId)),y=r.filter(h=>g.has(h.checkpointId));for(let h of m)o(`deleted ${a(h)}`);for(let h of y)o(`kept ${a(h)}: a take, a rewind or an undo of its org is running; delete it once it has ended`);let k=await Fe(m,{storeRoot:e.storeRoot,storeNamed:e.storeNamed===!0});for(let h of k.lines)o(h);let d=e.storeNamed?e.storeRoot:void 0;i({deleted:m.map(h=>h.checkpointId),kept:y.map(h=>h.checkpointId),...k.entries.length>0?{replaysInPlace:k.entries.map(h=>Te(h,d))}:{}}),y.length>0&&q(m.length>0?3:1)}function Ze(e,t,n,o,i){if(an(e.orgId,t.organizationId))return;let s=K([t],o).length>0,c=i==="preview"?"preview it":i==="rewind"?"rewind to it":"undo it";throw new v({code:"OTHER_ORG",message:s?`${o} answers as another org than the one '${n.name}' was taken of: a sandbox refreshed since is another org, and this checkpoint no longer rewinds it. ${Ae.replace(/\.$/,"")}: ${X(t.checkpointId,o)} --dry-run. No record was read.`:`'${n.name}' is a checkpoint of ${oe(n)}, not of ${o}: ${c} with --org ${oe(n)}. No record was read.`})}async function Xe(e,t,n){let o,i=e.onEvent((c,r,a)=>{o!==void 0&&r==="started"&&a.module==="checkpoint"&&e.abort(c)}),s=st(c=>{o=c,process.stderr.write(`
472
- interrupted: ${t} (Ctrl-C again ends it at once)
473
- `);for(let r of e.getRunning())r.module==="checkpoint"&&e.abort(r.operationId)});try{let c=await n();return o!==void 0?{answer:c,stoppedBy:o}:{answer:c}}finally{s(),i()}}var zn=720*6e4;function Wn(e,t,n=o=>o){let{answer:o,stoppedBy:i}=e;if(o.outcome!=="answered"){let s=n(W(o,t));throw i!==void 0&&s.code==="CANCELLED"?new v(s,pe(i)):new v(s,1,Ai(o).map(n))}return z(o).result}async function Ni(e,t){let{host:n,say:o,answerJson:i}=t,s=await t.listAll(),c=ue(ne(s,K(s,e.org),e.checkpoint,e.org)),r=qe(c);if(r)throw new v(r);let a=c.checkpoint,u=e.ignoreFields.filter(w=>!a.ignoredFields.includes(w));if(u.length>0){let w=await n.request({type:"checkpoint:ignore-fields",payload:{checkpointId:c.checkpointId,fields:[...a.ignoredFields,...u]},timeoutMs:ve});if(w.outcome!=="answered")throw new v(W(w,"The fields not to compare"));a=z(w).checkpoint,o(`not compared from now on, nor written back: ${u.join(", ")} (kept in '${a.name}')`)}let g=e.objects.length>0?Sn(a,e.objects):void 0,m=await t.connect(e.org);Ze(m,c,a,e.org,"rewind");let y=await n.request({type:"checkpoint:preview",payload:{checkpointId:c.checkpointId,...g?{objects:g}:{},...e.muteAutomation?{muteAutomation:!0}:{},acceptOutside:e.acceptOutside},timeoutMs:Bn});if(y.outcome!=="answered")throw new v(W(y,"The preview"));let k=z(y),d=g?await Je(n,k.diff,g,e.acceptOutside):void 0,h=g?void 0:await On(n,a,k.diff,e.acceptOutside),b=d??h,$=b?{...k,diff:b.diff}:k,l=e.muteAutomation&&$.automation?ut($.automation,nt(ae($.diff))):void 0,f=l?{...$,automation:l.automation}:$;for(let w of bn(e.org,a,f,m.username,e.acceptAutomation))o(w);for(let w of d?Rn(d.plan):[])o(w);for(let w of h?Cn(h.plan):[])o(w);for(let w of l?me(l.planned,e.org):[])o(` ${w}`);let C=Ot(f.diff).length>0,O=await Se({orgName:e.org,preview:f,bounds:{...e.maxRecords!==void 0?{maxRecords:e.maxRecords}:{},refuseWhenActive:e.refuseWhenActive},accepted:e,writers:async()=>Ct(a.takenBy,await t.userIdOf(m)),words:le,user:m.username}),S=En(f.refusal,O);if(jn(a,f.diff,e.acceptOutside)&&o(" without --accept-outside, the records they hang from stay, and so do they: each is said once the rewind is through"),e.dryRun){for(let w of S.slice(f.refusal?1:0))o(` a rewind now would be refused (${w.code}): ${w.message}`);i({...vn(e.org,a,k,d,h),...l?{mutedAutomation:l.planned,mutePlan:l.plan}:{},...S.length>0?{wouldBeRefused:S.map(w=>re(w)),wouldBeRefusedCodes:S.map(w=>w.code)}:{}});return}let[B,...D]=S;if(B)throw new v(B,1,D);if(C&&!e.yes&&await Oe(mi(e.org,a,f.diff,g))!==e.org)throw new v({code:"DECLINED",message:"Nothing was written."});let F=await Xe(t.registry,"the rewind stops before its next call to the org, and leaves its journal: rewind again takes up from what still differs",()=>n.request({type:"checkpoint:rewind",payload:{checkpointId:c.checkpointId,previewId:f.diff.previewId,...g?{objects:g}:{},acceptAutomation:e.acceptAutomation,...e.acceptEmails?{acceptEmails:!0}:{},...e.muteAutomation?{muteAutomation:!0}:{},acceptNoUndo:e.acceptNoUndo,acceptRecreate:e.acceptRecreate,acceptOutside:e.acceptOutside,acceptUnseen:e.acceptUnseen},timeoutMs:zn})),T=Wn(F,"The rewind",w=>w.code==="CANCELLED"?{...w,message:xn(e.org,a.name)}:ui(w)),Z=e.storeRoot!==je()?e.storeRoot:void 0;for(let w of ki(e.org,a,T,f.diff.userNames,Z))o(w);for(let w of T.mutedAutomation?me(T.mutedAutomation,e.org):[])o(w);i(Fn("rewind",e.org,a,T,f.diff)),q(_n(T.status,F.stoppedBy))}function xi(e,t,n,o,i){return`undo the rewind ${n} of ${e} to '${t.name}' (open until ${_(o)}, sooner if the recycle bin fills)`+(i?`: it brings back ${p(i.bringBack)} record(s) the rewind deleted, gives ${p(i.giveBack)} record(s) back the values they had before it, and sends ${p(i.remove-i.remade)} record(s) it brought back to the recycle bin`+(i.along>0?", with what came back with them":"")+(i.remade>0?`, deleting again the ${p(i.remade)} record(s) it made again`:"")+(i.drafted>0?` \u2014 of them, ${p(i.drafted)} order(s) set back to Draft first if past it, the one way Salesforce deletes one: an update, which what runs on an order's update fires on`:"")+"; what anyone changed since the rewind stays":"")}async function Li(e,t,n,o){try{let i=e.folderOf(t.organizationId,t.checkpointId),s=await Nt(i,o,n.objects);try{return{bringBack:s.bringBack.count,giveBack:s.giveBack.count,remove:s.remove.spool.count,along:s.goesWithParent.count,remade:s.remade.keys.size,drafted:s.remade.objects.filter(({objectApiName:c})=>lt([c]).length>0).reduce((c,{count:r})=>c+r,0)}}finally{await s.dispose()}}catch{return}}async function Pi(e,t){let{host:n,say:o,answerJson:i}=t,s=await t.listAll(),c=K(s,e.org),r=e.checkpoint===void 0?c.find(b=>b.undo!==void 0):ue(ne(s,c,e.checkpoint,e.org));if(!r)throw new v({code:"NOT_FOUND",message:`No rewind of ${e.org} can be undone from this machine: Undo is offered for the last rewind of an org, for 15 days after it, until it is undone. Nothing was written.`});let a=qe(r);if(a)throw new v(a);let u=r.checkpoint;if(!r.undo)throw new v({code:"UNDO_CLOSED",message:`'${u.name}' has no rewind that can be undone: Undo is offered for the last rewind of an org only, for 15 days after it, until it is undone. Nothing was written.`});let{rewindId:g,until:m}=r.undo,y=await Li(t.store,r,u,g);o(xi(e.org,u,g,m,y));let k=await t.connect(e.org);if(Ze(k,r,u,e.org,"undo"),!e.yes&&await Oe(`Type ${e.org} to undo its rewind:`)!==e.org)throw new v({code:"DECLINED",message:"Nothing was written."});let d=await Xe(t.registry,"the undo stops before its next call to the org: undo again takes up what it left",()=>n.request({type:"checkpoint:undo",payload:{checkpointId:r.checkpointId,rewindId:g,acceptAutomation:e.acceptAutomation,...e.acceptEmails?{acceptEmails:!0}:{},...e.muteAutomation?{muteAutomation:!0}:{}},timeoutMs:zn})),h=Wn(d,"The undo",b=>b.code==="CANCELLED"?{...b,message:Ln(e.org)}:fi(b));for(let b of yi(e.org,u,h))o(b);for(let b of h.mutedAutomation?me(h.mutedAutomation,e.org):[])o(b);i(Fn("undo",e.org,u,h)),q(_n(h.status,d.stoppedBy))}process.argv[1]?.includes("sandforge-checkpoint")&&(At(),Ri().then(()=>process.exit(process.exitCode??0)).catch(e=>{process.stderr.write(`${e instanceof Error?e.message:String(e)}
474
- `),process.exit(1)}));export{Bo as a,Mo as b,K as c,ne as d,qe as e,He as f,Wo as g,qo as h,Ho as i,Me as j,Go as k,Jo as l,Xo as m,kn as n,Ke as o,bn as p,vn as q,li as r,Rn as s,jn as t,Cn as u,Sn as v,Nr as w,mi as x,ki as y,yi as z,Fn as A,_n as B,Ri as C,xi as D};