@dereekb/zoho 13.38.0 → 13.40.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.
Files changed (41) hide show
  1. package/cli/index.js +7 -5
  2. package/cli/package.json +7 -7
  3. package/index.esm.js +3354 -556
  4. package/nestjs/docs/analytics-testing.md +202 -0
  5. package/nestjs/index.esm.js +867 -268
  6. package/nestjs/package.json +10 -10
  7. package/nestjs/src/lib/analytics/analytics.api.d.ts +236 -0
  8. package/nestjs/src/lib/analytics/analytics.config.d.ts +24 -0
  9. package/nestjs/src/lib/analytics/analytics.module.d.ts +65 -0
  10. package/nestjs/src/lib/analytics/index.d.ts +3 -0
  11. package/nestjs/src/lib/index.d.ts +1 -0
  12. package/package.json +15 -16
  13. package/src/lib/analytics/analytics.api.export.d.ts +167 -0
  14. package/src/lib/analytics/analytics.api.import.d.ts +252 -0
  15. package/src/lib/analytics/analytics.api.modeling.d.ts +106 -0
  16. package/src/lib/analytics/analytics.api.orgs.d.ts +36 -0
  17. package/src/lib/analytics/analytics.api.rows.d.ts +214 -0
  18. package/src/lib/analytics/analytics.api.views.d.ts +104 -0
  19. package/src/lib/analytics/analytics.api.workspaces.d.ts +96 -0
  20. package/src/lib/analytics/analytics.config.d.ts +92 -0
  21. package/src/lib/analytics/analytics.d.ts +86 -0
  22. package/src/lib/analytics/analytics.data.d.ts +74 -0
  23. package/src/lib/analytics/analytics.diff.d.ts +178 -0
  24. package/src/lib/analytics/analytics.error.api.d.ts +150 -0
  25. package/src/lib/analytics/analytics.export.d.ts +91 -0
  26. package/src/lib/analytics/analytics.factory.d.ts +56 -0
  27. package/src/lib/analytics/analytics.import.d.ts +176 -0
  28. package/src/lib/analytics/analytics.job.d.ts +132 -0
  29. package/src/lib/analytics/analytics.limit.d.ts +55 -0
  30. package/src/lib/analytics/analytics.org.d.ts +51 -0
  31. package/src/lib/analytics/analytics.param.d.ts +70 -0
  32. package/src/lib/analytics/analytics.view.d.ts +99 -0
  33. package/src/lib/analytics/index.d.ts +20 -0
  34. package/src/lib/index.d.ts +1 -0
  35. package/src/lib/zoho.limit.d.ts +14 -1
  36. package/index.cjs.default.js +0 -1
  37. package/index.cjs.js +0 -10617
  38. package/index.cjs.mjs +0 -2
  39. package/nestjs/index.cjs.default.js +0 -1
  40. package/nestjs/index.cjs.js +0 -4679
  41. package/nestjs/index.cjs.mjs +0 -2
@@ -0,0 +1,51 @@
1
+ import { type ZohoAnalyticsOrgId, type ZohoAnalyticsTimestampString } from './analytics';
2
+ /**
3
+ * An organization in Zoho Analytics.
4
+ *
5
+ * The org id is required by the `ZANALYTICS-ORGID` header on every other endpoint, making
6
+ * `GET /orgs` the bootstrap call for a newly configured client.
7
+ *
8
+ * @see https://www.zoho.com/analytics/api/v2/metadata-api/get-org.html
9
+ */
10
+ export interface ZohoAnalyticsOrg {
11
+ readonly orgId: ZohoAnalyticsOrgId;
12
+ readonly orgName: string;
13
+ readonly orgDesc?: string;
14
+ readonly createdBy?: string;
15
+ readonly createdByZuId?: string;
16
+ /**
17
+ * Subscription plan name, e.g. `'Premium'`. Determines the daily API unit quota.
18
+ */
19
+ readonly planName?: string;
20
+ readonly isDefault?: boolean;
21
+ /**
22
+ * Number of workspaces in the organization.
23
+ *
24
+ * Spelled with a lowercase `w` to match the field name the Zoho Analytics API returns.
25
+ */
26
+ readonly numberOfworkspaces?: number;
27
+ /**
28
+ * The authenticated user's role in the organization, e.g. `'Account Admin'`.
29
+ */
30
+ readonly role?: string;
31
+ }
32
+ /**
33
+ * A workspace summary as returned by the workspace listing endpoints.
34
+ *
35
+ * @see https://www.zoho.com/analytics/api/v2/metadata-api/all-workspace.html
36
+ */
37
+ export interface ZohoAnalyticsWorkspaceSummary {
38
+ readonly workspaceId: string;
39
+ readonly workspaceName: string;
40
+ readonly workspaceDesc?: string;
41
+ readonly orgId?: ZohoAnalyticsOrgId;
42
+ readonly createdTime?: ZohoAnalyticsTimestampString;
43
+ readonly createdBy?: string;
44
+ readonly isDefault?: boolean;
45
+ }
46
+ /**
47
+ * Full details of a single workspace.
48
+ *
49
+ * @see https://www.zoho.com/analytics/api/v2/metadata-api/workspace-details.html
50
+ */
51
+ export type ZohoAnalyticsWorkspace = ZohoAnalyticsWorkspaceSummary;
@@ -0,0 +1,70 @@
1
+ import { type Maybe } from '@dereekb/util';
2
+ import { type FetchJsonBody, type FetchJsonInput } from '@dereekb/util/fetch';
3
+ /**
4
+ * Name of the single parameter that carries every Zoho Analytics request option.
5
+ *
6
+ * @see https://www.zoho.com/analytics/api/v2/api-specification.html
7
+ */
8
+ export declare const ZOHO_ANALYTICS_CONFIG_PARAM = "CONFIG";
9
+ /**
10
+ * Content type used when a Zoho Analytics `CONFIG` is sent in the request body.
11
+ */
12
+ export declare const ZOHO_ANALYTICS_FORM_CONTENT_TYPE = "application/x-www-form-urlencoded";
13
+ /**
14
+ * The options object for a Zoho Analytics request.
15
+ *
16
+ * Zoho Analytics does not accept a normal JSON request body. Instead every option is collected
17
+ * into a single `CONFIG` parameter whose value is the JSON of this object, URL-encoded.
18
+ *
19
+ * Where that parameter is placed depends on the API family:
20
+ *
21
+ * - the query string for every `GET`, for every Bulk API write (import/export), and for the
22
+ * Modeling API deletes; use {@link zohoAnalyticsConfigQuerySuffix}
23
+ * - an `application/x-www-form-urlencoded` body for Data API row CRUD; use
24
+ * {@link zohoAnalyticsFormApiFetchJsonInput}
25
+ *
26
+ * The row-CRUD form body is the odd one out, and it is not the general rule for writes: the
27
+ * Modeling delete endpoints take their `CONFIG` in the query string despite also being writes.
28
+ * Verified against the live API.
29
+ *
30
+ * @see https://www.zoho.com/analytics/api/v2/api-specification.html
31
+ */
32
+ export type ZohoAnalyticsRequestConfig = object;
33
+ /**
34
+ * Encodes a {@link ZohoAnalyticsRequestConfig} as `CONFIG=<url-encoded json>`.
35
+ *
36
+ * Keys with an `undefined` value are dropped by JSON serialization, so optional request options
37
+ * can be passed through without filtering them first.
38
+ *
39
+ * @param config - The request options to encode, if any.
40
+ * @returns The encoded parameter, or an empty string when no config is provided.
41
+ */
42
+ export declare function zohoAnalyticsConfigParamString(config?: Maybe<ZohoAnalyticsRequestConfig>): string;
43
+ /**
44
+ * Encodes a {@link ZohoAnalyticsRequestConfig} as a query string suffix ready to append to a URL.
45
+ *
46
+ * @param config - The request options to encode, if any.
47
+ * @returns `'?CONFIG=...'`, or an empty string when no config is provided.
48
+ */
49
+ export declare function zohoAnalyticsConfigQuerySuffix(config?: Maybe<ZohoAnalyticsRequestConfig>): string;
50
+ /**
51
+ * Constructs the standard FetchJsonInput used by Zoho Analytics calls that carry their `CONFIG`
52
+ * in the query string, pairing the HTTP method with an optional body.
53
+ *
54
+ * @param method - HTTP method to use for the request.
55
+ * @param body - Optional request body to include.
56
+ * @returns Configured fetch input for the Zoho Analytics API call.
57
+ */
58
+ export declare function zohoAnalyticsApiFetchJsonInput(method: string, body?: Maybe<FetchJsonBody>): FetchJsonInput;
59
+ /**
60
+ * Constructs the FetchJsonInput for a Zoho Analytics call that carries its `CONFIG` in an
61
+ * `application/x-www-form-urlencoded` body, as the Data API row operations require.
62
+ *
63
+ * The content type is set explicitly to override the JSON default applied by the Analytics fetch
64
+ * factory.
65
+ *
66
+ * @param method - HTTP method to use for the request.
67
+ * @param config - Request options to encode into the body.
68
+ * @returns Configured fetch input carrying the encoded config as its body.
69
+ */
70
+ export declare function zohoAnalyticsFormApiFetchJsonInput(method: string, config: ZohoAnalyticsRequestConfig): FetchJsonInput;
@@ -0,0 +1,99 @@
1
+ import { type SuggestedString } from '@dereekb/util';
2
+ import { type ZohoAnalyticsColumnId, type ZohoAnalyticsFolderId, type ZohoAnalyticsName, type ZohoAnalyticsOrgId, type ZohoAnalyticsTimestampString, type ZohoAnalyticsViewId, type ZohoAnalyticsWorkspaceId } from './analytics';
3
+ /**
4
+ * Type of a view in Zoho Analytics.
5
+ *
6
+ * Zoho returns this in mixed case — `'Table'`, not `'TABLE'` — from both `GET /workspaces/{id}/views`
7
+ * and `GET /views/{id}`, verified against the live API. Only `'Table'` has been confirmed against a
8
+ * real account; the other members are the documented view kinds and their casing is inferred, so
9
+ * compare case-insensitively rather than against these literals.
10
+ *
11
+ * @see https://www.zoho.com/analytics/api/v2/metadata-api/get-views.html
12
+ */
13
+ export type ZohoAnalyticsViewType = SuggestedString<'Table' | 'QueryTable' | 'Report' | 'Dashboard'>;
14
+ /**
15
+ * A view in Zoho Analytics: a table, query table, report, or dashboard.
16
+ *
17
+ * @see https://www.zoho.com/analytics/api/v2/metadata-api/get-views.html
18
+ */
19
+ export interface ZohoAnalyticsView {
20
+ readonly viewId: ZohoAnalyticsViewId;
21
+ readonly viewName: ZohoAnalyticsName;
22
+ readonly viewDesc?: string;
23
+ readonly viewType?: ZohoAnalyticsViewType;
24
+ readonly folderId?: ZohoAnalyticsFolderId;
25
+ readonly folderName?: string;
26
+ readonly createdBy?: string;
27
+ readonly createdTime?: ZohoAnalyticsTimestampString;
28
+ /**
29
+ * View this one was derived from, for a query table or report.
30
+ */
31
+ readonly parentViewId?: ZohoAnalyticsViewId;
32
+ readonly lastModifiedTime?: ZohoAnalyticsTimestampString;
33
+ readonly lastModifiedBy?: string;
34
+ readonly isFavorite?: boolean;
35
+ /**
36
+ * Present when the view is shared with the authenticated user rather than owned by them.
37
+ */
38
+ readonly sharedBy?: string;
39
+ }
40
+ /**
41
+ * Full details of a single view, which include the owning workspace and organization.
42
+ *
43
+ * Carries a different field set than the listing rather than a superset: it adds the owning
44
+ * workspace/org and the design-modification fields, and drops the folder and favorite fields.
45
+ *
46
+ * @see https://www.zoho.com/analytics/api/v2/metadata-api/view-details.html
47
+ */
48
+ export interface ZohoAnalyticsViewDetails {
49
+ readonly viewId: ZohoAnalyticsViewId;
50
+ readonly viewName: ZohoAnalyticsName;
51
+ readonly viewDesc?: string;
52
+ readonly viewType?: ZohoAnalyticsViewType;
53
+ readonly workspaceId?: ZohoAnalyticsWorkspaceId;
54
+ readonly orgId?: ZohoAnalyticsOrgId;
55
+ readonly createdTime?: ZohoAnalyticsTimestampString;
56
+ readonly createdBy?: string;
57
+ readonly createdByName?: string;
58
+ readonly createdByZuId?: string;
59
+ /**
60
+ * When the view's design — its columns and formulas, not its rows — last changed.
61
+ */
62
+ readonly lastDesignModifiedTime?: ZohoAnalyticsTimestampString;
63
+ readonly lastDesignModifiedBy?: string;
64
+ readonly lastDesignModifiedByName?: string;
65
+ readonly lastDesignModifiedByZuId?: string;
66
+ }
67
+ /**
68
+ * Column data type in a Zoho Analytics table.
69
+ *
70
+ * @see https://www.zoho.com/analytics/api/v2/bulk-api/import-data/existing-table.html
71
+ */
72
+ export type ZohoAnalyticsColumnDataType = SuggestedString<'PLAIN' | 'MULTI_LINE' | 'EMAIL' | 'NUMBER' | 'POSITIVE_NUMBER' | 'DECIMAL_NUMBER' | 'CURRENCY' | 'PERCENT' | 'DATE' | 'BOOLEAN' | 'URL' | 'AUTO_NUMBER' | 'GEO'>;
73
+ /**
74
+ * Metadata describing a single column of a Zoho Analytics table.
75
+ *
76
+ * @see https://www.zoho.com/analytics/api/v2/metadata-api/get-table-metadata.html
77
+ */
78
+ export interface ZohoAnalyticsColumn {
79
+ readonly columnId: ZohoAnalyticsColumnId;
80
+ readonly columnName: ZohoAnalyticsName;
81
+ readonly dataType?: ZohoAnalyticsColumnDataType;
82
+ readonly dataTypeId?: number;
83
+ readonly dataTypeName?: string;
84
+ readonly columnIndex?: number;
85
+ readonly columnDesc?: string;
86
+ readonly columnMaxSize?: number;
87
+ readonly isNullable?: boolean;
88
+ readonly defaultValue?: string;
89
+ readonly pkTableName?: string;
90
+ readonly pkColumnName?: string;
91
+ readonly formulaDisplayName?: string;
92
+ readonly isHidden?: boolean;
93
+ readonly sortedOrder?: number;
94
+ readonly sortedIndex?: number;
95
+ readonly currencyFormat?: string;
96
+ readonly thousandSeparator?: string;
97
+ readonly decimalSeparator?: string;
98
+ readonly decimalPlaces?: number;
99
+ }
@@ -0,0 +1,20 @@
1
+ export * from './analytics';
2
+ export * from './analytics.config';
3
+ export * from './analytics.param';
4
+ export * from './analytics.error.api';
5
+ export * from './analytics.limit';
6
+ export * from './analytics.job';
7
+ export * from './analytics.org';
8
+ export * from './analytics.view';
9
+ export * from './analytics.import';
10
+ export * from './analytics.data';
11
+ export * from './analytics.diff';
12
+ export * from './analytics.export';
13
+ export * from './analytics.factory';
14
+ export * from './analytics.api.orgs';
15
+ export * from './analytics.api.workspaces';
16
+ export * from './analytics.api.views';
17
+ export * from './analytics.api.import';
18
+ export * from './analytics.api.export';
19
+ export * from './analytics.api.rows';
20
+ export * from './analytics.api.modeling';
@@ -3,6 +3,7 @@ export * from './crm';
3
3
  export * from './sign';
4
4
  export * from './desk';
5
5
  export * from './accounts';
6
+ export * from './analytics';
6
7
  export * from './zoho.error.api';
7
8
  export * from './zoho.api.page';
8
9
  export * from './zoho.config';
@@ -97,6 +97,18 @@ export interface MakeZohoRateLimitedFetchHandlerConfig extends ZohoRateLimitedFe
97
97
  * Parses service-specific rate limit headers into the common {@link ZohoRateLimitResponseDetails} shape.
98
98
  */
99
99
  readonly readRateLimitDetails: ZohoReadRateLimitDetailsFunction;
100
+ /**
101
+ * Whether the rate limiter stays enabled when a response carries no rate limit details.
102
+ *
103
+ * Defaults to false, which suits services that advertise their limits via response headers
104
+ * (CRM, Recruit, Sign, Desk): a header-less response there means the limiter has nothing to
105
+ * synchronize against, so throttling is suspended.
106
+ *
107
+ * Set to true for services that document a fixed limit but return no rate limit headers at all
108
+ * (Zoho Analytics). The limiter then self-counts each request against `maxRateLimit` and resets
109
+ * on its own `resetPeriod` schedule.
110
+ */
111
+ readonly enabledWithoutRateLimitDetails?: boolean;
100
112
  }
101
113
  /**
102
114
  * Creates a {@link ZohoRateLimitedFetchHandler} using a configurable header reader function.
@@ -108,7 +120,8 @@ export interface MakeZohoRateLimitedFetchHandlerConfig extends ZohoRateLimitedFe
108
120
  * - On each response, the limiter updates its remaining count and reset time via the provided reader
109
121
  * - When the API reports a different limit than configured, the limiter dynamically adjusts
110
122
  * - On 429 responses, the request is automatically retried after the rate limiter delay
111
- * - The limiter is disabled when responses lack rate limit headers (e.g., error responses)
123
+ * - The limiter is disabled when responses lack rate limit headers (e.g., error responses), unless
124
+ * `enabledWithoutRateLimitDetails` is set, in which case it self-counts against `maxRateLimit`
112
125
  *
113
126
  * @param config - Configuration including the service-specific header reader, rate limit, reset period, and 429 handling.
114
127
  * @returns A rate-limited fetch handler with the underlying rate limiter accessible via `_rateLimiter`
@@ -1 +0,0 @@
1
- exports._default = require('./index.cjs.js').default;