sandforge 1.80.0 → 1.82.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (266) hide show
  1. package/README.md +48 -0
  2. package/bin/sandforge-pipeline.mjs +12 -0
  3. package/bin/sandforge-users.mjs +12 -0
  4. package/lib/{chunk-J525F5KI.mjs → chunk-27Z76O2O.mjs} +1 -1
  5. package/lib/chunk-2JZGCCPG.mjs +9 -0
  6. package/lib/{chunk-ELFXJHU7.mjs → chunk-2UU42PTD.mjs} +1 -1
  7. package/lib/{chunk-N652NMZ4.mjs → chunk-32EUNQT6.mjs} +52 -52
  8. package/lib/chunk-3C2ZZIFN.mjs +7 -0
  9. package/lib/chunk-3CX7GPCR.mjs +7 -0
  10. package/lib/chunk-3HEMJTAP.mjs +925 -0
  11. package/lib/{chunk-BY2HJFFG.mjs → chunk-3HROD5RE.mjs} +1 -1
  12. package/lib/{chunk-OHWNPXWW.mjs → chunk-3MGMNK3Q.mjs} +1 -1
  13. package/lib/{chunk-PZPJKATS.mjs → chunk-3SKLBRPL.mjs} +8 -8
  14. package/lib/chunk-3XG25GTF.mjs +7 -0
  15. package/lib/chunk-42BFLWHR.mjs +7 -0
  16. package/lib/chunk-466F37VD.mjs +7 -0
  17. package/lib/chunk-47UHTN3Q.mjs +7 -0
  18. package/lib/chunk-4JKR4PTZ.mjs +8 -0
  19. package/lib/{chunk-COFG7Q6R.mjs → chunk-52EXDVPN.mjs} +1 -1
  20. package/lib/{chunk-SAR5622P.mjs → chunk-54HYHHVL.mjs} +1 -1
  21. package/lib/{chunk-RSWDYIHY.mjs → chunk-5GBO4KD5.mjs} +1 -1
  22. package/lib/chunk-5K2I2DMP.mjs +11 -0
  23. package/lib/{chunk-AV5SWEHP.mjs → chunk-6FARZYMJ.mjs} +1 -1
  24. package/lib/{chunk-BV6VTP3J.mjs → chunk-6GQUZ4IP.mjs} +1 -1
  25. package/lib/chunk-6KP6WETK.mjs +9 -0
  26. package/lib/{chunk-MJVTDA5Q.mjs → chunk-6VSZNZHH.mjs} +1 -1
  27. package/lib/{chunk-XUWL6ZPC.mjs → chunk-7CVDVBEE.mjs} +1 -1
  28. package/lib/{chunk-UCD54V2M.mjs → chunk-7EYQYZJP.mjs} +1 -1
  29. package/lib/{chunk-5K5VLULK.mjs → chunk-7LKI7OAS.mjs} +1 -1
  30. package/lib/chunk-7PY3VQP3.mjs +7 -0
  31. package/lib/chunk-7SDZR6SR.mjs +7 -0
  32. package/lib/chunk-7WSLT5VX.mjs +8 -0
  33. package/lib/chunk-A32ISQ6M.mjs +28 -0
  34. package/lib/{chunk-M3ROUWDX.mjs → chunk-A65ADTCR.mjs} +1 -1
  35. package/lib/chunk-A7JJWOLT.mjs +7 -0
  36. package/lib/chunk-AUS6NFLZ.mjs +8 -0
  37. package/lib/chunk-BMTNTBBM.mjs +7 -0
  38. package/lib/{chunk-SOU4FRYN.mjs → chunk-BN33LVPQ.mjs} +1 -1
  39. package/lib/chunk-BNKT3R3F.mjs +7 -0
  40. package/lib/{chunk-K2FBZIXY.mjs → chunk-BWWQXU2B.mjs} +1 -1
  41. package/lib/{chunk-IC2C2GOF.mjs → chunk-BXZ73A5M.mjs} +1 -1
  42. package/lib/{chunk-WA7EYLAQ.mjs → chunk-C2N2TNEU.mjs} +1 -1
  43. package/lib/{chunk-BKDV4ENO.mjs → chunk-C3LNYAVJ.mjs} +1 -1
  44. package/lib/{chunk-XLXIPIEW.mjs → chunk-CBL42DUU.mjs} +1 -1
  45. package/lib/chunk-CCEH7L53.mjs +7 -0
  46. package/lib/chunk-CELEBWEZ.mjs +7 -0
  47. package/lib/chunk-CV47FDQW.mjs +7 -0
  48. package/lib/{chunk-2UZPIMUC.mjs → chunk-CZLJZQCS.mjs} +1 -1
  49. package/lib/chunk-DBBPDSFN.mjs +7 -0
  50. package/lib/chunk-DIL62SUN.mjs +7 -0
  51. package/lib/chunk-DIS254AN.mjs +7 -0
  52. package/lib/{chunk-BTWDMNN3.mjs → chunk-DJCGURW7.mjs} +1 -1
  53. package/lib/{chunk-F6GUDTOB.mjs → chunk-DT3T7FRD.mjs} +1 -1
  54. package/lib/{chunk-IGYH7GMA.mjs → chunk-DWMRIWV5.mjs} +1 -1
  55. package/lib/{chunk-YRQGKDHM.mjs → chunk-EEFUE2ES.mjs} +1 -1
  56. package/lib/{chunk-FGRG7ANU.mjs → chunk-EOFO3PHS.mjs} +1 -1
  57. package/lib/{chunk-KBJ5VERV.mjs → chunk-FA4ZKDCU.mjs} +1 -1
  58. package/lib/{chunk-WU3GLFZO.mjs → chunk-FKK5YBGZ.mjs} +1 -1
  59. package/lib/chunk-FOIWWK7G.mjs +156 -0
  60. package/lib/chunk-FZF23M6R.mjs +7 -0
  61. package/lib/chunk-G2JR3F63.mjs +7 -0
  62. package/lib/{chunk-JEERQRLW.mjs → chunk-GBGHJTPC.mjs} +1 -1
  63. package/lib/{chunk-3RZQZHEB.mjs → chunk-GCGHHN4K.mjs} +1 -1
  64. package/lib/{chunk-RPI7LRTW.mjs → chunk-GGNUACTY.mjs} +1 -1
  65. package/lib/{chunk-EMNC6YI4.mjs → chunk-GGUOIDWP.mjs} +1 -1
  66. package/lib/chunk-GHPR5UVV.mjs +7 -0
  67. package/lib/{chunk-X5JYBPXP.mjs → chunk-GJ6SZVHT.mjs} +1 -1
  68. package/lib/{chunk-W622GUAW.mjs → chunk-H4JUYUSL.mjs} +1 -1
  69. package/lib/{chunk-XAMBCQPU.mjs → chunk-H4OBZIX3.mjs} +1 -1
  70. package/lib/{chunk-WIO4XO4F.mjs → chunk-HFSBDM7B.mjs} +1 -1
  71. package/lib/{chunk-L77FJZEP.mjs → chunk-HFUDCNU5.mjs} +1 -1
  72. package/lib/chunk-HIHCYMSL.mjs +7 -0
  73. package/lib/chunk-HKUWHVI7.mjs +9 -0
  74. package/lib/chunk-HQQVANWQ.mjs +20 -0
  75. package/lib/chunk-ICIYL45C.mjs +7 -0
  76. package/lib/chunk-IRZJU2PG.mjs +22 -0
  77. package/lib/chunk-ISSP2FZ5.mjs +7 -0
  78. package/lib/chunk-IVZJSDJD.mjs +7 -0
  79. package/lib/chunk-J24TIGSI.mjs +10 -0
  80. package/lib/{chunk-UNJA4J37.mjs → chunk-JESRFE2Z.mjs} +4 -4
  81. package/lib/chunk-JFNLKHY6.mjs +8 -0
  82. package/lib/chunk-JH27IKCO.mjs +9 -0
  83. package/lib/chunk-JJITOWZK.mjs +7 -0
  84. package/lib/{chunk-E5AHXLS6.mjs → chunk-JKT5YAQ2.mjs} +1 -1
  85. package/lib/{chunk-IWDREM66.mjs → chunk-JLZRZL5E.mjs} +1 -1
  86. package/lib/{chunk-FPKYYFM7.mjs → chunk-JPEVIXNH.mjs} +1 -1
  87. package/lib/chunk-JQZTMFO7.mjs +7 -0
  88. package/lib/chunk-KIMQQ6JQ.mjs +7 -0
  89. package/lib/{chunk-MILU7WFN.mjs → chunk-KJYEQHYP.mjs} +1 -1
  90. package/lib/chunk-KKOA62S4.mjs +474 -0
  91. package/lib/chunk-KP5G6FUC.mjs +7 -0
  92. package/lib/{chunk-JWTSEDIQ.mjs → chunk-L4INJ5TZ.mjs} +1 -1
  93. package/lib/{chunk-OLSGVAIL.mjs → chunk-LAUOSXMN.mjs} +53 -53
  94. package/lib/{chunk-MTMH6H2A.mjs → chunk-LCDPCUXS.mjs} +1 -1
  95. package/lib/{chunk-KDGMAGQR.mjs → chunk-LHU6CPGE.mjs} +1 -1
  96. package/lib/{chunk-YAZO75G2.mjs → chunk-LNXBCE7E.mjs} +1 -1
  97. package/lib/chunk-LXDSRP2W.mjs +7 -0
  98. package/lib/{chunk-2YIV2OB2.mjs → chunk-MIDBQ7SD.mjs} +1 -1
  99. package/lib/{chunk-TTKXMDBN.mjs → chunk-MKTXJCXN.mjs} +4 -4
  100. package/lib/chunk-MUEQRIK7.mjs +9 -0
  101. package/lib/{chunk-IOIWJ3DJ.mjs → chunk-NLB3RGIY.mjs} +1 -1
  102. package/lib/{chunk-O2HDYYUV.mjs → chunk-NWOI25WY.mjs} +1 -1
  103. package/lib/chunk-O2PUGRNW.mjs +10 -0
  104. package/lib/chunk-O4BROUGM.mjs +7 -0
  105. package/lib/chunk-OETEC3P7.mjs +7 -0
  106. package/lib/{chunk-GCOB7K5N.mjs → chunk-OHEOJISY.mjs} +1 -1
  107. package/lib/chunk-P55MKIZX.mjs +37 -0
  108. package/lib/chunk-P63WJMXQ.mjs +7 -0
  109. package/lib/chunk-PBE44M2Y.mjs +7 -0
  110. package/lib/{chunk-TYYOBZMU.mjs → chunk-PC247GKX.mjs} +1 -1
  111. package/lib/chunk-PE435FVH.mjs +15 -0
  112. package/lib/chunk-PPGDAUEQ.mjs +7 -0
  113. package/lib/{chunk-SE4QEZUG.mjs → chunk-PPHVWUFY.mjs} +1 -1
  114. package/lib/{chunk-CU2INBND.mjs → chunk-PR74GYVI.mjs} +1 -1
  115. package/lib/chunk-PWVDNN2C.mjs +7 -0
  116. package/lib/{chunk-6XYKJSGX.mjs → chunk-PYRZFUVU.mjs} +1 -1
  117. package/lib/{chunk-TLH7AD35.mjs → chunk-PZBZ7MNC.mjs} +1 -1
  118. package/lib/{chunk-DYFALGRT.mjs → chunk-Q3DY7TO2.mjs} +1 -1
  119. package/lib/{chunk-BGUEWRK2.mjs → chunk-Q6SXNKV2.mjs} +1 -1
  120. package/lib/chunk-QAPVKPEC.mjs +7 -0
  121. package/lib/{chunk-DBFJB2B6.mjs → chunk-QIRO4HTE.mjs} +1 -1
  122. package/lib/{chunk-TSLJUSLW.mjs → chunk-RCYEBY42.mjs} +1 -1
  123. package/lib/chunk-RLWB7F26.mjs +7 -0
  124. package/lib/{chunk-FXXLX4O6.mjs → chunk-RTWYLOCA.mjs} +1 -1
  125. package/lib/chunk-RYRMUPMY.mjs +7 -0
  126. package/lib/chunk-SAMWHL22.mjs +13 -0
  127. package/lib/{chunk-IZQZ6ZUF.mjs → chunk-SFGZFB4F.mjs} +1 -1
  128. package/lib/{chunk-FKG7Q3WH.mjs → chunk-SNEOKYV7.mjs} +1 -1
  129. package/lib/{chunk-3TJON4F3.mjs → chunk-STRMWSIQ.mjs} +1 -1
  130. package/lib/chunk-SZGGFST2.mjs +272 -0
  131. package/lib/{chunk-SOGQW4IG.mjs → chunk-T7WREYA5.mjs} +1 -1
  132. package/lib/{chunk-NTFIRZP6.mjs → chunk-TCBAE65A.mjs} +1 -1
  133. package/lib/{chunk-KYEDBS54.mjs → chunk-TEIBWMJM.mjs} +1 -1
  134. package/lib/{chunk-YKKRIEH4.mjs → chunk-TMA34QMA.mjs} +1 -1
  135. package/lib/chunk-TQ2TQHTT.mjs +9 -0
  136. package/lib/{chunk-HEKAZJRH.mjs → chunk-TWV4A5RK.mjs} +1 -1
  137. package/lib/{chunk-CEX3NEZL.mjs → chunk-UHFLKP26.mjs} +1 -1
  138. package/lib/chunk-UV74P4H2.mjs +7 -0
  139. package/lib/{chunk-WR4Q363I.mjs → chunk-V3R45ZWT.mjs} +1 -1
  140. package/lib/{chunk-GSKCGQIP.mjs → chunk-VPDEJGPS.mjs} +1 -1
  141. package/lib/{chunk-HLWMJF6Y.mjs → chunk-VQJMP3DC.mjs} +1 -1
  142. package/lib/chunk-VV3B6IC3.mjs +7 -0
  143. package/lib/{chunk-PJ5I73CK.mjs → chunk-VYOYXTCU.mjs} +1 -1
  144. package/lib/{chunk-NZC67CGR.mjs → chunk-VZT4E2OJ.mjs} +1 -1
  145. package/lib/{chunk-AEKONPF4.mjs → chunk-VZVICK7Q.mjs} +1 -1
  146. package/lib/{chunk-WR2GIKWE.mjs → chunk-WB2RIVO3.mjs} +1 -1
  147. package/lib/chunk-WEMLDUQA.mjs +7 -0
  148. package/lib/{chunk-MYW5QNGI.mjs → chunk-WOOUISSO.mjs} +1 -1
  149. package/lib/{chunk-G35N4P7D.mjs → chunk-WSUKC2U3.mjs} +1 -1
  150. package/lib/{chunk-ZVAED4QV.mjs → chunk-WT3SCUHS.mjs} +1 -1
  151. package/lib/{chunk-7EANH5PY.mjs → chunk-WZQEK4WT.mjs} +1 -1
  152. package/lib/{chunk-DBB3EMIN.mjs → chunk-XFU3HRUV.mjs} +1 -1
  153. package/lib/chunk-XK5W7BVE.mjs +7 -0
  154. package/lib/{chunk-2GTBABKU.mjs → chunk-XO5FBOQF.mjs} +1 -1
  155. package/lib/{chunk-CHYDMRSV.mjs → chunk-XSKPYGMT.mjs} +1 -1
  156. package/lib/chunk-XU25YA46.mjs +9 -0
  157. package/lib/chunk-XZISAZA6.mjs +7 -0
  158. package/lib/chunk-Y4TDVDP2.mjs +13 -0
  159. package/lib/chunk-YAIIRFKJ.mjs +8 -0
  160. package/lib/{chunk-LKQ5RKIV.mjs → chunk-YAJQS3OL.mjs} +1 -1
  161. package/lib/{chunk-74Q6DORA.mjs → chunk-YGJF55VJ.mjs} +1 -1
  162. package/lib/chunk-YH4DYI6D.mjs +7 -0
  163. package/lib/chunk-YMDFF657.mjs +10 -0
  164. package/lib/{chunk-2BA2XKAY.mjs → chunk-YT22LMF7.mjs} +1 -1
  165. package/lib/{chunk-IG2MTQRP.mjs → chunk-Z42PHCVZ.mjs} +1 -1
  166. package/lib/{chunk-2NBYT7GR.mjs → chunk-ZHIZY3ZC.mjs} +1 -1
  167. package/lib/chunk-ZQO5PDX5.mjs +48 -0
  168. package/lib/chunk-ZRUDYB7O.mjs +7 -0
  169. package/lib/{chunk-BXU6WFMH.mjs → chunk-ZUBBEP75.mjs} +1 -1
  170. package/lib/chunk-ZUOPC4W2.mjs +7 -0
  171. package/lib/{chunk-GGD7ON3M.mjs → chunk-ZUTUYBNW.mjs} +1 -1
  172. package/lib/{chunk-MHMH6MTP.mjs → chunk-ZXFL2MSN.mjs} +1 -1
  173. package/lib/sandforge-autopilot.mjs +11 -11
  174. package/lib/sandforge-backup.mjs +63 -32
  175. package/lib/sandforge-checkpoint.mjs +1 -348
  176. package/lib/sandforge-cleanup.mjs +1 -1
  177. package/lib/sandforge-clone.mjs +1 -1
  178. package/lib/sandforge-compare.mjs +1 -1
  179. package/lib/sandforge-dataops.mjs +1 -1
  180. package/lib/sandforge-empty.mjs +11 -11
  181. package/lib/sandforge-env.mjs +186 -140
  182. package/lib/sandforge-frozen.mjs +1 -266
  183. package/lib/sandforge-mcp.mjs +33 -14
  184. package/lib/sandforge-monitor.mjs +1 -1
  185. package/lib/sandforge-pipeline.mjs +88 -0
  186. package/lib/sandforge-seed.mjs +1 -1
  187. package/lib/sandforge-sync.mjs +1 -1
  188. package/lib/sandforge-users.mjs +157 -0
  189. package/lib/sandforge.mjs +1 -22
  190. package/lib/sf/sandforge/autopilot.mjs +20 -0
  191. package/lib/sf/sandforge/backup.mjs +20 -0
  192. package/lib/sf/sandforge/checkpoint.mjs +20 -0
  193. package/lib/sf/sandforge/cleanup.mjs +20 -0
  194. package/lib/sf/sandforge/clone.mjs +20 -0
  195. package/lib/sf/sandforge/compare.mjs +20 -0
  196. package/lib/sf/sandforge/dataops.mjs +20 -0
  197. package/lib/sf/sandforge/empty.mjs +20 -0
  198. package/lib/sf/sandforge/env.mjs +20 -0
  199. package/lib/sf/sandforge/frozen.mjs +20 -0
  200. package/lib/sf/sandforge/hardis-commands.mjs +20 -0
  201. package/lib/sf/sandforge/index.mjs +20 -0
  202. package/lib/sf/sandforge/mcp.mjs +20 -0
  203. package/lib/sf/sandforge/monitor.mjs +20 -0
  204. package/lib/sf/sandforge/pipeline.mjs +20 -0
  205. package/lib/sf/sandforge/seed.mjs +20 -0
  206. package/lib/sf/sandforge/sync.mjs +20 -0
  207. package/lib/sf/sandforge/users.mjs +20 -0
  208. package/lib/sfHelpHook.mjs +7 -0
  209. package/lib/sfPlugin.mjs +11 -0
  210. package/oclif.manifest.json +1 -0
  211. package/package.json +18 -3
  212. package/lib/chunk-2CNCDM56.mjs +0 -7
  213. package/lib/chunk-3F6Q5E7I.mjs +0 -14
  214. package/lib/chunk-4VS2V6WU.mjs +0 -25
  215. package/lib/chunk-5P4PHJRL.mjs +0 -9
  216. package/lib/chunk-5TC3QB4U.mjs +0 -10
  217. package/lib/chunk-7ABODJ4G.mjs +0 -7
  218. package/lib/chunk-7EGQP6S4.mjs +0 -7
  219. package/lib/chunk-7FFGJWHN.mjs +0 -7
  220. package/lib/chunk-7YDNUBO5.mjs +0 -7
  221. package/lib/chunk-A527W53V.mjs +0 -7
  222. package/lib/chunk-ADOAS63R.mjs +0 -7
  223. package/lib/chunk-B5QQJ4SI.mjs +0 -7
  224. package/lib/chunk-CION3VMZ.mjs +0 -7
  225. package/lib/chunk-CSBS5U5I.mjs +0 -7
  226. package/lib/chunk-DB7RBE5D.mjs +0 -7
  227. package/lib/chunk-E5ZB3LU5.mjs +0 -7
  228. package/lib/chunk-EFR2Y7E4.mjs +0 -7
  229. package/lib/chunk-EHQ3FX6X.mjs +0 -7
  230. package/lib/chunk-EQNW3UC2.mjs +0 -7
  231. package/lib/chunk-F43REJDZ.mjs +0 -10
  232. package/lib/chunk-GSG7WZHM.mjs +0 -7
  233. package/lib/chunk-HOJYWTP7.mjs +0 -20
  234. package/lib/chunk-HS4YRX4J.mjs +0 -7
  235. package/lib/chunk-I7O6C2B5.mjs +0 -8
  236. package/lib/chunk-IFETCRWE.mjs +0 -10
  237. package/lib/chunk-IQXHJEYB.mjs +0 -7
  238. package/lib/chunk-JPUR2CFX.mjs +0 -10
  239. package/lib/chunk-K327QKMD.mjs +0 -7
  240. package/lib/chunk-KRCA6IPH.mjs +0 -8
  241. package/lib/chunk-LPBMBW3O.mjs +0 -13
  242. package/lib/chunk-LWW4U276.mjs +0 -7
  243. package/lib/chunk-MFG4MUIO.mjs +0 -9
  244. package/lib/chunk-MJU2PGZQ.mjs +0 -15
  245. package/lib/chunk-OAZRPP4I.mjs +0 -7
  246. package/lib/chunk-OO6CLPEH.mjs +0 -7
  247. package/lib/chunk-OPXCV2KL.mjs +0 -7
  248. package/lib/chunk-P33PSCXK.mjs +0 -7
  249. package/lib/chunk-Q3DM32KF.mjs +0 -11
  250. package/lib/chunk-QR3WELJQ.mjs +0 -7
  251. package/lib/chunk-QWT2C74M.mjs +0 -7
  252. package/lib/chunk-R3X3LV64.mjs +0 -14
  253. package/lib/chunk-RMBPOTD7.mjs +0 -7
  254. package/lib/chunk-SIHORWVK.mjs +0 -7
  255. package/lib/chunk-T62WNR54.mjs +0 -7
  256. package/lib/chunk-TTFDUKUS.mjs +0 -47
  257. package/lib/chunk-VE6XKGGD.mjs +0 -7
  258. package/lib/chunk-VGW4MXXZ.mjs +0 -7
  259. package/lib/chunk-VS7ZXUII.mjs +0 -824
  260. package/lib/chunk-VXQLDM4R.mjs +0 -7
  261. package/lib/chunk-VYXMVJL5.mjs +0 -7
  262. package/lib/chunk-W7U5E5ZL.mjs +0 -9
  263. package/lib/chunk-WXAQ7FK3.mjs +0 -115
  264. package/lib/chunk-YS4G22C2.mjs +0 -7
  265. package/lib/chunk-ZM6OJGIG.mjs +0 -7
  266. package/lib/chunk-ZUTYVST5.mjs +0 -7
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{a as c,b as f,c as p}from"./chunk-QIRO4HTE.mjs";import{createHmac as g,randomBytes as d}from"node:crypto";function k(o){let t=o.truncateLength;return typeof t=="number"&&Number.isFinite(t)&&t>0?Math.floor(t):0}function R(o,t){let e=o.maskKeepLast;if(typeof e!="number"||!Number.isFinite(e)||e<=0)return 0;let n=Math.floor(e);return t>n?n:0}var m=/^[^\s@]+@[^\s@]+$/,h="example.invalid";function A(o){let t=o.lastIndexOf("@");return`${t===-1?o:o.slice(0,t)}@${h}`}var u=class extends Error{constructor(t){super(`Hash rule for ${t} has no hashSalt. The values being hashed are low-entropy PII (emails, phone numbers, names), so an unkeyed digest is recovered by enumeration in seconds. Set config.hashSalt to a secret value.`),this.name="MissingHashSaltError"}},y=class{personaRegistry;fallbackKey;constructor(t,e){this.fallbackKey=e??d(32).toString("hex"),this.personaRegistry=t??new p(this.fallbackKey)}saltedRegistries=new Map;registryFor(t){let e=t.config.hashSalt;if(!e)return this.personaRegistry;let n=this.saltedRegistries.get(e);return n||(n=new p(e),this.saltedRegistries.set(e,n)),n}namesGiven(){return this.personaRegistry.namesGiven()}continueFrom(t){return this.personaRegistry.continueFrom(t)}forgetRecords(){this.personaRegistry.forgetRecords();for(let t of this.saltedRegistries.values())t.forgetRecords()}peopleHeld(){let t=this.personaRegistry.size;for(let e of this.saltedRegistries.values())t+=e.size;return t}anonymize(t,e){return t.map(n=>{let i={...n},r=String(n.Id??n.id??"");for(let s of e)s.fieldApiName in i&&(i[s.fieldApiName]=this.applyRule(i[s.fieldApiName],s,r));return i})}applyRule(t,e,n=""){let r={mask:(s,a)=>this.applyMask(s,a),hash:(s,a)=>this.applyHash(s,a),fake:(s,a)=>this.applyFake(s,a,n),nullify:()=>null,shuffle:(s,a)=>this.applyShuffle(s,a),truncate:(s,a)=>this.applyTruncate(s,a),constant:(s,a)=>a.config.constantValue??"",preserve_format:s=>this.applyPreserveFormat(s)}[e.method];return r?r(t,e):t}preview(t,e,n){let i=t.slice(0,Math.max(0,n));return this.anonymize(i,e)}validateRules(t){let e=[];for(let n of t)n.fieldApiName||e.push("Rule must specify a fieldApiName"),n.objectApiName||e.push("Rule must specify an objectApiName"),n.method==="mask"&&!n.config.maskChar&&e.push(`Mask rule for ${n.fieldApiName} must specify a maskChar`),n.method==="hash"&&n.config.hashAlgorithm!=="sha256"&&n.config.hashAlgorithm!=="md5"&&e.push(`Hash rule for ${n.fieldApiName} must specify hashAlgorithm as sha256 or md5`),n.method==="hash"&&!n.config.hashSalt&&e.push(`Hash rule for ${n.fieldApiName} must specify a hashSalt \u2014 an unkeyed digest of low-entropy PII is trivially reversible`),n.method==="constant"&&n.config.constantValue===void 0&&e.push(`Constant rule for ${n.fieldApiName} must specify a constantValue`);return e}applyMask(t,e){let n=String(t??""),i=e.config.maskChar??"*",r=e.config.maskStart??0,s=e.config.maskEnd??n.length-R(e.config,n.length),a=n.split("");for(let l=r;l<Math.min(s,a.length);l++)a[l]=i;return a.join("")}applyHash(t,e){let n=e.config.hashSalt;if(!n)throw new u(e.fieldApiName);let i=e.config.hashAlgorithm??"sha256",r=String(t??""),s=g(i,n).update(r).digest("hex").slice(0,32);return m.test(r)?`${i}-${s}@${h}`:`${i}:${s}`}applyFake(t,e,n){let i=n!==""?n:this.keyedDigest(String(t??""),e),r=this.registryFor(e).getPersona(i),s=c[e.fieldApiName];if(s==="email")return A(r.email);if(s)return r[s];let a=this.keyedDigest(`${e.fieldApiName}:${i}`,e).slice(0,8);return m.test(String(t??""))?`fake-${a}@${h}`:`fake_${a}`}applyShuffle(t,e){return f(String(t??""),e.config.hashSalt??this.fallbackKey)}applyTruncate(t,e){let n=k(e.config);if(n===0)return"";let i=String(t??"");return e.config.truncateKeep==="first"?i.slice(0,n):i.slice(-n)}keyedDigest(t,e){return g("sha256",e.config.hashSalt??this.fallbackKey).update(t).digest("hex")}applyPreserveFormat(t){return String(t??"").replace(/[a-zA-Z]/g,"x").replace(/[0-9]/g,"0")}};export{u as a,y 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{i as g}from"./chunk-TTFDUKUS.mjs";var f=class{link(n,r,i,t){return t.length===0?n:n.map(o=>({...o,[r]:t[Math.floor(Math.random()*t.length)]}))}resolveInsertOrder(n,r=[]){let i=new Map;for(let e of n)i.set(e.objectApiName,e);let t=new Set,o=new Set,d=[];function c(e){if(t.has(e))return;if(o.has(e))throw new Error(`Circular dependency detected involving: ${e}`);o.add(e);let s=i.get(e);if(s){let p=g(s,r);for(let j of p)c(j);d.push(s)}o.delete(e),t.add(e)}for(let e of n)c(e.objectApiName);return d}};export{f as a};
7
+ import{j as g}from"./chunk-ZQO5PDX5.mjs";var f=class{link(n,r,i,t){return t.length===0?n:n.map(o=>({...o,[r]:t[Math.floor(Math.random()*t.length)]}))}resolveInsertOrder(n,r=[]){let i=new Map;for(let e of n)i.set(e.objectApiName,e);let t=new Set,o=new Set,d=[];function c(e){if(t.has(e))return;if(o.has(e))throw new Error(`Circular dependency detected involving: ${e}`);o.add(e);let s=i.get(e);if(s){let p=g(s,r);for(let j of p)c(j);d.push(s)}o.delete(e),t.add(e)}for(let e of n)c(e.objectApiName);return d}};export{f as a};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{a as 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};
@@ -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 S,b as k}from"./chunk-UNDIBZWG.mjs";import{tb as m,ub as z,vb as E,wb as h}from"./chunk-TTFDUKUS.mjs";import{b as c,f as g,i as f,k as l,l as d}from"./chunk-7EANH5PY.mjs";var D=/\bid\.?\s*:\s*([A-Za-z0-9]{18}|[A-Za-z0-9]{15})(?![A-Za-z0-9])/i;function x(e,s){let t;if(/^[A-Za-z0-9]{15}$/.test(e))t=S(e);else if(k(e))t=e;else return;if(!(s&&!t.startsWith(s)))return t}function v(e){return D.exec(e)?.[1]}var R=d({statusCode:c().optional(),errorCode:c().optional(),message:c().optional(),fields:l(f()).optional(),duplicateResult:f().optional()}).loose(),p="UNKNOWN_ERROR";function y(e){if(typeof e=="string")return{statusCode:p,message:e,fields:[]};let s=R.safeParse(e);return s.success?{statusCode:s.data.statusCode??s.data.errorCode??p,message:s.data.message??"",fields:(s.data.fields??[]).filter(t=>typeof t=="string")}:{statusCode:p,message:"Unknown error",fields:[]}}var _=/^([A-Z][A-Z0-9_]*):([\s\S]*):([A-Za-z0-9_]+(?: [A-Za-z0-9_]+)*)? ?--$/;function M(e){let s=e.trim();if(!s.endsWith("--")||s.slice(0,-2).includes("--"))return;let t=_.exec(s);if(t)return{statusCode:t[1],message:t[2],fields:t[3]===void 0?[]:t[3].split(" ")}}var b=d({matchResults:l(d({entityType:c().optional(),matchRecords:l(d({record:d({Id:c().optional(),attributes:d({type:c().optional()}).loose().optional()}).loose().optional()}).loose()).optional()}).loose()).optional()}).loose(),I=d({id:c().nullish(),success:g(),created:g().optional(),errors:l(f()).optional()}).loose();function P(e){return e.statusCode===p?e.message:`${e.statusCode}: ${e.message}`}function A(e){if(typeof e=="string")return e;let s=R.safeParse(e);if(!s.success)return"Unknown error";let t=s.data.statusCode??s.data.errorCode,n=s.data.message??"",r=t?`${t}: ${n}`:n,i=(s.data.fields??[]).filter(a=>typeof a=="string");if(i.length===0)return r;let o=`[${i.join(", ")}]`;return r.includes(o)?r:r?`${r} ${o}`:o}var C=5;function T(e){let s=(e??[]).map(r=>A(r)).filter(r=>r!==""&&r!=="Unknown error");if(s.length===0)return"Unknown insert error";let t=s.slice(0,C).join("; "),n=s.length-C;return n>0?`${t} (and ${n} more)`:t}function O(e,s){let t=R.safeParse(e);if(!t.success)return[];if((t.data.statusCode??t.data.errorCode)!==m)return[];let n=b.safeParse(t.data.duplicateResult);if(!n.success)return[];let r=[];for(let i of n.data.matchResults??[])for(let{record:o}of i.matchRecords??[]){let a=[i.entityType,o?.attributes?.type].filter(u=>typeof u=="string");a.length===0||a.some(u=>u!==s)||o?.Id&&r.push(o.Id)}return r}function w(e,s){let t=I.safeParse(e);if(!t.success){let i="Salesforce returned a save result of an unexpected shape";return{id:"",success:!1,errors:[i],errorDetails:[y(i)]}}let n=t.data.errors??[],r=n.flatMap(i=>O(i,s));return{id:t.data.id??"",success:t.data.success,...t.data.created!==void 0?{created:t.data.created}:{},errors:n.map(A),errorDetails:n.map(y),...r.length>0?{duplicateMatchIds:r}:{}}}function Z(e,s){return(Array.isArray(e)?e:[e]).map(t=>w(t,s))}function L(e,s){if(e.success||e.errors.length===0)return{kind:"none"};let t=o=>h(o)||z(o);if(!e.errors.every(t))return{kind:"none"};let n=new Set,r=!1;for(let o of e.errors){if(!o.includes(E))continue;let a=v(o),u=a?x(a,s):void 0;u?n.add(u):r=!0}let i=e.duplicateMatchIds??[];e.errors.some(o=>o.includes(m))&&i.length===0&&(r=!0);for(let o of i){let a=x(o,s);a?n.add(a):r=!0}return r||n.size!==1?{kind:"unidentified"}:{kind:"linked",id:[...n][0]}}export{x as a,p as b,y as c,M as d,P as e,A as f,T as g,O as h,w as i,Z as j,L as k};
7
+ import{a as S,b as k}from"./chunk-UNDIBZWG.mjs";import{dc as m,ec as z,fc as E,gc as h}from"./chunk-ZQO5PDX5.mjs";import{b as c,f as g,i as f,k as l,l as d}from"./chunk-WZQEK4WT.mjs";var D=/\bid\.?\s*:\s*([A-Za-z0-9]{18}|[A-Za-z0-9]{15})(?![A-Za-z0-9])/i;function x(e,s){let t;if(/^[A-Za-z0-9]{15}$/.test(e))t=S(e);else if(k(e))t=e;else return;if(!(s&&!t.startsWith(s)))return t}function v(e){return D.exec(e)?.[1]}var R=d({statusCode:c().optional(),errorCode:c().optional(),message:c().optional(),fields:l(f()).optional(),duplicateResult:f().optional()}).loose(),p="UNKNOWN_ERROR";function y(e){if(typeof e=="string")return{statusCode:p,message:e,fields:[]};let s=R.safeParse(e);return s.success?{statusCode:s.data.statusCode??s.data.errorCode??p,message:s.data.message??"",fields:(s.data.fields??[]).filter(t=>typeof t=="string")}:{statusCode:p,message:"Unknown error",fields:[]}}var _=/^([A-Z][A-Z0-9_]*):([\s\S]*):([A-Za-z0-9_]+(?: [A-Za-z0-9_]+)*)? ?--$/;function M(e){let s=e.trim();if(!s.endsWith("--")||s.slice(0,-2).includes("--"))return;let t=_.exec(s);if(t)return{statusCode:t[1],message:t[2],fields:t[3]===void 0?[]:t[3].split(" ")}}var b=d({matchResults:l(d({entityType:c().optional(),matchRecords:l(d({record:d({Id:c().optional(),attributes:d({type:c().optional()}).loose().optional()}).loose().optional()}).loose()).optional()}).loose()).optional()}).loose(),I=d({id:c().nullish(),success:g(),created:g().optional(),errors:l(f()).optional()}).loose();function P(e){return e.statusCode===p?e.message:`${e.statusCode}: ${e.message}`}function A(e){if(typeof e=="string")return e;let s=R.safeParse(e);if(!s.success)return"Unknown error";let t=s.data.statusCode??s.data.errorCode,n=s.data.message??"",r=t?`${t}: ${n}`:n,i=(s.data.fields??[]).filter(a=>typeof a=="string");if(i.length===0)return r;let o=`[${i.join(", ")}]`;return r.includes(o)?r:r?`${r} ${o}`:o}var C=5;function T(e){let s=(e??[]).map(r=>A(r)).filter(r=>r!==""&&r!=="Unknown error");if(s.length===0)return"Unknown insert error";let t=s.slice(0,C).join("; "),n=s.length-C;return n>0?`${t} (and ${n} more)`:t}function O(e,s){let t=R.safeParse(e);if(!t.success)return[];if((t.data.statusCode??t.data.errorCode)!==m)return[];let n=b.safeParse(t.data.duplicateResult);if(!n.success)return[];let r=[];for(let i of n.data.matchResults??[])for(let{record:o}of i.matchRecords??[]){let a=[i.entityType,o?.attributes?.type].filter(u=>typeof u=="string");a.length===0||a.some(u=>u!==s)||o?.Id&&r.push(o.Id)}return r}function w(e,s){let t=I.safeParse(e);if(!t.success){let i="Salesforce returned a save result of an unexpected shape";return{id:"",success:!1,errors:[i],errorDetails:[y(i)]}}let n=t.data.errors??[],r=n.flatMap(i=>O(i,s));return{id:t.data.id??"",success:t.data.success,...t.data.created!==void 0?{created:t.data.created}:{},errors:n.map(A),errorDetails:n.map(y),...r.length>0?{duplicateMatchIds:r}:{}}}function Z(e,s){return(Array.isArray(e)?e:[e]).map(t=>w(t,s))}function L(e,s){if(e.success||e.errors.length===0)return{kind:"none"};let t=o=>h(o)||z(o);if(!e.errors.every(t))return{kind:"none"};let n=new Set,r=!1;for(let o of e.errors){if(!o.includes(E))continue;let a=v(o),u=a?x(a,s):void 0;u?n.add(u):r=!0}let i=e.duplicateMatchIds??[];e.errors.some(o=>o.includes(m))&&i.length===0&&(r=!0);for(let o of i){let a=x(o,s);a?n.add(a):r=!0}return r||n.size!==1?{kind:"unidentified"}:{kind:"linked",id:[...n][0]}}export{x as a,p as b,y as c,M as d,P as e,A as f,T as g,O as h,w as i,Z as j,L as k};
@@ -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{S as N}from"./chunk-JPUR2CFX.mjs";import{a as j,h as D}from"./chunk-TZE3Y7IQ.mjs";import{b as J}from"./chunk-CA5NAXSU.mjs";function se(e){return`sync-before-${e.replace(/[^A-Za-z0-9-]+/g,"-")}`.slice(0,200)}var oe=1e3;function he(e){let o=se(e.runId),d=new Map,a=e.everyMs??oe,g=()=>(e.now?.()??new Date).getTime(),S,I=Number.NEGATIVE_INFINITY,k,E=!1,R=h=>{if(S===void 0)return;let t=[...d].map(([l,c])=>({objectApiName:l,recordCount:c,truncated:!1}));e.meta.set(`backup:${o}`,{operationId:o,orgId:e.orgId,...e.organizationId!==void 0?{organizationId:e.organizationId}:{},objects:t,partial:h,timestamp:S,totalRecords:t.reduce((l,c)=>l+c.recordCount,0),origin:"sync",runId:e.runId},"backups")},z=()=>{if(E)return;let h=I+a-g();if(h<=0){k!==void 0&&clearTimeout(k),k=void 0,I=g(),R(!0);return}k??=setTimeout(()=>{if(k=void 0,!E){I=g();try{R(!0)}catch{}}},h),k.unref?.()};return{id:o,keep:async(h,t)=>{t.length!==0&&(d.has(h)||(S??=(e.now?.()??new Date).toISOString(),d.set(h,0),R(!0),await e.files.begin(o,h)),await e.files.append(o,h,t),d.set(h,(d.get(h)??0)+t.length),z())},close:()=>{E=!0,k!==void 0&&clearTimeout(k),k=void 0,R(!1)}}}var F=200,de=["LastModifiedDate","LastModifiedById"],ee=100,te=4e3,ae=20,ne=255;function ce(e=ne){return 2*Math.max(0,e)+2}function ke(e,o){let d=o===void 0||o.creatable.size+4>ee;if(e.toLowerCase()==="id")return{characters:ae,wide:d};let a=o?.fields?.find(g=>g.name.toLowerCase()===e.toLowerCase());return a&&["double","int","long","currency","percent"].includes(a.type??"")?{characters:(a.precision??a.digits??18)+2,wide:d}:{characters:ce(a?.length??ne),wide:d}}function fe(e){let o=e.wide?F/4:F,d=Math.floor((te+2)/(Math.max(1,e.characters)+2));return Math.max(1,Math.min(o,d))}function me(e,o){let d=fe(o),a=e.reduce((g,S)=>g+Math.ceil(Math.max(0,S)/d),0);return a>0?a+1:0}function u(e){return e.slice(0,15)}function U(e,o){if(typeof e=="number"&&Number.isFinite(e))return`#${e}`;if(!(typeof e!="string"||e===""))return o?u(e):e.toLowerCase()}function ue(e){return typeof e=="number"?String(e):`'${j(String(e))}'`}function ge(e,o){let d=[],a=[],g=0;for(let S of e){let I=ue(S);a.length>0&&(a.length>=o||g+I.length>te)&&(d.push(a),a=[],g=0),a.push(I),g+=I.length+2}return a.length>0&&d.push(a),d}function le(e,o,d){return`What these ${o} ${e} record(s) would write over in the target could not be read and kept first (${J(d)}), so none of them was written: a run writes over nothing it cannot put back.`}function Se(e){let o=new Map,d=new Map,a=new Set,g=new Map,S=new Map,I=new Map,k=new Map,E=new Map,R=new Map,z=t=>{let l=e.describe,c=e.viewsEncrypted;if(!l||!c)return Promise.resolve(new Set);let y=I.get(t);return y||(y=l(t).then(async f=>{let m=(f.fields??[]).filter(M=>M.type===N).map(M=>M.name);return m.length>0&&!await c()?new Set(m):new Set},()=>new Set),I.set(t,y)),y},h=t=>{let l=e.describe;if(!l)return Promise.resolve(new Set);let c=S.get(t);return c||(c=l(t).then(y=>new Set((y.fields??[]).filter(f=>f.type==="base64"||f.queryable===!1).map(f=>f.name)),()=>new Set),S.set(t,c)),c};return{before:async(t,l,c,y)=>{if(g.delete(t),l!=="update"&&l!=="upsert"||c.length===0)return;let f=l==="update"?"Id":y??"Id",m=f==="Id";try{D(t),D(f);let M=await h(t),p=await z(t),v=new Set,O=new Set,T=new Map;for(let n of c){let i=U(n[f],m);i!==void 0&&!T.has(i)&&T.set(i,n[f]);for(let[r,s]of Object.entries(n))if(!(r==="Id"||r===f||r==="attributes")&&!M.has(r)&&!(typeof s=="object"&&s!==null)){if(p.has(r)){O.add(r);continue}v.add(D(r))}}if(T.size===0||v.size===0&&O.size===0)return;let x=["Id",...m?[]:[f],...v],V=[...x,...de.filter(n=>!x.includes(n))],re=V.length>ee?F/4:F,$=new Map,P=R.get(t)===!1?x:V;for(let n of ge([...T.values()],re)){let i=s=>`SELECT ${s.join(", ")} FROM ${t} WHERE ${f} IN (${n.join(", ")})`,r;try{r=await e.query(i(P))}catch(s){if(P===x)throw s;P=x,R.set(t,!1),r=await e.query(i(P))}for(let s of r){let w=U(m?s.Id:s[f],m);w===void 0||typeof s.Id!="string"||$.set(w,[...$.get(w)??[],s])}}let K=o.get(t)??new Map,_=[],B=new Map,C=new Map,G=new Map;for(let n of c){let i=U(n[f],m),r=i===void 0?void 0:$.get(i),s=r?.length===1?r[0]:void 0,w=s?.Id;if(_.push(w),!s||w===void 0||a.has(u(w)))continue;typeof s.LastModifiedDate=="string"&&G.set(u(w),{id:w,at:s.LastModifiedDate,...typeof s.LastModifiedById=="string"?{by:s.LastModifiedById}:{}});let ie=K.get(u(w)),q=B.get(u(w))??{Id:w},Q=C.get(u(w))??new Set;for(let b of Object.keys(n))!v.has(b)||ie?.has(b)||b in q||(q[b]=s[b]??null,Q.add(b));Q.size!==0&&(B.set(u(w),q),C.set(u(w),Q))}if(O.size>0&&_.some(n=>n!==void 0&&!a.has(u(n)))){let n=k.get(t)??new Set,i=[...O].filter(r=>!n.has(r));if(i.length>0){for(let r of i)n.add(r);k.set(t,n),e.recorder.unkept?.(t,i)}}if(B.size===0){g.set(t,{reaches:_,named:[],added:new Map});return}let X=[...B.values()],L=d.get(t)??new Map,Y=X.flatMap(n=>{let i=L.get(u(n.Id)),r=Object.entries(n).filter(([s])=>s==="Id"||!i?.has(s));return r.length>1?[Object.fromEntries(r)]:[]});Y.length>0&&await e.backup.keep(t,Y);for(let n of Y){let i=L.get(u(n.Id))??new Set;for(let r of Object.keys(n))r!=="Id"&&i.add(r);L.set(u(n.Id),i)}d.set(t,L);let A=X.map(n=>n.Id),W=E.get(t)??new Set,H=[];for(let n of A){let i=u(n);if(W.has(i))continue;W.add(i);let r=G.get(i);r&&H.push(r)}E.set(t,W),H.length>0?e.recorder.overwriting?.(t,e.backup.id,A,H):e.recorder.overwriting?.(t,e.backup.id,A);let Z=await e.recorder.flush();if(Z!==void 0)throw new Error(`the run's file could not be written: ${Z}`);for(let[n,i]of C){let r=K.get(n)??new Set;for(let s of i)r.add(s);K.set(n,r)}o.set(t,K),g.set(t,{reaches:_,named:A,added:C});return}catch(M){return le(t,c.length,M)}},answered:(t,l,c)=>{if(l==="insert"||l==="upsert")for(let p of c)p.success&&typeof p.id=="string"&&p.id!==""&&(l==="insert"||p.created===!0)&&a.add(u(p.id));let y=g.get(t);if(g.delete(t),!y||y.named.length===0)return;let f=new Set;c.forEach((p,v)=>{let O=y.reaches[v];O!==void 0&&p.success&&p.created!==!0&&f.add(u(O))});let m=y.named.filter(p=>!f.has(u(p))),M=o.get(t);for(let p of m){let v=M?.get(u(p));for(let O of y.added.get(u(p))??[])v?.delete(O)}e.recorder.overwrote?.(t,m)}}}export{se as a,he as b,ae as c,ce as d,ke as e,me as f,Se as g};
7
+ import{a as N}from"./chunk-SAMWHL22.mjs";import{a as j,h as D}from"./chunk-TZE3Y7IQ.mjs";import{b as J}from"./chunk-CA5NAXSU.mjs";function se(e){return`sync-before-${e.replace(/[^A-Za-z0-9-]+/g,"-")}`.slice(0,200)}var oe=1e3;function he(e){let o=se(e.runId),d=new Map,a=e.everyMs??oe,g=()=>(e.now?.()??new Date).getTime(),S,I=Number.NEGATIVE_INFINITY,k,E=!1,R=h=>{if(S===void 0)return;let t=[...d].map(([l,c])=>({objectApiName:l,recordCount:c,truncated:!1}));e.meta.set(`backup:${o}`,{operationId:o,orgId:e.orgId,...e.organizationId!==void 0?{organizationId:e.organizationId}:{},objects:t,partial:h,timestamp:S,totalRecords:t.reduce((l,c)=>l+c.recordCount,0),origin:"sync",runId:e.runId},"backups")},z=()=>{if(E)return;let h=I+a-g();if(h<=0){k!==void 0&&clearTimeout(k),k=void 0,I=g(),R(!0);return}k??=setTimeout(()=>{if(k=void 0,!E){I=g();try{R(!0)}catch{}}},h),k.unref?.()};return{id:o,keep:async(h,t)=>{t.length!==0&&(d.has(h)||(S??=(e.now?.()??new Date).toISOString(),d.set(h,0),R(!0),await e.files.begin(o,h)),await e.files.append(o,h,t),d.set(h,(d.get(h)??0)+t.length),z())},close:()=>{E=!0,k!==void 0&&clearTimeout(k),k=void 0,R(!1)}}}var F=200,de=["LastModifiedDate","LastModifiedById"],ee=100,te=4e3,ae=20,ne=255;function ce(e=ne){return 2*Math.max(0,e)+2}function ke(e,o){let d=o===void 0||o.creatable.size+4>ee;if(e.toLowerCase()==="id")return{characters:ae,wide:d};let a=o?.fields?.find(g=>g.name.toLowerCase()===e.toLowerCase());return a&&["double","int","long","currency","percent"].includes(a.type??"")?{characters:(a.precision??a.digits??18)+2,wide:d}:{characters:ce(a?.length??ne),wide:d}}function fe(e){let o=e.wide?F/4:F,d=Math.floor((te+2)/(Math.max(1,e.characters)+2));return Math.max(1,Math.min(o,d))}function me(e,o){let d=fe(o),a=e.reduce((g,S)=>g+Math.ceil(Math.max(0,S)/d),0);return a>0?a+1:0}function u(e){return e.slice(0,15)}function U(e,o){if(typeof e=="number"&&Number.isFinite(e))return`#${e}`;if(!(typeof e!="string"||e===""))return o?u(e):e.toLowerCase()}function ue(e){return typeof e=="number"?String(e):`'${j(String(e))}'`}function ge(e,o){let d=[],a=[],g=0;for(let S of e){let I=ue(S);a.length>0&&(a.length>=o||g+I.length>te)&&(d.push(a),a=[],g=0),a.push(I),g+=I.length+2}return a.length>0&&d.push(a),d}function le(e,o,d){return`What these ${o} ${e} record(s) would write over in the target could not be read and kept first (${J(d)}), so none of them was written: a run writes over nothing it cannot put back.`}function Se(e){let o=new Map,d=new Map,a=new Set,g=new Map,S=new Map,I=new Map,k=new Map,E=new Map,R=new Map,z=t=>{let l=e.describe,c=e.viewsEncrypted;if(!l||!c)return Promise.resolve(new Set);let y=I.get(t);return y||(y=l(t).then(async f=>{let m=(f.fields??[]).filter(M=>M.type===N).map(M=>M.name);return m.length>0&&!await c()?new Set(m):new Set},()=>new Set),I.set(t,y)),y},h=t=>{let l=e.describe;if(!l)return Promise.resolve(new Set);let c=S.get(t);return c||(c=l(t).then(y=>new Set((y.fields??[]).filter(f=>f.type==="base64"||f.queryable===!1).map(f=>f.name)),()=>new Set),S.set(t,c)),c};return{before:async(t,l,c,y)=>{if(g.delete(t),l!=="update"&&l!=="upsert"||c.length===0)return;let f=l==="update"?"Id":y??"Id",m=f==="Id";try{D(t),D(f);let M=await h(t),p=await z(t),v=new Set,O=new Set,T=new Map;for(let n of c){let i=U(n[f],m);i!==void 0&&!T.has(i)&&T.set(i,n[f]);for(let[r,s]of Object.entries(n))if(!(r==="Id"||r===f||r==="attributes")&&!M.has(r)&&!(typeof s=="object"&&s!==null)){if(p.has(r)){O.add(r);continue}v.add(D(r))}}if(T.size===0||v.size===0&&O.size===0)return;let x=["Id",...m?[]:[f],...v],V=[...x,...de.filter(n=>!x.includes(n))],re=V.length>ee?F/4:F,$=new Map,P=R.get(t)===!1?x:V;for(let n of ge([...T.values()],re)){let i=s=>`SELECT ${s.join(", ")} FROM ${t} WHERE ${f} IN (${n.join(", ")})`,r;try{r=await e.query(i(P))}catch(s){if(P===x)throw s;P=x,R.set(t,!1),r=await e.query(i(P))}for(let s of r){let w=U(m?s.Id:s[f],m);w===void 0||typeof s.Id!="string"||$.set(w,[...$.get(w)??[],s])}}let K=o.get(t)??new Map,_=[],B=new Map,C=new Map,G=new Map;for(let n of c){let i=U(n[f],m),r=i===void 0?void 0:$.get(i),s=r?.length===1?r[0]:void 0,w=s?.Id;if(_.push(w),!s||w===void 0||a.has(u(w)))continue;typeof s.LastModifiedDate=="string"&&G.set(u(w),{id:w,at:s.LastModifiedDate,...typeof s.LastModifiedById=="string"?{by:s.LastModifiedById}:{}});let ie=K.get(u(w)),q=B.get(u(w))??{Id:w},Q=C.get(u(w))??new Set;for(let b of Object.keys(n))!v.has(b)||ie?.has(b)||b in q||(q[b]=s[b]??null,Q.add(b));Q.size!==0&&(B.set(u(w),q),C.set(u(w),Q))}if(O.size>0&&_.some(n=>n!==void 0&&!a.has(u(n)))){let n=k.get(t)??new Set,i=[...O].filter(r=>!n.has(r));if(i.length>0){for(let r of i)n.add(r);k.set(t,n),e.recorder.unkept?.(t,i)}}if(B.size===0){g.set(t,{reaches:_,named:[],added:new Map});return}let X=[...B.values()],L=d.get(t)??new Map,Y=X.flatMap(n=>{let i=L.get(u(n.Id)),r=Object.entries(n).filter(([s])=>s==="Id"||!i?.has(s));return r.length>1?[Object.fromEntries(r)]:[]});Y.length>0&&await e.backup.keep(t,Y);for(let n of Y){let i=L.get(u(n.Id))??new Set;for(let r of Object.keys(n))r!=="Id"&&i.add(r);L.set(u(n.Id),i)}d.set(t,L);let A=X.map(n=>n.Id),W=E.get(t)??new Set,H=[];for(let n of A){let i=u(n);if(W.has(i))continue;W.add(i);let r=G.get(i);r&&H.push(r)}E.set(t,W),H.length>0?e.recorder.overwriting?.(t,e.backup.id,A,H):e.recorder.overwriting?.(t,e.backup.id,A);let Z=await e.recorder.flush();if(Z!==void 0)throw new Error(`the run's file could not be written: ${Z}`);for(let[n,i]of C){let r=K.get(n)??new Set;for(let s of i)r.add(s);K.set(n,r)}o.set(t,K),g.set(t,{reaches:_,named:A,added:C});return}catch(M){return le(t,c.length,M)}},answered:(t,l,c)=>{if(l==="insert"||l==="upsert")for(let p of c)p.success&&typeof p.id=="string"&&p.id!==""&&(l==="insert"||p.created===!0)&&a.add(u(p.id));let y=g.get(t);if(g.delete(t),!y||y.named.length===0)return;let f=new Set;c.forEach((p,v)=>{let O=y.reaches[v];O!==void 0&&p.success&&p.created!==!0&&f.add(u(O))});let m=y.named.filter(p=>!f.has(u(p))),M=o.get(t);for(let p of m){let v=M?.get(u(p));for(let O of y.added.get(u(p))??[])v?.delete(O)}e.recorder.overwrote?.(t,m)}}}export{se as a,he as b,ae as c,ce as d,ke as e,me as f,Se as g};