stepzen 0.0.0-experimental-94cb99b-20220608

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.
Files changed (82) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +229 -0
  3. package/bin/run +5 -0
  4. package/bin/run.cmd +3 -0
  5. package/lib/commands/deploy.d.ts +18 -0
  6. package/lib/commands/deploy.js +57 -0
  7. package/lib/commands/import.d.ts +105 -0
  8. package/lib/commands/import.js +368 -0
  9. package/lib/commands/init.d.ts +17 -0
  10. package/lib/commands/init.js +28 -0
  11. package/lib/commands/lint.d.ts +12 -0
  12. package/lib/commands/lint.js +27 -0
  13. package/lib/commands/list.d.ts +15 -0
  14. package/lib/commands/list.js +44 -0
  15. package/lib/commands/login.d.ts +14 -0
  16. package/lib/commands/login.js +74 -0
  17. package/lib/commands/logout.d.ts +9 -0
  18. package/lib/commands/logout.js +18 -0
  19. package/lib/commands/start.d.ts +19 -0
  20. package/lib/commands/start.js +101 -0
  21. package/lib/commands/transpile.d.ts +21 -0
  22. package/lib/commands/transpile.js +49 -0
  23. package/lib/commands/upload.d.ts +24 -0
  24. package/lib/commands/upload.js +73 -0
  25. package/lib/commands/validate.d.ts +14 -0
  26. package/lib/commands/validate.js +34 -0
  27. package/lib/commands/whoami.d.ts +14 -0
  28. package/lib/commands/whoami.js +70 -0
  29. package/lib/generate/curl2sdl.d.ts +55 -0
  30. package/lib/generate/curl2sdl.js +191 -0
  31. package/lib/generate/graphql2sdl.d.ts +23 -0
  32. package/lib/generate/graphql2sdl.js +64 -0
  33. package/lib/generate/helpers.d.ts +31 -0
  34. package/lib/generate/helpers.js +254 -0
  35. package/lib/generate/index.d.ts +11 -0
  36. package/lib/generate/index.js +102 -0
  37. package/lib/hooks/prerun/check-upgrade.d.ts +9 -0
  38. package/lib/hooks/prerun/check-upgrade.js +117 -0
  39. package/lib/hooks/prerun/ensure-config-file.d.ts +3 -0
  40. package/lib/hooks/prerun/ensure-config-file.js +28 -0
  41. package/lib/hooks/prerun/ensure-permissions.d.ts +3 -0
  42. package/lib/hooks/prerun/ensure-permissions.js +20 -0
  43. package/lib/index.d.ts +1 -0
  44. package/lib/index.js +6 -0
  45. package/lib/shared/actions.d.ts +4 -0
  46. package/lib/shared/actions.js +47 -0
  47. package/lib/shared/configuration.d.ts +24 -0
  48. package/lib/shared/configuration.js +133 -0
  49. package/lib/shared/constants.d.ts +13 -0
  50. package/lib/shared/constants.js +33 -0
  51. package/lib/shared/curl-parser.d.ts +24 -0
  52. package/lib/shared/curl-parser.js +189 -0
  53. package/lib/shared/errors.d.ts +5 -0
  54. package/lib/shared/errors.js +18 -0
  55. package/lib/shared/header-params-parser.d.ts +7 -0
  56. package/lib/shared/header-params-parser.js +110 -0
  57. package/lib/shared/header.d.ts +32 -0
  58. package/lib/shared/header.js +44 -0
  59. package/lib/shared/moniker.d.ts +4 -0
  60. package/lib/shared/moniker.js +645 -0
  61. package/lib/shared/path-params-parser.d.ts +7 -0
  62. package/lib/shared/path-params-parser.js +83 -0
  63. package/lib/shared/stepzen-sdk.d.ts +110 -0
  64. package/lib/shared/stepzen-sdk.js +207 -0
  65. package/lib/shared/types.d.ts +44 -0
  66. package/lib/shared/types.js +3 -0
  67. package/lib/shared/utils.d.ts +19 -0
  68. package/lib/shared/utils.js +93 -0
  69. package/lib/shared/validation.d.ts +2 -0
  70. package/lib/shared/validation.js +41 -0
  71. package/lib/shared/workspace.d.ts +10 -0
  72. package/lib/shared/workspace.js +165 -0
  73. package/lib/shared/zen-command.d.ts +18 -0
  74. package/lib/shared/zen-command.js +115 -0
  75. package/lib/start/console.d.ts +11 -0
  76. package/lib/start/console.js +51 -0
  77. package/lib/start/deploy.d.ts +6 -0
  78. package/lib/start/deploy.js +114 -0
  79. package/lib/start/index.d.ts +2 -0
  80. package/lib/start/index.js +10 -0
  81. package/oclif.manifest.json +1 -0
  82. package/package.json +136 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020,2021,2022, StepZen, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,229 @@
1
+ # StepZen CLI
2
+
3
+ The StepZen Command Line Interface (CLI) tool enables you to set up and manage StepZen using commands in your command-line shell.
4
+
5
+ After you have written or imported your GraphQL schema in the form of a Schema Definition Language (SDL) file, and defined your "configuration" in a YAML files, you can upload and deploy them to StepZen using the StepZen CLI - resulting in a live GraphQL endpoint.
6
+
7
+ # Installing
8
+
9
+ `npm install -g stepzen`
10
+
11
+ # Verifying your installation
12
+ To verify your CLI installation, use the `stepzen --version` command:
13
+
14
+ `$ stepzen (-v|--version|version)`
15
+
16
+ ----------------------------------------
17
+
18
+ <!-- toc -->
19
+ * [StepZen CLI](#stepzen-cli)
20
+ * [Installing](#installing)
21
+ * [Verifying your installation](#verifying-your-installation)
22
+ * [Usage](#usage)
23
+ * [Commands](#commands)
24
+ <!-- tocstop -->
25
+ # Usage
26
+ <!-- usage -->
27
+ ```sh-session
28
+ $ npm install -g stepzen
29
+ $ stepzen COMMAND
30
+ running command...
31
+ $ stepzen (-v|--version|version)
32
+ stepzen/0.0.0-experimental-94cb99b-20220608 darwin-x64 node-v14.19.3
33
+ $ stepzen --help [COMMAND]
34
+ USAGE
35
+ $ stepzen COMMAND
36
+ ...
37
+ ```
38
+ <!-- usagestop -->
39
+ # Commands
40
+ <!-- commands -->
41
+ * [`stepzen deploy DESTINATION`](#stepzen-deploy-destination)
42
+ * [`stepzen help [COMMAND]`](#stepzen-help-command)
43
+ * [`stepzen import SCHEMA`](#stepzen-import-schema)
44
+ * [`stepzen list TYPE`](#stepzen-list-type)
45
+ * [`stepzen login`](#stepzen-login)
46
+ * [`stepzen logout`](#stepzen-logout)
47
+ * [`stepzen start`](#stepzen-start)
48
+ * [`stepzen upload TYPE DESTINATION`](#stepzen-upload-type-destination)
49
+
50
+ ## `stepzen deploy DESTINATION`
51
+
52
+ deploy to stepzen
53
+
54
+ ```
55
+ USAGE
56
+ $ stepzen deploy DESTINATION
57
+
58
+ ARGUMENTS
59
+ DESTINATION destination
60
+
61
+ OPTIONS
62
+ -h, --help show CLI help
63
+ --configurationsets=configurationsets Configurationsets to use
64
+ --schema=schema (required) Schema to use
65
+ --silent
66
+ ```
67
+
68
+ ## `stepzen help [COMMAND]`
69
+
70
+ Display help for stepzen.
71
+
72
+ ```
73
+ USAGE
74
+ $ stepzen help [COMMAND]
75
+
76
+ ARGUMENTS
77
+ COMMAND Command to show help for.
78
+
79
+ OPTIONS
80
+ -n, --nested-commands Include all nested commands in the output.
81
+ ```
82
+
83
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.1.12/src/commands/help.ts)_
84
+
85
+ ## `stepzen import SCHEMA`
86
+
87
+ import a schema for an external data source or a API endpoint to your GraphQL API
88
+
89
+ ```
90
+ USAGE
91
+ $ stepzen import SCHEMA
92
+
93
+ OPTIONS
94
+ -H, --header=header
95
+ [curl, graphql] specifies a request header to pass
96
+
97
+ Example:
98
+ stepzen import curl https://example.com/api/customers \
99
+ -H "Authorization: apikey SecretAPIKeyValue"
100
+
101
+ -h, --help
102
+ show CLI help
103
+
104
+ --db-database=db-database
105
+ [mysql, postgresql] name of database to import
106
+
107
+ --db-host=db-host
108
+ [mysql, postgresql] database host
109
+
110
+ --db-password=db-password
111
+ [mysql, postgresql] database password
112
+
113
+ --db-schema=db-schema
114
+ [postgresql] database schema
115
+
116
+ --db-user=db-user
117
+ [mysql, postgresql] database user name
118
+
119
+ --dir=dir
120
+ working directory
121
+
122
+ --header-param=header-param
123
+ [curl, graphql] specifies a parameter in a header value. Can be formed by taking a -H, --header flag and replacing
124
+ the variable part of the header value with a $paramName placeholder. Repeat this flag once for each header with a
125
+ parameter.
126
+
127
+ Example:
128
+ stepzen import curl https://example.com/api/customers \
129
+ -H "Authorization: apikey SecretAPIKeyValue" \
130
+ --header-param 'Authorization: apikey $apikey'
131
+
132
+ --name=name
133
+ Subfolder inside the workspace folder to save the imported schema files to. Defaults to the name of the imported
134
+ schema.
135
+
136
+ --path-params=path-params
137
+ [curl] specifies path parameters in the URL path. Can be formed by taking the original path and replacing the
138
+ variable segments with $paramName placeholders.
139
+
140
+ Example:
141
+ stepzen import curl https://example.com/users/jane/posts/12 --path-params '/users/$userId/posts/$postId'
142
+
143
+ --prefix=prefix
144
+ [curl, graphql] prefix to add every type in the generated schema.
145
+
146
+ --query-name=query-name
147
+ [curl] property name to add to the Query type as a way to access the imported cURL endpoint.
148
+
149
+ --query-type=query-type
150
+ [curl] name for the type returned by the cURL endpoint in the generated schema. The name specified by --query-type
151
+ is not prefixed by --prefix if both flags are present.
152
+ ```
153
+
154
+ ## `stepzen list TYPE`
155
+
156
+ list your items
157
+
158
+ ```
159
+ USAGE
160
+ $ stepzen list TYPE
161
+
162
+ ARGUMENTS
163
+ TYPE (configurationsets|schemas) type
164
+
165
+ OPTIONS
166
+ -h, --help show CLI help
167
+ ```
168
+
169
+ ## `stepzen login`
170
+
171
+ log in to StepZen
172
+
173
+ ```
174
+ USAGE
175
+ $ stepzen login
176
+
177
+ OPTIONS
178
+ -h, --help show CLI help
179
+
180
+ --public Create a public anonymous StepZen account and use it. This is handy for trying StepZen out, but it not
181
+ suitable for handling private data as all endpoints created with a public account will be public.
182
+ ```
183
+
184
+ ## `stepzen logout`
185
+
186
+ log out of StepZen
187
+
188
+ ```
189
+ USAGE
190
+ $ stepzen logout
191
+
192
+ OPTIONS
193
+ -h, --help show CLI help
194
+ ```
195
+
196
+ ## `stepzen start`
197
+
198
+ upload and deploy your schema
199
+
200
+ ```
201
+ USAGE
202
+ $ stepzen start
203
+
204
+ OPTIONS
205
+ -h, --help show CLI help
206
+ --dir=dir working directory
207
+ --endpoint=endpoint Override workspace endpoint
208
+ --port=port [default: 5001]
209
+ ```
210
+
211
+ ## `stepzen upload TYPE DESTINATION`
212
+
213
+ upload to StepZen
214
+
215
+ ```
216
+ USAGE
217
+ $ stepzen upload TYPE DESTINATION
218
+
219
+ ARGUMENTS
220
+ TYPE (configurationset|schema) type
221
+ DESTINATION destination
222
+
223
+ OPTIONS
224
+ -h, --help show CLI help
225
+ --dir=dir A directory to upload
226
+ --file=file A file to upload
227
+ --silent
228
+ ```
229
+ <!-- commandsstop -->
package/bin/run ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ require('@oclif/command').run()
4
+ .then(require('@oclif/command/flush'))
5
+ .catch(require('@oclif/errors/handle'))
package/bin/run.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\run" %*
@@ -0,0 +1,18 @@
1
+ import { flags } from '@oclif/command';
2
+ import ZenCommand from '../shared/zen-command';
3
+ export default class Deploy extends ZenCommand {
4
+ static description: string;
5
+ static flags: {
6
+ configurationsets: flags.IOptionFlag<string>;
7
+ help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
8
+ schema: flags.IOptionFlag<string>;
9
+ silent: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
10
+ 'non-interactive': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
11
+ };
12
+ static args: {
13
+ name: string;
14
+ description: string;
15
+ required: boolean;
16
+ }[];
17
+ run(): Promise<void>;
18
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ // Copyright (c) 2020,2021,2022, StepZen, Inc.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ // This file contains the code for the `stepzen deploy` command.
5
+ // Deployment in stepzen is an operation that takes three classes of uploaded
6
+ // objects, a single schema, and a collection of configurationsets
7
+ // and uses them to produce an endpoint which serves a GraphQL API.
8
+ const command_1 = require("@oclif/command");
9
+ const errors_1 = require("@oclif/errors");
10
+ const actions_1 = require("../shared/actions");
11
+ const zen_command_1 = require("../shared/zen-command");
12
+ class Deploy extends zen_command_1.default {
13
+ async run() {
14
+ const { args, flags } = this.parse(Deploy);
15
+ // Make sure that you definitely specify folder/name
16
+ if (args.destination.includes('/') === false) {
17
+ throw new errors_1.CLIError('You must specify the folder/name you want to use');
18
+ }
19
+ const { configuration } = await this.ensureStepZenAccount();
20
+ if (!flags.silent) {
21
+ this.log('Deploying...');
22
+ }
23
+ // If this is a public account, add a special configuration set to make the
24
+ // endpoint public (https://github.com/steprz/zen/pull/5701)
25
+ if (configuration.account.startsWith('public')) {
26
+ flags.configurationsets = flags.configurationsets
27
+ ? `${flags.configurationsets},stepzen/public`
28
+ : 'stepzen/public';
29
+ }
30
+ const response = await (0, actions_1.deploy)(args.destination, flags.configurationsets, flags.schema);
31
+ if (response.success) {
32
+ if (!flags.silent) {
33
+ this.log(response.message || 'Success');
34
+ }
35
+ }
36
+ else {
37
+ // Errors. Exit, and output the server's error response
38
+ throw new errors_1.CLIError(JSON.stringify(response.errors) || 'An error occurred.');
39
+ }
40
+ }
41
+ }
42
+ exports.default = Deploy;
43
+ Deploy.description = 'deploy to stepzen';
44
+ Deploy.flags = Object.assign(Object.assign({}, zen_command_1.default.flags), {
45
+ // configurationsets is assumed to be a comma separated string naming uploaded configurationsets
46
+ // a special configuration 'stepzen/defaults' is recognized.
47
+ configurationsets: command_1.flags.string({
48
+ description: 'Configurationsets to use',
49
+ default: '',
50
+ }), help: command_1.flags.help({ char: 'h' }), schema: command_1.flags.string({ description: 'Schema to use', required: true }), silent: command_1.flags.boolean() });
51
+ Deploy.args = [
52
+ {
53
+ name: 'destination',
54
+ description: 'destination',
55
+ required: true,
56
+ },
57
+ ];
@@ -0,0 +1,105 @@
1
+ import { flags } from '@oclif/command';
2
+ import ZenCommand from '../shared/zen-command';
3
+ import { HeaderInput } from '../shared/header';
4
+ import { Workspace } from '../shared/types';
5
+ export default class Import extends ZenCommand {
6
+ static description: string;
7
+ static commonIntrospectionFlags: {
8
+ prefix: flags.IOptionFlag<string | undefined>;
9
+ header: flags.IOptionFlag<string[]>;
10
+ 'header-param': flags.IOptionFlag<string[]>;
11
+ };
12
+ static curlFlags: {
13
+ 'query-name': flags.IOptionFlag<string | undefined>;
14
+ 'query-type': flags.IOptionFlag<string | undefined>;
15
+ 'path-params': flags.IOptionFlag<string | undefined>;
16
+ };
17
+ static sqlFlags: {
18
+ 'db-host': flags.IOptionFlag<string | undefined>;
19
+ 'db-user': flags.IOptionFlag<string | undefined>;
20
+ 'db-password': flags.IOptionFlag<string | undefined>;
21
+ 'db-database': flags.IOptionFlag<string | undefined>;
22
+ };
23
+ static postgresqlFlags: {
24
+ 'db-schema': flags.IOptionFlag<string | undefined>;
25
+ };
26
+ static flagsForSchemas: ({
27
+ flags: {
28
+ prefix: flags.IOptionFlag<string | undefined>;
29
+ header: flags.IOptionFlag<string[]>;
30
+ 'header-param': flags.IOptionFlag<string[]>;
31
+ };
32
+ schemas: string[];
33
+ } | {
34
+ flags: {
35
+ 'query-name': flags.IOptionFlag<string | undefined>;
36
+ 'query-type': flags.IOptionFlag<string | undefined>;
37
+ 'path-params': flags.IOptionFlag<string | undefined>;
38
+ };
39
+ schemas: string[];
40
+ } | {
41
+ flags: {
42
+ 'db-host': flags.IOptionFlag<string | undefined>;
43
+ 'db-user': flags.IOptionFlag<string | undefined>;
44
+ 'db-password': flags.IOptionFlag<string | undefined>;
45
+ 'db-database': flags.IOptionFlag<string | undefined>;
46
+ };
47
+ schemas: string[];
48
+ } | {
49
+ flags: {
50
+ 'db-schema': flags.IOptionFlag<string | undefined>;
51
+ };
52
+ schemas: string[];
53
+ })[];
54
+ static flags: {
55
+ 'db-schema': flags.IOptionFlag<string | undefined>;
56
+ 'db-host': flags.IOptionFlag<string | undefined>;
57
+ 'db-user': flags.IOptionFlag<string | undefined>;
58
+ 'db-password': flags.IOptionFlag<string | undefined>;
59
+ 'db-database': flags.IOptionFlag<string | undefined>;
60
+ 'query-name': flags.IOptionFlag<string | undefined>;
61
+ 'query-type': flags.IOptionFlag<string | undefined>;
62
+ 'path-params': flags.IOptionFlag<string | undefined>;
63
+ prefix: flags.IOptionFlag<string | undefined>;
64
+ header: flags.IOptionFlag<string[]>;
65
+ 'header-param': flags.IOptionFlag<string[]>;
66
+ dir: flags.IOptionFlag<string | undefined>;
67
+ help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
68
+ silent: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
69
+ name: flags.IOptionFlag<string | undefined>;
70
+ overwrite: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
71
+ 'non-interactive': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
72
+ };
73
+ static args: {
74
+ name: string;
75
+ required: boolean;
76
+ }[];
77
+ static strict: boolean;
78
+ run(): Promise<void>;
79
+ ensureOnConflictBehavior(workspace: Workspace, schema: string, flags: ReturnType<Import['parseWorkaround']>['flags']): Promise<"overwrite" | "append">;
80
+ warnAboutIgnoredFlags(schema: string, usedFlags: {
81
+ [key: string]: any;
82
+ }): void;
83
+ parseWorkaround(): import("@oclif/parser").Output<{
84
+ 'db-schema': string | undefined;
85
+ 'db-host': string | undefined;
86
+ 'db-user': string | undefined;
87
+ 'db-password': string | undefined;
88
+ 'db-database': string | undefined;
89
+ 'query-name': string | undefined;
90
+ 'query-type': string | undefined;
91
+ 'path-params': string | undefined;
92
+ prefix: string | undefined;
93
+ header: string[];
94
+ 'header-param': string[];
95
+ dir: string | undefined;
96
+ help: void;
97
+ silent: boolean;
98
+ name: string | undefined;
99
+ overwrite: boolean;
100
+ 'non-interactive': boolean;
101
+ }, {
102
+ [name: string]: any;
103
+ }>;
104
+ parseHeaderFlags(headerFlagValues?: string[], headerParamFlagValues?: string[]): HeaderInput[];
105
+ }