codeforge-main-affinity-sdk
v0.3.9
Published
> **Unofficial SDK** — generated from @codeforge-main/affinity-sdk's public OpenAPI specification by the [CodeForge platform](https://www.code-forge.net). Not affiliated with or endorsed by @codeforge-main/affinity-sdk.
Readme
Unofficial SDK — generated from @codeforge-main/affinity-sdk's public OpenAPI specification by the CodeForge platform. Not affiliated with or endorsed by @codeforge-main/affinity-sdk.
codeforge-main-affinity-sdk
Version 0.3.9
Full generator behavior documentation: https://www.code-forge.net/docs
Requires Node 20+ (or a modern browser) — the generated transport uses AbortSignal.any
and AbortSignal.timeout.
Install
npm install codeforge-main-affinity-sdkyarn add codeforge-main-affinity-sdkpnpm add codeforge-main-affinity-sdkUsage
This SDK is exposed as a single, fully typed client class. Construct it once with your shared configuration and call any API operation as a method — each returns the deserialized response alongside HTTP metadata.
import { AffinityApiV2Client } from 'codeforge-main-affinity-sdk'
const client = new AffinityApiV2Client({
baseUrl: 'https://api.affinity.co',
auth: { type: 'bearer', token: 'YOUR_API_TOKEN' },
})
const response = await client.v2_authWhoamiGet()
console.log(response.status) // HTTP status code
console.log(response.data) // typed as V2AuthWhoamiGetResponseThe client holds the shared configuration (baseUrl, auth, retry, hooks).
Each method accepts a per-call context extending HttpClientContext — supply the
operation-specific payload / parameters, and override any shared field per call.
Available operations
v2_authWhoamiGetv2_callsGetv2_chatMessagesGetv2_companiesGetv2_companiesFieldsGetv2_companiesFieldsFieldIdDropdownOptionsGetv2_companiesSearchPostv2_companiesCompanyIdGetv2_companiesCompanyIdFieldsGetv2_companiesCompanyIdFieldsPatchv2_companiesCompanyIdFieldsFieldIdGetv2_companiesCompanyIdFieldsFieldIdPostv2_companiesCompanyIdFieldsFieldIdValuesGetv2_companiesCompanyIdListEntriesGetv2_companiesCompanyIdListsGetv2_companiesCompanyIdNotesGetv2_companiesCompanyIdRelationshipsGetv2_companyMergesGetv2_companyMergesPostv2_companyMergesMergeIdGetv2_duplicatesCompanySuggestionsGetv2_duplicatesPersonSuggestionsGetv2_emailsGetv2_feedbackPostv2_fieldValueChangesGetv2_filesSearchPostv2_inferredConnectionsCoworkersGetv2_inferredConnectionsInvestorExecutiveConnectionsGetv2_listsGetv2_listsPostv2_listsListIdGetv2_listsListIdFieldsGetv2_listsListIdFieldsFieldIdDropdownOptionsGetv2_listsListIdFieldsFieldIdDropdownOptionsPostv2_listsListIdFieldsFieldIdDropdownOptionsDropdownOptionIdGetv2_listsListIdFieldsFieldIdDropdownOptionsDropdownOptionIdPostv2_listsListIdFieldsFieldIdDropdownOptionsDropdownOptionIdDeletev2_listsListIdListEntriesGetv2_listsListIdListEntriesPostv2_listsListIdListEntriesSearchPostv2_listsListIdListEntriesListEntryIdGetv2_listsListIdListEntriesListEntryIdFieldValueChangesGetv2_listsListIdListEntriesListEntryIdFieldsGetv2_listsListIdListEntriesListEntryIdFieldsPatchv2_listsListIdListEntriesListEntryIdFieldsFieldIdGetv2_listsListIdListEntriesListEntryIdFieldsFieldIdPostv2_listsListIdListEntriesListEntryIdFieldsFieldIdValuesGetv2_listsListIdSavedViewsGetv2_listsListIdSavedViewsViewIdGetv2_listsListIdSavedViewsViewIdListEntriesGetv2_meetingsGetv2_meetingsMeetingIdGetv2_notesGetv2_notesPostv2_notesSearchPostv2_notesNoteIdGetv2_notesNoteIdPostv2_notesNoteIdDeletev2_notesNoteIdAttachedCompaniesGetv2_notesNoteIdAttachedOpportunitiesGetv2_notesNoteIdAttachedPersonsGetv2_notesNoteIdRepliesGetv2_opportunitiesGetv2_opportunitiesOpportunityIdGetv2_opportunitiesOpportunityIdPostv2_opportunitiesOpportunityIdDeletev2_opportunitiesOpportunityIdNotesGetv2_personMergesGetv2_personMergesPostv2_personMergesMergeIdGetv2_personsGetv2_personsPostv2_personsFieldsGetv2_personsFieldsFieldIdDropdownOptionsGetv2_personsSearchPostv2_personsPersonIdGetv2_personsPersonIdDeletev2_personsPersonIdFieldsGetv2_personsPersonIdFieldsPatchv2_personsPersonIdFieldsFieldIdGetv2_personsPersonIdFieldsFieldIdPostv2_personsPersonIdFieldsFieldIdValuesGetv2_personsPersonIdListEntriesGetv2_personsPersonIdListsGetv2_personsPersonIdNotesGetv2_personsPersonIdRelationshipsGetv2_rateLimitGetv2_remindersGetv2_remindersPostv2_remindersReminderIdGetv2_remindersReminderIdPostv2_remindersReminderIdDeletev2_semanticSearchPostv2_tasksCompanyMergesGetv2_tasksCompanyMergesTaskIdGetv2_tasksPersonMergesGetv2_tasksPersonMergesTaskIdGetv2_teamsGetv2_teamsTeamIdGetv2_transcriptsGetv2_transcriptsTranscriptIdGetv2_transcriptsTranscriptIdFragmentsGetv2_usersGetv2_usersUserIdGetv2_webhooksGetv2_webhooksPostv2_webhooksWebhookIdGetv2_webhooksWebhookIdPostv2_webhooksWebhookIdDelete
Transport
Every request goes through the same transport: a per-attempt timeout, cancellation via
AbortSignal, and an optional custom fetch.
const client = new AffinityApiV2Client({
timeoutMs: 10_000, // default 60000ms, applied fresh to each retry attempt
})
const controller = new AbortController()
setTimeout(() => controller.abort(), 5_000)
await client.v2_authWhoamiGet({ signal: controller.signal })timeoutMs is per attempt, not per call — a request that times out and then retries gets a
fresh timer on each attempt, and throws TimeoutError if every attempt times out. A
caller-triggered AbortSignal is never retried; a timeout is, under the same rule as a
network error. Streaming operations ignore timeoutMs and support only caller
cancellation.
Custom fetch
Pass a fetch implementation to route every request through it — a proxy included, via
undici's ProxyAgent:
import { ProxyAgent, fetch as undiciFetch } from 'undici'
const dispatcher = new ProxyAgent('http://localhost:8080')
const client = new AffinityApiV2Client({
fetch: (url, init) => undiciFetch(url, { ...init, dispatcher }),
})hooks.makeRequest wins when both are set — it replaces the whole transport, and fetch
is read only by the built-in one.
Raw requests
An endpoint the generated operations don’t model is still reachable, through the same auth, retries, timeout and hooks:
const { data, response } = await client.get('/v1/status')
await client.post('/v1/events', { body: { type: 'ping' } })
// the general form, for a method the verb helpers don’t cover:
await client.request({ method: 'OPTIONS', path: '/v1/status' })path is joined onto baseUrl with the URL constructor — a leading / resolves from
the origin (dropping any path segment baseUrl itself carries); a relative segment
appends after it. A plain-object body is JSON-serialized with a JSON Content-Type;
pass an already-encoded value (a string, FormData, ...) to send anything else.
data parses by the response’s own Content-Type: JSON via .json(), a textual type
via .text(), anything else as a Blob.
Errors
A non-OK response throws one of these HttpError subclasses, picked by an exact status
match first, then any >= 500 response as InternalServerError, then plain HttpError
for anything else. Every one of them is also an instanceof HttpError, so a catch-all
keeps working alongside a narrower check.
| Class | Status |
| --- | --- |
| BadRequestError | 400 |
| AuthenticationError | 401 |
| PermissionDeniedError | 403 |
| NotFoundError | 404 |
| ConflictError | 409 |
| UnprocessableEntityError | 422 |
| RateLimitError | 429 |
| InternalServerError | any >= 500 |
import { HttpError, NotFoundError } from 'codeforge-main-affinity-sdk'
try {
await client.v2_authWhoamiGet()
} catch (error) {
if (error instanceof NotFoundError) {
// error.status is narrowed to 404
} else if (error instanceof HttpError) {
// any other non-OK response — error.status is number
}
throw error
}Validation
Every model is plain data — the shape it has on the wire. This SDK carries no schemas and
no runtime dependency, so nothing is validated for you: response.data is the parsed body
typed as the operation declares it.
Regenerate the SDK with validation schemas turned on to get a zod schema exported beside every model type.
Generated by CodeForge v0.86.9.
