google-spreadsheet 4.1.4 → 5.0.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 +10 -1
- package/dist/index.cjs +4048 -1
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1653 -0
- package/dist/index.d.ts +655 -44
- package/dist/index.js +4042 -0
- package/dist/index.js.map +1 -0
- package/package.json +27 -44
- package/src/lib/GoogleSpreadsheet.ts +132 -120
- package/src/lib/GoogleSpreadsheetCell.ts +2 -2
- package/src/lib/GoogleSpreadsheetRow.ts +7 -8
- package/src/lib/GoogleSpreadsheetWorksheet.ts +54 -44
- package/src/lib/toolkit.ts +34 -0
- package/src/lib/utils.ts +1 -20
- package/dist/index.mjs +0 -1
- package/src/lib/lodash.ts +0 -34
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1653 @@
|
|
|
1
|
+
import * as stream_web from 'stream/web';
|
|
2
|
+
import { ReadableStream as ReadableStream$1 } from 'stream/web';
|
|
3
|
+
import { Headers } from 'google-auth-library/build/src/auth/oauth2client';
|
|
4
|
+
|
|
5
|
+
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
6
|
+
type LiteralUnion<LiteralType extends BaseType, BaseType extends Primitive> = LiteralType | (BaseType & {
|
|
7
|
+
_?: never;
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
type KyResponse<T = unknown> = {
|
|
11
|
+
json: <J = T>() => Promise<J>;
|
|
12
|
+
} & Response;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
Returns a `Response` object with `Body` methods added for convenience. So you can, for example, call `ky.get(input).json()` directly without having to await the `Response` first. When called like that, an appropriate `Accept` header will be set depending on the body method used. Unlike the `Body` methods of `window.Fetch`; these will throw an `HTTPError` if the response status is not in the range of `200...299`. Also, `.json()` will return an empty string if body is empty or the response status is `204` instead of throwing a parse error due to an empty body.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
type ResponsePromise<T = unknown> = {
|
|
19
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
20
|
+
blob: () => Promise<Blob>;
|
|
21
|
+
formData: () => Promise<FormData>;
|
|
22
|
+
/**
|
|
23
|
+
Get the response body as JSON.
|
|
24
|
+
|
|
25
|
+
@example
|
|
26
|
+
```
|
|
27
|
+
import ky from 'ky';
|
|
28
|
+
|
|
29
|
+
const json = await ky(…).json();
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
@example
|
|
33
|
+
```
|
|
34
|
+
import ky from 'ky';
|
|
35
|
+
|
|
36
|
+
interface Result {
|
|
37
|
+
value: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const result1 = await ky(…).json<Result>();
|
|
41
|
+
// or
|
|
42
|
+
const result2 = await ky<Result>(…).json();
|
|
43
|
+
```
|
|
44
|
+
*/
|
|
45
|
+
json: <J = T>() => Promise<J>;
|
|
46
|
+
text: () => Promise<string>;
|
|
47
|
+
} & Promise<KyResponse<T>>;
|
|
48
|
+
|
|
49
|
+
type KyRequest<T = unknown> = {
|
|
50
|
+
json: <J = T>() => Promise<J>;
|
|
51
|
+
} & Request;
|
|
52
|
+
|
|
53
|
+
declare class HTTPError<T = unknown> extends Error {
|
|
54
|
+
response: KyResponse<T>;
|
|
55
|
+
request: KyRequest;
|
|
56
|
+
options: NormalizedOptions;
|
|
57
|
+
constructor(response: Response, request: Request, options: NormalizedOptions);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
type BeforeRequestHook = (request: KyRequest, options: NormalizedOptions) => Request | Response | void | Promise<Request | Response | void>;
|
|
61
|
+
type BeforeRetryState = {
|
|
62
|
+
request: KyRequest;
|
|
63
|
+
options: NormalizedOptions;
|
|
64
|
+
error: Error;
|
|
65
|
+
retryCount: number;
|
|
66
|
+
};
|
|
67
|
+
type BeforeRetryHook = (options: BeforeRetryState) => typeof stop | void | Promise<typeof stop | void>;
|
|
68
|
+
type AfterResponseHook = (request: KyRequest, options: NormalizedOptions, response: KyResponse) => Response | void | Promise<Response | void>;
|
|
69
|
+
type BeforeErrorHook = (error: HTTPError) => HTTPError | Promise<HTTPError>;
|
|
70
|
+
type Hooks = {
|
|
71
|
+
/**
|
|
72
|
+
This hook enables you to modify the request right before it is sent. Ky will make no further changes to the request after this. The hook function receives normalized input and options as arguments. You could, for example, modify `options.headers` here.
|
|
73
|
+
|
|
74
|
+
A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) can be returned from this hook to completely avoid making a HTTP request. This can be used to mock a request, check an internal cache, etc. An **important** consideration when returning a `Response` from this hook is that all the following hooks will be skipped, so **ensure you only return a `Response` from the last hook**.
|
|
75
|
+
|
|
76
|
+
@default []
|
|
77
|
+
*/
|
|
78
|
+
beforeRequest?: BeforeRequestHook[];
|
|
79
|
+
/**
|
|
80
|
+
This hook enables you to modify the request right before retry. Ky will make no further changes to the request after this. The hook function receives an object with the normalized request and options, an error instance, and the retry count. You could, for example, modify `request.headers` here.
|
|
81
|
+
|
|
82
|
+
If the request received a response, the error will be of type `HTTPError` and the `Response` object will be available at `error.response`. Be aware that some types of errors, such as network errors, inherently mean that a response was not received. In that case, the error will not be an instance of `HTTPError`.
|
|
83
|
+
|
|
84
|
+
You can prevent Ky from retrying the request by throwing an error. Ky will not handle it in any way and the error will be propagated to the request initiator. The rest of the `beforeRetry` hooks will not be called in this case. Alternatively, you can return the [`ky.stop`](#ky.stop) symbol to do the same thing but without propagating an error (this has some limitations, see `ky.stop` docs for details).
|
|
85
|
+
|
|
86
|
+
@example
|
|
87
|
+
```
|
|
88
|
+
import ky from 'ky';
|
|
89
|
+
|
|
90
|
+
const response = await ky('https://example.com', {
|
|
91
|
+
hooks: {
|
|
92
|
+
beforeRetry: [
|
|
93
|
+
async ({request, options, error, retryCount}) => {
|
|
94
|
+
const token = await ky('https://example.com/refresh-token');
|
|
95
|
+
options.headers.set('Authorization', `token ${token}`);
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
@default []
|
|
103
|
+
*/
|
|
104
|
+
beforeRetry?: BeforeRetryHook[];
|
|
105
|
+
/**
|
|
106
|
+
This hook enables you to read and optionally modify the response. The hook function receives normalized input, options, and a clone of the response as arguments. The return value of the hook function will be used by Ky as the response object if it's an instance of [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response).
|
|
107
|
+
|
|
108
|
+
@default []
|
|
109
|
+
|
|
110
|
+
@example
|
|
111
|
+
```
|
|
112
|
+
import ky from 'ky';
|
|
113
|
+
|
|
114
|
+
const response = await ky('https://example.com', {
|
|
115
|
+
hooks: {
|
|
116
|
+
afterResponse: [
|
|
117
|
+
(_input, _options, response) => {
|
|
118
|
+
// You could do something with the response, for example, logging.
|
|
119
|
+
log(response);
|
|
120
|
+
|
|
121
|
+
// Or return a `Response` instance to overwrite the response.
|
|
122
|
+
return new Response('A different response', {status: 200});
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
// Or retry with a fresh token on a 403 error
|
|
126
|
+
async (input, options, response) => {
|
|
127
|
+
if (response.status === 403) {
|
|
128
|
+
// Get a fresh token
|
|
129
|
+
const token = await ky('https://example.com/token').text();
|
|
130
|
+
|
|
131
|
+
// Retry with the token
|
|
132
|
+
options.headers.set('Authorization', `token ${token}`);
|
|
133
|
+
|
|
134
|
+
return ky(input, options);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
*/
|
|
142
|
+
afterResponse?: AfterResponseHook[];
|
|
143
|
+
/**
|
|
144
|
+
This hook enables you to modify the `HTTPError` right before it is thrown. The hook function receives a `HTTPError` as an argument and should return an instance of `HTTPError`.
|
|
145
|
+
|
|
146
|
+
@default []
|
|
147
|
+
|
|
148
|
+
@example
|
|
149
|
+
```
|
|
150
|
+
import ky from 'ky';
|
|
151
|
+
|
|
152
|
+
await ky('https://example.com', {
|
|
153
|
+
hooks: {
|
|
154
|
+
beforeError: [
|
|
155
|
+
error => {
|
|
156
|
+
const {response} = error;
|
|
157
|
+
if (response && response.body) {
|
|
158
|
+
error.name = 'GitHubError';
|
|
159
|
+
error.message = `${response.body.message} (${response.status})`;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return error;
|
|
163
|
+
}
|
|
164
|
+
]
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
```
|
|
168
|
+
*/
|
|
169
|
+
beforeError?: BeforeErrorHook[];
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
type RetryOptions = {
|
|
173
|
+
/**
|
|
174
|
+
The number of times to retry failed requests.
|
|
175
|
+
|
|
176
|
+
@default 2
|
|
177
|
+
*/
|
|
178
|
+
limit?: number;
|
|
179
|
+
/**
|
|
180
|
+
The HTTP methods allowed to retry.
|
|
181
|
+
|
|
182
|
+
@default ['get', 'put', 'head', 'delete', 'options', 'trace']
|
|
183
|
+
*/
|
|
184
|
+
methods?: string[];
|
|
185
|
+
/**
|
|
186
|
+
The HTTP status codes allowed to retry.
|
|
187
|
+
|
|
188
|
+
@default [408, 413, 429, 500, 502, 503, 504]
|
|
189
|
+
*/
|
|
190
|
+
statusCodes?: number[];
|
|
191
|
+
/**
|
|
192
|
+
The HTTP status codes allowed to retry with a `Retry-After` header.
|
|
193
|
+
|
|
194
|
+
@default [413, 429, 503]
|
|
195
|
+
*/
|
|
196
|
+
afterStatusCodes?: number[];
|
|
197
|
+
/**
|
|
198
|
+
If the `Retry-After` header is greater than `maxRetryAfter`, the request will be canceled.
|
|
199
|
+
|
|
200
|
+
@default Infinity
|
|
201
|
+
*/
|
|
202
|
+
maxRetryAfter?: number;
|
|
203
|
+
/**
|
|
204
|
+
The upper limit of the delay per retry in milliseconds.
|
|
205
|
+
To clamp the delay, set `backoffLimit` to 1000, for example.
|
|
206
|
+
|
|
207
|
+
By default, the delay is calculated in the following way:
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
0.3 * (2 ** (attemptCount - 1)) * 1000
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
The delay increases exponentially.
|
|
214
|
+
|
|
215
|
+
@default Infinity
|
|
216
|
+
*/
|
|
217
|
+
backoffLimit?: number;
|
|
218
|
+
/**
|
|
219
|
+
A function to calculate the delay between retries given `attemptCount` (starts from 1).
|
|
220
|
+
|
|
221
|
+
@default attemptCount => 0.3 * (2 ** (attemptCount - 1)) * 1000
|
|
222
|
+
*/
|
|
223
|
+
delay?: (attemptCount: number) => number;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
type SearchParamsInit = string | string[][] | Record<string, string> | URLSearchParams | undefined;
|
|
227
|
+
type SearchParamsOption = SearchParamsInit | Record<string, string | number | boolean> | Array<Array<string | number | boolean>>;
|
|
228
|
+
type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'head' | 'delete';
|
|
229
|
+
type Input = string | URL | Request;
|
|
230
|
+
type Progress = {
|
|
231
|
+
percent: number;
|
|
232
|
+
transferredBytes: number;
|
|
233
|
+
/**
|
|
234
|
+
Note: If it's not possible to retrieve the body size, it will be `0`.
|
|
235
|
+
*/
|
|
236
|
+
totalBytes: number;
|
|
237
|
+
};
|
|
238
|
+
type KyHeadersInit = NonNullable<RequestInit['headers']> | Record<string, string | undefined>;
|
|
239
|
+
/**
|
|
240
|
+
Custom Ky options
|
|
241
|
+
*/
|
|
242
|
+
type KyOptions = {
|
|
243
|
+
/**
|
|
244
|
+
Shortcut for sending JSON. Use this instead of the `body` option.
|
|
245
|
+
|
|
246
|
+
Accepts any plain object or value, which will be `JSON.stringify()`'d and sent in the body with the correct header set.
|
|
247
|
+
*/
|
|
248
|
+
json?: unknown;
|
|
249
|
+
/**
|
|
250
|
+
User-defined JSON-parsing function.
|
|
251
|
+
|
|
252
|
+
Use-cases:
|
|
253
|
+
1. Parse JSON via the [`bourne` package](https://github.com/hapijs/bourne) to protect from prototype pollution.
|
|
254
|
+
2. Parse JSON with [`reviver` option of `JSON.parse()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).
|
|
255
|
+
|
|
256
|
+
@default JSON.parse()
|
|
257
|
+
|
|
258
|
+
@example
|
|
259
|
+
```
|
|
260
|
+
import ky from 'ky';
|
|
261
|
+
import bourne from '@hapijs/bourne';
|
|
262
|
+
|
|
263
|
+
const json = await ky('https://example.com', {
|
|
264
|
+
parseJson: text => bourne(text)
|
|
265
|
+
}).json();
|
|
266
|
+
```
|
|
267
|
+
*/
|
|
268
|
+
parseJson?: (text: string) => unknown;
|
|
269
|
+
/**
|
|
270
|
+
User-defined JSON-stringifying function.
|
|
271
|
+
|
|
272
|
+
Use-cases:
|
|
273
|
+
1. Stringify JSON with a custom `replacer` function.
|
|
274
|
+
|
|
275
|
+
@default JSON.stringify()
|
|
276
|
+
|
|
277
|
+
@example
|
|
278
|
+
```
|
|
279
|
+
import ky from 'ky';
|
|
280
|
+
import {DateTime} from 'luxon';
|
|
281
|
+
|
|
282
|
+
const json = await ky('https://example.com', {
|
|
283
|
+
stringifyJson: data => JSON.stringify(data, (key, value) => {
|
|
284
|
+
if (key.endsWith('_at')) {
|
|
285
|
+
return DateTime.fromISO(value).toSeconds();
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return value;
|
|
289
|
+
})
|
|
290
|
+
}).json();
|
|
291
|
+
```
|
|
292
|
+
*/
|
|
293
|
+
stringifyJson?: (data: unknown) => string;
|
|
294
|
+
/**
|
|
295
|
+
Search parameters to include in the request URL. Setting this will override all existing search parameters in the input URL.
|
|
296
|
+
|
|
297
|
+
Accepts any value supported by [`URLSearchParams()`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/URLSearchParams).
|
|
298
|
+
*/
|
|
299
|
+
searchParams?: SearchParamsOption;
|
|
300
|
+
/**
|
|
301
|
+
A prefix to prepend to the `input` URL when making the request. It can be any valid URL, either relative or absolute. A trailing slash `/` is optional and will be added automatically, if needed, when it is joined with `input`. Only takes effect when `input` is a string. The `input` argument cannot start with a slash `/` when using this option.
|
|
302
|
+
|
|
303
|
+
Useful when used with [`ky.extend()`](#kyextenddefaultoptions) to create niche-specific Ky-instances.
|
|
304
|
+
|
|
305
|
+
Notes:
|
|
306
|
+
- After `prefixUrl` and `input` are joined, the result is resolved against the [base URL](https://developer.mozilla.org/en-US/docs/Web/API/Node/baseURI) of the page (if any).
|
|
307
|
+
- Leading slashes in `input` are disallowed when using this option to enforce consistency and avoid confusion about how the `input` URL is handled, given that `input` will not follow the normal URL resolution rules when `prefixUrl` is being used, which changes the meaning of a leading slash.
|
|
308
|
+
|
|
309
|
+
@example
|
|
310
|
+
```
|
|
311
|
+
import ky from 'ky';
|
|
312
|
+
|
|
313
|
+
// On https://example.com
|
|
314
|
+
|
|
315
|
+
const response = await ky('unicorn', {prefixUrl: '/api'});
|
|
316
|
+
//=> 'https://example.com/api/unicorn'
|
|
317
|
+
|
|
318
|
+
const response = await ky('unicorn', {prefixUrl: 'https://cats.com'});
|
|
319
|
+
//=> 'https://cats.com/unicorn'
|
|
320
|
+
```
|
|
321
|
+
*/
|
|
322
|
+
prefixUrl?: URL | string;
|
|
323
|
+
/**
|
|
324
|
+
An object representing `limit`, `methods`, `statusCodes`, `afterStatusCodes`, and `maxRetryAfter` fields for maximum retry count, allowed methods, allowed status codes, status codes allowed to use the [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) time, and maximum [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) time.
|
|
325
|
+
|
|
326
|
+
If `retry` is a number, it will be used as `limit` and other defaults will remain in place.
|
|
327
|
+
|
|
328
|
+
If the response provides an HTTP status contained in `afterStatusCodes`, Ky will wait until the date or timeout given in the [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) header has passed to retry the request. If `Retry-After` is missing, the non-standard [`RateLimit-Reset`](https://www.ietf.org/archive/id/draft-polli-ratelimit-headers-02.html#section-3.3) header is used in its place as a fallback. If the provided status code is not in the list, the [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) header will be ignored.
|
|
329
|
+
|
|
330
|
+
If `maxRetryAfter` is set to `undefined`, it will use `options.timeout`. If [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) header is greater than `maxRetryAfter`, it will cancel the request.
|
|
331
|
+
|
|
332
|
+
By default, delays between retries are calculated with the function `0.3 * (2 ** (attemptCount - 1)) * 1000`, where `attemptCount` is the attempt number (starts from 1), however this can be changed by passing a `delay` function.
|
|
333
|
+
|
|
334
|
+
Retries are not triggered following a timeout.
|
|
335
|
+
|
|
336
|
+
@example
|
|
337
|
+
```
|
|
338
|
+
import ky from 'ky';
|
|
339
|
+
|
|
340
|
+
const json = await ky('https://example.com', {
|
|
341
|
+
retry: {
|
|
342
|
+
limit: 10,
|
|
343
|
+
methods: ['get'],
|
|
344
|
+
statusCodes: [413]
|
|
345
|
+
}
|
|
346
|
+
}).json();
|
|
347
|
+
```
|
|
348
|
+
*/
|
|
349
|
+
retry?: RetryOptions | number;
|
|
350
|
+
/**
|
|
351
|
+
Timeout in milliseconds for getting a response, including any retries. Can not be greater than 2147483647.
|
|
352
|
+
If set to `false`, there will be no timeout.
|
|
353
|
+
|
|
354
|
+
@default 10000
|
|
355
|
+
*/
|
|
356
|
+
timeout?: number | false;
|
|
357
|
+
/**
|
|
358
|
+
Hooks allow modifications during the request lifecycle. Hook functions may be async and are run serially.
|
|
359
|
+
*/
|
|
360
|
+
hooks?: Hooks;
|
|
361
|
+
/**
|
|
362
|
+
Throw an `HTTPError` when, after following redirects, the response has a non-2xx status code. To also throw for redirects instead of following them, set the [`redirect`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters) option to `'manual'`.
|
|
363
|
+
|
|
364
|
+
Setting this to `false` may be useful if you are checking for resource availability and are expecting error responses.
|
|
365
|
+
|
|
366
|
+
Note: If `false`, error responses are considered successful and the request will not be retried.
|
|
367
|
+
|
|
368
|
+
@default true
|
|
369
|
+
*/
|
|
370
|
+
throwHttpErrors?: boolean;
|
|
371
|
+
/**
|
|
372
|
+
Download progress event handler.
|
|
373
|
+
|
|
374
|
+
@param progress - Object containing download progress information.
|
|
375
|
+
@param chunk - Data that was received. Note: It's empty for the first call.
|
|
376
|
+
|
|
377
|
+
@example
|
|
378
|
+
```
|
|
379
|
+
import ky from 'ky';
|
|
380
|
+
|
|
381
|
+
const response = await ky('https://example.com', {
|
|
382
|
+
onDownloadProgress: (progress, chunk) => {
|
|
383
|
+
// Example output:
|
|
384
|
+
// `0% - 0 of 1271 bytes`
|
|
385
|
+
// `100% - 1271 of 1271 bytes`
|
|
386
|
+
console.log(`${progress.percent * 100}% - ${progress.transferredBytes} of ${progress.totalBytes} bytes`);
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
```
|
|
390
|
+
*/
|
|
391
|
+
onDownloadProgress?: (progress: Progress, chunk: Uint8Array) => void;
|
|
392
|
+
/**
|
|
393
|
+
Upload progress event handler.
|
|
394
|
+
|
|
395
|
+
@param progress - Object containing upload progress information.
|
|
396
|
+
@param chunk - Data that was sent. Note: It's empty for the last call.
|
|
397
|
+
|
|
398
|
+
@example
|
|
399
|
+
```
|
|
400
|
+
import ky from 'ky';
|
|
401
|
+
|
|
402
|
+
const response = await ky.post('https://example.com/upload', {
|
|
403
|
+
body: largeFile,
|
|
404
|
+
onUploadProgress: (progress, chunk) => {
|
|
405
|
+
// Example output:
|
|
406
|
+
// `0% - 0 of 1271 bytes`
|
|
407
|
+
// `100% - 1271 of 1271 bytes`
|
|
408
|
+
console.log(`${progress.percent * 100}% - ${progress.transferredBytes} of ${progress.totalBytes} bytes`);
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
```
|
|
412
|
+
*/
|
|
413
|
+
onUploadProgress?: (progress: Progress, chunk: Uint8Array) => void;
|
|
414
|
+
/**
|
|
415
|
+
User-defined `fetch` function.
|
|
416
|
+
Has to be fully compatible with the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) standard.
|
|
417
|
+
|
|
418
|
+
Use-cases:
|
|
419
|
+
1. Use custom `fetch` implementations like [`isomorphic-unfetch`](https://www.npmjs.com/package/isomorphic-unfetch).
|
|
420
|
+
2. Use the `fetch` wrapper function provided by some frameworks that use server-side rendering (SSR).
|
|
421
|
+
|
|
422
|
+
@default fetch
|
|
423
|
+
|
|
424
|
+
@example
|
|
425
|
+
```
|
|
426
|
+
import ky from 'ky';
|
|
427
|
+
import fetch from 'isomorphic-unfetch';
|
|
428
|
+
|
|
429
|
+
const json = await ky('https://example.com', {fetch}).json();
|
|
430
|
+
```
|
|
431
|
+
*/
|
|
432
|
+
fetch?: (input: Input, init?: RequestInit) => Promise<Response>;
|
|
433
|
+
};
|
|
434
|
+
/**
|
|
435
|
+
Options are the same as `window.fetch`, except for the KyOptions
|
|
436
|
+
*/
|
|
437
|
+
interface Options extends KyOptions, Omit<RequestInit, 'headers'> {
|
|
438
|
+
/**
|
|
439
|
+
HTTP method used to make the request.
|
|
440
|
+
|
|
441
|
+
Internally, the standard methods (`GET`, `POST`, `PUT`, `PATCH`, `HEAD` and `DELETE`) are uppercased in order to avoid server errors due to case sensitivity.
|
|
442
|
+
*/
|
|
443
|
+
method?: LiteralUnion<HttpMethod, string>;
|
|
444
|
+
/**
|
|
445
|
+
HTTP headers used to make the request.
|
|
446
|
+
|
|
447
|
+
You can pass a `Headers` instance or a plain object.
|
|
448
|
+
|
|
449
|
+
You can remove a header with `.extend()` by passing the header with an `undefined` value.
|
|
450
|
+
|
|
451
|
+
@example
|
|
452
|
+
```
|
|
453
|
+
import ky from 'ky';
|
|
454
|
+
|
|
455
|
+
const url = 'https://sindresorhus.com';
|
|
456
|
+
|
|
457
|
+
const original = ky.create({
|
|
458
|
+
headers: {
|
|
459
|
+
rainbow: 'rainbow',
|
|
460
|
+
unicorn: 'unicorn'
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
const extended = original.extend({
|
|
465
|
+
headers: {
|
|
466
|
+
rainbow: undefined
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
const response = await extended(url).json();
|
|
471
|
+
|
|
472
|
+
console.log('rainbow' in response);
|
|
473
|
+
//=> false
|
|
474
|
+
|
|
475
|
+
console.log('unicorn' in response);
|
|
476
|
+
//=> true
|
|
477
|
+
```
|
|
478
|
+
*/
|
|
479
|
+
headers?: KyHeadersInit;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
Normalized options passed to the `fetch` call and the `beforeRequest` hooks.
|
|
483
|
+
*/
|
|
484
|
+
interface NormalizedOptions extends RequestInit {
|
|
485
|
+
method: NonNullable<RequestInit['method']>;
|
|
486
|
+
credentials?: NonNullable<RequestInit['credentials']>;
|
|
487
|
+
retry: RetryOptions;
|
|
488
|
+
prefixUrl: string;
|
|
489
|
+
onDownloadProgress: Options['onDownloadProgress'];
|
|
490
|
+
onUploadProgress: Options['onUploadProgress'];
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
declare const stop: unique symbol;
|
|
494
|
+
|
|
495
|
+
type KyInstance = {
|
|
496
|
+
/**
|
|
497
|
+
Fetch the given `url`.
|
|
498
|
+
|
|
499
|
+
@param url - `Request` object, `URL` object, or URL string.
|
|
500
|
+
@returns A promise with `Body` method added.
|
|
501
|
+
|
|
502
|
+
@example
|
|
503
|
+
```
|
|
504
|
+
import ky from 'ky';
|
|
505
|
+
|
|
506
|
+
const json = await ky('https://example.com', {json: {foo: true}}).json();
|
|
507
|
+
|
|
508
|
+
console.log(json);
|
|
509
|
+
//=> `{data: '🦄'}`
|
|
510
|
+
```
|
|
511
|
+
*/
|
|
512
|
+
<T>(url: Input, options?: Options): ResponsePromise<T>;
|
|
513
|
+
/**
|
|
514
|
+
Fetch the given `url` using the option `{method: 'get'}`.
|
|
515
|
+
|
|
516
|
+
@param url - `Request` object, `URL` object, or URL string.
|
|
517
|
+
@returns A promise with `Body` methods added.
|
|
518
|
+
*/
|
|
519
|
+
get: <T>(url: Input, options?: Options) => ResponsePromise<T>;
|
|
520
|
+
/**
|
|
521
|
+
Fetch the given `url` using the option `{method: 'post'}`.
|
|
522
|
+
|
|
523
|
+
@param url - `Request` object, `URL` object, or URL string.
|
|
524
|
+
@returns A promise with `Body` methods added.
|
|
525
|
+
*/
|
|
526
|
+
post: <T>(url: Input, options?: Options) => ResponsePromise<T>;
|
|
527
|
+
/**
|
|
528
|
+
Fetch the given `url` using the option `{method: 'put'}`.
|
|
529
|
+
|
|
530
|
+
@param url - `Request` object, `URL` object, or URL string.
|
|
531
|
+
@returns A promise with `Body` methods added.
|
|
532
|
+
*/
|
|
533
|
+
put: <T>(url: Input, options?: Options) => ResponsePromise<T>;
|
|
534
|
+
/**
|
|
535
|
+
Fetch the given `url` using the option `{method: 'delete'}`.
|
|
536
|
+
|
|
537
|
+
@param url - `Request` object, `URL` object, or URL string.
|
|
538
|
+
@returns A promise with `Body` methods added.
|
|
539
|
+
*/
|
|
540
|
+
delete: <T>(url: Input, options?: Options) => ResponsePromise<T>;
|
|
541
|
+
/**
|
|
542
|
+
Fetch the given `url` using the option `{method: 'patch'}`.
|
|
543
|
+
|
|
544
|
+
@param url - `Request` object, `URL` object, or URL string.
|
|
545
|
+
@returns A promise with `Body` methods added.
|
|
546
|
+
*/
|
|
547
|
+
patch: <T>(url: Input, options?: Options) => ResponsePromise<T>;
|
|
548
|
+
/**
|
|
549
|
+
Fetch the given `url` using the option `{method: 'head'}`.
|
|
550
|
+
|
|
551
|
+
@param url - `Request` object, `URL` object, or URL string.
|
|
552
|
+
@returns A promise with `Body` methods added.
|
|
553
|
+
*/
|
|
554
|
+
head: (url: Input, options?: Options) => ResponsePromise;
|
|
555
|
+
/**
|
|
556
|
+
Create a new Ky instance with complete new defaults.
|
|
557
|
+
|
|
558
|
+
@returns A new Ky instance.
|
|
559
|
+
*/
|
|
560
|
+
create: (defaultOptions?: Options) => KyInstance;
|
|
561
|
+
/**
|
|
562
|
+
Create a new Ky instance with some defaults overridden with your own.
|
|
563
|
+
|
|
564
|
+
In contrast to `ky.create()`, `ky.extend()` inherits defaults from its parent.
|
|
565
|
+
|
|
566
|
+
You can also refer to parent defaults by providing a function to `.extend()`.
|
|
567
|
+
|
|
568
|
+
@example
|
|
569
|
+
```
|
|
570
|
+
import ky from 'ky';
|
|
571
|
+
|
|
572
|
+
const api = ky.create({prefixUrl: 'https://example.com/api'});
|
|
573
|
+
|
|
574
|
+
const usersApi = api.extend((options) => ({prefixUrl: `${options.prefixUrl}/users`}));
|
|
575
|
+
|
|
576
|
+
const response = await usersApi.get('123');
|
|
577
|
+
//=> 'https://example.com/api/users/123'
|
|
578
|
+
|
|
579
|
+
const response = await api.get('version');
|
|
580
|
+
//=> 'https://example.com/api/version'
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
@returns A new Ky instance.
|
|
584
|
+
*/
|
|
585
|
+
extend: (defaultOptions: Options | ((parentOptions: Options) => Options)) => KyInstance;
|
|
586
|
+
/**
|
|
587
|
+
A `Symbol` that can be returned by a `beforeRetry` hook to stop the retry. This will also short circuit the remaining `beforeRetry` hooks.
|
|
588
|
+
|
|
589
|
+
Note: Returning this symbol makes Ky abort and return with an `undefined` response. Be sure to check for a response before accessing any properties on it or use [optional chaining](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining). It is also incompatible with body methods, such as `.json()` or `.text()`, because there is no response to parse. In general, we recommend throwing an error instead of returning this symbol, as that will cause Ky to abort and then throw, which avoids these limitations.
|
|
590
|
+
|
|
591
|
+
A valid use-case for `ky.stop` is to prevent retries when making requests for side effects, where the returned data is not important. For example, logging client activity to the server.
|
|
592
|
+
|
|
593
|
+
@example
|
|
594
|
+
```
|
|
595
|
+
import ky from 'ky';
|
|
596
|
+
|
|
597
|
+
const options = {
|
|
598
|
+
hooks: {
|
|
599
|
+
beforeRetry: [
|
|
600
|
+
async ({request, options, error, retryCount}) => {
|
|
601
|
+
const shouldStopRetry = await ky('https://example.com/api');
|
|
602
|
+
if (shouldStopRetry) {
|
|
603
|
+
return ky.stop;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
]
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
// Note that response will be `undefined` in case `ky.stop` is returned.
|
|
611
|
+
const response = await ky.post('https://example.com', options);
|
|
612
|
+
|
|
613
|
+
// Using `.text()` or other body methods is not supported.
|
|
614
|
+
const text = await ky('https://example.com', options).text();
|
|
615
|
+
```
|
|
616
|
+
*/
|
|
617
|
+
readonly stop: typeof stop;
|
|
618
|
+
};
|
|
619
|
+
|
|
620
|
+
declare class GoogleSpreadsheetRow<T extends Record<string, any> = Record<string, any>> {
|
|
621
|
+
/** parent GoogleSpreadsheetWorksheet instance */
|
|
622
|
+
readonly _worksheet: GoogleSpreadsheetWorksheet;
|
|
623
|
+
/** the A1 row (1-indexed) */
|
|
624
|
+
private _rowNumber;
|
|
625
|
+
/** raw underlying data for row */
|
|
626
|
+
private _rawData;
|
|
627
|
+
constructor(
|
|
628
|
+
/** parent GoogleSpreadsheetWorksheet instance */
|
|
629
|
+
_worksheet: GoogleSpreadsheetWorksheet,
|
|
630
|
+
/** the A1 row (1-indexed) */
|
|
631
|
+
_rowNumber: number,
|
|
632
|
+
/** raw underlying data for row */
|
|
633
|
+
_rawData: any[]);
|
|
634
|
+
private _deleted;
|
|
635
|
+
get deleted(): boolean;
|
|
636
|
+
/** row number (matches A1 notation, ie first row is 1) */
|
|
637
|
+
get rowNumber(): number;
|
|
638
|
+
/**
|
|
639
|
+
* @internal
|
|
640
|
+
* Used internally to update row numbers after deleting rows.
|
|
641
|
+
* Should not be called directly.
|
|
642
|
+
*/
|
|
643
|
+
_updateRowNumber(newRowNumber: number): void;
|
|
644
|
+
get a1Range(): string;
|
|
645
|
+
/** get row's value of specific cell (by header key) */
|
|
646
|
+
get(key: keyof T): any;
|
|
647
|
+
/** set row's value of specific cell (by header key) */
|
|
648
|
+
set<K extends keyof T>(key: K, val: T[K]): void;
|
|
649
|
+
/** set multiple values in the row at once from an object */
|
|
650
|
+
assign(obj: Partial<T>): void;
|
|
651
|
+
/** return raw object of row data */
|
|
652
|
+
toObject(): Partial<T>;
|
|
653
|
+
/** save row values */
|
|
654
|
+
save(options?: {
|
|
655
|
+
raw?: boolean;
|
|
656
|
+
}): Promise<void>;
|
|
657
|
+
/** delete this row */
|
|
658
|
+
delete(): Promise<any>;
|
|
659
|
+
/**
|
|
660
|
+
* @internal
|
|
661
|
+
* Used internally to clear row data after calling sheet.clearRows
|
|
662
|
+
* Should not be called directly.
|
|
663
|
+
*/
|
|
664
|
+
_clearRowData(): void;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
type MakeOptional<Type, Key extends keyof Type> = Omit<Type, Key> & Partial<Pick<Type, Key>>;
|
|
668
|
+
type RecursivePartial<T> = {
|
|
669
|
+
[P in keyof T]?: RecursivePartial<T[P]>;
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
type Integer = number;
|
|
673
|
+
type SpreadsheetId = string;
|
|
674
|
+
type WorksheetId = number;
|
|
675
|
+
type DataSourceId = string;
|
|
676
|
+
type WorksheetIndex = number;
|
|
677
|
+
type RowOrColumnIndex = number;
|
|
678
|
+
type RowIndex = number;
|
|
679
|
+
type ColumnIndex = number;
|
|
680
|
+
type A1Address = string;
|
|
681
|
+
type A1Range = string;
|
|
682
|
+
type NamedRangeId = string;
|
|
683
|
+
/**
|
|
684
|
+
* ISO language code
|
|
685
|
+
* @example en
|
|
686
|
+
* @example en_US
|
|
687
|
+
* */
|
|
688
|
+
type LocaleCode = string;
|
|
689
|
+
/**
|
|
690
|
+
* timezone code, if not recognized, may be a custom time zone such as `GMT-07:00`
|
|
691
|
+
* @example America/New_York
|
|
692
|
+
* */
|
|
693
|
+
type Timezone = string;
|
|
694
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/sheets#SheetType */
|
|
695
|
+
type WorksheetType =
|
|
696
|
+
/** The sheet is a grid. */
|
|
697
|
+
'GRID' |
|
|
698
|
+
/** The sheet has no grid and instead has an object like a chart or image. */
|
|
699
|
+
'OBJECT' |
|
|
700
|
+
/** The sheet connects with an external DataSource and shows the preview of data. */
|
|
701
|
+
'DATA_SOURCE';
|
|
702
|
+
type WorksheetDimension = 'ROWS' | 'COLUMNS';
|
|
703
|
+
type HyperlinkDisplayType = 'LINKED' | 'PLAIN_TEXT';
|
|
704
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/cells#numberformattype */
|
|
705
|
+
type NumberFormatType =
|
|
706
|
+
/** Text formatting, e.g 1000.12 */
|
|
707
|
+
'TEXT' |
|
|
708
|
+
/** Number formatting, e.g, 1,000.12 */
|
|
709
|
+
'NUMBER' |
|
|
710
|
+
/** Percent formatting, e.g 10.12% */
|
|
711
|
+
'PERCENT' |
|
|
712
|
+
/** Currency formatting, e.g $1,000.12 */
|
|
713
|
+
'CURRENCY' |
|
|
714
|
+
/** Date formatting, e.g 9/26/2008 */
|
|
715
|
+
'DATE' |
|
|
716
|
+
/** Time formatting, e.g 3:59:00 PM */
|
|
717
|
+
'TIME' |
|
|
718
|
+
/** Date+Time formatting, e.g 9/26/08 15:59:00 */
|
|
719
|
+
'DATE_TIME' |
|
|
720
|
+
/** Scientific number formatting, e.g 1.01E+03 */
|
|
721
|
+
'SCIENTIFIC';
|
|
722
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#errortype */
|
|
723
|
+
type CellValueErrorType =
|
|
724
|
+
/** Corresponds to the #ERROR! error */
|
|
725
|
+
'ERROR' |
|
|
726
|
+
/** Corresponds to the #NULL! error. */
|
|
727
|
+
'NULL_VALUE' |
|
|
728
|
+
/** Corresponds to the #DIV/0 error. */
|
|
729
|
+
'DIVIDE_BY_ZERO' |
|
|
730
|
+
/** Corresponds to the #VALUE! error. */
|
|
731
|
+
'VALUE' |
|
|
732
|
+
/** Corresponds to the #REF! error. */
|
|
733
|
+
'REF' |
|
|
734
|
+
/** Corresponds to the #NAME? error. */
|
|
735
|
+
'NAME' |
|
|
736
|
+
/** Corresponds to the #NUM! error. */
|
|
737
|
+
'NUM' |
|
|
738
|
+
/** Corresponds to the #N/A error. */
|
|
739
|
+
'N_A' |
|
|
740
|
+
/** Corresponds to the Loading... state. */
|
|
741
|
+
'LOADING';
|
|
742
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#horizontalalign */
|
|
743
|
+
type HorizontalAlign = 'LEFT' | 'CENTER' | 'RIGHT';
|
|
744
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/cells#verticalalign */
|
|
745
|
+
type VerticalAlign = 'TOP' | 'MIDDLE' | 'BOTTOM';
|
|
746
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/cells#textdirection */
|
|
747
|
+
type TextDirection = 'LEFT_TO_RIGHT' | 'RIGHT_TO_LEFT';
|
|
748
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/cells#wrapstrategy */
|
|
749
|
+
type WrapStrategy = 'OVERFLOW_CELL' | 'LEGACY_WRAP' | 'CLIP' | 'WRAP';
|
|
750
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#themecolortype */
|
|
751
|
+
type ThemeColorType = 'TEXT' | 'BACKGROUND' | 'ACCENT1' | 'ACCENT2' | 'ACCENT3' | 'ACCENT4' | 'ACCENT5' | 'ACCENT6' | 'LINK';
|
|
752
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#recalculationinterval */
|
|
753
|
+
type RecalculationInterval = 'ON_CHANGE' | 'MINUTE' | 'HOUR';
|
|
754
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.developerMetadata#developermetadatavisibility */
|
|
755
|
+
type DeveloperMetadataVisibility =
|
|
756
|
+
/** Document-visible metadata is accessible from any developer project with access to the document. */
|
|
757
|
+
'DOCUMENT'
|
|
758
|
+
/** Project-visible metadata is only visible to and accessible by the developer project that created the metadata. */
|
|
759
|
+
| 'PROJECT';
|
|
760
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.developerMetadata#developermetadatalocationtype */
|
|
761
|
+
type DeveloperMetadataLocationType = 'ROW' | 'COLUMN' | 'SHEET' | 'SPREADSHEET';
|
|
762
|
+
type TextFormat = {
|
|
763
|
+
foregroundColor?: Color;
|
|
764
|
+
foregroundColorStyle?: ColorStyle;
|
|
765
|
+
fontFamily?: string;
|
|
766
|
+
fontSize?: number;
|
|
767
|
+
bold?: boolean;
|
|
768
|
+
italic?: boolean;
|
|
769
|
+
strikethrough?: boolean;
|
|
770
|
+
underline?: boolean;
|
|
771
|
+
};
|
|
772
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/cells#Style */
|
|
773
|
+
type CellBorderLineStyle = 'NONE' | 'DOTTED' | 'DASHED' | 'SOLID' | 'SOLID_MEDIUM' | 'SOLID_THICK' | 'DOUBLE';
|
|
774
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/cells#Border */
|
|
775
|
+
type CellBorder = {
|
|
776
|
+
style: CellBorderLineStyle;
|
|
777
|
+
width: number;
|
|
778
|
+
color: Color;
|
|
779
|
+
colorStyle: ColorStyle;
|
|
780
|
+
};
|
|
781
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/cells#Borders */
|
|
782
|
+
type CellBorders = {
|
|
783
|
+
top: CellBorder;
|
|
784
|
+
bottom: CellBorder;
|
|
785
|
+
left: CellBorder;
|
|
786
|
+
right: CellBorder;
|
|
787
|
+
};
|
|
788
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/cells#Padding */
|
|
789
|
+
type CellPadding = {
|
|
790
|
+
top: number;
|
|
791
|
+
bottom: number;
|
|
792
|
+
left: number;
|
|
793
|
+
right: number;
|
|
794
|
+
};
|
|
795
|
+
type TextRotation = {
|
|
796
|
+
angle: number;
|
|
797
|
+
vertical: boolean;
|
|
798
|
+
};
|
|
799
|
+
type DimensionRangeIndexes = {
|
|
800
|
+
startIndex: RowOrColumnIndex;
|
|
801
|
+
endIndex: RowOrColumnIndex;
|
|
802
|
+
};
|
|
803
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.developerMetadata#DeveloperMetadata.DeveloperMetadataLocation */
|
|
804
|
+
interface DeveloperMetadataLocation {
|
|
805
|
+
sheetId: number;
|
|
806
|
+
spreadsheet: boolean;
|
|
807
|
+
dimensionRange: DimensionRange;
|
|
808
|
+
locationType: DeveloperMetadataLocationType;
|
|
809
|
+
}
|
|
810
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.developerMetadata#DeveloperMetadata.DeveloperMetadataLocation */
|
|
811
|
+
interface DeveloperMetadata {
|
|
812
|
+
metadataId: number;
|
|
813
|
+
metadataKey: string;
|
|
814
|
+
metadataValue: string;
|
|
815
|
+
location: DeveloperMetadataLocation;
|
|
816
|
+
visibility: DeveloperMetadataVisibility;
|
|
817
|
+
}
|
|
818
|
+
interface WorksheetDimensionProperties {
|
|
819
|
+
pixelSize: number;
|
|
820
|
+
hiddenByUser: boolean;
|
|
821
|
+
hiddenByFilter: boolean;
|
|
822
|
+
/**
|
|
823
|
+
* @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.developerMetadata#DeveloperMetadata
|
|
824
|
+
*/
|
|
825
|
+
developerMetadata: DeveloperMetadata[];
|
|
826
|
+
}
|
|
827
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#DataSourceColumnReference */
|
|
828
|
+
type DataSourceColumnReference = {
|
|
829
|
+
name: string;
|
|
830
|
+
};
|
|
831
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#DataSourceColumn */
|
|
832
|
+
type DataSourceColumn = {
|
|
833
|
+
reference: DataSourceColumnReference;
|
|
834
|
+
formula: string;
|
|
835
|
+
};
|
|
836
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#DataExecutionState */
|
|
837
|
+
type DataExecutionState =
|
|
838
|
+
/** The data execution has not started. */
|
|
839
|
+
'NOT_STARTED' |
|
|
840
|
+
/** The data execution has started and is running. */
|
|
841
|
+
'RUNNING' |
|
|
842
|
+
/** The data execution has completed successfully. */
|
|
843
|
+
'SUCCEEDED' |
|
|
844
|
+
/** The data execution has completed with errors. */
|
|
845
|
+
'FAILED';
|
|
846
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#DataExecutionState */
|
|
847
|
+
type DataExecutionErrorCode =
|
|
848
|
+
/** Default value, do not use. */
|
|
849
|
+
'DATA_EXECUTION_ERROR_CODE_UNSPECIFIED' |
|
|
850
|
+
/** The data execution timed out. */
|
|
851
|
+
'TIMED_OUT' |
|
|
852
|
+
/** The data execution returns more rows than the limit. */
|
|
853
|
+
'TOO_MANY_ROWS' |
|
|
854
|
+
/** The data execution returns more columns than the limit. */
|
|
855
|
+
'TOO_MANY_COLUMNS' |
|
|
856
|
+
/** The data execution returns more cells than the limit. */
|
|
857
|
+
'TOO_MANY_CELLS' |
|
|
858
|
+
/** Error is received from the backend data execution engine (e.g. BigQuery). Check errorMessage for details. */
|
|
859
|
+
'ENGINE' |
|
|
860
|
+
/** One or some of the provided data source parameters are invalid. */
|
|
861
|
+
'PARAMETER_INVALID' |
|
|
862
|
+
/** The data execution returns an unsupported data type. */
|
|
863
|
+
'UNSUPPORTED_DATA_TYPE' |
|
|
864
|
+
/** The data execution returns duplicate column names or aliases. */
|
|
865
|
+
'DUPLICATE_COLUMN_NAMES' |
|
|
866
|
+
/** The data execution is interrupted. Please refresh later. */
|
|
867
|
+
'INTERRUPTED' |
|
|
868
|
+
/** The data execution is currently in progress, can not be refreshed until it completes. */
|
|
869
|
+
'CONCURRENT_QUERY' |
|
|
870
|
+
/** Other errors. */
|
|
871
|
+
'OTHER' |
|
|
872
|
+
/** The data execution returns values that exceed the maximum characters allowed in a single cell. */
|
|
873
|
+
'TOO_MANY_CHARS_PER_CELL' |
|
|
874
|
+
/** The database referenced by the data source is not found. */
|
|
875
|
+
'DATA_NOT_FOUND' |
|
|
876
|
+
/** The user does not have access to the database referenced by the data source. */
|
|
877
|
+
'PERMISSION_DENIED' |
|
|
878
|
+
/** The data execution returns columns with missing aliases. */
|
|
879
|
+
'MISSING_COLUMN_ALIAS' |
|
|
880
|
+
/** The data source object does not exist. */
|
|
881
|
+
'OBJECT_NOT_FOUND' |
|
|
882
|
+
/** The data source object is currently in error state. To force refresh, set force in RefreshDataSourceRequest . */
|
|
883
|
+
'OBJECT_IN_ERROR_STATE' |
|
|
884
|
+
/** The data source object specification is invalid. */
|
|
885
|
+
'OBJECT_SPEC_INVALID';
|
|
886
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#DataExecutionStatus */
|
|
887
|
+
type DataExecutionStatus = {
|
|
888
|
+
'state': DataExecutionState;
|
|
889
|
+
'errorCode': DataExecutionErrorCode;
|
|
890
|
+
'errorMessage': string;
|
|
891
|
+
'lastRefreshTime': string;
|
|
892
|
+
};
|
|
893
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/sheets#DataSourceSheetProperties */
|
|
894
|
+
type DataSourceSheetProperties = {
|
|
895
|
+
'dataSourceId': DataSourceId;
|
|
896
|
+
'columns': DataSourceColumn[];
|
|
897
|
+
'dataExecutionStatus': DataExecutionStatus;
|
|
898
|
+
};
|
|
899
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#SpreadsheetProperties */
|
|
900
|
+
type SpreadsheetProperties = {
|
|
901
|
+
/** title of the spreadsheet */
|
|
902
|
+
title: string;
|
|
903
|
+
/** locale of the spreadsheet (note - not all locales are supported) */
|
|
904
|
+
locale: LocaleCode;
|
|
905
|
+
/** amount of time to wait before volatile functions are recalculated */
|
|
906
|
+
autoRecalc: RecalculationInterval;
|
|
907
|
+
/** timezone of the sheet */
|
|
908
|
+
timeZone: Timezone;
|
|
909
|
+
defaultFormat: any;
|
|
910
|
+
iterativeCalculationSettings: any;
|
|
911
|
+
spreadsheetTheme: any;
|
|
912
|
+
};
|
|
913
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/sheets#SheetProperties */
|
|
914
|
+
type WorksheetProperties = {
|
|
915
|
+
'sheetId': WorksheetId;
|
|
916
|
+
'title': string;
|
|
917
|
+
'index': WorksheetIndex;
|
|
918
|
+
'sheetType': WorksheetType;
|
|
919
|
+
'gridProperties': WorksheetGridProperties;
|
|
920
|
+
'hidden': boolean;
|
|
921
|
+
'tabColor': Color;
|
|
922
|
+
'tabColorStyle': ColorStyle;
|
|
923
|
+
'rightToLeft': boolean;
|
|
924
|
+
'dataSourceSheetProperties': DataSourceSheetProperties;
|
|
925
|
+
};
|
|
926
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/cells#CellFormat */
|
|
927
|
+
type CellFormat = {
|
|
928
|
+
/** format describing how number values should be represented to the user */
|
|
929
|
+
numberFormat: NumberFormat;
|
|
930
|
+
/** @deprecated use backgroundColorStyle */
|
|
931
|
+
backgroundColor: Color;
|
|
932
|
+
backgroundColorStyle: ColorStyle;
|
|
933
|
+
borders: CellBorders;
|
|
934
|
+
padding: CellPadding;
|
|
935
|
+
horizontalAlignment: HorizontalAlign;
|
|
936
|
+
verticalAlignment: VerticalAlign;
|
|
937
|
+
wrapStrategy: WrapStrategy;
|
|
938
|
+
textDirection: TextDirection;
|
|
939
|
+
textFormat: TextFormat;
|
|
940
|
+
hyperlinkDisplayType: HyperlinkDisplayType;
|
|
941
|
+
textRotation: TextRotation;
|
|
942
|
+
};
|
|
943
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/cells#numberformat */
|
|
944
|
+
type NumberFormat = {
|
|
945
|
+
type: NumberFormatType;
|
|
946
|
+
/**
|
|
947
|
+
* pattern string used for formatting
|
|
948
|
+
* @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/cells#numberformat
|
|
949
|
+
* */
|
|
950
|
+
pattern: string;
|
|
951
|
+
};
|
|
952
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/sheets#GridProperties */
|
|
953
|
+
type WorksheetGridProperties = {
|
|
954
|
+
rowCount: number;
|
|
955
|
+
columnCount: number;
|
|
956
|
+
frozenRowCount?: number;
|
|
957
|
+
frozenColumnCount?: number;
|
|
958
|
+
hideGridlines?: boolean;
|
|
959
|
+
rowGroupControlAfter?: boolean;
|
|
960
|
+
columnGroupControlAfter?: boolean;
|
|
961
|
+
};
|
|
962
|
+
/**
|
|
963
|
+
*
|
|
964
|
+
* @see https://developers.google.com/sheets/api/reference/rest/v4/DimensionRange
|
|
965
|
+
*/
|
|
966
|
+
type DimensionRange = {
|
|
967
|
+
sheetId: WorksheetId;
|
|
968
|
+
dimension: WorksheetDimension;
|
|
969
|
+
startIndex?: Integer;
|
|
970
|
+
endIndex?: Integer;
|
|
971
|
+
};
|
|
972
|
+
/**
|
|
973
|
+
* object describing a range in a sheet
|
|
974
|
+
* see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#GridRange
|
|
975
|
+
* */
|
|
976
|
+
type GridRange = {
|
|
977
|
+
/** The sheet this range is on */
|
|
978
|
+
sheetId: WorksheetId;
|
|
979
|
+
/** The start row (inclusive) of the range, or not set if unbounded. */
|
|
980
|
+
startRowIndex?: Integer;
|
|
981
|
+
/** The end row (exclusive) of the range, or not set if unbounded. */
|
|
982
|
+
endRowIndex?: Integer;
|
|
983
|
+
/** The start column (inclusive) of the range, or not set if unbounded. */
|
|
984
|
+
startColumnIndex?: Integer;
|
|
985
|
+
/** The end column (exclusive) of the range, or not set if unbounded. */
|
|
986
|
+
endColumnIndex?: Integer;
|
|
987
|
+
};
|
|
988
|
+
type GridRangeWithoutWorksheetId = Omit<GridRange, 'sheetId'>;
|
|
989
|
+
type GridRangeWithOptionalWorksheetId = MakeOptional<GridRange, 'sheetId'>;
|
|
990
|
+
type DataFilter = A1Range | GridRange;
|
|
991
|
+
type DataFilterWithoutWorksheetId = A1Range | GridRangeWithoutWorksheetId;
|
|
992
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#colorstyle */
|
|
993
|
+
type ColorStyle = {
|
|
994
|
+
rgbColor: Color;
|
|
995
|
+
} | {
|
|
996
|
+
themeColor: ThemeColorType;
|
|
997
|
+
};
|
|
998
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#Color */
|
|
999
|
+
type Color = {
|
|
1000
|
+
red: number;
|
|
1001
|
+
green: number;
|
|
1002
|
+
blue: number;
|
|
1003
|
+
/** docs say alpha is not generally supported? */
|
|
1004
|
+
alpha?: number;
|
|
1005
|
+
};
|
|
1006
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/ValueRenderOption */
|
|
1007
|
+
type ValueRenderOption =
|
|
1008
|
+
/** Values will be calculated & formatted in the reply according to the cell's formatting. Formatting is based on the spreadsheet's locale, not the requesting user's locale. For example, if A1 is 1.23 and A2 is =A1 and formatted as currency, then A2 would return "$1.23". */
|
|
1009
|
+
'FORMATTED_VALUE' |
|
|
1010
|
+
/** Values will be calculated, but not formatted in the reply. For example, if A1 is 1.23 and A2 is =A1 and formatted as currency, then A2 would return the number 1.23. */
|
|
1011
|
+
'UNFORMATTED_VALUE' |
|
|
1012
|
+
/** Values will not be calculated. The reply will include the formulas. For example, if A1 is 1.23 and A2 is =A1 and formatted as currency, then A2 would return "=A1". */
|
|
1013
|
+
'FORMULA';
|
|
1014
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/get#query-parameters */
|
|
1015
|
+
type GetValuesRequestOptions = {
|
|
1016
|
+
majorDimension?: WorksheetDimension;
|
|
1017
|
+
valueRenderOption?: ValueRenderOption;
|
|
1018
|
+
};
|
|
1019
|
+
/**
|
|
1020
|
+
* Info about an error in a cell
|
|
1021
|
+
* @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#errortype
|
|
1022
|
+
*/
|
|
1023
|
+
type ErrorValue = {
|
|
1024
|
+
type: CellValueErrorType;
|
|
1025
|
+
message: string;
|
|
1026
|
+
};
|
|
1027
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#ExtendedValue */
|
|
1028
|
+
type ExtendedValue = {
|
|
1029
|
+
numberValue: number;
|
|
1030
|
+
} | {
|
|
1031
|
+
stringValue: string;
|
|
1032
|
+
} | {
|
|
1033
|
+
boolValue: boolean;
|
|
1034
|
+
} | {
|
|
1035
|
+
formulaValue: string;
|
|
1036
|
+
} | {
|
|
1037
|
+
errorValue: ErrorValue;
|
|
1038
|
+
};
|
|
1039
|
+
type CellValueType = 'boolValue' | 'stringValue' | 'numberValue' | 'errorValue';
|
|
1040
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/cells */
|
|
1041
|
+
type CellData = {
|
|
1042
|
+
/** The value the user entered in the cell. e.g., 1234, 'Hello', or =NOW() Note: Dates, Times and DateTimes are represented as doubles in serial number format. */
|
|
1043
|
+
userEnteredValue: ExtendedValue;
|
|
1044
|
+
/** The effective value of the cell. For cells with formulas, this is the calculated value. For cells with literals, this is the same as the userEnteredValue. This field is read-only. */
|
|
1045
|
+
effectiveValue: ExtendedValue;
|
|
1046
|
+
/** The formatted value of the cell. This is the value as it's shown to the user. This field is read-only. */
|
|
1047
|
+
formattedValue: string;
|
|
1048
|
+
/** The format the user entered for the cell. */
|
|
1049
|
+
userEnteredFormat: CellFormat;
|
|
1050
|
+
/** The effective format being used by the cell. This includes the results of applying any conditional formatting and, if the cell contains a formula, the computed number format. If the effective format is the default format, effective format will not be written. This field is read-only. */
|
|
1051
|
+
effectiveFormat: CellFormat;
|
|
1052
|
+
/** hyperlink in the cell if any */
|
|
1053
|
+
hyperlink?: string;
|
|
1054
|
+
/** note on the cell */
|
|
1055
|
+
note?: string;
|
|
1056
|
+
};
|
|
1057
|
+
/** shape of the cell data sent back when fetching the sheet */
|
|
1058
|
+
type CellDataRange = {
|
|
1059
|
+
startRow?: RowIndex;
|
|
1060
|
+
startColumn?: ColumnIndex;
|
|
1061
|
+
rowMetadata: any[];
|
|
1062
|
+
columnMetadata: any[];
|
|
1063
|
+
rowData: {
|
|
1064
|
+
values: any[];
|
|
1065
|
+
}[];
|
|
1066
|
+
};
|
|
1067
|
+
type AddRowOptions = {
|
|
1068
|
+
/** set to true to use raw mode rather than user entered */
|
|
1069
|
+
raw?: boolean;
|
|
1070
|
+
/** set to true to insert new rows in the sheet while adding this data */
|
|
1071
|
+
insert?: boolean;
|
|
1072
|
+
};
|
|
1073
|
+
/**
|
|
1074
|
+
* @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#ConditionType
|
|
1075
|
+
*/
|
|
1076
|
+
type ConditionType = 'NUMBER_GREATER' | 'NUMBER_GREATER_THAN_EQ' | 'NUMBER_LESS' | 'NUMBER_LESS_THAN_EQ' | 'NUMBER_EQ' | 'NUMBER_NOT_EQ' | 'NUMBER_BETWEEN' | 'NUMBER_NOT_BETWEEN' | 'TEXT_CONTAINS' | 'TEXT_NOT_CONTAINS' | 'TEXT_STARTS_WITH' | 'TEXT_ENDS_WITH' | 'TEXT_EQ' | 'TEXT_IS_EMAIL' | 'TEXT_IS_URL' | 'DATE_EQ' | 'DATE_BEFORE' | 'DATE_AFTER' | 'DATE_ON_OR_BEFORE' | 'DATE_ON_OR_AFTER' | 'DATE_BETWEEN' | 'DATE_NOT_BETWEEN' | 'DATE_IS_VALID' | 'ONE_OF_RANGE' | 'ONE_OF_LIST' | 'BLANK' | 'NOT_BLANK' | 'CUSTOM_FORMULA' | 'BOOLEAN' | 'TEXT_NOT_EQ' | 'DATE_NOT_EQ' | 'FILTER_EXPRESSION';
|
|
1077
|
+
/**
|
|
1078
|
+
* @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#relativedate
|
|
1079
|
+
*/
|
|
1080
|
+
type RelativeDate = 'PAST_YEAR' | 'PAST_MONTH' | 'PAST_WEEK' | 'YESTERDAY' | 'TODAY' | 'TOMORROW';
|
|
1081
|
+
/**
|
|
1082
|
+
* @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#ConditionValue
|
|
1083
|
+
*/
|
|
1084
|
+
type ConditionValue = {
|
|
1085
|
+
relativeDate: RelativeDate;
|
|
1086
|
+
userEnteredValue?: undefined;
|
|
1087
|
+
} | {
|
|
1088
|
+
relativeDate?: undefined;
|
|
1089
|
+
userEnteredValue: string;
|
|
1090
|
+
};
|
|
1091
|
+
/**
|
|
1092
|
+
* @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#BooleanCondition
|
|
1093
|
+
*/
|
|
1094
|
+
type BooleanCondition = {
|
|
1095
|
+
/** The type of condition. */
|
|
1096
|
+
type: ConditionType;
|
|
1097
|
+
/**
|
|
1098
|
+
* The values of the condition.
|
|
1099
|
+
* The number of supported values depends on the condition type. Some support zero values, others one or two values, and ConditionType.ONE_OF_LIST supports an arbitrary number of values.
|
|
1100
|
+
*/
|
|
1101
|
+
values: ConditionValue[];
|
|
1102
|
+
};
|
|
1103
|
+
/**
|
|
1104
|
+
* @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/cells#DataValidationRule
|
|
1105
|
+
*
|
|
1106
|
+
* example:
|
|
1107
|
+
* - https://stackoverflow.com/a/43442775/3068233
|
|
1108
|
+
*/
|
|
1109
|
+
type DataValidationRule = {
|
|
1110
|
+
/** The condition that data in the cell must match. */
|
|
1111
|
+
condition: BooleanCondition;
|
|
1112
|
+
/** A message to show the user when adding data to the cell. */
|
|
1113
|
+
inputMessage?: string;
|
|
1114
|
+
/** True if invalid data should be rejected. */
|
|
1115
|
+
strict: boolean;
|
|
1116
|
+
/** True if the UI should be customized based on the kind of condition. If true, "List" conditions will show a dropdown. */
|
|
1117
|
+
showCustomUi: boolean;
|
|
1118
|
+
};
|
|
1119
|
+
|
|
1120
|
+
/**
|
|
1121
|
+
* Cell error
|
|
1122
|
+
*
|
|
1123
|
+
* not a js "error" that gets thrown, but a value that holds an error code and message for a cell
|
|
1124
|
+
* it's useful to use a class so we can check `instanceof`
|
|
1125
|
+
|
|
1126
|
+
* @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#ErrorType
|
|
1127
|
+
*/
|
|
1128
|
+
declare class GoogleSpreadsheetCellErrorValue {
|
|
1129
|
+
/**
|
|
1130
|
+
* type of the error
|
|
1131
|
+
* @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#ErrorType
|
|
1132
|
+
* */
|
|
1133
|
+
readonly type: CellValueErrorType;
|
|
1134
|
+
/** A message with more information about the error (in the spreadsheet's locale) */
|
|
1135
|
+
readonly message: string;
|
|
1136
|
+
constructor(rawError: ErrorValue);
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
declare class GoogleSpreadsheetCell {
|
|
1140
|
+
readonly _sheet: GoogleSpreadsheetWorksheet;
|
|
1141
|
+
private _rowIndex;
|
|
1142
|
+
private _columnIndex;
|
|
1143
|
+
private _rawData?;
|
|
1144
|
+
private _draftData;
|
|
1145
|
+
private _error?;
|
|
1146
|
+
constructor(_sheet: GoogleSpreadsheetWorksheet, _rowIndex: RowIndex, _columnIndex: ColumnIndex, rawCellData: CellData);
|
|
1147
|
+
/**
|
|
1148
|
+
* update cell using raw CellData coming back from sheets API
|
|
1149
|
+
* @internal
|
|
1150
|
+
*/
|
|
1151
|
+
_updateRawData(newData: CellData): void;
|
|
1152
|
+
get rowIndex(): number;
|
|
1153
|
+
get columnIndex(): number;
|
|
1154
|
+
get a1Column(): string;
|
|
1155
|
+
get a1Row(): number;
|
|
1156
|
+
get a1Address(): string;
|
|
1157
|
+
get value(): number | boolean | string | null | GoogleSpreadsheetCellErrorValue;
|
|
1158
|
+
set value(newValue: number | boolean | Date | string | null | undefined | GoogleSpreadsheetCellErrorValue);
|
|
1159
|
+
get valueType(): CellValueType | null;
|
|
1160
|
+
/** The formatted value of the cell - this is the value as it's shown to the user */
|
|
1161
|
+
get formattedValue(): string | null;
|
|
1162
|
+
get formula(): string | null;
|
|
1163
|
+
set formula(newValue: string | null);
|
|
1164
|
+
/**
|
|
1165
|
+
* @deprecated use `cell.errorValue` instead
|
|
1166
|
+
*/
|
|
1167
|
+
get formulaError(): GoogleSpreadsheetCellErrorValue | undefined;
|
|
1168
|
+
/**
|
|
1169
|
+
* error contained in the cell, which can happen with a bad formula (maybe some other weird cases?)
|
|
1170
|
+
*/
|
|
1171
|
+
get errorValue(): GoogleSpreadsheetCellErrorValue | undefined;
|
|
1172
|
+
get numberValue(): number | undefined;
|
|
1173
|
+
set numberValue(val: number | undefined);
|
|
1174
|
+
get boolValue(): boolean | undefined;
|
|
1175
|
+
set boolValue(val: boolean | undefined);
|
|
1176
|
+
get stringValue(): string | undefined;
|
|
1177
|
+
set stringValue(val: string | undefined);
|
|
1178
|
+
/**
|
|
1179
|
+
* Hyperlink contained within the cell.
|
|
1180
|
+
*
|
|
1181
|
+
* To modify, do not set directly. Instead set cell.formula, for example `cell.formula = \'=HYPERLINK("http://google.com", "Google")\'`
|
|
1182
|
+
*/
|
|
1183
|
+
get hyperlink(): string | undefined;
|
|
1184
|
+
/** a note attached to the cell */
|
|
1185
|
+
get note(): string;
|
|
1186
|
+
set note(newVal: string | null | undefined | false);
|
|
1187
|
+
get userEnteredFormat(): Readonly<CellFormat | undefined>;
|
|
1188
|
+
get effectiveFormat(): Readonly<CellFormat | undefined>;
|
|
1189
|
+
private _getFormatParam;
|
|
1190
|
+
private _setFormatParam;
|
|
1191
|
+
get numberFormat(): CellFormat["numberFormat"];
|
|
1192
|
+
get backgroundColor(): CellFormat["backgroundColor"];
|
|
1193
|
+
get backgroundColorStyle(): CellFormat["backgroundColorStyle"];
|
|
1194
|
+
get borders(): CellFormat["borders"];
|
|
1195
|
+
get padding(): CellFormat["padding"];
|
|
1196
|
+
get horizontalAlignment(): CellFormat["horizontalAlignment"];
|
|
1197
|
+
get verticalAlignment(): CellFormat["verticalAlignment"];
|
|
1198
|
+
get wrapStrategy(): CellFormat["wrapStrategy"];
|
|
1199
|
+
get textDirection(): CellFormat["textDirection"];
|
|
1200
|
+
get textFormat(): CellFormat["textFormat"];
|
|
1201
|
+
get hyperlinkDisplayType(): CellFormat["hyperlinkDisplayType"];
|
|
1202
|
+
get textRotation(): CellFormat["textRotation"];
|
|
1203
|
+
set numberFormat(newVal: CellFormat['numberFormat']);
|
|
1204
|
+
set backgroundColor(newVal: CellFormat['backgroundColor']);
|
|
1205
|
+
set backgroundColorStyle(newVal: CellFormat['backgroundColorStyle']);
|
|
1206
|
+
set borders(newVal: CellFormat['borders']);
|
|
1207
|
+
set padding(newVal: CellFormat['padding']);
|
|
1208
|
+
set horizontalAlignment(newVal: CellFormat['horizontalAlignment']);
|
|
1209
|
+
set verticalAlignment(newVal: CellFormat['verticalAlignment']);
|
|
1210
|
+
set wrapStrategy(newVal: CellFormat['wrapStrategy']);
|
|
1211
|
+
set textDirection(newVal: CellFormat['textDirection']);
|
|
1212
|
+
set textFormat(newVal: CellFormat['textFormat']);
|
|
1213
|
+
set hyperlinkDisplayType(newVal: CellFormat['hyperlinkDisplayType']);
|
|
1214
|
+
set textRotation(newVal: CellFormat['textRotation']);
|
|
1215
|
+
clearAllFormatting(): void;
|
|
1216
|
+
get _isDirty(): boolean;
|
|
1217
|
+
discardUnsavedChanges(): void;
|
|
1218
|
+
/**
|
|
1219
|
+
* saves updates for single cell
|
|
1220
|
+
* usually it's better to make changes and call sheet.saveUpdatedCells
|
|
1221
|
+
* */
|
|
1222
|
+
save(): Promise<void>;
|
|
1223
|
+
/**
|
|
1224
|
+
* used by worksheet when saving cells
|
|
1225
|
+
* returns an individual batchUpdate request to update the cell
|
|
1226
|
+
* @internal
|
|
1227
|
+
*/
|
|
1228
|
+
_getUpdateRequest(): {
|
|
1229
|
+
updateCells: {
|
|
1230
|
+
rows: {
|
|
1231
|
+
values: any[];
|
|
1232
|
+
}[];
|
|
1233
|
+
fields: string;
|
|
1234
|
+
start: {
|
|
1235
|
+
sheetId: number;
|
|
1236
|
+
rowIndex: number;
|
|
1237
|
+
columnIndex: number;
|
|
1238
|
+
};
|
|
1239
|
+
};
|
|
1240
|
+
} | null;
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
type RowCellData = string | number | boolean | Date;
|
|
1244
|
+
type RawRowData = RowCellData[] | Record<string, RowCellData>;
|
|
1245
|
+
declare class GoogleSpreadsheetWorksheet {
|
|
1246
|
+
/** parent GoogleSpreadsheet instance */
|
|
1247
|
+
readonly _spreadsheet: GoogleSpreadsheet;
|
|
1248
|
+
private _headerRowIndex;
|
|
1249
|
+
private _rawProperties;
|
|
1250
|
+
private _cells;
|
|
1251
|
+
private _rowMetadata;
|
|
1252
|
+
private _columnMetadata;
|
|
1253
|
+
private _headerValues;
|
|
1254
|
+
get headerValues(): string[];
|
|
1255
|
+
constructor(
|
|
1256
|
+
/** parent GoogleSpreadsheet instance */
|
|
1257
|
+
_spreadsheet: GoogleSpreadsheet, rawProperties: WorksheetProperties, rawCellData?: CellDataRange[]);
|
|
1258
|
+
updateRawData(properties: WorksheetProperties, rawCellData: CellDataRange[]): void;
|
|
1259
|
+
_makeSingleUpdateRequest(requestType: string, requestParams: any): Promise<any>;
|
|
1260
|
+
private _ensureInfoLoaded;
|
|
1261
|
+
/** clear local cache of sheet data/properties */
|
|
1262
|
+
resetLocalCache(
|
|
1263
|
+
/** set to true to clear data only, leaving sheet metadata/propeties intact */
|
|
1264
|
+
dataOnly?: boolean): void;
|
|
1265
|
+
private _fillCellData;
|
|
1266
|
+
private _addSheetIdToRange;
|
|
1267
|
+
private _getProp;
|
|
1268
|
+
private _setProp;
|
|
1269
|
+
get sheetId(): WorksheetProperties["sheetId"];
|
|
1270
|
+
get title(): WorksheetProperties["title"];
|
|
1271
|
+
get index(): WorksheetProperties["index"];
|
|
1272
|
+
get sheetType(): WorksheetProperties["sheetType"];
|
|
1273
|
+
get gridProperties(): WorksheetProperties["gridProperties"];
|
|
1274
|
+
get hidden(): WorksheetProperties["hidden"];
|
|
1275
|
+
get tabColor(): WorksheetProperties["tabColor"];
|
|
1276
|
+
get rightToLeft(): WorksheetProperties["rightToLeft"];
|
|
1277
|
+
private get _headerRange();
|
|
1278
|
+
set sheetId(newVal: WorksheetProperties['sheetId']);
|
|
1279
|
+
set title(newVal: WorksheetProperties['title']);
|
|
1280
|
+
set index(newVal: WorksheetProperties['index']);
|
|
1281
|
+
set sheetType(newVal: WorksheetProperties['sheetType']);
|
|
1282
|
+
set gridProperties(newVal: WorksheetProperties['gridProperties']);
|
|
1283
|
+
set hidden(newVal: WorksheetProperties['hidden']);
|
|
1284
|
+
set tabColor(newVal: WorksheetProperties['tabColor']);
|
|
1285
|
+
set rightToLeft(newVal: WorksheetProperties['rightToLeft']);
|
|
1286
|
+
get rowCount(): number;
|
|
1287
|
+
get columnCount(): number;
|
|
1288
|
+
get a1SheetName(): string;
|
|
1289
|
+
get encodedA1SheetName(): string;
|
|
1290
|
+
get lastColumnLetter(): string;
|
|
1291
|
+
get cellStats(): {
|
|
1292
|
+
nonEmpty: number;
|
|
1293
|
+
loaded: number;
|
|
1294
|
+
total: number;
|
|
1295
|
+
};
|
|
1296
|
+
getCellByA1(a1Address: A1Address): GoogleSpreadsheetCell;
|
|
1297
|
+
getCell(rowIndex: RowIndex, columnIndex: ColumnIndex): GoogleSpreadsheetCell;
|
|
1298
|
+
loadCells(sheetFilters?: DataFilterWithoutWorksheetId | DataFilterWithoutWorksheetId[]): Promise<void>;
|
|
1299
|
+
saveUpdatedCells(): Promise<void>;
|
|
1300
|
+
saveCells(cellsToUpdate: GoogleSpreadsheetCell[]): Promise<void>;
|
|
1301
|
+
_ensureHeaderRowLoaded(): Promise<void>;
|
|
1302
|
+
loadHeaderRow(headerRowIndex?: number): Promise<void>;
|
|
1303
|
+
private _processHeaderRow;
|
|
1304
|
+
setHeaderRow(headerValues: string[], headerRowIndex?: number): Promise<void>;
|
|
1305
|
+
addRows(rows: RawRowData[], options?: AddRowOptions): Promise<GoogleSpreadsheetRow<Record<string, any>>[]>;
|
|
1306
|
+
/** add a single row - see addRows for more info */
|
|
1307
|
+
addRow(rowValues: RawRowData, options?: AddRowOptions): Promise<GoogleSpreadsheetRow<Record<string, any>>>;
|
|
1308
|
+
private _rowCache;
|
|
1309
|
+
getRows<T extends Record<string, any>>(options?: {
|
|
1310
|
+
/** skip first N rows */
|
|
1311
|
+
offset?: number;
|
|
1312
|
+
/** limit number of rows fetched */
|
|
1313
|
+
limit?: number;
|
|
1314
|
+
}): Promise<GoogleSpreadsheetRow<T>[]>;
|
|
1315
|
+
/**
|
|
1316
|
+
* @internal
|
|
1317
|
+
* Used internally to update row numbers after deleting rows.
|
|
1318
|
+
* Should not be called directly.
|
|
1319
|
+
* */
|
|
1320
|
+
_shiftRowCache(deletedRowNumber: number): void;
|
|
1321
|
+
clearRows(options?: {
|
|
1322
|
+
start?: number;
|
|
1323
|
+
end?: number;
|
|
1324
|
+
}): Promise<void>;
|
|
1325
|
+
/** @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#UpdateSheetPropertiesRequest */
|
|
1326
|
+
updateProperties(properties: Partial<Omit<WorksheetProperties, 'sheetId'>>): Promise<any>;
|
|
1327
|
+
/**
|
|
1328
|
+
* passes through the call to updateProperties to update only the gridProperties object
|
|
1329
|
+
*/
|
|
1330
|
+
updateGridProperties(gridProperties: WorksheetGridProperties): Promise<any>;
|
|
1331
|
+
/** resize, internally just calls updateGridProperties */
|
|
1332
|
+
resize(gridProperties: Pick<WorksheetGridProperties, 'rowCount' | 'columnCount'>): Promise<any>;
|
|
1333
|
+
/**
|
|
1334
|
+
*
|
|
1335
|
+
* @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#updatedimensionpropertiesrequest
|
|
1336
|
+
*/
|
|
1337
|
+
updateDimensionProperties(columnsOrRows: WorksheetDimension, properties: WorksheetDimensionProperties, bounds: Partial<DimensionRangeIndexes>): Promise<any>;
|
|
1338
|
+
getCellsInRange(a1Range: A1Range, options?: GetValuesRequestOptions): Promise<any>;
|
|
1339
|
+
batchGetCellsInRange(a1Ranges: A1Range[], options?: GetValuesRequestOptions): Promise<any>;
|
|
1340
|
+
updateNamedRange(): Promise<void>;
|
|
1341
|
+
addNamedRange(): Promise<void>;
|
|
1342
|
+
deleteNamedRange(): Promise<void>;
|
|
1343
|
+
repeatCell(): Promise<void>;
|
|
1344
|
+
autoFill(): Promise<void>;
|
|
1345
|
+
cutPaste(): Promise<void>;
|
|
1346
|
+
copyPaste(): Promise<void>;
|
|
1347
|
+
/**
|
|
1348
|
+
* Merges all cells in the range
|
|
1349
|
+
* @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#MergeCellsRequest
|
|
1350
|
+
*/
|
|
1351
|
+
mergeCells(range: GridRangeWithOptionalWorksheetId, mergeType?: string): Promise<void>;
|
|
1352
|
+
/**
|
|
1353
|
+
* Unmerges cells in the given range
|
|
1354
|
+
* @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#UnmergeCellsRequest
|
|
1355
|
+
*/
|
|
1356
|
+
unmergeCells(range: GridRangeWithOptionalWorksheetId): Promise<void>;
|
|
1357
|
+
updateBorders(): Promise<void>;
|
|
1358
|
+
addFilterView(): Promise<void>;
|
|
1359
|
+
appendCells(): Promise<void>;
|
|
1360
|
+
clearBasicFilter(): Promise<void>;
|
|
1361
|
+
deleteDimension(): Promise<void>;
|
|
1362
|
+
deleteEmbeddedObject(): Promise<void>;
|
|
1363
|
+
deleteFilterView(): Promise<void>;
|
|
1364
|
+
duplicateFilterView(): Promise<void>;
|
|
1365
|
+
/**
|
|
1366
|
+
* Duplicate worksheet within the document
|
|
1367
|
+
* @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#DuplicateSheetRequest
|
|
1368
|
+
*/
|
|
1369
|
+
duplicate(options?: {
|
|
1370
|
+
id?: WorksheetId;
|
|
1371
|
+
title?: string;
|
|
1372
|
+
index?: number;
|
|
1373
|
+
}): Promise<GoogleSpreadsheetWorksheet>;
|
|
1374
|
+
findReplace(): Promise<void>;
|
|
1375
|
+
/**
|
|
1376
|
+
* Inserts rows or columns at a particular index
|
|
1377
|
+
* @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#InsertDimensionRequest
|
|
1378
|
+
*/
|
|
1379
|
+
insertDimension(columnsOrRows: WorksheetDimension, rangeIndexes: DimensionRangeIndexes, inheritFromBefore?: boolean): Promise<any>;
|
|
1380
|
+
insertRange(): Promise<void>;
|
|
1381
|
+
moveDimension(): Promise<void>;
|
|
1382
|
+
updateEmbeddedObjectPosition(): Promise<void>;
|
|
1383
|
+
pasteData(): Promise<void>;
|
|
1384
|
+
textToColumns(): Promise<void>;
|
|
1385
|
+
updateFilterView(): Promise<void>;
|
|
1386
|
+
deleteRange(): Promise<void>;
|
|
1387
|
+
appendDimension(): Promise<void>;
|
|
1388
|
+
addConditionalFormatRule(): Promise<void>;
|
|
1389
|
+
updateConditionalFormatRule(): Promise<void>;
|
|
1390
|
+
deleteConditionalFormatRule(): Promise<void>;
|
|
1391
|
+
sortRange(): Promise<void>;
|
|
1392
|
+
/**
|
|
1393
|
+
* Sets (or unsets) a data validation rule to every cell in the range
|
|
1394
|
+
* @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#SetDataValidationRequest
|
|
1395
|
+
*/
|
|
1396
|
+
setDataValidation(range: GridRangeWithOptionalWorksheetId,
|
|
1397
|
+
/** data validation rule object, or set to false to clear an existing rule */
|
|
1398
|
+
rule: DataValidationRule | false): Promise<any>;
|
|
1399
|
+
setBasicFilter(): Promise<void>;
|
|
1400
|
+
addProtectedRange(): Promise<void>;
|
|
1401
|
+
updateProtectedRange(): Promise<void>;
|
|
1402
|
+
deleteProtectedRange(): Promise<void>;
|
|
1403
|
+
autoResizeDimensions(): Promise<void>;
|
|
1404
|
+
addChart(): Promise<void>;
|
|
1405
|
+
updateChartSpec(): Promise<void>;
|
|
1406
|
+
updateBanding(): Promise<void>;
|
|
1407
|
+
addBanding(): Promise<void>;
|
|
1408
|
+
deleteBanding(): Promise<void>;
|
|
1409
|
+
createDeveloperMetadata(): Promise<void>;
|
|
1410
|
+
updateDeveloperMetadata(): Promise<void>;
|
|
1411
|
+
deleteDeveloperMetadata(): Promise<void>;
|
|
1412
|
+
randomizeRange(): Promise<void>;
|
|
1413
|
+
addDimensionGroup(): Promise<void>;
|
|
1414
|
+
deleteDimensionGroup(): Promise<void>;
|
|
1415
|
+
updateDimensionGroup(): Promise<void>;
|
|
1416
|
+
trimWhitespace(): Promise<void>;
|
|
1417
|
+
deleteDuplicates(): Promise<void>;
|
|
1418
|
+
addSlicer(): Promise<void>;
|
|
1419
|
+
updateSlicerSpec(): Promise<void>;
|
|
1420
|
+
/** delete this worksheet */
|
|
1421
|
+
delete(): Promise<void>;
|
|
1422
|
+
/**
|
|
1423
|
+
* copies this worksheet into another document/spreadsheet
|
|
1424
|
+
* @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.sheets/copyTo
|
|
1425
|
+
* */
|
|
1426
|
+
copyToSpreadsheet(destinationSpreadsheetId: SpreadsheetId): Promise<any>;
|
|
1427
|
+
/** clear data in the sheet - either the entire sheet or a specific range */
|
|
1428
|
+
clear(
|
|
1429
|
+
/** optional A1 range to clear - defaults to entire sheet */
|
|
1430
|
+
a1Range?: A1Range): Promise<void>;
|
|
1431
|
+
/** exports worksheet as CSV file (comma-separated values) */
|
|
1432
|
+
downloadAsCSV(): Promise<ArrayBuffer>;
|
|
1433
|
+
downloadAsCSV(returnStreamInsteadOfBuffer: false): Promise<ArrayBuffer>;
|
|
1434
|
+
downloadAsCSV(returnStreamInsteadOfBuffer: true): Promise<ReadableStream$1>;
|
|
1435
|
+
/** exports worksheet as TSC file (tab-separated values) */
|
|
1436
|
+
downloadAsTSV(): Promise<ArrayBuffer>;
|
|
1437
|
+
downloadAsTSV(returnStreamInsteadOfBuffer: false): Promise<ArrayBuffer>;
|
|
1438
|
+
downloadAsTSV(returnStreamInsteadOfBuffer: true): Promise<ReadableStream$1>;
|
|
1439
|
+
/** exports worksheet as PDF */
|
|
1440
|
+
downloadAsPDF(): Promise<ArrayBuffer>;
|
|
1441
|
+
downloadAsPDF(returnStreamInsteadOfBuffer: false): Promise<ArrayBuffer>;
|
|
1442
|
+
downloadAsPDF(returnStreamInsteadOfBuffer: true): Promise<ReadableStream$1>;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
type PermissionRoles = 'owner' | 'writer' | 'commenter' | 'reader';
|
|
1446
|
+
type PublicPermissionRoles = Exclude<PermissionRoles, 'owner'>;
|
|
1447
|
+
type PublicPermissionListEntry = {
|
|
1448
|
+
id: 'anyoneWithLink';
|
|
1449
|
+
type: 'anyone';
|
|
1450
|
+
role: PublicPermissionRoles;
|
|
1451
|
+
};
|
|
1452
|
+
type UserOrGroupPermissionListEntry = {
|
|
1453
|
+
id: string;
|
|
1454
|
+
displayName: string;
|
|
1455
|
+
type: 'user' | 'group';
|
|
1456
|
+
photoLink?: string;
|
|
1457
|
+
emailAddress: string;
|
|
1458
|
+
role: PermissionRoles;
|
|
1459
|
+
deleted: boolean;
|
|
1460
|
+
};
|
|
1461
|
+
type DomainPermissionListEntry = {
|
|
1462
|
+
id: string;
|
|
1463
|
+
displayName: string;
|
|
1464
|
+
type: 'domain';
|
|
1465
|
+
domain: string;
|
|
1466
|
+
role: PublicPermissionRoles;
|
|
1467
|
+
photoLink?: string;
|
|
1468
|
+
};
|
|
1469
|
+
type PermissionsList = (PublicPermissionListEntry | UserOrGroupPermissionListEntry | DomainPermissionListEntry)[];
|
|
1470
|
+
|
|
1471
|
+
/** single type to handle all valid auth types */
|
|
1472
|
+
type GoogleApiAuth = {
|
|
1473
|
+
getRequestHeaders: () => Promise<Headers>;
|
|
1474
|
+
} | {
|
|
1475
|
+
apiKey: string;
|
|
1476
|
+
} | {
|
|
1477
|
+
token: string;
|
|
1478
|
+
};
|
|
1479
|
+
declare enum AUTH_MODES {
|
|
1480
|
+
GOOGLE_AUTH_CLIENT = "google_auth",
|
|
1481
|
+
RAW_ACCESS_TOKEN = "raw_access_token",
|
|
1482
|
+
API_KEY = "api_key"
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
declare const EXPORT_CONFIG: Record<string, {
|
|
1486
|
+
singleWorksheet?: boolean;
|
|
1487
|
+
}>;
|
|
1488
|
+
type ExportFileTypes = keyof typeof EXPORT_CONFIG;
|
|
1489
|
+
/**
|
|
1490
|
+
* Google Sheets document
|
|
1491
|
+
*
|
|
1492
|
+
* @description
|
|
1493
|
+
* **This class represents an entire google spreadsheet document**
|
|
1494
|
+
* Provides methods to interact with document metadata/settings, formatting, manage sheets, and acts as the main gateway to interacting with sheets and data that the document contains.q
|
|
1495
|
+
*
|
|
1496
|
+
*/
|
|
1497
|
+
declare class GoogleSpreadsheet {
|
|
1498
|
+
readonly spreadsheetId: string;
|
|
1499
|
+
auth: GoogleApiAuth;
|
|
1500
|
+
get authMode(): AUTH_MODES;
|
|
1501
|
+
private _rawSheets;
|
|
1502
|
+
private _rawProperties;
|
|
1503
|
+
private _spreadsheetUrl;
|
|
1504
|
+
private _deleted;
|
|
1505
|
+
/**
|
|
1506
|
+
* Sheets API [ky](https://github.com/sindresorhus/ky?tab=readme-ov-file#kycreatedefaultoptions) instance
|
|
1507
|
+
* authentication is automatically attached
|
|
1508
|
+
* can be used if unsupported sheets calls need to be made
|
|
1509
|
+
* @see https://developers.google.com/sheets/api/reference/rest
|
|
1510
|
+
* */
|
|
1511
|
+
readonly sheetsApi: KyInstance;
|
|
1512
|
+
/**
|
|
1513
|
+
* Drive API [ky](https://github.com/sindresorhus/ky?tab=readme-ov-file#kycreatedefaultoptions) instance
|
|
1514
|
+
* authentication automatically attached
|
|
1515
|
+
* can be used if unsupported drive calls need to be made
|
|
1516
|
+
* @topic permissions
|
|
1517
|
+
* @see https://developers.google.com/drive/api/v3/reference
|
|
1518
|
+
* */
|
|
1519
|
+
readonly driveApi: KyInstance;
|
|
1520
|
+
/**
|
|
1521
|
+
* initialize new GoogleSpreadsheet
|
|
1522
|
+
* @category Initialization
|
|
1523
|
+
* */
|
|
1524
|
+
constructor(
|
|
1525
|
+
/** id of google spreadsheet doc */
|
|
1526
|
+
spreadsheetId: SpreadsheetId,
|
|
1527
|
+
/** authentication to use with Google Sheets API */
|
|
1528
|
+
auth: GoogleApiAuth);
|
|
1529
|
+
/** @internal */
|
|
1530
|
+
_setAuthRequestHook(req: Request): Promise<Request>;
|
|
1531
|
+
/** @internal */
|
|
1532
|
+
_errorHook(error: HTTPError): Promise<HTTPError<unknown>>;
|
|
1533
|
+
/** @internal */
|
|
1534
|
+
_makeSingleUpdateRequest(requestType: string, requestParams: any): Promise<any>;
|
|
1535
|
+
/** @internal */
|
|
1536
|
+
_makeBatchUpdateRequest(requests: any[], responseRanges?: string | string[]): Promise<void>;
|
|
1537
|
+
/** @internal */
|
|
1538
|
+
_ensureInfoLoaded(): void;
|
|
1539
|
+
/** @internal */
|
|
1540
|
+
_updateRawProperties(newProperties: SpreadsheetProperties): void;
|
|
1541
|
+
/** @internal */
|
|
1542
|
+
_updateOrCreateSheet(sheetInfo: {
|
|
1543
|
+
properties: WorksheetProperties;
|
|
1544
|
+
data: any;
|
|
1545
|
+
}): void;
|
|
1546
|
+
_getProp(param: keyof SpreadsheetProperties): any;
|
|
1547
|
+
get title(): SpreadsheetProperties['title'];
|
|
1548
|
+
get locale(): SpreadsheetProperties['locale'];
|
|
1549
|
+
get timeZone(): SpreadsheetProperties['timeZone'];
|
|
1550
|
+
get autoRecalc(): SpreadsheetProperties['autoRecalc'];
|
|
1551
|
+
get defaultFormat(): SpreadsheetProperties['defaultFormat'];
|
|
1552
|
+
get spreadsheetTheme(): SpreadsheetProperties['spreadsheetTheme'];
|
|
1553
|
+
get iterativeCalculationSettings(): SpreadsheetProperties['iterativeCalculationSettings'];
|
|
1554
|
+
/**
|
|
1555
|
+
* update spreadsheet properties
|
|
1556
|
+
* @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#SpreadsheetProperties
|
|
1557
|
+
* */
|
|
1558
|
+
updateProperties(properties: Partial<SpreadsheetProperties>): Promise<void>;
|
|
1559
|
+
loadInfo(includeCells?: boolean): Promise<void>;
|
|
1560
|
+
resetLocalCache(): void;
|
|
1561
|
+
get sheetCount(): number;
|
|
1562
|
+
get sheetsById(): Record<WorksheetId, GoogleSpreadsheetWorksheet>;
|
|
1563
|
+
get sheetsByIndex(): GoogleSpreadsheetWorksheet[];
|
|
1564
|
+
get sheetsByTitle(): Record<string, GoogleSpreadsheetWorksheet>;
|
|
1565
|
+
/**
|
|
1566
|
+
* Add new worksheet to document
|
|
1567
|
+
* @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#AddSheetRequest
|
|
1568
|
+
* */
|
|
1569
|
+
addSheet(properties?: Partial<RecursivePartial<WorksheetProperties> & {
|
|
1570
|
+
headerValues: string[];
|
|
1571
|
+
headerRowIndex: number;
|
|
1572
|
+
}>): Promise<GoogleSpreadsheetWorksheet>;
|
|
1573
|
+
/**
|
|
1574
|
+
* delete a worksheet
|
|
1575
|
+
* @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#DeleteSheetRequest
|
|
1576
|
+
* */
|
|
1577
|
+
deleteSheet(sheetId: WorksheetId): Promise<void>;
|
|
1578
|
+
/**
|
|
1579
|
+
* create a new named range
|
|
1580
|
+
* @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#AddNamedRangeRequest
|
|
1581
|
+
*/
|
|
1582
|
+
addNamedRange(
|
|
1583
|
+
/** name of new named range */
|
|
1584
|
+
name: string,
|
|
1585
|
+
/** GridRange object describing range */
|
|
1586
|
+
range: GridRange,
|
|
1587
|
+
/** id for named range (optional) */
|
|
1588
|
+
namedRangeId?: string): Promise<any>;
|
|
1589
|
+
/**
|
|
1590
|
+
* delete a named range
|
|
1591
|
+
* @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#DeleteNamedRangeRequest
|
|
1592
|
+
* */
|
|
1593
|
+
deleteNamedRange(
|
|
1594
|
+
/** id of named range to delete */
|
|
1595
|
+
namedRangeId: NamedRangeId): Promise<any>;
|
|
1596
|
+
/** fetch cell data into local cache */
|
|
1597
|
+
loadCells(
|
|
1598
|
+
/**
|
|
1599
|
+
* single filter or array of filters
|
|
1600
|
+
* strings are treated as A1 ranges, objects are treated as GridRange objects
|
|
1601
|
+
* pass nothing to fetch all cells
|
|
1602
|
+
* */
|
|
1603
|
+
filters?: DataFilter | DataFilter[]): Promise<void>;
|
|
1604
|
+
/**
|
|
1605
|
+
* export/download helper, not meant to be called directly (use downloadAsX methods on spreadsheet and worksheet instead)
|
|
1606
|
+
* @internal
|
|
1607
|
+
*/
|
|
1608
|
+
_downloadAs(fileType: ExportFileTypes, worksheetId: WorksheetId | undefined, returnStreamInsteadOfBuffer?: boolean): Promise<ArrayBuffer | stream_web.ReadableStream<any> | null>;
|
|
1609
|
+
/**
|
|
1610
|
+
* exports entire document as html file (zipped)
|
|
1611
|
+
* @topic export
|
|
1612
|
+
* */
|
|
1613
|
+
downloadAsZippedHTML(): Promise<ArrayBuffer>;
|
|
1614
|
+
downloadAsZippedHTML(returnStreamInsteadOfBuffer: false): Promise<ArrayBuffer>;
|
|
1615
|
+
downloadAsZippedHTML(returnStreamInsteadOfBuffer: true): Promise<ReadableStream>;
|
|
1616
|
+
/**
|
|
1617
|
+
* @deprecated
|
|
1618
|
+
* use `doc.downloadAsZippedHTML()` instead
|
|
1619
|
+
* */
|
|
1620
|
+
downloadAsHTML(returnStreamInsteadOfBuffer?: boolean): Promise<ArrayBuffer | stream_web.ReadableStream<any> | null>;
|
|
1621
|
+
/**
|
|
1622
|
+
* exports entire document as xlsx spreadsheet (Microsoft Office Excel)
|
|
1623
|
+
* @topic export
|
|
1624
|
+
* */
|
|
1625
|
+
downloadAsXLSX(): Promise<ArrayBuffer>;
|
|
1626
|
+
downloadAsXLSX(returnStreamInsteadOfBuffer: false): Promise<ArrayBuffer>;
|
|
1627
|
+
downloadAsXLSX(returnStreamInsteadOfBuffer: true): Promise<ReadableStream>;
|
|
1628
|
+
/**
|
|
1629
|
+
* exports entire document as ods spreadsheet (Open Office)
|
|
1630
|
+
* @topic export
|
|
1631
|
+
*/
|
|
1632
|
+
downloadAsODS(): Promise<ArrayBuffer>;
|
|
1633
|
+
downloadAsODS(returnStreamInsteadOfBuffer: false): Promise<ArrayBuffer>;
|
|
1634
|
+
downloadAsODS(returnStreamInsteadOfBuffer: true): Promise<ReadableStream>;
|
|
1635
|
+
delete(): Promise<void>;
|
|
1636
|
+
/**
|
|
1637
|
+
* list all permissions entries for doc
|
|
1638
|
+
*/
|
|
1639
|
+
listPermissions(): Promise<PermissionsList>;
|
|
1640
|
+
setPublicAccessLevel(role: PublicPermissionRoles | false): Promise<void>;
|
|
1641
|
+
/** share document to email or domain */
|
|
1642
|
+
share(emailAddressOrDomain: string, opts?: {
|
|
1643
|
+
/** set role level, defaults to owner */
|
|
1644
|
+
role?: PermissionRoles;
|
|
1645
|
+
/** set to true if email is for a group */
|
|
1646
|
+
isGroup?: boolean;
|
|
1647
|
+
/** set to string to include a custom message, set to false to skip sending a notification altogether */
|
|
1648
|
+
emailMessage?: string | false;
|
|
1649
|
+
}): Promise<unknown>;
|
|
1650
|
+
static createNewSpreadsheetDocument(auth: GoogleApiAuth, properties?: Partial<SpreadsheetProperties>): Promise<GoogleSpreadsheet>;
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
export { GoogleSpreadsheet, GoogleSpreadsheetCell, GoogleSpreadsheetCellErrorValue, GoogleSpreadsheetRow, GoogleSpreadsheetWorksheet };
|