@dereekb/zoho 13.0.6 → 13.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +2164 -231
- package/index.esm.js +2143 -232
- package/nestjs/LICENSE +21 -0
- package/nestjs/README.md +11 -0
- package/nestjs/docs/configuration.md +165 -0
- package/nestjs/docs/crm-getting-started.md +296 -0
- package/nestjs/index.cjs.js +653 -5
- package/nestjs/index.esm.js +647 -7
- package/nestjs/package.json +3 -3
- package/nestjs/src/lib/crm/crm.api.d.ts +46 -0
- package/nestjs/src/lib/crm/crm.config.d.ts +16 -1
- package/nestjs/src/lib/crm/crm.module.d.ts +77 -8
- package/nestjs/src/lib/index.d.ts +2 -0
- package/nestjs/src/lib/recruit/recruit.api.d.ts +50 -0
- package/nestjs/src/lib/recruit/recruit.config.d.ts +16 -1
- package/nestjs/src/lib/recruit/recruit.module.d.ts +77 -8
- package/nestjs/src/lib/sign/index.d.ts +3 -0
- package/nestjs/src/lib/sign/sign.api.d.ts +54 -0
- package/nestjs/src/lib/sign/sign.config.d.ts +10 -0
- package/nestjs/src/lib/sign/sign.module.d.ts +94 -0
- package/package.json +2 -2
- package/src/lib/accounts/accounts.api.d.ts +149 -3
- package/src/lib/accounts/accounts.factory.d.ts +73 -6
- package/src/lib/crm/crm.api.d.ts +599 -62
- package/src/lib/crm/crm.api.notes.d.ts +46 -3
- package/src/lib/crm/crm.api.tags.d.ts +65 -2
- package/src/lib/crm/crm.config.d.ts +30 -0
- package/src/lib/crm/crm.criteria.d.ts +60 -3
- package/src/lib/crm/crm.error.api.d.ts +42 -0
- package/src/lib/crm/crm.factory.d.ts +39 -3
- package/src/lib/crm/crm.notes.d.ts +36 -0
- package/src/lib/crm/crm.tags.d.ts +3 -0
- package/src/lib/index.d.ts +1 -0
- package/src/lib/recruit/recruit.api.candidates.d.ts +44 -3
- package/src/lib/recruit/recruit.api.d.ts +719 -57
- package/src/lib/recruit/recruit.api.notes.d.ts +140 -0
- package/src/lib/recruit/recruit.api.tags.d.ts +122 -14
- package/src/lib/recruit/recruit.config.d.ts +30 -0
- package/src/lib/recruit/recruit.criteria.d.ts +55 -3
- package/src/lib/recruit/recruit.error.api.d.ts +39 -0
- package/src/lib/recruit/recruit.factory.d.ts +39 -3
- package/src/lib/recruit/recruit.notes.d.ts +21 -0
- package/src/lib/recruit/recruit.tags.d.ts +3 -0
- package/src/lib/shared/criteria.d.ts +95 -11
- package/src/lib/shared/criteria.util.d.ts +19 -4
- package/src/lib/sign/index.d.ts +6 -0
- package/src/lib/sign/sign.api.d.ts +397 -0
- package/src/lib/sign/sign.api.page.d.ts +109 -0
- package/src/lib/sign/sign.config.d.ts +24 -0
- package/src/lib/sign/sign.d.ts +225 -0
- package/src/lib/sign/sign.error.api.d.ts +7 -0
- package/src/lib/sign/sign.factory.d.ts +58 -0
- package/src/lib/zoho.api.page.d.ts +41 -10
- package/src/lib/zoho.config.d.ts +24 -9
- package/src/lib/zoho.limit.d.ts +41 -9
- package/src/lib/zoho.type.d.ts +24 -8
package/src/lib/crm/crm.api.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { type FetchFileResponse, type FetchJsonBody, type FetchJsonInput, type F
|
|
|
3
3
|
import { type ZohoCrmConfigApiUrlInput, type ZohoCrmContext } from './crm.config';
|
|
4
4
|
import { type ZohoCrmCommaSeparateFieldNames, type ZohoCrmCustomViewId, type ZohoCrmDraftOrSaveState, type ZohoCrmFieldName, type ZohoCrmModuleNameRef, type ZohoCrmChangeObjectDetails, type ZohoCrmRecord, type ZohoCrmRecordId, type ZohoCrmTerritoryId, type ZohoCrmTrueFalseBoth, type ZohoCrmRestFunctionApiName, type ZohoCrmUserId, type ZohoCrmModuleName, type ZohoCrmRecordEmailMetadata, type ZohoCrmRecordAttachmentMetadata, type ZohoCrmAttachmentRecordId, type ZohoCrmAttachmentCategoryId, type KnownZohoCrmAttachmentCategoryName } from './crm';
|
|
5
5
|
import { type ZohoCrmSearchRecordsCriteriaTreeElement } from './crm.criteria';
|
|
6
|
-
import { type ArrayOrValue, type EmailAddress, type Maybe, type PhoneNumber, type SortingOrder, type UniqueModelWithId
|
|
6
|
+
import { type ArrayOrValue, type EmailAddress, type Maybe, type PhoneNumber, type SortingOrder, type UniqueModelWithId } from '@dereekb/util';
|
|
7
7
|
import { type ZohoServerErrorDataWithDetails, type ZohoServerErrorStatus, type ZohoServerSuccessCode, type ZohoServerSuccessStatus } from '../zoho.error.api';
|
|
8
8
|
import { type ZohoDateTimeString } from '../zoho.type';
|
|
9
9
|
import { BaseError } from 'make-error';
|
|
@@ -13,47 +13,140 @@ import { BaseError } from 'make-error';
|
|
|
13
13
|
* This is a limit enforced by the Zoho Crm API
|
|
14
14
|
*/
|
|
15
15
|
export declare const ZOHO_CRM_CRUD_FUNCTION_MAX_RECORDS_LIMIT = 100;
|
|
16
|
+
/**
|
|
17
|
+
* Paired success/error results from a multi-record update, upsert, or insert operation.
|
|
18
|
+
*/
|
|
16
19
|
export type ZohoCrmUpdateRecordResult<T> = ZohoCrmMultiRecordResult<T, ZohoCrmChangeObjectResponseSuccessEntry, ZohoCrmChangeObjectResponseErrorEntry>;
|
|
20
|
+
/**
|
|
21
|
+
* Raw API response from a record change operation containing the data array.
|
|
22
|
+
*/
|
|
17
23
|
export type ZohoCrmUpdateRecordResponse = ZohoCrmChangeObjectResponse;
|
|
24
|
+
/**
|
|
25
|
+
* Record data for creation, excluding the `id` field since it is assigned by Zoho.
|
|
26
|
+
*/
|
|
18
27
|
export type ZohoCrmCreateRecordData<T> = Omit<T, 'id'>;
|
|
28
|
+
/**
|
|
29
|
+
* Input for creating a single record in a CRM module.
|
|
30
|
+
*/
|
|
19
31
|
export interface ZohoCrmCreateSingleRecordInput<T> extends ZohoCrmModuleNameRef {
|
|
20
32
|
readonly data: ZohoCrmCreateRecordData<T>;
|
|
21
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Input for creating multiple records in a CRM module in a single API call.
|
|
36
|
+
*/
|
|
22
37
|
export interface ZohoCrmCreateMultiRecordInput<T> extends ZohoCrmModuleNameRef {
|
|
23
38
|
readonly data: ZohoCrmCreateRecordData<T>[];
|
|
24
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Overloaded function type that handles both single and multi-record creation.
|
|
42
|
+
*/
|
|
25
43
|
export type ZohoCrmCreateRecordLikeFunction = ZohoCrmCreateMultiRecordFunction & ZohoCrmCreateSingleRecordFunction;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a single record and resolves with the created record's details.
|
|
46
|
+
*/
|
|
26
47
|
export type ZohoCrmCreateSingleRecordFunction = <T>(input: ZohoCrmCreateSingleRecordInput<T>) => Promise<ZohoCrmChangeObjectDetails>;
|
|
48
|
+
/**
|
|
49
|
+
* Creates multiple records and resolves with paired success/error results.
|
|
50
|
+
*/
|
|
27
51
|
export type ZohoCrmCreateMultiRecordFunction = <T>(input: ZohoCrmCreateMultiRecordInput<T>) => Promise<ZohoCrmUpdateRecordResult<T>>;
|
|
52
|
+
/**
|
|
53
|
+
* Discriminated input for updating one or more records.
|
|
54
|
+
*/
|
|
28
55
|
export type ZohoCrmUpdateRecordInput<T> = ZohoCrmUpdateSingleRecordInput<T> | ZohoCrmUpdateMultiRecordInput<T>;
|
|
56
|
+
/**
|
|
57
|
+
* Partial record data for updates, requiring the `id` to identify the target record.
|
|
58
|
+
*/
|
|
29
59
|
export type ZohoCrmUpdateRecordData<T> = UniqueModelWithId & Partial<T>;
|
|
60
|
+
/**
|
|
61
|
+
* Input for updating a single record in a CRM module.
|
|
62
|
+
*/
|
|
30
63
|
export interface ZohoCrmUpdateSingleRecordInput<T> extends ZohoCrmModuleNameRef {
|
|
31
64
|
readonly data: ZohoCrmUpdateRecordData<T>;
|
|
32
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Input for updating multiple records in a CRM module in a single API call.
|
|
68
|
+
*/
|
|
33
69
|
export interface ZohoCrmUpdateMultiRecordInput<T> extends ZohoCrmModuleNameRef {
|
|
34
70
|
readonly data: ZohoCrmUpdateRecordData<T>[];
|
|
35
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Overloaded function type that handles both single and multi-record updates.
|
|
74
|
+
*/
|
|
36
75
|
export type ZohoCrmUpdateRecordLikeFunction = ZohoCrmUpdateMultiRecordFunction & ZohoCrmUpdateSingleRecordFunction;
|
|
76
|
+
/**
|
|
77
|
+
* Updates multiple records and resolves with paired success/error results.
|
|
78
|
+
*/
|
|
37
79
|
export type ZohoCrmUpdateMultiRecordFunction = <T>(input: ZohoCrmUpdateMultiRecordInput<T>) => Promise<ZohoCrmUpdateRecordResult<T>>;
|
|
80
|
+
/**
|
|
81
|
+
* Updates a single record and resolves with the updated record's details.
|
|
82
|
+
*/
|
|
38
83
|
export type ZohoCrmUpdateSingleRecordFunction = <T>(input: ZohoCrmUpdateSingleRecordInput<T>) => Promise<ZohoCrmChangeObjectDetails>;
|
|
84
|
+
/**
|
|
85
|
+
* Record data for upsert, accepting either create data (without `id`) or update data (with `id`).
|
|
86
|
+
*/
|
|
39
87
|
export type ZohoCrmUpsertRecordData<T> = ZohoCrmCreateRecordData<T> | ZohoCrmUpdateRecordData<T>;
|
|
88
|
+
/**
|
|
89
|
+
* Input for upserting a single record in a CRM module.
|
|
90
|
+
*/
|
|
40
91
|
export interface ZohoCrmUpsertSingleRecordInput<T> extends ZohoCrmModuleNameRef {
|
|
41
92
|
readonly data: ZohoCrmUpsertRecordData<T>;
|
|
42
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Input for upserting multiple records in a CRM module in a single API call.
|
|
96
|
+
*/
|
|
43
97
|
export interface ZohoCrmUpsertMultiRecordInput<T> extends ZohoCrmModuleNameRef {
|
|
44
98
|
readonly data: ZohoCrmUpsertRecordData<T>[];
|
|
45
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Overloaded function type that handles both single and multi-record upserts.
|
|
102
|
+
*/
|
|
46
103
|
export type ZohoCrmUpsertRecordLikeFunction = ZohoCrmUpsertMultiRecordFunction & ZohoCrmUpsertSingleRecordFunction;
|
|
104
|
+
/**
|
|
105
|
+
* Upserts multiple records and resolves with paired success/error results.
|
|
106
|
+
*/
|
|
47
107
|
export type ZohoCrmUpsertMultiRecordFunction = <T>(input: ZohoCrmUpsertMultiRecordInput<T>) => Promise<ZohoCrmUpdateRecordResult<T>>;
|
|
108
|
+
/**
|
|
109
|
+
* Upserts a single record and resolves with the record's details.
|
|
110
|
+
*/
|
|
48
111
|
export type ZohoCrmUpsertSingleRecordFunction = <T>(input: ZohoCrmUpsertSingleRecordInput<T>) => Promise<ZohoCrmChangeObjectDetails>;
|
|
112
|
+
/**
|
|
113
|
+
* Alias for the insert record function, supporting both single and multi-record creation.
|
|
114
|
+
*/
|
|
49
115
|
export type ZohoCrmInsertRecordFunction = ZohoCrmCreateRecordLikeFunction;
|
|
50
116
|
/**
|
|
51
|
-
*
|
|
117
|
+
* Creates a {@link ZohoCrmInsertRecordFunction} bound to the given context.
|
|
118
|
+
*
|
|
119
|
+
* Inserts one or more records into a CRM module. When a single record is
|
|
120
|
+
* provided, returns the {@link ZohoCrmChangeObjectDetails} directly or
|
|
121
|
+
* throws on error. When multiple records are provided, returns a
|
|
122
|
+
* {@link ZohoCrmUpdateRecordResult} with paired success/error arrays.
|
|
123
|
+
*
|
|
124
|
+
* Maximum of {@link ZOHO_CRM_CRUD_FUNCTION_MAX_RECORDS_LIMIT} records per call.
|
|
125
|
+
*
|
|
126
|
+
* @param context - Authenticated Zoho CRM context providing fetch and rate limiting
|
|
127
|
+
* @returns Function that inserts records into the specified module
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* const insertRecord = zohoCrmInsertRecord(context);
|
|
132
|
+
*
|
|
133
|
+
* // Single record — returns details directly or throws on error:
|
|
134
|
+
* const details = await insertRecord({
|
|
135
|
+
* module: 'Contacts',
|
|
136
|
+
* data: { First_Name: 'Jane', Last_Name: 'Doe', Email: 'jane@example.com' }
|
|
137
|
+
* });
|
|
52
138
|
*
|
|
53
|
-
*
|
|
139
|
+
* // Multiple records — returns paired success/error arrays:
|
|
140
|
+
* const result = await insertRecord({
|
|
141
|
+
* module: 'Contacts',
|
|
142
|
+
* data: [
|
|
143
|
+
* { First_Name: 'Jane', Last_Name: 'Doe', Email: 'jane@example.com' },
|
|
144
|
+
* { First_Name: 'John', Last_Name: 'Doe', Email: 'john@example.com' }
|
|
145
|
+
* ]
|
|
146
|
+
* });
|
|
147
|
+
* ```
|
|
54
148
|
*
|
|
55
|
-
* @
|
|
56
|
-
* @returns
|
|
149
|
+
* @see https://www.zoho.com/crm/developer-guide/apiv2/insert-records.html
|
|
57
150
|
*/
|
|
58
151
|
export declare function zohoCrmInsertRecord(context: ZohoCrmContext): ZohoCrmInsertRecordFunction;
|
|
59
152
|
/**
|
|
@@ -61,61 +154,181 @@ export declare function zohoCrmInsertRecord(context: ZohoCrmContext): ZohoCrmIns
|
|
|
61
154
|
*/
|
|
62
155
|
export type ZohoCrmUpsertRecordFunction = ZohoCrmUpsertRecordLikeFunction;
|
|
63
156
|
/**
|
|
64
|
-
*
|
|
157
|
+
* Creates a {@link ZohoCrmUpsertRecordFunction} bound to the given context.
|
|
65
158
|
*
|
|
66
|
-
*
|
|
159
|
+
* Inserts or updates one or more records in a CRM module based on whether
|
|
160
|
+
* each record includes an `id`. Uses the `/upsert` endpoint. Single-record
|
|
161
|
+
* calls return details directly or throw; multi-record calls return paired
|
|
162
|
+
* success/error arrays.
|
|
67
163
|
*
|
|
68
|
-
* @
|
|
69
|
-
*
|
|
164
|
+
* Maximum of {@link ZOHO_CRM_CRUD_FUNCTION_MAX_RECORDS_LIMIT} records per call.
|
|
165
|
+
*
|
|
166
|
+
* @param context - Authenticated Zoho CRM context providing fetch and rate limiting
|
|
167
|
+
* @returns Function that upserts records in the specified module
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* const upsertRecord = zohoCrmUpsertRecord(context);
|
|
172
|
+
*
|
|
173
|
+
* // Create (no id) — returns details directly:
|
|
174
|
+
* const created = await upsertRecord({
|
|
175
|
+
* module: 'Contacts',
|
|
176
|
+
* data: { Email: 'new@example.com', Last_Name: 'New' }
|
|
177
|
+
* });
|
|
178
|
+
*
|
|
179
|
+
* // Update (with id) — returns details directly:
|
|
180
|
+
* const updated = await upsertRecord({
|
|
181
|
+
* module: 'Contacts',
|
|
182
|
+
* data: { id: existingId, First_Name: 'Updated' }
|
|
183
|
+
* });
|
|
184
|
+
*
|
|
185
|
+
* // Mixed create and update — returns paired arrays:
|
|
186
|
+
* const result = await upsertRecord({
|
|
187
|
+
* module: 'Contacts',
|
|
188
|
+
* data: [
|
|
189
|
+
* { Email: 'create@example.com', Last_Name: 'Create' },
|
|
190
|
+
* { id: existingId, First_Name: 'Update' }
|
|
191
|
+
* ]
|
|
192
|
+
* });
|
|
193
|
+
* ```
|
|
194
|
+
*
|
|
195
|
+
* @see https://www.zoho.com/crm/developer-guide/apiv2/upsert-records.html
|
|
70
196
|
*/
|
|
71
197
|
export declare function zohoCrmUpsertRecord(context: ZohoCrmContext): ZohoCrmUpsertRecordFunction;
|
|
198
|
+
/**
|
|
199
|
+
* Alias for the update record function, supporting both single and multi-record updates.
|
|
200
|
+
*/
|
|
72
201
|
export type ZohoCrmUpdateRecordFunction = ZohoCrmUpdateRecordLikeFunction;
|
|
73
202
|
/**
|
|
74
|
-
*
|
|
203
|
+
* Creates a {@link ZohoCrmUpdateRecordFunction} bound to the given context.
|
|
204
|
+
*
|
|
205
|
+
* Updates one or more existing records in a CRM module. Each record must
|
|
206
|
+
* include an `id` field. Single-record calls return details directly or throw;
|
|
207
|
+
* multi-record calls return paired success/error arrays.
|
|
208
|
+
*
|
|
209
|
+
* Maximum of {@link ZOHO_CRM_CRUD_FUNCTION_MAX_RECORDS_LIMIT} records per call.
|
|
210
|
+
*
|
|
211
|
+
* @param context - Authenticated Zoho CRM context providing fetch and rate limiting
|
|
212
|
+
* @returns Function that updates records in the specified module
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* const updateRecord = zohoCrmUpdateRecord(context);
|
|
75
217
|
*
|
|
76
|
-
*
|
|
218
|
+
* // Single record — returns details directly:
|
|
219
|
+
* const details = await updateRecord({
|
|
220
|
+
* module: 'Contacts',
|
|
221
|
+
* data: { id: recordId, First_Name: 'Updated Name' }
|
|
222
|
+
* });
|
|
77
223
|
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
224
|
+
* // Multiple records — returns paired arrays:
|
|
225
|
+
* const result = await updateRecord({
|
|
226
|
+
* module: 'Contacts',
|
|
227
|
+
* data: [
|
|
228
|
+
* { id: recordId1, First_Name: 'Updated 1' },
|
|
229
|
+
* { id: recordId2, First_Name: 'Updated 2' }
|
|
230
|
+
* ]
|
|
231
|
+
* });
|
|
232
|
+
* ```
|
|
233
|
+
*
|
|
234
|
+
* @see https://www.zoho.com/crm/developer-guide/apiv2/update-records.html
|
|
80
235
|
*/
|
|
81
236
|
export declare function zohoCrmUpdateRecord(context: ZohoCrmContext): ZohoCrmUpdateRecordFunction;
|
|
237
|
+
/**
|
|
238
|
+
* Function that deletes one or more records from a module.
|
|
239
|
+
*/
|
|
82
240
|
export type ZohoCrmDeleteRecordFunction = (input: ZohoCrmDeleteRecordInput) => Promise<ZohoCrmDeleteRecordResponse>;
|
|
241
|
+
/**
|
|
242
|
+
* Input for deleting records from a module.
|
|
243
|
+
*/
|
|
83
244
|
export interface ZohoCrmDeleteRecordInput extends ZohoCrmModuleNameRef {
|
|
84
245
|
/**
|
|
85
246
|
* Id or array of ids to delete.
|
|
86
247
|
*/
|
|
87
248
|
readonly ids: ArrayOrValue<ZohoCrmRecordId>;
|
|
249
|
+
/**
|
|
250
|
+
* Whether to trigger workflow rules on deletion.
|
|
251
|
+
*/
|
|
88
252
|
readonly wf_trigger?: boolean;
|
|
89
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* Successful entry in a delete response, containing the deleted record's id.
|
|
256
|
+
*/
|
|
90
257
|
export interface ZohoCrmDeleteRecordResponseSuccessEntry extends ZohoCrmChangeObjectLikeResponseSuccessEntryMeta {
|
|
91
258
|
readonly details: {
|
|
92
259
|
readonly id: ZohoCrmRecordId;
|
|
93
260
|
};
|
|
94
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* Response from a delete operation, split into success and error pairs.
|
|
264
|
+
*/
|
|
95
265
|
export type ZohoCrmDeleteRecordResponse = ZohoCrmChangeObjectLikeResponseSuccessAndErrorPairs<ZohoCrmDeleteRecordResponseSuccessEntry>;
|
|
266
|
+
/**
|
|
267
|
+
* Array of successful delete entries.
|
|
268
|
+
*/
|
|
96
269
|
export type ZohoCrmDeleteRecordResult = ZohoCrmChangeObjectResponseSuccessEntry[];
|
|
97
270
|
/**
|
|
98
|
-
*
|
|
271
|
+
* Creates a {@link ZohoCrmDeleteRecordFunction} bound to the given context.
|
|
272
|
+
*
|
|
273
|
+
* Deletes one or more records from a CRM module by their IDs. Supports
|
|
274
|
+
* an optional `wf_trigger` flag to execute workflow rules on deletion. Returns
|
|
275
|
+
* a response with separated success and error entries.
|
|
276
|
+
*
|
|
277
|
+
* @param context - Authenticated Zoho CRM context providing fetch and rate limiting
|
|
278
|
+
* @returns Function that deletes records from the specified module
|
|
99
279
|
*
|
|
100
|
-
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```typescript
|
|
282
|
+
* const deleteRecord = zohoCrmDeleteRecord(context);
|
|
101
283
|
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
284
|
+
* const result = await deleteRecord({
|
|
285
|
+
* module: 'Contacts',
|
|
286
|
+
* ids: contactId
|
|
287
|
+
* });
|
|
288
|
+
* ```
|
|
289
|
+
*
|
|
290
|
+
* @see https://www.zoho.com/crm/developer-guide/apiv2/delete-records.html
|
|
104
291
|
*/
|
|
105
292
|
export declare function zohoCrmDeleteRecord(context: ZohoCrmContext): ZohoCrmDeleteRecordFunction;
|
|
293
|
+
/**
|
|
294
|
+
* Input identifying a specific record by module and id.
|
|
295
|
+
*/
|
|
106
296
|
export interface ZohoCrmGetRecordByIdInput extends ZohoCrmModuleNameRef {
|
|
107
297
|
readonly id: ZohoCrmRecordId;
|
|
108
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* Raw API response wrapping the record in a data array.
|
|
301
|
+
*/
|
|
109
302
|
export type ZohoCrmGetRecordByIdResponse<T = ZohoCrmRecord> = ZohoDataArrayResultRef<T>;
|
|
303
|
+
/**
|
|
304
|
+
* The unwrapped record returned from a get-by-id call.
|
|
305
|
+
*/
|
|
110
306
|
export type ZohoCrmGetRecordByIdResult<T = ZohoCrmRecord> = T;
|
|
307
|
+
/**
|
|
308
|
+
* Retrieves a single record by id and resolves with the unwrapped record.
|
|
309
|
+
*/
|
|
111
310
|
export type ZohoCrmGetRecordByIdFunction = <T = ZohoCrmRecord>(input: ZohoCrmGetRecordByIdInput) => Promise<ZohoCrmGetRecordByIdResult<T>>;
|
|
112
311
|
/**
|
|
113
|
-
*
|
|
312
|
+
* Creates a {@link ZohoCrmGetRecordByIdFunction} bound to the given context.
|
|
114
313
|
*
|
|
115
|
-
*
|
|
314
|
+
* Retrieves a single record from a CRM module by its ID. The response is
|
|
315
|
+
* unwrapped from the standard data array, returning the record directly.
|
|
316
|
+
* Throws if the record is not found.
|
|
116
317
|
*
|
|
117
|
-
* @param context
|
|
118
|
-
* @returns
|
|
318
|
+
* @param context - Authenticated Zoho CRM context providing fetch and rate limiting
|
|
319
|
+
* @returns Function that retrieves a record by module name and ID
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* ```typescript
|
|
323
|
+
* const getRecordById = zohoCrmGetRecordById(context);
|
|
324
|
+
*
|
|
325
|
+
* const record = await getRecordById({
|
|
326
|
+
* module: 'Contacts',
|
|
327
|
+
* id: contactId
|
|
328
|
+
* });
|
|
329
|
+
* ```
|
|
330
|
+
*
|
|
331
|
+
* @see https://www.zoho.com/crm/developer-guide/apiv2/get-records.html
|
|
119
332
|
*/
|
|
120
333
|
export declare function zohoCrmGetRecordById(context: ZohoCrmContext): ZohoCrmGetRecordByIdFunction;
|
|
121
334
|
export interface ZohoCrmGetRecordsPageFilter extends ZohoPageFilter {
|
|
@@ -136,12 +349,27 @@ export interface ZohoCrmGetRecordsInput extends ZohoCrmModuleNameRef, ZohoCrmGet
|
|
|
136
349
|
export type ZohoCrmGetRecordsResponse<T = ZohoCrmRecord> = ZohoPageResult<T>;
|
|
137
350
|
export type ZohoCrmGetRecordsFunction = <T = ZohoCrmRecord>(input: ZohoCrmGetRecordsInput) => Promise<ZohoCrmGetRecordsResponse<T>>;
|
|
138
351
|
/**
|
|
139
|
-
*
|
|
352
|
+
* Creates a {@link ZohoCrmGetRecordsFunction} bound to the given context.
|
|
353
|
+
*
|
|
354
|
+
* Retrieves a paginated list of records from a CRM module. Supports field
|
|
355
|
+
* selection, sorting, custom view filtering, territory filtering, and
|
|
356
|
+
* conversion/approval status filters via {@link ZohoCrmGetRecordsInput}.
|
|
357
|
+
*
|
|
358
|
+
* @param context - Authenticated Zoho CRM context providing fetch and rate limiting
|
|
359
|
+
* @returns Function that retrieves paginated records from a module
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* ```typescript
|
|
363
|
+
* const getRecords = zohoCrmGetRecords(context);
|
|
140
364
|
*
|
|
141
|
-
*
|
|
365
|
+
* const page = await getRecords({
|
|
366
|
+
* module: 'Contacts',
|
|
367
|
+
* fields: 'First_Name,Last_Name,Email',
|
|
368
|
+
* per_page: 10
|
|
369
|
+
* });
|
|
370
|
+
* ```
|
|
142
371
|
*
|
|
143
|
-
* @
|
|
144
|
-
* @returns
|
|
372
|
+
* @see https://www.zoho.com/crm/developer-guide/apiv2/get-records.html
|
|
145
373
|
*/
|
|
146
374
|
export declare function zohoCrmGetRecords(context: ZohoCrmContext): ZohoCrmGetRecordsFunction;
|
|
147
375
|
/**
|
|
@@ -159,15 +387,65 @@ export interface ZohoCrmSearchRecordsInput<T = ZohoCrmRecord> extends ZohoCrmMod
|
|
|
159
387
|
export type ZohoCrmSearchRecordsResponse<T = ZohoCrmRecord> = ZohoCrmGetRecordsResponse<T>;
|
|
160
388
|
export type ZohoCrmSearchRecordsFunction = <T = ZohoCrmRecord>(input: ZohoCrmSearchRecordsInput<T>) => Promise<ZohoCrmSearchRecordsResponse<T>>;
|
|
161
389
|
/**
|
|
162
|
-
*
|
|
390
|
+
* Creates a {@link ZohoCrmSearchRecordsFunction} bound to the given context.
|
|
163
391
|
*
|
|
164
|
-
*
|
|
392
|
+
* Searches records in a CRM module using one of: criteria tree (compiled
|
|
393
|
+
* via {@link zohoCrmSearchRecordsCriteriaString}), email, phone, cvid, or keyword.
|
|
394
|
+
* At least one search parameter must be provided. Returns a paginated result,
|
|
395
|
+
* defaulting to an empty data array when no matches are found.
|
|
165
396
|
*
|
|
166
|
-
* @param context
|
|
167
|
-
* @returns
|
|
397
|
+
* @param context - Authenticated Zoho CRM context providing fetch and rate limiting
|
|
398
|
+
* @returns Function that searches records in the specified module
|
|
399
|
+
* @throws {Error} If none of `criteria`, `email`, `phone`, `cvid`, or `word` are provided
|
|
400
|
+
*
|
|
401
|
+
* @example
|
|
402
|
+
* ```typescript
|
|
403
|
+
* const searchRecords = zohoCrmSearchRecords(context);
|
|
404
|
+
*
|
|
405
|
+
* // Search by criteria:
|
|
406
|
+
* const result = await searchRecords({
|
|
407
|
+
* module: 'Contacts',
|
|
408
|
+
* criteria: [{ field: 'Last_Name', filter: 'starts_with', value: 'Smith' }],
|
|
409
|
+
* per_page: 10
|
|
410
|
+
* });
|
|
411
|
+
*
|
|
412
|
+
* // Search by keyword:
|
|
413
|
+
* const wordResult = await searchRecords({
|
|
414
|
+
* module: 'Contacts',
|
|
415
|
+
* word: 'engineer'
|
|
416
|
+
* });
|
|
417
|
+
* ```
|
|
418
|
+
*
|
|
419
|
+
* @see https://www.zoho.com/crm/developer-guide/apiv2/search-records.html
|
|
168
420
|
*/
|
|
169
421
|
export declare function zohoCrmSearchRecords(context: ZohoCrmContext): ZohoCrmSearchRecordsFunction;
|
|
422
|
+
/**
|
|
423
|
+
* Factory that creates paginated search iterators for search record queries.
|
|
424
|
+
*/
|
|
170
425
|
export type ZohoCrmSearchRecordsPageFactory = <T = ZohoCrmRecord>(input: ZohoCrmSearchRecordsInput<T>, options?: Maybe<FetchPageFactoryOptions<ZohoCrmSearchRecordsInput<T>, ZohoCrmSearchRecordsResponse<T>>>) => FetchPage<ZohoCrmSearchRecordsInput<T>, ZohoCrmSearchRecordsResponse<T>>;
|
|
426
|
+
/**
|
|
427
|
+
* Creates a {@link ZohoCrmSearchRecordsPageFactory} bound to the given context.
|
|
428
|
+
*
|
|
429
|
+
* Returns a page factory that automatically handles Zoho CRM's pagination,
|
|
430
|
+
* making it easy to iterate through all search results across multiple pages.
|
|
431
|
+
*
|
|
432
|
+
* @param context - Authenticated Zoho CRM context providing fetch and rate limiting
|
|
433
|
+
* @returns Page factory for iterating over search results
|
|
434
|
+
*
|
|
435
|
+
* @example
|
|
436
|
+
* ```typescript
|
|
437
|
+
* const pageFactory = zohoCrmSearchRecordsPageFactory(context);
|
|
438
|
+
*
|
|
439
|
+
* const fetchPage = pageFactory({
|
|
440
|
+
* module: 'Contacts',
|
|
441
|
+
* criteria: [{ field: 'Last_Name', filter: 'starts_with', value: 'Smith' }],
|
|
442
|
+
* per_page: 5
|
|
443
|
+
* });
|
|
444
|
+
*
|
|
445
|
+
* const firstPage = await fetchPage.fetchNext();
|
|
446
|
+
* const secondPage = await firstPage.fetchNext();
|
|
447
|
+
* ```
|
|
448
|
+
*/
|
|
171
449
|
export declare function zohoCrmSearchRecordsPageFactory(context: ZohoCrmContext): ZohoCrmSearchRecordsPageFactory;
|
|
172
450
|
export interface ZohoCrmGetRelatedRecordsFunctionConfig {
|
|
173
451
|
readonly targetModule: ZohoCrmModuleName;
|
|
@@ -200,12 +478,33 @@ export interface ZohoCrmGetRelatedRecordsRequestWithFields extends ZohoCrmGetRel
|
|
|
200
478
|
export type ZohoCrmGetRelatedRecordsResponse<T = ZohoCrmRecord> = ZohoPageResult<T>;
|
|
201
479
|
export type ZohoCrmGetRelatedRecordsFunction<T = ZohoCrmRecord> = (input: ZohoCrmGetRelatedRecordsRequest) => Promise<ZohoCrmGetRelatedRecordsResponse<T>>;
|
|
202
480
|
/**
|
|
203
|
-
* Creates a ZohoCrmGetRelatedRecordsFunctionFactory
|
|
481
|
+
* Creates a {@link ZohoCrmGetRelatedRecordsFunctionFactory} bound to the given context.
|
|
482
|
+
*
|
|
483
|
+
* Returns a factory that produces typed functions for fetching related records
|
|
484
|
+
* (e.g. Notes, Emails, Attachments) of a specific target module. The factory
|
|
485
|
+
* accepts a {@link ZohoCrmGetRelatedRecordsFunctionConfig} to specify the
|
|
486
|
+
* target module and empty-result behavior. By default, returns an empty page
|
|
487
|
+
* result instead of null when no records are found.
|
|
488
|
+
*
|
|
489
|
+
* @param context - Authenticated Zoho CRM context providing fetch and rate limiting
|
|
490
|
+
* @returns Factory that creates typed related-records retrieval functions
|
|
204
491
|
*
|
|
205
|
-
*
|
|
492
|
+
* @example
|
|
493
|
+
* ```typescript
|
|
494
|
+
* const factory = zohoCrmGetRelatedRecordsFunctionFactory(context);
|
|
206
495
|
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
496
|
+
* // Create a typed function for fetching related Notes:
|
|
497
|
+
* const getNotesForRecord = factory<ZohoCrmRecordNote>({
|
|
498
|
+
* targetModule: ZOHO_CRM_NOTES_MODULE
|
|
499
|
+
* });
|
|
500
|
+
*
|
|
501
|
+
* const notes = await getNotesForRecord({
|
|
502
|
+
* module: 'Contacts',
|
|
503
|
+
* id: contactId
|
|
504
|
+
* });
|
|
505
|
+
* ```
|
|
506
|
+
*
|
|
507
|
+
* @see https://www.zoho.com/crm/developer-guide/apiv2/get-related-records.html
|
|
209
508
|
*/
|
|
210
509
|
export declare function zohoCrmGetRelatedRecordsFunctionFactory(context: ZohoCrmContext): ZohoCrmGetRelatedRecordsFunctionFactory;
|
|
211
510
|
/**
|
|
@@ -231,14 +530,136 @@ export type ZohoCrmGetEmailsForRecordFunction = (input: ZohoCrmGetEmailsForRecor
|
|
|
231
530
|
export type ZohoCrmGetEmailsForRecordRawApiResponse = Omit<ZohoCrmGetEmailsForRecordResponse, 'data'> & {
|
|
232
531
|
Emails: ZohoCrmGetEmailsForRecordResponse['data'];
|
|
233
532
|
};
|
|
533
|
+
/**
|
|
534
|
+
* Creates a {@link ZohoCrmGetEmailsForRecordFunction} bound to the given context.
|
|
535
|
+
*
|
|
536
|
+
* Retrieves email metadata related to a specific record by targeting the
|
|
537
|
+
* Emails module via the related records API. Normalizes the Zoho API response
|
|
538
|
+
* which returns email data under an `Emails` key instead of the standard `data` key.
|
|
539
|
+
* Returns a paginated result of {@link ZohoCrmRecordEmailMetadata} entries.
|
|
540
|
+
*
|
|
541
|
+
* @param context - Authenticated Zoho CRM context providing fetch and rate limiting
|
|
542
|
+
* @returns Function that retrieves emails for a record
|
|
543
|
+
*
|
|
544
|
+
* @example
|
|
545
|
+
* ```typescript
|
|
546
|
+
* const getEmailsForRecord = zohoCrmGetEmailsForRecord(context);
|
|
547
|
+
*
|
|
548
|
+
* const result = await getEmailsForRecord({
|
|
549
|
+
* id: contactId,
|
|
550
|
+
* module: 'Contacts'
|
|
551
|
+
* });
|
|
552
|
+
* ```
|
|
553
|
+
*
|
|
554
|
+
* @see https://www.zoho.com/crm/developer/docs/api/v8/get-email-rel-list.html
|
|
555
|
+
*/
|
|
234
556
|
export declare function zohoCrmGetEmailsForRecord(context: ZohoCrmContext): ZohoCrmGetEmailsForRecordFunction;
|
|
557
|
+
/**
|
|
558
|
+
* Factory that creates paginated iterators for fetching emails related to a record.
|
|
559
|
+
*/
|
|
235
560
|
export type ZohoCrmGetEmailsForRecordPageFactory = FetchPageFactory<ZohoCrmGetEmailsForRecordRequest, ZohoCrmGetEmailsForRecordResponse>;
|
|
561
|
+
/**
|
|
562
|
+
* Creates a {@link ZohoCrmGetEmailsForRecordPageFactory} bound to the given context.
|
|
563
|
+
*
|
|
564
|
+
* Returns a page factory for iterating over emails related to a record across
|
|
565
|
+
* multiple pages. Wraps {@link zohoCrmGetEmailsForRecord} with automatic
|
|
566
|
+
* pagination handling via {@link zohoFetchPageFactory}.
|
|
567
|
+
*
|
|
568
|
+
* @param context - Authenticated Zoho CRM context providing fetch and rate limiting
|
|
569
|
+
* @returns Page factory for iterating over record emails
|
|
570
|
+
*
|
|
571
|
+
* @example
|
|
572
|
+
* ```typescript
|
|
573
|
+
* const pageFactory = zohoCrmGetEmailsForRecordPageFactory(context);
|
|
574
|
+
*
|
|
575
|
+
* const fetchPage = pageFactory({
|
|
576
|
+
* id: contactId,
|
|
577
|
+
* module: 'Contacts',
|
|
578
|
+
* per_page: 5
|
|
579
|
+
* });
|
|
580
|
+
*
|
|
581
|
+
* const firstPage = await fetchPage.fetchNext();
|
|
582
|
+
*
|
|
583
|
+
* if (firstPage.result.info.more_records) {
|
|
584
|
+
* const secondPage = await firstPage.fetchNext();
|
|
585
|
+
* }
|
|
586
|
+
* ```
|
|
587
|
+
*
|
|
588
|
+
* @see https://www.zoho.com/crm/developer/docs/api/v8/get-email-rel-list.html
|
|
589
|
+
*/
|
|
236
590
|
export declare function zohoCrmGetEmailsForRecordPageFactory(context: ZohoCrmContext): ZohoCrmGetEmailsForRecordPageFactory;
|
|
591
|
+
/**
|
|
592
|
+
* Request for fetching attachments, requiring fields to select from the attachment metadata.
|
|
593
|
+
*/
|
|
237
594
|
export type ZohoCrmGetAttachmentsForRecordRequest = ZohoCrmGetRelatedRecordsRequest & ZohoCrmGetRecordsFieldsRef;
|
|
595
|
+
/**
|
|
596
|
+
* Paginated response containing attachment metadata records.
|
|
597
|
+
*/
|
|
238
598
|
export type ZohoCrmGetAttachmentsForRecordResponse = ZohoPageResult<ZohoCrmRecordAttachmentMetadata>;
|
|
599
|
+
/**
|
|
600
|
+
* Fetches attachment metadata for a given record.
|
|
601
|
+
*/
|
|
239
602
|
export type ZohoCrmGetAttachmentsForRecordFunction = (input: ZohoCrmGetAttachmentsForRecordRequest) => Promise<ZohoCrmGetAttachmentsForRecordResponse>;
|
|
603
|
+
/**
|
|
604
|
+
* Creates a {@link ZohoCrmGetAttachmentsForRecordFunction} bound to the given context.
|
|
605
|
+
*
|
|
606
|
+
* Retrieves attachment metadata related to a specific record by targeting the
|
|
607
|
+
* Attachments module via the related records API. Returns a paginated result of
|
|
608
|
+
* {@link ZohoCrmRecordAttachmentMetadata} entries including file names, sizes,
|
|
609
|
+
* and category information. When no attachments exist for the record, the result
|
|
610
|
+
* contains an empty data array rather than null.
|
|
611
|
+
*
|
|
612
|
+
* @param context - Authenticated Zoho CRM context providing fetch and rate limiting
|
|
613
|
+
* @returns Function that retrieves attachments for a record
|
|
614
|
+
*
|
|
615
|
+
* @example
|
|
616
|
+
* ```typescript
|
|
617
|
+
* const getAttachmentsForRecord = zohoCrmGetAttachmentsForRecord(context);
|
|
618
|
+
*
|
|
619
|
+
* const result = await getAttachmentsForRecord({
|
|
620
|
+
* id: contactId,
|
|
621
|
+
* module: 'Contacts',
|
|
622
|
+
* fields: 'File_Name,Size,Created_Time'
|
|
623
|
+
* });
|
|
624
|
+
* ```
|
|
625
|
+
*
|
|
626
|
+
* @see https://www.zoho.com/crm/developer-guide/apiv2/get-related-records.html
|
|
627
|
+
*/
|
|
240
628
|
export declare function zohoCrmGetAttachmentsForRecord(context: ZohoCrmContext): ZohoCrmGetAttachmentsForRecordFunction;
|
|
629
|
+
/**
|
|
630
|
+
* Factory that creates paginated iterators for fetching attachments related to a record.
|
|
631
|
+
*/
|
|
241
632
|
export type ZohoCrmGetAttachmentsForRecordPageFactory = FetchPageFactory<ZohoCrmGetAttachmentsForRecordRequest, ZohoCrmGetAttachmentsForRecordResponse>;
|
|
633
|
+
/**
|
|
634
|
+
* Creates a {@link ZohoCrmGetAttachmentsForRecordPageFactory} bound to the given context.
|
|
635
|
+
*
|
|
636
|
+
* Returns a page factory for iterating over attachments related to a record
|
|
637
|
+
* across multiple pages. Wraps {@link zohoCrmGetAttachmentsForRecord} with
|
|
638
|
+
* automatic pagination handling via {@link zohoFetchPageFactory}.
|
|
639
|
+
*
|
|
640
|
+
* @param context - Authenticated Zoho CRM context providing fetch and rate limiting
|
|
641
|
+
* @returns Page factory for iterating over record attachments
|
|
642
|
+
*
|
|
643
|
+
* @example
|
|
644
|
+
* ```typescript
|
|
645
|
+
* const pageFactory = zohoCrmGetAttachmentsForRecordPageFactory(context);
|
|
646
|
+
*
|
|
647
|
+
* const fetchPage = pageFactory({
|
|
648
|
+
* id: contactId,
|
|
649
|
+
* module: 'Contacts',
|
|
650
|
+
* fields: 'File_Name,Size',
|
|
651
|
+
* per_page: 10
|
|
652
|
+
* });
|
|
653
|
+
*
|
|
654
|
+
* const firstPage = await fetchPage.fetchNext();
|
|
655
|
+
*
|
|
656
|
+
* if (firstPage.result.info.more_records) {
|
|
657
|
+
* const secondPage = await firstPage.fetchNext();
|
|
658
|
+
* }
|
|
659
|
+
* ```
|
|
660
|
+
*
|
|
661
|
+
* @see https://www.zoho.com/crm/developer-guide/apiv2/get-related-records.html
|
|
662
|
+
*/
|
|
242
663
|
export declare function zohoCrmGetAttachmentsForRecordPageFactory(context: ZohoCrmContext): ZohoCrmGetAttachmentsForRecordPageFactory;
|
|
243
664
|
/**
|
|
244
665
|
* Maximum attachment size allowed by Zoho Crm.
|
|
@@ -248,29 +669,19 @@ export declare function zohoCrmGetAttachmentsForRecordPageFactory(context: ZohoC
|
|
|
248
669
|
export declare const ZOHO_CRM_ATTACHMENT_MAX_SIZE: number;
|
|
249
670
|
export interface ZohoCrmUploadAttachmentForRecordRequest extends ZohoCrmGetRecordByIdInput {
|
|
250
671
|
/**
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
* Max of 20MB are allowed
|
|
254
|
-
*
|
|
255
|
-
* @deprecated Use attachmentUrl instead for now.
|
|
256
|
-
*/
|
|
257
|
-
readonly formData?: FormData;
|
|
258
|
-
/**
|
|
259
|
-
* File url to pull the file from.
|
|
260
|
-
*
|
|
261
|
-
* Either this or formData must be provided.
|
|
672
|
+
* File to upload as an attachment. Max 20MB.
|
|
262
673
|
*/
|
|
263
|
-
readonly
|
|
674
|
+
readonly file: File;
|
|
264
675
|
/**
|
|
265
676
|
* The category id(s) of the attachment.
|
|
266
677
|
*
|
|
267
|
-
* Either this or
|
|
678
|
+
* Either this or attachmentCategoryName must be provided.
|
|
268
679
|
*/
|
|
269
680
|
readonly attachmentCategoryId?: ArrayOrValue<ZohoCrmAttachmentCategoryId>;
|
|
270
681
|
/**
|
|
271
682
|
* The category name(s) of the attachment.
|
|
272
683
|
*
|
|
273
|
-
* Either this or
|
|
684
|
+
* Either this or attachmentCategoryId must be provided.
|
|
274
685
|
*
|
|
275
686
|
* Example: "Resume"
|
|
276
687
|
*/
|
|
@@ -279,12 +690,29 @@ export interface ZohoCrmUploadAttachmentForRecordRequest extends ZohoCrmGetRecor
|
|
|
279
690
|
export type ZohoCrmUploadAttachmentForRecordResponse = Response;
|
|
280
691
|
export type ZohoCrmUploadAttachmentForRecordFunction = (input: ZohoCrmUploadAttachmentForRecordRequest) => Promise<ZohoCrmUploadAttachmentForRecordResponse>;
|
|
281
692
|
/**
|
|
282
|
-
*
|
|
693
|
+
* Creates a {@link ZohoCrmUploadAttachmentForRecordFunction} bound to the given context.
|
|
694
|
+
*
|
|
695
|
+
* Uploads a file attachment to a specific record. The file is sent as
|
|
696
|
+
* multipart/form-data. An attachment category must be specified by ID or name.
|
|
697
|
+
* Maximum file size is {@link ZOHO_CRM_ATTACHMENT_MAX_SIZE} (20MB).
|
|
698
|
+
*
|
|
699
|
+
* @param context - Authenticated Zoho CRM context providing fetch and rate limiting
|
|
700
|
+
* @returns Function that uploads an attachment to a record
|
|
701
|
+
* @throws {Error} If neither `attachmentCategoryId` nor `attachmentCategoryName` is provided
|
|
283
702
|
*
|
|
284
|
-
*
|
|
703
|
+
* @example
|
|
704
|
+
* ```typescript
|
|
705
|
+
* const uploadAttachment = zohoCrmUploadAttachmentForRecord(context);
|
|
285
706
|
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
707
|
+
* await uploadAttachment({
|
|
708
|
+
* module: 'Contacts',
|
|
709
|
+
* id: contactId,
|
|
710
|
+
* file: new File(['content'], 'resume.pdf', { type: 'application/pdf' }),
|
|
711
|
+
* attachmentCategoryName: 'Resume'
|
|
712
|
+
* });
|
|
713
|
+
* ```
|
|
714
|
+
*
|
|
715
|
+
* @see https://www.zoho.com/crm/developer/docs/api/v2.1/upload-attachment.html
|
|
288
716
|
*/
|
|
289
717
|
export declare function zohoCrmUploadAttachmentForRecord(context: ZohoCrmContext): ZohoCrmUploadAttachmentForRecordFunction;
|
|
290
718
|
export interface ZohoCrmDownloadAttachmentForRecordRequest extends ZohoCrmGetRecordByIdInput {
|
|
@@ -293,12 +721,27 @@ export interface ZohoCrmDownloadAttachmentForRecordRequest extends ZohoCrmGetRec
|
|
|
293
721
|
export type ZohoCrmDownloadAttachmentForRecordResponse = FetchFileResponse;
|
|
294
722
|
export type ZohoCrmDownloadAttachmentForRecordFunction = (input: ZohoCrmDownloadAttachmentForRecordRequest) => Promise<ZohoCrmDownloadAttachmentForRecordResponse>;
|
|
295
723
|
/**
|
|
296
|
-
*
|
|
724
|
+
* Creates a {@link ZohoCrmDownloadAttachmentForRecordFunction} bound to the given context.
|
|
725
|
+
*
|
|
726
|
+
* Downloads a specific attachment from a record. Returns a parsed
|
|
727
|
+
* {@link FetchFileResponse} containing the file data and metadata extracted
|
|
728
|
+
* from the response headers.
|
|
729
|
+
*
|
|
730
|
+
* @param context - Authenticated Zoho CRM context providing fetch and rate limiting
|
|
731
|
+
* @returns Function that downloads an attachment by record and attachment ID
|
|
297
732
|
*
|
|
298
|
-
*
|
|
733
|
+
* @example
|
|
734
|
+
* ```typescript
|
|
735
|
+
* const downloadAttachment = zohoCrmDownloadAttachmentForRecord(context);
|
|
299
736
|
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
737
|
+
* const fileResponse = await downloadAttachment({
|
|
738
|
+
* module: 'Contacts',
|
|
739
|
+
* id: contactId,
|
|
740
|
+
* attachment_id: attachmentId
|
|
741
|
+
* });
|
|
742
|
+
* ```
|
|
743
|
+
*
|
|
744
|
+
* @see https://www.zoho.com/crm/developer-guide/apiv2/download-attachments.html
|
|
302
745
|
*/
|
|
303
746
|
export declare function zohoCrmDownloadAttachmentForRecord(context: ZohoCrmContext): ZohoCrmDownloadAttachmentForRecordFunction;
|
|
304
747
|
export interface ZohoCrmDeleteAttachmentFromRecordRequest extends ZohoCrmGetRecordByIdInput {
|
|
@@ -307,12 +750,26 @@ export interface ZohoCrmDeleteAttachmentFromRecordRequest extends ZohoCrmGetReco
|
|
|
307
750
|
export type ZohoCrmDeleteAttachmentFromRecordResponse = Response;
|
|
308
751
|
export type ZohoCrmDeleteAttachmentFromRecordFunction = (input: ZohoCrmDeleteAttachmentFromRecordRequest) => Promise<ZohoCrmDeleteAttachmentFromRecordResponse>;
|
|
309
752
|
/**
|
|
310
|
-
*
|
|
753
|
+
* Creates a {@link ZohoCrmDeleteAttachmentFromRecordFunction} bound to the given context.
|
|
754
|
+
*
|
|
755
|
+
* Deletes a specific attachment from a record by its attachment ID.
|
|
756
|
+
* Returns the raw {@link Response}.
|
|
757
|
+
*
|
|
758
|
+
* @param context - Authenticated Zoho CRM context providing fetch and rate limiting
|
|
759
|
+
* @returns Function that deletes an attachment by record and attachment ID
|
|
311
760
|
*
|
|
312
|
-
*
|
|
761
|
+
* @example
|
|
762
|
+
* ```typescript
|
|
763
|
+
* const deleteAttachment = zohoCrmDeleteAttachmentFromRecord(context);
|
|
313
764
|
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
765
|
+
* const response = await deleteAttachment({
|
|
766
|
+
* module: 'Contacts',
|
|
767
|
+
* id: contactId,
|
|
768
|
+
* attachment_id: attachmentId
|
|
769
|
+
* });
|
|
770
|
+
* ```
|
|
771
|
+
*
|
|
772
|
+
* @see https://www.zoho.com/crm/developer-guide/apiv2/delete-attachments.html
|
|
316
773
|
*/
|
|
317
774
|
export declare function zohoCrmDeleteAttachmentFromRecord(context: ZohoCrmContext): ZohoCrmDeleteAttachmentFromRecordFunction;
|
|
318
775
|
export type ZohoCrmExecuteRestApiFunctionRequest = ZohoCrmExecuteRestApiFunctionNormalRequest | ZohoCrmExecuteRestApiFunctionApiSpecificRequest;
|
|
@@ -350,6 +807,9 @@ export interface ZohoCrmExecuteRestApiFunctionErrorResponse {
|
|
|
350
807
|
readonly details: unknown;
|
|
351
808
|
readonly message: string;
|
|
352
809
|
}
|
|
810
|
+
/**
|
|
811
|
+
* Thrown when a Zoho CRM serverless function returns a non-success response code.
|
|
812
|
+
*/
|
|
353
813
|
export declare class ZohoCrmExecuteRestApiFunctionError extends BaseError {
|
|
354
814
|
readonly error: ZohoCrmExecuteRestApiFunctionErrorResponse;
|
|
355
815
|
constructor(error: ZohoCrmExecuteRestApiFunctionErrorResponse);
|
|
@@ -361,23 +821,58 @@ export declare class ZohoCrmExecuteRestApiFunctionError extends BaseError {
|
|
|
361
821
|
*/
|
|
362
822
|
export type ZohoCrmExecuteRestApiFunctionFunction = (input: ZohoCrmExecuteRestApiFunctionRequest) => Promise<ZohoCrmExecuteRestApiFunctionSuccessDetails>;
|
|
363
823
|
/**
|
|
364
|
-
* Creates a ZohoCrmExecuteRestApiFunctionFunction
|
|
824
|
+
* Creates a {@link ZohoCrmExecuteRestApiFunctionFunction} bound to the given context.
|
|
825
|
+
*
|
|
826
|
+
* Executes Zoho CRM serverless functions via the REST API. Supports both
|
|
827
|
+
* OAuth-based and API-key-based authentication. When using an API key, a custom
|
|
828
|
+
* target URL can be specified for cross-environment calls.
|
|
365
829
|
*
|
|
366
830
|
* OAuth Details:
|
|
367
831
|
* - https://www.zoho.com/crm/developer/docs/functions/serverless-fn-oauth.html#OAuth2
|
|
368
832
|
* - There is no documentation for ZohoCrm specifically, but it seems to behave the same way
|
|
369
833
|
* - You will need the following scopes: ZohoCrm.functions.execute.READ,ZohoCrm.functions.execute.CREATE
|
|
370
834
|
*
|
|
371
|
-
* @param context
|
|
372
|
-
* @returns
|
|
835
|
+
* @param context - Authenticated Zoho CRM context providing fetch and rate limiting
|
|
836
|
+
* @returns Function that executes serverless functions via the REST API
|
|
837
|
+
* @throws {ZohoCrmExecuteRestApiFunctionError} If the function execution fails
|
|
838
|
+
*
|
|
839
|
+
* @example
|
|
840
|
+
* ```typescript
|
|
841
|
+
* const executeFunction = zohoCrmExecuteRestApiFunction(context);
|
|
842
|
+
*
|
|
843
|
+
* // Execute using OAuth credentials:
|
|
844
|
+
* const result = await executeFunction({ functionName: 'my_function' });
|
|
845
|
+
*
|
|
846
|
+
* // Execute with parameters:
|
|
847
|
+
* const paramResult = await executeFunction({
|
|
848
|
+
* functionName: 'process_contact',
|
|
849
|
+
* params: { contact_id: '12345', action: 'approve' }
|
|
850
|
+
* });
|
|
851
|
+
*
|
|
852
|
+
* // Execute using an API key (cross-environment):
|
|
853
|
+
* const apiResult = await executeFunction({
|
|
854
|
+
* functionName: 'my_function',
|
|
855
|
+
* apiKey: 'your-api-key',
|
|
856
|
+
* apiUrl: 'production'
|
|
857
|
+
* });
|
|
858
|
+
* ```
|
|
373
859
|
*/
|
|
374
860
|
export declare function zohoCrmExecuteRestApiFunction(context: ZohoCrmContext): ZohoCrmExecuteRestApiFunctionFunction;
|
|
861
|
+
/**
|
|
862
|
+
* Builds URL search params from the input objects, omitting the `module` key since it is used in the URL path rather than as a query parameter.
|
|
863
|
+
*/
|
|
375
864
|
export declare function zohoCrmUrlSearchParamsMinusModule(...input: Maybe<object | Record<string, string | number>>[]): URLSearchParams;
|
|
865
|
+
/**
|
|
866
|
+
* Builds URL search params from the input objects, omitting both `id` and `module` keys since they are used in the URL path.
|
|
867
|
+
*/
|
|
376
868
|
export declare function zohoCrmUrlSearchParamsMinusIdAndModule(...input: Maybe<object | Record<string, string | number>>[]): URLSearchParams;
|
|
377
869
|
/**
|
|
378
870
|
* @deprecated use makeUrlSearchParams instead.
|
|
379
871
|
*/
|
|
380
872
|
export declare const zohoCrmUrlSearchParams: typeof makeUrlSearchParams;
|
|
873
|
+
/**
|
|
874
|
+
* Constructs the standard FetchJsonInput used by CRM API calls, pairing the HTTP method with an optional body.
|
|
875
|
+
*/
|
|
381
876
|
export declare function zohoCrmApiFetchJsonInput(method: string, body?: Maybe<FetchJsonBody>): FetchJsonInput;
|
|
382
877
|
/**
|
|
383
878
|
* Catches ZohoServerFetchResponseDataArrayError and returns the error data array as the response data, as each data element will have the error details.
|
|
@@ -397,6 +892,28 @@ export type ZohoCrmChangeObjectLikeResponseSuccessAndErrorPairs<T extends ZohoCr
|
|
|
397
892
|
readonly successItems: ZohoCrmChangeObjectLikeResponseSuccessEntryType<T>[];
|
|
398
893
|
readonly errorItems: ZohoCrmChangeObjectResponseErrorEntry[];
|
|
399
894
|
};
|
|
895
|
+
/**
|
|
896
|
+
* Separates a change response's entries into success and error arrays based on their status.
|
|
897
|
+
*
|
|
898
|
+
* Iterates over the `data` array from a Zoho CRM change operation response and
|
|
899
|
+
* partitions entries into `successItems` and `errorItems` based on their `status` field.
|
|
900
|
+
* The original response is spread into the result, so all original fields remain accessible.
|
|
901
|
+
*
|
|
902
|
+
* Used internally by {@link zohoCrmDeleteRecord} and similar functions to provide
|
|
903
|
+
* convenient access to separated success/error results.
|
|
904
|
+
*
|
|
905
|
+
* @param response - Raw change operation response containing mixed success/error entries
|
|
906
|
+
* @returns The response augmented with pre-separated `successItems` and `errorItems` arrays
|
|
907
|
+
*
|
|
908
|
+
* @example
|
|
909
|
+
* ```typescript
|
|
910
|
+
* const rawResponse = await context.fetchJson<ZohoCrmChangeObjectLikeResponse>(...);
|
|
911
|
+
* const result = zohoCrmChangeObjectLikeResponseSuccessAndErrorPairs(rawResponse);
|
|
912
|
+
*
|
|
913
|
+
* result.successItems; // entries with status === 'success'
|
|
914
|
+
* result.errorItems; // entries with non-success status
|
|
915
|
+
* ```
|
|
916
|
+
*/
|
|
400
917
|
export declare function zohoCrmChangeObjectLikeResponseSuccessAndErrorPairs<T extends ZohoCrmChangeObjectLikeResponseEntry>(response: ZohoCrmChangeObjectLikeResponse<T>): ZohoCrmChangeObjectLikeResponseSuccessAndErrorPairs<T>;
|
|
401
918
|
export type ZohoCrmChangeObjectResponse<T extends ZohoCrmChangeObjectResponseEntry = ZohoCrmChangeObjectResponseEntry> = ZohoCrmChangeObjectLikeResponse<T>;
|
|
402
919
|
export type ZohoCrmChangeObjectResponseEntry<E extends ZohoCrmChangeObjectResponseSuccessEntry = ZohoCrmChangeObjectResponseSuccessEntry> = ZohoCrmChangeObjectLikeResponseEntry<E>;
|
|
@@ -406,13 +923,33 @@ export interface ZohoCrmChangeObjectResponseSuccessEntry<D extends ZohoCrmChange
|
|
|
406
923
|
export interface ZohoCrmChangeObjectResponseErrorEntry extends ZohoServerErrorDataWithDetails {
|
|
407
924
|
readonly status: ZohoServerErrorStatus;
|
|
408
925
|
}
|
|
926
|
+
/**
|
|
927
|
+
* Result of a multi-record operation, grouping inputs by whether their API call succeeded or failed.
|
|
928
|
+
*/
|
|
409
929
|
export interface ZohoCrmMultiRecordResult<I, OS, OE> {
|
|
410
930
|
readonly successItems: ZohoCrmMultiRecordResultEntry<I, OS>[];
|
|
411
931
|
readonly errorItems: ZohoCrmMultiRecordResultEntry<I, OE>[];
|
|
412
932
|
}
|
|
933
|
+
/**
|
|
934
|
+
* Minimal shape required to determine whether an API result entry is a success or error.
|
|
935
|
+
*/
|
|
413
936
|
export interface ZohoCrmMultiRecordResultItem {
|
|
414
937
|
readonly status: ZohoServerSuccessStatus | ZohoServerErrorStatus;
|
|
415
938
|
}
|
|
939
|
+
/**
|
|
940
|
+
* Pairs each input record with its corresponding API result and separates them into success and error arrays by status.
|
|
941
|
+
*
|
|
942
|
+
* Iterates over the `input` and `results` arrays in parallel, matching each input record
|
|
943
|
+
* to its positional result. Entries are classified as success or error based on
|
|
944
|
+
* the result's `status` field matching {@link ZOHO_SUCCESS_STATUS}.
|
|
945
|
+
*
|
|
946
|
+
* Used internally by {@link updateRecordLikeFunction} to pair input data with API outcomes
|
|
947
|
+
* for insert, update, and upsert operations.
|
|
948
|
+
*
|
|
949
|
+
* @param input - Array of input records that were submitted to the API
|
|
950
|
+
* @param results - Array of per-record results returned by the API, positionally aligned with `input`
|
|
951
|
+
* @returns Object with `successItems` and `errorItems`, each containing paired `{ input, result }` entries
|
|
952
|
+
*/
|
|
416
953
|
export declare function zohoCrmMultiRecordResult<I, OS extends ZohoCrmMultiRecordResultItem, OE extends ZohoCrmMultiRecordResultItem>(input: I[], results: (OS | OE)[]): ZohoCrmMultiRecordResult<I, OS, OE>;
|
|
417
954
|
export interface ZohoCrmMultiRecordResultEntry<I, O> {
|
|
418
955
|
/**
|