@shopify/cli 4.0.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/analytics-CX22YIUZ.js +1 -0
- package/dist/analytics-UBWQIQYF.js +1 -0
- package/dist/angular-UTTM4Y4S.js +4 -0
- package/dist/bootstrap.js +1 -1
- package/dist/{chunk-DU4WR4OP.js → chunk-23AMFHXC.js} +1 -1
- package/dist/{chunk-LNHLDRC5.js → chunk-2EJCY4CE.js} +1 -1
- package/dist/{chunk-YMWHHINU.js → chunk-2KH2S7PI.js} +1 -1
- package/dist/chunk-2N4O33VM.js +6 -0
- package/dist/{chunk-WZBSLU4Q.js → chunk-2VLMN5QZ.js} +1 -1
- package/dist/chunk-2WNODIWJ.js +1 -0
- package/dist/chunk-2YXKZWYW.js +1 -0
- package/dist/{chunk-GFJ7UV74.js → chunk-3BRUCKZ2.js} +1 -1
- package/dist/{chunk-RM5SJJN6.js → chunk-3V63X7WZ.js} +66 -66
- package/dist/chunk-3YWUSKWF.js +159 -0
- package/dist/chunk-42RMKTCJ.js +8 -0
- package/dist/{chunk-V2CNCPIE.js → chunk-4EXYYBQ6.js} +1 -1
- package/dist/chunk-4KRT35A2.js +1 -0
- package/dist/chunk-4V4DQ6W7.js +836 -0
- package/dist/chunk-4Z2WYNTE.js +1 -0
- package/dist/chunk-57N2DFIF.js +1 -0
- package/dist/chunk-5TIJLYZU.js +3 -0
- package/dist/{chunk-GNPS5SBU.js → chunk-6AJZKIZ3.js} +1 -1
- package/dist/{chunk-XNO6DZYP.js → chunk-6HZTMQD6.js} +1 -1
- package/dist/chunk-6LK6ZP3Q.js +1 -0
- package/dist/chunk-6SXOUZ7V.js +1 -0
- package/dist/chunk-6TEXPRI2.js +2 -0
- package/dist/{chunk-OUOYKNMY.js → chunk-6TORWTD7.js} +1 -1
- package/dist/{chunk-IASVAERO.js → chunk-6YAXFS6V.js} +1 -1
- package/dist/chunk-6YHJ554P.js +6 -0
- package/dist/chunk-6ZIOYXEF.js +3 -0
- package/dist/chunk-7BFDUVOG.js +1 -0
- package/dist/chunk-7DVOSOEP.js +11 -0
- package/dist/chunk-7JESXDF2.js +14 -0
- package/dist/chunk-7KJ5TBWG.js +5 -0
- package/dist/{chunk-7MUKLZOL.js → chunk-A3VYI4LO.js} +2 -2
- package/dist/{chunk-4HHXSMD7.js → chunk-A5SQCM63.js} +2 -2
- package/dist/chunk-A6X2IVGT.js +4 -0
- package/dist/{chunk-HUZUORYM.js → chunk-AP3RFOPL.js} +10 -10
- package/dist/{chunk-3LVGAQB4.js → chunk-ATPFTRCC.js} +1 -1
- package/dist/chunk-AWQ5AR2K.js +5 -0
- package/dist/chunk-BECEP46I.js +16 -0
- package/dist/{chunk-JPGO36XP.js → chunk-BHWEA4V2.js} +1 -1
- package/dist/chunk-BPVZ7E63.js +1 -0
- package/dist/chunk-C2FFA4O4.js +1 -0
- package/dist/chunk-C3LZPAAH.js +3 -0
- package/dist/chunk-C6ABJCRG.js +1 -0
- package/dist/chunk-CCEA5CUX.js +1 -0
- package/dist/chunk-CE6FKJFS.js +1 -0
- package/dist/chunk-CW7WJZKR.js +28 -0
- package/dist/chunk-D3DDLLNF.js +2 -0
- package/dist/chunk-D656BV5Z.js +25 -0
- package/dist/chunk-DCBYHVKW.js +1 -0
- package/dist/{chunk-RF2DPBA6.js → chunk-DCK2FX6J.js} +1 -1
- package/dist/chunk-DERA4K6A.js +32 -0
- package/dist/chunk-DNLOSMHL.js +3 -0
- package/dist/chunk-E2YBU6D3.js +294 -0
- package/dist/{chunk-INEU4XKS.js → chunk-F47MFBKM.js} +1 -1
- package/dist/chunk-F6T3UBBL.js +1 -0
- package/dist/{chunk-WXVZJJOR.js → chunk-FBVBO5YQ.js} +1 -1
- package/dist/chunk-FD5S2O6M.js +7 -0
- package/dist/chunk-FFYYJKF7.js +1 -0
- package/dist/{chunk-LX3ZOW52.js → chunk-FGVC22EY.js} +1 -1
- package/dist/{chunk-NRAFVIU3.js → chunk-FP2NOZSD.js} +1 -1
- package/dist/chunk-FQDRVPCY.js +2 -0
- package/dist/{chunk-IOLVEXM6.js → chunk-FSTCEWXX.js} +1 -1
- package/dist/chunk-FTN7Y6HD.js +7 -0
- package/dist/{chunk-52GC6XUT.js → chunk-GVITHCQJ.js} +1 -1
- package/dist/chunk-H4W4DFKK.js +1 -0
- package/dist/{chunk-72F3YBNA.js → chunk-HD5TYIDZ.js} +1 -1
- package/dist/chunk-HHXHOQQP.js +3 -0
- package/dist/chunk-HJSYHK4S.js +8 -0
- package/dist/chunk-HLMFVORT.js +1 -0
- package/dist/chunk-HSYRYSX4.js +3 -0
- package/dist/chunk-I3LX25MB.js +1 -0
- package/dist/chunk-INFBVFMU.js +4 -0
- package/dist/chunk-IOQQUHST.js +18 -0
- package/dist/chunk-IVGWFPMA.js +19 -0
- package/dist/chunk-IWCPQD7X.js +1382 -0
- package/dist/chunk-IWE4RUI7.js +1 -0
- package/dist/chunk-IXUVSFW2.js +1 -0
- package/dist/chunk-J6VTZEE2.js +15 -0
- package/dist/{chunk-MQNYGGAM.js → chunk-K3PGC6DC.js} +1 -1
- package/dist/{chunk-MBAFWQSZ.js → chunk-K77WAKOB.js} +1 -1
- package/dist/{chunk-UGDBJTLP.js → chunk-K7K6GNF6.js} +1 -1
- package/dist/chunk-KFCGMT67.js +1 -0
- package/dist/chunk-KLA7AWG6.js +7 -0
- package/dist/{chunk-6B53BWJW.js → chunk-KQU6HOJ3.js} +1 -1
- package/dist/{chunk-A74GETYC.js → chunk-KU5OPV7U.js} +1 -1
- package/dist/chunk-L2VSSINY.js +1 -0
- package/dist/chunk-LCCMXY6N.js +1 -0
- package/dist/{chunk-GOJ2QHSR.js → chunk-LITB5QQX.js} +1 -1
- package/dist/chunk-LKS47US7.js +8 -0
- package/dist/{chunk-DJONKJSZ.js → chunk-LQMSF3F7.js} +1 -1
- package/dist/chunk-LTWXTDDR.js +5 -0
- package/dist/{chunk-D6JARNEH.js → chunk-M2TJICTB.js} +1 -1
- package/dist/chunk-M4LOKANA.js +1 -0
- package/dist/chunk-M4V2OQAX.js +1 -0
- package/dist/chunk-MA52QGHP.js +1 -0
- package/dist/chunk-MFLBTJO7.js +1 -0
- package/dist/chunk-MGL4YM3S.js +28 -0
- package/dist/{chunk-6TZAAS5H.js → chunk-MIO2CV3Q.js} +1 -1
- package/dist/{chunk-2APPXD5Z.js → chunk-MKE434RB.js} +1 -1
- package/dist/chunk-MZJRNFAU.js +1 -0
- package/dist/{chunk-HSK7YMRE.js → chunk-N3YWHJMB.js} +11 -11
- package/dist/{chunk-TQYMC7TH.js → chunk-N5ROZKPZ.js} +1 -1
- package/dist/chunk-NBYS6YQ2.js +5 -0
- package/dist/chunk-NEZEHBT2.js +1 -0
- package/dist/chunk-NO5KVFTV.js +22 -0
- package/dist/{chunk-3DQIVE24.js → chunk-NP4UFPAX.js} +1 -1
- package/dist/chunk-NPM3MFB3.js +7 -0
- package/dist/{chunk-JVIKCGDY.js → chunk-NXL6LDJU.js} +1 -1
- package/dist/chunk-OA4P6AKS.js +1 -0
- package/dist/chunk-OKNBZSGN.js +2 -0
- package/dist/chunk-OKOYLEA7.js +278 -0
- package/dist/chunk-OLOBQ42K.js +1 -0
- package/dist/chunk-OYP7DKPU.js +1 -0
- package/dist/{chunk-7UYZQN4V.js → chunk-PBTXPBI6.js} +2 -2
- package/dist/chunk-PLQFX5ZP.js +9 -0
- package/dist/{chunk-JLBH7RCF.js → chunk-PS25FEBF.js} +1 -1
- package/dist/{chunk-OLZHWPZP.js → chunk-PSQFZAF3.js} +1 -1
- package/dist/chunk-PUTZFF2Z.js +613 -0
- package/dist/chunk-QLQGHMVU.js +15 -0
- package/dist/{chunk-XLELNRFF.js → chunk-QTGMS62F.js} +1 -1
- package/dist/chunk-R6JNXEB3.js +1 -0
- package/dist/chunk-RAH5NW3R.js +1 -0
- package/dist/{chunk-R466TU3N.js → chunk-RGNAWKD7.js} +1 -1
- package/dist/chunk-RL5BWZ7D.js +15 -0
- package/dist/{chunk-Y5JKV2AI.js → chunk-RVMB5LC2.js} +1 -1
- package/dist/chunk-SSM346XI.js +5 -0
- package/dist/chunk-T5MK7ZSF.js +1 -0
- package/dist/{chunk-22PCRFG4.js → chunk-TGACBJIY.js} +1 -1
- package/dist/{chunk-KBQ4LGFB.js → chunk-TLSAQ6FG.js} +1 -1
- package/dist/chunk-TNQXTZAX.js +32 -0
- package/dist/{chunk-ELVFJ7BR.js → chunk-TQGTEVSR.js} +1 -1
- package/dist/chunk-TXUTT6UA.js +17 -0
- package/dist/chunk-U3ZG675O.js +5 -0
- package/dist/chunk-UARVYVLN.js +3 -0
- package/dist/chunk-UBKVCI7A.js +3 -0
- package/dist/{chunk-SRCQVUMC.js → chunk-UCLSPAVX.js} +1 -1
- package/dist/chunk-ULQG3XQS.js +1 -0
- package/dist/chunk-UOQ75BL3.js +1 -0
- package/dist/{chunk-OXPWCC7I.js → chunk-UOQQNAHX.js} +2 -2
- package/dist/chunk-UURFVUAH.js +11 -0
- package/dist/chunk-VA5IUGZV.js +2 -0
- package/dist/{chunk-YZDDTYTU.js → chunk-VEDZUOVI.js} +3 -3
- package/dist/chunk-VICNWPLQ.js +567 -0
- package/dist/chunk-VPL2NDH6.js +370 -0
- package/dist/chunk-VT77EFRL.js +10 -0
- package/dist/chunk-VYXVYOIJ.js +3 -0
- package/dist/chunk-WCWNI3ZV.js +283 -0
- package/dist/chunk-WNGV4JQS.js +4 -0
- package/dist/chunk-WUK5NQSX.js +6 -0
- package/dist/chunk-X2TC7S57.js +103 -0
- package/dist/chunk-X4CV6TRE.js +1 -0
- package/dist/chunk-XDAOLCPN.js +4 -0
- package/dist/chunk-XFKCDWXB.js +5 -0
- package/dist/chunk-XP6IRAZN.js +1 -0
- package/dist/{chunk-JGXWQULI.js → chunk-XX343DDG.js} +1 -1
- package/dist/{chunk-Q7ING5F5.js → chunk-XXE7667M.js} +1 -1
- package/dist/chunk-YGMVL6NZ.js +6 -0
- package/dist/chunk-YJB7P2HC.js +1 -0
- package/dist/{chunk-P6XE4MH5.js → chunk-YS6VOQ7I.js} +1 -1
- package/dist/chunk-ZZYFG22L.js +26 -0
- package/dist/cli/commands/app/app-logs/sources.js +1 -2
- package/dist/cli/commands/app/build.js +1 -1
- package/dist/cli/commands/app/bulk/cancel.js +1 -1
- package/dist/cli/commands/app/bulk/execute.js +1 -9
- package/dist/cli/commands/app/bulk/status.js +1 -5
- package/dist/cli/commands/app/config/link.js +1 -4
- package/dist/cli/commands/app/config/pull.js +1 -1
- package/dist/cli/commands/app/config/use.js +1 -1
- package/dist/cli/commands/app/config/validate.js +1 -3
- package/dist/cli/commands/app/demo/watcher.js +1 -1
- package/dist/cli/commands/app/deploy.js +1 -22
- package/dist/cli/commands/app/dev/clean.js +1 -5
- package/dist/cli/commands/app/dev.js +1 -320
- package/dist/cli/commands/app/env/pull.js +1 -11
- package/dist/cli/commands/app/env/show.js +1 -1
- package/dist/cli/commands/app/execute.js +1 -1
- package/dist/cli/commands/app/function/build.js +1 -1
- package/dist/cli/commands/app/function/info.js +1 -16
- package/dist/cli/commands/app/function/replay.js +1 -5
- package/dist/cli/commands/app/function/run.js +1 -1
- package/dist/cli/commands/app/function/schema.js +1 -1
- package/dist/cli/commands/app/function/typegen.js +1 -1
- package/dist/cli/commands/app/generate/extension.js +1 -5
- package/dist/cli/commands/app/import-custom-data-definitions.js +1 -4
- package/dist/cli/commands/app/import-extensions.js +1 -1
- package/dist/cli/commands/app/info.js +1 -11
- package/dist/cli/commands/app/init.js +1 -10
- package/dist/cli/commands/app/logs.js +1 -2
- package/dist/cli/commands/app/release.js +1 -4
- package/dist/cli/commands/app/versions/list.js +1 -1
- package/dist/cli/commands/app/webhook/trigger.js +1 -25
- package/dist/cli/commands/auth/login.js +1 -1
- package/dist/cli/commands/auth/logout.js +1 -1
- package/dist/cli/commands/cache/clear.js +1 -1
- package/dist/cli/commands/config/autoupgrade/off.js +1 -1
- package/dist/cli/commands/config/autoupgrade/on.js +1 -1
- package/dist/cli/commands/config/autoupgrade/status.js +1 -1
- package/dist/cli/commands/debug/command-flags.js +1 -1
- package/dist/cli/commands/docs/generate.d.ts +0 -8
- package/dist/cli/commands/docs/generate.js +1 -1
- package/dist/cli/commands/doctor-release/doctor-release.js +1 -1
- package/dist/cli/commands/doctor-release/theme/index.js +1 -1
- package/dist/cli/commands/help.js +1 -1
- package/dist/cli/commands/kitchen-sink/async.js +1 -1
- package/dist/cli/commands/kitchen-sink/index.js +1 -1
- package/dist/cli/commands/kitchen-sink/prompts.js +1 -1
- package/dist/cli/commands/kitchen-sink/static.js +1 -1
- package/dist/cli/commands/notifications/generate.js +1 -1
- package/dist/cli/commands/notifications/list.js +1 -1
- package/dist/cli/commands/organization/list.js +1 -1
- package/dist/cli/commands/search.js +1 -1
- package/dist/cli/commands/theme/check.js +1 -1
- package/dist/cli/commands/theme/console.js +1 -15
- package/dist/cli/commands/theme/delete.js +1 -7
- package/dist/cli/commands/theme/dev.js +1 -26
- package/dist/cli/commands/theme/duplicate.js +1 -32
- package/dist/cli/commands/theme/info.js +1 -1
- package/dist/cli/commands/theme/init.js +1 -8
- package/dist/cli/commands/theme/language-server.js +1 -1
- package/dist/cli/commands/theme/list.js +1 -1
- package/dist/cli/commands/theme/metafields/pull.js +1 -3
- package/dist/cli/commands/theme/open.js +1 -8
- package/dist/cli/commands/theme/package.js +1 -7
- package/dist/cli/commands/theme/preview.js +1 -1
- package/dist/cli/commands/theme/profile.js +1 -3
- package/dist/cli/commands/theme/publish.js +1 -7
- package/dist/cli/commands/theme/pull.js +1 -3
- package/dist/cli/commands/theme/push.js +1 -28
- package/dist/cli/commands/theme/rename.js +1 -6
- package/dist/cli/commands/theme/share.js +1 -3
- package/dist/cli/commands/upgrade.js +1 -1
- package/dist/cli/commands/version.js +1 -1
- package/dist/command-registry.js +1 -1
- package/dist/conf-store-6QNH5BID.js +1 -0
- package/dist/configs/all.yml +3 -0
- package/dist/configs/recommended.yml +3 -0
- package/dist/{custom-oclif-loader-DVFFWCBV.js → custom-oclif-loader-TSPWW5YF.js} +1 -1
- package/dist/data/filters.json +60 -0
- package/dist/data/latest.json +1 -1
- package/dist/data/setting.json +29 -9
- package/dist/data/shopify_system_translations.json +71 -19
- package/dist/data/tags.json +3 -3
- package/dist/deprecations-F6JWVV2W.js +1 -0
- package/dist/{devtools-OLOT2NY4.js → devtools-HCKYP7DQ.js} +1 -1
- package/dist/{devtools-UFRKBFGI.js → devtools-VEZNCV6W.js} +1 -1
- package/dist/dist-4BD6KOLR.js +1 -0
- package/dist/dist-AUABCVPI.js +1 -0
- package/dist/environments-RGLI75HN.js +1 -0
- package/dist/error-OZALZZ3U.js +1 -0
- package/dist/error-handler-V7LSEXHM.js +1 -0
- package/dist/{estree-KI7NUW53.js → estree-BYYJYS3A.js} +1 -1
- package/dist/fs-YMUQ6JLE.js +1 -0
- package/dist/hooks/app-init.js +1 -1
- package/dist/hooks/did-you-mean.js +1 -1
- package/dist/hooks/hydrogen-init.js +1 -1
- package/dist/hooks/plugin-plugins.js +1 -1
- package/dist/hooks/postrun.js +1 -1
- package/dist/hooks/prerun.js +1 -1
- package/dist/hooks/public-metadata.js +1 -1
- package/dist/hooks/sensitive-metadata.js +1 -1
- package/dist/hooks/tunnel-provider.js +1 -1
- package/dist/hooks/tunnel-start.js +1 -1
- package/dist/html-HETICZ2F.js +25 -0
- package/dist/index.js +9 -1182
- package/dist/is-global-BLIZ57HQ.js +1 -0
- package/dist/is-wsl-TN2CXYI7.js +1 -0
- package/dist/{latest-version-EFWBOTWM.js → latest-version-6OAYLOBL.js} +1 -1
- package/dist/{lib-QB6I6CTC.js → lib-AK5EOIKR.js} +1 -1
- package/dist/{lib-C3VO2BQW.js → lib-LVUMLZ4H.js} +1 -1
- package/dist/lib-ME6554NA.js +1 -0
- package/dist/local-GPDAXHE6.js +1 -0
- package/dist/local-storage-P66KJG6I.js +1 -0
- package/dist/{markdown-PLKL4IZK.js → markdown-5TVCXM53.js} +1 -1
- package/dist/{metadata-UDMOTRS7.js → metadata-TRH25EHU.js} +1 -1
- package/dist/{morph-EMYAITFM.js → morph-I35VYPBH.js} +4 -4
- package/dist/node-package-manager-GO4ZRTKQ.js +1 -0
- package/dist/notifications-system-HM6JZ6WJ.js +1 -0
- package/dist/{npa-ICFSA3NL.js → npa-VNALV7XY.js} +1 -1
- package/dist/output-7IYOMPSA.js +1 -0
- package/dist/{postcss-3FJQPJI2.js → postcss-IIK6CGAW.js} +1 -1
- package/dist/{prettier-NVRHEAFO.js → prettier-ZSBNNQTK.js} +1 -1
- package/dist/system-X5C4EQQH.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui-H62CMRLG.js +1 -0
- package/dist/upgrade-EEOPH464.js +1 -0
- package/dist/version-76NBQR4K.js +1 -0
- package/dist/version-IGSEISUA.js +1 -0
- package/dist/{workerd-L2EJKIAQ.js → workerd-ST6XJKUN.js} +1 -1
- package/oclif.manifest.json +142 -7
- package/package.json +14 -11
- package/dist/analytics-6IHHYAV6.js +0 -1
- package/dist/analytics-KKVP5DT3.js +0 -1
- package/dist/angular-VRDO2DBE.js +0 -4
- package/dist/chunk-26D72ZNV.js +0 -1
- package/dist/chunk-2I4PRX2I.js +0 -1
- package/dist/chunk-2VQJQ36C.js +0 -103
- package/dist/chunk-323UTVMM.js +0 -1
- package/dist/chunk-3F6NZK7S.js +0 -2
- package/dist/chunk-4G7J6HIV.js +0 -1
- package/dist/chunk-66RJ5T7A.js +0 -102
- package/dist/chunk-6BMMB2UO.js +0 -1
- package/dist/chunk-6HBRBQAN.js +0 -6
- package/dist/chunk-74HYYXXE.js +0 -17
- package/dist/chunk-7BGM2GAH.js +0 -1
- package/dist/chunk-AIV5RI3X.js +0 -1
- package/dist/chunk-AKML26N3.js +0 -7
- package/dist/chunk-ALKTLKQ6.js +0 -5
- package/dist/chunk-B2EHO7ZC.js +0 -847
- package/dist/chunk-B2IVY4V5.js +0 -1
- package/dist/chunk-BDVAE5MS.js +0 -28
- package/dist/chunk-CERXUPGC.js +0 -14
- package/dist/chunk-D3TSJA5S.js +0 -1
- package/dist/chunk-DFMQWJQ3.js +0 -3
- package/dist/chunk-DJQVNH7P.js +0 -567
- package/dist/chunk-ELYP4KFP.js +0 -8
- package/dist/chunk-FFQ5EWII.js +0 -294
- package/dist/chunk-FUOIGXI4.js +0 -1
- package/dist/chunk-GD7FWXJ5.js +0 -2
- package/dist/chunk-GFEAKSGV.js +0 -374
- package/dist/chunk-IIIVWD4R.js +0 -1
- package/dist/chunk-IX5ICOBV.js +0 -7
- package/dist/chunk-J3KVONB3.js +0 -6
- package/dist/chunk-JHPRFW5B.js +0 -19
- package/dist/chunk-K2WUCOQJ.js +0 -32
- package/dist/chunk-K5YV6UVF.js +0 -4
- package/dist/chunk-KGXQS7LS.js +0 -1
- package/dist/chunk-KL5Z3T6L.js +0 -1
- package/dist/chunk-KNVM7N3U.js +0 -1
- package/dist/chunk-KWJ562F2.js +0 -12
- package/dist/chunk-LALIKZPS.js +0 -5
- package/dist/chunk-LAZJ47DZ.js +0 -6
- package/dist/chunk-LDGAHMS7.js +0 -159
- package/dist/chunk-LW7U753G.js +0 -1
- package/dist/chunk-LXFJDCNG.js +0 -1
- package/dist/chunk-N5YIPQ6J.js +0 -1
- package/dist/chunk-N7RBSKYT.js +0 -1
- package/dist/chunk-NF2ABOOU.js +0 -1
- package/dist/chunk-ODNGDO4H.js +0 -50
- package/dist/chunk-OHY4ZL3U.js +0 -2
- package/dist/chunk-P5VVOLGV.js +0 -1
- package/dist/chunk-P7R7FBY2.js +0 -3
- package/dist/chunk-QRRNOVJ3.js +0 -1
- package/dist/chunk-RFG5RMPL.js +0 -1
- package/dist/chunk-RVNMVBPM.js +0 -1
- package/dist/chunk-SBEZBZM7.js +0 -144
- package/dist/chunk-SGQ6D3LU.js +0 -15
- package/dist/chunk-TFSBQ4RY.js +0 -5
- package/dist/chunk-UGXYQ23Y.js +0 -1411
- package/dist/chunk-VS3T5YOG.js +0 -264
- package/dist/chunk-VWYM4OWK.js +0 -1
- package/dist/chunk-VY6SNDKW.js +0 -3
- package/dist/chunk-WFXRSKRK.js +0 -1
- package/dist/chunk-XBXMPFXM.js +0 -1
- package/dist/chunk-YC6G4MHD.js +0 -3
- package/dist/chunk-YI232QLS.js +0 -1
- package/dist/chunk-ZTMSBSYD.js +0 -1
- package/dist/chunk-ZV6NCNI4.js +0 -586
- package/dist/chunk-ZVJVDCIM.js +0 -1
- package/dist/conf-store-U5ZITKJN.js +0 -1
- package/dist/deprecations-TU5UQJVV.js +0 -1
- package/dist/dist-2Z5TND4U.js +0 -1
- package/dist/dist-GYHFDHKP.js +0 -1
- package/dist/environments-Z5PR7DSI.js +0 -1
- package/dist/error-IJGNYKZ3.js +0 -1
- package/dist/error-handler-WSCGNS2P.js +0 -1
- package/dist/fs-5BDEA2KD.js +0 -1
- package/dist/html-VSSXOZOQ.js +0 -25
- package/dist/is-global-V4ZRHQG2.js +0 -1
- package/dist/is-wsl-FVUIXDOK.js +0 -1
- package/dist/lib-5L7UKDEK.js +0 -1
- package/dist/local-6QPX4GCJ.js +0 -1
- package/dist/local-storage-JLXBZVWO.js +0 -1
- package/dist/node-package-manager-HAFRYGUM.js +0 -1
- package/dist/notifications-system-MP7WDOCS.js +0 -1
- package/dist/output-YGMHXEIS.js +0 -1
- package/dist/system-KLXD4FXF.js +0 -1
- package/dist/ui-GHG3UGB3.js +0 -1
- package/dist/upgrade-OPZGPM5J.js +0 -1
- package/dist/version-D5PJZIRW.js +0 -1
- package/dist/version-KRQBMYCH.js +0 -1
- /package/dist/{acorn-LOOAJL3S.js → acorn-QBS5IYTX.js} +0 -0
- /package/dist/{babel-URCL33XX.js → babel-JS32NLHY.js} +0 -0
- /package/dist/{flow-MLHT7MTJ.js → flow-M3Q2HPQT.js} +0 -0
- /package/dist/{glimmer-HAJ4HQCW.js → glimmer-3DEJJGOJ.js} +0 -0
- /package/dist/{graphql-F7IHGXDT.js → graphql-A4HHE3MB.js} +0 -0
- /package/dist/{meriyah-AYZQ3BGY.js → meriyah-23OZNYWC.js} +0 -0
- /package/dist/{typescript-ODJ335NU.js → typescript-YKZ232QT.js} +0 -0
- /package/dist/{yaml-BIHS2GQW.js → yaml-SJKIH3VD.js} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Na}from"./chunk-FFQ5EWII.js";import{a as Sa,b as Fm}from"./chunk-VS3T5YOG.js";import"./chunk-OLZHWPZP.js";import"./chunk-HSK7YMRE.js";import{a as Gm}from"./chunk-ZTMSBSYD.js";import{a as cm,b as dm,c as bx,d as gm,e as Sx,f as xx,g as ba,h as Bm,i as zm,j as Wm,k as Wl,l as Hl,m as Hm}from"./chunk-ZV6NCNI4.js";import{a as $d}from"./chunk-AKML26N3.js";import"./chunk-RM5SJJN6.js";import{a as wm,b as _m,c as bm}from"./chunk-4G7J6HIV.js";import{a as pt,b as Bl}from"./chunk-KL5Z3T6L.js";import"./chunk-3VZEETAV.js";import{a as um,b as mm,c as jl,d as cr,e as fm,f as pr,h as hm,l as dr,m as ya,n as Ze,s as Re,u as va,v as ka,w as wa}from"./chunk-IX5ICOBV.js";import{a as pm}from"./chunk-YMWHHINU.js";import"./chunk-QFWIDATO.js";import{b as lm,g as ga,j as ql}from"./chunk-RFG5RMPL.js";import"./chunk-KBQ4LGFB.js";import{b as Am,c as Tm}from"./chunk-DJONKJSZ.js";import"./chunk-UWJ73J4B.js";import{a as go,b as _i}from"./chunk-WFXRSKRK.js";import"./chunk-YOZNRLFC.js";import"./chunk-XEFQQPL4.js";import{a as mr,b as yo}from"./chunk-SGQ6D3LU.js";import{a as km,c as _a}from"./chunk-P7R7FBY2.js";import{a as Sm,b as xm}from"./chunk-OXPWCC7I.js";import"./chunk-LX3ZOW52.js";import"./chunk-NKQBEFPS.js";import{a as Nm}from"./chunk-WDC3KIZT.js";import{a as om}from"./chunk-UGDBJTLP.js";import{a as Qu}from"./chunk-P5VVOLGV.js";import{a as xa,b as Cx,c as Nx,d as Pm,e as Im,f as Dm,g as zl,h as Rm,i as Um,j as Yt,k as ho,l as Ax,m as Ea,n as jm}from"./chunk-66RJ5T7A.js";import"./chunk-K2WUCOQJ.js";import{a as Cm,b as ur}from"./chunk-ELYP4KFP.js";import{b as Em,o as Ex}from"./chunk-7MUKLZOL.js";import{a as vm}from"./chunk-VBUZWRUL.js";import{a as Om,b as Mm,c as Lm,d as $m,e as Vm,f as qm}from"./chunk-XBXMPFXM.js";import{a as ym}from"./chunk-R466TU3N.js";import{aa as _x}from"./chunk-UGXYQ23Y.js";import"./chunk-QSTEVZFQ.js";import"./chunk-5Y7GIF2W.js";import{a as rm,b as Xe,c as am,d as sm,e as Kt}from"./chunk-TQYMC7TH.js";import{a as kx,b as lr,c as _e}from"./chunk-HUZUORYM.js";import{a as Gu}from"./chunk-MQNYGGAM.js";import{a as Wu}from"./chunk-SRCQVUMC.js";import"./chunk-A74GETYC.js";import"./chunk-4ZGSSQC6.js";import{a as Hu}from"./chunk-GNPS5SBU.js";import"./chunk-MBAFWQSZ.js";import{a as em}from"./chunk-GFJ7UV74.js";import{a as Zu}from"./chunk-22PCRFG4.js";import"./chunk-2APPXD5Z.js";import{a as nm}from"./chunk-INEU4XKS.js";import{a as im}from"./chunk-WZBSLU4Q.js";import"./chunk-OCOY5MV2.js";import{a as Lu}from"./chunk-Y5JKV2AI.js";import{a as ju}from"./chunk-6TZAAS5H.js";import{a as qu}from"./chunk-6B53BWJW.js";import{a as tm}from"./chunk-Q7ING5F5.js";import{a as Bu}from"./chunk-JLBH7RCF.js";import{a as Ju}from"./chunk-ODNGDO4H.js";import{a as Ku}from"./chunk-JGXWQULI.js";import{a as zu}from"./chunk-DU4WR4OP.js";import"./chunk-JVIKCGDY.js";import{a as Km}from"./chunk-IOLVEXM6.js";import{a as Ym}from"./chunk-3LVGAQB4.js";import{a as Q}from"./chunk-NRAFVIU3.js";import{a as Ix}from"./chunk-GD7FWXJ5.js";import{d as Px}from"./chunk-72F3YBNA.js";import{a as Xu}from"./chunk-D6JARNEH.js";import{a as $u}from"./chunk-3DQIVE24.js";import{a as Vu}from"./chunk-LNHLDRC5.js";import"./chunk-ELVFJ7BR.js";import{c as tu}from"./chunk-52GC6XUT.js";import{a as Mu}from"./chunk-XLELNRFF.js";import{$ as kn,A as Fl,G as ra,H as ao,I as so,K as Pl,L as Il,N as aa,R as gi,Z as rt,_ as vn,a as zd,aa as Jd,b as Wd,ba as Oe,c as Hd,ca as Xd,da as yi,e as Nl,ea as Zd,fa as rr,g as Al,ga as eu,h as na,j as R,ja as fu,ka as hu,l as Gd,la as gu,m as Kd,n as Ae,na as Rl,o as ia,oa as yu,p as Yd,pa,q as Qd,r as u,t as fi,ta as ku,u as oa,x as Tl,z as K}from"./chunk-B2EHO7ZC.js";import"./chunk-4LNCYIS3.js";import{B as pu,C as du,D as uu,E as mu,f as sa,g as ou,i as ru,m as la,n as au,o as su,p as ar,s as lu,t as cu,w as vi,x as ca,y as Dl}from"./chunk-LAZJ47DZ.js";import"./chunk-PRKBO42R.js";import"./chunk-GOJ2QHSR.js";import{a as Pt}from"./chunk-7BGM2GAH.js";import{a as Wt,b as hi}from"./chunk-XNO6DZYP.js";import{a as wx}from"./chunk-6HBRBQAN.js";import{a as Yu,b as T,c as Fe}from"./chunk-323UTVMM.js";import"./chunk-3TNEIDOD.js";import{c as Aa,d as Fx}from"./chunk-WXVZJJOR.js";import{b as Ht}from"./chunk-4HHXSMD7.js";import{b as fo}from"./chunk-YZDDTYTU.js";import"./chunk-MOA33ZFO.js";import{a as ut,c as gn,d as yn}from"./chunk-JUVAGMIH.js";import{A as De,B as Ge,C as co,D as xe,E as Le,F as Gt,G as Eu,H as Cu,I as wi,J as Rt,O as Ke,P as Nt,Q as Ll,R as fa,T as Tu,a as hn,b as Bd,f as vu,g as da,i as ki,j as lo,k as Me,l as je,m as ua,n as Ol,o as bu,p as wn,s as Su,t as ma,u as oe,v as j,w as He,x as Te,y as xu,z as Je}from"./chunk-BDVAE5MS.js";import"./chunk-P6XE4MH5.js";import"./chunk-KLMDWDT2.js";import"./chunk-5CH3B62S.js";import{a as vx}from"./chunk-QUTQDXSL.js";import{d as mt,e as wu,f as Ul}from"./chunk-IASVAERO.js";import{b as Ml,c as Nu,d as y,f as de,g as L,l as Au}from"./chunk-JPGO36XP.js";import{a as vo,b as Tx}from"./chunk-7UYZQN4V.js";import"./chunk-Z35BTAM6.js";import"./chunk-75VPUOC5.js";import"./chunk-HZA6IAA4.js";import"./chunk-PD5ZHJWI.js";import{r as ke}from"./chunk-LDGAHMS7.js";import"./chunk-ZR76GGZ6.js";import"./chunk-EENHXSWU.js";import"./chunk-FUOIGXI4.js";import"./chunk-6M3ZYNGO.js";import"./chunk-QYR5VPQA.js";import{a as Ca}from"./chunk-KGXQS7LS.js";import{a as _u}from"./chunk-V2CNCPIE.js";import{$ as Ct,$a as qe,Ab as nu,Ba as Pd,Bb as iu,Ca as mi,Ea as Dt,Ga as oo,Gb as b,Hb as Be,Ib as w,Ja as Id,Ka as Dd,L as zt,La as Rd,Mb as J,N as Jr,Na as ea,Nb as q,O as bl,Oa as dn,Ob as sr,P as Sl,Pa as Ud,Pb as po,Q as xl,Qb as S,Rb as se,Sb as uo,Ta as C,Tb as bn,U as Nd,Ua as Se,Ub as Ru,Va as Od,W as tr,Wa as re,Wb as mo,Xa as Md,Xb as Uu,Y as te,Yb as Ou,Z as nr,ba as Xr,bb as un,ca as ir,cb as Ld,da as Zr,db as ta,ea as Ad,eb as ot,fa as no,fb as V,ga as Td,gb as N,ha as El,ib as Vd,jb as mn,ka as It,kb as fn,ma as P,mb as qd,na as ct,nb as jd,oa as or,pa as it,qa as pn,sa as Cl,tb as ve,ua as ie,ub as ro,va as Fd,wa as ae,ya as io}from"./chunk-GFEAKSGV.js";import"./chunk-CERXUPGC.js";import"./chunk-T4M5CWAO.js";import"./chunk-PRVQAHWI.js";import{a as Fu,d as Pu,e as ha,f as ft,g as Iu,k as _n,m as $l,n as Vl,o as Du}from"./chunk-YC6G4MHD.js";import{a as Bt}from"./chunk-N7RBSKYT.js";import{d as k,e as Ne,f as he,g as z,h as Qr,i as H,j as $,k as cn,l as Ed,n as eo,p as ui,q as to,s as Cd,t as _l}from"./chunk-IU2ZQ6TE.js";import"./chunk-PIBY5DDZ.js";import{a as xd,e as O,g as l}from"./chunk-VPRTJUIN.js";l();var yx=O(wx(),1);l();l();l();l();var Sn="7e9cb568cfd431c538f36d1ad3f2b4f6";var Ta="/auth/callback";function Qm(e){return`http://127.0.0.1:${e}${Ta}`}function fr(e){return`${Sn}::${e}`}function ht(e){return e.length<=10?"***":`${e.slice(0,10)}***`}l();var Gl;function Kl(){return Gl??(Gl=new Ht({projectName:"shopify-cli-store"})),Gl}function gt(e){return typeof e=="string"}function Jm(e){if(!e||typeof e!="object")return;let t=e;if(typeof t.id=="number")return{id:t.id,...gt(t.email)?{email:t.email}:{},...gt(t.firstName)?{firstName:t.firstName}:{},...gt(t.lastName)?{lastName:t.lastName}:{},...typeof t.accountOwner=="boolean"?{accountOwner:t.accountOwner}:{}}}function Dx(e){if(!e||typeof e!="object")return;let t=e;if(!(!gt(t.store)||!gt(t.clientId)||!gt(t.userId)||!gt(t.accessToken)||!Array.isArray(t.scopes)||!t.scopes.every(gt)||!gt(t.acquiredAt)))return{store:t.store,clientId:t.clientId,userId:t.userId,accessToken:t.accessToken,scopes:t.scopes,acquiredAt:t.acquiredAt,...gt(t.refreshToken)?{refreshToken:t.refreshToken}:{},...gt(t.expiresAt)?{expiresAt:t.expiresAt}:{},...gt(t.refreshTokenExpiresAt)?{refreshTokenExpiresAt:t.refreshTokenExpiresAt}:{},...Jm(t.associatedUser)?{associatedUser:Jm(t.associatedUser)}:{}}}function Yl(e,t){let n=fr(e),i=t.get(n);if(!i||typeof i!="object")return;let{sessionsByUserId:o,currentUserId:r}=i;if(!o||typeof o!="object"||Array.isArray(o)||typeof r!="string"){t.delete(n);return}let a=Object.fromEntries(Object.entries(o).flatMap(([s,c])=>{let d=Dx(c);return d?[[s,d]]:[]}));if(Object.keys(a).length!==Object.keys(o).length)if(a[r])t.set(n,{currentUserId:r,sessionsByUserId:a});else{t.delete(n);return}return{currentUserId:r,sessionsByUserId:a}}function Fa(e,t=Kl()){let n=Yl(e,t);if(!n)return;let i=n.sessionsByUserId[n.currentUserId];if(!i){t.delete(fr(e));return}return i}function Pa(e,t=Kl()){let n=fr(e.store),i=Yl(e.store,t),o={currentUserId:e.userId,sessionsByUserId:{...i?.sessionsByUserId??{},[e.userId]:e}};t.set(n,o)}function hr(e,t,n){let i=typeof t=="string"?t:void 0,o=(typeof t=="string"?n:t)??Kl(),r=fr(e);if(!i){o.delete(r);return}let a=Yl(e,o);if(!a)return;let{[i]:s,...c}=a.sessionsByUserId,d=Object.keys(c);if(d.length===0){o.delete(r);return}o.set(r,{currentUserId:a.currentUserId===i?d[0]:a.currentUserId,sessionsByUserId:c})}l();function Xm(e,t=300){return e.slice(0,t)}async function Zm(e){let t=`https://${e.store}/admin/oauth/access_token`;S(w`Exchanging authorization code for token at ${b.raw(t)}`);let n=await Ae(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:Sn,code:e.code,code_verifier:e.codeVerifier,redirect_uri:e.redirectUri})}),i=await n.text();if(!n.ok)throw S(w`Token exchange failed with HTTP ${b.raw(String(n.status))}: ${b.raw(Xm(i||n.statusText))}`),new y(`Failed to exchange OAuth code for an access token (HTTP ${n.status}).`,i||n.statusText);let o;try{o=JSON.parse(i)}catch{throw new y("Received an invalid token response from Shopify.")}return S(w`Token exchange succeeded: access_token=${b.raw(ht(o.access_token))}, refresh_token=${b.raw(o.refresh_token?ht(o.refresh_token):"none")}, expires_in=${b.raw(String(o.expires_in??"unknown"))}s, user=${b.raw(String(o.associated_user?.id??"unknown"))} (${b.raw(o.associated_user?.email??"no email")})`),o}async function ef(e){let t=`https://${e.store}/admin/oauth/access_token`;S(w`Refreshing access token for ${b.raw(e.store)} using refresh_token=${b.raw(ht(e.refreshToken))}`);let n=await Ae(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:Sn,grant_type:"refresh_token",refresh_token:e.refreshToken})}),i=await n.text();if(!n.ok)throw S(w`Token refresh failed with HTTP ${b.raw(String(n.status))}: ${b.raw(Xm(i||n.statusText))}`),new y(`Token refresh failed for ${e.store} (HTTP ${n.status}).`);let o;try{o=JSON.parse(i)}catch{throw new y("Received an invalid refresh response from Shopify.")}if(!o.access_token)throw new y(`Token refresh returned an invalid response for ${e.store}.`);return{accessToken:o.access_token,refreshToken:o.refresh_token,expiresIn:o.expires_in,refreshTokenExpiresIn:o.refresh_token_expires_in}}var Rx=`#graphql
|
|
1
|
+
import{a as ae}from"./chunk-E2YBU6D3.js";import{a as ie,b as At}from"./chunk-OKOYLEA7.js";import"./chunk-PSQFZAF3.js";import"./chunk-N3YWHJMB.js";import{a as Ct}from"./chunk-M4LOKANA.js";import{a as ro}from"./chunk-6SXOUZ7V.js";import{a as Bt}from"./chunk-HLMFVORT.js";import{a as Qt}from"./chunk-7DVOSOEP.js";import{a as W,b as xt,c as Yt}from"./chunk-VT77EFRL.js";import{a as Dt}from"./chunk-OKNBZSGN.js";import{a as qt}from"./chunk-VA5IUGZV.js";import{a as Jt}from"./chunk-XDAOLCPN.js";import{a as Kt}from"./chunk-F6T3UBBL.js";import{a as Zt}from"./chunk-D656BV5Z.js";import{a as zt}from"./chunk-CCEA5CUX.js";import{a as oo}from"./chunk-BECEP46I.js";import{a as Mt}from"./chunk-7KJ5TBWG.js";import{a as Ht}from"./chunk-6LK6ZP3Q.js";import"./chunk-2WNODIWJ.js";import{a as Vt}from"./chunk-57N2DFIF.js";import{a as jt}from"./chunk-4Z2WYNTE.js";import"./chunk-CE6FKJFS.js";import{a as Gt}from"./chunk-AWQ5AR2K.js";import{a as no}from"./chunk-INFBVFMU.js";import{a as It}from"./chunk-FFYYJKF7.js";import{a as Wt}from"./chunk-C3LZPAAH.js";import{a as Ft}from"./chunk-NO5KVFTV.js";import"./chunk-6TEXPRI2.js";import{a as re,b as Pt}from"./chunk-PUTZFF2Z.js";import"./chunk-FD5S2O6M.js";import"./chunk-NPM3MFB3.js";import{a as nn}from"./chunk-6ZIOYXEF.js";import"./chunk-CW7WJZKR.js";import"./chunk-6YHJ554P.js";import"./chunk-DNLOSMHL.js";import{a as rn}from"./chunk-LTWXTDDR.js";import"./chunk-HJSYHK4S.js";import"./chunk-3V63X7WZ.js";import"./chunk-RAH5NW3R.js";import"./chunk-5TIJLYZU.js";import"./chunk-LKS47US7.js";import"./chunk-KLA7AWG6.js";import"./chunk-I3LX25MB.js";import"./chunk-UBKVCI7A.js";import"./chunk-IVGWFPMA.js";import"./chunk-QLQGHMVU.js";import"./chunk-FTN7Y6HD.js";import"./chunk-ZZYFG22L.js";import"./chunk-MFLBTJO7.js";import"./chunk-D3DDLLNF.js";import"./chunk-OYP7DKPU.js";import"./chunk-TXUTT6UA.js";import"./chunk-X2TC7S57.js";import"./chunk-3VZEETAV.js";import"./chunk-MA52QGHP.js";import"./chunk-IOQQUHST.js";import"./chunk-DERA4K6A.js";import"./chunk-KFCGMT67.js";import"./chunk-M4V2OQAX.js";import"./chunk-BPVZ7E63.js";import"./chunk-2YXKZWYW.js";import"./chunk-2KH2S7PI.js";import"./chunk-QFWIDATO.js";import"./chunk-7BFDUVOG.js";import{b as on}from"./chunk-L2VSSINY.js";import"./chunk-MZJRNFAU.js";import"./chunk-HHXHOQQP.js";import"./chunk-TLSAQ6FG.js";import"./chunk-LQMSF3F7.js";import"./chunk-C6ABJCRG.js";import"./chunk-UWJ73J4B.js";import"./chunk-YGMVL6NZ.js";import"./chunk-YOZNRLFC.js";import"./chunk-NBYS6YQ2.js";import"./chunk-XEFQQPL4.js";import"./chunk-WNGV4JQS.js";import"./chunk-RL5BWZ7D.js";import"./chunk-VYXVYOIJ.js";import"./chunk-NEZEHBT2.js";import"./chunk-UOQQNAHX.js";import"./chunk-FGVC22EY.js";import"./chunk-NKQBEFPS.js";import{a as to}from"./chunk-SSM346XI.js";import{a as $t}from"./chunk-UURFVUAH.js";import"./chunk-WDC3KIZT.js";import{a as Lt}from"./chunk-IXUVSFW2.js";import"./chunk-U3ZG675O.js";import{a as Ut}from"./chunk-OLOBQ42K.js";import{a as yt}from"./chunk-K7K6GNF6.js";import{a as mt}from"./chunk-R6JNXEB3.js";import{a as Tt}from"./chunk-C2FFA4O4.js";import"./chunk-UOQ75BL3.js";import"./chunk-DCBYHVKW.js";import{a as Nt}from"./chunk-X4CV6TRE.js";import{a as Rt}from"./chunk-PLQFX5ZP.js";import{a as _t}from"./chunk-XFKCDWXB.js";import"./chunk-HSYRYSX4.js";import"./chunk-IWE4RUI7.js";import"./chunk-LCCMXY6N.js";import{a as Et}from"./chunk-A6X2IVGT.js";import{a as Ot}from"./chunk-OA4P6AKS.js";import"./chunk-T5MK7ZSF.js";import"./chunk-DCK2FX6J.js";import{t as bt}from"./chunk-WCWNI3ZV.js";import"./chunk-42RMKTCJ.js";import"./chunk-A3VYI4LO.js";import"./chunk-VBUZWRUL.js";import{a as wt,c as vt}from"./chunk-VICNWPLQ.js";import"./chunk-RGNAWKD7.js";import"./chunk-IWCPQD7X.js";import"./chunk-TNQXTZAX.js";import"./chunk-QSTEVZFQ.js";import{e as Y}from"./chunk-N5ROZKPZ.js";import"./chunk-AP3RFOPL.js";import{a as ct}from"./chunk-K3PGC6DC.js";import{a as at}from"./chunk-UCLSPAVX.js";import"./chunk-KU5OPV7U.js";import"./chunk-4ZGSSQC6.js";import{a as st}from"./chunk-6AJZKIZ3.js";import"./chunk-K77WAKOB.js";import{a as ht}from"./chunk-3BRUCKZ2.js";import{a as ft}from"./chunk-TGACBJIY.js";import"./chunk-MKE434RB.js";import{a as kt}from"./chunk-F47MFBKM.js";import{a as St}from"./chunk-2VLMN5QZ.js";import"./chunk-OCOY5MV2.js";import{a as Xe}from"./chunk-RVMB5LC2.js";import{a as nt}from"./chunk-MIO2CV3Q.js";import{a as ot}from"./chunk-KQU6HOJ3.js";import{a as gt}from"./chunk-XXE7667M.js";import{a as rt}from"./chunk-PS25FEBF.js";import{a as pt}from"./chunk-J6VTZEE2.js";import{a as dt}from"./chunk-XX343DDG.js";import{a as it}from"./chunk-23AMFHXC.js";import"./chunk-NXL6LDJU.js";import{a as Xt}from"./chunk-FSTCEWXX.js";import{a as eo}from"./chunk-ATPFTRCC.js";import"./chunk-FP2NOZSD.js";import{a as dn}from"./chunk-FQDRVPCY.js";import{d as cn}from"./chunk-HD5TYIDZ.js";import{a as lt}from"./chunk-M2TJICTB.js";import{a as et}from"./chunk-NP4UFPAX.js";import{a as tt}from"./chunk-2EJCY4CE.js";import"./chunk-TQGTEVSR.js";import"./chunk-GVITHCQJ.js";import"./chunk-QTGMS62F.js";import{G as oe,P as T,ea as Ae,fa as G,g as en,n as xe,na as be,pa as B,z as b}from"./chunk-4V4DQ6W7.js";import"./chunk-4LNCYIS3.js";import"./chunk-WUK5NQSX.js";import"./chunk-PRKBO42R.js";import"./chunk-LITB5QQX.js";import"./chunk-YJB7P2HC.js";import"./chunk-6HZTMQD6.js";import{a as tn}from"./chunk-2N4O33VM.js";import{a as ut,b as F,c as P}from"./chunk-4KRT35A2.js";import"./chunk-3TNEIDOD.js";import{c as se,d as sn}from"./chunk-FBVBO5YQ.js";import{b as je}from"./chunk-A5SQCM63.js";import{b as ne}from"./chunk-VEDZUOVI.js";import"./chunk-MOA33ZFO.js";import{a as Ve,c as te}from"./chunk-JUVAGMIH.js";import{E as M,J as Je,P as Ke,u as Qe,v as Q,y as Ye}from"./chunk-MGL4YM3S.js";import"./chunk-YS6VOQ7I.js";import"./chunk-KLMDWDT2.js";import"./chunk-5CH3B62S.js";import"./chunk-QUTQDXSL.js";import{d as Ge,e as Be}from"./chunk-6YAXFS6V.js";import{c as We,d as s,g as H}from"./chunk-BHWEA4V2.js";import{a as V,b as an}from"./chunk-PBTXPBI6.js";import"./chunk-Z35BTAM6.js";import"./chunk-75VPUOC5.js";import"./chunk-HZA6IAA4.js";import"./chunk-PD5ZHJWI.js";import{r as ee}from"./chunk-3YWUSKWF.js";import"./chunk-ZR76GGZ6.js";import"./chunk-EENHXSWU.js";import"./chunk-H4W4DFKK.js";import"./chunk-6M3ZYNGO.js";import"./chunk-QYR5VPQA.js";import"./chunk-XP6IRAZN.js";import"./chunk-4EXYYBQ6.js";import{Fb as a,Hb as c,Lb as v,Mb as L,N as Me,Ob as Ze,Pb as m,Ta as ve,_ as ye,ma as we,ua as He}from"./chunk-VPL2NDH6.js";import"./chunk-7JESXDF2.js";import"./chunk-5Y7GIF2W.js";import"./chunk-T4M5CWAO.js";import"./chunk-PRVQAHWI.js";import"./chunk-UARVYVLN.js";import"./chunk-ULQG3XQS.js";import{f as X}from"./chunk-IU2ZQ6TE.js";import"./chunk-PIBY5DDZ.js";import{e as z,g as i}from"./chunk-VPRTJUIN.js";i();var Zo=z(tn(),1);i();i();i();i();var D="7e9cb568cfd431c538f36d1ad3f2b4f6";var ce="/auth/callback";function io(e){return`http://127.0.0.1:${e}${ce}`}function J(e){return`${D}::${e}`}function y(e){return e.length<=10?"***":`${e.slice(0,10)}***`}i();var Te;function Ne(){return Te??(Te=new je({projectName:"shopify-cli-store"})),Te}function w(e){return typeof e=="string"}function ao(e){if(!e||typeof e!="object")return;let t=e;if(typeof t.id=="number")return{id:t.id,...w(t.email)?{email:t.email}:{},...w(t.firstName)?{firstName:t.firstName}:{},...w(t.lastName)?{lastName:t.lastName}:{},...typeof t.accountOwner=="boolean"?{accountOwner:t.accountOwner}:{}}}function un(e){if(!e||typeof e!="object")return;let t=e;if(!(!w(t.store)||!w(t.clientId)||!w(t.userId)||!w(t.accessToken)||!Array.isArray(t.scopes)||!t.scopes.every(w)||!w(t.acquiredAt)))return{store:t.store,clientId:t.clientId,userId:t.userId,accessToken:t.accessToken,scopes:t.scopes,acquiredAt:t.acquiredAt,...w(t.refreshToken)?{refreshToken:t.refreshToken}:{},...w(t.expiresAt)?{expiresAt:t.expiresAt}:{},...w(t.refreshTokenExpiresAt)?{refreshTokenExpiresAt:t.refreshTokenExpiresAt}:{},...ao(t.associatedUser)?{associatedUser:ao(t.associatedUser)}:{}}}function _e(e,t){let o=J(e),n=t.get(o);if(!n||typeof n!="object")return;let{sessionsByUserId:r,currentUserId:u}=n;if(!r||typeof r!="object"||Array.isArray(r)||typeof u!="string"){t.delete(o);return}let d=Object.fromEntries(Object.entries(r).flatMap(([p,g])=>{let l=un(g);return l?[[p,l]]:[]}));if(Object.keys(d).length!==Object.keys(r).length)if(d[u])t.set(o,{currentUserId:u,sessionsByUserId:d});else{t.delete(o);return}return{currentUserId:u,sessionsByUserId:d}}function de(e,t=Ne()){let o=_e(e,t);if(!o)return;let n=o.sessionsByUserId[o.currentUserId];if(!n){t.delete(J(e));return}return n}function ue(e,t=Ne()){let o=J(e.store),n=_e(e.store,t),r={currentUserId:e.userId,sessionsByUserId:{...n?.sessionsByUserId??{},[e.userId]:e}};t.set(o,r)}function K(e,t,o){let n=typeof t=="string"?t:void 0,r=(typeof t=="string"?o:t)??Ne(),u=J(e);if(!n){r.delete(u);return}let d=_e(e,r);if(!d)return;let{[n]:p,...g}=d.sessionsByUserId,l=Object.keys(g);if(l.length===0){r.delete(u);return}r.set(u,{currentUserId:d.currentUserId===n?l[0]:d.currentUserId,sessionsByUserId:g})}i();function so(e,t=300){return e.slice(0,t)}async function co(e){let t=`https://${e.store}/admin/oauth/access_token`;m(c`Exchanging authorization code for token at ${a.raw(t)}`);let o=await xe(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:D,code:e.code,code_verifier:e.codeVerifier,redirect_uri:e.redirectUri})}),n=await o.text();if(!o.ok)throw m(c`Token exchange failed with HTTP ${a.raw(String(o.status))}: ${a.raw(so(n||o.statusText))}`),new s(`Failed to exchange OAuth code for an access token (HTTP ${o.status}).`,n||o.statusText);let r;try{r=JSON.parse(n)}catch{throw new s("Received an invalid token response from Shopify.")}return m(c`Token exchange succeeded: access_token=${a.raw(y(r.access_token))}, refresh_token=${a.raw(r.refresh_token?y(r.refresh_token):"none")}, expires_in=${a.raw(String(r.expires_in??"unknown"))}s, user=${a.raw(String(r.associated_user?.id??"unknown"))} (${a.raw(r.associated_user?.email??"no email")})`),r}async function uo(e){let t=`https://${e.store}/admin/oauth/access_token`;m(c`Refreshing access token for ${a.raw(e.store)} using refresh_token=${a.raw(y(e.refreshToken))}`);let o=await xe(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:D,grant_type:"refresh_token",refresh_token:e.refreshToken})}),n=await o.text();if(!o.ok)throw m(c`Token refresh failed with HTTP ${a.raw(String(o.status))}: ${a.raw(so(n||o.statusText))}`),new s(`Token refresh failed for ${e.store} (HTTP ${o.status}).`);let r;try{r=JSON.parse(n)}catch{throw new s("Received an invalid refresh response from Shopify.")}if(!r.access_token)throw new s(`Token refresh returned an invalid response for ${e.store}.`);return{accessToken:r.access_token,refreshToken:r.refresh_token,expiresIn:r.expires_in,refreshTokenExpiresIn:r.refresh_token_expires_in}}var mn=`#graphql
|
|
2
2
|
query CurrentAppInstallationAccessScopes {
|
|
3
3
|
currentAppInstallation {
|
|
4
4
|
accessScopes {
|
|
@@ -6,12 +6,12 @@ import{a as Na}from"./chunk-FFQ5EWII.js";import{a as Sa,b as Fm}from"./chunk-VS3
|
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
`;async function
|
|
9
|
+
`;async function mo(e){m(c`Fetching current app installation scopes for ${a.raw(e.store)} using token ${a.raw(y(e.accessToken))}`);let t=await G({query:mn,api:"Admin",url:Y(e.store,"unstable"),token:e.accessToken,responseOptions:{handleErrors:!1}});if(!Array.isArray(t.currentAppInstallation?.accessScopes))throw new Error("Shopify did not return currentAppInstallation.accessScopes.");return t.currentAppInstallation.accessScopes.flatMap(o=>typeof o.handle=="string"?[o.handle]:[])}i();i();function pn(e,t){return{command:`shopify store auth --store ${e} --scopes ${t}`}}function Ee(e,t){return[[pn(e,t)]]}function po(e){throw new s(`No stored app authentication found for ${e}.`,"To create stored auth for this store, run:",Ee(e,"<comma-separated-scopes>"))}function R(e,t,o){throw new s(e,"To re-authenticate, run:",Ee(t,o))}function lo(e){return new s("OAuth callback store does not match the requested store.",`Shopify returned ${e} during authentication. Re-run using the permanent store domain:`,Ee(e,"<comma-separated-scopes>"))}import{timingSafeEqual as ln}from"crypto";import{createServer as fn}from"http";function fo(e,t){let o=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),n=t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");return`<!doctype html>
|
|
10
10
|
<html lang="en">
|
|
11
11
|
<head>
|
|
12
12
|
<meta charset="utf-8" />
|
|
13
13
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
14
|
-
<title>${
|
|
14
|
+
<title>${o}</title>
|
|
15
15
|
<style>
|
|
16
16
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
17
17
|
html, body {
|
|
@@ -70,1192 +70,19 @@ import{a as Na}from"./chunk-FFQ5EWII.js";import{a as Sa,b as Fm}from"./chunk-VS3
|
|
|
70
70
|
<div class="page-main">
|
|
71
71
|
<header class="header"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 28" width="80" height="90"><path fill="#95BF47" fill-rule="evenodd" d="M17.836 27.059l-.062-23.736c-.16-.16-.472-.112-.594-.076l-.813.252a5.675 5.675 0 00-.39-.957c-.576-1.1-1.42-1.682-2.44-1.683h-.003c-.068 0-.136.006-.204.012h-.008a2.234 2.234 0 00-.092-.105C12.786.29 12.216.059 11.533.079c-1.318.038-2.63.99-3.693 2.679-.75 1.19-1.318 2.683-1.48 3.84L3.767 7.4c-.764.24-.788.263-.888.982C2.803 8.928.806 24.377.806 24.377l16.743 2.895.287-.213zM12.35 1.163a1.347 1.347 0 00-.792-.208c-2.033.06-3.807 3.235-4.26 5.352l1.949-.604.347-.107c.255-1.344.896-2.738 1.733-3.636a3.821 3.821 0 011.023-.797zm-1.793 4.135l2.796-.866c.009-.728-.07-1.805-.435-2.565-.388.16-.715.44-.95.691-.628.675-1.14 1.705-1.41 2.74zM14.23 4.16l1.299-.403c-.208-.674-.7-1.805-1.7-1.994.311.802.391 1.73.4 2.397z" clip-rule="evenodd"/><path fill="#5E8E3E" d="M21.587 5.088c-.099-.008-2.035-.037-2.035-.037s-1.619-1.573-1.778-1.733a.399.399 0 00-.225-.103v24.053l7.256-1.804S21.844 5.447 21.825 5.31a.263.263 0 00-.238-.222z"/><path fill="#fff" d="M13.528 8.824l-.843 3.153s-.94-.429-2.054-.358c-1.635.103-1.652 1.134-1.636 1.392.09 1.41 3.799 1.718 4.008 5.021.163 2.599-1.379 4.376-3.601 4.516-2.667.169-4.135-1.405-4.135-1.405l.565-2.404s1.478 1.115 2.66 1.04c.773-.048 1.05-.677 1.021-1.121-.116-1.84-3.137-1.731-3.328-4.754-.16-2.544 1.51-5.12 5.196-5.353 1.42-.09 2.147.273 2.147.273"/></svg></header>
|
|
72
72
|
<main class="card">
|
|
73
|
-
<h1>${
|
|
74
|
-
<p>${
|
|
73
|
+
<h1>${o}</h1>
|
|
74
|
+
<p>${n}</p>
|
|
75
75
|
</main>
|
|
76
76
|
</div>
|
|
77
77
|
</body>
|
|
78
|
-
</html>`}async function
|
|
78
|
+
</html>`}async function ho({store:e,state:t,port:o,timeoutMs:n=300*1e3,onListening:r}){let u=b(e);return new Promise((d,p)=>{let g=!1,l=!1,x=setTimeout(()=>{A(new s("Timed out waiting for OAuth callback."))},n),h=fn((S,f)=>{let he=new URL(S.url??"/",`http://127.0.0.1:${o}`);if(he.pathname!==ce){f.statusCode=404,f.end("Not found");return}let{searchParams:Z}=he,j=(Se,Xo)=>{let ze=typeof Se=="string"?new s(Se,Xo):Se;f.statusCode=400,f.setHeader("Content-Type","text/html"),f.setHeader("Connection","close"),f.once("finish",()=>A(ze)),f.end(fo("Authentication failed",ze.message))},ge=Z.get("shop");if(m(c`Received OAuth callback for shop ${a.raw(ge??"unknown")}`),!ge){j("OAuth callback store does not match the requested store.");return}let Le=b(ge);if(Le!==u){j(lo(Le));return}let Re=Z.get("state");if(!Re||!hn(Re,t)){j("OAuth callback state does not match the original request.");return}let Ue=Z.get("error");if(Ue){j(`Shopify returned an OAuth error: ${Ue}`);return}let ke=Z.get("code");if(!ke){j("OAuth callback did not include an authorization code.");return}m(c`Received authorization code ${a.raw(y(ke))}`),f.statusCode=200,f.setHeader("Content-Type","text/html"),f.setHeader("Connection","close"),f.once("finish",()=>k(()=>d(ke))),f.end(fo("Authentication succeeded","Close this window and return to the terminal"))}),k=S=>{if(g)return;g=!0,clearTimeout(x);let f=()=>{S()};if(!l){f();return}h.close(()=>{l=!1,f()}),h.closeIdleConnections?.()},A=S=>{k(()=>p(S))};h.on("error",S=>{if(S.code==="EADDRINUSE"){A(new s(`Port ${o} is already in use.`,`Free port ${o} and re-run ${a.genericShellCommand(`shopify store auth --store ${e} --scopes <comma-separated-scopes>`).value}. Ensure that redirect URI is allowed in the app configuration.`));return}A(S)}),h.listen(o,"127.0.0.1",()=>{l=!0,m(c`PKCE callback server listening on http://127.0.0.1:${a.raw(String(o))}${a.raw(ce)}`),r&&Promise.resolve(r()).catch(S=>{A(S instanceof Error?S:new Error(String(S)))})})})}function hn(e,t){return e.length!==t.length?!1:ln(Buffer.from(e,"utf8"),Buffer.from(t,"utf8"))}i();import{createHash as kn,randomBytes as Sn}from"crypto";function yn(){return Sn(32).toString("base64url")}function wn(e){return kn("sha256").update(e).digest("base64url")}function vn(e){let t=new URLSearchParams;return t.set("client_id",D),t.set("scope",e.scopes.join(",")),t.set("redirect_uri",e.redirectUri),t.set("state",e.state),t.set("response_type","code"),t.set("code_challenge",e.codeChallenge),t.set("code_challenge_method","S256"),`https://${e.store}/admin/oauth/authorize?${t.toString()}`}function go(e){let{store:t,scopes:o,exchangeCodeForToken:n}=e,r=13387,u=te(),d=io(r),p=yn(),g=wn(p),l=vn({store:t,scopes:o,state:u,redirectUri:d,codeChallenge:g});return m(c`Starting PKCE auth for ${a.raw(t)} with scopes ${a.raw(o.join(","))} (redirect_uri=${a.raw(d)})`),{authorization:{store:t,scopes:o,state:u,port:r,redirectUri:d,authorizationUrl:l,codeVerifier:p},waitForAuthCodeOptions:{store:t,state:u,port:r},exchangeCodeForToken:x=>n({store:t,code:x,codeVerifier:p,redirectUri:d})}}i();function Oe(e){let t=e.split(/[ ,]+/).filter(Boolean);if(t.length===0)throw new s("At least one scope is required.","Pass --scopes as a comma-separated list.");return Me(t)}function Ie(e){let t=new Set(e);for(let o of e){let n=o.match(/^(unauthenticated_)?write_(.*)$/);n&&t.add(`${n[1]??""}read_${n[2]}`)}return t}function ko(e,t){let o=[...t],n=Ie(t);for(let r of e)if(!n.has(r)){o.push(r);for(let u of Ie([r]))n.add(u)}return o}function So(e,t){if(!e.scope)return m(c`Token response did not include scope; falling back to requested scopes`),t;let o=Oe(e.scope),n=Ie(o),r=t.filter(u=>!n.has(u));if(r.length>0)throw new s("Shopify granted fewer scopes than were requested.",`Missing scopes: ${r.join(", ")}.`,["Update the app or store installation scopes.","See https://shopify.dev/app/scopes","Re-run shopify store auth."]);return o}i();i();var xn=240*1e3;function An(e){if(!e.expiresAt)return!1;let t=new Date(e.expiresAt).getTime();return Number.isNaN(t)?!0:t-xn<Date.now()}function bn(e,t){let o=Date.now(),n=t.expiresIn?new Date(o+t.expiresIn*1e3).toISOString():e.expiresAt;return{...e,accessToken:t.accessToken,refreshToken:t.refreshToken??e.refreshToken,expiresAt:n,refreshTokenExpiresAt:t.refreshTokenExpiresIn?new Date(o+t.refreshTokenExpiresIn*1e3).toISOString():e.refreshTokenExpiresAt,acquiredAt:new Date(o).toISOString()}}async function me(e){let t=de(e);if(t||po(e),m(c`Loaded stored session for ${a.raw(e)}: token=${a.raw(y(t.accessToken))}, expires=${a.raw(t.expiresAt??"unknown")}`),!An(t))return t;t.refreshToken||R(`No refresh token stored for ${t.store}.`,t.store,t.scopes.join(",")),m(c`Refreshing expired token for ${a.raw(t.store)} (expired at ${a.raw(t.expiresAt??"unknown")}, refresh_token=${a.raw(y(t.refreshToken))})`);let o=t.accessToken,n;try{n=await uo({store:t.store,refreshToken:t.refreshToken})}catch(r){throw K(t.store,t.userId),r instanceof s&&r.message.startsWith(`Token refresh failed for ${t.store} (HTTP `)&&R(r.message,t.store,t.scopes.join(",")),r instanceof s&&r.message===`Token refresh returned an invalid response for ${t.store}.`&&R(r.message,t.store,t.scopes.join(",")),r instanceof s&&r.message==="Received an invalid refresh response from Shopify.",r}return t=bn(t,n),m(c`Token refresh succeeded for ${a.raw(t.store)}: ${a.raw(y(o))} → ${a.raw(y(t.accessToken))}, new expiry ${a.raw(t.expiresAt??"unknown")}`),ue(t),t}function yo(e,t=300){return e.slice(0,t)}function Tn(e){if(e&&typeof e=="object"&&"response"in e){let t=e.response,o=t?.status,n=t?.errors;if(typeof o=="number"){let r=typeof n=="string"?n:JSON.stringify(n);return yo(r?`HTTP ${o}: ${r}`:`HTTP ${o}`)}}return yo(e instanceof Error?e.message:String(e))}async function wo(e){let t=b(e),o=de(t);if(!o)return{scopes:[],authoritative:!0};try{let n=await me(t),r=await mo({store:n.store,accessToken:n.accessToken});return m(c`Resolved current remote scopes for ${a.raw(t)}: ${a.raw(r.join(",")||"none")}`),{scopes:r,authoritative:!0}}catch(n){if(n instanceof Error)return m(c`Falling back to locally stored scopes for ${a.raw(t)} after remote scope lookup failed: ${a.raw(Tn(n))}`),{scopes:o.scopes,authoritative:!1};throw n}}i();function Nn(e){return JSON.stringify(e,null,2)}function _n(e){return{completed:["Logged in.",`Authenticated${e.associatedUser?.email?` as ${e.associatedUser.email}`:""} against ${e.store}.`],info:["","To verify that authentication worked, run:",`shopify store execute --store ${e.store} --query 'query { shop { name id } }'`]}}function En(){L("Shopify CLI will open the app authorization page in your browser."),L("")}function In(e){L("Browser did not open automatically. Open this URL manually:"),L(c`${a.link(e)}`),L("")}function On(e,t="text"){if(t==="json"){v(Nn(e));return}let o=_n(e);o.completed.forEach(n=>Ze(n)),o.info.forEach(n=>L(n))}function pe(e="text"){return{openingBrowser:En,manualAuthUrl:In,success(t){On(t,e)}}}i();async function U(e,t){await Be(()=>({store_fqdn:e})),await Ge(()=>({store_fqdn_hash:Ve(e),store_fqdn_validated:t,store_domain:e}))}var Cn={openURL:Je,waitForStoreAuthCode:ho,exchangeStoreAuthCodeForToken:co,resolveExistingScopes:wo,presenter:pe("text")};async function vo(e,t={}){let o={...Cn,...t},n=b(e.store);await U(n,!1);let r=Oe(e.scopes),u=await o.resolveExistingScopes(n),d=ko(r,u.scopes),p=u.authoritative?d:r;u.scopes.length>0&&m(c`Merged requested scopes ${a.raw(r.join(","))} with existing scopes ${a.raw(u.scopes.join(","))} for ${a.raw(n)}`);let g=go({store:n,scopes:d,exchangeCodeForToken:o.exchangeStoreAuthCodeForToken}),{authorization:{authorizationUrl:l}}=g;o.presenter.openingBrowser();let x=await o.waitForStoreAuthCode({...g.waitForAuthCodeOptions,onListening:async()=>{await o.openURL(l)||o.presenter.manualAuthUrl(l)}}),h=await g.exchangeCodeForToken(x);await U(n,!0);let k=h.associated_user?.id?.toString();if(!k)throw new s("Shopify did not return associated user information for the online access token.");oe(k);let A=Date.now(),S=h.expires_in?new Date(A+h.expires_in*1e3).toISOString():void 0,f={store:n,userId:k,scopes:So(h,p),acquiredAt:new Date(A).toISOString(),expiresAt:S,refreshTokenExpiresAt:h.refresh_token_expires_in?new Date(A+h.refresh_token_expires_in*1e3).toISOString():void 0,hasRefreshToken:!!h.refresh_token,associatedUser:h.associated_user?{id:h.associated_user.id,email:h.associated_user.email,firstName:h.associated_user.first_name,lastName:h.associated_user.last_name,accountOwner:h.associated_user.account_owner}:void 0};return ue({store:n,clientId:D,userId:k,accessToken:h.access_token,refreshToken:h.refresh_token,scopes:f.scopes,acquiredAt:f.acquiredAt,expiresAt:S,refreshTokenExpiresAt:f.refreshTokenExpiresAt,associatedUser:f.associatedUser}),m(c`Session persisted for ${a.raw(n)} (user ${a.raw(k)}, expires ${a.raw(S??"unknown")})`),o.presenter.success(f),f}i();var N=class extends ne{};i();var Ce=z(ee(),1),q={store:Ce.Flags.string({char:"s",description:"The myshopify.com domain of the store.",env:"SHOPIFY_FLAG_STORE",parse:async e=>b(e),required:!0}),"organization-id":Ce.Flags.integer({description:"The organization to create the store in (numeric ID). Auto-selects if you belong to a single org.",env:"SHOPIFY_FLAG_ORGANIZATION_ID"})};var xo=z(ee(),1),Fe,_=class extends N{async run(){let{flags:t}=await this.parse(Fe);await vo({store:t.store,scopes:t.scopes},{presenter:pe(t.json?"json":"text")})}};Fe=_;_.summary="Authenticate an app against a store for store commands.";_.descriptionWithMarkdown=`Authenticates the app against the specified store for store commands and stores an online access token for later reuse.
|
|
79
79
|
|
|
80
|
-
Re-run this command if the stored token is missing, expires, or no longer has the scopes you need.`;
|
|
80
|
+
Re-run this command if the stored token is missing, expires, or no longer has the scopes you need.`;_.description=Fe.descriptionWithoutMarkdown();_.examples=["<%= config.bin %> <%= command.id %> --store shop.myshopify.com --scopes read_products,write_products","<%= config.bin %> <%= command.id %> --store shop.myshopify.com --scopes read_products,write_products --json"];_.flags={...F,...P,store:q.store,scopes:xo.Flags.string({description:"Comma-separated Admin API scopes to request for the app.",env:"SHOPIFY_FLAG_SCOPES",required:!0})};var Ao=_;i();i();i();var bo={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CreateAppDevelopmentStore"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"shopName"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"priceLookupKey"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"prepopulateTestData"}},type:{kind:"NamedType",name:{kind:"Name",value:"Boolean"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"createAppDevelopmentStore"},arguments:[{kind:"Argument",name:{kind:"Name",value:"shopName"},value:{kind:"Variable",name:{kind:"Name",value:"shopName"}}},{kind:"Argument",name:{kind:"Name",value:"priceLookupKey"},value:{kind:"Variable",name:{kind:"Name",value:"priceLookupKey"}}},{kind:"Argument",name:{kind:"Name",value:"prepopulateTestData"},value:{kind:"Variable",name:{kind:"Name",value:"prepopulateTestData"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"shopAdminUrl"}},{kind:"Field",name:{kind:"Name",value:"shopDomain"}},{kind:"Field",name:{kind:"Name",value:"userErrors"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"code"}},{kind:"Field",name:{kind:"Name",value:"field"}},{kind:"Field",name:{kind:"Name",value:"message"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};i();var To={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"PollStoreCreation"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"shopDomain"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"organization"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"storeCreation"},arguments:[{kind:"Argument",name:{kind:"Name",value:"shopDomain"},value:{kind:"Variable",name:{kind:"Name",value:"shopDomain"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"status"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};var Fn=2,Pn=300*1e3;function Dn(e){switch(e){case"CALLING_CORE":return"Initiating store creation...";case"AWAITING_CORE_STORE_READY":return"Waiting for store to be ready...";case"FINALIZING":return"Finalizing store setup...";case"COMPLETE":return"Store creation complete!";case"FAILED":return"Store creation failed.";case"TIMED_OUT":return"Store creation timed out.";case"USER_ERROR":return"Store creation encountered a user error.";default:return`Store creation status: ${e}`}}async function No(e){let t=await vt(e.organizationId?.toString()),o=await T(),n={type:"token_refresh",handler:async()=>({token:await T()})},u=(await B({query:bo,token:o,organizationId:t.id,variables:{shopName:e.name,priceLookupKey:"SHOPIFY_PLUS_APP_DEVELOPMENT",prepopulateTestData:!1},unauthorizedHandler:n})).createAppDevelopmentStore;if(!u)throw new s("Store creation failed: unexpected empty response.");let d=u.userErrors;if(d&&d.length>0){let l=d.map(x=>x.message).join(", ");throw new s(`Failed to create development store: ${l}`)}let{shopDomain:p,shopAdminUrl:g}=u;if(!p)throw new s("Store creation succeeded but no shop domain was returned.");await M({title:c`Waiting for store to be ready...`,task:async l=>{let x=Date.now();for(;;){if(Date.now()-x>Pn)throw new s("Store creation timed out after 5 minutes.");let k=(await B({query:To,token:o,organizationId:t.id,variables:{shopDomain:p},unauthorizedHandler:n})).organization?.storeCreation?.status;if(!k)throw new s("Unable to determine store creation status.");if(k==="COMPLETE")return;if(k==="FAILED"||k==="TIMED_OUT"||k==="USER_ERROR")throw new s(`Store creation failed with status: ${k}`);l(c`${Dn(k)}`),await Ke(Fn)}},renderOptions:{stdout:process.stderr}}),e.json?v(JSON.stringify({store:{name:e.name,domain:p,adminUrl:g},organization:{id:t.id,name:t.businessName}},null,2)):Q({headline:`Development store "${e.name}" created successfully.`,body:[`Domain: ${p}`,`Admin: ${g??"N/A"}`]})}var _o=z(ee(),1),Pe,E=class extends ne{async run(){let{flags:t}=await this.parse(Pe);try{await No({name:t.name,organizationId:t["organization-id"],json:t.json})}catch(o){throw t.json&&o instanceof s&&(v(JSON.stringify({error:!0,message:o.message,nextSteps:o.nextSteps??[],exitCode:1},null,2)),process.exit(1)),o}}};Pe=E;E.hidden=!0;E.summary="Create a new development store.";E.descriptionWithMarkdown="Creates a new app development store in your organization.";E.description=Pe.descriptionWithoutMarkdown();E.flags={...F,...P,name:_o.Flags.string({description:"Name for the new development store.",required:!0,env:"SHOPIFY_FLAG_STORE_NAME"}),"organization-id":q["organization-id"]};var Eo=E;i();i();i();var Io=z(en(),1);async function qn(e){if(e.query!==void 0){if(!e.query.trim())throw new s("The --query flag value is empty. Please provide a valid GraphQL query or mutation.");return e.query}if(e.queryFile){if(!await ve(e.queryFile))throw new s(c`Query file not found at ${a.path(e.queryFile)}. Please check the path and try again.`);let t=await we(e.queryFile,{encoding:"utf8"});if(!t.trim())throw new s(c`Query file at ${a.path(e.queryFile)} is empty. Please provide a valid GraphQL query or mutation.`);return t}throw new H("Query should have been provided via --query or --query-file flags due to exactlyOne constraint. This indicates the oclif flag validation failed.")}async function $n(e,t){if(e)try{return JSON.parse(e)}catch(o){let n=o instanceof Error?o.message:"Unknown error";throw new s(c`Invalid JSON in ${a.yellow("--variables")} flag: ${n}`,"Please provide valid JSON format.")}else if(t){if(!await ve(t))throw new s(c`Variable file not found at ${a.path(t)}. Please check the path and try again.`);let o=await we(t,{encoding:"utf8"});try{return JSON.parse(o)}catch(n){let r=n instanceof Error?n.message:"Unknown error";throw new s(c`Invalid JSON in variable file ${a.path(t)}: ${r}`,"Please provide valid JSON format.")}}}function Ln(e){let t;try{t=(0,Io.parse)(e)}catch(n){throw n instanceof Error?new s(`Invalid GraphQL syntax: ${n.message}`):n}let o=t.definitions.filter(n=>n.kind==="OperationDefinition");if(o.length!==1)throw new s("GraphQL document must contain exactly one operation definition. Multiple operations are not supported.");return{operationDefinition:o[0]}}function Rn(e){return e.operationDefinition.operation==="mutation"}function Un(e,t=!1){if(Rn(e)&&!t)throw new s("Mutations are disabled by default for shopify store execute.","Re-run with --allow-mutations if you intend to modify store data.")}async function Oo(e){let t=await qn({query:e.query,queryFile:e.queryFile}),o=Ln(t);Un(o,e.allowMutations);let n=await $n(e.variables,e.variableFile);return{query:t,parsedOperation:o,parsedVariables:n,requestedVersion:e.version}}i();i();i();var zn=`
|
|
81
81
|
query StoreExecutePublicApiVersions {
|
|
82
82
|
publicApiVersions {
|
|
83
83
|
handle
|
|
84
84
|
supported
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
`;async function gf(e){try{return(await rr({query:aE,api:"Admin",url:Kt(e.adminSession.storeFqdn,"unstable",e.adminSession),token:e.adminSession.token,responseOptions:{handleErrors:!1}})).publicApiVersions}catch(t){let n=vf(t);(n===401||n===404)&&(hr(e.session.store,e.session.userId),bi(`Stored app authentication for ${e.session.store} is no longer valid.`,e.session.store,e.session.scopes.join(",")));let i=kf(t,e.adminSession.storeFqdn);throw i||t}}async function yf(e){try{return await Le({title:w`Executing GraphQL operation`,task:async()=>rr({query:e.request.query,api:"Admin",url:Kt(e.context.adminSession.storeFqdn,e.context.version,e.context.adminSession),token:e.context.adminSession.token,variables:e.request.parsedVariables,responseOptions:{handleErrors:!1}}),renderOptions:{stdout:process.stderr}})}catch(t){tc(t)&&t.response.status===401&&(hr(e.context.session.store,e.context.session.userId),bi(`Stored app authentication for ${e.context.session.store} is no longer valid.`,e.context.session.store,e.context.session.scopes.join(",")));let n=kf(t,e.context.adminSession.storeFqdn);throw n||(tc(t)&&t.response.errors?new y("GraphQL operation failed.",JSON.stringify({errors:t.response.errors},null,2)):t)}}function tc(e){if(!e||typeof e!="object"||!("response"in e))return!1;let t=e.response;return!!t&&typeof t=="object"}function vf(e){if(!tc(e))return;let t=e.response.status;return typeof t=="number"?t:void 0}var sE=["the user aborted a request","the operation was aborted"];function lE(e){if(!(e instanceof Error))return!1;if(e.name==="AbortError")return!0;let t=e.message.toLowerCase();return sE.some(n=>t.includes(n))}function kf(e,t){if(vf(e)===402)return new y(`The store ${t} is currently unavailable.`,"Check the store in the Shopify admin and try again once it is reactivated.");if(lE(e))return new y(`Request to ${t} was aborted before it completed.`)}async function cE(e){let{session:t,adminSession:n,userSpecifiedVersion:i}=e;if(i==="unstable")return i;let o=await gf({adminSession:n,session:t});if(!i)return o.filter(s=>s.supported).map(s=>s.handle).sort().reverse()[0];let r=o.map(a=>a.handle);if(r.includes(i))return i;throw new y(`Invalid API version: ${i}`,`Allowed versions: ${r.join(", ")}`)}async function wf(e){let t=await Ia(e.store);await Si(t.store,!0),ra(t.userId);let n={token:t.accessToken,storeFqdn:t.store},i=await cE({session:t,adminSession:n,userSpecifiedVersion:e.userSpecifiedVersion});return{adminSession:n,version:i,session:t}}var pE={id:"admin",prepareContext:async({store:e,requestedVersion:t})=>wf({store:e,userSpecifiedVersion:t}),execute:async({context:e,request:t})=>yf({context:e,request:t})};function _f(e){if(e==="admin")return pE;throw new L(`Unsupported store GraphQL API target: ${e}`)}async function bf(e){await Si(e.store,!1);let t=_f(e.api??"admin"),n=await hf({query:e.query,queryFile:e.queryFile,variables:e.variables,variableFile:e.variableFile,version:e.version,allowMutations:e.allowMutations}),i=await Le({title:w`Loading stored store auth`,task:async()=>t.prepareContext({store:e.store,requestedVersion:n.requestedVersion}),renderOptions:{stdout:process.stderr}});return t.execute({context:i,request:n})}l();function dE(e){return JSON.stringify(e,null,2)}function Sf(e){if(e){j({headline:"Operation succeeded.",body:`Results written to ${e}`});return}j({headline:"Operation succeeded."})}async function xf(e,t,n="text"){let i=dE(e);if(t){await ie(t,i),n==="text"&&Sf(t);return}n==="text"&&Sf(),J(i)}var Jt=O(ke(),1),nc,Xt=class extends xi{async run(){let{flags:t}=await this.parse(nc),n=await bf({store:t.store,query:t.query,queryFile:t["query-file"],variables:t.variables,variableFile:t["variable-file"],version:t.version,allowMutations:t["allow-mutations"]});await xf(n,t["output-file"],t.json?"json":"text")}};nc=Xt;Xt.summary="Execute GraphQL queries and mutations on a store.";Xt.descriptionWithMarkdown="Executes an Admin API GraphQL query or mutation on the specified store using previously stored app authentication.\n\nRun `shopify store auth` first to create stored auth for the store.\n\nMutations are disabled by default. Re-run with `--allow-mutations` if you intend to modify store data.";Xt.description=nc.descriptionWithoutMarkdown();Xt.examples=['<%= config.bin %> <%= command.id %> --store shop.myshopify.com --query "query { shop { name } }"',`<%= config.bin %> <%= command.id %> --store shop.myshopify.com --query-file ./operation.graphql --variables '{"id":"gid://shopify/Product/1"}'`,'<%= config.bin %> <%= command.id %> --store shop.myshopify.com --query "mutation { shop { id } }" --allow-mutations','<%= config.bin %> <%= command.id %> --store shop.myshopify.com --query "query { shop { name } }" --json'];Xt.flags={...T,...Fe,query:Jt.Flags.string({char:"q",description:"The GraphQL query or mutation, as a string.",env:"SHOPIFY_FLAG_QUERY",required:!1,exactlyOne:["query","query-file"]}),"query-file":Jt.Flags.string({description:"Path to a file containing the GraphQL query or mutation. Can't be used with --query.",env:"SHOPIFY_FLAG_QUERY_FILE",parse:async e=>he(e),exactlyOne:["query","query-file"]}),variables:Jt.Flags.string({char:"v",description:"The values for any GraphQL variables in your query or mutation, in JSON format.",env:"SHOPIFY_FLAG_VARIABLES",exclusive:["variable-file"]}),"variable-file":Jt.Flags.string({description:"Path to a file containing GraphQL variables in JSON format. Can't be used with --variables.",env:"SHOPIFY_FLAG_VARIABLE_FILE",parse:async e=>he(e),exclusive:["variables"]}),store:Jt.Flags.string({char:"s",description:"The myshopify.com domain of the store to execute against.",env:"SHOPIFY_FLAG_STORE",parse:async e=>K(e),required:!0}),version:Jt.Flags.string({description:"The API version to use for the query or mutation. Defaults to the latest stable version.",env:"SHOPIFY_FLAG_VERSION"}),"output-file":Jt.Flags.string({description:"The file name where results should be written, instead of STDOUT.",env:"SHOPIFY_FLAG_OUTPUT_FILE",parse:async e=>he(e)}),"allow-mutations":Jt.Flags.boolean({description:"Allow GraphQL mutations to run against the target store.",env:"SHOPIFY_FLAG_ALLOW_MUTATIONS",default:!1})};var Ef=Xt;var uE={"store:auth":mf,"store:execute":Ef},Ra=uE;l();l();l();var Pe=O(ke(),1);var I={path:Pe.Flags.string({description:"The path to your app directory.",parse:async e=>he(e),default:async()=>to(),noCacheDefault:!0,env:"SHOPIFY_FLAG_PATH"}),config:Pe.Flags.string({hidden:!1,char:"c",description:"The name of the app configuration.",env:"SHOPIFY_FLAG_APP_CONFIG"}),"client-id":Pe.Flags.string({hidden:!1,description:"The Client ID of your app.",env:"SHOPIFY_FLAG_CLIENT_ID",exclusive:["config"]}),reset:Pe.Flags.boolean({hidden:!1,description:"Reset all your settings.",env:"SHOPIFY_FLAG_RESET",default:!1,exclusive:["config"]})},Cf={query:Pe.Flags.string({char:"q",description:"The GraphQL query or mutation to run as a bulk operation.",env:"SHOPIFY_FLAG_QUERY",required:!1,exactlyOne:["query","query-file"]}),"query-file":Pe.Flags.string({description:"Path to a file containing the GraphQL query or mutation. Can't be used with --query.",env:"SHOPIFY_FLAG_QUERY_FILE",parse:async e=>he(e),exactlyOne:["query","query-file"]}),variables:Pe.Flags.string({char:"v",description:"The values for any GraphQL variables in your mutation, in JSON format. Can be specified multiple times.",env:"SHOPIFY_FLAG_VARIABLES",multiple:!0,exclusive:["variable-file"]}),"variable-file":Pe.Flags.string({description:"Path to a file containing GraphQL variables in JSONL format (one JSON object per line). Can't be used with --variables.",env:"SHOPIFY_FLAG_VARIABLE_FILE",parse:async e=>he(e),exclusive:["variables"]}),store:Pe.Flags.string({char:"s",description:"The store domain. Must be an existing dev store.",env:"SHOPIFY_FLAG_STORE",parse:async e=>K(e)}),watch:Pe.Flags.boolean({description:"Wait for bulk operation results before exiting. Defaults to false.",env:"SHOPIFY_FLAG_WATCH"}),"output-file":Pe.Flags.string({description:"The file path where results should be written if --watch is specified. If not specified, results will be written to STDOUT.",env:"SHOPIFY_FLAG_OUTPUT_FILE",dependsOn:["watch"]}),version:Pe.Flags.string({description:"The API version to use for the bulk operation. If not specified, uses the latest stable version.",env:"SHOPIFY_FLAG_VERSION"})},Nf={query:Pe.Flags.string({char:"q",description:"The GraphQL query or mutation, as a string.",env:"SHOPIFY_FLAG_QUERY",required:!1,exactlyOne:["query","query-file"]}),"query-file":Pe.Flags.string({description:"Path to a file containing the GraphQL query or mutation. Can't be used with --query.",env:"SHOPIFY_FLAG_QUERY_FILE",parse:async e=>he(e),exactlyOne:["query","query-file"]}),variables:Pe.Flags.string({char:"v",description:"The values for any GraphQL variables in your query or mutation, in JSON format.",env:"SHOPIFY_FLAG_VARIABLES",exclusive:["variable-file"]}),"variable-file":Pe.Flags.string({description:"Path to a file containing GraphQL variables in JSON format. Can't be used with --variables.",env:"SHOPIFY_FLAG_VARIABLE_FILE",parse:async e=>he(e),exclusive:["variables"]}),store:Pe.Flags.string({char:"s",description:"The myshopify.com domain of the store to execute against. The app must be installed on the store. If not specified, you will be prompted to select a store.",env:"SHOPIFY_FLAG_STORE",parse:async e=>K(e)}),version:Pe.Flags.string({description:"The API version to use for the query or mutation. Defaults to the latest stable version.",env:"SHOPIFY_FLAG_VERSION"}),"output-file":Pe.Flags.string({description:"The file name where results should be written, instead of STDOUT.",env:"SHOPIFY_FLAG_OUTPUT_FILE"})};l();l();async function ic(e,{web:t,stdout:n,stderr:i,signal:o,env:r={}}){let a=t.configuration.commands[e];if(!a)return;let[s,...c]=a.split(" ");await Ke(s,c,{cwd:t.directory,stdout:n,stderr:i,signal:o,env:r}),n.write("Web successfully built.")}l();async function Ua(e){await xe([{title:"Installing dependencies",task:async()=>{await su({packageManager:e.packageManager,directory:e.directory,deep:3})}}])}l();l();import{pipeline as mE}from"stream/promises";import Af from"node:stream/promises";import*as Tf from"node:zlib";import{fileURLToPath as sc}from"node:url";var Ff="9.1.2",Pf="7.0.1",If="3",fE="123.0.0",Df="1.0.2",Rf="2.0.1";function Uf(e){return e==="0"||e==="1"?{functionRunner:"7.0.1",javy:"4.0.0",javyPlugin:"1"}:e==="2"?{functionRunner:Ff,javy:Pf,javyPlugin:If}:null}var gr=class{constructor(t,n,i,o,r=`v${n}`){this.name=t,this.version=n,this.release=r,this.supportsWindowsOnArm=o;let a;a=`${t}-${n}`,a=process.platform==="win32"?`${a}.exe`:a,this.path=k(H(sc(import.meta.url)),"..","bin",a),this.gitHubRepo=i}downloadUrl(t,n){let i,o;switch(t.toLowerCase()){case"darwin":i="macos";break;case"linux":i="linux";break;case"win32":i="windows";break;default:throw Error(`Unsupported platform ${t}`)}switch(n.toLowerCase()){case"arm":case"arm64":o="arm";break;case"ia32":case"x64":o="x86_64";break;default:throw Error(`Unsupported architecture ${n}`)}let r=`${o}-${i}`,a=["arm-linux","arm-macos","x86_64-macos","x86_64-windows","x86_64-linux"];if(this.supportsWindowsOnArm&&a.push("arm-windows"),!a.includes(r))throw Error(`Unsupported platform/architecture combination ${t}/${n}`);return`https://github.com/${this.gitHubRepo}/releases/download/${this.release}/${this.name}-${r}-v${this.version}.gz`}async processResponse(t,n){return gE(t,n)}},rc=class{constructor(t){this.name=`shopify_functions_javy_v${t}`,this.version=t,this.path=k(H(sc(import.meta.url)),"..","bin",`shopify_functions_javy_v${t}.wasm`)}downloadUrl(t,n){return`https://cdn.shopify.com/shopifycloud/shopify-functions-javy-plugin/shopify_functions_javy_v${this.version}.wasm`}async processResponse(t,n){return mE(t,n)}},ac=class{constructor(t,n){this.name=t,this.version=n,this.path=k(H(sc(import.meta.url)),"..","bin",t)}downloadUrl(t,n){return`https://cdn.jsdelivr.net/npm/binaryen@${this.version}/bin/wasm-opt`}async processResponse(t,n){await Af.pipeline(t,n)}},oc;function lc(e=Pf){return new gr("javy",e,"bytecodealliance/javy",vi(e,">=7.0.0"))}function cc(e=If){return new rc(e)}function yr(e=Ff){return new gr("function-runner",e,"Shopify/function-runner",vi(e,">=9.1.1"))}function vr(){return oc||(oc=new ac("wasm-opt.cjs",fE)),oc}function Of(e){return new gr("shopify-function-trampoline",e,"Shopify/shopify-function-wasm-api",vi(e,">=2.0.1"),`shopify_function_trampoline/v${e}`)}var Oa=new Map;async function At(e){if(await C(e.path)&&!Oa.has(e.path))return;let n=Oa.get(e.path);if(n){await n;return}let i=hE(e);Oa.set(e.path,i);try{await i}finally{Oa.delete(e.path)}}async function hE(e){let t=e.downloadUrl(process.platform,process.arch);S(`Downloading ${e.name} ${e.version} from ${t} to ${e.path}`);let n=H(e.path);await C(n)||await ae(n),await xa(async()=>{let i=await Ae(t,void 0,"slow-request");if(i.status!==200)throw new Error(`Downloading ${e.name} failed with status code of ${i.status}`);let o=i.body;if(o===null)throw new Error(`Downloading ${e.name} failed with empty response body`);await It(async r=>{let a=k(r,"binary"),s=Rd(a);await e.processResponse(o,s),await Ud(a,509),await dn(a,e.path,{overwrite:!0})})},async()=>{},2)}async function gE(e,t){let n=Tf.createGunzip();await Af.pipeline(e,n,t)}l();var Zt={skipEsbuildReactDedeuplication:"SHOPIFY_CLI_SKIP_ESBUILD_REACT_DEDUPLICATION",disableGraphiQLExplorer:"SHOPIFY_CLI_DISABLE_GRAPHIQL",useDynamicConfigSpecifications:"SHOPIFY_CLI_DYNAMIC_CONFIG",enableAppLogPolling:"SHOPIFY_CLI_ENABLE_APP_LOG_POLLING",templatesJsonPath:"SHOPIFY_CLI_APP_TEMPLATES_JSON_PATH",mkcertBinaryPath:"SHOPIFY_CLI_MKCERT_BINARY",disableMinificationOnDev:"SHOPIFY_CLI_DISABLE_MINIFICATION_ON_DEV"},me={app:"shopify.app.toml",web:"shopify.web.toml",appEnvironments:"shopify.environments.toml",lockFile:".shopify.lock",hiddenConfig:"project.json",hiddenFolder:".shopify"},ko={production:".env"},Mf={reactTypes:"17.0.30"},wo={extensions:{directoryName:"extensions",defaultRegistrationLimit:1},web:{directoryName:"web",configurationName:me.web}},kr={graphiql:3457,localhost:3458},Ma=/^([a-zA-Z_$])([a-zA-Z0-9_$])*$/;import{build as $f}from"esbuild";var dc="2",wr=class extends y{constructor(t){super(t,w`Make sure you have a compatible version of the ${b.yellow("@shopify/shopify_function")} library installed.`,[w`Add ${b.green(`"@shopify/shopify_function": "~${dc}.0.0"`)} to the dependencies section of the package.json file in your function's directory, if not already present.`.value,"Run your package manager's install command to update dependencies."])}};async function Vf(e,t){let n=bE(e),i=n.length===0?_E:new pc(n),o=await La(e);return t.useTasks?vE(e,t,i,o):yE(e,t,i,o)}async function yE(e,t,n,i){t.signal?.aborted||(t.stdout.write(`Building function ${e.localIdentifier}...`),t.stdout.write(`Building GraphQL types...
|
|
88
|
-
`),
|
|
89
|
-
`),await n.bundle(e,t)),t.signal?.aborted||(t.stdout.write(`Running javy...
|
|
90
|
-
`),await n.compile(e,t,i)),t.signal?.aborted||t.stdout.write(`Done!
|
|
91
|
-
`)}async function vE(e,t,n,i){await xe([{title:"Building GraphQL types",task:async()=>{await en(e,t)}},{title:"Bundling JS function",task:async()=>{await n.bundle(e,t)}},{title:"Running javy",task:async()=>{await n.compile(e,t,i)}}])}async function en(e,t){if(e.typegenCommand){let i=e.typegenCommand.split(" ");return Ul("cmd_all_timing_network_ms")(async()=>Ke(i[0],i.slice(1),{cwd:e.directory,stdout:t.stdout,stderr:t.stderr,signal:t.signal}))}if(!e.isJavaScript)throw new y("No typegen_command specified. Set build.typegen_command in your function extension TOML to generate GraphQL types for non-JavaScript functions.");let n=await au(e.directory,"graphql-code-generator","--config","package.json");return Ul("cmd_all_timing_network_ms")(async()=>Ke(n.command,n.args,{cwd:e.directory,stderr:t.stderr,signal:t.signal}))}async function qf(e){let t=await qe("node_modules/@shopify/shopify_function/index.ts",{type:"file",cwd:e.directory}),n=await qe("node_modules/@shopify/shopify_function/run.ts",{type:"file",cwd:e.directory});if(!t||!n)throw new wr("Could not find the Shopify Functions JavaScript library.");if(!e.entrySourceFilePath)throw new y("Could not find your function entry point. It must be in src/index.js or src/index.ts");return t}async function La(e){let t=await qe("node_modules/@shopify/shopify_function/package.json",{type:"file",cwd:e.directory});if(!t)throw new wr("Could not find the Shopify Functions JavaScript library.");let i=JSON.parse(await P(t)).version.split(".")[0],o=Uf(i);if(o===null)throw new wr("The installed version of the Shopify Functions JavaScript library is not compatible with this version of Shopify CLI.");return o}async function kE(e,t,n=process.env){let i=await qf(e),o={...jf(e.directory,e.entrySourceFilePath,t.app.dotenv?.variables??{},n),entryPoints:[i]};return $f(o)}function jf(e,t,n,i=process.env){let o=vn(i,(c,d)=>Ma.test(d)&&c),r={...n,...o},a=Object.keys(r||{}).reduce((c,d)=>({...c,[`process.env.${d}`]:JSON.stringify(r[d])}),{});return{outfile:k(e,"dist/function.js"),alias:{"user-function":t},define:a,logLevel:"silent",bundle:!0,legalComments:"none",target:"es2022",format:"esm"}}async function Bf(e){let t=vr();await At(t);let n=H(vr().path),i="node",o=[vr().name,e,"-Oz","--enable-bulk-memory","--enable-multimemory","--enable-nontrapping-float-to-int","--strip-debug","-o",e];S(`Wasm binary: ${vr().name}`),S("Optimizing this wasm binary using wasm-opt."),await Ke(i,o,{cwd:n})}async function zf(e){let t,n=await wE(e);if(n.includes("shopify_function_v1")?t=Df:n.includes("shopify_function_v2")&&(t=Rf),!t)return;let i=Of(t);await At(i);let o=i.path,r=["-i",e,"-o",e];S(`Applying trampoline to the wasm binary with command: ${o} ${r.join(" ")}`),await Ke(o,r)}async function wE(e){let t=new Uint8Array(ct(e));if(!WebAssembly.validate(t))return[];let i=new WebAssembly.Module(t),o=WebAssembly.Module.imports(i);return[...new Set(o.map(r=>r.module))]}async function Wf(e,t,n,i=[]){let o=lc(n.javy),r=cc(n.javyPlugin);await Promise.all([At(o),At(r)]);let a=["build","-C","dynamic","-C",`plugin=${r.path}`,...i,"-o",e.outputPath,"dist/function.js"];return Ke(o.path,a,{cwd:e.directory,stdout:"inherit",stderr:"inherit",signal:t.signal})}async function _o(e){let n=e.allExtensions.filter(s=>s.features.includes("function")&&s.isJavaScript).map(s=>La(s)),i=await Promise.all(n),o=new Set,r=new Set;i.forEach(s=>{o.add(s.javy),r.add(s.javyPlugin)});let a=[];o.forEach(s=>{a.push(At(lc(s)))}),r.forEach(s=>{a.push(At(cc(s)))}),await Promise.all(a)}var _E={async bundle(e,t){return kE(e,t)},async compile(e,t,n){return Wf(e,t,n)}},Lf="shopify-function",pc=class{constructor(t){this.exports=t}async bundle(t,n,i=process.env){await qf(t);let o=this.entrypointContents;S("Generating dist/function.js using generated module:"),S(o);let r={...jf(t.directory,t.entrySourceFilePath,n.app.dotenv?.variables??{},i),stdin:{contents:o,loader:"ts",resolveDir:t.directory}};return $f(r)}async compile(t,n,i){let o=this.wit;return S("Generating world to use with Javy:"),S(o),It(async r=>{let a=k(r,"javy-world.wit");return await ie(a,o),Wf(t,n,i,["-C",`wit=${a}`,"-C",`wit-world=${Lf}`])})}get wit(){let t=this.exports.map(n=>`export %${Ct(n)}: func();`);return`package function:impl;
|
|
92
|
-
|
|
93
|
-
world ${Lf} {
|
|
94
|
-
${t.join(`
|
|
95
|
-
`)}
|
|
96
|
-
}`}get entrypointContents(){let t=`
|
|
97
|
-
import __runFunction from "@shopify/shopify_function/run"`,n=this.exports.map(i=>{let o=nr(i),r=nr(`run-${i}`);return`
|
|
98
|
-
import { ${o} as ${r} } from "user-function"
|
|
99
|
-
export function ${o}() { return __runFunction(${r}) }`});return`${t}
|
|
100
|
-
${n.join(`
|
|
101
|
-
`)}`}};function bE(e){let t=e.configuration.targeting??[],n=t.filter(r=>!r.export),i=t.filter(r=>!!r.export);if(t.length>1&&n.length>0)throw new Error(`Can't infer export name for targets:
|
|
102
|
-
${n.map(({target:r})=>`- '${r}'`).join(`
|
|
103
|
-
`)}
|
|
104
|
-
All targets must have an export when multiple targets are present.`);let o=i.filter(r=>!r.export.match(/^[a-z0-9-]+$/));if(o.length>0){let r=[],a=o.map(s=>`'${s.export}'`);throw r.push(`Invalid export names: ${a.join(", ")}.
|
|
105
|
-
|
|
106
|
-
The TOML's exports must be kebab-case (lowercase, hyphen or numbers) to comply with WebAssembly's Component Model.
|
|
107
|
-
|
|
108
|
-
JavaScript exports with camelCase names are automatically mapped to kebab-case Wasm exports.
|
|
109
|
-
`),r.push("Suggested TOML changes:"),o.forEach(s=>{let c=s.export;r.push(`- Change export for '${s.target}' to '${Ct(c)}'.`)}),new Error(r.join(`
|
|
110
|
-
`))}return i.map(r=>r.export)}async function SE(e){!e.skipDependenciesInstallation&&!e.project.usesWorkspaces&&await Ua(e.project);let t={};e.apiKey&&(t.SHOPIFY_API_KEY=e.apiKey),await _o(e.app),await ma({processes:[...e.app.webs.map(n=>({prefix:["web",...n.configuration.roles].join("-"),action:async(i,o,r)=>{await ic("build",{web:n,stdout:i,stderr:o,signal:r,env:t})}})),...e.app.allExtensions.map(n=>({prefix:n.localIdentifier,action:async(i,o,r)=>{await n.build({stdout:i,stderr:o,signal:r,app:e.app,environment:"production"})}}))],showTimestamps:!1}),j({headline:[{userInput:e.app.name},"built!"]})}var Hf=SE;l();l();l();l();function $a(e,t){return async n=>{let i=await e.appsForOrg(t,n);return{apps:i.apps,hasMorePages:i.hasMorePages}}}l();l();l();l();l();function _r(e,{httpsOnly:t=!1,message:n="Invalid URL"}={}){return e.refine(i=>Kf(i,t),{message:n}).refine(i=>!i.includes(`
|
|
111
|
-
`),{message:n})}function Gf(e,{message:t="URL must be HTTPS URL or start with /"}={}){return e.refine(n=>n.startsWith("/")||Kf(n,!0),{message:t})}function Kf(e,t){try{let n=new URL(e);return t?n.protocol==="https:":["http:","https:"].includes(n.protocol)}catch{return!1}}function uc(e){return typeof e=="string"&&!e.startsWith("/")?`/${e}`:e}var Va=30;function Yf(e){return e.length<=Va}l();l();l();var Ee=50,qa=250,tn=u.object({namespace:u.string(),key:u.string()}),xE=u.object({sms_marketing:u.boolean().optional(),customer_privacy:u.boolean().optional()}),EE=u.object({sources:u.array(u.string()).optional()}),CE=u.object({network_access:u.boolean().optional(),block_progress:u.boolean().optional(),api_access:u.boolean().optional(),collect_buyer_consent:xE.optional(),iframe:EE.optional()}),NE=u.object({runs_offline:u.boolean().optional()}),Qf=u.object({type:u.string().optional(),extensions:u.array(u.any()).optional()}),AE=u.object({allow_direct_linking:u.boolean().optional()}),TE=u.object({module:u.string()}),FE=u.object({target:u.string(),module:u.string(),should_render:TE.optional(),tools:u.string().optional(),instructions:u.string().optional(),intents:u.array(u.object({type:u.string(),action:u.string(),schema:u.string(),name:u.string().optional(),description:u.string().optional()})).optional(),metafields:u.array(tn).optional(),default_placement:u.string().optional(),urls:u.object({edit:u.string().optional()}).optional(),capabilities:AE.optional(),preloads:u.object({chat:u.string().optional()}).optional(),assets:u.string().optional()}),mc=u.array(FE),Jf=u.string(),fc=u.object({key:u.string().optional(),name:u.string().optional(),description:u.string().optional(),required:u.boolean().optional(),default_value:u.any().optional(),type:u.string(),validations:u.array(u.any()).optional(),marketingActivityCreateUrl:u.string().optional(),marketingActivityDeleteUrl:u.string().optional()}),Xf=u.object({fields:u.array(fc).optional()}),Zf=u.string().trim().nonempty("Handle can't be empty").max(Ee,`Handle can't exceed ${Ee} characters`).regex(/^[a-zA-Z0-9-]*$/,"Handle can only contain alphanumeric characters and hyphens").refine(e=>!e.startsWith("-")&&!e.endsWith("-"),"Handle can't start or end with a hyphen"),PE=u.string().trim().nonempty("UID can't be empty").max(qa,`UID can't exceed ${qa} characters`).regex(/^[a-zA-Z0-9-${}.()_`]*$/,"UID can only contain alphanumeric characters and hyphens").refine(e=>!e.startsWith("-")&&!e.endsWith("-"),"UID can't start or end with a hyphen"),ge=u.object({name:u.string().optional(),type:u.string().optional(),handle:Zf.optional(),uid:PE.optional(),description:u.string().optional(),api_version:Jf.optional(),extension_points:u.any().optional(),capabilities:CE.optional(),supported_features:NE.optional(),settings:Xf.optional()}),bo=ge.extend({handle:Zf}),at=ge.omit({handle:!0}),eh=u.object({api_version:Jf.optional(),description:u.string().optional(),extensions:u.array(u.any()),settings:Xf.optional()});l();import{isUtf8 as IE}from"node:buffer";import th from"fs";async function yt(e,t){let n=await re(k(e,"locales/*.json"));if(!n||n.length===0)return{};let i=DE(n);if(i.length===0)throw new y(`Missing default language in ${t} configuration`,"Make sure to have a {locale}.default.json file in your locales directory");if(i.length>1)throw new y(`Error loading ${t}`,'There must be one (and only one) locale identified as the default locale: e.g. "en.default.json"');for(let o of n)if(th.statSync(o).size===0)throw new y(`Error loading ${t}`,`Locale file ${o} can't be empty`);return{default_locale:i[0],translations:RE(n,t)}}function DE(e){return e.filter(n=>$(n).endsWith(".default.json")).map(n=>$(n).split(".")[0])}function RE(e,t){let n={};for(let i of e){let o=UE($(i).split(".")[0],"Locale code is unset"),r=th.readFileSync(i);if(!IE(r))throw new y(`Error loading ${t}`,`Locale file ${i} contains invalid UTF-8 byte sequences. Re-save the file using UTF-8 encoding.`);n[o]=r.toString("base64")}return n}function UE(e,t){if(e===void 0)throw new L(t);return e}function Ei(e){return e.experience==="configuration"}var st;(function(e){e.ShouldRender="should_render",e.Main="main",e.Tools="tools",e.Instructions="instructions",e.Intents="intents"})(st||(st={}));function le(e){let n={...{externalIdentifier:`${e.identifier}_external`,additionalIdentifiers:[],externalName:Nd(e.identifier.replace(/_/g," ")),surface:"test-surface",partnersWebIdentifier:e.identifier,schema:ge,registrationLimit:wo.extensions.defaultRegistrationLimit,transform:e.transformLocalToRemote,reverseTransform:e.transformRemoteToLocal,experience:e.experience??"extension",uidStrategy:e.uidStrategy??(e.experience==="configuration"?"single":"uuid"),getDevSessionUpdateMessages:e.getDevSessionUpdateMessages,clientSteps:e.clientSteps},...e};return{...n,contributeToAppConfigurationSchema:i=>{let o=Ei(n),r=n.schema._def.shape!==void 0,a=n.uidStrategy==="single";return o&&r&&a?i.merge(n.schema):i},parseConfigurationObject:i=>{let o=n.schema.safeParse(i);return o.success?{state:"ok",data:o.data,errors:void 0}:{state:"error",data:void 0,errors:o.error.errors}}}}function $e(e){let t=e.appModuleFeatures??(()=>[]);return le({identifier:e.identifier,schema:e.schema,appModuleFeatures:t,transformLocalToRemote:OE(e.transformConfig),transformRemoteToLocal:ME(e.schema,e.transformConfig),experience:"configuration",uidStrategy:e.uidStrategy??"single",clientSteps:e.clientSteps,getDevSessionUpdateMessages:e.getDevSessionUpdateMessages,patchWithAppDevURLs:e.patchWithAppDevURLs})}function xn(e){return le({identifier:e.identifier,schema:u.any({}),appModuleFeatures:e.appModuleFeatures,experience:e.experience,clientSteps:e.clientSteps,uidStrategy:e.uidStrategy,transformRemoteToLocal:e.transformRemoteToLocal,devSessionWatchConfig:e.devSessionWatchConfig,deployConfig:async(t,n)=>{let i=LE(t);if(e.appModuleFeatures().includes("localization")){let o=await yt(n,e.identifier);i={...i,localization:o}}return i}})}function OE(e){return Object.keys(e).includes("forward")?e.forward:t=>nh(t,e)}function ME(e,t){return t?Object.keys(t).includes("reverse")?t.reverse:n=>nh(n,t,!0):n=>ih(e,n)}function nh(e,t,n=!1){let i={};for(let[o,r]of Object.entries(t)){let a=n?o:r,s=n?r:o,c=Oe(e,a);c!==void 0&&Xd(i,s,c)}return i}function ih(e,t){return Object.keys(e._def.shape()).reduce((n,i)=>{let o=e._def.shape()[i];return o instanceof u.ZodOptional&&(o=o._def.innerType),o instanceof u.ZodObject?n[i]=ih(o,t):(t[i]!==void 0&&(n[i]=t[i]),delete t[i]),n},{})}function LE(e){let{type:t,handle:n,uid:i,path:o,extensions:r,...a}=e;return a}var $E=at.extend({access:u.object({admin:u.object({direct_api_mode:u.union([u.literal("online"),u.literal("offline")]).optional(),embedded_app_direct_api_access:u.boolean().optional()}).optional()}).optional(),access_scopes:u.object({scopes:u.string().transform(e=>Td(e)??"").optional(),required_scopes:u.array(u.string()).optional(),optional_scopes:u.array(u.string()).optional(),use_legacy_install_flow:u.boolean().optional()}).optional(),auth:u.object({redirect_urls:u.array(_r(u.string()))})}),Ci="app_access",VE={access:"access",scopes:"access_scopes.scopes",required_scopes:"access_scopes.required_scopes",optional_scopes:"access_scopes.optional_scopes",use_legacy_install_flow:"access_scopes.use_legacy_install_flow",redirect_url_allowlist:"auth.redirect_urls"},qE=$e({identifier:Ci,schema:$E,transformConfig:VE,getDevSessionUpdateMessages:async e=>{let t=e.access_scopes!==void 0,n=e.access_scopes?.use_legacy_install_flow===!0,i=e.access_scopes?.scopes==null&&e.access_scopes?.required_scopes==null;if(n||t&&i)return["Using legacy install flow - access scopes are not auto-granted"];let o=e.access_scopes?.scopes?e.access_scopes.scopes.split(",").map(r=>r.trim()).join(", "):e.access_scopes?.required_scopes?.join(", ");return o?[`Access scopes auto-granted: ${o}`]:["App has been installed"]},patchWithAppDevURLs:(e,t)=>{t.redirectUrlWhitelist&&(e.auth={redirect_urls:t.redirectUrlWhitelist})}}),oh=qE;l();function jE(e,t){return t}async function ja(e,t,n){let i={};try{let a=await P(e);i=JSON.parse(a)}catch{}let o={[t]:n},r=rt(i,o,jE);await ie(e,JSON.stringify(r,null,2))}var BE=u.array(u.string()).optional().transform(zE).transform(WE);function zE(e){return e?.map(t=>t.replace(/[\/\\]+$/,""))}function WE(e){return e?.map(t=>t.replace(/([^\*])\*$/,"$1**"))}var br=u.object({client_id:u.string(),build:u.object({automatically_update_urls_on_dev:u.boolean().optional(),dev_store_url:u.string().optional(),include_config_on_deploy:u.boolean().optional()}).optional(),extension_directories:BE,web_directories:u.array(u.string()).optional()}).passthrough();function lh(e,t=!0){let n=e.reduce((i,o)=>o.contributeToAppConfigurationSchema(i),br);return t?n.passthrough():e.length>0?n.strict():n}function vt(e){return e.access_scopes?.scopes??""}function So(e){let t=vt(e);return t.length?t.split(",").map(n=>n.trim()):[]}function HE(e){return k(e,me.hiddenFolder,me.hiddenConfig)}function hc(e){let t=Object.keys(br.shape).concat("organization_id");return Object.keys(e).filter(n=>!t.includes(n))}var fe;(function(e){e.Frontend="frontend",e.Backend="backend",e.Background="background"})(fe||(fe={}));var rh=u.preprocess(uc,u.string()),ah=u.object({auth_callback_path:u.union([rh,rh.array()]).optional(),webhooks_path:u.preprocess(uc,u.string()).optional(),port:u.number().max(65536).min(0).optional(),commands:u.object({build:u.string().optional(),predev:u.string().optional(),dev:u.string()}),name:u.string().optional(),hmr_server:u.object({http_paths:u.string().array()}).optional()}),sh=u.enum([fe.Frontend,fe.Backend,fe.Background]).default(fe.Frontend),ch=u.union([ah.extend({roles:u.array(sh)}),ah.extend({type:sh})]),Ba=class{constructor({name:t,directory:n,configPath:i,configuration:o,webs:r,modules:a,dotenv:s,errors:c,specifications:d,configSchema:p,remoteFlags:m,hiddenConfig:h,devApplicationURLs:g}){this.idEnvironmentVariableName="SHOPIFY_API_KEY",this.name=t,this.directory=n,this.configPath=i,this.configuration=o,this.webs=r,this.dotenv=s,this.realExtensions=a,this.errors=c??new xr,this.specifications=d,this.configSchema=p??br,this.remoteFlags=m??[],this._hiddenConfig=h,g&&this.setDevApplicationURLs(g)}get allExtensions(){return this.includeConfigOnDeploy===!1?this.nonConfigExtensions:this.realExtensions}get nonConfigExtensions(){return this.realExtensions.filter(t=>!t.isAppConfigExtension)}get draftableExtensions(){return this.realExtensions.filter(t=>t.isUUIDStrategyExtension||t.specification.identifier===Ci)}setDevApplicationURLs(t){this.patchAppConfiguration(t),this.realExtensions.forEach(n=>n.patchWithAppDevURLs(t))}async manifest(t){let n=await Promise.all(this.realExtensions.map(async i=>{let o=await i.deployConfig({apiKey:String(this.configuration.client_id??""),appConfiguration:this.configuration});return{type:i.externalType,handle:i.handle,uid:i.uid,uuid:t?.extensions[i.localIdentifier],assets:i.uid,target:i.contextValue,config:o??{}}}));return{name:this.name,handle:"",modules:zt(n)}}get hiddenConfig(){return this._hiddenConfig}getLogsDir(){return k(this.directory,".shopify","logs")}async updateHiddenConfig(t){if(!this.configuration.client_id)return;this._hiddenConfig=rt(this.hiddenConfig,t);let n=HE(this.directory);await ja(n,String(this.configuration.client_id),this.hiddenConfig)}async preDeployValidation(){this.validateWebhookLegacyFlowCompatibility();let t=this.allExtensions.filter(i=>i.isFunctionExtension&&i.configuration.ui?.handle);if(t.length>0){let i=GE(t,this.allExtensions);if(i)throw new y("Invalid function configuration",i.join(`
|
|
112
|
-
`))}let n=this.allExtensions.filter(i=>i.isEditorExtensionCollection);if(n.length>0){let i=KE(n,this.allExtensions);if(i)throw new y("Invalid editor extension collection configuration",i.join(`
|
|
113
|
-
|
|
114
|
-
`))}await Promise.all(this.allExtensions.map(i=>i.preDeployValidation()))}extensionsForType(t){return this.allExtensions.filter(n=>n.type===t.identifier||n.type===t.externalIdentifier)}updateExtensionUUIDS(t){this.allExtensions.forEach(n=>{n.devUUID=t[n.localIdentifier]??n.devUUID})}appIsLaunchable(){let t=this.webs.find(i=>Ye(i,fe.Frontend)),n=this.webs.find(i=>Ye(i,fe.Backend));return!!(t??n)}get appIsEmbedded(){return this.configuration.embedded}creationDefaultOptions(){return{isLaunchable:this.appIsLaunchable(),scopesArray:So(this.configuration),name:this.name,isEmbedded:this.appIsEmbedded,directory:this.directory}}removeExtension(t){this.realExtensions=this.realExtensions.filter(n=>n.uid!==t)}async generateExtensionTypes(){let t=new Map;await Promise.all(this.allExtensions.map(n=>n.contributeToSharedTypeFile(t))),t.forEach((n,i)=>{let o=Se(i);if(n.size===0){o&&Pd(i);return}let r=o?ct(i).toString():"",a=[`import '@shopify/ui-extensions';
|
|
115
|
-
`,...Array.from(n)].join(`
|
|
116
|
-
`);r!==a&&Fd(i,a)})}get includeConfigOnDeploy(){return this.configuration.build?.include_config_on_deploy}patchAppConfiguration(t){this.devApplicationURLs=t,this.configuration.application_url=t.applicationUrl,t.appProxy&&(this.configuration.app_proxy={url:t.appProxy.proxyUrl,subpath:t.appProxy.proxySubPath,prefix:t.appProxy.proxySubPathPrefix}),this.configuration.auth?.redirect_urls&&(this.configuration.auth.redirect_urls=t.redirectUrlWhitelist)}validateWebhookLegacyFlowCompatibility(){let t=this.configuration.webhooks?.subscriptions?.some(i=>i.topics&&i.topics.length>0)??!1,n=this.configuration.access_scopes?.use_legacy_install_flow===!0;if(t&&n)throw new y("App-specific webhook subscriptions are not supported when use_legacy_install_flow is enabled.",`To use app-specific webhooks, you need to:
|
|
117
|
-
1. Remove 'use_legacy_install_flow = true' from your configuration
|
|
118
|
-
2. Run 'shopify app deploy' to sync your scopes with the Developer Dashboard
|
|
119
|
-
|
|
120
|
-
Alternatively, continue using shop-specific webhooks with the legacy install flow.
|
|
121
|
-
|
|
122
|
-
Learn more: https://shopify.dev/docs/apps/build/authentication-authorization/app-installation`)}};function GE(e,t){let n=[];return e.forEach(i=>{let o=i.configuration.ui.handle,r=ph(t,o);r?r.type!=="ui_extension"&&n.push(`[${i.name}] - Local app must contain one extension of type 'ui_extension' and handle '${o}'`):n.push(`[${i.name}] - Local app must contain a ui_extension with handle '${o}'`)}),n.length>0?n:void 0}function KE(e,t){let n=[],i=["ui_extension"];return e.forEach(o=>{o.configuration.inCollection.forEach(r=>{let a=ph(t,r.handle);a?i.includes(a.specification.identifier)?a.specification.identifier==="ui_extension"&&a.configuration.extension_points.forEach(c=>{c.target.startsWith("admin.")&&n.push(`[${o.handle}] editor extension collection: Remove extension '${a.configuration.handle}' with target '${c.target}' from this collection. This extension target is not supported in collections.`)}):n.push(`[${o.handle}] editor extension collection: Remove extension of type '${a.specification.identifier}' from this collection. This extension type is not supported in collections.`):n.push(`[${o.handle}] editor extension collection: Add extension with handle '${r.handle}' to local app. Local app must include extension with handle '${r.handle}'.`)})}),n.length>0?n:void 0}function ph(e,t){return e.find(n=>n.handle===t)}async function dh(e){let t=e.dependency;if(t)return Sr(t,e.directory)}async function Sr(e,t){let n=e.replace("-react","").split("/"),i=k("node_modules",n[0],n[1],"package.json"),o=await qe(i,{cwd:t,type:"file",allowSymlinks:!0});if(!o)return"not_found";o=await or(o);let r=await ca(o);return r.version?{name:e,version:r.version}:"not_found"}l();function YE(e){if(!e?.length)return null;let t=null,n=-1;for(let i of e){if(!i.issues?.length)continue;let o=0,r=0,a=0;for(let c of i.issues)c.message?.includes("Required")||c.message?.includes("required")?o++:c.message?.includes("Expected")&&c.message?.includes("received")?r++:a++;let s;o>0?s=1e3-o*10-r-a:r>0?s=100-r*5-a:s=50-a,s>n&&(n=s,t=i)}return t}function uh(e){let t=[];for(let n of e)if(n.code==="invalid_union"&&n.unionErrors){let i=YE(n.unionErrors);if(i?.issues?.length)for(let o of i.issues)t.push({path:o.path,message:o.message,code:n.code});else t.push({path:n.path,message:n.message??"Configuration doesn't match any expected format",code:n.code})}else t.push({path:n.path,message:n.message??"Unknown error",code:n.code});return t}l();var mh=/^shopify\.app(\.[-\w]+)?\.toml$/;function dt(e){return e?za(e)?e:`shopify.app.${te(e)}.toml`:me.app}function Er(e){return $(e).match(mh)?.[1]?.slice(1)}function za(e){return!!mh.test(e)}l();l();l();import{deflate as QE}from"node:zlib";import{promisify as JE}from"node:util";var XE=JE(QE);async function ZE(e){let t=await P(e),n=Buffer.byteLength(t),o=(await XE(Buffer.from(t))).byteLength;return{path:e,rawBytes:n,compressedBytes:o}}function fh(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(2)} MB`:`${(e/1024).toFixed(1)} KB`}async function hh(e){try{let{rawBytes:t,compressedBytes:n}=await ZE(e);return` (${fh(t)} original, ~${fh(n)} compressed)`}catch(t){return S(`Failed to get bundle size for ${e}: ${t}`),""}}l();l();import{createInterface as eC}from"readline";var tC=[".git",".hg",".bzr",".svn","_darcs","CVS",".sublime-(project|workspace)",".DS_Store",".sass-cache","Thumbs.db","desktop.ini","config.yml","node_modules",".gitkeep",".shopifyignore","*.toml"];async function En(e){let n=k(e.directory,".shopifyignore"),i=tC.map(o=>k("*",o));if(Se(n)){let o=await nC(n);i.push(...o)}return re("*/*",{absolute:!0,cwd:e.directory,ignore:i})}function nC(e){return new Promise((t,n)=>{let i=[],o=eC({input:Dd(e),crlfDelay:1/0});o.on("line",r=>{let a=r.trim();a.length>0&&!a.startsWith("#")&&i.push(a)}),o.on("close",()=>{t(i)}),o.on("error",r=>{n(r)})})}import{context as iC,formatMessagesSync as gh}from"esbuild";var yh=O(Cx(),1);async function gc(e,t=process.env){let n=aC(e,t),i=await iC(n),o=await i.rebuild();rC(o,e),await oC(o,e.outputPath),await i.dispose()}async function vh(e,t){t.stdout.write(`Bundling theme extension ${e.localIdentifier}...`);let n=await En(e);await Promise.all(n.map(function(i){let o=z(e.directory,i),r=k(e.outputPath,o);if(i!==r)return it(i,r)}))}async function oC(e,t){if(!e?.metafile)return;let{dir:n,name:i}=Ed(t),o=k(n,`${i}.metafile.json`);try{await ie(o,JSON.stringify(e.metafile))}catch(r){se(`Failed to write metafile to ${o}: ${r}`)}}function rC(e,t){let n=e?.warnings??[],i=e?.errors??[];n.length>0&&gh(n,{kind:"warning"}).forEach(r=>{t.stdout.write(r)}),i.length>0&&gh(i,{kind:"error"}).forEach(r=>{t.stderr.write(r)})}function aC(e,t=process.env){let n=vn(t,(a,s)=>Ma.test(s)&&a),i={...e.env,...n},o=Object.keys(i||{}).reduce((a,s)=>({...a,[`process.env.${s}`]:JSON.stringify(i[s])}),{"process.env.NODE_ENV":JSON.stringify(e.environment)}),r={outfile:e.outputPath,stdin:e.stdin,bundle:!0,define:o,jsx:"automatic",logLevel:e.logLevel??"error",loader:{".esnext":"ts",".js":"jsx"},legalComments:"none",minify:e.minify,plugins:sC(e.stdin.resolveDir,t),target:"es6",resolveExtensions:[".tsx",".ts",".js",".json",".esnext",".mjs",".ejs"]};if(e.sourceMaps&&(r.sourcemap=!0,r.sourceRoot=`${e.stdin.resolveDir}/src`),e.environment==="production"&&(r.metafile=!0),e.environment==="development"){let a=i[Zt.disableMinificationOnDev];r.minify=!Bt(a),r.logLevel="silent"}return r}function sC(e,t=process.env){let n=[yh.default.default()],i=Bt(t[Zt.skipEsbuildReactDedeuplication]);if(e&&!i){let o;try{o=xd.resolve("react",{paths:[e]})}catch{S(`Unable to load React in ${e}, skipping React de-duplication`)}o&&(S(`Deduplicating React dependency for ${e}, using ${o}`),n.push(lC(o)))}return n}function lC(e){return{name:"shopify:deduplicate-react",setup({onResolve:t}){t({filter:/^react$/},n=>({path:e}))}}}l();var Wa="# api_version: ";function kh(e,t){return`${Wa}${t}
|
|
123
|
-
|
|
124
|
-
${e}`}async function cC(e){if(!await C(e)){S(`Could not determine api_version: schema file not found at ${e}.`);return}let n=(await P(e)).split(`
|
|
125
|
-
`,1)[0];if(n.startsWith(Wa))return n.slice(Wa.length).trim();S(`Could not determine api_version from ${e}: missing '${Wa}' marker on the first line.`)}async function wh({directory:e,localIdentifier:t,apiVersion:n}){let i=k(e,"schema.graphql"),o=await cC(i);if(o!==void 0&&o!==n)throw new y(w`The ${b.cyan("schema.graphql")} file for ${b.cyan(t)} was generated for api_version ${b.yellow(o)} but your function is now on api_version ${b.yellow(n)}.`,w`Run ${b.genericShellCommand("shopify app function schema")} to refresh it.`)}var _h=O(Nx(),1);async function bh(e,t){t.stdout.write(`Bundling UI extension ${e.localIdentifier}...`);let n=t.app.dotenv?.variables??{};t.appURL&&(n.APP_URL=t.appURL);let i=t.buildDirectory??"",o=k(e.directory,i,e.outputRelativePath),{main:r,assets:a}=e.getBundleExtensionStdinContent(),s=performance.now();try{await gc({minify:!0,outputPath:o,stdin:{contents:r,resolveDir:e.directory,loader:"tsx"},environment:t.environment,env:n,stderr:t.stderr,stdout:t.stdout,sourceMaps:e.isSourceMapGeneratingExtension}),a&&await Promise.all(a.map(async p=>{await gc({minify:!0,outputPath:k(H(o),p.outputFileName),stdin:{contents:p.content,resolveDir:e.directory,loader:"tsx"},environment:t.environment,env:n,stderr:t.stderr,stdout:t.stdout})}))}catch(p){let m=p.message??"Unknown error occurred",h=new y(`Failed to bundle extension ${e.localIdentifier}. Please check the extension source code for errors.`,m);throw h.errors=p.errors,h}await e.buildValidation({outputPath:o});let c=Math.round(performance.now()-s),d=await hh(o);return t.stdout.write(`${e.localIdentifier} successfully built in ${c}ms${d}`),o}async function Ha(e,t){let n=k(e.directory,".build-lock"),i;try{i=await _h.default.lock(e.directory,{retries:20,lockfilePath:n})}catch(o){throw S(`Failed to acquire function build lock: ${o.message}`),new y("Failed to build function.","This is likely due to another in-progress build.",["Ensure there are no other function builds in-progress.","Delete the `.build-lock` file in your function directory."])}try{let o=e.configuration,r=e.outputPath,a=o.build?.path??e.outputRelativePath;e.outputPath=k(e.directory,a),await wh({directory:e.directory,localIdentifier:e.localIdentifier,apiVersion:o.api_version}),e.isJavaScript?await pC(e,t):await dC(e,t);let s=e.configuration.build?.wasm_opt;Se(e.outputPath)&&s&&await Bf(e.outputPath),Se(e.outputPath)&&await zf(e.outputPath);let c=k(e.directory,e.outputRelativePath);Se(e.outputPath)&&r!==e.outputPath&&r!==c&&H(r)!==H(e.outputPath)&&await yc(e.outputPath,r)}catch(o){if(o instanceof y)throw o;let r=o.message??"Unknown error occurred",a=new y("Failed to build function.",r);throw a.errors=o.errors,a}finally{await i()}}async function yc(e,t){S(`Converting WASM from ${e} to base64 in ${t}`);let n=await P(e,{encoding:"base64"});await pn(t),await ie(t,n)}async function pC(e,t){return e.buildCommand?(e.typegenCommand&&await en(e,t),Sh(e.buildCommand,e,t)):Vf(e,t)}async function dC(e,t){if(!e.buildCommand)throw t.stderr.write(`The function extension ${e.localIdentifier} doesn't have a build command or it's empty`),t.stderr.write(`
|
|
126
|
-
Edit the shopify.function.extension.toml configuration file and set how to build the extension.
|
|
127
|
-
|
|
128
|
-
[build]
|
|
129
|
-
command = "{COMMAND}"
|
|
130
|
-
|
|
131
|
-
Note that the command must output a dist/index.wasm file.
|
|
132
|
-
`),new de;return e.typegenCommand&&await en(e,t),Sh(e.buildCommand,e,t)}async function Sh(e,t,n){let i=e.split(" ");n.stdout.write(`Building function ${t.localIdentifier}...`),await Ke(i[0],i.slice(1),{stdout:n.stdout,stderr:n.stderr,cwd:t.directory,signal:n.signal})}l();l();l();l();l();l();async function xo(e,t,n){let[i,o]=await Promise.all([or(e),or(t)]),r=z(o,i);if(r.split(/[/\\]/,1)[0]===".."||Qr(r))throw new y(`Asset path '${n}' resolves outside the app directory.`,`Asset sources must be inside the app folder. Resolved to: ${i}`)}async function Eh(e){let{key:t,baseDir:n,outputDir:i,context:o,appDirectory:r,destination:a,usedBasenames:s=new Set,preserveFilePaths:c=!1}=e,{stdout:d}=o.options,p=Ga(o.extension.configuration,t),m;typeof p=="string"?m=[p]:Array.isArray(p)?m=p.filter(_=>typeof _=="string"):m=[];for(let _ of m)if(_.trim()==="")throw new y(`'${t}' can't be empty.`);if(m.length===0)return S(`No value for configKey '${t}', skipping
|
|
133
|
-
`,d),{filesCopied:0,pathMap:new Map};let h=a?k(i,a):i,g=[...new Set(m)],f=new Map,v=0;for(let _ of g){let x=k(n,_);if(!await C(x))throw new Error(w`Couldn't find ${b.path(x)}\n Please check the path '${_}' in your configuration`.value);await xo(x,r,_);let A=await Dt(x),F=h;if(A){let W=await re(["**/*"],{cwd:x,absolute:!1}),ee=W.map(ne=>z(i,k(F,ne)));if(c)for(let ne of W)xh($(ne),_,s);await ta(x,F),d.write(`Included '${_}'
|
|
134
|
-
`);for(let ne of W)s.add($(ne));f.set(_,ee),v+=W.length}else{await ae(F);let W=$(x),ee;c?(xh(W,_,s),ee=W):ee=uC(W,s),s.add(ee);let ne=z(i,k(F,ee)),be=k(F,ee);await it(x,be),d.write(`Included '${_}'
|
|
135
|
-
`),f.set(_,ne),v+=1}}return{filesCopied:v,pathMap:f}}function xh(e,t,n){if(n.has(e))throw new y(`File collision: '${e}' from '${t}' would overwrite a file copied from a different source. Rename or relocate the conflicting file.`)}function uC(e,t){if(!t.has(e))return e;let n=cn(e),i=n?e.slice(0,-n.length):e,o=1e3,r=1;for(;t.has(`${i}-${r}${n}`);)if(r++,r>o)throw new Error(`Unable to find unique basename for '${e}' after ${o} attempts`);return`${i}-${r}${n}`}function vc(e){return e.split(".").map(t=>{let n=t.endsWith("[]");return{name:n?t.slice(0,-2):t,flatten:n}})}function Ga(e,t){let n=e;for(let{name:i,flatten:o}of vc(t)){if(n==null)return;if(Array.isArray(n)){let r=n.map(a=>a!==null&&typeof a=="object"?a[i]:void 0).filter(a=>a!==void 0);n=r.length>0?r:void 0}else if(typeof n=="object")n=n[i];else return;if(o){if(!Array.isArray(n))return;n=n.flat(1)}}return n}function Cr(e){return cn(e)?H(e):e}async function Ch(e,t,n,i){let{extension:o,options:r}=t,a=[],s=[];for(let p of e)typeof p.anchor=="string"&&typeof p.groupBy=="string"?a.push(p):s.push(p);if(a.length===0&&s.length===0&&i.length===0)return;let c={};for(let p of s){let m=hC(p.key),h=Ga(o.configuration,p.key);h!=null&&(c[m]=Ka(h,n))}let d=new Map;for(let p of a){let m=`${p.anchor}||${p.groupBy}`,h=d.get(m);h?h.push(p):d.set(m,[p])}for(let p of d.values()){let{anchor:m,groupBy:h}=p[0],g=Ga(o.configuration,m);if(Array.isArray(g))for(let f of g){if(f===null||typeof f!="object"||Array.isArray(f))continue;let v=f,_=v[h];if(typeof _!="string")continue;let x=p.map(F=>{let W=mC(F.key,m),ee=kc(v,W);return Ka(ee,n)});x.some(wc)&&r.stdout.write(`Warning: manifest entry '${_}' contains unresolved paths \u2014 source files may be missing
|
|
136
|
-
`);let A=c[_]??{};c[_]=fC([A,...x])}}if(i.length>0&&(c.files=i),Object.keys(c).length===0){r.stdout.write(`Warning: no manifest entries produced \u2014 skipping manifest.json
|
|
137
|
-
`);return}await _c(t,c)}async function _c(e,t){let n=Cr(e.extension.outputPath),i=k(n,"manifest.json");await C(n)||await ae(n);let o={};if(await C(i))try{let r=await P(i);o=JSON.parse(r)}catch{S(`Warning: could not parse existing manifest.json, starting fresh
|
|
138
|
-
`,e.options.stdout)}for(let[r,a]of Object.entries(t)){let s=o[r];s&&typeof s=="object"&&!Array.isArray(s)&&typeof a=="object"&&!Array.isArray(a)?o[r]={...s,...a}:o[r]=a}await ie(i,JSON.stringify(o,null,2)),S(`Updated manifest.json in ${n}
|
|
139
|
-
`,e.options.stdout)}function mC(e,t){if(t===e)return"";let n=`${t}.`;return e.startsWith(n)?e.slice(n.length):e}function kc(e,t){if(t==="")return e;let n=vc(t),[i,...o]=n;if(!i)return e;let r=o.map(s=>`${s.name}${s.flatten?"[]":""}`).join("."),a=e[i.name];if(i.flatten){if(!Array.isArray(a))return{[i.name]:a};let s=a.map(c=>r?kc(c,r):c);return{[i.name]:s}}return r&&a!==null&&a!==void 0&&typeof a=="object"&&!Array.isArray(a)?{[i.name]:kc(a,r)}:{[i.name]:a}}function fC(e){return Object.assign({},...e)}function Ka(e,t){if(typeof e=="string")return(e.startsWith(".")||e.includes("/")||e.includes("\\")||t.has(e)?t.get(e):void 0)??e;if(Array.isArray(e))return e.map(n=>Ka(n,t));if(e!==null&&typeof e=="object"){let n={};for(let[i,o]of Object.entries(e))n[i]=Ka(o,t);return n}return e}function hC(e){let t=e.split(".").at(-1)??e;return t.endsWith("[]")?t.slice(0,-2):t}function wc(e){return typeof e=="string"?e.startsWith("./")||e.startsWith("../"):Array.isArray(e)?e.some(wc):e!==null&&typeof e=="object"?Object.values(e).some(wc):!1}l();async function Nh(e,t){let{sourceDir:n,outputDir:i,patterns:o,ignore:r,appDirectory:a,sourceDirConfigValue:s}=e;if(!await C(n))return{filesCopied:0,outputPaths:[]};await xo(n,a,s);let c=await re(o,{absolute:!0,cwd:n,ignore:r});if(c.length===0)return{filesCopied:0,outputPaths:[]};await ae(i);let d=c,p=await Promise.all(d.map(async g=>{let f=z(n,g),v=k(i,f);return z(i,v).startsWith("..")?(t.stdout.write(`Warning: skipping '${g}' - resolved destination is outside the output directory
|
|
140
|
-
`),{count:0,path:null}):g===v?{count:0,path:null}:(await ae(H(v)),await it(g,v),{count:1,path:f})})),m=p.reduce((g,f)=>g+f.count,0),h=p.flatMap(g=>g.path===null?[]:[g.path]);return t.stdout.write(`Included ${m} file(s)
|
|
141
|
-
`),{filesCopied:m,outputPaths:h}}l();async function Ah(e,t){let{source:n,destination:i,baseDir:o,outputDir:r,appDirectory:a}=e,s=k(o,n);if(!await C(s))throw new Error(`Source does not exist: ${s}`);await xo(s,a,n);let c=await Dt(s),d,p;if(i===void 0?(d=k(r,$(s)),p=`Included ${n}
|
|
142
|
-
`):(d=k(r,i),p=`Included ${n}
|
|
143
|
-
`),c){let m=await re(["**/*"],{cwd:s,absolute:!1});await ta(s,d),t.stdout.write(p);let h=z(r,d),g=h?m.map(f=>k(h,f)):m;return{filesCopied:m.length,outputPaths:g}}return await ae(H(d)),await it(s,d),t.stdout.write(p),{filesCopied:1,outputPaths:[z(r,d)]}}var gC=u.object({type:u.literal("pattern"),baseDir:u.string().optional(),include:u.array(u.string()).default(["**/*"]),ignore:u.array(u.string()).optional(),destination:u.string().optional()}),yC=u.object({type:u.literal("static"),source:u.string(),destination:u.string().optional()}),vC=u.object({type:u.literal("configKey"),key:u.string(),destination:u.string().optional(),anchor:u.string().optional(),groupBy:u.string().optional(),preserveFilePaths:u.boolean().default(!1)}),kC=u.discriminatedUnion("type",[gC,yC,vC]),wC=u.object({inclusions:u.array(kC),generatesAssetsManifest:u.boolean().default(!1)}).strict().superRefine((e,t)=>{for(let[n,i]of e.inclusions.entries())if(i.type==="configKey"){let o=i.anchor!==void 0,r=i.groupBy!==void 0;o!==r&&t.addIssue({code:u.ZodIssueCode.custom,message:"`anchor` and `groupBy` must both be set or both be omitted",path:["inclusions",n]})}});async function Th(e,t){let n=wC.parse(e.config),{extension:i,options:o}=t,r=Cr(i.outputPath),a=o.app.directory,s=new Map,c=new Set,d=0;for(let g of n.inclusions){if(g.type!=="configKey")continue;let f=E=>o.stdout.write(E),v=g.destination?_l(g.destination,f):void 0,_=v===""?void 0:v,x=await Eh({key:g.key,baseDir:i.directory,outputDir:r,context:t,appDirectory:a,destination:_,usedBasenames:c,preserveFilePaths:g.preserveFilePaths});x.pathMap.forEach((E,A)=>s.set(A,E)),d+=x.filesCopied}let p=await Promise.all(n.inclusions.filter(g=>g.type!=="configKey").map(async g=>{let f=x=>o.stdout.write(x),v=g.destination?_l(g.destination,f):void 0,_=v===""?void 0:v;if(g.type==="pattern"){let x=g.baseDir?k(i.directory,g.baseDir):i.directory,E=_?k(r,_):r,A=await Nh({sourceDir:x,outputDir:E,patterns:g.include,ignore:g.ignore??[],appDirectory:a,sourceDirConfigValue:g.baseDir??"."},o),F=_?A.outputPaths.map(W=>k(_,W)):A.outputPaths;return{filesCopied:A.filesCopied,outputPaths:F}}if(g.type==="static")return Ah({source:g.source,destination:_,baseDir:i.directory,outputDir:r,appDirectory:a},o)})),m=n.generatesAssetsManifest?p.flatMap(g=>g?.outputPaths??[]):[],h=[d,...p.map(g=>g?.filesCopied??0)];if(n.generatesAssetsManifest){let g=n.inclusions.filter(f=>f.type==="configKey");await Ch(g,t,s,m)}return{filesCopied:h.reduce((g,f)=>g+(f??0),0)}}l();l();var Cn=O(_x(),1);function _C(e,t,n){let i=Cn.path.fsPath(e),a=ct(i).toString().split(`
|
|
144
|
-
`).slice(t,n+1),s=a.length===1;return a.map((c,d)=>{let p=t+d+1,m=s?c.trim():c;return`${p} ${m}`}).join(`
|
|
145
|
-
`)}function bC(e){switch(e){case Cn.Severity.ERROR:return{error:`
|
|
146
|
-
[error]:`};case Cn.Severity.WARNING:return{warn:`
|
|
147
|
-
[warning]:`};case Cn.Severity.INFO:return{info:`
|
|
148
|
-
[info]:`}}}function SC(e){return e.map((n,i)=>{let{message:o,uri:r,start:a,end:s,check:c,severity:d}=n,p=_C(r,a.line,s.line),m=i===e.length-1?"":`
|
|
149
|
-
|
|
150
|
-
`;return[bC(d),{bold:c},{subdued:`
|
|
151
|
-
${o}`},`
|
|
152
|
-
|
|
153
|
-
${p}`,m]}).flat()}async function Fh(e){let n=await(0,Cn.check)(e,"theme-check:theme-app-extension"),i=SC(n);return Ru(i)}async function Ph(e,t){let{extension:n,options:i}=t;i.stdout.write("Running theme check on your Theme app extension...");let o=await Fh(n.directory);o&&i.stdout.write(o)}l();async function Ih(e,t){let{extension:n,options:i}=t;i.stdout.write(`Bundling theme extension ${n.localIdentifier}...`);let o=await En(n);return await Promise.all(o.map(async r=>{let a=z(n.directory,r),s=k(n.outputPath,a);r!==s&&await it(r,s)})),{filesCopied:o.length}}l();async function Dh(e,t){let n=t.extension.configuration;t.options.buildDirectory=e.config?.bundleFolder??void 0;let i=await bh(t.extension,t.options),o=H(i),r=e.config?.bundleFolder?k(H(t.extension.outputPath),e.config.bundleFolder):H(t.extension.outputPath);if(he(o)===he(r)||(await it(o,r),!e.config?.generatesAssetsManifest)||!Array.isArray(n.extension_points))return;let a=n.extension_points.filter(c=>typeof c=="object"&&c.build_manifest),s=xC(a,e.config?.bundleFolder);Object.keys(s).length>0&&await _c(t,s)}function xC(e,t){let n={};for(let{target:i,build_manifest:o}of e){if(!o?.assets)continue;let r={};for(let[a,s]of Object.entries(o.assets))s?.filepath&&(r[a]=t?k(t,s.filepath):s.filepath);Object.keys(r).length>0&&(n[i]=r)}return n}l();async function Rh(e,t){return Ha(t.extension,t.options)}l();async function Uh(e,t){let{extension:n}=t;if(await C(n.outputPath)&&await Dt(n.outputPath))throw new Error(`outputPath '${n.outputPath}' is a directory \u2014 expected a file path for the tax stub`);await pn(n.outputPath),await ie(n.outputPath,"(()=>{})();")}async function Oh(e,t){switch(e.type){case"include_assets":return Th(e,t);case"build_theme":return Ph(e,t);case"bundle_theme":return Ih(e,t);case"bundle_ui":return Dh(e,t);case"build_function":return Rh(e,t);case"create_tax_stub":return Uh(e,t);default:throw new Error(`Unknown build step type: ${e.type}`)}}async function Mh(e,t){let n=Date.now();try{let i=await Oh(e,t);return{id:e.id,success:!0,duration:Date.now()-n,output:i}}catch(i){let o=i;if(e.continueOnError)return t.options.stderr.write(`Warning: Step "${e.name}" failed but continuing: ${o.message}
|
|
154
|
-
`),{id:e.id,success:!1,duration:Date.now()-n,error:o};throw o.message=`Build step "${e.name}" failed: ${o.message}`,o}}var EC=["**/node_modules/**","**/.git/**","**/*.test.*","**/dist/**","**/*.swp","**/generated/**","**/.gitignore"],Ya=class{get graphQLType(){return(this.specification.graphQLType??this.specification.identifier).toUpperCase()}get type(){return this.specification.identifier}get humanName(){return this.specification.externalName}get name(){return this.configuration.name??this.specification.externalName}get dependency(){return this.specification.dependency}get externalType(){return this.specification.externalIdentifier}get surface(){return this.specification.surface}get isPreviewable(){return this.features.includes("ui_preview")}get isThemeExtension(){return this.features.includes("theme")}get isFunctionExtension(){return this.features.includes("function")}get isESBuildExtension(){return this.features.includes("esbuild")}get isSourceMapGeneratingExtension(){return this.features.includes("generates_source_maps")}get isAppConfigExtension(){return this.specification.experience==="configuration"}get isFlow(){return this.specification.identifier.includes("flow")}get isEditorExtensionCollection(){return this.specification.identifier==="editor_extension_collection"}get hasDeploySteps(){return this.specification.clientSteps?.some(t=>t.lifecycle==="deploy"&&t.steps.length>0)??!1}get features(){return this.specification.appModuleFeatures(this.configuration)}get outputFileName(){return $(this.outputRelativePath)}get outputRelativePath(){return this.specification.getOutputRelativePath?.(this)??""}constructor(t){this.configuration=t.configuration,this.configurationPath=t.configurationPath,this.entrySourceFilePath=t.entryPath??"",this.directory=t.directory,this.specification=t.specification,this.handle=this.buildHandle(),this.localIdentifier=this.handle,this.idEnvironmentVariableName=`SHOPIFY_${Xr(this.localIdentifier)}_ID`,this.outputPath=k(this.directory,this.outputRelativePath),this.uid=this.buildUIDFromStrategy(),this.devUUID=`dev-${this.uid}`}get draftMessages(){if(this.isAppConfigExtension)return{successMessage:void 0,errorMessage:void 0};let t=`Draft updated successfully for extension: ${this.localIdentifier}`,n=`Error updating extension draft for ${this.localIdentifier}`;return{successMessage:t,errorMessage:n}}get isUUIDStrategyExtension(){return this.specification.uidStrategy==="uuid"}get isSingleStrategyExtension(){return this.specification.uidStrategy==="single"}get isDynamicStrategyExtension(){return this.specification.uidStrategy==="dynamic"}get outputPrefix(){return this.handle}isSentToMetrics(){return!this.isAppConfigExtension}isReturnedAsInfo(){return!this.isAppConfigExtension}async deployConfig({apiKey:t,appConfiguration:n}){let i=await this.specification.deployConfig?.(this.configuration,this.directory,t,void 0),o=this.specification.transformLocalToRemote?.(this.configuration,n),r=i??o??void 0;return r&&Object.keys(r).length>0?r:void 0}validate(){return this.specification.validate?this.specification.validate(this.configuration,this.configurationPath,this.directory):Promise.resolve(Wt(void 0))}preDeployValidation(){return this.specification.preDeployValidation?this.specification.preDeployValidation(this):Promise.resolve()}buildValidation({outputPath:t}){return this.specification.buildValidation?this.specification.buildValidation(this,t):Promise.resolve()}async keepBuiltSourcemapsLocally(t){if(!this.isSourceMapGeneratingExtension)return Promise.resolve();let i=(await re(`**/${this.handle}.js.map`,{cwd:t,absolute:!0,followSymbolicLinks:!1}))[0];if(i===void 0)return Promise.resolve();let o=k(this.directory,z(t,i));await dn(i,o,{overwrite:!0}),S(`Source map for ${this.localIdentifier} created: ${o}`)}async publishURL(t){let n=await fi(),i=this.specification.partnersWebIdentifier;return`https://${n}/${t.orgId}/apps/${t.appId}/extensions/${i}/${t.extensionId}`}getOutputFolderId(t){return t??this.uid}getBundleExtensionStdinContent(){return this.specification.getBundleExtensionStdinContent?this.specification.getBundleExtensionStdinContent(this.configuration):{main:`import '.${this.entrySourceFilePath.replace(this.directory,"")}';`}}shouldFetchCartUrl(){return this.features.includes("cart_url")}hasExtensionPointTarget(t){return this.specification.hasExtensionPointTarget?.(this.configuration,t)??!1}get buildCommand(){return this.configuration.build?.command}get typegenCommand(){return this.configuration.build?.typegen_command}devSessionDefaultWatchPaths(){if(this.specification.identifier==="ui_extension"){let{main:t,assets:n}=this.getBundleExtensionStdinContent(),i=zl(t,this.directory),o=n?.flatMap(r=>zl(r.content,this.directory))??[];return i.concat(...o)}return[this.entrySourceFilePath]}get devSessionWatchConfig(){return this.specification.devSessionWatchConfig?this.specification.devSessionWatchConfig(this):this.isAppConfigExtension?{paths:[]}:void 0}async watchConfigurationPaths(){if(this.isAppConfigExtension)return[this.configurationPath];{let t=[];return await C(k(this.directory,"locales"))&&t.push(k(this.directory,"locales","**.json")),t.push(k(this.directory,"**.toml")),t}}get inputQueryPath(){return k(this.directory,"input.graphql")}get isJavaScript(){return!!(this.entrySourceFilePath.endsWith(".js")||this.entrySourceFilePath.endsWith(".ts"))}async build(t){let{clientSteps:n=[]}=this.specification,i={extension:this,options:t,stepResults:new Map},o=n.find(r=>r.lifecycle==="deploy")?.steps??[];for(let r of o){let a=await Mh(r,i);i.stepResults.set(r.id,a)}}async buildForBundle(t,n,i){this.outputPath=this.getOutputPathForDirectory(n,i),await this.build(t);let o=k(n,this.getOutputFolderId(i));await this.keepBuiltSourcemapsLocally(o)}async copyIntoBundle(t,n,i){let o=this.outputPath;this.outputPath=this.getOutputPathForDirectory(n,i),this.isThemeExtension?await vh(this,t):this.hasDeploySteps&&(S(`Will copy pre-built file from ${o} to ${this.outputPath}`),await C(o)&&(await it(o,this.outputPath),this.isFunctionExtension&&await yc(this.outputPath,this.outputPath)))}getOutputPathForDirectory(t,n){let i=this.getOutputFolderId(n);return k(t,i,this.outputRelativePath)}get singleTarget(){let t=Oe(this.configuration,"targeting")??[];if(t.length===1)return t[0]?.target}get contextValue(){let t=this.singleTarget??"";return this.isFlow&&(t=this.configuration.handle??""),t}async bundleConfig({identifiers:t,developerPlatformClient:n,apiKey:i,appConfiguration:o}){let r=await this.deployConfig({apiKey:i,appConfiguration:o});if(!r)return;let a={config:JSON.stringify(r),context:this.contextValue,handle:this.handle},s=this.isUUIDStrategyExtension?t.extensions[this.localIdentifier]:t.extensionsNonUuidManaged[this.localIdentifier];return{...a,uid:this.uid,uuid:s,specificationIdentifier:n.toExtensionGraphQLType(this.graphQLType)}}async getDevSessionUpdateMessages(){if(this.specification.getDevSessionUpdateMessages)return this.specification.getDevSessionUpdateMessages(this.configuration)}patchWithAppDevURLs(t){this.specification.patchWithAppDevURLs&&this.specification.patchWithAppDevURLs(this.configuration,t)}async contributeToSharedTypeFile(t){await this.specification.contributeToSharedTypeFile?.(this,t)}watchPatterns(){let t=this.devSessionWatchConfig;return{paths:t?.paths??["**/*"],ignore:t?.ignore??EC}}watchedFiles(){let t=[],{paths:n,ignore:i}=this.watchPatterns(),o=n.flatMap(r=>Md(r,{cwd:this.directory,absolute:!0,followSymbolicLinks:!1,ignore:i}));if(t.push(...o.flat()),!this.devSessionWatchConfig){let r=this.scanImports();t.push(...r)}return[...new Set(t.map(r=>Ne(r)))]}async rescanImports(){let t=this.cachedImportPaths;return this.cachedImportPaths=void 0,Pm(),this.scanImports(),t!==this.cachedImportPaths}scanImports(){if(this.cachedImportPaths!==void 0)return this.cachedImportPaths;if(Bt(process.env.SHOPIFY_CLI_DISABLE_IMPORT_SCANNING))return this.cachedImportPaths=[],this.cachedImportPaths;try{let t=performance.now(),n=this.devSessionDefaultWatchPaths(),i=n.flatMap(s=>Im(s).map(c=>Ne(he(c))));this.cachedImportPaths=Jr(i)??[];let o=Math.round(performance.now()-t),r=Dm(),a=r?` (cache: ${r.directImports} parsed, ${r.fileExists} stats)`:"";return S(`Import scan for "${this.handle}": ${n.length} entries, ${this.cachedImportPaths.length} files, ${o}ms${a}`),this.cachedImportPaths}catch(t){return S(`Failed to scan imports for extension ${this.handle}: ${t}`),this.cachedImportPaths=[],this.cachedImportPaths}}buildHandle(){switch(this.specification.uidStrategy){case"single":return this.specification.identifier;case"uuid":return this.configuration.handle??te(this.name??"");case"dynamic":if("topic"in this.configuration&&"uri"in this.configuration){let t=this.configuration,n=`${t.topic}${t.uri}${t.filter}`;return ut(n).substring(0,Ee)}else return yn(JSON.stringify(this.configuration))}}buildUIDFromStrategy(){switch(this.specification.uidStrategy){case"single":return this.specification.identifier;case"uuid":return this.configuration.uid??yn(this.handle);case"dynamic":if("topic"in this.configuration&&"uri"in this.configuration){let t=this.configuration;return`${t.topic}::${t.filter}::${t.uri}`.substring(0,qa)}else return yn(JSON.stringify(this.configuration))}}};l();async function Lh(e,t=""){let n=CC(t),i=await Gt(n);for(;await C(k(e,Qa(i)))&&await De({message:`Configuration file ${Qa(i)} already exists. Do you want to choose a different configuration name?`,confirmationMessage:"Yes, I'll choose a different name",cancellationMessage:"No, overwrite my existing configuration file"});)i=await Gt(n);return Qa(i)}function Qa(e,t=!1){let n=te(e);return n===""?"shopify.app.toml":`shopify.app.${t?ve.cyan(n):n}.toml`}async function bc(e){return re(k(e,"shopify.app*.toml"))}async function $h(e){let t=(await bc(e)).map(i=>$(i));if(t.length===0)return hi("Could not find any shopify.app.toml file in the directory.");if(t.length===1)return Wt(t[0]);let n=await Je({message:"Configuration file",choices:t.map(i=>({label:i,value:i}))});return Wt(n)}function CC(e){return{message:"Configuration file name:",initialAnswer:e,validate:NC,preview:t=>`${Qa(t,!0)} will be generated in your root directory`}}function NC(e){if(te(e).length>238)return"The file name is too long."}l();l();var AC=/^(https:\/\/)/,TC=/^pubsub:\/\/(?<gcp_project_id>[^:]+):(?<gcp_topic>.+)$/,FC=/^arn:aws:events:(?<aws_region>[a-z]{2}-[a-z]+-[0-9]+)::event-source\/aws\.partner\/shopify\.com(\.test)?\/(?<api_client_id>\d+)\/(?<event_source_name>.+)$/;function et(e){return typeof e=="string"&&e.endsWith("/")?e.replace(/\/+$/,""):e}var Nn=u.string({invalid_type_error:"Value must be string"}).refine(e=>e.startsWith("/")?!0:AC.test(e)||TC.test(e)||FC.test(e),{message:"URI format isn't correct. Valid formats include: relative path starting with a slash, HTTPS URL, pubsub://{project-id}:{topic-id} or Eventbridge ARN"});l();function An(e,t){return!t||!e.startsWith("/")?e:`${et(t)}${e}`}var Eo="webhook_subscription",PC=u.object({topic:u.string(),actions:u.array(u.string({invalid_type_error:"Value must be a string"})).optional(),api_version:u.string(),uri:u.preprocess(et,Nn,{required_error:"Missing value at"}),include_fields:u.array(u.string({invalid_type_error:"Value must be a string"})).optional(),filter:u.string({invalid_type_error:"Value must be a string"}).optional(),payload_query:u.string({invalid_type_error:"Value must be a string"}).trim().min(1).optional(),name:u.string({invalid_type_error:"Value must be a string"}).trim().min(1).max(50).optional()});function IC(e){let{api_version:t,topic:n,...i}=e;return{webhooks:{subscriptions:[{topics:[n],...i}]}}}var DC={forward:(e,t)=>{let n=e,i;return"application_url"in t&&(i=t?.application_url),{...n,uri:An(n.uri,i)}},reverse:IC},RC=$e({identifier:Eo,schema:PC,transformConfig:DC,uidStrategy:"dynamic"}),Vh=RC;l();l();var nn;(function(e){e.CustomersRedact="customers/redact",e.CustomersDataRequest="customers/data_request",e.ShopRedact="shop/redact"})(nn||(nn={}));var qh=u.object({topics:u.array(u.string({invalid_type_error:"Values within array must be a string"}),{invalid_type_error:"Value must be string[]"}).optional(),actions:u.array(u.string({invalid_type_error:"Value must be a string"})).optional(),uri:u.preprocess(e=>et(e),Nn,{required_error:"Missing value at"}),include_fields:u.array(u.string({invalid_type_error:"Value must be a string"})).optional(),filter:u.string({invalid_type_error:"Value must be a string"}).optional(),payload_query:u.string({invalid_type_error:"Value must be a string"}).trim().min(1).optional(),name:u.string({invalid_type_error:"Value must be a string"}).trim().min(1).max(50).optional(),compliance_topics:u.array(u.enum([nn.CustomersRedact,nn.CustomersDataRequest,nn.ShopRedact]),{invalid_type_error:"Value must be an array containing values: customers/redact, customers/data_request or shop/redact"}).optional()});l();function jh(e,t){let n=UC(e);if(n)return t.addIssue(n),u.NEVER}function UC(e){let{subscriptions:t=[]}=e,n=new Set,i=[];if(!t.length)return;if(e.privacy_compliance&&e.subscriptions?.some(r=>r.compliance_topics))return{code:u.ZodIssueCode.custom,message:"The privacy_compliance section can't be used if there are subscriptions including compliance_topics"};let o=t.flatMap(r=>r.compliance_topics).filter(Boolean);if(Jr(o).length!==o.length)return{code:u.ZodIssueCode.custom,message:"You can\u2019t have multiple subscriptions with the same compliance topic",fatal:!0,path:["subscriptions"]};for(let[r,{uri:a,topics:s=[],compliance_topics:c=[],filter:d=""}]of t.entries()){let p=["subscriptions",r];if(!s.length&&!c.length)return{code:u.ZodIssueCode.custom,message:"Either topics or compliance_topics must be added to the webhook subscription",path:p};s.forEach(m=>{let h=`${m}::${a}::${d}`;if(n.has(h)){let g=d?ve.dim(`
|
|
155
|
-
|
|
156
|
-
topic: ${m}
|
|
157
|
-
uri: ${a}
|
|
158
|
-
filter: ${d}`):ve.dim(`
|
|
159
|
-
|
|
160
|
-
topic: ${m}
|
|
161
|
-
uri: ${a}`);i.push(g)}n.add(h)})}if(i.length>0){let r=i.join("");return{code:u.ZodIssueCode.custom,message:`Multiple subscriptions with the exact same topic, uri, and filter. To resolve, remove or edit the duplicates ${r}`,path:["subscriptions"]}}}l();function zh(e){let t=Oe(e,"webhooks");if(!t)return e;let{api_version:n}=t;return{api_version:n}}function Wh(e){let t={},n=Oe(e,"api_version");return t={...n?{webhooks:{api_version:n}}:{}},t}function Ja(e){if(e.length===0)return;let t=e.filter(r=>r.topics!==void 0).flatMap(({compliance_topics:r,topics:a,...s})=>Hh(a)?.map(d=>({topics:[d],...s}))??[]),n=e.filter(r=>r.topics===void 0||r.compliance_topics!==void 0).map(({compliance_topics:r,topics:a,...s})=>({compliance_topics:r,...s})),i=Sc(n,"compliance_topics"),o=OC(i);return[...Bh(o),...Bh(t)]}function Hh(e){return e?.sort((t,n)=>t.localeCompare(n))}function Bh(e){return e.sort((t,n)=>t.uri.localeCompare(n.uri))}function OC(e){return e.forEach(t=>t.compliance_topics=Hh(t.compliance_topics)),e}function MC(e,t){return e.find(n=>n.uri===t.uri&&kn(n.include_fields??[],t.include_fields??[])&&n.filter===t.filter)}function Sc(e,t){return e.reduce((n,i)=>{let o=MC(n,i);return o?t&&i?.[t]?.length?o[t]?.push(...i[t]):(i.topics&&(o.topics??(o.topics=[]),o.topics.push(...i.topics)),i.compliance_topics&&(o.compliance_topics??(o.compliance_topics=[]),o.compliance_topics.push(...i.compliance_topics))):n.push(i),n},[])}var LC=u.object({api_version:u.string({required_error:"String is required"}),privacy_compliance:u.object({customer_deletion_url:Nn.optional(),customer_data_request_url:Nn.optional(),shop_deletion_url:Nn.optional()}).optional(),subscriptions:u.array(qh).optional().transform(e=>Ja(e??[]))}),Co=at.extend({webhooks:LC.superRefine(jh)});l();l();var xc;function Cc(){return xc??(xc=new Ht({projectName:"shopify-cli-app"})),xc}function Ni(e,t=Cc()){let n=Ne(e);return S(w`Reading cached app information for directory ${b.path(n)}...`),t.get(n)}function Tn(e,t=Cc()){e.directory=Ne(e.directory),S(w`Storing app information for directory ${b.path(e.directory)}:${b.json(e)}`);let n=t.get(e.directory);n?t.set(e.directory,{...n,...e}):t.set(e.directory,e)}function Gh(e,t=Cc()){let n=Ne(e),i=t.get(n);i&&t.set(n,{...i,configFile:void 0})}var Ec;function Nc(){return Ec??(Ec=new Ht({projectName:"shopify-cli-app-command"})),Ec}function Kh(e){let t=process.env.COMMAND_RUN_ID;if(!t)return;let n=Nc(),i=n.get(t);n.set(t,{...i,...e})}function Xa(){let e=process.env.COMMAND_RUN_ID;return e?Nc().get(e):void 0}function Yh(){Nc().clear()}function Qh(e){Kh({tomls:e})}function Jh(e){Kh({selectedToml:e})}async function Xh(e){if(e.noTunnelUseLocalhost)return{frontendUrl:"https://localhost",frontendPort:e.port,usingLocalhost:!0};let t=4040,n="",i=e.noTunnelUseLocalhost;if(Vl())return n=`https://${Vl()}-${t}.${Du()}`,{frontendUrl:n,frontendPort:t,usingLocalhost:i};if($l()){let o=$l()?.replace("https://","");return n=`https://${t}-${o}`,{frontendUrl:n,frontendPort:t,usingLocalhost:i}}if(e.tunnelUrl){let o=e.tunnelUrl.match(/(https:\/\/[^:]+):([0-9]+)/);if(!o)throw new y(`Invalid tunnel URL: ${e.tunnelUrl}`,'Valid format: "https://my-tunnel-url:port"');return t=Number(o[2]),n=o[1],{frontendUrl:n,frontendPort:t,usingLocalhost:i}}return e.tunnelClient&&(t=e.tunnelClient.port,n=await $C(e.tunnelClient)),{frontendUrl:n,frontendPort:t,usingLocalhost:i}}async function $C(e){return new Promise((t,n)=>{let i=0,o=async()=>{let a=e.getTunnelStatus();if(S(`Polling tunnel status for ${e.provider} (attempt ${i}): ${a.status}`),a.status==="error")return n(new y(a.message,a.tryMessage));a.status==="connected"?t(a.url):(i+=1,r())},r=()=>{setTimeout(o,500)};o()})}function Za(e,t,n){let i;t&&t.length>0?i=(Array.isArray(t)?t:[t]).reduce((a,s)=>(s&&s.length>0&&a.push(`${e}${s}`),a),[]):i=[`${e}/auth/callback`,`${e}/auth/shopify/callback`,`${e}/api/auth/callback`];let o=n?{appProxy:{proxyUrl:VC(An(n.url,e),e),proxySubPath:n.subpath,proxySubPathPrefix:n.prefix}}:{};return{applicationUrl:e,redirectUrlWhitelist:i,...o}}function VC(e,t){let n=new URL(e),i=new URL(t);return n.host=i.host,n.toString().replace(/\/$/,"")}async function Zh(e,t,n,i){let o={apiKey:t,...e},r=await n.updateURLs(o);if(r.appUpdate.userErrors.length>0){let a=r.appUpdate.userErrors.map(s=>s.message).join(", ");throw new y(a)}if(i&&i.configuration.client_id===t){let a=await _e.read(i.configPath),s={application_url:e.applicationUrl,auth:{redirect_urls:e.redirectUrlWhitelist}};e.appProxy&&(s.app_proxy={url:e.appProxy.proxyUrl,subpath:e.appProxy.proxySubPath,prefix:e.appProxy.proxySubPathPrefix}),await a.patch(s)}}async function eg(e){let t={applicationUrl:e?.application_url??"",redirectUrlWhitelist:e?.auth?.redirect_urls??[]};return e?.app_proxy&&(t.appProxy={proxyUrl:e?.app_proxy.url,proxySubPath:e?.app_proxy.subpath,proxySubPathPrefix:e?.app_proxy.prefix}),t}async function tg(e){if(e.localApp&&e.localApp.configuration.client_id!==e.apiKey||(e.newApp??!fa()))return!0;let t=e.cachedUpdateURLs===!0;if(e.cachedUpdateURLs===void 0)if(t=await ig(e.developerPlatformClient.supportsDevSessions,e.currentURLs.applicationUrl,e.currentURLs.redirectUrlWhitelist,e.newURLs),e.localApp){let n=e.localApp.configuration;n.build={...n.build,automatically_update_urls_on_dev:t},await(await _e.read(e.localApp.configPath)).patch({build:{automatically_update_urls_on_dev:t}})}else Tn({directory:e.appDirectory,updateURLs:t});return t}async function ng(e,t,n){let i=await Yd(e,"tunnel_start",{port:t,provider:n}),o=Object.values(i).filter(a=>!a?.isErr()||a.error.type!=="invalid-provider");if(o.length>1)throw new L(`Multiple tunnel plugins for ${n} found`);let r=o[0];if(!r)throw new L(`We couldn't find the ${n} tunnel plugin`);if(r.isErr())throw new y(`${n} failed to start the tunnel.
|
|
162
|
-
${r.error.message}`,["What to try:",{list:{items:[["Try to run the command again"],["Add the flag",{command:"--tunnel-url {URL}"},"to use a custom tunnel URL"]]}}]);return r.value}l();var og="shopify.app*.toml",qC=/^shopify\.app(\.[-\w]+)?\.toml$/,jC="*.extension.toml",BC="shopify.web.toml",rg="extensions/*",ag="**/node_modules/**",zC=".env*",Ai=class e{static async load(t){let n=await WC(t),i=[],o=await HC(n,i);if(o.length===0)throw new y(`Could not find a Shopify app TOML file in ${n}`);let r=new Set;for(let _ of o){let x=_.content.extension_directories;if(Array.isArray(x))for(let E of x)r.add(E);else r.add(rg)}let a=await GC(n,[...r],i),s=new Set;for(let _ of o){let x=_.content.web_directories;if(Array.isArray(x))for(let E of x)s.add(E)}let c=await KC(n,s.size>0?[...s]:void 0,i),d=k(n,"package.json"),p=await C(d),m=p?await la(n):"unknown",h=p?await lu(d):{},g=p?await cu(n):!1,f=await YC(n),v=await QC(n);return new e({directory:n,packageManager:m,nodeDependencies:h,usesWorkspaces:g,appConfigFiles:o,extensionConfigFiles:a,webConfigFiles:c,dotenvFiles:f,hiddenConfigRaw:v,errors:i})}constructor(t){this.directory=t.directory,this.packageManager=t.packageManager,this.nodeDependencies=t.nodeDependencies,this.usesWorkspaces=t.usesWorkspaces,this.appConfigFiles=t.appConfigFiles,this.extensionConfigFiles=t.extensionConfigFiles,this.webConfigFiles=t.webConfigFiles,this.dotenvFiles=t.dotenvFiles,this.hiddenConfigRaw=t.hiddenConfigRaw,this.errors=t.errors}appConfigByName(t){return this.appConfigFiles.find(n=>$(n.path)===t)}appConfigByClientId(t){return this.appConfigFiles.find(n=>n.content.client_id===t)}get defaultAppConfig(){return this.appConfigByName(me.app)}};async function WC(e){let t=await qe(async n=>{if((await re(k(n,og))).length>0)return n},{cwd:e,type:"directory"});if(!t)throw new y(`Could not find a Shopify app configuration file. Looked in ${e} and parent directories.`);return t}async function HC(e,t){let n=k(e,og),o=(await re(n)).filter(r=>qC.test($(r)));return Ac(o,t)}async function GC(e,t,n){let o=(t.length>0?t:[rg]).map(a=>k(e,a,jC));o.push(`!${k(e,ag)}`);let r=await re(o);return Ac(r,n)}async function KC(e,t,n){let o=(t??["**"]).map(a=>k(e,a,BC));o.push(`!${k(e,ag)}`);let r=await re(o);return Ac(r,n)}async function Ac(e,t){let n=[];return await Promise.all(e.map(async i=>{try{n.push(await _e.read(i))}catch(o){let r=o instanceof lr?o:new lr(i,`Failed to read ${i}`),a=new _e(i,{});a.errors.push(r),n.push(a),t.push(r)}})),n}async function YC(e){let t=k(e,zC),i=(await re(t,{dot:!0})).filter(a=>{let s=$(a);return s===".env"||/^\.env\.[\w-]+$/.test(s)}),o=await Promise.all(i.map(async a=>{try{let s=await Cm(a);return[$(a),s]}catch{return}})),r=new Map;for(let a of o)a&&r.set(a[0],a[1]);return r}async function QC(e){let t=k(e,me.hiddenFolder,me.hiddenConfig);try{if(await C(t)){let n=await P(t);return JSON.parse(n)}}catch{}return{}}l();l();l();var JC="project.json";async function Tc(e){let t=await ym(e),n=k(t,JC);return await C(n)||await ie(n,JSON.stringify({})),n}function es(e,t){let n=Er(t);if(n){let i=`${ko.production}.${n}`;return e.dotenvFiles.get(i)}return e.dotenvFiles.get(ko.production)}async function ts(e,t){if(!t||typeof t!="string")return{};await Tc(e.directory);let n=e.hiddenConfigRaw,i=n[t];if(i&&typeof i=="object")return i;if(typeof n.dev_store_url=="string"){try{let o=await Tc(e.directory);await ja(o,t,{dev_store_url:n.dev_store_url})}catch{}return{dev_store_url:n.dev_store_url}}return{}}function sg(e,t){let n=t.content.extension_directories,o=(Array.isArray(n)&&n.length>0?n:["extensions/*"]).map(r=>`${r}/*.extension.toml`);return e.extensionConfigFiles.filter(r=>{let a=z(e.directory,r.path).replace(/\\/g,"/");return o.some(s=>un(a,s))})}function Fc(e,t){let n=t.content.web_directories;if(!Array.isArray(n)||n.length===0)return e.webConfigFiles;let i=n.map(o=>`${o}/shopify.web.toml`);return e.webConfigFiles.filter(o=>{let r=z(e.directory,o.path).replace(/\\/g,"/");return i.some(a=>un(r,a))})}function lg(e,t){let n=t.content.extension_directories,i=(Array.isArray(n)&&n.length>0?n:["extensions/*"]).map(s=>`${s}/*.extension.toml`),o=t.content.web_directories,r=Array.isArray(o)&&o.length>0?o.map(s=>`${s}/shopify.web.toml`):["**/shopify.web.toml"],a=[...i,...r];return e.errors.filter(s=>{if(s.path===t.path)return!0;let c=z(e.directory,s.path).replace(/\\/g,"/");return a.some(d=>un(c,d))})}l();async function Nr({directory:e,configName:t,warningContent:n,shouldRenderSuccess:i=!0,reset:o=!1}){if(o){Gh(e);let s=await la(e);j({headline:"Cleared current configuration.",body:["In order to set a new current configuration, please run",{command:Be(s,"shopify app config use CONFIG_NAME")},{char:"."}]});return}n&&He(n);let r=(await XC(e,t)).valueOrAbort(),{activeConfig:a}=await Tt(e,r);return Pc(a.file.content,{configFileName:r,directory:e}),i&&j({headline:`Using configuration file ${r}`}),r}function Pc(e,t){let{configFileName:n,directory:i}=t;if(e.client_id)Tn({directory:i,configFile:n});else throw new y(`Configuration file ${n} needs a client_id.`)}async function XC(e,t){if(t){let n=dt(t);return await C(k(e,n))?Wt(n):hi(`Could not find configuration file ${n}`)}return $h(e)}async function ns(e,t,n){let i=t,o=Ni(e.directory)?.configFile,r=o?k(e.directory,o):null,a=!!(!i&&r&&!Se(r));if(a&&!n?.skipPrompts){let p={headline:`Couldn't find ${o}`,body:["If you have multiple config files, select a new one. If you only have one config file, it's been selected as your default."]};i=await Nr({directory:e.directory,warningContent:p,shouldRenderSuccess:!1})}i=i??(a?void 0:o);let s;t?s="flag":i?s="cached":s="default";let c=dt(i),d=e.appConfigByName(c);if(!d)throw new y(w`Couldn't find ${c} in ${b.path(e.directory)}.`);return ZC(e,d,s)}async function ZC(e,t,n){let i=typeof t.content.client_id=="string"?t.content.client_id:void 0,o=!!i&&i!=="",r=es(e,t.path),a=await ts(e,i);return{file:t,source:n,isLinked:o,dotenv:r,hiddenConfig:a}}var pg=O(vm(),1);function Ti(e){return e.path?.length?`[${e.path.join(".")}]: ${e.message}`:e.message}async function Dc(e,t,n){let i=n;if(!i)try{i=(await _e.read(t)).content}catch(o){if(o instanceof lr)return{errors:[{file:t,message:o.message}]};throw o}return dg(e,t,i)}function dg(e,t,n){let i=e.safeParse(n);return i.success?{data:i.data}:{errors:uh(i.error.issues).map(o=>({file:t,message:o.message,path:o.path,code:o.code}))}}function cg(e,t,n){let i=e.parseConfigurationObject(n);switch(i.state){case"ok":return{data:i.data};case"error":return{errors:i.errors.map(o=>({file:t,message:o.message??"Unknown error",path:o.path}))}}}var xr=class{constructor(){this.errors=[]}addError(t){this.errors.push(t)}addErrors(t){this.errors.push(...t)}getErrors(t){return t?this.errors.filter(n=>n.file===t):[...this.errors]}isEmpty(){return this.errors.length===0}};async function Ut(e){if(!((await bc(e)).length>0))throw new y(w`Couldn't find an app toml file at ${b.path(e)}, is this an app directory?`)}async function ug(e,t){let{project:n,activeConfig:i}=await Tt(e),o=i.file.content,r=Fc(n,i.file),a=await Promise.all(r.map(m=>mg(m.path,m.content))),s=a.flatMap(m=>m.errors??[]);if(s.length>0)throw new y(s.map(Ti).join(`
|
|
163
|
-
`));let d=a.filter(m=>"web"in m).map(m=>m.web).some(m=>Ye(m,fe.Frontend)||Ye(m,fe.Backend)),p=So(o);return{isLaunchable:d,scopesArray:p,name:t,directory:n.directory,isEmbedded:d}}async function mg(e,t){let n=await Dc(ch,e,t);if(n.errors)return{errors:n.errors};let i=n.data,o=new Set("roles"in i?i.roles:[]);"type"in i&&o.add(i.type);let{type:r,...a}={...i,roles:Array.from(o),type:void 0};return{web:{directory:H(e),configuration:a,framework:await Um(H(e))}}}async function fg(e){let{project:t,activeConfig:n}=await Tt(e.directory,e.userProvidedConfigName,e.skipPrompts?{skipPrompts:!0}:void 0);return No({project:t,activeConfig:n,specifications:e.specifications,remoteFlags:e.remoteFlags,ignoreUnknownExtensions:e.ignoreUnknownExtensions})}async function No(e){let{project:t,activeConfig:n,specifications:i,remoteFlags:o=[],ignoreUnknownExtensions:r,reloadState:a,clientIdOverride:s}=e,c={...n.file.content};s&&(c.client_id=s);let p=lh(i),m=n.file.path,h=$(m),g=await Dc(p,m,c);if(g.errors){let F=g.errors.map(Ti).join(`
|
|
164
|
-
`);throw new y(`Validation errors in ${m}:
|
|
165
|
-
|
|
166
|
-
${F}`)}let f=g.data,v=iN(t.appConfigFiles,{[h]:f.client_id}),_=!1;try{_=await tN(t.directory,m)}catch{}let x={allClientIdsByConfigName:v,usesLinkedConfig:!0,name:h,gitTracked:_,source:n.source,usesCliManagedUrls:f.build?.automatically_update_urls_on_dev},E={directory:t.directory,configPath:m,configuration:f,configurationLoadResultMetadata:x,configSchema:p,specifications:i,remoteFlags:o};return new Ic({ignoreUnknownExtensions:r,loadedConfiguration:E,project:t,reloadState:a}).loaded()}function eN(e){return e.access_scopes?.scopes??""}async function hg(e){try{let{project:t,activeConfig:n}=await Tt(e.directory,e.configName,e.skipPrompts?{skipPrompts:!0}:void 0),i=await No({project:t,activeConfig:n,specifications:e.specifications,remoteFlags:e.remoteFlags});return{state:"loaded-app",app:i,configuration:i.configuration,packageManager:t.packageManager}}catch{try{let t=await Ai.load(e.directory),{configurationPath:n}=await nN(t.directory,e.configName),o=(await _e.read(n)).content;return{state:"loaded-template",rawConfig:o,scopes:eN(o),appDirectory:t.directory,packageManager:t.packageManager}}catch{return{state:"error"}}}}async function on(e){let{project:t,activeConfig:n}=await Tt(e.directory,$(e.configPath)),i={extensionDevUUIDs:new Map(e.allExtensions.map(r=>[r.handle,r.devUUID])),previousDevURLs:e.devApplicationURLs},o=await No({project:t,activeConfig:n,specifications:e.specifications,remoteFlags:e.remoteFlags??[],reloadState:i});if(!o.errors.isEmpty()){let r=o.errors.getErrors();throw new y(w`${b.errorText("Validation errors")}:\n\n${r.map(Ti).join(`
|
|
167
|
-
`)}`)}return o}function is(e){let t=Er(e);return t?`${ko.production}.${t}`:ko.production}var Ic=class{constructor({ignoreUnknownExtensions:t,loadedConfiguration:n,reloadState:i,project:o}){this.errors=new xr,this.ignoreUnknownExtensions=t??!1,this.specifications=n.specifications,this.remoteFlags=n.remoteFlags,this.loadedConfiguration=n,this.reloadState=i,this.project=o}get activeConfigFile(){let t=this.loadedConfiguration.configPath;return this.project.appConfigFiles.find(n=>n.path===t)}async loaded(){let{configuration:t,directory:n,configPath:i,configurationLoadResultMetadata:o,configSchema:r}=this.loadedConfiguration;await sN(o);let a=es(this.project,i),s=await this.loadExtensions(n,t),c=t.name,p=t.handle??c??"",m=await ts(this.project,t.client_id);this.reloadState||await Rm(n,this.project.nodeDependencies);let{webs:h,usedCustomLayout:g}=await this.loadWebs(n,t.web_directories),f=new Ba({name:p,directory:n,configPath:i,configuration:t,webs:h,modules:s,dotenv:a,errors:this.errors,specifications:this.specifications,configSchema:r,remoteFlags:this.remoteFlags,hiddenConfig:m,devApplicationURLs:this.getDevApplicationURLs(t,h)}),v=f.realExtensions.map(_=>_.type);return await Mu(v),await rN(f,this.project.usesWorkspaces,{usedCustomLayoutForWeb:g,usedCustomLayoutForExtensions:t.extension_directories!==void 0}),await f.generateExtensionTypes(),f}async loadWebs(t,n){let i=this.activeConfigFile,o=i?Fc(this.project,i):this.project.webConfigFiles,r=o.map(p=>p.path),a=await Promise.all(o.map(p=>mg(p.path,p.content))),s=[];for(let p of a)p.errors?this.errors.addErrors(p.errors):s.push(p.web);this.validateWebs(s);let c=r.every(p=>z(t,p).startsWith("web/"));return{webs:s,usedCustomLayout:n!==void 0||!c}}findSpecificationForType(t){return this.specifications.find(n=>n.identifier===t||n.externalIdentifier===t||n.additionalIdentifiers?.includes(t))}validateWebs(t){[fe.Backend,fe.Frontend].forEach(n=>{let i=t.filter(o=>o.configuration.roles.includes(n));if(i.length>1){let o=i.map(s=>k(s.directory,me.web)),r=o.map(s=>` ${s}`).join(`
|
|
168
|
-
`),a=o[o.length-1];this.errors.addError({file:a,message:`You can only have one "web" configuration file with the ${n} role in your app.
|
|
169
|
-
|
|
170
|
-
Conflicting configurations found at:
|
|
171
|
-
${r}`})}})}async createExtensionInstance(t,n,i,o){let r=this.findSpecificationForType(t),a,s=!1;if(r)s=!0;else{if(this.ignoreUnknownExtensions)return;this.errors.addError({file:i,message:`Invalid extension type "${t}" in "${eo(i)}"`});return}let c=cg(r,i,n);if(c.errors){this.errors.addErrors(c.errors);return}let d=c.data;s&&(a=await this.findEntryPath(o,r));let p=new Ya({configuration:d,configurationPath:i,entryPath:a,directory:o,specification:r});if(this.reloadState&&d.handle){let m=this.reloadState.extensionDevUUIDs.get(d.handle);m&&(p.devUUID=m)}if(s){let m=await p.validate();m.isErr()&&this.errors.addError({file:i,message:bn(m.error).trim()})}return p}async loadExtensions(t,n){if(this.specifications.length===0)return[];let i=await this.createExtensionInstances(t),o=await this.createConfigExtensionInstances(t,n),r=this.createWebhookSubscriptionInstances(t,n),a=await Promise.all([...i,...o,...r]),s=zt(a.flat()),c=new Set;return s.forEach(d=>{if(d.handle&&c.has(d.handle)){let p=s.filter(h=>h.handle===d.handle),m=Ad(p.map(h=>h.name));this.errors.addError({file:d.configurationPath,message:`Duplicated handle "${d.handle}" in extensions ${m}. Handle needs to be unique per extension.`})}else d.handle&&c.add(d.handle)}),s}async createExtensionInstances(t){let n=this.activeConfigFile;return(n?sg(this.project,n):this.project.extensionConfigFiles).map(async o=>{let r=o.path,a=H(r),s=o.content,c=Qf.safeParse(s);if(!c.success)return this.errors.addError({file:r,message:`Invalid extension configuration at ${z(t,r)}`}),[];let{extensions:d,type:p}=c.data;if(d){let m=await Dc(eh,r,o.content);if(m.errors)return this.errors.addErrors(m.errors),[];let h=m.data,g=h.extensions.map(async f=>{let v={...h,...f};return v.handle||(this.errors.addError({file:r,message:`Missing handle for extension "${v.name}" at ${z(t,r)}`}),v.handle="unknown-handle"),this.createExtensionInstance(v.type,v,r,a)});return Promise.all(g)}else{if(p)return this.createExtensionInstance(p,s,r,a);this.errors.addError({file:r,message:`Invalid extension type at "${z(t,r)}". Please specify a type.`});return}})}createWebhookSubscriptionInstances(t,n){let i=this.loadedConfiguration.configPath,o=this.findSpecificationForType(Eo);if(!o)return[];let r=dg(Co,i,n);if(r.errors)return this.errors.addErrors(r.errors),[];let{api_version:a,subscriptions:s=[]}=r.data.webhooks;return zt(s.flatMap(p=>{let{uri:m,topics:h,compliance_topics:g,...f}=p;return h?.map(v=>({api_version:a,uri:m,topic:v,...f}))})).map(async p=>this.createExtensionInstance(o.identifier,p,i,t))}async createConfigExtensionInstances(t,n){let i=this.loadedConfiguration.configPath,o=await Promise.all(this.specifications.filter(a=>Ei(a)).filter(a=>a.identifier!==Eo).map(async a=>{let s=cg(a,i,n);if(s.errors)return this.errors.addErrors(s.errors),[null,[]];let c=s.data;return Object.keys(c).length===0?[null,Object.keys(c)]:[await this.createExtensionInstance(a.identifier,c,i,t).then(p=>this.validateConfigurationExtensionInstance(n.client_id,n,p)),Object.keys(c)]})),r=Object.keys(n).filter(a=>!o.some(([s,c])=>c.includes(a))).filter(a=>![...Object.keys(br.shape),"organization_id"].includes(a));return r.length>0&&!this.ignoreUnknownExtensions&&this.errors.addError({file:i,message:`Unsupported section(s) in app configuration: ${r.sort().join(", ")}`}),o.filter(([a])=>a).map(([a])=>a)}async validateConfigurationExtensionInstance(t,n,i){return i&&await i.deployConfig({apiKey:t,appConfiguration:n})?i:void 0}async findEntryPath(t,n){let i;return n.appModuleFeatures().includes("single_js_entry_path")?(i=(await Promise.all(["index"].flatMap(o=>[`${o}.js`,`${o}.jsx`,`${o}.ts`,`${o}.tsx`]).flatMap(o=>[`src/${o}`,o]).map(o=>k(t,o)).map(async o=>await C(o)?o:void 0))).find(o=>o!==void 0),i||this.errors.addError({file:t,message:`Couldn't find an index.{js,jsx,ts,tsx} file in the directories ${t} or ${k(t,"src")}`})):n.identifier==="function"&&(i=(await Promise.all(["src/index.js","src/index.ts","src/main.rs"].map(o=>k(t,o)).map(async o=>await C(o)?o:void 0))).find(o=>o!==void 0)),i}getDevApplicationURLs(t,n){let i=this.reloadState?.previousDevURLs;return i&&Za(i.applicationUrl,n.map(({configuration:o})=>o.auth_callback_path).find(o=>o),t.app_proxy)}};async function Tt(e,t,n){let i=await Ai.load(e),o=await ns(i,t,n);return{project:i,activeConfig:o}}async function tN(e,t){let n=k(e,".gitignore");if(!Se(n))return!0;let i=await P(n),o=pg.default.default().add(i),r=z(e,t);return!o.ignores(r)}async function nN(e,t){let n=dt(t),i=k(e,n);if(await C(i))return{configurationPath:i,configurationFileName:n};throw new y(w`Couldn't find ${n} in ${b.path(e)}.`)}function iN(e,t){let n=e.map(i=>{let o=$(i.path);if(t[o]!==void 0&&typeof t[o]=="string")return[o,t[o]];let r=i.content.client_id;if(typeof r=="string"&&r!=="")return[o,r]}).filter(i=>i!==void 0);return Object.fromEntries(n)}async function oN(e){let t=e.filter(s=>Ye(s,fe.Backend)),n=e.filter(s=>Ye(s,fe.Frontend));if(t.length>1){S("Unable to decide project type as multiple web backends");return}else{if(t.length===0&&n.length>0)return"frontend";if(!t[0]){S("Unable to decide project type as no web backend");return}}let{directory:i}=t[0],o=k(i,"package.json"),r=k(i,"Gemfile"),a=k(i,"composer.json");if(await C(o))return"node";if(await C(r))return"ruby";if(await C(a))return"php"}function Ye(e,t){return e.configuration.roles.includes(t)}async function rN(e,t,n){let i=e.webs,o=e.allExtensions.filter(c=>c.isSentToMetrics()),r=e.name,a=e.directory,s=So(e.configuration).sort();await aN(i,o,n,r,a,s,t)}async function aN(e,t,n,i,o,r,a){await Q.addPublicMetadata(async()=>{let s=await oN(e),c=t.filter(_=>_.isFunctionExtension).length,d=t.filter(_=>_.isESBuildExtension).length,p=t.filter(_=>_.isThemeExtension).length,m=t.length,h=e.filter(_=>Ye(_,fe.Backend)).length,g=h===1?e.filter(_=>Ye(_,fe.Backend))[0]?.framework:void 0,f=e.filter(_=>Ye(_,fe.Frontend)).length,v={};for(let _ of t)v[_.type]===void 0?v[_.type]=1:v[_.type]++;return{project_type:s,app_extensions_any:m>0,app_extensions_breakdown:JSON.stringify(v),app_extensions_count:m,app_extensions_custom_layout:n.usedCustomLayoutForExtensions,app_extensions_function_any:c>0,app_extensions_function_count:c,app_extensions_theme_any:p>0,app_extensions_theme_count:p,app_extensions_ui_any:d>0,app_extensions_ui_count:d,app_name_hash:ut(i),app_path_hash:ut(o),app_scopes:JSON.stringify(r),app_web_backend_any:h>0,app_web_backend_count:h,app_web_custom_layout:n.usedCustomLayoutForWeb,app_web_framework:g,app_web_frontend_any:f>0,app_web_frontend_count:f,env_package_manager_workspaces:a}}),await Q.addSensitiveMetadata(async()=>({app_name:i}))}async function sN(e){await Q.addPublicMetadata(async()=>({cmd_app_all_configs_any:Object.keys(e.allClientIdsByConfigName).length>0,cmd_app_all_configs_clients:JSON.stringify(e.allClientIdsByConfigName),cmd_app_linked_config_used:e.usesLinkedConfig,...e.usesLinkedConfig?{cmd_app_linked_config_name:e.name,cmd_app_linked_config_git_tracked:e.gitTracked,cmd_app_linked_config_source:e.source,cmd_app_linked_config_uses_cli_managed_urls:e.usesCliManagedUrls}:{}}))}import{readdirSync as lN}from"fs";async function Ao(e){if(!e||!await Dt(e))return{};let t={},n=lN(e);return await Promise.all(n.map(async i=>{if(za(i)){let o=k(e,i),a=(await _e.read(o)).content;a.client_id&&(t[a.client_id]=i)}})),t}async function gg(e){if(e.length===1)return e[0];let n=new Set(e.map(r=>r.businessName)).size<e.length,i=e.map(r=>({label:n?`${r.businessName} (${r.id})`:r.businessName,value:r.id})),o=await Ge({message:"Which organization is this work for?",choices:i});return e.find(r=>r.id===o)}async function os(e,t,n,i){let o=await Ao(i?.directory);o&&Qh(o);let r=c=>o[c?.apiKey]?{label:`${c.title} (${o[c.apiKey]})`,value:c.apiKey}:{label:c.title,value:c.apiKey},a=t,s=await Ge({message:"Which existing app is this for?",choices:a.map(r),hasMorePages:n,search:async c=>{let d=await e(c);return a=d.apps,{data:a.map(r),meta:{hasNextPage:d.hasMorePages}}}});return a.find(c=>c.apiKey===s)}async function Rc({stores:e,hasMorePages:t=!1,onSearchForStoresByName:n,showDomainOnPrompt:i=!0}){if(e.length===0)return;if(e.length===1)return po(`Using your default dev store, ${e[0].shopName}, to preview your project.`),e[0];let o=c=>{let d=c.shopName;return i&&c.shopDomain&&(d=`${c.shopName} (${c.shopDomain})`),{label:d,value:c.shopId}},r=e,a={};n&&(a.search=async c=>{let d=await n(c);return r=d.stores,{data:r.map(o),meta:{hasNextPage:d.hasMorePages}}});let s=await Ge({message:"Which store would you like to use to view your project?",choices:r.map(o),hasMorePages:t,...a});return r.find(c=>c.shopId===s)}async function yg(){return De({message:"Make this store transfer-disabled? For security, once you use a dev store to preview an app locally, the store can never be transferred to a merchant to use as a production store.",confirmationMessage:"Yes, make this store transfer-disabled permanently",cancellationMessage:"No, select another store",defaultValue:!1})}async function rs(e){return Gt({message:"App name",defaultValue:e,validate:t=>{if(t.length===0)return"App name can't be empty";if(t.length>Va)return`Enter a shorter name (${Va} character max.)`;if(t.includes("shopify"))return`Name can't contain "shopify." Enter another name.`}})}async function vg(e){return De({message:"Finished creating a dev store?",confirmationMessage:`Yes, ${e.businessName} has a new dev store`,cancellationMessage:"No, cancel dev"})}async function as(){return De({message:"Create this project as a new app on Shopify?",confirmationMessage:"Yes, create it as a new app",cancellationMessage:"No, connect it to an existing app"})}function ig(e,t,n,i){return e?pN(t,i):cN(t,n)}function cN(e,t){return De({message:"Have Shopify automatically update your app's URL in order to create a preview experience?",confirmationMessage:"Yes, automatically update",cancellationMessage:"No, never",infoTable:{"Current app URL":[e],"Current redirect URLs":t}})}function pN(e,t){let n=["application_url","redirect_urls"];t.appProxy?.proxyUrl&&n.push("app_proxy");let i={"Currently released app URL":[e],"=> Dev URL":[t.applicationUrl],"Affected configurations":n};return De({message:"Have Shopify override your app URLs when running `app dev` against your dev store? This won't affect your app on other stores",confirmationMessage:"Yes, automatically update",cancellationMessage:"No, never",infoTable:i})}function kg(){return De({message:"--use-localhost requires a certificate for `localhost`. Generate it now?",confirmationMessage:"Yes, use mkcert to generate it",cancellationMessage:"No, I'll run `app dev` again without `--use-localhost`"})}var wg=2,dN=["This may happen if:"," \u2022 Running in an unstable environment (container restart, resource limits)"," \u2022 Network interruption during app fetching","","Try running the command again. If the issue persists:"," \u2022 Check system resources and stability"," \u2022 Try running outside of containers/WSL if applicable"," \u2022 Report this issue with the error details and a verbose log"].filter(Boolean).join(`
|
|
172
|
-
`);async function _g(e,t,n,i,o){let r=e.length===0;if(r||(r=await as()),r){let a=await rs(o.name);return i.createApp(n,{...o,name:a})}else{let s=Xa()?.tomls??{};for(let d=0;d<wg;d++){let p=await os($a(i,n.id),e,t,{directory:o.directory});if(p){let m=s[p.apiKey];m&&Jh(m);let h=await i.appFromIdentifiers(p.apiKey);if(h)return h}else{d<wg-1&&q("App selection failed. Retrying...");continue}}let c=["Unable to select an app: the selection prompt failed multiple times.","",`Available apps: ${e.length}`].join(`
|
|
173
|
-
`);throw new L(c,dN)}}l();l();l();async function bg(e){let{currentAccountInfo:t}=await e.currentAccountInfo();if(!t)throw new y("Unable to get current user account");return uN(t)}function uN(e){return e.__typename==="UserAccount"?{type:"UserAccount",email:e.email}:e.__typename==="ServiceAccount"?{type:"ServiceAccount",orgName:e.orgName}:{type:"UnknownAccount"}}l();var mN=4320*60*1e3;function Sg(e){return new Ht({projectName:"shopify-app-account-info",cwd:e})}function xg(e,t){let i=Sg(t).get(e);if(i)return new Date().valueOf()-new Date(i.loadedAt).valueOf()>mN?void 0:i.info}function Eg(e,t,n){Sg(n).set(e,{info:t,loadedAt:new Date().toISOString()})}async function ss(e,t){let n=xg(t);if(n)return S("Getting partner account info from cache"),n;try{let i=await bg(e);return Eg(t,i),i}catch{return S("Error fetching user account info"),{type:"UnknownAccount"}}}l();l();l();var Cg=R`
|
|
174
|
-
mutation AppCreate(
|
|
175
|
-
$org: Int!
|
|
176
|
-
$title: String!
|
|
177
|
-
$appUrl: Url!
|
|
178
|
-
$redir: [Url]!
|
|
179
|
-
$type: AppType
|
|
180
|
-
$requestedAccessScopes: [String!]
|
|
181
|
-
) {
|
|
182
|
-
appCreate(
|
|
183
|
-
input: {
|
|
184
|
-
organizationID: $org
|
|
185
|
-
title: $title
|
|
186
|
-
applicationUrl: $appUrl
|
|
187
|
-
redirectUrlWhitelist: $redir
|
|
188
|
-
appType: $type
|
|
189
|
-
requestedAccessScopes: $requestedAccessScopes
|
|
190
|
-
}
|
|
191
|
-
) {
|
|
192
|
-
app {
|
|
193
|
-
id
|
|
194
|
-
title
|
|
195
|
-
apiKey
|
|
196
|
-
organizationId
|
|
197
|
-
apiSecretKeys {
|
|
198
|
-
secret
|
|
199
|
-
}
|
|
200
|
-
appType
|
|
201
|
-
grantedScopes
|
|
202
|
-
applicationUrl
|
|
203
|
-
redirectUrlWhitelist
|
|
204
|
-
requestedAccessScopes
|
|
205
|
-
webhookApiVersion
|
|
206
|
-
embedded
|
|
207
|
-
posEmbedded
|
|
208
|
-
preferencesUrl
|
|
209
|
-
gdprWebhooks {
|
|
210
|
-
customerDeletionUrl
|
|
211
|
-
customerDataRequestUrl
|
|
212
|
-
shopDeletionUrl
|
|
213
|
-
}
|
|
214
|
-
appProxy {
|
|
215
|
-
subPath
|
|
216
|
-
subPathPrefix
|
|
217
|
-
url
|
|
218
|
-
}
|
|
219
|
-
disabledFlags
|
|
220
|
-
}
|
|
221
|
-
userErrors {
|
|
222
|
-
field
|
|
223
|
-
message
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
`;l();var kt;(function(e){e.Partners="Partners",e.BusinessPlatform="BusinessPlatform"})(kt||(kt={}));l();var Ng=R`
|
|
228
|
-
query allAppExtensionRegistrations($apiKey: String!) {
|
|
229
|
-
app(apiKey: $apiKey) {
|
|
230
|
-
extensionRegistrations {
|
|
231
|
-
id
|
|
232
|
-
uuid
|
|
233
|
-
title
|
|
234
|
-
type
|
|
235
|
-
draftVersion {
|
|
236
|
-
config
|
|
237
|
-
context
|
|
238
|
-
}
|
|
239
|
-
activeVersion {
|
|
240
|
-
config
|
|
241
|
-
context
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
configurationRegistrations {
|
|
245
|
-
id
|
|
246
|
-
uuid
|
|
247
|
-
title
|
|
248
|
-
type
|
|
249
|
-
draftVersion {
|
|
250
|
-
config
|
|
251
|
-
context
|
|
252
|
-
}
|
|
253
|
-
activeVersion {
|
|
254
|
-
config
|
|
255
|
-
context
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
dashboardManagedExtensionRegistrations {
|
|
259
|
-
id
|
|
260
|
-
uuid
|
|
261
|
-
title
|
|
262
|
-
type
|
|
263
|
-
activeVersion {
|
|
264
|
-
config
|
|
265
|
-
context
|
|
266
|
-
}
|
|
267
|
-
draftVersion {
|
|
268
|
-
config
|
|
269
|
-
context
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
`;l();var Ag=R`
|
|
275
|
-
query activeAppVersion($apiKey: String!) {
|
|
276
|
-
app(apiKey: $apiKey) {
|
|
277
|
-
activeAppVersion {
|
|
278
|
-
appModuleVersions {
|
|
279
|
-
registrationId
|
|
280
|
-
registrationUuid
|
|
281
|
-
registrationTitle
|
|
282
|
-
type
|
|
283
|
-
config
|
|
284
|
-
specification {
|
|
285
|
-
identifier
|
|
286
|
-
name
|
|
287
|
-
experience
|
|
288
|
-
options {
|
|
289
|
-
managementExperience
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
`;l();var Tg=R`
|
|
297
|
-
mutation AppDeploy(
|
|
298
|
-
$apiKey: String!
|
|
299
|
-
$bundleUrl: String
|
|
300
|
-
$appModules: [AppModuleSettings!]
|
|
301
|
-
$skipPublish: Boolean
|
|
302
|
-
$message: String
|
|
303
|
-
$versionTag: String
|
|
304
|
-
$commitReference: String
|
|
305
|
-
) {
|
|
306
|
-
appDeploy(
|
|
307
|
-
input: {
|
|
308
|
-
apiKey: $apiKey
|
|
309
|
-
bundleUrl: $bundleUrl
|
|
310
|
-
appModules: $appModules
|
|
311
|
-
skipPublish: $skipPublish
|
|
312
|
-
message: $message
|
|
313
|
-
versionTag: $versionTag
|
|
314
|
-
commitReference: $commitReference
|
|
315
|
-
}
|
|
316
|
-
) {
|
|
317
|
-
appVersion {
|
|
318
|
-
uuid
|
|
319
|
-
id
|
|
320
|
-
message
|
|
321
|
-
versionTag
|
|
322
|
-
location
|
|
323
|
-
appModuleVersions {
|
|
324
|
-
uuid
|
|
325
|
-
registrationUuid
|
|
326
|
-
validationErrors {
|
|
327
|
-
message
|
|
328
|
-
field
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
userErrors {
|
|
333
|
-
message
|
|
334
|
-
field
|
|
335
|
-
category
|
|
336
|
-
details
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
`;l();var Fg=R`
|
|
341
|
-
mutation GenerateSignedUploadUrl($apiKey: String!, $bundleFormat: Int!) {
|
|
342
|
-
appVersionGenerateSignedUploadUrl(input: {apiKey: $apiKey, bundleFormat: $bundleFormat}) {
|
|
343
|
-
signedUploadUrl
|
|
344
|
-
userErrors {
|
|
345
|
-
field
|
|
346
|
-
message
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
`;l();var Pg=R`
|
|
351
|
-
mutation ExtensionCreate(
|
|
352
|
-
$apiKey: String!
|
|
353
|
-
$type: ExtensionType!
|
|
354
|
-
$title: String!
|
|
355
|
-
$config: JSON!
|
|
356
|
-
$context: String
|
|
357
|
-
$handle: String
|
|
358
|
-
) {
|
|
359
|
-
extensionCreate(
|
|
360
|
-
input: {apiKey: $apiKey, type: $type, title: $title, config: $config, context: $context, handle: $handle}
|
|
361
|
-
) {
|
|
362
|
-
extensionRegistration {
|
|
363
|
-
id
|
|
364
|
-
uuid
|
|
365
|
-
type
|
|
366
|
-
title
|
|
367
|
-
draftVersion {
|
|
368
|
-
config
|
|
369
|
-
registrationId
|
|
370
|
-
lastUserInteractionAt
|
|
371
|
-
validationErrors {
|
|
372
|
-
field
|
|
373
|
-
message
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
userErrors {
|
|
378
|
-
field
|
|
379
|
-
message
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
`;l();var Ig=R`
|
|
384
|
-
mutation convertDevToTestStore($input: ConvertDevToTestStoreInput!) {
|
|
385
|
-
convertDevToTestStore(input: $input) {
|
|
386
|
-
convertedToTestStore
|
|
387
|
-
userErrors {
|
|
388
|
-
message
|
|
389
|
-
field
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
`;l();var Dg=R`
|
|
394
|
-
query FindOrganization($orgId: ID!, $shopDomain: String) {
|
|
395
|
-
organizations(id: $orgId, first: 1) {
|
|
396
|
-
nodes {
|
|
397
|
-
id
|
|
398
|
-
businessName
|
|
399
|
-
stores(shopDomain: $shopDomain, first: 1, archived: false) {
|
|
400
|
-
nodes {
|
|
401
|
-
shopId
|
|
402
|
-
link
|
|
403
|
-
shopDomain
|
|
404
|
-
shopName
|
|
405
|
-
transferDisabled
|
|
406
|
-
convertableToPartnerTest
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
`;l();var Rg=R`
|
|
413
|
-
query AppVersionsQuery($apiKey: String!) {
|
|
414
|
-
app(apiKey: $apiKey) {
|
|
415
|
-
id
|
|
416
|
-
organizationId
|
|
417
|
-
title
|
|
418
|
-
appVersions {
|
|
419
|
-
nodes {
|
|
420
|
-
createdAt
|
|
421
|
-
createdBy {
|
|
422
|
-
displayName
|
|
423
|
-
}
|
|
424
|
-
message
|
|
425
|
-
status
|
|
426
|
-
versionTag
|
|
427
|
-
}
|
|
428
|
-
pageInfo {
|
|
429
|
-
totalResults
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
`;l();var Ug=R`
|
|
435
|
-
mutation DevelopmentStorePreviewUpdate($input: DevelopmentStorePreviewUpdateInput!) {
|
|
436
|
-
developmentStorePreviewUpdate(input: $input) {
|
|
437
|
-
app {
|
|
438
|
-
id
|
|
439
|
-
developmentStorePreviewEnabled
|
|
440
|
-
}
|
|
441
|
-
userErrors {
|
|
442
|
-
message
|
|
443
|
-
field
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
`;l();var Og=R`
|
|
448
|
-
query FindAppPreviewMode($apiKey: String!) {
|
|
449
|
-
app(apiKey: $apiKey) {
|
|
450
|
-
developmentStorePreviewEnabled
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
`;l();var Mg=R`
|
|
454
|
-
query AppVersionsDiff($apiKey: String!, $versionId: ID!) {
|
|
455
|
-
app(apiKey: $apiKey) {
|
|
456
|
-
versionsDiff(appVersionId: $versionId) {
|
|
457
|
-
added {
|
|
458
|
-
uuid
|
|
459
|
-
registrationTitle
|
|
460
|
-
specification {
|
|
461
|
-
identifier
|
|
462
|
-
experience
|
|
463
|
-
options {
|
|
464
|
-
managementExperience
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
updated {
|
|
469
|
-
uuid
|
|
470
|
-
registrationTitle
|
|
471
|
-
specification {
|
|
472
|
-
identifier
|
|
473
|
-
experience
|
|
474
|
-
options {
|
|
475
|
-
managementExperience
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
removed {
|
|
480
|
-
uuid
|
|
481
|
-
registrationTitle
|
|
482
|
-
specification {
|
|
483
|
-
identifier
|
|
484
|
-
experience
|
|
485
|
-
options {
|
|
486
|
-
managementExperience
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
`;l();var Lg=R`
|
|
494
|
-
mutation AppRelease($apiKey: String!, $appVersionId: ID, $versionTag: String) {
|
|
495
|
-
appRelease(input: {apiKey: $apiKey, appVersionId: $appVersionId, versionTag: $versionTag}) {
|
|
496
|
-
appVersion {
|
|
497
|
-
versionTag
|
|
498
|
-
message
|
|
499
|
-
location
|
|
500
|
-
}
|
|
501
|
-
userErrors {
|
|
502
|
-
message
|
|
503
|
-
field
|
|
504
|
-
category
|
|
505
|
-
details
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
`;l();var $g=R`
|
|
510
|
-
query AppVersionByTag($apiKey: String!, $versionTag: String!) {
|
|
511
|
-
app(apiKey: $apiKey) {
|
|
512
|
-
appVersion(versionTag: $versionTag) {
|
|
513
|
-
id
|
|
514
|
-
uuid
|
|
515
|
-
versionTag
|
|
516
|
-
location
|
|
517
|
-
message
|
|
518
|
-
appModuleVersions {
|
|
519
|
-
config
|
|
520
|
-
specification {
|
|
521
|
-
identifier
|
|
522
|
-
name
|
|
523
|
-
experience
|
|
524
|
-
options {
|
|
525
|
-
managementExperience
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
`;l();var Vg=`
|
|
533
|
-
mutation samplePayload($topic: String!, $api_version: String!, $address: String!, $delivery_method: String!, $shared_secret: String!, $api_key: String) {
|
|
534
|
-
sendSampleWebhook(input: {topic: $topic, apiVersion: $api_version, address: $address, deliveryMethod: $delivery_method, sharedSecret: $shared_secret, apiKey: $api_key}) {
|
|
535
|
-
samplePayload
|
|
536
|
-
success
|
|
537
|
-
headers
|
|
538
|
-
userErrors {
|
|
539
|
-
message
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
`;async function ls(e,t,n){let{sendSampleWebhook:i}=await e.sendSampleWebhook(t,n);return i}l();var qg=`
|
|
544
|
-
query getApiVersions {
|
|
545
|
-
publicApiVersions
|
|
546
|
-
}
|
|
547
|
-
`;async function cs(e,t){let{publicApiVersions:n}=await e.apiVersions(t),i=n.indexOf("unstable");return i===-1?n.sort().reverse():(n.splice(i,1),n.sort().reverse(),n.push("unstable")),n}l();var jg=`
|
|
548
|
-
query getWebhookTopics($api_version: String!) {
|
|
549
|
-
webhookTopics(apiVersion: $api_version)
|
|
550
|
-
}
|
|
551
|
-
`;async function Bg(e,t,n){let i={api_version:t},{webhookTopics:o}=await e.topics(i,n);return o}l();var zg=R`
|
|
552
|
-
mutation MigrateFlowExtension($apiKey: String!, $registrationId: ID, $registrationUuid: String) {
|
|
553
|
-
migrateFlowExtension(
|
|
554
|
-
input: {apiKey: $apiKey, registrationId: $registrationId, registrationUuid: $registrationUuid}
|
|
555
|
-
) {
|
|
556
|
-
migratedFlowExtension
|
|
557
|
-
userErrors {
|
|
558
|
-
field
|
|
559
|
-
message
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
`;l();var Wg=R`
|
|
564
|
-
mutation appUpdate($apiKey: String!, $applicationUrl: Url!, $redirectUrlWhitelist: [Url]!, $appProxy: AppProxyInput) {
|
|
565
|
-
appUpdate(
|
|
566
|
-
input: {
|
|
567
|
-
apiKey: $apiKey
|
|
568
|
-
applicationUrl: $applicationUrl
|
|
569
|
-
redirectUrlWhitelist: $redirectUrlWhitelist
|
|
570
|
-
appProxy: $appProxy
|
|
571
|
-
}
|
|
572
|
-
) {
|
|
573
|
-
userErrors {
|
|
574
|
-
message
|
|
575
|
-
field
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
`;l();var Hg={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"currentAccountInfo"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"currentAccountInfo"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"__typename"}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"ServiceAccount"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"orgName"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"UserAccount"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]}}]};l();var Gg=R`
|
|
580
|
-
query RemoteTemplateSpecifications($version: String, $apiKey: String) {
|
|
581
|
-
templateSpecifications(version: $version, apiKey: $apiKey) {
|
|
582
|
-
identifier
|
|
583
|
-
name
|
|
584
|
-
defaultName
|
|
585
|
-
group
|
|
586
|
-
sortPriority
|
|
587
|
-
supportLinks
|
|
588
|
-
types {
|
|
589
|
-
url
|
|
590
|
-
type
|
|
591
|
-
extensionPoints
|
|
592
|
-
supportedFlavors {
|
|
593
|
-
name
|
|
594
|
-
value
|
|
595
|
-
path
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
`;l();var Kg=R`
|
|
601
|
-
query TargetSchemaDefinitionQuery($apiKey: String!, $version: String!, $target: String!) {
|
|
602
|
-
definition: functionTargetSchemaDefinition(apiKey: $apiKey, version: $version, target: $target)
|
|
603
|
-
}
|
|
604
|
-
`;l();var Yg=R`
|
|
605
|
-
query ApiSchemaDefinitionQuery($apiKey: String!, $version: String!, $type: String!) {
|
|
606
|
-
definition: functionApiSchemaDefinition(apiKey: $apiKey, version: $version, type: $type)
|
|
607
|
-
}
|
|
608
|
-
`;l();var Qg=R`
|
|
609
|
-
mutation MigrateToUiExtension($apiKey: String!, $registrationId: ID, $registrationUuid: String) {
|
|
610
|
-
migrateToUiExtension(
|
|
611
|
-
input: {apiKey: $apiKey, registrationId: $registrationId, registrationUuid: $registrationUuid}
|
|
612
|
-
) {
|
|
613
|
-
migratedToUiExtension
|
|
614
|
-
userErrors {
|
|
615
|
-
field
|
|
616
|
-
message
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
`;l();var Jg=R`
|
|
621
|
-
query fetchSpecifications($apiKey: String!) {
|
|
622
|
-
extensionSpecifications(apiKey: $apiKey) {
|
|
623
|
-
name
|
|
624
|
-
externalName
|
|
625
|
-
externalIdentifier
|
|
626
|
-
identifier
|
|
627
|
-
gated
|
|
628
|
-
experience
|
|
629
|
-
options {
|
|
630
|
-
managementExperience
|
|
631
|
-
registrationLimit
|
|
632
|
-
}
|
|
633
|
-
features {
|
|
634
|
-
argo {
|
|
635
|
-
surface
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
validationSchema {
|
|
639
|
-
jsonSchema
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
`;l();var Xg=R`
|
|
644
|
-
query FindOrganization($id: ID!) {
|
|
645
|
-
organizations(id: $id, first: 1) {
|
|
646
|
-
nodes {
|
|
647
|
-
id
|
|
648
|
-
businessName
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
`;l();var Zg=R`
|
|
653
|
-
mutation MigrateAppModule($apiKey: String!, $registrationId: ID, $registrationUuid: String, $type: String!) {
|
|
654
|
-
migrateAppModule(
|
|
655
|
-
input: {apiKey: $apiKey, registrationId: $registrationId, registrationUuid: $registrationUuid, type: $type}
|
|
656
|
-
) {
|
|
657
|
-
migratedAppModule
|
|
658
|
-
userErrors {
|
|
659
|
-
field
|
|
660
|
-
message
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
`;l();var ey=R`
|
|
665
|
-
mutation AppLogsSubscribe($apiKey: String!, $shopIds: [ID!]!) {
|
|
666
|
-
appLogsSubscribe(input: {apiKey: $apiKey, shopIds: $shopIds}) {
|
|
667
|
-
jwtToken
|
|
668
|
-
success
|
|
669
|
-
errors
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
`;l();var ty={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"AllOrgs"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"organizations"},arguments:[{kind:"Argument",name:{kind:"Name",value:"first"},value:{kind:"IntValue",value:"200"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"nodes"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"businessName"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var ny={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"ExtensionUpdateDraft"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"apiKey"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"registrationId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"config"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"JSON"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"context"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"handle"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"extensionUpdateDraft"},arguments:[{kind:"Argument",name:{kind:"Name",value:"input"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"apiKey"},value:{kind:"Variable",name:{kind:"Name",value:"apiKey"}}},{kind:"ObjectField",name:{kind:"Name",value:"registrationId"},value:{kind:"Variable",name:{kind:"Name",value:"registrationId"}}},{kind:"ObjectField",name:{kind:"Name",value:"config"},value:{kind:"Variable",name:{kind:"Name",value:"config"}}},{kind:"ObjectField",name:{kind:"Name",value:"context"},value:{kind:"Variable",name:{kind:"Name",value:"context"}}},{kind:"ObjectField",name:{kind:"Name",value:"handle"},value:{kind:"Variable",name:{kind:"Name",value:"handle"}}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"userErrors"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"field"}},{kind:"Field",name:{kind:"Name",value:"message"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var iy=R`
|
|
673
|
-
query FindApp($apiKey: String!) {
|
|
674
|
-
app(apiKey: $apiKey) {
|
|
675
|
-
id
|
|
676
|
-
title
|
|
677
|
-
apiKey
|
|
678
|
-
organizationId
|
|
679
|
-
apiSecretKeys {
|
|
680
|
-
secret
|
|
681
|
-
}
|
|
682
|
-
appType
|
|
683
|
-
grantedScopes
|
|
684
|
-
applicationUrl
|
|
685
|
-
redirectUrlWhitelist
|
|
686
|
-
requestedAccessScopes
|
|
687
|
-
webhookApiVersion
|
|
688
|
-
embedded
|
|
689
|
-
posEmbedded
|
|
690
|
-
preferencesUrl
|
|
691
|
-
gdprWebhooks {
|
|
692
|
-
customerDeletionUrl
|
|
693
|
-
customerDataRequestUrl
|
|
694
|
-
shopDeletionUrl
|
|
695
|
-
}
|
|
696
|
-
appProxy {
|
|
697
|
-
subPath
|
|
698
|
-
subPathPrefix
|
|
699
|
-
url
|
|
700
|
-
}
|
|
701
|
-
developmentStorePreviewEnabled
|
|
702
|
-
disabledFlags
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
`;l();var oy=R`
|
|
706
|
-
query FindOrganization($id: ID!, $title: String) {
|
|
707
|
-
organizations(id: $id, first: 1) {
|
|
708
|
-
nodes {
|
|
709
|
-
id
|
|
710
|
-
businessName
|
|
711
|
-
apps(first: 25, title: $title) {
|
|
712
|
-
pageInfo {
|
|
713
|
-
hasNextPage
|
|
714
|
-
}
|
|
715
|
-
nodes {
|
|
716
|
-
id
|
|
717
|
-
title
|
|
718
|
-
apiKey
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
`;l();var ry={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"DevStoresByOrg"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"organizations"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}},{kind:"Argument",name:{kind:"Name",value:"first"},value:{kind:"IntValue",value:"1"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"nodes"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"stores"},arguments:[{kind:"Argument",name:{kind:"Name",value:"first"},value:{kind:"IntValue",value:"500"}},{kind:"Argument",name:{kind:"Name",value:"archived"},value:{kind:"BooleanValue",value:!1}},{kind:"Argument",name:{kind:"Name",value:"type"},value:{kind:"ListValue",values:[{kind:"EnumValue",value:"DEVELOPMENT"},{kind:"EnumValue",value:"MANAGED"},{kind:"EnumValue",value:"PLUS_SANDBOX"}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"nodes"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"shopId"}},{kind:"Field",name:{kind:"Name",value:"link"}},{kind:"Field",name:{kind:"Name",value:"shopDomain"}},{kind:"Field",name:{kind:"Name",value:"shopName"}},{kind:"Field",name:{kind:"Name",value:"transferDisabled"}},{kind:"Field",name:{kind:"Name",value:"convertableToPartnerTest"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};var fN="https://shopify.dev/apps/default-app-home",hN="https://shopify.dev/apps/default-app-home/api/auth";function gN(e,t){let{name:n,isLaunchable:i=!0,scopesArray:o}=t,r=i?"https://example.com":fN,a=i?"https://example.com/api/auth":hN;return{org:parseInt(e.id,10),title:n,appUrl:r,redir:[a],requestedAccessScopes:o??[],type:"undecided"}}var Fn=class e{static getInstance(t){return e.instance??(e.instance=new e(t)),e.instance}static resetInstance(){e.instance=void 0}constructor(t){this.clientName=wt.Partners,this.webUiName="Partner Dashboard",this.supportsAtomicDeployments=!1,this.supportsDevSessions=!1,this.supportsStoreSearch=!1,this.organizationSource=kt.Partners,this.bundleFormat="zip",this.supportsDashboardManagedExtensions=!0,this._session=t}async session(){if(!this._session){if(ft())throw new Error("PartnersClient.session() should not be invoked dynamically in a unit test");let{token:t,userId:n}=await Pl();this._session={token:t,businessPlatformToken:"",accountInfo:{type:"UnknownAccount"},userId:n};let i=await ss(this,n);this._session={token:t,businessPlatformToken:"",accountInfo:i,userId:n}}return this._session}async request(t,n=void 0,i,o){return fu(t,await this.token(),n,i,o,this.createUnauthorizedHandler())}async requestDoc(t,n){return gu(t,await this.token(),n,void 0,this.createUnauthorizedHandler())}async token(){return(await this.session()).token}async unsafeRefreshToken(){let{token:t}=await Pl([],process.env,{noPrompt:!0,forceRefresh:!0}),n=await this.session();return t&&(n.token=t),n.token}async accountInfo(){return(await this.session()).accountInfo}async appFromIdentifiers(t){let n={apiKey:t},o=(await this.request(iy,n)).app;if(o){let r=Ar(o.disabledFlags);return{...o,flags:r,developerPlatformClient:this}}}async organizations(){try{return(await this.requestDoc(ty)).organizations.nodes.map(n=>({id:n.id,businessName:`${n.businessName} (Partner Dashboard)`,source:this.organizationSource}))}catch(t){if(t.statusCode===404)return[];throw t}}async orgFromId(t){let n={id:t},o=(await this.request(Xg,n,{cacheTTL:{hours:6}})).organizations.nodes[0];return o?{...o,source:this.organizationSource}:void 0}async orgAndApps(t){let n=await this.fetchOrgAndApps(t);return{organization:n.organization,apps:n.apps.nodes,hasMorePages:n.apps.pageInfo.hasNextPage}}async appsForOrg(t,n){let i=await this.fetchOrgAndApps(t,n);return{apps:i.apps.nodes,hasMorePages:i.apps.pageInfo.hasNextPage}}async specifications({apiKey:t}){let n={apiKey:t};return(await this.request(Jg,n)).extensionSpecifications.map(({options:o,features:r,...a})=>({...a,uidStrategy:a.experience==="extension"?"uuid":"single",registrationLimit:o.registrationLimit,managementExperience:o.managementExperience,surface:r?.argo?.surface}))}async templateSpecifications({apiKey:t}){let n={apiKey:t},o=(await this.request(Gg,n)).templateSpecifications.map(c=>{let{types:d,...p}=c;return{...p,...d[0]}}),r=0,a=o.map(c=>({...c,sortPriority:c.sortPriority??r++})),s=[];for(let c of a)c.group&&!s.includes(c.group)&&s.push(c.group);return{templates:a,groupOrder:s}}async createApp(t,n){let i=gN(t,n),o=await this.request(Cg,i);if(o.appCreate.userErrors.length>0){let a=o.appCreate.userErrors.map(s=>s.message).join(", ");throw new y(a)}let r=Ar(o.appCreate.app.disabledFlags);return{...o.appCreate.app,organizationId:t.id,newApp:!0,flags:r,developerPlatformClient:this}}async devStoresForOrg(t){let n={id:t};return{stores:(await this.requestDoc(ry,n)).organizations.nodes[0].stores.nodes,hasMorePages:!1}}async appExtensionRegistrations({apiKey:t},n){let i={apiKey:t};return this.request(Ng,i)}async appVersions({apiKey:t}){let n={apiKey:t};return this.request(Rg,n)}async appInstallCount(t){throw new Error("Unsupported operation")}async appVersionByTag({apiKey:t},n){let i={apiKey:t,versionTag:n},r=(await this.request($g,i)).app.appVersion;return{...r,appModuleVersions:r.appModuleVersions.map(a=>({...a,config:a.config?JSON.parse(a.config):void 0}))}}async appVersionsDiff({apiKey:t},{appVersionId:n}){let i={apiKey:t,versionId:n};return this.request(Mg,i)}async activeAppVersion({apiKey:t}){let n={apiKey:t},o=(await this.request(Ag,n)).app.activeAppVersion;if(o)return{...o,appModuleVersions:o.appModuleVersions.map(r=>({...r,config:r.config?JSON.parse(r.config):{}}))}}async createExtension(t){return this.request(Pg,t)}async updateExtension(t){return this.requestDoc(ny,t)}async deploy(t){let{organizationId:n,...i}=t,o=i;return o.appModules=o.appModules?.map(r=>{let{uid:a,...s}=r;return s}),this.request(Tg,o,void 0,"slow-request")}async release({app:{apiKey:t},version:{appVersionId:n}}){let i={apiKey:t,appVersionId:n};return this.request(Lg,i)}async generateSignedUploadUrl(t){let n={apiKey:t.apiKey,bundleFormat:1},i=await this.request(Fg,n);return{assetUrl:i.appVersionGenerateSignedUploadUrl.signedUploadUrl,userErrors:i.appVersionGenerateSignedUploadUrl.userErrors}}async convertToTransferDisabledStore(t){return this.request(Ig,t)}async storeByDomain(t,n,i){let o={orgId:t,shopDomain:n},a=(await this.request(Dg,o)).organizations.nodes[0]?.stores.nodes[0];if(a)return{...a,provisionable:!1}}async ensureUserAccessToStore(t,n){}async updateDeveloperPreview(t){return this.request(Ug,t)}async appPreviewMode(t){return this.request(Og,t)}async sendSampleWebhook(t,n){return this.request(Vg,t)}async apiVersions(t){return this.request(qg)}async topics(t,n){return this.request(jg,t)}async migrateFlowExtension(t){return this.request(zg,t)}async migrateAppModule(t){return this.request(Zg,t)}async updateURLs(t){return this.request(Wg,t)}async currentAccountInfo(){return this.requestDoc(Hg)}async targetSchemaDefinition(t,n,i){let o={target:t.handle,version:t.version,apiKey:n};return(await this.request(Kg,o)).definition}async apiSchemaDefinition(t,n,i,o){return(await this.request(Yg,{...t,apiKey:n})).definition}async migrateToUiExtension(t){return this.request(Qg,t)}toExtensionGraphQLType(t){return t.toUpperCase()}async subscribeToAppLogs(t,n){return this.request(ey,t)}async appDeepLink({id:t,organizationId:n}){return`https://${await fi()}/${n}/apps/${t}`}async appLogs(t,n){let i=await yN(t);try{let o=await i.json();return i.ok?{app_logs:o.app_logs??[],cursor:o.cursor,status:i.status}:{errors:o.errors??[`Request failed with status ${i.status}`],status:i.status}}catch(o){return{errors:[`Failed to parse response: ${o}`],status:i.status}}}async devSessionCreate(t){throw new Error("Unsupported operation")}async devSessionUpdate(t){throw new Error("Unsupported operation")}async devSessionDelete(t){return Promise.resolve()}async getCreateDevStoreLink(t){let n=`https://${await fi()}/${t.id}/stores`;return[`Looks like you don't have any dev stores associated with ${t.businessName}'s Partner Dashboard.`,{link:{url:n,label:"Create a store in Partner Dashboard"}}]}async fetchOrgAndApps(t,n){let i={id:t};n&&(i.title=n);let r=(await this.request(oy,i)).organizations.nodes[0];if(!r){let c=await this.session();throw new Ot(c.accountInfo,t)}let a={id:r.id,businessName:r.businessName,source:this.organizationSource},s=r.apps.nodes.map(c=>({...c,organizationId:r.id}));return{organization:a,apps:{...r.apps,nodes:s},stores:[]}}createUnauthorizedHandler(){return ps(this)}},yN=async({jwtToken:e,cursor:t,filters:n})=>{let i=await hu(t,n),o=`Shopify CLI; v=${Pt}`,r={Authorization:`Bearer ${e}`,"User-Agent":o};return ia(i,{method:"GET",headers:r},"non-blocking")};l();l();function ay(e){return R`
|
|
725
|
-
query OrganizationBetaFlags($organizationId: OrganizationID!) {
|
|
726
|
-
organization(organizationId: $organizationId) {
|
|
727
|
-
id
|
|
728
|
-
${e.map(t=>`flag_${t}: hasFeatureFlag(handle: "${t}")`).join(`
|
|
729
|
-
`)}
|
|
730
|
-
}
|
|
731
|
-
}`}l();var sy={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"OrganizationExpFlags"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"organizationId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"OrganizationID"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"flagHandles"}},type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"organization"},arguments:[{kind:"Argument",name:{kind:"Name",value:"organizationId"},value:{kind:"Variable",name:{kind:"Name",value:"organizationId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"enabledFlags"},arguments:[{kind:"Argument",name:{kind:"Name",value:"flagHandles"},value:{kind:"Variable",name:{kind:"Name",value:"flagHandles"}}}]},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var ly={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"ListOrganizations"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"currentUserAccount"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"uuid"}},{kind:"Field",name:{kind:"Name",value:"organizationsWithAccessToDestination"},arguments:[{kind:"Argument",name:{kind:"Name",value:"destination"},value:{kind:"EnumValue",value:"APPS_CLI"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"nodes"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var vN=at.extend({application_url:_r(u.string({required_error:"Valid URL is required"})),embedded:u.boolean({required_error:"Boolean is required",invalid_type_error:"Value must be Boolean"}),app_preferences:u.object({url:_r(u.string().max(255,{message:"String must be less than 255 characters"}))}).optional()}),kN={app_url:"application_url",embedded:"embedded",preferences_url:"app_preferences.url"},Tr="app_home",wN=$e({identifier:Tr,schema:vN,transformConfig:kN,patchWithAppDevURLs:(e,t)=>{e.application_url=t.applicationUrl},getDevSessionUpdateMessages:async e=>[`Using URL: ${e.application_url}`]}),cy=wN;l();var _N=at.extend({name:u.string({required_error:"String is required"}).max(30,{message:"String must be less than 30 characters"}),handle:u.string({required_error:"String is required"}).max(256,{message:"String must be less than 256 characters long"}).refine(e=>e&&/^\w*(?!-)[_a-z0-9-]+(?<!-)$/.test(e),{message:"String can't contain special characters"}).optional()}),bN={name:"name",app_handle:"handle"},Fr="branding",SN=$e({identifier:Fr,schema:_N,transformConfig:bN}),py=SN;l();var dy={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"DevSessionCreate"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"appId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"assetsUrl"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"websocketUrl"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"devSessionCreate"},arguments:[{kind:"Argument",name:{kind:"Name",value:"appId"},value:{kind:"Variable",name:{kind:"Name",value:"appId"}}},{kind:"Argument",name:{kind:"Name",value:"assetsUrl"},value:{kind:"Variable",name:{kind:"Name",value:"assetsUrl"}}},{kind:"Argument",name:{kind:"Name",value:"websocketUrl"},value:{kind:"Variable",name:{kind:"Name",value:"websocketUrl"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"devSession"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"websocketUrl"}},{kind:"Field",name:{kind:"Name",value:"updatedAt"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"app"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"key"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"warnings"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"message"}},{kind:"Field",name:{kind:"Name",value:"code"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"userErrors"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"message"}},{kind:"Field",name:{kind:"Name",value:"on"}},{kind:"Field",name:{kind:"Name",value:"field"}},{kind:"Field",name:{kind:"Name",value:"category"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var uy={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"DevSessionUpdate"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"appId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"assetsUrl"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"manifest"}},type:{kind:"NamedType",name:{kind:"Name",value:"JSON"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"inheritedModuleUids"}},type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"devSessionUpdate"},arguments:[{kind:"Argument",name:{kind:"Name",value:"appId"},value:{kind:"Variable",name:{kind:"Name",value:"appId"}}},{kind:"Argument",name:{kind:"Name",value:"assetsUrl"},value:{kind:"Variable",name:{kind:"Name",value:"assetsUrl"}}},{kind:"Argument",name:{kind:"Name",value:"manifest"},value:{kind:"Variable",name:{kind:"Name",value:"manifest"}}},{kind:"Argument",name:{kind:"Name",value:"inheritedModuleUids"},value:{kind:"Variable",name:{kind:"Name",value:"inheritedModuleUids"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"devSession"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"websocketUrl"}},{kind:"Field",name:{kind:"Name",value:"updatedAt"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"app"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"key"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"userErrors"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"message"}},{kind:"Field",name:{kind:"Name",value:"on"}},{kind:"Field",name:{kind:"Name",value:"field"}},{kind:"Field",name:{kind:"Name",value:"category"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var my={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"DevSessionDelete"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"appId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"devSessionDelete"},arguments:[{kind:"Argument",name:{kind:"Name",value:"appId"},value:{kind:"Variable",name:{kind:"Name",value:"appId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"userErrors"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"message"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var fy={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"FetchStoreByDomain"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"domain"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"filters"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ShopFilterInput"}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"organization"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"accessibleShops"},arguments:[{kind:"Argument",name:{kind:"Name",value:"filters"},value:{kind:"Variable",name:{kind:"Name",value:"filters"}}},{kind:"Argument",name:{kind:"Name",value:"search"},value:{kind:"Variable",name:{kind:"Name",value:"domain"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"edges"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"node"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"externalId"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"storeType"}},{kind:"Field",name:{kind:"Name",value:"primaryDomain"}},{kind:"Field",name:{kind:"Name",value:"shortName"}},{kind:"Field",name:{kind:"Name",value:"url"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"currentUser"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"organizationPermissions"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var hy={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"ListAppDevStores"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"searchTerm"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"organization"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"accessibleShops"},arguments:[{kind:"Argument",name:{kind:"Name",value:"filters"},value:{kind:"ListValue",values:[{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"field"},value:{kind:"EnumValue",value:"STORE_TYPE"}},{kind:"ObjectField",name:{kind:"Name",value:"operator"},value:{kind:"EnumValue",value:"EQUALS"}},{kind:"ObjectField",name:{kind:"Name",value:"value"},value:{kind:"StringValue",value:"app_development",block:!1}}]},{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"field"},value:{kind:"EnumValue",value:"STORE_STATUS"}},{kind:"ObjectField",name:{kind:"Name",value:"operator"},value:{kind:"EnumValue",value:"EQUALS"}},{kind:"ObjectField",name:{kind:"Name",value:"value"},value:{kind:"StringValue",value:"ACTIVE",block:!1}}]}]}},{kind:"Argument",name:{kind:"Name",value:"search"},value:{kind:"Variable",name:{kind:"Name",value:"searchTerm"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"edges"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"node"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"externalId"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"storeType"}},{kind:"Field",name:{kind:"Name",value:"primaryDomain"}},{kind:"Field",name:{kind:"Name",value:"shortName"}},{kind:"Field",name:{kind:"Name",value:"url"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"pageInfo"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"hasNextPage"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"currentUser"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"organizationPermissions"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var gy={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"ProvisionShopAccess"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"input"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"OrganizationUserProvisionShopAccessInput"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"organizationUserProvisionShopAccess"},arguments:[{kind:"Argument",name:{kind:"Name",value:"organizationUserProvisionShopAccessInput"},value:{kind:"Variable",name:{kind:"Name",value:"input"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"success"}},{kind:"Field",name:{kind:"Name",value:"userErrors"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"message"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var yy={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"ActiveAppReleaseFromApiKey"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"apiKey"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",alias:{kind:"Name",value:"app"},name:{kind:"Name",value:"appByKey"},arguments:[{kind:"Argument",name:{kind:"Name",value:"key"},value:{kind:"Variable",name:{kind:"Name",value:"apiKey"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"AppVersionInfo"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"ReleasedAppModule"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"AppModule"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"uuid"}},{kind:"Field",name:{kind:"Name",value:"userIdentifier"}},{kind:"Field",name:{kind:"Name",value:"handle"}},{kind:"Field",name:{kind:"Name",value:"config"}},{kind:"Field",name:{kind:"Name",value:"target"}},{kind:"Field",name:{kind:"Name",value:"specification"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"identifier"}},{kind:"Field",name:{kind:"Name",value:"externalIdentifier"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"experience"}},{kind:"Field",name:{kind:"Name",value:"managementExperience"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"AppVersionInfo"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"App"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"key"}},{kind:"Field",name:{kind:"Name",value:"organizationId"}},{kind:"Field",name:{kind:"Name",value:"activeRoot"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"clientCredentials"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"secrets"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"key"}}]}}]}},{kind:"Field",name:{kind:"Name",value:"grantedShopifyApprovalScopes"}}]}},{kind:"Field",name:{kind:"Name",value:"activeRelease"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"version"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"appModules"},selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ReleasedAppModule"}}]}}]}}]}}]}}]};l();var Uc={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"ReleaseVersion"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"appId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"versionId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"appReleaseCreate"},arguments:[{kind:"Argument",name:{kind:"Name",value:"appId"},value:{kind:"Variable",name:{kind:"Name",value:"appId"}}},{kind:"Argument",name:{kind:"Name",value:"versionId"},value:{kind:"Variable",name:{kind:"Name",value:"versionId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"release"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"version"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"metadata"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"message"}},{kind:"Field",name:{kind:"Name",value:"versionTag"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"userErrors"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"field"}},{kind:"Field",name:{kind:"Name",value:"message"}},{kind:"Field",name:{kind:"Name",value:"category"}},{kind:"Field",name:{kind:"Name",value:"code"}},{kind:"Field",name:{kind:"Name",value:"on"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var vy={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CreateAppVersion"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"appId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"version"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"AppVersionInput"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"metadata"}},type:{kind:"NamedType",name:{kind:"Name",value:"VersionMetadataInput"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"appVersionCreate"},arguments:[{kind:"Argument",name:{kind:"Name",value:"appId"},value:{kind:"Variable",name:{kind:"Name",value:"appId"}}},{kind:"Argument",name:{kind:"Name",value:"version"},value:{kind:"Variable",name:{kind:"Name",value:"version"}}},{kind:"Argument",name:{kind:"Name",value:"metadata"},value:{kind:"Variable",name:{kind:"Name",value:"metadata"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"version"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"appModules"},selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ReleasedAppModule"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"metadata"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"versionTag"}},{kind:"Field",name:{kind:"Name",value:"message"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"userErrors"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"field"}},{kind:"Field",name:{kind:"Name",value:"message"}},{kind:"Field",name:{kind:"Name",value:"category"}},{kind:"Field",name:{kind:"Name",value:"code"}},{kind:"Field",name:{kind:"Name",value:"on"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"ReleasedAppModule"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"AppModule"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"uuid"}},{kind:"Field",name:{kind:"Name",value:"userIdentifier"}},{kind:"Field",name:{kind:"Name",value:"handle"}},{kind:"Field",name:{kind:"Name",value:"config"}},{kind:"Field",name:{kind:"Name",value:"target"}},{kind:"Field",name:{kind:"Name",value:"specification"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"identifier"}},{kind:"Field",name:{kind:"Name",value:"externalIdentifier"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"experience"}},{kind:"Field",name:{kind:"Name",value:"managementExperience"}}]}}]}}]};l();var ky={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CreateAssetURL"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"sourceExtension"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"SourceExtension"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"organizationId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"appRequestSourceUploadUrl"},arguments:[{kind:"Argument",name:{kind:"Name",value:"sourceExtension"},value:{kind:"Variable",name:{kind:"Name",value:"sourceExtension"}}},{kind:"Argument",name:{kind:"Name",value:"organizationId"},value:{kind:"Variable",name:{kind:"Name",value:"organizationId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"sourceUploadUrl"}},{kind:"Field",name:{kind:"Name",value:"userErrors"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"field"}},{kind:"Field",name:{kind:"Name",value:"message"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var wy={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"AppVersionById"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"versionId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"version"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"versionId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"VersionInfo"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"ReleasedAppModule"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"AppModule"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"uuid"}},{kind:"Field",name:{kind:"Name",value:"userIdentifier"}},{kind:"Field",name:{kind:"Name",value:"handle"}},{kind:"Field",name:{kind:"Name",value:"config"}},{kind:"Field",name:{kind:"Name",value:"target"}},{kind:"Field",name:{kind:"Name",value:"specification"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"identifier"}},{kind:"Field",name:{kind:"Name",value:"externalIdentifier"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"experience"}},{kind:"Field",name:{kind:"Name",value:"managementExperience"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"VersionInfo"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"Version"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"metadata"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"message"}},{kind:"Field",name:{kind:"Name",value:"versionTag"}}]}},{kind:"Field",name:{kind:"Name",value:"appModules"},selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ReleasedAppModule"}}]}}]}}]};l();var _y={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"AppVersions"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"appId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"app"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"appId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"activeRelease"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"version"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"versions"},arguments:[{kind:"Argument",name:{kind:"Name",value:"first"},value:{kind:"IntValue",value:"20"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"edges"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"node"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"createdAt"}},{kind:"Field",name:{kind:"Name",value:"createdBy"}},{kind:"Field",name:{kind:"Name",value:"metadata"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"message"}},{kind:"Field",name:{kind:"Name",value:"versionTag"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"versionsCount"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var by={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"AppInstallCount"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"appId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"app"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"appId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"installCount"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var Sy={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CreateApp"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"initialVersion"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"AppVersionInput"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"organizationId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"appCreate"},arguments:[{kind:"Argument",name:{kind:"Name",value:"initialVersion"},value:{kind:"Variable",name:{kind:"Name",value:"initialVersion"}}},{kind:"Argument",name:{kind:"Name",value:"organizationId"},value:{kind:"Variable",name:{kind:"Name",value:"organizationId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"app"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"key"}},{kind:"Field",name:{kind:"Name",value:"activeRoot"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"clientCredentials"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"secrets"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"key"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"userErrors"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"category"}},{kind:"Field",name:{kind:"Name",value:"message"}},{kind:"Field",name:{kind:"Name",value:"on"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var xy={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"fetchSpecifications"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"organizationId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"specifications"},arguments:[{kind:"Argument",name:{kind:"Name",value:"organizationId"},value:{kind:"Variable",name:{kind:"Name",value:"organizationId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"identifier"}},{kind:"Field",name:{kind:"Name",value:"externalIdentifier"}},{kind:"Field",name:{kind:"Name",value:"experience"}},{kind:"Field",name:{kind:"Name",value:"features"}},{kind:"Field",name:{kind:"Name",value:"uidStrategy"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"__typename"}},{kind:"Field",name:{kind:"Name",value:"appModuleLimit"}},{kind:"Field",name:{kind:"Name",value:"isClientProvided"}}]}},{kind:"Field",name:{kind:"Name",value:"validationSchema"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"jsonSchema"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var Ey={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"listApps"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"query"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"appsConnection"},arguments:[{kind:"Argument",name:{kind:"Name",value:"query"},value:{kind:"Variable",name:{kind:"Name",value:"query"}}},{kind:"Argument",name:{kind:"Name",value:"first"},value:{kind:"IntValue",value:"50"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"edges"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"node"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"key"}},{kind:"Field",name:{kind:"Name",value:"activeRelease"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"version"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"pageInfo"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"hasNextPage"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var Cy={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"FindOrganizations"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"organizationId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"OrganizationID"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"currentUserAccount"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"organization"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"organizationId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var Ny={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"UserInfo"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"currentUserAccount"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"uuid"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"organizations"},arguments:[{kind:"Argument",name:{kind:"Name",value:"first"},value:{kind:"IntValue",value:"2"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"nodes"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var Ay={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"availableTopics"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"apiVersion"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"availableTopics"},arguments:[{kind:"Argument",name:{kind:"Name",value:"apiVersion"},value:{kind:"Variable",name:{kind:"Name",value:"apiVersion"}}}]}]}}]};l();var Ty={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CliTesting"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"address"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"apiKey"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"apiVersion"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"deliveryMethod"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"sharedSecret"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"topic"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"cliTesting"},arguments:[{kind:"Argument",name:{kind:"Name",value:"address"},value:{kind:"Variable",name:{kind:"Name",value:"address"}}},{kind:"Argument",name:{kind:"Name",value:"apiKey"},value:{kind:"Variable",name:{kind:"Name",value:"apiKey"}}},{kind:"Argument",name:{kind:"Name",value:"apiVersion"},value:{kind:"Variable",name:{kind:"Name",value:"apiVersion"}}},{kind:"Argument",name:{kind:"Name",value:"deliveryMethod"},value:{kind:"Variable",name:{kind:"Name",value:"deliveryMethod"}}},{kind:"Argument",name:{kind:"Name",value:"sharedSecret"},value:{kind:"Variable",name:{kind:"Name",value:"sharedSecret"}}},{kind:"Argument",name:{kind:"Name",value:"topic"},value:{kind:"Variable",name:{kind:"Name",value:"topic"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"headers"}},{kind:"Field",name:{kind:"Name",value:"samplePayload"}},{kind:"Field",name:{kind:"Name",value:"success"}},{kind:"Field",name:{kind:"Name",value:"errors"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var Fy={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"publicApiVersions"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"publicApiVersions"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"handle"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var Py={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"SchemaDefinitionByTarget"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"handle"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"version"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"target"},arguments:[{kind:"Argument",name:{kind:"Name",value:"handle"},value:{kind:"Variable",name:{kind:"Name",value:"handle"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"api"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"schema"},arguments:[{kind:"Argument",name:{kind:"Name",value:"version"},value:{kind:"Variable",name:{kind:"Name",value:"version"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"definition"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var Iy={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"SchemaDefinitionByApiType"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"type"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"version"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"api"},arguments:[{kind:"Argument",name:{kind:"Name",value:"type"},value:{kind:"Variable",name:{kind:"Name",value:"type"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"schema"},arguments:[{kind:"Argument",name:{kind:"Name",value:"version"},value:{kind:"Variable",name:{kind:"Name",value:"version"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"definition"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var Pr="webhooks",xN={forward:zh,reverse:e=>Wh(e)},EN=$e({identifier:Pr,schema:Co,transformConfig:xN}),Dy=EN;l();var Ry={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"AppVersionByTag"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"versionTag"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"versionByTag"},arguments:[{kind:"Argument",name:{kind:"Name",value:"tag"},value:{kind:"Variable",name:{kind:"Name",value:"versionTag"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"VersionInfo"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"ReleasedAppModule"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"AppModule"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"uuid"}},{kind:"Field",name:{kind:"Name",value:"userIdentifier"}},{kind:"Field",name:{kind:"Name",value:"handle"}},{kind:"Field",name:{kind:"Name",value:"config"}},{kind:"Field",name:{kind:"Name",value:"target"}},{kind:"Field",name:{kind:"Name",value:"specification"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"identifier"}},{kind:"Field",name:{kind:"Name",value:"externalIdentifier"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"experience"}},{kind:"Field",name:{kind:"Name",value:"managementExperience"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"VersionInfo"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"Version"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"metadata"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"message"}},{kind:"Field",name:{kind:"Name",value:"versionTag"}}]}},{kind:"Field",name:{kind:"Name",value:"appModules"},selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ReleasedAppModule"}}]}}]}}]};l();var Uy={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"AppLogsSubscribe"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"shopIds"}},type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"apiKey"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"appLogsSubscribe"},arguments:[{kind:"Argument",name:{kind:"Name",value:"shopIds"},value:{kind:"Variable",name:{kind:"Name",value:"shopIds"}}},{kind:"Argument",name:{kind:"Name",value:"apiKey"},value:{kind:"Variable",name:{kind:"Name",value:"apiKey"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"jwtToken"}},{kind:"Field",name:{kind:"Name",value:"success"}},{kind:"Field",name:{kind:"Name",value:"errors"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};var Oy="https://cdn.shopify.com/static/cli/extensions/templates.json",To=class e{static getInstance(t){return e.instance??(e.instance=new e(t)),e.instance}static resetInstance(){e.instance=void 0}constructor(t){this.clientName=wt.AppManagement,this.webUiName="Developer Dashboard",this.supportsAtomicDeployments=!0,this.supportsDevSessions=!0,this.supportsStoreSearch=!0,this.organizationSource=kt.BusinessPlatform,this.bundleFormat="br",this.supportsDashboardManagedExtensions=!1,this._session=t}async subscribeToAppLogs(t,n){return this.appManagementRequest({query:Uy,variables:{shopIds:t.shopIds,apiKey:t.apiKey}})}async appLogs(t,n){let i=await RN({organizationId:n,jwtToken:t.jwtToken,cursor:t.cursor,filters:t.filters});try{let o=await i.json();return i.ok?{app_logs:o.app_logs??[],cursor:o.cursor,status:i.status}:{errors:o.errors??[`Request failed with status ${i.status}`],status:i.status}}catch(o){return{errors:[`Failed to parse response: ${o}`],status:i.status}}}async session(){if(!this._session){if(ft())throw new Error("AppManagementClient.session() should not be invoked dynamically in a unit test");let t=await Il(),{appManagementToken:n,businessPlatformToken:i,userId:o}=t,r=await Rl({query:Ny,cacheOptions:{cacheTTL:{hours:6},cacheExtraKey:o},token:i,unauthorizedHandler:this.createUnauthorizedHandler("businessPlatform")});if(Wd()&&r.currentUserAccount){let a=r.currentUserAccount.organizations.nodes.map(s=>({name:s.name}));if(a.length>1)throw new L("Multiple organizations found for the CLI token");this._session={token:n,businessPlatformToken:i,accountInfo:{type:"ServiceAccount",orgName:a[0]?.name??"Unknown organization"},userId:o}}else r.currentUserAccount?this._session={token:n,businessPlatformToken:i,accountInfo:{type:"UserAccount",email:r.currentUserAccount.email},userId:o}:this._session={token:n,businessPlatformToken:i,accountInfo:{type:"UnknownAccount"},userId:o}}return this._session}async token(){return(await this.session()).token}async businessPlatformToken(){return(await this.session()).businessPlatformToken}async unsafeRefreshToken(){let t=await Il({noPrompt:!0,forceRefresh:!0}),n=await this.session();return n.token=t.appManagementToken,n.businessPlatformToken=t.businessPlatformToken,n.token}async accountInfo(){return(await this.session()).accountInfo}async appFromIdentifiers(t){let{app:n}=await this.activeAppVersionRawResult(t);if(!n)return;let{name:i,appModules:o}=n.activeRelease.version,r=o.find(s=>s.specification.externalIdentifier==="app_home"),a=n.activeRoot.clientCredentials.secrets.map(s=>({secret:s.key}));return{id:n.id,title:i,apiKey:n.key,apiSecretKeys:a,organizationId:String(ze(n.organizationId)),grantedScopes:n.activeRoot.grantedShopifyApprovalScopes,applicationUrl:r?.config?.app_url,embedded:r?.config?.embedded,flags:[],developerPlatformClient:this}}async organizations(){let t=await this.businessPlatformRequest({query:ly});return t.currentUserAccount?t.currentUserAccount.organizationsWithAccessToDestination.nodes.map(i=>({id:qy(i.id),businessName:i.name,source:this.organizationSource})):[]}async orgFromId(t){let i={organizationId:Oc(t)},r=(await this.businessPlatformRequest({query:Cy,variables:i,cacheOptions:{cacheTTL:{hours:6}}})).currentUserAccount?.organization;if(r)return{id:t,businessName:r.name,source:this.organizationSource}}async orgAndApps(t){let[n,{apps:i,hasMorePages:o}]=await Promise.all([this.orgFromId(t),this.appsForOrg(t)]);if(!n){let{accountInfo:r}=await this.session();throw new Ot(r,t)}return{organization:n,apps:i,hasMorePages:o}}async appsForOrg(t,n=""){let i=Ey,o={query:n.split(" ").filter(s=>s).map(s=>`title:${s}`).join(" "),organizationId:t},r=await this.appManagementRequest({query:i,variables:o});if(!r.appsConnection)throw new L("Server failed to retrieve apps");return{apps:r.appsConnection.edges.map(s=>{let c=s.node;return{id:c.id,apiKey:c.key,title:c.activeRelease.version.name,organizationId:t}}),hasMorePages:r.appsConnection.pageInfo.hasNextPage}}async specifications({organizationId:t}){let n=xy,i={organizationId:Mc(t)};return(await this.appManagementRequest({query:n,variables:i})).specifications.map(r=>({name:r.name,externalName:r.name,identifier:r.identifier,externalIdentifier:r.externalIdentifier,gated:!1,managementExperience:"cli",registrationLimit:r.uidStrategy.appModuleLimit,uidStrategy:DN(r.uidStrategy.__typename),experience:Lc(r.experience),validationSchema:r.validationSchema}))}async templateSpecifications({organizationId:t}){let n,{templatesJsonPath:i}=Zt,o=process.env[i];if(o){if(!await C(o))throw new y("There is no file at the path specified for template specifications");let c=await P(o);n=JSON.parse(c)}else try{n=await(await Ae(Oy)).json()}catch{throw new y(["Failed to fetch extension templates from",{link:{url:Oy}},{char:"."},"This likely means a problem with your internet connection."])}let r=0,a=(await IN(n,async c=>this.organizationBetaFlags(t,c),async c=>this.organizationExpFlags(t,c))).map(c=>({...c,sortPriority:r++})),s=[];for(let c of n)c.group&&!s.includes(c.group)&&s.push(c.group);return{templates:a,groupOrder:s}}async createApp(t,n){let o=(await this.apiVersions(t.id)).publicApiVersions.filter(m=>m!=="unstable").sort().at(-1)??"unstable",r=AN(n,t.id,o),a=Sy,s=await this.appManagementRequest({query:a,variables:r});if(!s.appCreate.app||s.appCreate.userErrors?.length>0){let m=s.appCreate.userErrors.map(h=>h.message).join(", ");throw new y(m)}let c=Ar([]),d=s.appCreate.app,p=d.activeRoot.clientCredentials.secrets.map(m=>({secret:m.key}));return{...d,title:n.name,apiKey:d.key,apiSecretKeys:p,grantedScopes:n?.scopesArray??[],organizationId:t.id,newApp:!0,flags:c,developerPlatformClient:this}}async devStoresForOrg(t,n){let i=await this.businessPlatformOrganizationsRequest({query:hy,organizationId:String(ze(t)),variables:{searchTerm:n}}),o=i.organization;if(!o)throw new y("No organization found");let r=o.accessibleShops?.edges.map(s=>s.node)??[],a=Vy(o.currentUser?.organizationPermissions??[]);return{stores:My(r,a),hasMorePages:i.organization?.accessibleShops?.pageInfo.hasNextPage??!1}}async appExtensionRegistrations(t,n){let i=n??await this.activeAppVersion(t),o=[],r=[],a=[];return i.appModuleVersions.forEach(s=>{let c={id:s.registrationId,uuid:s.registrationUuid,title:s.registrationTitle,type:s.type,activeVersion:s.config?{config:JSON.stringify(s.config),...s.target&&{context:s.target}}:void 0};s.specification?.experience==="configuration"?o.push(c):s.specification?.options?.managementExperience==="dashboard"?a.push(c):r.push(c)}),{app:{dashboardManagedExtensionRegistrations:a,configurationRegistrations:o,extensionRegistrations:r}}}async appVersions({id:t,organizationId:n,title:i}){let o=_y,r={appId:t},a=await this.appManagementRequest({query:o,variables:r});return{app:{id:a.app.id,organizationId:n,title:i,appVersions:{nodes:a.app.versions?.edges.map(s=>{let c=s.node;return{createdAt:c.createdAt,createdBy:{displayName:c.createdBy},versionTag:c.metadata.versionTag,status:c.id===a.app.activeRelease.version.id?"active":"inactive",versionId:c.id,message:c.metadata.message}})??[],pageInfo:{totalResults:a.app.versionsCount}}}}}async appInstallCount({id:t}){let n=by,i={appId:t};return(await this.appManagementRequest({query:n,variables:i})).app.installCount??0}async appVersionByTag({id:t,organizationId:n},i){let o=Ry,r={versionTag:i},s=(await this.appManagementRequest({query:o,variables:r})).versionByTag;if(!s)throw new y(`Version not found for tag: ${i}`);return{id:parseInt(s.id,10),uuid:s.id,versionTag:s.metadata.versionTag,location:[await ds({organizationId:n,id:t}),"versions",ze(s.id)].join("/"),message:s.metadata.message??"",appModuleVersions:s.appModules.map(Ly)}}async appVersionsDiff(t,{versionId:n}){let i={versionId:n},[o,r]=await Promise.all([this.activeAppVersionRawResult(t.apiKey),this.appManagementRequest({query:wy,variables:i})]),a=o.app.activeRelease.version.appModules,s=r.version.appModules,{added:c,removed:d,updated:p}=PN({currentModules:a,selectedVersionModules:s});function m(h){return{uuid:h.uuid,registrationTitle:h.handle,specification:{identifier:h.specification.identifier,experience:Lc(h.specification.experience),options:{managementExperience:"cli"}}}}return{app:{versionsDiff:{added:c.map(m),updated:p.map(m),removed:d.map(m)}}}}async activeAppVersion(t){let n=await this.activeAppVersionRawResult(t.apiKey);return{appModuleVersions:n.app.activeRelease.version.appModules.map(Ly),...n.app.activeRelease}}async generateSignedUploadUrl({organizationId:t}){let n={sourceExtension:"BR",organizationId:Mc(t)},i=await this.appManagementRequest({query:ky,variables:n,cacheOptions:{cacheTTL:{minutes:59}}});return{assetUrl:i.appRequestSourceUploadUrl.sourceUploadUrl,userErrors:i.appRequestSourceUploadUrl.userErrors}}async updateExtension(t){throw new L("Not implemented: updateExtension")}async deploy({appManifest:t,appId:n,organizationId:i,versionTag:o,message:r,commitReference:a,bundleUrl:s,skipPublish:c}){let m={appId:n,version:s?{sourceUrl:s}:{source:t},metadata:{versionTag:o,message:r,sourceControlUrl:a}},h=await this.appManagementRequest({query:vy,variables:m,requestOptions:{requestMode:"slow-request"}}),{version:g}=h.appVersionCreate,f=h.appVersionCreate.userErrors.map($y)??[];if(!g)return{appDeploy:{userErrors:f}};let v={appDeploy:{appVersion:{uuid:g.id,id:parseInt(g.id,10),versionTag:g.metadata.versionTag,location:await FN(i,n,g.id),appModuleVersions:g.appModules.map(E=>({uuid:E.uuid,registrationUuid:E.uuid,validationErrors:[]})),message:g.metadata.message},userErrors:f}};if(c)return v;let _={appId:n,versionId:g.id},x=await this.appManagementRequest({query:Uc,variables:_});return x.appReleaseCreate.userErrors&&(v.appDeploy.userErrors=(v.appDeploy.userErrors??[]).concat(x.appReleaseCreate.userErrors.map($y))),v}async release({app:{id:t,organizationId:n},version:{versionId:i}}){let o={appId:t,versionId:i},r=await this.appManagementRequest({query:Uc,variables:o});return r.appReleaseCreate.release?{appRelease:{appVersion:{versionTag:r.appReleaseCreate.release.version.metadata.versionTag,message:r.appReleaseCreate.release.version.metadata.message,location:[await ds({organizationId:n,id:t}),"versions",ze(r.appReleaseCreate.release.version.id).toString()].join("/")}}}:{appRelease:{userErrors:r.appReleaseCreate.userErrors?.map(a=>({field:a.field,message:a.message,category:a.category,details:[],on:a.on}))??[]}}}async storeByDomain(t,n,i){let r=(await Promise.all(i.map(s=>this.businessPlatformOrganizationsRequest({query:fy,organizationId:String(ze(t)),variables:{domain:n,filters:UN(s)}})))).map(s=>s.organization).filter(s=>s!=null);if(r.length===0)throw new y("No organization found");return r.flatMap(s=>{let c=s.accessibleShops?.edges.map(p=>p.node)??[],d=Vy(s.currentUser?.organizationPermissions??[]);return My(c,d)})[0]}async ensureUserAccessToStore(t,n){if(!n.provisionable)return;let o={input:{shopifyShopId:TN(n.shopId)}},a=(await pa({query:gy,token:await this.businessPlatformToken(),organizationId:String(ze(t)),variables:o,unauthorizedHandler:this.createUnauthorizedHandler()})).organizationUserProvisionShopAccess;if(!a.success){let s=a.userErrors?.map(c=>c.message).join(", ")??"";throw new L(`Failed to provision user access to store: ${s}`)}}async createExtension(t){throw new L("Not implemented: createExtension")}async convertToTransferDisabledStore(t){throw new L("Not implemented: convertToTransferDisabledStore")}async updateDeveloperPreview(t){throw new L("Not implemented: updateDeveloperPreview")}async appPreviewMode(t){throw new L("Not implemented: appPreviewMode")}async sendSampleWebhook(t,n){let i=Ty,o={address:t.address,apiKey:t.api_key,apiVersion:t.api_version,deliveryMethod:t.delivery_method,sharedSecret:t.shared_secret,topic:t.topic},r=await this.webhooksRequest({organizationId:n,query:i,variables:o}),a={samplePayload:"{}",headers:"{}",success:!1,userErrors:[]},s=r.cliTesting;return s&&(a={samplePayload:s.samplePayload??"{}",headers:s.headers??"{}",success:s.success,userErrors:s.errors.map(c=>({message:c,fields:[]}))}),{sendSampleWebhook:a}}async apiVersions(t){return{publicApiVersions:(await this.webhooksRequest({organizationId:t,query:Fy,variables:{}})).publicApiVersions.map(i=>i.handle)}}async topics({api_version:t},n){let i=Ay,o={apiVersion:t};return{webhookTopics:(await this.webhooksRequest({organizationId:n,query:i,variables:o})).availableTopics??[]}}async migrateFlowExtension(t){throw new L("Not implemented: migrateFlowExtension")}async migrateAppModule(t){throw new L("Not implemented: migrateAppModule")}async updateURLs(t){return S("\u26A0\uFE0F updateURLs is not implemented"),{appUpdate:{userErrors:[]}}}async currentAccountInfo(){throw new L("Not implemented: currentAccountInfo")}async targetSchemaDefinition(t,n,i){try{let{app:o}=await this.activeAppVersionRawResult(n),r=String(ze(o.id));return(await this.functionsRequest({organizationId:i,query:Py,appId:r,variables:{handle:t.handle,version:t.version}}))?.target?.api?.schema?.definition??null}catch(o){throw new y(`Failed to fetch schema definition: ${o}`)}}async apiSchemaDefinition(t,n,i){try{let{app:o}=await this.activeAppVersionRawResult(n),r=String(ze(o.id));return(await this.functionsRequest({organizationId:i,query:Iy,appId:r,variables:t}))?.api?.schema?.definition??null}catch(o){throw new y(`Failed to fetch schema definition: ${o}`)}}async migrateToUiExtension(t){throw new L("Not implemented: migrateToUiExtension")}toExtensionGraphQLType(t){return t.toLowerCase()}async appDeepLink({id:t,organizationId:n}){return ds({id:t,organizationId:n})}async devSessionCreate({appId:t,assetsUrl:n,shopFqdn:i,websocketUrl:o}){let r=String(ze(t));return this.appDevRequest({query:dy,shopFqdn:i,variables:{appId:r,assetsUrl:n??"",websocketUrl:o},requestOptions:{requestMode:"slow-request"}})}async devSessionUpdate({appId:t,assetsUrl:n,shopFqdn:i,manifest:o,inheritedModuleUids:r}){let s={appId:String(ze(t)),assetsUrl:n,manifest:JSON.stringify(o),inheritedModuleUids:r};return this.appDevRequest({query:uy,shopFqdn:i,variables:s})}async devSessionDelete({appId:t,shopFqdn:n}){let i=String(ze(t));return this.appDevRequest({query:my,shopFqdn:n,variables:{appId:i}})}async getCreateDevStoreLink(t){let n=`https://${await Tl()}/dashboard/${t.id}/stores`;return[`Looks like you don't have any dev stores associated with ${t.businessName}'s Dev Dashboard.`,{link:{url:n,label:"Create a store in Dev Dashboard"}}]}async activeAppVersionRawResult(t){return this.appManagementRequest({query:yy,variables:{apiKey:t}})}async organizationBetaFlags(t,n){let i={organizationId:Oc(t)},o=await yu({query:ay(n),token:await this.businessPlatformToken(),organizationId:t,variables:i,unauthorizedHandler:this.createUnauthorizedHandler()}),r={};return n.forEach(a=>{r[a]=!!o.organization[`flag_${a}`]}),r}async organizationExpFlags(t,n){let i={organizationId:Oc(t),flagHandles:n},o=await pa({query:sy,token:await this.businessPlatformToken(),organizationId:t,variables:i,unauthorizedHandler:this.createUnauthorizedHandler()}),r={},a=o.organization?.enabledFlags??[];return n.forEach((s,c)=>{r[s]=!!a[c]}),r}async appManagementRequest(t){return Lm({...t,token:await this.token(),unauthorizedHandler:this.createUnauthorizedHandler()})}async appDevRequest(t){return $m({...t,token:await this.token(),unauthorizedHandler:this.createUnauthorizedHandler()})}async businessPlatformRequest(t){return Rl({...t,token:await this.businessPlatformToken(),unauthorizedHandler:this.createUnauthorizedHandler("businessPlatform")})}async businessPlatformOrganizationsRequest(t){return pa({...t,token:await this.businessPlatformToken(),unauthorizedHandler:this.createUnauthorizedHandler("businessPlatform")})}async functionsRequest(t){return Vm({...t,token:await this.token(),unauthorizedHandler:this.createUnauthorizedHandler()})}async webhooksRequest(t){return qm({...t,token:await this.token(),unauthorizedHandler:this.createUnauthorizedHandler()})}createUnauthorizedHandler(t="default"){return ps(this,t)}},CN="https://shopify.dev/apps/default-app-home",NN="https://shopify.dev/apps/default-app-home/api/auth";function AN(e,t,n){let{isLaunchable:i,scopesArray:o,name:r}=e;return{initialVersion:{source:{source:{name:r,modules:[{type:Tr,config:{app_url:i?"https://example.com":CN,embedded:!0}},{type:Fr,config:{name:r}},{type:Pr,config:{api_version:n}},{type:Ci,config:{redirect_url_allowlist:[i?"https://example.com/api/auth":NN],...o&&{scopes:o.map(d=>d.trim()).join(",")}}}]}}.source},organizationId:Mc(t)}}function $c(e){let t=e.startsWith("gid://")?ze(e):Number(e);if(Number.isNaN(t))throw new Error(`Invalid organization ID: ${e}`);return`gid://organization/Organization/${t}`}function Oc(e){return Buffer.from($c(e)).toString("base64")}function Mc(e){return`gid://shopify/Organization/${e.startsWith("gid://")?ze(e):Number(e)}`}function TN(e){let t=`gid://organization/ShopifyShop/${e}`;return Buffer.from(t).toString("base64")}function qy(e){let t=Buffer.from(e,"base64").toString("ascii");return ze(t).toString()}function ze(e){return e.startsWith("gid://")?Number(e.match(/^gid.*\/(\d+)$/)[1]):Number(e)}async function ds({id:e,organizationId:t}){let n=ze(t).toString();return`https://${await Tl()}/dashboard/${n}/apps/${ze(e)}`}async function FN(e,t,n){return`${await ds({organizationId:e,id:t})}/versions/${ze(n)}`}function PN({currentModules:e,selectedVersionModules:t}){let n=e.map(c=>c.userIdentifier),i=t.map(c=>c.userIdentifier),o=t.filter(c=>!n.includes(c.userIdentifier)),r=e.filter(c=>!i.includes(c.userIdentifier)),a=r.map(c=>c.userIdentifier),s=e.filter(c=>!a.includes(c.userIdentifier));return{added:o,removed:r,updated:s}}async function IN(e,t,n,i=Pt){let o=Array.from(new Set(e.map(c=>c.organizationBetaFlags??[]).flat())),r=Array.from(new Set(e.map(c=>c.organizationExpFlags??[]).flat())),[a,s]=await Promise.all([o.length>0?t(o):Promise.resolve({}),r.length>0?n(r):Promise.resolve({})]);return e.filter(c=>{let d=!c.organizationBetaFlags||c.organizationBetaFlags.every(v=>a[v]),p=!c.organizationExpFlags||c.organizationExpFlags.every(v=>s[v]),m=!c.minimumCliVersion||vi(i,`>=${c.minimumCliVersion}`),h=!c.deprecatedFromCliVersion||vi(i,`<${c.deprecatedFromCliVersion}`),g=m&&h,f=tu(i)&&c.deprecatedFromCliVersion===void 0;return d&&p&&(g||f)})}function Lc(e){switch(e){case"extension":case"configuration":case"deprecated":return e;default:return S(`Unknown specification experience value "${e}", defaulting to "extension"`),"extension"}}function DN(e){switch(e){case"UidStrategiesDynamic":return"dynamic";case"UidStrategiesStatic":return"single";case"UidStrategiesClientProvided":return"uuid";default:return"uuid"}}function My(e,t){return e.map(n=>{let{externalId:i,primaryDomain:o,name:r,url:a,storeType:s}=n,c=a??o;if(!c)throw new L("The selected store does not have a valid URL");return{shopId:i?qy(i):void 0,link:o,shopDomain:K(c),shopName:r,transferDisabled:!0,convertableToPartnerTest:!0,provisionable:t,storeType:s}})}function Ly(e){return{registrationId:e.userIdentifier===e.uuid?"":e.userIdentifier,registrationUuid:e.uuid,registrationTitle:e.handle,type:e.specification.externalIdentifier,config:e.config,target:e.target??"",specification:{...e.specification,identifier:e.specification.identifier,options:{managementExperience:e.specification.managementExperience},experience:Lc(e.specification.experience)}}}var RN=async({organizationId:e,jwtToken:t,cursor:n,filters:i})=>{let o=await Mm(e,n,i),r=Om(t);return ia(o,{method:"GET",headers:r})};function $y(e){let t=[],n=e.on[0]?.user_identifier;return n&&t.push({extension_id:n}),{...e,details:t}}function UN(e){return[{field:"STORE_TYPE",operator:"EQUALS",value:e.toLowerCase()},{field:"STORE_STATUS",operator:"EQUALS",value:"ACTIVE"}]}function Vy(e){return e.includes("ondemand_access_to_stores")}var wt;(function(e){e.AppManagement="app-management",e.Partners="partners"})(wt||(wt={}));function us(){let e=[];return e.push(To.getInstance()),Nl()||e.push(Fn.getInstance()),e}function Fi({organization:e}={}){return e?ON(e):MN()}function ON(e){return e.source===kt.BusinessPlatform?To.getInstance():Fn.getInstance()}function MN(){return _n()&&!Nl()?Fn.getInstance():To.getInstance()}var jy;jy||(jy={});var LN={};function Ar(e=[]){let t=[],n=e.map(i=>LN[i]);return t.filter(i=>!n.includes(i))}var Vc=new WeakMap;function ps(e,t="default"){return{type:"token_refresh",handler:async()=>{let n=Vc.get(e);if(n)await n;else try{n=e.unsafeRefreshToken(),Vc.set(e,n),await n}finally{Vc.delete(e)}let i=await e.session();return{token:t==="businessPlatform"?i.businessPlatformToken:i.token}}}}var Ot=class extends y{constructor(t,n){let i="unknown",o=s=>`an ${s}`;so(t)?(i=t.orgName,o=s=>`the ${s} organization`):ao(t)&&(i=t.email,o=s=>`the ${s} user`);let r=w`${b.yellow(i)}`.value,a=[[`Your current active session is associated with ${o(r)} account. To start a new session with a different account, run`,{command:"shopify auth login"}],["Have you",{link:{label:"created a Shopify Partners organization",url:"https://partners.shopify.com/signup"}},{char:"?"}],["Does your account include",{subdued:"Manage app"},"permissions?, please contact the owner of the organization to grant you access."],"Have you confirmed your accounts from the emails you received?",["Need to connect to a different App or organization? Run the command again with",{command:"--reset"}]];n&&a.push(["Do you have access to the right Shopify Partners organization? The CLI is loading",{link:{label:"this organization",url:`https://partner.shopify.com/${n}`}}]),super("No Organization found",void 0,a)}};async function ms(){let e=[];for(let t of us()){let n=await t.organizations();e.push(...n)}if(e.length===0){let t=Fi(),n=await t.session(),i=await ss(t,n.userId);throw new Ot(i)}return e}async function By(e,t){return(await t.appPreviewMode({apiKey:e})).app?.developmentStorePreviewEnabled}async function fs(e,t){let n=await t.orgFromId(e);if(!n)throw new Ot((await t.session()).accountInfo,e);return n}async function hs(e,t,n,i=["APP_DEVELOPMENT"]){let o=await n.storeByDomain(e.id,t,i);if(!o){let a=i.length===1&&i[0]==="APP_DEVELOPMENT"?"Ensure you have provided the correct store domain, that the store is a dev store, and that you have access to the store.":"Ensure you have provided the correct store domain and that you have access to the store.";throw new y(`Could not find store for domain ${t} in organization ${e.businessName}.`,a)}return o}l();l();l();l();async function zy(e,t,n="extension"){return De({message:`Match ${e.handle} (local name) with ${t.title} (name on Shopify Partners, ID: ${t.id})?`,confirmationMessage:`Yes, match to existing ${n}`,cancellationMessage:`No, create as a new ${n}`})}async function Wy(e,t){let n=t.map(o=>({label:`Match it to ${o.title} (ID: ${o.id} on Shopify Partners)`,value:o.uuid}));n.push({label:"Create new extension",value:"create"});let i=await Ge({message:`How would you like to deploy your "${e.handle}"?`,choices:n});return t.find(o=>o.uuid===i)}async function Pi(e,t=!0){let n=e.map(({local:s})=>`"${s.handle}"`).join(", "),i=e.map(({remote:s})=>s.type.toLocaleLowerCase()),o=i.filter((s,c)=>i.indexOf(s)===c).map(s=>`"${s}"`).join(", "),r=e.map(({local:s})=>`"${s.type}"`).join(", ");oe({headline:"Extension migrations can't be undone.",body:`Your ${n} configuration has been updated. Migrating gives you access to new features and won't impact the end user experience. All previous extension versions will reflect this change.`});let a=t?`Yes, confirm migration from ${o} to ${r}`:"Yes, confirm migration";return De({message:`Migrate ${n}?`,confirmationMessage:a,cancellationMessage:"No, cancel"})}async function Hy(e){let t={},n=e.remote,i=e.local;for(let o of e.local){let r=n.filter(s=>s.type===o.graphQLType);if(r.length===0)continue;let a=await Wy(o,r);a&&(t[o.localIdentifier]=a.uuid,n=n.filter(s=>s.uuid!==a.uuid),i=i.filter(s=>s.localIdentifier!==o.localIdentifier))}return{identifiers:t,toCreate:i,onlyRemote:n}}l();var $N=(e,t)=>(t.type.toLowerCase()===e.graphQLType.toLowerCase()||t.type.toLowerCase()===e.externalType.toLowerCase()||t.type.toLowerCase()===e.type.toLowerCase())&&te(t.title)===te(e.handle);function Gy(e,t){let n=bl(e,p=>[p.graphQLType,p.handle]),i=bl(t,p=>[p.type,p.title]),o={};n.forEach(p=>{let m=i.find(h=>$N(p,h));m&&(o[p.localIdentifier]=m.uuid)});let r=e.filter(p=>!o[p.localIdentifier]),a=t.filter(p=>!Object.values(o).includes(p.uuid)),{toConfirm:s,toCreate:c,toManualMatch:d}=jN(r,a);return{matched:o,toCreate:c,toConfirm:s,toManualMatch:d}}function VN(e,t,n){let i={},o=[],r={};e.forEach(g=>{let f=t.find(_=>_.id===g.uid),v=t.find(_=>_.uuid===n[g.localIdentifier]);f?i[g.localIdentifier]=f.id:v&&v.id.length===0?r[g.localIdentifier]=v.uuid:o.push(g)});let a=t.filter(g=>!Object.values(r).includes(g.uuid)&&!Object.values(i).includes(g.id)&&g.id.length===0),{matched:s,toCreate:c,toConfirm:d,toManualMatch:p}=Gy(o,a),m={...r,...s},h=e.filter(g=>m[g.localIdentifier]);return qN(h),{matched:{...i,...m},toCreate:c,toConfirm:d,toManualMatch:p}}function qN(e){if(e.length===0)return;let t=[ve.cyan,ve.magenta,ve.blue,ve.green,ve.yellow,ve.red],n=e.reduce((i,o)=>Math.max(i,o.handle.length),0);q(`Generating extension IDs
|
|
732
|
-
`),e.forEach((i,o)=>{let r=t[o%t.length]??ve.white;q(`${r(i.handle.padStart(n))} | Added ID: ${i.uid}`)}),q(`
|
|
733
|
-
`)}function jN(e,t){let n=Yt(e,"graphQLType"),i=Object.values(vn(n,(g,f)=>g.length===1)).flat(),o=t.map(g=>({...g,type:g.type.toLowerCase()})),r=Yt(o,"type"),a=vn(r,(g,f)=>g.length===1),s=[],c=[];for(let g of i){let f=a[g.graphQLType.toLowerCase()];f&&f[0]?s.push({local:g,remote:f[0]}):c.push(g)}let d=Sl(e,i),p=Sl(o,s.map(g=>g.remote)),[m,h]=ho(d,g=>p.map(f=>f.type.toLowerCase()).includes(g.graphQLType.toLowerCase()));return c.push(...h),{toCreate:c,toConfirm:s,toManualMatch:{local:m,remote:p}}}async function Ky(e,t,n,i){let o=i.supportsAtomicDeployments,r=qc(e,n),a=Object.values(r),s=f=>t.some(v=>v.type!==i.toExtensionGraphQLType(f.graphQLType)?!1:r[f.localIdentifier]===v.uuid),c=e.filter(f=>!s(f)),d=t.filter(f=>!a.includes(f.uuid)),{matched:p,toCreate:m,toConfirm:h,toManualMatch:g}=o?VN(e,t,r):Gy(c,d);return{identifiers:{...r,...p},toConfirm:h,toCreate:m,toManualMatch:g}}function qc(e,t){let n=e.map(i=>i.localIdentifier);return vn(t,(i,o)=>n.includes(o))}l();async function jc(e,t,n,i,o){let r={apiKey:e,type:t,title:n,config:JSON.stringify({}),context:o??null,handle:n},a=await i.createExtension(r);if(a.extensionCreate.userErrors?.length>0){let s=a.extensionCreate.userErrors.map(c=>c.message).join(", ");throw new y(s)}return a.extensionCreate.extensionRegistration}l();async function Yy(e){let{extensionsToMigrate:t,appId:n,remoteExtensions:i,migrationClient:o}=e;return await Promise.all(t.map(({remote:r})=>BN({apiKey:n,registrationId:void 0,registrationUuid:r.uuid,migrationClient:o}))),i.map(r=>t.some(({remote:a})=>a.uuid===r.uuid)?{...r,type:"UI_EXTENSION"}:r)}async function BN(e){let{apiKey:t,registrationId:n,registrationUuid:i,migrationClient:o}=e,r={apiKey:t,registrationId:n,registrationUuid:i},a=await o.migrateToUiExtension(r);if(a?.migrateToUiExtension?.userErrors?.length>0){let s=a.migrateToUiExtension.userErrors.map(c=>c.message).join(", ");throw new y(s)}if(!a?.migrateToUiExtension?.migratedToUiExtension)throw new y("Couldn't migrate to UI extension")}l();async function Qy(e){let{extensionsToMigrate:t,appId:n,remoteExtensions:i,migrationClient:o}=e;await Promise.all(t.map(({remote:s})=>zN({apiKey:n,registrationId:void 0,registrationUuid:s.uuid,migrationClient:o})));let r=new Map([["flow_action_definition","FLOW_ACTION"],["flow_trigger_definition","FLOW_TRIGGER"]]),a=t.map(({remote:s})=>s.uuid);return i.filter(s=>a.includes(s.uuid)).map(s=>({...s,type:r.get(s.type)??s.type}))}async function zN(e){let{apiKey:t,registrationId:n,registrationUuid:i,migrationClient:o}=e,r={apiKey:t,registrationId:n,registrationUuid:i},a=await o.migrateFlowExtension(r);if(a?.migrateFlowExtension?.userErrors?.length>0){let s=a.migrateFlowExtension.userErrors.map(c=>c.message).join(", ");throw new y(s)}if(!a?.migrateFlowExtension?.migratedFlowExtension)throw new y("Couldn't migrate to Flow extension");return n}l();var Jy={payments_extension:["payments_app","payments_app_credit_card","payments_app_custom_credit_card","payments_app_custom_onsite","payments_app_redeemable"]},Xy={marketing_activity:["marketing_activity_extension"]},Zy={flow_action:["flow_action_definition"],flow_trigger:["flow_trigger_definition"],flow_trigger_lifecycle_callback:["flow_trigger_discovery_webhook"]},ev={ui_extension:["CHECKOUT_UI_EXTENSION","POS_UI_EXTENSION"]},tv={subscription_link_extension:["subscription_link"]},nv={admin_link:["app_link","bulk_action"]};function Ii(e,t,n,i){let o=qc(e,n),r=Object.keys(i),a=Object.values(i).flat(),s=e.filter(p=>r.includes(p.type)),c=t.filter(p=>a.includes(p.type)),d=new Map;return c.forEach(p=>{d.set(p.uuid,p),d.set(te(p.title.substring(0,Ee)),p)}),s.reduce((p,m)=>{let h=o[m.localIdentifier]??"unknown",g=d.get(h)??d.get(m.localIdentifier.toLowerCase()),f=i[m.type]?.includes(g?.type??"undefined");return g&&f&&p.push({local:m,remote:g}),p},[])}async function Ir(e){let{extensionsToMigrate:t,appId:n,type:i,remoteExtensions:o,migrationClient:r}=e;await Promise.all(t.map(({remote:s})=>WN({apiKey:n,registrationId:void 0,registrationUuid:s.uuid,type:i,migrationClient:r})));let a=t.map(({remote:s})=>s.uuid);return o.filter(s=>a.includes(s.uuid)).map(s=>({...s,type:i.toUpperCase()}))}async function WN(e){let{apiKey:t,registrationId:n,registrationUuid:i,type:o,migrationClient:r}=e,a={apiKey:t,registrationId:n,registrationUuid:i,type:o},s=await r.migrateAppModule(a);if(s?.migrateAppModule?.userErrors?.length>0){let c=s.migrateAppModule.userErrors.map(d=>d.message).join(", ");throw new y(c)}if(!s?.migrateAppModule?.migratedAppModule)throw new y(`Couldn't migrate to app module ${o}`);return n}async function iv(e,{extensionRegistrations:t,dashboardManagedExtensionRegistrations:n}){let i=t,o=e.envIdentifiers.extensions??{},r=e.app.allExtensions.filter(E=>!E.isAppConfigExtension),a=Ii(r,i,o,ev),s=Ii(r,n,o,Zy),c=Ii(r,n,o,Jy),d=Ii(r,n,o,Xy),p=Ii(r,n,o,tv),m=Ii(r,n,o,nv),g=e.developerPlatformClient.clientName===wt.Partners?e.developerPlatformClient:Fn.getInstance(),f=!1;if(a.length>0){if(!await Pi(a))throw new de;i=await Yy({extensionsToMigrate:a,appId:e.appId,remoteExtensions:i,migrationClient:g}),f=!0}if(s.length>0){if(!await Pi(s,!1))throw new de;let A=await Qy({extensionsToMigrate:s,appId:e.appId,remoteExtensions:n,migrationClient:g});i=i.concat(A),f=!0}if(d.length>0){if(!await Pi(d,!1))throw new de;let A=await Ir({extensionsToMigrate:d,appId:e.appId,type:"marketing_activity",remoteExtensions:n,migrationClient:g});i=i.concat(A),f=!0}if(c.length>0){if(!await Pi(c,!1))throw new de;let A=await Ir({extensionsToMigrate:c,appId:e.appId,type:"payments_extension",remoteExtensions:n,migrationClient:g});i=i.concat(A),f=!0}if(p.length>0){if(!await Pi(p,!1))throw new de;let A=await Ir({extensionsToMigrate:p,appId:e.appId,type:"subscription_link_extension",remoteExtensions:n,migrationClient:g});i=i.concat(A),f=!0}if(m.length>0){if(!await Pi(m,!1))throw new de;let A=await Ir({extensionsToMigrate:m,appId:e.appId,type:"admin_link",remoteExtensions:n,migrationClient:g});i=i.concat(A),f=!0}let v=await Ky(r,i,o,e.developerPlatformClient),_=v.identifiers,x=v.toCreate??[];for(let E of v.toConfirm)await zy(E.local,E.remote)?_[E.local.localIdentifier]=E.remote.uuid:x.push(E.local);if(v.toManualMatch.local.length>0){let E=await Hy(v.toManualMatch);_={..._,...E.identifiers},x.push(...E.toCreate)}return{validMatches:_,extensionsToCreate:x,dashboardOnlyExtensions:n,didMigrateDashboardExtensions:f}}async function ov(e,t,n,{validMatches:i,extensionsToCreate:o}){let{uuidUidStrategyExtensions:r,singleAndDynamicStrategyExtensions:a}=YN(t,n,e.app.specifications||[]),{extensionsNonUuidManaged:s,extensionsIdsNonUuidManaged:c}=await KN(a,e.app,e.appId,e.includeDraftExtensions,e.developerPlatformClient),d={};if(o.length>0){let p=await rv(o,e.appId,e.developerPlatformClient);for(let[m,h]of Object.entries(p))i[m]=h.uuid,d[m]=h.id}for(let[p,m]of Object.entries(i)){let h=r.find(g=>g.uuid===m);h&&(d[p]=h.id)}return{extensions:i,extensionIds:{...d,...c},extensionsNonUuidManaged:s}}function HN(e,t){let n=e.activeVersion?.config,i=n?JSON.parse(n):{},o=t.configuration,r=i.uri??"";return i.topic===o.topic&&r.endsWith(o.uri)&&i.filter===o.filter}function GN(e,t,n,i,o,r){n.forEach(a=>{let s=e.filter(d=>d.type===t.toExtensionGraphQLType(a.graphQLType)),c;a.isSingleStrategyExtension&&s.length===1?c=s[0]:a.isDynamicStrategyExtension&&(c=s.find(d=>HN(d,a))),c?(o[a.localIdentifier]=c.uuid,r[a.localIdentifier]=c.id):i.push(a)})}async function KN(e,t,n,i=!1,o){let r=i?t.draftableExtensions:t.allExtensions;r=r.filter(d=>!d.isUUIDStrategyExtension);let a=[],s={},c={};if(GN(e,o,r,a,s,c),a.length>0){let d=await rv(a,n,o,!1);for(let[p,m]of Object.entries(d))s[p]=m.uuid,c[p]=m.id}return{extensionsNonUuidManaged:s,extensionsIdsNonUuidManaged:c}}async function rv(e,t,n,i=!0){let o={};for(let r of e)if(n.supportsAtomicDeployments)o[r.localIdentifier]={id:r.uid,uuid:r.uid,type:r.type,title:r.handle};else{let a=await jc(t,r.graphQLType,r.handle,n,r.contextValue);i&&po(`Created extension ${r.handle}.`),o[r.localIdentifier]=a}return o}function YN(e,t,n){let i=n.filter(s=>s.uidStrategy==="dynamic").map(s=>s.identifier),r=Yt(e,s=>i.includes(s.type.toLowerCase())),a=t.concat(r.true??[]);return{uuidUidStrategyExtensions:r.false??[],singleAndDynamicStrategyExtensions:a}}l();l();async function av(e,t,n){let i=await QN(e,t,n),{app:{versionsDiff:o}}=await n.appVersionsDiff(e,{versionId:i.uuid,appVersionId:i.id});return{versionsDiff:o,versionDetails:i}}async function QN(e,t,n){try{return await n.appVersionByTag(e,t)}catch{throw Te({headline:"Version couldn't be released.",body:["Version",{userInput:t},"could not be found."]}),new de}}l();function JN(e,t){return t?e.find(i=>i.identifier===t||i.externalIdentifier===t||i.additionalIdentifiers?.includes(t))?.uidStrategy:void 0}async function Fo(e,t,n,i,o){let a=(o??await t.activeAppVersion(e))?.appModuleVersions.filter(c=>JN(n,c.specification?.identifier)!=="uuid")??[];return a.length===0?void 0:Bc(a,n,i)}function Bc(e,t,n){let i={},o=t.filter(Ei);return e.forEach(r=>{let a=o.find(c=>c.identifier===r.specification?.identifier.toLowerCase());if(!a)return;let s=r.config;s&&(i=rt(i,a.transformRemoteToLocal?.(s,{flags:n})??s))}),{...i}}l();async function sv(e,t){S(`Writing app configuration to ${t}`);let n=ZN(structuredClone(e)),i=zc(n),o=new _e(t,{});await o.replace(i),await o.transformRaw(XN)}function zc(e){if(e==null)return e;if(Array.isArray(e))return e.map(zc);if(typeof e=="object"){let t={};for(let[n,i]of Object.entries(e)){let o=zc(i);typeof o=="object"&&o!==null&&!Array.isArray(o)&&Object.keys(o).length===0||(t[n]=o)}return t}return e}var Di=(e,t)=>{if(e==null)return null;if(e instanceof u.ZodNullable||e instanceof u.ZodOptional)return Di(e.unwrap(),t);if(e instanceof u.ZodArray)return t.map(n=>Di(e.element,n));if(e instanceof u.ZodEffects)return Di(e._def.schema,t);if(e instanceof u.ZodObject){let n=Object.entries(e.shape),i=t,o={};n.forEach(([a,s])=>{if(i!==void 0&&i[a]!==void 0){let c=Di(s,i[a]);!(c instanceof Array)&&c instanceof Object&&Object.keys(c).length===0&&(c=void 0),o={...o,[a]:c}}});let r=["scopes"];return Object.entries(i).filter(([a])=>!r.includes(a)).sort(([a,s])=>a.localeCompare(a)).forEach(([a,s])=>{n.map(([c])=>c).includes(a)||(o={...o,[a]:s})}),o}return t};function XN(e){let t=`# Learn more about configuring your app at https://shopify.dev/docs/apps/tools/cli/configuration
|
|
734
|
-
`,n=`
|
|
735
|
-
# Learn more at https://shopify.dev/docs/apps/tools/cli/configuration#access_scopes`,i=e.split(/(\r\n|\r|\n)/);return i.unshift(`
|
|
736
|
-
`),i.unshift(t),i.forEach((o,r)=>{o==="[access_scopes]"&&i.splice(r+1,0,n)}),i.join("")}function ZN(e){let t=e.webhooks;if(Array.isArray(t?.subscriptions)&&t.subscriptions.length){let n=et(e?.application_url);t.subscriptions=Sc(t.subscriptions),t.subscriptions=t.subscriptions.map(({uri:i,...o})=>({uri:n&&i.includes(n)?i.replace(n,""):i,...o}))}return e}l();function gs(){let e=["Your app has extensions which need to be assigned",{command:"uid"},"identifiers."],t=["You must first map IDs to your existing extensions by running",{command:"shopify app deploy"},"interactively, without",{command:"--allow-updates"},"or",{command:"--allow-deletes"},", to finish the migration."],n={title:"Reference",body:{list:{items:[{link:{label:"Migrating from the Partner Dashboard",url:"https://shopify.dev/docs/apps/build/dev-dashboard/migrate-from-partners"}}]}}};throw new y(e,void 0,[t],[n])}function Ri(e,t){return{title:e,uid:t,experience:"extension"}}function Dr(e){return{title:e,uid:void 0,experience:"dashboard"}}async function cv(e){let t=await lv(e);e.force&&!e.developerPlatformClient.supportsDashboardManagedExtensions&&t.app.extensionRegistrations.filter(r=>!r.id).length>0&&gs();let n=await iv(e,t.app);if(n.didMigrateDashboardExtensions){let o=await e.developerPlatformClient.activeAppVersion(e.remoteApp);e.activeAppVersion=o}n.dashboardOnlyExtensions.length>0&&(t=await lv({...e,activeAppVersion:void 0}));let i=iA(n);return e.release&&(i=await oA(e.developerPlatformClient,e.remoteApp,n.validMatches,n.extensionsToCreate,n.dashboardOnlyExtensions,e.app.specifications??[],e.activeAppVersion)??i),{extensionIdentifiersBreakdown:i,extensionsToConfirm:n,remoteExtensionsRegistrations:t.app}}async function pv(e,t,n){let{versionsDiff:i,versionDetails:o}=await av(t,n,e),r=c=>c.filter(d=>d.specification.experience==="extension"&&d.specification.identifier!=="webhook_subscription").map(d=>Ri(d.registrationTitle,void 0)),a=c=>c.filter(d=>d.specification.options.managementExperience==="dashboard").map(d=>Dr(d.registrationTitle));return{extensionIdentifiersBreakdown:{onlyRemote:[...r(i.removed),...a(i.removed)],toCreate:[...r(i.added),...a(i.added)],toUpdate:[],unchanged:[...r(i.updated),...a(i.updated)]},versionDetails:o}}async function ys({developerPlatformClient:e,remoteApp:t,localApp:n,versionAppModules:i,release:o,activeAppVersion:r}){if(n.allExtensions.filter(a=>a.isAppConfigExtension).length!==0)return o?tA(e,t,n,i,r):eA(n)}function eA(e){return{existingFieldNames:hc(e.configuration),existingUpdatedFieldNames:[],newFieldNames:[],deletedFieldNames:[]}}async function lv(e){return e.developerPlatformClient.appExtensionRegistrations(e.remoteApp,e.activeAppVersion)}async function tA(e,t,n,i,o){let r=await Fo(t,e,n.specifications??[],n.remoteFlags,o)??{},a=i?Bc(i,n.specifications??[],n.remoteFlags):n.configuration;a?.webhooks?.subscriptions?.length&&(a.webhooks.subscriptions=a.webhooks.subscriptions.map(v=>(v.uri.startsWith("/")&&(v.uri=`${et(a.application_url)}${v.uri}`),v)),a.webhooks.subscriptions.sort((v,_)=>{let x=v.uri+(v.topics?.sort().join(",")??""),E=_.uri+(_.topics?.sort().join(",")??"");return x.localeCompare(E)}),r.webhooks?.subscriptions?.sort((v,_)=>{let x=v.uri+(v.topics?.sort().join(",")??""),E=_.uri+(_.topics?.sort().join(",")??"");return x.localeCompare(E)}));let s=nA(a,r,n.configSchema),c=hc(a),d=s?.baselineFieldNames??[],p=s?.updatedFieldNames??[],m=c.filter(v=>!d.includes(v)&&!p.includes(v)),h=c.filter(v=>d.includes(v)&&p.includes(v)),g=p.filter(v=>!d.includes(v)&&c.includes(v)),f=d.filter(v=>!p.includes(v)&&v!=="handle");return{existingFieldNames:m,existingUpdatedFieldNames:h,newFieldNames:g,deletedFieldNames:f}}function nA(e,t,n){let[i,o]=Jd({...Di(n,e),build:void 0},{...Di(n,t),build:void 0});if(kn(i,o))return;let r=a=>Object.entries(a).filter(([s,c])=>c!==void 0).map(([s])=>s);return{updatedFieldNames:r(i),baselineFieldNames:r(o)}}function iA({validMatches:e,extensionsToCreate:t,dashboardOnlyExtensions:n}){let i=Object.keys(e).map(a=>Ri(a,void 0)),o=t.map(a=>Ri(a.localIdentifier,void 0)),r=n.filter(a=>!Object.values(e).includes(a.uuid)).map(a=>Dr(a.title));return{onlyRemote:[],toCreate:[],toUpdate:[],unchanged:[...i,...o,...r]}}async function oA(e,t,n,i,o,r,a){let s=a??await e.activeAppVersion(t);if(!s)return;let c=rA(s,n,i,r,e),d=o.filter(m=>!Object.values(n).includes(m.uuid)&&!i.map(h=>h.localIdentifier).includes(m.uuid)),p=aA(d,s);return{onlyRemote:[...c.onlyRemote,...p.onlyRemote],toCreate:[...c.toCreate,...p.toCreate],toUpdate:[...c.toUpdate,...p.toUpdate],unchanged:[...c.unchanged,...p.unchanged]}}function rA(e,t,n,i,o){let r=e?.appModuleVersions.filter(f=>{let v=i.find(_=>_.identifier===f.specification?.identifier||_.externalIdentifier===f.specification?.identifier);return v&&!Ei(v)});function a(f,v){let _=f.registrationUuid===v,x=f.registrationId===v,E=f.registrationId.length===0;return o.supportsAtomicDeployments?x||E&&_:_}let s=Object.entries(t).filter(([f,v])=>r.some(_=>a(_,v))).map(([f,v])=>f),c=r.filter(f=>f.registrationId===""),d=s.filter(f=>c.some(v=>v.registrationUuid===t[f])),p=s.filter(f=>!c.some(v=>v.registrationUuid===t[f])),m=Object.entries(t).filter(([f,v])=>!r.some(_=>a(_,v))).map(([f,v])=>({title:f,uid:v}));return n.map(f=>({title:f.localIdentifier,uid:f.uid})).forEach(f=>{let v=m.findIndex(_=>_.title===f.title);v===-1?m.push(f):m[v]=f}),{onlyRemote:r.filter(f=>!Object.values(t).some(v=>a(f,v))&&!n.map(v=>v.localIdentifier).some(v=>a(f,v))).map(f=>({title:f.registrationTitle,uid:f.registrationId})).map(({title:f,uid:v})=>Ri(f,v)),toCreate:m.map(({title:f,uid:v})=>Ri(f,v)),toUpdate:d.map(f=>Ri(f,void 0)),unchanged:p.map(f=>Ri(f,void 0))}}function aA(e,t){let n=t?.appModuleVersions.filter(d=>d.specification.options.managementExperience==="dashboard")||[],i=d=>!e.map(p=>p.uuid).includes(d.registrationUuid),o=n.filter(i).map(d=>Dr(d.registrationTitle)),r=d=>n.map(p=>p.registrationUuid).includes(d.uuid),a=d=>!r(d),s=e.filter(a).map(d=>Dr(d.title)),c=e.filter(r).map(d=>Dr(d.title));return{onlyRemote:o,toCreate:s,toUpdate:[],unchanged:c}}l();l();var sA={bullet:"+",color:"green",suffix:"(new)"},lA={color:"#FF8800",suffix:"(updated)"},cA={bullet:"-",color:"red",suffix:"(removed)"};function Hc(e){return[...e.new.map(t=>Wc(t,sA)),...e.updated?e.updated.map(t=>Wc(t,lA)):[],...e.unchanged,...e.removed.map(t=>Wc(t,cA))]}function Wc(e,t){let n=typeof e=="string"?[e,{subdued:t.suffix??""}]:e;return{...t.bullet?{bullet:t.bullet}:{},item:n,color:t.color}}function pA({force:e,allowUpdates:t,allowDeletes:n,extensionIdentifiersBreakdown:i,configExtensionIdentifiersBreakdown:o}){if(e||t&&n)return!0;let r=i.onlyRemote.length>0,a=(o?.deletedFieldNames.length??0)>0,s=r||a,c=i.toCreate.length>0||i.toUpdate.length>0,d=(o?.newFieldNames.length??0)>0||(o?.existingUpdatedFieldNames.length??0)>0,p=c||d;if(t&&!s||n&&!p)return!0;if(!wi()&&(s||p)){let m=[];throw p&&m.push("--allow-updates"),s&&m.push("--allow-deletes"),new y("This deployment includes changes that require confirmation.",["Run the command with",{command:m.join(" ")},"to deploy without confirmation."])}return!1}async function vs({force:e,allowUpdates:t,allowDeletes:n,extensionIdentifiersBreakdown:i,configExtensionIdentifiersBreakdown:o,appTitle:r,release:a,installCount:s}){if(await Q.addPublicMetadata(()=>fA(o)),pA({force:e,allowUpdates:t,allowDeletes:n,extensionIdentifiersBreakdown:i,configExtensionIdentifiersBreakdown:o}))return!0;let d=await uA(i),p=await mA(a,o);return dA({appTitle:r,extensionsContentPrompt:d,configContentPrompt:p,release:a,installCount:s})}async function dA({appTitle:e,extensionsContentPrompt:{extensionsInfoTable:t,hasDeletedExtensions:n},configContentPrompt:i,release:o,installCount:r}){let a=new Date().valueOf(),s=!0,c=[];i&&c.push(i.configInfoTable.items.length===0?{...i.configInfoTable,emptyItemsText:"No changes",items:[]}:i.configInfoTable);let d=e!==void 0&&n;t?c.push(d?{...t,helperText:"Removing extensions can permanently delete app user data"}:t):c.push({header:"Extensions:",emptyItemsText:"None",items:[]});let p=`${o?"Release":"Create"} a new version${e?` of ${e}`:""}?`,m=n&&r!==void 0&&r>0;d?s=await Eu({message:p,infoTable:c,confirmation:e,...m?{warningItem:["This release removes extensions and related data from",{error:r.toString()},`app installations.
|
|
737
|
-
Use caution as this may include production data on live stores.`]}:{}}):s=await De({message:p,infoTable:c,confirmationMessage:`Yes, ${o?"release":"create"} this new version`,cancellationMessage:"No, cancel"});let h=new Date().valueOf()-a;return await Q.addPublicMetadata(()=>({cmd_deploy_confirm_cancelled:!s,cmd_deploy_confirm_time_to_complete_ms:h})),s}async function uA(e){let{onlyRemote:t,toCreate:n,toUpdate:i,unchanged:o}=e,r=(p,m)=>{switch(p.experience){case"dashboard":return[p.title,{subdued:`(${m}from Partner Dashboard)`}];case"extension":return p.uid&&p.uid.length>0?`${p.title} (uid: ${p.uid})`:p.title}},a,s={new:n.map(p=>r(p,"new, ")),unchanged:o.map(p=>r(p,"")),updated:i.map(p=>r(p,"updated, ")),removed:t.map(p=>r(p,"removed, "))},c=Hc(s),d=t.length>0;return c.length>0&&(a={header:"Extensions:",items:c}),await Q.addPublicMetadata(()=>({cmd_deploy_confirm_new_registrations:n.length,cmd_deploy_confirm_updated_registrations:i.length,cmd_deploy_confirm_removed_registrations:t.length})),{extensionsInfoTable:a,hasDeletedExtensions:d}}async function mA(e,t){if(!t)return;let{existingFieldNames:n,existingUpdatedFieldNames:i,newFieldNames:o,deletedFieldNames:r}=t,s=Hc({new:o,updated:i,unchanged:n,removed:r});return{configInfoTable:{header:"Configuration:",items:o.length>0||i.length>0||r.length>0||!e?s:[]}}}function fA(e){if(!e)return{cmd_deploy_include_config_used:!1};let{existingFieldNames:t,existingUpdatedFieldNames:n,newFieldNames:i,deletedFieldNames:o}=e,r=[...n,...i,...t];return{cmd_deploy_include_config_used:!0,...r.length>0?{cmd_deploy_config_modules_breakdown:JSON.stringify(r.sort())}:{},...n.length>0?{cmd_deploy_config_modules_updated:JSON.stringify(n.sort())}:{},...i.length>0?{cmd_deploy_config_modules_added:JSON.stringify(i.sort())}:{},...o.length>0?{cmd_deploy_config_modules_deleted:JSON.stringify(o.sort())}:{}}}async function ks(e){let{extensionIdentifiersBreakdown:t,extensionsToConfirm:n,remoteExtensionsRegistrations:i}=await cv(e),o=await ys({developerPlatformClient:e.developerPlatformClient,apiKey:e.appId,localApp:e.app,remoteApp:e.remoteApp,release:e.release,activeAppVersion:e.activeAppVersion}),r=t.onlyRemote.length>0&&!e.force&&!(e.allowUpdates&&e.allowDeletes),a;if(r)try{a=await e.developerPlatformClient.appInstallCount({id:e.remoteApp.id,apiKey:e.remoteApp.apiKey,organizationId:e.remoteApp.organizationId})}catch{a=void 0}if(!await vs({extensionIdentifiersBreakdown:t,configExtensionIdentifiersBreakdown:o,appTitle:e.remoteApp?.title,release:e.release,force:e.force,allowUpdates:e.allowUpdates,allowDeletes:e.allowDeletes,installCount:a}))throw new de;let c=await ov(e,i.extensionRegistrations,i.configurationRegistrations,n);return{app:e.appId,extensions:c.extensions,extensionIds:c.extensionIds,extensionsNonUuidManaged:c.extensionsNonUuidManaged}}l();function ws({appName:e,org:t,devStores:n,updateURLs:i,includeConfigOnDeploy:o,messages:r}){let a=[`App: ${e}`];t&&a.unshift(`Org: ${t}`),n&&n.length>0&&n.forEach(c=>a.push(`Dev store: ${c}`)),i&&a.push(`Update URLs: ${i}`),o!==void 0&&a.push(`Include config: ${o?"Yes":"No"}`);let s=[{list:{items:a}}];if(r&&r.length)for(let c=0;c<r.length;c++){let d=r[c];if(!d||d.length===0)continue;let p=c===0?`
|
|
738
|
-
`:`
|
|
739
|
-
|
|
740
|
-
`;s=s.concat(p,d)}return s}l();async function Ui({app:e,identifiers:t,command:n,developerPlatformClient:i},o=process.env){let r=e.dotenv;r??(r={path:k(e.directory,is(e.configPath)),variables:{}});let a={...e.dotenv?.variables??{}};o[e.idEnvironmentVariableName]||(a[e.idEnvironmentVariableName]=t.app),Object.keys(t.extensions).forEach(d=>{let p=`SHOPIFY_${Xr(d)}_ID`;o[p]||(a[p]=t.extensions[d])});let c=!kn(r.variables,a)&&(n==="deploy"||n==="release")&&!i.supportsAtomicDeployments||n==="import-extensions";if(r.variables=a,c){let p=await C(r.path)?await P(r.path):"",m=ur(p,a);await ie(r.path,m),e.dotenv=r}return e}function _s({app:e},t=process.env){let n={...e.dotenv?.variables,...t},i={},o=r=>{Object.keys(n).includes(r.idEnvironmentVariableName)&&(i[r.localIdentifier]=n[r.idEnvironmentVariableName])};return e.allExtensions.forEach(o),{app:n[e.idEnvironmentVariableName],extensions:i}}var dv=e=>({message:w`Invalid Client ID: ${e}`,tryMessage:w`You can find the Client ID in the app settings in the Developer Dashboard.`}),bs=["You can pass",{command:"--reset"},"to your command to reset your app configuration."],hA=(e,t=!1)=>[{list:{title:"Next steps:",items:["Check that your account has permission to develop apps for this organization or contact the owner of the organization to grant you permission",["Run",{command:"shopify auth login"},"to log into a different",t?"organization":"account","than",{bold:e}],["Pass",{command:"--reset"},"to your command to create a new app"]]}}],Po=async e=>{let t=us(),n;for(let i of t)try{if(n=await i.appFromIdentifiers(e.apiKey),n)break}catch(o){if("statusCode"in o&&o.statusCode===404)continue;throw o}if(!n){let i=await t[0]?.accountInfo()??{type:"UnknownAccount"},o="Unknown account",r=!1;throw so(i)?(o=i.orgName,r=!0):ao(i)&&(o=i.email),new y(["No app with client ID",{command:e.apiKey},"found"],hA(o,r))}return n};async function uv(e){let{reset:t,force:n,noRelease:i,app:o,remoteApp:r,developerPlatformClient:a,organization:s}=e,c=await a.activeAppVersion(r),d=await gA({app:o,reset:t,force:n,developerPlatformClient:a});Io({org:s.businessName,appName:r.title,appDotEnv:o.dotenv?.path,configFile:$(o.configPath),includeConfigOnDeploy:d,messages:[bs]});let p=await ks({app:o,appId:r.apiKey,appName:r.title,force:n,release:!i,developerPlatformClient:a,envIdentifiers:_s({app:o}),remoteApp:r,activeAppVersion:c,allowUpdates:e.allowUpdates,allowDeletes:e.allowDeletes});await Ui({app:o,identifiers:p,command:"deploy",developerPlatformClient:a});let m=!1;return a.supportsAtomicDeployments&&c&&(m=c.appModuleVersions.some(h=>!h.registrationId)),{identifiers:p,didMigrateExtensionsToDevDash:m}}async function gA({app:e,reset:t,force:n,developerPlatformClient:i}){if(i.supportsAtomicDeployments){await yA(e);return}let o=e.includeConfigOnDeploy;if(t&&(o=void 0),n&&o===void 0){let r=["You must specify a value for",{command:"include_config_on_deploy"},"in your TOML file. Including configuration will be required very soon."],a=["Run",{command:"shopify app deploy"},"interactively, without",{command:"--allow-updates"},"or",{command:"--allow-deletes"},"."];throw new y(r,a)}return n||o===!0?o:wA({appDirectory:e.directory,localApp:e})}async function yA(e){let t=e.configuration.build?.include_config_on_deploy;if(t===void 0)return;await(await _e.read(e.configPath)).remove("build.include_config_on_deploy"),t?vA():kA()}function vA(){oe({headline:"Your configuration file has been modified",body:["The `include_config_on_deploy` field is no longer supported, since all apps must now include configuration on deploy. It has been removed from your configuration file."],link:{label:"See Shopify CLI documentation.",url:"https://shopify.dev/docs/apps/build/cli-for-apps/app-configuration#build"}})}function kA(){He({headline:"Configuration is now included on deploy",body:["The `include_config_on_deploy` field is no longer supported and has been removed from your configuration file. Review this file to ensure it's up to date with the correct configuration."],link:{label:"See Shopify CLI documentation.",url:"https://shopify.dev/docs/apps/build/cli-for-apps/app-configuration#build"}})}async function wA(e){let t=await _A(e.localApp.configPath);return e.localApp.configuration.build={...e.localApp.configuration.build,include_config_on_deploy:t},await(await _e.read(e.localApp.configPath)).patch({build:{include_config_on_deploy:t}}),await Q.addPublicMetadata(()=>({cmd_deploy_confirm_include_config_used:t})),t}function _A(e){return De({message:`Include \`${$(e)}\` configuration on \`deploy\`? Soon, this will no longer be optional and configuration will be included on every deploy.`,confirmationMessage:"Yes, always (Recommended)",cancellationMessage:"No, not now"})}async function mv(e){let t=await Gc(),n=Fi({organization:t}),{organization:i,apps:o,hasMorePages:r}=await n.orgAndApps(t.id),a=await _g(o,r,i,n,e);return await Oi(a,n.organizationSource),a}async function Gc(){let e=await ms();return await gg(e)}function fv({organization:e,app:t,remoteApp:n,selectedStore:i,tunnelMode:o}){if(Cd())return;let r="Not yet configured",a=t.configuration.build?.automatically_update_urls_on_dev;a!==void 0&&(r=a?"Yes":"No");let s=[bs];o==="use-localhost"&&s.push(["Note:",{command:"--use-localhost"},"is not compatible with Shopify features which directly invoke your app","(such as Webhooks, App proxy, and Flow actions), or those which require testing your app from another","device (such as POS)."]),Io({org:e.businessName,appName:n.title,devStore:i.shopDomain,updateURLs:r,configFile:$(t.configPath),messages:s})}function Io({org:e,appName:t,devStore:n,updateURLs:i,configFile:o,appDotEnv:r,includeConfigOnDeploy:a,messages:s}){let c=[];n&&c.push(n);let d=(r&&$(r))??(o&&dt(o));oe({headline:o?`Using ${d} for default values:`:"Using these settings:",body:ws({appName:t,org:e,devStores:c,updateURLs:i,includeConfigOnDeploy:a,messages:s})})}async function Oi(e,t){let i={[t===kt.BusinessPlatform?"business_platform_id":"partner_id"]:tr(e.organizationId)};await Q.addPublicMetadata(()=>({...i,api_key:e.apiKey}))}async function hv({apiKey:e,developerPlatformClient:t}){return Ss({apiKey:e,developerPlatformClient:t,enabled:!0})}async function gv({apiKey:e,developerPlatformClient:t}){await Ss({apiKey:e,developerPlatformClient:t,enabled:!1})}async function Ss({apiKey:e,developerPlatformClient:t,enabled:n}){let i={input:{apiKey:e,enabled:n}},r=(await t.updateDeveloperPreview(i)).developmentStorePreviewUpdate.userErrors;return!r||r.length===0}l();l();l();var bA=at.extend({app_proxy:u.object({url:u.preprocess(et,Gf(u.string({invalid_type_error:"Value must be string"}))),subpath:u.string({invalid_type_error:"Value must be a string"}),prefix:u.string({invalid_type_error:"Value must be a string"})}).optional()}),Kc="app_proxy",SA={forward:(e,t)=>{let n=e;if(!n.app_proxy)return{};let i;return"application_url"in t&&(i=t?.application_url),{url:An(n.app_proxy.url,i),subpath:n.app_proxy.subpath,prefix:n.app_proxy.prefix}},reverse:e=>{let t=e;return{app_proxy:{url:et(t.url),subpath:t.subpath,prefix:t.prefix}}}},xA=$e({identifier:Kc,schema:bA,transformConfig:SA,getDevSessionUpdateMessages:async e=>e.app_proxy?[`Using URL: ${e.app_proxy.url}`,"Any changes to prefix and subpath will only apply to new installs"]:[],patchWithAppDevURLs:(e,t)=>{t.appProxy&&(e.app_proxy={url:t.appProxy.proxyUrl,subpath:t.appProxy.proxySubPath,prefix:t.appProxy.proxySubPathPrefix})}}),yv=xA;l();var EA=at.extend({pos:u.object({embedded:u.boolean({invalid_type_error:"Value must be Boolean"})}).optional()}),Yc="point_of_sale",CA={embedded:"pos.embedded"},NA=$e({identifier:Yc,schema:EA,transformConfig:CA}),vv=NA;l();l();function kv(e,t){let n=e;if(!n.events?.subscription)return e;let i;return t&&"application_url"in t&&(i=t?.application_url),{...n,events:{...n.events,subscription:n.events.subscription.map(o=>({...o,uri:An(o.uri,i)}))}}}function wv(e){let t=Oe(e,"events"),n=Oe(t,"api_version"),o=Oe(t,"subscription")?.map(a=>{let{identifier:s,...c}=a;return c});return{events:n??o?{api_version:n,subscription:o}:{}}}var Qc="events",AA={forward:kv,reverse:e=>wv(e)},TA=at.extend({events:u.any().optional()}),FA=$e({identifier:Qc,schema:TA,transformConfig:AA}),_v=FA;l();var PA={forward:DA,reverse:e=>RA(e)},Xc="privacy_compliance_webhooks",IA=$e({identifier:Xc,schema:Co,transformConfig:PA}),bv=IA;function DA(e,t){let n=Oe(e,"webhooks"),i;"application_url"in t&&(i=t?.application_url);let o=Zd({customers_redact_url:Jc(UA(n),i),customers_data_request_url:Jc(OA(n),i),shop_redact_url:Jc(MA(n),i)});if(Object.keys(o).length===0)return o;{let{api_version:r}=n;return{api_version:r,...o}}}function RA(e){let t=Oe(e,"customers_redact_url"),n=Oe(e,"customers_data_request_url"),i=Oe(e,"shop_redact_url"),o=[];return n&&o.push({compliance_topics:[nn.CustomersDataRequest],uri:n}),t&&o.push({compliance_topics:[nn.CustomersRedact],uri:t}),i&&o.push({compliance_topics:[nn.ShopRedact],uri:i}),o.length===0?{}:{webhooks:{subscriptions:Ja(o),privacy_compliance:void 0}}}function Zc(e,t){return e.subscriptions?.find(n=>n.compliance_topics?.includes(t))?.uri}function Jc(e,t){return t&&e?.startsWith("/")?`${et(t)}${e}`:e}function UA(e){return Zc(e,"customers/redact")??e?.privacy_compliance?.customer_deletion_url}function OA(e){return Zc(e,"customers/data_request")??e?.privacy_compliance?.customer_data_request_url}function MA(e){return Zc(e,"shop/redact")??e?.privacy_compliance?.shop_deletion_url}l();var LA="@shopify/post-purchase-ui-extensions",$A=ge.extend({metafields:u.array(tn).optional()}),VA=le({identifier:"checkout_post_purchase",dependency:LA,partnersWebIdentifier:"post_purchase",schema:$A,appModuleFeatures:e=>["ui_preview","cart_url","esbuild","single_js_entry_path"],getOutputRelativePath:e=>`dist/${e.handle}.js`,clientSteps:[{lifecycle:"deploy",steps:[{id:"bundle-ui",name:"Bundle UI Extension",type:"bundle_ui",config:{}}]}],deployConfig:async(e,t)=>({metafields:e.metafields??[]})}),Sv=VA;l();var qA="@shopify/checkout-ui-extensions",jA=ge.extend({name:u.string(),extension_points:u.array(u.string()).optional(),metafields:u.array(tn).optional(),settings:u.object({fields:u.any().optional()}).optional()}),BA=le({identifier:"checkout_ui_extension",dependency:qA,schema:jA,appModuleFeatures:e=>["ui_preview","cart_url","esbuild","single_js_entry_path","generates_source_maps"],getOutputRelativePath:e=>`dist/${e.handle}.js`,clientSteps:[{lifecycle:"deploy",steps:[{id:"bundle-ui",name:"Bundle UI Extension",type:"bundle_ui",config:{}}]}],deployConfig:async(e,t)=>({extension_points:e.extension_points,capabilities:e.capabilities,supported_features:e.supported_features,metafields:e.metafields??[],name:e.name,settings:e.settings,localization:await yt(t,"checkout_ui")})}),xv=BA;l();l();l();var Qe={customer_reference:"customer_reference",order_reference:"order_reference",product_reference:"product_reference",marketing_activity_reference:"marketing_activity_reference",abandonment_reference:"abandonment_reference",company_reference:"company_reference",company_contact_reference:"company_contact_reference"},Ev=["customer","order","product","marketing_activity","abandonment","company","company_contact"],Cv=[Qe.customer_reference,Qe.order_reference,Qe.product_reference,Qe.company_reference,Qe.company_contact_reference],Nv=[Qe.customer_reference,Qe.order_reference,Qe.product_reference,Qe.marketing_activity_reference,Qe.abandonment_reference,Qe.company_reference,Qe.company_contact_reference],Ce={boolean:"boolean",email:"email",multiLineText:"multi_line_text_field",int:"number_integer",singleLineText:"single_line_text_field",url:"url",decimal:"number_decimal",schemaTypeReference:"schema_type_reference"},xs=[[Ce.boolean,"checkbox"],[Ce.email,"email"],[Ce.multiLineText,"text-multi-line"],[Ce.int,"int"],[Ce.singleLineText,"text-single-line"],[Ce.url,"url"],[Ce.decimal,"number"],[Ce.schemaTypeReference,"schema-type-reference"]],zA=[Ce.boolean,Ce.email,Ce.multiLineText,Ce.int,Ce.singleLineText,Ce.url,Ce.decimal],WA=[Ce.boolean,Ce.email,Ce.singleLineText,Ce.url,Ce.decimal,Ce.schemaTypeReference],Av=xs.filter(([e])=>zA.includes(e)),Tv=xs.filter(([e])=>WA.includes(e));l();l();var Es=async(e,t)=>{if(!t)return"";let n=await re(k(e,t));if(n.length>1)throw new Error("Multiple files found for schema path");if(n.length===0)throw new Error("No file found for schema path");return P(n[0])};l();var HA=new Map(Av),GA=new Map(Tv),KA=(e,t)=>{let n=t==="flow_action"?HA:GA,i=ep(e.type),o=i?n.get("schema_type_reference"):n.get(e.type);if(typeof e.key!="string")throw new y(`key property must be specified for non-commerce object fields in ${JSON.stringify(e)}`);if(!o)throw new y(`Field type ${e.type} is not supported on Flow ${t==="flow_action"?"Actions":"Triggers"}`);let r={name:e.key,description:e.description,uiType:o};return t==="flow_action"&&(r.label=e.name,r.required=e.required),i&&(r.typeRefName=e.type.replace("schema.","")),r},YA=(e,t)=>{if(t==="flow_trigger"&&!Cv.includes(e.type))throw new y(`Commerce object ${e.type} is not supported for Flow Triggers`);if(t==="flow_action"&&!Nv.includes(e.type))throw new y(`Commerce object ${e.type} is not supported for Flow Actions`);let n=e.type.replace("_reference",""),i={name:`${n}_id`,uiType:t==="flow_action"?"commerce-object-id":n,description:e.description};return n==="marketing_activity"&&(i.uiType="marketing-activity-id",i.marketingActivityCreateUrl=e.marketingActivityCreateUrl,i.marketingActivityDeleteUrl=e.marketingActivityDeleteUrl),t==="flow_action"&&(i.label=`${no(n)} ID`,i.required=e.required),i},Cs=(e,t)=>t?t.map(i=>Object.keys(Qe).includes(i.type)?YA(i,e):KA(i,e)):[];var tp=fc.extend({key:u.string().regex(/^[a-zA-Z\s]*$/,{message:"String must contain only alphabetic characters and spaces"}).optional()}),QA=bo.extend({type:u.literal("flow_trigger"),name:u.string(),schema:u.string().optional(),settings:u.object({fields:u.array(tp).optional()}).optional()}).refine(e=>{let t=e.settings?.fields??[],n=t.every((o,r)=>Ns(o,"flow_trigger",e.handle,r)),i=Pv(t,e.schema);return n&&i}),JA=le({identifier:"flow_trigger",schema:QA,appModuleFeatures:e=>[],deployConfig:async(e,t)=>({title:e.name,description:e.description,fields:Cs("flow_trigger",e.settings?.fields),schema_patch:await Es(t,e.schema)})}),Fv=JA;function Iv(e,t,n,i){let o=`'${e}' property must be a string for 'field[${i}]' ${JSON.stringify(t)} of flow extension '${n}'`;return{required_error:o,invalid_type_error:o}}var np=u.object({type:u.string(),description:u.string().optional()}).strict(),Ns=(e,t,n,i)=>{let o=Object.keys(Qe).includes(e.type);return o?o?np.extend({required:u.boolean().optional(),marketingActivityCreateUrl:u.string().optional(),marketingActivityDeleteUrl:u.string().optional()}).parse(e):np.parse(e):t==="flow_action"?np.extend({key:u.string(Iv("key",e,n,i)),name:u.string(Iv("name",e,n,i)),required:u.boolean().optional()}).parse(e):tp.parse(e)},Rr=e=>e.startsWith("https://"),ep=e=>e.startsWith("schema."),Dv=(e,t,n)=>{if(e||t){if(!e)throw new u.ZodError([{code:u.ZodIssueCode.custom,path:["extensions[0].config_page_url"],message:"To set a custom configuration page a `config_page_url` must be specified."}]);if(!t)throw new u.ZodError([{code:u.ZodIssueCode.custom,path:["extensions[0].config_page_preview_url"],message:"To set a custom configuration page a `config_page_preview_url` must be specified."}]);if(!n)throw new u.ZodError([{code:u.ZodIssueCode.custom,path:["extensions[0].validation_url"],message:"To set a custom configuration page a `validation_url` must be specified."}])}return!0},Pv=(e,t)=>{if(e.some(n=>ep(n.type))&&!t)throw new u.ZodError([{code:u.ZodIssueCode.custom,path:["extensions[0].schema"],message:"To reference schema types a `schema` must be specified."}]);return!0},Rv=(e,t)=>{if(e||t){if(!e)throw new u.ZodError([{code:u.ZodIssueCode.custom,path:["extensions[0].return_type_ref"],message:"When uploading a schema a `return_type_ref` must be specified."}]);if(!t)throw new u.ZodError([{code:u.ZodIssueCode.custom,path:["extensions[0].schema"],message:"To set a return type a `schema` must be specified."}])}return!0};var XA=bo.extend({type:u.literal("flow_action"),name:u.string(),runtime_url:u.string().url().refine(Rr),validation_url:u.string().url().refine(Rr).optional(),config_page_url:u.string().url().refine(Rr).optional(),config_page_preview_url:u.string().url().refine(Rr).optional(),schema:u.string().optional(),return_type_ref:u.string().optional()}).refine(e=>{let t=Dv(e.config_page_url,e.config_page_preview_url,e.validation_url),i=(e.settings?.fields??[]).every((r,a)=>Ns(r,"flow_action",e.handle,a)),o=Rv(e.return_type_ref,e.schema);return t&&i&&o}),ZA=le({identifier:"flow_action",schema:XA,appModuleFeatures:e=>[],deployConfig:async(e,t)=>({title:e.name,description:e.description,url:e.runtime_url,fields:Cs("flow_action",e.settings?.fields),validation_url:e.validation_url,custom_configuration_page_url:e.config_page_url,custom_configuration_page_preview_url:e.config_page_preview_url,schema_patch:await Es(t,e.schema),return_type_ref:e.return_type_ref})}),Uv=ZA;l();import eT from"fs";var Ov=["buyer_experience","customers","fulfillment","inventory_and_merch","loyalty","orders","promotion","risk","b2b","payment_reminders","custom_data","error_monitoring"],tT=["capture_at_fulfillment"],nT=bo.extend({type:u.literal("flow_template"),name:u.string(),description:u.string().max(1024),template:u.object({categories:u.array(u.string().refine(e=>Ov.concat(tT).includes(e),e=>({message:`${e} is not a valid category. Valid categories include: ${Ov.join(", ")}.`}))),module:u.string(),require_app:u.boolean().optional(),discoverable:u.boolean().optional(),allow_one_click_activate:u.boolean().optional(),enabled:u.boolean().optional()})}),iT=le({identifier:"flow_template",schema:nT,appModuleFeatures:e=>["ui_preview"],clientSteps:[{lifecycle:"deploy",steps:[{id:"copy-files",name:"Copy Files",type:"include_assets",config:{inclusions:[{type:"pattern",include:["**/*.flow","**/*.json","**/*.toml"]}]}}]}],deployConfig:async(e,t)=>({template_handle:e.handle,name:e.name,description:e.description,categories:e.template.categories,require_app:e.template.require_app,discoverable:e.template.discoverable,allow_one_click_activate:e.template.allow_one_click_activate,enabled:e.template.enabled,definition:await oT(t,e.template.module),localization:await yt(t,e.name)})});async function oT(e,t){let i=(await re(k(e,t)))[0];if(!i)throw new y(`Missing flow file with the path ${k(e,t)}`);return eT.readFileSync(i,"base64")}var Mv=iT;l();var rT=ge.extend({build:u.object({command:u.string().transform(e=>e.trim()===""?void 0:e).optional(),path:u.string().optional(),watch:u.union([u.string(),u.string().array()]).optional(),wasm_opt:u.boolean().optional().default(!0),typegen_command:u.string().transform(e=>e.trim()===""?void 0:e).optional()}).optional(),name:u.string(),type:u.string(),configuration_ui:u.boolean().optional().default(!0),ui:u.object({enable_create:u.boolean().optional(),paths:u.object({create:u.string(),details:u.string()}).optional(),handle:u.string().optional()}).optional(),api_version:u.string(),input:u.object({variables:u.object({namespace:u.string(),key:u.string()}).optional()}).optional(),targeting:u.array(u.object({target:u.string(),input_query:u.string().optional(),export:u.string().optional()})).optional()}),aT=le({identifier:"function",additionalIdentifiers:["order_discounts","cart_checkout_validation","cart_transform","delivery_customization","payment_customization","product_discounts","shipping_discounts","fulfillment_constraints","order_routing_location_rule","local_pickup_delivery_option_generator","pickup_point_delivery_option_generator"],schema:rT,appModuleFeatures:e=>["function"],getOutputRelativePath:e=>k("dist","index.wasm"),devSessionWatchConfig:e=>{let t=e.configuration;if(!t.build||!t.build.watch)return;let n=[t.build.watch].flat().map(i=>k(e.directory,i));return n.push(k(e.directory,"locales","**.json")),n.push(k(e.directory,"**","!(.)*.graphql")),n.push(k(e.directory,"**.toml")),{paths:n}},clientSteps:[{lifecycle:"deploy",steps:[{id:"build-function",name:"Build Function",type:"build_function",config:{}}]}],deployConfig:async(e,t,n)=>{let i,o=gn(),r=k(t,"input.graphql");await C(r)&&(i=await P(r));let a=e.targeting&&await Promise.all(e.targeting.map(async c=>{let d;return c.input_query&&(d=await sT(k(t,c.input_query))),{handle:c.target,export:c.export,input_query:d}})),s;return e.ui?.paths&&(s={app_bridge:{details_path:e.ui.paths.details,create_path:e.ui.paths.create}}),e.ui?.handle!==void 0&&(s={...s,ui_extension_handle:e.ui.handle}),{title:e.name,module_id:o,description:e.description,app_key:n,api_type:e.type==="function"?void 0:e.type,api_version:e.api_version,input_query:i,input_query_variables:e.input?.variables?{single_json_metafield:e.input.variables}:void 0,ui:s,enable_creation_ui:e.ui?.enable_create??!0,localization:await yt(t,"function"),targets:a}},preDeployValidation:async e=>{if(!await C(e.outputPath))throw new y(w`The function extension "${e.handle}" hasn't compiled the wasm in the expected path: ${e.outputPath}`,"Make sure the build command outputs the wasm in the expected directory.")}});async function sT(e){if(await C(e))return P(e);throw new y(`No input query file at ${e}.`,"Create the file or remove the line referencing it in the extension's TOML.")}var Lv=aT;l();l();l();var $v=50,_t=ge.extend({api_version:u.string(),payment_session_url:u.string().url(),refund_session_url:u.string().url().optional(),capture_session_url:u.string().url().optional(),void_session_url:u.string().url().optional(),supported_countries:u.array(u.string()),supported_payment_methods:u.array(u.string()),test_mode_available:u.boolean(),merchant_label:u.string().max($v),input:u.object({metafield_identifiers:u.object({namespace:u.string(),key:u.string()}).optional()}).optional()}),Pn=u.object({buyer_label:u.string().max($v).optional(),buyer_label_translations:u.array(u.object({locale:u.string(),label:u.string()})).optional()}),Do=u.object({supports_installments:u.boolean(),supports_deferred_payments:u.boolean()}),As=u.object({multiple_capture:u.boolean().optional()}),In=u.object({confirmation_callback_url:u.string().url().optional(),supports_3ds:u.boolean()}),Mt=u.object({supported_buyer_contexts:u.array(u.object({currency:u.string(),countries:u.array(u.string()).nonempty().optional()}).strict()).optional().refine(e=>e===void 0||e.every(t=>t.countries)||e.every(t=>!t.countries),{message:"Must all be defined with only a currency, or must all be defined with a currency plus countries -- a mixture of the two is not allowed"})});var Ro="payments.offsite.render",Vv=_t.merge(Pn).merge(Do).merge(In).merge(As).merge(Mt).extend({targeting:u.array(u.object({target:u.literal(Ro)})).length(1),supports_oversell_protection:u.boolean().optional()}).refine(e=>!e.supports_oversell_protection||e.confirmation_callback_url,{message:"Property required when supports_oversell_protection is true",path:["confirmation_callback_url"]}).refine(e=>e.supports_installments===e.supports_deferred_payments,{message:"supports_installments and supports_deferred_payments must be the same"});function qv(e){return{api_version:e.api_version,payment_session_url:e.start_payment_session_url,refund_session_url:e.start_refund_session_url,capture_session_url:e.start_capture_session_url,void_session_url:e.start_void_session_url,confirmation_callback_url:e.confirmation_callback_url,multiple_capture:e.multiple_capture,merchant_label:e.merchant_label,supported_countries:e.supported_countries,supported_payment_methods:e.supported_payment_methods,supported_buyer_contexts:e.supported_buyer_contexts,test_mode_available:e.test_mode_available,buyer_label:e.default_buyer_label,buyer_label_translations:e.buyer_label_to_locale,supports_oversell_protection:e.supports_oversell_protection,supports_3ds:e.supports_3ds,supports_deferred_payments:e.supports_deferred_payments,supports_installments:e.supports_installments}}async function jv(e){return{api_version:e.api_version,start_payment_session_url:e.payment_session_url,start_refund_session_url:e.refund_session_url,start_capture_session_url:e.capture_session_url,start_void_session_url:e.void_session_url,confirmation_callback_url:e.confirmation_callback_url,multiple_capture:e.multiple_capture,merchant_label:e.merchant_label,supported_countries:e.supported_countries,supported_payment_methods:e.supported_payment_methods,supported_buyer_contexts:e.supported_buyer_contexts,test_mode_available:e.test_mode_available,default_buyer_label:e.buyer_label,buyer_label_to_locale:e.buyer_label_translations,supports_oversell_protection:e.supports_oversell_protection,supports_3ds:e.supports_3ds,supports_deferred_payments:e.supports_deferred_payments,supports_installments:e.supports_installments}}l();l();function Dn(e,t){let n=e.ui_extension_handle;if(n||!("ui_extension_registration_uuid"in e))return n;let i=t.find(o=>o.uuid===e.ui_extension_registration_uuid)?.title;return i?te(i):n}var Uo="payments.redeemable.render",Bv=_t.merge(Pn).merge(Mt).extend({targeting:u.array(u.object({target:u.literal(Uo)})).length(1),api_version:u.string(),balance_url:u.string().url(),ui_extension_handle:u.string().optional(),checkout_payment_method_fields:u.array(u.object({type:u.union([u.literal("string"),u.literal("number"),u.literal("boolean")]),required:u.boolean(),key:u.string()})).optional()});function zv(e,t){let n=Dn(e,t);return{api_version:e.api_version,payment_session_url:e.start_payment_session_url,refund_session_url:e.start_refund_session_url,capture_session_url:e.start_capture_session_url,void_session_url:e.start_void_session_url,merchant_label:e.merchant_label,supported_countries:e.supported_countries,supported_payment_methods:e.supported_payment_methods,supported_buyer_contexts:e.supported_buyer_contexts,test_mode_available:e.test_mode_available,buyer_label:e.default_buyer_label,buyer_label_translations:e.buyer_label_to_locale,balance_url:e.balance_url,checkout_payment_method_fields:e.checkout_payment_method_fields?.map(i=>({key:i.key,type:i.type,required:i.required})),ui_extension_handle:n}}async function Wv(e){let t=e.supported_payment_methods[0]==="gift-card"?"gift_card":null;return{api_version:e.api_version,start_payment_session_url:e.payment_session_url,start_refund_session_url:e.refund_session_url,start_capture_session_url:e.capture_session_url,start_void_session_url:e.void_session_url,merchant_label:e.merchant_label,supported_countries:e.supported_countries,supported_payment_methods:e.supported_payment_methods,supported_buyer_contexts:e.supported_buyer_contexts,test_mode_available:e.test_mode_available,default_buyer_label:e.buyer_label,buyer_label_to_locale:e.buyer_label_translations,balance_url:e.balance_url,redeemable_type:t,checkout_payment_method_fields:e.checkout_payment_method_fields,ui_extension_handle:e.ui_extension_handle}}l();var Oo="payments.custom-onsite.render",Hv=7,Gv=_t.merge(Pn).merge(Do).merge(In).merge(Mt).extend({targeting:u.array(u.object({target:u.literal(Oo)})).length(1),update_payment_session_url:u.string().url().optional(),multiple_capture:u.boolean().optional(),supports_oversell_protection:u.boolean().optional(),modal_payment_method_fields:u.array(u.object({})).optional(),ui_extension_handle:u.string().optional(),start_verification_session_url:u.string().url().optional(),checkout_payment_method_fields:u.array(u.object({type:u.union([u.literal("string"),u.literal("number"),u.literal("boolean")]),required:u.boolean(),key:u.string()})).max(Hv,`The extension can't have more than ${Hv} checkout_payment_method_fields`).optional()}).refine(e=>e.supports_installments===e.supports_deferred_payments,{message:"supports_installments and supports_deferred_payments must be the same"});function Kv(e,t){let n=Dn(e,t);return{api_version:e.api_version,payment_session_url:e.start_payment_session_url,refund_session_url:e.start_refund_session_url,capture_session_url:e.start_capture_session_url,void_session_url:e.start_void_session_url,confirmation_callback_url:e.confirmation_callback_url,update_payment_session_url:e.update_payment_session_url,start_verification_session_url:e.start_verification_session_url,merchant_label:e.merchant_label,supports_oversell_protection:e.supports_oversell_protection,supports_3ds:e.supports_3ds,supports_installments:e.supports_installments,supports_deferred_payments:e.supports_deferred_payments,supported_countries:e.supported_countries,supported_payment_methods:e.supported_payment_methods,supported_buyer_contexts:e.supported_buyer_contexts,test_mode_available:e.test_mode_available,multiple_capture:e.multiple_capture,buyer_label:e.default_buyer_label,buyer_label_translations:e.buyer_label_to_locale,checkout_payment_method_fields:e.checkout_payment_method_fields,modal_payment_method_fields:e.modal_payment_method_fields,ui_extension_handle:n}}async function Yv(e){return{api_version:e.api_version,start_payment_session_url:e.payment_session_url,start_refund_session_url:e.refund_session_url,start_capture_session_url:e.capture_session_url,start_void_session_url:e.void_session_url,confirmation_callback_url:e.confirmation_callback_url,update_payment_session_url:e.update_payment_session_url,start_verification_session_url:e.start_verification_session_url,merchant_label:e.merchant_label,supports_oversell_protection:e.supports_oversell_protection,supports_3ds:e.supports_3ds,supports_installments:e.supports_installments,supports_deferred_payments:e.supports_deferred_payments,supported_countries:e.supported_countries,supported_payment_methods:e.supported_payment_methods,supported_buyer_contexts:e.supported_buyer_contexts,test_mode_available:e.test_mode_available,multiple_capture:e.multiple_capture,default_buyer_label:e.buyer_label,buyer_label_to_locale:e.buyer_label_translations,checkout_payment_method_fields:e.checkout_payment_method_fields,modal_payment_method_fields:e.modal_payment_method_fields,ui_extension_handle:e.ui_extension_handle}}l();var Mo="payments.custom-credit-card.render",Qv=7,Jv=_t.merge(Pn).merge(In).merge(Mt).required({refund_session_url:!0,capture_session_url:!0,void_session_url:!0}).extend({targeting:u.array(u.object({target:u.literal(Mo)})).length(1),api_version:u.string(),multiple_capture:u.boolean(),checkout_hosted_fields:u.array(u.string()).optional(),ui_extension_handle:u.string().optional(),encryption_certificate_fingerprint:u.string(),checkout_payment_method_fields:u.array(u.object({type:u.union([u.literal("string"),u.literal("number"),u.literal("boolean")]),required:u.boolean(),key:u.string()})).max(Qv,`The extension can't have more than ${Qv} checkout_payment_method_fields`).optional()});function Xv(e,t){let n=Dn(e,t);return{api_version:e.api_version,payment_session_url:e.start_payment_session_url,refund_session_url:e.start_refund_session_url,capture_session_url:e.start_capture_session_url,void_session_url:e.start_void_session_url,confirmation_callback_url:e.confirmation_callback_url,merchant_label:e.merchant_label,supports_3ds:e.supports_3ds,supported_countries:e.supported_countries,supported_payment_methods:e.supported_payment_methods,supported_buyer_contexts:e.supported_buyer_contexts,buyer_label:e.default_buyer_label,buyer_label_translations:e.buyer_label_to_locale,encryption_certificate_fingerprint:e.encryption_certificate.fingerprint,test_mode_available:e.test_mode_available,multiple_capture:e.multiple_capture,checkout_payment_method_fields:e.checkout_payment_method_fields,checkout_hosted_fields:e.checkout_hosted_fields,ui_extension_handle:n}}async function Zv(e){return{api_version:e.api_version,start_payment_session_url:e.payment_session_url,start_refund_session_url:e.refund_session_url,start_capture_session_url:e.capture_session_url,start_void_session_url:e.void_session_url,confirmation_callback_url:e.confirmation_callback_url,merchant_label:e.merchant_label,supports_3ds:e.supports_3ds,supported_countries:e.supported_countries,supported_buyer_contexts:e.supported_buyer_contexts,default_buyer_label:e.buyer_label,buyer_label_to_locale:e.buyer_label_translations,encryption_certificate_fingerprint:e.encryption_certificate_fingerprint,supported_payment_methods:e.supported_payment_methods,test_mode_available:e.test_mode_available,multiple_capture:e.multiple_capture,checkout_payment_method_fields:e.checkout_payment_method_fields,checkout_hosted_fields:e.checkout_hosted_fields,ui_extension_handle:e.ui_extension_handle}}l();var Lo="payments.credit-card.render",ek=7,tk=_t.merge(Do).merge(In).merge(As).merge(Mt).required({refund_session_url:!0,capture_session_url:!0,void_session_url:!0}).extend({targeting:u.array(u.object({target:u.literal(Lo)})).length(1),verification_session_url:u.string().url().optional(),ui_extension_handle:u.string().optional(),supports_moto:u.boolean({required_error:"supports_moto is required",invalid_type_error:"Value must be Boolean"}),encryption_certificate_fingerprint:u.string(),checkout_payment_method_fields:u.array(u.object({type:u.union([u.literal("string"),u.literal("number"),u.literal("boolean")]),required:u.boolean(),key:u.string()})).max(ek,`The extension can't have more than ${ek} checkout_payment_method_fields`).optional()}).refine(e=>!e.supports_3ds||e.confirmation_callback_url,{message:"Property required when supports_3ds is true",path:["confirmation_callback_url"]}).refine(e=>e.supports_installments===e.supports_deferred_payments,{message:"supports_installments and supports_deferred_payments must be the same"});function nk(e,t){let n=Dn(e,t);return{api_version:e.api_version,payment_session_url:e.start_payment_session_url,refund_session_url:e.start_refund_session_url,capture_session_url:e.start_capture_session_url,void_session_url:e.start_void_session_url,confirmation_callback_url:e.confirmation_callback_url,multiple_capture:e.multiple_capture,merchant_label:e.merchant_label,supported_countries:e.supported_countries,supported_payment_methods:e.supported_payment_methods,supported_buyer_contexts:e.supported_buyer_contexts,test_mode_available:e.test_mode_available,supports_3ds:e.supports_3ds,supports_moto:e.supports_moto,supports_deferred_payments:e.supports_deferred_payments,supports_installments:e.supports_installments,verification_session_url:e.start_verification_session_url,encryption_certificate_fingerprint:e.encryption_certificate.fingerprint,checkout_payment_method_fields:e.checkout_payment_method_fields,ui_extension_handle:n}}async function ik(e){return{api_version:e.api_version,start_payment_session_url:e.payment_session_url,start_refund_session_url:e.refund_session_url,start_capture_session_url:e.capture_session_url,start_void_session_url:e.void_session_url,confirmation_callback_url:e.confirmation_callback_url,multiple_capture:e.multiple_capture,merchant_label:e.merchant_label,supported_countries:e.supported_countries,supported_payment_methods:e.supported_payment_methods,supported_buyer_contexts:e.supported_buyer_contexts,test_mode_available:e.test_mode_available,supports_3ds:e.supports_3ds,supports_moto:e.supports_moto,supports_deferred_payments:e.supports_deferred_payments,encryption_certificate_fingerprint:e.encryption_certificate_fingerprint,supports_installments:e.supports_installments,start_verification_session_url:e.verification_session_url,checkout_payment_method_fields:e.checkout_payment_method_fields,ui_extension_handle:e.ui_extension_handle}}l();var $o="payments.card-present.render",ok=_t.required({refund_session_url:!0,capture_session_url:!0,void_session_url:!0}).extend({targeting:u.array(u.object({target:u.literal($o)})).length(1),sync_terminal_transaction_result_url:u.string().url().optional()});function rk(e){return{api_version:e.api_version,payment_session_url:e.start_payment_session_url,refund_session_url:e.start_refund_session_url,capture_session_url:e.start_capture_session_url,void_session_url:e.start_void_session_url,sync_terminal_transaction_result_url:e.sync_terminal_transaction_result_url,merchant_label:e.merchant_label,supported_countries:e.supported_countries,supported_payment_methods:e.supported_payment_methods,test_mode_available:e.test_mode_available}}async function ak(e){return{api_version:e.api_version,start_payment_session_url:e.payment_session_url,start_refund_session_url:e.refund_session_url,start_capture_session_url:e.capture_session_url,start_void_session_url:e.void_session_url,sync_terminal_transaction_result_url:e.sync_terminal_transaction_result_url,merchant_label:e.merchant_label,supported_countries:e.supported_countries,supported_payment_methods:e.supported_payment_methods,test_mode_available:e.test_mode_available}}var lT=u.union([Vv,Bv,Gv,Jv,tk,ok]),cT=le({identifier:"payments_extension",schema:lT,appModuleFeatures:e=>[],deployConfig:async(e,t)=>{switch(e.targeting[0]?.target){case Ro:return jv(e);case Uo:return Wv(e);case Lo:return ik(e);case Oo:return Yv(e);case Mo:return Zv(e);case $o:return ak(e);default:return{}}}}),sk=cT;l();var ip="@shopify/retail-ui-extensions",pT=ge.extend({name:u.string()}),dT=le({identifier:"pos_ui_extension",dependency:ip,schema:pT,appModuleFeatures:e=>["ui_preview","esbuild","single_js_entry_path"],getOutputRelativePath:e=>`dist/${e.handle}.js`,clientSteps:[{lifecycle:"deploy",steps:[{id:"bundle-ui",name:"Bundle UI Extension",type:"bundle_ui",config:{}}]}],deployConfig:async(e,t)=>{let n=await Sr(ip,t);if(n==="not_found")throw new L(`Dependency ${ip} not found`);return{name:e.name,description:e.description,renderer_version:n?.version}}}),lk=dT;l();var op="@shopify/admin-ui-extensions",uT=le({identifier:"product_subscription",additionalIdentifiers:["subscription_management"],dependency:op,graphQLType:"subscription_management",schema:ge,appModuleFeatures:e=>["ui_preview","esbuild","single_js_entry_path"],getOutputRelativePath:e=>`dist/${e.handle}.js`,clientSteps:[{lifecycle:"deploy",steps:[{id:"bundle-ui",name:"Bundle UI Extension",type:"bundle_ui",config:{}}]}],deployConfig:async(e,t)=>{let n=await Sr(op,t);if(n==="not_found")throw new L(`Dependency ${op} not found`);return{renderer_version:n?.version}}}),ck=uT;l();var mT=u.object({key:u.string()}),fT=ge.extend({production_api_base_url:u.string(),benchmark_api_base_url:u.string().optional(),calculate_taxes_api_endpoint:u.string(),input:u.object({metafield_identifiers:u.object({namespace:u.string(),key:u.string()}).optional()}).optional(),metafields:u.array(tn).optional(),cart_line_properties:u.array(mT).optional()}),hT=le({identifier:"tax_calculation",schema:fT,appModuleFeatures:e=>[],getOutputRelativePath:e=>k("dist",`${e.handle}.js`),clientSteps:[{lifecycle:"deploy",steps:[{id:"create-tax-stub",name:"Create Tax Stub",type:"create_tax_stub",config:{}}]}],deployConfig:async(e,t)=>({production_api_base_url:e.production_api_base_url,benchmark_api_base_url:e.benchmark_api_base_url,calculate_taxes_api_endpoint:e.calculate_taxes_api_endpoint,metafields:e.metafields,cart_line_properties:e.cart_line_properties,api_version:e.api_version,metafield_identifiers:e.input?.metafield_identifiers})}),pk=hT;l();var gT=le({identifier:"theme",schema:ge,partnersWebIdentifier:"theme_app_extension",graphQLType:"theme_app_extension",clientSteps:[{lifecycle:"deploy",steps:[{id:"build-theme",name:"Build Theme Extension",type:"build_theme",config:{}},{id:"bundle-theme",name:"Bundle Theme Extension",type:"bundle_theme",config:{}}]}],appModuleFeatures:e=>["theme"],deployConfig:async()=>({theme_extension:{files:{}}}),preDeployValidation:async e=>kT(e)}),hk=gT,rp=1024,gk=rp*1024,yk=10,yT=yk*gk,vk=500,vT=vk*rp,dk=[".jpg",".jpeg",".json",".js",".css",".png",".svg",".wasm"],uk=[".json"],kk={assets:{validator:new RegExp(`${dk.join("|")}$`),failureMessage:e=>`Only these filetypes are supported in assets: ${dk.join(", ")}`},blocks:{validator:/.liquid$/,failureMessage:e=>"Only .liquid files are allowed in blocks."},locales:{validator:new RegExp(`${uk.join("|")}$`),failureMessage:e=>`Only these filetypes are supported in locales: ${uk.join(", ")}`},snippets:{validator:/.liquid$/,failureMessage:e=>"Only .liquid files are allowed in snippets."}},mk=Object.keys(kk);async function kT(e){let t=await En(e),n=[],i=[];await Promise.all(t.map(async o=>{let r=z(e.directory,o),a=H(r);bT(r,a);let s=await oo(o);i.push(s),["blocks","snippets"].includes(a)&&n.push(s)})),wT(fk(i)),_T(fk(n))}function wT(e){if(e>yT){let t=`${(e/gk).toFixed(2)} MB`;throw new y(`Your theme app extension exceeds the file size limit (${yk} MB). It's currently ${t}.`,"Reduce your total file size and try again.")}}function _T(e){if(e>vT){let t=`${(e/rp).toFixed(2)} kB`;throw new y(`Your theme app extension exceeds the total liquid file size limit (${vk} kB). It's currently ${t}.`,"Reduce your total file size and try again.")}}function bT(e,t){if(!mk.includes(t))throw new y(w`Your theme app extension includes files in an unsupported directory, ${b.path(t)}`,`Make sure all theme app extension files are in the supported directories: ${mk.join(", ")}`);let n=kk[t];if(!e.match(n.validator))throw new y(`Invalid filename in your theme app extension: ${e}
|
|
741
|
-
${n.failureMessage(e)}`)}function fk(e){return e.reduce((t,n)=>t+n,0)}l();l();var bk=O(Ax(),1);import{createRequire as ST}from"module";async function ap(){let e=await import("./typescript-K5CWIA4V.js");return e.default??e}var wk=ST(import.meta.url),_k="@shopify/ui-extensions";function xT(e){let t=e.toLowerCase().replace(/(::|\.).+$/,"");switch(t){case"purchase":return"checkout";case"pos":return"point-of-sale";default:return t}}function sp(e){let t=e[0];return t?`${_k}/${xT(t)}`:_k}function Ur(e){let[t,n]=e.split("-");return!t||!n?null:{year:parseInt(t,10),month:parseInt(n,10)}}async function ET(e){let t=await ap(),n=t.findConfigFile(e,t.sys.fileExists.bind(t.sys),"tsconfig.json");if(!n)return{compilerOptions:{},configPath:void 0};let i=t.readConfigFile(n,t.sys.readFile.bind(t.sys));return i.error?{compilerOptions:{},configPath:n}:{compilerOptions:t.parseJsonConfigFileContent(i.config,t.sys,H(n)).options,configPath:n}}async function CT(e,t){if(!e.startsWith("./")&&!e.startsWith("../"))return null;let n=he(t,e),i=["",".js",".jsx",".ts",".tsx"];for(let o of i){let r=n+o;if(await C(r)&&!r.includes("node_modules"))return r}for(let o of[".js",".jsx",".ts",".tsx"]){let r=k(n,`index${o}`);if(await C(r)&&!r.includes("node_modules"))return r}return null}async function NT(e){try{let t=await ap(),n=ct(e).toString(),i=[],{compilerOptions:o}=await ET(e),r=t.ScriptKind.JSX;e.endsWith(".ts")?r=t.ScriptKind.TS:e.endsWith(".tsx")&&(r=t.ScriptKind.TSX);let a=t.createSourceFile(e,n,t.ScriptTarget.Latest,!0,r),s=new Set,c=[],d=p=>{if(t.isImportDeclaration(p)&&p.moduleSpecifier&&t.isStringLiteral(p.moduleSpecifier))c.push(p.moduleSpecifier.text);else if(t.isCallExpression(p)&&p.expression.kind===t.SyntaxKind.ImportKeyword){let m=p.arguments[0];m&&t.isStringLiteral(m)&&c.push(m.text)}else t.isExportDeclaration(p)&&p.moduleSpecifier&&t.isStringLiteral(p.moduleSpecifier)&&c.push(p.moduleSpecifier.text);t.forEachChild(p,d)};d(a);for(let p of c){if(!p||s.has(p))continue;s.add(p);let m=t.resolveModuleName(p,e,o,t.sys);if(m.resolvedModule?.resolvedFileName){let h=m.resolvedModule.resolvedFileName;h.includes("node_modules")||i.push(h)}else{let h=await CT(p,H(e));h&&i.push(h)}}return i}catch(t){if(t instanceof y)throw t;return[]}}async function Ts(e,t=new Set){if(t.has(e))return[];t.add(e);let n=await NT(e),i=[...n];for(let o of n){let r=await Ts(o,t);i.push(...r)}return[...new Set(i)]}async function AT(e){let t;try{t=ct(e).toString()}catch{return!1}let n=await ap(),i=n.createSourceFile(e,t,n.ScriptTarget.Latest,!0,n.ScriptKind.TS),o=!1,r=a=>{if(!o){if(n.isExportDeclaration(a)&&a.exportClause&&n.isNamedExports(a.exportClause)){for(let s of a.exportClause.elements)if(s.name.text==="ShopifyGlobal"){o=!0;return}}n.forEachChild(a,r)}};return r(i),o}async function TT(e,t){let n=async i=>{let o=`import('@shopify/ui-extensions/${i}').Api`,r=t.get(i);return r&&await AT(r)?`${o} & import('@shopify/ui-extensions/${i}').ShopifyGlobal`:o};return e.length===1?n(e[0]??""):e.length>1?`(${(await Promise.all(e.map(n))).join(" | ")})`:null}async function FT(e,t,{includesTools:n,includesIntents:i},o){let r=await TT(e,t);if(!r)return null;if(!n&&!i)return r;let a=r;return i&&(a=`import('${o}').WithGeneratedIntents<${a}, ShopifyGeneratedIntentVariants>`),n&&(a=`import('${o}').WithGeneratedTools<${a}, ShopifyTools>`),a}async function Sk({fullPath:e,typeFilePath:t,targets:n,apiVersion:i,toolsTypeDefinition:o,intentsTypeDefinition:r}){try{let a=new Map,s=!!o,c=!!r;for(let g of n)try{let f=wk.resolve(`@shopify/ui-extensions/${g}`,{paths:[e,t]});a.set(g,f)}catch{let{year:v,month:_}=Ur(i)??{year:2025,month:10};throw new y(`Type reference for ${g} could not be found. You might be using the wrong @shopify/ui-extensions version.`,`Fix the error by ensuring you have the correct version of @shopify/ui-extensions, for example ~${v}.${_}.0, in your dependencies.`)}let d=sp(n);if(s||c)try{wk.resolve(d,{paths:[e,t]})}catch{let{year:f,month:v}=Ur(i)??{year:2025,month:10};throw new y(`Type reference for ${d} could not be found. You might be using the wrong @shopify/ui-extensions version.`,`Fix the error by ensuring you have the correct version of @shopify/ui-extensions, for example ~${f}.${v}.0, in your dependencies.`)}let p=eo(e,H(t)),m=await FT(n,a,{includesTools:s,includesIntents:c},d);return m?["//@ts-ignore",`declare module './${p}' {`,...o?[o]:[],...r?[r]:[],` const shopify: ${m};`," const globalThis: { shopify: typeof shopify };","}",""].join(`
|
|
742
|
-
`):null}catch(a){if(a instanceof y)throw a;let{year:s,month:c}=Ur(i)??{year:2025,month:10};throw new y("Type reference could not be found. You might be using the wrong @shopify/ui-extensions version.",`Fix the error by ensuring you have the correct version of @shopify/ui-extensions, for example ~${s}.${c}.0, in your dependencies.`)}}async function xk(e,t){let n=H(e),i=await qe("tsconfig.json",{cwd:n,type:"file"});if(i){let o=he(i),r=he(t);if(o.startsWith(r))return H(i)}}var PT=u.object({name:u.string(),description:u.string(),inputSchema:u.object({}).passthrough(),outputSchema:u.object({}).passthrough().optional()}),Ek=u.array(PT),Ck=u.object({value:u.object({}).passthrough().optional(),inputSchema:u.object({}).passthrough(),outputSchema:u.object({}).passthrough().optional()});function IT(e){return no(`${e.action} ${e.type}`.replace(/[^a-zA-Z0-9]+/g," "))}async function Nk(e,{generatedTypesHelperImportPath:t}){if(e.length===0)return"";let n=new Set,i=e.map(async a=>{let s=`${a.action}:${a.type}`;if(n.has(s))throw new y(`Intent "${s}" is defined multiple times. Intents must be unique within a target.`);n.add(s);let c=IT(a),d=`${c}IntentInput`,p=`${c}IntentValue`,m=`${c}IntentOutput`,h=`${c}IntentRequest`,g=await Or(d,a.inputSchema),f=await Or(p,a.valueSchema),v=await Or(m,a.outputSchema),_=`interface ${h} {
|
|
743
|
-
action: ${JSON.stringify(a.action)};
|
|
744
|
-
type: ${JSON.stringify(a.type)};
|
|
745
|
-
data: ${d};
|
|
746
|
-
value?: ${p};
|
|
747
|
-
}`;return{inputType:g,valueType:f,outputType:v,requestType:_,requestTypeName:h,outputTypeName:m}}),o=await Promise.all(i),r=o.map(({requestTypeName:a,outputTypeName:s})=>` | import('${t}').ShopifyGeneratedIntentVariant<${a}, ${s}>`).join(`
|
|
748
|
-
`);return`${o.map(({inputType:a,valueType:s,outputType:c,requestType:d})=>`${a}
|
|
749
|
-
${s}
|
|
750
|
-
${c}
|
|
751
|
-
${d}`).join(`
|
|
752
|
-
|
|
753
|
-
`)}
|
|
754
|
-
|
|
755
|
-
type ShopifyGeneratedIntentVariants =
|
|
756
|
-
${r}
|
|
757
|
-
`}async function Ak(e){if(e.length===0)return"";let t=new Set,n=e.map(async r=>{if(t.has(r.name))throw new y(`Tool name "${r.name}" is defined multiple times. Tool names must be unique within a tools file.`);t.add(r.name);let a=no(`${r.name}Input`),s=await Or(a,r.inputSchema),c=no(`${r.name}Output`),d=await Or(c,r.outputSchema);return{name:r.name,description:r.description,inputType:s,outputType:d,inputTypeName:a,outputTypeName:c}}),i=await Promise.all(n),o=i.map(({name:r,description:a,inputTypeName:s,outputTypeName:c})=>` /**
|
|
758
|
-
${a.replace(/\*\//g,"*\\/").split(`
|
|
759
|
-
`).map(p=>` * ${p}`).join(`
|
|
760
|
-
`)}
|
|
761
|
-
*/
|
|
762
|
-
register(name: '${r}', handler: (input: ${s}) => ${c} | Promise<${c}>): () => void;`).join(`
|
|
763
|
-
`);return`${i.map(({inputType:r,outputType:a})=>`${r}
|
|
764
|
-
${a}`).join(`
|
|
765
|
-
`)}
|
|
766
|
-
interface ShopifyTools {
|
|
767
|
-
${o}
|
|
768
|
-
}
|
|
769
|
-
`}function DT(e,t){return e.replace(/^(interface|type|enum)\s+[A-Za-z0-9_]+/,`$1 ${t}`)}async function Or(e,t){if(!t)return`type ${e} = unknown`;let n=await(0,bk.compile)(t,e,{bannerComment:""}),i=n.startsWith("export ")?n.slice(7):n;return DT(i,e)}l();l();l();var Tk=R`
|
|
770
|
-
query {
|
|
771
|
-
products(first: 1, query: "published_status:published") {
|
|
772
|
-
edges {
|
|
773
|
-
node {
|
|
774
|
-
id
|
|
775
|
-
variants(first: 1) {
|
|
776
|
-
edges {
|
|
777
|
-
node {
|
|
778
|
-
id
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
`;async function Fk(e){let t=await aa(e),n=await rm(Tk,t);if(n.products.edges.length===0){let a=`https://${K(e)}/admin/products/new`,s=w`${b.link("Add a product",a,`You can add a new product here: ${a}`)}`.value;throw new y("Could not find a product variant",`Your store needs to have at least one product to test a 'checkout_ui' extension.
|
|
787
|
-
|
|
788
|
-
${s}`)}return n.products.edges[0].node.variants.edges[0].node.id.split("/").pop()}async function Fs(e,t,n){return e.filter(r=>r.shouldFetchCartUrl()).length>0?n||`/cart/${await Fk(t)}:1`:void 0}function Vo(e){let t=e.toLowerCase().replace(/(::|\.).+$/,""),n=e.split(".")[1];switch(t){case"purchase":return n==="post"?"post_purchase":"checkout";case"customer-account":return"customer-accounts";case"pos":return"point_of_sale";default:return t}}l();Ex();async function Pk(e,t){return Em.format(e,t)}var RT="@shopify/checkout-ui-extensions",UT=e=>e.extension_points!==void 0||e.targeting!==void 0,Dk="No extension targets defined, add a `targeting` field to your configuration",OT=ge.extend({name:u.string(),type:u.literal("ui_extension"),extension_points:mc.optional(),targeting:mc.optional(),metafields:u.array(tn).optional()}).refine(e=>UT(e),Dk).transform(e=>{let t=(e.targeting??e.extension_points??[]).map(n=>{let i={assets:{[st.Main]:{filepath:`${e.handle}.js`,module:n.module},...n.should_render?.module?{[st.ShouldRender]:{filepath:`${e.handle}-conditions.js`,module:n.should_render.module}}:null}};return{target:n.target,module:n.module,metafields:n.metafields??e.metafields??[],default_placement_reference:n.default_placement,urls:n.urls??{},capabilities:n.capabilities,preloads:n.preloads??{},build_manifest:i,tools:n.tools,instructions:n.instructions,intents:n.intents,assets:n.assets}});return{...e,extension_points:t}}),MT=le({identifier:"ui_extension",dependency:RT,schema:OT,getOutputRelativePath:e=>`${e.handle}.js`,clientSteps:[{lifecycle:"deploy",steps:[{id:"bundle-ui",name:"Bundle UI Extension",type:"bundle_ui",config:{generatesAssetsManifest:!0,bundleFolder:"dist/"}},{id:"include-ui-extension-assets",name:"Include UI Extension Assets",type:"include_assets",config:{generatesAssetsManifest:!0,inclusions:[{type:"configKey",anchor:"extension_points[]",groupBy:"target",key:"extension_points[].assets"},{type:"configKey",anchor:"extension_points[]",groupBy:"target",key:"extension_points[].tools"},{type:"configKey",anchor:"extension_points[]",groupBy:"target",key:"extension_points[].instructions"},{type:"configKey",anchor:"extension_points[]",groupBy:"target",key:"extension_points[].intents[].schema"}]}}]}],appModuleFeatures:e=>{let t=["ui_preview","esbuild","generates_source_maps"];return e?.extension_points?.find(i=>Vo(i.target)==="checkout")!==void 0?[...t,"cart_url"]:t},validate:async(e,t,n)=>qT(n,e.extension_points,t),deployConfig:async(e,t)=>{let n=e.extension_points?.map(LT)??[];return{api_version:e.api_version,extension_points:n,capabilities:e.capabilities,supported_features:e.supported_features,name:e.name,description:e.description,settings:e.settings,localization:await yt(t,e.type)}},getBundleExtensionStdinContent:e=>{let t=Ik(e),n=e.extension_points||[],i=n.map(({target:a,module:s},c)=>t?`import Target_${c} from '${s}';shopify.extend('${a}', (...args) => Target_${c}(...args));`:`import '${s}';`).join(`
|
|
789
|
-
`),o={};n.forEach(a=>{let s=jT(a,t);s&&(o[st.ShouldRender]=s)});let r=Object.values(o);return{main:i,...r.length?{assets:r}:{}}},hasExtensionPointTarget:(e,t)=>e.extension_points?.find(n=>n.target===t)!==void 0,contributeToSharedTypeFile:async(e,t)=>{if(!Ik(e.configuration))return;let{configuration:n}=e,i=new Map,o=new Map,r=new Map;for await(let a of n.extension_points){let s=k(e.directory,a.module);if(!await C(s))continue;let d=i.get(s)??[];if(d.push(a.target),i.set(s,d),a.tools&&o.set(s,a.tools),a.intents?.length){let p=r.get(s)??[];p.push(...a.intents),r.set(s,p)}if(a.build_manifest.assets[st.ShouldRender]?.module){let p=k(e.directory,a.build_manifest.assets[st.ShouldRender].module);if(await C(p)){let h=i.get(p)??[];h.push(lp(a.target)),i.set(p,h)}}}for await(let a of n.extension_points){let s=k(e.directory,a.module);if(!await C(s))continue;let d=await Ts(s);for(let p of d){let m=i.get(p)??[];m.push(a.target),i.set(p,m)}if(a.build_manifest.assets[st.ShouldRender]?.module){let p=k(e.directory,a.build_manifest.assets[st.ShouldRender].module);if(await C(p)){let h=await Ts(p);for(let g of h){let f=i.get(g)??[];f.push(lp(a.target)),i.set(g,f)}}}}for await(let[a,s]of i.entries()){let c=await xk(a,e.directory);if(!c)continue;let d=k(c,"shopify.d.ts"),p=[...new Set(s)],m=sp(p);try{let h=o.get(a),g="";if(h)try{let x=await Rk(e.directory,h,Ek);x.status==="ok"?g=await Ak(x.data):x.status==="invalid"&&se(`Invalid tools definition in "${h}": ${x.issues}`)}catch(x){se(`Failed to create tools type definition for tools file "${h}": ${x instanceof Error?x.message:"Unknown error"}`)}let f=r.get(a),v="";if(f?.length){let x=await $T(e.directory,f);if(x.length>0)try{v=await Nk(x,{generatedTypesHelperImportPath:m})}catch(E){if(E instanceof y)throw E;se(`Failed to create intent type definition for intent schema files "${f.map(A=>A.schema).join(", ")}": ${E instanceof Error?E.message:"Unknown error"}`)}}let _=await Sk({fullPath:a,typeFilePath:d,targets:p,apiVersion:n.api_version,toolsTypeDefinition:g,intentsTypeDefinition:v});if(_){let x=t.get(d)??new Set;_=await Pk(_,{parser:"typescript",singleQuote:!0}),x.add(_),t.set(d,x)}}catch(h){if(n.extension_points.some(f=>k(e.directory,f.module)===a||f.build_manifest.assets[st.ShouldRender]?.module&&k(e.directory,f.build_manifest.assets[st.ShouldRender].module)===a))throw h}}}});function LT(e){return{...e,build_manifest:{...e.build_manifest,assets:Object.fromEntries(Object.entries(e.build_manifest.assets).map(([t,n])=>[t,{...n,filepath:k("dist",n.filepath)}]))}}}async function Rk(e,t,n){let i=k(e,t);if(!await C(i))return{status:"missing"};let r=await P(i),a=n.safeParse(JSON.parse(r));return a.success?{status:"ok",data:a.data}:{status:"invalid",issues:a.error.issues.map(s=>s.message).join(", ")}}async function $T(e,t){let n=await Promise.all(t.map(async o=>{try{let r=await Rk(e,o.schema,Ck);return r.status==="missing"?(se(`Intent schema file "${o.schema}" was not found. Skipping intent type generation.`),null):r.status==="invalid"?(se(`Invalid intent schema in "${o.schema}": ${r.issues}`),null):{action:o.action,type:o.type,inputSchema:r.data.inputSchema,valueSchema:r.data.value,outputSchema:r.data.outputSchema}}catch(r){return se(`Failed to create intent type definition for intent schema file "${o.schema}": ${r instanceof Error?r.message:"Unknown error"}`),null}})),i=[];for(let o of n)o&&i.push(o);return i}async function VT(e,t,n,i){if(!t)return;let o=k(e,t);return await C(o)?void 0:w`Couldn't find ${b.path(o)}
|
|
790
|
-
Please check the ${i} path for ${n}`.value}async function qT(e,t,n){let i=[],o=[],r=[];if(!t||t.length===0)return hi(Dk);for await(let a of t){let{module:s,target:c}=a,d=await VT(e,s,c,"module");d&&i.push(d),o.includes(c)?r.push(c):o.push(c)}return r.length&&i.push(`Duplicate targets found: ${r.join(", ")}
|
|
791
|
-
Extension point targets must be unique`),i.length?(i.push(`Please check the configuration in ${n}`),hi(i.join(`
|
|
792
|
-
|
|
793
|
-
`))):Wt({})}function Ik(e){let t=e.api_version;if(!t)return!1;let{year:n,month:i}=Ur(t)??{year:0,month:0};return n>2025||n===2025&&i>=10}function lp(e){return e.replace(/\.render$/,".should-render")}function jT(e,t){let n=e.build_manifest.assets[st.ShouldRender];if(n)return{identifier:st.ShouldRender,outputFileName:n.filepath,content:t?`import shouldRender from '${n.module}';shopify.extend('${lp(e.target)}', (...args) => shouldRender(...args));`:`import '${n.module}'`}}var Uk=MT;l();var Ok=1024,Mk=128,BT=Mk*Ok,zT="@shopify/web-pixels-extension",WT=ge.extend({runtime_context:u.string(),version:u.string().optional(),configuration:u.any(),customer_privacy:u.object({analytics:u.boolean(),preferences:u.boolean(),marketing:u.boolean(),sale_of_data:u.enum(["enabled","disabled","ldu"])}).optional(),settings:u.any()}),HT=le({identifier:"web_pixel_extension",dependency:zT,partnersWebIdentifier:"web_pixel",schema:WT,appModuleFeatures:e=>["esbuild","single_js_entry_path"],getOutputRelativePath:e=>`dist/${e.handle}.js`,clientSteps:[{lifecycle:"deploy",steps:[{id:"bundle-ui",name:"Bundle UI Extension",type:"bundle_ui",config:{}}]}],deployConfig:async(e,t)=>({runtime_context:e.runtime_context,customer_privacy:e.customer_privacy,runtime_configuration_definition:e.settings}),buildValidation:async(e,t)=>{let n=await oo(t);if(n>BT){let i=`${(n/Ok).toFixed(2)} kB`;throw new y(`Your web pixel extension exceeds the total file size limit (${Mk} kB). It's currently ${i}.`,"Reduce your total file size and try again.")}},preDeployValidation:async e=>{if(e.configuration.configuration)throw new y("The property configuration is deprecated and no longer supported.","It has been replaced by settings.");return Promise.resolve()}}),Lk=HT;l();var GT=u.object({handle:u.string()}),KT=ge.extend({name:u.string(),include:u.array(GT).optional(),includes:u.array(u.string()).optional(),type:u.literal("editor_extension_collection")}).transform(e=>{let t=e.includes?.map(i=>({handle:i}))??[],n=e.include??[];return{...e,inCollection:[...t,...n]}}),YT=le({identifier:"editor_extension_collection",schema:KT,appModuleFeatures:e=>[],deployConfig:async(e,t)=>({name:e.name,handle:e.handle,in_collection:e.inCollection,localization:await yt(t,e.name)})}),$k=YT;l();var Vk="specifications",QT=["json","toml","yaml","yml","svg"],JT=xn({identifier:"channel_config",uidStrategy:"single",experience:"extension",clientSteps:[{lifecycle:"deploy",steps:[{id:"copy-files",name:"Copy Files",type:"include_assets",config:{inclusions:[{type:"pattern",baseDir:Vk,destination:Vk,include:QT.map(e=>`**/*.${e}`)}]}}]}],appModuleFeatures:()=>[]}),qk=JT;l();var jk="icons",XT=["svg"],ZT=xn({identifier:"order_attribution_config",uidStrategy:"single",experience:"extension",clientSteps:[{lifecycle:"deploy",steps:[{id:"copy-files",name:"Copy Files",type:"include_assets",config:{inclusions:[{type:"pattern",baseDir:jk,destination:jk,include:XT.map(e=>`**/*.${e}`)}]}}]}],appModuleFeatures:()=>[]}),Bk=ZT;l();var eF=xn({identifier:"admin_link",uidStrategy:"uuid",experience:"extension",clientSteps:[{lifecycle:"deploy",steps:[{id:"include-admin-link-assets",name:"Include Admin Link Assets",type:"include_assets",config:{generatesAssetsManifest:!0,inclusions:[{type:"configKey",anchor:"targeting[]",groupBy:"target",key:"targeting[].tools"},{type:"configKey",anchor:"targeting[]",groupBy:"target",key:"targeting[].instructions"},{type:"configKey",anchor:"targeting[]",groupBy:"target",key:"targeting[].intents[].schema"}]}}]}],appModuleFeatures:()=>["localization","ui_preview"]}),zk=eF;var Wk=[Fr,Ci,Pr,Eo,Qc,Xc,Kc,Yc,Tr];async function qo(){let e=(t,n)=>Wk.indexOf(t.identifier)-Wk.indexOf(n.identifier);return tF().sort(e)}function tF(){let e=[oh,cy,yv,py,vv,bv,Dy,Vh,_v],t=[Sv,xv,Uv,Mv,Fv,Lv,sk,lk,ck,pk,hk,Uk,Lk,$k,qk,Bk,zk];return[...e,...t]}l();var nF={type:{type:"string"},handle:{type:"string"},uid:{type:"string"},path:{type:"string"},extensions:{}};async function Hk(e,t,n="strip"){let i=t?.jsonSchema;if(i===void 0||yi(JSON.parse(i)))return e.parseConfigurationObject;let o=await Ea(i);o.properties={...nF,...o.properties};let r=e.identifier;return s=>{let c=e.parseConfigurationObject(s),p=(c.state==="ok"?c.data:void 0)??s,m=jm(p,o,n,r),h=c.errors??[];m.state==="error"&&(h=h.concat(m.errors));let g=new Set;return h=h.filter(f=>{let v=JSON.stringify({path:f.path,message:f.message});return g.has(v)?!1:(g.add(v),!0)}),c.state!=="ok"||h.length>0?{state:"error",data:void 0,errors:h}:{state:"ok",data:m.data,errors:void 0}}}async function jo({developerPlatformClient:e,app:t}){let i=(await e.specifications(t)).filter(a=>["extension","configuration"].includes(a.experience)).map(a=>(a.identifier==="theme_app_extension"&&(a.identifier="theme"),a.identifier==="subscription_management"&&(a.identifier="product_subscription"),a.identifier==="checkout_post_purchase"&&(a.surface="post_purchase"),a.identifier==="webhook_subscription"&&(a.experience="configuration",a.uidStrategy="dynamic"),a)),o=await qo();return[...await iF(o,i)]}async function iF(e,t){let n=t.map(async a=>{let s=e.find(p=>p.identifier===a.identifier);if(!s&&a.validationSchema?.jsonSchema&&(s=await rF(a,a.validationSchema)),!s)return;let c=oF(s,a),d=await Hk(c,a.validationSchema,c.experience==="extension"?"fail":"strip");return{...c,parseConfigurationObject:d}}),i=zt(await Promise.all(n)),o=e.filter(a=>!i.find(s=>s.identifier===a.identifier));o.length>0&&S(`The following extension specifications were defined locally but not found in the remote specifications: ${o.map(a=>a.identifier).sort().join(", ")}`);let r=t.filter(a=>!i.find(s=>s.identifier===a.identifier));return r.length>0&&S(`The following extension specifications were found in the remote specifications but not defined locally: ${r.map(a=>a.identifier).sort().join(", ")}`),i}function oF(e,t){return{...e,loadedRemoteSpecs:!0,externalName:t.externalName,externalIdentifier:t.externalIdentifier,experience:t.experience,registrationLimit:t.registrationLimit,uidStrategy:t.uidStrategy,surface:t.surface??e.surface}}async function rF(e,t){let i=(await Ea(t.jsonSchema)).properties?.localization!==void 0;return{...xn({identifier:e.identifier,uidStrategy:e.uidStrategy,experience:e.experience,appModuleFeatures:()=>i?["localization"]:[]}),loadedRemoteSpecs:!0}}l();async function Rn(e,t=!0){let{remoteApp:n,appDirectory:i,developerPlatformClient:o}=await aF(e),r=await jo({developerPlatformClient:o,app:n}),a=n.flags,s=await cp(e,r,a,n.apiKey),c=await lF(n,e,{appDirectory:s.appDirectory});await Oi(n,o.organizationSource);let d=await pp({configFileName:c,remoteApp:n,developerPlatformClient:o,specifications:r,flags:a,appDirectory:i,localAppOptions:s});return t&&pF(c,d.name,s.packageManager),{remoteApp:n,configFileName:c,configuration:d}}async function aF(e){let{creationOptions:t,appDirectory:n}=await sF(e),i=n??e.directory;if(e.apiKey){let a=await Po({apiKey:e.apiKey});if(!a){let s=dv(e.apiKey);throw new y(s.message,s.tryMessage)}return e.isNewApp&&(a.newApp=!0),{remoteApp:a,appDirectory:i,developerPlatformClient:a.developerPlatformClient}}let o=await mv({...t,directory:i}),r=o.developerPlatformClient;return{remoteApp:o,appDirectory:i,developerPlatformClient:r}}async function sF(e){let t={isLaunchable:!1,scopesArray:[],name:"",directory:e.directory,isEmbedded:!1};try{let n=await fg({specifications:await qo(),directory:e.directory,userProvidedConfigName:e.configName,remoteFlags:void 0,skipPrompts:!0});return{creationOptions:n.creationDefaultOptions(),appDirectory:n.directory}}catch{return{creationOptions:t}}}async function cp(e,t,n,i){let o=await hg({directory:e.directory,configName:e.configName,specifications:t,remoteFlags:n,skipPrompts:!0});switch(o.state){case"loaded-app":{let{app:r,configuration:a}=o;return a.client_id===i||e.isNewApp?{state:"reusable-current-app",scopes:vt(a),localAppIdMatchedRemote:!0,existingBuildOptions:a.build,existingConfig:{...a},appDirectory:r.directory,packageManager:o.packageManager}:{state:"unable-to-reuse-current-config",scopes:"",localAppIdMatchedRemote:!0,appDirectory:void 0,existingBuildOptions:void 0,existingConfig:void 0,packageManager:"npm"}}case"loaded-template":return{state:"reusable-current-app",scopes:o.scopes,localAppIdMatchedRemote:!0,existingBuildOptions:void 0,existingConfig:o.rawConfig,appDirectory:o.appDirectory,packageManager:o.packageManager};case"error":return{state:"unable-to-load-config",scopes:"",localAppIdMatchedRemote:!1,appDirectory:void 0,existingBuildOptions:void 0,existingConfig:void 0,packageManager:"npm"}}}async function lF(e,t,n){if(t.configName)return dt(t.configName);let i=Xa();if(i?.selectedToml)return i.selectedToml;let o=await Ao(t.directory),r=o[e.apiKey];return r||(yi(o)?"shopify.app.toml":Lh(n.appDirectory??t.directory,e.title))}async function pp(e){let{remoteApp:t,developerPlatformClient:n,specifications:i,flags:o,configFileName:r,appDirectory:a,localAppOptions:s}=e,c=k(a,r),d=await Fo(t,n,i,o);if(!d){let h=s.scopes;d=dF(t,h)}let p=(h,g)=>g,m={...rt({...s.existingConfig??{}},{client_id:t.apiKey,...d},p),build:cF({existingBuildOptions:s.existingBuildOptions,linkedAppAndClientIdFromFileAreInSync:s.localAppIdMatchedRemote,linkedAppWasNewlyCreated:!!t.newApp,defaultToUpdateUrlsOnDev:n.supportsDevSessions})};return delete m.scopes,await sv(m,c),Pc(m,{configFileName:r,directory:a}),m}function cF(e){let{existingBuildOptions:t,linkedAppAndClientIdFromFileAreInSync:n,linkedAppWasNewlyCreated:i,defaultToUpdateUrlsOnDev:o}=e,r={...i?{include_config_on_deploy:!0}:{},...o&&i?{automatically_update_urls_on_dev:!0}:{},...n?t:{}};if(!yi(r))return r}function pF(e,t,n){j({headline:`${e} is now linked to "${t}" on Shopify`,body:`Using ${e} as your default config.`,nextSteps:[[`Make updates to ${e} in your local project`],["To upload your config, run",{command:Be(n,"shopify app deploy")}]],reference:[{link:{label:"App configuration",url:"https://shopify.dev/docs/apps/tools/cli/configuration"}}]})}function dF(e,t){return{...yF(e),...gF(e),...fF(e),...hF(t,e),...mF(e),...uF(e)}}function uF(e){let t={application_url:e.applicationUrl?.replace(/\/$/,"")??"",embedded:e.embedded??!0};return e.preferencesUrl?{...t,app_preferences:{url:e.preferencesUrl}}:{...t}}function mF(e){return e.appProxy?.url?{app_proxy:{url:e.appProxy.url,subpath:e.appProxy.subPath,prefix:e.appProxy.subPathPrefix}}:{}}function fF(e){let t=e.gdprWebhooks?.customerDataRequestUrl??e.gdprWebhooks?.customerDeletionUrl??e.gdprWebhooks?.shopDeletionUrl,n={privacy_compliance:{customer_data_request_url:e.gdprWebhooks?.customerDataRequestUrl,customer_deletion_url:e.gdprWebhooks?.customerDeletionUrl,shop_deletion_url:e.gdprWebhooks?.shopDeletionUrl}};return{webhooks:{api_version:e.webhookApiVersion??"2023-07",...t?n:{}}}}function hF(e,t){let n={};return t.requestedAccessScopes?n={scopes:t.requestedAccessScopes.join(",")}:e===""?n={use_legacy_install_flow:!0}:n={scopes:e,use_legacy_install_flow:!0},{auth:{redirect_urls:t.redirectUrlWhitelist??[]},access_scopes:n}}function gF(e){return{pos:{embedded:e.posEmbedded??!1}}}function yF(e){return{name:e.title}}l();async function Gk(e,t){if(t.supportsAtomicDeployments)for(let n of e)await vF(n)}async function vF(e){if(!e.isUUIDStrategyExtension||e.configuration.uid)return;let t=await _e.read(e.configurationPath),n=Oe(t.content,"extensions");if(!("uid"in t.content)){if(n){let i=n.find(o=>o.handle===e.handle);if(i&&"uid"in i)return}if(n){let i=e.handle;await t.transformRaw(o=>{let r=new RegExp(`(\\n?(\\s*)handle\\s*=\\s*"${i}")`);return o.replace(r,`$1
|
|
794
|
-
$2uid = "${e.uid}"`)})}else await t.patch({uid:e.uid})}}function Kk(e){let t=Ti(e);return w`${b.errorText("Validation error")} in ${b.path(e.file)}:\n\n${t}`}async function B({directory:e,clientId:t,forceRelink:n,userProvidedConfigName:i,unsafeTolerateErrors:o=!1}){let r,a,s;if(n){let _=await Rn({directory:e,apiKey:t});s=_.remoteApp;let x=await Tt(e,_.configFileName);r=x.project,a=x.activeConfig}else{let _=await Tt(e,i);if(r=_.project,a=_.activeConfig,a.file.errors.length>0)throw new y(a.file.errors.map(x=>x.message).join(`
|
|
795
|
-
`));if(!a.isLinked){let x=await Rn({directory:e,apiKey:t,configName:$(a.file.path)});s=x.remoteApp;let E=await Tt(e,x.configFileName);r=E.project,a=E.activeConfig}}let c=a.file.content.client_id;if(typeof c!="string"||c.length===0)throw new L(`Active config at ${a.file.path} is marked as linked but has no client_id`);s??(s=await Po({apiKey:t??c}));let p=s.developerPlatformClient,m=await fs(s.organizationId,p),h=await jo({developerPlatformClient:p,app:s}),g=await No({project:r,activeConfig:a,specifications:h,remoteFlags:s.flags,clientIdOverride:t&&t!==c?t:void 0});if(!o&&!g.errors.isEmpty())throw new y(Kk(g.errors.getErrors()[0]));let f=Ni(e),v=s.apiKey===g.configuration.client_id;return(!f||v)&&Tn({appId:s.apiKey,title:s.title,directory:e,orgId:s.organizationId}),await kF(s,m,n),g.errors.isEmpty()&&await Gk(g.allExtensions,p),{project:r,activeConfig:a,app:g,remoteApp:s,developerPlatformClient:p,specifications:h,organization:m}}async function kF(e,t,n){let i;t.source===kt.BusinessPlatform?i={business_platform_id:tr(t.id)}:i={partner_id:tr(t.id)},await Q.addPublicMetadata(()=>({...i,api_key:e.apiKey,cmd_app_reset_used:n}))}async function bt({directory:e,userProvidedConfigName:t}){let{project:n,activeConfig:i}=await Tt(e,t);if(i.file.errors.length>0)throw new y(i.file.errors.map(a=>a.message).join(`
|
|
796
|
-
`));let o=await qo(),r=await No({project:n,activeConfig:i,specifications:o,ignoreUnknownExtensions:!0});if(!r.errors.isEmpty())throw new y(Kk(r.errors.getErrors()[0]));return{app:r,project:n}}l();l();var Mi=class extends fo{environmentsFilename(){return me.appEnvironments}};var tt=class extends Mi{};var Yk=O(ke(),1);var dp,Un=class extends tt{async run(){let{flags:t}=await this.parse(dp),n=t["client-id"];await mt(()=>({cmd_app_dependency_installation_skipped:t["skip-dependencies-installation"]}));let{app:i,project:o}=await bt({directory:t.path,userProvidedConfigName:t.config});return await Hf({app:i,project:o,skipDependenciesInstallation:t["skip-dependencies-installation"],apiKey:n}),{app:i}}};dp=Un;Un.summary="Build the app, including extensions.";Un.descriptionWithMarkdown="This command executes the build script specified in the element's TOML file. You can specify a custom script in the file. To learn about configuration files in Shopify apps, refer to [App configuration](https://shopify.dev/docs/apps/tools/cli/configuration).\n\n If you're building a [theme app extension](https://shopify.dev/docs/apps/online-store/theme-app-extensions), then running the `build` command runs [Theme Check](https://shopify.dev/docs/themes/tools/theme-check) against your extension to ensure that it's valid.";Un.description=dp.descriptionWithoutMarkdown();Un.flags={...T,...I,"skip-dependencies-installation":Yk.Flags.boolean({hidden:!1,description:"Skips the installation of dependencies. Deprecated, use workspaces instead.",env:"SHOPIFY_FLAG_SKIP_DEPENDENCIES_INSTALLATION",default:!1})};var Qk=Un;l();l();var M=class extends Mi{};l();l();l();async function up(e,t,n){let i=n.clientName===wt.AppManagement,o;n.supportsStoreSearch&&(o=async s=>n.devStoresForOrg(t.id,s));let r=await Rc({onSearchForStoresByName:o,...e,showDomainOnPrompt:i});if(!r){if(oe({body:await n.getCreateDevStoreLink(t)}),await Nt(5),!await vg(t))throw new Ml;let c=await wF(t.id,n);r=await up({stores:c,hasMorePages:!1},t,n)}let a=await Ps(r,t.id,n,"prompt-first");for(;!a;){if(r=await Rc({stores:[r],hasMorePages:!1,showDomainOnPrompt:i}),!r)throw new Ml;a=await Ps(r,t.id,n,"prompt-first")}return r}async function wF(e,t){let o=[];return await xe([{title:"Fetching organization data",task:async()=>{for(let a=0;a<10;a++){let{stores:s}=await t.devStoresForOrg(e);if(s.length>0){o=s;return}await Nt(3)}}}]),o}async function Ps(e,t,n,i){if(e.transferDisabled||_n())return!0;if(!e.transferDisabled&&!e.convertableToPartnerTest)throw new y(`The store you specified (${e.shopDomain}) is not a dev store`,"Run dev --reset and select an eligible dev store.");switch(i){case"prompt-first":return await yg()?(await _F(e,t,n),!0):!1;case"never":throw new y("The store you specified is not transfer-disabled","Try running 'dev --reset' and selecting a different store, or choosing to convert this one.")}}async function _F(e,t,n){let i={input:{organizationID:parseInt(t,10),shopId:e.shopId}},o=await n.convertToTransferDisabledStore(i);if(!o.convertDevToTestStore.convertedToTestStore){let r=o.convertDevToTestStore.userErrors.map(a=>a.message).join(", ");throw new L(`Error converting store ${e.shopDomain} to a transfer-disabled store: ${r}`,"This store might not be compatible with draft apps, please try a different store")}sr(`Converted ${e.shopDomain} to a transfer-disabled store`)}async function Lt({appContextResult:e,storeFqdn:t,forceReselectStore:n,storeTypes:i=["APP_DEVELOPMENT"]}){let{app:o,organization:r,developerPlatformClient:a}=e,s,c=o.configuration.build?.dev_store_url,d=o.hiddenConfig.dev_store_url,p=c??d,h=t??(n?void 0:p),g=i.length===1&&i[0]==="APP_DEVELOPMENT";if(h)s=await hs(r,h,a,i),g&&await Ps(s,r.id,a,"never");else{let f=await a.devStoresForOrg(r.id);s=await up(f,r,a)}return await bF(s,n),s.shopDomain=K(s.shopDomain),(s.shopDomain!==p||!d)&&await o.updateHiddenConfig({dev_store_url:s.shopDomain}),await a.ensureUserAccessToStore(r.id,s),s}async function bF(e,t){await Q.addPublicMetadata(()=>({cmd_app_reset_used:t,store_fqdn_hash:ut(e.shopDomain)})),await Q.addSensitiveMetadata(()=>({store_fqdn:e.shopDomain}))}l();var mp=O(Al(),1);async function Bo(e,t){let n=e.apiSecretKeys[0]?.secret;if(!n)throw new L("No API secret keys found for app");return gi(t,e.apiKey,n)}function Is(e){let t;try{t=(0,mp.parse)(e)}catch(i){throw i instanceof Error?new y(`Invalid GraphQL syntax: ${i.message}`):i}if(t.definitions.filter(i=>i.kind==="OperationDefinition").length!==1)throw new y("GraphQL document must contain exactly one operation definition. Multiple operations are not supported.")}async function Li(e){let{adminSession:t,userSpecifiedVersion:n,minimumDefaultVersion:i}=e;if(n==="unstable")return n;let o=await sm(t);if(!n){let c=o.filter(d=>d.supported).map(d=>d.handle);return i&&c.push(i),c.sort().reverse()[0]}let r=o.map(c=>c.handle);if(r.includes(n))return n;let a=w`Invalid API version: ${n}`.value,s=w`Allowed versions: ${r.join(", ")}`.value;throw new y(a,s)}function $i(e){let{organization:t,remoteApp:n,storeFqdn:i,version:o}=e,r=[`Organization: ${t.businessName}`,`App: ${n.title}`,`Store: ${i}`];return o&&r.push(`API version: ${o}`),r}function Mr(e){return(0,mp.parse)(e).definitions.find(i=>i.kind==="OperationDefinition")?.operation==="mutation"}function Ds(e,t){if(Mr(e)&&t.storeType!=="APP_DEVELOPMENT")throw new y("Mutations can only be executed on dev stores.")}async function Lr(e){let t=await B({directory:e.path,clientId:e["client-id"],forceRelink:e.reset,userProvidedConfigName:e.config}),n=await Lt({appContextResult:t,storeFqdn:e.store,forceReselectStore:e.reset,storeTypes:["APP_DEVELOPMENT","DEVELOPMENT","DEVELOPMENT_SUPERSET","PRODUCTION"]});return{appContextResult:t,store:n}}async function Rs(e){let t;if(e.query!==void 0){if(!e.query.trim())throw new y("The --query flag value is empty. Please provide a valid GraphQL query or mutation.");t=e.query}else if(e["query-file"]){let o=e["query-file"];if(!await C(o))throw new y(w`Query file not found at ${b.path(o)}. Please check the path and try again.`);if(t=await P(o,{encoding:"utf8"}),!t.trim())throw new y(w`Query file at ${b.path(o)} is empty. Please provide a valid GraphQL query or mutation.`)}if(!t)throw new L("Query should have been provided via --query or --query-file flags due to exactlyOne constraint. This indicates the oclif flag validation failed.");Is(t);let{appContextResult:n,store:i}=await Lr(e);return{query:t,appContextResult:n,store:i}}l();l();l();l();var Vi="2026-01";l();var Us={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetBulkOperationById"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"bulkOperation"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"type"}},{kind:"Field",name:{kind:"Name",value:"completedAt"}},{kind:"Field",name:{kind:"Name",value:"createdAt"}},{kind:"Field",name:{kind:"Name",value:"errorCode"}},{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"objectCount"}},{kind:"Field",name:{kind:"Name",value:"partialDataUrl"}},{kind:"Field",name:{kind:"Name",value:"status"}},{kind:"Field",name:{kind:"Name",value:"url"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};l();var Jk={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"ListBulkOperations"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"query"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"first"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"sortKey"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"BulkOperationsSortKeys"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"bulkOperations"},arguments:[{kind:"Argument",name:{kind:"Name",value:"first"},value:{kind:"Variable",name:{kind:"Name",value:"first"}}},{kind:"Argument",name:{kind:"Name",value:"query"},value:{kind:"Variable",name:{kind:"Name",value:"query"}}},{kind:"Argument",name:{kind:"Name",value:"sortKey"},value:{kind:"Variable",name:{kind:"Name",value:"sortKey"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"nodes"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"status"}},{kind:"Field",name:{kind:"Name",value:"errorCode"}},{kind:"Field",name:{kind:"Name",value:"objectCount"}},{kind:"Field",name:{kind:"Name",value:"createdAt"}},{kind:"Field",name:{kind:"Name",value:"completedAt"}},{kind:"Field",name:{kind:"Name",value:"url"}},{kind:"Field",name:{kind:"Name",value:"partialDataUrl"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};function Os(e){return e.startsWith("gid://")?e:/^\d+$/.test(e)?`gid://shopify/BulkOperation/${e}`:e}function $r(e){return e.match(/^gid:\/\/shopify\/BulkOperation\/(\d+)$/)?.[1]??e}async function Xk(e){let{organization:t,storeFqdn:n,operationId:i,remoteApp:o}=e;oe({headline:"Checking bulk operation status.",body:[{list:{items:$i({organization:t,remoteApp:o,storeFqdn:n})}}]});let r=o.apiSecretKeys[0]?.secret;if(!r)throw new L("No API secret keys found for app");let a=await gi(n,o.apiKey,r),s=await Xe({query:Us,session:a,variables:{id:i},version:await Li({adminSession:a,minimumDefaultVersion:Vi})});s.bulkOperation?SF(s.bulkOperation):Te({headline:"Bulk operation not found.",body:w`ID: ${b.yellow(i)}`.value})}async function Zk(e){let{organization:t,storeFqdn:n,remoteApp:i}=e;oe({headline:"Listing bulk operations.",body:[{list:{items:$i({organization:t,remoteApp:i,storeFqdn:n})}}]});let o=i.apiSecretKeys[0]?.secret;if(!o)throw new L("No API secret keys found for app");let r=await gi(n,i.apiKey,o),a=new Date(Date.now()-10080*60*1e3).toISOString().split("T")[0],c=(await Xe({query:Jk,session:r,variables:{query:`created_at:>=${a}`,first:100,sortKey:"CREATED_AT"},version:await Li({adminSession:r,minimumDefaultVersion:Vi})})).bulkOperations.nodes.map(d=>({id:$r(d.id),status:EF(d.status),count:CF(d.objectCount),dateCreated:ir(new Date(String(d.createdAt))),dateFinished:d.completedAt?ir(new Date(String(d.completedAt))):"",results:NF(d.url??d.partialDataUrl)}));uo(),c.length===0?oe({body:"No bulk operations found in the last 7 days."}):co({rows:c,columns:{id:{header:"ID",color:"yellow"},status:{header:"STATUS"},count:{header:"COUNT"},dateCreated:{header:"DATE CREATED",color:"cyan"},dateFinished:{header:"DATE FINISHED",color:"cyan"},results:{header:"RESULTS"}}}),uo()}function SF(e){let{id:t,status:n,createdAt:i,completedAt:o,url:r,partialDataUrl:a}=e,s=qi(e).value,c=xF(i,o),d=w`ID: ${b.yellow(t)}\n${c}`.value;if(n==="COMPLETED"){let p=r?b.link("Download results",r):"";j({headline:s,body:w`${d}\n${p}`.value})}else if(n==="FAILED"){let p=a?b.link("Download partial results",a):"";Te({headline:s,body:w`${d}\n${p}`.value})}else oe({headline:s,body:d})}function xF(e,t){let n=new Date;return t?`Finished ${El(new Date(String(t)),n)}`:`Started ${El(new Date(String(e)),n)}`}function EF(e){return e==="COMPLETED"?ve.green(e):e==="FAILED"?ve.red(e):ve.dim(e)}function CF(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function NF(e){return e?w`${b.link("download",e)}`.value:""}function qi(e){switch(e.status){case"RUNNING":return w`Bulk operation in progress${e.objectCount>0?b.gray(` (${String(e.objectCount)} objects ${e.type==="MUTATION"?"written":"read"})`):""}`;case"CREATED":return w`Starting`;case"COMPLETED":return w`Bulk operation succeeded: ${b.gray(`${String(e.objectCount)} objects`)}`;case"FAILED":return w`Bulk operation failed. ${b.errorText(`Error: ${e.errorCode??"unknown"}`)}`;case"CANCELING":return w`Bulk operation canceling...`;case"CANCELED":return w`Bulk operation canceled.`;case"EXPIRED":return w`Bulk operation expired.`;default:return w`Bulk operation status: ${e.status}`}}function ew(e,t){let n=e.map(i=>w`${i.field?.join(".")??"unknown"}: ${i.message}`.value).join(`
|
|
797
|
-
`);Te({headline:t,body:n})}function tw(e){let t=qi(e).value;switch(e.status){case"CANCELING":return{headline:"Bulk operation is being cancelled.",body:[`This may take a few moments. Check the status with:
|
|
798
|
-
`,{command:`shopify app bulk status --id=${$r(e.id)}`}],renderType:"success"};case"CANCELED":case"COMPLETED":case"FAILED":{let n=[w`ID: ${b.cyan(e.id)}`.value,w`Status: ${b.yellow(e.status)}`.value,w`Created at: ${b.gray(String(e.createdAt))}`.value,...e.completedAt?[w`Completed at: ${b.gray(String(e.completedAt))}`.value]:[]];return{headline:w`Bulk operation is already ${e.status.toLowerCase()}.`.value,body:w`This operation has already finished and can't be canceled.`.value,customSections:[{body:[{list:{items:n}}]}],renderType:"warning"}}case"CREATED":case"EXPIRED":case"RUNNING":return{headline:t,renderType:"info"}}}l();var nw={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"BulkOperationCancel"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"bulkOperationCancel"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"bulkOperation"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"completedAt"}},{kind:"Field",name:{kind:"Name",value:"createdAt"}},{kind:"Field",name:{kind:"Name",value:"errorCode"}},{kind:"Field",name:{kind:"Name",value:"fileSize"}},{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"objectCount"}},{kind:"Field",name:{kind:"Name",value:"partialDataUrl"}},{kind:"Field",name:{kind:"Name",value:"query"}},{kind:"Field",name:{kind:"Name",value:"rootObjectCount"}},{kind:"Field",name:{kind:"Name",value:"status"}},{kind:"Field",name:{kind:"Name",value:"type"}},{kind:"Field",name:{kind:"Name",value:"url"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"userErrors"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"field"}},{kind:"Field",name:{kind:"Name",value:"message"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};var AF="2026-01";async function iw(e){let{organization:t,storeFqdn:n,operationId:i,remoteApp:o}=e;oe({headline:"Canceling bulk operation.",body:[{list:{items:[`ID: ${i}`,...$i({organization:t,remoteApp:o,storeFqdn:n})]}}]});let r=await Bo(o,n),a=await Xe({query:nw,session:r,variables:{id:i},version:AF});if(a.bulkOperationCancel?.userErrors?.length){ew(a.bulkOperationCancel.userErrors,"Failed to cancel bulk operation.");return}let s=a.bulkOperationCancel?.bulkOperation;if(s){let c=tw(s),d={headline:c.headline,...c.body&&{body:c.body},...c.customSections&&{customSections:c.customSections}};switch(c.renderType){case"success":j(d);break;case"warning":He(d);break;case"info":oe(d);break}}else Te({headline:"Bulk operation not found or could not be canceled.",body:w`ID: ${b.yellow(i)}`.value})}var fp=O(ke(),1);var ow,ji=class extends M{async run(){let{flags:t}=await this.parse(ow),{appContextResult:n,store:i}=await Lr(t);return await iw({organization:n.organization,storeFqdn:i.shopDomain,operationId:Os(t.id),remoteApp:n.remoteApp}),{app:n.app}}};ow=ji;ji.summary="Cancel a bulk operation.";ji.description="Cancels a running bulk operation by ID.";ji.flags={...T,...I,id:fp.Flags.string({description:"The bulk operation ID to cancel (numeric ID or full GID).",env:"SHOPIFY_FLAG_ID",required:!0}),store:fp.Flags.string({char:"s",description:"The store domain. Must be an existing dev store.",env:"SHOPIFY_FLAG_STORE",parse:async e=>K(e)})};var rw=ji;l();var hp=O(ke(),1);var gp,On=class extends M{async run(){let{flags:t}=await this.parse(gp),{appContextResult:n,store:i}=await Lr(t);return t.id?await Xk({organization:n.organization,storeFqdn:i.shopDomain,operationId:Os(t.id),remoteApp:n.remoteApp}):await Zk({organization:n.organization,storeFqdn:i.shopDomain,remoteApp:n.remoteApp}),{app:n.app}}};gp=On;On.summary="Check the status of bulk operations.";On.descriptionWithMarkdown=`Check the status of a specific bulk operation by ID, or list all bulk operations belonging to this app on this store in the last 7 days.
|
|
799
|
-
|
|
800
|
-
Bulk operations allow you to process large amounts of data asynchronously. Learn more about [bulk query operations](https://shopify.dev/docs/api/usage/bulk-operations/queries) and [bulk mutation operations](https://shopify.dev/docs/api/usage/bulk-operations/imports).
|
|
801
|
-
|
|
802
|
-
Use [\`bulk execute\`](https://shopify.dev/docs/api/shopify-cli/app/app-bulk-execute) to start a new bulk operation.`;On.description=gp.descriptionWithoutMarkdown();On.flags={...T,...I,id:hp.Flags.string({description:"The bulk operation ID (numeric ID or full GID). If not provided, lists all bulk operations belonging to this app on this store in the last 7 days.",env:"SHOPIFY_FLAG_ID"}),store:hp.Flags.string({char:"s",description:"The store domain. Must be an existing dev store.",env:"SHOPIFY_FLAG_STORE",parse:async e=>K(e)})};var aw=On;l();var yp,Mn=class extends M{async run(){let{flags:t}=await this.parse(yp),n={directory:t.path,apiKey:t["client-id"],configName:t.config},i=await Rn(n),{app:o}=await B({directory:t.path,clientId:void 0,forceRelink:!1,userProvidedConfigName:i.configFileName});return{app:o}}};yp=Mn;Mn.summary="Fetch your app configuration from the Developer Dashboard.";Mn.descriptionWithMarkdown=`Pulls app configuration from the Developer Dashboard and creates or overwrites a configuration file. You can create a new app with this command to start with a default configuration file.
|
|
803
|
-
|
|
804
|
-
For more information on the format of the created TOML configuration file, refer to the [App configuration](https://shopify.dev/docs/apps/tools/cli/configuration) page.
|
|
805
|
-
`;Mn.description=yp.descriptionWithoutMarkdown();Mn.flags={...T,...I};var sw=Mn;l();var lw=O(ke(),1);var vp,{config:RY,...TF}=I,$t=class extends tt{async run(){let{flags:t,args:n}=await this.parse(vp),{app:i}=await bt({directory:t.path,userProvidedConfigName:n.config});return await Ut(t.path),await Nr({directory:t.path,configName:n.config,reset:t.reset}),{app:i}}};vp=$t;$t.summary="Activate an app configuration.";$t.descriptionWithMarkdown="Sets default configuration when you run app-related CLI commands. If you omit the `config-name` parameter, then you'll be prompted to choose from the configuration files in your project.";$t.description=vp.descriptionWithoutMarkdown();$t.usage="app config use [config] [flags]";$t.flags={...T,...TF};$t.args={config:lw.Args.string({description:"The name of the app configuration. Can be 'shopify.app.staging.toml' or simply 'staging'."})};var cw=$t;l();l();async function kp(e){let{directory:t,configName:n,configPath:i,configuration:o,remoteApp:r}=e;if(!o.client_id)throw new y("The selected configuration is not linked to a remote app.","Run `shopify app config link` first to link this configuration to a Shopify app.");let a=r.developerPlatformClient,s=await jo({developerPlatformClient:a,app:r}),c=r.flags,d={directory:t,configName:n,developerPlatformClient:a,apiKey:o.client_id},p=await cp(d,s,c,r.apiKey),m=$(i),h=await pp({remoteApp:r,developerPlatformClient:a,specifications:s,flags:c,configFileName:m,appDirectory:p.appDirectory??t,localAppOptions:p});return{configPath:i,configuration:h,remoteApp:r}}var wp,Ln=class extends M{async run(){let{flags:t}=await this.parse(wp),{app:n,remoteApp:i}=await B({directory:t.path,clientId:t["client-id"],forceRelink:t.reset,userProvidedConfigName:t.config}),{configuration:o,configPath:r}=await kp({directory:t.path,configName:t.config,configPath:n.configPath,configuration:n.configuration,remoteApp:i});return j({headline:`Pulled latest configuration for "${o.name}"`,body:`Updated ${$(r)} with the remote data.`}),{app:n}}};wp=Ln;Ln.summary="Refresh an already-linked app configuration without prompts.";Ln.descriptionWithMarkdown="Pulls the latest configuration from the already-linked Shopify app and updates the selected configuration file.\n\nThis command reuses the existing linked app and organization and skips all interactive prompts. Use `--config` to target a specific configuration file, or omit it to use the default one.";Ln.description=wp.descriptionWithoutMarkdown();Ln.flags={...T,...I};var pw=Ln;l();l();l();var uw=O(vm(),1),FF=200,PF=6e4,dw=200,IF=500,Ms=class{constructor(t,n,i=FF){this.currentEvents=[],this.extensionPaths=[],this.ignored={},this.extensionWatchedFiles=new Map,this.emitEvents=()=>{let o=this.currentEvents;this.currentEvents=[];let r=`\u{1F509} ${o.length} EVENTS EMITTED in files: ${o.map(a=>a.path).join(`
|
|
806
|
-
`)}`;S(r,this.options.stdout),this.onChangeCallback?.(o)},this.handleFileEvent=(o,r)=>{let a=go(),s=Ne(r),c=r===this.app.configPath,d=r.endsWith(".extension.toml");if(S(`\u{1F300}: ${o} ${r.replace(this.app.directory,"")}
|
|
807
|
-
`),c)this.handleEventForExtension(o,r,this.app.directory,a,!1);else{let p=this.extensionWatchedFiles.get(s),m=p===void 0||p.size===0;if(m&&o==="add"&&!d){let h=this.discoverFileOwners(s);h.size>0&&(this.extensionWatchedFiles.set(s,h),p=h,m=!1)}if(m&&!d&&!c){S(`\u{1F300}: File ${r} is not watched by any extension`,this.options.stdout);return}for(let h of p??[]){let g=this.app.realExtensions.find(v=>v.handle===h),f=g?Ne(g.directory):this.app.directory;this.handleEventForExtension(o,r,f,a,!1,h)}m&&this.handleEventForExtension(o,r,this.app.directory,a,!0)}this.debouncedEmit()},this.close=()=>{this.watcher&&(S("Closing file watcher",this.options.stdout),this.watcher.close().then(()=>S("File watching closed",this.options.stdout)).catch(o=>S(`File watching failed to close: ${o.message}`,this.options.stderr)))},this.app=t,this.options=n,this.debouncedEmit=Su(this.emitEvents.bind(this),i,{leading:!0,trailing:!0}),this.updateApp(t)}onChange(t){this.onChangeCallback=t}async start(){let n=[...this.app.configuration.extension_directories??["extensions"]].map(a=>k(this.app.directory,a));await Promise.all(n.map(async a=>{try{await ae(a.replace(/\/\*+$/,""))}catch{}}));let i=[this.app.configPath,...n],o=this.getAllWatchedFiles();i.push(...o),this.close();let{default:r}=await import("./chokidar-G4ONJSK4.js");this.watcher=r.watch(i,{ignored:["**/node_modules/**","**/.git/**"],persistent:!0,ignoreInitial:!0}),this.watcher.on("all",this.handleFileEvent),this.addAbortListener(),S(`File watcher started with ${i.length} paths`,this.options.stdout)}updateApp(t){this.app=t,this.extensionPaths=this.app.nonConfigExtensions.map(n=>Ne(n.directory)).filter(n=>n!==this.app.directory),this.extensionPaths.forEach(n=>{var i;(i=this.ignored)[n]??(i[n]=this.createIgnoreInstance(n))})}addAbortListener(){this.options.signal.removeEventListener("abort",this.close),this.options.signal.addEventListener("abort",this.close)}getAllWatchedFiles(){this.extensionWatchedFiles.clear();let t=this.app.realExtensions.map(i=>({extension:i,watchedFiles:i.watchedFiles()})),n=new Set;for(let{extension:i,watchedFiles:o}of t)for(let r of o){let a=Ne(r);n.add(a);let s=this.extensionWatchedFiles.get(a)??new Set;s.add(i.handle),this.extensionWatchedFiles.set(a,s)}return Array.from(n)}pushEvent(t){this.shouldIgnoreEvent(t)||(t.type==="extension_folder_created"&&(this.ignored[t.path]=this.createIgnoreInstance(t.path)),!this.currentEvents.some(n=>n.path===t.path&&n.type===t.type&&n.extensionHandle===t.extensionHandle)&&this.currentEvents.push(t))}shouldIgnoreEvent(t){if(t.type==="extension_folder_deleted"||t.type==="extension_folder_created"||t.extensionHandle&&this.extensionWatchedFiles.get(Ne(t.path))?.has(t.extensionHandle))return!1;let i=(t.extensionHandle?this.app.realExtensions.find(r=>r.handle===t.extensionHandle):void 0)?.watchedFiles(),o=this.ignored[t.extensionPath];if(i)return!i.some(a=>un(t.path,a));if(o){let r=z(t.extensionPath,t.path);return o.ignores(r)}return!1}discoverFileOwners(t){let n=new Set;for(let i of this.app.realExtensions){let o=Ne(i.directory);o!==this.app.directory&&t.startsWith(`${o}/`)&&this.pathMatchesWatchPatterns(t,i)&&n.add(i.handle)}return n}pathMatchesWatchPatterns(t,n){let{paths:i,ignore:o}=n.watchPatterns(),r=z(Ne(n.directory),t);return o.some(a=>un(r,a))?!1:i.some(a=>un(r,a))}handleEventForExtension(t,n,i,o,r,a){let s=n.endsWith(".extension.toml"),c=n===this.app.configPath;switch(t){case"change":if(r)break;s||c?this.pushEvent({type:"extensions_config_updated",path:n,extensionPath:i,extensionHandle:a,startTime:o}):this.pushEvent({type:"file_updated",path:n,extensionPath:i,extensionHandle:a,startTime:o});break;case"add":if(!s){this.pushEvent({type:"file_created",path:n,extensionPath:i,extensionHandle:a,startTime:o});break}let d=0,p=H(n),m=setInterval(()=>{Se(k(p,me.lockFile))?(S(`Waiting for extension to complete creation: ${n}
|
|
808
|
-
`),d+=dw):(clearInterval(m),this.extensionPaths.push(p),this.pushEvent({type:"extension_folder_created",path:p,extensionPath:i,startTime:o}),this.debouncedEmit()),d>=PF&&(clearInterval(m),this.options.stderr.write(`Error loading new extension at path: ${n}.
|
|
809
|
-
Please restart the process.`))},dw);break;case"unlink":if(n.endsWith(me.lockFile))break;c?this.pushEvent({type:"app_config_deleted",path:n,extensionPath:i,startTime:o}):s?(this.extensionPaths=this.extensionPaths.filter(h=>h!==i),this.pushEvent({type:"extension_folder_deleted",path:i,extensionPath:i,startTime:o})):setTimeout(()=>{this.extensionPaths.includes(i)&&(this.pushEvent({type:"file_deleted",path:n,extensionPath:i,extensionHandle:a,startTime:o}),this.extensionWatchedFiles.delete(Ne(n)),this.debouncedEmit())},IF);break;case"addDir":case"unlinkDir":break}}createIgnoreInstance(t){let n=k(t,".gitignore");if(!Se(n))return;let i=ct(n).toString().split(`
|
|
810
|
-
`).map(o=>o.trim()).filter(o=>o!==""&&!o.startsWith("#"));return uw.default.default().add(i)}};l();l();function mw(e,t,n=!0){let i=e.realExtensions,o=i.map(p=>p.uid),r=t.realExtensions,a=r.map(p=>p.uid),s=r.filter(p=>!o.includes(p.uid)),c=i.filter(p=>!a.includes(p.uid)),d;return n&&(d=r.filter(p=>{let m=i.find(f=>f.uid===p.uid);if(!m)return!1;let h=JSON.stringify(m.configuration)!==JSON.stringify(p.configuration),g=m.configurationPath!==p.configurationPath;return h||g})),{created:s,updated:d??[],deleted:c}}async function gw(e,t,n){if(e[0]===void 0)return;let i=e.some(a=>fw.includes(a.type)),o=e.filter(a=>!fw.includes(a.type));if(i)return OF({event:e[0],app:t,options:n,extensions:[]});let r={app:t,extensionEvents:[],path:e[0].path,startTime:e[0].startTime};for(let a of o){let s=a.extensionHandle?t.realExtensions.filter(d=>d.handle===a.extensionHandle):t.realExtensions.filter(d=>d.directory===a.extensionPath),c=DF[a.type]({event:a,app:r.app,extensions:s,options:n});r.extensionEvents.push(...c.extensionEvents)}return r}var fw=["extensions_config_updated","extension_folder_created"],DF={extension_folder_deleted:RF,file_created:_p,file_deleted:_p,file_updated:_p,app_config_deleted:UF,extension_folder_created:hw,extensions_config_updated:hw};function RF({event:e,app:t,extensions:n}){let i=n.map(o=>(t.removeExtension(o.uid),{type:ye.Deleted,extension:o}));return{app:t,extensionEvents:i,startTime:e.startTime,path:e.path}}function _p({event:e,app:t,extensions:n}){let i=n.map(o=>({type:ye.Updated,extension:o}));return{app:t,extensionEvents:i,startTime:e.startTime,path:e.path}}function hw(e){return{app:e.app,extensionEvents:[],startTime:e.event.startTime,path:e.event.path}}function UF(e){throw new y("The active app.toml was deleted, exiting")}async function OF({event:e,app:t}){let n=await MF(t),i=mw(t,n,!0),o=i.created.map(c=>({type:ye.Created,extension:c})),r=i.deleted.map(c=>({type:ye.Deleted,extension:c})),a=i.updated.map(c=>({type:ye.Updated,extension:c})),s=[...o,...r,...a];return{app:n,extensionEvents:s,startTime:e.startTime,path:e.path,appWasReloaded:!0}}async function MF(e){let t=go();try{let n=await on(e);return S(`App reloaded [${_i(t)}ms]`),n}catch(n){let i=new Error(`Error reloading app: ${n.message}`);throw i.cause="validation-error",i}}import{formatMessagesSync as LF}from"esbuild";import $F from"events";var ye;(function(e){e.Updated="changed",e.Deleted="deleted",e.Created="created"})(ye||(ye={}));var $n=class extends $F{constructor(t,n,i,o){super(),this.started=!1,this.ready=!1,this.initialEvents=[],this.app=t,this.appURL=n,this.buildOutputPath=i??k(t.directory,".shopify","dev-bundle"),this.options={stdout:process.stdout,stderr:process.stderr,signal:new Bd},this.fileWatcher=o}async start(t,n=!0){this.started||(this.started=!0,this.options=t??this.options,await C(this.buildOutputPath)&&await mi(this.buildOutputPath,{force:!0}),await ae(this.buildOutputPath),n&&(this.initialEvents=this.app.realExtensions.map(i=>({type:ye.Updated,extension:i})),await this.buildExtensions(this.initialEvents)),this.fileWatcher=this.fileWatcher??new Ms(this.app,this.options),this.fileWatcher.onChange(i=>{gw(i,this.app,this.options).then(async o=>{if(o?.extensionEvents.length===0&&S("Change detected, but no extensions were affected"),!o)return;this.app=o.app,o.appWasReloaded&&this.fileWatcher?.updateApp(this.app),await this.rescanImports(o);let r=o.extensionEvents.filter(a=>a.type!==ye.Deleted);await this.buildExtensions(r),o.appWasReloaded||await this.app.generateExtensionTypes(),await this.deleteExtensionsBuildOutput(o),this.emit("all",o)}).catch(o=>{this.emit("error",o)})}),await this.fileWatcher.start(),this.ready=!0,this.emit("ready",{app:this.app,extensionEvents:this.initialEvents}))}onEvent(t){return this.addListener("all",t),this}onStart(t){if(this.ready){let n={app:this.app,extensionEvents:this.initialEvents,startTime:[0,0],path:""};t(n)?.catch(()=>{})}else this.once("ready",t);return this}onError(t){return this.addListener("error",t),this}async deleteExtensionsBuildOutput(t){let i=t.extensionEvents.filter(o=>o.type===ye.Deleted).map(o=>o.extension).map(async o=>{let r=k(this.buildOutputPath,o.getOutputFolderId());return mi(r,{force:!0})});await Promise.all(i)}async buildExtensions(t){let n=Yt(t,r=>r.extension.uid),i=[];for(let r of Object.values(n))r.length>0&&r[0]&&i.push({extension:r[0].extension,events:r});let o=i.map(async({extension:r,events:a})=>je({outputPrefix:r.handle,stripAnsi:!1},async()=>{try{await this.buildExtension(r);let s={status:"ok",uid:r.uid};a.forEach(c=>{c.buildResult=s})}catch(s){let c=s.errors??[],d=s.message,p;if(c.length){let h=c[0];d=h?.text,p=h?.location?.file,LF(c,{kind:"error",color:!ft()}).forEach(f=>{this.options.stderr.write(f)})}else this.options.stderr.write(s.message);let m={status:"error",error:d,file:p,uid:r.uid};a.forEach(h=>{h.buildResult=m})}}));return Promise.all(o)}async buildExtension(t){let n={app:this.app,stdout:this.options.stdout,stderr:this.options.stderr,useTasks:!1,environment:"development",appURL:this.appURL};await t.buildForBundle(n,this.buildOutputPath)}async rescanImports(t){if(t.path.endsWith(".toml"))return;let i=t.extensionEvents.filter(o=>o.type!==ye.Deleted).map(o=>o.extension);i.length>0&&(await Promise.all(i.map(async a=>a.rescanImports()))).some(a=>a)&&await this.fileWatcher?.start()}};var zo=class e extends M{async run(){let{flags:t}=await this.parse(e),{app:n}=await B({directory:t.path,clientId:t["client-id"],forceRelink:t.reset,userProvidedConfigName:t.config}),i=new $n(n);return await i.start(),q(`Watching for changes in ${n.name}...`),i.onEvent(async({app:o,extensionEvents:r,startTime:a,path:s})=>{q(`\u{1F195} Event [${_i(a)}ms]`),q(` \u{1F4C2} ${s}`),r.forEach(c=>{switch(c.type){case ye.Created:q(` \u2705 Extension created - ${ve.green(c.extension.handle)}`);break;case ye.Deleted:q(` \u274C Extension deleted: ${ve.red(c.extension.handle)}`);break;case ye.Updated:q(` \u{1F504} Updated: ${ve.yellow(c.extension.handle)}`);break}})}),setInterval(()=>{},1<<30),{app:n}}};zo.summary="Watch and prints out changes to an app.";zo.hidden=!0;zo.flags={...T,...I};var yw=zo;l();l();l();l();import{writeFile as VF}from"fs/promises";var vw=1024*1024,kw=100,qF=kw*vw;async function Ls(e,t){let n=k(t,"manifest.json");await VF(n,JSON.stringify(e,null,2))}var bp=["!**/*.js.map","!**/*.metafile.json"];async function $s(e,t,n){let i=n??["**/*",...bp];t.endsWith(".br")?await xm({inputDirectory:e,outputPath:t,matchFilePattern:i}):await Sm({inputDirectory:e,outputZipPath:t,matchFilePattern:i})}async function Vs(e,t){let n=await oo(t);if(n>qF){let r=`${(Math.ceil(n/vw*100)/100).toFixed(2)} MB`;throw new y(`Your app bundle exceeds the ${kw} MB upload limit (it is ${r}).`,"Check the asset paths in your extension configuration \u2014 a misconfigured source can pull in much more than intended. Exclude large files or directories from your bundle, then try again.")}let i=Kd(),o=ct(t);i.append("my_upload",o),await Ae(e,{method:"put",body:o,headers:i.getHeaders()},"slow-request")}async function qs(e,t){let n=await e.generateSignedUploadUrl(t);if(!n.assetUrl||n.userErrors?.length>0){let i=n.userErrors.map(o=>o.message).join(", ");throw new y(i)}return n.assetUrl}async function ww(e){let t,n;e.bundlePath&&(t=await qs(e.developerPlatformClient,{id:e.apiKey,apiKey:e.apiKey,organizationId:e.organizationId}),await Vs(t,e.bundlePath));let i={appManifest:e.appManifest,appId:e.appId,apiKey:e.apiKey,name:e.name,organizationId:e.organizationId,skipPublish:!e.release,message:e.message,versionTag:e.version,commitReference:e.commitReference};t&&(i.bundleUrl=t),e.appModules.length>0&&(i.appModules=e.appModules);let o=await e.developerPlatformClient.deploy(i);if(!o.appDeploy.appVersion){let a=jF(o.appDeploy.userErrors??[],e.extensionIds,e.appModules,{version:e.version});throw new y({bold:"Version couldn't be created."},null,[],a)}return o.appDeploy.userErrors?.length>0&&(n=o.appDeploy.userErrors.map(a=>a.message).join(", ")),{validationErrors:o.appDeploy.appVersion.appModuleVersions.filter(a=>a.validationErrors.length>0).map(a=>({uuid:a.registrationUuid,errors:a.validationErrors})),versionTag:o.appDeploy.appVersion.versionTag,location:o.appDeploy.appVersion.location,message:o.appDeploy.appVersion.message,deployError:n}}var Bi=`
|
|
811
|
-
Validation errors`,Sp=`
|
|
812
|
-
`;function jF(e,t,n,i={}){let o=f=>f.details?.some(v=>v.extension_id)??!1,r=(f,v)=>{let _=f.details?.find(x=>typeof x.extension_id<"u")?.extension_id??"";return Object.values(v).includes(_.toString())},a=f=>{let v=f.on?f.on[0]:void 0;return n.some(_=>_.uid===v?.user_identifier)},[s,c]=ho(e,f=>a(f)),[d,p]=ho(c,f=>o(f)),[m,h]=ho(d,f=>r(f,t));return[...BF(p,{version:i.version}),...zF(m,t),...HF(h),...WF(s,n)]}function BF(e,t={}){return e.length>0?e.filter(n=>n.field&&n.field.includes("version_tag")&&n.message==="has already been taken").length>0&&t.version?[{body:["An app version with the name",{userInput:t.version},"already exists. Deploy again with a different version name."]}]:e.length===1?[{body:e[0]?.message??""}]:[{body:{list:{items:e.map(n=>n.message)}}}]:[]}function zF(e,t){return e.reduce((n,i)=>{let o=(i.field??["unknown"]).join(".").replace("extension_points","extensions.targeting"),r=o==="base"?i.message:`${o}: ${i.message}`,a=i.details.find(h=>typeof h.extension_title<"u")?.extension_title,s=i.details.find(h=>typeof h.specification_identifier<"u")?.specification_identifier,c=i.details.find(h=>typeof h.extension_id<"u")?.extension_id?.toString(),p=Object.keys(t).find(h=>t[h]===c)??a;s==="webhook_subscription"&&(p="Webhook Subscription");let m=n.find(h=>h.title===p);if(m){let h=m.body,g=i.category==="invalid"?h.find(f=>f.list.title===Bi):h.find(f=>f.list.title===Sp);g?g.list.items.includes(r)||g.list.items.push(r):h.push({list:{title:i.category==="invalid"?Bi:Sp,items:[r]}})}else n.push({title:p,body:[{list:{title:i.category==="invalid"?Bi:Sp,items:[r]}}]});return n.forEach(h=>{h.body.sort((g,f)=>g.list.title===Bi?1:f.list.title===Bi?-1:0)}),n},[])}function WF(e,t){return e.reduce((n,i)=>{let r=(i.on?i.on[0]:void 0)?.user_identifier,a=t.find(h=>h.uid===r),s=r?`Extension with uid: ${r}`:"Unknown Extension",c=a?.handle??s,p=`${(i.field??["unknown"]).join(".")}: ${i.message}`,m=n.find(h=>h.title===c);if(m){let g=m.body.find(f=>f.list.title===Bi);g&&(g.list.items.includes(p)||g.list.items.push(p))}else n.push({title:c,body:[{list:{title:Bi,items:[p]}}]});return n},[])}function HF(e){return e.reduce((t,n)=>{let i=n.details.find(r=>typeof r.extension_title<"u")?.extension_title,o=t.find(r=>r.title===i);return o?o.errorCount+=1:t.push({title:i,errorCount:1}),t},[]).map(t=>({title:t.title,body:`
|
|
813
|
-
${t.errorCount} error${t.errorCount>1?"s":""} found in your extensions. Fix these issues and try deploying again.`}))}l();async function _w(e){let t=k(e.app.directory,".shopify","deploy-bundle");await mi(t,{force:!0}),await ae(t),await Ls(e.appManifest,t),e.skipBuild||await _o(e.app);let n=e.app.allExtensions.map(o=>({prefix:o.localIdentifier,action:async(r,a,s)=>{let c=e.isDevDashboardApp?void 0:e.identifiers?.extensions[o.localIdentifier];e.skipBuild?await o.copyIntoBundle({stderr:a,stdout:r,signal:s,app:e.app,environment:"production"},t,c):await o.buildForBundle({stderr:a,stdout:r,signal:s,app:e.app,environment:"production"},t,c)}}));if(await ma({processes:n,showTimestamps:!1}),e.app.allExtensions.some(o=>o.hasDeploySteps))return await $s(t,e.bundlePath),e.bundlePath}l();l();l();function bw(e){switch(e){case Vn.Offsite:return Ro;case Vn.CreditCard:return Lo;case Vn.CustomCreditCard:return Mo;case Vn.CustomOnsite:return Oo;case Vn.Redeemable:return Uo;case Vn.CardPresent:return $o}}var Vn;(function(e){e.Offsite="payments_app",e.CreditCard="payments_app_credit_card",e.CustomCreditCard="payments_app_custom_credit_card",e.CustomOnsite="payments_app_custom_onsite",e.Redeemable="payments_app_redeemable",e.CardPresent="payments_app_card_present"})(Vn||(Vn={}));function Sw(e,t){let n=e.activeVersion?.context??e.draftVersion?.context??bw(e.type);switch(n){case Ro:return Wo(e,t,qv);case Lo:return Wo(e,t,nk);case Mo:return Wo(e,t,Xv);case Oo:return Wo(e,t,Kv);case Uo:return Wo(e,t,zv);case $o:return Wo(e,t,rk);default:throw new Error(`Unsupported extension: ${n}`)}}function Wo(e,t,n){let o=(e.activeVersion??e.draftVersion)?.config;if(!o)throw new Error("No config found for extension");let r=JSON.parse(o),a=n(r,t);a&&delete a.api_version;let s=e.activeVersion?.context??e.draftVersion?.context??bw(e.type);return{api_version:r.api_version,extensions:[{name:e.title,type:"payments_extension",handle:te(e.title.substring(0,Ee)),...a,targeting:[{target:`${s}`}]}]}}l();l();var GF=new Map(xs.map(e=>[e[1],e[0]])),KF=(e,t)=>{let n=GF.get(e.uiType);if(!n)throw new y(`Field type ${e.uiType} is not supported`);let i={key:e.name,description:e.description??void 0,type:n};return t==="flow_action_definition"&&(i.name=e.label,i.required=e.required),i},YF=(e,t)=>{let o={type:t==="flow_action_definition"?`${e.name.replace("_id","")}_reference`:`${e.uiType}_reference`};return t==="flow_action_definition"&&(o.required=e.required),e.uiType==="marketing-activity-id"&&(o.marketingActivityCreateUrl=e.marketingActivityCreateUrl,o.marketingActivityDeleteUrl=e.marketingActivityDeleteUrl),o},xw=(e,t)=>t?t.map(i=>i.uiType==="commerce-object-id"||i.uiType==="marketing-activity-id"||Ev.includes(i.uiType)?YF(i,e):KF(i,e)):[];function Ew(e){let t=e.activeVersion?.config??e.draftVersion?.config;if(!t)throw new Error("No config found for extension");let n=e.type==="flow_action_definition"?"https://url.com/api/execute":void 0,i;if(e.type==="flow_trigger_discovery_webhook"){let o=JSON.parse(t);i={extensions:[{type:"flow_trigger_lifecycle_callback",name:e.title,handle:te(e.title.substring(0,Ee)),url:o.url}]}}else{let o=JSON.parse(t),r=xw(e.type,o.fields??[]);i={extensions:[{type:e.type.replace("_definition",""),name:o.title,handle:te(e.title.substring(0,Ee)),description:o.description,runtime_url:o.url??n,config_page_url:o.custom_configuration_page_url,config_page_preview_url:o.custom_configuration_page_preview_url,validation_url:o.validation_url}],settings:(r?.length??0)>0?{fields:r}:void 0}}return i}l();l();var Cw=e=>{let t=e.split("#");if(t.length!==2||t.some(a=>a===""||a===void 0))throw new Error("Invalid context");let n="admin",i=JF(t[0]??""),o=QF(t[1]??""),r="link";return o==="selection"?[n,`${i}-index`,`${o}-action`,r].join("."):[n,`${i}-${o}`,"action",r].join(".")},QF=e=>{switch(e.toLocaleLowerCase()){case"show":return"details";case"index":return"index";case"action":return"selection";case"fulfilled_card":return"fulfilled-card";default:throw new Error(`Invalid context location: ${e}`)}},JF=e=>e.toLocaleLowerCase()==="variants"?"product-variant":Ct(e.toLocaleLowerCase().replace(new RegExp("(s)$"),""));function Nw(e,t,n){let i=e.activeVersion?.config??e.draftVersion?.config;if(!i)throw new Error("No config found for extension");let o=e.activeVersion?.context??e.draftVersion?.context;if(!o)throw new Error("No context found for link extension");let r=JSON.parse(i);if(n.embedded)try{let s=new URL(r.url),c=s.pathname.startsWith("/")?s.pathname.substring(1):s.pathname,d=new URL(`app://${c}`);d.search=s.search,d.hash=s.hash,r.url=d.toString()}catch{}return{extensions:[{type:"admin_link",name:r.text,handle:te(e.title.substring(0,Ee)),targeting:[{url:r.url,target:Cw(o)}]}]}}l();var XF={facebook:"social",instagram:"social",google:"search",pinterest:"social",bing:"search",email:"email",snapchat:"social",sms:"sms",verizon_media:"display",ebay:"marketplace",tiktok:"social",flow:"email"},ZF={facebook:"facebook.com",instagram:"instagram.com",google:"google.com",pinterest:"pinterest.com",bing:"bing.com",snapchat:"snapchat.com",verizon_media:null,email:null,sms:null,ebay:"ebay.com",tiktok:"tiktok.com",flow:null};function eP(e){let t=new URL(e);return t.pathname+t.search+t.hash}function Aw(e){let t=e.activeVersion?.config??e.draftVersion?.config;if(!t)throw new Error("No config found for extension");let n=JSON.parse(t);return{extensions:[{type:"marketing_activity",name:e.title,handle:te(e.title.substring(0,Ee)),title:n.title,description:n.description,api_path:eP(n.app_api_url),tactic:n.tactic,marketing_channel:XF[n.platform]??"",referring_domain:ZF[n.platform]??"",is_automation:n.is_automation,use_external_editor:n.use_external_editor,preview_data:n.preview_data,fields:n.fields.map(({id:o,...r})=>r)}]}}l();function Tw(e){let t=e.activeVersion?.config??e.draftVersion?.config;if(!t)throw new Error("No config found for extension");let n=JSON.parse(t);return{extensions:[{type:"subscription_link_extension",name:e.title,handle:te(e.title.substring(0,Ee)),pattern:n.pattern}]}}var xp=[{label:"Payments Extensions",value:"payments",extensionTypes:["payments_app","payments_app_credit_card","payments_app_custom_credit_card","payments_app_custom_onsite","payments_app_redeemable","payments_extension"],buildExtensionConfig:Sw},{label:"Flow Extensions",value:"flow",extensionTypes:["flow_action_definition","flow_trigger_definition","flow_trigger_discovery_webhook"],buildExtensionConfig:Ew},{label:"Marketing Activity Extensions",value:"marketing activity",extensionTypes:["marketing_activity_extension"],buildExtensionConfig:Aw},{label:"Subscription Link Extensions",value:"subscription link",extensionTypes:["subscription_link","subscription_link_extension"],buildExtensionConfig:Tw},{label:"Admin Link extensions",value:"link extension",extensionTypes:["app_link","bulk_action"],buildExtensionConfig:Nw}];function js(e){return xp.filter(t=>t.extensionTypes.some(n=>e.some(i=>i.type.toLowerCase()===n.toLowerCase())))}async function Fw(e){if(e.length===1&&e[0])return e[0];let t=e.map(o=>({label:o.label,value:o.value})),n=await Je({message:"Extension type to migrate",choices:t}),i=e.find(o=>o.value===n);if(i===void 0)throw new y("Invalid migration choice");return i}var Bs=xp.flatMap(e=>e.extensionTypes),qn;(function(e){e.Write="write",e.Skip="skip",e.Cancel="cancel"})(qn||(qn={}));async function tP({name:e,app:t}){let n=Ct(e),i=k(t.directory,wo.extensions.directoryName,n);if(await C(i)){let o=[{label:"Overwrite local TOML with remote configuration",value:qn.Write},{label:"Keep local TOML",value:qn.Skip},{label:"Cancel",value:qn.Cancel}],r=await Je({message:`Directory "${n}" already exists. What would you like to do?`,choices:o});if(r===qn.Cancel)throw new de;return{directory:i,action:r}}return await ae(i),await pn(k(i,me.lockFile)),{directory:i,action:qn.Write}}async function Ep(e){let{app:t,remoteApp:n,developerPlatformClient:i,extensionTypes:o,extensions:r,buildExtensionConfig:a,all:s}=e,c=r.filter(h=>o.includes(h.type.toLowerCase()));if(c=Cp(t,c),c.length===0)throw new y("No extensions to migrate");if(!s){let h=c.map(f=>({label:f.title,value:f.uuid}));c.length>1&&h.push({label:"All",value:"All"});let g=await Je({message:"Extensions to migrate",choices:h});g!=="All"&&(c=[c.find(f=>f?.uuid===g)])}let d={},p=c.map(async h=>{let{directory:g,action:f}=await tP({app:t,name:h.title}),v=te(h.title.substring(0,Ee));if(d[v]=h.uuid,f===qn.Write){let _=a(h,r,t.configuration),x=k(g,"shopify.extension.toml");await new _e(x,_).replace(_);let A=k(g,me.lockFile);await io(A)}return{extension:h,directory:k("extensions",$(g))}}),m=await Promise.all(p);nP(m),await Ui({app:t,identifiers:{extensions:d,app:n.apiKey},command:"import-extensions",developerPlatformClient:i})}function Cp(e,t){let n=e.dotenv?.variables??{},i=e.allExtensions.map(o=>n[o.idEnvironmentVariableName]);return t.filter(o=>!i.includes(o.uuid))}async function Np(e){let t=js(e.extensions);await Promise.all(t.map(async n=>Ep({...e,extensionTypes:n.extensionTypes,buildExtensionConfig:n.buildExtensionConfig,all:!0})))}function nP(e){j({headline:["Imported the following extensions from the dashboard:"],body:e.map(t=>w`• "${t.extension.title}" at: ${t.directory}`.value).join(`
|
|
814
|
-
`)})}l();async function zs({developerPlatformClient:e,apiKey:t,organizationId:n,extensionTypes:i,onlyDashboardManaged:o=!1}){let r=await e.appExtensionRegistrations({id:t,apiKey:t,organizationId:n}),{dashboardManagedExtensionRegistrations:a,extensionRegistrations:s}=r.app;return(o?a:s.concat(a)).filter(d=>{let p=i.includes(d.type.toLowerCase()),m=d.activeVersion&&d.activeVersion.config,h=d.draftVersion&&d.draftVersion.config;return p&&(m??h)})}async function iP(e){let{app:t,remoteApp:n,developerPlatformClient:i,force:o,extensions:r}=e;if(o||!wi())return t;let a=[`App includes legacy extensions that will be deprecated soon:
|
|
815
|
-
`,r.map(c=>` - ${c.title}`).join(`
|
|
816
|
-
`),`
|
|
817
|
-
|
|
818
|
-
Run `,{command:"shopify app import-extensions"},"to add legacy extensions now?"];return await De({message:a,confirmationMessage:"Yes, add legacy extensions and deploy",cancellationMessage:"No, skip for now"})?(await Np({app:t,remoteApp:n,developerPlatformClient:i,extensions:r}),on(t)):t}async function oP(e){let{app:t,remoteApp:n,developerPlatformClient:i,force:o,extensions:r}=e,a=[`App can't be deployed until Partner Dashboard managed extensions are added to your version or removed from your app:
|
|
819
|
-
`,r.map(p=>` - ${p.title}`).join(`
|
|
820
|
-
`)],s=[`
|
|
821
|
-
|
|
822
|
-
Run `,{command:"shopify app import-extensions"},"to add legacy extensions."];if(o||!wi())throw new y(a,s);let c=[`
|
|
823
|
-
|
|
824
|
-
Run `,{command:"shopify app import-extensions"}," to add legacy extensions now?"];if(await De({message:[...a,...c],confirmationMessage:"Yes, add legacy extensions and deploy",cancellationMessage:"No, don't add legacy extensions"}))return await Np({app:t,remoteApp:n,developerPlatformClient:i,extensions:r}),on(t);throw new de}async function rP(e){let{app:t,remoteApp:n,developerPlatformClient:i}=e,o=await zs({developerPlatformClient:i,apiKey:n.apiKey,organizationId:n.organizationId,extensionTypes:Bs,onlyDashboardManaged:!0}),r=Cp(e.app,o);return r.length===0?t:i.supportsDashboardManagedExtensions?iP({...e,extensions:r}):oP({...e,extensions:r})}async function Pw(e){let{remoteApp:t,developerPlatformClient:n,noRelease:i,force:o,allowUpdates:r,allowDeletes:a}=e,s=await rP({app:e.app,remoteApp:t,developerPlatformClient:n,force:o}),{identifiers:c,didMigrateExtensionsToDevDash:d}=await uv({...e,app:s,developerPlatformClient:n,allowUpdates:r,allowDeletes:a}),p=!i,m=t.apiKey;uo(),p?q(`Releasing a new app version as part of ${t.title}`):q(`Creating a new app version as part of ${t.title}`),uo();let h;try{let g=k(e.app.directory,".shopify",`deploy-bundle.${n.bundleFormat}`);await ae(H(g));let f=await s.manifest(c),v=await _w({app:s,appManifest:f,bundlePath:g,identifiers:c,skipBuild:e.skipBuild,isDevDashboardApp:n.supportsAtomicDeployments}),_;p?_="Releasing an app version":_="Creating an app version",await xe([{title:"Running validation",task:async()=>{await s.preDeployValidation()}},{title:_,task:async()=>{let E=await Promise.all(s.allExtensions.flatMap(A=>A.bundleConfig({identifiers:c,developerPlatformClient:n,apiKey:m,appConfiguration:s.configuration})));h=await ww({appManifest:f,appId:t.id,apiKey:m,name:s.name,organizationId:t.organizationId,bundlePath:v,appModules:zt(E),release:p,developerPlatformClient:n,extensionIds:c.extensionIds,message:e.message,version:e.version,commitReference:e.commitReference}),await Ui({app:s,identifiers:c,command:"deploy",developerPlatformClient:n})}}]),await aP({app:s,project:e.project,release:p,uploadExtensionsBundleResult:h,didMigrateExtensionsToDevDash:d})}catch(g){throw await Ui({app:s,identifiers:c,command:"deploy",developerPlatformClient:n}),g}return{app:s}}async function aP({app:e,project:t,release:n,uploadExtensionsBundleResult:i,didMigrateExtensionsToDevDash:o}){let r=[{link:{label:i.versionTag??"version",url:i.location}},i.message?`
|
|
825
|
-
${i.message}`:""],a=[];if(o){let s=await Ao(e.directory),c=Object.values(s).filter(p=>p!==s[e.configuration.client_id]),d=[];c.length>0&&d.push("\u2022 Map extension IDs to other copies of your app by running",{command:Be(t.packageManager,"shopify app deploy")},"for: ",{list:{items:c}}),d.push("\u2022 Commit to source control to ensure your extension IDs aren't regenerated on the next deploy."),a=[{title:"Next steps",body:d},{title:"Reference",body:["\u2022 ",{link:{label:"Migrating from the Partner Dashboard",url:"https://shopify.dev/docs/apps/build/dev-dashboard/migrate-from-partners"}}]}]}return n?i.deployError?oe({headline:"New version created, but not released.",body:[...r,`
|
|
826
|
-
|
|
827
|
-
${i.deployError}`],customSections:a}):j({headline:"New version released to users.",body:r,customSections:a}):j({headline:"New version created.",body:r,customSections:a,nextSteps:[["Run",{command:Be(t.packageManager,"shopify app release",`--version=${i.versionTag}`)},"to release this version to users."]]})}l();function Iw(e){if(typeof e>"u")return;let t=["Invalid version name:",{userInput:e}],n=100;if(e.length>n)throw new y(t,`Version name must be ${n} characters or less.`);let i=[".",".."];if(i.find(r=>e===r))throw new y(t,`Version name may not be any of: ${i.map(r=>`'${r}'`).join(" , ")}`);let o=/^[a-zA-Z0-9.\-_]+$/;if(!e.match(o))throw new y(t,["Version name can only contain alphanumeric characters, periods, hyphens, and underscores"])}l();function Dw(e){if(typeof e>"u")return;let t=["Invalid message:",{userInput:e}],n=200;if(e.length>n)throw new y(t,`Message name must be ${n} characters or less.`)}var jn=O(ke(),1);var Ap,Bn=class extends M{async run(){let{flags:t}=await this.parse(Ap);await Q.addPublicMetadata(()=>({cmd_deploy_flag_message_used:!!t.message,cmd_deploy_flag_version_used:!!t.version,cmd_deploy_flag_source_url_used:!!t["source-control-url"]})),Iw(t.version),Dw(t.message);let n=t["client-id"];await mt(()=>({cmd_app_reset_used:t.reset}));let i=t["no-release"],o=[];i||t["allow-updates"]||t["allow-deletes"]||o.push("allow-updates"),this.failMissingNonTTYFlags(t,o);let{app:a,project:s,remoteApp:c,developerPlatformClient:d,organization:p}=await B({directory:t.path,clientId:n,forceRelink:t.reset,userProvidedConfigName:t.config}),m=i||t["allow-updates"],h=i||t["allow-deletes"];return{app:(await Pw({app:a,project:s,remoteApp:c,organization:p,developerPlatformClient:d,reset:t.reset,force:i,allowUpdates:m,allowDeletes:h,noRelease:t["no-release"],message:t.message,version:t.version,commitReference:t["source-control-url"],skipBuild:t["no-build"]})).app}}};Ap=Bn;Bn.summary="Deploy your Shopify app.";Bn.descriptionWithMarkdown=`[Builds the app](https://shopify.dev/docs/api/shopify-cli/app/app-build), then deploys your app configuration and extensions.
|
|
828
|
-
|
|
829
|
-
This command creates an app version, which is a snapshot of your app configuration and all extensions. This version is then released to users.
|
|
830
|
-
|
|
831
|
-
This command doesn't deploy your [web app](https://shopify.dev/docs/apps/tools/cli/structure#web-components). You need to [deploy your web app](https://shopify.dev/docs/apps/deployment/web) to your own hosting solution.
|
|
832
|
-
`;Bn.description=Ap.descriptionWithoutMarkdown();Bn.flags={...T,...I,"allow-updates":jn.Flags.boolean({hidden:!1,description:"Allows adding and updating extensions and configuration without requiring user confirmation. Recommended option for CI/CD environments.",env:"SHOPIFY_FLAG_ALLOW_UPDATES"}),"allow-deletes":jn.Flags.boolean({hidden:!1,description:"Allows removing extensions and configuration without requiring user confirmation. For CI/CD environments, the recommended flag is --allow-updates.",env:"SHOPIFY_FLAG_ALLOW_DELETES"}),"no-release":jn.Flags.boolean({hidden:!1,description:"Creates a version but doesn't release it - it's not made available to merchants. With this flag, a user confirmation is not required.",env:"SHOPIFY_FLAG_NO_RELEASE",default:!1,exclusive:["allow-updates","allow-deletes"]}),"no-build":jn.Flags.boolean({description:"Use with caution: Skips building any elements of the app that require building. You should ensure your app has been prepared in advance, such as by running `shopify app build` or by caching build artifacts.",env:"SHOPIFY_FLAG_NO_BUILD",default:!1}),message:jn.Flags.string({hidden:!1,description:"Optional message that will be associated with this version. This is for internal use only and won't be available externally.",env:"SHOPIFY_FLAG_MESSAGE"}),version:jn.Flags.string({hidden:!1,description:"Optional version tag that will be associated with this app version. If not provided, an auto-generated identifier will be generated for this app version.",env:"SHOPIFY_FLAG_VERSION"}),"source-control-url":jn.Flags.string({hidden:!1,description:"URL associated with the new app version.",env:"SHOPIFY_FLAG_SOURCE_CONTROL_URL"})};var Rw=Bn;l();l();l();l();l();l();var sP=300*1e3,lP='The host theme could not be created to host your theme app extension. Please try again or use the "--theme" flag to use an existing theme as the host theme.';async function Uw(e,t,n=Date.now()){for(;await cP(e,t,n););}async function cP(e,t,n){let i=await ga(e,t);if(!i||pP(i,n))throw new y(lP);return await Nt(3),i.processing}function pP(e,t){return e.processing&&Date.now()-t>=sP}var dP="https://codeload.github.com/Shopify/dawn/zip/refs/tags/v15.0.0",uP="https://cdn.shopify.com/theme-store/uhrdefhlndzaoyrgylhto59sx2i7.jpg",Tp=3,Ws=class extends pm{constructor(t,n={devPreview:!1}){super(t),this.context="App Ext. Host",this.themeId=wm(t.storeFqdn),this.devPreview=n.devPreview}async findOrCreate(){let t=await this.fetch();return t??(t=this.devPreview?await this.createHostTheme():await this.create()),t}setTheme(t){_m(this.adminSession.storeFqdn,t)}removeTheme(){bm(this.adminSession.storeFqdn)}async createHostTheme(){let t={role:lm,name:this.generateThemeName(this.context),src:dP};for(let i=0;i<Tp;i++){S(`Attempt ${i}/${Tp}: Creating theme with name "${t.name}" and role "${t.role}"`);try{let o=await ql(t,this.adminSession);if(o)return this.setTheme(o.id.toString()),S(`Waiting for theme with id "${o.id}" to be processed`),await Uw(o.id,this.adminSession),o;throw new Error}catch{S(`Failed to create theme with name "${t.name}" and role "${t.role}". Retrying...`)}}S(`Theme creation failed after ${Tp} retries. Creating theme using fallback theme zip`);let n=await ql({...t,src:uP},this.adminSession);if(!n)throw S("Theme creation failed. Exiting process."),new L(`Could not create theme with name "${t.name}" and role "${t.role}"`);return n}};async function Ow(e){let{remoteApp:t,localApp:n}=e,o=n.allExtensions.filter(f=>f.isThemeExtension);if(o.length===0)return;let a=o[0].directory,s=e.themeExtensionPort??9293,[c,d]=await Promise.all([aa(e.storeFqdn),hP(t)]),p=c.storeFqdn,m=await cm(c)?await dm("",p):void 0,h=await fP(c,e.theme),g=h.id.toString();return oe({headline:"The theme app extension development server is ready.",orderedNextSteps:!0,nextSteps:[[{link:{label:"Install your app in your development store",url:d}}],[{link:{label:"Setup your theme app extension in the host theme",url:`https://${p}/admin/themes/${g}/editor`}}],["Preview your theme app extension at",{link:{label:`http://127.0.0.1:${s}`,url:`http://127.0.0.1:${s}`}}]]}),{type:"theme-app-extensions",prefix:"theme-extensions",function:mP,options:{theme:h,adminSession:c,storefrontPassword:m,themeExtensionDirectory:a,themeExtensionPort:s}}}var mP=async(e,{theme:t,adminSession:n,storefrontPassword:i,themeExtensionDirectory:o,themeExtensionPort:r})=>{await(await gm(t,{adminSession:n,storefrontPassword:i,themeExtensionDirectory:o,themeExtensionPort:r})).start()};async function fP(e,t){let n;if(t)S(`Fetching theme with provided id ${t}`),n=await ga(parseInt(t,10),e);else{let i=new Ws(e,{devPreview:!0});await xe([{title:"Configuring host theme for theme app extension",task:async()=>{S("Finding or creating host theme for theme app extensions"),n=await i.findOrCreate()}}])}if(!n)throw new y("Could not find or create a host theme for theme app extensions");return n}async function hP(e){return e.developerPlatformClient?.clientName===wt.AppManagement?`https://${await oa()}/?organization_id=${e.organizationId}&no_redirect=true&redirect=/oauth/redirect_from_developer_dashboard?client_id%3D${e.apiKey}`:`https://${await fi()}/${e.organizationId}/apps/${e.id}/test`}l();l();l();l();l();l();async function gP(e){let t=k(e.directory,"locales");return re([k(t,"*.json")])}async function Mw(e,t){let n=await gP(e);if(!n.length)return{localization:void 0,status:""};let i=t.currentLocalizationPayload??{defaultLocale:"en",translations:{},lastUpdated:0},o="success";try{await Promise.all(n.map(async r=>{let[a,...s]=r.split("/").pop().split(".");if(a)return s[0]==="default"&&(i.defaultLocale=a),yP(a,r,i,e,t)})),i.lastUpdated=Date.now(),S(`Parsed locales for extension ${e.handle} at ${e.directory}`,t.stdout)}catch{o="error"}return{localization:i,status:o}}async function yP(e,t,n,i,o){let r;try{r=await P(t),n.translations[e]=JSON.parse(r)}catch(a){let s=`Error parsing ${e} locale for ${i.handle} at ${t}: ${a.message}`;throw se(s,o.stderr),new Au.ExtendableError(s)}}l();function Hs(e,t){switch(e){case"checkout_ui_extension":return{url:t.checkoutCartUrl};case"checkout_post_purchase":return{url:t.checkoutCartUrl};case"product_subscription":return{url:t.subscriptionProductUrl??""};default:return{url:""}}}async function Ho(e,t,n,i){return je({outputPrefix:e.outputPrefix},async()=>{i?.clear();let o=e.getOutputPathForDirectory(t),r=`${n.url}/extensions/${e.devUUID}`,{localization:a,status:s}=await Mw(e,n),c=await dh(e),d=e.outputRelativePath?H(o):o,p=await vP(e,r,d,i),m=null;return"metafields"in e.configuration&&Array.isArray(e.configuration.metafields)&&e.configuration.metafields.length>0&&(m=e.configuration.metafields),{assets:{main:Vr(p)&&p[0]?.assets?.main?p[0].assets.main:{name:"main",url:`${r}/assets/${e.outputFileName}`,lastUpdated:await ea(o)??0}},supportedFeatures:{runsOffline:e.configuration.supported_features?.runs_offline??!1},capabilities:{blockProgress:e.configuration.capabilities?.block_progress??!1,networkAccess:e.configuration.capabilities?.network_access??!1,apiAccess:e.configuration.capabilities?.api_access??!1,collectBuyerConsent:{smsMarketing:e.configuration.capabilities?.collect_buyer_consent?.sms_marketing??!1,customerPrivacy:e.configuration.capabilities?.collect_buyer_consent?.customer_privacy??!1},iframe:{sources:e.configuration.capabilities?.iframe?.sources??[]}},development:{...n.currentDevelopmentPayload,resource:Hs(e.type,n),root:{url:r},hidden:n.currentDevelopmentPayload?.hidden??!1,localizationStatus:s,status:n.currentDevelopmentPayload?.status??"success",...n.currentDevelopmentPayload??{status:"success"}},extensionPoints:p,localization:a??null,metafields:m,type:e.type,externalType:e.externalType,uuid:e.devUUID,surface:e.surface,version:c?.version,title:e.name,handle:e.handle,name:e.name,description:e.configuration.description,apiVersion:e.configuration.api_version,approvalScopes:n.grantedScopes,settings:e.configuration.settings}})}async function vP(e,t,n,i){let o=e.configuration,r=o.extension_points??o.targeting;if(e.type==="checkout_post_purchase"&&(r=[{target:"purchase.post.render"}]),Vr(r)){let a=await kP(n);return Promise.all(r.map(async s=>{let{target:c,resource:d}=s,p={...s,surface:Vo(c),root:{url:`${t}/${c}`},resource:d||{url:""}},m=a?.[c];if(!m)return p;let g=await xP(m,{target:c,extensionPoint:s,url:t,extension:e,buildDirectory:n,resolver:i});return{...p,...g}}))}return r}async function kP(e){try{let t=k(e,"manifest.json"),n=await P(t);return JSON.parse(n)}catch(t){if(t instanceof SyntaxError)throw new Error(`Invalid manifest.json in ${e}: ${t.message}`);return null}}async function wP({target:e,extensionPoint:t,url:n,extension:i,resolver:o},r,a){let s=`${e}/${r}`,c=t[r];if(typeof c=="string"){let g=await Gs(r,s,typeof a=="string"?a:c,n,i,o,typeof a=="string"?c:void 0);return{assets:{[g.name]:g}}}let p=t.build_manifest?.assets?.[r];if(p?.filepath){let m=await Gs(r,s,p.filepath,n,i,o,p.module);return{assets:{[m.name]:m}}}return{}}async function _P({target:e,url:t,buildDirectory:n,resolver:i},o,r){if(r.length===0)return{};for(let s of r)i?.set(`${e}/${s}`,s);let a=await Promise.all(r.map(async s=>await ea(k(n,s))??0));return{assets:{[o]:{name:o,url:`${t}/assets/${e}/`,lastUpdated:Math.max(...a)}}}}async function bP({target:e,extensionPoint:t,url:n,extension:i,resolver:o},r){return t.intents?{intents:await Promise.all(t.intents.map(async(s,c)=>{let d=s.schema,p=r[c]?.schema,m=typeof p=="string"?p:d,h=typeof p=="string"?d:void 0;return{...s,schema:await Gs("schema",`${e}/intents/${c}/schema`,m,n,i,o,h)}}))}:{}}async function SP({target:e,url:t,extension:n,resolver:i},o,r){let a=await Gs(o,`${e}/${o}`,r,t,n,i);return{assets:{[a.name]:a}}}async function xP(e,t){return(await Promise.all(Object.keys(e).map(async i=>{let o=e[i];return EP(i,o)?bP(t,o):CP(i,o)?SP(t,i,o):NP(i,o)?_P(t,i,o):wP(t,i,o)}))).reduce((i,o)=>({...i,...o,assets:{...i.assets,...o.assets}}),{})}function Vr(e){return Array.isArray(e)&&e.every(t=>typeof t=="object")}async function Gs(e,t,n,i,o,r,a){let s=`${t}${cn(n)}`;return r?.set(s,n),{name:e,url:`${i}/assets/${s}`,lastUpdated:await ea(k(o.directory,a??n))??0}}function EP(e,t){return e==="intents"&&Array.isArray(t)}function CP(e,t){return(e==="main"||e==="should_render")&&typeof t=="string"}function NP(e,t){return e==="assets"&&Array.isArray(t)&&t.every(n=>typeof n=="string")}l();function Ks(e,t){let n=K(e);return`https://${Fl(n)}/admin/oauth/redirect_from_cli?client_id=${t}`}function Lw(e,t,n){let o=K(e).split(".")[0];return`https://${n}/store/${o}/apps/${t}?dev-console=show`}function Fp(e){return`https://${K(e)}/admin?dev-console=show`}function $w(e,t){let n=K(e),o=`${Fl(n)}/admin/apps/${t}`,r=Buffer.from(o).toString("base64").replace(/[=]/g,"");return`https://${o}?shop=${n}&host=${r}`}import{EventEmitter as AP}from"events";var qr;(function(e){e.Update="PayloadUpdatedEvent:UPDATE"})(qr||(qr={}));async function Vw(e,t,n){return{app:{title:e.appName,apiKey:e.apiKey,url:Ks(e.storeFqdn,e.apiKey),mobileUrl:$w(e.storeFqdn,e.apiKey)},appId:e.id,version:e.manifestVersion,root:{url:new URL("/extensions",e.url).toString()},socket:{url:e.websocketURL},devConsole:{url:new URL("/extensions/dev-console",e.url).toString()},store:e.storeFqdn,extensions:await Promise.all(e.extensions.filter(o=>o.isPreviewable).map(o=>Ho(o,t,e,n&&Pp(n,o.devUUID))))}}function Pp(e,t){let n=e.get(t);return n||(n=new Map,e.set(t,n)),n}var Ys=class extends AP{constructor(t,n,i=new Map){super(),this.rawPayload=t,this.options=n,this.assetResolvers=i}getAssetResolver(t){return this.assetResolvers.get(t)}getConnectedPayload(){let t=this.getRawPayload();return{app:t.app,appId:t.appId,store:t.store,extensions:t.extensions}}getRawPayloadFilteredByExtensionIds(t){return{...this.rawPayload,extensions:this.rawPayload.extensions.filter(n=>t.includes(n.uuid))}}getRawPayload(){return this.rawPayload}updateApp(t){this.rawPayload=rt(this.rawPayload,{app:t}),this.emitUpdate([])}updateExtensions(t){let n=this.rawPayload.extensions.map(i=>{let o=t.find(r=>r.uuid===i.uuid);if(o){if(Vr(o.extensionPoints)&&Vr(i.extensionPoints)){let r=o.extensionPoints.reduce((c,d)=>({...c,[d.target]:d}),{});i.extensionPoints=rt(i.extensionPoints,o.extensionPoints,c=>c.map(d=>{let p=r[d.target];return p?rt(d,p,(m,h)=>h):d}));let{extensionPoints:a,...s}=o;return rt(i,s)}return rt(i,o)}return i});this.rawPayload={...this.rawPayload,extensions:n},this.emitUpdate(t.map(i=>i.uuid))}async updateExtension(t,n,i,o){let r=this.rawPayload.extensions,a=r.findIndex(s=>s.uuid===t.devUUID);if(a===-1){S(w`Could not updateExtension() for extension with uuid: ${t.devUUID}`,n.stderr);return}r[a]=await Ho(t,i,{...this.options,currentDevelopmentPayload:o??{status:r[a]?.development.status},currentLocalizationPayload:r[a]?.localization},Pp(this.assetResolvers,t.devUUID)),this.rawPayload.extensions=r,this.emitUpdate([t.devUUID])}deleteExtension(t){let n=this.rawPayload.extensions.findIndex(i=>i.uuid===t.devUUID);n!==-1&&(this.rawPayload.extensions.splice(n,1),this.assetResolvers.delete(t.devUUID),this.emitUpdate([t.devUUID]))}async addExtension(t,n){this.rawPayload.extensions.push(await Ho(t,n,this.options,Pp(this.assetResolvers,t.devUUID))),this.emitUpdate([t.devUUID])}emitUpdate(t){this.emit(qr.Update,t)}};l();l();var zi;(function(e){e.Update="update",e.Dispatch="dispatch",e.Log="log"})(zi||(zi={}));function qw(e,t){return(n,i,o)=>{n.url==="/extensions"&&(S("Upgrading HTTP request to a websocket connection",t.stdout),e.handleUpgrade(n,i,o,TP(e,t)))}}function TP(e,t){return n=>{S("Websocket connection successfully established",t.stdout);let i={event:"connected",data:t.payloadStore.getConnectedPayload(),version:t.manifestVersion};S(w`Sending connected payload: ${b.json(i)}`,t.stdout),n.send(JSON.stringify(i)),n.on("message",RP(e,t))}}function FP(e){try{let t=JSON.parse(e);if(!Array.isArray(t))return e;let n=t.map(i=>typeof i=="object"&&i!==null?b.json(i).output():String(i)).join(" ");return w`${n}`.value}catch(t){if(t instanceof SyntaxError)return e;throw t}}var PP={debug:e=>b.gray(e),warn:e=>b.yellow(e),error:e=>b.errorText(e)};function IP({type:e,message:t}){let n=FP(t);switch(e){case"debug":case"warn":case"error":return w`${PP[e](e.toUpperCase())}: ${n}`.value;case"log":case"info":return n;default:return`${e.toUpperCase()}: ${n}`}}function DP(e,t){je({outputPrefix:e.extensionName,stripAnsi:!1},()=>{t.stdout.write(IP(e))})}function RP(e,t){return n=>{let i=JSON.parse(n.toString()),{event:o,data:r}=i;if(S(w`Received websocket message with event type ${o} and data:
|
|
833
|
-
${b.json(r)}
|
|
834
|
-
`,t.stdout),o===zi.Update){let a=t.payloadStore.getRawPayload().app.apiKey,s=r.app?.apiKey;if(r.app){if(a!==s)return;t.payloadStore.updateApp(r.app)}r.extensions&&t.payloadStore.updateExtensions(r.extensions)}else if(o===zi.Dispatch){let a=UP(i,t);Bw(e,a,t)}else o===zi.Log&&DP(r,t)}}function jw(e,t){return n=>{let i={event:zi.Update,version:t.manifestVersion,data:{...t.payloadStore.getRawPayloadFilteredByExtensionIds(n)}};S(w`Sending websocket update event to the websocket clients:
|
|
835
|
-
${b.json(i)}
|
|
836
|
-
`,t.stdout),Bw(e,i,t)}}function Bw(e,t,n){S(w`Sending websocket with event type ${t.event} and data:
|
|
837
|
-
${b.json(t.data)}
|
|
838
|
-
`,n.stdout);let i=JSON.stringify(t);e.clients.forEach(o=>o.send(i))}function UP(e,t){let n=t.payloadStore.getRawPayload();return{...e,version:t.manifestVersion,data:{...e.data,extensions:[],store:n.store,app:n.app}}}var OP=10;function zw(e){let t=new $d.default({noServer:!0,clientTracking:!0}),n=MP(t);return e.httpServer.on("upgrade",qw(t,e)),e.payloadStore.on(qr.Update,jw(t,e)),{close:()=>{t.close(),clearInterval(n)}}}function MP(e){return setInterval(()=>{e.clients.forEach(t=>{t.readyState<2&&t.ping()})},OP*1e3)}l();l();l();function Ww(e,t){let{url:n}=Hs(e.type,t);if(e.surface==="checkout"&&n){let i=new URL(`https://${t.storeFqdn}/`);return i.pathname=n,i.searchParams.append("dev",`${t.url}/extensions`),i.toString()}else{let i=new URL(`https://${t.storeFqdn}/`);return i.pathname="admin/extensions-dev",i.searchParams.append("url",Qs(e,t)),i.toString()}}function Hw(e,t,n){let i=Vo(e),o=new URL(`https://${n.storeFqdn}/`);switch(i){case"checkout":o.pathname=n.checkoutCartUrl,o.searchParams.append("dev",`${n.url}/extensions`);break;case"post_purchase":if(o.pathname=n.checkoutCartUrl,o.searchParams.set("script_url",`${n.url}/extensions/${t.devUUID}/assets/${t.localIdentifier}.js`),o.searchParams.set("post_purchase_dev_api_key",n.apiKey),t.devUUID&&n.websocketURL&&(o.searchParams.set("uuid",t.devUUID),o.searchParams.set("socket_url",n.websocketURL)),"metafields"in t.configuration){let r={config:{metafields:t.configuration.metafields}};o.searchParams.set("config",JSON.stringify(r))}break;case"admin":o.pathname="admin/extensions-dev",o.searchParams.append("url",Qs(t,n)),o.searchParams.append("target",e);break;case"customer-accounts":o=LP(t,n,e);break;default:return}return o.toString()}function LP(e,t,n=""){let i=`${t.url}/extensions`,o=t.storeId,r="shopify.com",a=new URL(`https://${r}/${o}/account/extensions-development`);return a.searchParams.append("origin",i),a.searchParams.append("extensionId",e.devUUID),a.searchParams.append("source","CUSTOMER_ACCOUNT_EXTENSION"),a.searchParams.append("appId",t.id??""),n!==""&&a.searchParams.append("target",n),a}function Qs(e,t){let n=new URL(t.url);return n.pathname=`/extensions/${e.devUUID}`,n.toString()}function Ft(e,t){mm(e,um(t))}l();var Ip=class extends L{constructor(t){super(`Couldn't find template ${t.template} for extension surface ${t.extensionSurface}`)}};async function Gw(e){let t=await $P(e),n=await P(t);return mr(n,e.data)}async function $P(e){let t=await VP(),n=[];e.extensionSurface&&n.push(k(t,`${e.extensionSurface}/${e.template}.html.liquid`)),n.push(k(t,`${e.template}.html.liquid`));let i=await re(n);if(i.length===0)throw new Ip(e);return i[0]}async function VP(){return await qe("templates/ui-extensions/html",{type:"directory",cwd:ui(import.meta.url)})}var Kw=Re(e=>{Ze(e,"Access-Control-Allow-Origin","*"),Ze(e,"Access-Control-Allow-Methods","GET, OPTIONS"),Ze(e,"Access-Control-Allow-Headers","Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, ngrok-skip-browser-warning")}),Yw=Re(e=>{Ze(e,"Cache-Control","no-cache")}),Qw=Re(async e=>ya(e,"/extensions/dev-console",307));async function Dp(e,t){let{filePath:n}=t;if(!await C(n))return Ft(e,{statusCode:404,statusMessage:`Not Found: ${n}`});if(await Dt(n)&&(n+=n.endsWith("/")?"index.html":"/index.html",!await C(n)))return Ft(e,{statusCode:404,statusMessage:`Not Found: ${n}`});let i=await P(n,{}),o={".ico":"image/x-icon",".html":"text/html",".js":"text/javascript",".json":"application/json",".wasm":"application/wasm",".css":"text/css",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".wav":"audio/wav",".mp3":"audio/mpeg",".svg":"image/svg+xml",".pdf":"application/pdf",".doc":"application/msword"},r=cn(n),a=o[r]||"text/plain";return Ze(e,"Content-Type",a),i}function Jw({getExtensions:e,payloadStore:t}){return Re(async n=>{let{extensionId:i,assetPath:o=""}=cr(n),r=e().find(m=>m.devUUID===i);if(!r)return Ft(n,{statusCode:404,statusMessage:`Extension with id ${i} not found`});let s=t.getAssetResolver(r.devUUID)?.get(o)??o,c=he(Cr(r.outputPath)),d=he(k(c,s)),p=z(c,d);return p.startsWith("..")||Qr(p)?Ft(n,{statusCode:404,statusMessage:"Not Found"}):Dp(n,{filePath:d})})}function Rp({payloadStore:e}){return Re(t=>(Ze(t,"content-type","application/json"),e.getRawPayload()))}var Xw=Re(async e=>{let t=await qe(k("assets","dev-console"),{type:"directory",cwd:ui(import.meta.url)});return t?Dp(e,{filePath:t}):Ft(e,{statusCode:404,statusMessage:"Could not find root directory for dev console"})}),Zw=Re(async e=>{let{assetPath:t=""}=cr(e),n=await qe(k("assets","dev-console","extensions","dev-console","assets"),{type:"directory",cwd:ui(import.meta.url)});return n?Dp(e,{filePath:k(n,t)}):Ft(e,{statusCode:404,statusMessage:"Could not find root directory for dev console asset"})});function e_({devOptions:e}){return Re(t=>{S(`UI extensions server received a ${t.method} request to URL ${t.path}`,e.stdout)})}function Up({devOptions:e,getExtensions:t}){return Re(async n=>{let{extensionId:i}=cr(n),o=t().find(s=>s.devUUID===i);if(!o)return Ft(n,{statusCode:404,statusMessage:`Extension with id ${i} not found`});if(pr(n,"accept")?.startsWith("text/html")){if(o.type==="checkout_post_purchase")return Gw({data:{url:Qs(o,e)},template:"index",extensionSurface:"post_purchase"});{let s=Ww(o,e);return ya(n,s,307)}}let a=e.appWatcher.buildOutputPath;return Ze(n,"content-type","application/json"),{app:{apiKey:e.apiKey},version:e.manifestVersion,root:{url:new URL("/extensions",e.url).toString()},socket:{url:Go(e.url)},devConsole:{url:new URL("/extensions/dev-console",e.url).toString()},store:e.storeFqdn,extension:await Ho(o,a,e)}})}function t_({devOptions:e,getExtensions:t}){return Re(async n=>{let{extensionId:i,extensionPointTarget:o=""}=cr(n),r=t().find(s=>s.devUUID===i);if(!r)return Ft(n,{statusCode:404,statusMessage:`Extension with id ${i} not found`});if(r.configuration.type!=="checkout_post_purchase"&&!r.hasExtensionPointTarget(o))return Ft(n,{statusCode:404,statusMessage:`Extension with id ${i} has not configured the "${o}" extension target`});let a=Hw(o,r,e);return a?ya(n,a,307):Ft(n,{statusCode:404,statusMessage:`Redirect url can't be constructed for extension with id ${i} and extension target "${o}"`})})}import{createServer as qP}from"http";function n_(e){let t=va(),n=ka();t.use(e_(e)),t.use(Kw),t.use(Yw),n.use("/extensions/dev-console",Xw),n.use("/extensions/dev-console/assets/**:assetPath",Zw),n.use("/extensions/:extensionId",Up(e)),n.use("/extensions/:extensionId/",Up(e)),n.use("/extensions/:extensionId/:extensionPointTarget",t_(e)),n.use("/extensions/:extensionId/assets/**:assetPath",Jw(e)),n.use("/extensions",Rp(e)),n.use("/extensions/",Rp(e)),n.use("/",Qw),t.use(n);let i=qP(wa(t));return i.listen(e.devOptions.port,"localhost"),i}async function i_(e){let t={...e,websocketURL:Go(e.url)},n=t.appWatcher.buildOutputPath,i=new Map,o=await Vw(t,n,i),r=new Ys(o,t,i),a=t.extensions.filter(m=>m.isPreviewable),s=()=>a;S("Setting up the UI extensions HTTP server...",t.stdout);let c=n_({devOptions:t,payloadStore:r,getExtensions:s});S("Setting up the UI extensions Websocket server...",t.stdout);let d=zw({...t,httpServer:c,payloadStore:r});S("Setting up the UI extensions bundler and file watching...",t.stdout);let p=async({appWasReloaded:m,app:h,extensionEvents:g})=>{m&&(a=h.allExtensions.filter(f=>f.isPreviewable));for(let f of g){if(!f.extension.isPreviewable)continue;let v=f.buildResult?.status==="ok"?"success":"error",_=f.buildResult?.status==="error"?{message:f.buildResult.error,file:f.buildResult.file}:void 0;switch(f.type){case ye.Created:if(t.extensions.push(f.extension),!t.checkoutCartUrl){let x=await Fs(t.extensions,t.storeFqdn);t.checkoutCartUrl=x}await r.addExtension(f.extension,n);break;case ye.Updated:await r.updateExtension(f.extension,t,n,{status:v,error:_});break;case ye.Deleted:t.extensions=t.extensions.filter(x=>x.devUUID!==f.extension.devUUID),await r.deleteExtension(f.extension);break}}};t.appWatcher.onEvent(p).onStart(p),t.signal.addEventListener("abort",()=>{S("Closing the UI extensions dev server..."),d.close(),c.close()})}function Go(e){let t=new URL("/extensions",e);return t.protocol="wss:",t.toString()}var jP="3",BP=async({stderr:e,stdout:t,abortSignal:n},{apiKey:i,storeFqdn:o,storeId:r,subscriptionProductUrl:a,port:s,cartUrl:c,proxyUrl:d,appName:p,appDotEnvFile:m,appId:h,grantedScopes:g,allExtensions:f,appDirectory:v,appWatcher:_})=>{await i_({appName:p,appDotEnvFile:m,appDirectory:v,id:h,extensions:f,stdout:t,stderr:e,signal:n,url:d,port:s,storeFqdn:K(o),storeId:r,apiKey:i,grantedScopes:g,checkoutCartUrl:c,subscriptionProductUrl:a,manifestVersion:jP,appWatcher:_})};async function o_({allExtensions:e,storeFqdn:t,checkoutCartUrl:n,...i}){let o=e.filter(a=>a.isPreviewable),r=await Fs(o,t,n);return{prefix:"extensions",type:"previewable-extension",function:BP,options:{pathPrefix:"/extensions",port:-1,storeFqdn:t,allExtensions:e,cartUrl:r,...i}}}l();l();l();async function r_(e){let t={},n=await En(e);return await Promise.all(n.map(async i=>{let o=z(e.directory,i),a=H(o)==="assets"?"binary":"utf8",s=await P(i,{encoding:a});t[o]=Buffer.from(s,a).toString("base64")})),{theme_extension:{files:t}}}async function a_({extension:e,developerPlatformClient:t,apiKey:n,registrationId:i,stdout:o,stderr:r,appConfiguration:a,bundlePath:s}){let c,d=e.getOutputPathForDirectory(s);if(e.features.includes("esbuild")){let _=await P(d);if(!_)return;c=Buffer.from(_).toString("base64")}let p;e.isThemeExtension?p=await r_(e):p=await e.deployConfig({apiKey:n,appConfiguration:a})??{};let m={...p,serialized_script:c};if(e.isFunctionExtension){let _=await P(e.outputPath,{encoding:"base64"});m.uploaded_files={"dist/index.wasm":_}}let h={apiKey:n,config:JSON.stringify(m),handle:e.handle,context:e.contextValue,registrationId:i},g,f=[];try{g=await t.updateExtension(h)}catch(_){if(f=[{message:"Unknown error"}],_&&typeof _=="object"){let x=_;x.errors?.length?f=x.errors:x.message&&(f=[{message:x.message}])}else typeof _=="string"&&(f=[{message:_}])}let v=g?.extensionUpdateDraft?.userErrors;if(v?.length&&f.push(...v),f.length>0){let _=f.map(x=>x.message).join(", ");r.write(`${e.draftMessages.errorMessage}: ${_}`)}else{let _=e.draftMessages.successMessage;_&&q(_,o)}}var zP=async({stderr:e,stdout:t},{developerPlatformClient:n,apiKey:i,remoteExtensionIds:o,localApp:r,appWatcher:a})=>{await _o(r);let s=r.draftableExtensions.map(d=>d.handle),c=async d=>{let m=d.extensionEvents.filter(h=>h.type===ye.Updated).filter(h=>h.buildResult?.status==="ok").filter(h=>s.includes(h.extension.handle)).map(async h=>{let g=h.extension,f=o[g.localIdentifier];if(!f)throw new y(`Extension ${g.localIdentifier} not found on remote app.`);await je({outputPrefix:g.outputPrefix},async()=>{await a_({extension:g,developerPlatformClient:n,apiKey:i,registrationId:f,stdout:t,stderr:e,appConfiguration:r.configuration,bundlePath:a.buildOutputPath})})});await Promise.all(m)};a.onEvent(c).onStart(c)};async function s_({localApp:e,apiKey:t,developerPlatformClient:n,remoteApp:i,...o}){let r=e.draftableExtensions;if(r.length===0)return;let a=_s({app:e}),{extensionIds:s,extensions:c}=await ks({app:e,remoteApp:i,appId:t,appName:i.title,force:!0,release:!0,developerPlatformClient:n,envIdentifiers:a,includeDraftExtensions:!0});return e.updateExtensionUUIDS(c),{type:"draftable-extension",prefix:"extensions",function:zP,options:{localApp:e,apiKey:t,developerPlatformClient:n,...o,extensions:r,remoteExtensionIds:s}}}l();l();function Wi(e){let t=e.find(i=>Ye(i,fe.Frontend)),n=e.find(i=>Ye(i,fe.Backend));return{frontendConfig:t,backendConfig:n}}l();l();async function Js(e,t,n){let i={method:"POST",body:t,headers:{"Content-Type":"application/json",...JSON.parse(n)}},o=await Ae(e,i);return o.status>=200&&o.status<300}l();var ce={LOCALHOST:"localhost",HTTP:"http",PUBSUB:"google-pub-sub",EVENTBRIDGE:"event-bridge"},l_={LOCALHOST:new RegExp("^http:","i"),HTTP:new RegExp("^https:","i"),PUBSUB:new RegExp("^pubsub:"),EVENTBRIDGE:new RegExp("^arn:aws:events:")};function Op(e,t){let n=Mp(e);return n===ce.LOCALHOST&&t===ce.HTTP?!0:n===t}function c_(e){return l_.LOCALHOST.test(e)?new URL(e.toLowerCase()).hostname==="localhost":!1}function p_(e,t){if(!Op(e,t))throw new y(`Can't deliver your webhook payload to this address using '${t}'`,"Use a valid URL for address",WP(t));let n=t;return c_(e)&&(n=ce.LOCALHOST),[e.trim(),n]}function WP(e){return e===ce.HTTP?["For remote HTTP testing, use a URL that starts with https://","For local HTTP testing, use http://localhost:{port}/{url-path}"]:e===ce.PUBSUB?["For Google Pub/Sub, use pubsub://{project-id}:{topic-id}"]:e===ce.EVENTBRIDGE?["For Amazon EventBridge, use an Amazon Resource Name (ARN) starting with arn:aws:events:"]:[]}function d_(e,t){if(t.includes(e))return e;throw new y(`Api Version '${e}' does not exist`,`Allowed values: ${t.join(", ")}`,["Try again with a valid api-version value"])}function u_(e,t,n){if(n.length===0)throw new y(`No topics found for '${t}'`);let i=HP(e.trim(),n);if(i===void 0)throw new y(`Topic '${e}' does not exist for ApiVersion '${t}'`,`Allowed values: ${n.join(", ")}`,["Try again with a valid api-version - topic pair"]);return i}function HP(e,t){return t.includes(e)?e:t.find(n=>n.toUpperCase().replace("/","_")===e)}function Mp(e){if(e){if(e.startsWith("pubsub:"))return ce.PUBSUB;if(e.startsWith("arn:aws:events:"))return ce.EVENTBRIDGE;if(c_(e))return ce.LOCALHOST;if(l_.HTTP.test(e))return ce.HTTP}}async function m_(e){let n={topic:"app/uninstalled",api_version:(await cs(e.developerPlatformClient,e.organizationId))[1],address:e.address,delivery_method:ce.LOCALHOST,shared_secret:e.sharedSecret},i=await ls(e.developerPlatformClient,n,e.organizationId);e.stdout.write("Sending APP_UNINSTALLED webhook to app server"),await Nt(3);let o=await GP(e,i);return e.stdout.write(o?"APP_UNINSTALLED webhook delivered":"APP_UNINSTALLED webhook delivery failed"),o}async function GP(e,t){let n=0;for(;n<3;){try{return await Js(e.address,t.samplePayload,JSON.stringify({...JSON.parse(t.headers),"X-Shopify-Shop-Domain":e.storeFqdn}))}catch(i){if(i instanceof Gd&&i.code==="ECONNREFUSED")n<3&&(e.stdout.write("App isn't responding yet, retrying in 5 seconds"),await Nt(5));else throw i}n++}return e.stdout.write("App hasn't started in time, giving up"),!1}var KP=async({stdout:e},t)=>{await m_({stdout:e,developerPlatformClient:t.developerPlatformClient,address:`http://localhost:${t.deliveryPort}${t.webhooksPath}`,sharedSecret:t.apiSecret,storeFqdn:t.storeFqdn,organizationId:t.organizationId})};function f_({webs:e,remoteAppUpdated:t,backendPort:n,frontendPort:i,organizationId:o,...r}){let{backendConfig:a,frontendConfig:s}=Wi(e),c=e.map(({configuration:p})=>p.webhooks_path).find(p=>p)??"/api/webhooks";if(c&&t&&(s??a))return{type:"send-webhook",prefix:"webhooks",function:KP,options:{deliveryPort:a?n:i,webhooksPath:c,organizationId:o,...r}}}l();l();l();var Z=O(ot(),1),Lp=O(Bm(),1),ue=O(zm(),1);var Xs=da().platform==="darwin"?"MAC_COMMAND_KEY":"Ctrl",YP=`
|
|
839
|
-
# Welcome to GraphiQL for the Shopify Admin API! If you've used
|
|
840
|
-
# GraphiQL before, you can jump to the next tab.
|
|
841
|
-
#
|
|
842
|
-
# GraphiQL is an in-browser tool for writing, validating, and
|
|
843
|
-
# testing GraphQL queries.
|
|
844
|
-
#
|
|
845
|
-
# Type queries into this side of the screen, and you will see intelligent
|
|
846
|
-
# typeaheads aware of the current GraphQL type schema and live syntax and
|
|
847
|
-
# validation errors highlighted within the text.
|
|
848
|
-
#
|
|
849
|
-
# GraphQL queries typically start with a "{" character. Lines that start
|
|
850
|
-
# with a # are ignored.
|
|
851
|
-
#
|
|
852
|
-
# Keyboard shortcuts:
|
|
853
|
-
#
|
|
854
|
-
# Prettify query: Shift-${Xs}-P (or press the prettify button)
|
|
855
|
-
#
|
|
856
|
-
# Merge fragments: Shift-${Xs}-M (or press the merge button)
|
|
857
|
-
#
|
|
858
|
-
# Run Query: ${Xs}-Enter (or press the play button)
|
|
859
|
-
#
|
|
860
|
-
# Auto Complete: ${Xs}-Space (or just start typing)
|
|
861
|
-
#
|
|
862
|
-
`,g_=`query shopInfo {
|
|
863
|
-
shop {
|
|
864
|
-
name
|
|
865
|
-
url
|
|
866
|
-
myshopifyDomain
|
|
867
|
-
plan {
|
|
868
|
-
displayName
|
|
869
|
-
partnerDevelopment
|
|
870
|
-
shopifyPlus
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
`.replace(/\n/g,"\\n");function y_({apiVersion:e,apiVersions:t,appName:n,appUrl:i,key:o,storeFqdn:r}){return`<!DOCTYPE html>
|
|
875
|
-
<html lang="en">
|
|
876
|
-
<head>
|
|
877
|
-
<title>GraphiQL</title>
|
|
878
|
-
<link rel="shortcut icon" href="{{url}}/graphiql/favicon.ico" type="image/x-icon" />
|
|
879
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shopify/polaris@12.10.0/build/esm/styles.css" />
|
|
880
|
-
<style>
|
|
881
|
-
body {
|
|
882
|
-
height: 100%;
|
|
883
|
-
margin: 0;
|
|
884
|
-
width: 100%;
|
|
885
|
-
overflow: hidden;
|
|
886
|
-
}
|
|
887
|
-
.Polaris-Page--fullWidth {
|
|
888
|
-
width: 100%;
|
|
889
|
-
}
|
|
890
|
-
#top-bar {
|
|
891
|
-
border-bottom: 1px solid var(--p-color-border);
|
|
892
|
-
}
|
|
893
|
-
#top-bar #top-error-bar {
|
|
894
|
-
display: none;
|
|
895
|
-
}
|
|
896
|
-
#top-error-bar .Polaris-FullscreenBar__BackAction {
|
|
897
|
-
/* hide default back button in FullscreenBar component */
|
|
898
|
-
display: none;
|
|
899
|
-
}
|
|
900
|
-
#top-error-bar button {
|
|
901
|
-
/* hide X to dismiss banner */
|
|
902
|
-
display: none;
|
|
903
|
-
}
|
|
904
|
-
#top-bar .top-bar-section {
|
|
905
|
-
display: inline-flex;
|
|
906
|
-
align-items: center;
|
|
907
|
-
gap: 8px;
|
|
908
|
-
}
|
|
909
|
-
#top-bar .Polaris-Grid-Cell:nth-child(2) {
|
|
910
|
-
justify-self: right;
|
|
911
|
-
}
|
|
912
|
-
#top-bar #scopes-note {
|
|
913
|
-
display: inline-flex;
|
|
914
|
-
align-items: center;
|
|
915
|
-
height: 100%;
|
|
916
|
-
}
|
|
917
|
-
#top-bar .status-badge-option {
|
|
918
|
-
gap: 8px;
|
|
919
|
-
display: none;
|
|
920
|
-
}
|
|
921
|
-
#top-bar #status-badge-running {
|
|
922
|
-
display: flex;
|
|
923
|
-
}
|
|
924
|
-
#graphiql {
|
|
925
|
-
height: 100vh;
|
|
926
|
-
display: flex;
|
|
927
|
-
flex-direction: column;
|
|
928
|
-
}
|
|
929
|
-
#graphiql-explorer {
|
|
930
|
-
flex-grow: 1;
|
|
931
|
-
overflow: auto;
|
|
932
|
-
}
|
|
933
|
-
#top-bar #outbound-links a {
|
|
934
|
-
line-height: 0;
|
|
935
|
-
}
|
|
936
|
-
#top-bar #outbound-links a:hover .Polaris-Text--root {
|
|
937
|
-
text-decoration: underline;
|
|
938
|
-
}
|
|
939
|
-
#top-bar #outbound-links a span.Polaris-Text--root {
|
|
940
|
-
max-width: max(12vw, 150px);
|
|
941
|
-
text-overflow: ellipsis;
|
|
942
|
-
overflow: hidden;
|
|
943
|
-
white-space: nowrap;
|
|
944
|
-
}
|
|
945
|
-
.with-shrunk-icon .Polaris-Icon {
|
|
946
|
-
height: 1rem;
|
|
947
|
-
width: 1rem;
|
|
948
|
-
margin: 0.125rem;
|
|
949
|
-
}
|
|
950
|
-
@media only screen and (max-width: 1550px) {
|
|
951
|
-
.top-bar-section-title {
|
|
952
|
-
display: none;
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
@media only screen and (max-width: 1150px) {
|
|
956
|
-
#top-bar #outbound-links a span.Polaris-Text--root {
|
|
957
|
-
max-width: max(12vw, 140px);
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
@media only screen and (max-width: 1080px) {
|
|
961
|
-
#top-bar .Polaris-Grid-Cell:nth-child(2) {
|
|
962
|
-
justify-self: left;
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
@media only screen and (max-width: 650px) {
|
|
966
|
-
#top-bar #outbound-links a span.Polaris-Text--root {
|
|
967
|
-
max-width: 17vw;
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
</style>
|
|
971
|
-
|
|
972
|
-
<script
|
|
973
|
-
src="https://cdn.jsdelivr.net/npm/react@17/umd/react.development.js"
|
|
974
|
-
integrity="sha512-Vf2xGDzpqUOEIKO+X2rgTLWPY+65++WPwCHkX2nFMu9IcstumPsf/uKKRd5prX3wOu8Q0GBylRpsDB26R6ExOg=="
|
|
975
|
-
crossorigin="anonymous"
|
|
976
|
-
></script>
|
|
977
|
-
<script
|
|
978
|
-
src="https://cdn.jsdelivr.net/npm/react-dom@17/umd/react-dom.development.js"
|
|
979
|
-
integrity="sha512-Wr9OKCTtq1anK0hq5bY3X/AvDI5EflDSAh0mE9gma+4hl+kXdTJPKZ3TwLMBcrgUeoY0s3dq9JjhCQc7vddtFg=="
|
|
980
|
-
crossorigin="anonymous"
|
|
981
|
-
></script>
|
|
982
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/graphiql@3.0.4/graphiql.min.css" />
|
|
983
|
-
</head>
|
|
984
|
-
<body>
|
|
985
|
-
<div id="graphiql">
|
|
986
|
-
${(0,Lp.renderToStaticMarkup)(Z.default.createElement(ue.AppProvider,{i18n:{}},Z.default.createElement("div",{id:"top-bar"},Z.default.createElement(ue.Box,{background:"bg-surface",padding:"400"},Z.default.createElement(ue.BlockStack,{gap:"300"},Z.default.createElement(ue.Grid,{columns:{xs:3,sm:3,md:3}},Z.default.createElement(ue.Grid.Cell,{columnSpan:{xs:3,sm:3,md:3,lg:7,xl:7}},Z.default.createElement(ue.InlineStack,{gap:"400"},Z.default.createElement("div",{id:"status-badge",className:"top-bar-section"},Z.default.createElement("div",{className:"status-badge-option",id:"status-badge-running"},Z.default.createElement("span",{className:"top-bar-section-title"},"Status: "),Z.default.createElement(ue.Badge,{tone:"success",progress:"complete"},"Running")),Z.default.createElement("div",{className:"status-badge-option with-shrunk-icon",id:"status-badge-unauthorized"},Z.default.createElement("span",{className:"top-bar-section-title"},"Status: "),Z.default.createElement(ue.Badge,{tone:"attention",icon:Wm},"App uninstalled")),Z.default.createElement("div",{className:"status-badge-option with-shrunk-icon",id:"status-badge-disconnected"},Z.default.createElement("span",{className:"top-bar-section-title"},"Status: "),Z.default.createElement(ue.Badge,{tone:"critical",icon:Wl},"Disconnected"))),Z.default.createElement("div",{id:"version-select",className:"top-bar-section"},Z.default.createElement("span",{className:"top-bar-section-title"},"API version: "),Z.default.createElement(ue.Select,{label:"API version",labelHidden:!0,options:t,value:e,onChange:()=>{}})),h_({storeFqdn:r,appName:n,appUrl:i}))),Z.default.createElement(ue.Grid.Cell,{columnSpan:{xs:3,sm:3,md:3,lg:5,xl:5}},Z.default.createElement("div",{id:"scopes-note",className:"top-bar-section"},Z.default.createElement(ue.Text,{as:"span",tone:"subdued"},"GraphiQL runs on the same access scopes you've defined in the TOML file for your app.")))),Z.default.createElement("div",{id:"top-error-bar"},Z.default.createElement(ue.Banner,{tone:"critical",onDismiss:()=>{},icon:Wl},Z.default.createElement("p",null,"The server has been stopped. Restart ",Z.default.createElement("code",null,"dev")," from the CLI."))))))))}
|
|
987
|
-
<div id="graphiql-explorer">Loading...</div>
|
|
988
|
-
</div>
|
|
989
|
-
<script
|
|
990
|
-
src="https://cdn.jsdelivr.net/npm/graphiql@3.0.4/graphiql.min.js"
|
|
991
|
-
type="application/javascript"
|
|
992
|
-
></script>
|
|
993
|
-
<script>
|
|
994
|
-
const macCommandKey = String.fromCodePoint(8984)
|
|
995
|
-
const renderGraphiQL = function(apiVersion) {
|
|
996
|
-
ReactDOM.render(
|
|
997
|
-
React.createElement(GraphiQL, {
|
|
998
|
-
fetcher: GraphiQL.createFetcher({
|
|
999
|
-
url: '{{url}}/graphiql/graphql.json?key=${encodeURIComponent(o)}&api_version=' + apiVersion,
|
|
1000
|
-
}),
|
|
1001
|
-
defaultEditorToolsVisibility: true,
|
|
1002
|
-
{% if query %}
|
|
1003
|
-
query: {{query}},
|
|
1004
|
-
{% endif %}
|
|
1005
|
-
{% if variables %}
|
|
1006
|
-
variables: {{variables}},
|
|
1007
|
-
{% endif %}
|
|
1008
|
-
defaultTabs: [
|
|
1009
|
-
{query: "${YP.replace(/"/g,'\\"').replace(/\n/g,"\\n")}".replace(/MAC_COMMAND_KEY/g, macCommandKey)},
|
|
1010
|
-
{%for query in defaultQueries%}
|
|
1011
|
-
{query: "{%if query.preface %}{{query.preface}}\\n{% endif %}{{query.query}}", variables: "{{query.variables}}"},
|
|
1012
|
-
{%endfor%}
|
|
1013
|
-
],
|
|
1014
|
-
isHeadersEditorEnabled: true,
|
|
1015
|
-
}),
|
|
1016
|
-
document.getElementById('graphiql-explorer'),
|
|
1017
|
-
)
|
|
1018
|
-
}
|
|
1019
|
-
renderGraphiQL('${e}')
|
|
1020
|
-
|
|
1021
|
-
// Update the version when the select changes
|
|
1022
|
-
document.getElementById('version-select').addEventListener('change', function(event) {
|
|
1023
|
-
document.querySelector('#version-select .Polaris-Select__SelectedOption').innerText = event.target.value
|
|
1024
|
-
renderGraphiQL(event.target.value)
|
|
1025
|
-
})
|
|
1026
|
-
|
|
1027
|
-
// Start out optimistic
|
|
1028
|
-
let serverIsLive = true
|
|
1029
|
-
let appIsInstalled = true
|
|
1030
|
-
|
|
1031
|
-
const updateBadge = function() {
|
|
1032
|
-
const topErrorBar = document.querySelector('#graphiql #top-error-bar')
|
|
1033
|
-
const statusDiv = document.querySelector('#graphiql #status-badge')
|
|
1034
|
-
const allBadgeDivs = Array.from(statusDiv.querySelectorAll('.status-badge-option'))
|
|
1035
|
-
let activeBadge = 'running'
|
|
1036
|
-
if (!appIsInstalled) activeBadge = 'unauthorized'
|
|
1037
|
-
if (!serverIsLive) activeBadge = 'disconnected'
|
|
1038
|
-
allBadgeDivs.forEach(function(badge) {
|
|
1039
|
-
if (badge.id == ('status-badge-' + activeBadge)) {
|
|
1040
|
-
badge.style.display = 'flex'
|
|
1041
|
-
} else {
|
|
1042
|
-
badge.style.display = 'none'
|
|
1043
|
-
}
|
|
1044
|
-
})
|
|
1045
|
-
topErrorBar.style.display = serverIsLive ? 'none' : 'block'
|
|
1046
|
-
}
|
|
1047
|
-
const statusInterval = setInterval(updateBadge, 1000)
|
|
1048
|
-
|
|
1049
|
-
// Warn when the server has been stopped
|
|
1050
|
-
const displayErrorServerStoppedTimeouts = []
|
|
1051
|
-
const pingInterval = setInterval(function() {
|
|
1052
|
-
displayErrorServerStoppedTimeouts.push(setTimeout(function() { serverIsLive = false }, 3000))
|
|
1053
|
-
fetch('{{url}}/graphiql/ping')
|
|
1054
|
-
.then(function(response) {
|
|
1055
|
-
if (response.status === 200) {
|
|
1056
|
-
while (displayErrorServerStoppedTimeouts.length > 0) {
|
|
1057
|
-
const timeout = displayErrorServerStoppedTimeouts.pop()
|
|
1058
|
-
clearTimeout(timeout)
|
|
1059
|
-
}
|
|
1060
|
-
serverIsLive = true
|
|
1061
|
-
} else {
|
|
1062
|
-
serverIsLive = false
|
|
1063
|
-
}
|
|
1064
|
-
})
|
|
1065
|
-
}, 2000)
|
|
1066
|
-
|
|
1067
|
-
// Verify the current store/app connection
|
|
1068
|
-
setInterval(function() {
|
|
1069
|
-
fetch('{{ url }}/graphiql/status?key=${encodeURIComponent(o)}')
|
|
1070
|
-
.then(async function(response) {
|
|
1071
|
-
const {status, storeFqdn, appName, appUrl} = await response.json()
|
|
1072
|
-
appIsInstalled = status === 'OK'
|
|
1073
|
-
if (storeFqdn) {
|
|
1074
|
-
document.getElementById('outbound-links').innerHTML = \`${(0,Lp.renderToStaticMarkup)(Z.default.createElement(ue.AppProvider,{i18n:{}},h_({storeFqdn:"${storeFqdn}",appName:"${appName}",appUrl:"${appUrl}"})))}\`
|
|
1075
|
-
}
|
|
1076
|
-
})
|
|
1077
|
-
}, 5000)
|
|
1078
|
-
</script>
|
|
1079
|
-
</body>
|
|
1080
|
-
</html>
|
|
1081
|
-
`}function h_({storeFqdn:e,appName:t,appUrl:n}){return Z.default.createElement("div",{id:"outbound-links",className:"top-bar-section with-shrunk-icon"},Z.default.createElement("span",{className:"top-bar-section-title"},"Store: "),Z.default.createElement(ue.Link,{url:`https://${e}/admin`,target:"_blank"},Z.default.createElement(ue.Badge,{tone:"info",icon:Hl,children:e})),Z.default.createElement("span",{className:"top-bar-section-title"},"App: "),Z.default.createElement(ue.Link,{url:n,target:"_blank"},Z.default.createElement(ue.Badge,{tone:"info",icon:Hl,children:t})))}l();var pe=O(ot(),1),v_=O(Bm(),1),We=O(zm(),1),QP=pe.default.createElement("svg",{width:"102",height:"28",viewBox:"0 0 102 28",fill:"none",xmlns:"http://www.w3.org/2000/svg"},pe.default.createElement("path",{d:"M21.4028 5.3032C21.3836 5.16414 21.2615 5.08697 21.16 5.07856C21.0594 5.07016 19.0881 5.04036 19.0881 5.04036C19.0881 5.04036 17.4395 3.44802 17.2767 3.28603C17.1138 3.12405 16.7957 3.17295 16.6721 3.20962C16.6705 3.21039 16.3625 3.30513 15.8439 3.46483C15.7571 3.18517 15.6296 2.84134 15.4475 2.49597C14.8606 1.38194 14.0009 0.792838 12.9623 0.79131C12.9608 0.79131 12.96 0.79131 12.9585 0.79131C12.8862 0.79131 12.8148 0.798187 12.7426 0.804299C12.7119 0.767624 12.6811 0.731712 12.6489 0.696564C12.1964 0.215194 11.6164 -0.0193788 10.9211 0.00125134C9.57979 0.0394553 8.24384 1.00296 7.16064 2.7145C6.39856 3.91869 5.81855 5.43157 5.65415 6.6029C4.11386 7.0774 3.0368 7.40901 3.01299 7.41665C2.23554 7.65962 2.21096 7.68331 2.10955 8.41224C2.03427 8.96314 0 24.6084 0 24.6084L17.0477 27.541L24.4365 25.7141C24.4365 25.7141 21.422 5.44226 21.4028 5.3032ZM14.9904 3.72767C14.5979 3.84839 14.1515 3.98593 13.6675 4.13492C13.6575 3.45948 13.5769 2.51966 13.2604 1.70744C14.2783 1.89923 14.7792 3.04458 14.9904 3.72767ZM12.7756 4.40999C11.8822 4.68506 10.9073 4.98534 9.92933 5.28639C10.2044 4.23884 10.726 3.19587 11.3667 2.51202C11.6048 2.25758 11.9382 1.97411 12.3331 1.81212C12.7042 2.58231 12.7848 3.67266 12.7756 4.40999ZM10.948 0.889112C11.263 0.882236 11.528 0.951003 11.7546 1.09923C11.392 1.28643 11.0417 1.55539 10.7129 1.9061C9.86096 2.81536 9.20797 4.22661 8.94754 5.5882C8.13552 5.83806 7.34118 6.08333 6.60983 6.30797C7.07153 4.16472 8.87763 0.94871 10.948 0.889112Z",fill:"#95BF47"}),pe.default.createElement("path",{d:"M21.1611 5.07934C21.0605 5.07093 19.0892 5.04114 19.0892 5.04114C19.0892 5.04114 17.4406 3.44879 17.2778 3.28681C17.2171 3.22645 17.1349 3.19512 17.0488 3.18213L17.0496 27.5402L24.4376 25.7141C24.4376 25.7141 21.4231 5.44304 21.4039 5.30398C21.3847 5.16492 21.2618 5.08774 21.1611 5.07934Z",fill:"#5E8E3E"}),pe.default.createElement("path",{d:"M12.9528 8.85773L12.0947 12.0508C12.0947 12.0508 11.1375 11.6176 10.0028 11.6886C8.33885 11.7933 8.32118 12.8371 8.33808 13.0991C8.42873 14.5272 12.2061 14.8389 12.4181 18.1841C12.5848 20.8156 11.0146 22.6158 8.75216 22.7579C6.03647 22.9283 4.5415 21.3352 4.5415 21.3352L5.11691 18.9008C5.11691 18.9008 6.62186 20.0301 7.82644 19.9545C8.61311 19.9048 8.89428 19.2683 8.86585 18.8183C8.74755 16.9554 5.67157 17.0655 5.4772 14.0046C5.31357 11.4289 7.01443 8.81876 10.7672 8.58343C12.213 8.49097 12.9528 8.85773 12.9528 8.85773Z",fill:"white"}),pe.default.createElement("path",{d:"M34.1664 15.544C33.3168 15.0855 32.8802 14.699 32.8802 14.1677C32.8802 13.4917 33.4867 13.0575 34.4338 13.0575C35.5364 13.0575 36.5208 13.516 36.5208 13.516L37.2973 11.15C37.2973 11.15 36.5833 10.5945 34.4818 10.5945C31.5574 10.5945 29.5306 12.2602 29.5306 14.602C29.5306 15.9297 30.4769 16.9437 31.7395 17.6675C32.759 18.2465 33.1232 18.6572 33.1232 19.2605C33.1232 19.888 32.6135 20.395 31.6671 20.395C30.2567 20.395 28.9248 19.6705 28.9248 19.6705L28.0996 22.0365C28.0996 22.0365 29.3302 22.8572 31.4004 22.8572C34.4102 22.8572 36.5704 21.3847 36.5704 18.7292C36.5696 17.306 35.4777 16.292 34.1664 15.544Z",fill:"black"}),pe.default.createElement("path",{d:"M46.1564 10.571C44.6759 10.571 43.5108 11.2712 42.6132 12.333L42.5645 12.3087L43.8507 5.62222H40.5011L37.249 22.6405H40.5986L41.7149 16.8232C42.1515 14.6262 43.2922 13.275 44.3604 13.275C45.1125 13.275 45.4043 13.782 45.4043 14.5065C45.4043 14.965 45.3555 15.5205 45.2588 15.979L43.997 22.6412H47.3466L48.6571 15.7615C48.8027 15.037 48.9002 14.1685 48.9002 13.5887C48.8987 11.7055 47.9036 10.571 46.1564 10.571Z",fill:"black"}),pe.default.createElement("path",{d:"M56.4709 10.571C52.4416 10.571 49.7725 14.192 49.7725 18.223C49.7725 20.8058 51.3741 22.8815 54.3839 22.8815C58.34 22.8815 61.0099 19.3575 61.0099 15.2295C61.0099 12.84 59.6018 10.571 56.4709 10.571ZM54.8205 20.3238C53.6798 20.3238 53.1944 19.3583 53.1944 18.151C53.1944 16.2443 54.1896 13.1303 56.0099 13.1303C57.1993 13.1303 57.5872 14.1443 57.5872 15.134C57.5872 17.1855 56.5928 20.3238 54.8205 20.3238Z",fill:"black"}),pe.default.createElement("path",{d:"M69.5778 10.571C67.3171 10.571 66.0339 12.5505 66.0339 12.5505H65.9859L66.1802 10.7643H63.2192C63.0737 11.9715 62.8062 13.8055 62.5396 15.1818L60.2095 27.3718H63.5591L64.481 22.4473H64.5542C64.5542 22.4473 65.2415 22.8815 66.5201 22.8815C70.4518 22.8815 73.0242 18.8748 73.0242 14.8187C73.0242 12.5748 72.029 10.571 69.5778 10.571ZM66.3738 20.3715C65.5044 20.3715 64.99 19.8888 64.99 19.8888L65.5485 16.7748C65.9371 14.699 67.029 13.3228 68.1941 13.3228C69.2136 13.3228 69.529 14.264 69.529 15.1575C69.529 17.306 68.2428 20.3715 66.3738 20.3715Z",fill:"black"}),pe.default.createElement("path",{d:"M77.8058 5.79121C76.7383 5.79121 75.8887 6.63622 75.8887 7.72221C75.8887 8.71197 76.5196 9.38797 77.4659 9.38797H77.5147C78.5586 9.38797 79.4562 8.68771 79.4806 7.45697C79.4806 6.49147 78.8253 5.79121 77.8058 5.79121Z",fill:"black"}),pe.default.createElement("path",{d:"M73.1216 22.6405H76.4704L78.7525 10.837H75.3785L73.1216 22.6405Z",fill:"black"}),pe.default.createElement("path",{d:"M87.2711 10.8127H84.9411L85.0622 10.2572C85.2565 9.12274 85.9362 8.10874 87.0525 8.10874C87.6483 8.10874 88.12 8.27774 88.12 8.27774L88.7753 5.67074C88.7753 5.67074 88.1931 5.38124 86.9549 5.38124C85.7655 5.38124 84.5768 5.71924 83.6785 6.49149C82.5378 7.45699 82.0037 8.85674 81.737 10.2572L81.6402 10.8127H80.0866L79.6012 13.3235H81.1549L79.3833 22.6413H82.7329L84.5045 13.3235H86.8102L87.2711 10.8127Z",fill:"black"}),pe.default.createElement("path",{d:"M95.3288 10.837C95.3288 10.837 93.2349 16.0836 92.2947 18.9475H92.2459C92.1819 18.0252 91.4207 10.837 91.4207 10.837H87.9012L89.9166 21.675C89.9653 21.916 89.9409 22.0615 89.8434 22.2305C89.4548 22.9785 88.7995 23.703 88.0231 24.2343C87.3922 24.6928 86.6881 24.9823 86.1304 25.1755L87.0523 28C87.732 27.8553 89.1394 27.2998 90.3288 26.1895C91.858 24.7655 93.2654 22.5685 94.7215 19.575L98.8231 10.8362H95.3288V10.837Z",fill:"black"})),JP=(0,v_.renderToStaticMarkup)(pe.default.createElement(We.AppProvider,{i18n:{}},pe.default.createElement(We.Page,{narrowWidth:!0},pe.default.createElement("div",{className:"card-wrapper"},pe.default.createElement(We.Card,{padding:"600"},pe.default.createElement(We.BlockStack,{gap:"500"},QP,pe.default.createElement("div",{id:"pre-install"},pe.default.createElement(We.BlockStack,{gap:"200"},pe.default.createElement(We.Text,{variant:"headingMd",as:"h2"},"Install your app to access GraphiQL"),pe.default.createElement("p",null,"The GraphiQL Explorer relies on your app being installed on your dev store to access its data."),pe.default.createElement("p",{id:"card-cta"},pe.default.createElement(We.Button,{id:"app-install-button"},"Install your app")))),pe.default.createElement("div",{id:"post-install"},pe.default.createElement(We.BlockStack,{gap:"200"},pe.default.createElement(We.Text,{variant:"headingMd",as:"h2"},"Loading GraphiQL..."),pe.default.createElement("p",null,"If you're not redirected automatically, ",pe.default.createElement(We.Link,{url:"{{url}}/graphiql"},"click here"),"."))))))))),k_=`
|
|
1082
|
-
<!DOCTYPE html>
|
|
1083
|
-
<html>
|
|
1084
|
-
<head>
|
|
1085
|
-
<title>GraphiQL Explorer - App Not Installed</title>
|
|
1086
|
-
<meta charset="UTF-8">
|
|
1087
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
1088
|
-
|
|
1089
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
1090
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shopify/polaris@12.10.0/build/esm/styles.css" />
|
|
1091
|
-
<style>
|
|
1092
|
-
.vertical-center {
|
|
1093
|
-
display: flex;
|
|
1094
|
-
flex-direction: row;
|
|
1095
|
-
align-items: center;
|
|
1096
|
-
height: 100%;
|
|
1097
|
-
}
|
|
1098
|
-
.card-wrapper {
|
|
1099
|
-
max-width: 480px;
|
|
1100
|
-
margin-left: 20px;
|
|
1101
|
-
margin-right: 20px;
|
|
1102
|
-
}
|
|
1103
|
-
#post-install {
|
|
1104
|
-
display: none;
|
|
1105
|
-
}
|
|
1106
|
-
</style>
|
|
1107
|
-
|
|
1108
|
-
<script type="text/javascript">
|
|
1109
|
-
let appInstalled = false
|
|
1110
|
-
let newTab = null
|
|
1111
|
-
|
|
1112
|
-
setInterval(function() {
|
|
1113
|
-
fetch('{{ url }}/graphiql/status')
|
|
1114
|
-
.then(async function(response) {
|
|
1115
|
-
const body = await response.json()
|
|
1116
|
-
if (body.status === 'OK') {
|
|
1117
|
-
if (newTab) newTab.close()
|
|
1118
|
-
document.getElementById('pre-install').style.display = 'none'
|
|
1119
|
-
document.getElementById('post-install').style.display = 'block'
|
|
1120
|
-
window.location.href = window.location.href
|
|
1121
|
-
}
|
|
1122
|
-
})
|
|
1123
|
-
}, 5000)
|
|
1124
|
-
|
|
1125
|
-
function openAppInstallTab() {
|
|
1126
|
-
newTab = window.open('{{ previewUrl }}', '_blank')
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
document.addEventListener("DOMContentLoaded", function() {
|
|
1130
|
-
document.getElementById('app-install-button').onclick = openAppInstallTab
|
|
1131
|
-
})
|
|
1132
|
-
</script>
|
|
1133
|
-
</head>
|
|
1134
|
-
<body>
|
|
1135
|
-
<div class="vertical-center">
|
|
1136
|
-
${JP}
|
|
1137
|
-
</div>
|
|
1138
|
-
</body>
|
|
1139
|
-
</html>
|
|
1140
|
-
`;l();var XP=new Set(["connection","keep-alive","proxy-authenticate","proxy-authorization","te","trailer","transfer-encoding","upgrade","host","content-length","content-type","accept","user-agent","authorization","cookie","x-shopify-access-token"]);function w_(e){let t={};for(let[n,i]of Object.entries(e))!XP.has(n.toLowerCase())&&typeof i=="string"&&(t[n]=i);return t}import{createHmac as ZP}from"crypto";import{createServer as eI}from"http";import{readFileSync as __}from"fs";import{createRequire as tI}from"module";function nI(e,t){return ZP("sha256",e).update(`graphiql:${t}`).digest("hex")}function $p(e,t,n){return e?.trim()||nI(t,n)}var b_=tI(import.meta.url),Zs=class extends y{constructor(){super("Failed to refresh credentials. Check that your app is installed, and try again.")}};function S_({stdout:e,port:t,appName:n,appUrl:i,apiKey:o,apiSecret:r,key:a,storeFqdn:s}){let c=$p(a,r,s);S(`Setting up GraphiQL HTTP server on port ${t}...`,e);let d=va(),p=ka(),m;async function h(){return m??(m=await g()),m}async function g(){try{S("refreshing token",e),m=void 0;let F={client_id:o,client_secret:r,grant_type:"client_credentials"};return(await(await Ae(`https://${s}/admin/oauth/access_token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)})).json()).access_token}catch{throw new Zs}}async function f(){return xa(async()=>am({storeFqdn:s,token:await h()}),g)}let v=b_.resolve("../../../assets/graphiql/favicon.ico"),_=__(v),x=b_.resolve("../../../assets/graphiql/style.css"),E=__(x,"utf8");d.use(Re(F=>{Ze(F,"Access-Control-Allow-Origin","*"),Ze(F,"Access-Control-Allow-Methods","GET, OPTIONS"),Ze(F,"Access-Control-Allow-Headers","Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, ngrok-skip-browser-warning")})),p.get("/graphiql/ping",Re(()=>"pong")),p.get("/graphiql/favicon.ico",Re(F=>(Ze(F,"Content-Type","image/x-icon"),_))),p.get("/graphiql/simple.css",Re(F=>(Ze(F,"Content-Type","text/css"),E))),p.get("/graphiql/status",Re(async()=>{try{return await f(),{status:"OK",storeFqdn:s,appName:n,appUrl:i}}catch{return{status:"UNAUTHENTICATED"}}})),p.get("/graphiql",Re(async F=>{S("Handling /graphiql request",e);let W=jl(F);if(c&&W.key!==c)return dr(F,404),`Invalid path ${F.path}`;let ne=pr(F,"x-forwarded-proto")==="https",be=pr(F,"host"),U=`http${ne?"s":""}://${be}`,we;try{we=await f()}catch(er){if(er instanceof Zs)return mr(k_,{previewUrl:i,url:U});throw er}let Ve=we.sort().reverse()[0];function Ue(er){return er?decodeURIComponent(er).replace(/\n/g,"\\n"):void 0}let nt=Ue(W.query),Sd=Ue(W.variables);return mr(y_({apiVersion:Ve,apiVersions:[...we,"unstable"],appName:n,appUrl:i,key:c,storeFqdn:s}),{url:U,defaultQueries:[{query:g_}],query:nt?JSON.stringify(nt):void 0,variables:Sd?JSON.stringify(Sd):void 0})})),p.post("/graphiql/graphql.json",Re(async F=>{S("Handling /graphiql/graphql.json request",e);let W=jl(F);if(c&&W.key!==c)return dr(F,404),`Invalid path ${F.path}`;let ee=Kt(s,W.api_version);try{let ne=await hm(F),be=JSON.stringify(ne),U=fm(F),we=w_(U),Ve=async()=>{let nt={...we,Accept:"application/json","Content-Type":"application/json","X-Shopify-Access-Token":await h(),"User-Agent":`ShopifyCLIGraphiQL/${Pt}`};return Ae(ee,{method:"POST",headers:nt,body:be})},Ue=await Ve();return Ue.status===401&&(S("Token expired, fetching new token",e),await g(),Ue=await Ve()),Ze(F,"Content-Type","application/json"),dr(F,Ue.status),Ue.json()}catch(ne){return dr(F,500),ne instanceof Error?{errors:[ne.message]}:{errors:["Unknown error"]}}})),d.use(p);let A=eI(wa(d));return A.listen(t,"localhost",()=>e.write(`GraphiQL server started on port ${t}`)),A}async function x_(e){return{type:"graphiql",prefix:"graphiql",options:e,function:iI}}var iI=async({stdout:e,abortSignal:t},n)=>{let i=S_({...n,stdout:e});t.addEventListener("abort",async()=>{i.close()})};l();async function C_({webs:e,proxyUrl:t,frontendPort:n,backendPort:i,apiKey:o,apiSecret:r,scopes:a}){let{frontendConfig:s}=Wi(e),c=s?.configuration.hmr_server?await pt():void 0,d=void 0,p=e.map(async m=>{let h=await oI({web:m,frontendPort:n,backendPort:i}),g=c&&m.configuration.roles.includes(fe.Frontend)?{port:c,httpPaths:m.configuration.hmr_server.http_paths}:void 0;return{type:"web",prefix:m.configuration.name??["web",...m.configuration.roles].join("-"),function:rI,options:{port:h,portFromConfig:m.configuration.port,apiKey:o,apiSecret:r,hostname:t,backendPort:i,frontendServerPort:n,directory:m.directory,devCommand:m.configuration.commands.dev,preDevCommand:m.configuration.commands.predev,scopes:a,shopCustomDomain:d,hmrServerOptions:g,roles:m.configuration.roles}}});return Promise.all(p)}async function oI({web:e,frontendPort:t,backendPort:n}){return Ye(e,fe.Frontend)?t:Ye(e,fe.Backend)?n:pt()}async function rI({stdout:e,stderr:t,abortSignal:n},{port:i,apiKey:o,apiSecret:r,hostname:a,backendPort:s,frontendServerPort:c,directory:d,devCommand:p,preDevCommand:m,scopes:h,shopCustomDomain:g,hmrServerOptions:f}){let v=f?.port,_={SHOPIFY_API_KEY:o,SHOPIFY_API_SECRET:r,HOST:a,SCOPES:h,NODE_ENV:"development",...g&&{SHOP_CUSTOM_DOMAIN:g},BACKEND_PORT:`${s}`,FRONTEND_PORT:`${c}`,...v&&{HMR_SERVER_PORT:`${v}`},APP_URL:a,APP_ENV:"development",REMIX_DEV_ORIGIN:a},x={signal:n,directory:d,port:i,env:_,stdout:e,stderr:t};m&&(e.write(`Running pre-dev command: "${m}"`),await E_({...x,command:m,showOutput:Pu()})),await E_({...x,command:p,showOutput:!0})}async function E_({command:e,signal:t,directory:n,port:i,env:o,showOutput:r,stdout:a,stderr:s}){let c=e.split("&&").map(d=>d.trim())??[];for(let d of c){let[p,...m]=d.split(" ");p?.length!==0&&await Ke(p,m,{cwd:n,stdout:r?a:void 0,stderr:s,signal:t,env:{...o,PORT:`${i}`,SERVER_PORT:`${i}`}})}}l();l();l();var el=class{constructor(t){this.stdout=t}async info(t){await this.log(t)}async warning(t){await this.log(w`${b.yellow(t)}`.value)}async success(t){await this.log(w`${b.green(t)}`.value)}async debug(t){S(t,this.stdout)}async error(t,n){let i=b.errorText("\u274C Error"),o=b.errorText(`\u2514 ${t}`);await this.log(w`${i}`.value,n),await this.log(w`${o}`.value,n)}async logUserErrors(t,n){if(typeof t=="string")await this.error(t);else if(t instanceof Error)await this.error(t.message);else{let i=t.map(o=>{let r=o.on?o.on[0]:void 0,a=n.find(s=>s.uid===r?.user_identifier);return{error:o.message,prefix:a?.handle??"app-preview"}});await this.logMultipleErrors(i)}}async logExtensionEvents(t){let n=t.extensionEvents.filter(o=>o.extension.isAppConfigExtension),i=t.extensionEvents.filter(o=>!o.extension.isAppConfigExtension);n.length&&await this.log("App config updated","app-config"),i.forEach(async o=>{let r=o.extension.handle,a=`Extension ${o.type}`;await this.log(a,r)})}async logExtensionUpdateMessages(t){if(!t)return;let n=t.extensionEvents??[],o=(await Promise.all(n.map(async a=>a.type===ye.Deleted?[]:(await a.extension.getDevSessionUpdateMessages())?.map(c=>({message:c,prefix:a.extension.handle}))??[]))).flat(),r=o.map((a,s)=>{let c=w`${b.gray(s===o.length-1?"\u2514 ":"\u2502 ")}${a.message}`.value;return this.log(c,a.prefix)});await Promise.all(r)}async logMultipleErrors(t){let n=b.errorText("\u274C Error");await this.log(w`${n}`.value,"app-preview");let i=t.map(o=>{let r=b.errorText(`\u2514 ${o.error}`);return this.log(w`${r}`.value,o.prefix)});await Promise.all(i)}async log(t,n){await je({outputPrefix:n??"app-preview",stripAnsi:!1},()=>{this.stdout.write(t)})}};var tl=class e{static async start(t,n){let i=new e(t,n);return await i.start(),i}constructor(t,n){this.failedEvents=[],this.currentSessionState=null,this.statusManager=t.devSessionStatusManager,this.logger=new el(n),this.options=t,this.appWatcher=t.appWatcher,this.bundlePath=t.appWatcher.buildOutputPath,this.appEventsProcessor=new Hm(i=>this.processEvents(i))}async start(){await this.logger.info(`Preparing dev preview on ${this.options.storeFqdn}`),this.statusManager.setMessage("LOADING"),this.appWatcher.onEvent(async t=>this.onEvent(t)).onStart(async t=>this.onStart(t)).onError(async t=>this.handleDevSessionResult({status:"unknown-error",error:t}))}async onEvent(t){await this.validateAppEvent(t)&&this.appEventsProcessor.enqueue(t)}async processEvents(t){let n=[...this.failedEvents,...t],i=this.consolidateAppEvents(n);if(this.failedEvents=[],!i)return;this.statusManager.setMessage("CHANGE_DETECTED"),this.updatePreviewURL(i),await this.logger.logExtensionEvents(i);let o=go(),r=await this.bundleExtensionsAndUpload(i);await this.handleDevSessionResult(r,i),await this.logger.debug(`\u2705 Event handled [Network: ${_i(o)}ms - Total: ${_i(i.startTime)}ms]`)}consolidateAppEvents(t){if(t.length===0)return;if(t.length===1)return t[0];let n=t[0],i=t[t.length-1];if(!n||!i)return;let o=new Map;for(let a of t)for(let s of a.extensionEvents)o.set(s.extension.uid,s);return{app:i.app,path:i.path,extensionEvents:Array.from(o.values()),startTime:n.startTime,appWasReloaded:t.some(a=>a.appWasReloaded)}}async onStart(t){let n=this.parseBuildErrors(t);if(n.length)await this.logger.logMultipleErrors(n),await setImmediate(()=>{let i=n.map(o=>o.prefix);throw new y(`Dev preview aborted, build errors detected in extensions: ${i}`)});else{let i=await this.bundleExtensionsAndUpload(t);await this.handleDevSessionResult(i,t)}}async validateAppEvent(t){if(!this.statusManager.status.isReady)return await this.logger.warning("Change detected, but dev preview is not ready yet."),!1;let n=this.parseBuildErrors(t);return n.length?(await this.logger.logMultipleErrors(n),this.statusManager.setMessage("BUILD_ERROR"),!1):t.extensionEvents.length===0?(this.statusManager.setMessage("READY"),!1):!0}parseBuildErrors(t){return t.extensionEvents.filter(i=>i.buildResult?.status==="error").map(i=>({error:"Build error. Please review your code and try again.",prefix:i.extension.handle}))}async handleDevSessionResult(t,n){t.status==="updated"?(await this.logger.success(`\u2705 Updated dev preview on ${this.options.storeFqdn}`),await this.logger.logExtensionUpdateMessages(n),await this.setUpdatedStatusMessage()):t.status==="created"?(this.statusManager.updateStatus({isReady:!0}),await this.logger.success("\u2705 Ready, watching for changes in your app "),await this.logger.logExtensionUpdateMessages(n),this.statusManager.setMessage("READY")):t.status==="aborted"?await this.logger.debug("\u274C Dev preview update aborted (new change detected or error during update)"):(t.status==="remote-error"||t.status==="unknown-error")&&(await this.logger.logUserErrors(t.error,n?.app.allExtensions??[]),t.error instanceof Error&&t.error.cause==="validation-error"?this.statusManager.setMessage("VALIDATION_ERROR"):(n&&this.failedEvents.push(n),this.statusManager.setMessage("REMOTE_ERROR"))),!this.statusManager.status.isReady&&!ft()&&setImmediate(()=>{throw new y("Failed to start dev preview.")})}updatePreviewURL(t){let n=t.app.allExtensions.filter(a=>a.isPreviewable).length>0,o=_n()&&n?this.options.appLocalProxyURL:this.options.appPreviewURL,r=t.app.nonConfigExtensions.length>0;this.statusManager.updateStatus({previewURL:o,appEmbedded:t.app.configuration.embedded,hasExtensions:r})}async setUpdatedStatusMessage(){this.statusManager.setMessage("UPDATED"),setTimeout(async()=>{this.statusManager.status.statusMessage?.message==="Updated"&&this.statusManager.setMessage("READY")},2e3)}async bundleExtensionsAndUpload(t){try{let{manifest:n,inheritedModuleUids:i,assets:o}=await this.createManifest(t),r=await this.uploadAssetsIfNeeded(o,!this.statusManager.status.isReady),a=Go(this.options.url);if(this.statusManager.status.isReady){let s={shopFqdn:this.options.storeFqdn,appId:this.options.appId,assetsUrl:r,manifest:n,inheritedModuleUids:i};return this.devSessionUpdateWithRetry(s)}else{let s={shopFqdn:this.options.storeFqdn,appId:this.options.appId,assetsUrl:r,websocketUrl:a};return this.devSessionCreateWithRetry(s)}}catch(n){if(n.statusCode===401)throw new Error("Unauthorized");if(n instanceof na)throw n.response.status===401||n.response.status===403?new y("Auth session expired. Please run `shopify app dev` again."):(await this.logger.debug(JSON.stringify(n.response,null,2)),new y("Unknown error"));return n.code==="ETIMEDOUT"?{status:"unknown-error",error:new Error("Request timed out, please check your internet connection and try again.")}:{status:"unknown-error",error:n}}}async createManifest(t){let n=t.extensionEvents.filter(s=>s.type!=="deleted").map(s=>s.extension.uid);t.app.allExtensions.some(s=>s.type==="admin")&&!n.includes("admin")&&n.push("admin");let i=t.app.allExtensions.filter(s=>!n.includes(s.uid)).map(s=>s.uid),o=await t.app.manifest(void 0);await Ls(o,this.bundlePath),this.statusManager.status.isReady&&(o.modules=o.modules.filter(s=>n.includes(s.uid)));let r=await Ld(this.bundlePath),a=o.modules.map(s=>s.assets).filter(s=>r.includes(s));return{manifest:o,inheritedModuleUids:i,assets:a}}async uploadAssetsIfNeeded(t,n){if(!t.length&&!n)return;let i=k(H(this.bundlePath),`dev-bundle.${this.options.developerPlatformClient.bundleFormat}`),o=[...t.map(a=>`${a}/**`),...bp];n&&o.push("manifest.json"),await $s(this.bundlePath,i,o);let r=await this.getSignedURLWithRetry();return await Vs(r,i),r}async getSignedURLWithRetry(){return qs(this.options.developerPlatformClient,{apiKey:this.options.appId,organizationId:this.options.organizationId,id:this.options.appId})}async devSessionUpdateWithRetry(t){let n=await this.options.developerPlatformClient.devSessionUpdate(t),i=n.devSessionUpdate?.userErrors??[],o=n.devSessionUpdate?.devSession;if(o&&this.currentSessionState){let r=Go(this.options.url),a=this.currentSessionState?.userId;if(o.websocketUrl!==r||o.user?.id!==a){let s=o.user?.email;await this.logger.error(`Another developer ${s?`(${s}) `:""}has taken ownership of this dev preview.`);let c=`Another user${s?` (${s})`:""} has taken ownership of this dev preview. Your preview is no longer active.`,d=["You can restart by running",{command:"shopify app dev"},"again."];throw new y(c,d)}this.currentSessionState={websocketUrl:o.websocketUrl,userId:o.user?.id??null,userEmail:o.user?.email??null}}return i.length?{status:"remote-error",error:i}:{status:"updated"}}async devSessionCreateWithRetry(t){let n=await this.options.developerPlatformClient.devSessionCreate(t),i=n.devSessionCreate?.userErrors??[],o=n.devSessionCreate?.warnings??[],r=n.devSessionCreate?.devSession;return r&&(this.currentSessionState={websocketUrl:r.websocketUrl,userId:r.user?.id??null,userEmail:r.user?.email??null}),o.length>0&&await Promise.all(o.map(a=>{let s=a.code==="SESSION_TAKEOVER"?`\u26A0\uFE0F ${a.message}`:a.message;return this.logger.warning(s)})),i.length?{status:"remote-error",error:i}:{status:"created"}}};async function N_({app:e,apiKey:t,developerPlatformClient:n,...i}){return{type:"dev-session",prefix:"app-preview",function:aI,options:{app:e,apiKey:t,developerPlatformClient:n,...i}}}var aI=async({stdout:e},t)=>{await tl.start(t,e)};l();l();l();l();l();var Vt=class{constructor({export:t,input:n,inputBytes:i,output:o,outputBytes:r,logs:a,functionId:s,fuelConsumed:c,target:d,errorMessage:p,errorType:m,inputQueryVariablesMetafieldValue:h,inputQueryVariablesMetafieldNamespace:g,inputQueryVariablesMetafieldKey:f}){this.export=t,this.input=n,this.inputBytes=i,this.output=o,this.outputBytes=r,this.logs=a,this.functionId=s,this.fuelConsumed=c,this.target=d,this.errorMessage=p,this.errorType=m,this.inputQueryVariablesMetafieldValue=h,this.inputQueryVariablesMetafieldNamespace=g,this.inputQueryVariablesMetafieldKey=f}},Hi=class{constructor({cacheEntryEpochMs:t,cacheTtlMs:n,httpRequest:i,httpResponse:o}){this.cacheEntryEpochMs=t,this.cacheTtlMs=n,this.httpRequest=i,this.httpResponse=o}},qt;(function(e){e[e.NoCachedResponse=0]="NoCachedResponse",e[e.CacheAboutToExpire=1]="CacheAboutToExpire",e[e.Unknown=2]="Unknown"})(qt||(qt={}));var Gi=class{constructor({reason:t,httpRequest:n}){this.reason=t,this.httpRequest=n}},Ki=class{constructor({attempt:t,connectTimeMs:n,writeReadTimeMs:i,httpRequest:o,httpResponse:r,error:a}){this.attempt=t,this.connectTimeMs=n,this.writeReadTimeMs=i,this.httpRequest=o,this.httpResponse=r,this.error=a}};l();function A_(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype}function sI(e,t){return t?.deep&&A_(e)||t?.deep&&Array.isArray(e)?rn(e,t):e}function rn(e,t){if(Array.isArray(e))return e.map(n=>t?.deep?rn(n,t):n);if(A_(e)){let n={};for(let[i,o]of Object.entries(e))n[nr(i)]=sI(o,t);return n}return e}var Yi=450,nl=5*1e3,T_=60*1e3,Ko=5,il=1e6,jr="function_run",F_="function_network_access",Br="function_network_access.response_from_cache",zr="function_network_access.request_execution_in_background",Wr="function_network_access.request_execution",P_="no_cached_response",I_="cached_response_about_to_expire";function D_(e){let t=JSON.parse(e),n=t.input_query_variables_metafield_value&&L_(t.input_query_variables_metafield_value);return new Vt({export:t.export,input:t.input,inputBytes:t.input_bytes,output:t.output,outputBytes:t.output_bytes,logs:t.logs,functionId:t.function_id,fuelConsumed:t.fuel_consumed,target:t.target,errorMessage:t.error_message,errorType:t.error_type,inputQueryVariablesMetafieldValue:n,inputQueryVariablesMetafieldNamespace:t.input_query_variables_metafield_namespace,inputQueryVariablesMetafieldKey:t.input_query_variables_metafield_key})}function R_(e){let t=JSON.parse(e);return new Hi({cacheEntryEpochMs:t.cache_entry_epoch_ms,cacheTtlMs:t.cache_ttl_ms,httpRequest:t.http_request,httpResponse:t.http_response})}var lI={no_cached_response:qt.NoCachedResponse,cached_response_about_to_expire:qt.CacheAboutToExpire};function U_(e){let t=JSON.parse(e);return new Gi({reason:lI[t.reason]??qt.Unknown,httpRequest:t.http_request})}function O_(e){let t=JSON.parse(e);return new Ki({attempt:t.attempt,connectTimeMs:t.connect_time_ms??null,writeReadTimeMs:t.write_read_time_ms??null,httpRequest:t.http_request,httpResponse:t.http_response??null,error:t.error??null})}var Yo=async e=>{let{errors:t}=e.response,n=Yi,i=null,o="not_attempted";if(t.length>0)if(S(`Errors: ${t.map(r=>r.message).join(", ")}`),t.some(r=>r.status===401))try{i=await e.onResubscribe(),o="succeeded"}catch(r){S(`Failed to resubscribe to app logs: ${r}`),n=T_,o="failed",e.onThrottle(n)}else t.some(r=>r.status===429)?(n=T_,e.onThrottle(n)):(n=nl,e.onUnknownError(n));return{retryIntervalMs:n,nextJwtToken:i,resubscribeResult:o}};function ol(e){return e.allExtensions.flatMap(t=>t.isFunctionExtension?[`extensions.${t.configuration.handle}`]:[])}var rl=({appLog:e,appLogPayload:t,storeName:n,prettyPrint:i=!0})=>{let{cursor:o,...r}=e,a=rn({...r,payload:t,localTime:Zr(e.log_timestamp),storeName:n});return t instanceof Vt&&(a.payload.logs=t.logs.split(`
|
|
1141
|
-
`).filter(Boolean),a.payload.inputQueryVariablesMetafieldValue&&(a.payload.inputQueryVariablesMetafieldValue=L_(a.payload.inputQueryVariablesMetafieldValue))),i?JSON.stringify(a,null,2):JSON.stringify(a)},M_=(e,t)=>{let n=rn(JSON.parse(e));return t===jr?new Vt(n):t===Br?new Hi(n):t===zr?new Gi(n):t===Wr?new Ki(n):n},an=async(e,t,n,i)=>{let o=await e.subscribeToAppLogs(t,n);if(!o.appLogsSubscribe)throw new y("Failed to subscribe to app logs: No response received");let{jwtToken:r,success:a,errors:s}=o.appLogsSubscribe;if(S(`Token: ${r}
|
|
1142
|
-
`),S(`API Key: ${t.apiKey}
|
|
1143
|
-
`),s&&s.length>0){let c=s.join(", ");throw await je({stripAnsi:!1},()=>{se(`Errors subscribing to app logs: ${c}`,i),se("App log streaming is not available in this session.",i)}),new y(c)}else{if(!r)throw new y("Failed to subscribe to app logs: No response received");let c=Array.isArray(t.shopIds)?t.shopIds:[t.shopIds];S(`Subscribed to App Events for shop ID(s) ${c.join(", ")}`),a!==void 0&&S(`Success: ${a}
|
|
1144
|
-
`)}return r};function St(e){try{if(typeof e=="string"){let t=JSON.parse(e);return JSON.stringify(t,null,2)}else return typeof e=="object"&&e!==null?JSON.stringify(e,null,2):void 0}catch(t){throw new Error(`Error parsing JSON: ${t}`)}}var L_=e=>{try{return JSON.parse(e)}catch{return e}};var $_=async({appLog:e,appLogPayload:t,stdout:n,storeName:i,logsDir:o})=>{let r=gn().substring(0,6),s=`${cI(e.log_timestamp)}_${e.source_namespace}_${e.source}_${r}.json`,c=rl({appLog:e,appLogPayload:t,prettyPrint:!0,storeName:i}),d=k(o,s);try{return await ae(o),await ie(d,c),{fullOutputPath:d,identifier:r}}catch(p){throw n.write(`Error while writing log to file: ${p}
|
|
1145
|
-
`),p}};function cI(e){let t=new Date(e),n=t.getUTCFullYear(),i=(t.getUTCMonth()+1).toString().padStart(2,"0"),o=t.getUTCDate().toString().padStart(2,"0"),r=t.getUTCHours().toString().padStart(2,"0"),a=t.getUTCMinutes().toString().padStart(2,"0"),s=t.getUTCSeconds().toString().padStart(2,"0"),c=t.getUTCMilliseconds().toString().padStart(3,"0");return`${n}${i}${o}_${r}${a}${s}_${c}Z`}var al=async({stdout:e,appLogsFetchInput:{jwtToken:t,cursor:n},developerPlatformClient:i,resubscribeCallback:o,storeName:r,organizationId:a,abortSignal:s,logsDir:c,consecutiveResubscribeFailures:d=0})=>{if(!s?.aborted)try{let p=t,m=Yi,h=d,g=await i.appLogs({jwtToken:t,cursor:n},a),{errors:f,status:v}=g;if(v===200){h=0;let{app_logs:x}=g;for(let E of x){let A=JSON.parse(E.payload);await je({outputPrefix:E.source,stripAnsi:!1},async()=>{E.log_type===jr?(pI(E,A,e),A=new Vt(rn(A))):E.log_type.startsWith(F_)?dI(E,A,e):e.write(JSON.stringify(A));let F=await $_({appLog:E,appLogPayload:A,stdout:e,storeName:r,logsDir:c});e.write(w`${b.gray("\u2514 ")}${b.link("Open log file",`file://${F.fullOutputPath}`,`Log: ${F.fullOutputPath}`)} ${b.gray(`(${F.identifier})`)}\n`.value)})}}else{let x={errors:f.map(A=>({message:A,status:v}))},E=await Yo({response:x,onThrottle:A=>{se("Request throttled while polling app logs.",e),se(`Retrying in ${A/1e3} seconds.`,e)},onUnknownError:A=>{se("Error while polling app logs.",e),se(`Retrying in ${A/1e3} seconds.`,e)},onResubscribe:()=>o()});if(E.resubscribeResult==="failed"){if(h+=1,h>=Ko){se("App log streaming session has expired. Please restart your dev session.",e);return}}else E.resubscribeResult==="succeeded"&&(h=0);E.nextJwtToken&&(p=E.nextJwtToken),m=E.retryIntervalMs}let{cursor:_}=g;setTimeout(()=>{al({stdout:e,appLogsFetchInput:{jwtToken:p,cursor:_??n},developerPlatformClient:i,resubscribeCallback:o,storeName:r,organizationId:a,abortSignal:s,logsDir:c,consecutiveResubscribeFailures:h}).catch(x=>{S(`Unexpected error during polling: ${x}}
|
|
1146
|
-
`)})},m)}catch(p){se("Error while polling app logs.",e),se(`Retrying in ${nl/1e3} seconds.`,e),S(`${p}}
|
|
1147
|
-
`),setTimeout(()=>{al({stdout:e,appLogsFetchInput:{jwtToken:t,cursor:void 0},developerPlatformClient:i,resubscribeCallback:o,storeName:r,organizationId:a,abortSignal:s,logsDir:c}).catch(m=>{S(`Unexpected error during polling: ${m}}
|
|
1148
|
-
`)})},nl)}};function pI(e,t,n){let i=(t.fuel_consumed/il).toFixed(4);e.status==="success"?n.write(`Function export "${t.export}" executed successfully using ${i}M instructions.`):e.status==="failure"&&n.write(`\u274C Function export "${t.export}" failed to execute with error: ${t.error_type}`);let o=t.logs;o.length>0&&n.write(o.split(`
|
|
1149
|
-
`).filter(Boolean).map(r=>w`${b.gray("\u2502 ")}${r}`.value).join(`
|
|
1150
|
-
`))}function dI(e,t,n){e.log_type===Br?n.write("Function network access response retrieved from cache."):e.log_type===zr?t.reason===P_?n.write("Function network access request executing in background because there is no cached response."):t.reason===I_&&n.write("Function network access request executing in background because the cached response is about to expire."):e.log_type===Wr&&(e.status==="success"?n.write("Function network access request executed successfully."):e.status==="failure"&&n.write(`\u274C Function network access request failed to execute with error: ${t.error}.`))}function uI(e){return e.allExtensions.some(t=>t.isFunctionExtension)}async function V_({developerPlatformClient:e,subscription:{shopIds:t,apiKey:n},storeName:i,organizationId:o,appWatcher:r,localApp:a}){return{type:"app-logs-subscribe",prefix:"app-logs",function:mI,options:{developerPlatformClient:e,appLogsSubscribeVariables:{shopIds:t,apiKey:n},storeName:i,organizationId:o,appWatcher:r,localApp:a}}}var mI=async({stdout:e,stderr:t,abortSignal:n},{developerPlatformClient:i,appLogsSubscribeVariables:o,storeName:r,organizationId:a,appWatcher:s,localApp:c})=>{async function d(p){let m=await an(i,o,a,e),h=c.getLogsDir();await ae(h),await al({stdout:e,appLogsFetchInput:{jwtToken:m},resubscribeCallback:()=>an(i,o,a),developerPlatformClient:i,storeName:r,organizationId:a,abortSignal:p,logsDir:h})}try{let p=!1,m,h=async g=>{let f=uI(g.app);if(f&&!p){S("Function extensions detected, starting logs polling"),p=!0,m=new AbortController;try{await d(m.signal)}catch(v){S(`Failed to start function logs: ${v}`,t)}}else!f&&p&&(S("No function extensions detected, stopping logs polling"),p=!1,m?.abort(),m=void 0)};s.onStart(h).onEvent(h)}catch{}};l();async function q_(e){return{type:"app-watcher",prefix:"app-preview",options:e,function:fI}}var fI=async({stdout:e,stderr:t,abortSignal:n},i)=>{let{appWatcher:o}=i;await o.start({stdout:e,stderr:t,signal:n})};l();import{EventEmitter as hI}from"events";var gI={BUILD_ERROR:{message:"Build error. Please review your code and try again",type:"error"},READY:{message:"Ready, watching for changes in your app",type:"success"},LOADING:{message:"Preparing dev preview",type:"loading"},UPDATED:{message:"Updated",type:"success"},VALIDATION_ERROR:{message:"Validation error in your app configuration",type:"error"},REMOTE_ERROR:{message:"Error updating dev preview",type:"error"},CHANGE_DETECTED:{message:"Change detected, updating dev preview",type:"loading"}},sl=class extends hI{constructor(t){super(),this.currentStatus={isReady:!1,previewURL:void 0,graphiqlURL:void 0,statusMessage:void 0},t&&(this.currentStatus=t)}updateStatus(t){let n={...this.currentStatus,...t};kn(this.currentStatus,n)||(this.currentStatus=n,this.emit("dev-session-update",n))}setMessage(t){this.updateStatus({statusMessage:gI[t]})}get status(){return this.currentStatus}reset(){this.currentStatus={isReady:!1,previewURL:void 0,graphiqlURL:void 0,statusMessage:void 0}}};l();import*as j_ from"http";import*as B_ from"https";function z_(e){return"errors"in e&&Array.isArray(e.errors)}async function W_(e,t,n,i){let r=(await import("./http-proxy-node16-Q5DZMBHC.js")).default.createProxyServer(),a=vI(e,r,i),s=n?B_.createServer(n,a):j_.createServer(a);return s.on("upgrade",yI(e,r,i)),t.addEventListener("abort",()=>{S("Closing reverse HTTP proxy"),s.close()}),{server:s}}function yI(e,t,n){return function(i,o,r){let a=H_(e,i,!0);if(a)return t.ws(i,o,r,{target:a},s=>{je({outputPrefix:"proxy",stripAnsi:!1},()=>{let d=(z_(s)?s.errors[s.errors.length-1]:void 0)??s;se(`Error forwarding websocket request: ${d.message}`,n),se(`\u2514 Unreachable target "${a}" for path: "${i.url}"`,n)})});o.destroy()}}function vI(e,t,n){return function(i,o){let r=H_(e,i);if(r)return i.method==="OPTIONS"?(o.writeHead(204,{"Access-Control-Allow-Origin":i.headers.origin??"*","Access-Control-Allow-Methods":i.headers["access-control-request-method"]??"GET, POST, PUT, DELETE, PATCH, OPTIONS","Access-Control-Allow-Headers":i.headers["access-control-request-headers"]??"Content-Type, Authorization","Access-Control-Max-Age":"86400"}),o.end()):t.web(i,o,{target:r},a=>{je({outputPrefix:"proxy",stripAnsi:!1},()=>{let c=(z_(a)?a.errors[a.errors.length-1]:void 0)??a;se(`Error forwarding web request: ${c.message}`,n),se(`\u2514 Unreachable target "${r}" for path: "${i.url}"`,n)})});S(w`
|
|
1151
|
-
Reverse HTTP proxy error - Invalid path: ${i.url??""}
|
|
1152
|
-
These are the allowed paths:
|
|
1153
|
-
${b.json(JSON.stringify(e))}
|
|
1154
|
-
`),o.statusCode=500,o.end(`Invalid path ${i.url}`)}}function H_(e,t,n=!1){let i=t.url??"/";for(let o in e)if(i.startsWith(o))return e[o];return n&&e.websocket?e.websocket:e.default}async function G_({localApp:e,remoteAppUpdated:t,developerPlatformClient:n,remoteApp:i,storeFqdn:o,storeId:r,commandOptions:a,network:s,graphiqlPort:c,graphiqlKey:d}){let p=i.apiKey,m=i.apiSecretKeys[0]?.secret??"",h=zd(),g=!Bt(h[Zt.disableGraphiQLExplorer]),f=await on(e),v=new $n(f,s.proxyUrl),_=f.allExtensions.some(nt=>nt.isPreviewable),x=`${s.proxyUrl}/extensions/dev-console`,E=_n(),A;if(E)A=Ks(o,p);else{let nt=await oa();A=Lw(o,p,nt)}let W=E&&_?x:A,ee=$p(d,m,o),ne=g?`http://localhost:${c}/graphiql?key=${encodeURIComponent(ee)}`:void 0,be=f.configuration.embedded,U=f.nonConfigExtensions.length>0,we=new sl({isReady:!1,previewURL:W,graphiqlURL:ne,appEmbedded:be,hasExtensions:U}),Ve=[...await C_({webs:f.webs,proxyUrl:s.proxyUrl,frontendPort:s.frontendPort,backendPort:s.backendPort,apiKey:p,apiSecret:m,scopes:vt(f.configuration)}),g?await x_({appName:i.title,appUrl:A,port:c,apiKey:p,apiSecret:m,key:ee,storeFqdn:o}):void 0,await o_({allExtensions:f.realExtensions,storeFqdn:o,storeId:r,apiKey:p,subscriptionProductUrl:a.subscriptionProductUrl,checkoutCartUrl:a.checkoutCartUrl,proxyUrl:s.proxyUrl,appName:f.name,appDotEnvFile:f.dotenv,grantedScopes:i.grantedScopes,appId:i.id,appDirectory:f.directory,appWatcher:v}),n.supportsDevSessions?await N_({app:f,apiKey:p,developerPlatformClient:n,url:s.proxyUrl,appId:i.id,organizationId:i.organizationId,storeFqdn:o,appWatcher:v,appPreviewURL:A,appLocalProxyURL:x,devSessionStatusManager:we}):await s_({localApp:f,remoteApp:i,apiKey:p,developerPlatformClient:n,proxyUrl:s.proxyUrl,appWatcher:v}),await Ow({remoteApp:i,localApp:f,storeFqdn:o,theme:a.theme,themeExtensionPort:a.themeExtensionPort}),f_({webs:f.webs,backendPort:s.backendPort,frontendPort:s.frontendPort,organizationId:i.organizationId,developerPlatformClient:n,storeFqdn:o,apiSecret:m,remoteAppUpdated:t}),await V_({developerPlatformClient:n,subscription:{shopIds:[Number(r)],apiKey:p},storeName:o,organizationId:i.organizationId,localApp:e,appWatcher:v}),await q_({appWatcher:v})].filter(kI);return{processes:await wI(Ve,s.proxyPort,s.reverseProxyCert),previewUrl:W,graphiqlUrl:ne,devSessionStatusManager:we}}var kI=e=>e!==void 0&&e!==!1;async function wI(e,t,n){let i=await Promise.all(e.map(async a=>{let s={};if(a.type==="web"&&a.options.roles.includes(fe.Frontend)){let c=a.options.portFromConfig??a.options.port;s.default=`http://localhost:${c}`;let d=a.options.hmrServerOptions;d&&(s.websocket=`http://localhost:${d.port}`,d.httpPaths.forEach(p=>s[p]=`http://localhost:${d.port}`)),a.options.port=c}else if(a.type==="previewable-extension"){let c=await pt();s[a.options.pathPrefix]=`http://localhost:${c}`,a.options.port=c}return{process:a,rules:s}})),o=i.map(({process:a})=>a),r=i.map(({rules:a})=>a).reduce((a,s)=>({...a,...s}),{});return Object.keys(r).length>0&&o.push({type:"proxy-server",prefix:"proxy",function:_I,options:{port:t,rules:r,localhostCert:n}}),o}var _I=async({abortSignal:e,stdout:t},{port:n,rules:i,localhostCert:o})=>{let{server:r}=await W_(i,e,o,t);q(`Proxy server started on port ${n} ${o?`with certificate ${o.certPath}`:""}`,t),await r.listen(n,"localhost")};l();l();var X=O(ot(),1);var bI=(e,t)=>Math.max(...e.map(n=>n.prefix.length),...t.map(n=>n.handle.length)),K_=({abortController:e,processes:t,previewUrl:n,graphiqlUrl:i="",graphiqlPort:o,app:r,pollingTime:a=5e3,developerPreview:s,isEditionWeek:c})=>{let{canEnablePreviewMode:d,developmentStorePreviewEnabled:p}=r,{isRawModeSupported:m}=mn(),h=(0,X.useRef)(),g=`http://localhost:${o}/graphiql`,[f,v]=(0,X.useState)(void 0),[_,x]=(0,X.useState)(!0),[E,A]=(0,X.useState)(void 0),{isAborted:F}=wn(e.signal,async U=>{U?v("Shutting down dev because of an error ..."):(v("Shutting down dev ..."),Ca()),clearInterval(h.current),await s.disable()}),W=(0,X.useMemo)(()=>t.map(U=>({...U,action:async(we,Ve,Ue)=>{try{return await U.action(we,Ve,Ue)}catch(nt){e.abort(nt)}}})),[t,e]);(0,X.useEffect)(()=>{let U=async()=>{try{let Ve=await s.fetchMode();x(Ve??!1),A("")}catch{A("Failed to fetch the latest status of the development store preview, trying again in 5 seconds.")}},we=async()=>{try{await s.enable(),A("")}catch{A("Failed to turn on development store preview automatically.\nTry turning it on manually by pressing `d`."),x(!!p)}};if(d){we();let Ve=()=>setInterval(()=>U(),a);h.current=Ve()}return()=>{clearInterval(h.current)}},[d]),fn((U,we)=>{lo(U,we,()=>e.abort()),(async()=>{try{if(A(""),U==="p"&&n)await Q.addPublicMetadata(()=>({cmd_dev_preview_url_opened:!0})),await Rt(n);else if(U==="g"&&i)await Q.addPublicMetadata(()=>({cmd_dev_graphiql_opened:!0})),await Rt(g);else if(U==="q")e.abort();else if(U==="e"&&c)await Rt("https://shopify.link/yQmk");else if(U==="d"&&d){await Q.addPublicMetadata(()=>({cmd_dev_dev_preview_toggle_used:!0}));let Ue=!_;x(Ue);try{if(!await s.update(Ue))throw new Error(`Failed to turn ${Ue?"on":"off"} development store preview.`)}catch{x(_),A(`Failed to turn ${Ue?"on":"off"} development store preview.`)}}}catch{A("Failed to handle your input.")}})()},{isActive:!!m});let ee=new Date,ne=ee.getMonth()>3?"Summer":"Winter",be=ee.getFullYear();return X.default.createElement(X.default.Fragment,null,X.default.createElement(ua,{processes:W,prefixColumnSize:bI(W,r.extensions),abortSignal:e.signal,keepRunningAfterProcessesResolve:!0,useAlternativeColorPalette:!1}),F?null:X.default.createElement(V,{marginY:1,paddingTop:1,flexDirection:"column",flexGrow:1,borderStyle:"single",borderBottom:!1,borderLeft:!1,borderRight:!1,borderTop:!0},m?X.default.createElement(V,{flexDirection:"column"},c?X.default.createElement(N,null,Me.pointerSmall," Press ",X.default.createElement(N,{bold:!0},"e")," ",Me.lineVertical," check out ",ne," Edition",` ${be}`,", live NOW with 100+ product announcements!"):null,d?X.default.createElement(N,null,Me.pointerSmall," Press ",X.default.createElement(N,{bold:!0},"d")," ",Me.lineVertical," toggle development store preview: ",_?X.default.createElement(N,{color:"green"},"\u2714 on"):X.default.createElement(N,{color:"red"},"\u2716 off")):null,i?X.default.createElement(N,null,Me.pointerSmall," Press ",X.default.createElement(N,{bold:!0},"g")," ",Me.lineVertical," open GraphiQL (Admin API) in your browser"):null,X.default.createElement(N,null,Me.pointerSmall," Press ",X.default.createElement(N,{bold:!0},"p")," ",Me.lineVertical," preview in your browser"),X.default.createElement(N,null,Me.pointerSmall," Press ",X.default.createElement(N,{bold:!0},"q")," ",Me.lineVertical," quit")):null,X.default.createElement(V,{marginTop:m?1:0,flexDirection:"column"},f?X.default.createElement(N,null,f):X.default.createElement(X.default.Fragment,null,X.default.createElement(N,null,"Preview URL: ",X.default.createElement(ro,{url:n})),i?X.default.createElement(N,null,"GraphiQL URL: ",X.default.createElement(ro,{url:g})):null)),E?X.default.createElement(N,{color:"red"},E):null))};l();l();var Qo=O(ot(),1);var Y_=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function Q_(){let[e,t]=(0,Qo.useState)(0);return(0,Qo.useEffect)(()=>{let n=setInterval(()=>{t(i=>(i+1)%Y_.length)},70);return()=>clearInterval(n)},[]),Qo.default.createElement(N,null,Y_[e])}l();var Ie=O(ot(),1);var J_=.9,X_=({tabs:e,initialActiveTab:t})=>{let{stdout:n}=qd(),{isRawModeSupported:i}=mn(),[o,r]=(0,Ie.useState)(t),[a,s]=(0,Ie.useState)(Math.floor(n.columns*J_)),[c,d]=(0,Ie.useState)(!0),p=(0,Ie.useRef)(null);if(!o)throw new Error("No tabs provided");fn((f,v)=>{(async()=>{if(v?.leftArrow||v?.rightArrow||v?.tab){let A=Object.entries(e).filter(([be,U])=>U.content),F=A.findIndex(([be])=>be===o);if(F===-1)return;let W=v?.leftArrow?-1:1,ee=(F+W+A.length)%A.length,ne=A[ee];ne&&r(ne[0])}let x=e[f];if(x){x.action?await x.action():r(f);return}let E=e[o];if(E?.shortcuts){let A=E.shortcuts.find(F=>F.key===f);A&&(!A.condition||A.condition())&&await A.action()}})()},{isActive:!!i}),(0,Ie.useLayoutEffect)(()=>{let f=()=>{if(s(Math.floor(n.columns*J_)),!p.current)return;let v=jd(p.current);d(v.width<n.columns)};return n.on("resize",f),()=>{n.off("resize",f)}},[n]);let m=Object.entries(e).map(([f,v])=>({...v,inputKey:f,header:` (${f}) ${v.label} `})),h=m.filter(f=>!f.action),g=m.filter(f=>f.action);return Ie.default.createElement(Ie.default.Fragment,null,Ie.default.createElement(V,{paddingTop:0,width:a,flexDirection:"row",flexGrow:1,borderStyle:"single",borderBottom:!1,borderLeft:!1,borderRight:!1,borderTop:!0},Ie.default.createElement(V,{ref:p,flexDirection:"row",flexWrap:"nowrap",flexShrink:0,marginRight:3},Ie.default.createElement(N,{wrap:"truncate-end"},"\u2502",h.map(f=>Ie.default.createElement(Ie.default.Fragment,{key:f.inputKey},Ie.default.createElement(N,{bold:o===f.inputKey,inverse:o===f.inputKey,wrap:"truncate"},f.header),"\u2502")))),c&&Ie.default.createElement(V,{flexGrow:1,justifyContent:"flex-end"},g.map((f,v)=>Ie.default.createElement(N,{wrap:"truncate",key:f.inputKey},"(",f.inputKey,") ",f.label,v<g.length-1&&" \u2502 ")))),Ie.default.createElement(V,{flexDirection:"column",marginLeft:1,marginRight:1,marginTop:1},e[o]?.content))};var G=O(ot(),1);var Z_=({abortController:e,processes:t,devSessionStatusManager:n,shopFqdn:i,appURL:o,appName:r,organizationName:a,configPath:s,localURL:c,onAbort:d})=>{let{isRawModeSupported:p}=mn(),[m,h]=(0,G.useState)(void 0),[g,f]=(0,G.useState)(void 0),[v,_]=(0,G.useState)(n.status),[x,E]=(0,G.useState)(!1),{isAborted:A}=wn(e.signal,async U=>{U&&f(typeof U=="string"?U:U.message),n.status.isReady?E(!0):(h("Shutting down dev ..."),await d()),Ca()}),F=(0,G.useMemo)(()=>t.map(U=>({...U,action:async(we,Ve,Ue)=>{try{return await U.action(we,Ve,Ue)}catch(nt){e.abort(nt)}}})),[t,e]);(0,G.useEffect)(()=>(n.on("dev-session-update",_),()=>{n.off("dev-session-update",_)}),[]),fn((U,we)=>{lo(U,we,()=>e.abort())},{isActive:!!p});let W=U=>{switch(U){case"loading":return G.default.createElement(Q_,null);case"success":return"\u2705";case"error":return"\u274C"}},ee=[{key:"p",shortcutLabel:"Open app preview",linkLabel:"Preview",url:v.previewURL,condition:()=>!!(v.isReady&&v.previewURL),action:async()=>{await Q.addPublicMetadata(()=>({cmd_dev_preview_url_opened:!0})),v.previewURL&&await Rt(v.previewURL)}},{key:"c",shortcutLabel:"Open Dev Console for extension previews",linkLabel:"Dev Console",url:Fp(i),condition:()=>!!(v.isReady&&v.appEmbedded===!1&&v.hasExtensions),action:async()=>{await Q.addPublicMetadata(()=>({cmd_dev_preview_url_opened:!0})),await Rt(Fp(i))}},{key:"g",shortcutLabel:"Open GraphiQL (Admin API)",linkLabel:"GraphiQL",url:v.graphiqlURL,condition:()=>!!(v.isReady&&v.graphiqlURL),action:async()=>{await Q.addPublicMetadata(()=>({cmd_dev_graphiql_opened:!0})),v.graphiqlURL&&await Rt(v.graphiqlURL)}}],ne=ee.filter(U=>U.condition?.()??!0),be={d:{label:"Dev status",shortcuts:ee,content:G.default.createElement(G.default.Fragment,null,v.statusMessage&&G.default.createElement(N,null,W(v.statusMessage.type)," ",v.statusMessage.message),p&&ne.length>0&&G.default.createElement(V,{marginTop:1,flexDirection:"column"},ne.map(U=>G.default.createElement(N,{key:U.key},Me.pointerSmall," ",G.default.createElement(N,{bold:!0},"(",U.key,")")," ",Ll()&&U.url?G.default.createElement(ro,{url:U.url,label:U.shortcutLabel}):U.shortcutLabel))),G.default.createElement(V,{marginTop:p?1:0,flexDirection:"column"},m?G.default.createElement(N,null,m):G.default.createElement(G.default.Fragment,null,v.isReady&&!(p&&Ll())&&G.default.createElement(G.default.Fragment,null,ne.filter(U=>U.url).map(U=>G.default.createElement(N,{key:U.key},U.linkLabel," URL: ",G.default.createElement(ro,{url:U.url})))))))},a:{label:"App info",content:G.default.createElement(V,{flexDirection:"column"},G.default.createElement(Ol,{tabularData:[["App:",r??""],["App URL:",o??""],["Local URL:",o?"":c??""],["Config:",s?.split("/").pop()??""],["Org:",a??""]].filter(([,U])=>U)}))},s:{label:"Store info",content:G.default.createElement(V,{flexDirection:"column"},G.default.createElement(Ol,{tabularData:[["Dev store:",{link:{url:`https://${i}`}}],["Dev store admin:",{link:{url:`https://${i}/admin`}}],["Org:",a??""]].filter(([,U])=>U)}))},q:{label:"Quit",action:async()=>{e.abort()}}};return G.default.createElement(G.default.Fragment,null,G.default.createElement(ua,{processes:F,prefixColumnSize:Ee,abortSignal:e.signal,keepRunningAfterProcessesResolve:!0,useAlternativeColorPalette:!0}),x&&G.default.createElement(V,{marginTop:1,flexDirection:"column"},G.default.createElement(bu,{type:"info",headline:`A preview of your development changes is still available on ${i}.`,body:["Run",{command:"shopify app dev clean"},"to restore the latest released version of your app."],link:{label:"Learn more about dev previews",url:"https://shopify.dev/beta/developer-dashboard/shopify-app-dev"}})),A?null:G.default.createElement(V,{paddingTop:1,flexDirection:"column",flexGrow:1},p?G.default.createElement(X_,{tabs:be,initialActiveTab:"d"}):G.default.createElement(V,{marginY:1,paddingTop:0,flexDirection:"column",flexGrow:1,borderStyle:"single",borderBottom:!1,borderLeft:!1,borderRight:!1,borderTop:!0},be.d?.content)),g?G.default.createElement(V,{marginTop:1,flexDirection:"column"},G.default.createElement(N,{color:"red"},g)):null)};var Vp=O(ot(),1);async function eb({processes:e,previewUrl:t,app:n,abortController:i,graphiqlUrl:o,graphiqlPort:r,developerPreview:a,shopFqdn:s,devSessionStatusManager:c,appURL:d,appName:p,organizationName:m,configPath:h,localURL:g}){if(!fa())await SI({processes:e,app:n,abortController:i,developerPreview:a,shopFqdn:s});else return n.developerPlatformClient.supportsDevSessions?ki(Vp.default.createElement(Z_,{processes:e,abortController:i,devSessionStatusManager:c,shopFqdn:s,appURL:d,appName:p,organizationName:m,configPath:h,localURL:g,onAbort:async()=>{await n.developerPlatformClient.devSessionDelete({appId:n.id,shopFqdn:s})}}),{exitOnCtrlC:!1}):ki(Vp.default.createElement(K_,{processes:e,abortController:i,previewUrl:t,app:n,graphiqlUrl:o,graphiqlPort:r,developerPreview:a,isEditionWeek:xI(),shopFqdn:s}),{exitOnCtrlC:!1})}async function SI({processes:e,app:{canEnablePreviewMode:t},abortController:n,developerPreview:i}){return t&&(await i.enable(),n?.signal.addEventListener("abort",async()=>{await i.disable()})),Promise.all(e.map(async o=>{await o.action(process.stdout,process.stderr,n.signal)}))}function xI(){if(Bt(process.env.IS_EDITION_WEEK))return!0;if(ft())return!1;let e=new Date("2024-01-31T17:00:00.000Z"),t=new Date("2024-02-07T17:00:00.000Z"),n=new Date;return n>=e&&n<=t}l();async function tb(e,t){let n=e?.path??"",i=k(t,n);if(!await C(i))throw new y(`
|
|
1155
|
-
The extension is not available for ${e?.value}`);return i}async function nb({name:e,app:t}){let n=Ct(e),i=k(t.directory,wo.extensions.directoryName,n);if(await C(i))throw new y(`
|
|
1156
|
-
A directory with this name (${n}) already exists.
|
|
1157
|
-
Choose a new name for your extension.`);return await ae(i),await pn(k(i,me.lockFile)),i}async function ib({localApp:e,developerPlatformClient:t,apiKey:n,organizationId:i}){let{dashboardManagedExtensionRegistrations:o}=(await t.appExtensionRegistrations({id:n,apiKey:n,organizationId:i})).app;return o.length>0||e.allExtensions.filter(a=>a.isThemeExtension).length>0||e.allExtensions.length>0}l();function ob(e){if(!e.length)return;let t=e.filter(o=>o.requested!==o.actual);if(t.length===0)return;if(t.length===1&&t[0]){let o=t[0];He({headline:[`A random port will be used for ${o.for} because ${o?.requested} is not available.`],body:["If you want to use a specific port, you can choose a different one by setting the ",{command:o?.flagToRemedy}," flag."]});return}let n=xl(t.map(o=>o.for)).join(" "),i=xl(t.map(o=>({command:o.flagToRemedy})));He({headline:[`Random ports will be used for ${n} because the requested ports are not available.`],body:["If you want to use specific ports, you can choose different ports using the",...i,"flags."]})}l();async function rb(e,t){return t?t.includes("localhost")?"localhost":(await Qd(e)).plugins.find(i=>t?.includes(i))??"custom":void 0}l();var ab=O(vx(),1);var Qi="v1.4.4",sb="FiloSottile/mkcert",qp=b.genericShellCommand("mkcert");async function EI(e,t,n,i){let o=t[Zt.mkcertBinaryPath];if(o)return o;let a=k(e,n==="win32"?"mkcert.exe":"mkcert");if(await C(a))return a;let s=await(0,ab.default)("mkcert",{nothrow:!0});return s?(S(w`Found ${qp} at ${b.path(s)}`),s):(await CI(a,n,i),a)}async function CI(e,t,n){let i;switch(t){case"darwin":i=n==="arm64"?`mkcert-${Qi}-darwin-arm64`:`mkcert-${Qi}-darwin-amd64`;break;case"linux":i=n==="arm64"?`mkcert-${Qi}-linux-arm64`:`mkcert-${Qi}-linux-amd64`;break;case"win32":i=`mkcert-${Qi}-windows-amd64.exe`;break;default:throw new L(`Unsupported platform: ${t}`)}await Tm(sb,Qi,i,e),S(w`${qp} saved to ${b.path(e)}`)}async function NI(e){let t=k(e,"mkcert-LICENSE");if(await C(t))return;let n=`https://raw.githubusercontent.com/${sb}/refs/tags/${Qi}/LICENSE`,i={headline:"Failed to download mkcert license.",body:["We tried to download the license for mkcert, but the request failed. You can ",{link:{url:n,label:"view the license here"}}]},o;try{if(o=await Ae(n),!o.ok)return i}catch{return i}let r=await o.text();await ie(t,r)}async function lb({appDirectory:e,env:t=process.env,platform:n=process.platform,arch:i=process.arch}){let o=k(".shopify","localhost-key.pem"),r=k(".shopify","localhost.pem"),a=k(e,o),s=k(e,r);if(await C(a)&&await C(s))return{keyContent:await P(a),certContent:await P(s),certPath:r};if(!await kg())throw new y(`Localhost certificate and key are required at ${r} and ${o}`);let d="",p;return await xe([{title:"Finding or downloading mkcert binary",task:async()=>{let h=k(e,".shopify");d=await EI(h,t,n,i),p=await NI(h),S(w`${qp} found at: ${b.path(d)}`)}}]),p&&oe(p),q(w`Generating self-signed certificate for localhost. You may be prompted for your password.`),await Ke(d,["-install","-key-file",a,"-cert-file",s,"localhost"]),q(w`${b.successIcon()} Certificate generated at ${r}\n`),await Tu()&&(He({headline:"It looks like you're using WSL.",body:["Additional steps are required to configure certificate trust in Windows."],link:{label:"See Shopify CLI documentation",url:"https://shopify.dev/docs/apps/build/cli-for-apps/networking-options#localhost-based-development-with-windows-subsystem-for-linux-wsl"}}),q("\u{1F449} Press any key to continue"),await Cu(),q("")),{keyContent:await P(a),certContent:await P(s),certPath:z(e,s)}}async function pb(e){let t=await AI(e);await TI(t);let{processes:n,graphiqlUrl:i,previewUrl:o,devSessionStatusManager:r}=await G_(t);await II(t),await UI({processes:n,previewUrl:o,graphiqlUrl:i,config:t,devSessionStatusManager:r})}async function AI(e){let{app:t,remoteApp:n,developerPlatformClient:i,store:o,specifications:r,tunnel:a}=e,s;if(a.mode==="auto"){let x=await pt();s=await ng(e.commandConfig,x,"cloudflare")}let c=await Fo(n,i,r,n.flags);n.configuration=c,fv({app:t,remoteApp:n,selectedStore:o,cachedInfo:Ni(e.directory),organization:e.organization,tunnelMode:a.mode}),t.configuration.build?.dev_store_url&&(t.configuration.build={...t.configuration.build,dev_store_url:o.shopDomain},await(await _e.read(t.configPath)).patch({build:{dev_store_url:o.shopDomain}})),!e.skipDependenciesInstallation&&!e.project.usesWorkspaces&&await Ua(e.project);let d=e.graphiqlPort??await pt(kr.graphiql),p=[{for:"GraphiQL",flagToRemedy:"--graphiql-port",requested:e.graphiqlPort??kr.graphiql,actual:d}];a.mode==="use-localhost"&&p.push({for:"localhost",flagToRemedy:"--localhost-port",requested:a.requestedPort,actual:a.actualPort}),ob(p);let{webs:m,...h}=await RI(t.directory,t.webs,d,a,s,n.configuration);t.webs=m;let g=t.configuration.build?.automatically_update_urls_on_dev,f=Ni(e.directory)?.previousAppId,v=n.apiKey,_=await DI(m,e.update,h,t,g,n,v,i);return{storeFqdn:o.shopDomain,storeId:o.shopId,remoteApp:n,remoteAppUpdated:n.apiKey!==f,localApp:t,developerPlatformClient:i,commandOptions:e,network:h,partnerUrlsUpdated:_,graphiqlPort:d,graphiqlKey:e.graphiqlKey}}async function TI(e){await FI(e),await PI(e)}async function FI({localApp:e,remoteApp:t,developerPlatformClient:n,commandOptions:i}){if(n.supportsDevSessions)return;let o=e.configuration.access_scopes,r=t.configuration?.access_scopes,a=d=>d&&d.split(",").map(p=>p.trim()).sort().join(","),s=a(o?.scopes),c=a(r?.scopes);if(!o?.use_legacy_install_flow&&s!==c){let d=[["Run",{command:Be(i.project.packageManager,"shopify app deploy")},"to push your scopes to the Partner Dashboard"]];He({headline:["The scopes in your TOML don't match the scopes in your Partner Dashboard"],body:[`Scopes in ${$(e.configPath)}:`,cb(So(e.configuration)),`
|
|
1158
|
-
`,"Scopes in Partner Dashboard:",cb(r?.scopes?.split(",")??[])],nextSteps:d})}}async function PI(e){let{developerPlatformClient:t,remoteApp:n}=e;if(!t.supportsDevSessions)return;(await t.appExtensionRegistrations(n)).app.extensionRegistrations.filter(o=>o.type.toLowerCase()!=="webhook_subscription").every(o=>o.id)||gs()}async function II(e){Tn({directory:e.commandOptions.directory,previousAppId:e.remoteApp.apiKey}),await MI({devOptions:e.commandOptions,tunnelUrl:e.network.proxyUrl,shouldUpdateURLs:e.partnerUrlsUpdated,storeFqdn:e.storeFqdn}),await ku({config:e.commandOptions.commandConfig,exitMode:"ok"})}async function DI(e,t,n,i,o,r,a,s){let{backendConfig:c,frontendConfig:d}=Wi(e),p=!1;if((d??c)&&t){let m=Za(n.proxyUrl,e.map(({configuration:h})=>h.auth_callback_path).find(h=>h),i.configuration.app_proxy);p=await tg({currentURLs:n.currentUrls,appDirectory:i.directory,cachedUpdateURLs:o,newApp:r.newApp,localApp:i,apiKey:a,newURLs:m,developerPlatformClient:s}),p&&(s.supportsDevSessions?i.setDevApplicationURLs(m):await Zh(m,a,s,i))}return p}async function RI(e,t,n,i,o,r){let{backendConfig:a,frontendConfig:s}=Wi(t);await LI(t,n);let c=i.mode==="use-localhost"?{noTunnelUseLocalhost:!0,port:i.actualPort}:{noTunnelUseLocalhost:!1,tunnelUrl:i.mode==="custom"?i.url:void 0,tunnelClient:o},[{frontendUrl:d,frontendPort:p,usingLocalhost:m},h,g]=await Promise.all([Xh(c),Hd()??a?.configuration.port??pt(),eg(r)]),f=m?`${d}:${p}`:d,v=s?.configuration.port;s&&(v??(v=s===a?h:await pt()),s.configuration.port=v),v=v??await pt();let _;if(i.mode==="use-localhost"){let{keyContent:x,certContent:E,certPath:A}=await lb({appDirectory:e});_={key:x,cert:E,certPath:A,port:i.actualPort}}return{proxyUrl:f,proxyPort:p,frontendPort:v,backendPort:h,currentUrls:g,webs:t,reverseProxyCert:_}}async function UI({processes:e,previewUrl:t,graphiqlUrl:n,config:i,devSessionStatusManager:o}){let r=new hn,a=e.map(p=>({prefix:p.prefix,action:async(h,g,f)=>{let v=p.function;return v({stdout:h,stderr:g,abortSignal:f},p.options)}})),s=i.remoteApp.apiKey,c=i.developerPlatformClient,d={canEnablePreviewMode:c.supportsDevSessions?!1:await ib({localApp:i.localApp,developerPlatformClient:c,apiKey:s,organizationId:i.remoteApp.organizationId}),developmentStorePreviewEnabled:i.remoteApp.developmentStorePreviewEnabled,apiKey:s,id:i.remoteApp.id,developerPlatformClient:c,extensions:i.localApp.allExtensions};return eb({processes:a,previewUrl:t,graphiqlUrl:n,graphiqlPort:i.graphiqlPort,app:d,abortController:r,developerPreview:OI(s,c),shopFqdn:i.storeFqdn,devSessionStatusManager:o,appURL:i.localApp.devApplicationURLs?.applicationUrl,appName:i.remoteApp.title,organizationName:i.commandOptions.organization.businessName,configPath:i.localApp.configPath,localURL:i.network.proxyUrl})}function OI(e,t){return t.supportsDevSessions?{fetchMode:()=>Promise.resolve(!1),enable:()=>Promise.resolve(!1),disable:()=>Promise.resolve(),update:()=>Promise.resolve(!1)}:{fetchMode:async()=>!!await By(e,t),enable:async()=>hv({apiKey:e,developerPlatformClient:t}),disable:async()=>gv({apiKey:e,developerPlatformClient:t}),update:async n=>Ss({apiKey:e,developerPlatformClient:t,enabled:n})}}async function MI(e){let t=await rb(e.devOptions.commandConfig,e.tunnelUrl);await Q.addPublicMetadata(()=>({cmd_dev_tunnel_type:t,cmd_dev_tunnel_custom_hash:t==="custom"?ut(e.tunnelUrl):void 0,cmd_dev_urls_updated:e.shouldUpdateURLs,store_fqdn_hash:ut(e.storeFqdn),cmd_app_dependency_installation_skipped:e.devOptions.skipDependenciesInstallation})),await Q.addSensitiveMetadata(()=>({store_fqdn:e.storeFqdn,cmd_dev_tunnel_custom:t==="custom"?e.tunnelUrl:void 0}))}function cb(e){return{list:{items:e.length===0?["No scopes"]:e}}}async function LI(e,t){let n=e.map(o=>o.configuration.port).filter(o=>o),i=n.find((o,r)=>n.indexOf(o)!==r);if(i)throw new y(`Found port ${i} for multiple webs.`,"Please define a unique port for each web.");await Promise.all([...n.map(async o=>{if(!await Bl(o))throw new y(`Hard-coded port ${o} is not available, please choose a different one.`)}),(async()=>{if(!await Bl(t)){let r=`Port ${t} is not available for serving GraphiQL.`,a=["Choose a different port for the",{command:"--graphiql-port"},"flag."];throw new y(r,a)}})()])}l();async function db({useLocalhost:e,localhostPort:t,tunnelUrl:n}){if(n)return{mode:"custom",url:n};if(!e&&!t)return{mode:"auto"};let i=t??kr.localhost,o=await pt(i);if(t&&o!==i){let r=`Port ${t} is not available.`,a=["Choose a different port for the",{command:"--localhost-port"},"flag."];throw new y(r,a)}return{mode:"use-localhost",requestedPort:i,actualPort:o}}var lt=O(ke(),1);var jp,zn=class extends M{static analyticsStopCommand(){return"app dev stop"}async run(){let{flags:t}=await this.parse(jp),n=await db({useLocalhost:t["use-localhost"],tunnelUrl:t["tunnel-url"],localhostPort:t["localhost-port"]});await mt(()=>({cmd_app_dependency_installation_skipped:t["skip-dependencies-installation"],cmd_app_reset_used:t.reset,cmd_dev_tunnel_type:n.mode})),await Ut(t.path);let i=await B({directory:t.path,clientId:t["client-id"],forceRelink:t.reset,userProvidedConfigName:t.config}),o=await Lt({appContextResult:i,storeFqdn:t.store,forceReselectStore:t.reset}),r={...i,store:o,directory:t.path,update:!t["no-update"],skipDependenciesInstallation:t["skip-dependencies-installation"],commandConfig:this.config,subscriptionProductUrl:t["subscription-product-url"],checkoutCartUrl:t["checkout-cart-url"],theme:t.theme,themeExtensionPort:t["theme-app-extension-port"],notify:t.notify,graphiqlPort:t["graphiql-port"],graphiqlKey:t["graphiql-key"],tunnel:n};return await pb(r),{app:i.app}}};jp=zn;zn.summary="Run the app.";zn.descriptionWithMarkdown="Builds and previews your app on a dev store, and watches for changes. [Read more about testing apps locally](https://shopify.dev/docs/apps/build/cli-for-apps/test-apps-locally).";zn.description=jp.descriptionWithoutMarkdown();zn.flags={...T,...I,store:lt.Flags.string({char:"s",description:"Store URL. Must be an existing development or Shopify Plus sandbox store.",env:"SHOPIFY_FLAG_STORE",parse:async e=>K(e)}),"skip-dependencies-installation":lt.Flags.boolean({description:"Skips the installation of dependencies. Deprecated, use workspaces instead.",env:"SHOPIFY_FLAG_SKIP_DEPENDENCIES_INSTALLATION",default:!1}),"no-update":lt.Flags.boolean({description:"Uses the app URL from the toml file instead an autogenerated URL for dev.",env:"SHOPIFY_FLAG_NO_UPDATE",default:!1}),"subscription-product-url":lt.Flags.string({description:'Resource URL for subscription UI extension. Format: "/products/{productId}"',env:"SHOPIFY_FLAG_SUBSCRIPTION_PRODUCT_URL"}),"checkout-cart-url":lt.Flags.string({description:'Resource URL for checkout UI extension. Format: "/cart/{productVariantID}:{productQuantity}"',env:"SHOPIFY_FLAG_CHECKOUT_CART_URL"}),"tunnel-url":lt.Flags.string({description:'Use a custom tunnel, it must be running before executing dev. Format: "https://my-tunnel-url:port".',env:"SHOPIFY_FLAG_TUNNEL_URL",exclusive:["tunnel"]}),"use-localhost":lt.Flags.boolean({description:"Service entry point will listen to localhost. A tunnel won't be used. Will work for testing many app features, but not those that directly invoke your app (E.g: Webhooks)",env:"SHOPIFY_FLAG_USE_LOCALHOST",default:!1,exclusive:["tunnel-url"]}),"localhost-port":lt.Flags.integer({description:"Port to use for localhost.",env:"SHOPIFY_FLAG_LOCALHOST_PORT"}),theme:lt.Flags.string({char:"t",description:"Theme ID or name of the theme app extension host theme.",env:"SHOPIFY_FLAG_THEME"}),"theme-app-extension-port":lt.Flags.integer({description:"Local port of the theme app extension development server.",env:"SHOPIFY_FLAG_THEME_APP_EXTENSION_PORT"}),notify:lt.Flags.string({description:"The file path or URL. The file path is to a file that you want updated on idle. The URL path is where you want a webhook posted to report on file changes.",env:"SHOPIFY_FLAG_NOTIFY"}),"graphiql-port":lt.Flags.integer({hidden:!0,description:"Local port of the GraphiQL development server.",env:"SHOPIFY_FLAG_GRAPHIQL_PORT"}),"graphiql-key":lt.Flags.string({hidden:!0,description:"Key used to authenticate GraphiQL requests. By default, a key is automatically derived from the app secret. Use this flag to override with a custom key.",env:"SHOPIFY_FLAG_GRAPHIQL_KEY"})};var ub=zn;l();l();l();l();l();l();var Hr=O(ot(),1);function mb(e){let t=(0,Hr.useRef)(e);(0,Hr.useEffect)(()=>{t.current=e},[e]),(0,Hr.useEffect)(()=>{let n;function i(){t.current().then(({retryIntervalMs:r})=>{r&&(n=setTimeout(i,r))}).catch(()=>{})}return n=setTimeout(i,0),()=>n&&clearTimeout(n)},[])}l();var ll=async({pollOptions:{jwtToken:e,cursor:t,filters:n},developerPlatformClient:i,organizationId:o})=>{let r=await i.appLogs({jwtToken:e,cursor:t},o),{errors:a,status:s}=r;if(s!==200){if(s===401||s===429||s>=500)return{errors:a.map(m=>({status:s,message:m}))};throw new y(`${a.join(", ")} while fetching app logs`)}let{cursor:c,app_logs:d}=r,p=$I(d,n);return{cursor:c,appLogs:p}};function $I(e,t){let n=e;return(t.status!==void 0||t.sources!==void 0)&&(n=n.filter(i=>{let o=t.status===void 0?!0:i.status===t.status,r=t.sources===void 0?!0:t.sources.includes(`${i.source_namespace}.${i.source}`);return o&&r})),n}var jt=O(ot(),1);async function VI({jwtToken:e,cursor:t,filters:n,storeNameById:i,organizationId:o,setErrors:r,setAppLogOutputs:a,resubscribeCallback:s,developerPlatformClient:c}){let d=e,p=Yi,m=t,h=await ll({pollOptions:{jwtToken:e,cursor:t,filters:n},developerPlatformClient:c,organizationId:o}),g="not_attempted",f=h;if(f.errors){let v=await Yo({response:f,onThrottle:_=>{r(["Request throttled while polling app logs.",`Retrying in ${_/1e3}s`])},onUnknownError:_=>{r(["Error while polling app logs",`Retrying in ${_/1e3}s`])},onResubscribe:()=>s()});g=v.resubscribeResult,v.nextJwtToken&&(d=v.nextJwtToken),p=v.retryIntervalMs}else{r(_=>_.length?[]:_);let{appLogs:v}=h;if(m=h.cursor,v)for(let _ of v){let x,E,A,F=i.get(_.shop_id.toString());if(F===void 0)continue;switch(_.log_type){case jr:x=D_(_.payload),E=`export "${x.export}" executed in ${(x.fuelConsumed/il).toFixed(4)}M instructions`;break;case Br:x=R_(_.payload),E="network access response retrieved from cache";break;case zr:x=U_(_.payload),E="network access request executing in background";break;case Wr:x=O_(_.payload),A=x.connectTimeMs&&x.writeReadTimeMs?x.connectTimeMs+x.writeReadTimeMs:null,E=`network access request executed${A?` in ${A} ms`:""}`;break;default:continue}let W={status:_.status==="success"?"Success":"Failure",source:_.source,storeName:F,description:E,logTimestamp:Zr(_.log_timestamp)};x&&a(ee=>[...ee,{appLog:x,prefix:W}])}}return{nextJwtToken:d,retryIntervalMs:p,cursor:m??t,resubscribeResult:g}}function fb({initialJwt:e,filters:t,resubscribeCallback:n,storeNameById:i,developerPlatformClient:o,organizationId:r}){let[a,s]=(0,jt.useState)([]),[c,d]=(0,jt.useState)([]),p=(0,jt.useRef)(e),m=(0,jt.useRef)(0),h=(0,jt.useRef)(""),g=(0,jt.useRef)(0),f=(0,jt.useCallback)(async()=>{let v=await VI({jwtToken:p.current,cursor:h.current,filters:t,storeNameById:i,setErrors:s,setAppLogOutputs:d,resubscribeCallback:n,developerPlatformClient:o,organizationId:r});if(v.resubscribeResult==="failed"){if(g.current+=1,g.current>=Ko)return s(["App log streaming session has expired. Please restart your dev session."]),{retryIntervalMs:0}}else v.resubscribeResult==="succeeded"&&(g.current=0);return p.current=v.nextJwtToken,h.current=v.cursor,m.current=v.retryIntervalMs,{retryIntervalMs:m.current}},[]);return mb(f),{appLogOutputs:c,errors:a}}var D=O(ot(),1);var qI=e=>{switch(e){case qt.NoCachedResponse:return"No cached response available";case qt.CacheAboutToExpire:return"Cache is about to expire";case qt.Unknown:return"Unknown reason"}},hb=({pollOptions:{jwtToken:e,filters:t},resubscribeCallback:n,storeNameById:i,developerPlatformClient:o,organizationId:r})=>{let{appLogOutputs:a,errors:s}=fb({filters:t,initialJwt:e,resubscribeCallback:n,storeNameById:i,developerPlatformClient:o,organizationId:r});return D.default.createElement(D.default.Fragment,null,a.map(({appLog:c,prefix:d},p)=>D.default.createElement(V,{flexDirection:"column",key:p},D.default.createElement(V,{flexDirection:"row",gap:1},D.default.createElement(N,null,D.default.createElement(N,{color:"green"},d.logTimestamp," "),D.default.createElement(N,{color:"blueBright"},`${d.storeName.split(".")[0]}`," "),D.default.createElement(N,{color:"blueBright"},d.source," "),D.default.createElement(N,{color:d.status==="Success"?"green":"red"},d.status," "),D.default.createElement(N,null,d.description))),D.default.createElement(V,{flexDirection:"column",marginLeft:4},c instanceof Vt&&D.default.createElement(V,{flexDirection:"column"},D.default.createElement(N,null,c.logs),c.inputQueryVariablesMetafieldKey&&c.inputQueryVariablesMetafieldNamespace?D.default.createElement(V,{flexDirection:"column",marginTop:1},D.default.createElement(N,{bold:!0},"Input Query Variables:"),D.default.createElement(V,{flexDirection:"row",marginLeft:1,marginTop:1},D.default.createElement(N,{dimColor:!0},"Namespace:"),D.default.createElement(N,null," ",c.inputQueryVariablesMetafieldNamespace)),D.default.createElement(V,{flexDirection:"row",marginLeft:1},D.default.createElement(N,{dimColor:!0},"Key:"),D.default.createElement(N,null," ",c.inputQueryVariablesMetafieldKey)),D.default.createElement(V,{marginLeft:1,marginTop:1},D.default.createElement(N,null,St(c.inputQueryVariablesMetafieldValue)??D.default.createElement(N,{color:"red"},"Metafield is not set")))):null,c.input?D.default.createElement(V,{flexDirection:"column",marginTop:1},D.default.createElement(N,{bold:!0},"Input ",D.default.createElement(N,{dimColor:!0},"(",c.inputBytes," bytes):")),D.default.createElement(V,{marginLeft:1,marginTop:1},D.default.createElement(N,null,St(c.input)))):null,c.output?D.default.createElement(V,{flexDirection:"column",marginTop:1},D.default.createElement(N,{bold:!0},"Output ",D.default.createElement(N,{dimColor:!0},"(",c.outputBytes," bytes):")),D.default.createElement(V,{marginLeft:1,marginTop:1},D.default.createElement(N,null,St(c.output)))):null),c instanceof Hi&&D.default.createElement(V,{flexDirection:"column"},D.default.createElement(N,null,"Cache write time: ",new Date(c.cacheEntryEpochMs).toISOString()),D.default.createElement(N,null,"Cache TTL: ",c.cacheTtlMs/1e3," s"),D.default.createElement(N,null,"HTTP request:"),D.default.createElement(N,null,St(c.httpRequest)),D.default.createElement(N,null,"HTTP response:"),D.default.createElement(N,null,St(c.httpResponse))),c instanceof Gi&&D.default.createElement(V,{flexDirection:"column"},D.default.createElement(N,null,"Reason: ",qI(c.reason)),D.default.createElement(N,null,"HTTP request:"),D.default.createElement(N,null,St(c.httpRequest))),c instanceof Ki&&D.default.createElement(V,{flexDirection:"column"},D.default.createElement(N,null,"Attempt: ",c.attempt),c.connectTimeMs?D.default.createElement(N,null,"Connect time: ",c.connectTimeMs," ms"):null,c.writeReadTimeMs?D.default.createElement(N,null,"Write read time: ",c.writeReadTimeMs," ms"):null,D.default.createElement(N,null,"HTTP request:"),D.default.createElement(N,null,St(c.httpRequest)),c.httpResponse?D.default.createElement(V,{flexDirection:"column"},D.default.createElement(N,null,"HTTP response:"),D.default.createElement(N,null,St(c.httpResponse))):null,c.error?D.default.createElement(N,null,"Error: ",c.error):null)))),s.length>0&&D.default.createElement(V,{flexDirection:"column"},s.map((c,d)=>D.default.createElement(V,{key:d},D.default.createElement(N,{color:"red"},c)))))};var gb=O(ot(),1);async function yb({pollOptions:e,options:{variables:t,developerPlatformClient:n},storeNameById:i,organizationId:o}){let r=async()=>an(n,t,o);return ki(gb.default.createElement(hb,{pollOptions:e,resubscribeCallback:r,storeNameById:i,developerPlatformClient:n,organizationId:o}))}l();async function Bp({pollOptions:e,options:{variables:t,developerPlatformClient:n},storeNameById:i,organizationId:o,consecutiveResubscribeFailures:r=0}){let a=await ll({pollOptions:e,developerPlatformClient:n,organizationId:o}),s=Yi,c=e.jwtToken,d=r,p=a;if(p.errors){let g=await Yo({response:p,onThrottle:f=>{q(JSON.stringify({message:"Request throttled while polling app logs.",retry_in_ms:f}))},onUnknownError:f=>{q(JSON.stringify({message:"Error while polling app logs.",retry_in_ms:f}))},onResubscribe:()=>an(n,t,o)});if(g.resubscribeResult==="failed"){if(d+=1,d>=Ko){q(JSON.stringify({message:"App log streaming session has expired. Please restart your dev session."}));return}}else g.resubscribeResult==="succeeded"&&(d=0);g.nextJwtToken&&(c=g.nextJwtToken),s=g.retryIntervalMs}else d=0;let{cursor:m,appLogs:h}=a;h&&h.forEach(g=>{let f=i.get(g.shop_id?.toString());f!==void 0&&J(rl({appLog:g,appLogPayload:M_(g.payload,g.log_type),storeName:f,prettyPrint:!1}))}),setTimeout(()=>{Bp({options:{variables:t,developerPlatformClient:n},pollOptions:{jwtToken:c||e.jwtToken,cursor:m??e.cursor,filters:e.filters},storeNameById:i,organizationId:o,consecutiveResubscribeFailures:d}).catch(g=>{throw g})},s)}async function vb(e){let{app:t,remoteApp:n,developerPlatformClient:i}=e,o=await jI(e),r=ol(t);if(r.length===0)throw new y("This app has no log sources. Learn more about app logs at https://shopify.dev/docs/api/shopify-cli/app/app-logs");if(e.sources){let p=e.sources.filter(m=>!r.includes(m));if(p.length)throw new y(`Invalid sources: ${p.join(", ")}. Valid sources are: ${r.join(", ")}`)}let a={shopIds:o.storeIds.map(Number),apiKey:n.apiKey},s=await an(i,a,e.organization.id),c={status:e.status,sources:e.sources},d={jwtToken:s,filters:c};e.format==="json"?(J(JSON.stringify({subscribedToStores:e.storeFqdns})),q(JSON.stringify({message:"Waiting for app logs..."})),await Bp({options:{variables:a,developerPlatformClient:i},pollOptions:d,storeNameById:o.storeNameById,organizationId:e.organization.id})):(q(`Waiting for app logs...
|
|
1159
|
-
`),await yb({options:{variables:a,developerPlatformClient:i},pollOptions:d,storeNameById:o.storeNameById,organizationId:e.organization.id}))}async function jI(e){let{app:t,remoteApp:n,developerPlatformClient:i,primaryStore:o,organization:r}=e,a=$(t.configPath);e.format==="text"&&BI(n.title,o.shopDomain,e.storeFqdns,a,r.businessName);let s=new Map;return s.set(o.shopId,o.shopDomain),e.storeFqdns&&e.storeFqdns.length>1&&await Promise.all(e.storeFqdns?.slice(1).map(async d=>{let p=await hs(r,d,i);s.set(p.shopId,d)})),{storeIds:Array.from(s.keys()),storeNameById:s}}function BI(e,t,n,i,o){let r=[];n&&n.length>0?n.forEach(s=>r.push(s)):r.push(t);let a=i?dt(i):void 0;oe({headline:i?`Using ${a} for default values:`:"Using these settings:",body:ws({appName:e,org:o,devStores:r,messages:[bs]})})}var cl=O(ke(),1);var zp,Wn=class extends M{async run(){let{flags:t}=await this.parse(zp);await Ut(t.path);let n=await B({directory:t.path,clientId:t["client-id"],forceRelink:t.reset,userProvidedConfigName:t.config}),i=await Lt({appContextResult:n,storeFqdn:t.store?.[0],forceReselectStore:t.reset}),o={...n,primaryStore:i,storeFqdns:t.store,sources:t.source,status:t.status,format:t.json?"json":"text"};return await vb(o),{app:n.app}}};zp=Wn;Wn.summary="Stream detailed logs for your Shopify app.";Wn.descriptionWithMarkdown="\n Opens a real-time stream of detailed app logs from the selected app and store.\n Use the `--source` argument to limit output to a particular log source, such as a specific Shopify Function handle. Use the `shopify app logs sources` command to view a list of sources.\n Use the `--status` argument to filter on status, either `success` or `failure`.\n ```\n shopify app logs --status=success --source=extension.discount-function\n ```\n ";Wn.description=zp.descriptionWithoutMarkdown();Wn.flags={...T,...I,...Fe,store:cl.Flags.string({char:"s",description:"Store URL. Must be an existing development or Shopify Plus sandbox store.",env:"SHOPIFY_FLAG_STORE",multiple:!0,parse:async e=>K(e)}),source:cl.Flags.string({description:"Filters output to the specified log source.",env:"SHOPIFY_FLAG_SOURCE",multiple:!0}),status:cl.Flags.string({description:"Filters output to the specified status (success or failure).",options:["success","failure"],env:"SHOPIFY_FLAG_STATUS"})};var kb=Wn;l();l();function wb(e){let t=ol(e),n=new Map;t.forEach(i=>{let o=i.split(".");if(o.length>=2){let r=o[0];n.has(r)||n.set(r,[]),n.set(r,[...n.get(r),i])}});for(let[i,o]of n)J(Ou(i,o.join(`
|
|
1160
|
-
`)))}var Wp,Hn=class extends M{async run(){let{flags:t}=await this.parse(Wp),{app:n}=await B({directory:t.path,clientId:t["client-id"],forceRelink:t.reset,userProvidedConfigName:t.config});return n.errors.isEmpty()?wb(n):process.exit(2),{app:n}}};Wp=Hn;Hn.summary="Print out a list of sources that may be used with the logs command.";Hn.descriptionWithMarkdown="The output source names can be used with the `--source` argument of `shopify app logs` to filter log output. Currently only function extensions are supported as sources.";Hn.description=Wp.descriptionWithoutMarkdown();Hn.flags={...T,...I};var _b=Hn;l();l();async function bb({app:e,remoteApp:t,organization:n,envFile:i}){await Oi(t,n.source);let o={SHOPIFY_API_KEY:t.apiKey,SHOPIFY_API_SECRET:t.apiSecretKeys[0]?.secret,SCOPES:vt(e.configuration)};if(await C(i)){let r=await P(i),a=ur(r,o);if(a===r)return w`No changes to ${b.path(i)}`;{await ie(i,a);let s=Nm(r??"",a);return w`Updated ${b.path(i)} to be:
|
|
1161
|
-
|
|
1162
|
-
${a}
|
|
1163
|
-
|
|
1164
|
-
Here's what changed:
|
|
1165
|
-
|
|
1166
|
-
${b.linesDiff(s)}
|
|
1167
|
-
`}}else{let r=ur(null,o);return await ie(i,r),w`Created ${b.path(i)}:
|
|
1168
|
-
|
|
1169
|
-
${r}
|
|
1170
|
-
`}}var Sb=O(ke(),1);var Hp,Gn=class extends M{async run(){let{flags:t}=await this.parse(Hp),{app:n,remoteApp:i,organization:o}=await B({directory:t.path,clientId:t["client-id"],forceRelink:t.reset,userProvidedConfigName:t.config}),r=k(n.directory,t["env-file"]??is(n.configPath));return J(await bb({app:n,remoteApp:i,organization:o,envFile:r})),{app:n}}};Hp=Gn;Gn.summary="Pull app and extensions environment variables.";Gn.descriptionWithMarkdown="Creates or updates an `.env` files that contains app and app extension environment variables.\n\n When an existing `.env` file is updated, changes to the variables are displayed in the terminal output. Existing variables and commented variables are preserved.";Gn.description=Hp.descriptionWithoutMarkdown();Gn.flags={...T,...I,"env-file":Sb.Flags.string({hidden:!1,description:"Specify an environment file to update if the update flag is set",env:"SHOPIFY_FLAG_ENV_FILE"})};var xb=Gn;l();l();async function Eb(e,t,n){return Gp(e,t,n,"text")}async function Gp(e,t,n,i){return await Oi(t,n.source),i==="json"?w`${b.json({SHOPIFY_API_KEY:t.apiKey,SHOPIFY_API_SECRET:t.apiSecretKeys[0]?.secret,SCOPES:vt(e.configuration)})}`:w`
|
|
1171
|
-
${b.green("SHOPIFY_API_KEY")}=${t.apiKey}
|
|
1172
|
-
${b.green("SHOPIFY_API_SECRET")}=${t.apiSecretKeys[0]?.secret??""}
|
|
1173
|
-
${b.green("SCOPES")}=${vt(e.configuration)}
|
|
1174
|
-
`}var Kp,Kn=class extends M{async run(){let{flags:t}=await this.parse(Kp),{app:n,remoteApp:i,organization:o}=await B({directory:t.path,clientId:t["client-id"],forceRelink:t.reset,userProvidedConfigName:t.config});return J(await Eb(n,i,o)),{app:n}}};Kp=Kn;Kn.summary="Display app and extensions environment variables.";Kn.descriptionWithMarkdown="Displays environment variables that can be used to deploy apps and app extensions.";Kn.description=Kp.descriptionWithoutMarkdown();Kn.flags={...T,...I};var Cb=Kn;l();l();l();l();var Nb={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"BulkOperationRunQuery"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"query"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"bulkOperationRunQuery"},arguments:[{kind:"Argument",name:{kind:"Name",value:"query"},value:{kind:"Variable",name:{kind:"Name",value:"query"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"bulkOperation"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"type"}},{kind:"Field",name:{kind:"Name",value:"completedAt"}},{kind:"Field",name:{kind:"Name",value:"createdAt"}},{kind:"Field",name:{kind:"Name",value:"errorCode"}},{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"objectCount"}},{kind:"Field",name:{kind:"Name",value:"partialDataUrl"}},{kind:"Field",name:{kind:"Name",value:"status"}},{kind:"Field",name:{kind:"Name",value:"url"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"userErrors"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"code"}},{kind:"Field",name:{kind:"Name",value:"field"}},{kind:"Field",name:{kind:"Name",value:"message"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};async function Ab(e){let{adminSession:t,query:n,version:i}=e;return(await Xe({query:Nb,session:t,variables:{query:n},...i&&{version:i}})).bulkOperationRunQuery}l();l();l();var Tb={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"StagedUploadsCreate"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"input"}},type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StagedUploadInput"}}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"stagedUploadsCreate"},arguments:[{kind:"Argument",name:{kind:"Name",value:"input"},value:{kind:"Variable",name:{kind:"Name",value:"input"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"stagedTargets"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"url"}},{kind:"Field",name:{kind:"Name",value:"resourceUrl"}},{kind:"Field",name:{kind:"Name",value:"parameters"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"value"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"userErrors"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"field"}},{kind:"Field",name:{kind:"Name",value:"message"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};async function Fb(e){let{adminSession:t,variablesJsonl:n}=e,i=Buffer.from(n??"","utf-8"),o="bulk-variables.jsonl",r=i.length,a=await zI(t,o,r),s=WI(a);return await HI(i,s.url,s.parameters,o),s.stagedUploadKey}async function zI(e,t,n){return Xe({query:Tb,session:e,variables:{input:[{filename:t,fileSize:n.toString(),httpMethod:"POST",mimeType:"text/jsonl",resource:"BULK_MUTATION_VARIABLES"}]}})}function WI(e){if(!e.stagedUploadsCreate)throw new y("No response received from stagedUploadsCreate mutation");if(e.stagedUploadsCreate.userErrors.length>0){let i=e.stagedUploadsCreate.userErrors.map(o=>o.message).join(", ");throw new y(`Failed to create staged upload: ${i}`)}let t=e.stagedUploadsCreate.stagedTargets?.[0];if(!t)throw new y("No staged upload target returned from Shopify");if(!t.url||!t.resourceUrl)throw new y("Invalid staged upload target: missing required URLs");let n=t.parameters.find(i=>i.name==="key")?.value;if(!n)throw new y("No key parameter found in staged upload target");return{url:t.url,resourceUrl:t.resourceUrl,parameters:t.parameters,stagedUploadKey:n}}async function HI(e,t,n,i){let o=new FormData;for(let a of n)o.append(a.name,a.value);o.append("file",new Blob([new Uint8Array(e)],{type:"text/jsonl"}),i);let r=await Le({title:w`Uploading bulk operation variables`,task:async()=>Ae(t,{method:"POST",body:o},"slow-request"),renderOptions:{stdout:process.stderr}});if(!r.ok){let a=await r.text();throw new y(`Failed to upload file to staged URL: ${r.statusText}
|
|
1175
|
-
${a}`)}}l();var Pb={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"BulkOperationRunMutation"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"mutation"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"stagedUploadPath"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"clientIdentifier"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"bulkOperationRunMutation"},arguments:[{kind:"Argument",name:{kind:"Name",value:"mutation"},value:{kind:"Variable",name:{kind:"Name",value:"mutation"}}},{kind:"Argument",name:{kind:"Name",value:"stagedUploadPath"},value:{kind:"Variable",name:{kind:"Name",value:"stagedUploadPath"}}},{kind:"Argument",name:{kind:"Name",value:"clientIdentifier"},value:{kind:"Variable",name:{kind:"Name",value:"clientIdentifier"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"bulkOperation"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"type"}},{kind:"Field",name:{kind:"Name",value:"completedAt"}},{kind:"Field",name:{kind:"Name",value:"createdAt"}},{kind:"Field",name:{kind:"Name",value:"errorCode"}},{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"objectCount"}},{kind:"Field",name:{kind:"Name",value:"partialDataUrl"}},{kind:"Field",name:{kind:"Name",value:"status"}},{kind:"Field",name:{kind:"Name",value:"url"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"userErrors"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"code"}},{kind:"Field",name:{kind:"Name",value:"field"}},{kind:"Field",name:{kind:"Name",value:"message"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};async function Ib(e){let{adminSession:t,query:n,variablesJsonl:i,version:o}=e,r=await Fb({adminSession:t,variablesJsonl:i});return(await Xe({query:Pb,session:t,variables:{mutation:n,stagedUploadPath:r},...o&&{version:o}})).bulkOperationRunMutation}l();var GI=["COMPLETED","FAILED","CANCELED","EXPIRED"],Db=1,KI=5,Rb=10,YI=3e3,QI=300;async function Ub(e,t){return Le({title:w`Starting bulk operation`,task:async()=>{let n=Date.now(),i=Mb({adminSession:e,operationId:t,pollIntervalSeconds:QI/1e3,useAdaptivePolling:!1}),o;do{let{value:r,done:a}=await i.next();if(o=r,a)return o}while(Date.now()-n<YI);return o},renderOptions:{stdout:process.stderr}})}async function Ob(e,t,n,i){return Le({title:w`Polling bulk operation`,task:async o=>{let r=Mb({adminSession:e,operationId:t,pollIntervalSeconds:KI,initialPollIntervalSeconds:Db,initialPollCount:Rb,useAdaptivePolling:!0,abortSignal:n});for(;;){let{value:a,done:s}=await r.next();if(s)return a;o(qi(a))}},onAbort:i,renderOptions:{stdout:process.stderr}})}async function*Mb({adminSession:e,operationId:t,pollIntervalSeconds:n,useAdaptivePolling:i=!1,initialPollIntervalSeconds:o=Db,initialPollCount:r=Rb,abortSignal:a}){let s=0;for(;;){let c=await JI(e,t);if(!c.bulkOperation)throw new Error("bulk operation not found");let d=c.bulkOperation;if(GI.includes(d.status)||a?.aborted)return d;yield d,s++;let p=n;i&&s<=r&&(p=o),a?await Promise.race([Nt(p),new Promise(m=>a.addEventListener("abort",m))]):await Nt(p)}}async function JI(e,t){return Xe({query:Us,session:e,variables:{id:t},version:Vi})}l();async function Lb(e){let t=await Ae(e);if(!t.ok)throw new y(`Failed to download bulk operation results: ${t.statusText}`);return t.text()}async function XI(e,t){if(e)return e.join(`
|
|
1176
|
-
`);if(t){if(!await C(t))throw new y(w`Variable file not found at ${b.path(t)}. Please check the path and try again.`);return P(t,{encoding:"utf8"})}else return}async function Vb(e){let{organization:t,remoteApp:n,store:i,query:o,variables:r,variableFile:a,outputFile:s,watch:c=!1,version:d}=e,{adminSession:p,version:m}=await Le({title:w`Authenticating`,task:async()=>{let v=await Bo(n,i.shopDomain),_=await Li({adminSession:v,userSpecifiedVersion:d,minimumDefaultVersion:Vi});return{adminSession:v,version:_}},renderOptions:{stdout:process.stderr}}),h=await XI(r,a);eD(o,h),Ds(o,i),oe({headline:"Starting bulk operation.",body:[{list:{items:$i({organization:t,remoteApp:n,storeFqdn:i.shopDomain,version:m})}}]});let g=Mr(o)?await Ib({adminSession:p,query:o,variablesJsonl:h,version:m}):await Ab({adminSession:p,query:o,version:m});if(g?.userErrors?.length){Te({headline:"Error creating bulk operation.",body:{list:{items:g.userErrors.map(v=>v.field?`${v.field.join(".")}: ${v.message}`:v.message)}}});return}let f=g?.bulkOperation;if(f)if(c){let v=new hn,_=await Ob(p,f.id,v.signal,()=>v.abort());v.signal.aborted?oe({headline:`Bulk operation ${_.id} is still running in the background.`,body:pl(_.id)}):await $b(_,s)}else{let v=await Ub(p,f.id);["FAILED","CANCELED","EXPIRED"].includes(v.status)?await $b(v,s):j({headline:"Bulk operation is running.",body:pl(v.id),customSections:[{body:[{list:{items:[w`ID: ${b.cyan(v.id)}`.value]}}]}]})}else throw He({headline:"Bulk operation not created successfully.",body:"This is an unexpected error. Please try again later."}),new L("Bulk operation response returned null with no error message.")}async function $b(e,t){let n=qi(e).value,o=[{body:[{list:{items:[w`ID: ${b.cyan(e.id)}`.value,w`Status: ${b.yellow(e.status)}`.value,w`Created at: ${b.gray(String(e.createdAt))}`.value,...e.completedAt?[w`Completed at: ${b.gray(String(e.completedAt))}`.value]:[]]}}]}];switch(e.status){case"CREATED":j({headline:"Bulk operation started.",body:pl(e.id),customSections:o});break;case"RUNNING":j({headline:"Bulk operation is running.",body:pl(e.id),customSections:o});break;case"COMPLETED":if(e.url){let r=await Lb(e.url),a=ZI(r);t?await ie(t,r):J(r),a?He({headline:"Bulk operation completed with errors.",body:t?`Results written to ${t}. Check file for error details.`:"Check results for error details.",customSections:o}):j({headline:n,body:t?[`Results written to ${t}`]:void 0,customSections:o})}else j({headline:n,customSections:o});break;case"CANCELED":case"CANCELING":case"EXPIRED":case"FAILED":Te({headline:n,customSections:o});break}}function ZI(e){return e.trim().split(`
|
|
1177
|
-
`).some(n=>{let i=JSON.parse(n);if(!i.data)return!1;let o=Object.values(i.data)[0];return o?.userErrors!==void 0&&o.userErrors.length>0})}function eD(e,t){if(Mr(e)&&!t)throw new y(w`Bulk mutations require variables. Provide a JSONL file with ${b.yellow("--variable-file")} or individual JSON objects with ${b.yellow("--variables")}.`);if(!Mr(e)&&t)throw new y(w`The ${b.yellow("--variables")} and ${b.yellow("--variable-file")} flags can only be used with mutations, not queries.`)}function pl(e){return[`Monitor its progress with:
|
|
1178
|
-
`,{command:`shopify app bulk status --id=${$r(e)}`}]}var Yp,Yn=class extends M{async run(){let{flags:t}=await this.parse(Yp),{query:n,appContextResult:i,store:o}=await Rs(t);return await Vb({organization:i.organization,remoteApp:i.remoteApp,store:o,query:n,variables:t.variables,variableFile:t["variable-file"],watch:t.watch??!1,outputFile:t["output-file"],...t.version&&{version:t.version}}),{app:i.app}}};Yp=Yn;Yn.summary="Execute bulk operations.";Yn.descriptionWithMarkdown=`Executes an Admin API GraphQL query or mutation on the specified store, as a bulk operation. Mutations are only allowed on dev stores.
|
|
1179
|
-
|
|
1180
|
-
Bulk operations allow you to process large amounts of data asynchronously. Learn more about [bulk query operations](https://shopify.dev/docs/api/usage/bulk-operations/queries) and [bulk mutation operations](https://shopify.dev/docs/api/usage/bulk-operations/imports).
|
|
1181
|
-
|
|
1182
|
-
Use [\`bulk status\`](https://shopify.dev/docs/api/shopify-cli/app/app-bulk-status) to check the status of your bulk operations.`;Yn.description=Yp.descriptionWithoutMarkdown();Yn.flags={...T,...I,...Cf};var qb=Yn;l();l();var jb=O(Al(),1);async function tD(e,t){if(e)try{return JSON.parse(e)}catch(n){let i=n instanceof Error?n.message:"Unknown error";throw new y(w`Invalid JSON in ${b.yellow("--variables")} flag: ${i}`,"Please provide valid JSON format.")}else if(t){if(!await C(t))throw new y(w`Variable file not found at ${b.path(t)}. Please check the path and try again.`);let n=await P(t,{encoding:"utf8"});try{return JSON.parse(n)}catch(i){let o=i instanceof Error?i.message:"Unknown error";throw new y(w`Invalid JSON in variable file ${b.path(t)}: ${o}`,"Please provide valid JSON format.")}}}async function Bb(e){let{remoteApp:t,store:n,query:i,variables:o,variableFile:r,version:a,outputFile:s}=e,{adminSession:c,version:d}=await Le({title:w`Authenticating`,task:async()=>{let m=await Bo(t,n.shopDomain),h=await Li({adminSession:m,userSpecifiedVersion:a});return{adminSession:m,version:h}},renderOptions:{stdout:process.stderr}}),p=await tD(o,r);Is(i),Ds(i,n);try{let m=await Le({title:w`Executing GraphQL operation`,task:async()=>Xe({query:(0,jb.parse)(i),session:c,variables:p,version:d,responseOptions:{handleErrors:!1}}),renderOptions:{stdout:process.stderr}}),h=JSON.stringify(m,null,2);s?(await ie(s,h),j({headline:"Operation succeeded.",body:`Results written to ${s}`})):(j({headline:"Operation succeeded."}),J(h))}catch(m){if(m instanceof na){let h={errors:m.response.errors},g=JSON.stringify(h,null,2);Te({headline:"GraphQL operation failed.",body:g});return}throw m}}var Qp,Qn=class extends M{async run(){let{flags:t}=await this.parse(Qp),{query:n,appContextResult:i,store:o}=await Rs(t);return await Bb({organization:i.organization,remoteApp:i.remoteApp,store:o,query:n,variables:t.variables,variableFile:t["variable-file"],outputFile:t["output-file"],...t.version&&{version:t.version}}),{app:i.app}}};Qp=Qn;Qn.summary="Execute GraphQL queries and mutations.";Qn.descriptionWithMarkdown="Executes an Admin API GraphQL query or mutation on the specified store. Mutations are only allowed on dev stores.\n\n For operations that process large amounts of data, use [`bulk execute`](https://shopify.dev/docs/api/shopify-cli/app/app-bulk-execute) instead.";Qn.description=Qp.descriptionWithoutMarkdown();Qn.flags={...T,...I,...Nf};var zb=Qn;l();l();l();async function dl(e){let{extension:t,stdout:n,developerPlatformClient:i,app:o,orgId:r}=e,a=o.configuration.client_id,{api_version:s,type:c,targeting:d}=t.configuration,m=await(!!d?.length?nD({localIdentifier:t.localIdentifier,developerPlatformClient:i,apiKey:a,target:d[0].target,version:s,orgId:r}):iD({localIdentifier:t.localIdentifier,developerPlatformClient:i,apiKey:a,type:c,version:s,orgId:r})),h=kh(m,s);if(n)J(h);else{let g=k(t.directory,"schema.graphql");await ie(g,h),q(`GraphQL Schema for ${t.localIdentifier} written to ${g}`)}}async function nD({localIdentifier:e,developerPlatformClient:t,apiKey:n,target:i,version:o,orgId:r}){let a={handle:i,version:o},s=await t.targetSchemaDefinition(a,n,r);if(!s)throw new y(w`A schema could not be generated for ${e}`,w`Check that the Function targets and version are valid.`);return s}async function iD({localIdentifier:e,developerPlatformClient:t,apiKey:n,version:i,type:o,orgId:r}){let a={version:i,type:o},s=await t.apiSchemaDefinition(a,n,r);if(!s)throw new y(w`A schema could not be generated for ${e}`,w`Check that the Function API type and version are valid.`);return s}var Wb=O(ke(),1);var xt={path:Wb.Flags.string({hidden:!1,description:"The path to your function directory.",parse:async e=>he(e),default:async()=>to(),noCacheDefault:!0,env:"SHOPIFY_FLAG_PATH"})};async function Et(e,t){let n=e.allExtensions.filter(o=>o.isFunctionExtension),i=n.find(o=>o.directory===t);if(i)return i;if(n.length===1&&n[0])return n[0];if(Fu())return await Ge({message:"Which function?",choices:n.map(r=>({label:r.handle,value:r}))});throw new y("Run this command from a function directory or use `--path` to specify a function directory.")}async function ul(e,t,n,i,o){let r=k(e.directory,"schema.graphql");if(await C(r))return r;let{app:a,developerPlatformClient:s,organization:c}=await B({directory:t,clientId:n,forceRelink:i,userProvidedConfigName:o});return await dl({app:a,developerPlatformClient:s,extension:e,stdout:!1,orgId:c.id}),await C(r)?r:void 0}var Jp,Jn=class extends tt{async run(){let{flags:t}=await this.parse(Jp),{app:n}=await bt({directory:t.path,userProvidedConfigName:t.config}),i=await Et(n,t.path);return await Ha(i,{app:n,stdout:process.stdout,stderr:process.stderr,useTasks:!0,environment:"production"}),j({headline:"Function built successfully."}),{app:n}}};Jp=Jn;Jn.summary="Compile a function to wasm.";Jn.descriptionWithMarkdown="Compiles the function in your current directory to WebAssembly (Wasm) for testing purposes.";Jn.description=Jp.descriptionWithoutMarkdown();Jn.flags={...T,...I,...xt};var Hb=Jn;l();l();l();l();l();l();async function oD(e){if(e.features.includes("function")&&e.isJavaScript){let t=await La(e);return yr(t.functionRunner)}return yr()}function rD(e){return e.configuration.build?.path?k(e.directory,e.configuration.build.path):e.outputPath}async function Jo(e){let t=e.functionExtension,n=await oD(t);await At(n);let i=[];e.inputPath&&i.push("--input",e.inputPath),e.export&&i.push("--export",e.export),e.json&&i.push("--json"),e.schemaPath&&e.queryPath&&(i.push("--schema-path",e.schemaPath),i.push("--query-path",e.queryPath));let o=rD(t);return Ke(n.path,["-f",o,...i],{cwd:e.functionExtension.directory,stdin:e.stdin,stdout:e.stdout??"inherit",stderr:e.stderr??"inherit",input:e.input})}var Ji=O(ot(),1);import{Writable as Gb}from"stream";function Kb({selectedRun:e,abortController:t,app:n,extension:i,appWatcher:o}){let r={type:"functionRun",input:e.payload.input,output:e.payload.output,logs:e.payload.logs,name:e.source,size:0,memory_usage:0,instructions:e.payload.fuelConsumed},[a,s]=(0,Ji.useState)([]),[c,d]=(0,Ji.useState)([r,r]),[p,m]=(0,Ji.useState)(void 0),{input:h,export:g}=e.payload,[f,v]=(0,Ji.useState)(`Watching for changes to ${e.source}...`);return(0,Ji.useEffect)(()=>{let _=new hn;t.signal.addEventListener("abort",()=>{_.abort()});let x=async()=>{let F=await aD(i,JSON.stringify(h),g);d(W=>[F,W[0]]),v(`Watching for changes to ${e.source}...`),s(W=>[...W,F])},E=async()=>{v("Replaying log with local function..."),await x()},A=async()=>{o.onEvent(async W=>{let ee=W.extensionEvents.find(ne=>ne.extension.handle===i.handle);if(!(!ee||ee.type!==ye.Updated)){if(ee.buildResult?.status==="error"){m(`Error while reloading and building extension: ${ee.buildResult?.error}`);return}m(void 0),v("Re-running with latest changes..."),await x()}});let F=new Gb({write(W,ee,ne){s(be=>[...be,{type:"systemMessage",message:W.toString()}]),ne()}});await o.start({stdout:F,stderr:F,signal:_.signal},!1)};return E().then(()=>{A()}),()=>{_.abort()}},[h,g,n,i]),wn(t.signal,async()=>{setTimeout(()=>{ft()||_u(process.pid,"SIGINT",!1,()=>{process.exit(0)})},2e3)}),{logs:a,statusMessage:f,recentFunctionRuns:c,error:p}}async function aD(e,t,n){let i="",o=new Gb({write(a,s,c){i+=a,c()}});return await Jo({functionExtension:e,input:t,export:n,stdout:o,json:!0}),{...JSON.parse(i),type:"functionRun"}}var Y=O(ot(),1);var Yb=({selectedRun:e,abortController:t,app:n,extension:i})=>{let{isAborted:o}=wn(t.signal),{isRawModeSupported:r}=mn(),a=new $n(n),{logs:s,statusMessage:c,recentFunctionRuns:d,error:p}=Kb({selectedRun:e,abortController:t,app:n,extension:i,appWatcher:a});return fn((m,h)=>{lo(m,h,()=>t.abort()),m==="q"&&t.abort()},{isActive:!!r}),Y.default.createElement(Y.default.Fragment,null,Y.default.createElement(Vd,{items:s},(m,h)=>Y.default.createElement(V,{key:`replayOutputScrollerLog${h}`,flexDirection:"column"},Y.default.createElement(uD,{log:m}))),o?null:Y.default.createElement(V,{marginY:1,paddingTop:1,flexDirection:"column",flexGrow:1,borderStyle:"single",borderBottom:!1,borderLeft:!1,borderRight:!1,borderTop:!0},r?Y.default.createElement(V,{flexDirection:"column"},Y.default.createElement(V,{flexDirection:"row"},Y.default.createElement(N,null,Me.pointerSmall," ",c)),Y.default.createElement(dD,{recentFunctionRuns:d}),Y.default.createElement(N,null,Me.pointerSmall," Press ",Y.default.createElement(N,{bold:!0},"q")," ",Me.lineVertical," quit")):null,p?Y.default.createElement(N,{color:"red"},p):null))};function ml({title:e,backgroundColor:t}){let n=Math.max(Math.round((28-e.length)/2),0),i=" ".repeat(n);return Y.default.createElement(N,{backgroundColor:t,color:"black"},`
|
|
1183
|
-
|
|
1184
|
-
`,i,e,i,`
|
|
1185
|
-
`)}function sD({input:e}){return Y.default.createElement(V,{flexDirection:"column"},Y.default.createElement(ml,{title:"Input",backgroundColor:"yellow"}),Y.default.createElement(N,null,St(e)))}function lD({logs:e}){return Y.default.createElement(V,{flexDirection:"column"},Y.default.createElement(ml,{title:"Logs",backgroundColor:"blueBright"}),Y.default.createElement(N,null,e))}function cD({output:e}){return Y.default.createElement(V,{flexDirection:"column"},Y.default.createElement(ml,{title:"Output",backgroundColor:"greenBright"}),Y.default.createElement(N,null,St(e)))}function pD({functionRun:e}){return Y.default.createElement(V,{flexDirection:"column"},Y.default.createElement(ml,{title:"Benchmark Results",backgroundColor:"green"}),Y.default.createElement(N,null,"Name: ",e.name),Y.default.createElement(N,null,"Linear Memory Usage: ",e.memory_usage,"KB"),Y.default.createElement(N,null,"Instructions: ",e.instructions/1e3,"K"),Y.default.createElement(N,null,"Size: ",e.size,"KB"))}function dD({recentFunctionRuns:e}){let t=e[0].instructions-e[1].instructions;return Y.default.createElement(V,{flexDirection:"column"},Y.default.createElement(N,null,Me.pointerSmall," Instruction count change: ",t>0?"+":"",t))}function uD({log:e}){switch(e.type){case"functionRun":return Y.default.createElement(V,{flexDirection:"column"},Y.default.createElement(sD,{input:e.input}),Y.default.createElement(lD,{logs:e.logs}),Y.default.createElement(cD,{output:e.output}),Y.default.createElement(pD,{functionRun:e}),Y.default.createElement(N,null,"\xA0"));case"systemMessage":return Y.default.createElement(N,null,e.message);default:return null}}var Qb=O(ot(),1);async function Jb({selectedRun:e,abortController:t,app:n,extension:i}){return ki(Qb.default.createElement(Yb,{selectedRun:e,abortController:t,app:n,extension:i}),{exitOnCtrlC:!1})}l();async function Xb(e){if(e.length===0)return;let t=o=>({label:`${o.logTimestamp} (${o.status}) - ${o.identifier}`,value:o}),n=e.map(t);return await Ge({message:"Which function run would you like to replay locally?",choices:n})}import{existsSync as mD,readdirSync as fD}from"fs";var Xp=100;async function Zb(e){let{watch:t,extension:n,app:i}=e,o=new hn;try{let r=i.getLogsDir(),a=e.log?await hD(r,n.handle,e.log):await yD(r,n.handle),{input:s,export:c}=a.payload;t?await Jb({selectedRun:a,abortController:o,app:i,extension:n}):await Jo({functionExtension:n,json:e.json,input:JSON.stringify(s),export:c})}catch(r){throw o.abort(),r}}async function hD(e,t,n){let i=await gD(e,t,n);if(i===void 0)throw new y(`No log found for '${n}'.
|
|
1186
|
-
Searched ${e} for function ${t}.`);let o=await P(i);return JSON.parse(o)}function eS(e){let t=e.split(/[_.]/);if(!(t.length<6))return{namespace:t[3],functionHandle:t[4],identifier:t[5]}}async function gD(e,t,n){let i=tS(e).find(o=>{let r=eS(o);return r?.namespace==="extensions"&&r?.functionHandle===t&&r?.identifier===n});return i?k(e,i):void 0}async function yD(e,t){let n=await vD(e,t),i=await Xb(n);if(i===void 0)throw new y(`No logs found in ${e}`);return i}async function vD(e,t){let n=tS(e).filter(o=>{let r=eS(o);return r?.namespace==="extensions"&&r?.functionHandle===t}).reverse(),i=[];for(let o=0;o<n.length&&i.length<Xp;o+=Xp){let a=n.slice(o,o+Xp).map(d=>k(e,d)),c=(await Promise.all(a.map(async d=>{let p=await P(d);return{...JSON.parse(p),identifier:kD(d)}}))).filter(d=>d.payload.input!=null);i=i.concat(c)}return i}function kD(e){return e.split("_").pop().substring(0,6)}function tS(e){return mD(e)?fD(e):[]}var Zp=O(ke(),1),ed,Xn=class extends M{async run(){let{flags:t}=await this.parse(ed),{app:n}=await B({directory:t.path,clientId:t["client-id"],forceRelink:t.reset,userProvidedConfigName:t.config}),i=await Et(n,t.path);return await Zb({app:n,extension:i,path:t.path,log:t.log,json:t.json,watch:t.watch}),{app:n}}};ed=Xn;Xn.summary="Replays a function run from an app log.";Xn.descriptionWithMarkdown="Runs the function from your current directory for [testing purposes](https://shopify.dev/docs/apps/functions/testing-and-debugging). To learn how you can monitor and debug functions when errors occur, refer to [Shopify Functions error handling](https://shopify.dev/docs/api/functions/errors).";Xn.description=ed.descriptionWithoutMarkdown();Xn.flags={...T,...I,...xt,...Fe,log:Zp.Flags.string({char:"l",description:"Specifies a log identifier to replay instead of selecting from a list. The identifier is provided in the output of `shopify app dev` and is the suffix of the log file name.",env:"SHOPIFY_FLAG_LOG"}),watch:Zp.Flags.boolean({char:"w",hidden:!1,allowNo:!0,default:!0,description:"Re-run the function when the source code changes.",env:"SHOPIFY_FLAG_WATCH"})};var nS=Xn;l();var nd=O(ke(),1);var id,td="_start",Zn=class extends tt{async run(){let{flags:t}=await this.parse(id),n=td,{app:i}=await bt({directory:t.path,userProvidedConfigName:t.config}),o=await Et(i,t.path);if(t.export!==void 0)S(`Using export ${t.export} from the --export flag.`),n=t.export;else if(o.configuration.targeting!==void 0&&o.configuration.targeting.length>0){let c=o.configuration.targeting;if(c.length>1&&wi({})){let d=c.map(p=>({label:p.target,value:p.export||td}));n=await Ge({message:"Which target would you like to execute?",choices:d})}else n=c?.[0]?.export||td,S(`Using export '${n}'. Use the --export flag or an interactive terminal to select a different export.`)}else S(`No targeting information found. Using the default export '${n}'. Use the --export flag or an interactive terminal to select a different export.`);let r=o?.configuration.targeting?.[0]?.input_query,a=r&&`${o?.directory}/${r}`,s=await ul(o,t.path,t["client-id"],t.reset,t.config);return await Jo({functionExtension:o,json:t.json,inputPath:t.input,export:n,stdin:"inherit",schemaPath:s,queryPath:a}),{app:i}}};id=Zn;Zn.summary="Run a function locally for testing.";Zn.descriptionWithMarkdown="Runs the function from your current directory for [testing purposes](https://shopify.dev/docs/apps/functions/testing-and-debugging). To learn how you can monitor and debug functions when errors occur, refer to [Shopify Functions error handling](https://shopify.dev/docs/api/functions/errors).";Zn.description=id.descriptionWithoutMarkdown();Zn.flags={...T,...I,...xt,...Fe,input:nd.Flags.string({char:"i",description:"The input JSON to pass to the function. If omitted, standard input is used.",env:"SHOPIFY_FLAG_INPUT"}),export:nd.Flags.string({char:"e",hidden:!1,description:"Name of the WebAssembly export to invoke.",env:"SHOPIFY_FLAG_EXPORT"})};var iS=Zn;l();var oS=O(ke(),1);var od,ei=class extends M{async run(){let{flags:t}=await this.parse(od),{app:n,developerPlatformClient:i,organization:o}=await B({directory:t.path,clientId:t["client-id"],forceRelink:t.reset,userProvidedConfigName:t.config}),r=await Et(n,t.path);return await dl({app:n,extension:r,stdout:t.stdout,developerPlatformClient:i,orgId:o.id}),{app:n}}};od=ei;ei.summary="Fetch the latest GraphQL schema for a function.";ei.descriptionWithMarkdown="Generates the latest [GraphQL schema](https://shopify.dev/docs/apps/functions/input-output#graphql-schema) for a function in your app. Run this command from the function directory.\n\n This command uses the API type and version of your function, as defined in your extension TOML file, to generate the latest GraphQL schema. The schema is written to the `schema.graphql` file.";ei.description=od.descriptionWithoutMarkdown();ei.flags={...T,...I,...xt,stdout:oS.Flags.boolean({description:"Output the schema to stdout instead of writing to a file.",required:!1,default:!1,env:"SHOPIFY_FLAG_STDOUT"})};var rS=ei;l();var rd,ti=class extends tt{async run(){let{flags:t}=await this.parse(rd),{app:n}=await bt({directory:t.path,userProvidedConfigName:t.config}),i=await Et(n,t.path);return await en(i,{stdout:process.stdout,stderr:process.stderr,app:n}),j({headline:"GraphQL types generated successfully."}),{app:n}}};rd=ti;ti.summary="Generate GraphQL types for a function.";ti.descriptionWithMarkdown="Creates GraphQL types based on your [input query](https://shopify.dev/docs/apps/functions/input-output#input) for a function. Supports JavaScript functions out of the box, or any language via the `build.typegen_command` configuration.";ti.description=rd.descriptionWithoutMarkdown();ti.flags={...T,...I,...xt};var aS=ti;l();l();l();async function sS(e,t,n){let{templates:i,groupOrder:o}=await e.templateSpecifications(t);return{templates:i.filter(a=>n.includes(a.identifier)||n.includes(a.type)),groupOrder:o}}l();function ad(e){switch(e){case"vanilla-js":case"preact":case"react":case"typescript":case"typescript-react":return"javascript";case"rust":case"wasm":return e;case void 0:case"liquid":case"config-only":return}}async function lS(e){let t=e.extensionChoices.name,n=e.extensionChoices.flavor,i=e.extensionTemplate.supportedFlavors.find(s=>s.value===n),o=await nb({app:e.app,name:t}),r=e.cloneUrl??e.extensionTemplate.url,a={directory:o,url:r,app:e.app,project:e.project,type:e.extensionTemplate.type,name:t,extensionFlavor:i,onGetTemplateRepository:e.onGetTemplateRepository??(async(s,c)=>{await _a({repoUrl:s,destination:c,shallow:!0})})};return await wD(a),{directory:eo(o),extensionTemplate:e.extensionTemplate}}async function wD(e){try{switch(e.type){case"theme":await _D(e);break;case"function":await bD(e);break;default:await SD(e);break}let t=k(e.directory,me.lockFile);await io(t)}catch(t){throw await io(e.directory),t}}async function _D({directory:e,url:t,type:n,name:i,extensionFlavor:o,onGetTemplateRepository:r}){return It(async a=>{let s=await sd(t,o,a,r);await yo(s,e,{name:i,type:n,uid:yn(te(i))})})}async function bD({directory:e,url:t,app:n,project:i,name:o,extensionFlavor:r,onGetTemplateRepository:a}){let s=ad(r?.value),c=[];c.push({title:"Generating function extension",task:async()=>{if(await It(async d=>{let p=await sd(t,r,d,a);await yo(p,e,{name:o,handle:te(o),flavor:r?.value,uid:yn(te(o))})}),s==="javascript"){let d=cS(r?.value??"rust");await pS(e,d,"!(*.graphql)")}}}),s==="javascript"&&c.push({title:"Installing additional dependencies",task:async()=>{i.usesWorkspaces&&await ar({packageManager:i.packageManager,directory:i.directory});let d=xD(s);await Dl(d,{packageManager:i.packageManager,type:"prod",directory:i.usesWorkspaces?e:i.directory})}}),s==="javascript"&&c.push({title:"Building GraphQL types",task:async()=>{await en({directory:e,isJavaScript:!0},{stdout:process.stdout,stderr:process.stderr,app:n})}}),await xe(c)}async function SD({directory:e,url:t,app:n,project:i,name:o,extensionFlavor:r,onGetTemplateRepository:a}){let s=ad(r?.value),c=[{title:"Generating extension",task:async()=>{let d=cS(r?.value??"vanilla-js");await It(async p=>{let m=await sd(t,r,p,a);await yo(m,e,{srcFileExtension:d,name:o,handle:te(o),flavor:r?.value??"",uid:yn(te(o))})}),s==="javascript"&&await pS(e,d)}},{title:"Installing dependencies",task:async()=>{let d=i.packageManager;if(i.usesWorkspaces)ad(r?.value)==="javascript"&&await ar({packageManager:d,directory:i.directory});else{await ED(i.directory,r?.value);let p=k(e,"package.json"),m=await CD(p);await Dl(m,{packageManager:d,type:"prod",directory:i.directory}),await io(p)}}}];c.push({title:"Update shared type definition",task:async()=>{await on(n)}}),await xe(c)}function cS(e){return{"vanilla-js":"js",preact:"jsx",react:"jsx",typescript:"ts","typescript-react":"tsx",rust:"rs",wasm:"wasm",liquid:"liquid","config-only":""}[e]??"js"}function xD(e){let t=[];return e==="javascript"&&t.push({name:"@shopify/shopify_function",version:`~${dc}.0.0`}),t}async function pS(e,t,n="*"){let i=await re(k(e,"src",n)),o=[];for(let r of i)o.push(dn(r,`${r}.${t}`));await Promise.all(o)}async function ED(e,t){t==="typescript-react"&&await du(e,{"@types/react":Mf.reactTypes})}async function CD(e){if(!await C(e))return[];let t=await ca(e);return Object.entries(t?.dependencies??{}).map(([n,i])=>({name:n,version:i}))}async function sd(e,t,n,i){let o=k(n,"download");return await ae(o),await i(e,o),tb(t,o)}l();function ND(e,t=[]){let n=[...e.map(o=>({label:o.name,value:o.identifier,group:o.group||"Other",sortPriority:o.sortPriority??Number.MAX_SAFE_INTEGER})),...t.map(o=>({label:`${o.name} (limit reached)`,value:o.identifier,group:o.group||"Other",disabled:!0,sortPriority:o.sortPriority??Number.MAX_SAFE_INTEGER}))],i=(o,r)=>o.sortPriority===r.sortPriority?o.label.localeCompare(r.label):o.sortPriority-r.sortPriority;return n.sort(i)}var AD=async e=>{let t=e.extensionTemplates,n=e.templateType,i=e.extensionFlavor;if(!n){if(i&&(t=t.filter(c=>c.supportedFlavors.map(d=>d.value).includes(i))),t.length===0)throw new y("You have reached the limit for the number of extensions you can create.");n=await Ge({message:"Type of extension?",choices:ND(t,e.unavailableExtensions),groupOrder:e.groupOrder})}let o=t.find(c=>c.identifier===n),r=e.name||await dS(e.directory,o.defaultName),a=e.extensionFlavor??await TD(o);return{extensionTemplate:o,extensionContent:{name:r,flavor:a}}};async function dS(e,t,n=1){let i=t.includes(" ")?" ":"-",o=n<=1?t:`${t}${i}${n}`,r=k(e,te(o));return Se(r)?dS(e,t,n+1):Gt({message:"Name your extension:",defaultValue:o})}async function TD(e){if(e.supportedFlavors.length!==0)return e.supportedFlavors.length===1&&e.supportedFlavors[0]?e.supportedFlavors[0].value:Je({message:"What would you like to work in?",choices:e.supportedFlavors.map(t=>({label:t.name,value:t.value})),defaultValue:"react"})}var uS=AD;async function FD(e){let{app:t,developerPlatformClient:n,remoteApp:i,specifications:o,template:r}=e,a=o.map(g=>g.identifier),{templates:s,groupOrder:c}=await sS(n,i,a),d=await PD(s,c,o,t,e),p=await uS(d);await DD(p,r);let m=RD(p,t,e,n),h=await lS(m);UD(h,e.project.packageManager)}async function PD(e,t,n,i,o){let r=await LD(o.template,i,e,n);OD(r,o.flavor);let{validTemplates:a,templatesOverlimit:s}=ID(e,n,i);return{templateType:r?.identifier,name:o.name,extensionFlavor:o.flavor,directory:k(o.directory,"extensions"),app:i,extensionTemplates:a??[],unavailableExtensions:s??[],reset:o.reset,groupOrder:t}}function ID(e,t,n){return Yt(e,o=>!mS(n,t,o)?"validTemplates":"templatesOverlimit")}function mS(e,t,n){let i=n.type,o=t.find(a=>a.identifier===i||a.externalIdentifier===i);return e.extensionsForType({identifier:i,externalIdentifier:i}).length>=(o?.registrationLimit??1)}async function DD(e,t){let{extensionContent:n}=e;return Q.addPublicMetadata(()=>({cmd_scaffold_template_flavor:n.flavor,cmd_scaffold_type:e.extensionTemplate.identifier,cmd_scaffold_used_prompts_for_type:!t}))}function RD(e,t,n,i){return{app:t,project:n.project,cloneUrl:n.cloneUrl,extensionChoices:e.extensionContent,extensionTemplate:e.extensionTemplate,developerPlatformClient:i}}function UD(e,t){let n=MD(e.extensionTemplate,e.directory,t);j(n)}function OD(e,t){if(!t||!e)return;let n=e.supportedFlavors.map(i=>i.value);if(!n.includes(t))throw new y("Invalid template for extension type",`Expected template to be one of the following: ${n.join(", ")}.`)}function MD(e,t,n){let i={headline:["Your extension was created in",{filePath:t},{char:"."}],nextSteps:[],reference:[]};return e.type!=="function"&&i.nextSteps.push(["To preview this extension along with the rest of the project, run",{command:Be(n,"shopify app dev")}]),e.supportLinks[0]&&i.reference.push(["For more details, see the",{link:{label:"docs",url:e.supportLinks[0]}}]),i}async function LD(e,t,n,i){if(!e)return;let o=n.find(r=>r.identifier===e);if(!o){let r=await ha(),a=n.map(c=>c.identifier),s=r?"You might need to enable some flags on your Organization or App":void 0;throw new y(`Unknown extension type: ${e}.
|
|
1187
|
-
The following extension types are supported: ${a.join(", ")}`,s)}if(mS(t,i,o))throw new y(`Invalid extension type: ${e}`,`You have reached the limit of extension(s) of type ${o.type} per app`);return o}var fS=FD;var Gr=O(ke(),1);var ld,ni=class extends M{async run(){let{flags:t}=await this.parse(ld);await Q.addPublicMetadata(()=>({cmd_scaffold_required_auth:!0,cmd_scaffold_template_custom:t["clone-url"]!==void 0,cmd_scaffold_type_owner:"@shopify/app"})),await Ut(t.path);let{app:n,project:i,specifications:o,remoteApp:r,developerPlatformClient:a}=await B({directory:t.path,clientId:t["client-id"],forceRelink:t.reset,userProvidedConfigName:t.config});return await fS({directory:t.path,reset:t.reset,name:t.name,cloneUrl:t["clone-url"],template:t.template,flavor:t.flavor,app:n,project:i,specifications:o,remoteApp:r,developerPlatformClient:a}),{app:n}}};ld=ni;ni.summary="Generate a new app Extension.";ni.descriptionWithMarkdown=`Generates a new [app extension](https://shopify.dev/docs/apps/build/app-extensions). For a list of app extensions that you can generate using this command, refer to [Supported extensions](https://shopify.dev/docs/apps/build/app-extensions/list-of-app-extensions).
|
|
1188
|
-
|
|
1189
|
-
Each new app extension is created in a folder under \`extensions/\`. To learn more about the extensions file structure, refer to [App structure](https://shopify.dev/docs/apps/build/cli-for-apps/app-structure) and the documentation for your extension.
|
|
1190
|
-
`;ni.description=ld.descriptionWithoutMarkdown();ni.flags={...T,...I,template:Gr.Flags.string({char:"t",hidden:!1,description:"Extension template",env:"SHOPIFY_FLAG_EXTENSION_TEMPLATE"}),name:Gr.Flags.string({char:"n",hidden:!1,description:"name of your Extension",env:"SHOPIFY_FLAG_NAME"}),"clone-url":Gr.Flags.string({hidden:!0,char:"u",description:"The Git URL to clone the function extensions templates from. Defaults to: https://github.com/Shopify/function-examples",env:"SHOPIFY_FLAG_CLONE_URL"}),flavor:Gr.Flags.string({hidden:!1,description:"Choose a starting template for your extension, where applicable",options:["vanilla-js","react","typescript","typescript-react","wasm","rust"],env:"SHOPIFY_FLAG_FLAVOR"})};var hS=ni;l();var gS=O(ke(),1);var Kr=class e extends M{async run(){let{flags:t}=await this.parse(e),n=await B({directory:t.path,clientId:t["client-id"],forceRelink:t.reset,userProvidedConfigName:t.config}),i=await zs({developerPlatformClient:n.developerPlatformClient,apiKey:n.remoteApp.apiKey,organizationId:n.remoteApp.organizationId,extensionTypes:Bs}),o=js(i);if(o.length===0)j({headline:["No extensions to migrate."]});else{let r=await Fw(o);await Ep({...n,extensions:i,extensionTypes:r.extensionTypes,buildExtensionConfig:r.buildExtensionConfig})}return{app:n.app}}};Kr.description="Import dashboard-managed extensions into your app.";Kr.flags={...T,...I,"client-id":gS.Flags.string({hidden:!1,description:"The Client ID of your app.",env:"SHOPIFY_FLAG_CLIENT_ID",exclusive:["config"]})};var yS=Kr;l();l();async function kS(e,t,n,i,o){return o.webEnv?$D(e,t,n,o):VD(e,t,i,o)}async function $D(e,t,n,{format:i}){return Gp(e,t,n,i)}async function VD(e,t,n,i){if(i.format==="json"){let o=vS(e.allExtensions.filter(a=>a.isReturnedAsInfo())),r={...e,packageManager:n.packageManager,nodeDependencies:n.nodeDependencies,usesWorkspaces:n.usesWorkspaces,allExtensions:o};return"realExtensions"in r&&(r.realExtensions=vS(r.realExtensions)),"specifications"in r&&(r={...r,specifications:r.specifications?.map(a=>wS(a))}),w`${JSON.stringify(Object.fromEntries(Object.entries(r).filter(([a])=>a!=="configSchema")),null,2)}`}else return new cd(e,t,n,i).output()}function wS(e){if("schema"in e){let{schema:t,...n}=e;return n}return e}function vS(e){return e.map(t=>{if("specification"in t&&t.specification){let n=t.specification,i=wS(n);return{...t,specification:i}}else return t})}var qD="unknown",fl={subdued:"Not yet configured"},jD="NOT LOADED",cd=class{constructor(t,n,i,o){this.app=t,this.remoteApp=n,this.project=i,this.options=o}async output(){return[...await this.devConfigsSection(),this.projectSettingsSection(),...await this.appComponentsSection(),await this.systemInfoSection()]}async devConfigsSection(){let t=fl;this.app.configuration.build?.automatically_update_urls_on_dev!==void 0&&(t=this.app.configuration.build.automatically_update_urls_on_dev?"Yes":"No");let n=["User","unknown"],i=await this.options.developerPlatformClient.accountInfo();return so(i)?n=["Service account",i.orgName]:ao(i)&&(n[1]=i.email),[this.tableSection("Current app configuration",[["Configuration file",{filePath:$(this.app.configPath)||me.app}],["App name",this.remoteApp.title?{userInput:this.remoteApp.title}:fl],["Client ID",this.remoteApp.apiKey||fl],["Access scopes",vt(this.app.configuration)],["Dev store",this.app.configuration.build?.dev_store_url??this.app.hiddenConfig.dev_store_url??fl],["Update URLs",t],n],{isFirstItem:!0}),{body:["\u{1F4A1} To change these, run",{command:Be(this.project.packageManager,"shopify app config link")}]}]}projectSettingsSection(){return this.tableSection("Your Project",[["Root location",{filePath:this.app.directory}]])}async appComponentsSection(){let t=this.webComponentsSection();return[{title:`
|
|
1191
|
-
Directory components`.toUpperCase(),body:""},...t?[t]:[],...this.extensionsSections()]}webComponentsSection(){let t=[],n=[];if(this.app.webs[0])return this.app.webs.forEach(i=>{if(i.configuration)if(i.configuration.name){let{name:o,roles:r}=i.configuration,a=z(this.app.directory,i.directory);n.push([` \u{1F4C2} ${o}`,{filePath:a||"/"}]),r.length>0&&n.push([" roles",r.join(", ")])}else i.configuration.roles.forEach(o=>{n.push([` \u{1F4C2} ${o}`,{filePath:z(this.app.directory,i.directory)}])});else n.push([{subdued:` \u{1F4C2} ${qD}`},{filePath:z(this.app.directory,i.directory)}]);if(!this.app.errors.isEmpty()){let o=this.app.errors.getErrors(`${i.directory}/${me.web}`);t.push(...o.map(r=>r.message))}}),this.subtableSection("web",[["\u{1F4C2} web",""],...n,...t.map(i=>[{error:"error"},{error:this.formattedError(i)}])])}extensionsSections(){let t=this.app.allExtensions.filter(i=>i.isReturnedAsInfo());return Array.from(new Set(t.map(i=>i.type))).map(i=>{let o=t.filter(r=>r.type===i);if(o[0])return this.subtableSection(o[0].externalType,o.map(r=>this.extensionSubSection(r)).flat())}).filter(i=>i!==void 0)}extensionSubSection(t){let n=t.configuration,i=[[`\u{1F4C2} ${t.handle||jD}`,{filePath:z(this.app.directory,t.directory)}],[" config file",{filePath:z(t.directory,t.configurationPath)}]];n&&"metafields"in n&&Array.isArray(n.metafields)&&n.metafields.length>0&&i.push([" metafields",`${n.metafields.length}`]);let o=this.app.errors.getErrors(t.configurationPath);for(let r of o)i.push([{error:" error"},{error:this.formattedError(r.message)}]);return i}formattedError(t){let n=t.trim();if(Uu())return n;let[i,...o]=n.split(`
|
|
1192
|
-
`);return[`! ${i}`,...o.map(r=>` ${r}`)].join(`
|
|
1193
|
-
`)}async systemInfoSection(){let{platform:t,arch:n}=da();return this.tableSection("Tooling and System",[["Shopify CLI",Pt],["Package manager",this.project.packageManager],["OS",`${t}-${n}`],["Shell",process.env.SHELL??"unknown"],["Node version",process.version]])}tableSection(t,n,{isFirstItem:i=!1}={}){return{title:`${i?"":`
|
|
1194
|
-
`}${t.toUpperCase()}
|
|
1195
|
-
`,body:{tabularData:n,firstColumnSubdued:!0}}}subtableSection(t,n){return{title:t,body:{tabularData:n,firstColumnSubdued:!0}}}};var _S=O(ke(),1);var pd,ii=class extends M{async run(){let{flags:t}=await this.parse(pd),{app:n,project:i,remoteApp:o,organization:r,developerPlatformClient:a}=await B({directory:t.path,clientId:t["client-id"],forceRelink:t.reset,userProvidedConfigName:t.config,unsafeTolerateErrors:!0}),s=await kS(n,o,r,i,{format:t.json?"json":"text",webEnv:t["web-env"],configName:t.config,developerPlatformClient:a});return typeof s=="string"||"value"in s?J(s):oe({customSections:s}),n.errors.isEmpty()||process.exit(2),{app:n}}};pd=ii;ii.summary="Print basic information about your app and extensions.";ii.descriptionWithMarkdown=`The information returned includes the following:
|
|
1196
|
-
|
|
1197
|
-
- The app and dev store that's used when you run the [dev](https://shopify.dev/docs/api/shopify-cli/app/app-dev) command. You can reset these configurations using [\`dev --reset\`](https://shopify.dev/docs/api/shopify-cli/app/app-dev#flags-propertydetail-reset).
|
|
1198
|
-
- The [structure](https://shopify.dev/docs/apps/tools/cli/structure) of your app project.
|
|
1199
|
-
- The [access scopes](https://shopify.dev/docs/api/usage) your app has requested.
|
|
1200
|
-
- System information, including the package manager and version of Shopify CLI used in the project.`;ii.description=pd.descriptionWithoutMarkdown();ii.flags={...T,...I,...Fe,"web-env":_S.Flags.boolean({hidden:!1,description:"Outputs environment variables necessary for running and deploying web/.",env:"SHOPIFY_FLAG_OUTPUT_WEB_ENV",default:!1})};var bS=ii;l();l();function BD(){return{url:Iu()?"https://github.com/Shopify/shopify-app-template-extension-only":"https://github.com/Shopify/shopify-app-template-none",label:"Build an extension-only app",visible:!0}}var oi={reactRouter:{url:"https://github.com/Shopify/shopify-app-template-react-router",label:"Build a React Router app (recommended)",visible:!0,branches:{prompt:"For your React Router template, which language do you want?",options:{javascript:{branch:"javascript-cli",label:"JavaScript"},typescript:{branch:"main-cli",label:"TypeScript"}}}},remix:{url:"https://github.com/Shopify/shopify-app-template-remix",label:"Build a Remix app",visible:!1,branches:{prompt:"For your Remix template, which language do you want?",options:{javascript:{branch:"javascript",label:"JavaScript"},typescript:{branch:"main",label:"TypeScript"}}}},none:BD(),node:{url:"https://github.com/Shopify/shopify-app-template-node",visible:!1},ruby:{url:"https://github.com/Shopify/shopify-app-template-ruby",visible:!1}},dd=Object.keys(oi),hl=dd.filter(e=>oi[e].visible),zD=["reactRouter","none"],WD=async e=>{let t=e.template,n=e.flavor,i={template:oi.reactRouter.url};t??(t=await Je({choices:zD.map(s=>({label:oi[s].label||s,value:s})),message:"Get started building your app:",defaultValue:dd.find(s=>oi[s].url===i.template)}));let o={...e,template:t,templateType:gl(t)?t:"custom",globalCLIResult:{install:!1,alreadyInstalled:!1}},r,a;if(o.templateType!=="custom"){let s=oi[o.templateType];r=s.url,s.branches&&(n?a=s.branches.options[n]?.branch:a=await Je({message:s.branches.prompt||"Choose a flavor:",choices:Object.entries(s.branches.options).map(([c,d])=>({value:d.branch,label:d.label}))}))}return a&&(r=`${r}#${a}`),o.template=r||o.template||i.template,o.globalCLIResult=await iu(),o},SS=WD;function gl(e){return dd.includes(e)}l();l();import{platform as HD}from"os";async function xS({packageJSON:e,local:t,useGlobalCLI:n}){if(e.dependencies=e.dependencies??{},n?delete e.dependencies["@shopify/cli"]:e.dependencies["@shopify/cli"]=Pt,delete e.dependencies["@shopify/app"],t){let i=await GD("cli");e.dependencies["@shopify/cli"]=i;let o={"@shopify/cli":i};e.overrides=e.overrides?{...e.overrides,...o}:o,e.resolutions=e.resolutions?{...e.resolutions,...o}:o}return e}async function GD(e){return`file:${await qe(`packages/${e}`,{type:"directory",cwd:ui(import.meta.url)})}`}async function ES({from:e,packageManager:t}){let n=HD()==="win32"&&t==="yarn"?["--network-concurrency","1"]:[];return ar({directory:Ne(e),packageManager:t,args:n})}l();async function ud(e,t){let i=(await re([k(e,"**",".git"),k(e,"**",".github"),k(e,"**",".gitmodules"),k(e,"**",".cli-liquid-bypass"),k(e,"LICENSE*"),k(e,"**","frontend/LICENSE*"),k(e,"package.json.cli2")],{dot:!0,onlyFiles:!1,onlyDirectories:!1,ignore:["**/node_modules/**"]})).map(a=>mi(a,{force:!0})),o=new Set(ou[t]),r=sa.filter(a=>!o.has(a)).map(a=>{let s=k(e,a);if(Se(s))return Id(s)});return Promise.all([...i,...r])}async function KD(e){let t=e.packageManager,n=Ct(e.name),i=k(e.directory,n),o=Am(e.template);await CS(i,n),await YD(i),oe({body:["Initializing project with",{command:t},`
|
|
1201
|
-
Use the`,{command:"--package-manager"},"flag to select a different package manager."]}),await It(async s=>{let c=k(s,"download"),d=o.filePath?k(c,o.filePath):c,p=k(s,"app"),m=o.branch?`${o.baseURL}#${o.branch}`:o.baseURL;await ae(c);let h=[{title:`Downloading template from ${m}`,task:async()=>{await _a({repoUrl:m,destination:c,shallow:!0})}}];h.push({title:"Parsing liquid",task:async()=>{await yo(d,p,{dependency_manager:t,app_name:e.name})}},{title:"Updating package.json",task:async()=>{let g=(await pu(p)).content;g.name=n,g.author=await vu()??"",g.private=!0;let f=["extensions/*"].concat(QD(p));switch(t){case"npm":case"yarn":case"bun":g.workspaces=f;break;case"pnpm":{await JD(p,f),await Cl(k(p,".npmrc"),`auto-install-peers=true
|
|
1202
|
-
`);break}case"homebrew":case"unknown":throw new ru}await xS({packageJSON:g,local:e.local,directory:p,useGlobalCLI:e.useGlobalCLI}),await uu(p,g)}}),e.postCloneActions.removeLockfilesFromGitignore&&h.push({title:"Removing lockfiles from .gitignore",task:async()=>{let g=k(p,".gitignore");if(await C(g)){let f=await P(g);sa.forEach(v=>{let _=new RegExp(`^${v.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}$`,"gm");f=f.replace(_,"")}),await ie(g,f.trim())}}}),await ha()&&h.push({title:"[Shopifolks-only] Configuring the project's NPM registry",task:async()=>{let g=k(p,".npmrc");await Cl(g,`@shopify:registry=https://registry.npmjs.org
|
|
1203
|
-
`)}}),h.push({title:`Installing dependencies with ${t}`,task:async()=>{await ES({from:p,packageManager:t})}},{title:"Cleaning up",task:async()=>{await ud(p,t)}},{title:"Initializing a Git repository...",task:async()=>{await km(p)}}),await xe(h),await CS(i,n),await dn(p,i)});let r;if(e.selectedAppOrNameResult.result==="new"){let s=await ug(i,e.name),c=e.selectedAppOrNameResult.org;r=await e.developerPlatformClient.createApp(c,s)}else r=e.selectedAppOrNameResult.app;await Rn({directory:i,apiKey:r.apiKey,appId:r.id,organizationId:r.organizationId,configName:"shopify.app.toml",developerPlatformClient:e.developerPlatformClient,isNewApp:!0},!1);let a=await B({directory:i,clientId:void 0,forceRelink:!1,userProvidedConfigName:void 0});return j({headline:[{userInput:n},"is ready for you to build!"],nextSteps:[["Run",{command:`cd ${n}`}],["For extensions, run",{command:Be(t,"shopify app generate extension")}],["To see your app, run",{command:Be(t,"shopify app dev")}]],reference:[{link:{label:"Shopify docs",url:"https://shopify.dev"}},[{link:{label:"Shopify Dev MCP,",url:"https://shopify.dev/docs/apps/build/devmcp"}},"connect your AI assistant to development resources"],["For an overview of commands, run",{command:Be(t,"shopify app","--help")}]]}),{app:a.app}}async function CS(e,t){if(await C(e))throw new y(`
|
|
1204
|
-
A directory with this name (${t}) already exists.
|
|
1205
|
-
Choose a new name for your app.`)}async function YD(e){let t=new Ht({projectName:"shopify-cli-app"}),n=Ne(e);t.delete(n)}function QD(e){return["web","web/frontend"].filter(t=>Se(k(e,t)))}async function JD(e,t){let n=k(e,"pnpm-workspace.yaml");if(await C(n))return;let i=t.map(o=>` - '${o}'`).join(`
|
|
1206
|
-
`);await ie(n,`packages:
|
|
1207
|
-
${i}`)}var NS=KD;l();function AS(e){if(!e)return;let t=Gm(e);if(t&&t.origin!=="https://github.com")throw new y("Only GitHub repository references are supported, e.g., https://github.com/Shopify/<repository>/[subpath]#[branch]");if(!t&&!gl(e))throw new y(w`Only ${hl.map(n=>w`${b.yellow(n)}`.value).join(", ")} template aliases are supported, please provide a valid URL`)}function TS(e,t){if(!e){if(t)throw new y(w`The ${b.yellow("--flavor")} flag requires the ${b.yellow("--template")} flag to be set`);return}if(!t)return;if(!gl(e))throw new y(w`The ${b.yellow("--flavor")} flag is not supported for custom templates`);let n=oi[e];if(!n.branches)throw new y(w`The ${b.yellow(e)} template does not support flavors`);if(!n.branches.options[t])throw new y(w`Invalid option for ${b.yellow("--flavor")}\nThe ${b.yellow("--flavor")} flag for ${b.yellow(e)} accepts only ${Object.keys(n.branches.options).map(i=>w`${b.yellow(i)}`.value).join(", ")}`)}var sn=O(ke(),1);var FS,Xo=class extends M{async run(){let{flags:t}=await this.parse(FS);if(AS(t.template),TS(t.template,t.flavor),t.name!==void 0&&t.name.trim()==="")throw new y("The --name flag can't be empty","Provide a valid app name, for example: --name my-app");let n=mu(t["package-manager"]),i=t.name??await XD(t.path),o=Fi();await o.session();let r=await SS({template:t.template,flavor:t.flavor}),a,s;if(t["client-id"]){let d=await Po({apiKey:t["client-id"]});s=d.title,o=d.developerPlatformClient??o,a={result:"existing",app:d}}else{let d;t["organization-id"]?d=await fs(t["organization-id"],o):d=await Gc(),o=Fi({organization:d});let{organization:p,apps:m,hasMorePages:h}=await o.orgAndApps(d.id);a=await ZD(t.name!==void 0,i,m,h,p,o),s=a.result==="new"?a.name:a.app.title}r.globalCLIResult.install&&await nu(n),await mt(()=>({cmd_create_app_template:r.templateType,cmd_create_app_template_url:r.template}));let{app:c}=await NS({name:s,selectedAppOrNameResult:a,packageManager:n,template:r.template,local:t.local,directory:t.path,useGlobalCLI:r.globalCLIResult.alreadyInstalled||r.globalCLIResult.install,developerPlatformClient:o,postCloneActions:{removeLockfilesFromGitignore:r.templateType!=="custom"}});return{app:c}}};FS=Xo;Xo.summary="Create a new app project";Xo.flags={...T,name:sn.Flags.string({char:"n",env:"SHOPIFY_FLAG_NAME",hidden:!1,description:"The name for the new app. When provided, skips the app selection prompt and creates a new app with this name."}),path:sn.Flags.string({char:"p",env:"SHOPIFY_FLAG_PATH",parse:async e=>he(e),default:async()=>to(),hidden:!1}),template:sn.Flags.string({description:`The app template. Accepts one of the following:
|
|
1208
|
-
- <${hl.join("|")}>
|
|
1209
|
-
- Any GitHub repo with optional branch and subpath, e.g., https://github.com/Shopify/<repository>/[subpath]#[branch]`,env:"SHOPIFY_FLAG_TEMPLATE"}),flavor:sn.Flags.string({description:"Which flavor of the given template to use.",env:"SHOPIFY_FLAG_TEMPLATE_FLAVOR"}),"package-manager":sn.Flags.string({char:"d",env:"SHOPIFY_FLAG_PACKAGE_MANAGER",hidden:!1,options:["npm","yarn","pnpm","bun"]}),local:sn.Flags.boolean({char:"l",env:"SHOPIFY_FLAG_LOCAL",default:!1,hidden:!0}),"client-id":sn.Flags.string({hidden:!1,description:"The Client ID of your app. Use this to automatically link your new project to an existing app. Using this flag avoids the app selection prompt.",env:"SHOPIFY_FLAG_CLIENT_ID",exclusive:["config"]}),"organization-id":sn.Flags.string({hidden:!1,description:"The organization ID. Your organization ID can be found in your Dev Dashboard URL: https://dev.shopify.com/dashboard/<organization-id>",env:"SHOPIFY_FLAG_ORGANIZATION_ID",exclusive:["client-id"]})};var PS=Xo;async function XD(e){for(let t=0;t<3;t++){let n=await Od({suffix:"app",directory:e});if(Yf(n))return n}return""}async function ZD(e,t,n,i,o,r){let a=n.length===0||e;if(a||(a=await as()),a)return{result:"new",name:e?t:await rs(t),org:o};{let s=await os($a(r,o.id),n,i);if(!s)throw new y("Unable to select an app: the selection prompt was interrupted.");let c=await r.appFromIdentifiers(s.apiKey);if(!c)throw new y(`App with id ${s.id} not found`);return{result:"existing",app:c}}}l();l();async function IS(e,t){let n=new Set(t.map(i=>i.file)).size;await Q.addPublicMetadata(()=>({cmd_app_validate_valid:e,cmd_app_validate_issue_count:t.length,cmd_app_validate_file_count:n}))}async function DS(e,t={json:!1}){let n=e.errors;if(!n||n.isEmpty()){if(await IS(!0,[]),t.json){J(JSON.stringify({valid:!0,issues:[]},null,2));return}j({headline:"App configuration is valid."});return}let i=n.getErrors();if(await IS(!1,i),t.json){let o=i.map(({file:r,message:a,path:s,code:c})=>({file:r,message:a,path:s,code:c}));throw J(JSON.stringify({valid:!1,issues:o},null,2)),new de}throw Te({headline:"Validation errors found.",body:i.map(o=>`\u2022 ${Ti(o)}`).join(`
|
|
1210
|
-
`)}),new de}var md;async function yl(e,t){await Q.addPublicMetadata(()=>({cmd_app_validate_valid:!1,cmd_app_validate_issue_count:e,cmd_app_validate_file_count:t}))}var ri=class extends M{async run(){let{flags:t}=await this.parse(md);await Q.addPublicMetadata(()=>({cmd_app_validate_json:t.json}));let n;try{n=await Ai.load(t.path)}catch(a){if(a instanceof y&&t.json){await yl(1,1);let s=mo(bn(a.message)).trim();throw J(JSON.stringify({valid:!1,issues:[{message:s}]},null,2)),new de}throw a}let i;try{i=await ns(n,t.config)}catch(a){if(a instanceof y&&t.json){await yl(1,1);let s=mo(bn(a.message)).trim();throw J(JSON.stringify({valid:!1,issues:[{message:s}]},null,2)),new de}throw a}let o=lg(n,i.file);if(o.length>0){let a=o.map(c=>({file:c.path,message:c.message})),s=new Set(o.map(c=>c.path)).size;throw await yl(a.length,s),t.json?(J(JSON.stringify({valid:!1,issues:a},null,2)),new de):(Te({headline:"Validation errors found.",body:a.map(c=>`\u2022 ${c.message}`).join(`
|
|
1211
|
-
`)}),new de)}let r;try{r=(await B({directory:t.path,clientId:t["client-id"],forceRelink:t.reset,userProvidedConfigName:t.config,unsafeTolerateErrors:!0})).app}catch(a){let s=a instanceof y?mo(bn(a.message)).trim():"";throw s.startsWith("Validation errors in ")&&t.json?(await yl(1,1),J(JSON.stringify({valid:!1,issues:[{message:s}]},null,2)),new de):a}return await DS(r,{json:t.json}),{app:r}}};md=ri;ri.summary="Validate your app configuration and extensions.";ri.descriptionWithMarkdown="Validates the selected app configuration file and all extension configurations against their schemas and reports any errors found.";ri.description=md.descriptionWithoutMarkdown();ri.flags={...T,...I,...Fe};var RS=ri;l();l();async function US(e){let{developerPlatformClient:t,app:n,remoteApp:i}=e,{extensionIdentifiersBreakdown:o,versionDetails:r}=await pv(t,i,e.version),a=await ys({developerPlatformClient:t,apiKey:i.apiKey,localApp:n,remoteApp:i,versionAppModules:r.appModuleVersions.map(m=>({...m})),release:!0});if(!await vs({configExtensionIdentifiersBreakdown:a,extensionIdentifiersBreakdown:o,appTitle:i.title,release:!0,force:e.force,allowUpdates:e.allowUpdates,allowDeletes:e.allowDeletes}))throw new de;let c=[{title:"Releasing version",task:async m=>{m.appRelease=await t.release({app:i,version:{versionId:r.uuid,appVersionId:r.id}})}}],{appRelease:{appRelease:d}}=await xe(c),p=[{link:{label:r.versionTag??void 0,url:r.location}},r.message?`
|
|
1212
|
-
${r.message}`:""];if(d.userErrors&&d.userErrors.length>0){let m=d.userErrors?.map(h=>h.message).join(", ");Te({headline:"Version couldn't be released.",body:[...p,`${p.length>0?`
|
|
1213
|
-
|
|
1214
|
-
`:""}${m}`]})}else j({headline:"Version released to users.",body:p})}var vl=O(ke(),1);var fd,ln=class extends M{async run(){let{flags:t}=await this.parse(fd),n=t["client-id"];await mt(()=>({cmd_app_reset_used:t.reset}));let i=t["allow-updates"],o=t["allow-deletes"],r=!!(i&&o),a=[];!i&&!o&&a.push("allow-updates"),this.failMissingNonTTYFlags(t,a);let{app:s,remoteApp:c,developerPlatformClient:d}=await B({directory:t.path,clientId:n,forceRelink:t.reset,userProvidedConfigName:t.config});return await US({app:s,remoteApp:c,developerPlatformClient:d,force:r,allowUpdates:i,allowDeletes:o,version:t.version}),{app:s}}};fd=ln;ln.summary="Release an app version.";ln.usage="app release --version <version>";ln.descriptionWithMarkdown="Releases an existing app version. Pass the name of the version that you want to release using the `--version` flag.";ln.description=fd.descriptionWithoutMarkdown();ln.flags={...T,...I,"allow-updates":vl.Flags.boolean({hidden:!1,description:"Allows adding and updating extensions and configuration without requiring user confirmation. Recommended option for CI/CD environments.",env:"SHOPIFY_FLAG_ALLOW_UPDATES"}),"allow-deletes":vl.Flags.boolean({hidden:!1,description:"Allows removing extensions and configuration without requiring user confirmation. For CI/CD environments, the recommended flag is --allow-updates.",env:"SHOPIFY_FLAG_ALLOW_DELETES"}),version:vl.Flags.string({hidden:!1,description:"The name of the app version to release.",env:"SHOPIFY_FLAG_VERSION",required:!0})};var OS=ln;l();l();var eR=12;async function tR(e,t,n){let i=await e.appVersions(t);if(!i.app)throw new y(`Invalid API Key: ${t.apiKey}`);let o=i.app.appVersions.nodes.map(r=>{let a=r.message??"";return{...r,status:r.status==="active"&&!n?ve.green(`\u2605 ${r.status}`):r.status,createdBy:r.createdBy?.displayName??"",createdAt:ir(new Date(r.createdAt)),message:a}});if(!n){let r=(process.stdout.columns??75)-eR,a=r;o.forEach(s=>{let c=s.message.length+(s.versionTag?.length??0)+mo(s.status).length+s.createdAt.length+s.createdBy.length;if(c>r){let d=c-s.message.length,p=Math.max(r-d,10);p<a&&(a=p)}}),o.forEach(s=>{s.message.length>a&&(s.message=`${s.message.slice(0,a-3)}...`)})}return{appVersions:o,totalResults:i.app.appVersions.pageInfo.totalResults,app:i.app}}async function hd(e){let{remoteApp:t,developerPlatformClient:n,organization:i}=e,{appVersions:o,totalResults:r}=await tR(n,t,e.json);if(e.json)return J(JSON.stringify(o,null,2));if(Io({org:i.businessName,appName:t.title,configFile:$(e.app.configPath)}),o.length===0){q("No app versions found for this app");return}co({rows:o,columns:{versionTag:{header:"VERSION"},status:{header:"STATUS"},message:{header:"MESSAGE"},createdAt:{header:"DATE CREATED"},createdBy:{header:"CREATED BY"}}});let a=b.link(n.webUiName,[await n.appDeepLink(t),"versions"].join("/"));q(w`\nView all ${String(r)} app versions in the ${a}`)}var gd,ai=class extends M{async run(){let{flags:t}=await this.parse(gd),{app:n,remoteApp:i,developerPlatformClient:o,organization:r}=await B({directory:t.path,clientId:t["client-id"],forceRelink:t.reset,userProvidedConfigName:t.config});return await hd({app:n,remoteApp:i,organization:r,developerPlatformClient:o,json:t.json}),{app:n}}};gd=ai;ai.summary="List deployed versions of your app.";ai.descriptionWithMarkdown="Lists the deployed app versions. An app version is a snapshot of your app extensions.";ai.description=gd.descriptionWithoutMarkdown();ai.flags={...T,...I,...Fe};var MS=ai;l();l();l();l();async function LS(e){let t=e.map(i=>({label:i,value:i}));return await Ge({message:"Webhook Topic",choices:t})}async function $S(e){return Je({message:"Webhook ApiVersion",choices:e.map(t=>({label:t,value:t}))})}async function VS(){return Je({message:"Delivery method",choices:[{label:"HTTP",value:ce.HTTP},{label:"Google Pub/Sub",value:ce.PUBSUB},{label:"Amazon EventBridge",value:ce.EVENTBRIDGE}]})}async function qS(e){return(await Gt({message:"Address for delivery",validate:n=>{let i=n.trim();if(i.length===0)return"Address can't be empty";if(!Op(i,e))return`Invalid address.
|
|
1215
|
-
${Yr(e)}`}})).trim()}function nR(e){return e===ce.HTTP?["For remote HTTP testing, use a URL that starts with https://","For local HTTP testing, use http://localhost:{port}/{url-path}"]:e===ce.PUBSUB?["For Google Pub/Sub, use pubsub://{project-id}:{topic-id}"]:e===ce.EVENTBRIDGE?["For Amazon EventBridge, use an Amazon Resource Name (ARN) starting with arn:aws:events:"]:[]}function Yr(e){return nR(e).map(t=>` \xB7 ${bn(t)}`).join(`
|
|
1216
|
-
`)}async function jS(e,t){let{clientSecret:n,clientId:i,remoteApp:o,app:r}=e;return n&&(i||t!==ce.EVENTBRIDGE)?{clientSecret:n,apiKey:i}:(Io({appName:o.title,configFile:$(r.configPath)}),{clientSecret:o.apiSecretKeys.find(s=>s.secret).secret,apiKey:o.apiKey})}async function BS(e,t,n){let i=await cs(e,n);return t?d_(t,i):$S(i)}async function zS(e,t,n,i){let o=await Bg(e,t,i);return n?u_(n,t,o):LS(o)}async function WS(e,t){let n=e??Mp(t)??await VS(),i=t??await qS(n);return p_(i,n)}async function HS(e){let t=await iR(e);await oR(t)}async function iR(e){let t=await BS(e.developerPlatformClient,e.apiVersion,e.organizationId),n=await zS(e.developerPlatformClient,t,e.topic,e.organizationId),[i,o]=await WS(e.deliveryMethod,e.address),r=await jS(e,o);return{topic:n,apiVersion:t,deliveryMethod:o,address:i,apiKey:r.apiKey,clientSecret:r.clientSecret,developerPlatformClient:e.developerPlatformClient,organizationId:e.organizationId}}async function oR(e){let t={topic:e.topic,api_version:e.apiVersion,address:e.address,delivery_method:e.deliveryMethod,shared_secret:e.clientSecret,api_key:e.apiKey},n=await ls(e.developerPlatformClient,t,e.organizationId);if(!n.success){se(`Request errors:
|
|
1217
|
-
${rR(n.userErrors)}`);return}if(e.deliveryMethod===ce.LOCALHOST){if(await Js(e.address,n.samplePayload,n.headers)){sr("Localhost delivery sucessful");return}se("Localhost delivery failed");return}n.samplePayload===JSON.stringify({})&&sr("Webhook has been enqueued for delivery")}function rR(e){try{return e.map(t=>JSON.parse(t.message).map(n=>` \xB7 ${n}`).join(`
|
|
1218
|
-
`)).join(`
|
|
1219
|
-
`)}catch{return JSON.stringify(e)}}var Xi=O(ke(),1),yd,si=class extends M{async run(){let{flags:t}=await this.parse(yd),n=await B({directory:t.path,clientId:t["client-id"],forceRelink:t.reset,userProvidedConfigName:t.config}),i={...n,topic:t.topic,apiVersion:t["api-version"],deliveryMethod:t["delivery-method"],address:t.address,clientId:t["client-id"],clientSecret:t["client-secret"],path:t.path,config:t.config,organizationId:n.organization.id};return await HS(i),{app:n.app}}};yd=si;si.summary="Trigger delivery of a sample webhook topic payload to a designated address.";si.descriptionWithMarkdown=`
|
|
1220
|
-
Triggers the delivery of a sample Admin API event topic payload to a designated address.
|
|
1221
|
-
|
|
1222
|
-
You should use this command to experiment with webhooks, to initially test your webhook configuration, or for unit testing. However, to test your webhook configuration from end to end, you should always trigger webhooks by performing the related action in Shopify.
|
|
1223
|
-
|
|
1224
|
-
Because most webhook deliveries use remote endpoints, you can trigger the command from any directory where you can use Shopify CLI, and send the webhook to any of the supported endpoint types. For example, you can run the command from your app's local directory, but send the webhook to a staging environment endpoint.
|
|
1225
|
-
|
|
1226
|
-
To learn more about using webhooks in a Shopify app, refer to [Webhooks overview](https://shopify.dev/docs/apps/webhooks).
|
|
1227
|
-
|
|
1228
|
-
### Limitations
|
|
1229
|
-
|
|
1230
|
-
- Webhooks triggered using this method always have the same payload, so they can't be used to test scenarios that differ based on the payload contents.
|
|
1231
|
-
- Webhooks triggered using this method aren't retried when they fail.
|
|
1232
|
-
- Trigger requests are rate-limited using the [Partner API rate limit](https://shopify.dev/docs/api/partner#rate_limits).
|
|
1233
|
-
- You can't use this method to validate your API webhook subscriptions.
|
|
1234
|
-
`;si.description=yd.descriptionWithoutMarkdown();si.flags={...I,help:Xi.Flags.help({required:!1,hidden:!1,env:"SHOPIFY_FLAG_HELP",description:"This help. When you run the trigger command the CLI will prompt you for any information that isn't passed using flags."}),topic:Xi.Flags.string({required:!1,hidden:!1,env:"SHOPIFY_FLAG_TOPIC",description:"The requested webhook topic."}),"api-version":Xi.Flags.string({required:!1,hidden:!1,env:"SHOPIFY_FLAG_API_VERSION",description:"The API Version of the webhook topic."}),"delivery-method":Xi.Flags.string({required:!1,hidden:!1,options:[ce.HTTP,ce.PUBSUB,ce.EVENTBRIDGE],env:"SHOPIFY_FLAG_DELIVERY_METHOD",description:"Method chosen to deliver the topic payload. If not passed, it's inferred from the address."}),"client-secret":Xi.Flags.string({required:!1,hidden:!1,env:"SHOPIFY_FLAG_CLIENT_SECRET",description:"Your app's client secret. This secret allows us to return the X-Shopify-Hmac-SHA256 header that lets you validate the origin of the response that you receive."}),address:Xi.Flags.string({required:!1,hidden:!1,env:"SHOPIFY_FLAG_ADDRESS",description:`The URL where the webhook payload should be sent.
|
|
1235
|
-
You will need a different address type for each delivery-method:
|
|
1236
|
-
${Yr(ce.HTTP)}
|
|
1237
|
-
${Yr(ce.PUBSUB)}
|
|
1238
|
-
${Yr(ce.EVENTBRIDGE)}`})};var GS=si;l();var aR=async e=>{Yh(),process.env.COMMAND_RUN_ID=gn()},KS=aR;l();l();async function YS(e){let t=e.appContextResult.developerPlatformClient,n=e.appContextResult.remoteApp;if(!t.supportsDevSessions)throw new y("Dev preview is not supported for this app. It's valid only for apps created on the Next-Gen Dev Platform.");let i=await t.devSessionDelete({shopFqdn:e.store.shopDomain,appId:n.id});if(i.devSessionDelete?.userErrors.length){let o=i.devSessionDelete.userErrors.map(r=>r.message).join(`
|
|
1239
|
-
`);throw new y(`Failed to stop the dev preview: ${o}`)}j({headline:"Dev preview stopped.",body:[`The dev preview has been stopped on ${e.store.shopDomain} and the app's active version has been restored.`,"You can start it again with",{command:"shopify app dev"}]})}var QS=O(ke(),1);var vd,li=class extends M{async run(){let{flags:t}=await this.parse(vd),n=await B({directory:t.path,clientId:t["client-id"],forceRelink:t.reset,userProvidedConfigName:t.config}),i=await Lt({appContextResult:n,storeFqdn:t.store,forceReselectStore:t.reset});return await YS({appContextResult:n,store:i}),{app:n.app}}};vd=li;li.summary="Cleans up the dev preview from the selected store.";li.descriptionWithMarkdown=`Stop the dev preview that was started with \`shopify app dev\`.
|
|
1240
|
-
|
|
1241
|
-
It restores the app's active version to the selected development store.
|
|
1242
|
-
`;li.description=vd.descriptionWithoutMarkdown();li.flags={...T,...I,store:QS.Flags.string({hidden:!1,char:"s",description:"Store URL. Must be an existing development store.",env:"SHOPIFY_FLAG_STORE",parse:async e=>K(e)})};var JS=li;l();l();function sR(e,t){let n={};return e.targeting?.forEach(i=>{i.target&&(n[i.target]={...i.input_query&&{inputQueryPath:`${t}/${i.input_query}`},...i.export&&{export:i.export}})}),n}function lR(e,t,n,i,o,r){return JSON.stringify({handle:t.handle,name:e.name,apiVersion:t.api_version,targeting:n,schemaPath:r,wasmPath:o,functionRunnerPath:i},null,2)}function cR(e,t){return{title:`CONFIGURATION
|
|
1243
|
-
`,body:{tabularData:[["Handle",e.handle??"N/A"],["Name",t??"N/A"],["API Version",e.api_version??"N/A"]],firstColumnSubdued:!0}}}function pR(e){if(Object.keys(e).length===0)return null;let t=[];return Object.entries(e).forEach(([n,i])=>{t.push([w`${b.cyan(n)}`.value,""]),i.inputQueryPath&&t.push([{subdued:" Input Query Path"},{filePath:i.inputQueryPath}]),i.export&&t.push([{subdued:" Export"},i.export])}),{title:`
|
|
1244
|
-
TARGETING
|
|
1245
|
-
`,body:{tabularData:t}}}function dR(e,t){return{title:`
|
|
1246
|
-
BUILD
|
|
1247
|
-
`,body:{tabularData:[["Schema Path",{filePath:t??"N/A"}],["Wasm Path",{filePath:e}]],firstColumnSubdued:!0}}}function uR(e){return{title:`
|
|
1248
|
-
FUNCTION RUNNER
|
|
1249
|
-
`,body:{tabularData:[["Path",{filePath:e}]],firstColumnSubdued:!0}}}function mR(e,t,n,i,o,r){let a=[cR(t,e.name)],s=pR(n);return s&&a.push(s),a.push(dR(o,r),uR(i)),a}function XS(e,t){let{format:n,functionRunnerPath:i,schemaPath:o}=t,r=e.configuration,a=sR(r,e.directory),s=k(e.directory,r.build?.path??e.outputRelativePath);return n==="json"?lR(e,r,a,i,s,o):mR(e,r,a,i,s,o)}var kd,ci=class extends tt{async run(){let{flags:t}=await this.parse(kd),{app:n}=await bt({directory:t.path,userProvidedConfigName:t.config}),i=await Et(n,t.path),o=yr();await At(o);let r=await ul(i,t.path,t["client-id"],t.reset,t.config),a=XS(i,{format:t.json?"json":"text",functionRunnerPath:o.path,schemaPath:r});return t.json?J(a):oe({customSections:a}),{app:n}}};kd=ci;ci.summary="Print basic information about your function.";ci.descriptionWithMarkdown=`The information returned includes the following:
|
|
1250
|
-
|
|
1251
|
-
- The function handle
|
|
1252
|
-
- The function name
|
|
1253
|
-
- The function API version
|
|
1254
|
-
- The targeting configuration
|
|
1255
|
-
- The schema path
|
|
1256
|
-
- The WASM path
|
|
1257
|
-
- The function runner path`;ci.description=kd.descriptionWithoutMarkdown();ci.flags={...T,...I,...xt,...Fe};var ZS=ci;l();l();l();var ex={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"metafieldDefinitions"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"ownerType"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"MetafieldOwnerType"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"after"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"metafieldDefinitions"},arguments:[{kind:"Argument",name:{kind:"Name",value:"ownerType"},value:{kind:"Variable",name:{kind:"Name",value:"ownerType"}}},{kind:"Argument",name:{kind:"Name",value:"first"},value:{kind:"IntValue",value:"30"}},{kind:"Argument",name:{kind:"Name",value:"after"},value:{kind:"Variable",name:{kind:"Name",value:"after"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"pageInfo"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"hasNextPage"}},{kind:"Field",name:{kind:"Name",value:"endCursor"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"nodes"},selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"MetafieldForImport"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"MetafieldForImport"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"MetafieldDefinition"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"key"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"namespace"}},{kind:"Field",name:{kind:"Name",value:"description"}},{kind:"Field",name:{kind:"Name",value:"type"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"category"}},{kind:"Field",name:{kind:"Name",value:"name"}}]}},{kind:"Field",name:{kind:"Name",value:"access"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"admin"}},{kind:"Field",name:{kind:"Name",value:"storefront"}},{kind:"Field",name:{kind:"Name",value:"customerAccount"}}]}},{kind:"Field",name:{kind:"Name",value:"capabilities"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"adminFilterable"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"enabled"}}]}}]}},{kind:"Field",name:{kind:"Name",value:"validations"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"value"}}]}}]}}]};l();async function fR(e){let t="Admin",n=Kt(e.storeFqdn,"unstable");return{token:e.token,api:t,url:n}}async function tx(e){return eu({query:e.query,...await fR(e.session),variables:e.variables,autoRateLimitRestore:e.autoRateLimitRestore})}l();var nx={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"metaobjectDefinitions"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"after"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"metaobjectDefinitions"},arguments:[{kind:"Argument",name:{kind:"Name",value:"first"},value:{kind:"IntValue",value:"10"}},{kind:"Argument",name:{kind:"Name",value:"after"},value:{kind:"Variable",name:{kind:"Name",value:"after"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"pageInfo"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"hasNextPage"}},{kind:"Field",name:{kind:"Name",value:"endCursor"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"nodes"},selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"MetaobjectForImport"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"MetaobjectForImport"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"MetaobjectDefinition"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"type"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"description"}},{kind:"Field",name:{kind:"Name",value:"access"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"admin"}},{kind:"Field",name:{kind:"Name",value:"storefront"}}]}},{kind:"Field",name:{kind:"Name",value:"displayNameKey"}},{kind:"Field",name:{kind:"Name",value:"capabilities"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"publishable"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"enabled"}}]}},{kind:"Field",name:{kind:"Name",value:"translatable"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"enabled"}}]}},{kind:"Field",name:{kind:"Name",value:"renderable"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"enabled"}},{kind:"Field",name:{kind:"Name",value:"data"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"metaTitleKey"}},{kind:"Field",name:{kind:"Name",value:"metaDescriptionKey"}}]}}]}}]}},{kind:"Field",name:{kind:"Name",value:"fieldDefinitions"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"key"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"type"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"category"}},{kind:"Field",name:{kind:"Name",value:"name"}}]}},{kind:"Field",name:{kind:"Name",value:"description"}},{kind:"Field",name:{kind:"Name",value:"required"}},{kind:"Field",name:{kind:"Name",value:"validations"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"value"}}]}}]}}]}}]};var ox=O(kx(),1);var hR={article:"ARTICLE",blog:"BLOG",collection:"COLLECTION",company:"COMPANY",company_location:"COMPANY_LOCATION",location:"LOCATION",market:"MARKET",order:"ORDER",page:"PAGE",product:"PRODUCT",customer:"CUSTOMER",delivery_customization:"DELIVERY_CUSTOMIZATION",delivery_method:"DELIVERY_METHOD",delivery_option_generator:"DELIVERY_OPTION_GENERATOR",discount:"DISCOUNT",draft_order:"DRAFTORDER",fulfillment_constraint_rule:"FULFILLMENT_CONSTRAINT_RULE",gift_card_transaction:"GIFT_CARD_TRANSACTION",order_routing_location_rule:"ORDER_ROUTING_LOCATION_RULE",payment_customization:"PAYMENT_CUSTOMIZATION",selling_plan:"SELLING_PLAN",shop:"SHOP",validation:"VALIDATION",variant:"PRODUCTVARIANT",cart_transform:"CARTTRANSFORM"};async function rx({query:e,session:t,toNodes:n,toVariables:i,performQuery:o=r=>tx({query:e,session:t,variables:r,autoRateLimitRestore:!0})}){let r;try{let a=n(await o(i(r))),s=[];for(s.push(...a.nodes);a.pageInfo.hasNextPage;)r=a.pageInfo.endCursor,a=n(await o(i(r))),s.push(...a.nodes);return{status:"ok",items:s}}catch(a){if(a instanceof Error&&a.message.includes("ACCESS_DENIED"))return{status:"scope_error"};throw a}}function ix(e,t){let n="";for(let i of e)n=(0,ox.updateTomlValues)(n,i);return`# ${t}
|
|
1258
|
-
${n}`}function gR(e,t){let n=t.map(xR).map(r=>{switch(r.status){case"ok":{let{typeName:a,patches:s}=r;return ix(s,`type: $app:${a}`)}case"not_app_reserved":return null}}).filter(r=>r!==null),i=e.flatMap(({items:r,ownerType:a,graphQLOwner:s})=>r.map(c=>({result:SR(c,a),graphQLOwner:s}))).map(({result:r,graphQLOwner:a})=>{switch(r.status){case"ok":{let{namespace:s,key:c,patches:d}=r;return ix(d,`namespace: ${s==="app"?"$app":`$app:${s}`} key: ${c} owner_type: ${a}`)}case"not_app_reserved":return null}}).filter(r=>r!==null);return{tomlContent:[...n,...i].join(`
|
|
1259
|
-
`),metafieldCount:i.length,metaobjectCount:n.length}}async function ax(e){let t=await bR(e),n=t.storeFqdn,i=await vR(t),o=await kR(t);e.includeExistingDeclaredDefinitions||(i=wR(i,e.appConfiguration),o=_R(o,e.appConfiguration));let{tomlContent:r,metafieldCount:a,metaobjectCount:s}=gR(i,o);yR(a,s,n,r)}function yR(e,t,n,i){oe({headline:"Conversion to TOML complete.",body:["Converted",{warn:`${e} metafields`},"and",{warn:`${t} metaobjects`},"from",{warn:n},"into TOML, ready for you to copy."],orderedNextSteps:!0,nextSteps:["Review the suggested TOML carefully before applying.",["Missing sections? Make sure your app has the required access scopes to load metafields and metaobjects (e.g.",{command:"read_customers"},"to load customer metafields,",{command:"read_metaobject_definitions"},"to load metaobjects.)"],["Missing definitions? Only metafields and metaobjects that are app-reserved (using",{command:"$app"},") will be converted."],["When you're ready, add the generated TOML to your app's configuration file and test out changes with the",{command:"shopify app dev"},"command."]]}),TR(i)}async function vR(e){let t=[];return await xe(Object.entries(hR).map(([n,i])=>({title:w`Loading ${b.green(n)} metafields`,task:async()=>{let o=await rx({query:ex,session:e,toNodes:r=>r.metafieldDefinitions,toVariables:r=>({ownerType:i,after:r})});t.push({metafields:o,ownerType:n,graphQLOwner:i})}}))),t.map(({metafields:n,ownerType:i,graphQLOwner:o})=>n.status==="ok"?{ownerType:i,items:n.items,graphQLOwner:o}:null).filter(n=>n!==null)}async function kR(e){let t=await Le({title:w`Loading ${b.green("metaobjects")}`,task:async()=>rx({query:nx,session:e,toNodes:n=>n.metaobjectDefinitions,toVariables:n=>({after:n})})});return t.status==="ok"?t.items:[]}function wR(e,t){return e.map(n=>{let i=n.items.filter(o=>!sx(t,[n.ownerType,"metafields",Zo(o.namespace)??"",o.key]));return i.length>0?{...n,items:i}:null}).filter(n=>n!==null)}function _R(e,t){return e.filter(n=>!sx(t,["metaobjects","app",Zo(n.type)??""]))}function sx(e,t){let n=e;for(let i of t){if(!n[i])return!1;n=n[i]}return!0}async function bR(e){let{remoteApp:t,store:n}=e,i=t.apiSecretKeys[0]?.secret;if(!i)throw new L("No API secret keys found for app");return await gi(n.shopDomain,t.apiKey,i)}function Zo(e){if(!e.match(/^app--\d+/))return null;let t="app";return e.match(/^app--\d+--/)&&(t=e.replace(/^app--\d+--/,"")),t}function SR(e,t){let n=Zo(e.namespace);if(!n)return{status:"not_app_reserved"};let i=e.key,o=ER(e),r=NR(o,t,n,i);return{status:"ok",key:i,namespace:n,patches:r}}function xR(e){let t=Zo(e.type);if(!t)return{status:"not_app_reserved"};let n=CR(e,t),i=AR(n,t);return{status:"ok",typeName:t,patches:i}}function ER(e){let t={name:e.name===e.key?void 0:e.name,type:e.type.name,description:e.description??void 0,capabilities:Zi({admin_filterable:e.capabilities.adminFilterable.enabled||void 0}),access:Zi({admin:dx(e.access.admin),storefront:ux(e.access.storefront),customer_account:FR(e.access.customerAccount)}),validations:cx(e.validations)},{type:n,validations:i}=lx(t.type,t.validations);return t.type=n,t.validations=i,t}function CR(e,t){return{name:e.name===t?void 0:e.name,description:e.description??void 0,display_name_field:e.displayNameKey??void 0,access:Zi({admin:dx(e.access.admin),storefront:ux(e.access.storefront)}),capabilities:Zi({translatable:e.capabilities.translatable.enabled||void 0,publishable:e.capabilities.publishable.enabled||void 0,renderable:e.capabilities.renderable?.enabled||void 0,renderable_meta_title_field:e.capabilities.renderable?.data?.metaTitleKey??void 0,renderable_meta_description_field:e.capabilities.renderable?.data?.metaDescriptionKey??void 0}),fields:Object.fromEntries(e.fieldDefinitions.map(n=>{let i={type:n.type.name,description:n.description??void 0,name:n.name===n.key?void 0:n.name,required:n.required||void 0,validations:cx(n.validations)},{type:o,validations:r}=lx(i.type,i.validations);return i.type=o,i.validations=r,[n.key,i]}))}}function lx(e,t){if(!t)return{type:e,validations:void 0};if(t.metaobject_definition_type&&typeof t.metaobject_definition_type=="string"){let n=Zo(t.metaobject_definition_type);return{type:`${e}<$app:${n}>`,validations:Zi({...t,metaobject_definition_type:void 0})}}if(t.metaobject_definition_types&&Array.isArray(t.metaobject_definition_types)&&t.metaobject_definition_types.every(n=>typeof n=="string")){let n=t.metaobject_definition_types.map(i=>Zo(i));return{type:`${e}<${n.map(i=>`$app:${i}`).join(",")}>`,validations:Zi({...t,metaobject_definition_types:void 0})}}return{type:e,validations:t}}function cx(e){let t=n=>{try{return JSON.parse(n)}catch{return n}};return Zi(Object.fromEntries(e.filter(n=>n.value!==void 0&&n.name!=="metaobject_definition_id"&&n.name!=="metaobject_definition_ids").map(n=>[n.name,n.value?t(n.value):void 0])))}function NR(e,t,n,i){let o=[[[t,"metafields",n,i,"name"],e.name],[[t,"metafields",n,i,"type"],e.type],[[t,"metafields",n,i,"description"],e.description]],r=[[[t,"metafields",n,i,"access","admin"],e.access?.admin],[[t,"metafields",n,i,"access","storefront"],e.access?.storefront],[[t,"metafields",n,i,"access","customer_account"],e.access?.customer_account],[[t,"metafields",n,i,"capabilities","admin_filterable"],e.capabilities?.admin_filterable||void 0]];return e.validations&&px(e.validations).forEach(({validationKey:s,actualValue:c})=>{o.push([[t,"metafields",n,i,"validations",s],c])}),[kl(o),kl(r)]}function AR(e,t){let n=[[["metaobjects","app",t,"name"],e.name===t?void 0:e.name],[["metaobjects","app",t,"description"],e.description],[["metaobjects","app",t,"display_name_field"],e.display_name_field]],i=[[["metaobjects","app",t,"access","admin"],e.access?.admin],[["metaobjects","app",t,"access","storefront"],e.access?.storefront]];return e.capabilities?.translatable&&i.push([["metaobjects","app",t,"capabilities","translatable"],!0]),e.capabilities?.publishable&&i.push([["metaobjects","app",t,"capabilities","publishable"],!0]),e.capabilities?.renderable&&(i.push([["metaobjects","app",t,"capabilities","renderable"],!0]),e.capabilities?.renderable_meta_title_field&&i.push([["metaobjects","app",t,"capabilities","renderable_meta_title_field"],e.capabilities.renderable_meta_title_field]),e.capabilities?.renderable_meta_description_field&&i.push([["metaobjects","app",t,"capabilities","renderable_meta_description_field"],e.capabilities.renderable_meta_description_field])),Object.entries(e.fields).forEach(([o,r])=>{if(typeof r=="string")n.push([["metaobjects","app",t,"fields",o],r]);else{let a=Object.fromEntries(Object.entries(r).filter(([s,c])=>c!==void 0));Object.keys(a).length===1?n.push([["metaobjects","app",t,"fields",o],r.type]):(n.push([["metaobjects","app",t,"fields",o,"type"],r.type]),n.push([["metaobjects","app",t,"fields",o,"description"],r.description]),n.push([["metaobjects","app",t,"fields",o,"name"],r.name]),n.push([["metaobjects","app",t,"fields",o,"required"],r.required||void 0]),r.validations&&px(r.validations).forEach(({validationKey:c,actualValue:d})=>{n.push([["metaobjects","app",t,"fields",o,"validations",c],d])}))}}),[kl(n),kl(i)]}function px(e){return Object.entries(e).map(([t,n])=>{let i;return typeof n=="string"||typeof n=="number"||typeof n=="boolean"||Array.isArray(n)&&n.every(o=>typeof o=="string")?i=n:i=JSON.stringify(n),{validationKey:t,actualValue:i}})}function TR(e){let t=e.split(`
|
|
1260
|
-
`);for(let n of t)n.match(/^\s*\[/)?q(w`${b.green(n)}`):n.match(/^\s*#/)?q(w`${b.gray(n)}`):q(w`${n}`)}function dx(e){switch(e){case"MERCHANT_READ_WRITE":return"merchant_read_write";case"MERCHANT_READ":case"PRIVATE":case"PUBLIC_READ":case"PUBLIC_READ_WRITE":case null:case void 0:return}}function ux(e){switch(e){case"PUBLIC_READ":return"public_read";case"NONE":case null:case void 0:return}}function FR(e){switch(e){case"READ":return"read";case"READ_WRITE":return"read_write";case"NONE":case null:case void 0:return}}function Zi(e){if(e&&!yi(e)&&!(typeof e=="object"&&Object.values(e).every(t=>t===void 0)))return e}function kl(e){return e.filter(([t,n])=>n!==void 0)}var wd=O(ke(),1);var _d,pi=class extends M{async run(){let{appContextResult:t,...n}=await Le({title:w`Loading application`,task:async()=>{let{flags:i}=await this.parse(_d);await Ut(i.path);let o=await B({directory:i.path,clientId:i["client-id"],forceRelink:i.reset,userProvidedConfigName:i.config}),r=await Lt({appContextResult:o,storeFqdn:i.store,forceReselectStore:i.reset});return{appContextResult:o,appConfiguration:o.app.configuration,remoteApp:o.remoteApp,store:r,includeExistingDeclaredDefinitions:i["include-existing"]}}});return await ax(n),{app:t.app}}};_d=pi;pi.summary="Import metafield and metaobject definitions.";pi.descriptionWithMarkdown="Import metafield and metaobject definitions from your development store. [Read more about declarative custom data definitions](https://shopify.dev/docs/apps/build/custom-data/declarative-custom-data-definitions).";pi.description=_d.descriptionWithoutMarkdown();pi.flags={...T,...I,store:wd.Flags.string({char:"s",description:"Store URL. Must be an existing development or Shopify Plus sandbox store.",env:"SHOPIFY_FLAG_STORE",parse:async e=>K(e)}),"include-existing":wd.Flags.boolean({description:"Include existing declared definitions in the output.",default:!1,env:"SHOPIFY_FLAG_INCLUDE_EXISTING"})};var mx=pi;l();l();async function fx(e){let t;try{t=await ms()}catch(n){if(e.json&&n instanceof Ot){J(JSON.stringify({organizations:[]},null,2));return}throw n}if(e.json){let n={organizations:t.map(i=>({id:i.id,gid:$c(i.id),name:i.businessName}))};J(JSON.stringify(n,null,2));return}PR(t)}function PR(e){let t=e.map(n=>({id:n.id,name:n.businessName}));co({rows:t,columns:{id:{header:"ID"},name:{header:"NAME"}}})}var bd,di=class extends fo{async run(){let{flags:t}=await this.parse(bd);await fx({json:t.json})}};bd=di;di.summary="List Shopify organizations you have access to.";di.descriptionWithMarkdown="Lists the Shopify organizations that you have access to, along with their organization IDs.";di.description=bd.descriptionWithoutMarkdown();di.flags={...T,...Fe};var hx=di;var wl={"app:build":Qk,"app:bulk:cancel":rw,"app:bulk:status":aw,"app:deploy":Rw,"app:dev":ub,"app:dev:clean":JS,"app:logs":kb,"app:logs:sources":_b,"app:import-custom-data-definitions":mx,"app:import-extensions":yS,"app:info":bS,"app:init":PS,"app:config:validate":RS,"app:release":OS,"app:config:link":sw,"app:config:use":cw,"app:config:pull":pw,"app:env:pull":xb,"app:env:show":Cb,"app:execute":zb,"app:bulk:execute":qb,"app:function:build":Hb,"app:function:replay":nS,"app:function:run":iS,"app:function:info":ZS,"app:function:schema":rS,"app:function:typegen":aS,"app:generate:extension":hS,"app:versions:list":MS,"app:webhook:trigger":GS,"demo:watcher":yw,"organization:list":hx},IR=Ym,DR=KS,RR=Km;import UR from"fs";var vye=Fm.init;(0,yx.createGlobalProxyAgent)({environmentVariableNamespace:"SHOPIFY_",forceGlobalAgent:!0,socketConnectionTimeout:6e4});process.on("uncaughtException",e=>{e instanceof Nu?xu(e):UR.writeSync(process.stderr.fd,`${e.stack??e.message??e}
|
|
1261
|
-
`),process.exit(1)});var OR=["SIGINT","SIGTERM","SIGQUIT"];OR.forEach(e=>{process.on(e,()=>{process.exit(1)})});var gx=Number(process.env.SHOPIFY_CLI_COLUMNS);isNaN(gx)||(process.stdout.columns=gx);async function MR({development:e}){await Yu({moduleURL:import.meta.url,development:e})}vo.plugins.hidden=!0;vo["plugins:install"].description="";var LR=Object.keys(wl);LR.forEach(e=>{wl[e].customPluginName="@shopify/app"});var $R=Object.keys(ba);$R.forEach(e=>{ba[e].customPluginName="@shopify/theme"});var VR=Object.keys(Sa);VR.forEach(e=>{Sa[e].customPluginName="@shopify/cli-hydrogen"});var qR=Object.keys(Ra);qR.forEach(e=>{Ra[e].customPluginName="@shopify/store"});var jR=Object.keys(Na);jR.forEach(e=>{Na[e].customPluginName="@oclif/plugin-commands"});var BR=Object.keys(Aa);BR.forEach(e=>{Aa[e].customPluginName="@shopify/plugin-did-you-mean"});var zR=Object.keys(vo);zR.forEach(e=>{vo[e].customPluginName="@oclif/plugin-plugins"});var kye={...wl,...ba,...vo,...Aa,...Na,...Sa,...Ra,search:$u,upgrade:Vu,version:Lu,help:Xu,"auth:logout":qu,"auth:login":ju,"debug:command-flags":Bu,"kitchen-sink":Gu,"kitchen-sink:async":zu,"kitchen-sink:prompts":Wu,"kitchen-sink:static":Hu,"doctor-release":Ku,"doctor-release:theme":Qu,"docs:generate":Ju,"notifications:list":Zu,"notifications:generate":em,"cache:clear":tm,"config:autoupgrade:off":nm,"config:autoupgrade:on":im,"config:autoupgrade:status":om},wye=MR;export{DR as AppInitHook,RR as AppPublicMetadataHook,IR as AppSensitiveMetadataHook,kye as COMMANDS,Fx as DidYouMeanHook,vye as HydrogenInitHook,Tx as PluginHook,Px as TunnelProviderHook,Ix as TunnelStartHook,wye as default,bx as fetchStoreThemes,Sx as pull,xx as push};
|
|
87
|
+
`;async function Co(e){try{return(await G({query:zn,api:"Admin",url:Y(e.adminSession.storeFqdn,"unstable",e.adminSession),token:e.adminSession.token,responseOptions:{handleErrors:!1}})).publicApiVersions}catch(t){let o=Po(t);(o===401||o===404)&&(K(e.session.store,e.session.userId),R(`Stored app authentication for ${e.session.store} is no longer valid.`,e.session.store,e.session.scopes.join(",")));let n=Do(t,e.adminSession.storeFqdn);throw n||t}}async function Fo(e){try{return await M({title:c`Executing GraphQL operation`,task:async()=>G({query:e.request.query,api:"Admin",url:Y(e.context.adminSession.storeFqdn,e.context.version,e.context.adminSession),token:e.context.adminSession.token,variables:e.request.parsedVariables,responseOptions:{handleErrors:!1}}),renderOptions:{stdout:process.stderr}})}catch(t){De(t)&&t.response.status===401&&(K(e.context.session.store,e.context.session.userId),R(`Stored app authentication for ${e.context.session.store} is no longer valid.`,e.context.session.store,e.context.session.scopes.join(",")));let o=Do(t,e.context.adminSession.storeFqdn);throw o||(De(t)&&t.response.errors?new s("GraphQL operation failed.",JSON.stringify({errors:t.response.errors},null,2)):t)}}function De(e){if(!e||typeof e!="object"||!("response"in e))return!1;let t=e.response;return!!t&&typeof t=="object"}function Po(e){if(!De(e))return;let t=e.response.status;return typeof t=="number"?t:void 0}var Mn=["the user aborted a request","the operation was aborted"];function Hn(e){if(!(e instanceof Error))return!1;if(e.name==="AbortError")return!0;let t=e.message.toLowerCase();return Mn.some(o=>t.includes(o))}function Do(e,t){if(Po(e)===402)return new s(`The store ${t} is currently unavailable.`,"Check the store in the Shopify admin and try again once it is reactivated.");if(Hn(e))return new s(`Request to ${t} was aborted before it completed.`)}async function Vn(e){let{session:t,adminSession:o,userSpecifiedVersion:n}=e;if(n==="unstable")return n;let r=await Co({adminSession:o,session:t});if(!n)return r.filter(p=>p.supported).map(p=>p.handle).sort().reverse()[0];let u=r.map(d=>d.handle);if(u.includes(n))return n;throw new s(`Invalid API version: ${n}`,`Allowed versions: ${u.join(", ")}`)}async function qo(e){let t=await me(e.store);await U(t.store,!0),oe(t.userId);let o={token:t.accessToken,storeFqdn:t.store},n=await Vn({session:t,adminSession:o,userSpecifiedVersion:e.userSpecifiedVersion});return{adminSession:o,version:n,session:t}}var jn={id:"admin",prepareContext:async({store:e,requestedVersion:t})=>qo({store:e,userSpecifiedVersion:t}),execute:async({context:e,request:t})=>Fo({context:e,request:t})};function $o(e){if(e==="admin")return jn;throw new H(`Unsupported store GraphQL API target: ${e}`)}async function Lo(e){await U(e.store,!1);let t=$o(e.api??"admin"),o=await Oo({query:e.query,queryFile:e.queryFile,variables:e.variables,variableFile:e.variableFile,version:e.version,allowMutations:e.allowMutations}),n=await M({title:c`Loading stored store auth`,task:async()=>t.prepareContext({store:e.store,requestedVersion:o.requestedVersion}),renderOptions:{stdout:process.stderr}});return t.execute({context:n,request:o})}i();function Gn(e){return JSON.stringify(e,null,2)}function Ro(e){if(e){Q({headline:"Operation succeeded.",body:`Results written to ${e}`});return}Q({headline:"Operation succeeded."})}async function Uo(e,t,o="text"){let n=Gn(e);if(t){await He(t,n),o==="text"&&Ro(t);return}o==="text"&&Ro(),v(n)}var $=z(ee(),1),qe,I=class extends N{async run(){let{flags:t}=await this.parse(qe),o=await Lo({store:t.store,query:t.query,queryFile:t["query-file"],variables:t.variables,variableFile:t["variable-file"],version:t.version,allowMutations:t["allow-mutations"]});await Uo(o,t["output-file"],t.json?"json":"text")}};qe=I;I.summary="Execute GraphQL queries and mutations on a store.";I.descriptionWithMarkdown="Executes an Admin API GraphQL query or mutation on the specified store using previously stored app authentication.\n\nRun `shopify store auth` first to create stored auth for the store.\n\nMutations are disabled by default. Re-run with `--allow-mutations` if you intend to modify store data.";I.description=qe.descriptionWithoutMarkdown();I.examples=['<%= config.bin %> <%= command.id %> --store shop.myshopify.com --query "query { shop { name } }"',`<%= config.bin %> <%= command.id %> --store shop.myshopify.com --query-file ./operation.graphql --variables '{"id":"gid://shopify/Product/1"}'`,'<%= config.bin %> <%= command.id %> --store shop.myshopify.com --query "mutation { shop { id } }" --allow-mutations','<%= config.bin %> <%= command.id %> --store shop.myshopify.com --query "query { shop { name } }" --json'];I.flags={...F,...P,query:$.Flags.string({char:"q",description:"The GraphQL query or mutation, as a string.",env:"SHOPIFY_FLAG_QUERY",required:!1,exactlyOne:["query","query-file"]}),"query-file":$.Flags.string({description:"Path to a file containing the GraphQL query or mutation. Can't be used with --query.",env:"SHOPIFY_FLAG_QUERY_FILE",parse:async e=>X(e),exactlyOne:["query","query-file"]}),variables:$.Flags.string({char:"v",description:"The values for any GraphQL variables in your query or mutation, in JSON format.",env:"SHOPIFY_FLAG_VARIABLES",exclusive:["variable-file"]}),"variable-file":$.Flags.string({description:"Path to a file containing GraphQL variables in JSON format. Can't be used with --variables.",env:"SHOPIFY_FLAG_VARIABLE_FILE",parse:async e=>X(e),exclusive:["variables"]}),store:q.store,version:$.Flags.string({description:"The API version to use for the query or mutation. Defaults to the latest stable version.",env:"SHOPIFY_FLAG_VERSION"}),"output-file":$.Flags.string({description:"The file name where results should be written, instead of STDOUT.",env:"SHOPIFY_FLAG_OUTPUT_FILE",parse:async e=>X(e)}),"allow-mutations":$.Flags.boolean({description:"Allow GraphQL mutations to run against the target store.",env:"SHOPIFY_FLAG_ALLOW_MUTATIONS",default:!1})};var zo=I;i();i();i();i();var Mo={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"StoreInfoDestinations"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"search"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"currentUserAccount"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"destinations"},arguments:[{kind:"Argument",name:{kind:"Name",value:"search"},value:{kind:"Variable",name:{kind:"Name",value:"search"}}},{kind:"Argument",name:{kind:"Name",value:"shopsOnly"},value:{kind:"BooleanValue",value:!0}},{kind:"Argument",name:{kind:"Name",value:"first"},value:{kind:"IntValue",value:"25"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"nodes"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"publicId"}},{kind:"Field",name:{kind:"Name",value:"primaryDomain"}},{kind:"Field",name:{kind:"Name",value:"webUrl"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};i();var Ho={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"StoreInfoOwningOrg"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"destinationPublicId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"DestinationPublicID"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"currentUserAccount"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"organizationForDestination"},arguments:[{kind:"Argument",name:{kind:"Name",value:"destinationPublicId"},value:{kind:"Variable",name:{kind:"Name",value:"destinationPublicId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};async function Vo(e){let t=e.token??await T(),o={type:"token_refresh",handler:async()=>({token:await T()})},n=W(e.store)??e.store.toLowerCase(),r=n.split(".")[0]??n,p=((await be({query:Mo,token:t,variables:{search:r},unauthorizedHandler:o})).currentUserAccount?.destinations.nodes??[]).find(l=>Qn(l,n));if(!p)throw new s(`Couldn't find a store with domain ${e.store} for the current account.`,"Verify the domain (must be the canonical `myshopify.com` FQDN) and that you are signed in to an account with access to the store. Inactive shops are not searchable.");let g=await Bn(String(p.publicId),t,o);return{...g?{owningOrg:g}:{}}}async function Bn(e,t,o){try{let r=(await be({query:Ho,token:t,variables:{destinationPublicId:e},unauthorizedHandler:o})).currentUserAccount?.organizationForDestination;if(!r){m(`No owning organization returned for destination ${e}.`);return}let u=r.id?wt(r.id):void 0;return{name:r.name,...u?{id:u}:{}}}catch(n){m(`Failed to resolve owning organization: ${Yn(n)}`);return}}function Qn(e,t){return[e.primaryDomain,e.webUrl].some(o=>W(o)===t)}function Yn(e){return e instanceof Error?e.message:String(e)}i();i();var jo={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"StoreInfoShop"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"search"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"organization"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"accessibleShops"},arguments:[{kind:"Argument",name:{kind:"Name",value:"first"},value:{kind:"IntValue",value:"5"}},{kind:"Argument",name:{kind:"Name",value:"search"},value:{kind:"Variable",name:{kind:"Name",value:"search"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"edges"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"node"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"shopifyShopId"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"primaryDomain"}},{kind:"Field",name:{kind:"Name",value:"storeType"}},{kind:"Field",name:{kind:"Name",value:"developerPreviewHandle"}},{kind:"Field",name:{kind:"Name",value:"planName"}},{kind:"Field",name:{kind:"Name",value:"ownerDetails"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"fullName"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}},{kind:"Field",name:{kind:"Name",value:"__typename"}}]}}]}}]};async function Go(e){let t=e.token??await T(),o={type:"token_refresh",handler:async()=>({token:await T()})},r=(await B({query:jo,token:t,organizationId:e.organizationId,variables:{search:e.store},unauthorizedHandler:o})).organization?.accessibleShops?.edges??[],u=e.store.toLowerCase(),d=r.map(p=>p.node).find(p=>W(p.primaryDomain)===u);if(!d)throw new H(`Couldn't find shop ${e.store} inside organization ${e.organizationId}.`,"The shop matched a global lookup but is not listed under its parent organization. This usually means the search index is stale; try again in a moment.");return{shopifyShopId:d.shopifyShopId??void 0,name:d.name,primaryDomain:d.primaryDomain??void 0,storeType:d.storeType??void 0,developerPreviewHandle:d.developerPreviewHandle??void 0,planName:d.planName??void 0,ownerName:d.ownerDetails?.fullName??void 0,ownerEmail:d.ownerDetails?.email??void 0}}i();var Wn={basic:"basic",professional:"grow",grow:"grow",unlimited:"advanced",advanced:"advanced",shopify_plus:"plus",plus:"plus"};function Bo(e){if(e)return Wn[e.toLowerCase()]}async function Qo(e){let t=e.store;if(!t)throw new s("No store specified.","Pass the `myshopify.com` domain via the `--store` flag, e.g. `shopify store info --store shop.myshopify.com`.");let o=await Vo({store:t}),n=await Jn(o,t);return Kn({store:t,destinationsCtx:o,orgShop:n})}async function Jn(e,t){if(!e.owningOrg?.id){m("Owning organization id is unknown; skipping BP Organizations shop lookup.");return}try{return await Go({store:t,organizationId:e.owningOrg.id})}catch(o){m(`BP Organizations shop lookup failed: ${o instanceof Error?o.message:String(o)}`);return}}function Kn(e){let{store:t,destinationsCtx:o,orgShop:n}=e,r={id:Zn(n?.shopifyShopId),displayName:n?.name,organizationId:o.owningOrg?.id,organizationName:o.owningOrg?.name,storeOwner:Xn(n),type:or(n?.storeType),plan:Bo(n?.planName),featurePreview:n?.developerPreviewHandle,adminUrl:er(xt(t))};return{...Ae(r),subdomain:t}}function Zn(e){if(e)return`gid://shopify/Shop/${e}`}function Xn(e){if(!e)return;let t=Ae({name:e.ownerName,email:e.ownerEmail});return Object.keys(t).length>0?t:void 0}function er(e){if(e)return`https://admin.shopify.com/store/${encodeURIComponent(e)}`}var tr={APP_DEVELOPMENT:"dev",CLIENT_TRANSFER:"client_transfer",COLLABORATOR:"collaborator",DEVELOPMENT:"dev",DEVELOPMENT_SUPERSET:"dev",PRODUCTION:"production"};function or(e){if(e)return tr[e]}i();function Yo(e,t){if(t==="json"){v(JSON.stringify(e,null,2));return}Qe({customSections:[{title:"Store details",body:{list:{items:nr(e)}}}]})}function nr(e){let t=[];return O(t,"ID",e.id),O(t,"Display Name",e.displayName),O(t,"Subdomain",e.subdomain),O(t,"Organization",e.organizationName),O(t,"Store owner",rr(e.storeOwner)),O(t,"Type",e.type?ye(e.type):void 0),O(t,"Plan",e.plan?ye(e.plan):void 0),O(t,"Feature Preview",e.featurePreview),O(t,"Admin URL",e.adminUrl),t}function rr(e){if(e)return e.name&&e.email?`${e.name} (${e.email})`:e.name??e.email}function O(e,t,o){o&&e.push(`${t}: ${o}`)}var $e,C=class extends N{async run(){let{flags:t}=await this.parse($e),o=await Qo({store:t.store});Yo(o,t.json?"json":"text")}};$e=C;C.summary="Surface metadata about a Shopify store.";C.descriptionWithMarkdown="Returns metadata about a store you have access to: id, display name, subdomain, organization, store owner, type, plan, feature preview, and admin URL.\n\nUse `--json` for machine-readable output.";C.description=$e.descriptionWithoutMarkdown();C.examples=["<%= config.bin %> <%= command.id %> --store shop.myshopify.com","<%= config.bin %> <%= command.id %> --store shop.myshopify.com --json"];C.flags={...F,...P,store:q.store};var Wo=C;var ir={"store:auth":Ao,"store:create:dev":Eo,"store:execute":zo,"store:info":Wo},le=ir;i();i();var ar=async e=>{bt(),process.env.COMMAND_RUN_ID=te()},Jo=ar;var fe={"app:build":Tt,"app:bulk:cancel":Nt,"app:bulk:status":_t,"app:deploy":Ft,"app:dev":Pt,"app:dev:clean":to,"app:logs":Dt,"app:logs:sources":qt,"app:import-custom-data-definitions":no,"app:import-extensions":Bt,"app:info":Qt,"app:init":Yt,"app:config:validate":Wt,"app:release":Jt,"app:config:link":Et,"app:config:use":It,"app:config:pull":Ot,"app:env:pull":$t,"app:env:show":Lt,"app:execute":Ut,"app:bulk:execute":Rt,"app:function:build":zt,"app:function:replay":Mt,"app:function:run":Ht,"app:function:info":oo,"app:function:schema":Vt,"app:function:typegen":jt,"app:generate:extension":Gt,"app:versions:list":Kt,"app:webhook:trigger":Zt,"demo:watcher":Ct,"organization:list":ro},sr=eo,cr=Jo,dr=Xt;import ur from"fs";var Cd=At.init;(0,Zo.createGlobalProxyAgent)({environmentVariableNamespace:"SHOPIFY_",forceGlobalAgent:!0,socketConnectionTimeout:6e4});process.on("uncaughtException",e=>{e instanceof We?Ye(e):ur.writeSync(process.stderr.fd,`${e.stack??e.message??e}
|
|
88
|
+
`),process.exit(1)});var mr=["SIGINT","SIGTERM","SIGQUIT"];mr.forEach(e=>{process.on(e,()=>{process.exit(1)})});var Ko=Number(process.env.SHOPIFY_CLI_COLUMNS);isNaN(Ko)||(process.stdout.columns=Ko);async function pr({development:e}){await ut({moduleURL:import.meta.url,development:e})}V.plugins.hidden=!0;V["plugins:install"].description="";var lr=Object.keys(fe);lr.forEach(e=>{fe[e].customPluginName="@shopify/app"});var fr=Object.keys(re);fr.forEach(e=>{re[e].customPluginName="@shopify/theme"});var hr=Object.keys(ie);hr.forEach(e=>{ie[e].customPluginName="@shopify/cli-hydrogen"});var gr=Object.keys(le);gr.forEach(e=>{le[e].customPluginName="@shopify/store"});var kr=Object.keys(ae);kr.forEach(e=>{ae[e].customPluginName="@oclif/plugin-commands"});var Sr=Object.keys(se);Sr.forEach(e=>{se[e].customPluginName="@shopify/plugin-did-you-mean"});var yr=Object.keys(V);yr.forEach(e=>{V[e].customPluginName="@oclif/plugin-plugins"});var Fd={...fe,...re,...V,...se,...ae,...ie,...le,search:et,upgrade:tt,version:Xe,help:lt,"auth:logout":ot,"auth:login":nt,"debug:command-flags":rt,"kitchen-sink":ct,"kitchen-sink:async":it,"kitchen-sink:prompts":at,"kitchen-sink:static":st,"doctor-release":dt,"doctor-release:theme":mt,"docs:generate":pt,"notifications:list":ft,"notifications:generate":ht,"cache:clear":gt,"config:autoupgrade:off":kt,"config:autoupgrade:on":St,"config:autoupgrade:status":yt},Pd=pr;export{cr as AppInitHook,dr as AppPublicMetadataHook,sr as AppSensitiveMetadataHook,Fd as COMMANDS,sn as DidYouMeanHook,Cd as HydrogenInitHook,an as PluginHook,cn as TunnelProviderHook,dn as TunnelStartHook,Pd as default,on as fetchStoreThemes,nn as pull,rn as push};
|