@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,308 @@
|
|
|
1
|
+
import { test, expect, describe, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { Effect, Layer, Logger } from 'effect';
|
|
3
|
+
import { GlobalOpts } from '../src/context/globalOpts.ts';
|
|
4
|
+
import { CurrentApp } from '../src/context/currentApp.ts';
|
|
5
|
+
import { InstantHttpAuthed } from '../src/lib/http.ts';
|
|
6
|
+
|
|
7
|
+
// -- mocks --
|
|
8
|
+
|
|
9
|
+
// Prevent src/index.ts side-effect (program.parse) from running.
|
|
10
|
+
// The command files import types from index.ts, but vitest still evaluates it.
|
|
11
|
+
vi.mock('../src/index.ts', () => ({}));
|
|
12
|
+
|
|
13
|
+
let prompts: any[] = [];
|
|
14
|
+
let mockPromptReturn: any = '';
|
|
15
|
+
|
|
16
|
+
vi.mock('../src/ui/lib.ts', async (importOriginal) => {
|
|
17
|
+
const orig: any = await importOriginal();
|
|
18
|
+
return {
|
|
19
|
+
...orig,
|
|
20
|
+
renderUnwrap: (prompt: any) => {
|
|
21
|
+
prompts.push(prompt);
|
|
22
|
+
return Promise.resolve(mockPromptReturn);
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
let origins: any[] = [];
|
|
28
|
+
let addedOrigins: any[] = [];
|
|
29
|
+
let removedOriginIds: string[] = [];
|
|
30
|
+
|
|
31
|
+
vi.mock('../src/lib/oauth.ts', async (importOriginal) => {
|
|
32
|
+
const orig: any = await importOriginal();
|
|
33
|
+
return {
|
|
34
|
+
...orig,
|
|
35
|
+
getAppsAuth: () =>
|
|
36
|
+
Effect.succeed({
|
|
37
|
+
authorized_redirect_origins: origins,
|
|
38
|
+
oauth_service_providers: [],
|
|
39
|
+
oauth_clients: [],
|
|
40
|
+
}),
|
|
41
|
+
addAuthorizedOrigin: (params: any) => {
|
|
42
|
+
addedOrigins.push(params);
|
|
43
|
+
return Effect.succeed({
|
|
44
|
+
origin: {
|
|
45
|
+
id: `origin-${addedOrigins.length}`,
|
|
46
|
+
service: params.service,
|
|
47
|
+
params: params.params,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
removeAuthorizedOrigin: (originId: string) => {
|
|
52
|
+
removedOriginIds.push(originId);
|
|
53
|
+
return Effect.succeed({
|
|
54
|
+
origin: origins.find((origin) => origin.id === originId) ?? {
|
|
55
|
+
id: originId,
|
|
56
|
+
service: 'generic',
|
|
57
|
+
params: ['example.com'],
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Lazy import so mocks are in place.
|
|
65
|
+
const { authOriginAddCmd } = await import('../src/commands/auth/origin/add.ts');
|
|
66
|
+
const { authOriginDeleteCmd } = await import(
|
|
67
|
+
'../src/commands/auth/origin/delete.ts'
|
|
68
|
+
);
|
|
69
|
+
const { authOriginListCmd } = await import(
|
|
70
|
+
'../src/commands/auth/origin/list.ts'
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
// -- helpers --
|
|
74
|
+
|
|
75
|
+
let logs: string[] = [];
|
|
76
|
+
|
|
77
|
+
type TestContext = GlobalOpts | CurrentApp | InstantHttpAuthed;
|
|
78
|
+
|
|
79
|
+
const run = (
|
|
80
|
+
cmd: Effect.Effect<void, any, TestContext>,
|
|
81
|
+
{ yes }: { yes: boolean },
|
|
82
|
+
) =>
|
|
83
|
+
Effect.runPromise(
|
|
84
|
+
cmd.pipe(
|
|
85
|
+
Effect.provide(
|
|
86
|
+
Layer.mergeAll(
|
|
87
|
+
Layer.succeed(GlobalOpts, { yes }),
|
|
88
|
+
Layer.succeed(CurrentApp, { appId: 'test-app', source: 'env' }),
|
|
89
|
+
Layer.succeed(InstantHttpAuthed, {} as any),
|
|
90
|
+
Logger.replace(
|
|
91
|
+
Logger.defaultLogger,
|
|
92
|
+
Logger.make(({ message }) => {
|
|
93
|
+
logs.push(String(message));
|
|
94
|
+
}),
|
|
95
|
+
),
|
|
96
|
+
),
|
|
97
|
+
),
|
|
98
|
+
),
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const add = (flags: Map<string, string>, opts = { yes: true }) =>
|
|
102
|
+
run(authOriginAddCmd(Object.fromEntries(flags) as any), opts);
|
|
103
|
+
|
|
104
|
+
const list = (flags: Map<string, any>, opts = { yes: true }) =>
|
|
105
|
+
run(authOriginListCmd(Object.fromEntries(flags) as any), opts);
|
|
106
|
+
|
|
107
|
+
const remove = (flags: Map<string, string>, opts = { yes: true }) =>
|
|
108
|
+
run(authOriginDeleteCmd(Object.fromEntries(flags) as any), opts);
|
|
109
|
+
|
|
110
|
+
const without = (flags: Map<string, string>, key: string) => {
|
|
111
|
+
const copy = new Map(flags);
|
|
112
|
+
copy.delete(key);
|
|
113
|
+
return copy;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
beforeEach(() => {
|
|
117
|
+
prompts = [];
|
|
118
|
+
origins = [];
|
|
119
|
+
addedOrigins = [];
|
|
120
|
+
removedOriginIds = [];
|
|
121
|
+
logs = [];
|
|
122
|
+
mockPromptReturn = '';
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// -- flag sets --
|
|
126
|
+
|
|
127
|
+
const websiteFlags = new Map([
|
|
128
|
+
['type', 'website'],
|
|
129
|
+
['url', 'https://example.com/login'],
|
|
130
|
+
]);
|
|
131
|
+
|
|
132
|
+
const vercelFlags = new Map([
|
|
133
|
+
['type', 'vercel'],
|
|
134
|
+
['project', 'instant-preview'],
|
|
135
|
+
]);
|
|
136
|
+
|
|
137
|
+
const netlifyFlags = new Map([
|
|
138
|
+
['type', 'netlify'],
|
|
139
|
+
['site', 'instant-netlify'],
|
|
140
|
+
]);
|
|
141
|
+
|
|
142
|
+
const customSchemeFlags = new Map([
|
|
143
|
+
['type', 'custom-scheme'],
|
|
144
|
+
['scheme', 'instant://'],
|
|
145
|
+
]);
|
|
146
|
+
|
|
147
|
+
// -- add: build-up with --yes --
|
|
148
|
+
|
|
149
|
+
describe('add: --yes errors on missing required flags', () => {
|
|
150
|
+
test('missing --type', async () => {
|
|
151
|
+
await add(without(websiteFlags, 'type'), { yes: true });
|
|
152
|
+
expect(logs.join('\n')).toContain('Missing required value for --type');
|
|
153
|
+
expect(addedOrigins).toHaveLength(0);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test('website missing --url', async () => {
|
|
157
|
+
await add(without(websiteFlags, 'url'), { yes: true });
|
|
158
|
+
expect(logs.join('\n')).toContain('Missing required value for --url');
|
|
159
|
+
expect(addedOrigins).toHaveLength(0);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
test('vercel missing --project', async () => {
|
|
163
|
+
await add(without(vercelFlags, 'project'), { yes: true });
|
|
164
|
+
expect(logs.join('\n')).toContain('Missing required value for --project');
|
|
165
|
+
expect(addedOrigins).toHaveLength(0);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
test('netlify missing --site', async () => {
|
|
169
|
+
await add(without(netlifyFlags, 'site'), { yes: true });
|
|
170
|
+
expect(logs.join('\n')).toContain('Missing required value for --site');
|
|
171
|
+
expect(addedOrigins).toHaveLength(0);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
test('custom scheme missing --scheme', async () => {
|
|
175
|
+
await add(without(customSchemeFlags, 'scheme'), { yes: true });
|
|
176
|
+
expect(logs.join('\n')).toContain('Missing required value for --scheme');
|
|
177
|
+
expect(addedOrigins).toHaveLength(0);
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// -- add: interactive prompts --
|
|
182
|
+
|
|
183
|
+
describe('add: interactive prompts for missing flags', () => {
|
|
184
|
+
test('missing --type -> prompts type selector', async () => {
|
|
185
|
+
mockPromptReturn = 'website';
|
|
186
|
+
await add(without(websiteFlags, 'type'), { yes: false });
|
|
187
|
+
expect((prompts[0] as any).params.promptText).toBe(
|
|
188
|
+
'Select an origin type:',
|
|
189
|
+
);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
test('website missing --url -> prompts for URL', async () => {
|
|
193
|
+
mockPromptReturn = 'example.com';
|
|
194
|
+
await add(without(websiteFlags, 'url'), { yes: false });
|
|
195
|
+
expect((prompts[0] as any).props.prompt).toBe('Website URL:');
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
test('delete missing --id -> prompts origin selector', async () => {
|
|
199
|
+
origins = [{ id: 'origin-1', service: 'generic', params: ['example.com'] }];
|
|
200
|
+
mockPromptReturn = origins[0];
|
|
201
|
+
await remove(new Map(), { yes: false });
|
|
202
|
+
expect((prompts[0] as any).params.promptText).toBe(
|
|
203
|
+
'Select an origin to delete:',
|
|
204
|
+
);
|
|
205
|
+
expect(removedOriginIds).toEqual(['origin-1']);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
// -- add: success --
|
|
210
|
+
|
|
211
|
+
describe('add: success', () => {
|
|
212
|
+
test('website origin -> creates generic origin with host only', async () => {
|
|
213
|
+
await add(websiteFlags, { yes: true });
|
|
214
|
+
expect(addedOrigins).toEqual([
|
|
215
|
+
{ service: 'generic', params: ['example.com'] },
|
|
216
|
+
]);
|
|
217
|
+
const output = logs.join('\n');
|
|
218
|
+
expect(output).toContain('Origin added: example.com');
|
|
219
|
+
expect(output).toContain('Type: Website');
|
|
220
|
+
expect(output).toContain('ID: origin-1');
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
test('website origin without protocol -> accepts domain', async () => {
|
|
224
|
+
await add(
|
|
225
|
+
new Map([
|
|
226
|
+
['type', 'website'],
|
|
227
|
+
['url', 'example.org'],
|
|
228
|
+
]),
|
|
229
|
+
{ yes: true },
|
|
230
|
+
);
|
|
231
|
+
expect(addedOrigins).toEqual([
|
|
232
|
+
{ service: 'generic', params: ['example.org'] },
|
|
233
|
+
]);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
test('vercel origin -> creates vercel origin params', async () => {
|
|
237
|
+
await add(vercelFlags, { yes: true });
|
|
238
|
+
expect(addedOrigins).toEqual([
|
|
239
|
+
{ service: 'vercel', params: ['vercel.app', 'instant-preview'] },
|
|
240
|
+
]);
|
|
241
|
+
expect(logs.join('\n')).toContain('Origin added: instant-preview');
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
test('netlify origin -> creates netlify origin params', async () => {
|
|
245
|
+
await add(netlifyFlags, { yes: true });
|
|
246
|
+
expect(addedOrigins).toEqual([
|
|
247
|
+
{ service: 'netlify', params: ['instant-netlify'] },
|
|
248
|
+
]);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
test('custom scheme origin -> creates custom scheme origin params', async () => {
|
|
252
|
+
await add(customSchemeFlags, { yes: true });
|
|
253
|
+
expect(addedOrigins).toEqual([
|
|
254
|
+
{ service: 'custom-scheme', params: ['instant'] },
|
|
255
|
+
]);
|
|
256
|
+
expect(logs.join('\n')).toContain('Origin added: instant://');
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
// -- list and delete --
|
|
261
|
+
|
|
262
|
+
describe('list', () => {
|
|
263
|
+
test('prints configured origins', async () => {
|
|
264
|
+
origins = [
|
|
265
|
+
{ id: 'origin-1', service: 'generic', params: ['example.com'] },
|
|
266
|
+
{ id: 'origin-2', service: 'vercel', params: ['vercel.app', 'preview'] },
|
|
267
|
+
];
|
|
268
|
+
await list(new Map(), { yes: true });
|
|
269
|
+
const output = logs.join('\n');
|
|
270
|
+
expect(output).toContain('example.com');
|
|
271
|
+
expect(output).toContain('Type: Website');
|
|
272
|
+
expect(output).toContain('ID: origin-1');
|
|
273
|
+
expect(output).toContain('preview');
|
|
274
|
+
expect(output).toContain('Type: Vercel project');
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
test('--json prints raw origins', async () => {
|
|
278
|
+
origins = [{ id: 'origin-1', service: 'generic', params: ['example.com'] }];
|
|
279
|
+
await list(new Map([['json', true]]), { yes: true });
|
|
280
|
+
expect(JSON.parse(logs.join('\n'))).toEqual(origins);
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
describe('delete', () => {
|
|
285
|
+
test('--id removes origin', async () => {
|
|
286
|
+
origins = [{ id: 'origin-1', service: 'generic', params: ['example.com'] }];
|
|
287
|
+
await remove(new Map([['id', 'origin-1']]), { yes: true });
|
|
288
|
+
expect(removedOriginIds).toEqual(['origin-1']);
|
|
289
|
+
expect(logs.join('\n')).toContain('Origin deleted!');
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
test('missing --id with --yes errors', async () => {
|
|
293
|
+
origins = [{ id: 'origin-1', service: 'generic', params: ['example.com'] }];
|
|
294
|
+
await expect(remove(new Map(), { yes: true })).rejects.toThrow(
|
|
295
|
+
'Must specify --id',
|
|
296
|
+
);
|
|
297
|
+
expect(removedOriginIds).toHaveLength(0);
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
test('no origins exits without deleting', async () => {
|
|
301
|
+
await remove(new Map(), { yes: false });
|
|
302
|
+
expect(logs.join('\n')).toContain(
|
|
303
|
+
'No authorized redirect origins configured.',
|
|
304
|
+
);
|
|
305
|
+
expect(prompts).toHaveLength(0);
|
|
306
|
+
expect(removedOriginIds).toHaveLength(0);
|
|
307
|
+
});
|
|
308
|
+
});
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { test, expect, describe, beforeAll, afterAll, afterEach } from 'vitest';
|
|
2
|
+
import { createServer, type Server } from 'node:http';
|
|
3
|
+
import { existsSync, readdirSync } from 'node:fs';
|
|
4
|
+
import { readFile, rm } from 'node:fs/promises';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
import { basename, join } from 'node:path';
|
|
7
|
+
import { once } from 'node:events';
|
|
8
|
+
import zlib from 'node:zlib';
|
|
9
|
+
import { BackupsManager } from '@instantdb/platform';
|
|
10
|
+
import { downloadBackupToFile } from '../src/lib/backupDownload.ts';
|
|
11
|
+
|
|
12
|
+
// Exercises the real pipeline end-to-end against a local HTTP server: zstd
|
|
13
|
+
// decompression of entity shards, canonical entry order (config.json, then
|
|
14
|
+
// entities/*.jsonl, then files/<locationId>), and the partial-file rename.
|
|
15
|
+
|
|
16
|
+
// Not yet in this @types/node version, same as createZstdDecompress in the
|
|
17
|
+
// pipeline itself.
|
|
18
|
+
const zstd = (s: string): Buffer =>
|
|
19
|
+
(zlib as any).zstdCompressSync(Buffer.from(s));
|
|
20
|
+
|
|
21
|
+
const bodies: Record<string, { body: Buffer; encoding?: string }> = {
|
|
22
|
+
'/config.json': { body: zstd('{"schema":{}}'), encoding: 'zstd' },
|
|
23
|
+
'/entities/todos.jsonl': {
|
|
24
|
+
body: zstd('{"entity":{"id":"1"}}\n'),
|
|
25
|
+
encoding: 'zstd',
|
|
26
|
+
},
|
|
27
|
+
'/entities/$files.jsonl': {
|
|
28
|
+
body: zstd('{"entity":{"location-id":"loc-1"}}\n'),
|
|
29
|
+
encoding: 'zstd',
|
|
30
|
+
},
|
|
31
|
+
'/blobs/loc-1': { body: Buffer.from('blob-one') },
|
|
32
|
+
'/blobs/loc-2': { body: Buffer.from('blob-two') },
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
let server: Server;
|
|
36
|
+
let baseUrl: string;
|
|
37
|
+
|
|
38
|
+
beforeAll(async () => {
|
|
39
|
+
server = createServer((req, res) => {
|
|
40
|
+
const found = bodies[req.url ?? ''];
|
|
41
|
+
if (!found) {
|
|
42
|
+
res.writeHead(404).end();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const headers: Record<string, string> = {};
|
|
46
|
+
if (found.encoding) headers['content-encoding'] = found.encoding;
|
|
47
|
+
res.writeHead(200, headers).end(found.body);
|
|
48
|
+
});
|
|
49
|
+
server.listen(0);
|
|
50
|
+
await once(server, 'listening');
|
|
51
|
+
const address = server.address();
|
|
52
|
+
if (typeof address === 'string' || address === null) {
|
|
53
|
+
throw new Error('Expected a TCP address');
|
|
54
|
+
}
|
|
55
|
+
baseUrl = `http://127.0.0.1:${address.port}`;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
afterAll(() => {
|
|
59
|
+
server.close();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const backup = {
|
|
63
|
+
id: 'backup-1',
|
|
64
|
+
isn: '1',
|
|
65
|
+
backupAt: new Date('2026-08-01T00:00:00Z'),
|
|
66
|
+
filesSize: 16,
|
|
67
|
+
dbSize: 100,
|
|
68
|
+
uncompressedSize: 40,
|
|
69
|
+
description: null,
|
|
70
|
+
expiresAt: new Date('2026-08-08T00:00:00Z'),
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const storageFiles = [
|
|
74
|
+
{ locationId: 'loc-1', path: 'a.png', url: () => `${baseUrl}/blobs/loc-1` },
|
|
75
|
+
{ locationId: 'loc-2', path: 'b.png', url: () => `${baseUrl}/blobs/loc-2` },
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
const manager = {
|
|
79
|
+
listFiles: async (_backupId: string) => [
|
|
80
|
+
{ name: 'config.json', size: 10 },
|
|
81
|
+
{ name: 'entities/todos.jsonl', size: 10 },
|
|
82
|
+
{ name: 'entities/$files.jsonl', size: 10 },
|
|
83
|
+
],
|
|
84
|
+
getFileUrl: async (_backupId: string, name: string) => `${baseUrl}/${name}`,
|
|
85
|
+
streamStorageFiles: async function* (
|
|
86
|
+
_backupId: string,
|
|
87
|
+
_opts?: { signal?: AbortSignal },
|
|
88
|
+
) {
|
|
89
|
+
for (const f of storageFiles) {
|
|
90
|
+
yield { locationId: f.locationId, path: f.path, url: f.url() };
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
// Borrow the real method so the test drives the production pipeline
|
|
94
|
+
// against this fake's endpoints.
|
|
95
|
+
downloadArchive(opts: unknown) {
|
|
96
|
+
return (BackupsManager.prototype.downloadArchive as any).call(this, opts);
|
|
97
|
+
},
|
|
98
|
+
} as any;
|
|
99
|
+
|
|
100
|
+
const outPath = join(tmpdir(), `backup-download-test-${process.pid}.zip`);
|
|
101
|
+
|
|
102
|
+
// The partial file carries a random suffix, so scan for leftovers by prefix.
|
|
103
|
+
const partialLeftovers = () =>
|
|
104
|
+
readdirSync(tmpdir()).filter((f) =>
|
|
105
|
+
f.startsWith(`${basename(outPath)}.partial`),
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
afterEach(async () => {
|
|
109
|
+
await rm(outPath, { force: true });
|
|
110
|
+
for (const f of partialLeftovers()) {
|
|
111
|
+
await rm(join(tmpdir(), f), { force: true });
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
describe('downloadBackupToFile', () => {
|
|
116
|
+
test('writes a zip with the canonical entry order', async () => {
|
|
117
|
+
const result = await downloadBackupToFile({
|
|
118
|
+
manager,
|
|
119
|
+
backup,
|
|
120
|
+
outPath,
|
|
121
|
+
signal: new AbortController().signal,
|
|
122
|
+
onProgress: () => {},
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
expect(result.entities).toBe(2);
|
|
126
|
+
expect(result.files).toBe(2);
|
|
127
|
+
expect(partialLeftovers()).toEqual([]);
|
|
128
|
+
|
|
129
|
+
const { ZipReader, Uint8ArrayReader, TextWriter } = await import(
|
|
130
|
+
'@zip.js/zip.js'
|
|
131
|
+
);
|
|
132
|
+
const reader = new ZipReader(
|
|
133
|
+
new Uint8ArrayReader(new Uint8Array(await readFile(outPath))),
|
|
134
|
+
);
|
|
135
|
+
const entries = await reader.getEntries();
|
|
136
|
+
|
|
137
|
+
// Entry order is the restore contract: config first, all entity shards
|
|
138
|
+
// before any storage blob.
|
|
139
|
+
expect(entries.map((e) => e.filename)).toEqual([
|
|
140
|
+
'config.json',
|
|
141
|
+
'entities/todos.jsonl',
|
|
142
|
+
'entities/$files.jsonl',
|
|
143
|
+
'files/loc-1',
|
|
144
|
+
'files/loc-2',
|
|
145
|
+
]);
|
|
146
|
+
|
|
147
|
+
// Entity shards land decompressed; blobs land verbatim.
|
|
148
|
+
const readText = (entry: any) => entry.getData(new TextWriter());
|
|
149
|
+
expect(await readText(entries[0])).toBe('{"schema":{}}');
|
|
150
|
+
expect(await readText(entries[1])).toBe('{"entity":{"id":"1"}}\n');
|
|
151
|
+
expect(await readText(entries[3])).toBe('blob-one');
|
|
152
|
+
expect(await readText(entries[4])).toBe('blob-two');
|
|
153
|
+
await reader.close();
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test('removes the partial file when a fetch fails', async () => {
|
|
157
|
+
const failingManager = {
|
|
158
|
+
...manager,
|
|
159
|
+
getFileUrl: async (_backupId: string, name: string) =>
|
|
160
|
+
`${baseUrl}/missing-${name}`,
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
await expect(
|
|
164
|
+
downloadBackupToFile({
|
|
165
|
+
manager: failingManager,
|
|
166
|
+
backup,
|
|
167
|
+
outPath,
|
|
168
|
+
signal: new AbortController().signal,
|
|
169
|
+
onProgress: () => {},
|
|
170
|
+
}),
|
|
171
|
+
).rejects.toThrow(/Failed to fetch config.json/);
|
|
172
|
+
|
|
173
|
+
expect(existsSync(outPath)).toBe(false);
|
|
174
|
+
expect(partialLeftovers()).toEqual([]);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test('aborting removes the partial file', async () => {
|
|
178
|
+
const controller = new AbortController();
|
|
179
|
+
const slowManager = {
|
|
180
|
+
...manager,
|
|
181
|
+
streamStorageFiles: async function* () {
|
|
182
|
+
yield {
|
|
183
|
+
locationId: 'loc-1',
|
|
184
|
+
path: 'a.png',
|
|
185
|
+
url: `${baseUrl}/blobs/loc-1`,
|
|
186
|
+
};
|
|
187
|
+
controller.abort();
|
|
188
|
+
// Give the pipeline a moment to observe the abort mid-drain.
|
|
189
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
await expect(
|
|
194
|
+
downloadBackupToFile({
|
|
195
|
+
manager: slowManager,
|
|
196
|
+
backup,
|
|
197
|
+
outPath,
|
|
198
|
+
signal: controller.signal,
|
|
199
|
+
onProgress: () => {},
|
|
200
|
+
}),
|
|
201
|
+
).rejects.toThrow();
|
|
202
|
+
|
|
203
|
+
expect(existsSync(outPath)).toBe(false);
|
|
204
|
+
expect(partialLeftovers()).toEqual([]);
|
|
205
|
+
});
|
|
206
|
+
});
|