Skip to content

Rejecting custom types from the API surface #137

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

Merged
merged 6 commits into from
Feb 16, 2018
Merged

Conversation

schmidt-sebastian
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian commented Feb 16, 2018

This cleans up our error handling for field values and adds better error messages for users that use types from other instances of the Firestore SDK.

As part of this (to get to 100% coverage), I re-added the test that transforms allPlainTypesObject into allPlainTypesProtobufJs. Along with the changes for #105, this meant adding support for missing (empty) array and object values.

@ghost ghost added the cla: yes This human has signed the Contributor License Agreement. label Feb 16, 2018
@schmidt-sebastian schmidt-sebastian changed the title Nonplaintypes Rejecting custom types from the API surface Feb 16, 2018
@schmidt-sebastian schmidt-sebastian mentioned this pull request Feb 16, 2018
@codecov
Copy link

codecov bot commented Feb 16, 2018

Codecov Report

Merging #137 into master will decrease coverage by 0.05%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #137      +/-   ##
==========================================
- Coverage     100%   99.94%   -0.06%     
==========================================
  Files          12       12              
  Lines        1668     1689      +21     
==========================================
+ Hits         1668     1688      +20     
- Misses          0        1       +1
Impacted Files Coverage Δ
src/path.js 100% <100%> (ø) ⬆️
src/reference.js 100% <100%> (ø) ⬆️
src/write-batch.js 100% <100%> (ø) ⬆️
src/validate.js 100% <100%> (ø) ⬆️
src/order.js 100% <100%> (ø) ⬆️
src/field-value.js 100% <100%> (ø) ⬆️
src/document.js 99.67% <100%> (-0.33%) ⬇️

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 843a5d1...e1592ed. Read the comment docs.

Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

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

Some random nits that you can just ignore.

src/document.js Outdated
options.allowDeletes === 'none'
) {
throw new Error(
'Deletes must appear at the top-level and can only be used in update() or set() with {merge:true}.'

This comment was marked as spam.

This comment was marked as spam.

src/document.js Outdated
} else if (obj === FieldValue.SERVER_TIMESTAMP_SENTINEL) {
if (!options.allowServerTimestamps) {
throw new Error(
'ServerTimestamps can only be used in update(), set() and create().'

This comment was marked as spam.

This comment was marked as spam.

src/document.js Outdated
Object.prototype.toString.call(val) +
') to a Firestore Value'
);
validate.throwCustomObjectError(val);

This comment was marked as spam.

This comment was marked as spam.

src/path.js Outdated
@@ -484,7 +484,7 @@ class FieldPath extends Path {
static validateFieldPath(fieldPath) {
if (!is.instanceof(fieldPath, FieldPath)) {
if (!is.string(fieldPath)) {
throw new Error(`Paths must be strings or FieldPath objects.`);
validate.throwCustomObjectError(fieldPath);

This comment was marked as spam.

This comment was marked as spam.

@schmidt-sebastian schmidt-sebastian merged commit 463fbfc into master Feb 16, 2018
@ghost ghost removed the cla: yes This human has signed the Contributor License Agreement. label Feb 16, 2018
@schmidt-sebastian schmidt-sebastian deleted the nonplaintypes branch June 26, 2018 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants