@apimatic/cli 1.1.0-alpha.9 → 1.1.0-beta.2
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 +436 -374
- package/bin/run.js +5 -0
- package/lib/actions/action-result.d.ts +13 -0
- package/lib/actions/action-result.js +44 -0
- package/lib/actions/action-result.js.map +1 -0
- package/lib/actions/api/transform.d.ts +15 -0
- package/lib/actions/api/transform.js +48 -0
- package/lib/actions/api/transform.js.map +1 -0
- package/lib/actions/api/validate.d.ts +12 -0
- package/lib/actions/api/validate.js +41 -0
- package/lib/actions/api/validate.js.map +1 -0
- package/lib/actions/auth/login.d.ts +13 -0
- package/lib/actions/auth/login.js +55 -0
- package/lib/actions/auth/login.js.map +1 -0
- package/lib/actions/auth/logout.d.ts +8 -0
- package/lib/actions/auth/logout.js +15 -0
- package/lib/actions/auth/logout.js.map +1 -0
- package/lib/actions/auth/status.d.ts +11 -0
- package/lib/actions/auth/status.js +26 -0
- package/lib/actions/auth/status.js.map +1 -0
- package/lib/actions/portal/copilot.d.ts +16 -0
- package/lib/actions/portal/copilot.js +89 -0
- package/lib/actions/portal/copilot.js.map +1 -0
- package/lib/actions/portal/generate.d.ts +11 -5
- package/lib/actions/portal/generate.js +60 -55
- package/lib/actions/portal/generate.js.map +1 -0
- package/lib/actions/portal/quickstart.d.ts +16 -0
- package/lib/actions/portal/quickstart.js +146 -0
- package/lib/actions/portal/quickstart.js.map +1 -0
- package/lib/actions/portal/recipe/new-recipe.d.ts +15 -0
- package/lib/actions/portal/recipe/new-recipe.js +177 -0
- package/lib/actions/portal/recipe/new-recipe.js.map +1 -0
- package/lib/actions/portal/serve.d.ts +15 -0
- package/lib/actions/portal/serve.js +118 -0
- package/lib/actions/portal/serve.js.map +1 -0
- package/lib/actions/portal/toc/new-toc.d.ts +17 -13
- package/lib/actions/portal/toc/new-toc.js +85 -122
- package/lib/actions/portal/toc/new-toc.js.map +1 -0
- package/lib/actions/quickstart.d.ts +10 -0
- package/lib/actions/quickstart.js +30 -0
- package/lib/actions/quickstart.js.map +1 -0
- package/lib/actions/sdk/generate.d.ts +13 -0
- package/lib/actions/sdk/generate.js +47 -0
- package/lib/actions/sdk/generate.js.map +1 -0
- package/lib/actions/sdk/quickstart.d.ts +14 -0
- package/lib/actions/sdk/quickstart.js +149 -0
- package/lib/actions/sdk/quickstart.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 +21 -0
- package/lib/application/portal/recipe/recipe-generator.js +145 -0
- package/lib/application/portal/recipe/recipe-generator.js.map +1 -0
- package/lib/application/portal/toc/toc-content-parser.d.ts +1 -1
- package/lib/application/portal/toc/toc-content-parser.js +9 -11
- package/lib/application/portal/toc/toc-content-parser.js.map +1 -0
- package/lib/application/portal/toc/toc-structure-generator.d.ts +1 -1
- package/lib/application/portal/toc/toc-structure-generator.js +4 -8
- package/lib/application/portal/toc/toc-structure-generator.js.map +1 -0
- package/lib/client-utils/auth-manager.d.ts +7 -2
- package/lib/client-utils/auth-manager.js +26 -14
- package/lib/client-utils/auth-manager.js.map +1 -0
- package/lib/commands/api/transform.d.ts +10 -7
- package/lib/commands/api/transform.js +51 -111
- package/lib/commands/api/transform.js.map +1 -0
- package/lib/commands/api/validate.d.ts +7 -4
- package/lib/commands/api/validate.js +31 -74
- package/lib/commands/api/validate.js.map +1 -0
- package/lib/commands/auth/login.d.ts +3 -1
- package/lib/commands/auth/login.js +26 -68
- package/lib/commands/auth/login.js.map +1 -0
- package/lib/commands/auth/logout.d.ts +3 -1
- package/lib/commands/auth/logout.js +14 -21
- package/lib/commands/auth/logout.js.map +1 -0
- package/lib/commands/auth/status.d.ts +1 -0
- package/lib/commands/auth/status.js +18 -21
- package/lib/commands/auth/status.js.map +1 -0
- package/lib/commands/portal/copilot.d.ts +13 -0
- package/lib/commands/portal/copilot.js +34 -0
- package/lib/commands/portal/copilot.js.map +1 -0
- package/lib/commands/portal/generate.d.ts +7 -11
- package/lib/commands/portal/generate.js +26 -89
- package/lib/commands/portal/generate.js.map +1 -0
- package/lib/commands/portal/recipe/new.d.ts +12 -0
- package/lib/commands/portal/recipe/new.js +45 -0
- package/lib/commands/portal/recipe/new.js.map +1 -0
- package/lib/commands/portal/serve.d.ts +8 -8
- package/lib/commands/portal/serve.js +41 -125
- package/lib/commands/portal/serve.js.map +1 -0
- package/lib/commands/portal/toc/new.d.ts +5 -6
- package/lib/commands/portal/toc/new.js +45 -50
- package/lib/commands/portal/toc/new.js.map +1 -0
- package/lib/commands/quickstart.d.ts +9 -0
- package/lib/commands/quickstart.js +37 -0
- package/lib/commands/quickstart.js.map +1 -0
- package/lib/commands/sdk/generate.d.ts +10 -8
- package/lib/commands/sdk/generate.js +46 -131
- package/lib/commands/sdk/generate.js.map +1 -0
- package/lib/config/axios-config.js +4 -6
- package/lib/config/axios-config.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.js +2 -5
- package/lib/index.js.map +1 -0
- package/lib/infrastructure/debounce-service.d.ts +10 -0
- package/lib/infrastructure/debounce-service.js +52 -0
- package/lib/infrastructure/debounce-service.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 +24 -0
- package/lib/infrastructure/file-service.js +120 -0
- package/lib/infrastructure/file-service.js.map +1 -0
- package/lib/infrastructure/launcher-service.d.ts +9 -0
- package/lib/infrastructure/launcher-service.js +72 -0
- package/lib/infrastructure/launcher-service.js.map +1 -0
- package/lib/infrastructure/network-service.d.ts +3 -0
- package/lib/infrastructure/network-service.js +7 -0
- package/lib/infrastructure/network-service.js.map +1 -0
- package/lib/infrastructure/service-error.d.ts +16 -0
- package/lib/infrastructure/service-error.js +49 -0
- package/lib/infrastructure/service-error.js.map +1 -0
- package/lib/infrastructure/services/api-client-factory.d.ts +6 -0
- package/lib/infrastructure/services/api-client-factory.js +20 -0
- package/lib/infrastructure/services/api-client-factory.js.map +1 -0
- package/lib/infrastructure/services/api-service.d.ts +12 -0
- package/lib/infrastructure/services/api-service.js +79 -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 +37 -0
- package/lib/infrastructure/services/auth-service.js.map +1 -0
- package/lib/infrastructure/services/file-download-service.d.ts +15 -0
- package/lib/infrastructure/services/file-download-service.js +104 -0
- package/lib/infrastructure/services/file-download-service.js.map +1 -0
- package/lib/infrastructure/services/portal-service.d.ts +17 -12
- package/lib/infrastructure/services/portal-service.js +134 -99
- package/lib/infrastructure/services/portal-service.js.map +1 -0
- package/lib/infrastructure/services/telemetry-service.d.ts +9 -0
- package/lib/infrastructure/services/telemetry-service.js +38 -0
- package/lib/infrastructure/services/telemetry-service.js.map +1 -0
- package/lib/infrastructure/services/transformation-service.d.ts +23 -0
- package/lib/infrastructure/services/transformation-service.js +56 -0
- package/lib/infrastructure/services/transformation-service.js.map +1 -0
- package/lib/infrastructure/services/validation-service.d.ts +17 -0
- package/lib/infrastructure/services/validation-service.js +49 -0
- package/lib/infrastructure/services/validation-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/api/transform.d.ts +11 -0
- package/lib/prompts/api/transform.js +29 -0
- package/lib/prompts/api/transform.js.map +1 -0
- package/lib/prompts/api/validate.d.ts +12 -0
- package/lib/prompts/api/validate.js +40 -0
- package/lib/prompts/api/validate.js.map +1 -0
- package/lib/prompts/auth/login.d.ts +10 -0
- package/lib/prompts/auth/login.js +22 -0
- package/lib/prompts/auth/login.js.map +1 -0
- package/lib/prompts/auth/logout.d.ts +3 -0
- package/lib/prompts/auth/logout.js +7 -0
- package/lib/prompts/auth/logout.js.map +1 -0
- package/lib/prompts/auth/status.d.ts +8 -0
- package/lib/prompts/auth/status.js +22 -0
- package/lib/prompts/auth/status.js.map +1 -0
- package/lib/prompts/format.d.ts +31 -0
- package/lib/prompts/format.js +89 -0
- package/lib/prompts/format.js.map +1 -0
- package/lib/prompts/portal/copilot.d.ts +18 -0
- package/lib/prompts/portal/copilot.js +82 -0
- package/lib/prompts/portal/copilot.js.map +1 -0
- package/lib/prompts/portal/generate.d.ts +13 -8
- package/lib/prompts/portal/generate.js +36 -53
- package/lib/prompts/portal/generate.js.map +1 -0
- package/lib/prompts/portal/quickstart.d.ts +28 -29
- package/lib/prompts/portal/quickstart.js +102 -185
- package/lib/prompts/portal/quickstart.js.map +1 -0
- package/lib/prompts/portal/recipe/new-recipe.d.ts +29 -0
- package/lib/prompts/portal/recipe/new-recipe.js +165 -0
- package/lib/prompts/portal/recipe/new-recipe.js.map +1 -0
- package/lib/prompts/portal/serve.d.ts +9 -5
- package/lib/prompts/portal/serve.js +29 -19
- package/lib/prompts/portal/serve.js.map +1 -0
- package/lib/prompts/portal/toc/new-toc.d.ts +13 -8
- package/lib/prompts/portal/toc/new-toc.js +28 -36
- package/lib/prompts/portal/toc/new-toc.js.map +1 -0
- package/lib/prompts/prompt.d.ts +3 -0
- package/lib/prompts/prompt.js +37 -0
- package/lib/prompts/prompt.js.map +1 -0
- package/lib/prompts/quickstart.d.ts +6 -0
- package/lib/prompts/quickstart.js +25 -0
- package/lib/prompts/quickstart.js.map +1 -0
- package/lib/prompts/sdk/generate.d.ts +11 -0
- package/lib/prompts/sdk/generate.js +37 -0
- package/lib/prompts/sdk/generate.js.map +1 -0
- package/lib/prompts/sdk/quickstart.d.ts +32 -0
- package/lib/prompts/sdk/quickstart.js +140 -0
- package/lib/prompts/sdk/quickstart.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 +14 -25
- package/lib/types/api/transform.js +20 -23
- package/lib/types/api/transform.js.map +1 -0
- package/lib/types/build/build.d.ts +22 -0
- package/lib/types/build/build.js +7 -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 +33 -0
- package/lib/types/build-context.js.map +1 -0
- package/lib/types/common/command-metadata.d.ts +4 -0
- package/lib/types/common/command-metadata.js +2 -0
- package/lib/types/common/command-metadata.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/directory.d.ts +17 -0
- package/lib/types/file/directory.js +87 -0
- package/lib/types/file/directory.js.map +1 -0
- package/lib/types/file/directoryPath.d.ts +10 -0
- package/lib/types/file/directoryPath.js +26 -0
- package/lib/types/file/directoryPath.js.map +1 -0
- package/lib/types/file/fileName.d.ts +7 -0
- package/lib/types/file/fileName.js +21 -0
- package/lib/types/file/fileName.js.map +1 -0
- package/lib/types/file/filePath.d.ts +10 -0
- package/lib/types/file/filePath.js +32 -0
- package/lib/types/file/filePath.js.map +1 -0
- package/lib/types/file/resource-input.d.ts +5 -0
- package/lib/types/file/resource-input.js +42 -0
- package/lib/types/file/resource-input.js.map +1 -0
- package/lib/types/file/urlPath.d.ts +6 -0
- package/lib/types/file/urlPath.js +22 -0
- package/lib/types/file/urlPath.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-context.d.ts +13 -0
- package/lib/types/portal-context.js +38 -0
- package/lib/types/portal-context.js.map +1 -0
- package/lib/types/recipe/recipe.d.ts +22 -0
- package/lib/types/recipe/recipe.js +6 -0
- package/lib/types/recipe/recipe.js.map +1 -0
- package/lib/types/recipe-context.d.ts +9 -0
- package/lib/types/recipe-context.js +26 -0
- package/lib/types/recipe-context.js.map +1 -0
- package/lib/types/resource-context.d.ts +12 -0
- package/lib/types/resource-context.js +30 -0
- package/lib/types/resource-context.js.map +1 -0
- package/lib/types/sdk/generate.d.ts +9 -22
- package/lib/types/sdk/generate.js +25 -14
- package/lib/types/sdk/generate.js.map +1 -0
- package/lib/types/sdk-context.d.ts +14 -0
- package/lib/types/sdk-context.js +32 -0
- package/lib/types/sdk-context.js.map +1 -0
- package/lib/types/sdl/sdl.d.ts +10 -0
- package/lib/types/sdl/sdl.js +47 -3
- package/lib/types/sdl/sdl.js.map +1 -0
- package/lib/types/spec-context.d.ts +12 -0
- package/lib/types/spec-context.js +29 -0
- package/lib/types/spec-context.js.map +1 -0
- package/lib/types/temp-context.d.ts +11 -0
- package/lib/types/temp-context.js +27 -0
- package/lib/types/temp-context.js.map +1 -0
- package/lib/types/toc/toc.js +2 -10
- package/lib/types/toc/toc.js.map +1 -0
- package/lib/types/toc-context.d.ts +12 -0
- package/lib/types/toc-context.js +26 -0
- package/lib/types/toc-context.js.map +1 -0
- package/lib/types/transform-context.d.ts +13 -0
- package/lib/types/transform-context.js +30 -0
- package/lib/types/transform-context.js.map +1 -0
- package/lib/types/utils.d.ts +0 -9
- package/lib/types/utils.js +2 -3
- package/lib/types/utils.js.map +1 -0
- package/lib/utils/string-utils.d.ts +2 -0
- package/lib/utils/string-utils.js +37 -0
- package/lib/utils/string-utils.js.map +1 -0
- package/lib/utils/utils.d.ts +2 -44
- package/lib/utils/utils.js +14 -366
- package/lib/utils/utils.js.map +1 -0
- package/package.json +50 -31
- package/bin/run +0 -9
- package/lib/application/portal/toc/sdl-parser.d.ts +0 -13
- package/lib/application/portal/toc/sdl-parser.js +0 -53
- package/lib/client-utils/sdk-client.d.ts +0 -23
- package/lib/client-utils/sdk-client.js +0 -124
- package/lib/commands/portal/quickstart.d.ts +0 -10
- package/lib/commands/portal/quickstart.js +0 -79
- package/lib/config/env.d.ts +0 -27
- package/lib/config/env.js +0 -31
- package/lib/controllers/api/transform.d.ts +0 -5
- package/lib/controllers/api/transform.js +0 -56
- package/lib/controllers/api/validate.d.ts +0 -3
- package/lib/controllers/api/validate.js +0 -33
- package/lib/controllers/portal/generate.d.ts +0 -3
- package/lib/controllers/portal/generate.js +0 -110
- package/lib/controllers/portal/quickstart.d.ts +0 -14
- package/lib/controllers/portal/quickstart.js +0 -258
- package/lib/controllers/portal/serve.d.ts +0 -3
- package/lib/controllers/portal/serve.js +0 -138
- package/lib/controllers/sdk/generate.d.ts +0 -4
- package/lib/controllers/sdk/generate.js +0 -66
- package/lib/services/portal/server.d.ts +0 -14
- package/lib/services/portal/server.js +0 -101
- package/lib/types/api/validate.d.ts +0 -12
- package/lib/types/api/validate.js +0 -3
- package/lib/types/common/result.d.ts +0 -17
- package/lib/types/common/result.js +0 -36
- package/lib/types/portal/generate.d.ts +0 -26
- package/lib/types/portal/generate.js +0 -4
- package/lib/types/portal/quickstart.d.ts +0 -17
- package/lib/types/portal/quickstart.js +0 -3
- package/lib/validators/common/directoryValidator.d.ts +0 -9
- package/lib/validators/common/directoryValidator.js +0 -53
- package/lib/validators/common/portValidator.d.ts +0 -5
- package/lib/validators/common/portValidator.js +0 -20
- package/lib/validators/portal/serveValidator.d.ts +0 -6
- package/lib/validators/portal/serveValidator.js +0 -21
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
2
|
+
import { Result } from "neverthrow";
|
|
3
|
+
import { TransformationResultData } from "../../infrastructure/services/transformation-service.js";
|
|
4
|
+
import { ServiceError } from "../../infrastructure/service-error.js";
|
|
5
|
+
export declare class ApiTransformPrompts {
|
|
6
|
+
overwriteApi(directory: DirectoryPath): Promise<boolean>;
|
|
7
|
+
transformedApiAlreadyExists(): void;
|
|
8
|
+
transformApi(fn: Promise<Result<TransformationResultData, string>>): Promise<Result<TransformationResultData, string>>;
|
|
9
|
+
logTransformationError(error: string): void;
|
|
10
|
+
networkError(serviceError: ServiceError): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { log, isCancel, confirm } from "@clack/prompts";
|
|
2
|
+
import { format as f } from "../format.js";
|
|
3
|
+
import { withSpinner } from "../prompt.js";
|
|
4
|
+
export class ApiTransformPrompts {
|
|
5
|
+
async overwriteApi(directory) {
|
|
6
|
+
const overwrite = await confirm({
|
|
7
|
+
message: `A specification file already exists at ${f.path(directory)}. Do you want to overwrite the existing file?`,
|
|
8
|
+
initialValue: false
|
|
9
|
+
});
|
|
10
|
+
if (isCancel(overwrite)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
return overwrite;
|
|
14
|
+
}
|
|
15
|
+
transformedApiAlreadyExists() {
|
|
16
|
+
const message = `Specification already exists.`;
|
|
17
|
+
log.error(message);
|
|
18
|
+
}
|
|
19
|
+
async transformApi(fn) {
|
|
20
|
+
return withSpinner("Transforming API", "API transformed successfully.", "API transformation failed.", fn);
|
|
21
|
+
}
|
|
22
|
+
logTransformationError(error) {
|
|
23
|
+
log.error(error);
|
|
24
|
+
}
|
|
25
|
+
networkError(serviceError) {
|
|
26
|
+
log.error(serviceError.errorMessage);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/prompts/api/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,cAAc,CAAC;AAI3C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,OAAO,mBAAmB;IACvB,KAAK,CAAC,YAAY,CAAC,SAAwB;QAChD,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC;YAC9B,OAAO,EAAE,0CAA0C,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,+CAA+C;YACnH,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;QAEH,IAAI,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YACxB,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAEM,2BAA2B;QAChC,MAAM,OAAO,GAAG,+BAA+B,CAAC;QAChD,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,EAAqD;QAC7E,OAAO,WAAW,CAAC,kBAAkB,EAAE,+BAA+B,EAAE,4BAA4B,EAAE,EAAE,CAAC,CAAC;IAC5G,CAAC;IAED,sBAAsB,CAAC,KAAa;QAClC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC;IAEM,YAAY,CAAC,YAA0B;QAC5C,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ValidationMessages } from "../../types/utils.js";
|
|
2
|
+
import { Result } from "neverthrow";
|
|
3
|
+
import { ApiValidationSummary } from "@apimatic/sdk";
|
|
4
|
+
import { ServiceError } from "../../infrastructure/service-error.js";
|
|
5
|
+
import { FilePath } from "../../types/file/filePath.js";
|
|
6
|
+
export declare class ApiValidatePrompts {
|
|
7
|
+
validateApi(fn: Promise<Result<ApiValidationSummary, string>>): Promise<Result<ApiValidationSummary, string>>;
|
|
8
|
+
displayValidationMessages({ warnings, errors, messages }: ValidationMessages): void;
|
|
9
|
+
logValidationError(error: string): void;
|
|
10
|
+
networkError(serviceError: ServiceError): void;
|
|
11
|
+
transformedApiSaved(filePath: FilePath): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { log } from "@clack/prompts";
|
|
2
|
+
import { replaceHTML } from "../../utils/utils.js";
|
|
3
|
+
import { format as f } from "../format.js";
|
|
4
|
+
import { withSpinner } from "../prompt.js";
|
|
5
|
+
export class ApiValidatePrompts {
|
|
6
|
+
async validateApi(fn) {
|
|
7
|
+
return withSpinner("Validating API", "API validation completed", "API validation failed", fn);
|
|
8
|
+
}
|
|
9
|
+
displayValidationMessages({ warnings, errors, messages }) {
|
|
10
|
+
if (messages.length > 0) {
|
|
11
|
+
log.info("Messages");
|
|
12
|
+
messages.forEach((msg) => {
|
|
13
|
+
log.message(`${replaceHTML(msg)}`);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
if (warnings.length > 0) {
|
|
17
|
+
log.warning("Warnings");
|
|
18
|
+
warnings.forEach((war) => {
|
|
19
|
+
log.message(`${replaceHTML(war)}`);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (errors.length > 0) {
|
|
23
|
+
log.error("Errors");
|
|
24
|
+
errors.forEach((err) => {
|
|
25
|
+
log.message(`${replaceHTML(err)}`);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
logValidationError(error) {
|
|
30
|
+
log.error(error);
|
|
31
|
+
}
|
|
32
|
+
networkError(serviceError) {
|
|
33
|
+
const message = serviceError.errorMessage;
|
|
34
|
+
log.error(message);
|
|
35
|
+
}
|
|
36
|
+
transformedApiSaved(filePath) {
|
|
37
|
+
log.info(`Transformed API has been saved to ${f.path(filePath)}.`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/prompts/api/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAMnD,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,OAAO,kBAAkB;IACtB,KAAK,CAAC,WAAW,CAAC,EAAiD;QACxE,OAAO,WAAW,CAAC,gBAAgB,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAC;IAChG,CAAC;IAED,yBAAyB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAsB;QAC1E,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACrB,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBACvB,GAAG,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACrC,CAAC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YACxB,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBACvB,GAAG,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACrC,CAAC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YACpB,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBACrB,GAAG,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACrC,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,kBAAkB,CAAC,KAAa;QAC9B,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC;IAEM,YAAY,CAAC,YAA0B;QAC5C,MAAM,OAAO,GAAG,YAAY,CAAC,YAAY,CAAC;QAC1C,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAEM,mBAAmB,CAAC,QAAkB;QAC3C,GAAG,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACrE,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ServiceError } from "../../infrastructure/service-error.js";
|
|
2
|
+
import { SubscriptionInfo } from "../../types/api/account.js";
|
|
3
|
+
import { Result } from "neverthrow";
|
|
4
|
+
export declare class LoginPrompts {
|
|
5
|
+
loginSuccessful(email: string): void;
|
|
6
|
+
openBrowser(): void;
|
|
7
|
+
invalidKeyProvided(serviceError: ServiceError): void;
|
|
8
|
+
loginTimeout(): void;
|
|
9
|
+
accountInfoSpinner(fn: Promise<Result<SubscriptionInfo, ServiceError>>): Promise<Result<SubscriptionInfo, ServiceError>>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { log } from "@clack/prompts";
|
|
2
|
+
import { ServiceError } from "../../infrastructure/service-error.js";
|
|
3
|
+
import { withSpinner } from "../prompt.js";
|
|
4
|
+
export class LoginPrompts {
|
|
5
|
+
loginSuccessful(email) {
|
|
6
|
+
log.success(`Successfully logged in as ${email}`);
|
|
7
|
+
}
|
|
8
|
+
openBrowser() {
|
|
9
|
+
log.info("Please continue with authentication in the opened browser window.");
|
|
10
|
+
}
|
|
11
|
+
invalidKeyProvided(serviceError) {
|
|
12
|
+
const message = serviceError === ServiceError.NetworkError ? "Invalid API key provided." : serviceError.errorMessage;
|
|
13
|
+
log.error(message);
|
|
14
|
+
}
|
|
15
|
+
loginTimeout() {
|
|
16
|
+
log.error("Authentication timed out. Please try again.");
|
|
17
|
+
}
|
|
18
|
+
accountInfoSpinner(fn) {
|
|
19
|
+
return withSpinner("Retrieving your subscription info", "Retrieved subscription info", "Error retrieving subscription info", fn);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/prompts/auth/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAGrE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,OAAO,YAAY;IAChB,eAAe,CAAC,KAAa;QAClC,GAAG,CAAC,OAAO,CAAC,6BAA6B,KAAK,EAAE,CAAC,CAAC;IACpD,CAAC;IAEM,WAAW;QAChB,GAAG,CAAC,IAAI,CAAC,mEAAmE,CAAC,CAAC;IAChF,CAAC;IAEM,kBAAkB,CAAC,YAA0B;QAClD,MAAM,OAAO,GACX,YAAY,KAAK,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC;QACvG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAEM,YAAY;QACjB,GAAG,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAC3D,CAAC;IAEM,kBAAkB,CAAC,EAAmD;QAC3E,OAAO,WAAW,CAChB,mCAAmC,EACnC,6BAA6B,EAC7B,oCAAoC,EACpC,EAAE,CACH,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/prompts/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAGrC,MAAM,OAAO,aAAa;IAEjB,cAAc;QACnB,GAAG,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;IACvC,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Result } from "neverthrow";
|
|
2
|
+
import { SubscriptionInfo } from "../../types/api/account.js";
|
|
3
|
+
import { ServiceError } from "../../infrastructure/service-error.js";
|
|
4
|
+
export declare class StatusPrompts {
|
|
5
|
+
accountInfoSpinner(fn: Promise<Result<SubscriptionInfo, ServiceError>>): Promise<Result<SubscriptionInfo, ServiceError>>;
|
|
6
|
+
invalidKeyProvided(serviceError: ServiceError): void;
|
|
7
|
+
showAccountInfo(info: SubscriptionInfo): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ServiceError } from "../../infrastructure/service-error.js";
|
|
2
|
+
import { format } from "../format.js";
|
|
3
|
+
import { log } from "@clack/prompts";
|
|
4
|
+
import { mapLanguages } from "../../types/sdk/generate.js";
|
|
5
|
+
import { withSpinner } from "../prompt.js";
|
|
6
|
+
export class StatusPrompts {
|
|
7
|
+
accountInfoSpinner(fn) {
|
|
8
|
+
return withSpinner("Retrieving your subscription info", "Retrieved subscription info", "Error retrieving subscription info", fn);
|
|
9
|
+
}
|
|
10
|
+
invalidKeyProvided(serviceError) {
|
|
11
|
+
const message = serviceError === ServiceError.UnAuthorized ? "Invalid API key provided." : serviceError.errorMessage;
|
|
12
|
+
log.error(message);
|
|
13
|
+
}
|
|
14
|
+
showAccountInfo(info) {
|
|
15
|
+
const languages = mapLanguages(info.allowedLanguages);
|
|
16
|
+
const message = `Account Information:
|
|
17
|
+
Email: ${format.var(info.Email)}
|
|
18
|
+
Allowed Languages: ${languages.map((language) => format.var(language)).join(", ")}`;
|
|
19
|
+
log.info(`${message}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/prompts/auth/status.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,OAAO,aAAa;IACjB,kBAAkB,CAAC,EAAmD;QAC3E,OAAO,WAAW,CAChB,mCAAmC,EACnC,6BAA6B,EAC7B,oCAAoC,EACpC,EAAE,CACH,CAAC;IACJ,CAAC;IAEM,kBAAkB,CAAC,YAA0B;QAClD,MAAM,OAAO,GACX,YAAY,KAAK,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC;QACvG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAEM,eAAe,CAAC,IAAsB;QAC3C,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACtD,MAAM,OAAO,GAAG;WACT,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;uBACV,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAClF,GAAG,CAAC,IAAI,CAAC,GAAG,OAAO,EAAE,CAAC,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ActionResult } from "../actions/action-result.js";
|
|
2
|
+
import { Directory } from "../types/file/directory.js";
|
|
3
|
+
import { DirectoryPath } from "../types/file/directoryPath.js";
|
|
4
|
+
import { FilePath } from "../types/file/filePath.js";
|
|
5
|
+
export declare const format: {
|
|
6
|
+
var: (text: string) => string;
|
|
7
|
+
path: (text: DirectoryPath | FilePath) => string;
|
|
8
|
+
cmd: (cmd: string, ...args: string[]) => string;
|
|
9
|
+
cmdAlt: (cmd: string, ...args: string[]) => string;
|
|
10
|
+
link: (text: string) => string;
|
|
11
|
+
description: (text: string) => string;
|
|
12
|
+
flag: (name: string, value?: string | undefined) => string;
|
|
13
|
+
success: (text: string) => string;
|
|
14
|
+
error: (text: string) => string;
|
|
15
|
+
info: (text: string) => string;
|
|
16
|
+
intro: (text: string) => string;
|
|
17
|
+
outroSuccess: (text: string) => string;
|
|
18
|
+
outroFailure: (text: string) => string;
|
|
19
|
+
outroCancelled: (text: string) => string;
|
|
20
|
+
};
|
|
21
|
+
export declare function intro(text: string): void;
|
|
22
|
+
export declare function outro(result: ActionResult): void;
|
|
23
|
+
export declare function getDirectoryTree(dir: Directory, prefix?: string, isLast?: boolean): string;
|
|
24
|
+
export interface LeafNode {
|
|
25
|
+
name: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface TreeNode extends LeafNode {
|
|
29
|
+
items: Array<TreeNode | LeafNode>;
|
|
30
|
+
}
|
|
31
|
+
export declare function getTree(dir: TreeNode, prefix?: string, isLast?: boolean): string;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import pc from "picocolors";
|
|
2
|
+
import { intro as i, outro as o } from '@clack/prompts';
|
|
3
|
+
import { Directory } from "../types/file/directory.js";
|
|
4
|
+
export const format = {
|
|
5
|
+
// Core element types
|
|
6
|
+
var: (text) => pc.magenta(`'${text}'`),
|
|
7
|
+
path: (text) => pc.cyan(`'${text}'`),
|
|
8
|
+
cmd: (cmd, ...args) => `${pc.blueBright(cmd)} ${args.map(arg => pc.dim(arg)).join(" ")}`,
|
|
9
|
+
cmdAlt: (cmd, ...args) => `${pc.dim(pc.blueBright(cmd))} ${args.map(arg => pc.blueBright(arg)).join(" ")}`,
|
|
10
|
+
link: (text) => pc.underline(pc.blueBright(text)),
|
|
11
|
+
description: (text) => pc.greenBright(`${text}`),
|
|
12
|
+
flag: (name, value = undefined) => {
|
|
13
|
+
if (value) {
|
|
14
|
+
const sanitizedValue = value.includes(" ") ? `'${value}'` : value;
|
|
15
|
+
return `${pc.green(`--${name}`)}=${pc.dim(sanitizedValue)}`;
|
|
16
|
+
}
|
|
17
|
+
return `${pc.green(`--${name}`)}`;
|
|
18
|
+
},
|
|
19
|
+
// Common message styles
|
|
20
|
+
success: (text) => pc.green(text),
|
|
21
|
+
error: (text) => pc.red(text),
|
|
22
|
+
info: (text) => pc.cyan(text),
|
|
23
|
+
intro: (text) => pc.bgCyan(text),
|
|
24
|
+
outroSuccess: (text) => pc.bgGreen(text),
|
|
25
|
+
outroFailure: (text) => pc.bgRed(text),
|
|
26
|
+
outroCancelled: (text) => pc.bgWhite(pc.blackBright(text)),
|
|
27
|
+
};
|
|
28
|
+
export function intro(text) {
|
|
29
|
+
i(format.intro(` ${text} `));
|
|
30
|
+
}
|
|
31
|
+
export function outro(result) {
|
|
32
|
+
const exitCode = result.getExitCode();
|
|
33
|
+
const message = result.getMessage();
|
|
34
|
+
const outroMessage = result.mapAll(() => format.outroSuccess(message), () => format.outroFailure(message), () => format.outroCancelled(message));
|
|
35
|
+
o(outroMessage);
|
|
36
|
+
process.exitCode = exitCode;
|
|
37
|
+
}
|
|
38
|
+
export function getDirectoryTree(dir, prefix = "", isLast = true) {
|
|
39
|
+
const folderDescription = {
|
|
40
|
+
spec: "# Contains all API definition files",
|
|
41
|
+
content: "# Includes custom documentation pages in Markdown",
|
|
42
|
+
static: "# Includes all static files, such as images, GIFs, and PDFs"
|
|
43
|
+
};
|
|
44
|
+
const fileDescriptions = {
|
|
45
|
+
"toc.yml": "# Controls the structure of the side navigation bar in the API portal",
|
|
46
|
+
"APIMATIC-BUILD.json": "# Defines all configurations for the API portal, including programming languages and themes"
|
|
47
|
+
};
|
|
48
|
+
const pointer = isLast ? "└─ " : "├─ ";
|
|
49
|
+
const folderName = dir.directoryPath.leafName();
|
|
50
|
+
const description = folderDescription[folderName] ? format.description(folderDescription[folderName]) : "";
|
|
51
|
+
let output = `${prefix}${pointer}${folderName}${description ? " " + description : ""}\n`;
|
|
52
|
+
const items = dir.items;
|
|
53
|
+
const newPrefix = prefix + (isLast ? " " : "| ");
|
|
54
|
+
items.forEach((item, index) => {
|
|
55
|
+
const last = index === items.length - 1;
|
|
56
|
+
if (item instanceof Directory) {
|
|
57
|
+
output += getDirectoryTree(item, newPrefix, last);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
const filePointer = last ? "└─ " : "├─ ";
|
|
61
|
+
const fileName = item.toString();
|
|
62
|
+
const fileDescription = fileDescriptions[fileName] ? format.description(fileDescriptions[fileName]) : "";
|
|
63
|
+
output += `${newPrefix}${filePointer}${fileName}${fileDescription ? " " + fileDescription : ""}\n`;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return output;
|
|
67
|
+
}
|
|
68
|
+
export function getTree(dir, prefix = "", isLast = true) {
|
|
69
|
+
const pointer = isLast ? "└─ " : "├─ ";
|
|
70
|
+
const folderName = dir.name;
|
|
71
|
+
const description = dir.description ? format.description(dir.description) : "";
|
|
72
|
+
let output = `${prefix}${pointer}${folderName}${description ? " " + description : ""}\n`;
|
|
73
|
+
const items = dir.items;
|
|
74
|
+
const newPrefix = prefix + (isLast ? " " : "| ");
|
|
75
|
+
items.forEach((item, index) => {
|
|
76
|
+
const last = index === items.length - 1;
|
|
77
|
+
if ('items' in item) {
|
|
78
|
+
output += getTree(item, newPrefix, last);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
const filePointer = last ? "└─ " : "├─ ";
|
|
82
|
+
const fileName = item.name;
|
|
83
|
+
const fileDescription = item.description ? format.description(item.description) : "";
|
|
84
|
+
output += `${newPrefix}${filePointer}${fileName}${fileDescription ? " " + fileDescription : ""}\n`;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
return output;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/prompts/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAIvD,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,qBAAqB;IACrB,GAAG,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,GAAG,CAAC;IAC9C,IAAI,EAAE,CAAC,IAA8B,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC;IAC9D,GAAG,EAAE,CAAC,GAAW,EAAE,GAAG,IAAc,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,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,IAAI,CAAC,IAAI,CAAC;YAC3B,MAAM,eAAe,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACrF,MAAM,IAAI,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,eAAe,CAAC,CAAC,CAAC,GAAG,GAAG,eAAe,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;QACrG,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Result } from "neverthrow";
|
|
2
|
+
import { SubscriptionInfo } from "../../types/api/account.js";
|
|
3
|
+
import { ServiceError } from "../../infrastructure/service-error.js";
|
|
4
|
+
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
5
|
+
export declare class PortalCopilotPrompts {
|
|
6
|
+
displayApiCopilotKeyUsageWarning(): Promise<void>;
|
|
7
|
+
openWelcomeMessageEditor(): void;
|
|
8
|
+
selectCopilotKey(keys: string[]): Promise<string | null>;
|
|
9
|
+
copilotConfigured(status: boolean, copilotId: string): void;
|
|
10
|
+
confirmOverwrite(): Promise<boolean>;
|
|
11
|
+
spinnerAccountInfo(fn: Promise<Result<SubscriptionInfo, ServiceError>>): Promise<Result<SubscriptionInfo, ServiceError>>;
|
|
12
|
+
confirmSingleKeyUsage(apiCopilotKey: string): Promise<boolean>;
|
|
13
|
+
srcDirectoryEmpty(directory: DirectoryPath): void;
|
|
14
|
+
cancelled(): void;
|
|
15
|
+
serviceError(serviceError: ServiceError): void;
|
|
16
|
+
noCopilotKeyFound(): void;
|
|
17
|
+
noCopilotKeySelected(): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { confirm, isCancel, log, select } from "@clack/prompts";
|
|
2
|
+
import { format as f } from "../format.js";
|
|
3
|
+
import { noteWrapped, withSpinner } from "../prompt.js";
|
|
4
|
+
export class PortalCopilotPrompts {
|
|
5
|
+
async displayApiCopilotKeyUsageWarning() {
|
|
6
|
+
log.warn("API Copilot can only be active on one Portal at a time. Configuring it on this Portal will disable it on any previously configured Portal.");
|
|
7
|
+
}
|
|
8
|
+
openWelcomeMessageEditor() {
|
|
9
|
+
log.step("Opening markdown editor for you to enter welcome message in...");
|
|
10
|
+
}
|
|
11
|
+
async selectCopilotKey(keys) {
|
|
12
|
+
const selectedKey = await select({
|
|
13
|
+
message: "Select the ID for the API Copilot you would like to add to this API Portal:",
|
|
14
|
+
maxItems: 10,
|
|
15
|
+
options: keys.map((key) => ({
|
|
16
|
+
value: key,
|
|
17
|
+
label: key
|
|
18
|
+
}))
|
|
19
|
+
});
|
|
20
|
+
if (isCancel(selectedKey)) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return selectedKey;
|
|
24
|
+
}
|
|
25
|
+
copilotConfigured(status, copilotId) {
|
|
26
|
+
log.info(`API Copilot configured successfully!
|
|
27
|
+
|
|
28
|
+
Copilot ID: ${f.var(copilotId)}
|
|
29
|
+
Status: ${f.var(status ? "Enabled" : "Disabled")}
|
|
30
|
+
|
|
31
|
+
Configuration saved to: ${f.var("APIMATIC-BUILD.json")}`);
|
|
32
|
+
noteWrapped(`API Copilot will index your content the next time you run
|
|
33
|
+
'${f.cmdAlt("apimatic", "portal", "generate")}' or '${f.cmdAlt("apimatic", "portal", "serve")}'.
|
|
34
|
+
This process can take up to 10 minutes, depending on your API’s size.
|
|
35
|
+
|
|
36
|
+
To see your copilot: If your portal is already running, refresh the page.
|
|
37
|
+
Otherwise, run '${f.cmdAlt("apimatic", "portal", "serve")}',
|
|
38
|
+
select any programming language in the Portal and
|
|
39
|
+
look for the chat icon in the bottom-right corner.`, "Next Steps");
|
|
40
|
+
}
|
|
41
|
+
async confirmOverwrite() {
|
|
42
|
+
const shouldOverwrite = await confirm({
|
|
43
|
+
message: "API Copilot is already configured for this Portal, do you want to overwrite it?",
|
|
44
|
+
initialValue: false
|
|
45
|
+
});
|
|
46
|
+
if (isCancel(shouldOverwrite)) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return shouldOverwrite;
|
|
50
|
+
}
|
|
51
|
+
async spinnerAccountInfo(fn) {
|
|
52
|
+
return withSpinner("Retrieving your subscription info", "Subscription info retrieved", "Subscription info retrieval failed", fn);
|
|
53
|
+
}
|
|
54
|
+
async confirmSingleKeyUsage(apiCopilotKey) {
|
|
55
|
+
const confirmKeyUsage = await confirm({
|
|
56
|
+
message: "API Copilot can only be active on one Portal at a time. Configuring it on this Portal will disable it on any previously configured Portal.\n" +
|
|
57
|
+
`Do you want to use this key: ${f.var(apiCopilotKey)}?`,
|
|
58
|
+
initialValue: true
|
|
59
|
+
});
|
|
60
|
+
if (isCancel(confirmKeyUsage)) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
return confirmKeyUsage;
|
|
64
|
+
}
|
|
65
|
+
srcDirectoryEmpty(directory) {
|
|
66
|
+
const message = `The ${f.var("src")} directory is either empty or invalid: ${f.path(directory)}`;
|
|
67
|
+
log.error(message);
|
|
68
|
+
}
|
|
69
|
+
cancelled() {
|
|
70
|
+
log.warning("Exiting without making any change.");
|
|
71
|
+
}
|
|
72
|
+
serviceError(serviceError) {
|
|
73
|
+
log.error(serviceError.errorMessage);
|
|
74
|
+
}
|
|
75
|
+
noCopilotKeyFound() {
|
|
76
|
+
log.error(`No copilot key found for the current subscription. Please contact support at ${f.var("support@apimatic.io")}.`);
|
|
77
|
+
}
|
|
78
|
+
noCopilotKeySelected() {
|
|
79
|
+
log.error("No API Copilot key was selected.");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=copilot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot.js","sourceRoot":"","sources":["../../../src/prompts/portal/copilot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OA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B;QACtB,GAAG,CAAC,KAAK,CACP,gFAAgF,CAAC,CAAC,GAAG,CAAC,qBAAqB,CAAC,GAAG,CAChH,CAAC;IACJ,CAAC;IAEM,oBAAoB;QACzB,GAAG,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;IAChD,CAAC;CACF"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
2
|
+
import { Result } from "neverthrow";
|
|
3
|
+
import { FilePath } from "../../types/file/filePath.js";
|
|
4
|
+
import { ServiceError } from "../../infrastructure/service-error.js";
|
|
1
5
|
export declare class PortalGeneratePrompts {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
overwritePortal(directory: DirectoryPath): Promise<boolean>;
|
|
7
|
+
directoryCannotBeSame(directory: DirectoryPath): void;
|
|
8
|
+
srcDirectoryEmpty(directory: DirectoryPath): void;
|
|
9
|
+
portalDirectoryNotEmpty(): void;
|
|
10
|
+
generatePortal(fn: Promise<Result<NodeJS.ReadableStream, ServiceError | NodeJS.ReadableStream>>): Promise<Result<NodeJS.ReadableStream, NodeJS.ReadableStream | ServiceError>>;
|
|
11
|
+
portalGenerationError(error: string): void;
|
|
12
|
+
portalGenerationServiceError(serviceError: ServiceError): void;
|
|
13
|
+
portalGenerationErrorWithReport(reportPath: FilePath): void;
|
|
14
|
+
portalGenerated(portal: DirectoryPath): void;
|
|
10
15
|
}
|
|
@@ -1,62 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
this.spin = (0, prompts_1.spinner)();
|
|
10
|
-
}
|
|
11
|
-
async overwriteExistingPortalArtifactsPrompt() {
|
|
12
|
-
const useExistingFolder = await (0, prompts_1.select)({
|
|
13
|
-
message: `The destination folder is not empty, do you want to overwrite the existing files?`,
|
|
14
|
-
options: [
|
|
15
|
-
{ value: "yes", label: "Yes" },
|
|
16
|
-
{ value: "no", label: "No" }
|
|
17
|
-
]
|
|
1
|
+
import { isCancel, confirm, log } from "@clack/prompts";
|
|
2
|
+
import { format as f } from "../format.js";
|
|
3
|
+
import { withSpinner } from "../prompt.js";
|
|
4
|
+
export class PortalGeneratePrompts {
|
|
5
|
+
async overwritePortal(directory) {
|
|
6
|
+
const overwrite = await confirm({
|
|
7
|
+
message: `The destination ${f.path(directory)} is not empty, do you want to overwrite?`,
|
|
8
|
+
initialValue: false
|
|
18
9
|
});
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
return process.exit(1);
|
|
10
|
+
if (isCancel(overwrite)) {
|
|
11
|
+
return false;
|
|
22
12
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if ((0, axios_1.isCancel)(useExistingZip)) {
|
|
37
|
-
(0, prompts_1.cancel)("Operation cancelled.");
|
|
38
|
-
return process.exit(1);
|
|
39
|
-
}
|
|
40
|
-
if (useExistingZip === "no") {
|
|
41
|
-
(0, prompts_1.outro)("Please enter a different destination path or delete the existing zip file and try again.");
|
|
42
|
-
}
|
|
43
|
-
return useExistingZip === "yes";
|
|
13
|
+
return overwrite;
|
|
14
|
+
}
|
|
15
|
+
directoryCannotBeSame(directory) {
|
|
16
|
+
const message = `The ${f.var("src")} and ${f.var("portal")} directories must be different. Current value: ${f.path(directory)}`;
|
|
17
|
+
log.error(message);
|
|
18
|
+
}
|
|
19
|
+
srcDirectoryEmpty(directory) {
|
|
20
|
+
const message = `The ${f.var("src")} directory is either empty or invalid: ${f.path(directory)}`;
|
|
21
|
+
log.error(message);
|
|
22
|
+
}
|
|
23
|
+
portalDirectoryNotEmpty() {
|
|
24
|
+
const message = `Please enter a different destination folder or remove the existing files and try again.`;
|
|
25
|
+
log.error(message);
|
|
44
26
|
}
|
|
45
|
-
|
|
46
|
-
|
|
27
|
+
generatePortal(fn) {
|
|
28
|
+
return withSpinner("Generating portal", "Portal generated successfully.", "Portal Generation failed.", fn);
|
|
47
29
|
}
|
|
48
|
-
|
|
49
|
-
|
|
30
|
+
portalGenerationError(error) {
|
|
31
|
+
log.error(error);
|
|
50
32
|
}
|
|
51
|
-
|
|
52
|
-
|
|
33
|
+
portalGenerationServiceError(serviceError) {
|
|
34
|
+
log.error(serviceError.errorMessage);
|
|
53
35
|
}
|
|
54
|
-
|
|
55
|
-
|
|
36
|
+
portalGenerationErrorWithReport(reportPath) {
|
|
37
|
+
const message = `An error occurred during portal generation.
|
|
38
|
+
A report has been written at the destination path ${f.path(reportPath)}`;
|
|
39
|
+
log.error(message);
|
|
56
40
|
}
|
|
57
|
-
|
|
58
|
-
(
|
|
41
|
+
portalGenerated(portal) {
|
|
42
|
+
log.info(`Portal artifacts can be found at ${f.path(portal)}.`);
|
|
59
43
|
}
|
|
60
44
|
}
|
|
61
|
-
|
|
62
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2VuZXJhdGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvcHJvbXB0cy9wb3J0YWwvZ2VuZXJhdGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsNENBQWdFO0FBQ2hFLGlDQUFpQztBQUNqQyw2Q0FBeUQ7QUFFekQsTUFBYSxxQkFBcUI7SUFBbEM7UUFDbUIsU0FBSSxHQUFHLElBQUEsaUJBQU8sR0FBRSxDQUFDO0lBK0RwQyxDQUFDO0lBN0RDLEtBQUssQ0FBQyxzQ0FBc0M7UUFDMUMsTUFBTSxpQkFBaUIsR0FBRyxNQUFNLElBQUEsZ0JBQU0sRUFB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