@firebase-function-kits/firestore-bigquery-export 0.0.2-rc.12 → 0.0.2-rc.13

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/lib/index.js CHANGED
@@ -79,6 +79,7 @@ const init_1 = require("./init");
79
79
  const logs = __importStar(require("./logs"));
80
80
  const region_1 = require("./region");
81
81
  const tasks_2 = require("./tasks");
82
+ (0, config_1.assertRequiredParams)();
82
83
  // Re-export the side-effect-free library surface (handlers and config types).
83
84
  __exportStar(require("./lib"), exports);
84
85
  const INIT_BIGQUERY_SYNC_FUNCTION = "initBigQuerySync";
@@ -116,6 +117,10 @@ const REQUIRED_APIS = [
116
117
  api: "bigquery.googleapis.com",
117
118
  reason: "Mirrors data from your Cloud Firestore collection in BigQuery.",
118
119
  },
120
+ {
121
+ api: "eventarcpublishing.googleapis.com",
122
+ reason: "Publishes the extension's custom events to its Eventarc channel.",
123
+ },
119
124
  ];
120
125
  for (const role of REQUIRED_ROLES) {
121
126
  (0, v2_1.requiresRole)(role);
@@ -153,8 +158,9 @@ function getHandlerContext() {
153
158
  }
154
159
  /*
155
160
  * Read at module load: the CLI populates `.env` values into the discovery
156
- * process env (firebase-tools >= 15.28.0), and the region option cannot be a
157
- * param expression. When unset, no function declares a region and the CLI
161
+ * process env (firebase-tools >= 15.28.0), and the location to Cloud Run region
162
+ * lookup needs a nested ternary the CLI's CEL subset cannot express. When
163
+ * unset, no function declares a region and the CLI
158
164
  * falls back to its default. The Eventarc trigger region needs no handling:
159
165
  * the CLI pins it to the database's own region regardless of where the
160
166
  * function runs.
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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,sBAAsB,CAC1C;KACJ;CACF,EACD,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,iCAAsB,EAAC,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;IACE,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACrD,WAAW,EAAE,sBAAsB;CACpC,EACD,gCAAgC,CACjC,CAAC;AAEF;;;GAGG;AACU,QAAA,iBAAiB,GAAG,IAAA,wBAAgB,EAC/C;IACE,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACrD,WAAW,EAAE,sBAAsB;CACpC,EACD,gCAAgC,CACjC,CAAC"}
package/lib/region.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * Maps a Firestore database location to the Cloud Run region the functions
3
- * should deploy to. Regional locations pass through unchanged; an unset or
4
- * empty location returns `undefined`, meaning the functions declare no region.
3
+ * should deploy to. The lookup is case-insensitive and ignores surrounding
4
+ * whitespace, as the CLI's own region handling is. Regional locations pass
5
+ * through lowercased; an unset or blank location returns `undefined`, meaning
6
+ * the functions declare no region.
5
7
  */
6
8
  export declare function firestoreLocationToFunctionRegion(location: string | undefined): string | undefined;
7
9
  //# sourceMappingURL=region.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"region.d.ts","sourceRoot":"","sources":["../src/region.ts"],"names":[],"mappings":"AAwBA;;;;GAIG;AACH,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC3B,MAAM,GAAG,SAAS,CAKpB"}
1
+ {"version":3,"file":"region.d.ts","sourceRoot":"","sources":["../src/region.ts"],"names":[],"mappings":"AAwBA;;;;;;GAMG;AACH,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC3B,MAAM,GAAG,SAAS,CAMpB"}
package/lib/region.js CHANGED
@@ -25,13 +25,16 @@ const MULTI_REGION_TO_FUNCTION_REGION = {
25
25
  };
26
26
  /**
27
27
  * Maps a Firestore database location to the Cloud Run region the functions
28
- * should deploy to. Regional locations pass through unchanged; an unset or
29
- * empty location returns `undefined`, meaning the functions declare no region.
28
+ * should deploy to. The lookup is case-insensitive and ignores surrounding
29
+ * whitespace, as the CLI's own region handling is. Regional locations pass
30
+ * through lowercased; an unset or blank location returns `undefined`, meaning
31
+ * the functions declare no region.
30
32
  */
31
33
  function firestoreLocationToFunctionRegion(location) {
32
- if (!location) {
34
+ const normalized = location?.trim().toLowerCase();
35
+ if (!normalized) {
33
36
  return undefined;
34
37
  }
35
- return MULTI_REGION_TO_FUNCTION_REGION[location] ?? location;
38
+ return MULTI_REGION_TO_FUNCTION_REGION[normalized] ?? normalized;
36
39
  }
37
40
  //# sourceMappingURL=region.js.map
package/lib/region.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"region.js","sourceRoot":"","sources":["../src/region.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAeH,8EAOC;AApBD,0EAA0E;AAC1E,+EAA+E;AAC/E,MAAM,+BAA+B,GAA2B;IAC9D,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,cAAc;CACrB,CAAC;AAEF;;;;GAIG;AACH,SAAgB,iCAAiC,CAC/C,QAA4B;IAE5B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,+BAA+B,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC;AAC/D,CAAC"}
1
+ {"version":3,"file":"region.js","sourceRoot":"","sources":["../src/region.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAiBH,8EAQC;AAvBD,0EAA0E;AAC1E,+EAA+E;AAC/E,MAAM,+BAA+B,GAA2B;IAC9D,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,cAAc;CACrB,CAAC;AAEF;;;;;;GAMG;AACH,SAAgB,iCAAiC,CAC/C,QAA4B;IAE5B,MAAM,UAAU,GAAG,QAAQ,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAClD,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,+BAA+B,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC;AACnE,CAAC"}
@@ -1,32 +1,28 @@
1
1
  {
2
2
  "name": "@firebase-function-kits/firestore-bigquery-export",
3
- "version": "0.0.2-rc.12",
3
+ "version": "0.0.2-rc.13",
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.12",
9
+ "version": "0.0.2-rc.13",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "@firebaseextensions/firestore-bigquery-change-tracker": "^2.2.1",
13
13
  "@google-cloud/bigquery": "^7.6.0",
14
+ "firebase-admin": "^14.4.0",
15
+ "firebase-functions": "^7.4.0",
14
16
  "generate-schema": "^2.6.0",
15
17
  "lodash": "^4.17.14"
16
18
  },
17
19
  "devDependencies": {
18
20
  "@types/lodash": "^4.17.0",
19
- "firebase-admin": "^14.4.0",
20
- "firebase-functions": "^7.3.3-rc.3",
21
21
  "typescript": "^5.9.3",
22
22
  "vitest": "^3.2.4"
23
23
  },
24
24
  "engines": {
25
25
  "node": ">=22"
26
- },
27
- "peerDependencies": {
28
- "firebase-admin": "^14.3.0",
29
- "firebase-functions": "^7.3.3-rc.3"
30
26
  }
31
27
  },
32
28
  "node_modules/@esbuild/aix-ppc64": {
@@ -610,6 +606,42 @@
610
606
  "node": ">=18"
611
607
  }
612
608
  },
609
+ "node_modules/@firebaseextensions/firestore-bigquery-change-tracker/node_modules/firebase-functions": {
610
+ "version": "7.3.2",
611
+ "resolved": "https://registry.npmjs.org/firebase-functions/-/firebase-functions-7.3.2.tgz",
612
+ "integrity": "sha512-DTa5CtCNxFE1gPjkjlhl5uh8AcNWXLKORAMRenfkecP8zGstbje+r2TaNh4Ehdxp0qTPvTUe/sS23VESW32Gbg==",
613
+ "license": "MIT",
614
+ "dependencies": {
615
+ "@types/cors": "^2.8.5",
616
+ "@types/express": "^5.0.0",
617
+ "cors": "^2.8.5",
618
+ "express": "^5.2.1",
619
+ "protobufjs": "^7.2.2"
620
+ },
621
+ "bin": {
622
+ "firebase-functions": "lib/bin/firebase-functions.js"
623
+ },
624
+ "engines": {
625
+ "node": ">=18.0.0"
626
+ },
627
+ "peerDependencies": {
628
+ "@apollo/server": "^5.2.0",
629
+ "@as-integrations/express4": "^1.1.2",
630
+ "firebase-admin": "^11.10.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
631
+ "graphql": "^16.12.0"
632
+ },
633
+ "peerDependenciesMeta": {
634
+ "@apollo/server": {
635
+ "optional": true
636
+ },
637
+ "@as-integrations/express4": {
638
+ "optional": true
639
+ },
640
+ "graphql": {
641
+ "optional": true
642
+ }
643
+ }
644
+ },
613
645
  "node_modules/@google-cloud/bigquery": {
614
646
  "version": "7.9.4",
615
647
  "resolved": "https://registry.npmjs.org/@google-cloud/bigquery/-/bigquery-7.9.4.tgz",
@@ -1417,9 +1449,6 @@
1417
1449
  "x64"
1418
1450
  ],
1419
1451
  "dev": true,
1420
- "libc": [
1421
- "glibc"
1422
- ],
1423
1452
  "license": "MIT",
1424
1453
  "optional": true,
1425
1454
  "os": [
@@ -1611,9 +1640,6 @@
1611
1640
  "arm"
1612
1641
  ],
1613
1642
  "dev": true,
1614
- "libc": [
1615
- "glibc"
1616
- ],
1617
1643
  "license": "MIT",
1618
1644
  "optional": true,
1619
1645
  "os": [
@@ -1628,9 +1654,6 @@
1628
1654
  "arm"
1629
1655
  ],
1630
1656
  "dev": true,
1631
- "libc": [
1632
- "musl"
1633
- ],
1634
1657
  "license": "MIT",
1635
1658
  "optional": true,
1636
1659
  "os": [
@@ -1645,9 +1668,6 @@
1645
1668
  "arm64"
1646
1669
  ],
1647
1670
  "dev": true,
1648
- "libc": [
1649
- "glibc"
1650
- ],
1651
1671
  "license": "MIT",
1652
1672
  "optional": true,
1653
1673
  "os": [
@@ -1662,9 +1682,6 @@
1662
1682
  "arm64"
1663
1683
  ],
1664
1684
  "dev": true,
1665
- "libc": [
1666
- "musl"
1667
- ],
1668
1685
  "license": "MIT",
1669
1686
  "optional": true,
1670
1687
  "os": [
@@ -1679,9 +1696,6 @@
1679
1696
  "loong64"
1680
1697
  ],
1681
1698
  "dev": true,
1682
- "libc": [
1683
- "glibc"
1684
- ],
1685
1699
  "license": "MIT",
1686
1700
  "optional": true,
1687
1701
  "os": [
@@ -1696,9 +1710,6 @@
1696
1710
  "loong64"
1697
1711
  ],
1698
1712
  "dev": true,
1699
- "libc": [
1700
- "musl"
1701
- ],
1702
1713
  "license": "MIT",
1703
1714
  "optional": true,
1704
1715
  "os": [
@@ -1713,9 +1724,6 @@
1713
1724
  "ppc64"
1714
1725
  ],
1715
1726
  "dev": true,
1716
- "libc": [
1717
- "glibc"
1718
- ],
1719
1727
  "license": "MIT",
1720
1728
  "optional": true,
1721
1729
  "os": [
@@ -1730,9 +1738,6 @@
1730
1738
  "ppc64"
1731
1739
  ],
1732
1740
  "dev": true,
1733
- "libc": [
1734
- "musl"
1735
- ],
1736
1741
  "license": "MIT",
1737
1742
  "optional": true,
1738
1743
  "os": [
@@ -1747,9 +1752,6 @@
1747
1752
  "riscv64"
1748
1753
  ],
1749
1754
  "dev": true,
1750
- "libc": [
1751
- "glibc"
1752
- ],
1753
1755
  "license": "MIT",
1754
1756
  "optional": true,
1755
1757
  "os": [
@@ -1764,9 +1766,6 @@
1764
1766
  "riscv64"
1765
1767
  ],
1766
1768
  "dev": true,
1767
- "libc": [
1768
- "musl"
1769
- ],
1770
1769
  "license": "MIT",
1771
1770
  "optional": true,
1772
1771
  "os": [
@@ -1781,9 +1780,6 @@
1781
1780
  "s390x"
1782
1781
  ],
1783
1782
  "dev": true,
1784
- "libc": [
1785
- "glibc"
1786
- ],
1787
1783
  "license": "MIT",
1788
1784
  "optional": true,
1789
1785
  "os": [
@@ -1798,9 +1794,6 @@
1798
1794
  "x64"
1799
1795
  ],
1800
1796
  "dev": true,
1801
- "libc": [
1802
- "glibc"
1803
- ],
1804
1797
  "license": "MIT",
1805
1798
  "optional": true,
1806
1799
  "os": [
@@ -1815,9 +1808,6 @@
1815
1808
  "x64"
1816
1809
  ],
1817
1810
  "dev": true,
1818
- "libc": [
1819
- "musl"
1820
- ],
1821
1811
  "license": "MIT",
1822
1812
  "optional": true,
1823
1813
  "os": [
@@ -3420,10 +3410,9 @@
3420
3410
  }
3421
3411
  },
3422
3412
  "node_modules/firebase-functions": {
3423
- "version": "7.3.3-rc.3",
3424
- "resolved": "https://registry.npmjs.org/firebase-functions/-/firebase-functions-7.3.3-rc.3.tgz",
3425
- "integrity": "sha512-ZSk85ExZSIgRaKZiTD2Z8Q4dU6KIeIVfwYT75PWC4KlaEgnoAyH6l4fmbP2IeAV3K8WQpLP9A5uTJIKMzeqL8A==",
3426
- "license": "MIT",
3413
+ "version": "7.4.0",
3414
+ "resolved": "https://registry.npmjs.org/firebase-functions/-/firebase-functions-7.4.0.tgz",
3415
+ "integrity": "sha512-jR+c16q1E07dPVqU/sdbIEVEQJYSxjY6BFI+QR5/AvrnII8C6UkJv6fR8LJ+GKmcGUBe7SjO/MnEWLAeOiHWMw==",
3427
3416
  "dependencies": {
3428
3417
  "@types/cors": "^2.8.5",
3429
3418
  "@types/express": "^5.0.0",
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.12",
3
+ "version": "0.0.2-rc.13",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/firebase/extensions.git",
@@ -33,6 +33,8 @@
33
33
  "dependencies": {
34
34
  "@firebaseextensions/firestore-bigquery-change-tracker": "^2.2.1",
35
35
  "@google-cloud/bigquery": "^7.6.0",
36
+ "firebase-admin": "^14.4.0",
37
+ "firebase-functions": "^7.4.0",
36
38
  "generate-schema": "^2.6.0",
37
39
  "lodash": "^4.17.14"
38
40
  },
@@ -43,13 +45,7 @@
43
45
  },
44
46
  "devDependencies": {
45
47
  "@types/lodash": "^4.17.0",
46
- "firebase-admin": "^14.4.0",
47
- "firebase-functions": "^7.3.3-rc.3",
48
48
  "typescript": "^5.9.3",
49
49
  "vitest": "^3.2.4"
50
- },
51
- "peerDependencies": {
52
- "firebase-admin": "^14.3.0",
53
- "firebase-functions": "^7.3.3-rc.3"
54
50
  }
55
51
  }
package/src/config.ts CHANGED
@@ -129,8 +129,9 @@ const params = {
129
129
  input: { text: { example: "(default)" } },
130
130
  }),
131
131
  // Declared so the CLI prompts for the value and persists it to `.env`; the
132
- // function region option cannot be a param expression, so the entry point
133
- // reads the same variable from `process.env` at module load instead.
132
+ // location to Cloud Run region lookup needs a nested ternary the CLI's CEL
133
+ // subset cannot express, so the entry point reads the same variable from
134
+ // `process.env` at module load instead.
134
135
  databaseRegion: defineString("DATABASE_REGION", {
135
136
  label: "Firestore Instance Location",
136
137
  description:
@@ -705,3 +706,46 @@ export function configFromEnv(): ExportConfig {
705
706
  maxEnqueueAttempts: optionalInt(params.maxEnqueueAttempts),
706
707
  };
707
708
  }
709
+
710
+ // Params the published extension marks `required: true`. A value the user never
711
+ // supplied is absent from process.env; one they deliberately blanked is present
712
+ // and empty. Only the second is a misconfiguration, so the guard below reads
713
+ // process.env rather than `.value()`, which reports both as "".
714
+ // DATABASE_REGION is `required: true` upstream but deliberately omitted here:
715
+ // an explicit empty value is a supported setting that leaves the function
716
+ // without a declared region, so the CLI resolves one at deploy time.
717
+ const REQUIRED_PARAMS = [
718
+ "DATASET_LOCATION",
719
+ "BIGQUERY_PROJECT_ID",
720
+ "DATABASE",
721
+ "COLLECTION_PATH",
722
+ "DATASET_ID",
723
+ "TABLE_ID",
724
+ "VIEW_TYPE",
725
+ "USE_NEW_SNAPSHOT_QUERY_SYNTAX",
726
+ "LOG_LEVEL",
727
+ ] as const;
728
+
729
+ /**
730
+ * Rejects required params that were explicitly set to an empty value.
731
+ *
732
+ * `.env` values bypass the CLI's prompt-time validation and take precedence
733
+ * over a param's declared default, so an empty entry otherwise reaches the
734
+ * handlers silently. Called at module scope so deploy-time discovery fails
735
+ * before the function ships, rather than on the first event.
736
+ */
737
+ export function assertRequiredParams(
738
+ names: ReadonlyArray<string> = REQUIRED_PARAMS
739
+ ): void {
740
+ const blank = names.filter((name) => {
741
+ const raw = process.env[name];
742
+ return raw !== undefined && raw.trim() === "";
743
+ });
744
+
745
+ if (blank.length > 0) {
746
+ throw new Error(
747
+ `Required parameters are set to an empty value: ${blank.join(", ")}. ` +
748
+ "Set them in your .env file, or remove the entries to use their defaults."
749
+ );
750
+ }
751
+ }
package/src/events.ts CHANGED
@@ -14,6 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import * as eventArc from "firebase-admin/eventarc";
17
+ import { logger } from "firebase-functions";
17
18
 
18
19
  const { getEventarc } = eventArc;
19
20
 
@@ -50,21 +51,35 @@ export const setupEventChannel = () => {
50
51
  : undefined;
51
52
  };
52
53
 
54
+ /**
55
+ * Publishes an event, logging and swallowing any failure.
56
+ *
57
+ * A deleted or unreachable Eventarc channel must not fail the invocation: the
58
+ * BigQuery export is the contract, event delivery is best effort.
59
+ */
60
+ const publish = async (event: eventArc.CloudEvent): Promise<void> => {
61
+ if (!eventChannel) return;
62
+
63
+ try {
64
+ await eventChannel.publish(event);
65
+ } catch (err) {
66
+ logger.warn(`Failed to publish Eventarc event ${event.type}`, err);
67
+ }
68
+ };
69
+
53
70
  /**
54
71
  * Publishes a "start" event using both OLD and NEW event types.
55
72
  *
56
73
  * @param data The payload to send with the event. Can be a string or an object.
57
- * @returns A Promise resolving when both events are published.
74
+ * @returns A Promise resolving once both publishes have been attempted.
58
75
  */
59
76
  export const recordStartEvent = async (data: string | object) => {
60
- if (!eventChannel) return Promise.resolve();
61
-
62
77
  const eventTypes = getEventTypes("onStart");
63
78
 
64
79
  // Publish events for both OLD and NEW event types
65
- return Promise.all(
80
+ await Promise.all(
66
81
  eventTypes.map((type) =>
67
- eventChannel.publish({
82
+ publish({
68
83
  type,
69
84
  data,
70
85
  })
@@ -77,17 +92,15 @@ export const recordStartEvent = async (data: string | object) => {
77
92
  *
78
93
  * @param err The Error object containing the error message.
79
94
  * @param subject (Optional) Subject identifier related to the error event.
80
- * @returns A Promise resolving when both events are published.
95
+ * @returns A Promise resolving once both publishes have been attempted.
81
96
  */
82
97
  export const recordErrorEvent = async (err: Error, subject?: string) => {
83
- if (!eventChannel) return Promise.resolve();
84
-
85
98
  const eventTypes = getEventTypes("onError");
86
99
 
87
100
  // Publish events for both OLD and NEW event types
88
- return Promise.all(
101
+ await Promise.all(
89
102
  eventTypes.map((type) =>
90
- eventChannel.publish({
103
+ publish({
91
104
  type,
92
105
  data: { message: err.message },
93
106
  subject,
@@ -102,7 +115,7 @@ export const recordErrorEvent = async (err: Error, subject?: string) => {
102
115
  * @param params An object containing the subject and the event data.
103
116
  * @param params.subject A string representing the subject of the event.
104
117
  * @param params.data The payload to send with the event.
105
- * @returns A Promise resolving when both events are published.
118
+ * @returns A Promise resolving once both publishes have been attempted.
106
119
  */
107
120
  export const recordSuccessEvent = async ({
108
121
  subject,
@@ -111,14 +124,12 @@ export const recordSuccessEvent = async ({
111
124
  subject: string;
112
125
  data: string | object;
113
126
  }) => {
114
- if (!eventChannel) return Promise.resolve();
115
-
116
127
  const eventTypes = getEventTypes("onSuccess");
117
128
 
118
129
  // Publish events for both OLD and NEW event types
119
- return Promise.all(
130
+ await Promise.all(
120
131
  eventTypes.map((type) =>
121
- eventChannel.publish({
132
+ publish({
122
133
  type,
123
134
  subject,
124
135
  data,
@@ -131,17 +142,15 @@ export const recordSuccessEvent = async ({
131
142
  * Publishes a "completion" event using both OLD and NEW event types.
132
143
  *
133
144
  * @param data The payload to send with the event. Can be a string or an object.
134
- * @returns A Promise resolving when both events are published.
145
+ * @returns A Promise resolving once both publishes have been attempted.
135
146
  */
136
147
  export const recordCompletionEvent = async (data: string | object) => {
137
- if (!eventChannel) return Promise.resolve();
138
-
139
148
  const eventTypes = getEventTypes("onCompletion");
140
149
 
141
150
  // Publish events for both OLD and NEW event types
142
- return Promise.all(
151
+ await Promise.all(
143
152
  eventTypes.map((type) =>
144
- eventChannel.publish({
153
+ publish({
145
154
  type,
146
155
  data,
147
156
  })
package/src/handlers.ts CHANGED
@@ -111,8 +111,6 @@ async function enqueueForSync(
111
111
  try {
112
112
  await ctx.enqueue(change);
113
113
  } catch (enqueueErr) {
114
- // Log before publishing: the log line is the only trace of the dropped
115
- // row, and the event publish can itself reject.
116
114
  logs.logFailedEventAction(
117
115
  "Failed to enqueue event to Cloud Tasks from onWrite handler",
118
116
  change.fullResourceName,
@@ -183,18 +181,13 @@ export async function handleDocumentWrite(
183
181
  throw err;
184
182
  }
185
183
 
186
- try {
187
- await events.recordStartEvent({
188
- documentId,
189
- changeType,
190
- before: { data: data.before.data() },
191
- after: { data: data.after.data() },
192
- context,
193
- });
194
- } catch (err) {
195
- logs.error(false, "Failed to record start event", err);
196
- throw err;
197
- }
184
+ await events.recordStartEvent({
185
+ documentId,
186
+ changeType,
187
+ before: { data: data.before.data() },
188
+ after: { data: data.after.data() },
189
+ context,
190
+ });
198
191
 
199
192
  const change: SerializedDocumentChange = {
200
193
  timestamp: context.time,
@@ -256,25 +249,19 @@ export async function handleSyncBigQueryTask(
256
249
  throw err;
257
250
  }
258
251
 
259
- try {
260
- await events.recordSuccessEvent({
261
- subject: change.documentId,
262
- data: {
263
- timestamp: change.timestamp,
264
- operation: change.changeType,
265
- documentName: change.fullResourceName,
266
- documentId: change.documentId,
267
- pathParams: change.params,
268
- eventId: change.eventId,
269
- data: change.data,
270
- oldData: change.oldData,
271
- },
272
- });
273
- } catch (err) {
274
- // The row is already in BigQuery. Rethrowing would have Cloud Tasks retry
275
- // the insert past the dedupe window and duplicate it.
276
- logs.error(false, "Failed to record success event", err as Error);
277
- }
252
+ await events.recordSuccessEvent({
253
+ subject: change.documentId,
254
+ data: {
255
+ timestamp: change.timestamp,
256
+ operation: change.changeType,
257
+ documentName: change.fullResourceName,
258
+ documentId: change.documentId,
259
+ pathParams: change.params,
260
+ eventId: change.eventId,
261
+ data: change.data,
262
+ oldData: change.oldData,
263
+ },
264
+ });
278
265
 
279
266
  logs.complete();
280
267
  }
package/src/index.ts CHANGED
@@ -38,7 +38,11 @@ import {
38
38
  afterFirstDeploy,
39
39
  afterRedeploy,
40
40
  } from "firebase-functions/v2/lifecycle";
41
- import { CONFIG_EXPRESSIONS, configFromEnv } from "./config";
41
+ import {
42
+ assertRequiredParams,
43
+ CONFIG_EXPRESSIONS,
44
+ configFromEnv,
45
+ } from "./config";
42
46
  import * as events from "./events";
43
47
  import {
44
48
  DEFAULT_MAX_DISPATCHES_PER_SECOND,
@@ -56,6 +60,7 @@ import * as logs from "./logs";
56
60
  import { firestoreLocationToFunctionRegion } from "./region";
57
61
  import { enqueueSyncTask } from "./tasks";
58
62
 
63
+ assertRequiredParams();
59
64
  // Re-export the side-effect-free library surface (handlers and config types).
60
65
  export * from "./lib";
61
66
 
@@ -94,6 +99,10 @@ const REQUIRED_APIS = [
94
99
  api: "bigquery.googleapis.com",
95
100
  reason: "Mirrors data from your Cloud Firestore collection in BigQuery.",
96
101
  },
102
+ {
103
+ api: "eventarcpublishing.googleapis.com",
104
+ reason: "Publishes the extension's custom events to its Eventarc channel.",
105
+ },
97
106
  ] as const;
98
107
 
99
108
  for (const role of REQUIRED_ROLES) {
@@ -147,8 +156,9 @@ function getHandlerContext(): HandlerContext {
147
156
 
148
157
  /*
149
158
  * Read at module load: the CLI populates `.env` values into the discovery
150
- * process env (firebase-tools >= 15.28.0), and the region option cannot be a
151
- * param expression. When unset, no function declares a region and the CLI
159
+ * process env (firebase-tools >= 15.28.0), and the location to Cloud Run region
160
+ * lookup needs a nested ternary the CLI's CEL subset cannot express. When
161
+ * unset, no function declares a region and the CLI
152
162
  * falls back to its default. The Eventarc trigger region needs no handling:
153
163
  * the CLI pins it to the database's own region regardless of where the
154
164
  * function runs.
package/src/region.ts CHANGED
@@ -24,14 +24,17 @@ const MULTI_REGION_TO_FUNCTION_REGION: Record<string, string> = {
24
24
 
25
25
  /**
26
26
  * Maps a Firestore database location to the Cloud Run region the functions
27
- * should deploy to. Regional locations pass through unchanged; an unset or
28
- * empty location returns `undefined`, meaning the functions declare no region.
27
+ * should deploy to. The lookup is case-insensitive and ignores surrounding
28
+ * whitespace, as the CLI's own region handling is. Regional locations pass
29
+ * through lowercased; an unset or blank location returns `undefined`, meaning
30
+ * the functions declare no region.
29
31
  */
30
32
  export function firestoreLocationToFunctionRegion(
31
33
  location: string | undefined
32
34
  ): string | undefined {
33
- if (!location) {
35
+ const normalized = location?.trim().toLowerCase();
36
+ if (!normalized) {
34
37
  return undefined;
35
38
  }
36
- return MULTI_REGION_TO_FUNCTION_REGION[location] ?? location;
39
+ return MULTI_REGION_TO_FUNCTION_REGION[normalized] ?? normalized;
37
40
  }