@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.
- package/CHANGELOG.md +1 -0
- package/README.md +234 -0
- package/lib/config.d.ts +33 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +345 -0
- package/lib/config.js.map +1 -0
- package/lib/events.d.ts +45 -0
- package/lib/events.d.ts.map +1 -0
- package/lib/events.js +154 -0
- package/lib/events.js.map +1 -0
- package/lib/export-config.d.ts +96 -0
- package/lib/export-config.d.ts.map +1 -0
- package/lib/export-config.js +77 -0
- package/lib/export-config.js.map +1 -0
- package/lib/handlers.d.ts +29 -0
- package/lib/handlers.d.ts.map +1 -0
- package/lib/handlers.js +165 -0
- package/lib/handlers.js.map +1 -0
- package/lib/index.d.ts +23 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +179 -0
- package/lib/index.js.map +1 -0
- package/lib/init.d.ts +16 -0
- package/lib/init.d.ts.map +1 -0
- package/lib/init.js +44 -0
- package/lib/init.js.map +1 -0
- package/lib/lib.d.ts +20 -0
- package/lib/lib.d.ts.map +1 -0
- package/lib/lib.js +47 -0
- package/lib/lib.js.map +1 -0
- package/lib/logs.d.ts +39 -0
- package/lib/logs.d.ts.map +1 -0
- package/lib/logs.js +186 -0
- package/lib/logs.js.map +1 -0
- package/lib/util.d.ts +23 -0
- package/lib/util.d.ts.map +1 -0
- package/lib/util.js +66 -0
- package/lib/util.js.map +1 -0
- package/package.json +33 -3
- package/src/config.ts +420 -0
- package/src/events.ts +146 -0
- package/src/export-config.ts +205 -0
- package/src/handlers.ts +211 -0
- package/src/index.ts +174 -0
- package/src/init.ts +45 -0
- package/src/lib.ts +55 -0
- package/src/logs.ts +233 -0
- package/src/util.ts +64 -0
- package/tests/config.test.ts +182 -0
- package/tests/events.test.ts +84 -0
- package/tests/export-config.test.ts +114 -0
- package/tests/handlers.test.ts +220 -0
- package/tests/init.test.ts +76 -0
- package/tests/util.test.ts +102 -0
- package/tsconfig.json +18 -0
- package/tsconfig.tsbuildinfo +1 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
- Initial release
|
package/README.md
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# @firebase/firestore-bigquery-export
|
|
2
|
+
|
|
3
|
+
Stream a Cloud Firestore collection to BigQuery. This is the Stream Firestore to
|
|
4
|
+
BigQuery Firebase Extension as an npm package you add to your own Firebase
|
|
5
|
+
Functions codebase and deploy.
|
|
6
|
+
|
|
7
|
+
It listens for document writes on a collection, serializes each change, and
|
|
8
|
+
writes it to a BigQuery changelog table. Failed writes are retried through a
|
|
9
|
+
Firebase Functions runtime retry policy. The functions run in your own Firebase
|
|
10
|
+
project; there is no hosted version, so you deploy them yourself.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm install @firebase/firestore-bigquery-export
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Required IAM
|
|
19
|
+
|
|
20
|
+
Deploy needs these Google Cloud roles and APIs for the function's service
|
|
21
|
+
account. Firebase CLI 15.23.0 or later creates that account, grants the roles
|
|
22
|
+
below, enables the listed APIs, and attaches the account to every function in
|
|
23
|
+
this kit. Do not set a custom runtime service account for this codebase — it
|
|
24
|
+
conflicts with that automatic setup.
|
|
25
|
+
|
|
26
|
+
| Role / API | Why |
|
|
27
|
+
|---|---|
|
|
28
|
+
| `roles/bigquery.dataEditor` | create dataset/table/views; insert rows |
|
|
29
|
+
| `roles/bigquery.user` | run BigQuery jobs and materialized views |
|
|
30
|
+
| `roles/datastore.user` | write failed-row records back to Firestore (only if you configure a backup collection) |
|
|
31
|
+
| `roles/eventarc.eventReceiver` | receive Gen2 Firestore trigger events |
|
|
32
|
+
| `roles/run.invoker` | allow Eventarc to invoke the Gen2 Cloud Run service |
|
|
33
|
+
| `bigquery.googleapis.com` | mirror Firestore collection changes in BigQuery |
|
|
34
|
+
|
|
35
|
+
If the dataset lives in a different project (`BIGQUERY_PROJECT_ID`), grant the
|
|
36
|
+
managed runtime service account the `bigquery.*` roles on that project. For a
|
|
37
|
+
CMEK dataset, also grant the BigQuery service account access to your KMS key.
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
Export the three functions from your functions codebase entry:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
// functions/src/index.ts
|
|
45
|
+
export {
|
|
46
|
+
fsexportbigquery,
|
|
47
|
+
initBigQuerySync,
|
|
48
|
+
setupBigQuerySync,
|
|
49
|
+
} from "@firebase/firestore-bigquery-export";
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
and configure them with a `.env` (or `.env.<projectId>`):
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
COLLECTION_PATH=users
|
|
56
|
+
DATASET_ID=analytics
|
|
57
|
+
TABLE_ID=users
|
|
58
|
+
DATABASE_REGION=europe-west2
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
- `fsexportbigquery` is the Firestore trigger.
|
|
62
|
+
- `initBigQuerySync` is the first-deploy provisioning lifecycle task.
|
|
63
|
+
- `setupBigQuerySync` is the reconfigure provisioning lifecycle task.
|
|
64
|
+
|
|
65
|
+
Importing the package without exporting its functions deploys nothing — the CLI
|
|
66
|
+
only deploys what your entry file exports.
|
|
67
|
+
|
|
68
|
+
## Deploy
|
|
69
|
+
|
|
70
|
+
The package's `firebase.json` declares a `kit` stanza (Firebase CLI 15.25.1 or
|
|
71
|
+
later, behind the `kits` experiment):
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"functions": [
|
|
76
|
+
{
|
|
77
|
+
"source": ".",
|
|
78
|
+
"kit": "firestore-bigquery-export",
|
|
79
|
+
"instances": {
|
|
80
|
+
"default": "."
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`instances` maps each instance id to the directory (relative to
|
|
88
|
+
`firebase.json`) holding that instance's `.env`. The CLI prefixes every
|
|
89
|
+
function and task queue name with `kit-<instance id>-`, so the functions above
|
|
90
|
+
deploy as `kit-default-fsexportbigquery`, `kit-default-initBigQuerySync`, and
|
|
91
|
+
`kit-default-setupBigQuerySync`.
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
firebase experiments:enable kits
|
|
95
|
+
firebase deploy --only functions
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Deploy a single instance with `firebase deploy --only functions:<instance id>`.
|
|
99
|
+
|
|
100
|
+
## Configuration
|
|
101
|
+
|
|
102
|
+
Set these values in a `.env` (or `.env.<projectId>`) file. The Firebase CLI
|
|
103
|
+
loads them at deploy time and prompts for any required values that are missing.
|
|
104
|
+
`PROJECT_ID` is supplied by the Firebase CLI.
|
|
105
|
+
|
|
106
|
+
| Field | Env var | Required | Default | Description |
|
|
107
|
+
|---|---|---|---|---|
|
|
108
|
+
| `collectionPath` | `COLLECTION_PATH` | no | `posts` | Collection or collection-group path |
|
|
109
|
+
| `datasetId` | `DATASET_ID` | no | `firestore_export` | BigQuery dataset |
|
|
110
|
+
| `tableId` | `TABLE_ID` | no | `posts` | BigQuery changelog table |
|
|
111
|
+
| `databaseRegion` | `DATABASE_REGION` | yes | — | Region for the trigger and queues |
|
|
112
|
+
| `datasetLocation` | `DATASET_LOCATION` | no | `us` | BigQuery dataset location |
|
|
113
|
+
| `database` | `DATABASE` | no | `(default)` | Firestore database id |
|
|
114
|
+
| `bigqueryProjectId` | `BIGQUERY_PROJECT_ID` | no | project id | Dataset project, if different |
|
|
115
|
+
| `backupCollection` | `BACKUP_COLLECTION` | no | (empty) | Firestore collection for failed rows |
|
|
116
|
+
| `transformFunction` | `TRANSFORM_FUNCTION` | no | (empty) | Optional transform Cloud Function |
|
|
117
|
+
| `tablePartitioning` | `TABLE_PARTITIONING` | no | `NONE` | Table partitioning strategy |
|
|
118
|
+
| `timePartitioningField` | `TIME_PARTITIONING_FIELD` | no | (empty) | Time-partitioning column name |
|
|
119
|
+
| `timePartitioningFieldType` | `TIME_PARTITIONING_FIELD_TYPE` | no | `omit` | Time-partitioning field type |
|
|
120
|
+
| `timePartitioningFirestoreField` | `TIME_PARTITIONING_FIRESTORE_FIELD` | no | (empty) | Firestore field for partitioning |
|
|
121
|
+
| `clustering` | `CLUSTERING` | no | (empty) | Clustering columns (max 4) |
|
|
122
|
+
| `wildcardIds` | `WILDCARD_IDS` | no | `false` | Store path-param values as columns |
|
|
123
|
+
| `useNewSnapshotQuerySyntax` | `USE_NEW_SNAPSHOT_QUERY_SYNTAX` | no | `false` | Use newer snapshot query syntax |
|
|
124
|
+
| `excludeOldData` | `EXCLUDE_OLD_DATA` | no | `false` | Skip previous document state on updates |
|
|
125
|
+
| `viewType` | `VIEW_TYPE` | no | `view` | `view`, `materialized_incremental`, `materialized_non_incremental` |
|
|
126
|
+
| `maxStaleness` | `MAX_STALENESS` | no | (empty) | Materialized view max staleness |
|
|
127
|
+
| `refreshIntervalMinutes` | `REFRESH_INTERVAL_MINUTES` | no | (empty) | Materialized view refresh interval |
|
|
128
|
+
| `kmsKeyName` | `KMS_KEY_NAME` | no | (empty) | CMEK key for the dataset |
|
|
129
|
+
| `logLevel` | `LOG_LEVEL` | no | `info` | `debug`, `info`, `warn`, `error`, `silent` |
|
|
130
|
+
|
|
131
|
+
## Multiple instances
|
|
132
|
+
|
|
133
|
+
To export several collections, add one entry per instance to the `instances`
|
|
134
|
+
map, each pointing at its own config directory with its own `.env`:
|
|
135
|
+
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"functions": [
|
|
139
|
+
{
|
|
140
|
+
"source": ".",
|
|
141
|
+
"kit": "firestore-bigquery-export",
|
|
142
|
+
"instances": {
|
|
143
|
+
"users": "instances/users",
|
|
144
|
+
"orders": "instances/orders"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Instance ids must be unique across all kit stanzas in the project, and every
|
|
152
|
+
instance's function names are namespaced by its `kit-<instance id>-` prefix, so
|
|
153
|
+
the instances cannot collide.
|
|
154
|
+
|
|
155
|
+
## Events
|
|
156
|
+
|
|
157
|
+
When `EVENTARC_CHANNEL` is configured, the function publishes lifecycle events
|
|
158
|
+
such as `onStart`, `onError`, `onSuccess`, and `onCompletion` under
|
|
159
|
+
`firebase.extensions.firestore-bigquery-export.v1.*`.
|
|
160
|
+
|
|
161
|
+
## Provisioning
|
|
162
|
+
|
|
163
|
+
The BigQuery dataset, table, and views are created by `tracker.initialize()`
|
|
164
|
+
through the shared provisioning path used by both task functions. Both tasks
|
|
165
|
+
are idempotent and retry on transient BigQuery failures (up to 15 attempts,
|
|
166
|
+
60s minimum backoff).
|
|
167
|
+
|
|
168
|
+
Deploy wiring (declared in the package):
|
|
169
|
+
|
|
170
|
+
- First deploy runs `initBigQuerySync` automatically (`afterFirstDeploy`).
|
|
171
|
+
- Later deploys run `setupBigQuerySync` automatically (`afterRedeploy`).
|
|
172
|
+
|
|
173
|
+
`initBigQuerySync` and `setupBigQuerySync` call the same handler; they exist as
|
|
174
|
+
separate task functions so first-deploy and redeploy can target different
|
|
175
|
+
queues, matching the extension's install vs update/configure split.
|
|
176
|
+
|
|
177
|
+
If automatic post-deploy enqueue did not run, enqueue a task yourself. The
|
|
178
|
+
snippets below use the `default` instance; substitute your instance id in the
|
|
179
|
+
`kit-<instance id>-` prefix if you named yours differently. Prefer
|
|
180
|
+
`initBigQuerySync` after a first deploy and `setupBigQuerySync` after a
|
|
181
|
+
redeploy or schema-related config change (`TABLE_PARTITIONING`, `CLUSTERING`,
|
|
182
|
+
`WILDCARD_IDS`, `VIEW_TYPE`, and related fields).
|
|
183
|
+
|
|
184
|
+
```sh
|
|
185
|
+
node -e '
|
|
186
|
+
const { initializeApp } = require("firebase-admin/app");
|
|
187
|
+
const { getFunctions } = require("firebase-admin/functions");
|
|
188
|
+
initializeApp();
|
|
189
|
+
getFunctions()
|
|
190
|
+
.taskQueue("locations/'"$DATABASE_REGION"'/functions/kit-default-initBigQuerySync")
|
|
191
|
+
.enqueue({})
|
|
192
|
+
.then(() => console.log("init task enqueued"));
|
|
193
|
+
'
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Run it from your functions directory (it uses the installed `firebase-admin`)
|
|
197
|
+
with application-default credentials and `GOOGLE_CLOUD_PROJECT` set. The caller
|
|
198
|
+
needs `roles/cloudtasks.enqueuer`.
|
|
199
|
+
|
|
200
|
+
Under the hood the task queue is an authenticated HTTP endpoint, so for a quick
|
|
201
|
+
manual run you can also POST to it directly — note this skips the queue, so a
|
|
202
|
+
failure is not retried:
|
|
203
|
+
|
|
204
|
+
```sh
|
|
205
|
+
URL=$(gcloud functions describe kit-default-initBigQuerySync \
|
|
206
|
+
--region "$DATABASE_REGION" --gen2 --format='value(url)')
|
|
207
|
+
|
|
208
|
+
curl -fsS -X POST -H "Content-Type: application/json" -d '{"data":{}}' \
|
|
209
|
+
-H "Authorization: Bearer $(gcloud auth print-identity-token --audiences="$URL")" "$URL"
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
The Firestore write path never provisions on the hot path. If resources are
|
|
213
|
+
missing when a write arrives, the inline write fails, the handler calls
|
|
214
|
+
`ensureInitialized()` once as a self-heal and retries the write, and a remaining
|
|
215
|
+
failure is surfaced to the function runtime retry policy (`retry: true` on
|
|
216
|
+
`fsexportbigquery`).
|
|
217
|
+
|
|
218
|
+
## API surface
|
|
219
|
+
|
|
220
|
+
- **Main entry** (`@firebase/firestore-bigquery-export`): exports
|
|
221
|
+
`fsexportbigquery`, `initBigQuerySync`, and `setupBigQuerySync`, and
|
|
222
|
+
registers the first-deploy / redeploy provisioning hooks. Runtime config is
|
|
223
|
+
resolved lazily on first invocation. Use this entry from Firebase
|
|
224
|
+
deploy/emulator/runtime. For your own triggers, import from `./lib` instead.
|
|
225
|
+
- **Library entry** (`./lib`): `handleDocumentWrite`, the raw handler for owning
|
|
226
|
+
trigger registration yourself, plus the config types and helpers
|
|
227
|
+
(`ExportConfig`, `resolveExportConfig`, `toTrackerConfig`) for building its
|
|
228
|
+
injected `HandlerContext`. Safe to import anywhere.
|
|
229
|
+
|
|
230
|
+
The change-tracker engine is an internal dependency and is not exported.
|
|
231
|
+
|
|
232
|
+
## License
|
|
233
|
+
|
|
234
|
+
Apache-2.0
|
package/lib/config.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ChangeTrackerConfig, TimePartitioningGranularity } from "@firebaseextensions/firestore-bigquery-change-tracker";
|
|
2
|
+
import type { Expression } from "firebase-functions/params";
|
|
3
|
+
import type { ExportConfig } from "./export-config";
|
|
4
|
+
type ConfigExpression<T extends string | number | boolean> = Expression<T>;
|
|
5
|
+
export interface ConfigExpressions {
|
|
6
|
+
collectionPath: ConfigExpression<string>;
|
|
7
|
+
datasetId: ConfigExpression<string>;
|
|
8
|
+
tableId: ConfigExpression<string>;
|
|
9
|
+
location: ConfigExpression<string>;
|
|
10
|
+
database: ConfigExpression<string>;
|
|
11
|
+
}
|
|
12
|
+
export declare const CONFIG_EXPRESSIONS: ConfigExpressions;
|
|
13
|
+
export declare function clustering(clusters: string | undefined): string[];
|
|
14
|
+
export declare function buildPartitioningConfig(params: {
|
|
15
|
+
timePartitioning: TimePartitioningGranularity | null;
|
|
16
|
+
timePartitioningField: string | undefined;
|
|
17
|
+
timePartitioningFieldType: string | undefined;
|
|
18
|
+
timePartitioningFirestoreField: string | undefined;
|
|
19
|
+
}): ChangeTrackerConfig["partitioning"];
|
|
20
|
+
/**
|
|
21
|
+
* Resolves all deploy-time params into an {@link ExportConfig}.
|
|
22
|
+
*
|
|
23
|
+
* Param values are read when this is called. During the Firebase deploy-time
|
|
24
|
+
* discovery pass params return their declared defaults, so the default
|
|
25
|
+
* `TABLE_PARTITIONING=NONE` keeps {@link buildPartitioningConfig} from throwing.
|
|
26
|
+
* This is the bridge for the env-driven path: env params in, typed config out,
|
|
27
|
+
* which the main entry point wires into the exported functions.
|
|
28
|
+
*
|
|
29
|
+
* @returns The export configuration assembled from environment params.
|
|
30
|
+
*/
|
|
31
|
+
export declare function configFromEnv(): ExportConfig;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACV,mBAAmB,EAEnB,2BAA2B,EAC5B,MAAM,uDAAuD,CAAC;AAE/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAO5D,OAAO,KAAK,EAAE,YAAY,EAAY,MAAM,iBAAiB,CAAC;AAG9D,KAAK,gBAAgB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;AAkH3E,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACzC,SAAS,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACpC,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAClC,QAAQ,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACnC,QAAQ,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;CACpC;AAiED,eAAO,MAAM,kBAAkB,EAAE,iBAMhC,CAAC;AAiBF,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,YAEtD;AA4BD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE;IAC9C,gBAAgB,EAAE,2BAA2B,GAAG,IAAI,CAAC;IACrD,qBAAqB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,yBAAyB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9C,8BAA8B,EAAE,MAAM,GAAG,SAAS,CAAC;CACpD,GAAG,mBAAmB,CAAC,cAAc,CAAC,CAuEtC;AA6BD;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,IAAI,YAAY,CAiC5C"}
|
package/lib/config.js
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.CONFIG_EXPRESSIONS = void 0;
|
|
19
|
+
exports.clustering = clustering;
|
|
20
|
+
exports.buildPartitioningConfig = buildPartitioningConfig;
|
|
21
|
+
exports.configFromEnv = configFromEnv;
|
|
22
|
+
const firestore_bigquery_change_tracker_1 = require("@firebaseextensions/firestore-bigquery-change-tracker");
|
|
23
|
+
const params_1 = require("firebase-functions/params");
|
|
24
|
+
const DECIMAL_RADIX = 10;
|
|
25
|
+
const DATASET_LOCATION_OPTIONS = [
|
|
26
|
+
"us-central1",
|
|
27
|
+
"us-west4",
|
|
28
|
+
"europe-central2",
|
|
29
|
+
"us-west2",
|
|
30
|
+
"northamerica-northeast1",
|
|
31
|
+
"us-east4",
|
|
32
|
+
"us-west1",
|
|
33
|
+
"us-west3",
|
|
34
|
+
"southamerica-east1",
|
|
35
|
+
"us-east1",
|
|
36
|
+
"europe-west1",
|
|
37
|
+
"europe-north1",
|
|
38
|
+
"europe-west3",
|
|
39
|
+
"europe-west2",
|
|
40
|
+
"europe-west4",
|
|
41
|
+
"europe-west6",
|
|
42
|
+
"asia-east1",
|
|
43
|
+
"asia-east2",
|
|
44
|
+
"asia-southeast2",
|
|
45
|
+
"asia-south1",
|
|
46
|
+
"asia-southeast1",
|
|
47
|
+
"asia-northeast2",
|
|
48
|
+
"asia-northeast3",
|
|
49
|
+
"australia-southeast1",
|
|
50
|
+
"asia-northeast1",
|
|
51
|
+
"us",
|
|
52
|
+
"eu",
|
|
53
|
+
"africa-south1",
|
|
54
|
+
"me-west1",
|
|
55
|
+
"me-central1",
|
|
56
|
+
"me-central2",
|
|
57
|
+
"europe-west12",
|
|
58
|
+
"europe-north2",
|
|
59
|
+
"europe-west9",
|
|
60
|
+
"europe-west8",
|
|
61
|
+
"europe-southwest1",
|
|
62
|
+
"europe-west10",
|
|
63
|
+
"australia-southeast2",
|
|
64
|
+
"asia-south2",
|
|
65
|
+
"northamerica-northeast2",
|
|
66
|
+
"southamerica-west1",
|
|
67
|
+
"northamerica-south1",
|
|
68
|
+
"us-south1",
|
|
69
|
+
"us-east5",
|
|
70
|
+
];
|
|
71
|
+
const DATABASE_REGION_OPTIONS = [
|
|
72
|
+
"eur3",
|
|
73
|
+
"nam5",
|
|
74
|
+
"nam7",
|
|
75
|
+
"us-central1",
|
|
76
|
+
"us-west1",
|
|
77
|
+
"us-west2",
|
|
78
|
+
"us-west3",
|
|
79
|
+
"us-west4",
|
|
80
|
+
"us-east1",
|
|
81
|
+
"us-east4",
|
|
82
|
+
"us-east5",
|
|
83
|
+
"us-south1",
|
|
84
|
+
"northamerica-northeast1",
|
|
85
|
+
"northamerica-northeast2",
|
|
86
|
+
"northamerica-south1",
|
|
87
|
+
"southamerica-east1",
|
|
88
|
+
"southamerica-west1",
|
|
89
|
+
"europe-west1",
|
|
90
|
+
"europe-west2",
|
|
91
|
+
"europe-west3",
|
|
92
|
+
"europe-west4",
|
|
93
|
+
"europe-west6",
|
|
94
|
+
"europe-west8",
|
|
95
|
+
"europe-west9",
|
|
96
|
+
"europe-west10",
|
|
97
|
+
"europe-west12",
|
|
98
|
+
"europe-southwest1",
|
|
99
|
+
"europe-north1",
|
|
100
|
+
"europe-north2",
|
|
101
|
+
"europe-central2",
|
|
102
|
+
"me-central1",
|
|
103
|
+
"me-central2",
|
|
104
|
+
"me-west1",
|
|
105
|
+
"asia-south1",
|
|
106
|
+
"asia-south2",
|
|
107
|
+
"asia-southeast1",
|
|
108
|
+
"asia-southeast2",
|
|
109
|
+
"asia-east1",
|
|
110
|
+
"asia-east2",
|
|
111
|
+
"asia-northeast1",
|
|
112
|
+
"asia-northeast2",
|
|
113
|
+
"asia-northeast3",
|
|
114
|
+
"australia-southeast1",
|
|
115
|
+
"australia-southeast2",
|
|
116
|
+
"africa-south1",
|
|
117
|
+
];
|
|
118
|
+
const TABLE_PARTITIONING_OPTIONS = [
|
|
119
|
+
"HOUR",
|
|
120
|
+
"DAY",
|
|
121
|
+
"MONTH",
|
|
122
|
+
"YEAR",
|
|
123
|
+
"NONE",
|
|
124
|
+
];
|
|
125
|
+
const TIME_PARTITIONING_FIELD_TYPE_OPTIONS = [
|
|
126
|
+
"TIMESTAMP",
|
|
127
|
+
"DATETIME",
|
|
128
|
+
"DATE",
|
|
129
|
+
"omit",
|
|
130
|
+
];
|
|
131
|
+
const VIEW_TYPE_OPTIONS = [
|
|
132
|
+
"view",
|
|
133
|
+
"materialized_incremental",
|
|
134
|
+
"materialized_non_incremental",
|
|
135
|
+
];
|
|
136
|
+
const LOG_LEVEL_OPTIONS = ["debug", "info", "warn", "error", "silent"];
|
|
137
|
+
/**
|
|
138
|
+
* Deploy-time parameters. Set these via a `.env` / `.env.<project>` file or the
|
|
139
|
+
* interactive prompts shown by `firebase deploy`.
|
|
140
|
+
*
|
|
141
|
+
* @see https://firebase.google.com/docs/functions/config-env
|
|
142
|
+
*/
|
|
143
|
+
const params = {
|
|
144
|
+
bigqueryProjectId: (0, params_1.defineString)("BIGQUERY_PROJECT_ID", {
|
|
145
|
+
default: params_1.projectID,
|
|
146
|
+
}),
|
|
147
|
+
database: (0, params_1.defineString)("DATABASE", { default: "(default)" }),
|
|
148
|
+
databaseRegion: (0, params_1.defineString)("DATABASE_REGION", {
|
|
149
|
+
input: (0, params_1.select)([...DATABASE_REGION_OPTIONS]),
|
|
150
|
+
}),
|
|
151
|
+
collectionPath: (0, params_1.defineString)("COLLECTION_PATH", { default: "posts" }),
|
|
152
|
+
datasetId: (0, params_1.defineString)("DATASET_ID", { default: "firestore_export" }),
|
|
153
|
+
tableId: (0, params_1.defineString)("TABLE_ID", { default: "posts" }),
|
|
154
|
+
datasetLocation: (0, params_1.defineString)("DATASET_LOCATION", {
|
|
155
|
+
default: "us",
|
|
156
|
+
input: (0, params_1.select)([...DATASET_LOCATION_OPTIONS]),
|
|
157
|
+
}),
|
|
158
|
+
backupCollection: (0, params_1.defineString)("BACKUP_COLLECTION", { default: "" }),
|
|
159
|
+
transformFunction: (0, params_1.defineString)("TRANSFORM_FUNCTION", { default: "" }),
|
|
160
|
+
tablePartitioning: (0, params_1.defineString)("TABLE_PARTITIONING", {
|
|
161
|
+
default: "NONE",
|
|
162
|
+
input: (0, params_1.select)([...TABLE_PARTITIONING_OPTIONS]),
|
|
163
|
+
}),
|
|
164
|
+
timePartitioningField: (0, params_1.defineString)("TIME_PARTITIONING_FIELD", {
|
|
165
|
+
default: "",
|
|
166
|
+
}),
|
|
167
|
+
timePartitioningFieldType: (0, params_1.defineString)("TIME_PARTITIONING_FIELD_TYPE", {
|
|
168
|
+
default: "omit",
|
|
169
|
+
input: (0, params_1.select)([...TIME_PARTITIONING_FIELD_TYPE_OPTIONS]),
|
|
170
|
+
}),
|
|
171
|
+
timePartitioningFirestoreField: (0, params_1.defineString)("TIME_PARTITIONING_FIRESTORE_FIELD", { default: "" }),
|
|
172
|
+
clustering: (0, params_1.defineString)("CLUSTERING", { default: "" }),
|
|
173
|
+
wildcardIds: (0, params_1.defineBoolean)("WILDCARD_IDS", {
|
|
174
|
+
default: false,
|
|
175
|
+
}),
|
|
176
|
+
useNewSnapshotQuerySyntax: (0, params_1.defineBoolean)("USE_NEW_SNAPSHOT_QUERY_SYNTAX", {
|
|
177
|
+
default: false,
|
|
178
|
+
}),
|
|
179
|
+
excludeOldData: (0, params_1.defineBoolean)("EXCLUDE_OLD_DATA", {
|
|
180
|
+
default: false,
|
|
181
|
+
}),
|
|
182
|
+
viewType: (0, params_1.defineString)("VIEW_TYPE", {
|
|
183
|
+
default: "view",
|
|
184
|
+
input: (0, params_1.select)([...VIEW_TYPE_OPTIONS]),
|
|
185
|
+
}),
|
|
186
|
+
maxStaleness: (0, params_1.defineString)("MAX_STALENESS", { default: "" }),
|
|
187
|
+
refreshIntervalMinutes: (0, params_1.defineString)("REFRESH_INTERVAL_MINUTES", {
|
|
188
|
+
default: "",
|
|
189
|
+
}),
|
|
190
|
+
kmsKeyName: (0, params_1.defineString)("KMS_KEY_NAME", { default: "" }),
|
|
191
|
+
logLevel: (0, params_1.defineString)("LOG_LEVEL", {
|
|
192
|
+
default: "info",
|
|
193
|
+
input: (0, params_1.select)([...LOG_LEVEL_OPTIONS]),
|
|
194
|
+
}),
|
|
195
|
+
};
|
|
196
|
+
exports.CONFIG_EXPRESSIONS = {
|
|
197
|
+
collectionPath: params.collectionPath,
|
|
198
|
+
datasetId: params.datasetId,
|
|
199
|
+
tableId: params.tableId,
|
|
200
|
+
location: params.databaseRegion,
|
|
201
|
+
database: params.database,
|
|
202
|
+
};
|
|
203
|
+
function timePartitioning(type) {
|
|
204
|
+
if (type === "HOUR" ||
|
|
205
|
+
type === "DAY" ||
|
|
206
|
+
type === "MONTH" ||
|
|
207
|
+
type === "YEAR") {
|
|
208
|
+
return type;
|
|
209
|
+
}
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
function clustering(clusters) {
|
|
213
|
+
return clusters ? clusters.split(",").slice(0, 4) : null;
|
|
214
|
+
}
|
|
215
|
+
function normalizeOptionalPartitionValue(value) {
|
|
216
|
+
const normalized = value?.trim();
|
|
217
|
+
if (!normalized || normalized === "NONE" || normalized === "omit") {
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
return normalized;
|
|
221
|
+
}
|
|
222
|
+
function normalizePartitionFieldType(value) {
|
|
223
|
+
const normalized = normalizeOptionalPartitionValue(value);
|
|
224
|
+
if (normalized === "TIMESTAMP" ||
|
|
225
|
+
normalized === "DATE" ||
|
|
226
|
+
normalized === "DATETIME") {
|
|
227
|
+
return normalized;
|
|
228
|
+
}
|
|
229
|
+
return undefined;
|
|
230
|
+
}
|
|
231
|
+
function buildPartitioningConfig(params) {
|
|
232
|
+
const { timePartitioning } = params;
|
|
233
|
+
const rawFieldName = params.timePartitioningField?.trim();
|
|
234
|
+
const rawFieldType = params.timePartitioningFieldType?.trim();
|
|
235
|
+
const rawFirestoreField = params.timePartitioningFirestoreField?.trim();
|
|
236
|
+
const formatValue = (value) => value && value.length > 0 ? `"${value}"` : "(empty)";
|
|
237
|
+
const throwInvalidPartitioningConfig = (detail) => {
|
|
238
|
+
throw new Error([
|
|
239
|
+
"Invalid partitioning configuration for firestore-bigquery-export.",
|
|
240
|
+
detail,
|
|
241
|
+
`Received TABLE_PARTITIONING=${formatValue(timePartitioning ?? undefined)},`,
|
|
242
|
+
`TIME_PARTITIONING_FIELD=${formatValue(rawFieldName)},`,
|
|
243
|
+
`TIME_PARTITIONING_FIRESTORE_FIELD=${formatValue(rawFirestoreField)},`,
|
|
244
|
+
`TIME_PARTITIONING_FIELD_TYPE=${formatValue(rawFieldType)}.`,
|
|
245
|
+
"Valid combinations are:",
|
|
246
|
+
"1) Ingestion-time: TABLE_PARTITIONING set and all TIME_PARTITIONING_* values empty/NONE/omit.",
|
|
247
|
+
"2) Timestamp field: TABLE_PARTITIONING set, TIME_PARTITIONING_FIELD=timestamp, TIME_PARTITIONING_FIRESTORE_FIELD empty.",
|
|
248
|
+
"3) Custom field: TABLE_PARTITIONING set, and TIME_PARTITIONING_FIELD + TIME_PARTITIONING_FIRESTORE_FIELD + TIME_PARTITIONING_FIELD_TYPE all provided.",
|
|
249
|
+
].join(" "));
|
|
250
|
+
};
|
|
251
|
+
const fieldName = normalizeOptionalPartitionValue(params.timePartitioningField);
|
|
252
|
+
const fieldType = normalizePartitionFieldType(params.timePartitioningFieldType);
|
|
253
|
+
const firestoreField = normalizeOptionalPartitionValue(params.timePartitioningFirestoreField);
|
|
254
|
+
if (!timePartitioning) {
|
|
255
|
+
if (fieldName || fieldType || firestoreField) {
|
|
256
|
+
return throwInvalidPartitioningConfig("Partition-specific fields cannot be provided when TABLE_PARTITIONING is NONE.");
|
|
257
|
+
}
|
|
258
|
+
return { granularity: "NONE" };
|
|
259
|
+
}
|
|
260
|
+
if (!fieldName && !firestoreField) {
|
|
261
|
+
return { granularity: timePartitioning };
|
|
262
|
+
}
|
|
263
|
+
if (fieldName === "timestamp" && !firestoreField) {
|
|
264
|
+
return {
|
|
265
|
+
granularity: timePartitioning,
|
|
266
|
+
bigqueryColumnName: "timestamp",
|
|
267
|
+
...(fieldType ? { bigqueryColumnType: fieldType } : {}),
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
if (fieldName && firestoreField && fieldType) {
|
|
271
|
+
return {
|
|
272
|
+
granularity: timePartitioning,
|
|
273
|
+
bigqueryColumnName: fieldName,
|
|
274
|
+
bigqueryColumnType: fieldType,
|
|
275
|
+
firestoreFieldName: firestoreField,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
return throwInvalidPartitioningConfig("When TABLE_PARTITIONING is set, partitioning fields are either incomplete or invalid.");
|
|
279
|
+
}
|
|
280
|
+
function normalizeLogLevel(level) {
|
|
281
|
+
switch ((level || "").toLowerCase()) {
|
|
282
|
+
case "debug":
|
|
283
|
+
return "debug";
|
|
284
|
+
case "info":
|
|
285
|
+
return "info";
|
|
286
|
+
case "warn":
|
|
287
|
+
return "warn";
|
|
288
|
+
case "error":
|
|
289
|
+
return "error";
|
|
290
|
+
case "silent":
|
|
291
|
+
return "silent";
|
|
292
|
+
default:
|
|
293
|
+
return firestore_bigquery_change_tracker_1.LogLevel.INFO;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
function normalizePositiveInt(value) {
|
|
297
|
+
const normalized = Number.parseInt(value, DECIMAL_RADIX);
|
|
298
|
+
return normalized > 0 ? normalized : undefined;
|
|
299
|
+
}
|
|
300
|
+
/** Coerce an empty-string param value to `undefined`. */
|
|
301
|
+
function optional(value) {
|
|
302
|
+
return value.length > 0 ? value : undefined;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Resolves all deploy-time params into an {@link ExportConfig}.
|
|
306
|
+
*
|
|
307
|
+
* Param values are read when this is called. During the Firebase deploy-time
|
|
308
|
+
* discovery pass params return their declared defaults, so the default
|
|
309
|
+
* `TABLE_PARTITIONING=NONE` keeps {@link buildPartitioningConfig} from throwing.
|
|
310
|
+
* This is the bridge for the env-driven path: env params in, typed config out,
|
|
311
|
+
* which the main entry point wires into the exported functions.
|
|
312
|
+
*
|
|
313
|
+
* @returns The export configuration assembled from environment params.
|
|
314
|
+
*/
|
|
315
|
+
function configFromEnv() {
|
|
316
|
+
const tablePartitioning = optional(params.tablePartitioning.value());
|
|
317
|
+
return {
|
|
318
|
+
collectionPath: params.collectionPath.value(),
|
|
319
|
+
datasetId: params.datasetId.value(),
|
|
320
|
+
tableId: params.tableId.value(),
|
|
321
|
+
location: params.databaseRegion.value(),
|
|
322
|
+
datasetLocation: optional(params.datasetLocation.value()),
|
|
323
|
+
bqProjectId: optional(params.bigqueryProjectId.value()),
|
|
324
|
+
projectId: params_1.projectID.value(),
|
|
325
|
+
databaseId: optional(params.database.value()) || "(default)",
|
|
326
|
+
wildcardIds: params.wildcardIds.value(),
|
|
327
|
+
excludeOldData: params.excludeOldData.value(),
|
|
328
|
+
useNewSnapshotQuerySyntax: params.useNewSnapshotQuerySyntax.value(),
|
|
329
|
+
viewType: (optional(params.viewType.value()) || "view"),
|
|
330
|
+
partitioning: buildPartitioningConfig({
|
|
331
|
+
timePartitioning: timePartitioning(tablePartitioning),
|
|
332
|
+
timePartitioningField: params.timePartitioningField.value(),
|
|
333
|
+
timePartitioningFieldType: params.timePartitioningFieldType.value(),
|
|
334
|
+
timePartitioningFirestoreField: params.timePartitioningFirestoreField.value(),
|
|
335
|
+
}),
|
|
336
|
+
clustering: clustering(optional(params.clustering.value())),
|
|
337
|
+
maxStaleness: optional(params.maxStaleness.value()),
|
|
338
|
+
refreshIntervalMinutes: normalizePositiveInt(params.refreshIntervalMinutes.value()),
|
|
339
|
+
backupCollectionId: optional(params.backupCollection.value()),
|
|
340
|
+
transformFunction: optional(params.transformFunction.value()),
|
|
341
|
+
kmsKeyName: optional(params.kmsKeyName.value()),
|
|
342
|
+
logLevel: normalizeLogLevel(params.logLevel.value()),
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;AAOH,6GAAiF;AAEjF,sDAKmC;AAKnC,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,wBAAwB,GAAG;IAC/B,aAAa;IACb,UAAU;IACV,iBAAiB;IACjB,UAAU;IACV,yBAAyB;IACzB,UAAU;IACV,UAAU;IACV,UAAU;IACV,oBAAoB;IACpB,UAAU;IACV,cAAc;IACd,eAAe;IACf,cAAc;IACd,cAAc;IACd,cAAc;IACd,cAAc;IACd,YAAY;IACZ,YAAY;IACZ,iBAAiB;IACjB,aAAa;IACb,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;IACjB,sBAAsB;IACtB,iBAAiB;IACjB,IAAI;IACJ,IAAI;IACJ,eAAe;IACf,UAAU;IACV,aAAa;IACb,aAAa;IAC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sBAAsB,CAAC,KAAK,EAAE,CACtC;QACD,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAC7D,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;QAC7D,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QAC/C,QAAQ,EAAE,iBAAiB,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;KACrD,CAAC;AACJ,CAAC"}
|
package/lib/events.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets up the Eventarc channel.
|
|
3
|
+
*
|
|
4
|
+
* This function retrieves the Eventarc channel based on the environment variables:
|
|
5
|
+
* - `EVENTARC_CHANNEL` specifies the channel to use for publishing events.
|
|
6
|
+
* - `EXT_SELECTED_EVENTS` defines the allowed event types.
|
|
7
|
+
*
|
|
8
|
+
* @function setupEventChannel
|
|
9
|
+
*/
|
|
10
|
+
export declare const setupEventChannel: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* Publishes a "start" event using both OLD and NEW event types.
|
|
13
|
+
*
|
|
14
|
+
* @param data The payload to send with the event. Can be a string or an object.
|
|
15
|
+
* @returns A Promise resolving when both events are published.
|
|
16
|
+
*/
|
|
17
|
+
export declare const recordStartEvent: (data: string | object) => Promise<void | void[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Publishes an "error" event using both OLD and NEW event types.
|
|
20
|
+
*
|
|
21
|
+
* @param err The Error object containing the error message.
|
|
22
|
+
* @param subject (Optional) Subject identifier related to the error event.
|
|
23
|
+
* @returns A Promise resolving when both events are published.
|
|
24
|
+
*/
|
|
25
|
+
export declare const recordErrorEvent: (err: Error, subject?: string) => Promise<void | void[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Publishes a "success" event using both OLD and NEW event types.
|
|
28
|
+
*
|
|
29
|
+
* @param params An object containing the subject and the event data.
|
|
30
|
+
* @param params.subject A string representing the subject of the event.
|
|
31
|
+
* @param params.data The payload to send with the event.
|
|
32
|
+
* @returns A Promise resolving when both events are published.
|
|
33
|
+
*/
|
|
34
|
+
export declare const recordSuccessEvent: ({ subject, data, }: {
|
|
35
|
+
subject: string;
|
|
36
|
+
data: string | object;
|
|
37
|
+
}) => Promise<void | void[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Publishes a "completion" event using both OLD and NEW event types.
|
|
40
|
+
*
|
|
41
|
+
* @param data The payload to send with the event. Can be a string or an object.
|
|
42
|
+
* @returns A Promise resolving when both events are published.
|
|
43
|
+
*/
|
|
44
|
+
export declare const recordCompletionEvent: (data: string | object) => Promise<void | void[]>;
|
|
45
|
+
//# sourceMappingURL=events.d.ts.map
|