Skip to content

Commit

Permalink
feat: connectedAccount fix
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu-dixit committed Dec 9, 2024
1 parent 633f47f commit 06f7888
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
12 changes: 8 additions & 4 deletions js/src/cli/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ import { Command } from "commander";
import { getOpenAPIClient } from "../sdk/utils/config";
import client from "../sdk/client/client";

// @ts-ignore
import resolvePackagePath from "resolve-package-path";
import fs from "fs";
import path from "path";

type ErrorWithMessage = {
message: string;
};

export default class AppsCommand {
private program: Command;

Expand All @@ -34,7 +38,7 @@ export default class AppsCommand {
console.log(app.key);
}
} catch (error) {
console.log(chalk.red((error as any).message));
console.log(chalk.red((error as ErrorWithMessage).message));
return;
}
}
Expand Down Expand Up @@ -77,7 +81,7 @@ class AppUpdateCommand {
}
} catch (e) {
console.log(chalk.red("Error while updating constants file"));
console.log(chalk.red((e as any).message));
console.log(chalk.red((e as ErrorWithMessage).message));
}

const constantFile = fs.readFileSync(constantFilePath, "utf8");
Expand All @@ -100,7 +104,7 @@ class AppUpdateCommand {
);
} catch (e) {
console.log(chalk.red("Error while updating constants file"));
console.log(chalk.red((e as any).message));
console.log(chalk.red((e as ErrorWithMessage).message));
}
}

Expand Down
14 changes: 8 additions & 6 deletions js/src/sdk/models/connectedAccounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import {
GetConnectionInfoData,
GetConnectionInfoResponse,
GetConnectionsData,
InitiateConnectionResponse2,
} from "../client";
import client from "../client/client";
import apiClient from "../client/client";
import { BackendClient } from "./backendClient";
import { Integrations } from "./integrations";
import { Apps } from "./apps";
import { CEG } from "../utils/error";
import { SDK_ERROR_CODES } from "../utils/errors/src/constants";

type ConnectedAccountsListData = GetConnectionsData["query"] & {
appNames?: string;
Expand Down Expand Up @@ -53,13 +55,13 @@ export class ConnectedAccounts {
try {
const { data: res } = await apiClient.connections.initiateConnection({
body: data,
}) as { data: InitiateConnectionResponse2 };

return new ConnectionRequest({
connectionStatus: res.connectionStatus,
connectedAccountId: res.connectedAccountId,
redirectUri: res.redirectUrl ?? null
});
//@ts-ignore
return new ConnectionRequest(
res.connectionStatus,
res.connectedAccountId,
res.redirectUrl
);
} catch (error) {
throw CEG.handleAllError(error);
}
Expand Down
1 change: 1 addition & 0 deletions js/src/sdk/utils/errors/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const SDK_ERROR_CODES = {
},
SDK: {
NO_CONNECTED_ACCOUNT_FOUND: "SDK::NO_CONNECTED_ACCOUNT_FOUND",
FAILED_TO_INITIATE_CONNECTION: "SDK::FAILED_TO_INITIATE_CONNECTION",
},
};

Expand Down

0 comments on commit 06f7888

Please sign in to comment.