Skip to content
Closed
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
42 changes: 38 additions & 4 deletions src/__tests__/linkup-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ describe('LinkupClient', () => {
mockAxiosInstance.post.mockResolvedValueOnce({
data: { answer: '' },
} as AxiosResponse);
const fromDate = new Date('2025-01-01');
const toDate = new Date('2025-01-02');
const fromDate = new Date('2025-01-01T12:34:56.000Z');
const toDate = new Date('2025-01-02T23:45:01.000Z');

await underTest.search({
depth: 'deep',
Expand All @@ -93,14 +93,14 @@ describe('LinkupClient', () => {
expect(mockAxiosInstance.post).toHaveBeenCalledWith('/search', {
depth: 'deep',
excludeDomains: ['baz.com', 'qux.com'],
fromDate: fromDate.toISOString(),
fromDate: '2025-01-01',
includeDomains: ['foo.com', 'bar.com'],
includeImages: true,
includeInlineCitations: true,
maxResults: 10,
outputType: 'sourcedAnswer',
q: 'foo',
toDate: toDate.toISOString(),
toDate: '2025-01-02',
});
});

Expand Down Expand Up @@ -366,6 +366,40 @@ describe('LinkupClient', () => {
});

describe('research methods', () => {
it('should serialize research date filters as ISO dates', async () => {
mockAxiosInstance.post.mockResolvedValueOnce({
data: {
createdAt: '2026-05-18T00:00:00.000Z',
error: null,
id: '2dbcc4bb-2c0d-4bcb-aaf5-44f7cbcf4eee',
input: {
fromDate: '2025-01-01',
outputType: 'sourcedAnswer',
q: 'What changed?',
toDate: '2025-01-02',
},
output: null,
status: 'pending',
type: 'research',
updatedAt: '2026-05-18T00:00:00.000Z',
},
} as AxiosResponse);

await underTest.research({
fromDate: new Date('2025-01-01T12:34:56.000Z'),
outputType: 'sourcedAnswer',
query: 'What changed?',
toDate: new Date('2025-01-02T23:45:01.000Z'),
});

expect(mockAxiosInstance.post).toHaveBeenCalledWith('/research', {
fromDate: '2025-01-01',
outputType: 'sourcedAnswer',
q: 'What changed?',
toDate: '2025-01-02',
});
});

it('should create a research task and normalize the returned input', async () => {
mockAxiosInstance.post.mockResolvedValueOnce({
data: {
Expand Down
12 changes: 8 additions & 4 deletions src/linkup-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ export class LinkupClient {
...(includeImages && { includeImages }),
...(includeDomains && { includeDomains }),
...(excludeDomains && { excludeDomains }),
...(fromDate && { fromDate: fromDate.toISOString() }),
...(toDate && { toDate: toDate.toISOString() }),
...(fromDate && { fromDate: this.serializeDate(fromDate) }),
...(toDate && { toDate: this.serializeDate(toDate) }),
...(maxResults && { maxResults }),
};

Expand Down Expand Up @@ -203,8 +203,8 @@ export class LinkupClient {
q: query,
...(includeDomains && { includeDomains }),
...(excludeDomains && { excludeDomains }),
...(fromDate && { fromDate: fromDate.toISOString() }),
...(toDate && { toDate: toDate.toISOString() }),
...(fromDate && { fromDate: this.serializeDate(fromDate) }),
...(toDate && { toDate: this.serializeDate(toDate) }),
...(mode && { mode }),
...(reasoningDepth && { reasoningDepth }),
};
Expand All @@ -224,6 +224,10 @@ export class LinkupClient {
);
}

private serializeDate(date: Date): string {
return date.toISOString().slice(0, 10);
}

private sanitizeTaskRequest(task: TaskRequest): {
input: SanitizedParams | FetchParams;
type: string;
Expand Down