@dereekb/zoho 10.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +11 -0
- package/index.cjs.d.ts +1 -0
- package/index.cjs.js +3353 -0
- package/index.esm.js +4396 -0
- package/nestjs/CHANGELOG.md +16 -0
- package/nestjs/README.md +11 -0
- package/nestjs/package.json +6 -0
- package/nestjs/src/index.d.ts +1 -0
- package/nestjs/src/index.js +5 -0
- package/nestjs/src/index.js.map +1 -0
- package/nestjs/src/lib/accounts/accounts.api.d.ts +11 -0
- package/nestjs/src/lib/accounts/accounts.api.js +33 -0
- package/nestjs/src/lib/accounts/accounts.api.js.map +1 -0
- package/nestjs/src/lib/accounts/accounts.config.d.ts +15 -0
- package/nestjs/src/lib/accounts/accounts.config.js +48 -0
- package/nestjs/src/lib/accounts/accounts.config.js.map +1 -0
- package/nestjs/src/lib/accounts/accounts.service.d.ts +34 -0
- package/nestjs/src/lib/accounts/accounts.service.js +152 -0
- package/nestjs/src/lib/accounts/accounts.service.js.map +1 -0
- package/nestjs/src/lib/accounts/index.d.ts +3 -0
- package/nestjs/src/lib/accounts/index.js +7 -0
- package/nestjs/src/lib/accounts/index.js.map +1 -0
- package/nestjs/src/lib/index.d.ts +3 -0
- package/nestjs/src/lib/index.js +7 -0
- package/nestjs/src/lib/index.js.map +1 -0
- package/nestjs/src/lib/recruit/index.d.ts +3 -0
- package/nestjs/src/lib/recruit/index.js +7 -0
- package/nestjs/src/lib/recruit/index.js.map +1 -0
- package/nestjs/src/lib/recruit/recruit.api.d.ts +16 -0
- package/nestjs/src/lib/recruit/recruit.api.js +47 -0
- package/nestjs/src/lib/recruit/recruit.api.js.map +1 -0
- package/nestjs/src/lib/recruit/recruit.config.d.ts +10 -0
- package/nestjs/src/lib/recruit/recruit.config.js +14 -0
- package/nestjs/src/lib/recruit/recruit.config.js.map +1 -0
- package/nestjs/src/lib/recruit/recruit.module.d.ts +7 -0
- package/nestjs/src/lib/recruit/recruit.module.js +54 -0
- package/nestjs/src/lib/recruit/recruit.module.js.map +1 -0
- package/nestjs/src/lib/zoho.config.d.ts +27 -0
- package/nestjs/src/lib/zoho.config.js +52 -0
- package/nestjs/src/lib/zoho.config.js.map +1 -0
- package/package.json +30 -0
- package/src/index.d.ts +1 -0
- package/src/lib/accounts/accounts.api.d.ts +27 -0
- package/src/lib/accounts/accounts.config.d.ts +45 -0
- package/src/lib/accounts/accounts.d.ts +75 -0
- package/src/lib/accounts/accounts.error.api.d.ts +28 -0
- package/src/lib/accounts/accounts.factory.d.ts +34 -0
- package/src/lib/accounts/index.d.ts +5 -0
- package/src/lib/index.d.ts +6 -0
- package/src/lib/recruit/index.d.ts +5 -0
- package/src/lib/recruit/recruit.api.d.ts +144 -0
- package/src/lib/recruit/recruit.config.d.ts +23 -0
- package/src/lib/recruit/recruit.d.ts +108 -0
- package/src/lib/recruit/recruit.error.api.d.ts +29 -0
- package/src/lib/recruit/recruit.factory.d.ts +16 -0
- package/src/lib/zoho.api.page.d.ts +37 -0
- package/src/lib/zoho.config.d.ts +35 -0
- package/src/lib/zoho.error.api.d.ts +145 -0
- package/src/lib/zoho.type.d.ts +20 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { PageNumber } from '@dereekb/util';
|
|
2
|
+
export interface ZohoDataArrayResultRef<T> {
|
|
3
|
+
/**
|
|
4
|
+
* Array of data returned.
|
|
5
|
+
*/
|
|
6
|
+
readonly data: T[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Page result that contains an array of data and page information.
|
|
10
|
+
*/
|
|
11
|
+
export interface ZohoPageResult<T> extends ZohoDataArrayResultRef<T> {
|
|
12
|
+
/**
|
|
13
|
+
* Current page information
|
|
14
|
+
*/
|
|
15
|
+
readonly info: ZohoPageResultInfo;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Page information within a ZohoPageResult
|
|
19
|
+
*/
|
|
20
|
+
export interface ZohoPageResultInfo {
|
|
21
|
+
/**
|
|
22
|
+
* Number of results being returned per page.
|
|
23
|
+
*/
|
|
24
|
+
readonly per_page: number;
|
|
25
|
+
/**
|
|
26
|
+
* Number of results returned on this page.
|
|
27
|
+
*/
|
|
28
|
+
readonly count: number;
|
|
29
|
+
/**
|
|
30
|
+
* The current page number.
|
|
31
|
+
*/
|
|
32
|
+
readonly page: PageNumber;
|
|
33
|
+
/**
|
|
34
|
+
* Whether or not there are more records to return.
|
|
35
|
+
*/
|
|
36
|
+
readonly more_records: boolean;
|
|
37
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Name used to identify a specific service. Always lowercase.
|
|
3
|
+
*
|
|
4
|
+
* I.E. recruit
|
|
5
|
+
*/
|
|
6
|
+
export type ZohoApiServiceName = string;
|
|
7
|
+
/**
|
|
8
|
+
* The base URL for a Zoho API.
|
|
9
|
+
*/
|
|
10
|
+
export type ZohoApiUrl = string;
|
|
11
|
+
/**
|
|
12
|
+
* Non-expiring refresh token used to retrieve access tokens for performing API calls.
|
|
13
|
+
*
|
|
14
|
+
* https://www.zoho.com/recruit/developer-guide/apiv2/oauth-overview.html
|
|
15
|
+
*
|
|
16
|
+
* Is in the format of "1000.abc.123"
|
|
17
|
+
*/
|
|
18
|
+
export type ZohoRefreshToken = string;
|
|
19
|
+
/**
|
|
20
|
+
* OAuth Client Id
|
|
21
|
+
*/
|
|
22
|
+
export type ZohoOAuthClientId = string;
|
|
23
|
+
/**
|
|
24
|
+
* OAuth Client Secret
|
|
25
|
+
*/
|
|
26
|
+
export type ZohoOAuthClientSecret = string;
|
|
27
|
+
export interface ZohoAuthClientIdAndSecretPair {
|
|
28
|
+
readonly clientId: ZohoOAuthClientId;
|
|
29
|
+
readonly clientSecret: ZohoOAuthClientSecret;
|
|
30
|
+
}
|
|
31
|
+
export type ZohoApiUrlKey = 'sandbox' | 'production';
|
|
32
|
+
export type ZohoConfigApiUrlInput = ZohoApiUrlKey | ZohoApiUrl;
|
|
33
|
+
export interface ZohoConfig {
|
|
34
|
+
readonly apiUrl?: ZohoConfigApiUrlInput;
|
|
35
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { Maybe } from '@dereekb/util';
|
|
2
|
+
import { ConfiguredFetch, FetchJsonInterceptJsonResponseFunction, FetchRequestFactoryError, FetchResponseError } from '@dereekb/util/fetch';
|
|
3
|
+
import { BaseError } from 'make-error';
|
|
4
|
+
export type ZohoServerErrorResponseDataError = ZohoServerErrorData | ZohoServerErrorCode;
|
|
5
|
+
export interface ZohoServerErrorResponseData {
|
|
6
|
+
readonly error: ZohoServerErrorResponseDataError;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A code used in some cases to denote success.
|
|
10
|
+
*/
|
|
11
|
+
export declare const ZOHO_SUCCESS_CODE = "SUCCESS";
|
|
12
|
+
export type ZohoServerSuccessCode = typeof ZOHO_SUCCESS_CODE;
|
|
13
|
+
export type ZohoServerSuccessStatus = 'success';
|
|
14
|
+
export type ZohoServerErrorCode = string;
|
|
15
|
+
export type ZohoServerErrorStatus = 'error';
|
|
16
|
+
/**
|
|
17
|
+
* Zoho Server Error Data
|
|
18
|
+
*
|
|
19
|
+
* Always contains a code and message. Details and status are optional.
|
|
20
|
+
*/
|
|
21
|
+
export interface ZohoServerErrorData<T = unknown> {
|
|
22
|
+
readonly code: ZohoServerErrorCode;
|
|
23
|
+
readonly message: string;
|
|
24
|
+
readonly details?: T;
|
|
25
|
+
/**
|
|
26
|
+
* Is sometimes present on some error responses.
|
|
27
|
+
*/
|
|
28
|
+
readonly status?: ZohoServerErrorStatus;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Contains details and a status
|
|
32
|
+
*/
|
|
33
|
+
export type ZohoServerErrorDataWithDetails<T = unknown> = Required<ZohoServerErrorData<T>>;
|
|
34
|
+
export declare function zohoServerErrorData(error: ZohoServerErrorResponseDataError): ZohoServerErrorData;
|
|
35
|
+
/**
|
|
36
|
+
* Zoho Server Error
|
|
37
|
+
*/
|
|
38
|
+
export declare class ZohoServerError<D extends ZohoServerErrorData = ZohoServerErrorData> extends BaseError {
|
|
39
|
+
readonly error: D;
|
|
40
|
+
get code(): string;
|
|
41
|
+
constructor(error: D);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Zoho Server Error that includes the FetchResponseError
|
|
45
|
+
*/
|
|
46
|
+
export declare class ZohoServerFetchResponseError<D extends ZohoServerErrorData = ZohoServerErrorData> extends ZohoServerError<D> {
|
|
47
|
+
readonly data: D;
|
|
48
|
+
readonly responseError: FetchResponseError;
|
|
49
|
+
constructor(data: D, responseError: FetchResponseError);
|
|
50
|
+
}
|
|
51
|
+
export type LogZohoServerErrorFunction = (error: FetchRequestFactoryError | ZohoServerError | ZohoServerFetchResponseError) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a logZohoServerErrorFunction that logs the error to console.
|
|
54
|
+
*
|
|
55
|
+
* @param zohoApiNamePrefix Prefix to use when logging. I.E. ZohoRecruitError, etc.
|
|
56
|
+
* @returns
|
|
57
|
+
*/
|
|
58
|
+
export declare function logZohoServerErrorFunction(zohoApiNamePrefix: string): LogZohoServerErrorFunction;
|
|
59
|
+
/**
|
|
60
|
+
* Wraps a ConfiguredFetch to support handling errors returned by fetch.
|
|
61
|
+
*
|
|
62
|
+
* @param fetch
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
65
|
+
export type HandleZohoErrorFetchFactory = (fetch: ConfiguredFetch, logError?: LogZohoServerErrorFunction) => ConfiguredFetch;
|
|
66
|
+
export type ParsedZohoServerError = FetchRequestFactoryError | ZohoServerError | undefined;
|
|
67
|
+
export type ParseZohoFetchResponseErrorFunction = (responseError: FetchResponseError) => Promise<ParsedZohoServerError>;
|
|
68
|
+
/**
|
|
69
|
+
* Wraps a ConfiguredFetch to support handling errors returned by fetch.
|
|
70
|
+
*
|
|
71
|
+
* @param fetch
|
|
72
|
+
* @returns
|
|
73
|
+
*/
|
|
74
|
+
export declare function handleZohoErrorFetchFactory(parseZohoError: ParseZohoFetchResponseErrorFunction, defaultLogError: LogZohoServerErrorFunction): HandleZohoErrorFetchFactory;
|
|
75
|
+
export type ParseZohoServerErrorResponseData = (zohoServerErrorResponseData: ZohoServerErrorResponseData, fetchResponseError: FetchResponseError) => ParsedZohoServerError;
|
|
76
|
+
/**
|
|
77
|
+
* FetchJsonInterceptJsonResponseFunction that intercepts ZohoServerError responses and throws a ZohoServerError.
|
|
78
|
+
*
|
|
79
|
+
* @returns
|
|
80
|
+
*/
|
|
81
|
+
export declare function interceptZohoErrorResponseFactory(parseZohoServerErrorResponseData: ParseZohoServerErrorResponseData): FetchJsonInterceptJsonResponseFunction;
|
|
82
|
+
/**
|
|
83
|
+
* Error in the following (but not limited to) cases:
|
|
84
|
+
* - An extra parameter is provided
|
|
85
|
+
*/
|
|
86
|
+
export declare const ZOHO_INTERNAL_ERROR_CODE = "INTERNAL_ERROR";
|
|
87
|
+
/**
|
|
88
|
+
* Error when the Zoho API returns an internal error
|
|
89
|
+
*/
|
|
90
|
+
export declare class ZohoInternalError extends ZohoServerFetchResponseError {
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Error in the following cases:
|
|
94
|
+
* - Authorization is not properly constructed ("Invalid Ticket Id")
|
|
95
|
+
* - OAuth token is expired ("Invalid OAuthtoken")
|
|
96
|
+
*/
|
|
97
|
+
export declare const ZOHO_INVALID_AUTHORIZATION_ERROR_CODE = "4834";
|
|
98
|
+
/**
|
|
99
|
+
* Error when the Zoho API returns an invalid authorization error code.
|
|
100
|
+
*/
|
|
101
|
+
export declare class ZohoInvalidAuthorizationError extends ZohoServerFetchResponseError {
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Error in the following cases:
|
|
105
|
+
* - Search query is invalid
|
|
106
|
+
*/
|
|
107
|
+
export declare const ZOHO_INVALID_QUERY_ERROR_CODE = "INVALID_QUERY";
|
|
108
|
+
export interface ZohoInvalidQueryErrorDetails {
|
|
109
|
+
readonly reason: string;
|
|
110
|
+
readonly api_name: string;
|
|
111
|
+
readonly operator: string;
|
|
112
|
+
}
|
|
113
|
+
export declare class ZohoInvalidQueryError extends ZohoServerFetchResponseError {
|
|
114
|
+
get details(): ZohoInvalidQueryErrorDetails;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Error when a mandatory field is missing.
|
|
118
|
+
*/
|
|
119
|
+
export declare const ZOHO_MANDATORY_NOT_FOUND_ERROR_CODE = "MANDATORY_NOT_FOUND";
|
|
120
|
+
/**
|
|
121
|
+
* Error when a duplicate record is found with a matching unique field value.
|
|
122
|
+
*/
|
|
123
|
+
export declare const ZOHO_DUPLICATE_DATA_ERROR_CODE = "DUPLICATE_DATA";
|
|
124
|
+
/**
|
|
125
|
+
* Error when some passed data is invalid.
|
|
126
|
+
*/
|
|
127
|
+
export declare const ZOHO_INVALID_DATA_ERROR_CODE = "INVALID_DATA";
|
|
128
|
+
/**
|
|
129
|
+
* Function that parses/transforms a ZohoServerErrorResponseData into a general ZohoServerError or other known error type.
|
|
130
|
+
*
|
|
131
|
+
* @param errorResponseData
|
|
132
|
+
* @param responseError
|
|
133
|
+
* @returns
|
|
134
|
+
*/
|
|
135
|
+
export declare function parseZohoServerErrorResponseData(errorResponseData: ZohoServerErrorResponseData, responseError: FetchResponseError): ZohoServerFetchResponseError | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* Attempts to retrieve an ZohoServerErrorResponseDataError from the input.
|
|
138
|
+
*
|
|
139
|
+
* Non-200 errors returned by the Zoho API are returned as the object directly instead of as an ZohoServerErrorResponseData directly.
|
|
140
|
+
*
|
|
141
|
+
* @param errorResponseData
|
|
142
|
+
* @param responseError
|
|
143
|
+
* @returns
|
|
144
|
+
*/
|
|
145
|
+
export declare function tryFindZohoServerErrorData(errorResponseData: ZohoServerErrorResponseData | ZohoServerErrorResponseDataError, responseError: FetchResponseError): Maybe<ZohoServerErrorResponseDataError>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { WebsitePath } from '@dereekb/util';
|
|
2
|
+
export interface ZohoModel {
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* General Zoho API GET request response sent by the v1 API.
|
|
6
|
+
*
|
|
7
|
+
* @deprecated
|
|
8
|
+
*/
|
|
9
|
+
export interface ZohoGetApiV1Result<T> {
|
|
10
|
+
readonly response: {
|
|
11
|
+
/**
|
|
12
|
+
* Result value
|
|
13
|
+
*/
|
|
14
|
+
readonly result: T;
|
|
15
|
+
/**
|
|
16
|
+
* Path to the resource.
|
|
17
|
+
*/
|
|
18
|
+
readonly url: WebsitePath;
|
|
19
|
+
};
|
|
20
|
+
}
|