diff --git a/.appveyor.yml b/.appveyor.yml index f91b2522b..240821526 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,6 +1,4 @@ environment: - GOOGLE_APPLICATION_CREDENTIALS: build/test/fake-certificate.json - matrix: - nodejs_version: 8 diff --git a/.circleci/config.yml b/.circleci/config.yml index 80dcf7e67..2209b374e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -128,7 +128,7 @@ jobs: name: Run sample tests. command: npm run samples-test environment: - GCLOUD_PROJECT: long-door-651 + GCLOUD_PROJECT: node-gcloud-ci GOOGLE_APPLICATION_CREDENTIALS: /home/node/samples/.circleci/key.json NPM_CONFIG_PREFIX: /home/node/.npm-global - run: @@ -149,21 +149,24 @@ jobs: name: Decrypt credentials. command: | if ! [[ -z "${SYSTEM_TESTS_ENCRYPTION_KEY}" ]]; then - openssl aes-256-cbc -d -in .circleci/key.json.enc \ - -out .circleci/key.json \ - -k "${SYSTEM_TESTS_ENCRYPTION_KEY}" + for encrypted_key in .circleci/*.json.enc; do + openssl aes-256-cbc -d -in $encrypted_key \ + -out $(echo $encrypted_key | sed 's/\.enc//') \ + -k "${SYSTEM_TESTS_ENCRYPTION_KEY}" + done fi - run: *npm_install_and_link - run: name: Run system tests. command: npm run system-test environment: + GCLOUD_PROJECT: node-gcloud-ci GOOGLE_APPLICATION_CREDENTIALS: .circleci/key.json - run: name: Remove unencrypted key. command: | if ! [[ -z "${SYSTEM_TESTS_ENCRYPTION_KEY}" ]]; then - rm .circleci/key.json + rm .circleci/*.json fi when: always publish_npm: diff --git a/.eslintrc.yml b/.eslintrc.yml new file mode 100644 index 000000000..bed57fbc4 --- /dev/null +++ b/.eslintrc.yml @@ -0,0 +1,13 @@ +--- +extends: + - 'eslint:recommended' + - 'plugin:node/recommended' + - prettier +plugins: + - node + - prettier +rules: + prettier/prettier: error + block-scoped-var: error + eqeqeq: error + no-warning-comments: warn diff --git a/.jsdoc.js b/.jsdoc.js index ab57dca20..f9ab8d4f9 100644 --- a/.jsdoc.js +++ b/.jsdoc.js @@ -1,5 +1,5 @@ /*! - * Copyright 2017 Google Inc. All Rights Reserved. + * Copyright 2018 Google LLC. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ module.exports = { includePattern: '\\.js$' }, templates: { - copyright: 'Copyright 2017 Google, Inc.', + copyright: 'Copyright 2018 Google, LLC.', includeDate: false, sourceFiles: false, systemName: '@google-cloud/firestore', diff --git a/.kokoro/common.cfg b/.kokoro/common.cfg new file mode 100644 index 000000000..1a8cb95e4 --- /dev/null +++ b/.kokoro/common.cfg @@ -0,0 +1,24 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "nodejs-firestore/.kokoro/trampoline.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/node:10-user" +} +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-firestore/.kokoro/test.sh" +} diff --git a/.kokoro/continuous/node10/common.cfg b/.kokoro/continuous/node10/common.cfg new file mode 100644 index 000000000..1a8cb95e4 --- /dev/null +++ b/.kokoro/continuous/node10/common.cfg @@ -0,0 +1,24 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "nodejs-firestore/.kokoro/trampoline.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/node:10-user" +} +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-firestore/.kokoro/test.sh" +} diff --git a/.kokoro/continuous/node10/test.cfg b/.kokoro/continuous/node10/test.cfg new file mode 100644 index 000000000..e69de29bb diff --git a/.kokoro/continuous/node6/common.cfg b/.kokoro/continuous/node6/common.cfg new file mode 100644 index 000000000..2a096264c --- /dev/null +++ b/.kokoro/continuous/node6/common.cfg @@ -0,0 +1,24 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "nodejs-firestore/.kokoro/trampoline.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/node:6-user" +} +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-firestore/.kokoro/test.sh" +} diff --git a/.kokoro/continuous/node6/test.cfg b/.kokoro/continuous/node6/test.cfg new file mode 100644 index 000000000..e69de29bb diff --git a/.kokoro/continuous/node8/common.cfg b/.kokoro/continuous/node8/common.cfg new file mode 100644 index 000000000..21659d8ad --- /dev/null +++ b/.kokoro/continuous/node8/common.cfg @@ -0,0 +1,24 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "nodejs-firestore/.kokoro/trampoline.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/node:8-user" +} +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-firestore/.kokoro/test.sh" +} diff --git a/.kokoro/continuous/node8/docs.cfg b/.kokoro/continuous/node8/docs.cfg new file mode 100644 index 000000000..f3ec34b9a --- /dev/null +++ b/.kokoro/continuous/node8/docs.cfg @@ -0,0 +1,4 @@ +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-firestore/.kokoro/docs.sh" +} diff --git a/.kokoro/continuous/node8/lint.cfg b/.kokoro/continuous/node8/lint.cfg new file mode 100644 index 000000000..17e5e331c --- /dev/null +++ b/.kokoro/continuous/node8/lint.cfg @@ -0,0 +1,4 @@ +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-firestore/.kokoro/lint.sh" +} diff --git a/.kokoro/continuous/node8/samples-test.cfg b/.kokoro/continuous/node8/samples-test.cfg new file mode 100644 index 000000000..bfe5e16df --- /dev/null +++ b/.kokoro/continuous/node8/samples-test.cfg @@ -0,0 +1,7 @@ +# Download resources for system tests (service account key, etc.) +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-firestore/.kokoro/samples-test.sh" +} diff --git a/.kokoro/continuous/node8/system-test.cfg b/.kokoro/continuous/node8/system-test.cfg new file mode 100644 index 000000000..6a42e89fa --- /dev/null +++ b/.kokoro/continuous/node8/system-test.cfg @@ -0,0 +1,7 @@ +# Download resources for system tests (service account key, etc.) +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-firestore/.kokoro/system-test.sh" +} diff --git a/.kokoro/continuous/node8/test.cfg b/.kokoro/continuous/node8/test.cfg new file mode 100644 index 000000000..e69de29bb diff --git a/.kokoro/docs.sh b/.kokoro/docs.sh new file mode 100755 index 000000000..3af319341 --- /dev/null +++ b/.kokoro/docs.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -xeo pipefail + +export NPM_CONFIG_PREFIX=/home/node/.npm-global + +cd $(dirname $0)/.. + +npm install + +npm run docs diff --git a/.kokoro/lint.sh b/.kokoro/lint.sh new file mode 100755 index 000000000..7c2ea2a28 --- /dev/null +++ b/.kokoro/lint.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -xeo pipefail + +export NPM_CONFIG_PREFIX=/home/node/.npm-global + +cd $(dirname $0)/.. + +npm install + +# Install and link samples +cd samples/ +npm link ../ +npm install +cd .. + +npm run lint diff --git a/.kokoro/presubmit/node10/common.cfg b/.kokoro/presubmit/node10/common.cfg new file mode 100644 index 000000000..1a8cb95e4 --- /dev/null +++ b/.kokoro/presubmit/node10/common.cfg @@ -0,0 +1,24 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "nodejs-firestore/.kokoro/trampoline.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/node:10-user" +} +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-firestore/.kokoro/test.sh" +} diff --git a/.kokoro/presubmit/node10/test.cfg b/.kokoro/presubmit/node10/test.cfg new file mode 100644 index 000000000..e69de29bb diff --git a/.kokoro/presubmit/node6/common.cfg b/.kokoro/presubmit/node6/common.cfg new file mode 100644 index 000000000..2a096264c --- /dev/null +++ b/.kokoro/presubmit/node6/common.cfg @@ -0,0 +1,24 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "nodejs-firestore/.kokoro/trampoline.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/node:6-user" +} +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-firestore/.kokoro/test.sh" +} diff --git a/.kokoro/presubmit/node6/test.cfg b/.kokoro/presubmit/node6/test.cfg new file mode 100644 index 000000000..e69de29bb diff --git a/.kokoro/presubmit/node8/common.cfg b/.kokoro/presubmit/node8/common.cfg new file mode 100644 index 000000000..21659d8ad --- /dev/null +++ b/.kokoro/presubmit/node8/common.cfg @@ -0,0 +1,24 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "nodejs-firestore/.kokoro/trampoline.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/node:8-user" +} +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-firestore/.kokoro/test.sh" +} diff --git a/.kokoro/presubmit/node8/docs.cfg b/.kokoro/presubmit/node8/docs.cfg new file mode 100644 index 000000000..f3ec34b9a --- /dev/null +++ b/.kokoro/presubmit/node8/docs.cfg @@ -0,0 +1,4 @@ +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-firestore/.kokoro/docs.sh" +} diff --git a/.kokoro/presubmit/node8/lint.cfg b/.kokoro/presubmit/node8/lint.cfg new file mode 100644 index 000000000..17e5e331c --- /dev/null +++ b/.kokoro/presubmit/node8/lint.cfg @@ -0,0 +1,4 @@ +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-firestore/.kokoro/lint.sh" +} diff --git a/.kokoro/presubmit/node8/test.cfg b/.kokoro/presubmit/node8/test.cfg new file mode 100644 index 000000000..e69de29bb diff --git a/.kokoro/presubmit/windows/common.cfg b/.kokoro/presubmit/windows/common.cfg new file mode 100644 index 000000000..7320db792 --- /dev/null +++ b/.kokoro/presubmit/windows/common.cfg @@ -0,0 +1,9 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + diff --git a/.kokoro/presubmit/windows/test.cfg b/.kokoro/presubmit/windows/test.cfg new file mode 100644 index 000000000..1b333c87a --- /dev/null +++ b/.kokoro/presubmit/windows/test.cfg @@ -0,0 +1,2 @@ +# Use the test file directly +build_file: "nodejs-firestore/.kokoro/test.bat" diff --git a/.kokoro/samples-test.sh b/.kokoro/samples-test.sh new file mode 100755 index 000000000..787e4fc49 --- /dev/null +++ b/.kokoro/samples-test.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -xeo pipefail + +export NPM_CONFIG_PREFIX=/home/node/.npm-global + +# Setup service account credentials. +export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json +export GCLOUD_PROJECT=node-gcloud-ci + +cd $(dirname $0)/.. + +npm install + +# Install and link samples +cd samples/ +npm link ../ +npm install +cd .. + +npm run samples-test diff --git a/.kokoro/system-test.sh b/.kokoro/system-test.sh new file mode 100755 index 000000000..1c2eba661 --- /dev/null +++ b/.kokoro/system-test.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -xeo pipefail + +export NPM_CONFIG_PREFIX=/home/node/.npm-global + +# Setup service account credentials. +export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json +export GCLOUD_PROJECT=node-gcloud-ci + +cd $(dirname $0)/.. + +# Run a pre-test hook, if a pre-system-test.sh is in the project +if [ -f .kokoro/pre-system-test.sh ]; then + . .kokoro/pre-system-test.sh +fi + +npm install + +npm run system-test diff --git a/.kokoro/test.bat b/.kokoro/test.bat new file mode 100644 index 000000000..a8534ba80 --- /dev/null +++ b/.kokoro/test.bat @@ -0,0 +1,26 @@ +@rem Copyright 2018 gRPC authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem http://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. + +@echo "Starting Windows build" + +cd /d %~dp0 +cd .. + +call npm install || goto :error +call npm run test || goto :error + +goto :EOF + +:error +exit /b 1 diff --git a/.kokoro/test.sh b/.kokoro/test.sh new file mode 100755 index 000000000..51f29589b --- /dev/null +++ b/.kokoro/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -xeo pipefail + +export NPM_CONFIG_PREFIX=/home/node/.npm-global + +cd $(dirname $0)/.. + +npm install +npm test +node_modules/.bin/codecov diff --git a/.kokoro/trampoline.sh b/.kokoro/trampoline.sh new file mode 100755 index 000000000..87ffd2ca9 --- /dev/null +++ b/.kokoro/trampoline.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# Copyright 2017 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -xeo pipefail + +# Always run the cleanup script, regardless of the success of bouncing into +# the container. +function cleanup() { + chmod +x ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh + ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh + echo "cleanup"; +} +trap cleanup EXIT + +python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py" diff --git a/.nycrc b/.nycrc index 2b29e2b8c..a1a8e6920 100644 --- a/.nycrc +++ b/.nycrc @@ -1,10 +1,9 @@ { "report-dir": "./.coverage", "exclude": [ - "build/src/*{/*,/**/*}.js", - "build/src/*/v*/*.js", - "build/protos/*.js", - "build/test/**/*.js" + "src/*{/*,/**/*}.js", + "src/*/v*/*.js", + "test/**/*.js" ], "watermarks": { "branches": [ diff --git a/dev/src/index.js b/dev/src/index.js index ea2efa39b..3664c41b9 100644 --- a/dev/src/index.js +++ b/dev/src/index.js @@ -777,10 +777,10 @@ follow these steps, YOUR APP MAY BREAK.`); const clientPool = new ClientPool(MAX_CONCURRENT_REQUESTS_PER_CLIENT, () => { - const gapicClient = - module.exports.v1beta1(this._initalizationSettings); + const client = + new module.exports.v1beta1(this._initalizationSettings); logger('Firestore', null, 'Initialized Firestore GAPIC Client'); - return gapicClient; + return client; }); const projectIdProvided = this._referencePath.projectId !== '{{projectId}}'; diff --git a/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_document.js b/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_document.js index 94f797b95..d5d23bc2f 100644 --- a/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_document.js +++ b/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_document.js @@ -30,7 +30,7 @@ * The map keys represent field names. * * A simple field name contains only characters `a` to `z`, `A` to `Z`, - * `0` to `9`, or `_`, and must not start with `0` to `9` or `_`. For example, + * `0` to `9`, or `_`, and must not start with `0` to `9`. For example, * `foo_bar_17`. * * Field names matching the regular expression `__.*__` are reserved. Reserved @@ -63,7 +63,7 @@ * @property {Object} updateTime * Output only. The time at which the document was last changed. * - * This value is initally set to the `create_time` then increases + * This value is initially set to the `create_time` then increases * monotonically with each change to the document. It can also be * compared to values from other documents and the `read_time` of a query. * @@ -131,7 +131,8 @@ var Document = { * @property {Object} arrayValue * An array value. * - * Cannot contain another array value. + * Cannot directly contain another array value, though can contain an + * map which contains another array. * * This object should have the same structure as [ArrayValue]{@link * google.firestore.v1beta1.ArrayValue} diff --git a/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_query.js b/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_query.js index 9e24516c3..6f12cf3db 100644 --- a/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_query.js +++ b/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_query.js @@ -250,7 +250,12 @@ var StructuredQuery = { /** * Equal. */ - EQUAL: 5 + EQUAL: 5, + + /** + * Contains. Requires that the field is an array. + */ + ARRAY_CONTAINS: 7 } }, diff --git a/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_write.js b/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_write.js index 447796cc7..9e049f1c7 100644 --- a/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_write.js +++ b/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_write.js @@ -41,9 +41,10 @@ * The fields to update in this write. * * This field can be set only when the operation is `update`. - * None of the field paths in the mask may contain a reserved name. - * If the document exists on the server and has fields not referenced in the - * mask, they are left unchanged. + * If the mask is not set for an `update` and the document exists, any + * existing data will be overwritten. + * If the mask is set and the document on the server has fields not covered by + * the mask, they are left unchanged. * Fields referenced in the mask, but not present in the input document, are * deleted from the document on the server. * The field paths in this mask must not contain a reserved field name. @@ -101,6 +102,38 @@ var DocumentTransform = { * The number should be among the values of [ServerValue]{@link * google.firestore.v1beta1.ServerValue} * + * @property {Object} appendMissingElements + * Append the given elements in order if they are not already present in + * the current field value. + * If the field is not an array, or if the field does not yet exist, it is + * first set to the empty array. + * + * Equivalent numbers of different types (e.g. 3L and 3.0) are + * considered equal when checking if a value is missing. + * NaN is equal to NaN, and Null is equal to Null. + * If the input contains multiple equivalent values, only the first will + * be considered. + * + * The corresponding transform_result will be the null value. + * + * This object should have the same structure as [ArrayValue]{@link + * google.firestore.v1beta1.ArrayValue} + * + * @property {Object} removeAllFromArray + * Remove all of the given elements from the array in the field. + * If the field is not an array, or if the field does not yet exist, it is + * set to the empty array. + * + * Equivalent numbers of the different types (e.g. 3L and 3.0) are + * considered equal when deciding whether an element should be removed. + * NaN is equal to NaN, and Null is equal to Null. + * This will remove all equivalent values if there are duplicates. + * + * The corresponding transform_result will be the null value. + * + * This object should have the same structure as [ArrayValue]{@link + * google.firestore.v1beta1.ArrayValue} + * * @typedef FieldTransform * @memberof google.firestore.v1beta1 * @see [google.firestore.v1beta1.DocumentTransform.FieldTransform definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/write.proto} diff --git a/dev/src/v1beta1/doc/google/protobuf/doc_any.js b/dev/src/v1beta1/doc/google/protobuf/doc_any.js index d24ff32c4..c08235030 100644 --- a/dev/src/v1beta1/doc/google/protobuf/doc_any.js +++ b/dev/src/v1beta1/doc/google/protobuf/doc_any.js @@ -97,17 +97,18 @@ * } * * @property {string} typeUrl - * A URL/resource name whose content describes the type of the - * serialized protocol buffer message. + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). * - * For URLs which use the scheme `http`, `https`, or no scheme, the - * following restrictions and interpretations apply: + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: * * * If no scheme is provided, `https` is assumed. - * * The last segment of the URL's path must represent the fully - * qualified name of the type (as in `path/google.protobuf.Duration`). - * The name should be in a canonical form (e.g., leading "." is - * not accepted). * * An HTTP GET on the URL must yield a google.protobuf.Type * value in binary format, or produce an error. * * Applications are allowed to cache lookup results based on the @@ -116,6 +117,10 @@ * on changes to types. (Use versioned type names to manage * breaking changes.) * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * * Schemes other than `http`, `https` (or the empty scheme) might be * used with implementation specific semantics. * diff --git a/dev/src/v1beta1/doc/google/protobuf/doc_timestamp.js b/dev/src/v1beta1/doc/google/protobuf/doc_timestamp.js index b17b32de9..2d0a17cbf 100644 --- a/dev/src/v1beta1/doc/google/protobuf/doc_timestamp.js +++ b/dev/src/v1beta1/doc/google/protobuf/doc_timestamp.js @@ -80,7 +80,9 @@ * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone - * is required, though only UTC (as indicated by "Z") is presently supported. + * is required. A proto3 JSON serializer should always use UTC (as indicated by + * "Z") when printing the Timestamp type and a proto3 JSON parser should be + * able to accept both UTC and other timezones (as indicated by an offset). * * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past * 01:30 UTC on January 15, 2017. @@ -93,8 +95,8 @@ * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use * the Joda Time's [`ISODateTimeFormat.dateTime()`](https://cloud.google.com - * http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()) - * to obtain a formatter capable of generating timestamps in this format. + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime-- + * ) to obtain a formatter capable of generating timestamps in this format. * * @property {number} seconds * Represents seconds of UTC time since Unix epoch diff --git a/dev/src/v1beta1/firestore_client.js b/dev/src/v1beta1/firestore_client.js index 16abf775c..eee2462f2 100644 --- a/dev/src/v1beta1/firestore_client.js +++ b/dev/src/v1beta1/firestore_client.js @@ -526,7 +526,7 @@ class FirestoreClient { return this._descriptors.page.listDocuments.createStream( this._innerApiCalls.listDocuments, request, options); - } + }; /** * Creates a new document. @@ -1287,7 +1287,7 @@ class FirestoreClient { return this._descriptors.page.listCollectionIds.createStream( this._innerApiCalls.listCollectionIds, request, options); - } + }; // -------------------- // -- Path templates -- @@ -1484,4 +1484,5 @@ class FirestoreClient { } } + module.exports = FirestoreClient; diff --git a/dev/src/v1beta1/firestore_client_config.json b/dev/src/v1beta1/firestore_client_config.json index 53a379c2e..4c15ed4e8 100644 --- a/dev/src/v1beta1/firestore_client_config.json +++ b/dev/src/v1beta1/firestore_client_config.json @@ -24,8 +24,8 @@ "max_retry_delay_millis": 60000, "initial_rpc_timeout_millis": 300000, "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 86400000, - "total_timeout_millis": 86400000 + "max_rpc_timeout_millis": 300000, + "total_timeout_millis": 600000 } }, "methods": { @@ -55,7 +55,7 @@ "retry_params_name": "default" }, "BatchGetDocuments": { - "timeout_millis": 86400000, + "timeout_millis": 300000, "retry_codes_name": "idempotent", "retry_params_name": "streaming" }, @@ -75,12 +75,12 @@ "retry_params_name": "default" }, "RunQuery": { - "timeout_millis": 86400000, + "timeout_millis": 60000, "retry_codes_name": "idempotent", "retry_params_name": "default" }, "Write": { - "timeout_millis": 300000, + "timeout_millis": 86400000, "retry_codes_name": "non_idempotent", "retry_params_name": "streaming" }, diff --git a/dev/src/v1beta1/index.js b/dev/src/v1beta1/index.js index 17fc42007..a09e6b18c 100644 --- a/dev/src/v1beta1/index.js +++ b/dev/src/v1beta1/index.js @@ -1,35 +1,19 @@ -/* - * Copyright 2017, Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -'use strict'; - -var firestoreClient = require('./firestore_client'); -var gax = require('google-gax'); -var extend = require('extend'); +// Copyright 2018 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. -function v1beta1(options) { - options = extend( - { - scopes: v1beta1.ALL_SCOPES, - }, - options); - var gaxGrpc = new gax.GrpcClient(options); - return new firestoreClient(gaxGrpc); -} +'use strict'; -v1beta1.SERVICE_ADDRESS = firestoreClient.SERVICE_ADDRESS; -v1beta1.ALL_SCOPES = firestoreClient.ALL_SCOPES; +const FirestoreClient = require('./firestore_client'); -module.exports = v1beta1; +module.exports = FirestoreClient; diff --git a/dev/test/gapic-v1beta1.js b/dev/test/gapic-v1beta1.js index e2f72deb0..ea105ead3 100644 --- a/dev/test/gapic-v1beta1.js +++ b/dev/test/gapic-v1beta1.js @@ -74,7 +74,7 @@ describe('FirestoreClient', () => { client.getDocument(request, (err, response) => { assert(err instanceof Error); - assert.equal(err.code, FAKE_STATUS_CODE); + assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); done(); }); @@ -141,7 +141,7 @@ describe('FirestoreClient', () => { client.listDocuments(request, (err, response) => { assert(err instanceof Error); - assert.equal(err.code, FAKE_STATUS_CODE); + assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); done(); }); @@ -210,7 +210,7 @@ describe('FirestoreClient', () => { client.createDocument(request, (err, response) => { assert(err instanceof Error); - assert.equal(err.code, FAKE_STATUS_CODE); + assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); done(); }); @@ -269,7 +269,7 @@ describe('FirestoreClient', () => { client.updateDocument(request, (err, response) => { assert(err instanceof Error); - assert.equal(err.code, FAKE_STATUS_CODE); + assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); done(); }); @@ -318,7 +318,7 @@ describe('FirestoreClient', () => { client.deleteDocument(request, err => { assert(err instanceof Error); - assert.equal(err.code, FAKE_STATUS_CODE); + assert.strictEqual(err.code, FAKE_STATUS_CODE); done(); }); }); @@ -389,7 +389,7 @@ describe('FirestoreClient', () => { }); stream.on('error', err => { assert(err instanceof Error); - assert.equal(err.code, FAKE_STATUS_CODE); + assert.strictEqual(err.code, FAKE_STATUS_CODE); done(); }); @@ -447,7 +447,7 @@ describe('FirestoreClient', () => { client.beginTransaction(request, (err, response) => { assert(err instanceof Error); - assert.equal(err.code, FAKE_STATUS_CODE); + assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); done(); }); @@ -504,7 +504,7 @@ describe('FirestoreClient', () => { client.commit(request, (err, response) => { assert(err instanceof Error); - assert.equal(err.code, FAKE_STATUS_CODE); + assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); done(); }); @@ -557,7 +557,7 @@ describe('FirestoreClient', () => { client.rollback(request, err => { assert(err instanceof Error); - assert.equal(err.code, FAKE_STATUS_CODE); + assert.strictEqual(err.code, FAKE_STATUS_CODE); done(); }); }); @@ -624,7 +624,7 @@ describe('FirestoreClient', () => { }); stream.on('error', err => { assert(err instanceof Error); - assert.equal(err.code, FAKE_STATUS_CODE); + assert.strictEqual(err.code, FAKE_STATUS_CODE); done(); }); @@ -695,7 +695,7 @@ describe('FirestoreClient', () => { }) .on('error', err => { assert(err instanceof Error); - assert.equal(err.code, FAKE_STATUS_CODE); + assert.strictEqual(err.code, FAKE_STATUS_CODE); done(); }); @@ -761,7 +761,7 @@ describe('FirestoreClient', () => { }) .on('error', err => { assert(err instanceof Error); - assert.equal(err.code, FAKE_STATUS_CODE); + assert.strictEqual(err.code, FAKE_STATUS_CODE); done(); }); @@ -825,7 +825,7 @@ describe('FirestoreClient', () => { client.listCollectionIds(request, (err, response) => { assert(err instanceof Error); - assert.equal(err.code, FAKE_STATUS_CODE); + assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); done(); }); @@ -871,5 +871,5 @@ function mockBidiStreamingGrpcMethod(expectedRequest, response, error) { } }); return mockStream; - }; + } } diff --git a/dev/test/util/helpers.ts b/dev/test/util/helpers.ts index 948504524..040ab76c6 100644 --- a/dev/test/util/helpers.ts +++ b/dev/test/util/helpers.ts @@ -21,7 +21,7 @@ import {GrpcClient} from 'google-gax'; import {google} from '../../protos/firestore_proto_api'; import api = google.firestore.v1beta1; -import v1beta1 from '../../src/v1beta1'; +const v1beta1 = require('../../src/v1beta1'); // TODO: This should be a TypeScript import after the full migration. import Firestore = require('../../src'); @@ -91,7 +91,7 @@ export function createInstance( firestore.settings(initializationOptions); const clientPool = new ClientPool(/* concurrentRequestLimit= */ 1, () => { - const gapicClient: GapicClient = v1beta1(initializationOptions); + const gapicClient: GapicClient = new v1beta1(initializationOptions); if (apiOverrides) { Object.keys(apiOverrides).forEach(override => { gapicClient._innerApiCalls[override] = apiOverrides[override]; diff --git a/package.json b/package.json index 4c04742d6..2c3b0410b 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "docs": "jsdoc -c .jsdoc.js", "generate-scaffolding": "repo-tools generate all", "system-test": "mocha build/system-test --timeout 600000", + "samples-test": "npm link && cd samples/ && npm link ../ && npm test && cd ../", "conformance": "mocha build/conformance", "test-only": "nyc mocha build/test", "test": "npm run test-only", diff --git a/synth.py b/synth.py index 1b812abe2..94549b3bd 100644 --- a/synth.py +++ b/synth.py @@ -9,26 +9,39 @@ # tasks has two product names, and a poorly named artman yaml library = gapic.node_library( - 'firestore', 'v1beta1', - config_path='/google/firestore/artman_firestore.yaml') + "firestore", "v1beta1", config_path="/google/firestore/artman_firestore.yaml" +) # skip index, protos, package.json, and README.md -s.copy( - library, - 'dev', - excludes=['package.json', 'README.md', 'src/index.js', - 'src/v1beta1/index.js']) +s.copy(library, "dev", excludes=["package.json", "README.md", "src/index.js"]) +# package.json is one level deeper since firestore's src/ is under dev/ s.replace( - 'dev/test/gapic-v1beta1.js', - 'new firestoreModule.v1beta1.FirestoreClient\(', - 'new firestoreModule.v1beta1(') + "dev/src/v1beta1/firestore_client.js", "../../package.json", "../../../package.json" +) + +# Special case for firestore: FirestoreClient is exported as top level module.exports +# from gapic-generated code +s.replace( + "dev/src/v1beta1/index.js", + "module.exports.FirestoreClient = FirestoreClient", + "module.exports = FirestoreClient", +) + +s.replace( + "dev/test/gapic-v1beta1.js", + "new firestoreModule.v1beta1.FirestoreClient\(", + "new firestoreModule.v1beta1(", +) # Copy template files common_templates = gcp.CommonTemplates() -templates = common_templates.node_library() +templates = common_templates.node_library( + source_location="build/src", test_project="node-gcloud-ci" +) + s.copy(templates) # Node.js specific cleanup -subprocess.run(['npm', 'install']) -subprocess.run(['npm', 'run', 'fix']) +subprocess.run(["npm", "install"]) +subprocess.run(["npm", "run", "fix"])