Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ $ npm install -g @apimatic/cli
$ apimatic COMMAND
running command...
$ apimatic (--version)
@apimatic/cli/1.1.0-beta.5 win32-x64 node-v23.4.0
@apimatic/cli/1.1.0-beta.6 win32-x64 node-v23.4.0
$ apimatic --help [COMMAND]
USAGE
$ apimatic COMMAND
Expand Down
120 changes: 61 additions & 59 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"test": "tsx node_modules/mocha/bin/_mocha --forbid-only \"test/**/*.test.ts\" --timeout 99999"
},
"dependencies": {
"@apimatic/sdk": "^0.2.0-alpha.5",
"@apimatic/sdk": "^0.2.0-alpha.6",
"@clack/prompts": "1.0.0-alpha.1",
"@oclif/core": "^4.2.8",
"@oclif/plugin-autocomplete": "^3.2.24",
Expand Down
20 changes: 17 additions & 3 deletions src/infrastructure/services/portal-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
TransformationController,
Transformation,
ExportFormats,
Platforms
Platforms,
Status
} from "@apimatic/sdk";
import { AuthInfo, getAuthInfo } from "../../client-utils/auth-manager.js";
import { parseStreamBodyToJson } from "../../utils/utils.js";
Expand Down Expand Up @@ -58,6 +59,7 @@ export class PortalService {
generationId = portalInstance.result.id;
} catch (error) {
if (error instanceof ProblemDetailsError) {
// TODO: This only picks the first error message, improve it to show all errors.
const message = Object.values(error.result!.errors as Record<string, string[]>)[0]?.[0] ?? null;
const errorMessage = error.result!.title + "\n- " + message;
if (error.statusCode === 400) {
Expand Down Expand Up @@ -85,10 +87,22 @@ export class PortalService {
if (statusResult.isErr()) {
return err(statusResult.error);
}
if (statusResult.value.status === "Failed") {
if (statusResult.value.status === Status.Failed) {
return err(ServiceError.ServerError);
}
} while (statusResult.value.status !== "Completed");
if (statusResult.value.errors && statusResult.value.status === Status.ValidationError) {
// TODO: This only picks the first error message, improve it to show all errors.
const message = Object.values(statusResult.value.errors as Record<string, string[]>)[0]?.[0] ?? null;
const errorMessage = "One or more validation errors occurred." + "\n- " + message;
return err(ServiceError.badRequest(errorMessage));
}
if (statusResult.value.errors && statusResult.value.status === Status.SubscriptionError) {
// TODO: This only picks the first error message, improve it to show all errors.
const message = Object.values(statusResult.value.errors as Record<string, string[]>)[0]?.[0] ?? null;
const errorMessage = "Access denied to resource." + "\n- " + message;
return err(ServiceError.forbidden(errorMessage));
}
} while (statusResult.value.status !== Status.Completed);

try {
const portalDownloadResponse = await docsPortalAsyncController.downloadGeneratedPortal(generationId);
Expand Down