@flytedesk/app-kit 8.0.0 → 9.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/README.md +15 -3
- package/dist/bigquery/errors.d.ts +34 -8
- package/dist/bigquery/errors.js +180 -22
- package/dist/bigquery/errors.js.map +1 -1
- package/dist/bigquery/index.d.ts +2 -1
- package/dist/bigquery/index.js +1 -1
- package/dist/bigquery/index.js.map +1 -1
- package/dist/bigquery/jobIdentity.d.ts +39 -0
- package/dist/bigquery/jobIdentity.js +83 -0
- package/dist/bigquery/jobIdentity.js.map +1 -0
- package/dist/bigquery/load.d.ts +11 -14
- package/dist/bigquery/load.js +132 -56
- package/dist/bigquery/load.js.map +1 -1
- package/dist/bigquery/query.d.ts +19 -1
- package/dist/bigquery/query.js +143 -50
- package/dist/bigquery/query.js.map +1 -1
- package/dist/bigquery/retry.d.ts +56 -0
- package/dist/bigquery/retry.js +110 -0
- package/dist/bigquery/retry.js.map +1 -0
- package/dist/bigquery/types.d.ts +40 -5
- package/package.json +1 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export interface RetryOptions {
|
|
2
|
+
/** Total attempts before giving up, including the first, counted across every
|
|
3
|
+
* step of the call (creating the job, checking it, resubmitting it). A
|
|
4
|
+
* positive integer; default 5. Pass 1 for a call that must never be
|
|
5
|
+
* repeated. */
|
|
6
|
+
attempts?: number;
|
|
7
|
+
/** Delay before the first retry; doubles every subsequent retry. Default 1000ms. */
|
|
8
|
+
initialDelayMs?: number;
|
|
9
|
+
/** Injectable for tests — real code always uses a real timer. */
|
|
10
|
+
sleep?: (ms: number) => Promise<void>;
|
|
11
|
+
/** Injectable clock (ms) for tests — real code always uses `Date.now`. */
|
|
12
|
+
now?: () => number;
|
|
13
|
+
}
|
|
14
|
+
/** One call's retry state: the attempts used so far and the time left. */
|
|
15
|
+
export declare class RetryPolicy {
|
|
16
|
+
private readonly what;
|
|
17
|
+
private readonly attempts;
|
|
18
|
+
private readonly initialDelayMs;
|
|
19
|
+
private readonly sleep;
|
|
20
|
+
private readonly now;
|
|
21
|
+
private readonly startedAt;
|
|
22
|
+
private readonly budgetMs;
|
|
23
|
+
private tried;
|
|
24
|
+
private lastTransient;
|
|
25
|
+
/** `budgetMs` is the TOTAL time the whole call may take, backoffs included. */
|
|
26
|
+
constructor(options: RetryOptions, what: string, budgetMs?: number);
|
|
27
|
+
/** Milliseconds of the budget still unspent, rounded up (the whole budget
|
|
28
|
+
* while the clock has not moved), or `undefined` when the call has no
|
|
29
|
+
* budget. Never negative. */
|
|
30
|
+
remainingMs(): number | undefined;
|
|
31
|
+
/** Starts an attempt: counts it and returns the budget left for it
|
|
32
|
+
* (`undefined` when the call has none). Never starts one with no time left:
|
|
33
|
+
* that gives up with the last transient error, or a `JobTimeoutError` when
|
|
34
|
+
* there was none. */
|
|
35
|
+
begin(): number | undefined;
|
|
36
|
+
/** The budget still unspent for a request inside an attempt, or throws when it
|
|
37
|
+
* is gone, so no request is sent with a zero wait. `undefined` when the call
|
|
38
|
+
* has no budget. */
|
|
39
|
+
timeLeft(): number | undefined;
|
|
40
|
+
private giveUp;
|
|
41
|
+
/**
|
|
42
|
+
* Called after an attempt failed with a transient `err` the caller has
|
|
43
|
+
* decided to retry: waits (doubling backoff, never past the budget) so the
|
|
44
|
+
* caller can `begin()` the next attempt. Throws the classified error, with
|
|
45
|
+
* the attempt count, when no attempt is left. When the budget runs out, the
|
|
46
|
+
* backoff is clamped to what is left and the next `begin()` gives up.
|
|
47
|
+
*/
|
|
48
|
+
retryAfter(err: unknown): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Runs `step` (one whole attempt, handed the budget left), retrying it while
|
|
51
|
+
* it fails with an error `shouldRetry` accepts and attempts and budget
|
|
52
|
+
* remain. Any other error is classified and thrown on the attempt that raised
|
|
53
|
+
* it.
|
|
54
|
+
*/
|
|
55
|
+
run<T>(step: (remainingMs: number | undefined) => Promise<T>, shouldRetry: (err: unknown) => boolean): Promise<T>;
|
|
56
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one bounded retry of every BigQuery call this module runs (queries, dry
|
|
3
|
+
* runs and load jobs): exponential backoff, a fixed number of attempts shared
|
|
4
|
+
* by every step of one call, and an optional ONE total time budget for the
|
|
5
|
+
* whole call. What may be retried is the caller's predicate for each step
|
|
6
|
+
* (see `isJobLevelFailure`, `isTransientRequestError` in ./errors.js): a
|
|
7
|
+
* request about an existing job is asked again, a job is resubmitted only when
|
|
8
|
+
* the job itself failed or was never created.
|
|
9
|
+
*/
|
|
10
|
+
import { BadQueryError, classifyBigQueryError, JobTimeoutError, } from "./errors.js";
|
|
11
|
+
const DEFAULT_ATTEMPTS = 5;
|
|
12
|
+
const DEFAULT_INITIAL_DELAY_MS = 1_000;
|
|
13
|
+
function defaultSleep(ms) {
|
|
14
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
15
|
+
}
|
|
16
|
+
/** One call's retry state: the attempts used so far and the time left. */
|
|
17
|
+
export class RetryPolicy {
|
|
18
|
+
what;
|
|
19
|
+
attempts;
|
|
20
|
+
initialDelayMs;
|
|
21
|
+
sleep;
|
|
22
|
+
now;
|
|
23
|
+
startedAt;
|
|
24
|
+
budgetMs;
|
|
25
|
+
tried = 0;
|
|
26
|
+
lastTransient;
|
|
27
|
+
/** `budgetMs` is the TOTAL time the whole call may take, backoffs included. */
|
|
28
|
+
constructor(options, what, budgetMs) {
|
|
29
|
+
this.what = what;
|
|
30
|
+
const attempts = options.attempts ?? DEFAULT_ATTEMPTS;
|
|
31
|
+
if (!Number.isInteger(attempts) || attempts < 1) {
|
|
32
|
+
throw new BadQueryError(`${what}: attempts must be a positive integer (got ${String(attempts)})`);
|
|
33
|
+
}
|
|
34
|
+
this.attempts = attempts;
|
|
35
|
+
this.initialDelayMs = options.initialDelayMs ?? DEFAULT_INITIAL_DELAY_MS;
|
|
36
|
+
this.sleep = options.sleep ?? defaultSleep;
|
|
37
|
+
this.now = options.now ?? Date.now;
|
|
38
|
+
this.startedAt = this.now();
|
|
39
|
+
this.budgetMs = budgetMs;
|
|
40
|
+
}
|
|
41
|
+
/** Milliseconds of the budget still unspent, rounded up (the whole budget
|
|
42
|
+
* while the clock has not moved), or `undefined` when the call has no
|
|
43
|
+
* budget. Never negative. */
|
|
44
|
+
remainingMs() {
|
|
45
|
+
if (this.budgetMs === undefined)
|
|
46
|
+
return undefined;
|
|
47
|
+
const elapsed = Math.max(0, this.now() - this.startedAt);
|
|
48
|
+
return Math.max(0, Math.ceil(this.budgetMs - elapsed));
|
|
49
|
+
}
|
|
50
|
+
/** Starts an attempt: counts it and returns the budget left for it
|
|
51
|
+
* (`undefined` when the call has none). Never starts one with no time left:
|
|
52
|
+
* that gives up with the last transient error, or a `JobTimeoutError` when
|
|
53
|
+
* there was none. */
|
|
54
|
+
begin() {
|
|
55
|
+
this.timeLeft();
|
|
56
|
+
this.tried += 1;
|
|
57
|
+
return this.remainingMs();
|
|
58
|
+
}
|
|
59
|
+
/** The budget still unspent for a request inside an attempt, or throws when it
|
|
60
|
+
* is gone, so no request is sent with a zero wait. `undefined` when the call
|
|
61
|
+
* has no budget. */
|
|
62
|
+
timeLeft() {
|
|
63
|
+
const remaining = this.remainingMs();
|
|
64
|
+
if (remaining !== 0)
|
|
65
|
+
return remaining;
|
|
66
|
+
if (this.lastTransient !== undefined) {
|
|
67
|
+
throw this.giveUp(this.lastTransient, "time budget spent");
|
|
68
|
+
}
|
|
69
|
+
throw new JobTimeoutError(this.budgetMs ?? 0);
|
|
70
|
+
}
|
|
71
|
+
giveUp(err, reason) {
|
|
72
|
+
const classified = classifyBigQueryError(err);
|
|
73
|
+
const Ctor = classified.constructor;
|
|
74
|
+
return new Ctor(`${classified.message} (gave up after ${this.tried} attempt${this.tried === 1 ? "" : "s"}: ${reason})`, classified.cause ?? err);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Called after an attempt failed with a transient `err` the caller has
|
|
78
|
+
* decided to retry: waits (doubling backoff, never past the budget) so the
|
|
79
|
+
* caller can `begin()` the next attempt. Throws the classified error, with
|
|
80
|
+
* the attempt count, when no attempt is left. When the budget runs out, the
|
|
81
|
+
* backoff is clamped to what is left and the next `begin()` gives up.
|
|
82
|
+
*/
|
|
83
|
+
async retryAfter(err) {
|
|
84
|
+
this.lastTransient = err;
|
|
85
|
+
if (this.tried >= this.attempts)
|
|
86
|
+
throw this.giveUp(err, "no attempts left");
|
|
87
|
+
const delayMs = Math.min(this.initialDelayMs * 2 ** (this.tried - 1), this.remainingMs() ?? Number.POSITIVE_INFINITY);
|
|
88
|
+
console.warn(`[bigquery/retry] ${this.what}: ${classifyBigQueryError(err).name} on attempt ${this.tried}/${this.attempts}, retrying in ${delayMs}ms`);
|
|
89
|
+
await this.sleep(delayMs);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Runs `step` (one whole attempt, handed the budget left), retrying it while
|
|
93
|
+
* it fails with an error `shouldRetry` accepts and attempts and budget
|
|
94
|
+
* remain. Any other error is classified and thrown on the attempt that raised
|
|
95
|
+
* it.
|
|
96
|
+
*/
|
|
97
|
+
async run(step, shouldRetry) {
|
|
98
|
+
for (;;) {
|
|
99
|
+
try {
|
|
100
|
+
return await step(this.begin());
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
if (!shouldRetry(err))
|
|
104
|
+
throw classifyBigQueryError(err);
|
|
105
|
+
await this.retryAfter(err);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=retry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/bigquery/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,eAAe,GAChB,MAAM,aAAa,CAAC;AAiBrB,MAAM,gBAAgB,GAAG,CAAC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I,CAAC,aAAa,GAAG,GAAG,CAAC;QACzB,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;QAC5E,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CACtB,IAAI,CAAC,cAAc,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,EAC3C,IAAI,CAAC,WAAW,EAAE,IAAI,MAAM,CAAC,iBAAiB,CAC/C,CAAC;QACF,OAAO,CAAC,IAAI,CACV,oBAAoB,IAAI,CAAC,IAAI,KAAK,qBAAqB,CAAC,GAAG,CAAC,CAAC,IAAI,eAAe,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,QAAQ,iBAAiB,OAAO,IAAI,CACxI,CAAC;QACF,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CACP,IAAqD,EACrD,WAAsC;QAEtC,SAAS,CAAC;YACR,IAAI,CAAC;gBACH,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;YAClC,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC;oBAAE,MAAM,qBAAqB,CAAC,GAAG,CAAC,CAAC;gBACxD,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
package/dist/bigquery/types.d.ts
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* in media-planner.
|
|
13
13
|
*/
|
|
14
14
|
import type { Writable } from "node:stream";
|
|
15
|
+
import type { RetryOptions } from "./retry.js";
|
|
15
16
|
/** One structured error entry, same shape the Google APIs client library
|
|
16
17
|
* attaches to a rejected job promise's `.errors` array. */
|
|
17
18
|
export interface BigQueryApiErrorDetail {
|
|
@@ -47,6 +48,9 @@ export interface BigQueryRawSchema {
|
|
|
47
48
|
fields?: BigQueryRawSchemaField[];
|
|
48
49
|
}
|
|
49
50
|
export interface BigQueryJobStatistics {
|
|
51
|
+
load?: {
|
|
52
|
+
outputRows?: string;
|
|
53
|
+
};
|
|
50
54
|
query?: {
|
|
51
55
|
totalBytesProcessed?: string | number;
|
|
52
56
|
totalBytesBilled?: string | number;
|
|
@@ -83,12 +87,18 @@ export type BigQueryNextQuery = {
|
|
|
83
87
|
pageToken?: string;
|
|
84
88
|
} | null;
|
|
85
89
|
export interface BigQueryJobLike {
|
|
90
|
+
/** The location BigQuery created the job in (the real `Job#location`). */
|
|
91
|
+
location?: string;
|
|
86
92
|
/** `@google-cloud/bigquery`'s real `Job#id` is itself `string | undefined`
|
|
87
93
|
* (inherited from its generic Operation base) — present in practice once a
|
|
88
94
|
* job has actually been created, but the SDK's own type never guarantees
|
|
89
95
|
* it. Callers fall back to `""` rather than assume non-null. */
|
|
90
96
|
id?: string;
|
|
91
97
|
getMetadata(): Promise<[BigQueryJobMetadata, unknown]>;
|
|
98
|
+
/** Resolves when the job is done; rejects with the job's error if it failed.
|
|
99
|
+
* The load helpers use it on a handle from `BigQueryLike#job` to wait on an
|
|
100
|
+
* existing load job again. */
|
|
101
|
+
promise?(): Promise<unknown>;
|
|
92
102
|
/** `@google-cloud/bigquery`'s real `Job#getQueryResults` return type varies
|
|
93
103
|
* in tuple length by overload (a plain `[rows]` when there is nothing else
|
|
94
104
|
* to report, up to `[rows, nextQuery, apiResponse]`) — accept any prefix of
|
|
@@ -199,7 +209,15 @@ export interface BigQueryLoadOptions {
|
|
|
199
209
|
writeDisposition?: "WRITE_TRUNCATE" | "WRITE_APPEND" | "WRITE_EMPTY";
|
|
200
210
|
createDisposition?: "CREATE_IF_NEEDED" | "CREATE_NEVER";
|
|
201
211
|
labels?: Record<string, string>;
|
|
212
|
+
/** The id the load job is submitted under, reused by every retry of the call
|
|
213
|
+
* (a random one when omitted). Submitting an id that already exists does not
|
|
214
|
+
* fail: the load helpers wait on that job and report ITS result, loading
|
|
215
|
+
* nothing again. */
|
|
202
216
|
jobId?: string;
|
|
217
|
+
/** The location of the dataset and the load job. BigQuery jobs are per
|
|
218
|
+
* location, so finding the job again after a failed submission needs it for
|
|
219
|
+
* data outside the US and EU multi-regions. */
|
|
220
|
+
location?: string;
|
|
203
221
|
}
|
|
204
222
|
export interface BigQueryInsertOptions {
|
|
205
223
|
skipInvalidRows: boolean;
|
|
@@ -226,6 +244,9 @@ export interface BigQueryDatasetLike {
|
|
|
226
244
|
}
|
|
227
245
|
/** A submitted load job, as `BigQuery#createJob` resolves it. */
|
|
228
246
|
export interface BigQueryLoadJobLike {
|
|
247
|
+
/** The location BigQuery created the job in. BigQuery jobs are per location,
|
|
248
|
+
* so the load helpers keep it to find the job again. */
|
|
249
|
+
location?: string;
|
|
229
250
|
/** Resolves when the job is done; rejects with the job's error if it failed. */
|
|
230
251
|
promise(): Promise<unknown>;
|
|
231
252
|
getMetadata(): Promise<readonly [{
|
|
@@ -243,14 +264,22 @@ export interface BigQueryLike {
|
|
|
243
264
|
* missing. Mirrors `@google-cloud/bigquery`'s `BigQuery#createJob`. */
|
|
244
265
|
createJob?(options: {
|
|
245
266
|
configuration: Record<string, unknown>;
|
|
267
|
+
/** The id to submit the job under (the SDK honours it). */
|
|
268
|
+
jobId?: string;
|
|
269
|
+
/** The location to create the job in (the SDK honours it). */
|
|
270
|
+
location?: string;
|
|
246
271
|
}): Promise<readonly [BigQueryLoadJobLike, ...unknown[]]>;
|
|
247
272
|
createQueryJob(options: BigQueryCreateQueryJobOptions): Promise<[BigQueryJobLike, BigQueryJobMetadata]>;
|
|
248
|
-
dataset(id: string
|
|
273
|
+
dataset(id: string, options?: {
|
|
274
|
+
location?: string;
|
|
275
|
+
}): BigQueryDatasetLike;
|
|
249
276
|
/** Looks up an already-submitted job by id — used to poll extract-job status
|
|
250
277
|
* independently of the handle returned at submission time. */
|
|
251
|
-
job(id: string
|
|
278
|
+
job(id: string, options?: {
|
|
279
|
+
location?: string;
|
|
280
|
+
}): BigQueryJobLike;
|
|
252
281
|
}
|
|
253
|
-
export interface RunQueryOptions {
|
|
282
|
+
export interface RunQueryOptions extends RetryOptions {
|
|
254
283
|
/** The parameterised SQL. Always use `params`/`types` for user-supplied
|
|
255
284
|
* values — never string-interpolate them into `sql`. */
|
|
256
285
|
sql: string;
|
|
@@ -268,7 +297,9 @@ export interface RunQueryOptions {
|
|
|
268
297
|
* it a token it never issued (AK-26). */
|
|
269
298
|
pageToken?: string;
|
|
270
299
|
/** The job that produced `pageToken` — required together with it to fetch
|
|
271
|
-
* the next page of that same job instead of starting a new one.
|
|
300
|
+
* the next page of that same job instead of starting a new one. Without a
|
|
301
|
+
* `pageToken` it is the id the new job is submitted under (a random one when
|
|
302
|
+
* omitted), reused by every retry of the call. */
|
|
272
303
|
jobId?: string;
|
|
273
304
|
/** Hard cap BigQuery itself enforces on the real job — a job that would
|
|
274
305
|
* bill more than this many bytes is refused by BigQuery before running,
|
|
@@ -293,10 +324,14 @@ export interface RunQueryOptions {
|
|
|
293
324
|
export interface QueryPage<T = Record<string, unknown>> {
|
|
294
325
|
rows: T[];
|
|
295
326
|
jobId: string;
|
|
327
|
+
/** The location the job runs in, as BigQuery reports it (else the one
|
|
328
|
+
* requested). Pass it back as `RunQueryOptions.location` with `pageToken` to
|
|
329
|
+
* fetch a later page: BigQuery jobs are per location. `runQueryAllPages` does. */
|
|
330
|
+
location?: string;
|
|
296
331
|
/** Present when another page is available. */
|
|
297
332
|
nextPageToken?: string;
|
|
298
333
|
}
|
|
299
|
-
export interface EstimateQueryBytesOptions {
|
|
334
|
+
export interface EstimateQueryBytesOptions extends RetryOptions {
|
|
300
335
|
sql: string;
|
|
301
336
|
params?: unknown[] | Record<string, unknown>;
|
|
302
337
|
/** Declared BigQuery parameter types — see `BigQueryParamTypes`. */
|
package/package.json
CHANGED