codeforge-main-affinity-sdk 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -2
- package/dist/channels/http_client.d.ts +123 -1
- package/dist/channels/http_client.d.ts.map +1 -1
- package/dist/channels/http_client.js +714 -0
- package/dist/channels/http_client.js.map +1 -1
- package/dist/client/AffinityApiV2Client.d.ts +100 -2
- package/dist/client/AffinityApiV2Client.d.ts.map +1 -1
- package/dist/client/AffinityApiV2Client.js +97 -13
- package/dist/client/AffinityApiV2Client.js.map +1 -1
- package/dist/index.d.ts +29 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +48 -13
- package/dist/index.js.map +1 -1
- package/dist/parameters/V2RemindersReminderIdDeleteParameters.d.ts +47 -0
- package/dist/parameters/V2RemindersReminderIdDeleteParameters.d.ts.map +1 -0
- package/dist/parameters/V2RemindersReminderIdDeleteParameters.js +105 -0
- package/dist/parameters/V2RemindersReminderIdDeleteParameters.js.map +1 -0
- package/dist/parameters/V2RemindersReminderIdGetParameters.d.ts +47 -0
- package/dist/parameters/V2RemindersReminderIdGetParameters.d.ts.map +1 -0
- package/dist/parameters/V2RemindersReminderIdGetParameters.js +105 -0
- package/dist/parameters/V2RemindersReminderIdGetParameters.js.map +1 -0
- package/dist/parameters/V2WebhooksGetParameters.d.ts +68 -0
- package/dist/parameters/V2WebhooksGetParameters.d.ts.map +1 -0
- package/dist/parameters/V2WebhooksGetParameters.js +185 -0
- package/dist/parameters/V2WebhooksGetParameters.js.map +1 -0
- package/dist/parameters/V2WebhooksWebhookIdDeleteParameters.d.ts +47 -0
- package/dist/parameters/V2WebhooksWebhookIdDeleteParameters.d.ts.map +1 -0
- package/dist/parameters/V2WebhooksWebhookIdDeleteParameters.js +105 -0
- package/dist/parameters/V2WebhooksWebhookIdDeleteParameters.js.map +1 -0
- package/dist/parameters/V2WebhooksWebhookIdGetParameters.d.ts +47 -0
- package/dist/parameters/V2WebhooksWebhookIdGetParameters.d.ts.map +1 -0
- package/dist/parameters/V2WebhooksWebhookIdGetParameters.js +105 -0
- package/dist/parameters/V2WebhooksWebhookIdGetParameters.js.map +1 -0
- package/dist/parameters/V2WebhooksWebhookIdPostParameters.d.ts +47 -0
- package/dist/parameters/V2WebhooksWebhookIdPostParameters.d.ts.map +1 -0
- package/dist/parameters/V2WebhooksWebhookIdPostParameters.js +105 -0
- package/dist/parameters/V2WebhooksWebhookIdPostParameters.js.map +1 -0
- package/dist/payloads/CompanyMergeStateStatus.d.ts +10 -0
- package/dist/payloads/CompanyMergeStateStatus.d.ts.map +1 -0
- package/dist/payloads/CompanyMergeStateStatus.js +13 -0
- package/dist/payloads/CompanyMergeStateStatus.js.map +1 -0
- package/dist/payloads/PersonMergeStateStatus.d.ts +10 -0
- package/dist/payloads/PersonMergeStateStatus.d.ts.map +1 -0
- package/dist/payloads/PersonMergeStateStatus.js +13 -0
- package/dist/payloads/PersonMergeStateStatus.js.map +1 -0
- package/dist/payloads/Status.d.ts +4 -4
- package/dist/payloads/Status.d.ts.map +1 -1
- package/dist/payloads/Status.js +4 -4
- package/dist/payloads/Status.js.map +1 -1
- package/dist/payloads/V2RemindersReminderIdDeleteResponse.d.ts +7 -0
- package/dist/payloads/V2RemindersReminderIdDeleteResponse.d.ts.map +1 -0
- package/dist/payloads/V2RemindersReminderIdDeleteResponse.js +3 -0
- package/dist/payloads/V2RemindersReminderIdDeleteResponse.js.map +1 -0
- package/dist/payloads/V2RemindersReminderIdGetResponse.d.ts +8 -0
- package/dist/payloads/V2RemindersReminderIdGetResponse.d.ts.map +1 -0
- package/dist/payloads/V2RemindersReminderIdGetResponse.js +3 -0
- package/dist/payloads/V2RemindersReminderIdGetResponse.js.map +1 -0
- package/dist/payloads/V2RemindersReminderIdGetResponsePersonReference.d.ts +11 -0
- package/dist/payloads/V2RemindersReminderIdGetResponsePersonReference.d.ts.map +1 -0
- package/dist/payloads/V2RemindersReminderIdGetResponsePersonReference.js +3 -0
- package/dist/payloads/V2RemindersReminderIdGetResponsePersonReference.js.map +1 -0
- package/dist/payloads/V2WebhooksGetResponse.d.ts +7 -0
- package/dist/payloads/V2WebhooksGetResponse.d.ts.map +1 -0
- package/dist/payloads/V2WebhooksGetResponse.js +3 -0
- package/dist/payloads/V2WebhooksGetResponse.js.map +1 -0
- package/dist/payloads/V2WebhooksGetResponseOneOf_0DataItemStatus.d.ts +10 -0
- package/dist/payloads/V2WebhooksGetResponseOneOf_0DataItemStatus.d.ts.map +1 -0
- package/dist/payloads/V2WebhooksGetResponseOneOf_0DataItemStatus.js +13 -0
- package/dist/payloads/V2WebhooksGetResponseOneOf_0DataItemStatus.js.map +1 -0
- package/dist/payloads/V2WebhooksPostResponse.d.ts +7 -0
- package/dist/payloads/V2WebhooksPostResponse.d.ts.map +1 -0
- package/dist/payloads/V2WebhooksPostResponse.js +3 -0
- package/dist/payloads/V2WebhooksPostResponse.js.map +1 -0
- package/dist/payloads/V2WebhooksPostResponseOneOf_0Status.d.ts +10 -0
- package/dist/payloads/V2WebhooksPostResponseOneOf_0Status.d.ts.map +1 -0
- package/dist/payloads/V2WebhooksPostResponseOneOf_0Status.js +13 -0
- package/dist/payloads/V2WebhooksPostResponseOneOf_0Status.js.map +1 -0
- package/dist/payloads/V2WebhooksWebhookIdDeleteResponse.d.ts +6 -0
- package/dist/payloads/V2WebhooksWebhookIdDeleteResponse.d.ts.map +1 -0
- package/dist/payloads/V2WebhooksWebhookIdDeleteResponse.js +3 -0
- package/dist/payloads/V2WebhooksWebhookIdDeleteResponse.js.map +1 -0
- package/dist/payloads/V2WebhooksWebhookIdGetResponse.d.ts +7 -0
- package/dist/payloads/V2WebhooksWebhookIdGetResponse.d.ts.map +1 -0
- package/dist/payloads/V2WebhooksWebhookIdGetResponse.js +3 -0
- package/dist/payloads/V2WebhooksWebhookIdGetResponse.js.map +1 -0
- package/dist/payloads/V2WebhooksWebhookIdGetResponseOneOf_0Status.d.ts +10 -0
- package/dist/payloads/V2WebhooksWebhookIdGetResponseOneOf_0Status.d.ts.map +1 -0
- package/dist/payloads/V2WebhooksWebhookIdGetResponseOneOf_0Status.js +13 -0
- package/dist/payloads/V2WebhooksWebhookIdGetResponseOneOf_0Status.js.map +1 -0
- package/dist/payloads/V2WebhooksWebhookIdPostResponse.d.ts +6 -0
- package/dist/payloads/V2WebhooksWebhookIdPostResponse.d.ts.map +1 -0
- package/dist/payloads/V2WebhooksWebhookIdPostResponse.js +3 -0
- package/dist/payloads/V2WebhooksWebhookIdPostResponse.js.map +1 -0
- package/dist/payloads/WebhooksSubscriptionType.d.ts +38 -0
- package/dist/payloads/WebhooksSubscriptionType.d.ts.map +1 -0
- package/dist/payloads/WebhooksSubscriptionType.js +41 -0
- package/dist/payloads/WebhooksSubscriptionType.js.map +1 -0
- package/dist/payloads/WebhooksWebhook.d.ts +41 -0
- package/dist/payloads/WebhooksWebhook.d.ts.map +1 -0
- package/dist/payloads/WebhooksWebhook.js +3 -0
- package/dist/payloads/WebhooksWebhook.js.map +1 -0
- package/dist/payloads/WebhooksWebhookPaged.d.ts +14 -0
- package/dist/payloads/WebhooksWebhookPaged.d.ts.map +1 -0
- package/dist/payloads/WebhooksWebhookPaged.js +3 -0
- package/dist/payloads/WebhooksWebhookPaged.js.map +1 -0
- package/dist/payloads/WebhooksWebhookPaged1.d.ts +14 -0
- package/dist/payloads/WebhooksWebhookPaged1.d.ts.map +1 -0
- package/dist/payloads/WebhooksWebhookPaged1.js +3 -0
- package/dist/payloads/WebhooksWebhookPaged1.js.map +1 -0
- package/dist/payloads/WebhooksWebhookPagedDataItemStatus.d.ts +10 -0
- package/dist/payloads/WebhooksWebhookPagedDataItemStatus.d.ts.map +1 -0
- package/dist/payloads/WebhooksWebhookPagedDataItemStatus.js +13 -0
- package/dist/payloads/WebhooksWebhookPagedDataItemStatus.js.map +1 -0
- package/dist/payloads/WebhooksWebhookPagedPaginationWithTotalCount.d.ts +16 -0
- package/dist/payloads/WebhooksWebhookPagedPaginationWithTotalCount.d.ts.map +1 -0
- package/dist/payloads/WebhooksWebhookPagedPaginationWithTotalCount.js +3 -0
- package/dist/payloads/WebhooksWebhookPagedPaginationWithTotalCount.js.map +1 -0
- package/dist/payloads/WebhooksWebhookStatus.d.ts +10 -0
- package/dist/payloads/WebhooksWebhookStatus.d.ts.map +1 -0
- package/dist/payloads/WebhooksWebhookStatus.js +13 -0
- package/dist/payloads/WebhooksWebhookStatus.js.map +1 -0
- package/dist/payloads/WebhooksWebhookToBeCreated.d.ts +17 -0
- package/dist/payloads/WebhooksWebhookToBeCreated.d.ts.map +1 -0
- package/dist/payloads/WebhooksWebhookToBeCreated.js +3 -0
- package/dist/payloads/WebhooksWebhookToBeCreated.js.map +1 -0
- package/dist/payloads/WebhooksWebhookToBeUpdated.d.ts +23 -0
- package/dist/payloads/WebhooksWebhookToBeUpdated.d.ts.map +1 -0
- package/dist/payloads/WebhooksWebhookToBeUpdated.js +3 -0
- package/dist/payloads/WebhooksWebhookToBeUpdated.js.map +1 -0
- package/dist/types/Types.d.ts +2 -2
- package/dist/types/Types.d.ts.map +1 -1
- package/dist/types/Types.js +28 -1
- package/dist/types/Types.js.map +1 -1
- package/package.json +1 -1
|
@@ -80,6 +80,8 @@ exports.v2_personsPersonIdNotesGet = v2_personsPersonIdNotesGet;
|
|
|
80
80
|
exports.v2_personsPersonIdRelationshipsGet = v2_personsPersonIdRelationshipsGet;
|
|
81
81
|
exports.v2_remindersGet = v2_remindersGet;
|
|
82
82
|
exports.v2_remindersPost = v2_remindersPost;
|
|
83
|
+
exports.v2_remindersReminderIdGet = v2_remindersReminderIdGet;
|
|
84
|
+
exports.v2_remindersReminderIdDelete = v2_remindersReminderIdDelete;
|
|
83
85
|
exports.v2_semanticSearchPost = v2_semanticSearchPost;
|
|
84
86
|
exports.v2_tasksCompanyMergesGet = v2_tasksCompanyMergesGet;
|
|
85
87
|
exports.v2_tasksCompanyMergesTaskIdGet = v2_tasksCompanyMergesTaskIdGet;
|
|
@@ -90,6 +92,11 @@ exports.v2_transcriptsTranscriptIdGet = v2_transcriptsTranscriptIdGet;
|
|
|
90
92
|
exports.v2_transcriptsTranscriptIdFragmentsGet = v2_transcriptsTranscriptIdFragmentsGet;
|
|
91
93
|
exports.v2_usersGet = v2_usersGet;
|
|
92
94
|
exports.v2_usersUserIdGet = v2_usersUserIdGet;
|
|
95
|
+
exports.v2_webhooksGet = v2_webhooksGet;
|
|
96
|
+
exports.v2_webhooksPost = v2_webhooksPost;
|
|
97
|
+
exports.v2_webhooksWebhookIdGet = v2_webhooksWebhookIdGet;
|
|
98
|
+
exports.v2_webhooksWebhookIdPost = v2_webhooksWebhookIdPost;
|
|
99
|
+
exports.v2_webhooksWebhookIdDelete = v2_webhooksWebhookIdDelete;
|
|
93
100
|
const V2CallsGetParameters_js_1 = require("./../parameters/V2CallsGetParameters.js");
|
|
94
101
|
const V2ChatMessagesGetParameters_js_1 = require("./../parameters/V2ChatMessagesGetParameters.js");
|
|
95
102
|
const V2CompaniesGetParameters_js_1 = require("./../parameters/V2CompaniesGetParameters.js");
|
|
@@ -159,6 +166,8 @@ const V2PersonsPersonIdListsGetParameters_js_1 = require("./../parameters/V2Pers
|
|
|
159
166
|
const V2PersonsPersonIdNotesGetParameters_js_1 = require("./../parameters/V2PersonsPersonIdNotesGetParameters.js");
|
|
160
167
|
const V2PersonsPersonIdRelationshipsGetParameters_js_1 = require("./../parameters/V2PersonsPersonIdRelationshipsGetParameters.js");
|
|
161
168
|
const V2RemindersGetParameters_js_1 = require("./../parameters/V2RemindersGetParameters.js");
|
|
169
|
+
const V2RemindersReminderIdGetParameters_js_1 = require("./../parameters/V2RemindersReminderIdGetParameters.js");
|
|
170
|
+
const V2RemindersReminderIdDeleteParameters_js_1 = require("./../parameters/V2RemindersReminderIdDeleteParameters.js");
|
|
162
171
|
const V2TasksCompanyMergesGetParameters_js_1 = require("./../parameters/V2TasksCompanyMergesGetParameters.js");
|
|
163
172
|
const V2TasksCompanyMergesTaskIdGetParameters_js_1 = require("./../parameters/V2TasksCompanyMergesTaskIdGetParameters.js");
|
|
164
173
|
const V2TasksPersonMergesGetParameters_js_1 = require("./../parameters/V2TasksPersonMergesGetParameters.js");
|
|
@@ -168,6 +177,10 @@ const V2TranscriptsTranscriptIdGetParameters_js_1 = require("./../parameters/V2T
|
|
|
168
177
|
const V2TranscriptsTranscriptIdFragmentsGetParameters_js_1 = require("./../parameters/V2TranscriptsTranscriptIdFragmentsGetParameters.js");
|
|
169
178
|
const V2UsersGetParameters_js_1 = require("./../parameters/V2UsersGetParameters.js");
|
|
170
179
|
const V2UsersUserIdGetParameters_js_1 = require("./../parameters/V2UsersUserIdGetParameters.js");
|
|
180
|
+
const V2WebhooksGetParameters_js_1 = require("./../parameters/V2WebhooksGetParameters.js");
|
|
181
|
+
const V2WebhooksWebhookIdGetParameters_js_1 = require("./../parameters/V2WebhooksWebhookIdGetParameters.js");
|
|
182
|
+
const V2WebhooksWebhookIdPostParameters_js_1 = require("./../parameters/V2WebhooksWebhookIdPostParameters.js");
|
|
183
|
+
const V2WebhooksWebhookIdDeleteParameters_js_1 = require("./../parameters/V2WebhooksWebhookIdDeleteParameters.js");
|
|
171
184
|
// ============================================================================
|
|
172
185
|
// Common Types - Shared across all HTTP client functions
|
|
173
186
|
// ============================================================================
|
|
@@ -8888,6 +8901,201 @@ async function v2_remindersPost(context) {
|
|
|
8888
8901
|
throw error;
|
|
8889
8902
|
}
|
|
8890
8903
|
}
|
|
8904
|
+
/**
|
|
8905
|
+
* | ⚠️ This endpoint is currently in BETA |
|
|
8906
|
+
* |--|
|
|
8907
|
+
*
|
|
8908
|
+
* Returns a single Reminder. Responds with `404` when the reminder does not exist or is not visible to the caller.
|
|
8909
|
+
*
|
|
8910
|
+
*/
|
|
8911
|
+
async function v2_remindersReminderIdGet(context) {
|
|
8912
|
+
// Apply defaults
|
|
8913
|
+
const config = {
|
|
8914
|
+
baseUrl: 'https://api.affinity.co',
|
|
8915
|
+
...context,
|
|
8916
|
+
};
|
|
8917
|
+
const parameters = context.parameters instanceof V2RemindersReminderIdGetParameters_js_1.V2RemindersReminderIdGetParameters ? context.parameters : new V2RemindersReminderIdGetParameters_js_1.V2RemindersReminderIdGetParameters(context.parameters);
|
|
8918
|
+
// Validate OAuth2 config if present
|
|
8919
|
+
if (config.auth?.type === 'oauth2' && AUTH_FEATURES.oauth2) {
|
|
8920
|
+
validateOAuth2Config(config.auth);
|
|
8921
|
+
}
|
|
8922
|
+
// Build headers
|
|
8923
|
+
let headers = { 'Content-Type': 'application/json', ...config.additionalHeaders };
|
|
8924
|
+
// Build URL
|
|
8925
|
+
let url = buildUrlWithParameters(config.baseUrl, '/v2/reminders/{reminderId}', parameters);
|
|
8926
|
+
url = applyQueryParams(config.additionalQueryParams, url);
|
|
8927
|
+
// Apply authentication
|
|
8928
|
+
const authResult = applyAuth(config.auth, headers, url);
|
|
8929
|
+
headers = authResult.headers;
|
|
8930
|
+
url = authResult.url;
|
|
8931
|
+
// Prepare body
|
|
8932
|
+
const body = undefined;
|
|
8933
|
+
// Determine request function - a custom fetch is read only by the built-in
|
|
8934
|
+
// makeRequest, so it is bound in here rather than passed to executeWithRetry.
|
|
8935
|
+
const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
|
|
8936
|
+
// Build request params
|
|
8937
|
+
let requestParams = {
|
|
8938
|
+
url,
|
|
8939
|
+
method: 'GET',
|
|
8940
|
+
headers,
|
|
8941
|
+
body,
|
|
8942
|
+
signal: context.signal
|
|
8943
|
+
};
|
|
8944
|
+
// Apply beforeRequest hook
|
|
8945
|
+
if (config.hooks?.beforeRequest) {
|
|
8946
|
+
requestParams = await config.hooks.beforeRequest(requestParams);
|
|
8947
|
+
}
|
|
8948
|
+
try {
|
|
8949
|
+
// Execute request with retry logic
|
|
8950
|
+
let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
8951
|
+
// Apply afterResponse hook
|
|
8952
|
+
if (config.hooks?.afterResponse) {
|
|
8953
|
+
response = await config.hooks.afterResponse(response, requestParams);
|
|
8954
|
+
}
|
|
8955
|
+
// Handle OAuth2 token flows that require getting a token first
|
|
8956
|
+
if (config.auth?.type === 'oauth2' && !config.auth.accessToken && AUTH_FEATURES.oauth2) {
|
|
8957
|
+
const tokenFlowResponse = await handleOAuth2TokenFlow(config.auth, requestParams, makeRequest, config.retry);
|
|
8958
|
+
if (tokenFlowResponse) {
|
|
8959
|
+
response = tokenFlowResponse;
|
|
8960
|
+
}
|
|
8961
|
+
}
|
|
8962
|
+
// Handle 401 with token refresh
|
|
8963
|
+
if (response.status === 401 && config.auth?.type === 'oauth2' && AUTH_FEATURES.oauth2) {
|
|
8964
|
+
try {
|
|
8965
|
+
const refreshResponse = await handleTokenRefresh(config.auth, requestParams, makeRequest, config.retry);
|
|
8966
|
+
if (refreshResponse) {
|
|
8967
|
+
response = refreshResponse;
|
|
8968
|
+
}
|
|
8969
|
+
}
|
|
8970
|
+
catch {
|
|
8971
|
+
throw new HttpGlobalError('Unauthorized');
|
|
8972
|
+
}
|
|
8973
|
+
}
|
|
8974
|
+
// Handle error responses
|
|
8975
|
+
if (!response.ok) {
|
|
8976
|
+
const errorBody = await response.json().catch(() => undefined);
|
|
8977
|
+
handleHttpError(response.status, response.statusText, errorBody);
|
|
8978
|
+
}
|
|
8979
|
+
// Parse response
|
|
8980
|
+
const rawData = await response.json();
|
|
8981
|
+
const responseData = rawData;
|
|
8982
|
+
// Extract response metadata
|
|
8983
|
+
const responseHeaders = extractHeaders(response);
|
|
8984
|
+
const result = {
|
|
8985
|
+
data: responseData,
|
|
8986
|
+
status: response.status,
|
|
8987
|
+
statusText: response.statusText,
|
|
8988
|
+
headers: responseHeaders,
|
|
8989
|
+
rawData: rawData ?? {},
|
|
8990
|
+
};
|
|
8991
|
+
return result;
|
|
8992
|
+
}
|
|
8993
|
+
catch (error) {
|
|
8994
|
+
// Apply onError hook if present
|
|
8995
|
+
if (config.hooks?.onError && error instanceof HttpGlobalError) {
|
|
8996
|
+
throw await config.hooks.onError(error, requestParams);
|
|
8997
|
+
}
|
|
8998
|
+
throw error;
|
|
8999
|
+
}
|
|
9000
|
+
}
|
|
9001
|
+
/**
|
|
9002
|
+
* | ⚠️ This endpoint is currently in BETA |
|
|
9003
|
+
* |--|
|
|
9004
|
+
*
|
|
9005
|
+
* Deletes a Reminder. Only the reminder's creator or owner may delete it.
|
|
9006
|
+
*
|
|
9007
|
+
*/
|
|
9008
|
+
async function v2_remindersReminderIdDelete(context) {
|
|
9009
|
+
// Apply defaults
|
|
9010
|
+
const config = {
|
|
9011
|
+
baseUrl: 'https://api.affinity.co',
|
|
9012
|
+
...context,
|
|
9013
|
+
};
|
|
9014
|
+
const parameters = context.parameters instanceof V2RemindersReminderIdDeleteParameters_js_1.V2RemindersReminderIdDeleteParameters ? context.parameters : new V2RemindersReminderIdDeleteParameters_js_1.V2RemindersReminderIdDeleteParameters(context.parameters);
|
|
9015
|
+
// Validate OAuth2 config if present
|
|
9016
|
+
if (config.auth?.type === 'oauth2' && AUTH_FEATURES.oauth2) {
|
|
9017
|
+
validateOAuth2Config(config.auth);
|
|
9018
|
+
}
|
|
9019
|
+
// Build headers
|
|
9020
|
+
let headers = { 'Content-Type': 'application/json', ...config.additionalHeaders };
|
|
9021
|
+
// Build URL
|
|
9022
|
+
let url = buildUrlWithParameters(config.baseUrl, '/v2/reminders/{reminderId}', parameters);
|
|
9023
|
+
url = applyQueryParams(config.additionalQueryParams, url);
|
|
9024
|
+
// Apply authentication
|
|
9025
|
+
const authResult = applyAuth(config.auth, headers, url);
|
|
9026
|
+
headers = authResult.headers;
|
|
9027
|
+
url = authResult.url;
|
|
9028
|
+
// Prepare body
|
|
9029
|
+
const body = undefined;
|
|
9030
|
+
// Determine request function - a custom fetch is read only by the built-in
|
|
9031
|
+
// makeRequest, so it is bound in here rather than passed to executeWithRetry.
|
|
9032
|
+
const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
|
|
9033
|
+
// Build request params
|
|
9034
|
+
let requestParams = {
|
|
9035
|
+
url,
|
|
9036
|
+
method: 'DELETE',
|
|
9037
|
+
headers,
|
|
9038
|
+
body,
|
|
9039
|
+
signal: context.signal
|
|
9040
|
+
};
|
|
9041
|
+
// Apply beforeRequest hook
|
|
9042
|
+
if (config.hooks?.beforeRequest) {
|
|
9043
|
+
requestParams = await config.hooks.beforeRequest(requestParams);
|
|
9044
|
+
}
|
|
9045
|
+
try {
|
|
9046
|
+
// Execute request with retry logic
|
|
9047
|
+
let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
9048
|
+
// Apply afterResponse hook
|
|
9049
|
+
if (config.hooks?.afterResponse) {
|
|
9050
|
+
response = await config.hooks.afterResponse(response, requestParams);
|
|
9051
|
+
}
|
|
9052
|
+
// Handle OAuth2 token flows that require getting a token first
|
|
9053
|
+
if (config.auth?.type === 'oauth2' && !config.auth.accessToken && AUTH_FEATURES.oauth2) {
|
|
9054
|
+
const tokenFlowResponse = await handleOAuth2TokenFlow(config.auth, requestParams, makeRequest, config.retry);
|
|
9055
|
+
if (tokenFlowResponse) {
|
|
9056
|
+
response = tokenFlowResponse;
|
|
9057
|
+
}
|
|
9058
|
+
}
|
|
9059
|
+
// Handle 401 with token refresh
|
|
9060
|
+
if (response.status === 401 && config.auth?.type === 'oauth2' && AUTH_FEATURES.oauth2) {
|
|
9061
|
+
try {
|
|
9062
|
+
const refreshResponse = await handleTokenRefresh(config.auth, requestParams, makeRequest, config.retry);
|
|
9063
|
+
if (refreshResponse) {
|
|
9064
|
+
response = refreshResponse;
|
|
9065
|
+
}
|
|
9066
|
+
}
|
|
9067
|
+
catch {
|
|
9068
|
+
throw new HttpGlobalError('Unauthorized');
|
|
9069
|
+
}
|
|
9070
|
+
}
|
|
9071
|
+
// Handle error responses
|
|
9072
|
+
if (!response.ok) {
|
|
9073
|
+
const errorBody = await response.json().catch(() => undefined);
|
|
9074
|
+
handleHttpError(response.status, response.statusText, errorBody);
|
|
9075
|
+
}
|
|
9076
|
+
// Parse response
|
|
9077
|
+
// This operation declares no response body.
|
|
9078
|
+
const rawData = await readOptionalJsonBody(response);
|
|
9079
|
+
const responseData = undefined;
|
|
9080
|
+
// Extract response metadata
|
|
9081
|
+
const responseHeaders = extractHeaders(response);
|
|
9082
|
+
const result = {
|
|
9083
|
+
data: responseData,
|
|
9084
|
+
status: response.status,
|
|
9085
|
+
statusText: response.statusText,
|
|
9086
|
+
headers: responseHeaders,
|
|
9087
|
+
rawData: rawData ?? {},
|
|
9088
|
+
};
|
|
9089
|
+
return result;
|
|
9090
|
+
}
|
|
9091
|
+
catch (error) {
|
|
9092
|
+
// Apply onError hook if present
|
|
9093
|
+
if (config.hooks?.onError && error instanceof HttpGlobalError) {
|
|
9094
|
+
throw await config.hooks.onError(error, requestParams);
|
|
9095
|
+
}
|
|
9096
|
+
throw error;
|
|
9097
|
+
}
|
|
9098
|
+
}
|
|
8891
9099
|
/**
|
|
8892
9100
|
* Perform an AI-powered semantic search. Use the `entityType` field in the request body to specify which entity type to search. Currently only supports companies.
|
|
8893
9101
|
*
|
|
@@ -9977,4 +10185,510 @@ async function v2_usersUserIdGet(context) {
|
|
|
9977
10185
|
throw error;
|
|
9978
10186
|
}
|
|
9979
10187
|
}
|
|
10188
|
+
/**
|
|
10189
|
+
* | ⚠️ This endpoint is currently in BETA |
|
|
10190
|
+
* |--|
|
|
10191
|
+
*
|
|
10192
|
+
* Returns a page of the Webhooks created by the caller. Users allowed to manage all webhooks receive every Webhook in the organization.
|
|
10193
|
+
*
|
|
10194
|
+
* You can filter webhooks using the `filter` query parameter. The filter parameter is a string
|
|
10195
|
+
* that you can specify conditions based on the following properties.
|
|
10196
|
+
* | **Property Name** | **Type** | **Allowed Operators** | **Examples** |
|
|
10197
|
+
* |---|---|---|---|
|
|
10198
|
+
* | `id` | `int64` | `=` | `id=1\|id=2` |
|
|
10199
|
+
* | `createdAt` | `datetime` | `>`, `<`, `>=`, `<=` | `createdAt>=2026-01-01T00:00:00Z` |
|
|
10200
|
+
* | `updatedAt` | `datetime` | `>`, `<`, `>=`, `<=` | `updatedAt>=2026-01-01T00:00:00Z` |
|
|
10201
|
+
*
|
|
10202
|
+
* Results are ordered by `id` ascending.
|
|
10203
|
+
*
|
|
10204
|
+
*/
|
|
10205
|
+
async function v2_webhooksGet(context) {
|
|
10206
|
+
// Apply defaults
|
|
10207
|
+
const config = {
|
|
10208
|
+
baseUrl: 'https://api.affinity.co',
|
|
10209
|
+
...context,
|
|
10210
|
+
};
|
|
10211
|
+
const parameters = context.parameters instanceof V2WebhooksGetParameters_js_1.V2WebhooksGetParameters ? context.parameters : new V2WebhooksGetParameters_js_1.V2WebhooksGetParameters(context.parameters);
|
|
10212
|
+
// Validate OAuth2 config if present
|
|
10213
|
+
if (config.auth?.type === 'oauth2' && AUTH_FEATURES.oauth2) {
|
|
10214
|
+
validateOAuth2Config(config.auth);
|
|
10215
|
+
}
|
|
10216
|
+
// Build headers
|
|
10217
|
+
let headers = { 'Content-Type': 'application/json', ...config.additionalHeaders };
|
|
10218
|
+
// Build URL
|
|
10219
|
+
let url = buildUrlWithParameters(config.baseUrl, '/v2/webhooks', parameters);
|
|
10220
|
+
url = applyQueryParams(config.additionalQueryParams, url);
|
|
10221
|
+
// Apply authentication
|
|
10222
|
+
const authResult = applyAuth(config.auth, headers, url);
|
|
10223
|
+
headers = authResult.headers;
|
|
10224
|
+
url = authResult.url;
|
|
10225
|
+
// Prepare body
|
|
10226
|
+
const body = undefined;
|
|
10227
|
+
// Determine request function - a custom fetch is read only by the built-in
|
|
10228
|
+
// makeRequest, so it is bound in here rather than passed to executeWithRetry.
|
|
10229
|
+
const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
|
|
10230
|
+
// Build request params
|
|
10231
|
+
let requestParams = {
|
|
10232
|
+
url,
|
|
10233
|
+
method: 'GET',
|
|
10234
|
+
headers,
|
|
10235
|
+
body,
|
|
10236
|
+
signal: context.signal
|
|
10237
|
+
};
|
|
10238
|
+
// Apply beforeRequest hook
|
|
10239
|
+
if (config.hooks?.beforeRequest) {
|
|
10240
|
+
requestParams = await config.hooks.beforeRequest(requestParams);
|
|
10241
|
+
}
|
|
10242
|
+
try {
|
|
10243
|
+
// Execute request with retry logic
|
|
10244
|
+
let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
10245
|
+
// Apply afterResponse hook
|
|
10246
|
+
if (config.hooks?.afterResponse) {
|
|
10247
|
+
response = await config.hooks.afterResponse(response, requestParams);
|
|
10248
|
+
}
|
|
10249
|
+
// Handle OAuth2 token flows that require getting a token first
|
|
10250
|
+
if (config.auth?.type === 'oauth2' && !config.auth.accessToken && AUTH_FEATURES.oauth2) {
|
|
10251
|
+
const tokenFlowResponse = await handleOAuth2TokenFlow(config.auth, requestParams, makeRequest, config.retry);
|
|
10252
|
+
if (tokenFlowResponse) {
|
|
10253
|
+
response = tokenFlowResponse;
|
|
10254
|
+
}
|
|
10255
|
+
}
|
|
10256
|
+
// Handle 401 with token refresh
|
|
10257
|
+
if (response.status === 401 && config.auth?.type === 'oauth2' && AUTH_FEATURES.oauth2) {
|
|
10258
|
+
try {
|
|
10259
|
+
const refreshResponse = await handleTokenRefresh(config.auth, requestParams, makeRequest, config.retry);
|
|
10260
|
+
if (refreshResponse) {
|
|
10261
|
+
response = refreshResponse;
|
|
10262
|
+
}
|
|
10263
|
+
}
|
|
10264
|
+
catch {
|
|
10265
|
+
throw new HttpGlobalError('Unauthorized');
|
|
10266
|
+
}
|
|
10267
|
+
}
|
|
10268
|
+
// Handle error responses
|
|
10269
|
+
if (!response.ok) {
|
|
10270
|
+
const errorBody = await response.json().catch(() => undefined);
|
|
10271
|
+
handleHttpError(response.status, response.statusText, errorBody);
|
|
10272
|
+
}
|
|
10273
|
+
// Parse response
|
|
10274
|
+
const rawData = await response.json();
|
|
10275
|
+
const responseData = rawData;
|
|
10276
|
+
// Extract response metadata
|
|
10277
|
+
const responseHeaders = extractHeaders(response);
|
|
10278
|
+
const result = {
|
|
10279
|
+
data: responseData,
|
|
10280
|
+
status: response.status,
|
|
10281
|
+
statusText: response.statusText,
|
|
10282
|
+
headers: responseHeaders,
|
|
10283
|
+
rawData: rawData ?? {},
|
|
10284
|
+
};
|
|
10285
|
+
return result;
|
|
10286
|
+
}
|
|
10287
|
+
catch (error) {
|
|
10288
|
+
// Apply onError hook if present
|
|
10289
|
+
if (config.hooks?.onError && error instanceof HttpGlobalError) {
|
|
10290
|
+
throw await config.hooks.onError(error, requestParams);
|
|
10291
|
+
}
|
|
10292
|
+
throw error;
|
|
10293
|
+
}
|
|
10294
|
+
}
|
|
10295
|
+
/**
|
|
10296
|
+
* | ⚠️ This endpoint is currently in BETA |
|
|
10297
|
+
* |--|
|
|
10298
|
+
*
|
|
10299
|
+
* Creates a new Webhook. The `creator` of the new webhook is the user associated with the API key.
|
|
10300
|
+
*
|
|
10301
|
+
* The URL is validated with a test delivery before the webhook is created. The request is rejected with a `validation` error on the `url` property when the URL is invalid or unreachable, contains embedded credentials, or already belongs to another webhook in the organization.
|
|
10302
|
+
*
|
|
10303
|
+
* The request is rejected with a `bad-request` error, which has no associated property, when the organization has reached its webhook limit.
|
|
10304
|
+
*
|
|
10305
|
+
*/
|
|
10306
|
+
async function v2_webhooksPost(context) {
|
|
10307
|
+
// Apply defaults
|
|
10308
|
+
const config = {
|
|
10309
|
+
baseUrl: 'https://api.affinity.co',
|
|
10310
|
+
...context,
|
|
10311
|
+
};
|
|
10312
|
+
// Validate OAuth2 config if present
|
|
10313
|
+
if (config.auth?.type === 'oauth2' && AUTH_FEATURES.oauth2) {
|
|
10314
|
+
validateOAuth2Config(config.auth);
|
|
10315
|
+
}
|
|
10316
|
+
// Build headers
|
|
10317
|
+
let headers = { 'Content-Type': 'application/json', ...config.additionalHeaders };
|
|
10318
|
+
// Build URL
|
|
10319
|
+
let url = `${config.baseUrl}/v2/webhooks`;
|
|
10320
|
+
url = applyQueryParams(config.additionalQueryParams, url);
|
|
10321
|
+
// Apply authentication
|
|
10322
|
+
const authResult = applyAuth(config.auth, headers, url);
|
|
10323
|
+
headers = authResult.headers;
|
|
10324
|
+
url = authResult.url;
|
|
10325
|
+
// Prepare body
|
|
10326
|
+
const payload = context.payload;
|
|
10327
|
+
const body = JSON.stringify(payload);
|
|
10328
|
+
// Determine request function - a custom fetch is read only by the built-in
|
|
10329
|
+
// makeRequest, so it is bound in here rather than passed to executeWithRetry.
|
|
10330
|
+
const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
|
|
10331
|
+
// Build request params
|
|
10332
|
+
let requestParams = {
|
|
10333
|
+
url,
|
|
10334
|
+
method: 'POST',
|
|
10335
|
+
headers,
|
|
10336
|
+
body,
|
|
10337
|
+
signal: context.signal
|
|
10338
|
+
};
|
|
10339
|
+
// Apply beforeRequest hook
|
|
10340
|
+
if (config.hooks?.beforeRequest) {
|
|
10341
|
+
requestParams = await config.hooks.beforeRequest(requestParams);
|
|
10342
|
+
}
|
|
10343
|
+
try {
|
|
10344
|
+
// Execute request with retry logic
|
|
10345
|
+
let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
10346
|
+
// Apply afterResponse hook
|
|
10347
|
+
if (config.hooks?.afterResponse) {
|
|
10348
|
+
response = await config.hooks.afterResponse(response, requestParams);
|
|
10349
|
+
}
|
|
10350
|
+
// Handle OAuth2 token flows that require getting a token first
|
|
10351
|
+
if (config.auth?.type === 'oauth2' && !config.auth.accessToken && AUTH_FEATURES.oauth2) {
|
|
10352
|
+
const tokenFlowResponse = await handleOAuth2TokenFlow(config.auth, requestParams, makeRequest, config.retry);
|
|
10353
|
+
if (tokenFlowResponse) {
|
|
10354
|
+
response = tokenFlowResponse;
|
|
10355
|
+
}
|
|
10356
|
+
}
|
|
10357
|
+
// Handle 401 with token refresh
|
|
10358
|
+
if (response.status === 401 && config.auth?.type === 'oauth2' && AUTH_FEATURES.oauth2) {
|
|
10359
|
+
try {
|
|
10360
|
+
const refreshResponse = await handleTokenRefresh(config.auth, requestParams, makeRequest, config.retry);
|
|
10361
|
+
if (refreshResponse) {
|
|
10362
|
+
response = refreshResponse;
|
|
10363
|
+
}
|
|
10364
|
+
}
|
|
10365
|
+
catch {
|
|
10366
|
+
throw new HttpGlobalError('Unauthorized');
|
|
10367
|
+
}
|
|
10368
|
+
}
|
|
10369
|
+
// Handle error responses
|
|
10370
|
+
if (!response.ok) {
|
|
10371
|
+
const errorBody = await response.json().catch(() => undefined);
|
|
10372
|
+
handleHttpError(response.status, response.statusText, errorBody);
|
|
10373
|
+
}
|
|
10374
|
+
// Parse response
|
|
10375
|
+
const rawData = await response.json();
|
|
10376
|
+
const responseData = rawData;
|
|
10377
|
+
// Extract response metadata
|
|
10378
|
+
const responseHeaders = extractHeaders(response);
|
|
10379
|
+
const result = {
|
|
10380
|
+
data: responseData,
|
|
10381
|
+
status: response.status,
|
|
10382
|
+
statusText: response.statusText,
|
|
10383
|
+
headers: responseHeaders,
|
|
10384
|
+
rawData: rawData ?? {},
|
|
10385
|
+
};
|
|
10386
|
+
return result;
|
|
10387
|
+
}
|
|
10388
|
+
catch (error) {
|
|
10389
|
+
// Apply onError hook if present
|
|
10390
|
+
if (config.hooks?.onError && error instanceof HttpGlobalError) {
|
|
10391
|
+
throw await config.hooks.onError(error, requestParams);
|
|
10392
|
+
}
|
|
10393
|
+
throw error;
|
|
10394
|
+
}
|
|
10395
|
+
}
|
|
10396
|
+
/**
|
|
10397
|
+
* | ⚠️ This endpoint is currently in BETA |
|
|
10398
|
+
* |--|
|
|
10399
|
+
*
|
|
10400
|
+
* Returns a single Webhook created by the caller. Users allowed to manage all webhooks may retrieve any Webhook in the organization. Responds with `404` when the webhook does not exist or is not accessible.
|
|
10401
|
+
*
|
|
10402
|
+
*/
|
|
10403
|
+
async function v2_webhooksWebhookIdGet(context) {
|
|
10404
|
+
// Apply defaults
|
|
10405
|
+
const config = {
|
|
10406
|
+
baseUrl: 'https://api.affinity.co',
|
|
10407
|
+
...context,
|
|
10408
|
+
};
|
|
10409
|
+
const parameters = context.parameters instanceof V2WebhooksWebhookIdGetParameters_js_1.V2WebhooksWebhookIdGetParameters ? context.parameters : new V2WebhooksWebhookIdGetParameters_js_1.V2WebhooksWebhookIdGetParameters(context.parameters);
|
|
10410
|
+
// Validate OAuth2 config if present
|
|
10411
|
+
if (config.auth?.type === 'oauth2' && AUTH_FEATURES.oauth2) {
|
|
10412
|
+
validateOAuth2Config(config.auth);
|
|
10413
|
+
}
|
|
10414
|
+
// Build headers
|
|
10415
|
+
let headers = { 'Content-Type': 'application/json', ...config.additionalHeaders };
|
|
10416
|
+
// Build URL
|
|
10417
|
+
let url = buildUrlWithParameters(config.baseUrl, '/v2/webhooks/{webhookId}', parameters);
|
|
10418
|
+
url = applyQueryParams(config.additionalQueryParams, url);
|
|
10419
|
+
// Apply authentication
|
|
10420
|
+
const authResult = applyAuth(config.auth, headers, url);
|
|
10421
|
+
headers = authResult.headers;
|
|
10422
|
+
url = authResult.url;
|
|
10423
|
+
// Prepare body
|
|
10424
|
+
const body = undefined;
|
|
10425
|
+
// Determine request function - a custom fetch is read only by the built-in
|
|
10426
|
+
// makeRequest, so it is bound in here rather than passed to executeWithRetry.
|
|
10427
|
+
const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
|
|
10428
|
+
// Build request params
|
|
10429
|
+
let requestParams = {
|
|
10430
|
+
url,
|
|
10431
|
+
method: 'GET',
|
|
10432
|
+
headers,
|
|
10433
|
+
body,
|
|
10434
|
+
signal: context.signal
|
|
10435
|
+
};
|
|
10436
|
+
// Apply beforeRequest hook
|
|
10437
|
+
if (config.hooks?.beforeRequest) {
|
|
10438
|
+
requestParams = await config.hooks.beforeRequest(requestParams);
|
|
10439
|
+
}
|
|
10440
|
+
try {
|
|
10441
|
+
// Execute request with retry logic
|
|
10442
|
+
let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
10443
|
+
// Apply afterResponse hook
|
|
10444
|
+
if (config.hooks?.afterResponse) {
|
|
10445
|
+
response = await config.hooks.afterResponse(response, requestParams);
|
|
10446
|
+
}
|
|
10447
|
+
// Handle OAuth2 token flows that require getting a token first
|
|
10448
|
+
if (config.auth?.type === 'oauth2' && !config.auth.accessToken && AUTH_FEATURES.oauth2) {
|
|
10449
|
+
const tokenFlowResponse = await handleOAuth2TokenFlow(config.auth, requestParams, makeRequest, config.retry);
|
|
10450
|
+
if (tokenFlowResponse) {
|
|
10451
|
+
response = tokenFlowResponse;
|
|
10452
|
+
}
|
|
10453
|
+
}
|
|
10454
|
+
// Handle 401 with token refresh
|
|
10455
|
+
if (response.status === 401 && config.auth?.type === 'oauth2' && AUTH_FEATURES.oauth2) {
|
|
10456
|
+
try {
|
|
10457
|
+
const refreshResponse = await handleTokenRefresh(config.auth, requestParams, makeRequest, config.retry);
|
|
10458
|
+
if (refreshResponse) {
|
|
10459
|
+
response = refreshResponse;
|
|
10460
|
+
}
|
|
10461
|
+
}
|
|
10462
|
+
catch {
|
|
10463
|
+
throw new HttpGlobalError('Unauthorized');
|
|
10464
|
+
}
|
|
10465
|
+
}
|
|
10466
|
+
// Handle error responses
|
|
10467
|
+
if (!response.ok) {
|
|
10468
|
+
const errorBody = await response.json().catch(() => undefined);
|
|
10469
|
+
handleHttpError(response.status, response.statusText, errorBody);
|
|
10470
|
+
}
|
|
10471
|
+
// Parse response
|
|
10472
|
+
const rawData = await response.json();
|
|
10473
|
+
const responseData = rawData;
|
|
10474
|
+
// Extract response metadata
|
|
10475
|
+
const responseHeaders = extractHeaders(response);
|
|
10476
|
+
const result = {
|
|
10477
|
+
data: responseData,
|
|
10478
|
+
status: response.status,
|
|
10479
|
+
statusText: response.statusText,
|
|
10480
|
+
headers: responseHeaders,
|
|
10481
|
+
rawData: rawData ?? {},
|
|
10482
|
+
};
|
|
10483
|
+
return result;
|
|
10484
|
+
}
|
|
10485
|
+
catch (error) {
|
|
10486
|
+
// Apply onError hook if present
|
|
10487
|
+
if (config.hooks?.onError && error instanceof HttpGlobalError) {
|
|
10488
|
+
throw await config.hooks.onError(error, requestParams);
|
|
10489
|
+
}
|
|
10490
|
+
throw error;
|
|
10491
|
+
}
|
|
10492
|
+
}
|
|
10493
|
+
/**
|
|
10494
|
+
* | ⚠️ This endpoint is currently in BETA |
|
|
10495
|
+
* |--|
|
|
10496
|
+
*
|
|
10497
|
+
* Updates a Webhook. Only provided fields are changed; omitted fields keep their current value.
|
|
10498
|
+
*
|
|
10499
|
+
* Changing `url` on an active webhook, or setting `status` to `active` on a disabled webhook, triggers a test delivery that validates the URL before the update is applied. URLs containing embedded credentials are rejected.
|
|
10500
|
+
*
|
|
10501
|
+
* Only the webhook's creator, or a user allowed to manage all webhooks, may update it.
|
|
10502
|
+
*
|
|
10503
|
+
*/
|
|
10504
|
+
async function v2_webhooksWebhookIdPost(context) {
|
|
10505
|
+
// Apply defaults
|
|
10506
|
+
const config = {
|
|
10507
|
+
baseUrl: 'https://api.affinity.co',
|
|
10508
|
+
...context,
|
|
10509
|
+
};
|
|
10510
|
+
const parameters = context.parameters instanceof V2WebhooksWebhookIdPostParameters_js_1.V2WebhooksWebhookIdPostParameters ? context.parameters : new V2WebhooksWebhookIdPostParameters_js_1.V2WebhooksWebhookIdPostParameters(context.parameters);
|
|
10511
|
+
// Validate OAuth2 config if present
|
|
10512
|
+
if (config.auth?.type === 'oauth2' && AUTH_FEATURES.oauth2) {
|
|
10513
|
+
validateOAuth2Config(config.auth);
|
|
10514
|
+
}
|
|
10515
|
+
// Build headers
|
|
10516
|
+
let headers = { 'Content-Type': 'application/json', ...config.additionalHeaders };
|
|
10517
|
+
// Build URL
|
|
10518
|
+
let url = buildUrlWithParameters(config.baseUrl, '/v2/webhooks/{webhookId}', parameters);
|
|
10519
|
+
url = applyQueryParams(config.additionalQueryParams, url);
|
|
10520
|
+
// Apply authentication
|
|
10521
|
+
const authResult = applyAuth(config.auth, headers, url);
|
|
10522
|
+
headers = authResult.headers;
|
|
10523
|
+
url = authResult.url;
|
|
10524
|
+
// Prepare body
|
|
10525
|
+
const payload = context.payload;
|
|
10526
|
+
const body = JSON.stringify(payload);
|
|
10527
|
+
// Determine request function - a custom fetch is read only by the built-in
|
|
10528
|
+
// makeRequest, so it is bound in here rather than passed to executeWithRetry.
|
|
10529
|
+
const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
|
|
10530
|
+
// Build request params
|
|
10531
|
+
let requestParams = {
|
|
10532
|
+
url,
|
|
10533
|
+
method: 'POST',
|
|
10534
|
+
headers,
|
|
10535
|
+
body,
|
|
10536
|
+
signal: context.signal
|
|
10537
|
+
};
|
|
10538
|
+
// Apply beforeRequest hook
|
|
10539
|
+
if (config.hooks?.beforeRequest) {
|
|
10540
|
+
requestParams = await config.hooks.beforeRequest(requestParams);
|
|
10541
|
+
}
|
|
10542
|
+
try {
|
|
10543
|
+
// Execute request with retry logic
|
|
10544
|
+
let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
10545
|
+
// Apply afterResponse hook
|
|
10546
|
+
if (config.hooks?.afterResponse) {
|
|
10547
|
+
response = await config.hooks.afterResponse(response, requestParams);
|
|
10548
|
+
}
|
|
10549
|
+
// Handle OAuth2 token flows that require getting a token first
|
|
10550
|
+
if (config.auth?.type === 'oauth2' && !config.auth.accessToken && AUTH_FEATURES.oauth2) {
|
|
10551
|
+
const tokenFlowResponse = await handleOAuth2TokenFlow(config.auth, requestParams, makeRequest, config.retry);
|
|
10552
|
+
if (tokenFlowResponse) {
|
|
10553
|
+
response = tokenFlowResponse;
|
|
10554
|
+
}
|
|
10555
|
+
}
|
|
10556
|
+
// Handle 401 with token refresh
|
|
10557
|
+
if (response.status === 401 && config.auth?.type === 'oauth2' && AUTH_FEATURES.oauth2) {
|
|
10558
|
+
try {
|
|
10559
|
+
const refreshResponse = await handleTokenRefresh(config.auth, requestParams, makeRequest, config.retry);
|
|
10560
|
+
if (refreshResponse) {
|
|
10561
|
+
response = refreshResponse;
|
|
10562
|
+
}
|
|
10563
|
+
}
|
|
10564
|
+
catch {
|
|
10565
|
+
throw new HttpGlobalError('Unauthorized');
|
|
10566
|
+
}
|
|
10567
|
+
}
|
|
10568
|
+
// Handle error responses
|
|
10569
|
+
if (!response.ok) {
|
|
10570
|
+
const errorBody = await response.json().catch(() => undefined);
|
|
10571
|
+
handleHttpError(response.status, response.statusText, errorBody);
|
|
10572
|
+
}
|
|
10573
|
+
// Parse response
|
|
10574
|
+
// This operation declares no response body.
|
|
10575
|
+
const rawData = await readOptionalJsonBody(response);
|
|
10576
|
+
const responseData = undefined;
|
|
10577
|
+
// Extract response metadata
|
|
10578
|
+
const responseHeaders = extractHeaders(response);
|
|
10579
|
+
const result = {
|
|
10580
|
+
data: responseData,
|
|
10581
|
+
status: response.status,
|
|
10582
|
+
statusText: response.statusText,
|
|
10583
|
+
headers: responseHeaders,
|
|
10584
|
+
rawData: rawData ?? {},
|
|
10585
|
+
};
|
|
10586
|
+
return result;
|
|
10587
|
+
}
|
|
10588
|
+
catch (error) {
|
|
10589
|
+
// Apply onError hook if present
|
|
10590
|
+
if (config.hooks?.onError && error instanceof HttpGlobalError) {
|
|
10591
|
+
throw await config.hooks.onError(error, requestParams);
|
|
10592
|
+
}
|
|
10593
|
+
throw error;
|
|
10594
|
+
}
|
|
10595
|
+
}
|
|
10596
|
+
/**
|
|
10597
|
+
* | ⚠️ This endpoint is currently in BETA |
|
|
10598
|
+
* |--|
|
|
10599
|
+
*
|
|
10600
|
+
* Deletes a Webhook. Only the webhook's creator, or a user allowed to manage all webhooks, may delete it.
|
|
10601
|
+
*
|
|
10602
|
+
*/
|
|
10603
|
+
async function v2_webhooksWebhookIdDelete(context) {
|
|
10604
|
+
// Apply defaults
|
|
10605
|
+
const config = {
|
|
10606
|
+
baseUrl: 'https://api.affinity.co',
|
|
10607
|
+
...context,
|
|
10608
|
+
};
|
|
10609
|
+
const parameters = context.parameters instanceof V2WebhooksWebhookIdDeleteParameters_js_1.V2WebhooksWebhookIdDeleteParameters ? context.parameters : new V2WebhooksWebhookIdDeleteParameters_js_1.V2WebhooksWebhookIdDeleteParameters(context.parameters);
|
|
10610
|
+
// Validate OAuth2 config if present
|
|
10611
|
+
if (config.auth?.type === 'oauth2' && AUTH_FEATURES.oauth2) {
|
|
10612
|
+
validateOAuth2Config(config.auth);
|
|
10613
|
+
}
|
|
10614
|
+
// Build headers
|
|
10615
|
+
let headers = { 'Content-Type': 'application/json', ...config.additionalHeaders };
|
|
10616
|
+
// Build URL
|
|
10617
|
+
let url = buildUrlWithParameters(config.baseUrl, '/v2/webhooks/{webhookId}', parameters);
|
|
10618
|
+
url = applyQueryParams(config.additionalQueryParams, url);
|
|
10619
|
+
// Apply authentication
|
|
10620
|
+
const authResult = applyAuth(config.auth, headers, url);
|
|
10621
|
+
headers = authResult.headers;
|
|
10622
|
+
url = authResult.url;
|
|
10623
|
+
// Prepare body
|
|
10624
|
+
const body = undefined;
|
|
10625
|
+
// Determine request function - a custom fetch is read only by the built-in
|
|
10626
|
+
// makeRequest, so it is bound in here rather than passed to executeWithRetry.
|
|
10627
|
+
const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
|
|
10628
|
+
// Build request params
|
|
10629
|
+
let requestParams = {
|
|
10630
|
+
url,
|
|
10631
|
+
method: 'DELETE',
|
|
10632
|
+
headers,
|
|
10633
|
+
body,
|
|
10634
|
+
signal: context.signal
|
|
10635
|
+
};
|
|
10636
|
+
// Apply beforeRequest hook
|
|
10637
|
+
if (config.hooks?.beforeRequest) {
|
|
10638
|
+
requestParams = await config.hooks.beforeRequest(requestParams);
|
|
10639
|
+
}
|
|
10640
|
+
try {
|
|
10641
|
+
// Execute request with retry logic
|
|
10642
|
+
let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
10643
|
+
// Apply afterResponse hook
|
|
10644
|
+
if (config.hooks?.afterResponse) {
|
|
10645
|
+
response = await config.hooks.afterResponse(response, requestParams);
|
|
10646
|
+
}
|
|
10647
|
+
// Handle OAuth2 token flows that require getting a token first
|
|
10648
|
+
if (config.auth?.type === 'oauth2' && !config.auth.accessToken && AUTH_FEATURES.oauth2) {
|
|
10649
|
+
const tokenFlowResponse = await handleOAuth2TokenFlow(config.auth, requestParams, makeRequest, config.retry);
|
|
10650
|
+
if (tokenFlowResponse) {
|
|
10651
|
+
response = tokenFlowResponse;
|
|
10652
|
+
}
|
|
10653
|
+
}
|
|
10654
|
+
// Handle 401 with token refresh
|
|
10655
|
+
if (response.status === 401 && config.auth?.type === 'oauth2' && AUTH_FEATURES.oauth2) {
|
|
10656
|
+
try {
|
|
10657
|
+
const refreshResponse = await handleTokenRefresh(config.auth, requestParams, makeRequest, config.retry);
|
|
10658
|
+
if (refreshResponse) {
|
|
10659
|
+
response = refreshResponse;
|
|
10660
|
+
}
|
|
10661
|
+
}
|
|
10662
|
+
catch {
|
|
10663
|
+
throw new HttpGlobalError('Unauthorized');
|
|
10664
|
+
}
|
|
10665
|
+
}
|
|
10666
|
+
// Handle error responses
|
|
10667
|
+
if (!response.ok) {
|
|
10668
|
+
const errorBody = await response.json().catch(() => undefined);
|
|
10669
|
+
handleHttpError(response.status, response.statusText, errorBody);
|
|
10670
|
+
}
|
|
10671
|
+
// Parse response
|
|
10672
|
+
// This operation declares no response body.
|
|
10673
|
+
const rawData = await readOptionalJsonBody(response);
|
|
10674
|
+
const responseData = undefined;
|
|
10675
|
+
// Extract response metadata
|
|
10676
|
+
const responseHeaders = extractHeaders(response);
|
|
10677
|
+
const result = {
|
|
10678
|
+
data: responseData,
|
|
10679
|
+
status: response.status,
|
|
10680
|
+
statusText: response.statusText,
|
|
10681
|
+
headers: responseHeaders,
|
|
10682
|
+
rawData: rawData ?? {},
|
|
10683
|
+
};
|
|
10684
|
+
return result;
|
|
10685
|
+
}
|
|
10686
|
+
catch (error) {
|
|
10687
|
+
// Apply onError hook if present
|
|
10688
|
+
if (config.hooks?.onError && error instanceof HttpGlobalError) {
|
|
10689
|
+
throw await config.hooks.onError(error, requestParams);
|
|
10690
|
+
}
|
|
10691
|
+
throw error;
|
|
10692
|
+
}
|
|
10693
|
+
}
|
|
9980
10694
|
//# sourceMappingURL=http_client.js.map
|