@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.
- package/cli/index.js +7 -5
- package/cli/package.json +7 -7
- package/index.esm.js +3354 -556
- package/nestjs/docs/analytics-testing.md +202 -0
- package/nestjs/index.esm.js +867 -268
- package/nestjs/package.json +10 -10
- package/nestjs/src/lib/analytics/analytics.api.d.ts +236 -0
- package/nestjs/src/lib/analytics/analytics.config.d.ts +24 -0
- package/nestjs/src/lib/analytics/analytics.module.d.ts +65 -0
- package/nestjs/src/lib/analytics/index.d.ts +3 -0
- package/nestjs/src/lib/index.d.ts +1 -0
- package/package.json +15 -16
- package/src/lib/analytics/analytics.api.export.d.ts +167 -0
- package/src/lib/analytics/analytics.api.import.d.ts +252 -0
- package/src/lib/analytics/analytics.api.modeling.d.ts +106 -0
- package/src/lib/analytics/analytics.api.orgs.d.ts +36 -0
- package/src/lib/analytics/analytics.api.rows.d.ts +214 -0
- package/src/lib/analytics/analytics.api.views.d.ts +104 -0
- package/src/lib/analytics/analytics.api.workspaces.d.ts +96 -0
- package/src/lib/analytics/analytics.config.d.ts +92 -0
- package/src/lib/analytics/analytics.d.ts +86 -0
- package/src/lib/analytics/analytics.data.d.ts +74 -0
- package/src/lib/analytics/analytics.diff.d.ts +178 -0
- package/src/lib/analytics/analytics.error.api.d.ts +150 -0
- package/src/lib/analytics/analytics.export.d.ts +91 -0
- package/src/lib/analytics/analytics.factory.d.ts +56 -0
- package/src/lib/analytics/analytics.import.d.ts +176 -0
- package/src/lib/analytics/analytics.job.d.ts +132 -0
- package/src/lib/analytics/analytics.limit.d.ts +55 -0
- package/src/lib/analytics/analytics.org.d.ts +51 -0
- package/src/lib/analytics/analytics.param.d.ts +70 -0
- package/src/lib/analytics/analytics.view.d.ts +99 -0
- package/src/lib/analytics/index.d.ts +20 -0
- package/src/lib/index.d.ts +1 -0
- package/src/lib/zoho.limit.d.ts +14 -1
- package/index.cjs.default.js +0 -1
- package/index.cjs.js +0 -10617
- package/index.cjs.mjs +0 -2
- package/nestjs/index.cjs.default.js +0 -1
- package/nestjs/index.cjs.js +0 -4679
- package/nestjs/index.cjs.mjs +0 -2
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { type Maybe } from '@dereekb/util';
|
|
2
|
+
import { type ZohoAnalyticsJobId, type ZohoAnalyticsResponse, type ZohoAnalyticsRow, type ZohoAnalyticsViewId, type ZohoAnalyticsWorkspaceId } from './analytics';
|
|
3
|
+
import { type ZohoAnalyticsContext } from './analytics.config';
|
|
4
|
+
import { type ZohoAnalyticsImportConfig, type ZohoAnalyticsImportFileType, type ZohoAnalyticsImportJobConfig, type ZohoAnalyticsImportJobNewTableConfig, type ZohoAnalyticsImportNewTableConfig, type ZohoAnalyticsImportResult } from './analytics.import';
|
|
5
|
+
import { type ZohoAnalyticsJobStatus, type PollZohoAnalyticsJobConfig } from './analytics.job';
|
|
6
|
+
/**
|
|
7
|
+
* The data to import, given either as a file, as raw text, or as rows to serialize as JSON.
|
|
8
|
+
*
|
|
9
|
+
* Exactly one of these must be provided: Zoho Analytics accepts a `FILE` or a `DATA` field, never
|
|
10
|
+
* both.
|
|
11
|
+
*
|
|
12
|
+
* @see https://www.zoho.com/analytics/api/v2/bulk-api/import-data/existing-table.html
|
|
13
|
+
*/
|
|
14
|
+
export interface ZohoAnalyticsImportDataInput {
|
|
15
|
+
/**
|
|
16
|
+
* The file to import. Capped at 100MB by Zoho Analytics.
|
|
17
|
+
*/
|
|
18
|
+
readonly file?: Maybe<File>;
|
|
19
|
+
/**
|
|
20
|
+
* Raw CSV or JSON text to import.
|
|
21
|
+
*/
|
|
22
|
+
readonly data?: Maybe<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Rows to import, serialized to JSON automatically.
|
|
25
|
+
*
|
|
26
|
+
* A convenience over `data` for the common case of pushing records out of application code. When
|
|
27
|
+
* used, the import config's `fileType` defaults to `'json'`.
|
|
28
|
+
*/
|
|
29
|
+
readonly rows?: Maybe<ZohoAnalyticsRow[]>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Options controlling how {@link zohoAnalyticsImportFormData} encodes the data.
|
|
33
|
+
*/
|
|
34
|
+
export interface ZohoAnalyticsImportFormDataOptions {
|
|
35
|
+
/**
|
|
36
|
+
* Sends `data`/`rows` as a `FILE` part rather than a `DATA` field.
|
|
37
|
+
*
|
|
38
|
+
* Required by the Bulk (async job) endpoints, which reject a `DATA` field with
|
|
39
|
+
* "The imported file is empty" — verified against the live API. The synchronous endpoints accept
|
|
40
|
+
* `DATA`, so this defaults to false.
|
|
41
|
+
*/
|
|
42
|
+
readonly asFile?: Maybe<boolean>;
|
|
43
|
+
/**
|
|
44
|
+
* File type, used only to name the generated file part.
|
|
45
|
+
*/
|
|
46
|
+
readonly fileType?: Maybe<ZohoAnalyticsImportFileType>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Builds the multipart body carrying the data of an import.
|
|
50
|
+
*
|
|
51
|
+
* @param input - The file, raw text, or rows to import.
|
|
52
|
+
* @param options - How to encode the data; see {@link ZohoAnalyticsImportFormDataOptions}.
|
|
53
|
+
* @returns The multipart form body to send.
|
|
54
|
+
* @throws {Error} When none of `file`, `data`, or `rows` is provided.
|
|
55
|
+
*/
|
|
56
|
+
export declare function zohoAnalyticsImportFormData(input: ZohoAnalyticsImportDataInput, options?: Maybe<ZohoAnalyticsImportFormDataOptions>): FormData;
|
|
57
|
+
/**
|
|
58
|
+
* Input for importing data into an existing table.
|
|
59
|
+
*/
|
|
60
|
+
export interface ZohoAnalyticsImportDataInTableInput extends ZohoAnalyticsImportDataInput {
|
|
61
|
+
readonly workspaceId: ZohoAnalyticsWorkspaceId;
|
|
62
|
+
readonly viewId: ZohoAnalyticsViewId;
|
|
63
|
+
readonly config: ZohoAnalyticsImportConfig;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Response for a synchronous import.
|
|
67
|
+
*/
|
|
68
|
+
export type ZohoAnalyticsImportDataResponse = ZohoAnalyticsResponse<ZohoAnalyticsImportResult>;
|
|
69
|
+
/**
|
|
70
|
+
* Imports data into an existing table and waits for the result.
|
|
71
|
+
*/
|
|
72
|
+
export type ZohoAnalyticsImportDataInTableFunction = (input: ZohoAnalyticsImportDataInTableInput) => Promise<ZohoAnalyticsImportDataResponse>;
|
|
73
|
+
/**
|
|
74
|
+
* Creates a {@link ZohoAnalyticsImportDataInTableFunction} bound to the given context.
|
|
75
|
+
*
|
|
76
|
+
* Imports synchronously, returning once Zoho has processed the data. Use
|
|
77
|
+
* {@link zohoAnalyticsCreateImportJobInTable} instead for large payloads, since a synchronous
|
|
78
|
+
* import must finish inside the request timeout.
|
|
79
|
+
*
|
|
80
|
+
* What a bad row does depends on `config.onError`. Under `skiprow` or `setcolumnempty` the import
|
|
81
|
+
* resolves and describes the loss in `data.importSummary` and `data.importErrors`, so a resolved
|
|
82
|
+
* import does not mean every row landed. Under `abort` it throws error 7232 instead and nothing is
|
|
83
|
+
* written, not even the valid rows of the same request. Verified against the live API.
|
|
84
|
+
*
|
|
85
|
+
* @param context - Authenticated Zoho Analytics context providing fetch and rate limiting.
|
|
86
|
+
* @returns Function that imports data into an existing table.
|
|
87
|
+
*
|
|
88
|
+
* @see https://www.zoho.com/analytics/api/v2/bulk-api/import-data/existing-table.html
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* const importData = zohoAnalyticsImportDataInTable(context);
|
|
93
|
+
* const { data } = await importData({
|
|
94
|
+
* workspaceId,
|
|
95
|
+
* viewId,
|
|
96
|
+
* rows: [{ Region: 'East', Sales: 100 }],
|
|
97
|
+
* config: { importType: 'truncateadd' }
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export declare function zohoAnalyticsImportDataInTable(context: ZohoAnalyticsContext): ZohoAnalyticsImportDataInTableFunction;
|
|
102
|
+
/**
|
|
103
|
+
* Input for importing data into a newly created table.
|
|
104
|
+
*/
|
|
105
|
+
export interface ZohoAnalyticsImportDataInNewTableInput extends ZohoAnalyticsImportDataInput {
|
|
106
|
+
readonly workspaceId: ZohoAnalyticsWorkspaceId;
|
|
107
|
+
readonly config: ZohoAnalyticsImportNewTableConfig;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Creates a table from the imported data and waits for the result.
|
|
111
|
+
*/
|
|
112
|
+
export type ZohoAnalyticsImportDataInNewTableFunction = (input: ZohoAnalyticsImportDataInNewTableInput) => Promise<ZohoAnalyticsImportDataResponse>;
|
|
113
|
+
/**
|
|
114
|
+
* Creates a {@link ZohoAnalyticsImportDataInNewTableFunction} bound to the given context.
|
|
115
|
+
*
|
|
116
|
+
* The new table's id comes back on the result as `viewId`, so it does not have to be found by
|
|
117
|
+
* listing the workspace afterwards. Drop the table again with `zohoAnalyticsDeleteView()`, which is
|
|
118
|
+
* the only way to remove one through the API.
|
|
119
|
+
*
|
|
120
|
+
* A name already taken in the workspace is rejected rather than reused, so a caller that reruns this
|
|
121
|
+
* has to delete the previous table first.
|
|
122
|
+
*
|
|
123
|
+
* @param context - Authenticated Zoho Analytics context providing fetch and rate limiting.
|
|
124
|
+
* @returns Function that creates a table in a workspace and imports data into it.
|
|
125
|
+
*
|
|
126
|
+
* @see https://www.zoho.com/analytics/api/v2/bulk-api/import-data/new-table.html
|
|
127
|
+
*/
|
|
128
|
+
export declare function zohoAnalyticsImportDataInNewTable(context: ZohoAnalyticsContext): ZohoAnalyticsImportDataInNewTableFunction;
|
|
129
|
+
/**
|
|
130
|
+
* Payload returned when an asynchronous job is created.
|
|
131
|
+
*/
|
|
132
|
+
export interface ZohoAnalyticsJobCreationResult {
|
|
133
|
+
readonly jobId: ZohoAnalyticsJobId;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Response returned when an asynchronous import job is created.
|
|
137
|
+
*/
|
|
138
|
+
export type ZohoAnalyticsCreateImportJobResponse = ZohoAnalyticsResponse<ZohoAnalyticsJobCreationResult>;
|
|
139
|
+
/**
|
|
140
|
+
* Input for queueing an asynchronous import into an existing table.
|
|
141
|
+
*/
|
|
142
|
+
export interface ZohoAnalyticsCreateImportJobInTableInput extends ZohoAnalyticsImportDataInput {
|
|
143
|
+
readonly workspaceId: ZohoAnalyticsWorkspaceId;
|
|
144
|
+
readonly viewId: ZohoAnalyticsViewId;
|
|
145
|
+
readonly config: ZohoAnalyticsImportJobConfig;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Queues an asynchronous import into an existing table.
|
|
149
|
+
*/
|
|
150
|
+
export type ZohoAnalyticsCreateImportJobInTableFunction = (input: ZohoAnalyticsCreateImportJobInTableInput) => Promise<ZohoAnalyticsCreateImportJobResponse>;
|
|
151
|
+
/**
|
|
152
|
+
* Creates a {@link ZohoAnalyticsCreateImportJobInTableFunction} bound to the given context.
|
|
153
|
+
*
|
|
154
|
+
* Returns as soon as the job is queued. Poll it with {@link zohoAnalyticsGetImportJob}, or use
|
|
155
|
+
* {@link zohoAnalyticsImportDataInTableAndAwaitJob} to queue and wait in one call.
|
|
156
|
+
*
|
|
157
|
+
* Zoho Analytics allows at most 5 concurrent import jobs per organization and caps each payload at
|
|
158
|
+
* 100MB.
|
|
159
|
+
*
|
|
160
|
+
* @param context - Authenticated Zoho Analytics context providing fetch and rate limiting.
|
|
161
|
+
* @returns Function that queues an asynchronous import.
|
|
162
|
+
*
|
|
163
|
+
* @see https://www.zoho.com/analytics/api/v2/bulk-api/import-data-async/create-import-job/existing-table.html
|
|
164
|
+
*/
|
|
165
|
+
export declare function zohoAnalyticsCreateImportJobInTable(context: ZohoAnalyticsContext): ZohoAnalyticsCreateImportJobInTableFunction;
|
|
166
|
+
/**
|
|
167
|
+
* Input for queueing an asynchronous import that creates a new table.
|
|
168
|
+
*/
|
|
169
|
+
export interface ZohoAnalyticsCreateImportJobInNewTableInput extends ZohoAnalyticsImportDataInput {
|
|
170
|
+
readonly workspaceId: ZohoAnalyticsWorkspaceId;
|
|
171
|
+
readonly config: ZohoAnalyticsImportJobNewTableConfig;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Queues an asynchronous import that creates a new table.
|
|
175
|
+
*/
|
|
176
|
+
export type ZohoAnalyticsCreateImportJobInNewTableFunction = (input: ZohoAnalyticsCreateImportJobInNewTableInput) => Promise<ZohoAnalyticsCreateImportJobResponse>;
|
|
177
|
+
/**
|
|
178
|
+
* Creates a {@link ZohoAnalyticsCreateImportJobInNewTableFunction} bound to the given context.
|
|
179
|
+
*
|
|
180
|
+
* @param context - Authenticated Zoho Analytics context providing fetch and rate limiting.
|
|
181
|
+
* @returns Function that queues an asynchronous import into a new table.
|
|
182
|
+
*
|
|
183
|
+
* @see https://www.zoho.com/analytics/api/v2/bulk-api/import-data-async/create-import-job/new-table.html
|
|
184
|
+
*/
|
|
185
|
+
export declare function zohoAnalyticsCreateImportJobInNewTable(context: ZohoAnalyticsContext): ZohoAnalyticsCreateImportJobInNewTableFunction;
|
|
186
|
+
/**
|
|
187
|
+
* Status of an asynchronous import job.
|
|
188
|
+
*/
|
|
189
|
+
export interface ZohoAnalyticsImportJobStatus extends ZohoAnalyticsJobStatus {
|
|
190
|
+
/**
|
|
191
|
+
* Present once the job has completed.
|
|
192
|
+
*/
|
|
193
|
+
readonly jobInfo?: ZohoAnalyticsImportResult;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Response for `GET /bulk/workspaces/{workspaceId}/importjobs/{jobId}`.
|
|
197
|
+
*/
|
|
198
|
+
export type ZohoAnalyticsGetImportJobResponse = ZohoAnalyticsResponse<ZohoAnalyticsImportJobStatus>;
|
|
199
|
+
/**
|
|
200
|
+
* Input for retrieving an import job's status.
|
|
201
|
+
*/
|
|
202
|
+
export interface ZohoAnalyticsGetImportJobInput {
|
|
203
|
+
readonly workspaceId: ZohoAnalyticsWorkspaceId;
|
|
204
|
+
readonly jobId: ZohoAnalyticsJobId;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Retrieves the status of an asynchronous import job.
|
|
208
|
+
*/
|
|
209
|
+
export type ZohoAnalyticsGetImportJobFunction = (input: ZohoAnalyticsGetImportJobInput) => Promise<ZohoAnalyticsGetImportJobResponse>;
|
|
210
|
+
/**
|
|
211
|
+
* Creates a {@link ZohoAnalyticsGetImportJobFunction} bound to the given context.
|
|
212
|
+
*
|
|
213
|
+
* Checking job status costs zero API units, so it can be polled freely within the request
|
|
214
|
+
* frequency limit.
|
|
215
|
+
*
|
|
216
|
+
* A job id that does not exist is a thrown 404 (error 8137), not a resolved status carrying
|
|
217
|
+
* `ZOHO_ANALYTICS_JOB_CODE_NOT_FOUND` — so a mistyped id rejects rather than reporting itself.
|
|
218
|
+
* Verified against the live API.
|
|
219
|
+
*
|
|
220
|
+
* @param context - Authenticated Zoho Analytics context providing fetch and rate limiting.
|
|
221
|
+
* @returns Function that retrieves an import job's status.
|
|
222
|
+
*
|
|
223
|
+
* @see https://www.zoho.com/analytics/api/v2/bulk-api/import-data-async/get-import-job.html
|
|
224
|
+
*/
|
|
225
|
+
export declare function zohoAnalyticsGetImportJob(context: ZohoAnalyticsContext): ZohoAnalyticsGetImportJobFunction;
|
|
226
|
+
/**
|
|
227
|
+
* Input for queueing an asynchronous import and waiting for it to finish.
|
|
228
|
+
*/
|
|
229
|
+
export interface ZohoAnalyticsImportDataInTableAndAwaitJobInput extends ZohoAnalyticsCreateImportJobInTableInput {
|
|
230
|
+
/**
|
|
231
|
+
* Overrides for how the job is polled.
|
|
232
|
+
*/
|
|
233
|
+
readonly poll?: Omit<PollZohoAnalyticsJobConfig<ZohoAnalyticsGetImportJobResponse>, 'loadJob' | 'readJobCode'>;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Queues an asynchronous import into an existing table and resolves once it reaches a terminal
|
|
237
|
+
* state.
|
|
238
|
+
*/
|
|
239
|
+
export type ZohoAnalyticsImportDataInTableAndAwaitJobFunction = (input: ZohoAnalyticsImportDataInTableAndAwaitJobInput) => Promise<ZohoAnalyticsGetImportJobResponse>;
|
|
240
|
+
/**
|
|
241
|
+
* Creates a {@link ZohoAnalyticsImportDataInTableAndAwaitJobFunction} bound to the given context.
|
|
242
|
+
*
|
|
243
|
+
* Queues the import, then polls until the job completes, fails, or the poll budget is exhausted.
|
|
244
|
+
* The returned job is the last one observed — check it with `isZohoAnalyticsJobComplete()` and
|
|
245
|
+
* `isZohoAnalyticsJobError()` rather than assuming success.
|
|
246
|
+
*
|
|
247
|
+
* @param context - Authenticated Zoho Analytics context providing fetch and rate limiting.
|
|
248
|
+
* @returns Function that imports asynchronously and waits for the job.
|
|
249
|
+
*
|
|
250
|
+
* @see https://www.zoho.com/analytics/api/v2/bulk-api/import-data-async/create-import-job/existing-table.html
|
|
251
|
+
*/
|
|
252
|
+
export declare function zohoAnalyticsImportDataInTableAndAwaitJob(context: ZohoAnalyticsContext): ZohoAnalyticsImportDataInTableAndAwaitJobFunction;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { type Maybe } from '@dereekb/util';
|
|
2
|
+
import { type ZohoAnalyticsResponse, type ZohoAnalyticsViewId, type ZohoAnalyticsWorkspaceId } from './analytics';
|
|
3
|
+
import { type ZohoAnalyticsContext } from './analytics.config';
|
|
4
|
+
/**
|
|
5
|
+
* Response returned by a Modeling API delete.
|
|
6
|
+
*
|
|
7
|
+
* Zoho answers a successful delete with `204 No Content`, so there is no envelope to read and the
|
|
8
|
+
* client resolves `null` rather than a {@link ZohoAnalyticsResponse}. The type stays a `Maybe` of the
|
|
9
|
+
* envelope rather than `void` so a caller is not lied to if Zoho ever starts returning one, and so
|
|
10
|
+
* the failure envelope Analytics sometimes returns with a 200 still flows through the interceptor.
|
|
11
|
+
*
|
|
12
|
+
* A resolved delete is therefore the whole result: there is no count, no id, and nothing to inspect.
|
|
13
|
+
* Confirm a delete landed by listing the views again, not by reading this.
|
|
14
|
+
*/
|
|
15
|
+
export type ZohoAnalyticsModelingDeleteResponse = Maybe<ZohoAnalyticsResponse<unknown>>;
|
|
16
|
+
/**
|
|
17
|
+
* Options for deleting a view.
|
|
18
|
+
*
|
|
19
|
+
* The one option widens the blast radius, so it follows the same rule as
|
|
20
|
+
* `ZohoAnalyticsDeleteRowsConfig`'s `deleteAllRows`: it is never inferred. Left unset, a table that
|
|
21
|
+
* other views are built on is refused rather than silently taking them with it.
|
|
22
|
+
*/
|
|
23
|
+
export interface ZohoAnalyticsDeleteViewConfig {
|
|
24
|
+
/**
|
|
25
|
+
* Also deletes every view derived from this one — the reports, dashboards and query tables built
|
|
26
|
+
* on the table being deleted.
|
|
27
|
+
*
|
|
28
|
+
* Without it a table carrying dependents is rejected instead of deleted.
|
|
29
|
+
*/
|
|
30
|
+
readonly deleteDependentViews?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Input for deleting a view.
|
|
34
|
+
*/
|
|
35
|
+
export interface ZohoAnalyticsDeleteViewInput {
|
|
36
|
+
readonly workspaceId: ZohoAnalyticsWorkspaceId;
|
|
37
|
+
readonly viewId: ZohoAnalyticsViewId;
|
|
38
|
+
readonly config?: Maybe<ZohoAnalyticsDeleteViewConfig>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Response for `DELETE /workspaces/{workspaceId}/views/{viewId}`.
|
|
42
|
+
*/
|
|
43
|
+
export type ZohoAnalyticsDeleteViewResponse = ZohoAnalyticsModelingDeleteResponse;
|
|
44
|
+
/**
|
|
45
|
+
* Deletes a view — a table, query table, report or dashboard.
|
|
46
|
+
*/
|
|
47
|
+
export type ZohoAnalyticsDeleteViewFunction = (input: ZohoAnalyticsDeleteViewInput) => Promise<ZohoAnalyticsDeleteViewResponse>;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a {@link ZohoAnalyticsDeleteViewFunction} bound to the given context.
|
|
50
|
+
*
|
|
51
|
+
* This is the inverse of `zohoAnalyticsImportDataInNewTable()`, and the only way to remove a table
|
|
52
|
+
* the client created — without it a table can only be dropped by hand in the Analytics UI.
|
|
53
|
+
*
|
|
54
|
+
* **The deletion is irreversible.** Zoho has no undo and no recycle bin for a deleted view, so the
|
|
55
|
+
* only recovery is recreating the table and re-importing its data. To empty a table while keeping
|
|
56
|
+
* it, use `zohoAnalyticsDeleteRows()` or a `truncateadd` import instead.
|
|
57
|
+
*
|
|
58
|
+
* Unlike the other Modeling writes, the `CONFIG` goes in the QUERY STRING rather than a form body —
|
|
59
|
+
* Zoho documents this endpoint under "query parameters", and the live API agrees.
|
|
60
|
+
*
|
|
61
|
+
* Requires the `ZohoAnalytics.modeling.delete` OAuth scope, which the broader
|
|
62
|
+
* `ZohoAnalytics.modeling.create` grant does NOT imply: a token without it fails every delete with
|
|
63
|
+
* error 8540 rather than with a permission error naming the view.
|
|
64
|
+
*
|
|
65
|
+
* @param context - Authenticated Zoho Analytics context providing fetch and rate limiting.
|
|
66
|
+
* @returns Function that deletes a view.
|
|
67
|
+
*
|
|
68
|
+
* @see https://www.zoho.com/analytics/api/v2/modeling-api/delete-view.html
|
|
69
|
+
*/
|
|
70
|
+
export declare function zohoAnalyticsDeleteView(context: ZohoAnalyticsContext): ZohoAnalyticsDeleteViewFunction;
|
|
71
|
+
/**
|
|
72
|
+
* Input for deleting a workspace.
|
|
73
|
+
*/
|
|
74
|
+
export interface ZohoAnalyticsDeleteWorkspaceInput {
|
|
75
|
+
readonly workspaceId: ZohoAnalyticsWorkspaceId;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Response for `DELETE /workspaces/{workspaceId}`.
|
|
79
|
+
*/
|
|
80
|
+
export type ZohoAnalyticsDeleteWorkspaceResponse = ZohoAnalyticsModelingDeleteResponse;
|
|
81
|
+
/**
|
|
82
|
+
* Deletes a workspace and everything in it.
|
|
83
|
+
*/
|
|
84
|
+
export type ZohoAnalyticsDeleteWorkspaceFunction = (input: ZohoAnalyticsDeleteWorkspaceInput) => Promise<ZohoAnalyticsDeleteWorkspaceResponse>;
|
|
85
|
+
/**
|
|
86
|
+
* Creates a {@link ZohoAnalyticsDeleteWorkspaceFunction} bound to the given context.
|
|
87
|
+
*
|
|
88
|
+
* **This is the most destructive call in the client, and it is irreversible.** It removes the
|
|
89
|
+
* workspace along with every table, report and dashboard inside it. The endpoint takes no `CONFIG`
|
|
90
|
+
* at all, so there is no cascade flag to withhold — passing the id IS the whole request.
|
|
91
|
+
*
|
|
92
|
+
* That is also why this carries no `deleteAllRows`-style confirmation flag: unlike a row delete,
|
|
93
|
+
* nothing here can be under-specified into a wider blast radius, so a required literal would be
|
|
94
|
+
* ceremony rather than a guard. The real hazard is that the input is shaped exactly like
|
|
95
|
+
* `zohoAnalyticsGetWorkspaceDetails()`'s, so a mistyped call site reads as a lookup — guard it at
|
|
96
|
+
* the boundary that has no code review, which is why the `zoho-cli` command demands the workspace
|
|
97
|
+
* id a second time via `--confirm`.
|
|
98
|
+
*
|
|
99
|
+
* Requires the `ZohoAnalytics.modeling.delete` OAuth scope; see {@link zohoAnalyticsDeleteView}.
|
|
100
|
+
*
|
|
101
|
+
* @param context - Authenticated Zoho Analytics context providing fetch and rate limiting.
|
|
102
|
+
* @returns Function that deletes a workspace.
|
|
103
|
+
*
|
|
104
|
+
* @see https://www.zoho.com/analytics/api/v2/modeling-api/delete-workspace.html
|
|
105
|
+
*/
|
|
106
|
+
export declare function zohoAnalyticsDeleteWorkspace(context: ZohoAnalyticsContext): ZohoAnalyticsDeleteWorkspaceFunction;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type ZohoAnalyticsResponse } from './analytics';
|
|
2
|
+
import { type ZohoAnalyticsContext } from './analytics.config';
|
|
3
|
+
import { type ZohoAnalyticsOrg } from './analytics.org';
|
|
4
|
+
/**
|
|
5
|
+
* Payload of a {@link ZohoAnalyticsGetOrgsResponse}.
|
|
6
|
+
*/
|
|
7
|
+
export interface ZohoAnalyticsGetOrgsResponseData {
|
|
8
|
+
readonly orgs: ZohoAnalyticsOrg[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Response for `GET /orgs`.
|
|
12
|
+
*/
|
|
13
|
+
export type ZohoAnalyticsGetOrgsResponse = ZohoAnalyticsResponse<ZohoAnalyticsGetOrgsResponseData>;
|
|
14
|
+
/**
|
|
15
|
+
* Lists the organizations the authenticated user belongs to.
|
|
16
|
+
*/
|
|
17
|
+
export type ZohoAnalyticsGetOrgsFunction = () => Promise<ZohoAnalyticsGetOrgsResponse>;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a {@link ZohoAnalyticsGetOrgsFunction} bound to the given context.
|
|
20
|
+
*
|
|
21
|
+
* This is the only Zoho Analytics endpoint that does not require the `ZANALYTICS-ORGID` header,
|
|
22
|
+
* which makes it the bootstrap call used to discover the org id that every other endpoint needs.
|
|
23
|
+
*
|
|
24
|
+
* @param context - Authenticated Zoho Analytics context providing fetch and rate limiting.
|
|
25
|
+
* @returns Function that lists the organizations available to the authenticated user.
|
|
26
|
+
*
|
|
27
|
+
* @see https://www.zoho.com/analytics/api/v2/metadata-api/get-org.html
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const getOrgs = zohoAnalyticsGetOrgs(context);
|
|
32
|
+
* const { data } = await getOrgs();
|
|
33
|
+
* const orgId = data.orgs.find((x) => x.isDefault)?.orgId;
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function zohoAnalyticsGetOrgs(context: ZohoAnalyticsContext): ZohoAnalyticsGetOrgsFunction;
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { type ZohoAnalyticsCriteria, type ZohoAnalyticsName, type ZohoAnalyticsResponse, type ZohoAnalyticsRow, type ZohoAnalyticsViewId, type ZohoAnalyticsWorkspaceId } from './analytics';
|
|
2
|
+
import { type ZohoAnalyticsContext } from './analytics.config';
|
|
3
|
+
/**
|
|
4
|
+
* Date-format options shared by the row write operations.
|
|
5
|
+
*/
|
|
6
|
+
export interface ZohoAnalyticsRowDateFormatOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Format of any date value whose format cannot be auto-detected, e.g. `'dd-MMM-YYYY'`.
|
|
9
|
+
*/
|
|
10
|
+
readonly dateFormat?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Per-column date formats, keyed by column name.
|
|
13
|
+
*/
|
|
14
|
+
readonly columnDateFormat?: Record<ZohoAnalyticsName, string>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Columns rejected by a row write, keyed by column name.
|
|
18
|
+
*/
|
|
19
|
+
export type ZohoAnalyticsInvalidColumns = Record<ZohoAnalyticsName, string>;
|
|
20
|
+
/**
|
|
21
|
+
* Options for adding a single row.
|
|
22
|
+
*/
|
|
23
|
+
export interface ZohoAnalyticsAddRowConfig extends ZohoAnalyticsRowDateFormatOptions {
|
|
24
|
+
/**
|
|
25
|
+
* The row to add, keyed by column name.
|
|
26
|
+
*/
|
|
27
|
+
readonly columns: ZohoAnalyticsRow;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Input for adding a single row to a table.
|
|
31
|
+
*/
|
|
32
|
+
export interface ZohoAnalyticsAddRowInput {
|
|
33
|
+
readonly workspaceId: ZohoAnalyticsWorkspaceId;
|
|
34
|
+
readonly viewId: ZohoAnalyticsViewId;
|
|
35
|
+
readonly config: ZohoAnalyticsAddRowConfig;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Payload returned when a row is added.
|
|
39
|
+
*/
|
|
40
|
+
export interface ZohoAnalyticsAddRowResult {
|
|
41
|
+
/**
|
|
42
|
+
* The column values that were accepted.
|
|
43
|
+
*
|
|
44
|
+
* Echoed back as strings regardless of the column's type — a numeric `2` comes back as `'2'`.
|
|
45
|
+
*/
|
|
46
|
+
readonly addedColumns?: ZohoAnalyticsRow;
|
|
47
|
+
/**
|
|
48
|
+
* The column values that were rejected.
|
|
49
|
+
*
|
|
50
|
+
* Always present, as an empty object when nothing was rejected — test it for emptiness rather
|
|
51
|
+
* than for presence. Verified against the live API.
|
|
52
|
+
*/
|
|
53
|
+
readonly invalidColumns?: ZohoAnalyticsInvalidColumns;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Response for `POST /workspaces/{workspaceId}/views/{viewId}/rows`.
|
|
57
|
+
*/
|
|
58
|
+
export type ZohoAnalyticsAddRowResponse = ZohoAnalyticsResponse<ZohoAnalyticsAddRowResult>;
|
|
59
|
+
/**
|
|
60
|
+
* Adds a single row to a table.
|
|
61
|
+
*/
|
|
62
|
+
export type ZohoAnalyticsAddRowFunction = (input: ZohoAnalyticsAddRowInput) => Promise<ZohoAnalyticsAddRowResponse>;
|
|
63
|
+
/**
|
|
64
|
+
* Creates a {@link ZohoAnalyticsAddRowFunction} bound to the given context.
|
|
65
|
+
*
|
|
66
|
+
* Intended for single rows. Use the import operations for bulk data — a row-at-a-time loop burns
|
|
67
|
+
* through the request frequency limit and costs far more API units than one import.
|
|
68
|
+
*
|
|
69
|
+
* A successful response can still report rejected values in `invalidColumns`: an unrecognized
|
|
70
|
+
* column does not fail the call, the row is written without it, and the response is the only record
|
|
71
|
+
* of the loss. The write is rejected outright only when NO column is recognized, as error 8016.
|
|
72
|
+
* {@link zohoAnalyticsUpdateRows} behaves identically. Verified against the live API.
|
|
73
|
+
*
|
|
74
|
+
* @param context - Authenticated Zoho Analytics context providing fetch and rate limiting.
|
|
75
|
+
* @returns Function that adds a row to a table.
|
|
76
|
+
*
|
|
77
|
+
* @see https://www.zoho.com/analytics/api/v2/data-api/add-row.html
|
|
78
|
+
*/
|
|
79
|
+
export declare function zohoAnalyticsAddRow(context: ZohoAnalyticsContext): ZohoAnalyticsAddRowFunction;
|
|
80
|
+
/**
|
|
81
|
+
* Options for updating rows.
|
|
82
|
+
*
|
|
83
|
+
* Either `criteria` or `updateAllRows` must be set, so that an update cannot silently rewrite an
|
|
84
|
+
* entire table.
|
|
85
|
+
*/
|
|
86
|
+
export interface ZohoAnalyticsUpdateRowsConfig extends ZohoAnalyticsRowDateFormatOptions {
|
|
87
|
+
/**
|
|
88
|
+
* The new column values, keyed by column name.
|
|
89
|
+
*/
|
|
90
|
+
readonly columns: ZohoAnalyticsRow;
|
|
91
|
+
/**
|
|
92
|
+
* Restricts the update to rows matching this filter expression.
|
|
93
|
+
*/
|
|
94
|
+
readonly criteria?: ZohoAnalyticsCriteria;
|
|
95
|
+
/**
|
|
96
|
+
* Updates every row in the table.
|
|
97
|
+
*/
|
|
98
|
+
readonly updateAllRows?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Inserts a row when `criteria` matches nothing. Defaults to false.
|
|
101
|
+
*/
|
|
102
|
+
readonly addIfNotExist?: boolean;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Input for updating rows of a table.
|
|
106
|
+
*/
|
|
107
|
+
export interface ZohoAnalyticsUpdateRowsInput {
|
|
108
|
+
readonly workspaceId: ZohoAnalyticsWorkspaceId;
|
|
109
|
+
readonly viewId: ZohoAnalyticsViewId;
|
|
110
|
+
readonly config: ZohoAnalyticsUpdateRowsConfig;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Payload returned when rows are updated.
|
|
114
|
+
*/
|
|
115
|
+
export interface ZohoAnalyticsUpdateRowsResult {
|
|
116
|
+
readonly updatedColumns?: ZohoAnalyticsRow;
|
|
117
|
+
/**
|
|
118
|
+
* Number of rows the criteria matched and updated.
|
|
119
|
+
*
|
|
120
|
+
* Zero when the criteria matched nothing, which is a success rather than a failure — a resolved
|
|
121
|
+
* update says nothing about whether any row changed.
|
|
122
|
+
*/
|
|
123
|
+
readonly updatedRows?: number;
|
|
124
|
+
/**
|
|
125
|
+
* The column values that were rejected, as an empty object when none were.
|
|
126
|
+
*
|
|
127
|
+
* Populated for the same reason as on {@link ZohoAnalyticsAddRowResult}: an unrecognized column is
|
|
128
|
+
* dropped and reported here rather than failing the update. Verified against the live API.
|
|
129
|
+
*/
|
|
130
|
+
readonly invalidColumns?: ZohoAnalyticsInvalidColumns;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Response for `PUT /workspaces/{workspaceId}/views/{viewId}/rows`.
|
|
134
|
+
*/
|
|
135
|
+
export type ZohoAnalyticsUpdateRowsResponse = ZohoAnalyticsResponse<ZohoAnalyticsUpdateRowsResult>;
|
|
136
|
+
/**
|
|
137
|
+
* Updates the rows of a table.
|
|
138
|
+
*/
|
|
139
|
+
export type ZohoAnalyticsUpdateRowsFunction = (input: ZohoAnalyticsUpdateRowsInput) => Promise<ZohoAnalyticsUpdateRowsResponse>;
|
|
140
|
+
/**
|
|
141
|
+
* Creates a {@link ZohoAnalyticsUpdateRowsFunction} bound to the given context.
|
|
142
|
+
*
|
|
143
|
+
* Requires either `criteria` or `updateAllRows`: an update with neither would target every row,
|
|
144
|
+
* which is too destructive to infer.
|
|
145
|
+
*
|
|
146
|
+
* Two things a resolved call does NOT tell the caller, both verified against the live API: a
|
|
147
|
+
* criteria matching no row succeeds with `updatedRows: 0`, and an unrecognized column is dropped
|
|
148
|
+
* and reported in `invalidColumns` rather than failing. An update left with no recognized column at
|
|
149
|
+
* all is rejected as error 8016.
|
|
150
|
+
*
|
|
151
|
+
* @param context - Authenticated Zoho Analytics context providing fetch and rate limiting.
|
|
152
|
+
* @returns Function that updates rows of a table.
|
|
153
|
+
* @throws {Error} When neither `criteria` nor `updateAllRows` is set.
|
|
154
|
+
*
|
|
155
|
+
* @see https://www.zoho.com/analytics/api/v2/data-api/update-row.html
|
|
156
|
+
*/
|
|
157
|
+
export declare function zohoAnalyticsUpdateRows(context: ZohoAnalyticsContext): ZohoAnalyticsUpdateRowsFunction;
|
|
158
|
+
/**
|
|
159
|
+
* Options for deleting rows.
|
|
160
|
+
*
|
|
161
|
+
* Either `criteria` or `deleteAllRows` must be set, so that a delete cannot silently empty an
|
|
162
|
+
* entire table.
|
|
163
|
+
*/
|
|
164
|
+
export interface ZohoAnalyticsDeleteRowsConfig {
|
|
165
|
+
/**
|
|
166
|
+
* Restricts the delete to rows matching this filter expression.
|
|
167
|
+
*/
|
|
168
|
+
readonly criteria?: ZohoAnalyticsCriteria;
|
|
169
|
+
/**
|
|
170
|
+
* Deletes every row in the table.
|
|
171
|
+
*/
|
|
172
|
+
readonly deleteAllRows?: boolean;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Input for deleting rows of a table.
|
|
176
|
+
*/
|
|
177
|
+
export interface ZohoAnalyticsDeleteRowsInput {
|
|
178
|
+
readonly workspaceId: ZohoAnalyticsWorkspaceId;
|
|
179
|
+
readonly viewId: ZohoAnalyticsViewId;
|
|
180
|
+
readonly config: ZohoAnalyticsDeleteRowsConfig;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Payload returned when rows are deleted.
|
|
184
|
+
*/
|
|
185
|
+
export interface ZohoAnalyticsDeleteRowsResult {
|
|
186
|
+
/**
|
|
187
|
+
* Number of rows the criteria matched and deleted.
|
|
188
|
+
*
|
|
189
|
+
* Zero when the criteria matched nothing, which is a success rather than a failure.
|
|
190
|
+
*/
|
|
191
|
+
readonly deletedRows?: number;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Response for `DELETE /workspaces/{workspaceId}/views/{viewId}/rows`.
|
|
195
|
+
*/
|
|
196
|
+
export type ZohoAnalyticsDeleteRowsResponse = ZohoAnalyticsResponse<ZohoAnalyticsDeleteRowsResult>;
|
|
197
|
+
/**
|
|
198
|
+
* Deletes rows of a table.
|
|
199
|
+
*/
|
|
200
|
+
export type ZohoAnalyticsDeleteRowsFunction = (input: ZohoAnalyticsDeleteRowsInput) => Promise<ZohoAnalyticsDeleteRowsResponse>;
|
|
201
|
+
/**
|
|
202
|
+
* Creates a {@link ZohoAnalyticsDeleteRowsFunction} bound to the given context.
|
|
203
|
+
*
|
|
204
|
+
* Requires either `criteria` or `deleteAllRows`: a delete with neither would empty the table, which
|
|
205
|
+
* is too destructive to infer. To replace a table's contents wholesale, prefer a `truncateadd`
|
|
206
|
+
* import, which does it in one operation.
|
|
207
|
+
*
|
|
208
|
+
* @param context - Authenticated Zoho Analytics context providing fetch and rate limiting.
|
|
209
|
+
* @returns Function that deletes rows of a table.
|
|
210
|
+
* @throws {Error} When neither `criteria` nor `deleteAllRows` is set.
|
|
211
|
+
*
|
|
212
|
+
* @see https://www.zoho.com/analytics/api/v2/data-api/delete-row.html
|
|
213
|
+
*/
|
|
214
|
+
export declare function zohoAnalyticsDeleteRows(context: ZohoAnalyticsContext): ZohoAnalyticsDeleteRowsFunction;
|