@koda-sl/baker-cli 0.450.0-dev.b454c3dd2 → 0.450.0-dev.d6701597d
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.
- package/README.md +10 -11
- package/dist/{account-XQXC7BR6.js → account-AL2ZDSR7.js} +4 -5
- package/dist/{account-XQXC7BR6.js.map → account-AL2ZDSR7.js.map} +1 -1
- package/dist/{accounts-722UY53A.js → accounts-HAFCLSR5.js} +3 -4
- package/dist/{accounts-722UY53A.js.map → accounts-HAFCLSR5.js.map} +1 -1
- package/dist/{accounts-E67BMK7T.js → accounts-O5MFO3QQ.js} +5 -6
- package/dist/{accounts-E67BMK7T.js.map → accounts-O5MFO3QQ.js.map} +1 -1
- package/dist/{actions-6TQMSVWD.js → actions-P35MEMGN.js} +18 -18
- package/dist/{add-2BEGRHUX.js → add-5GAN6CVO.js} +5 -28
- package/dist/add-5GAN6CVO.js.map +1 -0
- package/dist/{add-LEMKEOPO.js → add-6DTC6X5G.js} +2 -3
- package/dist/{add-LEMKEOPO.js.map → add-6DTC6X5G.js.map} +1 -1
- package/dist/{ads-AGYCVD62.js → ads-73PGA4YC.js} +4 -4
- package/dist/{advertisers-2VQKAYKG.js → advertisers-AE75CGVE.js} +3 -4
- package/dist/{advertisers-2VQKAYKG.js.map → advertisers-AE75CGVE.js.map} +1 -1
- package/dist/{analytics-IFELDWLL.js → analytics-FKCXIMPO.js} +20 -24
- package/dist/analytics-FKCXIMPO.js.map +1 -0
- package/dist/{analytics-OH5QEH7F.js → analytics-FPWQQGRM.js} +3 -4
- package/dist/{analytics-OH5QEH7F.js.map → analytics-FPWQQGRM.js.map} +1 -1
- package/dist/{assign-PTUJUCEL.js → assign-ABN2AQ4J.js} +3 -4
- package/dist/{assign-PTUJUCEL.js.map → assign-ABN2AQ4J.js.map} +1 -1
- package/dist/{audience-size-LRI6GJRT.js → audience-size-GNBJY35X.js} +3 -4
- package/dist/{audience-size-LRI6GJRT.js.map → audience-size-GNBJY35X.js.map} +1 -1
- package/dist/{audit-HWP7OPB7.js → audit-3VS63TBW.js} +3 -4
- package/dist/{audit-HWP7OPB7.js.map → audit-3VS63TBW.js.map} +1 -1
- package/dist/{autocomplete-J6DHU6MR.js → autocomplete-VS3XG3B7.js} +3 -4
- package/dist/{autocomplete-J6DHU6MR.js.map → autocomplete-VS3XG3B7.js.map} +1 -1
- package/dist/{avatars-467OSBD6.js → avatars-EKCKHCC3.js} +4 -4
- package/dist/{bid-pricing-EO5WLHGV.js → bid-pricing-Q72B65AY.js} +3 -4
- package/dist/{bid-pricing-EO5WLHGV.js.map → bid-pricing-Q72B65AY.js.map} +1 -1
- package/dist/{brand-YRTEPGBK.js → brand-C6PFGGQN.js} +2 -2
- package/dist/{brief-OSFJ2V7F.js → brief-YFJHQ5VQ.js} +7 -8
- package/dist/{brief-OSFJ2V7F.js.map → brief-YFJHQ5VQ.js.map} +1 -1
- package/dist/{campaign-groups-PQ6KSQJR.js → campaign-groups-KFFYQPU3.js} +8 -9
- package/dist/{campaign-groups-PQ6KSQJR.js.map → campaign-groups-KFFYQPU3.js.map} +1 -1
- package/dist/{campaign-writes-5OVLUD5E.js → campaign-writes-FHOS5XZY.js} +3 -4
- package/dist/{campaign-writes-5OVLUD5E.js.map → campaign-writes-FHOS5XZY.js.map} +1 -1
- package/dist/{campaigns-6T3NSUT2.js → campaigns-2NHWBF5C.js} +11 -12
- package/dist/{campaigns-6T3NSUT2.js.map → campaigns-2NHWBF5C.js.map} +1 -1
- package/dist/{campaigns-OYMXDGWX.js → campaigns-KZYZTXDS.js} +5 -5
- package/dist/{canvas-YQFG52IG.js → canvas-5NB27FX2.js} +13 -13
- package/dist/{capabilities-PXBKUN2G.js → capabilities-DJFTRJKS.js} +3 -4
- package/dist/{capabilities-PXBKUN2G.js.map → capabilities-DJFTRJKS.js.map} +1 -1
- package/dist/{catalog-XLXIM7IW.js → catalog-VSSY6FGI.js} +4 -4
- package/dist/{chats-UK47UE7C.js → chats-D2CSDX5Q.js} +3 -4
- package/dist/{chats-UK47UE7C.js.map → chats-D2CSDX5Q.js.map} +1 -1
- package/dist/{chunk-5ZNTADVR.js → chunk-3G3ZDLMI.js} +2 -2
- package/dist/{chunk-SJYEY5MV.js → chunk-3HJLHTWP.js} +3 -12
- package/dist/{chunk-SJYEY5MV.js.map → chunk-3HJLHTWP.js.map} +1 -1
- package/dist/{chunk-ZDMTXQ2Q.js → chunk-3IBYKLXR.js} +2 -2
- package/dist/{chunk-CWYAELVG.js → chunk-464O4MT2.js} +2 -2
- package/dist/{chunk-NA63BH7V.js → chunk-4AUMTNVB.js} +3 -3
- package/dist/{chunk-NDEE6G2J.js → chunk-4BQXAE7Z.js} +2 -2
- package/dist/{chunk-2AOE2MZQ.js → chunk-5ZDLTE5T.js} +3 -3
- package/dist/{chunk-ULG4QRTV.js → chunk-6NB47MRW.js} +2 -2
- package/dist/{chunk-24EB7EDR.js → chunk-7YCRFMXF.js} +3 -3
- package/dist/{chunk-WGUQHAJY.js → chunk-A4LOJ2VD.js} +2 -2
- package/dist/{chunk-6F7DVPOS.js → chunk-AEOSAVVL.js} +3 -3
- package/dist/{chunk-MACCF4JZ.js → chunk-CMPEUZOR.js} +22 -16
- package/dist/{chunk-MACCF4JZ.js.map → chunk-CMPEUZOR.js.map} +1 -1
- package/dist/{chunk-N4LAYIIN.js → chunk-CSYSX4D2.js} +2 -2
- package/dist/{chunk-RX2DKU3W.js → chunk-DGUNI37S.js} +2 -2
- package/dist/{chunk-QE7W555R.js → chunk-DWHIOO7E.js} +12 -163
- package/dist/chunk-DWHIOO7E.js.map +1 -0
- package/dist/{chunk-FPOGPFAG.js → chunk-EBWBG6YV.js} +51 -24
- package/dist/chunk-EBWBG6YV.js.map +1 -0
- package/dist/{chunk-NYIGXDUG.js → chunk-EDLZGTGN.js} +39 -1
- package/dist/chunk-EDLZGTGN.js.map +1 -0
- package/dist/{chunk-I3ZR655O.js → chunk-IR6D7K4H.js} +2 -2
- package/dist/{chunk-FUHN4MFY.js → chunk-JQJDXPCO.js} +2 -2
- package/dist/{chunk-7CTMH5AK.js → chunk-KAUOHQTF.js} +3 -3
- package/dist/{chunk-VYQ3QJ3C.js → chunk-KHRXPQID.js} +2 -2
- package/dist/{chunk-6Y7ZBENQ.js → chunk-LECGCWT5.js} +6 -6
- package/dist/{chunk-5WCSKQ7Z.js → chunk-LZ73CZGP.js} +6 -6
- package/dist/{chunk-R25YLW6H.js → chunk-MELOSESI.js} +2 -2
- package/dist/{chunk-DCRPXOJJ.js → chunk-MXYBTMKB.js} +2 -2
- package/dist/{chunk-54C6YDGJ.js → chunk-NPY4QUMQ.js} +2 -2
- package/dist/{chunk-LYQJ4PZW.js → chunk-OQ6663F4.js} +5 -5
- package/dist/{chunk-H3427GPU.js → chunk-OZRUJVIQ.js} +2 -2
- package/dist/{chunk-KMKEYI37.js → chunk-Q2V6E6SL.js} +3 -3
- package/dist/{chunk-VL43TNIP.js → chunk-QRP3PXWN.js} +2 -2
- package/dist/{chunk-HDLYPC6K.js → chunk-RPUSTYHL.js} +3 -5
- package/dist/{chunk-HDLYPC6K.js.map → chunk-RPUSTYHL.js.map} +1 -1
- package/dist/{chunk-C46GUI2S.js → chunk-RZBEK2VE.js} +2 -2
- package/dist/{chunk-2VPBIT65.js → chunk-S3A3YOKO.js} +8 -8
- package/dist/{chunk-FYGR3I2A.js → chunk-S77PZVYM.js} +3 -3
- package/dist/{chunk-VLMBTPXU.js → chunk-SHL7LOC3.js} +3 -3
- package/dist/{chunk-HR6IWNKE.js → chunk-SSJK7FEV.js} +1140 -1196
- package/dist/chunk-SSJK7FEV.js.map +1 -0
- package/dist/{chunk-KS2QY6MK.js → chunk-W3ZHJJVT.js} +4 -4
- package/dist/{chunk-7EPXVICM.js → chunk-XF4JUKVF.js} +5 -38
- package/dist/chunk-XF4JUKVF.js.map +1 -0
- package/dist/{chunk-RL5CP7N6.js → chunk-Y6O7EWYY.js} +5 -5
- package/dist/{chunk-6NY2GPR4.js → chunk-Y6ZQXUZ7.js} +3 -3
- package/dist/{chunk-HROZYQ5H.js → chunk-YRQYA2LR.js} +5 -63
- package/dist/chunk-YRQYA2LR.js.map +1 -0
- package/dist/{chunk-ASI4P6X2.js → chunk-YUCLMOEG.js} +6 -6
- package/dist/chunk-YUCLMOEG.js.map +1 -0
- package/dist/{chunk-WKQG6TER.js → chunk-ZEYEWPK6.js} +2 -2
- package/dist/{claim-W6G6VEG5.js → claim-FZ5OQLMU.js} +3 -4
- package/dist/{claim-W6G6VEG5.js.map → claim-FZ5OQLMU.js.map} +1 -1
- package/dist/cli.js +30 -30
- package/dist/{companies-TS6KBATJ.js → companies-DNI634RC.js} +3 -4
- package/dist/{companies-TS6KBATJ.js.map → companies-DNI634RC.js.map} +1 -1
- package/dist/{complete-LYR2HMQU.js → complete-2FZMGJV5.js} +3 -4
- package/dist/{complete-LYR2HMQU.js.map → complete-2FZMGJV5.js.map} +1 -1
- package/dist/{connect-FCXNVTXG.js → connect-QCOGEPP4.js} +6 -13
- package/dist/{conversation-6ZJGPCXM.js → conversation-6IOGV7B7.js} +3 -4
- package/dist/{conversation-6ZJGPCXM.js.map → conversation-6IOGV7B7.js.map} +1 -1
- package/dist/{conversions-UHB55MMQ.js → conversions-4SRZPBBX.js} +7 -8
- package/dist/{conversions-UHB55MMQ.js.map → conversions-4SRZPBBX.js.map} +1 -1
- package/dist/{create-EX6OWLNM.js → create-BJNMO6HT.js} +2 -3
- package/dist/{create-EX6OWLNM.js.map → create-BJNMO6HT.js.map} +1 -1
- package/dist/{create-JFSK4BOP.js → create-FX4OJ2XF.js} +3 -4
- package/dist/{create-JFSK4BOP.js.map → create-FX4OJ2XF.js.map} +1 -1
- package/dist/{create-JCA7JPLP.js → create-RM7HV77Y.js} +3 -4
- package/dist/{create-JCA7JPLP.js.map → create-RM7HV77Y.js.map} +1 -1
- package/dist/{create-WU22YYU2.js → create-VXM34ZWH.js} +3 -4
- package/dist/{create-WU22YYU2.js.map → create-VXM34ZWH.js.map} +1 -1
- package/dist/{creatives-FXUQ5WSD.js → creatives-B5NTXPUB.js} +10 -10
- package/dist/{creatives-KGXUOYPE.js → creatives-JSWBFQ5R.js} +8 -9
- package/dist/{creatives-KGXUOYPE.js.map → creatives-JSWBFQ5R.js.map} +1 -1
- package/dist/{credentials-MJC7PGKR.js → credentials-C33K6XCJ.js} +3 -4
- package/dist/{credentials-MJC7PGKR.js.map → credentials-C33K6XCJ.js.map} +1 -1
- package/dist/{critique-GS5VV5ZC.js → critique-4V5SKH7C.js} +6 -7
- package/dist/{critique-GS5VV5ZC.js.map → critique-4V5SKH7C.js.map} +1 -1
- package/dist/{critique-TPHR27KH.js → critique-ZS4ON3SU.js} +3 -4
- package/dist/{critique-TPHR27KH.js.map → critique-ZS4ON3SU.js.map} +1 -1
- package/dist/{crm-VK44O3ED.js → crm-52ROSWH5.js} +4 -5
- package/dist/{crm-VK44O3ED.js.map → crm-52ROSWH5.js.map} +1 -1
- package/dist/{crm-AVCM5D4G.js → crm-R5IXIFIV.js} +4 -5
- package/dist/{crm-AVCM5D4G.js.map → crm-R5IXIFIV.js.map} +1 -1
- package/dist/{customers-XH2DMTFH.js → customers-A36LOZOB.js} +5 -6
- package/dist/{delete-WI5E3DR3.js → delete-AIGE4Y4H.js} +3 -4
- package/dist/{delete-WI5E3DR3.js.map → delete-AIGE4Y4H.js.map} +1 -1
- package/dist/{delete-KRH2YMSZ.js → delete-HGHXY24R.js} +3 -4
- package/dist/{delete-KRH2YMSZ.js.map → delete-HGHXY24R.js.map} +1 -1
- package/dist/{delete-E3R3TKIL.js → delete-M2GDLPYN.js} +2 -3
- package/dist/{delete-E3R3TKIL.js.map → delete-M2GDLPYN.js.map} +1 -1
- package/dist/{demographics-XV5PBA77.js → demographics-NTWB2IMG.js} +3 -4
- package/dist/{demographics-XV5PBA77.js.map → demographics-NTWB2IMG.js.map} +1 -1
- package/dist/{discard-HTQUUHJR.js → discard-2WWQG6OU.js} +3 -4
- package/dist/{discard-HTQUUHJR.js.map → discard-2WWQG6OU.js.map} +1 -1
- package/dist/{domain-RECGZXJB.js → domain-Y2LT6JLT.js} +3 -4
- package/dist/{domain-RECGZXJB.js.map → domain-Y2LT6JLT.js.map} +1 -1
- package/dist/{draft-Q546QPPU.js → draft-EJXNNJ3Y.js} +4 -5
- package/dist/{draft-Q546QPPU.js.map → draft-EJXNNJ3Y.js.map} +1 -1
- package/dist/{draft-PVTX6QT6.js → draft-FJ7WHIXW.js} +3 -4
- package/dist/{draft-PVTX6QT6.js.map → draft-FJ7WHIXW.js.map} +1 -1
- package/dist/{draft-2IBSJEKC.js → draft-SLHAKJ2A.js} +3 -4
- package/dist/{draft-2IBSJEKC.js.map → draft-SLHAKJ2A.js.map} +1 -1
- package/dist/engine/index.js +3 -3
- package/dist/{facets-7EVPJMKS.js → facets-U7AQC4H6.js} +3 -4
- package/dist/{facets-7EVPJMKS.js.map → facets-U7AQC4H6.js.map} +1 -1
- package/dist/{feedback-EIZKS4JU.js → feedback-OLTCHE6C.js} +2 -2
- package/dist/{feedback-record-TKO54BOE.js → feedback-record-7WZ4H7EP.js} +8 -9
- package/dist/{feedback-record-TKO54BOE.js.map → feedback-record-7WZ4H7EP.js.map} +1 -1
- package/dist/{fetch-4BY6HYUM.js → fetch-W7NULDEO.js} +3 -4
- package/dist/{fetch-4BY6HYUM.js.map → fetch-W7NULDEO.js.map} +1 -1
- package/dist/{find-FRRHAPWX.js → find-OTDIX6V4.js} +4 -4
- package/dist/{flows-KTFAML22.js → flows-KABCBS3S.js} +17 -21
- package/dist/flows-KABCBS3S.js.map +1 -0
- package/dist/{fonts-MXR3ZKDX.js → fonts-EMMX3KII.js} +5 -6
- package/dist/{forecast-3QTJYVND.js → forecast-GNODEIIC.js} +3 -4
- package/dist/{forecast-3QTJYVND.js.map → forecast-GNODEIIC.js.map} +1 -1
- package/dist/{funnel-I6XIAEHG.js → funnel-AAX27NH4.js} +455 -11
- package/dist/funnel-AAX27NH4.js.map +1 -0
- package/dist/{ga4-DV2AXCSL.js → ga4-UDQ2HA2J.js} +1 -1
- package/dist/{get-5PKNKJ5S.js → get-QEYJRLV3.js} +4 -7
- package/dist/get-QEYJRLV3.js.map +1 -0
- package/dist/{get-72YPHJGV.js → get-RTVUZM6E.js} +3 -4
- package/dist/{get-72YPHJGV.js.map → get-RTVUZM6E.js.map} +1 -1
- package/dist/{google-QYYYSSXI.js → google-KTO3PLEU.js} +5 -5
- package/dist/{google-6OGZX47I.js → google-M7KEXVK5.js} +2 -2
- package/dist/{google-ads-QGMQKZQD.js → google-ads-OK6IG3UV.js} +3 -4
- package/dist/{google-ads-QGMQKZQD.js.map → google-ads-OK6IG3UV.js.map} +1 -1
- package/dist/{gsc-TAKOF7J5.js → gsc-P3QYGDV2.js} +1 -1
- package/dist/{history-6AVQX2OQ.js → history-PQUJKK26.js} +3 -4
- package/dist/{history-6AVQX2OQ.js.map → history-PQUJKK26.js.map} +1 -1
- package/dist/{hubspot-SVEMFK5S.js → hubspot-Y77VLY6Y.js} +8 -9
- package/dist/{hubspot-SVEMFK5S.js.map → hubspot-Y77VLY6Y.js.map} +1 -1
- package/dist/{icon-L4RSS6PZ.js → icon-I43F77FV.js} +4 -4
- package/dist/{ideas-NFOW3HKJ.js → ideas-MIDU7YOA.js} +2 -3
- package/dist/{images-2EFFUNNV.js → images-S254MS6O.js} +9 -9
- package/dist/{ingest-2SO62RRI.js → ingest-J4I3HKM3.js} +2 -3
- package/dist/{ingest-2SO62RRI.js.map → ingest-J4I3HKM3.js.map} +1 -1
- package/dist/{ingest-2EIKN4QC.js → ingest-YV2NLDBE.js} +3 -4
- package/dist/{inspect-4OOS4APT.js → inspect-Q5NHBBHX.js} +3 -4
- package/dist/{inspect-4OOS4APT.js.map → inspect-Q5NHBBHX.js.map} +1 -1
- package/dist/{inspiration-S3DU4CMQ.js → inspiration-P265QJ2H.js} +1 -1
- package/dist/{keyword-metrics-SF4CSNZ2.js → keyword-metrics-PDY4ZXSP.js} +3 -4
- package/dist/{keyword-metrics-SF4CSNZ2.js.map → keyword-metrics-PDY4ZXSP.js.map} +1 -1
- package/dist/{keywords-for-site-WDAOPNKC.js → keywords-for-site-GALSCV77.js} +3 -4
- package/dist/{keywords-for-site-WDAOPNKC.js.map → keywords-for-site-GALSCV77.js.map} +1 -1
- package/dist/{landing-2ZB46LXH.js → landing-CJYGWCK4.js} +3 -3
- package/dist/{leads-A4W5KTWB.js → leads-PHKG6CP3.js} +3 -4
- package/dist/{leads-A4W5KTWB.js.map → leads-PHKG6CP3.js.map} +1 -1
- package/dist/{learn-IPULBCOD.js → learn-FUQSY7DN.js} +4 -5
- package/dist/{learn-IPULBCOD.js.map → learn-FUQSY7DN.js.map} +1 -1
- package/dist/{line-item-writes-EMYSOJKM.js → line-item-writes-E6MZPIZZ.js} +3 -4
- package/dist/{line-item-writes-EMYSOJKM.js.map → line-item-writes-E6MZPIZZ.js.map} +1 -1
- package/dist/{line-items-5NECXUZT.js → line-items-7ZGIKEF2.js} +5 -5
- package/dist/{link-CI45HWFN.js → link-QYAW6A2W.js} +3 -4
- package/dist/{link-CI45HWFN.js.map → link-QYAW6A2W.js.map} +1 -1
- package/dist/{linkedin-B7SYR75X.js → linkedin-FFSDSGGS.js} +26 -27
- package/dist/{linkedin-B7SYR75X.js.map → linkedin-FFSDSGGS.js.map} +1 -1
- package/dist/{list-ZBT3EBVZ.js → list-5IC6KIKO.js} +3 -4
- package/dist/{list-ZBT3EBVZ.js.map → list-5IC6KIKO.js.map} +1 -1
- package/dist/{list-2BARXOT5.js → list-NVQC5SNY.js} +2 -3
- package/dist/{list-2BARXOT5.js.map → list-NVQC5SNY.js.map} +1 -1
- package/dist/{list-BIEVLEHS.js → list-SAV3LQHY.js} +3 -4
- package/dist/{list-BIEVLEHS.js.map → list-SAV3LQHY.js.map} +1 -1
- package/dist/{log-C23OOAJZ.js → log-XZPVOALD.js} +3 -4
- package/dist/{log-C23OOAJZ.js.map → log-XZPVOALD.js.map} +1 -1
- package/dist/{logo-Q5D7PZY6.js → logo-2IP663QO.js} +3 -3
- package/dist/{lookup-ETWY47F7.js → lookup-XK45W2SH.js} +5 -6
- package/dist/{make-TPKKJXGL.js → make-BMWRKIIY.js} +20 -18
- package/dist/{make-TPKKJXGL.js.map → make-BMWRKIIY.js.map} +1 -1
- package/dist/{map-SYZMPHLL.js → map-4J5WIWIG.js} +4 -5
- package/dist/{map-SYZMPHLL.js.map → map-4J5WIWIG.js.map} +1 -1
- package/dist/{mcp-6FQBVJ6F.js → mcp-XXD7ZQCP.js} +2 -3
- package/dist/{mcp-6FQBVJ6F.js.map → mcp-XXD7ZQCP.js.map} +1 -1
- package/dist/{media-sources-ZXHEEP6T.js → media-sources-O6ZRUA3N.js} +2 -2
- package/dist/{members-UDY4OOJW.js → members-D5ZYLS4Y.js} +3 -4
- package/dist/{members-UDY4OOJW.js.map → members-D5ZYLS4Y.js.map} +1 -1
- package/dist/{normalize-DAKHYS3V.js → normalize-PCNC6E2N.js} +3 -7
- package/dist/{normalize-DAKHYS3V.js.map → normalize-PCNC6E2N.js.map} +1 -1
- package/dist/{options-QL3ULED5.js → options-MQ65VEVD.js} +6 -7
- package/dist/{options-QL3ULED5.js.map → options-MQ65VEVD.js.map} +1 -1
- package/dist/{performance-UF5VTY2U.js → performance-6QW2KEEQ.js} +4 -5
- package/dist/{promoted-tweet-writes-7HGESJ46.js → promoted-tweet-writes-JPLHY3GM.js} +3 -4
- package/dist/{promoted-tweet-writes-7HGESJ46.js.map → promoted-tweet-writes-JPLHY3GM.js.map} +1 -1
- package/dist/{promoted-tweets-LZKS5JIF.js → promoted-tweets-SURKMHFI.js} +3 -3
- package/dist/{publish-NPD3SMZL.js → publish-HCQ6MXLB.js} +3 -4
- package/dist/{publish-NPD3SMZL.js.map → publish-HCQ6MXLB.js.map} +1 -1
- package/dist/{reddit-NU2N3LZD.js → reddit-GIP3ADMS.js} +4 -5
- package/dist/{refresh-EBVJ2C6L.js → refresh-UXQSLCR3.js} +2 -3
- package/dist/{refresh-EBVJ2C6L.js.map → refresh-UXQSLCR3.js.map} +1 -1
- package/dist/{release-V43YB2PY.js → release-5KVLXNP6.js} +3 -4
- package/dist/{release-V43YB2PY.js.map → release-5KVLXNP6.js.map} +1 -1
- package/dist/{remove-QPSWLFI4.js → remove-6FIVKCJI.js} +2 -3
- package/dist/{remove-QPSWLFI4.js.map → remove-6FIVKCJI.js.map} +1 -1
- package/dist/{reopen-GQ66NMWF.js → reopen-YM5LNOLB.js} +3 -4
- package/dist/{reopen-GQ66NMWF.js.map → reopen-YM5LNOLB.js.map} +1 -1
- package/dist/{rerun-PZK275DY.js → rerun-6XZG7BGK.js} +17 -18
- package/dist/{rerun-PZK275DY.js.map → rerun-6XZG7BGK.js.map} +1 -1
- package/dist/{research-FMM6AWZC.js → research-2BLEISBG.js} +10 -10
- package/dist/{research-GEOCUBXB.js → research-YOGE7GT2.js} +2 -3
- package/dist/{research-GEOCUBXB.js.map → research-YOGE7GT2.js.map} +1 -1
- package/dist/{reset-REXJ6AUK.js → reset-C4UHQ3EU.js} +2 -3
- package/dist/{reset-REXJ6AUK.js.map → reset-C4UHQ3EU.js.map} +1 -1
- package/dist/{reset-Y72IVESB.js → reset-OLVB6AE6.js} +2 -3
- package/dist/{reset-Y72IVESB.js.map → reset-OLVB6AE6.js.map} +1 -1
- package/dist/{resolve-OGX7C4TV.js → resolve-XYH2GDAE.js} +3 -4
- package/dist/{resolve-OGX7C4TV.js.map → resolve-XYH2GDAE.js.map} +1 -1
- package/dist/{retry-TCUBBFR5.js → retry-726GKI6V.js} +2 -3
- package/dist/{retry-TCUBBFR5.js.map → retry-726GKI6V.js.map} +1 -1
- package/dist/{retry-CD6JAQ3F.js → retry-7EELDEQP.js} +2 -3
- package/dist/{retry-CD6JAQ3F.js.map → retry-7EELDEQP.js.map} +1 -1
- package/dist/{run-EUO34T2J.js → run-MMEDKJDB.js} +17 -18
- package/dist/{run-A5ZDXTOI.js → run-P4KR2MXC.js} +3 -4
- package/dist/{run-A5ZDXTOI.js.map → run-P4KR2MXC.js.map} +1 -1
- package/dist/{scaffold-ad-SW2HEWM3.js → scaffold-ad-PBTEWDAC.js} +12 -13
- package/dist/{scaffold-ad-SW2HEWM3.js.map → scaffold-ad-PBTEWDAC.js.map} +1 -1
- package/dist/{scaffold-static-ad-ECTJL54Y.js → scaffold-static-ad-RM4M4X5U.js} +36 -37
- package/dist/scaffold-static-ad-RM4M4X5U.js.map +1 -0
- package/dist/{scaffold-video-EI7U7RBK.js → scaffold-video-O2TTKZIE.js} +11 -12
- package/dist/{scaffold-video-EI7U7RBK.js.map → scaffold-video-O2TTKZIE.js.map} +1 -1
- package/dist/{schedule-S5YZJZ5U.js → schedule-RDK4GEPI.js} +2 -3
- package/dist/{schedule-S5YZJZ5U.js.map → schedule-RDK4GEPI.js.map} +1 -1
- package/dist/{scheduled-agents-N4LJRM4C.js → scheduled-agents-6U44QE76.js} +11 -11
- package/dist/{schema-R7JWWOF4.js → schema-CHJDC7GQ.js} +4 -8
- package/dist/{schema-R7JWWOF4.js.map → schema-CHJDC7GQ.js.map} +1 -1
- package/dist/{search-KHMQH3AT.js → search-PMJRU3C4.js} +2 -3
- package/dist/{search-KHMQH3AT.js.map → search-PMJRU3C4.js.map} +1 -1
- package/dist/{select-O2FN2JEQ.js → select-OEUKOVZ5.js} +8 -9
- package/dist/{select-O2FN2JEQ.js.map → select-OEUKOVZ5.js.map} +1 -1
- package/dist/{sends-BQZM5PLS.js → sends-WGJVQUMF.js} +4 -5
- package/dist/{sends-BQZM5PLS.js.map → sends-WGJVQUMF.js.map} +1 -1
- package/dist/{set-prompt-2HASHGWC.js → set-prompt-5E5I7QAZ.js} +8 -9
- package/dist/{set-prompt-2HASHGWC.js.map → set-prompt-5E5I7QAZ.js.map} +1 -1
- package/dist/{setup-links-GYSE56GX.js → setup-links-REPREN3C.js} +3 -4
- package/dist/{setup-links-GYSE56GX.js.map → setup-links-REPREN3C.js.map} +1 -1
- package/dist/{site-4SKM7RKG.js → site-WFSWIA3S.js} +4 -5
- package/dist/{site-4SKM7RKG.js.map → site-WFSWIA3S.js.map} +1 -1
- package/dist/{sources-R2NKNC6J.js → sources-AMI2AWKZ.js} +9 -10
- package/dist/{sources-R2NKNC6J.js.map → sources-AMI2AWKZ.js.map} +1 -1
- package/dist/{sources-FQ2UZTHL.js → sources-YBQ6KPFM.js} +6 -6
- package/dist/{stale-W756ACKC.js → stale-IGFUKEN2.js} +7 -8
- package/dist/{stale-W756ACKC.js.map → stale-IGFUKEN2.js.map} +1 -1
- package/dist/{status-SE2VZJJB.js → status-7F2KHFGA.js} +3 -4
- package/dist/{status-SE2VZJJB.js.map → status-7F2KHFGA.js.map} +1 -1
- package/dist/{stock-KXJ26BY4.js → stock-2YCDN3N6.js} +5 -5
- package/dist/{studio-SYKOSNDB.js → studio-RA7QQH4O.js} +1 -1
- package/dist/{sync-LJGSODK3.js → sync-GWTLKZTU.js} +2 -3
- package/dist/{sync-LJGSODK3.js.map → sync-GWTLKZTU.js.map} +1 -1
- package/dist/{sync-definition-QR2N233R.js → sync-definition-UGSDX2SZ.js} +11 -12
- package/dist/{tags-PYWFSBTR.js → tags-3WPW6PTV.js} +4 -4
- package/dist/{tags-QQU3OKMZ.js → tags-6342FQEB.js} +3 -4
- package/dist/{tags-QQU3OKMZ.js.map → tags-6342FQEB.js.map} +1 -1
- package/dist/{tags-5SBMRC2A.js → tags-ABHSX6M5.js} +3 -4
- package/dist/{tags-5SBMRC2A.js.map → tags-ABHSX6M5.js.map} +1 -1
- package/dist/{tags-YYLNF3PK.js → tags-FJIBBBRG.js} +3 -4
- package/dist/{tags-YYLNF3PK.js.map → tags-FJIBBBRG.js.map} +1 -1
- package/dist/{tags-4BAVFH4S.js → tags-KFYLZLB3.js} +2 -3
- package/dist/{tags-4BAVFH4S.js.map → tags-KFYLZLB3.js.map} +1 -1
- package/dist/{targeting-criteria-RJFLFICN.js → targeting-criteria-NR47AF5C.js} +3 -3
- package/dist/{targets-S2MT2PNB.js → targets-L56KOVQE.js} +3 -4
- package/dist/{targets-S2MT2PNB.js.map → targets-L56KOVQE.js.map} +1 -1
- package/dist/{templates-ZE5TOGRT.js → templates-B6XGDYUF.js} +3 -4
- package/dist/{templates-ZE5TOGRT.js.map → templates-B6XGDYUF.js.map} +1 -1
- package/dist/{testimonials-DII5DYLR.js → testimonials-CVC4YIXO.js} +6 -6
- package/dist/{top-companies-PGIAEHDF.js → top-companies-45X3DT7Z.js} +3 -4
- package/dist/{top-companies-PGIAEHDF.js.map → top-companies-45X3DT7Z.js.map} +1 -1
- package/dist/{translate-GXTS633J.js → translate-VP5R67PL.js} +11 -12
- package/dist/{translate-GXTS633J.js.map → translate-VP5R67PL.js.map} +1 -1
- package/dist/{triggers-2PTONXRU.js → triggers-22EMIVFD.js} +3 -4
- package/dist/{triggers-2PTONXRU.js.map → triggers-22EMIVFD.js.map} +1 -1
- package/dist/{unlink-XRMYJ6DB.js → unlink-65KUN6ID.js} +3 -4
- package/dist/{unlink-XRMYJ6DB.js.map → unlink-65KUN6ID.js.map} +1 -1
- package/dist/{unstage-FY7A3YFF.js → unstage-2E3I5SWF.js} +3 -4
- package/dist/{unstage-FY7A3YFF.js.map → unstage-2E3I5SWF.js.map} +1 -1
- package/dist/{unstage-RM2RLXKD.js → unstage-4ZEULXEQ.js} +4 -5
- package/dist/{unstage-RM2RLXKD.js.map → unstage-4ZEULXEQ.js.map} +1 -1
- package/dist/{update-S4562V3O.js → update-2S7CSEAW.js} +3 -4
- package/dist/{update-S4562V3O.js.map → update-2S7CSEAW.js.map} +1 -1
- package/dist/{update-V6YVEUI2.js → update-7NCOTAQZ.js} +3 -4
- package/dist/{update-V6YVEUI2.js.map → update-7NCOTAQZ.js.map} +1 -1
- package/dist/{update-PJ67D2OG.js → update-D6DJC6T7.js} +2 -3
- package/dist/{update-PJ67D2OG.js.map → update-D6DJC6T7.js.map} +1 -1
- package/dist/{update-E5SRBXQR.js → update-KREBPGBH.js} +3 -4
- package/dist/{update-E5SRBXQR.js.map → update-KREBPGBH.js.map} +1 -1
- package/dist/{upload-R6CQVLKF.js → upload-O6NHRPS7.js} +3 -4
- package/dist/{upload-R6CQVLKF.js.map → upload-O6NHRPS7.js.map} +1 -1
- package/dist/{url-options-JOKU46F2.js → url-options-GGXAL3J4.js} +3 -4
- package/dist/{url-options-JOKU46F2.js.map → url-options-GGXAL3J4.js.map} +1 -1
- package/dist/{url-params-7U2XMOWF.js → url-params-3EFGVTZZ.js} +3 -4
- package/dist/{url-params-7U2XMOWF.js.map → url-params-3EFGVTZZ.js.map} +1 -1
- package/dist/{validate-7YPOUKPB.js → validate-CSJM7XZM.js} +9 -10
- package/dist/{validate-7YPOUKPB.js.map → validate-CSJM7XZM.js.map} +1 -1
- package/dist/{videos-LICG6ACJ.js → videos-YSXYGTBM.js} +5 -5
- package/dist/{web-BA2PGTWU.js → web-IGIGVEKS.js} +3 -4
- package/dist/{web-BA2PGTWU.js.map → web-IGIGVEKS.js.map} +1 -1
- package/dist/{winning-ads-C6S2C5VP.js → winning-ads-2WS7FI4E.js} +2 -2
- package/dist/{write-commands-7SJ3BOW5.js → write-commands-5C7FUOVN.js} +4 -5
- package/dist/{write-commands-7SJ3BOW5.js.map → write-commands-5C7FUOVN.js.map} +1 -1
- package/dist/{x-CZHRC6U7.js → x-BFSKFCZD.js} +6 -6
- package/package.json +1 -1
- package/dist/add-2BEGRHUX.js.map +0 -1
- package/dist/analytics-IFELDWLL.js.map +0 -1
- package/dist/chunk-4PDHHHUJ.js +0 -537
- package/dist/chunk-4PDHHHUJ.js.map +0 -1
- package/dist/chunk-7EPXVICM.js.map +0 -1
- package/dist/chunk-ASI4P6X2.js.map +0 -1
- package/dist/chunk-FPOGPFAG.js.map +0 -1
- package/dist/chunk-HR6IWNKE.js.map +0 -1
- package/dist/chunk-HROZYQ5H.js.map +0 -1
- package/dist/chunk-NYIGXDUG.js.map +0 -1
- package/dist/chunk-QE7W555R.js.map +0 -1
- package/dist/flows-KTFAML22.js.map +0 -1
- package/dist/funnel-I6XIAEHG.js.map +0 -1
- package/dist/get-5PKNKJ5S.js.map +0 -1
- package/dist/plan-FT632COT.js +0 -51
- package/dist/plan-FT632COT.js.map +0 -1
- package/dist/questionnaire-JNGYJTAY.js +0 -37
- package/dist/questionnaire-JNGYJTAY.js.map +0 -1
- package/dist/scaffold-static-ad-ECTJL54Y.js.map +0 -1
- /package/dist/{actions-6TQMSVWD.js.map → actions-P35MEMGN.js.map} +0 -0
- /package/dist/{ads-AGYCVD62.js.map → ads-73PGA4YC.js.map} +0 -0
- /package/dist/{avatars-467OSBD6.js.map → avatars-EKCKHCC3.js.map} +0 -0
- /package/dist/{brand-YRTEPGBK.js.map → brand-C6PFGGQN.js.map} +0 -0
- /package/dist/{campaigns-OYMXDGWX.js.map → campaigns-KZYZTXDS.js.map} +0 -0
- /package/dist/{canvas-YQFG52IG.js.map → canvas-5NB27FX2.js.map} +0 -0
- /package/dist/{catalog-XLXIM7IW.js.map → catalog-VSSY6FGI.js.map} +0 -0
- /package/dist/{chunk-5ZNTADVR.js.map → chunk-3G3ZDLMI.js.map} +0 -0
- /package/dist/{chunk-ZDMTXQ2Q.js.map → chunk-3IBYKLXR.js.map} +0 -0
- /package/dist/{chunk-CWYAELVG.js.map → chunk-464O4MT2.js.map} +0 -0
- /package/dist/{chunk-NA63BH7V.js.map → chunk-4AUMTNVB.js.map} +0 -0
- /package/dist/{chunk-NDEE6G2J.js.map → chunk-4BQXAE7Z.js.map} +0 -0
- /package/dist/{chunk-2AOE2MZQ.js.map → chunk-5ZDLTE5T.js.map} +0 -0
- /package/dist/{chunk-ULG4QRTV.js.map → chunk-6NB47MRW.js.map} +0 -0
- /package/dist/{chunk-24EB7EDR.js.map → chunk-7YCRFMXF.js.map} +0 -0
- /package/dist/{chunk-WGUQHAJY.js.map → chunk-A4LOJ2VD.js.map} +0 -0
- /package/dist/{chunk-6F7DVPOS.js.map → chunk-AEOSAVVL.js.map} +0 -0
- /package/dist/{chunk-N4LAYIIN.js.map → chunk-CSYSX4D2.js.map} +0 -0
- /package/dist/{chunk-RX2DKU3W.js.map → chunk-DGUNI37S.js.map} +0 -0
- /package/dist/{chunk-I3ZR655O.js.map → chunk-IR6D7K4H.js.map} +0 -0
- /package/dist/{chunk-FUHN4MFY.js.map → chunk-JQJDXPCO.js.map} +0 -0
- /package/dist/{chunk-7CTMH5AK.js.map → chunk-KAUOHQTF.js.map} +0 -0
- /package/dist/{chunk-VYQ3QJ3C.js.map → chunk-KHRXPQID.js.map} +0 -0
- /package/dist/{chunk-6Y7ZBENQ.js.map → chunk-LECGCWT5.js.map} +0 -0
- /package/dist/{chunk-5WCSKQ7Z.js.map → chunk-LZ73CZGP.js.map} +0 -0
- /package/dist/{chunk-R25YLW6H.js.map → chunk-MELOSESI.js.map} +0 -0
- /package/dist/{chunk-DCRPXOJJ.js.map → chunk-MXYBTMKB.js.map} +0 -0
- /package/dist/{chunk-54C6YDGJ.js.map → chunk-NPY4QUMQ.js.map} +0 -0
- /package/dist/{chunk-LYQJ4PZW.js.map → chunk-OQ6663F4.js.map} +0 -0
- /package/dist/{chunk-H3427GPU.js.map → chunk-OZRUJVIQ.js.map} +0 -0
- /package/dist/{chunk-KMKEYI37.js.map → chunk-Q2V6E6SL.js.map} +0 -0
- /package/dist/{chunk-VL43TNIP.js.map → chunk-QRP3PXWN.js.map} +0 -0
- /package/dist/{chunk-C46GUI2S.js.map → chunk-RZBEK2VE.js.map} +0 -0
- /package/dist/{chunk-2VPBIT65.js.map → chunk-S3A3YOKO.js.map} +0 -0
- /package/dist/{chunk-FYGR3I2A.js.map → chunk-S77PZVYM.js.map} +0 -0
- /package/dist/{chunk-VLMBTPXU.js.map → chunk-SHL7LOC3.js.map} +0 -0
- /package/dist/{chunk-KS2QY6MK.js.map → chunk-W3ZHJJVT.js.map} +0 -0
- /package/dist/{chunk-RL5CP7N6.js.map → chunk-Y6O7EWYY.js.map} +0 -0
- /package/dist/{chunk-6NY2GPR4.js.map → chunk-Y6ZQXUZ7.js.map} +0 -0
- /package/dist/{chunk-WKQG6TER.js.map → chunk-ZEYEWPK6.js.map} +0 -0
- /package/dist/{connect-FCXNVTXG.js.map → connect-QCOGEPP4.js.map} +0 -0
- /package/dist/{creatives-FXUQ5WSD.js.map → creatives-B5NTXPUB.js.map} +0 -0
- /package/dist/{customers-XH2DMTFH.js.map → customers-A36LOZOB.js.map} +0 -0
- /package/dist/{feedback-EIZKS4JU.js.map → feedback-OLTCHE6C.js.map} +0 -0
- /package/dist/{find-FRRHAPWX.js.map → find-OTDIX6V4.js.map} +0 -0
- /package/dist/{fonts-MXR3ZKDX.js.map → fonts-EMMX3KII.js.map} +0 -0
- /package/dist/{ga4-DV2AXCSL.js.map → ga4-UDQ2HA2J.js.map} +0 -0
- /package/dist/{google-QYYYSSXI.js.map → google-KTO3PLEU.js.map} +0 -0
- /package/dist/{google-6OGZX47I.js.map → google-M7KEXVK5.js.map} +0 -0
- /package/dist/{gsc-TAKOF7J5.js.map → gsc-P3QYGDV2.js.map} +0 -0
- /package/dist/{icon-L4RSS6PZ.js.map → icon-I43F77FV.js.map} +0 -0
- /package/dist/{ideas-NFOW3HKJ.js.map → ideas-MIDU7YOA.js.map} +0 -0
- /package/dist/{images-2EFFUNNV.js.map → images-S254MS6O.js.map} +0 -0
- /package/dist/{ingest-2EIKN4QC.js.map → ingest-YV2NLDBE.js.map} +0 -0
- /package/dist/{inspiration-S3DU4CMQ.js.map → inspiration-P265QJ2H.js.map} +0 -0
- /package/dist/{landing-2ZB46LXH.js.map → landing-CJYGWCK4.js.map} +0 -0
- /package/dist/{line-items-5NECXUZT.js.map → line-items-7ZGIKEF2.js.map} +0 -0
- /package/dist/{logo-Q5D7PZY6.js.map → logo-2IP663QO.js.map} +0 -0
- /package/dist/{lookup-ETWY47F7.js.map → lookup-XK45W2SH.js.map} +0 -0
- /package/dist/{media-sources-ZXHEEP6T.js.map → media-sources-O6ZRUA3N.js.map} +0 -0
- /package/dist/{performance-UF5VTY2U.js.map → performance-6QW2KEEQ.js.map} +0 -0
- /package/dist/{promoted-tweets-LZKS5JIF.js.map → promoted-tweets-SURKMHFI.js.map} +0 -0
- /package/dist/{reddit-NU2N3LZD.js.map → reddit-GIP3ADMS.js.map} +0 -0
- /package/dist/{research-FMM6AWZC.js.map → research-2BLEISBG.js.map} +0 -0
- /package/dist/{run-EUO34T2J.js.map → run-MMEDKJDB.js.map} +0 -0
- /package/dist/{scheduled-agents-N4LJRM4C.js.map → scheduled-agents-6U44QE76.js.map} +0 -0
- /package/dist/{sources-FQ2UZTHL.js.map → sources-YBQ6KPFM.js.map} +0 -0
- /package/dist/{stock-KXJ26BY4.js.map → stock-2YCDN3N6.js.map} +0 -0
- /package/dist/{studio-SYKOSNDB.js.map → studio-RA7QQH4O.js.map} +0 -0
- /package/dist/{sync-definition-QR2N233R.js.map → sync-definition-UGSDX2SZ.js.map} +0 -0
- /package/dist/{tags-PYWFSBTR.js.map → tags-3WPW6PTV.js.map} +0 -0
- /package/dist/{targeting-criteria-RJFLFICN.js.map → targeting-criteria-NR47AF5C.js.map} +0 -0
- /package/dist/{testimonials-DII5DYLR.js.map → testimonials-CVC4YIXO.js.map} +0 -0
- /package/dist/{videos-LICG6ACJ.js.map → videos-YSXYGTBM.js.map} +0 -0
- /package/dist/{winning-ads-C6S2C5VP.js.map → winning-ads-2WS7FI4E.js.map} +0 -0
- /package/dist/{x-CZHRC6U7.js.map → x-BFSKFCZD.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/flows/shared.ts"],"sourcesContent":["import { existsSync, readdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport {\n FLOW_ACCOUNT_ONLY_KINDS,\n FLOW_AGENT_DESTINATION_KINDS,\n FLOW_RESOURCE_NODE_TYPES,\n FLOW_SECRET_FIELDS,\n FLOW_SECRET_SIDE_EFFECT_TYPES,\n type FlowConfigStatus,\n type FlowSideEffectType,\n type FlowsRevealResponse,\n flowCatalogEntry,\n isFlowOauthSideEffect,\n} from \"@baker/api\";\nimport { apiPost } from \"../../client.ts\";\nimport { writeJson } from \"../../output.ts\";\n\nconst FLOWS_DIR = \"src/lib/flow-engine/flows\";\n\n/** Resolve the flows directory from cwd (walk up a few levels to find the repo root). */\nexport function flowsDir(): string {\n let dir = process.cwd();\n for (let i = 0; i < 6; i++) {\n const candidate = join(dir, FLOWS_DIR);\n if (existsSync(candidate)) {\n return candidate;\n }\n const parent = join(dir, \"..\");\n if (parent === dir) {\n break;\n }\n dir = parent;\n }\n return join(process.cwd(), FLOWS_DIR);\n}\n\nexport function failLocal(message: string): never {\n writeJson({ ok: false, error: { code: \"NOT_FOUND\", message } });\n process.exit(1);\n}\n\nexport function listFlowSlugs(): string[] {\n const dir = flowsDir();\n if (!existsSync(dir)) {\n return [];\n }\n return readdirSync(dir, { withFileTypes: true })\n .filter((entry) => entry.isDirectory() && !entry.name.startsWith(\"_\") && entry.name !== \".gitkeep\")\n .map((entry) => entry.name)\n .sort();\n}\n\ntype AnyRecord = Record<string, unknown>;\n\n/** Absolute path to a form's `_data.json` — the one file the agent may edit. */\nexport function flowDataPath(slug: string): string {\n return join(flowsDir(), slug, \"_data.json\");\n}\n\n/**\n * Write a form tree back. Two-space JSON with a trailing newline, matching what\n * the scaffolder and the repo's markdown/JSON formatting already produce — a\n * write in any other shape turns a one-field edit into a whole-file diff.\n */\nexport function writeFlowTree(slug: string, tree: AnyRecord): void {\n writeFileSync(flowDataPath(slug), `${JSON.stringify(tree, null, 2)}\\n`, \"utf-8\");\n}\n\n/**\n * Every node in the tree, depth-first, parents before children.\n *\n * `Array.isArray`, not `?? []`: `_data.json` is hand-authored, so `children`\n * can be an object or a string, and `??` only guards null. These walkers are\n * what `flows show` and the pre-commit `normalize` run over, which are the two\n * things reached for when a form file is already wrong — throwing there would\n * take out the diagnosis along with the form.\n */\nexport function walkNodes(node: AnyRecord, acc: AnyRecord[] = []): AnyRecord[] {\n if (!node || typeof node !== \"object\") return acc;\n acc.push(node);\n if (Array.isArray(node.children)) {\n for (const child of node.children as AnyRecord[]) walkNodes(child, acc);\n }\n return acc;\n}\n\n/**\n * Every side effect in the tree, with the node that owns it.\n *\n * Walked rather than read off the root: side effects hang off whichever node\n * fires them, so a multi-step form keeps them on a child step. Reading\n * `tree.sideEffects` alone reports \"no side effects\" for a form that plainly\n * has one.\n */\nexport function collectSideEffects(tree: AnyRecord): Array<{ node: AnyRecord; sideEffect: AnyRecord }> {\n return walkNodes(tree).flatMap((node) =>\n Array.isArray(node.sideEffects)\n ? (node.sideEffects as AnyRecord[])\n .filter((sideEffect): sideEffect is AnyRecord => Boolean(sideEffect) && typeof sideEffect === \"object\")\n .map((sideEffect) => ({ node, sideEffect }))\n : [],\n );\n}\n\n/** A destination with something sealed in it, as `/api/flows/destinations/reveal` takes it. */\nexport type SealedSideEffect = { sideEffectId: string; type: FlowSideEffectType; encryptedConfig: string };\n\nexport function sealedSideEffects(tree: AnyRecord): SealedSideEffect[] {\n return collectSideEffects(tree).flatMap(({ sideEffect }) => {\n const { id, type, encryptedConfig } = sideEffect;\n const sealed =\n typeof id === \"string\" &&\n typeof type === \"string\" &&\n (FLOW_SECRET_SIDE_EFFECT_TYPES as readonly string[]).includes(type) &&\n typeof encryptedConfig === \"string\" &&\n encryptedConfig.length > 0;\n return sealed\n ? [{ sideEffectId: id as string, type: type as FlowSideEffectType, encryptedConfig: encryptedConfig as string }]\n : [];\n });\n}\n\nfunction describeSettings(settings: Record<string, unknown>): string {\n if (typeof settings.email === \"string\") {\n return `to ${settings.email}${typeof settings.subject === \"string\" ? ` · subject \"${settings.subject}\"` : \"\"}`;\n }\n return Object.entries(settings)\n .filter(([, value]) => typeof value === \"string\" || typeof value === \"number\")\n .map(([key, value]) => `${key}: ${String(value)}`)\n .join(\" · \");\n}\n\n/** Each sealed destination's row, saying where it sends — credentials never included (the backend strips them). */\nexport function withSettings(\n rows: FlowConfigStatus[],\n settingsById: Record<string, Record<string, unknown> | null>,\n): FlowConfigStatus[] {\n return rows.map((row) => {\n const settings = row.sideEffectId ? settingsById[row.sideEffectId] : undefined;\n const described = settings ? describeSettings(settings) : \"\";\n return described ? { ...row, status: `${row.status} → ${described}` } : row;\n });\n}\n\n/** Whether this workspace holds a Form by that slug. Never exits. */\nexport function flowExists(slug: string): boolean {\n return existsSync(join(flowsDir(), slug, \"_data.json\"));\n}\n\nexport function readFlowTree(slug: string): AnyRecord {\n const path = join(flowsDir(), slug, \"_data.json\");\n if (!existsSync(path)) {\n failLocal(`No form \"${slug}\". Run \"baker flows list\" to see the forms in this workspace.`);\n }\n try {\n return JSON.parse(readFileSync(path, \"utf-8\")) as AnyRecord;\n } catch (error) {\n failLocal(`Could not read form \"${slug}\": ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\nfunction isConfigured(value: unknown): boolean {\n return typeof value === \"string\" && value.length > 0;\n}\n\ntype NodeMeta = { nodeId: string; nodeName?: string };\n\nfunction nodeMeta(record: AnyRecord): NodeMeta {\n const nodeId = typeof record.id === \"string\" ? record.id : \"\";\n const nodeName = typeof record.name === \"string\" ? record.name : undefined;\n return { nodeId, ...(nodeName ? { nodeName } : {}) };\n}\n\nfunction widgetNodeStatus(record: AnyRecord, meta: NodeMeta): FlowConfigStatus | null {\n const nodeData = record.nodeData as AnyRecord | undefined;\n const nodeType = nodeData?.type;\n if (typeof nodeType !== \"string\" || !(FLOW_RESOURCE_NODE_TYPES as readonly string[]).includes(nodeType)) {\n return null;\n }\n const external = (nodeData?.form as AnyRecord | undefined)?.external;\n const selected = external != null && typeof external === \"object\";\n const name = selected ? (external as AnyRecord).name : undefined;\n return {\n ...meta,\n target: \"node\",\n kind: nodeType,\n status: selected\n ? `${nodeType} — selected${typeof name === \"string\" ? ` \"${name}\"` : \"\"}`\n : `${nodeType} — not selected`,\n needsInput: !selected,\n };\n}\n\n/**\n * Whether this side effect still needs something only the user can give.\n *\n * `false` for a type that has no confidential half at all (a pixel takes a tag\n * ref and nothing else), so a caller can ask the question of any side effect\n * without first checking whether the question applies.\n */\nexport function sideEffectNeedsInput(raw: unknown): boolean {\n const effect = raw as AnyRecord | null;\n const type = effect?.type;\n if (typeof type !== \"string\" || !(FLOW_SECRET_SIDE_EFFECT_TYPES as readonly string[]).includes(type)) {\n return false;\n }\n const configured = isConfigured(effect?.encryptedConfig);\n if (!isFlowOauthSideEffect(type as FlowSideEffectType)) return !configured;\n return !isConfigured(effect?.oauthProviderId) || !configured;\n}\n\n/** A pixel has no confidential half; it is listed so a form's tracking is visible before anyone adds to it. */\nfunction trackingStatus(effect: AnyRecord, type: string, meta: NodeMeta): FlowConfigStatus | null {\n if (flowCatalogEntry(\"side-effect\", type)?.owners?.tagIds !== \"tags\") return null;\n const tags = Array.isArray(effect.tagIds) ? effect.tagIds.length : 0;\n const event = typeof effect.eventName === \"string\" ? ` \"${effect.eventName}\"` : \"\";\n return {\n ...meta,\n target: \"sideEffect\",\n ...(typeof effect.id === \"string\" ? { sideEffectId: effect.id } : {}),\n kind: type,\n status: `${type}${event} — ${tags > 0 ? `[${tags} tag${tags === 1 ? \"\" : \"s\"}]` : \"[no tag]\"}`,\n needsInput: false,\n };\n}\n\nfunction sideEffectStatus(raw: unknown, meta: NodeMeta): FlowConfigStatus | null {\n const effect = raw as AnyRecord | null;\n const type = effect?.type;\n if (typeof type !== \"string\") return null;\n if (!(FLOW_SECRET_SIDE_EFFECT_TYPES as readonly string[]).includes(type)) {\n return effect ? trackingStatus(effect, type, meta) : null;\n }\n const configured = isConfigured(effect?.encryptedConfig);\n const oauth = isFlowOauthSideEffect(type as FlowSideEffectType);\n const connected = isConfigured(effect?.oauthProviderId);\n const needs = FLOW_SECRET_FIELDS[type as FlowSideEffectType];\n const status = oauth\n ? `${type} — connection ${connected ? \"[connected]\" : \"[needs connection]\"}, config ${configured ? \"[set]\" : \"[missing]\"}`\n : configured\n ? `${type} — [configured]`\n : `${type} — [missing]${needs.length > 0 ? ` (needs: ${needs.join(\", \")})` : \"\"}`;\n return {\n ...meta,\n target: \"sideEffect\",\n ...(typeof effect?.id === \"string\" ? { sideEffectId: effect.id } : {}),\n kind: type,\n status,\n needsInput: sideEffectNeedsInput(effect),\n };\n}\n\n/**\n * The exact call that fills a still-unconfigured item — `baker flows connect`\n * for anything the agent can wire itself, `request_flow_input` for the rest\n * and as the fallback.\n *\n * Emitted as a ready-to-issue call rather than a reminder that one exists. The\n * argument set is not guessable — it needs the node id, and for a side effect\n * the side-effect id too — so a hint that only named the tool would still cost\n * the agent a `flows show --full` to assemble.\n */\nexport function requestFlowInputCall(slug: string, status: FlowConfigStatus): string {\n const args =\n status.target === \"node\"\n ? `{ target: \"node\", flowSlug: \"${slug}\", nodeId: \"${status.nodeId}\", nodeType: \"${status.kind}\" }`\n : `{ target: \"sideEffect\", flowSlug: \"${slug}\", nodeId: \"${status.nodeId}\", sideEffectId: \"${status.sideEffectId}\", sideEffectType: \"${status.kind}\" }`;\n const card = `request_flow_input with ${args}`;\n const target = status.target === \"node\" ? `--node ${status.nodeId}` : `--side-effect ${status.sideEffectId}`;\n const fallback = \"only if nothing is connected or several could be meant\";\n // Nothing in an email is confidential: you state it, and the user is never handed a card for it.\n if (status.kind === \"email\") {\n return `baker flows connect ${slug} ${target} --email \"<who receives each lead, comma-separated>\" --subject \"<New lead — the Form's name>\"`;\n }\n if (status.kind === \"httpWebhook\") {\n return `baker flows connect ${slug} ${target} --url <https address> — only a webhook that needs a token or password goes to the user: ${card}`;\n }\n if (status.kind === \"hubspotForm\") {\n return `baker flows connect ${slug} ${target} --hubspot-form <formId from baker hubspot forms list> — ${fallback}: ${card}`;\n }\n if (status.kind === \"hubspot\" || status.kind === \"hubspotMeeting\") {\n const list = status.kind === \"hubspot\" ? \"forms view <id>\" : \"meetings view <slug>\";\n return `write \\`baker hubspot ${list} --as-node\\` into the step's form.external — ${fallback}: ${card}`;\n }\n if ((FLOW_ACCOUNT_ONLY_KINDS as readonly string[]).includes(status.kind)) {\n return `baker flows connect ${slug} ${target} — ${fallback}: ${card}`;\n }\n if ((FLOW_AGENT_DESTINATION_KINDS as readonly string[]).includes(status.kind)) {\n const sheet = status.kind === \"googleSpreadsheet\" ? ' (or --new-sheet \"<title>\" --columns \"…\")' : \"\";\n return `baker flows connect ${slug} ${target} --resource <id from baker flows options ${status.kind}>${sheet} — ${fallback}: ${card}`;\n }\n return card;\n}\n\n/**\n * Walk a local flow tree collecting the configuration status of every\n * confidential field — WITHOUT decrypting anything. A present `encryptedConfig`\n * string / `oauthProviderId` / `form.external` object means \"configured\"; null /\n * absent means the agent still needs to run `request_flow_input` for it.\n */\nexport function collectConfigStatus(node: unknown, acc: FlowConfigStatus[]): void {\n if (!node || typeof node !== \"object\") {\n return;\n }\n const record = node as AnyRecord;\n const meta = nodeMeta(record);\n\n const widget = widgetNodeStatus(record, meta);\n if (widget) {\n acc.push(widget);\n }\n if (Array.isArray(record.sideEffects)) {\n for (const raw of record.sideEffects) {\n const status = sideEffectStatus(raw, meta);\n if (status) {\n acc.push(status);\n }\n }\n }\n if (Array.isArray(record.children)) {\n for (const child of record.children) {\n collectConfigStatus(child, acc);\n }\n }\n}\n\n/** Replace opaque ciphertext with a status marker so `--full` stays readable and never leaks noise. */\nexport function redactTree(node: unknown): unknown {\n if (Array.isArray(node)) {\n return node.map(redactTree);\n }\n if (!node || typeof node !== \"object\") {\n return node;\n }\n const out: AnyRecord = {};\n for (const [key, value] of Object.entries(node as AnyRecord)) {\n if (key === \"encryptedConfig\") {\n out[key] = isConfigured(value) ? \"[configured]\" : value;\n } else {\n out[key] = redactTree(value);\n }\n }\n return out;\n}\n\n/**\n * The constant a step's name becomes in the generated `_query.ts`.\n *\n * Byte-for-byte the scaffold's own `toScreamingSnake`\n * (`__tooling__/checks/base/flow-typed/flow-typed.mjs`), which is the only implementation\n * that decides anything: the watcher writes `export const <key> = \"<node id>\";`\n * for every step and throws `Duplicate flow node name` when two steps produce\n * the same one. `flows-step-name-key.test.ts` pins the two together.\n *\n * It is copied rather than imported because the CLI ships as a binary into a\n * Session Runtime and the scaffold ships as files — there is no module boundary\n * they share. The copy that was here before was NOT this rule: it uppercased and\n * squashed every non-alphanumeric run, which agrees on `Contact Info` and\n * disagrees on `contactInfo` (`CONTACTINFO` here, `CONTACT_INFO` there). So\n * `add-node` waved through a name that collided in the generator, the watcher\n * then threw, and `_query.ts` stopped regenerating for the whole form.\n */\nexport function stepNameKey(name: string): string {\n return name\n .replace(/([a-z])([A-Z])/g, \"$1_$2\")\n .replace(/[-\\s]+/g, \"_\")\n .toUpperCase();\n}\n\n/**\n * Whether that constant is one TypeScript will accept.\n *\n * `flow-typed.mjs` interpolates the key straight into `export const <key> = …`\n * without checking, so a step called \"1. Your details\" or \"Thanks!\" writes a\n * `_query.ts` that is a syntax error, and the whole workspace stops building —\n * a failure whose message names the generated file rather than the step that\n * caused it. `add-node` is where a name is minted, so it is where this is worth\n * catching.\n *\n * The real identifier grammar, not `[A-Z0-9_]`: this product is Spanish-first\n * and `INFORMACIÓN_DE_CONTACTO` is both a legal identifier and an ordinary step\n * name. Rejecting it would be the check being wrong, not the name.\n */\nexport function isUsableStepNameKey(key: string): boolean {\n return /^[\\p{ID_Start}$_][\\p{ID_Continue}$]*$/u.test(key);\n}\n\n/**\n * What each sealed destination holds, minus credentials — so \"add Fran to the\n * leads email\" starts from who gets it today instead of a card for the user.\n * A destination Baker would not open for this company (sealed for another,\n * or saved before destinations recorded whose they are) maps to null; the whole call failing\n * returns null. `flows show` leaves those rows as they were, and `connect`\n * refuses to overwrite what it cannot see.\n */\nexport async function readSettings(\n tree: Record<string, unknown>,\n): Promise<Record<string, Record<string, unknown> | null> | null> {\n const sealed = sealedSideEffects(tree);\n if (sealed.length === 0) return {};\n try {\n const { data } = await apiPost<FlowsRevealResponse>(\"/api/flows/destinations/reveal\", {\n items: sealed.map(({ type, encryptedConfig }) => ({ type, encryptedConfig })),\n });\n return Object.fromEntries(sealed.map((item, index) => [item.sideEffectId, data.items[index] ?? null]));\n } catch {\n return null;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,aAAa,cAAc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;AAAA,IAC7B;AAAA,EACF;AACA,SAAO;AACT;AAmBO,SAAS,YAAY,MAAsB;AAChD,SAAO,KACJ,QAAQ,mBAAmB,OAAO,EAClC,QAAQ,WAAW,GAAG,EACtB,YAAY;AACjB;AAgBO,SAAS,oBAAoB,KAAsB;AACxD,SAAO,2CAA2C,KAAK,GAAG;AAC5D;AAUA,eAAsB,aACpB,MACgE;AAChE,QAAM,SAAS,kBAAkB,IAAI;AACrC,MAAI,OAAO,WAAW,EAAG,QAAO,CAAC;AACjC,MAAI;AACF,UAAM,EAAE,KAAK,IAAI,MAAM,QAA6B,kCAAkC;AAAA,MACpF,OAAO,OAAO,IAAI,CAAC,EAAE,MAAM,gBAAgB,OAAO,EAAE,MAAM,gBAAgB,EAAE;AAAA,IAC9E,CAAC;AACD,WAAO,OAAO,YAAY,OAAO,IAAI,CAAC,MAAM,UAAU,CAAC,KAAK,cAAc,KAAK,MAAM,KAAK,KAAK,IAAI,CAAC,CAAC;AAAA,EACvG,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../api/src/event-ingest/matching.ts","../../api/src/event-ingest/vocabulary.ts","../../api/src/event-sources/fields.ts","../../api/src/event-sources/template.ts"],"sourcesContent":["/**\n * The customer-matching block: one vocabulary for everything Meta calls\n * *advanced matching* and Google calls *enhanced conversions*.\n *\n * ## Why these fields are here at all\n *\n * A server event is worth what it can be joined to. An email is the join that\n * works, and everything in this file is the second-best set for when the join\n * has to happen *outward* instead — Meta and Google both accept an event with\n * no email at all if it carries enough of a person: a name and a postcode, a\n * click id, a browser cookie. They disagree about spelling and about what has\n * to be hashed, and they do not disagree about the set.\n *\n * Two things follow, and they are the whole design:\n *\n * - **One block, one spelling.** A sender maps their CRM once, here, rather\n * than once per destination. `MATCH_FIELD_FORWARDING` is the table that says\n * what each field is called on the other side, so the mapping is published\n * rather than folklore.\n * - **Kept in the form every destination can still be derived from.** That rule\n * decides, per field, whether it is stored hashed or in the clear, and it is\n * the only rule here worth remembering: **a digest can be computed later and\n * never undone.** A city hashed on arrival can never be sent to Google, which\n * wants `address_info.city` in plain text; a city kept in the clear can be\n * hashed for Meta at the moment of sending, for free.\n *\n * So: hashed here are the fields **both** destinations want hashed and which\n * identify a person on their own — email, phone, the two names, the date of\n * birth, and the sender's own id. Kept in the clear are the coarse ones that\n * identify nobody by themselves and that Google wants unhashed: city, region,\n * postal code, country, and the gender letter. Hashing that second set would\n * buy no privacy — the digest of `es` is not a secret — and would cost the\n * ability to send them anywhere.\n *\n * ## A value that arrives already hashed\n *\n * Accepted for every field, and detected rather than declared. There is no\n * `email_sha256` beside `email` any more, because two fields for one idea is a\n * choice a sender should never have had to make: a 64-character hex string is\n * unambiguously a digest — no address, phone number, city or name can be one —\n * so the field can hold either and we can tell. What we cannot do is *unhash*,\n * so a digest arriving for a field this module would otherwise keep in the\n * clear is stored under `<field>_sha256`: the key says what is inside it, and a\n * forward that needs the plain value knows it does not have one.\n *\n * ## Normalization is Meta's, and the divergence is stated\n *\n * The hashed fields are normalized under the rule Meta publishes (lower case,\n * trimmed, punctuation and spacing removed) because a digest can only be\n * computed under one rule and Meta's is the stricter of the two. Google's rule\n * for a name is lower-case-and-trim only, so the two agree on every name\n * without punctuation in it and differ on `O'Brien`. Email and phone do not\n * have this problem: they go through `../identity`, which is the platform's one\n * versioned rule and the same one the browser beacon writes with — which is\n * what makes a server event and a Form submission land on one person.\n */\n\nimport { isSha256Hex, sha256Hex } from \"../identity\";\n\n/**\n * A field of `user_data` that describes the person rather than naming a click.\n *\n * `email` and `phone` are deliberately not here: they are resolved by\n * `./identity` into the row's own `identity_hash`, under the platform's\n * versioned rule, and this module reads that result rather than hashing them a\n * second time under a different one.\n */\nexport const MATCH_FIELDS = [\n \"first_name\",\n \"last_name\",\n \"date_of_birth\",\n \"gender\",\n \"city\",\n \"region\",\n \"postal_code\",\n \"country\",\n] as const;\nexport type MatchField = (typeof MATCH_FIELDS)[number];\n\n/**\n * The browser cookies Meta's pixel sets, which name a browser rather than a\n * person.\n *\n * `fbp` is the pixel's own first-party cookie and `fbc` is the one it derives\n * from a click. Both are sent to Meta **unhashed and verbatim** — they are\n * opaque strings of Meta's own making, and hashing one destroys it — so they\n * are stored exactly as they arrived.\n *\n * They are not in {@link MATCH_FIELDS} and not in the click-id list either.\n * They are not click ids: a `gclid` is stamped on a URL by the ad platform and\n * has a column of its own here because reports filter on it, while `fbp` is a\n * cookie a script wrote and nothing reports on. But they *do* name somebody,\n * which is why `namesSomebody` counts them — an event carrying only an `fbp` is\n * still an event Meta can attribute, and refusing it would lose exactly the\n * conversions this block exists to make sendable.\n */\nexport const MATCH_COOKIES = [\"fbp\", \"fbc\"] as const;\nexport type MatchCookie = (typeof MATCH_COOKIES)[number];\n\n/** How a field is stored, once it has been normalized. */\ntype Keeping = \"hashed\" | \"plain\";\n\ntype MatchSpec = {\n keep: Keeping;\n /** The canonical form, or `null` when the value says nothing usable. */\n normalize: (value: string) => string | null;\n /** What Meta and Google call this field, for the published mapping. */\n meta: string;\n google: string | null;\n};\n\n/** Lower-cased, trimmed, and stripped of everything that is not a letter or a digit. Meta's rule. */\nfunction tightened(value: string): string | null {\n const stripped = value.toLowerCase().replace(/[^\\p{L}\\p{N}]/gu, \"\");\n return stripped === \"\" ? null : stripped;\n}\n\n/** Lower-cased and trimmed, with runs of whitespace collapsed. Nothing else is removed. */\nfunction loosened(value: string): string | null {\n const collapsed = value.trim().toLowerCase().replace(/\\s+/g, \" \");\n return collapsed === \"\" ? null : collapsed;\n}\n\n/**\n * `1985-04-09`, `1985/04/09`, `19850409` — eight digits in year-month-day\n * order, however they are punctuated.\n *\n * The order is not guessed. `09/04/1985` is refused rather than read as the\n * ninth of April or the fourth of September: nothing in the value says which,\n * and a birth date hashed under the wrong reading is a digest that matches\n * nobody at Meta, with no error anywhere to say so. A refusal costs one field\n * on one event and is visible in the arrival log; a wrong guess costs the match\n * and is not.\n */\nfunction birthDate(value: string): string | null {\n const digits = value.replace(/\\D/g, \"\");\n if (!/^\\d{8}$/.test(digits)) return null;\n const month = Number(digits.slice(4, 6));\n const day = Number(digits.slice(6, 8));\n if (month < 1 || month > 12 || day < 1 || day > 31) return null;\n return digits;\n}\n\n/** `f` or `m`, from whatever word or letter the sender's system stores. */\nfunction genderLetter(value: string): string | null {\n const first = value.trim().toLowerCase().charAt(0);\n return first === \"f\" || first === \"m\" ? first : null;\n}\n\n/** ISO-3166 alpha-2, lower-cased. A country name is refused rather than guessed at. */\nfunction countryCode(value: string): string | null {\n const code = value.trim().toLowerCase();\n return /^[a-z]{2}$/.test(code) ? code : null;\n}\n\nexport const MATCH_SPECS: Readonly<Record<MatchField, MatchSpec>> = {\n first_name: { keep: \"hashed\", normalize: tightened, meta: \"fn\", google: \"hashed_first_name\" },\n last_name: { keep: \"hashed\", normalize: tightened, meta: \"ln\", google: \"hashed_last_name\" },\n // Meta only. Google's enhanced conversions have no date of birth, so there is\n // no destination wanting it in the clear and every reason not to keep one.\n date_of_birth: { keep: \"hashed\", normalize: birthDate, meta: \"db\", google: null },\n gender: { keep: \"plain\", normalize: genderLetter, meta: \"ge\", google: null },\n city: { keep: \"plain\", normalize: loosened, meta: \"ct\", google: \"city\" },\n region: { keep: \"plain\", normalize: loosened, meta: \"st\", google: \"state\" },\n postal_code: { keep: \"plain\", normalize: loosened, meta: \"zp\", google: \"postal_code\" },\n country: { keep: \"plain\", normalize: countryCode, meta: \"country\", google: \"country_code\" },\n};\n\n/** One row of the published mapping: our name, Meta's, Google's, and whether we hold it hashed. */\nexport type MatchFieldForwarding = {\n field: string;\n meta: string;\n google: string | null;\n hashed: boolean;\n};\n\n/**\n * What each field of the matching block is called at the destinations that\n * accept it — the table the dialog and the docs both read.\n *\n * Published rather than described, because \"it maps onto Meta's user_data\" is\n * a promise a sender cannot check and this is the same promise they can.\n */\nexport const MATCH_FIELD_FORWARDING: readonly MatchFieldForwarding[] = [\n { field: \"email\", meta: \"em\", google: \"hashed_email\", hashed: true },\n { field: \"phone\", meta: \"ph\", google: \"hashed_phone_number\", hashed: true },\n // Kept in the clear — see `resolveOwnId`. The digest is still computed and\n // still stored beside it, so a Meta forward has one; what changed is that the\n // sender's own key is now readable, which is the entire reason they sent it.\n { field: \"external_id\", meta: \"external_id\", google: null, hashed: false },\n ...MATCH_FIELDS.map((field) => ({\n field,\n meta: MATCH_SPECS[field].meta,\n google: MATCH_SPECS[field].google,\n hashed: MATCH_SPECS[field].keep === \"hashed\",\n })),\n { field: \"fbp\", meta: \"fbp\", google: null, hashed: false },\n { field: \"fbc\", meta: \"fbc\", google: null, hashed: false },\n];\n\n/** The longest a stored match value may be, matching the width the map's values are held at. */\nconst MAX_MATCH_VALUE = 255;\n\n/**\n * One field, resolved to the key it is stored under and the value stored there.\n *\n * `null` when the field said nothing usable — `gender: \"unknown\"`, a country\n * spelled out in full, a postcode of whitespace. A field that is present and\n * unusable contributes nothing rather than storing something that matches\n * nobody, which is the same rule the identity resolution follows.\n */\nexport async function resolveMatchField(\n field: MatchField,\n raw: string,\n): Promise<{ key: string; value: string } | null> {\n const value = raw.trim();\n if (value === \"\") return null;\n const spec = MATCH_SPECS[field];\n // Already a digest, whatever this field would otherwise keep. Taken at face\n // value — hashing a hash matches nothing, forever — and keyed so that the\n // name says what is inside, because a plain-text destination cannot use it.\n if (isSha256Hex(value)) return { key: `${field}_sha256`, value: value.toLowerCase() };\n const normalized = spec.normalize(value);\n if (normalized === null) return null;\n if (spec.keep === \"plain\") return { key: field, value: normalized.slice(0, MAX_MATCH_VALUE) };\n return { key: `${field}_sha256`, value: await sha256Hex(normalized) };\n}\n\n/**\n * The two ids that are not facts about a person but *names the sender chose*,\n * kept exactly as they were sent.\n *\n * `external_id` is the client's own key — a HubSpot contact id, a Salesforce\n * record id — and `baker_id` is a cookie value one of our own pages minted.\n * Neither describes anybody: they are pointers, and a pointer is worth only\n * what it can be followed with.\n *\n * ## Why these are the exception to \"identifying fields are hashed\"\n *\n * `external_id` used to be hashed here and nothing else, on the reasoning that\n * it is sometimes an email or a document number in disguise. That reasoning\n * held and the consequence did not: it made the field **useless to the person\n * who sent it**. An integrator posting `external_id: \"hs:contact:12345\"` opened\n * the event and read *Provided, stored hashed* — no way to check we had read\n * the right record, no way to paste the id back into their CRM, and no way to\n * tell a working integration from one silently keyed on the wrong column. The\n * whole point of the field is to be recognised on the way back out.\n *\n * The privacy this bought was also smaller than it looked. The digest is still\n * computed, still what `identity_hash` stores and still what the identity graph\n * joins on — see `./identity` — so nothing about the joining changed. What is\n * new is a second copy in the clear, under the key that says so.\n *\n * A value that arrives *already* a digest still keeps `<field>_sha256`, for the\n * rule that governs every field here: a digest cannot be undone, so the key has\n * to say what is inside it.\n */\nexport function resolveOwnId(field: \"external_id\" | \"baker_id\", raw: string): { key: string; value: string } | null {\n const value = raw.trim();\n if (value === \"\") return null;\n if (isSha256Hex(value)) return { key: `${field}_sha256`, value: value.toLowerCase() };\n return { key: field, value: value.slice(0, MAX_MATCH_VALUE) };\n}\n\n/** A cookie value, as Meta minted it: bounded, and otherwise untouched. */\nexport function resolveMatchCookie(raw: string): string | null {\n const value = raw.trim();\n return value === \"\" ? null : value.slice(0, MAX_MATCH_VALUE);\n}\n\n/**\n * The `fbclid` hiding inside an `fbc`, or `null`.\n *\n * `fbc` is `fb.<subdomain index>.<timestamp>.<fbclid>` — Meta's own encoding of\n * a click id it already saw. A sender whose system stored the cookie has the\n * click id and does not know it, so reading it out costs one split and gives\n * the event the same paid-attribution column a landing page would have written\n * from the URL. Nothing is invented: the value was there.\n */\nexport function fbclidFromFbc(fbc: string): string | null {\n const parts = fbc.split(\".\");\n if (parts.length < 4 || parts[0] !== \"fb\") return null;\n const id = parts.slice(3).join(\".\");\n return id === \"\" ? null : id;\n}\n","/**\n * The click ids a sender may hand over, named the way their own system stored\n * them.\n *\n * The wire uses the **URL parameter** spelling (`li_fat_id`) rather than the\n * analytics row's field spelling (`liFatId`), because a client's CRM captured\n * these off a landing URL and that is the name it wrote them down under.\n * {@link clickIdsFromWire} is the one place the two vocabularies meet.\n *\n * Mirrored from `CLICK_ID_FIELDS` in `../analytics/normalize.ts`, which is the\n * source of truth for which click ids the store has columns for.\n * `vocabulary.parity.test.ts` reads that file and fails if the two drift — a\n * missing entry here is an attribution a client sent and we dropped.\n */\n\nimport type { ClickIdFields } from \"../analytics/normalize\";\n\nexport const INGEST_CLICK_ID_PARAMS = [\n \"gclid\",\n \"wbraid\",\n \"gbraid\",\n \"dclid\",\n \"fbclid\",\n \"ttclid\",\n \"twclid\",\n \"li_fat_id\",\n \"msclkid\",\n \"rdt_cid\",\n \"epik\",\n \"sccid\",\n \"oppref\",\n] as const;\nexport type IngestClickIdParam = (typeof INGEST_CLICK_ID_PARAMS)[number];\n\nconst FIELD_FOR_PARAM: Readonly<Record<IngestClickIdParam, keyof ClickIdFields>> = {\n gclid: \"gclid\",\n wbraid: \"wbraid\",\n gbraid: \"gbraid\",\n dclid: \"dclid\",\n fbclid: \"fbclid\",\n ttclid: \"ttclid\",\n twclid: \"twclid\",\n li_fat_id: \"liFatId\",\n msclkid: \"msclkid\",\n rdt_cid: \"rdtCid\",\n epik: \"epik\",\n sccid: \"sccid\",\n oppref: \"oppref\",\n};\n\n/** The wire's click block as the analytics row builder names its fields. Empty values are dropped. */\nexport function clickIdsFromWire(click: Partial<Record<IngestClickIdParam, string | null>> | null | undefined): {\n clickIds: ClickIdFields;\n kinds: IngestClickIdParam[];\n} {\n const clickIds: ClickIdFields = {};\n const kinds: IngestClickIdParam[] = [];\n for (const param of INGEST_CLICK_ID_PARAMS) {\n const value = click?.[param];\n if (typeof value !== \"string\" || value === \"\") continue;\n clickIds[FIELD_FOR_PARAM[param]] = value;\n kinds.push(param);\n }\n return { clickIds, kinds };\n}\n","/**\n * What a source can be read into: the fields of an event, named the way\n * `POST /v1/events` already names them.\n *\n * Assembled from the ingest vocabulary rather than spelled a fourth time. A\n * mapping is `SourceField → dotted path`, and the field half of that pair has\n * to be a name the wire already accepts, because the whole of what a source\n * does is build an `IngestEventInput` and hand it to the same door the\n * client's own server would have used. A field that existed only here would be\n * a field the event could not carry.\n */\n\nimport { MATCH_FIELDS, type MatchField } from \"../event-ingest/matching\";\nimport type { IngestClickIdParam } from \"../event-ingest/vocabulary\";\nimport { INGEST_CLICK_ID_PARAMS } from \"../event-ingest/vocabulary\";\n\n/** Where a field sits on the sheet: one row per group, in this order. */\nexport type SourceFieldGroup = \"event\" | \"person\" | \"money\" | \"click\";\n\nexport type SourceField =\n | \"event_name\"\n | \"event_time\"\n | \"event_id\"\n | \"email\"\n | \"phone\"\n | \"external_id\"\n | MatchField\n | \"value\"\n | \"currency\"\n | IngestClickIdParam;\n\nexport interface SourceFieldSpec {\n field: SourceField;\n /** The product word for it — what the sheet and the CLI show. */\n label: string;\n group: SourceFieldGroup;\n}\n\nconst MATCH_LABELS: Readonly<Record<MatchField, string>> = {\n first_name: \"First name\",\n last_name: \"Last name\",\n date_of_birth: \"Date of birth\",\n gender: \"Gender\",\n city: \"City\",\n region: \"Region\",\n postal_code: \"Postcode\",\n country: \"Country\",\n};\n\nconst CLICK_LABELS: Readonly<Record<IngestClickIdParam, string>> = {\n gclid: \"Google click id\",\n wbraid: \"Google click id (iOS, web to app)\",\n gbraid: \"Google click id (iOS, app)\",\n dclid: \"Google click id (Display & Video)\",\n fbclid: \"Meta click id\",\n ttclid: \"TikTok click id\",\n twclid: \"X click id\",\n li_fat_id: \"LinkedIn click id\",\n msclkid: \"Microsoft click id\",\n rdt_cid: \"Reddit click id\",\n epik: \"Pinterest click id\",\n sccid: \"Snapchat click id\",\n oppref: \"ChatGPT Ads click id\",\n};\n\nexport const SOURCE_FIELDS: readonly SourceFieldSpec[] = [\n { field: \"event_name\", label: \"What happened\", group: \"event\" },\n { field: \"event_time\", label: \"When it happened\", group: \"event\" },\n { field: \"event_id\", label: \"Its id\", group: \"event\" },\n { field: \"email\", label: \"Email\", group: \"person\" },\n { field: \"phone\", label: \"Phone\", group: \"person\" },\n { field: \"external_id\", label: \"Your own id for the person\", group: \"person\" },\n ...MATCH_FIELDS.map((field) => ({ field, label: MATCH_LABELS[field], group: \"person\" as const })),\n { field: \"value\", label: \"Amount\", group: \"money\" },\n { field: \"currency\", label: \"Currency\", group: \"money\" },\n ...INGEST_CLICK_ID_PARAMS.map((field) => ({ field, label: CLICK_LABELS[field], group: \"click\" as const })),\n];\n\nexport const SOURCE_FIELD_NAMES: readonly SourceField[] = SOURCE_FIELDS.map((spec) => spec.field);\n\nconst FIELD_SET: ReadonlySet<string> = new Set(SOURCE_FIELD_NAMES);\n\nexport function isSourceField(value: string): value is SourceField {\n return FIELD_SET.has(value);\n}\n\nexport const SOURCE_FIELD_GROUPS: readonly { group: SourceFieldGroup; label: string; detail: string }[] = [\n { group: \"event\", label: \"The event\", detail: \"What it is called, when it happened, and its own id.\" },\n {\n group: \"person\",\n label: \"Who it is about\",\n detail: \"How the platforms find the person. Email or phone is the one that matters.\",\n },\n {\n group: \"money\",\n label: \"What it was worth\",\n detail: \"The amount and its currency, for revenue and for the platforms.\",\n },\n {\n group: \"click\",\n label: \"The ad click that brought them\",\n detail: \"When the source keeps the click id, the campaign gets the credit.\",\n },\n];\n\n/**\n * A row that is not a field of the event but one of its own **properties** —\n * the flat `properties` object every event carries, which Measure → Events\n * breaks an event down by and which a send can forward to a platform as an\n * extra parameter (Meta's `custom_data`, a GA4 event parameter).\n *\n * Spelled `properties.<key>` in the mapping so the row shares the table with\n * the fields and the CLI's `--field` takes it unchanged, while an unknown bare\n * key is still refused: the namespace is what tells a deliberate extra\n * property from a typo that would otherwise silently map nothing.\n */\nexport const PROPERTY_ROW_PREFIX = \"properties.\";\n\n/** The longest a property's key may be. Keys are a shared dictionary in the store, so they are kept short and plain. */\nexport const PROPERTY_KEY_MAX = 64;\n\n/** Letters, digits, underscore, dash and dot — what a property key of `POST /v1/events` may be, and what a platform parameter name may be. */\nconst PROPERTY_KEY = /^[A-Za-z0-9_][A-Za-z0-9_.-]*$/;\n\n/** Keys a source writes itself; a row naming one would be overwritten in silence. */\nexport const RESERVED_PROPERTY_KEYS: readonly string[] = [\"baker_source\", \"hubspot_property\", \"hubspot_value\"];\n\n/** Whether a mapping row names a property rather than a field. */\nexport function isPropertyRow(row: string): boolean {\n return row.startsWith(PROPERTY_ROW_PREFIX);\n}\n\n/** The property's own key, for a `properties.<key>` row; null for anything else. */\nexport function propertyKeyOf(row: string): string | null {\n return isPropertyRow(row) ? row.slice(PROPERTY_ROW_PREFIX.length) : null;\n}\n\n/** The mapping row for a property key. */\nexport function propertyRow(key: string): string {\n return `${PROPERTY_ROW_PREFIX}${key}`;\n}\n\n/**\n * Why a property key cannot be used, in one sentence, or null when it can.\n * The same rule for a source's extra properties and for a send's parameters.\n */\nexport function propertyKeyProblem(key: string): string | null {\n const trimmed = key.trim();\n if (trimmed === \"\") return \"A property needs a name.\";\n if (trimmed.length > PROPERTY_KEY_MAX) return `A property name is at most ${PROPERTY_KEY_MAX} characters.`;\n if (!PROPERTY_KEY.test(trimmed)) {\n return `\"${trimmed}\" is not a property name: letters, digits, underscore, dash and dot only, starting with a letter or digit.`;\n }\n if (RESERVED_PROPERTY_KEYS.includes(trimmed)) return `\"${trimmed}\" is written by Baker itself; pick another name.`;\n return null;\n}\n\n/**\n * Whether a mapping row is one a source can hold: a field of the event, or a\n * well-named property. The reason when it is not.\n */\nexport function mappingRowProblem(row: string): string | null {\n if (isSourceField(row)) return null;\n const key = propertyKeyOf(row);\n if (key === null) {\n return `\"${row}\" is not a field an event can carry. A field is one of ${SOURCE_FIELD_NAMES.join(\", \")}; an extra property is spelled properties.<name>.`;\n }\n return propertyKeyProblem(key);\n}\n\n/** The property rows of a mapping, as `key → template`, in the order stored. */\nexport function propertyRows(mapping: Readonly<Record<string, string>>): { key: string; template: string }[] {\n return Object.entries(mapping).flatMap(([row, template]) => {\n const key = propertyKeyOf(row);\n return key === null ? [] : [{ key, template }];\n });\n}\n","/**\n * A mapping row is a template: literal text with `{{mentions}}` in it.\n *\n * ## Why a template and not a path\n *\n * A row used to hold one dotted path, and one path answers one question —\n * \"which field of the payload is the email\". It cannot answer the next three:\n * a currency the tool never sends but the company knows (`EUR`), a name split\n * over two fields (`{{firstname}} {{lastname}}`), or an amount a HubSpot\n * contact carries under a property nobody would guess. A template answers all\n * of them with one rule the Forms builder already teaches: type text, insert\n * a variable. The same spelling is what the CLI takes, so an agent and a\n * person write the same thing.\n *\n * ## What a mention points at\n *\n * Whatever the source can read. For an address it is a dotted path into the\n * payload (`contact.email`, `deal.contacts.0.email`); for a HubSpot read it\n * is a contact property's internal name (`hs_google_click_id`), plus `id` for\n * the contact's own id. The template does not know which — the lookup passed\n * to `renderTemplate` does.\n *\n * A mention names exactly one thing. There was a `{{phone|mobilephone}}`\n * spelling for \"the first that holds anything\"; it is gone, because it was a\n * rule the Forms builder's variables do not have, and a row that reads\n * differently from every other variable field in the product is a row nobody\n * can predict. A person who wants the mobile picks the mobile.\n */\n\nconst MENTION = /\\{\\{\\s*([^{}]+?)\\s*\\}\\}/g;\n\n/** The path a mention names, with the braces on. */\nexport function mentionOf(path: string): string {\n return `{{${path}}}`;\n}\n\n/** Every path a template reads, in order, once each. */\nexport function templateMentions(template: string): string[] {\n const seen: string[] = [];\n for (const match of template.matchAll(MENTION)) {\n const path = (match[1] ?? \"\").trim();\n if (path !== \"\" && !seen.includes(path)) seen.push(path);\n }\n return seen;\n}\n\n/**\n * The template with every mention replaced by what it points at, trimmed —\n * or nothing, when what is left is empty. An empty mention reads as empty\n * text rather than as its own spelling, so a template made only of mentions\n * the payload did not fill is \"not sent\", not the literal `{{phone}}`.\n */\nexport function renderTemplate(template: string, lookup: (path: string) => string | undefined): string | undefined {\n const rendered = template.replace(MENTION, (_whole, path: string) => lookup(path.trim()) ?? \"\").trim();\n return rendered === \"\" ? undefined : rendered;\n}\n\n/** The one path a template is, when it is exactly one mention and nothing else. */\nexport function isBareMention(template: string): string | null {\n const match = /^\\{\\{\\s*([^{}]+?)\\s*\\}\\}$/.exec(template.trim());\n return match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B;AAGhC,IAAM,eAAe;AAGd,IAAM,yBAA4C,CAAC,gBAAgB,oBAAoB,eAAe;AAGtG,SAAS,cAAc,KAAsB;AAClD,SAAO,IAAI,WAAW,mBAAmB;AAC3C;AAGO,SAAS,cAAc,KAA4B;AACxD,SAAO,cAAc,GAAG,IAAI,IAAI,MAAM,oBAAoB,MAAM,IAAI;AACtE;AAWO,SAAS,mBAAmB,KAA4B;AAC7D,QAAM,UAAU,IAAI,KAAK;AACzB,MAAI,YAAY,GAAI,QAAO;AAC3B,MAAI,QAAQ,SAAS,iBAAkB,QAAO,8BAA8B,gBAAgB;AAC5F,MAAI,CAAC,aAAa,KAAK,OAAO,GAAG;AAC/B,WAAO,IAAI,OAAO;AAAA,EACpB;AACA,MAAI,uBAAuB,SAAS,OAAO,EAAG,QAAO,IAAI,OAAO;AAChE,SAAO;AACT;AAMO,SAAS,kBAAkB,KAA4B;AAC5D,MAAI,cAAc,GAAG,EAAG,QAAO;AAC/B,QAAM,MAAM,cAAc,GAAG;AAC7B,MAAI,QAAQ,MAAM;AAChB,WAAO,IAAI,GAAG,0DAA0D,mBAAmB,KAAK,IAAI,CAAC;AAAA,EACvG;AACA,SAAO,mBAAmB,GAAG;AAC/B;;;AC3IA,IAAM,UAAU;AAGT,SAAS,UAAU,MAAsB;AAC9C,SAAO,KAAK,IAAI;AAClB;AAGO,SAAS,iBAAiB,UAA4B;AAC3D,QAAM,OAAiB,CAAC;AACxB,aAAW,SAAS,SAAS,SAAS,OAAO,GAAG;AAC9C,UAAM,QAAQ,MAAM,CAAC,KAAK,IAAI,KAAK;AACnC,QAAI,SAAS,MAAM,CAAC,KAAK,SAAS,IAAI,EAAG,MAAK,KAAK,IAAI;AAAA,EACzD;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/flows/connect.ts"],"sourcesContent":["/**\n * `connect`: fill a Form's step or destination yourself once you know which\n * resource is meant, instead of parking the turn on the chat's picker card.\n *\n * Three sources, one write:\n * - `--hubspot-form <id>` — a HubSpot form as a `hubspotForm` destination.\n * - `--resource <id>` / `--new-sheet <title>` / nothing — Calendly, SavvyCal\n * and GoHighLevel steps; Google Sheets, Pipedrive and GoHighLevel\n * destinations. The backend reads the resource through the company's\n * connected account and answers with exactly what the card would write,\n * sealed under the flow key where it is a destination — so this command\n * writes ciphertext it cannot read.\n * - `--same-as <slug>:<id>` — the destination or step another Form already\n * has, copied as-is. No platform is asked anything.\n *\n * `request_flow_input` stays the path when nothing is connected, when a\n * spreadsheet has never been chosen, or when the agent cannot tell which\n * resource is meant.\n */\n\nimport {\n FLOW_AGENT_DESTINATION_KINDS,\n FLOW_PROVIDER_TYPE,\n type FlowAgentDestinationKind,\n type FlowsResolveResponse,\n type FlowsSealRequest,\n type FlowsSealResponse,\n type HubspotFormsDestinationResponse,\n} from \"@baker/api\";\nimport { defineCommand } from \"citty\";\nimport { ApiError, apiPost } from \"../../client.ts\";\nimport { writeJson } from \"../../output.ts\";\nimport { registerSchema } from \"../../schemas.ts\";\nimport { failApi } from \"../actions/shared.ts\";\nimport { hubspotRefusal } from \"../hubspot/refusal.ts\";\nimport { collectSideEffects, readFlowTree, readSettings, walkNodes, writeFlowTree } from \"./shared.ts\";\n\ntype AnyRecord = Record<string, unknown>;\n\ntype Sealed = { oauthProviderId: string; encryptedConfig: string };\n\ntype Attached = { ok: true; nodeId: string; sideEffectId: string } | { ok: false; message: string; fix: string };\n\ntype Target = { kind: string; on: \"node\" | \"sideEffect\"; ids: string[] };\n\ntype Stepped = { ok: true; nodeId: string; type: string } | { ok: false; message: string; fix: string };\n\nconst STEP_KINDS = new Set([\"calendly\", \"savvycal\", \"highlevel\", \"highlevelForm\", \"hubspot\", \"hubspotMeeting\"]);\nconst OAUTH_SIDE_EFFECTS = new Set([\"hubspotForm\", \"googleSpreadsheet\", \"pipedrive\", \"goHighlevelContact\"]);\n\n/**\n * Put the sealed destination on the side effect `named` picks — or, with no\n * name, on the form's only one of `type`. Mutates `tree`; the caller writes it.\n */\nexport function attachDestination(\n tree: AnyRecord,\n named: string | undefined,\n sealed: Sealed,\n type = \"hubspotForm\",\n): Attached {\n const ofType = collectSideEffects(tree).filter((entry) => entry.sideEffect.type === type);\n const inventory = ofType.map((entry) => String(entry.sideEffect.id)).join(\", \") || \"none\";\n const chosen = named\n ? collectSideEffects(tree).find((entry) => entry.sideEffect.id === named)\n : ofType.length === 1\n ? ofType[0]\n : undefined;\n if (!chosen) {\n return {\n ok: false,\n message: named\n ? `No side effect with id \"${named}\" in this form.`\n : `This form has ${ofType.length} ${type} side effects — name one with --side-effect <id>.`,\n fix:\n ofType.length === 0\n ? `Add one first: baker flows add-side-effect <slug> --node <stepId> --type ${type}`\n : `${type} side effects in this form: ${inventory}`,\n };\n }\n if (chosen.sideEffect.type !== type) {\n return {\n ok: false,\n message: `Side effect \"${named}\" is a ${String(chosen.sideEffect.type)}, not a ${type}.`,\n fix: `${type} side effects in this form: ${inventory}`,\n };\n }\n chosen.sideEffect.oauthProviderId = sealed.oauthProviderId;\n chosen.sideEffect.encryptedConfig = sealed.encryptedConfig;\n return { ok: true, nodeId: String(chosen.node.id), sideEffectId: String(chosen.sideEffect.id) };\n}\n\nfunction isSet(value: unknown): boolean {\n return typeof value === \"string\" && value.length > 0;\n}\n\n/**\n * Every side effect of `type` that still lacks its account or its config — what\n * `--all` wires. One already wired is left alone, so re-running after a partial\n * setup never repoints a destination someone chose.\n */\nexport function unwiredSideEffects(tree: AnyRecord, type: string): string[] {\n return collectSideEffects(tree)\n .filter(({ sideEffect }) => sideEffect.type === type)\n .filter(\n ({ sideEffect }) =>\n (OAUTH_SIDE_EFFECTS.has(type) && !isSet(sideEffect.oauthProviderId)) || !isSet(sideEffect.encryptedConfig),\n )\n .map(({ sideEffect }) => String(sideEffect.id));\n}\n\nexport function unwiredHubspotForms(tree: AnyRecord): string[] {\n return unwiredSideEffects(tree, \"hubspotForm\");\n}\n\n/** Destinations with nothing confidential in them: the agent states them, no card. */\nconst STATED_KINDS = new Set([\"email\", \"httpWebhook\"]);\n\n/** The stated kind an `--email` / `--subject` / `--url` call is about. */\nfunction statedKind(args: AnyRecord): string | undefined {\n if (typeof args.email === \"string\" || typeof args.subject === \"string\") return \"email\";\n if (typeof args.url === \"string\") return \"httpWebhook\";\n return undefined;\n}\n\ntype SealPlan = { ok: true; request: FlowsSealRequest } | { ok: false; message: string; fix: string };\n\n/** What `--email/--subject` or `--url` say, as the request the backend seals — or why not. */\nexport function sealRequestFor(kind: string, args: AnyRecord): SealPlan {\n const text = (key: string) => (typeof args[key] === \"string\" && args[key].trim() ? args[key].trim() : undefined);\n if (kind === \"email\") {\n const email = text(\"email\");\n const subject = text(\"subject\");\n if (!email || !subject) {\n return {\n ok: false,\n message: \"An email destination needs both who receives it and its subject.\",\n fix: 'Pass --email \"a@x.com, b@x.com\" --subject \"New lead — <Form name>\". Write the subject yourself from the Form; ask the user only for an address you were not given.',\n };\n }\n return { ok: true, request: { type: \"email\", email, subject } };\n }\n if (kind === \"httpWebhook\") {\n const apiUrl = text(\"url\");\n if (!apiUrl) {\n return { ok: false, message: \"A webhook destination needs its address.\", fix: \"Pass --url https://…\" };\n }\n return { ok: true, request: { type: \"httpWebhook\", apiUrl } };\n }\n return {\n ok: false,\n message: `A ${kind} destination holds a credential, so it is not one you can state.`,\n fix: \"Its token or URL is the user's to enter: request_flow_input.\",\n };\n}\n\ntype Restatable = { ok: true; ids: string[]; skipped: string[] } | { ok: false; message: string; fix: string };\n\n/** Why a stated value must not replace what `settings` holds, or undefined when it may. */\nconst UNREADABLE = \"holds settings this chat cannot read\";\n\nfunction keepsWhatTheAgentCannotState(kind: string, settings: AnyRecord | null | undefined): string | undefined {\n if (settings === null) return UNREADABLE;\n if (kind === \"httpWebhook\" && typeof settings?.auth === \"string\" && settings.auth !== \"noAuth\") {\n return \"sends a credential the user entered\";\n }\n if (kind === \"email\" && settings !== undefined && \"email\" in settings && typeof settings.email !== \"string\") {\n return \"replies to the visitor's own email answer\";\n }\n return undefined;\n}\n\n/**\n * Which of `target`'s destinations a stated `--email` / `--url` may overwrite.\n * The sealed value is replaced whole, so a webhook's credential or a reply to\n * the visitor's own address would be lost and nothing the agent can say puts it\n * back. One whose settings came back unreadable (null) is treated the same:\n * unknown is not empty. `--all` passes over those. An unreadable email may be\n * replaced explicitly with a complete recipient list and subject, without\n * reading the old value or claiming ownership of its ciphertext.\n */\nexport function restatableTargets(\n target: Target,\n settingsById: Record<string, AnyRecord | null>,\n all: boolean,\n replaceUnreadableEmail = false,\n): Restatable {\n const kept = target.ids.flatMap((id) => {\n if (\n target.kind === \"email\" &&\n settingsById[id] === null &&\n replaceUnreadableEmail &&\n !all &&\n target.ids.length === 1\n ) {\n return [];\n }\n const why = keepsWhatTheAgentCannotState(target.kind, settingsById[id]);\n return why ? [{ id, why }] : [];\n });\n const ids = target.ids.filter((id) => !kept.some((entry) => entry.id === id));\n if (kept.length > 0 && (!all || ids.length === 0)) {\n const [first] = kept;\n return {\n ok: false,\n message: `\"${first?.id}\" ${first?.why}; restating it would replace that.`,\n fix:\n first?.why === UNREADABLE\n ? target.kind === \"email\"\n ? `Baker cannot read the old recipients or tell whether this replies to a visitor. If the user wants to replace this destination, pass --side-effect ${first?.id} --replace-unreadable --email <complete recipient list> --subject <subject>. This replaces its entire previous setup; never use it to add a recipient to an unknown list. Otherwise leave it as it is and add a separate team email destination.`\n : \"Have the user restate the webhook address and any credential once with request_flow_input; after that this command can change a webhook with no credential.\"\n : target.kind === \"httpWebhook\"\n ? \"A new address for a webhook with a credential is the user's to enter with it: request_flow_input.\"\n : \"Leave it as it is. Add a separate email destination for the team: baker flows add-side-effect.\",\n };\n }\n return { ok: true, ids, skipped: kept.map((entry) => entry.id) };\n}\n\n/** Write sealed settings onto a destination that has no account (email, webhook). Mutates `tree`. */\nexport function attachSettings(tree: AnyRecord, id: string, encryptedConfig: string, type: string): Attached {\n const chosen = collectSideEffects(tree).find((entry) => entry.sideEffect.id === id);\n if (!chosen || chosen.sideEffect.type !== type) {\n const ofType = collectSideEffects(tree).filter((entry) => entry.sideEffect.type === type);\n return {\n ok: false,\n message: chosen\n ? `Side effect \"${id}\" is a ${String(chosen.sideEffect.type)}, not a ${type}.`\n : `No side effect with id \"${id}\" in this form.`,\n fix: `${type} side effects in this form: ${ofType.map((entry) => String(entry.sideEffect.id)).join(\", \") || \"none\"}`,\n };\n }\n chosen.sideEffect.encryptedConfig = encryptedConfig;\n return { ok: true, nodeId: String(chosen.node.id), sideEffectId: id };\n}\n\nfunction stepType(node: AnyRecord | undefined): string | undefined {\n const type = (node?.nodeData as AnyRecord | undefined)?.type;\n return typeof type === \"string\" ? type : undefined;\n}\n\nfunction findStep(tree: AnyRecord, nodeId: string): AnyRecord | undefined {\n return walkNodes(tree).find((node) => node.id === nodeId);\n}\n\n/** Write a picked resource into a step's `form.external`, keeping what the step autofills. */\nexport function attachStep(tree: AnyRecord, nodeId: string, external: AnyRecord): Stepped {\n const node = findStep(tree, nodeId);\n const type = stepType(node);\n if (!node || !type) {\n return {\n ok: false,\n message: `No step with id \"${nodeId}\" in this form.`,\n fix: \"Step ids: baker flows show <slug>\",\n };\n }\n if (!STEP_KINDS.has(type)) {\n return {\n ok: false,\n message: `Step \"${nodeId}\" is a ${type}, which embeds nothing from another platform.`,\n fix: \"Only calendly, savvycal, highlevel, highlevelForm, hubspot and hubspotMeeting steps take a resource.\",\n };\n }\n const nodeData = node.nodeData as AnyRecord;\n const form = (nodeData.form as AnyRecord | undefined) ?? {};\n nodeData.form = { autofilledFields: {}, ...form, external };\n return { ok: true, nodeId, type };\n}\n\n/** Steps of `type` with nothing picked yet — what `--all` fills for a step kind. */\nexport function unpickedSteps(tree: AnyRecord, type: string): string[] {\n return walkNodes(tree)\n .filter((node) => stepType(node) === type)\n .filter((node) => ((node.nodeData as AnyRecord).form as AnyRecord | undefined)?.external == null)\n .map((node) => String(node.id));\n}\n\n/**\n * Give `targetId` exactly the destination (or picked resource) `sourceId`\n * already has in another Form. Only between the same type: a sheet's sealed\n * config means nothing to Pipedrive.\n */\nexport function copyDestination(source: AnyRecord, sourceId: string, target: AnyRecord, targetId: string): Stepped {\n const from = collectSideEffects(source).find((entry) => entry.sideEffect.id === sourceId);\n if (from) {\n const type = String(from.sideEffect.type);\n if (!isSet(from.sideEffect.oauthProviderId) || !isSet(from.sideEffect.encryptedConfig)) {\n return {\n ok: false,\n message: `\"${sourceId}\" is not wired itself — nothing to copy.`,\n fix: \"Copy from one that is.\",\n };\n }\n const attached = attachDestination(\n target,\n targetId,\n {\n oauthProviderId: String(from.sideEffect.oauthProviderId),\n encryptedConfig: String(from.sideEffect.encryptedConfig),\n },\n type,\n );\n return attached.ok ? { ok: true, nodeId: attached.nodeId, type } : attached;\n }\n const step = findStep(source, sourceId);\n const external = ((step?.nodeData as AnyRecord | undefined)?.form as AnyRecord | undefined)?.external;\n if (!step || external == null || typeof external !== \"object\") {\n return {\n ok: false,\n message: `No wired side effect or picked step \"${sourceId}\" in the source form.`,\n fix: \"Ids: baker flows show <slug>\",\n };\n }\n const targetType = stepType(findStep(target, targetId));\n if (targetType !== stepType(step)) {\n return {\n ok: false,\n message: `\"${sourceId}\" is a ${String(stepType(step))} and \"${targetId}\" a ${String(targetType)} — copy only between the same type.`,\n fix: \"Pick a source of the same type.\",\n };\n }\n return attachStep(target, targetId, structuredClone(external as AnyRecord));\n}\n\nfunction refuse(\n message: string,\n fix: string | { action: string; explanation: string },\n code = \"VALIDATION_ERROR\",\n): never {\n writeJson({ ok: false, error: { code, message, fix } });\n process.exit(1);\n}\n\nfunction allTargets(tree: AnyRecord, kind: string | undefined): Target {\n if (!kind) refuse(\"--all needs --type <kind> to know what to wire.\", \"e.g. --all --type googleSpreadsheet\");\n const on = STEP_KINDS.has(kind) ? \"node\" : \"sideEffect\";\n // A stated destination is restated whole (\"every lead to Vicente and Fran\"), set or not.\n const ids = STATED_KINDS.has(kind)\n ? collectSideEffects(tree)\n .filter(({ sideEffect }) => sideEffect.type === kind)\n .map(({ sideEffect }) => String(sideEffect.id))\n : on === \"node\"\n ? unpickedSteps(tree, kind)\n : unwiredSideEffects(tree, kind);\n if (ids.length === 0 && STATED_KINDS.has(kind)) {\n refuse(\n `This Form has no ${kind} destination.`,\n `Add one: baker flows add-side-effect <slug> --node <stepId> --type ${kind}`,\n );\n }\n if (ids.length === 0) {\n refuse(\n `Every ${kind} in this Form is already wired.`,\n \"Repoint one by naming it with --node / --side-effect instead of --all.\",\n );\n }\n return { kind, on, ids };\n}\n\nfunction onlyOfType(tree: AnyRecord, type: string): string {\n const probe = attachDestination(tree, undefined, { oauthProviderId: \"\", encryptedConfig: \"\" }, type);\n if (!probe.ok) refuse(probe.message, probe.fix);\n return probe.sideEffectId;\n}\n\nfunction stepTarget(tree: AnyRecord, node: string): Target {\n const type = stepType(findStep(tree, node));\n if (!type) refuse(`No step with id \"${node}\" in this form.`, \"Step ids: baker flows show <slug>\");\n return { kind: type, on: \"node\", ids: [node] };\n}\n\nfunction sideEffectTarget(tree: AnyRecord, named: string): Target {\n const found = collectSideEffects(tree).find((entry) => entry.sideEffect.id === named);\n if (!found) refuse(`No side effect with id \"${named}\" in this form.`, \"Side-effect ids: baker flows show <slug>\");\n return { kind: String(found.sideEffect.type), on: \"sideEffect\", ids: [named] };\n}\n\n/** Which steps or side effects this call fills, resolved before any platform is asked anything. */\nexport function targetsFor(tree: AnyRecord, args: AnyRecord): Target {\n const node = typeof args.node === \"string\" ? args.node : undefined;\n const named = typeof args[\"side-effect\"] === \"string\" ? args[\"side-effect\"] : undefined;\n if ([node, named, args.all === true ? \"all\" : undefined].filter(Boolean).length > 1) {\n refuse(\"Pass one of --node, --side-effect or --all.\", \"One target per call; --all for every unwired one.\");\n }\n if (args.all === true) {\n const kind = typeof args.type === \"string\" ? args.type : args[\"hubspot-form\"] ? \"hubspotForm\" : statedKind(args);\n return allTargets(tree, kind);\n }\n if (node) return stepTarget(tree, node);\n if (named) return sideEffectTarget(tree, named);\n if (args[\"hubspot-form\"]) return { kind: \"hubspotForm\", on: \"sideEffect\", ids: [onlyOfType(tree, \"hubspotForm\")] };\n const stated = statedKind(args);\n if (stated) return { kind: stated, on: \"sideEffect\", ids: [onlyOfType(tree, stated)] };\n return refuse(\n \"Name what to fill: --node <stepId>, --side-effect <id>, or --all --type <kind>.\",\n \"Ids: baker flows show <slug>\",\n );\n}\n\nasync function sealHubspotForm(formId: string): Promise<HubspotFormsDestinationResponse[\"data\"]> {\n try {\n return (await apiPost<HubspotFormsDestinationResponse>(\"/api/hubspot/forms/destination\", { formId })).data;\n } catch (err) {\n const refusal = err instanceof ApiError ? hubspotRefusal(err.code, err.message) : null;\n if (err instanceof ApiError && refusal !== null) refuse(err.message, refusal.fix, refusal.code);\n failApi(err);\n }\n}\n\nfunction isAgentKind(kind: string): kind is FlowAgentDestinationKind {\n return (FLOW_AGENT_DESTINATION_KINDS as readonly string[]).includes(kind);\n}\n\n/**\n * The refusals only the user can clear, as the call that clears them: nothing\n * connected is the connect card; two accounts is a question only when the\n * agent cannot tell which one the user means.\n */\nexport function destinationRefusal(\n kind: FlowAgentDestinationKind,\n err: ApiError,\n): { code: string; fix: string } | null {\n if (err.code === \"NOT_FOUND\" && err.message.includes(\"is connected to this company\")) {\n return {\n code: \"NOT_CONNECTED\",\n fix: `AGENT INSTRUCTION: only the user can connect it. Call request_connection with { platform: \"${FLOW_PROVIDER_TYPE[kind]}\", reason } — reason in their words — then run this again. Keep going with the rest of the task meanwhile.`,\n };\n }\n if (err.code === \"CONFLICT\" && err.message.includes(\"--account\")) {\n return {\n code: \"SEVERAL_ACCOUNTS\",\n fix: \"Pass --account <id> when the user or the brief makes clear which one; otherwise ask them which (AskUserQuestion), naming the accounts above.\",\n };\n }\n return null;\n}\n\nfunction resolveBody(kind: FlowAgentDestinationKind, args: AnyRecord): AnyRecord {\n const columns =\n typeof args.columns === \"string\"\n ? args.columns\n .split(\",\")\n .map((column) => column.trim())\n .filter(Boolean)\n : undefined;\n return {\n kind,\n ...(typeof args.account === \"string\" ? { account: args.account } : {}),\n ...(typeof args.resource === \"string\" ? { resourceId: args.resource } : {}),\n ...(typeof args.tab === \"string\" ? { tab: args.tab } : {}),\n ...(typeof args[\"new-sheet\"] === \"string\" ? { newSheet: { title: args[\"new-sheet\"], columns } } : {}),\n };\n}\n\nasync function resolveDestination(\n kind: FlowAgentDestinationKind,\n args: AnyRecord,\n): Promise<FlowsResolveResponse[\"data\"]> {\n try {\n return (await apiPost<FlowsResolveResponse>(\"/api/flows/destinations/resolve\", resolveBody(kind, args))).data;\n } catch (err) {\n const refusal = err instanceof ApiError ? destinationRefusal(kind, err) : null;\n if (err instanceof ApiError && refusal !== null) refuse(err.message, refusal.fix, refusal.code);\n failApi(err);\n }\n}\n\ntype Wired = { wired: { nodeId: string; sideEffectId?: string }[]; destination: unknown; hints: string[] };\n\nfunction applyAll(target: Target, apply: (id: string) => Stepped | Attached): Wired[\"wired\"] {\n return target.ids.map((id) => {\n const done = apply(id);\n if (!done.ok) refuse(done.message, done.fix);\n return \"sideEffectId\" in done ? { nodeId: done.nodeId, sideEffectId: done.sideEffectId } : { nodeId: done.nodeId };\n });\n}\n\nfunction sameAs(tree: AnyRecord, target: Target, ref: string): Wired {\n const [slug, id] = ref.split(\":\");\n if (!slug || !id) refuse(`--same-as takes <slug>:<id>, got \"${ref}\".`, \"e.g. --same-as madrid:se-gsheet-1\");\n const source = readFlowTree(slug);\n const wired = applyAll(target, (targetId) => copyDestination(source, id, tree, targetId));\n return { wired, destination: { sameAs: ref }, hints: [] };\n}\n\nasync function fromHubspot(tree: AnyRecord, target: Target, formId: string, slug: string): Promise<Wired> {\n if (target.kind !== \"hubspotForm\") {\n refuse(\n `--hubspot-form wires a hubspotForm side effect, not a ${target.kind}.`,\n \"A HubSpot step takes `baker hubspot forms view <id> --as-node` (or `meetings view <slug> --as-node`).\",\n );\n }\n const sealed = await sealHubspotForm(formId);\n const wired = applyAll(target, (id) => attachDestination(tree, id, sealed));\n return {\n wired,\n destination: { formGuid: sealed.formGuid, formName: sealed.formName, portalId: sealed.portalId },\n hints: [\n `Now map each step's answers onto it: baker flows map ${slug} --side-effect <id> --hubspot-form ${sealed.formGuid} --map email=<value> … --write. Field names come from \\`baker hubspot forms view ${sealed.formGuid}\\`.`,\n ],\n };\n}\n\nfunction sheetHints(slug: string, data: Extract<FlowsResolveResponse[\"data\"], { target: \"sideEffect\" }>): string[] {\n const sheet = data.destination;\n if (!sheet)\n return [`Now map the fields: baker flows map ${slug} --side-effect <id> --map <fieldKey>=<value> … --write.`];\n const columns = sheet.columns.map((column) => `${column.letter}=${column.header}`).join(\", \");\n return [\n ...(sheet.created\n ? [\n `Created \"${sheet.name}\" in the connected Google account${sheet.url ? ` (${sheet.url})` : \"\"} — tell the user where their leads will land.`,\n ]\n : []),\n columns\n ? `Columns: ${columns}. Map by letter: baker flows map ${slug} --side-effect <id> --map A=<value> … --write.`\n : `The \"${sheet.tab}\" tab has no header row. Map by letter anyway, and say which column holds what.`,\n ];\n}\n\nasync function fromStated(tree: AnyRecord, target: Target, args: AnyRecord): Promise<Wired> {\n const plan = sealRequestFor(target.kind, args);\n if (!plan.ok) refuse(plan.message, plan.fix);\n const current = await readSettings(tree);\n if (current === null) {\n refuse(\n \"Could not read what this Form's destinations hold now, so nothing was overwritten.\",\n \"Try again in a moment; if it keeps failing, carry on with the rest and tell the user this one is not set.\",\n \"NETWORK_ERROR\",\n );\n }\n const restatable = restatableTargets(target, current, args.all === true, args[\"replace-unreadable\"] === true);\n if (!restatable.ok) refuse(restatable.message, restatable.fix);\n const kept = restatable.skipped.length\n ? [`Left as it was: ${restatable.skipped.join(\", \")} (it holds what only the user can set).`]\n : [];\n let sealed: FlowsSealResponse[\"data\"];\n try {\n sealed = (await apiPost<FlowsSealResponse>(\"/api/flows/destinations/seal\", plan.request)).data;\n } catch (err) {\n failApi(err);\n }\n const wired = applyAll({ ...target, ids: restatable.ids }, (id) =>\n attachSettings(tree, id, sealed.encryptedConfig, target.kind),\n );\n return {\n wired,\n destination: sealed.settings,\n hints: [\n ...kept,\n target.kind === \"email\"\n ? `Leads from these steps now go to ${String(sealed.settings.email)} with the subject \"${String(sealed.settings.subject)}\". Tell the user in those words.`\n : `Submissions now go to ${String(sealed.settings.apiUrl)}.`,\n ],\n };\n}\n\nasync function fromPlatform(tree: AnyRecord, target: Target, args: AnyRecord, slug: string): Promise<Wired> {\n const kind = target.kind;\n if (!isAgentKind(kind)) {\n const hubspotStep = kind === \"hubspot\" || kind === \"hubspotMeeting\";\n refuse(\n `A ${kind} ${target.on === \"node\" ? \"step\" : \"side effect\"} is not something this command can fill from a platform.`,\n hubspotStep\n ? \"Write the blob from `baker hubspot forms view <id> --as-node` (or `meetings view <slug> --as-node`) into the step's form.external.\"\n : OAUTH_SIDE_EFFECTS.has(kind)\n ? \"Pass --hubspot-form <formId>.\"\n : \"It takes typed credentials only the user has: request_flow_input.\",\n );\n }\n const data = await resolveDestination(kind, args);\n if (data.target === \"node\") {\n const wired = applyAll(target, (id) => attachStep(tree, id, data.external));\n return {\n wired,\n destination: { name: data.name, account: data.account },\n hints: [`Picked \"${data.name}\". Autofill its fields from earlier answers in the step's form.autofilledFields.`],\n };\n }\n const sealed = { oauthProviderId: data.oauthProviderId, encryptedConfig: data.encryptedConfig };\n const wired = applyAll(target, (id) => attachDestination(tree, id, sealed, kind));\n return {\n wired,\n destination: data.destination ? { ...data.destination, account: data.account } : { account: data.account },\n hints: sheetHints(slug, data),\n };\n}\n\nregisterSchema({\n command: \"flows.connect\",\n description:\n 'Fill a Form\\'s step or destination yourself — no card for the user. Steps: Calendly, SavvyCal, GoHighLevel calendar/form (`--node <id> --resource <id>`). Destinations: HubSpot form (`--hubspot-form <id>`), Google Sheets (`--resource <spreadsheetId>` or `--new-sheet <title> --columns …`), Pipedrive and GoHighLevel contact (no resource: the connected account is the destination), email (`--email \"a@x.com, b@x.com\" --subject \"New lead — <Form>\"`, never a card), webhook without a credential (`--url`). `--same-as <slug>:<id>` copies what another Form already has. `--all --type <kind>` fills every unwired one of that kind at once. Ids come from `baker flows options <kind>`. Fall back to request_flow_input only when nothing is connected, the sheet was never chosen, or several resources plausibly match.',\n args: {\n slug: { type: \"positional\", description: \"Form slug\", required: true },\n node: {\n type: \"string\",\n description: \"Step id to fill (calendly, savvycal, highlevel, highlevelForm)\",\n required: false,\n },\n \"side-effect\": { type: \"string\", description: \"Side-effect id to wire\", required: false },\n all: { type: \"boolean\", description: \"Every unwired one of --type in this Form\", required: false, default: false },\n type: { type: \"string\", description: \"The kind --all wires (e.g. googleSpreadsheet, calendly)\", required: false },\n resource: { type: \"string\", description: \"Option id from `baker flows options <kind>`\", required: false },\n \"hubspot-form\": {\n type: \"string\",\n description: \"HubSpot form id (from `baker hubspot forms list`)\",\n required: false,\n },\n \"new-sheet\": {\n type: \"string\",\n description: \"Create a Google spreadsheet with this title and wire it\",\n required: false,\n },\n columns: {\n type: \"string\",\n description: \"With --new-sheet: header row, comma-separated, from column A\",\n required: false,\n },\n tab: { type: \"string\", description: \"Google Sheets tab to append to (default: the first)\", required: false },\n \"same-as\": {\n type: \"string\",\n description: \"<slug>:<id> — copy another Form's wired destination or picked step\",\n required: false,\n },\n account: {\n type: \"string\",\n description: \"Connection id, when more than one account of the platform is connected\",\n required: false,\n },\n email: {\n type: \"string\",\n description:\n 'Email destination: who receives each lead, comma-separated for several (--email \"ana@x.com, luis@x.com\"). Never a card: you state it.',\n required: false,\n },\n subject: {\n type: \"string\",\n description:\n 'Email destination: the subject line. Write it yourself from the Form (\"New lead — Private events\").',\n required: false,\n },\n \"replace-unreadable\": {\n type: \"boolean\",\n description:\n \"Email only, one destination: replace unreadable old settings with the complete --email and --subject. Use only when the user intends replacement, never to add to an unknown recipient list. Does not apply with --all.\",\n required: false,\n default: false,\n },\n url: {\n type: \"string\",\n description:\n \"Webhook destination with no credential: its https address. One that needs a token goes to request_flow_input.\",\n required: false,\n },\n },\n});\n\nexport const connectCommand = defineCommand({\n meta: {\n name: \"connect\",\n description:\n 'Fill a step or destination yourself. Start here: baker flows options calendly, then baker flows connect contact --node book --resource <id>. Email: --side-effect se-email-1 --email \"ana@x.com, luis@x.com\" --subject \"New lead — Contact\". Sheets: --side-effect se-gsheet-1 --new-sheet \"Leads\" --columns \"Name,Email\". Same as another Form: --same-as madrid:se-gsheet-1',\n },\n args: {\n slug: { type: \"positional\", description: \"Form slug\", required: true },\n node: { type: \"string\", description: \"Step id to fill\" },\n \"side-effect\": { type: \"string\", description: \"Side-effect id to wire\" },\n all: { type: \"boolean\", description: \"Every unwired one of --type\" },\n type: { type: \"string\", description: \"The kind --all wires\" },\n resource: { type: \"string\", description: \"Option id from baker flows options <kind>\" },\n \"hubspot-form\": { type: \"string\", description: \"HubSpot form id (from baker hubspot forms list)\" },\n \"new-sheet\": { type: \"string\", description: \"Create a spreadsheet with this title\" },\n columns: { type: \"string\", description: \"Header row for --new-sheet, comma-separated\" },\n tab: { type: \"string\", description: \"Sheet tab (default: the first)\" },\n \"same-as\": { type: \"string\", description: \"<slug>:<id> to copy\" },\n account: { type: \"string\", description: \"Connection id when several are connected\" },\n email: { type: \"string\", description: \"Email destination: recipients, comma-separated\" },\n subject: { type: \"string\", description: \"Email destination: subject line\" },\n \"replace-unreadable\": {\n type: \"boolean\",\n description: \"Replace one unreadable email's entire setup with --email and --subject\",\n },\n url: { type: \"string\", description: \"Webhook destination with no credential: its address\" },\n },\n run: async ({ args }) => {\n const slug = String(args.slug);\n const target = targetsFor(readFlowTree(slug), args);\n\n const tree = readFlowTree(slug);\n const result =\n typeof args[\"same-as\"] === \"string\"\n ? sameAs(tree, target, args[\"same-as\"])\n : typeof args[\"hubspot-form\"] === \"string\"\n ? await fromHubspot(tree, target, args[\"hubspot-form\"], slug)\n : STATED_KINDS.has(target.kind)\n ? await fromStated(tree, target, args)\n : await fromPlatform(tree, target, args, slug);\n writeFlowTree(slug, tree);\n\n writeJson({\n ok: true,\n data: {\n slug,\n kind: target.kind,\n [target.on === \"node\" ? \"steps\" : \"sideEffects\"]: result.wired,\n destination: result.destination,\n connected: true,\n },\n hints: [...result.hints, \"Staged like any other edit in this chat: it goes live when the chat is published.\"],\n });\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAS,qBAAqB;AAkB9B,IAAM,aAAa,oBAAI,IAAI,CAAC,YAAY,YAAY,aAAa,iBAAiB,WAAW,gBAAgB,CAAC;AAC9G,IAAM,qBAAqB,oBAAI,IAAI,CAAC,eAAe,qBAAqB,aAAa,oBAAoB,CAAC;AAMnG,SAAS,kBACd,MACA,OACA,QACA,OAAO,eACG;AACV,QAAM,SAAS,mBAAmB,IAAI,EAAE,OAAO,CAAC,UAAU,MAAM,WAAW,SAAS,IAAI;AACxF,QAAM,YAAY,OAAO,IAAI,CAAC,UAAU,OAAO,MAAM,WAAW,EAAE,CAAC,EAAE,KAAK,IAAI,KAAK;AACnF,QAAM,SAAS,QACX,mBAAmB,IAAI,EAAE,KAAK,CAAC,UAAU,MAAM,WAAW,OAAO,KAAK,IACtE,OAAO,WAAW,IAChB,OAAO,CAAC,IACR;AACN,MAAI,CAAC,QAAQ;AACX,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS,QACL,2BAA2B,KAAK,oBAChC,iBAAiB,OAAO,MAAM,IAAI,IAAI;AAAA,MAC1C,KACE,OAAO,WAAW,IACd,4EAA4E,IAAI,KAChF,GAAG,IAAI,+BAA+B,SAAS;AAAA,IACvD;AAAA,EACF;AACA,MAAI,OAAO,WAAW,SAAS,MAAM;AACnC,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS,gBAAgB,KAAK,UAAU,OAAO,OAAO,WAAW,IAAI,CAAC,WAAW,IAAI;AAAA,MACrF,KAAK,GAAG,IAAI,+BAA+B,SAAS;AAAA,IACtD;AAAA,EACF;AACA,SAAO,WAAW,kBAAkB,OAAO;AAC3C,SAAO,WAAW,kBAAkB,OAAO;AAC3C,SAAO,EAAE,IAAI,MAAM,QAAQ,OAAO,OAAO,KAAK,EAAE,GAAG,c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_AGENT_DESTINATION_KINDS,\n type FlowConfigStatus,\n type FlowDrift,\n type FlowSummary,\n type FlowsDriftResponse,\n type FlowsShowResponse,\n flowNodeTriggers,\n} from \"@baker/api\";\nimport { defineCommand } from \"citty\";\nimport { apiPost } from \"../../client.ts\";\nimport { writeJson } from \"../../output.ts\";\nimport { registerSchema } from \"../../schemas.ts\";\nimport {\n collectConfigStatus,\n collectSideEffects,\n listFlowSlugs,\n readFlowTree,\n readSettings,\n redactTree,\n requestFlowInputCall,\n withSettings,\n} from \"./shared.ts\";\n\nregisterSchema({\n command: \"flows.list\",\n description:\n \"List the Forms (flows) in this workspace and how many confidential fields each still needs configured. Read-only.\",\n args: {},\n});\n\nregisterSchema({\n command: \"flows.show\",\n description:\n \"Show a Form's confidential fields and whether each is configured (secrets/connections/third-party resources), AND whether its destination has changed under it — never reveals secret values. Destination drift is the one problem a Form cannot show you itself: when a HubSpot field a Form maps is deleted, HubSpot refuses the WHOLE submission and the visitor still sees the thank-you screen, so every lead is lost silently. Run this before changing any Form. Each sealed destination says where it sends (recipients, subject, sheet) — never a credential. Author structure by editing the flow's _data.json; set destinations yourself with `baker flows connect` (email: --email/--subject); only a typed secret goes to the request_flow_input tool.\",\n args: {\n slug: { type: \"positional\", description: \"Form slug (folder under flows/)\", required: true },\n full: { type: \"boolean\", description: \"Include the full flow tree (secret values redacted)\", required: false },\n },\n});\n\nfunction statusFor(slug: string): FlowConfigStatus[] {\n const tree = readFlowTree(slug);\n const config: FlowConfigStatus[] = [];\n collectConfigStatus(tree, config);\n return config;\n}\n\n/**\n * The calls that close out everything this form is still waiting on.\n *\n * `show` is the command an agent runs to answer \"is this form wired up?\", and\n * it answered with `needsInput: true` and nothing else — leaving the agent to\n * work out that a tool exists, which tool, and how to address the exact node or\n * side effect. The whole point of asking is to find out what to do next, so the\n * answer is the call itself.\n */\nfunction pendingInputHints(slug: string, config: FlowConfigStatus[]): string[] {\n const pending = config.filter((row) => row.needsInput);\n if (pending.length === 0) return [];\n const calls = pending.slice(0, MAX_PENDING_HINTS).map((row) => `${row.kind}: ${requestFlowInputCall(slug, row)}`);\n const rest = pending.length - calls.length;\n return [\n ...repeatedKindHints(slug, pending),\n `${pending.length} item${pending.length === 1 ? \"\" : \"s\"} still unwired. Wire each yourself with the command below when you know which resource is meant; the card is the fallback, and its result carries the destination — read the names from there rather than looking them up again.`,\n ...calls,\n ...(rest > 0 ? [`…and ${rest} more — see \\`config\\` above.`] : []),\n ];\n}\n\n/**\n * Several unwired items of one kind usually share one destination — chat\n * r57ed43j had 24 HubSpot side effects all sending to the same form — so\n * name the call that fills them all at once.\n */\nfunction repeatedKindHints(slug: string, pending: FlowConfigStatus[]): string[] {\n const counts = new Map<string, number>();\n for (const row of pending) counts.set(row.kind, (counts.get(row.kind) ?? 0) + 1);\n return [...counts].flatMap(([kind, count]) => {\n if (count < 2) return [];\n if (kind === \"hubspotForm\") {\n return [\n `${count} hubspotForm side effects are unwired. When they all send to the same HubSpot form: baker flows connect ${slug} --all --hubspot-form <formId>.`,\n ];\n }\n if (!(FLOW_AGENT_DESTINATION_KINDS as readonly string[]).includes(kind)) return [];\n return [\n `${count} ${kind} items are unwired. When they share one destination: baker flows connect ${slug} --all --type ${kind} [--resource <id>].`,\n ];\n });\n}\n\n/** Enough for any real form; the cap only stops a pathological tree flooding the response. */\nconst MAX_PENDING_HINTS = 6;\n\n/**\n * Side effects wired to a moment their own step never raises.\n *\n * `fireSideEffects` filters on `triggerId` equality, so one that does not match\n * is inert: written, valid, green on every check in the repo, and it never\n * runs. Nothing else in the toolchain looks at the pair — `validate-flow.mjs`\n * only checks the key is present and `validate-flow-schema.mjs` does not read\n * it at all — so a form can report \"fully configured\" while a side effect on it\n * has never fired once. This is the one command that is asked whether a form is\n * wired up, so it is the one that has to say.\n *\n * Silent about a node type the trigger table does not cover: no opinion is the\n * honest answer there, and a false \"this never fires\" on a working form would\n * cost more than the warning is worth.\n */\nexport function inertSideEffectHints(tree: Record<string, unknown>): string[] {\n const dead = collectSideEffects(tree).flatMap(({ node, sideEffect }) => {\n const triggers = flowNodeTriggers(node.nodeData);\n if (!triggers.known) return [];\n const triggerId = String(sideEffect.triggerId ?? \"\");\n if (triggers.available.includes(triggerId)) return [];\n const where = `${String(sideEffect.id ?? sideEffect.type)} on \"${String(node.name ?? node.id)}\"`;\n const raises =\n triggers.available.length > 0\n ? `It raises: ${triggers.available.join(\", \")}.`\n : (triggers.why ?? \"That step raises nothing.\");\n return [`${where} fires on \\`${triggerId || \"(none)\"}\\`, which that step never raises. ${raises}`];\n });\n\n if (dead.length === 0) return [];\n return [\n `${dead.length} side effect${dead.length === 1 ? \" has\" : \"s have\"} a triggerId their step never raises, so ${dead.length === 1 ? \"it never runs\" : \"they never run\"} — no error, nothing half-written, just nothing. A triggerId belongs to the STEP, not to the side-effect type.`,\n ...dead.slice(0, MAX_PENDING_HINTS),\n ...(dead.length > MAX_PENDING_HINTS ? [`…and ${dead.length - MAX_PENDING_HINTS} more.`] : []),\n \"Fix each by setting the id its own step raises: `baker flows schema node <nodeType>` lists them.\",\n ];\n}\n\n/**\n * Where the company funnel stands on this Form.\n *\n * A Form moves nobody along the company funnel until a step names one of its\n * endings, and nothing places it for the agent — so a Form that is configured,\n * fires every pixel and counts its conversions can still leave \"Became a lead\"\n * at zero. `show` reads only the local file and cannot tell whether a step\n * names it; `baker funnel` can, so the hint names that read and the write.\n */\nexport function funnelPlacementHint(slug: string): string {\n return `Whether this Form moves anyone along the company funnel is not in _data.json either: \\`baker funnel\\` names every Form no step counts. If it names this one, place its ending on the step it moves people to — \\`submit:${slug}\\`, or its booking trigger, both listed by \\`baker funnel --moments\\` — with \\`baker funnel --step\\`, which replaces the step it names, so keep that step's other ways in.`;\n}\n\n/**\n * What this Form's destination has changed under it, asked of Baker.\n *\n * A read the Company Workspace cannot do for itself twice over: the findings\n * live on the `flows` row, and the HubSpot form id a repair needs is inside an\n * encrypted config. Before this, detection had no reader in the Runtime at all\n * — 47 live findings across 11 Forms, and an agent editing one of those Forms\n * could not see a single one.\n *\n * A failure returns null rather than `[]`. They are different answers and\n * collapsing them would report a Form healthy on the strength of a network\n * error, which is exactly the silence the drift check exists to break.\n */\nasync function readDrift(slug: string): Promise<FlowsDriftResponse | null> {\n try {\n const response = await apiPost<{ ok: true; data: FlowsDriftResponse }>(\"/api/flows/drift\", { slug });\n return response.data;\n } catch {\n return null;\n }\n}\n\n/**\n * Drift said to an agent: what is wrong, and the command that fixes it.\n *\n * The summary comes from `@baker/api`, which the dashboard badge reads too, so\n * this and the badge cannot come apart about whether a Form is healthy. What is\n * added here is the half that is the CLI's: the repair, spelled as a command\n * line, because an agent that has to go and work out `--prune-missing` for\n * itself will instead reach for `--replace` and delete the mappings that still\n * work.\n */\nexport function driftHints(slug: string, drift: FlowsDriftResponse | null): string[] {\n if (drift === null) {\n return [\n \"Could not check whether this Form's destination has changed under it. Treat that as UNKNOWN, not as healthy — a deleted HubSpot field refuses every submission while the visitor still sees the thank-you screen.\",\n ];\n }\n\n const forms = drift.forms.filter((form) => form.slug === slug);\n if (forms.length === 0) {\n return drift.checkedAt === null\n ? [\n \"This Form's destination has never been checked, so nothing here says it is healthy — only that nothing was compared.\",\n ]\n : [];\n }\n\n return forms.flatMap((form: FlowDrift) => {\n const repair = driftRepairHint(slug, form.formGuid, form.deadFields, form.sideEffectId);\n return [`DESTINATION DRIFT (${form.severity}): ${form.summary}`, ...(repair === null ? [] : [repair])];\n });\n}\n\nfunction displayName(slug: string): string {\n const tree = readFlowTree(slug);\n const name = tree.displayName;\n return typeof name === \"string\" && name.trim() ? name.trim() : slug;\n}\n\nconst listCommand = defineCommand({\n meta: {\n name: \"list\",\n description:\n \"List Forms in this workspace with the count of confidential fields still needing setup. Example: baker flows list\",\n },\n run: () => {\n const flows: FlowSummary[] = listFlowSlugs().map((slug) => ({\n slug,\n name: displayName(slug),\n needsConfig: statusFor(slug).filter((c) => c.needsInput).length,\n }));\n const pending = flows.filter((flow) => flow.needsConfig > 0);\n writeJson({\n ok: true,\n data: { flows },\n hints: [\n ...(pending.length > 0\n ? [\n `Still unwired: ${pending.map((flow) => `${flow.slug} (${flow.needsConfig})`).join(\", \")}. \\`baker flows show <slug>\\` returns the command that wires each — most you run yourself.`,\n ]\n : []),\n // \"Set the conversions on the Forms\" lands here first, and nothing in\n // this family can do it — the conversion side effects it does offer\n // fire a pixel and are not what any Baker report counts.\n \"Setting what a Form COUNTS is not in this family: a conversion is a named event held in Baker. `baker analytics conversions` lists what this company counts; `--flow <slug>` spells one Form's endings as keys you can count, traffic or no traffic.\",\n ],\n });\n },\n});\n\nconst showCommand = defineCommand({\n meta: {\n name: \"show\",\n description:\n \"Show a Form's confidential fields and their configuration status (never secret values). Example: baker flows show contact\",\n },\n args: {\n slug: { type: \"positional\", description: \"Form slug\", required: true },\n full: { type: \"boolean\", description: \"Include the full flow tree (secret values redacted)\" },\n },\n run: async ({ args }) => {\n const slug = String(args.slug);\n const tree = readFlowTree(slug);\n const [drift, settings] = await Promise.all([readDrift(slug), readSettings(tree)]);\n const config = withSettings(statusFor(slug), settings ?? {});\n const response: FlowsShowResponse = {\n slug,\n name: displayName(slug),\n config,\n drift: drift === null ? null : drift.forms.filter((form) => form.slug === slug),\n ...(drift === null ? {} : { driftCheckedAt: drift.checkedAt }),\n ...(args.full === true ? { tree: redactTree(tree) } : {}),\n };\n writeJson({\n ok: true,\n data: response,\n // Drift first, above everything. The other hints are about work still to\n // do; this one is about leads already being lost, and it is the only\n // thing here that is true of a Form that looks completely finished.\n hints: [\n ...driftHints(slug, drift),\n ...inertSideEffectHints(tree),\n ...pendingInputHints(slug, config),\n // The question this command is asked — \"is this Form wired up?\" — has\n // an answer that is not in this file at all. What a Form counts is a\n // named event in Baker, and a Form can be perfectly configured, fire\n // every pixel it has, and still report converting nobody.\n `What this Form counts as a conversion is NOT in _data.json and not in any side effect here: it is a named event held in Baker. Read it, and this Form's own endings spelled as event keys, with \\`baker analytics conversions --flow ${slug}\\`.`,\n funnelPlacementHint(slug),\n ],\n });\n },\n});\n\nexport const flowsCommand = defineCommand({\n meta: {\n name: \"flows\",\n description: `Read and shape this workspace's Forms (flows).\n\nReads never reveal a secret value. Writes touch only the form's own _data.json — they stage structure, never a live system.\n\nWire every destination yourself — no card for the user: an email (\\`connect --email \"a@x.com, b@x.com\" --subject \"New lead — Contact\"\\`; write the subject yourself), a webhook without a token (\\`--url\\`), and any connected platform once you know which resource is meant (\\`baker flows options <kind>\\` lists it; Calendly, SavvyCal, GoHighLevel steps; Google Sheets, Pipedrive, GoHighLevel and HubSpot destinations; \\`--same-as\\` copies another Form's). A HubSpot step takes \\`baker hubspot forms view <id> --as-node\\`. \\`show\\` reads back where each destination sends; a credential is never shown.\n\nThe request_flow_input tool (baker_ui MCP server) is only for what the user alone holds: a typed secret (a webhook token, Zapier, Crmble), a platform nobody connected, or several resources that could equally be meant.\n\nExamples:\n baker flows list # every Form + how many fields still need setup\n baker flows show contact # one Form's confidential fields and their status\n baker flows schema node customForm # the shape of a step, before you author one\n baker flows add-node contact --type text --name \"Thanks\"\n baker flows add-side-effect contact --node <id> --type googleSpreadsheet\n baker flows options calendly # what the connected account holds\n baker flows connect contact --node book --resource <id>\n baker flows connect contact --side-effect se-email-1 --email \"ana@x.com, luis@x.com\" --subject \"New lead — Contact\"\n baker flows connect contact --side-effect se-hubspotForm-1 --hubspot-form <formId> # --all: every unwired one\n baker flows map contact --map A=name --map B=email --write\nFull guide: __tooling__/docs/tools/baker/flows.md`,\n },\n subCommands: {\n list: listCommand,\n show: showCommand,\n schema: () => import(\"./schema.ts\").then((m) => m.schemaCommand),\n \"add-node\": () => import(\"./add.ts\").then((m) => m.addNodeCommand),\n \"add-side-effect\": () => import(\"./add.ts\").then((m) => m.addSideEffectCommand),\n options: () => import(\"./options.ts\").then((m) => m.optionsCommand),\n connect: () => import(\"./connect.ts\").then((m) => m.connectCommand),\n map: () => import(\"./map.ts\").then((m) => m.mapCommand),\n normalize: () => import(\"./normalize.ts\").then((m) => m.normalizeCommand),\n },\n // Bare `baker flows` lists the Forms. This must be `default`, not `run`: citty falls\n // through to `run` after dispatching a subcommand, so a `run` here would also print\n // the list on every `baker flows show <slug>`.\n default: \"list\",\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,SAAS,qBAAqB;AAe9B,eAAe;AAAA,EACb,SAAS;AAAA,EACT,aACE;AAAA,EACF,MAAM,CAAC;AACT,CAAC;AAED,eAAe;AAAA,EACb,SAAS;AAAA,EACT,aACE;AAAA,EACF,MAAM;AAAA,IACJ,MAAM,EAAE,MAAM,cAAc,aAAa,mCAAmC,UAAU,KAAK;AAAA,IAC3F,MAAM,EAAE,MAAM,WAAW,aAAa,uDAAuD,UAAU,MAAM;AAAA,EAC/G;AACF,CAAC;AAED,SAAS,UAAU,MAAkC;AACnD,QAAM,OAAO,aAAa,IAAI;AAC9B,QAAM,SAA6B,CAAC;AACpC,sBAAoB,MAAM,MAAM;AAChC,SAAO;AACT;AAWA,SAAS,kBAAkB,MAAc,QAAsC;AAC7E,QAAM,UAAU,OAAO,OAAO,CAAC,QAAQ,IAAI,UAAU;AACrD,MAAI,QAAQ,WAAW,EAAG,QAAO,CAAC;AAClC,QAAM,QAAQ,QAAQ,MAAM,GAAG,iBAAiB,EAAE,IAAI,CAAC,QAAQ,GAAG,IAAI,IAAI,KAAK,qBAAqB,MAAM,GAAG,CAAC,EAAE;AAChH,QAAM,OAAO,QAAQ,SAAS,MAAM;AACpC,SAAO;AAAA,IACL,GAAG,kBAAkB,MAAM,OAAO;AAAA,IAClC,GAAG,QAAQ,MAAM,QAAQ,QAAQ,WAAW,IAAI,KAAK,GAAG;AAAA,IACxD,GAAG;AAAA,IACH,GAAI,OAAO,IAAI,CAAC,aAAQ,IAAI,oCAA+B,IAAI,CAAC;AAAA,EAClE;AACF;AAOA,SAAS,kBAAkB,MAAc,SAAuC;AAC9E,QAAM,SAAS,oBAAI,IAAoB;AACvC,aAAW,OAAO,QAAS,QAAO,IAAI,IAAI,OAAO,OAAO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{"version":3,"sources":["../src/commands/funnel/index.ts","../src/commands/funnel/formMoments.ts","../src/commands/funnel/funnelArgs.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport type { FunnelRequest, FunnelResponse } from \"@baker/api/funnel\";\nimport { defineCommand } from \"citty\";\nimport { ApiError, apiPost } from \"../../client.ts\";\nimport { registerSchema } from \"../../schemas.ts\";\nimport { writeJsonEnvelope } from \"../ads/output.ts\";\nimport { flowDataPath, listFlowSlugs } from \"../flows/shared.ts\";\nimport { formsNamedHere, unplacedFormHints, type WorkspaceForm, withFormMoments } from \"./formMoments.ts\";\nimport { FunnelArgsError, funnelWrite, parseFunnelArgs } from \"./funnelArgs.ts\";\n\n/**\n * `baker funnel` — the company's own funnel: the steps it has, in its own\n * words, wired the way its business actually runs.\n *\n * One command rather than a family, because there is one thing to say: this is\n * the funnel. A read with no flags, a write that restates the whole graph. It\n * is the only staged write in the CLI that does not take operations, and the\n * reason is in `@baker/api/funnel/wire.ts`: a funnel is a graph of a handful of\n * steps, so restating it costs nothing and the person reviewing it sees the\n * funnel they will get rather than a list of edits.\n */\nconst args = {\n steps: {\n type: \"string\",\n description:\n 'The WHOLE funnel, as a JSON array. One object per step: {\"key\":\"meeting_held\",\"displayName\":\"Demo held\",\"stepClass\":\"engaged\",\"after\":[\"lead\"],\"triggers\":[{\"id\":\"t1\",\"kind\":\"event\",\"eventKey\":\"page:demo_held\"}]}. It REPLACES the funnel rather than adding to it, so read first and restate everything you want to keep. `key` is permanent and reaches reporting and URLs (lowercase, digits, underscores); `displayName` is the client\\'s own words and can be anything. `stepClass` is the stage, one of visited, lead, engaged, customer, repeat, lost — six plain words every business has, used to compare one company\\'s funnel with another\\'s. `after` is a LIST, so two ways into one step is expressible and normal. `triggers` is what MOVES somebody onto the step, any one of them being enough, and there are three kinds: `{\"id\":\"t1\",\"kind\":\"event\",\"eventKey\":\"submit:contact\"}` for anything the company\\'s Forms, pages or systems produced, used by its own key with nothing named first; `{\"id\":\"t2\",\"kind\":\"landing\",\"landingId\":\"<from --moments>\"}` for one landing page being viewed; `{\"id\":\"t3\",\"kind\":\"any_landing\"}` for any landing being viewed. Take every key and id from `--moments`. A trigger carries no amount: an event is worth what it says, and a step is worth the sum. Where a step SENDS its people is not written here: a send belongs to the system\\'s event (`baker analytics sends`), and the step reads it back as `sends[]`',\n required: false,\n },\n step: {\n type: \"string\",\n description:\n 'ONE step as a JSON object, in the same shape as an entry of --steps. It is added to the funnel as it now stands, or replaces the step with the same `key`, and every other step is left exactly as it is — the door for adding or changing a stage without restating the rest. Example: --step \\'{\"key\":\"demo\",\"displayName\":\"Demo held\",\"stepClass\":\"engaged\",\"after\":[\"lead\"],\"triggers\":[{\"id\":\"t1\",\"kind\":\"event\",\"eventKey\":\"page:demo_held\"}]}\\'',\n required: false,\n },\n \"add-trigger\": {\n type: \"string\",\n description:\n 'The key of ONE step to add a way in to, with `--event` naming what gets somebody there: `--add-trigger lead --event \"submit:contact\"`. Start here for \"this Form should count as a lead\" — it adds that one way in and leaves the step\\'s name, stage, `after[]` and every other trigger exactly as they are. Prefer it to `--step`, which takes a WHOLE step and therefore silently removes any trigger the restatement forgets. Adding a key the step already listens for changes nothing. Take the key from `--moments`, never from memory',\n required: false,\n },\n \"remove-trigger\": {\n type: \"string\",\n description:\n 'The key of ONE step to take a way in OFF, with `--event` naming which: `--remove-trigger lead --event \"submit:contact\"`. By event key rather than by trigger id, because the id is not something you ever saw. Everything else about the step is untouched',\n required: false,\n },\n event: {\n type: \"string\",\n description:\n \"The event key `--add-trigger` or `--remove-trigger` acts on — an `events[].eventKey` from `--moments`, never invented. Every Form's endings are listed there by the step each happens on, at zero before anybody has filled the Form in; which one means the step is your decision\",\n required: false,\n },\n \"remove-step\": {\n type: \"string\",\n description:\n \"The key of one step to take off the funnel. Whatever came after it moves up to whatever came before it, so the chain stays joined. The response lists it under `removed`\",\n required: false,\n },\n preset: {\n type: \"string\",\n description:\n \"Draw one of the ready-made graphs instead of stating steps: b2b_sales, b2b_inbound, saas_self_serve, saas_sales_assisted, ecommerce_purchase. It draws over the whole funnel — every company already has one, so prefer --step to change a step. Run --templates first to see what each one contains\",\n required: false,\n },\n moments: {\n type: \"boolean\",\n description:\n \"Also return everything a trigger can name, so a trigger is PICKED rather than invented: `events` (every event this company's Forms, pages and systems produced in the window, with volume, the Form it belongs to, `origin` — `site` for a page or Form, `systems` for the client's own server, `both` — and `countedAs` when the company also counts it as a page conversion, which a trigger does not need; PLUS **every workspace Form's endings** — each step's completion and its `submit:` — with the `step` each happens on, at zero and `seen: false` until somebody fires one, so a Form built minutes ago is pickable with nothing set up first, and `countedAs` when the company already counts it. Nothing is marked as the outcome: which ending means a step is YOUR decision — read the step names, and ask the person when they do not make it obvious (a Form that branches into “Not a fit” and “Quote confirmed”). If the Form is already counted, use that same key, so the step and the conversion agree. `baker analytics conversions --flow <slug>` also lists a widget's housekeeping), `sources` (the client's own systems that post events to Baker, by the `page:<name>` key each raises, pickable before its first send arrives) and `landings` (its pages, by the id a `landing` trigger takes). Use this before writing any `triggers`: a key typed from memory saves, publishes and counts nobody forever. A Form's events need NOTHING set up first — no Source, no conversion: a Baker page raises them by itself\",\n required: false,\n },\n days: {\n type: \"string\",\n description:\n \"How many days the counts beside each step cover (default 30, up to 400). Every step comes back with `people` (reached it), `atLeast` (reached it or anything after it), `before` (got as far as the step before) and `share` (atLeast / before) — counted in PEOPLE across visits and devices, not in visits\",\n required: false,\n },\n templates: {\n type: \"boolean\",\n description:\n \"Also return the libraries: the suggested steps with their stages, the presets, and `stages[]` (the six stages with the test to apply). Where a step can be sent is not here — a send belongs to the system's event, and `baker analytics sends` lists the platforms and the tags that can send\",\n required: false,\n },\n} as const;\n\nregisterSchema({\n command: \"funnel\",\n description: \"Read the company's funnel, or draw one\",\n args,\n});\n\nexport const funnelCommand = defineCommand({\n meta: {\n name: \"funnel\",\n description:\n 'Start here: run with no flags to see the funnel this company has, with the last 30 days of PEOPLE counted beside every step — `people` reached it, `atLeast` got at least that far, `before` got as far as the step before, `share` is the ratio, and `worstStep` names where the most people are lost. Every company has one from the day it exists: Visited (any landing) → Became a lead → Became a customer, the last two with no way in until somebody gives them one. Then `--moments` for everything a trigger can name (every event the company\\'s Forms, pages and systems produced, its sources, its landings, plus each Form\\'s own outcome at zero). **To make an event count on a step — the usual job — use `--add-trigger <step> --event <key>`:** it adds that one way in and touches nothing else about the step. `--step \\'<json>\\'` is for adding or renaming a STEP; it replaces the step with that key, so it means restating its `after` and every trigger it keeps, and one left out is gone. A step is reached by three kinds of thing and nothing else: an event by its own key (`{\"id\":\"t1\",\"kind\":\"event\",\"eventKey\":\"<from moments.events or moments.sources>\"}`), one landing being viewed (`{\"id\":\"t2\",\"kind\":\"landing\",\"landingId\":\"<from moments.landings>\"}`) or any landing (`{\"id\":\"t3\",\"kind\":\"any_landing\"}`). Nothing has to be named first. Pick every trigger from `--moments`, never from memory. A step with no `triggers` advances NOBODY and reports zero forever without warning — that is what the hints keep pointing at. There is no default door: a Form is only counted where a trigger names it. Keep it true: a chat that adds a Form, a Source or an event that moves people forward places it on its step in the same chat. Each step comes back with `sends[]`, read-only: where the people who reach it are sent and what happened, read off the system events behind its ways in. A send is set on the event with `baker analytics sends`, never on a step, and once published it spends ad budget — a failed one is named in the hints. Everything here is STAGED: it becomes the company\\'s funnel in one piece when the chat is published — the client sees it on the canvas in this chat and can edit it there too — and the previous version stays on file so what was already measured under it is not lost.',\n },\n args,\n run: async ({ args: raw }) => {\n try {\n const parsed = parseFunnelArgs(raw as Record<string, unknown>);\n // Read once: every Form in this workspace, including the one built in\n // this Session that the backend has never seen.\n const forms = workspaceForms();\n const namedByCaller = formsNamedHere(forms);\n const request: FunnelRequest = {\n ...funnelWrite(parsed),\n ...(namedByCaller.length === 0 ? {} : { namedByCaller }),\n };\n const response = await apiPost<FunnelResponse>(\"/api/funnel\", request);\n // What the company already counts, so a Form's ending can say so: the\n // agent choosing a way in should put the same key on the step.\n const counted = new Map((response.data.counted ?? []).map((row) => [row.eventKey, row.name] as const));\n const data =\n response.data.moments === undefined\n ? response.data\n : { ...response.data, moments: withFormMoments(response.data.moments, forms, counted) };\n const hints = [...(response.hints ?? []), ...unplacedFormHints(response.data.steps ?? [], forms, counted)];\n writeJsonEnvelope({\n ok: true,\n data,\n ...(hints.length > 0 ? { hints } : {}),\n });\n } catch (err) {\n handleError(err);\n }\n },\n});\n\n/**\n * A malformed `--steps` is the caller's own JSON, so it comes back as a\n * validation error carrying the parser's own sentence and its `fix` — the\n * request was never made, and \"that did not parse\" is something the agent can\n * act on in the same turn.\n */\nfunction handleError(err: unknown): never {\n if (err instanceof FunnelArgsError) {\n writeJsonEnvelope({\n ok: false,\n error: { code: \"VALIDATION_ERROR\", message: err.message, ...(err.fix ? { fix: err.fix } : {}) },\n });\n process.exit(1);\n }\n if (err instanceof ApiError) {\n writeJsonEnvelope({ ok: false, error: { code: err.code, message: err.message } });\n process.exit(1);\n }\n writeJsonEnvelope({\n ok: false,\n error: { code: \"NETWORK_ERROR\", message: err instanceof Error ? err.message : \"Unexpected error\" },\n });\n process.exit(1);\n}\n\n/**\n * Every Form in this workspace with its tree, skipping whatever cannot be read.\n *\n * Skipping rather than failing: `baker funnel` is one of the commands reached\n * for while a Form is half-written, and a flow-builder loop that has created\n * the folder but not yet the file would otherwise take the whole funnel down\n * with it. A Form left out costs one unfired ending in a list; a throw costs\n * the command.\n */\nfunction workspaceForms(): WorkspaceForm[] {\n const forms: WorkspaceForm[] = [];\n for (const slug of listFlowSlugs()) {\n try {\n forms.push({ slug, tree: JSON.parse(readFileSync(flowDataPath(slug), \"utf-8\")) });\n } catch {\n // Unreadable or not yet written.\n }\n }\n return forms;\n}\n","import { type FlowEventKey, flowEventKeys } from \"@baker/api/analytics/flowEventKeys\";\nimport type { FunnelResponse } from \"@baker/api/funnel\";\n\n/**\n * A Form's endings, added to `--moments` before any of them has fired.\n *\n * `moments.events` is built from the event store, so it knows an event only\n * once somebody has produced one. A Form published this morning offered\n * nothing, and the picker's remaining affordances — type the key by hand, or\n * add a Source — are both wrong: a Source is a door for the company's own\n * systems, and a Baker page already raises its events natively. That is how a\n * funnel step ends up naming a key nothing produces, which never errors and\n * counts zero forever.\n *\n * Facts only. Which ending is the point of a Form is the agent's decision:\n * it is a reading of what the steps mean — \"Quote confirmed\" against \"Not a\n * fit\" — and a rule over the tree's shape picked the step both branches pass\n * through, which would have counted every rejected visitor as a lead. So\n * nothing here is marked as the outcome; each ending says the step it happens\n * on and whether the company already counts it, and the agent chooses.\n *\n * Pure, and the reading of the trees is the caller's: a half-written\n * `_data.json` under a flow-builder loop must not take out `baker funnel`.\n */\n\ntype Moments = NonNullable<FunnelResponse[\"data\"][\"moments\"]>;\ntype MomentEvent = Moments[\"events\"][number];\n\nexport interface WorkspaceForm {\n slug: string;\n tree: unknown;\n}\n\n/** Event key → the name the company counts it under, this chat's staged counts included. */\nexport type CountedNames = ReadonlyMap<string, string>;\n\n/**\n * Each step's completion and the Form's own submit — the endings a step could\n * mean. A widget's housekeeping (\"the booking page was viewed\") is left out:\n * it is never what a person means by reaching a step, it roughly doubled the\n * list, and `baker analytics conversions --flow <slug>` still has it.\n */\nfunction offeredEndings(form: WorkspaceForm): FlowEventKey[] {\n return flowEventKeys(form.tree, form.slug).filter((ending) => ending.isCompletion || ending.nodeId === null);\n}\n\n/**\n * The store's events plus every workspace Form's endings, each with its step.\n *\n * An ending that has fired stays the store's own row, never replaced: it\n * carries a real volume, and a zero in its place would say the opposite of\n * what is true. It gains the step it happens on, which only the Form knows. An\n * ending nothing has fired yet is appended at zero, `seen: false`, with the\n * name the company counts it under when it counts it.\n */\nexport function formMoments(\n events: readonly MomentEvent[],\n forms: readonly WorkspaceForm[],\n counted: CountedNames,\n): MomentEvent[] {\n const endings = new Map<string, { slug: string; ending: FlowEventKey }>();\n for (const form of forms) {\n for (const ending of offeredEndings(form)) endings.set(ending.eventKey, { slug: form.slug, ending });\n }\n\n const known = events.map((event) => {\n const found = endings.get(event.eventKey);\n if (found === undefined) return event;\n endings.delete(event.eventKey);\n return { ...event, step: found.ending.nodeName };\n });\n const unfired = [...endings.values()].map(({ slug, ending }): MomentEvent => {\n const countedAs = counted.get(ending.eventKey);\n return {\n eventKey: ending.eventKey,\n origin: \"site\",\n flowSlug: slug,\n ...(ending.nodeType === null ? {} : { nodeType: ending.nodeType }),\n events: 0,\n sessions: 0,\n step: ending.nodeName,\n seen: false,\n ...(countedAs === undefined ? {} : { countedAs }),\n };\n });\n return [...known, ...unfired];\n}\n\n/** The moments as answered, with every workspace Form's endings alongside. */\nexport function withFormMoments(moments: Moments, forms: readonly WorkspaceForm[], counted: CountedNames): Moments {\n return { ...moments, events: formMoments(moments.events, forms, counted) };\n}\n\n/**\n * The Forms {@link unplacedFormHints} speaks for, by slug — every one that\n * raises an ending at all.\n *\n * Sent with the request so the backend leaves them out of its own \"on no step\"\n * hint, and every unplaced Form is named once. A Form whose tree holds no step\n * is left to the backend, so it is still named.\n */\nexport function formsNamedHere(forms: readonly WorkspaceForm[]): string[] {\n return forms.filter((form) => flowEventKeys(form.tree, form.slug).length > 0).map((form) => form.slug);\n}\n\n/**\n * The Forms in this workspace that no step counts, as ONE hint.\n *\n * The backend knows only PUBLISHED Forms, so a Form built in this Session was\n * named by nobody — on the one turn where the reminder is worth most. So this\n * owns the reminder for every Form in the workspace ({@link formsNamedHere})\n * and the backend's hint covers only the rest.\n *\n * It names Forms and never a key to place: the key is the agent's decision.\n * The one key it does print is a fact — the ending the company already counts\n * — because a step on a different ending of the same Form saves, publishes and\n * disagrees with the conversion for ever.\n *\n * One hint rather than one per Form, measured: a 27-Form client got 27\n * near-identical paragraphs, which is how an agent learns to skip the hints.\n * But every Form is named in it: the backend leaves all of them to this hint,\n * so a Form cut from the list here is named nowhere.\n */\nexport function unplacedFormHints(\n steps: readonly { key: string; triggers?: readonly { eventKey?: string }[] }[],\n forms: readonly WorkspaceForm[],\n counted: CountedNames,\n): string[] {\n const onAStep = new Set(\n steps.flatMap((step) => (step.triggers ?? []).flatMap((trigger) => (trigger.eventKey ? [trigger.eventKey] : []))),\n );\n const unplaced: string[] = [];\n for (const form of forms) {\n const endings = flowEventKeys(form.tree, form.slug);\n if (endings.length === 0 || endings.some((ending) => onAStep.has(ending.eventKey))) continue;\n const countedOn = endings.filter((ending) => counted.has(ending.eventKey));\n unplaced.push(\n countedOn.length === 0\n ? form.slug\n : `${form.slug} (counted as ${countedOn.map((ending) => `\"${counted.get(ending.eventKey)}\" on \\`${ending.eventKey}\\``).join(\", \")})`,\n );\n }\n if (unplaced.length === 0) return [];\n\n return [\n `${unplaced.length} Form(s) in this workspace reach no funnel step, so they move nobody along it however many people finish them: ${unplaced.join(\"; \")}. Which ending moves somebody to which step is your call: \\`baker funnel --moments\\` lists every Form's endings by the step each happens on, and when the step names do not make it obvious — a Form that branches into a rejection and a confirmation — ask the person which one means a lead or a customer. Place it with \\`baker funnel --add-trigger <step> --event <key>\\`. A Form already counted as a page conversion goes on the funnel by THAT SAME key, or the two numbers disagree for ever.`,\n ];\n}\n","import { parseEventKey } from \"@baker/api/analytics\";\nimport { FUNNEL_VERTICALS, type FunnelRequest, funnelRequestSchema } from \"@baker/api/funnel\";\n\n/**\n * `baker funnel`'s flags, turned into the one request the route takes.\n *\n * Pure and tier-1 tested, because everything that can go wrong with this\n * command goes wrong here: hand-written JSON, a preset spelled from memory, and\n * a step whose ways in are half-written. Each of those has to come back as a\n * sentence the agent can act on in the same turn rather than as a request that\n * failed for a reason only the server can see.\n *\n * There is no `--forms` any more. It used to say which step each Form's\n * submissions entered, alongside a rule that dropped an unplaced Form on the\n * funnel's first step — so a funnel that measured a client's Forms\n * by accident was indistinguishable from one that measured them deliberately.\n * A Form reaches a step because a trigger on that step names it, and `baker\n * funnel`'s hints name every Form no step counts.\n */\n\nexport class FunnelArgsError extends Error {\n /** Structured remediation, in the shape the CLI's error envelope carries. */\n readonly fix?: { action: string; explanation: string };\n\n constructor(message: string, fix?: { action: string; explanation: string }) {\n super(message);\n this.name = \"FunnelArgsError\";\n if (fix) {\n this.fix = fix;\n }\n }\n}\n\nexport interface FunnelArgs {\n steps?: unknown[];\n /** One step, added or replaced by key; the rest of the funnel is left as it stands. */\n step?: unknown;\n /** One step taken off by key. */\n removeStep?: string;\n /** One way in added to a step, by the event key it listens for. */\n addTrigger?: { stepKey: string; eventKey: string };\n /** One way in taken off a step. */\n removeTrigger?: { stepKey: string; eventKey: string };\n preset?: string;\n templates: boolean;\n moments: boolean;\n days?: number;\n}\n\nexport function parseFunnelArgs(raw: Record<string, unknown>): FunnelArgs {\n const steps = parseSteps(raw.steps);\n const step = parseStep(raw.step);\n const removeStep = parseRemoveStep(raw[\"remove-step\"] ?? raw.removeStep);\n const preset = parsePreset(raw.preset);\n const addTrigger = parseWayIn(raw[\"add-trigger\"] ?? raw.addTrigger, raw.event, \"--add-trigger\");\n const removeTrigger = parseWayIn(raw[\"remove-trigger\"] ?? raw.removeTrigger, raw.event, \"--remove-trigger\");\n\n const doors = [steps, step, removeStep, preset, addTrigger, removeTrigger].filter(\n (door) => door !== undefined,\n ).length;\n if (doors > 1) {\n throw new FunnelArgsError(\n \"Give one of --steps, --step, --remove-step, --preset, --add-trigger or --remove-trigger, not two.\",\n );\n }\n\n const days = raw.days === undefined ? undefined : Number(raw.days);\n if (days !== undefined && (!Number.isInteger(days) || days <= 0 || days > 400)) {\n throw new FunnelArgsError(\"--days must be a whole number of days, from 1 to 400.\");\n }\n\n return {\n ...(steps === undefined ? {} : { steps }),\n ...(step === undefined ? {} : { step }),\n ...(removeStep === undefined ? {} : { removeStep }),\n ...(preset === undefined ? {} : { preset }),\n ...(addTrigger === undefined ? {} : { addTrigger }),\n ...(removeTrigger === undefined ? {} : { removeTrigger }),\n templates: raw.templates === true,\n moments: raw.moments === true,\n ...(days === undefined ? {} : { days }),\n };\n}\n\n/**\n * The request body. Validated against the shared schema here rather than only\n * on the server, so a malformed step is named before a round trip — and named\n * as the step it is, which the server's first-issue message cannot always do.\n */\nexport function funnelWrite(args: FunnelArgs): FunnelRequest {\n const body = {\n ...(args.steps === undefined ? {} : { steps: args.steps }),\n ...(args.step === undefined ? {} : { step: args.step }),\n ...(args.removeStep === undefined ? {} : { removeStep: args.removeStep }),\n ...(args.preset === undefined ? {} : { preset: args.preset }),\n ...(args.addTrigger === undefined ? {} : { addTrigger: args.addTrigger }),\n ...(args.removeTrigger === undefined ? {} : { removeTrigger: args.removeTrigger }),\n ...(args.templates ? { templates: true } : {}),\n ...(args.moments ? { moments: true } : {}),\n ...(args.days === undefined ? {} : { days: args.days }),\n };\n const parsed = funnelRequestSchema.safeParse(body);\n if (!parsed.success) {\n const issue = parsed.error.issues[0];\n throw new FunnelArgsError(\n `That funnel cannot be sent — ${issue?.path.join(\".\") || \"steps\"}: ${issue?.message ?? \"invalid\"}`,\n {\n action: \"read_the_schema\",\n explanation:\n \"Run `baker schema funnel` for the exact shape of one step, or `baker funnel --templates` for sixteen worked examples plus every field an event carries.\",\n },\n );\n }\n return parsed.data;\n}\n\nfunction parseSteps(raw: unknown): unknown[] | undefined {\n if (raw === undefined) {\n return undefined;\n }\n if (typeof raw !== \"string\") {\n throw new FunnelArgsError(\"--steps takes a JSON array of steps.\");\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (cause) {\n throw new FunnelArgsError(`--steps is not valid JSON: ${cause instanceof Error ? cause.message : \"parse failed\"}`, {\n action: \"quote_the_json\",\n explanation:\n 'Wrap the whole array in single quotes so the shell leaves the double quotes alone: --steps \\'[{\"key\":\"lead\",...}]\\'.',\n });\n }\n if (!Array.isArray(parsed)) {\n throw new FunnelArgsError(\"--steps takes an ARRAY of steps, even when the funnel has one step.\");\n }\n refuseRetiredShapes(parsed);\n return parsed;\n}\n\n/**\n * One step, as JSON. The same shape one entry of `--steps` takes, and the same\n * refusals — a step written the old way is refused here too.\n */\nfunction parseStep(raw: unknown): unknown | undefined {\n if (raw === undefined) {\n return undefined;\n }\n if (typeof raw !== \"string\") {\n throw new FunnelArgsError(\"--step takes one step as a JSON object.\");\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (cause) {\n throw new FunnelArgsError(`--step is not valid JSON: ${cause instanceof Error ? cause.message : \"parse failed\"}`, {\n action: \"quote_the_json\",\n explanation:\n 'Wrap the object in single quotes so the shell leaves the double quotes alone: --step \\'{\"key\":\"demo\",...}\\'.',\n });\n }\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n throw new FunnelArgsError(\"--step takes ONE step as an object. To restate several, use --steps with an array.\");\n }\n refuseRetiredShapes([parsed]);\n return parsed;\n}\n\nfunction parseRemoveStep(raw: unknown): string | undefined {\n if (raw === undefined) {\n return undefined;\n }\n if (typeof raw !== \"string\" || raw.trim() === \"\") {\n throw new FunnelArgsError(\"--remove-step takes the key of the step to take off, as `baker funnel` lists it.\");\n }\n return raw.trim();\n}\n\n/**\n * The shapes a step used to have and no longer does, refused by name.\n *\n * The wire schema would strip them silently: a step written with\n * `offlineConversions` would be stored without them and answer `ok`, and an\n * `analytics` or `conversion` trigger would be refused with zod's generic\n * discriminator message. Each has a home now — a send is set on the event, and\n * a way in is an event by its key with nothing to name first — so the refusal\n * says where.\n */\nfunction refuseRetiredShapes(steps: readonly unknown[]): void {\n for (const step of steps) {\n if (typeof step !== \"object\" || step === null) continue;\n const key = String((step as { key?: unknown }).key ?? \"?\");\n if (\"offlineConversions\" in step) {\n throw new FunnelArgsError(`Step \"${key}\" puts sends on the step, and a send belongs to the conversion.`, {\n action: \"set_sends_on_the_conversion\",\n explanation:\n \"Drop `offlineConversions`. Name the outcome with `baker analytics conversions`, then `baker analytics sends --set --conversion <name> --platform <p> --tag <tagId> --event <e>`; the step reads its conversions' sends back as `sends[]`.\",\n });\n }\n const triggers = (step as { triggers?: unknown }).triggers;\n if (!Array.isArray(triggers)) continue;\n const kinds = triggers.map((trigger) =>\n typeof trigger === \"object\" && trigger !== null ? (trigger as { kind?: unknown }).kind : undefined,\n );\n if (kinds.includes(\"analytics\") || kinds.includes(\"conversion\")) {\n const word = kinds.includes(\"analytics\") ? \"analytics\" : \"conversion\";\n throw new FunnelArgsError(\n `Step \"${key}\" has a \\`${word}\\` trigger, and a step is reached by an event or a landing only.`,\n {\n action: \"use_an_event_trigger\",\n explanation:\n 'Pick the moment from `baker funnel --moments` and write it as `{\"kind\":\"event\",\"eventKey\":\"<from moments.events or moments.sources>\"}` — nothing has to be named first. A landing is `{\"kind\":\"landing\",\"landingId\":\"<from moments.landings>\"}`.',\n },\n );\n }\n }\n}\n\nfunction parsePreset(raw: unknown): string | undefined {\n if (raw === undefined) {\n return undefined;\n }\n if (typeof raw !== \"string\" || !(FUNNEL_VERTICALS as readonly string[]).includes(raw)) {\n throw new FunnelArgsError(`--preset must be one of: ${FUNNEL_VERTICALS.join(\", \")}`, {\n action: \"list_the_presets\",\n explanation: \"Run `baker funnel --templates` to see what each preset contains before picking one.\",\n });\n }\n return raw;\n}\n\n/**\n * `--add-trigger <step> --event <key>`, or a refusal naming the missing half.\n *\n * Two flags rather than one JSON object, because that is the whole point of\n * this door: the thing being asked is \"this event should count on that step\",\n * and asking for JSON here would put the caller back in the business of\n * hand-writing a shape. The event key is still never invented — `--moments`\n * is where it comes from, and the refusal says so.\n */\nfunction parseWayIn(\n stepKey: unknown,\n eventKey: unknown,\n flag: string,\n): { stepKey: string; eventKey: string } | undefined {\n if (stepKey === undefined) return undefined;\n if (typeof stepKey !== \"string\" || stepKey.trim() === \"\") {\n throw new FunnelArgsError(`${flag} takes the key of the step to change: \\`${flag} lead\\`.`);\n }\n if (typeof eventKey !== \"string\" || eventKey.trim() === \"\") {\n throw new FunnelArgsError(`${flag} needs --event, naming what gets somebody there.`, {\n action: \"read_the_moments\",\n explanation: `Run \\`baker funnel --moments\\` and copy an \\`events[].eventKey\\` — a Form's own outcome is listed there at zero before anybody has filled it in. Then: \\`${flag} ${stepKey.trim()} --event \"<key>\"\\`.`,\n });\n }\n const key = eventKey.trim();\n // Refused here rather than at the backend, and only when ADDING: a key\n // nothing can produce does not error downstream, it counts zero for ever.\n // Removing is the opposite case — a key already on a step precisely because\n // it was wrong has to stay removable, whatever it parses as.\n if (flag === \"--add-trigger\" && parseEventKey(key) === null) {\n throw new FunnelArgsError(`\"${key}\" is not an event key, so nothing would ever reach that step through it.`, {\n action: \"read_the_moments\",\n explanation:\n \"Run `baker funnel --moments` and copy an `events[].eventKey`. They look like form:<form>:<step>:<trigger>, submit:<form>, page:<name> or view:<landing>.\",\n });\n }\n return { stepKey: stepKey.trim(), eventKey: key };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,oBAAoB;AAE7B,SAAS,qBAAqB;;;ACwC9B,SAAS,eAAe,MAAqC;AAC3D,SAAO,cAAc,KAAK,MAAM,KAAK,IAAI,EAAE,OAAO,CAAC,WAAW,OAAO,gBAAgB,OAAO,WAAW,IAAI;AAC7G;AAWO,SAAS,YACd,QACA,OACA,SACe;AACf,QAAM,UAAU,oBAAI,IAAoD;AACxE,aAAW,QAAQ,OAAO;AACxB,eAAW,UAAU,eAAe,IAAI,EAAG,SAAQ,IAAI,OAAO,UAAU,EAAE,MAAM,KAAK,MAAM,OAAO,CAAC;AAAA,EACrG;AAEA,QAAM,QAAQ,OAAO,IAAI,CAAC,UAAU;AAClC,UAAM,QAAQ,QAAQ,IAAI,MAAM,QAAQ;AACxC,QAAI,UAAU,OAAW,QAAO;AAChC,YAAQ,OAAO,MAAM,QAAQ;AAC7B,WAAO,EAAE,GAAG,OAAO,MAAM,MAAM,OAAO,SAAS;AAAA,EACjD,CAAC;AACD,QAAM,UAAU,CAAC,GAAG,QAAQ,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,OAAO,MAAmB;AAC3E,UAAM,YAAY,QAAQ,IAAI,OAAO,QAAQ;AAC7C,WAAO;AAAA,MACL,UAAU,OAAO;AAAA,MACjB,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,GAAI,OAAO,aAAa,OAAO,CAAC,IAAI,EAAE,UAAU,OAAO,SA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IAAI,IAAI,IAAI,CAAC,EAAG;AAAA,IAChG,CAAC;AACD,YAAQ,KAAK,CAAC;AAAA,EAChB;AACA,MAAI,eAAe,UAAU;AAC3B,sBAAkB,EAAE,IAAI,OAAO,OAAO,EAAE,MAAM,IAAI,MAAM,SAAS,IAAI,QAAQ,EAAE,CAAC;AAChF,YAAQ,KAAK,CAAC;AAAA,EAChB;AACA,oBAAkB;AAAA,IAChB,IAAI;AAAA,IACJ,OAAO,EAAE,MAAM,iBAAiB,SAAS,eAAe,QAAQ,IAAI,UAAU,mBAAmB;AAAA,EACnG,CAAC;AACD,UAAQ,KAAK,CAAC;AAChB;AAWA,SAAS,iBAAkC;AACzC,QAAM,QAAyB,CAAC;AAChC,aAAW,QAAQ,cAAc,GAAG;AAClC,QAAI;AACF,YAAM,KAAK,EAAE,MAAM,MAAM,KAAK,MAAM,aAAa,aAAa,IAAI,GAAG,OAAO,CAAC,EAAE,CAAC;AAAA,IAClF,QAAQ;AAAA,IAER;AAAA,EACF;AACA,SAAO;AACT;","names":["args"]}
|
package/dist/get-5PKNKJ5S.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/actions/get.ts"],"sourcesContent":["import type { ActionsGetResponse } from \"@baker/api\";\nimport { defineCommand } from \"citty\";\nimport { apiPost, validateConvexId } from \"../../client.ts\";\nimport { writeJson } from \"../../output.ts\";\nimport { registerSchema } from \"../../schemas.ts\";\nimport { buildGetHints, failApi, failValidation } from \"./shared.ts\";\n\nregisterSchema({\n command: \"actions.get\",\n description: \"Get a single action with tags, blockers, blocked-by, and active-chat info.\",\n args: {\n id: { type: \"string\", description: \"Action ID\", required: true },\n },\n});\n\nexport const getCommand = defineCommand({\n meta: { name: \"get\", description: \"Get a single action by ID. Example: baker actions get <action-id>\" },\n args: {\n id: { type: \"positional\", description: \"Action ID\", required: false },\n \"action-id\": { type: \"string\", description: \"Action ID (alternative to positional)\", required: false },\n },\n run: async ({ args }) => {\n try {\n const id = (args.id as string | undefined) || (args[\"action-id\"] as string | undefined);\n if (!id) {\n failValidation(\"Action ID is required.\");\n }\n validateConvexId(id);\n const response = await apiPost<ActionsGetResponse>(\"/api/actions/get\", { actionId: id });\n const hints = buildGetHints(response.data);\n writeJson(hints.length > 0 ? { ...response, hints } : response);\n } catch (err) {\n failApi(err);\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,qBAAqB;AAM9B,eAAe;AAAA,EACb,SAAS;AAAA,EACT,aAAa;AAAA,EACb,MAAM;AAAA,IACJ,IAAI,EAAE,MAAM,UAAU,aAAa,aAAa,UAAU,KAAK;AAAA,EACjE;AACF,CAAC;AAEM,IAAM,aAAa,cAAc;AAAA,EACtC,MAAM,EAAE,MAAM,OAAO,aAAa,oEAAoE;AAAA,EACtG,MAAM;AAAA,IACJ,IAAI,EAAE,MAAM,cAAc,aAAa,aAAa,UAAU,MAAM;AAAA,IACpE,aAAa,EAAE,MAAM,UAAU,aAAa,yCAAyC,UAAU,MAAM;AAAA,EACvG;AAAA,EACA,KAAK,OAAO,EAAE,KAAK,MAAM;AACvB,QAAI;AACF,YAAM,KAAM,KAAK,MAA8B,KAAK,WAAW;AAC/D,UAAI,CAAC,IAAI;AACP,uBAAe,wBAAwB;AAAA,MACzC;AACA,uBAAiB,EAAE;AACnB,YAAM,WAAW,MAAM,QAA4B,oBAAoB,EAAE,UAAU,GAAG,CAAC;AACvF,YAAM,QAAQ,cAAc,SAAS,IAAI;AACzC,gBAAU,MAAM,SAAS,IAAI,EAAE,GAAG,UAAU,MAAM,IAAI,QAAQ;AAAA,IAChE,SAAS,KAAK;AACZ,cAAQ,GAAG;AAAA,IACb;AAAA,EACF;AACF,CAAC;","names":[]}
|
package/dist/plan-FT632COT.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import "./chunk-4PDHHHUJ.js";
|
|
2
|
-
import "./chunk-NYIGXDUG.js";
|
|
3
|
-
import {
|
|
4
|
-
writeJsonEnvelope
|
|
5
|
-
} from "./chunk-VFIOJD5M.js";
|
|
6
|
-
import {
|
|
7
|
-
trackingPlanRequestSchema,
|
|
8
|
-
trackingPlanResponseSchema
|
|
9
|
-
} from "./chunk-HR6IWNKE.js";
|
|
10
|
-
import {
|
|
11
|
-
apiPost
|
|
12
|
-
} from "./chunk-XBOK23HI.js";
|
|
13
|
-
import "./chunk-IFWP3ZDO.js";
|
|
14
|
-
import {
|
|
15
|
-
getEnv
|
|
16
|
-
} from "./chunk-NAWWC5I3.js";
|
|
17
|
-
import {
|
|
18
|
-
registerSchema
|
|
19
|
-
} from "./chunk-NU7JSWVA.js";
|
|
20
|
-
import "./chunk-YQSBHWOI.js";
|
|
21
|
-
|
|
22
|
-
// src/commands/analytics/plan.ts
|
|
23
|
-
import { readFileSync } from "fs";
|
|
24
|
-
import { defineCommand } from "citty";
|
|
25
|
-
var description = "Start here before building a replacement Form: read the agreed journeys, event names, purposes and readiness. --json @plan.json stages the complete plan, with optional wireConversions, funnel steps and a managed Tag Manager installation. Each event records its actual emitter or the missing change and owner. Prepared is not verified. See analytics.md for the contract. Repeating installation preparation replaces its own staged tags; applies only at Publish. --full includes evidence; the default keeps the decision inventory compact.";
|
|
26
|
-
var args = { json: { type: "string", description: "Preparation request as JSON or @path; omit to read the effective plan", required: false }, full: { type: "boolean", description: "Include all journey and verification evidence", required: false } };
|
|
27
|
-
registerSchema({ command: "analytics.plan", description, args });
|
|
28
|
-
var planCommand = defineCommand({
|
|
29
|
-
meta: { name: "plan", description },
|
|
30
|
-
args,
|
|
31
|
-
run: async ({ args: args2 }) => {
|
|
32
|
-
try {
|
|
33
|
-
const input = args2.json ? JSON.parse(args2.json.startsWith("@") ? readFileSync(args2.json.slice(1), "utf8") : args2.json) : {};
|
|
34
|
-
const parsed = trackingPlanRequestSchema.parse(input);
|
|
35
|
-
const body = { ...parsed, chatId: getEnv().BAKER_CHAT_ID };
|
|
36
|
-
const response = trackingPlanResponseSchema.parse(await apiPost("/api/analytics/plan", body));
|
|
37
|
-
const plan = response.data.plan;
|
|
38
|
-
writeJsonEnvelope({ ...response, data: { ...response.data, plan: args2.full || !plan ? plan : {
|
|
39
|
-
journeys: plan.journeys.map(({ key, name, strategy, status, destinationUrl, requirement, owner }) => ({ key, name, strategy, status, destinationUrl, requirement, owner })),
|
|
40
|
-
events: plan.events.map(({ eventKey, name, purpose, door, sourceEvent, status, requirement, owner }) => ({ eventKey, name, purpose, door, sourceEvent, status, requirement, owner }))
|
|
41
|
-
} } });
|
|
42
|
-
} catch (error) {
|
|
43
|
-
writeJsonEnvelope({ ok: false, error: { code: "TRACKING_PLAN_FAILED", message: error instanceof Error ? error.message : "Could not prepare tracking", fix: "Read baker analytics plan --full and baker tag-manager draft list to see what is prepared. Correct the request and repeat; do not publish until every requested installation is staged." } });
|
|
44
|
-
process.exitCode = 1;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
export {
|
|
49
|
-
planCommand
|
|
50
|
-
};
|
|
51
|
-
//# sourceMappingURL=plan-FT632COT.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/analytics/plan.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { trackingPlanRequestSchema, trackingPlanResponseSchema } from \"@baker/api/analytics\";\nimport { defineCommand } from \"citty\";\nimport { apiPost } from \"../../client.ts\";\nimport { getEnv } from \"../../env.ts\";\nimport { registerSchema } from \"../../schemas.ts\";\nimport { writeJsonEnvelope } from \"../ads/output.ts\";\n\nconst description = \"Start here before building a replacement Form: read the agreed journeys, event names, purposes and readiness. --json @plan.json stages the complete plan, with optional wireConversions, funnel steps and a managed Tag Manager installation. Each event records its actual emitter or the missing change and owner. Prepared is not verified. See analytics.md for the contract. Repeating installation preparation replaces its own staged tags; applies only at Publish. --full includes evidence; the default keeps the decision inventory compact.\";\nconst args = { json: { type: \"string\" as const, description: \"Preparation request as JSON or @path; omit to read the effective plan\", required: false }, full: { type: \"boolean\" as const, description: \"Include all journey and verification evidence\", required: false } };\nregisterSchema({ command: \"analytics.plan\", description, args });\n\nexport const planCommand = defineCommand({\n meta: { name: \"plan\", description }, args,\n run: async ({ args }) => {\n try {\n const input: unknown = args.json ? JSON.parse(args.json.startsWith(\"@\") ? readFileSync(args.json.slice(1), \"utf8\") : args.json) : {};\n const parsed = trackingPlanRequestSchema.parse(input);\n const body = { ...parsed, chatId: getEnv().BAKER_CHAT_ID };\n const response = trackingPlanResponseSchema.parse(await apiPost(\"/api/analytics/plan\", body));\n const plan = response.data.plan;\n writeJsonEnvelope({ ...response, data: { ...response.data, plan: args.full || !plan ? plan : {\n journeys: plan.journeys.map(({ key, name, strategy, status, destinationUrl, requirement, owner }) => ({ key, name, strategy, status, destinationUrl, requirement, owner })),\n events: plan.events.map(({ eventKey, name, purpose, door, sourceEvent, status, requirement, owner }) => ({ eventKey, name, purpose, door, sourceEvent, status, requirement, owner })),\n } } });\n } catch (error) {\n writeJsonEnvelope({ ok: false, error: { code: \"TRACKING_PLAN_FAILED\", message: error instanceof Error ? error.message : \"Could not prepare tracking\", fix: \"Read baker analytics plan --full and baker tag-manager draft list to see what is prepared. Correct the request and repeat; do not publish until every requested installation is staged.\" } });\n process.exitCode = 1;\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,oBAAoB;AAE7B,SAAS,qBAAqB;AAM9B,IAAM,cAAc;AACpB,IAAM,OAAO,EAAE,MAAM,EAAE,MAAM,UAAmB,aAAa,yEAAyE,UAAU,MAAM,GAAG,MAAM,EAAE,MAAM,WAAoB,aAAa,iDAAiD,UAAU,MAAM,EAAE;AAC3Q,eAAe,EAAE,SAAS,kBAAkB,aAAa,KAAK,CAAC;AAExD,IAAM,cAAc,cAAc;AAAA,EACvC,MAAM,EAAE,MAAM,QAAQ,YAAY;AAAA,EAAG;AAAA,EACrC,KAAK,OAAO,EAAE,MAAAA,MAAK,MAAM;AACvB,QAAI;AACF,YAAM,QAA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unk-VFIOJD5M.js";
|
|
9
|
-
import "./chunk-HR6IWNKE.js";
|
|
10
|
-
import {
|
|
11
|
-
apiPost
|
|
12
|
-
} from "./chunk-XBOK23HI.js";
|
|
13
|
-
import "./chunk-IFWP3ZDO.js";
|
|
14
|
-
import "./chunk-NAWWC5I3.js";
|
|
15
|
-
import {
|
|
16
|
-
registerSchema
|
|
17
|
-
} from "./chunk-NU7JSWVA.js";
|
|
18
|
-
import "./chunk-YQSBHWOI.js";
|
|
19
|
-
|
|
20
|
-
// src/commands/analytics/questionnaire.ts
|
|
21
|
-
import { defineCommand } from "citty";
|
|
22
|
-
var description = "Question-level drop-off from the external questionnaire contract: start, viewed, completed, skipped and finished per attempt, version and sequence. Reports actual reached questions and the last unanswered one after inactivity; deduplicates repeated visits. Refuses a truncated feed (maximum 600 events), so narrow --days if needed. No events is not proof of zero abandonment. The contract is in analytics.md.";
|
|
23
|
-
var args = { name: { type: "string", description: "Event name (default questionnaire_step)", required: false }, days: { type: "string", description: "Observation window in days (default 7, maximum 90)", required: false }, inactivity: { type: "string", description: "Minutes without an event before abandonment (default 30)", required: false } };
|
|
24
|
-
registerSchema({ command: "analytics.questionnaire", description, args });
|
|
25
|
-
var questionnaireCommand = defineCommand({ meta: { name: "questionnaire", description }, args, run: async ({ args: args2 }) => {
|
|
26
|
-
try {
|
|
27
|
-
const body = questionnaireRequestSchema.parse({ ...args2.name ? { eventName: args2.name } : {}, ...args2.days ? { days: Number(args2.days) } : {}, ...args2.inactivity ? { inactivityMinutes: Number(args2.inactivity) } : {} });
|
|
28
|
-
writeJsonEnvelope(questionnaireResponseSchema.parse(await apiPost("/api/analytics/questionnaire", body)));
|
|
29
|
-
} catch (error) {
|
|
30
|
-
writeJsonEnvelope({ ok: false, error: { code: "QUESTIONNAIRE_REPORT_FAILED", message: error instanceof Error ? error.message : "Could not read question tracking", fix: "Check baker analytics plan --full for missing app events. Resolve the named contract issue or narrow the observation window; never infer abandonment from completion totals." } });
|
|
31
|
-
process.exitCode = 1;
|
|
32
|
-
}
|
|
33
|
-
} });
|
|
34
|
-
export {
|
|
35
|
-
questionnaireCommand
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=questionnaire-JNGYJTAY.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/analytics/questionnaire.ts"],"sourcesContent":["import { questionnaireRequestSchema, questionnaireResponseSchema } from \"@baker/api/analytics\";\nimport { defineCommand } from \"citty\";\nimport { apiPost } from \"../../client.ts\";\nimport { registerSchema } from \"../../schemas.ts\";\nimport { writeJsonEnvelope } from \"../ads/output.ts\";\n\nconst description = \"Question-level drop-off from the external questionnaire contract: start, viewed, completed, skipped and finished per attempt, version and sequence. Reports actual reached questions and the last unanswered one after inactivity; deduplicates repeated visits. Refuses a truncated feed (maximum 600 events), so narrow --days if needed. No events is not proof of zero abandonment. The contract is in analytics.md.\";\nconst args = { name: { type: \"string\" as const, description: \"Event name (default questionnaire_step)\", required: false }, days: { type: \"string\" as const, description: \"Observation window in days (default 7, maximum 90)\", required: false }, inactivity: { type: \"string\" as const, description: \"Minutes without an event before abandonment (default 30)\", required: false } };\nregisterSchema({ command: \"analytics.questionnaire\", description, args });\nexport const questionnaireCommand = defineCommand({ meta: { name: \"questionnaire\", description }, args, run: async ({ args }) => {\n try {\n const body = questionnaireRequestSchema.parse({ ...(args.name ? { eventName: args.name } : {}), ...(args.days ? { days: Number(args.days) } : {}), ...(args.inactivity ? { inactivityMinutes: Number(args.inactivity) } : {}) });\n writeJsonEnvelope(questionnaireResponseSchema.parse(await apiPost(\"/api/analytics/questionnaire\", body)));\n } catch (error) {\n writeJsonEnvelope({ ok: false, error: { code: \"QUESTIONNAIRE_REPORT_FAILED\", message: error instanceof Error ? error.message : \"Could not read question tracking\", fix: \"Check baker analytics plan --full for missing app events. Resolve the named contract issue or narrow the observation window; never infer abandonment from completion totals.\" } });\n process.exitCode = 1;\n }\n} });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AACA,SAAS,qBAAqB;AAK9B,IAAM,cAAc;AACpB,IAAM,OAAO,EAAE,MAAM,EAAE,MAAM,UAAmB,aAAa,2CAA2C,UAAU,MAAM,GAAG,MAAM,EAAE,MAAM,UAAmB,aAAa,sDAAsD,UAAU,MAAM,GAAG,YAAY,EAAE,MAAM,UAAmB,aAAa,4DAA4D,UAAU,MAAM,EAAE;AACpX,eAAe,EAAE,SAAS,2BAA2B,aAAa,KAAK,CAAC;AACjE,IAAM,uBAAuB,cAAc,EAAE,MAAM,EAAE,MAAM,iBAAiB,YAAY,GAAG,MAAM,KAAK,OAAO,EAAE,MAAAA,MAAK,MAAM;AAC/H,MAAI;AACF,UAAM,OAAO,2BAA2B,MAAM,EAAE,GAAIA,MAAK,OAAO,EAAE,WAAWA,MAAK,KAAK,IAAI,CAAC,GAAI,GAAIA,MAAK,OAAO,EAAE,MAAM,OAAOA,MAAK,IAAI,EAAE,IAAI,CAAC,GAAI,GAAIA,MAAK,aAAa,EAAE,mBAAmB,OAAOA,MAAK,UAAU,EAAE,IAAI,CAAC,EAAG,CAAC;AAC/N,sBAAkB,4BAA4B,MAAM,MAAM,QAAQ,gCAAgC,IAAI,CAAC,CAAC;AAAA,EAC1G,SAAS,OAAO;AACd,sBAAkB,EAAE,IAAI,OAAO,OAAO,EAAE,MAAM,+BAA+B,SAAS,iBAAiB,QAAQ,MAAM,UAAU,oCAAoC,KAAK,+KAA+K,EAAE,CAAC;AAC1V,YAAQ,WAAW;AAAA,EACrB;AACF,EAAE,CAAC;","names":["args"]}
|