@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
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { type Maybe } from '@dereekb/util';
|
|
2
|
+
import { type FetchPageFactoryConfigDefaults } from '@dereekb/util/fetch';
|
|
3
|
+
/**
|
|
4
|
+
* Pagination parameters for Zoho Sign list endpoints.
|
|
5
|
+
*
|
|
6
|
+
* Unlike CRM/Recruit which use `page`/`per_page`, Zoho Sign uses an offset-based
|
|
7
|
+
* model with `start_index` and `row_count`.
|
|
8
|
+
*/
|
|
9
|
+
export interface ZohoSignPageFilter {
|
|
10
|
+
/**
|
|
11
|
+
* 1-based offset index of the first record to return.
|
|
12
|
+
*/
|
|
13
|
+
readonly start_index?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Number of records to return per page.
|
|
16
|
+
*/
|
|
17
|
+
readonly row_count?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Column to sort results by.
|
|
20
|
+
*/
|
|
21
|
+
readonly sort_column?: ZohoSignSortColumn;
|
|
22
|
+
/**
|
|
23
|
+
* Sort direction.
|
|
24
|
+
*/
|
|
25
|
+
readonly sort_order?: ZohoSignSortOrder;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Known sortable column names for Zoho Sign list endpoints, with a `string` fallback for custom columns.
|
|
29
|
+
*/
|
|
30
|
+
export type ZohoSignSortColumn = 'request_name' | 'folder_name' | 'owner_full_name' | 'recipient_email' | 'form_name' | 'created_time' | string;
|
|
31
|
+
/**
|
|
32
|
+
* Sort direction for Zoho Sign list queries.
|
|
33
|
+
*/
|
|
34
|
+
export type ZohoSignSortOrder = 'ASC' | 'DESC';
|
|
35
|
+
/**
|
|
36
|
+
* Optional search filters for narrowing Zoho Sign document list results by specific columns.
|
|
37
|
+
*/
|
|
38
|
+
export interface ZohoSignSearchColumns {
|
|
39
|
+
readonly request_name?: string;
|
|
40
|
+
readonly folder_name?: string;
|
|
41
|
+
readonly owner_full_name?: string;
|
|
42
|
+
readonly recipient_email?: string;
|
|
43
|
+
readonly recipient_name?: string;
|
|
44
|
+
readonly form_name?: string;
|
|
45
|
+
readonly template_name?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Pagination metadata returned by Zoho Sign list endpoints alongside each page of results.
|
|
49
|
+
*/
|
|
50
|
+
export interface ZohoSignPageContext {
|
|
51
|
+
/**
|
|
52
|
+
* Whether additional rows exist beyond the current page.
|
|
53
|
+
*/
|
|
54
|
+
readonly has_more_rows: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Total number of records matching the query across all pages.
|
|
57
|
+
*/
|
|
58
|
+
readonly total_count: number;
|
|
59
|
+
/**
|
|
60
|
+
* The 1-based offset index of the first record on this page.
|
|
61
|
+
*/
|
|
62
|
+
readonly start_index: number;
|
|
63
|
+
/**
|
|
64
|
+
* Number of records returned on this page.
|
|
65
|
+
*/
|
|
66
|
+
readonly row_count: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Paginated response from a Zoho Sign list endpoint, containing an array of
|
|
70
|
+
* request records and pagination metadata.
|
|
71
|
+
*/
|
|
72
|
+
export interface ZohoSignPageResult<T> {
|
|
73
|
+
/**
|
|
74
|
+
* Array of sign request records for the current page.
|
|
75
|
+
*/
|
|
76
|
+
readonly requests: T[];
|
|
77
|
+
/**
|
|
78
|
+
* Pagination metadata for the current page.
|
|
79
|
+
*/
|
|
80
|
+
readonly page_context: ZohoSignPageContext;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* A fetch function that accepts paginated input and returns a {@link ZohoSignPageResult}.
|
|
84
|
+
* Used as the underlying data source for {@link zohoSignFetchPageFactory}.
|
|
85
|
+
*/
|
|
86
|
+
export type ZohoSignFetchPageFetchFunction<I extends ZohoSignPageFilter, R extends ZohoSignPageResult<any>> = (input: I) => Promise<R>;
|
|
87
|
+
/**
|
|
88
|
+
* Creates a page factory that wraps a Zoho Sign fetch function with automatic offset-based pagination.
|
|
89
|
+
*
|
|
90
|
+
* The factory reads `page_context.has_more_rows` from each response to determine if additional
|
|
91
|
+
* pages exist, and automatically advances `start_index` by `row_count` for subsequent requests.
|
|
92
|
+
*
|
|
93
|
+
* @param fetch - The Zoho Sign fetch function to paginate over
|
|
94
|
+
* @param defaults - Optional default configuration for the page factory
|
|
95
|
+
* @returns A page factory that produces iterable page fetchers
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* const pageFactory = zohoSignFetchPageFactory(zohoSignGetDocumentsList(context));
|
|
100
|
+
*
|
|
101
|
+
* const fetchPage = pageFactory({ row_count: 10 });
|
|
102
|
+
* const firstPage = await fetchPage.fetchNext();
|
|
103
|
+
*
|
|
104
|
+
* if (firstPage.result.page_context.has_more_rows) {
|
|
105
|
+
* const secondPage = await firstPage.fetchNext();
|
|
106
|
+
* }
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export declare function zohoSignFetchPageFactory<I extends ZohoSignPageFilter, R extends ZohoSignPageResult<any>>(fetch: ZohoSignFetchPageFetchFunction<I, R>, defaults?: Maybe<FetchPageFactoryConfigDefaults>): import("@dereekb/util/fetch").FetchPageFactory<I, R>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type FactoryWithRequiredInput } from '@dereekb/util';
|
|
2
|
+
import { type ConfiguredFetch, type FetchJsonFunction } from '@dereekb/util/fetch';
|
|
3
|
+
import { type ZohoApiUrl, type ZohoApiUrlKey, type ZohoConfig, type ZohoApiServiceName } from '../zoho.config';
|
|
4
|
+
import { type ZohoAccessTokenStringFactory, type ZohoServiceAccessTokenKey } from '../accounts';
|
|
5
|
+
import { type ZohoRateLimiterRef } from '../zoho.limit';
|
|
6
|
+
export declare const ZOHO_SIGN_SERVICE_NAME: ZohoApiServiceName | ZohoServiceAccessTokenKey;
|
|
7
|
+
export type ZohoSignApiUrl = ZohoApiUrl;
|
|
8
|
+
export type ZohoSignApiUrlKey = ZohoApiUrlKey;
|
|
9
|
+
export type ZohoSignConfigApiUrlInput = ZohoSignApiUrlKey | ZohoSignApiUrl;
|
|
10
|
+
export declare function zohoSignConfigApiUrl(input: ZohoSignConfigApiUrlInput): ZohoApiUrl;
|
|
11
|
+
export type ZohoSignConfig = ZohoConfig;
|
|
12
|
+
export interface ZohoSignFetchFactoryInput {
|
|
13
|
+
readonly apiUrl: ZohoSignApiUrl;
|
|
14
|
+
}
|
|
15
|
+
export type ZohoSignFetchFactory = FactoryWithRequiredInput<ConfiguredFetch, ZohoSignFetchFactoryInput>;
|
|
16
|
+
export interface ZohoSignContext extends ZohoRateLimiterRef {
|
|
17
|
+
readonly fetch: ConfiguredFetch;
|
|
18
|
+
readonly fetchJson: FetchJsonFunction;
|
|
19
|
+
readonly accessTokenStringFactory: ZohoAccessTokenStringFactory;
|
|
20
|
+
readonly config: ZohoSignConfig;
|
|
21
|
+
}
|
|
22
|
+
export interface ZohoSignContextRef {
|
|
23
|
+
readonly signContext: ZohoSignContext;
|
|
24
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { type EmailAddress } from '@dereekb/util';
|
|
2
|
+
/**
|
|
3
|
+
* An identifier in Zoho Sign.
|
|
4
|
+
*/
|
|
5
|
+
export type ZohoSignId = string;
|
|
6
|
+
/**
|
|
7
|
+
* Identifier of a request (envelope) in Zoho Sign.
|
|
8
|
+
*/
|
|
9
|
+
export type ZohoSignRequestId = string;
|
|
10
|
+
/**
|
|
11
|
+
* Identifier of a document within a Zoho Sign request.
|
|
12
|
+
*/
|
|
13
|
+
export type ZohoSignDocumentId = string;
|
|
14
|
+
/**
|
|
15
|
+
* Identifier of an action (recipient action) in Zoho Sign.
|
|
16
|
+
*/
|
|
17
|
+
export type ZohoSignActionId = string;
|
|
18
|
+
/**
|
|
19
|
+
* Identifier of a folder in Zoho Sign.
|
|
20
|
+
*/
|
|
21
|
+
export type ZohoSignFolderId = string;
|
|
22
|
+
/**
|
|
23
|
+
* Identifier of a request type (document category) in Zoho Sign.
|
|
24
|
+
*/
|
|
25
|
+
export type ZohoSignRequestTypeId = string;
|
|
26
|
+
/**
|
|
27
|
+
* Identifier of a field type in Zoho Sign.
|
|
28
|
+
*/
|
|
29
|
+
export type ZohoSignFieldTypeId = string;
|
|
30
|
+
/**
|
|
31
|
+
* Status of a Zoho Sign request.
|
|
32
|
+
*/
|
|
33
|
+
export type ZohoSignRequestStatus = 'inprogress' | 'completed' | 'recalled' | 'declined' | 'expired' | string;
|
|
34
|
+
/**
|
|
35
|
+
* Recipient action type in Zoho Sign.
|
|
36
|
+
*/
|
|
37
|
+
export type ZohoSignActionType = 'SIGN' | 'VIEW' | 'INPERSONSIGN' | 'APPROVER';
|
|
38
|
+
/**
|
|
39
|
+
* Verification type for a recipient.
|
|
40
|
+
*/
|
|
41
|
+
export type ZohoSignVerificationType = 'EMAIL' | 'SMS' | 'OFFLINE';
|
|
42
|
+
/**
|
|
43
|
+
* Field type name for document fields.
|
|
44
|
+
*/
|
|
45
|
+
export type ZohoSignFieldTypeName = 'Checkbox' | 'Radiogroup' | 'Signature' | 'Initial' | 'Textfield' | 'Email' | 'Date' | 'Name' | 'Company' | 'Jobtitle' | 'CustomDate' | 'Dropdown' | 'Attachment' | 'Checkout' | string;
|
|
46
|
+
/**
|
|
47
|
+
* Name format for name fields.
|
|
48
|
+
*/
|
|
49
|
+
export type ZohoSignNameFormat = 'FIRST_NAME' | 'LAST_NAME' | 'FULL_NAME';
|
|
50
|
+
/**
|
|
51
|
+
* Field category classification.
|
|
52
|
+
*/
|
|
53
|
+
export type ZohoSignFieldCategory = 'textfield' | 'image' | 'datefield' | string;
|
|
54
|
+
/**
|
|
55
|
+
* Definition of a field type available in Zoho Sign.
|
|
56
|
+
*/
|
|
57
|
+
export interface ZohoSignFieldType {
|
|
58
|
+
readonly field_type_id: ZohoSignFieldTypeId;
|
|
59
|
+
readonly field_type_name: ZohoSignFieldTypeName;
|
|
60
|
+
readonly field_category: ZohoSignFieldCategory;
|
|
61
|
+
readonly is_mandatory: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Text styling properties for a field.
|
|
65
|
+
*/
|
|
66
|
+
export interface ZohoSignTextProperty {
|
|
67
|
+
readonly font_size?: number;
|
|
68
|
+
readonly font_color?: string;
|
|
69
|
+
readonly font?: string;
|
|
70
|
+
readonly is_italic?: boolean;
|
|
71
|
+
readonly is_underline?: boolean;
|
|
72
|
+
readonly is_bold?: boolean;
|
|
73
|
+
readonly is_read_only?: boolean;
|
|
74
|
+
readonly is_fixed_width?: boolean;
|
|
75
|
+
readonly is_fixed_height?: boolean;
|
|
76
|
+
readonly max_field_length?: number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Validation settings for a field.
|
|
80
|
+
*/
|
|
81
|
+
export interface ZohoSignFieldValidation {
|
|
82
|
+
readonly validation_type?: string;
|
|
83
|
+
readonly validation_regex?: string;
|
|
84
|
+
readonly validation_error_message?: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* A field placed on a document within a Zoho Sign request.
|
|
88
|
+
*/
|
|
89
|
+
export interface ZohoSignField {
|
|
90
|
+
readonly field_name?: string;
|
|
91
|
+
readonly field_id?: string;
|
|
92
|
+
readonly field_label?: string;
|
|
93
|
+
readonly field_type_name?: ZohoSignFieldTypeName;
|
|
94
|
+
readonly document_id?: ZohoSignDocumentId;
|
|
95
|
+
readonly action_id?: ZohoSignActionId;
|
|
96
|
+
readonly is_mandatory?: boolean;
|
|
97
|
+
readonly x_coord?: number;
|
|
98
|
+
readonly y_coord?: number;
|
|
99
|
+
readonly abs_width?: number;
|
|
100
|
+
readonly abs_height?: number;
|
|
101
|
+
readonly page_no?: number;
|
|
102
|
+
readonly default_value?: string;
|
|
103
|
+
readonly is_read_only?: boolean;
|
|
104
|
+
readonly name_format?: ZohoSignNameFormat;
|
|
105
|
+
readonly date_format?: string;
|
|
106
|
+
readonly description_tooltip?: string;
|
|
107
|
+
readonly text_property?: ZohoSignTextProperty;
|
|
108
|
+
readonly validation?: ZohoSignFieldValidation;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* A recipient action within a Zoho Sign request.
|
|
112
|
+
*/
|
|
113
|
+
export interface ZohoSignAction {
|
|
114
|
+
readonly action_id?: ZohoSignActionId;
|
|
115
|
+
readonly action_type: ZohoSignActionType;
|
|
116
|
+
readonly recipient_name: string;
|
|
117
|
+
readonly recipient_email: EmailAddress;
|
|
118
|
+
readonly signing_order?: number;
|
|
119
|
+
readonly verify_recipient?: boolean;
|
|
120
|
+
readonly verification_type?: ZohoSignVerificationType;
|
|
121
|
+
readonly verification_code?: string;
|
|
122
|
+
readonly private_notes?: string;
|
|
123
|
+
readonly in_person_name?: string;
|
|
124
|
+
readonly in_person_email?: EmailAddress;
|
|
125
|
+
readonly fields?: ZohoSignActionFields;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Fields grouped by type within an action.
|
|
129
|
+
*/
|
|
130
|
+
export interface ZohoSignActionFields {
|
|
131
|
+
readonly check_boxes?: ZohoSignField[];
|
|
132
|
+
readonly text_fields?: ZohoSignField[];
|
|
133
|
+
readonly image_fields?: ZohoSignField[];
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* A document within a Zoho Sign request.
|
|
137
|
+
*/
|
|
138
|
+
export interface ZohoSignDocument {
|
|
139
|
+
readonly document_id: ZohoSignDocumentId;
|
|
140
|
+
readonly document_name?: string;
|
|
141
|
+
readonly document_size?: number;
|
|
142
|
+
readonly total_pages?: number;
|
|
143
|
+
readonly document_order?: string;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* A Zoho Sign request (envelope) containing documents to be signed.
|
|
147
|
+
*/
|
|
148
|
+
export interface ZohoSignRequest {
|
|
149
|
+
readonly request_id?: ZohoSignRequestId;
|
|
150
|
+
readonly request_status?: ZohoSignRequestStatus;
|
|
151
|
+
readonly request_name: string;
|
|
152
|
+
readonly request_type_id?: ZohoSignRequestTypeId;
|
|
153
|
+
readonly request_type_name?: string;
|
|
154
|
+
readonly owner_id?: string;
|
|
155
|
+
readonly owner_email?: EmailAddress;
|
|
156
|
+
readonly owner_first_name?: string;
|
|
157
|
+
readonly owner_last_name?: string;
|
|
158
|
+
readonly description?: string;
|
|
159
|
+
readonly notes?: string;
|
|
160
|
+
readonly created_time?: number;
|
|
161
|
+
readonly modified_time?: number;
|
|
162
|
+
readonly action_time?: number;
|
|
163
|
+
readonly sign_submitted_time?: number;
|
|
164
|
+
readonly expire_by?: number;
|
|
165
|
+
readonly expiration_days?: number;
|
|
166
|
+
readonly sign_percentage?: number;
|
|
167
|
+
readonly email_reminders?: boolean;
|
|
168
|
+
readonly reminder_period?: number;
|
|
169
|
+
readonly is_sequential?: boolean;
|
|
170
|
+
readonly is_deleted?: boolean;
|
|
171
|
+
readonly folder_id?: ZohoSignFolderId;
|
|
172
|
+
readonly zsdocumentid?: string;
|
|
173
|
+
readonly attachment_size?: number;
|
|
174
|
+
readonly actions?: ZohoSignAction[];
|
|
175
|
+
readonly document_ids?: ZohoSignDocument[];
|
|
176
|
+
readonly document_fields?: ZohoSignDocumentFieldsEntry[];
|
|
177
|
+
readonly templates_used?: unknown[];
|
|
178
|
+
readonly attachments?: unknown[];
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Document fields entry associating document_id with its fields.
|
|
182
|
+
*/
|
|
183
|
+
export interface ZohoSignDocumentFieldsEntry {
|
|
184
|
+
readonly document_id: ZohoSignDocumentId;
|
|
185
|
+
readonly fields: ZohoSignField[];
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Form data returned for a completed request, containing field values.
|
|
189
|
+
*/
|
|
190
|
+
export interface ZohoSignDocumentFormData {
|
|
191
|
+
readonly request_name: string;
|
|
192
|
+
readonly zsdocumentid: string;
|
|
193
|
+
readonly actions: ZohoSignFormDataAction[];
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Action within form data containing filled field values.
|
|
197
|
+
*/
|
|
198
|
+
export interface ZohoSignFormDataAction {
|
|
199
|
+
readonly action_type: ZohoSignActionType;
|
|
200
|
+
readonly signed_time?: string;
|
|
201
|
+
readonly recipient_email: EmailAddress;
|
|
202
|
+
readonly recipient_name: string;
|
|
203
|
+
readonly fields: ZohoSignFormDataField[];
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* A form data field with its label and filled value.
|
|
207
|
+
*/
|
|
208
|
+
export interface ZohoSignFormDataField {
|
|
209
|
+
readonly field_label: string;
|
|
210
|
+
readonly field_value: string;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Input data for creating or updating a Zoho Sign request.
|
|
214
|
+
*/
|
|
215
|
+
export interface ZohoSignRequestData {
|
|
216
|
+
readonly request_name: string;
|
|
217
|
+
readonly is_sequential: boolean;
|
|
218
|
+
readonly request_type_id?: ZohoSignRequestTypeId;
|
|
219
|
+
readonly notes?: string;
|
|
220
|
+
readonly expiration_days?: number;
|
|
221
|
+
readonly email_reminders?: boolean;
|
|
222
|
+
readonly reminder_period?: number;
|
|
223
|
+
readonly folder_id?: ZohoSignFolderId;
|
|
224
|
+
readonly actions: ZohoSignAction[];
|
|
225
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type FetchResponseError } from '@dereekb/util/fetch';
|
|
2
|
+
import { type ZohoServerErrorResponseData, type ParsedZohoServerError, type ZohoServerErrorResponseDataArrayRef } from '../zoho.error.api';
|
|
3
|
+
export declare const logZohoSignErrorToConsole: import("..").LogZohoServerErrorFunction;
|
|
4
|
+
export declare function parseZohoSignError(responseError: FetchResponseError): Promise<ParsedZohoServerError>;
|
|
5
|
+
export declare function parseZohoSignServerErrorResponseData(errorResponseData: ZohoServerErrorResponseData | ZohoServerErrorResponseDataArrayRef, responseError: FetchResponseError): ParsedZohoServerError;
|
|
6
|
+
export declare const interceptZohoSign200StatusWithErrorResponse: import("@dereekb/util/fetch").FetchJsonInterceptJsonResponseFunction;
|
|
7
|
+
export declare const handleZohoSignErrorFetch: import("..").HandleZohoErrorFetchFactory;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type ZohoSignConfig, type ZohoSignContextRef, type ZohoSignFetchFactory } from './sign.config';
|
|
2
|
+
import { type LogZohoServerErrorFunction } from '../zoho.error.api';
|
|
3
|
+
import { type ZohoAccountsContextRef } from '../accounts/accounts.config';
|
|
4
|
+
import { type ZohoRateLimitedFetchHandlerConfig } from '../zoho.limit';
|
|
5
|
+
import { type Maybe } from '@dereekb/util';
|
|
6
|
+
/**
|
|
7
|
+
* Top-level Zoho Sign client instance, providing access to the authenticated {@link ZohoSignContext}.
|
|
8
|
+
*/
|
|
9
|
+
export type ZohoSign = ZohoSignContextRef;
|
|
10
|
+
/**
|
|
11
|
+
* Configuration for creating a {@link ZohoSignFactory}, combining account credentials
|
|
12
|
+
* with optional overrides for rate limiting, fetch behavior, and error logging.
|
|
13
|
+
*/
|
|
14
|
+
export interface ZohoSignFactoryConfig extends ZohoAccountsContextRef {
|
|
15
|
+
/**
|
|
16
|
+
* Custom rate limiter configuration to control request concurrency and throttling.
|
|
17
|
+
*/
|
|
18
|
+
rateLimiterConfig?: Maybe<ZohoRateLimitedFetchHandlerConfig>;
|
|
19
|
+
/**
|
|
20
|
+
* Custom fetch factory for creating the underlying HTTP client.
|
|
21
|
+
* Defaults to a standard fetch service with OAuth Bearer token headers and a 20-second timeout.
|
|
22
|
+
*/
|
|
23
|
+
fetchFactory?: ZohoSignFetchFactory;
|
|
24
|
+
/**
|
|
25
|
+
* Custom error logging function invoked when Zoho API errors are encountered.
|
|
26
|
+
*/
|
|
27
|
+
logZohoServerErrorFunction?: LogZohoServerErrorFunction;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Factory function that creates a {@link ZohoSign} client from a {@link ZohoSignConfig}.
|
|
31
|
+
*/
|
|
32
|
+
export type ZohoSignFactory = (config: ZohoSignConfig) => ZohoSign;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a {@link ZohoSignFactory} from the given configuration.
|
|
35
|
+
*
|
|
36
|
+
* The factory pre-initializes shared resources (access token provider, rate limiter)
|
|
37
|
+
* once, then produces {@link ZohoSign} client instances for each {@link ZohoSignConfig}.
|
|
38
|
+
* Each client handles OAuth token refresh on {@link ZohoInvalidTokenError}, rate limiting,
|
|
39
|
+
* and Zoho Sign's non-standard error responses (200 status with error body).
|
|
40
|
+
*
|
|
41
|
+
* @param factoryConfig - Configuration providing account credentials and optional overrides
|
|
42
|
+
* @returns A factory function that creates authenticated Zoho Sign clients
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const factory = zohoSignFactory({
|
|
47
|
+
* accountsContext: zohoAccountsApi.accountsContext
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
* const zohoSign = factory({
|
|
51
|
+
* apiUrl: 'https://sign.zoho.com'
|
|
52
|
+
* });
|
|
53
|
+
*
|
|
54
|
+
* // Use the sign context for API calls:
|
|
55
|
+
* const { signContext } = zohoSign;
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function zohoSignFactory(factoryConfig: ZohoSignFactoryConfig): ZohoSignFactory;
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import { type Maybe, type PageNumber } from '@dereekb/util';
|
|
2
2
|
import { type FetchPageFactoryConfigDefaults } from '@dereekb/util/fetch';
|
|
3
3
|
/**
|
|
4
|
-
* Base
|
|
4
|
+
* Base pagination parameters shared by all Zoho list/search API endpoints.
|
|
5
5
|
*/
|
|
6
6
|
export interface ZohoPageFilter {
|
|
7
|
+
/**
|
|
8
|
+
* 1-based page number to retrieve.
|
|
9
|
+
*/
|
|
7
10
|
readonly page?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Number of records to return per page.
|
|
13
|
+
*/
|
|
8
14
|
readonly per_page?: number;
|
|
9
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Generic wrapper for Zoho API responses that return an array of records in a `data` field.
|
|
18
|
+
*/
|
|
10
19
|
export interface ZohoDataArrayResultRef<T> {
|
|
11
20
|
/**
|
|
12
21
|
* Array of data returned.
|
|
@@ -14,20 +23,23 @@ export interface ZohoDataArrayResultRef<T> {
|
|
|
14
23
|
readonly data: T[];
|
|
15
24
|
}
|
|
16
25
|
/**
|
|
17
|
-
*
|
|
26
|
+
* Paginated API response combining a data array with page metadata.
|
|
18
27
|
*/
|
|
19
28
|
export interface ZohoPageResult<T, I extends ZohoPageResultInfo = ZohoPageResultInfo> extends ZohoDataArrayResultRef<T> {
|
|
20
29
|
/**
|
|
21
|
-
*
|
|
30
|
+
* Pagination metadata for the current page.
|
|
22
31
|
*/
|
|
23
32
|
readonly info: I;
|
|
24
33
|
}
|
|
25
34
|
/**
|
|
26
|
-
*
|
|
35
|
+
* Creates an empty {@link ZohoPageResult} with no data and `more_records: false`.
|
|
36
|
+
* Useful as a fallback when the API returns `null` instead of an empty result.
|
|
37
|
+
*
|
|
38
|
+
* @returns An empty page result with default pagination info
|
|
27
39
|
*/
|
|
28
40
|
export declare function emptyZohoPageResult<T = unknown>(): ZohoPageResult<T>;
|
|
29
41
|
/**
|
|
30
|
-
*
|
|
42
|
+
* Pagination metadata returned by Zoho list/search API endpoints.
|
|
31
43
|
*/
|
|
32
44
|
export interface ZohoPageResultInfo {
|
|
33
45
|
/**
|
|
@@ -48,17 +60,36 @@ export interface ZohoPageResultInfo {
|
|
|
48
60
|
readonly more_records: boolean;
|
|
49
61
|
}
|
|
50
62
|
/**
|
|
51
|
-
* Reference
|
|
63
|
+
* Reference interface for objects that expose a {@link ZohoPageResultInfo}.
|
|
52
64
|
*/
|
|
53
65
|
export interface ZohoPageResultInfoRef {
|
|
54
66
|
readonly info: ZohoPageResultInfo;
|
|
55
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* A fetch function that accepts paginated input and returns a {@link ZohoPageResult}.
|
|
70
|
+
* Used as the underlying data source for {@link zohoFetchPageFactory}.
|
|
71
|
+
*/
|
|
56
72
|
export type ZohoFetchPageFetchFunction<I extends ZohoPageFilter, R extends ZohoPageResult<any>> = (input: I) => Promise<R>;
|
|
57
73
|
/**
|
|
58
|
-
* Creates a
|
|
74
|
+
* Creates a page factory that wraps a Zoho fetch function with automatic pagination.
|
|
75
|
+
*
|
|
76
|
+
* The factory reads `info.more_records` from each response to determine if additional
|
|
77
|
+
* pages exist, and automatically increments the `page` parameter for subsequent requests.
|
|
78
|
+
*
|
|
79
|
+
* @param fetch - The Zoho fetch function to paginate over
|
|
80
|
+
* @param defaults - Optional default configuration for the page factory
|
|
81
|
+
* @returns A page factory that produces iterable page fetchers
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const pageFactory = zohoFetchPageFactory(zohoCrmSearchRecords(context));
|
|
86
|
+
*
|
|
87
|
+
* const fetchPage = pageFactory({ module: 'Contacts', word: 'Smith', per_page: 10 });
|
|
88
|
+
* const firstPage = await fetchPage.fetchNext();
|
|
59
89
|
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
90
|
+
* if (firstPage.result.info.more_records) {
|
|
91
|
+
* const secondPage = await firstPage.fetchNext();
|
|
92
|
+
* }
|
|
93
|
+
* ```
|
|
63
94
|
*/
|
|
64
95
|
export declare function zohoFetchPageFactory<I extends ZohoPageFilter, R extends ZohoPageResult<any>>(fetch: ZohoFetchPageFetchFunction<I, R>, defaults?: Maybe<FetchPageFactoryConfigDefaults>): import("@dereekb/util/fetch").FetchPageFactory<I, R>;
|
package/src/lib/zoho.config.d.ts
CHANGED
|
@@ -1,35 +1,50 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* I.E. recruit
|
|
2
|
+
* Lowercase identifier for a specific Zoho service (e.g. `'recruit'`, `'crm'`, `'sign'`).
|
|
5
3
|
*/
|
|
6
4
|
export type ZohoApiServiceName = string;
|
|
7
5
|
/**
|
|
8
|
-
*
|
|
6
|
+
* Fully-qualified base URL for a Zoho API endpoint (e.g. `'https://www.zohoapis.com/crm'`).
|
|
9
7
|
*/
|
|
10
8
|
export type ZohoApiUrl = string;
|
|
11
9
|
/**
|
|
12
|
-
* Non-expiring refresh token used to retrieve access tokens
|
|
10
|
+
* Non-expiring OAuth refresh token used to retrieve short-lived access tokens.
|
|
13
11
|
*
|
|
14
|
-
*
|
|
12
|
+
* Format: `'1000.abc.123'`
|
|
15
13
|
*
|
|
16
|
-
*
|
|
14
|
+
* @see https://www.zoho.com/recruit/developer-guide/apiv2/oauth-overview.html
|
|
17
15
|
*/
|
|
18
16
|
export type ZohoRefreshToken = string;
|
|
19
17
|
/**
|
|
20
|
-
* OAuth Client
|
|
18
|
+
* OAuth 2.0 Client ID issued by the Zoho Developer Console.
|
|
21
19
|
*/
|
|
22
20
|
export type ZohoOAuthClientId = string;
|
|
23
21
|
/**
|
|
24
|
-
* OAuth Client Secret
|
|
22
|
+
* OAuth 2.0 Client Secret issued by the Zoho Developer Console.
|
|
25
23
|
*/
|
|
26
24
|
export type ZohoOAuthClientSecret = string;
|
|
25
|
+
/**
|
|
26
|
+
* Paired OAuth client credentials required for token exchange.
|
|
27
|
+
*/
|
|
27
28
|
export interface ZohoAuthClientIdAndSecretPair {
|
|
28
29
|
readonly clientId: ZohoOAuthClientId;
|
|
29
30
|
readonly clientSecret: ZohoOAuthClientSecret;
|
|
30
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Well-known environment key for selecting a pre-configured Zoho API URL.
|
|
34
|
+
*/
|
|
31
35
|
export type ZohoApiUrlKey = 'sandbox' | 'production';
|
|
36
|
+
/**
|
|
37
|
+
* Input for configuring the target Zoho API URL. Accepts either a well-known
|
|
38
|
+
* {@link ZohoApiUrlKey} (e.g. `'sandbox'`, `'production'`) or a full {@link ZohoApiUrl}.
|
|
39
|
+
*/
|
|
32
40
|
export type ZohoConfigApiUrlInput = ZohoApiUrlKey | ZohoApiUrl;
|
|
41
|
+
/**
|
|
42
|
+
* Base configuration shared by all Zoho service configs (CRM, Recruit, Sign, Accounts).
|
|
43
|
+
*/
|
|
33
44
|
export interface ZohoConfig {
|
|
45
|
+
/**
|
|
46
|
+
* Target API URL, either as an environment key or a full URL.
|
|
47
|
+
* Each service resolves this to a concrete URL via its own config utility.
|
|
48
|
+
*/
|
|
34
49
|
readonly apiUrl?: ZohoConfigApiUrlInput;
|
|
35
50
|
}
|
package/src/lib/zoho.limit.d.ts
CHANGED
|
@@ -1,37 +1,69 @@
|
|
|
1
1
|
import { type Maybe, type Milliseconds, type PromiseOrValue, type ResetPeriodPromiseRateLimiter } from '@dereekb/util';
|
|
2
2
|
import { type FetchResponseError, type RateLimitedFetchHandler } from '@dereekb/util/fetch';
|
|
3
3
|
import { type ZohoRateLimitHeaderDetails } from './zoho.error.api';
|
|
4
|
+
/**
|
|
5
|
+
* Reference interface for objects that expose the shared Zoho rate limiter instance.
|
|
6
|
+
*/
|
|
4
7
|
export interface ZohoRateLimiterRef {
|
|
5
8
|
readonly zohoRateLimiter: ResetPeriodPromiseRateLimiter;
|
|
6
9
|
}
|
|
7
10
|
/**
|
|
8
|
-
*
|
|
11
|
+
* Callback invoked when a 429 Too Many Requests response is received from the Zoho API.
|
|
9
12
|
*
|
|
10
|
-
* Typically used for logging
|
|
13
|
+
* Typically used for logging or alerting. Any errors thrown by this function are silently ignored.
|
|
11
14
|
*/
|
|
12
15
|
export type ZohoRateLimitedTooManyRequestsLogFunction = (headers: ZohoRateLimitHeaderDetails, response: Response, fetchResponseError?: FetchResponseError) => PromiseOrValue<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Default handler that logs a warning to the console when the Zoho API rate limit is exceeded.
|
|
18
|
+
*/
|
|
13
19
|
export declare const DEFAULT_ZOHO_RATE_LIMITED_TOO_MANY_REQUETS_LOG_FUNCTION: (headers: ZohoRateLimitHeaderDetails) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for the Zoho rate-limited fetch handler, allowing customization of
|
|
22
|
+
* the rate limit, reset period, and 429 response handling.
|
|
23
|
+
*/
|
|
14
24
|
export interface ZohoRateLimitedFetchHandlerConfig {
|
|
15
25
|
/**
|
|
16
|
-
* Custom
|
|
26
|
+
* Custom maximum number of requests allowed per reset period.
|
|
17
27
|
*
|
|
18
|
-
*
|
|
28
|
+
* Defaults to {@link DEFAULT_ZOHO_API_RATE_LIMIT} (100 requests).
|
|
29
|
+
* The actual limit may be dynamically adjusted based on `X-RATELIMIT-LIMIT` response headers.
|
|
19
30
|
*
|
|
20
|
-
*
|
|
31
|
+
* Rate limits vary by Zoho account type:
|
|
32
|
+
* @see https://help.zoho.com/portal/en/community/topic/key-changes-in-api-limits-26-9-2018#:~:text=X%2DRATELIMIT%2DREMAINING%20%2D%20Represents,time%20of%20the%20current%20window.&text=Please%20note%20that%20these%20Rate,API%20limit%20changes%20are%20implemented.
|
|
21
33
|
*/
|
|
22
34
|
readonly maxRateLimit?: number;
|
|
23
35
|
/**
|
|
24
|
-
* Custom reset period for the rate limiter.
|
|
36
|
+
* Custom reset period for the rate limiter in milliseconds.
|
|
25
37
|
*
|
|
26
|
-
* Defaults to 1 minute
|
|
38
|
+
* Defaults to {@link DEFAULT_ZOHO_API_RATE_LIMIT_RESET_PERIOD} (1 minute).
|
|
27
39
|
*/
|
|
28
40
|
readonly resetPeriod?: Milliseconds;
|
|
29
41
|
/**
|
|
30
|
-
* Optional
|
|
42
|
+
* Optional callback invoked when a 429 Too Many Requests response is received.
|
|
31
43
|
*
|
|
32
|
-
* Defaults to
|
|
44
|
+
* Defaults to {@link DEFAULT_ZOHO_RATE_LIMITED_TOO_MANY_REQUETS_LOG_FUNCTION}.
|
|
45
|
+
* Pass `false` to disable the callback entirely.
|
|
33
46
|
*/
|
|
34
47
|
readonly onTooManyRequests?: ZohoRateLimitedTooManyRequestsLogFunction | false;
|
|
35
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* A {@link RateLimitedFetchHandler} configured with a {@link ResetPeriodPromiseRateLimiter}
|
|
51
|
+
* for Zoho API rate limiting. Exposes the underlying `_rateLimiter` for sharing across contexts.
|
|
52
|
+
*/
|
|
36
53
|
export type ZohoRateLimitedFetchHandler = RateLimitedFetchHandler<ResetPeriodPromiseRateLimiter>;
|
|
54
|
+
/**
|
|
55
|
+
* Creates a {@link ZohoRateLimitedFetchHandler} that throttles outgoing requests based on
|
|
56
|
+
* Zoho's rate limit headers (`X-RATELIMIT-LIMIT`, `X-RATELIMIT-REMAINING`, `X-RATELIMIT-RESET`).
|
|
57
|
+
*
|
|
58
|
+
* The handler uses an exponential backoff strategy with the following behavior:
|
|
59
|
+
* - Rate limiting begins after 10% of the allowed requests have been made (`startLimitAt`)
|
|
60
|
+
* - Wait times increase exponentially (rate 1.08) as more requests are made, capped at 10 seconds
|
|
61
|
+
* - On each response, the limiter updates its remaining count and reset time from headers
|
|
62
|
+
* - When the API returns a different limit than configured, the limiter dynamically adjusts
|
|
63
|
+
* - On 429 responses, the request is automatically retried after the rate limiter delay
|
|
64
|
+
* - The limiter is disabled when responses lack rate limit headers (e.g., error responses)
|
|
65
|
+
*
|
|
66
|
+
* @param config - Optional configuration for rate limit, reset period, and 429 handling
|
|
67
|
+
* @returns A rate-limited fetch handler with the underlying rate limiter accessible via `_rateLimiter`
|
|
68
|
+
*/
|
|
37
69
|
export declare function zohoRateLimitedFetchHandler(config?: Maybe<ZohoRateLimitedFetchHandlerConfig>): ZohoRateLimitedFetchHandler;
|