@dereekb/zoho 13.3.1 → 13.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/index.cjs.js +292 -95
  2. package/index.esm.js +292 -96
  3. package/nestjs/docs/zoho-sign-webhooks.md +202 -0
  4. package/nestjs/index.cjs.js +1379 -219
  5. package/nestjs/index.esm.js +1374 -222
  6. package/nestjs/package.json +6 -4
  7. package/nestjs/src/lib/accounts/accounts.service.d.ts +14 -2
  8. package/nestjs/src/lib/crm/crm.api.d.ts +142 -27
  9. package/nestjs/src/lib/crm/crm.config.d.ts +2 -0
  10. package/nestjs/src/lib/recruit/recruit.api.d.ts +162 -31
  11. package/nestjs/src/lib/recruit/recruit.config.d.ts +2 -0
  12. package/nestjs/src/lib/sign/index.d.ts +1 -0
  13. package/nestjs/src/lib/sign/sign.api.d.ts +67 -12
  14. package/nestjs/src/lib/sign/webhook/index.d.ts +6 -0
  15. package/nestjs/src/lib/sign/webhook/webhook.zoho.sign.config.d.ts +11 -0
  16. package/nestjs/src/lib/sign/webhook/webhook.zoho.sign.controller.d.ts +8 -0
  17. package/nestjs/src/lib/sign/webhook/webhook.zoho.sign.d.ts +127 -0
  18. package/nestjs/src/lib/sign/webhook/webhook.zoho.sign.module.d.ts +13 -0
  19. package/nestjs/src/lib/sign/webhook/webhook.zoho.sign.service.d.ts +16 -0
  20. package/nestjs/src/lib/sign/webhook/webhook.zoho.sign.verify.d.ts +45 -0
  21. package/nestjs/src/lib/zoho.config.d.ts +26 -2
  22. package/package.json +4 -2
  23. package/src/lib/accounts/accounts.api.d.ts +9 -5
  24. package/src/lib/accounts/accounts.config.d.ts +12 -2
  25. package/src/lib/accounts/accounts.d.ts +6 -3
  26. package/src/lib/accounts/accounts.error.api.d.ts +13 -0
  27. package/src/lib/accounts/accounts.factory.d.ts +2 -2
  28. package/src/lib/crm/crm.api.d.ts +13 -0
  29. package/src/lib/crm/crm.api.notes.d.ts +15 -0
  30. package/src/lib/crm/crm.api.tags.d.ts +17 -8
  31. package/src/lib/crm/crm.config.d.ts +9 -2
  32. package/src/lib/crm/crm.d.ts +12 -12
  33. package/src/lib/crm/crm.error.api.d.ts +14 -0
  34. package/src/lib/crm/crm.factory.d.ts +3 -3
  35. package/src/lib/crm/crm.notes.d.ts +23 -23
  36. package/src/lib/crm/crm.tags.d.ts +3 -3
  37. package/src/lib/recruit/recruit.api.candidates.d.ts +19 -0
  38. package/src/lib/recruit/recruit.api.d.ts +10 -0
  39. package/src/lib/recruit/recruit.config.d.ts +9 -2
  40. package/src/lib/recruit/recruit.d.ts +12 -12
  41. package/src/lib/recruit/recruit.error.api.d.ts +14 -0
  42. package/src/lib/recruit/recruit.factory.d.ts +3 -3
  43. package/src/lib/sign/sign.config.d.ts +12 -2
  44. package/src/lib/sign/sign.d.ts +14 -14
  45. package/src/lib/sign/sign.error.api.d.ts +13 -0
  46. package/src/lib/sign/sign.factory.d.ts +3 -3
  47. package/src/lib/zoho.error.api.d.ts +25 -8
  48. package/src/lib/zoho.limit.d.ts +8 -1
@@ -0,0 +1,6 @@
1
+ export * from './webhook.zoho.sign';
2
+ export * from './webhook.zoho.sign.config';
3
+ export * from './webhook.zoho.sign.controller';
4
+ export * from './webhook.zoho.sign.module';
5
+ export * from './webhook.zoho.sign.service';
6
+ export * from './webhook.zoho.sign.verify';
@@ -0,0 +1,11 @@
1
+ export declare const ZOHO_SIGN_WEBHOOK_SECRET_TOKEN_ENV_VAR = "ZOHO_SIGN_WEBHOOK_SECRET_TOKEN";
2
+ export interface ZohoSignWebhookConfig {
3
+ readonly webhookSecret: string;
4
+ }
5
+ /**
6
+ * Configuration for the Zoho Sign webhook service.
7
+ */
8
+ export declare abstract class ZohoSignWebhookServiceConfig {
9
+ readonly zohoSignWebhook: ZohoSignWebhookConfig;
10
+ static assertValidConfig(config: ZohoSignWebhookServiceConfig): void;
11
+ }
@@ -0,0 +1,8 @@
1
+ import { type RawBodyBuffer } from '@dereekb/nestjs';
2
+ import { type Request } from 'express';
3
+ import { ZohoSignWebhookService } from './webhook.zoho.sign.service';
4
+ export declare class ZohoSignWebhookController {
5
+ private readonly _zohoSignWebhookService;
6
+ constructor(zohoSignWebhookService: ZohoSignWebhookService);
7
+ handleZohoSignWebhook(req: Request, rawBody: RawBodyBuffer): Promise<void>;
8
+ }
@@ -0,0 +1,127 @@
1
+ import { type HandlerBindAccessor, type HandlerMappedSetFunction, type Handler, type EmailAddress } from '@dereekb/util';
2
+ import { type ZohoSignRequestId, type ZohoSignDocumentId, type ZohoSignActionId, type ZohoSignRequestStatus, type ZohoSignRequestTypeId } from '@dereekb/zoho';
3
+ /**
4
+ * Zoho Sign webhook operation type constants.
5
+ *
6
+ * These correspond to the `operation_type` field in the webhook `notifications` payload.
7
+ */
8
+ export type ZohoSignWebhookOperationType = 'RequestSubmitted' | 'RequestViewed' | 'RequestSigningSuccess' | 'RequestCompleted' | 'RequestRejected' | 'RequestRecalled' | 'RequestForwarded' | 'RequestExpired';
9
+ /**
10
+ * The `notifications` portion of a Zoho Sign webhook payload.
11
+ *
12
+ * Contains details about the action performed on the document.
13
+ */
14
+ export interface ZohoSignWebhookNotification {
15
+ /**
16
+ * Email address of the person who performed the operation.
17
+ */
18
+ readonly performed_by_email: EmailAddress;
19
+ /**
20
+ * Name of the person who performed the operation.
21
+ */
22
+ readonly performed_by_name: string;
23
+ /**
24
+ * Timestamp of the operation in Java milliseconds.
25
+ */
26
+ readonly performed_at: number;
27
+ /**
28
+ * Reason stated for the operation, if applicable.
29
+ */
30
+ readonly reason?: string;
31
+ /**
32
+ * Short description of the activity performed.
33
+ */
34
+ readonly activity: string;
35
+ /**
36
+ * The type of operation that triggered this webhook.
37
+ */
38
+ readonly operation_type: ZohoSignWebhookOperationType;
39
+ /**
40
+ * Sign action ID of the signer.
41
+ *
42
+ * Present for signer-related actions: RequestViewed, RequestSigningSuccess,
43
+ * RequestRejected, and RequestForwarded.
44
+ */
45
+ readonly action_id?: ZohoSignActionId;
46
+ /**
47
+ * IP address captured during this operation.
48
+ */
49
+ readonly ip_address?: string;
50
+ }
51
+ /**
52
+ * A document reference within the webhook request data.
53
+ */
54
+ export interface ZohoSignWebhookDocumentRef {
55
+ readonly document_name: string;
56
+ readonly document_id: ZohoSignDocumentId;
57
+ }
58
+ /**
59
+ * The `requests` portion of a Zoho Sign webhook payload.
60
+ *
61
+ * Contains details about the document for which the webhook was triggered.
62
+ */
63
+ export interface ZohoSignWebhookRequestData {
64
+ readonly request_status: ZohoSignRequestStatus;
65
+ readonly request_name: string;
66
+ readonly request_id: ZohoSignRequestId;
67
+ readonly org_id?: string;
68
+ readonly request_type_id?: ZohoSignRequestTypeId;
69
+ readonly document_ids: ZohoSignWebhookDocumentRef[];
70
+ }
71
+ /**
72
+ * The complete webhook payload from Zoho Sign.
73
+ *
74
+ * Contains two top-level keys: `notifications` (the action details) and
75
+ * `requests` (the document details).
76
+ *
77
+ * @example
78
+ * ```json
79
+ * {
80
+ * "notifications": {
81
+ * "performed_by_email": "testuser@zoho.com",
82
+ * "performed_at": 1555062604837,
83
+ * "activity": "Document has been signed",
84
+ * "operation_type": "RequestSigningSuccess",
85
+ * "action_id": "1000000000090",
86
+ * "performed_by_name": "test user"
87
+ * },
88
+ * "requests": {
89
+ * "request_name": "NDA Document",
90
+ * "request_id": "1000000000000",
91
+ * "request_status": "inprogress",
92
+ * "document_ids": [{ "document_name": "CommonNDA.pdf", "document_id": "100000000000050" }]
93
+ * }
94
+ * }
95
+ * ```
96
+ */
97
+ export interface ZohoSignWebhookPayload {
98
+ readonly notifications: ZohoSignWebhookNotification;
99
+ readonly requests: ZohoSignWebhookRequestData;
100
+ }
101
+ /**
102
+ * A parsed Zoho Sign webhook event, providing convenient access to the operation type.
103
+ */
104
+ export type ZohoSignWebhookEvent<T extends ZohoSignWebhookOperationType = ZohoSignWebhookOperationType> = ZohoSignWebhookPayload & {
105
+ readonly operationType: T;
106
+ };
107
+ /**
108
+ * Creates a {@link ZohoSignWebhookEvent} from a raw payload.
109
+ *
110
+ * @param payload - the raw Zoho Sign webhook payload to convert
111
+ * @returns a webhook event with the operation type extracted for convenience
112
+ */
113
+ export declare function zohoSignWebhookEvent(payload: ZohoSignWebhookPayload): ZohoSignWebhookEvent;
114
+ export type ZohoSignEventHandler = Handler<ZohoSignWebhookEvent, ZohoSignWebhookOperationType>;
115
+ export declare const zohoSignEventHandlerFactory: import("@dereekb/util").HandlerFactory<ZohoSignWebhookEvent<ZohoSignWebhookOperationType>, ZohoSignWebhookOperationType, boolean>;
116
+ export type ZohoSignHandlerMappedSetFunction<T extends ZohoSignWebhookOperationType = ZohoSignWebhookOperationType> = HandlerMappedSetFunction<ZohoSignWebhookEvent<T>>;
117
+ export interface ZohoSignEventHandlerConfigurer extends HandlerBindAccessor<ZohoSignWebhookEvent, ZohoSignWebhookOperationType> {
118
+ readonly handleRequestSubmitted: ZohoSignHandlerMappedSetFunction<'RequestSubmitted'>;
119
+ readonly handleRequestViewed: ZohoSignHandlerMappedSetFunction<'RequestViewed'>;
120
+ readonly handleRequestSigningSuccess: ZohoSignHandlerMappedSetFunction<'RequestSigningSuccess'>;
121
+ readonly handleRequestCompleted: ZohoSignHandlerMappedSetFunction<'RequestCompleted'>;
122
+ readonly handleRequestRejected: ZohoSignHandlerMappedSetFunction<'RequestRejected'>;
123
+ readonly handleRequestRecalled: ZohoSignHandlerMappedSetFunction<'RequestRecalled'>;
124
+ readonly handleRequestForwarded: ZohoSignHandlerMappedSetFunction<'RequestForwarded'>;
125
+ readonly handleRequestExpired: ZohoSignHandlerMappedSetFunction<'RequestExpired'>;
126
+ }
127
+ export declare const zohoSignEventHandlerConfigurerFactory: import("@dereekb/util").HandlerConfigurerFactory<ZohoSignEventHandlerConfigurer, ZohoSignWebhookEvent<ZohoSignWebhookOperationType>, ZohoSignWebhookOperationType, boolean>;
@@ -0,0 +1,13 @@
1
+ import { ZohoSignWebhookServiceConfig } from './webhook.zoho.sign.config';
2
+ import { ConfigService } from '@nestjs/config';
3
+ /**
4
+ * Reads the Zoho Sign webhook secret from the NestJS ConfigService
5
+ * and returns a validated webhook service config.
6
+ *
7
+ * @param configService - NestJS config service populated with webhook environment variables
8
+ * @returns Validated Zoho Sign webhook service configuration
9
+ * @throws {Error} If the webhook secret is not configured
10
+ */
11
+ export declare function zohoSignWebhookServiceConfigFactory(configService: ConfigService): ZohoSignWebhookServiceConfig;
12
+ export declare class ZohoSignWebhookModule {
13
+ }
@@ -0,0 +1,16 @@
1
+ import { type Request } from 'express';
2
+ import { type ZohoSignWebhookEvent, type ZohoSignWebhookOperationType } from './webhook.zoho.sign';
3
+ import { type Handler } from '@dereekb/util';
4
+ import { ZohoSignWebhookServiceConfig } from './webhook.zoho.sign.config';
5
+ /**
6
+ * Service that handles Zoho Sign webhook events.
7
+ */
8
+ export declare class ZohoSignWebhookService {
9
+ private readonly logger;
10
+ private readonly _verifier;
11
+ readonly handler: Handler<ZohoSignWebhookEvent, ZohoSignWebhookOperationType>;
12
+ readonly configure: import("@dereekb/util").HandlerConfigurer<import("./webhook.zoho.sign").ZohoSignEventHandlerConfigurer, ZohoSignWebhookEvent<ZohoSignWebhookOperationType>, ZohoSignWebhookOperationType, boolean>;
13
+ constructor(zohoSignWebhookServiceConfig: ZohoSignWebhookServiceConfig);
14
+ updateForWebhook(req: Request, rawBody: Buffer): Promise<void>;
15
+ updateForZohoSignEvent(event: ZohoSignWebhookEvent): Promise<void>;
16
+ }
@@ -0,0 +1,45 @@
1
+ import { type Request } from 'express';
2
+ import { type ZohoSignWebhookEvent } from './webhook.zoho.sign';
3
+ /**
4
+ * Header name used by Zoho Sign to send the HMAC signature.
5
+ */
6
+ export declare const ZOHO_SIGN_WEBHOOK_SIGNATURE_HEADER = "x-zs-webhook-signature";
7
+ export interface ZohoSignWebhookVerificationConfig {
8
+ /**
9
+ * Secret key configured in Zoho Sign webhook settings.
10
+ */
11
+ readonly secret: string;
12
+ }
13
+ export type ZohoSignWebhookEventVerificationResult = ZohoSignWebhookEventVerificationSuccessResult | ZohoSignWebhookEventVerificationErrorResult;
14
+ export interface ZohoSignWebhookEventVerificationSuccessResult {
15
+ readonly valid: true;
16
+ readonly event: ZohoSignWebhookEvent;
17
+ }
18
+ export interface ZohoSignWebhookEventVerificationErrorResult {
19
+ readonly valid: false;
20
+ }
21
+ /**
22
+ * Function that verifies a Zoho Sign webhook event.
23
+ */
24
+ export type ZohoSignWebhookEventVerifier = (req: Request, rawBody: Buffer) => Promise<ZohoSignWebhookEventVerificationResult>;
25
+ /**
26
+ * Creates a verifier for Zoho Sign webhook events using HMAC-SHA256 signature verification.
27
+ *
28
+ * Zoho Sign computes `base64(HMAC-SHA256(payload, secret))` and sends the result
29
+ * in the `X-ZS-WEBHOOK-SIGNATURE` header. This verifier recomputes the signature
30
+ * from the raw request body and compares using timing-safe equality.
31
+ *
32
+ * @param config - Configuration containing the webhook secret key
33
+ * @returns A function that verifies webhook requests
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const verifier = zohoSignWebhookEventVerifier({ secret: 'my-secret-key' });
38
+ * const result = await verifier(req, rawBody);
39
+ *
40
+ * if (result.valid) {
41
+ * console.log(result.event.operationType);
42
+ * }
43
+ * ```
44
+ */
45
+ export declare function zohoSignWebhookEventVerifier(config: ZohoSignWebhookVerificationConfig): ZohoSignWebhookEventVerifier;
@@ -13,15 +13,39 @@ export interface ZohoConfigServiceReaderConfig {
13
13
  export type ZohoConfigServiceReaderFunction = (configKey: string) => string;
14
14
  /**
15
15
  * Creates a new ZohoConfigServiceReaderFunction that reads from the input ConfigService.
16
+ *
16
17
  * @param input
18
+ * @returns a function that reads config values for the given Zoho service
17
19
  */
18
20
  export declare function zohoConfigServiceReaderFunction(input: ZohoConfigServiceReaderConfig): ZohoConfigServiceReaderFunction;
19
21
  export declare function zohoConfigServiceReaderFunction(serviceAccessTokenKey: ZohoServiceAccessTokenKey, configService: ConfigService): ZohoConfigServiceReaderFunction;
22
+ export interface ReadZohoConfigFromConfigServiceConfig {
23
+ readonly configService: ConfigService;
24
+ readonly servicePrefix?: string;
25
+ readonly assertValid?: boolean;
26
+ }
20
27
  /**
21
28
  * Reads the ZohoConfig config from the ConfigService.
22
29
  *
23
- * @param configService
24
- * @param prefix
30
+ * @param config - Configuration for reading from the config service
31
+ * @param configService - NestJS ConfigService to read environment variables from
32
+ * @param servicePrefix - optional prefix to scope config keys per service
33
+ * @param assertValid - whether to throw if required config values are missing
34
+ * @returns ZohoConfig read from environment variables
35
+ */
36
+ export declare function readZohoConfigFromConfigService(config: ReadZohoConfigFromConfigServiceConfig): ZohoConfig;
37
+ /**
38
+ * @deprecated Use the config object overload instead.
39
+ *
40
+ * @param configService - NestJS ConfigService to read environment variables from
41
+ * @param servicePrefix - optional prefix to scope config keys per service
42
+ * @param assertValid - whether to throw if required config values are missing
43
+ * @returns ZohoConfig read from environment variables
25
44
  */
26
45
  export declare function readZohoConfigFromConfigService(configService: ConfigService, servicePrefix?: string, assertValid?: boolean): ZohoConfig;
46
+ /**
47
+ * Asserts that the provided ZohoConfig has a valid API URL configured.
48
+ *
49
+ * @param config - the Zoho config to validate
50
+ */
27
51
  export declare function assertValidZohoConfig(config: ZohoConfig): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/zoho",
3
- "version": "13.3.1",
3
+ "version": "13.4.1",
4
4
  "exports": {
5
5
  "./nestjs": {
6
6
  "module": "./nestjs/index.esm.js",
@@ -17,9 +17,11 @@
17
17
  }
18
18
  },
19
19
  "peerDependencies": {
20
- "@dereekb/util": "13.3.1",
20
+ "@dereekb/nestjs": "13.4.1",
21
+ "@dereekb/util": "13.4.1",
21
22
  "@nestjs/common": "^11.1.16",
22
23
  "@nestjs/config": "^4.0.3",
24
+ "express": "^5.0.0",
23
25
  "make-error": "^1.3.0"
24
26
  },
25
27
  "devDependencies": {
@@ -26,23 +26,23 @@ export interface ZohoAccountsAccessTokenResponse {
26
26
  /**
27
27
  * Short-lived OAuth access token for authenticating API calls.
28
28
  */
29
- access_token: ZohoAccessTokenString;
29
+ readonly access_token: ZohoAccessTokenString;
30
30
  /**
31
31
  * Comma-separated list of OAuth scopes granted to this token.
32
32
  */
33
- scope: ZohoAccessTokenScopesString;
33
+ readonly scope: ZohoAccessTokenScopesString;
34
34
  /**
35
35
  * The API domain to use for subsequent API calls (e.g. `'https://www.zohoapis.com'`).
36
36
  */
37
- api_domain: ZohoAccessTokenApiDomain;
37
+ readonly api_domain: ZohoAccessTokenApiDomain;
38
38
  /**
39
39
  * Token type, always `'Bearer'`.
40
40
  */
41
- token_type: 'Bearer';
41
+ readonly token_type: 'Bearer';
42
42
  /**
43
43
  * Number of seconds until the access token expires.
44
44
  */
45
- expires_in: Seconds;
45
+ readonly expires_in: Seconds;
46
46
  }
47
47
  /**
48
48
  * Error response from the Zoho OAuth token endpoint when the refresh fails.
@@ -169,5 +169,9 @@ export type ZohoAccountsRefreshTokenFromAuthorizationCodeFunction = (input: Zoho
169
169
  export declare function zohoAccountsRefreshTokenFromAuthorizationCode(context: ZohoAccountsContext): ZohoAccountsRefreshTokenFromAuthorizationCodeFunction;
170
170
  /**
171
171
  * Constructs a standard {@link FetchJsonInput} for Zoho Accounts API calls with the given HTTP method and optional body.
172
+ *
173
+ * @param method - HTTP method to use for the request
174
+ * @param body - Optional request body to include
175
+ * @returns Configured fetch input for the Zoho Accounts API call
172
176
  */
173
177
  export declare function zohoAccountsApiFetchJsonInput(method: string, body?: FetchJsonBody): FetchJsonInput;
@@ -16,6 +16,12 @@ export declare const ZOHO_ACCOUNTS_US_API_URL = "https://accounts.zoho.com";
16
16
  export type ZohoAccountsApiUrl = ZohoApiUrl;
17
17
  export type ZohoAccountsApiUrlKey = 'us';
18
18
  export type ZohoAccountsConfigApiUrlInput = ZohoAccountsApiUrlKey | ZohoAccountsApiUrl;
19
+ /**
20
+ * Resolves a Zoho Accounts API URL input to the full base URL. The 'us' key maps to the US datacenter; custom URLs pass through unchanged.
21
+ *
22
+ * @param input - A well-known datacenter key or a custom Zoho Accounts API URL
23
+ * @returns The resolved full Zoho Accounts API base URL
24
+ */
19
25
  export declare function zohoAccountsConfigApiUrl(input: ZohoAccountsConfigApiUrlInput): ZohoApiUrl;
20
26
  /**
21
27
  * Configuration for ZohoAccounts.
@@ -30,10 +36,10 @@ export interface ZohoAccountsConfig extends ZohoConfig, ZohoAuthClientIdAndSecre
30
36
  */
31
37
  readonly accessTokenCache?: Maybe<ZohoAccessTokenCache>;
32
38
  }
33
- export interface ZohoAccountsFetchFactoryInput {
39
+ export interface ZohoAccountsFetchFactoryParams {
34
40
  readonly apiUrl: ZohoApiUrl;
35
41
  }
36
- export type ZohoAccountsFetchFactory = FactoryWithRequiredInput<ConfiguredFetch, ZohoAccountsFetchFactoryInput>;
42
+ export type ZohoAccountsFetchFactory = FactoryWithRequiredInput<ConfiguredFetch, ZohoAccountsFetchFactoryParams>;
37
43
  export interface ZohoAccountsContext {
38
44
  readonly fetch: ConfiguredFetch;
39
45
  readonly fetchJson: FetchJsonFunction;
@@ -43,3 +49,7 @@ export interface ZohoAccountsContext {
43
49
  export interface ZohoAccountsContextRef {
44
50
  readonly accountsContext: ZohoAccountsContext;
45
51
  }
52
+ /**
53
+ * @deprecated use ZohoAccountsFetchFactoryParams instead.
54
+ */
55
+ export type ZohoAccountsFetchFactoryInput = ZohoAccountsFetchFactoryParams;
@@ -1,4 +1,4 @@
1
- import { type Maybe } from '@dereekb/util';
1
+ import { type Maybe, type Seconds } from '@dereekb/util';
2
2
  import { type ZohoApiServiceName } from '../zoho.config';
3
3
  /**
4
4
  * Arbitrary key used to identify a specific service's access token. Typically coincides with the ZohoApiServiceName.
@@ -30,9 +30,9 @@ export interface ZohoAccessToken {
30
30
  readonly scope: ZohoAccessTokenScopesString;
31
31
  readonly apiDomain: ZohoAccessTokenApiDomain;
32
32
  /**
33
- * Length of time the token is valid for.
33
+ * Length of time the token is valid for, in seconds.
34
34
  */
35
- readonly expiresIn: number;
35
+ readonly expiresIn: Seconds;
36
36
  /**
37
37
  * Date the token expires at.
38
38
  */
@@ -80,5 +80,8 @@ export type ZohoAccessTokenRefresher = ZohoAccessTokenFactory;
80
80
  export type ZohoAccessTokenStringFactory = () => Promise<ZohoAccessTokenString>;
81
81
  /**
82
82
  * Generates a new ZohoAccessTokenStringFactory.
83
+ *
84
+ * @param zohoAccessTokenFactory - Factory that produces ZohoAccessToken instances
85
+ * @returns A factory function that resolves to the access token string
83
86
  */
84
87
  export declare function zohoAccessTokenStringFactory(zohoAccessTokenFactory: ZohoAccessTokenFactory): ZohoAccessTokenStringFactory;
@@ -22,7 +22,20 @@ export declare class ZohoAccountsAuthFailureError extends FetchRequestFactoryErr
22
22
  constructor(reason?: string | undefined);
23
23
  }
24
24
  export declare const logZohoAccountsErrorToConsole: import("..").LogZohoServerErrorFunction;
25
+ /**
26
+ * Parses a fetch response error into a typed Zoho Accounts server error by extracting and interpreting the JSON error body.
27
+ *
28
+ * @param responseError - The fetch response error to parse
29
+ * @returns The parsed Zoho server error, or undefined if the response could not be parsed
30
+ */
25
31
  export declare function parseZohoAccountsError(responseError: FetchResponseError): Promise<ParsedZohoServerError>;
32
+ /**
33
+ * Parses a Zoho Accounts error response body into a typed error. Handles account-specific error codes before falling back to the generic Zoho error parser.
34
+ *
35
+ * @param errorResponseData - The raw error response data from the Zoho Accounts API
36
+ * @param responseError - The original fetch response error for context
37
+ * @returns The parsed Zoho server error, or undefined if the error could not be classified
38
+ */
26
39
  export declare function parseZohoAccountsServerErrorResponseData(errorResponseData: ZohoServerErrorResponseData, responseError: FetchResponseError): ParsedZohoServerError;
27
40
  export declare const interceptZohoAccounts200StatusWithErrorResponse: import("@dereekb/util/fetch").FetchJsonInterceptJsonResponseFunction;
28
41
  export declare const handleZohoAccountsErrorFetch: import("..").HandleZohoErrorFetchFactory;
@@ -16,11 +16,11 @@ export interface ZohoAccountsFactoryConfig {
16
16
  * Custom fetch factory for creating the underlying HTTP client.
17
17
  * Defaults to a standard fetch service with JSON content headers and a 20-second timeout.
18
18
  */
19
- fetchFactory?: ZohoAccountsFetchFactory;
19
+ readonly fetchFactory?: ZohoAccountsFetchFactory;
20
20
  /**
21
21
  * Custom error logging function invoked when Zoho API errors are encountered.
22
22
  */
23
- logZohoServerErrorFunction?: LogZohoServerErrorFunction;
23
+ readonly logZohoServerErrorFunction?: LogZohoServerErrorFunction;
24
24
  }
25
25
  /**
26
26
  * Factory function that creates a {@link ZohoAccounts} client from a {@link ZohoAccountsConfig}.
@@ -860,10 +860,16 @@ export type ZohoCrmExecuteRestApiFunctionFunction = (input: ZohoCrmExecuteRestAp
860
860
  export declare function zohoCrmExecuteRestApiFunction(context: ZohoCrmContext): ZohoCrmExecuteRestApiFunctionFunction;
861
861
  /**
862
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
+ *
864
+ * @param input - One or more objects to convert into URL search parameters
865
+ * @returns URL search params string with the `module` key excluded
863
866
  */
864
867
  export declare function zohoCrmUrlSearchParamsMinusModule(...input: Maybe<object | Record<string, string | number>>[]): URLSearchParams;
865
868
  /**
866
869
  * Builds URL search params from the input objects, omitting both `id` and `module` keys since they are used in the URL path.
870
+ *
871
+ * @param input - One or more objects to convert into URL search parameters
872
+ * @returns URL search params string with `id` and `module` keys excluded
867
873
  */
868
874
  export declare function zohoCrmUrlSearchParamsMinusIdAndModule(...input: Maybe<object | Record<string, string | number>>[]): URLSearchParams;
869
875
  /**
@@ -872,12 +878,19 @@ export declare function zohoCrmUrlSearchParamsMinusIdAndModule(...input: Maybe<o
872
878
  export declare const zohoCrmUrlSearchParams: typeof makeUrlSearchParams;
873
879
  /**
874
880
  * Constructs the standard FetchJsonInput used by CRM API calls, pairing the HTTP method with an optional body.
881
+ *
882
+ * @param method - HTTP method to use for the request
883
+ * @param body - Optional request body to include
884
+ * @returns Configured fetch input for the Zoho CRM API call
875
885
  */
876
886
  export declare function zohoCrmApiFetchJsonInput(method: string, body?: Maybe<FetchJsonBody>): FetchJsonInput;
877
887
  /**
878
888
  * Catches ZohoServerFetchResponseDataArrayError and returns the error data array as the response data, as each data element will have the error details.
879
889
  *
880
890
  * Use to catch errors from functions that return ZohoCrmChangeObjectLikeResponse and pass the result to zohoCrmChangeObjectLikeResponseSuccessAndErrorPairs.
891
+ *
892
+ * @param e - The error to catch and potentially convert
893
+ * @returns The error data array wrapped as a change object response
881
894
  */
882
895
  export declare function zohoCrmCatchZohoCrmChangeObjectLikeResponseError<R extends ZohoCrmChangeObjectLikeResponse<any>>(e: unknown): R;
883
896
  export type ZohoCrmChangeObjectLikeResponse<T extends ZohoCrmChangeObjectLikeResponseEntry = ZohoCrmChangeObjectLikeResponseEntry> = ZohoDataArrayResultRef<T>;
@@ -28,6 +28,9 @@ export type ZohoCrmCreateNotesFunction = (input: ZohoCrmCreateNotesRequest) => P
28
28
  * Creates notes directly in the CRM Notes module. Each note must include the parent record reference and module name.
29
29
  *
30
30
  * For creating notes associated with a specific record, prefer {@link zohoCrmCreateNotesForRecord} which handles parent binding automatically.
31
+ *
32
+ * @param context - Authenticated Zoho CRM context for making API calls
33
+ * @returns Function that creates notes in the CRM Notes module
31
34
  */
32
35
  export declare function zohoCrmCreateNotes(context: ZohoCrmContext): (input: ZohoCrmCreateNotesRequest) => Promise<ZohoCrmMultiRecordResult<NewZohoCrmNoteData, ZohoCrmChangeObjectResponseSuccessEntry<import("./crm").ZohoCrmChangeObjectDetails>, ZohoCrmChangeObjectResponseErrorEntry>>;
33
36
  /**
@@ -47,6 +50,9 @@ export type ZohoCrmDeleteNotesResponse = ZohoCrmChangeObjectResponse;
47
50
  export type ZohoCrmDeleteNotesFunction = (input: ZohoCrmDeleteNotesRequest) => Promise<ZohoCrmDeleteNotesResult>;
48
51
  /**
49
52
  * Deletes one or more notes from the CRM Notes module by their IDs.
53
+ *
54
+ * @param context - Authenticated Zoho CRM context for making API calls
55
+ * @returns Function that deletes notes by their IDs
50
56
  */
51
57
  export declare function zohoCrmDeleteNotes(context: ZohoCrmContext): (input: ZohoCrmDeleteNotesRequest) => Promise<ZohoCrmMultiRecordResult<string, ZohoCrmChangeObjectResponseSuccessEntry<import("./crm").ZohoCrmChangeObjectDetails>, ZohoCrmChangeObjectResponseErrorEntry>>;
52
58
  /**
@@ -60,11 +66,17 @@ export type ZohoCrmGetNotesForRecordResponse = ZohoPageResult<ZohoCrmRecordNote>
60
66
  export type ZohoCrmGetNotesForRecordFunction = (input: ZohoCrmGetNotesForRecordRequest) => Promise<ZohoCrmGetNotesForRecordResponse>;
61
67
  /**
62
68
  * Retrieves paginated notes associated with a specific CRM record using the related records API.
69
+ *
70
+ * @param context - Authenticated Zoho CRM context for making API calls
71
+ * @returns Function that retrieves notes for a specific record
63
72
  */
64
73
  export declare function zohoCrmGetNotesForRecord(context: ZohoCrmContext): ZohoCrmGetNotesForRecordFunction;
65
74
  export type ZohoCrmGetNotesForRecordPageFactory = FetchPageFactory<ZohoCrmGetNotesForRecordRequest, ZohoCrmGetNotesForRecordResponse>;
66
75
  /**
67
76
  * Creates a page factory for iterating through all notes for a record across multiple pages.
77
+ *
78
+ * @param context - Authenticated Zoho CRM context for making API calls
79
+ * @returns Page factory for paginating through notes for a record
68
80
  */
69
81
  export declare function zohoCrmGetNotesForRecordPageFactory(context: ZohoCrmContext): ZohoCrmGetNotesForRecordPageFactory;
70
82
  /**
@@ -79,5 +91,8 @@ export type ZohoCrmCreateNotesForRecordFunction = (input: ZohoCrmCreateNotesForR
79
91
  * Creates notes for a specific record, automatically binding the parent module and record ID to each note entry.
80
92
  *
81
93
  * https://www.zoho.com/crm/developer/docs/api/v8/create-notes.html
94
+ *
95
+ * @param context - Authenticated Zoho CRM context for making API calls
96
+ * @returns Function that creates notes bound to a specific record
82
97
  */
83
98
  export declare function zohoCrmCreateNotesForRecord(context: ZohoCrmContext): ZohoCrmCreateNotesForRecordFunction;
@@ -31,6 +31,9 @@ export type ZohoCrmCreateTagsResult = ZohoCrmMultiRecordResult<ZohoCrmCreateTagD
31
31
  export type ZohoCrmCreateTagsFunction = (input: ZohoCrmCreateTagsRequest) => Promise<ZohoCrmCreateTagsResult>;
32
32
  /**
33
33
  * Creates one or more tags for a CRM module. Duplicate tag errors are separated from other errors in the result to simplify idempotent workflows.
34
+ *
35
+ * @param context - Authenticated Zoho CRM context for making API calls
36
+ * @returns Function that creates tags for a module
34
37
  */
35
38
  export declare function zohoCrmCreateTagsForModule(context: ZohoCrmContext): (input: ZohoCrmCreateTagsRequest) => Promise<{
36
39
  errorItems: ZohoCrmMultiRecordResultEntry<ZohoCrmCreateTagData, ZohoCrmChangeObjectResponseErrorEntry>[];
@@ -67,8 +70,8 @@ export type ZohoCrmDeleteTagFunction = (input: ZohoCrmDeleteTagRequest) => Promi
67
70
  *
68
71
  * https://www.zoho.com/crm/developer/docs/api/v8/delete-tag.html
69
72
  *
70
- * @param context
71
- * @returns
73
+ * @param context - Authenticated Zoho CRM context for making API calls
74
+ * @returns Function that deletes a tag by ID
72
75
  */
73
76
  export declare function zohoCrmDeleteTag(context: ZohoCrmContext): ZohoCrmDeleteTagFunction;
74
77
  /**
@@ -93,13 +96,16 @@ export type ZohoCrmGetTagsFunction = (input: ZohoCrmGetTagsRequest) => Promise<Z
93
96
  *
94
97
  * https://www.zoho.com/crm/developer-guide/apiv2/get-tag-list.html
95
98
  *
96
- * @param context
97
- * @returns
99
+ * @param context - Authenticated Zoho CRM context for making API calls
100
+ * @returns Function that retrieves tags for a module
98
101
  */
99
102
  export declare function zohoCrmGetTagsForModule(context: ZohoCrmContext): ZohoCrmGetTagsFunction;
100
103
  export type ZohoCrmGetTagsForModulePageFactory = (input: ZohoCrmGetTagsRequest, options?: Maybe<FetchPageFactoryOptions<ZohoCrmGetTagsRequest, ZohoCrmGetTagsResult>>) => FetchPage<ZohoCrmGetTagsRequest, ZohoCrmGetTagsResult>;
101
104
  /**
102
105
  * Creates a page factory for iterating through all tags in a module across multiple pages.
106
+ *
107
+ * @param context - Authenticated Zoho CRM context for making API calls
108
+ * @returns Page factory for paginating through tags in a module
103
109
  */
104
110
  export declare function zohoCrmGetTagsForModulePageFactory(context: ZohoCrmContext): ZohoCrmGetTagsForModulePageFactory;
105
111
  /**
@@ -165,12 +171,15 @@ export type ZohoCrmAddTagsToRecordsFunction = (input: ZohoCrmAddTagsToRecordsReq
165
171
  *
166
172
  * https://www.zoho.com/crm/developer-guide/apiv2/add-tags.html
167
173
  *
168
- * @param context
169
- * @returns
174
+ * @param context - Authenticated Zoho CRM context for making API calls
175
+ * @returns Function that adds tags to records
170
176
  */
171
177
  export declare function zohoCrmAddTagsToRecords(context: ZohoCrmContext): ZohoCrmAddTagsToRecordsFunction;
172
178
  /**
173
179
  * Builds the request body for the add/remove tags endpoints, merging `tag_names` into `tags` and enforcing the max ID limit.
180
+ *
181
+ * @param input - The add/remove tags request containing tag names, tag objects, and record IDs
182
+ * @returns The formatted request body with merged tags and record IDs
174
183
  */
175
184
  export declare function zohoCrmAddTagsToRecordsRequestBody(input: ZohoCrmAddTagsToRecordsRequest): {
176
185
  tags: (ZohoCrmTagData & {
@@ -217,7 +226,7 @@ export type ZohoCrmRemoveTagsFromRecordsFunction = (input: ZohoCrmRemoveTagsFrom
217
226
  *
218
227
  * https://www.zoho.com/crm/developer-guide/apiv2/remove-tags.html
219
228
  *
220
- * @param context
221
- * @returns
229
+ * @param context - Authenticated Zoho CRM context for making API calls
230
+ * @returns Function that removes tags from records
222
231
  */
223
232
  export declare function zohoCrmRemoveTagsFromRecords(context: ZohoCrmContext): ZohoCrmRemoveTagsFromRecordsFunction;
@@ -21,6 +21,9 @@ export type ZohoCrmApiUrlKey = ZohoApiUrlKey;
21
21
  export type ZohoCrmConfigApiUrlInput = ZohoCrmApiUrlKey | ZohoCrmApiUrl;
22
22
  /**
23
23
  * Resolves a CRM API URL input to its full base URL. Well-known keys ('sandbox', 'production') map to their respective Zoho CRM endpoints; custom URLs pass through unchanged.
24
+ *
25
+ * @param input - A well-known environment key or a custom CRM API URL
26
+ * @returns The resolved full Zoho CRM API base URL
24
27
  */
25
28
  export declare function zohoCrmConfigApiUrl(input: ZohoCrmConfigApiUrlInput): ZohoApiUrl;
26
29
  /**
@@ -30,13 +33,13 @@ export type ZohoCrmConfig = ZohoConfig;
30
33
  /**
31
34
  * Input provided to a CRM fetch factory to construct an authenticated fetch instance for a specific API base URL.
32
35
  */
33
- export interface ZohoCrmFetchFactoryInput {
36
+ export interface ZohoCrmFetchFactoryParams {
34
37
  readonly apiUrl: ZohoCrmApiUrl;
35
38
  }
36
39
  /**
37
40
  * Factory that produces a pre-configured fetch instance bound to a specific Zoho CRM API URL, used to customize HTTP transport (e.g., timeouts, headers).
38
41
  */
39
- export type ZohoCrmFetchFactory = FactoryWithRequiredInput<ConfiguredFetch, ZohoCrmFetchFactoryInput>;
42
+ export type ZohoCrmFetchFactory = FactoryWithRequiredInput<ConfiguredFetch, ZohoCrmFetchFactoryParams>;
40
43
  /**
41
44
  * Core context for making authenticated Zoho CRM API calls. Bundles the configured fetch, JSON parsing, access token management, rate limiting, and service configuration needed by all CRM operations.
42
45
  */
@@ -52,3 +55,7 @@ export interface ZohoCrmContext extends ZohoRateLimiterRef {
52
55
  export interface ZohoCrmContextRef {
53
56
  readonly crmContext: ZohoCrmContext;
54
57
  }
58
+ /**
59
+ * @deprecated use ZohoCrmFetchFactoryParams instead.
60
+ */
61
+ export type ZohoCrmFetchFactoryInput = ZohoCrmFetchFactoryParams;