@beezer-pet/instant-cli 0.0.0-stage → 1.0.67-beezer.3
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/.turbo/turbo-build.log +4 -0
- package/LICENSE.md +202 -0
- package/README.md +34 -2
- package/__tests__/appCommands.test.ts +228 -0
- package/__tests__/args.test.ts +358 -0
- package/__tests__/auth.test.ts +128 -0
- package/__tests__/authClientAddApple.test.ts +376 -0
- package/__tests__/authClientAddClerk.test.ts +222 -0
- package/__tests__/authClientAddGithub.test.ts +245 -0
- package/__tests__/authClientAddGoogle.test.ts +373 -0
- package/__tests__/authClientAddLinkedin.test.ts +262 -0
- package/__tests__/authClientList.test.ts +90 -0
- package/__tests__/authClientUpdate.test.ts +583 -0
- package/__tests__/authOriginManagement.test.ts +308 -0
- package/__tests__/backupDownload.test.ts +206 -0
- package/__tests__/backups.test.ts +221 -0
- package/__tests__/config.test.ts +57 -0
- package/__tests__/e2e/cli.e2e.test.ts +1267 -0
- package/__tests__/e2e/helpers.ts +177 -0
- package/__tests__/effectHelpers.ts +45 -0
- package/__tests__/mergeSchema.test.ts +197 -0
- package/__tests__/multiSelect.test.ts +236 -0
- package/__tests__/oauthMock.ts +76 -0
- package/__tests__/promptOk.test.ts +44 -0
- package/__tests__/redirectUriPrompt.test.ts +40 -0
- package/__tests__/sdkInstallSpec.test.ts +36 -0
- package/__tests__/select.test.ts +224 -0
- package/__tests__/webhooks.test.ts +728 -0
- package/bin/index.js +3 -0
- package/dist/auth/index.d.ts +4 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +103 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/commands/app/delete.d.ts +7 -0
- package/dist/commands/app/delete.d.ts.map +1 -0
- package/dist/commands/app/delete.js +57 -0
- package/dist/commands/app/delete.js.map +1 -0
- package/dist/commands/app/list.d.ts +6 -0
- package/dist/commands/app/list.d.ts.map +1 -0
- package/dist/commands/app/list.js +29 -0
- package/dist/commands/app/list.js.map +1 -0
- package/dist/commands/auth/client/add.d.ts +9 -0
- package/dist/commands/auth/client/add.d.ts.map +1 -0
- package/dist/commands/auth/client/add.js +409 -0
- package/dist/commands/auth/client/add.js.map +1 -0
- package/dist/commands/auth/client/delete.d.ts +11 -0
- package/dist/commands/auth/client/delete.d.ts.map +1 -0
- package/dist/commands/auth/client/delete.js +48 -0
- package/dist/commands/auth/client/delete.js.map +1 -0
- package/dist/commands/auth/client/list.d.ts +6 -0
- package/dist/commands/auth/client/list.d.ts.map +1 -0
- package/dist/commands/auth/client/list.js +38 -0
- package/dist/commands/auth/client/list.js.map +1 -0
- package/dist/commands/auth/client/shared.d.ts +70 -0
- package/dist/commands/auth/client/shared.d.ts.map +1 -0
- package/dist/commands/auth/client/shared.js +140 -0
- package/dist/commands/auth/client/shared.js.map +1 -0
- package/dist/commands/auth/client/update.d.ts +8 -0
- package/dist/commands/auth/client/update.d.ts.map +1 -0
- package/dist/commands/auth/client/update.js +445 -0
- package/dist/commands/auth/client/update.js.map +1 -0
- package/dist/commands/auth/email/pull.d.ts +24 -0
- package/dist/commands/auth/email/pull.d.ts.map +1 -0
- package/dist/commands/auth/email/pull.js +100 -0
- package/dist/commands/auth/email/pull.js.map +1 -0
- package/dist/commands/auth/email/push.d.ts +8 -0
- package/dist/commands/auth/email/push.d.ts.map +1 -0
- package/dist/commands/auth/email/push.js +58 -0
- package/dist/commands/auth/email/push.js.map +1 -0
- package/dist/commands/auth/email/resend.d.ts +3 -0
- package/dist/commands/auth/email/resend.d.ts.map +1 -0
- package/dist/commands/auth/email/resend.js +7 -0
- package/dist/commands/auth/email/resend.js.map +1 -0
- package/dist/commands/auth/email/reset.d.ts +5 -0
- package/dist/commands/auth/email/reset.d.ts.map +1 -0
- package/dist/commands/auth/email/reset.js +25 -0
- package/dist/commands/auth/email/reset.js.map +1 -0
- package/dist/commands/auth/email/status.d.ts +57 -0
- package/dist/commands/auth/email/status.d.ts.map +1 -0
- package/dist/commands/auth/email/status.js +96 -0
- package/dist/commands/auth/email/status.js.map +1 -0
- package/dist/commands/auth/email/verify.d.ts +5 -0
- package/dist/commands/auth/email/verify.d.ts.map +1 -0
- package/dist/commands/auth/email/verify.js +12 -0
- package/dist/commands/auth/email/verify.js.map +1 -0
- package/dist/commands/auth/origin/add.d.ts +12 -0
- package/dist/commands/auth/origin/add.d.ts.map +1 -0
- package/dist/commands/auth/origin/add.js +153 -0
- package/dist/commands/auth/origin/add.js.map +1 -0
- package/dist/commands/auth/origin/delete.d.ts +8 -0
- package/dist/commands/auth/origin/delete.d.ts.map +1 -0
- package/dist/commands/auth/origin/delete.js +38 -0
- package/dist/commands/auth/origin/delete.js.map +1 -0
- package/dist/commands/auth/origin/list.d.ts +9 -0
- package/dist/commands/auth/origin/list.d.ts.map +1 -0
- package/dist/commands/auth/origin/list.js +52 -0
- package/dist/commands/auth/origin/list.js.map +1 -0
- package/dist/commands/backup/download.d.ts +10 -0
- package/dist/commands/backup/download.d.ts.map +1 -0
- package/dist/commands/backup/download.js +174 -0
- package/dist/commands/backup/download.js.map +1 -0
- package/dist/commands/backup/list.d.ts +11 -0
- package/dist/commands/backup/list.d.ts.map +1 -0
- package/dist/commands/backup/list.js +74 -0
- package/dist/commands/backup/list.js.map +1 -0
- package/dist/commands/claim.d.ts +6 -0
- package/dist/commands/claim.d.ts.map +1 -0
- package/dist/commands/claim.js +22 -0
- package/dist/commands/claim.js.map +1 -0
- package/dist/commands/explorer.d.ts +6 -0
- package/dist/commands/explorer.d.ts.map +1 -0
- package/dist/commands/explorer.js +13 -0
- package/dist/commands/explorer.js.map +1 -0
- package/dist/commands/info.d.ts +9 -0
- package/dist/commands/info.d.ts.map +1 -0
- package/dist/commands/info.js +41 -0
- package/dist/commands/info.js.map +1 -0
- package/dist/commands/init.d.ts +5 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +41 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/initWithoutFiles.d.ts +6 -0
- package/dist/commands/initWithoutFiles.d.ts.map +1 -0
- package/dist/commands/initWithoutFiles.js +64 -0
- package/dist/commands/initWithoutFiles.js.map +1 -0
- package/dist/commands/login.d.ts +9 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +44 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +3 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +14 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/pull.d.ts +5 -0
- package/dist/commands/pull.d.ts.map +1 -0
- package/dist/commands/pull.js +15 -0
- package/dist/commands/pull.js.map +1 -0
- package/dist/commands/push.d.ts +6 -0
- package/dist/commands/push.d.ts.map +1 -0
- package/dist/commands/push.js +20 -0
- package/dist/commands/push.js.map +1 -0
- package/dist/commands/query.d.ts +7 -0
- package/dist/commands/query.d.ts.map +1 -0
- package/dist/commands/query.js +52 -0
- package/dist/commands/query.js.map +1 -0
- package/dist/commands/webhooks/add.d.ts +9 -0
- package/dist/commands/webhooks/add.d.ts.map +1 -0
- package/dist/commands/webhooks/add.js +75 -0
- package/dist/commands/webhooks/add.js.map +1 -0
- package/dist/commands/webhooks/delete.d.ts +6 -0
- package/dist/commands/webhooks/delete.d.ts.map +1 -0
- package/dist/commands/webhooks/delete.js +17 -0
- package/dist/commands/webhooks/delete.js.map +1 -0
- package/dist/commands/webhooks/disable.d.ts +7 -0
- package/dist/commands/webhooks/disable.d.ts.map +1 -0
- package/dist/commands/webhooks/disable.js +18 -0
- package/dist/commands/webhooks/disable.js.map +1 -0
- package/dist/commands/webhooks/enable.d.ts +6 -0
- package/dist/commands/webhooks/enable.d.ts.map +1 -0
- package/dist/commands/webhooks/enable.js +18 -0
- package/dist/commands/webhooks/enable.js.map +1 -0
- package/dist/commands/webhooks/events/list.d.ts +7 -0
- package/dist/commands/webhooks/events/list.d.ts.map +1 -0
- package/dist/commands/webhooks/events/list.js +31 -0
- package/dist/commands/webhooks/events/list.js.map +1 -0
- package/dist/commands/webhooks/events/payload.d.ts +8 -0
- package/dist/commands/webhooks/events/payload.d.ts.map +1 -0
- package/dist/commands/webhooks/events/payload.js +39 -0
- package/dist/commands/webhooks/events/payload.js.map +1 -0
- package/dist/commands/webhooks/events/resend.d.ts +8 -0
- package/dist/commands/webhooks/events/resend.d.ts.map +1 -0
- package/dist/commands/webhooks/events/resend.js +43 -0
- package/dist/commands/webhooks/events/resend.js.map +1 -0
- package/dist/commands/webhooks/list.d.ts +8 -0
- package/dist/commands/webhooks/list.d.ts.map +1 -0
- package/dist/commands/webhooks/list.js +29 -0
- package/dist/commands/webhooks/list.js.map +1 -0
- package/dist/commands/webhooks/shared.d.ts +40 -0
- package/dist/commands/webhooks/shared.d.ts.map +1 -0
- package/dist/commands/webhooks/shared.js +248 -0
- package/dist/commands/webhooks/shared.js.map +1 -0
- package/dist/commands/webhooks/update.d.ts +10 -0
- package/dist/commands/webhooks/update.d.ts.map +1 -0
- package/dist/commands/webhooks/update.js +189 -0
- package/dist/commands/webhooks/update.js.map +1 -0
- package/dist/context/authToken.d.ts +29 -0
- package/dist/context/authToken.d.ts.map +1 -0
- package/dist/context/authToken.js +73 -0
- package/dist/context/authToken.js.map +1 -0
- package/dist/context/currentApp.d.ts +38 -0
- package/dist/context/currentApp.d.ts.map +1 -0
- package/dist/context/currentApp.js +222 -0
- package/dist/context/currentApp.js.map +1 -0
- package/dist/context/globalOpts.d.ts +11 -0
- package/dist/context/globalOpts.d.ts.map +1 -0
- package/dist/context/globalOpts.js +13 -0
- package/dist/context/globalOpts.js.map +1 -0
- package/dist/context/platformApi.d.ts +19 -0
- package/dist/context/platformApi.d.ts.map +1 -0
- package/dist/context/platformApi.js +24 -0
- package/dist/context/platformApi.js.map +1 -0
- package/dist/context/projectInfo.d.ts +30 -0
- package/dist/context/projectInfo.d.ts.map +1 -0
- package/dist/context/projectInfo.js +153 -0
- package/dist/context/projectInfo.js.map +1 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +6 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +159 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +714 -0
- package/dist/index.js.map +1 -0
- package/dist/layer.d.ts +25 -0
- package/dist/layer.d.ts.map +1 -0
- package/dist/layer.js +119 -0
- package/dist/layer.js.map +1 -0
- package/dist/lib/args.d.ts +212 -0
- package/dist/lib/args.d.ts.map +1 -0
- package/dist/lib/args.js +313 -0
- package/dist/lib/args.js.map +1 -0
- package/dist/lib/backupDownload.d.ts +21 -0
- package/dist/lib/backupDownload.d.ts.map +1 -0
- package/dist/lib/backupDownload.js +151 -0
- package/dist/lib/backupDownload.js.map +1 -0
- package/dist/lib/backups.d.ts +12 -0
- package/dist/lib/backups.d.ts.map +1 -0
- package/dist/lib/backups.js +26 -0
- package/dist/lib/backups.js.map +1 -0
- package/dist/lib/config.d.ts +6 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +39 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/createApp.d.ts +12 -0
- package/dist/lib/createApp.d.ts.map +1 -0
- package/dist/lib/createApp.js +15 -0
- package/dist/lib/createApp.js.map +1 -0
- package/dist/lib/email.d.ts +47 -0
- package/dist/lib/email.d.ts.map +1 -0
- package/dist/lib/email.js +71 -0
- package/dist/lib/email.js.map +1 -0
- package/dist/lib/handleEnv.d.ts +7 -0
- package/dist/lib/handleEnv.d.ts.map +1 -0
- package/dist/lib/handleEnv.js +99 -0
- package/dist/lib/handleEnv.js.map +1 -0
- package/dist/lib/http.d.ts +30 -0
- package/dist/lib/http.d.ts.map +1 -0
- package/dist/lib/http.js +55 -0
- package/dist/lib/http.js.map +1 -0
- package/dist/lib/login.d.ts +12 -0
- package/dist/lib/login.d.ts.map +1 -0
- package/dist/lib/login.js +38 -0
- package/dist/lib/login.js.map +1 -0
- package/dist/lib/oauth.d.ts +306 -0
- package/dist/lib/oauth.d.ts.map +1 -0
- package/dist/lib/oauth.js +195 -0
- package/dist/lib/oauth.js.map +1 -0
- package/dist/lib/platformApi.d.ts +5 -0
- package/dist/lib/platformApi.d.ts.map +1 -0
- package/dist/lib/platformApi.js +11 -0
- package/dist/lib/platformApi.js.map +1 -0
- package/dist/lib/pullPerms.d.ts +7 -0
- package/dist/lib/pullPerms.d.ts.map +1 -0
- package/dist/lib/pullPerms.js +41 -0
- package/dist/lib/pullPerms.js.map +1 -0
- package/dist/lib/pullSchema.d.ts +12 -0
- package/dist/lib/pullSchema.d.ts.map +1 -0
- package/dist/lib/pullSchema.js +62 -0
- package/dist/lib/pullSchema.js.map +1 -0
- package/dist/lib/pushPerms.d.ts +13 -0
- package/dist/lib/pushPerms.d.ts.map +1 -0
- package/dist/lib/pushPerms.js +54 -0
- package/dist/lib/pushPerms.js.map +1 -0
- package/dist/lib/pushSchema.d.ts +53 -0
- package/dist/lib/pushSchema.d.ts.map +1 -0
- package/dist/lib/pushSchema.js +165 -0
- package/dist/lib/pushSchema.js.map +1 -0
- package/dist/lib/ui.d.ts +18 -0
- package/dist/lib/ui.d.ts.map +1 -0
- package/dist/lib/ui.js +32 -0
- package/dist/lib/ui.js.map +1 -0
- package/dist/lib/webhooks.d.ts +27 -0
- package/dist/lib/webhooks.d.ts.map +1 -0
- package/dist/lib/webhooks.js +95 -0
- package/dist/lib/webhooks.js.map +1 -0
- package/dist/logging.d.ts +5 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +25 -0
- package/dist/logging.js.map +1 -0
- package/dist/old.d.ts +17 -0
- package/dist/old.d.ts.map +1 -0
- package/dist/old.js +410 -0
- package/dist/old.js.map +1 -0
- package/dist/program.d.ts +3 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +3 -0
- package/dist/program.js.map +1 -0
- package/dist/renderSchemaPlan.d.ts +19 -0
- package/dist/renderSchemaPlan.d.ts.map +1 -0
- package/dist/renderSchemaPlan.js +220 -0
- package/dist/renderSchemaPlan.js.map +1 -0
- package/dist/ui/index.d.ts +292 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +1296 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/lib.d.ts +124 -0
- package/dist/ui/lib.d.ts.map +1 -0
- package/dist/ui/lib.js +333 -0
- package/dist/ui/lib.js.map +1 -0
- package/dist/util/findConfigCandidates.d.ts +13 -0
- package/dist/util/findConfigCandidates.d.ts.map +1 -0
- package/dist/util/findConfigCandidates.js +211 -0
- package/dist/util/findConfigCandidates.js.map +1 -0
- package/dist/util/fs.d.ts +4 -0
- package/dist/util/fs.d.ts.map +1 -0
- package/dist/util/fs.js +22 -0
- package/dist/util/fs.js.map +1 -0
- package/dist/util/getAppName.d.ts +5 -0
- package/dist/util/getAppName.d.ts.map +1 -0
- package/dist/util/getAppName.js +14 -0
- package/dist/util/getAppName.js.map +1 -0
- package/dist/util/instantConfig.d.ts +9 -0
- package/dist/util/instantConfig.d.ts.map +1 -0
- package/dist/util/instantConfig.js +13 -0
- package/dist/util/instantConfig.js.map +1 -0
- package/dist/util/isHeadlessEnvironment.d.ts +4 -0
- package/dist/util/isHeadlessEnvironment.d.ts.map +1 -0
- package/dist/util/isHeadlessEnvironment.js +11 -0
- package/dist/util/isHeadlessEnvironment.js.map +1 -0
- package/dist/util/loadConfig.d.ts +3 -0
- package/dist/util/loadConfig.d.ts.map +1 -0
- package/dist/util/loadConfig.js +72 -0
- package/dist/util/loadConfig.js.map +1 -0
- package/dist/util/loadEnv.d.ts +2 -0
- package/dist/util/loadEnv.d.ts.map +1 -0
- package/dist/util/loadEnv.js +10 -0
- package/dist/util/loadEnv.js.map +1 -0
- package/dist/util/mergeSchema.d.ts +10 -0
- package/dist/util/mergeSchema.d.ts.map +1 -0
- package/dist/util/mergeSchema.js +338 -0
- package/dist/util/mergeSchema.js.map +1 -0
- package/dist/util/projectDir.d.ts +7 -0
- package/dist/util/projectDir.d.ts.map +1 -0
- package/dist/util/projectDir.js +43 -0
- package/dist/util/projectDir.js.map +1 -0
- package/dist/util/renamePrompt.d.ts +15 -0
- package/dist/util/renamePrompt.d.ts.map +1 -0
- package/dist/util/renamePrompt.js +57 -0
- package/dist/util/renamePrompt.js.map +1 -0
- package/dist/util/sdkInstallSpec.d.ts +13 -0
- package/dist/util/sdkInstallSpec.d.ts.map +1 -0
- package/dist/util/sdkInstallSpec.js +37 -0
- package/dist/util/sdkInstallSpec.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/package.json +91 -3
- package/src/auth/index.ts +125 -0
- package/src/commands/app/delete.ts +82 -0
- package/src/commands/app/list.ts +44 -0
- package/src/commands/auth/client/add.ts +744 -0
- package/src/commands/auth/client/delete.ts +60 -0
- package/src/commands/auth/client/list.ts +60 -0
- package/src/commands/auth/client/shared.ts +190 -0
- package/src/commands/auth/client/update.ts +830 -0
- package/src/commands/auth/email/pull.ts +143 -0
- package/src/commands/auth/email/push.ts +94 -0
- package/src/commands/auth/email/resend.ts +8 -0
- package/src/commands/auth/email/reset.ts +37 -0
- package/src/commands/auth/email/status.ts +154 -0
- package/src/commands/auth/email/verify.ts +20 -0
- package/src/commands/auth/origin/add.ts +237 -0
- package/src/commands/auth/origin/delete.ts +50 -0
- package/src/commands/auth/origin/list.ts +66 -0
- package/src/commands/backup/download.ts +231 -0
- package/src/commands/backup/list.ts +94 -0
- package/src/commands/claim.ts +31 -0
- package/src/commands/explorer.ts +21 -0
- package/src/commands/info.ts +57 -0
- package/src/commands/init.ts +60 -0
- package/src/commands/initWithoutFiles.ts +107 -0
- package/src/commands/login.ts +62 -0
- package/src/commands/logout.ts +22 -0
- package/src/commands/pull.ts +22 -0
- package/src/commands/push.ts +25 -0
- package/src/commands/query.ts +61 -0
- package/src/commands/webhooks/add.ts +111 -0
- package/src/commands/webhooks/delete.ts +23 -0
- package/src/commands/webhooks/disable.ts +24 -0
- package/src/commands/webhooks/enable.ts +24 -0
- package/src/commands/webhooks/events/list.ts +38 -0
- package/src/commands/webhooks/events/payload.ts +56 -0
- package/src/commands/webhooks/events/resend.ts +66 -0
- package/src/commands/webhooks/list.ts +41 -0
- package/src/commands/webhooks/shared.ts +339 -0
- package/src/commands/webhooks/update.ts +276 -0
- package/src/context/authToken.ts +134 -0
- package/src/context/currentApp.ts +301 -0
- package/src/context/globalOpts.ts +22 -0
- package/src/context/platformApi.ts +35 -0
- package/src/context/projectInfo.ts +219 -0
- package/src/errors.ts +7 -0
- package/src/index.ts +1212 -0
- package/src/layer.ts +211 -0
- package/src/lib/args.ts +453 -0
- package/src/lib/backupDownload.ts +188 -0
- package/src/lib/backups.ts +33 -0
- package/src/lib/config.ts +73 -0
- package/src/lib/createApp.ts +28 -0
- package/src/lib/email.ts +93 -0
- package/src/lib/handleEnv.ts +122 -0
- package/src/lib/http.ts +128 -0
- package/src/lib/login.ts +48 -0
- package/src/lib/oauth.ts +310 -0
- package/src/lib/platformApi.ts +11 -0
- package/src/lib/pullPerms.ts +50 -0
- package/src/lib/pullSchema.ts +95 -0
- package/src/lib/pushPerms.ts +80 -0
- package/src/lib/pushSchema.ts +248 -0
- package/src/lib/ui.ts +48 -0
- package/src/lib/webhooks.ts +118 -0
- package/src/logging.ts +41 -0
- package/src/old.js +487 -0
- package/src/program.ts +3 -0
- package/src/renderSchemaPlan.ts +324 -0
- package/src/ui/index.ts +1615 -0
- package/src/ui/lib.ts +424 -0
- package/src/util/findConfigCandidates.ts +262 -0
- package/src/util/fs.ts +26 -0
- package/src/util/getAppName.ts +14 -0
- package/src/util/instantConfig.ts +21 -0
- package/src/util/isHeadlessEnvironment.ts +15 -0
- package/src/util/loadConfig.ts +93 -0
- package/src/util/loadEnv.ts +11 -0
- package/src/util/mergeSchema.ts +374 -0
- package/src/util/projectDir.ts +54 -0
- package/src/util/renamePrompt.ts +79 -0
- package/src/util/sdkInstallSpec.ts +45 -0
- package/src/version.js +3 -0
- package/tsconfig.build.json +20 -0
- package/tsconfig.json +23 -0
- package/vitest.config.ts +22 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import boxen from 'boxen';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { Effect } from 'effect';
|
|
4
|
+
import type {
|
|
5
|
+
WebhookAction,
|
|
6
|
+
WebhookEventInfo,
|
|
7
|
+
WebhookEventStatus,
|
|
8
|
+
WebhookInfo,
|
|
9
|
+
} from '@instantdb/platform';
|
|
10
|
+
import { GlobalOpts } from '../../context/globalOpts.ts';
|
|
11
|
+
import { BadArgsError } from '../../errors.ts';
|
|
12
|
+
import { runUIEffect } from '../../lib/ui.ts';
|
|
13
|
+
import {
|
|
14
|
+
buildWebhooksManager,
|
|
15
|
+
fetchRecentEvents,
|
|
16
|
+
useWebhooksManager,
|
|
17
|
+
WEBHOOK_ACTIONS,
|
|
18
|
+
} from '../../lib/webhooks.ts';
|
|
19
|
+
import { UI } from '../../ui/index.ts';
|
|
20
|
+
|
|
21
|
+
type PickerParams = {
|
|
22
|
+
promptText: string;
|
|
23
|
+
emptyMessage: string;
|
|
24
|
+
filter?: (w: WebhookInfo) => boolean;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const joinNamespaces = (namespaces: readonly string[]) =>
|
|
28
|
+
[...namespaces].sort().join(', ');
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Validates a webhook URL: must be non-empty after trim, parse as a URL, and
|
|
32
|
+
* use the `https:` scheme (matches the server's requirement). Returns an error
|
|
33
|
+
* message or undefined. Pass to `Args.prompt({ validate })` for inline
|
|
34
|
+
* feedback, and `Args.validate(...)` to also cover flag-supplied values.
|
|
35
|
+
*/
|
|
36
|
+
export const validateWebhookUrl = (raw: string): string | undefined => {
|
|
37
|
+
const trimmed = raw.trim();
|
|
38
|
+
if (!trimmed) return 'URL cannot be empty';
|
|
39
|
+
let parsed: URL;
|
|
40
|
+
try {
|
|
41
|
+
parsed = new URL(trimmed);
|
|
42
|
+
} catch {
|
|
43
|
+
return `Invalid URL: ${raw}`;
|
|
44
|
+
}
|
|
45
|
+
if (parsed.protocol !== 'https:') {
|
|
46
|
+
return 'URL must use https://';
|
|
47
|
+
}
|
|
48
|
+
return undefined;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const joinActions = (actions: readonly string[]) =>
|
|
52
|
+
[...actions]
|
|
53
|
+
.sort(
|
|
54
|
+
(a, b) =>
|
|
55
|
+
WEBHOOK_ACTIONS.indexOf(a as WebhookAction) -
|
|
56
|
+
WEBHOOK_ACTIONS.indexOf(b as WebhookAction),
|
|
57
|
+
)
|
|
58
|
+
.join(', ');
|
|
59
|
+
|
|
60
|
+
const renderWebhookLabel = (w: WebhookInfo) =>
|
|
61
|
+
[
|
|
62
|
+
`${w.sink.url} ${chalk.dim(`(${w.id})`)}`,
|
|
63
|
+
chalk.dim(` status: ${w.status}`),
|
|
64
|
+
chalk.dim(` actions: ${joinActions(w.actions)}`),
|
|
65
|
+
chalk.dim(` namespaces: ${joinNamespaces(w.namespaces)}`),
|
|
66
|
+
].join('\n');
|
|
67
|
+
|
|
68
|
+
const pickWebhook = (params: PickerParams) =>
|
|
69
|
+
Effect.gen(function* () {
|
|
70
|
+
const all = yield* useWebhooksManager(
|
|
71
|
+
(m) => m.list(),
|
|
72
|
+
'Error listing webhooks',
|
|
73
|
+
);
|
|
74
|
+
const webhooks = params.filter ? all.filter(params.filter) : all;
|
|
75
|
+
if (webhooks.length === 0) {
|
|
76
|
+
yield* Effect.log(params.emptyMessage);
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
return yield* runUIEffect(
|
|
80
|
+
new UI.Select<WebhookInfo>({
|
|
81
|
+
options: webhooks.map((w) => ({
|
|
82
|
+
label: renderWebhookLabel(w),
|
|
83
|
+
value: w,
|
|
84
|
+
})),
|
|
85
|
+
promptText: params.promptText,
|
|
86
|
+
modifyOutput: UI.modifiers.vanishOnComplete,
|
|
87
|
+
}),
|
|
88
|
+
);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export const resolveWebhookId = (params: {
|
|
92
|
+
id: string | undefined;
|
|
93
|
+
picker: PickerParams;
|
|
94
|
+
flagName?: string;
|
|
95
|
+
}) =>
|
|
96
|
+
Effect.gen(function* () {
|
|
97
|
+
if (params.id) return params.id;
|
|
98
|
+
const { yes } = yield* GlobalOpts;
|
|
99
|
+
if (yes) {
|
|
100
|
+
return yield* BadArgsError.make({
|
|
101
|
+
message: `Must specify ${params.flagName ?? '--id'}`,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
const picked = yield* pickWebhook(params.picker);
|
|
105
|
+
return picked?.id;
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
export const logWebhookEvent = (action: string, webhook: WebhookInfo) => {
|
|
109
|
+
const lines = [
|
|
110
|
+
`Webhook ${action}: ${webhook.sink.url}`,
|
|
111
|
+
`ID: ${webhook.id}`,
|
|
112
|
+
`Status: ${webhook.status}`,
|
|
113
|
+
`Actions: ${joinActions(webhook.actions)}`,
|
|
114
|
+
`Namespaces: ${joinNamespaces(webhook.namespaces)}`,
|
|
115
|
+
];
|
|
116
|
+
if (webhook.disabledReason) {
|
|
117
|
+
lines.push(`Disabled reason: ${webhook.disabledReason}`);
|
|
118
|
+
}
|
|
119
|
+
return Effect.log(
|
|
120
|
+
'\n' +
|
|
121
|
+
boxen(lines.join('\n'), {
|
|
122
|
+
dimBorder: true,
|
|
123
|
+
padding: { right: 1, left: 1 },
|
|
124
|
+
}),
|
|
125
|
+
);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const colorStatus = (status: WebhookEventStatus): string => {
|
|
129
|
+
switch (status) {
|
|
130
|
+
case 'success':
|
|
131
|
+
return chalk.green(status);
|
|
132
|
+
case 'failed':
|
|
133
|
+
return chalk.red(status);
|
|
134
|
+
case 'error':
|
|
135
|
+
return chalk.yellow(status);
|
|
136
|
+
case 'processing':
|
|
137
|
+
return chalk.cyan(status);
|
|
138
|
+
case 'pending':
|
|
139
|
+
return chalk.dim(status);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const lastAttemptSummary = (event: WebhookEventInfo): string => {
|
|
144
|
+
if (!event.attempts || event.attempts.length === 0) return 'no attempts';
|
|
145
|
+
const last = event.attempts[event.attempts.length - 1]!;
|
|
146
|
+
const code =
|
|
147
|
+
last.statusCode != null
|
|
148
|
+
? String(last.statusCode)
|
|
149
|
+
: (last.errorType ?? 'error');
|
|
150
|
+
const dur = last.durationMs != null ? `, ${last.durationMs}ms` : '';
|
|
151
|
+
return `${code}${dur}`;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export const renderEventLabel = (e: WebhookEventInfo): string => {
|
|
155
|
+
const attempts = e.attempts?.length ?? 0;
|
|
156
|
+
const attemptsPart =
|
|
157
|
+
attempts === 0 ? '—' : `${attempts} attempt${attempts === 1 ? '' : 's'}`;
|
|
158
|
+
return `${e.isn} ${colorStatus(e.status)} ${chalk.dim(`${attemptsPart} · last: ${lastAttemptSummary(e)}`)}`;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const fmtTime = (d: Date | null) => (d ? d.toLocaleString() : 'n/a');
|
|
162
|
+
|
|
163
|
+
export const logEventDetail = (e: WebhookEventInfo): string[] => {
|
|
164
|
+
const lines = [
|
|
165
|
+
`${chalk.cyan(e.isn)}`,
|
|
166
|
+
` Status: ${colorStatus(e.status)}`,
|
|
167
|
+
` Created: ${fmtTime(e.createdAt)}`,
|
|
168
|
+
` Updated: ${fmtTime(e.updatedAt)}`,
|
|
169
|
+
` Attempts: ${e.attempts?.length ?? 0}${
|
|
170
|
+
e.attempts && e.attempts.length > 0
|
|
171
|
+
? ` (last: ${lastAttemptSummary(e)})`
|
|
172
|
+
: ''
|
|
173
|
+
}`,
|
|
174
|
+
];
|
|
175
|
+
if (e.nextAttemptAfter) {
|
|
176
|
+
lines.push(` Next attempt: ${fmtTime(e.nextAttemptAfter)}`);
|
|
177
|
+
}
|
|
178
|
+
return lines;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const formatExpandedEvent = (
|
|
182
|
+
e: WebhookEventInfo,
|
|
183
|
+
maxAttempts?: number,
|
|
184
|
+
): string => {
|
|
185
|
+
const lines: string[] = [];
|
|
186
|
+
lines.push(chalk.dim(` Created: ${fmtTime(e.createdAt)}`));
|
|
187
|
+
lines.push(chalk.dim(` Updated: ${fmtTime(e.updatedAt)}`));
|
|
188
|
+
if (e.nextAttemptAfter) {
|
|
189
|
+
lines.push(chalk.dim(` Next attempt: ${fmtTime(e.nextAttemptAfter)}`));
|
|
190
|
+
}
|
|
191
|
+
if (e.attempts && e.attempts.length > 0) {
|
|
192
|
+
const total = e.attempts.length;
|
|
193
|
+
const cap = maxAttempts ?? total;
|
|
194
|
+
const hiddenCount = Math.max(0, total - cap);
|
|
195
|
+
const shown = e.attempts.slice(-cap);
|
|
196
|
+
lines.push(
|
|
197
|
+
chalk.dim(
|
|
198
|
+
hiddenCount > 0
|
|
199
|
+
? ` Attempts: showing last ${shown.length} of ${total}`
|
|
200
|
+
: ` Attempts:`,
|
|
201
|
+
),
|
|
202
|
+
);
|
|
203
|
+
shown.forEach((a, i) => {
|
|
204
|
+
const realIdx = hiddenCount + i + 1;
|
|
205
|
+
const code =
|
|
206
|
+
a.statusCode != null ? String(a.statusCode) : (a.errorType ?? 'error');
|
|
207
|
+
const dur = a.durationMs != null ? `${a.durationMs}ms` : '—';
|
|
208
|
+
const ok = a.success === true;
|
|
209
|
+
const codeColored = ok
|
|
210
|
+
? chalk.green(code)
|
|
211
|
+
: a.success === false
|
|
212
|
+
? chalk.red(code)
|
|
213
|
+
: chalk.yellow(code);
|
|
214
|
+
lines.push(
|
|
215
|
+
chalk.dim(` ${realIdx}. ${fmtTime(a.attemptAt)} → `) +
|
|
216
|
+
codeColored +
|
|
217
|
+
chalk.dim(` (${dur})`),
|
|
218
|
+
);
|
|
219
|
+
if (a.errorMessage) {
|
|
220
|
+
lines.push(chalk.dim(` ${a.errorMessage}`));
|
|
221
|
+
}
|
|
222
|
+
if (a.responseText) {
|
|
223
|
+
const trimmed = a.responseText.replace(/\s+/g, ' ').trim();
|
|
224
|
+
// 13 reserves the visible prefix on the printed line: 9 spaces of
|
|
225
|
+
// indent + 'body: ' (4 chars including the trailing space).
|
|
226
|
+
const max = Math.max(20, (process.stdout.columns ?? 80) - 13);
|
|
227
|
+
const body =
|
|
228
|
+
trimmed.length > max ? trimmed.slice(0, max - 1) + '…' : trimmed;
|
|
229
|
+
lines.push(chalk.dim(` body: ${body}`));
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
} else {
|
|
233
|
+
lines.push(chalk.dim(` Attempts: none yet`));
|
|
234
|
+
}
|
|
235
|
+
return lines.join('\n');
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
export const pickEvent = (params: {
|
|
239
|
+
webhookId: string;
|
|
240
|
+
limit?: number;
|
|
241
|
+
promptText: string;
|
|
242
|
+
emptyMessage: string;
|
|
243
|
+
}) =>
|
|
244
|
+
Effect.gen(function* () {
|
|
245
|
+
const events = yield* fetchRecentEvents(
|
|
246
|
+
params.webhookId,
|
|
247
|
+
params.limit ?? 25,
|
|
248
|
+
);
|
|
249
|
+
if (events.length === 0) {
|
|
250
|
+
yield* Effect.log(params.emptyMessage);
|
|
251
|
+
return undefined;
|
|
252
|
+
}
|
|
253
|
+
const manager = yield* buildWebhooksManager;
|
|
254
|
+
return yield* runUIEffect(
|
|
255
|
+
new UI.Select<WebhookEventInfo>({
|
|
256
|
+
options: events.map((e) => ({
|
|
257
|
+
label: renderEventLabel(e),
|
|
258
|
+
expandableLabel: async () => {
|
|
259
|
+
// Total budget = terminal rows minus picker chrome (prompt + one
|
|
260
|
+
// line per option + hint + safety).
|
|
261
|
+
const rows = process.stdout.rows ?? 24;
|
|
262
|
+
const chrome = events.length + 4;
|
|
263
|
+
const totalBudget = Math.max(12, rows - chrome);
|
|
264
|
+
|
|
265
|
+
// Split: reserve roughly half for payload (floor 6, ceil 30) and
|
|
266
|
+
// give the rest to attempts. Static timestamp lines + payload
|
|
267
|
+
// header are accounted for in `staticOverhead`.
|
|
268
|
+
const staticOverhead = 4; // 3 timestamp-ish lines + Payload: header
|
|
269
|
+
const payloadBudget = Math.min(
|
|
270
|
+
30,
|
|
271
|
+
Math.max(6, Math.floor((totalBudget - staticOverhead) / 2)),
|
|
272
|
+
);
|
|
273
|
+
const attemptsBudget = Math.max(
|
|
274
|
+
2,
|
|
275
|
+
totalBudget - staticOverhead - payloadBudget,
|
|
276
|
+
);
|
|
277
|
+
// Each attempt is 1-3 lines (line + optional errorMessage +
|
|
278
|
+
// optional body). Conservative average: 2 lines per attempt.
|
|
279
|
+
const maxAttempts = Math.max(1, Math.floor(attemptsBudget / 2));
|
|
280
|
+
|
|
281
|
+
const base = formatExpandedEvent(e, maxAttempts);
|
|
282
|
+
|
|
283
|
+
try {
|
|
284
|
+
const payload = await manager.getPayload(params.webhookId, e.isn);
|
|
285
|
+
const json = JSON.stringify(payload, null, 2);
|
|
286
|
+
const indented = json.split('\n').map((l) => ' ' + l);
|
|
287
|
+
|
|
288
|
+
let payloadLines = indented;
|
|
289
|
+
let truncationHint = '';
|
|
290
|
+
if (payloadLines.length > payloadBudget) {
|
|
291
|
+
const omitted = payloadLines.length - (payloadBudget - 1);
|
|
292
|
+
payloadLines = payloadLines.slice(0, payloadBudget - 1);
|
|
293
|
+
truncationHint =
|
|
294
|
+
'\n' +
|
|
295
|
+
chalk.dim(
|
|
296
|
+
` … ${omitted} more lines · run \`instant-cli webhook event payload --webhook-id ${params.webhookId} --isn ${e.isn}\` for full output`,
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
return `${base}\n${chalk.dim(' Payload:')}\n${chalk.dim(payloadLines.join('\n'))}${truncationHint}`;
|
|
301
|
+
} catch (err: any) {
|
|
302
|
+
return `${base}\n${chalk.red(` Payload error: ${err instanceof Error ? err.message : String(err)}`)}`;
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
value: e,
|
|
306
|
+
})),
|
|
307
|
+
promptText: params.promptText,
|
|
308
|
+
modifyOutput: UI.modifiers.vanishOnComplete,
|
|
309
|
+
}),
|
|
310
|
+
);
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
export const resolveWebhook = (params: {
|
|
314
|
+
id: string | undefined;
|
|
315
|
+
picker: PickerParams;
|
|
316
|
+
flagName?: string;
|
|
317
|
+
}) =>
|
|
318
|
+
Effect.gen(function* () {
|
|
319
|
+
if (params.id) {
|
|
320
|
+
const all = yield* useWebhooksManager(
|
|
321
|
+
(m) => m.list(),
|
|
322
|
+
'Error listing webhooks',
|
|
323
|
+
);
|
|
324
|
+
const found = all.find((w) => w.id === params.id);
|
|
325
|
+
if (!found) {
|
|
326
|
+
return yield* BadArgsError.make({
|
|
327
|
+
message: `No webhook found with id ${params.id}`,
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
return found;
|
|
331
|
+
}
|
|
332
|
+
const { yes } = yield* GlobalOpts;
|
|
333
|
+
if (yes) {
|
|
334
|
+
return yield* BadArgsError.make({
|
|
335
|
+
message: `Must specify ${params.flagName ?? '--id'}`,
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
return yield* pickWebhook(params.picker);
|
|
339
|
+
});
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { Effect } from 'effect';
|
|
3
|
+
import type {
|
|
4
|
+
UpdateWebhookParams,
|
|
5
|
+
WebhookAction,
|
|
6
|
+
WebhookInfo,
|
|
7
|
+
} from '@instantdb/platform';
|
|
8
|
+
import type { OptsFromCommand, webhooksUpdateDef } from '../../index.ts';
|
|
9
|
+
import { GlobalOpts } from '../../context/globalOpts.ts';
|
|
10
|
+
import { BadArgsError } from '../../errors.ts';
|
|
11
|
+
import { runUIEffect } from '../../lib/ui.ts';
|
|
12
|
+
import {
|
|
13
|
+
getRemoteNamespaces,
|
|
14
|
+
parseActions,
|
|
15
|
+
parseNamespaces,
|
|
16
|
+
useWebhooksManager,
|
|
17
|
+
WEBHOOK_ACTIONS,
|
|
18
|
+
} from '../../lib/webhooks.ts';
|
|
19
|
+
import { UI } from '../../ui/index.ts';
|
|
20
|
+
import {
|
|
21
|
+
joinActions,
|
|
22
|
+
joinNamespaces,
|
|
23
|
+
logWebhookEvent,
|
|
24
|
+
resolveWebhook,
|
|
25
|
+
resolveWebhookId,
|
|
26
|
+
validateWebhookUrl,
|
|
27
|
+
} from './shared.ts';
|
|
28
|
+
|
|
29
|
+
type MenuChoice = 'url' | 'namespaces' | 'actions' | 'save' | 'cancel';
|
|
30
|
+
|
|
31
|
+
const buildUpdateWebhookParams = Effect.fn(function* (
|
|
32
|
+
url: string | undefined,
|
|
33
|
+
namespaces: string[] | undefined,
|
|
34
|
+
actions: WebhookAction[] | undefined,
|
|
35
|
+
) {
|
|
36
|
+
const params: UpdateWebhookParams<any> = {};
|
|
37
|
+
if (url !== undefined) {
|
|
38
|
+
const trimmed = url.trim();
|
|
39
|
+
const err = validateWebhookUrl(trimmed);
|
|
40
|
+
if (err) return yield* BadArgsError.make({ message: err });
|
|
41
|
+
params.url = trimmed;
|
|
42
|
+
}
|
|
43
|
+
if (namespaces) params.namespaces = namespaces;
|
|
44
|
+
if (actions) params.actions = actions;
|
|
45
|
+
return params;
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const sortedEq = (a: readonly string[], b: readonly string[]) => {
|
|
49
|
+
if (a.length !== b.length) return false;
|
|
50
|
+
const aa = [...a].sort();
|
|
51
|
+
const bb = [...b].sort();
|
|
52
|
+
return aa.every((v, i) => v === bb[i]);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const fmtScalar = (current: string, pending: string | undefined) =>
|
|
56
|
+
pending !== undefined && pending !== current
|
|
57
|
+
? `${chalk.green(pending)} ${chalk.dim(`(was ${current})`)}`
|
|
58
|
+
: chalk.dim(current);
|
|
59
|
+
|
|
60
|
+
const fmtList = (
|
|
61
|
+
current: readonly string[],
|
|
62
|
+
pending: readonly string[] | undefined,
|
|
63
|
+
join: (xs: readonly string[]) => string = (xs) => xs.join(', '),
|
|
64
|
+
) =>
|
|
65
|
+
pending !== undefined && !sortedEq(current, pending)
|
|
66
|
+
? `${chalk.green(join(pending))} ${chalk.dim(`(was ${join(current)})`)}`
|
|
67
|
+
: chalk.dim(join(current));
|
|
68
|
+
|
|
69
|
+
export const webhooksUpdateCmd = Effect.fn(
|
|
70
|
+
function* (opts: OptsFromCommand<typeof webhooksUpdateDef>) {
|
|
71
|
+
const { yes } = yield* GlobalOpts;
|
|
72
|
+
const optsNamespaces = yield* parseNamespaces(opts.namespaces);
|
|
73
|
+
const optsActions = yield* parseActions(opts.actions);
|
|
74
|
+
const hasAnyFieldFlag =
|
|
75
|
+
opts.url !== undefined || !!optsNamespaces || !!optsActions;
|
|
76
|
+
|
|
77
|
+
if (yes) {
|
|
78
|
+
if (!opts.id) {
|
|
79
|
+
return yield* BadArgsError.make({ message: 'Must specify --id' });
|
|
80
|
+
}
|
|
81
|
+
if (!hasAnyFieldFlag) {
|
|
82
|
+
return yield* BadArgsError.make({
|
|
83
|
+
message:
|
|
84
|
+
'Must specify at least one of --url, --namespaces, or --actions',
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const params = yield* buildUpdateWebhookParams(
|
|
88
|
+
opts.url,
|
|
89
|
+
optsNamespaces,
|
|
90
|
+
optsActions,
|
|
91
|
+
);
|
|
92
|
+
const webhook = yield* useWebhooksManager(
|
|
93
|
+
(m) => m.update(opts.id!, params),
|
|
94
|
+
'Error updating webhook',
|
|
95
|
+
);
|
|
96
|
+
yield* logUpdated(webhook);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (hasAnyFieldFlag) {
|
|
101
|
+
const id = yield* resolveWebhookId({
|
|
102
|
+
id: opts.id,
|
|
103
|
+
picker: {
|
|
104
|
+
promptText: 'Select a webhook to update:',
|
|
105
|
+
emptyMessage: 'No webhooks configured.',
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
if (!id) return;
|
|
109
|
+
const params = yield* buildUpdateWebhookParams(
|
|
110
|
+
opts.url,
|
|
111
|
+
optsNamespaces,
|
|
112
|
+
optsActions,
|
|
113
|
+
);
|
|
114
|
+
const webhook = yield* useWebhooksManager(
|
|
115
|
+
(m) => m.update(id, params),
|
|
116
|
+
'Error updating webhook',
|
|
117
|
+
);
|
|
118
|
+
yield* logUpdated(webhook);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const current = yield* resolveWebhook({
|
|
123
|
+
id: opts.id,
|
|
124
|
+
picker: {
|
|
125
|
+
promptText: 'Select a webhook to update:',
|
|
126
|
+
emptyMessage: 'No webhooks configured.',
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
if (!current) return;
|
|
130
|
+
|
|
131
|
+
const pending: UpdateWebhookParams<any> = {};
|
|
132
|
+
let cursor: MenuChoice = 'url';
|
|
133
|
+
|
|
134
|
+
while (true) {
|
|
135
|
+
const choice: MenuChoice = yield* runUIEffect(
|
|
136
|
+
new UI.Select<MenuChoice>({
|
|
137
|
+
promptText: `Editing webhook ${chalk.cyan(current.sink.url)} ${chalk.dim(`(${current.id})`)}`,
|
|
138
|
+
defaultValue: cursor,
|
|
139
|
+
modifyOutput: UI.modifiers.vanishOnComplete,
|
|
140
|
+
options: [
|
|
141
|
+
{
|
|
142
|
+
value: 'url',
|
|
143
|
+
label: `URL: ${fmtScalar(current.sink.url, pending.url)}`,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
value: 'actions',
|
|
147
|
+
label: `Actions: ${fmtList(current.actions, pending.actions, joinActions)}`,
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
value: 'namespaces',
|
|
151
|
+
label: `Namespaces: ${fmtList(current.namespaces, pending.namespaces, joinNamespaces)}`,
|
|
152
|
+
},
|
|
153
|
+
{ value: 'save', label: 'Save changes', secondary: true },
|
|
154
|
+
{ value: 'cancel', label: 'Cancel', secondary: true },
|
|
155
|
+
],
|
|
156
|
+
}),
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
if (choice === 'cancel') {
|
|
160
|
+
yield* Effect.log('Cancelled.');
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (choice === 'save') {
|
|
164
|
+
if (!hasPending(pending, current)) {
|
|
165
|
+
yield* Effect.log('No changes to save.');
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
cursor = choice;
|
|
172
|
+
|
|
173
|
+
if (choice === 'url') {
|
|
174
|
+
const seed = pending.url ?? current.sink.url;
|
|
175
|
+
const rawUrl = yield* runUIEffect(
|
|
176
|
+
new UI.TextInput({
|
|
177
|
+
prompt: 'Webhook URL:',
|
|
178
|
+
defaultValue: seed,
|
|
179
|
+
placeholder: seed,
|
|
180
|
+
validate: (v) => validateWebhookUrl(v.trim()),
|
|
181
|
+
modifyOutput: UI.modifiers.piped([
|
|
182
|
+
UI.modifiers.topPadding,
|
|
183
|
+
UI.modifiers.vanishOnComplete,
|
|
184
|
+
]),
|
|
185
|
+
}),
|
|
186
|
+
);
|
|
187
|
+
pending.url = rawUrl.trim();
|
|
188
|
+
} else if (choice === 'namespaces') {
|
|
189
|
+
pending.namespaces = yield* promptNamespaces(
|
|
190
|
+
pending.namespaces ?? current.namespaces,
|
|
191
|
+
);
|
|
192
|
+
} else if (choice === 'actions') {
|
|
193
|
+
pending.actions = yield* runUIEffect(
|
|
194
|
+
new UI.MultiSelect<WebhookAction>({
|
|
195
|
+
options: WEBHOOK_ACTIONS.map((a) => ({ value: a, label: a })),
|
|
196
|
+
promptText: 'Actions to trigger on:',
|
|
197
|
+
initialSelected: pending.actions ?? current.actions,
|
|
198
|
+
minSelected: 1,
|
|
199
|
+
modifyOutput: UI.modifiers.vanishOnComplete,
|
|
200
|
+
}),
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const webhook = yield* useWebhooksManager(
|
|
206
|
+
(m) => m.update(current.id, pending),
|
|
207
|
+
'Error updating webhook',
|
|
208
|
+
);
|
|
209
|
+
yield* logUpdated(webhook);
|
|
210
|
+
},
|
|
211
|
+
Effect.catchTag('BadArgsError', (e) =>
|
|
212
|
+
Effect.gen(function* () {
|
|
213
|
+
yield* Effect.logError(e.message);
|
|
214
|
+
yield* Effect.log(
|
|
215
|
+
chalk.dim(
|
|
216
|
+
'hint: run `instant-cli webhook update --help` for available arguments',
|
|
217
|
+
),
|
|
218
|
+
);
|
|
219
|
+
}),
|
|
220
|
+
),
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
const promptNamespaces = Effect.fn(function* (initial: readonly string[]) {
|
|
224
|
+
const available = yield* getRemoteNamespaces;
|
|
225
|
+
if (available && available.length > 0) {
|
|
226
|
+
return yield* runUIEffect(
|
|
227
|
+
new UI.MultiSelect<string>({
|
|
228
|
+
options: available.map((name) => ({ value: name, label: name })),
|
|
229
|
+
promptText: 'Namespaces to listen to:',
|
|
230
|
+
initialSelected: [...initial],
|
|
231
|
+
minSelected: 1,
|
|
232
|
+
modifyOutput: UI.modifiers.vanishOnComplete,
|
|
233
|
+
}),
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
const raw = yield* runUIEffect(
|
|
237
|
+
new UI.TextInput({
|
|
238
|
+
prompt: 'Namespaces (comma-separated):',
|
|
239
|
+
defaultValue: initial.join(','),
|
|
240
|
+
placeholder: initial.join(','),
|
|
241
|
+
modifyOutput: UI.modifiers.piped([
|
|
242
|
+
UI.modifiers.topPadding,
|
|
243
|
+
UI.modifiers.vanishOnComplete,
|
|
244
|
+
]),
|
|
245
|
+
}),
|
|
246
|
+
);
|
|
247
|
+
const parsed = yield* parseNamespaces(raw);
|
|
248
|
+
if (!parsed) {
|
|
249
|
+
return yield* BadArgsError.make({
|
|
250
|
+
message: '--namespaces must include at least one namespace',
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
return parsed;
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
const hasPending = (
|
|
257
|
+
pending: UpdateWebhookParams<any>,
|
|
258
|
+
current: WebhookInfo,
|
|
259
|
+
) => {
|
|
260
|
+
if (pending.url !== undefined && pending.url !== current.sink.url)
|
|
261
|
+
return true;
|
|
262
|
+
if (
|
|
263
|
+
pending.namespaces !== undefined &&
|
|
264
|
+
!sortedEq(pending.namespaces, current.namespaces)
|
|
265
|
+
)
|
|
266
|
+
return true;
|
|
267
|
+
if (
|
|
268
|
+
pending.actions !== undefined &&
|
|
269
|
+
!sortedEq(pending.actions, current.actions)
|
|
270
|
+
)
|
|
271
|
+
return true;
|
|
272
|
+
return false;
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
const logUpdated = (webhook: WebhookInfo) =>
|
|
276
|
+
logWebhookEvent('updated', webhook);
|