@firebase-function-kits/firestore-bigquery-export 0.0.2-rc.16 → 0.0.2-rc.17

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/CHANGELOG.md CHANGED
@@ -1,4 +1,3 @@
1
- - feat: add the `./default-options` entry, which exports `defaultOptions` (`cpu: "gcf_gen1"`, `concurrency: 1`, `maxInstances: 100`). Spread it into your codebase's single `setGlobalOptions` call, before your own keys: `setGlobalOptions({ ...defaultOptions, region })`. The functions no longer declare `cpu` or `concurrency` themselves, so your global options can now override them; before, the per-function values always won. A hand-written entry that does not spread `defaultOptions` deploys at the 2nd gen defaults (1 vCPU at 256MiB, concurrency `80`) instead of the extension's 0.1666 vCPU. The trigger takes its instance cap from `defaultOptions` (100, the platform default the extension's 2nd gen trigger ran at) or your override. In an ES module entry, `export ... from` loads the kit before any `setGlobalOptions` statement in the same file runs, so call `setGlobalOptions` in its own module and import it first. Deploy discovery logs a warning when the kit loads with no global `cpu` set. `fsexportbigquery` keeps `ingressSettings: "ALLOW_INTERNAL_ONLY"`, the task-queue functions keep `timeoutSeconds: 540`, and `syncBigQuery` keeps `maxInstances: 500`, which a global `maxInstances` does not change.
2
1
  - fix: `eventarcpublishing.googleapis.com` and `roles/eventarc.publisher` are declared only when `EVENTARC_CHANNEL` is set in `.env`. A default install never publishes an event, yet every deploy prompted to enable the Eventarc Publishing API and declining aborted the deploy with `Must enable required APIs to deploy.` The extension declared only `bigquery.googleapis.com` and gained Eventarc publishing when the user opted into events at install; the kit now does the same. Detecting the channel needs firebase-tools 15.28.0 or later, which loads `.env` during deploy discovery; an older CLI skips the declarations even with `EVENTARC_CHANNEL` set, and every publish then fails with `PERMISSION_DENIED`, logged as a warning while the export continues. A blank `EVENTARC_CHANNEL` now disables events the same as an unset one.
3
2
  - fix: cap `syncBigQuery` at `maxInstances: 500`, its declared `maxConcurrentDispatches`. At concurrency `1`, the default 100 instances would take only 100 of the 500 dispatches Cloud Tasks may have in flight, so the cap keeps capacity level with the dispatch limit. A dispatch above the instance ceiling waits up to about 10 seconds for a free instance, then gets a Cloud Run 429 that Cloud Tasks counts as a failed attempt and retries on the queue's schedule (5 attempts, 60s minimum backoff), slowing the queue while 429s continue. The handler never ran for such a dispatch, so a task that exhausts its attempts that way writes no `BACKUP_COLLECTION` row. At 0.1666 vCPU the cap needs about 84 vCPU of regional Cloud Run CPU quota, within the captured defaults (500 in most regions, 343 in `europe-west10` and `europe-west12`); the README describes the deploy failure a smaller quota produces and how to recover.
4
3
  - fix: set `timeoutSeconds: 540` on `syncBigQuery`, `initBigQuerySync` and `setupBigQuerySync`, the extension's 1st gen task-function timeout, instead of the 2nd gen default of 60s. `fsexportbigquery` keeps 60s, which the deployed trigger ran at.
package/README.md CHANGED
@@ -47,20 +47,10 @@ CMEK dataset, also grant the BigQuery service account access to your KMS key.
47
47
 
48
48
  ## Usage
49
49
 
50
- Spread the kit's `defaultOptions` into your codebase's single
51
- `setGlobalOptions` call, then export the four functions from your functions
52
- codebase entry. `setGlobalOptions` must run before the kit module loads,
53
- because the kit reads the global options when it defines its functions. A
54
- TypeScript entry compiled to CommonJS runs its statements in order, so this
55
- works:
50
+ Export the four functions from your functions codebase entry:
56
51
 
57
52
  ```ts
58
53
  // functions/src/index.ts
59
- import { setGlobalOptions } from "firebase-functions";
60
- import { defaultOptions } from "@firebase-function-kits/firestore-bigquery-export/default-options";
61
-
62
- setGlobalOptions({ ...defaultOptions });
63
-
64
54
  export {
65
55
  fsexportbigquery,
66
56
  syncBigQuery,
@@ -69,29 +59,6 @@ export {
69
59
  } from "@firebase-function-kits/firestore-bigquery-export";
70
60
  ```
71
61
 
72
- In an ES module entry (`"type": "module"`, or TypeScript emitting ES modules),
73
- Node loads every `import` and `export ... from` before any statement in the
74
- file runs, so the kit loads before `setGlobalOptions` and your functions
75
- deploy at 1 vCPU and concurrency `80`. Call `setGlobalOptions` in its
76
- own module and import that module first:
77
-
78
- ```js
79
- // functions/options.js
80
- import { setGlobalOptions } from "firebase-functions";
81
- import { defaultOptions } from "@firebase-function-kits/firestore-bigquery-export/default-options";
82
-
83
- setGlobalOptions({ ...defaultOptions });
84
- ```
85
-
86
- ```js
87
- // functions/index.js
88
- import "./options.js";
89
- export * from "@firebase-function-kits/firestore-bigquery-export";
90
- ```
91
-
92
- If the global options set no `cpu` when the kit loads, deploy logs a warning
93
- that `defaultOptions` was not applied.
94
-
95
62
  and configure them with a `.env` (or `.env.<projectId>`):
96
63
 
97
64
  ```sh
@@ -617,46 +584,12 @@ documents missed during a migration.
617
584
 
618
585
  ### Concurrency, CPU and timeouts match the extension
619
586
 
620
- The kit exports `defaultOptions` from
621
- `@firebase-function-kits/firestore-bigquery-export/default-options`:
622
- `cpu: "gcf_gen1"`, `concurrency: 1` and `maxInstances: 100`. The extension
623
- deployed every function at 0.1666 vCPU with an instance handling one
624
- invocation at a time. `maxInstances: 100` matches the extension's Firestore
625
- trigger, a 2nd gen function that ran at the platform default of 100
626
- instances; the extension's task-queue functions were 1st gen functions with no
627
- declared cap. The 2nd gen defaults would be concurrency `80` and 1 vCPU at
628
- 256MiB. The module has no side effects, so you can import it before
629
- `setGlobalOptions` runs.
630
-
631
- Firebase Functions applies options in this order, field by field:
632
-
633
- 1. The object you pass to `setGlobalOptions`. Spread `defaultOptions` first
634
- and put your own keys after it, so your keys win:
635
- `setGlobalOptions({ ...defaultOptions, region: "europe-west1", maxInstances: 20 })`.
636
- A key you set to `undefined` also wins: `maxInstances: undefined` removes
637
- the default cap instead of keeping it.
638
- 2. The options each function declares, which override the globals. The kit
639
- declares only `ingressSettings` on `fsexportbigquery`, `timeoutSeconds` and
640
- `retryConfig` on the task-queue functions, `maxInstances` and `rateLimits`
641
- on `syncBigQuery`, and `region` from `DATABASE_REGION`.
642
-
643
- A codebase calls `setGlobalOptions` once; a second call replaces the first
644
- instead of merging with it. For that reason the kit does not call it. If you
645
- write your own entry file and do not spread `defaultOptions`, or your ES
646
- module entry loads the kit before `setGlobalOptions` runs (see
647
- [Usage](#usage)), every function falls back to the 2nd gen defaults: 1 vCPU at
648
- 256MiB, concurrency `80` and no instance cap from the kit. You lose CPU parity
649
- with the extension.
650
-
651
- `concurrency` above `1` needs `cpu` of `1` or more. To raise concurrency,
652
- override both keys:
653
- `setGlobalOptions({ ...defaultOptions, cpu: 1, concurrency: 80 })`.
654
-
655
- `fsexportbigquery` sets `ingressSettings: "ALLOW_INTERNAL_ONLY"`, so only
656
- internal traffic reaches the Firestore trigger, as with the extension. This
657
- option is not in `defaultOptions`: as a global it would also apply to the
658
- task-queue functions and stop Cloud Tasks from invoking them. The task-queue
659
- functions `syncBigQuery`, `initBigQuerySync` and
587
+ Every function sets `concurrency: 1` and `cpu: "gcf_gen1"`, and
588
+ `fsexportbigquery` also sets `ingressSettings: "ALLOW_INTERNAL_ONLY"`. The 2nd
589
+ gen defaults would be concurrency `80`, `ALLOW_ALL`, and 1 vCPU at 256MiB. The
590
+ extension deployed every function at 0.1666 vCPU with an instance handling one
591
+ invocation at a time, and only internal traffic reached the Firestore trigger.
592
+ The task-queue functions `syncBigQuery`, `initBigQuerySync` and
660
593
  `setupBigQuerySync` set `timeoutSeconds: 540`, the extension's 1st gen task
661
594
  timeout; `fsexportbigquery` keeps the 60 second default, which the deployed
662
595
  trigger ran at.
@@ -669,21 +602,20 @@ functions ran with open ingress, and the `curl` into `initBigQuerySync` under
669
602
  globally makes that request fail.
670
603
 
671
604
  At concurrency `1`, a function serves as many requests at once as it has
672
- instances. `fsexportbigquery`, `initBigQuerySync` and `setupBigQuerySync` take
673
- the `maxInstances: 100` from `defaultOptions` unless you override it after the
674
- spread; the two lifecycle tasks receive one task per deploy, so the cap does
675
- not matter for them. The trigger therefore handles 100
605
+ instances. `fsexportbigquery`, `initBigQuerySync` and `setupBigQuerySync` run
606
+ on the Cloud Run default of 100 instances unless your codebase sets
607
+ `setGlobalOptions({ maxInstances })`; the two lifecycle tasks receive one task
608
+ per deploy, so no cap is declared on them. The trigger therefore handles 100
676
609
  events at once, the same as the deployed extension trigger (100 instances,
677
610
  concurrency `1`, no retry policy). An event above that ceiling waits up to
678
611
  about 10 seconds for a free instance and is then refused before the handler
679
612
  runs: no error log, no `onError` event, no enqueue and no backup row. Whether
680
613
  Eventarc redelivers a refused push under the trigger's
681
- `RETRY_POLICY_DO_NOT_RETRY` is not verified. Set a higher `maxInstances` after
682
- the `defaultOptions` spread to lift the ceiling.
614
+ `RETRY_POLICY_DO_NOT_RETRY` is not verified. Raise
615
+ `setGlobalOptions({ maxInstances })` to lift the ceiling.
683
616
 
684
617
  `syncBigQuery` sets `maxInstances: 500` to match its `maxConcurrentDispatches`
685
- limit. A global `maxInstances`, from `defaultOptions` or from your own keys,
686
- does not change it, because the per-function value wins: Cloud Tasks may
618
+ limit, and a global `maxInstances` does not override it: Cloud Tasks may
687
619
  dispatch 500 tasks at once, and 100 instances would take only 100 of them. A
688
620
  dispatch above the instance ceiling waits for a free instance for up to about
689
621
  10 seconds, then gets a Cloud Run 429. Cloud Tasks counts that as a failed
@@ -722,10 +654,6 @@ services in the region.
722
654
  yourself, plus the config types and helpers (`ExportConfig`,
723
655
  `resolveExportConfig`, `toTrackerConfig`, `SerializedDocumentChange`) for
724
656
  building their injected `HandlerContext`. Safe to import anywhere.
725
- - **Default options entry** (`./default-options`): `defaultOptions`, the
726
- global options to spread into your `setGlobalOptions` call (see
727
- [Concurrency, CPU and timeouts](#concurrency-cpu-and-timeouts-match-the-extension)).
728
- Safe to import anywhere.
729
657
 
730
658
  The change-tracker engine is an internal dependency and is not exported.
731
659
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmDA,OAAO,EAEL,KAAK,wBAAwB,EAG9B,MAAM,YAAY,CAAC;AAUpB,cAAc,OAAO,CAAC;AAgItB;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,wOAO5B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,gFAiBxB,CAAC;AAWF;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,2DAG5B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,2DAG7B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmDA,OAAO,EAEL,KAAK,wBAAwB,EAG9B,MAAM,YAAY,CAAC;AAQpB,cAAc,OAAO,CAAC;AAoItB;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,wOAO5B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,gFAiBxB,CAAC;AAWF;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,2DAG5B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,2DAG7B,CAAC"}
package/lib/index.js CHANGED
@@ -75,13 +75,11 @@ const config_1 = require("./config");
75
75
  const events = __importStar(require("./events"));
76
76
  const export_config_1 = require("./export-config");
77
77
  const handlers_1 = require("./handlers");
78
- const global_options_1 = require("./global-options");
79
78
  const init_1 = require("./init");
80
79
  const logs = __importStar(require("./logs"));
81
80
  const region_1 = require("./region");
82
81
  const tasks_2 = require("./tasks");
83
82
  (0, config_1.assertRequiredParams)();
84
- (0, global_options_1.warnIfDefaultOptionsMissing)();
85
83
  // Re-export the side-effect-free library surface (handlers and config types).
86
84
  __exportStar(require("./lib"), exports);
87
85
  const INIT_BIGQUERY_SYNC_FUNCTION = "initBigQuerySync";
@@ -168,14 +166,18 @@ const functionRegion = (0, region_1.firestoreLocationToFunctionRegion)(process.e
168
166
  const REGION_OPTION = functionRegion
169
167
  ? { region: functionRegion }
170
168
  : {};
171
- /** Trigger ingress; as a global it would stop Cloud Tasks from invoking the task functions. */
169
+ /** Options of the Firestore trigger, matching the extension's deployed trigger. */
172
170
  const EVENT_FUNCTION_OPTIONS = {
173
171
  ...REGION_OPTION,
172
+ concurrency: 1,
173
+ cpu: "gcf_gen1",
174
174
  ingressSettings: "ALLOW_INTERNAL_ONLY",
175
175
  };
176
- /** Options shared by the task-queue functions: the extension's 1st gen task timeout. */
176
+ /** Options shared by the task-queue functions, matching the extension's 1st gen task functions. */
177
177
  const TASK_FUNCTION_OPTIONS = {
178
178
  ...REGION_OPTION,
179
+ concurrency: 1,
180
+ cpu: "gcf_gen1",
179
181
  timeoutSeconds: 540,
180
182
  };
181
183
  /** Options of the two lifecycle tasks, which share one retry config. */
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH;;;;;;;;;;;GAWG;AAEH,6GAA6G;AAC7G,4CAA4D;AAC5D,4DAAiE;AACjE,sDAAiD;AACjD,oDAA4D;AAE5D,8CAAkE;AAClE,+DAGyC;AACzC,qCAIkB;AAClB,iDAAmC;AACnC,mDAIyB;AACzB,yCAKoB;AACpB,qDAA+D;AAC/D,iCAAiD;AACjD,6CAA+B;AAC/B,qCAA6D;AAC7D,mCAA0C;AAE1C,IAAA,6BAAoB,GAAE,CAAC;AACvB,IAAA,4CAA2B,GAAE,CAAC;AAC9B,8EAA8E;AAC9E,wCAAsB;AAEtB,MAAM,2BAA2B,GAAG,kBAAkB,CAAC;AACvD,MAAM,4BAA4B,GAAG,mBAAmB,CAAC;AACzD,MAAM,sBAAsB,GAAG;IAC7B,WAAW,EAAE,EAAE;IACf,iBAAiB,EAAE,EAAE;CACb,CAAC;AACX,MAAM,iBAAiB,GAAG;IACxB,WAAW,EAAE,CAAC;IACd,iBAAiB,EAAE,EAAE;CACb,CAAC;AACX,MAAM,8BAA8B,GAAG,GAAG,CAAC;AAC3C,MAAM,cAAc,GAAwB;IAC1C,2BAA2B;IAC3B,sBAAsB;IACtB,qBAAqB;IACrB,oFAAoF;IACpF,8BAA8B;IAC9B,mBAAmB;IACnB,2EAA2E;IAC3E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AC,GAAG,EAAE,iBAAiB,EAAE,CAAC,CAC1D,CAAC;AAEF,KAAK,UAAU,gCAAgC;IAC7C,IAAI,CAAC;QACH,MAAM,iBAAiB,EAAE,CAAC,iBAAiB,EAAE,CAAC;IAChD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,yCAAyC,EAAE,GAAG,CAAC,CAAC;QAClE,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACU,QAAA,gBAAgB,GAAG,IAAA,wBAAgB,EAC9C,sBAAsB,EACtB,gCAAgC,CACjC,CAAC;AAEF;;;GAGG;AACU,QAAA,iBAAiB,GAAG,IAAA,wBAAgB,EAC/C,sBAAsB,EACtB,gCAAgC,CACjC,CAAC"}
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@firebase-function-kits/firestore-bigquery-export",
3
- "version": "0.0.2-rc.16",
3
+ "version": "0.0.2-rc.17",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@firebase-function-kits/firestore-bigquery-export",
9
- "version": "0.0.2-rc.16",
9
+ "version": "0.0.2-rc.17",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "@firebaseextensions/firestore-bigquery-change-tracker": "^2.2.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firebase-function-kits/firestore-bigquery-export",
3
- "version": "0.0.2-rc.16",
3
+ "version": "0.0.2-rc.17",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/firebase/extensions.git",
@@ -18,20 +18,6 @@
18
18
  "./lib": {
19
19
  "types": "./lib/lib.d.ts",
20
20
  "default": "./lib/lib.js"
21
- },
22
- "./default-options": {
23
- "types": "./lib/default-options.d.ts",
24
- "default": "./lib/default-options.js"
25
- }
26
- },
27
- "typesVersions": {
28
- "*": {
29
- "default-options": [
30
- "lib/default-options.d.ts"
31
- ],
32
- "lib": [
33
- "lib/lib.d.ts"
34
- ]
35
21
  }
36
22
  },
37
23
  "engines": {
package/src/index.ts CHANGED
@@ -55,14 +55,12 @@ import {
55
55
  handleDocumentWrite,
56
56
  handleSyncBigQueryTask,
57
57
  } from "./handlers";
58
- import { warnIfDefaultOptionsMissing } from "./global-options";
59
58
  import { createEnsureInitialized } from "./init";
60
59
  import * as logs from "./logs";
61
60
  import { firestoreLocationToFunctionRegion } from "./region";
62
61
  import { enqueueSyncTask } from "./tasks";
63
62
 
64
63
  assertRequiredParams();
65
- warnIfDefaultOptionsMissing();
66
64
  // Re-export the side-effect-free library surface (handlers and config types).
67
65
  export * from "./lib";
68
66
 
@@ -174,15 +172,19 @@ const REGION_OPTION = functionRegion
174
172
  ? ({ region: functionRegion } as const)
175
173
  : {};
176
174
 
177
- /** Trigger ingress; as a global it would stop Cloud Tasks from invoking the task functions. */
175
+ /** Options of the Firestore trigger, matching the extension's deployed trigger. */
178
176
  const EVENT_FUNCTION_OPTIONS = {
179
177
  ...REGION_OPTION,
178
+ concurrency: 1,
179
+ cpu: "gcf_gen1",
180
180
  ingressSettings: "ALLOW_INTERNAL_ONLY",
181
181
  } as const;
182
182
 
183
- /** Options shared by the task-queue functions: the extension's 1st gen task timeout. */
183
+ /** Options shared by the task-queue functions, matching the extension's 1st gen task functions. */
184
184
  const TASK_FUNCTION_OPTIONS = {
185
185
  ...REGION_OPTION,
186
+ concurrency: 1,
187
+ cpu: "gcf_gen1",
186
188
  timeoutSeconds: 540,
187
189
  } as const;
188
190
 
@@ -213,12 +213,12 @@ describe("exported function options", () => {
213
213
  });
214
214
 
215
215
  test.each(RUNTIME_OPTIONS_BY_FUNCTION)(
216
- "%s declares ingress %s, maxInstances %s, timeout %s and leaves cpu and concurrency to the global options",
216
+ "%s runs one request per 0.1666 vCPU instance with ingress %s, maxInstances %s, timeout %s",
217
217
  async (name, ingress, maxInstances, timeoutSeconds) => {
218
218
  const deployed = await loadDeployedOptions();
219
219
  const opts = deployed[name];
220
- expect(opts).not.toHaveProperty("concurrency");
221
- expect(opts).not.toHaveProperty("cpu");
220
+ expect(opts.concurrency).toBe(1);
221
+ expect(opts.cpu).toBe("gcf_gen1");
222
222
  expectOptional(opts, "ingressSettings", ingress);
223
223
  expectOptional(opts, "maxInstances", maxInstances);
224
224
  expectOptional(opts, "timeoutSeconds", timeoutSeconds);
@@ -1 +1 @@
1
- {"root":["./src/config.ts","./src/default-options.ts","./src/events.ts","./src/export-config.ts","./src/global-options.ts","./src/handlers.ts","./src/index.ts","./src/init.ts","./src/lib.ts","./src/logs.ts","./src/region.ts","./src/tasks.ts","./src/util.ts"],"version":"5.9.3"}
1
+ {"root":["./src/config.ts","./src/events.ts","./src/export-config.ts","./src/handlers.ts","./src/index.ts","./src/init.ts","./src/lib.ts","./src/logs.ts","./src/region.ts","./src/tasks.ts","./src/util.ts"],"version":"5.9.3"}
@@ -1,18 +0,0 @@
1
- /**
2
- * Global options that reproduce the extension's runtime shape: one request per
3
- * 0.1666 vCPU instance, up to 100 instances. Spread into your codebase's single
4
- * `setGlobalOptions` call, before your own keys so they override these:
5
- *
6
- * ```ts
7
- * setGlobalOptions({ ...defaultOptions, region: "europe-west1" });
8
- * ```
9
- *
10
- * Importing this module has no side effects, so it is safe to import before
11
- * `setGlobalOptions` runs.
12
- */
13
- export declare const defaultOptions: {
14
- readonly cpu: "gcf_gen1";
15
- readonly concurrency: 1;
16
- readonly maxInstances: 100;
17
- };
18
- //# sourceMappingURL=default-options.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"default-options.d.ts","sourceRoot":"","sources":["../src/default-options.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc;;;;CAIO,CAAC"}
@@ -1,36 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright 2026 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * https://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.defaultOptions = void 0;
19
- /**
20
- * Global options that reproduce the extension's runtime shape: one request per
21
- * 0.1666 vCPU instance, up to 100 instances. Spread into your codebase's single
22
- * `setGlobalOptions` call, before your own keys so they override these:
23
- *
24
- * ```ts
25
- * setGlobalOptions({ ...defaultOptions, region: "europe-west1" });
26
- * ```
27
- *
28
- * Importing this module has no side effects, so it is safe to import before
29
- * `setGlobalOptions` runs.
30
- */
31
- exports.defaultOptions = {
32
- cpu: "gcf_gen1",
33
- concurrency: 1,
34
- maxInstances: 100,
35
- };
36
- //# sourceMappingURL=default-options.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"default-options.js","sourceRoot":"","sources":["../src/default-options.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIH;;;;;;;;;;;GAWG;AACU,QAAA,cAAc,GAAG;IAC5B,GAAG,EAAE,UAAU;IACf,WAAW,EAAE,CAAC;IACd,YAAY,EAAE,GAAG;CACe,CAAC"}
@@ -1,9 +0,0 @@
1
- /** Warning logged when deploy discovery loads the kit before `defaultOptions` reached `setGlobalOptions`. */
2
- export declare const DEFAULT_OPTIONS_MISSING_WARNING: string;
3
- /**
4
- * Logs {@link DEFAULT_OPTIONS_MISSING_WARNING} during deploy discovery when the
5
- * codebase's global options set no `cpu`, which means `defaultOptions` was not
6
- * applied before the kit's functions were defined.
7
- */
8
- export declare function warnIfDefaultOptionsMissing(): void;
9
- //# sourceMappingURL=global-options.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"global-options.d.ts","sourceRoot":"","sources":["../src/global-options.ts"],"names":[],"mappings":"AAyBA,6GAA6G;AAC7G,eAAO,MAAM,+BAA+B,QAMwF,CAAC;AAErI;;;;GAIG;AACH,wBAAgB,2BAA2B,IAAI,IAAI,CAQlD"}
@@ -1,78 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright 2026 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * https://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- var desc = Object.getOwnPropertyDescriptor(m, k);
20
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
- desc = { enumerable: true, get: function() { return m[k]; } };
22
- }
23
- Object.defineProperty(o, k2, desc);
24
- }) : (function(o, m, k, k2) {
25
- if (k2 === undefined) k2 = k;
26
- o[k2] = m[k];
27
- }));
28
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
- Object.defineProperty(o, "default", { enumerable: true, value: v });
30
- }) : function(o, v) {
31
- o["default"] = v;
32
- });
33
- var __importStar = (this && this.__importStar) || (function () {
34
- var ownKeys = function(o) {
35
- ownKeys = Object.getOwnPropertyNames || function (o) {
36
- var ar = [];
37
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
38
- return ar;
39
- };
40
- return ownKeys(o);
41
- };
42
- return function (mod) {
43
- if (mod && mod.__esModule) return mod;
44
- var result = {};
45
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
46
- __setModuleDefault(result, mod);
47
- return result;
48
- };
49
- })();
50
- Object.defineProperty(exports, "__esModule", { value: true });
51
- exports.DEFAULT_OPTIONS_MISSING_WARNING = void 0;
52
- exports.warnIfDefaultOptionsMissing = warnIfDefaultOptionsMissing;
53
- const logger_1 = require("firebase-functions/logger");
54
- const functionsOptions = __importStar(require("firebase-functions/options"));
55
- /** `getGlobalOptions` ships at runtime but is marked internal, so it is absent from the typings. */
56
- const { getGlobalOptions } = functionsOptions;
57
- /** Warning logged when deploy discovery loads the kit before `defaultOptions` reached `setGlobalOptions`. */
58
- exports.DEFAULT_OPTIONS_MISSING_WARNING = "firestore-bigquery-export: no global cpu was set when the kit loaded, so its functions " +
59
- "deploy at the 2nd gen defaults (1 vCPU, concurrency 80) instead of the extension's 0.1666 vCPU. " +
60
- "Spread defaultOptions from @firebase-function-kits/firestore-bigquery-export/default-options " +
61
- "into setGlobalOptions before the kit is imported. In an ES module entry, call setGlobalOptions " +
62
- "in its own module and import that module first. See " +
63
- "https://github.com/firebase/extensions/tree/kits/kits/firestore-bigquery-export#concurrency-cpu-and-timeouts-match-the-extension";
64
- /**
65
- * Logs {@link DEFAULT_OPTIONS_MISSING_WARNING} during deploy discovery when the
66
- * codebase's global options set no `cpu`, which means `defaultOptions` was not
67
- * applied before the kit's functions were defined.
68
- */
69
- function warnIfDefaultOptionsMissing() {
70
- // The Firebase CLI sets FUNCTIONS_CONTROL_API only in the discovery process.
71
- if (process.env.FUNCTIONS_CONTROL_API !== "true" || !getGlobalOptions) {
72
- return;
73
- }
74
- if (getGlobalOptions().cpu === undefined) {
75
- (0, logger_1.warn)(exports.DEFAULT_OPTIONS_MISSING_WARNING);
76
- }
77
- }
78
- //# sourceMappingURL=global-options.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"global-options.js","sourceRoot":"","sources":["../src/global-options.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBH,kEAQC;AA/BD,sDAAiD;AACjD,6EAA+D;AAG/D,oGAAoG;AACpG,MAAM,EAAE,gBAAgB,EAAE,GAAG,gBAE5B,CAAC;AAEF,6GAA6G;AAChG,QAAA,+BAA+B,GAC1C,yFAAyF;IACzF,kGAAkG;IAClG,+FAA+F;IAC/F,iGAAiG;IACjG,sDAAsD;IACtD,kIAAkI,CAAC;AAErI;;;;GAIG;AACH,SAAgB,2BAA2B;IACzC,6EAA6E;IAC7E,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtE,OAAO;IACT,CAAC;IACD,IAAI,gBAAgB,EAAE,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QACzC,IAAA,aAAI,EAAC,uCAA+B,CAAC,CAAC;IACxC,CAAC;AACH,CAAC"}
@@ -1,35 +0,0 @@
1
- /*
2
- * Copyright 2026 Google LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * https://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
- import type { GlobalOptions } from "firebase-functions/options";
18
-
19
- /**
20
- * Global options that reproduce the extension's runtime shape: one request per
21
- * 0.1666 vCPU instance, up to 100 instances. Spread into your codebase's single
22
- * `setGlobalOptions` call, before your own keys so they override these:
23
- *
24
- * ```ts
25
- * setGlobalOptions({ ...defaultOptions, region: "europe-west1" });
26
- * ```
27
- *
28
- * Importing this module has no side effects, so it is safe to import before
29
- * `setGlobalOptions` runs.
30
- */
31
- export const defaultOptions = {
32
- cpu: "gcf_gen1",
33
- concurrency: 1,
34
- maxInstances: 100,
35
- } as const satisfies GlobalOptions;
@@ -1,48 +0,0 @@
1
- /*
2
- * Copyright 2026 Google LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * https://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
- import { warn } from "firebase-functions/logger";
18
- import * as functionsOptions from "firebase-functions/options";
19
- import type { GlobalOptions } from "firebase-functions/options";
20
-
21
- /** `getGlobalOptions` ships at runtime but is marked internal, so it is absent from the typings. */
22
- const { getGlobalOptions } = functionsOptions as typeof functionsOptions & {
23
- getGlobalOptions?: () => GlobalOptions;
24
- };
25
-
26
- /** Warning logged when deploy discovery loads the kit before `defaultOptions` reached `setGlobalOptions`. */
27
- export const DEFAULT_OPTIONS_MISSING_WARNING =
28
- "firestore-bigquery-export: no global cpu was set when the kit loaded, so its functions " +
29
- "deploy at the 2nd gen defaults (1 vCPU, concurrency 80) instead of the extension's 0.1666 vCPU. " +
30
- "Spread defaultOptions from @firebase-function-kits/firestore-bigquery-export/default-options " +
31
- "into setGlobalOptions before the kit is imported. In an ES module entry, call setGlobalOptions " +
32
- "in its own module and import that module first. See " +
33
- "https://github.com/firebase/extensions/tree/kits/kits/firestore-bigquery-export#concurrency-cpu-and-timeouts-match-the-extension";
34
-
35
- /**
36
- * Logs {@link DEFAULT_OPTIONS_MISSING_WARNING} during deploy discovery when the
37
- * codebase's global options set no `cpu`, which means `defaultOptions` was not
38
- * applied before the kit's functions were defined.
39
- */
40
- export function warnIfDefaultOptionsMissing(): void {
41
- // The Firebase CLI sets FUNCTIONS_CONTROL_API only in the discovery process.
42
- if (process.env.FUNCTIONS_CONTROL_API !== "true" || !getGlobalOptions) {
43
- return;
44
- }
45
- if (getGlobalOptions().cpu === undefined) {
46
- warn(DEFAULT_OPTIONS_MISSING_WARNING);
47
- }
48
- }
@@ -1,181 +0,0 @@
1
- /**
2
- * Copyright 2026 Google LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * https://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
- import { setGlobalOptions, type GlobalOptions } from "firebase-functions";
18
- import { warn } from "firebase-functions/logger";
19
- import * as v2Options from "firebase-functions/options";
20
- import { afterEach, describe, expect, test, vi } from "vitest";
21
-
22
- // Each entry load registers the lifecycle hooks again, which the SDK allows only once per process.
23
- vi.mock("firebase-functions/v2/lifecycle", () => ({
24
- afterFirstDeploy: vi.fn(),
25
- afterRedeploy: vi.fn(),
26
- }));
27
- vi.mock("firebase-functions/logger", async (importOriginal) => ({
28
- ...(await importOriginal<typeof import("firebase-functions/logger")>()),
29
- warn: vi.fn(),
30
- }));
31
-
32
- const FUNCTION_NAMES = [
33
- "fsexportbigquery",
34
- "syncBigQuery",
35
- "initBigQuerySync",
36
- "setupBigQuerySync",
37
- ] as const;
38
-
39
- type FunctionName = (typeof FUNCTION_NAMES)[number];
40
- type Endpoint = Record<string, unknown>;
41
-
42
- /** `clearGlobalOptions` ships at runtime but is marked internal, so it is absent from the typings. */
43
- const { clearGlobalOptions } = v2Options as unknown as {
44
- clearGlobalOptions: () => void;
45
- };
46
-
47
- afterEach(() => {
48
- clearGlobalOptions();
49
- vi.unstubAllEnvs();
50
- vi.mocked(warn).mockClear();
51
- });
52
-
53
- /** Loads the entry after the wrapper's `setGlobalOptions` call and returns each function's deploy endpoint. */
54
- async function loadEndpoints(
55
- globals?: GlobalOptions
56
- ): Promise<Record<FunctionName, Endpoint>> {
57
- vi.resetModules();
58
- vi.stubEnv("DATABASE_REGION", "");
59
- if (globals) {
60
- setGlobalOptions(globals);
61
- }
62
- const index: Record<string, unknown> = await import("../src/index");
63
- const endpoints = {} as Record<FunctionName, Endpoint>;
64
- for (const name of FUNCTION_NAMES) {
65
- const fn = index[name] as { __endpoint: Endpoint };
66
- expect(fn?.__endpoint, name).toBeDefined();
67
- endpoints[name] = fn.__endpoint;
68
- }
69
- return endpoints;
70
- }
71
-
72
- /** Asserts the endpoint leaves `key` to the platform default: absent, or the SDK's reset marker. */
73
- function expectPlatformDefault(
74
- endpoint: Endpoint,
75
- key: string,
76
- label?: string
77
- ): void {
78
- const value = endpoint[key];
79
- if (value !== undefined) {
80
- expect(value, label).toBeInstanceOf(v2Options.RESET_VALUE.constructor);
81
- }
82
- }
83
-
84
- async function loadDefaultOptions() {
85
- vi.resetModules();
86
- const { defaultOptions } = await import("../src/default-options");
87
- return defaultOptions;
88
- }
89
-
90
- describe("defaultOptions", () => {
91
- test("holds the extension's runtime shape", async () => {
92
- expect(await loadDefaultOptions()).toEqual({
93
- cpu: "gcf_gen1",
94
- concurrency: 1,
95
- maxInstances: 100,
96
- });
97
- });
98
-
99
- test("imports without side effects when the entry would reject its params", async () => {
100
- vi.stubEnv("DATASET_ID", "");
101
- await expect(loadDefaultOptions()).resolves.toBeDefined();
102
- vi.resetModules();
103
- await expect(import("../src/index")).rejects.toThrow("DATASET_ID");
104
- });
105
-
106
- test("as the globals, gives every function 0.1666 vCPU and concurrency 1", async () => {
107
- const endpoints = await loadEndpoints(await loadDefaultOptions());
108
- for (const name of FUNCTION_NAMES) {
109
- expect(endpoints[name].cpu, name).toBe("gcf_gen1");
110
- expect(endpoints[name].concurrency, name).toBe(1);
111
- }
112
- expect(endpoints.fsexportbigquery.maxInstances).toBe(100);
113
- expect(endpoints.initBigQuerySync.maxInstances).toBe(100);
114
- expect(endpoints.setupBigQuerySync.maxInstances).toBe(100);
115
- expect(endpoints.syncBigQuery.maxInstances).toBe(500);
116
- });
117
-
118
- test("keys after the spread override the defaults, except syncBigQuery's instance cap", async () => {
119
- const endpoints = await loadEndpoints({
120
- ...(await loadDefaultOptions()),
121
- maxInstances: 5,
122
- cpu: 1,
123
- });
124
- expect(endpoints.fsexportbigquery.maxInstances).toBe(5);
125
- expect(endpoints.fsexportbigquery.cpu).toBe(1);
126
- expect(endpoints.syncBigQuery.maxInstances).toBe(500);
127
- expect(endpoints.syncBigQuery.cpu).toBe(1);
128
- });
129
-
130
- test("per-function ingress and timeout survive the globals", async () => {
131
- const endpoints = await loadEndpoints(await loadDefaultOptions());
132
- expect(endpoints.fsexportbigquery.ingressSettings).toBe(
133
- "ALLOW_INTERNAL_ONLY"
134
- );
135
- expectPlatformDefault(endpoints.fsexportbigquery, "timeoutSeconds");
136
- for (const name of FUNCTION_NAMES.slice(1)) {
137
- expectPlatformDefault(endpoints[name], "ingressSettings", name);
138
- expect(endpoints[name].timeoutSeconds, name).toBe(540);
139
- }
140
- });
141
-
142
- test("without the globals, every function falls back to the platform cpu and concurrency", async () => {
143
- const endpoints = await loadEndpoints();
144
- for (const name of FUNCTION_NAMES) {
145
- expectPlatformDefault(endpoints[name], "cpu", name);
146
- expectPlatformDefault(endpoints[name], "concurrency", name);
147
- }
148
- expectPlatformDefault(endpoints.fsexportbigquery, "maxInstances");
149
- expect(endpoints.syncBigQuery.maxInstances).toBe(500);
150
- });
151
-
152
- test("a key set to undefined after the spread drops that default", async () => {
153
- const endpoints = await loadEndpoints({
154
- ...(await loadDefaultOptions()),
155
- maxInstances: undefined,
156
- });
157
- expectPlatformDefault(endpoints.fsexportbigquery, "maxInstances");
158
- expect(endpoints.fsexportbigquery.cpu).toBe("gcf_gen1");
159
- });
160
- });
161
-
162
- describe("missing defaultOptions warning", () => {
163
- test("warns during deploy discovery when no global cpu is set", async () => {
164
- vi.stubEnv("FUNCTIONS_CONTROL_API", "true");
165
- await loadEndpoints();
166
- expect(warn).toHaveBeenCalledOnce();
167
- expect(vi.mocked(warn).mock.calls[0][0]).toContain("defaultOptions");
168
- });
169
-
170
- test("stays silent during deploy discovery when defaultOptions is applied", async () => {
171
- vi.stubEnv("FUNCTIONS_CONTROL_API", "true");
172
- await loadEndpoints(await loadDefaultOptions());
173
- expect(warn).not.toHaveBeenCalled();
174
- });
175
-
176
- test("stays silent outside deploy discovery", async () => {
177
- vi.stubEnv("FUNCTIONS_CONTROL_API", undefined);
178
- await loadEndpoints();
179
- expect(warn).not.toHaveBeenCalled();
180
- });
181
- });