Skip to content

Commit

Permalink
Remove path usage so it works in the browser
Browse files Browse the repository at this point in the history
  • Loading branch information
BruceWouaigne committed Jan 3, 2025
1 parent fdc420e commit 22514e1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
14 changes: 13 additions & 1 deletion src/__tests__/linkup-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
LinkupUnknownError,
} from '../errors';
import { z } from 'zod';
import { readFileSync } from 'fs';
import { join } from 'path';

jest.mock('axios');
const maxios = axios as jest.Mocked<typeof axios>;
Expand Down Expand Up @@ -43,7 +45,7 @@ describe('LinkupClient', () => {
baseURL: 'https://api.linkup.so/v1',
headers: {
Authorization: 'Bearer 1234',
'User-Agent': 'Linkup-JS-SDK/1.0.1',
'User-Agent': `Linkup-JS-SDK/${getVersionFromPackage()}`,
},
},
);
Expand Down Expand Up @@ -221,3 +223,13 @@ describe('LinkupClient', () => {
.catch((e) => expect(e).toBeInstanceOf(LinkupInvalidRequestError));
});
});

function getVersionFromPackage(): string {
try {
const packagePath = join(__dirname, '..', '..', 'package.json');
const packageJson = JSON.parse(readFileSync(packagePath, 'utf8'));
return packageJson.version;
} catch {
throw new Error('Could not read package version');
}
}
5 changes: 0 additions & 5 deletions src/__tests__/utils/version.utils.test.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/linkup-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ import {
StructuredOutputSchema,
LinkupSearchResponse,
} from './types';
import { getVersionFromPackage } from './utils/version.utils';
import zodToJsonSchema from 'zod-to-json-schema';
import { ZodObject, ZodRawShape } from 'zod';
import { isZodObject } from './utils/schema.utils';

export class LinkupClient {
private readonly USER_AGENT = `Linkup-JS-SDK/${getVersionFromPackage()}`;
private readonly USER_AGENT = 'Linkup-JS-SDK/1.0.1';
private readonly apiKey: string;
private readonly baseUrl: string;

Expand Down
12 changes: 0 additions & 12 deletions src/utils/version.utils.ts

This file was deleted.

0 comments on commit 22514e1

Please sign in to comment.