Skip to content
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.

Commit

Permalink
chore: Using serverUrl from openapi rather than hard-coding in client
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyxiao committed Nov 20, 2023
1 parent f9cbcc9 commit ede7916
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/core/remotes/impl/apollo/apollo.client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createOpenapiClient } from '../../utils/createOpenapiClient';

import type { paths } from './apollo.openapi.gen';
import oas from './apollo.openapi.json';

interface ApolloCredentials {
apiKey: string;
Expand All @@ -9,7 +10,7 @@ interface ApolloCredentials {
export type ApolloClient = ReturnType<typeof createApolloClient>;
export function createApolloClient(creds: ApolloCredentials) {
return createOpenapiClient<paths>({
baseUrl: 'https://app.apollo.io/api',
baseUrl: oas.servers[0].url,
preRequest(input, init) {
if (input && init?.method?.toLowerCase() === 'get') {
const url = new URL(input);
Expand Down
3 changes: 2 additions & 1 deletion packages/core/remotes/impl/outreach/outreach.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { OAuthClientOptions } from '../../utils/createOpenapiClient';
import { createOpenapiOauthClient, HTTPError } from '../../utils/createOpenapiClient';

import type { paths } from './outreach.openapi.gen';
import oas from './outreach.openapi.json';

interface OutreachCredentials {
accessToken: string;
Expand All @@ -19,7 +20,7 @@ export function createOutreachClient({
}: { credentials: OutreachCredentials } & Pick<OAuthClientOptions, 'onTokenRefreshed'>) {
// Maybe worth modifying the outreach openapi spec with refresh token tools
return createOpenapiOauthClient<paths>({
baseUrl: 'https://api.outreach.io/api/v2',
baseUrl: oas.servers[0].url,
...options,
tokens: creds,
refreshTokens: async (client) => {
Expand Down
3 changes: 2 additions & 1 deletion packages/core/remotes/impl/salesloft/salesloft.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { OAuthClientOptions } from '../../utils/createOpenapiClient';
import { createOpenapiOauthClient } from '../../utils/createOpenapiClient';

import type { paths } from './salesloft.openapi.gen';
import oas from './salesloft.openapi.json';

interface SalesloftCredentials {
accessToken: string;
Expand All @@ -18,7 +19,7 @@ export function createSalesloftClient({
...options
}: { credentials: SalesloftCredentials } & Pick<OAuthClientOptions, 'onTokenRefreshed'>) {
return createOpenapiOauthClient<paths>({
baseUrl: ' https://api.salesloft.com',
baseUrl: oas.servers[0].url,
...options,
tokens: creds,
refreshTokens: async (client) =>
Expand Down
3 changes: 2 additions & 1 deletion packages/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"compilerOptions": {
"outDir": "dist",
"rootDir": ".",
"moduleResolution": "node16"
"moduleResolution": "node16",
"resolveJsonModule": true
},
"include": ["./**/*.ts"]
}
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"outDir": "dist",
"moduleResolution": "node",
"target": "esnext",
"lib": ["es6"]
"lib": ["es6"],
"resolveJsonModule": true
},
"exclude": ["node_modules", "dist"]
}

0 comments on commit ede7916

Please sign in to comment.