Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix snapshot creation for null docs, add script to protos
- Loading branch information
1 parent
70faa4a
commit 3692a01
Showing
10 changed files
with
4,712 additions
and
3,022 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Generate compiled ProtoBuf | ||
|
||
## Step 1 | ||
|
||
### Grab the protos | ||
|
||
Firestore DocumentEventData - https://github.com/googleapis/google-cloudevents/blob/main/proto/google/events/cloud/firestore/v1/data.proto | ||
|
||
Any - https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/any.proto | ||
|
||
Struct - https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/struct.proto | ||
|
||
Timestamp - https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/timestamp.proto | ||
|
||
Latlng - https://github.com/googleapis/googleapis/blob/master/google/type/latlng.proto | ||
|
||
## Step 2 | ||
|
||
### Directory structure | ||
|
||
data.proto | ||
any.proto | ||
google/ | ||
struct.proto | ||
timestamp.proto | ||
type/ | ||
latlng.proto | ||
|
||
## Step 3 | ||
|
||
### Run the protobufjs cli to generate | ||
|
||
``` | ||
npx pbjs -t static-module -w commonjs -o compiled.js data.proto any.proto google/struct.proto google/timestamp.proto google/type/latlng.proto | ||
npx pbts -o compiled.d.ts compiled.js | ||
``` | ||
|
||
https://github.com/protobufjs/protobuf.js/tree/master/cli#pbts-for-typescript |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#!/bin/bash | ||
|
||
# The MIT License (MIT) | ||
# | ||
# Copyright (c) 2023 Firebase | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
|
||
# vars | ||
PROTOS_DIR="$(pwd)" | ||
WORK_DIR=`mktemp -d` | ||
|
||
# deletes the temp directory on exit | ||
function cleanup { | ||
rm -rf "$WORK_DIR" | ||
echo "Deleted temp working directory $WORK_DIR" | ||
# rm -rf "${PROTOS_DIR}/data.proto" "${PROTOS_DIR}/any.proto" "${PROTOS_DIR}/google" | ||
# echo "Deleted copied protos" | ||
} | ||
|
||
# register the cleanup function to be called on the EXIT signal | ||
trap cleanup EXIT | ||
|
||
# Capture location of pbjs / pbts before we pushd. | ||
PBJS="$(npm bin)/pbjs" | ||
PBTS="$(npm bin)/pbts" | ||
|
||
# enter working directory | ||
pushd "$WORK_DIR" | ||
|
||
git clone --depth 1 https://github.com/googleapis/google-cloudevents.git | ||
git clone --depth 1 https://github.com/googleapis/googleapis.git | ||
git clone --depth 1 https://github.com/google/protobuf.git | ||
|
||
# make dirs | ||
mkdir -p "${PROTOS_DIR}/google/type" | ||
|
||
# copy protos | ||
cp google-cloudevents/proto/google/events/cloud/firestore/v1/data.proto \ | ||
"${PROTOS_DIR}/" | ||
|
||
cp protobuf/src/google/protobuf/any.proto \ | ||
"${PROTOS_DIR}/" | ||
|
||
cp protobuf/src/google/protobuf/struct.proto \ | ||
"${PROTOS_DIR}/google/" | ||
|
||
cp protobuf/src/google/protobuf/timestamp.proto \ | ||
"${PROTOS_DIR}/google/" | ||
|
||
cp googleapis/google/type/latlng.proto \ | ||
"${PROTOS_DIR}/google/type/" | ||
|
||
popd | ||
|
||
# PBJS_ARGS=( --proto_path=. \ | ||
# --js_out=import_style=commonjs,binary:library \ | ||
# --target=static-module \ | ||
# --no-create \ | ||
# --no-encode \ | ||
# --no-decode \ | ||
# --no-verify \ | ||
# --no-delimited \ | ||
# --force-enum-string) | ||
|
||
"${PBJS}" -t static-module -w commonjs -o compiled.js \ | ||
data.proto any.proto google/*.proto google/type/*.proto | ||
|
||
"${PBTS}" -o compiledFirestore.d.ts compiledFirestore.js | ||
|
||
# "${PBJS}" "${PBJS_ARGS[@]}" -o compiledFirestore.js \ | ||
# -r firestore_v1 \ | ||
# "${PROTOS_DIR}/*.proto" \ | ||
# "${PROTOS_DIR}/google/type/*.proto" | ||
|
||
# perl -pi -e 's/number\|Long/number\|string/g' compiledFirestore.js | ||
|
||
# "${PBTS}" -o compiledFirestore.d.ts compiledFirestore.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.