@firebase-function-kits/firestore-bigquery-export 0.0.1 → 0.0.2-rc.1

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 (57) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/README.md +303 -0
  3. package/lib/config.d.ts +33 -0
  4. package/lib/config.d.ts.map +1 -0
  5. package/lib/config.js +569 -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/npm-shrinkwrap.json +7016 -0
  40. package/package.json +37 -3
  41. package/src/config.ts +696 -0
  42. package/src/events.ts +146 -0
  43. package/src/export-config.ts +205 -0
  44. package/src/handlers.ts +211 -0
  45. package/src/index.ts +174 -0
  46. package/src/init.ts +45 -0
  47. package/src/lib.ts +55 -0
  48. package/src/logs.ts +233 -0
  49. package/src/util.ts +64 -0
  50. package/tests/config.test.ts +182 -0
  51. package/tests/events.test.ts +84 -0
  52. package/tests/export-config.test.ts +114 -0
  53. package/tests/handlers.test.ts +220 -0
  54. package/tests/init.test.ts +76 -0
  55. package/tests/util.test.ts +102 -0
  56. package/tsconfig.json +18 -0
  57. package/tsconfig.tsbuildinfo +1 -0
package/lib/util.js ADDED
@@ -0,0 +1,66 @@
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.resolveWildcardIds = void 0;
19
+ exports.getChangeType = getChangeType;
20
+ exports.getDocumentId = getDocumentId;
21
+ const firestore_bigquery_change_tracker_1 = require("@firebaseextensions/firestore-bigquery-change-tracker");
22
+ /**
23
+ * Get the change type (CREATE, UPDATE, DELETE) from the Firestore change.
24
+ * @param change Firestore document change object.
25
+ * @returns {ChangeType} The type of change.
26
+ */
27
+ function getChangeType(change) {
28
+ if (!change.after.exists) {
29
+ return firestore_bigquery_change_tracker_1.ChangeType.DELETE;
30
+ }
31
+ if (!change.before.exists) {
32
+ return firestore_bigquery_change_tracker_1.ChangeType.CREATE;
33
+ }
34
+ return firestore_bigquery_change_tracker_1.ChangeType.UPDATE;
35
+ }
36
+ /**
37
+ * Get the document ID from the Firestore change.
38
+ * @param change Firestore document change object.
39
+ * @returns {string} The document ID.
40
+ */
41
+ function getDocumentId(change) {
42
+ if (change.after.exists) {
43
+ return change.after.id;
44
+ }
45
+ return change.before.id;
46
+ }
47
+ /**
48
+ *
49
+ * @param template - eg, regions/{regionId}/countries
50
+ * @param text - eg, regions/asia/countries
51
+ *
52
+ * @return - eg, { regionId: "asia" }
53
+ */
54
+ const resolveWildcardIds = (template, text) => {
55
+ const textSegments = text.split("/");
56
+ return template
57
+ .split("/")
58
+ .reduce((previousValue, currentValue, currentIndex) => {
59
+ if (currentValue.startsWith("{") && currentValue.endsWith("}")) {
60
+ previousValue[currentValue.slice(1, -1)] = textSegments[currentIndex];
61
+ }
62
+ return previousValue;
63
+ }, {});
64
+ };
65
+ exports.resolveWildcardIds = resolveWildcardIds;
66
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;AAEH,6GAAmF;AAGnF;;;;GAIG;AACH,uBAA8B,MAAgC;IAC5D,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QACzB,OAAO,8CAAU,CAAC,MAAM,CAAC;IAC3B,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QAC1B,OAAO,8CAAU,CAAC,MAAM,CAAC;IAC3B,CAAC;IACD,OAAO,8CAAU,CAAC,MAAM,CAAC;AAC3B,CAAC;AAED;;;;GAIG;AACH,uBAA8B,MAAgC;IAC5D,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IACzB,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;AAC1B,CAAC;AAED;;;;;;GAMG;AACI,MAAM,kBAAkB,GAAG,CAAC,QAAgB,EAAE,IAAY,EAAE,EAAE;IACnE,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CA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