@superlayer/cli 1.0.67
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.md +202 -0
- package/NOTICE +4 -0
- package/README.md +67 -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 +152 -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/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 +96 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,714 @@
|
|
|
1
|
+
import { loadEnv } from "./util/loadEnv.js";
|
|
2
|
+
loadEnv();
|
|
3
|
+
import minimist from 'minimist';
|
|
4
|
+
import { Command, Option } from '@commander-js/extra-typings';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import { Effect, Layer } from 'effect';
|
|
7
|
+
import version from './version.js';
|
|
8
|
+
import { initCommand } from "./commands/init.js";
|
|
9
|
+
import { initWithoutFilesCommand } from "./commands/initWithoutFiles.js";
|
|
10
|
+
import { loginCommand } from "./commands/login.js";
|
|
11
|
+
import { logoutCommand } from "./commands/logout.js";
|
|
12
|
+
import { AuthLayerLive, BaseLayerLive, runCommandEffect, WithAppLayer, } from "./layer.js";
|
|
13
|
+
import { infoCommand } from "./commands/info.js";
|
|
14
|
+
import { pullCommand } from "./commands/pull.js";
|
|
15
|
+
import { claimCommand } from "./commands/claim.js";
|
|
16
|
+
import { pushCommand } from "./commands/push.js";
|
|
17
|
+
import { explorerCmd } from "./commands/explorer.js";
|
|
18
|
+
import { queryCmd } from "./commands/query.js";
|
|
19
|
+
import { program } from "./program.js";
|
|
20
|
+
import { PACKAGE_ALIAS_AND_FULL_NAMES } from "./context/projectInfo.js";
|
|
21
|
+
import { authClientAddCmd } from "./commands/auth/client/add.js";
|
|
22
|
+
import { authClientListCmd } from "./commands/auth/client/list.js";
|
|
23
|
+
import { authClientDeleteCmd } from "./commands/auth/client/delete.js";
|
|
24
|
+
import { authClientUpdateCmd } from "./commands/auth/client/update.js";
|
|
25
|
+
import { authOriginListCmd } from "./commands/auth/origin/list.js";
|
|
26
|
+
import { authOriginDeleteCmd } from "./commands/auth/origin/delete.js";
|
|
27
|
+
import { authOriginAddCmd } from "./commands/auth/origin/add.js";
|
|
28
|
+
import { authEmailPushCmd } from "./commands/auth/email/push.js";
|
|
29
|
+
import { authEmailPullCmd } from "./commands/auth/email/pull.js";
|
|
30
|
+
import { authEmailResetCmd } from "./commands/auth/email/reset.js";
|
|
31
|
+
import { link } from "./logging.js";
|
|
32
|
+
import { appListCommand } from "./commands/app/list.js";
|
|
33
|
+
import { appDeleteCommand } from "./commands/app/delete.js";
|
|
34
|
+
import { webhooksListCmd } from "./commands/webhooks/list.js";
|
|
35
|
+
import { webhooksAddCmd } from "./commands/webhooks/add.js";
|
|
36
|
+
import { webhooksUpdateCmd } from "./commands/webhooks/update.js";
|
|
37
|
+
import { webhooksDeleteCmd } from "./commands/webhooks/delete.js";
|
|
38
|
+
import { webhooksEnableCmd } from "./commands/webhooks/enable.js";
|
|
39
|
+
import { webhooksDisableCmd } from "./commands/webhooks/disable.js";
|
|
40
|
+
import { webhooksEventsListCmd } from "./commands/webhooks/events/list.js";
|
|
41
|
+
import { webhooksEventsPayloadCmd } from "./commands/webhooks/events/payload.js";
|
|
42
|
+
import { webhooksEventsResendCmd } from "./commands/webhooks/events/resend.js";
|
|
43
|
+
import { emailStatusCmd } from "./commands/auth/email/status.js";
|
|
44
|
+
import { verifyCmd } from "./commands/auth/email/verify.js";
|
|
45
|
+
import { resendEmailCmd } from "./commands/auth/email/resend.js";
|
|
46
|
+
import { backupListCmd } from "./commands/backup/list.js";
|
|
47
|
+
import { backupDownloadCmd } from "./commands/backup/download.js";
|
|
48
|
+
program
|
|
49
|
+
.name('superlayer')
|
|
50
|
+
.addOption(globalOption('-t --token <token>', 'Auth token override'))
|
|
51
|
+
.addOption(globalOption('-y --yes', "Answer 'yes' to all prompts"))
|
|
52
|
+
.addOption(globalOption('--env <file>', 'Use a specific .env file'))
|
|
53
|
+
.addOption(globalOption('-v --version', 'Print the version number', () => {
|
|
54
|
+
console.log(version);
|
|
55
|
+
process.exit(0);
|
|
56
|
+
}))
|
|
57
|
+
.addHelpOption(globalOption('-h --help', 'Print the help text for a command'))
|
|
58
|
+
.usage(`<command> ${chalk.dim('[options] [args]')}`);
|
|
59
|
+
// Command List
|
|
60
|
+
export const initDef = program
|
|
61
|
+
.command('init')
|
|
62
|
+
.description('Set up a new project.')
|
|
63
|
+
.option('-a --app <app-id>', 'If you have an existing app ID, we can pull schema and perms from there.')
|
|
64
|
+
.option('-p --package <react|react-native|core|admin|solid|svelte>', 'Which package to automatically install if there is not one installed already.')
|
|
65
|
+
.option('--title <title>', 'Title for the created app')
|
|
66
|
+
.option('--temp', 'Create a temporary app which will automatically delete itself after >24 hours.')
|
|
67
|
+
.action((options) => {
|
|
68
|
+
return runCommandEffect(initCommand(options).pipe(Effect.provide(WithAppLayer({
|
|
69
|
+
coerce: true,
|
|
70
|
+
coerceAuth: true,
|
|
71
|
+
title: options.title,
|
|
72
|
+
appId: options.app,
|
|
73
|
+
packageName: options.package,
|
|
74
|
+
applyEnv: true,
|
|
75
|
+
temp: options.temp,
|
|
76
|
+
}))));
|
|
77
|
+
});
|
|
78
|
+
const auth = program
|
|
79
|
+
.command('auth')
|
|
80
|
+
.description('Manage authentication for your app');
|
|
81
|
+
const app = program
|
|
82
|
+
.command('app')
|
|
83
|
+
.description('Manage individual Superlayer apps');
|
|
84
|
+
export const appListDef = app
|
|
85
|
+
.command('list')
|
|
86
|
+
.description('List apps on your Superlayer account')
|
|
87
|
+
.option('--json', 'Output apps as JSON')
|
|
88
|
+
.action(async (opts) => {
|
|
89
|
+
return runCommandEffect(appListCommand(opts).pipe(Effect.provide(AuthLayerLive({
|
|
90
|
+
coerce: false,
|
|
91
|
+
allowAdminToken: false,
|
|
92
|
+
}).pipe(Layer.annotateLogs('silent', !!opts.json)))));
|
|
93
|
+
});
|
|
94
|
+
export const appDeleteDef = app
|
|
95
|
+
.command('delete')
|
|
96
|
+
.description('Delete an app from your Superlayer account')
|
|
97
|
+
.option('-a --app <app-id>', 'App ID to delete. Defaults to *_INSTANT_APP_ID in .env')
|
|
98
|
+
.action(async (opts) => {
|
|
99
|
+
return runCommandEffect(appDeleteCommand(opts).pipe(Effect.provide(AuthLayerLive({
|
|
100
|
+
coerce: false,
|
|
101
|
+
allowAdminToken: false,
|
|
102
|
+
}))));
|
|
103
|
+
});
|
|
104
|
+
const authClient = auth.command('client');
|
|
105
|
+
export const authClientAddDef = authClient
|
|
106
|
+
.command('add')
|
|
107
|
+
.allowExcessArguments(true)
|
|
108
|
+
.allowUnknownOption(true)
|
|
109
|
+
.option('--type <google|github|apple|linkedin>', 'Type of oauth client to add')
|
|
110
|
+
.option('--name <client name>', 'Custom name to identify the OAuth client (ex: google-web)')
|
|
111
|
+
.option('-a --app <app-id>', 'App ID to modify. Defaults to *_INSTANT_APP_ID in .env')
|
|
112
|
+
.addHelpText('after', `
|
|
113
|
+
Provider Specific Options:
|
|
114
|
+
Google:
|
|
115
|
+
--app-type web|ios|android|button-for-web
|
|
116
|
+
--dev-credentials (optional, web only)
|
|
117
|
+
--client-id (required unless using dev credentials)
|
|
118
|
+
--client-secret (web only, unless using dev credentials)
|
|
119
|
+
--custom-redirect-uri (optional, web only)
|
|
120
|
+
GitHub:
|
|
121
|
+
--client-id
|
|
122
|
+
--client-secret
|
|
123
|
+
--custom-redirect-uri (optional)
|
|
124
|
+
Apple:
|
|
125
|
+
--services-id (Services ID from ${link('https://developer.apple.com', 'developer.apple.com')})
|
|
126
|
+
--team-id (optional, required for web redirect flow)
|
|
127
|
+
--key-id (optional, required for web redirect flow)
|
|
128
|
+
--private-key-file (optional, path to .p8 PEM; required for web redirect flow)
|
|
129
|
+
--custom-redirect-uri (optional, web redirect flow only)
|
|
130
|
+
LinkedIn:
|
|
131
|
+
--client-id
|
|
132
|
+
--client-secret
|
|
133
|
+
--custom-redirect-uri (optional)
|
|
134
|
+
Clerk:
|
|
135
|
+
--publishable-key (Publishable Key from ${link('https://dashboard.clerk.com', 'dashboard.clerk.com')})
|
|
136
|
+
Firebase:
|
|
137
|
+
--project-id (Project ID from ${link('https://console.firebase.google.com', 'console.firebase.google.com')})
|
|
138
|
+
`)
|
|
139
|
+
.action((opts) => {
|
|
140
|
+
opts = {
|
|
141
|
+
...opts,
|
|
142
|
+
...minimist(process.argv),
|
|
143
|
+
};
|
|
144
|
+
return runCommandEffect(authClientAddCmd(opts).pipe(Effect.provide(WithAppLayer({
|
|
145
|
+
coerce: false,
|
|
146
|
+
coerceAuth: false,
|
|
147
|
+
appId: opts.app,
|
|
148
|
+
allowAdminToken: true,
|
|
149
|
+
}))));
|
|
150
|
+
});
|
|
151
|
+
export const authClientListDef = authClient
|
|
152
|
+
.command('list')
|
|
153
|
+
.option('-a --app <app-id>', 'App ID to list clients for. Defaults to *_INSTANT_APP_ID in .env')
|
|
154
|
+
.option('--json', 'Enable JSON output')
|
|
155
|
+
.allowUnknownOption(true)
|
|
156
|
+
.action((opts) => {
|
|
157
|
+
return runCommandEffect(authClientListCmd(opts).pipe(Effect.provide(WithAppLayer({
|
|
158
|
+
coerce: false,
|
|
159
|
+
coerceAuth: false,
|
|
160
|
+
appId: opts.app,
|
|
161
|
+
allowAdminToken: true,
|
|
162
|
+
// Silence "searching for instant sdk.. logs for json output"
|
|
163
|
+
}).pipe(Layer.annotateLogs('silent', !!opts.json)))));
|
|
164
|
+
});
|
|
165
|
+
export const authClientDeleteDef = authClient
|
|
166
|
+
.command('delete')
|
|
167
|
+
.option('--id <client-id>', 'Client ID to delete')
|
|
168
|
+
.option('--name <client-name>', 'Client name to delete')
|
|
169
|
+
.option('-a --app <app-id>', 'App ID to delete a client from. Defaults to *_INSTANT_APP_ID in .env')
|
|
170
|
+
.action((opts) => {
|
|
171
|
+
return runCommandEffect(authClientDeleteCmd(opts).pipe(Effect.provide(WithAppLayer({
|
|
172
|
+
coerce: false,
|
|
173
|
+
appId: opts.app,
|
|
174
|
+
allowAdminToken: true,
|
|
175
|
+
}))));
|
|
176
|
+
});
|
|
177
|
+
export const authClientUpdateDef = authClient
|
|
178
|
+
.command('update')
|
|
179
|
+
.description('Update an OAuth client')
|
|
180
|
+
.allowExcessArguments(true)
|
|
181
|
+
.allowUnknownOption(true)
|
|
182
|
+
.option('--id <client-id>', 'Client ID to update')
|
|
183
|
+
.option('--name <client-name>', 'Client name to update')
|
|
184
|
+
.option('-a --app <app-id>', 'App ID to update a client in. Defaults to *_INSTANT_APP_ID in .env')
|
|
185
|
+
.addHelpText('after', `
|
|
186
|
+
Provider Specific Options:
|
|
187
|
+
Google:
|
|
188
|
+
--dev-credentials (web only)
|
|
189
|
+
--client-id
|
|
190
|
+
--client-secret (web only)
|
|
191
|
+
--custom-redirect-uri (optional, web only)
|
|
192
|
+
GitHub:
|
|
193
|
+
--client-id
|
|
194
|
+
--client-secret
|
|
195
|
+
--custom-redirect-uri (optional)
|
|
196
|
+
Apple:
|
|
197
|
+
--services-id
|
|
198
|
+
--team-id (web redirect flow)
|
|
199
|
+
--key-id (web redirect flow)
|
|
200
|
+
--private-key-file (web redirect flow)
|
|
201
|
+
--custom-redirect-uri (optional, web redirect flow only)
|
|
202
|
+
LinkedIn:
|
|
203
|
+
--client-id
|
|
204
|
+
--client-secret
|
|
205
|
+
--custom-redirect-uri (optional)
|
|
206
|
+
Clerk:
|
|
207
|
+
--publishable-key
|
|
208
|
+
Firebase:
|
|
209
|
+
--project-id
|
|
210
|
+
`)
|
|
211
|
+
.action((opts) => {
|
|
212
|
+
opts = {
|
|
213
|
+
...opts,
|
|
214
|
+
...minimist(process.argv),
|
|
215
|
+
};
|
|
216
|
+
return runCommandEffect(authClientUpdateCmd(opts).pipe(Effect.provide(WithAppLayer({
|
|
217
|
+
coerce: false,
|
|
218
|
+
appId: opts.app,
|
|
219
|
+
allowAdminToken: true,
|
|
220
|
+
}))));
|
|
221
|
+
});
|
|
222
|
+
const authOrigin = auth.command('origin');
|
|
223
|
+
export const authOriginListDef = authOrigin
|
|
224
|
+
.command('list')
|
|
225
|
+
.option('-a --app <app-id>', 'App ID to list origins for. Defaults to *_INSTANT_APP_ID in .env')
|
|
226
|
+
.option('--json', 'Enable JSON output')
|
|
227
|
+
.action((opts) => {
|
|
228
|
+
return runCommandEffect(authOriginListCmd(opts).pipe(Effect.provide(WithAppLayer({
|
|
229
|
+
coerce: false,
|
|
230
|
+
coerceAuth: false,
|
|
231
|
+
appId: opts.app,
|
|
232
|
+
allowAdminToken: true,
|
|
233
|
+
}).pipe(Layer.annotateLogs('silent', !!opts.json)))));
|
|
234
|
+
});
|
|
235
|
+
export const authOriginAddDef = authOrigin
|
|
236
|
+
.command('add')
|
|
237
|
+
.option('--type <website|vercel|netlify|custom-scheme>', 'Type of origin to add.')
|
|
238
|
+
.option('--url <url>', 'Website URL (for website type, e.g. example.com)')
|
|
239
|
+
.option('--project <name>', 'Vercel project name (for vercel type, e.g. my-project)')
|
|
240
|
+
.option('--site <name>', 'Netlify site name (for netlify type, e.g. my-site)')
|
|
241
|
+
.option('--scheme <scheme>', 'App scheme (for custom-scheme type, e.g. myapp://)')
|
|
242
|
+
.option('-a --app <app-id>', 'App ID to add an origin to. Defaults to *_INSTANT_APP_ID in .env')
|
|
243
|
+
.addHelpText('after', `
|
|
244
|
+
Origin Types:
|
|
245
|
+
website A standard website origin (e.g. example.com)
|
|
246
|
+
vercel Vercel preview deployments (project name)
|
|
247
|
+
netlify Netlify preview deployments (site name)
|
|
248
|
+
custom-scheme Native app scheme (e.g. your-app-scheme://)
|
|
249
|
+
`)
|
|
250
|
+
.action((opts) => {
|
|
251
|
+
return runCommandEffect(authOriginAddCmd(opts).pipe(Effect.provide(WithAppLayer({
|
|
252
|
+
coerce: false,
|
|
253
|
+
coerceAuth: false,
|
|
254
|
+
appId: opts.app,
|
|
255
|
+
allowAdminToken: true,
|
|
256
|
+
}))));
|
|
257
|
+
});
|
|
258
|
+
export const authOriginDeleteDef = authOrigin
|
|
259
|
+
.command('delete')
|
|
260
|
+
.option('--id <origin-id>', 'Origin ID to delete')
|
|
261
|
+
.option('-a --app <app-id>', 'App ID to delete an origin from. Defaults to *_INSTANT_APP_ID in .env')
|
|
262
|
+
.action((opts) => {
|
|
263
|
+
return runCommandEffect(authOriginDeleteCmd(opts).pipe(Effect.provide(WithAppLayer({
|
|
264
|
+
coerce: false,
|
|
265
|
+
appId: opts.app,
|
|
266
|
+
allowAdminToken: true,
|
|
267
|
+
}))));
|
|
268
|
+
});
|
|
269
|
+
const webhooks = program
|
|
270
|
+
.command('webhook')
|
|
271
|
+
.description('Manage webhooks for an app');
|
|
272
|
+
export const webhooksListDef = webhooks
|
|
273
|
+
.command('list')
|
|
274
|
+
.description('List webhooks for an app')
|
|
275
|
+
.option('-a --app <app-id>', 'App ID to list webhooks for. Defaults to *_INSTANT_APP_ID in .env')
|
|
276
|
+
.option('--json', 'Enable JSON output')
|
|
277
|
+
.action((opts) => {
|
|
278
|
+
return runCommandEffect(webhooksListCmd(opts).pipe(Effect.provide(WithAppLayer({
|
|
279
|
+
coerce: false,
|
|
280
|
+
coerceAuth: false,
|
|
281
|
+
appId: opts.app,
|
|
282
|
+
allowAdminToken: false,
|
|
283
|
+
}).pipe(Layer.annotateLogs('silent', !!opts.json)))));
|
|
284
|
+
});
|
|
285
|
+
export const webhooksAddDef = webhooks
|
|
286
|
+
.command('add')
|
|
287
|
+
.description('Add a webhook to an app')
|
|
288
|
+
.option('--url <url>', 'HTTPS endpoint to deliver events to')
|
|
289
|
+
.option('--namespaces <e1,e2>', 'Comma-separated list of namespaces to listen on')
|
|
290
|
+
.option('--actions <a1,a2>', 'Comma-separated list of actions (create, update, delete)')
|
|
291
|
+
.option('-a --app <app-id>', 'App ID to add a webhook to. Defaults to *_INSTANT_APP_ID in .env')
|
|
292
|
+
.action((opts) => {
|
|
293
|
+
return runCommandEffect(webhooksAddCmd(opts).pipe(Effect.provide(WithAppLayer({
|
|
294
|
+
coerce: false,
|
|
295
|
+
coerceAuth: false,
|
|
296
|
+
appId: opts.app,
|
|
297
|
+
allowAdminToken: false,
|
|
298
|
+
}))));
|
|
299
|
+
});
|
|
300
|
+
export const webhooksUpdateDef = webhooks
|
|
301
|
+
.command('update')
|
|
302
|
+
.description('Update a webhook')
|
|
303
|
+
.option('--id <webhook-id>', 'Webhook ID to update')
|
|
304
|
+
.option('--url <url>', 'New HTTPS endpoint')
|
|
305
|
+
.option('--namespaces <e1,e2>', 'New comma-separated namespaces')
|
|
306
|
+
.option('--actions <a1,a2>', 'New comma-separated actions (create, update, delete)')
|
|
307
|
+
.option('-a --app <app-id>', 'App ID the webhook belongs to. Defaults to *_INSTANT_APP_ID in .env')
|
|
308
|
+
.action((opts) => {
|
|
309
|
+
return runCommandEffect(webhooksUpdateCmd(opts).pipe(Effect.provide(WithAppLayer({
|
|
310
|
+
coerce: false,
|
|
311
|
+
coerceAuth: false,
|
|
312
|
+
appId: opts.app,
|
|
313
|
+
allowAdminToken: false,
|
|
314
|
+
}))));
|
|
315
|
+
});
|
|
316
|
+
export const webhooksDeleteDef = webhooks
|
|
317
|
+
.command('delete')
|
|
318
|
+
.description('Delete a webhook')
|
|
319
|
+
.option('--id <webhook-id>', 'Webhook ID to delete')
|
|
320
|
+
.option('-a --app <app-id>', 'App ID the webhook belongs to. Defaults to *_INSTANT_APP_ID in .env')
|
|
321
|
+
.action((opts) => {
|
|
322
|
+
return runCommandEffect(webhooksDeleteCmd(opts).pipe(Effect.provide(WithAppLayer({
|
|
323
|
+
coerce: false,
|
|
324
|
+
coerceAuth: false,
|
|
325
|
+
appId: opts.app,
|
|
326
|
+
allowAdminToken: false,
|
|
327
|
+
}))));
|
|
328
|
+
});
|
|
329
|
+
export const webhooksEnableDef = webhooks
|
|
330
|
+
.command('enable')
|
|
331
|
+
.description('Re-enable a disabled webhook')
|
|
332
|
+
.option('--id <webhook-id>', 'Webhook ID to enable')
|
|
333
|
+
.option('-a --app <app-id>', 'App ID the webhook belongs to. Defaults to *_INSTANT_APP_ID in .env')
|
|
334
|
+
.action((opts) => {
|
|
335
|
+
return runCommandEffect(webhooksEnableCmd(opts).pipe(Effect.provide(WithAppLayer({
|
|
336
|
+
coerce: false,
|
|
337
|
+
coerceAuth: false,
|
|
338
|
+
appId: opts.app,
|
|
339
|
+
allowAdminToken: false,
|
|
340
|
+
}))));
|
|
341
|
+
});
|
|
342
|
+
export const webhooksDisableDef = webhooks
|
|
343
|
+
.command('disable')
|
|
344
|
+
.description('Disable an active webhook')
|
|
345
|
+
.option('--id <webhook-id>', 'Webhook ID to disable')
|
|
346
|
+
.option('--reason <reason>', 'Human-readable reason stored on the webhook')
|
|
347
|
+
.option('-a --app <app-id>', 'App ID the webhook belongs to. Defaults to *_INSTANT_APP_ID in .env')
|
|
348
|
+
.action((opts) => {
|
|
349
|
+
return runCommandEffect(webhooksDisableCmd(opts).pipe(Effect.provide(WithAppLayer({
|
|
350
|
+
coerce: false,
|
|
351
|
+
coerceAuth: false,
|
|
352
|
+
appId: opts.app,
|
|
353
|
+
allowAdminToken: false,
|
|
354
|
+
}))));
|
|
355
|
+
});
|
|
356
|
+
const webhooksEvents = webhooks
|
|
357
|
+
.command('event')
|
|
358
|
+
.description('Inspect and resend webhook events');
|
|
359
|
+
export const webhooksEventsListDef = webhooksEvents
|
|
360
|
+
.command('list')
|
|
361
|
+
.description('List recent events for a webhook (up to 100, newest first)')
|
|
362
|
+
.option('--webhook-id <webhook-id>', 'Webhook ID to inspect')
|
|
363
|
+
.option('--json', 'Enable JSON output')
|
|
364
|
+
.option('-a --app <app-id>', 'App ID the webhook belongs to. Defaults to *_INSTANT_APP_ID in .env')
|
|
365
|
+
.action((opts) => {
|
|
366
|
+
return runCommandEffect(webhooksEventsListCmd(opts).pipe(Effect.provide(WithAppLayer({
|
|
367
|
+
coerce: false,
|
|
368
|
+
coerceAuth: false,
|
|
369
|
+
appId: opts.app,
|
|
370
|
+
allowAdminToken: false,
|
|
371
|
+
}).pipe(Layer.annotateLogs('silent', !!opts.json)))));
|
|
372
|
+
});
|
|
373
|
+
export const webhooksEventsResendDef = webhooksEvents
|
|
374
|
+
.command('resend')
|
|
375
|
+
.description('Re-queue a webhook event for delivery')
|
|
376
|
+
.option('--webhook-id <webhook-id>', 'Webhook ID the event belongs to')
|
|
377
|
+
.option('--isn <isn>', 'Event ISN to resend')
|
|
378
|
+
.option('-a --app <app-id>', 'App ID the webhook belongs to. Defaults to *_INSTANT_APP_ID in .env')
|
|
379
|
+
.action((opts) => {
|
|
380
|
+
return runCommandEffect(webhooksEventsResendCmd(opts).pipe(Effect.provide(WithAppLayer({
|
|
381
|
+
coerce: false,
|
|
382
|
+
coerceAuth: false,
|
|
383
|
+
appId: opts.app,
|
|
384
|
+
allowAdminToken: false,
|
|
385
|
+
}))));
|
|
386
|
+
});
|
|
387
|
+
export const webhooksEventsPayloadDef = webhooksEvents
|
|
388
|
+
.command('payload')
|
|
389
|
+
.description('Print the JSON payload for a webhook event')
|
|
390
|
+
.option('--webhook-id <webhook-id>', 'Webhook ID the event belongs to')
|
|
391
|
+
.option('--isn <isn>', 'Event ISN to fetch')
|
|
392
|
+
.option('-a --app <app-id>', 'App ID the webhook belongs to. Defaults to *_INSTANT_APP_ID in .env')
|
|
393
|
+
.action((opts) => {
|
|
394
|
+
return runCommandEffect(webhooksEventsPayloadCmd(opts).pipe(Effect.provide(WithAppLayer({
|
|
395
|
+
coerce: false,
|
|
396
|
+
coerceAuth: false,
|
|
397
|
+
appId: opts.app,
|
|
398
|
+
allowAdminToken: false,
|
|
399
|
+
}))));
|
|
400
|
+
});
|
|
401
|
+
const backup = program
|
|
402
|
+
.command('backup')
|
|
403
|
+
.description('View and download backups of your app');
|
|
404
|
+
export const backupListDef = backup
|
|
405
|
+
.command('list')
|
|
406
|
+
.description('List downloadable backups for an app')
|
|
407
|
+
.option('-a --app <app-id>', 'App ID to list backups for. Defaults to *_INSTANT_APP_ID in .env')
|
|
408
|
+
.option('--json', 'Output backups as JSON')
|
|
409
|
+
.action((opts) => {
|
|
410
|
+
return runCommandEffect(backupListCmd(opts).pipe(Effect.provide(WithAppLayer({
|
|
411
|
+
coerce: false,
|
|
412
|
+
coerceAuth: false,
|
|
413
|
+
appId: opts.app,
|
|
414
|
+
allowAdminToken: true,
|
|
415
|
+
}).pipe(Layer.annotateLogs('silent', !!opts.json)))));
|
|
416
|
+
});
|
|
417
|
+
export const backupDownloadDef = backup
|
|
418
|
+
.command('download')
|
|
419
|
+
.description('Download a backup as a zip file')
|
|
420
|
+
.argument('[backup-id]', 'Backup ID to download. Defaults to an interactive picker')
|
|
421
|
+
.option('-a --app <app-id>', 'App ID to download a backup of. Defaults to *_INSTANT_APP_ID in .env')
|
|
422
|
+
.option('--latest', 'Download the most recent backup')
|
|
423
|
+
.option('-o --out <path>', 'Output zip path. Defaults to instant-backup-<timestamp>.zip')
|
|
424
|
+
.action((backupId, opts) => {
|
|
425
|
+
return runCommandEffect(backupDownloadCmd(backupId, opts).pipe(Effect.provide(WithAppLayer({
|
|
426
|
+
coerce: false,
|
|
427
|
+
coerceAuth: false,
|
|
428
|
+
appId: opts.app,
|
|
429
|
+
allowAdminToken: true,
|
|
430
|
+
}))));
|
|
431
|
+
});
|
|
432
|
+
const authEmail = auth
|
|
433
|
+
.command('email')
|
|
434
|
+
.description('Manage custom magic code email templates');
|
|
435
|
+
export const authEmailStatusDef = authEmail
|
|
436
|
+
.command('status')
|
|
437
|
+
.description('Get status for the custom magic code email template')
|
|
438
|
+
.option('-a --app <app-id>', 'App ID to push email settings to. Defaults to *_INSTANT_APP_ID in .env')
|
|
439
|
+
.option('--json', 'Output email status as JSON')
|
|
440
|
+
.action((opts) => {
|
|
441
|
+
runCommandEffect(emailStatusCmd(opts).pipe(Effect.provide(WithAppLayer({
|
|
442
|
+
appId: opts.app,
|
|
443
|
+
coerce: false,
|
|
444
|
+
allowAdminToken: true,
|
|
445
|
+
}))));
|
|
446
|
+
});
|
|
447
|
+
export const authEmailPushDef = authEmail
|
|
448
|
+
.command('push')
|
|
449
|
+
.description('Push the custom magic code email template.')
|
|
450
|
+
.option('-a --app <app-id>', 'App ID to push email settings to. Defaults to *_INSTANT_APP_ID in .env')
|
|
451
|
+
.option('-f --file <path>', 'Path to instant.email.ts. Defaults to INSTANT_EMAIL_FILE_PATH or auto-discovery.')
|
|
452
|
+
.action((opts) => runCommandEffect(authEmailPushCmd({ file: opts.file }).pipe(Effect.provide(WithAppLayer({
|
|
453
|
+
coerce: false,
|
|
454
|
+
coerceAuth: false,
|
|
455
|
+
appId: opts.app,
|
|
456
|
+
allowAdminToken: true,
|
|
457
|
+
})))));
|
|
458
|
+
export const authEmailPullDef = authEmail
|
|
459
|
+
.command('pull')
|
|
460
|
+
.description('Pull the custom magic code email template.')
|
|
461
|
+
.option('-a --app <app-id>', 'App ID to pull email settings from. Defaults to *_INSTANT_APP_ID in .env')
|
|
462
|
+
.option('-f --file <path>', 'Path to instant.email.ts. Defaults to INSTANT_EMAIL_FILE_PATH or auto-discovery.')
|
|
463
|
+
.action((opts) => runCommandEffect(authEmailPullCmd({ file: opts.file }).pipe(Effect.provide(WithAppLayer({
|
|
464
|
+
coerce: false,
|
|
465
|
+
coerceAuth: false,
|
|
466
|
+
appId: opts.app,
|
|
467
|
+
allowAdminToken: true,
|
|
468
|
+
})))));
|
|
469
|
+
export const authEmailResetDef = authEmail
|
|
470
|
+
.command('reset')
|
|
471
|
+
.description('Delete the custom magic code email template.')
|
|
472
|
+
.option('-a --app <app-id>', 'App ID to reset email settings for. Defaults to *_INSTANT_APP_ID in .env')
|
|
473
|
+
.action((opts) => runCommandEffect(authEmailResetCmd().pipe(Effect.provide(WithAppLayer({
|
|
474
|
+
coerce: false,
|
|
475
|
+
coerceAuth: false,
|
|
476
|
+
appId: opts.app,
|
|
477
|
+
allowAdminToken: true,
|
|
478
|
+
})))));
|
|
479
|
+
export const authEmailResendDef = authEmail
|
|
480
|
+
.command('resend')
|
|
481
|
+
.description('Resend the verification email')
|
|
482
|
+
.option('-a --app <app-id>', 'App ID to reset email settings for. Defaults to *_INSTANT_APP_ID in .env')
|
|
483
|
+
.action(() => {
|
|
484
|
+
runCommandEffect(resendEmailCmd.pipe(Effect.provide(WithAppLayer({
|
|
485
|
+
coerce: false,
|
|
486
|
+
coerceAuth: false,
|
|
487
|
+
allowAdminToken: true,
|
|
488
|
+
}))));
|
|
489
|
+
});
|
|
490
|
+
export const authEmailVerifyDef = authEmail
|
|
491
|
+
.command('verify')
|
|
492
|
+
.description('Verify a custom email sender with a magic code')
|
|
493
|
+
.argument('<code>', 'The magic code to verify')
|
|
494
|
+
.option('-a --app <app-id>', 'App ID to reset email settings for. Defaults to *_INSTANT_APP_ID in .env')
|
|
495
|
+
.action((code, opts) => {
|
|
496
|
+
runCommandEffect(verifyCmd(code, opts).pipe(Effect.provide(WithAppLayer({
|
|
497
|
+
coerce: false,
|
|
498
|
+
coerceAuth: false,
|
|
499
|
+
appId: opts.app,
|
|
500
|
+
allowAdminToken: true,
|
|
501
|
+
}))));
|
|
502
|
+
});
|
|
503
|
+
export const initWithoutFilesDef = program
|
|
504
|
+
.command('init-without-files')
|
|
505
|
+
.description('Generate a new app id and admin token pair without any files.')
|
|
506
|
+
.option('--title <title>', 'Title for the created app.')
|
|
507
|
+
.option('--org-id <org-id>', 'Organization id for app. Cannot be used with --temp flag.')
|
|
508
|
+
.option('--temp', 'Create a temporary app which will automatically delete itself after >24 hours.')
|
|
509
|
+
.action((opts) => {
|
|
510
|
+
return runCommandEffect(initWithoutFilesCommand(opts).pipe(Effect.provide(BaseLayerLive)));
|
|
511
|
+
});
|
|
512
|
+
export const loginDef = program
|
|
513
|
+
.command('login')
|
|
514
|
+
.description('Log into your account')
|
|
515
|
+
.option('-p --print', 'Prints the auth token into the console.')
|
|
516
|
+
.option('--headless', 'Print the login URL instead of trying to open the browser')
|
|
517
|
+
.action(async (opts) => {
|
|
518
|
+
await runCommandEffect(loginCommand(opts).pipe(Effect.provide(BaseLayerLive)));
|
|
519
|
+
});
|
|
520
|
+
program
|
|
521
|
+
.command('logout')
|
|
522
|
+
.description('Log out of your Superlayer account')
|
|
523
|
+
.action(async () => {
|
|
524
|
+
return runCommandEffect(logoutCommand().pipe(Effect.provide(BaseLayerLive)));
|
|
525
|
+
});
|
|
526
|
+
export const infoDef = program
|
|
527
|
+
.command('info')
|
|
528
|
+
.description('Display CLI version, login status, and app info')
|
|
529
|
+
.action(async () => {
|
|
530
|
+
const authLayer = AuthLayerLive({
|
|
531
|
+
coerce: false,
|
|
532
|
+
allowAdminToken: false,
|
|
533
|
+
});
|
|
534
|
+
return runCommandEffect(infoCommand().pipe(Effect.provide(Layer.mergeAll(BaseLayerLive, authLayer.pipe(Layer.catchAll(() => Layer.empty)), WithAppLayer({ coerce: false, allowAdminToken: true }).pipe(Layer.annotateLogs('silent', true), Layer.catchAll(() => Layer.empty))))));
|
|
535
|
+
});
|
|
536
|
+
export const explorerDef = program
|
|
537
|
+
.command('explorer')
|
|
538
|
+
.description('Opens the Explorer in your browser')
|
|
539
|
+
.option('-a --app <app-id>', 'App ID to open the explorer to. Defaults to *_INSTANT_APP_ID in .env')
|
|
540
|
+
.action(async (opts) => {
|
|
541
|
+
return runCommandEffect(explorerCmd(opts).pipe(Effect.provide(WithAppLayer({
|
|
542
|
+
coerce: true,
|
|
543
|
+
coerceAuth: true,
|
|
544
|
+
appId: opts.app,
|
|
545
|
+
}))));
|
|
546
|
+
});
|
|
547
|
+
export const queryDef = program
|
|
548
|
+
.command('query')
|
|
549
|
+
.argument('<query>', 'InstaQL query as JSON/JSON5')
|
|
550
|
+
.option('-a --app <app-id>', 'App ID to query. Defaults to *_INSTANT_APP_ID in .env')
|
|
551
|
+
.option('--admin', 'Run the query as admin (bypasses permissions)')
|
|
552
|
+
.option('--as-email <email>', 'Run the query as a specific user by email')
|
|
553
|
+
.option('--as-guest', 'Run the query as an unauthenticated guest')
|
|
554
|
+
.option('--as-token <refresh-token>', 'Run the query as a user identified by refresh token')
|
|
555
|
+
.description('Run an InstaQL query against your app.')
|
|
556
|
+
.action(async function (queryArg, opts) {
|
|
557
|
+
return runCommandEffect(queryCmd(queryArg, opts));
|
|
558
|
+
});
|
|
559
|
+
export const pullDef = program
|
|
560
|
+
.command('pull')
|
|
561
|
+
.argument('[schema|perms|all]', 'Which configuration to pull. Defaults to `all`')
|
|
562
|
+
.option('-a --app <app-id>', 'App ID to pull to. Defaults to *_INSTANT_APP_ID in .env')
|
|
563
|
+
.option('-p --package <react|react-native|core|admin|solid|svelte>', 'Which package to automatically install if there is not one installed already.')
|
|
564
|
+
.option('--experimental-type-preservation', "[Experimental] Preserve manual type changes like `status: i.json<'online' | 'offline'>()` when doing `superlayer pull schema`")
|
|
565
|
+
.description('Pull schema and perm files from production.')
|
|
566
|
+
.addHelpText('after', `
|
|
567
|
+
Environment Variables:
|
|
568
|
+
INSTANT_SCHEMA_FILE_PATH Override schema file location (default: instant.schema.ts)
|
|
569
|
+
INSTANT_PERMS_FILE_PATH Override perms file location (default: instant.perms.ts)
|
|
570
|
+
`)
|
|
571
|
+
.action(async function (arg, inputOpts) {
|
|
572
|
+
return runCommandEffect(pullCommand(arg, inputOpts).pipe(Effect.provide(WithAppLayer({
|
|
573
|
+
coerce: true,
|
|
574
|
+
packageName: inputOpts.package,
|
|
575
|
+
appId: inputOpts.app,
|
|
576
|
+
}))));
|
|
577
|
+
});
|
|
578
|
+
export const pushDef = program
|
|
579
|
+
.command('push')
|
|
580
|
+
.argument('[schema|perms|all]', 'Which configuration to push. Defaults to `all`')
|
|
581
|
+
.option('-a --app <app-id>', 'App ID to push to. Defaults to *_INSTANT_APP_ID in .env')
|
|
582
|
+
.option('--skip-check-types', "Don't check types on the server when pushing schema")
|
|
583
|
+
.option('--rename [renames...]', 'List of full attribute names separated by a ":"\n Example:`push --rename posts.author:posts.creator stores.owner:stores.manager`')
|
|
584
|
+
.option('-p --package <react|react-native|core|admin|solid|svelte>', 'Which package to automatically install if there is not one installed already.')
|
|
585
|
+
.description('Push schema and perm files to production.')
|
|
586
|
+
.addHelpText('after', `
|
|
587
|
+
Environment Variables:
|
|
588
|
+
INSTANT_SCHEMA_FILE_PATH Override schema file location (default: instant.schema.ts)
|
|
589
|
+
INSTANT_PERMS_FILE_PATH Override perms file location (default: instant.perms.ts)
|
|
590
|
+
`)
|
|
591
|
+
.action(async function (arg, inputOpts) {
|
|
592
|
+
return runCommandEffect(pushCommand(arg, inputOpts).pipe(Effect.provide(WithAppLayer({
|
|
593
|
+
coerce: false,
|
|
594
|
+
appId: inputOpts.app,
|
|
595
|
+
coerceLibraryInstall: true,
|
|
596
|
+
coerceAuth: false,
|
|
597
|
+
allowAdminToken: true,
|
|
598
|
+
applyEnv: true,
|
|
599
|
+
packageName: inputOpts.package,
|
|
600
|
+
}))));
|
|
601
|
+
});
|
|
602
|
+
export const claimDef = program
|
|
603
|
+
.command('claim')
|
|
604
|
+
.description('Transfer a temporary app into your Superlayer account')
|
|
605
|
+
.option('-a --app <app-id>', 'App to claim. Defaults to *_INSTANT_APP_ID in .env')
|
|
606
|
+
.action(async function (opts) {
|
|
607
|
+
return runCommandEffect(claimCommand.pipe(Effect.provide(WithAppLayer({
|
|
608
|
+
coerce: false,
|
|
609
|
+
allowAdminToken: false,
|
|
610
|
+
appId: opts.app,
|
|
611
|
+
applyEnv: false,
|
|
612
|
+
}))));
|
|
613
|
+
});
|
|
614
|
+
//// Program setup /////
|
|
615
|
+
function globalOption(flags, description, argParser) {
|
|
616
|
+
const opt = new Option(flags, description);
|
|
617
|
+
if (argParser) {
|
|
618
|
+
opt.argParser(argParser);
|
|
619
|
+
}
|
|
620
|
+
// @ts-ignore
|
|
621
|
+
// __global does not exist on `Option`,
|
|
622
|
+
// but we use it in `getLocalAndGlobalOptions`, to produce
|
|
623
|
+
// our own custom list of local and global options.
|
|
624
|
+
// For more info, see the original PR:
|
|
625
|
+
// https://github.com/InterfaceLDN/Superlayer/pull/505
|
|
626
|
+
opt.__global = true;
|
|
627
|
+
return opt;
|
|
628
|
+
}
|
|
629
|
+
function getLocalAndGlobalOptions(cmd, helper) {
|
|
630
|
+
const mixOfLocalAndGlobal = helper.visibleOptions(cmd);
|
|
631
|
+
const localOptionsFromMix = mixOfLocalAndGlobal.filter((option) => !option.__global);
|
|
632
|
+
const globalOptionsFromMix = mixOfLocalAndGlobal.filter((option) => option.__global);
|
|
633
|
+
const globalOptions = helper.visibleGlobalOptions(cmd);
|
|
634
|
+
return [localOptionsFromMix, globalOptionsFromMix.concat(globalOptions)];
|
|
635
|
+
}
|
|
636
|
+
function formatHelp(cmd, helper) {
|
|
637
|
+
const termWidth = helper.padWidth(cmd, helper);
|
|
638
|
+
const helpWidth = helper.helpWidth || 80;
|
|
639
|
+
const itemIndentWidth = 2;
|
|
640
|
+
const itemSeparatorWidth = 2; // between term and description
|
|
641
|
+
function formatItem(term, description) {
|
|
642
|
+
if (description) {
|
|
643
|
+
const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`;
|
|
644
|
+
return helper.boxWrap(fullText, helpWidth - itemIndentWidth, termWidth + itemSeparatorWidth);
|
|
645
|
+
}
|
|
646
|
+
return term;
|
|
647
|
+
}
|
|
648
|
+
function formatList(textArray) {
|
|
649
|
+
return textArray.join('\n').replace(/^/gm, ' '.repeat(itemIndentWidth));
|
|
650
|
+
}
|
|
651
|
+
// Usage
|
|
652
|
+
let output = [`${helper.commandUsage(cmd)}`, ''];
|
|
653
|
+
// Description
|
|
654
|
+
const commandDescription = helper.commandDescription(cmd);
|
|
655
|
+
if (commandDescription.length > 0) {
|
|
656
|
+
output = output.concat([
|
|
657
|
+
helper.boxWrap(commandDescription, helpWidth, 0),
|
|
658
|
+
'',
|
|
659
|
+
]);
|
|
660
|
+
}
|
|
661
|
+
// Arguments
|
|
662
|
+
const argumentList = helper.visibleArguments(cmd).map((argument) => {
|
|
663
|
+
return formatItem(helper.argumentTerm(argument), helper.argumentDescription(argument));
|
|
664
|
+
});
|
|
665
|
+
if (argumentList.length > 0) {
|
|
666
|
+
output = output.concat([
|
|
667
|
+
chalk.dim.bold('Arguments'),
|
|
668
|
+
formatList(argumentList),
|
|
669
|
+
'',
|
|
670
|
+
]);
|
|
671
|
+
}
|
|
672
|
+
const [visibleOptions, visibleGlobalOptions] = getLocalAndGlobalOptions(cmd, helper);
|
|
673
|
+
// Options
|
|
674
|
+
const optionList = visibleOptions.map((option) => {
|
|
675
|
+
return formatItem(helper.optionTerm(option), helper.optionDescription(option));
|
|
676
|
+
});
|
|
677
|
+
if (optionList.length > 0) {
|
|
678
|
+
output = output.concat([
|
|
679
|
+
chalk.dim.bold('Options'),
|
|
680
|
+
formatList(optionList),
|
|
681
|
+
'',
|
|
682
|
+
]);
|
|
683
|
+
}
|
|
684
|
+
// Commands
|
|
685
|
+
const commandList = helper.visibleCommands(cmd).map((cmd) => {
|
|
686
|
+
return formatItem(helper.subcommandTerm(cmd), helper.subcommandDescription(cmd));
|
|
687
|
+
});
|
|
688
|
+
if (commandList.length > 0) {
|
|
689
|
+
output = output.concat([
|
|
690
|
+
chalk.dim.bold('Commands'),
|
|
691
|
+
formatList(commandList),
|
|
692
|
+
'',
|
|
693
|
+
]);
|
|
694
|
+
}
|
|
695
|
+
if (this.showGlobalOptions) {
|
|
696
|
+
const globalOptionList = visibleGlobalOptions.map((option) => {
|
|
697
|
+
return formatItem(helper.optionTerm(option), helper.optionDescription(option));
|
|
698
|
+
});
|
|
699
|
+
if (globalOptionList.length > 0) {
|
|
700
|
+
output = output.concat([
|
|
701
|
+
chalk.dim.bold('Global Options'),
|
|
702
|
+
formatList(globalOptionList),
|
|
703
|
+
'',
|
|
704
|
+
]);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
return output.join('\n');
|
|
708
|
+
}
|
|
709
|
+
program.configureHelp({
|
|
710
|
+
showGlobalOptions: true,
|
|
711
|
+
formatHelp,
|
|
712
|
+
});
|
|
713
|
+
program.parse(process.argv);
|
|
714
|
+
//# sourceMappingURL=index.js.map
|