@firebase-function-kits/firestore-bigquery-export 0.0.1 → 0.0.2-rc.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/README.md +234 -0
  3. package/lib/config.d.ts +33 -0
  4. package/lib/config.d.ts.map +1 -0
  5. package/lib/config.js +345 -0
  6. package/lib/config.js.map +1 -0
  7. package/lib/events.d.ts +45 -0
  8. package/lib/events.d.ts.map +1 -0
  9. package/lib/events.js +154 -0
  10. package/lib/events.js.map +1 -0
  11. package/lib/export-config.d.ts +96 -0
  12. package/lib/export-config.d.ts.map +1 -0
  13. package/lib/export-config.js +77 -0
  14. package/lib/export-config.js.map +1 -0
  15. package/lib/handlers.d.ts +29 -0
  16. package/lib/handlers.d.ts.map +1 -0
  17. package/lib/handlers.js +165 -0
  18. package/lib/handlers.js.map +1 -0
  19. package/lib/index.d.ts +23 -0
  20. package/lib/index.d.ts.map +1 -0
  21. package/lib/index.js +179 -0
  22. package/lib/index.js.map +1 -0
  23. package/lib/init.d.ts +16 -0
  24. package/lib/init.d.ts.map +1 -0
  25. package/lib/init.js +44 -0
  26. package/lib/init.js.map +1 -0
  27. package/lib/lib.d.ts +20 -0
  28. package/lib/lib.d.ts.map +1 -0
  29. package/lib/lib.js +47 -0
  30. package/lib/lib.js.map +1 -0
  31. package/lib/logs.d.ts +39 -0
  32. package/lib/logs.d.ts.map +1 -0
  33. package/lib/logs.js +186 -0
  34. package/lib/logs.js.map +1 -0
  35. package/lib/util.d.ts +23 -0
  36. package/lib/util.d.ts.map +1 -0
  37. package/lib/util.js +66 -0
  38. package/lib/util.js.map +1 -0
  39. package/package.json +33 -3
  40. package/src/config.ts +420 -0
  41. package/src/events.ts +146 -0
  42. package/src/export-config.ts +205 -0
  43. package/src/handlers.ts +211 -0
  44. package/src/index.ts +174 -0
  45. package/src/init.ts +45 -0
  46. package/src/lib.ts +55 -0
  47. package/src/logs.ts +233 -0
  48. package/src/util.ts +64 -0
  49. package/tests/config.test.ts +182 -0
  50. package/tests/events.test.ts +84 -0
  51. package/tests/export-config.test.ts +114 -0
  52. package/tests/handlers.test.ts +220 -0
  53. package/tests/init.test.ts +76 -0
  54. package/tests/util.test.ts +102 -0
  55. package/tsconfig.json +18 -0
  56. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AA+BA;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,YAM7B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,SAAgB,MAAM,GAAG,MAAM,2BAc3D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,QAAe,KAAK,YAAY,MAAM,2BAelE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,uBAG5B;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,2BAeA,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,SAAgB,MAAM,GAAG,MAAM,2BAchE,CAAC"}
package/lib/events.js ADDED
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.recordCompletionEvent = exports.recordSuccessEvent = exports.recordErrorEvent = exports.recordStartEvent = exports.setupEventChannel = void 0;
37
+ /*
38
+ * Copyright 2019 Google LLC
39
+ *
40
+ * Licensed under the Apache License, Version 2.0 (the "License");
41
+ * you may not use this file except in compliance with the License.
42
+ * You may obtain a copy of the License at
43
+ *
44
+ * https://www.apache.org/licenses/LICENSE-2.0
45
+ *
46
+ * Unless required by applicable law or agreed to in writing, software
47
+ * distributed under the License is distributed on an "AS IS" BASIS,
48
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
49
+ * See the License for the specific language governing permissions and
50
+ * limitations under the License.
51
+ */
52
+ const eventArc = __importStar(require("firebase-admin/eventarc"));
53
+ const { getEventarc } = eventArc;
54
+ /**
55
+ * Builds the Eventarc event type for this extension.
56
+ *
57
+ * @param eventName The name of the event (e.g., "onStart", "onError", etc.)
58
+ * @returns The event type string.
59
+ */
60
+ const getEventTypes = (eventName) => [
61
+ `firebase.extensions.firestore-bigquery-export.v1.${eventName}`,
62
+ ];
63
+ let eventChannel;
64
+ /**
65
+ * Sets up the Eventarc channel.
66
+ *
67
+ * This function retrieves the Eventarc channel based on the environment variables:
68
+ * - `EVENTARC_CHANNEL` specifies the channel to use for publishing events.
69
+ * - `EXT_SELECTED_EVENTS` defines the allowed event types.
70
+ *
71
+ * @function setupEventChannel
72
+ */
73
+ const setupEventChannel = () => {
74
+ eventChannel = process.env.EVENTARC_CHANNEL
75
+ ? getEventarc().channel(process.env.EVENTARC_CHANNEL, {
76
+ allowedEventTypes: process.env.EXT_SELECTED_EVENTS,
77
+ })
78
+ : undefined;
79
+ };
80
+ exports.setupEventChannel = setupEventChannel;
81
+ /**
82
+ * Publishes a "start" event using both OLD and NEW event types.
83
+ *
84
+ * @param data The payload to send with the event. Can be a string or an object.
85
+ * @returns A Promise resolving when both events are published.
86
+ */
87
+ const recordStartEvent = async (data) => {
88
+ if (!eventChannel)
89
+ return Promise.resolve();
90
+ const eventTypes = getEventTypes("onStart");
91
+ // Publish events for both OLD and NEW event types
92
+ return Promise.all(eventTypes.map((type) => eventChannel.publish({
93
+ type,
94
+ data,
95
+ })));
96
+ };
97
+ exports.recordStartEvent = recordStartEvent;
98
+ /**
99
+ * Publishes an "error" event using both OLD and NEW event types.
100
+ *
101
+ * @param err The Error object containing the error message.
102
+ * @param subject (Optional) Subject identifier related to the error event.
103
+ * @returns A Promise resolving when both events are published.
104
+ */
105
+ const recordErrorEvent = async (err, subject) => {
106
+ if (!eventChannel)
107
+ return Promise.resolve();
108
+ const eventTypes = getEventTypes("onError");
109
+ // Publish events for both OLD and NEW event types
110
+ return Promise.all(eventTypes.map((type) => eventChannel.publish({
111
+ type,
112
+ data: { message: err.message },
113
+ subject,
114
+ })));
115
+ };
116
+ exports.recordErrorEvent = recordErrorEvent;
117
+ /**
118
+ * Publishes a "success" event using both OLD and NEW event types.
119
+ *
120
+ * @param params An object containing the subject and the event data.
121
+ * @param params.subject A string representing the subject of the event.
122
+ * @param params.data The payload to send with the event.
123
+ * @returns A Promise resolving when both events are published.
124
+ */
125
+ const recordSuccessEvent = async ({ subject, data, }) => {
126
+ if (!eventChannel)
127
+ return Promise.resolve();
128
+ const eventTypes = getEventTypes("onSuccess");
129
+ // Publish events for both OLD and NEW event types
130
+ return Promise.all(eventTypes.map((type) => eventChannel.publish({
131
+ type,
132
+ subject,
133
+ data,
134
+ })));
135
+ };
136
+ exports.recordSuccessEvent = recordSuccessEvent;
137
+ /**
138
+ * Publishes a "completion" event using both OLD and NEW event types.
139
+ *
140
+ * @param data The payload to send with the event. Can be a string or an object.
141
+ * @returns A Promise resolving when both events are published.
142
+ */
143
+ const recordCompletionEvent = async (data) => {
144
+ if (!eventChannel)
145
+ return Promise.resolve();
146
+ const eventTypes = getEventTypes("onCompletion");
147
+ // Publish events for both OLD and NEW event types
148
+ return Promise.all(eventTypes.map((type) => eventChannel.publish({
149
+ type,
150
+ data,
151
+ })));
152
+ };
153
+ exports.recordCompletionEvent = recordCompletionEvent;
154
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAY,QAAQ,oDAAgC;AAEpD,MAAM,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC;IAC3C,oDAAoD,SAAS,EAAE;CAChE,CAAC;AAEF,IAAI,YAA0C,CAAC;AAE/C;;;;;;;;GAQG;AACI,MAAM,iBAAiB,GAAG,GAAG,EAAE;IACpC,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB;QACzC,CAAC,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE;YAClD,iBAAiB,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB;SACnD,CAAC;QACJ,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC,CAAC;AANW,QAAA,iBAAiB,GAAjB,iBAAiB,CAM5B;AAEF;;;;;GAKG;AACI,MAAM,gBAAgB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CACtB,YAAY,CAAC,OAAO,CAAC;QACnB,IAAI;QACJ,OAAO;QACP,IAAI;KACL,CAAC,CACH,CACF,CAAC;AACJ,CAAC,CAAC;AArBW,QAAA,kBAAkB,GAAlB,kBAAkB,CAqB7B;AAEF;;;;;GAKG;AACI,MAAM,qBAAqB,GAAG,KAAK,EAAE,IAAqB,EAAE,EAAE;IACnE,IAAI,CAAC,YAAY;QAAE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAE5C,MAAM,UAAU,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;IAEjD,kDAAkD;IAClD,OAAO,OAAO,CAAC,GAAG,CAChB,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACtB,YAAY,CAAC,OAAO,CAAC;QACnB,IAAI;QACJ,IAAI;KACL,CAAC,CACH,CACF,CAAC;AACJ,CAAC,CAAC;AAdW,QAAA,qBAAqB,GAArB,qBAAqB,CAchC"}
@@ -0,0 +1,96 @@
1
+ import type { ChangeTrackerConfig, LogLevel } from "@firebaseextensions/firestore-bigquery-change-tracker";
2
+ import type { Expression } from "firebase-functions/params";
3
+ type TrackerLogLevel = "debug" | "info" | "warn" | "error" | "silent";
4
+ type ConfigValue<T extends string | number | boolean | string[]> = T | Expression<T>;
5
+ /** How the BigQuery changelog view is materialized. */
6
+ export type ViewType = "view" | "materialized_incremental" | "materialized_non_incremental";
7
+ /**
8
+ * The export configuration. The main entry point builds it from deploy-time
9
+ * params; handler consumers can construct it directly.
10
+ *
11
+ * `collectionPath`, `datasetId`, `tableId`, `location`, and `projectId` are
12
+ * required; everything else has a sensible default.
13
+ */
14
+ export interface ExportConfig {
15
+ /** Firestore collection (or collection group) path to mirror, e.g. `users`
16
+ * or `regions/{regionId}/users`. */
17
+ collectionPath: ConfigValue<string>;
18
+ /** BigQuery dataset id to write into. */
19
+ datasetId: ConfigValue<string>;
20
+ /** BigQuery changelog table id. */
21
+ tableId: ConfigValue<string>;
22
+ /** Region for the trigger and task queue. */
23
+ location: ConfigValue<string>;
24
+ /** BigQuery dataset location, e.g. `us`, `eu`. Defaults to `us`. */
25
+ datasetLocation?: ConfigValue<string>;
26
+ /** Project that owns the BigQuery dataset, if different from the function's
27
+ * project. */
28
+ bqProjectId?: ConfigValue<string>;
29
+ /** GCP project id. */
30
+ projectId: ConfigValue<string>;
31
+ /** Firestore database id. Defaults to `(default)`. */
32
+ databaseId?: ConfigValue<string>;
33
+ /** Include path-param values as columns. Defaults to `false`. */
34
+ wildcardIds?: ConfigValue<boolean>;
35
+ /** Skip writing the previous document state on updates. Defaults to `false`. */
36
+ excludeOldData?: ConfigValue<boolean>;
37
+ /** Use the newer snapshot view query syntax. Defaults to `false`. */
38
+ useNewSnapshotQuerySyntax?: ConfigValue<boolean>;
39
+ /** Changelog view strategy. Defaults to `view`. */
40
+ viewType?: ConfigValue<ViewType>;
41
+ /** Partitioning strategy for the changelog table. */
42
+ partitioning?: ChangeTrackerConfig["partitioning"];
43
+ /** Clustering columns (max 4). */
44
+ clustering?: string[] | null;
45
+ /** Materialized-view max staleness interval, e.g. `0-0 0 4:0:0`. */
46
+ maxStaleness?: ConfigValue<string>;
47
+ /** Incremental materialized-view refresh interval in minutes. */
48
+ refreshIntervalMinutes?: ConfigValue<number>;
49
+ /** Collection id used for the changelog backup table. */
50
+ backupCollectionId?: ConfigValue<string>;
51
+ /** Name of a transform function to apply before writing. */
52
+ transformFunction?: ConfigValue<string>;
53
+ /** Customer-managed encryption key for the dataset. */
54
+ kmsKeyName?: ConfigValue<string>;
55
+ /** Log verbosity. Defaults to `info`. */
56
+ logLevel?: ConfigValue<TrackerLogLevel | LogLevel>;
57
+ }
58
+ /** {@link ExportConfig} with all defaults applied. */
59
+ export interface ResolvedExportConfig {
60
+ collectionPath: string;
61
+ datasetId: string;
62
+ tableId: string;
63
+ location: string;
64
+ datasetLocation: string;
65
+ bqProjectId?: string;
66
+ projectId: string;
67
+ databaseId: string;
68
+ wildcardIds: boolean;
69
+ excludeOldData: boolean;
70
+ useNewSnapshotQuerySyntax: boolean;
71
+ viewType: ViewType;
72
+ partitioning?: ChangeTrackerConfig["partitioning"];
73
+ clustering: string[] | null;
74
+ maxStaleness?: string;
75
+ refreshIntervalMinutes?: number;
76
+ backupCollectionId?: string;
77
+ transformFunction?: string;
78
+ kmsKeyName?: string;
79
+ logLevel: TrackerLogLevel;
80
+ }
81
+ /**
82
+ * Applies defaults to an {@link ExportConfig}.
83
+ *
84
+ * @param config - The user-supplied configuration.
85
+ * @returns The configuration with every field populated.
86
+ */
87
+ export declare function resolveExportConfig(config: ExportConfig): ResolvedExportConfig;
88
+ /**
89
+ * Maps a resolved export config onto the change-tracker's config shape.
90
+ *
91
+ * @param config - The resolved export configuration.
92
+ * @returns The {@link ChangeTrackerConfig} for the event history tracker.
93
+ */
94
+ export declare function toTrackerConfig(config: ResolvedExportConfig): ChangeTrackerConfig;
95
+ export {};
96
+ //# sourceMappingURL=export-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-config.d.ts","sourceRoot":"","sources":["../src/export-config.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACV,mBAAmB,EACnB,QAAQ,EACT,MAAM,uDAAuD,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,KAAK,eAAe,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AACtE,KAAK,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,IAC3D,CAAC,GACD,UAAU,CAAC,CAAC,CAAC,CAAC;AAElB,uDAAuD;AACvD,MAAM,MAAM,QAAQ,GAChB,MAAM,GACN,0BAA0B,GAC1B,8BAA8B,CAAC;AAEnC;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B;yCACqC;IACrC,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,yCAAyC;IAC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;IACzC,QAAQ,CAAC,EAAE,WAAW,CAAC,eAAe,GAAG,QAAQ,CAAC,CAAC;CACpD;AAED,sDAAsD;AACtD,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC;IACxB,yBAAyB,EAAE,OAAO,CAAC;IACnC,QAAQ,EAAE,QAAQ,CAAC;IACnB,YAAY,CAAC,EAAE,mBAAmB,CAAC,cAAc,CAAC,CAAC;IACnD,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,eAAe,CAAC;CAC3B;AAoBD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,YAAY,GACnB,oBAAoB,CA8BtB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,oBAAoB,GAC3B,mBAAmB,CAyBrB"}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveExportConfig = resolveExportConfig;
4
+ exports.toTrackerConfig = toTrackerConfig;
5
+ function isExpression(value) {
6
+ return typeof value === "object" && value !== null && "value" in value;
7
+ }
8
+ function resolveConfigValue(value) {
9
+ return isExpression(value) ? value.value() : value;
10
+ }
11
+ function resolveOptionalConfigValue(value) {
12
+ return value === undefined ? undefined : resolveConfigValue(value);
13
+ }
14
+ /**
15
+ * Applies defaults to an {@link ExportConfig}.
16
+ *
17
+ * @param config - The user-supplied configuration.
18
+ * @returns The configuration with every field populated.
19
+ */
20
+ function resolveExportConfig(config) {
21
+ const projectId = resolveConfigValue(config.projectId);
22
+ const viewType = resolveOptionalConfigValue(config.viewType);
23
+ const logLevel = resolveOptionalConfigValue(config.logLevel);
24
+ return {
25
+ collectionPath: resolveConfigValue(config.collectionPath),
26
+ datasetId: resolveConfigValue(config.datasetId),
27
+ tableId: resolveConfigValue(config.tableId),
28
+ location: resolveConfigValue(config.location),
29
+ datasetLocation: resolveOptionalConfigValue(config.datasetLocation) ?? "us",
30
+ bqProjectId: resolveOptionalConfigValue(config.bqProjectId),
31
+ projectId,
32
+ databaseId: resolveOptionalConfigValue(config.databaseId) ?? "(default)",
33
+ wildcardIds: resolveOptionalConfigValue(config.wildcardIds) ?? false,
34
+ excludeOldData: resolveOptionalConfigValue(config.excludeOldData) ?? false,
35
+ useNewSnapshotQuerySyntax: resolveOptionalConfigValue(config.useNewSnapshotQuerySyntax) ?? false,
36
+ viewType: viewType ?? "view",
37
+ partitioning: config.partitioning,
38
+ clustering: config.clustering ?? null,
39
+ maxStaleness: resolveOptionalConfigValue(config.maxStaleness),
40
+ refreshIntervalMinutes: resolveOptionalConfigValue(config.refreshIntervalMinutes),
41
+ backupCollectionId: resolveOptionalConfigValue(config.backupCollectionId),
42
+ transformFunction: resolveOptionalConfigValue(config.transformFunction),
43
+ kmsKeyName: resolveOptionalConfigValue(config.kmsKeyName),
44
+ logLevel: logLevel ?? "info",
45
+ };
46
+ }
47
+ /**
48
+ * Maps a resolved export config onto the change-tracker's config shape.
49
+ *
50
+ * @param config - The resolved export configuration.
51
+ * @returns The {@link ChangeTrackerConfig} for the event history tracker.
52
+ */
53
+ function toTrackerConfig(config) {
54
+ return {
55
+ firestoreInstanceId: config.databaseId,
56
+ tableId: config.tableId,
57
+ datasetId: config.datasetId,
58
+ datasetLocation: config.datasetLocation,
59
+ backupTableId: config.backupCollectionId,
60
+ transformFunction: config.transformFunction,
61
+ partitioning: config.partitioning,
62
+ databaseId: config.databaseId,
63
+ clustering: config.clustering,
64
+ wildcardIds: config.wildcardIds,
65
+ bqProjectId: config.bqProjectId ?? config.projectId,
66
+ useNewSnapshotQuerySyntax: config.useNewSnapshotQuerySyntax,
67
+ skipInit: true,
68
+ kmsKeyName: config.kmsKeyName,
69
+ useMaterializedView: config.viewType === "materialized_incremental" ||
70
+ config.viewType === "materialized_non_incremental",
71
+ useIncrementalMaterializedView: config.viewType === "materialized_incremental",
72
+ maxStaleness: config.maxStaleness,
73
+ refreshIntervalMinutes: config.refreshIntervalMinutes,
74
+ logLevel: config.logLevel,
75
+ };
76
+ }
77
+ //# sourceMappingURL=export-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-config.js","sourceRoot":"","sources":["../src/export-config.ts"],"names":[],"mappings":";;;;AAiHA,SAAS,YAAY,CACnB,KAAqB;IAErB,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,CAAC;AACzE,CAAC;AAED,SAAS,kBAAkB,CACzB,KAAqB;IAErB,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AACrD,CAAC;AAED,SAAS,0BAA0B,CAEjC,KAAiC;IACjC,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;AACrE,CAAC;AAED;;;;;GAKG;AACH,6BACE,MAAoB;IAEpB,MAAM,SAAS,GAAG,kBAAkB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,0BAA0B,CAAC,MAAM,CAAC,QAAQ,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AAED;;;;;GAKG;AACH,yBACE,MAA4B;IAE5B,OAAO;QACL,mBAAmB,EAAE,MAAM,CAAC,UAAU;QACtC,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,aAAa,EAAE,MAAM,CAAC,kBAAkB;QACxC,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,SAAS;QACnD,yBAAyB,EAAE,MAAM,CAAC,yBAAyB;QAC3D,QAAQ,EAAE,IAAI;QACd,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,mBAAmB,EACjB,MAAM,CAAC,QAAQ,KAAK,0BAA0B;YAC9C,MAAM,CAAC,QAAQ,KAAK,8BAA8B;QACpD,8BAA8B,EAC5B,MAAM,CAAC,QAAQ,KAAK,0BAA0B;QAChD,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,sBAAsB,EAAE,MAAM,CAAC,sBAAsB;QACrD,QAAQ,EAAE,MAAM,CAAC,QAAQ;KAC1B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { type FirestoreBigQueryEventHistoryTracker } from "@firebaseextensions/firestore-bigquery-change-tracker";
2
+ import type { Change, DocumentSnapshot, FirestoreEvent } from "firebase-functions/firestore";
3
+ import type { ResolvedExportConfig } from "./export-config";
4
+ /** The Firestore document-write event passed to {@link handleDocumentWrite}. */
5
+ export type DocumentWriteEvent = FirestoreEvent<Change<DocumentSnapshot> | undefined, Record<string, string>>;
6
+ /**
7
+ * Everything a handler needs to do its work, injected by the caller so the
8
+ * handlers stay free of global state.
9
+ */
10
+ export interface HandlerContext {
11
+ tracker: FirestoreBigQueryEventHistoryTracker;
12
+ config: ResolvedExportConfig;
13
+ /**
14
+ * Provisions the BigQuery dataset/table/views once per instance. Only called
15
+ * after an inline write failure as a self-heal; the hot path relies on
16
+ * out-of-band provisioning (`initBigQuerySync` / `setupBigQuerySync`).
17
+ */
18
+ ensureInitialized: () => Promise<void>;
19
+ }
20
+ /**
21
+ * Handles a Firestore document write: serializes the change and writes it to
22
+ * BigQuery. Failed writes are surfaced to the trigger retry policy after one
23
+ * self-heal attempt.
24
+ *
25
+ * @param event - The Firestore document-write event.
26
+ * @param ctx - The handler context.
27
+ */
28
+ export declare function handleDocumentWrite(event: DocumentWriteEvent, ctx: HandlerContext): Promise<void>;
29
+ //# sourceMappingURL=handlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../src/handlers.ts"],"names":[],"mappings":"AAgBA,OAAO,EAEL,KAAK,oCAAoC,EAE1C,MAAM,uDAAuD,CAAC;AAC/D,OAAO,KAAK,EACV,MAAM,EACN,gBAAgB,EAChB,cAAc,EACf,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAgB5D,gFAAgF;AAChF,MAAM,MAAM,kBAAkB,GAAG,cAAc,CAC7C,MAAM,CAAC,gBAAgB,CAAC,GAAG,SAAS,EACpC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CACvB,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,oCAAoC,CAAC;IAC9C,MAAM,EAAE,oBAAoB,CAAC;IAC7B;;;;OAIG;IACH,iBAAiB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC;AAuDD;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,kBAAkB,EACzB,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,IAAI,CAAC,CAkFf"}
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2019 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.handleDocumentWrite = handleDocumentWrite;
52
+ const firestore_bigquery_change_tracker_1 = require("@firebaseextensions/firestore-bigquery-change-tracker");
53
+ const events = __importStar(require("./events"));
54
+ const logs = __importStar(require("./logs"));
55
+ const util_1 = require("./util");
56
+ /**
57
+ * Records a Firestore document change to BigQuery.
58
+ *
59
+ * @param change - Serialized change metadata and payload.
60
+ * @param tracker - The event history tracker to write through.
61
+ */
62
+ async function recordEventToBigQuery(change, tracker) {
63
+ const event = {
64
+ timestamp: change.timestamp,
65
+ operation: change.changeType,
66
+ documentName: change.fullResourceName,
67
+ documentId: change.documentId,
68
+ pathParams: change.params,
69
+ eventId: change.eventId,
70
+ data: change.data,
71
+ oldData: change.oldData,
72
+ };
73
+ await tracker.record([event]);
74
+ }
75
+ /**
76
+ * Gives a failed inline write one self-heal attempt before surfacing it to the
77
+ * Firestore trigger retry policy.
78
+ *
79
+ * @param change - The serialized change to write.
80
+ * @param ctx - The handler context.
81
+ */
82
+ async function retryAfterSelfHeal(change, ctx) {
83
+ try {
84
+ await ctx.ensureInitialized();
85
+ await recordEventToBigQuery(change, ctx.tracker);
86
+ }
87
+ catch (retryErr) {
88
+ await events.recordErrorEvent(retryErr);
89
+ logs.logFailedEventAction("Failed to write event to BigQuery from onWrite handler after self-heal", change.fullResourceName, change.eventId, change.changeType, retryErr);
90
+ throw retryErr;
91
+ }
92
+ }
93
+ /**
94
+ * Handles a Firestore document write: serializes the change and writes it to
95
+ * BigQuery. Failed writes are surfaced to the trigger retry policy after one
96
+ * self-heal attempt.
97
+ *
98
+ * @param event - The Firestore document-write event.
99
+ * @param ctx - The handler context.
100
+ */
101
+ async function handleDocumentWrite(event, ctx) {
102
+ const { data, ...context } = event;
103
+ if (!data)
104
+ return;
105
+ logs.start();
106
+ // No provisioning on the hot path: BigQuery resources are provisioned
107
+ // out-of-band (afterFirstDeploy / afterRedeploy tasks). If they are missing,
108
+ // the inline write fails, self-heals once, then falls back to the trigger
109
+ // retry policy.
110
+ const { config, tracker } = ctx;
111
+ const changeType = (0, util_1.getChangeType)(data);
112
+ const documentId = (0, util_1.getDocumentId)(data);
113
+ const isCreated = changeType === firestore_bigquery_change_tracker_1.ChangeType.CREATE;
114
+ const isDeleted = changeType === firestore_bigquery_change_tracker_1.ChangeType.DELETE;
115
+ const newData = isDeleted ? undefined : data.after.data();
116
+ const oldData = isCreated || config.excludeOldData ? undefined : data.before.data();
117
+ const relativeName = context.document;
118
+ const projectId = config.projectId;
119
+ const fullResourceName = `projects/${projectId}/databases/${config.databaseId}/documents/${relativeName}`;
120
+ const eventId = context.id;
121
+ const operation = changeType;
122
+ logs.logEventAction("Firestore event received by onDocumentWritten trigger", fullResourceName, eventId, operation);
123
+ let serializedData;
124
+ let serializedOldData;
125
+ try {
126
+ serializedData = tracker.serializeData(newData);
127
+ serializedOldData = tracker.serializeData(oldData);
128
+ }
129
+ catch (err) {
130
+ logs.logFailedEventAction("Failed to serialize data", fullResourceName, eventId, operation, err);
131
+ throw err;
132
+ }
133
+ try {
134
+ await events.recordStartEvent({
135
+ documentId,
136
+ changeType,
137
+ before: { data: data.before.data() },
138
+ after: { data: data.after.data() },
139
+ context,
140
+ });
141
+ }
142
+ catch (err) {
143
+ logs.error(false, "Failed to record start event", err);
144
+ throw err;
145
+ }
146
+ const change = {
147
+ timestamp: context.time,
148
+ eventId: context.id,
149
+ fullResourceName,
150
+ changeType,
151
+ documentId,
152
+ params: config.wildcardIds ? { ...context.params, documentId } : null,
153
+ data: serializedData,
154
+ oldData: serializedOldData,
155
+ };
156
+ try {
157
+ await recordEventToBigQuery(change, tracker);
158
+ }
159
+ catch (err) {
160
+ logs.failedToWriteToBigQueryImmediately(err);
161
+ await retryAfterSelfHeal(change, ctx);
162
+ }
163
+ logs.complete();
164
+ }
165
+ //# sourceMappingURL=handlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.js","sourceRoot":"","sources":["../src/handlers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;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23 @@
1
+ export * from "./lib";
2
+ /**
3
+ * Firestore trigger: streams document writes on the watched collection into the
4
+ * BigQuery changelog table. Failed executions are retried by the Firebase
5
+ * Functions runtime.
6
+ */
7
+ export declare const fsexportbigquery: import("firebase-functions/core").CloudFunction<import("firebase-functions/firestore").FirestoreEvent<import("firebase-functions/firestore").Change<import("firebase-functions/firestore").DocumentSnapshot>, Record<string, string>>>;
8
+ /**
9
+ * First-deploy provisioning task (`afterFirstDeploy`). Runs in the function's
10
+ * own identity, so it has the runtime service account and bound secrets that
11
+ * creating the dataset/table/views needs (e.g. CMEK). Cloud Tasks retries a
12
+ * failed initialization on its own schedule, so a transient BigQuery error does
13
+ * not leave the resources unprovisioned. It is idempotent (`initialize()`
14
+ * no-ops when resources already exist) and can also be invoked directly as an
15
+ * authenticated HTTP POST, without queue retries.
16
+ */
17
+ export declare const initBigQuerySync: import("firebase-functions/tasks").TaskQueueFunction<any>;
18
+ /**
19
+ * Update/configure lifecycle task. Uses the same idempotent provisioning path
20
+ * so BigQuery resources are reconciled after parameter changes.
21
+ */
22
+ export declare const setupBigQuerySync: import("firebase-functions/tasks").TaskQueueFunction<any>;
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAgDA,cAAc,OAAO,CAAC;AA0EtB;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,wOAQ5B,CAAC;AAWF;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,2DAM5B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,2DAM7B,CAAC"}