-
Notifications
You must be signed in to change notification settings - Fork 427
Expand file tree
/
Copy pathconfig.ts
More file actions
81 lines (77 loc) · 3.11 KB
/
config.ts
File metadata and controls
81 lines (77 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { LogLevel } from "@firebaseextensions/firestore-bigquery-change-tracker";
function timePartitioning(type) {
if (
type === "HOUR" ||
type === "DAY" ||
type === "MONTH" ||
type === "YEAR"
) {
return type;
}
return null;
}
export function clustering(clusters: string | undefined) {
return clusters ? clusters.split(",").slice(0, 4) : null;
}
export default {
bqProjectId: process.env.BIGQUERY_PROJECT_ID,
projectId: process.env.PROJECT_ID,
databaseId: process.env.DATABASE || "(default)",
databaseRegion: process.env.DATABASE_REGION,
collectionPath: process.env.COLLECTION_PATH,
datasetId: process.env.DATASET_ID,
tableId: process.env.TABLE_ID,
location: process.env.LOCATION,
initialized: false,
importCollectionPath: process.env.IMPORT_COLLECTION_PATH,
datasetLocation: process.env.DATASET_LOCATION,
backupCollectionId: process.env.BACKUP_COLLECTION,
transformFunction: process.env.TRANSFORM_FUNCTION,
timePartitioning: timePartitioning(process.env.TABLE_PARTITIONING),
timePartitioningField: process.env.TIME_PARTITIONING_FIELD,
timePartitioningFieldType:
process.env.TIME_PARTITIONING_FIELD_TYPE !== "omit"
? process.env.TIME_PARTITIONING_FIELD_TYPE
: undefined,
timePartitioningFirestoreField: process.env.TIME_PARTITIONING_FIRESTORE_FIELD,
clustering: clustering(process.env.CLUSTERING),
wildcardIds: process.env.WILDCARD_IDS === "true",
useNewSnapshotQuerySyntax:
process.env.USE_NEW_SNAPSHOT_QUERY_SYNTAX === "yes" ? true : false,
excludeOldData: process.env.EXCLUDE_OLD_DATA === "yes" ? true : false,
viewType: process.env.VIEW_TYPE || "view",
maxStaleness: process.env.MAX_STALENESS,
refreshIntervalMinutes: process.env.REFRESH_INTERVAL_MINUTES
? parseInt(process.env.REFRESH_INTERVAL_MINUTES)
: undefined,
instanceId: process.env.EXT_INSTANCE_ID!,
maxDispatchesPerSecond: parseInt(
process.env.MAX_DISPATCHES_PER_SECOND || "10"
),
kmsKeyName: process.env.KMS_KEY_NAME,
maxEnqueueAttempts: isNaN(parseInt(process.env.MAX_ENQUEUE_ATTEMPTS))
? 3
: parseInt(process.env.MAX_ENQUEUE_ATTEMPTS),
// backup bucket defaults to default firebase cloud storage bucket
backupToGCS: process.env.BACKUP_TO_GCS === "yes" ? true : false,
backupBucketName:
process.env.BACKUP_GCS_BUCKET || `${process.env.PROJECT_ID}.appspot.com`,
backupDir: `_${process.env.INSTANCE_ID || "firestore-bigquery-export"}`,
logLevel: process.env.LOG_LEVEL || LogLevel.INFO,
ignoreDocumentDeletion: process.env.IGNORE_DOCUMENT_DELETION === "yes" ? true : false,
};