feat: add ContactImports class for managing contact imports#963
feat: add ContactImports class for managing contact imports#963vcapretz wants to merge 4 commits into
ContactImports class for managing contact imports#963Conversation
ContactImports class for managing contact imports
commit: |
There was a problem hiding this comment.
No issues found across 6 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: This PR adds a new ContactImports class with a list method, following the established pattern of similar sub-resources like ContactTopics and ContactSegments, includes passing tests, and only touches new files and minimal additions to existing files, making the blast radius very low.
Re-trigger cubic
…anaging contact imports
Co-authored-by: Cursor <cursoragent@cursor.com>
|
example script to create a new import: #!/usr/bin/env node
import { openAsBlob } from 'node:fs';
import { access } from 'node:fs/promises';
import path from 'node:path';
import { Resend } from '../dist/index.mjs';
const apiKey = process.env.RESEND_API_KEY;
if (!apiKey) {
console.error('Missing RESEND_API_KEY environment variable.');
process.exit(1);
}
const csvPath = path.resolve(process.cwd(), 'contacts.csv');
try {
await access(csvPath);
} catch {
console.error(`CSV file not found: ${csvPath}`);
process.exit(1);
}
const file = await openAsBlob(csvPath, { type: 'text/csv' });
const resend = new Resend(apiKey);
const result = await resend.contacts.imports.create({
file,
fileName: path.basename(csvPath),
columnMap: { email: 'Email', firstName: 'Name', lastName: 'Last Name' },
onConflict: 'skip',
onError: 'continue',
});
console.log(JSON.stringify(result, null, 2));
if (result.error) {
process.exitCode = 1;
} |
lucasfcosta
left a comment
There was a problem hiding this comment.
No blockers, but I think the fileName comment is worth looking at. Same for other cleanups.
| ) { | ||
| const headers = new Headers(this.headers); | ||
| const isFormData = | ||
| typeof FormData !== 'undefined' && entity instanceof FormData; |
There was a problem hiding this comment.
FormData is not supported on Node 16 and below, which I think it's fine as it's out of LTS and was released in 2021 and LTS ended in 2023, but just noting.
There was a problem hiding this comment.
oh yeah, at this point i wouldn't say we support Node versions older than 20 (maybe even 22)
There was a problem hiding this comment.
1 issue found across 3 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Auto-approved: This PR adds a new contact imports feature with multipart CSV uploads, including comprehensive tests and a targeted FormData handler in the HTTP client, all isolated to new functionality with minimal risk to existing code.
Re-trigger cubic
Summary by cubic
Adds
ContactImportsunderresend.contacts.importsto create, list, and get contact import jobs with multipart CSV uploads, pagination, and status filters. Also updates the client to sendFormDatacorrectly, exports the new interfaces, and bumpsresendto 6.13.0-preview-imports.0.New Features
contacts.imports(create,list,get) via/contacts/imports;createsupports multipart uploads (file) withcolumnMap,onConflict,onError,segments, andtopics;listsupports pagination andstatus(queued,in_progress,completed,failed).Contactsasimports; exported interfaces viaindex.Bug Fixes
Resend.postnow detectsFormData, removesContent-Type, and sends the form body as-is to support multipart uploads.Written for commit bf926f2. Summary will update on new commits.