@senators/bifrost-cli 0.0.0-stage → 7.0.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/LICENSE +21 -0
- package/README.md +180 -2
- package/out/accountEditor-CQB91PVf.js +2 -0
- package/out/accountEditor-CQB91PVf.js.map +1 -0
- package/out/achievements-Df5qqpYQ.js +2 -0
- package/out/achievements-Df5qqpYQ.js.map +1 -0
- package/out/active-CnUKpiEo.js +2 -0
- package/out/active-CnUKpiEo.js.map +1 -0
- package/out/alliance-BsPnhi7w.js +2 -0
- package/out/alliance-BsPnhi7w.js.map +1 -0
- package/out/allianceAdmin-Bkyl6ev4.js +2 -0
- package/out/allianceAdmin-Bkyl6ev4.js.map +1 -0
- package/out/arsenal-BMCmAHzv.js +2 -0
- package/out/arsenal-BMCmAHzv.js.map +1 -0
- package/out/ban-BXNvHPMq.js +2 -0
- package/out/ban-BXNvHPMq.js.map +1 -0
- package/out/banList-3DbCToEy.js +2 -0
- package/out/banList-3DbCToEy.js.map +1 -0
- package/out/banList-dT5GF5eO.js +2 -0
- package/out/banList-dT5GF5eO.js.map +1 -0
- package/out/battleHall-C4BALP6S.js +2 -0
- package/out/battleHall-C4BALP6S.js.map +1 -0
- package/out/battleHall-P7Co1jS5.js +2 -0
- package/out/battleHall-P7Co1jS5.js.map +1 -0
- package/out/battleReport-BG0-S-bF.js +2 -0
- package/out/battleReport-BG0-S-bF.js.map +1 -0
- package/out/battleReport-C3PQTXxc.js +2 -0
- package/out/battleReport-C3PQTXxc.js.map +1 -0
- package/out/battleSimulator-BOySErLn.js +2 -0
- package/out/battleSimulator-BOySErLn.js.map +1 -0
- package/out/board-CsNgDx4j.js +2 -0
- package/out/board-CsNgDx4j.js.map +1 -0
- package/out/board-DSCl8eU8.js +2 -0
- package/out/board-DSCl8eU8.js.map +1 -0
- package/out/bonusSummary-Dmm646zj.js +2 -0
- package/out/bonusSummary-Dmm646zj.js.map +1 -0
- package/out/buddyList-B50t-9_g.js +2 -0
- package/out/buddyList-B50t-9_g.js.map +1 -0
- package/out/buildings-CXrMgFyb.js +2 -0
- package/out/buildings-CXrMgFyb.js.map +1 -0
- package/out/catalog-DmSXp_YG.js +2 -0
- package/out/catalog-DmSXp_YG.js.map +1 -0
- package/out/chat-BvtMl-I7.js +2 -0
- package/out/chat-BvtMl-I7.js.map +1 -0
- package/out/clearCache-79cjREI0.js +2 -0
- package/out/clearCache-79cjREI0.js.map +1 -0
- package/out/cli.js +3 -0
- package/out/cli.js.map +1 -0
- package/out/containers-BhguCCkz.js +2 -0
- package/out/containers-BhguCCkz.js.map +1 -0
- package/out/control-IJRy1LDx.js +2 -0
- package/out/control-IJRy1LDx.js.map +1 -0
- package/out/create-D-IygCER.js +2 -0
- package/out/create-D-IygCER.js.map +1 -0
- package/out/createMoon-BMWjdwO0.js +2 -0
- package/out/createMoon-BMWjdwO0.js.map +1 -0
- package/out/cronjob-CCJKDSuv.js +2 -0
- package/out/cronjob-CCJKDSuv.js.map +1 -0
- package/out/dailyBonus-2UwWD4D0.js +2 -0
- package/out/dailyBonus-2UwWD4D0.js.map +1 -0
- package/out/delivery-d8NKP-f1.js +2 -0
- package/out/delivery-d8NKP-f1.js.map +1 -0
- package/out/disclaimer-BmejHZqk.js +2 -0
- package/out/disclaimer-BmejHZqk.js.map +1 -0
- package/out/dump--mJa5m3e.js +2 -0
- package/out/dump--mJa5m3e.js.map +1 -0
- package/out/endpoints-CbZGTbF-.js +2 -0
- package/out/endpoints-CbZGTbF-.js.map +1 -0
- package/out/externalAuth-Dwl3VAHa.js +2 -0
- package/out/externalAuth-Dwl3VAHa.js.map +1 -0
- package/out/findDebris-DOMvMC1l.js +2 -0
- package/out/findDebris-DOMvMC1l.js.map +1 -0
- package/out/fleet-DyITa_Xu.js +2 -0
- package/out/fleet-DyITa_Xu.js.map +1 -0
- package/out/fleetAjax-BGxyUtdi.js +2 -0
- package/out/fleetAjax-BGxyUtdi.js.map +1 -0
- package/out/fleetDealer-n6LM_8IT.js +2 -0
- package/out/fleetDealer-n6LM_8IT.js.map +1 -0
- package/out/fleetMissile-CucQvNmZ.js +2 -0
- package/out/fleetMissile-CucQvNmZ.js.map +1 -0
- package/out/fleetStep1-wp-NgTsC.js +2 -0
- package/out/fleetStep1-wp-NgTsC.js.map +1 -0
- package/out/fleetStep2-C-GzHXyn.js +2 -0
- package/out/fleetStep2-C-GzHXyn.js.map +1 -0
- package/out/fleetStep3-D_fqImWm.js +2 -0
- package/out/fleetStep3-D_fqImWm.js.map +1 -0
- package/out/fleetTable-BpWLh0R1.js +2 -0
- package/out/fleetTable-BpWLh0R1.js.map +1 -0
- package/out/flyingFleet-ClIrGPJz.js +2 -0
- package/out/flyingFleet-ClIrGPJz.js.map +1 -0
- package/out/galaxy-B12wKQUU.js +2 -0
- package/out/galaxy-B12wKQUU.js.map +1 -0
- package/out/get-Cn2hFvGS.js +2 -0
- package/out/get-Cn2hFvGS.js.map +1 -0
- package/out/giveaway-CDWEArOF.js +2 -0
- package/out/giveaway-CDWEArOF.js.map +1 -0
- package/out/growth-C_-C8rLD.js +2 -0
- package/out/growth-C_-C8rLD.js.map +1 -0
- package/out/index.d.ts +29 -0
- package/out/index.d.ts.map +1 -0
- package/out/index.js +1 -0
- package/out/information-CqfqYCH1.js +2 -0
- package/out/information-CqfqYCH1.js.map +1 -0
- package/out/information-DK93hgyE.js +2 -0
- package/out/information-DK93hgyE.js.map +1 -0
- package/out/log-BBE1Jt9i.js +2 -0
- package/out/log-BBE1Jt9i.js.map +1 -0
- package/out/login--4vqysQx.js +2 -0
- package/out/login--4vqysQx.js.map +1 -0
- package/out/login-C_DqRApn.js +2 -0
- package/out/login-C_DqRApn.js.map +1 -0
- package/out/logout-BYnLiMja.js +2 -0
- package/out/logout-BYnLiMja.js.map +1 -0
- package/out/logout-BsCSXzv8.js +2 -0
- package/out/logout-BsCSXzv8.js.map +1 -0
- package/out/lostPassword-Pc_1CUBD.js +2 -0
- package/out/lostPassword-Pc_1CUBD.js.map +1 -0
- package/out/market-DN8cY1tr.js +2 -0
- package/out/market-DN8cY1tr.js.map +1 -0
- package/out/messageList-k_zW_D0G.js +2 -0
- package/out/messageList-k_zW_D0G.js.map +1 -0
- package/out/messages-D461yIe6.js +2 -0
- package/out/messages-D461yIe6.js.map +1 -0
- package/out/missions-5zZtlLIm.js +2 -0
- package/out/missions-5zZtlLIm.js.map +1 -0
- package/out/module-BEPeTBhK.js +2 -0
- package/out/module-BEPeTBhK.js.map +1 -0
- package/out/multiIp-CP3lub1T.js +2 -0
- package/out/multiIp-CP3lub1T.js.map +1 -0
- package/out/new-star-BaVTTcIn.js +2 -0
- package/out/new-star-BaVTTcIn.js.map +1 -0
- package/out/news-BdDDcd-M.js +2 -0
- package/out/news-BdDDcd-M.js.map +1 -0
- package/out/news-Dd1C9JDl.js +2 -0
- package/out/news-Dd1C9JDl.js.map +1 -0
- package/out/notes-DLngBta3.js +2 -0
- package/out/notes-DLngBta3.js.map +1 -0
- package/out/overview-CzcSTNla.js +2 -0
- package/out/overview-CzcSTNla.js.map +1 -0
- package/out/overview-wQWIR_CB.js +2 -0
- package/out/overview-wQWIR_CB.js.map +1 -0
- package/out/password-ZA_1lStC.js +2 -0
- package/out/password-ZA_1lStC.js.map +1 -0
- package/out/phalanx-DaMaoJCT.js +2 -0
- package/out/phalanx-DaMaoJCT.js.map +1 -0
- package/out/planet-CecZ2cAZ.js +2 -0
- package/out/planet-CecZ2cAZ.js.map +1 -0
- package/out/playerCard-BG711xQi.js +2 -0
- package/out/playerCard-BG711xQi.js.map +1 -0
- package/out/post-C_ywAss7.js +2 -0
- package/out/post-C_ywAss7.js.map +1 -0
- package/out/production-D8SZfez8.js +2 -0
- package/out/production-D8SZfez8.js.map +1 -0
- package/out/public-TVVf75qu.js +2 -0
- package/out/public-TVVf75qu.js.map +1 -0
- package/out/questions-NwzZ5_fL.js +2 -0
- package/out/questions-NwzZ5_fL.js.map +1 -0
- package/out/quickEditor-DEJQFH0f.js +2 -0
- package/out/quickEditor-DEJQFH0f.js.map +1 -0
- package/out/records-CDVglYGy.js +2 -0
- package/out/records-CDVglYGy.js.map +1 -0
- package/out/records-Djjz9kxk.js +2 -0
- package/out/records-Djjz9kxk.js.map +1 -0
- package/out/reduceFleet-y8p89weR.js +2 -0
- package/out/reduceFleet-y8p89weR.js.map +1 -0
- package/out/reduceResources-CnGJ9fuf.js +2 -0
- package/out/reduceResources-CnGJ9fuf.js.map +1 -0
- package/out/refreshStatistics-CjGWyNc_.js +2 -0
- package/out/refreshStatistics-CjGWyNc_.js.map +1 -0
- package/out/register-4x5hZcWe.js +2 -0
- package/out/register-4x5hZcWe.js.map +1 -0
- package/out/research-dTK3-tOW.js +2 -0
- package/out/research-dTK3-tOW.js.map +1 -0
- package/out/reset-CHiMI9rj.js +2 -0
- package/out/reset-CHiMI9rj.js.map +1 -0
- package/out/resources-CjnevA41.js +2 -0
- package/out/resources-CjnevA41.js.map +1 -0
- package/out/rights-WPf-j_YF.js +2 -0
- package/out/rights-WPf-j_YF.js.map +1 -0
- package/out/rules-E29jtQRj.js +2 -0
- package/out/rules-E29jtQRj.js.map +1 -0
- package/out/runner-C2bQQS2G.js +43 -0
- package/out/runner-C2bQQS2G.js.map +1 -0
- package/out/scan-RvWZeyyM.js +2 -0
- package/out/scan-RvWZeyyM.js.map +1 -0
- package/out/screens-CZ4g-KNp.js +2 -0
- package/out/screens-CZ4g-KNp.js.map +1 -0
- package/out/search-BYvqiUBF.js +2 -0
- package/out/search-BYvqiUBF.js.map +1 -0
- package/out/search-auPbK2Xc.js +2 -0
- package/out/search-auPbK2Xc.js.map +1 -0
- package/out/sendMessages-B2Uj3PW4.js +2 -0
- package/out/sendMessages-B2Uj3PW4.js.map +1 -0
- package/out/settings-DFFa6Ush.js +2 -0
- package/out/settings-DFFa6Ush.js.map +1 -0
- package/out/settings-Ddez5x9U.js +2 -0
- package/out/settings-Ddez5x9U.js.map +1 -0
- package/out/shared-DoaW4mlX.js +2 -0
- package/out/shared-DoaW4mlX.js.map +1 -0
- package/out/shipyard-DXr745hR.js +2 -0
- package/out/shipyard-DXr745hR.js.map +1 -0
- package/out/shops-CEE02c0g.js +2 -0
- package/out/shops-CEE02c0g.js.map +1 -0
- package/out/snapshot-CrJ8l50N.js +2 -0
- package/out/snapshot-CrJ8l50N.js.map +1 -0
- package/out/social-1Gdni-jZ.js +2 -0
- package/out/social-1Gdni-jZ.js.map +1 -0
- package/out/spec-CrkWB0BN.js +2 -0
- package/out/spec-CrkWB0BN.js.map +1 -0
- package/out/statistics-zg3aVAvW.js +2 -0
- package/out/statistics-zg3aVAvW.js.map +1 -0
- package/out/store-dXG7NoB4.js +2 -0
- package/out/store-dXG7NoB4.js.map +1 -0
- package/out/support-DisUQr57.js +2 -0
- package/out/support-DisUQr57.js.map +1 -0
- package/out/techtree-Ba3FEH5_.js +2 -0
- package/out/techtree-Ba3FEH5_.js.map +1 -0
- package/out/ticket-O_8jTKW8.js +2 -0
- package/out/ticket-O_8jTKW8.js.map +1 -0
- package/out/trader-zFDGaHZ9.js +2 -0
- package/out/trader-zFDGaHZ9.js.map +1 -0
- package/out/universe-DO32RnLQ.js +2 -0
- package/out/universe-DO32RnLQ.js.map +1 -0
- package/out/universeSettings-S7enRJR4.js +2 -0
- package/out/universeSettings-S7enRJR4.js.map +1 -0
- package/out/values-gwcnIHXs.js +2 -0
- package/out/values-gwcnIHXs.js.map +1 -0
- package/out/verify-sYnZ9juV.js +2 -0
- package/out/verify-sYnZ9juV.js.map +1 -0
- package/out/version-Cgs-grc5.js +2 -0
- package/out/version-Cgs-grc5.js.map +1 -0
- package/package.json +65 -4
- package/src/admin.ts +317 -0
- package/src/arguments.ts +323 -0
- package/src/catalog.ts +117 -0
- package/src/cli.ts +29 -0
- package/src/commands/admin/accountEditor.ts +33 -0
- package/src/commands/admin/active.ts +25 -0
- package/src/commands/admin/ban.ts +59 -0
- package/src/commands/admin/clearCache.ts +12 -0
- package/src/commands/admin/create.ts +59 -0
- package/src/commands/admin/cronjob.ts +94 -0
- package/src/commands/admin/dump.ts +25 -0
- package/src/commands/admin/flyingFleet.ts +25 -0
- package/src/commands/admin/giveaway.ts +37 -0
- package/src/commands/admin/information.ts +12 -0
- package/src/commands/admin/log.ts +37 -0
- package/src/commands/admin/login.ts +15 -0
- package/src/commands/admin/logout.ts +12 -0
- package/src/commands/admin/messageList.ts +19 -0
- package/src/commands/admin/module.ts +25 -0
- package/src/commands/admin/multiIp.ts +25 -0
- package/src/commands/admin/news.ts +40 -0
- package/src/commands/admin/overview.ts +12 -0
- package/src/commands/admin/password.ts +18 -0
- package/src/commands/admin/quickEditor.ts +30 -0
- package/src/commands/admin/refreshStatistics.ts +12 -0
- package/src/commands/admin/reset.ts +26 -0
- package/src/commands/admin/rights.ts +68 -0
- package/src/commands/admin/search.ts +31 -0
- package/src/commands/admin/sendMessages.ts +26 -0
- package/src/commands/admin/support.ts +48 -0
- package/src/commands/admin/universe.ts +49 -0
- package/src/commands/admin/universeSettings.ts +32 -0
- package/src/commands/game/achievements.ts +18 -0
- package/src/commands/game/alliance.ts +248 -0
- package/src/commands/game/allianceAdmin.ts +236 -0
- package/src/commands/game/arsenal.ts +12 -0
- package/src/commands/game/banList.ts +20 -0
- package/src/commands/game/battleHall.ts +21 -0
- package/src/commands/game/battleReport.ts +20 -0
- package/src/commands/game/battleSimulator.ts +41 -0
- package/src/commands/game/board.ts +12 -0
- package/src/commands/game/bonusSummary.ts +12 -0
- package/src/commands/game/buddyList.ts +76 -0
- package/src/commands/game/buildings.ts +81 -0
- package/src/commands/game/chat.ts +12 -0
- package/src/commands/game/containers.ts +33 -0
- package/src/commands/game/control.ts +16 -0
- package/src/commands/game/createMoon.ts +28 -0
- package/src/commands/game/dailyBonus.ts +18 -0
- package/src/commands/game/delivery.ts +34 -0
- package/src/commands/game/endpoints.ts +61 -0
- package/src/commands/game/findDebris.ts +16 -0
- package/src/commands/game/fleetAjax.ts +24 -0
- package/src/commands/game/fleetDealer.ts +36 -0
- package/src/commands/game/fleetMissile.ts +25 -0
- package/src/commands/game/fleetStep1.ts +74 -0
- package/src/commands/game/fleetStep2.ts +27 -0
- package/src/commands/game/fleetStep3.ts +28 -0
- package/src/commands/game/fleetTable.ts +96 -0
- package/src/commands/game/galaxy.ts +26 -0
- package/src/commands/game/growth.ts +313 -0
- package/src/commands/game/information.ts +56 -0
- package/src/commands/game/logout.ts +12 -0
- package/src/commands/game/market.ts +67 -0
- package/src/commands/game/messages.ts +129 -0
- package/src/commands/game/notes.ts +65 -0
- package/src/commands/game/overview.ts +49 -0
- package/src/commands/game/phalanx.ts +23 -0
- package/src/commands/game/planet.ts +78 -0
- package/src/commands/game/playerCard.ts +20 -0
- package/src/commands/game/questions.ts +23 -0
- package/src/commands/game/records.ts +16 -0
- package/src/commands/game/reduceFleet.ts +41 -0
- package/src/commands/game/reduceResources.ts +35 -0
- package/src/commands/game/research.ts +80 -0
- package/src/commands/game/resources.ts +49 -0
- package/src/commands/game/scan.ts +12 -0
- package/src/commands/game/search.ts +44 -0
- package/src/commands/game/settings.ts +121 -0
- package/src/commands/game/shipyard.ts +61 -0
- package/src/commands/game/shops.ts +89 -0
- package/src/commands/game/statistics.ts +22 -0
- package/src/commands/game/store.ts +12 -0
- package/src/commands/game/techtree.ts +16 -0
- package/src/commands/game/ticket.ts +44 -0
- package/src/commands/game/trader.ts +51 -0
- package/src/commands/game/workflows/fleet.ts +12 -0
- package/src/commands/game/workflows/snapshot.ts +84 -0
- package/src/commands/game/workflows/social.ts +37 -0
- package/src/commands/http/get.ts +13 -0
- package/src/commands/http/post.ts +44 -0
- package/src/commands/public/banList.ts +21 -0
- package/src/commands/public/battleHall.ts +20 -0
- package/src/commands/public/battleReport.ts +20 -0
- package/src/commands/public/board.ts +20 -0
- package/src/commands/public/disclaimer.ts +20 -0
- package/src/commands/public/externalAuth.ts +17 -0
- package/src/commands/public/index.ts +22 -0
- package/src/commands/public/login.ts +20 -0
- package/src/commands/public/lostPassword.ts +57 -0
- package/src/commands/public/news.ts +20 -0
- package/src/commands/public/register.ts +46 -0
- package/src/commands/public/rules.ts +20 -0
- package/src/commands/public/screens.ts +20 -0
- package/src/commands/public/verify.ts +38 -0
- package/src/commands/rules/new-star.ts +221 -0
- package/src/commands/rules/production.ts +51 -0
- package/src/completion/BifrostCompletion.psm1 +47 -0
- package/src/completion.ts +445 -0
- package/src/connection.ts +106 -0
- package/src/destination.ts +64 -0
- package/src/game.ts +978 -0
- package/src/help.ts +203 -0
- package/src/i18n.ts +45 -0
- package/src/index.ts +2 -0
- package/src/input/admin/accountEditor.ts +156 -0
- package/src/input/admin/ban.ts +23 -0
- package/src/input/admin/create.ts +36 -0
- package/src/input/admin/cronjob.ts +22 -0
- package/src/input/admin/fields.ts +432 -0
- package/src/input/admin/login.ts +9 -0
- package/src/input/admin/messageList.ts +21 -0
- package/src/input/admin/news.ts +29 -0
- package/src/input/admin/quickEditor.ts +115 -0
- package/src/input/admin/records.ts +68 -0
- package/src/input/admin/reset.ts +29 -0
- package/src/input/admin/search.ts +23 -0
- package/src/input/admin/sendMessages.ts +21 -0
- package/src/input/admin/universeSettings.ts +46 -0
- package/src/input/files.ts +65 -0
- package/src/input/game/allianceAdmin.ts +55 -0
- package/src/input/game/battleSimulator.ts +25 -0
- package/src/input/game/fleetStep1.ts +14 -0
- package/src/input/game/settings.ts +46 -0
- package/src/input/game/ticket.ts +16 -0
- package/src/input/parse.ts +173 -0
- package/src/input/paths.ts +392 -0
- package/src/input/protocol/context.ts +10 -0
- package/src/input/protocol/missions.ts +6 -0
- package/src/input/protocol/routes.ts +15 -0
- package/src/input/protocol/settings.ts +126 -0
- package/src/input/protocol/values.ts +13 -0
- package/src/input/public/externalAuth.ts +26 -0
- package/src/input/public/register.ts +9 -0
- package/src/input/rules/new-star.ts +21 -0
- package/src/input/rules/production.ts +14 -0
- package/src/input/shared.ts +51 -0
- package/src/input/spec.ts +155 -0
- package/src/input/values.ts +114 -0
- package/src/input/workflows/fleet.ts +22 -0
- package/src/input/workflows/snapshot.ts +74 -0
- package/src/locales/en-US/commands.ts +377 -0
- package/src/locales/en-US/diagnostics.ts +89 -0
- package/src/locales/en-US.ts +61 -0
- package/src/locales/zh-CN/commands.ts +307 -0
- package/src/locales/zh-CN/diagnostics.ts +81 -0
- package/src/locales/zh-CN.ts +57 -0
- package/src/options.ts +48 -0
- package/src/output.ts +201 -0
- package/src/pointer.ts +46 -0
- package/src/presentation.ts +96 -0
- package/src/public.ts +99 -0
- package/src/registry.ts +67 -0
- package/src/requests.ts +13 -0
- package/src/result.ts +27 -0
- package/src/rules.ts +77 -0
- package/src/runner.ts +214 -0
- package/src/selection.ts +44 -0
- package/src/terminal.ts +27 -0
- package/src/types.ts +110 -0
- package/src/version.ts +11 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AdminSearchRequest, AdminSearchTarget } from '@senators/bifrost'
|
|
2
|
+
|
|
3
|
+
import { enumeration, numberInput, optional, required, stringInput } from '../spec.ts'
|
|
4
|
+
import type { InputSpec } from '../spec.ts'
|
|
5
|
+
|
|
6
|
+
export const adminSearchRequestInput: InputSpec<AdminSearchRequest> = {
|
|
7
|
+
kind: 'object',
|
|
8
|
+
fields: {
|
|
9
|
+
term: required(stringInput),
|
|
10
|
+
kind: required(stringInput),
|
|
11
|
+
field: optional(stringInput),
|
|
12
|
+
match: optional(stringInput),
|
|
13
|
+
page: optional(numberInput),
|
|
14
|
+
limit: optional(numberInput),
|
|
15
|
+
order: optional(stringInput),
|
|
16
|
+
sortBy: optional(stringInput),
|
|
17
|
+
},
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const adminSearchTargetInput: InputSpec<AdminSearchTarget> = {
|
|
21
|
+
kind: 'object',
|
|
22
|
+
fields: { type: required(enumeration(['player', 'planet'])), id: required(numberInput) },
|
|
23
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AdminBroadcastChannel, AdminBroadcast } from '@senators/bifrost'
|
|
2
|
+
|
|
3
|
+
import { enumeration, nonEmptyStringInput, optional, required, stringInput } from '../spec.ts'
|
|
4
|
+
import type { InputSpec } from '../spec.ts'
|
|
5
|
+
|
|
6
|
+
const adminBroadcastChannelInput: InputSpec<AdminBroadcastChannel> = enumeration([0, 1, 2])
|
|
7
|
+
|
|
8
|
+
export const adminBroadcastInput: InputSpec<AdminBroadcast> = {
|
|
9
|
+
kind: 'object',
|
|
10
|
+
fields: {
|
|
11
|
+
channel: required(adminBroadcastChannelInput),
|
|
12
|
+
/**
|
|
13
|
+
* An empty language is the server's "all languages" choice, not a missing value.
|
|
14
|
+
*
|
|
15
|
+
* 空语言是服务端的「全部语言」选项,而不是缺失值。
|
|
16
|
+
*/
|
|
17
|
+
language: optional(stringInput),
|
|
18
|
+
subject: required(nonEmptyStringInput),
|
|
19
|
+
text: required(nonEmptyStringInput),
|
|
20
|
+
},
|
|
21
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AdminUniverseSettingKey,
|
|
3
|
+
AdminUniverseSettingsPage,
|
|
4
|
+
AdminUniverseSettingsSetting,
|
|
5
|
+
} from '@senators/bifrost'
|
|
6
|
+
|
|
7
|
+
import { enumeration, numberInput, required, stringInput, unionInput } from '../spec.ts'
|
|
8
|
+
import type { InputSpec } from '../spec.ts'
|
|
9
|
+
import { adminUniverseSettingFields } from './fields.ts'
|
|
10
|
+
import { adminDocumentInput, adminPatchInput, adminRecordInput } from './records.ts'
|
|
11
|
+
|
|
12
|
+
const settingInput: InputSpec<AdminUniverseSettingsSetting> = {
|
|
13
|
+
kind: 'object',
|
|
14
|
+
additional: true,
|
|
15
|
+
fields: { section: required(stringInput), value: required(stringInput) },
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Complete stored settings preserve every value omitted from a patch.
|
|
20
|
+
*
|
|
21
|
+
* 完整配置记录保留补丁未修改的每个值。
|
|
22
|
+
*/
|
|
23
|
+
const universeSettingsPageInput: InputSpec<AdminUniverseSettingsPage> = {
|
|
24
|
+
kind: 'object',
|
|
25
|
+
additional: true,
|
|
26
|
+
fields: {
|
|
27
|
+
kind: required(enumeration(['adminUniverseSettings'])),
|
|
28
|
+
observedAtMs: required(numberInput),
|
|
29
|
+
settings: required(
|
|
30
|
+
adminRecordInput<AdminUniverseSettingKey, AdminUniverseSettingsSetting>(
|
|
31
|
+
adminUniverseSettingFields,
|
|
32
|
+
settingInput,
|
|
33
|
+
true,
|
|
34
|
+
),
|
|
35
|
+
),
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const adminUniverseSettingsPageInput: InputSpec<AdminUniverseSettingsPage> =
|
|
40
|
+
adminDocumentInput(universeSettingsPageInput)
|
|
41
|
+
export const adminUniverseSettingsPatchInput: InputSpec<
|
|
42
|
+
Readonly<Partial<Record<AdminUniverseSettingKey, string | number>>>
|
|
43
|
+
> = adminPatchInput<AdminUniverseSettingKey, string | number>(
|
|
44
|
+
adminUniverseSettingFields,
|
|
45
|
+
unionInput(stringInput, numberInput),
|
|
46
|
+
)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises'
|
|
2
|
+
import { resolve } from 'node:path'
|
|
3
|
+
|
|
4
|
+
import { messages } from '../i18n.ts'
|
|
5
|
+
import { parsePointer, selectPointer } from '../pointer.ts'
|
|
6
|
+
import { UsageError } from '../result.ts'
|
|
7
|
+
import type { JsonSource } from '../types.ts'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Resolves `@FILE`, `@-` and `-` references, sharing parsed documents within one invocation.
|
|
11
|
+
*
|
|
12
|
+
* 解析 `@FILE`、`@-` 与 `-` 引用,并在单次调用内共享已解析的文档。
|
|
13
|
+
*/
|
|
14
|
+
export type InputSource = (reference: string) => Promise<unknown>
|
|
15
|
+
|
|
16
|
+
export function parseJson(text: string, source: JsonSource): unknown {
|
|
17
|
+
try {
|
|
18
|
+
return JSON.parse(text)
|
|
19
|
+
} catch {
|
|
20
|
+
throw new UsageError(messages().diagnostics.invalidJson(source))
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Read an argument that holds inline JSON or a reference, so any failure names that argument.
|
|
26
|
+
*
|
|
27
|
+
* 读取内联 JSON 或引用的参数,使失败信息点名该参数。
|
|
28
|
+
*/
|
|
29
|
+
export async function readArgument(
|
|
30
|
+
value: string,
|
|
31
|
+
source: 'input' | 'select' | 'session',
|
|
32
|
+
read: InputSource,
|
|
33
|
+
): Promise<unknown> {
|
|
34
|
+
return value === '-' || value.startsWith('@') ? read(value) : parseJson(value, source)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* References share parsed documents within one invocation; imported strings remain literal.
|
|
39
|
+
*
|
|
40
|
+
* 单次调用中的引用共享已解析的文档;导入的字符串保持字面值。
|
|
41
|
+
*/
|
|
42
|
+
export function createInputSource(stdin: () => string | Promise<string>): InputSource {
|
|
43
|
+
let standardInput: Promise<unknown> | undefined
|
|
44
|
+
const files = new Map<string, Promise<unknown>>()
|
|
45
|
+
return async (reference) => {
|
|
46
|
+
const separator = reference.indexOf('#')
|
|
47
|
+
const filename =
|
|
48
|
+
reference === '-' ? '-' : separator < 0 ? reference.slice(1) : reference.slice(1, separator)
|
|
49
|
+
if (filename === '') throw new UsageError(messages().diagnostics.referenceFilename)
|
|
50
|
+
const parts = parsePointer(separator < 0 ? '' : reference.slice(separator + 1))
|
|
51
|
+
if (filename === '-') {
|
|
52
|
+
standardInput ??= Promise.resolve()
|
|
53
|
+
.then(stdin)
|
|
54
|
+
.then((text) => parseJson(text, 'stdin'))
|
|
55
|
+
return selectPointer(await standardInput, parts)
|
|
56
|
+
}
|
|
57
|
+
const path = resolve(filename)
|
|
58
|
+
let document = files.get(path)
|
|
59
|
+
if (document === undefined) {
|
|
60
|
+
document = readFile(path, 'utf8').then((text) => parseJson(text, 'file'))
|
|
61
|
+
files.set(path, document)
|
|
62
|
+
}
|
|
63
|
+
return selectPointer(await document, parts)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { AllianceAdminOverviewPage, AllianceRankChange } from '@senators/bifrost'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
isAllianceSettingsValues,
|
|
5
|
+
isAllianceTextKind,
|
|
6
|
+
isFormChoices,
|
|
7
|
+
} from '../protocol/settings.ts'
|
|
8
|
+
import { arrayInput, enumeration, numberInput, required, stringInput, unionInput } from '../spec.ts'
|
|
9
|
+
import type { InputSpec } from '../spec.ts'
|
|
10
|
+
import { isBoolean, isNumber, isObject } from '../values.ts'
|
|
11
|
+
|
|
12
|
+
export function isAllianceAdminOverviewPage(value: unknown): value is AllianceAdminOverviewPage {
|
|
13
|
+
return (
|
|
14
|
+
isObject(value) &&
|
|
15
|
+
value.kind === 'allianceAdminOverview' &&
|
|
16
|
+
isNumber(value.observedAtMs) &&
|
|
17
|
+
isAllianceTextKind(value.textKind) &&
|
|
18
|
+
isAllianceSettingsValues(value) &&
|
|
19
|
+
isFormChoices(
|
|
20
|
+
value.choices,
|
|
21
|
+
['applicationsClosed', 'showStatistics', 'showDiplomacy'],
|
|
22
|
+
isBoolean,
|
|
23
|
+
) &&
|
|
24
|
+
isFormChoices(value.choices, ['eventMissions'], isNumber)
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const allianceAdminOverviewInput: InputSpec<AllianceAdminOverviewPage> = {
|
|
29
|
+
kind: 'document',
|
|
30
|
+
accepts: isAllianceAdminOverviewPage,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const allianceRankChangeInput: InputSpec<AllianceRankChange> = unionInput(
|
|
34
|
+
{
|
|
35
|
+
kind: 'object',
|
|
36
|
+
fields: {
|
|
37
|
+
operation: required(enumeration(['create'])),
|
|
38
|
+
name: required(stringInput),
|
|
39
|
+
rights: required(arrayInput(numberInput)),
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
kind: 'object',
|
|
44
|
+
fields: {
|
|
45
|
+
operation: required(enumeration(['update'])),
|
|
46
|
+
id: required(numberInput),
|
|
47
|
+
name: required(stringInput),
|
|
48
|
+
rights: required(arrayInput(numberInput)),
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
kind: 'object',
|
|
53
|
+
fields: { operation: required(enumeration(['delete'])), id: required(numberInput) },
|
|
54
|
+
},
|
|
55
|
+
)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { BattleParticipantInput, BattleSimulatorPage } from '@senators/bifrost'
|
|
2
|
+
|
|
3
|
+
import { elementInput } from '../shared.ts'
|
|
4
|
+
import { arrayInput, numberInput, optional, required } from '../spec.ts'
|
|
5
|
+
import type { InputSpec } from '../spec.ts'
|
|
6
|
+
import { isObject, isArrayOf, isNumber } from '../values.ts'
|
|
7
|
+
|
|
8
|
+
export const battleParticipantInput: InputSpec<BattleParticipantInput> = {
|
|
9
|
+
kind: 'object',
|
|
10
|
+
fields: { units: required(elementInput), bonuses: optional(elementInput) },
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function isBattleCatalog(value: unknown): value is Pick<BattleSimulatorPage, 'bonusIds'> {
|
|
14
|
+
return isObject(value) && isArrayOf(value.bonusIds, isNumber)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const battleCatalogInput: InputSpec<Pick<BattleSimulatorPage, 'bonusIds'>> = {
|
|
18
|
+
kind: 'document',
|
|
19
|
+
accepts: isBattleCatalog,
|
|
20
|
+
input: {
|
|
21
|
+
kind: 'object',
|
|
22
|
+
fields: { bonusIds: required(arrayInput(numberInput)) },
|
|
23
|
+
additional: true,
|
|
24
|
+
},
|
|
25
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ShortcutInput } from '@senators/bifrost'
|
|
2
|
+
|
|
3
|
+
import { locationInput } from '../shared.ts'
|
|
4
|
+
import { numberInput, optional, required, stringInput } from '../spec.ts'
|
|
5
|
+
import type { InputSpec } from '../spec.ts'
|
|
6
|
+
|
|
7
|
+
export const shortcutInput: InputSpec<ShortcutInput> = {
|
|
8
|
+
kind: 'object',
|
|
9
|
+
fields: {
|
|
10
|
+
id: optional(numberInput),
|
|
11
|
+
name: required(stringInput),
|
|
12
|
+
target: required(locationInput),
|
|
13
|
+
},
|
|
14
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { AccountSettingsPage, SettingsPage } from '@senators/bifrost'
|
|
2
|
+
|
|
3
|
+
import type { Fields } from '../../types.ts'
|
|
4
|
+
import { isAccountSettingsValues, isFormChoices } from '../protocol/settings.ts'
|
|
5
|
+
import type { InputSpec } from '../spec.ts'
|
|
6
|
+
import { isBoolean, isNumber, isObject, isString, optionalFieldsMatch } from '../values.ts'
|
|
7
|
+
|
|
8
|
+
function isSettingsObservation(value: unknown): value is Fields {
|
|
9
|
+
return (
|
|
10
|
+
isObject(value) &&
|
|
11
|
+
value.kind === 'settings' &&
|
|
12
|
+
isNumber(value.observedAtMs) &&
|
|
13
|
+
isBoolean(value.accountDeletionChecked)
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function isAccountSettingsPage(value: unknown): value is AccountSettingsPage {
|
|
18
|
+
return (
|
|
19
|
+
isSettingsObservation(value) &&
|
|
20
|
+
value.onVacation === false &&
|
|
21
|
+
value.hasLeaveVacationControl === false &&
|
|
22
|
+
isAccountSettingsValues(value) &&
|
|
23
|
+
isString(value.email) &&
|
|
24
|
+
optionalFieldsMatch(value, ['username'], isString) &&
|
|
25
|
+
isFormChoices(value.choices, ['timezone', 'language', 'theme'], isString) &&
|
|
26
|
+
isFormChoices(value.choices, ['planetSort', 'planetOrder'], isNumber)
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function isSettingsPage(value: unknown): value is SettingsPage {
|
|
31
|
+
return (
|
|
32
|
+
isAccountSettingsPage(value) ||
|
|
33
|
+
(isSettingsObservation(value) &&
|
|
34
|
+
value.onVacation === true &&
|
|
35
|
+
isBoolean(value.hasLeaveVacationControl))
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const accountSettingsPageInput: InputSpec<AccountSettingsPage> = {
|
|
40
|
+
kind: 'document',
|
|
41
|
+
accepts: isAccountSettingsPage,
|
|
42
|
+
}
|
|
43
|
+
export const settingsPageInput: InputSpec<SettingsPage> = {
|
|
44
|
+
kind: 'document',
|
|
45
|
+
accepts: isSettingsPage,
|
|
46
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { TicketDraft, TicketReply } from '@senators/bifrost'
|
|
2
|
+
|
|
3
|
+
import { numberInput, required, stringInput, unionInput } from '../spec.ts'
|
|
4
|
+
import type { InputSpec } from '../spec.ts'
|
|
5
|
+
|
|
6
|
+
export const ticketInput: InputSpec<TicketReply | TicketDraft> = unionInput(
|
|
7
|
+
{ kind: 'object', fields: { ticketId: required(numberInput), text: required(stringInput) } },
|
|
8
|
+
{
|
|
9
|
+
kind: 'object',
|
|
10
|
+
fields: {
|
|
11
|
+
categoryId: required(stringInput),
|
|
12
|
+
subject: required(stringInput),
|
|
13
|
+
text: required(stringInput),
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
)
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { messages } from '../i18n.ts'
|
|
2
|
+
import { UsageError } from '../result.ts'
|
|
3
|
+
import type { InputNode, InputSpec } from './spec.ts'
|
|
4
|
+
import { fieldPath, isArrayOf, isMap, isNumber, isObject, numberKey } from './values.ts'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Decode only declared containers; document metadata retains its identity.
|
|
8
|
+
*
|
|
9
|
+
* 仅转换声明的容器;文档元数据保留自身引用。
|
|
10
|
+
*/
|
|
11
|
+
export function readInput(schema: InputNode, input: unknown): unknown {
|
|
12
|
+
switch (schema.kind) {
|
|
13
|
+
case 'object':
|
|
14
|
+
if (!isObject(input)) return input
|
|
15
|
+
return Object.fromEntries(
|
|
16
|
+
Object.entries(input).map(([name, value]) => {
|
|
17
|
+
const field = Object.hasOwn(schema.fields, name) ? schema.fields[name] : undefined
|
|
18
|
+
return [name, field === undefined ? value : readInput(field.schema, value)]
|
|
19
|
+
}),
|
|
20
|
+
)
|
|
21
|
+
case 'array':
|
|
22
|
+
return Array.isArray(input)
|
|
23
|
+
? input.map((value: unknown) => readInput(schema.item, value))
|
|
24
|
+
: input
|
|
25
|
+
case 'map': {
|
|
26
|
+
if (!isObject(input)) return input
|
|
27
|
+
const result = new Map<unknown, unknown>()
|
|
28
|
+
for (const [name, value] of Object.entries(input)) {
|
|
29
|
+
const key = numericKey(schema.key) ? numberKey(name) : name
|
|
30
|
+
if (key === undefined || !matchesInput(schema.key, key))
|
|
31
|
+
throw new UsageError(messages().diagnostics.invalidMapKey(JSON.stringify(name)))
|
|
32
|
+
result.set(key, readInput(schema.value, value))
|
|
33
|
+
}
|
|
34
|
+
return result
|
|
35
|
+
}
|
|
36
|
+
case 'union':
|
|
37
|
+
for (const variant of schema.variants) {
|
|
38
|
+
let value: unknown
|
|
39
|
+
try {
|
|
40
|
+
value = readInput(variant, input)
|
|
41
|
+
} catch (error) {
|
|
42
|
+
if (!(error instanceof UsageError)) throw error
|
|
43
|
+
continue
|
|
44
|
+
}
|
|
45
|
+
if (matchesInput(variant, value)) return value
|
|
46
|
+
}
|
|
47
|
+
return input
|
|
48
|
+
case 'document':
|
|
49
|
+
case 'custom':
|
|
50
|
+
return schema.read === undefined ? input : schema.read(input)
|
|
51
|
+
default:
|
|
52
|
+
return input
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function numericKey(schema: InputNode): boolean {
|
|
57
|
+
return (
|
|
58
|
+
schema.kind === 'number' ||
|
|
59
|
+
(schema.kind === 'enum' && schema.values.every((value) => typeof value === 'number'))
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function matchesInput(schema: InputNode, value: unknown): boolean {
|
|
64
|
+
switch (schema.kind) {
|
|
65
|
+
case 'string':
|
|
66
|
+
return typeof value === 'string'
|
|
67
|
+
case 'number':
|
|
68
|
+
return isNumber(value)
|
|
69
|
+
case 'boolean':
|
|
70
|
+
return typeof value === 'boolean'
|
|
71
|
+
case 'null':
|
|
72
|
+
return value === null
|
|
73
|
+
case 'enum':
|
|
74
|
+
return schema.values.some((choice) => choice === value)
|
|
75
|
+
case 'array':
|
|
76
|
+
return isArrayOf(value, (item) => matchesInput(schema.item, item))
|
|
77
|
+
case 'map':
|
|
78
|
+
return (
|
|
79
|
+
isMap(value) &&
|
|
80
|
+
[...value].every(
|
|
81
|
+
([key, item]) => matchesInput(schema.key, key) && matchesInput(schema.value, item),
|
|
82
|
+
)
|
|
83
|
+
)
|
|
84
|
+
case 'object':
|
|
85
|
+
return (
|
|
86
|
+
isObject(value) &&
|
|
87
|
+
(schema.additional === true ||
|
|
88
|
+
Object.keys(value).every((name) => Object.hasOwn(schema.fields, name))) &&
|
|
89
|
+
Object.entries(schema.fields).every(
|
|
90
|
+
([name, field]) =>
|
|
91
|
+
(field.optional && value[name] === undefined) ||
|
|
92
|
+
matchesInput(field.schema, value[name]),
|
|
93
|
+
) &&
|
|
94
|
+
(schema.check === undefined || schema.check(value))
|
|
95
|
+
)
|
|
96
|
+
case 'union':
|
|
97
|
+
return schema.variants.some((variant) => matchesInput(variant, value))
|
|
98
|
+
default:
|
|
99
|
+
return schema.accepts(value)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function matchingBranch(schema: InputNode, value: unknown): boolean {
|
|
104
|
+
if (value === undefined) return true
|
|
105
|
+
if ((schema.kind === 'custom' || schema.kind === 'document') && schema.output !== undefined)
|
|
106
|
+
return matchingBranch(schema.output, value)
|
|
107
|
+
if (schema.kind === 'enum' && schema.values.length === 1) return matchesInput(schema, value)
|
|
108
|
+
if (schema.kind === 'union')
|
|
109
|
+
return schema.variants.some((variant) => matchingBranch(variant, value))
|
|
110
|
+
if (schema.kind === 'array') return Array.isArray(value)
|
|
111
|
+
if (schema.kind === 'map') return isMap(value) || isObject(value)
|
|
112
|
+
if (schema.kind === 'object')
|
|
113
|
+
return (
|
|
114
|
+
isObject(value) &&
|
|
115
|
+
Object.entries(schema.fields).every(
|
|
116
|
+
([name, field]) => value[name] === undefined || matchingBranch(field.schema, value[name]),
|
|
117
|
+
)
|
|
118
|
+
)
|
|
119
|
+
return true
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function invalidField(schema: InputNode, value: unknown, path: string): string | undefined {
|
|
123
|
+
if (matchesInput(schema, value)) return undefined
|
|
124
|
+
if ((schema.kind === 'custom' || schema.kind === 'document') && schema.output !== undefined)
|
|
125
|
+
return invalidField(schema.output, value, path)
|
|
126
|
+
if (schema.kind === 'union') {
|
|
127
|
+
const candidates = schema.variants.filter((variant) => matchingBranch(variant, value))
|
|
128
|
+
const selected = candidates.length === 1 ? candidates[0] : undefined
|
|
129
|
+
if (selected !== undefined) return invalidField(selected, value, path)
|
|
130
|
+
}
|
|
131
|
+
if (schema.kind === 'object' && isObject(value)) {
|
|
132
|
+
if (schema.additional !== true)
|
|
133
|
+
for (const name of Object.keys(value))
|
|
134
|
+
if (!Object.hasOwn(schema.fields, name))
|
|
135
|
+
return messages().diagnostics.unknownParameter(fieldPath(path, name))
|
|
136
|
+
for (const [name, field] of Object.entries(schema.fields)) {
|
|
137
|
+
if (field.optional && value[name] === undefined) continue
|
|
138
|
+
const issue = invalidField(field.schema, value[name], fieldPath(path, name))
|
|
139
|
+
if (issue !== undefined) return issue
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (schema.kind === 'array' && Array.isArray(value))
|
|
143
|
+
for (const [index, item] of value.entries()) {
|
|
144
|
+
const issue = invalidField(schema.item, item, `${path}[${index}]`)
|
|
145
|
+
if (issue !== undefined) return issue
|
|
146
|
+
}
|
|
147
|
+
if (schema.kind === 'map' && isMap(value))
|
|
148
|
+
for (const [key, item] of value) {
|
|
149
|
+
const issue = invalidField(schema.value, item, `${path}[${String(key)}]`)
|
|
150
|
+
if (issue !== undefined) return issue
|
|
151
|
+
}
|
|
152
|
+
return path === '' ? undefined : messages().diagnostics.invalidParameter(path)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export function parseInput<Type>(schema: InputSpec<Type>, input: unknown, command: string): Type {
|
|
156
|
+
const value = readInput(schema, input)
|
|
157
|
+
checkInput<Type>(schema, value, command)
|
|
158
|
+
return value
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function checkInput<Type>(
|
|
162
|
+
schema: InputSpec<Type>,
|
|
163
|
+
value: unknown,
|
|
164
|
+
command: string,
|
|
165
|
+
path?: string,
|
|
166
|
+
): asserts value is Type
|
|
167
|
+
export function checkInput(schema: InputNode, value: unknown, command: string, path?: string): void
|
|
168
|
+
export function checkInput(schema: InputNode, value: unknown, command: string, path = ''): void {
|
|
169
|
+
if (!matchesInput(schema, value))
|
|
170
|
+
throw new UsageError(
|
|
171
|
+
invalidField(schema, value, path) ?? messages().diagnostics.invalidCommandParameters(command),
|
|
172
|
+
)
|
|
173
|
+
}
|