sandforge 1.81.0 → 1.83.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/README.md +48 -0
  2. package/bin/sandforge-users.mjs +12 -0
  3. package/lib/{chunk-J6G23RUI.mjs → chunk-262TP6UU.mjs} +1 -1
  4. package/lib/{chunk-NWVVCZUK.mjs → chunk-27BBEGUD.mjs} +1 -1
  5. package/lib/{chunk-Y5ZCPY36.mjs → chunk-2ADSD5WK.mjs} +1 -1
  6. package/lib/{chunk-55LQD3Y3.mjs → chunk-2GSMHGIV.mjs} +1 -1
  7. package/lib/chunk-2K5BYZQM.mjs +8 -0
  8. package/lib/{chunk-GK7VEYFM.mjs → chunk-2KTGDYUH.mjs} +1 -1
  9. package/lib/{chunk-T3PLRQ2T.mjs → chunk-2N73W63D.mjs} +1 -1
  10. package/lib/{chunk-7PK5QDQI.mjs → chunk-2R6GFNKF.mjs} +1 -1
  11. package/lib/{chunk-2OIRJEYE.mjs → chunk-2WMKJVD2.mjs} +1 -1
  12. package/lib/{chunk-D62KWDDT.mjs → chunk-36Y225OM.mjs} +1 -1
  13. package/lib/{chunk-HYOOJVR6.mjs → chunk-3CM7LAPE.mjs} +1 -1
  14. package/lib/{chunk-OIIL4NVI.mjs → chunk-3OVTKRS4.mjs} +1 -1
  15. package/lib/{chunk-UT27HXE7.mjs → chunk-3V4YH5KO.mjs} +1 -1
  16. package/lib/{chunk-OZNLOV4U.mjs → chunk-446GBKAC.mjs} +1 -1
  17. package/lib/{chunk-SQGP46QS.mjs → chunk-4GCYGQXD.mjs} +1 -1
  18. package/lib/{chunk-2NAIUKVL.mjs → chunk-4V3QO7HF.mjs} +1 -1
  19. package/lib/{chunk-GWRKS3AL.mjs → chunk-4X5D3MSV.mjs} +1 -1
  20. package/lib/{chunk-KGYXLSQ5.mjs → chunk-5OGNK3JP.mjs} +1 -1
  21. package/lib/{chunk-D7P7DTWL.mjs → chunk-6KOUYHEY.mjs} +1 -1
  22. package/lib/chunk-6QSHWIZI.mjs +48 -0
  23. package/lib/chunk-6VOQFISN.mjs +7 -0
  24. package/lib/{chunk-742SSN7I.mjs → chunk-6YC2ELCU.mjs} +1 -1
  25. package/lib/chunk-77IVKH7R.mjs +7 -0
  26. package/lib/{chunk-KNIRA333.mjs → chunk-77MZRBWX.mjs} +1 -1
  27. package/lib/{chunk-ZUA5BNAO.mjs → chunk-7BQMBXKX.mjs} +1 -1
  28. package/lib/{chunk-OQQHNYR7.mjs → chunk-7DPHZWA4.mjs} +2 -2
  29. package/lib/chunk-7V2UYZ6S.mjs +7 -0
  30. package/lib/chunk-7WSQ65WG.mjs +9 -0
  31. package/lib/{chunk-HVC5CYIB.mjs → chunk-7ZBDACVG.mjs} +1 -1
  32. package/lib/chunk-A32ISQ6M.mjs +28 -0
  33. package/lib/{chunk-XC2QKQT5.mjs → chunk-AG24QMSY.mjs} +1 -1
  34. package/lib/{chunk-K77NR3UK.mjs → chunk-AHUGG3WU.mjs} +1 -1
  35. package/lib/{chunk-K55LH4ZQ.mjs → chunk-ALBY5SOH.mjs} +1 -1
  36. package/lib/chunk-AXFD2OH6.mjs +7 -0
  37. package/lib/{chunk-YCSFP6ER.mjs → chunk-BH76USTQ.mjs} +1 -1
  38. package/lib/chunk-BNKT3R3F.mjs +7 -0
  39. package/lib/{chunk-YIGFYZQY.mjs → chunk-BPHTA6KP.mjs} +1 -1
  40. package/lib/{chunk-MNITSYI2.mjs → chunk-BT43WSOS.mjs} +1 -1
  41. package/lib/{chunk-ZWZXQTAK.mjs → chunk-BVZ5H3N4.mjs} +14 -14
  42. package/lib/{chunk-43K2C6H2.mjs → chunk-C6RKM4BB.mjs} +1 -1
  43. package/lib/{chunk-C4YGSK6W.mjs → chunk-CDWZGQAJ.mjs} +1 -1
  44. package/lib/chunk-CGZGL6VT.mjs +7 -0
  45. package/lib/{chunk-KE2PGD6C.mjs → chunk-CN5HGFG4.mjs} +1 -1
  46. package/lib/chunk-CQAFVEKP.mjs +13 -0
  47. package/lib/{chunk-XIZ5LMQM.mjs → chunk-CTPLYUXA.mjs} +1 -1
  48. package/lib/chunk-CXKZ6TYV.mjs +9 -0
  49. package/lib/{chunk-DHIW4IO5.mjs → chunk-D6JT4PAB.mjs} +1 -1
  50. package/lib/{chunk-AELFEK3G.mjs → chunk-D7XUNWWU.mjs} +1 -1
  51. package/lib/{chunk-GR3NGDVM.mjs → chunk-DB5RVDC5.mjs} +1 -1
  52. package/lib/{chunk-MO3N5XVV.mjs → chunk-DIGUC7S4.mjs} +2 -2
  53. package/lib/{chunk-2OZG6GRW.mjs → chunk-DKDKCGXV.mjs} +1 -1
  54. package/lib/chunk-DMT5SCO3.mjs +7 -0
  55. package/lib/chunk-DNQKVCUV.mjs +475 -0
  56. package/lib/{chunk-MAHZMPMZ.mjs → chunk-DSR2MSBH.mjs} +1 -1
  57. package/lib/{chunk-O6ADMP36.mjs → chunk-E3RQ575Y.mjs} +1 -1
  58. package/lib/{chunk-ETT5GP4P.mjs → chunk-EOQON3E5.mjs} +1 -1
  59. package/lib/{chunk-TKQQVB2D.mjs → chunk-ETNQHIDI.mjs} +1 -1
  60. package/lib/chunk-F5SBGJWW.mjs +7 -0
  61. package/lib/chunk-FBXH4VRQ.mjs +7 -0
  62. package/lib/chunk-FKCIGJOI.mjs +15 -0
  63. package/lib/{chunk-OVOLG3AL.mjs → chunk-FVLFO2S6.mjs} +1 -1
  64. package/lib/{chunk-YOGMP72T.mjs → chunk-FYWNSMOZ.mjs} +1 -1
  65. package/lib/{chunk-DHGPDSXS.mjs → chunk-GEEWPTV5.mjs} +1 -1
  66. package/lib/{chunk-FSDO4DJA.mjs → chunk-GLN4PI5P.mjs} +1 -1
  67. package/lib/{chunk-PYUEHBA6.mjs → chunk-GT5ZKU6V.mjs} +1 -1
  68. package/lib/chunk-GTRU5AV5.mjs +7 -0
  69. package/lib/chunk-H33DVU3D.mjs +7 -0
  70. package/lib/{chunk-5WGA5CZB.mjs → chunk-H4OBZIX3.mjs} +1 -1
  71. package/lib/{chunk-4L7FBOJS.mjs → chunk-HQZUQXDC.mjs} +1 -1
  72. package/lib/{chunk-VSU74RQ3.mjs → chunk-HVX2AFYW.mjs} +1 -1
  73. package/lib/chunk-I3ZO76LL.mjs +21 -0
  74. package/lib/{chunk-V4RKM4QZ.mjs → chunk-I5C4O3VA.mjs} +1 -1
  75. package/lib/{chunk-FSZTXLNW.mjs → chunk-IHGYJZZ2.mjs} +1 -1
  76. package/lib/chunk-ISA2NYJV.mjs +7 -0
  77. package/lib/{chunk-2IB7I3IQ.mjs → chunk-ISAUCWYK.mjs} +1 -1
  78. package/lib/{chunk-3B5H24ZG.mjs → chunk-ISOSTAJR.mjs} +1 -1
  79. package/lib/chunk-IXIY6Q4M.mjs +7 -0
  80. package/lib/{chunk-TPHXRHOA.mjs → chunk-J3TIHLWG.mjs} +1 -1
  81. package/lib/{chunk-TQM2XJ27.mjs → chunk-JAV6F6OA.mjs} +1 -1
  82. package/lib/chunk-JBWJ6UEZ.mjs +7 -0
  83. package/lib/{chunk-WM5JI4JI.mjs → chunk-JH4ZTVQN.mjs} +1 -1
  84. package/lib/{chunk-BZFIOZS3.mjs → chunk-JIPT5FUD.mjs} +1 -1
  85. package/lib/{chunk-6FMLW7PH.mjs → chunk-JPEVIXNH.mjs} +1 -1
  86. package/lib/{chunk-67CC7RAE.mjs → chunk-JREKJO3D.mjs} +1 -1
  87. package/lib/{chunk-3AOKLIVE.mjs → chunk-JUOQUG7U.mjs} +1 -1
  88. package/lib/chunk-JYUMD357.mjs +7 -0
  89. package/lib/{chunk-56MPPWLA.mjs → chunk-K7G3W7XH.mjs} +1 -1
  90. package/lib/{chunk-OU5W7SCB.mjs → chunk-KKS2KFBT.mjs} +1 -1
  91. package/lib/{chunk-RKALOKAU.mjs → chunk-KWAVSZ2B.mjs} +1 -1
  92. package/lib/{chunk-WI4HYWV6.mjs → chunk-KXUOHACP.mjs} +1 -1
  93. package/lib/{chunk-GTIXJCGS.mjs → chunk-L3I6DAHX.mjs} +1 -1
  94. package/lib/{chunk-FLNLG43R.mjs → chunk-L47JCNP3.mjs} +1 -1
  95. package/lib/{chunk-5344TZBT.mjs → chunk-L4MSL4U7.mjs} +1 -1
  96. package/lib/chunk-L4RJX7DG.mjs +7 -0
  97. package/lib/chunk-L6CLN664.mjs +7 -0
  98. package/lib/chunk-LI2XNV7F.mjs +7 -0
  99. package/lib/chunk-LP2D3JJP.mjs +7 -0
  100. package/lib/{chunk-EH5YUA5W.mjs → chunk-LWES2KZE.mjs} +1 -1
  101. package/lib/{chunk-YJEXE6HZ.mjs → chunk-LYOGCIYD.mjs} +2 -2
  102. package/lib/{chunk-BNO5GIJ6.mjs → chunk-MJD6CPZZ.mjs} +1 -1
  103. package/lib/{chunk-33ZX3A56.mjs → chunk-MTM4KG3T.mjs} +1 -1
  104. package/lib/{chunk-E2YJVSX6.mjs → chunk-N2HYG3BL.mjs} +1 -1
  105. package/lib/chunk-N5UIE4IR.mjs +7 -0
  106. package/lib/{chunk-R6TF26V4.mjs → chunk-NDFFIJL5.mjs} +1 -1
  107. package/lib/{chunk-FDGFUEK3.mjs → chunk-NFEBX75O.mjs} +1 -1
  108. package/lib/{chunk-QXLZINZB.mjs → chunk-NNV7IGM7.mjs} +1 -1
  109. package/lib/{chunk-OXKZ4Y3B.mjs → chunk-NS6ONPWL.mjs} +1 -1
  110. package/lib/{chunk-OEHVAJAB.mjs → chunk-O7GCCRPW.mjs} +1 -1
  111. package/lib/chunk-OO24ZYYJ.mjs +7 -0
  112. package/lib/chunk-OOIDCHBQ.mjs +9 -0
  113. package/lib/{chunk-MWLFFVQV.mjs → chunk-OS5GE52G.mjs} +1 -1
  114. package/lib/chunk-OS6HFJ7L.mjs +7 -0
  115. package/lib/{chunk-HYBH5PFM.mjs → chunk-OTJH6AEA.mjs} +1 -1
  116. package/lib/chunk-OUU47Y7A.mjs +7 -0
  117. package/lib/{chunk-FTA5LOVX.mjs → chunk-P6WRYJN3.mjs} +1 -1
  118. package/lib/{chunk-DXOXLUZA.mjs → chunk-PDRXM5WN.mjs} +1 -1
  119. package/lib/chunk-PGRY365W.mjs +7 -0
  120. package/lib/chunk-Q4PPI3KG.mjs +7 -0
  121. package/lib/chunk-QFTF2PGS.mjs +21 -0
  122. package/lib/chunk-QKJXIY6L.mjs +7 -0
  123. package/lib/{chunk-DMBR24CK.mjs → chunk-QLRWU3MB.mjs} +1 -1
  124. package/lib/chunk-QO4MPHZD.mjs +7 -0
  125. package/lib/chunk-QP3JLFIO.mjs +7 -0
  126. package/lib/{chunk-UCHAZ4ZU.mjs → chunk-QQDZQCO2.mjs} +1 -1
  127. package/lib/chunk-QROPNEGY.mjs +14 -0
  128. package/lib/{chunk-6NADW3OI.mjs → chunk-QXB6U3ZP.mjs} +1 -1
  129. package/lib/chunk-R3OM3X4L.mjs +8 -0
  130. package/lib/chunk-R7GKMAT4.mjs +7 -0
  131. package/lib/{chunk-JU2XEKEO.mjs → chunk-RVCPQVKM.mjs} +1 -1
  132. package/lib/{chunk-WEZLXE34.mjs → chunk-RZKJQOOC.mjs} +1 -1
  133. package/lib/chunk-S4PRKKGC.mjs +8 -0
  134. package/lib/{chunk-NJ3EOEHS.mjs → chunk-SX6QWYCQ.mjs} +1 -1
  135. package/lib/{chunk-ONMBSACW.mjs → chunk-T36DZJPH.mjs} +1 -1
  136. package/lib/{chunk-AJPSGVMD.mjs → chunk-T7DDS4UQ.mjs} +1 -1
  137. package/lib/chunk-TCEXCHXR.mjs +7 -0
  138. package/lib/chunk-TMIESDE5.mjs +7 -0
  139. package/lib/chunk-TQJ5NPRC.mjs +7 -0
  140. package/lib/chunk-TUPZY2QJ.mjs +7 -0
  141. package/lib/{chunk-2Z54GB6X.mjs → chunk-U2CTKIPE.mjs} +1 -1
  142. package/lib/{chunk-DQR5NDMI.mjs → chunk-U4YFYSF3.mjs} +1 -1
  143. package/lib/{chunk-EOSEMFPU.mjs → chunk-UIR77ZJD.mjs} +1 -1
  144. package/lib/{chunk-UUSLTW5V.mjs → chunk-UOHZW2L4.mjs} +1 -1
  145. package/lib/chunk-UV74P4H2.mjs +7 -0
  146. package/lib/{chunk-CULAOP3U.mjs → chunk-VXZ5PTOM.mjs} +1 -1
  147. package/lib/{chunk-IBURU7T7.mjs → chunk-VZLJZEV2.mjs} +1 -1
  148. package/lib/chunk-W3BQGMTR.mjs +7 -0
  149. package/lib/{chunk-WWTXRWNZ.mjs → chunk-WABXKL4N.mjs} +1 -1
  150. package/lib/{chunk-E2OBAWSH.mjs → chunk-WAYQLQAD.mjs} +1 -1
  151. package/lib/{chunk-6CDIIFNX.mjs → chunk-WBELLGNE.mjs} +1 -1
  152. package/lib/{chunk-LO527YLT.mjs → chunk-WJAZ5LHL.mjs} +1 -1
  153. package/lib/{chunk-6IGEASOF.mjs → chunk-WXU6ZJIV.mjs} +1 -1
  154. package/lib/{chunk-YHIOS2PU.mjs → chunk-WZN36ACK.mjs} +1 -1
  155. package/lib/{chunk-AITNZWLB.mjs → chunk-X2XZQ434.mjs} +1 -1
  156. package/lib/chunk-X4HZD5U2.mjs +7 -0
  157. package/lib/chunk-X6XNTOGO.mjs +7 -0
  158. package/lib/{chunk-5VQNKDFU.mjs → chunk-XAMMIPZ4.mjs} +1 -1
  159. package/lib/{chunk-MHW6DV6T.mjs → chunk-XAUQXYPW.mjs} +1 -1
  160. package/lib/{chunk-5UT2ZBGF.mjs → chunk-XCJUNX63.mjs} +1 -1
  161. package/lib/chunk-XJICAOAQ.mjs +7 -0
  162. package/lib/{chunk-GYKNCYES.mjs → chunk-XKFHTBAB.mjs} +1 -1
  163. package/lib/{chunk-6SEDOIO3.mjs → chunk-XMQ5R6TC.mjs} +1 -1
  164. package/lib/chunk-XPXEQKLR.mjs +7 -0
  165. package/lib/{chunk-SW2NUKQL.mjs → chunk-Y7YUNRKK.mjs} +1 -1
  166. package/lib/{chunk-UIUPPEFB.mjs → chunk-YBZIDW6W.mjs} +1 -1
  167. package/lib/{chunk-X2ZVSQ54.mjs → chunk-YEVB7LVK.mjs} +1 -1
  168. package/lib/{chunk-EAFLDSQ2.mjs → chunk-Z3MGN42K.mjs} +1 -1
  169. package/lib/{chunk-MKNAZPOT.mjs → chunk-ZB5E7NHU.mjs} +1 -1
  170. package/lib/chunk-ZCOSME6P.mjs +7 -0
  171. package/lib/{chunk-KRNFVAGC.mjs → chunk-ZOSESZ22.mjs} +1 -1
  172. package/lib/chunk-ZTHC42X6.mjs +7 -0
  173. package/lib/{chunk-XEB6HZ34.mjs → chunk-ZXOUWHYE.mjs} +1 -1
  174. package/lib/sandforge-autopilot.mjs +1 -1
  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 +1 -1
  180. package/lib/sandforge-dataops.mjs +1 -1
  181. package/lib/sandforge-empty.mjs +4 -4
  182. package/lib/sandforge-env.mjs +184 -139
  183. package/lib/sandforge-frozen.mjs +1 -1
  184. package/lib/sandforge-mcp.mjs +14 -14
  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 +155 -0
  190. package/lib/sandforge.mjs +1 -22
  191. package/lib/sf/sandforge/autopilot.mjs +20 -0
  192. package/lib/sf/sandforge/backup.mjs +20 -0
  193. package/lib/sf/sandforge/checkpoint.mjs +20 -0
  194. package/lib/sf/sandforge/cleanup.mjs +20 -0
  195. package/lib/sf/sandforge/clone.mjs +20 -0
  196. package/lib/sf/sandforge/compare.mjs +20 -0
  197. package/lib/sf/sandforge/dataops.mjs +20 -0
  198. package/lib/sf/sandforge/empty.mjs +20 -0
  199. package/lib/sf/sandforge/env.mjs +20 -0
  200. package/lib/sf/sandforge/frozen.mjs +20 -0
  201. package/lib/sf/sandforge/hardis-commands.mjs +20 -0
  202. package/lib/sf/sandforge/index.mjs +20 -0
  203. package/lib/sf/sandforge/mcp.mjs +20 -0
  204. package/lib/sf/sandforge/monitor.mjs +20 -0
  205. package/lib/sf/sandforge/pipeline.mjs +20 -0
  206. package/lib/sf/sandforge/seed.mjs +20 -0
  207. package/lib/sf/sandforge/sync.mjs +20 -0
  208. package/lib/sf/sandforge/users.mjs +20 -0
  209. package/lib/sfHelpHook.mjs +7 -0
  210. package/lib/sfPlugin.mjs +11 -0
  211. package/oclif.manifest.json +1 -0
  212. package/package.json +17 -3
  213. package/lib/chunk-2ZMGVBLW.mjs +0 -7
  214. package/lib/chunk-5C5XEVZN.mjs +0 -11
  215. package/lib/chunk-5CKWGZX4.mjs +0 -9
  216. package/lib/chunk-5ZKCLBTN.mjs +0 -474
  217. package/lib/chunk-7DALDJMO.mjs +0 -7
  218. package/lib/chunk-CAFUNR6D.mjs +0 -7
  219. package/lib/chunk-DPYTG6DM.mjs +0 -48
  220. package/lib/chunk-G4VXPS3A.mjs +0 -7
  221. package/lib/chunk-GF247DA7.mjs +0 -7
  222. package/lib/chunk-IKGHRYCN.mjs +0 -7
  223. package/lib/chunk-IM2XA6JI.mjs +0 -7
  224. package/lib/chunk-K5HV4YRO.mjs +0 -7
  225. package/lib/chunk-KOQV4WXC.mjs +0 -8
  226. package/lib/chunk-N6HHNR6J.mjs +0 -7
  227. package/lib/chunk-N7J6NJQ6.mjs +0 -7
  228. package/lib/chunk-NWPQF5XR.mjs +0 -7
  229. package/lib/chunk-O7DAFE6M.mjs +0 -14
  230. package/lib/chunk-OMZJ37JI.mjs +0 -15
  231. package/lib/chunk-R2BJWO5N.mjs +0 -20
  232. package/lib/chunk-T26C576X.mjs +0 -9
  233. package/lib/chunk-T5VAULLQ.mjs +0 -7
  234. package/lib/chunk-V2QO6KOE.mjs +0 -19
  235. package/lib/chunk-V473C7LY.mjs +0 -7
  236. package/lib/chunk-W2AAGIZF.mjs +0 -7
  237. package/lib/chunk-WD47PGUS.mjs +0 -10
  238. package/lib/chunk-XC54KKKC.mjs +0 -7
  239. package/lib/chunk-XGKSSCW7.mjs +0 -7
  240. package/lib/chunk-ZWCRWF7E.mjs +0 -7
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{A as y,B as z,C as A,D as B,E as C,F as D,G as E,H as F,I as G,J as H,K as I,L as J,M as K,N as L,O as M,P as N,Q as O,c as a,d as b,e as c,f as d,g as e,h as f,i as g,j as h,k as i,l as j,m as k,n as l,o as m,p as n,q as o,r as p,s as q,t as r,u as s,v as t,w as u,x as v,y as w,z as x}from"./chunk-E2YJVSX6.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-3B5H24ZG.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as CHECKPOINT_DIR_MODE,b as CHECKPOINT_FILE_MODE,r as CHECKPOINT_FILE_PATH,F as CheckpointStoreError,c as DEFAULT_KEEP_DAYS,d as EXPIRY_WARNING_DAYS,K as OrgCheckpointStore,f as PREVIEW_KEEP_MS,e as RECYCLE_BIN_DAYS,q as REPLAY_ANNEX_PATH,N as acquireOrgLock,m as binFileOf,C as binReachSince,I as compressedFieldPrints,h as defaultCheckpointLocksDir,g as defaultCheckpointStoreRoot,z as expiresAtFor,B as expiresSoon,u as exportedFileIn,t as exportedFilesOf,n as filesDocumentsFileOf,o as filesLinksFileOf,j as indexFileOf,A as isExpired,s as isExportedPath,L as latestRewindOf,x as makePrivateDir,y as newFolderId,l as notInBinFileOf,J as openCheckpointStore,M as orgLockFileOf,O as orgLockHolder,i as organizationKey,v as previewDirOf,H as readFieldPrints,k as recreatedFileOf,p as replayAnnexFileOf,w as rewindDirOf,D as scratchOrgExpired,E as scratchOrgExpiresSoon,G as storeRefusalWords};
7
+ import{A as y,B as z,C as A,D as B,E as C,F as D,G as E,H as F,I as G,J as H,K as I,L as J,M as K,N as L,O as M,P as N,Q as O,c as a,d as b,e as c,f as d,g as e,h as f,i as g,j as h,k as i,l as j,m as k,n as l,o as m,p as n,q as o,r as p,s as q,t as r,u as s,v as t,w as u,x as v,y as w,z as x}from"./chunk-N2HYG3BL.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-ISOSTAJR.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as CHECKPOINT_DIR_MODE,b as CHECKPOINT_FILE_MODE,r as CHECKPOINT_FILE_PATH,F as CheckpointStoreError,c as DEFAULT_KEEP_DAYS,d as EXPIRY_WARNING_DAYS,K as OrgCheckpointStore,f as PREVIEW_KEEP_MS,e as RECYCLE_BIN_DAYS,q as REPLAY_ANNEX_PATH,N as acquireOrgLock,m as binFileOf,C as binReachSince,I as compressedFieldPrints,h as defaultCheckpointLocksDir,g as defaultCheckpointStoreRoot,z as expiresAtFor,B as expiresSoon,u as exportedFileIn,t as exportedFilesOf,n as filesDocumentsFileOf,o as filesLinksFileOf,j as indexFileOf,A as isExpired,s as isExportedPath,L as latestRewindOf,x as makePrivateDir,y as newFolderId,l as notInBinFileOf,J as openCheckpointStore,M as orgLockFileOf,O as orgLockHolder,i as organizationKey,v as previewDirOf,H as readFieldPrints,k as recreatedFileOf,p as replayAnnexFileOf,w as rewindDirOf,D as scratchOrgExpired,E as scratchOrgExpiresSoon,G as storeRefusalWords};
@@ -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 N,e as k}from"./chunk-OVOLG3AL.mjs";import{l as y}from"./chunk-FQGHL7GR.mjs";var S=class{deps;constructor(t){this.deps=t}async mapFields(t,n,r,i=0,a){let{recordCount:s,fieldRules:f,rows:d}=t;if(s<=0||f.length===0&&!d)return[];let u=f.filter(o=>o.ruleType==="ai_generate"),g=f.filter(o=>o.ruleType==="faker"),R=N(),O=f.filter(o=>o.ruleType!=="ai_generate"&&o.ruleType!=="faker").map(o=>G(o,R)),p=u.length>0?await this.deps.aiGenerator.generate(u,s):[],b=g.length>0?this.deps.fakerFallback.generate(g,s,i):[],m=I(u,p,s),V=m?this.deps.fakerFallback.generate(u.map(q),s,i):[];m&&r?.({fields:C(u,p,s),reason:p.length===0?"no-answer":"short-answer"});let D=[...u,...g],x=this.deps.random??Math.random,_=E(t),F=d?P(f,R,a):void 0,w=[];for(let o=0;o<s;o++){let l={};for(let c of O)l[c.fieldApiName]=L(c,i+o,n,x);p[o]&&Object.assign(l,p[o]);for(let c of m?u:[])(l[c.fieldApiName]===void 0||l[c.fieldApiName]===null)&&(l[c.fieldApiName]=V[o]?.[c.fieldApiName]??null);b[o]&&Object.assign(l,b[o]);for(let c of D)l[c.fieldApiName]=M(l[c.fieldApiName],c.config.maxLength);_&&typeof l[h]=="string"&&(l[T]=this.deps.fakerFallback.dateOf(j.test(l[h])?"pastDate":"futureDate"));let A=d?.[i+o];A&&F&&Object.assign(l,F(A)),w.push(l)}return w}};function P(e,t,n){let r=new Set(e.filter(a=>a.fieldType?.toLowerCase()==="phone").map(a=>a.fieldApiName)),i=new Map(e.flatMap(a=>a.config.maxLength!==void 0?[[a.fieldApiName,a.config.maxLength]]:[]));return a=>{let s=k(a.values,r,t);for(let[f,d]of Object.entries(s))s[f]=M(d,n?.get(f)??i.get(f));return s}}var h="StageName",T="CloseDate",j=/closed/i;function E(e){return e.objectApiName!=="Opportunity"?!1:e.fieldRules.find(n=>n.fieldApiName===T)?.ruleType==="faker"&&e.fieldRules.some(n=>n.fieldApiName===h)}function G(e,t){let n=e.config.picklistValues;if(e.ruleType!=="picklist_random"||!n)return e;let r=new Set(e.fieldType?.toLowerCase()==="phone"?[e.fieldApiName]:[]),i=n.map(a=>{let s=k({[e.fieldApiName]:a},r,t)[e.fieldApiName];return typeof s=="string"?s:a});return{...e,config:{...e.config,picklistValues:i}}}function M(e,t){if(typeof e!="string"||t===void 0||t<=0||e.length<=t)return e;let n=e.slice(0,t);if(/\s/.test(e.charAt(t)))return n.trimEnd();let r=n.search(/\s\S*$/);return r>0?n.slice(0,r).trimEnd():n}function C(e,t,n){return e.filter(r=>Array.from({length:n},(i,a)=>t[a]?.[r.fieldApiName]).some(i=>i==null)).map(r=>r.fieldApiName)}function I(e,t,n){return e.length===0?!1:t.length<n?!0:t.some(r=>e.some(i=>r[i.fieldApiName]===void 0||r[i.fieldApiName]===null))}function q(e){return{fieldApiName:e.fieldApiName,ruleType:"faker",config:{fakerMethod:"sentence"}}}function L(e,t,n,r=Math.random){switch(e.ruleType){case"static":return e.config.staticValue??null;case"random":return $(e,r);case"sequence":return U(e,t);case"picklist_random":return v(e,r);case"reference":return z(e,n,r);case"formula":return e.config.formula??null;case"regex":return Y(e,t);case"from_csv":return null;default:return null}}function $(e,t){let n=e.config.minValue??0,r=e.config.maxValue??1e3;return Math.floor(n+t()*(r-n+1))}function U(e,t){let n=e.config.sequenceStart??1,r=e.config.sequenceStep??1;return`${e.config.sequencePrefix??""}${n+t*r}`}function Y(e,t){let n=e.config.regexPattern;return n?y(n,t):null}function v(e,t){let n=e.config.picklistValues;if(!n||n.length===0)return null;let r=Math.floor(t()*n.length);return n[r]}function z(e,t,n){let r=e.config.referenceObject;if(!r)return null;let i=t.get(r);if(!i||i.length===0)return null;let a=Math.floor(n()*i.length);return i[a]}export{S as a,L as b};
7
+ import{b as N,e as k}from"./chunk-FVLFO2S6.mjs";import{l as y}from"./chunk-FQGHL7GR.mjs";var S=class{deps;constructor(t){this.deps=t}async mapFields(t,n,r,i=0,a){let{recordCount:s,fieldRules:f,rows:d}=t;if(s<=0||f.length===0&&!d)return[];let u=f.filter(o=>o.ruleType==="ai_generate"),g=f.filter(o=>o.ruleType==="faker"),R=N(),O=f.filter(o=>o.ruleType!=="ai_generate"&&o.ruleType!=="faker").map(o=>G(o,R)),p=u.length>0?await this.deps.aiGenerator.generate(u,s):[],b=g.length>0?this.deps.fakerFallback.generate(g,s,i):[],m=I(u,p,s),V=m?this.deps.fakerFallback.generate(u.map(q),s,i):[];m&&r?.({fields:C(u,p,s),reason:p.length===0?"no-answer":"short-answer"});let D=[...u,...g],x=this.deps.random??Math.random,_=E(t),F=d?P(f,R,a):void 0,w=[];for(let o=0;o<s;o++){let l={};for(let c of O)l[c.fieldApiName]=L(c,i+o,n,x);p[o]&&Object.assign(l,p[o]);for(let c of m?u:[])(l[c.fieldApiName]===void 0||l[c.fieldApiName]===null)&&(l[c.fieldApiName]=V[o]?.[c.fieldApiName]??null);b[o]&&Object.assign(l,b[o]);for(let c of D)l[c.fieldApiName]=M(l[c.fieldApiName],c.config.maxLength);_&&typeof l[h]=="string"&&(l[T]=this.deps.fakerFallback.dateOf(j.test(l[h])?"pastDate":"futureDate"));let A=d?.[i+o];A&&F&&Object.assign(l,F(A)),w.push(l)}return w}};function P(e,t,n){let r=new Set(e.filter(a=>a.fieldType?.toLowerCase()==="phone").map(a=>a.fieldApiName)),i=new Map(e.flatMap(a=>a.config.maxLength!==void 0?[[a.fieldApiName,a.config.maxLength]]:[]));return a=>{let s=k(a.values,r,t);for(let[f,d]of Object.entries(s))s[f]=M(d,n?.get(f)??i.get(f));return s}}var h="StageName",T="CloseDate",j=/closed/i;function E(e){return e.objectApiName!=="Opportunity"?!1:e.fieldRules.find(n=>n.fieldApiName===T)?.ruleType==="faker"&&e.fieldRules.some(n=>n.fieldApiName===h)}function G(e,t){let n=e.config.picklistValues;if(e.ruleType!=="picklist_random"||!n)return e;let r=new Set(e.fieldType?.toLowerCase()==="phone"?[e.fieldApiName]:[]),i=n.map(a=>{let s=k({[e.fieldApiName]:a},r,t)[e.fieldApiName];return typeof s=="string"?s:a});return{...e,config:{...e.config,picklistValues:i}}}function M(e,t){if(typeof e!="string"||t===void 0||t<=0||e.length<=t)return e;let n=e.slice(0,t);if(/\s/.test(e.charAt(t)))return n.trimEnd();let r=n.search(/\s\S*$/);return r>0?n.slice(0,r).trimEnd():n}function C(e,t,n){return e.filter(r=>Array.from({length:n},(i,a)=>t[a]?.[r.fieldApiName]).some(i=>i==null)).map(r=>r.fieldApiName)}function I(e,t,n){return e.length===0?!1:t.length<n?!0:t.some(r=>e.some(i=>r[i.fieldApiName]===void 0||r[i.fieldApiName]===null))}function q(e){return{fieldApiName:e.fieldApiName,ruleType:"faker",config:{fakerMethod:"sentence"}}}function L(e,t,n,r=Math.random){switch(e.ruleType){case"static":return e.config.staticValue??null;case"random":return $(e,r);case"sequence":return U(e,t);case"picklist_random":return v(e,r);case"reference":return z(e,n,r);case"formula":return e.config.formula??null;case"regex":return Y(e,t);case"from_csv":return null;default:return null}}function $(e,t){let n=e.config.minValue??0,r=e.config.maxValue??1e3;return Math.floor(n+t()*(r-n+1))}function U(e,t){let n=e.config.sequenceStart??1,r=e.config.sequenceStep??1;return`${e.config.sequencePrefix??""}${n+t*r}`}function Y(e,t){let n=e.config.regexPattern;return n?y(n,t):null}function v(e,t){let n=e.config.picklistValues;if(!n||n.length===0)return null;let r=Math.floor(t()*n.length);return n[r]}function z(e,t,n){let r=e.config.referenceObject;if(!r)return null;let i=t.get(r);if(!i||i.length===0)return null;let a=Math.floor(n()*i.length);return i[a]}export{S as a,L as b};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{f as m,h as u}from"./chunk-TZE3Y7IQ.mjs";import{b as $}from"./chunk-CA5NAXSU.mjs";import{e as l}from"./chunk-DPYTG6DM.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-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};
@@ -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 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};
@@ -4,6 +4,6 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{i as E}from"./chunk-YOGMP72T.mjs";import{b as j,c as S,e as U,m as O,n as P,o as C}from"./chunk-GWRKS3AL.mjs";import{da as N}from"./chunk-55LQD3Y3.mjs";import{h as B}from"./chunk-EAFLDSQ2.mjs";import{od as A,wd as y}from"./chunk-DPYTG6DM.mjs";var h="No record was written.",l=e=>e.toLocaleString("en-US"),D=e=>e.toDelete.createdSince+e.toDelete.broughtBackSince+e.toDelete.comesBackWithParent,$=e=>e.toBringBack.inBin+e.toBringBack.withParent+e.toBringBack.deletedWhileTaken,k=e=>e.toRecreate??0,v=e=>e.toBringBack.carriers??0;function L(e){let n=t=>D(t)+t.toGiveBack.records+$(t)+v(t)+k(t)>0,o=e.objects.filter(n).map(t=>t.objectApiName),a=e.files;return a!==void 0&&a.unlink+a.relink+a.updateLinks>0&&o.push(B),o}function M(e){return e.objects.reduce((n,o)=>({toDelete:n.toDelete+D(o),toGiveBack:n.toGiveBack+o.toGiveBack.records,toBringBack:n.toBringBack+$(o),toRecreate:n.toRecreate+k(o)}),{toDelete:0,toGiveBack:0,toBringBack:0,toRecreate:0})}function te(e,n){let o=new Set(n.objects),a=new Map(n.acts.map(i=>[i.objectApiName,i]));return{...E(e,o),objects:e.objects.filter(i=>o.has(i.objectApiName)||a.has(i.objectApiName)).map(i=>{let s=a.get(i.objectApiName),r=o.has(i.objectApiName);return{...i,toDelete:{createdSince:s?.toDelete??0,broughtBackSince:0,comesBackWithParent:0},toGiveBack:{...i.toGiveBack,records:s?.toGiveBack??0},toBringBack:{inBin:s?.toBringBack??0,withParent:0,deletedWhileTaken:0,...r&&i.toBringBack.carriers!==void 0?{carriers:i.toBringBack.carriers}:{}},toRecreate:s?.toRecreate??0,cannotUndo:r?i.cannotUndo:[],unexplained:r?i.unexplained:0}}),undoCannot:[...n.undoCannot]}}function W(e){let n=e.objects.filter(t=>D(t)+v(t)>0).map(t=>t.objectApiName),o=e.files,a=(t,i)=>i>0?[...t,B]:t;return{bringBack:e.objects.filter(t=>$(t)+v(t)>0).map(t=>t.objectApiName),recreate:a(e.objects.filter(t=>k(t)>0).map(t=>t.objectApiName),o?.relink??0),giveBack:a(e.objects.filter(t=>j(t)+U(t)>0).map(t=>t.objectApiName),o?.updateLinks??0),setToDraft:e.objects.filter(t=>S(t)>0).map(t=>t.objectApiName),delete:a(n,o?.unlink??0)}}function z(e){return new Set(e.map(n=>`${n.objectApiName}
7
+ import{i as E}from"./chunk-FYWNSMOZ.mjs";import{b as j,c as S,e as U,m as O,n as P,o as C}from"./chunk-4X5D3MSV.mjs";import{h as B}from"./chunk-Z3MGN42K.mjs";import{da as N}from"./chunk-2GSMHGIV.mjs";import{Nd as A,Vd as y}from"./chunk-6QSHWIZI.mjs";var h="No record was written.",l=e=>e.toLocaleString("en-US"),D=e=>e.toDelete.createdSince+e.toDelete.broughtBackSince+e.toDelete.comesBackWithParent,$=e=>e.toBringBack.inBin+e.toBringBack.withParent+e.toBringBack.deletedWhileTaken,k=e=>e.toRecreate??0,v=e=>e.toBringBack.carriers??0;function L(e){let n=t=>D(t)+t.toGiveBack.records+$(t)+v(t)+k(t)>0,o=e.objects.filter(n).map(t=>t.objectApiName),a=e.files;return a!==void 0&&a.unlink+a.relink+a.updateLinks>0&&o.push(B),o}function M(e){return e.objects.reduce((n,o)=>({toDelete:n.toDelete+D(o),toGiveBack:n.toGiveBack+o.toGiveBack.records,toBringBack:n.toBringBack+$(o),toRecreate:n.toRecreate+k(o)}),{toDelete:0,toGiveBack:0,toBringBack:0,toRecreate:0})}function te(e,n){let o=new Set(n.objects),a=new Map(n.acts.map(i=>[i.objectApiName,i]));return{...E(e,o),objects:e.objects.filter(i=>o.has(i.objectApiName)||a.has(i.objectApiName)).map(i=>{let s=a.get(i.objectApiName),r=o.has(i.objectApiName);return{...i,toDelete:{createdSince:s?.toDelete??0,broughtBackSince:0,comesBackWithParent:0},toGiveBack:{...i.toGiveBack,records:s?.toGiveBack??0},toBringBack:{inBin:s?.toBringBack??0,withParent:0,deletedWhileTaken:0,...r&&i.toBringBack.carriers!==void 0?{carriers:i.toBringBack.carriers}:{}},toRecreate:s?.toRecreate??0,cannotUndo:r?i.cannotUndo:[],unexplained:r?i.unexplained:0}}),undoCannot:[...n.undoCannot]}}function W(e){let n=e.objects.filter(t=>D(t)+v(t)>0).map(t=>t.objectApiName),o=e.files,a=(t,i)=>i>0?[...t,B]:t;return{bringBack:e.objects.filter(t=>$(t)+v(t)>0).map(t=>t.objectApiName),recreate:a(e.objects.filter(t=>k(t)>0).map(t=>t.objectApiName),o?.relink??0),giveBack:a(e.objects.filter(t=>j(t)+U(t)>0).map(t=>t.objectApiName),o?.updateLinks??0),setToDraft:e.objects.filter(t=>S(t)>0).map(t=>t.objectApiName),delete:a(n,o?.unlink??0)}}function z(e){return new Set(e.map(n=>`${n.objectApiName}
8
8
  ${n.kind}
9
9
  ${n.name}`)).size}function ne(e,n,o,a=!1){let t=(c,f)=>(c??[]).includes(f),i=o.filter(c=>!t(n.recreate,c)),s=o.filter(c=>N[c]!==void 0&&!t(n.giveBack,c)),r=new Set(e.objectsRead),d=[...i,...s];return{fired:y(e,{recreate:i,giveBack:s}),blind:d.length>0&&(!a&&A(e.unread)||d.some(c=>!r.has(c)))}}var T={limit:e=>`this step's limit of ${l(e)}`,mutes:!1,lift:{acceptAutomation:"turn on muteAutomation in the step for what a bypass keeps quiet, or acceptAutomation to let it run, and confirm it again to rewind all the same",acceptEmails:"turn on acceptEmails in the step and confirm it again to rewind all the same",acceptNoUndo:"turn on acceptNoUndo in the step and confirm it again to rewind all the same",acceptRecreate:"turn on acceptRecreate in the step and confirm it again to rewind all the same",acceptUnseen:"turn on acceptUnseen in the step and confirm it again to rewind all the same",maxRecords:"preview the rewind, then raise the step's maxRecords to what it rewinds and confirm it again",refuseWhenActive:"run it once they are done, or turn off refuseWhenActive in the step and confirm it again"}},oe={...T,lift:{...T.lift,acceptAutomation:"turn on acceptAutomation in the step to let what no bypass keeps quiet run, and confirm it again to rewind all the same"}},H=[{reason:"onlyWithParent",words:"Salesforce undeletes them only with their parent, which stays"},{reason:"deletedBeforeParent",words:"deleted before a record they point at, which the rewind deletes next, Salesforce cannot bring them back after that"}],Y="Add --accept-emails to rewind all the same";function q(e,n,o,a,t){let{automation:i,deliverability:s}=n;if(!i||!s)return;let r=W(n.diff),{refusal:d}=C({act:"rewind",orgName:e,automation:i,steps:r,accepted:o.acceptEmails===!0,mayMute:t,...P({automation:i,steps:r}),reading:s.reading});if(!d)return;let c=a.acceptEmails;return{...d,message:d.message.replace(Y,`${c.charAt(0).toUpperCase()}${c.slice(1)}`)}}function ie(e,n,o,a,t="the user SandForge connects as",i=!1){return _(e,n,o,a,t,i)[0]}function _(e,n,o,a,t="the user SandForge connects as",i=!1){let s=[],{diff:r,automation:d}=n;if(r.undoCannot.length>0&&!o.acceptNoUndo){let u=H.flatMap(({reason:w,words:g})=>{let R=r.undoCannot.filter(b=>(b.reason??"onlyWithParent")===w);if(R.length===0)return[];let F=R.reduce((b,G)=>b+G.count,0),I=[...new Set(R.map(b=>b.objectApiName))].join(", ");return[`Undo couldn't bring back ${l(F)} ${I} record(s) this rewind deletes: ${g}.`]});s.push({code:"NO_UNDO",message:`${u.join(" ")} Rewind refused; ${a.acceptNoUndo}. ${h}`})}let c=r.objects.filter(u=>k(u)>0);if(c.length>0&&!o.acceptRecreate){let u=c.reduce((w,g)=>w+k(g),0);s.push({code:"RECREATE",message:`${l(u)} ${c.map(w=>w.objectApiName).join(", ")} record(s) deleted since are no longer in the recycle bin, or Salesforce keeps them there for good: this rewind makes them again from the checkpoint, with new Ids. Anything outside Salesforce that names their old Ids \u2014 an integration, a link, a report filter \u2014 no longer finds them. Rewind refused; ${a.acceptRecreate}. ${h}`})}let f=r.unseen??[];if(f.length>0&&o.acceptUnseen!==!0){let u=f.map(({objectApiName:w,children:g,records:R})=>`Deleting ${l(R)} ${w} record(s) created since also deletes what ${t} can't see under them in ${g.join(", ")}: Rewind can't count those.`);s.push({code:"UNSEEN",message:`${u.join(" ")} Rewind refused; ${a.acceptUnseen}. ${h}`})}if(!d)return s;let m=K(e,n,o,a),p=q(e,n,o,a,i);return[...s,...m?[m]:[],...p?[p]:[]]}function K(e,n,o,a){let{diff:t,automation:i,emailsUncounted:s}=n;if(!i||o.acceptAutomation)return;let r=W(t),d=y(i,r);if(d.length===0&&!A(i.unread)&&s===void 0)return;let c=[...new Set(d.map(u=>u.objectApiName))],f=(r.recreate??[]).some(u=>u!==B)?"makes them again, ":"",m=d.length>0?`${z(d)} flow(s), trigger(s) or rule(s) of ${c.join(", ")} run as the rewind brings records back, ${f}gives them their values back or deletes them`:"what runs as the rewind writes could not all be read, so automation may run",p=s!==void 0?`The emails it sends as the rewind writes were not counted against its daily limits, as what sends them was not read (${s}). `:"";return{code:"AUTOMATION",message:`${e}: ${m}. ${p}Rewind refused; ${a.acceptAutomation}. `+h}}var x=e=>e.slice(0,15);async function ae(e){return(await J(e))[0]}async function J(e){let{orgName:n,preview:o,bounds:a,words:t}=e,{diff:i}=o;if(L(i).length===0)return[];let s=[],r=M(i),d=r.toDelete+r.toGiveBack+r.toBringBack+r.toRecreate;if(a.maxRecords!==void 0&&d>a.maxRecords){let f=[`${l(r.toDelete)} to delete`,`${l(r.toGiveBack)} to give back`,`${l(r.toBringBack)} to bring back`,...r.toRecreate>0?[`${l(r.toRecreate)} to make again`]:[]];s.push({code:"TOO_MANY_TO_REWIND",message:`The rewind of ${n} would rewind ${l(d)} records (${f.join(", ")}), past ${t.limit(a.maxRecords)}. Rewind refused; ${t.lift.maxRecords}. `+h})}if(a.refuseWhenActive&&i.activeLastHour.length>0){let f=new Set((await e.writers()).map(x)),m=new Set(i.activeLastHour.map(x).filter(p=>!f.has(p)));if(m.size>0){let p=m.size===1?"1 person":`${l(m.size)} people`;s.push({code:"PEOPLE_ACTIVE",message:`${p} other than the user the rewind writes as changed records of the checkpoint's objects in ${n} in the hour before the rewind read it: it would take their work back. Rewind refused; ${t.lift.refuseWhenActive}. `+h})}}let c=O("rewind",o.emails??[],n);return[...s,..._(n,o,e.accepted,t.lift,e.user,t.mutes),...c?[c]:[]]}function re(e,n,o){let a=n.map(t=>`${t.objectApiName} (${l(t.records)})`).join(", ");return{code:"UNDELETABLE_UNATTENDED",message:`The user SandForge connects to ${e} as may not delete the ${a} record(s) this rewind deletes. With nobody to ask whether to delete the rest, the deletion was left untouched. Give the user Delete on those objects, or rewind from the Checkpoints page, which asks. `+(o?"What the rewind's first pass wrote stays: its result says what, and Undo takes it back.":h)}}function se(e,n){return{code:"NOT_CONFIRMED",message:`Rewind step "${e}" has `+(n?"not been confirmed since it was changed":"never been confirmed")+": open it and type the org's alias, or, for an org that has none, its name or Organization Id. "+h}}export{L as a,M as b,te as c,W as d,z as e,ne as f,T as g,oe as h,ie as i,ae as j,J as k,re as l,se as m};
@@ -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{n as Ae,o as Ce}from"./chunk-ZWCRWF7E.mjs";import{e as k,f as $,g as Ee,l as v,m as Be}from"./chunk-ETT5GP4P.mjs";import{a as re}from"./chunk-SW2NUKQL.mjs";import{b as M}from"./chunk-BNO5GIJ6.mjs";import{$a as ve,Pb as je,bb as z,db as Te,f as ye}from"./chunk-KOQV4WXC.mjs";import{b as ne,f as we}from"./chunk-INIT2UKJ.mjs";import{k as Oe,l as Se,m as ke}from"./chunk-KRNFVAGC.mjs";import{da as V,ea as Re}from"./chunk-55LQD3Y3.mjs";import{b as I}from"./chunk-CA5NAXSU.mjs";import{b as be,e as K,f as te,k as he,l as D}from"./chunk-WZQEK4WT.mjs";function it(e){return e.keptChanged+e.keptDependents+e.refused+(e.notVisible??0)}function Cn(e,t){return t?"cancelled":e.every(n=>it(n)===0)?"success":e.some(n=>n.deleted>0)?"partial":"failure"}function En(e,t){return e!=="success"||!t||t.status==="success"?e:t.status==="cancelled"?"cancelled":"partial"}function Bn(e){return e.status}function vn(e){return e.filter(t=>t.deleted+t.refused+(t.notReached??0)>0).map(t=>({...ye(t.objectApiName),deleted:t.deleted,failed:t.refused,...(t.notReached??0)>0?{notSent:t.notReached}:{}}))}function Tn(e,t,n,r=!1){let o=R=>e.objects.reduce((B,C)=>B+R(C),0),i=o(R=>R.deleted),a=o(R=>R.alreadyGone),l=o(R=>R.keptChanged+R.keptDependents),u=o(R=>R.refused),c=o(R=>R.notVisible??0);if(i+a===0&&(!r||e.status==="cancelled"||l+u+c===0))return;let g=r?void 0:n,O=o(R=>R.platformCopies??0),E=e.status==="cancelled"?Math.max(0,t+O-i-a-l-u-c):0;return{removedAt:e.finishedAt,deleted:(g?.deleted??0)+i,alreadyGone:(g?.alreadyGone??0)+a,kept:l,refused:u,...E>0?{notReached:E}:{},...c>0?{notVisible:c}:{}}}function jn(...e){let t=new Set,n=[];for(let r of e.flatMap(o=>o??[])){let o=`${r.first}|${r.last}|${r.userId.slice(0,15)}`;t.has(o)||(t.add(o),n.push(r))}return n.sort((r,o)=>Date.parse(r.first)-Date.parse(o.first))}var oe=5;function P(e,t,n=1/0){return[...new Set([...e,...t])].slice(0,n)}function _(e,t){return e===void 0&&t===void 0?void 0:(e??0)+(t??0)}function Ne(e,t){if(!(!e&&!t))return{count:(e?.count??0)+(t?.count??0),objects:P(e?.objects??[],t?.objects??[])}}function Nn(...e){let t=new Map;for(let n of e.flat()){let r=t.get(n.objectApiName);if(!r){t.set(n.objectApiName,{...n});continue}let o={notVisible:_(r.notVisible,n.notVisible),notReached:_(r.notReached,n.notReached),heldByAutomation:_(r.heldByAutomation,n.heldByAutomation),heldByAutomationAfterRun:_(r.heldByAutomationAfterRun,n.heldByAutomationAfterRun),heldByAutomationAlong:_(r.heldByAutomationAlong,n.heldByAutomationAlong),platformCopies:_(r.platformCopies,n.platformCopies)},i=P(r.automationHolders??[],n.automationHolders??[]),a=r.filesLeft||n.filesLeft?{count:(r.filesLeft?.count??0)+(n.filesLeft?.count??0),names:P(r.filesLeft?.names??[],n.filesLeft?.names??[],oe)}:void 0,l=Ne(r.tookAlong,n.tookAlong),u=Ne(r.cameAlong,n.cameAlong);t.set(n.objectApiName,{objectApiName:n.objectApiName,planned:r.planned+n.planned,deleted:r.deleted+n.deleted,alreadyGone:r.alreadyGone+n.alreadyGone,keptChanged:r.keptChanged+n.keptChanged,keptDependents:r.keptDependents+n.keptDependents,refused:r.refused+n.refused,...Object.fromEntries(Object.entries(o).filter(([,c])=>c!==void 0)),heldBy:P(r.heldBy,n.heldBy),...i.length>0?{automationHolders:i}:{},unchecked:P(r.unchecked,n.unchecked),reasons:P(r.reasons,n.reasons,oe),...a?{filesLeft:a}:{},...l?{tookAlong:l}:{},...u?{cameAlong:u}:{}})}return[...t.values()]}function Dn(...e){let t=new Map;for(let n of e.flat()){let r=t.get(n.objectApiName);if(!r){t.set(n.objectApiName,{...n,changedBy:{...n.changedBy}});continue}let o={...r.changedBy};for(let[a,l]of Object.entries(n.changedBy))o[a]=(o[a]??0)+l;let i=_(r.platformCopies,n.platformCopies);t.set(n.objectApiName,{objectApiName:n.objectApiName,planned:r.planned+n.planned,toDelete:r.toDelete+n.toDelete,alreadyGone:r.alreadyGone+n.alreadyGone,changedSince:r.changedSince+n.changedSince,keptChanged:r.keptChanged+n.keptChanged,changedBy:o,undeletable:r.undeletable+n.undeletable,notVisible:r.notVisible+n.notVisible,unread:r.unread+n.unread,...i!==void 0?{platformCopies:i}:{},reasons:P(r.reasons,n.reasons,oe)})}return[...t.values()]}import{AsyncLocalStorage as st}from"node:async_hooks";var De=new Set(["delete","hardDelete"]),de=1e4,xe=5e4;function xn(e){switch(e){case"production":return;case"staging":return de;case"development":case"scratch":return xe}}var Ie=new st;function ie(){let e=Ie.getStore();return e?.live?e:void 0}async function In(e,t){let n={approved:e.approved,live:!0};try{return await Ie.run(n,t)}finally{n.live=!1}}var _e=class{overrides=new Map;options;constructor(t){this.options=t??{}}check(t){let n=this.checkTier(t),{orgNameOf:r}=this.options;return!n.requiresConfirmation||!r?n:{...n,question:ct(t,r(t.orgId),this.options.questionWords)}}checkTier(t){switch(t.orgTier){case"production":return this.checkProduction(t);case"staging":return this.checkStaging(t);case"development":case"scratch":return this.checkDevelopment(t)}}setProductionOverride(t,n){this.overrides.set(t,n)}isProductionOverridden(t){return this.overrides.get(t)===!0}get canAskForConfirmation(){return this.options.requestConfirmation!==void 0||ie()!==void 0}async confirmIfNeeded(t,n){if(!t.allowed||!t.requiresConfirmation)return t.allowed;let r=ie();return r?r.approved:this.options.requestConfirmation?t.question===void 0?this.options.requestConfirmation(t.impactSummary,n):this.options.requestConfirmation(t.impactSummary,n,t.question):!0}declinedWithoutAsking(t,n){if(!(!t.allowed||!t.requiresConfirmation||ie())&&this.options.requestConfirmation)return this.options.declinesWithoutAsking?.(n)}async confirmRun(t){return this.options.requestRunConfirmation?await this.options.requestRunConfirmation(t)?"confirmed":"declined":"unavailable"}orgPhrase(t,n){let r=this.options.orgNameOf?.(t.orgId);return r?n.org(t.orgTier,r,!0):n.org(t.orgTier,t.orgId,!1)}checkProduction(t){let n=[],r=De.has(t.operation),o=this.isProductionOverridden(t.orgId);n.push(`Production operation: ${t.operation} on ${t.objectName} (${q(t.recordCount)} ${at(t)}${t.alsoWrites?`, plus ${t.alsoWrites}`:""})`);let i=this.options.questionWords??Me;return t.operation==="deploy"?{allowed:!1,requiresConfirmation:!1,blockedReason:i.deployRefused(this.orgPhrase(t,i)),warnings:n,impactSummary:U(t)}:r&&!o?{allowed:!1,requiresConfirmation:!1,blockedReason:i.deleteRefused(t.operation==="hardDelete"?"hardDelete":"delete",this.orgPhrase(t,i)),warnings:n,impactSummary:U(t)}:(r&&o&&n.push("Production override is active \u2014 destructive operation permitted"),{allowed:!0,requiresConfirmation:!0,warnings:n,impactSummary:U(t)})}checkStaging(t){let n=[],r=De.has(t.operation),o=t.operation==="deploy",i=r||o||se(t.recordCount)>de;return r&&n.push(`Destructive operation (${t.operation}) on staging org \u2014 confirmation required`),o&&n.push("Metadata deployment on staging org \u2014 confirmation required"),se(t.recordCount)>de&&n.push(`Large volume operation: ${q(t.recordCount)} records on staging`),{allowed:!0,requiresConfirmation:i,warnings:n,impactSummary:U(t)}}checkDevelopment(t){let n=[];return se(t.recordCount)>xe&&n.push(`Large volume operation: ${q(t.recordCount)} records on ${t.orgTier} org`),{allowed:!0,requiresConfirmation:!1,warnings:n,impactSummary:U(t)}}};function q(e){return e==="unknown"?"an unknown number of":typeof e=="number"?String(e):`at most ${e.atMost}`}function se(e){return e==="unknown"?0:typeof e=="number"?e:e.atMost}function at(e){return e.operation==="deploy"?"components":"records"}var Mn="the related records the run adds",Me={sentence:(e,t,n)=>{switch(e){case"insert":return`Insert ${t} into ${n}.`;case"update":return`Update ${t} in ${n}.`;case"upsert":return`Insert or update ${t} in ${n}.`;case"delete":return`Delete ${t} in ${n}.`;case"hardDelete":return`Permanently delete ${t} in ${n}.`;case"deploy":return`Deploy ${t} to ${n}.`}},counted:(e,t)=>t==="unknown"?`${e}s`:typeof t=="number"?`${t} ${e}${t===1?"":"s"}`:`at most ${t.atMost} ${e}s`,besides:(e,t)=>`${e}, plus ${t},`,org:(e,t,n)=>n?`the ${e} org "${t}"`:`the ${e} org ${t}`,deployRefused:e=>`SandForge deploys metadata only to a sandbox, a scratch org or a Developer Edition org, not to ${e}: bring the change there through your release process, as a change set or a deployment from source control.`,deleteRefused:(e,t)=>e==="hardDelete"?`Permanently deleting records is not allowed in ${t}.`:`Deleting records is not allowed in ${t}.`},dt=new Set(["SeedData","SyncData","CloneData","AutopilotData"]);function ct(e,t,n=Me){let r=e.operation==="deploy"?"component":"record",o=dt.has(e.objectName)?"":` (${e.objectName})`,i=`${n.counted(r,e.recordCount)}${o}`,a=e.alsoWrites?n.besides(i,e.alsoWrites):i,l=t?n.org(e.orgTier,t,!0):n.org(e.orgTier,e.orgId,!1);return n.sentence(e.operation,a,l)}function U(e){if(e.operation==="deploy")return`DEPLOY ${q(e.recordCount)} component(s) (${e.objectName}) to ${e.orgTier} org ${e.orgId} [module: ${e.module}]`;let t=e.alsoWrites?`, plus ${e.alsoWrites},`:"";return`${e.operation.toUpperCase()} ${q(e.recordCount)} ${e.objectName} record(s)${t} on ${e.orgTier} org ${e.orgId} [module: ${e.module}]`}function J(e,t){return`${e} ${t}${e===1?"":"s"}`}var ut={cost:({records:e,objects:t,requests:n,seconds:r,megabytes:o,keepDays:i})=>`Checkpoint first: about ${J(e,"record")} of ${J(t,"object")}, ${J(n,"API request")}, ${r} s, ${o} MB on this machine, unencrypted, and none of the org's storage, `+(i===0?"kept until you delete it.":`kept ${J(i,"day")}.`),added:(e,t)=>`Added: ${e} \u2014 ${t}`,notHeld:(e,t)=>`Not in the checkpoint: ${e} \u2014 ${t}`,more:e=>`\u2026 and ${e} more`,unknown:"What an Apex trigger, or automation that could not be read, creates as the run writes is not known: a rewind leaves those records as they are."},ae=10;function lt(e){return e<=0?"0":Math.max(.1,Math.ceil(e/1048576*10-1e-9)/10).toFixed(1)}function $n(e,t=ut){let{estimate:n}=e,r=[t.cost({records:n.records,objects:e.objects.length,requests:n.apiRequests,seconds:Math.ceil(n.seconds),megabytes:lt(n.bytes),keepDays:e.keepDays})],o=(i,a)=>{for(let{objectApiName:l,reason:u}of i.slice(0,ae))r.push(a(l,u));i.length>ae&&r.push(t.more(i.length-ae))};return o(e.added,t.added),o(e.notHeld,t.notHeld),r.push(t.unknown),r}var mt=300,ft=1024,pt=160,gt=500,Ke=40,bt=4,ht=3,Rt=3,yt=1,wt=1e3,Ot=1,$e=200,St=60,kt=50,At=Buffer.byteLength(`${JSON.stringify({Id:"0".repeat(18)})}
7
+ import{m as Ae,n as Ce}from"./chunk-IXIY6Q4M.mjs";import{e as k,f as $,g as Ee,l as v,m as Be}from"./chunk-EOQON3E5.mjs";import{a as re}from"./chunk-Y7YUNRKK.mjs";import{b as M}from"./chunk-MJD6CPZZ.mjs";import{Jb as je,Va as ve,Xa as z,Za as Te}from"./chunk-R3OM3X4L.mjs";import{f as ye}from"./chunk-77IVKH7R.mjs";import{b as ne,f as we}from"./chunk-INIT2UKJ.mjs";import{k as Oe,l as Se,m as ke}from"./chunk-ZOSESZ22.mjs";import{da as V,ea as Re}from"./chunk-2GSMHGIV.mjs";import{b as I}from"./chunk-CA5NAXSU.mjs";import{b as be,e as K,f as te,k as he,l as D}from"./chunk-WZQEK4WT.mjs";function it(e){return e.keptChanged+e.keptDependents+e.refused+(e.notVisible??0)}function Cn(e,t){return t?"cancelled":e.every(n=>it(n)===0)?"success":e.some(n=>n.deleted>0)?"partial":"failure"}function En(e,t){return e!=="success"||!t||t.status==="success"?e:t.status==="cancelled"?"cancelled":"partial"}function Bn(e){return e.status}function vn(e){return e.filter(t=>t.deleted+t.refused+(t.notReached??0)>0).map(t=>({...ye(t.objectApiName),deleted:t.deleted,failed:t.refused,...(t.notReached??0)>0?{notSent:t.notReached}:{}}))}function Tn(e,t,n,r=!1){let o=R=>e.objects.reduce((B,C)=>B+R(C),0),i=o(R=>R.deleted),a=o(R=>R.alreadyGone),l=o(R=>R.keptChanged+R.keptDependents),u=o(R=>R.refused),c=o(R=>R.notVisible??0);if(i+a===0&&(!r||e.status==="cancelled"||l+u+c===0))return;let g=r?void 0:n,O=o(R=>R.platformCopies??0),E=e.status==="cancelled"?Math.max(0,t+O-i-a-l-u-c):0;return{removedAt:e.finishedAt,deleted:(g?.deleted??0)+i,alreadyGone:(g?.alreadyGone??0)+a,kept:l,refused:u,...E>0?{notReached:E}:{},...c>0?{notVisible:c}:{}}}function jn(...e){let t=new Set,n=[];for(let r of e.flatMap(o=>o??[])){let o=`${r.first}|${r.last}|${r.userId.slice(0,15)}`;t.has(o)||(t.add(o),n.push(r))}return n.sort((r,o)=>Date.parse(r.first)-Date.parse(o.first))}var oe=5;function P(e,t,n=1/0){return[...new Set([...e,...t])].slice(0,n)}function _(e,t){return e===void 0&&t===void 0?void 0:(e??0)+(t??0)}function Ne(e,t){if(!(!e&&!t))return{count:(e?.count??0)+(t?.count??0),objects:P(e?.objects??[],t?.objects??[])}}function Nn(...e){let t=new Map;for(let n of e.flat()){let r=t.get(n.objectApiName);if(!r){t.set(n.objectApiName,{...n});continue}let o={notVisible:_(r.notVisible,n.notVisible),notReached:_(r.notReached,n.notReached),heldByAutomation:_(r.heldByAutomation,n.heldByAutomation),heldByAutomationAfterRun:_(r.heldByAutomationAfterRun,n.heldByAutomationAfterRun),heldByAutomationAlong:_(r.heldByAutomationAlong,n.heldByAutomationAlong),platformCopies:_(r.platformCopies,n.platformCopies)},i=P(r.automationHolders??[],n.automationHolders??[]),a=r.filesLeft||n.filesLeft?{count:(r.filesLeft?.count??0)+(n.filesLeft?.count??0),names:P(r.filesLeft?.names??[],n.filesLeft?.names??[],oe)}:void 0,l=Ne(r.tookAlong,n.tookAlong),u=Ne(r.cameAlong,n.cameAlong);t.set(n.objectApiName,{objectApiName:n.objectApiName,planned:r.planned+n.planned,deleted:r.deleted+n.deleted,alreadyGone:r.alreadyGone+n.alreadyGone,keptChanged:r.keptChanged+n.keptChanged,keptDependents:r.keptDependents+n.keptDependents,refused:r.refused+n.refused,...Object.fromEntries(Object.entries(o).filter(([,c])=>c!==void 0)),heldBy:P(r.heldBy,n.heldBy),...i.length>0?{automationHolders:i}:{},unchecked:P(r.unchecked,n.unchecked),reasons:P(r.reasons,n.reasons,oe),...a?{filesLeft:a}:{},...l?{tookAlong:l}:{},...u?{cameAlong:u}:{}})}return[...t.values()]}function Dn(...e){let t=new Map;for(let n of e.flat()){let r=t.get(n.objectApiName);if(!r){t.set(n.objectApiName,{...n,changedBy:{...n.changedBy}});continue}let o={...r.changedBy};for(let[a,l]of Object.entries(n.changedBy))o[a]=(o[a]??0)+l;let i=_(r.platformCopies,n.platformCopies);t.set(n.objectApiName,{objectApiName:n.objectApiName,planned:r.planned+n.planned,toDelete:r.toDelete+n.toDelete,alreadyGone:r.alreadyGone+n.alreadyGone,changedSince:r.changedSince+n.changedSince,keptChanged:r.keptChanged+n.keptChanged,changedBy:o,undeletable:r.undeletable+n.undeletable,notVisible:r.notVisible+n.notVisible,unread:r.unread+n.unread,...i!==void 0?{platformCopies:i}:{},reasons:P(r.reasons,n.reasons,oe)})}return[...t.values()]}import{AsyncLocalStorage as st}from"node:async_hooks";var De=new Set(["delete","hardDelete"]),de=1e4,xe=5e4;function xn(e){switch(e){case"production":return;case"staging":return de;case"development":case"scratch":return xe}}var Ie=new st;function ie(){let e=Ie.getStore();return e?.live?e:void 0}async function In(e,t){let n={approved:e.approved,live:!0};try{return await Ie.run(n,t)}finally{n.live=!1}}var _e=class{overrides=new Map;options;constructor(t){this.options=t??{}}check(t){let n=this.checkTier(t),{orgNameOf:r}=this.options;return!n.requiresConfirmation||!r?n:{...n,question:ct(t,r(t.orgId),this.options.questionWords)}}checkTier(t){switch(t.orgTier){case"production":return this.checkProduction(t);case"staging":return this.checkStaging(t);case"development":case"scratch":return this.checkDevelopment(t)}}setProductionOverride(t,n){this.overrides.set(t,n)}isProductionOverridden(t){return this.overrides.get(t)===!0}get canAskForConfirmation(){return this.options.requestConfirmation!==void 0||ie()!==void 0}async confirmIfNeeded(t,n){if(!t.allowed||!t.requiresConfirmation)return t.allowed;let r=ie();return r?r.approved:this.options.requestConfirmation?t.question===void 0?this.options.requestConfirmation(t.impactSummary,n):this.options.requestConfirmation(t.impactSummary,n,t.question):!0}declinedWithoutAsking(t,n){if(!(!t.allowed||!t.requiresConfirmation||ie())&&this.options.requestConfirmation)return this.options.declinesWithoutAsking?.(n)}async confirmRun(t){return this.options.requestRunConfirmation?await this.options.requestRunConfirmation(t)?"confirmed":"declined":"unavailable"}orgPhrase(t,n){let r=this.options.orgNameOf?.(t.orgId);return r?n.org(t.orgTier,r,!0):n.org(t.orgTier,t.orgId,!1)}checkProduction(t){let n=[],r=De.has(t.operation),o=this.isProductionOverridden(t.orgId);n.push(`Production operation: ${t.operation} on ${t.objectName} (${q(t.recordCount)} ${at(t)}${t.alsoWrites?`, plus ${t.alsoWrites}`:""})`);let i=this.options.questionWords??Me;return t.operation==="deploy"?{allowed:!1,requiresConfirmation:!1,blockedReason:i.deployRefused(this.orgPhrase(t,i)),warnings:n,impactSummary:U(t)}:r&&!o?{allowed:!1,requiresConfirmation:!1,blockedReason:i.deleteRefused(t.operation==="hardDelete"?"hardDelete":"delete",this.orgPhrase(t,i)),warnings:n,impactSummary:U(t)}:(r&&o&&n.push("Production override is active \u2014 destructive operation permitted"),{allowed:!0,requiresConfirmation:!0,warnings:n,impactSummary:U(t)})}checkStaging(t){let n=[],r=De.has(t.operation),o=t.operation==="deploy",i=r||o||se(t.recordCount)>de;return r&&n.push(`Destructive operation (${t.operation}) on staging org \u2014 confirmation required`),o&&n.push("Metadata deployment on staging org \u2014 confirmation required"),se(t.recordCount)>de&&n.push(`Large volume operation: ${q(t.recordCount)} records on staging`),{allowed:!0,requiresConfirmation:i,warnings:n,impactSummary:U(t)}}checkDevelopment(t){let n=[];return se(t.recordCount)>xe&&n.push(`Large volume operation: ${q(t.recordCount)} records on ${t.orgTier} org`),{allowed:!0,requiresConfirmation:!1,warnings:n,impactSummary:U(t)}}};function q(e){return e==="unknown"?"an unknown number of":typeof e=="number"?String(e):`at most ${e.atMost}`}function se(e){return e==="unknown"?0:typeof e=="number"?e:e.atMost}function at(e){return e.operation==="deploy"?"components":"records"}var Mn="the related records the run adds",Me={sentence:(e,t,n)=>{switch(e){case"insert":return`Insert ${t} into ${n}.`;case"update":return`Update ${t} in ${n}.`;case"upsert":return`Insert or update ${t} in ${n}.`;case"delete":return`Delete ${t} in ${n}.`;case"hardDelete":return`Permanently delete ${t} in ${n}.`;case"deploy":return`Deploy ${t} to ${n}.`}},counted:(e,t)=>t==="unknown"?`${e}s`:typeof t=="number"?`${t} ${e}${t===1?"":"s"}`:`at most ${t.atMost} ${e}s`,besides:(e,t)=>`${e}, plus ${t},`,org:(e,t,n)=>n?`the ${e} org "${t}"`:`the ${e} org ${t}`,deployRefused:e=>`SandForge deploys metadata only to a sandbox, a scratch org or a Developer Edition org, not to ${e}: bring the change there through your release process, as a change set or a deployment from source control.`,deleteRefused:(e,t)=>e==="hardDelete"?`Permanently deleting records is not allowed in ${t}.`:`Deleting records is not allowed in ${t}.`},dt=new Set(["SeedData","SyncData","CloneData","AutopilotData"]);function ct(e,t,n=Me){let r=e.operation==="deploy"?"component":"record",o=dt.has(e.objectName)?"":` (${e.objectName})`,i=`${n.counted(r,e.recordCount)}${o}`,a=e.alsoWrites?n.besides(i,e.alsoWrites):i,l=t?n.org(e.orgTier,t,!0):n.org(e.orgTier,e.orgId,!1);return n.sentence(e.operation,a,l)}function U(e){if(e.operation==="deploy")return`DEPLOY ${q(e.recordCount)} component(s) (${e.objectName}) to ${e.orgTier} org ${e.orgId} [module: ${e.module}]`;let t=e.alsoWrites?`, plus ${e.alsoWrites},`:"";return`${e.operation.toUpperCase()} ${q(e.recordCount)} ${e.objectName} record(s)${t} on ${e.orgTier} org ${e.orgId} [module: ${e.module}]`}function J(e,t){return`${e} ${t}${e===1?"":"s"}`}var ut={cost:({records:e,objects:t,requests:n,seconds:r,megabytes:o,keepDays:i})=>`Checkpoint first: about ${J(e,"record")} of ${J(t,"object")}, ${J(n,"API request")}, ${r} s, ${o} MB on this machine, unencrypted, and none of the org's storage, `+(i===0?"kept until you delete it.":`kept ${J(i,"day")}.`),added:(e,t)=>`Added: ${e} \u2014 ${t}`,notHeld:(e,t)=>`Not in the checkpoint: ${e} \u2014 ${t}`,more:e=>`\u2026 and ${e} more`,unknown:"What an Apex trigger, or automation that could not be read, creates as the run writes is not known: a rewind leaves those records as they are."},ae=10;function lt(e){return e<=0?"0":Math.max(.1,Math.ceil(e/1048576*10-1e-9)/10).toFixed(1)}function $n(e,t=ut){let{estimate:n}=e,r=[t.cost({records:n.records,objects:e.objects.length,requests:n.apiRequests,seconds:Math.ceil(n.seconds),megabytes:lt(n.bytes),keepDays:e.keepDays})],o=(i,a)=>{for(let{objectApiName:l,reason:u}of i.slice(0,ae))r.push(a(l,u));i.length>ae&&r.push(t.more(i.length-ae))};return o(e.added,t.added),o(e.notHeld,t.notHeld),r.push(t.unknown),r}var mt=300,ft=1024,pt=160,gt=500,Ke=40,bt=4,ht=3,Rt=3,yt=1,wt=1e3,Ot=1,$e=200,St=60,kt=50,At=Buffer.byteLength(`${JSON.stringify({Id:"0".repeat(18)})}
8
8
  `),Ct="IsDeleted = false",Ve=4;function Et(e){return e.access?.kind==="perObject"?e.access.requests:0}var Bt=1,vt=200,Tt=3,jt=1,Nt=1,ze=2,Dt=3,_t=2e3,Pt=100,Je=["Id","SystemModstamp"],Le=23,N=2.5,h=.35,xt=1,It=.9,S=.5,fe=.25,T=.86,Mt="ContentVersion",$t="ContentDocument",ce=200,Fe=150,w={apiRequests:0,seconds:0};function d(e,t){return{apiRequests:e,seconds:e*t}}function G(e){return{apiRequests:e,seconds:f(e,Ee)*h}}function m(...e){return e.reduce((t,n)=>({apiRequests:t.apiRequests+n.apiRequests,seconds:t.seconds+n.seconds}),w)}function f(e,t){return e>0?Math.ceil(e/t):0}function A(e){return f(e,M)}function Ye(e){return ne(e,Je).length}function Lt(e){return e.length>Pt?M/4:M}function Q(e,t){return f(e,Lt(t))*Ye(t)}function We(e,t){if(e.length===0)return 0;let n=2*(e.length-1)+2+2*(t-1);for(let r of e){let o=JSON.stringify(r,null,2),i=1;for(let a=o.indexOf(`
9
9
  `);a>=0;a=o.indexOf(`
10
10
  `,a+1))i++;n+=Buffer.byteLength(o,"utf8")+i*2*t}return n}function Ft(e){let t=ft+(e.printsBytes??0),n=[];for(let r of e.objects)t+=r.records*mt+Be(r.records,2),r.records>0&&(t+=pt),t+=(r.inBin??0)*At,t+=(r.links??0)*(St+kt),r.entry!==void 0&&n.push(r.entry);return t+We(n,2)+We(e.leftOut??[],3)}function Yn(e,t,n){let[,...r]=ne(t,Je),o=n==="scanAllLive"?Ct:void 0;return r.map(i=>we(e,i,o))}function Ue(e,t){return t.reduce((n,r)=>n+f(e,Math.max(1,r)),0)}function Wt(e,t){if(e.records===0)return{pages:0,reads:0};let n=Math.floor(e.records/t),r=e.records-n*t,o=e.otherGroups??[];return{pages:n+(r>0?1:0),reads:n*Ue(t,o)+Ue(r,o)}}function Xn(e){let t=e.objects.length,n=f(e.described,$),r=e.describedAlone??0,o=G(f(e.counted??t,k)),i=(e.countedAlone??0)+f(e.recounted??0,k),a=o.apiRequests+i,l=G(f(t,k)),u=Math.min(e.pageRows,wt),c=0,g=0,O=0;for(let b of e.objects){O+=b.records;let y=Wt(b,u);c+=y.pages,g+=y.reads}let E=H(e.objects.map(b=>L(b.inBin??0))),R=Ut(e.objects),B=e.objects.filter(b=>(b.stampedSince??0)>0),C=m(H(B.flatMap(b=>[L(b.stampedSince??0),1])),G(f(B.length,k))),W=c+g+(c>0?yt:0),s=e.annexCalls??0,p={guard:bt,scope:ht+n+r,start:Rt,counts:a,bin:E.apiRequests,snapshot:W+R.apiRequests+s,stability:Ot+l.apiRequests+C.apiRequests};return{records:O,apiRequests:Object.values(p).reduce((b,y)=>b+y,0),requestsByPhase:p,seconds:Math.ceil(n*N+(r+i+s)*h+o.seconds+l.seconds+E.seconds+C.seconds+R.seconds+c*xt+g*S),bytes:Ft(e)}}function Ut(e){let t=e.filter(o=>o.links!==void 0);if(t.length===0)return w;let n=0,r=0;for(let o of t)o.links===null?n+=f(f(o.records,$e),k):r+=o.links??0;return m(H(t.map(o=>L(o.links??0))),d(n,S),d(f(f(r,$e),k),S))}function L(e){return Math.max(1,f(e,_t))}function H(e){let t=0,n=0;for(let r=0;r<e.length;r+=k){let o=Math.max(1,...e.slice(r,r+k));t+=1,n+=o-1}return m(d(t,h),d(n,It))}function qt(e){let t=new Set([...e.held,...e.moved.map(n=>n.objectApiName)]);return m(G(f(e.objects,k)),H(e.moved.flatMap(({live:n,deleted:r})=>[L(n),L(r)])),G(f(t.size,k)))}function Xe(e){let t=e.reduce((n,r)=>n+A(r),0);return m(d(t*(Tt-1),S),d(t,T))}function Gt(e){return m(...e.filter(t=>t.records>0).map(({records:t,cascades:n,described:r})=>{let o=A(t);return m(d(r?0:1,N),Xe([t]),d(o*f(n,k),h),d(o*jt,S))}))}function ue(e,t){let n=w;for(let r=e;r>0;r-=v){let o=Math.min(r,v);n=m(n,d(ze,h),d(Q(o,t),S),d(z([{rows:o}]),T),d(A(o),S))}return n}function Ht(e,t,n,r){return e===0||n===0?w:m(d(r?0:1,N),d((n+A(e))*f(t,k),h))}var Qt=D({childRelationships:he(D({childSObject:be().optional(),cascadeDelete:te().optional(),restrictedDelete:te().optional()}).loose()).nullish()}).loose();function Zn(e,t){let n=Qt.parse(e).childRelationships??[],r=n.filter(u=>u.cascadeDelete===!0),o=t?.worked,i={dependents:n.filter(u=>(u.cascadeDelete===!0||u.restrictedDelete===!0)&&(o===void 0||u.childSObject!==void 0&&o.has(u.childSObject))).length,cascades:r.length,cascadeChildren:[...new Set(r.flatMap(u=>u.childSObject===void 0?[]:[u.childSObject]))]};if(t===void 0)return i;let a=n.filter(u=>u.cascadeDelete===!0&&u.childSObject!==void 0&&!t.inCheckpoint.has(u.childSObject.toLowerCase())),l=a.filter(u=>u.childSObject!==void 0&&t.worked?.has(u.childSObject)===!0);return{...i,outside:{all:a.length,worked:l.length}}}function pe(e,t){return e?.get(t)??{dependents:Le,cascades:Le}}function Kt(e,t){if(e<Ae||t===Mt||t===$t)return d(z([{rows:e}]),T);let n=Math.ceil(e/Ce),r=Math.ceil(e/n),o=w;for(let i=e;i>0;i-=r){let a=Math.min(i,r);o=m(o,{apiRequests:Oe({stateReads:ke(a)}),seconds:Se(a)})}return o}function le(e,t=Number.POSITIVE_INFINITY){let n=e.filter(r=>r.records>0);return n.length===0?w:m(d(Dt,h),...n.map(({records:r,dependents:o,objectApiName:i})=>{let a=A(r),l=0;for(let c=r;c>0;c-=t)Math.min(c,t)>M&&l++;let u=l*o;return m(d(1,h),d(a,S),d(u+o*a,fe),zt(i,a,u+o*a),Kt(r,i))}))}function Vt(e,t,n){return m(...e.filter(({count:r})=>r>0).map(({objectApiName:r,count:o})=>{let{dependents:i}=pe(t,r),a=o>M?i:0;return m(d(n.has(r)?0:1,N),d(a+i*A(o),fe))}))}function zt(e,t,n){return e===void 0||V[e]===void 0||Re.has(e)?w:m(d(1,h),d(t,S),d(n,fe),d(t,T))}function j(e){return e.toDelete.createdSince+e.toDelete.broughtBackSince}function Y(e){return e.toBringBack.inBin+e.toBringBack.deletedWhileTaken+ee(e)}function ee(e){return e.toBringBack.carriers??0}function F(e){return e.toDelete.comesBackWithParent+ee(e)}function X(e){return e.cannotUndo.filter(t=>t.reason==="deletedWithCreatedParent"||t.reason==="deletedWithParentOutside").reduce((t,n)=>t+n.count,0)}function Z(e){return Y(e)-ee(e)+e.toBringBack.withParent}function Ze(e){return e.toGiveBack.records+e.toBringBack.inBin+e.toBringBack.withParent}function me(e){return e.cannotUndo.filter(t=>t.reason==="goneForGood").reduce((t,n)=>t+n.count,0)}function x(e){return e.toRecreate??0}function Jt(e){return me(e)+x(e)}function Yt(e,t){let n=0;for(let r=e;r>0&&t>0;r-=v){let o=Math.min(r,v);n+=f(t*A(o),k)}return n}function et(e,t,n){let r=Jt(e);return{objectApiName:e.objectApiName,live:e.toGiveBack.records+e.touched+j(e)+e.unexplained,deleted:Z(e)+F(e)+X(e),valued:e.toGiveBack.records+e.touched+e.toBringBack.withParent,backTo:Z(e)+ee(e)+X(e)>0||t.undeletable===!1&&r>0,deletes:j(e),scans:r>0&&t.undeletable!==!1,whole:e.schemaDrift!==void 0,outside:n?.get(e.objectApiName)?.outside??{all:e.outside.length,worked:e.outside.length}}}function Xt(e,t,n,r){let o=et(e,t,n),i=e.toBringBack,a=r?0:F(e);return{...o,live:e.toGiveBack.records+e.touched+e.unexplained+Z(e)+x(e)+a,deleted:j(e)+F(e)-a+X(e),valued:e.toGiveBack.records+e.touched+i.inBin+i.withParent+x(e),backTo:X(e)>0||t.undeletable===!1&&me(e)>0,scans:me(e)>0&&t.undeletable!==!1,deletes:a}}function tt(e,t,n,r,o,i=0,a,l=0){let u=[],c=[],g=0,O=0,E=0,R=!1,B=0;for(let{objectApiName:s,records:p,fields:b}of e){let y=t.get(s);if(y===void 0){n.has(s)&&u.push({objectApiName:s,live:0,deleted:0});continue}u.push({objectApiName:s,live:y.live,deleted:y.deleted}),g+=Q(y.valued,b),y.backTo&&!y.whole&&O++,y.scans&&c.push(H([L(p)])),y.deletes!==0&&(!y.whole&&!y.backTo&&E++,y.outside.all>0&&(R=!0),B+=Yt(y.deletes,y.outside.worked))}a!==void 0&&(R=!0);let C=a!==void 0?1:0,W=o===void 0?f(e.length+C,$):f(o.first+C,$)+f(o.later,$);return m(d(Bt,h),d(W,N),qt({objects:e.length,held:e.filter(s=>s.records>0).map(s=>s.objectApiName),moved:u}),d(g,S),d(f(O,$),N),d(E,h),d(R?1:0,N),d(B,h),d(i,h),d(l,h),d(a?.requests??0,S),...c,d(f(f(r,vt),k),h))}function nt(e){return e.files!==void 0?{requests:e.filesRequests??0}:void 0}function rt(e,t){let n=new Map(e.diff.objects.map(o=>[o.objectApiName,o])),r=new Map;for(let o of e.objects){let i=n.get(o.objectApiName);i&&r.set(o.objectApiName,t(i,o))}return r}function Zt(e){let t=new Set(e.diff.objects.flatMap(n=>Object.keys(n.lastChangedBy)));return tt(e.objects,rt(e,(n,r)=>et(n,r,e.relationships)),new Set(e.diff.unread.map(n=>n.objectApiName)),t.size,e.diff.described,e.diff.parentsOutsideRequests??0,nt(e.diff),e.diff.fieldsRequests??0)}function qe(e,t,n=!1){let r=!t&&(n||e.diff.objects.some(i=>F(i)>0)),o=e.diff.described;return tt(e.objects,rt(e,(i,a)=>Xt(i,a,e.relationships,t)),new Set(e.diff.unread.map(i=>i.objectApiName)),r?1:0,o===void 0?void 0:{first:o.first+o.later,later:0},e.diff.parentsOutsideRequests??0,nt(e.diff),e.diff.fieldsRequests??0)}function en(e){return m(...e.filter(t=>t>0).map(t=>m(d(1,h),d(A(t),T))))}var tn=new Set(["activateddate","activatedbyid"]);function nn(e){return m(...e.filter(({objectApiName:t,records:n})=>n>0&&V[t]!==void 0).map(({records:t})=>m(d(1,h),d(A(t),T))))}function rn(e,t){return e*gt+t*Ke}function Ge(e){return m(d(ze,h),d(Ye(e),S),d(1,T),d(1,S))}function on(e,t,n,r){if(t===0)return w;let o=e==="Order"?n.find(c=>c.toLowerCase()==="status"):void 0,i=o===void 0?[]:[o],a=c=>m(ue(c,n),o?ue(c,i):w),l=m(Ge(n),o?Ge(i):w),u=d(Q(t,n),S);return m(a(t),r.held?m(u,l):w,r.held&&r.twice?m(a(t),l):w,r.nextPass?m(u,l):w)}function He(e,t,n,r){let o=r?.get(n.objectApiName)?.cascadeChildren;return o!==void 0?o.includes(t):e?.cascadeParents!==void 0&&e.cascadeParents.length===0?!1:e?.readOrder!==void 0&&n.readOrder!==void 0?e.readOrder<n.readOrder:!0}function sn(e){let t=e.diff.objects,n=new Map(e.objects.map(s=>[s.objectApiName,s])),r=s=>pe(e.relationships,s),o=e.diff.undoCannot?e.diff.undoCannot.reduce((s,{objectApiName:p,count:b})=>s.set(p,(s.get(p)??0)+b),new Map):void 0,i=e.diff.withParentDeleted?new Map(e.diff.withParentDeleted.map(({objectApiName:s,count:p})=>[s,p])):void 0,a=s=>{if(i!==void 0)return Math.max(0,j(s)-(i.get(s.objectApiName)??0));if(o===void 0||n.get(s.objectApiName)?.undeletable!==!1)return j(s);let p=(o.get(s.objectApiName)??0)-s.toDelete.comesBackWithParent;return Math.max(0,Math.min(j(s),p))},l=t.filter(s=>a(s)>0),u=t.filter(s=>F(s)>0),c=(s,p)=>p.some(b=>b.objectApiName!==s.objectApiName&&He(n.get(b.objectApiName),b.objectApiName,s,e.relationships)),g=(s,p)=>p.some(b=>{let y=n.get(b.objectApiName);return y!==void 0&&b.objectApiName!==s.objectApiName&&He(s,s.objectApiName,y,e.relationships)}),O=t.reduce((s,p)=>s+A(Y(p)),0),E=e.reusesPreview!==!0&&t.some(s=>j(s)>0&&(e.relationships?.get(s.objectApiName)?.outside?.all??s.outside.length)>0),R=t.some(s=>Y(s)>0&&r(s.objectApiName).cascades>0),B=m(d(R&&!E?1:0,N),Gt(t.map(s=>({records:Y(s),cascades:r(s.objectApiName).cascades,described:e.reusesPreview!==!0}))),...t.map(s=>Ht(s.toBringBack.withParent,r(s.objectApiName).cascades,O,e.reusesPreview!==!0)),...t.map(s=>{let p=n.get(s.objectApiName);return p===void 0?w:on(s.objectApiName,Ze(s),p.fields,{held:c(p,l),twice:g(p,l),nextPass:c(p,u)})}),en(t.map(x)),nn(t.map(s=>({objectApiName:s.objectApiName,records:x(s)}))),le(t.map(s=>({objectApiName:s.objectApiName,records:a(s),dependents:r(s.objectApiName).dependents})),re)),C=t.flatMap(s=>{let p=n.get(s.objectApiName),b=x(s);return b===0||p===void 0?[]:V[s.objectApiName]===void 0?[]:p.fields.some(y=>tn.has(y.toLowerCase()))?[ue(b,p.fields)]:[]}),W=u.length>0||C.length>0?m(le(u.map(s=>({objectApiName:s.objectApiName,records:F(s),dependents:r(s.objectApiName).dependents})),re),...C,qe(e,!0)):w;return m(d(Nt,h),B,dn(e.diff.files),qe(e,!1,C.length>0),W)}function an(e){return e===void 0?0:e.unlink+e.relink+e.updateLinks}function dn(e){return e===void 0?w:d(f(e.unlink,ce)+f(e.relink,ce)+f(e.updateLinks,ce),T)}function er(e){let t=e.diff.objects,n=t.reduce((g,O)=>g+j(O)+O.toDelete.comesBackWithParent,0),r=t.reduce((g,O)=>g+O.toGiveBack.records,0),o=t.reduce((g,O)=>g+Z(O),0),i=t.reduce((g,O)=>g+x(O),0),a=n+r+o+i,l=m(d(Ve+Et(e.diff),h),e.reusesPreview===!0?w:Zt(e)),u=e.diff.files;if(a===0&&an(u)===0)return{records:0,apiRequests:l.apiRequests,seconds:Math.ceil(l.seconds),bytes:0};let c=m(l,d(e.automationRequests,S),d(e.deliverabilityRequests??0,h),sn(e));return{records:a,apiRequests:c.apiRequests,seconds:Math.ceil(c.seconds),bytes:rn(t.reduce((g,O)=>g+Ze(O),0),n+o+2*i)+cn(u)}}function cn(e){return e===void 0?0:e.unlink*Fe+e.relink*Ke+e.updateLinks*Fe}var un=1;function Qe(e,t){let n=w;for(let r=e;r>0;r-=v){let o=Math.min(r,v);n=m(n,d(un,h),d(Q(o,t),S),d(z([{rows:o}]),T))}return n}function ln(e,t){let n=Math.min(e.givenBackHeld??0,e.givenBack),r=w;for(let o=e.givenBack;o>0;o-=v)r=m(r,d(Q(Math.min(o,v),t),S));return m(Qe(n,t),Qe(e.givenBack-n,t),r)}var mn=2;function fn(e){let t=Math.min(e.givenBackHeld??0,e.givenBack);return d(A(e.givenBack)+A(t)+A(e.givenBack-t),S)}function tr(e){let t=new Map(e.objects.map(c=>[c.objectApiName,c.fields])),n=e.rewound.reduce((c,g)=>c+g.deleted+g.broughtBack+g.givenBack,0),r=d(Ve,h);if(n===0)return{records:0,apiRequests:r.apiRequests,seconds:Math.ceil(r.seconds),bytes:0};let o=e.rewound.some(c=>c.deleted>0),i=e.rewound.some(c=>c.givenBack>0),a=new Set(e.rewound.filter(c=>c.broughtBack>0).map(c=>c.objectApiName)),l=o&&i?m(d(mn,h),...e.rewound.map(fn)):w,u=m(r,d(e.automationRequests,S),l,le(e.rewound.map(c=>({objectApiName:c.objectApiName,records:c.broughtBack,dependents:pe(e.relationships,c.objectApiName).dependents}))),a.size>0?Vt(e.along??[],e.relationships,a):w,Xe(e.rewound.map(c=>c.deleted)),...e.rewound.map(c=>ln(c,t.get(c.objectApiName)??[])));return{records:n,apiRequests:u.apiRequests,seconds:Math.ceil(u.seconds),bytes:0}}var pn={take:{what:"This checkpoint",then:"Take it once the org has requests to spare \u2014 the limit is counted over the last 24 hours \u2014 or pick fewer objects.",done:"No record was read."},rewind:{what:"This rewind",then:"Rewind once the org has requests to spare \u2014 the limit is counted over the last 24 hours \u2014 or rewind fewer of its objects at a time, which sends only theirs (the objects ticked in the preview, or --object on a command line).",done:"No record was read or written."},undo:{what:"This undo",then:"Undo the rewind once the org has requests to spare \u2014 the limit is counted over the last 24 hours \u2014 while the recycle bin still holds what it brings back.",done:"No record was read or written."}},gn=D({FileStorageMB:D({Max:K(),Remaining:K()}).loose()}).loose(),bn=D({DataStorageMB:D({Max:K().int().nonnegative()}).loose()}).loose();async function nr(e,t){let n,r;try{n=await e.request({method:"GET",url:"/limits"}),r=await ve({request:()=>Promise.resolve(n)})}catch(l){throw new Error(`${t} did not say how many API requests it has left today: ${I(l)}`)}let o;try{o=await je({request:()=>Promise.resolve(n)})}catch(l){o={unread:I(l)}}let i=gn.safeParse(n),a=bn.safeParse(n);return{...r,emails:o,...i.success?{fileStorage:{max:i.data.FileStorageMB.Max,remaining:i.data.FileStorageMB.Remaining}}:{},...a.success?{dataStorageMaxMB:a.data.DataStorageMB.Max}:{}}}var hn={deliverability:e=>`to read whether ${e} delivers its emails`};function Rn(e,t){if(e===void 0)return"";let n=Object.entries(hn).flatMap(([r,o])=>{let i=e[r]??0;return i>0&&o?[{requests:i,words:o(t)}]:[]}).map(({requests:r,words:o},i)=>`${r}${i===0?" of them":""} ${o}`);return n.length>0?` (${n.join(", ")})`:""}function rr(e,t,n,r){let o=Te(t,n);if(o.verdict!=="exceeds")return;let i=pn[e];return{code:"API_BUDGET",message:`${i.what} takes about ${o.estimate} API requests${Rn(o.parts,r)}; ${r} has ${n.remaining} of its ${n.max} left today. ${i.then} ${i.done}`}}var yn={rewind:{then:"Free file storage, then rewind again.",done:"Nothing was written."},undo:{then:"Free file storage, then undo the rewind again while the recycle bin still holds them.",done:"Nothing was written."}};function wn(e){let t=e/1048576;return t<1?`${Math.max(1,Math.round(t*10))/10} MB`:`${Math.ceil(t)} MB`}function or(e,t,n,r){if(n===void 0||t.files===0||t.bytes<=n*1048576)return;let o=yn[e];return{code:"FILE_STORAGE",message:`Bringing back ${t.files===1?"1 file":`${t.files} files`} takes ${wn(t.bytes)} of file storage; ${r} has ${n} MB left. ${o.then} ${o.done}`}}import{randomUUID as On}from"node:crypto";var ge="\0configStore:revision",Sn="\0configStore";function kn(e){let t=e[ge]?.value;if(t!==void 0)try{let n=JSON.parse(t);return typeof n.writer=="string"&&typeof n.write=="number"?{writer:n.writer,write:n.write}:void 0}catch{return}}var ot=class{backend;logWarning;writer=On();writes=0;written;constructor(t,n){this.backend=t,this.logWarning=n}initialize(){this.backend.getData()}get(t){let n=this.current()[t];if(n)try{return JSON.parse(n.value)}catch(r){let o=I(r);this.logWarning?.(`[ConfigStore] Failed to parse JSON for key "${t}": ${o}`);return}}set(t,n,r="general"){let o=JSON.stringify(n);this.update(i=>{let a=i[t];return a&&a.value===o&&a.category===r?!1:(i[t]={value:o,category:r},!0)})}delete(t){return this.update(n=>t in n?(delete n[t],!0):!1)}has(t){return t in this.current()}getByCategory(t){let n={};for(let[r,o]of Object.entries(this.current()))if(o.category===t)try{n[r]=JSON.parse(o.value)}catch(i){let a=I(i);this.logWarning?.(`[ConfigStore] Corrupted entry in category "${t}", key "${r}": ${a}`)}return n}getAllKeys(){return Object.keys(this.current()).filter(t=>t!==ge)}getKeysByPrefix(t){return this.getAllKeys().filter(n=>n.startsWith(t))}clearCategory(t){let n=0;return this.update(r=>{for(let[o,i]of Object.entries(r))i.category===t&&(delete r[o],n++);return n>0}),n}clearAll(){this.write({})}current(){let t=this.backend.getData(),n=kn(t);return this.written&&n?.writer===this.writer&&n.write<this.writes?this.written:t}update(t){let n={...this.current()},r=t(n);return r&&this.write(n),r}write(t){this.writes+=1,t[ge]={value:JSON.stringify({writer:this.writer,write:this.writes}),category:Sn},this.backend.setData(t),this.written=t}};export{Cn as a,En as b,Bn as c,vn as d,Tn as e,jn as f,Nn as g,Dn as h,xn as i,ie as j,In as k,_e as l,Mn as m,$n as n,wt as o,_t as p,h as q,xt as r,T as s,Yn as t,Xn as u,Zn as v,sn as w,er as x,tr as y,nr as z,rr as A,or as B,ot as C};
@@ -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}from"./chunk-TUPZY2QJ.mjs";import"./chunk-JBWJ6UEZ.mjs";import"./chunk-4GCYGQXD.mjs";import"./chunk-PPGDAUEQ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-Z3MGN42K.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{d as hostIsMyDomain,b as isScratchHost,a as myDomainHostOf,e as refreshedSince,c as sandboxMyDomainOf};
@@ -4,6 +4,6 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{o as m}from"./chunk-4JKR4PTZ.mjs";import{H as d,d as w,z as b}from"./chunk-E2YJVSX6.mjs";import{vc as u}from"./chunk-DPYTG6DM.mjs";import{b as R,e as A,k as j,l as p,v as P}from"./chunk-WZQEK4WT.mjs";import{randomBytes as O}from"node:crypto";import{createReadStream as T}from"node:fs";import{appendFile as C,open as $,readFile as D,rename as F,rm as _}from"node:fs/promises";import{join as k}from"node:path";import{createInterface as M}from"node:readline";var U=2e3,a=15,x=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,W=2e3,z="spool.json",h="a rewind";function v(r){return typeof r=="string"&&x.test(r)?r.slice(0,a):void 0}var g=class{bytes=Buffer.alloc(a*1024);flags=new Uint16Array(1024);slots=new Uint32Array(2048);used=0;get size(){return this.used}find(t){let e=this.slots.length-1;for(let s=m(t)&e;;s=s+1&e){let n=this.slots[s];if(n===0)return-1;if(this.holds(n-1,t))return n-1}}holds(t,e){let s=t*a;for(let n=0;n<a;n++)if(this.bytes[s+n]!==e.charCodeAt(n))return!1;return!0}keyAt(t){let e=t*a;return this.bytes.toString("latin1",e,e+a)}place(t,e){let s=this.slots.length-1,n=m(e)&s;for(;this.slots[n]!==0;)n=n+1&s;this.slots[n]=t+1}add(t,e=0){let s=v(t);if(s===void 0)throw new RangeError(`Not a Salesforce id: ${String(t)}`);let n=this.find(s);if(n>=0)return this.flags[n]|=e,!1;if((this.used+1)*2>this.slots.length){let o=this.slots;this.slots=new Uint32Array(o.length*2);for(let i of o)i!==0&&this.place(i-1,this.keyAt(i-1))}if((this.used+1)*a>this.bytes.length){let o=Buffer.alloc(this.bytes.length*2);this.bytes.copy(o),this.bytes=o;let i=new Uint16Array(this.flags.length*2);i.set(this.flags),this.flags=i}return this.bytes.write(s,this.used*a,a,"latin1"),this.flags[this.used]=e,this.place(this.used,s),this.used++,!0}has(t){let e=v(t);return e!==void 0&&this.find(e)>=0}count(t){let e=0;for(let s=0;s<this.used;s++)t(this.flags[s])&&e++;return e}flagsOf(t){let e=v(t);if(e===void 0)return 0;let s=this.find(e);return s<0?0:this.flags[s]}},B=p({version:P(1),objects:j(p({objectApiName:R().min(1),count:A().int().nonnegative()}))});function S(r,t){return k(r,`${u(t)}.ids`)}async function G(r,t){let e=`${r}.${process.pid}-${O(4).toString("hex")}.tmp`,s=await $(e,"wx",w);try{try{await s.writeFile(t,"utf8"),await s.sync()}finally{await s.close()}await F(e,r)}catch(n){throw await _(e,{force:!0}),n}}async function J(r){let t=await $(r,"r+");try{await t.sync()}finally{await t.close()}}async function L(r,t,e=h){for(let{objectApiName:s,count:n}of t)n>0&&await J(S(r,s));return await G(k(r,z),`${JSON.stringify({version:1,objects:t})}
7
+ import{o as m}from"./chunk-4JKR4PTZ.mjs";import{H as d,d as w,z as b}from"./chunk-N2HYG3BL.mjs";import{Uc as u}from"./chunk-6QSHWIZI.mjs";import{b as R,e as A,k as j,l as p,v as P}from"./chunk-WZQEK4WT.mjs";import{randomBytes as O}from"node:crypto";import{createReadStream as T}from"node:fs";import{appendFile as C,open as $,readFile as D,rename as F,rm as _}from"node:fs/promises";import{join as k}from"node:path";import{createInterface as M}from"node:readline";var U=2e3,a=15,x=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,W=2e3,z="spool.json",h="a rewind";function v(r){return typeof r=="string"&&x.test(r)?r.slice(0,a):void 0}var g=class{bytes=Buffer.alloc(a*1024);flags=new Uint16Array(1024);slots=new Uint32Array(2048);used=0;get size(){return this.used}find(t){let e=this.slots.length-1;for(let s=m(t)&e;;s=s+1&e){let n=this.slots[s];if(n===0)return-1;if(this.holds(n-1,t))return n-1}}holds(t,e){let s=t*a;for(let n=0;n<a;n++)if(this.bytes[s+n]!==e.charCodeAt(n))return!1;return!0}keyAt(t){let e=t*a;return this.bytes.toString("latin1",e,e+a)}place(t,e){let s=this.slots.length-1,n=m(e)&s;for(;this.slots[n]!==0;)n=n+1&s;this.slots[n]=t+1}add(t,e=0){let s=v(t);if(s===void 0)throw new RangeError(`Not a Salesforce id: ${String(t)}`);let n=this.find(s);if(n>=0)return this.flags[n]|=e,!1;if((this.used+1)*2>this.slots.length){let o=this.slots;this.slots=new Uint32Array(o.length*2);for(let i of o)i!==0&&this.place(i-1,this.keyAt(i-1))}if((this.used+1)*a>this.bytes.length){let o=Buffer.alloc(this.bytes.length*2);this.bytes.copy(o),this.bytes=o;let i=new Uint16Array(this.flags.length*2);i.set(this.flags),this.flags=i}return this.bytes.write(s,this.used*a,a,"latin1"),this.flags[this.used]=e,this.place(this.used,s),this.used++,!0}has(t){let e=v(t);return e!==void 0&&this.find(e)>=0}count(t){let e=0;for(let s=0;s<this.used;s++)t(this.flags[s])&&e++;return e}flagsOf(t){let e=v(t);if(e===void 0)return 0;let s=this.find(e);return s<0?0:this.flags[s]}},B=p({version:P(1),objects:j(p({objectApiName:R().min(1),count:A().int().nonnegative()}))});function S(r,t){return k(r,`${u(t)}.ids`)}async function G(r,t){let e=`${r}.${process.pid}-${O(4).toString("hex")}.tmp`,s=await $(e,"wx",w);try{try{await s.writeFile(t,"utf8"),await s.sync()}finally{await s.close()}await F(e,r)}catch(n){throw await _(e,{force:!0}),n}}async function J(r){let t=await $(r,"r+");try{await t.sync()}finally{await t.close()}}async function L(r,t,e=h){for(let{objectApiName:s,count:n}of t)n>0&&await J(S(r,s));return await G(k(r,z),`${JSON.stringify({version:1,objects:t})}
8
8
  `),new y(r,t,e)}var I=class{constructor(t,e=h){this.dir=t;this.act=e}dir;act;order=[];counts=new Map;lines=new Map;written=new Set;keys=new g;made=!1;async add(t,e){if(!this.keys.add(e))return!1;let s=this.lines.get(t);return s||(u(t),s=[],this.lines.set(t,s),this.order.push(t)),s.push(e),this.counts.set(t,(this.counts.get(t)??0)+1),s.length>=W&&await this.flush(t),!0}async flush(t){let e=this.lines.get(t)??[];this.made||(await b(this.dir),this.made=!0);let s=!this.written.has(t);e.length===0&&!s||(await C(S(this.dir,t),e.map(n=>`${n}
9
9
  `).join(""),{encoding:"utf8",mode:w,flag:s?"w":"a"}),this.written.add(t),this.lines.set(t,[]))}get objects(){return this.order.map(t=>({objectApiName:t,count:this.counts.get(t)??0}))}async finish(t){this.made||(await b(this.dir),this.made=!0);for(let e of this.order)await this.flush(e);return L(this.dir,t?t(this.objects):this.objects,this.act)}},y=class r{constructor(t,e,s=h){this.dir=t;this.objects=e;this.act=s}dir;objects;act;get count(){return this.objects.reduce((t,e)=>t+e.count,0)}static async open(t,e=h){let s;try{s=JSON.parse(await D(k(t,z),"utf8"))}catch{throw new d("damaged",`The list of what ${e} sets out to do is not on this machine.`)}let n=B.safeParse(s);if(!n.success)throw new d("damaged",`The list of what ${e} sets out to do does not read as one.`);for(let{objectApiName:o}of n.data.objects)u(o);return new r(t,n.data.objects,e)}async*pages(t,e=U){let s=this.objects.find(c=>c.objectApiName===t);if(!s||s.count===0)return;let n=()=>new d("damaged",`The ${t} records ${this.act} sets out to act on are not as they were written.`),o=Math.max(1,Math.floor(e)),i=T(S(this.dir,t),{encoding:"utf8"}),f=M({input:i,crlfDelay:1/0}),E=0,l=[];try{for await(let c of f)if(c!==""){if(!x.test(c))throw n();E++,l.push(c),l.length>=o&&(yield l,l=[])}}catch(c){throw c.code==="ENOENT"?n():c}finally{f.close(),i.destroy()}if(E!==s.count)throw n();l.length>0&&(yield l)}},N=class r{constructor(t,e){this.spool=t;this.keys=e}spool;keys;static async of(t,e){return new r(await t.finish(e),t.keys)}static async open(t,e=h){let s=await y.open(t,e),n=new g;for(let{objectApiName:o}of s.objects)for await(let i of s.pages(o))for(let f of i)n.add(f);return new r(s,n)}get objects(){return this.spool.objects}pages(t){return this.spool.pages(t)}has(t){return this.keys.has(t)}};export{U as a,g as b,S as c,L as d,I as e,y as f,N as g};
@@ -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{e as R}from"./chunk-3B5H24ZG.mjs";var h="FIELD_CUSTOM_VALIDATION_EXCEPTION",y="INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST",_="FIELD_FILTER_VALIDATION_EXCEPTION",w="INACTIVE_OWNER_OR_USER",E=/\[(005[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?)\]/,F="005",b=["CreatedById","LastModifiedById"];function A(t,e){if(t.statusCode!==w)return;let r=c(e,"OwnerId"),n=r===void 0?void 0:e[r],o=E.exec(t.message)?.[1];if(!(typeof n!="string"||o===void 0))return n.slice(0,15)===o.slice(0,15)?o.slice(0,15):void 0}function D(t,e,r){let n=c(e,"OwnerId");if(n===void 0||n.toLowerCase()===r?.toLowerCase())return;let o=e[n];if(!(typeof o!="string"||!o.startsWith(F)||t.fields.some(s=>s.toLowerCase()!=="ownerid")||!(E.test(t.message)?A(t,e)!==void 0:b.every(s=>c(e,s)===void 0))))return{field:n,refusedBy:"inactive-owner",reason:R(t)}}var S=new Map([[h,"validation-rule"],[y,"restricted-picklist"],[_,"lookup-filter"]]);function T(t){return t!=null&&t!==""}function c(t,e){let r=e.toLowerCase();return Object.keys(t).find(n=>n.toLowerCase()===r&&T(t[n]))}function P(t,e,r,n,o){if(!t||t.length===0)return;let i=new Map;for(let a of t){let s=S.get(a.statusCode);if(!s){let d=o?.inactiveOwner===!0&&a.statusCode===w?D(a,e,r):void 0;if(!d)return;i.has(d.field)||i.set(d.field,d);continue}let u=a.fields.map(d=>c(e,d)).filter(d=>d!==void 0&&d.toLowerCase()!==r?.toLowerCase());if(u.length===0||s==="lookup-filter"&&!u.every(d=>n?.(d)===!0))return;for(let d of u)i.has(d)||i.set(d,{field:d,refusedBy:s,reason:R(a)})}return[...i.values()]}function K(t){return(t??[]).some(e=>e.statusCode===h&&e.fields.length===0)}function B(t,e){let r=new Set(e.map(n=>n.field));return Object.fromEntries(Object.entries(t).filter(([n])=>!r.has(n)))}function j(t,e){let r=t??{rows:0,fields:[]};r.rows+=e.rows;for(let n of e.fields){let o=r.fields.find(i=>i.field===n.field&&i.reason===n.reason);o?o.rows+=n.rows:r.fields.push({...n})}return r}var k={"validation-rule":"a validation rule of the target refused it","restricted-picklist":"a restricted picklist of the target refused its value","lookup-filter":"a lookup filter of the target refused the record it names","inactive-owner":"the target holds the owner it names inactive"};function x(t){return(t?.fields??[]).map(({field:e,refusedBy:r="validation-rule",reason:n,rows:o,replacedWith:i})=>{let a=i===void 0?`written without ${e}`:`written with ${e} set to "${i}"`;return`, ${o} ${a}: ${k[r]}, ${n}`}).join("")}function V(t){let e=`${t.rows} record(s) written again without the fields the target refused them on${x(t)}`;return e.endsWith(".")?e:`${e}.`}var f=class{config;constructor(e){this.config={maxRetries:e?.maxRetries??3,initialDelay:e?.initialDelay??1e3,maxDelay:e?.maxDelay??3e4,backoffMultiplier:e?.backoffMultiplier??2,jitter:e?.jitter??!0}}calculateDelay(e){let r=this.config.initialDelay*Math.pow(this.config.backoffMultiplier,e),n=Math.min(r,this.config.maxDelay);if(!this.config.jitter)return n;let o=n/2;return Math.floor(o+Math.random()*o)}async execute(e){let r,n=0;for(let o=0;o<=this.config.maxRetries;o++)try{return{success:!0,result:await e(),attempts:o+1,totalDelay:n}}catch(i){if(r=i instanceof Error?i:new Error(String(i)),o<this.config.maxRetries){let a=this.calculateDelay(o);n+=a,await new Promise(s=>setTimeout(s,a))}}return{success:!1,error:r,attempts:this.config.maxRetries+1,totalDelay:n}}shouldRetry(e){return e<this.config.maxRetries}getConfig(){return{...this.config}}};var O="UNABLE_TO_LOCK_ROW",l=3,C=2e3,L=200,Z=`Rows the target refuses for a record lock go again on their own, up to ${l} times each: up to ${l} more requests for every ${L} of them, which no estimate made before the write can count.`,X=`rows the target refuses for a record lock go again, up to ${l} times each: up to ${l} more requests for every ${L} of them, not counted above`,I="CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY",v=/\bfirst error: UNABLE_TO_LOCK_ROW\b/,N=/^([A-Z][A-Z0-9_]*):\s*([\s\S]*)$/;function p(t,e){return t===O||t===I&&v.test(e)}function q(t,e){return e&&e.length>0?e.every(r=>p(r.statusCode,r.message)):t.length>0&&t.every(r=>{let n=N.exec(r.trim());return n!==null&&p(n[1],n[2])})}var $=new f({initialDelay:C});function U(t){return $.calculateDelay(t)}function H(t,e){return new Promise(r=>{if(e?.aborted){r();return}let n=()=>{clearTimeout(o),e?.removeEventListener("abort",n),r()},o=setTimeout(n,t);e?.addEventListener("abort",n,{once:!0})})}function W(t){return`sent again ${t===1?"once":`${t} times`}, waiting longer each time: the target still could not lock a record the write needed`}function J(t,e){return`${t} \u2014 ${W(e)}`}async function Q(t){let e=[...t.outcomes],r=new Map,n=e.flatMap((s,u)=>t.locked(s)?[u]:[]),o=n.length;for(let s=0;n.length>0&&s<l&&(await t.wait(U(s)),!t.stopped());s++){let u=n,d=await t.send(u);if(d.slice(0,u.length).forEach((m,g)=>{e[u[g]]=m,r.set(u[g],(r.get(u[g])??0)+1)}),d.length<u.length)break;n=u.filter(m=>t.locked(e[m]))}let i=0,a=0;for(let[s,u]of r)t.written(e[s])?i++:t.locked(e[s])&&(a++,e[s]=t.note(e[s],u));return{outcomes:e,refused:o,sentAgain:r.size,written:i,stillLocked:a,notSentAgain:o-r.size}}function ee(t,e){if(e.refused===0)return;let r=e.sentAgain-e.written-e.stillLocked,n=[`${e.written} written`,...e.stillLocked>0?[`${e.stillLocked} still refused for the lock`]:[],...r>0?[`${r} refused for another reason`]:[],...e.notSentAgain>0?[`${e.notSentAgain} not sent again: the run was stopped`]:[]];return`${e.refused} ${t} refused because the target could not lock a record their write needed (${O}), sent again up to ${l} times, waiting longer each time: ${n.join(", ")}`}export{y as a,_ as b,w as c,A as d,c as e,P as f,K as g,B as h,j as i,x as j,V as k,f as l,Z as m,X as n,q as o,H as p,J as q,Q as r,ee as s};
7
+ import{e as R}from"./chunk-ISOSTAJR.mjs";var h="FIELD_CUSTOM_VALIDATION_EXCEPTION",y="INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST",_="FIELD_FILTER_VALIDATION_EXCEPTION",w="INACTIVE_OWNER_OR_USER",E=/\[(005[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?)\]/,F="005",b=["CreatedById","LastModifiedById"];function A(t,e){if(t.statusCode!==w)return;let r=c(e,"OwnerId"),n=r===void 0?void 0:e[r],o=E.exec(t.message)?.[1];if(!(typeof n!="string"||o===void 0))return n.slice(0,15)===o.slice(0,15)?o.slice(0,15):void 0}function D(t,e,r){let n=c(e,"OwnerId");if(n===void 0||n.toLowerCase()===r?.toLowerCase())return;let o=e[n];if(!(typeof o!="string"||!o.startsWith(F)||t.fields.some(s=>s.toLowerCase()!=="ownerid")||!(E.test(t.message)?A(t,e)!==void 0:b.every(s=>c(e,s)===void 0))))return{field:n,refusedBy:"inactive-owner",reason:R(t)}}var S=new Map([[h,"validation-rule"],[y,"restricted-picklist"],[_,"lookup-filter"]]);function T(t){return t!=null&&t!==""}function c(t,e){let r=e.toLowerCase();return Object.keys(t).find(n=>n.toLowerCase()===r&&T(t[n]))}function P(t,e,r,n,o){if(!t||t.length===0)return;let i=new Map;for(let a of t){let s=S.get(a.statusCode);if(!s){let d=o?.inactiveOwner===!0&&a.statusCode===w?D(a,e,r):void 0;if(!d)return;i.has(d.field)||i.set(d.field,d);continue}let u=a.fields.map(d=>c(e,d)).filter(d=>d!==void 0&&d.toLowerCase()!==r?.toLowerCase());if(u.length===0||s==="lookup-filter"&&!u.every(d=>n?.(d)===!0))return;for(let d of u)i.has(d)||i.set(d,{field:d,refusedBy:s,reason:R(a)})}return[...i.values()]}function K(t){return(t??[]).some(e=>e.statusCode===h&&e.fields.length===0)}function B(t,e){let r=new Set(e.map(n=>n.field));return Object.fromEntries(Object.entries(t).filter(([n])=>!r.has(n)))}function j(t,e){let r=t??{rows:0,fields:[]};r.rows+=e.rows;for(let n of e.fields){let o=r.fields.find(i=>i.field===n.field&&i.reason===n.reason);o?o.rows+=n.rows:r.fields.push({...n})}return r}var k={"validation-rule":"a validation rule of the target refused it","restricted-picklist":"a restricted picklist of the target refused its value","lookup-filter":"a lookup filter of the target refused the record it names","inactive-owner":"the target holds the owner it names inactive"};function x(t){return(t?.fields??[]).map(({field:e,refusedBy:r="validation-rule",reason:n,rows:o,replacedWith:i})=>{let a=i===void 0?`written without ${e}`:`written with ${e} set to "${i}"`;return`, ${o} ${a}: ${k[r]}, ${n}`}).join("")}function V(t){let e=`${t.rows} record(s) written again without the fields the target refused them on${x(t)}`;return e.endsWith(".")?e:`${e}.`}var f=class{config;constructor(e){this.config={maxRetries:e?.maxRetries??3,initialDelay:e?.initialDelay??1e3,maxDelay:e?.maxDelay??3e4,backoffMultiplier:e?.backoffMultiplier??2,jitter:e?.jitter??!0}}calculateDelay(e){let r=this.config.initialDelay*Math.pow(this.config.backoffMultiplier,e),n=Math.min(r,this.config.maxDelay);if(!this.config.jitter)return n;let o=n/2;return Math.floor(o+Math.random()*o)}async execute(e){let r,n=0;for(let o=0;o<=this.config.maxRetries;o++)try{return{success:!0,result:await e(),attempts:o+1,totalDelay:n}}catch(i){if(r=i instanceof Error?i:new Error(String(i)),o<this.config.maxRetries){let a=this.calculateDelay(o);n+=a,await new Promise(s=>setTimeout(s,a))}}return{success:!1,error:r,attempts:this.config.maxRetries+1,totalDelay:n}}shouldRetry(e){return e<this.config.maxRetries}getConfig(){return{...this.config}}};var O="UNABLE_TO_LOCK_ROW",l=3,C=2e3,L=200,Z=`Rows the target refuses for a record lock go again on their own, up to ${l} times each: up to ${l} more requests for every ${L} of them, which no estimate made before the write can count.`,X=`rows the target refuses for a record lock go again, up to ${l} times each: up to ${l} more requests for every ${L} of them, not counted above`,I="CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY",v=/\bfirst error: UNABLE_TO_LOCK_ROW\b/,N=/^([A-Z][A-Z0-9_]*):\s*([\s\S]*)$/;function p(t,e){return t===O||t===I&&v.test(e)}function q(t,e){return e&&e.length>0?e.every(r=>p(r.statusCode,r.message)):t.length>0&&t.every(r=>{let n=N.exec(r.trim());return n!==null&&p(n[1],n[2])})}var $=new f({initialDelay:C});function U(t){return $.calculateDelay(t)}function H(t,e){return new Promise(r=>{if(e?.aborted){r();return}let n=()=>{clearTimeout(o),e?.removeEventListener("abort",n),r()},o=setTimeout(n,t);e?.addEventListener("abort",n,{once:!0})})}function W(t){return`sent again ${t===1?"once":`${t} times`}, waiting longer each time: the target still could not lock a record the write needed`}function J(t,e){return`${t} \u2014 ${W(e)}`}async function Q(t){let e=[...t.outcomes],r=new Map,n=e.flatMap((s,u)=>t.locked(s)?[u]:[]),o=n.length;for(let s=0;n.length>0&&s<l&&(await t.wait(U(s)),!t.stopped());s++){let u=n,d=await t.send(u);if(d.slice(0,u.length).forEach((m,g)=>{e[u[g]]=m,r.set(u[g],(r.get(u[g])??0)+1)}),d.length<u.length)break;n=u.filter(m=>t.locked(e[m]))}let i=0,a=0;for(let[s,u]of r)t.written(e[s])?i++:t.locked(e[s])&&(a++,e[s]=t.note(e[s],u));return{outcomes:e,refused:o,sentAgain:r.size,written:i,stillLocked:a,notSentAgain:o-r.size}}function ee(t,e){if(e.refused===0)return;let r=e.sentAgain-e.written-e.stillLocked,n=[`${e.written} written`,...e.stillLocked>0?[`${e.stillLocked} still refused for the lock`]:[],...r>0?[`${r} refused for another reason`]:[],...e.notSentAgain>0?[`${e.notSentAgain} not sent again: the run was stopped`]:[]];return`${e.refused} ${t} refused because the target could not lock a record their write needed (${O}), sent again up to ${l} times, waiting longer each time: ${n.join(", ")}`}export{y as a,_ as b,w as c,A as d,c as e,P as f,K as g,B as h,j as i,x as j,V as k,f as l,Z as m,X as n,q as o,H as p,J as q,Q as r,ee as s};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a as c}from"./chunk-FSZTXLNW.mjs";import{Nd as a,Od as b}from"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{c as ConditionalRouter,a as conditionDefect,b as evaluateCondition};
7
+ import{a as c}from"./chunk-IHGYJZZ2.mjs";import{ke as a,le as b}from"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{c as ConditionalRouter,a as conditionDefect,b as evaluateCondition};
@@ -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{Zb as S,_b as O}from"./chunk-DPYTG6DM.mjs";import{b as y,f as b,l as R}from"./chunk-WZQEK4WT.mjs";var v=["User","Group","Profile","UserRole","RecordType","Organization","Queue","PermissionSet","BusinessProcess","CurrencyType","DandBCompany","DuplicateRecordItem","DuplicateRecordSet","ProcessInstance","LoginHistory","LoginEvent","LoginIp","LoginGeo","AsyncApexJob","ApexLog","ApexTestResult","ApexTestQueueItem","LightningUsageByPageMetrics","LightningExitByPageMetrics","EventBusSubscriber","PlatformEventUsageMetric","CronTrigger","CronJobDetail","AttachedContentDocument","AttachedContentNote","CombinedAttachment","ContentBody","NoteAndAttachment","OwnedContentDocument","EntitySubscription","TopicAssignment","UserRecordAccess","DeclinedEventRelation","UndecidedEventRelation","AcceptedEventRelation","OpenActivity","ActivityHistory","AppUsageAssignment","AuthProvider","Folder","ContentDocument","ContentDocumentLink","OpportunityRelatedDeleteLog","CaseHistory2","Calendar","SlaProcess","AccountCleanInfo","ContactCleanInfo","LeadCleanInfo","ApprovalSubmission","ApprovalSubmissionDetail","ApprovalWorkItem","AIRecordInsight","AIInsightValue","MatchingInformation","Invoice","InvoiceLine","CreditMemo","CreditMemoLine","AppDefinition","BackgroundOperation","ContentTaxonomyTermRelationshipType","Dashboard","DashboardComponent","DeleteEvent","ManagedContentChannel","ManagedContentSpace","ManagedContentVariant","Report","ServiceSetupProvisioning","TabDefinition"],P=new Set(v.map(e=>e.toLowerCase())),W=["History","Feed","Share","ChangeEvent","__hd","__Tag","EventStore"].map(e=>e.toLowerCase()),F=/^vlocity_[a-z0-9]+__/;function B(e,t){return I(e,t,{byNamespace:!0})}function I(e,t,r){let n=e.toLowerCase();return P.has(n)||S(e)||t&&(t.has(e)||U(t).has(n))||r.byNamespace&&F.test(n)?!0:W.some(i=>n.endsWith(i))}var w=new WeakMap;function U(e){let t=w.get(e);if(t&&t.size===e.size)return t.names;let r=new Set([...e].map(n=>n.toLowerCase()));return w.set(e,{size:e.size,names:r}),r}function z(e,t){return O(e)||B(e,t)}function E(e){return O(e)||I(e,void 0,{byNamespace:!1})}function x(e,t=[]){let r=new Set(t);for(let n of e)n.createable===!1&&r.add(n.name);return r}function le(e,t=r=>z(r)){return new Set(e.filter(r=>{let n=r.referenceTo??[];return n.length>0&&n.every(i=>t(i))}).map(r=>r.name))}var ge=R({name:y(),queryable:b().optional(),createable:b().optional(),updateable:b().optional(),deletable:b().optional(),undeletable:b().optional(),customSetting:b().optional(),layoutable:b().optional(),keyPrefix:y().nullish()}).loose(),D="ContentDocument",H="ContentDocumentLink",G="ContentVersion",L="Attachment",J=[D,L],K={AccountContactRelation:["Contact"]},V=new Set(["feeditem","feedcomment","feedattachment"]),X=new Set(["casehistory2"]),Y=new Set(["AccountCleanInfo","ContactCleanInfo","LeadCleanInfo","ApprovalSubmission","ApprovalSubmissionDetail","ApprovalWorkItem","ProcessInstance","ProcessInstanceNode","ProcessInstanceStep","ProcessInstanceWorkitem","AIRecordInsight","AIInsightValue","AIInsightAction","AIInsightFeedback","AIInsightReason","MatchingInformation","Invoice","InvoiceLine","CreditMemo","CreditMemoLine","CreditMemoInvApplication"].map(e=>e.toLowerCase())),Q=new Set([G,H].map(e=>e.toLowerCase())),Z=["__b","__x","__dlm","__kav","__ka","__e"],$=new Set(["AccountContactRole",L,"CaseTeamMember","EmailMessageRelation","EventRelation","OpportunityCompetitor"].map(e=>e.toLowerCase()));function q(e,t,r,n,i){let o=e.name.toLowerCase();return V.has(o)||o.endsWith("feed")?"chatter":o.endsWith("history")||o.endsWith("__hd")||X.has(o)?"history":o.endsWith("share")?"sharing":o.endsWith("changeevent")?"changeEvent":Z.some(c=>o.endsWith(c))?"unsupportedKind":e.customSetting===!0?n?A(e,i)?void 0:"notWritable":"customSetting":Q.has(o)?"heldWithFiles":o===D.toLowerCase()?(i==="delete"?_(e):T(e))?void 0:"notWritable":o===L.toLowerCase()?A(e,i)?void 0:"notWritable":S(e.name)?"files":Y.has(o)?"platformCreated":E(e.name)||r==="everything"&&e.layoutable===!1&&!$.has(o)?"setup":t.out.has(o)?t.tooling.has(o)?"metadata":"notWritable":A(e,i)?void 0:"notWritable"}function A(e,t){return t==="delete"?_(e):ee(e)}function ee(e){return e.createable===!0&&T(e)}function _(e){return e.queryable===!0&&e.deletable===!0}function T(e){return e.queryable===!0&&e.updateable===!0&&e.deletable===!0}function k(e,t){return e.objectApiName<t.objectApiName?-1:e.objectApiName>t.objectApiName?1:0}var te="all";function ne(e){return e.customSetting===!0}function oe(e,t){let r=e.filter(ne);if(t===void 0)return{held:new Set,unknown:[]};if(t===te)return{held:new Set(r.map(c=>c.name.toLowerCase())),unknown:[]};let n=new Set(r.map(c=>c.name.toLowerCase())),i=new Set,o=[];for(let c of t){let p=c.toLowerCase();i.has(p)||o.some(u=>u.toLowerCase()===p)||(n.has(p)?i.add(p):o.push(c))}return{held:i,unknown:o}}function he(e,t,r=[]){let n=t.access??"write",i=n==="delete"?r:x(e,r),o={out:new Set([...i].map(a=>a.toLowerCase())),tooling:new Set(r.map(a=>a.toLowerCase()))},c=new Set((t.excluded??[]).map(a=>a.toLowerCase())),p=new Map(e.map(a=>[a.name.toLowerCase(),a])),u=oe(e,t.customSettings),h=u.unknown.map(a=>({objectApiName:a,reason:"notCustomSetting"})),g=[],f=[],s=[];if(t.mode==="picked"){let a=new Set;for(let d of t.objects??[]){let l=d.toLowerCase();if(a.has(l))continue;a.add(l);let m=p.get(l);m?f.push(m):h.push({objectApiName:d,reason:"notFound"})}for(let d of J){let l=d.toLowerCase(),m=p.get(l);if(!(a.has(l)||m===void 0)){if(c.has(l)){h.push({objectApiName:m.name,reason:"excludedByUser"});continue}f.push(m),s.push(m.name)}}for(let[d,l]of Object.entries(K)){let m=d.toLowerCase(),C=p.get(m);if(!(a.has(m)||C===void 0)&&l.some(j=>a.has(j.toLowerCase()))){if(a.add(m),c.has(m)){h.push({objectApiName:C.name,reason:"excludedByUser"});continue}f.push(C)}}for(let d of u.held){let l=p.get(d);a.has(d)||l===void 0||(a.add(d),f.push(l))}}else f.push(...p.values());for(let a of f){let d=a.name.toLowerCase(),l=c.has(d)?"excludedByUser":q(a,o,t.mode,u.held.has(d),n);l===void 0?g.push(a.name):h.push({objectApiName:a.name,reason:l})}return g.sort(),h.sort(k),{mode:t.mode,candidates:g,leftOut:h,addedToPicked:s}}function be(e){return e.fields.find(r=>r.name==="Name")?.nillable===!0?"hierarchy":"list"}function Ce(e){return e==="hierarchy"?"SetupOwnerId":"Name"}function Se(e){return e.objects.some(t=>t.customSetting!==void 0)}function re(e){let t=e.split("__");return t.length>=3&&t[0]!==""?t[0]:void 0}var se=()=>({first:"child",firmness:0});function ie(e,t,r=se){let n=new Map(e.map((o,c)=>[o.toLowerCase(),c])),i=e.map(()=>new Map);return e.forEach((o,c)=>{for(let p of t.get(o)?.childRelationships??[]){let u=n.get(p.childSObject.toLowerCase());if(u===void 0||u===c)continue;let h=r(p);if(h===void 0)continue;let[g,f]=h.first==="child"?[u,c]:[c,u],s=i[g].get(f);(s===void 0||h.firmness>s)&&i[g].set(f,h.firmness)}}),N(e.map((o,c)=>c),i,Number.NEGATIVE_INFINITY).map(o=>e[o])}function N(e,t,r){let n=new Set(e),i=f=>[...t[f]].filter(([s,a])=>n.has(s)&&a>r).map(([s])=>s),o=ae(e,i,t.length),c=new Map;o.forEach((f,s)=>{for(let a of f)c.set(a,s)});let p=o.map(()=>0),u=o.map(()=>new Set);for(let f of e){let s=c.get(f)??0;for(let a of i(f)){let d=c.get(a)??0;d===s||u[s].has(d)||(u[s].add(d),p[d]++)}}let h=o.map(()=>!1),g=[];for(let f=o.length;f>0;f--){let s=-1;for(let d=0;d<o.length;d++){if(h[d]||p[d]>0)continue;let l=o[d].length===1,m=s>=0&&o[s].length===1;(s<0||l&&!m||l===m&&o[d][0]<o[s][0])&&(s=d)}h[s]=!0;let a=o[s];if(a.length===1)g.push(a[0]);else{let d=Number.POSITIVE_INFINITY;for(let l of a)for(let[m,C]of t[l])C>r&&c.get(m)===s&&C<d&&(d=C);g.push(...N(a,t,d))}for(let d of u[s])p[d]--}return g}function ae(e,t,r){let n=new Array(r).fill(-1),i=new Array(r).fill(0),o=new Array(r).fill(!1),c=[],p=[],u=0;for(let h of e){if(n[h]>=0)continue;let g=[],f=s=>{n[s]=u,i[s]=u,u++,c.push(s),o[s]=!0,g.push({node:s,edges:t(s),at:0})};for(f(h);g.length>0;){let s=g[g.length-1];if(s.at<s.edges.length){let l=s.edges[s.at++];n[l]<0?f(l):o[l]&&(i[s.node]=Math.min(i[s.node],n[l]));continue}g.pop();let a=g[g.length-1];if(a&&(i[a.node]=Math.min(i[a.node],i[s.node])),i[s.node]!==n[s.node])continue;let d=[];for(let l=c.pop();l!==void 0&&(o[l]=!1,d.push(l),l!==s.node);l=c.pop());p.push(d.sort((l,m)=>l-m))}}return p}function M(e){let t=new Map;for(let{objectApiName:r,namespace:n}of e)n!==void 0&&t.set(n,[...t.get(n)??[],r]);return[...t].sort(([r],[n])=>r<n?-1:r>n?1:0).map(([r,n])=>({namespace:r,objects:n.sort()}))}function ce(e,t){return ie(e,t).map((r,n)=>{let i=re(r);return{objectApiName:r,readOrder:n,...i===void 0?{}:{namespace:i}}})}function ye(e,t,r=new Map){let n=[...e.leftOut],i=[];for(let c of e.candidates){let p=t.get(c);if(p)p.fields.some(u=>u.name==="SystemModstamp")?p.fields.some(u=>u.name==="IsDeleted")?i.push(c):n.push({objectApiName:c,reason:"noRecycleBin"}):n.push({objectApiName:c,reason:"noSystemModstamp"});else{let u=r.get(c);n.push({objectApiName:c,reason:"notDescribed",...u===void 0?{}:{detail:u}})}}let o=ce(i,t);return{mode:e.mode,objects:o,leftOut:n.sort(k),packages:M(o)}}function Oe(e,t){if(t.size===0)return e;let r=[...e.leftOut],n=[];for(let i of e.objects){let o=t.get(i.objectApiName);o===void 0?n.push({...i,readOrder:n.length}):r.push({objectApiName:i.objectApiName,reason:"unreadable",detail:o})}return{...e,objects:n,leftOut:r.sort(k),packages:M(n)}}export{B as a,z as b,E as c,x as d,le as e,ge as f,D as g,H as h,G as i,L as j,J as k,te as l,ne as m,he as n,be as o,Ce as p,Se as q,re as r,ie as s,ye as t,Oe as u};
7
+ import{wc as S,xc as O}from"./chunk-6QSHWIZI.mjs";import{b as y,f as b,l as R}from"./chunk-WZQEK4WT.mjs";var v=["User","Group","Profile","UserRole","RecordType","Organization","Queue","PermissionSet","BusinessProcess","CurrencyType","DandBCompany","DuplicateRecordItem","DuplicateRecordSet","ProcessInstance","LoginHistory","LoginEvent","LoginIp","LoginGeo","AsyncApexJob","ApexLog","ApexTestResult","ApexTestQueueItem","LightningUsageByPageMetrics","LightningExitByPageMetrics","EventBusSubscriber","PlatformEventUsageMetric","CronTrigger","CronJobDetail","AttachedContentDocument","AttachedContentNote","CombinedAttachment","ContentBody","NoteAndAttachment","OwnedContentDocument","EntitySubscription","TopicAssignment","UserRecordAccess","DeclinedEventRelation","UndecidedEventRelation","AcceptedEventRelation","OpenActivity","ActivityHistory","AppUsageAssignment","AuthProvider","Folder","ContentDocument","ContentDocumentLink","OpportunityRelatedDeleteLog","CaseHistory2","Calendar","SlaProcess","AccountCleanInfo","ContactCleanInfo","LeadCleanInfo","ApprovalSubmission","ApprovalSubmissionDetail","ApprovalWorkItem","AIRecordInsight","AIInsightValue","MatchingInformation","Invoice","InvoiceLine","CreditMemo","CreditMemoLine","AppDefinition","BackgroundOperation","ContentTaxonomyTermRelationshipType","Dashboard","DashboardComponent","DeleteEvent","ManagedContentChannel","ManagedContentSpace","ManagedContentVariant","Report","ServiceSetupProvisioning","TabDefinition"],P=new Set(v.map(e=>e.toLowerCase())),W=["History","Feed","Share","ChangeEvent","__hd","__Tag","EventStore"].map(e=>e.toLowerCase()),F=/^vlocity_[a-z0-9]+__/;function B(e,t){return I(e,t,{byNamespace:!0})}function I(e,t,r){let n=e.toLowerCase();return P.has(n)||S(e)||t&&(t.has(e)||U(t).has(n))||r.byNamespace&&F.test(n)?!0:W.some(i=>n.endsWith(i))}var w=new WeakMap;function U(e){let t=w.get(e);if(t&&t.size===e.size)return t.names;let r=new Set([...e].map(n=>n.toLowerCase()));return w.set(e,{size:e.size,names:r}),r}function z(e,t){return O(e)||B(e,t)}function E(e){return O(e)||I(e,void 0,{byNamespace:!1})}function x(e,t=[]){let r=new Set(t);for(let n of e)n.createable===!1&&r.add(n.name);return r}function le(e,t=r=>z(r)){return new Set(e.filter(r=>{let n=r.referenceTo??[];return n.length>0&&n.every(i=>t(i))}).map(r=>r.name))}var ge=R({name:y(),queryable:b().optional(),createable:b().optional(),updateable:b().optional(),deletable:b().optional(),undeletable:b().optional(),customSetting:b().optional(),layoutable:b().optional(),keyPrefix:y().nullish()}).loose(),D="ContentDocument",H="ContentDocumentLink",G="ContentVersion",L="Attachment",J=[D,L],K={AccountContactRelation:["Contact"]},V=new Set(["feeditem","feedcomment","feedattachment"]),X=new Set(["casehistory2"]),Y=new Set(["AccountCleanInfo","ContactCleanInfo","LeadCleanInfo","ApprovalSubmission","ApprovalSubmissionDetail","ApprovalWorkItem","ProcessInstance","ProcessInstanceNode","ProcessInstanceStep","ProcessInstanceWorkitem","AIRecordInsight","AIInsightValue","AIInsightAction","AIInsightFeedback","AIInsightReason","MatchingInformation","Invoice","InvoiceLine","CreditMemo","CreditMemoLine","CreditMemoInvApplication"].map(e=>e.toLowerCase())),Q=new Set([G,H].map(e=>e.toLowerCase())),Z=["__b","__x","__dlm","__kav","__ka","__e"],$=new Set(["AccountContactRole",L,"CaseTeamMember","EmailMessageRelation","EventRelation","OpportunityCompetitor"].map(e=>e.toLowerCase()));function q(e,t,r,n,i){let o=e.name.toLowerCase();return V.has(o)||o.endsWith("feed")?"chatter":o.endsWith("history")||o.endsWith("__hd")||X.has(o)?"history":o.endsWith("share")?"sharing":o.endsWith("changeevent")?"changeEvent":Z.some(c=>o.endsWith(c))?"unsupportedKind":e.customSetting===!0?n?A(e,i)?void 0:"notWritable":"customSetting":Q.has(o)?"heldWithFiles":o===D.toLowerCase()?(i==="delete"?_(e):T(e))?void 0:"notWritable":o===L.toLowerCase()?A(e,i)?void 0:"notWritable":S(e.name)?"files":Y.has(o)?"platformCreated":E(e.name)||r==="everything"&&e.layoutable===!1&&!$.has(o)?"setup":t.out.has(o)?t.tooling.has(o)?"metadata":"notWritable":A(e,i)?void 0:"notWritable"}function A(e,t){return t==="delete"?_(e):ee(e)}function ee(e){return e.createable===!0&&T(e)}function _(e){return e.queryable===!0&&e.deletable===!0}function T(e){return e.queryable===!0&&e.updateable===!0&&e.deletable===!0}function k(e,t){return e.objectApiName<t.objectApiName?-1:e.objectApiName>t.objectApiName?1:0}var te="all";function ne(e){return e.customSetting===!0}function oe(e,t){let r=e.filter(ne);if(t===void 0)return{held:new Set,unknown:[]};if(t===te)return{held:new Set(r.map(c=>c.name.toLowerCase())),unknown:[]};let n=new Set(r.map(c=>c.name.toLowerCase())),i=new Set,o=[];for(let c of t){let p=c.toLowerCase();i.has(p)||o.some(u=>u.toLowerCase()===p)||(n.has(p)?i.add(p):o.push(c))}return{held:i,unknown:o}}function he(e,t,r=[]){let n=t.access??"write",i=n==="delete"?r:x(e,r),o={out:new Set([...i].map(a=>a.toLowerCase())),tooling:new Set(r.map(a=>a.toLowerCase()))},c=new Set((t.excluded??[]).map(a=>a.toLowerCase())),p=new Map(e.map(a=>[a.name.toLowerCase(),a])),u=oe(e,t.customSettings),h=u.unknown.map(a=>({objectApiName:a,reason:"notCustomSetting"})),g=[],f=[],s=[];if(t.mode==="picked"){let a=new Set;for(let d of t.objects??[]){let l=d.toLowerCase();if(a.has(l))continue;a.add(l);let m=p.get(l);m?f.push(m):h.push({objectApiName:d,reason:"notFound"})}for(let d of J){let l=d.toLowerCase(),m=p.get(l);if(!(a.has(l)||m===void 0)){if(c.has(l)){h.push({objectApiName:m.name,reason:"excludedByUser"});continue}f.push(m),s.push(m.name)}}for(let[d,l]of Object.entries(K)){let m=d.toLowerCase(),C=p.get(m);if(!(a.has(m)||C===void 0)&&l.some(j=>a.has(j.toLowerCase()))){if(a.add(m),c.has(m)){h.push({objectApiName:C.name,reason:"excludedByUser"});continue}f.push(C)}}for(let d of u.held){let l=p.get(d);a.has(d)||l===void 0||(a.add(d),f.push(l))}}else f.push(...p.values());for(let a of f){let d=a.name.toLowerCase(),l=c.has(d)?"excludedByUser":q(a,o,t.mode,u.held.has(d),n);l===void 0?g.push(a.name):h.push({objectApiName:a.name,reason:l})}return g.sort(),h.sort(k),{mode:t.mode,candidates:g,leftOut:h,addedToPicked:s}}function be(e){return e.fields.find(r=>r.name==="Name")?.nillable===!0?"hierarchy":"list"}function Ce(e){return e==="hierarchy"?"SetupOwnerId":"Name"}function Se(e){return e.objects.some(t=>t.customSetting!==void 0)}function re(e){let t=e.split("__");return t.length>=3&&t[0]!==""?t[0]:void 0}var se=()=>({first:"child",firmness:0});function ie(e,t,r=se){let n=new Map(e.map((o,c)=>[o.toLowerCase(),c])),i=e.map(()=>new Map);return e.forEach((o,c)=>{for(let p of t.get(o)?.childRelationships??[]){let u=n.get(p.childSObject.toLowerCase());if(u===void 0||u===c)continue;let h=r(p);if(h===void 0)continue;let[g,f]=h.first==="child"?[u,c]:[c,u],s=i[g].get(f);(s===void 0||h.firmness>s)&&i[g].set(f,h.firmness)}}),N(e.map((o,c)=>c),i,Number.NEGATIVE_INFINITY).map(o=>e[o])}function N(e,t,r){let n=new Set(e),i=f=>[...t[f]].filter(([s,a])=>n.has(s)&&a>r).map(([s])=>s),o=ae(e,i,t.length),c=new Map;o.forEach((f,s)=>{for(let a of f)c.set(a,s)});let p=o.map(()=>0),u=o.map(()=>new Set);for(let f of e){let s=c.get(f)??0;for(let a of i(f)){let d=c.get(a)??0;d===s||u[s].has(d)||(u[s].add(d),p[d]++)}}let h=o.map(()=>!1),g=[];for(let f=o.length;f>0;f--){let s=-1;for(let d=0;d<o.length;d++){if(h[d]||p[d]>0)continue;let l=o[d].length===1,m=s>=0&&o[s].length===1;(s<0||l&&!m||l===m&&o[d][0]<o[s][0])&&(s=d)}h[s]=!0;let a=o[s];if(a.length===1)g.push(a[0]);else{let d=Number.POSITIVE_INFINITY;for(let l of a)for(let[m,C]of t[l])C>r&&c.get(m)===s&&C<d&&(d=C);g.push(...N(a,t,d))}for(let d of u[s])p[d]--}return g}function ae(e,t,r){let n=new Array(r).fill(-1),i=new Array(r).fill(0),o=new Array(r).fill(!1),c=[],p=[],u=0;for(let h of e){if(n[h]>=0)continue;let g=[],f=s=>{n[s]=u,i[s]=u,u++,c.push(s),o[s]=!0,g.push({node:s,edges:t(s),at:0})};for(f(h);g.length>0;){let s=g[g.length-1];if(s.at<s.edges.length){let l=s.edges[s.at++];n[l]<0?f(l):o[l]&&(i[s.node]=Math.min(i[s.node],n[l]));continue}g.pop();let a=g[g.length-1];if(a&&(i[a.node]=Math.min(i[a.node],i[s.node])),i[s.node]!==n[s.node])continue;let d=[];for(let l=c.pop();l!==void 0&&(o[l]=!1,d.push(l),l!==s.node);l=c.pop());p.push(d.sort((l,m)=>l-m))}}return p}function M(e){let t=new Map;for(let{objectApiName:r,namespace:n}of e)n!==void 0&&t.set(n,[...t.get(n)??[],r]);return[...t].sort(([r],[n])=>r<n?-1:r>n?1:0).map(([r,n])=>({namespace:r,objects:n.sort()}))}function ce(e,t){return ie(e,t).map((r,n)=>{let i=re(r);return{objectApiName:r,readOrder:n,...i===void 0?{}:{namespace:i}}})}function ye(e,t,r=new Map){let n=[...e.leftOut],i=[];for(let c of e.candidates){let p=t.get(c);if(p)p.fields.some(u=>u.name==="SystemModstamp")?p.fields.some(u=>u.name==="IsDeleted")?i.push(c):n.push({objectApiName:c,reason:"noRecycleBin"}):n.push({objectApiName:c,reason:"noSystemModstamp"});else{let u=r.get(c);n.push({objectApiName:c,reason:"notDescribed",...u===void 0?{}:{detail:u}})}}let o=ce(i,t);return{mode:e.mode,objects:o,leftOut:n.sort(k),packages:M(o)}}function Oe(e,t){if(t.size===0)return e;let r=[...e.leftOut],n=[];for(let i of e.objects){let o=t.get(i.objectApiName);o===void 0?n.push({...i,readOrder:n.length}):r.push({objectApiName:i.objectApiName,reason:"unreadable",detail:o})}return{...e,objects:n,leftOut:r.sort(k),packages:M(n)}}export{B as a,z as b,E as c,x as d,le as e,ge as f,D as g,H as h,G as i,L as j,J as k,te as l,ne as m,he as n,be as o,Ce as p,Se as q,re as r,ie as s,ye as t,Oe as u};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a,b,c,d,e,f,g}from"./chunk-742SSN7I.mjs";import"./chunk-DMBR24CK.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{f as STANDARD_PRICEBOOK_MATCHED_NOTE,b as namesAPricebook,d as pricesHeldWithTheirs,e as pricesHeldWithTheirsNote,a as readStandardPricebooks,c as settleSyncPrices,g as withPricesSettled};
7
+ import{a,b,c,d,e,f,g}from"./chunk-6YC2ELCU.mjs";import"./chunk-QLRWU3MB.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{f as STANDARD_PRICEBOOK_MATCHED_NOTE,b as namesAPricebook,d as pricesHeldWithTheirs,e as pricesHeldWithTheirsNote,a as readStandardPricebooks,c as settleSyncPrices,g as withPricesSettled};
@@ -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{e as a,f as b,g as c,h as d,i as e,j as f,k as g,l as h,m as i,n as j,o as k,p as l,q as m,r as n}from"./chunk-BH76USTQ.mjs";import"./chunk-XKFHTBAB.mjs";import"./chunk-FYWNSMOZ.mjs";import"./chunk-WBELLGNE.mjs";import"./chunk-OS5GE52G.mjs";import"./chunk-BPHTA6KP.mjs";import"./chunk-U2CTKIPE.mjs";import"./chunk-NDFFIJL5.mjs";import"./chunk-I5C4O3VA.mjs";import"./chunk-RVCPQVKM.mjs";import"./chunk-ALBY5SOH.mjs";import"./chunk-FKCIGJOI.mjs";import"./chunk-C6RKM4BB.mjs";import"./chunk-IHGYJZZ2.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-WB2RIVO3.mjs";import"./chunk-AXFD2OH6.mjs";import"./chunk-X2XZQ434.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-O7GCCRPW.mjs";import"./chunk-4X5D3MSV.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-XMQ5R6TC.mjs";import"./chunk-IXIY6Q4M.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-54HYHHVL.mjs";import"./chunk-QIRO4HTE.mjs";import"./chunk-BT43WSOS.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-EOQON3E5.mjs";import"./chunk-Y7YUNRKK.mjs";import"./chunk-4JKR4PTZ.mjs";import"./chunk-N2HYG3BL.mjs";import"./chunk-7WSQ65WG.mjs";import"./chunk-MJD6CPZZ.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-OUU47Y7A.mjs";import"./chunk-4GCYGQXD.mjs";import"./chunk-WXU6ZJIV.mjs";import"./chunk-R3OM3X4L.mjs";import"./chunk-77IVKH7R.mjs";import"./chunk-2WMKJVD2.mjs";import"./chunk-PPGDAUEQ.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-VXZ5PTOM.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-ZOSESZ22.mjs";import"./chunk-ZXOUWHYE.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-Z3MGN42K.mjs";import"./chunk-2GSMHGIV.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ISOSTAJR.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-7BQMBXKX.mjs";import"./chunk-KWAVSZ2B.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{d as NOT_REMADE_WORDS,b as OTHERS_DELETION_WORDS,c as OUT_OF_REACH_WORDS,j as REWIND_AUTOMATION_LIFTED_BY,a as REWIND_RESIDUAL_IDS,i as RewindStopped,k as automationUnread,m as counted,h as heldWhile,l as inRewindWords,g as muteOfSteps,e as notAskedWords,n as rewindOrg,f as rewindOrgOf};
@@ -4,7 +4,7 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a as _}from"./chunk-3B5H24ZG.mjs";import{k as S}from"./chunk-DPYTG6DM.mjs";var x="#N/A";function I(e,t,r){let n=[],o=new Map,a=t.map(u=>{let m=new Map;for(let[b,h]of D(e,u)){let p=b.toLowerCase(),i=o.get(p);i===void 0&&(i=n.push(b)-1,o.set(p,i)),m.set(i,$(h))}return m}).map(u=>n.map((m,b)=>u.get(b)??"")),l=[n.map(C).join(",")];for(let u of a)l.push(u.length===1&&u[0]===""?'""':u.map(C).join(","));return{text:`${l.join(`
7
+ import{a as _}from"./chunk-ISOSTAJR.mjs";import{k as S}from"./chunk-6QSHWIZI.mjs";var x="#N/A";function I(e,t,r){let n=[],o=new Map,a=t.map(u=>{let m=new Map;for(let[b,h]of D(e,u)){let p=b.toLowerCase(),i=o.get(p);i===void 0&&(i=n.push(b)-1,o.set(p,i)),m.set(i,$(h))}return m}).map(u=>n.map((m,b)=>u.get(b)??"")),l=[n.map(C).join(",")];for(let u of a)l.push(u.length===1&&u[0]===""?'""':u.map(C).join(","));return{text:`${l.join(`
8
8
  `)}
9
9
  `,columns:n,rows:a,identity:U(e,n,r)}}function y(e,t,r){let n=r==="exact"?E:A;return JSON.stringify(t.map(o=>n(e[o]??"")))}function ue(e){let t=new Map,r=new Set;return e.rows.forEach((n,o)=>{let c=y(n,e.identity,"canonical"),a=t.get(c);a===void 0?t.set(c,o):(r.add(a),r.add(o))}),r}function ie(e){let t=[];for(let[r,n]of e){let o=A(n);o!==""&&t.push(`${r.toLowerCase()}${o}`)}return t.sort().join("")}function J(e,t){return e.map(r=>{let n=t[r];return typeof n=="string"?n:n==null?"":String(n)})}function D(e,t){if(e==="delete"||e==="hardDelete")return[["Id",t.Id]];let r=[];for(let[n,o]of Object.entries(t))n==="attributes"||n==="type"||e==="insert"&&n.toLowerCase()==="id"||O(n,o,r);return r}function O(e,t,r){if(!N(t)){r.push([e,t]);return}for(let[n,o]of Object.entries(t))n!=="attributes"&&O(`${e}.${n}`,o,r)}function N(e){if(e===null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function $(e){return e===void 0?"":e===null?x:typeof e=="string"?e:e instanceof Date?Number.isNaN(e.getTime())?"":e.toISOString():typeof e=="object"?JSON.stringify(e):String(e)}function C(e){return/[",\r\n]/.test(e)?`"${e.replaceAll('"','""')}"`:e}function U(e,t,r){let n=e==="insert"?void 0:e==="upsert"?r:"Id",o=n===void 0?-1:t.findIndex(c=>c.toLowerCase()===n.toLowerCase());return o>=0?[o]:t.map((c,a)=>a)}function E(e){return e===x?"":e.replace(/\r\n?/g,`
10
10
  `)}var T=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/,v=/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/;function A(e){let t=E(e),r=t.toLowerCase();if(r==="true"||r==="false")return r;if(T.test(t))return String(Number(t));let n=v.exec(t);if(n){let o=t.includes("T")&&n[1]===void 0,c=Date.parse(o?`${t}Z`:t);if(!Number.isNaN(c))return`@${c}`}return _(t)??t}var F="No result returned by Bulk API job",K="Record not processed by Bulk API job",B=10,w=5e3;function H(e){if(e===!0||e==="true")return!0;if(e===!1||e==="false")return!1}function z(e,t,r){let n=t.rows.length,o=[],c=[],a=0,l=[],u=new Array(n).fill(!1),m=(i,s,g)=>{s>=0&&s<n&&!u[s]?(u[s]=!0,o.push({recordIndex:s,id:i,success:!0,...g!==void 0?{created:g}:{}})):(a++,i!==void 0&&c.push(i))},b=(i,s,g)=>{s>=0&&s<n&&!u[s]?(u[s]=!0,o.push({recordIndex:s,success:!1,error:i,...g?{state:g}:{}})):l.push(i)},h=r?` (${r})`:"";if(Array.isArray(e))e.forEach((i,s)=>{i.success?m(i.id,s):b(i.errors?.join(", ")??"Unknown error",s)});else{let i=[];for(let f of e.successfulResults??[]){let k=typeof f.sf__Id=="string"?f.sf__Id:void 0,R=H(f.sf__Created);i.push({row:f,settle:d=>m(k,d,R),orphan:()=>m(k,-1)})}for(let f of e.failedResults??[]){let k=typeof f.sf__Error=="string"&&f.sf__Error.length>0?f.sf__Error:"Unknown error";i.push({row:f,settle:R=>b(k,R),orphan:()=>b(k,-1)})}let s=e.unprocessedRecords;for(let f of Array.isArray(s)?s:[]){let k=`${K}${h}`;i.push({row:f,settle:R=>b(k,R,"unprocessed"),orphan:()=>b(k,-1)})}let g=i;for(let f of["exact","canonical"])g.length>0&&(g=W(f,g,t,u));for(let f of g)f.orphan()}let p=`${F}${h}${Z(c,l)}`;for(let i=0;i<n;i++)u[i]||b(p,i,"no-result");return o.sort((i,s)=>i.recordIndex-s.recordIndex),{outcomes:o,unattributedSuccessIds:c,unattributedSuccesses:a,unattributedFailures:l}}function W(e,t,r,n){let o=new Map;r.rows.forEach((a,l)=>{if(n[l])return;let u=y(a,r.identity,e),m=o.get(u);m?m.push(l):o.set(u,[l])});let c=[];for(let a of t){let l=y(J(r.columns,a.row),r.identity,e),u=o.get(l)?.shift();u===void 0?c.push(a):a.settle(u)}return c}function Z(e,t){let r=[];if(e.length>0){let n=e.slice(0,B).join(", "),o=e.length>B?` and ${e.length-B} more`:"";r.push(`wrote ${e.length} record(s) no row was matched to: ${n}${o}`)}return t.length>0&&r.push(`did not write ${t.length} row(s) no row was matched to, the first for: ${t[0]}`),r.length>0?`; the job ${r.join("; it ")}`:""}function V(e){let t;try{t=e.id}catch{return}return typeof t=="string"&&/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/.test(t)?t:void 0}function q(e){if(e.state!=="JobComplete")return e.errorMessage||`job ${e.state}`}async function X(e){try{await e.abort()}catch{}}var P=class{threshold;constructor(t=S.REST_API_BATCH_SIZE){this.threshold=t}shouldUseBulkApi(t){return t>this.threshold}getThreshold(){return this.threshold}async executeBulk(t,r,n,o,c){if(!t.bulkManager.canStartNewJob())throw new Error("Maximum concurrent bulk jobs reached");let a=I(n,o,c),l=t.connection.bulk2.createJob({operation:n,object:r,...c?{externalIdFieldName:c}:{}}),u=l.id??`bulk-${crypto.randomUUID()}`,m={id:u,operation:n,object:r,state:"UploadComplete",numberRecordsProcessed:0,numberRecordsFailed:0,totalProcessingTime:0,createdDate:new Date().toISOString()};t.bulkManager.registerJob(m);try{await l.open();let b=V(l);b!==void 0&&t.onOpened?.(b);let h=0;if(t.signal?.aborted||(await l.uploadData(a.text),h=o.length),t.signal?.aborted)return await X(l),t.bulkManager.updateJobState(u,"Aborted"),{totalRecords:h,successCount:0,failureCount:0,failures:[],jobId:u,usedBulkApi:!0,successIds:[],outcomes:[],aborted:!0};await l.close();let p=await l.check();for(let d=0;p.state==="InProgress"||p.state==="UploadComplete";d++){t.bulkManager.updateJobState(u,p.state),t.onProgress?.(p.numberRecordsProcessed??0,o.length);let M=t.pollIntervalMs?.(d)??w;await new Promise(j=>setTimeout(j,M)),p=await l.check()}let i=await l.getAllResults(),s=z(i,a,q(p)),g=s.outcomes.filter(d=>!d.success).map(d=>({recordIndex:d.recordIndex,error:d.error??"Unknown error"}));for(let d of s.unattributedFailures)g.push({recordIndex:-1,error:d});let f=s.outcomes.filter(d=>d.success&&d.id!==void 0).map(d=>d.id).concat(s.unattributedSuccessIds),k=s.outcomes.filter(d=>d.success).length+s.unattributedSuccessIds.length,R=p.state==="JobComplete"?"JobComplete":"Failed";return t.bulkManager.updateJobState(u,R),t.bulkManager.updateJobCounts(u,p.numberRecordsProcessed??o.length,g.length),{totalRecords:o.length,successCount:k,failureCount:g.length,failures:g,jobId:u,usedBulkApi:!0,successIds:f,outcomes:s.outcomes,...s.unattributedSuccessIds.length>0?{unmatchedIds:s.unattributedSuccessIds}:{},...s.unattributedSuccesses>0?{unmatchedWrites:s.unattributedSuccesses}:{}}}catch(b){throw t.bulkManager.updateJobState(u,"Failed"),b}}};var G=3,Q=3,Y=24,ee=750,L=()=>w,be=e=>[5e3,1e4,2e4][e]??3e4,te=60;function ne(e){return Q+e.stateReads+(e.resultReads??G)}function re(e,t="delete"){let r=t==="save"?te:ee;return Y+Math.max(0,e)/r}function oe(e,t=L,r="delete"){let n=re(e,r)*1e3,o=0,c=0;for(;o<n;)o+=Math.max(1,t(c)),c++;return 1+c}function ge(e){return ne({stateReads:oe(e,L,"save")})}export{I as a,ue as b,ie as c,z as d,V as e,q as f,X as g,P as h,G as i,be as j,ne as k,re as l,oe as m,ge as n};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r}from"./chunk-4X5D3MSV.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-WXU6ZJIV.mjs";import"./chunk-R3OM3X4L.mjs";import"./chunk-77IVKH7R.mjs";import"./chunk-2WMKJVD2.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-VXZ5PTOM.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-ZOSESZ22.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-Z3MGN42K.mjs";import"./chunk-2GSMHGIV.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ISOSTAJR.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{p as actDeliverability,o as actEmailsGate,n as actSendersOf,q as afterLeaseEmailsRefusal,l as checkpointEmails,j as checkpointEmailsUncounted,c as draftedByDiff,d as draftedByPlan,a as emailsOfLimit,m as emailsRefusal,k as emailsUncountedWords,r as pageEmailsRefusal,e as statusBackByDiff,f as statusBackByPlan,b as updatedByDiff,g as writtenByDiff,h as writtenByPlan,i as writtenByUndo};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a as P}from"./chunk-ICIYL45C.mjs";import{d as J}from"./chunk-ZUA5BNAO.mjs";import{d as Z}from"./chunk-HFSBDM7B.mjs";import{c as H,g as Y}from"./chunk-OHEOJISY.mjs";import{a as F}from"./chunk-EADHKH3A.mjs";import{g as W,t as Q}from"./chunk-55LQD3Y3.mjs";import{a as U,f as D,h as k}from"./chunk-TZE3Y7IQ.mjs";import{O as z,Q as B,T as V,vc as R}from"./chunk-DPYTG6DM.mjs";import{b as I,k as G,l as A,v as K,z as _}from"./chunk-WZQEK4WT.mjs";function Le(e){let n=new Set;for(let t of e)t.controllerName&&n.add(t.controllerName);return n}function X(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0}function je(e,n){let t=X(e.precision),r=typeof e.scale=="number"&&e.scale>=0?e.scale:void 0,o=X(e.digits),s=(e.picklistValues??[]).filter(d=>d!==null&&typeof d.value=="string"),i={};if(e.controllerName)for(let d of s)d.active===!1||typeof d.validFor!="string"||(i[d.value]=d.validFor);return{...t!==void 0?{precision:t}:{},...t!==void 0&&r!==void 0?{scale:r}:{},...o!==void 0?{digits:o}:{},...e.unique===!0?{unique:!0}:{},...e.unique===!0&&typeof e.caseSensitive=="boolean"?{caseSensitive:e.caseSensitive}:{},...e.calculated===!0?{calculated:!0}:{},...e.filteredLookupInfo?{filteredLookup:!0}:{},...Object.keys(i).length>0?{validFor:i}:{},...n.has(e.name)&&s.length>0?{controllingValues:s.map(d=>d.value)}:{}}}function Ce(e,n){return e.caseSensitive===!1?n.toLowerCase():n}function M(e,n){if(n<0)return!1;let r=Buffer.from(e,"base64")[n>>3];return r!==void 0&&(r&128>>n%8)!==0}var ie={picklist_value_refused:["map_value","leave_empty","skip_rows","exclude_object","ignore"],dependent_value_invalid:["map_value","leave_empty","exclude_object","ignore"],picklist_value_absent:["map_value","skip_rows","ignore"],required_field_missing:["set_default","exclude_object","ignore"],value_too_long:["truncate","exclude_object","ignore"],number_out_of_range:["exclude_object","ignore"],record_type_unmapped:["map_record_type","exclude_object","ignore"],record_type_unavailable:["map_record_type","exclude_object","ignore"],currency_inactive:["map_value","skip_rows","exclude_object","ignore"],unique_value_collision:["exclude_object","ignore"]};function w(e){return[...ie[e]??["ignore"]]}var se=100,ae=new Set(["longest","colliding"]),O=class{gaps=new Map;recordTypes=new Map;get size(){return this.gaps.size}knowRecordTypes(n,t,r){let o=de(r);o!==void 0&&this.recordTypes.set(n,{...this.recordTypes.get(n),[t]:o})}add(n){let t=z(n.kind,n.objectApiName,n.field,n.recordType,n.value),r=this.gaps.get(t);if(!r){this.gaps.set(t,{...n,id:t,source:"simulation",decisions:[...n.decisions]});return}r.rows+=n.rows,n.decisions.includes("skip_rows")||(r.decisions=r.decisions.filter(s=>s!=="skip_rows"));let o={...n.detail??{},...r.detail??{}};for(let s of ae){let i=r.detail?.[s],d=n.detail?.[s];typeof i=="number"&&typeof d=="number"&&(o[s]=Math.max(i,d))}r.detail=o}list(n){let t=[...this.gaps.keys()],r=[...this.gaps.values()].map(o=>this.withSameDeveloperName(o)).map(o=>B(n,o,t)!==void 0?{...o,detail:{...o.detail??{},ignored:!0}}:o);return V(r)}withSameDeveloperName(n){let t=n.kind==="record_type_unmapped";return le(n,this.recordTypes.get(n.objectApiName)?.[t?"source":"target"])}};function de(e){let n=e.filter(t=>!t.master);if(!n.some(t=>t.namespacePrefix===void 0))return n.map(Z)}function le(e,n){let t=e.kind==="record_type_unmapped"?e.value:e.recordType;if(t===void 0||n===void 0)return e;let r=Y(t);if(!r.namespacePrefix)return e;let o=n.filter(s=>s.developerName===r.developerName&&s.namespacePrefix!==r.namespacePrefix).map(s=>H(s.namespacePrefix,s.developerName));return o.length===0?e:{...e,detail:{...e.detail??{},sameDeveloperName:[...new Set(o)].sort()}}}function L(e){return[...new Set(e)].sort().slice(0,se)}function We(e,n,t){let r=[];for(let o of n){if(o.field===P)continue;let s=t(o);for(let i of o.values)r.push({kind:"picklist_value_refused",severity:"warning",objectApiName:e,field:o.field,...o.recordType!==void 0?{recordType:o.recordType}:{},value:i,rows:1,detail:{reason:o.reason,...s?{allowed:L(s)}:{},...o.controllingField?{controllingField:o.controllingField}:{},...o.replacedBy!==void 0?{replacement:o.replacedBy}:{}},decisions:w("picklist_value_refused").filter(d=>d!=="skip_rows"||o.reason!=="controlling-value"),defaultDecision:o.replacedBy!==void 0?"map_value":"leave_empty"})}return r}var ce=new Set(["string","textarea","email","phone","url","encryptedstring"]),ue=new Set(["double","currency","percent"]);function fe(e){return e==null||e===""}function ne(e){return e.createable&&e.nillable===!1&&e.defaultedOnCreate!==!0&&e.calculated!==!0&&e.type!=="boolean"}function pe(e,n,t){return e==="Account"&&n==="Name"&&Q(t)}function ge(e,n,t,r){return r.filter(o=>ne(o)&&fe(n[o.name])&&!pe(e,o.name,t))}function me(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e!="string"||e.trim()==="")return;let n=Number(e);return Number.isFinite(n)?n:void 0}function ee(e){if(e.type==="int"&&e.digits!==void 0)return e.digits;if(e.precision!==void 0)return e.precision-(e.scale??0)}function ye(e,n){return e?e.type==="boolean"?n===!0||n==="true"?1:n===!1||n==="false"?0:-1:typeof n!="string"||n===""?-1:(e.controllingValues??[]).indexOf(n):-1}function te(e,n){let{objectApiName:t,rows:r,targetFields:o,picklistValuesByField:s,picklistFields:i}=e,d=new Map(o.map(u=>[u.name,u])),f=o.filter(ne),y=o.filter(u=>u.createable&&ce.has(u.type??"")&&(u.length??0)>0),g=o.filter(u=>u.createable&&(ue.has(u.type??"")||u.type==="int")&&ee(u)!==void 0),c=[...i].filter(([u,l])=>l.anyValue===!0&&s?.has(u)===!0),p=o.filter(u=>u.createable&&u.controllerName!==void 0&&u.validFor!==void 0);for(let{payload:u,source:l,typed:m}of r){for(let a of ge(t,u,l,f))n.add({kind:"required_field_missing",severity:"blocking",objectApiName:t,field:a.name,rows:1,...a.type?{detail:{type:a.type}}:{},decisions:w("required_field_missing")});for(let a of y){let h=u[a.name],b=a.length??0;typeof h!="string"||h.length<=b||n.add({kind:"value_too_long",severity:"blocking",objectApiName:t,field:a.name,rows:1,detail:{length:b,longest:h.length},decisions:w("value_too_long")})}for(let a of g){let h=me(u[a.name]),b=ee(a);h===void 0||b===void 0||Math.abs(Math.trunc(h))<10**b||n.add({kind:"number_out_of_range",severity:"blocking",objectApiName:t,field:a.name,rows:1,detail:{...a.precision!==void 0?{precision:a.precision}:{},...a.scale!==void 0?{scale:a.scale}:{},...a.type==="int"&&a.digits!==void 0?{digits:a.digits}:{}},decisions:w("number_out_of_range")})}for(let[a,h]of c){let b=u[a];if(typeof b!="string"||b==="")continue;let x=s?.get(a),v=h.multi?b.split(";"):[b];for(let E of new Set(v))x?.has(E)||n.add({kind:"picklist_value_absent",severity:"info",objectApiName:t,field:a,value:E,rows:1,decisions:w("picklist_value_absent")})}if(!m)for(let a of p){let h=u[a.name];if(typeof h!="string"||h==="")continue;let b=d.get(a.controllerName??""),x=ye(b,u[a.controllerName??""]),v=i.get(a.name)?.restricted===!0,E=i.get(a.name)?.multi?h.split(";"):[h];for(let q of new Set(E)){let $=a.validFor?.[q];$!==void 0&&(x>=0&&M($,x)||n.add({kind:"dependent_value_invalid",severity:v?"blocking":"warning",objectApiName:t,field:a.name,value:q,rows:1,detail:{controllingField:a.controllerName??"",allowed:L((b?.controllingValues??[]).filter((Me,oe)=>M($,oe)))},decisions:w("dependent_value_invalid")}))}}}}function Qe(e,n,t,r){return{kind:"currency_inactive",severity:"warning",objectApiName:e,field:P,value:n,rows:t,...r&&r.to.length>0?{detail:{replacement:r.to.join(", "),...r.converted.length>0?{amountsConverted:[...r.converted]}:{},...r.asRead?{amountsAsRead:!0}:{}}}:{},decisions:w("currency_inactive"),defaultDecision:"map_value"}}function He(e,n,t,r){return{kind:"unique_value_collision",severity:"warning",objectApiName:e,field:n,rows:t,detail:{colliding:r,linkedToTheRecordItNames:!0},decisions:w("unique_value_collision"),defaultDecision:"ignore"}}function Ye(e,n,t,r,o){return{kind:e,severity:"blocking",objectApiName:n,field:"RecordTypeId",...e==="record_type_unavailable"?{recordType:t}:{value:t},rows:r,detail:{mapTo:L(o)},decisions:w(e)}}var he=10;function re(e){switch(e.operation){case"insert":return null;case"upsert":return e.externalIdField??"Id";case"update":case"delete":return"Id"}}function S(e){if(e==null||typeof e!="string"&&typeof e!="number"&&typeof e!="boolean")return null;let n=String(e);return n===""?null:n.toLowerCase()}function T(e){return typeof e=="number"&&Number.isFinite(e)?String(e):typeof e=="boolean"?e?"true":"false":`'${U(String(e))}'`}var be=200,Se=4e3;function N(e){let n=[],t=[],r=0;for(let o of e){let s=T(o).length+2;t.length>0&&(t.length>=be||r+s>Se)&&(n.push(t),t=[],r=0),t.push(o),r+=s}return t.length>0&&n.push(t),n}function rn(e,n){return async(t,r,o,s)=>{let i=R(r.objectApiName),d=k(o),f=new Map;for(let y of N(s)){if(n?.aborted)throw new Error("The simulation was cancelled.");let{records:g}=await F(e,`SELECT ${d} FROM ${i} WHERE ${d} IN (${y.map(T).join(", ")})`);for(let c of g){let p=S(c[d]);p!==null&&f.set(p,(f.get(p)??0)+1)}}return f}}var we=new Set(["attributes","Id"]);function Re(e,n,t,r){return n?e.conflictFields.filter(o=>o!==t&&!we.has(o)&&o in n&&(r===null||r.has(o))):[]}var on=new Set(["noKey","notInTarget","ambiguous"]);function _e(e,n,t){let r=e.operation,o=re(e);if(o===null)return"insert";let s=S(n[o]);if(s===null)return r==="delete"?"notSent":"noKey";let i=t.get(s)??0;return r==="upsert"?i===0?o.toLowerCase()==="id"?"notInTarget":"insert":i===1?"update":"ambiguous":i===0?"notInTarget":r==="update"?"update":"delete"}var ke=1e4;function sn(e,n,t){let r=e>t?ke:Math.max(1,n);return{callOf:o=>Math.floor(o/r),job:e>t}}function an(e,n,t,r){let o=new Map;n.forEach((c,p)=>{if(c===null)return;let u=`${r.callOf(p)}\0${c}`,l=o.get(u);l?l.push(p):o.set(u,[p])});let s=new Set;for(let c of o.values())if(c.length>1)for(let p of c)s.add(p);let i=new Map,d=new Set,f=0;n.forEach((c,p)=>{if(c===null||s.has(p))return;let u=r.callOf(p);if(i.get(c)===void 0){t[p]==="insert"&&i.set(c,u);return}r.job?f++:t[p]==="insert"&&d.add(p)});let y=[],g=[];if(s.size>0){let c=`${s.size} record(s) carry the ${e} of another record of the same call: an upsert finds its record by its key, and the target refuses every record of a call whose key another carries (DUPLICATE_VALUE: Duplicate external id specified).`;y.push(c),g.push({code:"DUPLICATE_VALUE",rows:s.size,note:c})}return d.size>0&&y.push(`${d.size} record(s) carry the ${e} of a record sent in an earlier call: the upsert finds the record that one created and updates it with theirs.`),f>0&&y.push(`${f} record(s) carry the ${e} of a record in another batch of the Bulk API job: the platform may write the batches at once, so whether each updates the record the other created or creates one of its own cannot be told before the run.`),{refused:s,updated:d,notes:y,refusedFor:g}}function dn(e){let{objectConfig:n,records:t,inTarget:r}=e,o=n.operation,s=re(n),i={insert:0,update:0,delete:0,noKey:0,notInTarget:0,notSent:0,ambiguous:0},d=new Set;t.forEach((l,m)=>{let a=e.simulated?.[m]??_e(n,l,r);i[a]++,(a==="insert"||a==="update")&&d.add(m)});let f=e.leftOut.map(({why:l,count:m})=>W(m,l));i.noKey>0&&f.push(o==="upsert"?`${i.noKey} record(s) carry no value in ${s}: an upsert matches on it, and the target refuses a record without one.`:`${i.noKey} record(s) carry no Id: an update finds its record by Id, and the target refuses one without it.`),i.notInTarget>0&&f.push(`${i.notInTarget} record(s) carry an Id the target does not hold: ${o==="upsert"?"an upsert on the Id finds no record there and creates none":`${o==="update"?"an update":"a delete"} finds no record there`}, and the target refuses it. Two orgs share a record's Id only when it was copied with the org.`),i.ambiguous>0&&f.push(`${i.ambiguous} record(s) match more than one record of the target on ${s}: an upsert finds no single record to update, and the target refuses it.`),i.notSent>0&&f.push(`${i.notSent} record(s) carry no Id: a delete sends ids alone, so the run leaves them out.`);let y=new Map;e.unsettled.forEach((l,m)=>{let a=String(l[e.matchField]??"");a&&d.has(m)&&y.set(a,l)});let g=new Map,c=0;for(let l of e.conflicts){let m=Re(l,y.get(l.recordId),e.matchField,e.writable);if(m.length!==0){c++;for(let a of m)g.set(a,(g.get(a)??0)+1)}}let p=[...g].sort(([l,m],[a,h])=>h-m||l.localeCompare(a)).slice(0,he).map(([l])=>l),u=e.leftOut.reduce((l,{count:m})=>l+m,0);return{objectApiName:n.objectApiName,operation:o,read:e.read,insert:i.insert,update:i.update,delete:i.delete,skipped:u+i.notSent,refused:i.noKey+i.notInTarget+i.ambiguous,conflicts:c,conflictFields:p,notes:f}}var Fe={required_field_missing:"REQUIRED_FIELD_MISSING",value_too_long:"STRING_TOO_LONG",number_out_of_range:"NUMBER_OUTSIDE_VALID_RANGE"};function Ie(e){let n=e.field??"";switch(e.kind){case"required_field_missing":return`${e.rows} record(s) leave ${n} empty, which the target requires: it refuses them (REQUIRED_FIELD_MISSING).`;case"value_too_long":return`${e.rows} record(s) hold a ${n} longer than the ${String(e.detail?.length)} characters the target's field takes (the longest, ${String(e.detail?.longest)}): it refuses them (STRING_TOO_LONG).`;case"number_out_of_range":return`${e.rows} record(s) hold a ${n} larger than the target's field takes: it refuses them (NUMBER_OUTSIDE_VALID_RANGE).`;default:return}}function ln(e,n,t){let r=new Set,o=new O;n.forEach(({payload:i,source:d,creates:f},y)=>{let g=new O;te({objectApiName:e,rows:[{payload:i,source:d,typed:!0}],targetFields:t,picklistValuesByField:null,picklistFields:new Map},g);let c=g.list(new Set).filter(p=>p.severity==="blocking"&&(f||p.kind!=="required_field_missing"));if(c.length!==0){r.add(y);for(let p of c)o.add(p)}});let s=o.list(new Set).flatMap(i=>{let d=Ie(i),f=Fe[i.kind];return d&&f?[{code:f,rows:i.rows,note:d}]:[]});return{refused:r,notes:s.map(({note:i})=>i),refusedFor:s}}function cn(e,n){let t=new Set,r=new Set,o=[],s=[];for(let[i,d]of n){let f=new Set,y=0,g=0,c=0;if(e.forEach((u,l)=>{let m=S(u[i]);if(m===null)return;let a=d.get(m)??0;a===1?(y++,r.add(l)):a>1?(g++,t.add(l)):f.has(m)&&(c++,t.add(l)),f.add(m)}),y>0&&o.push(`LINKED_TO_EXISTING: ${y} record(s) hold a ${i} the target keeps unique, which a record of the target holds already: it refuses them as duplicates (DUPLICATE_VALUE) and names that record, which the run links them to \u2014 what it writes under them points at that record.`),g+c===0)continue;let p=`${g+c} record(s) hold a ${i} the target keeps unique, which `+[g>0?`several records of the target hold already (${g})`:"",c>0?`a record sent before them holds (${c})`:""].filter(Boolean).join(" or ")+": it refuses them (DUPLICATE_VALUE).";o.push(p),s.push({code:"DUPLICATE_VALUE",rows:g+c,note:p})}for(let i of t)r.delete(i);return{refused:t,linked:r,notes:o,refusedFor:s}}import{createHash as Oe}from"node:crypto";var Te=5*6e4,xe=500,Ee=A({sourceOrgId:I().min(1).max(200),targetOrgId:I().min(1).max(200),objectApiName:I().regex(/^[A-Za-z][A-Za-z0-9_]{0,79}$/),watermark:_.datetime(),fingerprint:I().regex(/^[0-9a-f]{64}$/),recordedAt:_.datetime(),filesSeen:_.datetime().optional(),removedAt:_.datetime().optional()}),Ne=A({version:K(1),entries:G(Ee).max(xe),resetAt:_.datetime().optional()});function Sn(e){if(e==null)return{kind:"none"};let n=Ne.safeParse(e);if(n.success)return{kind:"stored",state:n.data};let t=n.error.issues[0];return{kind:"unreadable",issue:`${t.path.join(".")||"state"}: ${t.message}`}}function j(e){return Array.isArray(e)?`[${e.map(j).join(",")}]`:e!==null&&typeof e=="object"?`{${Object.entries(e).filter(([,t])=>t!==void 0).sort(([t],[r])=>t<r?-1:t>r?1:0).map(([t,r])=>`${JSON.stringify(t)}:${j(r)}`).join(",")}}`:JSON.stringify(e)}function C(e){let n=e?.trim();return n||null}function ve(e,n){let t={direction:e.direction,conflictStrategy:e.conflictStrategy,copiesFiles:e.files?!0:void 0,objectApiName:n.objectApiName,operation:n.operation,externalIdField:C(n.externalIdField),where:C(n.where),fieldMappings:n.fieldMappings??[],unmappedSentAsRead:(n.fieldMappings??[]).length>0?!0:void 0,transformRules:n.transformRules??[],excludedFields:n.excludedFields??[],addOnFields:n.addOnFields??[]};return Oe("sha256").update(j(t)).digest("hex")}function wn(e,n,t){let r=ve(e,n);if(t===null)return{read:"full",reason:"not_saved",fingerprint:r};if(t.kind==="unreadable")return{read:"full",reason:"unreadable",fingerprint:r};if(t.kind==="none")return{read:"full",reason:"first_run",fingerprint:r};let o=t.state.entries.find(s=>s.sourceOrgId===e.sourceOrgId&&s.targetOrgId===e.targetOrgId&&s.objectApiName===n.objectApiName);return o?o.fingerprint!==r?{read:"full",reason:"scope_changed",fingerprint:r}:o.removedAt!==void 0?{read:"full",reason:"removed",fingerprint:r}:{read:"delta",since:o.watermark,fingerprint:r,...o.filesSeen!==void 0?{filesSeen:o.filesSeen}:{}}:{read:"full",reason:t.state.resetAt?"reset":"first_run",fingerprint:r}}var $e=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/;function Rn(e,n=Te){let t=Date.parse(e);if(!Number.isFinite(t))throw new Error(`Not a watermark: "${e}".`);let r=Math.floor((t-n)/1e3)*1e3;return new Date(r).toISOString().replace(/\.\d{3}Z$/,"Z")}function _n(e){let n=Date.parse(e);if(!Number.isFinite(n))throw new Error(`Not a date: "${e}".`);return new Date(Math.floor(n/1e3)*1e3).toISOString().replace(/\.\d{3}Z$/,"Z")}function Ae(e){if(!$e.test(e)||!Number.isFinite(Date.parse(e)))throw new Error(`Not a SOQL datetime: "${e}".`);return e}function kn(e,n){let t=e?.trim()?D(e):void 0;if(n===void 0)return t;let r=`SystemModstamp > ${Ae(n)}`;return t?`${r} AND (${t})`:r}function De(e){if(typeof e!="string"||e==="")return null;let n=Date.parse(e.replace(/([+-]\d{2})(\d{2})$/,"$1:$2"));return Number.isFinite(n)?new Date(n).toISOString():null}function Fn(e,n,t){let r={query:i=>e.query(i),queryMore:i=>e.queryMore(i)},o={query:i=>e.query(i,{scanAll:!0}),queryMore:i=>e.queryMore(i)},s=()=>{if(t?.aborted)throw new Error("The run was cancelled.")};return{async latestModstamp(i){let d=R(i),y=(await e.query(`SELECT SystemModstamp FROM ${d} ORDER BY SystemModstamp DESC LIMIT 1`)).records[0];if(!y)return null;let g=De(y.SystemModstamp);if(g===null)throw new Error(`${d} answered a SystemModstamp that is not a date.`);return g},async deletedRows(i,d,f){let y=R(i),g=new Set(["Id","SystemModstamp",...d.map(k)]),{records:c,truncated:p}=await F(o,`SELECT ${[...g].join(", ")} FROM ${y} WHERE IsDeleted = true AND (${D(f)})`);return{records:c,truncated:p}},async heldInSource(i,d,f){let y=R(i),g=k(d),c=new Set;for(let p of N(f)){s();let{records:u}=await F(r,`SELECT ${g} FROM ${y} WHERE ${g} IN (${p.map(T).join(", ")})`);for(let l of u){let m=S(l[g]);m!==null&&c.add(m)}}return c},async targetIdsByKey(i,d,f){let y=R(i),g=k(d),c=g==="Id"?"Id":`Id, ${g}`,p=new Map;for(let u of N(f)){s();let{records:l}=await F(n,`SELECT ${c} FROM ${y} WHERE ${g} IN (${u.map(T).join(", ")})`);for(let m of l){let a=S(m[g]);a===null||typeof m.Id!="string"||p.set(a,[...p.get(a)??[],m.Id])}}return p}}}var Pe=new Set(["direct","rename","transform"]);function In(e){let n=e.objectApiName;if(e.operation==="insert"||e.operation==="delete")return{refused:`${n} is written by ${e.operation}, which finds no record by a key: a deleted source record cannot be tied to a target record.`};if(e.operation==="update")return{sourceField:"Id",keyField:"Id"};let t=C(e.externalIdField)??"Id";if((e.addOnFields??[]).some(s=>s.fieldApiName===t))return{refused:`${n}: an add-on writes ${t}, the key the upsert matches on, so it ties no deleted source record to one target record.`};let r=e.fieldMappings??[],o=r.find(s=>s.targetField.toLowerCase()===t.toLowerCase());return!o&&!J(r,e.excludedFields??[]).has(t.toLowerCase())?{sourceField:t,keyField:t}:!o||!Pe.has(o.type)?{refused:`${n}: no source field is carried onto ${t}, the key the upsert matches on, so no deleted source record can be tied to a target record.`}:{sourceField:o.sourceField,keyField:t}}async function On(e,n,t,r,o){let s=n.objectApiName,{records:i,truncated:d}=await e.deletedRows(s,[t.sourceField],r),f={ids:[],read:i.length,stillInSource:0,ambiguous:0,noKey:0,truncated:d};if(i.length===0)return f;let y=[];for(let l of i){let m=l[t.sourceField],a=o(l);if(S(m)===null||S(a)===null){f.noKey++;continue}y.push({raw:m,key:a})}if(y.length===0)return f;let g=t.sourceField==="Id"?new Set:await e.heldInSource(s,t.sourceField,y.map(l=>l.raw)),c=y.filter(l=>g.has(S(l.raw))?(f.stillInSource++,!1):!0);if(c.length===0)return f;let p=await e.targetIdsByKey(s,t.keyField,c.map(l=>l.key)),u=new Set;for(let l of c){let m=p.get(S(l.key))??[];m.length>1?f.ambiguous++:m.length===1&&!u.has(m[0])&&(u.add(m[0]),f.ids.push(m[0]))}return f}function Tn(e,n){let t=[];return e.stillInSource>0&&t.push(`${e.stillInSource} record(s) deleted in the source share their ${n} with a record the source still holds: their target record was kept.`),e.ambiguous>0&&t.push(`${e.ambiguous} record(s) deleted in the source match more than one target record on ${n}: none of those target records was deleted.`),e.noKey>0&&t.push(`${e.noKey} record(s) deleted in the source carry no ${n}: no target record is tied to them.`),e.truncated&&t.push("The source's deleted records were read up to a bound: the rest are read by the next run, from the same watermark."),t}function xn(e,n,t,r,o=0){return{read:e.read,...e.read==="delta"?{since:e.since}:{reason:e.reason},changed:n,deletionsChecked:t!==void 0,deleted:t?.deleted??0,deleteFailed:t?.deleteFailed??0,...t?.error!==void 0?{deletionError:t.error}:{},...r!==void 0?{recorded:r}:{},...o>0?{lookupsOwed:o}:{}}}export{Le as a,je as b,Ce as c,ie as d,O as e,de as f,le as g,We as h,ge as i,te as j,Qe as k,He as l,Ye as m,re as n,S as o,rn as p,on as q,_e as r,sn as s,an as t,dn as u,ln as v,cn as w,Te as x,Sn as y,wn as z,Rn as A,_n as B,Ae as C,kn as D,De as E,Fn as F,In as G,On as H,Tn as I,xn as J};
7
+ import{d as Z}from"./chunk-HFSBDM7B.mjs";import{c as H,g as Y}from"./chunk-OHEOJISY.mjs";import{a as F}from"./chunk-EADHKH3A.mjs";import{g as W,t as Q}from"./chunk-2GSMHGIV.mjs";import{a as U,f as D,h as k}from"./chunk-TZE3Y7IQ.mjs";import{a as P}from"./chunk-ICIYL45C.mjs";import{d as J}from"./chunk-7BQMBXKX.mjs";import{O as z,Q as B,T as V,Uc as R}from"./chunk-6QSHWIZI.mjs";import{b as I,k as G,l as A,v as K,z as _}from"./chunk-WZQEK4WT.mjs";function Le(e){let n=new Set;for(let t of e)t.controllerName&&n.add(t.controllerName);return n}function X(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0}function je(e,n){let t=X(e.precision),r=typeof e.scale=="number"&&e.scale>=0?e.scale:void 0,o=X(e.digits),s=(e.picklistValues??[]).filter(d=>d!==null&&typeof d.value=="string"),i={};if(e.controllerName)for(let d of s)d.active===!1||typeof d.validFor!="string"||(i[d.value]=d.validFor);return{...t!==void 0?{precision:t}:{},...t!==void 0&&r!==void 0?{scale:r}:{},...o!==void 0?{digits:o}:{},...e.unique===!0?{unique:!0}:{},...e.unique===!0&&typeof e.caseSensitive=="boolean"?{caseSensitive:e.caseSensitive}:{},...e.calculated===!0?{calculated:!0}:{},...e.filteredLookupInfo?{filteredLookup:!0}:{},...Object.keys(i).length>0?{validFor:i}:{},...n.has(e.name)&&s.length>0?{controllingValues:s.map(d=>d.value)}:{}}}function Ce(e,n){return e.caseSensitive===!1?n.toLowerCase():n}function M(e,n){if(n<0)return!1;let r=Buffer.from(e,"base64")[n>>3];return r!==void 0&&(r&128>>n%8)!==0}var ie={picklist_value_refused:["map_value","leave_empty","skip_rows","exclude_object","ignore"],dependent_value_invalid:["map_value","leave_empty","exclude_object","ignore"],picklist_value_absent:["map_value","skip_rows","ignore"],required_field_missing:["set_default","exclude_object","ignore"],value_too_long:["truncate","exclude_object","ignore"],number_out_of_range:["exclude_object","ignore"],record_type_unmapped:["map_record_type","exclude_object","ignore"],record_type_unavailable:["map_record_type","exclude_object","ignore"],currency_inactive:["map_value","skip_rows","exclude_object","ignore"],unique_value_collision:["exclude_object","ignore"]};function w(e){return[...ie[e]??["ignore"]]}var se=100,ae=new Set(["longest","colliding"]),O=class{gaps=new Map;recordTypes=new Map;get size(){return this.gaps.size}knowRecordTypes(n,t,r){let o=de(r);o!==void 0&&this.recordTypes.set(n,{...this.recordTypes.get(n),[t]:o})}add(n){let t=z(n.kind,n.objectApiName,n.field,n.recordType,n.value),r=this.gaps.get(t);if(!r){this.gaps.set(t,{...n,id:t,source:"simulation",decisions:[...n.decisions]});return}r.rows+=n.rows,n.decisions.includes("skip_rows")||(r.decisions=r.decisions.filter(s=>s!=="skip_rows"));let o={...n.detail??{},...r.detail??{}};for(let s of ae){let i=r.detail?.[s],d=n.detail?.[s];typeof i=="number"&&typeof d=="number"&&(o[s]=Math.max(i,d))}r.detail=o}list(n){let t=[...this.gaps.keys()],r=[...this.gaps.values()].map(o=>this.withSameDeveloperName(o)).map(o=>B(n,o,t)!==void 0?{...o,detail:{...o.detail??{},ignored:!0}}:o);return V(r)}withSameDeveloperName(n){let t=n.kind==="record_type_unmapped";return le(n,this.recordTypes.get(n.objectApiName)?.[t?"source":"target"])}};function de(e){let n=e.filter(t=>!t.master);if(!n.some(t=>t.namespacePrefix===void 0))return n.map(Z)}function le(e,n){let t=e.kind==="record_type_unmapped"?e.value:e.recordType;if(t===void 0||n===void 0)return e;let r=Y(t);if(!r.namespacePrefix)return e;let o=n.filter(s=>s.developerName===r.developerName&&s.namespacePrefix!==r.namespacePrefix).map(s=>H(s.namespacePrefix,s.developerName));return o.length===0?e:{...e,detail:{...e.detail??{},sameDeveloperName:[...new Set(o)].sort()}}}function L(e){return[...new Set(e)].sort().slice(0,se)}function We(e,n,t){let r=[];for(let o of n){if(o.field===P)continue;let s=t(o);for(let i of o.values)r.push({kind:"picklist_value_refused",severity:"warning",objectApiName:e,field:o.field,...o.recordType!==void 0?{recordType:o.recordType}:{},value:i,rows:1,detail:{reason:o.reason,...s?{allowed:L(s)}:{},...o.controllingField?{controllingField:o.controllingField}:{},...o.replacedBy!==void 0?{replacement:o.replacedBy}:{}},decisions:w("picklist_value_refused").filter(d=>d!=="skip_rows"||o.reason!=="controlling-value"),defaultDecision:o.replacedBy!==void 0?"map_value":"leave_empty"})}return r}var ce=new Set(["string","textarea","email","phone","url","encryptedstring"]),ue=new Set(["double","currency","percent"]);function fe(e){return e==null||e===""}function ne(e){return e.createable&&e.nillable===!1&&e.defaultedOnCreate!==!0&&e.calculated!==!0&&e.type!=="boolean"}function pe(e,n,t){return e==="Account"&&n==="Name"&&Q(t)}function ge(e,n,t,r){return r.filter(o=>ne(o)&&fe(n[o.name])&&!pe(e,o.name,t))}function me(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e!="string"||e.trim()==="")return;let n=Number(e);return Number.isFinite(n)?n:void 0}function ee(e){if(e.type==="int"&&e.digits!==void 0)return e.digits;if(e.precision!==void 0)return e.precision-(e.scale??0)}function ye(e,n){return e?e.type==="boolean"?n===!0||n==="true"?1:n===!1||n==="false"?0:-1:typeof n!="string"||n===""?-1:(e.controllingValues??[]).indexOf(n):-1}function te(e,n){let{objectApiName:t,rows:r,targetFields:o,picklistValuesByField:s,picklistFields:i}=e,d=new Map(o.map(u=>[u.name,u])),f=o.filter(ne),y=o.filter(u=>u.createable&&ce.has(u.type??"")&&(u.length??0)>0),g=o.filter(u=>u.createable&&(ue.has(u.type??"")||u.type==="int")&&ee(u)!==void 0),c=[...i].filter(([u,l])=>l.anyValue===!0&&s?.has(u)===!0),p=o.filter(u=>u.createable&&u.controllerName!==void 0&&u.validFor!==void 0);for(let{payload:u,source:l,typed:m}of r){for(let a of ge(t,u,l,f))n.add({kind:"required_field_missing",severity:"blocking",objectApiName:t,field:a.name,rows:1,...a.type?{detail:{type:a.type}}:{},decisions:w("required_field_missing")});for(let a of y){let h=u[a.name],b=a.length??0;typeof h!="string"||h.length<=b||n.add({kind:"value_too_long",severity:"blocking",objectApiName:t,field:a.name,rows:1,detail:{length:b,longest:h.length},decisions:w("value_too_long")})}for(let a of g){let h=me(u[a.name]),b=ee(a);h===void 0||b===void 0||Math.abs(Math.trunc(h))<10**b||n.add({kind:"number_out_of_range",severity:"blocking",objectApiName:t,field:a.name,rows:1,detail:{...a.precision!==void 0?{precision:a.precision}:{},...a.scale!==void 0?{scale:a.scale}:{},...a.type==="int"&&a.digits!==void 0?{digits:a.digits}:{}},decisions:w("number_out_of_range")})}for(let[a,h]of c){let b=u[a];if(typeof b!="string"||b==="")continue;let x=s?.get(a),v=h.multi?b.split(";"):[b];for(let E of new Set(v))x?.has(E)||n.add({kind:"picklist_value_absent",severity:"info",objectApiName:t,field:a,value:E,rows:1,decisions:w("picklist_value_absent")})}if(!m)for(let a of p){let h=u[a.name];if(typeof h!="string"||h==="")continue;let b=d.get(a.controllerName??""),x=ye(b,u[a.controllerName??""]),v=i.get(a.name)?.restricted===!0,E=i.get(a.name)?.multi?h.split(";"):[h];for(let q of new Set(E)){let $=a.validFor?.[q];$!==void 0&&(x>=0&&M($,x)||n.add({kind:"dependent_value_invalid",severity:v?"blocking":"warning",objectApiName:t,field:a.name,value:q,rows:1,detail:{controllingField:a.controllerName??"",allowed:L((b?.controllingValues??[]).filter((Me,oe)=>M($,oe)))},decisions:w("dependent_value_invalid")}))}}}}function Qe(e,n,t,r){return{kind:"currency_inactive",severity:"warning",objectApiName:e,field:P,value:n,rows:t,...r&&r.to.length>0?{detail:{replacement:r.to.join(", "),...r.converted.length>0?{amountsConverted:[...r.converted]}:{},...r.asRead?{amountsAsRead:!0}:{}}}:{},decisions:w("currency_inactive"),defaultDecision:"map_value"}}function He(e,n,t,r){return{kind:"unique_value_collision",severity:"warning",objectApiName:e,field:n,rows:t,detail:{colliding:r,linkedToTheRecordItNames:!0},decisions:w("unique_value_collision"),defaultDecision:"ignore"}}function Ye(e,n,t,r,o){return{kind:e,severity:"blocking",objectApiName:n,field:"RecordTypeId",...e==="record_type_unavailable"?{recordType:t}:{value:t},rows:r,detail:{mapTo:L(o)},decisions:w(e)}}var he=10;function re(e){switch(e.operation){case"insert":return null;case"upsert":return e.externalIdField??"Id";case"update":case"delete":return"Id"}}function S(e){if(e==null||typeof e!="string"&&typeof e!="number"&&typeof e!="boolean")return null;let n=String(e);return n===""?null:n.toLowerCase()}function T(e){return typeof e=="number"&&Number.isFinite(e)?String(e):typeof e=="boolean"?e?"true":"false":`'${U(String(e))}'`}var be=200,Se=4e3;function N(e){let n=[],t=[],r=0;for(let o of e){let s=T(o).length+2;t.length>0&&(t.length>=be||r+s>Se)&&(n.push(t),t=[],r=0),t.push(o),r+=s}return t.length>0&&n.push(t),n}function rn(e,n){return async(t,r,o,s)=>{let i=R(r.objectApiName),d=k(o),f=new Map;for(let y of N(s)){if(n?.aborted)throw new Error("The simulation was cancelled.");let{records:g}=await F(e,`SELECT ${d} FROM ${i} WHERE ${d} IN (${y.map(T).join(", ")})`);for(let c of g){let p=S(c[d]);p!==null&&f.set(p,(f.get(p)??0)+1)}}return f}}var we=new Set(["attributes","Id"]);function Re(e,n,t,r){return n?e.conflictFields.filter(o=>o!==t&&!we.has(o)&&o in n&&(r===null||r.has(o))):[]}var on=new Set(["noKey","notInTarget","ambiguous"]);function _e(e,n,t){let r=e.operation,o=re(e);if(o===null)return"insert";let s=S(n[o]);if(s===null)return r==="delete"?"notSent":"noKey";let i=t.get(s)??0;return r==="upsert"?i===0?o.toLowerCase()==="id"?"notInTarget":"insert":i===1?"update":"ambiguous":i===0?"notInTarget":r==="update"?"update":"delete"}var ke=1e4;function sn(e,n,t){let r=e>t?ke:Math.max(1,n);return{callOf:o=>Math.floor(o/r),job:e>t}}function an(e,n,t,r){let o=new Map;n.forEach((c,p)=>{if(c===null)return;let u=`${r.callOf(p)}\0${c}`,l=o.get(u);l?l.push(p):o.set(u,[p])});let s=new Set;for(let c of o.values())if(c.length>1)for(let p of c)s.add(p);let i=new Map,d=new Set,f=0;n.forEach((c,p)=>{if(c===null||s.has(p))return;let u=r.callOf(p);if(i.get(c)===void 0){t[p]==="insert"&&i.set(c,u);return}r.job?f++:t[p]==="insert"&&d.add(p)});let y=[],g=[];if(s.size>0){let c=`${s.size} record(s) carry the ${e} of another record of the same call: an upsert finds its record by its key, and the target refuses every record of a call whose key another carries (DUPLICATE_VALUE: Duplicate external id specified).`;y.push(c),g.push({code:"DUPLICATE_VALUE",rows:s.size,note:c})}return d.size>0&&y.push(`${d.size} record(s) carry the ${e} of a record sent in an earlier call: the upsert finds the record that one created and updates it with theirs.`),f>0&&y.push(`${f} record(s) carry the ${e} of a record in another batch of the Bulk API job: the platform may write the batches at once, so whether each updates the record the other created or creates one of its own cannot be told before the run.`),{refused:s,updated:d,notes:y,refusedFor:g}}function dn(e){let{objectConfig:n,records:t,inTarget:r}=e,o=n.operation,s=re(n),i={insert:0,update:0,delete:0,noKey:0,notInTarget:0,notSent:0,ambiguous:0},d=new Set;t.forEach((l,m)=>{let a=e.simulated?.[m]??_e(n,l,r);i[a]++,(a==="insert"||a==="update")&&d.add(m)});let f=e.leftOut.map(({why:l,count:m})=>W(m,l));i.noKey>0&&f.push(o==="upsert"?`${i.noKey} record(s) carry no value in ${s}: an upsert matches on it, and the target refuses a record without one.`:`${i.noKey} record(s) carry no Id: an update finds its record by Id, and the target refuses one without it.`),i.notInTarget>0&&f.push(`${i.notInTarget} record(s) carry an Id the target does not hold: ${o==="upsert"?"an upsert on the Id finds no record there and creates none":`${o==="update"?"an update":"a delete"} finds no record there`}, and the target refuses it. Two orgs share a record's Id only when it was copied with the org.`),i.ambiguous>0&&f.push(`${i.ambiguous} record(s) match more than one record of the target on ${s}: an upsert finds no single record to update, and the target refuses it.`),i.notSent>0&&f.push(`${i.notSent} record(s) carry no Id: a delete sends ids alone, so the run leaves them out.`);let y=new Map;e.unsettled.forEach((l,m)=>{let a=String(l[e.matchField]??"");a&&d.has(m)&&y.set(a,l)});let g=new Map,c=0;for(let l of e.conflicts){let m=Re(l,y.get(l.recordId),e.matchField,e.writable);if(m.length!==0){c++;for(let a of m)g.set(a,(g.get(a)??0)+1)}}let p=[...g].sort(([l,m],[a,h])=>h-m||l.localeCompare(a)).slice(0,he).map(([l])=>l),u=e.leftOut.reduce((l,{count:m})=>l+m,0);return{objectApiName:n.objectApiName,operation:o,read:e.read,insert:i.insert,update:i.update,delete:i.delete,skipped:u+i.notSent,refused:i.noKey+i.notInTarget+i.ambiguous,conflicts:c,conflictFields:p,notes:f}}var Fe={required_field_missing:"REQUIRED_FIELD_MISSING",value_too_long:"STRING_TOO_LONG",number_out_of_range:"NUMBER_OUTSIDE_VALID_RANGE"};function Ie(e){let n=e.field??"";switch(e.kind){case"required_field_missing":return`${e.rows} record(s) leave ${n} empty, which the target requires: it refuses them (REQUIRED_FIELD_MISSING).`;case"value_too_long":return`${e.rows} record(s) hold a ${n} longer than the ${String(e.detail?.length)} characters the target's field takes (the longest, ${String(e.detail?.longest)}): it refuses them (STRING_TOO_LONG).`;case"number_out_of_range":return`${e.rows} record(s) hold a ${n} larger than the target's field takes: it refuses them (NUMBER_OUTSIDE_VALID_RANGE).`;default:return}}function ln(e,n,t){let r=new Set,o=new O;n.forEach(({payload:i,source:d,creates:f},y)=>{let g=new O;te({objectApiName:e,rows:[{payload:i,source:d,typed:!0}],targetFields:t,picklistValuesByField:null,picklistFields:new Map},g);let c=g.list(new Set).filter(p=>p.severity==="blocking"&&(f||p.kind!=="required_field_missing"));if(c.length!==0){r.add(y);for(let p of c)o.add(p)}});let s=o.list(new Set).flatMap(i=>{let d=Ie(i),f=Fe[i.kind];return d&&f?[{code:f,rows:i.rows,note:d}]:[]});return{refused:r,notes:s.map(({note:i})=>i),refusedFor:s}}function cn(e,n){let t=new Set,r=new Set,o=[],s=[];for(let[i,d]of n){let f=new Set,y=0,g=0,c=0;if(e.forEach((u,l)=>{let m=S(u[i]);if(m===null)return;let a=d.get(m)??0;a===1?(y++,r.add(l)):a>1?(g++,t.add(l)):f.has(m)&&(c++,t.add(l)),f.add(m)}),y>0&&o.push(`LINKED_TO_EXISTING: ${y} record(s) hold a ${i} the target keeps unique, which a record of the target holds already: it refuses them as duplicates (DUPLICATE_VALUE) and names that record, which the run links them to \u2014 what it writes under them points at that record.`),g+c===0)continue;let p=`${g+c} record(s) hold a ${i} the target keeps unique, which `+[g>0?`several records of the target hold already (${g})`:"",c>0?`a record sent before them holds (${c})`:""].filter(Boolean).join(" or ")+": it refuses them (DUPLICATE_VALUE).";o.push(p),s.push({code:"DUPLICATE_VALUE",rows:g+c,note:p})}for(let i of t)r.delete(i);return{refused:t,linked:r,notes:o,refusedFor:s}}import{createHash as Oe}from"node:crypto";var Te=5*6e4,xe=500,Ee=A({sourceOrgId:I().min(1).max(200),targetOrgId:I().min(1).max(200),objectApiName:I().regex(/^[A-Za-z][A-Za-z0-9_]{0,79}$/),watermark:_.datetime(),fingerprint:I().regex(/^[0-9a-f]{64}$/),recordedAt:_.datetime(),filesSeen:_.datetime().optional(),removedAt:_.datetime().optional()}),Ne=A({version:K(1),entries:G(Ee).max(xe),resetAt:_.datetime().optional()});function Sn(e){if(e==null)return{kind:"none"};let n=Ne.safeParse(e);if(n.success)return{kind:"stored",state:n.data};let t=n.error.issues[0];return{kind:"unreadable",issue:`${t.path.join(".")||"state"}: ${t.message}`}}function j(e){return Array.isArray(e)?`[${e.map(j).join(",")}]`:e!==null&&typeof e=="object"?`{${Object.entries(e).filter(([,t])=>t!==void 0).sort(([t],[r])=>t<r?-1:t>r?1:0).map(([t,r])=>`${JSON.stringify(t)}:${j(r)}`).join(",")}}`:JSON.stringify(e)}function C(e){let n=e?.trim();return n||null}function ve(e,n){let t={direction:e.direction,conflictStrategy:e.conflictStrategy,copiesFiles:e.files?!0:void 0,objectApiName:n.objectApiName,operation:n.operation,externalIdField:C(n.externalIdField),where:C(n.where),fieldMappings:n.fieldMappings??[],unmappedSentAsRead:(n.fieldMappings??[]).length>0?!0:void 0,transformRules:n.transformRules??[],excludedFields:n.excludedFields??[],addOnFields:n.addOnFields??[]};return Oe("sha256").update(j(t)).digest("hex")}function wn(e,n,t){let r=ve(e,n);if(t===null)return{read:"full",reason:"not_saved",fingerprint:r};if(t.kind==="unreadable")return{read:"full",reason:"unreadable",fingerprint:r};if(t.kind==="none")return{read:"full",reason:"first_run",fingerprint:r};let o=t.state.entries.find(s=>s.sourceOrgId===e.sourceOrgId&&s.targetOrgId===e.targetOrgId&&s.objectApiName===n.objectApiName);return o?o.fingerprint!==r?{read:"full",reason:"scope_changed",fingerprint:r}:o.removedAt!==void 0?{read:"full",reason:"removed",fingerprint:r}:{read:"delta",since:o.watermark,fingerprint:r,...o.filesSeen!==void 0?{filesSeen:o.filesSeen}:{}}:{read:"full",reason:t.state.resetAt?"reset":"first_run",fingerprint:r}}var $e=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/;function Rn(e,n=Te){let t=Date.parse(e);if(!Number.isFinite(t))throw new Error(`Not a watermark: "${e}".`);let r=Math.floor((t-n)/1e3)*1e3;return new Date(r).toISOString().replace(/\.\d{3}Z$/,"Z")}function _n(e){let n=Date.parse(e);if(!Number.isFinite(n))throw new Error(`Not a date: "${e}".`);return new Date(Math.floor(n/1e3)*1e3).toISOString().replace(/\.\d{3}Z$/,"Z")}function Ae(e){if(!$e.test(e)||!Number.isFinite(Date.parse(e)))throw new Error(`Not a SOQL datetime: "${e}".`);return e}function kn(e,n){let t=e?.trim()?D(e):void 0;if(n===void 0)return t;let r=`SystemModstamp > ${Ae(n)}`;return t?`${r} AND (${t})`:r}function De(e){if(typeof e!="string"||e==="")return null;let n=Date.parse(e.replace(/([+-]\d{2})(\d{2})$/,"$1:$2"));return Number.isFinite(n)?new Date(n).toISOString():null}function Fn(e,n,t){let r={query:i=>e.query(i),queryMore:i=>e.queryMore(i)},o={query:i=>e.query(i,{scanAll:!0}),queryMore:i=>e.queryMore(i)},s=()=>{if(t?.aborted)throw new Error("The run was cancelled.")};return{async latestModstamp(i){let d=R(i),y=(await e.query(`SELECT SystemModstamp FROM ${d} ORDER BY SystemModstamp DESC LIMIT 1`)).records[0];if(!y)return null;let g=De(y.SystemModstamp);if(g===null)throw new Error(`${d} answered a SystemModstamp that is not a date.`);return g},async deletedRows(i,d,f){let y=R(i),g=new Set(["Id","SystemModstamp",...d.map(k)]),{records:c,truncated:p}=await F(o,`SELECT ${[...g].join(", ")} FROM ${y} WHERE IsDeleted = true AND (${D(f)})`);return{records:c,truncated:p}},async heldInSource(i,d,f){let y=R(i),g=k(d),c=new Set;for(let p of N(f)){s();let{records:u}=await F(r,`SELECT ${g} FROM ${y} WHERE ${g} IN (${p.map(T).join(", ")})`);for(let l of u){let m=S(l[g]);m!==null&&c.add(m)}}return c},async targetIdsByKey(i,d,f){let y=R(i),g=k(d),c=g==="Id"?"Id":`Id, ${g}`,p=new Map;for(let u of N(f)){s();let{records:l}=await F(n,`SELECT ${c} FROM ${y} WHERE ${g} IN (${u.map(T).join(", ")})`);for(let m of l){let a=S(m[g]);a===null||typeof m.Id!="string"||p.set(a,[...p.get(a)??[],m.Id])}}return p}}}var Pe=new Set(["direct","rename","transform"]);function In(e){let n=e.objectApiName;if(e.operation==="insert"||e.operation==="delete")return{refused:`${n} is written by ${e.operation}, which finds no record by a key: a deleted source record cannot be tied to a target record.`};if(e.operation==="update")return{sourceField:"Id",keyField:"Id"};let t=C(e.externalIdField)??"Id";if((e.addOnFields??[]).some(s=>s.fieldApiName===t))return{refused:`${n}: an add-on writes ${t}, the key the upsert matches on, so it ties no deleted source record to one target record.`};let r=e.fieldMappings??[],o=r.find(s=>s.targetField.toLowerCase()===t.toLowerCase());return!o&&!J(r,e.excludedFields??[]).has(t.toLowerCase())?{sourceField:t,keyField:t}:!o||!Pe.has(o.type)?{refused:`${n}: no source field is carried onto ${t}, the key the upsert matches on, so no deleted source record can be tied to a target record.`}:{sourceField:o.sourceField,keyField:t}}async function On(e,n,t,r,o){let s=n.objectApiName,{records:i,truncated:d}=await e.deletedRows(s,[t.sourceField],r),f={ids:[],read:i.length,stillInSource:0,ambiguous:0,noKey:0,truncated:d};if(i.length===0)return f;let y=[];for(let l of i){let m=l[t.sourceField],a=o(l);if(S(m)===null||S(a)===null){f.noKey++;continue}y.push({raw:m,key:a})}if(y.length===0)return f;let g=t.sourceField==="Id"?new Set:await e.heldInSource(s,t.sourceField,y.map(l=>l.raw)),c=y.filter(l=>g.has(S(l.raw))?(f.stillInSource++,!1):!0);if(c.length===0)return f;let p=await e.targetIdsByKey(s,t.keyField,c.map(l=>l.key)),u=new Set;for(let l of c){let m=p.get(S(l.key))??[];m.length>1?f.ambiguous++:m.length===1&&!u.has(m[0])&&(u.add(m[0]),f.ids.push(m[0]))}return f}function Tn(e,n){let t=[];return e.stillInSource>0&&t.push(`${e.stillInSource} record(s) deleted in the source share their ${n} with a record the source still holds: their target record was kept.`),e.ambiguous>0&&t.push(`${e.ambiguous} record(s) deleted in the source match more than one target record on ${n}: none of those target records was deleted.`),e.noKey>0&&t.push(`${e.noKey} record(s) deleted in the source carry no ${n}: no target record is tied to them.`),e.truncated&&t.push("The source's deleted records were read up to a bound: the rest are read by the next run, from the same watermark."),t}function xn(e,n,t,r,o=0){return{read:e.read,...e.read==="delta"?{since:e.since}:{reason:e.reason},changed:n,deletionsChecked:t!==void 0,deleted:t?.deleted??0,deleteFailed:t?.deleteFailed??0,...t?.error!==void 0?{deletionError:t.error}:{},...r!==void 0?{recorded:r}:{},...o>0?{lookupsOwed:o}:{}}}export{Le as a,je as b,Ce as c,ie as d,O as e,de as f,le as g,We as h,ge as i,te as j,Qe as k,He as l,Ye as m,re as n,S as o,rn as p,on as q,_e as r,sn as s,an as t,dn as u,ln as v,cn as w,Te as x,Sn as y,wn as z,Rn as A,_n as B,Ae as C,kn as D,De as E,Fn as F,In as G,On as H,Tn as I,xn as J};