sandforge 1.83.0 → 1.84.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. package/README.md +1 -1
  2. package/lib/chunk-23SEDORH.mjs +11 -0
  3. package/lib/{chunk-I5C4O3VA.mjs → chunk-24RFOFYT.mjs} +1 -1
  4. package/lib/chunk-26POJDIT.mjs +7 -0
  5. package/lib/{chunk-WJAZ5LHL.mjs → chunk-2AZQHBEF.mjs} +1 -1
  6. package/lib/{chunk-IHGYJZZ2.mjs → chunk-2HVOZUM4.mjs} +1 -1
  7. package/lib/{chunk-3V4YH5KO.mjs → chunk-2JDAOWUW.mjs} +1 -1
  8. package/lib/{chunk-BNKT3R3F.mjs → chunk-2METQHGG.mjs} +1 -1
  9. package/lib/chunk-2WFIVO4F.mjs +13 -0
  10. package/lib/chunk-2YHZBUZE.mjs +7 -0
  11. package/lib/{chunk-7DPHZWA4.mjs → chunk-326AJTIU.mjs} +14 -14
  12. package/lib/{chunk-UIR77ZJD.mjs → chunk-36JOHEJL.mjs} +1 -1
  13. package/lib/chunk-3PVRGTVK.mjs +7 -0
  14. package/lib/{chunk-2WMKJVD2.mjs → chunk-3Q353S2R.mjs} +1 -1
  15. package/lib/chunk-3TZSBHEY.mjs +7 -0
  16. package/lib/{chunk-T36DZJPH.mjs → chunk-43TOMFV4.mjs} +1 -1
  17. package/lib/{chunk-XAMMIPZ4.mjs → chunk-4CVUUVGJ.mjs} +1 -1
  18. package/lib/{chunk-6YC2ELCU.mjs → chunk-4EOHEDFP.mjs} +1 -1
  19. package/lib/{chunk-ZB5E7NHU.mjs → chunk-4JE4BYXK.mjs} +1 -1
  20. package/lib/{chunk-JREKJO3D.mjs → chunk-54WZUS7J.mjs} +1 -1
  21. package/lib/{chunk-CGZGL6VT.mjs → chunk-5CRLRHOJ.mjs} +1 -1
  22. package/lib/{chunk-UOHZW2L4.mjs → chunk-5IZTFMJM.mjs} +1 -1
  23. package/lib/{chunk-6VOQFISN.mjs → chunk-5M5FQ7RP.mjs} +1 -1
  24. package/lib/{chunk-U4YFYSF3.mjs → chunk-5SMWFNE7.mjs} +1 -1
  25. package/lib/{chunk-HQZUQXDC.mjs → chunk-5XTUSN72.mjs} +1 -1
  26. package/lib/chunk-6I6TWNV5.mjs +7 -0
  27. package/lib/{chunk-QLRWU3MB.mjs → chunk-6JWWSDM6.mjs} +1 -1
  28. package/lib/chunk-6O222PW6.mjs +7 -0
  29. package/lib/{chunk-J3TIHLWG.mjs → chunk-6PD6K7LP.mjs} +1 -1
  30. package/lib/{chunk-ISAUCWYK.mjs → chunk-6QE6R6RL.mjs} +1 -1
  31. package/lib/{chunk-2KTGDYUH.mjs → chunk-6WX5ZU7Q.mjs} +1 -1
  32. package/lib/{chunk-XAUQXYPW.mjs → chunk-6YL7BNYD.mjs} +1 -1
  33. package/lib/chunk-6ZLKIT3H.mjs +7 -0
  34. package/lib/{chunk-XKFHTBAB.mjs → chunk-7QYHEHMA.mjs} +1 -1
  35. package/lib/chunk-7SQSWVAU.mjs +9 -0
  36. package/lib/{chunk-NNV7IGM7.mjs → chunk-7UVKIWKV.mjs} +1 -1
  37. package/lib/{chunk-RZKJQOOC.mjs → chunk-7WATA4SB.mjs} +1 -1
  38. package/lib/{chunk-DMT5SCO3.mjs → chunk-7YNM6KFZ.mjs} +1 -1
  39. package/lib/{chunk-TMIESDE5.mjs → chunk-A3MYSOOC.mjs} +1 -1
  40. package/lib/chunk-AL4C3GFT.mjs +7 -0
  41. package/lib/chunk-B3FBHVNN.mjs +21 -0
  42. package/lib/{chunk-CDWZGQAJ.mjs → chunk-B63POIPQ.mjs} +1 -1
  43. package/lib/{chunk-YEVB7LVK.mjs → chunk-BAWCOKRW.mjs} +1 -1
  44. package/lib/{chunk-FVLFO2S6.mjs → chunk-BBRWFKS5.mjs} +1 -1
  45. package/lib/chunk-BEA27DLS.mjs +7 -0
  46. package/lib/chunk-BRY3PLIZ.mjs +7 -0
  47. package/lib/chunk-CBH3TOWK.mjs +341 -0
  48. package/lib/{chunk-7V2UYZ6S.mjs → chunk-CPQIZGG5.mjs} +1 -1
  49. package/lib/chunk-CVHNXJH3.mjs +7 -0
  50. package/lib/{chunk-ZOSESZ22.mjs → chunk-D4GF4FAB.mjs} +1 -1
  51. package/lib/chunk-DGDRQRCW.mjs +7 -0
  52. package/lib/{chunk-2N73W63D.mjs → chunk-DPMRIMUC.mjs} +1 -1
  53. package/lib/chunk-DUN2EPRC.mjs +7 -0
  54. package/lib/chunk-E3A3LOCY.mjs +7 -0
  55. package/lib/{chunk-KWAVSZ2B.mjs → chunk-EAC5QCE3.mjs} +1 -1
  56. package/lib/{chunk-JUOQUG7U.mjs → chunk-EC72TIEG.mjs} +1 -1
  57. package/lib/chunk-EPFCERGL.mjs +7 -0
  58. package/lib/{chunk-6KOUYHEY.mjs → chunk-ETDCBLGU.mjs} +1 -1
  59. package/lib/{chunk-2R6GFNKF.mjs → chunk-F3AQW6IU.mjs} +1 -1
  60. package/lib/{chunk-AHUGG3WU.mjs → chunk-FITPY3L4.mjs} +1 -1
  61. package/lib/chunk-FNJ4SGWO.mjs +7 -0
  62. package/lib/{chunk-EOQON3E5.mjs → chunk-FP7CYB2F.mjs} +1 -1
  63. package/lib/{chunk-262TP6UU.mjs → chunk-GKY2JMHY.mjs} +1 -1
  64. package/lib/{chunk-JBWJ6UEZ.mjs → chunk-GMIGWR6U.mjs} +1 -1
  65. package/lib/{chunk-OS5GE52G.mjs → chunk-GNRSF65U.mjs} +1 -1
  66. package/lib/chunk-GOOVPVWX.mjs +7 -0
  67. package/lib/{chunk-DB5RVDC5.mjs → chunk-GWZRR3MM.mjs} +1 -1
  68. package/lib/{chunk-SX6QWYCQ.mjs → chunk-H2BHESDA.mjs} +2 -2
  69. package/lib/chunk-H4CGM6YO.mjs +7 -0
  70. package/lib/{chunk-NFEBX75O.mjs → chunk-HCGXK7G7.mjs} +1 -1
  71. package/lib/{chunk-4X5D3MSV.mjs → chunk-HIDW7FNV.mjs} +1 -1
  72. package/lib/chunk-HSBXRQTI.mjs +7 -0
  73. package/lib/chunk-HUZPBE47.mjs +7 -0
  74. package/lib/{chunk-F5SBGJWW.mjs → chunk-HV7VPEXP.mjs} +1 -1
  75. package/lib/chunk-I6E6T6YY.mjs +7 -0
  76. package/lib/chunk-IUM4NFKI.mjs +10 -0
  77. package/lib/chunk-IVFVNNGB.mjs +37 -0
  78. package/lib/{chunk-L4MSL4U7.mjs → chunk-IZGCEOYO.mjs} +1 -1
  79. package/lib/{chunk-E3RQ575Y.mjs → chunk-J3DND3BC.mjs} +1 -1
  80. package/lib/{chunk-MJD6CPZZ.mjs → chunk-JAEDM4SI.mjs} +1 -1
  81. package/lib/chunk-JCFBFF4Y.mjs +7 -0
  82. package/lib/{chunk-U2CTKIPE.mjs → chunk-JE6SCT6R.mjs} +1 -1
  83. package/lib/{chunk-XJICAOAQ.mjs → chunk-JGZPD4IM.mjs} +1 -1
  84. package/lib/{chunk-XCJUNX63.mjs → chunk-JKJ74BX5.mjs} +1 -1
  85. package/lib/{chunk-WAYQLQAD.mjs → chunk-JLSIWO4Z.mjs} +1 -1
  86. package/lib/{chunk-D7XUNWWU.mjs → chunk-JSAJS3MY.mjs} +1 -1
  87. package/lib/chunk-JTJK2D36.mjs +7 -0
  88. package/lib/{chunk-OTJH6AEA.mjs → chunk-KAZS5Z6W.mjs} +1 -1
  89. package/lib/chunk-KB4ZHM4Q.mjs +10 -0
  90. package/lib/{chunk-N2HYG3BL.mjs → chunk-KGU4SVIT.mjs} +1 -1
  91. package/lib/{chunk-FKCIGJOI.mjs → chunk-KJWFYBMU.mjs} +2 -2
  92. package/lib/{chunk-KXUOHACP.mjs → chunk-KZTZDC7H.mjs} +1 -1
  93. package/lib/{chunk-S4PRKKGC.mjs → chunk-L2E5WBGD.mjs} +1 -1
  94. package/lib/{chunk-X2XZQ434.mjs → chunk-L53JWJ3S.mjs} +1 -1
  95. package/lib/{chunk-CQAFVEKP.mjs → chunk-LA4KIATH.mjs} +6 -6
  96. package/lib/chunk-LC3NDW4N.mjs +7 -0
  97. package/lib/{chunk-4V3QO7HF.mjs → chunk-LKTNQEBS.mjs} +1 -1
  98. package/lib/chunk-M2ABR4JM.mjs +7 -0
  99. package/lib/{chunk-3CM7LAPE.mjs → chunk-M4BLK6HJ.mjs} +1 -1
  100. package/lib/{chunk-Z3MGN42K.mjs → chunk-M6K34KGF.mjs} +1 -1
  101. package/lib/{chunk-TUPZY2QJ.mjs → chunk-MDMPJEV3.mjs} +1 -1
  102. package/lib/{chunk-BVZ5H3N4.mjs → chunk-MJZU3U5O.mjs} +68 -63
  103. package/lib/{chunk-OUU47Y7A.mjs → chunk-MSIEU5MR.mjs} +1 -1
  104. package/lib/{chunk-QQDZQCO2.mjs → chunk-N4WPCWJO.mjs} +1 -1
  105. package/lib/{chunk-MTM4KG3T.mjs → chunk-NCZKWSC7.mjs} +1 -1
  106. package/lib/{chunk-Y7YUNRKK.mjs → chunk-NED4MBIM.mjs} +1 -1
  107. package/lib/{chunk-QKJXIY6L.mjs → chunk-NOBQTEQD.mjs} +1 -1
  108. package/lib/{chunk-WBELLGNE.mjs → chunk-NSQWI7ZY.mjs} +1 -1
  109. package/lib/{chunk-BPHTA6KP.mjs → chunk-O677VOGO.mjs} +1 -1
  110. package/lib/chunk-OFTT7J2M.mjs +7 -0
  111. package/lib/{chunk-JH4ZTVQN.mjs → chunk-OLCVHL7I.mjs} +1 -1
  112. package/lib/chunk-OM5NORJG.mjs +7 -0
  113. package/lib/{chunk-QP3JLFIO.mjs → chunk-OMNMLKDT.mjs} +1 -1
  114. package/lib/{chunk-WABXKL4N.mjs → chunk-OPMO6I45.mjs} +1 -1
  115. package/lib/{chunk-7ZBDACVG.mjs → chunk-OUZQPYT3.mjs} +1 -1
  116. package/lib/chunk-OVNMB6Q2.mjs +7 -0
  117. package/lib/{chunk-DKDKCGXV.mjs → chunk-PAXNWTYK.mjs} +1 -1
  118. package/lib/{chunk-GLN4PI5P.mjs → chunk-PBY2O6OF.mjs} +1 -1
  119. package/lib/chunk-PEDQPM2P.mjs +926 -0
  120. package/lib/chunk-PH7SP4YK.mjs +21 -0
  121. package/lib/{chunk-BT43WSOS.mjs → chunk-PMN4PAC3.mjs} +1 -1
  122. package/lib/chunk-PMWAFDUB.mjs +48 -0
  123. package/lib/chunk-PPLVFX6N.mjs +7 -0
  124. package/lib/{chunk-L3I6DAHX.mjs → chunk-PR3XCSPO.mjs} +1 -1
  125. package/lib/{chunk-WZN36ACK.mjs → chunk-PR42EZSR.mjs} +1 -1
  126. package/lib/{chunk-NDFFIJL5.mjs → chunk-PWRJRL5U.mjs} +1 -1
  127. package/lib/{chunk-NS6ONPWL.mjs → chunk-Q7GIJBCD.mjs} +1 -1
  128. package/lib/chunk-Q7TLC3I2.mjs +7 -0
  129. package/lib/{chunk-ALBY5SOH.mjs → chunk-QAFPQ3YB.mjs} +1 -1
  130. package/lib/{chunk-KKS2KFBT.mjs → chunk-QKEKG2LD.mjs} +1 -1
  131. package/lib/{chunk-OOIDCHBQ.mjs → chunk-QO53K5W2.mjs} +2 -2
  132. package/lib/{chunk-HVX2AFYW.mjs → chunk-QTG6LUZT.mjs} +1 -1
  133. package/lib/{chunk-K7G3W7XH.mjs → chunk-RE7RYF3B.mjs} +1 -1
  134. package/lib/{chunk-JIPT5FUD.mjs → chunk-RGBGUCJA.mjs} +1 -1
  135. package/lib/{chunk-GT5ZKU6V.mjs → chunk-RGUQOSBU.mjs} +1 -1
  136. package/lib/{chunk-VXZ5PTOM.mjs → chunk-RHNTHGNU.mjs} +1 -1
  137. package/lib/chunk-RKTFFCNS.mjs +7 -0
  138. package/lib/chunk-RMFU4BAL.mjs +28 -0
  139. package/lib/{chunk-DNQKVCUV.mjs → chunk-ROV3QXEF.mjs} +11 -11
  140. package/lib/chunk-RT47RKLY.mjs +7 -0
  141. package/lib/{chunk-ISOSTAJR.mjs → chunk-S42RBRH2.mjs} +1 -1
  142. package/lib/{chunk-27BBEGUD.mjs → chunk-SI267LYR.mjs} +1 -1
  143. package/lib/chunk-T3G6VZNS.mjs +7 -0
  144. package/lib/chunk-TNT27RBG.mjs +7 -0
  145. package/lib/chunk-UBIKR5VO.mjs +7 -0
  146. package/lib/chunk-UI3JQVRU.mjs +8 -0
  147. package/lib/{chunk-RVCPQVKM.mjs → chunk-UIOMAX56.mjs} +1 -1
  148. package/lib/chunk-UX3BVH2Y.mjs +7 -0
  149. package/lib/{chunk-L4RJX7DG.mjs → chunk-VCUXCK36.mjs} +1 -1
  150. package/lib/chunk-VINGECAJ.mjs +10 -0
  151. package/lib/chunk-VOXJHJIE.mjs +7 -0
  152. package/lib/chunk-W6PN6TJG.mjs +7 -0
  153. package/lib/{chunk-D6JT4PAB.mjs → chunk-WAPSSYMT.mjs} +1 -1
  154. package/lib/{chunk-7BQMBXKX.mjs → chunk-WUUKFE2U.mjs} +1 -1
  155. package/lib/chunk-WWTCWWZI.mjs +7 -0
  156. package/lib/chunk-WXDLQT2O.mjs +10 -0
  157. package/lib/{chunk-TCEXCHXR.mjs → chunk-WY5V5PR3.mjs} +1 -1
  158. package/lib/chunk-X4BXESMQ.mjs +7 -0
  159. package/lib/chunk-XBQGZGWR.mjs +7 -0
  160. package/lib/{chunk-AXFD2OH6.mjs → chunk-XGGOUNPP.mjs} +1 -1
  161. package/lib/chunk-XKWW3GKF.mjs +7 -0
  162. package/lib/{chunk-PDRXM5WN.mjs → chunk-Y2DRK37K.mjs} +1 -1
  163. package/lib/{chunk-ZXOUWHYE.mjs → chunk-YA6ATMTB.mjs} +1 -1
  164. package/lib/{chunk-54HYHHVL.mjs → chunk-YDXMTWAT.mjs} +1 -1
  165. package/lib/chunk-YHR4WQPR.mjs +7 -0
  166. package/lib/{chunk-LWES2KZE.mjs → chunk-YTLUYSMF.mjs} +1 -1
  167. package/lib/{chunk-2K5BYZQM.mjs → chunk-YWEQQL3C.mjs} +1 -1
  168. package/lib/{chunk-C6RKM4BB.mjs → chunk-Z4LKKOFY.mjs} +1 -1
  169. package/lib/chunk-ZBAWJUG2.mjs +7 -0
  170. package/lib/{chunk-446GBKAC.mjs → chunk-ZJW6YOMV.mjs} +1 -1
  171. package/lib/chunk-ZQQXSCVI.mjs +7 -0
  172. package/lib/{chunk-L6CLN664.mjs → chunk-ZQWIVYVM.mjs} +1 -1
  173. package/lib/{chunk-CXKZ6TYV.mjs → chunk-ZV7ZFQQC.mjs} +1 -1
  174. package/lib/sandforge-autopilot.mjs +25 -25
  175. package/lib/sandforge-backup.mjs +1 -1
  176. package/lib/sandforge-checkpoint.mjs +1 -1
  177. package/lib/sandforge-cleanup.mjs +1 -1
  178. package/lib/sandforge-clone.mjs +1 -1
  179. package/lib/sandforge-compare.mjs +52 -21
  180. package/lib/sandforge-dataops.mjs +1 -1
  181. package/lib/sandforge-empty.mjs +1 -1
  182. package/lib/sandforge-env.mjs +95 -95
  183. package/lib/sandforge-frozen.mjs +1 -1
  184. package/lib/sandforge-mcp.mjs +12 -12
  185. package/lib/sandforge-monitor.mjs +1 -1
  186. package/lib/sandforge-pipeline.mjs +1 -1
  187. package/lib/sandforge-seed.mjs +1 -1
  188. package/lib/sandforge-sync.mjs +1 -1
  189. package/lib/sandforge-users.mjs +1 -1
  190. package/lib/sandforge.mjs +1 -1
  191. package/lib/sf/sandforge/compare.mjs +2 -2
  192. package/lib/sfPlugin.mjs +1 -1
  193. package/oclif.manifest.json +1 -1
  194. package/package.json +1 -1
  195. package/lib/chunk-2ADSD5WK.mjs +0 -7
  196. package/lib/chunk-2GSMHGIV.mjs +0 -7
  197. package/lib/chunk-36Y225OM.mjs +0 -7
  198. package/lib/chunk-3OVTKRS4.mjs +0 -7
  199. package/lib/chunk-4GCYGQXD.mjs +0 -7
  200. package/lib/chunk-4JKR4PTZ.mjs +0 -8
  201. package/lib/chunk-5OGNK3JP.mjs +0 -37
  202. package/lib/chunk-6QSHWIZI.mjs +0 -48
  203. package/lib/chunk-77IVKH7R.mjs +0 -7
  204. package/lib/chunk-77MZRBWX.mjs +0 -7
  205. package/lib/chunk-7WSQ65WG.mjs +0 -9
  206. package/lib/chunk-A32ISQ6M.mjs +0 -28
  207. package/lib/chunk-AG24QMSY.mjs +0 -7
  208. package/lib/chunk-BH76USTQ.mjs +0 -11
  209. package/lib/chunk-BZ24IAP5.mjs +0 -7
  210. package/lib/chunk-CN5HGFG4.mjs +0 -7
  211. package/lib/chunk-CTPLYUXA.mjs +0 -7
  212. package/lib/chunk-DIGUC7S4.mjs +0 -341
  213. package/lib/chunk-DSR2MSBH.mjs +0 -7
  214. package/lib/chunk-ETNQHIDI.mjs +0 -9
  215. package/lib/chunk-FBXH4VRQ.mjs +0 -7
  216. package/lib/chunk-FYWNSMOZ.mjs +0 -10
  217. package/lib/chunk-GEEWPTV5.mjs +0 -7
  218. package/lib/chunk-GTRU5AV5.mjs +0 -7
  219. package/lib/chunk-I3ZO76LL.mjs +0 -21
  220. package/lib/chunk-ISA2NYJV.mjs +0 -7
  221. package/lib/chunk-IXIY6Q4M.mjs +0 -7
  222. package/lib/chunk-JAV6F6OA.mjs +0 -7
  223. package/lib/chunk-JYUMD357.mjs +0 -7
  224. package/lib/chunk-L47JCNP3.mjs +0 -7
  225. package/lib/chunk-LI2XNV7F.mjs +0 -7
  226. package/lib/chunk-LP2D3JJP.mjs +0 -7
  227. package/lib/chunk-LYOGCIYD.mjs +0 -925
  228. package/lib/chunk-N5UIE4IR.mjs +0 -7
  229. package/lib/chunk-O7GCCRPW.mjs +0 -7
  230. package/lib/chunk-OO24ZYYJ.mjs +0 -7
  231. package/lib/chunk-OS6HFJ7L.mjs +0 -7
  232. package/lib/chunk-P6WRYJN3.mjs +0 -7
  233. package/lib/chunk-PGRY365W.mjs +0 -7
  234. package/lib/chunk-PPGDAUEQ.mjs +0 -7
  235. package/lib/chunk-Q4PPI3KG.mjs +0 -7
  236. package/lib/chunk-QFTF2PGS.mjs +0 -21
  237. package/lib/chunk-QO4MPHZD.mjs +0 -7
  238. package/lib/chunk-QXB6U3ZP.mjs +0 -7
  239. package/lib/chunk-R3OM3X4L.mjs +0 -8
  240. package/lib/chunk-R7GKMAT4.mjs +0 -7
  241. package/lib/chunk-SCKUIE3R.mjs +0 -7
  242. package/lib/chunk-SU65Z2BA.mjs +0 -7
  243. package/lib/chunk-T7DDS4UQ.mjs +0 -7
  244. package/lib/chunk-TQJ5NPRC.mjs +0 -7
  245. package/lib/chunk-VZLJZEV2.mjs +0 -7
  246. package/lib/chunk-W3BQGMTR.mjs +0 -7
  247. package/lib/chunk-WXU6ZJIV.mjs +0 -7
  248. package/lib/chunk-X4HZD5U2.mjs +0 -7
  249. package/lib/chunk-X6XNTOGO.mjs +0 -7
  250. package/lib/chunk-XMQ5R6TC.mjs +0 -10
  251. package/lib/chunk-XPXEQKLR.mjs +0 -7
  252. package/lib/chunk-YBZIDW6W.mjs +0 -7
  253. package/lib/chunk-ZCOSME6P.mjs +0 -7
  254. package/lib/chunk-ZTHC42X6.mjs +0 -7
@@ -4,7 +4,7 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{g as ae,i as V}from"./chunk-I5C4O3VA.mjs";import{m as oe,o as ie}from"./chunk-EOQON3E5.mjs";import{B as q,H as ee,I as te,J as ne,L as re,d as M,k as B,s as W,t as E,u as Z,v as z,w as Q,z as j}from"./chunk-N2HYG3BL.mjs";import{$a as J,ab as U,bb as D}from"./chunk-6QSHWIZI.mjs";import{b as N,e as K,m as F,v as L}from"./chunk-WZQEK4WT.mjs";import{createCipheriv as Se,createDecipheriv as Ce,createHash as m,hkdfSync as Te,randomBytes as C,timingSafeEqual as Pe}from"node:crypto";import{createReadStream as He}from"node:fs";import{lstat as se,open as _,rename as _e,rm as $e,statfs as Ne}from"node:fs/promises";import{basename as de,dirname as le,join as ue}from"node:path";import{Readable as pe}from"node:stream";import{pipeline as ye}from"node:stream/promises";import{createGunzip as Ke,createGzip as Fe}from"node:zlib";var bt=".sfcheckpoint",De=1024*1024,Me=new Set([1]),ze=new Set([1,2]),$=32,O=16,je=4096,Ve=1024,Xe=64*1024*1024,me=2**32,ge="sandforge-checkpoint/1 block key",we="sandforge-checkpoint/1 key check",X="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",Ye=Math.ceil($*8/5),g="Nothing was imported.";function Bt(){return C($)}function At(n){if(n.length!==$)throw new RangeError("Not a key of a checkpoint file");let e="",t=0,r=0;for(let o of n)for(t=(t<<8|o)&65535,r+=8;r>=5;)e+=X[t>>>r-5&31],r-=5;return r>0&&(e+=X[t<<5-r&31]),(e.match(/.{1,4}/g)??[]).join("-")}function Et(n){let e=n.replace(/[\s-]/g,"").toUpperCase();if(e.length!==Ye||!/^[A-Z2-7]+$/.test(e))return;let t=Buffer.alloc($),r=0,o=0,i=0;for(let a of e)r=(r<<5|X.indexOf(a))&65535,o+=5,o>=8&&(t[i++]=r>>>o-8&255,o-=8);if((r&(1<<o)-1)===0)return t}function T(n,e,t,r){return Buffer.from(Te("sha256",n,e,t,r))}function ke(n,e){let t=Buffer.alloc(12);return n.copy(t,0),t.writeUInt32BE(e,8),t}function be(n,e,t){let r=Buffer.alloc(37);return n.copy(r,0),r.writeUInt32BE(e,32),r[36]=t?1:0,r}function Ge(n,e,t,r){let o=Se("aes-256-gcm",n.blockKey,ke(n.prefix,e),{authTagLength:O});return o.setAAD(be(n.headerHash,e,t)),Buffer.concat([o.update(r),o.final(),o.getAuthTag()])}function Le(n,e,t,r){let o=Ce("aes-256-gcm",n.blockKey,ke(n.prefix,e),{authTagLength:O});o.setAAD(be(n.headerHash,e,t)),o.setAuthTag(r.subarray(r.length-O));try{let i=o.update(r.subarray(0,r.length-O));return Buffer.concat([i,o.final()])}catch{return}}var P=class extends Error{constructor(t){super(t.message);this.refusal=t;this.name="ImportRefused"}refusal};function f(n){return new P({code:"IMPORT_DAMAGED",message:`This checkpoint file ${n}: it was changed or damaged after it was exported. ${g}`})}var I=class extends Error{constructor(t,r){super(r);this.code=t;this.name="CheckpointExportError"}code};function Je(n){return{...H(n,Be),org:H(n.org,Ae)}}var Be=["lastRewind","takenOn","expiresAt","bytes","importedFrom"],Ae=["alias"];function H(n,e){return Object.fromEntries(Object.entries(n).filter(([t])=>!e.includes(t)))}async function*Ee(n,e){if(e===0)return;let t=0;for await(let r of He(n,{start:0,end:e-1})){let o=r;t+=o.length,yield o}if(t!==e)throw new I("EXPORT_CHANGED",`${de(n)} of the checkpoint shrank while it was exported: export it again.`)}async function xe(n,e){let t=m("sha256");for await(let r of Ee(n,e))t.update(r);return t.digest("hex")}async function xt(n){let{folder:e,checkpoint:t,out:r,key:o}=n,i=n.chunkBytes??De;if(await se(r).catch(()=>{}))throw new I("EXPORT_EXISTS",`${r} is there already: name another file, or move that one away first.`);let a=Buffer.from(`${JSON.stringify(Je(t))}
7
+ import{g as ae,i as V}from"./chunk-24RFOFYT.mjs";import{m as oe,o as ie}from"./chunk-FP7CYB2F.mjs";import{B as q,H as ee,I as te,J as ne,L as re,d as M,k as B,s as W,t as E,u as Z,v as z,w as Q,z as j}from"./chunk-KGU4SVIT.mjs";import{$a as J,ab as U,bb as D}from"./chunk-PMWAFDUB.mjs";import{b as N,e as K,m as F,v as L}from"./chunk-WZQEK4WT.mjs";import{createCipheriv as Se,createDecipheriv as Ce,createHash as m,hkdfSync as Te,randomBytes as C,timingSafeEqual as Pe}from"node:crypto";import{createReadStream as He}from"node:fs";import{lstat as se,open as _,rename as _e,rm as $e,statfs as Ne}from"node:fs/promises";import{basename as de,dirname as le,join as ue}from"node:path";import{Readable as pe}from"node:stream";import{pipeline as ye}from"node:stream/promises";import{createGunzip as Ke,createGzip as Fe}from"node:zlib";var bt=".sfcheckpoint",De=1024*1024,Me=new Set([1]),ze=new Set([1,2]),$=32,O=16,je=4096,Ve=1024,Xe=64*1024*1024,me=2**32,ge="sandforge-checkpoint/1 block key",we="sandforge-checkpoint/1 key check",X="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",Ye=Math.ceil($*8/5),g="Nothing was imported.";function Bt(){return C($)}function At(n){if(n.length!==$)throw new RangeError("Not a key of a checkpoint file");let e="",t=0,r=0;for(let o of n)for(t=(t<<8|o)&65535,r+=8;r>=5;)e+=X[t>>>r-5&31],r-=5;return r>0&&(e+=X[t<<5-r&31]),(e.match(/.{1,4}/g)??[]).join("-")}function Et(n){let e=n.replace(/[\s-]/g,"").toUpperCase();if(e.length!==Ye||!/^[A-Z2-7]+$/.test(e))return;let t=Buffer.alloc($),r=0,o=0,i=0;for(let a of e)r=(r<<5|X.indexOf(a))&65535,o+=5,o>=8&&(t[i++]=r>>>o-8&255,o-=8);if((r&(1<<o)-1)===0)return t}function T(n,e,t,r){return Buffer.from(Te("sha256",n,e,t,r))}function ke(n,e){let t=Buffer.alloc(12);return n.copy(t,0),t.writeUInt32BE(e,8),t}function be(n,e,t){let r=Buffer.alloc(37);return n.copy(r,0),r.writeUInt32BE(e,32),r[36]=t?1:0,r}function Ge(n,e,t,r){let o=Se("aes-256-gcm",n.blockKey,ke(n.prefix,e),{authTagLength:O});return o.setAAD(be(n.headerHash,e,t)),Buffer.concat([o.update(r),o.final(),o.getAuthTag()])}function Le(n,e,t,r){let o=Ce("aes-256-gcm",n.blockKey,ke(n.prefix,e),{authTagLength:O});o.setAAD(be(n.headerHash,e,t)),o.setAuthTag(r.subarray(r.length-O));try{let i=o.update(r.subarray(0,r.length-O));return Buffer.concat([i,o.final()])}catch{return}}var P=class extends Error{constructor(t){super(t.message);this.refusal=t;this.name="ImportRefused"}refusal};function f(n){return new P({code:"IMPORT_DAMAGED",message:`This checkpoint file ${n}: it was changed or damaged after it was exported. ${g}`})}var I=class extends Error{constructor(t,r){super(r);this.code=t;this.name="CheckpointExportError"}code};function Je(n){return{...H(n,Be),org:H(n.org,Ae)}}var Be=["lastRewind","takenOn","expiresAt","bytes","importedFrom"],Ae=["alias"];function H(n,e){return Object.fromEntries(Object.entries(n).filter(([t])=>!e.includes(t)))}async function*Ee(n,e){if(e===0)return;let t=0;for await(let r of He(n,{start:0,end:e-1})){let o=r;t+=o.length,yield o}if(t!==e)throw new I("EXPORT_CHANGED",`${de(n)} of the checkpoint shrank while it was exported: export it again.`)}async function xe(n,e){let t=m("sha256");for await(let r of Ee(n,e))t.update(r);return t.digest("hex")}async function xt(n){let{folder:e,checkpoint:t,out:r,key:o}=n,i=n.chunkBytes??De;if(await se(r).catch(()=>{}))throw new I("EXPORT_EXISTS",`${r} is there already: name another file, or move that one away first.`);let a=Buffer.from(`${JSON.stringify(Je(t))}
8
8
  `,"utf8"),s=[{path:E,bytes:a.length,sha256:m("sha256").update(a).digest("hex"),content:a}];for(let u of await z(e))u.path!==E&&s.push({...u,sha256:await xe(u.file,u.bytes)});let h=s.some(u=>u.path===W);h&&await V(e);let c=C(32),d=C(8),{dataStorageMaxMB:l,staging:p}=t.org,v={format:"sandforge-checkpoint",formatVersion:h?2:1,checkpointFormat:1,sandforgeVersion:n.sandforgeVersion,organizationId:B(t.org.organizationId),orgTier:t.org.tier,...l!==void 0?{dataStorageMaxMB:l}:{},...p===!0?{staging:p}:{},checkpointId:t.checkpointId,takenAt:t.takenAt,records:Ie(t),objects:t.objects.length,files:s.length,bytes:s.reduce((u,b)=>u+b.bytes,0),cipher:"aes-256-gcm",kdf:"hkdf-sha256",salt:c.toString("hex"),noncePrefix:d.toString("hex"),keyCheck:T(o,c,we,16).toString("hex"),chunkBytes:i},R=Buffer.from(`${JSON.stringify(D.parse(v))}
9
9
  `),w={blockKey:T(o,c,ge,32),prefix:d,headerHash:m("sha256").update(R).digest()},S=ue(le(r),`.${de(r)}.${process.pid}-${C(4).toString("hex")}.tmp`),y=m("sha256"),k=0,A=await _(S,"wx",M);try{try{let u=async b=>{y.update(b),k+=b.length,await Oe(A,b)};await u(R),await ye(pe.from(Ue(s)),Fe({level:6}),async b=>{await We(b,i,w,u)}),await A.sync()}finally{await A.close()}if(await se(r).catch(()=>{}))throw new I("EXPORT_EXISTS",`${r} appeared while the checkpoint was exported: name another file.`);await _e(S,r)}catch(u){throw await $e(S,{force:!0}),u}return{header:v,bytes:k,sha256:y.digest("hex")}}async function Oe(n,e){for(let t=0;t<e.length;){let{bytesWritten:r}=await n.write(e,t,e.length-t);t+=r}}function Ie(n){return n.objects.reduce((e,t)=>e+t.records,0)}async function*Ue(n){for(let e of n){let{path:t,bytes:r,sha256:o}=e;if(yield Buffer.from(`${JSON.stringify({path:t,bytes:r,sha256:o})}
10
10
  `,"utf8"),e.content!==void 0){yield e.content;continue}let i=m("sha256");for await(let a of Ee(e.file??"",r))i.update(a),yield a;if(i.digest("hex")!==o)throw new I("EXPORT_CHANGED",`${t} of the checkpoint changed while it was exported: export it again.`)}yield Buffer.from(`${JSON.stringify({end:!0,files:n.length})}
@@ -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-XAUQXYPW.mjs";import"./chunk-FVLFO2S6.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as FieldMapper,b as generateValue};
7
+ import{a,b}from"./chunk-6YL7BNYD.mjs";import"./chunk-BBRWFKS5.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as FieldMapper,b as generateValue};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a as A}from"./chunk-5LFSFYFJ.mjs";import{a as z,h as p}from"./chunk-TZE3Y7IQ.mjs";import{b as S}from"./chunk-CA5NAXSU.mjs";import{vc as C}from"./chunk-6QSHWIZI.mjs";import{b as g,f as b,k as w,l as m,o as j}from"./chunk-WZQEK4WT.mjs";function H(r,n){return{describe:e=>r.describe(e),describeGlobal:()=>r.describeGlobal(),query:async e=>{let t=await r.query(e);return A(r.limitInfo,n),{totalSize:t.totalSize,records:t.records}},update:(e,t)=>r.sobject(e).update(t,{headers:C()}),destroy:(e,t)=>r.sobject(e).destroy(t)}}var u=200,P=30,I=100,M=4,y=10,q=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function B(r){return typeof r=="string"&&q.test(r)}function k(r,n=u){let e=[];for(let t=0;t<r.length;t+=n)e.push(r.slice(t,t+n).map(s=>`'${z(s)}'`).join(", "));return e}var L=m({success:b(),id:g().nullish(),errors:w(j([m({message:g()}).loose(),g()])).optional()}).loose(),W=m({name:g(),label:g(),queryable:b().optional(),createable:b().optional(),layoutable:b().optional()}).loose(),_=m({sobjects:w(W)}).loose();async function F(r){let n=_.parse(await r.describeGlobal());return new Map(n.sobjects.filter(e=>e.queryable===!0&&e.createable===!0&&e.layoutable===!0).map(e=>[e.name,e.label]))}async function E(r,n){let e=new Array(r.length),t=0,s=async()=>{for(;t<r.length;){let i=t++;e[i]=await r[i]()}};return await Promise.all(Array.from({length:Math.min(n,r.length)},s)),e}async function Q(r,n,e,t){if(e.length===0)return{related:[],uncounted:[]};let s=(n.childRelationships??[]).filter(o=>o.cascadeDelete===!0&&t.has(o.childSObject)),i=s.slice(0,P),a=new Set(s.slice(P).map(o=>t.get(o.childSObject)??o.childSObject)),l=k(e),h=await E(i.map(o=>async()=>{try{let c=p(o.childSObject),d=p(o.field),O=0;for(let T of l)O+=(await r.query(`SELECT COUNT() FROM ${c} WHERE ${d} IN (${T})`)).totalSize;return{relationship:o,records:O}}catch{return{relationship:o,records:null}}}),M),f=new Map;for(let{relationship:o,records:c}of h){let d=t.get(o.childSObject)??o.childSObject;if(c===null){a.add(d);continue}f.set(o.childSObject,(f.get(o.childSObject)??0)+c)}return{related:[...f].filter(([,o])=>o>0).map(([o,c])=>({objectApiName:o,label:t.get(o)??o,records:c})).sort((o,c)=>c.records-o.records||o.label.localeCompare(c.label)),uncounted:[...a].sort()}}async function Z(r,n,e,t,s=1){let i=p(n),a=[...new Set(["Id",...e])].map(p),l=a.join(", "),h=a.length>I?u/4:u,f=await E(k(t,h).map(o=>()=>r.query(`SELECT ${l} FROM ${i} WHERE Id IN (${o})`)),s),R=[];for(let o of f)for(let c of o.records){if(typeof c!="object"||c===null)continue;let d={...c};delete d.attributes,R.push(d)}return R}function x(r,n,e){let t=Array.isArray(r)?r:[r];for(let s of t){let i=L.safeParse(s);if(i.success&&i.data.success){e.done++;continue}if(e.failed++,e.errors.length<y){let a=i.success?i.data.errors?.[0]:void 0,l=typeof a=="string"?a:a?.message??"The org gave no reason.";e.errors.push({objectApiName:n,message:l})}}}async function J(r,n,e,t){let s={done:0,failed:0,errors:[]};for(let i=0;i<e.length&&!t?.aborted;i+=u){let a=e.slice(i,i+u);try{x(await r.update(n,[...a]),n,s)}catch(l){s.failed+=a.length,s.errors.length<y&&s.errors.push({objectApiName:n,message:S(l)})}}return s}async function V(r,n,e,t){let s={done:0,failed:0,errors:[]};for(let i=0;i<e.length&&!t?.aborted;i+=u){let a=e.slice(i,i+u);try{x(await r.destroy(n,[...a]),n,s)}catch(l){s.failed+=a.length,s.errors.length<y&&s.errors.push({objectApiName:n,message:S(l)})}}return s}function D(r,n){return n===0?"success":r===0?"failure":"partial"}function Y(r){let n=r.reduce((t,s)=>t+s.counts.done,0),e=r.reduce((t,s)=>t+s.counts.failed,0);return{status:D(n,e),done:n,failed:e,objects:r.map(t=>({objectApiName:t.objectApiName,done:t.counts.done,failed:t.counts.failed})),errors:r.flatMap(t=>t.counts.errors).slice(0,y)}}export{H as a,u as b,B as c,k as d,F as e,E as f,Q as g,Z as h,J as i,V as j,Y as k};
7
+ import{a as A}from"./chunk-5LFSFYFJ.mjs";import{a as z,h as p}from"./chunk-TZE3Y7IQ.mjs";import{b as S}from"./chunk-CA5NAXSU.mjs";import{vc as C}from"./chunk-PMWAFDUB.mjs";import{b as g,f as b,k as w,l as m,o as j}from"./chunk-WZQEK4WT.mjs";function H(r,n){return{describe:e=>r.describe(e),describeGlobal:()=>r.describeGlobal(),query:async e=>{let t=await r.query(e);return A(r.limitInfo,n),{totalSize:t.totalSize,records:t.records}},update:(e,t)=>r.sobject(e).update(t,{headers:C()}),destroy:(e,t)=>r.sobject(e).destroy(t)}}var u=200,P=30,I=100,M=4,y=10,q=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function B(r){return typeof r=="string"&&q.test(r)}function k(r,n=u){let e=[];for(let t=0;t<r.length;t+=n)e.push(r.slice(t,t+n).map(s=>`'${z(s)}'`).join(", "));return e}var L=m({success:b(),id:g().nullish(),errors:w(j([m({message:g()}).loose(),g()])).optional()}).loose(),W=m({name:g(),label:g(),queryable:b().optional(),createable:b().optional(),layoutable:b().optional()}).loose(),_=m({sobjects:w(W)}).loose();async function F(r){let n=_.parse(await r.describeGlobal());return new Map(n.sobjects.filter(e=>e.queryable===!0&&e.createable===!0&&e.layoutable===!0).map(e=>[e.name,e.label]))}async function E(r,n){let e=new Array(r.length),t=0,s=async()=>{for(;t<r.length;){let i=t++;e[i]=await r[i]()}};return await Promise.all(Array.from({length:Math.min(n,r.length)},s)),e}async function Q(r,n,e,t){if(e.length===0)return{related:[],uncounted:[]};let s=(n.childRelationships??[]).filter(o=>o.cascadeDelete===!0&&t.has(o.childSObject)),i=s.slice(0,P),a=new Set(s.slice(P).map(o=>t.get(o.childSObject)??o.childSObject)),l=k(e),h=await E(i.map(o=>async()=>{try{let c=p(o.childSObject),d=p(o.field),O=0;for(let T of l)O+=(await r.query(`SELECT COUNT() FROM ${c} WHERE ${d} IN (${T})`)).totalSize;return{relationship:o,records:O}}catch{return{relationship:o,records:null}}}),M),f=new Map;for(let{relationship:o,records:c}of h){let d=t.get(o.childSObject)??o.childSObject;if(c===null){a.add(d);continue}f.set(o.childSObject,(f.get(o.childSObject)??0)+c)}return{related:[...f].filter(([,o])=>o>0).map(([o,c])=>({objectApiName:o,label:t.get(o)??o,records:c})).sort((o,c)=>c.records-o.records||o.label.localeCompare(c.label)),uncounted:[...a].sort()}}async function Z(r,n,e,t,s=1){let i=p(n),a=[...new Set(["Id",...e])].map(p),l=a.join(", "),h=a.length>I?u/4:u,f=await E(k(t,h).map(o=>()=>r.query(`SELECT ${l} FROM ${i} WHERE Id IN (${o})`)),s),R=[];for(let o of f)for(let c of o.records){if(typeof c!="object"||c===null)continue;let d={...c};delete d.attributes,R.push(d)}return R}function x(r,n,e){let t=Array.isArray(r)?r:[r];for(let s of t){let i=L.safeParse(s);if(i.success&&i.data.success){e.done++;continue}if(e.failed++,e.errors.length<y){let a=i.success?i.data.errors?.[0]:void 0,l=typeof a=="string"?a:a?.message??"The org gave no reason.";e.errors.push({objectApiName:n,message:l})}}}async function J(r,n,e,t){let s={done:0,failed:0,errors:[]};for(let i=0;i<e.length&&!t?.aborted;i+=u){let a=e.slice(i,i+u);try{x(await r.update(n,[...a]),n,s)}catch(l){s.failed+=a.length,s.errors.length<y&&s.errors.push({objectApiName:n,message:S(l)})}}return s}async function V(r,n,e,t){let s={done:0,failed:0,errors:[]};for(let i=0;i<e.length&&!t?.aborted;i+=u){let a=e.slice(i,i+u);try{x(await r.destroy(n,[...a]),n,s)}catch(l){s.failed+=a.length,s.errors.length<y&&s.errors.push({objectApiName:n,message:S(l)})}}return s}function D(r,n){return n===0?"success":r===0?"failure":"partial"}function Y(r){let n=r.reduce((t,s)=>t+s.counts.done,0),e=r.reduce((t,s)=>t+s.counts.failed,0);return{status:D(n,e),done:n,failed:e,objects:r.map(t=>({objectApiName:t.objectApiName,done:t.counts.done,failed:t.counts.failed})),errors:r.flatMap(t=>t.counts.errors).slice(0,y)}}export{H as a,u as b,B as c,k as d,F as e,E as f,Q as g,Z as h,J as i,V as j,Y as k};
@@ -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 b}from"./chunk-HUZPBE47.mjs";import"./chunk-2WFIVO4F.mjs";import{a}from"./chunk-7QYHEHMA.mjs";import"./chunk-WXDLQT2O.mjs";import"./chunk-NSQWI7ZY.mjs";import"./chunk-GNRSF65U.mjs";import"./chunk-O677VOGO.mjs";import"./chunk-JE6SCT6R.mjs";import"./chunk-PWRJRL5U.mjs";import"./chunk-24RFOFYT.mjs";import"./chunk-UIOMAX56.mjs";import"./chunk-QAFPQ3YB.mjs";import"./chunk-KJWFYBMU.mjs";import"./chunk-Z4LKKOFY.mjs";import"./chunk-2HVOZUM4.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-WB2RIVO3.mjs";import"./chunk-XGGOUNPP.mjs";import"./chunk-L53JWJ3S.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-OFTT7J2M.mjs";import"./chunk-HIDW7FNV.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-VINGECAJ.mjs";import"./chunk-H4CGM6YO.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-YDXMTWAT.mjs";import"./chunk-QIRO4HTE.mjs";import"./chunk-PMN4PAC3.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-FP7CYB2F.mjs";import"./chunk-NED4MBIM.mjs";import"./chunk-UI3JQVRU.mjs";import"./chunk-KGU4SVIT.mjs";import"./chunk-JAEDM4SI.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-MSIEU5MR.mjs";import"./chunk-LC3NDW4N.mjs";import"./chunk-KB4ZHM4Q.mjs";import"./chunk-23SEDORH.mjs";import"./chunk-W6PN6TJG.mjs";import"./chunk-3Q353S2R.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-RHNTHGNU.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-Q7TLC3I2.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-D4GF4FAB.mjs";import"./chunk-CVHNXJH3.mjs";import"./chunk-YA6ATMTB.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-M6K34KGF.mjs";import"./chunk-TNT27RBG.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-S42RBRH2.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-WUUKFE2U.mjs";import"./chunk-EAC5QCE3.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as objectsWrittenBy,b as previewCheckpoint};
@@ -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{g as v}from"./chunk-Z3MGN42K.mjs";var x=!0;function D(t){let e=new Map;for(let n of t){let r=n.SobjectType;if(typeof r!="string"||r==="")continue;let o=r.toLowerCase(),c=e.get(o)??{viewAll:!1,modifyAll:!1};e.set(o,{viewAll:c.viewAll||n.PermissionsViewAllRecords===!0,modifyAll:c.modifyAll||n.PermissionsModifyAllRecords===!0})}return e}function E(t){return[...t.values()].some(e=>e.modifyAll)}var I=new Set(["task","event"]),M=new Set(["product2","pricebook2","pricebookentry"]),N=new Set(["user","group"]);function L(t){let e=[];for(let n of t.fields){if(n.type!=="reference")continue;let r=(n.referenceTo??[]).filter(o=>!N.has(o.toLowerCase()));r.length>0&&e.push({field:n.name,targets:r})}return e}function R(t,e){if(I.has(t))return"activities";if(M.has(t))return"catalog";if(t===v.toLowerCase())return"filesNotProven";if(e.has(t))return"settingNotProven"}function G(t,e){let n=j(e.describes),r=k(e.customSettings),o=new Map;for(let c of t){let f=c.toLowerCase();if(R(f,r)!==void 0||e.grants.has(f))continue;let u=n.get(f);if(u!==void 0)for(let{targets:p}of L(u)){if(p.length!==1)continue;let s=p[0],i=s.toLowerCase();!n.has(i)&&!o.has(i)&&o.set(i,s)}}return[...o.values()]}function j(t){return new Map([...t].map(e=>[e.name.toLowerCase(),e]))}function k(t){return new Set([...t??[]].map(e=>e.toLowerCase()))}function P(t,e,n){return(t.childRelationships??[]).some(r=>r.cascadeDelete===!0&&r.childSObject.toLowerCase()===e&&r.field.toLowerCase()===n.toLowerCase())}function $(t,e,n={}){let r=n.byParent??x,o=j(e.describes),c=k(e.customSettings),f=new Map,u=(s,i)=>{let d=s.toLowerCase(),C=f.get(d);if(C!==void 0)return C;let m=R(d,c);if(m!==void 0)return{reason:m};let h=e.grants.get(d);if(h!==void 0)return h.modifyAll?{access:"object"}:{reason:h.viewAll?"noModifyAll":"noViewAll"};if(!r)return{reason:"parentNotSeen",detail:"held through its parents is not proven"};let A=o.get(d);if(A===void 0)return{reason:"parentNotSeen",detail:"it could not be described"};let w=[];for(let{field:l,targets:a}of L(A)){let b=a.filter(y=>!o.has(y.toLowerCase())),g=a.filter(y=>{let S=o.get(y.toLowerCase());return S!==void 0&&P(S,d,l)});if(a.length>1){if(g.length>0||b.length>0)return{reason:"parentNotSeen",detail:`${l} may name a record of ${a.join(", ")}`};continue}if(b.length>0)return{reason:"parentNotSeen",detail:`${b[0]}, which ${l} names, could not be described`};g.length>0&&w.push({field:l,parent:g[0]})}if(w.length===0)return{reason:"parentNotSeen",detail:"it hangs from no record whose delete takes it along"};let O=new Set([...i,d]);for(let{field:l,parent:a}of w){let b=a.toLowerCase(),g=O.has(b)?void 0:u(a,O);if(g===void 0||!("access"in g))return{reason:"parentNotSeen",detail:`${a}, which ${l} names, is not held whole`}}return{access:"parent"}},p=new Map;for(let s of t){let i=u(s,new Set);f.set(s.toLowerCase(),i),p.set(s,i)}return p}export{D as a,E as b,G as c,$ as d};
7
+ import{g as v}from"./chunk-M6K34KGF.mjs";var x=!0;function D(t){let e=new Map;for(let n of t){let r=n.SobjectType;if(typeof r!="string"||r==="")continue;let o=r.toLowerCase(),c=e.get(o)??{viewAll:!1,modifyAll:!1};e.set(o,{viewAll:c.viewAll||n.PermissionsViewAllRecords===!0,modifyAll:c.modifyAll||n.PermissionsModifyAllRecords===!0})}return e}function E(t){return[...t.values()].some(e=>e.modifyAll)}var I=new Set(["task","event"]),M=new Set(["product2","pricebook2","pricebookentry"]),N=new Set(["user","group"]);function L(t){let e=[];for(let n of t.fields){if(n.type!=="reference")continue;let r=(n.referenceTo??[]).filter(o=>!N.has(o.toLowerCase()));r.length>0&&e.push({field:n.name,targets:r})}return e}function R(t,e){if(I.has(t))return"activities";if(M.has(t))return"catalog";if(t===v.toLowerCase())return"filesNotProven";if(e.has(t))return"settingNotProven"}function G(t,e){let n=j(e.describes),r=k(e.customSettings),o=new Map;for(let c of t){let f=c.toLowerCase();if(R(f,r)!==void 0||e.grants.has(f))continue;let u=n.get(f);if(u!==void 0)for(let{targets:p}of L(u)){if(p.length!==1)continue;let s=p[0],i=s.toLowerCase();!n.has(i)&&!o.has(i)&&o.set(i,s)}}return[...o.values()]}function j(t){return new Map([...t].map(e=>[e.name.toLowerCase(),e]))}function k(t){return new Set([...t??[]].map(e=>e.toLowerCase()))}function P(t,e,n){return(t.childRelationships??[]).some(r=>r.cascadeDelete===!0&&r.childSObject.toLowerCase()===e&&r.field.toLowerCase()===n.toLowerCase())}function $(t,e,n={}){let r=n.byParent??x,o=j(e.describes),c=k(e.customSettings),f=new Map,u=(s,i)=>{let d=s.toLowerCase(),C=f.get(d);if(C!==void 0)return C;let m=R(d,c);if(m!==void 0)return{reason:m};let h=e.grants.get(d);if(h!==void 0)return h.modifyAll?{access:"object"}:{reason:h.viewAll?"noModifyAll":"noViewAll"};if(!r)return{reason:"parentNotSeen",detail:"held through its parents is not proven"};let A=o.get(d);if(A===void 0)return{reason:"parentNotSeen",detail:"it could not be described"};let w=[];for(let{field:l,targets:a}of L(A)){let b=a.filter(y=>!o.has(y.toLowerCase())),g=a.filter(y=>{let S=o.get(y.toLowerCase());return S!==void 0&&P(S,d,l)});if(a.length>1){if(g.length>0||b.length>0)return{reason:"parentNotSeen",detail:`${l} may name a record of ${a.join(", ")}`};continue}if(b.length>0)return{reason:"parentNotSeen",detail:`${b[0]}, which ${l} names, could not be described`};g.length>0&&w.push({field:l,parent:g[0]})}if(w.length===0)return{reason:"parentNotSeen",detail:"it hangs from no record whose delete takes it along"};let O=new Set([...i,d]);for(let{field:l,parent:a}of w){let b=a.toLowerCase(),g=O.has(b)?void 0:u(a,O);if(g===void 0||!("access"in g))return{reason:"parentNotSeen",detail:`${a}, which ${l} names, is not held whole`}}return{access:"parent"}},p=new Map;for(let s of t){let i=u(s,new Set);f.set(s.toLowerCase(),i),p.set(s,i)}return p}export{D as a,E as b,G as c,$ as d};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a as O,b as T,c as k}from"./chunk-S4PRKKGC.mjs";import{a as A,b as S,c as l,d as w,e as y,h as J,i as F}from"./chunk-H33DVU3D.mjs";import{c as R}from"./chunk-WXU6ZJIV.mjs";import{Fb as x}from"./chunk-6QSHWIZI.mjs";var $="SELECT CronJobDetail.Name, CronJobDetail.JobType, CronExpression, State, NextFireTime, PreviousFireTime, OwnerId FROM CronTrigger",C={0:"Data Export",3:"Dashboard Refresh",4:"Reporting Snapshot",7:"Scheduled Apex",8:"Report Run",9:"Batch Job",A:"Analytics Notification"},M=new Set(["COMPLETE","DELETED"]),z=200,_=/^005[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/;function q(n){return n===void 0?"job of no type":C[n]??`job type ${n}`}function P(n){let e=[];for(let t=0;t<n.length;t+=z)e.push(n.slice(t,t+z));return e}function g(n){return n.slice(0,15)}async function j(n){let e;try{e=await n.query($)}catch(s){return{unread:A(s,n.timeout)}}let t=[];for(let s of e.records){let r=s.CronJobDetail,o=typeof r=="object"&&r!==null?r:{},f=l(o,"Name"),a=l(s,"State");if(f===void 0||a===void 0)continue;let c=l(s,"CronExpression"),E=y(s.NextFireTime),I=y(s.PreviousFireTime),m=l(s,"OwnerId");t.push({job:{name:f.slice(0,255),type:q(l(o,"JobType")),...c!==void 0?{cronExpression:c.slice(0,255)}:{},state:a.slice(0,40),...E!==void 0?{nextFireTime:E}:{},...I!==void 0?{previousFireTime:I}:{}},...m!==void 0&&_.test(m)?{ownerId:m}:{}})}let u=[...new Set(t.flatMap(s=>s.ownerId!==void 0&&b(s.job)?[g(s.ownerId)]:[]))],i=new Map,d;try{for(let s of P(u)){let r=s.map(a=>`'${a}'`).join(", "),o=await n.query(`SELECT Id, Username, IsActive FROM User WHERE Id IN (${r})`);for(let a of o.records){let c=l(a,"Id");c!==void 0&&i.set(g(c),{...i.get(g(c)),username:l(a,"Username"),active:w(a,"IsActive")})}let f=await n.query(`SELECT UserId, IsFrozen FROM UserLogin WHERE UserId IN (${r})`);for(let a of f.records){let c=l(a,"UserId");c!==void 0&&i.set(g(c),{...i.get(g(c)),frozen:w(a,"IsFrozen")})}}}catch(s){d=A(s,n.timeout)}return{jobs:t.map(({job:s,ownerId:r})=>{let o=r!==void 0?i.get(g(r)):void 0;return{...s,...o?.username!==void 0?{owner:o.username.slice(0,255)}:{},...o?.active!==void 0?{ownerActive:o.active}:{},...o?.frozen!==void 0?{ownerFrozen:o.frozen}:{}}}),truncated:e.truncated,...d!==void 0?{ownersUnread:d}:{}}}function b(n){return!M.has(n.state.toUpperCase())}function h(n){return`${n.type}\0${n.name}`}function U(n,e){return{version:1,savedAt:e.savedAt,organizationId:e.organizationId,host:e.host,jobs:n.map(t=>({name:t.name,type:t.type,...t.cronExpression!==void 0?{cronExpression:t.cronExpression}:{},state:t.state,...t.nextFireTime!==void 0?{nextFireTime:t.nextFireTime}:{},...t.previousFireTime!==void 0?{previousFireTime:t.previousFireTime}:{},...t.owner!==void 0?{owner:t.owner}:{}}))}}function v(n,e){return{status:n,name:e.name,type:e.type,...e.cronExpression!==void 0?{cronExpression:e.cronExpression}:{},...e.owner!==void 0?{owner:e.owner}:{},...e.nextFireTime!==void 0?{nextFireTime:e.nextFireTime}:{}}}var D=["gone","inactive","frozen","new"];function N(n,e){let t=n.jobs.filter(b),u=e?.kept.inventory.jobs.filter(b)??[],i=new Map;for(let r of u)i.set(h(r),(i.get(h(r))??0)+1);let d=[],p=0;for(let r of t){let o=h(r),f=(i.get(o)??0)>0;f&&i.set(o,(i.get(o)??0)-1),r.ownerActive===!1?d.push(v("inactive",r)):r.ownerFrozen===!0?d.push(v("frozen",r)):e!==void 0&&!f?d.push(v("new",r)):p++}if(e!==void 0&&!n.truncated)for(let r of u){let o=h(r);(i.get(o)??0)!==0&&(i.set(o,(i.get(o)??0)-1),d.push(v("gone",r)))}d.sort((r,o)=>D.indexOf(r.status)-D.indexOf(o.status)||r.name.localeCompare(o.name));let s=[n.truncated?`more jobs than ${n.jobs.length} were there: those past them were not read, and none is said gone`:void 0,n.ownersUnread!==void 0?`the users the jobs run as could not be read (${n.ownersUnread}): a job run as a frozen or inactive user is not told`:void 0].filter(r=>r!==void 0);return{now:t.length,...e!==void 0?{against:{savedAt:e.kept.inventory.savedAt,organizationId:e.kept.inventory.organizationId,refreshed:e.refreshed}}:{},jobs:d,kept:p,...s.length>0?{unread:s.join("; ")}:{}}}function V(n,e){let t=d=>typeof d=="object"?{productionHosts:d.productionHosts??[],fields:d.fields??[]}:{productionHosts:[],fields:[]};if(e==="verb")return{deliverability:!0,schedules:n?.schedules!==!1,endpoints:n?.endpoints===!1?!1:t(n?.endpoints)};let u=n?.schedules===!0,i=n?.endpoints!==void 0&&n.endpoints!==!1?t(n.endpoints):!1;if(!(!u&&i===!1))return{deliverability:!0,schedules:u,endpoints:i}}function X(n){let e=0,t=0;if(n.deliverability&&(e+=1,t+=2),n.schedules&&(e+=1,t+=3),n.endpoints!==!1){let u=J(n.endpoints.fields);e+=u,t+=u}return{fewest:e,most:t}}function H(n){let e=(n.schedules?.jobs??[]).filter(i=>i.status!=="new").length,t=n.endpoints?.found.length??0,u=n.deliverability?.read==="open"?1:0;return e+t+u}async function ee(n,e){let t=(n.now??(()=>new Date))(),u=new S(n.transport,{...n.timeoutMs!==void 0?{timeoutMs:n.timeoutMs}:{}}),i=[],d,p=!1,s={org:{organizationId:e.org.organizationId,kind:e.org.kind,...e.org.alias!==void 0?{alias:e.org.alias}:{},...e.org.host!==void 0?{host:e.org.host}:{}},at:t.toISOString()};if(e.asked.deliverability){let o=await R(u.asTransport(),{timeoutMs:u.timeout}).catch(f=>({reading:{unread:f instanceof Error?f.message:String(f)},requests:0}));s.deliverability="unread"in o.reading?{unread:o.reading.unread.slice(0,2e3)}:{read:o.reading.level==="all"?"open":"closed"}}if(e.asked.schedules){let o=await j(u);if("unread"in o)s.schedules={now:0,jobs:[],kept:0,unread:o.unread.slice(0,2e3)},e.save===!0&&(d="the scheduled jobs were not read");else{let f;if(e.org.host!==void 0){let a=await T(n.journalDir,e.org.host);for(let c of a.setAside)i.push(`inventory set aside: ${c.path}: ${c.why}`);a.unread!==void 0&&i.push(`no inventory read: ${a.unread}`),f=k(a.kept,e.org.organizationId)}if(s.schedules=N(o,f),e.save===!0)if(e.org.host===void 0)p=!0,d="the org's host is not known, and an inventory is kept by its host";else if(o.truncated)d="more jobs were there than were read: an inventory of part of them would have the next comparison call the others new";else try{let a=await O(n.journalDir,U(o.jobs,{savedAt:t.toISOString(),organizationId:e.org.organizationId,host:e.org.host}));s.schedules={...s.schedules,saved:a}}catch(a){p=!0,d=`it could not be written: ${a instanceof Error?a.message:String(a)}`}}}else e.save===!0&&(d="the file reads no scheduled jobs (audits.schedules: false)");return e.asked.endpoints!==!1&&(s.endpoints=await F(u,{...e.org.host!==void 0?{host:e.org.host}:{},productionHosts:e.asked.endpoints.productionHosts,fields:e.asked.endpoints.fields})),d!==void 0&&i.push(`nothing saved: ${d}`),{result:x.parse({...s,apiRequests:u.requests,findings:H(s)}),notes:i,...p&&d!==void 0?{saveFailed:d}:{}}}export{V as a,X as b,H as c,ee as d};
7
+ import{a as O,b as T,c as k}from"./chunk-L2E5WBGD.mjs";import{a as A,b as S,c as l,d as w,e as y,h as J,i as F}from"./chunk-H33DVU3D.mjs";import{c as R}from"./chunk-LC3NDW4N.mjs";import{Fb as x}from"./chunk-PMWAFDUB.mjs";var $="SELECT CronJobDetail.Name, CronJobDetail.JobType, CronExpression, State, NextFireTime, PreviousFireTime, OwnerId FROM CronTrigger",C={0:"Data Export",3:"Dashboard Refresh",4:"Reporting Snapshot",7:"Scheduled Apex",8:"Report Run",9:"Batch Job",A:"Analytics Notification"},M=new Set(["COMPLETE","DELETED"]),z=200,_=/^005[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/;function q(n){return n===void 0?"job of no type":C[n]??`job type ${n}`}function P(n){let e=[];for(let t=0;t<n.length;t+=z)e.push(n.slice(t,t+z));return e}function g(n){return n.slice(0,15)}async function j(n){let e;try{e=await n.query($)}catch(s){return{unread:A(s,n.timeout)}}let t=[];for(let s of e.records){let r=s.CronJobDetail,o=typeof r=="object"&&r!==null?r:{},f=l(o,"Name"),a=l(s,"State");if(f===void 0||a===void 0)continue;let c=l(s,"CronExpression"),E=y(s.NextFireTime),I=y(s.PreviousFireTime),m=l(s,"OwnerId");t.push({job:{name:f.slice(0,255),type:q(l(o,"JobType")),...c!==void 0?{cronExpression:c.slice(0,255)}:{},state:a.slice(0,40),...E!==void 0?{nextFireTime:E}:{},...I!==void 0?{previousFireTime:I}:{}},...m!==void 0&&_.test(m)?{ownerId:m}:{}})}let u=[...new Set(t.flatMap(s=>s.ownerId!==void 0&&b(s.job)?[g(s.ownerId)]:[]))],i=new Map,d;try{for(let s of P(u)){let r=s.map(a=>`'${a}'`).join(", "),o=await n.query(`SELECT Id, Username, IsActive FROM User WHERE Id IN (${r})`);for(let a of o.records){let c=l(a,"Id");c!==void 0&&i.set(g(c),{...i.get(g(c)),username:l(a,"Username"),active:w(a,"IsActive")})}let f=await n.query(`SELECT UserId, IsFrozen FROM UserLogin WHERE UserId IN (${r})`);for(let a of f.records){let c=l(a,"UserId");c!==void 0&&i.set(g(c),{...i.get(g(c)),frozen:w(a,"IsFrozen")})}}}catch(s){d=A(s,n.timeout)}return{jobs:t.map(({job:s,ownerId:r})=>{let o=r!==void 0?i.get(g(r)):void 0;return{...s,...o?.username!==void 0?{owner:o.username.slice(0,255)}:{},...o?.active!==void 0?{ownerActive:o.active}:{},...o?.frozen!==void 0?{ownerFrozen:o.frozen}:{}}}),truncated:e.truncated,...d!==void 0?{ownersUnread:d}:{}}}function b(n){return!M.has(n.state.toUpperCase())}function h(n){return`${n.type}\0${n.name}`}function U(n,e){return{version:1,savedAt:e.savedAt,organizationId:e.organizationId,host:e.host,jobs:n.map(t=>({name:t.name,type:t.type,...t.cronExpression!==void 0?{cronExpression:t.cronExpression}:{},state:t.state,...t.nextFireTime!==void 0?{nextFireTime:t.nextFireTime}:{},...t.previousFireTime!==void 0?{previousFireTime:t.previousFireTime}:{},...t.owner!==void 0?{owner:t.owner}:{}}))}}function v(n,e){return{status:n,name:e.name,type:e.type,...e.cronExpression!==void 0?{cronExpression:e.cronExpression}:{},...e.owner!==void 0?{owner:e.owner}:{},...e.nextFireTime!==void 0?{nextFireTime:e.nextFireTime}:{}}}var D=["gone","inactive","frozen","new"];function N(n,e){let t=n.jobs.filter(b),u=e?.kept.inventory.jobs.filter(b)??[],i=new Map;for(let r of u)i.set(h(r),(i.get(h(r))??0)+1);let d=[],p=0;for(let r of t){let o=h(r),f=(i.get(o)??0)>0;f&&i.set(o,(i.get(o)??0)-1),r.ownerActive===!1?d.push(v("inactive",r)):r.ownerFrozen===!0?d.push(v("frozen",r)):e!==void 0&&!f?d.push(v("new",r)):p++}if(e!==void 0&&!n.truncated)for(let r of u){let o=h(r);(i.get(o)??0)!==0&&(i.set(o,(i.get(o)??0)-1),d.push(v("gone",r)))}d.sort((r,o)=>D.indexOf(r.status)-D.indexOf(o.status)||r.name.localeCompare(o.name));let s=[n.truncated?`more jobs than ${n.jobs.length} were there: those past them were not read, and none is said gone`:void 0,n.ownersUnread!==void 0?`the users the jobs run as could not be read (${n.ownersUnread}): a job run as a frozen or inactive user is not told`:void 0].filter(r=>r!==void 0);return{now:t.length,...e!==void 0?{against:{savedAt:e.kept.inventory.savedAt,organizationId:e.kept.inventory.organizationId,refreshed:e.refreshed}}:{},jobs:d,kept:p,...s.length>0?{unread:s.join("; ")}:{}}}function V(n,e){let t=d=>typeof d=="object"?{productionHosts:d.productionHosts??[],fields:d.fields??[]}:{productionHosts:[],fields:[]};if(e==="verb")return{deliverability:!0,schedules:n?.schedules!==!1,endpoints:n?.endpoints===!1?!1:t(n?.endpoints)};let u=n?.schedules===!0,i=n?.endpoints!==void 0&&n.endpoints!==!1?t(n.endpoints):!1;if(!(!u&&i===!1))return{deliverability:!0,schedules:u,endpoints:i}}function X(n){let e=0,t=0;if(n.deliverability&&(e+=1,t+=2),n.schedules&&(e+=1,t+=3),n.endpoints!==!1){let u=J(n.endpoints.fields);e+=u,t+=u}return{fewest:e,most:t}}function H(n){let e=(n.schedules?.jobs??[]).filter(i=>i.status!=="new").length,t=n.endpoints?.found.length??0,u=n.deliverability?.read==="open"?1:0;return e+t+u}async function ee(n,e){let t=(n.now??(()=>new Date))(),u=new S(n.transport,{...n.timeoutMs!==void 0?{timeoutMs:n.timeoutMs}:{}}),i=[],d,p=!1,s={org:{organizationId:e.org.organizationId,kind:e.org.kind,...e.org.alias!==void 0?{alias:e.org.alias}:{},...e.org.host!==void 0?{host:e.org.host}:{}},at:t.toISOString()};if(e.asked.deliverability){let o=await R(u.asTransport(),{timeoutMs:u.timeout}).catch(f=>({reading:{unread:f instanceof Error?f.message:String(f)},requests:0}));s.deliverability="unread"in o.reading?{unread:o.reading.unread.slice(0,2e3)}:{read:o.reading.level==="all"?"open":"closed"}}if(e.asked.schedules){let o=await j(u);if("unread"in o)s.schedules={now:0,jobs:[],kept:0,unread:o.unread.slice(0,2e3)},e.save===!0&&(d="the scheduled jobs were not read");else{let f;if(e.org.host!==void 0){let a=await T(n.journalDir,e.org.host);for(let c of a.setAside)i.push(`inventory set aside: ${c.path}: ${c.why}`);a.unread!==void 0&&i.push(`no inventory read: ${a.unread}`),f=k(a.kept,e.org.organizationId)}if(s.schedules=N(o,f),e.save===!0)if(e.org.host===void 0)p=!0,d="the org's host is not known, and an inventory is kept by its host";else if(o.truncated)d="more jobs were there than were read: an inventory of part of them would have the next comparison call the others new";else try{let a=await O(n.journalDir,U(o.jobs,{savedAt:t.toISOString(),organizationId:e.org.organizationId,host:e.org.host}));s.schedules={...s.schedules,saved:a}}catch(a){p=!0,d=`it could not be written: ${a instanceof Error?a.message:String(a)}`}}}else e.save===!0&&(d="the file reads no scheduled jobs (audits.schedules: false)");return e.asked.endpoints!==!1&&(s.endpoints=await F(u,{...e.org.host!==void 0?{host:e.org.host}:{},productionHosts:e.asked.endpoints.productionHosts,fields:e.asked.endpoints.fields})),d!==void 0&&i.push(`nothing saved: ${d}`),{result:x.parse({...s,apiRequests:u.requests,findings:H(s)}),notes:i,...p&&d!==void 0?{saveFailed:d}:{}}}export{V as a,X as b,H as c,ee as d};
@@ -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{f as m,h as u}from"./chunk-TZE3Y7IQ.mjs";import{b as $}from"./chunk-CA5NAXSU.mjs";import{e as l}from"./chunk-6QSHWIZI.mjs";async function q(n,a,o,t){if(!Number.isInteger(t)||t<1||t>l.maxExistingParents)throw new Error(`A relation reads between 1 and ${l.maxExistingParents} existing records, not ${t}.`);let c=o?.trim()?` WHERE ${m(o.trim())}`:"",i=`SELECT Id FROM ${u(a)}${c} LIMIT ${t}`,r=[],e=await n.query(i);for(;;){for(let s of e.records)typeof s.Id=="string"&&r.push(s.Id);if(e.done||!e.nextRecordsUrl||r.length>=t)break;e=await n.queryMore(e.nextRecordsUrl)}return r.slice(0,t)}var w=200,E=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function R(n){return n.slice(0,15)}async function N(n,a,o){let t=u(a);for(let i of o)if(!E.test(i))throw new Error(`Not a record id: "${i}".`);let c=[];for(let i=0;i<o.length;i+=w){let r=o.slice(i,i+w).map(s=>`'${s}'`).join(", "),e=await n.query(`SELECT Id FROM ${t} WHERE Id IN (${r})`);for(;;){for(let s of e.records)typeof s.Id=="string"&&c.push(s.Id);if(e.done||!e.nextRecordsUrl)break;e=await n.queryMore(e.nextRecordsUrl)}}return c}function y(n){let a=n.slice(0,5).join(", ");return n.length>5?`${a}, and ${n.length-5} more`:a}async function b(n,a){let o=[];for(let t of n??[]){if(t.parents.kind!=="records")continue;let{childObject:c,lookupField:i,parentObject:r}=t,e=t.parents.ids,s=`${c}.${i}`,d;try{d=await a.keyPrefixOf?.(r)}catch{d=void 0}let f=d?e.filter(g=>g.slice(0,3)!==d):[];if(f.length>0){o.push(`The relation on ${s} names ${f.length} id(s) that are not ${r} ids \u2014 the org's ${r} ids start with ${d}: ${y(f)}. Nothing was written. Give the ids of ${r} records.`);continue}if(!a.presentIds){o.push(`This run cannot check that the ${e.length} ${r} record(s) the relation on ${s} names are in the org. Nothing was written.`);continue}let p;try{p=await a.presentIds(r,e)}catch(g){o.push(`Reading the ${r} records the relation on ${s} names failed (${$(g)}). Nothing was written.`);continue}let I=new Set(p.map(R)),h=e.filter(g=>!I.has(R(g)));h.length>0&&o.push(`${h.length} of the ${e.length} ${r} record(s) the relation on ${s} names are no longer in the org: ${y(h)}. Nothing was written. Run again what created them, or give the ids of ${r} records the org holds.`)}return o}export{q as a,w as b,N as c,b as d};
7
+ import{f as m,h as u}from"./chunk-TZE3Y7IQ.mjs";import{b as $}from"./chunk-CA5NAXSU.mjs";import{e as l}from"./chunk-PMWAFDUB.mjs";async function q(n,a,o,t){if(!Number.isInteger(t)||t<1||t>l.maxExistingParents)throw new Error(`A relation reads between 1 and ${l.maxExistingParents} existing records, not ${t}.`);let c=o?.trim()?` WHERE ${m(o.trim())}`:"",i=`SELECT Id FROM ${u(a)}${c} LIMIT ${t}`,r=[],e=await n.query(i);for(;;){for(let s of e.records)typeof s.Id=="string"&&r.push(s.Id);if(e.done||!e.nextRecordsUrl||r.length>=t)break;e=await n.queryMore(e.nextRecordsUrl)}return r.slice(0,t)}var w=200,E=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function R(n){return n.slice(0,15)}async function N(n,a,o){let t=u(a);for(let i of o)if(!E.test(i))throw new Error(`Not a record id: "${i}".`);let c=[];for(let i=0;i<o.length;i+=w){let r=o.slice(i,i+w).map(s=>`'${s}'`).join(", "),e=await n.query(`SELECT Id FROM ${t} WHERE Id IN (${r})`);for(;;){for(let s of e.records)typeof s.Id=="string"&&c.push(s.Id);if(e.done||!e.nextRecordsUrl)break;e=await n.queryMore(e.nextRecordsUrl)}}return c}function y(n){let a=n.slice(0,5).join(", ");return n.length>5?`${a}, and ${n.length-5} more`:a}async function b(n,a){let o=[];for(let t of n??[]){if(t.parents.kind!=="records")continue;let{childObject:c,lookupField:i,parentObject:r}=t,e=t.parents.ids,s=`${c}.${i}`,d;try{d=await a.keyPrefixOf?.(r)}catch{d=void 0}let f=d?e.filter(g=>g.slice(0,3)!==d):[];if(f.length>0){o.push(`The relation on ${s} names ${f.length} id(s) that are not ${r} ids \u2014 the org's ${r} ids start with ${d}: ${y(f)}. Nothing was written. Give the ids of ${r} records.`);continue}if(!a.presentIds){o.push(`This run cannot check that the ${e.length} ${r} record(s) the relation on ${s} names are in the org. Nothing was written.`);continue}let p;try{p=await a.presentIds(r,e)}catch(g){o.push(`Reading the ${r} records the relation on ${s} names failed (${$(g)}). Nothing was written.`);continue}let I=new Set(p.map(R)),h=e.filter(g=>!I.has(R(g)));h.length>0&&o.push(`${h.length} of the ${e.length} ${r} record(s) the relation on ${s} names are no longer in the org: ${y(h)}. Nothing was written. Run again what created them, or give the ids of ${r} records the org holds.`)}return o}export{q as a,w as b,N as c,b as d};
@@ -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{b as c,j as o,k as d}from"./chunk-OUU47Y7A.mjs";import{b as i}from"./chunk-CA5NAXSU.mjs";import{o as a}from"./chunk-6QSHWIZI.mjs";var u=6e4,g=class{tokenCache=new Map;sfdxBridge;setSfdxBridge(e){this.sfdxBridge=e}async authenticate(e){switch(e.method){case"oauth_web":return this.authenticateOAuth(e);case"oauth_device":return{success:!1,error:"OAuth device flow handled via DeviceLogin and SfdxBridge.loginWithRefreshToken()"};case"jwt":return this.authenticateJwt(e);case"usernamePassword":return this.authenticateUsernamePassword(e);case"sfdx_import":return this.importFromSfdx(e.username);default:return{success:!1,error:`Unsupported auth method: ${e.method}`}}}buildConnectionConfig(e,r){return{loginUrl:e.loginUrl,clientId:e.clientId,clientSecret:e.clientSecret,accessToken:r.accessToken,refreshToken:r.refreshToken,instanceUrl:r.instanceUrl,username:e.username}}async validateConnection(e,r){let t=await o({accessToken:e,instanceUrl:r}),{identity:s,orgResult:h}=await c(t,async()=>({identity:await t.identity(),orgResult:await t.query(`SELECT Id, Name, OrganizationType, IsSandbox FROM Organization LIMIT ${a.singleRecord}`)})),n=h.records[0];return{userId:s.user_id,username:s.username,displayName:s.display_name,orgId:n.Id,orgName:n.Name,orgType:n.OrganizationType,isSandbox:n.IsSandbox}}isTokenValid(e){let r=this.tokenCache.get(e);return r?Date.now()<r.expiresAt:!1}cacheToken(e,r,t){this.tokenCache.set(e,{token:r,expiresAt:Date.now()+t})}getCachedToken(e){let r=this.tokenCache.get(e);if(!r||Date.now()>=r.expiresAt){this.tokenCache.delete(e);return}return r.token}clearTokenCache(e){this.tokenCache.delete(e)}clearAllTokens(){this.tokenCache.clear()}async authenticateOAuth(e){return{success:!1,error:"OAuth handled via SfdxBridge.loginWeb()"}}async authenticateJwt(e){return{success:!1,error:"JWT handled via SfdxBridge.loginJwt()"}}async authenticateUsernamePassword(e){if(!e.username||!e.password)return{success:!1,error:"Username and password are required"};try{let r=await o({loginUrl:e.loginUrl}),t=await d(r.login(e.username,e.password+(e.securityToken??"")),u,`${new URL(e.loginUrl).host} did not answer within ${u/1e3} s: check that this machine reaches it, through its proxy if it has one`);return{success:!0,accessToken:r.accessToken??void 0,instanceUrl:r.instanceUrl,userId:t.id,orgId:t.organizationId}}catch(r){return{success:!1,error:`Login failed: ${i(r)}`}}}async importFromSfdx(e){if(!this.sfdxBridge)return{success:!1,error:"SFDX bridge not configured"};if(!e)return{success:!1,error:"An SFDX import needs the username of the org to import"};try{let r=await this.sfdxBridge.findOrg(e);return r?{success:!0,accessToken:r.credentials.accessToken,instanceUrl:r.credentials.instanceUrl,orgId:r.org.orgId}:{success:!1,error:`No connected org for ${e} found in SF CLI`}}catch(r){return{success:!1,error:`SFDX import failed: ${i(r)}`}}}};export{g as a};
7
+ import{b as c,j as o,k as d}from"./chunk-MSIEU5MR.mjs";import{b as i}from"./chunk-CA5NAXSU.mjs";import{o as a}from"./chunk-PMWAFDUB.mjs";var u=6e4,g=class{tokenCache=new Map;sfdxBridge;setSfdxBridge(e){this.sfdxBridge=e}async authenticate(e){switch(e.method){case"oauth_web":return this.authenticateOAuth(e);case"oauth_device":return{success:!1,error:"OAuth device flow handled via DeviceLogin and SfdxBridge.loginWithRefreshToken()"};case"jwt":return this.authenticateJwt(e);case"usernamePassword":return this.authenticateUsernamePassword(e);case"sfdx_import":return this.importFromSfdx(e.username);default:return{success:!1,error:`Unsupported auth method: ${e.method}`}}}buildConnectionConfig(e,r){return{loginUrl:e.loginUrl,clientId:e.clientId,clientSecret:e.clientSecret,accessToken:r.accessToken,refreshToken:r.refreshToken,instanceUrl:r.instanceUrl,username:e.username}}async validateConnection(e,r){let t=await o({accessToken:e,instanceUrl:r}),{identity:s,orgResult:h}=await c(t,async()=>({identity:await t.identity(),orgResult:await t.query(`SELECT Id, Name, OrganizationType, IsSandbox FROM Organization LIMIT ${a.singleRecord}`)})),n=h.records[0];return{userId:s.user_id,username:s.username,displayName:s.display_name,orgId:n.Id,orgName:n.Name,orgType:n.OrganizationType,isSandbox:n.IsSandbox}}isTokenValid(e){let r=this.tokenCache.get(e);return r?Date.now()<r.expiresAt:!1}cacheToken(e,r,t){this.tokenCache.set(e,{token:r,expiresAt:Date.now()+t})}getCachedToken(e){let r=this.tokenCache.get(e);if(!r||Date.now()>=r.expiresAt){this.tokenCache.delete(e);return}return r.token}clearTokenCache(e){this.tokenCache.delete(e)}clearAllTokens(){this.tokenCache.clear()}async authenticateOAuth(e){return{success:!1,error:"OAuth handled via SfdxBridge.loginWeb()"}}async authenticateJwt(e){return{success:!1,error:"JWT handled via SfdxBridge.loginJwt()"}}async authenticateUsernamePassword(e){if(!e.username||!e.password)return{success:!1,error:"Username and password are required"};try{let r=await o({loginUrl:e.loginUrl}),t=await d(r.login(e.username,e.password+(e.securityToken??"")),u,`${new URL(e.loginUrl).host} did not answer within ${u/1e3} s: check that this machine reaches it, through its proxy if it has one`);return{success:!0,accessToken:r.accessToken??void 0,instanceUrl:r.instanceUrl,userId:t.id,orgId:t.organizationId}}catch(r){return{success:!1,error:`Login failed: ${i(r)}`}}}async importFromSfdx(e){if(!this.sfdxBridge)return{success:!1,error:"SFDX bridge not configured"};if(!e)return{success:!1,error:"An SFDX import needs the username of the org to import"};try{let r=await this.sfdxBridge.findOrg(e);return r?{success:!0,accessToken:r.credentials.accessToken,instanceUrl:r.credentials.instanceUrl,orgId:r.org.orgId}:{success:!1,error:`No connected org for ${e} found in SF CLI`}}catch(r){return{success:!1,error:`SFDX import failed: ${i(r)}`}}}};export{g as a};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a as Re}from"./chunk-AHUGG3WU.mjs";import{K as we,Q as Se,b as ye}from"./chunk-OO24ZYYJ.mjs";import{Ga as he,Ia as be,h as x,i as fe,j as ge,k as D}from"./chunk-5OGNK3JP.mjs";import{o as se,p as ie,q as ae,r as de,s as ue}from"./chunk-YBZIDW6W.mjs";import{g as oe}from"./chunk-WXU6ZJIV.mjs";import{Lb as ce,Mb as le,Nb as N,Ob as me,Vb as B,hc as pe}from"./chunk-R3OM3X4L.mjs";import{h as re}from"./chunk-ZOSESZ22.mjs";import{b as z}from"./chunk-HFSBDM7B.mjs";import{q as F}from"./chunk-2GSMHGIV.mjs";import{b as v}from"./chunk-CA5NAXSU.mjs";import{c as ee,d as te,g as ne}from"./chunk-ISOSTAJR.mjs";import{Kd as K,Nd as Q,Pd as P,_d as V,be as X,ce as J,de as Y,ee as Z,h as W,i as O,id as H,k as U,vc as G}from"./chunk-6QSHWIZI.mjs";var L=1e4,$e=U.REST_API_BATCH_SIZE;function Oe(e){return e.id===void 0&&e.error!==void 0&&(e.errorDetails?.length??0)>0&&se([e.error],e.errorDetails)}function Pe(e,r){return e.error===void 0?e:{...e,error:ae(e.error,r)}}function C(e){return{successIds:e.flatMap(r=>r.id===void 0?[]:[r.id]),errors:e.flatMap(r=>r.error===void 0?[]:[r.error])}}function Ae(e,r){if(e.aborted||e.outcomes.length!==r||(e.unmatchedIds?.length??0)>0||(e.failures??[]).some(n=>n.recordIndex<0))return;let t=new Array(r);for(let n of e.outcomes){if(n.recordIndex<0||n.recordIndex>=r)return;if(n.success){if(!n.id)return;t[n.recordIndex]={id:n.id}}else{let o=n.error??"Unknown error",s=te(o);t[n.recordIndex]={error:o,...s?{errorDetails:[s]}:{}}}}return t.every(n=>n!==void 0)?t:void 0}function ze(e){let{conn:r,bulkManager:t,retry:n,signal:o,label:s}=e,p=new re(e.bulkThreshold),g,y=async(f,a,c)=>{g??=be(r).then(l=>(l||e.log(`[WARN] ${s}: the org's duplicate rules could not be read: an object of more than the Bulk API threshold goes as a Bulk API job, which a duplicate rule may refuse`),l));let h=await g;if(h===void 0)return he.has(f)?(e.log(`[INFO] ${s}: ${f} goes through REST: the duplicate rules could not be read, and a standard rule watches it`),!0):!1;let b=h.has(f);return b&&e.log(`[INFO] ${s}: ${f} goes through REST: an active duplicate rule watches it, which a Bulk API job cannot waive`+(a>L?` \u2014 ${a} records in ${Math.ceil(a/Math.max(1,c))} calls, slower than one job`:"")),b},R=async(f,a,c)=>{let h=[];for(let b=0;b<a.length;b+=c){if(o.aborted)return{rows:h,stopped:!0};let l=a.slice(b,b+c);e.calls?.sending(f,l.length);let w=await n.execute(async()=>r.sobject(f).create(l,{headers:G()}));if(w.cancelled)return e.calls?.answered(f,[]),{rows:h,stopped:!0};if(w.success&&w.result){let i=[];for(let m of w.result)if(m.success&&m.id)i.push(m.id),h.push({id:m.id});else{let d=ne(m.errors);h.push({error:d,errorDetails:(m.errors??[]).map(ee)})}e.calls?.answered(f,i)}else{let i=w.error?.message??"Insert failed after retries";for(let m=0;m<l.length;m++)h.push({error:i});e.calls?.answered(f,[])}}return{rows:h}},u=e.wait??(f=>ie(f,o)),A=async(f,a,c,h)=>{let b=Math.min(Math.max(1,h),$e),l=await de({outcomes:c,locked:Oe,written:i=>i.id!==void 0,send:async i=>(await R(f,i.map(m=>a[m]),b)).rows,note:Pe,wait:u,stopped:()=>o.aborted}),w=ue("record(s)",l);return{rows:l.outcomes,notes:w===void 0?[]:[`${f}: ${w}.`]}};return async(f,a,c,h)=>{let b=(c.length>L||p.shouldUseBulkApi(c.length))&&await y(a,c.length,h),l=b&&await g===void 0?[`The org's duplicate rules could not be read (the user SandForge connects as needs View Setup and Configuration): ${a}, which a standard duplicate rule watches, was sent through REST, whose header lets its matches be saved, rather than as a Bulk API job.`]:[];if(c.length>L&&!b){if(o.aborted)return{successIds:[],errors:[],stopped:!0};let d=new ye({signal:o}),S={connection:r,bulkManager:t,onProgress:(T,Ie)=>{e.onProgress(T,Ie,`Streaming insert ${a}`)},onOpened:T=>e.calls?.sending(a,c.length,{job:T})};e.calls?.sending(a,c.length);let E=await d.executeChunked(S,a,"insert",d.createChunkGenerator(c),c.length);e.calls?.answered(a,E.aborted?[]:E.successIds);let j=E.aborted?void 0:Ae({outcomes:E.outcomes??[],unmatchedIds:E.unmatchedIds},c.length),k=j&&await A(a,c,j,h);return k&&k.notes.length>0?{...C(k.rows),notes:k.notes}:{successIds:E.successIds,errors:E.errors,...E.aborted?{stopped:!0}:{}}}if(p.shouldUseBulkApi(c.length)&&!b){if(o.aborted)return{successIds:[],errors:[],stopped:!0};let d={connection:r,bulkManager:t,onProgress:(k,T)=>{e.onProgress(k,T,`Bulk insert ${a}`)},signal:o,onOpened:k=>e.calls?.sending(a,c.length,{job:k})};e.calls?.sending(a,c.length);let S=await p.executeBulk(d,a,"insert",c);e.calls?.answered(a,S.aborted?[]:S.successIds);let E=Ae(S,c.length),j=E&&await A(a,c,E,h);return j&&j.notes.length>0?{...C(j.rows),rows:j.rows,notes:j.notes}:{successIds:S.successIds,errors:S.failures.map(k=>k.error),...E?{rows:E}:{},...S.aborted?{stopped:!0}:{}}}let w=await R(a,c,h);if(w.stopped)return{...C(w.rows),rows:w.rows,stopped:!0};let i=await A(a,c,w.rows,h),m=[...l,...i.notes];return{...C(i.rows),rows:i.rows,...m.length>0?{notes:m}:{}}}}var xe="SELECT Id, DeveloperName FROM RecordType WHERE SobjectType = 'Account' AND IsPersonType = true";async function rt(e){try{return(await e.query(xe)).records.flatMap(t=>typeof t.Id=="string"&&typeof t.DeveloperName=="string"?[{id:t.Id,developerName:t.DeveloperName}]:[])}catch{return[]}}function ot(e,r,t){let n=new Set(e===F?t.map(o=>o.id.slice(0,15)):[]);return z(r).filter(o=>!o.master&&o.active&&o.available).map(o=>({recordTypeId:o.recordTypeId,developerName:o.developerName,label:o.name,person:n.has(o.recordTypeId.slice(0,15)),isDefault:o.defaultRecordTypeMapping}))}function Ce(e){let{staticValue:r,picklistValues:t}=e.config;return e.ruleType==="static"&&typeof r=="string"?[r]:e.ruleType==="picklist_random"?[...t??[]]:[]}function st(e,r){if(r.length===0)return{template:e,personObjects:[]};let t=new Map(r.map(s=>[s.id.slice(0,15),s.developerName])),n=[],o=[];for(let s of e.objects){if(s.objectApiName!==F){o.push(s);continue}let p=s.fieldRules.find(u=>u.fieldApiName==="RecordTypeId"),g=p?Ce(p):[],y=g.filter(u=>t.has(u.slice(0,15)));if(y.length>0&&y.length<g.length){let u=y.map(A=>t.get(A.slice(0,15))).join(", ");return{refusal:`${F}: ${u} ${y.length===1?"is a person account record type":"are person account record types"} and the other record types chosen are not: a person account and a business account take different fields. Seed one kind in a run.`}}let R=y.length>0?"person":"business";R==="person"&&n.push(s.objectApiName),o.push({...s,fieldRules:s.fieldRules.filter(u=>!H(F,u.fieldApiName,R))})}return{template:{...e,objects:o},personObjects:n}}var Me=/^[a-z]{2,3}(?:_[A-Za-z0-9]{2,4}){0,2}$/;async function ve(e){try{let t=(await e.query("SELECT DefaultLocaleSidKey FROM Organization LIMIT 1")).records[0]?.DefaultLocaleSidKey;return typeof t=="string"&&Me.test(t)?t:void 0}catch{return}}async function at(e,r){return e??await ve(r)??"en_US"}var ft="SEED_FIT_STORAGE_UNREAD",gt="SEED_CANNOT_FIT";function ht(e,r=!1){return q(e.objects.filter(t=>t.recordCount>0).map(t=>t.objectApiName),r)}function q(e,r=!1){let t=new Set(e);return(n,o)=>t.has(n)&&(o==="insert"||o==="update"&&r&&n===Re)}function bt(e,r,t,n){if(typeof e.unread=="string")return{room:{perRecord:[],notCounted:[],unread:e.unread},unread:e.unread};let o=Z(e,r,t);if(!n)return{running:o,room:x(o,t)};let s=[],p=new Set,g=[];for(let u of o.firing){let A=u.flow,f=A?.requiresFilled??[];if(u.write!=="insert"||A?.condition!=="read"||!A.creates?.length)continue;let a=f.filter(b=>n(u.objectApiName,b)==="every"),c=f.filter(b=>n(u.objectApiName,b)==="some"),h={objectApiName:u.objectApiName,name:u.name};a.length>0&&!Ne(o.firing,u)?(p.add(u),s.push({...h,fields:a,why:"leftEmpty"})):(a.length>0||c.length>0)&&(g.push(u),s.push({...h,fields:a.length>0?a:c,why:a.length>0?"automationMayFill":"mayBeLeftEmpty"}))}let y=x({firing:o.firing.filter(u=>!p.has(u))},t),R=x({firing:g},t).perRecord;return{running:o,room:{...y,...R.length>0?{atMost:R}:{},...s.length>0?{starts:s}:{}}}}function Ne(e,r){return e.some(t=>t!==r&&t.objectApiName===r.objectApiName&&t.write==="insert"&&(t.kind==="trigger"||t.kind==="process"||t.kind==="workflowRule"||t.flow?.timing==="beforeSave"))}async function yt(e,r,t){let n=new Set("objects"in r?r.objects.filter(s=>s.flows.some(p=>(p.requiresFilled??[]).length>0)).map(s=>s.objectApiName):[]),o=new Map;for(let s of e.objects)s.recordCount<=0||!n.has(s.objectApiName)||o.set(s.objectApiName,await t(s.objectApiName).catch(()=>{}));return(s,p)=>{let g=e.objects.find(a=>a.objectApiName===s);if(!g)return"none";let y=a=>a.toLowerCase()===p.toLowerCase();if(g.fieldRules.some(a=>y(a.fieldApiName)))return"none";let R=O(s,e.relations);if(R&&y(R.lookupField))return"none";let u=g.rows??[],A=u.filter(a=>Object.entries(a.values).some(([c,h])=>y(c)&&h!==null&&h!=="")).length;if(u.length>0&&A===u.length)return"none";let f=o.get(s);return f?[...f.filled].some(y)?"none":A>0?"some":[...f.empty].some(y)?"every":"some":"some"}}function M(e,r){return O(e.objectApiName,r)?.distribution.mode==="byKey"?"byKey":e.rows!==void 0?"rows":void 0}function ke(e,r){let t=O(e,r.relations);if(!(!t||t.parents.kind!=="generated"||t.distribution.mode==="byKey"||t.parentObject===e||!r.objects.some(n=>n.objectApiName===t.parentObject)))return t}function Ee(e,r){let t=r?.objects?.[e.objectApiName]??r?.all;return t!==void 0?Math.min(e.recordCount,Math.max(1,Math.floor(t))):e.recordCount}function Be(e,r,t){let n=new Map(e.objects.map(g=>[g.objectApiName,g])),o=new Map,s=new Set,p=g=>{let y=o.get(g);if(y!==void 0)return y;let R=n.get(g);if(M(R,e.relations))return o.set(g,R.recordCount),R.recordCount;s.add(g);let u=Math.round(r*Ee(R,t)),A=ke(g,e),f=A&&!s.has(A.parentObject)?Math.max(1,Math.min(u,W(A.distribution,p(A.parentObject)))):Math.max(1,u);return s.delete(g),o.set(g,f),f};return new Map(e.objects.map(g=>[g.objectApiName,p(g.objectApiName)]))}function De(e,r){if(r.cannotFit!==void 0)return e;let t=new Map(r.objects.map(n=>[n.objectApiName,n.after]));return{...e,objects:e.objects.map(n=>{let o=t.get(n.objectApiName);return o!==void 0&&o<n.recordCount?{...n,recordCount:o}:n})}}function Le(e,r){let t=e.objects.filter(s=>!M(s,e.relations)),n=t.filter(s=>!ke(s.objectApiName,e)),o;for(let s of n.length>0?n:t){let p=Ee(s,r);(!o||p>o.records)&&(o={objectApiName:s.objectApiName,records:p})}return o}function _e(e){return`${e} record${e===1?"":"s"}`}function qe(e){let{template:r,personObjects:t,budget:n,room:o}=e,s=e.ask?.caps,p=e.ask?.share===!0||s===void 0,g=d=>{let S=Be(r,d,s),E=De(r,{objects:r.objects.map(k=>({objectApiName:k.objectApiName,before:k.recordCount,after:S.get(k.objectApiName)??k.recordCount}))}),j=fe(o,k=>S.get(k)??0);return{counts:S,bytes:Se(E,t)+j,roomBytes:j,requests:we(E,e.path),records:[...S.values()].reduce((k,T)=>k+T,0)}},y=d=>d.bytes<=n.bytes,R=d=>n.runRequests===void 0||d.requests<=n.runRequests,u=d=>y(d)&&R(d),A=(d,S,E,j)=>({share:d,budget:{...ge(n,S.roomBytes,o),...E==="apiRequests"?{limitedBy:"apiRequests"}:{}},objects:r.objects.map(k=>{let T=M(k,r.relations);return{objectApiName:k.objectApiName,before:k.recordCount,after:S.counts.get(k.objectApiName)??k.recordCount,...T?{keptWhole:T}:{}}}),estimateMB:S.bytes/1048576,...j!==void 0?{cannotFit:j}:{},...o.unread!==void 0?{automationUnread:o.unread}:{}}),f=(d,S,E,j)=>({proposal:A(d,S,E,j),heldBy:E,records:S.records,requests:S.requests}),a=d=>{if(y(d))return`about ${d.requests} API requests, past the ${n.runRequests??0} that leave the org a tenth of its daily requests`;let S=pe(d.bytes/1048576,n.bytes/1048576);return`${S.over} MB`+(d.roomBytes>0?", room for what the org's automation creates under them included":"")+`, past the ${S.bound} MB that fit`},c=d=>y(d)?"apiRequests":n.terms.limitedBy,h=r.objects.filter(d=>M(d,r.relations)).reduce((d,S)=>d+S.recordCount,0),b=g(1);if(u(b)){let d=r.objects.some(S=>(b.counts.get(S.objectApiName)??0)<S.recordCount);return f(1,b,d?"caps":"whole")}if(!p)return f(1,b,c(b),`with these caps the seed takes ${a(b)}: lower them, or fit by share`);let l=Le(r,s);if(!l)return f(1,b,c(b),`the ${h} rows the template gives take ${a(b)}, and rows are kept whole`);let w=d=>g(d/l.records),i=D(l.records,d=>u(w(d)));if(i===0){let d=w(1);return f(1/l.records,d,c(d),`the least it can be cut to \u2014 one ${l.objectApiName} and what follows it`+(h>0?`, with the ${h} rows the template gives kept whole`:"")+`, ${_e(d.records)} \u2014 takes ${a(d)}`)}let m=D(l.records,d=>y(w(d)));return f(i/l.records,w(i),m>i?"apiRequests":n.terms.limitedBy)}function wt(e,r,t,n,o){if(!("unread"in e))return qe({template:r,personObjects:t,budget:e,room:n,path:o}).proposal}function St(e,r){if(!(!e||e.before<r))return{module:"seed",share:e.share,...e.withinMB!==void 0?{withinMB:e.withinMB}:{},kept:r,inSource:e.before}}var Fe=(e,r)=>r==="insert";function je(e){return typeof e.unread=="string"}function We(e){return(K(e).find(t=>t.write==="insert")?.fired??[]).map(t=>{let n=t.flow,o=n?.messages??[];return{kind:t.kind,name:t.name,when:t.when,emails:o.filter(s=>s.kind==="email").length,messages:[...new Set(o.flatMap(s=>s.kind==="email"?[]:[s.kind]))],creates:[...n?.creates??[]],afterCommit:(n?.paths?.length??0)>0,bypasses:(n?.permissions??[]).filter(s=>s.bypass).map(({name:s,held:p})=>p===void 0?{name:s}:{name:s,held:p}),keptQuiet:t.keptQuiet===!0,unread:n!==void 0&&n.condition!=="read"}})}function $(e){return[...new Set(e)].sort((r,t)=>r.localeCompare(t))}function Te(e,r,t,n,o=Fe){let s=e.objects.flatMap(l=>{let w=We(l);return w.length>0?[{objectApiName:l.objectApiName,entries:w}]:[]}),p=je(t)?void 0:t,g=p!==void 0&&ce(p),y=p!==void 0&&le(p),R=N(P(e),g,y),u=s.flatMap(l=>l.entries.flatMap(w=>w.bypasses)),A=$(u.filter(l=>l.held===!0).map(l=>l.name)),f=$(u.map(l=>l.name)).filter(l=>!A.includes(l)),a=V(e,f),c=f.map(l=>{let w=a.find(i=>i.permission.toLowerCase()===l.toLowerCase())?.permissionSet;return w?{permission:l,permissionSet:w.name}:{permission:l}}),h=X(e,o),b=h.assign.length>0;return{org:r,objectsRead:[...e.objectsRead],objects:s,emailsPerRecord:R,...p&&R.length>0?{limits:{...p}}:{},...je(t)?{limitsUnread:t.unread}:{},alertsAsSingle:g,bypasses:c,bypassesHeld:A,...b?{mute:h,emailsPerRecordMuted:N(P(Y(e,J(h))),g,y)}:{},unread:e.unread.map(({part:l,reason:w})=>({part:l,reason:w})),blinded:Q(e.unread),conditionsNotRead:e.conditionsNotRead,...n?{deliverability:n}:{}}}async function Ft(e){let r=e.writes??q(e.objects),t;try{t=await e.readAutomation(e.objects)}catch(s){return{error:v(s)}}let n=e.deliverability??(e.readDeliverability?(await oe({read:t,writes:Fe,readDeliverability:e.readDeliverability,accepted:!1,target:e.org,run:"seed"})).gate.deliverability:void 0);if(P(t).length===0)return{preview:Te(t,e.org,{},n,r)};let o=await e.readLimits().catch(s=>({unread:v(s)}));return{preview:Te(t,e.org,o,n,r)}}function I(e,r="and"){return e.length<=1?e.join(""):e.length===2?`${e[0]} ${r} ${e[1]}`:`${e.slice(0,-1).join(", ")}, ${r} ${e[e.length-1]}`}var It="SEED_EMAILS_EXCEEDED";function $t(e,r,t){if("error"in e)return{checks:[],unknown:[`what ${t} runs as these records are created could not be read (${e.error}): the emails they make it send are not known`]};let{preview:n}=e,o={objects:r.map(i=>({objectApiName:i.objectApiName,rows:i.recordCount,storageBytes:0}))},s=n.limitsUnread!==void 0?{unread:n.limitsUnread}:n.limits??{},p=me(o,n.emailsPerRecord,s),g=new Set(r.filter(i=>i.recordCount>0).map(i=>i.objectApiName)),y=n.objects.flatMap(i=>g.has(i.objectApiName)?i.entries.filter(m=>m.unread&&!m.keptQuiet&&m.when!=="before").map(m=>`"${m.name}" on ${i.objectApiName}`):[]),R=[...p.filter(i=>i.verdict==="unread").map(i=>`about ${B(i.emails,i.limit)}, but what ${t} has left today could not be read (${i.unread??"not said"})`),...n.blinded?[`part of what ${t} runs could not be read: emails it sends may not be counted`]:[],...y.length>0?[`the emails of ${I(y)} are not counted: what ${y.length===1?"it does":"they do"} was not read`]:n.conditionsNotRead>0?[`${n.conditionsNotRead} start condition(s) of ${t} not read: the emails of those flows are not counted`]:[]],u=p.find(i=>i.verdict==="exceeds");if(!u)return R.length>0?{checks:p,unknown:R}:{checks:p};let A=p.filter(i=>i.verdict==="exceeds"),f=$(A.flatMap(i=>i.objects.map(m=>m.objectApiName))),a=$(A.flatMap(i=>i.objects.flatMap(m=>m.sentBy))),c=new Map;for(let i of n.objects.flatMap(m=>m.entries))if(!(i.emails===0||!a.includes(i.name)))for(let{name:m}of i.bypasses)c.set(m,(c.get(m)??new Set).add(i.name));let h=n.bypasses.flatMap(i=>{let m=c.get(i.permission);return m?[{...i,quiets:$([...m])}]:[]}),b=A.map(i=>`about ${B(i.emails,i.limit)} (`+i.objects.map(m=>`${m.perRecord} per ${m.objectApiName}`).join(", ")+`), ${i.remaining??0} of ${i.max??0} left today`).join("; "),l=["lower the record counts",`set ${I(f)} to 0`,`turn off ${I(a.map(i=>`"${i}"`))}`,...h.map(i=>"give the user the seed writes as "+(i.permissionSet?`the permission set ${i.permissionSet}, whose ${i.permission}`:`a permission set holding ${i.permission}, which`)+` keeps ${I(i.quiets.map(m=>`"${m}"`))} quiet`)],w=`The seed was refused before it wrote anything: its records would make ${t} send ${b}. Past what is left, a flow that sends in the save refuses its record (CANNOT_EXECUTE_FLOW_TRIGGER), and the org's own emails stop for the rest of the day. To seed it, ${I(l,"or")}. Nothing was written.`;return{checks:p,refusal:w,figures:{org:t,limit:u.limit,emails:u.emails,remaining:u.remaining??0,max:u.max??0,objects:f,senders:a,bypasses:h},...R.length>0?{unknown:R}:{}}}var Ue={flow:e=>`flow "${e}"`,trigger:e=>`Apex trigger ${e}`,process:e=>`process "${e}"`,workflowRule:e=>`workflow rule "${e}"`},Ge={before:"before save",after:"after save",beforeAndAfter:"before and after save"},He={notification:"custom notifications",outbound:"outbound messages",sms:"text messages"};function Ke(e){let r=n=>n.held===!0?" (held)":n.held===!1?" (not held)":"",t=[Ge[e.when],...e.emails>0?[`${e.emails} email(s) a record`]:[],...e.messages.map(n=>`sends ${He[n]}`),...e.creates.length>0?[`creates ${e.creates.join(", ")}`]:[],...e.afterCommit?["then after commit"]:[],...e.bypasses.length>0?[`not for a user with ${e.bypasses.map(n=>n.name+r(n)).join(", ")}`]:[],...e.keptQuiet?["quiet for this seed"]:[],...e.unread?["what it does was not read"]:[]];return`${Ue[e.kind](e.name)} (${t.join("; ")})`}function Ot(e,r){if("error"in e)return[`target automation: what ${r} runs as these records are created could not be read (${e.error}): the emails they make it send are not known`];let{preview:t}=e,n=[`target automation: what ${r} runs as these records are created`];for(let o of t.objects)n.push(` ${o.objectApiName}: ${o.entries.map(Ke).join(", ")}`);t.objects.length===0&&n.push(t.blinded?" nothing found in what could be read":" nothing runs on them: no flow, Apex trigger, process or workflow rule"),t.bypassesHeld.length>0&&n.push(` bypass held: the user the seed writes as holds ${t.bypassesHeld.join(", ")}, and what names it stays quiet`);for(let o of t.bypasses)n.push(o.permissionSet?` bypass: ${o.permission} keeps quiet what names it; permission set ${o.permissionSet} holds it`:` bypass: ${o.permission} keeps quiet what names it; no permission set of ${r} was found to hold it`);t.alertsAsSingle&&t.emailsPerRecord.some(o=>o.alertsAmong)&&n.push(` ${r} counts its email alerts against its single emails too, as a Developer Edition does`);for(let{part:o,reason:s}of t.unread)n.push(` ${o} could not be read: ${s}`);return t.conditionsNotRead>0&&n.push(` ${t.conditionsNotRead} start condition(s) not read`),n}export{ze as a,rt as b,ot as c,st as d,at as e,ft as f,gt as g,ht as h,q as i,bt as j,yt as k,De as l,qe as m,wt as n,St as o,Ft as p,It as q,$t as r,Ot as s};
7
+ import{a as Re}from"./chunk-FITPY3L4.mjs";import{K as we,Q as Se,b as ye}from"./chunk-6I6TWNV5.mjs";import{Ha as he,Ja as be,i as x,j as fe,k as ge,l as D}from"./chunk-IVFVNNGB.mjs";import{g as ue}from"./chunk-LC3NDW4N.mjs";import{$b as ce,ac as le,bc as N,cc as me,jc as B,xc as pe}from"./chunk-KB4ZHM4Q.mjs";import{h as re}from"./chunk-D4GF4FAB.mjs";import{d as oe,e as se,f as ie,g as ae,h as de}from"./chunk-CVHNXJH3.mjs";import{b as z}from"./chunk-HFSBDM7B.mjs";import{q as F}from"./chunk-TNT27RBG.mjs";import{b as v}from"./chunk-CA5NAXSU.mjs";import{c as ee,d as te,g as ne}from"./chunk-S42RBRH2.mjs";import{Kd as K,Nd as Q,Pd as P,_d as V,be as X,ce as J,de as Y,ee as Z,h as W,i as O,id as H,k as U,vc as G}from"./chunk-PMWAFDUB.mjs";var L=1e4,$e=U.REST_API_BATCH_SIZE;function Oe(e){return e.id===void 0&&e.error!==void 0&&(e.errorDetails?.length??0)>0&&oe([e.error],e.errorDetails)}function Pe(e,r){return e.error===void 0?e:{...e,error:ie(e.error,r)}}function C(e){return{successIds:e.flatMap(r=>r.id===void 0?[]:[r.id]),errors:e.flatMap(r=>r.error===void 0?[]:[r.error])}}function Ae(e,r){if(e.aborted||e.outcomes.length!==r||(e.unmatchedIds?.length??0)>0||(e.failures??[]).some(n=>n.recordIndex<0))return;let t=new Array(r);for(let n of e.outcomes){if(n.recordIndex<0||n.recordIndex>=r)return;if(n.success){if(!n.id)return;t[n.recordIndex]={id:n.id}}else{let o=n.error??"Unknown error",s=te(o);t[n.recordIndex]={error:o,...s?{errorDetails:[s]}:{}}}}return t.every(n=>n!==void 0)?t:void 0}function ze(e){let{conn:r,bulkManager:t,retry:n,signal:o,label:s}=e,p=new re(e.bulkThreshold),g,y=async(f,a,c)=>{g??=be(r).then(l=>(l||e.log(`[WARN] ${s}: the org's duplicate rules could not be read: an object of more than the Bulk API threshold goes as a Bulk API job, which a duplicate rule may refuse`),l));let h=await g;if(h===void 0)return he.has(f)?(e.log(`[INFO] ${s}: ${f} goes through REST: the duplicate rules could not be read, and a standard rule watches it`),!0):!1;let b=h.has(f);return b&&e.log(`[INFO] ${s}: ${f} goes through REST: an active duplicate rule watches it, which a Bulk API job cannot waive`+(a>L?` \u2014 ${a} records in ${Math.ceil(a/Math.max(1,c))} calls, slower than one job`:"")),b},R=async(f,a,c)=>{let h=[];for(let b=0;b<a.length;b+=c){if(o.aborted)return{rows:h,stopped:!0};let l=a.slice(b,b+c);e.calls?.sending(f,l.length);let w=await n.execute(async()=>r.sobject(f).create(l,{headers:G()}));if(w.cancelled)return e.calls?.answered(f,[]),{rows:h,stopped:!0};if(w.success&&w.result){let i=[];for(let m of w.result)if(m.success&&m.id)i.push(m.id),h.push({id:m.id});else{let d=ne(m.errors);h.push({error:d,errorDetails:(m.errors??[]).map(ee)})}e.calls?.answered(f,i)}else{let i=w.error?.message??"Insert failed after retries";for(let m=0;m<l.length;m++)h.push({error:i});e.calls?.answered(f,[])}}return{rows:h}},u=e.wait??(f=>se(f,o)),A=async(f,a,c,h)=>{let b=Math.min(Math.max(1,h),$e),l=await ae({outcomes:c,locked:Oe,written:i=>i.id!==void 0,send:async i=>(await R(f,i.map(m=>a[m]),b)).rows,note:Pe,wait:u,stopped:()=>o.aborted}),w=de("record(s)",l);return{rows:l.outcomes,notes:w===void 0?[]:[`${f}: ${w}.`]}};return async(f,a,c,h)=>{let b=(c.length>L||p.shouldUseBulkApi(c.length))&&await y(a,c.length,h),l=b&&await g===void 0?[`The org's duplicate rules could not be read (the user SandForge connects as needs View Setup and Configuration): ${a}, which a standard duplicate rule watches, was sent through REST, whose header lets its matches be saved, rather than as a Bulk API job.`]:[];if(c.length>L&&!b){if(o.aborted)return{successIds:[],errors:[],stopped:!0};let d=new ye({signal:o}),S={connection:r,bulkManager:t,onProgress:(T,Ie)=>{e.onProgress(T,Ie,`Streaming insert ${a}`)},onOpened:T=>e.calls?.sending(a,c.length,{job:T})};e.calls?.sending(a,c.length);let E=await d.executeChunked(S,a,"insert",d.createChunkGenerator(c),c.length);e.calls?.answered(a,E.aborted?[]:E.successIds);let j=E.aborted?void 0:Ae({outcomes:E.outcomes??[],unmatchedIds:E.unmatchedIds},c.length),k=j&&await A(a,c,j,h);return k&&k.notes.length>0?{...C(k.rows),notes:k.notes}:{successIds:E.successIds,errors:E.errors,...E.aborted?{stopped:!0}:{}}}if(p.shouldUseBulkApi(c.length)&&!b){if(o.aborted)return{successIds:[],errors:[],stopped:!0};let d={connection:r,bulkManager:t,onProgress:(k,T)=>{e.onProgress(k,T,`Bulk insert ${a}`)},signal:o,onOpened:k=>e.calls?.sending(a,c.length,{job:k})};e.calls?.sending(a,c.length);let S=await p.executeBulk(d,a,"insert",c);e.calls?.answered(a,S.aborted?[]:S.successIds);let E=Ae(S,c.length),j=E&&await A(a,c,E,h);return j&&j.notes.length>0?{...C(j.rows),rows:j.rows,notes:j.notes}:{successIds:S.successIds,errors:S.failures.map(k=>k.error),...E?{rows:E}:{},...S.aborted?{stopped:!0}:{}}}let w=await R(a,c,h);if(w.stopped)return{...C(w.rows),rows:w.rows,stopped:!0};let i=await A(a,c,w.rows,h),m=[...l,...i.notes];return{...C(i.rows),rows:i.rows,...m.length>0?{notes:m}:{}}}}var xe="SELECT Id, DeveloperName FROM RecordType WHERE SobjectType = 'Account' AND IsPersonType = true";async function rt(e){try{return(await e.query(xe)).records.flatMap(t=>typeof t.Id=="string"&&typeof t.DeveloperName=="string"?[{id:t.Id,developerName:t.DeveloperName}]:[])}catch{return[]}}function ot(e,r,t){let n=new Set(e===F?t.map(o=>o.id.slice(0,15)):[]);return z(r).filter(o=>!o.master&&o.active&&o.available).map(o=>({recordTypeId:o.recordTypeId,developerName:o.developerName,label:o.name,person:n.has(o.recordTypeId.slice(0,15)),isDefault:o.defaultRecordTypeMapping}))}function Ce(e){let{staticValue:r,picklistValues:t}=e.config;return e.ruleType==="static"&&typeof r=="string"?[r]:e.ruleType==="picklist_random"?[...t??[]]:[]}function st(e,r){if(r.length===0)return{template:e,personObjects:[]};let t=new Map(r.map(s=>[s.id.slice(0,15),s.developerName])),n=[],o=[];for(let s of e.objects){if(s.objectApiName!==F){o.push(s);continue}let p=s.fieldRules.find(u=>u.fieldApiName==="RecordTypeId"),g=p?Ce(p):[],y=g.filter(u=>t.has(u.slice(0,15)));if(y.length>0&&y.length<g.length){let u=y.map(A=>t.get(A.slice(0,15))).join(", ");return{refusal:`${F}: ${u} ${y.length===1?"is a person account record type":"are person account record types"} and the other record types chosen are not: a person account and a business account take different fields. Seed one kind in a run.`}}let R=y.length>0?"person":"business";R==="person"&&n.push(s.objectApiName),o.push({...s,fieldRules:s.fieldRules.filter(u=>!H(F,u.fieldApiName,R))})}return{template:{...e,objects:o},personObjects:n}}var Me=/^[a-z]{2,3}(?:_[A-Za-z0-9]{2,4}){0,2}$/;async function ve(e){try{let t=(await e.query("SELECT DefaultLocaleSidKey FROM Organization LIMIT 1")).records[0]?.DefaultLocaleSidKey;return typeof t=="string"&&Me.test(t)?t:void 0}catch{return}}async function at(e,r){return e??await ve(r)??"en_US"}var ft="SEED_FIT_STORAGE_UNREAD",gt="SEED_CANNOT_FIT";function ht(e,r=!1){return q(e.objects.filter(t=>t.recordCount>0).map(t=>t.objectApiName),r)}function q(e,r=!1){let t=new Set(e);return(n,o)=>t.has(n)&&(o==="insert"||o==="update"&&r&&n===Re)}function bt(e,r,t,n){if(typeof e.unread=="string")return{room:{perRecord:[],notCounted:[],unread:e.unread},unread:e.unread};let o=Z(e,r,t);if(!n)return{running:o,room:x(o,t)};let s=[],p=new Set,g=[];for(let u of o.firing){let A=u.flow,f=A?.requiresFilled??[];if(u.write!=="insert"||A?.condition!=="read"||!A.creates?.length)continue;let a=f.filter(b=>n(u.objectApiName,b)==="every"),c=f.filter(b=>n(u.objectApiName,b)==="some"),h={objectApiName:u.objectApiName,name:u.name};a.length>0&&!Ne(o.firing,u)?(p.add(u),s.push({...h,fields:a,why:"leftEmpty"})):(a.length>0||c.length>0)&&(g.push(u),s.push({...h,fields:a.length>0?a:c,why:a.length>0?"automationMayFill":"mayBeLeftEmpty"}))}let y=x({firing:o.firing.filter(u=>!p.has(u))},t),R=x({firing:g},t).perRecord;return{running:o,room:{...y,...R.length>0?{atMost:R}:{},...s.length>0?{starts:s}:{}}}}function Ne(e,r){return e.some(t=>t!==r&&t.objectApiName===r.objectApiName&&t.write==="insert"&&(t.kind==="trigger"||t.kind==="process"||t.kind==="workflowRule"||t.flow?.timing==="beforeSave"))}async function yt(e,r,t){let n=new Set("objects"in r?r.objects.filter(s=>s.flows.some(p=>(p.requiresFilled??[]).length>0)).map(s=>s.objectApiName):[]),o=new Map;for(let s of e.objects)s.recordCount<=0||!n.has(s.objectApiName)||o.set(s.objectApiName,await t(s.objectApiName).catch(()=>{}));return(s,p)=>{let g=e.objects.find(a=>a.objectApiName===s);if(!g)return"none";let y=a=>a.toLowerCase()===p.toLowerCase();if(g.fieldRules.some(a=>y(a.fieldApiName)))return"none";let R=O(s,e.relations);if(R&&y(R.lookupField))return"none";let u=g.rows??[],A=u.filter(a=>Object.entries(a.values).some(([c,h])=>y(c)&&h!==null&&h!=="")).length;if(u.length>0&&A===u.length)return"none";let f=o.get(s);return f?[...f.filled].some(y)?"none":A>0?"some":[...f.empty].some(y)?"every":"some":"some"}}function M(e,r){return O(e.objectApiName,r)?.distribution.mode==="byKey"?"byKey":e.rows!==void 0?"rows":void 0}function ke(e,r){let t=O(e,r.relations);if(!(!t||t.parents.kind!=="generated"||t.distribution.mode==="byKey"||t.parentObject===e||!r.objects.some(n=>n.objectApiName===t.parentObject)))return t}function Ee(e,r){let t=r?.objects?.[e.objectApiName]??r?.all;return t!==void 0?Math.min(e.recordCount,Math.max(1,Math.floor(t))):e.recordCount}function Be(e,r,t){let n=new Map(e.objects.map(g=>[g.objectApiName,g])),o=new Map,s=new Set,p=g=>{let y=o.get(g);if(y!==void 0)return y;let R=n.get(g);if(M(R,e.relations))return o.set(g,R.recordCount),R.recordCount;s.add(g);let u=Math.round(r*Ee(R,t)),A=ke(g,e),f=A&&!s.has(A.parentObject)?Math.max(1,Math.min(u,W(A.distribution,p(A.parentObject)))):Math.max(1,u);return s.delete(g),o.set(g,f),f};return new Map(e.objects.map(g=>[g.objectApiName,p(g.objectApiName)]))}function De(e,r){if(r.cannotFit!==void 0)return e;let t=new Map(r.objects.map(n=>[n.objectApiName,n.after]));return{...e,objects:e.objects.map(n=>{let o=t.get(n.objectApiName);return o!==void 0&&o<n.recordCount?{...n,recordCount:o}:n})}}function Le(e,r){let t=e.objects.filter(s=>!M(s,e.relations)),n=t.filter(s=>!ke(s.objectApiName,e)),o;for(let s of n.length>0?n:t){let p=Ee(s,r);(!o||p>o.records)&&(o={objectApiName:s.objectApiName,records:p})}return o}function _e(e){return`${e} record${e===1?"":"s"}`}function qe(e){let{template:r,personObjects:t,budget:n,room:o}=e,s=e.ask?.caps,p=e.ask?.share===!0||s===void 0,g=d=>{let S=Be(r,d,s),E=De(r,{objects:r.objects.map(k=>({objectApiName:k.objectApiName,before:k.recordCount,after:S.get(k.objectApiName)??k.recordCount}))}),j=fe(o,k=>S.get(k)??0);return{counts:S,bytes:Se(E,t)+j,roomBytes:j,requests:we(E,e.path),records:[...S.values()].reduce((k,T)=>k+T,0)}},y=d=>d.bytes<=n.bytes,R=d=>n.runRequests===void 0||d.requests<=n.runRequests,u=d=>y(d)&&R(d),A=(d,S,E,j)=>({share:d,budget:{...ge(n,S.roomBytes,o),...E==="apiRequests"?{limitedBy:"apiRequests"}:{}},objects:r.objects.map(k=>{let T=M(k,r.relations);return{objectApiName:k.objectApiName,before:k.recordCount,after:S.counts.get(k.objectApiName)??k.recordCount,...T?{keptWhole:T}:{}}}),estimateMB:S.bytes/1048576,...j!==void 0?{cannotFit:j}:{},...o.unread!==void 0?{automationUnread:o.unread}:{}}),f=(d,S,E,j)=>({proposal:A(d,S,E,j),heldBy:E,records:S.records,requests:S.requests}),a=d=>{if(y(d))return`about ${d.requests} API requests, past the ${n.runRequests??0} that leave the org a tenth of its daily requests`;let S=pe(d.bytes/1048576,n.bytes/1048576);return`${S.over} MB`+(d.roomBytes>0?", room for what the org's automation creates under them included":"")+`, past the ${S.bound} MB that fit`},c=d=>y(d)?"apiRequests":n.terms.limitedBy,h=r.objects.filter(d=>M(d,r.relations)).reduce((d,S)=>d+S.recordCount,0),b=g(1);if(u(b)){let d=r.objects.some(S=>(b.counts.get(S.objectApiName)??0)<S.recordCount);return f(1,b,d?"caps":"whole")}if(!p)return f(1,b,c(b),`with these caps the seed takes ${a(b)}: lower them, or fit by share`);let l=Le(r,s);if(!l)return f(1,b,c(b),`the ${h} rows the template gives take ${a(b)}, and rows are kept whole`);let w=d=>g(d/l.records),i=D(l.records,d=>u(w(d)));if(i===0){let d=w(1);return f(1/l.records,d,c(d),`the least it can be cut to \u2014 one ${l.objectApiName} and what follows it`+(h>0?`, with the ${h} rows the template gives kept whole`:"")+`, ${_e(d.records)} \u2014 takes ${a(d)}`)}let m=D(l.records,d=>y(w(d)));return f(i/l.records,w(i),m>i?"apiRequests":n.terms.limitedBy)}function wt(e,r,t,n,o){if(!("unread"in e))return qe({template:r,personObjects:t,budget:e,room:n,path:o}).proposal}function St(e,r){if(!(!e||e.before<r))return{module:"seed",share:e.share,...e.withinMB!==void 0?{withinMB:e.withinMB}:{},kept:r,inSource:e.before}}var Fe=(e,r)=>r==="insert";function je(e){return typeof e.unread=="string"}function We(e){return(K(e).find(t=>t.write==="insert")?.fired??[]).map(t=>{let n=t.flow,o=n?.messages??[];return{kind:t.kind,name:t.name,when:t.when,emails:o.filter(s=>s.kind==="email").length,messages:[...new Set(o.flatMap(s=>s.kind==="email"?[]:[s.kind]))],creates:[...n?.creates??[]],afterCommit:(n?.paths?.length??0)>0,bypasses:(n?.permissions??[]).filter(s=>s.bypass).map(({name:s,held:p})=>p===void 0?{name:s}:{name:s,held:p}),keptQuiet:t.keptQuiet===!0,unread:n!==void 0&&n.condition!=="read"}})}function $(e){return[...new Set(e)].sort((r,t)=>r.localeCompare(t))}function Te(e,r,t,n,o=Fe){let s=e.objects.flatMap(l=>{let w=We(l);return w.length>0?[{objectApiName:l.objectApiName,entries:w}]:[]}),p=je(t)?void 0:t,g=p!==void 0&&ce(p),y=p!==void 0&&le(p),R=N(P(e),g,y),u=s.flatMap(l=>l.entries.flatMap(w=>w.bypasses)),A=$(u.filter(l=>l.held===!0).map(l=>l.name)),f=$(u.map(l=>l.name)).filter(l=>!A.includes(l)),a=V(e,f),c=f.map(l=>{let w=a.find(i=>i.permission.toLowerCase()===l.toLowerCase())?.permissionSet;return w?{permission:l,permissionSet:w.name}:{permission:l}}),h=X(e,o),b=h.assign.length>0;return{org:r,objectsRead:[...e.objectsRead],objects:s,emailsPerRecord:R,...p&&R.length>0?{limits:{...p}}:{},...je(t)?{limitsUnread:t.unread}:{},alertsAsSingle:g,bypasses:c,bypassesHeld:A,...b?{mute:h,emailsPerRecordMuted:N(P(Y(e,J(h))),g,y)}:{},unread:e.unread.map(({part:l,reason:w})=>({part:l,reason:w})),blinded:Q(e.unread),conditionsNotRead:e.conditionsNotRead,...n?{deliverability:n}:{}}}async function Ft(e){let r=e.writes??q(e.objects),t;try{t=await e.readAutomation(e.objects)}catch(s){return{error:v(s)}}let n=e.deliverability??(e.readDeliverability?(await ue({read:t,writes:Fe,readDeliverability:e.readDeliverability,accepted:!1,target:e.org,run:"seed"})).gate.deliverability:void 0);if(P(t).length===0)return{preview:Te(t,e.org,{},n,r)};let o=await e.readLimits().catch(s=>({unread:v(s)}));return{preview:Te(t,e.org,o,n,r)}}function I(e,r="and"){return e.length<=1?e.join(""):e.length===2?`${e[0]} ${r} ${e[1]}`:`${e.slice(0,-1).join(", ")}, ${r} ${e[e.length-1]}`}var It="SEED_EMAILS_EXCEEDED";function $t(e,r,t){if("error"in e)return{checks:[],unknown:[`what ${t} runs as these records are created could not be read (${e.error}): the emails they make it send are not known`]};let{preview:n}=e,o={objects:r.map(i=>({objectApiName:i.objectApiName,rows:i.recordCount,storageBytes:0}))},s=n.limitsUnread!==void 0?{unread:n.limitsUnread}:n.limits??{},p=me(o,n.emailsPerRecord,s),g=new Set(r.filter(i=>i.recordCount>0).map(i=>i.objectApiName)),y=n.objects.flatMap(i=>g.has(i.objectApiName)?i.entries.filter(m=>m.unread&&!m.keptQuiet&&m.when!=="before").map(m=>`"${m.name}" on ${i.objectApiName}`):[]),R=[...p.filter(i=>i.verdict==="unread").map(i=>`about ${B(i.emails,i.limit)}, but what ${t} has left today could not be read (${i.unread??"not said"})`),...n.blinded?[`part of what ${t} runs could not be read: emails it sends may not be counted`]:[],...y.length>0?[`the emails of ${I(y)} are not counted: what ${y.length===1?"it does":"they do"} was not read`]:n.conditionsNotRead>0?[`${n.conditionsNotRead} start condition(s) of ${t} not read: the emails of those flows are not counted`]:[]],u=p.find(i=>i.verdict==="exceeds");if(!u)return R.length>0?{checks:p,unknown:R}:{checks:p};let A=p.filter(i=>i.verdict==="exceeds"),f=$(A.flatMap(i=>i.objects.map(m=>m.objectApiName))),a=$(A.flatMap(i=>i.objects.flatMap(m=>m.sentBy))),c=new Map;for(let i of n.objects.flatMap(m=>m.entries))if(!(i.emails===0||!a.includes(i.name)))for(let{name:m}of i.bypasses)c.set(m,(c.get(m)??new Set).add(i.name));let h=n.bypasses.flatMap(i=>{let m=c.get(i.permission);return m?[{...i,quiets:$([...m])}]:[]}),b=A.map(i=>`about ${B(i.emails,i.limit)} (`+i.objects.map(m=>`${m.perRecord} per ${m.objectApiName}`).join(", ")+`), ${i.remaining??0} of ${i.max??0} left today`).join("; "),l=["lower the record counts",`set ${I(f)} to 0`,`turn off ${I(a.map(i=>`"${i}"`))}`,...h.map(i=>"give the user the seed writes as "+(i.permissionSet?`the permission set ${i.permissionSet}, whose ${i.permission}`:`a permission set holding ${i.permission}, which`)+` keeps ${I(i.quiets.map(m=>`"${m}"`))} quiet`)],w=`The seed was refused before it wrote anything: its records would make ${t} send ${b}. Past what is left, a flow that sends in the save refuses its record (CANNOT_EXECUTE_FLOW_TRIGGER), and the org's own emails stop for the rest of the day. To seed it, ${I(l,"or")}. Nothing was written.`;return{checks:p,refusal:w,figures:{org:t,limit:u.limit,emails:u.emails,remaining:u.remaining??0,max:u.max??0,objects:f,senders:a,bypasses:h},...R.length>0?{unknown:R}:{}}}var Ue={flow:e=>`flow "${e}"`,trigger:e=>`Apex trigger ${e}`,process:e=>`process "${e}"`,workflowRule:e=>`workflow rule "${e}"`},Ge={before:"before save",after:"after save",beforeAndAfter:"before and after save"},He={notification:"custom notifications",outbound:"outbound messages",sms:"text messages"};function Ke(e){let r=n=>n.held===!0?" (held)":n.held===!1?" (not held)":"",t=[Ge[e.when],...e.emails>0?[`${e.emails} email(s) a record`]:[],...e.messages.map(n=>`sends ${He[n]}`),...e.creates.length>0?[`creates ${e.creates.join(", ")}`]:[],...e.afterCommit?["then after commit"]:[],...e.bypasses.length>0?[`not for a user with ${e.bypasses.map(n=>n.name+r(n)).join(", ")}`]:[],...e.keptQuiet?["quiet for this seed"]:[],...e.unread?["what it does was not read"]:[]];return`${Ue[e.kind](e.name)} (${t.join("; ")})`}function Ot(e,r){if("error"in e)return[`target automation: what ${r} runs as these records are created could not be read (${e.error}): the emails they make it send are not known`];let{preview:t}=e,n=[`target automation: what ${r} runs as these records are created`];for(let o of t.objects)n.push(` ${o.objectApiName}: ${o.entries.map(Ke).join(", ")}`);t.objects.length===0&&n.push(t.blinded?" nothing found in what could be read":" nothing runs on them: no flow, Apex trigger, process or workflow rule"),t.bypassesHeld.length>0&&n.push(` bypass held: the user the seed writes as holds ${t.bypassesHeld.join(", ")}, and what names it stays quiet`);for(let o of t.bypasses)n.push(o.permissionSet?` bypass: ${o.permission} keeps quiet what names it; permission set ${o.permissionSet} holds it`:` bypass: ${o.permission} keeps quiet what names it; no permission set of ${r} was found to hold it`);t.alertsAsSingle&&t.emailsPerRecord.some(o=>o.alertsAmong)&&n.push(` ${r} counts its email alerts against its single emails too, as a Developer Edition does`);for(let{part:o,reason:s}of t.unread)n.push(` ${o} could not be read: ${s}`);return t.conditionsNotRead>0&&n.push(` ${t.conditionsNotRead} start condition(s) not read`),n}export{ze as a,rt as b,ot as c,st as d,at as e,ft as f,gt as g,ht as h,q as i,bt as j,yt as k,De as l,qe as m,wt as n,St as o,Ft as p,It as q,$t as r,Ot as s};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"./chunk-7QYHEHMA.mjs";import"./chunk-WXDLQT2O.mjs";import"./chunk-JE6SCT6R.mjs";import"./chunk-PWRJRL5U.mjs";import"./chunk-UIOMAX56.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-L53JWJ3S.mjs";import"./chunk-HIDW7FNV.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-H4CGM6YO.mjs";import"./chunk-YDXMTWAT.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-FP7CYB2F.mjs";import"./chunk-NED4MBIM.mjs";import"./chunk-UI3JQVRU.mjs";import"./chunk-KGU4SVIT.mjs";import"./chunk-JAEDM4SI.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-LC3NDW4N.mjs";import"./chunk-KB4ZHM4Q.mjs";import"./chunk-23SEDORH.mjs";import"./chunk-W6PN6TJG.mjs";import"./chunk-3Q353S2R.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-RHNTHGNU.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-Q7TLC3I2.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-D4GF4FAB.mjs";import"./chunk-CVHNXJH3.mjs";import"./chunk-YA6ATMTB.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-M6K34KGF.mjs";import"./chunk-TNT27RBG.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-S42RBRH2.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-WUUKFE2U.mjs";import"./chunk-EAC5QCE3.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{h as REWIND_MUTING_STEP_WORDS,g as REWIND_STEP_WORDS,i as acceptanceRefusal,j as boundsRefusal,k as boundsRefusals,e as firedCount,m as notConfirmedRefusal,a as objectsWrittenBy,b as previewTotals,f as remakeUnasked,d as rewindStepsOf,c as selectionDiff,l as undeletableUnattendedRefusal};
@@ -4,7 +4,7 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{b as X,e as Y}from"./chunk-FVLFO2S6.mjs";import{a as G,b as q,e as J,f as Q,j as L}from"./chunk-FQGHL7GR.mjs";import{Ha as A,Ja as N,Ka as Z,La as W}from"./chunk-6QSHWIZI.mjs";var O=class extends Error{constructor(t){super(`The scenario cannot be compiled: ${t.join("; ")}`);this.issues=t;this.name="ScenarioCompileError"}issues},ee="2026-10-28T00:00:00.000Z",x={subject:255,description:32e3,commentBody:4e3,articleTitle:255,articleSummary:1e3},ie=new Set(["Phone"]);function $e(e,n={}){let t=Z.safeParse(e),a=W.safeParse(n);if(!t.success||!a.success)throw new O([...t.error?.issues.map(i=>te(["pack",...i.path],i))??[],...a.error?.issues.map(i=>te(["options",...i.path],i))??[]]);let r=n.customers??e.customers.count;if(r<e.topics.length)throw new O([`options.customers: ${r} customer(s) for ${e.topics.length} topics: each topic's utterances are said about a customer's open case on it`]);let s=n.seed??A.seed,u=n.historyPerCustomer??A.historyPerCustomer,l=n.caseStatus??A.caseStatus,c=ge(e.language),o=ce(),p=e.id,m=e.topics,f=fe(p,r,c,s),S=f.map((i,d)=>({key:i.key,values:o.row({Name:i.company,Industry:e.customers.industry,Type:"Customer - Direct",Phone:L(c,2*d),Website:`https://www.${se(i.company)}`})})),$=f.map((i,d)=>({key:i.key,parentKey:i.key,values:o.row({FirstName:i.firstName,LastName:i.lastName,Email:i.email,Phone:L(c,2*d+1)})})),T=m.map(()=>0),k=[],M=[],D=[],z=[],F=i=>`${p}-article-${m[i].key}`;for(let[i,d]of f.entries()){let I=[...Array.from({length:u},(g,h)=>({topicIndex:(i+1+h)%m.length,key:`${d.key}-h${h+1}`,open:!1})),{topicIndex:i%m.length,key:`${d.key}-open`,open:!0}];for(let{topicIndex:g,key:h,open:j}of I){let U=m[g].caseTemplates,w=U[T[g]++%U.length],v=o.text(P(w.subject,d),x.subject),V={...d,caseSubject:v};k.push({key:h,parentKey:d.key,values:o.row({Subject:v,Description:o.text(P(w.description,V),x.description),Status:j?l.open:l.closed,Priority:w.priority,Origin:w.origin})}),M.push(...le(h,w,j,V,o)),j?D.push({key:h,subject:v,topicIndex:g,customer:d}):z.push({caseKey:h,articleKey:F(g)})}}let y=ue(n),_=[],oe=m.map((i,d)=>{if(!y)return;let I=i.article.facts.map(h=>o.text(h)),g=me(o.text(i.article.body),I,y);if(typeof g=="string")return g;_.push(`pack.topics[${d}].article.facts[${g.unfit}]: the fact "${i.article.facts[g.unfit]}" does not fit, with the facts before it, in the ${y.max} characters of ${y.name}, the field the article's body goes to in this org: shorten the facts, or give Knowledge a longer field for the body`)});if(_.length>0)throw new O(_);let H=[...m.map((i,d)=>({key:F(d),values:ne(i.article,`${p}-${i.key}-${s}`,e,o,y&&{name:y.name,text:oe[d]??""})})),{key:`${p}-decoy-article`,values:ne(e.decoy,`${p}-${s}-decoy`,e,o,y&&{name:y.name,text:de(o.text(e.decoy.body),o.text(e.decoy.summary),y)})}],ae={id:`scenario-${p}`,name:o.text(e.name),description:o.text(e.businessContext),version:1,strategy:"template",objects:[R("Account",0,S),R("Contact",1,$),R("Case",2,k),R("CaseComment",3,M),{...R("Knowledge__kav",4,H),optional:!0}],relations:[B("Contact","AccountId","Account"),B("Case","ContactId","Contact"),B("CaseComment","ParentId","Case")],tags:["scenario",p],createdAt:ee,updatedAt:ee};return{packId:p,seed:s,template:ae,tests:pe(e,D,F,H,o),closedCaseArticles:z}}function te(e,n){return`${e.reduce((a,r)=>typeof r=="number"?`${a}[${r}]`:`${a}.${String(r)}`,"").replace(/^\./,"")}: ${n.message}`}function ce(){let e=X(),n=new Map,t=r=>{let s=n.get(r);if(s!==void 0)return s;let u=e(r);return n.set(r,u),u},a=(r,s)=>Y(r,s,t);return{text(r,s){let u=a({text:r},new Set).text;return E(typeof u=="string"?u:r,s)},row(r){return a(r,ie)}}}function E(e,n){if(n===void 0||e.length<=n)return e;let t=e.slice(0,n);if(/\s/.test(e.charAt(n)))return t.trimEnd();let a=t.search(/\s\S*$/);return a>0?t.slice(0,a).trimEnd():t}function P(e,n){return e.replace(/\{([A-Za-z][A-Za-z0-9_]*)\}/g,(t,a)=>n[a]??t)}function le(e,n,t,a,r){return(t?[n.followUp]:n.resolution).map((u,l)=>({key:`${e}-${l+1}`,parentKey:e,values:{CommentBody:r.text(P(u,a),x.commentBody),IsPublished:!1}}))}function ne(e,n,t,a,r){let s={Title:a.text(e.title,x.articleTitle),UrlName:n,Summary:a.text(e.summary,x.articleSummary),Language:t.language,IsVisibleInPkb:!1,IsVisibleInCsp:!1,IsVisibleInPrm:!1};return r&&(s[r.name]=r.text),s}function ue(e){let n=e.articleBodyField;if(n===void 0)return;let t=e.articleBodyLength??(n==="Summary"?x.articleSummary:void 0);return{name:n,...t!==void 0?{max:t}:{},html:e.articleBodyHtml===!0}}function K(e){return e.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function C(e,n){return n.html?e.map(t=>`<p>${re(t)}</p>`).join(""):e.join(`
7
+ import{b as X,e as Y}from"./chunk-BBRWFKS5.mjs";import{a as G,b as q,e as J,f as Q,j as L}from"./chunk-FQGHL7GR.mjs";import{Ha as A,Ja as N,Ka as Z,La as W}from"./chunk-PMWAFDUB.mjs";var O=class extends Error{constructor(t){super(`The scenario cannot be compiled: ${t.join("; ")}`);this.issues=t;this.name="ScenarioCompileError"}issues},ee="2026-10-28T00:00:00.000Z",x={subject:255,description:32e3,commentBody:4e3,articleTitle:255,articleSummary:1e3},ie=new Set(["Phone"]);function $e(e,n={}){let t=Z.safeParse(e),a=W.safeParse(n);if(!t.success||!a.success)throw new O([...t.error?.issues.map(i=>te(["pack",...i.path],i))??[],...a.error?.issues.map(i=>te(["options",...i.path],i))??[]]);let r=n.customers??e.customers.count;if(r<e.topics.length)throw new O([`options.customers: ${r} customer(s) for ${e.topics.length} topics: each topic's utterances are said about a customer's open case on it`]);let s=n.seed??A.seed,u=n.historyPerCustomer??A.historyPerCustomer,l=n.caseStatus??A.caseStatus,c=ge(e.language),o=ce(),p=e.id,m=e.topics,f=fe(p,r,c,s),S=f.map((i,d)=>({key:i.key,values:o.row({Name:i.company,Industry:e.customers.industry,Type:"Customer - Direct",Phone:L(c,2*d),Website:`https://www.${se(i.company)}`})})),$=f.map((i,d)=>({key:i.key,parentKey:i.key,values:o.row({FirstName:i.firstName,LastName:i.lastName,Email:i.email,Phone:L(c,2*d+1)})})),T=m.map(()=>0),k=[],M=[],D=[],z=[],F=i=>`${p}-article-${m[i].key}`;for(let[i,d]of f.entries()){let I=[...Array.from({length:u},(g,h)=>({topicIndex:(i+1+h)%m.length,key:`${d.key}-h${h+1}`,open:!1})),{topicIndex:i%m.length,key:`${d.key}-open`,open:!0}];for(let{topicIndex:g,key:h,open:j}of I){let U=m[g].caseTemplates,w=U[T[g]++%U.length],v=o.text(P(w.subject,d),x.subject),V={...d,caseSubject:v};k.push({key:h,parentKey:d.key,values:o.row({Subject:v,Description:o.text(P(w.description,V),x.description),Status:j?l.open:l.closed,Priority:w.priority,Origin:w.origin})}),M.push(...le(h,w,j,V,o)),j?D.push({key:h,subject:v,topicIndex:g,customer:d}):z.push({caseKey:h,articleKey:F(g)})}}let y=ue(n),_=[],oe=m.map((i,d)=>{if(!y)return;let I=i.article.facts.map(h=>o.text(h)),g=me(o.text(i.article.body),I,y);if(typeof g=="string")return g;_.push(`pack.topics[${d}].article.facts[${g.unfit}]: the fact "${i.article.facts[g.unfit]}" does not fit, with the facts before it, in the ${y.max} characters of ${y.name}, the field the article's body goes to in this org: shorten the facts, or give Knowledge a longer field for the body`)});if(_.length>0)throw new O(_);let H=[...m.map((i,d)=>({key:F(d),values:ne(i.article,`${p}-${i.key}-${s}`,e,o,y&&{name:y.name,text:oe[d]??""})})),{key:`${p}-decoy-article`,values:ne(e.decoy,`${p}-${s}-decoy`,e,o,y&&{name:y.name,text:de(o.text(e.decoy.body),o.text(e.decoy.summary),y)})}],ae={id:`scenario-${p}`,name:o.text(e.name),description:o.text(e.businessContext),version:1,strategy:"template",objects:[R("Account",0,S),R("Contact",1,$),R("Case",2,k),R("CaseComment",3,M),{...R("Knowledge__kav",4,H),optional:!0}],relations:[B("Contact","AccountId","Account"),B("Case","ContactId","Contact"),B("CaseComment","ParentId","Case")],tags:["scenario",p],createdAt:ee,updatedAt:ee};return{packId:p,seed:s,template:ae,tests:pe(e,D,F,H,o),closedCaseArticles:z}}function te(e,n){return`${e.reduce((a,r)=>typeof r=="number"?`${a}[${r}]`:`${a}.${String(r)}`,"").replace(/^\./,"")}: ${n.message}`}function ce(){let e=X(),n=new Map,t=r=>{let s=n.get(r);if(s!==void 0)return s;let u=e(r);return n.set(r,u),u},a=(r,s)=>Y(r,s,t);return{text(r,s){let u=a({text:r},new Set).text;return E(typeof u=="string"?u:r,s)},row(r){return a(r,ie)}}}function E(e,n){if(n===void 0||e.length<=n)return e;let t=e.slice(0,n);if(/\s/.test(e.charAt(n)))return t.trimEnd();let a=t.search(/\s\S*$/);return a>0?t.slice(0,a).trimEnd():t}function P(e,n){return e.replace(/\{([A-Za-z][A-Za-z0-9_]*)\}/g,(t,a)=>n[a]??t)}function le(e,n,t,a,r){return(t?[n.followUp]:n.resolution).map((u,l)=>({key:`${e}-${l+1}`,parentKey:e,values:{CommentBody:r.text(P(u,a),x.commentBody),IsPublished:!1}}))}function ne(e,n,t,a,r){let s={Title:a.text(e.title,x.articleTitle),UrlName:n,Summary:a.text(e.summary,x.articleSummary),Language:t.language,IsVisibleInPkb:!1,IsVisibleInCsp:!1,IsVisibleInPrm:!1};return r&&(s[r.name]=r.text),s}function ue(e){let n=e.articleBodyField;if(n===void 0)return;let t=e.articleBodyLength??(n==="Summary"?x.articleSummary:void 0);return{name:n,...t!==void 0?{max:t}:{},html:e.articleBodyHtml===!0}}function K(e){return e.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function C(e,n){return n.html?e.map(t=>`<p>${re(t)}</p>`).join(""):e.join(`
8
8
 
9
9
  `)}function re(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function b(e,n){return n.max===void 0||e.length<=n.max}function me(e,n,t){let a=K(e),r=t.html?C(a,t):e;if(b(r,t))return r;let s=a.filter(c=>n.some(o=>N(c,o)));if(n.every(c=>N(s.join(`
10
10