@apimatic/cli 1.1.0-alpha.2 → 1.1.0-alpha.21
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 +257 -101
- package/bin/run.js +5 -0
- package/lib/actions/action-result.d.ts +8 -0
- package/lib/actions/action-result.js +25 -0
- package/lib/actions/action-result.js.map +1 -0
- package/lib/actions/auth/login.d.ts +12 -0
- package/lib/actions/auth/login.js +63 -0
- package/lib/actions/auth/login.js.map +1 -0
- package/lib/actions/portal/copilot.d.ts +14 -0
- package/lib/actions/portal/copilot.js +79 -0
- package/lib/actions/portal/copilot.js.map +1 -0
- package/lib/actions/portal/generate.d.ts +14 -0
- package/lib/actions/portal/generate.js +66 -0
- package/lib/actions/portal/generate.js.map +1 -0
- package/lib/actions/portal/recipe/new-recipe.d.ts +24 -0
- package/lib/actions/portal/recipe/new-recipe.js +250 -0
- package/lib/actions/portal/recipe/new-recipe.js.map +1 -0
- package/lib/actions/portal/serve.d.ts +14 -0
- package/lib/actions/portal/serve.js +24 -0
- package/lib/actions/portal/serve.js.map +1 -0
- package/lib/actions/portal/toc/new-toc.d.ts +20 -0
- package/lib/actions/portal/toc/new-toc.js +133 -0
- package/lib/actions/portal/toc/new-toc.js.map +1 -0
- package/lib/actions/sdk/generate.d.ts +14 -0
- package/lib/actions/sdk/generate.js +72 -0
- package/lib/actions/sdk/generate.js.map +1 -0
- package/lib/application/portal/recipe/portal-recipe.d.ts +8 -0
- package/lib/application/portal/recipe/portal-recipe.js +33 -0
- package/lib/application/portal/recipe/portal-recipe.js.map +1 -0
- package/lib/application/portal/recipe/recipe-generator.d.ts +16 -0
- package/lib/application/portal/recipe/recipe-generator.js +147 -0
- package/lib/application/portal/recipe/recipe-generator.js.map +1 -0
- package/lib/application/portal/serve/portal-watcher.d.ts +11 -0
- package/lib/application/portal/serve/portal-watcher.js +64 -0
- package/lib/application/portal/serve/portal-watcher.js.map +1 -0
- package/lib/application/portal/serve/serve-handler.d.ts +16 -0
- package/lib/application/portal/serve/serve-handler.js +91 -0
- package/lib/application/portal/serve/serve-handler.js.map +1 -0
- package/lib/application/portal/serve/watcher-handler.d.ts +10 -0
- package/lib/application/portal/serve/watcher-handler.js +51 -0
- package/lib/application/portal/serve/watcher-handler.js.map +1 -0
- package/lib/application/portal/toc/sdl-parser.d.ts +19 -0
- package/lib/application/portal/toc/sdl-parser.js +90 -0
- package/lib/application/portal/toc/sdl-parser.js.map +1 -0
- package/lib/application/portal/toc/toc-content-parser.d.ts +5 -0
- package/lib/application/portal/toc/toc-content-parser.js +44 -0
- package/lib/application/portal/toc/toc-content-parser.js.map +1 -0
- package/lib/application/portal/toc/toc-structure-generator.d.ts +6 -0
- package/lib/application/portal/toc/toc-structure-generator.js +84 -0
- package/lib/application/portal/toc/toc-structure-generator.js.map +1 -0
- package/lib/client-utils/auth-manager.d.ts +8 -3
- package/lib/client-utils/auth-manager.js +23 -10
- package/lib/client-utils/auth-manager.js.map +1 -0
- package/lib/client-utils/sdk-client.d.ts +4 -9
- package/lib/client-utils/sdk-client.js +9 -87
- package/lib/client-utils/sdk-client.js.map +1 -0
- package/lib/commands/api/transform.d.ts +7 -7
- package/lib/commands/api/transform.js +46 -51
- package/lib/commands/api/transform.js.map +1 -0
- package/lib/commands/api/validate.d.ts +4 -4
- package/lib/commands/api/validate.js +35 -36
- package/lib/commands/api/validate.js.map +1 -0
- package/lib/commands/auth/login.d.ts +3 -2
- package/lib/commands/auth/login.js +22 -53
- package/lib/commands/auth/login.js.map +1 -0
- package/lib/commands/auth/logout.d.ts +1 -1
- package/lib/commands/auth/logout.js +8 -13
- package/lib/commands/auth/logout.js.map +1 -0
- package/lib/commands/auth/status.d.ts +1 -1
- package/lib/commands/auth/status.js +9 -13
- package/lib/commands/auth/status.js.map +1 -0
- package/lib/commands/portal/copilot.d.ts +13 -0
- package/lib/commands/portal/copilot.js +32 -0
- package/lib/commands/portal/copilot.js.map +1 -0
- package/lib/commands/portal/generate.d.ts +10 -8
- package/lib/commands/portal/generate.js +28 -107
- package/lib/commands/portal/generate.js.map +1 -0
- package/lib/commands/portal/quickstart.d.ts +10 -0
- package/lib/commands/portal/quickstart.js +114 -0
- package/lib/commands/portal/quickstart.js.map +1 -0
- package/lib/commands/portal/recipe/new.d.ts +10 -0
- package/lib/commands/portal/recipe/new.js +38 -0
- package/lib/commands/portal/recipe/new.js.map +1 -0
- package/lib/commands/portal/serve.d.ts +16 -0
- package/lib/commands/portal/serve.js +80 -0
- package/lib/commands/portal/serve.js.map +1 -0
- package/lib/commands/portal/toc/new.d.ts +14 -0
- package/lib/commands/portal/toc/new.js +52 -0
- package/lib/commands/portal/toc/new.js.map +1 -0
- package/lib/commands/sdk/generate.d.ts +9 -8
- package/lib/commands/sdk/generate.js +39 -128
- package/lib/commands/sdk/generate.js.map +1 -0
- package/lib/config/axios-config.d.ts +2 -0
- package/lib/config/axios-config.js +10 -0
- package/lib/config/axios-config.js.map +1 -0
- package/lib/config/env.d.ts +26 -1
- package/lib/config/env.js +27 -4
- package/lib/config/env.js.map +1 -0
- package/lib/controllers/api/transform.d.ts +1 -1
- package/lib/controllers/api/transform.js +23 -22
- package/lib/controllers/api/transform.js.map +1 -0
- package/lib/controllers/api/validate.d.ts +3 -3
- package/lib/controllers/api/validate.js +19 -12
- package/lib/controllers/api/validate.js.map +1 -0
- package/lib/controllers/portal/quickstart.d.ts +13 -0
- package/lib/controllers/portal/quickstart.js +214 -0
- package/lib/controllers/portal/quickstart.js.map +1 -0
- package/lib/hooks/not-found.d.ts +3 -0
- package/lib/hooks/not-found.js +52 -0
- package/lib/hooks/not-found.js.map +1 -0
- package/lib/hooks/utils.d.ts +5 -0
- package/lib/hooks/utils.js +51 -0
- package/lib/hooks/utils.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -4
- package/lib/index.js.map +1 -0
- package/lib/infrastructure/api-client-utils.d.ts +6 -0
- package/lib/infrastructure/api-client-utils.js +34 -0
- package/lib/infrastructure/api-client-utils.js.map +1 -0
- package/lib/infrastructure/api-utils.d.ts +9 -0
- package/lib/infrastructure/api-utils.js +33 -0
- package/lib/infrastructure/api-utils.js.map +1 -0
- package/lib/infrastructure/env-info.d.ts +12 -0
- package/lib/infrastructure/env-info.js +58 -0
- package/lib/infrastructure/env-info.js.map +1 -0
- package/lib/infrastructure/file-service.d.ts +18 -0
- package/lib/infrastructure/file-service.js +76 -0
- package/lib/infrastructure/file-service.js.map +1 -0
- package/lib/infrastructure/launcher-service.d.ts +5 -0
- package/lib/infrastructure/launcher-service.js +47 -0
- package/lib/infrastructure/launcher-service.js.map +1 -0
- package/lib/infrastructure/services/api-service.d.ts +10 -0
- package/lib/infrastructure/services/api-service.js +55 -0
- package/lib/infrastructure/services/api-service.js.map +1 -0
- package/lib/infrastructure/services/auth-service.d.ts +11 -0
- package/lib/infrastructure/services/auth-service.js +35 -0
- package/lib/infrastructure/services/auth-service.js.map +1 -0
- package/lib/infrastructure/services/portal-service.d.ts +23 -0
- package/lib/infrastructure/services/portal-service.js +186 -0
- package/lib/infrastructure/services/portal-service.js.map +1 -0
- package/lib/infrastructure/services/telemetry-service.d.ts +8 -0
- package/lib/infrastructure/services/telemetry-service.js +40 -0
- package/lib/infrastructure/services/telemetry-service.js.map +1 -0
- package/lib/infrastructure/tmp-extensions.d.ts +2 -0
- package/lib/infrastructure/tmp-extensions.js +6 -0
- package/lib/infrastructure/tmp-extensions.js.map +1 -0
- package/lib/infrastructure/zip-service.d.ts +6 -0
- package/lib/infrastructure/zip-service.js +39 -0
- package/lib/infrastructure/zip-service.js.map +1 -0
- package/lib/prompts/auth/login.d.ts +5 -0
- package/lib/prompts/auth/login.js +13 -0
- package/lib/prompts/auth/login.js.map +1 -0
- package/lib/prompts/portal/common/base-prompts.d.ts +7 -0
- package/lib/prompts/portal/common/base-prompts.js +19 -0
- package/lib/prompts/portal/common/base-prompts.js.map +1 -0
- package/lib/prompts/portal/copilot.d.ts +14 -0
- package/lib/prompts/portal/copilot.js +71 -0
- package/lib/prompts/portal/copilot.js.map +1 -0
- package/lib/prompts/portal/generate.d.ts +11 -0
- package/lib/prompts/portal/generate.js +42 -0
- package/lib/prompts/portal/generate.js.map +1 -0
- package/lib/prompts/portal/quickstart.d.ts +30 -0
- package/lib/prompts/portal/quickstart.js +240 -0
- package/lib/prompts/portal/quickstart.js.map +1 -0
- package/lib/prompts/portal/recipe/new-recipe.d.ts +24 -0
- package/lib/prompts/portal/recipe/new-recipe.js +203 -0
- package/lib/prompts/portal/recipe/new-recipe.js.map +1 -0
- package/lib/prompts/portal/serve.d.ts +4 -0
- package/lib/prompts/portal/serve.js +14 -0
- package/lib/prompts/portal/serve.js.map +1 -0
- package/lib/prompts/portal/toc/new-toc.d.ts +11 -0
- package/lib/prompts/portal/toc/new-toc.js +39 -0
- package/lib/prompts/portal/toc/new-toc.js.map +1 -0
- package/lib/prompts/sdk/generate.d.ts +11 -0
- package/lib/prompts/sdk/generate.js +42 -0
- package/lib/prompts/sdk/generate.js.map +1 -0
- package/lib/types/api/account.d.ts +10 -0
- package/lib/types/api/account.js +2 -0
- package/lib/types/api/account.js.map +1 -0
- package/lib/types/api/transform.d.ts +19 -4
- package/lib/types/api/transform.js +19 -4
- package/lib/types/api/transform.js.map +1 -0
- package/lib/types/api/validate.d.ts +3 -3
- package/lib/types/api/validate.js +2 -2
- package/lib/types/api/validate.js.map +1 -0
- package/lib/types/build/build.d.ts +14 -0
- package/lib/types/build/build.js +4 -0
- package/lib/types/build/build.js.map +1 -0
- package/lib/types/build-context.d.ts +13 -0
- package/lib/types/build-context.js +30 -0
- package/lib/types/build-context.js.map +1 -0
- package/lib/types/common/result.d.ts +17 -0
- package/lib/types/common/result.js +32 -0
- package/lib/types/common/result.js.map +1 -0
- package/lib/types/events/domain-event.d.ts +8 -0
- package/lib/types/events/domain-event.js +11 -0
- package/lib/types/events/domain-event.js.map +1 -0
- package/lib/types/events/quickstart-completed.d.ts +7 -0
- package/lib/types/events/quickstart-completed.js +10 -0
- package/lib/types/events/quickstart-completed.js.map +1 -0
- package/lib/types/events/quickstart-initiated.d.ts +7 -0
- package/lib/types/events/quickstart-initiated.js +10 -0
- package/lib/types/events/quickstart-initiated.js.map +1 -0
- package/lib/types/events/recipe-creation-failed.d.ts +5 -0
- package/lib/types/events/recipe-creation-failed.js +8 -0
- package/lib/types/events/recipe-creation-failed.js.map +1 -0
- package/lib/types/events/toc-creation-failed.d.ts +5 -0
- package/lib/types/events/toc-creation-failed.js +8 -0
- package/lib/types/events/toc-creation-failed.js.map +1 -0
- package/lib/types/file/directoryPath.d.ts +7 -0
- package/lib/types/file/directoryPath.js +16 -0
- package/lib/types/file/directoryPath.js.map +1 -0
- package/lib/types/file/fileName.d.ts +5 -0
- package/lib/types/file/fileName.js +9 -0
- package/lib/types/file/fileName.js.map +1 -0
- package/lib/types/file/filePath.d.ts +8 -0
- package/lib/types/file/filePath.js +11 -0
- package/lib/types/file/filePath.js.map +1 -0
- package/lib/types/flags-provider.d.ts +15 -0
- package/lib/types/flags-provider.js +34 -0
- package/lib/types/flags-provider.js.map +1 -0
- package/lib/types/portal/generate.d.ts +13 -9
- package/lib/types/portal/generate.js +3 -2
- package/lib/types/portal/generate.js.map +1 -0
- package/lib/types/portal/quickstart.d.ts +17 -0
- package/lib/types/portal/quickstart.js +2 -0
- package/lib/types/portal/quickstart.js.map +1 -0
- package/lib/types/portal/serve.d.ts +12 -0
- package/lib/types/portal/serve.js +2 -0
- package/lib/types/portal/serve.js.map +1 -0
- package/lib/types/portal-context.d.ts +11 -0
- package/lib/types/portal-context.js +28 -0
- package/lib/types/portal-context.js.map +1 -0
- package/lib/types/recipe/recipe.d.ts +37 -0
- package/lib/types/recipe/recipe.js +6 -0
- package/lib/types/recipe/recipe.js.map +1 -0
- package/lib/types/sdk/generate.d.ts +11 -10
- package/lib/types/sdk/generate.js +11 -12
- package/lib/types/sdk/generate.js.map +1 -0
- package/lib/types/sdk-context.d.ts +13 -0
- package/lib/types/sdk-context.js +28 -0
- package/lib/types/sdk-context.js.map +1 -0
- package/lib/types/sdl/sdl.d.ts +12 -0
- package/lib/types/sdl/sdl.js +2 -0
- package/lib/types/sdl/sdl.js.map +1 -0
- package/lib/types/spec-context.d.ts +7 -0
- package/lib/types/spec-context.js +12 -0
- package/lib/types/spec-context.js.map +1 -0
- package/lib/types/toc/toc.d.ts +31 -0
- package/lib/types/toc/toc.js +9 -0
- package/lib/types/toc/toc.js.map +1 -0
- package/lib/types/utils.d.ts +3 -3
- package/lib/types/utils.js +2 -2
- package/lib/types/utils.js.map +1 -0
- package/lib/utils/utils.d.ts +16 -7
- package/lib/utils/utils.js +142 -86
- package/lib/utils/utils.js.map +1 -0
- package/lib/validators/common/directoryValidator.d.ts +5 -0
- package/lib/validators/common/directoryValidator.js +22 -0
- package/lib/validators/common/directoryValidator.js.map +1 -0
- package/lib/validators/portal/serve-validator.d.ts +6 -0
- package/lib/validators/portal/serve-validator.js +15 -0
- package/lib/validators/portal/serve-validator.js.map +1 -0
- package/package.json +100 -43
- package/bin/run +0 -5
- package/lib/controllers/portal/generate.d.ts +0 -2
- package/lib/controllers/portal/generate.js +0 -49
- package/lib/controllers/sdk/generate.d.ts +0 -4
- package/lib/controllers/sdk/generate.js +0 -64
package/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
@apimatic/cli
|
|
2
2
|
=============
|
|
3
|
+
apimatic is in Alpha.
|
|
3
4
|
|
|
4
5
|
The official CLI for APIMatic.
|
|
5
6
|
|
|
@@ -8,18 +9,22 @@ The official CLI for APIMatic.
|
|
|
8
9
|
[](https://npmjs.org/package/@apimatic/cli)
|
|
9
10
|
[](https://github.com/apimatic/apimatic-cli/blob/master/package.json)
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
# Getting Started
|
|
13
|
+
|
|
14
|
+
To get started with APIMatic's CLI using a step by step wizard, run the following command:
|
|
15
|
+
|
|
16
|
+
```sh-session
|
|
17
|
+
$ apimatic portal:quickstart
|
|
18
|
+
```
|
|
19
|
+
|
|
15
20
|
# Usage
|
|
16
21
|
<!-- usage -->
|
|
17
22
|
```sh-session
|
|
18
|
-
$ npm install -g @apimatic/cli
|
|
23
|
+
$ npm install -g @apimatic/cli
|
|
19
24
|
$ apimatic COMMAND
|
|
20
25
|
running command...
|
|
21
|
-
$ apimatic (
|
|
22
|
-
@apimatic/cli/
|
|
26
|
+
$ apimatic (--version)
|
|
27
|
+
@apimatic/cli/1.1.0-alpha.21 win32-x64 node-v23.4.0
|
|
23
28
|
$ apimatic --help [COMMAND]
|
|
24
29
|
USAGE
|
|
25
30
|
$ apimatic COMMAND
|
|
@@ -36,7 +41,12 @@ USAGE
|
|
|
36
41
|
* [`apimatic auth:status`](#apimatic-authstatus)
|
|
37
42
|
* [`apimatic autocomplete [SHELL]`](#apimatic-autocomplete-shell)
|
|
38
43
|
* [`apimatic help [COMMAND]`](#apimatic-help-command)
|
|
44
|
+
* [`apimatic portal:copilot`](#apimatic-portalcopilot)
|
|
39
45
|
* [`apimatic portal:generate`](#apimatic-portalgenerate)
|
|
46
|
+
* [`apimatic portal:quickstart`](#apimatic-portalquickstart)
|
|
47
|
+
* [`apimatic portal:recipe:new`](#apimatic-portalrecipenew)
|
|
48
|
+
* [`apimatic portal:serve`](#apimatic-portalserve)
|
|
49
|
+
* [`apimatic portal:toc:new`](#apimatic-portaltocnew)
|
|
40
50
|
* [`apimatic sdk:generate`](#apimatic-sdkgenerate)
|
|
41
51
|
|
|
42
52
|
## `apimatic api:transform`
|
|
@@ -45,33 +55,31 @@ Transform API specifications from one format to another. Supports [10+ different
|
|
|
45
55
|
|
|
46
56
|
```
|
|
47
57
|
USAGE
|
|
48
|
-
$ apimatic api:transform
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
--file=file path to the API specification file to transform
|
|
58
|
-
|
|
59
|
-
--format=format (required) specification format to transform API specification into
|
|
58
|
+
$ apimatic api:transform --format <value> [--file <value>] [--url <value>] [-d <value>] [-f] [-k <value>]
|
|
59
|
+
|
|
60
|
+
FLAGS
|
|
61
|
+
-d, --destination=<value> [default: ./] directory to download transformed file to
|
|
62
|
+
-f, --force overwrite changes without asking for user consent.
|
|
63
|
+
-k, --auth-key=<value> override current authentication state with an authentication key.
|
|
64
|
+
--file=<value> path to the API specification file to transform
|
|
65
|
+
--format=<value> (required) specification format to transform API specification into
|
|
60
66
|
APIMATIC|WADL2009|WSDL|SWAGGER10|SWAGGER20|SWAGGERYAML|OAS3|OPENAPI3YAML|APIBLUEPRINT|RAML|
|
|
61
67
|
RAML10|POSTMAN10|POSTMAN20|GRAPHQLSCHEMA
|
|
62
|
-
|
|
63
|
-
--url=url URL to the API specification file to transform. Can be used in place of the --file option
|
|
68
|
+
--url=<value> URL to the API specification file to transform. Can be used in place of the --file option
|
|
64
69
|
if the API specification is publicly available.
|
|
65
70
|
|
|
71
|
+
DESCRIPTION
|
|
72
|
+
Transform API specifications from one format to another. Supports [10+ different
|
|
73
|
+
formats](https://www.apimatic.io/transformer/#supported-formats) including OpenApi/Swagger, RAML, WSDL and Postman
|
|
74
|
+
Collections.
|
|
75
|
+
|
|
66
76
|
EXAMPLES
|
|
67
|
-
$ apimatic api:transform --format=
|
|
68
|
-
Success! Your transformed file is located at D:/Transformed_OpenApi3Json.json
|
|
77
|
+
$ apimatic api:transform --format=OPENAPI3YAML --file="./specs/sample.json" --destination="D:/"
|
|
69
78
|
|
|
70
79
|
$ apimatic api:transform --format=RAML --url="https://petstore.swagger.io/v2/swagger.json" --destination="D:/"
|
|
71
|
-
Success! Your transformed file is located at D:/swagger_raml.yaml
|
|
72
80
|
```
|
|
73
81
|
|
|
74
|
-
_See code: [src/commands/api/transform.ts](https://github.com/apimatic/apimatic-cli/blob/
|
|
82
|
+
_See code: [src/commands/api/transform.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/api/transform.ts)_
|
|
75
83
|
|
|
76
84
|
## `apimatic api:validate`
|
|
77
85
|
|
|
@@ -79,24 +87,24 @@ Validate the syntactic and semantic correctness of an API specification
|
|
|
79
87
|
|
|
80
88
|
```
|
|
81
89
|
USAGE
|
|
82
|
-
$ apimatic api:validate
|
|
90
|
+
$ apimatic api:validate [--file <value>] [--url <value>] [-k <value>]
|
|
83
91
|
|
|
84
|
-
|
|
85
|
-
--auth-key
|
|
86
|
-
|
|
92
|
+
FLAGS
|
|
93
|
+
-k, --auth-key=<value> override current authentication state with an authentication key.
|
|
94
|
+
--file=<value> Path to the API specification file to validate
|
|
95
|
+
--url=<value> URL to the specification file to validate. Can be used in place of the --file option if the
|
|
96
|
+
API specification is publicly available.
|
|
87
97
|
|
|
88
|
-
|
|
89
|
-
|
|
98
|
+
DESCRIPTION
|
|
99
|
+
Validate the syntactic and semantic correctness of an API specification
|
|
90
100
|
|
|
91
101
|
EXAMPLES
|
|
92
102
|
$ apimatic api:validate --file="./specs/sample.json"
|
|
93
|
-
Specification file provided is valid
|
|
94
103
|
|
|
95
104
|
$ apimatic api:validate --url=https://petstore.swagger.io/v2/swagger.json
|
|
96
|
-
Specification file provided is valid
|
|
97
105
|
```
|
|
98
106
|
|
|
99
|
-
_See code: [src/commands/api/validate.ts](https://github.com/apimatic/apimatic-cli/blob/
|
|
107
|
+
_See code: [src/commands/api/validate.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/api/validate.ts)_
|
|
100
108
|
|
|
101
109
|
## `apimatic auth:login`
|
|
102
110
|
|
|
@@ -104,155 +112,303 @@ Login using your APIMatic credentials or an API Key
|
|
|
104
112
|
|
|
105
113
|
```
|
|
106
114
|
USAGE
|
|
107
|
-
$ apimatic auth:login
|
|
115
|
+
$ apimatic auth:login [-k <value>]
|
|
108
116
|
|
|
109
|
-
|
|
110
|
-
--auth-key
|
|
117
|
+
FLAGS
|
|
118
|
+
-k, --auth-key=<value> Sets authentication key for all commands.
|
|
119
|
+
|
|
120
|
+
DESCRIPTION
|
|
121
|
+
Login using your APIMatic credentials or an API Key
|
|
111
122
|
|
|
112
123
|
EXAMPLES
|
|
113
124
|
$ apimatic auth:login
|
|
114
|
-
Please enter your registered email: apimatic-user@gmail.com
|
|
115
|
-
Please enter your password: *********
|
|
116
|
-
|
|
117
|
-
You have successfully logged into APIMatic
|
|
118
125
|
|
|
119
|
-
$ apimatic auth:login --auth-key=
|
|
120
|
-
Authentication key successfully set
|
|
126
|
+
$ apimatic auth:login --auth-key={api-key}
|
|
121
127
|
```
|
|
122
128
|
|
|
123
|
-
_See code: [src/commands/auth/login.ts](https://github.com/apimatic/apimatic-cli/blob/
|
|
129
|
+
_See code: [src/commands/auth/login.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/auth/login.ts)_
|
|
124
130
|
|
|
125
131
|
## `apimatic auth:logout`
|
|
126
132
|
|
|
127
|
-
|
|
133
|
+
Clears the local login credentials.
|
|
128
134
|
|
|
129
135
|
```
|
|
130
136
|
USAGE
|
|
131
137
|
$ apimatic auth:logout
|
|
132
138
|
|
|
133
|
-
|
|
139
|
+
DESCRIPTION
|
|
140
|
+
Clears the local login credentials.
|
|
141
|
+
|
|
142
|
+
EXAMPLES
|
|
134
143
|
$ apimatic auth:logout
|
|
135
|
-
Logged out
|
|
136
144
|
```
|
|
137
145
|
|
|
138
|
-
_See code: [src/commands/auth/logout.ts](https://github.com/apimatic/apimatic-cli/blob/
|
|
146
|
+
_See code: [src/commands/auth/logout.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/auth/logout.ts)_
|
|
139
147
|
|
|
140
148
|
## `apimatic auth:status`
|
|
141
149
|
|
|
142
|
-
View
|
|
150
|
+
View the currently logged in user.
|
|
143
151
|
|
|
144
152
|
```
|
|
145
153
|
USAGE
|
|
146
154
|
$ apimatic auth:status
|
|
147
155
|
|
|
148
|
-
|
|
156
|
+
DESCRIPTION
|
|
157
|
+
View the currently logged in user.
|
|
158
|
+
|
|
159
|
+
EXAMPLES
|
|
149
160
|
$ apimatic auth:status
|
|
150
|
-
Currently logged in as apimatic-client@gmail.com
|
|
151
161
|
```
|
|
152
162
|
|
|
153
|
-
_See code: [src/commands/auth/status.ts](https://github.com/apimatic/apimatic-cli/blob/
|
|
163
|
+
_See code: [src/commands/auth/status.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/auth/status.ts)_
|
|
154
164
|
|
|
155
165
|
## `apimatic autocomplete [SHELL]`
|
|
156
166
|
|
|
157
|
-
|
|
167
|
+
Display autocomplete installation instructions.
|
|
158
168
|
|
|
159
169
|
```
|
|
160
170
|
USAGE
|
|
161
|
-
$ apimatic autocomplete [SHELL]
|
|
171
|
+
$ apimatic autocomplete [SHELL] [-r]
|
|
162
172
|
|
|
163
173
|
ARGUMENTS
|
|
164
|
-
SHELL
|
|
174
|
+
SHELL (zsh|bash|powershell) Shell type
|
|
165
175
|
|
|
166
|
-
|
|
176
|
+
FLAGS
|
|
167
177
|
-r, --refresh-cache Refresh cache (ignores displaying instructions)
|
|
168
178
|
|
|
179
|
+
DESCRIPTION
|
|
180
|
+
Display autocomplete installation instructions.
|
|
181
|
+
|
|
169
182
|
EXAMPLES
|
|
170
183
|
$ apimatic autocomplete
|
|
184
|
+
|
|
171
185
|
$ apimatic autocomplete bash
|
|
186
|
+
|
|
172
187
|
$ apimatic autocomplete zsh
|
|
188
|
+
|
|
189
|
+
$ apimatic autocomplete powershell
|
|
190
|
+
|
|
173
191
|
$ apimatic autocomplete --refresh-cache
|
|
174
192
|
```
|
|
175
193
|
|
|
176
|
-
_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/
|
|
194
|
+
_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/main/src/commands/autocomplete/index.ts)_
|
|
177
195
|
|
|
178
196
|
## `apimatic help [COMMAND]`
|
|
179
197
|
|
|
180
|
-
|
|
198
|
+
Display help for apimatic.
|
|
181
199
|
|
|
182
200
|
```
|
|
183
201
|
USAGE
|
|
184
|
-
$ apimatic help [COMMAND]
|
|
202
|
+
$ apimatic help [COMMAND...] [-n]
|
|
185
203
|
|
|
186
204
|
ARGUMENTS
|
|
187
|
-
COMMAND
|
|
205
|
+
COMMAND... Command to show help for.
|
|
188
206
|
|
|
189
|
-
|
|
190
|
-
--
|
|
207
|
+
FLAGS
|
|
208
|
+
-n, --nested-commands Include all nested commands in the output.
|
|
209
|
+
|
|
210
|
+
DESCRIPTION
|
|
211
|
+
Display help for apimatic.
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/main/src/commands/help.ts)_
|
|
215
|
+
|
|
216
|
+
## `apimatic portal:copilot`
|
|
217
|
+
|
|
218
|
+
Configure API Copilot for your API Documentation portal
|
|
219
|
+
|
|
220
|
+
```
|
|
221
|
+
USAGE
|
|
222
|
+
$ apimatic portal:copilot [-i <value>] [--disable] [-f] [-k <value>]
|
|
223
|
+
|
|
224
|
+
FLAGS
|
|
225
|
+
-f, --force overwrite changes without asking for user consent.
|
|
226
|
+
-i, --input=<value> [default: ./] path to the parent directory containing the 'src' directory, which includes API
|
|
227
|
+
specifications and configuration files.
|
|
228
|
+
-k, --auth-key=<value> override current authentication state with an authentication key.
|
|
229
|
+
--disable marks the API Copilot as disabled in the configuration
|
|
230
|
+
|
|
231
|
+
DESCRIPTION
|
|
232
|
+
Configure API Copilot for your API Documentation portal
|
|
233
|
+
|
|
234
|
+
Displays available API Copilots associated with your account and allows you to select which one to integrate with your
|
|
235
|
+
portal. Each APIMatic account includes one Copilot by default. The selected Copilot will be added to your
|
|
236
|
+
APIMATIC-BUILD.json file
|
|
237
|
+
|
|
238
|
+
EXAMPLES
|
|
239
|
+
$ apimatic portal:copilot --input="./"
|
|
240
|
+
|
|
241
|
+
$ apimatic portal:copilot --input="./" --disable
|
|
191
242
|
```
|
|
192
243
|
|
|
193
|
-
_See code: [
|
|
244
|
+
_See code: [src/commands/portal/copilot.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/copilot.ts)_
|
|
194
245
|
|
|
195
246
|
## `apimatic portal:generate`
|
|
196
247
|
|
|
197
|
-
Generate
|
|
248
|
+
Generate an API Documentation portal. Requires an input directory containing API specifications, a config file and optionally, markdown guides. For details, refer to the [documentation](https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/build-file-reference)
|
|
198
249
|
|
|
199
250
|
```
|
|
200
251
|
USAGE
|
|
252
|
+
$ apimatic portal:generate [-i <value>] [-d <value>] [-f] [--zip] [-k <value>]
|
|
253
|
+
|
|
254
|
+
FLAGS
|
|
255
|
+
-d, --destination=<value> [default: <input>/portal] path where the portal will be generated.
|
|
256
|
+
-f, --force overwrite changes without asking for user consent.
|
|
257
|
+
-i, --input=<value> [default: ./] path to the parent directory containing the 'src' directory, which includes
|
|
258
|
+
API specifications and configuration files.
|
|
259
|
+
-k, --auth-key=<value> override current authentication state with an authentication key.
|
|
260
|
+
--zip download the generated portal as a .zip archive
|
|
261
|
+
|
|
262
|
+
DESCRIPTION
|
|
263
|
+
Generate an API Documentation portal. Requires an input directory containing API specifications, a config file and
|
|
264
|
+
optionally, markdown guides. For details, refer to the [documentation](https://docs.apimatic.io/platform-api/#/http/gu
|
|
265
|
+
ides/generating-on-prem-api-portal/build-file-reference)
|
|
266
|
+
|
|
267
|
+
EXAMPLES
|
|
201
268
|
$ apimatic portal:generate
|
|
202
269
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
270
|
+
$ apimatic portal:generate --input="./" --destination="./portal"
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
_See code: [src/commands/portal/generate.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/generate.ts)_
|
|
274
|
+
|
|
275
|
+
## `apimatic portal:quickstart`
|
|
276
|
+
|
|
277
|
+
Create your first API Portal using APIMatic's Docs as Code offering.
|
|
209
278
|
|
|
210
|
-
EXAMPLE
|
|
211
|
-
$ apimatic portal:generate --folder="./portal/" --destination="D:/"
|
|
212
|
-
Your portal has been generated at D:/
|
|
213
279
|
```
|
|
280
|
+
USAGE
|
|
281
|
+
$ apimatic portal:quickstart
|
|
214
282
|
|
|
215
|
-
|
|
283
|
+
DESCRIPTION
|
|
284
|
+
Create your first API Portal using APIMatic's Docs as Code offering.
|
|
216
285
|
|
|
217
|
-
|
|
286
|
+
EXAMPLES
|
|
287
|
+
$ apimatic portal:quickstart
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
_See code: [src/commands/portal/quickstart.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/quickstart.ts)_
|
|
291
|
+
|
|
292
|
+
## `apimatic portal:recipe:new`
|
|
218
293
|
|
|
219
|
-
|
|
294
|
+
Add an API Recipe to your API Documentation portal.
|
|
220
295
|
|
|
221
296
|
```
|
|
222
297
|
USAGE
|
|
223
|
-
$ apimatic
|
|
298
|
+
$ apimatic portal:recipe:new [--name <value>] [-i <value>]
|
|
224
299
|
|
|
225
|
-
|
|
226
|
-
-
|
|
227
|
-
|
|
300
|
+
FLAGS
|
|
301
|
+
-i, --input=<value> [default: ./] path to the parent directory containing the 'src' directory, which includes API
|
|
302
|
+
specifications and configuration files.
|
|
303
|
+
--name=<value> name for the recipe
|
|
228
304
|
|
|
229
|
-
|
|
230
|
-
|
|
305
|
+
DESCRIPTION
|
|
306
|
+
Add an API Recipe to your API Documentation portal.
|
|
231
307
|
|
|
232
|
-
|
|
308
|
+
To learn more about API Recipes, visit:
|
|
309
|
+
https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/api-recipes
|
|
233
310
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
311
|
+
EXAMPLES
|
|
312
|
+
$ apimatic portal:recipe:new
|
|
313
|
+
|
|
314
|
+
$ apimatic portal:recipe:new --name="My API Recipe" --input="./"
|
|
315
|
+
```
|
|
239
316
|
|
|
240
|
-
|
|
241
|
-
option if the API specification is publicly available.
|
|
317
|
+
_See code: [src/commands/portal/recipe/new.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/recipe/new.ts)_
|
|
242
318
|
|
|
243
|
-
|
|
319
|
+
## `apimatic portal:serve`
|
|
320
|
+
|
|
321
|
+
Generate and deploy a Docs as Code portal with hot reload.
|
|
322
|
+
|
|
323
|
+
```
|
|
324
|
+
USAGE
|
|
325
|
+
$ apimatic portal:serve [-p <value>] [-i <value>] [-d <value>] [-o] [--no-reload] [-k <value>]
|
|
326
|
+
|
|
327
|
+
FLAGS
|
|
328
|
+
-d, --destination=<value> [default: <input>/portal] path where the portal will be generated.
|
|
329
|
+
-i, --input=<value> [default: ./] path to the parent directory containing the 'src' directory, which includes
|
|
330
|
+
API specifications and configuration files.
|
|
331
|
+
-k, --auth-key=<value> override current authentication state with an authentication key.
|
|
332
|
+
-o, --open Open the portal in the default browser.
|
|
333
|
+
-p, --port=<value> [default: 3000] port to serve the portal.
|
|
334
|
+
--no-reload Disable hot reload.
|
|
335
|
+
|
|
336
|
+
DESCRIPTION
|
|
337
|
+
Generate and deploy a Docs as Code portal with hot reload.
|
|
244
338
|
|
|
245
339
|
EXAMPLES
|
|
246
|
-
$ apimatic
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
340
|
+
$ apimatic portal:serve
|
|
341
|
+
|
|
342
|
+
$ apimatic portal:serve --input="./" --destination="./portal" --port=3000 --open --no-reload
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
_See code: [src/commands/portal/serve.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/serve.ts)_
|
|
346
|
+
|
|
347
|
+
## `apimatic portal:toc:new`
|
|
348
|
+
|
|
349
|
+
Generate a Table of Contents (TOC) file for your API documentation portal
|
|
350
|
+
|
|
351
|
+
```
|
|
352
|
+
USAGE
|
|
353
|
+
$ apimatic portal:toc:new [-d <value>] [-i <value>] [-f] [--expand-endpoints] [--expand-models]
|
|
354
|
+
|
|
355
|
+
FLAGS
|
|
356
|
+
-d, --destination=<value> [default: <input>/src/content] path where the 'toc.yml' will be generated.
|
|
357
|
+
-f, --force overwrite changes without asking for user consent.
|
|
358
|
+
-i, --input=<value> [default: ./] path to the parent directory containing the 'src' directory, which includes
|
|
359
|
+
API specifications and configuration files.
|
|
360
|
+
--expand-endpoints include individual entries for each endpoint in the generated 'toc.yml'. Requires a valid
|
|
361
|
+
API specification in the working directory.
|
|
362
|
+
--expand-models include individual entries for each model in the generated 'toc.yml'. Requires a valid API
|
|
363
|
+
specification in the working directory.
|
|
364
|
+
|
|
365
|
+
DESCRIPTION
|
|
366
|
+
Generate a Table of Contents (TOC) file for your API documentation portal
|
|
367
|
+
|
|
368
|
+
This command generates a new Table of Contents (TOC) file used in the
|
|
369
|
+
generation of your API documentation portal.
|
|
370
|
+
|
|
371
|
+
The output is a YAML file with the .yml extension.
|
|
372
|
+
|
|
373
|
+
To learn more about the TOC file and APIMatic build directory structure, visit:
|
|
374
|
+
https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/overview-generating-api-portal
|
|
375
|
+
|
|
376
|
+
EXAMPLES
|
|
377
|
+
$ apimatic portal:toc:new --destination="./src/content/"
|
|
378
|
+
|
|
379
|
+
$ apimatic portal:toc:new --input="./"
|
|
380
|
+
|
|
381
|
+
$ apimatic portal:toc:new --input="./" --destination="./src/content/"
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
_See code: [src/commands/portal/toc/new.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/toc/new.ts)_
|
|
385
|
+
|
|
386
|
+
## `apimatic sdk:generate`
|
|
387
|
+
|
|
388
|
+
Generate an SDK for your API
|
|
389
|
+
|
|
390
|
+
```
|
|
391
|
+
USAGE
|
|
392
|
+
$ apimatic sdk:generate --platform csharp|java|php|python|ruby|typescript|go [--spec <value>] [-d <value>] [-f]
|
|
393
|
+
[--zip] [-k <value>]
|
|
394
|
+
|
|
395
|
+
FLAGS
|
|
396
|
+
-d, --destination=<value> [default: ./sdk/<platform>] path where the sdk will be generated.
|
|
397
|
+
-f, --force overwrite changes without asking for user consent.
|
|
398
|
+
-k, --auth-key=<value> override current authentication state with an authentication key.
|
|
399
|
+
--platform=<option> (required) language platform for sdk
|
|
400
|
+
<options: csharp|java|php|python|ruby|typescript|go>
|
|
401
|
+
--spec=<value> [default: ./src/spec] path to the folder containing the API specification file.
|
|
402
|
+
--zip download the generated SDK as a .zip archive
|
|
403
|
+
|
|
404
|
+
DESCRIPTION
|
|
405
|
+
Generate an SDK for your API
|
|
406
|
+
|
|
407
|
+
EXAMPLES
|
|
408
|
+
$ apimatic sdk:generate --platform=java
|
|
409
|
+
|
|
410
|
+
$ apimatic sdk:generate --platform=csharp --spec="./src/spec"
|
|
255
411
|
```
|
|
256
412
|
|
|
257
|
-
_See code: [src/commands/sdk/generate.ts](https://github.com/apimatic/apimatic-cli/blob/
|
|
413
|
+
_See code: [src/commands/sdk/generate.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/sdk/generate.ts)_
|
|
258
414
|
<!-- commandsstop -->
|
package/bin/run.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class ActionResult {
|
|
2
|
+
private readonly message;
|
|
3
|
+
private constructor();
|
|
4
|
+
static error(message: string): ActionResult;
|
|
5
|
+
static success(): ActionResult;
|
|
6
|
+
map(onError: (message: string) => void): void;
|
|
7
|
+
mapAll<T>(onSuccess: () => T, onError: (message: string) => T): T;
|
|
8
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export class ActionResult {
|
|
2
|
+
constructor(message) {
|
|
3
|
+
this.message = message;
|
|
4
|
+
}
|
|
5
|
+
static error(message) {
|
|
6
|
+
return new ActionResult(message);
|
|
7
|
+
}
|
|
8
|
+
static success() {
|
|
9
|
+
return new ActionResult();
|
|
10
|
+
}
|
|
11
|
+
map(onError) {
|
|
12
|
+
if (this.message) {
|
|
13
|
+
onError(this.message);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
mapAll(onSuccess, onError) {
|
|
17
|
+
if (this.message) {
|
|
18
|
+
return onError(this.message);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
return onSuccess();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=action-result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-result.js","sourceRoot":"","sources":["../../src/actions/action-result.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,YAAY;IAGvB,YAAoB,OAAgB;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAe;QAC1B,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,MAAM,CAAC,OAAO;QACZ,OAAO,IAAI,YAAY,EAAE,CAAC;IAC5B,CAAC;IAED,GAAG,CAAC,OAAkC;QACpC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IAED,MAAM,CAAI,SAAiB,EAAE,OAA+B;QAC1D,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;aAAK,CAAC;YACL,OAAO,SAAS,EAAE,CAAC;QACrB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
2
|
+
import { Result } from "neverthrow";
|
|
3
|
+
export declare class LoginAction {
|
|
4
|
+
private readonly configDir;
|
|
5
|
+
private readonly authService;
|
|
6
|
+
private readonly apiService;
|
|
7
|
+
private readonly prompts;
|
|
8
|
+
constructor(configDir: DirectoryPath);
|
|
9
|
+
execute(apiKey?: string | undefined): Promise<Result<string, string>>;
|
|
10
|
+
private poolDeviceToken;
|
|
11
|
+
private verifyKeyAndSave;
|
|
12
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { AuthService } from "../../infrastructure/services/auth-service.js";
|
|
2
|
+
import { ApiService } from "../../infrastructure/services/api-service.js";
|
|
3
|
+
import { err, ok } from "neverthrow";
|
|
4
|
+
import { v4 as uuid } from "uuid";
|
|
5
|
+
import open from "open";
|
|
6
|
+
import { setAuthInfo } from "../../client-utils/auth-manager.js";
|
|
7
|
+
import { LoginPrompts } from "../../prompts/auth/login.js";
|
|
8
|
+
import { getErrorMessage } from "../../infrastructure/api-utils.js";
|
|
9
|
+
export class LoginAction {
|
|
10
|
+
constructor(configDir) {
|
|
11
|
+
this.configDir = configDir;
|
|
12
|
+
this.authService = new AuthService();
|
|
13
|
+
this.apiService = new ApiService();
|
|
14
|
+
this.prompts = new LoginPrompts();
|
|
15
|
+
}
|
|
16
|
+
async execute(apiKey = undefined) {
|
|
17
|
+
if (!apiKey) {
|
|
18
|
+
const result = await this.poolDeviceToken();
|
|
19
|
+
return (await result.asyncMap(async (token) => {
|
|
20
|
+
return await this.verifyKeyAndSave(token);
|
|
21
|
+
})).andThen((r) => r);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return await this.verifyKeyAndSave(apiKey);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async poolDeviceToken() {
|
|
28
|
+
const state = uuid();
|
|
29
|
+
this.prompts.openBrowser();
|
|
30
|
+
await open(this.authService.getDeviceLoginUrl(state));
|
|
31
|
+
const timeoutDuration = 5 * 60 * 1000; // 5 minutes in milliseconds
|
|
32
|
+
const startTime = Date.now();
|
|
33
|
+
const delayMs = 3 * 1000;
|
|
34
|
+
while (true) {
|
|
35
|
+
if (Date.now() - startTime > timeoutDuration) {
|
|
36
|
+
return err("Authentication timed out. Please try again.");
|
|
37
|
+
}
|
|
38
|
+
const result = await this.authService.getDeviceLoginToken(state);
|
|
39
|
+
const token = result.match((res) => res.apiKey, () => {
|
|
40
|
+
/* ignore errors */
|
|
41
|
+
});
|
|
42
|
+
if (token)
|
|
43
|
+
return ok(token);
|
|
44
|
+
// eslint-disable-next-line no-undef
|
|
45
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async verifyKeyAndSave(apiKey) {
|
|
49
|
+
const result = await this.apiService.getAccountInfo(this.configDir, apiKey);
|
|
50
|
+
return result.asyncMap(async (info) => {
|
|
51
|
+
await setAuthInfo(info.Email, apiKey, false, this.configDir);
|
|
52
|
+
return info.Email;
|
|
53
|
+
}).mapErr(e => {
|
|
54
|
+
switch (e) {
|
|
55
|
+
case "UNAUTHORIZED" /* ServiceError.UnAuthorized */:
|
|
56
|
+
return "The provided auth key is invalid";
|
|
57
|
+
default:
|
|
58
|
+
return getErrorMessage(e);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/actions/auth/login.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
2
|
+
import { ActionResult } from "../action-result.js";
|
|
3
|
+
export declare class CopilotAction {
|
|
4
|
+
private readonly apiService;
|
|
5
|
+
private readonly fileService;
|
|
6
|
+
private readonly launcherService;
|
|
7
|
+
private readonly prompts;
|
|
8
|
+
private readonly configDir;
|
|
9
|
+
private readonly authKey;
|
|
10
|
+
constructor(configDir: DirectoryPath, authKey?: string | null);
|
|
11
|
+
execute(buildDirectory: DirectoryPath, force: boolean, enable: boolean): Promise<ActionResult>;
|
|
12
|
+
private selectCopilotKey;
|
|
13
|
+
private getWelcomeMessage;
|
|
14
|
+
}
|