stepzen 0.10.0-beta.5 → 0.11.0-beta.1

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 CHANGED
@@ -29,7 +29,7 @@ $ npm install -g stepzen
29
29
  $ stepzen COMMAND
30
30
  running command...
31
31
  $ stepzen (-v|--version|version)
32
- stepzen/0.10.0-beta.5 darwin-x64 node-v14.18.3
32
+ stepzen/0.11.0-beta.1 darwin-x64 node-v14.18.3
33
33
  $ stepzen --help [COMMAND]
34
34
  USAGE
35
35
  $ stepzen COMMAND
@@ -12,6 +12,7 @@ const generate_1 = require("../generate");
12
12
  const utils_1 = require("../shared/utils");
13
13
  const helpers_1 = require("../generate/helpers");
14
14
  const curl2sdl_1 = require("../generate/curl2sdl");
15
+ const curl_parser_1 = require("../shared/curl-parser");
15
16
  const workspace_1 = require("../shared/workspace");
16
17
  const init_1 = require("./init");
17
18
  const constants_1 = require("../shared/constants");
@@ -40,25 +41,40 @@ class Import extends command_1.Command {
40
41
  if (schemas.length > 1) {
41
42
  throw new errors_1.CLIError('Please run cURL import separately from importing other schemas');
42
43
  }
43
- if (argv.length < 2) {
44
- throw new errors_1.CLIError('Please append the full cURL command, e.g. ' +
45
- chalk.bold(`${this.config.name} import curl https://test.stepzen.net/version`));
46
- }
47
44
  this.log(chalk.yellow(`NOTE: ${chalk.bold('stepzen import curl')} is a ${chalk.bold('new')} feature.`));
48
45
  this.log(chalk.yellow('If you have any issues, please check if they have been addressed ' +
49
46
  'in the latest version, or reach out to StepZen on Discord: ' +
50
47
  'https://discord.gg/9k2VdPn2FR'));
51
- // LATER: introduce a generic graphqlize() API taking in schema as the first arg
52
- argv.shift(); // remove 'curl' and pass everything else further
53
- cli_ux_1.cli.action.start('Starting');
54
- const resultOrError = await curl2sdl_1.curl2sdl({
55
- argv,
48
+ let curl2sdlOptions;
49
+ const fixedOptions = {
56
50
  name: flags.name,
57
51
  source: workspace.schema,
52
+ };
53
+ const editableOptions = {
58
54
  queryName: flags['query-name'],
59
55
  rootType: flags['query-type'],
60
56
  typePrefix: flags.prefix,
61
- });
57
+ };
58
+ if (argv.length === 1) {
59
+ // no parameters given: start an interactive prompt
60
+ console.log();
61
+ console.log('This command introspects the response of a REST endpoint and generates' +
62
+ ' a GraphQL schema allowing you to access this endpoint through your ' +
63
+ 'StepZen API. curl syntax is supported so that you copy and paste a ' +
64
+ 'curl command instead of the URL.');
65
+ console.log();
66
+ curl2sdlOptions = Object.assign(Object.assign({}, fixedOptions), (await curl2sdl_1.askCurlQuestions(editableOptions)));
67
+ }
68
+ else {
69
+ // run non-interative
70
+ const argsOrError = curl_parser_1.parseCurlArgv(argv);
71
+ if ('error' in argsOrError) {
72
+ throw new errors_1.CLIError(argsOrError.error);
73
+ }
74
+ curl2sdlOptions = Object.assign(Object.assign(Object.assign({}, fixedOptions), editableOptions), { curlArgs: argsOrError });
75
+ }
76
+ cli_ux_1.cli.action.start('Starting');
77
+ const resultOrError = await curl2sdl_1.curl2sdl(curl2sdlOptions);
62
78
  cli_ux_1.cli.action.stop();
63
79
  if ('error' in resultOrError) {
64
80
  this.log('A problem occured while processing your import. ' +
@@ -1,16 +1,21 @@
1
+ import { CurlArguments } from '../shared/curl-parser';
1
2
  export declare type Curl2SdlOptions = {
2
- argv: readonly string[];
3
+ curlArgs: CurlArguments;
3
4
  name: string;
4
5
  source: string;
5
6
  queryName?: string;
6
7
  rootType?: string;
7
8
  typePrefix?: string;
8
9
  };
9
- export declare type HeaderInput = {
10
- name: string;
11
- value: string;
10
+ export declare type EditableCurl2SdlOptions = Pick<Curl2SdlOptions, 'curlArgs' | 'queryName' | 'rootType' | 'typePrefix'>;
11
+ export declare type CurlAnswers = {
12
+ url: string;
13
+ queryName: string;
14
+ rootType: string;
15
+ typePrefix: string;
12
16
  };
13
- export declare const curl2sdl: ({ argv, name, source, queryName, rootType, typePrefix, }: Curl2SdlOptions) => Promise<{
17
+ export declare const askCurlQuestions: (defaultAnswers?: Partial<CurlAnswers>) => Promise<EditableCurl2SdlOptions>;
18
+ export declare const curl2sdl: ({ curlArgs, name, source, queryName, rootType, typePrefix, }: Curl2SdlOptions) => Promise<{
14
19
  error: string;
15
20
  } | {
16
21
  outPath: string;
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
  // Copyright (c) 2020,2021,2022, StepZen, Inc.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.curl2sdl = void 0;
4
+ exports.curl2sdl = exports.askCurlQuestions = void 0;
5
5
  const errors_1 = require("@oclif/errors");
6
+ const chalk = require("chalk");
6
7
  const fs = require("fs-extra");
8
+ const inquirer = require("inquirer");
9
+ const lodash_1 = require("lodash");
7
10
  const os = require("os");
8
11
  const path = require("path");
12
+ const string_argv_1 = require("string-argv");
9
13
  const node_fetch_1 = require("node-fetch");
10
14
  const debug = require("debug");
11
15
  const prettier = require("prettier");
@@ -13,12 +17,43 @@ const transpiler_1 = require("@stepzen/transpiler");
13
17
  const curl_parser_1 = require("../shared/curl-parser");
14
18
  const constants_1 = require("../shared/constants");
15
19
  const errors_2 = require("../shared/errors");
16
- exports.curl2sdl = async ({ argv, name, source, queryName, rootType, typePrefix, }) => {
17
- let json;
18
- const curlArgs = curl_parser_1.parseCurlArgv(argv);
20
+ exports.askCurlQuestions = async (defaultAnswers = {}) => {
21
+ let questions = [
22
+ {
23
+ name: 'url',
24
+ message: 'Endpoint URL or a full curl command',
25
+ },
26
+ {
27
+ name: 'queryName',
28
+ message: 'Query name to use when generating schema (leave blank to use defaults)',
29
+ },
30
+ {
31
+ name: 'rootType',
32
+ message: 'Query type name to use when generating schema (leave blank to use defaults)',
33
+ },
34
+ {
35
+ name: 'typePrefix',
36
+ message: 'Prefix to add to all generated type name (leave blank to use defaults)',
37
+ },
38
+ ];
39
+ questions = questions.map(question => (Object.assign(Object.assign({}, question), { default: lodash_1.get(defaultAnswers, question.name) })));
40
+ const answers = await inquirer.prompt(questions);
41
+ const curlArgs = curl_parser_1.parseCurlArgv(string_argv_1.default(answers.url));
19
42
  if ('error' in curlArgs) {
20
- throw new errors_1.CLIError(curlArgs.error);
43
+ console.log();
44
+ console.log(chalk.red('A problem occurred while parsing the curl command:\n', curlArgs.error), '\nPlease check enter a URL or a supported curl command.');
45
+ console.log();
46
+ return exports.askCurlQuestions(answers);
21
47
  }
48
+ return {
49
+ curlArgs,
50
+ queryName: answers.queryName,
51
+ rootType: answers.rootType,
52
+ typePrefix: answers.typePrefix,
53
+ };
54
+ };
55
+ exports.curl2sdl = async ({ curlArgs, name, source, queryName, rootType, typePrefix, }) => {
56
+ let json;
22
57
  try {
23
58
  const url = `${constants_1.STEPZEN_JSON2SDL_SERVER_URL}/api/graphql`;
24
59
  const query = `query (
@@ -27,6 +62,8 @@ exports.curl2sdl = async ({ argv, name, source, queryName, rootType, typePrefix,
27
62
  $rootType: String
28
63
  $typePrefix: String
29
64
  $headers: [HeaderInput!]
65
+ $data: String
66
+ $method: HTTPMethod
30
67
  ) {
31
68
  getSDLFromCurl(
32
69
  command: $command
@@ -34,6 +71,8 @@ exports.curl2sdl = async ({ argv, name, source, queryName, rootType, typePrefix,
34
71
  rootType: $rootType
35
72
  typePrefix: $typePrefix
36
73
  headers: $headers
74
+ data: $data
75
+ method: $method
37
76
  ) {
38
77
  sdl
39
78
  config
@@ -45,6 +84,8 @@ exports.curl2sdl = async ({ argv, name, source, queryName, rootType, typePrefix,
45
84
  rootType: rootType || null,
46
85
  typePrefix: typePrefix || null,
47
86
  headers: curlArgs.headers.length > 0 ? curlArgs.headers : null,
87
+ data: curlArgs.data || null,
88
+ method: curlArgs.method,
48
89
  };
49
90
  debug('stepzen:curl2sdl')(url);
50
91
  debug('stepzen:curl2sdl')(query);
@@ -1,3 +1,9 @@
1
1
  import { Hook } from '@oclif/config';
2
+ export declare const compareMajorVersions: (v1: string, v2: string) => number | string;
3
+ export declare const shouldCheckVersion: (version: string) => boolean;
4
+ export declare const checkUpgrade: (version: string) => Promise<{
5
+ message?: string;
6
+ isBlocking: boolean;
7
+ }>;
2
8
  declare const hook: Hook<'prerun'>;
3
9
  export default hook;
@@ -1,19 +1,56 @@
1
1
  "use strict";
2
2
  // Copyright (c) 2020,2021,2022, StepZen, Inc.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.checkUpgrade = exports.shouldCheckVersion = exports.compareMajorVersions = void 0;
4
5
  const chalk = require("chalk");
5
6
  const compareVersions = require("compare-versions");
6
- const shell = require("shelljs");
7
+ const fs = require("fs-extra");
8
+ const debug_1 = require("debug");
9
+ const node_fetch_1 = require("node-fetch");
10
+ const constants_1 = require("../../shared/constants");
11
+ const errors_1 = require("../../shared/errors");
7
12
  const { version } = require('../../../package.json');
8
- const hook = async function () {
9
- if (!shell.which('npm')) {
10
- return null;
13
+ const majorRegexp = /\d+\./;
14
+ const timeoutBeta = 1000 * 60 * 60 * 24; // one day
15
+ const timeoutStable = 7 * timeoutBeta; // one week
16
+ exports.compareMajorVersions = (v1, v2) => {
17
+ const v1Major = v1.match(majorRegexp);
18
+ const v2Major = v2.match(majorRegexp);
19
+ if (!v1Major || !v2Major) {
20
+ return ('Cannot get the major from the version string ' +
21
+ `'${v1Major ? v2 : v1}'. Does it follow semver?`);
22
+ }
23
+ return parseInt(v1Major[0], 10) - parseInt(v2Major[0], 10);
24
+ };
25
+ exports.shouldCheckVersion = (version) => {
26
+ if (!fs.existsSync(constants_1.STEPZEN_LAST_UPDATE_CHECK_TIMESTAMP)) {
27
+ // always check for a new version if the file does not exist
28
+ return true;
29
+ }
30
+ const { mtime } = fs.statSync(constants_1.STEPZEN_LAST_UPDATE_CHECK_TIMESTAMP);
31
+ const threshold = version.includes('beta') ? timeoutBeta : timeoutStable;
32
+ return new Date().getTime() - mtime.getTime() > threshold;
33
+ };
34
+ exports.checkUpgrade = async (version) => {
35
+ if (!exports.shouldCheckVersion(version)) {
36
+ return { message: undefined, isBlocking: false };
37
+ }
38
+ let versions;
39
+ try {
40
+ const pkgmeta = await node_fetch_1.default('https://registry.npmjs.org/stepzen').then(r => r.json());
41
+ versions = pkgmeta['dist-tags'];
42
+ }
43
+ catch (error) {
44
+ // cannot connect to npm -> proceed
45
+ debug_1.default('stepzen:check-upgrade')('failed to get the stepzen version info from npm', error);
46
+ return { message: undefined, isBlocking: false };
11
47
  }
12
- const npm = shell.exec('npm view stepzen dist-tags --json', { silent: true });
13
- const versions = JSON.parse(npm);
14
48
  let beta = false;
15
49
  let latest = versions.latest;
16
- let warning = '';
50
+ const result = {
51
+ message: undefined,
52
+ isBlocking: false,
53
+ };
17
54
  if (version.includes('beta')) {
18
55
  beta = true;
19
56
  latest = versions.beta;
@@ -22,23 +59,45 @@ const hook = async function () {
22
59
  if (upgradeable === -1) {
23
60
  const diff = `${chalk.grey(version)} => ${latest}`;
24
61
  if (beta) {
25
- warning = `${chalk.yellow('An upgrade to the beta channel is available:')}
62
+ result.message = `${chalk.yellow('An upgrade to the beta channel is available:')}
26
63
  ${diff}
27
64
  ${chalk.green('npm install -g stepzen@beta')}
28
65
  `;
29
66
  }
30
67
  else {
31
- warning = `${chalk.yellow('An upgrade to StepZen CLI is available:')}
68
+ result.message = `${chalk.yellow('An upgrade to StepZen CLI is available:')}
32
69
  ${diff}
33
70
  ${chalk.green('npm install -g stepzen')}
34
71
  `;
35
72
  }
73
+ const versionCmpLatest = exports.compareMajorVersions(version, latest);
74
+ if (typeof versionCmpLatest === 'string') {
75
+ debug_1.default('stepzen:check-upgrade')(versionCmpLatest);
76
+ result.message = errors_1.UPGRADE_CHECK_ERROR;
77
+ result.isBlocking = true;
78
+ }
79
+ else {
80
+ result.isBlocking = versionCmpLatest < 0;
81
+ }
82
+ }
83
+ try {
84
+ // update the modification time on the file
85
+ fs.writeFileSync(constants_1.STEPZEN_LAST_UPDATE_CHECK_TIMESTAMP, '');
86
+ }
87
+ catch (_a) {
88
+ // ignore
36
89
  }
37
- if (warning) {
90
+ return result;
91
+ };
92
+ const hook = async function () {
93
+ const { message, isBlocking } = await exports.checkUpgrade(version);
94
+ if (message) {
38
95
  this.log('');
39
- this.log(warning.trim());
96
+ this.log(message.trim());
40
97
  this.log('');
41
- this.exit();
98
+ if (isBlocking) {
99
+ this.exit(1);
100
+ }
42
101
  }
43
102
  };
44
103
  exports.default = hook;
@@ -1,4 +1,5 @@
1
1
  export declare const STEPZEN_CONFIG_DIRECTORY: string;
2
+ export declare const STEPZEN_LAST_UPDATE_CHECK_TIMESTAMP: string;
2
3
  export declare const STEPZEN_CONFIG_FILE: string;
3
4
  export declare const STEPZEN_DOMAIN: string;
4
5
  export declare const STEPZEN_SERVER_URL: string;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  // Copyright (c) 2020,2021,2022, StepZen, Inc.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.STEPZEN_JSON2SDL_SERVER_URL = exports.ADMIN_VERIFY_URL = exports.ADMIN_UPLOAD_URL = exports.ADMIN_LIST_URL = exports.ADMIN_DEPLOY_URL = exports.STEPZEN_API_TEMPLATES_REPOSITORY = exports.STEPZEN_GENERATOR_ENGINES_ENDPOINT = exports.STEPZEN_GENERATOR_ENGINES_SCHEMA = exports.STEPZEN_SERVER_URL = exports.STEPZEN_DOMAIN = exports.STEPZEN_CONFIG_FILE = exports.STEPZEN_CONFIG_DIRECTORY = void 0;
4
+ exports.STEPZEN_JSON2SDL_SERVER_URL = exports.ADMIN_VERIFY_URL = exports.ADMIN_UPLOAD_URL = exports.ADMIN_LIST_URL = exports.ADMIN_DEPLOY_URL = exports.STEPZEN_API_TEMPLATES_REPOSITORY = exports.STEPZEN_GENERATOR_ENGINES_ENDPOINT = exports.STEPZEN_GENERATOR_ENGINES_SCHEMA = exports.STEPZEN_SERVER_URL = exports.STEPZEN_DOMAIN = exports.STEPZEN_CONFIG_FILE = exports.STEPZEN_LAST_UPDATE_CHECK_TIMESTAMP = exports.STEPZEN_CONFIG_DIRECTORY = void 0;
5
5
  // This file contains constants and all magic strings
6
6
  const dotenv = require("dotenv");
7
7
  const os = require("os");
@@ -12,6 +12,7 @@ dotenv.config();
12
12
  const { STEPZEN_CONFIG_FILE: ENV_VAR_STEPZEN_CONFIG_FILE, STEPZEN_DOMAIN: ENV_VAR_STEPZEN_DOMAIN, STEPZEN_GENERATOR_ENGINES_SCHEMA: ENV_VAR_STEPZEN_GENERATOR_ENGINES_SCHEMA, STEPZEN_SERVER_URL: ENV_VAR_STEPZEN_SERVER_URL, STEPZEN_JSON2SDL_SERVER_URL: ENV_VAR_STEPZEN_JSON2SDL_SERVER_URL, } = process.env;
13
13
  // Where your authentication details are stored locally
14
14
  exports.STEPZEN_CONFIG_DIRECTORY = path.join(os.homedir(), '.stepzen');
15
+ exports.STEPZEN_LAST_UPDATE_CHECK_TIMESTAMP = path.join(exports.STEPZEN_CONFIG_DIRECTORY, 'last_update_check.timestamp');
15
16
  exports.STEPZEN_CONFIG_FILE = ENV_VAR_STEPZEN_CONFIG_FILE || 'stepzen-config.yaml';
16
17
  // The zenctl domain. Override with the env var `STEPZEN_DOMAIN`
17
18
  exports.STEPZEN_DOMAIN = ENV_VAR_STEPZEN_DOMAIN || 'stepzen.io';
@@ -15,10 +15,12 @@ export declare const parseCurlHeaderString: (header: string) => {
15
15
  };
16
16
  export interface CurlArguments {
17
17
  url: string;
18
+ method: 'Get' | 'Post';
18
19
  headers: Array<{
19
20
  name: string;
20
21
  value: string;
21
22
  }>;
23
+ data?: string;
22
24
  }
23
25
  export interface ParseError {
24
26
  error: string;
@@ -7,6 +7,7 @@ const curlFlagRegex = /^(-[a-zA-Z0-9.:#])|(--[a-zA-Z0-9.-]+)$/;
7
7
  // Based on the definition of a `token` at
8
8
  // https://datatracker.ietf.org/doc/html/rfc2616#page-17
9
9
  const httpHeaderRegex = /^(?<name>[a-zA-Z0-9!#$%&'*+,-.^_`|~]+)\s*:(?<value>.*)$/;
10
+ const httpURLRegex = /^https?:\/\//i;
10
11
  /**
11
12
  * Parse a header string according to https://curl.se/docs/manpage.html#-H
12
13
  * and https://datatracker.ietf.org/doc/html/rfc2616#section-4.2
@@ -43,7 +44,57 @@ exports.parseCurlHeaderString = (header) => {
43
44
  };
44
45
  };
45
46
  const isAFlagArg = (arg) => curlFlagRegex.test(arg);
46
- const isAHeaderFlag = (flag) => ['-H', '--header'].includes(flag);
47
+ const isAURL = (arg) => httpURLRegex.test(arg);
48
+ const parseHeaderFlag = (argv, i, partialCurlArgs) => {
49
+ if (i + 1 === argv.length) {
50
+ return {
51
+ error: `The '${argv[i]}' curl flag requires a value`,
52
+ };
53
+ }
54
+ const headerOrError = exports.parseCurlHeaderString(argv[i + 1]);
55
+ if (headerOrError && 'error' in headerOrError) {
56
+ return headerOrError; // error
57
+ }
58
+ const headers = partialCurlArgs.headers || [];
59
+ // A `null` from parseCurlHeaderString() means a header should NOT be
60
+ // sent. This is not supported by zenserv / the introspection service
61
+ // so the CLI simply omits such headers
62
+ if (headerOrError) {
63
+ headers.push(headerOrError); // header
64
+ }
65
+ return {
66
+ result: Object.assign(Object.assign({}, partialCurlArgs), { headers }),
67
+ skip: 1,
68
+ };
69
+ };
70
+ const parseDataFlag = (argv, i, partialCurlArgs) => {
71
+ if (i + 1 === argv.length) {
72
+ return {
73
+ error: `The '${argv[i]}' curl flag requires a value`,
74
+ };
75
+ }
76
+ if (argv[i] !== '--data-raw' && argv[i + 1].charAt(0) === '@') {
77
+ return {
78
+ error: `Reading request data from local files in not currently supported ` +
79
+ `by StepZen CLI (${argv[i]} ${argv[i + 1]})`,
80
+ };
81
+ }
82
+ const data = (partialCurlArgs.data ? partialCurlArgs.data + '&' : '') + argv[i + 1];
83
+ return {
84
+ result: Object.assign(Object.assign({}, partialCurlArgs), { data }),
85
+ skip: 1,
86
+ };
87
+ };
88
+ const flags = [
89
+ {
90
+ matches: ['-H', '--header'],
91
+ parse: parseHeaderFlag,
92
+ },
93
+ {
94
+ matches: ['-d', '--data', '--data-ascii', '--data-raw', '--data-binary'],
95
+ parse: parseDataFlag,
96
+ },
97
+ ];
47
98
  /**
48
99
  * Parse a curl command line arguments array to a JSON structure consumable by
49
100
  * the StepZen introspection service backend.
@@ -60,29 +111,21 @@ const isAHeaderFlag = (flag) => ['-H', '--header'].includes(flag);
60
111
  * @returns {*} a structured object with the curl arguments
61
112
  */
62
113
  exports.parseCurlArgv = (argv) => {
63
- const result = {
64
- url: '',
65
- headers: [],
66
- };
114
+ var _a;
115
+ if (((_a = argv[0]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'curl') {
116
+ argv = argv.slice(1);
117
+ }
118
+ let result = {};
67
119
  for (let i = 0; i < argv.length; i++) {
68
120
  if (isAFlagArg(argv[i])) {
69
- if (isAHeaderFlag(argv[i])) {
70
- if (i + 1 === argv.length) {
71
- return {
72
- error: `The '${argv[i]}' curl flag requires a value`,
73
- };
121
+ const knownFlag = flags.find(flag => flag.matches.includes(argv[i]));
122
+ if (knownFlag) {
123
+ const resultOrError = knownFlag.parse(argv, i, result);
124
+ if ('error' in resultOrError) {
125
+ return resultOrError; // error
74
126
  }
75
- const headerOrError = exports.parseCurlHeaderString(argv[i + 1]);
76
- if (headerOrError && 'error' in headerOrError) {
77
- return headerOrError; // error
78
- }
79
- // A `null` from parseCurlHeaderString() means a header should NOT be
80
- // sent. This is not supported by zenserv / the introspection service
81
- // so the CLI simply omits such headers
82
- if (headerOrError) {
83
- result.headers.push(headerOrError); // header
84
- }
85
- i += 1; // skip over the flag value
127
+ result = resultOrError.result; // result
128
+ i += resultOrError.skip || 0;
86
129
  }
87
130
  else {
88
131
  return {
@@ -104,5 +147,22 @@ exports.parseCurlArgv = (argv) => {
104
147
  error: 'curl: a URL is required',
105
148
  };
106
149
  }
150
+ if (!isAURL(result.url)) {
151
+ return {
152
+ error: `Unsupported URL schema in '${result.url}'. ` +
153
+ `StepZen CLI currently supports 'https' and 'http'.`,
154
+ };
155
+ }
156
+ result.headers = result.headers || [];
157
+ result.method = result.method || result.data ? 'Post' : 'Get';
158
+ // Add the default content-type header if the request has any data
159
+ // in it, and no content-type header is explicitly provided.
160
+ if (result.headers.findIndex(header => header.name.toLowerCase() === 'content-type') === -1 &&
161
+ result.data) {
162
+ result.headers.push({
163
+ name: 'content-type',
164
+ value: 'application/x-www-form-urlencoded',
165
+ });
166
+ }
107
167
  return result;
108
168
  };
@@ -2,3 +2,4 @@ export declare const formatTemporaryErrorMessage: (errors: ReadonlyArray<{
2
2
  message?: string;
3
3
  }>) => string;
4
4
  export declare const PERMANENT_STEPZEN_ERROR: string;
5
+ export declare const UPGRADE_CHECK_ERROR: string;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  // Copyright (c) 2020,2021,2022, StepZen, Inc.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.PERMANENT_STEPZEN_ERROR = exports.formatTemporaryErrorMessage = void 0;
4
+ exports.UPGRADE_CHECK_ERROR = exports.PERMANENT_STEPZEN_ERROR = exports.formatTemporaryErrorMessage = void 0;
5
5
  exports.formatTemporaryErrorMessage = (errors) => `A problem occurred while processing your import${errors.length > 0 && errors[0].message ? `: "${errors[0].message}"` : ''}. Please try again.` +
6
6
  ` If the issue persists, make sure you are on the latest version of StepZen ` +
7
7
  `CLI. And if the issue still persists contact support via the StepZen discord ` +
@@ -10,3 +10,7 @@ exports.PERMANENT_STEPZEN_ERROR = 'An unexpected problem occurred while processi
10
10
  ` If the issue persists, make sure you are on the latest version of StepZen ` +
11
11
  `CLI. And if the issue still persists contact support via the StepZen discord ` +
12
12
  `channel (https://discord.gg/9k2VdPn2FR).`;
13
+ exports.UPGRADE_CHECK_ERROR = 'An unexpected problem occurred while checking for new CLI versions.' +
14
+ ` If the issue persists, make sure you are on the latest version of StepZen ` +
15
+ `CLI. And if the issue still persists contact support via the StepZen discord ` +
16
+ `channel (https://discord.gg/9k2VdPn2FR).`;
@@ -1 +1 @@
1
- {"version":"0.10.0-beta.5","commands":{"deploy":{"id":"deploy","description":"deploy to stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"configurationsets":{"name":"configurationsets","type":"option","description":"Configurationsets to use","default":""},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"schema":{"name":"schema","type":"option","description":"Schema to use","required":true},"silent":{"name":"silent","type":"boolean","allowNo":false}},"args":[{"name":"destination","description":"destination","required":true}]},"import":{"id":"import","description":"import schemas from stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"dir":{"name":"dir","type":"option","description":"working directory"},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"silent":{"name":"silent","type":"boolean","hidden":true,"allowNo":false},"name":{"name":"name","type":"option","description":"subfolder inside the workspace folder to save the imported schema files, defaults to the imported schema name"},"prefix":{"name":"prefix","type":"option","description":"[curl] prefix to add every type in the generated schema."},"query-name":{"name":"query-name","type":"option","description":"[curl] property name to add to the Query type as a way to access the imported cURL endpoint."},"query-type":{"name":"query-type","type":"option","description":"[curl] name for the type returned by the cURL endpoint in the generated schema. The name specified by --query-type is not prefixed by --prefix if both flags are present."}},"args":[{"name":"schemas","required":true}]},"init":{"id":"init","description":"stepzen init","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"endpoint":{"name":"endpoint","type":"option","hidden":true},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"yes":{"name":"yes","type":"boolean","hidden":true,"allowNo":false}},"args":[{"name":"directory","hidden":true}]},"lint":{"id":"lint","description":"stepzen lint","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"dir":{"name":"dir","type":"option","hidden":true},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"list":{"id":"list","description":"list your items","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"type","description":"type","required":true,"options":["configurationsets","schemas"]}]},"login":{"id":"login","description":"log in to stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"account":{"name":"account","type":"option","char":"a","hidden":true},"adminkey":{"name":"adminkey","type":"option","char":"k","hidden":true},"config":{"name":"config","type":"option","hidden":true},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"logout":{"id":"logout","description":"log out of stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"start":{"id":"start","description":"upload and deploy your schema","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"dir":{"name":"dir","type":"option","description":"working directory"},"endpoint":{"name":"endpoint","type":"option","description":"Override workspace endpoint"},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"no-console":{"name":"no-console","type":"boolean","hidden":true,"allowNo":false},"no-dashboard":{"name":"no-dashboard","type":"boolean","hidden":true,"allowNo":false},"no-init":{"name":"no-init","type":"boolean","hidden":true,"allowNo":false},"no-server":{"name":"no-server","type":"boolean","hidden":true,"allowNo":false},"no-validate":{"name":"no-validate","type":"boolean","hidden":true,"allowNo":false},"no-watcher":{"name":"no-watcher","type":"boolean","hidden":true,"allowNo":false},"port":{"name":"port","type":"option","default":5001}},"args":[]},"transpile":{"id":"transpile","description":"transpile a graphql schema","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"config":{"name":"config","type":"option","hidden":true},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"hide-output":{"name":"hide-output","type":"boolean","hidden":true,"allowNo":false},"inspect":{"name":"inspect","type":"boolean","char":"i","hidden":true,"allowNo":false},"inspect-after":{"name":"inspect-after","type":"boolean","hidden":true,"allowNo":false},"output-configuration":{"name":"output-configuration","type":"boolean","allowNo":false},"silent":{"name":"silent","type":"boolean","allowNo":false}},"args":[{"name":"folder","required":true}]},"upload":{"id":"upload","description":"upload to stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"dir":{"name":"dir","type":"option","description":"A directory to upload"},"file":{"name":"file","type":"option","description":"A file to upload"},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"silent":{"name":"silent","type":"boolean","allowNo":false}},"args":[{"name":"type","description":"type","required":true,"options":["configurationset","schema"]},{"name":"destination","description":"destination","required":true}]},"validate":{"id":"validate","description":"validate a graphql schema","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"folder","required":true}]},"whoami":{"id":"whoami","description":"stepzen whoami","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"showkeys":{"name":"showkeys","type":"boolean","allowNo":false},"apikey":{"name":"apikey","type":"boolean","allowNo":false},"adminkey":{"name":"adminkey","type":"boolean","allowNo":false}},"args":[]}}}
1
+ {"version":"0.11.0-beta.1","commands":{"deploy":{"id":"deploy","description":"deploy to stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"configurationsets":{"name":"configurationsets","type":"option","description":"Configurationsets to use","default":""},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"schema":{"name":"schema","type":"option","description":"Schema to use","required":true},"silent":{"name":"silent","type":"boolean","allowNo":false}},"args":[{"name":"destination","description":"destination","required":true}]},"import":{"id":"import","description":"import schemas from stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"dir":{"name":"dir","type":"option","description":"working directory"},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"silent":{"name":"silent","type":"boolean","hidden":true,"allowNo":false},"name":{"name":"name","type":"option","description":"subfolder inside the workspace folder to save the imported schema files, defaults to the imported schema name"},"prefix":{"name":"prefix","type":"option","description":"[curl] prefix to add every type in the generated schema."},"query-name":{"name":"query-name","type":"option","description":"[curl] property name to add to the Query type as a way to access the imported cURL endpoint."},"query-type":{"name":"query-type","type":"option","description":"[curl] name for the type returned by the cURL endpoint in the generated schema. The name specified by --query-type is not prefixed by --prefix if both flags are present."}},"args":[{"name":"schemas","required":true}]},"init":{"id":"init","description":"stepzen init","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"endpoint":{"name":"endpoint","type":"option","hidden":true},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"yes":{"name":"yes","type":"boolean","hidden":true,"allowNo":false}},"args":[{"name":"directory","hidden":true}]},"lint":{"id":"lint","description":"stepzen lint","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"dir":{"name":"dir","type":"option","hidden":true},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"list":{"id":"list","description":"list your items","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"type","description":"type","required":true,"options":["configurationsets","schemas"]}]},"login":{"id":"login","description":"log in to stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"account":{"name":"account","type":"option","char":"a","hidden":true},"adminkey":{"name":"adminkey","type":"option","char":"k","hidden":true},"config":{"name":"config","type":"option","hidden":true},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"logout":{"id":"logout","description":"log out of stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"start":{"id":"start","description":"upload and deploy your schema","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"dir":{"name":"dir","type":"option","description":"working directory"},"endpoint":{"name":"endpoint","type":"option","description":"Override workspace endpoint"},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"no-console":{"name":"no-console","type":"boolean","hidden":true,"allowNo":false},"no-dashboard":{"name":"no-dashboard","type":"boolean","hidden":true,"allowNo":false},"no-init":{"name":"no-init","type":"boolean","hidden":true,"allowNo":false},"no-server":{"name":"no-server","type":"boolean","hidden":true,"allowNo":false},"no-validate":{"name":"no-validate","type":"boolean","hidden":true,"allowNo":false},"no-watcher":{"name":"no-watcher","type":"boolean","hidden":true,"allowNo":false},"port":{"name":"port","type":"option","default":5001}},"args":[]},"transpile":{"id":"transpile","description":"transpile a graphql schema","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"config":{"name":"config","type":"option","hidden":true},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"hide-output":{"name":"hide-output","type":"boolean","hidden":true,"allowNo":false},"inspect":{"name":"inspect","type":"boolean","char":"i","hidden":true,"allowNo":false},"inspect-after":{"name":"inspect-after","type":"boolean","hidden":true,"allowNo":false},"output-configuration":{"name":"output-configuration","type":"boolean","allowNo":false},"silent":{"name":"silent","type":"boolean","allowNo":false}},"args":[{"name":"folder","required":true}]},"upload":{"id":"upload","description":"upload to stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"dir":{"name":"dir","type":"option","description":"A directory to upload"},"file":{"name":"file","type":"option","description":"A file to upload"},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"silent":{"name":"silent","type":"boolean","allowNo":false}},"args":[{"name":"type","description":"type","required":true,"options":["configurationset","schema"]},{"name":"destination","description":"destination","required":true}]},"validate":{"id":"validate","description":"validate a graphql schema","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"folder","required":true}]},"whoami":{"id":"whoami","description":"stepzen whoami","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"showkeys":{"name":"showkeys","type":"boolean","allowNo":false},"apikey":{"name":"apikey","type":"boolean","allowNo":false},"adminkey":{"name":"adminkey","type":"boolean","allowNo":false}},"args":[]}}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stepzen",
3
3
  "description": "The StepZen CLI",
4
- "version": "0.10.0-beta.5",
4
+ "version": "0.11.0-beta.1",
5
5
  "license": "MIT",
6
6
  "author": "Darren Waddell <darren@stepzen.com>",
7
7
  "contributors": [
@@ -119,6 +119,8 @@
119
119
  "posttest": "eslint . --ignore-path .prettierignore",
120
120
  "prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
121
121
  "test": "tsc -b && STEPZEN_DOMAIN=steprz.io STEPZEN_SERVER_URL=http://localhost nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
122
+ "test:single:example": "npm run test:single -- test/src/shared/curl-parser.test.ts",
123
+ "test:single": "tsc -b && STEPZEN_DOMAIN=steprz.io STEPZEN_SERVER_URL=http://localhost mocha --forbid-only test/_global.test.ts",
122
124
  "version": "oclif-dev readme && git add README.md",
123
125
  "prepare": "husky install"
124
126
  },