@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,155 @@
|
|
|
1
|
+
import type { Fields, Primitive } from '../types.ts'
|
|
2
|
+
import { isNumber } from './values.ts'
|
|
3
|
+
|
|
4
|
+
export type InputField = { schema: InputNode; optional: boolean }
|
|
5
|
+
export type InputNode = (
|
|
6
|
+
| { kind: 'string' | 'number' | 'boolean' | 'null' }
|
|
7
|
+
| { kind: 'enum'; values: readonly Primitive[] }
|
|
8
|
+
| {
|
|
9
|
+
kind: 'object'
|
|
10
|
+
fields: Readonly<Record<string, InputField>>
|
|
11
|
+
additional?: boolean
|
|
12
|
+
check?: (value: Fields) => boolean
|
|
13
|
+
}
|
|
14
|
+
| { kind: 'array'; item: InputNode }
|
|
15
|
+
| { kind: 'map'; key: InputNode; value: InputNode }
|
|
16
|
+
| { kind: 'union'; variants: readonly InputNode[] }
|
|
17
|
+
| {
|
|
18
|
+
kind: 'document' | 'custom'
|
|
19
|
+
accepts: (value: unknown) => boolean
|
|
20
|
+
read?: (value: unknown) => unknown
|
|
21
|
+
input?: InputNode
|
|
22
|
+
output?: InputNode
|
|
23
|
+
}
|
|
24
|
+
) & { description?: () => string; reference?: 'command' }
|
|
25
|
+
|
|
26
|
+
type Structure<T> = T extends null
|
|
27
|
+
? { kind: 'null' }
|
|
28
|
+
: T extends string
|
|
29
|
+
? string extends T
|
|
30
|
+
? { kind: 'string' }
|
|
31
|
+
: never
|
|
32
|
+
: T extends number
|
|
33
|
+
? number extends T
|
|
34
|
+
? { kind: 'number' }
|
|
35
|
+
: never
|
|
36
|
+
: T extends boolean
|
|
37
|
+
? never
|
|
38
|
+
: T extends ReadonlyMap<infer Key, infer Value>
|
|
39
|
+
? { kind: 'map'; key: InputSpec<Key>; value: InputSpec<Value> }
|
|
40
|
+
: T extends readonly (infer Item)[]
|
|
41
|
+
? { kind: 'array'; item: InputSpec<Item> }
|
|
42
|
+
: T extends object
|
|
43
|
+
? {
|
|
44
|
+
kind: 'object'
|
|
45
|
+
fields: {
|
|
46
|
+
readonly [
|
|
47
|
+
Key in keyof T as Exclude<T[Key], undefined> extends never ? never : Key
|
|
48
|
+
]-?: {
|
|
49
|
+
schema: InputSpec<Exclude<T[Key], undefined>>
|
|
50
|
+
optional: undefined extends T[Key] ? true : false
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
: never
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Runtime input descriptions retain SDK field types, optionality and container boundaries.
|
|
58
|
+
*
|
|
59
|
+
* 运行时输入描述保留 SDK 字段类型、可选性与容器边界。
|
|
60
|
+
*/
|
|
61
|
+
export type InputSpec<T> = InputNode &
|
|
62
|
+
(
|
|
63
|
+
| Structure<T>
|
|
64
|
+
| (boolean extends T ? { kind: 'boolean' } : never)
|
|
65
|
+
| { kind: 'enum'; values: readonly Extract<T, Primitive>[] }
|
|
66
|
+
| { kind: 'union'; variants: readonly InputSpec<T>[] }
|
|
67
|
+
| {
|
|
68
|
+
kind: 'document' | 'custom'
|
|
69
|
+
accepts: (value: unknown) => value is T
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
export const stringInput: { kind: 'string' } = { kind: 'string' }
|
|
74
|
+
export const numberInput: { kind: 'number' } = { kind: 'number' }
|
|
75
|
+
export const booleanInput: { kind: 'boolean' } = { kind: 'boolean' }
|
|
76
|
+
export const nullInput: { kind: 'null' } = { kind: 'null' }
|
|
77
|
+
export const emptyInput: { kind: 'object'; fields: Record<string, never> } = {
|
|
78
|
+
kind: 'object',
|
|
79
|
+
fields: {},
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* A positive safe integer, the only count the SDK accepts where it validates one; rejecting it
|
|
84
|
+
* here keeps the failure a usage error instead of a runtime error.
|
|
85
|
+
*
|
|
86
|
+
* 正安全整数:SDK 在需要校验计数的位置只接受这一种取值,在此拒绝可让失败保持为用法错误,
|
|
87
|
+
* 而不是运行期错误。
|
|
88
|
+
*/
|
|
89
|
+
export const positiveIntegerInput: InputSpec<number> = {
|
|
90
|
+
kind: 'custom',
|
|
91
|
+
input: numberInput,
|
|
92
|
+
accepts: (value): value is number => isNumber(value) && Number.isSafeInteger(value) && value > 0,
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* A string the server refuses when empty. Accepting it would report success for a request that
|
|
97
|
+
* changes nothing.
|
|
98
|
+
*
|
|
99
|
+
* 为空时服务端会拒绝的字符串。接受空串会把一次什么也没做的请求报告为成功。
|
|
100
|
+
*/
|
|
101
|
+
export const nonEmptyStringInput: InputSpec<string> = {
|
|
102
|
+
kind: 'custom',
|
|
103
|
+
input: stringInput,
|
|
104
|
+
accepts: (value): value is string => typeof value === 'string' && value !== '',
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function required<Schema extends InputNode>(
|
|
108
|
+
schema: Schema,
|
|
109
|
+
): {
|
|
110
|
+
schema: Schema
|
|
111
|
+
optional: false
|
|
112
|
+
} {
|
|
113
|
+
return { schema, optional: false }
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function optional<Schema extends InputNode>(
|
|
117
|
+
schema: Schema,
|
|
118
|
+
): {
|
|
119
|
+
schema: Schema
|
|
120
|
+
optional: true
|
|
121
|
+
} {
|
|
122
|
+
return { schema, optional: true }
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* A choice of literal values. The `const` type parameter keeps the literals instead of widening them
|
|
127
|
+
* to their base type, so a declared field still proves it matches the SDK's own union.
|
|
128
|
+
*
|
|
129
|
+
* 字面量取值的选择。`const` 类型参数保留字面量而不放宽为其基础类型,
|
|
130
|
+
* 因此已声明的字段仍能证明它与 SDK 自身的联合类型一致。
|
|
131
|
+
*/
|
|
132
|
+
export function enumeration<const Value extends Primitive>(
|
|
133
|
+
values: readonly Value[],
|
|
134
|
+
): { kind: 'enum'; values: readonly Value[] } {
|
|
135
|
+
return { kind: 'enum', values }
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function arrayInput<Schema extends InputNode>(
|
|
139
|
+
item: Schema,
|
|
140
|
+
): { kind: 'array'; item: Schema } {
|
|
141
|
+
return { kind: 'array', item }
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export function mapInput<Key extends InputNode, Value extends InputNode>(
|
|
145
|
+
key: Key,
|
|
146
|
+
value: Value,
|
|
147
|
+
): { kind: 'map'; key: Key; value: Value } {
|
|
148
|
+
return { kind: 'map', key, value }
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function unionInput<Variants extends readonly InputNode[]>(
|
|
152
|
+
...variants: Variants
|
|
153
|
+
): { kind: 'union'; variants: Variants } {
|
|
154
|
+
return { kind: 'union', variants }
|
|
155
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { messages } from '../i18n.ts'
|
|
2
|
+
import { UsageError } from '../result.ts'
|
|
3
|
+
import type { Fields } from '../types.ts'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Named JSON fields, including queried documents with additional data.
|
|
7
|
+
*
|
|
8
|
+
* 具名 JSON 字段,允许查询文档包含额外数据。
|
|
9
|
+
*/
|
|
10
|
+
export function isFields(value: unknown): value is Fields {
|
|
11
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Maps and form containers are not ordinary input objects.
|
|
16
|
+
*
|
|
17
|
+
* Map 与表单容器不作为普通输入对象处理。
|
|
18
|
+
*/
|
|
19
|
+
export function isObject(value: unknown): value is Fields {
|
|
20
|
+
return isFields(value) && !(value instanceof Map) && !(value instanceof URLSearchParams)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function isNumber(value: unknown): value is number {
|
|
24
|
+
return typeof value === 'number' && Number.isFinite(value)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function numberKey(value: string): number | undefined {
|
|
28
|
+
const number = Number(value)
|
|
29
|
+
return Number.isFinite(number) && String(number) === value ? number : undefined
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function isString(value: unknown): value is string {
|
|
33
|
+
return typeof value === 'string'
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function isBoolean(value: unknown): value is boolean {
|
|
37
|
+
return typeof value === 'boolean'
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function isArrayOf(
|
|
41
|
+
value: unknown,
|
|
42
|
+
accepts: (input: unknown) => boolean,
|
|
43
|
+
): value is unknown[] {
|
|
44
|
+
return Array.isArray(value) && value.every(accepts)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function isScalar(value: unknown): value is string | number {
|
|
48
|
+
return isString(value) || isNumber(value)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Fields with the same primitive type share one check, while each command names them explicitly.
|
|
53
|
+
*
|
|
54
|
+
* 同一基础类型的字段复用检查逻辑,每条命令仍明确声明其字段名。
|
|
55
|
+
*/
|
|
56
|
+
export function fieldsMatch(
|
|
57
|
+
value: Fields,
|
|
58
|
+
names: readonly string[],
|
|
59
|
+
accepts: (input: unknown) => boolean,
|
|
60
|
+
): boolean {
|
|
61
|
+
return names.every((name) => accepts(value[name]))
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function optionalFieldsMatch(
|
|
65
|
+
value: Fields,
|
|
66
|
+
names: readonly string[],
|
|
67
|
+
accepts: (input: unknown) => boolean,
|
|
68
|
+
): boolean {
|
|
69
|
+
return names.every((name) => value[name] === undefined || accepts(value[name]))
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function isMap(value: unknown): value is Map<unknown, unknown> {
|
|
73
|
+
return value instanceof Map
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function isChoice(value: unknown, choices: readonly unknown[]): boolean {
|
|
77
|
+
return choices.includes(value)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function fieldPath(path: string, name: string): string {
|
|
81
|
+
return path === '' ? name : `${path}.${name}`
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Reject unknown names in a field record whose object shape is already checked.
|
|
86
|
+
*
|
|
87
|
+
* 拒绝已确认对象结构的字段记录中的未知名称。
|
|
88
|
+
*/
|
|
89
|
+
export function checkNames(value: Fields, names: readonly string[], path: string): void {
|
|
90
|
+
for (const name of Object.keys(value))
|
|
91
|
+
if (!names.includes(name))
|
|
92
|
+
throw new UsageError(messages().diagnostics.unknownParameter(fieldPath(path, name)))
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Restore repeated form fields without losing their order or invalid input.
|
|
97
|
+
*
|
|
98
|
+
* 按原顺序还原重复表单字段;无效输入保留给命令守卫判断。
|
|
99
|
+
*/
|
|
100
|
+
export function readParameters(value: unknown): unknown {
|
|
101
|
+
if (!Array.isArray(value)) return value
|
|
102
|
+
const parameters = new URLSearchParams()
|
|
103
|
+
for (const pair of value) {
|
|
104
|
+
if (
|
|
105
|
+
!Array.isArray(pair) ||
|
|
106
|
+
pair.length !== 2 ||
|
|
107
|
+
typeof pair[0] !== 'string' ||
|
|
108
|
+
typeof pair[1] !== 'string'
|
|
109
|
+
)
|
|
110
|
+
return value
|
|
111
|
+
parameters.append(pair[0], pair[1])
|
|
112
|
+
}
|
|
113
|
+
return parameters
|
|
114
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DispatchFleetOptions } from '@senators/bifrost'
|
|
2
|
+
|
|
3
|
+
import { fleetMissionInput } from '../protocol/missions.ts'
|
|
4
|
+
import { fleetSpeedInput } from '../protocol/values.ts'
|
|
5
|
+
import { elementInput, locationInput, planetReferenceInput, resourceInput } from '../shared.ts'
|
|
6
|
+
import { numberInput, optional, required } from '../spec.ts'
|
|
7
|
+
import type { InputSpec } from '../spec.ts'
|
|
8
|
+
|
|
9
|
+
export const dispatchFleetInput: InputSpec<DispatchFleetOptions> = {
|
|
10
|
+
kind: 'object',
|
|
11
|
+
fields: {
|
|
12
|
+
cargo: optional(resourceInput),
|
|
13
|
+
fleetGroupId: optional(numberInput),
|
|
14
|
+
mission: required(fleetMissionInput),
|
|
15
|
+
origin: required(planetReferenceInput),
|
|
16
|
+
sector: optional(numberInput),
|
|
17
|
+
ships: required(elementInput),
|
|
18
|
+
speed: required(fleetSpeedInput),
|
|
19
|
+
stayOption: optional(numberInput),
|
|
20
|
+
target: required(locationInput),
|
|
21
|
+
},
|
|
22
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AccountSnapshotOptions,
|
|
3
|
+
PlanetSnapshotOptions,
|
|
4
|
+
SnapshotRequest,
|
|
5
|
+
} from '@senators/bifrost'
|
|
6
|
+
|
|
7
|
+
import type { Fields, SnapshotDescriptor } from '../../types.ts'
|
|
8
|
+
import {
|
|
9
|
+
arrayInput,
|
|
10
|
+
mapInput,
|
|
11
|
+
nullInput,
|
|
12
|
+
numberInput,
|
|
13
|
+
optional,
|
|
14
|
+
positiveIntegerInput,
|
|
15
|
+
required,
|
|
16
|
+
stringInput,
|
|
17
|
+
unionInput,
|
|
18
|
+
} from '../spec.ts'
|
|
19
|
+
import type { InputSpec } from '../spec.ts'
|
|
20
|
+
import { isObject } from '../values.ts'
|
|
21
|
+
|
|
22
|
+
type SnapshotRequestInput = Omit<SnapshotRequest, 'read'> & { read: SnapshotDescriptor }
|
|
23
|
+
export type SnapshotPlanetInput = Omit<PlanetSnapshotOptions, 'additional'> & {
|
|
24
|
+
additional?: readonly SnapshotRequestInput[]
|
|
25
|
+
}
|
|
26
|
+
export type SnapshotAccountInput = Omit<
|
|
27
|
+
AccountSnapshotOptions,
|
|
28
|
+
'additional' | 'additionalByPlanet'
|
|
29
|
+
> & {
|
|
30
|
+
additional?: readonly SnapshotRequestInput[]
|
|
31
|
+
additionalByPlanet?: ReadonlyMap<number, readonly SnapshotRequestInput[]>
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const commandInput = {
|
|
35
|
+
kind: 'custom',
|
|
36
|
+
reference: 'command',
|
|
37
|
+
accepts: isObject,
|
|
38
|
+
input: { kind: 'object', fields: {}, additional: true },
|
|
39
|
+
} satisfies InputSpec<Fields>
|
|
40
|
+
|
|
41
|
+
const snapshotDescriptorInput = {
|
|
42
|
+
kind: 'object',
|
|
43
|
+
fields: {
|
|
44
|
+
command: required(stringInput),
|
|
45
|
+
input: optional(commandInput),
|
|
46
|
+
},
|
|
47
|
+
} satisfies InputSpec<SnapshotDescriptor>
|
|
48
|
+
|
|
49
|
+
export const snapshotRequestInput: InputSpec<SnapshotRequestInput> = {
|
|
50
|
+
kind: 'object',
|
|
51
|
+
fields: {
|
|
52
|
+
name: required(stringInput),
|
|
53
|
+
read: required(snapshotDescriptorInput),
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const snapshotFields = {
|
|
58
|
+
planetId: required(numberInput),
|
|
59
|
+
concurrency: required(unionInput(positiveIntegerInput, nullInput)),
|
|
60
|
+
additional: optional(arrayInput(snapshotRequestInput)),
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const snapshotPlanetInput: InputSpec<SnapshotPlanetInput> = {
|
|
64
|
+
kind: 'object',
|
|
65
|
+
fields: snapshotFields,
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const snapshotAccountInput: InputSpec<SnapshotAccountInput> = {
|
|
69
|
+
kind: 'object',
|
|
70
|
+
fields: {
|
|
71
|
+
...snapshotFields,
|
|
72
|
+
additionalByPlanet: optional(mapInput(numberInput, arrayInput(snapshotRequestInput))),
|
|
73
|
+
},
|
|
74
|
+
}
|