sandforge 1.79.0 → 1.81.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 (256) hide show
  1. package/bin/sandforge-pipeline.mjs +12 -0
  2. package/lib/{chunk-BN7A4GRQ.mjs → chunk-2IB7I3IQ.mjs} +1 -1
  3. package/lib/{chunk-PBI4BYWW.mjs → chunk-2NAIUKVL.mjs} +1 -1
  4. package/lib/chunk-2OIRJEYE.mjs +7 -0
  5. package/lib/{chunk-FOVVHGEP.mjs → chunk-2OZG6GRW.mjs} +1 -1
  6. package/lib/{chunk-5CD257T7.mjs → chunk-2Z54GB6X.mjs} +1 -1
  7. package/lib/chunk-2ZMGVBLW.mjs +7 -0
  8. package/lib/{chunk-4NAHW2D3.mjs → chunk-33ZX3A56.mjs} +1 -1
  9. package/lib/{chunk-4SNDMJP2.mjs → chunk-3AOKLIVE.mjs} +1 -1
  10. package/lib/{chunk-SIOZXPFG.mjs → chunk-3B5H24ZG.mjs} +1 -1
  11. package/lib/chunk-43K2C6H2.mjs +7 -0
  12. package/lib/chunk-4JKR4PTZ.mjs +8 -0
  13. package/lib/chunk-4L7FBOJS.mjs +8 -0
  14. package/lib/chunk-5344TZBT.mjs +11 -0
  15. package/lib/{chunk-SAR5622P.mjs → chunk-54HYHHVL.mjs} +1 -1
  16. package/lib/chunk-55LQD3Y3.mjs +7 -0
  17. package/lib/chunk-56MPPWLA.mjs +7 -0
  18. package/lib/chunk-5C5XEVZN.mjs +11 -0
  19. package/lib/chunk-5CKWGZX4.mjs +9 -0
  20. package/lib/{chunk-RSWDYIHY.mjs → chunk-5GBO4KD5.mjs} +1 -1
  21. package/lib/{chunk-GNC27UEU.mjs → chunk-5UT2ZBGF.mjs} +1 -1
  22. package/lib/chunk-5VQNKDFU.mjs +7 -0
  23. package/lib/chunk-5WGA5CZB.mjs +7 -0
  24. package/lib/chunk-5ZKCLBTN.mjs +474 -0
  25. package/lib/chunk-67CC7RAE.mjs +7 -0
  26. package/lib/{chunk-5O6JOMHS.mjs → chunk-6CDIIFNX.mjs} +1 -1
  27. package/lib/{chunk-AV5SWEHP.mjs → chunk-6FARZYMJ.mjs} +1 -1
  28. package/lib/{chunk-7UQD6V6F.mjs → chunk-6FMLW7PH.mjs} +1 -1
  29. package/lib/chunk-6IGEASOF.mjs +7 -0
  30. package/lib/{chunk-H2PJNIYJ.mjs → chunk-6NADW3OI.mjs} +1 -1
  31. package/lib/chunk-6SEDOIO3.mjs +10 -0
  32. package/lib/{chunk-AUTM6H6Z.mjs → chunk-742SSN7I.mjs} +1 -1
  33. package/lib/chunk-7DALDJMO.mjs +7 -0
  34. package/lib/chunk-7PK5QDQI.mjs +7 -0
  35. package/lib/chunk-AELFEK3G.mjs +7 -0
  36. package/lib/chunk-AITNZWLB.mjs +9 -0
  37. package/lib/{chunk-HV2MXMGI.mjs → chunk-AJPSGVMD.mjs} +1 -1
  38. package/lib/{chunk-OTWRDD6L.mjs → chunk-BNO5GIJ6.mjs} +1 -1
  39. package/lib/{chunk-K2FBZIXY.mjs → chunk-BWWQXU2B.mjs} +1 -1
  40. package/lib/{chunk-IC2C2GOF.mjs → chunk-BXZ73A5M.mjs} +1 -1
  41. package/lib/chunk-BZFIOZS3.mjs +156 -0
  42. package/lib/{chunk-XBG5SP6Q.mjs → chunk-C4YGSK6W.mjs} +1 -1
  43. package/lib/chunk-CAFUNR6D.mjs +7 -0
  44. package/lib/chunk-CULAOP3U.mjs +7 -0
  45. package/lib/chunk-D62KWDDT.mjs +7 -0
  46. package/lib/{chunk-BILZ3SSR.mjs → chunk-D7P7DTWL.mjs} +1 -1
  47. package/lib/chunk-DHGPDSXS.mjs +7 -0
  48. package/lib/{chunk-ZXH4MBWP.mjs → chunk-DHIW4IO5.mjs} +1 -1
  49. package/lib/{chunk-NM4MDLK4.mjs → chunk-DMBR24CK.mjs} +1 -1
  50. package/lib/chunk-DPYTG6DM.mjs +48 -0
  51. package/lib/chunk-DQR5NDMI.mjs +7 -0
  52. package/lib/chunk-DXOXLUZA.mjs +7 -0
  53. package/lib/chunk-E2OBAWSH.mjs +7 -0
  54. package/lib/chunk-E2YJVSX6.mjs +10 -0
  55. package/lib/chunk-EAFLDSQ2.mjs +7 -0
  56. package/lib/{chunk-HCIDVIOW.mjs → chunk-EH5YUA5W.mjs} +1 -1
  57. package/lib/{chunk-2BVTCNWA.mjs → chunk-EOSEMFPU.mjs} +1 -1
  58. package/lib/chunk-ETT5GP4P.mjs +13 -0
  59. package/lib/{chunk-3SRXFZSD.mjs → chunk-FDGFUEK3.mjs} +1 -1
  60. package/lib/{chunk-3DCUADVK.mjs → chunk-FLNLG43R.mjs} +1 -1
  61. package/lib/{chunk-HTJ5OGP5.mjs → chunk-FSDO4DJA.mjs} +1 -1
  62. package/lib/{chunk-HJKM3E56.mjs → chunk-FSZTXLNW.mjs} +1 -1
  63. package/lib/chunk-FTA5LOVX.mjs +7 -0
  64. package/lib/chunk-G4VXPS3A.mjs +7 -0
  65. package/lib/chunk-GF247DA7.mjs +7 -0
  66. package/lib/{chunk-QRV2OSIS.mjs → chunk-GK7VEYFM.mjs} +1 -1
  67. package/lib/{chunk-5MMXFWPD.mjs → chunk-GR3NGDVM.mjs} +1 -1
  68. package/lib/{chunk-P7GSGFJO.mjs → chunk-GTIXJCGS.mjs} +1 -1
  69. package/lib/{chunk-342FN7AO.mjs → chunk-GWRKS3AL.mjs} +1 -1
  70. package/lib/{chunk-LQ4DRFUH.mjs → chunk-GYKNCYES.mjs} +1 -1
  71. package/lib/{chunk-WIO4XO4F.mjs → chunk-HFSBDM7B.mjs} +1 -1
  72. package/lib/chunk-HVC5CYIB.mjs +7 -0
  73. package/lib/{chunk-EQF2IJS2.mjs → chunk-HYBH5PFM.mjs} +1 -1
  74. package/lib/chunk-HYOOJVR6.mjs +7 -0
  75. package/lib/{chunk-TQX3PURV.mjs → chunk-IBURU7T7.mjs} +1 -1
  76. package/lib/chunk-ICIYL45C.mjs +7 -0
  77. package/lib/{chunk-K22PA4XL.mjs → chunk-IKGHRYCN.mjs} +1 -1
  78. package/lib/chunk-IM2XA6JI.mjs +7 -0
  79. package/lib/{chunk-P2PJYWGQ.mjs → chunk-J6G23RUI.mjs} +1 -1
  80. package/lib/{chunk-JVL444U5.mjs → chunk-JU2XEKEO.mjs} +1 -1
  81. package/lib/{chunk-H45UXY6G.mjs → chunk-K55LH4ZQ.mjs} +1 -1
  82. package/lib/chunk-K5HV4YRO.mjs +7 -0
  83. package/lib/{chunk-IAZB4WIL.mjs → chunk-K77NR3UK.mjs} +1 -1
  84. package/lib/chunk-KE2PGD6C.mjs +7 -0
  85. package/lib/chunk-KGYXLSQ5.mjs +37 -0
  86. package/lib/{chunk-TEOLMRDO.mjs → chunk-KNIRA333.mjs} +1 -1
  87. package/lib/chunk-KOQV4WXC.mjs +8 -0
  88. package/lib/{chunk-PNCONNFJ.mjs → chunk-KRNFVAGC.mjs} +1 -1
  89. package/lib/chunk-L5FGY6YA.mjs +7 -0
  90. package/lib/{chunk-MTMH6H2A.mjs → chunk-LCDPCUXS.mjs} +1 -1
  91. package/lib/{chunk-YAZO75G2.mjs → chunk-LNXBCE7E.mjs} +1 -1
  92. package/lib/{chunk-ZOVSMN5C.mjs → chunk-LO527YLT.mjs} +1 -1
  93. package/lib/chunk-MAHZMPMZ.mjs +7 -0
  94. package/lib/{chunk-QQZZMKU3.mjs → chunk-MHW6DV6T.mjs} +1 -1
  95. package/lib/{chunk-2YIV2OB2.mjs → chunk-MIDBQ7SD.mjs} +1 -1
  96. package/lib/{chunk-6EBMEGZB.mjs → chunk-MKNAZPOT.mjs} +1 -1
  97. package/lib/{chunk-NTDN2JQZ.mjs → chunk-MNITSYI2.mjs} +8 -8
  98. package/lib/chunk-MO3N5XVV.mjs +341 -0
  99. package/lib/{chunk-SBIMVCXT.mjs → chunk-MS4FJDFD.mjs} +9 -9
  100. package/lib/chunk-MWLFFVQV.mjs +8 -0
  101. package/lib/chunk-N6HHNR6J.mjs +7 -0
  102. package/lib/chunk-N7J6NJQ6.mjs +7 -0
  103. package/lib/chunk-NJ3EOEHS.mjs +9 -0
  104. package/lib/chunk-NWPQF5XR.mjs +7 -0
  105. package/lib/{chunk-PUOX4NBJ.mjs → chunk-NWVVCZUK.mjs} +1 -1
  106. package/lib/{chunk-DLDX6RRC.mjs → chunk-O6ADMP36.mjs} +1 -1
  107. package/lib/chunk-O7DAFE6M.mjs +14 -0
  108. package/lib/chunk-OEHVAJAB.mjs +7 -0
  109. package/lib/chunk-OETEC3P7.mjs +7 -0
  110. package/lib/{chunk-GCOB7K5N.mjs → chunk-OHEOJISY.mjs} +1 -1
  111. package/lib/chunk-OIIL4NVI.mjs +7 -0
  112. package/lib/chunk-OMZJ37JI.mjs +15 -0
  113. package/lib/{chunk-NZ5ZZLKS.mjs → chunk-ONMBSACW.mjs} +1 -1
  114. package/lib/chunk-OQQHNYR7.mjs +272 -0
  115. package/lib/{chunk-AAVJ5XVX.mjs → chunk-OU5W7SCB.mjs} +1 -1
  116. package/lib/{chunk-RSYICMZG.mjs → chunk-OVOLG3AL.mjs} +1 -1
  117. package/lib/{chunk-F74IHMGL.mjs → chunk-OXKZ4Y3B.mjs} +1 -1
  118. package/lib/{chunk-W7KFAY55.mjs → chunk-OZNLOV4U.mjs} +1 -1
  119. package/lib/{chunk-TYYOBZMU.mjs → chunk-PC247GKX.mjs} +1 -1
  120. package/lib/chunk-PPGDAUEQ.mjs +7 -0
  121. package/lib/{chunk-RACDTRZA.mjs → chunk-PYUEHBA6.mjs} +1 -1
  122. package/lib/{chunk-TLH7AD35.mjs → chunk-PZBZ7MNC.mjs} +1 -1
  123. package/lib/{chunk-DBFJB2B6.mjs → chunk-QIRO4HTE.mjs} +1 -1
  124. package/lib/{chunk-PZTSVQSF.mjs → chunk-QXLZINZB.mjs} +1 -1
  125. package/lib/chunk-R2BJWO5N.mjs +20 -0
  126. package/lib/chunk-R6TF26V4.mjs +10 -0
  127. package/lib/{chunk-P42X3B4D.mjs → chunk-RKALOKAU.mjs} +1 -1
  128. package/lib/chunk-SQGP46QS.mjs +7 -0
  129. package/lib/chunk-SU65Z2BA.mjs +7 -0
  130. package/lib/chunk-SW2NUKQL.mjs +9 -0
  131. package/lib/chunk-T26C576X.mjs +9 -0
  132. package/lib/{chunk-3OHPD72J.mjs → chunk-T3PLRQ2T.mjs} +1 -1
  133. package/lib/chunk-T5VAULLQ.mjs +7 -0
  134. package/lib/chunk-TEIBWMJM.mjs +7 -0
  135. package/lib/chunk-TKQQVB2D.mjs +9 -0
  136. package/lib/{chunk-RAAANPPG.mjs → chunk-TPHXRHOA.mjs} +1 -1
  137. package/lib/chunk-TQ2TQHTT.mjs +9 -0
  138. package/lib/{chunk-IEYG5ATY.mjs → chunk-TQM2XJ27.mjs} +1 -1
  139. package/lib/{chunk-X65MT4W3.mjs → chunk-UCHAZ4ZU.mjs} +1 -1
  140. package/lib/chunk-UIUPPEFB.mjs +7 -0
  141. package/lib/{chunk-QPF6C5MX.mjs → chunk-UT27HXE7.mjs} +1 -1
  142. package/lib/{chunk-J7HVXMSW.mjs → chunk-UUSLTW5V.mjs} +1 -1
  143. package/lib/chunk-V2QO6KOE.mjs +19 -0
  144. package/lib/chunk-V473C7LY.mjs +7 -0
  145. package/lib/chunk-V4RKM4QZ.mjs +8 -0
  146. package/lib/chunk-VSU74RQ3.mjs +9 -0
  147. package/lib/chunk-VV3B6IC3.mjs +7 -0
  148. package/lib/chunk-W2AAGIZF.mjs +7 -0
  149. package/lib/{chunk-WR2GIKWE.mjs → chunk-WB2RIVO3.mjs} +1 -1
  150. package/lib/chunk-WD47PGUS.mjs +10 -0
  151. package/lib/{chunk-3CA767QB.mjs → chunk-WEZLXE34.mjs} +1 -1
  152. package/lib/{chunk-WFEB5X4U.mjs → chunk-WI4HYWV6.mjs} +1 -1
  153. package/lib/{chunk-AR7BE5O2.mjs → chunk-WM5JI4JI.mjs} +1 -1
  154. package/lib/chunk-WWTXRWNZ.mjs +7 -0
  155. package/lib/{chunk-7EANH5PY.mjs → chunk-WZQEK4WT.mjs} +1 -1
  156. package/lib/{chunk-ZJKCWBRJ.mjs → chunk-X2ZVSQ54.mjs} +1 -1
  157. package/lib/{chunk-SFURUNJM.mjs → chunk-XC2QKQT5.mjs} +1 -1
  158. package/lib/chunk-XC54KKKC.mjs +7 -0
  159. package/lib/chunk-XEB6HZ34.mjs +7 -0
  160. package/lib/chunk-XGKSSCW7.mjs +7 -0
  161. package/lib/chunk-XIZ5LMQM.mjs +7 -0
  162. package/lib/{chunk-RFEO2KAN.mjs → chunk-Y5ZCPY36.mjs} +1 -1
  163. package/lib/{chunk-TBZMC2VV.mjs → chunk-YCSFP6ER.mjs} +4 -4
  164. package/lib/{chunk-YBU4Z4QV.mjs → chunk-YHIOS2PU.mjs} +1 -1
  165. package/lib/chunk-YIGFYZQY.mjs +7 -0
  166. package/lib/chunk-YJEXE6HZ.mjs +925 -0
  167. package/lib/{chunk-57VHUYNG.mjs → chunk-YOGMP72T.mjs} +4 -4
  168. package/lib/chunk-ZRUDYB7O.mjs +7 -0
  169. package/lib/{chunk-55HEMHEG.mjs → chunk-ZUA5BNAO.mjs} +1 -1
  170. package/lib/chunk-ZWCRWF7E.mjs +7 -0
  171. package/lib/{chunk-VHI54FBK.mjs → chunk-ZWZXQTAK.mjs} +53 -53
  172. package/lib/sandforge-autopilot.mjs +29 -24
  173. package/lib/sandforge-backup.mjs +67 -32
  174. package/lib/sandforge-checkpoint.mjs +1 -347
  175. package/lib/sandforge-cleanup.mjs +14 -10
  176. package/lib/sandforge-clone.mjs +1 -1
  177. package/lib/sandforge-compare.mjs +9 -8
  178. package/lib/sandforge-dataops.mjs +1 -1
  179. package/lib/sandforge-empty.mjs +15 -15
  180. package/lib/sandforge-env.mjs +101 -101
  181. package/lib/sandforge-frozen.mjs +1 -257
  182. package/lib/sandforge-mcp.mjs +33 -14
  183. package/lib/sandforge-monitor.mjs +7 -7
  184. package/lib/sandforge-pipeline.mjs +88 -0
  185. package/lib/sandforge-seed.mjs +1 -1
  186. package/lib/sandforge-sync.mjs +1 -1
  187. package/lib/sandforge.mjs +6 -6
  188. package/package.json +2 -1
  189. package/lib/chunk-2S5OMIIA.mjs +0 -7
  190. package/lib/chunk-36U7IQ6Y.mjs +0 -25
  191. package/lib/chunk-3F5YMM2F.mjs +0 -7
  192. package/lib/chunk-3RYLICRX.mjs +0 -7
  193. package/lib/chunk-42RER7V4.mjs +0 -14
  194. package/lib/chunk-4GL773D5.mjs +0 -7
  195. package/lib/chunk-4HFRHFGQ.mjs +0 -7
  196. package/lib/chunk-4U6NXJNL.mjs +0 -7
  197. package/lib/chunk-4XZ5YT5O.mjs +0 -7
  198. package/lib/chunk-5AJRHRXA.mjs +0 -20
  199. package/lib/chunk-5HMAPZBV.mjs +0 -7
  200. package/lib/chunk-5P4PHJRL.mjs +0 -9
  201. package/lib/chunk-5QKTYCWE.mjs +0 -11
  202. package/lib/chunk-6LAXTAVN.mjs +0 -7
  203. package/lib/chunk-6MUEPV7M.mjs +0 -9
  204. package/lib/chunk-6QSM2WIH.mjs +0 -10
  205. package/lib/chunk-75ADZS6B.mjs +0 -7
  206. package/lib/chunk-ALJVEUUS.mjs +0 -7
  207. package/lib/chunk-ALUFROGA.mjs +0 -7
  208. package/lib/chunk-B45CNPUX.mjs +0 -47
  209. package/lib/chunk-BS5T3MOQ.mjs +0 -7
  210. package/lib/chunk-CGWXQX75.mjs +0 -7
  211. package/lib/chunk-D3QRXG63.mjs +0 -787
  212. package/lib/chunk-EEVVGGM6.mjs +0 -7
  213. package/lib/chunk-ENLBYECD.mjs +0 -7
  214. package/lib/chunk-EQOQASDQ.mjs +0 -7
  215. package/lib/chunk-FQBRBBY4.mjs +0 -7
  216. package/lib/chunk-GAM726CK.mjs +0 -7
  217. package/lib/chunk-HJC7AIBK.mjs +0 -7
  218. package/lib/chunk-HUMEKZT5.mjs +0 -8
  219. package/lib/chunk-I3JKJTLO.mjs +0 -110
  220. package/lib/chunk-I7O6C2B5.mjs +0 -8
  221. package/lib/chunk-KLX67VPL.mjs +0 -7
  222. package/lib/chunk-L776PUMV.mjs +0 -7
  223. package/lib/chunk-LRFAIUN7.mjs +0 -7
  224. package/lib/chunk-LV6G4XTK.mjs +0 -7
  225. package/lib/chunk-MYTIL2JD.mjs +0 -10
  226. package/lib/chunk-NEVXIGR6.mjs +0 -10
  227. package/lib/chunk-NGSMZZDA.mjs +0 -7
  228. package/lib/chunk-NHWE66K5.mjs +0 -7
  229. package/lib/chunk-OQOZAPCI.mjs +0 -7
  230. package/lib/chunk-PA3MKJVH.mjs +0 -7
  231. package/lib/chunk-QROPNEGY.mjs +0 -14
  232. package/lib/chunk-QWT2C74M.mjs +0 -7
  233. package/lib/chunk-RH3N2H7P.mjs +0 -7
  234. package/lib/chunk-SRQDABQ2.mjs +0 -15
  235. package/lib/chunk-SVS6UMDU.mjs +0 -323
  236. package/lib/chunk-TNXUU6W7.mjs +0 -14
  237. package/lib/chunk-VGW4MXXZ.mjs +0 -7
  238. package/lib/chunk-VXHDBYMI.mjs +0 -7
  239. package/lib/chunk-WJY54JO7.mjs +0 -13
  240. package/lib/chunk-WRU5FJFC.mjs +0 -7
  241. package/lib/chunk-X2PY6MWZ.mjs +0 -7
  242. package/lib/chunk-XEFDB2R4.mjs +0 -7
  243. package/lib/chunk-XETCPL7E.mjs +0 -7
  244. package/lib/chunk-Y5CGXLUB.mjs +0 -7
  245. package/lib/chunk-Y6J6QFI2.mjs +0 -7
  246. package/lib/chunk-YMJVMFPY.mjs +0 -7
  247. package/lib/chunk-YPSRZRIT.mjs +0 -7
  248. package/lib/chunk-YS4G22C2.mjs +0 -7
  249. package/lib/chunk-YW2SBL4Z.mjs +0 -7
  250. package/lib/chunk-Z7X534S4.mjs +0 -10
  251. package/lib/chunk-ZE6HKRR4.mjs +0 -9
  252. package/lib/chunk-ZLZRU6MO.mjs +0 -7
  253. package/lib/chunk-ZPYJPGDK.mjs +0 -7
  254. package/lib/chunk-ZQOZ4EFW.mjs +0 -7
  255. package/lib/chunk-ZUTYVST5.mjs +0 -7
  256. package/lib/chunk-ZYEE34WO.mjs +0 -7
@@ -0,0 +1,156 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{a as _e}from"./chunk-TW3N6W5Z.mjs";import{a as Le,b as Ee,c as Te,d as De}from"./chunk-5GBO4KD5.mjs";import{a as ye,j as $e,l as M}from"./chunk-O7DAFE6M.mjs";import{b as G,e as H}from"./chunk-BZ24IAP5.mjs";import{a as U}from"./chunk-SCKUIE3R.mjs";import{c as J}from"./chunk-6FARZYMJ.mjs";import{a as Me}from"./chunk-E2OBAWSH.mjs";import{f as pe,j as Q,k as T,m as ge,n as _,o as D,p as we}from"./chunk-OMZJ37JI.mjs";import{a as Se,c as je,d as xe,e as Re,f as Ce,g as Oe,h as Ie,i as Pe,j as Ne}from"./chunk-VSU74RQ3.mjs";import{Qc as fe,za as le}from"./chunk-CAFUNR6D.mjs";import{h as be,i as ke}from"./chunk-AITNZWLB.mjs";import{m as ve}from"./chunk-KGYXLSQ5.mjs";import{l as me}from"./chunk-6SEDOIO3.mjs";import{h as he}from"./chunk-MNITSYI2.mjs";import{b as oe}from"./chunk-HVC5CYIB.mjs";import{b as ne,c as re,e as ae,f as ie,h as Ae}from"./chunk-LCDPCUXS.mjs";import{q as ue}from"./chunk-55LQD3Y3.mjs";import{e as de,g as ce}from"./chunk-TZE3Y7IQ.mjs";import{Jc as se,xc as te,y as W}from"./chunk-DPYTG6DM.mjs";import{readFileSync as Xe}from"node:fs";import{basename as Ke,join as Ve}from"node:path";var Ze=`sandforge dataops \u2014 mask an org's records, and put them back, without the editor.
8
+
9
+ Usage:
10
+ npx sandforge dataops anonymize \\
11
+ --org <alias> [--object <ApiName>] (--template <id> | --rules <file>) [options]
12
+ npx sandforge dataops anonymize \\
13
+ --org <alias> --restore <snapshot or set> [--slice <k[,k]>] [--rewrite-all]
14
+ [--include-changed] [--store <dir>] [--yes]
15
+ npx sandforge dataops anonymize \\
16
+ --org <alias> (--template <id> | --rules <file>) --abandon [--store <dir>] [--yes]
17
+ A run and a restore take [--accept-automation] [--accept-emails] [--mute-automation].
18
+
19
+ Required:
20
+ anonymize the command
21
+ --org <alias> sf CLI alias of the org
22
+ --template <id> a template that ships (tpl-gdpr-standard, tpl-ccpa-california,
23
+ tpl-hipaa-health, tpl-sandbox-scrub) or one saved in the store
24
+ --rules <file> or a JSON file of rules, saved in the store as a template:
25
+ {"name": "...", "rules": [{"fieldPattern": "Contact.Email",
26
+ "ruleType": "hash"}]} \u2014 a rule as the panel's editor saves it
27
+
28
+ Options:
29
+ --object <ApiName> the object to mask, one per run; without it, every object
30
+ the template masks, as the panel's Apply masks them \u2014
31
+ Account's person accounts among them, in an org that has
32
+ person accounts, when the template masks contacts
33
+ --where <clause> with --object: mask only the records this SOQL condition
34
+ selects, written without WHERE
35
+ --dry-run say what a run would mask \u2014 the fields, the records, the
36
+ first records masked as a run masks them \u2014 and write
37
+ nothing
38
+ --slices mask in slices of --max-records records each, consecutive
39
+ by Id, each backed up just before it is masked and masked
40
+ from that backup: an object past what one snapshot holds
41
+ is masked with a way back. With --dry-run, their plan: the
42
+ slices, the requests against what the org has left today,
43
+ the disk and the time. A slice that cannot be backed up
44
+ whole stops the run there, and the slices before it stay
45
+ masked with their backups
46
+ --max-requests <n> with --slices: the most requests the run sends. It stops
47
+ between two slices before the next would send more, exit
48
+ 3, and --resume masks the rest
49
+ --resume mask only what the last run of the same template, object
50
+ and filter left, from where it stopped; of a run in
51
+ slices, the rest of its set, with the key it was masked
52
+ with
53
+ --abandon give up the set of slices of the template left open on the
54
+ org: nothing more is masked, and no resume carries it on.
55
+ Its slices stay masked, each with its snapshot, which
56
+ --restore puts back until the retention removes them; the
57
+ records no slice reached keep their values. It writes
58
+ nothing to the org
59
+ --restore <id> put back the values a snapshot holds, by Id: the id a run
60
+ printed, a snapshot's or a set of slices'. Of a set, every
61
+ slice not put back yet, in their order: stopped part way,
62
+ the same line puts back the rest. It reads the org's
63
+ values first and writes only the rows where one of them
64
+ differs from the snapshot, and says how many it found
65
+ unchanged
66
+ --slice <k[,k]> with --restore of a set of slices: only these slices, by
67
+ their number, put back again if they were already
68
+ --rewrite-all with --restore: write every row of the snapshot back,
69
+ the ones the org already holds as the snapshot does
70
+ included; of a set, every slice, those put back already
71
+ too
72
+ --include-changed with --restore of the snapshot a Sync run kept of what
73
+ it wrote over: put back the records changed or deleted
74
+ since the run too, which a restore of it otherwise
75
+ leaves as they are and counts, as removing the run does
76
+ --max-age-days <n> the retention, as sandforge.backup.maxAgeDays sets it:
77
+ snapshots taken more than <n> days ago are removed as
78
+ the command starts, each named on stderr \u2014 the one a
79
+ Sync run kept of what it wrote over too, which removing
80
+ that run then no longer puts back; 0 keeps them all
81
+ (default: 30)
82
+ --store <dir> where snapshots, saved templates and checkpoints live, a
83
+ folder of your own, and the key of each run in slices
84
+ until its set ends, in keys/, read by its owner alone;
85
+ the one sandforge backup reads and lists (default:
86
+ ~/.sandforge/backups, under the folder
87
+ SANDFORGE_JOURNAL_DIR names when it is set)
88
+ --max-records <n> most records of the object a snapshot holds, as
89
+ sandforge.backup.maxRecordsPerObject sets it; a run with
90
+ more writes nothing, and a dry run says so \u2014 past it,
91
+ --slices masks in slices of this size (default: 50000;
92
+ 100 to 1000000, any other refused, exit 2)
93
+ ${Te("written over","--dry-run")} --yes do not ask before writing. Without it, a command with no
94
+ terminal to answer the question \u2014 a CI step \u2014 stops
95
+ there, exit 2, and writes nothing. It answers no to a
96
+ restore into a sandbox refreshed since its snapshot,
97
+ which only a yes typed in a terminal writes
98
+ --json emit what the panel would receive, every other line on
99
+ stderr; a preview's original values are left out
100
+ --help this text
101
+
102
+ A run takes a snapshot of the records it masks, their masked fields as they are,
103
+ before its first write, and writes nothing unless the snapshot holds every one of
104
+ them. A production org is refused.
105
+
106
+ With --slices, each slice is backed up just before it is masked, and masked from
107
+ that backup, so a record created since is never masked without one: a run says
108
+ at its end the records created during it in a range a slice masked, which
109
+ --resume masks with a slice of their own. The key the run hashes and draws its
110
+ people with is kept in the store's keys/ until its set is done or given up, so a
111
+ resume, in another process too, masks the same values the same way. While the
112
+ set is open, a new run of the template is refused: --resume masks the rest, and
113
+ --abandon gives the set up. The run writes over REST, 200 records a call, and
114
+ sends no Bulk API batch.
115
+
116
+ Before it writes, a run and a --restore say what the org runs as the records are
117
+ written over \u2014 its record-triggered flows, Apex triggers, processes and workflow
118
+ rules on update, and on undelete for what a restore brings back from the recycle
119
+ bin \u2014, the emails that sends against what the org has left today, and whether
120
+ the org delivers them; a dry run says it too, and what a real run would be
121
+ refused for (with --json, the dataops:automation:response it carries).
122
+
123
+ Ctrl-C stops a run as the panel's Cancel does: before its next page, what it
124
+ masked recorded in the audit trail of the store, and --resume masks only what it
125
+ left \u2014 of a run in slices, from where the slice it was in stopped. It stops a
126
+ --restore before its next batch, what it put back recorded the same way, and the
127
+ same --restore puts back the rest. Ctrl-C again ends the process at once. A
128
+ SIGTERM \u2014 a CI job cancelled or timed out \u2014 or a SIGHUP stops it the same way.
129
+
130
+ Exit codes: 0 the run masked every record it counted, or the restore put back
131
+ every value; 1 it could not start, was refused or failed \u2014 what the org runs as
132
+ it writes, without --accept-automation (AUTOMATION_NOT_ACCEPTED), emails it
133
+ delivers, without --accept-emails (EMAILS_NOT_ACCEPTED), more emails than it
134
+ has left today (EMAILS_EXCEEDED), or a mute refused among the reasons \u2014, or a
135
+ --dry-run saw that a run would be refused; 2 a bad command line,
136
+ or a question with no terminal to answer it (give --yes); 3 the run left
137
+ records unmasked, their personal data still in the org (--resume masks what
138
+ it left) \u2014 of a run in slices, slices it did not reach, stopped by
139
+ --max-requests or the org's day, or records created during it in a range a
140
+ slice masked \u2014, or the restore left values as they are (rows the org refused, a
141
+ snapshot that holds part of the records, or records of a Sync run's snapshot
142
+ changed since the run, held back without --include-changed); 130 Ctrl-C
143
+ stopped the run, 143 a SIGTERM, 129 a SIGHUP.
144
+ `,qe=1e9,Ye=/^[A-Za-z][A-Za-z0-9_]{0,79}$/,et={words:1,switches:["--dry-run","--resume","--slices","--abandon","--rewrite-all","--include-changed","--yes","--json",...Le],values:["--org","--object","--template","--rules","--where","--restore","--slice","--store","--max-records","--max-requests","--max-age-days"]};function g(s){process.stderr.write(`${s}
145
+ `),process.exit(2)}function tt(s){let e;try{e=JSON.parse(Xe(s,"utf8"))}catch(r){g(`Cannot read the rules in ${s}: ${r instanceof Error?r.message:String(r)}`)}let n=Array.isArray(e)?{rules:e}:e,a=typeof n=="object"&&n!==null&&!("name"in n)?{...n,name:`Rules from ${Ke(s)}`}:n,o=le.safeParse(a);if(!o.success){let r=o.error.issues.map(d=>`${d.path.join(".")||"(file)"}: ${d.message}`).join("; ");g(`The rules in ${s} are not rules the panel saves: ${r}`)}return o.data}function st(s){let e=s.slice(2);(e.includes("--help")||e.includes("-h"))&&(process.stdout.write(Ze),process.exit(0)),e[0]!=="anonymize"&&g(`The command is anonymize: ${U("dataops")} anonymize --org \u2026 Run with --help.`),ne(e,et);let n=l=>{let b=e.indexOf(l),I=b>=0?e[b+1]:void 0;return b>=0&&(I===void 0||I.startsWith("--"))&&g(`${l} needs a value.`),I},a=l=>e.filter(b=>b===l).length,o=n("--org");o||g("Missing --org. Run with --help."),re.test(o)||g(`Not an sf alias: "${o}"`);let r=n("--restore"),d=e.includes("--dry-run"),C=e.includes("--resume"),w=e.includes("--slices"),x=e.includes("--abandon"),k=n("--max-records");k!==void 0&&!/^[1-9]\d*$/.test(k)&&g(`Not a number of records: "${k}"`),k!==void 0&&(Number(k)<_||Number(k)>D)&&g(`--max-records takes ${_} to ${D} records, not ${k}: a snapshot holds at least ${_} records of one object and at most ${D}; past that, --slices masks the object in slices of --max-records records, each backed up just before it is masked, or narrow the run with --where.`);let c=n("--max-requests");c!==void 0&&(!/^[1-9]\d{0,9}$/.test(c)||Number(c)>qe)&&g(`Not a number of requests, 1 to ${qe}: "${c}"`),c!==void 0&&!w&&r===void 0&&!x&&g("--max-requests bounds a run in slices: give it with --slices.");let p=Re(e,"--slice");p.length>0&&r===void 0&&g("--slice goes with --restore: it names the slices of a set to put back. A run in slices is --slices.");let h=e.includes("--rewrite-all");h&&r===void 0&&g("--rewrite-all goes with --restore.");let f=e.includes("--include-changed");f&&r===void 0&&g("--include-changed goes with --restore.");let R=xe(n("--max-age-days")),A={org:o,rewriteAll:h,includeChanged:f,...R!==void 0?{maxAgeDays:R}:{},storeDir:n("--store")??Se(),...k!==void 0?{maxRecords:Number(k)}:{},slices:w,...c!==void 0?{maxRequests:Number(c)}:{},yes:e.includes("--yes"),json:e.includes("--json"),accord:Ee(e)};if(r!==void 0){let l=["--object","--template","--rules","--where","--dry-run","--resume","--slices","--max-requests","--abandon"].filter(b=>e.includes(b));return l.length>0&&g(`--restore puts a snapshot back as it is: drop ${l.join(", ")}.`),{...A,mode:"restore",restoreId:r,...p.length>0?{restoreSlices:Ce(p)}:{}}}if(x){let l=["--dry-run","--resume","--max-requests"].filter(b=>e.includes(b));l.length>0&&g(`--abandon gives a set of slices up and masks nothing: drop ${l.join(", ")}.`)}a("--object")>1&&g("Give one --object at most: a run masks one object, or every object its template masks.");let $=n("--object");$!==void 0&&!Ye.test($)&&g(`Not an SObject API name: "${$}"`);let v=n("--template"),m=n("--rules");v===void 0==(m===void 0)&&g("Give one of --template or --rules: the rules a run masks with."),d&&C&&g("Give one of --dry-run or --resume.");let y=n("--where")?.trim();return y!==void 0&&(y===""||!de(y))&&g(`Not a filter --where can take: "${y}". ${ce}`),y!==void 0&&$===void 0&&g("--where filters the records of one object: give it with --object."),{...A,mode:x?"abandon":d?"dry-run":C?"resume":"run",...$!==void 0?{object:$}:{},...v!==void 0?{templateId:v}:{},...m!==void 0?{rules:tt(m)}:{},...y!==void 0?{where:y}:{}}}function Be(s,e){let n=`${e.toLowerCase()}.`;return s.rules.filter(a=>a.fieldPattern.toLowerCase().startsWith(n)||a.fieldPattern==="*")}function nt(s,e){return Be(s,e).length>0?!0:e.toLowerCase()===ue.toLowerCase()&&pe(s.rules).length>0}function rt(s,e){let n=a=>JSON.stringify(a.map(o=>[o.fieldPattern.toLowerCase(),o.ruleType,o.config??null]).sort((o,r)=>String(o[0]).localeCompare(String(r[0]))));return n(s)===n(e)}function ot(s){if(s==null||s==="")return"(empty)";let e=typeof s=="string"?s:JSON.stringify(s);return JSON.stringify(e.length>40?`${e.slice(0,39)}\u2026`:e)}function ze(s,e){let n=[];typeof s.message=="string"&&n.push(s.message);for(let d of s.objects??[])n.push(` ${d.objectApiName.padEnd(28)} counted ${d.total} masked ${d.processed} refused ${d.failed} still original ${d.notMasked}`);let a=s.errors??[];a[0]&&n.push(` e.g. ${a[0].objectApiName}: ${a[0].message}`);let o=s.snapshot;o&&n.push(`snapshot ${o.operationId}: ${o.totalRecords} record(s) as they were before the run. To put their values back:`,` ${e(o.operationId)}`);let r=s.slices;return r&&n.push(...at(r,e)),n}function at(s,e){let n=s.objects.flatMap(r=>r.slices).sort((r,d)=>r.index-d.index),a=n.filter(r=>r.state==="masked").length,o=[`set ${s.setId} (${s.state}): ${a} of ${n.length} slice(s) masked, up to ${s.size} records a slice, ${s.requestsSpent} request(s) sent by this run`,...n.map(r=>` slice ${r.index} ${r.objectApiName.padEnd(20)} ${r.state.padEnd(8)} ${r.rows} record(s) masked ${r.masked} refused ${r.refused} deleted since ${r.deletedSince}${r.late?" created during the run":""}${r.sizeUsed!==void 0?` read ${r.sizeUsed} at a time`:""} snapshot ${r.snapshotId}`)];return s.lateRecords>0&&o.push(` ${s.lateRecords} record(s) created during the run in a range a slice masked, or past its last: no snapshot holds them, and they keep their values`),n.some(r=>r.state!=="pending")&&o.push("To put back the values its slices hold, every slice in one line:",` ${e(s.setId)}`),o}function it(s,e){return`${s}.${e}: the org has no such field, or field-level security hides it from this user \u2014 a run is refused and masks nothing (give the user read and edit access to it, or take it out of the template)`}function Fe(s,e){return e===void 0?`${s}: this user may not edit its records \u2014 a run is refused (CRUD_FLS_DENIED) and masks nothing (give the user edit access to the object)`:`${s}.${e}: this user may read it and not edit it \u2014 a run is refused (CRUD_FLS_DENIED) and masks nothing (give the user edit access to it, or take it out of the template)`}function dt(s,e={},n=!1){let a=s.fieldsNotFound??[],o=s.objects??[],r=e.objects??[];return a.length>0||o.some(d=>d.notCovered===!0||d.error!==void 0||d.writeDenied!==void 0)||r.some(d=>d.count===null&&!(n&&d.slicePlan!==void 0))}function ct(s,e){let n=[],a=s.objects??[];for(let{objectApiName:d,count:C,slicePlan:w}of a)w!==void 0&&(!e&&C!==null&&C>w.size&&n.push(`${d} holds ${C} record(s), more than the ${w.size} a snapshot holds of one object: --slices masks it in ${w.slices} slices, each backed up just before it is masked (the same line with --slices shows their plan), or narrow the run with --where`),e&&w.slices>W&&n.push(`${d} would take ${w.slices} slices of ${w.size} records, more than the ${W} a set holds: give --max-records up to ${D}, or narrow the run with --where`));let o=s.plan;e&&o?.diskFree!==void 0&&Q(o.diskBytes)>o.diskFree&&n.push(`the slices' snapshots take about ${T(Q(o.diskBytes))}, and the store has ${T(o.diskFree)} free: give --store a folder on another disk, delete the backups no longer needed, or keep backups fewer days (--max-age-days)`);let r=s.sliceSet;return r?.state==="open"&&n.push(`set ${r.setId} of this template is still open on the org (${r.done} of ${r.total} slice(s) masked, last moved ${r.savedAt}), and a new run would mask its rows again: the same line with --resume masks the rest, and --abandon gives it up`),n}function ut(s,e){let n=s.apiBudget;if(n.verdict==="unread")return`the org's requests left today were not read (${n.unread??"no answer"}): the run stops between two slices if the org's day runs short, and --resume masks the rest`;let a=`of ${n.remaining??"?"} the org has left today`;if(n.verdict==="fits")return`${a}: fits`;if(n.verdict==="near")return`${a}: near it \u2014 the run stops between two slices before the org's integrations run short, and --resume masks the rest`;let o=s.requests/Math.max(1,e),r=Math.max(0,Math.floor((n.remaining??0)/Math.max(1,o)));return`${a}: more than that \u2014 about ${Math.min(r,e)} of the ${e} slices go today, the run stops between two of them, and --resume masks the rest`}function lt(s,e,n){let{snapshots:a,updates:o,reads:r}=s.parts;return[" a run in slices:",` requests: about ${s.requests} (snapshots ${a}, updates ${o}, reads ${r}) ${ut(s,e)}`," Bulk API batches: none (the run writes over REST, 200 records a call)",` disk: about ${T(s.diskBytes)} in ${n}`+(s.diskFree!==void 0?` (${T(s.diskFree)} free)`:""),` time: about ${se(s.seconds)}`]}function ht(s,e,n,a){let o=["dry run \u2014 nothing is written"],r=e.objects??[],d=n.objects??[],C=n.fieldsNotFound??[];for(let c of r){let p=c.count===null?"an unknown number of":String(c.count);o.push(` ${c.objectApiName}: ${p} record(s) to mask`);let h=a!==void 0?c.slicePlan:void 0;c.count===null&&o.push(h!==void 0?" not counted by the org: its own figure of the records plans the slices, approximate; the run reads the object a slice at a time by Id, whatever it holds":" not counted by the org: a run stops at its count and masks nothing"),h!==void 0&&o.push(` slices: ${h.approximate?"about ":""}${h.slices} of up to ${h.size} records, each backed up just before it is masked`);let f=d.find(m=>m.objectApiName===c.objectApiName);if(f?.error){o.push(` not read: ${f.error}`);continue}let R=new Map([...Be(s,c.objectApiName).map(m=>[m.fieldPattern.split(".").pop()?.toLowerCase()??"",m.ruleType]),...Object.entries(f?.methods??{}).map(([m,y])=>[m.toLowerCase(),y])]),A=f?.fields??[];o.push(` fields: ${A.map(m=>`${m} (${R.get(m.toLowerCase())??"?"})`).join(", ")||"(none)"}`);for(let m of C.filter(y=>y.objectApiName===c.objectApiName))o.push(` ${it(m.objectApiName,m.fieldApiName)}`);f?.notCovered&&o.push(" no field of it can be masked: a run is refused and masks nothing");let $=f?.writeDenied?.deniedFields;$?.length===0&&o.push(` ${Fe(c.objectApiName)}`);for(let m of $??[])o.push(` ${Fe(c.objectApiName,m)}`);let v=f?.rows??[];if(v.length>0){o.push(" the first records, masked as a run masks them (a run draws its own key, so its made-up names and digests differ from these):");for(let m of v)o.push(` ${m.id}: ${A.map(y=>`${y} ${ot(m.after[y])}`).join(", ")}`)}}let w=r.reduce((c,p)=>c+(p.count??0),0),x=e.plan;if(a!==void 0&&x!==void 0){let c=r.reduce((p,h)=>p+(h.slicePlan?.slices??0),0);o.push(...lt(x,c,a.store)),o.push(" a run backs each slice up just before it masks it, and masks it from that backup: a slice that cannot be backed up whole stops the run there, and the slices before it stay masked with their backups")}else w>0&&o.push(` a run takes a snapshot of these ${w} record(s) first, and writes nothing without it`);let k=e.checkpoint;return k&&o.push(` a run of this template, object and filter stopped short on ${k.savedAt}: --resume masks only what it left`),o}function pt(s){return`interrupted: the restore stopped before it was through; what it restored is in the audit trail, and the same line puts back the rest: ${s}`}function mt(s){return s!==void 0?`interrupted: the masking stopped before it was through; what it masked is in the audit trail, each slice it masked has its snapshot (--restore ${s} puts their values back), and the same line with --resume masks the rest, from where its slice stopped`:"interrupted: the masking stopped before it was through; what it masked is in the audit trail, the snapshot puts their values back (--restore), and the same line with --resume masks only what it left"}function ft(s){return s.map(e=>{if(e.type!=="dataops:anonymize:preview:response")return e;let n=e.payload?.objects??[];return{...e,payload:{...e.payload,objects:n.map(a=>({...a,rows:(a.rows??[]).map(({id:o,after:r})=>({id:o,after:r}))}))}}})}async function gt(s=process.argv){let e=st(s),n=t=>{process[e.json?"stderr":"stdout"].write(`${t}
146
+ `)},a=t=>{process.stderr.write(`${t}
147
+ `),process.exitCode=1},o=je(e.storeDir);if(o!==void 0){a(o);return}let r=await oe(e.org),d=await new Me().validateConnection(r.accessToken,r.instanceUrl),C={alias:e.org,orgType:te({isSandbox:d.isSandbox,edition:d.orgType}),metadata:{apiVersion:"66.0",edition:d.orgType}};n(`sandforge dataops ${e.org} (${d.isSandbox?"sandbox":d.orgType||"production"}) store: ${e.storeDir}`);let w=ve(Ve(e.storeDir,"snapshots.json")),x=[],k=new Map,c=new _e,p=new we({log:t=>{/^\[(WARN|INFO)\]/.test(t)&&n(` ${t}`)},broker:{postToWebview:t=>{if(x.push(t),t.type!=="operation:progress")return;let i=String(t.payload?.operationId??""),u=Number(t.payload?.percentage??0);(u-(k.get(i)??-10)>=10||u===100)&&(k.set(i,u),n(` ${u}% ${String(t.payload?.currentStep??"")}`))}},orgManager:{getOrg:()=>C},orgRegistry:{getCredentials:async()=>({accessToken:r.accessToken,instanceUrl:r.instanceUrl})},configStore:w,services:{getSandforgeSetting:Oe(e)},infraServices:{backgroundRegistry:c,productionGuard:new me({requestConfirmation:(t,i)=>(n(`refused: ${e.org} is taken for a ${i} org, and this command writes to none (${t})`),Promise.resolve(!1))}),confirmRestoreIntoReplacedOrg:({alias:t,backedUpFrom:i,now:u})=>e.yes?Promise.resolve(!1):M(`${t} answered as org ${i} when this snapshot was taken and answers as org ${u} now. Write its saved values into the org it is now?`)},nextId:()=>`cli-${Date.now()}-${Math.random().toString(36).slice(2,8)}`});p.setExpiryListener(t=>process.stderr.write(`${Ie(t)}
148
+ `)),p.setRunKeyStore(ge(e.storeDir)),p.setBackupRecordStore(new ke(be(e.storeDir))),await p.swept(),p.setSyncRuns(he(ye())),p.setMuteOffered($e("--mute-automation")),p.setOnCommandLine(!0);let h=async(t,i)=>{let u=`cli-${t.replaceAll(":","-")}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return await p.handle({id:u,type:t,timestamp:Date.now(),payload:i}),x.find(j=>j.correlationId===u&&(j.type===`${t}:response`||j.type==="dataops:error"))??{type:"dataops:error",payload:{message:`${t} was not answered.`}}},f=t=>t.type==="dataops:error",R=t=>String(t.payload?.message??t.type),A=t=>`${U("dataops")} anonymize --org ${e.org} --restore ${t} --store ${e.storeDir}`,$=async(t,i)=>{let u=await h("dataops:automation",{orgId:e.org,act:t,objects:i,...e.accord});if(f(u)){a(R(u));return}let S=u.payload;for(let j of S.lines)n(j);return S},v=t=>{e.json&&process.stdout.write(`${JSON.stringify({tool:"sandforge-dataops",command:t,org:e.org,...e.slices?{slices:!0}:{},posted:ft(x)},null,2)}
149
+ `)};if(e.mode==="restore"){let t=e.restoreId,i=Pe(w,t,{...e.restoreSlices?{slices:e.restoreSlices}:{},rewriteAll:e.rewriteAll});if(!i){a(`No snapshot or set of slices "${t}" in ${e.storeDir}.`);return}let u=i.objects.map(N=>N.objectApiName).join(", "),S=await $("restore",i.objects);if(!S){v("restore");return}if(S.refusals.length>0){v("restore");for(let N of S.refusals)a(J(N));return}if(!e.yes&&!await M(`Put back into ${e.org} the values ${i.words} holds? ${i.totalRecords} record(s) of ${u} will have those fields written over.`)){n("Nothing written.");return}n(`restoring ${t} into ${e.org}${e.rewriteAll?", every row written back":""}\u2026`);let j,He=H(N=>{j=N,process.stderr.write(`
150
+ interrupted: the restore stops before its next batch, and says what it restored (Ctrl-C again ends it at once)
151
+ `);for(let Je of c.getRunning())c.abort(Je.operationId)}),P;try{P=await h("dataops:rollback",{orgId:e.org,operationId:t,...e.rewriteAll?{rewriteAll:!0}:{},...e.includeChanged?{includeChanged:!0}:{},...e.restoreSlices?{slices:e.restoreSlices}:{},...e.accord})}finally{He()}if(v("restore"),f(P)){a(R(P)),e.yes&&P.payload?.code==="ORG_REPLACED_SINCE_BACKUP"&&a("--yes does not answer this question: it is answered yes only when typed in a terminal. Run the same line without --yes in a terminal to answer it; nothing answers it from a CI step.");return}n(String(P.payload?.message??""));for(let N of Ne(P.payload??{}))n(N);if(j){process.stderr.write(`${pt(A(t))}
152
+ `),process.exitCode=G(j);return}ie(ae(P.payload??{}));return}let y=(await h("dataops:anonymization-templates",{})).payload?.templates??[],l;if(e.rules){let t=e.rules,i=y.find(u=>u.saved===!0&&u.name.trim().toLowerCase()===t.name.toLowerCase());if(i&&rt(i.rules,t.rules))l=i;else{i&&await h("dataops:anonymization-template:delete",{templateId:i.id});let u=await h("dataops:anonymization-template:save",{name:t.name,rules:t.rules});if(f(u)){a(R(u));return}l=u.payload?.template,n(`rules saved in the store as template "${l.name}" (${l.id})`)}}else if(l=y.find(t=>t.id===e.templateId),!l){a(`No template "${e.templateId??""}". Templates: `+y.map(t=>`${t.id}${t.saved?` (saved: ${t.name})`:""}`).join(", "));return}let b=e.object;if(b!==void 0&&!nt(l,b)){a(`Template "${l.name}" has no rule for ${b}: a run would mask nothing.`);return}let I={orgId:e.org,templateId:l.id,...b!==void 0?{objects:[b]}:{},...e.where!==void 0?{where:e.where}:{}};if(n(`template: ${l.name} (${l.id}) `+(b!==void 0?`object: ${b}`:"objects: every object the template masks")+(e.where!==void 0?` where: ${e.where}`:"")+(e.slices?" in slices":"")),e.mode==="abandon"){let t=new fe(w).openFor(e.org,l.id);if(t&&!e.yes){let u=t.objects.flatMap(j=>j.slices).filter(j=>j.state==="masked").length,S=t.objects.reduce((j,ee)=>j+ee.slices.length,0);if(!await M(`Give up set ${t.setId} of ${l.name} on ${e.org}, ${u} of ${S} slice(s) masked, last moved ${t.lastActivityAt}? Nothing more is masked and no resume carries it on; its slices stay masked, each with its snapshot, which --restore ${t.setId} puts back until the retention removes them.`)){n("Nothing given up.");return}}let i=await h("dataops:anonymize",{...I,abandon:!0});v("abandon");for(let u of ze(i.payload??{},A))n(u);f(i)&&(process.exitCode=1);return}let O=await h("dataops:anonymize:coverage",{...I,...e.slices?{slices:!0}:{}});if(f(O)){a(R(O));return}let L=O.payload?.objects??[],Ue=L.reduce((t,i)=>t+(i.count??0),0),We=e.slices?L.filter(t=>t.count===null&&t.slicePlan!==void 0):[],q=O.payload?.sliceSet,K=L.map(t=>({objectApiName:t.objectApiName,records:t.count??(e.slices&&t.slicePlan!==void 0?t.slicePlan.slices*t.slicePlan.size:0)}));if(e.mode==="dry-run"){let t=await h("dataops:anonymize:preview",I);if(f(t)){v("dry-run"),a(R(t));return}for(let S of ht(l,O.payload??{},t.payload??{},e.slices?{store:e.storeDir}:void 0))n(S);let i=await $("masking",K);if(v("dry-run"),!i)return;for(let S of De(i))n(S);let u=ct(O.payload??{},e.slices);for(let S of u)n(` a run would be refused: ${S}`);(u.length>0||i.refusals.length>0||dt(t.payload??{},O.payload??{},e.slices))&&(process.exitCode=1);return}let V=O.payload?.checkpoint;if(e.mode==="resume"&&!V){a(q!==void 0?`There is nothing to resume for this object and filter: set ${q.setId} of this template is open on ${e.org}, its run given another object or filter. Its own line with --resume masks the rest, and --abandon gives it up.`:`There is nothing to resume: no run of this template, object and filter stopped short in ${e.storeDir}.`);return}let Z=e.mode==="resume"&&q!==void 0;if(e.mode==="run"&&Ue===0&&We.length===0){let t=L.filter(i=>i.count===null).map(i=>i.objectApiName);if(t.length>0){a(`${t.join(", ")}: the org did not count the records a run would mask, so nothing was masked (its reason is in the warning above).`);return}n(b!==void 0?"Nothing to mask: no record of the object is under the filter.":"Nothing to mask: no object the template masks holds a record."),v("run");return}let z=await $("masking",K);if(!z){v(e.mode);return}if(z.refusals.length>0){v(e.mode);for(let t of z.refusals)a(J(t));return}if(!e.yes){let t=b??L.map(i=>i.objectApiName).join(", ");if(!await M(wt(e,l.name,t,O,Z))){n("Nothing written.");return}}n(e.mode==="resume"?"resuming\u2026":"masking\u2026");let F,Ge=H(t=>{F=t,process.stderr.write(`
153
+ interrupted: the masking stops before its next page, and says what it masked (Ctrl-C again ends it at once)
154
+ `);for(let i of c.getRunning())c.abort(i.operationId)}),Y=e.slices||Z,E;try{E=await h("dataops:anonymize",{...I,...e.mode==="resume"?{resumeFrom:V.id}:{snapshot:!0},...Y?{slices:!0}:{},...Y&&e.maxRequests!==void 0?{maxRequests:e.maxRequests}:{},...e.accord})}finally{Ge()}v(e.mode);for(let t of ze(E.payload??{},A))n(t);let B=E.payload?.slices;if(F){process.stderr.write(`${mt(B?.setId)}
155
+ `),process.exitCode=G(F);return}if(f(E)){process.exitCode=1;return}(Number(E.payload?.recordsNotMasked??0)>0||B?.state==="open")&&(B===void 0&&n("A resume masks only what this run left: the same line with --resume, in place of the snapshot it does not take again."),process.exitCode=3)}function wt(s,e,n,a,o){let r=a.payload?.objects??[],d=a.payload?.sliceSet,C=a.payload?.checkpoint;if(s.mode==="resume")return o&&d!==void 0?`Resume the masking of ${n} in ${s.org} in slices, set ${d.setId}: ${d.done} of ${d.total} slice(s) masked, last moved ${d.savedAt}? Each slice left is backed up just before it is masked, with the key the set was masked with.`:`Resume the masking of ${n} in ${s.org} that stopped on ${C?.savedAt??"?"}? What it left is written over; the snapshot the first run took holds their values.`;let w=r.reduce((A,$)=>A+($.count??0),0),x=r.some(A=>A.count===null),k=x?`the records of ${n}`:`${w} record(s) of ${n}`;if(!s.slices)return`Mask ${k} in ${s.org} with ${e}? A snapshot of their values is taken first.`;let c=r.reduce((A,$)=>A+($.slicePlan?.slices??0),0),p=a.payload?.plan,h=p?.apiBudget,f=p!==void 0?p.requests/Math.max(1,c):0,R=h?.remaining!==void 0&&f>0?Math.min(c,Math.floor(h.remaining/f)):void 0;return`Mask ${k} in ${s.org} with ${e}, in ${x?"about ":""}${c} slice(s)? Each slice is backed up just before it is masked; if one cannot be backed up whole, the run stops there and the slices before it stay masked with their backups.`+(h?.verdict==="exceeds"&&R!==void 0?` The org has ${h.remaining} requests left today, enough for about ${R} of them: the run stops between two slices, and the same line with --resume masks the rest.`:"")}/sandforge-dataops\.[cm]?[jt]s$/.test(process.argv[1]??"")&&(Ae(),gt().then(()=>process.exit()).catch(s=>{process.stderr.write(`${s instanceof Error?s.message:String(s)}
156
+ `),process.exit(1)}));export{st as a,nt as b,ze as c,at as d,it as e,Fe as f,dt as g,ct as h,lt as i,ht as j,pt as k,mt as l,gt as m,wt as n};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a,b}from"./chunk-5HMAPZBV.mjs";import"./chunk-B45CNPUX.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{a as describedFieldsOf,b as requiredForAccountKinds};
7
+ import{a,b}from"./chunk-56MPPWLA.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as describedFieldsOf,b as requiredForAccountKinds};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{b as ie,c as se,d as Vt,e as Jt,f as be}from"./chunk-AITNZWLB.mjs";import{a as Zt,e as Xt}from"./chunk-6SEDOIO3.mjs";import{J as re,P as Ue,a as Kt}from"./chunk-ZWCRWF7E.mjs";import{f as Le,p as ge,s as Be,u as Yt,w as $e}from"./chunk-MNITSYI2.mjs";import{c as qt}from"./chunk-T26C576X.mjs";import{b as me,d as ue}from"./chunk-BNO5GIJ6.mjs";import{G as Ht}from"./chunk-XEB6HZ34.mjs";import{c as Gt,e as Fe,g as Me,h as pe}from"./chunk-TZE3Y7IQ.mjs";import{c as Wt}from"./chunk-EAFLDSQ2.mjs";import{a as $t,b as V}from"./chunk-CA5NAXSU.mjs";import{C as dt,D as pt,E as mt,Ea as zt,F as ut,Fa as St,Gc as Nt,J as gt,K as bt,Ka as ae,Kb as wt,L as ft,La as Ae,M as yt,Mb as vt,N as ht,Nb as At,Pa as M,Qa as xt,Qb as Et,Qc as Dt,Ra as F,Rb as Ct,Rc as Ft,Sa as Ee,Sb as Tt,Sc as Mt,Ta as It,Td as Lt,Ua as kt,Uc as Ut,Ud as Bt,Va as Ce,Vc as De,Wa as Te,Xa as _e,Zb as _t,cb as Ne,fb as jt,gb as Pt,hb as Ot,n as rt,s as we,t as it,tb as Rt,u as st,v as ct,w as ne,y as lt,z as ve}from"./chunk-DPYTG6DM.mjs";import{b as a,c as Oe,e as g,f as r,g as et,i as D,k as c,l as o,m as tt,o as de,p as Re,s as x,u as w,v,w as ot,x as nt,y as G,z as at}from"./chunk-WZQEK4WT.mjs";function sa(e,t,n){return async s=>{let d=s.map(f=>`${f.objectApiName} (${f.records})`).join(", ");e.log(`[WARN] ${n}: the user may not delete ${d} in the target: those records stay`);let p=e.infraServices?.confirmRemovalLeavingUndeletable;if(!p)return!0;let u=e.orgManager.getOrg(t);return p({org:Nt(u,t),objects:s})}}var Qt={code:"NOT_INITIALIZED",message:"Production Guard is not initialized \u2014 infrastructure services missing"};function ca(){return Object.assign(new Error(Qt.message),{code:Qt.code})}var qe={blocked:"GUARD_BLOCKED",declined:"GUARD_DECLINED"};function la(e){return Object.assign(new Error(`Operation blocked by Production Guard: ${e}`),{code:qe.blocked})}function da(e){return e instanceof Error&&e.code===qe.blocked?qe.blocked:void 0}function Bo(e){return e.robustness??zt}function pa(e){return e.bulkManager??new Kt(Bo(e).bulk.maxConcurrentJobs)}var $o={"sync:schedule":"sync:schedule:","sync:pipeline":"sync:pipeline:","seed:pipeline":"seed:pipeline:","offline-replay":"offline-replay-"};function ma(e,t,n){return{id:`${$o[e]}${t}`,type:n,timestamp:Date.now()}}function ua(e,t,n,s){return{id:e.nextId(),type:n,timestamp:Date.now(),correlationId:t.id,payload:s}}function ga(e,t,n,s,d={}){let p=t==="error"?null:d.autoDismissMs===void 0?5e3:d.autoDismissMs,u={id:e.nextId(),type:"notification",timestamp:Date.now(),payload:{level:t,title:n,message:s,...p===null?{}:{autoDismissMs:p},...d.actions?{actions:d.actions}:{},...d.code?{code:d.code}:{}}};e.broker.postToWebview(u),e.log(`[TX] notification: ${n}`)}function ba(e,t,n,s){let d={id:e.nextId(),type:"operation:started",timestamp:Date.now(),payload:{operationId:t,module:n,description:s}};e.broker.postToWebview(d)}function fa(e,t,n,s,d,p){let u={id:e.nextId(),type:"operation:progress",timestamp:Date.now(),payload:{operationId:t,percentage:n,processedRecords:s,totalRecords:d,currentStep:p}};e.broker.postToWebview(u)}function ya(e,t,n){let s={id:e.nextId(),type:"operation:completed",timestamp:Date.now(),payload:{operationId:t,result:n}};e.broker.postToWebview(s)}var qo=Symbol("sandforge.uncorrelated");function eo(e,t,n,s,d,p={}){let u=V(d),f=d instanceof qt?d:void 0,k=qo in s,E=p.code??f?.code??"UNKNOWN";k||Ko(e.broker,u,E),e.log(`[ERR] ${t}: ${u}${k?` (uncorrelated: ${String(s.reason)})`:""}`);let O={id:e.nextId(),type:n,timestamp:Date.now(),...k?{}:{correlationId:s.id},payload:{message:u,code:E,retryable:p.retryable??!1,...f?{orgId:f.orgId}:{},...p.extraPayload}};e.broker.postToWebview(O),e.log(`[TX] ${n}: ${u}`)}function ha(e,t){let n={id:e.nextId(),type:t.type,timestamp:Date.now(),payload:t.payload};e.broker.postToWebview(n)}function za(e){let t=e?.getSandforgeSetting;if(!(!t||!t("grappe.enabled",!1)))return{enabled:!0,autoActivateThreshold:t("grappe.autoActivateThreshold",1e4),maxWorkers:rt.maxWorkers,grappeSize:t("grappe.grappeSize",5e3),strategy:"round_robin",backPressure:{enabled:!1,maxQueueDepth:3,highWaterMark:80,lowWaterMark:60,strategy:"pause",monitoringInterval:5e3},checkpointing:!0,isolationLevel:"per_grappe"}}function Sa(e){let t=new Set(e.map(s=>s.batchSize)),[n]=t;return{...e.length>0?{objectName:e.map(s=>s.objectApiName).join(", ")}:{},...t.size===1&&n!==void 0?{batchSize:n}:{}}}function xa(e,t,n,s,d={}){let p={id:e.nextId(),type:"operation:failed",timestamp:Date.now(),payload:{operationId:t,error:n,retryable:s,...d.extraPayload}};e.broker.postToWebview(p),d.authored!==!0&&Zo(e,n,d.context)}var Go=[/^Operation cancelled by user\b/,/^Operation blocked by Production Guard: /,/^Production Guard is not initialized\b/,/^Duplicate operation: /,/^A backup or rollback operation is already running for org /,/^Object describe not available for '/,/^CRUD_FLS_DENIED: /,/^CRUD\/FLS check failed for /,/^No backup found for operation /,/^Backup \S+ was taken from org /,/^Restore not run: /,/^Pipeline failed$/,/^Pipeline did not start: /,/^Pipeline ran out of time: /,/^Org not found: /,/^No credentials for org /,/^Invalid username format: /];function Wo(e){return Go.some(t=>t.test(e))}var to=1e4,Ge=new WeakMap;function Ko(e,t,n){let s=De(t,{code:n});if(!s?.actionKey)return;let d=Ge.get(e)??new Map,p=Date.now();for(let[u,f]of d)p-f>to&&d.delete(u);d.set(s.code,p),Ge.set(e,d)}function Ho(e,t){let n=Ge.get(e)?.get(t);return n!==void 0&&Date.now()-n<=to}function Zo(e,t,n={}){if(!(e.broker.panelCount>0)||Wo(t))return;let d=$t(t,Ut)??"UNKNOWN",p=De(t,{code:d});if(p?.actionKey){if(Ho(e.broker,p.code))return;e.broker.showFixSuggestion({source:"catalogue",code:p.code,actionKey:p.actionKey});return}let u=e.errorResolver;u&&u.resolveError({errorCode:d,message:t},n).then(f=>{e.broker.showFixSuggestion({source:"model",text:Xo(f)})}).catch(f=>{e.log?.(`[ERR] operation:failed resolution: ${V(f)}`)})}function Xo(e){return e.suggestions[0]?.description||e.explanation}import{isAbsolute as tn}from"node:path";var i=a().min(1).max(128),l=a().regex(/^[A-Za-z][A-Za-z0-9_]*$/,"Invalid Salesforce API name").max(80),so=c(l).max(300),m=a().min(1).max(200),J=a().max(2e3).refine(Fe,{message:Me}),on=a().refine(Gt,{message:"ORDER BY clause must list only field names with optional ASC/DESC and NULLS FIRST/LAST (no LIMIT, OFFSET, FOR UPDATE or subquery)."}),y=100,co=1e4,B=o({keepDays:g().int().min(ve.min).max(ve.max).optional(),excluded:c(l).max(y).refine(e=>new Set(e).size===e.length,"An object is left out twice").optional()}).strict(),he={sweepLate:r().optional(),sweepUntied:r().optional()};function nn(e){return Wt(e)}function an(e,t='turn on "Copy the files of these records"'){return _t(e)?`Sync copies files with the records they hang on, not as an object of their own: "${e}" keeps its content in a file body. Remove it from this configuration and ${t} instead; the sync was not started.`:`Sync does not copy "${e}": no copy writes it \u2014 users and their access, metadata, a record's history, feed or sharing rows, and the records the platform keeps for itself are not data a copy carries. Remove it from this configuration; the sync was not started.`}var rn=w(gt,{error:e=>e.input==="manual"?"Manual conflict review is not available for a sync run: no run shows its conflicts to anyone before it writes. Pick source wins, target wins, newest wins or merge \u2014 target wins keeps every value the target holds where the two orgs differ. The sync was not started.":`Conflict strategy "${String(e.input)}" is not one a sync run acts on: pick source wins, target wins, newest wins or merge. The sync was not started.`}),sn=bt.extend({objectApiName:l.refine(e=>!nn(e),{error:e=>an(String(e.input))}),externalIdField:nt(e=>typeof e=="string"&&e.trim()===""?void 0:e,l.optional()),where:J.optional(),orderBy:on.optional(),batchSize:g().int().positive().max(co).optional()}).strip().refine(e=>e.operation!=="upsert"||(e.externalIdField??"Id").toLowerCase()!=="id",{path:["externalIdField"],error:e=>`An upsert of "${String(e.input.objectApiName)}" needs an External ID field: matching on Id cannot work, because the id belongs to the source org and the target has never issued it. Name an External ID field both orgs share, or set the operation to insert. The sync was not started.`}).superRefine((e,t)=>{let n=Ft([e]);n.length!==0&&t.addIssue({code:G.custom,message:`${Mt(n)} The sync was not started.`,params:{unreadablePatterns:n}})});function oo(e){return et({error:()=>`Sync does not run Apex: remove "${e}" from this configuration. The sync was not started so the script cannot be skipped without you knowing.`}).optional()}var Ke=ft.extend({id:m.optional(),sourceOrgId:i,targetOrgId:i,objects:c(sn).min(1).max(y),conflictStrategy:rn,createdAt:a().max(40).optional(),updatedAt:a().max(40).optional(),preScript:oo("preScript"),postScript:oo("postScript"),dryRun:v(!1,{error:()=>'A sync configuration cannot ask for a dry run: remove "dryRun" from it. A run of it writes to the target org; to see what it would write, simulate it from the Sync page. The run was not started, so it cannot write while you believed it was only reporting.'}).optional()}).strip().superRefine((e,t)=>{e.direction==="target_to_source"&&t.addIssue({code:G.custom,path:["direction"],message:'Sync writes source to target only: direction "target_to_source" is not supported. Swap the source and target orgs to copy the other way. The sync was not started, so it cannot write into the org you meant to read from.'}),e.mode!=="full"&&e.mode!=="delta"&&t.addIssue({code:G.custom,path:["mode"],message:`Sync runs a full or a delta sync only: mode "${e.mode}" is not implemented. Set mode to "full" or "delta". The sync was not started, so it cannot replay the whole object set while you believed it was reading changes only.`}),e.mode==="delta"&&e.objects.forEach((n,s)=>{n.operation==="upsert"||n.operation==="update"||t.addIssue({code:G.custom,path:["objects",s,"operation"],message:`A delta sync writes ${n.objectApiName} again for every record it reads twice, and ${n.operation} would ${n.operation==="insert"?"create a second copy":"delete a record already gone"}. Write it by upsert on an External ID, or by update, or run the configuration in full. The sync was not started.`})}),e.propagateDeletes===!0&&(e.mode!=="delta"?t.addIssue({code:G.custom,path:["propagateDeletes"],message:'Deletions are carried by a delta sync only, which knows since when to look for them: set mode to "delta", or turn deletions off. The sync was not started.'}):e.objects.forEach((n,s)=>{if(n.operation!=="upsert"&&n.operation!=="update")return;let d=Ht(n);"refused"in d&&t.addIssue({code:G.custom,path:["objects",s],message:`${d.refused} Turn deletions off, or carry a source field onto the key. The sync was not started.`})}))}),Ea=o({suggestedName:a().min(1).max(255).refine(e=>!e.includes("/")&&!e.includes("\\"),"suggestedName must not contain a path"),content:a().max(32*1024*1024),extensions:c(a().regex(/^[A-Za-z0-9]+$/)).max(8).optional()}),Ca=o({config:Ke,muteAutomation:r().optional(),checkpointFirst:B.optional()}),Ta=o({config:Ke,checkpointFirst:B.optional()}),_a=o({operationId:m}),Na=o({config:Ke}),Da=o({id:m}),Fa=o({orgId:i,targetOrgId:i.optional()}),Ma=o({sourceOrgId:i,targetOrgId:i,objectApiName:l}),lo=w(["source_wins","target_wins","newest_wins","manual","merge"]),cn=Re("kind",[o({kind:v("id")}),o({kind:v("externalId"),field:l}),o({kind:v("syncConfig"),configId:m})]),Ua=o({sourceOrgId:i,targetOrgId:i,watchedObjects:c(l).min(1).max(y),apply:c(o({objectApiName:l,match:cn,applyDeletes:r()})).max(y),conflictStrategy:lo,flushIntervalMs:g().int().min(50).max(6e4),maxBatchSize:g().int().min(1).max(200),keepContactPoints:r().optional()}).refine(e=>e.apply.every(t=>e.watchedObjects.includes(t.objectApiName)),{message:"Every applied object must be watched.",path:["apply"]}),La=o({sessionId:a().max(200)}),Ba=o({sourceOrgId:i,targetOrgId:i}),$a=o({conflictId:a().min(1).max(500),eventReplayId:g().optional(),resolution:lo,fieldResolutions:x(a(),o({value:D(),source:w(["source","target","manual"])})).optional()}),qa=o({entryId:m}),Ga=o({runId:m}),Wa=o({realtime:v(!0).optional()}).optional(),Ka=o({sourceOrgId:i,targetOrgId:i,objects:c(l).max(y),configId:m.optional()}),Ha=o({runId:m,includeChanged:r().optional(),sweep:r().optional(),again:r().optional(),muteAutomation:r().optional(),...he}),Za=o({runId:m}),Xa=o({runId:m,again:r().optional(),sweptObjects:so.optional()}),Ya=o({runId:m}),Va=o({runId:m,includeChanged:r().optional(),sweep:r().optional(),again:r().optional(),muteAutomation:r().optional(),...he}),Ja=o({runId:m}),Qa=o({format:w(["csv","json"]),entryIds:c(m).max(500).optional()}),ln=o({id:m,name:a().min(1).max(200),configId:m,cron:a().min(1).max(100),timezone:a().min(1).max(100),enabled:r(),maxRetries:g().int().min(0).max(10),notifyOnComplete:r(),notifyOnFailure:r(),createdAt:a().max(40),updatedAt:a().max(40),version:g().int().positive()}).strip(),er=o({schedule:ln}),tr=o({scheduleId:m,enabled:r()}),or=o({scheduleId:m}),dn=dt.extend({objectApiName:l,recordCount:g().int().positive().max(ne),batchSize:g().int().positive().max(co).optional()}).loose(),pn=pt.extend({childObject:l,lookupField:l,parentObject:l}).superRefine((e,t)=>{e.parents.kind==="existing"&&e.parents.where!==void 0&&!Fe(e.parents.where)&&t.addIssue({code:G.custom,path:["parents","where"],message:Me})}),mn=mt.extend({objects:c(dn).min(1).max(y),relations:c(pn).max(y).optional()}).loose().superRefine(ut),nr=o({orgId:i,template:mn,muteAutomation:r().optional(),checkpointFirst:B.optional(),fit:o({share:g().gt(0).max(1),withinMB:g().positive().max(1e6).optional(),before:g().int().positive().max(ne*y)}).strict().optional(),locale:a().regex(/^[a-z]{2,3}(?:_[A-Za-z0-9]{2,4}){0,2}$/).optional(),dryRun:r().optional()}),ar=o({orgId:i}),rr=o({orgId:i,objects:c(l).min(1).max(y),publishes:r().optional()}).strict(),ir=o({orgId:i,objectApiName:l}),sr=o({id:m}),cr=o({template:x(a(),D())}),lr=o({description:a().max(1e4)}),dr=o({}).strict(),pr=o({orgId:i,pack:ae,seed:Ae.shape.seed,articleBodyField:l.optional()}).strict(),mr=o({orgId:i,pack:ae,options:Ae,locale:a().regex(/^[a-z]{2,3}(?:_[A-Za-z0-9]{2,4}){0,2}$/).optional(),muteAutomation:r().optional(),checkpointFirst:B.optional()}).strict(),ur=o({orgId:i}).strict(),gr=o({pack:ae,overwrite:r().optional()}).strict(),br=o({runId:m,choice:Rt,overwrite:r().optional()}).strict(),un=131072,gn=o({objectApiName:l,whereClause:J.optional()}).loose(),fr=o({sourceOrgId:i}),yr=o({sourceOrgId:i,targetOrgId:i,objects:c(gn).min(1).max(y),upsert:r().optional(),externalIdField:l.optional(),previewId:m.optional(),keepContactPoints:r().optional(),checkpointFirst:B.optional()}).refine(e=>!e.upsert||e.externalIdField!==void 0,{message:"externalIdField is required when upsert is true",path:["externalIdField"]}),bn=o({csvHeader:a().min(1).max(500),sfFieldApiName:a().max(80),sfFieldType:a().max(40),sfFieldLength:g().int().positive().nullable()}).loose(),hr=o({orgId:i,objectApiName:l,records:c(x(a(),a().max(un))).min(1).max(st),columnMappings:c(bn).min(1).max(ct),externalIdField:l.optional(),checkpointFirst:B.optional()}),zr=o({orgId:i,objects:c(l).min(1).max(y),wheres:x(l,J).optional(),slices:r().optional()}).refine(e=>Object.keys(e.wheres??{}).every(t=>e.objects.some(n=>n.toLowerCase()===t.toLowerCase())),{message:"A filter names an object the backup reads: give it in objects",path:["wheres"]}),Sr=o({orgId:i}),xr=o({orgId:i,templateId:a().min(1).max(200).optional()}),Ir=o({orgId:i,operationId:a().min(1).max(200)}),kr=o({orgId:i,operationIds:c(a().min(1).max(200)).min(1).max(1e3).optional()}),W={acceptAutomation:r().optional(),acceptEmails:r().optional(),muteAutomation:r().optional()},X={fromPage:v(!0).optional()},jr=o({orgId:i,operationId:m,rewriteAll:r().optional(),includeChanged:r().optional(),slices:c(g().int().positive()).min(1).max(lt*y).optional(),...W,...X}),Pr=o({orgId:i,act:w(["masking","restore","cleanup"]),objects:c(o({objectApiName:l,records:g().int().min(0)})).max(y),erasure:r().optional(),...W,...X}),He={objects:c(l).min(1).max(y).optional(),where:J.optional()},Ze=e=>e.where===void 0||e.where.trim()===""||e.objects?.length===1,Xe={message:"A WHERE clause filters the rows of one object: name exactly one in objects",path:["where"]},Or=o({orgId:i,templateId:m,...He,resumeFrom:m.optional(),snapshot:r().optional(),slices:r().optional(),maxRequests:g().int().positive().max(1e9).optional(),abandon:r().optional(),...W,...X}).refine(Ze,Xe).refine(e=>!(e.snapshot===!0&&e.resumeFrom!==void 0&&e.slices!==!0),{message:"A resume takes no snapshot: the run it resumes has written over some of its rows",path:["snapshot"]}).refine(e=>!(e.slices===!0&&e.snapshot===!1),{message:"A run in slices backs each slice up before it masks it: it cannot keep no snapshot",path:["slices"]}).refine(e=>e.maxRequests===void 0||e.slices===!0,{message:"A bound on requests stops a run in slices between two of them: give slices too",path:["maxRequests"]}).refine(e=>e.abandon!==!0||e.resumeFrom===void 0&&e.snapshot!==!0&&e.maxRequests===void 0,{message:"Giving up a set of slices masks nothing: it takes no resume, snapshot or bound",path:["abandon"]}),Rr=o({orgId:i,templateId:m,...He,slices:r().optional()}).refine(Ze,Xe),wr=o({orgId:i,templateId:m,...He}).refine(Ze,Xe),vr=o({name:a().trim().min(1).max(jt),rules:c(Ot).min(1).max(Pt).refine(e=>new Set(e.map(t=>t.fieldPattern.toLowerCase())).size===e.length,"A field has two rules")}),Ar=o({templateId:m}),Er=o({orgId:i,objectNames:c(l).min(1).max(y)}),Cr=o({orgId:i,objects:c(o({objectApiName:l,duplicateKey:l.optional()})).min(1).max(10).refine(e=>new Set(e.map(t=>t.objectApiName.toLowerCase())).size===e.length,{message:"Each object may be named once per scan"}),staleDays:g().int().min(1).max(3650)}),po=c(l).min(1).max(10).refine(e=>new Set(e.map(t=>t.toLowerCase())).size===e.length,{message:"Each object may be named once per request"}),Tr=o({orgId:i,objects:po}),_r=o({orgId:i,objects:po,requestId:Oe().optional(),email:a().trim().refine(Ct,"Not an email address").optional(),name:a().refine(Tt,"Not a name").optional(),phone:a().refine(Et,"Not a phone number").optional()}).refine(e=>e.email!==void 0||e.name!==void 0||e.phone!==void 0,{message:"A search needs an email address, a name or a phone number"}),fn=o({orgId:i,requestId:Oe()}),ze=a().regex(/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,"Not a record Id"),Nr=o({runId:m,recordId:ze}).strict(),Dr=fn.extend({mode:w(["anonymize","delete"]),records:c(o({objectApiName:l,ids:c(ze).min(1).max(200)})).min(1).max(10).refine(e=>new Set(e.map(t=>t.objectApiName.toLowerCase())).size===e.length,{message:"Each object may be named once per request"}),dryRun:r(),...W}),yn=Re("kind",[o({kind:v("stale"),days:g().int().min(1).max(3650)}),o({kind:v("orphans"),fieldApiName:l}),o({kind:v("duplicates"),keyField:l})]),mo=o({orgId:i,objectApiName:l,recommendation:yn}),Fr=mo.extend({after:o({skip:g().int().nonnegative().max(1e8),id:ze.optional(),modified:a().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?(?:Z|[+-]\d{2}:?\d{2})$/).optional()}).strict().optional()}),Mr=mo.extend({dryRun:r(),...W,...X}),We=2e3,uo={mode:w(["objects","org"]),objects:c(l).min(1).max(We).optional(),excluded:c(l).max(We).optional(),customSettings:r().optional(),files:r().optional(),managedPackages:r().optional(),unrestorable:r().optional()},hn=o(uo).strict().refine(e=>e.mode==="objects"==(e.objects!==void 0),{message:"The objects picked are named in objects mode, and only there"}),Ur=o({orgId:i,...uo,objects:c(l).max(We).optional()}).strict().refine(e=>e.mode==="objects"==(e.objects!==void 0),{message:"The objects picked are named in objects mode, and only there"}),Lr=o({orgId:i,request:hn,deleteMode:w(["recycle","hard"]),checkpointFirst:r().optional(),acceptNoUndo:r().optional(),acceptPeopleActive:r().optional(),...W,...X}),Br=o({orgId:i,previewId:m.optional(),resumeRunId:a().regex(/^em-\d{8}-\d{6}-[a-z0-9]{4}$/).optional(),acceptNoUndo:r().optional(),acceptPeopleActive:r().optional(),checkpointFirst:r().optional(),...W,...X}).refine(e=>e.previewId===void 0!=(e.resumeRunId===void 0),{message:"An emptying acts on a preview, or takes up a run: one of them"}),$r=o({operationId:m}),qr=o({orgId:i,runId:a().regex(/^em-\d{8}-\d{6}-[a-z0-9]{4}$/),...W,...X}),Gr=o({orgId:i}),Wr=o({orgId:i}).strict(),Kr=o({alertId:m}),go=o({sourceOrgId:i,targetOrgId:i}),Hr=go.extend({types:c(a().min(1).max(80)).min(1).max(50),includeManaged:r().optional()}),zn=o({componentType:w(At),fullName:a().min(1).max(400).regex(/^[^\u0000-\u001f\u007f]+$/,"A component name holds no control character")}),Zr=go.extend({components:c(zn).min(1).max(500).refine(e=>new Set(e.map(t=>`${t.componentType}:${t.fullName}`)).size===e.length,{message:"Each component may be named once per deployment"}),testLevel:w(wt),runTests:c(a().max(255).regex(vt,"Not an Apex class name")).max(100).optional()}).refine(e=>e.sourceOrgId!==e.targetOrgId,{message:"The source and the target are the same org",path:["targetOrgId"]}).refine(e=>e.testLevel!=="RunSpecifiedTests"||(e.runTests?.length??0)>0,{message:"RunSpecifiedTests names at least one test class",path:["runTests"]}),Xr=o({validationId:a().regex(/^0Af[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/,"Not a deployment id"),targetOrgId:i}).strict(),Sn=a().regex(/^\d+\.\d+\.\d+$/,"Invalid semver"),ye=a().regex(/^[A-Za-z][A-Za-z0-9_]*\.[A-Za-z][A-Za-z0-9_]*$/,"Expected an Object.field key").max(170),xn=o({name:a().min(1).max(80),label:a().min(1).max(200),filterField:l,valuesSoql:a().min(1).max(4e3)}),In=o({name:a().min(1).max(80),label:a().min(1).max(200),whereFragment:J}),no=de([o({action:v("clear")}),o({action:v("replace"),value:a().max(255)})]),bo=o({rootObject:l,axes:c(xn).max(20),edgeCases:c(In).max(50),budgetMaxRecords:g().int().positive().max(1e5).optional(),candidatesPerCombination:g().int().positive().max(20).optional(),expectedObjects:c(l).max(100).optional(),maxNodes:g().int().min(10).max(500).optional(),excludedObjects:c(l).max(200).optional(),excludedFields:x(l,c(l).max(500)).optional(),sasDir:a().min(1).max(500).optional(),datasetDir:a().min(1).max(500).optional(),rulesFilePath:a().min(1).max(500).optional(),datasetVersion:Sn.optional(),protectedOrgIds:c(i).max(50).optional(),identityKeys:x(l,c(l).min(1).max(10)).optional(),undeletableObjects:x(l,l).optional(),requiredLookupPlaceholders:x(ye,o({name:a().min(1).max(200),recordTypeDeveloperName:a().min(1).max(97).optional(),targetObjectApiName:l.optional()})).optional(),requiredFieldDefaults:x(ye,D()).optional(),picklistRules:x(ye,no).optional(),defaultPicklistRule:no.optional(),duplicateErrorPatterns:c(a().min(1).max(200)).max(50).optional(),mockDetection:o({metadataTypeApiName:l,isMockedFieldApiName:l}).optional(),mandatoryLookups:x(l,c(l).min(1).max(50)).optional(),presenceKeys:x(l,l).optional()}),Yr=o({config:bo}),Vr=o({sourceOrgId:i}),Jr=o({fields:c(ye).min(1).max(2e3)}),Qr=o({sourceOrgId:i,author:a().min(1).max(120).optional()}),ce=o({organizationId:kt,checkpointId:F}).strict(),kn=bo.pick({requiredFieldDefaults:!0,requiredLookupPlaceholders:!0,picklistRules:!0,defaultPicklistRule:!0,identityKeys:!0,undeletableObjects:!0,duplicateErrorPatterns:!0,mockDetection:!0,protectedOrgIds:!0}).strict(),fo=ce.extend({choices:Ne,config:kn.optional()}).strict(),jn=fo.extend({choices:Ne.optional()}).strict(),ti=o({targetOrgId:i,replay:fo.optional(),pilot:r().optional(),reload:r().optional(),writeEncrypted:r().optional(),maxRecords:g().int().positive().max(1e6).optional(),muteAutomation:r().optional(),checkpointFirst:B.optional(),sweep:r().optional(),...he,includeChanged:r().optional(),acceptEmails:r().optional(),acceptAutomation:r().optional(),goneFirst:c(ze).max(1e6).optional()}),Pn=o({targetOrgId:i}),oi=Pn.extend({replay:jn.optional()}),ni=o({targetOrgId:i,loadedAt:a().min(1).max(64),includeChanged:r().optional(),sweep:r().optional(),...he,muteAutomation:r().optional(),replay:ce.optional()}),ai=o({targetOrgId:i,loadedAt:a().min(1).max(64),reload:r().optional(),replay:ce.optional()}),ri=o({targetOrgId:i,loadedAt:a().min(1).max(64),sweptObjects:so.optional(),reload:r().optional(),replay:ce.optional()}),ii=o({targetOrgId:i,loadedAt:a().min(1).max(64),includeChanged:r().optional(),replay:ce.optional()}),yo=1e3,ho=3650,On=200,Z=c(l).min(1).max(yo).refine(e=>new Set(e).size===e.length,"An object is named twice");function zo(e){return e.mode==="picked"?e.objects!==void 0:e.objects===void 0}var So=de([v("all"),c(l.refine(e=>e.toLowerCase().endsWith("__c"),"A custom setting's API name ends in __c")).min(1).max(yo).refine(e=>new Set(e.map(t=>t.toLowerCase())).size===e.length,"A custom setting is named twice")]),xo={path:["objects"],message:'Name the objects with "picked", and none with "everything"'},si=o({orgId:i.optional()}).optional(),Rn=1e6,Io=g().int().min(1).max(Rn),ci=o({orgId:i,mode:_e,objects:Z.optional(),excluded:Z.optional(),customSettings:So.optional(),maxTotal:Io.optional()}).refine(zo,xo),li=o({orgId:i,name:Te,mode:_e,objects:Z.optional(),excluded:Z.optional(),customSettings:So.optional(),maxTotal:Io.optional(),keepDays:g().int().min(0).max(ho),ignoredFields:Ce.optional()}).refine(zo,xo),di=o({checkpointId:F,objects:Z.optional(),muteAutomation:r().optional(),acceptOutside:r().optional()}),pi=o({checkpointId:F,previewId:Ee,objects:Z.optional(),acceptAutomation:r(),muteAutomation:r().optional(),acceptEmails:r().optional(),acceptNoUndo:r(),acceptRecreate:r(),acceptOutside:r(),acceptUnseen:r(),fromPage:v(!0).optional()}),mi=o({checkpointId:F,previewId:Ee,objects:Z,acceptOutside:r()}),ui=o({checkpointId:F}),wn=200,gi=o({token:m,orgId:i,key:a().min(1).max(wn),keepDays:g().int().min(0).max(ho)}),bi=o({checkpointId:F,rewindId:It,acceptAutomation:r(),muteAutomation:r().optional(),acceptEmails:r().optional(),fromPage:v(!0).optional()}),fi=o({checkpointIds:c(F).min(1).max(On).refine(e=>new Set(e).size===e.length,"A checkpoint is named twice")}),yi=o({checkpointId:F,keep:r()}),hi=o({checkpointId:F,name:Te}),zi=o({checkpointId:F,fields:Ce}),vn=500,Si=o({orgIds:c(i).min(1).max(vn).refine(e=>new Set(e).size===e.length,"An org is named twice").optional()}).strict().optional(),xi=o({sourceOrgId:i,targetOrgId:i,includeStandardObjects:r()}),Ii=o({sourceOrgId:i,objectApiNames:c(l).min(1).max(it)}),ki=o({sourceOrgId:i,targetOrgId:i,selectedObjects:c(l).max(y),includeStandardObjects:r(),maxDepth:g().int().min(1).max(10).optional(),maxObjects:g().int().min(1).max(500).optional()}),ji=o({complianceFramework:ht,objectFilters:x(a(),J).optional(),overrides:c(o({objectApiName:l,fieldApiName:l,method:de([yt,v("skip")])})).max(500).optional()}),Pi=o({grappeThreshold:g().int().nonnegative(),keepContactPoints:r().optional(),muteAutomation:r().optional(),checkpointFirst:B.optional()}),Oi=o({mode:o({share:v(!0).optional(),caps:x(l,g().int().min(1).max(ne)).refine(e=>Object.keys(e).length<=y,"Too many caps").optional(),all:g().int().min(1).max(ne).optional(),withinMB:g().positive().max(1e6).optional()}).strict().refine(e=>e.share===!0||e.caps!==void 0||e.all!==void 0,"Fit by share, by caps, or both"),muteAutomation:r().optional(),checkpointFirst:B.optional()}),Ri=o({objectApiName:l}),wi=o({orgId:i.optional(),sourceOrgId:i.optional(),alreadySelected:c(l).max(y).optional()}).loose(),vi=o({orgId:i.optional(),sourceOrgId:i.optional(),objectApiName:l.optional(),alreadySelected:c(l).max(y).optional(),selectedObjects:c(l).max(y).optional(),availableObjects:c(l).max(500).optional()}).loose(),Ai=o({sourceOrgId:i,targetOrgId:i.optional(),selectedObjects:c(l).min(1).max(y),parentObjects:c(l).max(y).optional()}).loose(),An=St.extend({sourceOrgId:i,targetOrgId:i,selectedObjects:c(l).min(1).max(y),parentObjects:c(l).max(y).default([])}).loose(),Ei=o({config:An.optional(),sourceOrgId:i.optional(),targetOrgId:i.optional(),selectedObjects:c(l).min(1).max(y).optional(),parentObjects:c(l).max(y).optional()}).loose(),En=a().min(1).max(5e4),Ci=o({conversationId:m,message:a().max(5e4)}),Ti=o({title:a().min(1).max(300)}),_i=o({conversationId:m}),Ni=o({apiKey:a().min(1).max(500),errorResolution:r().optional()}),Di=o({enabled:r().optional(),errorResolution:r().optional()}),Fi=o({orgId:i,objectName:l,sampleSize:g().int().positive().max(1e4).optional()}),Mi=o({orgId:i,prompt:a().trim().min(1).max(2e3).optional(),soql:a().trim().min(1).max(2e4).optional()}).refine(e=>e.prompt===void 0!=(e.soql===void 0),{message:"Send a prompt to draft from or a query to check, not both and not neither"}),Ui=o({description:En,orgIds:c(i).max(50).optional()}),Li=o({requestId:m}),fe=c(a().min(1).max(M.picklistValue)).max(M.picklistValues),ao={label:a().max(M.agentLabel).optional(),description:a().max(M.agentDescription).optional()},Bi=o({text:a().trim().min(1).max(M.text),language:ae.shape.language,casePicklists:o({Status:fe.optional(),Origin:fe.optional(),Priority:fe.optional(),Type:fe.optional()}).optional(),agent:o({topics:c(o({name:a().min(1).max(M.agentName),...ao,actions:c(o({name:a().min(1).max(M.agentName),...ao})).max(M.agentActions)})).max(M.agentTopics)}).optional(),draft:xt.optional(),maskOnly:r().optional()}),$i=o({filePath:a().min(1).max(2e3)}),qi=o({name:a().max(200),config:x(a(),D())}),Gi=o({operationId:m.optional(),executionId:m.optional(),objectName:a().min(1).max(200).optional()}).loose(),Wi=o({policyId:m}),Ki=o({policy:x(a(),D())}),Hi=o({policyId:m,orgId:i}),Zi=o({module:a().min(1).max(50).optional(),orgId:i.optional(),offset:g().int().min(0).max(we).optional(),limit:g().int().min(1).max(we).optional()}).optional(),Xi=o({operationId:m.optional()}).optional(),Cn=w(["syncMappings","forgePlans","pipelines","anonymizationTemplates"]),Yi=o({categories:c(Cn).min(1).max(50)}),Vi=o({json:a().min(1).max(5e6),overwrite:r()}),Ji=o({json:a().min(1).max(5e6)}),Qi=o({orgId:a().max(128),authMethod:a().min(1).max(50),alias:a().max(100).optional(),loginUrl:a().max(500).optional(),username:a().max(300).optional(),password:a().max(500).optional(),securityToken:a().max(100).optional(),clientId:a().max(256).optional(),jwtKeyFile:a().max(4096).optional()}).loose(),ko=a().trim().max(100).regex(/^[\w.-]*$/,"an alias is letters, digits, dots, dashes and underscores").optional(),Tn=a().trim().min(1,"the username is required").max(80).regex(/^[\w.@+-]+$/,"a username is written like an email address"),jo=a().trim().min(1,"the consumer key is required").max(256).regex(/^[A-Za-z0-9._-]+={0,2}$/,"a consumer key is letters, digits, dots, dashes and underscores"),_n=a().trim().min(1,"the private key file is required").max(4096).regex(/^[^\u0000-\u001f\u007f]+$/,"the private key file path holds a control character").refine(e=>tn(e),"give the private key file as an absolute path"),es=o({alias:ko,loginUrl:a().max(500).optional(),username:Tn,clientId:jo,jwtKeyFile:_n}).loose(),ts=o({alias:ko,loginUrl:a().max(500).optional(),clientId:jo}).loose(),os=o({requestId:m}),ns=o({orgId:i}),as=o({orgId:i}),rs=o({orgId:i}).strict(),is=o({orgId:i,alias:a().trim().min(1).max(100),color:a().regex(/^#[0-9A-Fa-f]{6}$/),tags:c(a().trim().min(1).max(50)).max(20),staging:r().optional()}),ss=o({key:a().min(1).max(200),value:D()}),cs=o({enabled:r()}),ls=o({lng:w(["en","fr","de","es","ja","pt-BR"])}),ds=o({targetOrgId:i,sourceOrgId:i.optional()}),ps=o({moduleId:a().min(1).max(64),route:a().min(1).max(64),overlay:r()}),ms=o({moduleId:a().min(1).max(64)}),Nn=80,Dn=ot(e=>Lt(e)||Bt(e)||typeof e=="string"&&e.trim()!==""&&e.length<=Nn,{message:"Not a pipeline step type"}),Fn=o({pipeline:o({name:a().min(1).max(200),steps:c(o({type:Dn,config:x(a(),D()).default({})}).loose()).max(200),variables:c(x(a(),D())).max(200).default([]),triggers:c(x(a(),D())).max(50).default([])}).loose(),variables:x(a(),a().max(2e3)).optional(),dryRun:r().optional()}),Mn=tt({since:at.datetime({offset:!0}),runner:w(["cron","taskScheduler","githubActions"]),file:a().min(1).max(255).refine(e=>!/[\\/]/.test(e),"The file's name, without its folder"),digest:a().regex(/^sha256:[0-9a-f]{64}$/,"Not a digest: sha256: and 64 hex digits")}),us=Fn.shape.pipeline.extend({id:a().min(1).max(200),runsOutside:Mn.optional()}),gs=o({pipelineId:m}),bs=o({id:a().max(200),config:x(a(),D())}),fs=o({id:m}),ys=o({operationId:m,stepId:m,decision:w(["approved","rejected"])}),Un=255,Po={pipelineId:m,stepId:m},hs=o({pipelineId:m}),zs=o({...Po,typed:a().min(1).max(Un)}),Ss=o(Po),xs=o({category:a().max(100).optional(),query:a().max(500).optional()}).loose().optional(),Is=o({templateId:m});function Ln(e){return e.issues.slice(0,3).map(t=>`${t.path.join(".")||"(root)"}: ${t.message}`).join("; ")}function Bn(e){let t=e.issues.map(n=>n.code==="custom"?n.params?.unreadablePatterns:void 0);return t.every(n=>n!==void 0)?t.flat():void 0}function ks(e,t,n,s){let d=e.safeParse(t.payload);if(!d.success){let p=Ln(d.error),u=Bn(d.error);return eo(s,t.type,n,t,new Error(`Invalid payload \u2014 ${p}`),u?{code:Dt,extraPayload:{rules:u}}:{code:"INVALID_PAYLOAD"}),null}return d.data}var $n=5;function Se(e){return e.slice(0,15)}function qn(e){let t=e.errors?.[0];if(t===void 0)return"The org gave no reason.";if(typeof t=="string")return t;let n=t.statusCode??"",s=t.message??"";return n&&s?`${n}: ${s}`:n||s||"The org gave no reason."}function Oo(e){let t=new Set;for(let n of e){let s=n.Id;typeof s=="string"&&t.add(Se(s))}return t}async function Ro(e){let t=[],n=[],s={},d=!1,p=!1,u=e.stampsFor,f=ie(e.org),k=e.org.serverTime?.bind(e.org),E=u&&k?Date.now()+await se({serverTime:k})-re:Number.NaN;for(let{objectApiName:O,ids:A}of e.plan){let I={objectApiName:O,planned:A.length,undeleted:0,alreadyBack:0,goneForGood:0,refused:0,reasons:[]};t.push(I);let h=_=>{I.reasons.length<$n&&!I.reasons.includes(_)&&I.reasons.push(_)},R=pe(O);for(let _=0;_<A.length;_+=me){let C=A.slice(_,_+me);if(p||e.signal?.aborted){p=!0,I.notReached=(I.notReached??0)+C.length,n.push(...C);continue}let[ee]=ue(C,me),K,te;try{K=Oo((await e.org.queryDeleted(`SELECT Id FROM ${R} WHERE Id IN (${ee}) AND IsDeleted = true`)).records),te=Oo((await e.org.query(`SELECT Id FROM ${R} WHERE Id IN (${ee})`)).records)}catch(j){I.refused+=C.length,h(`The recycle bin could not be read: ${V(j)}`),n.push(...C);continue}let z=C.filter(j=>K.has(Se(j)));for(let j of C)K.has(Se(j))||(te.has(Se(j))?I.alreadyBack++:I.goneForGood++);if(z.length===0)continue;let U;try{d=!0;let j=await e.undelete(z),T=Array.isArray(j)?j:[j];U=z.map((H,oe)=>T[oe]??{success:!1})}catch(j){let T=V(j);U=z.map(()=>({success:!1,errors:[T]}))}let Y=[];U.forEach((j,T)=>{if(j.success===!0){I.undeleted++,u?.(z[T])&&Y.push(z[T]);return}I.refused++,h(qn(j)),n.push(z[T])}),Y.length>0&&Number.isFinite(E)&&Object.assign(s,await be(e.org,R,Y,E,f))}}return{objects:t,left:n,wrote:d,cancelled:p,stamps:s}}function wo(e){return e.refused+e.goneForGood+(e.notReached??0)}async function Gn(e,t,n,s){let d=new Map(Object.entries(s).map(([u,f])=>[u.slice(0,15),Date.parse(f)])),p=new Set;for(let{objectApiName:u,ids:f}of t){let k=pe(u);for(let E of ue(f)){let O;try{O=(await e.query(`SELECT Id, LastModifiedDate FROM ${k} WHERE Id IN (${E})`)).records}catch{continue}for(let A of O){if(typeof A.Id!="string")continue;let I=A.Id.slice(0,15),h=Date.parse(String(A.LastModifiedDate??""));(h<=n||h<=(d.get(I)??Number.NaN))&&p.add(I)}}}return p}function vo(e){let t=Date.parse(e.startedAt),n=Date.parse(e.lastWrittenAt??e.end?.at??"");return Number.isFinite(n)?{runRecordedAt:new Date(n),...Number.isFinite(t)?{runDurationMs:Math.max(0,n-t)}:{}}:{}}function Wn(e){return e.filter(t=>t.deleted+t.alreadyGone>0).map(t=>t.objectApiName)}async function Ms(e){let{run:t,includeChanged:n}=e,s=e.again===!0,d=ge(t,s),p=d.reduce((b,S)=>b+S.ids.length,0),u=Be(t),f=u.reduce((b,S)=>b+S.ids.length,0),k=Yt(t),E=k.reduce((b,S)=>b+S.ids.length,0),O=[],A=e.backups,I=e.undelete;k.length>0&&!I&&O.push(`The ${E} record(s) the run deleted could not be brought back from the recycle bin here: the next removal offers them again.`),u.length>0&&!A&&O.push(`The values from before the run of ${f} record(s) it wrote over could not be read here: they were not put back, and the next removal offers them again.`);let h,R,_={},C=(e.earlierRuns??[]).map(b=>({runId:b.runId,keys:new Set([...ge(b),...Be(b)].flatMap(({ids:S})=>S.map(L=>L.slice(0,15))))})),ee=b=>C.some(({keys:S})=>S.has(b.slice(0,15))),K=e.sweep,te=u.length>0&&A||k.length>0&&I||K?async b=>{if(k.length>0&&I){let N=u.length>0&&A?await Gn(e.org,u,await Vt(e.org,xe(t)),t.removal?.removalStamps??{}):void 0,q=N?Date.now()+await se(e.org)-re:0;if(R=await Ro({org:e.org,plan:k,undelete:I,...C.length>0?{stampsFor:ee}:{},...e.signal?{signal:e.signal}:{}}),N&&R.wrote){let P=ie(e.org);for(let{objectApiName:Pe,ids:Mo}of u){let Uo=Mo.filter(Lo=>N.has(Lo.slice(0,15)));Object.assign(_,await be(e.org,Pe,Uo,q,P))}}if(R.cancelled||e.signal?.aborted)return R.wrote}if(u.length>0&&A){let N={...t.removal?.removalStamps,..._};h=await Jt({org:e.org,plan:u,backups:A,...xe(t)!==void 0?{lastWriteAt:xe(t)}:{},includeChanged:n,...Object.keys(N).length>0?{stamps:N}:{},...t.unkept?{unkept:t.unkept}:{},...C.length>0?{stampsFor:ee}:{},...e.signal?{signal:e.signal}:{}})}let S=(R?.wrote??!1)||(h?.wrote??!1);if(h?.cancelled||e.signal?.aborted)return S;let L=K?await K(b):!1;return S||L}:void 0,z=await Ue(e.org,d,{...vo(t),...t.removal?.removalStamps?{removalStamps:t.removal.removalStamps}:{},...t.removal?.removalSpans?{removalSpans:t.removal.removalSpans}:{},includeChanged:n,...te?{sweep:te}:{},...e.afterRemoval?{afterRemoval:e.afterRemoval}:{},...e.automationMade?{automationMade:e.automationMade}:{},...e.runUserId?{runUserId:e.runUserId}:{},...e.onUndeletable?{onUndeletable:e.onUndeletable}:{},...e.beforeFirstWrite?{beforeFirstWrite:e.beforeFirstWrite}:{},signal:e.signal,onProgress:e.onProgress}),U=new Date().toISOString();if(z.stoppedForUndeletable)return{result:{runId:t.runId,status:"cancelled",includeChanged:n,objects:[],finishedAt:U},planned:p,plannedBack:f,plannedUndelete:E,notes:[],stoppedForUndeletable:!0};let Y=s?void 0:t.removal?.undo?.removedAt,j={runId:t.runId,status:Zn(Xn(Zt(z.objects,z.cancelled),z.objects,h),z.objects,h,R),includeChanged:n,objects:z.objects,finishedAt:U,...Y?{leftBy:Y}:{},...h&&h.objects.length>0?{restored:h.objects}:{},...R&&R.objects.length>0?{undeleted:R.objects}:{}},T=Xt(j,p,t.removal?.undo,s),H=new Set(z.gone),oe=H.size>0||s&&T?d.flatMap(({ids:b})=>b.filter(S=>!H.has(S))):void 0,Je={..._,...z.stamps},Qe=Object.keys(Je).length>0,No=h?.objects.some(b=>b.restored+(b.restoredWithout??0)>0)===!0,Do=R!==void 0&&!R.cancelled;if(T||Qe||z.span||oe||h||R)try{await e.store.updateRemoval(t.runId,b=>({...b,...T?{undo:T}:{},...Qe?{removalStamps:{...b.removalStamps,...Je}}:{},...z.span?{removalSpans:[...b.removalSpans??[],z.span]}:{},...oe?{removalLeft:oe}:{},...h?{restoreLeft:h.left}:{},...No?{restoredAt:U}:{},...R?{undeleteLeft:R.left}:{},...Do?{undeletedAt:U}:{}}))}catch(b){O.push(`What this removal did could not be kept (${b instanceof Error?b.message:String(b)}): the next removal of the run may set out to take records already gone.`)}let Fo=Object.keys(h?.stamps??{}).length>0?await Kn(e.org,t,e.earlierRuns??[]):new Map,ke=[];for(let{runId:b,keys:S}of C){let L=Fo.get(b),N=Object.fromEntries(Object.entries({...R?.stamps,...h?.stamps}).filter(([P])=>S.has(P.slice(0,15))&&!L?.has(P.slice(0,15)))),q=Object.keys(N).length;if(q!==0)try{await e.store.updateRemoval(b,P=>({...P,removalStamps:{...P.removalStamps,...N},...z.span?{removalSpans:[...P.removalSpans??[],z.span]}:{}})),ke.push({runId:b,records:q})}catch(P){O.push(`What this removal gave back of ${q} record(s) the run ${b} wrote too could not be kept on it (${P instanceof Error?P.message:String(P)}): its removal reads them as changed since it.`)}}let le=e.configs;if(le&&H.size>0&&le.isSaved(t.configId)){let b={sourceOrgId:t.sourceOrgId,targetOrgId:$e(t)};try{let S=d.filter(P=>Le.includes(P.objectApiName)).flatMap(({ids:P})=>P.filter(Pe=>H.has(Pe))),L=le.forgetFiles(t.configId,b,S),N=Wn(z.objects).filter(P=>!Le.includes(P)),q=le.markRemoved(t.configId,b,[...new Set([...N,...L.map(P=>P.objectApiName)])],U);j={...j,...q.length>0?{readWhole:q}:{},...L.length>0?{filesForgotten:L.length}:{}}}catch(S){O.push(`The configuration could not be told what this removal took (${S instanceof Error?S.message:String(S)}): run it full next time.`)}}let je;if(e.links&&H.size>0)try{je=await e.links.forget(t.configId,{sourceOrgId:t.sourceOrgId,targetOrgId:$e(t)},[...H])}catch(b){O.push(`Which records of the target this removal took could not be forgotten (${b instanceof Error?b.message:String(b)}): a later run of the configuration may point a lookup at one of them.`)}return{result:j,planned:p,plannedBack:f,plannedUndelete:E,notes:O,...je?{linksForgotten:je}:{},...ke.length>0?{earlierStamped:ke}:{}}}async function Us(e){let{run:t}=e,n=ge(t);return{outcome:await Ue(e.org,n,{...vo(t),...t.removal?.removalStamps?{removalStamps:t.removal.removalStamps}:{},...t.removal?.removalSpans?{removalSpans:t.removal.removalSpans}:{},includeChanged:e.includeChanged,...e.runUserId?{runUserId:e.runUserId}:{},previewOnly:!0,...e.signal?{signal:e.signal}:{}}),planned:n.reduce((d,p)=>d+p.ids.length,0)}}async function Kn(e,t,n){let s=new Map,d=Object.entries(t.heldBefore??{});if(d.length===0||n.length===0)return s;let p=await ie(e)(),u=await se(e);for(let f of n){let k=Date.parse(xe(f)??""),E=Number.isFinite(k)?k+u+re:Number.NEGATIVE_INFINITY,O=new Set;for(let[A,{at:I,by:h}]of d)Date.parse(I)>E&&(p!==void 0&&h!==void 0&&h.slice(0,15)===p||O.add(A));O.size>0&&s.set(f.runId,O)}return s}function xe(e){return e.lastWriteAt??e.lastWrittenAt??e.end?.at}function Hn(e){return e.keptChanged+e.refused+e.notKept+(e.notReached??0)+(e.restoredWithout??0)}function Zn(e,t,n,s){if(!s||e==="cancelled")return e;if(s.cancelled)return"cancelled";let d=s.objects.some(u=>wo(u)>0);if(e==="success"&&!d)return"success";let p=t.some(u=>u.deleted>0)||(n?.objects??[]).some(u=>u.restored>0)||s.objects.some(u=>u.undeleted>0);return e==="partial"||p?"partial":"failure"}function Xn(e,t,n){if(!n||e==="cancelled")return e;if(n.cancelled)return"cancelled";let s=n.objects.some(p=>Hn(p)>0);return e==="success"&&!s?"success":t.some(p=>p.deleted>0)||n.objects.some(p=>p.restored+(p.restoredWithout??0)>0)?"partial":"failure"}function Bs(e){let t=e?.getSandforgeSetting?.("backup.maxAgeDays",30);return typeof t=="number"&&Number.isFinite(t)&&t>0?t:0}function $s(e,t,n){let s=[],d=0,p=Number.POSITIVE_INFINITY;for(let u of e){let f=t(u.backup);if(!f){d+=u.ids.length;continue}s.push(u);let k=Date.parse(f.timestamp??"");n>0&&Number.isFinite(k)&&(p=Math.min(p,k+n*864e5))}return{kept:s,notKept:d,...Number.isFinite(p)?{keptUntil:new Date(p).toISOString()}:{}}}var Ye="backupSet:",Yn="backups",Ve=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,Q=a().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/),$=g().int().nonnegative(),Vn=o({index:g().int().positive(),afterId:a().regex(Ve).optional(),lastId:a().regex(Ve).optional(),rows:$,snapshotId:a().min(1).max(240),takenAt:Q.optional(),readSince:Q.optional(),state:w(["pending","snapshotted","masking","masked","restored"]),masked:$,refused:$,deletedSince:$,nothingToMask:$,unanswered:$.optional(),late:v(!0).optional(),sizeUsed:g().int().positive(),lateLeft:$.optional(),lateOf:g().int().positive().optional(),lateAfterId:a().regex(Ve).optional(),restoredAt:Q.optional()}),Jn=o({objectApiName:a().min(1).max(255),where:a().max(2e3).optional(),select:a().max(1e5).optional(),done:r(),tailLeft:$.optional(),slices:c(Vn)}),Ao=o({setId:a().min(1).max(200),kind:w(["masking","backup"]),orgId:a().min(1).max(200),organizationId:a().max(18).optional(),templateId:a().min(1).max(200).optional(),fingerprint:a().regex(/^[0-9a-f]{64}$/).optional(),size:g().int().positive(),state:w(["open","done","abandoned"]),startedAt:Q,serverStartedAt:Q.optional(),lastActivityAt:Q,requestsSpent:$,keyCheck:a().regex(/^[0-9a-f]{16}$/).optional(),objects:c(Jn)});function Gs(e,t){return`${e}-s${String(t).padStart(4,"0")}`}function Ie(e){return e.objects.flatMap(t=>t.slices).sort((t,n)=>t.index-n.index)}function Ws(e){return Ie(e).reduce((t,n)=>Math.max(t,n.index),0)+1}function Co(e){return e.state==="masked"||e.state==="snapshotted"||e.state==="restored"}function Qn(e){return Ie(e).reduce((t,n)=>t+n.rows,0)}function To(e,t,n){return{index:t.index,objectApiName:e,snapshotId:t.snapshotId,rows:t.rows,masked:t.masked,refused:t.refused,deletedSince:t.deletedSince,nothingToMask:t.nothingToMask,state:t.state,...t.late?{late:!0}:{},...t.sizeUsed<n?{sizeUsed:t.sizeUsed}:{},...t.restoredAt?{restoredAt:t.restoredAt}:{}}}function ea(e){return e.objects.reduce((t,n)=>t+(n.tailLeft??0)+n.slices.reduce((s,d)=>s+(d.lateLeft??0),0),0)}function Ks(e,t){return{setId:e.setId,size:e.size,state:e.state,objects:e.objects.map(n=>({objectApiName:n.objectApiName,slices:n.slices.map(s=>To(n.objectApiName,s,e.size))})),lateRecords:ea(e),requestsSpent:t.requestsSpent,...t.stoppedOnBudget?{stoppedOnBudget:!0}:{},slicesLeft:e.objects.some(n=>!n.done||n.slices.some(s=>!Co(s)))}}function ta(e){return e.kind==="backup"&&e.state==="open"?"partial":e.state}function Hs(e){let t=Object.fromEntries(e.objects.flatMap(n=>n.where?[[n.objectApiName,n.where]]:[]));return{setId:e.setId,orgId:e.orgId,kind:e.kind,state:ta(e),startedAt:e.startedAt,lastActivityAt:e.lastActivityAt,size:e.size,totalRecords:Qn(e),...e.templateId?{templateId:e.templateId}:{},slices:e.objects.flatMap(n=>n.slices.map(s=>To(n.objectApiName,s,e.size))),...Object.keys(t).length>0?{wheres:t}:{}}}function Zs(e){let t=Ie(e);return{setId:e.setId,savedAt:e.lastActivityAt,done:t.filter(Co).length,total:t.length,state:e.state,size:e.size}}var Eo=class{constructor(t){this.configStore=t}configStore;get(t){let n=Ao.safeParse(this.configStore.get(this.key(t)));return n.success&&n.data.setId===t?n.data:void 0}save(t){this.configStore.set(this.key(t.setId),Ao.parse(t),Yn)}delete(t){this.configStore.delete(this.key(t))}list(t){return this.configStore.getKeysByPrefix(Ye).map(n=>this.get(n.slice(Ye.length))).filter(n=>n!==void 0).filter(n=>t===void 0||n.orgId===t)}openFor(t,n){return this.list(t).find(s=>s.kind==="masking"&&s.state==="open"&&s.templateId===n)}ofSnapshot(t){return this.list().find(n=>Ie(n).some(s=>s.snapshotId===t))}key(t){return`${Ye}${t}`}};async function Ys(e,t){let n=e.check(t);if(!n.allowed)return{check:n,decision:"refused"};if(!await e.confirmIfNeeded(n,t.orgTier))return{check:n,decision:"declined"};let d=n.requiresConfirmation&&e.canAskForConfirmation===!0;return{check:n,decision:d?"confirmed":"allowed"}}var _o={allowed:0,confirmed:1,declined:2,refused:3};function Vs(e,t){return e===void 0||_o[t]>_o[e]?t:e}export{sa as a,Qt as b,ca as c,qe as d,la as e,da as f,Bo as g,pa as h,ma as i,ua as j,ga as k,ba as l,fa as m,ya as n,eo as o,ha as p,za as q,Sa as r,xa as s,i as t,l as u,so as v,B as w,nn as x,an as y,Ke as z,Ea as A,Ca as B,Ta as C,_a as D,Na as E,Da as F,Fa as G,Ma as H,Ua as I,La as J,Ba as K,$a as L,qa as M,Ga as N,Wa as O,Ka as P,Ha as Q,Za as R,Xa as S,Ya as T,Va as U,Ja as V,Qa as W,er as X,tr as Y,or as Z,mn as _,nr as $,ar as aa,rr as ba,ir as ca,sr as da,cr as ea,lr as fa,dr as ga,pr as ha,mr as ia,ur as ja,gr as ka,br as la,fr as ma,yr as na,hr as oa,zr as pa,Sr as qa,xr as ra,Ir as sa,kr as ta,jr as ua,Pr as va,Or as wa,Rr as xa,wr as ya,vr as za,Ar as Aa,Er as Ba,Cr as Ca,Tr as Da,_r as Ea,fn as Fa,Nr as Ga,Dr as Ha,Fr as Ia,Mr as Ja,Ur as Ka,Lr as La,Br as Ma,$r as Na,qr as Oa,Gr as Pa,Wr as Qa,Kr as Ra,go as Sa,Hr as Ta,Zr as Ua,Xr as Va,bo as Wa,Yr as Xa,Vr as Ya,Jr as Za,Qr as _a,ti as $a,oi as ab,ni as bb,ai as cb,ri as db,ii as eb,si as fb,ci as gb,li as hb,di as ib,pi as jb,mi as kb,ui as lb,gi as mb,bi as nb,fi as ob,yi as pb,hi as qb,zi as rb,Si as sb,xi as tb,Ii as ub,ki as vb,ji as wb,Pi as xb,Oi as yb,Ri as zb,wi as Ab,vi as Bb,Ai as Cb,Ei as Db,Ci as Eb,Ti as Fb,_i as Gb,Ni as Hb,Di as Ib,Fi as Jb,Mi as Kb,Ui as Lb,Li as Mb,Bi as Nb,$i as Ob,qi as Pb,Gi as Qb,Wi as Rb,Ki as Sb,Hi as Tb,Zi as Ub,Xi as Vb,Yi as Wb,Vi as Xb,Ji as Yb,Qi as Zb,es as _b,ts as $b,os as ac,ns as bc,as as cc,rs as dc,is as ec,ss as fc,cs as gc,ls as hc,ds as ic,Fn as jc,Mn as kc,us as lc,gs as mc,bs as nc,fs as oc,ys as pc,hs as qc,zs as rc,Ss as sc,xs as tc,Is as uc,Ln as vc,ks as wc,Ro as xc,Ms as yc,Us as zc,xe as Ac,Zn as Bc,Xn as Cc,Ys as Dc,Vs as Ec,Bs as Fc,$s as Gc,Gs as Hc,Ie as Ic,Ws as Jc,Co as Kc,ea as Lc,Ks as Mc,ta as Nc,Hs as Oc,Zs as Pc,Eo as Qc};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{a as j,c as M}from"./chunk-INIT2UKJ.mjs";import{d as K}from"./chunk-55LQD3Y3.mjs";import{a as T,h as N}from"./chunk-TZE3Y7IQ.mjs";import{ac as z,bc as J,cc as Q,fc as C,gc as v,nc as H,oc as $,pc as F}from"./chunk-DPYTG6DM.mjs";var ee="Id = NULL",B="no parent in cache and not the root",Y=class{build(t){let n=this.buildMeasured(t);return{...n,statements:_(n.statements,t.node.objectApiName,t.selectFields)}}buildMeasured(t){let n=N(t.node.objectApiName),o=k(M(t.selectFields)),r=t.extraWhere?` AND (${t.extraWhere})`:"",i=t.extraWhere?" + extra filter":"",l=`SELECT ${o} FROM ${n} WHERE `,u=t.node.objectApiName===t.rootObjectApiName&&!t.under;if(u&&!(t.rootReadAgain&&t.cache.has(t.node.objectApiName))){if(t.rootRecordIds!==void 0)return{statements:L({prefix:l,suffix:r,wrap:!1,objectApiName:t.node.objectApiName},[{field:"Id",ids:t.rootRecordIds}]),scoped:t.rootRecordIds.size>0,scope:"root",reason:`${t.rootRecordIds.size} root records${i}`,parentObjectsUsed:[t.rootObjectApiName],scopeIdCount:t.rootRecordIds.size,byIdCount:0};let b=T(t.rootRecordId??"");return{statements:[`${l}Id = '${b}'${r}`],scoped:!0,scope:"root",reason:`root record${i}`,parentObjectsUsed:[t.rootObjectApiName],scopeIdCount:1,byIdCount:0}}let d=t.under?void 0:t.cache.get(t.node.objectApiName),s=d?.size??0,a=d&&s>0?L({prefix:l,suffix:r,wrap:!1,objectApiName:t.node.objectApiName},[{field:"Id",ids:d}]):[],h=`${s} ID(s) cached from earlier wave`,f={statements:a,scoped:!0,scope:"self-cached",reason:`${h}${i}`,parentObjectsUsed:[],scopeIdCount:s,byIdCount:a.length};if(s>0&&(!t.everyEdge||u))return f;let g=[],I=[],y=0;for(let b of t.edges){if(b.targetObject!==t.node.objectApiName||t.under&&!t.under.has(b.sourceObject)||b.sourceObject===b.targetObject)continue;let O=t.fromAboveOnly||t.catalog?.has(b.sourceObject)?t.cache.reachedOf(b.sourceObject):t.cache.scopeOf(b.sourceObject);if(!O||O.size===0)continue;let S=t.fields.filter(c=>c.type==="reference"&&c.referenceTo.includes(b.sourceObject));if(S.length!==0){for(let c of S)g.push({field:N(c.name),ids:O});I.includes(b.sourceObject)||(I.push(b.sourceObject),y+=O.size)}}let R=[];for(let b of t.fields){if(b.type!=="reference"||b.nillable!==!1)continue;let O=new Set;for(let S of b.referenceTo){if(!t.readObjects?.has(S))continue;let c=t.catalog?.has(S)===!0;if(c&&!t.cache.isRead(S))continue;let m=c?t.cache.scopeOf(S):t.cache.get(S);if(m)for(let p of m)O.add(p)}O.size!==0&&R.push({field:N(b.name),ids:O})}let x=R.length>0?" + required parents in scope":"";if(g.length===0)return s>0?f:{statements:[`${l}${ee}`],scoped:!1,scope:"unscoped",reason:B,parentObjectsUsed:[],scopeIdCount:0,byIdCount:1};let w=Z({prefix:l,extraSuffix:r,objectApiName:t.node.objectApiName},g,R),A=`via ${I.join(", ")}${i}${x}`;return s===0?{statements:w,scoped:!0,scope:"parent-fk",reason:A,parentObjectsUsed:I,scopeIdCount:y,byIdCount:0}:{statements:[...a,...w],scoped:!0,scope:"self-and-parent-fk",reason:`${h}, and ${A}`,parentObjectsUsed:I,scopeIdCount:s+y,byIdCount:a.length}}buildJoining(t){let n=N(t.objectApiName),r=`SELECT ${k(M(t.selectFields))} FROM ${n} WHERE `,i=t.extraWhere?` AND (${t.extraWhere})`:"";return _(Z({prefix:r,extraSuffix:i,objectApiName:t.objectApiName},[{field:N(t.split.field),ids:t.split.ids}],[{field:N(t.whole.field),ids:t.whole.ids}]),t.objectApiName,t.selectFields)}buildById(t){let n=N(t.objectApiName);return _(L({prefix:`SELECT ${k(M(t.selectFields))} FROM ${n} WHERE `,suffix:t.extraWhere?` AND (${t.extraWhere})`:"",wrap:!1,objectApiName:t.objectApiName},[{field:"Id",ids:t.ids}]),t.objectApiName,t.selectFields)}};function k(e){return e.length===0?"Id":e.map(t=>N(t)).join(", ")}function _(e,t,n){let o=N(t),r=`SELECT ${k(M(n))} FROM ${o} `,i=`SELECT ${k(n)} FROM ${o} `;return r===i?[...e]:e.map(l=>l.startsWith(r)?i+l.slice(r.length):l)}var te=500;function W(e,t){let n=[...t].map(o=>`'${T(o)}'`).join(", ");return` AND (${e.field} IN (${n}))`}function ne(e,t){if(e.field!==t.field)return!1;for(let n of e.ids)if(!t.ids.has(n))return!1;return!0}function oe(e,t,n){let o=j(W(e,[])),r=j(", "),i=[],l=[],u=o;for(let d of e.ids){let s=j(`'${T(d)}'`);if(l.length>0&&u+r+s>t&&(i.push(l),l=[],u=o),l.length===0&&o+s>t)throw X(n);u+=(l.length>0?r:0)+s,l.push(d)}return l.length>0&&i.push(l),i}function re(e,t,n){let o=[""];for(let r of e){let i=oe(r,t/e.length,n);o=o.flatMap(l=>i.map(u=>l+W(r,u)))}return o}function Z(e,t,n){let o=(d,s)=>L({prefix:e.prefix,suffix:d,wrap:d!=="",objectApiName:e.objectApiName},s),r=n.map(d=>W(d,d.ids)).join(""),i=14e3-j(`${e.prefix}()${e.extraSuffix}`);if(j(r)<=i/2)return o(`${r}${e.extraSuffix}`,t);let l=new Map;for(let d of t){let s=n.filter(f=>!ne(d,f)),a=s.map(f=>f.field).join("|"),h=l.get(a)??{needed:s,clauses:[]};h.clauses.push(d),l.set(a,h)}let u=[];for(let d of l.values())for(let s of re(d.needed,i/2,e.objectApiName))u.push(...o(`${s}${e.extraSuffix}`,d.clauses));return u}function X(e){return new Error(`Scoped clone for ${e}: its filter leaves a Salesforce query URI no room for a single record Id. Shorten the filter on this object and run it again.`)}function L(e,t){let n=e.wrap?"(":"",o=e.wrap?")":"",r=j(e.prefix+n+o+e.suffix),i=j(", "),l=j(" OR "),u=[],d=[],s=r,a=0,h=()=>{let f=d.map(g=>`${g.field} IN (${g.values.join(", ")})`).join(" OR ");u.push(`${e.prefix}${n}${f}${o}${e.suffix}`),d=[],s=r,a=0};for(let f of t){let g=j(`${f.field} IN ()`),I=!1;for(let y of f.ids){let R=`'${T(y)}'`,x=j(R),w=I?i+x:(d.length>0?l:0)+g+x,A=s+w>14e3||a>=te;if(d.length>0&&A&&(h(),I=!1,w=g+x),d.length===0&&s+w>14e3)throw X(e.objectApiName);I?d[d.length-1].values.push(R):(d.push({field:f.field,values:[R]}),I=!0),s+=w,a++}}return d.length>0&&h(),u}var G="Product2",U=[C,G,$,F,v,"ProductCategory","ProductCatalog"],Ne=new Set(U);function je(e,t){return z(e,t.name,t.nillable)||e===C&&t.name===H}function xe(e,t=new Set){let n=new Set(e.nodes.map(o=>o.objectApiName));return new Set(U.filter(o=>!n.has(o)&&!t.has(o)))}function we(e,t){return e.nodes.some(n=>n.included&&t.has(n.objectApiName))?{...e,nodes:e.nodes.map(n=>n.included&&t.has(n.objectApiName)?{...n,included:!1}:n)}:e}function se(e,t,n){if(t.length<2)return t;let o=e.slice(0,3),r=t.find(i=>n.get(i)===o);return r!==void 0?[r]:t.filter(i=>!n.has(i))}function Ae(e,t){let n=q(e);return t?he(n,t):n}function Ee(e,t,n){let o=U.flatMap(f=>t.filter(({node:g})=>g.objectApiName===f)),r=new Set(o.flatMap(({fieldInfos:f})=>f.flatMap(g=>g.isReference?g.referenceTo??[]:[]))),i=new Map,l=new Map,u=(f,g,I)=>{let y=f.get(g);y?y.push(I):f.set(g,[I])};for(let{sourceObject:f,targetObject:g}of n)u(i,g,f),u(l,f,g);let d=[],s=new Set,a=[...e],h=a.filter(f=>r.has(f.objectApiName));for(;h.length>0;){for(let f of h)s.add(f.objectApiName),d.push(f);a=a.filter(f=>!s.has(f.objectApiName)),h=a.filter(({objectApiName:f})=>(i.get(f)??[]).some(g=>s.has(g))||(l.get(f)??[]).some(g=>s.has(g)))}return[...a,...o.map(({node:f})=>f),...d]}function V(e){return e.settable!==!1}function Ce(e,t){let n=!1,o=e.edges.map(r=>{let i=(t.get(r.targetObject)??[]).filter(s=>s.isReference&&(s.referenceTo??[]).includes(r.sourceObject));if(i.length===0)return r;let l=i.some(s=>J(s)),u=i.some(s=>Q(s));if(l===V(r)&&u===(r.insertOnly===!0))return r;n=!0;let d={...r};return l?delete d.settable:d.settable=!1,u?d.insertOnly=!0:delete d.insertOnly,d});return n?{...e,edges:o}:e}function Fe(e,t=[]){let n=e.edges.filter(V),o=[...n.filter(c=>c.required===!0),...t],r=n.filter(c=>c.insertOnly===!0&&c.required!==!0);if(o.length===0&&r.length===0)return q(e,n);let i=new Set(e.nodes.map(c=>c.objectApiName)),l=q(e,n),u=new Map(l.map((c,m)=>[c.objectApiName,m])),d=new Map,s=new Map,a=new Map,h=(c,m,p)=>{let E=c.get(m)??new Set;E.add(p),c.set(m,E)};for(let c of o){let{sourceObject:m,targetObject:p}=c;m===p||!i.has(m)||!i.has(p)||(h(d,p,m),h(s,m,p))}for(let c of n){let{sourceObject:m,targetObject:p}=c;m===p||!i.has(m)||!i.has(p)||d.get(p)?.has(m)||h(a,p,m)}let f=new Map;for(let[c,m]of a)for(let p of m)h(f,p,c);let g=new Map,I=new Map;for(let{sourceObject:c,targetObject:m}of r)c===m||!i.has(c)||!i.has(m)||d.get(m)?.has(c)||(h(g,m,c),h(I,c,m));let y=new Map,R=new Map,x=new Map;for(let c of i)y.set(c,d.get(c)?.size??0),R.set(c,g.get(c)?.size??0),x.set(c,a.get(c)?.size??0);let w=(c,m)=>{for(let p of[R,x,u]){let E=p.get(c)??0,D=p.get(m)??0;if(E!==D)return E<D}return!1},A=new Set([...i].filter(c=>y.get(c)===0)),b=new Map(e.nodes.map(c=>[c.objectApiName,c])),O=[],S=new Set;for(;A.size>0;){let c;for(let p of A)(c===void 0||w(p,c))&&(c=p);if(c===void 0)break;A.delete(c),S.add(c);let m=b.get(c);m&&O.push(m);for(let p of s.get(c)??[]){let E=(y.get(p)??1)-1;y.set(p,E),E===0&&!S.has(p)&&A.add(p)}for(let p of I.get(c)??[])R.set(p,(R.get(p)??1)-1);for(let p of f.get(c)??[])x.set(p,(x.get(p)??1)-1)}for(let c of e.nodes)S.has(c.objectApiName)||O.push(c);return O}function $e(e,t){return[[G,F],[$,F],[G,C],[$,C],[F,C],[v,C],...t.map(o=>[C,o])].filter(([o,r])=>o!==r&&e.has(o)&&e.has(r)).map(([o,r])=>({sourceObject:o,targetObject:r,relationshipName:`${o}Before${r}`,type:"lookup",required:!0}))}var ie=new Set(["Id","Name","CurrencyIsoCode","IsPersonAccount","IsActive","Status","IsWhat","IsInvitee","Response","RespondedDate",...Object.values(K).flat()]);function de(e,t){let n=new Set(t??[]);return e.filter(o=>o.queryable&&(!n.has(o.name)||o.isReference||ie.has(o.name))).map(o=>o.name)}var ce=2;function ae(e,t){let n=Array.from({length:t.length+1},(o,r)=>r);for(let o=1;o<=e.length;o++){let r=[o];for(let i=1;i<=t.length;i++)r[i]=Math.min(n[i]+1,r[i-1]+1,n[i-1]+(e[o-1]===t[i-1]?0:1));n=r}return n[t.length]}function le(e,t){let n=e.toLowerCase(),o;for(let r of t){let i=ae(n,r.toLowerCase());i<=ce&&i<n.length&&(!o||i<o.edits)&&(o={name:r,edits:i})}return o?.name}function Te(e,t,n){let o={},r=[];for(let[i,l]of Object.entries(e)){let u=t.find(a=>a.toLowerCase()===i.toLowerCase())??i,d=n(u),s=o[u]??=[];for(let a of l){let h=d?.find(g=>g.toLowerCase()===a.toLowerCase());if(h===void 0&&d!==null){let g=d===void 0?void 0:le(a,d);r.push({objectApiName:u,field:a,missing:d===void 0?"object":"field",...g!==void 0?{nearest:g}:{}})}let f=h??a;s.includes(f)||s.push(f)}}return{exclusions:o,unmatched:r}}function Me(e){let t=de(e.fieldInfos,e.fieldsLeftOut);t.length===0&&t.push("Id");let n,o=0,r=[],i=!1,l=!!e.rootRecordId||e.rootRecordIds!==void 0;if(e.scopedBuilder&&e.scopeCache&&e.rootObjectApiName&&l&&e.node.objectApiName===F&&e.node.objectApiName!==e.rootObjectApiName&&e.catalog?.has(F)){let d=ge(e.scopedBuilder,e.scopeCache,t,e.extraWhere);if(!d)return{kind:"skip",reason:B};n=d,o=n.length}else if(e.scopedBuilder&&e.scopeCache&&e.rootObjectApiName&&l){let d=e.fieldInfos.filter(a=>a.isReference).map(a=>({name:a.name,type:"reference",referenceTo:a.referenceTo??[],nillable:a.nillable})),s=e.scopedBuilder.build({node:e.node,fields:d,selectFields:t,edges:e.edges,cache:e.scopeCache,rootObjectApiName:e.rootObjectApiName,...e.rootRecordIds!==void 0?{rootRecordIds:e.rootRecordIds}:{rootRecordId:e.rootRecordId},extraWhere:e.extraWhere,everyEdge:!0,readObjects:e.readObjects,catalog:e.catalog,rootReadAgain:e.rootReadAgain,under:e.under});if(!s.scoped)return{kind:"skip",reason:s.reason};n=s.statements,o=s.byIdCount,i=s.scope==="root"&&e.rootRecordIds!==void 0,e.rootRecordIds!==void 0&&(s.scope==="parent-fk"||s.scope==="self-and-parent-fk")&&(r=s.parentObjectsUsed)}else{let d=[...e.extraWhere?[`(${e.extraWhere})`]:[],...e.inIdOrder?.afterId!==void 0?[`Id > ${ue(e.inIdOrder.afterId)}`]:[]],s=d.length>0?` WHERE ${d.join(" AND ")}`:"",a=e.inIdOrder?" ORDER BY Id":"";n=[`SELECT ${t.join(", ")} FROM ${N(e.node.objectApiName)}${s}${a}`]}let u={...o>0?{byIdCount:o}:{},...r.length>0?{readUnder:[...r]}:{}};if(!i&&e.maxRecordsPerObject&&e.maxRecordsPerObject>0){let d=Math.floor(e.maxRecordsPerObject);if(d>0)return fe(n,d,u)}return{kind:"query",statements:n,...u}}function fe(e,t,n={}){return{kind:"query",statements:e.map(o=>`${o} LIMIT ${t+1}`),limit:t,...n}}function ue(e){if(!/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/.test(e))throw new Error(`Not a record id to resume after: ${JSON.stringify(e.slice(0,40))}`);return`'${e}'`}function ge(e,t,n,o){let r=t.scopeOf(G),i=t.scopeOf($);if(!(!r||r.size===0||!i||i.size===0))return e.buildJoining({objectApiName:F,selectFields:n,split:{field:"Product2Id",ids:r},whole:{field:"ProductSellingModelId",ids:i},extraWhere:o})}function ke(e){return(e.byIdCount??0)<e.statements.length}async function Le(e,t,n,o){let r=e.byIdCount??0,i=e.limit,l=s=>{if(i===void 0||s.length<=i)return s;for(let a of s.slice(i))typeof a.Id=="string"&&n?.delete(a.Id);return o?.(),s.slice(0,i)};if(e.statements.length===1){let s=await t(e.statements[0]);if(n&&r===0)for(let a of s)typeof a.Id=="string"&&n.add(a.Id);return l(s)}let u=[],d=new Set;for(let[s,a]of e.statements.entries())for(let h of await t(a)){let f=h.Id;if(typeof f=="string"){if(n&&s>=r&&n.add(f),d.has(f))continue;d.add(f)}if(u.push(h),i!==void 0&&u.length>i)return l(u)}return u}function pe(e,t,n,{settle:o=!0}={}){let r=[];for(let i of n){let l=i.Id;typeof l=="string"&&l&&r.push(l)}o?e.addRead(t,r):e.add(t,r)}function Ge(e,t,n,o,r={}){pe(e,t,n,r);let i=r.keyPrefixes??new Map,l=o.filter(u=>u.isReference&&u.referenceTo&&u.referenceTo.length>0);for(let u of l){let d=u.referenceTo??[];for(let s of n){let a=s[u.name];if(!(typeof a!="string"||!a))for(let h of se(a,d,i))e.add(h,[a])}}}function he(e,t){let n=e.findIndex(l=>l.objectApiName===t);if(n<0)throw new Error(`Cannot run scoped clone with root "${t}" missing from the graph. The root node was excluded or filtered out \u2014 re-include it before executing.`);let o=e[n];if(!o.included)throw o.status==="error"?new Error(`Cannot run scoped clone: root "${t}" could not be measured during discovery (${o.errors[0]??"unknown discovery error"}), and nothing was read or written. Run discovery again once the org answers for it; if it refuses again, the user the clone reads as may not read ${t}: start from a record the user can read.`):new Error(`Cannot run scoped clone with root "${t}" excluded: the clone starts from its record, and the records that point at it would be written without it. Include it again, or clone from a query instead of a record.`);if(n===0)return e;let r=[...e],[i]=r.splice(n,1);return r.unshift(i),r}function q(e,t){let n=t??e.edges,o=new Map;for(let s of e.nodes)o.set(s.objectApiName,s);let r=new Map,i=new Map;for(let s of e.nodes)r.set(s.objectApiName,0);for(let s of n){r.has(s.targetObject)&&r.set(s.targetObject,(r.get(s.targetObject)??0)+1);let a=i.get(s.sourceObject);a?a.push(s.targetObject):i.set(s.sourceObject,[s.targetObject])}let l=[];for(let[s,a]of r)a===0&&l.push(s);let u=[],d=new Set;for(;l.length>0;){let s=l.shift();if(d.has(s))continue;d.add(s);let a=o.get(s);a&&u.push(a);let h=i.get(s);if(h){for(let f of h)if(r.has(f)){let g=(r.get(f)??1)-1;r.set(f,g),g===0&&!d.has(f)&&l.push(f)}}}for(let s of e.nodes)d.has(s.objectApiName)||u.push(s);return u}export{B as a,Y as b,te as c,G as d,U as e,Ne as f,je as g,xe as h,we as i,se as j,Ae as k,Ee as l,V as m,Ce as n,Fe as o,$e as p,de as q,Te as r,Me as s,fe as t,ke as u,Le as v,pe as w,Ge as x};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{a,b}from"./chunk-YIGFYZQY.mjs";import"./chunk-2Z54GB6X.mjs";import"./chunk-SQGP46QS.mjs";import"./chunk-PPGDAUEQ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-EAFLDSQ2.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as grantsByObject,b as guardCheckpoint};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a,b,c,d}from"./chunk-IAZB4WIL.mjs";import"./chunk-OTWRDD6L.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-B45CNPUX.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{a as ARTICLE_VERSION_OBJECT,b as articleBodyFields,c as articleBodyOptions,d as seedKnowledge};
7
+ import{a,b,c,d}from"./chunk-K77NR3UK.mjs";import"./chunk-BNO5GIJ6.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as ARTICLE_VERSION_OBJECT,b as articleBodyFields,c as articleBodyOptions,d as seedKnowledge};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{a as Ce}from"./chunk-GMY5427L.mjs";import{h as Re,i as be,j as Se,k as ke,n as Te,o as Fe}from"./chunk-TEIBWMJM.mjs";import{c as Oe}from"./chunk-BWWQXU2B.mjs";import{f as he,i as me,o as we}from"./chunk-UIUPPEFB.mjs";import{a as z,l as ie,o as ae,q as de,t as ce,u as ue,v as le}from"./chunk-ICIYL45C.mjs";import{b as ye,e as ge}from"./chunk-ZUA5BNAO.mjs";import{b as fe,c as q,m as pe}from"./chunk-HFSBDM7B.mjs";import{d as K}from"./chunk-OHEOJISY.mjs";import{G as se,q as te,s as ne,t as re,u as oe}from"./chunk-55LQD3Y3.mjs";import{b as ee}from"./chunk-CA5NAXSU.mjs";import{Lc as B,tc as X}from"./chunk-DPYTG6DM.mjs";var H=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function b(t){return t.slice(0,15)}var We=class{constructor(e=new Map){this.earlier=e}earlier;written=new Map;refused=new Map;deleted=new Set;ownersRefused=new Set;contactsSentWith=new Map;noteSentWithContact(e,n){this.contactsSentWith.set(b(e),n)}contactSentWith(e){return this.contactsSentWith.get(b(e))}roleLinkedFor(e){this.contactsSentWith.delete(b(e))}get sentWithAContact(){return this.contactsSentWith.size>0}noteOwnerRefused(e){this.ownersRefused.add(b(e))}isOwnerRefused(e){return this.ownersRefused.has(b(e))}noteDeleted(e){for(let n of e)this.deleted.add(b(n))}standing(e){return e!==void 0&&this.deleted.has(b(e))?void 0:e}noteMatched(e,n){this.noteWritten(e,n)}noteWritten(e,n){this.written.set(b(e),n),this.refused.delete(b(e))}noteRefused(e,n){this.written.has(b(e))||this.refused.set(b(e),n)}targetOf(e){return this.standing(this.written.get(b(e)))??this.standing(this.earlier.get(b(e)))}refusedObjectOf(e){if(this.standing(this.earlier.get(b(e)))===void 0)return this.refused.get(b(e))}};function Ae(t,e,n){if(e.length===0||!n.some(o=>!o.master))return;let r={};for(let o of e)r[o]=(r[o]??0)+1;let s=Se(be(n));return{objectApiName:t,rows:e.length,why:r,...s?{predicted:s}:{}}}function Ie(t,e){return q(t,e?.target??[])}function Y(t){switch(t.operation){case"insert":return null;case"upsert":return t.externalIdField??"Id";case"update":case"delete":return"Id"}}function ze(t,e,n,r,s){let o=ge(t,e);for(let i of n)(!(i.fieldApiName in o)||i.overwriteExisting)&&(o[i.fieldApiName]=i.value);if(!r)return o;let a={};for(let i of Object.keys(o))i!=="attributes"&&(r.has(i)||i===s)&&(a[i]=o[i]);return a}function ve(t,e){return`${t} ${e} record${t===1?"":"s"}`}function Ue(t,e,n){let r=a=>e.find(i=>b(i.recordTypeId)===b(a)),s=t;if(!r(t)&&n){let a=n.mappings.find(i=>b(i.sourceId)===b(t));if(!a){let i=n.source.find(c=>b(c.id)===b(t)),y=i?(n.target??[]).filter(c=>c.sobjectType===i.sobjectType&&c.developerName===i.developerName):[];return{unmapped:i?K(i):"",namesakes:y.map(K)}}s=a.targetId}let o=q(e.filter(a=>b(a.recordTypeId)===b(s)),n?.target??[])[0];return o&&!o.available&&!o.master?{unavailable:o}:o?{sent:s,info:o}:{sent:s}}function Ge(t,e,n){if(t?.personAccounts===!1)return!0;if(!n)return!1;let r=e??Te(t?.recordTypes);return r!==void 0&&!n.has(b(r))}function Le(t,e,n){return{group:`parent:${e}:${n}`,reason:`PARENT_REFUSED: the ${n} record its ${e} names was refused in this run.`,say:r=>`PARENT_REFUSED: ${ve(r,t)} held back, not sent: the ${n} record their ${e} names was refused in this run, and written without it they would stand without their ${n}.`}}function Ee(t){let{config:e,records:n,target:r,run:s}=t,o=e.objectApiName,a=Y(e),i=r?.recordTypes??[],y=r?.references??new Set,c={payloads:[],sentAt:[],settled:[],held:[],deferred:[],deferredAcross:[],notes:[],currencies:[],withoutRecordType:new Map},h=new Map,m=new Map,T=(d,l,g,k)=>{c.held.push({index:d,reason:g}),h.delete(d);let I=m.get(l);I?I.count++:m.set(l,{count:1,say:k})},w=e.operation==="insert"||e.operation==="upsert",W=w&&i.some(d=>!d.master),f=new Map;s&&w&&s.sources.forEach((d,l)=>{let g=d?.Id;typeof g=="string"&&H.test(g)&&f.set(b(g),l)});let v=new Set([...s&&w?s.later??[]:[]].map(d=>d.toLowerCase())),R=new Set(v.size===0?[]:(r?.fields??[]).flatMap(d=>d.isReference&&(d.referenceTo??[]).some(l=>v.has(l.toLowerCase()))&&!(d.nillable===!1&&d.defaultedOnCreate!==!0)?[d.name]:[]));n.forEach((d,l)=>{let g=ze(d,e.fieldMappings,e.addOnFields,r?.creatable??null,a);if(e.operation==="delete"){h.set(l,{payload:g,settled:new Set});return}let k=new Set;if(s)for(let p of Object.keys(g)){let C=g[p];if(p==="RecordTypeId"||!y.has(p)||typeof C!="string"||!H.test(C))continue;if(f.has(b(C))){delete g[p],c.deferred.push({index:l,field:p,parent:C});continue}let _=s.links.targetOf(C);if(_){g[p]=_,k.add(p);continue}let M=s.links.refusedObjectOf(C);if(M===void 0){R.has(p)&&(delete g[p],c.deferredAcross.push({index:l,field:p,parent:C}));continue}let G=Le(o,p,M);T(l,G.group,G.reason,G.say);return}let I=g.RecordTypeId,E,j=Oe(I);if(j)delete g.RecordTypeId;else if(typeof I=="string"&&H.test(I)){let p=Ue(I,i,s?.recordTypes);if("unmapped"in p){let C=p.unmapped,_=p.namesakes.length>0?` The target org's ${p.namesakes.join(" and ")} carries its DeveloperName under another namespace, and a record type is mapped to one of the same namespace only.`:"";T(l,`unmapped:${C}`,"RECORD_TYPE_UNMAPPED: its record type has no counterpart in the target org.",M=>`RECORD_TYPE_UNMAPPED: ${ve(M,o)} held back, not sent: `+(C?`their record type ${C} has no active ${o} record type of that API name in the target org.${_} Create or activate record type ${C} on ${o} in the target org.`:"their record type is inactive in the source org, and has no counterpart in the target org."));return}if("unavailable"in p){let C=p.unavailable;T(l,`unavailable:${C.recordTypeId}`,`RECORD_TYPE_UNAVAILABLE: record type ${C.developerName} is closed to the running user in the target org.`,_=>`${pe({objectApiName:o,recordTypeId:C.recordTypeId,developerName:C.developerName,name:C.name,inactive:!C.active,recordCount:_})} Held back, not sent.`);return}g.RecordTypeId=p.sent,E=p.sent,p.info&&k.add("RecordTypeId")}let $=s?.sources[l]??d;if(re($)){let p=oe($,Ge(r,E,s?.recordTypes?.personTypes));for(let C of Object.keys(g))B(o,C,p)&&delete g[C]}else for(let p of Object.keys(g))B(o,p,"business")&&delete g[p];W&&!("RecordTypeId"in g)&&c.withoutRecordType.set(l,j?"masterInSource":"notRead"),h.set(l,{payload:g,settled:k})});let L=!0;for(;L;){L=!1;for(let{index:d,field:l,parent:g}of c.deferred){let k=f.get(b(g));if(!h.has(d)||k===void 0||h.has(k)||s?.links.targetOf(g)!==void 0)continue;let I=Le(o,l,o);T(d,I.group,I.reason,I.say),L=!0}}c.deferred=c.deferred.filter(({index:d})=>h.has(d)),c.deferredAcross=c.deferredAcross.filter(({index:d})=>h.has(d));for(let d of[...c.withoutRecordType.keys()])h.has(d)||c.withoutRecordType.delete(d);c.held.sort((d,l)=>d.index-l.index);let S=e.operation==="delete"?void 0:s?.currencies,O=r?.creatable.has(z)===!0,u=!O&&(s?.currencyChangesById?.size??0)>0&&r?.fields?.some(d=>d.name===z)===!0,F=S&&(O||u)?ae(r?.fields??[]):void 0,P=[...r?.references??[]],A=new le;for(let[d,{payload:l,settled:g}]of[...h].sort(([k],[I])=>k-I)){for(let k of X(o,l))delete l[k];if(S&&F){let k=s?.sources[d]??n[d],I=k?.[z],E=O?de(l,{read:I,currencyFields:F,ratesOn:ie(o,k)},S):ue(l,{read:I,parent:k?ce(o,k,P,$=>s?.currencyChangesById?.get($)):void 0,currencyFields:F},S);A.add(o,E);let j=k?.Id;E&&typeof j=="string"&&s?.currencyChangesById?.set(j,E)}c.payloads.push(l),c.sentAt.push(d),c.settled.push(g)}return c.notes=[...m.values()].map(({count:d,say:l})=>l(d)),c.currencies=A.list(),c}function V(t){return typeof t=="number"&&Number.isFinite(t)&&t>0?t:void 0}function Be(t){let e=V(t.length),n=V(t.precision),r=V(t.digits);return{name:t.name,queryable:t.queryable!==!1,createable:t.createable===!0,isReference:t.type==="reference",...t.type!==void 0?{type:t.type}:{},...e!==void 0?{length:e}:{},...t.nillable!==void 0?{nillable:t.nillable}:{},...t.defaultedOnCreate!==void 0?{defaultedOnCreate:t.defaultedOnCreate}:{},...t.calculated===!0?{calculated:!0}:{},...n!==void 0?{precision:n}:{},...n!==void 0&&typeof t.scale=="number"&&t.scale>=0?{scale:t.scale}:{},...r!==void 0?{digits:r}:{},...t.unique===!0?{unique:!0}:{},...t.referenceTo?{referenceTo:[...t.referenceTo]}:{}}}function yt(t){let e=t.fields.filter(r=>r.createable===!0),n=t.fields.some(r=>typeof r.idLookup=="boolean");return{creatable:new Set(e.map(r=>r.name)),references:new Set(e.filter(r=>r.type==="reference").map(r=>r.name)),...typeof t.createable=="boolean"?{objectCreateable:t.createable}:{},...typeof t.updateable=="boolean"?{objectUpdateable:t.updateable}:{},recordTypes:fe(t.recordTypeInfos),...t.name===te?{personAccounts:t.fields.some(r=>r.name===ne)}:{},fields:t.fields.map(Be),...n?{upsertKeys:new Set(t.fields.filter(r=>r.externalId===!0||r.idLookup===!0).map(r=>r.name.toLowerCase()))}:{}}}function Z(t,e,n){switch(e){case"notInTarget":return`Object is not in the target org, or the user the run writes as cannot see it: ${t}. None of its records were sent.`;case"notCreateable":return`Object is not createable on target org: the user the run writes as may not create ${t} records there. None of its records were sent.`;case"notUpdateable":return`Object is not updateable on target org: the user the run writes as may not edit ${t} records there. None of its records were sent.`;case"unread":return`The target org did not describe ${t}${n?` (${n})`:""}, so what it takes could not be told and none of its records were sent.`;case"notAKey":return`The upsert of ${t} matches on ${n??"a field"}, which the target org does not match an upsert on: it takes an External ID field, the Id, or a field its describe marks idLookup. None of its records were sent.`}}function gt(t,e){let n=t.externalIdField?.trim().toLowerCase();if(t.operation!=="upsert"||!n)return t;let r=e.fields?.find(s=>s.name.toLowerCase()===n)?.name;return r===void 0?t:{...t,externalIdField:r}}function ht(t,e){if(t.operation==="delete"||t.query===void 0)return t;let n=Ce(t.query);if(!("list"in n))return t;let r=new Set([...n.list,t.externalIdField??"",...t.fieldMappings.filter(o=>ye.has(o.type)).map(o=>o.sourceField)].map(o=>o.toLowerCase())),s=[...e.creatable].filter(o=>!r.has(o.toLowerCase()));return s.length===0?t:{...t,excludedFields:[...new Set([...t.excludedFields??[],...s])]}}async function Pe(t,e,n,r){let s;try{s=await t(e)}catch(c){if(n==="delete")return{notAsked:!0};let h=Fe(c)?"notInTarget":"unread";return{refused:{why:h,message:Z(e,h,ee(c))}}}let o=n==="insert"||n==="upsert",a=n==="update"||n==="upsert",i=o&&s.objectCreateable===!1?"notCreateable":a&&s.objectUpdateable===!1?"notUpdateable":void 0;if(i)return{refused:{why:i,message:Z(e,i)},target:s};let y=r?.trim()||"Id";return n==="upsert"&&s.upsertKeys&&!s.upsertKeys.has(y.toLowerCase())?{refused:{why:"notAKey",message:Z(e,"notAKey",y),key:y},target:s}:{target:s}}function Rt(t){return t.keepContactPoints===!0?void 0:new Re}function Ot(t,e){if(!t)return e?{neutralized:!1,fields:[],values:0}:void 0;let n=t.report();return n.values>0?n:void 0}function xe(t,e,n,r,s){let o=s?n.filter(i=>i.name!==s):n,a=t.forObject(e,o);if(a)for(let i of r)a(i)}var x=class extends Error{constructor(n,r=[],s=[],o=[],a){super(r.length===0?`The write of ${n} was cancelled before any of its records was written.`:`The write of ${n} was cancelled after ${r.length} of its records were sent.`);this.objectApiName=n;this.written=r;this.notes=s;this.lookupsLeftOut=o;this.writtenWithoutFields=a;this.name="WriteCancelledError"}objectApiName;written;notes;lookupsLeftOut;writtenWithoutFields};var Ne=class{deps;constructor(e){this.deps=e}async sync(e,n,r){let{outcomes:s,notes:o,currencies:a,lookupsLeftOut:i,writtenWithoutFields:y}=await this.write(e,n,r);return Je(Qe(e.objectApiName,e.operation,s,o,i,y),a)}updateRecords(e,n,r){return this.executeOperation(e,"update",n,r)}async write(e,n,r){let s=null;if(this.deps.describeTargetFields){let u=await Pe(this.deps.describeTargetFields,e.objectApiName,e.operation,e.externalIdField);if("refused"in u){let F=n.map(()=>({success:!1,errors:[u.refused.message]}));return r&&$e(e,F,r),{outcomes:F,notes:[],currencies:[],lookupsLeftOut:[]}}"target"in u&&u.target.creatable.size>0&&(s=u.target)}let o=Ee({config:e,records:n,target:s,run:r}),a=r?r.contactPoints:this.deps.contactPoints;a&&s?.fields&&xe(a,e.objectApiName,s.fields,o.payloads,e.externalIdField);let i=He(o.payloads,o.settled,r),y=new Map(o.held.map(({index:u,reason:F})=>[u,F])),c=u=>{let F=[],P=0;for(let A=0;A<n.length;A++){let d=y.get(A);if(d!==void 0){F.push({success:!1,errors:[d],heldBack:!0});continue}if(P>=u.length)break;F.push(u[P++])}return F},h,m=o.sentAt.filter(u=>u<(r?.standardFirst??0)).length,T=u=>this.executeOperation(e.objectApiName,e.operation,u,e.batchSize,e.externalIdField);try{h=o.payloads.length===0&&n.length>0?[]:m>0&&m<o.payloads.length?await Ve(e.objectApiName,T,o.payloads.slice(0,m),o.payloads.slice(m)):await T(o.payloads)}catch(u){if(!(u instanceof x))throw u;let F=je(i,u.written),P=c(u.written);throw De(e,o.withoutRecordType,P,s,r),new x(e.objectApiName,P,[...o.notes,...u.notes],[...F?[F]:[],...u.lookupsLeftOut,...Q(U([...o.deferred,...o.deferredAcross],P))],u.writtenWithoutFields)}let w=await this.retryRefused(e,o.payloads,h,s?.references??null,o.settled);if(r)for(let u of w.ownersRefused)r.links.noteOwnerRefused(u);let W=c(w.outcomes);De(e,o.withoutRecordType,W,s,r);let f=je(i,w.outcomes),v=[...o.notes,...w.notes],R=[...f?[f]:[],...w.lookupsLeftOut],{writtenWithoutFields:L}=w,S=U(o.deferredAcross,W),O=0;if(w.cancelled)throw new x(e.objectApiName,W,v,[...R,...Q([...U(o.deferred,W),...S])],L);if(r){$e(e,W,r),Ze(e,o.payloads,w.outcomes,r.links);let u=await this.setLookups(e,U(o.deferred,W),r.links,!1);if(R.push(...u.leftOut),O=u.unset,u.cancelled)throw new x(e.objectApiName,W,v,[...R,...Q(S)],L)}return{outcomes:W,notes:v,currencies:o.currencies,lookupsLeftOut:R,...L?{writtenWithoutFields:L}:{},...S.length>0?{lookupsToSet:S}:{},...O>0?{lookupsUnset:O}:{}}}async setLookups(e,n,r,s){let o=e.objectApiName,a=new Map,i=new Map,y=new D;for(let{id:f,field:v,parent:R}of n){let L=r.targetOf(R),S=L!==void 0?a:s&&r.refusedObjectOf(R)===void 0?i:void 0;if(!S){y.add(f,v);continue}let O=S.get(f)??{Id:f};O[v]=L??R,S.set(f,O)}let c=new D,h=new D,m=new D,T=new D,w=!1;for(let f of[[...a.values()],[...i.values()]]){if(f.length===0)continue;if(w){for(let R of f)T.addRow(R);continue}let v;try{v=await this.executeOperation(o,"update",f,e.batchSize)}catch(R){if(!(R instanceof x)){let L=R instanceof Error?R.message:String(R);for(let S of f)m.addRow(S,L);continue}v=R.written,w=!0}f.forEach((R,L)=>{let S=v[L];S===void 0?T.addRow(R):S.success?c.addRow(R):S.errors.some(O=>J(O))?h.addRow(R):m.addRow(R,S.errors[0])})}let W=[y,h,m,T];return{...c.records>0?{set:{records:c.records,fields:c.fields()}}:{},leftOut:[y.leftOut("parentRefused"),h.leftOut("notInTarget"),m.leftOut("notSet"),T.leftOut("notReached")].flatMap(f=>f?[f]:[]),unset:new Set(W.flatMap(f=>[...f.recordIds])).size,cancelled:w}}async retryRefused(e,n,r,s,o){let a=Y(e)??void 0,i=[...r],y=[...n],c=n.map(()=>new Set),h=n.map(()=>[]),m=n.map(()=>[]),T=[],w,W=new Set;for(let S=0;S<2&&!w;S++){let O=[],u=[],F=[];if(i.forEach((A,d)=>{if(A.success)return;let l=y[d],g=o[d]??new Set;if(A.errors.some(E=>J(E))){let E=n[d]?.[N];if(typeof E=="string"&&!g.has(N)&&(A.errorDetails??[]).some(p=>J(p.statusCode)&&p.fields.includes(N))&&W.add(E),c[d].has("lookup")||!s||s.size===0)return;let j={},$=!1;for(let p of Object.keys(l)){if(s.has(p)&&!g.has(p)&&l[p]!==null&&l[p]!==void 0){$=!0;continue}j[p]=l[p]}if(!$)return;O.push(d),u.push(j),F.push(null);return}if(c[d].has("fields"))return;let k=he(A.errorDetails,l,a);if(!k||k.some(({field:E})=>g.has(E)))return;let I=new Set(k.map(({field:E})=>E));O.push(d),u.push(Object.fromEntries(Object.entries(l).filter(([E])=>!I.has(E)))),F.push(k)}),O.length===0)break;let P;try{P=await this.executeOperation(e.objectApiName,e.operation,u,e.batchSize,e.externalIdField)}catch(A){if(!(A instanceof x)){T.push(...Ye(O,y,u,F,A));break}P=A.written,w=A}P.forEach((A,d)=>{let l=O[d],g=F[d];c[l].add(g===null?"lookup":"fields"),g===null?h[l].push(...Object.keys(y[l]).filter(k=>!(k in u[d]))):m[l].push(...g),y[l]=u[d],i[l]=A})}let f=new Set,v=0,R,L=new Set(W);return i.forEach((S,O)=>{if(!(!S.success||c[O].size===0)){if(h[O].length>0){v++;for(let F of h[O])f.add(F);let u=n[O]?.[N];typeof u=="string"&&h[O].length===1&&h[O][0]===N&&L.add(u)}m[O].length>0&&(R=me(R,{rows:1,fields:m[O].map(u=>({...u,rows:1}))}))}}),{outcomes:i,notes:[...T,...w?.notes??[]],...R?{writtenWithoutFields:R}:{},cancelled:w!==void 0,ownersRefused:[...L],lookupsLeftOut:[...v>0?[{records:v,fields:[...f].sort(),reason:"notInTarget"}]:[],...w?.lookupsLeftOut??[]]}}async executeOperation(e,n,r,s,o){if(this.deps.crudFlsGuard){let a=r.length>0?Object.keys(r[0]):[],i=await this.deps.crudFlsGuard.checkCrudAndFls(e,n,a);if(!i.allowed)throw new Error(`CRUD/FLS check failed for ${n} on ${e}: ${i.reason}`)}switch(n){case"insert":return this.deps.insert(e,r,s);case"update":return this.deps.update(e,r,s);case"upsert":return this.deps.upsert(e,o??"Id",r,s);case"delete":{let a=r.map(i=>i.Id).filter(i=>typeof i=="string");return this.deps.delete(e,a,s)}}}},Ke=["INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY","INVALID_CROSS_REFERENCE_KEY"],qe=/cross[- ]reference id|r[ée]f[ée]rence crois[ée]e/i;function J(t){return Ke.some(e=>t.includes(e))||qe.test(t)}var N="OwnerId";function He(t,e,n){let r=new Set;return n&&t.forEach((s,o)=>{let a=s[N];typeof a!="string"||e[o]?.has(N)||n.links.isOwnerRefused(a)&&(delete s[N],r.add(o))}),r}function je(t,e){let n=0;for(let r of t)e[r]?.success&&n++;if(n!==0)return{records:n,fields:[N],reason:"ownerRefusedEarlier"}}function Ye(t,e,n,r,s){let o=s instanceof Error?s.message:String(s),a=new Set,i=new Set,y=0;return r.forEach((c,h)=>{if(c===null){y++;let m=n[h];for(let T of Object.keys(e[t[h]]))T in m||a.add(T)}else for(let{field:m}of c)i.add(m)}),[...y>0?[`${y} record(s) the target refused for a lookup it does not have could not be written again without ${[...a].sort().join(", ")}: ${o}`]:[],...i.size>0?[`${t.length-y} record(s) the target refused on fields it named could not be written again without ${[...i].sort().join(", ")}: ${o}`]:[]]}var D=class{ids=new Set;named=new Set;said;add(e,n){this.ids.add(e),this.named.add(n)}addRow(e,n){let r=String(e.Id);for(let s of Object.keys(e))s!=="Id"&&this.add(r,s);n!==void 0&&n!==""&&(this.said??=n)}get records(){return this.ids.size}get recordIds(){return this.ids}fields(){return[...this.named].sort()}leftOut(e){if(this.ids.size!==0)return{records:this.ids.size,fields:this.fields(),reason:e,...this.said!==void 0?{refusal:this.said}:{}}}};function U(t,e){return t.flatMap(({index:n,field:r,parent:s})=>{let o=e[n];return o?.success&&typeof o.id=="string"&&o.id!==""?[{id:o.id,field:r,parent:s}]:[]})}function vt(t){return new Set(t.map(({id:e})=>e)).size}function Q(t){let e=new D;for(let{id:r,field:s}of t)e.add(r,s);let n=e.leftOut("notReached");return n?[n]:[]}function Me(t,e){if(!(e.success||t!=="insert"&&t!=="upsert"))return e.existingId!==void 0&&e.existingId!==""?e.existingId:void 0}async function Ve(t,e,n,r){let s=await e(n);try{return[...s,...await e(r)]}catch(o){throw o instanceof x?new x(t,[...s,...o.written],o.notes,o.lookupsLeftOut,o.writtenWithoutFields):o}}function De(t,e,n,r,s){if(!s?.createdWithoutRecordType||e.size===0)return;let o=[],a=[];for(let[c,h]of e){let m=n[c];!m?.success||typeof m.id!="string"||m.id===""||t.operation!=="insert"&&m.created!==!0||(o.push(h),a.length<ke&&a.push(m.id))}let i=Ie(s.recordTypesUnderTheLease??r?.recordTypes??[],s.recordTypes),y=Ae(t.objectApiName,o,i);y&&s.createdWithoutRecordType.set(t.objectApiName,{given:y,types:i,ids:a})}function Ze(t,e,n,r){t.objectApiName==="Opportunity"&&(t.operation!=="insert"&&t.operation!=="upsert"||e.forEach((s,o)=>{let a=n[o],i=s[se];!a?.success||typeof a.id!="string"||a.id===""||t.operation!=="insert"&&a.created!==!0||typeof i=="string"&&i!==""&&r.noteSentWithContact(a.id,i)}))}function $e(t,e,n){if(t.operation==="delete")return;let r=t.operation==="insert"||t.operation==="upsert";e.forEach((s,o)=>{let a=n.sources[o]?.Id;if(typeof a!="string"||a==="")return;let i=Me(t.operation,s);s.success&&typeof s.id=="string"&&s.id!==""?n.links.noteWritten(a,s.id):i!==void 0?n.links.noteWritten(a,i):!s.success&&r&&n.links.noteRefused(a,t.objectApiName)})}function Je(t,e){return e.length>0?{...t,currenciesReplaced:[...e]}:t}var _e=1e3;function Qe(t,e,n,r=[],s=[],o){let a=0,i=0,y=0,c,h=[],m=0,T={created:0,updated:0},w={rows:0,written:0,stillLocked:0};for(let f of n)f.lockResends!==void 0&&(w.rows++,f.success?w.written++:we(f.errors,f.errorDetails)&&w.stillLocked++),f.success?(a++,f.created===!0?T.created++:f.created===!1&&T.updated++):Me(e,f)!==void 0?(y++,c??=f.errors[0]):(i++,!f.heldBack&&m++<_e&&h.push(...f.errors));let W=Math.max(0,m-_e);return{objectApiName:t,operation:e,processed:n.length,success:a,failed:i,skipped:y,conflictCount:0,errors:[...h,...r],...y>0?{linkedToExisting:{records:y,...c?{refusal:c}:{}}}:{},...s.length>0?{lookupsLeftOut:[...s]}:{},...o?{writtenWithoutFields:o}:{},...w.rows>0?{sentAgainForALock:w}:{},...W>0?{refusalsDropped:W}:{},...e==="upsert"?{upsertSplit:T}:{}}}export{We as a,Ae as b,Ie as c,Ee as d,yt as e,gt as f,ht as g,Pe as h,Rt as i,Ot as j,xe as k,x as l,Ne as m,vt as n,Q as o,Me as p,Je as q,_e as r,Qe as s};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{M as f,j as k,k as s}from"./chunk-NEVXIGR6.mjs";import{a as d,b as u}from"./chunk-TYYOBZMU.mjs";import{Ia as i}from"./chunk-B45CNPUX.mjs";import{b as c,l as a,u as p}from"./chunk-7EANH5PY.mjs";import{homedir as E}from"node:os";import{join as O}from"node:path";var $=a({...d,operation:p(["apply","destroy","reset","recover"]),env:i,alias:c().min(1).max(255).optional()}),l=u(n=>{let e=$.safeParse(n);return e.success?e.data:void 0});function j(n=E()){return k(n)}function v(n,e){return O(n,`${s(e)}.env.lock`)}function K(n,e,o,r={}){let m=v(n,e),y=i.parse(o.env),t=l.acquire(m,h=>({...h,operation:o.operation,env:y,...o.alias!==void 0?{alias:o.alias}:{}}),r);return"busy"in t?{busy:L(t.busy)}:{lock:{organizationId:s(e),release:t.lock.release}}}function N(n,e,o={}){let r=l.holder(v(n,e),o);return r!==void 0?L(r):void 0}function L({version:n,token:e,...o}){return o}function g(n){return`process ${n.pid} on ${n.host}, since ${n.acquiredAt}`}function R(n){return`${w(n)}. Nothing was written: run this again once it ends. Two jobs applying to one org from two machines are not kept apart: give them one concurrency group.`}function w(n){let e=n.alias!==void 0?` to ${n.alias}`:"";return`${n.operation==="apply"?"an apply":n.operation==="recover"?"a state recover":`a ${n.operation}`} of ${n.env}${e} is under way on this machine (${g(n)})`}function _(n,e,o={}){let r=f(n,e,o);if(r!==void 0)return`a checkpoint ${r.operation} of this org is under way on this machine (${g(r)}): its records would be read or written as the step writes. Run this again once it ends.`}export{j as a,v as b,K as c,N as d,R as e,w as f,_ as g};
7
+ import{Q as f,j as k,k as s}from"./chunk-E2YJVSX6.mjs";import{a as d,b as u}from"./chunk-PC247GKX.mjs";import{ib as i}from"./chunk-DPYTG6DM.mjs";import{b as c,l as a,u as p}from"./chunk-WZQEK4WT.mjs";import{homedir as E}from"node:os";import{join as O}from"node:path";var $=a({...d,operation:p(["apply","destroy","reset","recover"]),env:i,alias:c().min(1).max(255).optional()}),l=u(n=>{let e=$.safeParse(n);return e.success?e.data:void 0});function j(n=E()){return k(n)}function v(n,e){return O(n,`${s(e)}.env.lock`)}function K(n,e,o,r={}){let m=v(n,e),y=i.parse(o.env),t=l.acquire(m,h=>({...h,operation:o.operation,env:y,...o.alias!==void 0?{alias:o.alias}:{}}),r);return"busy"in t?{busy:L(t.busy)}:{lock:{organizationId:s(e),release:t.lock.release}}}function N(n,e,o={}){let r=l.holder(v(n,e),o);return r!==void 0?L(r):void 0}function L({version:n,token:e,...o}){return o}function g(n){return`process ${n.pid} on ${n.host}, since ${n.acquiredAt}`}function R(n){return`${w(n)}. Nothing was written: run this again once it ends. Two jobs applying to one org from two machines are not kept apart: give them one concurrency group.`}function w(n){let e=n.alias!==void 0?` to ${n.alias}`:"";return`${n.operation==="apply"?"an apply":n.operation==="recover"?"a state recover":`a ${n.operation}`} of ${n.env}${e} is under way on this machine (${g(n)})`}function _(n,e,o={}){let r=f(n,e,o);if(r!==void 0)return`a checkpoint ${r.operation} of this org is under way on this machine (${g(r)}): its records would be read or written as the step writes. Run this again once it ends.`}export{j as a,v as b,K as c,N as d,R as e,w as f,_ as g};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{q as L}from"./chunk-ZUTYVST5.mjs";import{Eb as C,Gb as R,Lb as S,Mb as m,Pb as b}from"./chunk-B45CNPUX.mjs";var A="PricebookEntryId",F=Object.fromEntries([["OpportunityLineItem","Opportunity"],["QuoteLineItem","Quote"],["OrderItem","Order"],["ContractLineItem","ServiceContract"]].map(([e,o])=>[e,{record:o,field:L[e]}]));function K(e,o,c){if(!e.has(C))return[];let t=new Map;for(let{sourceObject:n,targetObject:a}of c)t.set(n,[...t.get(n)??[],a]);let i=n=>{let a=new Set,l=[C];for(;l.length>0;){let u=l.pop();if(u===n)return!0;a.has(u)||(a.add(u),l.push(...t.get(u)??[]))}return!1};return[...new Set(o.flatMap(n=>F[n]?.record??[]))].filter(n=>e.has(n)&&!i(n)).map(n=>({sourceObject:n,targetObject:C,relationshipName:`${n}Before${C}`,type:"lookup",required:!0}))}function k(e,o){return[e[R],e[S],o?e[m]:""].map(c=>String(c??"")).join("|")}function h(e,o){return`${e}|${o}`}function Y(e){return h([e.book,e.product,e.model].join("|"),e.currency)}function v(e){let o=e[b];return typeof o=="string"&&o!==""?o:void 0}function x(e){let o=e.wanted??new Map,c=e.prices.flatMap(i=>{let d=i.Id,n=v(i);if(typeof d!="string"||n===void 0)return[];let a=e.writtenIn(n),l=new Set(o.get(d)??[]);l.size===0&&!e.active.has(n)&&a!==void 0&&l.add(a);let u=i[R]===e.standardBookId;return[{row:i,id:d,read:n,alone:a,own:l,standard:u}]}),t=new Map;for(let{row:i,read:d,alone:n,own:a,standard:l}of c){if(l)continue;let u=a.size>0?a:n!==void 0?[n]:[],w=h(k({...i,[R]:e.standardBookId},e.sellingModels),d),p=t.get(w)??new Set;for(let y of u)p.add(y);t.set(w,p)}return c.map(({row:i,id:d,read:n,alone:a,own:l,standard:u})=>{let w=k(i,e.sellingModels),p=new Set(o.get(d)??[]);if(u)for(let y of t.get(h(w,n))??[])p.add(y);if(p.size===0)for(let y of l)p.add(y);return{row:i,id:d,key:w,read:n,alone:a,targets:[...p]}})}function _(e,o){let c=new Map;for(let t of e){if(t.alone!==t.read||!o.has(t.read))continue;let i=h(t.key,t.read);c.has(i)||c.set(i,t)}return c}function W(e){let o=x(e),c=_(o,e.active),t=new Map;for(let{row:i,key:d,targets:n}of o)for(let a of n){let l=h(d,a);c.has(l)||t.has(l)||t.set(l,{book:String(i[R]??""),product:String(i[S]??""),model:e.sellingModels?String(i[m]??""):"",currency:a})}return[...t.values()]}function G(e,o){let c=x(e),t=_(c,e.active),i=new Map(c.map(r=>[r.id,r.key])),d=new Map;for(let r of o){let s=r.Id,f=v(r);if(typeof s!="string"||f===void 0||e.writtenIn(f)!==f)continue;let g=k(r,e.sellingModels),P=h(g,f);if(t.has(P))continue;let M=d.get(P);M!==void 0&&!(r.IsActive===!0&&M.IsActive!==!0)||(d.set(P,r),i.set(s,g))}let n=new Map,a=new Set,l=new Set,u=new Map,w=new Set,p=[],y=(r,s,f)=>{s!==r.read&&p.push({from:r.read,to:s,how:f,forLines:s!==r.alone})},E=[];for(let r of c)for(let s of r.targets){let f=h(r.key,s),g=t.get(f);if(g){n.set(f,g.id),a.add(g.id),g!==r&&y(r,s,"replaced");continue}let P=d.get(f);if(P){n.set(f,String(P.Id)),l.add(P),y(r,s,"replaced");continue}E.push({price:r,to:s})}for(let{price:r,to:s}of E){let f=h(r.key,s);n.has(f)?y(r,s,"replaced"):!a.has(r.id)&&!w.has(r.id)?(w.add(r.id),n.set(f,r.id),s!==r.alone&&u.set(r.id,s),y(r,s,"converted")):y(r,s,"none")}let O=new Map,I=[],B=new Map(c.map(r=>[r.row,r]));for(let r of e.prices){let s=B.get(r);if(!s||s.targets.length===0||a.has(s.id)||w.has(s.id)){I.push(r);continue}let f=s.targets.map(g=>n.get(h(s.key,g))).find(g=>g!==void 0&&g!==s.id);if(f===void 0){I.push(r);continue}O.set(s.id,f)}I.push(...o.filter(r=>l.has(r)));for(let r of c){if(r.targets.length>0||r.alone===void 0)continue;let s=h(r.key,r.alone);n.has(s)||n.set(s,r.id)}return{rows:I,standsFor:O,convertedInto:u,written:n,keys:i,said:p}}function N(e){let o=new Map;for(let{from:c,to:t,how:i,forLines:d}of e){let n=[c,t,i,d?"lines":""].join("|"),a=o.get(n)??{from:c,to:t,how:i,forLines:d,prices:0};a.prices++,o.set(n,a)}return[...o.values()]}function $(e){let o=new Map;for(let{from:c,to:t,prices:i}of e){let d=`${c} \u2192 ${t}`;o.set(d,(o.get(d)??0)+i)}return[...o].map(([c,t])=>`${t} ${c}`).join(", ")}function H(e){return T(N(e))}function T(e){let o=(t,i)=>e.filter(d=>d.forLines===t&&d.how===i);return[[o(!1,"replaced"),"price(s) in a currency the target does not hold active replaced by the source's own price in the currency written, for the same product and price book"],[o(!1,"converted"),"no price in the currency written in the source for the same product and price book, written in it at the amount converted at the source's rates"],[o(!0,"replaced"),"price(s) replaced by the source's own price in the currency of the record their lines belong to, for the same product and price book"],[o(!0,"converted"),"no price in the currency of the record their lines belong to in the source for the same product and price book, written in it at its amount converted"],[e.filter(t=>t.how==="none"),"no price in the currency of the record their lines belong to in the source for the same product and price book, and the price goes in another currency for other lines: the target refuses the lines of a record in it"]].filter(([t])=>t.length>0).map(([t,i])=>`${$(t)}: ${i}`)}export{A as a,F as b,K as c,k as d,h as e,Y as f,W as g,G as h,N as i,H as j,T as k};
7
+ import{r as L}from"./chunk-ICIYL45C.mjs";import{fc as C,hc as R,mc as S,nc as m,qc as b}from"./chunk-DPYTG6DM.mjs";var A="PricebookEntryId",F=Object.fromEntries([["OpportunityLineItem","Opportunity"],["QuoteLineItem","Quote"],["OrderItem","Order"],["ContractLineItem","ServiceContract"]].map(([e,o])=>[e,{record:o,field:L[e]}]));function K(e,o,c){if(!e.has(C))return[];let t=new Map;for(let{sourceObject:n,targetObject:a}of c)t.set(n,[...t.get(n)??[],a]);let i=n=>{let a=new Set,l=[C];for(;l.length>0;){let u=l.pop();if(u===n)return!0;a.has(u)||(a.add(u),l.push(...t.get(u)??[]))}return!1};return[...new Set(o.flatMap(n=>F[n]?.record??[]))].filter(n=>e.has(n)&&!i(n)).map(n=>({sourceObject:n,targetObject:C,relationshipName:`${n}Before${C}`,type:"lookup",required:!0}))}function k(e,o){return[e[R],e[S],o?e[m]:""].map(c=>String(c??"")).join("|")}function h(e,o){return`${e}|${o}`}function Y(e){return h([e.book,e.product,e.model].join("|"),e.currency)}function v(e){let o=e[b];return typeof o=="string"&&o!==""?o:void 0}function x(e){let o=e.wanted??new Map,c=e.prices.flatMap(i=>{let d=i.Id,n=v(i);if(typeof d!="string"||n===void 0)return[];let a=e.writtenIn(n),l=new Set(o.get(d)??[]);l.size===0&&!e.active.has(n)&&a!==void 0&&l.add(a);let u=i[R]===e.standardBookId;return[{row:i,id:d,read:n,alone:a,own:l,standard:u}]}),t=new Map;for(let{row:i,read:d,alone:n,own:a,standard:l}of c){if(l)continue;let u=a.size>0?a:n!==void 0?[n]:[],w=h(k({...i,[R]:e.standardBookId},e.sellingModels),d),p=t.get(w)??new Set;for(let y of u)p.add(y);t.set(w,p)}return c.map(({row:i,id:d,read:n,alone:a,own:l,standard:u})=>{let w=k(i,e.sellingModels),p=new Set(o.get(d)??[]);if(u)for(let y of t.get(h(w,n))??[])p.add(y);if(p.size===0)for(let y of l)p.add(y);return{row:i,id:d,key:w,read:n,alone:a,targets:[...p]}})}function _(e,o){let c=new Map;for(let t of e){if(t.alone!==t.read||!o.has(t.read))continue;let i=h(t.key,t.read);c.has(i)||c.set(i,t)}return c}function W(e){let o=x(e),c=_(o,e.active),t=new Map;for(let{row:i,key:d,targets:n}of o)for(let a of n){let l=h(d,a);c.has(l)||t.has(l)||t.set(l,{book:String(i[R]??""),product:String(i[S]??""),model:e.sellingModels?String(i[m]??""):"",currency:a})}return[...t.values()]}function G(e,o){let c=x(e),t=_(c,e.active),i=new Map(c.map(r=>[r.id,r.key])),d=new Map;for(let r of o){let s=r.Id,f=v(r);if(typeof s!="string"||f===void 0||e.writtenIn(f)!==f)continue;let g=k(r,e.sellingModels),P=h(g,f);if(t.has(P))continue;let M=d.get(P);M!==void 0&&!(r.IsActive===!0&&M.IsActive!==!0)||(d.set(P,r),i.set(s,g))}let n=new Map,a=new Set,l=new Set,u=new Map,w=new Set,p=[],y=(r,s,f)=>{s!==r.read&&p.push({from:r.read,to:s,how:f,forLines:s!==r.alone})},E=[];for(let r of c)for(let s of r.targets){let f=h(r.key,s),g=t.get(f);if(g){n.set(f,g.id),a.add(g.id),g!==r&&y(r,s,"replaced");continue}let P=d.get(f);if(P){n.set(f,String(P.Id)),l.add(P),y(r,s,"replaced");continue}E.push({price:r,to:s})}for(let{price:r,to:s}of E){let f=h(r.key,s);n.has(f)?y(r,s,"replaced"):!a.has(r.id)&&!w.has(r.id)?(w.add(r.id),n.set(f,r.id),s!==r.alone&&u.set(r.id,s),y(r,s,"converted")):y(r,s,"none")}let O=new Map,I=[],B=new Map(c.map(r=>[r.row,r]));for(let r of e.prices){let s=B.get(r);if(!s||s.targets.length===0||a.has(s.id)||w.has(s.id)){I.push(r);continue}let f=s.targets.map(g=>n.get(h(s.key,g))).find(g=>g!==void 0&&g!==s.id);if(f===void 0){I.push(r);continue}O.set(s.id,f)}I.push(...o.filter(r=>l.has(r)));for(let r of c){if(r.targets.length>0||r.alone===void 0)continue;let s=h(r.key,r.alone);n.has(s)||n.set(s,r.id)}return{rows:I,standsFor:O,convertedInto:u,written:n,keys:i,said:p}}function N(e){let o=new Map;for(let{from:c,to:t,how:i,forLines:d}of e){let n=[c,t,i,d?"lines":""].join("|"),a=o.get(n)??{from:c,to:t,how:i,forLines:d,prices:0};a.prices++,o.set(n,a)}return[...o.values()]}function $(e){let o=new Map;for(let{from:c,to:t,prices:i}of e){let d=`${c} \u2192 ${t}`;o.set(d,(o.get(d)??0)+i)}return[...o].map(([c,t])=>`${t} ${c}`).join(", ")}function H(e){return T(N(e))}function T(e){let o=(t,i)=>e.filter(d=>d.forLines===t&&d.how===i);return[[o(!1,"replaced"),"price(s) in a currency the target does not hold active replaced by the source's own price in the currency written, for the same product and price book"],[o(!1,"converted"),"no price in the currency written in the source for the same product and price book, written in it at the amount converted at the source's rates"],[o(!0,"replaced"),"price(s) replaced by the source's own price in the currency of the record their lines belong to, for the same product and price book"],[o(!0,"converted"),"no price in the currency of the record their lines belong to in the source for the same product and price book, written in it at its amount converted"],[e.filter(t=>t.how==="none"),"no price in the currency of the record their lines belong to in the source for the same product and price book, and the price goes in another currency for other lines: the target refuses the lines of a record in it"]].filter(([t])=>t.length>0).map(([t,i])=>`${$(t)}: ${i}`)}export{A as a,F as b,K as c,k as d,h as e,Y as f,W as g,G as h,N as i,H as j,T as k};