@dereekb/zoho 12.3.7 → 12.3.9
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/index.cjs.js +126 -3
- package/index.esm.js +123 -6
- package/nestjs/CHANGELOG.md +8 -0
- package/nestjs/package.json +1 -1
- package/nestjs/src/lib/accounts/accounts.service.js +17 -0
- package/nestjs/src/lib/accounts/accounts.service.js.map +1 -1
- package/nestjs/src/lib/recruit/recruit.api.d.ts +3 -0
- package/nestjs/src/lib/recruit/recruit.api.js +9 -0
- package/nestjs/src/lib/recruit/recruit.api.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/accounts/accounts.d.ts +10 -1
- package/src/lib/recruit/recruit.api.d.ts +78 -3
- package/src/lib/recruit/recruit.config.d.ts +2 -1
- package/src/lib/recruit/recruit.d.ts +23 -2
- package/src/lib/zoho.error.api.d.ts +7 -1
package/index.cjs.js
CHANGED
|
@@ -2077,7 +2077,7 @@ function logZohoServerErrorFunction(zohoApiNamePrefix) {
|
|
|
2077
2077
|
* @returns
|
|
2078
2078
|
*/
|
|
2079
2079
|
function handleZohoErrorFetchFactory(parseZohoError, defaultLogError) {
|
|
2080
|
-
return (fetch$1, logError = defaultLogError) => {
|
|
2080
|
+
return (fetch$1, logError = defaultLogError, onError) => {
|
|
2081
2081
|
return async (x, y) => {
|
|
2082
2082
|
try {
|
|
2083
2083
|
return await fetch$1(x, y); // await to catch thrown errors
|
|
@@ -2086,6 +2086,7 @@ function handleZohoErrorFetchFactory(parseZohoError, defaultLogError) {
|
|
|
2086
2086
|
const error = await parseZohoError(e);
|
|
2087
2087
|
if (error) {
|
|
2088
2088
|
logError(error); // log before throwing.
|
|
2089
|
+
onError?.(error); // perform a task
|
|
2089
2090
|
throw error;
|
|
2090
2091
|
}
|
|
2091
2092
|
}
|
|
@@ -2118,6 +2119,11 @@ function interceptZohoErrorResponseFactory(parseZohoServerErrorResponseData) {
|
|
|
2118
2119
|
* - An extra parameter is provided
|
|
2119
2120
|
*/
|
|
2120
2121
|
const ZOHO_INTERNAL_ERROR_CODE = 'INTERNAL_ERROR';
|
|
2122
|
+
/**
|
|
2123
|
+
* Error code for when an invalid oauth token is provided.
|
|
2124
|
+
*/
|
|
2125
|
+
const ZOHO_INVALID_TOKEN_ERROR_CODE = 'INVALID_TOKEN';
|
|
2126
|
+
class ZohoInvalidTokenError extends ZohoServerFetchResponseError {}
|
|
2121
2127
|
/**
|
|
2122
2128
|
* Error code for when a failure occured for the given action
|
|
2123
2129
|
*/
|
|
@@ -2211,6 +2217,9 @@ function parseZohoServerErrorResponseData(errorResponseData, responseError) {
|
|
|
2211
2217
|
case ZOHO_INTERNAL_ERROR_CODE:
|
|
2212
2218
|
result = new ZohoInternalError(errorData, responseError);
|
|
2213
2219
|
break;
|
|
2220
|
+
case ZOHO_INVALID_TOKEN_ERROR_CODE:
|
|
2221
|
+
result = new ZohoInvalidTokenError(errorData, responseError);
|
|
2222
|
+
break;
|
|
2214
2223
|
case ZOHO_INVALID_AUTHORIZATION_ERROR_CODE:
|
|
2215
2224
|
result = new ZohoInvalidAuthorizationError(errorData, responseError);
|
|
2216
2225
|
break;
|
|
@@ -2497,6 +2506,101 @@ function getAttachmentsForRecord(context) {
|
|
|
2497
2506
|
function getAttachmentsForRecordPageFactory(context) {
|
|
2498
2507
|
return zohoFetchPageFactory(getAttachmentsForRecord(context));
|
|
2499
2508
|
}
|
|
2509
|
+
/**
|
|
2510
|
+
* Maximum attachment size allowed by Zoho Recruit.
|
|
2511
|
+
*
|
|
2512
|
+
* 20MB
|
|
2513
|
+
*/
|
|
2514
|
+
const ZOHO_RECRUIT_ATTACHMENT_MAX_SIZE = 20 * 1024 * 1024;
|
|
2515
|
+
/**
|
|
2516
|
+
* Uploads an attachment to a record.
|
|
2517
|
+
*
|
|
2518
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/upload-attachment.html
|
|
2519
|
+
*
|
|
2520
|
+
* @param context
|
|
2521
|
+
* @returns
|
|
2522
|
+
*/
|
|
2523
|
+
function uploadAttachmentForRecord(context) {
|
|
2524
|
+
return input => {
|
|
2525
|
+
const {
|
|
2526
|
+
attachmentCategoryId,
|
|
2527
|
+
attachmentCategoryName,
|
|
2528
|
+
formData
|
|
2529
|
+
} = input;
|
|
2530
|
+
const urlParams = {
|
|
2531
|
+
attachments_category_id: util.joinStringsWithCommas(attachmentCategoryId),
|
|
2532
|
+
attachments_category: util.joinStringsWithCommas(attachmentCategoryName),
|
|
2533
|
+
attachment_url: input.attachmentUrl
|
|
2534
|
+
};
|
|
2535
|
+
if (!urlParams.attachments_category_id?.length && !urlParams.attachments_category?.length) {
|
|
2536
|
+
throw new Error('attachmentCategoryId or attachmentCategoryName must be provided and not empty.');
|
|
2537
|
+
}
|
|
2538
|
+
if (formData != null) {
|
|
2539
|
+
delete urlParams.attachment_url;
|
|
2540
|
+
}
|
|
2541
|
+
const url = `https://recruitsandbox.zoho.com/recruit/v2/${input.module}/${input.id}/${ZOHO_RECRUIT_ATTACHMENTS_MODULE}?${fetch.makeUrlSearchParams(urlParams).toString()}`;
|
|
2542
|
+
let response;
|
|
2543
|
+
if (urlParams.attachment_url) {
|
|
2544
|
+
response = context.fetch(url, {
|
|
2545
|
+
method: 'POST'
|
|
2546
|
+
});
|
|
2547
|
+
} else if (formData != null) {
|
|
2548
|
+
throw new Error('unsupported currently. Use the attachmentUrl parameter instead.');
|
|
2549
|
+
// There is something weird going on with sending requests this way and zoho's server is rejecting it.
|
|
2550
|
+
/*
|
|
2551
|
+
response = context.fetch(url, {
|
|
2552
|
+
method: 'POST',
|
|
2553
|
+
headers: {
|
|
2554
|
+
'Content-Type': 'multipart/form-data',
|
|
2555
|
+
'content-length': '210'
|
|
2556
|
+
},
|
|
2557
|
+
body: formData
|
|
2558
|
+
});
|
|
2559
|
+
*/
|
|
2560
|
+
/*
|
|
2561
|
+
const fullUrl = (context.config.apiUrl as string) + url;
|
|
2562
|
+
const accessToken = await context.accessTokenStringFactory();
|
|
2563
|
+
response = fetch(fullUrl, {
|
|
2564
|
+
headers: {
|
|
2565
|
+
Authorization: `Bearer ${accessToken}`
|
|
2566
|
+
},
|
|
2567
|
+
body: formData,
|
|
2568
|
+
method: 'POST'
|
|
2569
|
+
});
|
|
2570
|
+
console.log({ response });
|
|
2571
|
+
*/
|
|
2572
|
+
} else {
|
|
2573
|
+
throw new Error('body or attachmentUrl must be provided.');
|
|
2574
|
+
}
|
|
2575
|
+
return response;
|
|
2576
|
+
};
|
|
2577
|
+
}
|
|
2578
|
+
/**
|
|
2579
|
+
* Downloads an attachment from a record.
|
|
2580
|
+
*
|
|
2581
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/download-attachments.html
|
|
2582
|
+
*
|
|
2583
|
+
* @param context
|
|
2584
|
+
* @returns
|
|
2585
|
+
*/
|
|
2586
|
+
function downloadAttachmentForRecord(context) {
|
|
2587
|
+
return input => context.fetch(`/v2/${input.module}/${input.id}/${ZOHO_RECRUIT_ATTACHMENTS_MODULE}/${input.attachment_id}`, {
|
|
2588
|
+
method: 'GET'
|
|
2589
|
+
}).then(fetch.parseFetchFileResponse);
|
|
2590
|
+
}
|
|
2591
|
+
/**
|
|
2592
|
+
* Deletes an attachment from a record.
|
|
2593
|
+
*
|
|
2594
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/delete-attachments.html
|
|
2595
|
+
*
|
|
2596
|
+
* @param context
|
|
2597
|
+
* @returns
|
|
2598
|
+
*/
|
|
2599
|
+
function deleteAttachmentFromRecord(context) {
|
|
2600
|
+
return input => context.fetch(`/v2/${input.module}/${input.id}/${ZOHO_RECRUIT_ATTACHMENTS_MODULE}/${input.attachment_id}`, {
|
|
2601
|
+
method: 'DELETE'
|
|
2602
|
+
});
|
|
2603
|
+
}
|
|
2500
2604
|
class ZohoRecruitExecuteRestApiFunctionError extends makeError.BaseError {
|
|
2501
2605
|
constructor(error) {
|
|
2502
2606
|
super(`An error occured during the execution of the function. Code: ${error.code}, Message: ${error.message}`);
|
|
@@ -2939,7 +3043,11 @@ function zohoRecruitFactory(factoryConfig) {
|
|
|
2939
3043
|
const baseFetch = fetchFactory({
|
|
2940
3044
|
apiUrl
|
|
2941
3045
|
});
|
|
2942
|
-
const fetch$1 = handleZohoRecruitErrorFetch(baseFetch, logZohoServerErrorFunction
|
|
3046
|
+
const fetch$1 = handleZohoRecruitErrorFetch(baseFetch, logZohoServerErrorFunction, x => {
|
|
3047
|
+
if (x instanceof ZohoInvalidTokenError) {
|
|
3048
|
+
accountsContext.loadAccessToken.resetAccessToken();
|
|
3049
|
+
}
|
|
3050
|
+
});
|
|
2943
3051
|
const fetchJson = fetch.fetchJsonFunction(fetch$1, {
|
|
2944
3052
|
interceptJsonResponse: interceptZohoRecruit200StatusWithErrorResponse,
|
|
2945
3053
|
// intercept errors that return status 200
|
|
@@ -2948,6 +3056,7 @@ function zohoRecruitFactory(factoryConfig) {
|
|
|
2948
3056
|
const recruitContext = {
|
|
2949
3057
|
fetch: fetch$1,
|
|
2950
3058
|
fetchJson,
|
|
3059
|
+
accessTokenStringFactory,
|
|
2951
3060
|
config: {
|
|
2952
3061
|
...config,
|
|
2953
3062
|
apiUrl
|
|
@@ -3049,6 +3158,9 @@ function zohoAccountsFactory(factoryConfig) {
|
|
|
3049
3158
|
};
|
|
3050
3159
|
return result;
|
|
3051
3160
|
};
|
|
3161
|
+
tokenRefresher.resetAccessToken = async () => {
|
|
3162
|
+
return config.accessTokenCache?.clearCachedToken();
|
|
3163
|
+
};
|
|
3052
3164
|
const loadAccessToken = zohoAccountsZohoAccessTokenFactory({
|
|
3053
3165
|
tokenRefresher,
|
|
3054
3166
|
accessTokenCache: config.accessTokenCache
|
|
@@ -3085,7 +3197,10 @@ function zohoAccountsZohoAccessTokenFactory(config) {
|
|
|
3085
3197
|
* Caches the token internally here until it expires.
|
|
3086
3198
|
*/
|
|
3087
3199
|
let currentToken = null;
|
|
3088
|
-
|
|
3200
|
+
const resetAccessToken = async () => {
|
|
3201
|
+
currentToken = null;
|
|
3202
|
+
};
|
|
3203
|
+
const fn = async () => {
|
|
3089
3204
|
// load from cache
|
|
3090
3205
|
if (!currentToken) {
|
|
3091
3206
|
const cachedToken = await accessTokenCache?.loadCachedToken();
|
|
@@ -3118,6 +3233,8 @@ function zohoAccountsZohoAccessTokenFactory(config) {
|
|
|
3118
3233
|
}
|
|
3119
3234
|
return currentToken;
|
|
3120
3235
|
};
|
|
3236
|
+
fn.resetAccessToken = resetAccessToken;
|
|
3237
|
+
return fn;
|
|
3121
3238
|
}
|
|
3122
3239
|
|
|
3123
3240
|
function safeZohoDateTimeString(date) {
|
|
@@ -3148,12 +3265,14 @@ exports.ZOHO_INTERNAL_ERROR_CODE = ZOHO_INTERNAL_ERROR_CODE;
|
|
|
3148
3265
|
exports.ZOHO_INVALID_AUTHORIZATION_ERROR_CODE = ZOHO_INVALID_AUTHORIZATION_ERROR_CODE;
|
|
3149
3266
|
exports.ZOHO_INVALID_DATA_ERROR_CODE = ZOHO_INVALID_DATA_ERROR_CODE;
|
|
3150
3267
|
exports.ZOHO_INVALID_QUERY_ERROR_CODE = ZOHO_INVALID_QUERY_ERROR_CODE;
|
|
3268
|
+
exports.ZOHO_INVALID_TOKEN_ERROR_CODE = ZOHO_INVALID_TOKEN_ERROR_CODE;
|
|
3151
3269
|
exports.ZOHO_MANDATORY_NOT_FOUND_ERROR_CODE = ZOHO_MANDATORY_NOT_FOUND_ERROR_CODE;
|
|
3152
3270
|
exports.ZOHO_RATE_LIMIT_LIMIT_HEADER = ZOHO_RATE_LIMIT_LIMIT_HEADER;
|
|
3153
3271
|
exports.ZOHO_RATE_LIMIT_REMAINING_HEADER = ZOHO_RATE_LIMIT_REMAINING_HEADER;
|
|
3154
3272
|
exports.ZOHO_RATE_LIMIT_RESET_HEADER = ZOHO_RATE_LIMIT_RESET_HEADER;
|
|
3155
3273
|
exports.ZOHO_RECRUIT_ALREADY_ASSOCIATED_ERROR_CODE = ZOHO_RECRUIT_ALREADY_ASSOCIATED_ERROR_CODE;
|
|
3156
3274
|
exports.ZOHO_RECRUIT_ATTACHMENTS_MODULE = ZOHO_RECRUIT_ATTACHMENTS_MODULE;
|
|
3275
|
+
exports.ZOHO_RECRUIT_ATTACHMENT_MAX_SIZE = ZOHO_RECRUIT_ATTACHMENT_MAX_SIZE;
|
|
3157
3276
|
exports.ZOHO_RECRUIT_CANDIDATES_MODULE = ZOHO_RECRUIT_CANDIDATES_MODULE;
|
|
3158
3277
|
exports.ZOHO_RECRUIT_EMAILS_MODULE = ZOHO_RECRUIT_EMAILS_MODULE;
|
|
3159
3278
|
exports.ZOHO_RECRUIT_JOB_OPENINGS_MODULE = ZOHO_RECRUIT_JOB_OPENINGS_MODULE;
|
|
@@ -3170,6 +3289,7 @@ exports.ZohoAccountsAuthFailureError = ZohoAccountsAuthFailureError;
|
|
|
3170
3289
|
exports.ZohoInternalError = ZohoInternalError;
|
|
3171
3290
|
exports.ZohoInvalidAuthorizationError = ZohoInvalidAuthorizationError;
|
|
3172
3291
|
exports.ZohoInvalidQueryError = ZohoInvalidQueryError;
|
|
3292
|
+
exports.ZohoInvalidTokenError = ZohoInvalidTokenError;
|
|
3173
3293
|
exports.ZohoRecruitExecuteRestApiFunctionError = ZohoRecruitExecuteRestApiFunctionError;
|
|
3174
3294
|
exports.ZohoRecruitRecordCrudDuplicateDataError = ZohoRecruitRecordCrudDuplicateDataError;
|
|
3175
3295
|
exports.ZohoRecruitRecordCrudError = ZohoRecruitRecordCrudError;
|
|
@@ -3187,8 +3307,10 @@ exports.associateCandidateRecordsWithJobOpenings = associateCandidateRecordsWith
|
|
|
3187
3307
|
exports.createNotes = createNotes;
|
|
3188
3308
|
exports.createNotesForRecord = createNotesForRecord;
|
|
3189
3309
|
exports.createTagsForModule = createTagsForModule;
|
|
3310
|
+
exports.deleteAttachmentFromRecord = deleteAttachmentFromRecord;
|
|
3190
3311
|
exports.deleteNotes = deleteNotes;
|
|
3191
3312
|
exports.deleteRecord = deleteRecord;
|
|
3313
|
+
exports.downloadAttachmentForRecord = downloadAttachmentForRecord;
|
|
3192
3314
|
exports.emptyZohoPageResult = emptyZohoPageResult;
|
|
3193
3315
|
exports.escapeZohoFieldValueForCriteriaString = escapeZohoFieldValueForCriteriaString;
|
|
3194
3316
|
exports.executeRestApiFunction = executeRestApiFunction;
|
|
@@ -3229,6 +3351,7 @@ exports.searchRecords = searchRecords;
|
|
|
3229
3351
|
exports.searchRecordsPageFactory = searchRecordsPageFactory;
|
|
3230
3352
|
exports.tryFindZohoServerErrorData = tryFindZohoServerErrorData;
|
|
3231
3353
|
exports.updateRecord = updateRecord;
|
|
3354
|
+
exports.uploadAttachmentForRecord = uploadAttachmentForRecord;
|
|
3232
3355
|
exports.upsertRecord = upsertRecord;
|
|
3233
3356
|
exports.zohoAccessTokenStringFactory = zohoAccessTokenStringFactory;
|
|
3234
3357
|
exports.zohoAccountsApiFetchJsonInput = zohoAccountsApiFetchJsonInput;
|
package/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getNextPageNumber, isStandardInternetAccessibleWebsiteUrl, escapeStringCharactersFunction, filterMaybeArrayValues, asArray, MS_IN_MINUTE, separateValues, resetPeriodPromiseRateLimiter, MS_IN_SECOND } from '@dereekb/util';
|
|
2
|
-
import { fetchPageFactory, FetchResponseError, makeUrlSearchParams, FetchRequestFactoryError, rateLimitedFetchHandler, fetchJsonFunction, returnNullHandleFetchJsonParseErrorFunction, fetchApiFetchService } from '@dereekb/util/fetch';
|
|
1
|
+
import { getNextPageNumber, isStandardInternetAccessibleWebsiteUrl, escapeStringCharactersFunction, filterMaybeArrayValues, asArray, MS_IN_MINUTE, joinStringsWithCommas, separateValues, resetPeriodPromiseRateLimiter, MS_IN_SECOND } from '@dereekb/util';
|
|
2
|
+
import { fetchPageFactory, FetchResponseError, makeUrlSearchParams, parseFetchFileResponse, FetchRequestFactoryError, rateLimitedFetchHandler, fetchJsonFunction, returnNullHandleFetchJsonParseErrorFunction, fetchApiFetchService } from '@dereekb/util/fetch';
|
|
3
3
|
import { BaseError } from 'make-error';
|
|
4
4
|
|
|
5
5
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -2075,7 +2075,7 @@ function logZohoServerErrorFunction(zohoApiNamePrefix) {
|
|
|
2075
2075
|
* @returns
|
|
2076
2076
|
*/
|
|
2077
2077
|
function handleZohoErrorFetchFactory(parseZohoError, defaultLogError) {
|
|
2078
|
-
return (fetch, logError = defaultLogError) => {
|
|
2078
|
+
return (fetch, logError = defaultLogError, onError) => {
|
|
2079
2079
|
return async (x, y) => {
|
|
2080
2080
|
try {
|
|
2081
2081
|
return await fetch(x, y); // await to catch thrown errors
|
|
@@ -2084,6 +2084,7 @@ function handleZohoErrorFetchFactory(parseZohoError, defaultLogError) {
|
|
|
2084
2084
|
const error = await parseZohoError(e);
|
|
2085
2085
|
if (error) {
|
|
2086
2086
|
logError(error); // log before throwing.
|
|
2087
|
+
onError?.(error); // perform a task
|
|
2087
2088
|
throw error;
|
|
2088
2089
|
}
|
|
2089
2090
|
}
|
|
@@ -2116,6 +2117,11 @@ function interceptZohoErrorResponseFactory(parseZohoServerErrorResponseData) {
|
|
|
2116
2117
|
* - An extra parameter is provided
|
|
2117
2118
|
*/
|
|
2118
2119
|
const ZOHO_INTERNAL_ERROR_CODE = 'INTERNAL_ERROR';
|
|
2120
|
+
/**
|
|
2121
|
+
* Error code for when an invalid oauth token is provided.
|
|
2122
|
+
*/
|
|
2123
|
+
const ZOHO_INVALID_TOKEN_ERROR_CODE = 'INVALID_TOKEN';
|
|
2124
|
+
class ZohoInvalidTokenError extends ZohoServerFetchResponseError {}
|
|
2119
2125
|
/**
|
|
2120
2126
|
* Error code for when a failure occured for the given action
|
|
2121
2127
|
*/
|
|
@@ -2209,6 +2215,9 @@ function parseZohoServerErrorResponseData(errorResponseData, responseError) {
|
|
|
2209
2215
|
case ZOHO_INTERNAL_ERROR_CODE:
|
|
2210
2216
|
result = new ZohoInternalError(errorData, responseError);
|
|
2211
2217
|
break;
|
|
2218
|
+
case ZOHO_INVALID_TOKEN_ERROR_CODE:
|
|
2219
|
+
result = new ZohoInvalidTokenError(errorData, responseError);
|
|
2220
|
+
break;
|
|
2212
2221
|
case ZOHO_INVALID_AUTHORIZATION_ERROR_CODE:
|
|
2213
2222
|
result = new ZohoInvalidAuthorizationError(errorData, responseError);
|
|
2214
2223
|
break;
|
|
@@ -2495,6 +2504,101 @@ function getAttachmentsForRecord(context) {
|
|
|
2495
2504
|
function getAttachmentsForRecordPageFactory(context) {
|
|
2496
2505
|
return zohoFetchPageFactory(getAttachmentsForRecord(context));
|
|
2497
2506
|
}
|
|
2507
|
+
/**
|
|
2508
|
+
* Maximum attachment size allowed by Zoho Recruit.
|
|
2509
|
+
*
|
|
2510
|
+
* 20MB
|
|
2511
|
+
*/
|
|
2512
|
+
const ZOHO_RECRUIT_ATTACHMENT_MAX_SIZE = 20 * 1024 * 1024;
|
|
2513
|
+
/**
|
|
2514
|
+
* Uploads an attachment to a record.
|
|
2515
|
+
*
|
|
2516
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/upload-attachment.html
|
|
2517
|
+
*
|
|
2518
|
+
* @param context
|
|
2519
|
+
* @returns
|
|
2520
|
+
*/
|
|
2521
|
+
function uploadAttachmentForRecord(context) {
|
|
2522
|
+
return input => {
|
|
2523
|
+
const {
|
|
2524
|
+
attachmentCategoryId,
|
|
2525
|
+
attachmentCategoryName,
|
|
2526
|
+
formData
|
|
2527
|
+
} = input;
|
|
2528
|
+
const urlParams = {
|
|
2529
|
+
attachments_category_id: joinStringsWithCommas(attachmentCategoryId),
|
|
2530
|
+
attachments_category: joinStringsWithCommas(attachmentCategoryName),
|
|
2531
|
+
attachment_url: input.attachmentUrl
|
|
2532
|
+
};
|
|
2533
|
+
if (!urlParams.attachments_category_id?.length && !urlParams.attachments_category?.length) {
|
|
2534
|
+
throw new Error('attachmentCategoryId or attachmentCategoryName must be provided and not empty.');
|
|
2535
|
+
}
|
|
2536
|
+
if (formData != null) {
|
|
2537
|
+
delete urlParams.attachment_url;
|
|
2538
|
+
}
|
|
2539
|
+
const url = `https://recruitsandbox.zoho.com/recruit/v2/${input.module}/${input.id}/${ZOHO_RECRUIT_ATTACHMENTS_MODULE}?${makeUrlSearchParams(urlParams).toString()}`;
|
|
2540
|
+
let response;
|
|
2541
|
+
if (urlParams.attachment_url) {
|
|
2542
|
+
response = context.fetch(url, {
|
|
2543
|
+
method: 'POST'
|
|
2544
|
+
});
|
|
2545
|
+
} else if (formData != null) {
|
|
2546
|
+
throw new Error('unsupported currently. Use the attachmentUrl parameter instead.');
|
|
2547
|
+
// There is something weird going on with sending requests this way and zoho's server is rejecting it.
|
|
2548
|
+
/*
|
|
2549
|
+
response = context.fetch(url, {
|
|
2550
|
+
method: 'POST',
|
|
2551
|
+
headers: {
|
|
2552
|
+
'Content-Type': 'multipart/form-data',
|
|
2553
|
+
'content-length': '210'
|
|
2554
|
+
},
|
|
2555
|
+
body: formData
|
|
2556
|
+
});
|
|
2557
|
+
*/
|
|
2558
|
+
/*
|
|
2559
|
+
const fullUrl = (context.config.apiUrl as string) + url;
|
|
2560
|
+
const accessToken = await context.accessTokenStringFactory();
|
|
2561
|
+
response = fetch(fullUrl, {
|
|
2562
|
+
headers: {
|
|
2563
|
+
Authorization: `Bearer ${accessToken}`
|
|
2564
|
+
},
|
|
2565
|
+
body: formData,
|
|
2566
|
+
method: 'POST'
|
|
2567
|
+
});
|
|
2568
|
+
console.log({ response });
|
|
2569
|
+
*/
|
|
2570
|
+
} else {
|
|
2571
|
+
throw new Error('body or attachmentUrl must be provided.');
|
|
2572
|
+
}
|
|
2573
|
+
return response;
|
|
2574
|
+
};
|
|
2575
|
+
}
|
|
2576
|
+
/**
|
|
2577
|
+
* Downloads an attachment from a record.
|
|
2578
|
+
*
|
|
2579
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/download-attachments.html
|
|
2580
|
+
*
|
|
2581
|
+
* @param context
|
|
2582
|
+
* @returns
|
|
2583
|
+
*/
|
|
2584
|
+
function downloadAttachmentForRecord(context) {
|
|
2585
|
+
return input => context.fetch(`/v2/${input.module}/${input.id}/${ZOHO_RECRUIT_ATTACHMENTS_MODULE}/${input.attachment_id}`, {
|
|
2586
|
+
method: 'GET'
|
|
2587
|
+
}).then(parseFetchFileResponse);
|
|
2588
|
+
}
|
|
2589
|
+
/**
|
|
2590
|
+
* Deletes an attachment from a record.
|
|
2591
|
+
*
|
|
2592
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/delete-attachments.html
|
|
2593
|
+
*
|
|
2594
|
+
* @param context
|
|
2595
|
+
* @returns
|
|
2596
|
+
*/
|
|
2597
|
+
function deleteAttachmentFromRecord(context) {
|
|
2598
|
+
return input => context.fetch(`/v2/${input.module}/${input.id}/${ZOHO_RECRUIT_ATTACHMENTS_MODULE}/${input.attachment_id}`, {
|
|
2599
|
+
method: 'DELETE'
|
|
2600
|
+
});
|
|
2601
|
+
}
|
|
2498
2602
|
class ZohoRecruitExecuteRestApiFunctionError extends BaseError {
|
|
2499
2603
|
constructor(error) {
|
|
2500
2604
|
super(`An error occured during the execution of the function. Code: ${error.code}, Message: ${error.message}`);
|
|
@@ -2937,7 +3041,11 @@ function zohoRecruitFactory(factoryConfig) {
|
|
|
2937
3041
|
const baseFetch = fetchFactory({
|
|
2938
3042
|
apiUrl
|
|
2939
3043
|
});
|
|
2940
|
-
const fetch = handleZohoRecruitErrorFetch(baseFetch, logZohoServerErrorFunction
|
|
3044
|
+
const fetch = handleZohoRecruitErrorFetch(baseFetch, logZohoServerErrorFunction, x => {
|
|
3045
|
+
if (x instanceof ZohoInvalidTokenError) {
|
|
3046
|
+
accountsContext.loadAccessToken.resetAccessToken();
|
|
3047
|
+
}
|
|
3048
|
+
});
|
|
2941
3049
|
const fetchJson = fetchJsonFunction(fetch, {
|
|
2942
3050
|
interceptJsonResponse: interceptZohoRecruit200StatusWithErrorResponse,
|
|
2943
3051
|
// intercept errors that return status 200
|
|
@@ -2946,6 +3054,7 @@ function zohoRecruitFactory(factoryConfig) {
|
|
|
2946
3054
|
const recruitContext = {
|
|
2947
3055
|
fetch,
|
|
2948
3056
|
fetchJson,
|
|
3057
|
+
accessTokenStringFactory,
|
|
2949
3058
|
config: {
|
|
2950
3059
|
...config,
|
|
2951
3060
|
apiUrl
|
|
@@ -3047,6 +3156,9 @@ function zohoAccountsFactory(factoryConfig) {
|
|
|
3047
3156
|
};
|
|
3048
3157
|
return result;
|
|
3049
3158
|
};
|
|
3159
|
+
tokenRefresher.resetAccessToken = async () => {
|
|
3160
|
+
return config.accessTokenCache?.clearCachedToken();
|
|
3161
|
+
};
|
|
3050
3162
|
const loadAccessToken = zohoAccountsZohoAccessTokenFactory({
|
|
3051
3163
|
tokenRefresher,
|
|
3052
3164
|
accessTokenCache: config.accessTokenCache
|
|
@@ -3083,7 +3195,10 @@ function zohoAccountsZohoAccessTokenFactory(config) {
|
|
|
3083
3195
|
* Caches the token internally here until it expires.
|
|
3084
3196
|
*/
|
|
3085
3197
|
let currentToken = null;
|
|
3086
|
-
|
|
3198
|
+
const resetAccessToken = async () => {
|
|
3199
|
+
currentToken = null;
|
|
3200
|
+
};
|
|
3201
|
+
const fn = async () => {
|
|
3087
3202
|
// load from cache
|
|
3088
3203
|
if (!currentToken) {
|
|
3089
3204
|
const cachedToken = await accessTokenCache?.loadCachedToken();
|
|
@@ -3116,6 +3231,8 @@ function zohoAccountsZohoAccessTokenFactory(config) {
|
|
|
3116
3231
|
}
|
|
3117
3232
|
return currentToken;
|
|
3118
3233
|
};
|
|
3234
|
+
fn.resetAccessToken = resetAccessToken;
|
|
3235
|
+
return fn;
|
|
3119
3236
|
}
|
|
3120
3237
|
|
|
3121
3238
|
function safeZohoDateTimeString(date) {
|
|
@@ -3132,4 +3249,4 @@ function zohoDateTimeString(date) {
|
|
|
3132
3249
|
return isoDate.substring(0, isoDate.length - 5) + 'Z';
|
|
3133
3250
|
}
|
|
3134
3251
|
|
|
3135
|
-
export { DEFAULT_ZOHO_API_RATE_LIMIT, DEFAULT_ZOHO_API_RATE_LIMIT_RESET_PERIOD, DEFAULT_ZOHO_RATE_LIMITED_TOO_MANY_REQUETS_LOG_FUNCTION, MAX_ZOHO_RECRUIT_SEARCH_MODULE_RECORDS_CRITERIA, ZOHO_ACCOUNTS_INVALID_CLIENT_ERROR_CODE, ZOHO_ACCOUNTS_INVALID_CODE_ERROR_CODE, ZOHO_ACCOUNTS_US_API_URL, ZOHO_DUPLICATE_DATA_ERROR_CODE, ZOHO_ERROR_STATUS, ZOHO_FAILURE_ERROR_CODE, ZOHO_INTERNAL_ERROR_CODE, ZOHO_INVALID_AUTHORIZATION_ERROR_CODE, ZOHO_INVALID_DATA_ERROR_CODE, ZOHO_INVALID_QUERY_ERROR_CODE, ZOHO_MANDATORY_NOT_FOUND_ERROR_CODE, ZOHO_RATE_LIMIT_LIMIT_HEADER, ZOHO_RATE_LIMIT_REMAINING_HEADER, ZOHO_RATE_LIMIT_RESET_HEADER, ZOHO_RECRUIT_ALREADY_ASSOCIATED_ERROR_CODE, ZOHO_RECRUIT_ATTACHMENTS_MODULE, ZOHO_RECRUIT_CANDIDATES_MODULE, ZOHO_RECRUIT_EMAILS_MODULE, ZOHO_RECRUIT_JOB_OPENINGS_MODULE, ZOHO_RECRUIT_NOTES_MODULE, ZOHO_RECRUIT_RECORD_ATTACHMENT_METADATA_ATTACH_TYPE_RESUME, ZOHO_RECRUIT_SERVICE_NAME, ZOHO_RECRUIT_TAG_NAME_MAX_LENGTH, ZOHO_SUCCESS_CODE, ZOHO_SUCCESS_STATUS, ZOHO_TOO_MANY_REQUESTS_ERROR_CODE, ZOHO_TOO_MANY_REQUESTS_HTTP_STATUS_CODE, ZohoAccountsAccessTokenError, ZohoAccountsAuthFailureError, ZohoInternalError, ZohoInvalidAuthorizationError, ZohoInvalidQueryError, ZohoRecruitExecuteRestApiFunctionError, ZohoRecruitRecordCrudDuplicateDataError, ZohoRecruitRecordCrudError, ZohoRecruitRecordCrudInvalidDataError, ZohoRecruitRecordCrudMandatoryFieldNotFoundError, ZohoRecruitRecordCrudNoMatchingRecordError, ZohoRecruitRecordNoContentError, ZohoServerError, ZohoServerFetchResponseError, ZohoTooManyRequestsError, accessToken, addTagsToRecords, assertRecordDataArrayResultHasContent, associateCandidateRecordsWithJobOpenings, createNotes, createNotesForRecord, createTagsForModule, deleteNotes, deleteRecord, emptyZohoPageResult, escapeZohoFieldValueForCriteriaString, executeRestApiFunction, getAttachmentsForRecord, getAttachmentsForRecordPageFactory, getEmailsForRecord, getEmailsForRecordPageFactory, getNotesForRecord, getNotesForRecordPageFactory, getRecordById, getRecords, getRelatedRecordsFunctionFactory, getTagsForModule, getTagsForModulePageFactory, handleZohoAccountsErrorFetch, handleZohoErrorFetchFactory, handleZohoRecruitErrorFetch, insertRecord, interceptZohoAccounts200StatusWithErrorResponse, interceptZohoErrorResponseFactory, interceptZohoRecruit200StatusWithErrorResponse, isZohoRecruitValidUrl, logZohoAccountsErrorToConsole, logZohoRecruitErrorToConsole, logZohoServerErrorFunction, parseZohoAccountsError, parseZohoAccountsServerErrorResponseData, parseZohoRecruitError, parseZohoRecruitServerErrorResponseData, parseZohoServerErrorResponseData, safeZohoDateTimeString, searchAssociatedRecords, searchCandidateAssociatedJobOpeningRecords, searchCandidateAssociatedJobOpeningRecordsPageFactory, searchJobOpeningAssociatedCandidateRecords, searchJobOpeningAssociatedCandidateRecordsPageFactory, searchRecords, searchRecordsPageFactory, tryFindZohoServerErrorData, updateRecord, upsertRecord, zohoAccessTokenStringFactory, zohoAccountsApiFetchJsonInput, zohoAccountsConfigApiUrl, zohoAccountsFactory, zohoAccountsZohoAccessTokenFactory, zohoDateTimeString, zohoFetchPageFactory, zohoRateLimitHeaderDetails, zohoRateLimitedFetchHandler, zohoRecruitApiFetchJsonInput, zohoRecruitChangeObjectLikeResponseSuccessAndErrorPairs, zohoRecruitConfigApiUrl, zohoRecruitFactory, zohoRecruitMultiRecordResult, zohoRecruitRecordCrudError, zohoRecruitSearchRecordsCriteriaEntriesForEmails, zohoRecruitSearchRecordsCriteriaEntryToCriteriaString, zohoRecruitSearchRecordsCriteriaString, zohoRecruitSearchRecordsCriteriaStringForTree, zohoRecruitUrlSearchParams, zohoRecruitUrlSearchParamsMinusIdAndModule, zohoRecruitUrlSearchParamsMinusModule, zohoServerErrorData };
|
|
3252
|
+
export { DEFAULT_ZOHO_API_RATE_LIMIT, DEFAULT_ZOHO_API_RATE_LIMIT_RESET_PERIOD, DEFAULT_ZOHO_RATE_LIMITED_TOO_MANY_REQUETS_LOG_FUNCTION, MAX_ZOHO_RECRUIT_SEARCH_MODULE_RECORDS_CRITERIA, ZOHO_ACCOUNTS_INVALID_CLIENT_ERROR_CODE, ZOHO_ACCOUNTS_INVALID_CODE_ERROR_CODE, ZOHO_ACCOUNTS_US_API_URL, ZOHO_DUPLICATE_DATA_ERROR_CODE, ZOHO_ERROR_STATUS, ZOHO_FAILURE_ERROR_CODE, ZOHO_INTERNAL_ERROR_CODE, ZOHO_INVALID_AUTHORIZATION_ERROR_CODE, ZOHO_INVALID_DATA_ERROR_CODE, ZOHO_INVALID_QUERY_ERROR_CODE, ZOHO_INVALID_TOKEN_ERROR_CODE, ZOHO_MANDATORY_NOT_FOUND_ERROR_CODE, ZOHO_RATE_LIMIT_LIMIT_HEADER, ZOHO_RATE_LIMIT_REMAINING_HEADER, ZOHO_RATE_LIMIT_RESET_HEADER, ZOHO_RECRUIT_ALREADY_ASSOCIATED_ERROR_CODE, ZOHO_RECRUIT_ATTACHMENTS_MODULE, ZOHO_RECRUIT_ATTACHMENT_MAX_SIZE, ZOHO_RECRUIT_CANDIDATES_MODULE, ZOHO_RECRUIT_EMAILS_MODULE, ZOHO_RECRUIT_JOB_OPENINGS_MODULE, ZOHO_RECRUIT_NOTES_MODULE, ZOHO_RECRUIT_RECORD_ATTACHMENT_METADATA_ATTACH_TYPE_RESUME, ZOHO_RECRUIT_SERVICE_NAME, ZOHO_RECRUIT_TAG_NAME_MAX_LENGTH, ZOHO_SUCCESS_CODE, ZOHO_SUCCESS_STATUS, ZOHO_TOO_MANY_REQUESTS_ERROR_CODE, ZOHO_TOO_MANY_REQUESTS_HTTP_STATUS_CODE, ZohoAccountsAccessTokenError, ZohoAccountsAuthFailureError, ZohoInternalError, ZohoInvalidAuthorizationError, ZohoInvalidQueryError, ZohoInvalidTokenError, ZohoRecruitExecuteRestApiFunctionError, ZohoRecruitRecordCrudDuplicateDataError, ZohoRecruitRecordCrudError, ZohoRecruitRecordCrudInvalidDataError, ZohoRecruitRecordCrudMandatoryFieldNotFoundError, ZohoRecruitRecordCrudNoMatchingRecordError, ZohoRecruitRecordNoContentError, ZohoServerError, ZohoServerFetchResponseError, ZohoTooManyRequestsError, accessToken, addTagsToRecords, assertRecordDataArrayResultHasContent, associateCandidateRecordsWithJobOpenings, createNotes, createNotesForRecord, createTagsForModule, deleteAttachmentFromRecord, deleteNotes, deleteRecord, downloadAttachmentForRecord, emptyZohoPageResult, escapeZohoFieldValueForCriteriaString, executeRestApiFunction, getAttachmentsForRecord, getAttachmentsForRecordPageFactory, getEmailsForRecord, getEmailsForRecordPageFactory, getNotesForRecord, getNotesForRecordPageFactory, getRecordById, getRecords, getRelatedRecordsFunctionFactory, getTagsForModule, getTagsForModulePageFactory, handleZohoAccountsErrorFetch, handleZohoErrorFetchFactory, handleZohoRecruitErrorFetch, insertRecord, interceptZohoAccounts200StatusWithErrorResponse, interceptZohoErrorResponseFactory, interceptZohoRecruit200StatusWithErrorResponse, isZohoRecruitValidUrl, logZohoAccountsErrorToConsole, logZohoRecruitErrorToConsole, logZohoServerErrorFunction, parseZohoAccountsError, parseZohoAccountsServerErrorResponseData, parseZohoRecruitError, parseZohoRecruitServerErrorResponseData, parseZohoServerErrorResponseData, safeZohoDateTimeString, searchAssociatedRecords, searchCandidateAssociatedJobOpeningRecords, searchCandidateAssociatedJobOpeningRecordsPageFactory, searchJobOpeningAssociatedCandidateRecords, searchJobOpeningAssociatedCandidateRecordsPageFactory, searchRecords, searchRecordsPageFactory, tryFindZohoServerErrorData, updateRecord, uploadAttachmentForRecord, upsertRecord, zohoAccessTokenStringFactory, zohoAccountsApiFetchJsonInput, zohoAccountsConfigApiUrl, zohoAccountsFactory, zohoAccountsZohoAccessTokenFactory, zohoDateTimeString, zohoFetchPageFactory, zohoRateLimitHeaderDetails, zohoRateLimitedFetchHandler, zohoRecruitApiFetchJsonInput, zohoRecruitChangeObjectLikeResponseSuccessAndErrorPairs, zohoRecruitConfigApiUrl, zohoRecruitFactory, zohoRecruitMultiRecordResult, zohoRecruitRecordCrudError, zohoRecruitSearchRecordsCriteriaEntriesForEmails, zohoRecruitSearchRecordsCriteriaEntryToCriteriaString, zohoRecruitSearchRecordsCriteriaString, zohoRecruitSearchRecordsCriteriaStringForTree, zohoRecruitUrlSearchParams, zohoRecruitUrlSearchParamsMinusIdAndModule, zohoRecruitUrlSearchParamsMinusModule, zohoServerErrorData };
|
package/nestjs/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [12.3.9](https://github.com/dereekb/dbx-components/compare/v12.3.8-dev...v12.3.9) (2025-08-15)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## [12.3.8](https://github.com/dereekb/dbx-components/compare/v12.3.7-dev...v12.3.8) (2025-08-14)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
5
13
|
## [12.3.7](https://github.com/dereekb/dbx-components/compare/v12.3.6-dev...v12.3.7) (2025-08-14)
|
|
6
14
|
|
|
7
15
|
|
package/nestjs/package.json
CHANGED
|
@@ -76,6 +76,9 @@ function mergeZohoAccountsAccessTokenCacheServices(inputServicesToMerge, logErro
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
|
+
},
|
|
80
|
+
clearCachedToken: async function () {
|
|
81
|
+
await Promise.allSettled(accessCachesForServices.map((x) => x.clearCachedToken()));
|
|
79
82
|
}
|
|
80
83
|
};
|
|
81
84
|
return cacheForService;
|
|
@@ -105,6 +108,12 @@ function memoryZohoAccountsAccessTokenCacheService(existingCache, logAccessToCon
|
|
|
105
108
|
if (logAccessToConsole) {
|
|
106
109
|
console.log('updating access token in memory: ', { accessToken, service });
|
|
107
110
|
}
|
|
111
|
+
},
|
|
112
|
+
clearCachedToken: async function () {
|
|
113
|
+
delete tokens[service];
|
|
114
|
+
if (logAccessToConsole) {
|
|
115
|
+
console.log('clearing access token in memory: ', { service });
|
|
116
|
+
}
|
|
108
117
|
}
|
|
109
118
|
};
|
|
110
119
|
return accessTokenCache;
|
|
@@ -209,6 +218,14 @@ function fileZohoAccountsAccessTokenCacheService(filename = exports.DEFAULT_FILE
|
|
|
209
218
|
catch (e) {
|
|
210
219
|
console.error('Failed updating access token in file: ', e);
|
|
211
220
|
}
|
|
221
|
+
},
|
|
222
|
+
clearCachedToken: async function () {
|
|
223
|
+
try {
|
|
224
|
+
await writeTokenFile({});
|
|
225
|
+
}
|
|
226
|
+
catch (e) {
|
|
227
|
+
console.error('Failed clearing access token in file: ', e);
|
|
228
|
+
}
|
|
212
229
|
}
|
|
213
230
|
};
|
|
214
231
|
return accessTokenCache;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.service.js","sourceRoot":"","sources":["../../../../../../../packages/zoho/nestjs/src/lib/accounts/accounts.service.ts"],"names":[],"mappings":";;;AAuBA,4HAKC;AAWD,
|
|
1
|
+
{"version":3,"file":"accounts.service.js","sourceRoot":"","sources":["../../../../../../../packages/zoho/nestjs/src/lib/accounts/accounts.service.ts"],"names":[],"mappings":";;;AAuBA,4HAKC;AAWD,8FAkEC;AAQD,8FAkCC;AAkBD,0FAgHC;;AArRD,2CAA4C;AAE5C,wCAAsI;AACtI,+BAA+B;AAC/B,2BAAwD;AA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,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;gBAC9B,0EAA0E;gBAC1E,OAAO,KAAK,CAAC;YACf,CAAC;YACD,iBAAiB,EAAE,KAAK,WAAW,WAA4B;gBAC7D,MAAM,MAAM,GAAG,MAAM,UAAU,EAAE,CAAC;gBAElC,IAAI,MAAM,EAAE,CAAC;oBACX,MAAM,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC;gBAChC,CAAC;gBAED,4EAA4E;gBAE5E,IAAI,CAAC;oBACH,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;gBAC/B,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,CAAC,CAAC,CAAC;gBAC7D,CAAC;YACH,CAAC;YACD,gBAAgB,EAAE,KAAK;gBACrB,IAAI,CAAC;oBACH,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;gBAC3B,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,CAAC,CAAC,CAAC;gBAC7D,CAAC;YACH,CAAC;SACF,CAAC;QAEF,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,OAAO;QACL,wBAAwB;QACxB,aAAa;QACb,cAAc;QACd,eAAe;KAChB,CAAC;AACJ,CAAC"}
|
|
@@ -21,6 +21,9 @@ export declare class ZohoRecruitApi {
|
|
|
21
21
|
get getEmailsForRecordPageFactory(): import("@dereekb/zoho").GetEmailsForRecordPageFactory;
|
|
22
22
|
get getAttachmentsForRecord(): import("@dereekb/zoho").ZohoRecruitGetAttachmentsForRecordFunction;
|
|
23
23
|
get getAttachmentsForRecordPageFactory(): import("@dereekb/zoho").GetAttachmentsForRecordPageFactory;
|
|
24
|
+
get uploadAttachmentForRecord(): import("@dereekb/zoho").ZohoRecruitUploadAttachmentForRecordFunction;
|
|
25
|
+
get downloadAttachmentForRecord(): import("@dereekb/zoho").ZohoRecruitDownloadAttachmentForRecordFunction;
|
|
26
|
+
get deleteAttachmentFromRecord(): import("@dereekb/zoho").ZohoRecruitDeleteAttachmentFromRecordFunction;
|
|
24
27
|
get createNotes(): (input: import("@dereekb/zoho").ZohoRecruitCreateNotesRequest) => Promise<import("@dereekb/zoho").ZohoRecruitMultiRecordResult<import("@dereekb/zoho").NewZohoRecruitNoteData, import("@dereekb/zoho").ZohoRecruitChangeObjectResponseSuccessEntry<import("@dereekb/zoho").ZohoRecruitChangeObjectDetails>, import("@dereekb/zoho").ZohoRecruitChangeObjectResponseErrorEntry>>;
|
|
25
28
|
get deleteNotes(): (input: import("@dereekb/zoho").ZohoRecruitDeleteNotesRequest) => Promise<import("@dereekb/zoho").ZohoRecruitMultiRecordResult<string, import("@dereekb/zoho").ZohoRecruitChangeObjectResponseSuccessEntry<import("@dereekb/zoho").ZohoRecruitChangeObjectDetails>, import("@dereekb/zoho").ZohoRecruitChangeObjectResponseErrorEntry>>;
|
|
26
29
|
get createNotesForRecord(): import("@dereekb/zoho").ZohoRecruitCreateNotesForRecordFunction;
|
|
@@ -64,6 +64,15 @@ let ZohoRecruitApi = class ZohoRecruitApi {
|
|
|
64
64
|
get getAttachmentsForRecordPageFactory() {
|
|
65
65
|
return (0, zoho_1.getAttachmentsForRecordPageFactory)(this.recruitContext);
|
|
66
66
|
}
|
|
67
|
+
get uploadAttachmentForRecord() {
|
|
68
|
+
return (0, zoho_1.uploadAttachmentForRecord)(this.recruitContext);
|
|
69
|
+
}
|
|
70
|
+
get downloadAttachmentForRecord() {
|
|
71
|
+
return (0, zoho_1.downloadAttachmentForRecord)(this.recruitContext);
|
|
72
|
+
}
|
|
73
|
+
get deleteAttachmentFromRecord() {
|
|
74
|
+
return (0, zoho_1.deleteAttachmentFromRecord)(this.recruitContext);
|
|
75
|
+
}
|
|
67
76
|
get createNotes() {
|
|
68
77
|
return (0, zoho_1.createNotes)(this.recruitContext);
|
|
69
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recruit.api.js","sourceRoot":"","sources":["../../../../../../../packages/zoho/nestjs/src/lib/recruit/recruit.api.ts"],"names":[],"mappings":";;;;AAAA,2CAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"recruit.api.js","sourceRoot":"","sources":["../../../../../../../packages/zoho/nestjs/src/lib/recruit/recruit.api.ts"],"names":[],"mappings":";;;;AAAA,2CAAoD;AACpD,wCAkCuB;AACvB,qDAA4D;AAC5D,2DAA2D;AAGpD,IAAM,cAAc,GAApB,MAAM,cAAc;IAYoB;IACT;IAZ3B,WAAW,CAAc;IAElC,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC;IACzC,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,eAAe,CAAC;IACzD,CAAC;IAED,YAC6C,MAAgC,EACzC,eAAgC;QADvB,WAAM,GAAN,MAAM,CAA0B;QACzC,oBAAe,GAAf,eAAe,CAAiB;QAElE,IAAI,CAAC,WAAW,GAAG,IAAA,yBAAkB,EAAC;YACpC,GAAG,MAAM,CAAC,aAAa;YACvB,eAAe,EAAE,eAAe,CAAC,eAAe;SACjD,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACzB,CAAC;IAED,kBAAkB;IAClB,IAAI,YAAY;QACd,OAAO,IAAA,mBAAY,EAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAA,mBAAY,EAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAA,mBAAY,EAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAA,mBAAY,EAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAA,oBAAa,EAA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R,mBAAA,IAAA,eAAM,EAAC,yCAAwB,CAAC,CAAA;IAChC,mBAAA,IAAA,eAAM,EAAC,8BAAe,CAAC,CAAA;6CAD2B,yCAAwB;QACxB,8BAAe;GAbzD,cAAc,CA6I1B"}
|
package/package.json
CHANGED
|
@@ -52,13 +52,22 @@ export interface ZohoAccessTokenCache {
|
|
|
52
52
|
* Updates the cache with the given access token.
|
|
53
53
|
*/
|
|
54
54
|
updateCachedToken(accessToken: ZohoAccessToken): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Clears the cached token.
|
|
57
|
+
*/
|
|
58
|
+
clearCachedToken(): Promise<void>;
|
|
55
59
|
}
|
|
56
60
|
/**
|
|
57
61
|
* Source for retriving a ZohoAccessToken.
|
|
58
62
|
*
|
|
59
63
|
* Throws an ZohoAccountsAuthRetrievalError error if the token could not be retrieved.
|
|
60
64
|
*/
|
|
61
|
-
export type ZohoAccessTokenFactory = () => Promise<ZohoAccessToken
|
|
65
|
+
export type ZohoAccessTokenFactory = (() => Promise<ZohoAccessToken>) & {
|
|
66
|
+
/**
|
|
67
|
+
* Resets/expires the existing token in the factory, if using a cache.
|
|
68
|
+
*/
|
|
69
|
+
resetAccessToken(): Promise<void>;
|
|
70
|
+
};
|
|
62
71
|
/**
|
|
63
72
|
* A ZohoAccessTokenFactory that always generates a new ZohoAccessToken.
|
|
64
73
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ZohoDataArrayResultRef, ZohoPageFilter, ZohoPageResult } from './../zoho.api.page';
|
|
2
|
-
import { FetchJsonBody, FetchJsonInput, FetchPage, FetchPageFactory, FetchPageFactoryOptions, makeUrlSearchParams } from '@dereekb/util/fetch';
|
|
2
|
+
import { FetchFileResponse, FetchJsonBody, FetchJsonInput, FetchPage, FetchPageFactory, FetchPageFactoryOptions, makeUrlSearchParams } from '@dereekb/util/fetch';
|
|
3
3
|
import { ZohoRecruitConfigApiUrlInput, ZohoRecruitContext } from './recruit.config';
|
|
4
|
-
import { ZohoRecruitCommaSeparateFieldNames, ZohoRecruitCustomViewId, ZohoRecruitDraftOrSaveState, ZohoRecruitFieldName, ZohoRecruitModuleNameRef, ZohoRecruitChangeObjectDetails, ZohoRecruitRecord, ZohoRecruitRecordId, ZohoRecruitTerritoryId, ZohoRecruitTrueFalseBoth, ZohoRecruitRestFunctionApiName, ZohoRecruitUserId, ZohoRecruitModuleName, ZohoRecruitRecordEmailMetadata, ZohoRecruitRecordAttachmentMetadata } from './recruit';
|
|
4
|
+
import { ZohoRecruitCommaSeparateFieldNames, ZohoRecruitCustomViewId, ZohoRecruitDraftOrSaveState, ZohoRecruitFieldName, ZohoRecruitModuleNameRef, ZohoRecruitChangeObjectDetails, ZohoRecruitRecord, ZohoRecruitRecordId, ZohoRecruitTerritoryId, ZohoRecruitTrueFalseBoth, ZohoRecruitRestFunctionApiName, ZohoRecruitUserId, ZohoRecruitModuleName, ZohoRecruitRecordEmailMetadata, ZohoRecruitRecordAttachmentMetadata, ZohoRecruitAttachmentRecordId, ZohoRecruitAttachmentCategoryId, KnownZohoRecruitAttachmentCategoryName } from './recruit';
|
|
5
5
|
import { ZohoRecruitSearchRecordsCriteriaTreeElement } from './recruit.criteria';
|
|
6
|
-
import { ArrayOrValue, EmailAddress, Maybe, PhoneNumber, SortingOrder, UniqueModelWithId } from '@dereekb/util';
|
|
6
|
+
import { ArrayOrValue, EmailAddress, Maybe, PhoneNumber, SortingOrder, UniqueModelWithId, WebsiteUrlWithPrefix } from '@dereekb/util';
|
|
7
7
|
import { ZohoServerErrorDataWithDetails, ZohoServerErrorStatus, ZohoServerSuccessCode, ZohoServerSuccessStatus } from '../zoho.error.api';
|
|
8
8
|
import { ZohoDateTimeString } from '../zoho.type';
|
|
9
9
|
import { BaseError } from 'make-error';
|
|
@@ -209,6 +209,81 @@ export type ZohoRecruitGetAttachmentsForRecordFunction = (input: ZohoRecruitGetA
|
|
|
209
209
|
export declare function getAttachmentsForRecord(context: ZohoRecruitContext): ZohoRecruitGetAttachmentsForRecordFunction;
|
|
210
210
|
export type GetAttachmentsForRecordPageFactory = FetchPageFactory<ZohoRecruitGetAttachmentsForRecordRequest, ZohoRecruitGetAttachmentsForRecordResponse>;
|
|
211
211
|
export declare function getAttachmentsForRecordPageFactory(context: ZohoRecruitContext): GetAttachmentsForRecordPageFactory;
|
|
212
|
+
/**
|
|
213
|
+
* Maximum attachment size allowed by Zoho Recruit.
|
|
214
|
+
*
|
|
215
|
+
* 20MB
|
|
216
|
+
*/
|
|
217
|
+
export declare const ZOHO_RECRUIT_ATTACHMENT_MAX_SIZE: number;
|
|
218
|
+
export interface ZohoRecruitUploadAttachmentForRecordRequest extends ZohoRecruitGetRecordByIdInput {
|
|
219
|
+
/**
|
|
220
|
+
* Requires the use of a FormData object.
|
|
221
|
+
*
|
|
222
|
+
* Max of 20MB are allowed
|
|
223
|
+
*
|
|
224
|
+
* @deprecated Use attachmentUrl instead for now.
|
|
225
|
+
*/
|
|
226
|
+
readonly formData?: FormData;
|
|
227
|
+
/**
|
|
228
|
+
* File url to pull the file from.
|
|
229
|
+
*
|
|
230
|
+
* Either this or formData must be provided.
|
|
231
|
+
*/
|
|
232
|
+
readonly attachmentUrl?: WebsiteUrlWithPrefix;
|
|
233
|
+
/**
|
|
234
|
+
* The category id(s) of the attachment.
|
|
235
|
+
*
|
|
236
|
+
* Either this or attachments_category must be provided.
|
|
237
|
+
*/
|
|
238
|
+
readonly attachmentCategoryId?: ArrayOrValue<ZohoRecruitAttachmentCategoryId>;
|
|
239
|
+
/**
|
|
240
|
+
* The category name(s) of the attachment.
|
|
241
|
+
*
|
|
242
|
+
* Either this or attachments_category_id must be provided.
|
|
243
|
+
*
|
|
244
|
+
* Example: "Resume"
|
|
245
|
+
*/
|
|
246
|
+
readonly attachmentCategoryName?: ArrayOrValue<KnownZohoRecruitAttachmentCategoryName>;
|
|
247
|
+
}
|
|
248
|
+
export type ZohoRecruitUploadAttachmentForRecordResponse = Response;
|
|
249
|
+
export type ZohoRecruitUploadAttachmentForRecordFunction = (input: ZohoRecruitUploadAttachmentForRecordRequest) => Promise<ZohoRecruitUploadAttachmentForRecordResponse>;
|
|
250
|
+
/**
|
|
251
|
+
* Uploads an attachment to a record.
|
|
252
|
+
*
|
|
253
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/upload-attachment.html
|
|
254
|
+
*
|
|
255
|
+
* @param context
|
|
256
|
+
* @returns
|
|
257
|
+
*/
|
|
258
|
+
export declare function uploadAttachmentForRecord(context: ZohoRecruitContext): ZohoRecruitUploadAttachmentForRecordFunction;
|
|
259
|
+
export interface ZohoRecruitDownloadAttachmentForRecordRequest extends ZohoRecruitGetRecordByIdInput {
|
|
260
|
+
readonly attachment_id: ZohoRecruitAttachmentRecordId;
|
|
261
|
+
}
|
|
262
|
+
export type ZohoRecruitDownloadAttachmentForRecordResponse = FetchFileResponse;
|
|
263
|
+
export type ZohoRecruitDownloadAttachmentForRecordFunction = (input: ZohoRecruitDownloadAttachmentForRecordRequest) => Promise<ZohoRecruitDownloadAttachmentForRecordResponse>;
|
|
264
|
+
/**
|
|
265
|
+
* Downloads an attachment from a record.
|
|
266
|
+
*
|
|
267
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/download-attachments.html
|
|
268
|
+
*
|
|
269
|
+
* @param context
|
|
270
|
+
* @returns
|
|
271
|
+
*/
|
|
272
|
+
export declare function downloadAttachmentForRecord(context: ZohoRecruitContext): ZohoRecruitDownloadAttachmentForRecordFunction;
|
|
273
|
+
export interface ZohoRecruitDeleteAttachmentFromRecordRequest extends ZohoRecruitGetRecordByIdInput {
|
|
274
|
+
readonly attachment_id: ZohoRecruitAttachmentRecordId;
|
|
275
|
+
}
|
|
276
|
+
export type ZohoRecruitDeleteAttachmentFromRecordResponse = Response;
|
|
277
|
+
export type ZohoRecruitDeleteAttachmentFromRecordFunction = (input: ZohoRecruitDeleteAttachmentFromRecordRequest) => Promise<ZohoRecruitDeleteAttachmentFromRecordResponse>;
|
|
278
|
+
/**
|
|
279
|
+
* Deletes an attachment from a record.
|
|
280
|
+
*
|
|
281
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/delete-attachments.html
|
|
282
|
+
*
|
|
283
|
+
* @param context
|
|
284
|
+
* @returns
|
|
285
|
+
*/
|
|
286
|
+
export declare function deleteAttachmentFromRecord(context: ZohoRecruitContext): ZohoRecruitDeleteAttachmentFromRecordFunction;
|
|
212
287
|
export type ZohoRecruitExecuteRestApiFunctionRequest = ZohoRecruitExecuteRestApiFunctionNormalRequest | ZohoRecruitExecuteRestApiFunctionApiSpecificRequest;
|
|
213
288
|
export interface ZohoRecruitExecuteRestApiFunctionNormalRequest {
|
|
214
289
|
readonly functionName: ZohoRecruitRestFunctionApiName;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FactoryWithRequiredInput } from '@dereekb/util';
|
|
2
2
|
import { ConfiguredFetch, FetchJsonFunction } from '@dereekb/util/fetch';
|
|
3
3
|
import { ZohoApiUrl, ZohoApiUrlKey, ZohoConfig, ZohoApiServiceName } from '../zoho.config';
|
|
4
|
-
import { ZohoServiceAccessTokenKey } from '../accounts';
|
|
4
|
+
import { ZohoAccessTokenStringFactory, ZohoServiceAccessTokenKey } from '../accounts';
|
|
5
5
|
import { ZohoRateLimiterRef } from '../zoho.limit';
|
|
6
6
|
export declare const ZOHO_RECRUIT_SERVICE_NAME: ZohoApiServiceName | ZohoServiceAccessTokenKey;
|
|
7
7
|
export type ZohoRecruitApiUrl = ZohoApiUrl;
|
|
@@ -16,6 +16,7 @@ export type ZohoRecruitFetchFactory = FactoryWithRequiredInput<ConfiguredFetch,
|
|
|
16
16
|
export interface ZohoRecruitContext extends ZohoRateLimiterRef {
|
|
17
17
|
readonly fetch: ConfiguredFetch;
|
|
18
18
|
readonly fetchJson: FetchJsonFunction;
|
|
19
|
+
readonly accessTokenStringFactory: ZohoAccessTokenStringFactory;
|
|
19
20
|
readonly config: ZohoRecruitConfig;
|
|
20
21
|
}
|
|
21
22
|
export interface ZohoRecruitContextRef {
|
|
@@ -199,6 +199,27 @@ export type ZohoRecruitAttachmentRecordId = ZohoRecruitRecordId;
|
|
|
199
199
|
* The size of the attachment in bytes, stored as a string.
|
|
200
200
|
*/
|
|
201
201
|
export type ZohoRecruitRecordAttachmentMetadataSize = string;
|
|
202
|
+
/**
|
|
203
|
+
* Attachment category id
|
|
204
|
+
*/
|
|
205
|
+
export type ZohoRecruitAttachmentCategoryId = string;
|
|
206
|
+
/**
|
|
207
|
+
* Known attachment category names
|
|
208
|
+
*/
|
|
209
|
+
export type KnownZohoRecruitAttachmentCategoryName = 'Resume' | 'Offer' | 'Contracts' | 'Criminal records' | 'Mandatory reporter' | 'Teaching certification' | 'Health records' | 'Others' | 'Cover Letter' | 'Formatted Resume';
|
|
210
|
+
/**
|
|
211
|
+
* Attachment category name
|
|
212
|
+
*
|
|
213
|
+
* I.E. "Resume"
|
|
214
|
+
*/
|
|
215
|
+
export type ZohoRecruitAttachmentCategoryName = KnownZohoRecruitAttachmentCategoryName | string;
|
|
216
|
+
/**
|
|
217
|
+
* The type of attachment.
|
|
218
|
+
*
|
|
219
|
+
* "Attachment" - Download the attachment to retrieve the value.
|
|
220
|
+
* "Link URL" - Use the Attachment_URL property to retrieve the value.
|
|
221
|
+
*/
|
|
222
|
+
export type ZohoRecruitAttachmentType = 'Attachment' | 'Link URL';
|
|
202
223
|
/**
|
|
203
224
|
* Metadata for a record's attachment.
|
|
204
225
|
*/
|
|
@@ -240,9 +261,9 @@ export interface ZohoRecruitRecordAttachmentMetadata {
|
|
|
240
261
|
*/
|
|
241
262
|
$file_id: string;
|
|
242
263
|
/**
|
|
243
|
-
* Type
|
|
264
|
+
* Type of attachment, and how to retrieve the value.
|
|
244
265
|
*/
|
|
245
|
-
$type:
|
|
266
|
+
$type: ZohoRecruitAttachmentType;
|
|
246
267
|
/**
|
|
247
268
|
* Direct URL to the attachment, when available
|
|
248
269
|
*/
|
|
@@ -70,7 +70,7 @@ export declare function logZohoServerErrorFunction(zohoApiNamePrefix: string): L
|
|
|
70
70
|
* @param fetch
|
|
71
71
|
* @returns
|
|
72
72
|
*/
|
|
73
|
-
export type HandleZohoErrorFetchFactory = (fetch: ConfiguredFetch, logError?: LogZohoServerErrorFunction) => ConfiguredFetch;
|
|
73
|
+
export type HandleZohoErrorFetchFactory = (fetch: ConfiguredFetch, logError?: LogZohoServerErrorFunction, onError?: (error: ParsedZohoServerError) => void) => ConfiguredFetch;
|
|
74
74
|
export type ParsedZohoServerError = FetchRequestFactoryError | ZohoServerError | undefined;
|
|
75
75
|
export type ParseZohoFetchResponseErrorFunction = (responseError: FetchResponseError) => Promise<ParsedZohoServerError>;
|
|
76
76
|
/**
|
|
@@ -90,6 +90,12 @@ export declare function interceptZohoErrorResponseFactory(parseZohoServerErrorRe
|
|
|
90
90
|
* - An extra parameter is provided
|
|
91
91
|
*/
|
|
92
92
|
export declare const ZOHO_INTERNAL_ERROR_CODE = "INTERNAL_ERROR";
|
|
93
|
+
/**
|
|
94
|
+
* Error code for when an invalid oauth token is provided.
|
|
95
|
+
*/
|
|
96
|
+
export declare const ZOHO_INVALID_TOKEN_ERROR_CODE = "INVALID_TOKEN";
|
|
97
|
+
export declare class ZohoInvalidTokenError extends ZohoServerFetchResponseError {
|
|
98
|
+
}
|
|
93
99
|
/**
|
|
94
100
|
* Error code for when a failure occured for the given action
|
|
95
101
|
*/
|