sandforge 1.82.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 (200) hide show
  1. package/lib/{chunk-JLZRZL5E.mjs → chunk-262TP6UU.mjs} +1 -1
  2. package/lib/{chunk-Z42PHCVZ.mjs → chunk-27BBEGUD.mjs} +1 -1
  3. package/lib/{chunk-YGJF55VJ.mjs → chunk-2ADSD5WK.mjs} +1 -1
  4. package/lib/{chunk-KIMQQ6JQ.mjs → chunk-2GSMHGIV.mjs} +1 -1
  5. package/lib/chunk-2K5BYZQM.mjs +8 -0
  6. package/lib/{chunk-DJCGURW7.mjs → chunk-2KTGDYUH.mjs} +1 -1
  7. package/lib/{chunk-YAJQS3OL.mjs → chunk-2N73W63D.mjs} +1 -1
  8. package/lib/{chunk-LXDSRP2W.mjs → chunk-2R6GFNKF.mjs} +1 -1
  9. package/lib/{chunk-VZVICK7Q.mjs → chunk-2WMKJVD2.mjs} +1 -1
  10. package/lib/{chunk-CV47FDQW.mjs → chunk-36Y225OM.mjs} +1 -1
  11. package/lib/{chunk-3C2ZZIFN.mjs → chunk-3CM7LAPE.mjs} +1 -1
  12. package/lib/{chunk-HIHCYMSL.mjs → chunk-3OVTKRS4.mjs} +1 -1
  13. package/lib/{chunk-XFU3HRUV.mjs → chunk-3V4YH5KO.mjs} +1 -1
  14. package/lib/{chunk-XO5FBOQF.mjs → chunk-446GBKAC.mjs} +1 -1
  15. package/lib/{chunk-ZUOPC4W2.mjs → chunk-4GCYGQXD.mjs} +1 -1
  16. package/lib/{chunk-GCGHHN4K.mjs → chunk-4V3QO7HF.mjs} +1 -1
  17. package/lib/{chunk-VZT4E2OJ.mjs → chunk-4X5D3MSV.mjs} +1 -1
  18. package/lib/{chunk-P55MKIZX.mjs → chunk-5OGNK3JP.mjs} +1 -1
  19. package/lib/{chunk-3MGMNK3Q.mjs → chunk-6KOUYHEY.mjs} +1 -1
  20. package/lib/chunk-6QSHWIZI.mjs +48 -0
  21. package/lib/chunk-6VOQFISN.mjs +7 -0
  22. package/lib/{chunk-VYOYXTCU.mjs → chunk-6YC2ELCU.mjs} +1 -1
  23. package/lib/chunk-77IVKH7R.mjs +7 -0
  24. package/lib/{chunk-JKT5YAQ2.mjs → chunk-77MZRBWX.mjs} +1 -1
  25. package/lib/{chunk-PR74GYVI.mjs → chunk-7BQMBXKX.mjs} +1 -1
  26. package/lib/{chunk-SZGGFST2.mjs → chunk-7DPHZWA4.mjs} +1 -1
  27. package/lib/chunk-7V2UYZ6S.mjs +7 -0
  28. package/lib/{chunk-HKUWHVI7.mjs → chunk-7WSQ65WG.mjs} +1 -1
  29. package/lib/{chunk-LHU6CPGE.mjs → chunk-7ZBDACVG.mjs} +1 -1
  30. package/lib/{chunk-WT3SCUHS.mjs → chunk-AG24QMSY.mjs} +1 -1
  31. package/lib/{chunk-A65ADTCR.mjs → chunk-AHUGG3WU.mjs} +1 -1
  32. package/lib/{chunk-ZXFL2MSN.mjs → chunk-ALBY5SOH.mjs} +1 -1
  33. package/lib/chunk-AXFD2OH6.mjs +7 -0
  34. package/lib/{chunk-JESRFE2Z.mjs → chunk-BH76USTQ.mjs} +1 -1
  35. package/lib/{chunk-DBBPDSFN.mjs → chunk-BPHTA6KP.mjs} +1 -1
  36. package/lib/{chunk-3SKLBRPL.mjs → chunk-BT43WSOS.mjs} +1 -1
  37. package/lib/{chunk-32EUNQT6.mjs → chunk-BVZ5H3N4.mjs} +1 -1
  38. package/lib/{chunk-PWVDNN2C.mjs → chunk-C6RKM4BB.mjs} +1 -1
  39. package/lib/{chunk-27Z76O2O.mjs → chunk-CDWZGQAJ.mjs} +1 -1
  40. package/lib/chunk-CGZGL6VT.mjs +7 -0
  41. package/lib/{chunk-P63WJMXQ.mjs → chunk-CN5HGFG4.mjs} +1 -1
  42. package/lib/{chunk-Y4TDVDP2.mjs → chunk-CQAFVEKP.mjs} +1 -1
  43. package/lib/{chunk-G2JR3F63.mjs → chunk-CTPLYUXA.mjs} +1 -1
  44. package/lib/chunk-CXKZ6TYV.mjs +9 -0
  45. package/lib/{chunk-FKK5YBGZ.mjs → chunk-D6JT4PAB.mjs} +1 -1
  46. package/lib/{chunk-3CX7GPCR.mjs → chunk-D7XUNWWU.mjs} +1 -1
  47. package/lib/{chunk-PPHVWUFY.mjs → chunk-DB5RVDC5.mjs} +1 -1
  48. package/lib/{chunk-LAUOSXMN.mjs → chunk-DIGUC7S4.mjs} +1 -1
  49. package/lib/{chunk-6GQUZ4IP.mjs → chunk-DKDKCGXV.mjs} +1 -1
  50. package/lib/chunk-DMT5SCO3.mjs +7 -0
  51. package/lib/{chunk-KKOA62S4.mjs → chunk-DNQKVCUV.mjs} +4 -3
  52. package/lib/{chunk-3XG25GTF.mjs → chunk-DSR2MSBH.mjs} +1 -1
  53. package/lib/{chunk-ZHIZY3ZC.mjs → chunk-E3RQ575Y.mjs} +1 -1
  54. package/lib/{chunk-SAMWHL22.mjs → chunk-EOQON3E5.mjs} +1 -1
  55. package/lib/{chunk-2JZGCCPG.mjs → chunk-ETNQHIDI.mjs} +1 -1
  56. package/lib/chunk-F5SBGJWW.mjs +7 -0
  57. package/lib/chunk-FBXH4VRQ.mjs +7 -0
  58. package/lib/chunk-FKCIGJOI.mjs +15 -0
  59. package/lib/{chunk-NWOI25WY.mjs → chunk-FVLFO2S6.mjs} +1 -1
  60. package/lib/{chunk-MKTXJCXN.mjs → chunk-FYWNSMOZ.mjs} +1 -1
  61. package/lib/{chunk-52EXDVPN.mjs → chunk-GEEWPTV5.mjs} +1 -1
  62. package/lib/{chunk-XSKPYGMT.mjs → chunk-GLN4PI5P.mjs} +1 -1
  63. package/lib/{chunk-DWMRIWV5.mjs → chunk-GT5ZKU6V.mjs} +1 -1
  64. package/lib/chunk-GTRU5AV5.mjs +7 -0
  65. package/lib/chunk-H33DVU3D.mjs +7 -0
  66. package/lib/{chunk-YAIIRFKJ.mjs → chunk-HQZUQXDC.mjs} +1 -1
  67. package/lib/{chunk-MUEQRIK7.mjs → chunk-HVX2AFYW.mjs} +1 -1
  68. package/lib/chunk-I3ZO76LL.mjs +21 -0
  69. package/lib/{chunk-7WSLT5VX.mjs → chunk-I5C4O3VA.mjs} +1 -1
  70. package/lib/{chunk-6VSZNZHH.mjs → chunk-IHGYJZZ2.mjs} +1 -1
  71. package/lib/{chunk-DIS254AN.mjs → chunk-ISA2NYJV.mjs} +1 -1
  72. package/lib/{chunk-GGUOIDWP.mjs → chunk-ISAUCWYK.mjs} +1 -1
  73. package/lib/{chunk-ZUTUYBNW.mjs → chunk-ISOSTAJR.mjs} +1 -1
  74. package/lib/chunk-IXIY6Q4M.mjs +7 -0
  75. package/lib/{chunk-2UU42PTD.mjs → chunk-J3TIHLWG.mjs} +1 -1
  76. package/lib/{chunk-GGNUACTY.mjs → chunk-JAV6F6OA.mjs} +1 -1
  77. package/lib/chunk-JBWJ6UEZ.mjs +7 -0
  78. package/lib/{chunk-C2N2TNEU.mjs → chunk-JH4ZTVQN.mjs} +1 -1
  79. package/lib/{chunk-FOIWWK7G.mjs → chunk-JIPT5FUD.mjs} +1 -1
  80. package/lib/{chunk-7EYQYZJP.mjs → chunk-JREKJO3D.mjs} +1 -1
  81. package/lib/{chunk-VQJMP3DC.mjs → chunk-JUOQUG7U.mjs} +1 -1
  82. package/lib/chunk-JYUMD357.mjs +7 -0
  83. package/lib/{chunk-KP5G6FUC.mjs → chunk-K7G3W7XH.mjs} +1 -1
  84. package/lib/{chunk-T7WREYA5.mjs → chunk-KKS2KFBT.mjs} +1 -1
  85. package/lib/{chunk-TMA34QMA.mjs → chunk-KWAVSZ2B.mjs} +1 -1
  86. package/lib/{chunk-H4JUYUSL.mjs → chunk-KXUOHACP.mjs} +1 -1
  87. package/lib/{chunk-STRMWSIQ.mjs → chunk-L3I6DAHX.mjs} +1 -1
  88. package/lib/{chunk-TCBAE65A.mjs → chunk-L47JCNP3.mjs} +1 -1
  89. package/lib/{chunk-5K2I2DMP.mjs → chunk-L4MSL4U7.mjs} +1 -1
  90. package/lib/chunk-L4RJX7DG.mjs +7 -0
  91. package/lib/{chunk-47UHTN3Q.mjs → chunk-L6CLN664.mjs} +1 -1
  92. package/lib/chunk-LI2XNV7F.mjs +7 -0
  93. package/lib/chunk-LP2D3JJP.mjs +7 -0
  94. package/lib/{chunk-KJYEQHYP.mjs → chunk-LWES2KZE.mjs} +1 -1
  95. package/lib/{chunk-3HEMJTAP.mjs → chunk-LYOGCIYD.mjs} +2 -2
  96. package/lib/{chunk-VPDEJGPS.mjs → chunk-MJD6CPZZ.mjs} +1 -1
  97. package/lib/{chunk-SNEOKYV7.mjs → chunk-MTM4KG3T.mjs} +1 -1
  98. package/lib/{chunk-J24TIGSI.mjs → chunk-N2HYG3BL.mjs} +1 -1
  99. package/lib/chunk-N5UIE4IR.mjs +7 -0
  100. package/lib/{chunk-YMDFF657.mjs → chunk-NDFFIJL5.mjs} +1 -1
  101. package/lib/{chunk-WOOUISSO.mjs → chunk-NFEBX75O.mjs} +1 -1
  102. package/lib/{chunk-ZUBBEP75.mjs → chunk-NNV7IGM7.mjs} +1 -1
  103. package/lib/{chunk-Q3DY7TO2.mjs → chunk-NS6ONPWL.mjs} +1 -1
  104. package/lib/{chunk-IVZJSDJD.mjs → chunk-O7GCCRPW.mjs} +1 -1
  105. package/lib/{chunk-A7JJWOLT.mjs → chunk-OO24ZYYJ.mjs} +1 -1
  106. package/lib/chunk-OOIDCHBQ.mjs +9 -0
  107. package/lib/{chunk-AUS6NFLZ.mjs → chunk-OS5GE52G.mjs} +1 -1
  108. package/lib/chunk-OS6HFJ7L.mjs +7 -0
  109. package/lib/{chunk-V3R45ZWT.mjs → chunk-OTJH6AEA.mjs} +1 -1
  110. package/lib/{chunk-PBE44M2Y.mjs → chunk-OUU47Y7A.mjs} +1 -1
  111. package/lib/{chunk-BN33LVPQ.mjs → chunk-P6WRYJN3.mjs} +1 -1
  112. package/lib/{chunk-JJITOWZK.mjs → chunk-PDRXM5WN.mjs} +1 -1
  113. package/lib/{chunk-RYRMUPMY.mjs → chunk-PGRY365W.mjs} +1 -1
  114. package/lib/chunk-Q4PPI3KG.mjs +7 -0
  115. package/lib/chunk-QFTF2PGS.mjs +21 -0
  116. package/lib/chunk-QKJXIY6L.mjs +7 -0
  117. package/lib/{chunk-PYRZFUVU.mjs → chunk-QLRWU3MB.mjs} +1 -1
  118. package/lib/chunk-QO4MPHZD.mjs +7 -0
  119. package/lib/chunk-QP3JLFIO.mjs +7 -0
  120. package/lib/{chunk-NLB3RGIY.mjs → chunk-QQDZQCO2.mjs} +1 -1
  121. package/lib/{chunk-7CVDVBEE.mjs → chunk-QXB6U3ZP.mjs} +1 -1
  122. package/lib/chunk-R3OM3X4L.mjs +8 -0
  123. package/lib/chunk-R7GKMAT4.mjs +7 -0
  124. package/lib/{chunk-YT22LMF7.mjs → chunk-RVCPQVKM.mjs} +1 -1
  125. package/lib/{chunk-TWV4A5RK.mjs → chunk-RZKJQOOC.mjs} +1 -1
  126. package/lib/chunk-S4PRKKGC.mjs +8 -0
  127. package/lib/{chunk-JH27IKCO.mjs → chunk-SX6QWYCQ.mjs} +1 -1
  128. package/lib/{chunk-UHFLKP26.mjs → chunk-T36DZJPH.mjs} +1 -1
  129. package/lib/{chunk-CZLJZQCS.mjs → chunk-T7DDS4UQ.mjs} +1 -1
  130. package/lib/chunk-TCEXCHXR.mjs +7 -0
  131. package/lib/chunk-TMIESDE5.mjs +7 -0
  132. package/lib/chunk-TQJ5NPRC.mjs +7 -0
  133. package/lib/chunk-TUPZY2QJ.mjs +7 -0
  134. package/lib/{chunk-GBGHJTPC.mjs → chunk-U2CTKIPE.mjs} +1 -1
  135. package/lib/{chunk-3HROD5RE.mjs → chunk-U4YFYSF3.mjs} +1 -1
  136. package/lib/{chunk-Q6SXNKV2.mjs → chunk-UIR77ZJD.mjs} +1 -1
  137. package/lib/{chunk-FA4ZKDCU.mjs → chunk-UOHZW2L4.mjs} +1 -1
  138. package/lib/{chunk-7PY3VQP3.mjs → chunk-VXZ5PTOM.mjs} +1 -1
  139. package/lib/{chunk-7LKI7OAS.mjs → chunk-VZLJZEV2.mjs} +1 -1
  140. package/lib/{chunk-YH4DYI6D.mjs → chunk-W3BQGMTR.mjs} +1 -1
  141. package/lib/{chunk-CELEBWEZ.mjs → chunk-WABXKL4N.mjs} +1 -1
  142. package/lib/{chunk-EEFUE2ES.mjs → chunk-WAYQLQAD.mjs} +1 -1
  143. package/lib/{chunk-RCYEBY42.mjs → chunk-WBELLGNE.mjs} +1 -1
  144. package/lib/{chunk-SFGZFB4F.mjs → chunk-WJAZ5LHL.mjs} +1 -1
  145. package/lib/{chunk-JQZTMFO7.mjs → chunk-WXU6ZJIV.mjs} +1 -1
  146. package/lib/{chunk-GJ6SZVHT.mjs → chunk-WZN36ACK.mjs} +1 -1
  147. package/lib/{chunk-XU25YA46.mjs → chunk-X2XZQ434.mjs} +1 -1
  148. package/lib/{chunk-QAPVKPEC.mjs → chunk-X4HZD5U2.mjs} +1 -1
  149. package/lib/chunk-X6XNTOGO.mjs +7 -0
  150. package/lib/{chunk-XK5W7BVE.mjs → chunk-XAMMIPZ4.mjs} +1 -1
  151. package/lib/{chunk-DT3T7FRD.mjs → chunk-XAUQXYPW.mjs} +1 -1
  152. package/lib/{chunk-C3LNYAVJ.mjs → chunk-XCJUNX63.mjs} +1 -1
  153. package/lib/chunk-XJICAOAQ.mjs +7 -0
  154. package/lib/{chunk-CBL42DUU.mjs → chunk-XKFHTBAB.mjs} +1 -1
  155. package/lib/{chunk-O2PUGRNW.mjs → chunk-XMQ5R6TC.mjs} +1 -1
  156. package/lib/chunk-XPXEQKLR.mjs +7 -0
  157. package/lib/{chunk-6KP6WETK.mjs → chunk-Y7YUNRKK.mjs} +1 -1
  158. package/lib/{chunk-WSUKC2U3.mjs → chunk-YBZIDW6W.mjs} +1 -1
  159. package/lib/{chunk-RTWYLOCA.mjs → chunk-YEVB7LVK.mjs} +1 -1
  160. package/lib/{chunk-L4INJ5TZ.mjs → chunk-Z3MGN42K.mjs} +1 -1
  161. package/lib/{chunk-EOFO3PHS.mjs → chunk-ZB5E7NHU.mjs} +1 -1
  162. package/lib/chunk-ZCOSME6P.mjs +7 -0
  163. package/lib/{chunk-HFUDCNU5.mjs → chunk-ZOSESZ22.mjs} +1 -1
  164. package/lib/chunk-ZTHC42X6.mjs +7 -0
  165. package/lib/{chunk-XZISAZA6.mjs → chunk-ZXOUWHYE.mjs} +1 -1
  166. package/lib/sandforge-autopilot.mjs +1 -1
  167. package/lib/sandforge-backup.mjs +1 -1
  168. package/lib/sandforge-checkpoint.mjs +1 -1
  169. package/lib/sandforge-cleanup.mjs +1 -1
  170. package/lib/sandforge-clone.mjs +1 -1
  171. package/lib/sandforge-compare.mjs +1 -1
  172. package/lib/sandforge-dataops.mjs +1 -1
  173. package/lib/sandforge-empty.mjs +4 -4
  174. package/lib/sandforge-env.mjs +98 -99
  175. package/lib/sandforge-frozen.mjs +1 -1
  176. package/lib/sandforge-mcp.mjs +2 -2
  177. package/lib/sandforge-monitor.mjs +1 -1
  178. package/lib/sandforge-pipeline.mjs +1 -1
  179. package/lib/sandforge-seed.mjs +1 -1
  180. package/lib/sandforge-sync.mjs +1 -1
  181. package/lib/sandforge-users.mjs +21 -23
  182. package/oclif.manifest.json +1 -1
  183. package/package.json +1 -1
  184. package/lib/chunk-42BFLWHR.mjs +0 -7
  185. package/lib/chunk-466F37VD.mjs +0 -7
  186. package/lib/chunk-7SDZR6SR.mjs +0 -7
  187. package/lib/chunk-BMTNTBBM.mjs +0 -7
  188. package/lib/chunk-CCEH7L53.mjs +0 -7
  189. package/lib/chunk-DIL62SUN.mjs +0 -7
  190. package/lib/chunk-FZF23M6R.mjs +0 -7
  191. package/lib/chunk-GHPR5UVV.mjs +0 -7
  192. package/lib/chunk-HQQVANWQ.mjs +0 -20
  193. package/lib/chunk-IRZJU2PG.mjs +0 -22
  194. package/lib/chunk-ISSP2FZ5.mjs +0 -7
  195. package/lib/chunk-JFNLKHY6.mjs +0 -8
  196. package/lib/chunk-O4BROUGM.mjs +0 -7
  197. package/lib/chunk-PE435FVH.mjs +0 -15
  198. package/lib/chunk-RLWB7F26.mjs +0 -7
  199. package/lib/chunk-WEMLDUQA.mjs +0 -7
  200. package/lib/chunk-ZQO5PDX5.mjs +0 -48
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a,b,c,d}from"./chunk-C3LNYAVJ.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{b as PARENT_IDS_PER_QUERY,a as readExistingParentIds,c as readPresentParentIds,d as recordParentsRefusals};
7
+ import{a,b,c,d}from"./chunk-XCJUNX63.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{b as PARENT_IDS_PER_QUERY,a as readExistingParentIds,c as readPresentParentIds,d as recordParentsRefusals};
@@ -4,5 +4,5 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a as w,b as x}from"./chunk-V3R45ZWT.mjs";import{b as R}from"./chunk-JKT5YAQ2.mjs";import{g as k}from"./chunk-3SKLBRPL.mjs";import{Fb as h,Ia as g,La as l}from"./chunk-ZQO5PDX5.mjs";import{b as d,m as S,s as u,v as f}from"./chunk-WZQEK4WT.mjs";import{createHash as $}from"node:crypto";import{mkdir as y,readFile as C,rename as P,writeFile as O}from"node:fs/promises";import*as a from"node:path";var A=k,N=d().regex(/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,"A record id"),p=S({version:f(1),runId:d().min(1).max(200),packId:g,packFingerprint:d().regex(/^[0-9a-f]{64}$/,"A sha256, in lower-case hexadecimal"),compile:l.refine(e=>e.seed!==void 0,{message:"The seed the pack was compiled with is kept",path:["seed"]}),openCases:u(d().min(1).max(255),N),agent:h.optional()});function F(e){return $("sha256").update(m(e)).digest("hex")}function v(e){let r={};for(let i of e.compiled.tests){let n=i.openCase?.caseKey;if(n===void 0)continue;let t=e.caseIds[n];t!==void 0&&(r[n]=t)}return p.parse({version:1,runId:e.runId,packId:e.pack.id,packFingerprint:F(e.pack),compile:{...e.options,seed:e.compiled.seed},openCases:r})}function D(e,r){return p.parse({...e,agent:r})}function U(e,r){if(r.id!==e.packId)return{ok:!1,message:`The run was seeded from the scenario ${e.packId}, not ${r.id}`};if(F(r)!==e.packFingerprint)return{ok:!1,message:`The scenario ${r.id} has changed since the run: its tests would be about subjects and addresses no record of the run holds`};try{return{ok:!0,compiled:x(r,e.compile)}}catch(i){if(i instanceof w)return{ok:!1,message:i.message};throw i}}function Z(){return{readFile:e=>C(e,"utf8"),writeFile:(e,r)=>O(e,r,"utf8"),rename:(e,r)=>P(e,r),mkdir:async e=>{await y(e,{recursive:!0})}}}function I(e,r){return a.join(e,R,`${r.replace(/[^A-Za-z0-9_-]/g,"_")}${A}`)}async function K(e,r,i){let n=p.parse(i),t=I(r,n.runId),o=`${t}.${process.pid}.tmp`;return await e.mkdir(a.dirname(t)),await e.writeFile(o,`${JSON.stringify(n,null,2)}
7
+ import{a as w,b as x}from"./chunk-OTJH6AEA.mjs";import{b as R}from"./chunk-77MZRBWX.mjs";import{g as k}from"./chunk-BT43WSOS.mjs";import{Ia as g,La as l,Sb as h}from"./chunk-6QSHWIZI.mjs";import{b as d,m as S,s as u,v as f}from"./chunk-WZQEK4WT.mjs";import{createHash as $}from"node:crypto";import{mkdir as y,readFile as C,rename as P,writeFile as O}from"node:fs/promises";import*as a from"node:path";var A=k,N=d().regex(/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,"A record id"),p=S({version:f(1),runId:d().min(1).max(200),packId:g,packFingerprint:d().regex(/^[0-9a-f]{64}$/,"A sha256, in lower-case hexadecimal"),compile:l.refine(e=>e.seed!==void 0,{message:"The seed the pack was compiled with is kept",path:["seed"]}),openCases:u(d().min(1).max(255),N),agent:h.optional()});function F(e){return $("sha256").update(m(e)).digest("hex")}function v(e){let r={};for(let i of e.compiled.tests){let n=i.openCase?.caseKey;if(n===void 0)continue;let t=e.caseIds[n];t!==void 0&&(r[n]=t)}return p.parse({version:1,runId:e.runId,packId:e.pack.id,packFingerprint:F(e.pack),compile:{...e.options,seed:e.compiled.seed},openCases:r})}function D(e,r){return p.parse({...e,agent:r})}function U(e,r){if(r.id!==e.packId)return{ok:!1,message:`The run was seeded from the scenario ${e.packId}, not ${r.id}`};if(F(r)!==e.packFingerprint)return{ok:!1,message:`The scenario ${r.id} has changed since the run: its tests would be about subjects and addresses no record of the run holds`};try{return{ok:!0,compiled:x(r,e.compile)}}catch(i){if(i instanceof w)return{ok:!1,message:i.message};throw i}}function Z(){return{readFile:e=>C(e,"utf8"),writeFile:(e,r)=>O(e,r,"utf8"),rename:(e,r)=>P(e,r),mkdir:async e=>{await y(e,{recursive:!0})}}}function I(e,r){return a.join(e,R,`${r.replace(/[^A-Za-z0-9_-]/g,"_")}${A}`)}async function K(e,r,i){let n=p.parse(i),t=I(r,n.runId),o=`${t}.${process.pid}.tmp`;return await e.mkdir(a.dirname(t)),await e.writeFile(o,`${JSON.stringify(n,null,2)}
8
8
  `),await e.rename(o,t),t}async function X(e,r,i){let n=I(r,i),t;try{t=await e.readFile(n)}catch(c){if(c.code==="ENOENT")return{kind:"absent"};throw c}let o;try{o=JSON.parse(t)}catch{return{kind:"invalid",message:`${a.basename(n)} is not JSON`}}let s=p.safeParse(o);if(!s.success){let c=s.error.issues[0];return{kind:"invalid",message:`${a.basename(n)}: ${c.path.join(".")||"the file"}: ${c.message}`}}return s.data.runId!==i?{kind:"invalid",message:`${a.basename(n)} is the companion of the run ${s.data.runId}, not ${i}`}:{kind:"read",sidecar:s.data}}function m(e){return Array.isArray(e)?`[${e.map(r=>m(r??null)).join(",")}]`:e!==null&&typeof e=="object"?`{${Object.entries(e).filter(([,i])=>i!==void 0).sort(([i],[n])=>i<n?-1:i>n?1:0).map(([i,n])=>`${JSON.stringify(i)}:${m(n)}`).join(",")}}`:JSON.stringify(e??null)}export{A as a,p as b,F as c,v as d,D as e,U as f,Z as g,I as h,K as i,X as j};
@@ -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{k as be}from"./chunk-JESRFE2Z.mjs";import{a as ge,c as B,d as we}from"./chunk-CBL42DUU.mjs";import{b as fe,e as pe,i as me,j as D,l as S}from"./chunk-MKTXJCXN.mjs";import{b as ue}from"./chunk-DBBPDSFN.mjs";import{g as P,j as te,l as T,m as ie,p as ne}from"./chunk-VZT4E2OJ.mjs";import{A as ce,B as le,v as se,x as ae,z as de}from"./chunk-O2PUGRNW.mjs";import{j as oe}from"./chunk-SAMWHL22.mjs";import{A as re,x as I}from"./chunk-J24TIGSI.mjs";import{d as ee}from"./chunk-HKUWHVI7.mjs";import{e as X}from"./chunk-VPDEJGPS.mjs";import{c as Z}from"./chunk-JQZTMFO7.mjs";import{g as V,h as Y,i as q,q as Q}from"./chunk-L4INJ5TZ.mjs";import{b as K}from"./chunk-CA5NAXSU.mjs";import{Ld as J}from"./chunk-ZQO5PDX5.mjs";var ve="No record would be read or written.";function je(t,e){return{code:"RUN_WRITING",message:`${e.operation==="take"?`A checkpoint of ${t} is being taken`:e.operation==="rewind"?`A rewind is writing to ${t}`:e.operation==="undo"?`An undo is writing to ${t}`:e.operation==="empty"?`An emptying of its objects is writing to ${t}`:`SandForge is deleting checkpoints of ${t}`} (process ${e.pid} on ${e.host}): rewind once it has ended. ${ve}`}}function Ae(t){return{query:e=>t.query(e),queryMore:e=>t.queryMore(e)}}function Ee(t){let e=t.objects.find(r=>r.objectApiName===V);if(e===void 0)return 0;let n=e.toBringBack;return n.inBin+n.withParent+n.deletedWhileTaken}function Pe(t,e){return{objectsRead:[...t],objects:[],unread:["flows","triggers","processes","workflowRules"].map(n=>({part:n,reason:e})),conditionsNotRead:0,conditionsBound:0,requests:0}}function Te(t,e){let n=new Map,r;return{bodies:n,global:()=>r,describeGlobal:()=>r??=t.describeGlobal(),reader:{lane:()=>e.lane(),tooling:i=>e.tooling(i),calls:()=>e.calls(),describe:async(i,a)=>{let d=await e.describe(i,a);return"body"in d&&n.set(i,d.body),d}}}}async function Je(t,e){let{org:n,signal:r}=t,{checkpoint:i,orgName:a}=e,d,p=await ue(Ae(n),{act:"preview",orgName:a,registered:e.registered,username:e.username,organizationId:i.org.organizationId,customSettings:Q(i)},{userId:async()=>d=await n.userId()});if(!p.allowed)return{previewed:!1,refusal:p.refusal};let m=await de(n,a),g=Te(n,oe(n,r)),ke=await fe({grants:p.grants,...d!==void 0?{userId:d}:{},username:e.username,checkpoint:i,reader:g.reader}),h=await n.serverTime(),R=re("pv",(t.now??(()=>new Date))()),c=await pe({checkpoint:i,folder:e.folder,reader:g.reader,describeGlobal:g.describeGlobal,previewId:R,readAt:h,queryAllFiles:p.queryAllFiles,access:ke,...r?{signal:r}:{}}),O=m.fileStorage;c.files!==void 0&&O!==void 0&&(c.files.storage.remaining=O.remaining*1048576);let w=e.objects!==void 0?new Set(e.objects):void 0,l=me(c,w),b=ge(l),F=w===void 0&&i.scope.mode==="picked"&&c.objects.some(o=>o.outside.length>0),ye=F&&e.acceptOutside===!1,y;if(w!==void 0||ye){y=await S({checkpoint:i,previewDir:I(e.folder,R),readAt:h,...w!==void 0?{objects:w}:{},acceptOutside:e.acceptOutside===!0,heldRows:D(i,e.folder),...r?{signal:r}:{}});for(let{objectApiName:o}of y.acts)b.includes(o)||b.push(o)}let s;if(b.length>0&&t.readAutomation)try{s=await t.readAutomation(b)}catch(o){s=Pe(b,K(o))}let C,k=0,G=y?B(c,y):l,v=we(G),u=s&&e.muteAutomation===!0?ee(s,J(v)):void 0,j=s&&u&&u.plan.assign.length>0&&t.mute?await be(t.mute,s,v):void 0,he=j&&"refusal"in j?j.refusal:void 0;if(s){let o=await ne({act:"rewind",orgName:a,automation:s,steps:v,...u?{plan:u.plan}:{},accepted:!1,mayMute:u===void 0,read:()=>Z(n)});C=o.gate.deliverability,k=o.ofRun.read?.requests??0}let M=g.global(),N=M?new Set((await X({describeGlobal:()=>M})).keys()):void 0,W=new Set(i.objects.map(({objectApiName:o})=>o.toLowerCase()));if(i.files!==void 0)for(let o of[Y,q])W.add(o.toLowerCase());let _=new Map;for(let[o,Oe]of g.bodies)_.set(o,se(Oe,{inCheckpoint:W,...N?{worked:N}:{}}));let L=ae({objects:i.objects,diff:l,automationRequests:s?.requests??0,...k>0?{deliverabilityRequests:k}:{},relationships:_,...e.reusesPreview===!0?{reusesPreview:!0}:{}}),Re={...L,apiRequestsLeft:m.remaining},$=P(G.objects),f=u?.automation??s,A=f?T($,f,m.emails):[],x=f?te($,f):void 0,U=F&&e.acceptOutside===void 0&&f?T(P(B(c,await S({checkpoint:i,previewDir:I(e.folder,R),readAt:h,acceptOutside:!1,heldRows:D(i,e.folder),...r?{signal:r}:{}})).objects),f,m.emails):void 0,E=t.store.heldBy(i.org.organizationId),z=E===void 0?await t.runWriting?.(p.org.id):void 0,H=E!==void 0?je(a,E):z!==void 0?{code:"RUN_WRITING",message:z}:he??ce("rewind",{run:L.apiRequests-k,deliverability:k},m,a)??ie("rewind",A,a)??(l.files!==void 0?le("rewind",{files:Ee(l),bytes:l.files.storage.bringBack},O?.remaining,a):void 0);return{previewed:!0,diff:c,...s?{automation:s}:{},...A.length>0?{emails:A}:{},...U?{emailsKeepingOutside:U}:{},...x!==void 0?{emailsUncounted:x}:{},...C?{deliverability:C}:{},estimate:Re,...H?{refusal:H}:{}}}export{Je as a};
7
+ import{k as be}from"./chunk-BH76USTQ.mjs";import{a as ge,c as B,d as we}from"./chunk-XKFHTBAB.mjs";import{b as fe,e as pe,i as me,j as D,l as S}from"./chunk-FYWNSMOZ.mjs";import{b as ue}from"./chunk-BPHTA6KP.mjs";import{g as P,j as te,l as T,m as ie,p as ne}from"./chunk-4X5D3MSV.mjs";import{A as ce,B as le,v as se,x as ae,z as de}from"./chunk-XMQ5R6TC.mjs";import{j as oe}from"./chunk-EOQON3E5.mjs";import{A as re,x as I}from"./chunk-N2HYG3BL.mjs";import{d as ee}from"./chunk-7WSQ65WG.mjs";import{e as X}from"./chunk-MJD6CPZZ.mjs";import{c as Z}from"./chunk-WXU6ZJIV.mjs";import{g as V,h as Y,i as q,q as Q}from"./chunk-Z3MGN42K.mjs";import{b as K}from"./chunk-CA5NAXSU.mjs";import{Yd as J}from"./chunk-6QSHWIZI.mjs";var ve="No record would be read or written.";function je(t,e){return{code:"RUN_WRITING",message:`${e.operation==="take"?`A checkpoint of ${t} is being taken`:e.operation==="rewind"?`A rewind is writing to ${t}`:e.operation==="undo"?`An undo is writing to ${t}`:e.operation==="empty"?`An emptying of its objects is writing to ${t}`:`SandForge is deleting checkpoints of ${t}`} (process ${e.pid} on ${e.host}): rewind once it has ended. ${ve}`}}function Ae(t){return{query:e=>t.query(e),queryMore:e=>t.queryMore(e)}}function Ee(t){let e=t.objects.find(r=>r.objectApiName===V);if(e===void 0)return 0;let n=e.toBringBack;return n.inBin+n.withParent+n.deletedWhileTaken}function Pe(t,e){return{objectsRead:[...t],objects:[],unread:["flows","triggers","processes","workflowRules"].map(n=>({part:n,reason:e})),conditionsNotRead:0,conditionsBound:0,requests:0}}function Te(t,e){let n=new Map,r;return{bodies:n,global:()=>r,describeGlobal:()=>r??=t.describeGlobal(),reader:{lane:()=>e.lane(),tooling:i=>e.tooling(i),calls:()=>e.calls(),describe:async(i,a)=>{let d=await e.describe(i,a);return"body"in d&&n.set(i,d.body),d}}}}async function Je(t,e){let{org:n,signal:r}=t,{checkpoint:i,orgName:a}=e,d,p=await ue(Ae(n),{act:"preview",orgName:a,registered:e.registered,username:e.username,organizationId:i.org.organizationId,customSettings:Q(i)},{userId:async()=>d=await n.userId()});if(!p.allowed)return{previewed:!1,refusal:p.refusal};let m=await de(n,a),g=Te(n,oe(n,r)),ke=await fe({grants:p.grants,...d!==void 0?{userId:d}:{},username:e.username,checkpoint:i,reader:g.reader}),h=await n.serverTime(),R=re("pv",(t.now??(()=>new Date))()),c=await pe({checkpoint:i,folder:e.folder,reader:g.reader,describeGlobal:g.describeGlobal,previewId:R,readAt:h,queryAllFiles:p.queryAllFiles,access:ke,...r?{signal:r}:{}}),O=m.fileStorage;c.files!==void 0&&O!==void 0&&(c.files.storage.remaining=O.remaining*1048576);let w=e.objects!==void 0?new Set(e.objects):void 0,l=me(c,w),b=ge(l),F=w===void 0&&i.scope.mode==="picked"&&c.objects.some(o=>o.outside.length>0),ye=F&&e.acceptOutside===!1,y;if(w!==void 0||ye){y=await S({checkpoint:i,previewDir:I(e.folder,R),readAt:h,...w!==void 0?{objects:w}:{},acceptOutside:e.acceptOutside===!0,heldRows:D(i,e.folder),...r?{signal:r}:{}});for(let{objectApiName:o}of y.acts)b.includes(o)||b.push(o)}let s;if(b.length>0&&t.readAutomation)try{s=await t.readAutomation(b)}catch(o){s=Pe(b,K(o))}let C,k=0,G=y?B(c,y):l,v=we(G),u=s&&e.muteAutomation===!0?ee(s,J(v)):void 0,j=s&&u&&u.plan.assign.length>0&&t.mute?await be(t.mute,s,v):void 0,he=j&&"refusal"in j?j.refusal:void 0;if(s){let o=await ne({act:"rewind",orgName:a,automation:s,steps:v,...u?{plan:u.plan}:{},accepted:!1,mayMute:u===void 0,read:()=>Z(n)});C=o.gate.deliverability,k=o.ofRun.read?.requests??0}let M=g.global(),N=M?new Set((await X({describeGlobal:()=>M})).keys()):void 0,W=new Set(i.objects.map(({objectApiName:o})=>o.toLowerCase()));if(i.files!==void 0)for(let o of[Y,q])W.add(o.toLowerCase());let _=new Map;for(let[o,Oe]of g.bodies)_.set(o,se(Oe,{inCheckpoint:W,...N?{worked:N}:{}}));let L=ae({objects:i.objects,diff:l,automationRequests:s?.requests??0,...k>0?{deliverabilityRequests:k}:{},relationships:_,...e.reusesPreview===!0?{reusesPreview:!0}:{}}),Re={...L,apiRequestsLeft:m.remaining},$=P(G.objects),f=u?.automation??s,A=f?T($,f,m.emails):[],x=f?te($,f):void 0,U=F&&e.acceptOutside===void 0&&f?T(P(B(c,await S({checkpoint:i,previewDir:I(e.folder,R),readAt:h,acceptOutside:!1,heldRows:D(i,e.folder),...r?{signal:r}:{}})).objects),f,m.emails):void 0,E=t.store.heldBy(i.org.organizationId),z=E===void 0?await t.runWriting?.(p.org.id):void 0,H=E!==void 0?je(a,E):z!==void 0?{code:"RUN_WRITING",message:z}:he??ce("rewind",{run:L.apiRequests-k,deliverability:k},m,a)??ie("rewind",A,a)??(l.files!==void 0?le("rewind",{files:Ee(l),bytes:l.files.storage.bringBack},O?.remaining,a):void 0);return{previewed:!0,diff:c,...s?{automation:s}:{},...A.length>0?{emails:A}:{},...U?{emailsKeepingOutside:U}:{},...x!==void 0?{emailsUncounted:x}:{},...C?{deliverability:C}:{},estimate:Re,...H?{refusal:H}:{}}}export{Je as a};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a as O,f as dt,h as C}from"./chunk-TZE3Y7IQ.mjs";import{Bc as at}from"./chunk-ZQO5PDX5.mjs";var It="AccountContactRelation",D="EmailMessage",z="Task",tt="TaskRelation",B="EventRelation",j=200,en={ProductSellingModel:["SellingModelType","PricingTerm","PricingTermUnit"]},rn={objectApiName:"FeedItem",field:"Type",value:"CreateRecordEvent",parent:"ParentId"},X={FeedItem:[{field:"Type",value:"TrackedChange",noun:"tracked change"}],[tt]:[{field:"IsWhat",value:!0,noun:"what relation",from:"the task's WhatId"}],[B]:[{field:"IsWhat",value:!0,noun:"what relation",from:"the event's WhatId"}],EmailMessageRelation:[{noun:"email relation",from:"the email's addresses"}]};function Et(t,n){return X[t]?.find(e=>e.field===void 0||e.value!==void 0&&String(n[e.field])===String(e.value))}var ut=class{constructor(n=Et){this.rowsOf=n}rowsOf;reasons=new Map;byObject=new Map;leaveOut(n,e,r,o=[]){let i=this.reasons.get(e);if(i)return i;let s=this.reasonFor(n,r,o);if(!s)return;this.reasons.set(e,s);let d=this.byObject.get(n)??new Map,u=`${s.rows.field}=${s.rows.value}|${s.through??""}`,l=d.get(u)??{why:s,ids:new Set};return l.ids.add(e),d.set(u,l),this.byObject.set(n,d),s}keep(n,e,r=[]){return e.filter(o=>!this.leaveOut(n,String(o.Id),o,r))}has(n){return this.reasons.has(n)}counts(n){return(n===void 0?[...this.byObject]:[[n,this.byObject.get(n)]]).flatMap(([r,o])=>[...o?.values()??[]].map(({why:i,ids:s})=>({objectApiName:r,why:i,count:s.size})))}reasonFor(n,e,r){let o=this.rowsOf(n,e);if(o)return{rows:o};for(let i of r){let s=e[i],d=typeof s=="string"?this.reasons.get(s):void 0;if(d)return{rows:d.rows,through:i}}}};function on(t,n){if(n.through)return`${t} left out: ${n.through} names a ${n.rows.noun}, which the platform writes itself`;let e=n.rows.from?`, from ${n.rows.from}`:"";return`${t} ${n.rows.noun}${t===1?"":"s"} left out: the platform writes them itself${e}`}function sn(t,n){let e=`${t} record${t===1?"":"s"}`;return n.through?`${n.through} \u2192 ${n.rows.noun} (${e})`:n.rows.field===void 0?`every ${n.rows.noun} (${e})`:`${n.rows.field}=${String(n.rows.value)} (${e})`}function an(t){return t.through?`Not written: ${t.through} may not be left empty, and the ${t.rows.noun} it names is one the platform writes itself, which no copy sends.`:t.rows.from?`Not written: the platform writes each ${t.rows.noun} itself, from ${t.rows.from}.`:`Not written: the platform writes each ${t.rows.noun} itself, and refuses one a copy sends.`}function ct({field:t,value:n},e){if(t===void 0)return e==="="?"Id != null":"Id = null";let r=typeof n=="boolean"?String(n):`'${O(n??"")}'`;return`${C(t)} ${e} ${r}`}function dn(t,n,e){let r=s=>s.map(d=>ct(d,"=")).join(" OR "),o=(X[t]??[]).map(s=>ct(s,"!=")),i=n.flatMap(s=>s.referenceTo.flatMap(d=>{let u=X[d];if(d===t||!e.has(d)||!u||u.length===0)return[];let l=e.get(d),I=l?`(${dt(l)}) AND (${r(u)})`:`(${r(u)})`;return[`${C(s.name)} NOT IN (SELECT Id FROM ${C(d)} WHERE ${I})`]}));return[...o,...i]}var $t={[tt]:new Set(["Contact","Lead"]),[B]:new Set(["Contact","Lead","User","Calendar"])};function un(t,n,e){let r=$t[t];if(!r)return n;let o=n.IsWhat;return o!==""&&o!==null&&o!==void 0||e===void 0||r.has(e)?n:{...n,IsWhat:!0}}var Ct="500";function Pt(t){return t.startsWith(Ct)?"Case":void 0}function ht(t,n=Pt){let e=t.ParentId;if(typeof e=="string"&&e!=="")return!0;let r=t.RelatedToId;return typeof r=="string"&&r!==""&&n(r)==="Case"}function cn(t,n){return t===D&&!ht(n)?["ActivityId"]:[]}function fn(t){return!t.has(D)||!t.has(z)?[]:[{sourceObject:D,targetObject:z,relationshipName:`${D}Before${z}`,type:"lookup",required:!0}]}function ln(t,n){let e=t.ActivityId;return typeof e=="string"&&e!==""&&ht(t,n)}var S=200;async function gn(t,n){let e=new Map;for(let r=0;r<n.length;r+=S){let o=n.slice(r,r+S).map(s=>`'${O(s)}'`).join(", "),i=await t(`SELECT Id, ActivityId FROM ${D} WHERE Id IN (${o})`);for(let s of i){let d=s.ActivityId;typeof s.Id=="string"&&typeof d=="string"&&d!==""&&e.set(s.Id,d)}}return e}var L="Account",H="Contact",Q="PersonContactId",mt="IsPersonAccount";function kt(t){let n=t[mt];return n===!0||n==="true"||n===1}function pn(t,n){return kt(t)?n?"personAsBusiness":"person":"business"}function yn(t,n){return t==="person"?n==="person":n!=="person"}function Rn(t,n){return!t.has(L)||!t.has(H)?[]:n.get(L)?.some(r=>r.name===Q)===!0||n.get(H)?.some(r=>r.name===mt)===!0?[{sourceObject:L,targetObject:H,relationshipName:`${L}Before${H}`,type:"lookup",required:!0}]:[]}function Mt(t){let n=t.map(e=>`'${O(e)}'`).join(", ");return`SELECT Id, ${Q} FROM ${L} WHERE Id IN (${n})`}var At=new RegExp(`^SELECT Id, ${Q} FROM ${L} WHERE Id IN \\((.*)\\)$`);function wn(t){let n=At.exec(t);if(n)return[...n[1].matchAll(/'([^']*)'/g)].map(([,e])=>e)}async function In(t,n){let e=new Map;for(let r=0;r<n.length;r+=S){let o=await t(Mt(n.slice(r,r+S)));for(let i of o){let s=i[Q];typeof i.Id=="string"&&typeof s=="string"&&s!==""&&e.set(i.Id,s)}}return e}var v="OpportunityTeamMember",M="OpportunitySplit",Nt="Opportunity",Z="OpportunitySplitType",$="SplitTypeId",nt={[v]:"UserId",[M]:"SplitOwnerId"};function hn(t){return nt[t]!==void 0}function mn(t){return t==="Task"?"their email":t==="Contact"?"their person account":t===It?"their contact":t===Ot?"their opportunity, for its contact":"their opportunity, for its owner"}var Ot="OpportunityContactRole",Y="ContactId",ft=t=>t.IsPrimary===!0||t.IsPrimary==="true";function Lt(t,n){let e=new Map;return t.forEach((r,o)=>{let i=w(r,"OpportunityId"),s=w(r,Y);if(i===void 0||s===void 0)return;let d=n(i);if(d===void 0||y(d)!==y(s))return;let u=y(i),l=e.get(u);(l===void 0||!ft(t[l])&&ft(r))&&e.set(u,o)}),[...e.values()].sort((r,o)=>r-o)}var lt=["CreatedDate","CreatedById","Opportunity.CreatedDate","Opportunity.CreatedById"];function xt(t,n=[]){let e=["Id","OpportunityId",Y],r=[...e,...lt];return`SELECT ${[...e,...lt,...n.filter(i=>!r.includes(i)).map(C)].join(", ")} FROM ${Ot} WHERE OpportunityId IN ${et(t)} ORDER BY CreatedDate, Id`}var bt=/^SELECT Id, OpportunityId, ContactId, CreatedDate, CreatedById, Opportunity\.CreatedDate, Opportunity\.CreatedById((?:, \w+)*) FROM OpportunityContactRole WHERE OpportunityId IN (\(.*\)) ORDER BY CreatedDate, Id$/;function On(t){let n=bt.exec(t);if(!n)return;let[,e,r]=n;return{fields:e.split(", ").filter(o=>o!==""),opportunities:rt(r)}}async function _t(t,n,e=[]){let r=[];for(let o=0;o<n.length;o+=S)r.push(...await t(xt(n.slice(o,o+S),e)));return r}var Ft=1,gt=t=>typeof t=="string"&&t!==""?Math.floor(Date.parse(t)/1e3):Number.NaN;function Wt(t){let n=t.Opportunity;if(typeof n!="object"||n===null)return!1;let e=n,r=w(t,"CreatedById"),o=w(e,"CreatedById"),i=gt(t.CreatedDate),s=gt(e.CreatedDate);return r!==void 0&&o!==void 0&&y(r)===y(o)&&!Number.isNaN(i)&&!Number.isNaN(s)&&i-s>=0&&i-s<=Ft}function Dt(t,n){let e=new Map;for(let i of n){let s=w(i,"Id"),d=w(i,"OpportunityId"),u=w(i,Y);if(!s||!d||!u||!Wt(i))continue;let l=`${y(d)}:${y(u)}`;e.set(l,[...e.get(l)??[],i])}let r=new Map,o=[];for(let[i,{opportunity:s,contact:d}]of t){let u=e.get(`${y(s)}:${y(d)}`)??[];u.length>1?o.push(i):u.length===1&&r.set(i,u[0])}return{found:r,alike:o}}function Tn(t,n="read"){return`${t} contact role(s) not linked to the one the platform wrote with their opportunity, so written as ${n}: the target holds more than one role of their contact under it made with it, within a second, by the same user, and nothing tells which the platform wrote. The opportunity holds the role of its contact more than once.`}var vt="the user the run writes as";function Sn(t,n){let e={CreatedDate:n,CreatedById:vt};return{...t,...e,Opportunity:{...e}}}async function En(t,n,e,r=[]){let o=Lt(n,e);if(o.length===0)return{found:new Map,alike:[]};let i=new Map(o.map(d=>[d,{opportunity:String(n[d].OpportunityId),contact:String(n[d][Y])}])),s=await _t(t,[...new Set([...i.values()].map(({opportunity:d})=>d))],r);return Dt(i,s)}function $n(t){return!t.has(v)||!t.has(M)?[]:[{sourceObject:v,targetObject:M,relationshipName:`${v}Before${M}`,type:"lookup",required:!0}]}var Ut={[v]:{TeamMemberRole:"Opportunity Owner",OpportunityAccessLevel:"All"},[M]:{}},pt=t=>!/__c$/i.test(t),qt=new Set(["SplitPercentage","SplitAmount","CurrencyIsoCode"]),U=`SELECT Id, OwnerId FROM ${Nt} WHERE Id IN `,Kt=`SELECT Id, DeveloperName, IsTotalValidated FROM ${Z} WHERE IsActive = true`,et=t=>`(${t.map(n=>`'${O(n)}'`).join(", ")})`,rt=t=>[...t.matchAll(/'([^']*)'/g)].map(([,n])=>n);function Cn(t){return`${U}${et(t)}`}function Pn(t){if(!t.startsWith(U))return;let n=t.slice(U.length);return/^\(.*\)$/.test(n)?rt(n):void 0}function Tt(t,n){let e=nt[t];return`SELECT ${["Id","OpportunityId",...t===M?[e,$]:[e],...n].join(", ")} FROM ${t} WHERE OpportunityId IN `}function kn(t,n,e){return`${Tt(t,n)}${et(e)}`}var Ht=/^SELECT Id, OpportunityId, (?:UserId|SplitOwnerId, SplitTypeId)((?:, \w+)*) FROM (OpportunityTeamMember|OpportunitySplit) WHERE OpportunityId IN (\(.*\))$/;function Mn(t){let n=Ht.exec(t);if(!n)return;let[,e,r,o]=n;return{objectApiName:r,fields:e.split(", ").filter(i=>i!==""),opportunities:rt(o)}}var y=t=>t.slice(0,15);async function W(t,n,e){let r=[];for(let o=0;o<e.length;o+=S){let i=e.slice(o,o+S).map(s=>`'${O(s)}'`).join(", ");r.push(...await t(`${n}(${i})`))}return r}function J(t,n){let e=new Map;for(let r of t){let o=r[n];typeof r.Id=="string"&&typeof o=="string"&&o!==""&&e.set(y(r.Id),o)}return e}var w=(t,n)=>{let e=t[n];return typeof e=="string"&&e!==""?e:void 0};async function An(t,n,e){let r={lookups:new Map,linked:new Map,held:new Map,defaulted:new Set},o=nt[t];if(o===void 0)return r;let i=t===M,s=n.filter(a=>{let f=w(a,"OpportunityId");return f!==void 0&&e.targetIdOf(f)!==void 0});if(s.length===0)return r;let d=[...new Set(s.map(a=>String(a.OpportunityId)))],u=J(await W(e.source,U,d),"OwnerId"),l=a=>e.targetIdOf(String(a.OpportunityId)),I=[...new Set(s.map(l))],{simulated:T}=e,x=T?void 0:J(await W(e.target,U,I),"OwnerId"),b=a=>{let f=u.get(y(String(a.OpportunityId)));return f===void 0?{}:{source:f,target:T?T.ownerOf(f):x?.get(y(l(a)))}},_=a=>{let f=w(a,o),R=b(a).source;return f!==void 0&&R!==void 0&&y(f)===y(R)},A=[...new Set(s.flatMap(a=>{let f=w(a,o);return f===void 0||_(a)||e.mappedUser(f)!==void 0?[]:[f]}))],q=A.length>0?new Set((await W(e.target,"SELECT Id FROM User WHERE IsActive = true AND Id IN ",A)).flatMap(a=>typeof a.Id=="string"?[y(a.Id)]:[])):new Set,K=i?J(await W(e.source,`SELECT Id, DeveloperName FROM ${Z} WHERE Id IN `,[...new Set(s.flatMap(a=>w(a,$)??[]))]),"DeveloperName"):new Map,F=new Map;if(i)for(let a of await e.target(Kt))typeof a.Id=="string"&&typeof a.DeveloperName=="string"&&F.set(a.DeveloperName,{id:a.Id,total:a.IsTotalValidated===!0||a.IsTotalValidated==="true"});let c=(e.written??[]).filter(a=>a!=="Id"&&a!=="OpportunityId"&&a!==o&&a!==$&&!qt.has(a)),g=(a,f)=>{let R=a[f];return!(R==null||R===""||R===!1)},p=(a,f,R=c)=>R.filter(P=>g(a,P)&&String(a[P])!==String(f[P]??"")),m=new Map,h=(a,f,R)=>[a,f,R??""].map(y).join("|");if(!T)for(let a of await W(e.target,Tt(t,c),I)){let f=w(a,"OpportunityId"),R=w(a,o);typeof a.Id!="string"||f===void 0||R===void 0||m.set(h(f,R,i?w(a,$):void 0),a)}for(let a of s){let f=w(a,o);if(f===void 0)continue;let R=_(a),P=b(a).target,N=R?P:e.mappedUser(f)??(q.has(y(f))?f:void 0),ot=!R&&N===void 0&&e.defaultUser!==void 0;if(ot&&(N=e.defaultUser),N===void 0){r.held.set(a,{field:o,parentObject:"User",why:R?`${o} names the owner of its opportunity, whose owner in the target could not be read.`:`${o} names a user the target has no counterpart of: a team member and a split go in for the opportunity's owner, which is the owner of its copy in the target, for a user an owner mapping gives, or for a user of the same id the target holds active.`});continue}let G={[o]:N},it=!1;if(i){let E=w(a,$);if(E!==void 0){let k=K.get(y(E)),V=k===void 0?void 0:F.get(k);if(V===void 0){r.held.set(a,{field:$,parentObject:Z,why:`${$} names ${k===void 0?"a split type":`the split type ${k}`}, which the target holds no active one of by that name: sent without it, the split would go in as one of the Revenue type.`});continue}G[$]=V.id,it=V.total}}let St=l(a),st=P!==void 0&&y(N)===y(P);if(T){if(st&&(!i||it)){let E=c.filter(k=>!pt(k)&&g(a,k));r.linked.set(a,{id:T.idFor(),owners:!0,notKept:p(a,Ut[t]??{},c.filter(pt)),...E.length>0?{unread:E}:{}});continue}}else{let E=m.get(h(St,N,G[$]));if(E!==void 0){r.linked.set(a,{id:String(E.Id),owners:st,notKept:p(a,E)});continue}}r.lookups.set(a,G),ot&&r.defaulted.add(a)}return r}var jt={[tt]:"TaskId",[B]:"EventId"};async function Nn(t,n,e){let r=new Map,o=jt[n];if(o===void 0)return r;let i=[...new Set(e.map(d=>d[o]).filter(d=>typeof d=="string"&&d!==""))];if(i.length===0)return r;let s=new Map;for(let d=0;d<i.length;d+=S){let u=i.slice(d,d+S).map(I=>`'${O(I)}'`).join(", "),l=await t(`SELECT Id, ${o}, RelationId FROM ${n} WHERE ${o} IN (${u})`);for(let I of l)typeof I.Id=="string"&&s.set(`${String(I[o])}|${String(I.RelationId)}`,I.Id)}return e.forEach((d,u)=>{let l=s.get(`${String(d[o])}|${String(d.RelationId)}`);l&&r.set(u,l)}),r}var Bt={[B]:["IsInvitee"]},yt={IsInvitee:["Status","Response","RespondedDate"]},Rt="the run was cancelled before it was updated";async function Ln(t,n,e,r,o=()=>!1){return Qt(await Yt(t,n,e,r,o))}function Qt(t){if(!(t===void 0||t.size===0))return[...t].map(([n,e])=>`${e} linked without ${n}`).join(", ")}function xn(t,n){if(n.size===0)return t;let e=new Map(t??[]);for(let[r,o]of n)e.set(r,(e.get(r)??0)+o);return e}async function Yt(t,n,e,r,o=()=>!1){let i=Bt[t]??[],s=new Set(i.flatMap(c=>[c,...yt[c]??[]]).filter(c=>!e(c))),d=new Map,u=(c,g)=>{let p=`${c}: ${g}`;d.set(p,(d.get(p)??0)+1)},l=[];for(let[c,g]of n){let p={},m={};for(let h of i.filter(a=>String(c[a])==="true")){if(s.has(h)){u(h,"the target does not let it be updated");continue}p[h]=!0;for(let a of yt[h]??[]){let f=c[a];f==null||f===""||(s.has(a)?u(a,"the target does not let it be updated"):m[a]=f)}}Object.keys(p).length>0&&l.push({Id:g,flagsGiven:p,answer:m})}let I=!1,T=async c=>{let g=new Map;if(c.length===0)return g;if(o()){for(let h of c)g.set(h.Id,Rt);return g}if(I)return g;let p=await r(c);I=p.length<c.length;let m=o();return c.forEach((h,a)=>{let f=p[a];f?.success||g.set(h.Id,f===void 0&&m?Rt:`the target refused the update, ${f?.errors[0]??"without saying why"}`)}),g},x=(c,g)=>{for(let p of c){let m=g.get(p.Id);if(m!==void 0)for(let h of Object.keys(p).filter(a=>a!=="Id"))u(h,m)}},b=l.map(({Id:c,flagsGiven:g,answer:p})=>({Id:c,...g,...p})),_=await T(b),A=I||o()?[]:l.filter(({Id:c,answer:g})=>_.has(c)&&Object.keys(g).length>0);x(b.filter(c=>!A.some(({Id:g})=>g===c.Id)),_);let q=A.map(({Id:c,flagsGiven:g})=>({Id:c,...g})),K=await T(q);x(q,K);let F=A.filter(({Id:c})=>!K.has(c));for(let c of new Set(F.flatMap(({answer:g})=>Object.keys(g)))){let g=F.filter(({answer:p})=>c in p).map(({Id:p,answer:m})=>({Id:p,[c]:m[c]}));x(g,await T(g))}return d}var bn={Order:"OrderStatus",Contract:"ContractStatus"},_n=new Set(["Contract"]);function Gt(t){return t==null||t===""?"null":typeof t=="number"||typeof t=="boolean"?String(t):`'${O(String(t))}'`}async function Fn(t,n){let e=new Map,r=[...new Set(n.map(i=>i.ContactId).filter(i=>typeof i=="string"&&i!==""))];if(r.length===0)return e;let o=new Map;for(let i=0;i<r.length;i+=j){let s=r.slice(i,i+j).map(u=>`'${O(u)}'`).join(", "),d=await t(`SELECT Id, AccountId, ContactId FROM ${It} WHERE IsDirect = true AND ContactId IN (${s})`);for(let u of d)typeof u.Id=="string"&&o.set(`${String(u.AccountId)}|${String(u.ContactId)}`,u.Id)}return n.forEach((i,s)=>{let d=o.get(`${String(i.AccountId)}|${String(i.ContactId)}`);d&&e.set(s,d)}),e}async function Wn(t,n){let e=new Set;for(let r=0;r<n.length;r+=j){let o=n.slice(r,r+j).map(s=>`'${O(s)}'`).join(", "),i=await t(`SELECT Id FROM PricebookEntry WHERE Id IN (${o}) AND Pricebook2.IsStandard = true`);for(let s of i)typeof s.Id=="string"&&e.add(s.Id)}return e}var wt=200;async function Dn(t,n){let e=new Map,r=[...new Set(n.map(i=>i.Product2Id).filter(i=>typeof i=="string"&&i!==""))];if(r.length===0)return e;let o=new Map;for(let i=0;i<r.length;i+=wt){let s=r.slice(i,i+wt).map(u=>`'${O(u)}'`).join(", "),d=await t(`SELECT Id, Product2Id, ProductSellingModelId FROM ${at} WHERE Product2Id IN (${s})`);for(let u of d)typeof u.Id=="string"&&o.set(`${String(u.Product2Id)}|${String(u.ProductSellingModelId)}`,u.Id)}return n.forEach((i,s)=>{let d=o.get(`${String(i.Product2Id)}|${String(i.ProductSellingModelId)}`);d&&e.set(s,d)}),e}async function vn(t,n,e,r){let o=new Map;for(let i of r){let s=JSON.stringify(e.map(l=>i[l]??null));if(o.has(s))continue;let d=e.map(l=>`${C(l)} = ${Gt(i[l])}`).join(" AND "),u=await t(`SELECT Id FROM ${C(n)} WHERE ${d} LIMIT 2`);o.set(s,u.length===1&&typeof u[0].Id=="string"?u[0].Id:void 0)}return r.map(i=>o.get(JSON.stringify(e.map(s=>i[s]??null))))}async function Un(t,n){let e;try{e=await t(`SELECT ApiName, StatusCode FROM ${C(n)}`)}catch{return}return{categoryOf:new Map(e.map(r=>[String(r.ApiName),String(r.StatusCode)])),draft:e.filter(r=>r.StatusCode==="Draft").map(r=>String(r.ApiName)).sort()[0]}}function qn(t,n){if(typeof t!="string"||t===""||!n.draft)return;let e=n.categoryOf.get(t);if(!(e===void 0||e==="Draft"))return n.draft}export{It as a,D as b,z as c,en as d,rn as e,ut as f,on as g,sn as h,an as i,dn as j,un as k,ht as l,cn as m,fn as n,ln as o,gn as p,L as q,H as r,Q as s,kt as t,pn as u,yn as v,Rn as w,Mt as x,wn as y,In as z,v as A,M as B,nt as C,hn as D,mn as E,Ot as F,Y as G,ft as H,Lt as I,xt as J,On as K,_t as L,Dt as M,Tn as N,Sn as O,En as P,$n as Q,Ut as R,Kt as S,Cn as T,Pn as U,kn as V,Mn as W,An as X,jt as Y,Nn as Z,Bt as _,Ln as $,Qt as aa,xn as ba,Yt as ca,bn as da,_n as ea,Fn as fa,Wn as ga,Dn as ha,vn as ia,Un as ja,qn as ka};
7
+ import{a as O,f as dt,h as C}from"./chunk-TZE3Y7IQ.mjs";import{Oc as at}from"./chunk-6QSHWIZI.mjs";var It="AccountContactRelation",D="EmailMessage",z="Task",tt="TaskRelation",B="EventRelation",j=200,en={ProductSellingModel:["SellingModelType","PricingTerm","PricingTermUnit"]},rn={objectApiName:"FeedItem",field:"Type",value:"CreateRecordEvent",parent:"ParentId"},X={FeedItem:[{field:"Type",value:"TrackedChange",noun:"tracked change"}],[tt]:[{field:"IsWhat",value:!0,noun:"what relation",from:"the task's WhatId"}],[B]:[{field:"IsWhat",value:!0,noun:"what relation",from:"the event's WhatId"}],EmailMessageRelation:[{noun:"email relation",from:"the email's addresses"}]};function Et(t,n){return X[t]?.find(e=>e.field===void 0||e.value!==void 0&&String(n[e.field])===String(e.value))}var ut=class{constructor(n=Et){this.rowsOf=n}rowsOf;reasons=new Map;byObject=new Map;leaveOut(n,e,r,o=[]){let i=this.reasons.get(e);if(i)return i;let s=this.reasonFor(n,r,o);if(!s)return;this.reasons.set(e,s);let d=this.byObject.get(n)??new Map,u=`${s.rows.field}=${s.rows.value}|${s.through??""}`,l=d.get(u)??{why:s,ids:new Set};return l.ids.add(e),d.set(u,l),this.byObject.set(n,d),s}keep(n,e,r=[]){return e.filter(o=>!this.leaveOut(n,String(o.Id),o,r))}has(n){return this.reasons.has(n)}counts(n){return(n===void 0?[...this.byObject]:[[n,this.byObject.get(n)]]).flatMap(([r,o])=>[...o?.values()??[]].map(({why:i,ids:s})=>({objectApiName:r,why:i,count:s.size})))}reasonFor(n,e,r){let o=this.rowsOf(n,e);if(o)return{rows:o};for(let i of r){let s=e[i],d=typeof s=="string"?this.reasons.get(s):void 0;if(d)return{rows:d.rows,through:i}}}};function on(t,n){if(n.through)return`${t} left out: ${n.through} names a ${n.rows.noun}, which the platform writes itself`;let e=n.rows.from?`, from ${n.rows.from}`:"";return`${t} ${n.rows.noun}${t===1?"":"s"} left out: the platform writes them itself${e}`}function sn(t,n){let e=`${t} record${t===1?"":"s"}`;return n.through?`${n.through} \u2192 ${n.rows.noun} (${e})`:n.rows.field===void 0?`every ${n.rows.noun} (${e})`:`${n.rows.field}=${String(n.rows.value)} (${e})`}function an(t){return t.through?`Not written: ${t.through} may not be left empty, and the ${t.rows.noun} it names is one the platform writes itself, which no copy sends.`:t.rows.from?`Not written: the platform writes each ${t.rows.noun} itself, from ${t.rows.from}.`:`Not written: the platform writes each ${t.rows.noun} itself, and refuses one a copy sends.`}function ct({field:t,value:n},e){if(t===void 0)return e==="="?"Id != null":"Id = null";let r=typeof n=="boolean"?String(n):`'${O(n??"")}'`;return`${C(t)} ${e} ${r}`}function dn(t,n,e){let r=s=>s.map(d=>ct(d,"=")).join(" OR "),o=(X[t]??[]).map(s=>ct(s,"!=")),i=n.flatMap(s=>s.referenceTo.flatMap(d=>{let u=X[d];if(d===t||!e.has(d)||!u||u.length===0)return[];let l=e.get(d),I=l?`(${dt(l)}) AND (${r(u)})`:`(${r(u)})`;return[`${C(s.name)} NOT IN (SELECT Id FROM ${C(d)} WHERE ${I})`]}));return[...o,...i]}var $t={[tt]:new Set(["Contact","Lead"]),[B]:new Set(["Contact","Lead","User","Calendar"])};function un(t,n,e){let r=$t[t];if(!r)return n;let o=n.IsWhat;return o!==""&&o!==null&&o!==void 0||e===void 0||r.has(e)?n:{...n,IsWhat:!0}}var Ct="500";function Pt(t){return t.startsWith(Ct)?"Case":void 0}function ht(t,n=Pt){let e=t.ParentId;if(typeof e=="string"&&e!=="")return!0;let r=t.RelatedToId;return typeof r=="string"&&r!==""&&n(r)==="Case"}function cn(t,n){return t===D&&!ht(n)?["ActivityId"]:[]}function fn(t){return!t.has(D)||!t.has(z)?[]:[{sourceObject:D,targetObject:z,relationshipName:`${D}Before${z}`,type:"lookup",required:!0}]}function ln(t,n){let e=t.ActivityId;return typeof e=="string"&&e!==""&&ht(t,n)}var S=200;async function gn(t,n){let e=new Map;for(let r=0;r<n.length;r+=S){let o=n.slice(r,r+S).map(s=>`'${O(s)}'`).join(", "),i=await t(`SELECT Id, ActivityId FROM ${D} WHERE Id IN (${o})`);for(let s of i){let d=s.ActivityId;typeof s.Id=="string"&&typeof d=="string"&&d!==""&&e.set(s.Id,d)}}return e}var L="Account",H="Contact",Q="PersonContactId",mt="IsPersonAccount";function kt(t){let n=t[mt];return n===!0||n==="true"||n===1}function pn(t,n){return kt(t)?n?"personAsBusiness":"person":"business"}function yn(t,n){return t==="person"?n==="person":n!=="person"}function Rn(t,n){return!t.has(L)||!t.has(H)?[]:n.get(L)?.some(r=>r.name===Q)===!0||n.get(H)?.some(r=>r.name===mt)===!0?[{sourceObject:L,targetObject:H,relationshipName:`${L}Before${H}`,type:"lookup",required:!0}]:[]}function Mt(t){let n=t.map(e=>`'${O(e)}'`).join(", ");return`SELECT Id, ${Q} FROM ${L} WHERE Id IN (${n})`}var At=new RegExp(`^SELECT Id, ${Q} FROM ${L} WHERE Id IN \\((.*)\\)$`);function wn(t){let n=At.exec(t);if(n)return[...n[1].matchAll(/'([^']*)'/g)].map(([,e])=>e)}async function In(t,n){let e=new Map;for(let r=0;r<n.length;r+=S){let o=await t(Mt(n.slice(r,r+S)));for(let i of o){let s=i[Q];typeof i.Id=="string"&&typeof s=="string"&&s!==""&&e.set(i.Id,s)}}return e}var v="OpportunityTeamMember",M="OpportunitySplit",Nt="Opportunity",Z="OpportunitySplitType",$="SplitTypeId",nt={[v]:"UserId",[M]:"SplitOwnerId"};function hn(t){return nt[t]!==void 0}function mn(t){return t==="Task"?"their email":t==="Contact"?"their person account":t===It?"their contact":t===Ot?"their opportunity, for its contact":"their opportunity, for its owner"}var Ot="OpportunityContactRole",Y="ContactId",ft=t=>t.IsPrimary===!0||t.IsPrimary==="true";function Lt(t,n){let e=new Map;return t.forEach((r,o)=>{let i=w(r,"OpportunityId"),s=w(r,Y);if(i===void 0||s===void 0)return;let d=n(i);if(d===void 0||y(d)!==y(s))return;let u=y(i),l=e.get(u);(l===void 0||!ft(t[l])&&ft(r))&&e.set(u,o)}),[...e.values()].sort((r,o)=>r-o)}var lt=["CreatedDate","CreatedById","Opportunity.CreatedDate","Opportunity.CreatedById"];function xt(t,n=[]){let e=["Id","OpportunityId",Y],r=[...e,...lt];return`SELECT ${[...e,...lt,...n.filter(i=>!r.includes(i)).map(C)].join(", ")} FROM ${Ot} WHERE OpportunityId IN ${et(t)} ORDER BY CreatedDate, Id`}var bt=/^SELECT Id, OpportunityId, ContactId, CreatedDate, CreatedById, Opportunity\.CreatedDate, Opportunity\.CreatedById((?:, \w+)*) FROM OpportunityContactRole WHERE OpportunityId IN (\(.*\)) ORDER BY CreatedDate, Id$/;function On(t){let n=bt.exec(t);if(!n)return;let[,e,r]=n;return{fields:e.split(", ").filter(o=>o!==""),opportunities:rt(r)}}async function _t(t,n,e=[]){let r=[];for(let o=0;o<n.length;o+=S)r.push(...await t(xt(n.slice(o,o+S),e)));return r}var Ft=1,gt=t=>typeof t=="string"&&t!==""?Math.floor(Date.parse(t)/1e3):Number.NaN;function Wt(t){let n=t.Opportunity;if(typeof n!="object"||n===null)return!1;let e=n,r=w(t,"CreatedById"),o=w(e,"CreatedById"),i=gt(t.CreatedDate),s=gt(e.CreatedDate);return r!==void 0&&o!==void 0&&y(r)===y(o)&&!Number.isNaN(i)&&!Number.isNaN(s)&&i-s>=0&&i-s<=Ft}function Dt(t,n){let e=new Map;for(let i of n){let s=w(i,"Id"),d=w(i,"OpportunityId"),u=w(i,Y);if(!s||!d||!u||!Wt(i))continue;let l=`${y(d)}:${y(u)}`;e.set(l,[...e.get(l)??[],i])}let r=new Map,o=[];for(let[i,{opportunity:s,contact:d}]of t){let u=e.get(`${y(s)}:${y(d)}`)??[];u.length>1?o.push(i):u.length===1&&r.set(i,u[0])}return{found:r,alike:o}}function Tn(t,n="read"){return`${t} contact role(s) not linked to the one the platform wrote with their opportunity, so written as ${n}: the target holds more than one role of their contact under it made with it, within a second, by the same user, and nothing tells which the platform wrote. The opportunity holds the role of its contact more than once.`}var vt="the user the run writes as";function Sn(t,n){let e={CreatedDate:n,CreatedById:vt};return{...t,...e,Opportunity:{...e}}}async function En(t,n,e,r=[]){let o=Lt(n,e);if(o.length===0)return{found:new Map,alike:[]};let i=new Map(o.map(d=>[d,{opportunity:String(n[d].OpportunityId),contact:String(n[d][Y])}])),s=await _t(t,[...new Set([...i.values()].map(({opportunity:d})=>d))],r);return Dt(i,s)}function $n(t){return!t.has(v)||!t.has(M)?[]:[{sourceObject:v,targetObject:M,relationshipName:`${v}Before${M}`,type:"lookup",required:!0}]}var Ut={[v]:{TeamMemberRole:"Opportunity Owner",OpportunityAccessLevel:"All"},[M]:{}},pt=t=>!/__c$/i.test(t),qt=new Set(["SplitPercentage","SplitAmount","CurrencyIsoCode"]),U=`SELECT Id, OwnerId FROM ${Nt} WHERE Id IN `,Kt=`SELECT Id, DeveloperName, IsTotalValidated FROM ${Z} WHERE IsActive = true`,et=t=>`(${t.map(n=>`'${O(n)}'`).join(", ")})`,rt=t=>[...t.matchAll(/'([^']*)'/g)].map(([,n])=>n);function Cn(t){return`${U}${et(t)}`}function Pn(t){if(!t.startsWith(U))return;let n=t.slice(U.length);return/^\(.*\)$/.test(n)?rt(n):void 0}function Tt(t,n){let e=nt[t];return`SELECT ${["Id","OpportunityId",...t===M?[e,$]:[e],...n].join(", ")} FROM ${t} WHERE OpportunityId IN `}function kn(t,n,e){return`${Tt(t,n)}${et(e)}`}var Ht=/^SELECT Id, OpportunityId, (?:UserId|SplitOwnerId, SplitTypeId)((?:, \w+)*) FROM (OpportunityTeamMember|OpportunitySplit) WHERE OpportunityId IN (\(.*\))$/;function Mn(t){let n=Ht.exec(t);if(!n)return;let[,e,r,o]=n;return{objectApiName:r,fields:e.split(", ").filter(i=>i!==""),opportunities:rt(o)}}var y=t=>t.slice(0,15);async function W(t,n,e){let r=[];for(let o=0;o<e.length;o+=S){let i=e.slice(o,o+S).map(s=>`'${O(s)}'`).join(", ");r.push(...await t(`${n}(${i})`))}return r}function J(t,n){let e=new Map;for(let r of t){let o=r[n];typeof r.Id=="string"&&typeof o=="string"&&o!==""&&e.set(y(r.Id),o)}return e}var w=(t,n)=>{let e=t[n];return typeof e=="string"&&e!==""?e:void 0};async function An(t,n,e){let r={lookups:new Map,linked:new Map,held:new Map,defaulted:new Set},o=nt[t];if(o===void 0)return r;let i=t===M,s=n.filter(a=>{let f=w(a,"OpportunityId");return f!==void 0&&e.targetIdOf(f)!==void 0});if(s.length===0)return r;let d=[...new Set(s.map(a=>String(a.OpportunityId)))],u=J(await W(e.source,U,d),"OwnerId"),l=a=>e.targetIdOf(String(a.OpportunityId)),I=[...new Set(s.map(l))],{simulated:T}=e,x=T?void 0:J(await W(e.target,U,I),"OwnerId"),b=a=>{let f=u.get(y(String(a.OpportunityId)));return f===void 0?{}:{source:f,target:T?T.ownerOf(f):x?.get(y(l(a)))}},_=a=>{let f=w(a,o),R=b(a).source;return f!==void 0&&R!==void 0&&y(f)===y(R)},A=[...new Set(s.flatMap(a=>{let f=w(a,o);return f===void 0||_(a)||e.mappedUser(f)!==void 0?[]:[f]}))],q=A.length>0?new Set((await W(e.target,"SELECT Id FROM User WHERE IsActive = true AND Id IN ",A)).flatMap(a=>typeof a.Id=="string"?[y(a.Id)]:[])):new Set,K=i?J(await W(e.source,`SELECT Id, DeveloperName FROM ${Z} WHERE Id IN `,[...new Set(s.flatMap(a=>w(a,$)??[]))]),"DeveloperName"):new Map,F=new Map;if(i)for(let a of await e.target(Kt))typeof a.Id=="string"&&typeof a.DeveloperName=="string"&&F.set(a.DeveloperName,{id:a.Id,total:a.IsTotalValidated===!0||a.IsTotalValidated==="true"});let c=(e.written??[]).filter(a=>a!=="Id"&&a!=="OpportunityId"&&a!==o&&a!==$&&!qt.has(a)),g=(a,f)=>{let R=a[f];return!(R==null||R===""||R===!1)},p=(a,f,R=c)=>R.filter(P=>g(a,P)&&String(a[P])!==String(f[P]??"")),m=new Map,h=(a,f,R)=>[a,f,R??""].map(y).join("|");if(!T)for(let a of await W(e.target,Tt(t,c),I)){let f=w(a,"OpportunityId"),R=w(a,o);typeof a.Id!="string"||f===void 0||R===void 0||m.set(h(f,R,i?w(a,$):void 0),a)}for(let a of s){let f=w(a,o);if(f===void 0)continue;let R=_(a),P=b(a).target,N=R?P:e.mappedUser(f)??(q.has(y(f))?f:void 0),ot=!R&&N===void 0&&e.defaultUser!==void 0;if(ot&&(N=e.defaultUser),N===void 0){r.held.set(a,{field:o,parentObject:"User",why:R?`${o} names the owner of its opportunity, whose owner in the target could not be read.`:`${o} names a user the target has no counterpart of: a team member and a split go in for the opportunity's owner, which is the owner of its copy in the target, for a user an owner mapping gives, or for a user of the same id the target holds active.`});continue}let G={[o]:N},it=!1;if(i){let E=w(a,$);if(E!==void 0){let k=K.get(y(E)),V=k===void 0?void 0:F.get(k);if(V===void 0){r.held.set(a,{field:$,parentObject:Z,why:`${$} names ${k===void 0?"a split type":`the split type ${k}`}, which the target holds no active one of by that name: sent without it, the split would go in as one of the Revenue type.`});continue}G[$]=V.id,it=V.total}}let St=l(a),st=P!==void 0&&y(N)===y(P);if(T){if(st&&(!i||it)){let E=c.filter(k=>!pt(k)&&g(a,k));r.linked.set(a,{id:T.idFor(),owners:!0,notKept:p(a,Ut[t]??{},c.filter(pt)),...E.length>0?{unread:E}:{}});continue}}else{let E=m.get(h(St,N,G[$]));if(E!==void 0){r.linked.set(a,{id:String(E.Id),owners:st,notKept:p(a,E)});continue}}r.lookups.set(a,G),ot&&r.defaulted.add(a)}return r}var jt={[tt]:"TaskId",[B]:"EventId"};async function Nn(t,n,e){let r=new Map,o=jt[n];if(o===void 0)return r;let i=[...new Set(e.map(d=>d[o]).filter(d=>typeof d=="string"&&d!==""))];if(i.length===0)return r;let s=new Map;for(let d=0;d<i.length;d+=S){let u=i.slice(d,d+S).map(I=>`'${O(I)}'`).join(", "),l=await t(`SELECT Id, ${o}, RelationId FROM ${n} WHERE ${o} IN (${u})`);for(let I of l)typeof I.Id=="string"&&s.set(`${String(I[o])}|${String(I.RelationId)}`,I.Id)}return e.forEach((d,u)=>{let l=s.get(`${String(d[o])}|${String(d.RelationId)}`);l&&r.set(u,l)}),r}var Bt={[B]:["IsInvitee"]},yt={IsInvitee:["Status","Response","RespondedDate"]},Rt="the run was cancelled before it was updated";async function Ln(t,n,e,r,o=()=>!1){return Qt(await Yt(t,n,e,r,o))}function Qt(t){if(!(t===void 0||t.size===0))return[...t].map(([n,e])=>`${e} linked without ${n}`).join(", ")}function xn(t,n){if(n.size===0)return t;let e=new Map(t??[]);for(let[r,o]of n)e.set(r,(e.get(r)??0)+o);return e}async function Yt(t,n,e,r,o=()=>!1){let i=Bt[t]??[],s=new Set(i.flatMap(c=>[c,...yt[c]??[]]).filter(c=>!e(c))),d=new Map,u=(c,g)=>{let p=`${c}: ${g}`;d.set(p,(d.get(p)??0)+1)},l=[];for(let[c,g]of n){let p={},m={};for(let h of i.filter(a=>String(c[a])==="true")){if(s.has(h)){u(h,"the target does not let it be updated");continue}p[h]=!0;for(let a of yt[h]??[]){let f=c[a];f==null||f===""||(s.has(a)?u(a,"the target does not let it be updated"):m[a]=f)}}Object.keys(p).length>0&&l.push({Id:g,flagsGiven:p,answer:m})}let I=!1,T=async c=>{let g=new Map;if(c.length===0)return g;if(o()){for(let h of c)g.set(h.Id,Rt);return g}if(I)return g;let p=await r(c);I=p.length<c.length;let m=o();return c.forEach((h,a)=>{let f=p[a];f?.success||g.set(h.Id,f===void 0&&m?Rt:`the target refused the update, ${f?.errors[0]??"without saying why"}`)}),g},x=(c,g)=>{for(let p of c){let m=g.get(p.Id);if(m!==void 0)for(let h of Object.keys(p).filter(a=>a!=="Id"))u(h,m)}},b=l.map(({Id:c,flagsGiven:g,answer:p})=>({Id:c,...g,...p})),_=await T(b),A=I||o()?[]:l.filter(({Id:c,answer:g})=>_.has(c)&&Object.keys(g).length>0);x(b.filter(c=>!A.some(({Id:g})=>g===c.Id)),_);let q=A.map(({Id:c,flagsGiven:g})=>({Id:c,...g})),K=await T(q);x(q,K);let F=A.filter(({Id:c})=>!K.has(c));for(let c of new Set(F.flatMap(({answer:g})=>Object.keys(g)))){let g=F.filter(({answer:p})=>c in p).map(({Id:p,answer:m})=>({Id:p,[c]:m[c]}));x(g,await T(g))}return d}var bn={Order:"OrderStatus",Contract:"ContractStatus"},_n=new Set(["Contract"]);function Gt(t){return t==null||t===""?"null":typeof t=="number"||typeof t=="boolean"?String(t):`'${O(String(t))}'`}async function Fn(t,n){let e=new Map,r=[...new Set(n.map(i=>i.ContactId).filter(i=>typeof i=="string"&&i!==""))];if(r.length===0)return e;let o=new Map;for(let i=0;i<r.length;i+=j){let s=r.slice(i,i+j).map(u=>`'${O(u)}'`).join(", "),d=await t(`SELECT Id, AccountId, ContactId FROM ${It} WHERE IsDirect = true AND ContactId IN (${s})`);for(let u of d)typeof u.Id=="string"&&o.set(`${String(u.AccountId)}|${String(u.ContactId)}`,u.Id)}return n.forEach((i,s)=>{let d=o.get(`${String(i.AccountId)}|${String(i.ContactId)}`);d&&e.set(s,d)}),e}async function Wn(t,n){let e=new Set;for(let r=0;r<n.length;r+=j){let o=n.slice(r,r+j).map(s=>`'${O(s)}'`).join(", "),i=await t(`SELECT Id FROM PricebookEntry WHERE Id IN (${o}) AND Pricebook2.IsStandard = true`);for(let s of i)typeof s.Id=="string"&&e.add(s.Id)}return e}var wt=200;async function Dn(t,n){let e=new Map,r=[...new Set(n.map(i=>i.Product2Id).filter(i=>typeof i=="string"&&i!==""))];if(r.length===0)return e;let o=new Map;for(let i=0;i<r.length;i+=wt){let s=r.slice(i,i+wt).map(u=>`'${O(u)}'`).join(", "),d=await t(`SELECT Id, Product2Id, ProductSellingModelId FROM ${at} WHERE Product2Id IN (${s})`);for(let u of d)typeof u.Id=="string"&&o.set(`${String(u.Product2Id)}|${String(u.ProductSellingModelId)}`,u.Id)}return n.forEach((i,s)=>{let d=o.get(`${String(i.Product2Id)}|${String(i.ProductSellingModelId)}`);d&&e.set(s,d)}),e}async function vn(t,n,e,r){let o=new Map;for(let i of r){let s=JSON.stringify(e.map(l=>i[l]??null));if(o.has(s))continue;let d=e.map(l=>`${C(l)} = ${Gt(i[l])}`).join(" AND "),u=await t(`SELECT Id FROM ${C(n)} WHERE ${d} LIMIT 2`);o.set(s,u.length===1&&typeof u[0].Id=="string"?u[0].Id:void 0)}return r.map(i=>o.get(JSON.stringify(e.map(s=>i[s]??null))))}async function Un(t,n){let e;try{e=await t(`SELECT ApiName, StatusCode FROM ${C(n)}`)}catch{return}return{categoryOf:new Map(e.map(r=>[String(r.ApiName),String(r.StatusCode)])),draft:e.filter(r=>r.StatusCode==="Draft").map(r=>String(r.ApiName)).sort()[0]}}function qn(t,n){if(typeof t!="string"||t===""||!n.draft)return;let e=n.categoryOf.get(t);if(!(e===void 0||e==="Draft"))return n.draft}export{It as a,D as b,z as c,en as d,rn as e,ut as f,on as g,sn as h,an as i,dn as j,un as k,ht as l,cn as m,fn as n,ln as o,gn as p,L as q,H as r,Q as s,kt as t,pn as u,yn as v,Rn as w,Mt as x,wn as y,In as z,v as A,M as B,nt as C,hn as D,mn as E,Ot as F,Y as G,ft as H,Lt as I,xt as J,On as K,_t as L,Dt as M,Tn as N,Sn as O,En as P,$n as Q,Ut as R,Kt as S,Cn as T,Pn as U,kn as V,Mn as W,An as X,jt as Y,Nn as Z,Bt as _,Ln as $,Qt as aa,xn as ba,Yt as ca,bn as da,_n as ea,Fn as fa,Wn as ga,Dn as ha,vn as ia,Un as ja,qn as ka};
@@ -0,0 +1,8 @@
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{g as s}from"./chunk-2GSMHGIV.mjs";function d(e){return e.map(({objectApiName:t,why:o,count:i})=>({objectApiName:t,count:i,note:s(i,o)}))}var a=/^\d+\.\d+\.\d+$/,u=/^[0-9a-f]{12}$/,r=class extends Error{constructor(t){super(t),this.name="ManifestError"}};function l(e){let t=(e.now?.()??new Date).toISOString(),o={version:e.version,status:"frozen",frozenAt:t,source:e.source,saltFingerprint:e.saltFingerprint,rulesVersion:e.rulesVersion,volumetry:e.volumetry,controls:{nonReidentification:e.nonReidentification,dryRunLoad:null,author:e.author,date:t},...e.coverage?{coverage:e.coverage}:{}};return n(o),o}function n(e){if(!a.test(e.version))throw new r(`version must be semver, got ${JSON.stringify(e.version)}`);if(e.status!=="frozen")throw new r(`status must be "frozen", got ${JSON.stringify(e.status)}`);if(!e.frozenAt)throw new r("frozenAt is required");if(!e.source?.orgId||!e.source.decisionDate)throw new r("source.orgId and source.decisionDate are required");if(!u.test(e.saltFingerprint))throw new r("saltFingerprint must be 12 lowercase hex chars of the salt SHA-256");if(!a.test(e.rulesVersion))throw new r(`rulesVersion must be semver, got ${JSON.stringify(e.rulesVersion)}`);if(typeof e.volumetry?.budgetMax!="number"||!e.volumetry.measured)throw new r("volumetry.budgetMax and volumetry.measured are required");if(!e.controls?.nonReidentification)throw new r("controls.nonReidentification is required");if(!e.controls.author||!e.controls.date)throw new r("controls.author and controls.date are required");let t=e.coverage;if(t!==void 0&&(typeof t.objects!="number"||typeof t.truncated!="boolean"||typeof t.maxNodes!="number"||!Array.isArray(t.unboundedObjects)||!Array.isArray(t.filesLeftOut)||t.leftToThePlatform!==void 0&&!Array.isArray(t.leftToThePlatform)||t.exclusionCosts!==void 0&&!Array.isArray(t.exclusionCosts)||t.requiredLeftEmpty!==void 0&&!Array.isArray(t.requiredLeftEmpty)||t.keptWithoutARule!==void 0&&!Array.isArray(t.keptWithoutARule)||t.encryptedNotKept!==void 0&&!Array.isArray(t.encryptedNotKept)))throw new r("coverage, when present, needs objects, truncated, maxNodes, unboundedObjects and filesLeftOut, and a list of what it left to the platform, of what its exclusions cost, of the required fields the rules leave empty, of the fields kept without a rule, or of the encrypted fields not kept, if it names any")}function c(e){return n(e),`${JSON.stringify(e,null,2)}
8
+ `}function g(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new r("Manifest must be a JSON object");let t=e;return n(t),t}export{d as a,l as b,c,g as d};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a}from"./chunk-2UU42PTD.mjs";import"./chunk-BWWQXU2B.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-KIMQQ6JQ.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as readSyncRecordTypes};
7
+ import{a}from"./chunk-J3TIHLWG.mjs";import"./chunk-BWWQXU2B.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-2GSMHGIV.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as readSyncRecordTypes};
@@ -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{e as k,f as w}from"./chunk-Z42PHCVZ.mjs";import{g as A,k as S}from"./chunk-H4OBZIX3.mjs";import{Fb as T,Gb as h}from"./chunk-ZQO5PDX5.mjs";import{mkdir as v,rename as D,writeFile as x}from"node:fs/promises";import*as f from"node:path";var y="CaseId",O=80;function $(e){let t=T.safeParse(e.choice);if(!t.success)return{ok:!1,refusals:t.error.issues.map(a=>({code:"choice-invalid",name:a.path.join("."),message:a.message}))};let n=t.data,s=A(e.catalog,n.agent);if(!s)return{ok:!1,refusals:[{code:"agent-absent",name:n.agent,message:`"${n.agent}" is not one of this org's agents`}]};let r=P(n,s,E(e.compiled.tests));if(r.length>0)return{ok:!1,refusals:r};let i=new Map(n.topics.map(a=>[a.packTopic,a])),c=S(s,y)?y:void 0,g=[],o=[];for(let a of e.compiled.tests){if(a.topicKey===null){if(n.guardTopic===null){o.push({test:a.key,reason:"no-guard-topic",message:`"${a.utterance}" is on no topic of the scenario, and no topic of the agent is chosen to decline it: the test is left out`});continue}g.push({key:a.key,utterance:a.utterance,expectedTopic:n.guardTopic,expectedActions:[],expectedOutcome:a.expectedOutcome,contextVariables:[]});continue}let u=i.get(a.topicKey),p=[];if(a.openCase){let m=e.openCaseIds[a.openCase.caseKey];if(m===void 0){o.push({test:a.key,reason:"case-not-written",message:`The case ${a.openCase.caseKey} the test is about was not written by the run: the test is left out`});continue}c!==void 0&&p.push({name:c,value:m})}g.push({key:a.key,utterance:a.utterance,expectedTopic:u.agentTopic,expectedActions:[...u.actions],expectedOutcome:j(a),contextVariables:p})}return g.length===0?{ok:!1,refusals:[{code:"no-test-left",name:e.compiled.packId,message:"No test of the scenario is left to write: "+o.map(a=>a.message).join("; ")}]}:{ok:!0,spec:{name:M(e.compiled.template.name),description:F(e.compiled.packId,e.compiled.seed,e.runId),subjectName:s.name,testCases:g},choice:n,leftOut:o,...c!==void 0?{contextVariable:c}:{}}}function E(e){return[...new Set(e.flatMap(t=>t.topicKey===null?[]:[t.topicKey]))]}function P(e,t,n){let s=[],r=new Map(t.topics.map(o=>[o.name,o])),i=new Set(t.topics.flatMap(o=>o.actions.map(a=>a.name))),c=o=>({code:"topic-absent",name:o,message:`"${o}" is not a topic of the agent ${t.name}`});for(let o of e.topics){n.includes(o.packTopic)||s.push({code:"pack-topic-unknown",name:o.packTopic,message:`"${o.packTopic}" is not a topic of the scenario`});let a=r.get(o.agentTopic);if(!a){s.push(c(o.agentTopic));continue}let u=new Set(a.actions.map(p=>p.name));for(let p of o.actions)u.has(p)||s.push(i.has(p)?{code:"action-not-of-topic",name:p,message:`"${p}" is not an action of the topic ${a.name}, which the agent answers "${o.packTopic}" from`}:{code:"action-absent",name:p,message:`"${p}" is not an action of the agent ${t.name}`})}let g=new Set(e.topics.map(o=>o.packTopic));for(let o of n)g.has(o)||s.push({code:"pack-topic-unmatched",name:o,message:`The topic "${o}" of the scenario is matched to no topic of the agent`});return e.guardTopic!==null&&!r.has(e.guardTopic)&&s.push(c(e.guardTopic)),s}function j(e){if(!e.article)return e.expectedOutcome;let t=e.article.facts.length>0?`, which states: ${e.article.facts.join("; ")}`:"";return`${e.expectedOutcome} The answer draws on the article "${e.article.title}"${t}.`}function M(e){let t=" (SandForge)",n=O-t.length;return`${e.length>n?e.slice(0,n).trimEnd():e}${t}`}function F(e,t,n){let s=n!==void 0?`, written by the seed run ${n}`:"";return`SandForge scenario ${e}, seed ${t}${s}. Its cases are about the records that run wrote: once it is removed, they are about none.`}var C="specs",L=80,V=10;function K(e,t){return G(h(e,t))}function W(e,t,n){let s=n==="agentforce-studio"?"ngtTestSpec":"testSpec";return`${b(e)}-${b(t)}-sandforge-${s}.yaml`}function z(e,t){let n=c=>c.replace(/[^A-Za-z0-9]+/g,"_").replace(/^_+|_+$/g,""),s=`${n(t)}_SandForge`,r=n(e);/^[A-Za-z]/.test(r)||(r=`Agent_${r}`.replace(/_+$/,""));let i=L-s.length-1;return r=r.slice(0,i).replace(/_+$/,""),`${r}_${s}`}function Z(e){let t=e.runner==="agentforce-studio"?["--test-runner","agentforce-studio"]:[],n=["sf","agent","test","create","--spec",e.specPath,"--api-name",e.apiName,...t,"-o",e.alias],s=["sf","agent","test","run","--api-name",e.apiName,"--wait",String(V),...t,"-o",e.alias];return{create:{argv:n,line:R(n)},run:{argv:s,line:R(s)}}}function te(){return{mkdir:async e=>{await v(e,{recursive:!0})},writeNew:async(e,t)=>{try{return await x(e,t,{encoding:"utf8",flag:"wx"}),!0}catch(n){if(n.code==="EEXIST")return!1;throw n}},replace:async(e,t)=>{let n=`${e}.${process.pid}.tmp`;await x(n,t,"utf8"),await D(n,e)}}}async function X(e,t){let n=W(t.model.subjectName,t.packId,t.runner),s=`${C}/${n}`,r=f.join(t.projectDir,C,n),i=K(t.model,t.runner);if(await e.mkdir(f.dirname(r)),t.overwrite===!0)await e.replace(r,i);else if(!await e.writeNew(r,i))return{kind:"exists",path:r,specPath:s};let c=z(t.model.subjectName,t.packId);return{kind:"written",path:r,specPath:s,apiName:c,commands:Z({specPath:s,apiName:c,alias:t.alias,runner:t.runner})}}async function ne(e,t){let n=w(t.sidecar,t.pack);if(!n.ok)return{kind:"refused",refusals:[{code:"pack-changed",name:t.pack.id,message:n.message}]};let s=$({compiled:n.compiled,catalog:t.catalog,choice:t.choice,openCaseIds:t.sidecar.openCases,runId:t.sidecar.runId});if(!s.ok)return{kind:"refused",refusals:s.refusals};let{choice:r}=s,i=await X(e,{projectDir:t.projectDir,model:s.spec,runner:r.runner,packId:t.pack.id,alias:t.alias,...t.overwrite!==void 0?{overwrite:t.overwrite}:{}});return i.kind==="exists"?i:{...i,leftOut:s.leftOut,sidecar:k(t.sidecar,r)}}function G(e){return`${l(e,0).join(`
7
+ import{e as k,f as w}from"./chunk-27BBEGUD.mjs";import{g as A,k as S}from"./chunk-H4OBZIX3.mjs";import{Sb as T,Tb as h}from"./chunk-6QSHWIZI.mjs";import{mkdir as v,rename as D,writeFile as x}from"node:fs/promises";import*as f from"node:path";var y="CaseId",O=80;function $(e){let t=T.safeParse(e.choice);if(!t.success)return{ok:!1,refusals:t.error.issues.map(a=>({code:"choice-invalid",name:a.path.join("."),message:a.message}))};let n=t.data,s=A(e.catalog,n.agent);if(!s)return{ok:!1,refusals:[{code:"agent-absent",name:n.agent,message:`"${n.agent}" is not one of this org's agents`}]};let r=P(n,s,E(e.compiled.tests));if(r.length>0)return{ok:!1,refusals:r};let i=new Map(n.topics.map(a=>[a.packTopic,a])),c=S(s,y)?y:void 0,g=[],o=[];for(let a of e.compiled.tests){if(a.topicKey===null){if(n.guardTopic===null){o.push({test:a.key,reason:"no-guard-topic",message:`"${a.utterance}" is on no topic of the scenario, and no topic of the agent is chosen to decline it: the test is left out`});continue}g.push({key:a.key,utterance:a.utterance,expectedTopic:n.guardTopic,expectedActions:[],expectedOutcome:a.expectedOutcome,contextVariables:[]});continue}let u=i.get(a.topicKey),p=[];if(a.openCase){let m=e.openCaseIds[a.openCase.caseKey];if(m===void 0){o.push({test:a.key,reason:"case-not-written",message:`The case ${a.openCase.caseKey} the test is about was not written by the run: the test is left out`});continue}c!==void 0&&p.push({name:c,value:m})}g.push({key:a.key,utterance:a.utterance,expectedTopic:u.agentTopic,expectedActions:[...u.actions],expectedOutcome:j(a),contextVariables:p})}return g.length===0?{ok:!1,refusals:[{code:"no-test-left",name:e.compiled.packId,message:"No test of the scenario is left to write: "+o.map(a=>a.message).join("; ")}]}:{ok:!0,spec:{name:M(e.compiled.template.name),description:F(e.compiled.packId,e.compiled.seed,e.runId),subjectName:s.name,testCases:g},choice:n,leftOut:o,...c!==void 0?{contextVariable:c}:{}}}function E(e){return[...new Set(e.flatMap(t=>t.topicKey===null?[]:[t.topicKey]))]}function P(e,t,n){let s=[],r=new Map(t.topics.map(o=>[o.name,o])),i=new Set(t.topics.flatMap(o=>o.actions.map(a=>a.name))),c=o=>({code:"topic-absent",name:o,message:`"${o}" is not a topic of the agent ${t.name}`});for(let o of e.topics){n.includes(o.packTopic)||s.push({code:"pack-topic-unknown",name:o.packTopic,message:`"${o.packTopic}" is not a topic of the scenario`});let a=r.get(o.agentTopic);if(!a){s.push(c(o.agentTopic));continue}let u=new Set(a.actions.map(p=>p.name));for(let p of o.actions)u.has(p)||s.push(i.has(p)?{code:"action-not-of-topic",name:p,message:`"${p}" is not an action of the topic ${a.name}, which the agent answers "${o.packTopic}" from`}:{code:"action-absent",name:p,message:`"${p}" is not an action of the agent ${t.name}`})}let g=new Set(e.topics.map(o=>o.packTopic));for(let o of n)g.has(o)||s.push({code:"pack-topic-unmatched",name:o,message:`The topic "${o}" of the scenario is matched to no topic of the agent`});return e.guardTopic!==null&&!r.has(e.guardTopic)&&s.push(c(e.guardTopic)),s}function j(e){if(!e.article)return e.expectedOutcome;let t=e.article.facts.length>0?`, which states: ${e.article.facts.join("; ")}`:"";return`${e.expectedOutcome} The answer draws on the article "${e.article.title}"${t}.`}function M(e){let t=" (SandForge)",n=O-t.length;return`${e.length>n?e.slice(0,n).trimEnd():e}${t}`}function F(e,t,n){let s=n!==void 0?`, written by the seed run ${n}`:"";return`SandForge scenario ${e}, seed ${t}${s}. Its cases are about the records that run wrote: once it is removed, they are about none.`}var C="specs",L=80,V=10;function K(e,t){return G(h(e,t))}function W(e,t,n){let s=n==="agentforce-studio"?"ngtTestSpec":"testSpec";return`${b(e)}-${b(t)}-sandforge-${s}.yaml`}function z(e,t){let n=c=>c.replace(/[^A-Za-z0-9]+/g,"_").replace(/^_+|_+$/g,""),s=`${n(t)}_SandForge`,r=n(e);/^[A-Za-z]/.test(r)||(r=`Agent_${r}`.replace(/_+$/,""));let i=L-s.length-1;return r=r.slice(0,i).replace(/_+$/,""),`${r}_${s}`}function Z(e){let t=e.runner==="agentforce-studio"?["--test-runner","agentforce-studio"]:[],n=["sf","agent","test","create","--spec",e.specPath,"--api-name",e.apiName,...t,"-o",e.alias],s=["sf","agent","test","run","--api-name",e.apiName,"--wait",String(V),...t,"-o",e.alias];return{create:{argv:n,line:R(n)},run:{argv:s,line:R(s)}}}function te(){return{mkdir:async e=>{await v(e,{recursive:!0})},writeNew:async(e,t)=>{try{return await x(e,t,{encoding:"utf8",flag:"wx"}),!0}catch(n){if(n.code==="EEXIST")return!1;throw n}},replace:async(e,t)=>{let n=`${e}.${process.pid}.tmp`;await x(n,t,"utf8"),await D(n,e)}}}async function X(e,t){let n=W(t.model.subjectName,t.packId,t.runner),s=`${C}/${n}`,r=f.join(t.projectDir,C,n),i=K(t.model,t.runner);if(await e.mkdir(f.dirname(r)),t.overwrite===!0)await e.replace(r,i);else if(!await e.writeNew(r,i))return{kind:"exists",path:r,specPath:s};let c=z(t.model.subjectName,t.packId);return{kind:"written",path:r,specPath:s,apiName:c,commands:Z({specPath:s,apiName:c,alias:t.alias,runner:t.runner})}}async function ne(e,t){let n=w(t.sidecar,t.pack);if(!n.ok)return{kind:"refused",refusals:[{code:"pack-changed",name:t.pack.id,message:n.message}]};let s=$({compiled:n.compiled,catalog:t.catalog,choice:t.choice,openCaseIds:t.sidecar.openCases,runId:t.sidecar.runId});if(!s.ok)return{kind:"refused",refusals:s.refusals};let{choice:r}=s,i=await X(e,{projectDir:t.projectDir,model:s.spec,runner:r.runner,packId:t.pack.id,alias:t.alias,...t.overwrite!==void 0?{overwrite:t.overwrite}:{}});return i.kind==="exists"?i:{...i,leftOut:s.leftOut,sidecar:k(t.sidecar,r)}}function G(e){return`${l(e,0).join(`
8
8
  `)}
9
9
  `}function l(e,t){let n=" ".repeat(t),s=[];for(let[r,i]of Object.entries(e)){if(i===void 0)continue;let c=`${n}${J(r)}:`;Array.isArray(i)?i.length===0?s.push(`${c} []`):s.push(c,...I(i,t+2)):d(i)?Object.values(i).every(g=>g===void 0)?s.push(`${c} {}`):s.push(c,...l(i,t+2)):s.push(`${c} ${_(i)}`)}return s}function I(e,t){let n=" ".repeat(t),s=[];for(let r of e){let i=Array.isArray(r)?r.length===0?void 0:I(r,t+2):d(r)&&Object.values(r).some(c=>c!==void 0)?l(r,t+2):void 0;if(i===void 0){s.push(`${n}- ${Array.isArray(r)?"[]":d(r)?"{}":_(r)}`);continue}s.push(`${n}- ${i[0].slice(t+2)}`,...i.slice(1))}return s}function d(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function J(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)?e:N(e)}function _(e){if(typeof e=="string")return N(e);if(typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e))return String(e);if(e===null)return"null";throw new TypeError(`No YAML scalar for ${typeof e}`)}function N(e){return JSON.stringify(e).replace(/[\u007f-\u009f\u2028\u2029\ufeff\ufffe\uffff]/g,t=>`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`)}function b(e){return e.replace(/[^A-Za-z0-9_-]/g,"_")}function R(e){return e.map(t=>/^[A-Za-z0-9_./:@=+,-]+$/.test(t)?t:`"${t.replace(/(["\\])/g,"\\$1")}"`).join(" ")}export{C as a,V as b,K as c,W as d,z as e,Z as f,te as g,X as h,ne as i,G as j};
@@ -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{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-3SKLBRPL.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{g as IDS_PER_LINE,m as OverwritesRead,h as PIPELINE_NAME_KEPT,e as SCENARIO_COMPANION_SUFFIX,d as SYNC_FILE_OBJECTS,a as SYNC_RUNS_DIR,c as SYNC_RUNS_HARD_MAX_BYTES,b as SYNC_RUNS_MAX_BYTES,x as SyncRunCreations,i as backupIdSchema,u as configTargetOf,o as createdCount,r as deletedCount,v as earlierRunsOf,f as nodeSyncRunCreations,p as overwrittenCount,j as readRemovalState,l as readRunFile,t as settled,n as syncRemovalPlan,q as syncRestorePlan,k as syncRunFileId,s as syncUndeletePlan,w as writtenAgainBy};
7
+ import{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-BT43WSOS.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{g as IDS_PER_LINE,m as OverwritesRead,h as PIPELINE_NAME_KEPT,e as SCENARIO_COMPANION_SUFFIX,d as SYNC_FILE_OBJECTS,a as SYNC_RUNS_DIR,c as SYNC_RUNS_HARD_MAX_BYTES,b as SYNC_RUNS_MAX_BYTES,x as SyncRunCreations,i as backupIdSchema,u as configTargetOf,o as createdCount,r as deletedCount,v as earlierRunsOf,f as nodeSyncRunCreations,p as overwrittenCount,j as readRemovalState,l as readRunFile,t as settled,n as syncRemovalPlan,q as syncRestorePlan,k as syncRunFileId,s as syncUndeletePlan,w as writtenAgainBy};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{g as m,h as S,i as E,j as x}from"./chunk-L4INJ5TZ.mjs";import{b as C}from"./chunk-CA5NAXSU.mjs";import{le as T,z as R}from"./chunk-ZQO5PDX5.mjs";import{statfs as q}from"node:fs/promises";var re=["reads","leasePlan","stillRunning","deliverabilityRead","question","checkpointTake","leaseAcquire","afterLeaseCheck","write","leaseRelease","recordTypeReadBack","result"];function ie(e){let t=[],n=s=>e.indexOf(s),r=s=>e.lastIndexOf(s),o=(s,c,d,p=r(s),l=n(c))=>{p>=0&&l>=0&&p>l&&t.push(d)};o("leasePlan","stillRunning","what still runs was computed before the lease was planned"),o("stillRunning","deliverabilityRead","the deliverability was read before what still runs was known"),o("deliverabilityRead","question","the deliverability was read after the question it belongs to",n("deliverabilityRead")),o("question","checkpointTake","the checkpoint was taken before the last question"),o("question","leaseAcquire","the lease was taken before the last question"),o("checkpointTake","leaseAcquire","the lease was taken before the checkpoint"),o("leaseAcquire","afterLeaseCheck","the lease was checked before it was taken"),o("checkpointTake","write","a record was written before the checkpoint was taken"),o("leaseAcquire","write","a record was written before the lease was taken"),o("afterLeaseCheck","write","a record was written before the lease was checked"),o("write","leaseRelease","the lease was given back before the last write"),o("write","recordTypeReadBack","the record types were read back before the last write"),o("leaseRelease","recordTypeReadBack","the record types were read back while the lease was held"),n("leaseAcquire")>=0&&n("leaseRelease")<0&&t.push("the lease was never given back");let i=n("result");return i>=0&&e.slice(i+1).some(s=>s!=="result")&&t.push("the run went on past its result"),t}var W={insert:"go in",update:"are updated",delete:"are deleted",undelete:"come back"},L={flow:"flow",process:"process",workflowRule:"workflow rule",trigger:"Apex trigger"},h=3,v=/__e$/i;function u(e){return e.toLowerCase()}function A(e){let t=new Set,n=[];for(let r of e)t.has(u(r))||(t.add(u(r)),n.push(r));return n}function F(e){let t=e.slice(0,h),n=e.length-t.length,r=`${t.join("; ")}${n>0?`; and ${n} more`:""}`;return`${r.charAt(0).toUpperCase()}${r.slice(1)}.`}function I(e){let t=A(e.written),n=new Set(t.map(u)),r=new Map;for(let i of e.running.firing)if(i.flow!==void 0)for(let s of i.flow.creates??[]){let c=u(s);if(n.has(c)||v.test(s))continue;let d=r.get(c);d===void 0&&(d={objectApiName:s,clauses:[],by:[]},r.set(c,d));let p=`the target's ${L[i.kind]} '${i.name}' creates ${s} records as ${i.objectApiName} records ${W[i.write]}`;d.clauses.includes(p)||(d.clauses.push(p),d.by.push({kind:i.kind,name:i.name,objectApiName:i.objectApiName,write:i.write}))}let o=[...r.values()].map(({objectApiName:i,clauses:s,by:c})=>({objectApiName:i,code:"createdByAutomation",reason:F(s),creators:c.slice(0,h),...c.length>h?{moreCreators:c.length-h}:{}}));return{written:t,added:o,excluded:A(e.request.excluded??[]),picked:[...t,...o.map(({objectApiName:i})=>i)]}}var M={[u(m)]:{code:"files",reason:"Files, which every checkpoint of picked objects holds: a rewind deletes the files added since to the records it holds."},[u(x)]:{code:"attachments",reason:"Attachments, which every checkpoint of picked objects holds: a rewind deletes the attachments added since."}},K="Held as every checkpoint of picked objects holds it.",U={[u("AccountContactRelation")]:"Account contact relations, which the platform writes with each contact: a rewind deletes those made since with their contacts, and keeps no contact for them."},J=new Set([E,S].map(u)),z="A rewind leaves its records as they are.",k="No record was read.";function w(e,t,n){let r=new Map(t.map(a=>[u(a),a])),o=r.has(u(m)),i=a=>r.has(u(a))||o&&J.has(u(a)),s=[],c=a=>{let f=r.get(u(a));f!==void 0&&!s.includes(f)&&s.push(f)};for(let a of e.written)c(a);for(let{objectApiName:a}of e.added)c(a);for(let a of t)c(a);let d=new Set(e.picked.map(u)),p=[...e.added.flatMap(a=>{let f=r.get(u(a.objectApiName));return f===void 0?[]:[{...a,objectApiName:f}]}),...t.filter(a=>!d.has(u(a))).map(a=>({objectApiName:a,...M[u(a)]??{code:"heldUnasked",reason:U[u(a)]??K}}))],l=n.filter(({objectApiName:a})=>!i(a)).map(({objectApiName:a,reason:f,code:b,detail:y,records:O,limit:B})=>({objectApiName:a,...b!==void 0?{code:b}:{},reason:`${f} ${z}`,...y!==void 0?{detail:y}:{},...O!==void 0?{records:O}:{},...B!==void 0?{limit:B}:{}})),H=new Map(n.map(({objectApiName:a,reason:f})=>[u(a),f]));return{objects:s,added:p,notHeld:l,holds:i,why:a=>H.get(u(a))}}function g(e,t,n){return e.written.some(o=>t.holds(o))?void 0:e.written.length===0?{code:"NOTHING_HELD",message:`The run names no object it writes: a checkpoint before it would hold nothing a rewind could take back. ${n}`}:{code:"NOTHING_HELD",message:`The checkpoint before the run would hold none of the objects the run writes, so a rewind to it could take nothing of the run back. ${e.written.map(o=>`${o}: ${t.why(o)??"The take did not hold it."}`).join(" ")} ${n}`}}function G(e,t,n){let r={state:"planned",estimate:t.estimate,keepDays:n};if(t.objects.length===0&&t.leftOut.length===0&&t.refusal!==void 0)return{...r,objects:[],added:[],notHeld:[],refusal:t.refusal};let o=w(e,t.objects.map(({objectApiName:s})=>s),t.leftOut),i=g(e,o,k)??t.refusal;return{...r,objects:o.objects,added:o.added,notHeld:o.notHeld,...i!==void 0?{refusal:i}:{}}}var V=1.1;function N(e){return`${(e/(1024*1024)).toFixed(1)} MB`}function P(e,t){if(!(t===void 0||t>=Math.ceil(e*V)))return{code:"DISK",message:`The checkpoint before the run takes about ${N(e)} on this machine, and its disk has ${N(t)} free, less than that and a tenth more: make room, or leave objects out of the checkpoint. ${k}`}}async function _(e){try{let t=await q(e);return Number(t.bavail)*Number(t.bsize)}catch{return}}var Y={forge:"Forge run",sync:"Sync run",seed:"Seed run",autopilot:"Autopilot run",frozen:"Frozen Dataset load",empty:"emptying",replay:"checkpoint replay"};function Q(e){return`Before ${Y[e]} ${T}`}function se(e,t){let{min:n,max:r}=R,o=i=>typeof i=="number"&&Number.isInteger(i)&&i>=n&&i<=r;if(e!==void 0){if(!o(e))throw new RangeError(`Not a number of days to keep a checkpoint, ${n} to ${r}: ${e}`);return e}return o(t)?t:R.default}function X(e,t){return{mode:"picked",objects:e.picked,...e.excluded.length>0?{excluded:e.excluded}:{},nameWithDate:Q(t.module),keepDays:t.keepDays,unprovenLeftOut:!0,beforeRun:{module:t.module,operationId:t.operationId,tool:t.tool}}}function j(e,t){let{checkpoint:n}=t,r=w(e,n.objects.map(({objectApiName:o})=>o),n.scope.leftOut);return{state:"taken",checkpointId:n.checkpointId,name:n.name,takenAt:n.takenAt,expiresAt:n.expiresAt,objects:r.objects,records:n.objects.reduce((o,i)=>o+i.records,0),bytes:n.bytes,requests:t.requests?.total??t.estimate.apiRequests,added:r.added,notHeld:r.notHeld}}function D(e){return`${e.operation==="take"?"a checkpoint is being taken":e.operation==="rewind"?"a rewind is writing":e.operation==="undo"?"an undo is writing":e.operation==="empty"?"an emptying of its objects is writing":"SandForge is deleting checkpoints"} (process ${e.pid} on ${e.host})`}async function Z(e,t,n){let r=w(t,n.checkpoint.objects.map(({objectApiName:c})=>c),n.checkpoint.scope.leftOut);if(g(t,r,"")===void 0)return{taken:!0,checkpoint:j(t,n)};let o=await e.delete(n.checkpoint.checkpointId),i=o.outcome==="busy"?`It is kept all the same, as ${D(o.holder)}: delete it from the Checkpoints page once that has ended. Nothing was written.`:"It was deleted again; nothing was written.",s=g(t,r,i);return s===void 0?{taken:!0,checkpoint:j(t,n)}:{taken:!1,refusal:s}}function $(e,t,n){return{...e,...X(t,n)}}async function ae(e,t,n){let{scopeCheckpoint:r}=await import("./chunk-FZF23M6R.mjs"),o=I(n),i=await r(e,$(t,o,n)),s=G(o,i,n.keepDays);if(s.refusal!==void 0)return s;let c=P(s.estimate.bytes,await(e.freeBytes??_)(e.store.root));return c===void 0?s:{...s,refusal:c}}async function ce(e,t,n,r){let o=await import("./chunk-FZF23M6R.mjs"),i=I(n);if(r!==void 0){let c=P(r.estimate.bytes,await(e.freeBytes??_)(e.store.root));if(c!==void 0)return{taken:!1,refusal:c}}let s;try{s=await o.takeCheckpoint(e,$(t,i,n))}catch(c){if(c instanceof o.CheckpointTakeStopped)return{taken:!1,stopped:!0};throw c}return s.taken?Z(e.store,i,s):{taken:!1,refusal:s.refusal}}async function ue(e,t,n){if(n)return{info:t};let r=await e.delete(t.checkpointId);return r.outcome==="busy"?{info:t,notDeleted:`The checkpoint '${t.name}' taken before the run is kept, though the run wrote nothing: ${D(r.holder)}. Delete it from the Checkpoints page once that has ended.`}:{info:{state:"deleted",deleted:"nothingWritten"}}}function de(e){return`The checkpoint before the run was refused: ${e.message.endsWith(k)?e.message.slice(0,-k.length).trimEnd():e.message} Nothing was written. Untick Checkpoint first to run without it, or fix what refuses it.`}function fe(e){return`The checkpoint before the run could not be taken: ${C(e).replace(/\.$/,"")}. Nothing was written.`}var pe="The checkpoint taken before the run was deleted: the run wrote nothing.";function le(e){return`Taking the checkpoint first (${Math.round(e)}%)`}export{re as a,ie as b,I as c,G as d,V as e,P as f,_ as g,Q as h,se as i,X as j,j as k,Z as l,ae as m,ce as n,ue as o,de as p,fe as q,pe as r,le as s};
7
+ import{g as m,h as S,i as E,j as x}from"./chunk-Z3MGN42K.mjs";import{b as C}from"./chunk-CA5NAXSU.mjs";import{ye as T,z as R}from"./chunk-6QSHWIZI.mjs";import{statfs as q}from"node:fs/promises";var re=["reads","leasePlan","stillRunning","deliverabilityRead","question","checkpointTake","leaseAcquire","afterLeaseCheck","write","leaseRelease","recordTypeReadBack","result"];function ie(e){let t=[],n=s=>e.indexOf(s),r=s=>e.lastIndexOf(s),o=(s,c,d,p=r(s),l=n(c))=>{p>=0&&l>=0&&p>l&&t.push(d)};o("leasePlan","stillRunning","what still runs was computed before the lease was planned"),o("stillRunning","deliverabilityRead","the deliverability was read before what still runs was known"),o("deliverabilityRead","question","the deliverability was read after the question it belongs to",n("deliverabilityRead")),o("question","checkpointTake","the checkpoint was taken before the last question"),o("question","leaseAcquire","the lease was taken before the last question"),o("checkpointTake","leaseAcquire","the lease was taken before the checkpoint"),o("leaseAcquire","afterLeaseCheck","the lease was checked before it was taken"),o("checkpointTake","write","a record was written before the checkpoint was taken"),o("leaseAcquire","write","a record was written before the lease was taken"),o("afterLeaseCheck","write","a record was written before the lease was checked"),o("write","leaseRelease","the lease was given back before the last write"),o("write","recordTypeReadBack","the record types were read back before the last write"),o("leaseRelease","recordTypeReadBack","the record types were read back while the lease was held"),n("leaseAcquire")>=0&&n("leaseRelease")<0&&t.push("the lease was never given back");let i=n("result");return i>=0&&e.slice(i+1).some(s=>s!=="result")&&t.push("the run went on past its result"),t}var W={insert:"go in",update:"are updated",delete:"are deleted",undelete:"come back"},L={flow:"flow",process:"process",workflowRule:"workflow rule",trigger:"Apex trigger"},h=3,v=/__e$/i;function u(e){return e.toLowerCase()}function A(e){let t=new Set,n=[];for(let r of e)t.has(u(r))||(t.add(u(r)),n.push(r));return n}function F(e){let t=e.slice(0,h),n=e.length-t.length,r=`${t.join("; ")}${n>0?`; and ${n} more`:""}`;return`${r.charAt(0).toUpperCase()}${r.slice(1)}.`}function I(e){let t=A(e.written),n=new Set(t.map(u)),r=new Map;for(let i of e.running.firing)if(i.flow!==void 0)for(let s of i.flow.creates??[]){let c=u(s);if(n.has(c)||v.test(s))continue;let d=r.get(c);d===void 0&&(d={objectApiName:s,clauses:[],by:[]},r.set(c,d));let p=`the target's ${L[i.kind]} '${i.name}' creates ${s} records as ${i.objectApiName} records ${W[i.write]}`;d.clauses.includes(p)||(d.clauses.push(p),d.by.push({kind:i.kind,name:i.name,objectApiName:i.objectApiName,write:i.write}))}let o=[...r.values()].map(({objectApiName:i,clauses:s,by:c})=>({objectApiName:i,code:"createdByAutomation",reason:F(s),creators:c.slice(0,h),...c.length>h?{moreCreators:c.length-h}:{}}));return{written:t,added:o,excluded:A(e.request.excluded??[]),picked:[...t,...o.map(({objectApiName:i})=>i)]}}var M={[u(m)]:{code:"files",reason:"Files, which every checkpoint of picked objects holds: a rewind deletes the files added since to the records it holds."},[u(x)]:{code:"attachments",reason:"Attachments, which every checkpoint of picked objects holds: a rewind deletes the attachments added since."}},K="Held as every checkpoint of picked objects holds it.",U={[u("AccountContactRelation")]:"Account contact relations, which the platform writes with each contact: a rewind deletes those made since with their contacts, and keeps no contact for them."},J=new Set([E,S].map(u)),z="A rewind leaves its records as they are.",k="No record was read.";function w(e,t,n){let r=new Map(t.map(a=>[u(a),a])),o=r.has(u(m)),i=a=>r.has(u(a))||o&&J.has(u(a)),s=[],c=a=>{let f=r.get(u(a));f!==void 0&&!s.includes(f)&&s.push(f)};for(let a of e.written)c(a);for(let{objectApiName:a}of e.added)c(a);for(let a of t)c(a);let d=new Set(e.picked.map(u)),p=[...e.added.flatMap(a=>{let f=r.get(u(a.objectApiName));return f===void 0?[]:[{...a,objectApiName:f}]}),...t.filter(a=>!d.has(u(a))).map(a=>({objectApiName:a,...M[u(a)]??{code:"heldUnasked",reason:U[u(a)]??K}}))],l=n.filter(({objectApiName:a})=>!i(a)).map(({objectApiName:a,reason:f,code:b,detail:y,records:O,limit:B})=>({objectApiName:a,...b!==void 0?{code:b}:{},reason:`${f} ${z}`,...y!==void 0?{detail:y}:{},...O!==void 0?{records:O}:{},...B!==void 0?{limit:B}:{}})),H=new Map(n.map(({objectApiName:a,reason:f})=>[u(a),f]));return{objects:s,added:p,notHeld:l,holds:i,why:a=>H.get(u(a))}}function g(e,t,n){return e.written.some(o=>t.holds(o))?void 0:e.written.length===0?{code:"NOTHING_HELD",message:`The run names no object it writes: a checkpoint before it would hold nothing a rewind could take back. ${n}`}:{code:"NOTHING_HELD",message:`The checkpoint before the run would hold none of the objects the run writes, so a rewind to it could take nothing of the run back. ${e.written.map(o=>`${o}: ${t.why(o)??"The take did not hold it."}`).join(" ")} ${n}`}}function G(e,t,n){let r={state:"planned",estimate:t.estimate,keepDays:n};if(t.objects.length===0&&t.leftOut.length===0&&t.refusal!==void 0)return{...r,objects:[],added:[],notHeld:[],refusal:t.refusal};let o=w(e,t.objects.map(({objectApiName:s})=>s),t.leftOut),i=g(e,o,k)??t.refusal;return{...r,objects:o.objects,added:o.added,notHeld:o.notHeld,...i!==void 0?{refusal:i}:{}}}var V=1.1;function N(e){return`${(e/(1024*1024)).toFixed(1)} MB`}function P(e,t){if(!(t===void 0||t>=Math.ceil(e*V)))return{code:"DISK",message:`The checkpoint before the run takes about ${N(e)} on this machine, and its disk has ${N(t)} free, less than that and a tenth more: make room, or leave objects out of the checkpoint. ${k}`}}async function _(e){try{let t=await q(e);return Number(t.bavail)*Number(t.bsize)}catch{return}}var Y={forge:"Forge run",sync:"Sync run",seed:"Seed run",autopilot:"Autopilot run",frozen:"Frozen Dataset load",empty:"emptying",replay:"checkpoint replay"};function Q(e){return`Before ${Y[e]} ${T}`}function se(e,t){let{min:n,max:r}=R,o=i=>typeof i=="number"&&Number.isInteger(i)&&i>=n&&i<=r;if(e!==void 0){if(!o(e))throw new RangeError(`Not a number of days to keep a checkpoint, ${n} to ${r}: ${e}`);return e}return o(t)?t:R.default}function X(e,t){return{mode:"picked",objects:e.picked,...e.excluded.length>0?{excluded:e.excluded}:{},nameWithDate:Q(t.module),keepDays:t.keepDays,unprovenLeftOut:!0,beforeRun:{module:t.module,operationId:t.operationId,tool:t.tool}}}function j(e,t){let{checkpoint:n}=t,r=w(e,n.objects.map(({objectApiName:o})=>o),n.scope.leftOut);return{state:"taken",checkpointId:n.checkpointId,name:n.name,takenAt:n.takenAt,expiresAt:n.expiresAt,objects:r.objects,records:n.objects.reduce((o,i)=>o+i.records,0),bytes:n.bytes,requests:t.requests?.total??t.estimate.apiRequests,added:r.added,notHeld:r.notHeld}}function D(e){return`${e.operation==="take"?"a checkpoint is being taken":e.operation==="rewind"?"a rewind is writing":e.operation==="undo"?"an undo is writing":e.operation==="empty"?"an emptying of its objects is writing":"SandForge is deleting checkpoints"} (process ${e.pid} on ${e.host})`}async function Z(e,t,n){let r=w(t,n.checkpoint.objects.map(({objectApiName:c})=>c),n.checkpoint.scope.leftOut);if(g(t,r,"")===void 0)return{taken:!0,checkpoint:j(t,n)};let o=await e.delete(n.checkpoint.checkpointId),i=o.outcome==="busy"?`It is kept all the same, as ${D(o.holder)}: delete it from the Checkpoints page once that has ended. Nothing was written.`:"It was deleted again; nothing was written.",s=g(t,r,i);return s===void 0?{taken:!0,checkpoint:j(t,n)}:{taken:!1,refusal:s}}function $(e,t,n){return{...e,...X(t,n)}}async function ae(e,t,n){let{scopeCheckpoint:r}=await import("./chunk-GTRU5AV5.mjs"),o=I(n),i=await r(e,$(t,o,n)),s=G(o,i,n.keepDays);if(s.refusal!==void 0)return s;let c=P(s.estimate.bytes,await(e.freeBytes??_)(e.store.root));return c===void 0?s:{...s,refusal:c}}async function ce(e,t,n,r){let o=await import("./chunk-GTRU5AV5.mjs"),i=I(n);if(r!==void 0){let c=P(r.estimate.bytes,await(e.freeBytes??_)(e.store.root));if(c!==void 0)return{taken:!1,refusal:c}}let s;try{s=await o.takeCheckpoint(e,$(t,i,n))}catch(c){if(c instanceof o.CheckpointTakeStopped)return{taken:!1,stopped:!0};throw c}return s.taken?Z(e.store,i,s):{taken:!1,refusal:s.refusal}}async function ue(e,t,n){if(n)return{info:t};let r=await e.delete(t.checkpointId);return r.outcome==="busy"?{info:t,notDeleted:`The checkpoint '${t.name}' taken before the run is kept, though the run wrote nothing: ${D(r.holder)}. Delete it from the Checkpoints page once that has ended.`}:{info:{state:"deleted",deleted:"nothingWritten"}}}function de(e){return`The checkpoint before the run was refused: ${e.message.endsWith(k)?e.message.slice(0,-k.length).trimEnd():e.message} Nothing was written. Untick Checkpoint first to run without it, or fix what refuses it.`}function fe(e){return`The checkpoint before the run could not be taken: ${C(e).replace(/\.$/,"")}. Nothing was written.`}var pe="The checkpoint taken before the run was deleted: the run wrote nothing.";function le(e){return`Taking the checkpoint first (${Math.round(e)}%)`}export{re as a,ie as b,I as c,G as d,V as e,P as f,_ as g,Q as h,se as i,X as j,j as k,Z as l,ae as m,ce as n,ue as o,de as p,fe as q,pe as r,le 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,b}from"./chunk-DBBPDSFN.mjs";import"./chunk-GBGHJTPC.mjs";import"./chunk-ZUOPC4W2.mjs";import"./chunk-PPGDAUEQ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-L4INJ5TZ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as grantsByObject,b as guardCheckpoint};
7
+ import{a,b}from"./chunk-BPHTA6KP.mjs";import"./chunk-U2CTKIPE.mjs";import"./chunk-4GCYGQXD.mjs";import"./chunk-PPGDAUEQ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-Z3MGN42K.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as grantsByObject,b as guardCheckpoint};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{c as a,d as b,e as c,f as d,g as e,h as f}from"./chunk-JJITOWZK.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as loadCreatedRecords,f as loadRecordsInfo,c as loadRecordsKept,b as loadRecordsLeft,d as loadToRemove,e as loadsSweptWith};
7
+ import{c as a,d as b,e as c,f as d,g as e,h as f}from"./chunk-PDRXM5WN.mjs";import"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as loadCreatedRecords,f as loadRecordsInfo,c as loadRecordsKept,b as loadRecordsLeft,d as loadToRemove,e as loadsSweptWith};
@@ -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 je,b as Ne,c as Pe,d as Fe,k as We,l as xe,o as Le,q as _e}from"./chunk-JESRFE2Z.mjs";import{e as Me}from"./chunk-CBL42DUU.mjs";import{b as De,f as Te}from"./chunk-MKTXJCXN.mjs";import{m as Be}from"./chunk-RCYEBY42.mjs";import{b as ve}from"./chunk-DBBPDSFN.mjs";import{i as he,j as we,k as ke,l as ye,m as be,p as Re,q as Ae}from"./chunk-VZT4E2OJ.mjs";import{A as Ie,B as $e,y as Se,z as Ue}from"./chunk-O2PUGRNW.mjs";import{C as ge}from"./chunk-7SDZR6SR.mjs";import{a as le,b as fe}from"./chunk-54HYHHVL.mjs";import{i as Oe,j as Ce}from"./chunk-SAMWHL22.mjs";import{b as pe}from"./chunk-HKUWHVI7.mjs";import{b as ue,d as ce}from"./chunk-VPDEJGPS.mjs";import{c as me}from"./chunk-JQZTMFO7.mjs";import{fc as Ee}from"./chunk-JFNLKHY6.mjs";import{g as L,h as _,q as de}from"./chunk-L4INJ5TZ.mjs";import{b as x}from"./chunk-CA5NAXSU.mjs";import{Ad as se,Id as W}from"./chunk-ZQO5PDX5.mjs";var C=class extends Error{constructor(){super("The undo was stopped before it wrote anything to the org."),this.name="UndoStopped"}},z="No record was written.",Je="accept that it runs to undo the rewind all the same";function ze(e){return e.slice(0,15)}function Ke(e){return{query:n=>e.query(n),queryMore:n=>e.queryMore(n)}}function Ye(e,n,t){if(e.kind==="org")return;let a=e.userKey;if(n.users.some(i=>i.slice(0,15)!==a))return{code:"PERMISSIONS",message:`This rewind was made as another user than ${t}: what it deleted is that user's deletion in the recycle bin, which Salesforce brings back only for a user with View All Data and Modify All Data. Undo it as the user it was made as, or as a user with View All Data and Modify All Data. ${z}`};let r=n.objects.flatMap(i=>{let l=e.notHeld.get(i);return l===void 0?[]:[`${i}: ${l}`]});if(r.length!==0)return{code:"PERMISSIONS",message:`Undo takes back what the rewind did to objects ${t} no longer holds whole (${r.join("; ")}), and does not stop part way: an undo left part way could not be offered again. Undo it once the user has View All and Modify All on them again, or as a user with View All Data and Modify All Data. ${z}`}}function Qe(e,n){return{undone:!1,refusal:{code:e,message:n}}}function Xe(e,n){return{code:"RUN_WRITING",message:`${n.operation==="take"?`A checkpoint of ${e} is being taken`:n.operation==="rewind"?`A rewind is writing to ${e}`:n.operation==="undo"?`An undo is writing to ${e}`:`SandForge is deleting checkpoints of ${e}`} (process ${n.pid} on ${n.host}): undo the rewind once it has ended. No record was read or written.`}}function Ze(e,n,t,a){let r=W(n,t),i=[...new Set(r.map(b=>b.objectApiName))],l=(t.setToDraft??[]).length>0?", sets an order back to Draft":"",h=r.length>0?`${Me(r)} flow(s), trigger(s) or rule(s) of ${i.join(", ")} run as the undo brings records back, gives them their values back${l} or sends them back to the recycle bin`:"what runs as the undo writes could not all be read, so automation may run";return{code:"AUTOMATION",message:`${e}: ${h}. ${ke("undo",a)}Undo refused; ${Je}. ${z}`}}async function et(e,n){let t=0,a=0;for await(let r of n.bringBack.pages(L)){t+=r.length;for(let i of ce(r,ue)){let l=await e.queryDeleted(`SELECT Id, ContentSize FROM ${L} WHERE Id IN (${i}) AND IsDeleted = true`);for(let h of l.records)typeof h.ContentSize=="number"&&(a+=h.ContentSize)}}return{files:t,bytes:a}}function tt(e,n){return e.status==="cancelled"||e.status==="failure"?e.status:n.some(t=>t.reason==="changedDuringRewind")?"unstable":e.status}function nt(e,n){return e.map(t=>{let a=Object.keys(t.by).filter(i=>!n.has(ze(i)));if(a.length===0)return{objectApiName:t.objectApiName,reason:"automation",count:t.count,ids:[...t.ids]};let r=a.length===1&&a[0]!=="unknown"?a[0]:void 0;return{objectApiName:t.objectApiName,reason:"changedDuringRewind",...r!==void 0?{by:r}:{},count:t.count,ids:[...t.ids]}})}async function Ot(e,n){let{checkpoint:t,folder:a,orgName:r,rewindId:i}=n,l=e.signal,h=()=>l?.aborted===!0,b=(U,k)=>e.onProgress?.({percentage:U,step:k}),c=_e(e.org,e.undelete),T,S=await ve(Ke(c.org),{act:"undo",orgName:r,registered:n.registered,username:n.username,organizationId:t.org.organizationId,customSettings:de(t)},{userId:async()=>T=await c.org.userId()});if(!S.allowed)return{undone:!1,refusal:S.refusal};let R=e.store.lock(t.org.organizationId,"undo",t.checkpointId);if("busy"in R)return{undone:!1,refusal:Xe(r,R.busy)};try{let U=await e.runWriting?.(S.org.id);if(U!==void 0)return Qe("RUN_WRITING",U);let k=await Ue(c.org,r);if(h())throw new C;b(5,"Reading what the rewind did");let g=await Ne(a,i,t.objects),G=Pe(g),M=g.goesWithParent.objects,Ge=g.remade.keys.size>0?"Sending back to the recycle bin what the rewind brought back, and deleting again what it made again":"Sending back to the recycle bin what the rewind brought back",A=o=>o.filter(u=>u.count>0).map(u=>u.objectApiName),j=g.links,q=o=>o>0?[_]:[],N=g.remade.objects.filter(({objectApiName:o,count:u})=>u>0&&ge([o]).length>0),m={bringBack:A(g.bringBack.objects),giveBack:[...A(g.giveBack.objects),...q(j?.share.count??0)],...N.length>0?{setToDraft:A(N)}:{},delete:[...new Set([...A(M),...A(g.remove.objects),...q(j?.remove.count??0)])],...(j?.reinsert.count??0)>0?{recreate:[_]}:{}},H;try{H=await et(c.org,g)}finally{await g.dispose()}let V=$e("undo",H,k.fileStorage?.remaining,r);if(V)return{undone:!1,refusal:V};let w=[...new Set([...m.bringBack??[],...m.giveBack??[],...m.setToDraft??[],...m.delete??[],...m.recreate??[]])],P;try{P=await De({grants:S.grants,...T!==void 0?{userId:T}:{},username:n.username,checkpoint:t,reader:Ce(c.org,l)})}catch(o){throw o instanceof Oe||h()?new C:o}if(P.kind==="perObject"){let o=await je(a,i),u=Ye(P,{users:o.passes.map(f=>f.userId),objects:w},n.username);if(u)return{undone:!1,refusal:u}}let d;if(w.length>0&&e.readAutomation){try{d=await e.readAutomation(w)}catch(o){d=Le(w,x(o))}c.add(d.requests)}let I=d,y=w.length>0?await We(e.mute,d,m):{},$="refusal"in y?y:void 0,J="refusal"in y?void 0:y.mute;y.automation&&(d=y.automation);let v=$?$.plan:J?.plan,K=n.acceptEmails===!0,p=w.length>0&&I?await Re({act:"undo",orgName:r,automation:I,steps:m,...v?{plan:v}:{},accepted:K,mayMute:e.mute===void 0&&n.canMute===!0,read:()=>me(c.org)}):void 0,Y=he(G,M,N),Q=d?we(Y,d):void 0,O=$?[$.refusal]:[];d&&!n.acceptAutomation&&(W(d,m).length>0||se(d.unread)||Q!==void 0)&&O.push(Ze(r,d,m,Q));let X=Se({objects:t.objects,rewound:G,along:M,automationRequests:0}),Z=Ee(p?.ofRun),ee=Ie("undo",{run:c.used()-(Z.deliverability??0)+X.apiRequests,...Z},k,r);w.length>0&&ee&&O.push(ee);let te=d?be("undo",ye(Y,d,k.emails),r):void 0;w.length>0&&te&&O.push(te),p?.refusal&&O.push(p.refusal);let[ne,...oe]=O;if(ne)return{undone:!1,refusal:ne,...oe.length>0?{alsoRefused:oe}:{}};if(h())throw new C;let qe=await c.org.userId(),He=new Set(Te(t.takenBy,qe).map(ze));b(20,"Bringing back what the rewind deleted and giving back what it wrote over");let B,E;try{E=await xe(J,`undo ${t.checkpointId} ${i}`,o=>{let u=o&&v&&I&&p?Ae({act:"undo",orgName:r,automation:I,steps:m,plan:v,held:o.outcome,planned:p.ofRun.senders,...p.ofRun.read?{reading:p.ofRun.read.reading}:{},accepted:K}):void 0;return u?Promise.resolve({relit:u}):Fe({folder:a,rewindId:i,lock:R.lock,objects:t.objects,org:c.org,undelete:c.undelete,splitting:le(fe(k.remaining,c.used()+X.apiRequests)),...l?{signal:l}:{},...e.onUndeletable?{onUndeletable:e.onUndeletable}:{},onProgress:(f,ae,Ve)=>b(20+Math.round(70*f/Math.max(ae,1)),`${Ge}: ${Ve} ${f} / ${ae}`)})},o=>{B=o})}catch(o){if(!pe(o))throw o;return{undone:!1,refusal:{code:"MUTE",message:`${o.message} No record was written.`}}}if("relit"in E)return{undone:!1,refusal:E.relit};let s=E,re=nt(s.residual,He),D=tt(s,re),F=[...s.notes];if(D!=="cancelled"&&D!=="failure"){let o=(e.now??(()=>new Date))().toISOString();try{await e.store.update(t.checkpointId,f=>f.lastRewind?.rewindId===i?{...f,lastRewind:{...f.lastRewind,undoneAt:o}}:f)}catch(f){F.push(`The checkpoint could not be told the rewind was undone (${x(f)}): its list may still offer to undo it.`)}let u=await Be({folder:a,lock:R.lock,checkpoint:t,rewindId:i,status:D,undoneAt:o});u!==void 0&&F.push(u)}let ie=c.used();return{undone:!0,result:{checkpointId:t.checkpointId,rewindId:i,status:D,deleted:s.deleted,...s.remade?{remade:s.remade}:{},...s.carriedAlone?{carriedAlone:s.carriedAlone}:{},...s.wentAlong?{wentAlong:s.wentAlong}:{},restored:s.restored,undeleted:s.undeleted,...s.files?{files:s.files}:{},residual:re,passes:1,apiRequests:{used:ie,leftToday:Math.max(0,k.remaining-ie)},finishedAt:s.finishedAt,...B?{mutedAutomation:B}:{}},notes:F,...p?.gate.audit!==void 0?{deliverability:p.gate.audit}:{}}}finally{R.lock.release()}}export{C as a,Je as b,Ot as c};
7
+ import{a as je,b as Ne,c as Pe,d as Fe,k as We,l as xe,o as Le,q as _e}from"./chunk-BH76USTQ.mjs";import{e as Me}from"./chunk-XKFHTBAB.mjs";import{b as De,f as Te}from"./chunk-FYWNSMOZ.mjs";import{m as Be}from"./chunk-WBELLGNE.mjs";import{b as ve}from"./chunk-BPHTA6KP.mjs";import{i as he,j as we,k as ke,l as ye,m as be,p as Re,q as Ae}from"./chunk-4X5D3MSV.mjs";import{A as Ie,B as $e,y as Se,z as Ue}from"./chunk-XMQ5R6TC.mjs";import{B as ge}from"./chunk-IXIY6Q4M.mjs";import{a as le,b as fe}from"./chunk-54HYHHVL.mjs";import{i as Oe,j as Ce}from"./chunk-EOQON3E5.mjs";import{b as pe}from"./chunk-7WSQ65WG.mjs";import{b as ue,d as ce}from"./chunk-MJD6CPZZ.mjs";import{c as me}from"./chunk-WXU6ZJIV.mjs";import{$b as Ee}from"./chunk-R3OM3X4L.mjs";import{g as L,h as _,q as de}from"./chunk-Z3MGN42K.mjs";import{b as x}from"./chunk-CA5NAXSU.mjs";import{Nd as se,Vd as W}from"./chunk-6QSHWIZI.mjs";var C=class extends Error{constructor(){super("The undo was stopped before it wrote anything to the org."),this.name="UndoStopped"}},z="No record was written.",Je="accept that it runs to undo the rewind all the same";function ze(e){return e.slice(0,15)}function Ke(e){return{query:n=>e.query(n),queryMore:n=>e.queryMore(n)}}function Ye(e,n,t){if(e.kind==="org")return;let a=e.userKey;if(n.users.some(i=>i.slice(0,15)!==a))return{code:"PERMISSIONS",message:`This rewind was made as another user than ${t}: what it deleted is that user's deletion in the recycle bin, which Salesforce brings back only for a user with View All Data and Modify All Data. Undo it as the user it was made as, or as a user with View All Data and Modify All Data. ${z}`};let r=n.objects.flatMap(i=>{let l=e.notHeld.get(i);return l===void 0?[]:[`${i}: ${l}`]});if(r.length!==0)return{code:"PERMISSIONS",message:`Undo takes back what the rewind did to objects ${t} no longer holds whole (${r.join("; ")}), and does not stop part way: an undo left part way could not be offered again. Undo it once the user has View All and Modify All on them again, or as a user with View All Data and Modify All Data. ${z}`}}function Qe(e,n){return{undone:!1,refusal:{code:e,message:n}}}function Xe(e,n){return{code:"RUN_WRITING",message:`${n.operation==="take"?`A checkpoint of ${e} is being taken`:n.operation==="rewind"?`A rewind is writing to ${e}`:n.operation==="undo"?`An undo is writing to ${e}`:`SandForge is deleting checkpoints of ${e}`} (process ${n.pid} on ${n.host}): undo the rewind once it has ended. No record was read or written.`}}function Ze(e,n,t,a){let r=W(n,t),i=[...new Set(r.map(b=>b.objectApiName))],l=(t.setToDraft??[]).length>0?", sets an order back to Draft":"",h=r.length>0?`${Me(r)} flow(s), trigger(s) or rule(s) of ${i.join(", ")} run as the undo brings records back, gives them their values back${l} or sends them back to the recycle bin`:"what runs as the undo writes could not all be read, so automation may run";return{code:"AUTOMATION",message:`${e}: ${h}. ${ke("undo",a)}Undo refused; ${Je}. ${z}`}}async function et(e,n){let t=0,a=0;for await(let r of n.bringBack.pages(L)){t+=r.length;for(let i of ce(r,ue)){let l=await e.queryDeleted(`SELECT Id, ContentSize FROM ${L} WHERE Id IN (${i}) AND IsDeleted = true`);for(let h of l.records)typeof h.ContentSize=="number"&&(a+=h.ContentSize)}}return{files:t,bytes:a}}function tt(e,n){return e.status==="cancelled"||e.status==="failure"?e.status:n.some(t=>t.reason==="changedDuringRewind")?"unstable":e.status}function nt(e,n){return e.map(t=>{let a=Object.keys(t.by).filter(i=>!n.has(ze(i)));if(a.length===0)return{objectApiName:t.objectApiName,reason:"automation",count:t.count,ids:[...t.ids]};let r=a.length===1&&a[0]!=="unknown"?a[0]:void 0;return{objectApiName:t.objectApiName,reason:"changedDuringRewind",...r!==void 0?{by:r}:{},count:t.count,ids:[...t.ids]}})}async function Ot(e,n){let{checkpoint:t,folder:a,orgName:r,rewindId:i}=n,l=e.signal,h=()=>l?.aborted===!0,b=(U,k)=>e.onProgress?.({percentage:U,step:k}),c=_e(e.org,e.undelete),T,S=await ve(Ke(c.org),{act:"undo",orgName:r,registered:n.registered,username:n.username,organizationId:t.org.organizationId,customSettings:de(t)},{userId:async()=>T=await c.org.userId()});if(!S.allowed)return{undone:!1,refusal:S.refusal};let R=e.store.lock(t.org.organizationId,"undo",t.checkpointId);if("busy"in R)return{undone:!1,refusal:Xe(r,R.busy)};try{let U=await e.runWriting?.(S.org.id);if(U!==void 0)return Qe("RUN_WRITING",U);let k=await Ue(c.org,r);if(h())throw new C;b(5,"Reading what the rewind did");let g=await Ne(a,i,t.objects),G=Pe(g),M=g.goesWithParent.objects,Ge=g.remade.keys.size>0?"Sending back to the recycle bin what the rewind brought back, and deleting again what it made again":"Sending back to the recycle bin what the rewind brought back",A=o=>o.filter(u=>u.count>0).map(u=>u.objectApiName),j=g.links,q=o=>o>0?[_]:[],N=g.remade.objects.filter(({objectApiName:o,count:u})=>u>0&&ge([o]).length>0),m={bringBack:A(g.bringBack.objects),giveBack:[...A(g.giveBack.objects),...q(j?.share.count??0)],...N.length>0?{setToDraft:A(N)}:{},delete:[...new Set([...A(M),...A(g.remove.objects),...q(j?.remove.count??0)])],...(j?.reinsert.count??0)>0?{recreate:[_]}:{}},H;try{H=await et(c.org,g)}finally{await g.dispose()}let V=$e("undo",H,k.fileStorage?.remaining,r);if(V)return{undone:!1,refusal:V};let w=[...new Set([...m.bringBack??[],...m.giveBack??[],...m.setToDraft??[],...m.delete??[],...m.recreate??[]])],P;try{P=await De({grants:S.grants,...T!==void 0?{userId:T}:{},username:n.username,checkpoint:t,reader:Ce(c.org,l)})}catch(o){throw o instanceof Oe||h()?new C:o}if(P.kind==="perObject"){let o=await je(a,i),u=Ye(P,{users:o.passes.map(f=>f.userId),objects:w},n.username);if(u)return{undone:!1,refusal:u}}let d;if(w.length>0&&e.readAutomation){try{d=await e.readAutomation(w)}catch(o){d=Le(w,x(o))}c.add(d.requests)}let I=d,y=w.length>0?await We(e.mute,d,m):{},$="refusal"in y?y:void 0,J="refusal"in y?void 0:y.mute;y.automation&&(d=y.automation);let v=$?$.plan:J?.plan,K=n.acceptEmails===!0,p=w.length>0&&I?await Re({act:"undo",orgName:r,automation:I,steps:m,...v?{plan:v}:{},accepted:K,mayMute:e.mute===void 0&&n.canMute===!0,read:()=>me(c.org)}):void 0,Y=he(G,M,N),Q=d?we(Y,d):void 0,O=$?[$.refusal]:[];d&&!n.acceptAutomation&&(W(d,m).length>0||se(d.unread)||Q!==void 0)&&O.push(Ze(r,d,m,Q));let X=Se({objects:t.objects,rewound:G,along:M,automationRequests:0}),Z=Ee(p?.ofRun),ee=Ie("undo",{run:c.used()-(Z.deliverability??0)+X.apiRequests,...Z},k,r);w.length>0&&ee&&O.push(ee);let te=d?be("undo",ye(Y,d,k.emails),r):void 0;w.length>0&&te&&O.push(te),p?.refusal&&O.push(p.refusal);let[ne,...oe]=O;if(ne)return{undone:!1,refusal:ne,...oe.length>0?{alsoRefused:oe}:{}};if(h())throw new C;let qe=await c.org.userId(),He=new Set(Te(t.takenBy,qe).map(ze));b(20,"Bringing back what the rewind deleted and giving back what it wrote over");let B,E;try{E=await xe(J,`undo ${t.checkpointId} ${i}`,o=>{let u=o&&v&&I&&p?Ae({act:"undo",orgName:r,automation:I,steps:m,plan:v,held:o.outcome,planned:p.ofRun.senders,...p.ofRun.read?{reading:p.ofRun.read.reading}:{},accepted:K}):void 0;return u?Promise.resolve({relit:u}):Fe({folder:a,rewindId:i,lock:R.lock,objects:t.objects,org:c.org,undelete:c.undelete,splitting:le(fe(k.remaining,c.used()+X.apiRequests)),...l?{signal:l}:{},...e.onUndeletable?{onUndeletable:e.onUndeletable}:{},onProgress:(f,ae,Ve)=>b(20+Math.round(70*f/Math.max(ae,1)),`${Ge}: ${Ve} ${f} / ${ae}`)})},o=>{B=o})}catch(o){if(!pe(o))throw o;return{undone:!1,refusal:{code:"MUTE",message:`${o.message} No record was written.`}}}if("relit"in E)return{undone:!1,refusal:E.relit};let s=E,re=nt(s.residual,He),D=tt(s,re),F=[...s.notes];if(D!=="cancelled"&&D!=="failure"){let o=(e.now??(()=>new Date))().toISOString();try{await e.store.update(t.checkpointId,f=>f.lastRewind?.rewindId===i?{...f,lastRewind:{...f.lastRewind,undoneAt:o}}:f)}catch(f){F.push(`The checkpoint could not be told the rewind was undone (${x(f)}): its list may still offer to undo it.`)}let u=await Be({folder:a,lock:R.lock,checkpoint:t,rewindId:i,status:D,undoneAt:o});u!==void 0&&F.push(u)}let ie=c.used();return{undone:!0,result:{checkpointId:t.checkpointId,rewindId:i,status:D,deleted:s.deleted,...s.remade?{remade:s.remade}:{},...s.carriedAlone?{carriedAlone:s.carriedAlone}:{},...s.wentAlong?{wentAlong:s.wentAlong}:{},restored:s.restored,undeleted:s.undeleted,...s.files?{files:s.files}:{},residual:re,passes:1,apiRequests:{used:ie,leftToday:Math.max(0,k.remaining-ie)},finishedAt:s.finishedAt,...B?{mutedAutomation:B}:{}},notes:F,...p?.gate.audit!==void 0?{deliverability:p.gate.audit}:{}}}finally{R.lock.release()}}export{C as a,Je as b,Ot as c};
@@ -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}from"./chunk-GJ6SZVHT.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-KIMQQ6JQ.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ZUTUYBNW.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as OPPORTUNITY,c as SeedPlatformRoles,b as rolesNotLookedUpNote,d as rolesOfADryRun,f as seedTargetOf,e as writtenByThePlatformLine};
7
+ import{a,b,c,d,e,f}from"./chunk-WZN36ACK.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-INIT2UKJ.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{a as OPPORTUNITY,c as SeedPlatformRoles,b as rolesNotLookedUpNote,d as rolesOfADryRun,f as seedTargetOf,e as writtenByThePlatformLine};
@@ -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{c as z,d as v,f as A,j as k,k as c,l as R}from"./chunk-FQGHL7GR.mjs";import{Tb as f}from"./chunk-ZQO5PDX5.mjs";var L={en_US:[{city:"New York",state:"New York",country:"United States",zipCode:"10001"},{city:"Los Angeles",state:"California",country:"United States",zipCode:"90001"},{city:"Chicago",state:"Illinois",country:"United States",zipCode:"60601"},{city:"Houston",state:"Texas",country:"United States",zipCode:"77001"},{city:"Phoenix",state:"Arizona",country:"United States",zipCode:"85001"},{city:"Philadelphia",state:"Pennsylvania",country:"United States",zipCode:"19101"},{city:"San Antonio",state:"Texas",country:"United States",zipCode:"78201"},{city:"San Diego",state:"California",country:"United States",zipCode:"92101"},{city:"Dallas",state:"Texas",country:"United States",zipCode:"75201"},{city:"Austin",state:"Texas",country:"United States",zipCode:"78701"}],fr_FR:[{city:"Paris",state:"Ile-de-France",country:"France",zipCode:"75001"},{city:"Lyon",state:"Auvergne-Rhone-Alpes",country:"France",zipCode:"69001"},{city:"Marseille",state:"Provence-Alpes-Cote d'Azur",country:"France",zipCode:"13001"},{city:"Toulouse",state:"Occitanie",country:"France",zipCode:"31000"},{city:"Nice",state:"Provence-Alpes-Cote d'Azur",country:"France",zipCode:"06000"},{city:"Bordeaux",state:"Nouvelle-Aquitaine",country:"France",zipCode:"33000"},{city:"Strasbourg",state:"Grand Est",country:"France",zipCode:"67000"},{city:"Nantes",state:"Pays de la Loire",country:"France",zipCode:"44000"},{city:"Lille",state:"Hauts-de-France",country:"France",zipCode:"59000"},{city:"Rennes",state:"Bretagne",country:"France",zipCode:"35000"}],de_DE:[{city:"Berlin",state:"Berlin",country:"Germany",zipCode:"10115"},{city:"Munich",state:"Bavaria",country:"Germany",zipCode:"80331"},{city:"Hamburg",state:"Hamburg",country:"Germany",zipCode:"20095"},{city:"Frankfurt",state:"Hesse",country:"Germany",zipCode:"60311"},{city:"Cologne",state:"North Rhine-Westphalia",country:"Germany",zipCode:"50667"},{city:"Stuttgart",state:"Baden-Wurttemberg",country:"Germany",zipCode:"70173"},{city:"Dusseldorf",state:"North Rhine-Westphalia",country:"Germany",zipCode:"40213"},{city:"Leipzig",state:"Saxony",country:"Germany",zipCode:"04109"},{city:"Dresden",state:"Saxony",country:"Germany",zipCode:"01067"},{city:"Hannover",state:"Lower Saxony",country:"Germany",zipCode:"30159"}],es_ES:[{city:"Madrid",state:"Comunidad de Madrid",country:"Spain",zipCode:"28001"},{city:"Barcelona",state:"Catalonia",country:"Spain",zipCode:"08001"},{city:"Valencia",state:"Comunitat Valenciana",country:"Spain",zipCode:"46001"},{city:"Seville",state:"Andalusia",country:"Spain",zipCode:"41001"},{city:"Zaragoza",state:"Aragon",country:"Spain",zipCode:"50001"},{city:"Malaga",state:"Andalusia",country:"Spain",zipCode:"29001"},{city:"Bilbao",state:"Basque Country",country:"Spain",zipCode:"48001"},{city:"Murcia",state:"Region de Murcia",country:"Spain",zipCode:"30001"},{city:"Palma",state:"Balearic Islands",country:"Spain",zipCode:"07001"},{city:"Granada",state:"Andalusia",country:"Spain",zipCode:"18001"}],ja_JP:[{city:"Tokyo",state:"Tokyo",country:"Japan",zipCode:"100-0001"},{city:"Osaka",state:"Osaka",country:"Japan",zipCode:"530-0001"},{city:"Yokohama",state:"Kanagawa",country:"Japan",zipCode:"220-0011"},{city:"Nagoya",state:"Aichi",country:"Japan",zipCode:"450-0001"},{city:"Sapporo",state:"Hokkaido",country:"Japan",zipCode:"060-0001"},{city:"Fukuoka",state:"Fukuoka",country:"Japan",zipCode:"810-0001"},{city:"Kobe",state:"Hyogo",country:"Japan",zipCode:"650-0001"},{city:"Kyoto",state:"Kyoto",country:"Japan",zipCode:"600-8001"},{city:"Sendai",state:"Miyagi",country:"Japan",zipCode:"980-0001"},{city:"Hiroshima",state:"Hiroshima",country:"Japan",zipCode:"730-0001"}],pt_BR:[{city:"Sao Paulo",state:"Sao Paulo",country:"Brazil",zipCode:"01000-000"},{city:"Rio de Janeiro",state:"Rio de Janeiro",country:"Brazil",zipCode:"20000-000"},{city:"Brasilia",state:"Distrito Federal",country:"Brazil",zipCode:"70000-000"},{city:"Salvador",state:"Bahia",country:"Brazil",zipCode:"40000-000"},{city:"Fortaleza",state:"Ceara",country:"Brazil",zipCode:"60000-000"},{city:"Belo Horizonte",state:"Minas Gerais",country:"Brazil",zipCode:"30000-000"},{city:"Manaus",state:"Amazonas",country:"Brazil",zipCode:"69000-000"},{city:"Curitiba",state:"Parana",country:"Brazil",zipCode:"80000-000"},{city:"Recife",state:"Pernambuco",country:"Brazil",zipCode:"50000-000"},{city:"Porto Alegre",state:"Rio Grande do Sul",country:"Brazil",zipCode:"90000-000"}]},B={en:"en_US",fr:"fr_FR",de:"de_DE",es:"es_ES",ja:"ja_JP",pt:"pt_BR"};function l(i){if(i in L)return i;let e=i.split("_")[0].toLowerCase();return B[e]??"en_US"}var u=class{tuples;resolvedLocale;constructor(e){this.resolvedLocale=l(e??"en_US"),this.tuples=L[this.resolvedLocale]}getAddress(e){return this.tuples[e%this.tuples.length]}getCity(e){return this.getAddress(e).city}getState(e){return this.getAddress(e).state}getCountry(e){return this.getAddress(e).country}getZipCode(e){return this.getAddress(e).zipCode}getLocaleData(){return c(this.resolvedLocale)}};var F={en_US:"US",fr_FR:"FR",de_DE:"DE",es_ES:"ES",ja_JP:"JP",pt_BR:"BR"},$={fr_FR:{country:"FR",bbanLength:23},de_DE:{country:"DE",bbanLength:18},es_ES:{country:"ES",bbanLength:20},en_US:{country:"DE",bbanLength:18},ja_JP:{country:"DE",bbanLength:18},pt_BR:{country:"DE",bbanLength:18}},w="ABCDEFGHIJKLMNPQRSTUVWXYZ",T=["Ergonomic","Handcrafted","Refined","Sleek","Rustic","Compact","Modular","Insulated"],E=["Steel","Wooden","Cotton","Granite","Rubber","Leather","Ceramic"],_=["Chair","Table","Lamp","Keyboard","Backpack","Bottle","Headphones","Gloves","Bench"],M=["Senior","Lead","Junior","Principal","Associate","Chief"],P=["Marketing","Operations","Finance","Sales","Product","Customer Success"],U=["Manager","Analyst","Coordinator","Specialist","Director","Consultant"],G=["Adaptive","Integrated","Customer-focused","Scalable","Secure"],O=["cloud-based","real-time","data-driven","modular","global"],I=["platform","solution","workflow","service","framework","network"],J=["daily use at home or in the office","long days on the move","teams that need something that lasts","small spaces","outdoor work in any weather"],H=["Unable to log in","Invoice discrepancy","Password reset email not received","Order arrived damaged","Request for a refund","Cannot update billing address","Shipment delayed","Error when exporting a report","Product not working as described","Question about my contract","Charged twice for one order","Need help with installation","Account locked after failed logins","Wrong item delivered","Request: edit several records at once","App crashes on startup","Items missing from my order","Cannot download my invoice","Change of delivery address","Warranty claim","Slow since the last update","Question about my subscription renewal","Data not syncing between devices","Cancel my order","Upgrade to a higher plan"],x=["Asked the customer for a screenshot of the error.","Reproduced the issue on our side.","Escalated to the second-level team.","Sent the customer a workaround.","Customer confirmed the fix works.","Waiting for the customer's reply.","Refund approved and processed.","Replacement shipped today.","Called the customer, no answer; left a voicemail.","Linked to a known issue, a fix is planned.","Updated the customer's address on file.","Shared the knowledge article on this topic.","Closed after the customer confirmed.","Reset the account; login works again.","Checked the logs, nothing unusual found."],j=1440*60*1e3,V=365,Y=120,W=30,N=20,K=65,b=class{locale;localeData;geoGenerator;usernameToken=crypto.randomUUID().replace(/-/g,"").slice(0,8);random;today;companyDecks=new Map;companiesDealt=new Map;constructor(e,t={}){this.locale=e??"en_US",this.localeData=c(this.locale),this.geoGenerator=new u(this.locale),this.random=t.random??Math.random,this.today=t.today??(()=>new Date)}setLocale(e){this.locale=e,this.localeData=c(e),this.geoGenerator=new u(e)}generate(e,t,r=0){if(t<=0||e.length===0)return[];let a=[],o=e.filter(n=>f(n.config.fakerMethod??"lorem")==="phone");for(let n=r;n<r+t;n++){let d={},m=new Map,C=(s,p)=>{let y=m.get(s);if(y!==void 0)return y%p;let D=this.below(p);return m.set(s,D),D};for(let s of e){let p=o.indexOf(s),y=p>=0?n*o.length+p:n;d[s.fieldApiName]=this.generateFieldValue(s,y,C)}a.push(d)}return a}dateOf(e){return e==="pastDate"?this.pastDate():this.futureDate()}below(e){return Math.min(e-1,Math.floor(this.random()*e))}pick(e){return e[this.below(e.length)]}generateFieldValue(e,t,r){let a=e.config.fakerMethod??"lorem",o={min:e.config.minValue??0,max:e.config.maxValue??1e3},n=e.config.fakerLocale;if(n&&n!==this.locale){let d=this.locale,m=this.localeData,C=this.geoGenerator;this.locale=n,this.localeData=c(n),this.geoGenerator=new u(n);let s=this.generateByMethodInstance(a,t,o,r);return this.locale=d,this.localeData=m,this.geoGenerator=C,s}return this.generateByMethodInstance(a,t,o,r)}generateByMethodInstance(e,t,r,a){let o=f(e);if(!o)return Z(e);let n=()=>a("geo",1e4);switch(o){case"name":return`${this.firstName(a)} ${this.lastName(a)}`;case"firstName":return this.firstName(a);case"lastName":return this.lastName(a);case"jobTitle":return`${this.pick(M)} ${this.pick(P)} ${this.pick(U)}`;case"email":return this.generateEmail(t,a);case"username":return this.generateUsername(t,a);case"nickname":return this.generateNickname(t,a);case"phone":return this.generatePhone(t);case"address":return`${this.streetAddress()}, ${this.geoGenerator.getCity(n())}`;case"streetAddress":return this.streetAddress();case"city":return this.geoGenerator.getCity(n());case"country":return this.geoGenerator.getCountry(n());case"state":return this.geoGenerator.getState(n());case"company":return this.generateCompany();case"catchPhrase":return`${this.pick(G)} ${this.pick(O)} `+this.pick(I);case"date":case"pastDate":return this.pastDate();case"futureDate":return this.futureDate();case"futureDateTime":return this.futureDateTime();case"birthdate":return this.birthdate();case"number":case"integer":return Math.floor(r.min+this.random()*(r.max-r.min+1));case"float":return Math.round((r.min+this.random()*(r.max-r.min))*100)/100;case"boolean":return t%2===0;case"lorem":case"sentence":return g(t);case"paragraph":return q(t);case"caseSubject":return this.pick(H);case"caseComment":return this.pick(x);case"uuid":return this.uuid();case"url":return`https://example.com/resource/${t}`;case"zipCode":return this.geoGenerator.getZipCode(n());case"productName":return this.productName(a);case"productDescription":return`${this.productName(a)}, made for ${this.pick(J)}.`;case"iban":return this.generateIban(t);case"bic":return this.generateBic(t)}}firstName(e){let t=this.localeData.firstNames;return t[e("first",t.length)]}lastName(e){let t=this.localeData.lastNames;return t[e("last",t.length)]}generateEmail(e,t){let r=this.localeData.emailDomains[e%this.localeData.emailDomains.length];return`${h(this.firstName(t))}.${h(this.lastName(t))}${e}@${r}`}generateUsername(e,t){let r=h(this.firstName(t)),a=h(this.lastName(t)),o=this.localeData.emailDomains[e%this.localeData.emailDomains.length];return`${r}.${a}.${this.usernameToken}${e}@${o}`}generateNickname(e,t){return`${h(this.firstName(t)).slice(0,20)}.${this.usernameToken}${e}`}generatePhone(e){return k(this.locale,e)}streetAddress(){let{names:e,format:t}=z[l(this.locale)];return t.replace("{street}",this.pick(e)).replace("{n}",String(1+this.below(199))).replace("{m}",String(1+this.below(9)))}generateCompany(){let e=l(this.locale),t=A[e].companies.length,r=this.companyDecks.get(e);if(!r||r.length!==t){r=Array.from({length:t},(o,n)=>n);for(let o=r.length-1;o>0;o--){let n=this.below(o+1);[r[o],r[n]]=[r[n],r[o]]}this.companyDecks.set(e,r)}let a=this.companiesDealt.get(e)??0;return this.companiesDealt.set(e,a+1),v(e,r[a%r.length],Math.floor(a/r.length))}productName(e){let t=T[e("productAdjective",T.length)],r=E[e("productMaterial",E.length)],a=_[e("product",_.length)];return`${t} ${r} ${a}`}pastDate(){return S(this.daysFromToday(-(1+this.below(V))))}futureDate(){return S(this.daysFromToday(1+this.below(Y)))}futureDateTime(){let e=this.daysFromToday(1+this.below(W));return e.setUTCHours(8+this.below(9),this.below(2)*30,0,0),e.toISOString()}birthdate(){let e=(K-N)*365;return S(this.daysFromToday(-(N*365+this.below(e))))}daysFromToday(e){return new Date(this.today().getTime()+e*j)}uuid(){let e=Array.from({length:32},()=>this.below(16).toString(16));e[12]="4",e[16]=(this.below(16)&3|8).toString(16);let t=e.join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}generateIban(e){let t=$[l(this.locale)],r=R("#".repeat(t.bbanLength),e);return`${t.country}${X(t.country,r)}${r}`}generateBic(e){let t=Array.from({length:4},(a,o)=>String.fromCharCode(65+(e*5+o*7+3)%26)).join(""),r=Array.from({length:2},(a,o)=>w[(e*3+o*11+2)%w.length]).join("");return`${t}${F[l(this.locale)]}${r}XXX`}};function oe(i,e,t,r,a){let o=new b(r,a),n={fieldApiName:"temp",ruleType:"faker",config:{fakerMethod:i,minValue:t.min,maxValue:t.max}};return o.generate([n],e+1)[e]?.temp}function S(i){return i.toISOString().split("T")[0]}function h(i){return i.normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z]/g,"")}function X(i,e){let t=`${e}${i}00`.replace(/[A-Z]/g,a=>String(a.charCodeAt(0)-55)),r=0;for(let a of t)r=(r*10+Number(a))%97;return String(98-r).padStart(2,"0")}function Z(i){throw new Error(`Faker method "${i}" is not implemented: choose a method SandForge generates, or remove it from the field rule.`)}function g(i){let e=["lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit"],t=i%e.length,r=[];for(let a=0;a<6;a++)r.push(e[(t+a)%e.length]);return r.join(" ")+"."}function q(i){return[g(i),g(i+1),g(i+2)].join(" ")}export{b as a,oe as b};
7
+ import{c as z,d as v,f as A,j as k,k as c,l as R}from"./chunk-FQGHL7GR.mjs";import{ec as f}from"./chunk-6QSHWIZI.mjs";var L={en_US:[{city:"New York",state:"New York",country:"United States",zipCode:"10001"},{city:"Los Angeles",state:"California",country:"United States",zipCode:"90001"},{city:"Chicago",state:"Illinois",country:"United States",zipCode:"60601"},{city:"Houston",state:"Texas",country:"United States",zipCode:"77001"},{city:"Phoenix",state:"Arizona",country:"United States",zipCode:"85001"},{city:"Philadelphia",state:"Pennsylvania",country:"United States",zipCode:"19101"},{city:"San Antonio",state:"Texas",country:"United States",zipCode:"78201"},{city:"San Diego",state:"California",country:"United States",zipCode:"92101"},{city:"Dallas",state:"Texas",country:"United States",zipCode:"75201"},{city:"Austin",state:"Texas",country:"United States",zipCode:"78701"}],fr_FR:[{city:"Paris",state:"Ile-de-France",country:"France",zipCode:"75001"},{city:"Lyon",state:"Auvergne-Rhone-Alpes",country:"France",zipCode:"69001"},{city:"Marseille",state:"Provence-Alpes-Cote d'Azur",country:"France",zipCode:"13001"},{city:"Toulouse",state:"Occitanie",country:"France",zipCode:"31000"},{city:"Nice",state:"Provence-Alpes-Cote d'Azur",country:"France",zipCode:"06000"},{city:"Bordeaux",state:"Nouvelle-Aquitaine",country:"France",zipCode:"33000"},{city:"Strasbourg",state:"Grand Est",country:"France",zipCode:"67000"},{city:"Nantes",state:"Pays de la Loire",country:"France",zipCode:"44000"},{city:"Lille",state:"Hauts-de-France",country:"France",zipCode:"59000"},{city:"Rennes",state:"Bretagne",country:"France",zipCode:"35000"}],de_DE:[{city:"Berlin",state:"Berlin",country:"Germany",zipCode:"10115"},{city:"Munich",state:"Bavaria",country:"Germany",zipCode:"80331"},{city:"Hamburg",state:"Hamburg",country:"Germany",zipCode:"20095"},{city:"Frankfurt",state:"Hesse",country:"Germany",zipCode:"60311"},{city:"Cologne",state:"North Rhine-Westphalia",country:"Germany",zipCode:"50667"},{city:"Stuttgart",state:"Baden-Wurttemberg",country:"Germany",zipCode:"70173"},{city:"Dusseldorf",state:"North Rhine-Westphalia",country:"Germany",zipCode:"40213"},{city:"Leipzig",state:"Saxony",country:"Germany",zipCode:"04109"},{city:"Dresden",state:"Saxony",country:"Germany",zipCode:"01067"},{city:"Hannover",state:"Lower Saxony",country:"Germany",zipCode:"30159"}],es_ES:[{city:"Madrid",state:"Comunidad de Madrid",country:"Spain",zipCode:"28001"},{city:"Barcelona",state:"Catalonia",country:"Spain",zipCode:"08001"},{city:"Valencia",state:"Comunitat Valenciana",country:"Spain",zipCode:"46001"},{city:"Seville",state:"Andalusia",country:"Spain",zipCode:"41001"},{city:"Zaragoza",state:"Aragon",country:"Spain",zipCode:"50001"},{city:"Malaga",state:"Andalusia",country:"Spain",zipCode:"29001"},{city:"Bilbao",state:"Basque Country",country:"Spain",zipCode:"48001"},{city:"Murcia",state:"Region de Murcia",country:"Spain",zipCode:"30001"},{city:"Palma",state:"Balearic Islands",country:"Spain",zipCode:"07001"},{city:"Granada",state:"Andalusia",country:"Spain",zipCode:"18001"}],ja_JP:[{city:"Tokyo",state:"Tokyo",country:"Japan",zipCode:"100-0001"},{city:"Osaka",state:"Osaka",country:"Japan",zipCode:"530-0001"},{city:"Yokohama",state:"Kanagawa",country:"Japan",zipCode:"220-0011"},{city:"Nagoya",state:"Aichi",country:"Japan",zipCode:"450-0001"},{city:"Sapporo",state:"Hokkaido",country:"Japan",zipCode:"060-0001"},{city:"Fukuoka",state:"Fukuoka",country:"Japan",zipCode:"810-0001"},{city:"Kobe",state:"Hyogo",country:"Japan",zipCode:"650-0001"},{city:"Kyoto",state:"Kyoto",country:"Japan",zipCode:"600-8001"},{city:"Sendai",state:"Miyagi",country:"Japan",zipCode:"980-0001"},{city:"Hiroshima",state:"Hiroshima",country:"Japan",zipCode:"730-0001"}],pt_BR:[{city:"Sao Paulo",state:"Sao Paulo",country:"Brazil",zipCode:"01000-000"},{city:"Rio de Janeiro",state:"Rio de Janeiro",country:"Brazil",zipCode:"20000-000"},{city:"Brasilia",state:"Distrito Federal",country:"Brazil",zipCode:"70000-000"},{city:"Salvador",state:"Bahia",country:"Brazil",zipCode:"40000-000"},{city:"Fortaleza",state:"Ceara",country:"Brazil",zipCode:"60000-000"},{city:"Belo Horizonte",state:"Minas Gerais",country:"Brazil",zipCode:"30000-000"},{city:"Manaus",state:"Amazonas",country:"Brazil",zipCode:"69000-000"},{city:"Curitiba",state:"Parana",country:"Brazil",zipCode:"80000-000"},{city:"Recife",state:"Pernambuco",country:"Brazil",zipCode:"50000-000"},{city:"Porto Alegre",state:"Rio Grande do Sul",country:"Brazil",zipCode:"90000-000"}]},B={en:"en_US",fr:"fr_FR",de:"de_DE",es:"es_ES",ja:"ja_JP",pt:"pt_BR"};function l(i){if(i in L)return i;let e=i.split("_")[0].toLowerCase();return B[e]??"en_US"}var u=class{tuples;resolvedLocale;constructor(e){this.resolvedLocale=l(e??"en_US"),this.tuples=L[this.resolvedLocale]}getAddress(e){return this.tuples[e%this.tuples.length]}getCity(e){return this.getAddress(e).city}getState(e){return this.getAddress(e).state}getCountry(e){return this.getAddress(e).country}getZipCode(e){return this.getAddress(e).zipCode}getLocaleData(){return c(this.resolvedLocale)}};var F={en_US:"US",fr_FR:"FR",de_DE:"DE",es_ES:"ES",ja_JP:"JP",pt_BR:"BR"},$={fr_FR:{country:"FR",bbanLength:23},de_DE:{country:"DE",bbanLength:18},es_ES:{country:"ES",bbanLength:20},en_US:{country:"DE",bbanLength:18},ja_JP:{country:"DE",bbanLength:18},pt_BR:{country:"DE",bbanLength:18}},w="ABCDEFGHIJKLMNPQRSTUVWXYZ",T=["Ergonomic","Handcrafted","Refined","Sleek","Rustic","Compact","Modular","Insulated"],E=["Steel","Wooden","Cotton","Granite","Rubber","Leather","Ceramic"],_=["Chair","Table","Lamp","Keyboard","Backpack","Bottle","Headphones","Gloves","Bench"],M=["Senior","Lead","Junior","Principal","Associate","Chief"],P=["Marketing","Operations","Finance","Sales","Product","Customer Success"],U=["Manager","Analyst","Coordinator","Specialist","Director","Consultant"],G=["Adaptive","Integrated","Customer-focused","Scalable","Secure"],O=["cloud-based","real-time","data-driven","modular","global"],I=["platform","solution","workflow","service","framework","network"],J=["daily use at home or in the office","long days on the move","teams that need something that lasts","small spaces","outdoor work in any weather"],H=["Unable to log in","Invoice discrepancy","Password reset email not received","Order arrived damaged","Request for a refund","Cannot update billing address","Shipment delayed","Error when exporting a report","Product not working as described","Question about my contract","Charged twice for one order","Need help with installation","Account locked after failed logins","Wrong item delivered","Request: edit several records at once","App crashes on startup","Items missing from my order","Cannot download my invoice","Change of delivery address","Warranty claim","Slow since the last update","Question about my subscription renewal","Data not syncing between devices","Cancel my order","Upgrade to a higher plan"],x=["Asked the customer for a screenshot of the error.","Reproduced the issue on our side.","Escalated to the second-level team.","Sent the customer a workaround.","Customer confirmed the fix works.","Waiting for the customer's reply.","Refund approved and processed.","Replacement shipped today.","Called the customer, no answer; left a voicemail.","Linked to a known issue, a fix is planned.","Updated the customer's address on file.","Shared the knowledge article on this topic.","Closed after the customer confirmed.","Reset the account; login works again.","Checked the logs, nothing unusual found."],j=1440*60*1e3,V=365,Y=120,W=30,N=20,K=65,b=class{locale;localeData;geoGenerator;usernameToken=crypto.randomUUID().replace(/-/g,"").slice(0,8);random;today;companyDecks=new Map;companiesDealt=new Map;constructor(e,t={}){this.locale=e??"en_US",this.localeData=c(this.locale),this.geoGenerator=new u(this.locale),this.random=t.random??Math.random,this.today=t.today??(()=>new Date)}setLocale(e){this.locale=e,this.localeData=c(e),this.geoGenerator=new u(e)}generate(e,t,r=0){if(t<=0||e.length===0)return[];let a=[],o=e.filter(n=>f(n.config.fakerMethod??"lorem")==="phone");for(let n=r;n<r+t;n++){let d={},m=new Map,C=(s,p)=>{let y=m.get(s);if(y!==void 0)return y%p;let D=this.below(p);return m.set(s,D),D};for(let s of e){let p=o.indexOf(s),y=p>=0?n*o.length+p:n;d[s.fieldApiName]=this.generateFieldValue(s,y,C)}a.push(d)}return a}dateOf(e){return e==="pastDate"?this.pastDate():this.futureDate()}below(e){return Math.min(e-1,Math.floor(this.random()*e))}pick(e){return e[this.below(e.length)]}generateFieldValue(e,t,r){let a=e.config.fakerMethod??"lorem",o={min:e.config.minValue??0,max:e.config.maxValue??1e3},n=e.config.fakerLocale;if(n&&n!==this.locale){let d=this.locale,m=this.localeData,C=this.geoGenerator;this.locale=n,this.localeData=c(n),this.geoGenerator=new u(n);let s=this.generateByMethodInstance(a,t,o,r);return this.locale=d,this.localeData=m,this.geoGenerator=C,s}return this.generateByMethodInstance(a,t,o,r)}generateByMethodInstance(e,t,r,a){let o=f(e);if(!o)return Z(e);let n=()=>a("geo",1e4);switch(o){case"name":return`${this.firstName(a)} ${this.lastName(a)}`;case"firstName":return this.firstName(a);case"lastName":return this.lastName(a);case"jobTitle":return`${this.pick(M)} ${this.pick(P)} ${this.pick(U)}`;case"email":return this.generateEmail(t,a);case"username":return this.generateUsername(t,a);case"nickname":return this.generateNickname(t,a);case"phone":return this.generatePhone(t);case"address":return`${this.streetAddress()}, ${this.geoGenerator.getCity(n())}`;case"streetAddress":return this.streetAddress();case"city":return this.geoGenerator.getCity(n());case"country":return this.geoGenerator.getCountry(n());case"state":return this.geoGenerator.getState(n());case"company":return this.generateCompany();case"catchPhrase":return`${this.pick(G)} ${this.pick(O)} `+this.pick(I);case"date":case"pastDate":return this.pastDate();case"futureDate":return this.futureDate();case"futureDateTime":return this.futureDateTime();case"birthdate":return this.birthdate();case"number":case"integer":return Math.floor(r.min+this.random()*(r.max-r.min+1));case"float":return Math.round((r.min+this.random()*(r.max-r.min))*100)/100;case"boolean":return t%2===0;case"lorem":case"sentence":return g(t);case"paragraph":return q(t);case"caseSubject":return this.pick(H);case"caseComment":return this.pick(x);case"uuid":return this.uuid();case"url":return`https://example.com/resource/${t}`;case"zipCode":return this.geoGenerator.getZipCode(n());case"productName":return this.productName(a);case"productDescription":return`${this.productName(a)}, made for ${this.pick(J)}.`;case"iban":return this.generateIban(t);case"bic":return this.generateBic(t)}}firstName(e){let t=this.localeData.firstNames;return t[e("first",t.length)]}lastName(e){let t=this.localeData.lastNames;return t[e("last",t.length)]}generateEmail(e,t){let r=this.localeData.emailDomains[e%this.localeData.emailDomains.length];return`${h(this.firstName(t))}.${h(this.lastName(t))}${e}@${r}`}generateUsername(e,t){let r=h(this.firstName(t)),a=h(this.lastName(t)),o=this.localeData.emailDomains[e%this.localeData.emailDomains.length];return`${r}.${a}.${this.usernameToken}${e}@${o}`}generateNickname(e,t){return`${h(this.firstName(t)).slice(0,20)}.${this.usernameToken}${e}`}generatePhone(e){return k(this.locale,e)}streetAddress(){let{names:e,format:t}=z[l(this.locale)];return t.replace("{street}",this.pick(e)).replace("{n}",String(1+this.below(199))).replace("{m}",String(1+this.below(9)))}generateCompany(){let e=l(this.locale),t=A[e].companies.length,r=this.companyDecks.get(e);if(!r||r.length!==t){r=Array.from({length:t},(o,n)=>n);for(let o=r.length-1;o>0;o--){let n=this.below(o+1);[r[o],r[n]]=[r[n],r[o]]}this.companyDecks.set(e,r)}let a=this.companiesDealt.get(e)??0;return this.companiesDealt.set(e,a+1),v(e,r[a%r.length],Math.floor(a/r.length))}productName(e){let t=T[e("productAdjective",T.length)],r=E[e("productMaterial",E.length)],a=_[e("product",_.length)];return`${t} ${r} ${a}`}pastDate(){return S(this.daysFromToday(-(1+this.below(V))))}futureDate(){return S(this.daysFromToday(1+this.below(Y)))}futureDateTime(){let e=this.daysFromToday(1+this.below(W));return e.setUTCHours(8+this.below(9),this.below(2)*30,0,0),e.toISOString()}birthdate(){let e=(K-N)*365;return S(this.daysFromToday(-(N*365+this.below(e))))}daysFromToday(e){return new Date(this.today().getTime()+e*j)}uuid(){let e=Array.from({length:32},()=>this.below(16).toString(16));e[12]="4",e[16]=(this.below(16)&3|8).toString(16);let t=e.join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}generateIban(e){let t=$[l(this.locale)],r=R("#".repeat(t.bbanLength),e);return`${t.country}${X(t.country,r)}${r}`}generateBic(e){let t=Array.from({length:4},(a,o)=>String.fromCharCode(65+(e*5+o*7+3)%26)).join(""),r=Array.from({length:2},(a,o)=>w[(e*3+o*11+2)%w.length]).join("");return`${t}${F[l(this.locale)]}${r}XXX`}};function oe(i,e,t,r,a){let o=new b(r,a),n={fieldApiName:"temp",ruleType:"faker",config:{fakerMethod:i,minValue:t.min,maxValue:t.max}};return o.generate([n],e+1)[e]?.temp}function S(i){return i.toISOString().split("T")[0]}function h(i){return i.normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z]/g,"")}function X(i,e){let t=`${e}${i}00`.replace(/[A-Z]/g,a=>String(a.charCodeAt(0)-55)),r=0;for(let a of t)r=(r*10+Number(a))%97;return String(98-r).padStart(2,"0")}function Z(i){throw new Error(`Faker method "${i}" is not implemented: choose a method SandForge generates, or remove it from the field rule.`)}function g(i){let e=["lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit"],t=i%e.length,r=[];for(let a=0;a<6;a++)r.push(e[(t+a)%e.length]);return r.join(" ")+"."}function q(i){return[g(i),g(i+1),g(i+2)].join(" ")}export{b as a,oe 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{a as d}from"./chunk-PPGDAUEQ.mjs";import{a as c}from"./chunk-SU65Z2BA.mjs";import{Jc as a,Lc as u}from"./chunk-ZQO5PDX5.mjs";async function I(t){let e=(await t.query("SELECT Id, IsSandbox FROM Organization LIMIT 1")).records[0];if(typeof e?.Id!="string")throw new Error("The org gave no Organization record: whether it is a sandbox cannot be told.");if(e.IsSandbox===!0)return{id:e.Id,sandbox:!0};try{let r=(await t.query("SELECT OrganizationType FROM Organization LIMIT 1")).records[0]?.OrganizationType;return typeof r=="string"&&r!==""?{id:e.Id,sandbox:!1,edition:r}:{id:e.Id,sandbox:!1}}catch{return{id:e.Id,sandbox:!1}}}function h(t){let n=a({isSandbox:t.sandbox,edition:t.edition});return u(n,t.edition)==="production"}function p(t){let{errorCode:n,statusCode:e}=typeof t=="object"&&t!==null?t:{},o=t instanceof Error?t.message:String(t);return e===403||typeof n=="string"&&/^INSUFFICIENT_ACCESS/.test(n)||/\bINSUFFICIENT_ACCESS/.test(o)||(n==="INVALID_TYPE"||/\bINVALID_TYPE\b/.test(o))&&/\bOrganization\b/.test(o)}function l(t){if(d(t))return"auth";if(c(t))return"network";if(p(t))return"organizationRefused"}function O(t,n,e){let o=n instanceof Error?n.message:String(n);switch(e){case"auth":return`${t} refused the session SandForge holds for it (${o}): reconnect it \u2014 Reconnect on the Organizations page, or "sf org login web --alias ${t}" for a command line \u2014 then try again.`;case"network":return`${t} did not answer (${o}): try again once it answers.`;case"organizationRefused":return`${t} would not show its Organization record (${o}): reading it takes the View Setup and Configuration permission, which the user SandForge connects as lacks: give it to them, or connect as a user who has it.`}}var g=/\/services\/Soap\//,f=/\/services\/data\/v\d+\.\d+\/jobs\/(?:ingest|query)(?:[/?]|$)/,y=/^\/jobs\/(?:ingest|query)(?:[/?]|$)/;function b(t){let n=typeof t=="string"?t:t?.url??"";return f.test(n)||y.test(n)}function S(t){let n=0;if(typeof t.request!="function")return()=>n;let e=t._transport,o=t.request.bind(t);if(t.request=(...r)=>((e===void 0||!b(r[0]))&&n++,o(...r)),e!==void 0){let r=e.httpRequest.bind(e);e.httpRequest=(...i)=>{let s=i[0].url;return(g.test(s)||f.test(s))&&n++,r(...i)}}return()=>n}export{I as a,h as b,p as c,l as d,O as e,S as f};
7
+ import{a as d}from"./chunk-PPGDAUEQ.mjs";import{a as c}from"./chunk-SU65Z2BA.mjs";import{Wc as a,Yc as u}from"./chunk-6QSHWIZI.mjs";async function I(t){let e=(await t.query("SELECT Id, IsSandbox FROM Organization LIMIT 1")).records[0];if(typeof e?.Id!="string")throw new Error("The org gave no Organization record: whether it is a sandbox cannot be told.");if(e.IsSandbox===!0)return{id:e.Id,sandbox:!0};try{let r=(await t.query("SELECT OrganizationType FROM Organization LIMIT 1")).records[0]?.OrganizationType;return typeof r=="string"&&r!==""?{id:e.Id,sandbox:!1,edition:r}:{id:e.Id,sandbox:!1}}catch{return{id:e.Id,sandbox:!1}}}function h(t){let n=a({isSandbox:t.sandbox,edition:t.edition});return u(n,t.edition)==="production"}function p(t){let{errorCode:n,statusCode:e}=typeof t=="object"&&t!==null?t:{},o=t instanceof Error?t.message:String(t);return e===403||typeof n=="string"&&/^INSUFFICIENT_ACCESS/.test(n)||/\bINSUFFICIENT_ACCESS/.test(o)||(n==="INVALID_TYPE"||/\bINVALID_TYPE\b/.test(o))&&/\bOrganization\b/.test(o)}function l(t){if(d(t))return"auth";if(c(t))return"network";if(p(t))return"organizationRefused"}function O(t,n,e){let o=n instanceof Error?n.message:String(n);switch(e){case"auth":return`${t} refused the session SandForge holds for it (${o}): reconnect it \u2014 Reconnect on the Organizations page, or "sf org login web --alias ${t}" for a command line \u2014 then try again.`;case"network":return`${t} did not answer (${o}): try again once it answers.`;case"organizationRefused":return`${t} would not show its Organization record (${o}): reading it takes the View Setup and Configuration permission, which the user SandForge connects as lacks: give it to them, or connect as a user who has it.`}}var g=/\/services\/Soap\//,f=/\/services\/data\/v\d+\.\d+\/jobs\/(?:ingest|query)(?:[/?]|$)/,y=/^\/jobs\/(?:ingest|query)(?:[/?]|$)/;function b(t){let n=typeof t=="string"?t:t?.url??"";return f.test(n)||y.test(n)}function S(t){let n=0;if(typeof t.request!="function")return()=>n;let e=t._transport,o=t.request.bind(t);if(t.request=(...r)=>((e===void 0||!b(r[0]))&&n++,o(...r)),e!==void 0){let r=e.httpRequest.bind(e);e.httpRequest=(...i)=>{let s=i[0].url;return(g.test(s)||f.test(s))&&n++,r(...i)}}return()=>n}export{I as a,h as b,p as c,l as d,O as e,S as f};
@@ -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{l as i}from"./chunk-O2PUGRNW.mjs";function u(o,t){let n=e=>e==="production"?`${t} is taken for a production org, and this command writes to none`:void 0;return new i({requestConfirmation:(e,d)=>{let r=n(d);return r===void 0?Promise.resolve(!0):(o(`refused: ${r} (${e})`),Promise.resolve(!1))},declinesWithoutAsking:n})}export{u as a};
7
+ import{l as i}from"./chunk-XMQ5R6TC.mjs";function u(o,t){let n=e=>e==="production"?`${t} is taken for a production org, and this command writes to none`:void 0;return new i({requestConfirmation:(e,d)=>{let r=n(d);return r===void 0?Promise.resolve(!0):(o(`refused: ${r} (${e})`),Promise.resolve(!1))},declinesWithoutAsking:n})}export{u as a};
@@ -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{c as B}from"./chunk-BOGNK4LV.mjs";import{d as k,e as A,f as b}from"./chunk-JQZTMFO7.mjs";import{Rb as D,Sb as P,Tb as O,Yb as S,dc as v,hc as x,kc as L}from"./chunk-JFNLKHY6.mjs";import{da as w}from"./chunk-KIMQQ6JQ.mjs";import{Dd as R,Ed as g,Ld as f,Td as p}from"./chunk-ZQO5PDX5.mjs";var C=["undelete","insert","update","delete"],M={SingleEmail:{one:"single email",more:"single emails"},DailyWorkflowEmails:{one:"workflow email",more:"workflow emails"}};function U(e,t){let n=M[t];return`${e} ${e===1?n.one:n.more}`}var I={rewind:{what:"This rewind",then:"rewind again"},undo:{what:"This undo",then:"undo the rewind again"}};function _(e){return e.toGiveBack.records+e.toBringBack.inBin+e.toBringBack.withParent}var N="Order";function T(e){return e.toDelete.createdSince+e.toDelete.broughtBackSince+e.toDelete.comesBackWithParent+(e.toBringBack.carriers??0)}function $(e){return e.objectApiName===N?T(e):0}function W(e){return e.deleted+e.withParentDeleted+e.nextPassDeleted}function F(e){return e.objectApiName===N?W(e):0}function G(e){return w[e.objectApiName]!==void 0?e.toRecreate??0:0}function j(e){return w[e.objectApiName]!==void 0?e.recreated:0}function K(e){return e.flatMap(t=>h(t.objectApiName,{undelete:t.toBringBack.inBin+t.toBringBack.withParent+t.toBringBack.deletedWhileTaken+(t.toBringBack.carriers??0),insert:t.toRecreate??0,update:_(t)+G(t)+$(t),delete:T(t)}))}function Z(e){return e.flatMap(t=>h(t.objectApiName,{undelete:t.broughtBack+t.backWithParent+(t.carriers??0),insert:t.recreated,update:t.givenBackFirst+t.givenBackAfter+t.givenBackNextPass+j(t)+F(t),delete:W(t)}))}function ee(e,t=[],n=[]){let i=a=>{let o=new Map;for(let{objectApiName:m,count:d}of a)o.set(m,(o.get(m)??0)+d);return o},c=i(t),s=i(n);return[...new Set([...e.map(a=>a.objectApiName),...c.keys(),...s.keys()])].flatMap(a=>{let o=e.find(m=>m.objectApiName===a);return h(a,{undelete:o?.deleted??0,insert:0,update:(o?.givenBack??0)+(s.get(a)??0),delete:(o?.broughtBack??0)+(c.get(a)??0)})})}function h(e,t){return C.filter(n=>t[n]>0).map(n=>({objectApiName:e,write:n,records:t[n]}))}function te(e,t){let n=new Set(e.filter(i=>i.records>0).map(i=>`${i.objectApiName}
7
+ import{c as B}from"./chunk-BOGNK4LV.mjs";import{d as k,e as A,f as b}from"./chunk-WXU6ZJIV.mjs";import{Lb as D,Mb as P,Nb as O,Sb as S,Zb as v,bc as x,ec as L}from"./chunk-R3OM3X4L.mjs";import{da as w}from"./chunk-2GSMHGIV.mjs";import{Qd as R,Rd as g,Yd as f,ee as p}from"./chunk-6QSHWIZI.mjs";var C=["undelete","insert","update","delete"],M={SingleEmail:{one:"single email",more:"single emails"},DailyWorkflowEmails:{one:"workflow email",more:"workflow emails"}};function U(e,t){let n=M[t];return`${e} ${e===1?n.one:n.more}`}var I={rewind:{what:"This rewind",then:"rewind again"},undo:{what:"This undo",then:"undo the rewind again"}};function _(e){return e.toGiveBack.records+e.toBringBack.inBin+e.toBringBack.withParent}var N="Order";function T(e){return e.toDelete.createdSince+e.toDelete.broughtBackSince+e.toDelete.comesBackWithParent+(e.toBringBack.carriers??0)}function $(e){return e.objectApiName===N?T(e):0}function W(e){return e.deleted+e.withParentDeleted+e.nextPassDeleted}function F(e){return e.objectApiName===N?W(e):0}function G(e){return w[e.objectApiName]!==void 0?e.toRecreate??0:0}function j(e){return w[e.objectApiName]!==void 0?e.recreated:0}function K(e){return e.flatMap(t=>h(t.objectApiName,{undelete:t.toBringBack.inBin+t.toBringBack.withParent+t.toBringBack.deletedWhileTaken+(t.toBringBack.carriers??0),insert:t.toRecreate??0,update:_(t)+G(t)+$(t),delete:T(t)}))}function Z(e){return e.flatMap(t=>h(t.objectApiName,{undelete:t.broughtBack+t.backWithParent+(t.carriers??0),insert:t.recreated,update:t.givenBackFirst+t.givenBackAfter+t.givenBackNextPass+j(t)+F(t),delete:W(t)}))}function ee(e,t=[],n=[]){let i=a=>{let o=new Map;for(let{objectApiName:m,count:d}of a)o.set(m,(o.get(m)??0)+d);return o},c=i(t),s=i(n);return[...new Set([...e.map(a=>a.objectApiName),...c.keys(),...s.keys()])].flatMap(a=>{let o=e.find(m=>m.objectApiName===a);return h(a,{undelete:o?.deleted??0,insert:0,update:(o?.givenBack??0)+(s.get(a)??0),delete:(o?.broughtBack??0)+(c.get(a)??0)})})}function h(e,t){return C.filter(n=>t[n]>0).map(n=>({objectApiName:e,write:n,records:t[n]}))}function te(e,t){let n=new Set(e.filter(i=>i.records>0).map(i=>`${i.objectApiName}
8
8
  ${i.write}`));return S(t,(i,c)=>n.has(`${i}
9
9
  ${c}`),"the org's")}function ne(e,t){return t===void 0?"":`The emails it sends as the ${e} writes were not counted against its daily limits, as what sends them was not read (${t}). `}function y(e){return typeof e.unread=="string"}function ie(e,t,n){let i=!y(n)&&D(n),c=!y(n)&&P(n),s=new Map;for(let r of C){let a=R(t,r);if(a.length===0)continue;let o=O(a,i,c),m=new Set(a.filter(d=>d.limit==="DailyWorkflowEmails").map(d=>d.objectApiName));for(let{objectApiName:d,records:E}of e.filter(l=>l.write===r))for(let l of o.filter(u=>u.objectApiName===d)){let u=s.get(l.limit)??{limit:l.limit,emails:0,objects:[],verdict:"fits"};u.emails+=E*l.perRecord,u.objects.push({objectApiName:d,write:r,records:E,perRecord:l.perRecord,sentBy:[...l.sentBy]}),i&&l.limit==="SingleEmail"&&m.has(d)&&(u.alertsCounted=!0),s.set(l.limit,u)}}return[...s.values()].map(r=>{if(y(n))return{...r,verdict:"unread",unread:n.unread};let a=n[r.limit];return a?{...r,verdict:r.emails>a.remaining?"exceeds":"fits",remaining:a.remaining,max:a.max}:{...r,verdict:"unread",unread:`the org's limits list no ${r.limit}`}})}function re(e,t,n){let i=t.filter(r=>r.verdict==="exceeds");if(i.length===0)return;let c=i.map(r=>`about ${U(r.emails,r.limit)}`+(r.alertsCounted?" (its email alerts among them, as a Developer Edition counts them)":"")+`, ${r.remaining??0} of ${r.max??0} left today`).join("; "),s=I[e];return{code:"EMAILS",message:`${s.what} would make ${n} send ${c}: past them, each record whose flow fails in the save is refused (CANNOT_EXECUTE_FLOW_TRIGGER), and the org's own emails stop for the rest of the day. Turn off what sends them, or assign the user a bypass that keeps it quiet, then ${s.then}. No record was written.`}}function ae(e){let t=f(e.steps),n=g(p(e.automation,e.plan,t),{writes:t}),i=v(e.automation.unread);return{senders:n,...i!==void 0?{sendersUnread:i}:{}}}function q(e){let t=e.mayMute&&e.plan===void 0&&e.senders.length>0?A(e.automation,{writes:f(e.steps)}):[],n=x({senders:e.senders,...e.sendersUnread!==void 0?{sendersUnread:e.sendersUnread}:{},...e.reading!==void 0?{reading:e.reading}:{},accepted:e.accepted,target:e.orgName,run:e.act,muteQuiets:t,keepsAddresses:!0});return n.stop?{gate:n,refusal:{code:"EMAILS_DELIVERED",message:n.stop.message}}:{gate:n}}async function se(e){let t=f(e.steps),n=await k({running:p(e.automation,e.plan,t),writes:t,read:e.read});return{ofRun:n,...q({...e,senders:n.senders,...n.sendersUnread!==void 0?{sendersUnread:n.sendersUnread}:{},...n.read!==void 0?{reading:n.read.reading}:{}})}}function oe(e){let t=f(e.steps),n=g(p(e.automation,b(e.plan,e.held),t),{writes:t}),i=L({planned:e.planned,held:n,...e.reading!==void 0?{reading:e.reading}:{},accepted:e.accepted,target:e.orgName,run:e.act});return i?{code:"EMAILS_DELIVERED",message:i.message}:void 0}var Q=", or run it again once the lease can assign them",V="--mute-automation keeps quiet";function de(e,t,n){if(e.code!=="EMAILS_DELIVERED")return e;let i=t==="undo"?"Tick the box for these emails in the undo's confirmation to undo all the same":e.message.includes(Q)?"Untick Mute automation to be asked about them and rewind all the same":`Tick "Let ${n} send these emails" in the preview to rewind all the same`;return{...e,message:B(e.message,t,i).replace(V,"Mute automation keeps quiet")}}export{U as a,_ as b,$ as c,F as d,G as e,j as f,K as g,Z as h,ee as i,te as j,ne as k,ie as l,re as m,ae as n,q as o,se as p,oe as q,de as r};