From ecd9f8e68164427ad1fe4f33754e63f1e5402b0d Mon Sep 17 00:00:00 2001 From: Maksim Karenko Date: Sun, 27 Oct 2019 11:46:44 -0700 Subject: [PATCH] fix(admin-firestore): add types from @google-cloud/firestore --- package-lock.json | 119 ++++++++++--------------------- package.json | 1 + src/Collection.ts | 2 +- src/DocumentSnapshot.ts | 2 +- src/Query.ts | 2 +- src/QuerySnapshot.ts | 2 +- src/decorators/documentRef.ts | 2 +- src/decorators/geoPoint.ts | 2 +- src/decorators/timestamp.ts | 2 +- src/fields/DocumentRef.ts | 2 +- src/fields/GeoPoint.ts | 2 +- src/fields/Timestamp.ts | 2 +- src/firestore.ts | 29 ++++++++ src/store.ts | 7 +- src/types/collection.types.ts | 2 +- src/types/field.types.ts | 2 +- src/types/store.types.ts | 2 +- src/types/timestamp.types.ts | 2 +- src/utils/FirestoreSerializer.ts | 2 +- src/utils/QueryBuilder.ts | 2 +- 20 files changed, 86 insertions(+), 102 deletions(-) create mode 100644 src/firestore.ts diff --git a/package-lock.json b/package-lock.json index cb448be..f50a790 100644 --- a/package-lock.json +++ b/package-lock.json @@ -417,16 +417,15 @@ } }, "@google-cloud/firestore": { - "version": "2.2.9", - "resolved": "https://registry.npmjs.org/@google-cloud/firestore/-/firestore-2.2.9.tgz", - "integrity": "sha512-75MdgTJeZ3TR4EsoKVT09N6PoyFlX4xDtcOe+oH2b63XfOA3/turoJTUplhsiVRGTP9SoEMHOl9kfYa4oepdmg==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@google-cloud/firestore/-/firestore-2.5.0.tgz", + "integrity": "sha512-pe8t2oDpDDGLVdhWRTxbKfMglwqE5U/4wdnX7oOAVeifHs11PgBuvUuJw1XLlV0CorjU3/zKzgKXY/XRjuy4uQ==", "dev": true, - "optional": true, "requires": { "bun": "^0.0.12", "deep-equal": "^1.0.1", "functional-red-black-tree": "^1.0.1", - "google-gax": "^1.1.2", + "google-gax": "^1.7.5", "through2": "^3.0.0" } }, @@ -498,21 +497,19 @@ } }, "@grpc/grpc-js": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-0.5.2.tgz", - "integrity": "sha512-NE1tP/1AF6BqhLdILElnF7aOBfoky+4ZOdZU/0NmKo2d+9F9QD8zGoElpBk/5BfyQZ3u1Zs+wFbDOFpVUzDx1w==", + "version": "0.6.9", + "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-0.6.9.tgz", + "integrity": "sha512-r1nDOEEiYmAsVYBaS4DPPqdwPOXPw7YhVOnnpPdWhlNtKbYzPash6DqWTTza9gBiYMA5d2Wiq6HzrPqsRaP4yA==", "dev": true, - "optional": true, "requires": { - "semver": "^6.0.0" + "semver": "^6.2.0" } }, "@grpc/proto-loader": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.5.1.tgz", - "integrity": "sha512-3y0FhacYAwWvyXshH18eDkUI40wT/uGio7MAegzY8lO5+wVsc19+1A7T0pPptae4kl7bdITL+0cHpnAPmryBjQ==", + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.5.2.tgz", + "integrity": "sha512-eBKD/FPxQoY1x6QONW2nBd54QUEyzcFP9FenujmoeDPy1rutVSHki1s/wR68F6O1QfCNDx+ayBH1O2CVNMzyyw==", "dev": true, - "optional": true, "requires": { "lodash.camelcase": "^4.3.0", "protobufjs": "^6.8.6" @@ -698,7 +695,6 @@ "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", "dev": true, - "optional": true, "requires": { "event-target-shim": "^5.0.0" } @@ -720,7 +716,6 @@ "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", "integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==", "dev": true, - "optional": true, "requires": { "es6-promisify": "^5.0.0" } @@ -831,8 +826,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/arrify/-/arrify-2.0.1.tgz", "integrity": "sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug==", - "dev": true, - "optional": true + "dev": true }, "ascli": { "version": "1.0.1", @@ -990,8 +984,7 @@ "version": "1.3.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==", - "dev": true, - "optional": true + "dev": true }, "bcrypt-pbkdf": { "version": "1.0.2", @@ -1006,8 +999,7 @@ "version": "7.2.1", "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-7.2.1.tgz", "integrity": "sha512-S4XzBk5sMB+Rcb/LNcpzXr57VRTxgAvaAEDAl1AwRx27j00hT84O6OkteE7u8UB3NuaaygCRrEpqox4uDOrbdQ==", - "dev": true, - "optional": true + "dev": true }, "binary-extensions": { "version": "2.0.0", @@ -1082,7 +1074,6 @@ "resolved": "https://registry.npmjs.org/bun/-/bun-0.0.12.tgz", "integrity": "sha512-Toms18J9DqnT+IfWkwxVTB2EaBprHvjlMWrTIsfX4xbu3ZBqVBwrERU0em1IgtRe04wT+wJxMlKHZok24hrcSQ==", "dev": true, - "optional": true, "requires": { "readable-stream": "~1.0.32" } @@ -1804,7 +1795,6 @@ "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.1.0.tgz", "integrity": "sha512-ZbfWJq/wN1Z273o7mUSjILYqehAktR2NVoSrOukDkU9kg2v/Uv89yU4Cvz8seJeAmtN5oqiefKq8FPuXOboqLw==", "dev": true, - "optional": true, "requires": { "is-arguments": "^1.0.4", "is-date-object": "^1.0.1", @@ -1953,7 +1943,6 @@ "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz", "integrity": "sha512-07z8uv2wMyS51kKhD1KsdXJg5WQ6t93RneqRxUHnskXVtlYYkLqM0gqStQZ3pj073g687jPCHrqNfCzawLYh5g==", "dev": true, - "optional": true, "requires": { "end-of-stream": "^1.0.0", "inherits": "^2.0.1", @@ -1965,15 +1954,13 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true, - "optional": true + "dev": true }, "readable-stream": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, - "optional": true, "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", @@ -1989,7 +1976,6 @@ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, - "optional": true, "requires": { "safe-buffer": "~5.1.0" } @@ -2089,15 +2075,13 @@ "version": "4.2.8", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==", - "dev": true, - "optional": true + "dev": true }, "es6-promisify": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", "dev": true, - "optional": true, "requires": { "es6-promise": "^4.0.3" } @@ -2275,8 +2259,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", - "dev": true, - "optional": true + "dev": true }, "execa": { "version": "1.0.0", @@ -2483,8 +2466,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/fast-text-encoding/-/fast-text-encoding-1.0.0.tgz", "integrity": "sha512-R9bHCvweUxxwkDwhjav5vxpFvdPGlVngtqmx4pIZfSUhM/Q4NiIUHB456BAf+Q1Nwu3HEZYONtu+Rya+af4jiQ==", - "dev": true, - "optional": true + "dev": true }, "fault": { "version": "1.0.3", @@ -2816,7 +2798,6 @@ "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-2.0.1.tgz", "integrity": "sha512-c1NXovTxkgRJTIgB2FrFmOFg4YIV6N/bAa4f/FZ4jIw13Ql9ya/82x69CswvotJhbV3DiGnlTZwoq2NVXk2Irg==", "dev": true, - "optional": true, "requires": { "abort-controller": "^3.0.0", "extend": "^3.0.2", @@ -2829,7 +2810,6 @@ "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-2.0.2.tgz", "integrity": "sha512-dxPXBvjyfz5qFEBXzEwNmuZXwsGYfuASGYeg3CKZDaQRXdiWti9J3/Ezmtyon1OrCNpDO2YekyoSjEqMtsrcXw==", "dev": true, - "optional": true, "requires": { "gaxios": "^2.0.1", "json-bigint": "^0.3.0" @@ -2953,7 +2933,6 @@ "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-5.2.0.tgz", "integrity": "sha512-I2726rgOedQ06HgTvoNvBeRCzy5iFe6z3khwj6ugfRd1b0VHwnTYKl/3t2ytOTo7kKc6KivYIBsCIdZf2ep67g==", "dev": true, - "optional": true, "requires": { "arrify": "^2.0.0", "base64-js": "^1.3.0", @@ -2966,13 +2945,12 @@ } }, "google-gax": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/google-gax/-/google-gax-1.5.1.tgz", - "integrity": "sha512-LSQ/VG2DZJGuKnDj1EjODxCImS30JBF9hGyhgGAYApsKuFTfS6Hd956+gx1ZTlQp6FbUnbL6Ajr569ydoxbMyg==", + "version": "1.7.5", + "resolved": "https://registry.npmjs.org/google-gax/-/google-gax-1.7.5.tgz", + "integrity": "sha512-Tz2DFs8umzDcCBTi2W1cY4vEgAKaYRj70g6Hh/MiiZaJizrly7PgyxsIYUGi7sOpEuAbARQymYKvy5mNi8hEbg==", "dev": true, - "optional": true, "requires": { - "@grpc/grpc-js": "^0.5.2", + "@grpc/grpc-js": "0.6.9", "@grpc/proto-loader": "^0.5.1", "abort-controller": "^3.0.0", "duplexify": "^3.6.0", @@ -2992,7 +2970,6 @@ "resolved": "https://registry.npmjs.org/google-p12-pem/-/google-p12-pem-2.0.1.tgz", "integrity": "sha512-6h6x+eBX3k+IDSe/c8dVYmn8Mzr1mUcmKC9MdUSwaBkFAXlqBEnwFWmSFgGC+tcqtsLn73BDP/vUNWEehf1Rww==", "dev": true, - "optional": true, "requires": { "node-forge": "^0.8.0" }, @@ -3001,8 +2978,7 @@ "version": "0.8.5", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.8.5.tgz", "integrity": "sha512-vFMQIWt+J/7FLNyKouZ9TazT74PRV3wgv9UT4cRjC8BffxFbKXkgIWR42URCPSnHm/QDz6BOlb2Q0U4+VQT67Q==", - "dev": true, - "optional": true + "dev": true } } }, @@ -3455,7 +3431,6 @@ "resolved": "https://registry.npmjs.org/gtoken/-/gtoken-4.0.0.tgz", "integrity": "sha512-XaRCfHJxhj06LmnWNBzVTAr85NfAErq0W1oabkdqwbq3uL/QTB1kyvGog361Uu2FMG/8e3115sIy/97Rnd4GjQ==", "dev": true, - "optional": true, "requires": { "gaxios": "^2.0.0", "google-p12-pem": "^2.0.0", @@ -3710,7 +3685,6 @@ "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.2.tgz", "integrity": "sha512-c8Ndjc9Bkpfx/vCJueCPy0jlP4ccCCSNDp8xwCZzPjKJUm+B+u9WX2x98Qx4n1PiMNTWo3D7KK5ifNV/yJyRzg==", "dev": true, - "optional": true, "requires": { "agent-base": "^4.3.0", "debug": "^3.1.0" @@ -3913,8 +3887,7 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.0.4.tgz", "integrity": "sha512-xPh0Rmt8NE65sNzvyUmWgI1tz3mKq74lGA0mL8LYZcoIzKOzDh6HmrYm3d18k60nHerC8A9Km8kYu87zfSFnLA==", - "dev": true, - "optional": true + "dev": true }, "is-arrayish": { "version": "0.2.1", @@ -4132,8 +4105,7 @@ "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-stream-ended/-/is-stream-ended-0.1.4.tgz", "integrity": "sha512-xj0XPvmr7bQFTvirqnFr50o0hQIh6ZItDqloxt5aJrR4NQsYeSsyFQERYGCAzfindAcnKjINnwEEgLx4IqVzQw==", - "dev": true, - "optional": true + "dev": true }, "is-symbol": { "version": "1.0.2", @@ -4178,8 +4150,7 @@ "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true, - "optional": true + "dev": true }, "isemail": { "version": "3.2.0", @@ -4450,7 +4421,6 @@ "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-0.3.0.tgz", "integrity": "sha1-DM2RLEuCcNBfBW+9E4FLU9OCWx4=", "dev": true, - "optional": true, "requires": { "bignumber.js": "^7.0.0" } @@ -4650,8 +4620,7 @@ "version": "4.6.0", "resolved": "https://registry.npmjs.org/lodash.at/-/lodash.at-4.6.0.tgz", "integrity": "sha1-k83OZk8KGZTqM9181A4jr9EbD/g=", - "dev": true, - "optional": true + "dev": true }, "lodash.camelcase": { "version": "4.3.0", @@ -4673,8 +4642,7 @@ "version": "4.5.2", "resolved": "https://registry.npmjs.org/lodash.has/-/lodash.has-4.5.2.tgz", "integrity": "sha1-0Z9NwQlQWMzL4rDN9O4P5Ko3yGI=", - "dev": true, - "optional": true + "dev": true }, "lodash.includes": { "version": "4.3.0", @@ -4935,8 +4903,7 @@ "version": "2.4.4", "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.4.tgz", "integrity": "sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA==", - "dev": true, - "optional": true + "dev": true }, "mime-db": { "version": "1.40.0", @@ -5273,8 +5240,7 @@ "version": "2.6.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==", - "dev": true, - "optional": true + "dev": true }, "node-forge": { "version": "0.7.4", @@ -5511,8 +5477,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.0.1.tgz", "integrity": "sha1-CqYOyZiaCz7Xlc9NBvYs8a1lObY=", - "dev": true, - "optional": true + "dev": true }, "object-keys": { "version": "1.1.1", @@ -5839,8 +5804,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", - "dev": true, - "optional": true + "dev": true }, "progress": { "version": "2.0.3", @@ -6009,7 +5973,6 @@ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, - "optional": true, "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.1", @@ -6062,7 +6025,6 @@ "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.2.0.tgz", "integrity": "sha512-ztaw4M1VqgMwl9HlPpOuiYgItcHlunW0He2fE6eNfT6E/CF2FtYi9ofOYe4mKntstYk0Fyh/rDRBdS3AnxjlrA==", "dev": true, - "optional": true, "requires": { "define-properties": "^1.1.2" } @@ -6516,7 +6478,6 @@ "resolved": "https://registry.npmjs.org/retry-request/-/retry-request-4.1.1.tgz", "integrity": "sha512-BINDzVtLI2BDukjWmjAIRZ0oglnCAkpP2vQjM3jdLhmT62h0xnQgciPwBRDAvHqpkPT2Wo1XuUyLyn6nbGrZQQ==", "dev": true, - "optional": true, "requires": { "debug": "^4.1.1", "through2": "^3.0.1" @@ -6527,7 +6488,6 @@ "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", "dev": true, - "optional": true, "requires": { "ms": "^2.1.1" } @@ -6993,8 +6953,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz", "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=", - "dev": true, - "optional": true + "dev": true }, "streamsearch": { "version": "0.1.2", @@ -7016,8 +6975,7 @@ "version": "0.10.31", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true, - "optional": true + "dev": true }, "stringify-entities": { "version": "2.0.0", @@ -7163,7 +7121,6 @@ "resolved": "https://registry.npmjs.org/through2/-/through2-3.0.1.tgz", "integrity": "sha512-M96dvTalPT3YbYLaKaCuwu+j06D/8Jfib0o/PxbVt6Amhv3dUAtW6rTV1jPgJSBG83I/e04Y6xkVdVhSRhi0ww==", "dev": true, - "optional": true, "requires": { "readable-stream": "2 || 3" }, @@ -7173,7 +7130,6 @@ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz", "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==", "dev": true, - "optional": true, "requires": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -7184,15 +7140,13 @@ "version": "5.2.0", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==", - "dev": true, - "optional": true + "dev": true }, "string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", "dev": true, - "optional": true, "requires": { "safe-buffer": "~5.2.0" } @@ -7907,8 +7861,7 @@ "version": "0.4.1", "resolved": "https://registry.npmjs.org/walkdir/-/walkdir-0.4.1.tgz", "integrity": "sha512-3eBwRyEln6E1MSzcxcVpQIhRG8Q1jLvEqRmCZqS3dsfXEDR/AhOF4d+jHg1qvDCpYaVRZjENPQyrVxAkQqxPgQ==", - "dev": true, - "optional": true + "dev": true }, "websocket-driver": { "version": "0.7.3", diff --git a/package.json b/package.json index eccc331..878066a 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ }, "license": "MIT", "devDependencies": { + "@google-cloud/firestore": "^2.5.0", "@types/chai": "^4.1.7", "@types/chai-as-promised": "^7.1.0", "@types/mocha": "^5.2.7", diff --git a/src/Collection.ts b/src/Collection.ts index d150cb6..dccf2f9 100644 --- a/src/Collection.ts +++ b/src/Collection.ts @@ -1,4 +1,4 @@ -import { firestore } from 'firebase/app'; +import { firestore } from './firestore'; import store, { getRepository } from './store'; import { ICollectionQuery, ICollection, IDocumentRef, WriteTypes } from './types'; import { QueryBuilder, FirestoreSerializer } from './utils'; diff --git a/src/DocumentSnapshot.ts b/src/DocumentSnapshot.ts index 3d789ab..a93ee61 100644 --- a/src/DocumentSnapshot.ts +++ b/src/DocumentSnapshot.ts @@ -1,7 +1,7 @@ import Entity from './Entity'; import { IDocumentSnapshot, ICollection } from './types/collection.types'; import { IDocumentRef } from './types'; -import { firestore } from 'firebase/app'; +import { firestore } from './firestore'; import { FirestoreSerializer } from './utils'; export default class DocumentSnapshot implements IDocumentSnapshot { diff --git a/src/Query.ts b/src/Query.ts index c672561..1ab3a2c 100644 --- a/src/Query.ts +++ b/src/Query.ts @@ -1,4 +1,4 @@ -import { firestore } from 'firebase/app'; +import { firestore } from './firestore'; import { Entity } from '.'; import { IFieldMeta, ICollection, IQuery } from './types'; import QuerySnapshot from './QuerySnapshot'; diff --git a/src/QuerySnapshot.ts b/src/QuerySnapshot.ts index 4d818c4..ef07908 100644 --- a/src/QuerySnapshot.ts +++ b/src/QuerySnapshot.ts @@ -1,4 +1,4 @@ -import { firestore } from 'firebase/app'; +import { firestore } from './firestore'; import Query from './Query'; import Entity from './Entity'; import { IQuerySnapshot, ICollection, DocumentChange } from './types'; diff --git a/src/decorators/documentRef.ts b/src/decorators/documentRef.ts index 9796120..297b1df 100644 --- a/src/decorators/documentRef.ts +++ b/src/decorators/documentRef.ts @@ -1,4 +1,4 @@ -import { firestore } from 'firebase/app'; +import { firestore } from '../firestore'; import { IDocumentRefConfig, IDocumentRefMeta, FieldTypes, IDocumentRef, IEntity, ICollection } from '../types'; import FieldUtils from '../utils/FieldUtils'; import { getOrCreateRepository, getRepository } from '../store'; diff --git a/src/decorators/geoPoint.ts b/src/decorators/geoPoint.ts index 8e6f474..1c4f860 100644 --- a/src/decorators/geoPoint.ts +++ b/src/decorators/geoPoint.ts @@ -1,4 +1,4 @@ -import { firestore } from 'firebase/app'; +import { firestore } from '../firestore'; import { FieldTypes, IGeoPointConfig, IGeoPoint, GeoPointData } from '../types'; import FieldUtils from '../utils/FieldUtils'; import { getOrCreateRepository } from '../store'; diff --git a/src/decorators/timestamp.ts b/src/decorators/timestamp.ts index 31bb10a..2147fd2 100644 --- a/src/decorators/timestamp.ts +++ b/src/decorators/timestamp.ts @@ -1,4 +1,4 @@ -import { firestore } from 'firebase/app'; +import { firestore } from '../firestore'; import { FieldTypes, ITimestampConfig, WriteTypes, ITimestampMeta } from '../types'; import FieldUtils from '../utils/FieldUtils'; import { getOrCreateRepository } from '../store'; diff --git a/src/fields/DocumentRef.ts b/src/fields/DocumentRef.ts index fd54aa7..7efb42f 100644 --- a/src/fields/DocumentRef.ts +++ b/src/fields/DocumentRef.ts @@ -1,5 +1,5 @@ import { IDocumentRef, ICollection } from '../types'; -import { firestore } from 'firebase/app'; +import { firestore } from '../firestore'; import { FirestoreSerializer } from '../utils'; import Collection from '../Collection'; import Entity from '../Entity'; diff --git a/src/fields/GeoPoint.ts b/src/fields/GeoPoint.ts index da73b52..99ab5dd 100644 --- a/src/fields/GeoPoint.ts +++ b/src/fields/GeoPoint.ts @@ -1,4 +1,4 @@ -import { firestore } from 'firebase/app'; +import { firestore } from '../firestore'; import { IGeoPoint } from '../types'; /** diff --git a/src/fields/Timestamp.ts b/src/fields/Timestamp.ts index 65c9602..70120da 100644 --- a/src/fields/Timestamp.ts +++ b/src/fields/Timestamp.ts @@ -1,4 +1,4 @@ -import { firestore } from 'firebase/app'; +import { firestore } from '../firestore'; import { ITimestamp } from '../types'; /** diff --git a/src/firestore.ts b/src/firestore.ts new file mode 100644 index 0000000..5e65a56 --- /dev/null +++ b/src/firestore.ts @@ -0,0 +1,29 @@ +import { firestore as firebaseFirestore } from 'firebase/app'; +import * as CloudFirestore from '@google-cloud/firestore'; + +const Timestamp = firebaseFirestore ? firebaseFirestore.Timestamp : CloudFirestore.Timestamp; +const GeoPoint = firebaseFirestore ? firebaseFirestore.GeoPoint : CloudFirestore.GeoPoint; +const FieldValue = firebaseFirestore ? firebaseFirestore.FieldValue : CloudFirestore.FieldValue; + +export namespace firestore { + export type Timestamp = firebaseFirestore.Timestamp | CloudFirestore.Timestamp; + export type GeoPoint = firebaseFirestore.GeoPoint | CloudFirestore.GeoPoint; + export type FieldValue = firebaseFirestore.FieldValue | CloudFirestore.FieldValue; + export type QuerySnapshot = firebaseFirestore.QuerySnapshot; + export type WhereFilterOp = firebaseFirestore.WhereFilterOp; + export type OrderByDirection = firebaseFirestore.OrderByDirection; + export type CollectionReference = firebaseFirestore.CollectionReference; + export type DocumentChangeType = firebaseFirestore.DocumentChangeType; + export type DocumentReference = firebaseFirestore.DocumentReference; + export type DocumentSnapshot = firebaseFirestore.DocumentSnapshot; + export type Query = firebaseFirestore.Query; + export type Firestore = firebaseFirestore.Firestore; + export type SnapshotMetadata = firebaseFirestore.SnapshotMetadata; + export type SnapshotListenOptions = firebaseFirestore.SnapshotListenOptions; +} + +export const firestore = { + Timestamp, + GeoPoint, + FieldValue, +}; diff --git a/src/store.ts b/src/store.ts index 6b1a51c..f68c277 100644 --- a/src/store.ts +++ b/src/store.ts @@ -1,4 +1,5 @@ -import * as firebase from 'firebase/app'; +import * as firebase from './firestore'; +import * as CloudFirestore from '@google-cloud/firestore'; import { IFireormConfig, IFieldMeta, @@ -20,8 +21,8 @@ let store: IStore = { * @param firestore A firestore instance. * @param config Configuration options for firestorm. */ -export const initialize = (firestore: firebase.firestore.Firestore, config?: IFireormConfig): void => { - store.firestore = firestore; +export const initialize = (firestore: firebase.firestore.Firestore | CloudFirestore.Firestore, config?: IFireormConfig): void => { + store.firestore = firestore as firebase.firestore.Firestore; if (config) { (Object.keys(config) as (keyof IFireormConfig)[]).forEach((key): void => { store.config[key] = config[key]; diff --git a/src/types/collection.types.ts b/src/types/collection.types.ts index 276f460..7c15469 100644 --- a/src/types/collection.types.ts +++ b/src/types/collection.types.ts @@ -1,4 +1,4 @@ -import { firestore } from 'firebase/app'; +import { firestore } from '../firestore'; import { IDocumentRef } from './field.types'; import { Query } from '..'; diff --git a/src/types/field.types.ts b/src/types/field.types.ts index 277b46e..d3cb64b 100644 --- a/src/types/field.types.ts +++ b/src/types/field.types.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-empty-interface */ -import { firestore } from 'firebase/app'; +import { firestore } from '../firestore'; import { FieldTypes } from './enum.types'; import { ICollection, IEntity, IDocumentSnapshot } from './collection.types'; diff --git a/src/types/store.types.ts b/src/types/store.types.ts index 8948329..b2cf4e9 100644 --- a/src/types/store.types.ts +++ b/src/types/store.types.ts @@ -1,4 +1,4 @@ -import { firestore } from 'firebase/app'; +import { firestore } from '../firestore'; import { ICollectionConfig, ISubCollectionConfig, IEntity } from './collection.types'; import { FieldConversionType } from './enum.types'; import { IFieldMeta } from './field.types'; diff --git a/src/types/timestamp.types.ts b/src/types/timestamp.types.ts index 2506edb..1beaedd 100644 --- a/src/types/timestamp.types.ts +++ b/src/types/timestamp.types.ts @@ -1,4 +1,4 @@ -import { firestore } from 'firebase/app'; +import { firestore } from '../firestore'; import { IFieldConfig, IFieldMeta, WriteTypes } from '.'; import { Timestamp } from '../fields'; diff --git a/src/utils/FirestoreSerializer.ts b/src/utils/FirestoreSerializer.ts index bd7ac54..2210e28 100644 --- a/src/utils/FirestoreSerializer.ts +++ b/src/utils/FirestoreSerializer.ts @@ -1,4 +1,4 @@ -import { firestore } from 'firebase/app'; +import { firestore } from '../firestore'; import { FieldTypes, ICollection, WriteTypes } from '../types'; import { getRepository } from '../store'; import Entity from '../Entity'; diff --git a/src/utils/QueryBuilder.ts b/src/utils/QueryBuilder.ts index c7b8257..bedfef0 100644 --- a/src/utils/QueryBuilder.ts +++ b/src/utils/QueryBuilder.ts @@ -1,4 +1,4 @@ -import { firestore } from 'firebase/app'; +import { firestore } from '../firestore'; import { IEntity, ICollectionQuery, ICollection, IFieldMeta } from '../types'; /**