stepzen 0.44.0 → 0.45.0-experimental.32a4304
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/README.md +5 -5
- package/bin/dev.cmd +1 -1
- package/bin/dev.js +13 -0
- package/bin/{run → run.js} +10 -15
- package/lib/commands/delete.d.ts +2 -2
- package/lib/commands/delete.d.ts.map +1 -1
- package/lib/commands/delete.js +24 -27
- package/lib/commands/delete.js.map +1 -1
- package/lib/commands/deploy.d.ts +11 -11
- package/lib/commands/deploy.d.ts.map +1 -1
- package/lib/commands/deploy.js +45 -45
- package/lib/commands/deploy.js.map +1 -1
- package/lib/commands/import/curl.d.ts +19 -19
- package/lib/commands/import/curl.d.ts.map +1 -1
- package/lib/commands/import/curl.js +44 -47
- package/lib/commands/import/curl.js.map +1 -1
- package/lib/commands/import/db2.d.ts +21 -21
- package/lib/commands/import/db2.d.ts.map +1 -1
- package/lib/commands/import/db2.js +37 -40
- package/lib/commands/import/db2.js.map +1 -1
- package/lib/commands/import/flow.d.ts +24 -24
- package/lib/commands/import/flow.d.ts.map +1 -1
- package/lib/commands/import/flow.js +23 -26
- package/lib/commands/import/flow.js.map +1 -1
- package/lib/commands/import/graphql.d.ts +14 -14
- package/lib/commands/import/graphql.d.ts.map +1 -1
- package/lib/commands/import/graphql.js +26 -29
- package/lib/commands/import/graphql.js.map +1 -1
- package/lib/commands/import/index.d.ts +8 -7
- package/lib/commands/import/index.d.ts.map +1 -1
- package/lib/commands/import/index.js +39 -41
- package/lib/commands/import/index.js.map +1 -1
- package/lib/commands/import/mysql.d.ts +19 -19
- package/lib/commands/import/mysql.d.ts.map +1 -1
- package/lib/commands/import/mysql.js +35 -38
- package/lib/commands/import/mysql.js.map +1 -1
- package/lib/commands/import/openapi.d.ts +12 -12
- package/lib/commands/import/openapi.d.ts.map +1 -1
- package/lib/commands/import/openapi.js +19 -22
- package/lib/commands/import/openapi.js.map +1 -1
- package/lib/commands/import/oracle.d.ts +19 -19
- package/lib/commands/import/oracle.d.ts.map +1 -1
- package/lib/commands/import/oracle.js +35 -38
- package/lib/commands/import/oracle.js.map +1 -1
- package/lib/commands/import/postgresql.d.ts +20 -20
- package/lib/commands/import/postgresql.d.ts.map +1 -1
- package/lib/commands/import/postgresql.js +37 -40
- package/lib/commands/import/postgresql.js.map +1 -1
- package/lib/commands/import/presto.d.ts +19 -19
- package/lib/commands/import/presto.d.ts.map +1 -1
- package/lib/commands/import/presto.js +37 -40
- package/lib/commands/import/presto.js.map +1 -1
- package/lib/commands/import/snowflake.d.ts +21 -21
- package/lib/commands/import/snowflake.d.ts.map +1 -1
- package/lib/commands/import/snowflake.js +37 -40
- package/lib/commands/import/snowflake.js.map +1 -1
- package/lib/commands/init.d.ts +7 -7
- package/lib/commands/init.d.ts.map +1 -1
- package/lib/commands/init.js +9 -12
- package/lib/commands/init.js.map +1 -1
- package/lib/commands/lint.d.ts +4 -4
- package/lib/commands/lint.d.ts.map +1 -1
- package/lib/commands/lint.js +10 -13
- package/lib/commands/lint.js.map +1 -1
- package/lib/commands/list.d.ts +6 -6
- package/lib/commands/list.d.ts.map +1 -1
- package/lib/commands/list.js +22 -25
- package/lib/commands/list.js.map +1 -1
- package/lib/commands/login.d.ts +10 -10
- package/lib/commands/login.d.ts.map +1 -1
- package/lib/commands/login.js +42 -42
- package/lib/commands/login.js.map +1 -1
- package/lib/commands/logout.d.ts +3 -3
- package/lib/commands/logout.d.ts.map +1 -1
- package/lib/commands/logout.js +5 -8
- package/lib/commands/logout.js.map +1 -1
- package/lib/commands/request.d.ts +11 -11
- package/lib/commands/request.d.ts.map +1 -1
- package/lib/commands/request.js +47 -50
- package/lib/commands/request.js.map +1 -1
- package/lib/commands/service.d.ts +10 -10
- package/lib/commands/service.d.ts.map +1 -1
- package/lib/commands/service.js +143 -146
- package/lib/commands/service.js.map +1 -1
- package/lib/commands/start.d.ts +14 -14
- package/lib/commands/start.d.ts.map +1 -1
- package/lib/commands/start.js +44 -44
- package/lib/commands/start.js.map +1 -1
- package/lib/commands/transpile.d.ts +10 -10
- package/lib/commands/transpile.d.ts.map +1 -1
- package/lib/commands/transpile.js +25 -28
- package/lib/commands/transpile.js.map +1 -1
- package/lib/commands/upload.d.ts +8 -8
- package/lib/commands/upload.d.ts.map +1 -1
- package/lib/commands/upload.js +20 -23
- package/lib/commands/upload.js.map +1 -1
- package/lib/commands/validate.d.ts +4 -4
- package/lib/commands/validate.d.ts.map +1 -1
- package/lib/commands/validate.js +17 -20
- package/lib/commands/validate.js.map +1 -1
- package/lib/commands/whoami.d.ts +8 -8
- package/lib/commands/whoami.d.ts.map +1 -1
- package/lib/commands/whoami.js +17 -20
- package/lib/commands/whoami.js.map +1 -1
- package/lib/generate/curl2sdl.d.ts +6 -6
- package/lib/generate/curl2sdl.d.ts.map +1 -1
- package/lib/generate/curl2sdl.js +12 -18
- package/lib/generate/curl2sdl.js.map +1 -1
- package/lib/generate/flags.d.ts +11 -11
- package/lib/generate/flags.js +14 -17
- package/lib/generate/flags.js.map +1 -1
- package/lib/generate/flow2sdl.d.ts +4 -4
- package/lib/generate/flow2sdl.d.ts.map +1 -1
- package/lib/generate/flow2sdl.js +4 -8
- package/lib/generate/flow2sdl.js.map +1 -1
- package/lib/generate/graphql2sdl.d.ts +4 -4
- package/lib/generate/graphql2sdl.d.ts.map +1 -1
- package/lib/generate/graphql2sdl.js +4 -8
- package/lib/generate/graphql2sdl.js.map +1 -1
- package/lib/generate/helpers.d.ts +2 -2
- package/lib/generate/helpers.d.ts.map +1 -1
- package/lib/generate/helpers.js +32 -38
- package/lib/generate/helpers.js.map +1 -1
- package/lib/generate/import-command.d.ts +9 -9
- package/lib/generate/import-command.d.ts.map +1 -1
- package/lib/generate/import-command.js +31 -35
- package/lib/generate/import-command.js.map +1 -1
- package/lib/generate/openapi2sdl.d.ts +3 -3
- package/lib/generate/openapi2sdl.d.ts.map +1 -1
- package/lib/generate/openapi2sdl.js +4 -8
- package/lib/generate/openapi2sdl.js.map +1 -1
- package/lib/generate/questions.js +4 -7
- package/lib/generate/questions.js.map +1 -1
- package/lib/generate/sql2sdl.d.ts +3 -3
- package/lib/generate/sql2sdl.d.ts.map +1 -1
- package/lib/generate/sql2sdl.js +10 -14
- package/lib/generate/sql2sdl.js.map +1 -1
- package/lib/hooks/init/version.js +6 -8
- package/lib/hooks/init/version.js.map +1 -1
- package/lib/hooks/prerun/check-upgrade.js +38 -41
- package/lib/hooks/prerun/check-upgrade.js.map +1 -1
- package/lib/hooks/prerun/ensure-config-file.js +9 -11
- package/lib/hooks/prerun/ensure-config-file.js.map +1 -1
- package/lib/hooks/prerun/ensure-permissions.js +5 -7
- package/lib/hooks/prerun/ensure-permissions.js.map +1 -1
- package/lib/index.js +1 -5
- package/lib/index.js.map +1 -1
- package/lib/shared/actions.d.ts +1 -1
- package/lib/shared/actions.d.ts.map +1 -1
- package/lib/shared/actions.js +15 -21
- package/lib/shared/actions.js.map +1 -1
- package/lib/shared/configuration.d.ts +1 -1
- package/lib/shared/configuration.d.ts.map +1 -1
- package/lib/shared/configuration.js +37 -48
- package/lib/shared/configuration.js.map +1 -1
- package/lib/shared/constants.d.ts +4 -1
- package/lib/shared/constants.d.ts.map +1 -1
- package/lib/shared/constants.js +62 -71
- package/lib/shared/constants.js.map +1 -1
- package/lib/shared/curl-parser.d.ts +2 -2
- package/lib/shared/curl-parser.d.ts.map +1 -1
- package/lib/shared/curl-parser.js +8 -12
- package/lib/shared/curl-parser.js.map +1 -1
- package/lib/shared/docker.d.ts +2 -2
- package/lib/shared/docker.d.ts.map +1 -1
- package/lib/shared/docker.js +36 -40
- package/lib/shared/docker.js.map +1 -1
- package/lib/shared/errors.js +7 -11
- package/lib/shared/errors.js.map +1 -1
- package/lib/shared/header-params-parser.d.ts +2 -2
- package/lib/shared/header-params-parser.d.ts.map +1 -1
- package/lib/shared/header-params-parser.js +7 -12
- package/lib/shared/header-params-parser.js.map +1 -1
- package/lib/shared/header.d.ts +1 -1
- package/lib/shared/header.d.ts.map +1 -1
- package/lib/shared/header.js +3 -7
- package/lib/shared/header.js.map +1 -1
- package/lib/shared/inquirer.d.ts +2 -2
- package/lib/shared/inquirer.d.ts.map +1 -1
- package/lib/shared/inquirer.js +26 -31
- package/lib/shared/inquirer.js.map +1 -1
- package/lib/shared/moniker.js +4 -9
- package/lib/shared/moniker.js.map +1 -1
- package/lib/shared/path-params-parser.d.ts +1 -1
- package/lib/shared/path-params-parser.d.ts.map +1 -1
- package/lib/shared/path-params-parser.js +4 -9
- package/lib/shared/path-params-parser.js.map +1 -1
- package/lib/shared/request-variables-parser.d.ts +1 -1
- package/lib/shared/request-variables-parser.d.ts.map +1 -1
- package/lib/shared/request-variables-parser.js +5 -10
- package/lib/shared/request-variables-parser.js.map +1 -1
- package/lib/shared/rmtemp.js +6 -10
- package/lib/shared/rmtemp.js.map +1 -1
- package/lib/shared/segment.d.ts +8 -0
- package/lib/shared/segment.d.ts.map +1 -0
- package/lib/shared/segment.js +102 -0
- package/lib/shared/segment.js.map +1 -0
- package/lib/shared/stepzen-sdk.d.ts +1 -1
- package/lib/shared/stepzen-sdk.d.ts.map +1 -1
- package/lib/shared/stepzen-sdk.js +24 -31
- package/lib/shared/stepzen-sdk.js.map +1 -1
- package/lib/shared/types.d.ts +3 -3
- package/lib/shared/types.d.ts.map +1 -1
- package/lib/shared/types.js +1 -2
- package/lib/shared/url-helpers.js +6 -13
- package/lib/shared/url-helpers.js.map +1 -1
- package/lib/shared/utils.d.ts +1 -1
- package/lib/shared/utils.d.ts.map +1 -1
- package/lib/shared/utils.js +43 -63
- package/lib/shared/utils.js.map +1 -1
- package/lib/shared/validation.js +12 -17
- package/lib/shared/validation.js.map +1 -1
- package/lib/shared/workspace.d.ts +1 -1
- package/lib/shared/workspace.d.ts.map +1 -1
- package/lib/shared/workspace.js +33 -41
- package/lib/shared/workspace.js.map +1 -1
- package/lib/shared/zen-command.d.ts +4 -4
- package/lib/shared/zen-command.d.ts.map +1 -1
- package/lib/shared/zen-command.js +38 -42
- package/lib/shared/zen-command.js.map +1 -1
- package/oclif.manifest.json +27 -2
- package/package.json +18 -15
- package/bin/dev +0 -23
package/lib/commands/login.js
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright IBM Corp. 2020, 2024
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.getServiceInstanceForDomain = void 0;
|
|
5
2
|
// This file contains the code for the `stepzen login` command.
|
|
6
3
|
// Stepzen login checks that credentials presented are good and
|
|
7
4
|
// subsequently changes the identity of the logged in account.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
import { Args, Flags, ux } from '@oclif/core';
|
|
6
|
+
import { CLIError } from '@oclif/core/lib/errors/index.js';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import debug from 'debug';
|
|
9
|
+
import { importConfiguration, readConfiguration, removeCredentialsAndServiceFromConfigFile, writeCredentialsAndServiceToConfigFile, } from '../shared/configuration.js';
|
|
10
|
+
import { DEFAULT_STEPZEN_DEPLOYMENT_TYPE, ZENCTL2_URL, INTROSPECTION_URL_PATH, DBINTROSPECTION_URL_PATH, } from '../shared/constants.js';
|
|
11
|
+
import { getStepzen2SDK, tryZenCtl2ThenZenCtl1, } from '../shared/stepzen-sdk.js';
|
|
12
|
+
import { appendPathnameIfEmpty, isLocalhost } from '../shared/url-helpers.js';
|
|
13
|
+
import { probeEndpoint } from '../shared/utils.js';
|
|
14
|
+
import ZenCommand from '../shared/zen-command.js';
|
|
15
|
+
import { trackLoginEvent } from '../shared/segment.js';
|
|
18
16
|
// If the `--config` file defines a custom service instance, the `login`
|
|
19
17
|
// command should authenticate against the ZenCtl2 API of _that_ service
|
|
20
18
|
// instance regardless of the `STEPZEN_ZENCTL_API_URL` env. variable.
|
|
@@ -34,16 +32,18 @@ async function tryCustomZenCtl2ThenDefaultZenCtl2ThenDefaultZenCtl1(configuratio
|
|
|
34
32
|
// from the configuration object over the `STEPZEN_DEPLOYMENT_TYPE` env var.
|
|
35
33
|
const deploymentType = configuration.serviceInstance.deploymentType ||
|
|
36
34
|
process.env.STEPZEN_DEPLOYMENT_TYPE ||
|
|
37
|
-
|
|
38
|
-
const stepzen2 =
|
|
35
|
+
DEFAULT_STEPZEN_DEPLOYMENT_TYPE;
|
|
36
|
+
const stepzen2 = getStepzen2SDK(configuration.serviceInstance.zenctl2, deploymentType);
|
|
39
37
|
return {
|
|
40
38
|
result: await fn(stepzen2),
|
|
41
39
|
serviceInstance: configuration.serviceInstance,
|
|
40
|
+
configuration,
|
|
41
|
+
configMigrated: false,
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
return
|
|
44
|
+
return tryZenCtl2ThenZenCtl1(configuration, fn);
|
|
45
45
|
}
|
|
46
|
-
const getServiceInstanceForDomain = (domainOrUrl) => {
|
|
46
|
+
export const getServiceInstanceForDomain = (domainOrUrl) => {
|
|
47
47
|
if (domainOrUrl === undefined) {
|
|
48
48
|
return { result: undefined };
|
|
49
49
|
}
|
|
@@ -61,11 +61,11 @@ const getServiceInstanceForDomain = (domainOrUrl) => {
|
|
|
61
61
|
try {
|
|
62
62
|
url = new URL(domainOrUrl);
|
|
63
63
|
if (url.pathname === '/') {
|
|
64
|
-
url.pathname =
|
|
64
|
+
url.pathname = ZENCTL2_URL;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
catch {
|
|
68
|
-
const zenctl2 = `http${
|
|
68
|
+
const zenctl2 = `http${isLocalhost(domainOrUrl) ? '' : 's'}://${domainOrUrl}${port ? `:${port}` : ''}${ZENCTL2_URL}`;
|
|
69
69
|
// ensure the inferred zenctl2 URL is valid
|
|
70
70
|
try {
|
|
71
71
|
url = new URL(zenctl2);
|
|
@@ -94,7 +94,7 @@ const getServiceInstanceForDomain = (domainOrUrl) => {
|
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
96
|
// ZenCtl v2 endpoint is deployed to the `stepzen` account
|
|
97
|
-
if (!
|
|
97
|
+
if (!isLocalhost(url) && url.hostname.includes('.')) {
|
|
98
98
|
url.hostname = `stepzen.${url.hostname}`;
|
|
99
99
|
}
|
|
100
100
|
debug('stepzen:login')(`using zenctl2 URL ${url}`);
|
|
@@ -105,23 +105,22 @@ const getServiceInstanceForDomain = (domainOrUrl) => {
|
|
|
105
105
|
},
|
|
106
106
|
};
|
|
107
107
|
};
|
|
108
|
-
|
|
109
|
-
class Login extends zen_command_1.default {
|
|
108
|
+
export default class Login extends ZenCommand {
|
|
110
109
|
async run() {
|
|
111
110
|
const { flags, args } = await this.parse(Login);
|
|
112
111
|
if (flags.public && args.domain) {
|
|
113
|
-
throw new
|
|
112
|
+
throw new CLIError(chalk `Public accounts are only supported in the {bold stepzen.net} StepZen service instance.` +
|
|
114
113
|
chalk ` Please remove either {bold --public} or {bold ${args.domain}}.`);
|
|
115
114
|
}
|
|
116
|
-
const { result: claimedServiceInstance, error } =
|
|
115
|
+
const { result: claimedServiceInstance, error } = getServiceInstanceForDomain(args.domain);
|
|
117
116
|
if (error) {
|
|
118
117
|
const message = error.message === 'Invalid URL'
|
|
119
118
|
? chalk `Could not parse {bold ${args.domain}} as a StepZen service` +
|
|
120
119
|
chalk ` instance domain name or URL. Please make sure it's correct.`
|
|
121
120
|
: error.message;
|
|
122
|
-
throw new
|
|
121
|
+
throw new CLIError(message);
|
|
123
122
|
}
|
|
124
|
-
const initialConfig = await
|
|
123
|
+
const initialConfig = await readConfiguration();
|
|
125
124
|
let claimedConfig = {
|
|
126
125
|
uuid: initialConfig.uuid,
|
|
127
126
|
account: undefined,
|
|
@@ -131,7 +130,7 @@ class Login extends zen_command_1.default {
|
|
|
131
130
|
if (flags.config) {
|
|
132
131
|
// If the --config flag is provided, try and log in using the credentials
|
|
133
132
|
// and the service instance in the file.
|
|
134
|
-
const referenceConfig = await
|
|
133
|
+
const referenceConfig = await importConfiguration(flags.config);
|
|
135
134
|
claimedConfig = {
|
|
136
135
|
...claimedConfig,
|
|
137
136
|
account: referenceConfig.account,
|
|
@@ -154,14 +153,14 @@ class Login extends zen_command_1.default {
|
|
|
154
153
|
if (!claimedConfig.account) {
|
|
155
154
|
// eslint-disable-next-line require-atomic-updates
|
|
156
155
|
claimedConfig.account =
|
|
157
|
-
flags.account || (await
|
|
156
|
+
flags.account || (await ux.prompt('What is your account name?'));
|
|
158
157
|
}
|
|
159
158
|
// Check if the --adminkey flag is provided, and if not prompt the user for an admin key.
|
|
160
159
|
if (!claimedConfig.adminkey) {
|
|
161
160
|
// eslint-disable-next-line require-atomic-updates
|
|
162
161
|
claimedConfig.adminkey =
|
|
163
162
|
flags.adminkey === undefined
|
|
164
|
-
? await
|
|
163
|
+
? await ux.prompt('What is your admin key?', {
|
|
165
164
|
required: false,
|
|
166
165
|
type: 'hide',
|
|
167
166
|
})
|
|
@@ -180,8 +179,8 @@ class Login extends zen_command_1.default {
|
|
|
180
179
|
introspectionBaseUrl = `https://${introspectionBaseUrl}`;
|
|
181
180
|
}
|
|
182
181
|
try {
|
|
183
|
-
await
|
|
184
|
-
await
|
|
182
|
+
await probeEndpoint(appendPathnameIfEmpty(introspectionBaseUrl, INTROSPECTION_URL_PATH), 1);
|
|
183
|
+
await probeEndpoint(appendPathnameIfEmpty(introspectionBaseUrl, DBINTROSPECTION_URL_PATH), 1);
|
|
185
184
|
serviceInstance.introspection = introspectionBaseUrl;
|
|
186
185
|
serviceInstance.dbintrospection = introspectionBaseUrl;
|
|
187
186
|
this.log(chalk `Using the introspection service at {bold ${introspectionBaseUrl}}.`);
|
|
@@ -193,14 +192,14 @@ class Login extends zen_command_1.default {
|
|
|
193
192
|
else {
|
|
194
193
|
this.log('Using the default StepZen introspection service.');
|
|
195
194
|
}
|
|
196
|
-
await
|
|
195
|
+
await writeCredentialsAndServiceToConfigFile(credentials, serviceInstance);
|
|
197
196
|
}
|
|
198
197
|
else {
|
|
199
198
|
// If the new service instance is 'undefined', explicitly remove any
|
|
200
199
|
// service instance details that may be stored in the config file.
|
|
201
|
-
await
|
|
200
|
+
await removeCredentialsAndServiceFromConfigFile();
|
|
202
201
|
// This call alone won't remove the service instance from config file
|
|
203
|
-
await
|
|
202
|
+
await writeCredentialsAndServiceToConfigFile(credentials);
|
|
204
203
|
}
|
|
205
204
|
const host = serviceInstance
|
|
206
205
|
? new URL(serviceInstance.zenctl2).host.replace(/^stepzen\./, '')
|
|
@@ -210,44 +209,45 @@ class Login extends zen_command_1.default {
|
|
|
210
209
|
: chalk ` to {bold ${host}}`;
|
|
211
210
|
this.log(`You have successfully logged in${toInstanceMsg} with the` +
|
|
212
211
|
chalk ` {bold ${credentials.account}} account.`);
|
|
212
|
+
// Call Segment to track the login event
|
|
213
|
+
trackLoginEvent(claimedConfig.account ?? '', claimedConfig.uuid);
|
|
213
214
|
}
|
|
214
215
|
}
|
|
215
|
-
exports.default = Login;
|
|
216
216
|
Login.description = 'Log in to StepZen.';
|
|
217
217
|
Login.flags = {
|
|
218
|
-
...
|
|
219
|
-
account:
|
|
218
|
+
...ZenCommand.flags,
|
|
219
|
+
account: Flags.string({
|
|
220
220
|
char: 'a',
|
|
221
221
|
description: 'StepZen account name (copy from https://stepzen.com/account).' +
|
|
222
222
|
' If not provided, the CLI prompts the users to enter one.',
|
|
223
223
|
exclusive: ['config', 'public'],
|
|
224
224
|
}),
|
|
225
|
-
adminkey:
|
|
225
|
+
adminkey: Flags.string({
|
|
226
226
|
char: 'k',
|
|
227
227
|
description: 'Admin key (copy from https://stepzen.com/account)' +
|
|
228
228
|
' If not provided, the CLI prompts the users to enter one.',
|
|
229
229
|
exclusive: ['config', 'public'],
|
|
230
230
|
}),
|
|
231
|
-
public:
|
|
231
|
+
public: Flags.boolean({
|
|
232
232
|
description: 'Create a public anonymous StepZen account and use it. This is handy' +
|
|
233
233
|
' for trying StepZen out, but it not suitable for handling private' +
|
|
234
234
|
' data as all endpoints created with a public account will be public.',
|
|
235
235
|
exclusive: ['config', 'account', 'adminkey'],
|
|
236
236
|
}),
|
|
237
|
-
introspection:
|
|
237
|
+
introspection: Flags.string({
|
|
238
238
|
description: chalk `Override the default StepZen introspection service URL for all {bold stepzen import} commands. ` +
|
|
239
239
|
chalk `If not provided, use the default introspection URL.` +
|
|
240
240
|
`\n` +
|
|
241
241
|
`\nExample:` +
|
|
242
242
|
`\nstepzen login --introspection stepzen-introspection.mydomain.com`,
|
|
243
243
|
}),
|
|
244
|
-
config:
|
|
244
|
+
config: Flags.string({
|
|
245
245
|
exclusive: ['account', 'adminkey', 'public'],
|
|
246
246
|
hidden: true,
|
|
247
247
|
}),
|
|
248
248
|
};
|
|
249
249
|
Login.args = {
|
|
250
|
-
domain:
|
|
250
|
+
domain: Args.string({
|
|
251
251
|
required: false,
|
|
252
252
|
description: chalk `Domain of the StepZen service to login to (e.g.` +
|
|
253
253
|
chalk ` {bold us-east-a.ibm.stepzen.net} or` +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAEjC,+DAA+D;AAC/D,+DAA+D;AAC/D,8DAA8D;AAE9D,OAAO,EAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAC,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAC,QAAQ,EAAC,MAAM,iCAAiC,CAAA;AACxD,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,yCAAyC,EACzC,sCAAsC,GACvC,MAAM,4BAA4B,CAAA;AACnC,OAAO,EACL,+BAA+B,EAC/B,WAAW,EACX,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,E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E,SAAS,EAAE,UAAU,CAAC;KAC7C,CAAC;IACF,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC;QAC1B,WAAW,EACT,KAAK,CAAA,iGAAiG;YACtG,KAAK,CAAA,qDAAqD;YAC1D,IAAI;YACJ,YAAY;YACZ,oEAAoE;KACvE,CAAC;IACF,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;QACnB,SAAS,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC;QAC5C,MAAM,EAAE,IAAI;KACb,CAAC;CACH,CAAA;AAEM,UAAI,GAAG;IACZ,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;QAClB,QAAQ,EAAE,KAAK;QACf,WAAW,EACT,KAAK,CAAA,iDAAiD;YACtD,KAAK,CAAA,sCAAsC;YAC3C,KAAK,CAAA,wCAAwC;YAC7C,KAAK,CAAA,4BAA4B;YACjC,KAAK,CAAA,yCAAyC;YAC9C,KAAK,CAAA,+CAA+C;KACvD,CAAC;CACH,CAAA"}
|
package/lib/commands/logout.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import ZenCommand from '../shared/zen-command';
|
|
1
|
+
import ZenCommand from '../shared/zen-command.js';
|
|
2
2
|
export default class Logout extends ZenCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static flags: {
|
|
5
|
-
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
6
|
-
'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
5
|
+
help: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<void>;
|
|
6
|
+
'non-interactive': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
7
7
|
};
|
|
8
8
|
run(): Promise<void>;
|
|
9
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAMA,OAAO,UAAU,MAAM,
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAMA,OAAO,UAAU,MAAM,0BAA0B,CAAA;AAEjD,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,UAAU;IAC5C,MAAM,CAAC,WAAW,SAAwB;IAE1C,MAAM,CAAC,KAAK;;;MAEX;IAEK,GAAG;CAKV"}
|
package/lib/commands/logout.js
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright IBM Corp. 2020, 2024
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
2
|
// This file contains the code for the `stepzen logout` command.
|
|
5
3
|
// The logout command removes the entry in the login file.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class Logout extends
|
|
4
|
+
import { removeCredentialsAndServiceFromConfigFile } from '../shared/configuration.js';
|
|
5
|
+
import ZenCommand from '../shared/zen-command.js';
|
|
6
|
+
export default class Logout extends ZenCommand {
|
|
9
7
|
async run() {
|
|
10
8
|
// Remove the configuration from the login file.
|
|
11
|
-
|
|
9
|
+
removeCredentialsAndServiceFromConfigFile();
|
|
12
10
|
this.log('You have been logged out.');
|
|
13
11
|
}
|
|
14
12
|
}
|
|
15
|
-
exports.default = Logout;
|
|
16
13
|
Logout.description = 'Log out of StepZen.';
|
|
17
14
|
Logout.flags = {
|
|
18
|
-
...
|
|
15
|
+
...ZenCommand.flags,
|
|
19
16
|
};
|
|
20
17
|
//# sourceMappingURL=logout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAEjC,gEAAgE;AAChE,0DAA0D;AAE1D,OAAO,EAAC,yCAAyC,EAAC,MAAM,4BAA4B,CAAA;AACpF,OAAO,UAAU,MAAM,0BAA0B,CAAA;AAEjD,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,UAAU;IAO5C,KAAK,CAAC,GAAG;QACP,gDAAgD;QAChD,yCAAyC,EAAE,CAAA;QAC3C,IAAI,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;IACvC,CAAC;;AAVM,kBAAW,GAAG,qBAAqB,CAAA;AAEnC,YAAK,GAAG;IACb,GAAG,UAAU,CAAC,KAAK;CACpB,CAAA"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import ZenCommand from '../shared/zen-command';
|
|
1
|
+
import ZenCommand from '../shared/zen-command.js';
|
|
2
2
|
import type { OperationDefinitionNode } from 'graphql';
|
|
3
3
|
export default class Request extends ZenCommand {
|
|
4
4
|
static description: string;
|
|
5
5
|
static flags: {
|
|
6
|
-
dir: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
-
endpoint: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
-
header: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
|
-
'operation-name': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
|
-
var: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
11
|
-
'var-file': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
12
|
-
file: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
13
|
-
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
14
|
-
'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
6
|
+
dir: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
7
|
+
endpoint: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
8
|
+
header: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
9
|
+
'operation-name': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
|
+
var: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
|
+
'var-file': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
12
|
+
file: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
13
|
+
help: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<void>;
|
|
14
|
+
'non-interactive': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
15
15
|
};
|
|
16
16
|
static args: {
|
|
17
|
-
query: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
|
|
17
|
+
query: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
|
|
18
18
|
};
|
|
19
19
|
run(): Promise<void>;
|
|
20
20
|
getRequestQuery(queryArg: string | undefined, queryFlag: string | undefined): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/commands/request.ts"],"names":[],"mappings":"AAmBA,OAAO,UAAU,MAAM,
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/commands/request.ts"],"names":[],"mappings":"AAmBA,OAAO,UAAU,MAAM,0BAA0B,CAAA;AAIjD,OAAO,KAAK,EAIV,uBAAuB,EACxB,MAAM,SAAS,CAAA;AAmChB,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,UAAU;IAC7C,MAAM,CAAC,WAAW,SAGH;IAEf,MAAM,CAAC,KAAK;;;;;;;;;;MA+DX;IAED,MAAM,CAAC,IAAI;;MAMV;IAEK,GAAG;IAuJT,eAAe,CACb,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,GAC5B,MAAM;IA8BT,mBAAmB,CACjB,KAAK,EAAE,MAAM,EACb,aAAa,CAAC,EAAE,MAAM,GACrB,uBAAuB;IA2C1B,mBAAmB,CACjB,KAAK,EAAE,uBAAuB,EAC9B,aAAa,CAAC,EAAE,MAAM,EAAE,EACxB,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAgCtB,2BAA2B,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAAG;QACxD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAC7B,OAAO,EAAE,MAAM,EAAE,CAAA;KAClB;CA8BF"}
|
package/lib/commands/request.js
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright IBM Corp. 2020, 2024
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
2
|
// This file contains the code for the `stepzen request` command.
|
|
5
3
|
// The request command sends a GraphQL request to the StepZen endpoint
|
|
6
4
|
// in the current / given StepZen workspace.
|
|
7
5
|
// The endpoint needs to be deployed first for this command to work.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
import debug from 'debug';
|
|
8
|
+
import fs from 'node:fs';
|
|
9
|
+
import { Args, Flags } from '@oclif/core';
|
|
10
|
+
import { CLIError } from '@oclif/core/lib/errors/index.js';
|
|
11
|
+
import { createClient } from 'graphql-ws';
|
|
12
|
+
import { parse } from 'graphql';
|
|
13
|
+
import { WebSocket } from 'ws';
|
|
14
|
+
import { fetchGraphQLQuery } from '@stepzen/sdk';
|
|
15
|
+
import prettyMilliseconds from 'pretty-ms';
|
|
16
|
+
import { tryZenCtl2ThenZenCtl1 } from '../shared/stepzen-sdk.js';
|
|
17
|
+
import ZenCommand from '../shared/zen-command.js';
|
|
18
|
+
import { getZenServUrl } from '../shared/constants.js';
|
|
19
|
+
import { prependEachLine } from '../shared/utils.js';
|
|
20
|
+
import { parseRequestVariables } from '../shared/request-variables-parser.js';
|
|
21
|
+
import { parseHeader } from '../shared/header.js';
|
|
24
22
|
// Errors that have a `path` are specific to particular fields of the query.
|
|
25
23
|
// Errors that do NOT have a `path` are about the query as a whole.
|
|
26
24
|
// The former as considered "business as usual", the latter are "severe" and
|
|
@@ -44,7 +42,7 @@ const formatErrorMessage = (errors) => {
|
|
|
44
42
|
message)
|
|
45
43
|
.join('\n'));
|
|
46
44
|
};
|
|
47
|
-
class Request extends
|
|
45
|
+
export default class Request extends ZenCommand {
|
|
48
46
|
async run() {
|
|
49
47
|
const { args, flags } = await this.parse(Request);
|
|
50
48
|
const query = this.getRequestQuery(args.query, flags.file);
|
|
@@ -55,7 +53,7 @@ class Request extends zen_command_1.default {
|
|
|
55
53
|
const { configuration } = await this.ensureStepZenAccount({
|
|
56
54
|
nonInteractive: flags['non-interactive'],
|
|
57
55
|
});
|
|
58
|
-
const zenserv =
|
|
56
|
+
const zenserv = getZenServUrl(configuration);
|
|
59
57
|
let endpoint = flags.endpoint;
|
|
60
58
|
if (!endpoint) {
|
|
61
59
|
// Get the StepZen workspace from the given directory (or the current directory)
|
|
@@ -66,7 +64,7 @@ class Request extends zen_command_1.default {
|
|
|
66
64
|
});
|
|
67
65
|
endpoint = workspace.endpoint;
|
|
68
66
|
}
|
|
69
|
-
const { result: userAgent } = await
|
|
67
|
+
const { result: userAgent } = await tryZenCtl2ThenZenCtl1(configuration, stepzen => Promise.resolve(stepzen.userAgent));
|
|
70
68
|
const headers = {
|
|
71
69
|
authorization: `APIKey ${configuration.adminkey}`,
|
|
72
70
|
'user-agent': userAgent,
|
|
@@ -76,8 +74,8 @@ class Request extends zen_command_1.default {
|
|
|
76
74
|
try {
|
|
77
75
|
if (operation.operation === 'subscription') {
|
|
78
76
|
const url = `${zenserv}/stepzen-subscriptions/${endpoint}/__graphql`.replace(/^http/i, 'ws');
|
|
79
|
-
const client =
|
|
80
|
-
webSocketImpl:
|
|
77
|
+
const client = createClient({
|
|
78
|
+
webSocketImpl: WebSocket,
|
|
81
79
|
url,
|
|
82
80
|
connectionParams: () => {
|
|
83
81
|
return {
|
|
@@ -110,7 +108,7 @@ class Request extends zen_command_1.default {
|
|
|
110
108
|
count += 1;
|
|
111
109
|
this.log(chalk `{grey event #${count} ({cyan +${elapsed}})}`);
|
|
112
110
|
const prefix = chalk.grey(`${count} | `);
|
|
113
|
-
this.log(
|
|
111
|
+
this.log(prependEachLine(JSON.stringify(result, undefined, 2), prefix));
|
|
114
112
|
},
|
|
115
113
|
error: (error) => {
|
|
116
114
|
if (error?.error instanceof Error) {
|
|
@@ -138,7 +136,7 @@ class Request extends zen_command_1.default {
|
|
|
138
136
|
}
|
|
139
137
|
}
|
|
140
138
|
else {
|
|
141
|
-
const result = await
|
|
139
|
+
const result = await fetchGraphQLQuery({
|
|
142
140
|
url: `${zenserv}/${endpoint}/__graphql`,
|
|
143
141
|
query: query,
|
|
144
142
|
variables,
|
|
@@ -152,24 +150,24 @@ class Request extends zen_command_1.default {
|
|
|
152
150
|
}
|
|
153
151
|
}
|
|
154
152
|
catch (error) {
|
|
155
|
-
if (error instanceof
|
|
153
|
+
if (error instanceof CLIError) {
|
|
156
154
|
throw error;
|
|
157
155
|
}
|
|
158
156
|
let message = `Failed to execute the GraphQL query\n${'message' in error ? error.message : error}`;
|
|
159
157
|
if (`${error}`.match(/Unexpected HTTP status 4\d+/i)) {
|
|
160
158
|
message += chalk `\n\nDid you run {bold stepzen deploy} to deploy your endpoint?`;
|
|
161
159
|
}
|
|
162
|
-
throw new
|
|
160
|
+
throw new CLIError(message);
|
|
163
161
|
}
|
|
164
162
|
}
|
|
165
163
|
getRequestQuery(queryArg, queryFlag) {
|
|
166
164
|
if (!queryArg && !queryFlag) {
|
|
167
|
-
throw new
|
|
165
|
+
throw new CLIError(chalk `Please provide a query either directly on the command line` +
|
|
168
166
|
chalk ` with the {bold QUERY} argument, or through a file with the` +
|
|
169
167
|
chalk ` {bold -f, --file} flag.`);
|
|
170
168
|
}
|
|
171
169
|
if (queryArg && queryFlag) {
|
|
172
|
-
throw new
|
|
170
|
+
throw new CLIError(chalk `Unexpected flag {bold -f, --file}={underline ${queryFlag}}.` +
|
|
173
171
|
chalk ` Could not handle both the {bold QUERY} argument and the` +
|
|
174
172
|
chalk ` {bold -f, --file} flag. Please remove one.`);
|
|
175
173
|
}
|
|
@@ -180,31 +178,31 @@ class Request extends zen_command_1.default {
|
|
|
180
178
|
return fs.readFileSync(queryFlag, { encoding: 'utf-8' });
|
|
181
179
|
}
|
|
182
180
|
catch (error) {
|
|
183
|
-
throw new
|
|
181
|
+
throw new CLIError(chalk `Could not read the query from ${queryFlag}.\n${error}`);
|
|
184
182
|
}
|
|
185
183
|
}
|
|
186
184
|
getRequestOperation(query, operationName) {
|
|
187
185
|
let parsedQuery;
|
|
188
186
|
try {
|
|
189
|
-
parsedQuery =
|
|
187
|
+
parsedQuery = parse(query);
|
|
190
188
|
}
|
|
191
189
|
catch (error) {
|
|
192
|
-
throw new
|
|
190
|
+
throw new CLIError(`Failed to parse the GraphQL query\n${error}`);
|
|
193
191
|
}
|
|
194
192
|
const operations = parsedQuery.definitions.filter(node => node.kind === 'OperationDefinition');
|
|
195
193
|
if (operations.length === 0) {
|
|
196
|
-
throw new
|
|
194
|
+
throw new CLIError(`Please provide a GraphQL request with at least one operation:` +
|
|
197
195
|
` query, mutation or subscription.`);
|
|
198
196
|
}
|
|
199
197
|
if (operationName) {
|
|
200
198
|
const operation = operations.find(odn => odn.name?.value === operationName);
|
|
201
199
|
if (!operation) {
|
|
202
|
-
throw new
|
|
200
|
+
throw new CLIError(chalk `Operation {bold ${operationName}} is not defined in the provided request.`);
|
|
203
201
|
}
|
|
204
202
|
return operation;
|
|
205
203
|
}
|
|
206
204
|
if (operations.length > 1) {
|
|
207
|
-
throw new
|
|
205
|
+
throw new CLIError(chalk `The request contains multiple operations, but the operation` +
|
|
208
206
|
chalk ` name is not provided. Please provide an operation name with` +
|
|
209
207
|
chalk ` the {bold --operation-name} flag, or remove all other` +
|
|
210
208
|
chalk ` operations except the intended one from the request.`);
|
|
@@ -218,15 +216,15 @@ class Request extends zen_command_1.default {
|
|
|
218
216
|
varFile = JSON.parse(fs.readFileSync(varFileFlag, 'utf8'));
|
|
219
217
|
}
|
|
220
218
|
catch (error) {
|
|
221
|
-
throw new
|
|
219
|
+
throw new CLIError(`Cannot read request variables from ${varFileFlag}.\n${error}`);
|
|
222
220
|
}
|
|
223
221
|
}
|
|
224
|
-
const { variables: flagVariables, errors } =
|
|
222
|
+
const { variables: flagVariables, errors } = parseRequestVariables(variableFlags || [], opdef, varFile);
|
|
225
223
|
if (errors.length > 0) {
|
|
226
224
|
const msg = variableFlags?.length || varFileFlag
|
|
227
225
|
? 'Could not resolve request variables'
|
|
228
226
|
: 'Missing request variables';
|
|
229
|
-
throw new
|
|
227
|
+
throw new CLIError(chalk `${msg}\n - ` + errors.join('\n - '));
|
|
230
228
|
}
|
|
231
229
|
return {
|
|
232
230
|
...varFile,
|
|
@@ -238,9 +236,9 @@ class Request extends zen_command_1.default {
|
|
|
238
236
|
const removed = [];
|
|
239
237
|
if (headerFlagValues) {
|
|
240
238
|
headerFlagValues.forEach(headerFlag => {
|
|
241
|
-
const { result: header, error } =
|
|
239
|
+
const { result: header, error } = parseHeader(headerFlag);
|
|
242
240
|
if (error) {
|
|
243
|
-
throw new
|
|
241
|
+
throw new CLIError(error.message);
|
|
244
242
|
}
|
|
245
243
|
// A `null` from parseHeader() means a header should NOT be sent.
|
|
246
244
|
if (!header) {
|
|
@@ -261,21 +259,20 @@ class Request extends zen_command_1.default {
|
|
|
261
259
|
};
|
|
262
260
|
}
|
|
263
261
|
}
|
|
264
|
-
exports.default = Request;
|
|
265
262
|
Request.description = `Send a GraphQL request to a StepZen endpoint and print the response,` +
|
|
266
263
|
` using the API key and the target endpoint from the current StepZen` +
|
|
267
264
|
` workspace.`;
|
|
268
265
|
Request.flags = {
|
|
269
|
-
...
|
|
270
|
-
dir:
|
|
266
|
+
...ZenCommand.flags,
|
|
267
|
+
dir: Flags.string({
|
|
271
268
|
description: 'StepZen workspace directory (defaults to the current directory)',
|
|
272
269
|
exclusive: ['endpoint'],
|
|
273
270
|
}),
|
|
274
|
-
endpoint:
|
|
271
|
+
endpoint: Flags.string({
|
|
275
272
|
description: 'StepZen endpoint to call (defaults to the endpoint in current StepZen workspace)',
|
|
276
273
|
exclusive: ['dir'],
|
|
277
274
|
}),
|
|
278
|
-
header:
|
|
275
|
+
header: Flags.string({
|
|
279
276
|
char: 'H',
|
|
280
277
|
description: chalk `Add an additional HTTP header to the request.` +
|
|
281
278
|
chalk ` This is useful for schemas where {bold @rest} or {bold @graphql}` +
|
|
@@ -290,10 +287,10 @@ Request.flags = {
|
|
|
290
287
|
` header with an empty value.`,
|
|
291
288
|
multiple: true,
|
|
292
289
|
}),
|
|
293
|
-
'operation-name':
|
|
290
|
+
'operation-name': Flags.string({
|
|
294
291
|
description: chalk `Specify the operation name (in case if the provided query includes multiple operations)`,
|
|
295
292
|
}),
|
|
296
|
-
var:
|
|
293
|
+
var: Flags.string({
|
|
297
294
|
description: chalk `Add a request variable, in the {bold name}={underline value} format.` +
|
|
298
295
|
`\n` +
|
|
299
296
|
`\nExample:` +
|
|
@@ -304,7 +301,7 @@ Request.flags = {
|
|
|
304
301
|
`\n\t--var limit=5`,
|
|
305
302
|
multiple: true,
|
|
306
303
|
}),
|
|
307
|
-
'var-file':
|
|
304
|
+
'var-file': Flags.string({
|
|
308
305
|
description: chalk `Read request variables from a JSON file. In case when the same` +
|
|
309
306
|
chalk ` variable value is provided both via {bold --var-file} and` +
|
|
310
307
|
chalk ` {bold --var}, the priority is given to the latter.` +
|
|
@@ -315,7 +312,7 @@ Request.flags = {
|
|
|
315
312
|
`\n\t}' \\` +
|
|
316
313
|
`\n\t--var-file ./vars.json`,
|
|
317
314
|
}),
|
|
318
|
-
file:
|
|
315
|
+
file: Flags.string({
|
|
319
316
|
char: 'f',
|
|
320
317
|
description: chalk `Read the query text from a file instead of the command line.` +
|
|
321
318
|
`\n` +
|
|
@@ -324,7 +321,7 @@ Request.flags = {
|
|
|
324
321
|
}),
|
|
325
322
|
};
|
|
326
323
|
Request.args = {
|
|
327
|
-
query:
|
|
324
|
+
query: Args.string({
|
|
328
325
|
description: 'GraphQL query (could include a query, a mutation or a subscription).' +
|
|
329
326
|
chalk `\nThis argument is required unless you provide the query as a file with {bold --file}={underline file}.`,
|
|
330
327
|
}),
|