Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Release Bundles #1365

Merged
merged 7 commits into from
Dec 2, 2020
Merged

feat: Release Bundles #1365

merged 7 commits into from
Dec 2, 2020

Conversation

wu-hui
Copy link
Contributor

@wu-hui wu-hui commented Nov 16, 2020

PR to release bundles. Will merge when we decide to release.

@wu-hui wu-hui requested review from a team as code owners November 16, 2020 01:30
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Nov 16, 2020
@product-auto-label product-auto-label bot added the api: firestore Issues related to the googleapis/nodejs-firestore API. label Nov 16, 2020
@codecov
Copy link

codecov bot commented Nov 16, 2020

Codecov Report

Merging #1365 (2f606da) into master (4acc5dd) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1365      +/-   ##
==========================================
- Coverage   98.51%   98.51%   -0.01%     
==========================================
  Files          32       32              
  Lines       19444    19440       -4     
  Branches     1281     1371      +90     
==========================================
- Hits        19156    19152       -4     
  Misses        284      284              
  Partials        4        4              
Impacted Files Coverage Δ
dev/src/bundle.ts 94.32% <100.00%> (-0.05%) ⬇️
dev/src/index.ts 97.56% <100.00%> (-0.01%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4acc5dd...2f606da. Read the comment docs.

Copy link
Contributor

@schmidt-sebastian schmidt-sebastian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect this PR to contain updates to types/firestore.d.ts. Can you double check what needs to be added there?

@wu-hui wu-hui removed their assignment Nov 16, 2020
@wu-hui
Copy link
Contributor Author

wu-hui commented Nov 16, 2020

I would expect this PR to contain updates to types/firestore.d.ts. Can you double check what needs to be added there?

Added. Thanks for the reminder.

* Creates a new `BundleBuilder` instance to package selected Firestore data into
* a bundle.
*
* @param bundleId. The id of the bundle. When loaded on clients, client SDKs use this id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the text part: s/id/ID here and everywhere (including the main sources)

Also drop the period after "bundleId".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

* @returns {BundleBuilder} This instance.
*/
add(documentSnapshot: DocumentSnapshot): BundleBuilder;
/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Missing empty line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines 1927 to 1928
* @param {DocumentSnapshot=} documentSnapshot A document snapshot to add.
* @returns {BundleBuilder} This instance.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is TypeScript. You should drop the JSDoc type markers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines 1935 to 1937
* @param {string=} queryName The name of the query to add.
* @param {QuerySnapshot=} querySnapshot A query snapshot to add to the bundle.
* @returns {BundleBuilder} This instance.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop types.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

* @param {DocumentSnapshot=} documentSnapshot A document snapshot to add.
* @returns {BundleBuilder} This instance.
*/
add(documentSnapshot: DocumentSnapshot): BundleBuilder;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should DocumentSnapshot (and QuerySnapshot) below be generic (for converter support)? Does the BundleBuilder respect the converters as it generates the Proto?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All it does is call toDocumentProto() on the snapshot, I don't think it is necessary to make it generic?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is actually no such thing as a non-generic DocumentSnapshot in our API. The DocumentSnapshot type defaults to DocumentSnapshot<DocumentData>, which means that a custom type such as DocumentSnapshot<Foo> cannot be passed. This should be:

add<T>(documentSnapshot: DocumentSnapshot<T>): BundleBuilder;

Same for QuerySnapshot.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks.

@wu-hui wu-hui assigned schmidt-sebastian and unassigned wu-hui Nov 17, 2020
@@ -42,7 +40,7 @@ export class BundleBuilder {
// The latest read time among all bundled documents and queries.
private latestReadTime = new Timestamp(0, 0);

constructor(private bundleId: string) {}
constructor(public readonly bundleId: string) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TS style guide recommends using only "readonly" instead of "public readonly" as they are equivalent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

* a bundle.
*
* @param bundleId The ID of the bundle. When loaded on clients, client SDKs use this ID
* and the timestamp associated with the built bundle to tell if it has been loaded already.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* and the timestamp associated with the built bundle to tell if it has been loaded already.
* and the timestamp associated with the bundle to tell if it has been loaded already.

or:

     * and bundle's timestamp associated to tell if the bundle has been loaded already.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


/**
* Adds a Firestore document snapshot or query snapshot to the bundle.
* Both the documents data and the query read time will be included in the bundle.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should only apply to DocumentSnapshots.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

* Adds a Firestore document snapshot or query snapshot to the bundle.
* Both the documents data and the query read time will be included in the bundle.
*
* @param documentSnapshot A document snapshot to add.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param documentSnapshot A document snapshot to add.
* @param documentSnapshot A `DocumentSnapshot` to add.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

* @param {DocumentSnapshot=} documentSnapshot A document snapshot to add.
* @returns {BundleBuilder} This instance.
*/
add(documentSnapshot: DocumentSnapshot): BundleBuilder;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is actually no such thing as a non-generic DocumentSnapshot in our API. The DocumentSnapshot type defaults to DocumentSnapshot<DocumentData>, which means that a custom type such as DocumentSnapshot<Foo> cannot be passed. This should be:

add<T>(documentSnapshot: DocumentSnapshot<T>): BundleBuilder;

Same for QuerySnapshot.

Comment on lines 1936 to 1937
* Adds a Firestore document snapshot or query snapshot to the bundle.
* Both the documents data and the query read time will be included in the bundle.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update to only refer to QuerySnapshots.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

add(queryName: string, querySnapshot: QuerySnapshot): BundleBuilder;

/**
* Builds the bundle into a `Buffer` instance.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe:

Suggested change
* Builds the bundle into a `Buffer` instance.
* Builds the bundle and returns the result as a`Buffer` instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


/**
* Adds a Firestore document snapshot or query snapshot to the bundle.
* Both the documents data and the query read time will be included in the bundle.
* Adds a Firestore query snapshot to the bundle. Both the query data and the query read time
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are also adding the resulting documents, no?

s/query snapshot/QuerySnapshot

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -1924,26 +1924,26 @@ declare namespace FirebaseFirestore {
readonly bundleId: string;

/**
* Adds a Firestore document snapshot or query snapshot to the bundle.
* Both the documents data and the query read time will be included in the bundle.
* Adds a Firestore document snapshot to the bundle. Both the documents data and the document
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/document snapshot/DocumentSnapshot

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@schmidt-sebastian schmidt-sebastian removed their assignment Nov 17, 2020
@wu-hui wu-hui merged commit bae82dd into master Dec 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the googleapis/nodejs-firestore API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants