@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
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const env_1 = require("../config/env");
|
|
8
|
-
const auth_manager_1 = require("./auth-manager");
|
|
9
|
-
class SDKClient {
|
|
10
|
-
constructor() {
|
|
11
|
-
this.setAuthKey = (authKey, configDir) => {
|
|
12
|
-
auth_manager_1.setAuthInfo({
|
|
13
|
-
email: "",
|
|
14
|
-
authKey
|
|
15
|
-
}, configDir);
|
|
16
|
-
return "Authentication key successfully set";
|
|
17
|
-
};
|
|
18
|
-
}
|
|
1
|
+
import { getAuthInfo, removeAuthInfo } from "./auth-manager.js";
|
|
2
|
+
/**
|
|
3
|
+
* The Singleton class defines the `getInstance` method that lets clients access
|
|
4
|
+
* the unique singleton instance.
|
|
5
|
+
*/
|
|
6
|
+
export class SDKClient {
|
|
19
7
|
/**
|
|
20
8
|
* The static method that controls the access to the SDKClient instance.
|
|
21
9
|
*
|
|
@@ -28,46 +16,13 @@ class SDKClient {
|
|
|
28
16
|
}
|
|
29
17
|
return SDKClient.instance;
|
|
30
18
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Finally, any SDKClient should define some business logic, which can be
|
|
33
|
-
* executed on its instance.
|
|
34
|
-
*/
|
|
35
|
-
async login(email, password, configDir) {
|
|
36
|
-
let storedAuthInfo = await auth_manager_1.getAuthInfo(configDir);
|
|
37
|
-
// If no config file or no credentials exist in the config file
|
|
38
|
-
if (!storedAuthInfo) {
|
|
39
|
-
storedAuthInfo = { email: "", authKey: "" };
|
|
40
|
-
}
|
|
41
|
-
const credentials = { email, password };
|
|
42
|
-
const authKey = await this.getAuthKey(credentials);
|
|
43
|
-
if (storedAuthInfo.email !== email) {
|
|
44
|
-
auth_manager_1.setAuthInfo({
|
|
45
|
-
email,
|
|
46
|
-
authKey
|
|
47
|
-
}, configDir);
|
|
48
|
-
return "Logged in";
|
|
49
|
-
}
|
|
50
|
-
else if (authKey === storedAuthInfo.authKey) {
|
|
51
|
-
return "Already logged in";
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
auth_manager_1.setAuthInfo({
|
|
55
|
-
email,
|
|
56
|
-
authKey
|
|
57
|
-
}, configDir);
|
|
58
|
-
return "Logged in";
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
19
|
async logout(configDir) {
|
|
62
|
-
|
|
63
|
-
email: "",
|
|
64
|
-
authKey: ""
|
|
65
|
-
}, configDir);
|
|
20
|
+
await removeAuthInfo(configDir);
|
|
66
21
|
return "Logged out";
|
|
67
22
|
}
|
|
68
23
|
async status(configDir) {
|
|
69
24
|
try {
|
|
70
|
-
let storedAuthInfo = await
|
|
25
|
+
let storedAuthInfo = await getAuthInfo(configDir);
|
|
71
26
|
if (!storedAuthInfo) {
|
|
72
27
|
// If no config file or no credentials exist in the config file
|
|
73
28
|
storedAuthInfo = { email: "", authKey: "" };
|
|
@@ -82,38 +37,5 @@ class SDKClient {
|
|
|
82
37
|
throw error;
|
|
83
38
|
}
|
|
84
39
|
}
|
|
85
|
-
async getClient(overrideAuthKey, configDir) {
|
|
86
|
-
if (overrideAuthKey) {
|
|
87
|
-
return new sdk_1.Client({
|
|
88
|
-
timeout: 0,
|
|
89
|
-
authorization: `X-Auth-Key ${overrideAuthKey}`
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
let storedAuthInfo = await auth_manager_1.getAuthInfo(configDir);
|
|
93
|
-
if (!storedAuthInfo) {
|
|
94
|
-
// If no config file or no credentials exist in the config file
|
|
95
|
-
storedAuthInfo = { email: "", authKey: "" };
|
|
96
|
-
}
|
|
97
|
-
if (storedAuthInfo.authKey !== "") {
|
|
98
|
-
return new sdk_1.Client({
|
|
99
|
-
timeout: 0,
|
|
100
|
-
authorization: `X-Auth-Key ${storedAuthInfo.authKey}`
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
throw new Error("Please login first or provide an authKey");
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
async getAuthKey(credentials) {
|
|
108
|
-
const config = {
|
|
109
|
-
headers: {
|
|
110
|
-
Authorization: `Basic ${base64.encode(`${credentials.email}:${credentials.password}`)}`
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
const response = await axios_1.default.get(SDKClient.authAPI, config);
|
|
114
|
-
const authKey = response.data.EncryptedValue;
|
|
115
|
-
return authKey;
|
|
116
|
-
}
|
|
117
40
|
}
|
|
118
|
-
|
|
119
|
-
SDKClient.authAPI = `${env_1.baseURL}/account/authkey`;
|
|
41
|
+
//# sourceMappingURL=sdk-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-client.js","sourceRoot":"","sources":["../../src/client-utils/sdk-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE1E;;;GAGG;AACH,MAAM,OAAO,SAAS;IAIpB;;;;;OAKG;IACI,MAAM,CAAC,WAAW;QACvB,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;YACxB,SAAS,CAAC,QAAQ,GAAG,IAAI,SAAS,EAAE,CAAC;QACvC,CAAC;QAED,OAAO,SAAS,CAAC,QAAQ,CAAC;IAC5B,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAiB;QACnC,MAAM,cAAc,CAAC,SAAS,CAAC,CAAC;QAChC,OAAO,YAAY,CAAC;IACtB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAiB;QACnC,IAAI,CAAC;YACH,IAAI,cAAc,GAAoB,MAAM,WAAW,CAAC,SAAS,CAAC,CAAC;YAEnE,IAAI,CAAC,cAAc,EAAE,CAAC;gBACpB,+DAA+D;gBAC/D,cAAc,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;YAC9C,CAAC;YAED,OAAO,cAAc,CAAC,KAAK,KAAK,EAAE,IAAI,cAAc,CAAC,OAAO,KAAK,EAAE;gBACjE,CAAC,CAAC,eAAe;gBACjB,CAAC,CAAC,cAAc,CAAC,KAAK,KAAK,EAAE,IAAI,cAAc,CAAC,OAAO,KAAK,EAAE;oBAC9D,CAAC,CAAC,mCAAmC;oBACrC,CAAC,CAAC,0BAA0B,cAAc,CAAC,KAAK,EAAE,CAAC;QACvD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,KAAc,CAAC;QACvB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
2
|
export default class Transform extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
6
|
+
"auth-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
file: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
url: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
destination: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
12
|
};
|
|
13
13
|
run(): Promise<void>;
|
|
14
14
|
}
|
|
@@ -1,44 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
var _a;
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import fsExtra from "fs-extra";
|
|
4
|
+
import { Flags, Command } from "@oclif/core";
|
|
5
|
+
import { TransformationController } from "@apimatic/sdk";
|
|
6
|
+
import { printValidationMessages } from "../../utils/utils.js";
|
|
7
|
+
import { getFileNameFromPath, replaceHTML } from "../../utils/utils.js";
|
|
8
|
+
import { DestinationFormats, TransformationFormats } from "../../types/api/transform.js";
|
|
9
|
+
import { getValidFormat, getTransformationId, downloadTransformationFile } from "../../controllers/api/transform.js";
|
|
10
|
+
import { FlagsProvider } from "../../types/flags-provider.js";
|
|
11
|
+
import { getAuthInfo } from "../../client-utils/auth-manager.js";
|
|
12
|
+
import { createApiClient, createAuthorizationHeader } from "../../infrastructure/api-client-utils.js";
|
|
13
|
+
const formats = Object.keys(TransformationFormats).join("|");
|
|
14
|
+
class Transform extends Command {
|
|
14
15
|
async run() {
|
|
15
|
-
const { flags } = this.parse(
|
|
16
|
-
const fileName = flags.file ?
|
|
17
|
-
const destinationFormat =
|
|
16
|
+
const { flags } = await this.parse(_a);
|
|
17
|
+
const fileName = flags.file ? getFileNameFromPath(flags.file) : getFileNameFromPath(flags.url);
|
|
18
|
+
const destinationFormat = DestinationFormats[flags.format];
|
|
18
19
|
const destinationFilePath = path.join(flags.destination, `${fileName}_${flags.format}.${destinationFormat}`.toLowerCase());
|
|
19
20
|
// Check if destination file already exist and throw error if force flag is not set
|
|
20
|
-
if (
|
|
21
|
+
if (fsExtra.existsSync(destinationFilePath) && !flags.force) {
|
|
21
22
|
throw new Error(`Can't download transformed file to path ${destinationFilePath}, because it already exists`);
|
|
22
23
|
}
|
|
23
24
|
try {
|
|
24
25
|
// Check if paths provided are valid
|
|
25
|
-
if (flags.file && !(await
|
|
26
|
+
if (flags.file && !(await fsExtra.pathExists(flags.file))) {
|
|
26
27
|
throw new Error(`Transformation file: ${flags.file} does not exist`);
|
|
27
28
|
}
|
|
28
|
-
else if (!(await
|
|
29
|
+
else if (!(await fsExtra.pathExists(flags.destination))) {
|
|
29
30
|
throw new Error(`Destination path: ${flags.destination} does not exist`);
|
|
30
31
|
}
|
|
31
32
|
const overrideAuthKey = flags["auth-key"] ? flags["auth-key"] : null;
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
33
|
+
const authInfo = await getAuthInfo(this.config.configDir);
|
|
34
|
+
const authorizationHeader = createAuthorizationHeader(authInfo, overrideAuthKey);
|
|
35
|
+
const client = createApiClient(authorizationHeader, 0);
|
|
36
|
+
const transformationController = new TransformationController(client);
|
|
37
|
+
const { id, apiValidationSummary } = await getTransformationId(flags, transformationController);
|
|
35
38
|
const logFunctions = {
|
|
36
|
-
log: this.log,
|
|
37
|
-
warn: this.warn,
|
|
38
|
-
error: this.error
|
|
39
|
+
log: (message) => this.log(message),
|
|
40
|
+
warn: (message) => this.warn(message),
|
|
41
|
+
error: (message) => this.error(message)
|
|
39
42
|
};
|
|
40
|
-
|
|
41
|
-
const savedTransformationFile = await
|
|
43
|
+
printValidationMessages(apiValidationSummary, logFunctions);
|
|
44
|
+
const savedTransformationFile = await downloadTransformationFile({
|
|
42
45
|
id,
|
|
43
46
|
destinationFilePath,
|
|
44
47
|
transformationController
|
|
@@ -52,7 +55,7 @@ class Transform extends command_1.Command {
|
|
|
52
55
|
// updated to throw the right exception type for this status code.
|
|
53
56
|
const result = apiError.result;
|
|
54
57
|
if (apiError.statusCode === 422 && result && "errors" in result && Array.isArray(result.errors)) {
|
|
55
|
-
this.error(
|
|
58
|
+
this.error(replaceHTML(`${result.errors}`));
|
|
56
59
|
}
|
|
57
60
|
else if (apiError.statusCode === 422 && apiError.body && typeof apiError.body === "string") {
|
|
58
61
|
this.error(JSON.parse(apiError.body)["dto.FileUrl"][0]);
|
|
@@ -78,37 +81,29 @@ class Transform extends command_1.Command {
|
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
}
|
|
81
|
-
|
|
84
|
+
_a = Transform;
|
|
82
85
|
Transform.description = `Transform API specifications from one format to another. Supports [10+ different formats](https://www.apimatic.io/transformer/#supported-formats) including OpenApi/Swagger, RAML, WSDL and Postman Collections.`;
|
|
83
86
|
Transform.examples = [
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
`,
|
|
87
|
-
`$ apimatic api:transform --format=RAML --url="https://petstore.swagger.io/v2/swagger.json" --destination="D:/"
|
|
88
|
-
Success! Your transformed file is located at D:/swagger_raml.yaml
|
|
89
|
-
`
|
|
87
|
+
`apimatic api:transform --format=OPENAPI3YAML --file="./specs/sample.json" --destination="D:/"`,
|
|
88
|
+
`apimatic api:transform --format=RAML --url="https://petstore.swagger.io/v2/swagger.json" --destination="D:/"`
|
|
90
89
|
];
|
|
91
|
-
Transform.flags = {
|
|
92
|
-
|
|
93
|
-
parse: (format) => transform_2.getValidFormat(format.toUpperCase()),
|
|
90
|
+
Transform.flags = Object.assign(Object.assign({ format: Flags.string({
|
|
91
|
+
parse: async (format) => getValidFormat(format),
|
|
94
92
|
required: true,
|
|
95
93
|
description: `specification format to transform API specification into
|
|
96
94
|
${formats}`
|
|
97
|
-
}),
|
|
98
|
-
|
|
99
|
-
parse: (input) => path.resolve(input),
|
|
95
|
+
}), file: Flags.string({
|
|
96
|
+
parse: async (input) => path.resolve(input),
|
|
100
97
|
default: "",
|
|
101
98
|
description: "path to the API specification file to transform"
|
|
102
|
-
}),
|
|
103
|
-
url: command_1.flags.string({
|
|
99
|
+
}), url: Flags.string({
|
|
104
100
|
default: "",
|
|
105
101
|
description: "URL to the API specification file to transform. Can be used in place of the --file option if the API specification is publicly available."
|
|
106
|
-
}),
|
|
107
|
-
|
|
108
|
-
parse: (input) => path.resolve(input),
|
|
102
|
+
}), destination: Flags.string({
|
|
103
|
+
parse: async (input) => path.resolve(input),
|
|
109
104
|
default: path.resolve("./"),
|
|
110
|
-
description: "directory to download transformed file to"
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
105
|
+
description: "directory to download transformed file to",
|
|
106
|
+
char: "d"
|
|
107
|
+
}) }, FlagsProvider.force), FlagsProvider.authKey);
|
|
108
|
+
export default Transform;
|
|
109
|
+
//# sourceMappingURL=transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/commands/api/transform.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAoC,MAAM,eAAe,CAAC;AAE3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,WA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AAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QAC3B,WAAW,EAAE,2CAA2C;QACxD,IAAI,EAAE,GAAG;KACV,CAAC,IACC,aAAa,CAAC,KAAK,GACnB,aAAa,CAAC,OAAO,CAxBd,CAyBV;eAjCiB,SAAS"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
2
|
export default class Validate extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
6
|
+
"auth-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
file: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
url: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
};
|
|
10
10
|
run(): Promise<void>;
|
|
11
11
|
}
|
|
@@ -1,38 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class Validate extends
|
|
1
|
+
import fsExtra from "fs-extra";
|
|
2
|
+
import { ux, Flags, Command } from "@oclif/core";
|
|
3
|
+
import { ApiValidationExternalApisController } from "@apimatic/sdk";
|
|
4
|
+
import { getValidationSummary } from "../../controllers/api/validate.js";
|
|
5
|
+
import { printValidationMessages, replaceHTML } from "../../utils/utils.js";
|
|
6
|
+
import { FlagsProvider } from "../../types/flags-provider.js";
|
|
7
|
+
import { getAuthInfo } from "../../client-utils/auth-manager.js";
|
|
8
|
+
import { createApiClient, createAuthorizationHeader } from "../../infrastructure/api-client-utils.js";
|
|
9
|
+
class Validate extends Command {
|
|
10
10
|
async run() {
|
|
11
|
-
const { flags } = this.parse(Validate);
|
|
11
|
+
const { flags } = await this.parse(Validate);
|
|
12
12
|
try {
|
|
13
|
-
if (flags.file && !(await
|
|
13
|
+
if (flags.file && !(await fsExtra.pathExists(flags.file))) {
|
|
14
14
|
throw new Error(`Validation file: ${flags.file} does not exist`);
|
|
15
15
|
}
|
|
16
16
|
const overrideAuthKey = flags["auth-key"] ? flags["auth-key"] : null;
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
17
|
+
const authInfo = await getAuthInfo(this.config.configDir);
|
|
18
|
+
const authorizationHeader = createAuthorizationHeader(authInfo, overrideAuthKey);
|
|
19
|
+
const client = createApiClient(authorizationHeader, 0);
|
|
20
|
+
const apiValidationController = new ApiValidationExternalApisController(client);
|
|
21
|
+
ux.action.start("Validating specification file");
|
|
22
|
+
const validationSummary = await getValidationSummary(flags, apiValidationController);
|
|
23
|
+
ux.action.stop();
|
|
20
24
|
const logFunctions = {
|
|
21
|
-
log: this.log,
|
|
22
|
-
warn: this.warn,
|
|
23
|
-
error: this.error
|
|
25
|
+
log: (message) => this.log(message),
|
|
26
|
+
warn: (message) => this.warn(message),
|
|
27
|
+
error: (message) => this.error(message)
|
|
24
28
|
};
|
|
25
|
-
|
|
26
|
-
validationSummary.success
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
printValidationMessages(validationSummary, logFunctions);
|
|
30
|
+
if (validationSummary.success) {
|
|
31
|
+
this.log("Specification file provided is valid");
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this.error("Specification file provided is invalid");
|
|
35
|
+
}
|
|
29
36
|
}
|
|
30
37
|
catch (error) {
|
|
31
38
|
if (error.result) {
|
|
32
39
|
const apiError = error;
|
|
33
40
|
const result = apiError.result;
|
|
34
41
|
if (result.modelState["exception Error"] && apiError.statusCode === 400) {
|
|
35
|
-
this.error(
|
|
42
|
+
this.error(replaceHTML(result.modelState["exception Error"][0]));
|
|
36
43
|
}
|
|
37
44
|
else if (error.body && apiError.statusCode === 401) {
|
|
38
45
|
this.error("You are not authorized to perform this action");
|
|
@@ -55,22 +62,14 @@ class Validate extends command_1.Command {
|
|
|
55
62
|
}
|
|
56
63
|
}
|
|
57
64
|
}
|
|
58
|
-
exports.default = Validate;
|
|
59
65
|
Validate.description = "Validate the syntactic and semantic correctness of an API specification";
|
|
60
66
|
Validate.examples = [
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
`,
|
|
64
|
-
`$ apimatic api:validate --url=https://petstore.swagger.io/v2/swagger.json
|
|
65
|
-
Specification file provided is valid
|
|
66
|
-
`
|
|
67
|
+
`apimatic api:validate --file="./specs/sample.json"`,
|
|
68
|
+
`apimatic api:validate --url=https://petstore.swagger.io/v2/swagger.json`
|
|
67
69
|
];
|
|
68
|
-
Validate.flags = {
|
|
69
|
-
file: command_1.flags.string({ default: "", description: "Path to the API specification file to validate" }),
|
|
70
|
-
url: command_1.flags.string({
|
|
70
|
+
Validate.flags = Object.assign({ file: Flags.string({ default: "", description: "Path to the API specification file to validate" }), url: Flags.string({
|
|
71
71
|
default: "",
|
|
72
72
|
description: "URL to the specification file to validate. Can be used in place of the --file option if the API specification is publicly available."
|
|
73
|
-
}),
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
};
|
|
73
|
+
}) }, FlagsProvider.authKey);
|
|
74
|
+
export default Validate;
|
|
75
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/commands/api/validate.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,UAAU,CAAC;AAE/B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAY,mCAAmC,EAAgC,MAAM,eAAe,CAAC;AAG5G,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE5E,OAAO,EAAE,aA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,UAAU,KAAK,GAAG;gBAChD,KAA6B,CAAC,IAAI;gBACnC,OAAQ,KAA6B,CAAC,IAAI,KAAK,QAAQ,EACvD,CAAC;gBACD,IAAI,CAAC,KAAK,CAAE,KAA6B,CAAC,IAAI,CAAC,CAAC;YAClD,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,KAAK,CAAC,GAAI,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;IACH,CAAC;;AAxEM,oBAAW,GAAG,yEAAyE,CAAC;AAExF,iBAAQ,GAAG;IAChB,oDAAoD;IACpD,yEAAyE;CAC1E,CAAC;AAEK,cAAK,mBACV,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC,EAClG,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC;QAChB,OAAO,EAAE,EAAE;QACX,WAAW,EACT,sIAAsI;KACzI,CAAC,IAEC,aAAa,CAAC,OAAO,EACxB;eAjBiB,QAAQ"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
2
|
export default class Login extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
-
"auth-key":
|
|
6
|
+
"auth-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
7
|
};
|
|
8
|
+
private readonly prompts;
|
|
8
9
|
run(): Promise<void>;
|
|
9
10
|
}
|
|
@@ -1,60 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
3
|
+
import { LoginPrompts } from "../../prompts/auth/login.js";
|
|
4
|
+
import { LoginAction } from "../../actions/auth/login.js";
|
|
5
|
+
class Login extends Command {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.prompts = new LoginPrompts();
|
|
9
|
+
}
|
|
8
10
|
async run() {
|
|
9
|
-
const { flags } = this.parse(Login);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const client = sdk_client_1.SDKClient.getInstance();
|
|
13
|
-
// If user is setting auth key
|
|
14
|
-
if (flags["auth-key"]) {
|
|
15
|
-
const response = client.setAuthKey(flags["auth-key"], configDir);
|
|
16
|
-
return this.log(response);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
// If user logs in with email and password
|
|
20
|
-
const email = await cli_ux_1.cli.prompt("Please enter your registered email");
|
|
21
|
-
const password = await cli_ux_1.cli.prompt("Please enter your password", {
|
|
22
|
-
type: "hide"
|
|
23
|
-
});
|
|
24
|
-
const response = await client.login(email, password, configDir);
|
|
25
|
-
this.log(response);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
if (error && error.response) {
|
|
30
|
-
const apiError = error;
|
|
31
|
-
const apiResponse = apiError.response;
|
|
32
|
-
if (apiResponse) {
|
|
33
|
-
const responseData = apiResponse.data;
|
|
34
|
-
if (apiResponse.status === 403 && responseData) {
|
|
35
|
-
return this.error(utils_1.replaceHTML(responseData));
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
return this.error(apiError.message);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
this.error(error.message);
|
|
11
|
+
const { flags: { "auth-key": authKey } } = await this.parse(Login);
|
|
12
|
+
if (authKey === "") {
|
|
13
|
+
this.error("Flag --auth-key must not be empty when provided.");
|
|
43
14
|
}
|
|
15
|
+
const loginAction = new LoginAction(new DirectoryPath(this.config.configDir));
|
|
16
|
+
const result = await loginAction.execute(authKey);
|
|
17
|
+
result.match((email) => this.prompts.loginSuccessful(email), (error) => this.prompts.logError(error));
|
|
44
18
|
}
|
|
45
19
|
}
|
|
46
|
-
exports.default = Login;
|
|
47
20
|
Login.description = "Login using your APIMatic credentials or an API Key";
|
|
48
|
-
Login.examples = [
|
|
49
|
-
`$ apimatic auth:login
|
|
50
|
-
Please enter your registered email: apimatic-user@gmail.com
|
|
51
|
-
Please enter your password: *********
|
|
52
|
-
|
|
53
|
-
You have successfully logged into APIMatic
|
|
54
|
-
`,
|
|
55
|
-
`$ apimatic auth:login --auth-key=xxxxxx
|
|
56
|
-
Authentication key successfully set`
|
|
57
|
-
];
|
|
21
|
+
Login.examples = [`apimatic auth:login`, `apimatic auth:login --auth-key={api-key}`];
|
|
58
22
|
Login.flags = {
|
|
59
|
-
"auth-key":
|
|
23
|
+
"auth-key": Flags.string({
|
|
24
|
+
char: "k",
|
|
25
|
+
description: "Sets authentication key for all commands.",
|
|
26
|
+
})
|
|
60
27
|
};
|
|
28
|
+
export default Login;
|
|
29
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/commands/auth/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,MAAqB,KAAM,SAAQ,OAAO;IAA1C;;QAYmB,YAAO,GAAG,IAAI,YAAY,EAAE,CAAC;IAkBhD,CAAC;IAhBC,KAAK,CAAC,GAAG;QACP,MAAM,EACJ,KAAK,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,EAC/B,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAE5B,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;YACnB,IAAI,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACjE,CAAC;QAED,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;QAC9E,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAClD,MAAM,CAAC,KAAK,CACV,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,EAC9C,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CACxC,CAAC;IACJ,CAAC;;AA5BM,iBAAW,GAAG,qDAAqD,AAAxD,CAAyD;AAEpE,cAAQ,GAAG,CAAC,qBAAqB,EAAE,0CAA0C,CAAC,AAAtE,CAAuE;AAE/E,WAAK,GAAG;IACb,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC;QACvB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,2CAA2C;KACzD,CAAC;CACH,AALW,CAKV;eAViB,KAAK"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const sdk_client_1 = require("../../client-utils/sdk-client");
|
|
5
|
-
class Login extends command_1.Command {
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
import { SDKClient } from "../../client-utils/sdk-client.js";
|
|
3
|
+
class Login extends Command {
|
|
6
4
|
async run() {
|
|
7
5
|
try {
|
|
8
|
-
const client =
|
|
6
|
+
const client = SDKClient.getInstance();
|
|
9
7
|
const response = await client.logout(this.config.configDir);
|
|
10
8
|
this.log(response);
|
|
11
9
|
}
|
|
@@ -14,10 +12,7 @@ class Login extends command_1.Command {
|
|
|
14
12
|
}
|
|
15
13
|
}
|
|
16
14
|
}
|
|
17
|
-
|
|
18
|
-
Login.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
Logged out
|
|
22
|
-
`
|
|
23
|
-
];
|
|
15
|
+
Login.description = "Clears the local login credentials.";
|
|
16
|
+
Login.examples = [`apimatic auth:logout`];
|
|
17
|
+
export default Login;
|
|
18
|
+
//# sourceMappingURL=logout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,MAAqB,KAAM,SAAQ,OAAO;IAKxC,KAAK,CAAC,GAAG;QACP,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;YACvC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAE5D,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACrB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,KAAe,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;;AAbM,iBAAW,GAAG,qCAAqC,CAAC;AAEpD,cAAQ,GAAG,CAAC,sBAAsB,CAAC,CAAC;eAHxB,KAAK"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const sdk_client_1 = require("../../client-utils/sdk-client");
|
|
5
|
-
class Status extends command_1.Command {
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
import { SDKClient } from "../../client-utils/sdk-client.js";
|
|
3
|
+
class Status extends Command {
|
|
6
4
|
async run() {
|
|
7
5
|
try {
|
|
8
|
-
const client =
|
|
6
|
+
const client = SDKClient.getInstance();
|
|
7
|
+
// TODO: Add validation for auth key from the server.
|
|
9
8
|
const response = await client.status(this.config.configDir);
|
|
10
9
|
this.log(response);
|
|
11
10
|
}
|
|
@@ -14,10 +13,7 @@ class Status extends command_1.Command {
|
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
|
-
|
|
18
|
-
Status.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
Currently logged in as apimatic-client@gmail.com
|
|
22
|
-
`
|
|
23
|
-
];
|
|
16
|
+
Status.description = "View the currently logged in user.";
|
|
17
|
+
Status.examples = [`apimatic auth:status`];
|
|
18
|
+
export default Status;
|
|
19
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/commands/auth/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,MAAqB,MAAO,SAAQ,OAAO;IAKzC,KAAK,CAAC,GAAG;QACP,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;YACvC,qDAAqD;YACrD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAE5D,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACrB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,KAAe,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;;AAdM,kBAAW,GAAG,oCAAoC,CAAC;AAEnD,eAAQ,GAAG,CAAC,sBAAsB,CAAC,CAAC;eAHxB,MAAM"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
export default class PortalCopilotEnable extends Command {
|
|
3
|
+
static summary: string;
|
|
4
|
+
static description: string;
|
|
5
|
+
static flags: {
|
|
6
|
+
"auth-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
disable: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
};
|
|
10
|
+
static examples: string[];
|
|
11
|
+
private readonly prompts;
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|