@dereekb/zoho 12.6.21 → 13.0.0
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/LICENSE +1 -1
- package/index.cjs.js +1763 -2531
- package/index.esm.js +1655 -2524
- package/nestjs/index.cjs.js +598 -0
- package/nestjs/index.esm.js +582 -0
- package/nestjs/package.json +19 -3
- package/nestjs/src/lib/accounts/accounts.config.d.ts +32 -0
- package/nestjs/src/lib/crm/crm.api.d.ts +43 -0
- package/nestjs/src/lib/crm/crm.config.d.ts +10 -0
- package/nestjs/src/lib/crm/crm.module.d.ts +24 -0
- package/nestjs/src/lib/crm/index.d.ts +3 -0
- package/nestjs/src/lib/recruit/recruit.api.d.ts +7 -7
- package/package.json +14 -7
- package/src/lib/accounts/accounts.api.d.ts +1 -1
- package/src/lib/accounts/accounts.error.api.d.ts +2 -2
- package/src/lib/crm/crm.api.d.ts +430 -0
- package/src/lib/crm/crm.api.notes.d.ts +40 -0
- package/src/lib/crm/crm.api.tags.d.ts +160 -0
- package/src/lib/crm/crm.config.d.ts +24 -0
- package/src/lib/crm/crm.criteria.d.ts +19 -0
- package/src/lib/crm/crm.d.ts +325 -0
- package/src/lib/crm/crm.error.api.d.ts +52 -0
- package/src/lib/crm/crm.factory.d.ts +22 -0
- package/src/lib/crm/crm.notes.d.ts +48 -0
- package/src/lib/crm/crm.tags.d.ts +40 -0
- package/src/lib/crm/index.d.ts +10 -0
- package/src/lib/index.d.ts +1 -0
- package/src/lib/recruit/index.d.ts +0 -1
- package/src/lib/recruit/recruit.api.candidates.d.ts +6 -6
- package/src/lib/recruit/recruit.api.d.ts +102 -22
- package/src/lib/recruit/recruit.api.notes.d.ts +30 -6
- package/src/lib/recruit/recruit.api.tags.d.ts +30 -6
- package/src/lib/recruit/recruit.criteria.d.ts +8 -44
- package/src/lib/recruit/recruit.d.ts +7 -3
- package/src/lib/recruit/recruit.error.api.d.ts +7 -3
- package/src/lib/shared/criteria.d.ts +55 -0
- package/src/lib/shared/criteria.util.d.ts +10 -0
- package/src/lib/zoho.error.api.d.ts +64 -6
- package/src/lib/zoho.type.d.ts +1 -18
- package/nestjs/CHANGELOG.md +0 -459
- package/nestjs/README.md +0 -11
- package/nestjs/src/index.js +0 -5
- package/nestjs/src/index.js.map +0 -1
- package/nestjs/src/lib/accounts/accounts.api.js +0 -37
- package/nestjs/src/lib/accounts/accounts.api.js.map +0 -1
- package/nestjs/src/lib/accounts/accounts.config.js +0 -50
- package/nestjs/src/lib/accounts/accounts.config.js.map +0 -1
- package/nestjs/src/lib/accounts/accounts.service.js +0 -240
- package/nestjs/src/lib/accounts/accounts.service.js.map +0 -1
- package/nestjs/src/lib/accounts/index.js +0 -7
- package/nestjs/src/lib/accounts/index.js.map +0 -1
- package/nestjs/src/lib/index.js +0 -7
- package/nestjs/src/lib/index.js.map +0 -1
- package/nestjs/src/lib/recruit/index.js +0 -7
- package/nestjs/src/lib/recruit/index.js.map +0 -1
- package/nestjs/src/lib/recruit/recruit.api.js +0 -130
- package/nestjs/src/lib/recruit/recruit.api.js.map +0 -1
- package/nestjs/src/lib/recruit/recruit.config.js +0 -16
- package/nestjs/src/lib/recruit/recruit.config.js.map +0 -1
- package/nestjs/src/lib/recruit/recruit.module.js +0 -61
- package/nestjs/src/lib/recruit/recruit.module.js.map +0 -1
- package/nestjs/src/lib/zoho.config.js +0 -52
- package/nestjs/src/lib/zoho.config.js.map +0 -1
- package/src/lib/recruit/recruit.criteria.util.d.ts +0 -10
- /package/{index.cjs.d.ts → index.d.ts} +0 -0
- /package/{index.esm.d.ts → nestjs/index.d.ts} +0 -0
package/index.cjs.js
CHANGED
|
@@ -1,2265 +1,1519 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
require('core-js/modules/es.iterator.constructor.js');
|
|
4
|
+
require('core-js/modules/es.iterator.filter.js');
|
|
5
|
+
require('core-js/modules/es.iterator.for-each.js');
|
|
3
6
|
var util = require('@dereekb/util');
|
|
4
7
|
var fetch = require('@dereekb/util/fetch');
|
|
8
|
+
require('core-js/modules/es.iterator.flat-map.js');
|
|
9
|
+
require('core-js/modules/es.iterator.map.js');
|
|
5
10
|
var makeError = require('make-error');
|
|
11
|
+
require('core-js/modules/es.set.difference.v2.js');
|
|
12
|
+
require('core-js/modules/es.set.symmetric-difference.v2.js');
|
|
13
|
+
require('core-js/modules/es.set.union.v2.js');
|
|
6
14
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
|
|
14
|
-
var global$b =
|
|
15
|
-
// eslint-disable-next-line es/no-global-this -- safe
|
|
16
|
-
check(typeof globalThis == 'object' && globalThis) ||
|
|
17
|
-
check(typeof window == 'object' && window) ||
|
|
18
|
-
// eslint-disable-next-line no-restricted-globals -- safe
|
|
19
|
-
check(typeof self == 'object' && self) ||
|
|
20
|
-
check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
|
|
21
|
-
check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
|
|
22
|
-
// eslint-disable-next-line no-new-func -- fallback
|
|
23
|
-
(function () { return this; })() || Function('return this')();
|
|
24
|
-
|
|
25
|
-
var objectGetOwnPropertyDescriptor = {};
|
|
26
|
-
|
|
27
|
-
var fails$c = function (exec) {
|
|
28
|
-
try {
|
|
29
|
-
return !!exec();
|
|
30
|
-
} catch (error) {
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
var fails$b = fails$c;
|
|
36
|
-
|
|
37
|
-
// Detect IE8's incomplete defineProperty implementation
|
|
38
|
-
var descriptors = !fails$b(function () {
|
|
39
|
-
// eslint-disable-next-line es/no-object-defineproperty -- required for testing
|
|
40
|
-
return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] !== 7;
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
var fails$a = fails$c;
|
|
44
|
-
|
|
45
|
-
var functionBindNative = !fails$a(function () {
|
|
46
|
-
// eslint-disable-next-line es/no-function-prototype-bind -- safe
|
|
47
|
-
var test = (function () { /* empty */ }).bind();
|
|
48
|
-
// eslint-disable-next-line no-prototype-builtins -- safe
|
|
49
|
-
return typeof test != 'function' || test.hasOwnProperty('prototype');
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
var NATIVE_BIND$2 = functionBindNative;
|
|
53
|
-
|
|
54
|
-
var call$c = Function.prototype.call;
|
|
55
|
-
|
|
56
|
-
var functionCall = NATIVE_BIND$2 ? call$c.bind(call$c) : function () {
|
|
57
|
-
return call$c.apply(call$c, arguments);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
var objectPropertyIsEnumerable = {};
|
|
61
|
-
|
|
62
|
-
var $propertyIsEnumerable = {}.propertyIsEnumerable;
|
|
63
|
-
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
64
|
-
var getOwnPropertyDescriptor$2 = Object.getOwnPropertyDescriptor;
|
|
65
|
-
|
|
66
|
-
// Nashorn ~ JDK8 bug
|
|
67
|
-
var NASHORN_BUG = getOwnPropertyDescriptor$2 && !$propertyIsEnumerable.call({ 1: 2 }, 1);
|
|
68
|
-
|
|
69
|
-
// `Object.prototype.propertyIsEnumerable` method implementation
|
|
70
|
-
// https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
|
|
71
|
-
objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
|
|
72
|
-
var descriptor = getOwnPropertyDescriptor$2(this, V);
|
|
73
|
-
return !!descriptor && descriptor.enumerable;
|
|
74
|
-
} : $propertyIsEnumerable;
|
|
75
|
-
|
|
76
|
-
var createPropertyDescriptor$3 = function (bitmap, value) {
|
|
15
|
+
/**
|
|
16
|
+
* Returns an empty ZohoPageResult that is typed to R and has no more records/results.
|
|
17
|
+
*/
|
|
18
|
+
function emptyZohoPageResult() {
|
|
77
19
|
return {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
var FunctionPrototype$1 = Function.prototype;
|
|
88
|
-
var call$b = FunctionPrototype$1.call;
|
|
89
|
-
var uncurryThisWithBind = NATIVE_BIND$1 && FunctionPrototype$1.bind.bind(call$b, call$b);
|
|
90
|
-
|
|
91
|
-
var functionUncurryThis = NATIVE_BIND$1 ? uncurryThisWithBind : function (fn) {
|
|
92
|
-
return function () {
|
|
93
|
-
return call$b.apply(fn, arguments);
|
|
20
|
+
data: [],
|
|
21
|
+
info: {
|
|
22
|
+
page: 1,
|
|
23
|
+
per_page: 100,
|
|
24
|
+
// default value
|
|
25
|
+
count: 0,
|
|
26
|
+
more_records: false
|
|
27
|
+
}
|
|
94
28
|
};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
} : $Object$4;
|
|
121
|
-
|
|
122
|
-
// we can't use just `it == null` since of `document.all` special case
|
|
123
|
-
// https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec
|
|
124
|
-
var isNullOrUndefined$3 = function (it) {
|
|
125
|
-
return it === null || it === undefined;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
var isNullOrUndefined$2 = isNullOrUndefined$3;
|
|
129
|
-
|
|
130
|
-
var $TypeError$b = TypeError;
|
|
131
|
-
|
|
132
|
-
// `RequireObjectCoercible` abstract operation
|
|
133
|
-
// https://tc39.es/ecma262/#sec-requireobjectcoercible
|
|
134
|
-
var requireObjectCoercible$2 = function (it) {
|
|
135
|
-
if (isNullOrUndefined$2(it)) throw new $TypeError$b("Can't call method on " + it);
|
|
136
|
-
return it;
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
// toObject with fallback for non-array-like ES3 strings
|
|
140
|
-
var IndexedObject = indexedObject;
|
|
141
|
-
var requireObjectCoercible$1 = requireObjectCoercible$2;
|
|
142
|
-
|
|
143
|
-
var toIndexedObject$4 = function (it) {
|
|
144
|
-
return IndexedObject(requireObjectCoercible$1(it));
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
// https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
|
|
148
|
-
var documentAll = typeof document == 'object' && document.all;
|
|
149
|
-
|
|
150
|
-
// `IsCallable` abstract operation
|
|
151
|
-
// https://tc39.es/ecma262/#sec-iscallable
|
|
152
|
-
// eslint-disable-next-line unicorn/no-typeof-undefined -- required for testing
|
|
153
|
-
var isCallable$e = typeof documentAll == 'undefined' && documentAll !== undefined ? function (argument) {
|
|
154
|
-
return typeof argument == 'function' || argument === documentAll;
|
|
155
|
-
} : function (argument) {
|
|
156
|
-
return typeof argument == 'function';
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
var isCallable$d = isCallable$e;
|
|
160
|
-
|
|
161
|
-
var isObject$6 = function (it) {
|
|
162
|
-
return typeof it == 'object' ? it !== null : isCallable$d(it);
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
var global$a = global$b;
|
|
166
|
-
var isCallable$c = isCallable$e;
|
|
167
|
-
|
|
168
|
-
var aFunction = function (argument) {
|
|
169
|
-
return isCallable$c(argument) ? argument : undefined;
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
var getBuiltIn$3 = function (namespace, method) {
|
|
173
|
-
return arguments.length < 2 ? aFunction(global$a[namespace]) : global$a[namespace] && global$a[namespace][method];
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
var uncurryThis$8 = functionUncurryThis;
|
|
177
|
-
|
|
178
|
-
var objectIsPrototypeOf = uncurryThis$8({}.isPrototypeOf);
|
|
179
|
-
|
|
180
|
-
var engineUserAgent = typeof navigator != 'undefined' && String(navigator.userAgent) || '';
|
|
181
|
-
|
|
182
|
-
var global$9 = global$b;
|
|
183
|
-
var userAgent = engineUserAgent;
|
|
184
|
-
|
|
185
|
-
var process = global$9.process;
|
|
186
|
-
var Deno = global$9.Deno;
|
|
187
|
-
var versions = process && process.versions || Deno && Deno.version;
|
|
188
|
-
var v8 = versions && versions.v8;
|
|
189
|
-
var match, version;
|
|
190
|
-
|
|
191
|
-
if (v8) {
|
|
192
|
-
match = v8.split('.');
|
|
193
|
-
// in old Chrome, versions of V8 isn't V8 = Chrome / 10
|
|
194
|
-
// but their correct versions are not interesting for us
|
|
195
|
-
version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Creates a FetchPageFactory using the input ZohoFetchPageFetchFunction.
|
|
32
|
+
*
|
|
33
|
+
* @param fetch
|
|
34
|
+
* @param defaults
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
function zohoFetchPageFactory(fetch$1, defaults) {
|
|
38
|
+
return fetch.fetchPageFactory({
|
|
39
|
+
...defaults,
|
|
40
|
+
fetch: fetch$1,
|
|
41
|
+
readFetchPageResultInfo: function (result) {
|
|
42
|
+
return {
|
|
43
|
+
hasNext: result.info?.more_records ?? false // if no info is returned, assume something wrong and there are no more records
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
buildInputForNextPage: function (pageResult, input, options) {
|
|
47
|
+
return {
|
|
48
|
+
...input,
|
|
49
|
+
page: util.getNextPageNumber(pageResult),
|
|
50
|
+
per_page: options.maxItemsPerPage ?? input.per_page
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
});
|
|
196
54
|
}
|
|
197
55
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
56
|
+
const ZOHO_RECRUIT_SERVICE_NAME = 'recruit';
|
|
57
|
+
function zohoRecruitConfigApiUrl(input) {
|
|
58
|
+
switch (input) {
|
|
59
|
+
case 'sandbox':
|
|
60
|
+
return 'https://recruitsandbox.zoho.com/recruit';
|
|
61
|
+
case 'production':
|
|
62
|
+
return 'https://recruit.zoho.com/recruit';
|
|
63
|
+
default:
|
|
64
|
+
return input;
|
|
205
65
|
}
|
|
206
66
|
}
|
|
207
67
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
&& !Symbol.sham
|
|
234
|
-
&& typeof Symbol.iterator == 'symbol';
|
|
235
|
-
|
|
236
|
-
var getBuiltIn$2 = getBuiltIn$3;
|
|
237
|
-
var isCallable$b = isCallable$e;
|
|
238
|
-
var isPrototypeOf$2 = objectIsPrototypeOf;
|
|
239
|
-
var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
|
|
240
|
-
|
|
241
|
-
var $Object$3 = Object;
|
|
242
|
-
|
|
243
|
-
var isSymbol$2 = USE_SYMBOL_AS_UID$1 ? function (it) {
|
|
244
|
-
return typeof it == 'symbol';
|
|
245
|
-
} : function (it) {
|
|
246
|
-
var $Symbol = getBuiltIn$2('Symbol');
|
|
247
|
-
return isCallable$b($Symbol) && isPrototypeOf$2($Symbol.prototype, $Object$3(it));
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
var $String$2 = String;
|
|
68
|
+
/**
|
|
69
|
+
* Candidates module name
|
|
70
|
+
*/
|
|
71
|
+
const ZOHO_RECRUIT_CANDIDATES_MODULE = 'Candidates';
|
|
72
|
+
/**
|
|
73
|
+
* Job Openings module name
|
|
74
|
+
*/
|
|
75
|
+
const ZOHO_RECRUIT_JOB_OPENINGS_MODULE = 'Job_Openings';
|
|
76
|
+
/**
|
|
77
|
+
* Notes module name
|
|
78
|
+
*/
|
|
79
|
+
const ZOHO_RECRUIT_NOTES_MODULE = 'Notes';
|
|
80
|
+
/**
|
|
81
|
+
* Emails module name
|
|
82
|
+
*/
|
|
83
|
+
const ZOHO_RECRUIT_EMAILS_MODULE = 'Emails';
|
|
84
|
+
/**
|
|
85
|
+
* Attachments module name
|
|
86
|
+
*/
|
|
87
|
+
const ZOHO_RECRUIT_ATTACHMENTS_MODULE = 'Attachments';
|
|
88
|
+
/**
|
|
89
|
+
* Returns true if it is a valid ZohoRecruitValidUrl.
|
|
90
|
+
*/
|
|
91
|
+
const isZohoRecruitValidUrl = util.isStandardInternetAccessibleWebsiteUrl;
|
|
92
|
+
const ZOHO_RECRUIT_RECORD_ATTACHMENT_METADATA_ATTACH_TYPE_RESUME = 'Resume';
|
|
251
93
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Can search up to 10 criteria at a time.
|
|
96
|
+
*
|
|
97
|
+
* https://www.zoho.com/crm/developer/docs/api/v8/search-records.html
|
|
98
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/search-records.html
|
|
99
|
+
*
|
|
100
|
+
* "You can search for a maximum of 10 criteria (with the same or different column) with equals and starts_with conditions."
|
|
101
|
+
*/
|
|
102
|
+
const MAX_ZOHO_SEARCH_MODULE_RECORDS_CRITERIA = 10;
|
|
103
|
+
/**
|
|
104
|
+
* Creates a ZohoSearchRecordsCriteriaString from a ZohoSearchRecordsCriteriaTree.
|
|
105
|
+
*
|
|
106
|
+
* If the input tree is empty, returns undefined.
|
|
107
|
+
*/
|
|
108
|
+
function zohoSearchRecordsCriteriaString(input) {
|
|
109
|
+
let result;
|
|
110
|
+
if (input != null) {
|
|
111
|
+
switch (typeof input) {
|
|
112
|
+
case 'string':
|
|
113
|
+
result = input;
|
|
114
|
+
break;
|
|
115
|
+
case 'object':
|
|
116
|
+
let tree;
|
|
117
|
+
if (Array.isArray(input)) {
|
|
118
|
+
tree = {
|
|
119
|
+
and: [input]
|
|
120
|
+
};
|
|
121
|
+
} else {
|
|
122
|
+
tree = input;
|
|
123
|
+
}
|
|
124
|
+
result = zohoSearchRecordsCriteriaStringForTree(tree);
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
257
127
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
var isPure = false;
|
|
300
|
-
|
|
301
|
-
var global$7 = global$b;
|
|
302
|
-
|
|
303
|
-
// eslint-disable-next-line es/no-object-defineproperty -- safe
|
|
304
|
-
var defineProperty$2 = Object.defineProperty;
|
|
305
|
-
|
|
306
|
-
var defineGlobalProperty$3 = function (key, value) {
|
|
307
|
-
try {
|
|
308
|
-
defineProperty$2(global$7, key, { value: value, configurable: true, writable: true });
|
|
309
|
-
} catch (error) {
|
|
310
|
-
global$7[key] = value;
|
|
311
|
-
} return value;
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
var globalThis$1 = global$b;
|
|
315
|
-
var defineGlobalProperty$2 = defineGlobalProperty$3;
|
|
316
|
-
|
|
317
|
-
var SHARED = '__core-js_shared__';
|
|
318
|
-
var store$3 = sharedStore.exports = globalThis$1[SHARED] || defineGlobalProperty$2(SHARED, {});
|
|
319
|
-
|
|
320
|
-
(store$3.versions || (store$3.versions = [])).push({
|
|
321
|
-
version: '3.36.1',
|
|
322
|
-
mode: 'global',
|
|
323
|
-
copyright: '© 2014-2024 Denis Pushkarev (zloirock.ru)',
|
|
324
|
-
license: 'https://github.com/zloirock/core-js/blob/v3.36.1/LICENSE',
|
|
325
|
-
source: 'https://github.com/zloirock/core-js'
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
function zohoSearchRecordsCriteriaStringForTree(tree) {
|
|
131
|
+
function convertToString(value) {
|
|
132
|
+
let result;
|
|
133
|
+
if (typeof value === 'object') {
|
|
134
|
+
// array of criteria entries
|
|
135
|
+
if (Array.isArray(value)) {
|
|
136
|
+
result = value.map(zohoSearchRecordsCriteriaEntryToCriteriaString);
|
|
137
|
+
} else if (value) {
|
|
138
|
+
// criteria tree that first needs to be converted to a string
|
|
139
|
+
result = zohoSearchRecordsCriteriaStringForTree(value);
|
|
140
|
+
}
|
|
141
|
+
} else {
|
|
142
|
+
result = value;
|
|
143
|
+
}
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
function mergeStringValues(values, type) {
|
|
147
|
+
return values.length > 1 ? `(${values.join(type)})` : values[0]; // wrap in and values
|
|
148
|
+
}
|
|
149
|
+
function mergeValues(values, type) {
|
|
150
|
+
const allStrings = util.filterMaybeArrayValues(values.map(convertToString)).flatMap(util.asArray);
|
|
151
|
+
return mergeStringValues(allStrings, type);
|
|
152
|
+
}
|
|
153
|
+
const orValues = tree.or ? mergeValues(tree.or, 'or') : undefined;
|
|
154
|
+
let result = orValues;
|
|
155
|
+
if (tree.and) {
|
|
156
|
+
result = mergeValues([mergeValues(tree.and, 'and'), orValues], 'and');
|
|
157
|
+
}
|
|
158
|
+
return result;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Escape used for ZohoSearchRecordsCriteriaString
|
|
162
|
+
*/
|
|
163
|
+
const escapeZohoFieldValueForCriteriaString = util.escapeStringCharactersFunction({
|
|
164
|
+
/**
|
|
165
|
+
* Parenthesis and commas must be escaped using a backslash
|
|
166
|
+
*/
|
|
167
|
+
escapeTargets: ['(', ')', ','],
|
|
168
|
+
escapeCharacter: char => `\\\\${char}`
|
|
326
169
|
});
|
|
170
|
+
/**
|
|
171
|
+
* Converts the input entry to a ZohoSearchRecordsCriteriaString. Properly escapes any parenthesis or commas.
|
|
172
|
+
*
|
|
173
|
+
* @param entry
|
|
174
|
+
* @returns
|
|
175
|
+
*/
|
|
176
|
+
function zohoSearchRecordsCriteriaEntryToCriteriaString(entry) {
|
|
177
|
+
const escapedValue = escapeZohoFieldValueForCriteriaString(entry.value);
|
|
178
|
+
return `(${entry.field}:${entry.filter}:${escapedValue})`;
|
|
179
|
+
}
|
|
327
180
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
// `ToObject` abstract operation
|
|
341
|
-
// https://tc39.es/ecma262/#sec-toobject
|
|
342
|
-
var toObject$3 = function (argument) {
|
|
343
|
-
return $Object$2(requireObjectCoercible(argument));
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
var uncurryThis$7 = functionUncurryThis;
|
|
347
|
-
var toObject$2 = toObject$3;
|
|
348
|
-
|
|
349
|
-
var hasOwnProperty = uncurryThis$7({}.hasOwnProperty);
|
|
350
|
-
|
|
351
|
-
// `HasOwnProperty` abstract operation
|
|
352
|
-
// https://tc39.es/ecma262/#sec-hasownproperty
|
|
353
|
-
// eslint-disable-next-line es/no-object-hasown -- safe
|
|
354
|
-
var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
|
|
355
|
-
return hasOwnProperty(toObject$2(it), key);
|
|
356
|
-
};
|
|
357
|
-
|
|
358
|
-
var uncurryThis$6 = functionUncurryThis;
|
|
359
|
-
|
|
360
|
-
var id = 0;
|
|
361
|
-
var postfix = Math.random();
|
|
362
|
-
var toString = uncurryThis$6(1.0.toString);
|
|
181
|
+
/**
|
|
182
|
+
* Can search up to 10 criteria at a time.
|
|
183
|
+
*
|
|
184
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/search-records.html
|
|
185
|
+
*
|
|
186
|
+
* "You can search for a maximum of 10 criteria (with the same or different column) with equals and starts_with conditions."
|
|
187
|
+
*/
|
|
188
|
+
const MAX_ZOHO_RECRUIT_SEARCH_MODULE_RECORDS_CRITERIA = MAX_ZOHO_SEARCH_MODULE_RECORDS_CRITERIA;
|
|
189
|
+
const zohoRecruitSearchRecordsCriteriaString = zohoSearchRecordsCriteriaString;
|
|
190
|
+
const zohoRecruitSearchRecordsCriteriaStringForTree = zohoSearchRecordsCriteriaStringForTree;
|
|
191
|
+
const zohoRecruitSearchRecordsCriteriaEntryToCriteriaString = zohoSearchRecordsCriteriaEntryToCriteriaString;
|
|
363
192
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
var toPrimitive$1 = function (input, pref) {
|
|
400
|
-
if (!isObject$4(input) || isSymbol$1(input)) return input;
|
|
401
|
-
var exoticToPrim = getMethod$3(input, TO_PRIMITIVE);
|
|
402
|
-
var result;
|
|
403
|
-
if (exoticToPrim) {
|
|
404
|
-
if (pref === undefined) pref = 'default';
|
|
405
|
-
result = call$9(exoticToPrim, input, pref);
|
|
406
|
-
if (!isObject$4(result) || isSymbol$1(result)) return result;
|
|
407
|
-
throw new $TypeError$8("Can't convert object to primitive value");
|
|
193
|
+
/**
|
|
194
|
+
* Default place-holder used by the ZohoServerFetchResponseDataArrayError class.
|
|
195
|
+
*/
|
|
196
|
+
const ZOHO_DATA_ARRAY_BLANK_ERROR_CODE = '__internal_data_array_blank_error';
|
|
197
|
+
/**
|
|
198
|
+
* Returns true if the input value is a ZohoServerErrorResponseDataArrayRef.
|
|
199
|
+
*
|
|
200
|
+
* @param value
|
|
201
|
+
* @returns
|
|
202
|
+
*/
|
|
203
|
+
function isZohoServerErrorResponseDataArrayRef(value) {
|
|
204
|
+
return Array.isArray(value?.data);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* A code used in some cases to denote success.
|
|
208
|
+
*/
|
|
209
|
+
const ZOHO_SUCCESS_CODE = 'SUCCESS';
|
|
210
|
+
/**
|
|
211
|
+
* Lowercase status code
|
|
212
|
+
*/
|
|
213
|
+
const ZOHO_SUCCESS_STATUS = 'success';
|
|
214
|
+
/**
|
|
215
|
+
* Set in the status field
|
|
216
|
+
*/
|
|
217
|
+
const ZOHO_ERROR_STATUS = 'error';
|
|
218
|
+
function zohoServerErrorData(error) {
|
|
219
|
+
const errorType = typeof error;
|
|
220
|
+
let errorData;
|
|
221
|
+
if (errorType === 'object') {
|
|
222
|
+
errorData = error;
|
|
223
|
+
} else {
|
|
224
|
+
errorData = {
|
|
225
|
+
code: error,
|
|
226
|
+
message: ''
|
|
227
|
+
};
|
|
408
228
|
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
value: 42,
|
|
480
|
-
writable: false
|
|
481
|
-
}).prototype !== 42;
|
|
482
|
-
});
|
|
483
|
-
|
|
484
|
-
var isObject$2 = isObject$6;
|
|
485
|
-
|
|
486
|
-
var $String$1 = String;
|
|
487
|
-
var $TypeError$7 = TypeError;
|
|
488
|
-
|
|
489
|
-
// `Assert: Type(argument) is Object`
|
|
490
|
-
var anObject$e = function (argument) {
|
|
491
|
-
if (isObject$2(argument)) return argument;
|
|
492
|
-
throw new $TypeError$7($String$1(argument) + ' is not an object');
|
|
493
|
-
};
|
|
494
|
-
|
|
495
|
-
var DESCRIPTORS$7 = descriptors;
|
|
496
|
-
var IE8_DOM_DEFINE = ie8DomDefine;
|
|
497
|
-
var V8_PROTOTYPE_DEFINE_BUG$1 = v8PrototypeDefineBug;
|
|
498
|
-
var anObject$d = anObject$e;
|
|
499
|
-
var toPropertyKey = toPropertyKey$2;
|
|
500
|
-
|
|
501
|
-
var $TypeError$6 = TypeError;
|
|
502
|
-
// eslint-disable-next-line es/no-object-defineproperty -- safe
|
|
503
|
-
var $defineProperty = Object.defineProperty;
|
|
504
|
-
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
505
|
-
var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
506
|
-
var ENUMERABLE = 'enumerable';
|
|
507
|
-
var CONFIGURABLE$1 = 'configurable';
|
|
508
|
-
var WRITABLE = 'writable';
|
|
509
|
-
|
|
510
|
-
// `Object.defineProperty` method
|
|
511
|
-
// https://tc39.es/ecma262/#sec-object.defineproperty
|
|
512
|
-
objectDefineProperty.f = DESCRIPTORS$7 ? V8_PROTOTYPE_DEFINE_BUG$1 ? function defineProperty(O, P, Attributes) {
|
|
513
|
-
anObject$d(O);
|
|
514
|
-
P = toPropertyKey(P);
|
|
515
|
-
anObject$d(Attributes);
|
|
516
|
-
if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
|
|
517
|
-
var current = $getOwnPropertyDescriptor(O, P);
|
|
518
|
-
if (current && current[WRITABLE]) {
|
|
519
|
-
O[P] = Attributes.value;
|
|
520
|
-
Attributes = {
|
|
521
|
-
configurable: CONFIGURABLE$1 in Attributes ? Attributes[CONFIGURABLE$1] : current[CONFIGURABLE$1],
|
|
522
|
-
enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
|
|
523
|
-
writable: false
|
|
524
|
-
};
|
|
229
|
+
return errorData;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Zoho Server Error
|
|
233
|
+
*/
|
|
234
|
+
class ZohoServerError extends makeError.BaseError {
|
|
235
|
+
get code() {
|
|
236
|
+
return this.error.code;
|
|
237
|
+
}
|
|
238
|
+
constructor(error) {
|
|
239
|
+
super(error.message);
|
|
240
|
+
this.error = void 0;
|
|
241
|
+
this.error = error;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Zoho Server Error that includes the FetchResponseError
|
|
246
|
+
*/
|
|
247
|
+
class ZohoServerFetchResponseError extends ZohoServerError {
|
|
248
|
+
constructor(data, errorResponseData, responseError) {
|
|
249
|
+
super(data);
|
|
250
|
+
this.data = void 0;
|
|
251
|
+
this.errorResponseData = void 0;
|
|
252
|
+
this.responseError = void 0;
|
|
253
|
+
this.data = data;
|
|
254
|
+
this.errorResponseData = errorResponseData;
|
|
255
|
+
this.responseError = responseError;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Used as a transient error for situations where there are potentially multiple errors within the data array returned.
|
|
260
|
+
*
|
|
261
|
+
* Zoho CRM returns a non-200 error as a result, but generally there is a partial success that can occur, with both
|
|
262
|
+
* the successful and errored results returned within the data.
|
|
263
|
+
*/
|
|
264
|
+
class ZohoServerFetchResponseDataArrayError extends ZohoServerFetchResponseError {
|
|
265
|
+
constructor(errorResponseData, responseError) {
|
|
266
|
+
super({
|
|
267
|
+
code: ZOHO_DATA_ARRAY_BLANK_ERROR_CODE,
|
|
268
|
+
message: 'Check data for individual errors.'
|
|
269
|
+
}, errorResponseData, responseError);
|
|
270
|
+
}
|
|
271
|
+
get errorDataArray() {
|
|
272
|
+
return this.errorResponseData.data;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Creates a logZohoServerErrorFunction that logs the error to console.
|
|
277
|
+
*
|
|
278
|
+
* @param zohoApiNamePrefix Prefix to use when logging. I.E. ZohoRecruitError, etc.
|
|
279
|
+
* @returns
|
|
280
|
+
*/
|
|
281
|
+
function logZohoServerErrorFunction(zohoApiNamePrefix, options) {
|
|
282
|
+
const {
|
|
283
|
+
logDataArrayErrors = false
|
|
284
|
+
} = options ?? {};
|
|
285
|
+
return error => {
|
|
286
|
+
if (error instanceof ZohoServerFetchResponseDataArrayError && !logDataArrayErrors) ; else if (error instanceof ZohoServerFetchResponseError) {
|
|
287
|
+
console.log(`${zohoApiNamePrefix}Error(${error.responseError.response.status}): `, {
|
|
288
|
+
error,
|
|
289
|
+
errorData: error.data
|
|
290
|
+
});
|
|
291
|
+
} else if (error instanceof ZohoServerError) {
|
|
292
|
+
console.log(`${zohoApiNamePrefix}Error(code:${error.code}): `, {
|
|
293
|
+
error
|
|
294
|
+
});
|
|
295
|
+
} else {
|
|
296
|
+
console.log(`${zohoApiNamePrefix}Error(name:${error.name}): `, {
|
|
297
|
+
error
|
|
298
|
+
});
|
|
525
299
|
}
|
|
526
|
-
} return $defineProperty(O, P, Attributes);
|
|
527
|
-
} : $defineProperty : function defineProperty(O, P, Attributes) {
|
|
528
|
-
anObject$d(O);
|
|
529
|
-
P = toPropertyKey(P);
|
|
530
|
-
anObject$d(Attributes);
|
|
531
|
-
if (IE8_DOM_DEFINE) try {
|
|
532
|
-
return $defineProperty(O, P, Attributes);
|
|
533
|
-
} catch (error) { /* empty */ }
|
|
534
|
-
if ('get' in Attributes || 'set' in Attributes) throw new $TypeError$6('Accessors not supported');
|
|
535
|
-
if ('value' in Attributes) O[P] = Attributes.value;
|
|
536
|
-
return O;
|
|
537
|
-
};
|
|
538
|
-
|
|
539
|
-
var DESCRIPTORS$6 = descriptors;
|
|
540
|
-
var definePropertyModule$4 = objectDefineProperty;
|
|
541
|
-
var createPropertyDescriptor$1 = createPropertyDescriptor$3;
|
|
542
|
-
|
|
543
|
-
var createNonEnumerableProperty$3 = DESCRIPTORS$6 ? function (object, key, value) {
|
|
544
|
-
return definePropertyModule$4.f(object, key, createPropertyDescriptor$1(1, value));
|
|
545
|
-
} : function (object, key, value) {
|
|
546
|
-
object[key] = value;
|
|
547
|
-
return object;
|
|
548
|
-
};
|
|
549
|
-
|
|
550
|
-
var makeBuiltIn$3 = {exports: {}};
|
|
551
|
-
|
|
552
|
-
var DESCRIPTORS$5 = descriptors;
|
|
553
|
-
var hasOwn$6 = hasOwnProperty_1;
|
|
554
|
-
|
|
555
|
-
var FunctionPrototype = Function.prototype;
|
|
556
|
-
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
557
|
-
var getDescriptor = DESCRIPTORS$5 && Object.getOwnPropertyDescriptor;
|
|
558
|
-
|
|
559
|
-
var EXISTS = hasOwn$6(FunctionPrototype, 'name');
|
|
560
|
-
// additional protection from minified / mangled / dropped function names
|
|
561
|
-
var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
|
|
562
|
-
var CONFIGURABLE = EXISTS && (!DESCRIPTORS$5 || (DESCRIPTORS$5 && getDescriptor(FunctionPrototype, 'name').configurable));
|
|
563
|
-
|
|
564
|
-
var functionName = {
|
|
565
|
-
EXISTS: EXISTS,
|
|
566
|
-
PROPER: PROPER,
|
|
567
|
-
CONFIGURABLE: CONFIGURABLE
|
|
568
|
-
};
|
|
569
|
-
|
|
570
|
-
var uncurryThis$5 = functionUncurryThis;
|
|
571
|
-
var isCallable$8 = isCallable$e;
|
|
572
|
-
var store$1 = sharedStoreExports;
|
|
573
|
-
|
|
574
|
-
var functionToString = uncurryThis$5(Function.toString);
|
|
575
|
-
|
|
576
|
-
// this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
|
|
577
|
-
if (!isCallable$8(store$1.inspectSource)) {
|
|
578
|
-
store$1.inspectSource = function (it) {
|
|
579
|
-
return functionToString(it);
|
|
580
300
|
};
|
|
581
301
|
}
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
var isObject$1 = isObject$6;
|
|
606
|
-
var createNonEnumerableProperty$2 = createNonEnumerableProperty$3;
|
|
607
|
-
var hasOwn$5 = hasOwnProperty_1;
|
|
608
|
-
var shared = sharedStoreExports;
|
|
609
|
-
var sharedKey$2 = sharedKey$3;
|
|
610
|
-
var hiddenKeys$3 = hiddenKeys$4;
|
|
611
|
-
|
|
612
|
-
var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
|
|
613
|
-
var TypeError$1 = global$3.TypeError;
|
|
614
|
-
var WeakMap = global$3.WeakMap;
|
|
615
|
-
var set, get, has;
|
|
616
|
-
|
|
617
|
-
var enforce = function (it) {
|
|
618
|
-
return has(it) ? get(it) : set(it, {});
|
|
619
|
-
};
|
|
620
|
-
|
|
621
|
-
var getterFor = function (TYPE) {
|
|
622
|
-
return function (it) {
|
|
623
|
-
var state;
|
|
624
|
-
if (!isObject$1(it) || (state = get(it)).type !== TYPE) {
|
|
625
|
-
throw new TypeError$1('Incompatible receiver, ' + TYPE + ' required');
|
|
626
|
-
} return state;
|
|
627
|
-
};
|
|
628
|
-
};
|
|
629
|
-
|
|
630
|
-
if (NATIVE_WEAK_MAP || shared.state) {
|
|
631
|
-
var store = shared.state || (shared.state = new WeakMap());
|
|
632
|
-
/* eslint-disable no-self-assign -- prototype methods protection */
|
|
633
|
-
store.get = store.get;
|
|
634
|
-
store.has = store.has;
|
|
635
|
-
store.set = store.set;
|
|
636
|
-
/* eslint-enable no-self-assign -- prototype methods protection */
|
|
637
|
-
set = function (it, metadata) {
|
|
638
|
-
if (store.has(it)) throw new TypeError$1(OBJECT_ALREADY_INITIALIZED);
|
|
639
|
-
metadata.facade = it;
|
|
640
|
-
store.set(it, metadata);
|
|
641
|
-
return metadata;
|
|
642
|
-
};
|
|
643
|
-
get = function (it) {
|
|
644
|
-
return store.get(it) || {};
|
|
645
|
-
};
|
|
646
|
-
has = function (it) {
|
|
647
|
-
return store.has(it);
|
|
648
|
-
};
|
|
649
|
-
} else {
|
|
650
|
-
var STATE = sharedKey$2('state');
|
|
651
|
-
hiddenKeys$3[STATE] = true;
|
|
652
|
-
set = function (it, metadata) {
|
|
653
|
-
if (hasOwn$5(it, STATE)) throw new TypeError$1(OBJECT_ALREADY_INITIALIZED);
|
|
654
|
-
metadata.facade = it;
|
|
655
|
-
createNonEnumerableProperty$2(it, STATE, metadata);
|
|
656
|
-
return metadata;
|
|
657
|
-
};
|
|
658
|
-
get = function (it) {
|
|
659
|
-
return hasOwn$5(it, STATE) ? it[STATE] : {};
|
|
302
|
+
/**
|
|
303
|
+
* Wraps a ConfiguredFetch to support handling errors returned by fetch.
|
|
304
|
+
*
|
|
305
|
+
* @param fetch
|
|
306
|
+
* @returns
|
|
307
|
+
*/
|
|
308
|
+
function handleZohoErrorFetchFactory(parseZohoError, defaultLogError) {
|
|
309
|
+
return (fetch$1, logError = defaultLogError, onError) => {
|
|
310
|
+
return async (x, y) => {
|
|
311
|
+
try {
|
|
312
|
+
return await fetch$1(x, y); // await to catch thrown errors
|
|
313
|
+
} catch (e) {
|
|
314
|
+
if (e instanceof fetch.FetchResponseError) {
|
|
315
|
+
const error = await parseZohoError(e);
|
|
316
|
+
if (error) {
|
|
317
|
+
logError(error); // log before throwing.
|
|
318
|
+
onError?.(error); // perform a task
|
|
319
|
+
throw error;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
throw e;
|
|
323
|
+
}
|
|
324
|
+
};
|
|
660
325
|
};
|
|
661
|
-
|
|
662
|
-
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* FetchJsonInterceptJsonResponseFunction that intercepts a 200 response that actually contains a ZohoServerError and throws a ZohoServerError for the error handling to catch.
|
|
329
|
+
*/
|
|
330
|
+
function interceptZohoErrorResponseFactory(parseZohoServerErrorResponseData) {
|
|
331
|
+
return (json, response) => {
|
|
332
|
+
const error = json?.error;
|
|
333
|
+
if (error != null) {
|
|
334
|
+
const responseError = new fetch.FetchResponseError(response);
|
|
335
|
+
if (responseError) {
|
|
336
|
+
const parsedError = parseZohoServerErrorResponseData(json, responseError);
|
|
337
|
+
if (parsedError) {
|
|
338
|
+
throw parsedError;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return json;
|
|
663
343
|
};
|
|
664
344
|
}
|
|
345
|
+
// MARK: Parsed Errors
|
|
346
|
+
/**
|
|
347
|
+
* Error in the following (but not limited to) cases:
|
|
348
|
+
* - An extra parameter is provided
|
|
349
|
+
*/
|
|
350
|
+
const ZOHO_INTERNAL_ERROR_CODE = 'INTERNAL_ERROR';
|
|
351
|
+
/**
|
|
352
|
+
* Error code for when an invalid oauth token is provided.
|
|
353
|
+
*/
|
|
354
|
+
const ZOHO_INVALID_TOKEN_ERROR_CODE = 'INVALID_TOKEN';
|
|
355
|
+
class ZohoInvalidTokenError extends ZohoServerFetchResponseError {}
|
|
356
|
+
/**
|
|
357
|
+
* Error code for when a failure occured for the given action
|
|
358
|
+
*/
|
|
359
|
+
const ZOHO_FAILURE_ERROR_CODE = 'FAILURE';
|
|
360
|
+
/**
|
|
361
|
+
* Error when the Zoho API returns an internal error
|
|
362
|
+
*/
|
|
363
|
+
class ZohoInternalError extends ZohoServerFetchResponseError {}
|
|
364
|
+
/**
|
|
365
|
+
* Error in the following cases:
|
|
366
|
+
* - Authorization is not properly constructed ("Invalid Ticket Id")
|
|
367
|
+
* - OAuth token is expired ("Invalid OAuthtoken")
|
|
368
|
+
*/
|
|
369
|
+
const ZOHO_INVALID_AUTHORIZATION_ERROR_CODE = '4834';
|
|
370
|
+
/**
|
|
371
|
+
* Error when the Zoho API returns an invalid authorization error code.
|
|
372
|
+
*/
|
|
373
|
+
class ZohoInvalidAuthorizationError extends ZohoServerFetchResponseError {}
|
|
374
|
+
/**
|
|
375
|
+
* Error in the following cases:
|
|
376
|
+
* - Search query is invalid
|
|
377
|
+
*/
|
|
378
|
+
const ZOHO_INVALID_QUERY_ERROR_CODE = 'INVALID_QUERY';
|
|
379
|
+
class ZohoInvalidQueryError extends ZohoServerFetchResponseError {
|
|
380
|
+
get details() {
|
|
381
|
+
return this.error.details;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Error when a mandatory field is missing.
|
|
386
|
+
*/
|
|
387
|
+
const ZOHO_MANDATORY_NOT_FOUND_ERROR_CODE = 'MANDATORY_NOT_FOUND';
|
|
388
|
+
/**
|
|
389
|
+
* Error when a duplicate record is found with a matching unique field value.
|
|
390
|
+
*/
|
|
391
|
+
const ZOHO_DUPLICATE_DATA_ERROR_CODE = 'DUPLICATE_DATA';
|
|
392
|
+
/**
|
|
393
|
+
* Error when some passed data is invalid.
|
|
394
|
+
*/
|
|
395
|
+
const ZOHO_INVALID_DATA_ERROR_CODE = 'INVALID_DATA';
|
|
396
|
+
/**
|
|
397
|
+
* Error when too many requests are made in a short period of time.
|
|
398
|
+
*/
|
|
399
|
+
const ZOHO_TOO_MANY_REQUESTS_ERROR_CODE = 'TOO_MANY_REQUESTS';
|
|
400
|
+
/**
|
|
401
|
+
* The status code that Zoho uses to indicates that too many requests have been made in a short period of time.
|
|
402
|
+
*/
|
|
403
|
+
const ZOHO_TOO_MANY_REQUESTS_HTTP_STATUS_CODE = 429;
|
|
404
|
+
const ZOHO_RATE_LIMIT_LIMIT_HEADER = 'X-RATELIMIT-LIMIT';
|
|
405
|
+
const ZOHO_RATE_LIMIT_REMAINING_HEADER = 'X-RATELIMIT-REMAINING';
|
|
406
|
+
const ZOHO_RATE_LIMIT_RESET_HEADER = 'X-RATELIMIT-RESET';
|
|
407
|
+
const DEFAULT_ZOHO_API_RATE_LIMIT = 100;
|
|
408
|
+
const DEFAULT_ZOHO_API_RATE_LIMIT_RESET_PERIOD = util.MS_IN_MINUTE;
|
|
409
|
+
function zohoRateLimitHeaderDetails(headers) {
|
|
410
|
+
const limitHeader = headers.get(ZOHO_RATE_LIMIT_LIMIT_HEADER);
|
|
411
|
+
const remainingHeader = headers.get(ZOHO_RATE_LIMIT_REMAINING_HEADER);
|
|
412
|
+
const resetHeader = headers.get(ZOHO_RATE_LIMIT_RESET_HEADER);
|
|
413
|
+
let result = null;
|
|
414
|
+
if (limitHeader != null && remainingHeader != null && resetHeader != null) {
|
|
415
|
+
const limit = Number(limitHeader);
|
|
416
|
+
const remaining = Number(remainingHeader);
|
|
417
|
+
const reset = Number(resetHeader);
|
|
418
|
+
const resetAt = new Date(reset);
|
|
419
|
+
result = {
|
|
420
|
+
limit,
|
|
421
|
+
remaining,
|
|
422
|
+
reset,
|
|
423
|
+
resetAt
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
return result;
|
|
427
|
+
}
|
|
428
|
+
class ZohoTooManyRequestsError extends ZohoServerFetchResponseError {
|
|
429
|
+
get headerDetails() {
|
|
430
|
+
return zohoRateLimitHeaderDetails(this.responseError.response.headers);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Function that parses/transforms a ZohoServerErrorResponseData into a general ZohoServerError or other known error type.
|
|
435
|
+
*
|
|
436
|
+
* @param errorResponseData
|
|
437
|
+
* @param responseError
|
|
438
|
+
* @returns
|
|
439
|
+
*/
|
|
440
|
+
function parseZohoServerErrorResponseData(errorResponseData, responseError) {
|
|
441
|
+
let result;
|
|
442
|
+
if (isZohoServerErrorResponseDataArrayRef(errorResponseData)) {
|
|
443
|
+
result = new ZohoServerFetchResponseDataArrayError(errorResponseData, responseError);
|
|
444
|
+
} else {
|
|
445
|
+
const error = tryFindZohoServerErrorData(errorResponseData, responseError);
|
|
446
|
+
if (error) {
|
|
447
|
+
const errorData = zohoServerErrorData(error);
|
|
448
|
+
switch (errorData.code) {
|
|
449
|
+
case ZOHO_INTERNAL_ERROR_CODE:
|
|
450
|
+
result = new ZohoInternalError(errorData, errorResponseData, responseError);
|
|
451
|
+
break;
|
|
452
|
+
case ZOHO_INVALID_TOKEN_ERROR_CODE:
|
|
453
|
+
result = new ZohoInvalidTokenError(errorData, errorResponseData, responseError);
|
|
454
|
+
break;
|
|
455
|
+
case ZOHO_INVALID_AUTHORIZATION_ERROR_CODE:
|
|
456
|
+
result = new ZohoInvalidAuthorizationError(errorData, errorResponseData, responseError);
|
|
457
|
+
break;
|
|
458
|
+
case ZOHO_INVALID_QUERY_ERROR_CODE:
|
|
459
|
+
result = new ZohoInvalidQueryError(errorData, errorResponseData, responseError);
|
|
460
|
+
break;
|
|
461
|
+
case ZOHO_TOO_MANY_REQUESTS_ERROR_CODE:
|
|
462
|
+
result = new ZohoTooManyRequestsError(errorData, errorResponseData, responseError);
|
|
463
|
+
break;
|
|
464
|
+
default:
|
|
465
|
+
result = new ZohoServerFetchResponseError(errorData, errorResponseData, responseError);
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return result;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Attempts to retrieve an ZohoServerErrorResponseDataError from the input.
|
|
474
|
+
*
|
|
475
|
+
* Non-200 errors returned by the Zoho API are returned as the object directly instead of as an ZohoServerErrorResponseData directly.
|
|
476
|
+
* Zoho CRM returns a ZohoServerErrorResponseDataArrayRef value for errors.
|
|
477
|
+
*
|
|
478
|
+
* @param errorResponseData
|
|
479
|
+
* @param responseError
|
|
480
|
+
* @returns
|
|
481
|
+
*/
|
|
482
|
+
function tryFindZohoServerErrorData(errorResponseData, responseError) {
|
|
483
|
+
const error = errorResponseData.error ?? errorResponseData.data?.[0] ?? (!responseError.response.ok ? errorResponseData : undefined);
|
|
484
|
+
return error;
|
|
485
|
+
}
|
|
665
486
|
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
var enforceInternalState = InternalStateModule$1.enforce;
|
|
684
|
-
var getInternalState = InternalStateModule$1.get;
|
|
685
|
-
var $String = String;
|
|
686
|
-
// eslint-disable-next-line es/no-object-defineproperty -- safe
|
|
687
|
-
var defineProperty$1 = Object.defineProperty;
|
|
688
|
-
var stringSlice = uncurryThis$4(''.slice);
|
|
689
|
-
var replace = uncurryThis$4(''.replace);
|
|
690
|
-
var join = uncurryThis$4([].join);
|
|
691
|
-
|
|
692
|
-
var CONFIGURABLE_LENGTH = DESCRIPTORS$4 && !fails$5(function () {
|
|
693
|
-
return defineProperty$1(function () { /* empty */ }, 'length', { value: 8 }).length !== 8;
|
|
694
|
-
});
|
|
695
|
-
|
|
696
|
-
var TEMPLATE = String(String).split('String');
|
|
697
|
-
|
|
698
|
-
var makeBuiltIn$2 = makeBuiltIn$3.exports = function (value, name, options) {
|
|
699
|
-
if (stringSlice($String(name), 0, 7) === 'Symbol(') {
|
|
700
|
-
name = '[' + replace($String(name), /^Symbol\(([^)]*)\).*$/, '$1') + ']';
|
|
487
|
+
/**
|
|
488
|
+
* Error code for when two records are already associated with each other.
|
|
489
|
+
*
|
|
490
|
+
* Example being a candidate and a job opening are already associated.
|
|
491
|
+
*/
|
|
492
|
+
const ZOHO_RECRUIT_ALREADY_ASSOCIATED_ERROR_CODE = 'ALREADY_ASSOCIATED';
|
|
493
|
+
/**
|
|
494
|
+
* Thrown when a record with the given id has no content. Typically also means it does not exist.
|
|
495
|
+
*/
|
|
496
|
+
class ZohoRecruitRecordNoContentError extends makeError.BaseError {
|
|
497
|
+
constructor(moduleName, recordId) {
|
|
498
|
+
super(`There was no content or matching records for the content. It may not exist.`);
|
|
499
|
+
this.moduleName = void 0;
|
|
500
|
+
this.recordId = void 0;
|
|
501
|
+
this.moduleName = moduleName;
|
|
502
|
+
this.recordId = recordId;
|
|
701
503
|
}
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
504
|
+
}
|
|
505
|
+
class ZohoRecruitRecordCrudError extends ZohoServerError {}
|
|
506
|
+
class ZohoRecruitRecordCrudMandatoryFieldNotFoundError extends ZohoRecruitRecordCrudError {}
|
|
507
|
+
class ZohoRecruitRecordCrudDuplicateDataError extends ZohoRecruitRecordCrudError {}
|
|
508
|
+
class ZohoRecruitRecordCrudInvalidDataError extends ZohoRecruitRecordCrudError {
|
|
509
|
+
get invalidFieldDetails() {
|
|
510
|
+
return this.error.details;
|
|
707
511
|
}
|
|
708
|
-
|
|
709
|
-
|
|
512
|
+
}
|
|
513
|
+
class ZohoRecruitRecordCrudNoMatchingRecordError extends ZohoRecruitRecordCrudInvalidDataError {}
|
|
514
|
+
function zohoRecruitRecordCrudError(error) {
|
|
515
|
+
let result;
|
|
516
|
+
switch (error.code) {
|
|
517
|
+
case ZOHO_INVALID_DATA_ERROR_CODE:
|
|
518
|
+
const invalidDataError = new ZohoRecruitRecordCrudInvalidDataError(error);
|
|
519
|
+
if (invalidDataError.invalidFieldDetails['id']) {
|
|
520
|
+
result = new ZohoRecruitRecordCrudNoMatchingRecordError(error);
|
|
521
|
+
} else {
|
|
522
|
+
result = invalidDataError;
|
|
523
|
+
}
|
|
524
|
+
break;
|
|
525
|
+
case ZOHO_MANDATORY_NOT_FOUND_ERROR_CODE:
|
|
526
|
+
result = new ZohoRecruitRecordCrudMandatoryFieldNotFoundError(error);
|
|
527
|
+
break;
|
|
528
|
+
case ZOHO_DUPLICATE_DATA_ERROR_CODE:
|
|
529
|
+
result = new ZohoRecruitRecordCrudDuplicateDataError(error);
|
|
530
|
+
break;
|
|
531
|
+
default:
|
|
532
|
+
result = new ZohoRecruitRecordCrudError(error);
|
|
533
|
+
break;
|
|
710
534
|
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
} return value;
|
|
721
|
-
};
|
|
722
|
-
|
|
723
|
-
// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
|
|
724
|
-
// eslint-disable-next-line no-extend-native -- required
|
|
725
|
-
Function.prototype.toString = makeBuiltIn$2(function toString() {
|
|
726
|
-
return isCallable$6(this) && getInternalState(this).source || inspectSource(this);
|
|
727
|
-
}, 'toString');
|
|
728
|
-
|
|
729
|
-
var makeBuiltInExports = makeBuiltIn$3.exports;
|
|
730
|
-
|
|
731
|
-
var isCallable$5 = isCallable$e;
|
|
732
|
-
var definePropertyModule$3 = objectDefineProperty;
|
|
733
|
-
var makeBuiltIn$1 = makeBuiltInExports;
|
|
734
|
-
var defineGlobalProperty$1 = defineGlobalProperty$3;
|
|
735
|
-
|
|
736
|
-
var defineBuiltIn$3 = function (O, key, value, options) {
|
|
737
|
-
if (!options) options = {};
|
|
738
|
-
var simple = options.enumerable;
|
|
739
|
-
var name = options.name !== undefined ? options.name : key;
|
|
740
|
-
if (isCallable$5(value)) makeBuiltIn$1(value, name, options);
|
|
741
|
-
if (options.global) {
|
|
742
|
-
if (simple) O[key] = value;
|
|
743
|
-
else defineGlobalProperty$1(key, value);
|
|
744
|
-
} else {
|
|
745
|
-
try {
|
|
746
|
-
if (!options.unsafe) delete O[key];
|
|
747
|
-
else if (O[key]) simple = true;
|
|
748
|
-
} catch (error) { /* empty */ }
|
|
749
|
-
if (simple) O[key] = value;
|
|
750
|
-
else definePropertyModule$3.f(O, key, {
|
|
751
|
-
value: value,
|
|
752
|
-
enumerable: false,
|
|
753
|
-
configurable: !options.nonConfigurable,
|
|
754
|
-
writable: !options.nonWritable
|
|
755
|
-
});
|
|
756
|
-
} return O;
|
|
757
|
-
};
|
|
758
|
-
|
|
759
|
-
var objectGetOwnPropertyNames = {};
|
|
760
|
-
|
|
761
|
-
var ceil = Math.ceil;
|
|
762
|
-
var floor = Math.floor;
|
|
763
|
-
|
|
764
|
-
// `Math.trunc` method
|
|
765
|
-
// https://tc39.es/ecma262/#sec-math.trunc
|
|
766
|
-
// eslint-disable-next-line es/no-math-trunc -- safe
|
|
767
|
-
var mathTrunc = Math.trunc || function trunc(x) {
|
|
768
|
-
var n = +x;
|
|
769
|
-
return (n > 0 ? floor : ceil)(n);
|
|
770
|
-
};
|
|
771
|
-
|
|
772
|
-
var trunc = mathTrunc;
|
|
773
|
-
|
|
774
|
-
// `ToIntegerOrInfinity` abstract operation
|
|
775
|
-
// https://tc39.es/ecma262/#sec-tointegerorinfinity
|
|
776
|
-
var toIntegerOrInfinity$2 = function (argument) {
|
|
777
|
-
var number = +argument;
|
|
778
|
-
// eslint-disable-next-line no-self-compare -- NaN check
|
|
779
|
-
return number !== number || number === 0 ? 0 : trunc(number);
|
|
780
|
-
};
|
|
781
|
-
|
|
782
|
-
var toIntegerOrInfinity$1 = toIntegerOrInfinity$2;
|
|
783
|
-
|
|
784
|
-
var max = Math.max;
|
|
785
|
-
var min$1 = Math.min;
|
|
786
|
-
|
|
787
|
-
// Helper for a popular repeating case of the spec:
|
|
788
|
-
// Let integer be ? ToInteger(index).
|
|
789
|
-
// If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
|
|
790
|
-
var toAbsoluteIndex$1 = function (index, length) {
|
|
791
|
-
var integer = toIntegerOrInfinity$1(index);
|
|
792
|
-
return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
|
|
793
|
-
};
|
|
794
|
-
|
|
795
|
-
var toIntegerOrInfinity = toIntegerOrInfinity$2;
|
|
796
|
-
|
|
797
|
-
var min = Math.min;
|
|
798
|
-
|
|
799
|
-
// `ToLength` abstract operation
|
|
800
|
-
// https://tc39.es/ecma262/#sec-tolength
|
|
801
|
-
var toLength$1 = function (argument) {
|
|
802
|
-
var len = toIntegerOrInfinity(argument);
|
|
803
|
-
return len > 0 ? min(len, 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
|
|
804
|
-
};
|
|
805
|
-
|
|
806
|
-
var toLength = toLength$1;
|
|
807
|
-
|
|
808
|
-
// `LengthOfArrayLike` abstract operation
|
|
809
|
-
// https://tc39.es/ecma262/#sec-lengthofarraylike
|
|
810
|
-
var lengthOfArrayLike$3 = function (obj) {
|
|
811
|
-
return toLength(obj.length);
|
|
812
|
-
};
|
|
813
|
-
|
|
814
|
-
var toIndexedObject$2 = toIndexedObject$4;
|
|
815
|
-
var toAbsoluteIndex = toAbsoluteIndex$1;
|
|
816
|
-
var lengthOfArrayLike$2 = lengthOfArrayLike$3;
|
|
817
|
-
|
|
818
|
-
// `Array.prototype.{ indexOf, includes }` methods implementation
|
|
819
|
-
var createMethod = function (IS_INCLUDES) {
|
|
820
|
-
return function ($this, el, fromIndex) {
|
|
821
|
-
var O = toIndexedObject$2($this);
|
|
822
|
-
var length = lengthOfArrayLike$2(O);
|
|
823
|
-
if (length === 0) return !IS_INCLUDES && -1;
|
|
824
|
-
var index = toAbsoluteIndex(fromIndex, length);
|
|
825
|
-
var value;
|
|
826
|
-
// Array#includes uses SameValueZero equality algorithm
|
|
827
|
-
// eslint-disable-next-line no-self-compare -- NaN check
|
|
828
|
-
if (IS_INCLUDES && el !== el) while (length > index) {
|
|
829
|
-
value = O[index++];
|
|
830
|
-
// eslint-disable-next-line no-self-compare -- NaN check
|
|
831
|
-
if (value !== value) return true;
|
|
832
|
-
// Array#indexOf ignores holes, Array#includes - not
|
|
833
|
-
} else for (;length > index; index++) {
|
|
834
|
-
if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
|
|
835
|
-
} return !IS_INCLUDES && -1;
|
|
535
|
+
return result;
|
|
536
|
+
}
|
|
537
|
+
function assertZohoRecruitRecordDataArrayResultHasContent(moduleName, recordId) {
|
|
538
|
+
return x => {
|
|
539
|
+
if (x == null || !x.data?.length) {
|
|
540
|
+
throw new ZohoRecruitRecordNoContentError(moduleName, recordId);
|
|
541
|
+
} else {
|
|
542
|
+
return x;
|
|
543
|
+
}
|
|
836
544
|
};
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
// https://tc39.es/ecma262/#sec-array.prototype.indexof
|
|
845
|
-
indexOf: createMethod(false)
|
|
846
|
-
};
|
|
847
|
-
|
|
848
|
-
var uncurryThis$3 = functionUncurryThis;
|
|
849
|
-
var hasOwn$3 = hasOwnProperty_1;
|
|
850
|
-
var toIndexedObject$1 = toIndexedObject$4;
|
|
851
|
-
var indexOf = arrayIncludes.indexOf;
|
|
852
|
-
var hiddenKeys$2 = hiddenKeys$4;
|
|
853
|
-
|
|
854
|
-
var push = uncurryThis$3([].push);
|
|
855
|
-
|
|
856
|
-
var objectKeysInternal = function (object, names) {
|
|
857
|
-
var O = toIndexedObject$1(object);
|
|
858
|
-
var i = 0;
|
|
859
|
-
var result = [];
|
|
860
|
-
var key;
|
|
861
|
-
for (key in O) !hasOwn$3(hiddenKeys$2, key) && hasOwn$3(O, key) && push(result, key);
|
|
862
|
-
// Don't enum bug & hidden keys
|
|
863
|
-
while (names.length > i) if (hasOwn$3(O, key = names[i++])) {
|
|
864
|
-
~indexOf(result, key) || push(result, key);
|
|
545
|
+
}
|
|
546
|
+
const logZohoRecruitErrorToConsole = logZohoServerErrorFunction('ZohoRecruit');
|
|
547
|
+
async function parseZohoRecruitError(responseError) {
|
|
548
|
+
const data = await responseError.response.json().catch(x => undefined);
|
|
549
|
+
let result;
|
|
550
|
+
if (data) {
|
|
551
|
+
result = parseZohoRecruitServerErrorResponseData(data, responseError);
|
|
865
552
|
}
|
|
866
553
|
return result;
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
return internalObjectKeys$1(O, hiddenKeys$1);
|
|
890
|
-
};
|
|
891
|
-
|
|
892
|
-
var objectGetOwnPropertySymbols = {};
|
|
893
|
-
|
|
894
|
-
// eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
|
|
895
|
-
objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
|
|
896
|
-
|
|
897
|
-
var getBuiltIn$1 = getBuiltIn$3;
|
|
898
|
-
var uncurryThis$2 = functionUncurryThis;
|
|
899
|
-
var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
|
|
900
|
-
var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
|
|
901
|
-
var anObject$c = anObject$e;
|
|
902
|
-
|
|
903
|
-
var concat = uncurryThis$2([].concat);
|
|
904
|
-
|
|
905
|
-
// all object keys, includes non-enumerable and symbols
|
|
906
|
-
var ownKeys$1 = getBuiltIn$1('Reflect', 'ownKeys') || function ownKeys(it) {
|
|
907
|
-
var keys = getOwnPropertyNamesModule.f(anObject$c(it));
|
|
908
|
-
var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
|
|
909
|
-
return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
|
|
910
|
-
};
|
|
911
|
-
|
|
912
|
-
var hasOwn$2 = hasOwnProperty_1;
|
|
913
|
-
var ownKeys = ownKeys$1;
|
|
914
|
-
var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor;
|
|
915
|
-
var definePropertyModule$2 = objectDefineProperty;
|
|
554
|
+
}
|
|
555
|
+
function parseZohoRecruitServerErrorResponseData(errorResponseData, responseError) {
|
|
556
|
+
let result;
|
|
557
|
+
const error = tryFindZohoServerErrorData(errorResponseData, responseError);
|
|
558
|
+
if (error) {
|
|
559
|
+
const errorData = zohoServerErrorData(error);
|
|
560
|
+
switch (errorData.code) {
|
|
561
|
+
// TODO: Add recruit-specific error codes here.
|
|
562
|
+
default:
|
|
563
|
+
result = parseZohoServerErrorResponseData(errorResponseData, responseError);
|
|
564
|
+
break;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
return result;
|
|
568
|
+
}
|
|
569
|
+
const interceptZohoRecruit200StatusWithErrorResponse = interceptZohoErrorResponseFactory(parseZohoRecruitServerErrorResponseData);
|
|
570
|
+
const handleZohoRecruitErrorFetch = handleZohoErrorFetchFactory(parseZohoRecruitError, logZohoRecruitErrorToConsole);
|
|
571
|
+
// MARK: Compat
|
|
572
|
+
/**
|
|
573
|
+
* @deprecated Use assertZohoRecruitRecordDataArrayResultHasContent instead.
|
|
574
|
+
*/
|
|
575
|
+
const assertRecordDataArrayResultHasContent = assertZohoRecruitRecordDataArrayResultHasContent;
|
|
916
576
|
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
577
|
+
// MARK: Insert/Update/Upsert Response
|
|
578
|
+
/**
|
|
579
|
+
* The maximum number of records allowed for most CRUD functions.
|
|
580
|
+
*
|
|
581
|
+
* This is a limit enforced by the Zoho Recruit API
|
|
582
|
+
*/
|
|
583
|
+
const ZOHO_RECRUIT_CRUD_FUNCTION_MAX_RECORDS_LIMIT = 100;
|
|
584
|
+
/**
|
|
585
|
+
* The APIs for Insert, Upsert, and Update have the same structure.
|
|
586
|
+
*
|
|
587
|
+
* @returns
|
|
588
|
+
*/
|
|
589
|
+
function updateRecordLikeFunction$1(context, fetchUrlPrefix, fetchMethod) {
|
|
590
|
+
return ({
|
|
591
|
+
data,
|
|
592
|
+
module
|
|
593
|
+
}) => context.fetchJson(`/v2/${module}${fetchUrlPrefix}`, zohoRecruitApiFetchJsonInput(fetchMethod, {
|
|
594
|
+
data: util.asArray(data)
|
|
595
|
+
})).then(x => {
|
|
596
|
+
const isInputMultipleItems = Array.isArray(data);
|
|
597
|
+
const result = zohoRecruitMultiRecordResult(util.asArray(data), x.data);
|
|
598
|
+
if (isInputMultipleItems) {
|
|
599
|
+
return result;
|
|
600
|
+
} else {
|
|
601
|
+
const {
|
|
602
|
+
successItems,
|
|
603
|
+
errorItems
|
|
604
|
+
} = result;
|
|
605
|
+
if (errorItems[0] != null) {
|
|
606
|
+
throw zohoRecruitRecordCrudError(errorItems[0].result);
|
|
607
|
+
} else {
|
|
608
|
+
return successItems[0].result.details;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Inserts one or more records into Recruit.
|
|
615
|
+
*
|
|
616
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/insert-records.html
|
|
617
|
+
*
|
|
618
|
+
* @param context
|
|
619
|
+
* @returns
|
|
620
|
+
*/
|
|
621
|
+
function zohoRecruitInsertRecord(context) {
|
|
622
|
+
return updateRecordLikeFunction$1(context, '', 'POST');
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Updates or inserts one or more records in Recruit.
|
|
626
|
+
*
|
|
627
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/upsert-records.html
|
|
628
|
+
*
|
|
629
|
+
* @param context
|
|
630
|
+
* @returns
|
|
631
|
+
*/
|
|
632
|
+
function zohoRecruitUpsertRecord(context) {
|
|
633
|
+
return updateRecordLikeFunction$1(context, '/upsert', 'POST');
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Updates one or more records in Recruit.
|
|
637
|
+
*
|
|
638
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/update-records.html
|
|
639
|
+
*
|
|
640
|
+
* @param context
|
|
641
|
+
* @returns
|
|
642
|
+
*/
|
|
643
|
+
function zohoRecruitUpdateRecord(context) {
|
|
644
|
+
return updateRecordLikeFunction$1(context, '', 'PUT');
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Deletes one or more records from the given module.
|
|
648
|
+
*
|
|
649
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/delete-records.html
|
|
650
|
+
*
|
|
651
|
+
* @param context
|
|
652
|
+
* @returns ZohoRecruitDeleteRecordFunction
|
|
653
|
+
*/
|
|
654
|
+
function zohoRecruitDeleteRecord(context) {
|
|
655
|
+
return ({
|
|
656
|
+
ids,
|
|
657
|
+
module,
|
|
658
|
+
wf_trigger
|
|
659
|
+
}) => {
|
|
660
|
+
return context.fetchJson(`/v2/${module}?${fetch.makeUrlSearchParams({
|
|
661
|
+
ids,
|
|
662
|
+
wf_trigger
|
|
663
|
+
})}`, zohoRecruitApiFetchJsonInput('DELETE')).then(zohoRecruitChangeObjectLikeResponseSuccessAndErrorPairs);
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Retrieves a specific record from the given module.
|
|
668
|
+
*
|
|
669
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/get-records.html
|
|
670
|
+
*
|
|
671
|
+
* @param context
|
|
672
|
+
* @returns
|
|
673
|
+
*/
|
|
674
|
+
function zohoRecruitGetRecordById(context) {
|
|
675
|
+
return input => context.fetchJson(`/v2/${input.module}/${input.id}`, zohoRecruitApiFetchJsonInput('GET')).then(assertZohoRecruitRecordDataArrayResultHasContent(input.module)).then(x => x.data[0]);
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Retrieves records from the given module. Used for paginating across all records.
|
|
679
|
+
*
|
|
680
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/get-records.html
|
|
681
|
+
*
|
|
682
|
+
* @param context
|
|
683
|
+
* @returns
|
|
684
|
+
*/
|
|
685
|
+
function zohoRecruitGetRecords(context) {
|
|
686
|
+
return input => context.fetchJson(`/v2/${input.module}?${zohoRecruitUrlSearchParamsMinusModule(input).toString()}`, zohoRecruitApiFetchJsonInput('GET'));
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* Searches records from the given module.
|
|
690
|
+
*
|
|
691
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/search-records.html
|
|
692
|
+
*
|
|
693
|
+
* @param context
|
|
694
|
+
* @returns
|
|
695
|
+
*/
|
|
696
|
+
function zohoRecruitSearchRecords(context) {
|
|
697
|
+
function searchRecordsUrlSearchParams(input) {
|
|
698
|
+
const baseInput = {
|
|
699
|
+
...input
|
|
700
|
+
};
|
|
701
|
+
delete baseInput.criteria;
|
|
702
|
+
if (input.criteria != null) {
|
|
703
|
+
const criteriaString = zohoRecruitSearchRecordsCriteriaString(input.criteria);
|
|
704
|
+
baseInput.criteria = criteriaString;
|
|
925
705
|
}
|
|
706
|
+
if (!baseInput.word && !input.criteria && !input.email && !input.phone) {
|
|
707
|
+
throw new Error('At least one of word, criteria, email, or phone must be provided');
|
|
708
|
+
}
|
|
709
|
+
const urlParams = zohoRecruitUrlSearchParamsMinusModule(baseInput);
|
|
710
|
+
return urlParams;
|
|
926
711
|
}
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
var replacement = /#|\.prototype\./;
|
|
933
|
-
|
|
934
|
-
var isForced$1 = function (feature, detection) {
|
|
935
|
-
var value = data[normalize(feature)];
|
|
936
|
-
return value === POLYFILL ? true
|
|
937
|
-
: value === NATIVE ? false
|
|
938
|
-
: isCallable$4(detection) ? fails$4(detection)
|
|
939
|
-
: !!detection;
|
|
940
|
-
};
|
|
941
|
-
|
|
942
|
-
var normalize = isForced$1.normalize = function (string) {
|
|
943
|
-
return String(string).replace(replacement, '.').toLowerCase();
|
|
944
|
-
};
|
|
945
|
-
|
|
946
|
-
var data = isForced$1.data = {};
|
|
947
|
-
var NATIVE = isForced$1.NATIVE = 'N';
|
|
948
|
-
var POLYFILL = isForced$1.POLYFILL = 'P';
|
|
949
|
-
|
|
950
|
-
var isForced_1 = isForced$1;
|
|
951
|
-
|
|
952
|
-
var global$2 = global$b;
|
|
953
|
-
var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
|
|
954
|
-
var createNonEnumerableProperty$1 = createNonEnumerableProperty$3;
|
|
955
|
-
var defineBuiltIn$2 = defineBuiltIn$3;
|
|
956
|
-
var defineGlobalProperty = defineGlobalProperty$3;
|
|
957
|
-
var copyConstructorProperties = copyConstructorProperties$1;
|
|
958
|
-
var isForced = isForced_1;
|
|
959
|
-
|
|
960
|
-
/*
|
|
961
|
-
options.target - name of the target object
|
|
962
|
-
options.global - target is the global object
|
|
963
|
-
options.stat - export as static methods of target
|
|
964
|
-
options.proto - export as prototype methods of target
|
|
965
|
-
options.real - real prototype method for the `pure` version
|
|
966
|
-
options.forced - export even if the native feature is available
|
|
967
|
-
options.bind - bind methods to the target, required for the `pure` version
|
|
968
|
-
options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
|
|
969
|
-
options.unsafe - use the simple assignment of property instead of delete + defineProperty
|
|
970
|
-
options.sham - add a flag to not completely full polyfills
|
|
971
|
-
options.enumerable - export as enumerable property
|
|
972
|
-
options.dontCallGetSet - prevent calling a getter on target
|
|
973
|
-
options.name - the .name of the function if it does not match the key
|
|
974
|
-
*/
|
|
975
|
-
var _export = function (options, source) {
|
|
976
|
-
var TARGET = options.target;
|
|
977
|
-
var GLOBAL = options.global;
|
|
978
|
-
var STATIC = options.stat;
|
|
979
|
-
var FORCED, target, key, targetProperty, sourceProperty, descriptor;
|
|
980
|
-
if (GLOBAL) {
|
|
981
|
-
target = global$2;
|
|
982
|
-
} else if (STATIC) {
|
|
983
|
-
target = global$2[TARGET] || defineGlobalProperty(TARGET, {});
|
|
984
|
-
} else {
|
|
985
|
-
target = global$2[TARGET] && global$2[TARGET].prototype;
|
|
986
|
-
}
|
|
987
|
-
if (target) for (key in source) {
|
|
988
|
-
sourceProperty = source[key];
|
|
989
|
-
if (options.dontCallGetSet) {
|
|
990
|
-
descriptor = getOwnPropertyDescriptor$1(target, key);
|
|
991
|
-
targetProperty = descriptor && descriptor.value;
|
|
992
|
-
} else targetProperty = target[key];
|
|
993
|
-
FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
|
|
994
|
-
// contained in target
|
|
995
|
-
if (!FORCED && targetProperty !== undefined) {
|
|
996
|
-
if (typeof sourceProperty == typeof targetProperty) continue;
|
|
997
|
-
copyConstructorProperties(sourceProperty, targetProperty);
|
|
712
|
+
return input => context.fetchJson(`/v2/${input.module}/search?${searchRecordsUrlSearchParams(input).toString()}`, zohoRecruitApiFetchJsonInput('GET')).then(x => x ?? {
|
|
713
|
+
data: [],
|
|
714
|
+
info: {
|
|
715
|
+
more_records: false
|
|
998
716
|
}
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
function zohoRecruitSearchRecordsPageFactory(context) {
|
|
720
|
+
return zohoFetchPageFactory(zohoRecruitSearchRecords(context));
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Creates a ZohoRecruitGetRelatedRecordsFunctionFactory, which can be used to create ZohoRecruitGetRelatedRecordsFunction<T> that targets retrieving related records of a given type.
|
|
724
|
+
*
|
|
725
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/get-related-records.html
|
|
726
|
+
*
|
|
727
|
+
* @param context the ZohoRecruitContext to use
|
|
728
|
+
* @returns a ZohoRecruitGetRelatedRecordsFunctionFactory
|
|
729
|
+
*/
|
|
730
|
+
function zohoRecruitGetRelatedRecordsFunctionFactory(context) {
|
|
731
|
+
return config => {
|
|
732
|
+
const {
|
|
733
|
+
targetModule,
|
|
734
|
+
returnEmptyRecordsInsteadOfNull = true
|
|
735
|
+
} = config;
|
|
736
|
+
return input => context.fetchJson(`/v2/${input.module}/${input.id}/${targetModule}?${zohoRecruitUrlSearchParamsMinusIdAndModule(input, input.filter).toString()}`, zohoRecruitApiFetchJsonInput('GET')).then(x => x ?? (returnEmptyRecordsInsteadOfNull !== false ? emptyZohoPageResult() : x));
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
function zohoRecruitGetEmailsForRecord(context) {
|
|
740
|
+
return zohoRecruitGetRelatedRecordsFunctionFactory(context)({
|
|
741
|
+
targetModule: ZOHO_RECRUIT_EMAILS_MODULE
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
function zohoRecruitGetEmailsForRecordPageFactory(context) {
|
|
745
|
+
return zohoFetchPageFactory(zohoRecruitGetEmailsForRecord(context));
|
|
746
|
+
}
|
|
747
|
+
function zohoRecruitGetAttachmentsForRecord(context) {
|
|
748
|
+
return zohoRecruitGetRelatedRecordsFunctionFactory(context)({
|
|
749
|
+
targetModule: ZOHO_RECRUIT_ATTACHMENTS_MODULE
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
function zohoRecruitGetAttachmentsForRecordPageFactory(context) {
|
|
753
|
+
return zohoFetchPageFactory(zohoRecruitGetAttachmentsForRecord(context));
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Maximum attachment size allowed by Zoho Recruit.
|
|
757
|
+
*
|
|
758
|
+
* 20MB
|
|
759
|
+
*/
|
|
760
|
+
const ZOHO_RECRUIT_ATTACHMENT_MAX_SIZE = 20 * 1024 * 1024;
|
|
761
|
+
/**
|
|
762
|
+
* Uploads an attachment to a record.
|
|
763
|
+
*
|
|
764
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/upload-attachment.html
|
|
765
|
+
*
|
|
766
|
+
* @param context
|
|
767
|
+
* @returns
|
|
768
|
+
*/
|
|
769
|
+
function zohoRecruitUploadAttachmentForRecord(context) {
|
|
770
|
+
return input => {
|
|
771
|
+
const {
|
|
772
|
+
attachmentCategoryId,
|
|
773
|
+
attachmentCategoryName,
|
|
774
|
+
formData
|
|
775
|
+
} = input;
|
|
776
|
+
const urlParams = {
|
|
777
|
+
attachments_category_id: util.joinStringsWithCommas(attachmentCategoryId),
|
|
778
|
+
attachments_category: util.joinStringsWithCommas(attachmentCategoryName),
|
|
779
|
+
attachment_url: input.attachmentUrl
|
|
780
|
+
};
|
|
781
|
+
if (!urlParams.attachments_category_id?.length && !urlParams.attachments_category?.length) {
|
|
782
|
+
throw new Error('attachmentCategoryId or attachmentCategoryName must be provided and not empty.');
|
|
1002
783
|
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
};
|
|
1006
|
-
|
|
1007
|
-
var classof$2 = classofRaw$2;
|
|
1008
|
-
|
|
1009
|
-
// `IsArray` abstract operation
|
|
1010
|
-
// https://tc39.es/ecma262/#sec-isarray
|
|
1011
|
-
// eslint-disable-next-line es/no-array-isarray -- safe
|
|
1012
|
-
var isArray$1 = Array.isArray || function isArray(argument) {
|
|
1013
|
-
return classof$2(argument) === 'Array';
|
|
1014
|
-
};
|
|
1015
|
-
|
|
1016
|
-
var DESCRIPTORS$3 = descriptors;
|
|
1017
|
-
var isArray = isArray$1;
|
|
1018
|
-
|
|
1019
|
-
var $TypeError$5 = TypeError;
|
|
1020
|
-
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
1021
|
-
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
1022
|
-
|
|
1023
|
-
// Safari < 13 does not throw an error in this case
|
|
1024
|
-
var SILENT_ON_NON_WRITABLE_LENGTH_SET = DESCRIPTORS$3 && !function () {
|
|
1025
|
-
// makes no sense without proper strict mode support
|
|
1026
|
-
if (this !== undefined) return true;
|
|
1027
|
-
try {
|
|
1028
|
-
// eslint-disable-next-line es/no-object-defineproperty -- safe
|
|
1029
|
-
Object.defineProperty([], 'length', { writable: false }).length = 1;
|
|
1030
|
-
} catch (error) {
|
|
1031
|
-
return error instanceof TypeError;
|
|
1032
|
-
}
|
|
1033
|
-
}();
|
|
1034
|
-
|
|
1035
|
-
var arraySetLength = SILENT_ON_NON_WRITABLE_LENGTH_SET ? function (O, length) {
|
|
1036
|
-
if (isArray(O) && !getOwnPropertyDescriptor(O, 'length').writable) {
|
|
1037
|
-
throw new $TypeError$5('Cannot set read only .length');
|
|
1038
|
-
} return O.length = length;
|
|
1039
|
-
} : function (O, length) {
|
|
1040
|
-
return O.length = length;
|
|
1041
|
-
};
|
|
1042
|
-
|
|
1043
|
-
var $TypeError$4 = TypeError;
|
|
1044
|
-
var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; // 2 ** 53 - 1 == 9007199254740991
|
|
1045
|
-
|
|
1046
|
-
var doesNotExceedSafeInteger$1 = function (it) {
|
|
1047
|
-
if (it > MAX_SAFE_INTEGER) throw $TypeError$4('Maximum allowed index exceeded');
|
|
1048
|
-
return it;
|
|
1049
|
-
};
|
|
1050
|
-
|
|
1051
|
-
var $$5 = _export;
|
|
1052
|
-
var toObject$1 = toObject$3;
|
|
1053
|
-
var lengthOfArrayLike$1 = lengthOfArrayLike$3;
|
|
1054
|
-
var setArrayLength = arraySetLength;
|
|
1055
|
-
var doesNotExceedSafeInteger = doesNotExceedSafeInteger$1;
|
|
1056
|
-
var fails$3 = fails$c;
|
|
1057
|
-
|
|
1058
|
-
var INCORRECT_TO_LENGTH = fails$3(function () {
|
|
1059
|
-
return [].push.call({ length: 0x100000000 }, 1) !== 4294967297;
|
|
1060
|
-
});
|
|
1061
|
-
|
|
1062
|
-
// V8 <= 121 and Safari <= 15.4; FF < 23 throws InternalError
|
|
1063
|
-
// https://bugs.chromium.org/p/v8/issues/detail?id=12681
|
|
1064
|
-
var properErrorOnNonWritableLength = function () {
|
|
1065
|
-
try {
|
|
1066
|
-
// eslint-disable-next-line es/no-object-defineproperty -- safe
|
|
1067
|
-
Object.defineProperty([], 'length', { writable: false }).push();
|
|
1068
|
-
} catch (error) {
|
|
1069
|
-
return error instanceof TypeError;
|
|
1070
|
-
}
|
|
1071
|
-
};
|
|
1072
|
-
|
|
1073
|
-
var FORCED$1 = INCORRECT_TO_LENGTH || !properErrorOnNonWritableLength();
|
|
1074
|
-
|
|
1075
|
-
// `Array.prototype.push` method
|
|
1076
|
-
// https://tc39.es/ecma262/#sec-array.prototype.push
|
|
1077
|
-
$$5({ target: 'Array', proto: true, arity: 1, forced: FORCED$1 }, {
|
|
1078
|
-
// eslint-disable-next-line no-unused-vars -- required for `.length`
|
|
1079
|
-
push: function push(item) {
|
|
1080
|
-
var O = toObject$1(this);
|
|
1081
|
-
var len = lengthOfArrayLike$1(O);
|
|
1082
|
-
var argCount = arguments.length;
|
|
1083
|
-
doesNotExceedSafeInteger(len + argCount);
|
|
1084
|
-
for (var i = 0; i < argCount; i++) {
|
|
1085
|
-
O[len] = arguments[i];
|
|
1086
|
-
len++;
|
|
784
|
+
if (formData != null) {
|
|
785
|
+
delete urlParams.attachment_url;
|
|
1087
786
|
}
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? $Object$1.getPrototypeOf : function (O) {
|
|
1125
|
-
var object = toObject(O);
|
|
1126
|
-
if (hasOwn$1(object, IE_PROTO$1)) return object[IE_PROTO$1];
|
|
1127
|
-
var constructor = object.constructor;
|
|
1128
|
-
if (isCallable$3(constructor) && object instanceof constructor) {
|
|
1129
|
-
return constructor.prototype;
|
|
1130
|
-
} return object instanceof $Object$1 ? ObjectPrototype : null;
|
|
1131
|
-
};
|
|
1132
|
-
|
|
1133
|
-
var makeBuiltIn = makeBuiltInExports;
|
|
1134
|
-
var defineProperty = objectDefineProperty;
|
|
1135
|
-
|
|
1136
|
-
var defineBuiltInAccessor$1 = function (target, name, descriptor) {
|
|
1137
|
-
if (descriptor.get) makeBuiltIn(descriptor.get, name, { getter: true });
|
|
1138
|
-
if (descriptor.set) makeBuiltIn(descriptor.set, name, { setter: true });
|
|
1139
|
-
return defineProperty.f(target, name, descriptor);
|
|
1140
|
-
};
|
|
1141
|
-
|
|
1142
|
-
var DESCRIPTORS$2 = descriptors;
|
|
1143
|
-
var definePropertyModule$1 = objectDefineProperty;
|
|
1144
|
-
var createPropertyDescriptor = createPropertyDescriptor$3;
|
|
1145
|
-
|
|
1146
|
-
var createProperty$1 = function (object, key, value) {
|
|
1147
|
-
if (DESCRIPTORS$2) definePropertyModule$1.f(object, key, createPropertyDescriptor(0, value));
|
|
1148
|
-
else object[key] = value;
|
|
1149
|
-
};
|
|
1150
|
-
|
|
1151
|
-
var objectDefineProperties = {};
|
|
1152
|
-
|
|
1153
|
-
var internalObjectKeys = objectKeysInternal;
|
|
1154
|
-
var enumBugKeys$1 = enumBugKeys$3;
|
|
1155
|
-
|
|
1156
|
-
// `Object.keys` method
|
|
1157
|
-
// https://tc39.es/ecma262/#sec-object.keys
|
|
1158
|
-
// eslint-disable-next-line es/no-object-keys -- safe
|
|
1159
|
-
var objectKeys$1 = Object.keys || function keys(O) {
|
|
1160
|
-
return internalObjectKeys(O, enumBugKeys$1);
|
|
1161
|
-
};
|
|
1162
|
-
|
|
1163
|
-
var DESCRIPTORS$1 = descriptors;
|
|
1164
|
-
var V8_PROTOTYPE_DEFINE_BUG = v8PrototypeDefineBug;
|
|
1165
|
-
var definePropertyModule = objectDefineProperty;
|
|
1166
|
-
var anObject$b = anObject$e;
|
|
1167
|
-
var toIndexedObject = toIndexedObject$4;
|
|
1168
|
-
var objectKeys = objectKeys$1;
|
|
1169
|
-
|
|
1170
|
-
// `Object.defineProperties` method
|
|
1171
|
-
// https://tc39.es/ecma262/#sec-object.defineproperties
|
|
1172
|
-
// eslint-disable-next-line es/no-object-defineproperties -- safe
|
|
1173
|
-
objectDefineProperties.f = DESCRIPTORS$1 && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) {
|
|
1174
|
-
anObject$b(O);
|
|
1175
|
-
var props = toIndexedObject(Properties);
|
|
1176
|
-
var keys = objectKeys(Properties);
|
|
1177
|
-
var length = keys.length;
|
|
1178
|
-
var index = 0;
|
|
1179
|
-
var key;
|
|
1180
|
-
while (length > index) definePropertyModule.f(O, key = keys[index++], props[key]);
|
|
1181
|
-
return O;
|
|
1182
|
-
};
|
|
1183
|
-
|
|
1184
|
-
var getBuiltIn = getBuiltIn$3;
|
|
1185
|
-
|
|
1186
|
-
var html$1 = getBuiltIn('document', 'documentElement');
|
|
1187
|
-
|
|
1188
|
-
/* global ActiveXObject -- old IE, WSH */
|
|
1189
|
-
var anObject$a = anObject$e;
|
|
1190
|
-
var definePropertiesModule = objectDefineProperties;
|
|
1191
|
-
var enumBugKeys = enumBugKeys$3;
|
|
1192
|
-
var hiddenKeys = hiddenKeys$4;
|
|
1193
|
-
var html = html$1;
|
|
1194
|
-
var documentCreateElement = documentCreateElement$1;
|
|
1195
|
-
var sharedKey = sharedKey$3;
|
|
1196
|
-
|
|
1197
|
-
var GT = '>';
|
|
1198
|
-
var LT = '<';
|
|
1199
|
-
var PROTOTYPE = 'prototype';
|
|
1200
|
-
var SCRIPT = 'script';
|
|
1201
|
-
var IE_PROTO = sharedKey('IE_PROTO');
|
|
1202
|
-
|
|
1203
|
-
var EmptyConstructor = function () { /* empty */ };
|
|
1204
|
-
|
|
1205
|
-
var scriptTag = function (content) {
|
|
1206
|
-
return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
|
|
1207
|
-
};
|
|
1208
|
-
|
|
1209
|
-
// Create object with fake `null` prototype: use ActiveX Object with cleared prototype
|
|
1210
|
-
var NullProtoObjectViaActiveX = function (activeXDocument) {
|
|
1211
|
-
activeXDocument.write(scriptTag(''));
|
|
1212
|
-
activeXDocument.close();
|
|
1213
|
-
var temp = activeXDocument.parentWindow.Object;
|
|
1214
|
-
activeXDocument = null; // avoid memory leak
|
|
1215
|
-
return temp;
|
|
1216
|
-
};
|
|
1217
|
-
|
|
1218
|
-
// Create object with fake `null` prototype: use iframe Object with cleared prototype
|
|
1219
|
-
var NullProtoObjectViaIFrame = function () {
|
|
1220
|
-
// Thrash, waste and sodomy: IE GC bug
|
|
1221
|
-
var iframe = documentCreateElement('iframe');
|
|
1222
|
-
var JS = 'java' + SCRIPT + ':';
|
|
1223
|
-
var iframeDocument;
|
|
1224
|
-
iframe.style.display = 'none';
|
|
1225
|
-
html.appendChild(iframe);
|
|
1226
|
-
// https://github.com/zloirock/core-js/issues/475
|
|
1227
|
-
iframe.src = String(JS);
|
|
1228
|
-
iframeDocument = iframe.contentWindow.document;
|
|
1229
|
-
iframeDocument.open();
|
|
1230
|
-
iframeDocument.write(scriptTag('document.F=Object'));
|
|
1231
|
-
iframeDocument.close();
|
|
1232
|
-
return iframeDocument.F;
|
|
1233
|
-
};
|
|
1234
|
-
|
|
1235
|
-
// Check for document.domain and active x support
|
|
1236
|
-
// No need to use active x approach when document.domain is not set
|
|
1237
|
-
// see https://github.com/es-shims/es5-shim/issues/150
|
|
1238
|
-
// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
|
|
1239
|
-
// avoid IE GC bug
|
|
1240
|
-
var activeXDocument;
|
|
1241
|
-
var NullProtoObject = function () {
|
|
1242
|
-
try {
|
|
1243
|
-
activeXDocument = new ActiveXObject('htmlfile');
|
|
1244
|
-
} catch (error) { /* ignore */ }
|
|
1245
|
-
NullProtoObject = typeof document != 'undefined'
|
|
1246
|
-
? document.domain && activeXDocument
|
|
1247
|
-
? NullProtoObjectViaActiveX(activeXDocument) // old IE
|
|
1248
|
-
: NullProtoObjectViaIFrame()
|
|
1249
|
-
: NullProtoObjectViaActiveX(activeXDocument); // WSH
|
|
1250
|
-
var length = enumBugKeys.length;
|
|
1251
|
-
while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
|
|
1252
|
-
return NullProtoObject();
|
|
1253
|
-
};
|
|
1254
|
-
|
|
1255
|
-
hiddenKeys[IE_PROTO] = true;
|
|
1256
|
-
|
|
1257
|
-
// `Object.create` method
|
|
1258
|
-
// https://tc39.es/ecma262/#sec-object.create
|
|
1259
|
-
// eslint-disable-next-line es/no-object-create -- safe
|
|
1260
|
-
var objectCreate = Object.create || function create(O, Properties) {
|
|
1261
|
-
var result;
|
|
1262
|
-
if (O !== null) {
|
|
1263
|
-
EmptyConstructor[PROTOTYPE] = anObject$a(O);
|
|
1264
|
-
result = new EmptyConstructor();
|
|
1265
|
-
EmptyConstructor[PROTOTYPE] = null;
|
|
1266
|
-
// add "__proto__" for Object.getPrototypeOf polyfill
|
|
1267
|
-
result[IE_PROTO] = O;
|
|
1268
|
-
} else result = NullProtoObject();
|
|
1269
|
-
return Properties === undefined ? result : definePropertiesModule.f(result, Properties);
|
|
1270
|
-
};
|
|
1271
|
-
|
|
1272
|
-
var fails$1 = fails$c;
|
|
1273
|
-
var isCallable$2 = isCallable$e;
|
|
1274
|
-
var isObject = isObject$6;
|
|
1275
|
-
var getPrototypeOf$1 = objectGetPrototypeOf;
|
|
1276
|
-
var defineBuiltIn$1 = defineBuiltIn$3;
|
|
1277
|
-
var wellKnownSymbol$6 = wellKnownSymbol$8;
|
|
1278
|
-
|
|
1279
|
-
var ITERATOR$3 = wellKnownSymbol$6('iterator');
|
|
1280
|
-
var BUGGY_SAFARI_ITERATORS = false;
|
|
1281
|
-
|
|
1282
|
-
// `%IteratorPrototype%` object
|
|
1283
|
-
// https://tc39.es/ecma262/#sec-%iteratorprototype%-object
|
|
1284
|
-
var IteratorPrototype$2, PrototypeOfArrayIteratorPrototype, arrayIterator;
|
|
1285
|
-
|
|
1286
|
-
/* eslint-disable es/no-array-prototype-keys -- safe */
|
|
1287
|
-
if ([].keys) {
|
|
1288
|
-
arrayIterator = [].keys();
|
|
1289
|
-
// Safari 8 has buggy iterators w/o `next`
|
|
1290
|
-
if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
|
|
1291
|
-
else {
|
|
1292
|
-
PrototypeOfArrayIteratorPrototype = getPrototypeOf$1(getPrototypeOf$1(arrayIterator));
|
|
1293
|
-
if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype$2 = PrototypeOfArrayIteratorPrototype;
|
|
1294
|
-
}
|
|
787
|
+
const url = `https://recruitsandbox.zoho.com/recruit/v2/${input.module}/${input.id}/${ZOHO_RECRUIT_ATTACHMENTS_MODULE}?${fetch.makeUrlSearchParams(urlParams).toString()}`;
|
|
788
|
+
let response;
|
|
789
|
+
if (urlParams.attachment_url) {
|
|
790
|
+
response = context.fetch(url, {
|
|
791
|
+
method: 'POST'
|
|
792
|
+
});
|
|
793
|
+
} else if (formData != null) {
|
|
794
|
+
throw new Error('unsupported currently. Use the attachmentUrl parameter instead.');
|
|
795
|
+
// There is something weird going on with sending requests this way and zoho's server is rejecting it.
|
|
796
|
+
/*
|
|
797
|
+
response = context.fetch(url, {
|
|
798
|
+
method: 'POST',
|
|
799
|
+
headers: {
|
|
800
|
+
'Content-Type': 'multipart/form-data',
|
|
801
|
+
'content-length': '210'
|
|
802
|
+
},
|
|
803
|
+
body: formData
|
|
804
|
+
});
|
|
805
|
+
*/
|
|
806
|
+
/*
|
|
807
|
+
const fullUrl = (context.config.apiUrl as string) + url;
|
|
808
|
+
const accessToken = await context.accessTokenStringFactory();
|
|
809
|
+
response = fetch(fullUrl, {
|
|
810
|
+
headers: {
|
|
811
|
+
Authorization: `Bearer ${accessToken}`
|
|
812
|
+
},
|
|
813
|
+
body: formData,
|
|
814
|
+
method: 'POST'
|
|
815
|
+
});
|
|
816
|
+
console.log({ response });
|
|
817
|
+
*/
|
|
818
|
+
} else {
|
|
819
|
+
throw new Error('body or attachmentUrl must be provided.');
|
|
820
|
+
}
|
|
821
|
+
return response;
|
|
822
|
+
};
|
|
1295
823
|
}
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
824
|
+
/**
|
|
825
|
+
* Downloads an attachment from a record.
|
|
826
|
+
*
|
|
827
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/download-attachments.html
|
|
828
|
+
*
|
|
829
|
+
* @param context
|
|
830
|
+
* @returns
|
|
831
|
+
*/
|
|
832
|
+
function zohoRecruitDownloadAttachmentForRecord(context) {
|
|
833
|
+
return input => context.fetch(`/v2/${input.module}/${input.id}/${ZOHO_RECRUIT_ATTACHMENTS_MODULE}/${input.attachment_id}`, {
|
|
834
|
+
method: 'GET'
|
|
835
|
+
}).then(fetch.parseFetchFileResponse);
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Deletes an attachment from a record.
|
|
839
|
+
*
|
|
840
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/delete-attachments.html
|
|
841
|
+
*
|
|
842
|
+
* @param context
|
|
843
|
+
* @returns
|
|
844
|
+
*/
|
|
845
|
+
function zohoRecruitDeleteAttachmentFromRecord(context) {
|
|
846
|
+
return input => context.fetch(`/v2/${input.module}/${input.id}/${ZOHO_RECRUIT_ATTACHMENTS_MODULE}/${input.attachment_id}`, {
|
|
847
|
+
method: 'DELETE'
|
|
1310
848
|
});
|
|
1311
849
|
}
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
var IteratorConstructor = function Iterator() {
|
|
1346
|
-
anInstance(this, IteratorPrototype$1);
|
|
1347
|
-
if (getPrototypeOf(this) === IteratorPrototype$1) throw new $TypeError$2('Abstract class Iterator not directly constructable');
|
|
1348
|
-
};
|
|
1349
|
-
|
|
1350
|
-
var defineIteratorPrototypeAccessor = function (key, value) {
|
|
1351
|
-
if (DESCRIPTORS) {
|
|
1352
|
-
defineBuiltInAccessor(IteratorPrototype$1, key, {
|
|
1353
|
-
configurable: true,
|
|
1354
|
-
get: function () {
|
|
1355
|
-
return value;
|
|
1356
|
-
},
|
|
1357
|
-
set: function (replacement) {
|
|
1358
|
-
anObject$9(this);
|
|
1359
|
-
if (this === IteratorPrototype$1) throw new $TypeError$2("You can't redefine this property");
|
|
1360
|
-
if (hasOwn(this, key)) this[key] = replacement;
|
|
1361
|
-
else createProperty(this, key, replacement);
|
|
850
|
+
class ZohoRecruitExecuteRestApiFunctionError extends makeError.BaseError {
|
|
851
|
+
constructor(error) {
|
|
852
|
+
super(`An error occured during the execution of the function. Code: ${error.code}, Message: ${error.message}`);
|
|
853
|
+
this.error = void 0;
|
|
854
|
+
this.error = error;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Creates a ZohoRecruitExecuteRestApiFunctionFunction
|
|
859
|
+
*
|
|
860
|
+
* OAuth Details:
|
|
861
|
+
* - https://www.zoho.com/crm/developer/docs/functions/serverless-fn-oauth.html#OAuth2
|
|
862
|
+
* - There is no documentation for ZohoRecruit specifically, but it seems to behave the same way
|
|
863
|
+
* - You will need the following scopes: ZohoRecruit.functions.execute.READ,ZohoRecruit.functions.execute.CREATE
|
|
864
|
+
*
|
|
865
|
+
* @param context
|
|
866
|
+
* @returns
|
|
867
|
+
*/
|
|
868
|
+
function zohoRecruitExecuteRestApiFunction(context) {
|
|
869
|
+
return input => {
|
|
870
|
+
const inputSearchParams = fetch.makeUrlSearchParams(input.params);
|
|
871
|
+
const inputSearchParamsString = inputSearchParams.toString();
|
|
872
|
+
const isSpecificRequest = Boolean(input.apiKey);
|
|
873
|
+
const urlParams = (isSpecificRequest ? `auth_type=apikey&zapikey=${input.apiKey}` : 'auth_type=oauth') + (inputSearchParamsString ? `&${inputSearchParamsString}` : '');
|
|
874
|
+
const relativeUrl = `/v2/functions/${input.functionName}/actions/execute?${urlParams}`;
|
|
875
|
+
const baseUrl = isSpecificRequest && input.apiUrl != null ? zohoRecruitConfigApiUrl(input.apiUrl) : '';
|
|
876
|
+
const url = `${baseUrl}${relativeUrl}`;
|
|
877
|
+
return context.fetchJson(url, zohoRecruitApiFetchJsonInput('POST')).then(x => {
|
|
878
|
+
if (x.code === 'success') {
|
|
879
|
+
return x.details;
|
|
880
|
+
} else {
|
|
881
|
+
throw new ZohoRecruitExecuteRestApiFunctionError(x);
|
|
1362
882
|
}
|
|
1363
883
|
});
|
|
1364
|
-
}
|
|
1365
|
-
};
|
|
1366
|
-
|
|
1367
|
-
if (!hasOwn(IteratorPrototype$1, TO_STRING_TAG$3)) defineIteratorPrototypeAccessor(TO_STRING_TAG$3, ITERATOR$2);
|
|
1368
|
-
|
|
1369
|
-
if (FORCED || !hasOwn(IteratorPrototype$1, CONSTRUCTOR) || IteratorPrototype$1[CONSTRUCTOR] === Object) {
|
|
1370
|
-
defineIteratorPrototypeAccessor(CONSTRUCTOR, IteratorConstructor);
|
|
884
|
+
};
|
|
1371
885
|
}
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
886
|
+
// MARK: Util
|
|
887
|
+
function zohoRecruitUrlSearchParamsMinusModule(...input) {
|
|
888
|
+
return fetch.makeUrlSearchParams(input, {
|
|
889
|
+
omitKeys: 'module'
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
function zohoRecruitUrlSearchParamsMinusIdAndModule(...input) {
|
|
893
|
+
return fetch.makeUrlSearchParams(input, {
|
|
894
|
+
omitKeys: ['id', 'module']
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
/**
|
|
898
|
+
* @deprecated use makeUrlSearchParams instead.
|
|
899
|
+
*/
|
|
900
|
+
const zohoRecruitUrlSearchParams = fetch.makeUrlSearchParams;
|
|
901
|
+
function zohoRecruitApiFetchJsonInput(method, body) {
|
|
902
|
+
const result = {
|
|
903
|
+
method,
|
|
904
|
+
body: body ?? undefined
|
|
1388
905
|
};
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
};
|
|
1403
|
-
|
|
1404
|
-
var call$7 = functionCall;
|
|
1405
|
-
var anObject$8 = anObject$e;
|
|
1406
|
-
var getMethod$2 = getMethod$4;
|
|
1407
|
-
|
|
1408
|
-
var iteratorClose$4 = function (iterator, kind, value) {
|
|
1409
|
-
var innerResult, innerError;
|
|
1410
|
-
anObject$8(iterator);
|
|
1411
|
-
try {
|
|
1412
|
-
innerResult = getMethod$2(iterator, 'return');
|
|
1413
|
-
if (!innerResult) {
|
|
1414
|
-
if (kind === 'throw') throw value;
|
|
1415
|
-
return value;
|
|
906
|
+
return result;
|
|
907
|
+
}
|
|
908
|
+
function zohoRecruitChangeObjectLikeResponseSuccessAndErrorPairs(response) {
|
|
909
|
+
const {
|
|
910
|
+
data
|
|
911
|
+
} = response;
|
|
912
|
+
const successItems = [];
|
|
913
|
+
const errorItems = [];
|
|
914
|
+
data.forEach(x => {
|
|
915
|
+
if (x.status === ZOHO_SUCCESS_STATUS) {
|
|
916
|
+
successItems.push(x);
|
|
917
|
+
} else {
|
|
918
|
+
errorItems.push(x);
|
|
1416
919
|
}
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
var ITERATOR_HELPER = 'IteratorHelper';
|
|
1441
|
-
var WRAP_FOR_VALID_ITERATOR = 'WrapForValidIterator';
|
|
1442
|
-
var setInternalState = InternalStateModule.set;
|
|
1443
|
-
|
|
1444
|
-
var createIteratorProxyPrototype = function (IS_ITERATOR) {
|
|
1445
|
-
var getInternalState = InternalStateModule.getterFor(IS_ITERATOR ? WRAP_FOR_VALID_ITERATOR : ITERATOR_HELPER);
|
|
1446
|
-
|
|
1447
|
-
return defineBuiltIns(create(IteratorPrototype), {
|
|
1448
|
-
next: function next() {
|
|
1449
|
-
var state = getInternalState(this);
|
|
1450
|
-
// for simplification:
|
|
1451
|
-
// for `%WrapForValidIteratorPrototype%.next` our `nextHandler` returns `IterResultObject`
|
|
1452
|
-
// for `%IteratorHelperPrototype%.next` - just a value
|
|
1453
|
-
if (IS_ITERATOR) return state.nextHandler();
|
|
1454
|
-
try {
|
|
1455
|
-
var result = state.done ? undefined : state.nextHandler();
|
|
1456
|
-
return createIterResultObject(result, state.done);
|
|
1457
|
-
} catch (error) {
|
|
1458
|
-
state.done = true;
|
|
1459
|
-
throw error;
|
|
1460
|
-
}
|
|
1461
|
-
},
|
|
1462
|
-
'return': function () {
|
|
1463
|
-
var state = getInternalState(this);
|
|
1464
|
-
var iterator = state.iterator;
|
|
1465
|
-
state.done = true;
|
|
1466
|
-
if (IS_ITERATOR) {
|
|
1467
|
-
var returnMethod = getMethod$1(iterator, 'return');
|
|
1468
|
-
return returnMethod ? call$6(returnMethod, iterator) : createIterResultObject(undefined, true);
|
|
1469
|
-
}
|
|
1470
|
-
if (state.inner) try {
|
|
1471
|
-
iteratorClose$3(state.inner.iterator, 'normal');
|
|
1472
|
-
} catch (error) {
|
|
1473
|
-
return iteratorClose$3(iterator, 'throw', error);
|
|
1474
|
-
}
|
|
1475
|
-
iteratorClose$3(iterator, 'normal');
|
|
1476
|
-
return createIterResultObject(undefined, true);
|
|
920
|
+
});
|
|
921
|
+
const result = {
|
|
922
|
+
...response,
|
|
923
|
+
successItems,
|
|
924
|
+
errorItems
|
|
925
|
+
};
|
|
926
|
+
return result;
|
|
927
|
+
}
|
|
928
|
+
function zohoRecruitMultiRecordResult(input, results) {
|
|
929
|
+
const successItems = [];
|
|
930
|
+
const errorItems = [];
|
|
931
|
+
input.forEach((x, i) => {
|
|
932
|
+
const result = results[i];
|
|
933
|
+
if (result.status === ZOHO_SUCCESS_STATUS) {
|
|
934
|
+
successItems.push({
|
|
935
|
+
input: x,
|
|
936
|
+
result: result
|
|
937
|
+
});
|
|
938
|
+
} else {
|
|
939
|
+
errorItems.push({
|
|
940
|
+
input: x,
|
|
941
|
+
result: result
|
|
942
|
+
});
|
|
1477
943
|
}
|
|
1478
944
|
});
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
var IteratorHelperPrototype = createIteratorProxyPrototype(false);
|
|
1483
|
-
|
|
1484
|
-
createNonEnumerableProperty(IteratorHelperPrototype, TO_STRING_TAG$2, 'Iterator Helper');
|
|
1485
|
-
|
|
1486
|
-
var iteratorCreateProxy = function (nextHandler, IS_ITERATOR) {
|
|
1487
|
-
var IteratorProxy = function Iterator(record, state) {
|
|
1488
|
-
if (state) {
|
|
1489
|
-
state.iterator = record.iterator;
|
|
1490
|
-
state.next = record.next;
|
|
1491
|
-
} else state = record;
|
|
1492
|
-
state.type = IS_ITERATOR ? WRAP_FOR_VALID_ITERATOR : ITERATOR_HELPER;
|
|
1493
|
-
state.nextHandler = nextHandler;
|
|
1494
|
-
state.counter = 0;
|
|
1495
|
-
state.done = false;
|
|
1496
|
-
setInternalState(this, state);
|
|
945
|
+
const result = {
|
|
946
|
+
successItems,
|
|
947
|
+
errorItems
|
|
1497
948
|
};
|
|
949
|
+
return result;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* @deprecated Use zohoRecruitInsertRecord instead.
|
|
953
|
+
*/
|
|
954
|
+
const insertRecord = zohoRecruitInsertRecord;
|
|
955
|
+
/**
|
|
956
|
+
* @deprecated Use zohoRecruitUpdateRecord instead.
|
|
957
|
+
*/
|
|
958
|
+
const updateRecord = zohoRecruitUpdateRecord;
|
|
959
|
+
/**
|
|
960
|
+
* @deprecated Use zohoRecruitUpsertRecord instead.
|
|
961
|
+
*/
|
|
962
|
+
const upsertRecord = zohoRecruitUpsertRecord;
|
|
963
|
+
/**
|
|
964
|
+
* @deprecated Use zohoRecruitDeleteRecord instead.
|
|
965
|
+
*/
|
|
966
|
+
const deleteRecord = zohoRecruitDeleteRecord;
|
|
967
|
+
/**
|
|
968
|
+
* @deprecated Use zohoRecruitGetRecordById instead.
|
|
969
|
+
*/
|
|
970
|
+
const getRecordById = zohoRecruitGetRecordById;
|
|
971
|
+
/**
|
|
972
|
+
* @deprecated Use zohoRecruitGetRecords instead.
|
|
973
|
+
*/
|
|
974
|
+
const getRecords = zohoRecruitGetRecords;
|
|
975
|
+
/**
|
|
976
|
+
* @deprecated Use zohoRecruitSearchRecords instead.
|
|
977
|
+
*/
|
|
978
|
+
const searchRecords = zohoRecruitSearchRecords;
|
|
979
|
+
/**
|
|
980
|
+
* @deprecated Use zohoRecruitSearchRecordsPageFactory instead.
|
|
981
|
+
*/
|
|
982
|
+
const searchRecordsPageFactory = zohoRecruitSearchRecordsPageFactory;
|
|
983
|
+
/**
|
|
984
|
+
* @deprecated Use zohoRecruitGetRelatedRecordsFunctionFactory instead.
|
|
985
|
+
*/
|
|
986
|
+
const getRelatedRecordsFunctionFactory = zohoRecruitGetRelatedRecordsFunctionFactory;
|
|
987
|
+
/**
|
|
988
|
+
* @deprecated Use zohoRecruitGetEmailsForRecord instead.
|
|
989
|
+
*/
|
|
990
|
+
const getEmailsForRecord = zohoRecruitGetEmailsForRecord;
|
|
991
|
+
/**
|
|
992
|
+
* @deprecated Use zohoRecruitGetEmailsForRecordPageFactory instead.
|
|
993
|
+
*/
|
|
994
|
+
const getEmailsForRecordPageFactory = zohoRecruitGetEmailsForRecordPageFactory;
|
|
995
|
+
/**
|
|
996
|
+
* @deprecated Use zohoRecruitGetAttachmentsForRecord instead.
|
|
997
|
+
*/
|
|
998
|
+
const getAttachmentsForRecord = zohoRecruitGetAttachmentsForRecord;
|
|
999
|
+
/**
|
|
1000
|
+
* @deprecated Use zohoRecruitGetAttachmentsForRecordPageFactory instead.
|
|
1001
|
+
*/
|
|
1002
|
+
const getAttachmentsForRecordPageFactory = zohoRecruitGetAttachmentsForRecordPageFactory;
|
|
1003
|
+
/**
|
|
1004
|
+
* @deprecated Use zohoRecruitUploadAttachmentForRecord instead.
|
|
1005
|
+
*/
|
|
1006
|
+
const uploadAttachmentForRecord = zohoRecruitUploadAttachmentForRecord;
|
|
1007
|
+
/**
|
|
1008
|
+
* @deprecated Use zohoRecruitDownloadAttachmentForRecord instead.
|
|
1009
|
+
*/
|
|
1010
|
+
const downloadAttachmentForRecord = zohoRecruitDownloadAttachmentForRecord;
|
|
1011
|
+
/**
|
|
1012
|
+
* @deprecated Use zohoRecruitDeleteAttachmentFromRecord instead.
|
|
1013
|
+
*/
|
|
1014
|
+
const deleteAttachmentFromRecord = zohoRecruitDeleteAttachmentFromRecord;
|
|
1015
|
+
/**
|
|
1016
|
+
* @deprecated Use zohoRecruitExecuteRestApiFunction instead.
|
|
1017
|
+
*/
|
|
1018
|
+
const executeRestApiFunction = zohoRecruitExecuteRestApiFunction;
|
|
1498
1019
|
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
done = this.done = !!result.done;
|
|
1533
|
-
if (done) return;
|
|
1534
|
-
value = result.value;
|
|
1535
|
-
if (callWithSafeIterationClosing$1(iterator, predicate, [value, this.counter++], true)) return value;
|
|
1536
|
-
}
|
|
1537
|
-
});
|
|
1538
|
-
|
|
1539
|
-
// `Iterator.prototype.filter` method
|
|
1540
|
-
// https://github.com/tc39/proposal-iterator-helpers
|
|
1541
|
-
$$3({ target: 'Iterator', proto: true, real: true, forced: IS_PURE$2 }, {
|
|
1542
|
-
filter: function filter(predicate) {
|
|
1543
|
-
anObject$6(this);
|
|
1544
|
-
aCallable$5(predicate);
|
|
1545
|
-
return new IteratorProxy$2(getIteratorDirect$4(this), {
|
|
1546
|
-
predicate: predicate
|
|
1020
|
+
/**
|
|
1021
|
+
* Associates one or more candidates with one or more job openings.
|
|
1022
|
+
*
|
|
1023
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/associate-candidate.html
|
|
1024
|
+
*
|
|
1025
|
+
* @param context
|
|
1026
|
+
* @returns
|
|
1027
|
+
*/
|
|
1028
|
+
function zohoRecruitAssociateCandidateRecordsWithJobOpenings(context) {
|
|
1029
|
+
return input => context.fetchJson(`/v2/${ZOHO_RECRUIT_CANDIDATES_MODULE}/actions/associate`, zohoRecruitApiFetchJsonInput('PUT', {
|
|
1030
|
+
data: util.asArray(input)
|
|
1031
|
+
})).then(x => {
|
|
1032
|
+
const resultInputMap = x.data.map(() => input); // assign "input" to each value for now
|
|
1033
|
+
const result = zohoRecruitMultiRecordResult(resultInputMap, x.data);
|
|
1034
|
+
const {
|
|
1035
|
+
included: alreadyAssociatedErrorItems,
|
|
1036
|
+
excluded: otherErrorItems
|
|
1037
|
+
} = util.separateValues(result.errorItems, x => {
|
|
1038
|
+
return x.result.code === ZOHO_FAILURE_ERROR_CODE && x.result.details.error[0].code === ZOHO_RECRUIT_ALREADY_ASSOCIATED_ERROR_CODE;
|
|
1039
|
+
});
|
|
1040
|
+
return {
|
|
1041
|
+
...result,
|
|
1042
|
+
errorItems: otherErrorItems,
|
|
1043
|
+
alreadyAssociatedErrorItems,
|
|
1044
|
+
allErrorItems: result.errorItems
|
|
1045
|
+
};
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
1048
|
+
function zohoRecruitSearchAssociatedRecords(context) {
|
|
1049
|
+
return input => {
|
|
1050
|
+
return context.fetchJson(`/v2/${input.module}/${input.id}/associate?${zohoRecruitUrlSearchParamsMinusIdAndModule(input).toString()}`, zohoRecruitApiFetchJsonInput('GET')).then(x => {
|
|
1051
|
+
const result = x ?? emptyZohoPageResult();
|
|
1052
|
+
return result;
|
|
1547
1053
|
});
|
|
1548
|
-
}
|
|
1549
|
-
});
|
|
1550
|
-
|
|
1551
|
-
var classofRaw$1 = classofRaw$2;
|
|
1552
|
-
var uncurryThis$1 = functionUncurryThis;
|
|
1553
|
-
|
|
1554
|
-
var functionUncurryThisClause = function (fn) {
|
|
1555
|
-
// Nashorn bug:
|
|
1556
|
-
// https://github.com/zloirock/core-js/issues/1128
|
|
1557
|
-
// https://github.com/zloirock/core-js/issues/1130
|
|
1558
|
-
if (classofRaw$1(fn) === 'Function') return uncurryThis$1(fn);
|
|
1559
|
-
};
|
|
1560
|
-
|
|
1561
|
-
var uncurryThis = functionUncurryThisClause;
|
|
1562
|
-
var aCallable$4 = aCallable$7;
|
|
1563
|
-
var NATIVE_BIND = functionBindNative;
|
|
1564
|
-
|
|
1565
|
-
var bind$1 = uncurryThis(uncurryThis.bind);
|
|
1566
|
-
|
|
1567
|
-
// optional / simple context binding
|
|
1568
|
-
var functionBindContext = function (fn, that) {
|
|
1569
|
-
aCallable$4(fn);
|
|
1570
|
-
return that === undefined ? fn : NATIVE_BIND ? bind$1(fn, that) : function (/* ...args */) {
|
|
1571
|
-
return fn.apply(that, arguments);
|
|
1572
1054
|
};
|
|
1573
|
-
}
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
var ArrayPrototype = Array.prototype;
|
|
1582
|
-
|
|
1583
|
-
// check on default Array iterator
|
|
1584
|
-
var isArrayIteratorMethod$1 = function (it) {
|
|
1585
|
-
return it !== undefined && (Iterators$1.Array === it || ArrayPrototype[ITERATOR$1] === it);
|
|
1586
|
-
};
|
|
1587
|
-
|
|
1588
|
-
var wellKnownSymbol$2 = wellKnownSymbol$8;
|
|
1589
|
-
|
|
1590
|
-
var TO_STRING_TAG$1 = wellKnownSymbol$2('toStringTag');
|
|
1591
|
-
var test = {};
|
|
1592
|
-
|
|
1593
|
-
test[TO_STRING_TAG$1] = 'z';
|
|
1594
|
-
|
|
1595
|
-
var toStringTagSupport = String(test) === '[object z]';
|
|
1596
|
-
|
|
1597
|
-
var TO_STRING_TAG_SUPPORT = toStringTagSupport;
|
|
1598
|
-
var isCallable = isCallable$e;
|
|
1599
|
-
var classofRaw = classofRaw$2;
|
|
1600
|
-
var wellKnownSymbol$1 = wellKnownSymbol$8;
|
|
1601
|
-
|
|
1602
|
-
var TO_STRING_TAG = wellKnownSymbol$1('toStringTag');
|
|
1603
|
-
var $Object = Object;
|
|
1604
|
-
|
|
1605
|
-
// ES3 wrong here
|
|
1606
|
-
var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) === 'Arguments';
|
|
1607
|
-
|
|
1608
|
-
// fallback for IE11 Script Access Denied error
|
|
1609
|
-
var tryGet = function (it, key) {
|
|
1610
|
-
try {
|
|
1611
|
-
return it[key];
|
|
1612
|
-
} catch (error) { /* empty */ }
|
|
1613
|
-
};
|
|
1614
|
-
|
|
1615
|
-
// getting tag from ES6+ `Object.prototype.toString`
|
|
1616
|
-
var classof$1 = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
|
|
1617
|
-
var O, tag, result;
|
|
1618
|
-
return it === undefined ? 'Undefined' : it === null ? 'Null'
|
|
1619
|
-
// @@toStringTag case
|
|
1620
|
-
: typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag
|
|
1621
|
-
// builtinTag case
|
|
1622
|
-
: CORRECT_ARGUMENTS ? classofRaw(O)
|
|
1623
|
-
// ES3 arguments fallback
|
|
1624
|
-
: (result = classofRaw(O)) === 'Object' && isCallable(O.callee) ? 'Arguments' : result;
|
|
1625
|
-
};
|
|
1626
|
-
|
|
1627
|
-
var classof = classof$1;
|
|
1628
|
-
var getMethod = getMethod$4;
|
|
1629
|
-
var isNullOrUndefined = isNullOrUndefined$3;
|
|
1630
|
-
var Iterators = iterators;
|
|
1631
|
-
var wellKnownSymbol = wellKnownSymbol$8;
|
|
1632
|
-
|
|
1633
|
-
var ITERATOR = wellKnownSymbol('iterator');
|
|
1634
|
-
|
|
1635
|
-
var getIteratorMethod$3 = function (it) {
|
|
1636
|
-
if (!isNullOrUndefined(it)) return getMethod(it, ITERATOR)
|
|
1637
|
-
|| getMethod(it, '@@iterator')
|
|
1638
|
-
|| Iterators[classof(it)];
|
|
1639
|
-
};
|
|
1640
|
-
|
|
1641
|
-
var call$4 = functionCall;
|
|
1642
|
-
var aCallable$3 = aCallable$7;
|
|
1643
|
-
var anObject$5 = anObject$e;
|
|
1644
|
-
var tryToString$1 = tryToString$3;
|
|
1645
|
-
var getIteratorMethod$2 = getIteratorMethod$3;
|
|
1646
|
-
|
|
1647
|
-
var $TypeError$1 = TypeError;
|
|
1648
|
-
|
|
1649
|
-
var getIterator$1 = function (argument, usingIterator) {
|
|
1650
|
-
var iteratorMethod = arguments.length < 2 ? getIteratorMethod$2(argument) : usingIterator;
|
|
1651
|
-
if (aCallable$3(iteratorMethod)) return anObject$5(call$4(iteratorMethod, argument));
|
|
1652
|
-
throw new $TypeError$1(tryToString$1(argument) + ' is not iterable');
|
|
1653
|
-
};
|
|
1654
|
-
|
|
1655
|
-
var bind = functionBindContext;
|
|
1656
|
-
var call$3 = functionCall;
|
|
1657
|
-
var anObject$4 = anObject$e;
|
|
1658
|
-
var tryToString = tryToString$3;
|
|
1659
|
-
var isArrayIteratorMethod = isArrayIteratorMethod$1;
|
|
1660
|
-
var lengthOfArrayLike = lengthOfArrayLike$3;
|
|
1661
|
-
var isPrototypeOf = objectIsPrototypeOf;
|
|
1662
|
-
var getIterator = getIterator$1;
|
|
1663
|
-
var getIteratorMethod$1 = getIteratorMethod$3;
|
|
1664
|
-
var iteratorClose$1 = iteratorClose$4;
|
|
1665
|
-
|
|
1666
|
-
var $TypeError = TypeError;
|
|
1667
|
-
|
|
1668
|
-
var Result = function (stopped, result) {
|
|
1669
|
-
this.stopped = stopped;
|
|
1670
|
-
this.result = result;
|
|
1671
|
-
};
|
|
1672
|
-
|
|
1673
|
-
var ResultPrototype = Result.prototype;
|
|
1674
|
-
|
|
1675
|
-
var iterate$1 = function (iterable, unboundFunction, options) {
|
|
1676
|
-
var that = options && options.that;
|
|
1677
|
-
var AS_ENTRIES = !!(options && options.AS_ENTRIES);
|
|
1678
|
-
var IS_RECORD = !!(options && options.IS_RECORD);
|
|
1679
|
-
var IS_ITERATOR = !!(options && options.IS_ITERATOR);
|
|
1680
|
-
var INTERRUPTED = !!(options && options.INTERRUPTED);
|
|
1681
|
-
var fn = bind(unboundFunction, that);
|
|
1682
|
-
var iterator, iterFn, index, length, result, next, step;
|
|
1683
|
-
|
|
1684
|
-
var stop = function (condition) {
|
|
1685
|
-
if (iterator) iteratorClose$1(iterator, 'normal', condition);
|
|
1686
|
-
return new Result(true, condition);
|
|
1055
|
+
}
|
|
1056
|
+
function zohoRecruitSearchCandidateAssociatedJobOpeningRecords(context) {
|
|
1057
|
+
const searchAssociatedRecordsFactory = zohoRecruitSearchAssociatedRecords(context);
|
|
1058
|
+
return input => {
|
|
1059
|
+
return searchAssociatedRecordsFactory({
|
|
1060
|
+
...input,
|
|
1061
|
+
module: ZOHO_RECRUIT_CANDIDATES_MODULE
|
|
1062
|
+
});
|
|
1687
1063
|
};
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1064
|
+
}
|
|
1065
|
+
function zohoRecruitSearchCandidateAssociatedJobOpeningRecordsPageFactory(context) {
|
|
1066
|
+
return zohoFetchPageFactory(zohoRecruitSearchCandidateAssociatedJobOpeningRecords(context));
|
|
1067
|
+
}
|
|
1068
|
+
function zohoRecruitSearchJobOpeningAssociatedCandidateRecords(context, jobOpeningModuleName = ZOHO_RECRUIT_JOB_OPENINGS_MODULE) {
|
|
1069
|
+
const searchAssociatedRecordsFactory = zohoRecruitSearchAssociatedRecords(context);
|
|
1070
|
+
return input => {
|
|
1071
|
+
return searchAssociatedRecordsFactory({
|
|
1072
|
+
...input,
|
|
1073
|
+
module: jobOpeningModuleName
|
|
1074
|
+
});
|
|
1694
1075
|
};
|
|
1076
|
+
}
|
|
1077
|
+
function zohoRecruitSearchJobOpeningAssociatedCandidateRecordsPageFactory(context) {
|
|
1078
|
+
return zohoFetchPageFactory(zohoRecruitSearchJobOpeningAssociatedCandidateRecords(context));
|
|
1079
|
+
}
|
|
1695
1080
|
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
}
|
|
1710
|
-
iterator = getIterator(iterable, iterFn);
|
|
1711
|
-
}
|
|
1712
|
-
|
|
1713
|
-
next = IS_RECORD ? iterable.next : iterator.next;
|
|
1714
|
-
while (!(step = call$3(next, iterator)).done) {
|
|
1715
|
-
try {
|
|
1716
|
-
result = callFn(step.value);
|
|
1717
|
-
} catch (error) {
|
|
1718
|
-
iteratorClose$1(iterator, 'throw', error);
|
|
1719
|
-
}
|
|
1720
|
-
if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result;
|
|
1721
|
-
} return new Result(false);
|
|
1722
|
-
};
|
|
1723
|
-
|
|
1724
|
-
var $$2 = _export;
|
|
1725
|
-
var iterate = iterate$1;
|
|
1726
|
-
var aCallable$2 = aCallable$7;
|
|
1727
|
-
var anObject$3 = anObject$e;
|
|
1728
|
-
var getIteratorDirect$3 = getIteratorDirect$5;
|
|
1729
|
-
|
|
1730
|
-
// `Iterator.prototype.forEach` method
|
|
1731
|
-
// https://github.com/tc39/proposal-iterator-helpers
|
|
1732
|
-
$$2({ target: 'Iterator', proto: true, real: true }, {
|
|
1733
|
-
forEach: function forEach(fn) {
|
|
1734
|
-
anObject$3(this);
|
|
1735
|
-
aCallable$2(fn);
|
|
1736
|
-
var record = getIteratorDirect$3(this);
|
|
1737
|
-
var counter = 0;
|
|
1738
|
-
iterate(record, function (value) {
|
|
1739
|
-
fn(value, counter++);
|
|
1740
|
-
}, { IS_RECORD: true });
|
|
1741
|
-
}
|
|
1742
|
-
});
|
|
1743
|
-
|
|
1744
|
-
/**
|
|
1745
|
-
* Returns an empty ZohoPageResult that is typed to R and has no more records/results.
|
|
1746
|
-
*/
|
|
1747
|
-
function emptyZohoPageResult() {
|
|
1748
|
-
return {
|
|
1749
|
-
data: [],
|
|
1750
|
-
info: {
|
|
1751
|
-
page: 1,
|
|
1752
|
-
per_page: 100,
|
|
1753
|
-
// default value
|
|
1754
|
-
count: 0,
|
|
1755
|
-
more_records: false
|
|
1756
|
-
}
|
|
1757
|
-
};
|
|
1081
|
+
function zohoRecruitCreateNotes(context) {
|
|
1082
|
+
return input => context.fetchJson(`/v2/${ZOHO_RECRUIT_NOTES_MODULE}`, zohoRecruitApiFetchJsonInput('POST', {
|
|
1083
|
+
data: input.data
|
|
1084
|
+
})).then(x => {
|
|
1085
|
+
return zohoRecruitMultiRecordResult(util.asArray(input.data), x.data);
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
function zohoRecruitDeleteNotes(context) {
|
|
1089
|
+
return input => context.fetchJson(`/v2/${ZOHO_RECRUIT_NOTES_MODULE}?${fetch.makeUrlSearchParams({
|
|
1090
|
+
ids: input.ids
|
|
1091
|
+
})}`, zohoRecruitApiFetchJsonInput('DELETE')).then(x => {
|
|
1092
|
+
return zohoRecruitMultiRecordResult(util.asArray(input.ids), x.data);
|
|
1093
|
+
});
|
|
1758
1094
|
}
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
* @param fetch
|
|
1763
|
-
* @param defaults
|
|
1764
|
-
* @returns
|
|
1765
|
-
*/
|
|
1766
|
-
function zohoFetchPageFactory(fetch$1, defaults) {
|
|
1767
|
-
return fetch.fetchPageFactory({
|
|
1768
|
-
...defaults,
|
|
1769
|
-
fetch: fetch$1,
|
|
1770
|
-
readFetchPageResultInfo: function (result) {
|
|
1771
|
-
return {
|
|
1772
|
-
hasNext: result.info?.more_records ?? false // if no info is returned, assume something wrong and there are no more records
|
|
1773
|
-
};
|
|
1774
|
-
},
|
|
1775
|
-
buildInputForNextPage: function (pageResult, input, options) {
|
|
1776
|
-
return {
|
|
1777
|
-
...input,
|
|
1778
|
-
page: util.getNextPageNumber(pageResult),
|
|
1779
|
-
per_page: options.maxItemsPerPage ?? input.per_page
|
|
1780
|
-
};
|
|
1781
|
-
}
|
|
1095
|
+
function zohoRecruitGetNotesForRecord(context) {
|
|
1096
|
+
return zohoRecruitGetRelatedRecordsFunctionFactory(context)({
|
|
1097
|
+
targetModule: ZOHO_RECRUIT_NOTES_MODULE
|
|
1782
1098
|
});
|
|
1783
1099
|
}
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
function zohoRecruitConfigApiUrl(input) {
|
|
1787
|
-
switch (input) {
|
|
1788
|
-
case 'sandbox':
|
|
1789
|
-
return 'https://recruitsandbox.zoho.com/recruit';
|
|
1790
|
-
case 'production':
|
|
1791
|
-
return 'https://recruit.zoho.com/recruit';
|
|
1792
|
-
default:
|
|
1793
|
-
return input;
|
|
1794
|
-
}
|
|
1100
|
+
function zohoRecruitGetNotesForRecordPageFactory(context) {
|
|
1101
|
+
return zohoFetchPageFactory(zohoRecruitGetNotesForRecord(context));
|
|
1795
1102
|
}
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1103
|
+
function zohoRecruitCreateNotesForRecord(context) {
|
|
1104
|
+
const createNotesInstance = zohoRecruitCreateNotes(context);
|
|
1105
|
+
return input => {
|
|
1106
|
+
const {
|
|
1107
|
+
module: se_module,
|
|
1108
|
+
id: Parent_Id,
|
|
1109
|
+
notes
|
|
1110
|
+
} = input;
|
|
1111
|
+
const createNotesRequest = {
|
|
1112
|
+
data: util.asArray(notes).map(x => ({
|
|
1113
|
+
...x,
|
|
1114
|
+
se_module,
|
|
1115
|
+
Parent_Id
|
|
1116
|
+
}))
|
|
1117
|
+
};
|
|
1118
|
+
return createNotesInstance(createNotesRequest);
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
// MARK: Compat
|
|
1801
1122
|
/**
|
|
1802
|
-
*
|
|
1123
|
+
* @deprecated Use zohoRecruitCreateNotes instead.
|
|
1803
1124
|
*/
|
|
1804
|
-
const
|
|
1125
|
+
const createNotes = zohoRecruitCreateNotes;
|
|
1805
1126
|
/**
|
|
1806
|
-
*
|
|
1127
|
+
* @deprecated Use zohoRecruitDeleteNotes instead.
|
|
1807
1128
|
*/
|
|
1808
|
-
const
|
|
1129
|
+
const deleteNotes = zohoRecruitDeleteNotes;
|
|
1809
1130
|
/**
|
|
1810
|
-
*
|
|
1131
|
+
* @deprecated Use zohoRecruitGetNotesForRecord instead.
|
|
1811
1132
|
*/
|
|
1812
|
-
const
|
|
1133
|
+
const getNotesForRecord = zohoRecruitGetNotesForRecord;
|
|
1813
1134
|
/**
|
|
1814
|
-
*
|
|
1135
|
+
* @deprecated Use zohoRecruitGetNotesForRecordPageFactory instead.
|
|
1815
1136
|
*/
|
|
1816
|
-
const
|
|
1137
|
+
const getNotesForRecordPageFactory = zohoRecruitGetNotesForRecordPageFactory;
|
|
1817
1138
|
/**
|
|
1818
|
-
*
|
|
1139
|
+
* @deprecated Use zohoRecruitCreateNotesForRecord instead.
|
|
1819
1140
|
*/
|
|
1820
|
-
const
|
|
1821
|
-
const ZOHO_RECRUIT_RECORD_ATTACHMENT_METADATA_ATTACH_TYPE_RESUME = 'Resume';
|
|
1822
|
-
|
|
1823
|
-
var call$2 = functionCall;
|
|
1824
|
-
var anObject$2 = anObject$e;
|
|
1825
|
-
var getIteratorDirect$2 = getIteratorDirect$5;
|
|
1826
|
-
var getIteratorMethod = getIteratorMethod$3;
|
|
1827
|
-
|
|
1828
|
-
var getIteratorFlattenable$1 = function (obj, stringHandling) {
|
|
1829
|
-
if (!stringHandling || typeof obj !== 'string') anObject$2(obj);
|
|
1830
|
-
var method = getIteratorMethod(obj);
|
|
1831
|
-
return getIteratorDirect$2(anObject$2(method !== undefined ? call$2(method, obj) : obj));
|
|
1832
|
-
};
|
|
1833
|
-
|
|
1834
|
-
var $$1 = _export;
|
|
1835
|
-
var call$1 = functionCall;
|
|
1836
|
-
var aCallable$1 = aCallable$7;
|
|
1837
|
-
var anObject$1 = anObject$e;
|
|
1838
|
-
var getIteratorDirect$1 = getIteratorDirect$5;
|
|
1839
|
-
var getIteratorFlattenable = getIteratorFlattenable$1;
|
|
1840
|
-
var createIteratorProxy$1 = iteratorCreateProxy;
|
|
1841
|
-
var iteratorClose = iteratorClose$4;
|
|
1842
|
-
var IS_PURE$1 = isPure;
|
|
1843
|
-
|
|
1844
|
-
var IteratorProxy$1 = createIteratorProxy$1(function () {
|
|
1845
|
-
var iterator = this.iterator;
|
|
1846
|
-
var mapper = this.mapper;
|
|
1847
|
-
var result, inner;
|
|
1141
|
+
const createNotesForRecord = zohoRecruitCreateNotesForRecord;
|
|
1848
1142
|
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
this.inner = getIteratorFlattenable(mapper(result.value, this.counter++), false);
|
|
1862
|
-
} catch (error) { iteratorClose(iterator, 'throw', error); }
|
|
1863
|
-
}
|
|
1864
|
-
});
|
|
1865
|
-
|
|
1866
|
-
// `Iterator.prototype.flatMap` method
|
|
1867
|
-
// https://github.com/tc39/proposal-iterator-helpers
|
|
1868
|
-
$$1({ target: 'Iterator', proto: true, real: true, forced: IS_PURE$1 }, {
|
|
1869
|
-
flatMap: function flatMap(mapper) {
|
|
1870
|
-
anObject$1(this);
|
|
1871
|
-
aCallable$1(mapper);
|
|
1872
|
-
return new IteratorProxy$1(getIteratorDirect$1(this), {
|
|
1873
|
-
mapper: mapper,
|
|
1874
|
-
inner: null
|
|
1143
|
+
function zohoRecruitCreateTagsForModule(context) {
|
|
1144
|
+
return input => context.fetchJson(`/v2/settings/tags?${fetch.makeUrlSearchParams({
|
|
1145
|
+
module: input.module
|
|
1146
|
+
})}`, zohoRecruitApiFetchJsonInput('POST', {
|
|
1147
|
+
tags: util.asArray(input.tags)
|
|
1148
|
+
})).then(x => {
|
|
1149
|
+
const result = zohoRecruitMultiRecordResult(util.asArray(input.tags), x.tags);
|
|
1150
|
+
const {
|
|
1151
|
+
included: duplicateErrorItems,
|
|
1152
|
+
excluded: otherErrorItems
|
|
1153
|
+
} = util.separateValues(result.errorItems, x => {
|
|
1154
|
+
return x.result.code === ZOHO_DUPLICATE_DATA_ERROR_CODE;
|
|
1875
1155
|
});
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
var getIteratorDirect = getIteratorDirect$5;
|
|
1883
|
-
var createIteratorProxy = iteratorCreateProxy;
|
|
1884
|
-
var callWithSafeIterationClosing = callWithSafeIterationClosing$2;
|
|
1885
|
-
|
|
1886
|
-
var IteratorProxy = createIteratorProxy(function () {
|
|
1887
|
-
var iterator = this.iterator;
|
|
1888
|
-
var result = anObject(call(this.next, iterator));
|
|
1889
|
-
var done = this.done = !!result.done;
|
|
1890
|
-
if (!done) return callWithSafeIterationClosing(iterator, this.mapper, [result.value, this.counter++], true);
|
|
1891
|
-
});
|
|
1892
|
-
|
|
1893
|
-
// `Iterator.prototype.map` method
|
|
1894
|
-
// https://github.com/tc39/proposal-iterator-helpers
|
|
1895
|
-
var iteratorMap = function map(mapper) {
|
|
1896
|
-
anObject(this);
|
|
1897
|
-
aCallable(mapper);
|
|
1898
|
-
return new IteratorProxy(getIteratorDirect(this), {
|
|
1899
|
-
mapper: mapper
|
|
1156
|
+
return {
|
|
1157
|
+
...result,
|
|
1158
|
+
errorItems: otherErrorItems,
|
|
1159
|
+
duplicateErrorItems,
|
|
1160
|
+
allErrorItems: result.errorItems
|
|
1161
|
+
};
|
|
1900
1162
|
});
|
|
1901
|
-
};
|
|
1902
|
-
|
|
1903
|
-
var $ = _export;
|
|
1904
|
-
var map = iteratorMap;
|
|
1905
|
-
var IS_PURE = isPure;
|
|
1906
|
-
|
|
1907
|
-
// `Iterator.prototype.map` method
|
|
1908
|
-
// https://github.com/tc39/proposal-iterator-helpers
|
|
1909
|
-
$({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
|
|
1910
|
-
map: map
|
|
1911
|
-
});
|
|
1912
|
-
|
|
1913
|
-
/**
|
|
1914
|
-
* Can search up to 10 criteria at a time.
|
|
1915
|
-
*
|
|
1916
|
-
* https://www.zoho.com/recruit/developer-guide/apiv2/search-records.html
|
|
1917
|
-
*
|
|
1918
|
-
* "You can search for a maximum of 10 criteria (with the same or different column) with equals and starts_with conditions."
|
|
1919
|
-
*/
|
|
1920
|
-
const MAX_ZOHO_RECRUIT_SEARCH_MODULE_RECORDS_CRITERIA = 10;
|
|
1921
|
-
/**
|
|
1922
|
-
* Creates a ZohoRecruitSearchRecordsCriteriaString from a ZohoRecruitSearchRecordsCriteriaTree.
|
|
1923
|
-
*
|
|
1924
|
-
* If the input tree is empty, returns undefined.
|
|
1925
|
-
*/
|
|
1926
|
-
function zohoRecruitSearchRecordsCriteriaString(input) {
|
|
1927
|
-
let result;
|
|
1928
|
-
if (input != null) {
|
|
1929
|
-
switch (typeof input) {
|
|
1930
|
-
case 'string':
|
|
1931
|
-
result = input;
|
|
1932
|
-
break;
|
|
1933
|
-
case 'object':
|
|
1934
|
-
let tree;
|
|
1935
|
-
if (Array.isArray(input)) {
|
|
1936
|
-
tree = {
|
|
1937
|
-
and: [input]
|
|
1938
|
-
};
|
|
1939
|
-
} else {
|
|
1940
|
-
tree = input;
|
|
1941
|
-
}
|
|
1942
|
-
result = zohoRecruitSearchRecordsCriteriaStringForTree(tree);
|
|
1943
|
-
break;
|
|
1944
|
-
}
|
|
1945
|
-
}
|
|
1946
|
-
return result;
|
|
1947
|
-
}
|
|
1948
|
-
function zohoRecruitSearchRecordsCriteriaStringForTree(tree) {
|
|
1949
|
-
function convertToString(value) {
|
|
1950
|
-
let result;
|
|
1951
|
-
if (typeof value === 'object') {
|
|
1952
|
-
// array of criteria entries
|
|
1953
|
-
if (Array.isArray(value)) {
|
|
1954
|
-
result = value.map(zohoRecruitSearchRecordsCriteriaEntryToCriteriaString);
|
|
1955
|
-
} else if (value) {
|
|
1956
|
-
// criteria tree that first needs to be converted to a string
|
|
1957
|
-
result = zohoRecruitSearchRecordsCriteriaStringForTree(value);
|
|
1958
|
-
}
|
|
1959
|
-
} else {
|
|
1960
|
-
result = value;
|
|
1961
|
-
}
|
|
1962
|
-
return result;
|
|
1963
|
-
}
|
|
1964
|
-
function mergeStringValues(values, type) {
|
|
1965
|
-
return values.length > 1 ? `(${values.join(type)})` : values[0]; // wrap in and values
|
|
1966
|
-
}
|
|
1967
|
-
function mergeValues(values, type) {
|
|
1968
|
-
const allStrings = util.filterMaybeArrayValues(values.map(convertToString)).flatMap(util.asArray);
|
|
1969
|
-
return mergeStringValues(allStrings, type);
|
|
1970
|
-
}
|
|
1971
|
-
const orValues = tree.or ? mergeValues(tree.or, 'or') : undefined;
|
|
1972
|
-
let result = orValues;
|
|
1973
|
-
if (tree.and) {
|
|
1974
|
-
result = mergeValues([mergeValues(tree.and, 'and'), orValues], 'and');
|
|
1975
|
-
}
|
|
1976
|
-
return result;
|
|
1977
1163
|
}
|
|
1978
1164
|
/**
|
|
1979
|
-
*
|
|
1980
|
-
*/
|
|
1981
|
-
const escapeZohoFieldValueForCriteriaString = util.escapeStringCharactersFunction({
|
|
1982
|
-
/**
|
|
1983
|
-
* Parenthesis and commas must be escaped using a backslash
|
|
1984
|
-
*/
|
|
1985
|
-
escapeTargets: ['(', ')', ','],
|
|
1986
|
-
escapeCharacter: char => `\\${char}`
|
|
1987
|
-
});
|
|
1988
|
-
/**
|
|
1989
|
-
* Converts the input entry to a ZohoRecruitSearchRecordsCriteriaString. Properly escapes any parenthesis or commas.
|
|
1165
|
+
* Returns the list of tags within a module.
|
|
1990
1166
|
*
|
|
1991
|
-
*
|
|
1167
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/get-tag-list.html
|
|
1168
|
+
*
|
|
1169
|
+
* @param context
|
|
1992
1170
|
* @returns
|
|
1993
1171
|
*/
|
|
1994
|
-
function
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
/**
|
|
2004
|
-
* Lowercase status code
|
|
2005
|
-
*/
|
|
2006
|
-
const ZOHO_SUCCESS_STATUS = 'success';
|
|
2007
|
-
/**
|
|
2008
|
-
* Set in the status field
|
|
2009
|
-
*/
|
|
2010
|
-
const ZOHO_ERROR_STATUS = 'error';
|
|
2011
|
-
function zohoServerErrorData(error) {
|
|
2012
|
-
const errorType = typeof error;
|
|
2013
|
-
let errorData;
|
|
2014
|
-
if (errorType === 'object') {
|
|
2015
|
-
errorData = error;
|
|
2016
|
-
} else {
|
|
2017
|
-
errorData = {
|
|
2018
|
-
code: error,
|
|
2019
|
-
message: ''
|
|
1172
|
+
function zohoRecruitGetTagsForModule(context) {
|
|
1173
|
+
return input => context.fetchJson(`/v2/settings/tags?${fetch.makeUrlSearchParams({
|
|
1174
|
+
module: input.module,
|
|
1175
|
+
my_tags: input.my_tags
|
|
1176
|
+
})}`, zohoRecruitApiFetchJsonInput('GET')).then(x => {
|
|
1177
|
+
// NOTE: This doesn't follow the api documentation, and instead is a normal page result except it has "tags" instead of "data".
|
|
1178
|
+
return {
|
|
1179
|
+
...x,
|
|
1180
|
+
data: x.tags
|
|
2020
1181
|
};
|
|
2021
|
-
}
|
|
2022
|
-
return errorData;
|
|
1182
|
+
});
|
|
2023
1183
|
}
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
*/
|
|
2027
|
-
class ZohoServerError extends makeError.BaseError {
|
|
2028
|
-
get code() {
|
|
2029
|
-
return this.error.code;
|
|
2030
|
-
}
|
|
2031
|
-
constructor(error) {
|
|
2032
|
-
super(error.message);
|
|
2033
|
-
this.error = void 0;
|
|
2034
|
-
this.error = error;
|
|
2035
|
-
}
|
|
1184
|
+
function zohoRecruitGetTagsForModulePageFactory(context) {
|
|
1185
|
+
return zohoFetchPageFactory(zohoRecruitGetTagsForModule(context));
|
|
2036
1186
|
}
|
|
1187
|
+
// MARK: Add Tag To Record
|
|
2037
1188
|
/**
|
|
2038
|
-
*
|
|
1189
|
+
* Limit enforced by Zoho Recruit
|
|
2039
1190
|
*/
|
|
2040
|
-
|
|
2041
|
-
constructor(data, responseError) {
|
|
2042
|
-
super(data);
|
|
2043
|
-
this.data = void 0;
|
|
2044
|
-
this.responseError = void 0;
|
|
2045
|
-
this.data = data;
|
|
2046
|
-
this.responseError = responseError;
|
|
2047
|
-
}
|
|
2048
|
-
}
|
|
1191
|
+
const ZOHO_RECRUIT_ADD_TAGS_TO_RECORDS_MAX_IDS_ALLOWED = 100;
|
|
2049
1192
|
/**
|
|
2050
|
-
*
|
|
1193
|
+
* Adds one or more tags to one or more records.
|
|
2051
1194
|
*
|
|
2052
|
-
*
|
|
2053
|
-
*
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
});
|
|
2062
|
-
} else if (error instanceof ZohoServerError) {
|
|
2063
|
-
console.log(`${zohoApiNamePrefix}Error(code:${error.code}): `, {
|
|
2064
|
-
error
|
|
2065
|
-
});
|
|
2066
|
-
} else {
|
|
2067
|
-
console.log(`${zohoApiNamePrefix}Error(name:${error.name}): `, {
|
|
2068
|
-
error
|
|
2069
|
-
});
|
|
1195
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/add-tags.html
|
|
1196
|
+
*
|
|
1197
|
+
* @param context
|
|
1198
|
+
* @returns
|
|
1199
|
+
*/
|
|
1200
|
+
function zohoRecruitAddTagsToRecords(context) {
|
|
1201
|
+
return input => {
|
|
1202
|
+
if (Array.isArray(input.ids) && input.ids.length > ZOHO_RECRUIT_ADD_TAGS_TO_RECORDS_MAX_IDS_ALLOWED) {
|
|
1203
|
+
throw new Error(`Cannot add tags to more than ${ZOHO_RECRUIT_ADD_TAGS_TO_RECORDS_MAX_IDS_ALLOWED} records at once.`);
|
|
2070
1204
|
}
|
|
1205
|
+
return context.fetchJson(`/v2/${ZOHO_RECRUIT_CANDIDATES_MODULE}/actions/add_tags?${fetch.makeUrlSearchParams({
|
|
1206
|
+
tag_names: input.tag_names,
|
|
1207
|
+
ids: input.ids
|
|
1208
|
+
})}`, zohoRecruitApiFetchJsonInput('POST')).then(x => {
|
|
1209
|
+
const resultInputMap = x.data.map(() => input); // assign "input" to each value for now
|
|
1210
|
+
return zohoRecruitMultiRecordResult(resultInputMap, x.data);
|
|
1211
|
+
});
|
|
2071
1212
|
};
|
|
2072
1213
|
}
|
|
1214
|
+
// MARK: Remove Tag From Record
|
|
2073
1215
|
/**
|
|
2074
|
-
*
|
|
1216
|
+
* Limit enforced by Zoho Recruit
|
|
1217
|
+
*/
|
|
1218
|
+
const ZOHO_RECRUIT_REMOVE_TAGS_FROM_RECORDS_MAX_IDS_ALLOWED = 100;
|
|
1219
|
+
/**
|
|
1220
|
+
* Removes one or more tags from one or more records.
|
|
2075
1221
|
*
|
|
2076
|
-
*
|
|
1222
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/remove-tags.html
|
|
1223
|
+
*
|
|
1224
|
+
* @param context
|
|
2077
1225
|
* @returns
|
|
2078
1226
|
*/
|
|
2079
|
-
function
|
|
2080
|
-
return
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
}
|
|
2092
|
-
}
|
|
2093
|
-
throw e;
|
|
2094
|
-
}
|
|
2095
|
-
};
|
|
1227
|
+
function zohoRecruitRemoveTagsFromRecords(context) {
|
|
1228
|
+
return input => {
|
|
1229
|
+
if (Array.isArray(input.ids) && input.ids.length > ZOHO_RECRUIT_REMOVE_TAGS_FROM_RECORDS_MAX_IDS_ALLOWED) {
|
|
1230
|
+
throw new Error(`Cannot remove tags from more than ${ZOHO_RECRUIT_REMOVE_TAGS_FROM_RECORDS_MAX_IDS_ALLOWED} records at once.`);
|
|
1231
|
+
}
|
|
1232
|
+
return context.fetchJson(`/v2/${ZOHO_RECRUIT_CANDIDATES_MODULE}/actions/remove_tags?${fetch.makeUrlSearchParams({
|
|
1233
|
+
tag_names: input.tag_names,
|
|
1234
|
+
ids: input.ids
|
|
1235
|
+
})}`, zohoRecruitApiFetchJsonInput('POST')).then(x => {
|
|
1236
|
+
const resultInputMap = x.data.map(() => input); // assign "input" to each value for now
|
|
1237
|
+
return zohoRecruitMultiRecordResult(resultInputMap, x.data);
|
|
1238
|
+
});
|
|
2096
1239
|
};
|
|
2097
1240
|
}
|
|
1241
|
+
// MARK: Compat
|
|
2098
1242
|
/**
|
|
2099
|
-
*
|
|
1243
|
+
* @deprecated Use zohoRecruitCreateTagsForModule instead.
|
|
2100
1244
|
*/
|
|
2101
|
-
|
|
2102
|
-
return (json, response) => {
|
|
2103
|
-
const error = json?.error;
|
|
2104
|
-
if (error != null) {
|
|
2105
|
-
const responseError = new fetch.FetchResponseError(response);
|
|
2106
|
-
if (responseError) {
|
|
2107
|
-
const parsedError = parseZohoServerErrorResponseData(json, responseError);
|
|
2108
|
-
if (parsedError) {
|
|
2109
|
-
throw parsedError;
|
|
2110
|
-
}
|
|
2111
|
-
}
|
|
2112
|
-
}
|
|
2113
|
-
return json;
|
|
2114
|
-
};
|
|
2115
|
-
}
|
|
2116
|
-
// MARK: Parsed Errors
|
|
1245
|
+
const createTagsForModule = zohoRecruitCreateTagsForModule;
|
|
2117
1246
|
/**
|
|
2118
|
-
*
|
|
2119
|
-
* - An extra parameter is provided
|
|
1247
|
+
* @deprecated Use zohoRecruitGetTagsForModule instead.
|
|
2120
1248
|
*/
|
|
2121
|
-
const
|
|
1249
|
+
const getTagsForModule = zohoRecruitGetTagsForModule;
|
|
2122
1250
|
/**
|
|
2123
|
-
*
|
|
1251
|
+
* @deprecated Use zohoRecruitGetTagsForModulePageFactory instead.
|
|
2124
1252
|
*/
|
|
2125
|
-
const
|
|
2126
|
-
class ZohoInvalidTokenError extends ZohoServerFetchResponseError {}
|
|
1253
|
+
const getTagsForModulePageFactory = zohoRecruitGetTagsForModulePageFactory;
|
|
2127
1254
|
/**
|
|
2128
|
-
*
|
|
1255
|
+
* @deprecated Use zohoRecruitAddTagsToRecords instead.
|
|
2129
1256
|
*/
|
|
2130
|
-
const
|
|
1257
|
+
const addTagsToRecords = zohoRecruitAddTagsToRecords;
|
|
2131
1258
|
/**
|
|
2132
|
-
*
|
|
1259
|
+
* @deprecated Use zohoRecruitRemoveTagsFromRecords instead.
|
|
2133
1260
|
*/
|
|
2134
|
-
|
|
1261
|
+
const removeTagsFromRecords = zohoRecruitRemoveTagsFromRecords;
|
|
1262
|
+
|
|
2135
1263
|
/**
|
|
2136
1264
|
* Error in the following cases:
|
|
2137
|
-
* -
|
|
2138
|
-
* - OAuth token is expired ("Invalid OAuthtoken")
|
|
1265
|
+
* - the refresh token string is invalid
|
|
2139
1266
|
*/
|
|
2140
|
-
const
|
|
1267
|
+
const ZOHO_ACCOUNTS_INVALID_CODE_ERROR_CODE = 'invalid_code';
|
|
1268
|
+
const ZOHO_ACCOUNTS_INVALID_CLIENT_ERROR_CODE = 'invalid_client';
|
|
2141
1269
|
/**
|
|
2142
|
-
*
|
|
1270
|
+
* Thrown if the call to the Zoho API creating an access token using a refresh token fails.
|
|
2143
1271
|
*/
|
|
2144
|
-
class
|
|
1272
|
+
class ZohoAccountsAccessTokenError extends fetch.FetchRequestFactoryError {
|
|
1273
|
+
constructor(errorCode) {
|
|
1274
|
+
super(`ZohoAccountsAccessTokenError: ${errorCode}`);
|
|
1275
|
+
this.errorCode = void 0;
|
|
1276
|
+
this.errorCode = errorCode;
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
/**
|
|
1280
|
+
* Thrown if a valid ZohoAccessToken cannot be retrieved successfully.
|
|
1281
|
+
*/
|
|
1282
|
+
class ZohoAccountsAuthFailureError extends fetch.FetchRequestFactoryError {
|
|
1283
|
+
constructor(reason) {
|
|
1284
|
+
super(`Failed to retrieve proper authentication for the API call. Reason: ${reason}`);
|
|
1285
|
+
this.reason = void 0;
|
|
1286
|
+
this.reason = reason;
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
const logZohoAccountsErrorToConsole = logZohoServerErrorFunction('ZohoAccounts');
|
|
1290
|
+
async function parseZohoAccountsError(responseError) {
|
|
1291
|
+
const data = await responseError.response.json().catch(x => undefined);
|
|
1292
|
+
let result;
|
|
1293
|
+
if (data) {
|
|
1294
|
+
result = parseZohoAccountsServerErrorResponseData(data, responseError);
|
|
1295
|
+
}
|
|
1296
|
+
return result;
|
|
1297
|
+
}
|
|
1298
|
+
function parseZohoAccountsServerErrorResponseData(errorResponseData, responseError) {
|
|
1299
|
+
let result;
|
|
1300
|
+
const error = errorResponseData.error;
|
|
1301
|
+
if (error) {
|
|
1302
|
+
const errorData = zohoServerErrorData(error);
|
|
1303
|
+
switch (errorData.code) {
|
|
1304
|
+
case ZOHO_ACCOUNTS_INVALID_CODE_ERROR_CODE:
|
|
1305
|
+
case ZOHO_ACCOUNTS_INVALID_CLIENT_ERROR_CODE:
|
|
1306
|
+
result = new ZohoAccountsAccessTokenError(errorData.code);
|
|
1307
|
+
break;
|
|
1308
|
+
default:
|
|
1309
|
+
result = parseZohoServerErrorResponseData(errorResponseData, responseError);
|
|
1310
|
+
break;
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
return result;
|
|
1314
|
+
}
|
|
1315
|
+
const interceptZohoAccounts200StatusWithErrorResponse = interceptZohoErrorResponseFactory(parseZohoAccountsServerErrorResponseData);
|
|
1316
|
+
const handleZohoAccountsErrorFetch = handleZohoErrorFetchFactory(parseZohoAccountsError, logZohoAccountsErrorToConsole);
|
|
1317
|
+
|
|
1318
|
+
/**
|
|
1319
|
+
* Generates a new ZohoAccessTokenStringFactory.
|
|
1320
|
+
*/
|
|
1321
|
+
function zohoAccessTokenStringFactory(zohoAccessTokenFactory) {
|
|
1322
|
+
return async () => {
|
|
1323
|
+
const token = await zohoAccessTokenFactory();
|
|
1324
|
+
if (!token?.accessToken) {
|
|
1325
|
+
throw new ZohoAccountsAuthFailureError();
|
|
1326
|
+
}
|
|
1327
|
+
return token.accessToken;
|
|
1328
|
+
};
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
const DEFAULT_ZOHO_RATE_LIMITED_TOO_MANY_REQUETS_LOG_FUNCTION = headers => {
|
|
1332
|
+
console.warn(`zohoRateLimitedFetchHandler(): Too many requests made. The limit is ${headers.limit} requests per reset period. Will be reset at ${headers.resetAt}.`);
|
|
1333
|
+
};
|
|
1334
|
+
function zohoRateLimitedFetchHandler(config) {
|
|
1335
|
+
const onTooManyRequests = config?.onTooManyRequests !== false ? config?.onTooManyRequests ?? DEFAULT_ZOHO_RATE_LIMITED_TOO_MANY_REQUETS_LOG_FUNCTION : undefined;
|
|
1336
|
+
const defaultLimit = config?.maxRateLimit ?? DEFAULT_ZOHO_API_RATE_LIMIT;
|
|
1337
|
+
const defaultResetPeriod = config?.resetPeriod ?? DEFAULT_ZOHO_API_RATE_LIMIT_RESET_PERIOD;
|
|
1338
|
+
function configForLimit(limit, resetAt) {
|
|
1339
|
+
return {
|
|
1340
|
+
limit: defaultLimit,
|
|
1341
|
+
startLimitAt: Math.ceil(limit / 10),
|
|
1342
|
+
// can do 10% of the requests of the limit before rate limiting begins
|
|
1343
|
+
cooldownRate: 1.2 * (limit / (defaultResetPeriod / util.MS_IN_SECOND)),
|
|
1344
|
+
exponentRate: 1.08,
|
|
1345
|
+
maxWaitTime: util.MS_IN_SECOND * 10,
|
|
1346
|
+
resetPeriod: defaultResetPeriod,
|
|
1347
|
+
resetAt
|
|
1348
|
+
};
|
|
1349
|
+
}
|
|
1350
|
+
const defaultConfig = configForLimit(defaultLimit);
|
|
1351
|
+
const rateLimiter = util.resetPeriodPromiseRateLimiter(defaultConfig);
|
|
1352
|
+
return fetch.rateLimitedFetchHandler({
|
|
1353
|
+
rateLimiter,
|
|
1354
|
+
updateWithResponse: function (response, fetchResponseError) {
|
|
1355
|
+
const hasLimitHeader = response.headers.has(ZOHO_RATE_LIMIT_REMAINING_HEADER);
|
|
1356
|
+
let shouldRetry = false;
|
|
1357
|
+
let enabled = false;
|
|
1358
|
+
if (hasLimitHeader) {
|
|
1359
|
+
const headerDetails = zohoRateLimitHeaderDetails(response.headers);
|
|
1360
|
+
if (headerDetails) {
|
|
1361
|
+
const {
|
|
1362
|
+
limit,
|
|
1363
|
+
resetAt,
|
|
1364
|
+
remaining
|
|
1365
|
+
} = headerDetails;
|
|
1366
|
+
if (limit !== defaultLimit) {
|
|
1367
|
+
const newConfig = configForLimit(limit, resetAt);
|
|
1368
|
+
rateLimiter.setConfig(newConfig, false);
|
|
1369
|
+
}
|
|
1370
|
+
rateLimiter.setRemainingLimit(remaining);
|
|
1371
|
+
rateLimiter.setNextResetAt(resetAt);
|
|
1372
|
+
enabled = true;
|
|
1373
|
+
// only retry if it's a TOO MANY REQUESTS error
|
|
1374
|
+
if (response.status === ZOHO_TOO_MANY_REQUESTS_HTTP_STATUS_CODE) {
|
|
1375
|
+
shouldRetry = true;
|
|
1376
|
+
try {
|
|
1377
|
+
onTooManyRequests?.(headerDetails, response, fetchResponseError);
|
|
1378
|
+
} catch (e) {}
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
rateLimiter.setEnabled(enabled);
|
|
1383
|
+
return shouldRetry;
|
|
1384
|
+
}
|
|
1385
|
+
});
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
function zohoRecruitFactory(factoryConfig) {
|
|
1389
|
+
const {
|
|
1390
|
+
accountsContext
|
|
1391
|
+
} = factoryConfig;
|
|
1392
|
+
const accessTokenStringFactory = zohoAccessTokenStringFactory(accountsContext.loadAccessToken);
|
|
1393
|
+
const fetchHandler = zohoRateLimitedFetchHandler(factoryConfig.rateLimiterConfig);
|
|
1394
|
+
const {
|
|
1395
|
+
logZohoServerErrorFunction,
|
|
1396
|
+
fetchFactory = input => fetch.fetchApiFetchService.makeFetch({
|
|
1397
|
+
baseUrl: input.apiUrl,
|
|
1398
|
+
baseRequest: async () => ({
|
|
1399
|
+
headers: {
|
|
1400
|
+
'Content-Type': 'application/json',
|
|
1401
|
+
Authorization: `Bearer ${await accessTokenStringFactory()}`
|
|
1402
|
+
}
|
|
1403
|
+
}),
|
|
1404
|
+
fetchHandler,
|
|
1405
|
+
timeout: 20 * 1000,
|
|
1406
|
+
// 20 second timeout
|
|
1407
|
+
requireOkResponse: true,
|
|
1408
|
+
// enforce ok response
|
|
1409
|
+
useTimeout: true // use timeout
|
|
1410
|
+
})
|
|
1411
|
+
} = factoryConfig;
|
|
1412
|
+
return config => {
|
|
1413
|
+
if (!config.apiUrl) {
|
|
1414
|
+
throw new Error('ZohoConfig missing api url.');
|
|
1415
|
+
}
|
|
1416
|
+
const apiUrl = zohoRecruitConfigApiUrl(config.apiUrl);
|
|
1417
|
+
const baseFetch = fetchFactory({
|
|
1418
|
+
apiUrl
|
|
1419
|
+
});
|
|
1420
|
+
const fetch$1 = handleZohoRecruitErrorFetch(baseFetch, logZohoServerErrorFunction, x => {
|
|
1421
|
+
if (x instanceof ZohoInvalidTokenError) {
|
|
1422
|
+
accountsContext.loadAccessToken.resetAccessToken();
|
|
1423
|
+
}
|
|
1424
|
+
});
|
|
1425
|
+
const fetchJson = fetch.fetchJsonFunction(fetch$1, {
|
|
1426
|
+
interceptJsonResponse: interceptZohoRecruit200StatusWithErrorResponse,
|
|
1427
|
+
// intercept errors that return status 200
|
|
1428
|
+
handleFetchJsonParseErrorFunction: fetch.returnNullHandleFetchJsonParseErrorFunction
|
|
1429
|
+
});
|
|
1430
|
+
const recruitContext = {
|
|
1431
|
+
fetch: fetch$1,
|
|
1432
|
+
fetchJson,
|
|
1433
|
+
accessTokenStringFactory,
|
|
1434
|
+
config: {
|
|
1435
|
+
...config,
|
|
1436
|
+
apiUrl
|
|
1437
|
+
},
|
|
1438
|
+
zohoRateLimiter: fetchHandler._rateLimiter
|
|
1439
|
+
};
|
|
1440
|
+
const zohoRecruit = {
|
|
1441
|
+
recruitContext
|
|
1442
|
+
};
|
|
1443
|
+
return zohoRecruit;
|
|
1444
|
+
};
|
|
1445
|
+
}
|
|
1446
|
+
|
|
2145
1447
|
/**
|
|
2146
|
-
*
|
|
2147
|
-
* - Search query is invalid
|
|
1448
|
+
* Maximum length of ZohoRecruitTagName
|
|
2148
1449
|
*/
|
|
2149
|
-
const
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
1450
|
+
const ZOHO_RECRUIT_TAG_NAME_MAX_LENGTH = 25;
|
|
1451
|
+
|
|
1452
|
+
const ZOHO_CRM_SERVICE_NAME = 'crm';
|
|
1453
|
+
function zohoCrmConfigApiUrl(input) {
|
|
1454
|
+
switch (input) {
|
|
1455
|
+
case 'sandbox':
|
|
1456
|
+
return 'https://crmsandbox.zoho.com/crm';
|
|
1457
|
+
case 'production':
|
|
1458
|
+
return 'https://www.zohoapis.com/crm';
|
|
1459
|
+
default:
|
|
1460
|
+
return input;
|
|
2153
1461
|
}
|
|
2154
1462
|
}
|
|
1463
|
+
|
|
2155
1464
|
/**
|
|
2156
|
-
*
|
|
1465
|
+
* Leads module name
|
|
2157
1466
|
*/
|
|
2158
|
-
const
|
|
1467
|
+
const ZOHO_CRM_LEADS_MODULE = 'Leads';
|
|
2159
1468
|
/**
|
|
2160
|
-
*
|
|
1469
|
+
* Contacts module name
|
|
2161
1470
|
*/
|
|
2162
|
-
const
|
|
1471
|
+
const ZOHO_CRM_CONTACTS_MODULE = 'Contacts';
|
|
2163
1472
|
/**
|
|
2164
|
-
*
|
|
1473
|
+
* Tasks module name
|
|
2165
1474
|
*/
|
|
2166
|
-
const
|
|
1475
|
+
const ZOHO_CRM_TASKS_MODULE = 'Tasks';
|
|
2167
1476
|
/**
|
|
2168
|
-
*
|
|
1477
|
+
* Notes module name
|
|
2169
1478
|
*/
|
|
2170
|
-
const
|
|
1479
|
+
const ZOHO_CRM_NOTES_MODULE = 'Notes';
|
|
2171
1480
|
/**
|
|
2172
|
-
*
|
|
1481
|
+
* Emails module name
|
|
2173
1482
|
*/
|
|
2174
|
-
const
|
|
2175
|
-
const ZOHO_RATE_LIMIT_LIMIT_HEADER = 'X-RATELIMIT-LIMIT';
|
|
2176
|
-
const ZOHO_RATE_LIMIT_REMAINING_HEADER = 'X-RATELIMIT-REMAINING';
|
|
2177
|
-
const ZOHO_RATE_LIMIT_RESET_HEADER = 'X-RATELIMIT-RESET';
|
|
2178
|
-
const DEFAULT_ZOHO_API_RATE_LIMIT = 100;
|
|
2179
|
-
const DEFAULT_ZOHO_API_RATE_LIMIT_RESET_PERIOD = util.MS_IN_MINUTE;
|
|
2180
|
-
function zohoRateLimitHeaderDetails(headers) {
|
|
2181
|
-
const limitHeader = headers.get(ZOHO_RATE_LIMIT_LIMIT_HEADER);
|
|
2182
|
-
const remainingHeader = headers.get(ZOHO_RATE_LIMIT_REMAINING_HEADER);
|
|
2183
|
-
const resetHeader = headers.get(ZOHO_RATE_LIMIT_RESET_HEADER);
|
|
2184
|
-
let result = null;
|
|
2185
|
-
if (limitHeader != null && remainingHeader != null && resetHeader != null) {
|
|
2186
|
-
const limit = Number(limitHeader);
|
|
2187
|
-
const remaining = Number(remainingHeader);
|
|
2188
|
-
const reset = Number(resetHeader);
|
|
2189
|
-
const resetAt = new Date(reset);
|
|
2190
|
-
result = {
|
|
2191
|
-
limit,
|
|
2192
|
-
remaining,
|
|
2193
|
-
reset,
|
|
2194
|
-
resetAt
|
|
2195
|
-
};
|
|
2196
|
-
}
|
|
2197
|
-
return result;
|
|
2198
|
-
}
|
|
2199
|
-
class ZohoTooManyRequestsError extends ZohoServerFetchResponseError {
|
|
2200
|
-
get headerDetails() {
|
|
2201
|
-
return zohoRateLimitHeaderDetails(this.responseError.response.headers);
|
|
2202
|
-
}
|
|
2203
|
-
}
|
|
1483
|
+
const ZOHO_CRM_EMAILS_MODULE = 'Emails';
|
|
2204
1484
|
/**
|
|
2205
|
-
*
|
|
2206
|
-
*
|
|
2207
|
-
* @param errorResponseData
|
|
2208
|
-
* @param responseError
|
|
2209
|
-
* @returns
|
|
1485
|
+
* Attachments module name
|
|
2210
1486
|
*/
|
|
2211
|
-
|
|
2212
|
-
let result;
|
|
2213
|
-
const error = tryFindZohoServerErrorData(errorResponseData, responseError);
|
|
2214
|
-
if (error) {
|
|
2215
|
-
const errorData = zohoServerErrorData(error);
|
|
2216
|
-
switch (errorData.code) {
|
|
2217
|
-
case ZOHO_INTERNAL_ERROR_CODE:
|
|
2218
|
-
result = new ZohoInternalError(errorData, responseError);
|
|
2219
|
-
break;
|
|
2220
|
-
case ZOHO_INVALID_TOKEN_ERROR_CODE:
|
|
2221
|
-
result = new ZohoInvalidTokenError(errorData, responseError);
|
|
2222
|
-
break;
|
|
2223
|
-
case ZOHO_INVALID_AUTHORIZATION_ERROR_CODE:
|
|
2224
|
-
result = new ZohoInvalidAuthorizationError(errorData, responseError);
|
|
2225
|
-
break;
|
|
2226
|
-
case ZOHO_INVALID_QUERY_ERROR_CODE:
|
|
2227
|
-
result = new ZohoInvalidQueryError(errorData, responseError);
|
|
2228
|
-
break;
|
|
2229
|
-
case ZOHO_TOO_MANY_REQUESTS_ERROR_CODE:
|
|
2230
|
-
result = new ZohoTooManyRequestsError(errorData, responseError);
|
|
2231
|
-
break;
|
|
2232
|
-
default:
|
|
2233
|
-
result = new ZohoServerFetchResponseError(errorData, responseError);
|
|
2234
|
-
break;
|
|
2235
|
-
}
|
|
2236
|
-
}
|
|
2237
|
-
return result;
|
|
2238
|
-
}
|
|
1487
|
+
const ZOHO_CRM_ATTACHMENTS_MODULE = 'Attachments';
|
|
2239
1488
|
/**
|
|
2240
|
-
*
|
|
1489
|
+
* Returns true if it is a valid ZohoCrmValidUrl.
|
|
1490
|
+
*/
|
|
1491
|
+
const isZohoCrmValidUrl = util.isStandardInternetAccessibleWebsiteUrl;
|
|
1492
|
+
const ZOHO_CRM_RECORD_ATTACHMENT_METADATA_ATTACH_TYPE_RESUME = 'Resume';
|
|
1493
|
+
|
|
1494
|
+
/**
|
|
1495
|
+
* Can search up to 10 criteria at a time.
|
|
2241
1496
|
*
|
|
2242
|
-
*
|
|
1497
|
+
* https://www.zoho.com/crm/developer/docs/api/v8/search-records.html
|
|
2243
1498
|
*
|
|
2244
|
-
*
|
|
2245
|
-
* @param responseError
|
|
2246
|
-
* @returns
|
|
1499
|
+
* "You can search for a maximum of 10 criteria (with the same or different column) with equals and starts_with conditions."
|
|
2247
1500
|
*/
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
1501
|
+
const MAX_ZOHO_CRM_SEARCH_MODULE_RECORDS_CRITERIA = MAX_ZOHO_SEARCH_MODULE_RECORDS_CRITERIA;
|
|
1502
|
+
const zohoCrmSearchRecordsCriteriaString = zohoSearchRecordsCriteriaString;
|
|
1503
|
+
const zohoCrmSearchRecordsCriteriaStringForTree = zohoSearchRecordsCriteriaStringForTree;
|
|
1504
|
+
const escapeZohoCrmFieldValueForCriteriaString = escapeZohoFieldValueForCriteriaString;
|
|
1505
|
+
const zohoCrmSearchRecordsCriteriaEntryToCriteriaString = zohoSearchRecordsCriteriaEntryToCriteriaString;
|
|
2252
1506
|
|
|
2253
1507
|
/**
|
|
2254
1508
|
* Error code for when two records are already associated with each other.
|
|
2255
1509
|
*
|
|
2256
1510
|
* Example being a candidate and a job opening are already associated.
|
|
2257
1511
|
*/
|
|
2258
|
-
const
|
|
1512
|
+
const ZOHO_CRM_ALREADY_ASSOCIATED_ERROR_CODE = 'ALREADY_ASSOCIATED';
|
|
2259
1513
|
/**
|
|
2260
1514
|
* Thrown when a record with the given id has no content. Typically also means it does not exist.
|
|
2261
1515
|
*/
|
|
2262
|
-
class
|
|
1516
|
+
class ZohoCrmRecordNoContentError extends makeError.BaseError {
|
|
2263
1517
|
constructor(moduleName, recordId) {
|
|
2264
1518
|
super(`There was no content or matching records for the content. It may not exist.`);
|
|
2265
1519
|
this.moduleName = void 0;
|
|
@@ -2268,63 +1522,65 @@ class ZohoRecruitRecordNoContentError extends makeError.BaseError {
|
|
|
2268
1522
|
this.recordId = recordId;
|
|
2269
1523
|
}
|
|
2270
1524
|
}
|
|
2271
|
-
class
|
|
2272
|
-
class
|
|
2273
|
-
class
|
|
2274
|
-
class
|
|
1525
|
+
class ZohoCrmRecordCrudError extends ZohoServerError {}
|
|
1526
|
+
class ZohoCrmRecordCrudMandatoryFieldNotFoundError extends ZohoCrmRecordCrudError {}
|
|
1527
|
+
class ZohoCrmRecordCrudDuplicateDataError extends ZohoCrmRecordCrudError {}
|
|
1528
|
+
class ZohoCrmRecordCrudInvalidDataError extends ZohoCrmRecordCrudError {
|
|
2275
1529
|
get invalidFieldDetails() {
|
|
2276
1530
|
return this.error.details;
|
|
2277
1531
|
}
|
|
2278
1532
|
}
|
|
2279
|
-
class
|
|
2280
|
-
function
|
|
1533
|
+
class ZohoCrmRecordCrudNoMatchingRecordError extends ZohoCrmRecordCrudInvalidDataError {}
|
|
1534
|
+
function zohoCrmRecordCrudError(error) {
|
|
2281
1535
|
let result;
|
|
2282
1536
|
switch (error.code) {
|
|
2283
1537
|
case ZOHO_INVALID_DATA_ERROR_CODE:
|
|
2284
|
-
const invalidDataError = new
|
|
2285
|
-
if (invalidDataError.invalidFieldDetails
|
|
2286
|
-
result = new
|
|
1538
|
+
const invalidDataError = new ZohoCrmRecordCrudInvalidDataError(error);
|
|
1539
|
+
if (invalidDataError.invalidFieldDetails.api_name === 'id') {
|
|
1540
|
+
result = new ZohoCrmRecordCrudNoMatchingRecordError(error);
|
|
2287
1541
|
} else {
|
|
2288
1542
|
result = invalidDataError;
|
|
2289
1543
|
}
|
|
2290
1544
|
break;
|
|
2291
1545
|
case ZOHO_MANDATORY_NOT_FOUND_ERROR_CODE:
|
|
2292
|
-
result = new
|
|
1546
|
+
result = new ZohoCrmRecordCrudMandatoryFieldNotFoundError(error);
|
|
2293
1547
|
break;
|
|
2294
1548
|
case ZOHO_DUPLICATE_DATA_ERROR_CODE:
|
|
2295
|
-
result = new
|
|
1549
|
+
result = new ZohoCrmRecordCrudDuplicateDataError(error);
|
|
2296
1550
|
break;
|
|
2297
1551
|
default:
|
|
2298
|
-
result = new
|
|
1552
|
+
result = new ZohoCrmRecordCrudError(error);
|
|
2299
1553
|
break;
|
|
2300
1554
|
}
|
|
2301
1555
|
return result;
|
|
2302
1556
|
}
|
|
2303
|
-
function
|
|
1557
|
+
function assertZohoCrmRecordDataArrayResultHasContent(moduleName, recordId) {
|
|
2304
1558
|
return x => {
|
|
2305
1559
|
if (x == null || !x.data?.length) {
|
|
2306
|
-
throw new
|
|
1560
|
+
throw new ZohoCrmRecordNoContentError(moduleName, recordId);
|
|
2307
1561
|
} else {
|
|
2308
1562
|
return x;
|
|
2309
1563
|
}
|
|
2310
1564
|
};
|
|
2311
1565
|
}
|
|
2312
|
-
const
|
|
2313
|
-
|
|
1566
|
+
const logZohoCrmErrorToConsole = logZohoServerErrorFunction('ZohoCrm', {
|
|
1567
|
+
logDataArrayErrors: false
|
|
1568
|
+
});
|
|
1569
|
+
async function parseZohoCrmError(responseError) {
|
|
2314
1570
|
const data = await responseError.response.json().catch(x => undefined);
|
|
2315
1571
|
let result;
|
|
2316
1572
|
if (data) {
|
|
2317
|
-
result =
|
|
1573
|
+
result = parseZohoCrmServerErrorResponseData(data, responseError);
|
|
2318
1574
|
}
|
|
2319
1575
|
return result;
|
|
2320
1576
|
}
|
|
2321
|
-
function
|
|
1577
|
+
function parseZohoCrmServerErrorResponseData(errorResponseData, responseError) {
|
|
2322
1578
|
let result;
|
|
2323
1579
|
const error = tryFindZohoServerErrorData(errorResponseData, responseError);
|
|
2324
1580
|
if (error) {
|
|
2325
1581
|
const errorData = zohoServerErrorData(error);
|
|
2326
1582
|
switch (errorData.code) {
|
|
2327
|
-
// TODO: Add
|
|
1583
|
+
// TODO: Add crm-specific error codes here.
|
|
2328
1584
|
default:
|
|
2329
1585
|
result = parseZohoServerErrorResponseData(errorResponseData, responseError);
|
|
2330
1586
|
break;
|
|
@@ -2332,16 +1588,16 @@ function parseZohoRecruitServerErrorResponseData(errorResponseData, responseErro
|
|
|
2332
1588
|
}
|
|
2333
1589
|
return result;
|
|
2334
1590
|
}
|
|
2335
|
-
const
|
|
2336
|
-
const
|
|
1591
|
+
const interceptZohoCrm200StatusWithErrorResponse = interceptZohoErrorResponseFactory(parseZohoCrmServerErrorResponseData);
|
|
1592
|
+
const handleZohoCrmErrorFetch = handleZohoErrorFetchFactory(parseZohoCrmError, logZohoCrmErrorToConsole);
|
|
2337
1593
|
|
|
2338
1594
|
// MARK: Insert/Update/Upsert Response
|
|
2339
1595
|
/**
|
|
2340
1596
|
* The maximum number of records allowed for most CRUD functions.
|
|
2341
1597
|
*
|
|
2342
|
-
* This is a limit enforced by the Zoho
|
|
1598
|
+
* This is a limit enforced by the Zoho Crm API
|
|
2343
1599
|
*/
|
|
2344
|
-
const
|
|
1600
|
+
const ZOHO_CRM_CRUD_FUNCTION_MAX_RECORDS_LIMIT = 100;
|
|
2345
1601
|
/**
|
|
2346
1602
|
* The APIs for Insert, Upsert, and Update have the same structure.
|
|
2347
1603
|
*
|
|
@@ -2351,11 +1607,11 @@ function updateRecordLikeFunction(context, fetchUrlPrefix, fetchMethod) {
|
|
|
2351
1607
|
return ({
|
|
2352
1608
|
data,
|
|
2353
1609
|
module
|
|
2354
|
-
}) => context.fetchJson(`/
|
|
1610
|
+
}) => context.fetchJson(`/v8/${module}${fetchUrlPrefix}`, zohoCrmApiFetchJsonInput(fetchMethod, {
|
|
2355
1611
|
data: util.asArray(data)
|
|
2356
|
-
})).then(x => {
|
|
1612
|
+
})).catch(zohoCrmCatchZohoCrmChangeObjectLikeResponseError).then(x => {
|
|
2357
1613
|
const isInputMultipleItems = Array.isArray(data);
|
|
2358
|
-
const result =
|
|
1614
|
+
const result = zohoCrmMultiRecordResult(util.asArray(data), x.data);
|
|
2359
1615
|
if (isInputMultipleItems) {
|
|
2360
1616
|
return result;
|
|
2361
1617
|
} else {
|
|
@@ -2364,7 +1620,7 @@ function updateRecordLikeFunction(context, fetchUrlPrefix, fetchMethod) {
|
|
|
2364
1620
|
errorItems
|
|
2365
1621
|
} = result;
|
|
2366
1622
|
if (errorItems[0] != null) {
|
|
2367
|
-
throw
|
|
1623
|
+
throw zohoCrmRecordCrudError(errorItems[0].result);
|
|
2368
1624
|
} else {
|
|
2369
1625
|
return successItems[0].result.details;
|
|
2370
1626
|
}
|
|
@@ -2372,162 +1628,169 @@ function updateRecordLikeFunction(context, fetchUrlPrefix, fetchMethod) {
|
|
|
2372
1628
|
});
|
|
2373
1629
|
}
|
|
2374
1630
|
/**
|
|
2375
|
-
* Inserts one or more records into
|
|
1631
|
+
* Inserts one or more records into Crm.
|
|
2376
1632
|
*
|
|
2377
|
-
* https://www.zoho.com/
|
|
1633
|
+
* https://www.zoho.com/crm/developer-guide/apiv2/insert-records.html
|
|
2378
1634
|
*
|
|
2379
1635
|
* @param context
|
|
2380
1636
|
* @returns
|
|
2381
1637
|
*/
|
|
2382
|
-
function
|
|
1638
|
+
function zohoCrmInsertRecord(context) {
|
|
2383
1639
|
return updateRecordLikeFunction(context, '', 'POST');
|
|
2384
1640
|
}
|
|
2385
1641
|
/**
|
|
2386
|
-
* Updates or inserts one or more records in
|
|
1642
|
+
* Updates or inserts one or more records in Crm.
|
|
2387
1643
|
*
|
|
2388
|
-
* https://www.zoho.com/
|
|
1644
|
+
* https://www.zoho.com/crm/developer-guide/apiv2/upsert-records.html
|
|
2389
1645
|
*
|
|
2390
1646
|
* @param context
|
|
2391
1647
|
* @returns
|
|
2392
1648
|
*/
|
|
2393
|
-
function
|
|
1649
|
+
function zohoCrmUpsertRecord(context) {
|
|
2394
1650
|
return updateRecordLikeFunction(context, '/upsert', 'POST');
|
|
2395
1651
|
}
|
|
2396
1652
|
/**
|
|
2397
|
-
* Updates one or more records in
|
|
1653
|
+
* Updates one or more records in Crm.
|
|
2398
1654
|
*
|
|
2399
|
-
* https://www.zoho.com/
|
|
1655
|
+
* https://www.zoho.com/crm/developer-guide/apiv2/update-records.html
|
|
2400
1656
|
*
|
|
2401
1657
|
* @param context
|
|
2402
1658
|
* @returns
|
|
2403
1659
|
*/
|
|
2404
|
-
function
|
|
1660
|
+
function zohoCrmUpdateRecord(context) {
|
|
2405
1661
|
return updateRecordLikeFunction(context, '', 'PUT');
|
|
2406
1662
|
}
|
|
2407
1663
|
/**
|
|
2408
1664
|
* Deletes one or more records from the given module.
|
|
2409
1665
|
*
|
|
2410
|
-
* https://www.zoho.com/
|
|
1666
|
+
* https://www.zoho.com/crm/developer-guide/apiv2/delete-records.html
|
|
2411
1667
|
*
|
|
2412
1668
|
* @param context
|
|
2413
|
-
* @returns
|
|
1669
|
+
* @returns ZohoCrmDeleteRecordFunction
|
|
2414
1670
|
*/
|
|
2415
|
-
function
|
|
1671
|
+
function zohoCrmDeleteRecord(context) {
|
|
2416
1672
|
return ({
|
|
2417
1673
|
ids,
|
|
2418
1674
|
module,
|
|
2419
1675
|
wf_trigger
|
|
2420
1676
|
}) => {
|
|
2421
|
-
return context.fetchJson(`/
|
|
1677
|
+
return context.fetchJson(`/v8/${module}?${fetch.makeUrlSearchParams({
|
|
2422
1678
|
ids,
|
|
2423
1679
|
wf_trigger
|
|
2424
|
-
})}`,
|
|
1680
|
+
})}`, zohoCrmApiFetchJsonInput('DELETE')).catch(zohoCrmCatchZohoCrmChangeObjectLikeResponseError).then(zohoCrmChangeObjectLikeResponseSuccessAndErrorPairs);
|
|
2425
1681
|
};
|
|
2426
1682
|
}
|
|
2427
1683
|
/**
|
|
2428
1684
|
* Retrieves a specific record from the given module.
|
|
2429
1685
|
*
|
|
2430
|
-
* https://www.zoho.com/
|
|
1686
|
+
* https://www.zoho.com/crm/developer-guide/apiv2/get-records.html
|
|
2431
1687
|
*
|
|
2432
1688
|
* @param context
|
|
2433
1689
|
* @returns
|
|
2434
1690
|
*/
|
|
2435
|
-
function
|
|
2436
|
-
return input => context.fetchJson(`/
|
|
1691
|
+
function zohoCrmGetRecordById(context) {
|
|
1692
|
+
return input => context.fetchJson(`/v8/${input.module}/${input.id}`, zohoCrmApiFetchJsonInput('GET')).then(assertZohoCrmRecordDataArrayResultHasContent(input.module)).then(x => x.data[0]);
|
|
2437
1693
|
}
|
|
2438
1694
|
/**
|
|
2439
1695
|
* Retrieves records from the given module. Used for paginating across all records.
|
|
2440
1696
|
*
|
|
2441
|
-
* https://www.zoho.com/
|
|
1697
|
+
* https://www.zoho.com/crm/developer-guide/apiv2/get-records.html
|
|
2442
1698
|
*
|
|
2443
1699
|
* @param context
|
|
2444
1700
|
* @returns
|
|
2445
1701
|
*/
|
|
2446
|
-
function
|
|
2447
|
-
return input => context.fetchJson(`/
|
|
1702
|
+
function zohoCrmGetRecords(context) {
|
|
1703
|
+
return input => context.fetchJson(`/v8/${input.module}?${zohoCrmUrlSearchParamsMinusModule(input).toString()}`, zohoCrmApiFetchJsonInput('GET'));
|
|
2448
1704
|
}
|
|
2449
1705
|
/**
|
|
2450
1706
|
* Searches records from the given module.
|
|
2451
1707
|
*
|
|
2452
|
-
* https://www.zoho.com/
|
|
1708
|
+
* https://www.zoho.com/crm/developer-guide/apiv2/search-records.html
|
|
2453
1709
|
*
|
|
2454
1710
|
* @param context
|
|
2455
1711
|
* @returns
|
|
2456
1712
|
*/
|
|
2457
|
-
function
|
|
1713
|
+
function zohoCrmSearchRecords(context) {
|
|
2458
1714
|
function searchRecordsUrlSearchParams(input) {
|
|
2459
1715
|
const baseInput = {
|
|
2460
1716
|
...input
|
|
2461
1717
|
};
|
|
2462
1718
|
delete baseInput.criteria;
|
|
2463
1719
|
if (input.criteria != null) {
|
|
2464
|
-
const criteriaString =
|
|
1720
|
+
const criteriaString = zohoCrmSearchRecordsCriteriaString(input.criteria);
|
|
2465
1721
|
baseInput.criteria = criteriaString;
|
|
2466
1722
|
}
|
|
2467
|
-
if (!baseInput.word && !input.criteria && !input.email && !input.phone) {
|
|
2468
|
-
throw new Error('At least one of word, criteria, email, or phone must be provided');
|
|
1723
|
+
if (!baseInput.word && !input.cvid && !input.criteria && !input.email && !input.phone) {
|
|
1724
|
+
throw new Error('At least one of word, cvid, criteria, email, or phone must be provided');
|
|
2469
1725
|
}
|
|
2470
|
-
const urlParams =
|
|
1726
|
+
const urlParams = zohoCrmUrlSearchParamsMinusModule(baseInput);
|
|
2471
1727
|
return urlParams;
|
|
2472
1728
|
}
|
|
2473
|
-
return input => context.fetchJson(`/
|
|
1729
|
+
return input => context.fetchJson(`/v8/${input.module}/search?${searchRecordsUrlSearchParams(input).toString()}`, zohoCrmApiFetchJsonInput('GET')).then(x => x ?? {
|
|
2474
1730
|
data: [],
|
|
2475
1731
|
info: {
|
|
2476
1732
|
more_records: false
|
|
2477
1733
|
}
|
|
2478
1734
|
});
|
|
2479
1735
|
}
|
|
2480
|
-
function
|
|
2481
|
-
return zohoFetchPageFactory(
|
|
1736
|
+
function zohoCrmSearchRecordsPageFactory(context) {
|
|
1737
|
+
return zohoFetchPageFactory(zohoCrmSearchRecords(context));
|
|
2482
1738
|
}
|
|
2483
1739
|
/**
|
|
2484
|
-
* Creates a
|
|
1740
|
+
* Creates a ZohoCrmGetRelatedRecordsFunctionFactory, which can be used to create ZohoCrmGetRelatedRecordsFunction<T> that targets retrieving related records of a given type.
|
|
2485
1741
|
*
|
|
2486
|
-
* https://www.zoho.com/
|
|
1742
|
+
* https://www.zoho.com/crm/developer-guide/apiv2/get-related-records.html
|
|
2487
1743
|
*
|
|
2488
|
-
* @param context the
|
|
2489
|
-
* @returns a
|
|
1744
|
+
* @param context the ZohoCrmContext to use
|
|
1745
|
+
* @returns a ZohoCrmGetRelatedRecordsFunctionFactory
|
|
2490
1746
|
*/
|
|
2491
|
-
function
|
|
1747
|
+
function zohoCrmGetRelatedRecordsFunctionFactory(context) {
|
|
2492
1748
|
return config => {
|
|
2493
1749
|
const {
|
|
2494
1750
|
targetModule,
|
|
2495
1751
|
returnEmptyRecordsInsteadOfNull = true
|
|
2496
1752
|
} = config;
|
|
2497
|
-
return input => context.fetchJson(`/
|
|
1753
|
+
return input => context.fetchJson(`/v8/${input.module}/${input.id}/${targetModule}?${zohoCrmUrlSearchParamsMinusIdAndModule(input, input.filter).toString()}`, zohoCrmApiFetchJsonInput('GET')).then(x => x ?? (returnEmptyRecordsInsteadOfNull !== false ? emptyZohoPageResult() : x));
|
|
2498
1754
|
};
|
|
2499
1755
|
}
|
|
2500
|
-
function
|
|
2501
|
-
|
|
2502
|
-
targetModule:
|
|
1756
|
+
function zohoCrmGetEmailsForRecord(context) {
|
|
1757
|
+
const getEmailsFactory = zohoCrmGetRelatedRecordsFunctionFactory(context)({
|
|
1758
|
+
targetModule: ZOHO_CRM_EMAILS_MODULE
|
|
1759
|
+
});
|
|
1760
|
+
return input => getEmailsFactory(input).then(x => {
|
|
1761
|
+
const data = x.data ?? x.Emails;
|
|
1762
|
+
return {
|
|
1763
|
+
...x,
|
|
1764
|
+
data
|
|
1765
|
+
};
|
|
2503
1766
|
});
|
|
2504
1767
|
}
|
|
2505
|
-
function
|
|
2506
|
-
return zohoFetchPageFactory(
|
|
1768
|
+
function zohoCrmGetEmailsForRecordPageFactory(context) {
|
|
1769
|
+
return zohoFetchPageFactory(zohoCrmGetEmailsForRecord(context));
|
|
2507
1770
|
}
|
|
2508
|
-
function
|
|
2509
|
-
return
|
|
2510
|
-
targetModule:
|
|
1771
|
+
function zohoCrmGetAttachmentsForRecord(context) {
|
|
1772
|
+
return zohoCrmGetRelatedRecordsFunctionFactory(context)({
|
|
1773
|
+
targetModule: ZOHO_CRM_ATTACHMENTS_MODULE
|
|
2511
1774
|
});
|
|
2512
1775
|
}
|
|
2513
|
-
function
|
|
2514
|
-
return zohoFetchPageFactory(
|
|
1776
|
+
function zohoCrmGetAttachmentsForRecordPageFactory(context) {
|
|
1777
|
+
return zohoFetchPageFactory(zohoCrmGetAttachmentsForRecord(context));
|
|
2515
1778
|
}
|
|
2516
1779
|
/**
|
|
2517
|
-
* Maximum attachment size allowed by Zoho
|
|
1780
|
+
* Maximum attachment size allowed by Zoho Crm.
|
|
2518
1781
|
*
|
|
2519
1782
|
* 20MB
|
|
2520
1783
|
*/
|
|
2521
|
-
const
|
|
1784
|
+
const ZOHO_CRM_ATTACHMENT_MAX_SIZE = 20 * 1024 * 1024;
|
|
2522
1785
|
/**
|
|
2523
1786
|
* Uploads an attachment to a record.
|
|
2524
1787
|
*
|
|
2525
|
-
* https://www.zoho.com/
|
|
1788
|
+
* https://www.zoho.com/crm/developer-guide/apiv2/upload-attachment.html
|
|
2526
1789
|
*
|
|
2527
1790
|
* @param context
|
|
2528
1791
|
* @returns
|
|
2529
1792
|
*/
|
|
2530
|
-
function
|
|
1793
|
+
function zohoCrmUploadAttachmentForRecord(context) {
|
|
2531
1794
|
return input => {
|
|
2532
1795
|
const {
|
|
2533
1796
|
attachmentCategoryId,
|
|
@@ -2545,7 +1808,7 @@ function uploadAttachmentForRecord(context) {
|
|
|
2545
1808
|
if (formData != null) {
|
|
2546
1809
|
delete urlParams.attachment_url;
|
|
2547
1810
|
}
|
|
2548
|
-
const url = `https://
|
|
1811
|
+
const url = `https://crmsandbox.zoho.com/crm/v8/${input.module}/${input.id}/${ZOHO_CRM_ATTACHMENTS_MODULE}?${fetch.makeUrlSearchParams(urlParams).toString()}`;
|
|
2549
1812
|
let response;
|
|
2550
1813
|
if (urlParams.attachment_url) {
|
|
2551
1814
|
response = context.fetch(url, {
|
|
@@ -2585,30 +1848,30 @@ function uploadAttachmentForRecord(context) {
|
|
|
2585
1848
|
/**
|
|
2586
1849
|
* Downloads an attachment from a record.
|
|
2587
1850
|
*
|
|
2588
|
-
* https://www.zoho.com/
|
|
1851
|
+
* https://www.zoho.com/crm/developer-guide/apiv2/download-attachments.html
|
|
2589
1852
|
*
|
|
2590
1853
|
* @param context
|
|
2591
1854
|
* @returns
|
|
2592
1855
|
*/
|
|
2593
|
-
function
|
|
2594
|
-
return input => context.fetch(`/
|
|
1856
|
+
function zohoCrmDownloadAttachmentForRecord(context) {
|
|
1857
|
+
return input => context.fetch(`/v8/${input.module}/${input.id}/${ZOHO_CRM_ATTACHMENTS_MODULE}/${input.attachment_id}`, {
|
|
2595
1858
|
method: 'GET'
|
|
2596
1859
|
}).then(fetch.parseFetchFileResponse);
|
|
2597
1860
|
}
|
|
2598
1861
|
/**
|
|
2599
1862
|
* Deletes an attachment from a record.
|
|
2600
1863
|
*
|
|
2601
|
-
* https://www.zoho.com/
|
|
1864
|
+
* https://www.zoho.com/crm/developer-guide/apiv2/delete-attachments.html
|
|
2602
1865
|
*
|
|
2603
1866
|
* @param context
|
|
2604
1867
|
* @returns
|
|
2605
1868
|
*/
|
|
2606
|
-
function
|
|
2607
|
-
return input => context.fetch(`/
|
|
1869
|
+
function zohoCrmDeleteAttachmentFromRecord(context) {
|
|
1870
|
+
return input => context.fetch(`/v8/${input.module}/${input.id}/${ZOHO_CRM_ATTACHMENTS_MODULE}/${input.attachment_id}`, {
|
|
2608
1871
|
method: 'DELETE'
|
|
2609
1872
|
});
|
|
2610
1873
|
}
|
|
2611
|
-
class
|
|
1874
|
+
class ZohoCrmExecuteRestApiFunctionError extends makeError.BaseError {
|
|
2612
1875
|
constructor(error) {
|
|
2613
1876
|
super(`An error occured during the execution of the function. Code: ${error.code}, Message: ${error.message}`);
|
|
2614
1877
|
this.error = void 0;
|
|
@@ -2616,41 +1879,41 @@ class ZohoRecruitExecuteRestApiFunctionError extends makeError.BaseError {
|
|
|
2616
1879
|
}
|
|
2617
1880
|
}
|
|
2618
1881
|
/**
|
|
2619
|
-
* Creates a
|
|
1882
|
+
* Creates a ZohoCrmExecuteRestApiFunctionFunction
|
|
2620
1883
|
*
|
|
2621
1884
|
* OAuth Details:
|
|
2622
1885
|
* - https://www.zoho.com/crm/developer/docs/functions/serverless-fn-oauth.html#OAuth2
|
|
2623
|
-
* - There is no documentation for
|
|
2624
|
-
* - You will need the following scopes:
|
|
1886
|
+
* - There is no documentation for ZohoCrm specifically, but it seems to behave the same way
|
|
1887
|
+
* - You will need the following scopes: ZohoCrm.functions.execute.READ,ZohoCrm.functions.execute.CREATE
|
|
2625
1888
|
*
|
|
2626
1889
|
* @param context
|
|
2627
1890
|
* @returns
|
|
2628
1891
|
*/
|
|
2629
|
-
function
|
|
1892
|
+
function zohoCrmExecuteRestApiFunction(context) {
|
|
2630
1893
|
return input => {
|
|
2631
1894
|
const inputSearchParams = fetch.makeUrlSearchParams(input.params);
|
|
2632
1895
|
const inputSearchParamsString = inputSearchParams.toString();
|
|
2633
1896
|
const isSpecificRequest = Boolean(input.apiKey);
|
|
2634
1897
|
const urlParams = (isSpecificRequest ? `auth_type=apikey&zapikey=${input.apiKey}` : 'auth_type=oauth') + (inputSearchParamsString ? `&${inputSearchParamsString}` : '');
|
|
2635
|
-
const relativeUrl = `/
|
|
2636
|
-
const baseUrl = isSpecificRequest && input.apiUrl != null ?
|
|
1898
|
+
const relativeUrl = `/v8/functions/${input.functionName}/actions/execute?${urlParams}`;
|
|
1899
|
+
const baseUrl = isSpecificRequest && input.apiUrl != null ? zohoCrmConfigApiUrl(input.apiUrl) : '';
|
|
2637
1900
|
const url = `${baseUrl}${relativeUrl}`;
|
|
2638
|
-
return context.fetchJson(url,
|
|
1901
|
+
return context.fetchJson(url, zohoCrmApiFetchJsonInput('POST')).then(x => {
|
|
2639
1902
|
if (x.code === 'success') {
|
|
2640
1903
|
return x.details;
|
|
2641
1904
|
} else {
|
|
2642
|
-
throw new
|
|
1905
|
+
throw new ZohoCrmExecuteRestApiFunctionError(x);
|
|
2643
1906
|
}
|
|
2644
1907
|
});
|
|
2645
1908
|
};
|
|
2646
1909
|
}
|
|
2647
1910
|
// MARK: Util
|
|
2648
|
-
function
|
|
1911
|
+
function zohoCrmUrlSearchParamsMinusModule(...input) {
|
|
2649
1912
|
return fetch.makeUrlSearchParams(input, {
|
|
2650
1913
|
omitKeys: 'module'
|
|
2651
1914
|
});
|
|
2652
1915
|
}
|
|
2653
|
-
function
|
|
1916
|
+
function zohoCrmUrlSearchParamsMinusIdAndModule(...input) {
|
|
2654
1917
|
return fetch.makeUrlSearchParams(input, {
|
|
2655
1918
|
omitKeys: ['id', 'module']
|
|
2656
1919
|
});
|
|
@@ -2658,143 +1921,105 @@ function zohoRecruitUrlSearchParamsMinusIdAndModule(...input) {
|
|
|
2658
1921
|
/**
|
|
2659
1922
|
* @deprecated use makeUrlSearchParams instead.
|
|
2660
1923
|
*/
|
|
2661
|
-
const
|
|
2662
|
-
function
|
|
1924
|
+
const zohoCrmUrlSearchParams = fetch.makeUrlSearchParams;
|
|
1925
|
+
function zohoCrmApiFetchJsonInput(method, body) {
|
|
2663
1926
|
const result = {
|
|
2664
1927
|
method,
|
|
2665
1928
|
body: body ?? undefined
|
|
2666
1929
|
};
|
|
2667
1930
|
return result;
|
|
2668
1931
|
}
|
|
2669
|
-
|
|
2670
|
-
const {
|
|
2671
|
-
data
|
|
2672
|
-
} = response;
|
|
2673
|
-
const successItems = [];
|
|
2674
|
-
const errorItems = [];
|
|
2675
|
-
data.forEach(x => {
|
|
2676
|
-
if (x.status === ZOHO_SUCCESS_STATUS) {
|
|
2677
|
-
successItems.push(x);
|
|
2678
|
-
} else {
|
|
2679
|
-
errorItems.push(x);
|
|
2680
|
-
}
|
|
2681
|
-
});
|
|
2682
|
-
const result = {
|
|
2683
|
-
...response,
|
|
2684
|
-
successItems,
|
|
2685
|
-
errorItems
|
|
2686
|
-
};
|
|
2687
|
-
return result;
|
|
2688
|
-
}
|
|
2689
|
-
function zohoRecruitMultiRecordResult(input, results) {
|
|
2690
|
-
const successItems = [];
|
|
2691
|
-
const errorItems = [];
|
|
2692
|
-
input.forEach((x, i) => {
|
|
2693
|
-
const result = results[i];
|
|
2694
|
-
if (result.status === ZOHO_SUCCESS_STATUS) {
|
|
2695
|
-
successItems.push({
|
|
2696
|
-
input: x,
|
|
2697
|
-
result: result
|
|
2698
|
-
});
|
|
2699
|
-
} else {
|
|
2700
|
-
errorItems.push({
|
|
2701
|
-
input: x,
|
|
2702
|
-
result: result
|
|
2703
|
-
});
|
|
2704
|
-
}
|
|
2705
|
-
});
|
|
2706
|
-
const result = {
|
|
2707
|
-
successItems,
|
|
2708
|
-
errorItems
|
|
2709
|
-
};
|
|
2710
|
-
return result;
|
|
2711
|
-
}
|
|
2712
|
-
|
|
1932
|
+
// MARK: Results
|
|
2713
1933
|
/**
|
|
2714
|
-
*
|
|
1934
|
+
* Catches ZohoServerFetchResponseDataArrayError and returns the error data array as the response data, as each data element will have the error details.
|
|
2715
1935
|
*
|
|
2716
|
-
*
|
|
2717
|
-
*
|
|
2718
|
-
* @param context
|
|
2719
|
-
* @returns
|
|
1936
|
+
* Use to catch errors from functions that return ZohoCrmChangeObjectLikeResponse and pass the result to zohoCrmChangeObjectLikeResponseSuccessAndErrorPairs.
|
|
2720
1937
|
*/
|
|
2721
|
-
function
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
const result = zohoRecruitMultiRecordResult(resultInputMap, x.data);
|
|
2727
|
-
const {
|
|
2728
|
-
included: alreadyAssociatedErrorItems,
|
|
2729
|
-
excluded: otherErrorItems
|
|
2730
|
-
} = util.separateValues(result.errorItems, x => {
|
|
2731
|
-
return x.result.code === ZOHO_FAILURE_ERROR_CODE && x.result.details.error[0].code === ZOHO_RECRUIT_ALREADY_ASSOCIATED_ERROR_CODE;
|
|
2732
|
-
});
|
|
2733
|
-
return {
|
|
2734
|
-
...result,
|
|
2735
|
-
errorItems: otherErrorItems,
|
|
2736
|
-
alreadyAssociatedErrorItems,
|
|
2737
|
-
allErrorItems: result.errorItems
|
|
1938
|
+
function zohoCrmCatchZohoCrmChangeObjectLikeResponseError(e) {
|
|
1939
|
+
let result;
|
|
1940
|
+
if (e instanceof ZohoServerFetchResponseDataArrayError) {
|
|
1941
|
+
result = {
|
|
1942
|
+
data: e.errorDataArray
|
|
2738
1943
|
};
|
|
2739
|
-
}
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
return
|
|
2743
|
-
return context.fetchJson(`/v2/${input.module}/${input.id}/associate?${zohoRecruitUrlSearchParamsMinusIdAndModule(input).toString()}`, zohoRecruitApiFetchJsonInput('GET')).then(x => {
|
|
2744
|
-
const result = x ?? emptyZohoPageResult();
|
|
2745
|
-
return result;
|
|
2746
|
-
});
|
|
2747
|
-
};
|
|
1944
|
+
} else {
|
|
1945
|
+
throw e;
|
|
1946
|
+
}
|
|
1947
|
+
return result;
|
|
2748
1948
|
}
|
|
2749
|
-
function
|
|
2750
|
-
const
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
1949
|
+
function zohoCrmChangeObjectLikeResponseSuccessAndErrorPairs(response) {
|
|
1950
|
+
const {
|
|
1951
|
+
data
|
|
1952
|
+
} = response;
|
|
1953
|
+
const successItems = [];
|
|
1954
|
+
const errorItems = [];
|
|
1955
|
+
data.forEach(x => {
|
|
1956
|
+
if (x.status === ZOHO_SUCCESS_STATUS) {
|
|
1957
|
+
successItems.push(x);
|
|
1958
|
+
} else {
|
|
1959
|
+
errorItems.push(x);
|
|
1960
|
+
}
|
|
1961
|
+
});
|
|
1962
|
+
const result = {
|
|
1963
|
+
...response,
|
|
1964
|
+
successItems,
|
|
1965
|
+
errorItems
|
|
2756
1966
|
};
|
|
1967
|
+
return result;
|
|
2757
1968
|
}
|
|
2758
|
-
function
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
1969
|
+
function zohoCrmMultiRecordResult(input, results) {
|
|
1970
|
+
const successItems = [];
|
|
1971
|
+
const errorItems = [];
|
|
1972
|
+
input.forEach((x, i) => {
|
|
1973
|
+
const result = results[i];
|
|
1974
|
+
if (result.status === ZOHO_SUCCESS_STATUS) {
|
|
1975
|
+
successItems.push({
|
|
1976
|
+
input: x,
|
|
1977
|
+
result: result
|
|
1978
|
+
});
|
|
1979
|
+
} else {
|
|
1980
|
+
errorItems.push({
|
|
1981
|
+
input: x,
|
|
1982
|
+
result: result
|
|
1983
|
+
});
|
|
1984
|
+
}
|
|
1985
|
+
});
|
|
1986
|
+
const result = {
|
|
1987
|
+
successItems,
|
|
1988
|
+
errorItems
|
|
2768
1989
|
};
|
|
2769
|
-
|
|
2770
|
-
function searchJobOpeningAssociatedCandidateRecordsPageFactory(context) {
|
|
2771
|
-
return zohoFetchPageFactory(searchJobOpeningAssociatedCandidateRecords(context));
|
|
1990
|
+
return result;
|
|
2772
1991
|
}
|
|
2773
1992
|
|
|
2774
|
-
function
|
|
2775
|
-
return input => context.fetchJson(`/v2/${
|
|
1993
|
+
function zohoCrmCreateNotes(context) {
|
|
1994
|
+
return input => context.fetchJson(`/v2/${ZOHO_CRM_NOTES_MODULE}`, zohoCrmApiFetchJsonInput('POST', {
|
|
2776
1995
|
data: input.data
|
|
2777
1996
|
})).then(x => {
|
|
2778
|
-
return
|
|
1997
|
+
return zohoCrmMultiRecordResult(util.asArray(input.data), x.data);
|
|
2779
1998
|
});
|
|
2780
1999
|
}
|
|
2781
|
-
function
|
|
2782
|
-
return input => context.fetchJson(`/v2/${
|
|
2000
|
+
function zohoCrmDeleteNotes(context) {
|
|
2001
|
+
return input => context.fetchJson(`/v2/${ZOHO_CRM_NOTES_MODULE}?${fetch.makeUrlSearchParams({
|
|
2783
2002
|
ids: input.ids
|
|
2784
|
-
})}`,
|
|
2785
|
-
return
|
|
2003
|
+
})}`, zohoCrmApiFetchJsonInput('DELETE')).then(x => {
|
|
2004
|
+
return zohoCrmMultiRecordResult(util.asArray(input.ids), x.data);
|
|
2786
2005
|
});
|
|
2787
2006
|
}
|
|
2788
|
-
function
|
|
2789
|
-
return
|
|
2790
|
-
targetModule:
|
|
2007
|
+
function zohoCrmGetNotesForRecord(context) {
|
|
2008
|
+
return zohoCrmGetRelatedRecordsFunctionFactory(context)({
|
|
2009
|
+
targetModule: ZOHO_CRM_NOTES_MODULE
|
|
2791
2010
|
});
|
|
2792
2011
|
}
|
|
2793
|
-
function
|
|
2794
|
-
return zohoFetchPageFactory(
|
|
2012
|
+
function zohoCrmGetNotesForRecordPageFactory(context) {
|
|
2013
|
+
return zohoFetchPageFactory(zohoCrmGetNotesForRecord(context));
|
|
2795
2014
|
}
|
|
2796
|
-
|
|
2797
|
-
|
|
2015
|
+
/**
|
|
2016
|
+
* https://www.zoho.com/crm/developer/docs/api/v8/create-notes.html
|
|
2017
|
+
*
|
|
2018
|
+
* @param context
|
|
2019
|
+
* @returns
|
|
2020
|
+
*/
|
|
2021
|
+
function zohoCrmCreateNotesForRecord(context) {
|
|
2022
|
+
const createNotesInstance = zohoCrmCreateNotes(context);
|
|
2798
2023
|
return input => {
|
|
2799
2024
|
const {
|
|
2800
2025
|
module: se_module,
|
|
@@ -2812,13 +2037,27 @@ function createNotesForRecord(context) {
|
|
|
2812
2037
|
};
|
|
2813
2038
|
}
|
|
2814
2039
|
|
|
2815
|
-
function
|
|
2816
|
-
return input => context.fetchJson(`/
|
|
2040
|
+
function zohoCrmCreateTagsForModule(context) {
|
|
2041
|
+
return input => context.fetchJson(`/v8/settings/tags?${fetch.makeUrlSearchParams({
|
|
2817
2042
|
module: input.module
|
|
2818
|
-
})}`,
|
|
2043
|
+
})}`, zohoCrmApiFetchJsonInput('POST', {
|
|
2819
2044
|
tags: util.asArray(input.tags)
|
|
2820
|
-
})).
|
|
2821
|
-
|
|
2045
|
+
})).catch(e => {
|
|
2046
|
+
let result;
|
|
2047
|
+
if (e instanceof ZohoServerFetchResponseError) {
|
|
2048
|
+
const tags = e.data?.tags;
|
|
2049
|
+
if (Array.isArray(tags)) {
|
|
2050
|
+
result = {
|
|
2051
|
+
tags
|
|
2052
|
+
};
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
2055
|
+
if (!result) {
|
|
2056
|
+
throw e;
|
|
2057
|
+
}
|
|
2058
|
+
return result;
|
|
2059
|
+
}).then(x => {
|
|
2060
|
+
const result = zohoCrmMultiRecordResult(util.asArray(input.tags), x.tags);
|
|
2822
2061
|
const {
|
|
2823
2062
|
included: duplicateErrorItems,
|
|
2824
2063
|
excluded: otherErrorItems
|
|
@@ -2833,19 +2072,32 @@ function createTagsForModule(context) {
|
|
|
2833
2072
|
};
|
|
2834
2073
|
});
|
|
2835
2074
|
}
|
|
2075
|
+
/**
|
|
2076
|
+
* Deletes a single tag by ID.
|
|
2077
|
+
*
|
|
2078
|
+
* Note: A tag cannot be deleted if it is associated with any configuration (e.g. Workflow Rules).
|
|
2079
|
+
*
|
|
2080
|
+
* https://www.zoho.com/crm/developer/docs/api/v8/delete-tag.html
|
|
2081
|
+
*
|
|
2082
|
+
* @param context
|
|
2083
|
+
* @returns
|
|
2084
|
+
*/
|
|
2085
|
+
function zohoCrmDeleteTag(context) {
|
|
2086
|
+
return input => context.fetchJson(`/v8/settings/tags/${input.id}`, zohoCrmApiFetchJsonInput('DELETE')).then(x => x.tags);
|
|
2087
|
+
}
|
|
2836
2088
|
/**
|
|
2837
2089
|
* Returns the list of tags within a module.
|
|
2838
2090
|
*
|
|
2839
|
-
* https://www.zoho.com/
|
|
2091
|
+
* https://www.zoho.com/crm/developer-guide/apiv2/get-tag-list.html
|
|
2840
2092
|
*
|
|
2841
2093
|
* @param context
|
|
2842
2094
|
* @returns
|
|
2843
2095
|
*/
|
|
2844
|
-
function
|
|
2845
|
-
return input => context.fetchJson(`/
|
|
2096
|
+
function zohoCrmGetTagsForModule(context) {
|
|
2097
|
+
return input => context.fetchJson(`/v8/settings/tags?${fetch.makeUrlSearchParams({
|
|
2846
2098
|
module: input.module,
|
|
2847
2099
|
my_tags: input.my_tags
|
|
2848
|
-
})}`,
|
|
2100
|
+
})}`, zohoCrmApiFetchJsonInput('GET')).then(x => {
|
|
2849
2101
|
// NOTE: This doesn't follow the api documentation, and instead is a normal page result except it has "tags" instead of "data".
|
|
2850
2102
|
return {
|
|
2851
2103
|
...x,
|
|
@@ -2853,209 +2105,74 @@ function getTagsForModule(context) {
|
|
|
2853
2105
|
};
|
|
2854
2106
|
});
|
|
2855
2107
|
}
|
|
2856
|
-
function
|
|
2857
|
-
return zohoFetchPageFactory(
|
|
2108
|
+
function zohoCrmGetTagsForModulePageFactory(context) {
|
|
2109
|
+
return zohoFetchPageFactory(zohoCrmGetTagsForModule(context));
|
|
2858
2110
|
}
|
|
2859
2111
|
// MARK: Add Tag To Record
|
|
2860
2112
|
/**
|
|
2861
|
-
* Limit enforced by Zoho
|
|
2113
|
+
* Limit enforced by Zoho Crm
|
|
2862
2114
|
*/
|
|
2863
|
-
const
|
|
2115
|
+
const ZOHO_CRM_ADD_TAGS_TO_RECORDS_MAX_IDS_ALLOWED = 100;
|
|
2864
2116
|
/**
|
|
2865
2117
|
* Adds one or more tags to one or more records.
|
|
2866
2118
|
*
|
|
2867
|
-
* https://www.zoho.com/
|
|
2119
|
+
* https://www.zoho.com/crm/developer-guide/apiv2/add-tags.html
|
|
2868
2120
|
*
|
|
2869
2121
|
* @param context
|
|
2870
2122
|
* @returns
|
|
2871
2123
|
*/
|
|
2872
|
-
function
|
|
2124
|
+
function zohoCrmAddTagsToRecords(context) {
|
|
2873
2125
|
return input => {
|
|
2874
|
-
|
|
2875
|
-
throw new Error(`Cannot add tags to more than ${ZOHO_RECRUIT_ADD_TAGS_TO_RECORDS_MAX_IDS_ALLOWED} records at once.`);
|
|
2876
|
-
}
|
|
2877
|
-
return context.fetchJson(`/v2/${ZOHO_RECRUIT_CANDIDATES_MODULE}/actions/add_tags?${fetch.makeUrlSearchParams({
|
|
2878
|
-
tag_names: input.tag_names,
|
|
2879
|
-
ids: input.ids
|
|
2880
|
-
})}`, zohoRecruitApiFetchJsonInput('POST')).then(x => {
|
|
2126
|
+
return context.fetchJson(`/v8/${input.module}/actions/add_tags`, zohoCrmApiFetchJsonInput('POST', zohoCrmAddTagsToRecordsRequestBody(input))).then(x => {
|
|
2881
2127
|
const resultInputMap = x.data.map(() => input); // assign "input" to each value for now
|
|
2882
|
-
return
|
|
2128
|
+
return zohoCrmMultiRecordResult(resultInputMap, x.data);
|
|
2129
|
+
});
|
|
2130
|
+
};
|
|
2131
|
+
}
|
|
2132
|
+
function zohoCrmAddTagsToRecordsRequestBody(input) {
|
|
2133
|
+
if (Array.isArray(input.ids) && input.ids.length > ZOHO_CRM_ADD_TAGS_TO_RECORDS_MAX_IDS_ALLOWED) {
|
|
2134
|
+
throw new Error(`Cannot add/remove tags from more than ${ZOHO_CRM_ADD_TAGS_TO_RECORDS_MAX_IDS_ALLOWED} records at once.`);
|
|
2135
|
+
}
|
|
2136
|
+
const tags = [...util.asArray(input.tags)];
|
|
2137
|
+
const tagNames = new Set(tags.map(x => x.name));
|
|
2138
|
+
if (input.tag_names) {
|
|
2139
|
+
util.asArray(input.tag_names).forEach(x => {
|
|
2140
|
+
if (!tagNames.has(x)) {
|
|
2141
|
+
tags.push({
|
|
2142
|
+
name: x
|
|
2143
|
+
});
|
|
2144
|
+
tagNames.add(x);
|
|
2145
|
+
}
|
|
2883
2146
|
});
|
|
2147
|
+
}
|
|
2148
|
+
return {
|
|
2149
|
+
tags,
|
|
2150
|
+
ids: util.asArray(input.ids)
|
|
2884
2151
|
};
|
|
2885
2152
|
}
|
|
2886
2153
|
// MARK: Remove Tag From Record
|
|
2887
2154
|
/**
|
|
2888
|
-
* Limit enforced by Zoho
|
|
2155
|
+
* Limit enforced by Zoho Crm
|
|
2889
2156
|
*/
|
|
2890
|
-
const
|
|
2157
|
+
const ZOHO_CRM_REMOVE_TAGS_FROM_RECORDS_MAX_IDS_ALLOWED = 100;
|
|
2891
2158
|
/**
|
|
2892
2159
|
* Removes one or more tags from one or more records.
|
|
2893
2160
|
*
|
|
2894
|
-
* https://www.zoho.com/
|
|
2161
|
+
* https://www.zoho.com/crm/developer-guide/apiv2/remove-tags.html
|
|
2895
2162
|
*
|
|
2896
2163
|
* @param context
|
|
2897
2164
|
* @returns
|
|
2898
2165
|
*/
|
|
2899
|
-
function
|
|
2166
|
+
function zohoCrmRemoveTagsFromRecords(context) {
|
|
2900
2167
|
return input => {
|
|
2901
|
-
|
|
2902
|
-
throw new Error(`Cannot remove tags from more than ${ZOHO_RECRUIT_REMOVE_TAGS_FROM_RECORDS_MAX_IDS_ALLOWED} records at once.`);
|
|
2903
|
-
}
|
|
2904
|
-
return context.fetchJson(`/v2/${ZOHO_RECRUIT_CANDIDATES_MODULE}/actions/remove_tags?${fetch.makeUrlSearchParams({
|
|
2905
|
-
tag_names: input.tag_names,
|
|
2906
|
-
ids: input.ids
|
|
2907
|
-
})}`, zohoRecruitApiFetchJsonInput('POST')).then(x => {
|
|
2168
|
+
return context.fetchJson(`/v8/${input.module}/actions/remove_tags`, zohoCrmApiFetchJsonInput('POST', zohoCrmAddTagsToRecordsRequestBody(input))).then(x => {
|
|
2908
2169
|
const resultInputMap = x.data.map(() => input); // assign "input" to each value for now
|
|
2909
|
-
return
|
|
2170
|
+
return zohoCrmMultiRecordResult(resultInputMap, x.data);
|
|
2910
2171
|
});
|
|
2911
2172
|
};
|
|
2912
2173
|
}
|
|
2913
2174
|
|
|
2914
|
-
|
|
2915
|
-
* Creates a ZohoRecruitSearchRecordsCriteriaEntryArray from an array of emails.
|
|
2916
|
-
*
|
|
2917
|
-
* @param emails Email or array of emails to search for.
|
|
2918
|
-
* @param field Optional field name to use. Defaults to 'Email'.
|
|
2919
|
-
* @returns Array of ZohoRecruitSearchRecordsCriteriaEntry
|
|
2920
|
-
*/
|
|
2921
|
-
function zohoRecruitSearchRecordsCriteriaEntriesForEmails(emails, field = 'Email') {
|
|
2922
|
-
const allEmails = util.asArray(emails);
|
|
2923
|
-
return allEmails.map(email => {
|
|
2924
|
-
const emailCriteria = {
|
|
2925
|
-
field,
|
|
2926
|
-
filter: 'equals',
|
|
2927
|
-
value: email
|
|
2928
|
-
};
|
|
2929
|
-
return emailCriteria;
|
|
2930
|
-
});
|
|
2931
|
-
}
|
|
2932
|
-
|
|
2933
|
-
/**
|
|
2934
|
-
* Error in the following cases:
|
|
2935
|
-
* - the refresh token string is invalid
|
|
2936
|
-
*/
|
|
2937
|
-
const ZOHO_ACCOUNTS_INVALID_CODE_ERROR_CODE = 'invalid_code';
|
|
2938
|
-
const ZOHO_ACCOUNTS_INVALID_CLIENT_ERROR_CODE = 'invalid_client';
|
|
2939
|
-
/**
|
|
2940
|
-
* Thrown if the call to the Zoho API creating an access token using a refresh token fails.
|
|
2941
|
-
*/
|
|
2942
|
-
class ZohoAccountsAccessTokenError extends fetch.FetchRequestFactoryError {
|
|
2943
|
-
constructor(errorCode) {
|
|
2944
|
-
super(`ZohoAccountsAccessTokenError: ${errorCode}`);
|
|
2945
|
-
this.errorCode = void 0;
|
|
2946
|
-
this.errorCode = errorCode;
|
|
2947
|
-
}
|
|
2948
|
-
}
|
|
2949
|
-
/**
|
|
2950
|
-
* Thrown if a valid ZohoAccessToken cannot be retrieved successfully.
|
|
2951
|
-
*/
|
|
2952
|
-
class ZohoAccountsAuthFailureError extends fetch.FetchRequestFactoryError {
|
|
2953
|
-
constructor(reason) {
|
|
2954
|
-
super(`Failed to retrieve proper authentication for the API call. Reason: ${reason}`);
|
|
2955
|
-
this.reason = void 0;
|
|
2956
|
-
this.reason = reason;
|
|
2957
|
-
}
|
|
2958
|
-
}
|
|
2959
|
-
const logZohoAccountsErrorToConsole = logZohoServerErrorFunction('ZohoAccounts');
|
|
2960
|
-
async function parseZohoAccountsError(responseError) {
|
|
2961
|
-
const data = await responseError.response.json().catch(x => undefined);
|
|
2962
|
-
let result;
|
|
2963
|
-
if (data) {
|
|
2964
|
-
result = parseZohoAccountsServerErrorResponseData(data, responseError);
|
|
2965
|
-
}
|
|
2966
|
-
return result;
|
|
2967
|
-
}
|
|
2968
|
-
function parseZohoAccountsServerErrorResponseData(errorResponseData, responseError) {
|
|
2969
|
-
let result;
|
|
2970
|
-
const error = errorResponseData.error;
|
|
2971
|
-
if (error) {
|
|
2972
|
-
const errorData = zohoServerErrorData(error);
|
|
2973
|
-
switch (errorData.code) {
|
|
2974
|
-
case ZOHO_ACCOUNTS_INVALID_CODE_ERROR_CODE:
|
|
2975
|
-
case ZOHO_ACCOUNTS_INVALID_CLIENT_ERROR_CODE:
|
|
2976
|
-
result = new ZohoAccountsAccessTokenError(errorData.code);
|
|
2977
|
-
break;
|
|
2978
|
-
default:
|
|
2979
|
-
result = parseZohoServerErrorResponseData(errorResponseData, responseError);
|
|
2980
|
-
break;
|
|
2981
|
-
}
|
|
2982
|
-
}
|
|
2983
|
-
return result;
|
|
2984
|
-
}
|
|
2985
|
-
const interceptZohoAccounts200StatusWithErrorResponse = interceptZohoErrorResponseFactory(parseZohoAccountsServerErrorResponseData);
|
|
2986
|
-
const handleZohoAccountsErrorFetch = handleZohoErrorFetchFactory(parseZohoAccountsError, logZohoAccountsErrorToConsole);
|
|
2987
|
-
|
|
2988
|
-
/**
|
|
2989
|
-
* Generates a new ZohoAccessTokenStringFactory.
|
|
2990
|
-
*/
|
|
2991
|
-
function zohoAccessTokenStringFactory(zohoAccessTokenFactory) {
|
|
2992
|
-
return async () => {
|
|
2993
|
-
const token = await zohoAccessTokenFactory();
|
|
2994
|
-
if (!token?.accessToken) {
|
|
2995
|
-
throw new ZohoAccountsAuthFailureError();
|
|
2996
|
-
}
|
|
2997
|
-
return token.accessToken;
|
|
2998
|
-
};
|
|
2999
|
-
}
|
|
3000
|
-
|
|
3001
|
-
const DEFAULT_ZOHO_RATE_LIMITED_TOO_MANY_REQUETS_LOG_FUNCTION = headers => {
|
|
3002
|
-
console.warn(`zohoRateLimitedFetchHandler(): Too many requests made. The limit is ${headers.limit} requests per reset period. Will be reset at ${headers.resetAt}.`);
|
|
3003
|
-
};
|
|
3004
|
-
function zohoRateLimitedFetchHandler(config) {
|
|
3005
|
-
const onTooManyRequests = config?.onTooManyRequests !== false ? config?.onTooManyRequests ?? DEFAULT_ZOHO_RATE_LIMITED_TOO_MANY_REQUETS_LOG_FUNCTION : undefined;
|
|
3006
|
-
const defaultLimit = config?.maxRateLimit ?? DEFAULT_ZOHO_API_RATE_LIMIT;
|
|
3007
|
-
const defaultResetPeriod = config?.resetPeriod ?? DEFAULT_ZOHO_API_RATE_LIMIT_RESET_PERIOD;
|
|
3008
|
-
function configForLimit(limit, resetAt) {
|
|
3009
|
-
return {
|
|
3010
|
-
limit: defaultLimit,
|
|
3011
|
-
startLimitAt: Math.ceil(limit / 10),
|
|
3012
|
-
// can do 10% of the requests of the limit before rate limiting begins
|
|
3013
|
-
cooldownRate: 1.2 * (limit / (defaultResetPeriod / util.MS_IN_SECOND)),
|
|
3014
|
-
exponentRate: 1.08,
|
|
3015
|
-
maxWaitTime: util.MS_IN_SECOND * 10,
|
|
3016
|
-
resetPeriod: defaultResetPeriod,
|
|
3017
|
-
resetAt
|
|
3018
|
-
};
|
|
3019
|
-
}
|
|
3020
|
-
const defaultConfig = configForLimit(defaultLimit);
|
|
3021
|
-
const rateLimiter = util.resetPeriodPromiseRateLimiter(defaultConfig);
|
|
3022
|
-
return fetch.rateLimitedFetchHandler({
|
|
3023
|
-
rateLimiter,
|
|
3024
|
-
updateWithResponse: function (response, fetchResponseError) {
|
|
3025
|
-
const hasLimitHeader = response.headers.has(ZOHO_RATE_LIMIT_REMAINING_HEADER);
|
|
3026
|
-
let shouldRetry = false;
|
|
3027
|
-
let enabled = false;
|
|
3028
|
-
if (hasLimitHeader) {
|
|
3029
|
-
const headerDetails = zohoRateLimitHeaderDetails(response.headers);
|
|
3030
|
-
if (headerDetails) {
|
|
3031
|
-
const {
|
|
3032
|
-
limit,
|
|
3033
|
-
resetAt,
|
|
3034
|
-
remaining
|
|
3035
|
-
} = headerDetails;
|
|
3036
|
-
if (limit !== defaultLimit) {
|
|
3037
|
-
const newConfig = configForLimit(limit, resetAt);
|
|
3038
|
-
rateLimiter.setConfig(newConfig, false);
|
|
3039
|
-
}
|
|
3040
|
-
rateLimiter.setRemainingLimit(remaining);
|
|
3041
|
-
rateLimiter.setNextResetAt(resetAt);
|
|
3042
|
-
enabled = true;
|
|
3043
|
-
// only retry if it's a TOO MANY REQUESTS error
|
|
3044
|
-
if (response.status === ZOHO_TOO_MANY_REQUESTS_HTTP_STATUS_CODE) {
|
|
3045
|
-
shouldRetry = true;
|
|
3046
|
-
try {
|
|
3047
|
-
onTooManyRequests?.(headerDetails, response, fetchResponseError);
|
|
3048
|
-
} catch (e) {}
|
|
3049
|
-
}
|
|
3050
|
-
}
|
|
3051
|
-
}
|
|
3052
|
-
rateLimiter.setEnabled(enabled);
|
|
3053
|
-
return shouldRetry;
|
|
3054
|
-
}
|
|
3055
|
-
});
|
|
3056
|
-
}
|
|
3057
|
-
|
|
3058
|
-
function zohoRecruitFactory(factoryConfig) {
|
|
2175
|
+
function zohoCrmFactory(factoryConfig) {
|
|
3059
2176
|
const {
|
|
3060
2177
|
accountsContext
|
|
3061
2178
|
} = factoryConfig;
|
|
@@ -3083,21 +2200,21 @@ function zohoRecruitFactory(factoryConfig) {
|
|
|
3083
2200
|
if (!config.apiUrl) {
|
|
3084
2201
|
throw new Error('ZohoConfig missing api url.');
|
|
3085
2202
|
}
|
|
3086
|
-
const apiUrl =
|
|
2203
|
+
const apiUrl = zohoCrmConfigApiUrl(config.apiUrl);
|
|
3087
2204
|
const baseFetch = fetchFactory({
|
|
3088
2205
|
apiUrl
|
|
3089
2206
|
});
|
|
3090
|
-
const fetch$1 =
|
|
2207
|
+
const fetch$1 = handleZohoCrmErrorFetch(baseFetch, logZohoServerErrorFunction, x => {
|
|
3091
2208
|
if (x instanceof ZohoInvalidTokenError) {
|
|
3092
2209
|
accountsContext.loadAccessToken.resetAccessToken();
|
|
3093
2210
|
}
|
|
3094
2211
|
});
|
|
3095
2212
|
const fetchJson = fetch.fetchJsonFunction(fetch$1, {
|
|
3096
|
-
interceptJsonResponse:
|
|
2213
|
+
interceptJsonResponse: interceptZohoCrm200StatusWithErrorResponse,
|
|
3097
2214
|
// intercept errors that return status 200
|
|
3098
2215
|
handleFetchJsonParseErrorFunction: fetch.returnNullHandleFetchJsonParseErrorFunction
|
|
3099
2216
|
});
|
|
3100
|
-
const
|
|
2217
|
+
const crmContext = {
|
|
3101
2218
|
fetch: fetch$1,
|
|
3102
2219
|
fetchJson,
|
|
3103
2220
|
accessTokenStringFactory,
|
|
@@ -3107,25 +2224,39 @@ function zohoRecruitFactory(factoryConfig) {
|
|
|
3107
2224
|
},
|
|
3108
2225
|
zohoRateLimiter: fetchHandler._rateLimiter
|
|
3109
2226
|
};
|
|
3110
|
-
const
|
|
3111
|
-
|
|
2227
|
+
const zohoCrm = {
|
|
2228
|
+
crmContext
|
|
3112
2229
|
};
|
|
3113
|
-
return
|
|
2230
|
+
return zohoCrm;
|
|
3114
2231
|
};
|
|
3115
2232
|
}
|
|
3116
2233
|
|
|
3117
2234
|
/**
|
|
3118
|
-
* Maximum length of
|
|
2235
|
+
* Maximum length of ZohoCrmTagName
|
|
3119
2236
|
*/
|
|
3120
|
-
const
|
|
2237
|
+
const ZOHO_CRM_TAG_NAME_MAX_LENGTH = 25;
|
|
3121
2238
|
|
|
3122
2239
|
/**
|
|
3123
2240
|
* Trades a refresh token for a new AccessToken
|
|
3124
2241
|
* @param context
|
|
3125
2242
|
* @returns
|
|
3126
2243
|
*/
|
|
3127
|
-
function
|
|
3128
|
-
return input =>
|
|
2244
|
+
function zohoAccountsAccessToken(context) {
|
|
2245
|
+
return input => {
|
|
2246
|
+
const {
|
|
2247
|
+
clientId: configClientId,
|
|
2248
|
+
clientSecret: configClientSecret,
|
|
2249
|
+
refreshToken: configRefreshToken
|
|
2250
|
+
} = context.config;
|
|
2251
|
+
const {
|
|
2252
|
+
client,
|
|
2253
|
+
refreshToken: inputRefreshToken
|
|
2254
|
+
} = input ?? {};
|
|
2255
|
+
const clientId = client?.clientId ?? configClientId;
|
|
2256
|
+
const clientSecret = client?.clientSecret ?? configClientSecret;
|
|
2257
|
+
const refreshToken = inputRefreshToken ?? configRefreshToken;
|
|
2258
|
+
return context.fetchJson(`/oauth/v2/token?grant_type=refresh_token&client_id=${clientId}&client_secret=${clientSecret}&refresh_token=${refreshToken}`, zohoAccountsApiFetchJsonInput('POST'));
|
|
2259
|
+
};
|
|
3129
2260
|
}
|
|
3130
2261
|
function zohoAccountsApiFetchJsonInput(method, body) {
|
|
3131
2262
|
const result = {
|
|
@@ -3192,7 +2323,7 @@ function zohoAccountsFactory(factoryConfig) {
|
|
|
3192
2323
|
api_domain,
|
|
3193
2324
|
scope,
|
|
3194
2325
|
expires_in
|
|
3195
|
-
} = await
|
|
2326
|
+
} = await zohoAccountsAccessToken(accountsContext)();
|
|
3196
2327
|
const result = {
|
|
3197
2328
|
accessToken: access_token,
|
|
3198
2329
|
apiDomain: api_domain,
|
|
@@ -3298,10 +2429,26 @@ function zohoDateTimeString(date) {
|
|
|
3298
2429
|
exports.DEFAULT_ZOHO_API_RATE_LIMIT = DEFAULT_ZOHO_API_RATE_LIMIT;
|
|
3299
2430
|
exports.DEFAULT_ZOHO_API_RATE_LIMIT_RESET_PERIOD = DEFAULT_ZOHO_API_RATE_LIMIT_RESET_PERIOD;
|
|
3300
2431
|
exports.DEFAULT_ZOHO_RATE_LIMITED_TOO_MANY_REQUETS_LOG_FUNCTION = DEFAULT_ZOHO_RATE_LIMITED_TOO_MANY_REQUETS_LOG_FUNCTION;
|
|
2432
|
+
exports.MAX_ZOHO_CRM_SEARCH_MODULE_RECORDS_CRITERIA = MAX_ZOHO_CRM_SEARCH_MODULE_RECORDS_CRITERIA;
|
|
3301
2433
|
exports.MAX_ZOHO_RECRUIT_SEARCH_MODULE_RECORDS_CRITERIA = MAX_ZOHO_RECRUIT_SEARCH_MODULE_RECORDS_CRITERIA;
|
|
3302
2434
|
exports.ZOHO_ACCOUNTS_INVALID_CLIENT_ERROR_CODE = ZOHO_ACCOUNTS_INVALID_CLIENT_ERROR_CODE;
|
|
3303
2435
|
exports.ZOHO_ACCOUNTS_INVALID_CODE_ERROR_CODE = ZOHO_ACCOUNTS_INVALID_CODE_ERROR_CODE;
|
|
3304
2436
|
exports.ZOHO_ACCOUNTS_US_API_URL = ZOHO_ACCOUNTS_US_API_URL;
|
|
2437
|
+
exports.ZOHO_CRM_ADD_TAGS_TO_RECORDS_MAX_IDS_ALLOWED = ZOHO_CRM_ADD_TAGS_TO_RECORDS_MAX_IDS_ALLOWED;
|
|
2438
|
+
exports.ZOHO_CRM_ALREADY_ASSOCIATED_ERROR_CODE = ZOHO_CRM_ALREADY_ASSOCIATED_ERROR_CODE;
|
|
2439
|
+
exports.ZOHO_CRM_ATTACHMENTS_MODULE = ZOHO_CRM_ATTACHMENTS_MODULE;
|
|
2440
|
+
exports.ZOHO_CRM_ATTACHMENT_MAX_SIZE = ZOHO_CRM_ATTACHMENT_MAX_SIZE;
|
|
2441
|
+
exports.ZOHO_CRM_CONTACTS_MODULE = ZOHO_CRM_CONTACTS_MODULE;
|
|
2442
|
+
exports.ZOHO_CRM_CRUD_FUNCTION_MAX_RECORDS_LIMIT = ZOHO_CRM_CRUD_FUNCTION_MAX_RECORDS_LIMIT;
|
|
2443
|
+
exports.ZOHO_CRM_EMAILS_MODULE = ZOHO_CRM_EMAILS_MODULE;
|
|
2444
|
+
exports.ZOHO_CRM_LEADS_MODULE = ZOHO_CRM_LEADS_MODULE;
|
|
2445
|
+
exports.ZOHO_CRM_NOTES_MODULE = ZOHO_CRM_NOTES_MODULE;
|
|
2446
|
+
exports.ZOHO_CRM_RECORD_ATTACHMENT_METADATA_ATTACH_TYPE_RESUME = ZOHO_CRM_RECORD_ATTACHMENT_METADATA_ATTACH_TYPE_RESUME;
|
|
2447
|
+
exports.ZOHO_CRM_REMOVE_TAGS_FROM_RECORDS_MAX_IDS_ALLOWED = ZOHO_CRM_REMOVE_TAGS_FROM_RECORDS_MAX_IDS_ALLOWED;
|
|
2448
|
+
exports.ZOHO_CRM_SERVICE_NAME = ZOHO_CRM_SERVICE_NAME;
|
|
2449
|
+
exports.ZOHO_CRM_TAG_NAME_MAX_LENGTH = ZOHO_CRM_TAG_NAME_MAX_LENGTH;
|
|
2450
|
+
exports.ZOHO_CRM_TASKS_MODULE = ZOHO_CRM_TASKS_MODULE;
|
|
2451
|
+
exports.ZOHO_DATA_ARRAY_BLANK_ERROR_CODE = ZOHO_DATA_ARRAY_BLANK_ERROR_CODE;
|
|
3305
2452
|
exports.ZOHO_DUPLICATE_DATA_ERROR_CODE = ZOHO_DUPLICATE_DATA_ERROR_CODE;
|
|
3306
2453
|
exports.ZOHO_ERROR_STATUS = ZOHO_ERROR_STATUS;
|
|
3307
2454
|
exports.ZOHO_FAILURE_ERROR_CODE = ZOHO_FAILURE_ERROR_CODE;
|
|
@@ -3333,6 +2480,13 @@ exports.ZOHO_TOO_MANY_REQUESTS_ERROR_CODE = ZOHO_TOO_MANY_REQUESTS_ERROR_CODE;
|
|
|
3333
2480
|
exports.ZOHO_TOO_MANY_REQUESTS_HTTP_STATUS_CODE = ZOHO_TOO_MANY_REQUESTS_HTTP_STATUS_CODE;
|
|
3334
2481
|
exports.ZohoAccountsAccessTokenError = ZohoAccountsAccessTokenError;
|
|
3335
2482
|
exports.ZohoAccountsAuthFailureError = ZohoAccountsAuthFailureError;
|
|
2483
|
+
exports.ZohoCrmExecuteRestApiFunctionError = ZohoCrmExecuteRestApiFunctionError;
|
|
2484
|
+
exports.ZohoCrmRecordCrudDuplicateDataError = ZohoCrmRecordCrudDuplicateDataError;
|
|
2485
|
+
exports.ZohoCrmRecordCrudError = ZohoCrmRecordCrudError;
|
|
2486
|
+
exports.ZohoCrmRecordCrudInvalidDataError = ZohoCrmRecordCrudInvalidDataError;
|
|
2487
|
+
exports.ZohoCrmRecordCrudMandatoryFieldNotFoundError = ZohoCrmRecordCrudMandatoryFieldNotFoundError;
|
|
2488
|
+
exports.ZohoCrmRecordCrudNoMatchingRecordError = ZohoCrmRecordCrudNoMatchingRecordError;
|
|
2489
|
+
exports.ZohoCrmRecordNoContentError = ZohoCrmRecordNoContentError;
|
|
3336
2490
|
exports.ZohoInternalError = ZohoInternalError;
|
|
3337
2491
|
exports.ZohoInvalidAuthorizationError = ZohoInvalidAuthorizationError;
|
|
3338
2492
|
exports.ZohoInvalidQueryError = ZohoInvalidQueryError;
|
|
@@ -3345,12 +2499,13 @@ exports.ZohoRecruitRecordCrudMandatoryFieldNotFoundError = ZohoRecruitRecordCrud
|
|
|
3345
2499
|
exports.ZohoRecruitRecordCrudNoMatchingRecordError = ZohoRecruitRecordCrudNoMatchingRecordError;
|
|
3346
2500
|
exports.ZohoRecruitRecordNoContentError = ZohoRecruitRecordNoContentError;
|
|
3347
2501
|
exports.ZohoServerError = ZohoServerError;
|
|
2502
|
+
exports.ZohoServerFetchResponseDataArrayError = ZohoServerFetchResponseDataArrayError;
|
|
3348
2503
|
exports.ZohoServerFetchResponseError = ZohoServerFetchResponseError;
|
|
3349
2504
|
exports.ZohoTooManyRequestsError = ZohoTooManyRequestsError;
|
|
3350
|
-
exports.accessToken = accessToken;
|
|
3351
2505
|
exports.addTagsToRecords = addTagsToRecords;
|
|
3352
2506
|
exports.assertRecordDataArrayResultHasContent = assertRecordDataArrayResultHasContent;
|
|
3353
|
-
exports.
|
|
2507
|
+
exports.assertZohoCrmRecordDataArrayResultHasContent = assertZohoCrmRecordDataArrayResultHasContent;
|
|
2508
|
+
exports.assertZohoRecruitRecordDataArrayResultHasContent = assertZohoRecruitRecordDataArrayResultHasContent;
|
|
3354
2509
|
exports.createNotes = createNotes;
|
|
3355
2510
|
exports.createNotesForRecord = createNotesForRecord;
|
|
3356
2511
|
exports.createTagsForModule = createTagsForModule;
|
|
@@ -3359,7 +2514,7 @@ exports.deleteNotes = deleteNotes;
|
|
|
3359
2514
|
exports.deleteRecord = deleteRecord;
|
|
3360
2515
|
exports.downloadAttachmentForRecord = downloadAttachmentForRecord;
|
|
3361
2516
|
exports.emptyZohoPageResult = emptyZohoPageResult;
|
|
3362
|
-
exports.
|
|
2517
|
+
exports.escapeZohoCrmFieldValueForCriteriaString = escapeZohoCrmFieldValueForCriteriaString;
|
|
3363
2518
|
exports.executeRestApiFunction = executeRestApiFunction;
|
|
3364
2519
|
exports.getAttachmentsForRecord = getAttachmentsForRecord;
|
|
3365
2520
|
exports.getAttachmentsForRecordPageFactory = getAttachmentsForRecordPageFactory;
|
|
@@ -3373,28 +2528,30 @@ exports.getRelatedRecordsFunctionFactory = getRelatedRecordsFunctionFactory;
|
|
|
3373
2528
|
exports.getTagsForModule = getTagsForModule;
|
|
3374
2529
|
exports.getTagsForModulePageFactory = getTagsForModulePageFactory;
|
|
3375
2530
|
exports.handleZohoAccountsErrorFetch = handleZohoAccountsErrorFetch;
|
|
2531
|
+
exports.handleZohoCrmErrorFetch = handleZohoCrmErrorFetch;
|
|
3376
2532
|
exports.handleZohoErrorFetchFactory = handleZohoErrorFetchFactory;
|
|
3377
2533
|
exports.handleZohoRecruitErrorFetch = handleZohoRecruitErrorFetch;
|
|
3378
2534
|
exports.insertRecord = insertRecord;
|
|
3379
2535
|
exports.interceptZohoAccounts200StatusWithErrorResponse = interceptZohoAccounts200StatusWithErrorResponse;
|
|
2536
|
+
exports.interceptZohoCrm200StatusWithErrorResponse = interceptZohoCrm200StatusWithErrorResponse;
|
|
3380
2537
|
exports.interceptZohoErrorResponseFactory = interceptZohoErrorResponseFactory;
|
|
3381
2538
|
exports.interceptZohoRecruit200StatusWithErrorResponse = interceptZohoRecruit200StatusWithErrorResponse;
|
|
2539
|
+
exports.isZohoCrmValidUrl = isZohoCrmValidUrl;
|
|
3382
2540
|
exports.isZohoRecruitValidUrl = isZohoRecruitValidUrl;
|
|
2541
|
+
exports.isZohoServerErrorResponseDataArrayRef = isZohoServerErrorResponseDataArrayRef;
|
|
3383
2542
|
exports.logZohoAccountsErrorToConsole = logZohoAccountsErrorToConsole;
|
|
2543
|
+
exports.logZohoCrmErrorToConsole = logZohoCrmErrorToConsole;
|
|
3384
2544
|
exports.logZohoRecruitErrorToConsole = logZohoRecruitErrorToConsole;
|
|
3385
2545
|
exports.logZohoServerErrorFunction = logZohoServerErrorFunction;
|
|
3386
2546
|
exports.parseZohoAccountsError = parseZohoAccountsError;
|
|
3387
2547
|
exports.parseZohoAccountsServerErrorResponseData = parseZohoAccountsServerErrorResponseData;
|
|
2548
|
+
exports.parseZohoCrmError = parseZohoCrmError;
|
|
2549
|
+
exports.parseZohoCrmServerErrorResponseData = parseZohoCrmServerErrorResponseData;
|
|
3388
2550
|
exports.parseZohoRecruitError = parseZohoRecruitError;
|
|
3389
2551
|
exports.parseZohoRecruitServerErrorResponseData = parseZohoRecruitServerErrorResponseData;
|
|
3390
2552
|
exports.parseZohoServerErrorResponseData = parseZohoServerErrorResponseData;
|
|
3391
2553
|
exports.removeTagsFromRecords = removeTagsFromRecords;
|
|
3392
2554
|
exports.safeZohoDateTimeString = safeZohoDateTimeString;
|
|
3393
|
-
exports.searchAssociatedRecords = searchAssociatedRecords;
|
|
3394
|
-
exports.searchCandidateAssociatedJobOpeningRecords = searchCandidateAssociatedJobOpeningRecords;
|
|
3395
|
-
exports.searchCandidateAssociatedJobOpeningRecordsPageFactory = searchCandidateAssociatedJobOpeningRecordsPageFactory;
|
|
3396
|
-
exports.searchJobOpeningAssociatedCandidateRecords = searchJobOpeningAssociatedCandidateRecords;
|
|
3397
|
-
exports.searchJobOpeningAssociatedCandidateRecordsPageFactory = searchJobOpeningAssociatedCandidateRecordsPageFactory;
|
|
3398
2555
|
exports.searchRecords = searchRecords;
|
|
3399
2556
|
exports.searchRecordsPageFactory = searchRecordsPageFactory;
|
|
3400
2557
|
exports.tryFindZohoServerErrorData = tryFindZohoServerErrorData;
|
|
@@ -3402,24 +2559,99 @@ exports.updateRecord = updateRecord;
|
|
|
3402
2559
|
exports.uploadAttachmentForRecord = uploadAttachmentForRecord;
|
|
3403
2560
|
exports.upsertRecord = upsertRecord;
|
|
3404
2561
|
exports.zohoAccessTokenStringFactory = zohoAccessTokenStringFactory;
|
|
2562
|
+
exports.zohoAccountsAccessToken = zohoAccountsAccessToken;
|
|
3405
2563
|
exports.zohoAccountsApiFetchJsonInput = zohoAccountsApiFetchJsonInput;
|
|
3406
2564
|
exports.zohoAccountsConfigApiUrl = zohoAccountsConfigApiUrl;
|
|
3407
2565
|
exports.zohoAccountsFactory = zohoAccountsFactory;
|
|
3408
2566
|
exports.zohoAccountsZohoAccessTokenFactory = zohoAccountsZohoAccessTokenFactory;
|
|
2567
|
+
exports.zohoCrmAddTagsToRecords = zohoCrmAddTagsToRecords;
|
|
2568
|
+
exports.zohoCrmAddTagsToRecordsRequestBody = zohoCrmAddTagsToRecordsRequestBody;
|
|
2569
|
+
exports.zohoCrmApiFetchJsonInput = zohoCrmApiFetchJsonInput;
|
|
2570
|
+
exports.zohoCrmCatchZohoCrmChangeObjectLikeResponseError = zohoCrmCatchZohoCrmChangeObjectLikeResponseError;
|
|
2571
|
+
exports.zohoCrmChangeObjectLikeResponseSuccessAndErrorPairs = zohoCrmChangeObjectLikeResponseSuccessAndErrorPairs;
|
|
2572
|
+
exports.zohoCrmConfigApiUrl = zohoCrmConfigApiUrl;
|
|
2573
|
+
exports.zohoCrmCreateNotes = zohoCrmCreateNotes;
|
|
2574
|
+
exports.zohoCrmCreateNotesForRecord = zohoCrmCreateNotesForRecord;
|
|
2575
|
+
exports.zohoCrmCreateTagsForModule = zohoCrmCreateTagsForModule;
|
|
2576
|
+
exports.zohoCrmDeleteAttachmentFromRecord = zohoCrmDeleteAttachmentFromRecord;
|
|
2577
|
+
exports.zohoCrmDeleteNotes = zohoCrmDeleteNotes;
|
|
2578
|
+
exports.zohoCrmDeleteRecord = zohoCrmDeleteRecord;
|
|
2579
|
+
exports.zohoCrmDeleteTag = zohoCrmDeleteTag;
|
|
2580
|
+
exports.zohoCrmDownloadAttachmentForRecord = zohoCrmDownloadAttachmentForRecord;
|
|
2581
|
+
exports.zohoCrmExecuteRestApiFunction = zohoCrmExecuteRestApiFunction;
|
|
2582
|
+
exports.zohoCrmFactory = zohoCrmFactory;
|
|
2583
|
+
exports.zohoCrmGetAttachmentsForRecord = zohoCrmGetAttachmentsForRecord;
|
|
2584
|
+
exports.zohoCrmGetAttachmentsForRecordPageFactory = zohoCrmGetAttachmentsForRecordPageFactory;
|
|
2585
|
+
exports.zohoCrmGetEmailsForRecord = zohoCrmGetEmailsForRecord;
|
|
2586
|
+
exports.zohoCrmGetEmailsForRecordPageFactory = zohoCrmGetEmailsForRecordPageFactory;
|
|
2587
|
+
exports.zohoCrmGetNotesForRecord = zohoCrmGetNotesForRecord;
|
|
2588
|
+
exports.zohoCrmGetNotesForRecordPageFactory = zohoCrmGetNotesForRecordPageFactory;
|
|
2589
|
+
exports.zohoCrmGetRecordById = zohoCrmGetRecordById;
|
|
2590
|
+
exports.zohoCrmGetRecords = zohoCrmGetRecords;
|
|
2591
|
+
exports.zohoCrmGetRelatedRecordsFunctionFactory = zohoCrmGetRelatedRecordsFunctionFactory;
|
|
2592
|
+
exports.zohoCrmGetTagsForModule = zohoCrmGetTagsForModule;
|
|
2593
|
+
exports.zohoCrmGetTagsForModulePageFactory = zohoCrmGetTagsForModulePageFactory;
|
|
2594
|
+
exports.zohoCrmInsertRecord = zohoCrmInsertRecord;
|
|
2595
|
+
exports.zohoCrmMultiRecordResult = zohoCrmMultiRecordResult;
|
|
2596
|
+
exports.zohoCrmRecordCrudError = zohoCrmRecordCrudError;
|
|
2597
|
+
exports.zohoCrmRemoveTagsFromRecords = zohoCrmRemoveTagsFromRecords;
|
|
2598
|
+
exports.zohoCrmSearchRecords = zohoCrmSearchRecords;
|
|
2599
|
+
exports.zohoCrmSearchRecordsCriteriaEntryToCriteriaString = zohoCrmSearchRecordsCriteriaEntryToCriteriaString;
|
|
2600
|
+
exports.zohoCrmSearchRecordsCriteriaString = zohoCrmSearchRecordsCriteriaString;
|
|
2601
|
+
exports.zohoCrmSearchRecordsCriteriaStringForTree = zohoCrmSearchRecordsCriteriaStringForTree;
|
|
2602
|
+
exports.zohoCrmSearchRecordsPageFactory = zohoCrmSearchRecordsPageFactory;
|
|
2603
|
+
exports.zohoCrmUpdateRecord = zohoCrmUpdateRecord;
|
|
2604
|
+
exports.zohoCrmUploadAttachmentForRecord = zohoCrmUploadAttachmentForRecord;
|
|
2605
|
+
exports.zohoCrmUpsertRecord = zohoCrmUpsertRecord;
|
|
2606
|
+
exports.zohoCrmUrlSearchParams = zohoCrmUrlSearchParams;
|
|
2607
|
+
exports.zohoCrmUrlSearchParamsMinusIdAndModule = zohoCrmUrlSearchParamsMinusIdAndModule;
|
|
2608
|
+
exports.zohoCrmUrlSearchParamsMinusModule = zohoCrmUrlSearchParamsMinusModule;
|
|
3409
2609
|
exports.zohoDateTimeString = zohoDateTimeString;
|
|
3410
2610
|
exports.zohoFetchPageFactory = zohoFetchPageFactory;
|
|
3411
2611
|
exports.zohoRateLimitHeaderDetails = zohoRateLimitHeaderDetails;
|
|
3412
2612
|
exports.zohoRateLimitedFetchHandler = zohoRateLimitedFetchHandler;
|
|
2613
|
+
exports.zohoRecruitAddTagsToRecords = zohoRecruitAddTagsToRecords;
|
|
3413
2614
|
exports.zohoRecruitApiFetchJsonInput = zohoRecruitApiFetchJsonInput;
|
|
2615
|
+
exports.zohoRecruitAssociateCandidateRecordsWithJobOpenings = zohoRecruitAssociateCandidateRecordsWithJobOpenings;
|
|
3414
2616
|
exports.zohoRecruitChangeObjectLikeResponseSuccessAndErrorPairs = zohoRecruitChangeObjectLikeResponseSuccessAndErrorPairs;
|
|
3415
2617
|
exports.zohoRecruitConfigApiUrl = zohoRecruitConfigApiUrl;
|
|
2618
|
+
exports.zohoRecruitCreateNotes = zohoRecruitCreateNotes;
|
|
2619
|
+
exports.zohoRecruitCreateNotesForRecord = zohoRecruitCreateNotesForRecord;
|
|
2620
|
+
exports.zohoRecruitCreateTagsForModule = zohoRecruitCreateTagsForModule;
|
|
2621
|
+
exports.zohoRecruitDeleteAttachmentFromRecord = zohoRecruitDeleteAttachmentFromRecord;
|
|
2622
|
+
exports.zohoRecruitDeleteNotes = zohoRecruitDeleteNotes;
|
|
2623
|
+
exports.zohoRecruitDeleteRecord = zohoRecruitDeleteRecord;
|
|
2624
|
+
exports.zohoRecruitDownloadAttachmentForRecord = zohoRecruitDownloadAttachmentForRecord;
|
|
2625
|
+
exports.zohoRecruitExecuteRestApiFunction = zohoRecruitExecuteRestApiFunction;
|
|
3416
2626
|
exports.zohoRecruitFactory = zohoRecruitFactory;
|
|
2627
|
+
exports.zohoRecruitGetAttachmentsForRecord = zohoRecruitGetAttachmentsForRecord;
|
|
2628
|
+
exports.zohoRecruitGetAttachmentsForRecordPageFactory = zohoRecruitGetAttachmentsForRecordPageFactory;
|
|
2629
|
+
exports.zohoRecruitGetEmailsForRecord = zohoRecruitGetEmailsForRecord;
|
|
2630
|
+
exports.zohoRecruitGetEmailsForRecordPageFactory = zohoRecruitGetEmailsForRecordPageFactory;
|
|
2631
|
+
exports.zohoRecruitGetNotesForRecord = zohoRecruitGetNotesForRecord;
|
|
2632
|
+
exports.zohoRecruitGetNotesForRecordPageFactory = zohoRecruitGetNotesForRecordPageFactory;
|
|
2633
|
+
exports.zohoRecruitGetRecordById = zohoRecruitGetRecordById;
|
|
2634
|
+
exports.zohoRecruitGetRecords = zohoRecruitGetRecords;
|
|
2635
|
+
exports.zohoRecruitGetRelatedRecordsFunctionFactory = zohoRecruitGetRelatedRecordsFunctionFactory;
|
|
2636
|
+
exports.zohoRecruitGetTagsForModule = zohoRecruitGetTagsForModule;
|
|
2637
|
+
exports.zohoRecruitGetTagsForModulePageFactory = zohoRecruitGetTagsForModulePageFactory;
|
|
2638
|
+
exports.zohoRecruitInsertRecord = zohoRecruitInsertRecord;
|
|
3417
2639
|
exports.zohoRecruitMultiRecordResult = zohoRecruitMultiRecordResult;
|
|
3418
2640
|
exports.zohoRecruitRecordCrudError = zohoRecruitRecordCrudError;
|
|
3419
|
-
exports.
|
|
2641
|
+
exports.zohoRecruitRemoveTagsFromRecords = zohoRecruitRemoveTagsFromRecords;
|
|
2642
|
+
exports.zohoRecruitSearchAssociatedRecords = zohoRecruitSearchAssociatedRecords;
|
|
2643
|
+
exports.zohoRecruitSearchCandidateAssociatedJobOpeningRecords = zohoRecruitSearchCandidateAssociatedJobOpeningRecords;
|
|
2644
|
+
exports.zohoRecruitSearchCandidateAssociatedJobOpeningRecordsPageFactory = zohoRecruitSearchCandidateAssociatedJobOpeningRecordsPageFactory;
|
|
2645
|
+
exports.zohoRecruitSearchJobOpeningAssociatedCandidateRecords = zohoRecruitSearchJobOpeningAssociatedCandidateRecords;
|
|
2646
|
+
exports.zohoRecruitSearchJobOpeningAssociatedCandidateRecordsPageFactory = zohoRecruitSearchJobOpeningAssociatedCandidateRecordsPageFactory;
|
|
2647
|
+
exports.zohoRecruitSearchRecords = zohoRecruitSearchRecords;
|
|
3420
2648
|
exports.zohoRecruitSearchRecordsCriteriaEntryToCriteriaString = zohoRecruitSearchRecordsCriteriaEntryToCriteriaString;
|
|
3421
2649
|
exports.zohoRecruitSearchRecordsCriteriaString = zohoRecruitSearchRecordsCriteriaString;
|
|
3422
2650
|
exports.zohoRecruitSearchRecordsCriteriaStringForTree = zohoRecruitSearchRecordsCriteriaStringForTree;
|
|
2651
|
+
exports.zohoRecruitSearchRecordsPageFactory = zohoRecruitSearchRecordsPageFactory;
|
|
2652
|
+
exports.zohoRecruitUpdateRecord = zohoRecruitUpdateRecord;
|
|
2653
|
+
exports.zohoRecruitUploadAttachmentForRecord = zohoRecruitUploadAttachmentForRecord;
|
|
2654
|
+
exports.zohoRecruitUpsertRecord = zohoRecruitUpsertRecord;
|
|
3423
2655
|
exports.zohoRecruitUrlSearchParams = zohoRecruitUrlSearchParams;
|
|
3424
2656
|
exports.zohoRecruitUrlSearchParamsMinusIdAndModule = zohoRecruitUrlSearchParamsMinusIdAndModule;
|
|
3425
2657
|
exports.zohoRecruitUrlSearchParamsMinusModule = zohoRecruitUrlSearchParamsMinusModule;
|