@firebaseextensions/firestore-bigquery-change-tracker 1.1.29 → 1.1.30
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/bigquery/partitioning.js +24 -2
- package/package.json +9 -9
|
@@ -35,7 +35,8 @@ class Partitioning {
|
|
|
35
35
|
}
|
|
36
36
|
isValidPartitionTypeDate(value) {
|
|
37
37
|
/* Check if valid timestamp value from sdk */
|
|
38
|
-
if (value instanceof firebase.firestore.Timestamp)
|
|
38
|
+
// if (value instanceof firebase.firestore.Timestamp) return true;
|
|
39
|
+
if (isTimestampLike(value))
|
|
39
40
|
return true;
|
|
40
41
|
/* Check if valid date/timstemap, expedted result from production */
|
|
41
42
|
if (value && value.toDate && value.toDate())
|
|
@@ -137,7 +138,7 @@ class Partitioning {
|
|
|
137
138
|
Extracts a valid Partition field from the Document Change Event.
|
|
138
139
|
Matches result based on a pre-defined Firestore field matching the event data object.
|
|
139
140
|
Return an empty object if no field name or value provided.
|
|
140
|
-
Returns empty object if not a string or timestamp
|
|
141
|
+
Returns empty object if not a string or timestamp (or result of serializing a timestamp)
|
|
141
142
|
Logs warning if not a valid datatype
|
|
142
143
|
Delete changes events have no data, return early as cannot partition on empty data.
|
|
143
144
|
**/
|
|
@@ -155,6 +156,12 @@ class Partitioning {
|
|
|
155
156
|
}
|
|
156
157
|
if (this.isValidPartitionTypeDate(fieldValue)) {
|
|
157
158
|
/* Return converted console value */
|
|
159
|
+
if (isTimestampLike(fieldValue)) {
|
|
160
|
+
const convertedTimestampFieldValue = convertToTimestamp(fieldValue);
|
|
161
|
+
return {
|
|
162
|
+
[fieldName]: this.convertDateValue(convertedTimestampFieldValue.toDate()),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
158
165
|
if (fieldValue.toDate) {
|
|
159
166
|
return { [fieldName]: this.convertDateValue(fieldValue.toDate()) };
|
|
160
167
|
}
|
|
@@ -234,3 +241,18 @@ class Partitioning {
|
|
|
234
241
|
}
|
|
235
242
|
}
|
|
236
243
|
exports.Partitioning = Partitioning;
|
|
244
|
+
const isTimestampLike = (value) => {
|
|
245
|
+
if (value instanceof firebase.firestore.Timestamp)
|
|
246
|
+
return true;
|
|
247
|
+
return (typeof value === "object" &&
|
|
248
|
+
value !== null &&
|
|
249
|
+
"_seconds" in value &&
|
|
250
|
+
typeof value["_seconds"] === "number" &&
|
|
251
|
+
"_nanoseconds" in value &&
|
|
252
|
+
typeof value["_nanoseconds"] === "number");
|
|
253
|
+
};
|
|
254
|
+
const convertToTimestamp = (value) => {
|
|
255
|
+
if (value instanceof firebase.firestore.Timestamp)
|
|
256
|
+
return value;
|
|
257
|
+
return new firebase.firestore.Timestamp(value._seconds, value._nanoseconds);
|
|
258
|
+
};
|
package/package.json
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
"url": "github.com/firebase/extensions.git",
|
|
6
6
|
"directory": "firestore-bigquery-export/firestore-bigquery-change-tracker"
|
|
7
7
|
},
|
|
8
|
-
"version": "1.1.
|
|
8
|
+
"version": "1.1.30",
|
|
9
9
|
"description": "Core change-tracker library for Cloud Firestore Collection BigQuery Exports",
|
|
10
10
|
"main": "./lib/index.js",
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "npm run clean && npm run compile",
|
|
13
13
|
"clean": "rimraf lib",
|
|
14
14
|
"compile": "tsc",
|
|
15
|
-
"test:local": "
|
|
15
|
+
"test:local": "jest",
|
|
16
16
|
"prepare": "npm run build",
|
|
17
17
|
"generate-stresstest-table": "bq query --project_id=extensions-testing --use_legacy_sql=false < ./src/__tests__/fixtures/sql/generateSnapshotStresstestTable.sql"
|
|
18
18
|
},
|
|
@@ -35,16 +35,16 @@
|
|
|
35
35
|
"traverse": "^0.6.6"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
+
"@types/chai": "^4.1.6",
|
|
39
|
+
"@types/jest": "^24.0.18",
|
|
38
40
|
"@types/node": "14.18.34",
|
|
39
41
|
"@types/traverse": "^0.6.32",
|
|
40
|
-
"typescript": "^4.9.4",
|
|
41
|
-
"rimraf": "^2.6.3",
|
|
42
|
-
"nyc": "^14.0.0",
|
|
43
|
-
"jest": "^24.9.0",
|
|
44
42
|
"chai": "^4.2.0",
|
|
45
|
-
"
|
|
43
|
+
"jest": "^24.9.0",
|
|
44
|
+
"nyc": "^14.0.0",
|
|
45
|
+
"rimraf": "^2.6.3",
|
|
46
46
|
"ts-jest": "^24.1.0",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
47
|
+
"ts-node": "^7.0.1",
|
|
48
|
+
"typescript": "^4.9.4"
|
|
49
49
|
}
|
|
50
50
|
}
|