mirror of
				https://github.com/musix-org/musix-oss
				synced 2025-11-04 06:49:31 +00:00 
			
		
		
		
	Updated
This commit is contained in:
		
							
								
								
									
										440
									
								
								node_modules/@google-cloud/common/CHANGELOG.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										440
									
								
								node_modules/@google-cloud/common/CHANGELOG.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,440 @@
 | 
			
		||||
# Changelog
 | 
			
		||||
 | 
			
		||||
[npm history][1]
 | 
			
		||||
 | 
			
		||||
[1]: https://www.npmjs.com/package/@google-cloud/common?activeTab=versions
 | 
			
		||||
 | 
			
		||||
### [2.1.2](https://www.github.com/googleapis/nodejs-common/compare/v2.1.1...v2.1.2) (2019-08-14)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Bug Fixes
 | 
			
		||||
 | 
			
		||||
* **types:** correct internal timeout field type ([#470](https://www.github.com/googleapis/nodejs-common/issues/470)) ([e7dd206](https://www.github.com/googleapis/nodejs-common/commit/e7dd206))
 | 
			
		||||
* upgrade to version of teeny-request with looser types for method ([#472](https://www.github.com/googleapis/nodejs-common/issues/472)) ([143774c](https://www.github.com/googleapis/nodejs-common/commit/143774c))
 | 
			
		||||
 | 
			
		||||
### [2.1.1](https://www.github.com/googleapis/nodejs-common/compare/v2.1.0...v2.1.1) (2019-08-13)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Bug Fixes
 | 
			
		||||
 | 
			
		||||
* **deps:** teeny-request@5.2.0 with fixes for http ([#467](https://www.github.com/googleapis/nodejs-common/issues/467)) ([e11d46c](https://www.github.com/googleapis/nodejs-common/commit/e11d46c))
 | 
			
		||||
 | 
			
		||||
## [2.1.0](https://www.github.com/googleapis/nodejs-common/compare/v2.0.5...v2.1.0) (2019-08-05)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Bug Fixes
 | 
			
		||||
 | 
			
		||||
* **deps:** upgrade to the latest version of teeny-request ([#448](https://www.github.com/googleapis/nodejs-common/issues/448)) ([bb76f07](https://www.github.com/googleapis/nodejs-common/commit/bb76f07))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Features
 | 
			
		||||
 | 
			
		||||
* adds timeout to options and use it in reqOpts ([#455](https://www.github.com/googleapis/nodejs-common/issues/455)) ([90a6097](https://www.github.com/googleapis/nodejs-common/commit/90a6097))
 | 
			
		||||
 | 
			
		||||
### [2.0.5](https://www.github.com/googleapis/nodejs-common/compare/v2.0.4...v2.0.5) (2019-07-29)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Bug Fixes
 | 
			
		||||
 | 
			
		||||
* **deps:** update dependency google-auth-library to v5 ([#453](https://www.github.com/googleapis/nodejs-common/issues/453)) ([755635c](https://www.github.com/googleapis/nodejs-common/commit/755635c))
 | 
			
		||||
 | 
			
		||||
### [2.0.4](https://www.github.com/googleapis/nodejs-common/compare/v2.0.3...v2.0.4) (2019-07-11)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Bug Fixes
 | 
			
		||||
 | 
			
		||||
* allow methodConfig to override request method and uri ([#451](https://www.github.com/googleapis/nodejs-common/issues/451)) ([8c2f903](https://www.github.com/googleapis/nodejs-common/commit/8c2f903))
 | 
			
		||||
 | 
			
		||||
### [2.0.3](https://www.github.com/googleapis/nodejs-common/compare/v2.0.2...v2.0.3) (2019-06-26)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Bug Fixes
 | 
			
		||||
 | 
			
		||||
* **docs:** link to reference docs section on googleapis.dev ([#443](https://www.github.com/googleapis/nodejs-common/issues/443)) ([11ccb28](https://www.github.com/googleapis/nodejs-common/commit/11ccb28))
 | 
			
		||||
 | 
			
		||||
### [2.0.2](https://www.github.com/googleapis/nodejs-common/compare/v2.0.1...v2.0.2) (2019-06-14)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Bug Fixes
 | 
			
		||||
 | 
			
		||||
* **docs:** move to new client docs URL ([#438](https://www.github.com/googleapis/nodejs-common/issues/438)) ([1a52715](https://www.github.com/googleapis/nodejs-common/commit/1a52715))
 | 
			
		||||
 | 
			
		||||
### [2.0.1](https://www.github.com/googleapis/nodejs-common/compare/v2.0.0...v2.0.1) (2019-06-11)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Bug Fixes
 | 
			
		||||
 | 
			
		||||
* **deps:** teeny-request was retrying some requests in error ([#436](https://www.github.com/googleapis/nodejs-common/issues/436)) ([00a8ba2](https://www.github.com/googleapis/nodejs-common/commit/00a8ba2))
 | 
			
		||||
 | 
			
		||||
## [2.0.0](https://www.github.com/googleapis/nodejs-common/compare/v1.0.0...v2.0.0) (2019-05-23)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### ⚠ BREAKING CHANGES
 | 
			
		||||
 | 
			
		||||
* This adds the apiEndpoint property as a required field for the ServiceConfig, and makes it a public property on the Service class. This is being added to broadly support apiEndpoint overrides.
 | 
			
		||||
 | 
			
		||||
### Features
 | 
			
		||||
 | 
			
		||||
* add apiEndpoint property to service config ([#427](https://www.github.com/googleapis/nodejs-common/issues/427)) ([c063df8](https://www.github.com/googleapis/nodejs-common/commit/c063df8)), closes [googleapis/nodejs-bigquery#455](https://www.github.com/googleapis/nodejs-common/issues/455)
 | 
			
		||||
 | 
			
		||||
## [1.0.0](https://www.github.com/googleapis/nodejs-common/compare/v0.32.1...v1.0.0) (2019-05-09)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Bug Fixes
 | 
			
		||||
 | 
			
		||||
* **deps:** update dependency @google-cloud/projectify to v1 ([#414](https://www.github.com/googleapis/nodejs-common/issues/414)) ([6cdc2fe](https://www.github.com/googleapis/nodejs-common/commit/6cdc2fe))
 | 
			
		||||
* **deps:** update dependency @google-cloud/promisify to v1 ([#415](https://www.github.com/googleapis/nodejs-common/issues/415)) ([00c422a](https://www.github.com/googleapis/nodejs-common/commit/00c422a))
 | 
			
		||||
* **deps:** update dependency google-auth-library to v4 ([#422](https://www.github.com/googleapis/nodejs-common/issues/422)) ([e0a94af](https://www.github.com/googleapis/nodejs-common/commit/e0a94af))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Build System
 | 
			
		||||
 | 
			
		||||
* upgrade engines field to >=8.10.0 ([#412](https://www.github.com/googleapis/nodejs-common/issues/412)) ([4349d68](https://www.github.com/googleapis/nodejs-common/commit/4349d68))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Miscellaneous Chores
 | 
			
		||||
 | 
			
		||||
* **deps:** update dependency gts to v1 ([#407](https://www.github.com/googleapis/nodejs-common/issues/407)) ([8e73d8c](https://www.github.com/googleapis/nodejs-common/commit/8e73d8c))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### BREAKING CHANGES
 | 
			
		||||
 | 
			
		||||
* **deps:** this will ship async/await in the generated code
 | 
			
		||||
* upgrade engines field to >=8.10.0 (#412)
 | 
			
		||||
 | 
			
		||||
## v0.32.1
 | 
			
		||||
 | 
			
		||||
04-08-2019 10:53 PDT
 | 
			
		||||
 | 
			
		||||
### Dependencies
 | 
			
		||||
 | 
			
		||||
- fix: teeny-request should be dependency
 | 
			
		||||
- fix(deps): update dependency arrify to v2 ([#404](https://github.com/googleapis/nodejs-common/pull/404))
 | 
			
		||||
- chore: unpin @types/node ([#402](https://github.com/googleapis/nodejs-common/pull/402))
 | 
			
		||||
 | 
			
		||||
## v0.32.0
 | 
			
		||||
 | 
			
		||||
04-02-2019 15:11 PDT
 | 
			
		||||
 | 
			
		||||
**BREAKING CHANGE**: This PR removes the ability to configure a custom implementation of the Request module. This was necessary when we were migrating from request to teeny-request, but that migration is now complete. All interfaces at accepted a custom implementation of request will no longer accept one. teeny-request is now just included in the box.
 | 
			
		||||
 | 
			
		||||
## Bug Fixes
 | 
			
		||||
 | 
			
		||||
- fix: @types/node@11.13.0 breaks paginate/promisifyAll ([#397](https://github.com/googleapis/nodejs-common/pull/397))
 | 
			
		||||
- fix(ts): do not ship @types/duplexify ([#393](https://github.com/googleapis/nodejs-common/pull/393))
 | 
			
		||||
- fix(deps): bump the min version required for all deps
 | 
			
		||||
 | 
			
		||||
### Implementation Changes
 | 
			
		||||
 | 
			
		||||
- refactor: remove configurable request ([#394](https://github.com/googleapis/nodejs-common/pull/394))
 | 
			
		||||
 | 
			
		||||
### Dependencies
 | 
			
		||||
 | 
			
		||||
- chore(deps): update dependency @types/tmp to v0.1.0
 | 
			
		||||
- chore(deps): update dependency typescript to ~3.4.0
 | 
			
		||||
- chore(deps): update dependency tmp to v0.1.0 ([#390](https://github.com/googleapis/nodejs-common/pull/390))
 | 
			
		||||
 | 
			
		||||
### Internal / Testing Changes
 | 
			
		||||
 | 
			
		||||
- build: use per-repo publish token ([#384](https://github.com/googleapis/nodejs-common/pull/384))
 | 
			
		||||
 | 
			
		||||
## v0.31.1
 | 
			
		||||
 | 
			
		||||
03-13-2019 16:25 PDT
 | 
			
		||||
 | 
			
		||||
### Bug Fixes
 | 
			
		||||
- fix(autoCreate): leave user options intact ([#378](https://github.com/googleapis/nodejs-common/pull/378))
 | 
			
		||||
 | 
			
		||||
### Dependencies
 | 
			
		||||
- fix(deps): update dependency @google-cloud/promisify to ^0.4.0 ([#374](https://github.com/googleapis/nodejs-common/pull/374))
 | 
			
		||||
 | 
			
		||||
### Documentation
 | 
			
		||||
- docs: update links in contrib guide ([#375](https://github.com/googleapis/nodejs-common/pull/375))
 | 
			
		||||
- docs: update contributing path in README ([#369](https://github.com/googleapis/nodejs-common/pull/369))
 | 
			
		||||
- docs: move CONTRIBUTING.md to root ([#368](https://github.com/googleapis/nodejs-common/pull/368))
 | 
			
		||||
 | 
			
		||||
### Internal / Testing Changes
 | 
			
		||||
- build: Add docuploader credentials to node publish jobs ([#381](https://github.com/googleapis/nodejs-common/pull/381))
 | 
			
		||||
- build: use node10 to run samples-test, system-test etc ([#380](https://github.com/googleapis/nodejs-common/pull/380))
 | 
			
		||||
- build: update release configuration
 | 
			
		||||
- chore(deps): update dependency mocha to v6
 | 
			
		||||
- test: do not depend on request ([#376](https://github.com/googleapis/nodejs-common/pull/376))
 | 
			
		||||
- build: use linkinator for docs test ([#372](https://github.com/googleapis/nodejs-common/pull/372))
 | 
			
		||||
- chore(deps): update dependency @types/tmp to v0.0.34 ([#373](https://github.com/googleapis/nodejs-common/pull/373))
 | 
			
		||||
- build: create docs test npm scripts ([#371](https://github.com/googleapis/nodejs-common/pull/371))
 | 
			
		||||
- build: test using @grpc/grpc-js in CI ([#370](https://github.com/googleapis/nodejs-common/pull/370))
 | 
			
		||||
- refactor: change error message format to multiline ([#362](https://github.com/googleapis/nodejs-common/pull/362))
 | 
			
		||||
 | 
			
		||||
## v0.31.0
 | 
			
		||||
 | 
			
		||||
02-05-2019 16:37 PST
 | 
			
		||||
  
 | 
			
		||||
### New Features
 | 
			
		||||
 | 
			
		||||
- fix: remove timeout rule from streaming uploads ([#365](https://github.com/googleapis/nodejs-common/pull/365))
 | 
			
		||||
 | 
			
		||||
### Dependencies
 | 
			
		||||
 | 
			
		||||
- deps: update typescript to v3.3.0 ([#358](https://github.com/googleapis/nodejs-common/pull/358))
 | 
			
		||||
 | 
			
		||||
### Documentation
 | 
			
		||||
 | 
			
		||||
- docs: add lint/fix example to contributing guide ([#364](https://github.com/googleapis/nodejs-common/pull/364))
 | 
			
		||||
 | 
			
		||||
## v0.30.2
 | 
			
		||||
 | 
			
		||||
01-25-2019 12:06 PST
 | 
			
		||||
 | 
			
		||||
### New Features
 | 
			
		||||
- fix: clone default request configuration object ([#356](https://github.com/googleapis/nodejs-common/pull/356))
 | 
			
		||||
 | 
			
		||||
## v0.30.1
 | 
			
		||||
 | 
			
		||||
01-25-2019 11:06 PST
 | 
			
		||||
 | 
			
		||||
### New Features
 | 
			
		||||
 | 
			
		||||
- fix: favor user options over defaults ([#353](https://github.com/googleapis/nodejs-common/pull/353))
 | 
			
		||||
 | 
			
		||||
### Documentation
 | 
			
		||||
 | 
			
		||||
- build: ignore googleapis.com in doc link check ([#351](https://github.com/googleapis/nodejs-common/pull/351))
 | 
			
		||||
 | 
			
		||||
### Internal / Testing Changes
 | 
			
		||||
 | 
			
		||||
- add tests ([#352](https://github.com/googleapis/nodejs-common/pull/352))
 | 
			
		||||
 | 
			
		||||
## v0.30.0
 | 
			
		||||
 | 
			
		||||
01-23-2019 06:21 PST
 | 
			
		||||
 | 
			
		||||
### New Features
 | 
			
		||||
 | 
			
		||||
- fix: inherit requestModule from parent ([#344](https://github.com/googleapis/nodejs-common/pull/344))
 | 
			
		||||
- feat: allow options to ServiceObject methods ([#349](https://github.com/googleapis/nodejs-common/pull/349))
 | 
			
		||||
 | 
			
		||||
### Dependencies
 | 
			
		||||
 | 
			
		||||
- chore(deps): update dependency google-auth-library to v3.0.0 ([#348](https://github.com/googleapis/nodejs-common/pull/348))
 | 
			
		||||
- chore(deps): update dependency @types/sinon to v7.0.3 ([#346](https://github.com/googleapis/nodejs-common/pull/346))
 | 
			
		||||
- chore(deps): update dependency @types/sinon to v7.0.2 ([#343](https://github.com/googleapis/nodejs-common/pull/343))
 | 
			
		||||
 | 
			
		||||
### Internal / Testing Changes
 | 
			
		||||
 | 
			
		||||
- build: check for 404s in the docs ([#347](https://github.com/googleapis/nodejs-common/pull/347))
 | 
			
		||||
 | 
			
		||||
## v0.29.1
 | 
			
		||||
 | 
			
		||||
12-19-2018 20:57 PST
 | 
			
		||||
 | 
			
		||||
### Bug fixes
 | 
			
		||||
- fix: bind to this instead of true ([#341](https://github.com/googleapis/nodejs-common/pull/341))
 | 
			
		||||
 | 
			
		||||
## v0.29.0
 | 
			
		||||
 | 
			
		||||
12-19-2018 13:11 PST
 | 
			
		||||
 | 
			
		||||
- fix: use request_ for service-object ([#337](https://github.com/googleapis/nodejs-common/pull/337))
 | 
			
		||||
 | 
			
		||||
## v0.28.0
 | 
			
		||||
 | 
			
		||||
12-13-2018 14:34 PST
 | 
			
		||||
 | 
			
		||||
**This release has breaking changes**.  The signature of the protected `request` method on `ServiceObject` has been changed.  The method now resolves with an array of `[Body, Response]`, making it consistent with all other promisified methods.  This change was made to fix several breaking changes that occurred in the `0.18.0` release.
 | 
			
		||||
 | 
			
		||||
### New Features
 | 
			
		||||
- feat: allow passing GoogleAuth client to Service ([#314](https://github.com/googleapis/nodejs-common/pull/314))
 | 
			
		||||
- feat: add maybeOptionsOrCallback util method ([#315](https://github.com/googleapis/nodejs-common/pull/315))
 | 
			
		||||
 | 
			
		||||
### Bug Fixes
 | 
			
		||||
- fix: revert async behavior of request ([#331](https://github.com/googleapis/nodejs-common/pull/331))
 | 
			
		||||
 | 
			
		||||
### Documentation
 | 
			
		||||
- docs: update readme badges ([#316](https://github.com/googleapis/nodejs-common/pull/316))
 | 
			
		||||
 | 
			
		||||
### Internal / Testing Changes
 | 
			
		||||
- chore(deps): update dependency @types/sinon to v7 ([#332](https://github.com/googleapis/nodejs-common/pull/332))
 | 
			
		||||
- chore(build): inject yoshi automation key ([#330](https://github.com/googleapis/nodejs-common/pull/330))
 | 
			
		||||
- chore: update nyc and eslint configs ([#329](https://github.com/googleapis/nodejs-common/pull/329))
 | 
			
		||||
- chore: fix publish.sh permission +x ([#327](https://github.com/googleapis/nodejs-common/pull/327))
 | 
			
		||||
- fix(build): fix Kokoro release script ([#326](https://github.com/googleapis/nodejs-common/pull/326))
 | 
			
		||||
- build: add Kokoro configs for autorelease ([#325](https://github.com/googleapis/nodejs-common/pull/325))
 | 
			
		||||
- chore: always nyc report before calling codecov ([#322](https://github.com/googleapis/nodejs-common/pull/322))
 | 
			
		||||
- chore: nyc ignore build/test by default ([#321](https://github.com/googleapis/nodejs-common/pull/321))
 | 
			
		||||
- chore(build): update the prettier config ([#319](https://github.com/googleapis/nodejs-common/pull/319))
 | 
			
		||||
- chore: update license file ([#318](https://github.com/googleapis/nodejs-common/pull/318))
 | 
			
		||||
- fix(build): fix system key decryption ([#313](https://github.com/googleapis/nodejs-common/pull/313))
 | 
			
		||||
- chore(deps): update dependency @types/sinon to v5.0.7 ([#308](https://github.com/googleapis/nodejs-common/pull/308))
 | 
			
		||||
- chore(deps): update dependency typescript to ~3.2.0 ([#312](https://github.com/googleapis/nodejs-common/pull/312))
 | 
			
		||||
 | 
			
		||||
## v0.27.0
 | 
			
		||||
 | 
			
		||||
11-26-2018 12:26 PST
 | 
			
		||||
 | 
			
		||||
**BREAKING CHANGE**: The `ServiceObject` class now has stricter TypeScript types for property names.  This will have no runtime impact, but may cause TypeScript compilation errors until the issues are addressed.
 | 
			
		||||
 | 
			
		||||
### Fixes
 | 
			
		||||
- fix: improve types for service object ([#310](https://github.com/googleapis/nodejs-common/pull/310))
 | 
			
		||||
- refactor: drop through2, mv, and a few others ([#306](https://github.com/googleapis/nodejs-common/pull/306))
 | 
			
		||||
 | 
			
		||||
### Internal / Testing Changes
 | 
			
		||||
- chore: add a synth.metadata
 | 
			
		||||
- fix: Pin @types/sinon to last compatible version ([#307](https://github.com/googleapis/nodejs-common/pull/307))
 | 
			
		||||
 | 
			
		||||
## v0.26.2
 | 
			
		||||
 | 
			
		||||
This patch release also brings in a patch dependency update of @google-cloud/projectify which contains a fix for OOM issue.
 | 
			
		||||
 | 
			
		||||
### Implementation Changes
 | 
			
		||||
- ts: genericize CreateOptions in ServiceObject ([#275](https://github.com/googleapis/nodejs-common/pull/275))
 | 
			
		||||
 | 
			
		||||
### Dependencies
 | 
			
		||||
- chore(deps): upgrade @google-cloud/projectify to v0.3.2 ([#301](https://github.com/googleapis/nodejs-common/pull/301))
 | 
			
		||||
- chore(deps): update dependency gts to ^0.9.0 ([#300](https://github.com/googleapis/nodejs-common/pull/300))
 | 
			
		||||
- chore(deps): update dependency @google-cloud/nodejs-repo-tools to v3 ([#298](https://github.com/googleapis/nodejs-common/pull/298))
 | 
			
		||||
- fix(deps): update dependency through2 to v3 ([#295](https://github.com/googleapis/nodejs-common/pull/295))
 | 
			
		||||
 | 
			
		||||
### Internal / Testing Changes
 | 
			
		||||
- chore: update eslintignore config ([#299](https://github.com/googleapis/nodejs-common/pull/299))
 | 
			
		||||
- chore: drop contributors from multiple places ([#297](https://github.com/googleapis/nodejs-common/pull/297))
 | 
			
		||||
- chore: use latest npm on Windows ([#296](https://github.com/googleapis/nodejs-common/pull/296))
 | 
			
		||||
- chore: update CircleCI config ([#294](https://github.com/googleapis/nodejs-common/pull/294))
 | 
			
		||||
 | 
			
		||||
## v0.26.1
 | 
			
		||||
 | 
			
		||||
### Dependencies
 | 
			
		||||
- chore(deps): upgrade @google-cloud/projectify to ^0.3.1 ([#289](https://github.com/googleapis/nodejs-common/pull/289))
 | 
			
		||||
 | 
			
		||||
### Internal / Testing Changes
 | 
			
		||||
- chore: include build in eslintignore ([#288](https://github.com/googleapis/nodejs-common/pull/288))
 | 
			
		||||
- chore: update issue templates ([#284](https://github.com/googleapis/nodejs-common/pull/284))
 | 
			
		||||
- chore: remove old issue template ([#282](https://github.com/googleapis/nodejs-common/pull/282))
 | 
			
		||||
- build: run tests on node11 ([#280](https://github.com/googleapis/nodejs-common/pull/280))
 | 
			
		||||
 | 
			
		||||
## v0.26.0
 | 
			
		||||
 | 
			
		||||
### Implementation Changes
 | 
			
		||||
- fix(typescript): Make ResponseCallback match subtype ([#271](https://github.com/googleapis/nodejs-common/pull/271))
 | 
			
		||||
- fix: Do not retry streaming POST requests. ([#268](https://github.com/googleapis/nodejs-common/pull/268))
 | 
			
		||||
- Don't publish sourcemaps ([#256](https://github.com/googleapis/nodejs-common/pull/256))
 | 
			
		||||
 | 
			
		||||
### Dependencies
 | 
			
		||||
- chore: Remove 'is' dependency ([#270](https://github.com/googleapis/nodejs-common/pull/270))
 | 
			
		||||
- chore(deps): update dependency sinon to v7 ([#267](https://github.com/googleapis/nodejs-common/pull/267))
 | 
			
		||||
- chore(deps): update dependency typescript to ~3.1.0 ([#259](https://github.com/googleapis/nodejs-common/pull/259))
 | 
			
		||||
 | 
			
		||||
### Internal / Testing Changes
 | 
			
		||||
- chores(build): run codecov on continuous builds ([#276](https://github.com/googleapis/nodejs-common/pull/276))
 | 
			
		||||
- chore: update new issue template ([#274](https://github.com/googleapis/nodejs-common/pull/274))
 | 
			
		||||
- chore: re-enable codecov ([#266](https://github.com/googleapis/nodejs-common/pull/266))
 | 
			
		||||
- test: move install to system tests, and other tsconfig cleanup ([#269](https://github.com/googleapis/nodejs-common/pull/269))
 | 
			
		||||
- Update kokoro config ([#264](https://github.com/googleapis/nodejs-common/pull/264))
 | 
			
		||||
- docs: Remove appveyor badge from readme ([#262](https://github.com/googleapis/nodejs-common/pull/262))
 | 
			
		||||
- Update CI config ([#258](https://github.com/googleapis/nodejs-common/pull/258))
 | 
			
		||||
- build: prevent system/sample-test from leaking credentials
 | 
			
		||||
- Update the kokoro config ([#254](https://github.com/googleapis/nodejs-common/pull/254))
 | 
			
		||||
- test: remove appveyor config ([#253](https://github.com/googleapis/nodejs-common/pull/253))
 | 
			
		||||
- Update CI config ([#252](https://github.com/googleapis/nodejs-common/pull/252))
 | 
			
		||||
 | 
			
		||||
## v0.25.3
 | 
			
		||||
 | 
			
		||||
### Bug fixes
 | 
			
		||||
- fix(types): improve TypeScript types ([#248](https://github.com/googleapis/nodejs-common/pull/248))
 | 
			
		||||
 | 
			
		||||
## v0.25.2
 | 
			
		||||
 | 
			
		||||
### Bug fixes
 | 
			
		||||
- fix(service): Use getProjectId instead of getDefaultProjectId ([#246](https://github.com/googleapis/nodejs-common/pull/246))
 | 
			
		||||
 | 
			
		||||
## v0.25.1
 | 
			
		||||
 | 
			
		||||
### Implementation Changes
 | 
			
		||||
- Improve TypeScript types for async operations ([#241](https://github.com/googleapis/nodejs-common/pull/241))
 | 
			
		||||
- Enhance typing of ServiceObject.prototype.get ([#239](https://github.com/googleapis/nodejs-common/pull/239))
 | 
			
		||||
- Fix TypeScript setMetadata return type ([#240](https://github.com/googleapis/nodejs-common/pull/240))
 | 
			
		||||
- Enable no-var in eslint ([#238](https://github.com/googleapis/nodejs-common/pull/238))
 | 
			
		||||
 | 
			
		||||
## v0.25.0
 | 
			
		||||
 | 
			
		||||
### Implementation Changes
 | 
			
		||||
Some types improvements.
 | 
			
		||||
- Improve types for SO.getMetadata, setMetadata ([#235](https://github.com/googleapis/nodejs-common/pull/235))
 | 
			
		||||
- Expose the parent property on service-object ([#233](https://github.com/googleapis/nodejs-common/pull/233))
 | 
			
		||||
 | 
			
		||||
### Internal / Testing Changes
 | 
			
		||||
- Update CI config ([#232](https://github.com/googleapis/nodejs-common/pull/232))
 | 
			
		||||
 | 
			
		||||
## v0.24.0
 | 
			
		||||
 | 
			
		||||
**BREAKING CHANGES**: This release includes an update to `google-auth-library` [2.0](https://github.com/google/google-auth-library-nodejs/releases/tag/v2.0.0), which has a variety of breaking changes.
 | 
			
		||||
 | 
			
		||||
### Bug fixes
 | 
			
		||||
- fix: set default once (#226)
 | 
			
		||||
- fix: export DecorateRequestOptions and BodyResponseCallback (#225)
 | 
			
		||||
- fix: fix the types (#221)
 | 
			
		||||
 | 
			
		||||
### Dependencies
 | 
			
		||||
- fix(deps): update dependency google-auth-library to v2 (#224)
 | 
			
		||||
- chore(deps): update dependency nyc to v13 (#223)
 | 
			
		||||
 | 
			
		||||
## v0.23.0
 | 
			
		||||
 | 
			
		||||
### Fixes
 | 
			
		||||
- fix: move repo-tools to dev dependencies (#218)
 | 
			
		||||
 | 
			
		||||
### Features
 | 
			
		||||
- feat: make HTTP dependency configurable (#210)
 | 
			
		||||
 | 
			
		||||
### Keepin the lights on
 | 
			
		||||
- chore: run repo-tools (#219)
 | 
			
		||||
 | 
			
		||||
## v0.22.0
 | 
			
		||||
 | 
			
		||||
### Commits
 | 
			
		||||
 | 
			
		||||
- fix: Remove old code & replace project ID token in multipart arrays. (#215)
 | 
			
		||||
- allow ServiceObject`s parent to be an ServiceObject (#212)
 | 
			
		||||
- fix: increase timeout for install test (#214)
 | 
			
		||||
- chore: remove dead code and packages (#209)
 | 
			
		||||
- fix(deps): update dependency pify to v4 (#208)
 | 
			
		||||
 | 
			
		||||
## v0.21.1
 | 
			
		||||
 | 
			
		||||
### Bug fixes
 | 
			
		||||
- fix: method metadata can be a boolean (#206)
 | 
			
		||||
 | 
			
		||||
### Build and Test
 | 
			
		||||
- test: throw on deprecation (#198)
 | 
			
		||||
- chore(deps): update dependency typescript to v3 (#197)
 | 
			
		||||
- chore: ignore package-lock.json (#205)
 | 
			
		||||
 | 
			
		||||
## v0.21.0
 | 
			
		||||
 | 
			
		||||
**This release has breaking changes**.
 | 
			
		||||
 | 
			
		||||
#### Node.js support
 | 
			
		||||
Versions 4.x and 9.x of node.js are no longer supported.  Please upgrade to node.js 8.x or 10.x.
 | 
			
		||||
 | 
			
		||||
#### New npm modules
 | 
			
		||||
The support for pagination, promisification, and project Id replacement have been moved into their own npm modules.  You can find them at:
 | 
			
		||||
- [@google-cloud/projectify](https://github.com/googleapis/nodejs-projectify)
 | 
			
		||||
- [@google-cloud/promisify](https://github.com/googleapis/nodejs-promisify)
 | 
			
		||||
- [@google-cloud/paginator](https://github.com/googleapis/nodejs-paginator)
 | 
			
		||||
 | 
			
		||||
These methods have been removed from `@google-cloud/common`.
 | 
			
		||||
 | 
			
		||||
### Breaking Changes
 | 
			
		||||
- fix: drop support for node.js 4.x and 9.x (#190)
 | 
			
		||||
- chore: cut out code split into other modules (#194)
 | 
			
		||||
 | 
			
		||||
### Implementation Changes
 | 
			
		||||
- fix: make ServiceObject#id protected to allow subclass access (#200)
 | 
			
		||||
 | 
			
		||||
### Internal / Testing Changes
 | 
			
		||||
- chore(deps): update dependency gts to ^0.8.0 (#192)
 | 
			
		||||
- chore: update renovate config (#202)
 | 
			
		||||
- refactor: remove circular imports (#201)
 | 
			
		||||
- fix: special JSON.stringify for for strictEqual test (#199)
 | 
			
		||||
- chore: assert.deelEqual => assert.deepStrictEqual (#196)
 | 
			
		||||
- chore: move mocha options to mocha.opts (#195)
 | 
			
		||||
- Update config.yml (#191)
 | 
			
		||||
							
								
								
									
										202
									
								
								node_modules/@google-cloud/common/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										202
									
								
								node_modules/@google-cloud/common/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,202 @@
 | 
			
		||||
 | 
			
		||||
                                 Apache License
 | 
			
		||||
                           Version 2.0, January 2004
 | 
			
		||||
                        http://www.apache.org/licenses/
 | 
			
		||||
 | 
			
		||||
   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
 | 
			
		||||
 | 
			
		||||
   1. Definitions.
 | 
			
		||||
 | 
			
		||||
      "License" shall mean the terms and conditions for use, reproduction,
 | 
			
		||||
      and distribution as defined by Sections 1 through 9 of this document.
 | 
			
		||||
 | 
			
		||||
      "Licensor" shall mean the copyright owner or entity authorized by
 | 
			
		||||
      the copyright owner that is granting the License.
 | 
			
		||||
 | 
			
		||||
      "Legal Entity" shall mean the union of the acting entity and all
 | 
			
		||||
      other entities that control, are controlled by, or are under common
 | 
			
		||||
      control with that entity. For the purposes of this definition,
 | 
			
		||||
      "control" means (i) the power, direct or indirect, to cause the
 | 
			
		||||
      direction or management of such entity, whether by contract or
 | 
			
		||||
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
 | 
			
		||||
      outstanding shares, or (iii) beneficial ownership of such entity.
 | 
			
		||||
 | 
			
		||||
      "You" (or "Your") shall mean an individual or Legal Entity
 | 
			
		||||
      exercising permissions granted by this License.
 | 
			
		||||
 | 
			
		||||
      "Source" form shall mean the preferred form for making modifications,
 | 
			
		||||
      including but not limited to software source code, documentation
 | 
			
		||||
      source, and configuration files.
 | 
			
		||||
 | 
			
		||||
      "Object" form shall mean any form resulting from mechanical
 | 
			
		||||
      transformation or translation of a Source form, including but
 | 
			
		||||
      not limited to compiled object code, generated documentation,
 | 
			
		||||
      and conversions to other media types.
 | 
			
		||||
 | 
			
		||||
      "Work" shall mean the work of authorship, whether in Source or
 | 
			
		||||
      Object form, made available under the License, as indicated by a
 | 
			
		||||
      copyright notice that is included in or attached to the work
 | 
			
		||||
      (an example is provided in the Appendix below).
 | 
			
		||||
 | 
			
		||||
      "Derivative Works" shall mean any work, whether in Source or Object
 | 
			
		||||
      form, that is based on (or derived from) the Work and for which the
 | 
			
		||||
      editorial revisions, annotations, elaborations, or other modifications
 | 
			
		||||
      represent, as a whole, an original work of authorship. For the purposes
 | 
			
		||||
      of this License, Derivative Works shall not include works that remain
 | 
			
		||||
      separable from, or merely link (or bind by name) to the interfaces of,
 | 
			
		||||
      the Work and Derivative Works thereof.
 | 
			
		||||
 | 
			
		||||
      "Contribution" shall mean any work of authorship, including
 | 
			
		||||
      the original version of the Work and any modifications or additions
 | 
			
		||||
      to that Work or Derivative Works thereof, that is intentionally
 | 
			
		||||
      submitted to Licensor for inclusion in the Work by the copyright owner
 | 
			
		||||
      or by an individual or Legal Entity authorized to submit on behalf of
 | 
			
		||||
      the copyright owner. For the purposes of this definition, "submitted"
 | 
			
		||||
      means any form of electronic, verbal, or written communication sent
 | 
			
		||||
      to the Licensor or its representatives, including but not limited to
 | 
			
		||||
      communication on electronic mailing lists, source code control systems,
 | 
			
		||||
      and issue tracking systems that are managed by, or on behalf of, the
 | 
			
		||||
      Licensor for the purpose of discussing and improving the Work, but
 | 
			
		||||
      excluding communication that is conspicuously marked or otherwise
 | 
			
		||||
      designated in writing by the copyright owner as "Not a Contribution."
 | 
			
		||||
 | 
			
		||||
      "Contributor" shall mean Licensor and any individual or Legal Entity
 | 
			
		||||
      on behalf of whom a Contribution has been received by Licensor and
 | 
			
		||||
      subsequently incorporated within the Work.
 | 
			
		||||
 | 
			
		||||
   2. Grant of Copyright License. Subject to the terms and conditions of
 | 
			
		||||
      this License, each Contributor hereby grants to You a perpetual,
 | 
			
		||||
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
 | 
			
		||||
      copyright license to reproduce, prepare Derivative Works of,
 | 
			
		||||
      publicly display, publicly perform, sublicense, and distribute the
 | 
			
		||||
      Work and such Derivative Works in Source or Object form.
 | 
			
		||||
 | 
			
		||||
   3. Grant of Patent License. Subject to the terms and conditions of
 | 
			
		||||
      this License, each Contributor hereby grants to You a perpetual,
 | 
			
		||||
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
 | 
			
		||||
      (except as stated in this section) patent license to make, have made,
 | 
			
		||||
      use, offer to sell, sell, import, and otherwise transfer the Work,
 | 
			
		||||
      where such license applies only to those patent claims licensable
 | 
			
		||||
      by such Contributor that are necessarily infringed by their
 | 
			
		||||
      Contribution(s) alone or by combination of their Contribution(s)
 | 
			
		||||
      with the Work to which such Contribution(s) was submitted. If You
 | 
			
		||||
      institute patent litigation against any entity (including a
 | 
			
		||||
      cross-claim or counterclaim in a lawsuit) alleging that the Work
 | 
			
		||||
      or a Contribution incorporated within the Work constitutes direct
 | 
			
		||||
      or contributory patent infringement, then any patent licenses
 | 
			
		||||
      granted to You under this License for that Work shall terminate
 | 
			
		||||
      as of the date such litigation is filed.
 | 
			
		||||
 | 
			
		||||
   4. Redistribution. You may reproduce and distribute copies of the
 | 
			
		||||
      Work or Derivative Works thereof in any medium, with or without
 | 
			
		||||
      modifications, and in Source or Object form, provided that You
 | 
			
		||||
      meet the following conditions:
 | 
			
		||||
 | 
			
		||||
      (a) You must give any other recipients of the Work or
 | 
			
		||||
          Derivative Works a copy of this License; and
 | 
			
		||||
 | 
			
		||||
      (b) You must cause any modified files to carry prominent notices
 | 
			
		||||
          stating that You changed the files; and
 | 
			
		||||
 | 
			
		||||
      (c) You must retain, in the Source form of any Derivative Works
 | 
			
		||||
          that You distribute, all copyright, patent, trademark, and
 | 
			
		||||
          attribution notices from the Source form of the Work,
 | 
			
		||||
          excluding those notices that do not pertain to any part of
 | 
			
		||||
          the Derivative Works; and
 | 
			
		||||
 | 
			
		||||
      (d) If the Work includes a "NOTICE" text file as part of its
 | 
			
		||||
          distribution, then any Derivative Works that You distribute must
 | 
			
		||||
          include a readable copy of the attribution notices contained
 | 
			
		||||
          within such NOTICE file, excluding those notices that do not
 | 
			
		||||
          pertain to any part of the Derivative Works, in at least one
 | 
			
		||||
          of the following places: within a NOTICE text file distributed
 | 
			
		||||
          as part of the Derivative Works; within the Source form or
 | 
			
		||||
          documentation, if provided along with the Derivative Works; or,
 | 
			
		||||
          within a display generated by the Derivative Works, if and
 | 
			
		||||
          wherever such third-party notices normally appear. The contents
 | 
			
		||||
          of the NOTICE file are for informational purposes only and
 | 
			
		||||
          do not modify the License. You may add Your own attribution
 | 
			
		||||
          notices within Derivative Works that You distribute, alongside
 | 
			
		||||
          or as an addendum to the NOTICE text from the Work, provided
 | 
			
		||||
          that such additional attribution notices cannot be construed
 | 
			
		||||
          as modifying the License.
 | 
			
		||||
 | 
			
		||||
      You may add Your own copyright statement to Your modifications and
 | 
			
		||||
      may provide additional or different license terms and conditions
 | 
			
		||||
      for use, reproduction, or distribution of Your modifications, or
 | 
			
		||||
      for any such Derivative Works as a whole, provided Your use,
 | 
			
		||||
      reproduction, and distribution of the Work otherwise complies with
 | 
			
		||||
      the conditions stated in this License.
 | 
			
		||||
 | 
			
		||||
   5. Submission of Contributions. Unless You explicitly state otherwise,
 | 
			
		||||
      any Contribution intentionally submitted for inclusion in the Work
 | 
			
		||||
      by You to the Licensor shall be under the terms and conditions of
 | 
			
		||||
      this License, without any additional terms or conditions.
 | 
			
		||||
      Notwithstanding the above, nothing herein shall supersede or modify
 | 
			
		||||
      the terms of any separate license agreement you may have executed
 | 
			
		||||
      with Licensor regarding such Contributions.
 | 
			
		||||
 | 
			
		||||
   6. Trademarks. This License does not grant permission to use the trade
 | 
			
		||||
      names, trademarks, service marks, or product names of the Licensor,
 | 
			
		||||
      except as required for reasonable and customary use in describing the
 | 
			
		||||
      origin of the Work and reproducing the content of the NOTICE file.
 | 
			
		||||
 | 
			
		||||
   7. Disclaimer of Warranty. Unless required by applicable law or
 | 
			
		||||
      agreed to in writing, Licensor provides the Work (and each
 | 
			
		||||
      Contributor provides its Contributions) on an "AS IS" BASIS,
 | 
			
		||||
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 | 
			
		||||
      implied, including, without limitation, any warranties or conditions
 | 
			
		||||
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
 | 
			
		||||
      PARTICULAR PURPOSE. You are solely responsible for determining the
 | 
			
		||||
      appropriateness of using or redistributing the Work and assume any
 | 
			
		||||
      risks associated with Your exercise of permissions under this License.
 | 
			
		||||
 | 
			
		||||
   8. Limitation of Liability. In no event and under no legal theory,
 | 
			
		||||
      whether in tort (including negligence), contract, or otherwise,
 | 
			
		||||
      unless required by applicable law (such as deliberate and grossly
 | 
			
		||||
      negligent acts) or agreed to in writing, shall any Contributor be
 | 
			
		||||
      liable to You for damages, including any direct, indirect, special,
 | 
			
		||||
      incidental, or consequential damages of any character arising as a
 | 
			
		||||
      result of this License or out of the use or inability to use the
 | 
			
		||||
      Work (including but not limited to damages for loss of goodwill,
 | 
			
		||||
      work stoppage, computer failure or malfunction, or any and all
 | 
			
		||||
      other commercial damages or losses), even if such Contributor
 | 
			
		||||
      has been advised of the possibility of such damages.
 | 
			
		||||
 | 
			
		||||
   9. Accepting Warranty or Additional Liability. While redistributing
 | 
			
		||||
      the Work or Derivative Works thereof, You may choose to offer,
 | 
			
		||||
      and charge a fee for, acceptance of support, warranty, indemnity,
 | 
			
		||||
      or other liability obligations and/or rights consistent with this
 | 
			
		||||
      License. However, in accepting such obligations, You may act only
 | 
			
		||||
      on Your own behalf and on Your sole responsibility, not on behalf
 | 
			
		||||
      of any other Contributor, and only if You agree to indemnify,
 | 
			
		||||
      defend, and hold each Contributor harmless for any liability
 | 
			
		||||
      incurred by, or claims asserted against, such Contributor by reason
 | 
			
		||||
      of your accepting any such warranty or additional liability.
 | 
			
		||||
 | 
			
		||||
   END OF TERMS AND CONDITIONS
 | 
			
		||||
 | 
			
		||||
   APPENDIX: How to apply the Apache License to your work.
 | 
			
		||||
 | 
			
		||||
      To apply the Apache License to your work, attach the following
 | 
			
		||||
      boilerplate notice, with the fields enclosed by brackets "[]"
 | 
			
		||||
      replaced with your own identifying information. (Don't include
 | 
			
		||||
      the brackets!)  The text should be enclosed in the appropriate
 | 
			
		||||
      comment syntax for the file format. We also recommend that a
 | 
			
		||||
      file or class name and description of purpose be included on the
 | 
			
		||||
      same "printed page" as the copyright notice for easier
 | 
			
		||||
      identification within third-party archives.
 | 
			
		||||
 | 
			
		||||
   Copyright [yyyy] [name of copyright owner]
 | 
			
		||||
 | 
			
		||||
   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.
 | 
			
		||||
							
								
								
									
										91
									
								
								node_modules/@google-cloud/common/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										91
									
								
								node_modules/@google-cloud/common/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,91 @@
 | 
			
		||||
[//]: # "This README.md file is auto-generated, all changes to this file will be lost."
 | 
			
		||||
[//]: # "To regenerate it, use `python -m synthtool`."
 | 
			
		||||
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>
 | 
			
		||||
 | 
			
		||||
# [Google Cloud Common: Node.js Client](https://github.com/googleapis/nodejs-common)
 | 
			
		||||
 | 
			
		||||
[](https://cloud.google.com/terms/launch-stages)
 | 
			
		||||
[](https://www.npmjs.org/package/@google-cloud/common)
 | 
			
		||||
[](https://codecov.io/gh/googleapis/nodejs-common)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Common components for Cloud APIs Node.js Client Libraries
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
* [Google Cloud Common Node.js Client API Reference][client-docs]
 | 
			
		||||
 | 
			
		||||
* [github.com/googleapis/nodejs-common](https://github.com/googleapis/nodejs-common)
 | 
			
		||||
 | 
			
		||||
Read more about the client libraries for Cloud APIs, including the older
 | 
			
		||||
Google APIs Client Libraries, in [Client Libraries Explained][explained].
 | 
			
		||||
 | 
			
		||||
[explained]: https://cloud.google.com/apis/docs/client-libraries-explained
 | 
			
		||||
 | 
			
		||||
**Table of contents:**
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
* [Quickstart](#quickstart)
 | 
			
		||||
 | 
			
		||||
  * [Installing the client library](#installing-the-client-library)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
* [Versioning](#versioning)
 | 
			
		||||
* [Contributing](#contributing)
 | 
			
		||||
* [License](#license)
 | 
			
		||||
 | 
			
		||||
## Quickstart
 | 
			
		||||
 | 
			
		||||
### Installing the client library
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
npm install @google-cloud/common
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
It's unlikely you will need to install this package directly, as it will be
 | 
			
		||||
installed as a dependency when you install other `@google-cloud` packages.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
The [Google Cloud Common Node.js Client API Reference][client-docs] documentation
 | 
			
		||||
also contains samples.
 | 
			
		||||
 | 
			
		||||
## Versioning
 | 
			
		||||
 | 
			
		||||
This library follows [Semantic Versioning](http://semver.org/).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
This library is considered to be **General Availability (GA)**. This means it
 | 
			
		||||
is stable; the code surface will not change in backwards-incompatible ways
 | 
			
		||||
unless absolutely necessary (e.g. because of critical security issues) or with
 | 
			
		||||
an extensive deprecation period. Issues and requests against **GA** libraries
 | 
			
		||||
are addressed with the highest priority.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
More Information: [Google Cloud Platform Launch Stages][launch_stages]
 | 
			
		||||
 | 
			
		||||
[launch_stages]: https://cloud.google.com/terms/launch-stages
 | 
			
		||||
 | 
			
		||||
## Contributing
 | 
			
		||||
 | 
			
		||||
Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/nodejs-common/blob/master/CONTRIBUTING.md).
 | 
			
		||||
 | 
			
		||||
## License
 | 
			
		||||
 | 
			
		||||
Apache Version 2.0
 | 
			
		||||
 | 
			
		||||
See [LICENSE](https://github.com/googleapis/nodejs-common/blob/master/LICENSE)
 | 
			
		||||
 | 
			
		||||
[client-docs]: https://googleapis.dev/nodejs/common/latest#reference
 | 
			
		||||
 | 
			
		||||
[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png
 | 
			
		||||
[projects]: https://console.cloud.google.com/project
 | 
			
		||||
[billing]: https://support.google.com/cloud/answer/6293499#enable-billing
 | 
			
		||||
 | 
			
		||||
[auth]: https://cloud.google.com/docs/authentication/getting-started
 | 
			
		||||
 | 
			
		||||
<a name="reference"></a>
 | 
			
		||||
							
								
								
									
										36
									
								
								node_modules/@google-cloud/common/build/src/index.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								node_modules/@google-cloud/common/build/src/index.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
/*!
 | 
			
		||||
 * Copyright 2016 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.
 | 
			
		||||
 */
 | 
			
		||||
export { GoogleAuthOptions } from 'google-auth-library';
 | 
			
		||||
/**
 | 
			
		||||
 * @type {module:common/operation}
 | 
			
		||||
 * @private
 | 
			
		||||
 */
 | 
			
		||||
export { Operation } from './operation';
 | 
			
		||||
/**
 | 
			
		||||
 * @type {module:common/service}
 | 
			
		||||
 * @private
 | 
			
		||||
 */
 | 
			
		||||
export { Service, ServiceConfig, ServiceOptions, StreamRequestOptions, } from './service';
 | 
			
		||||
/**
 | 
			
		||||
 * @type {module:common/serviceObject}
 | 
			
		||||
 * @private
 | 
			
		||||
 */
 | 
			
		||||
export { DeleteCallback, ExistsCallback, GetConfig, InstanceResponseCallback, Interceptor, Metadata, MetadataCallback, MetadataResponse, Methods, ResponseCallback, ServiceObject, ServiceObjectConfig, ServiceObjectParent, SetMetadataResponse, } from './service-object';
 | 
			
		||||
/**
 | 
			
		||||
 * @type {module:common/util}
 | 
			
		||||
 * @private
 | 
			
		||||
 */
 | 
			
		||||
export { Abortable, AbortableDuplex, ApiError, BodyResponseCallback, DecorateRequestOptions, ResponseBody, util, } from './util';
 | 
			
		||||
							
								
								
									
										43
									
								
								node_modules/@google-cloud/common/build/src/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								node_modules/@google-cloud/common/build/src/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,43 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
/*!
 | 
			
		||||
 * Copyright 2016 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.
 | 
			
		||||
 */
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
/**
 | 
			
		||||
 * @type {module:common/operation}
 | 
			
		||||
 * @private
 | 
			
		||||
 */
 | 
			
		||||
var operation_1 = require("./operation");
 | 
			
		||||
exports.Operation = operation_1.Operation;
 | 
			
		||||
/**
 | 
			
		||||
 * @type {module:common/service}
 | 
			
		||||
 * @private
 | 
			
		||||
 */
 | 
			
		||||
var service_1 = require("./service");
 | 
			
		||||
exports.Service = service_1.Service;
 | 
			
		||||
/**
 | 
			
		||||
 * @type {module:common/serviceObject}
 | 
			
		||||
 * @private
 | 
			
		||||
 */
 | 
			
		||||
var service_object_1 = require("./service-object");
 | 
			
		||||
exports.ServiceObject = service_object_1.ServiceObject;
 | 
			
		||||
/**
 | 
			
		||||
 * @type {module:common/util}
 | 
			
		||||
 * @private
 | 
			
		||||
 */
 | 
			
		||||
var util_1 = require("./util");
 | 
			
		||||
exports.ApiError = util_1.ApiError;
 | 
			
		||||
exports.util = util_1.util;
 | 
			
		||||
//# sourceMappingURL=index.js.map
 | 
			
		||||
							
								
								
									
										68
									
								
								node_modules/@google-cloud/common/build/src/operation.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								node_modules/@google-cloud/common/build/src/operation.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,68 @@
 | 
			
		||||
/*!
 | 
			
		||||
 * Copyright 2016 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.
 | 
			
		||||
 */
 | 
			
		||||
/*!
 | 
			
		||||
 * @module common/operation
 | 
			
		||||
 */
 | 
			
		||||
import { MetadataCallback, ServiceObject, ServiceObjectConfig } from './service-object';
 | 
			
		||||
export declare class Operation<T = any> extends ServiceObject<T> {
 | 
			
		||||
    completeListeners: number;
 | 
			
		||||
    hasActiveListeners: boolean;
 | 
			
		||||
    /**
 | 
			
		||||
     * An Operation object allows you to interact with APIs that take longer to
 | 
			
		||||
     * process things.
 | 
			
		||||
     *
 | 
			
		||||
     * @constructor
 | 
			
		||||
     * @alias module:common/operation
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} config - Configuration object.
 | 
			
		||||
     * @param {module:common/service|module:common/serviceObject|module:common/grpcService|module:common/grpcServiceObject} config.parent - The parent object.
 | 
			
		||||
     */
 | 
			
		||||
    constructor(config: ServiceObjectConfig);
 | 
			
		||||
    /**
 | 
			
		||||
     * Wraps the `complete` and `error` events in a Promise.
 | 
			
		||||
     *
 | 
			
		||||
     * @return {promise}
 | 
			
		||||
     */
 | 
			
		||||
    promise(): Promise<unknown>;
 | 
			
		||||
    /**
 | 
			
		||||
     * Begin listening for events on the operation. This method keeps track of how
 | 
			
		||||
     * many "complete" listeners are registered and removed, making sure polling
 | 
			
		||||
     * is handled automatically.
 | 
			
		||||
     *
 | 
			
		||||
     * As long as there is one active "complete" listener, the connection is open.
 | 
			
		||||
     * When there are no more listeners, the polling stops.
 | 
			
		||||
     *
 | 
			
		||||
     * @private
 | 
			
		||||
     */
 | 
			
		||||
    protected listenForEvents_(): void;
 | 
			
		||||
    /**
 | 
			
		||||
     * Poll for a status update. Returns null for an incomplete
 | 
			
		||||
     * status, and metadata for a complete status.
 | 
			
		||||
     *
 | 
			
		||||
     * @private
 | 
			
		||||
     */
 | 
			
		||||
    protected poll_(callback: MetadataCallback): void;
 | 
			
		||||
    /**
 | 
			
		||||
     * Poll `getMetadata` to check the operation's status. This runs a loop to
 | 
			
		||||
     * ping the API on an interval.
 | 
			
		||||
     *
 | 
			
		||||
     * Note: This method is automatically called once a "complete" event handler
 | 
			
		||||
     * is registered on the operation.
 | 
			
		||||
     *
 | 
			
		||||
     * @private
 | 
			
		||||
     */
 | 
			
		||||
    protected startPolling_(): Promise<void>;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										148
									
								
								node_modules/@google-cloud/common/build/src/operation.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										148
									
								
								node_modules/@google-cloud/common/build/src/operation.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,148 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
/*!
 | 
			
		||||
 * Copyright 2016 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.
 | 
			
		||||
 */
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
/*!
 | 
			
		||||
 * @module common/operation
 | 
			
		||||
 */
 | 
			
		||||
const service_object_1 = require("./service-object");
 | 
			
		||||
const util_1 = require("util");
 | 
			
		||||
// tslint:disable-next-line no-any
 | 
			
		||||
class Operation extends service_object_1.ServiceObject {
 | 
			
		||||
    /**
 | 
			
		||||
     * An Operation object allows you to interact with APIs that take longer to
 | 
			
		||||
     * process things.
 | 
			
		||||
     *
 | 
			
		||||
     * @constructor
 | 
			
		||||
     * @alias module:common/operation
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} config - Configuration object.
 | 
			
		||||
     * @param {module:common/service|module:common/serviceObject|module:common/grpcService|module:common/grpcServiceObject} config.parent - The parent object.
 | 
			
		||||
     */
 | 
			
		||||
    constructor(config) {
 | 
			
		||||
        const methods = {
 | 
			
		||||
            /**
 | 
			
		||||
             * Checks to see if an operation exists.
 | 
			
		||||
             */
 | 
			
		||||
            exists: true,
 | 
			
		||||
            /**
 | 
			
		||||
             * Retrieves the operation.
 | 
			
		||||
             */
 | 
			
		||||
            get: true,
 | 
			
		||||
            /**
 | 
			
		||||
             * Retrieves metadata for the operation.
 | 
			
		||||
             */
 | 
			
		||||
            getMetadata: {
 | 
			
		||||
                reqOpts: {
 | 
			
		||||
                    name: config.id,
 | 
			
		||||
                },
 | 
			
		||||
            },
 | 
			
		||||
        };
 | 
			
		||||
        config = Object.assign({
 | 
			
		||||
            baseUrl: '',
 | 
			
		||||
        }, config);
 | 
			
		||||
        // tslint:disable-next-line:no-any
 | 
			
		||||
        config.methods = (config.methods || methods);
 | 
			
		||||
        super(config);
 | 
			
		||||
        this.completeListeners = 0;
 | 
			
		||||
        this.hasActiveListeners = false;
 | 
			
		||||
        this.listenForEvents_();
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Wraps the `complete` and `error` events in a Promise.
 | 
			
		||||
     *
 | 
			
		||||
     * @return {promise}
 | 
			
		||||
     */
 | 
			
		||||
    promise() {
 | 
			
		||||
        return new this.Promise((resolve, reject) => {
 | 
			
		||||
            this.on('error', reject).on('complete', (metadata) => {
 | 
			
		||||
                resolve([metadata]);
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Begin listening for events on the operation. This method keeps track of how
 | 
			
		||||
     * many "complete" listeners are registered and removed, making sure polling
 | 
			
		||||
     * is handled automatically.
 | 
			
		||||
     *
 | 
			
		||||
     * As long as there is one active "complete" listener, the connection is open.
 | 
			
		||||
     * When there are no more listeners, the polling stops.
 | 
			
		||||
     *
 | 
			
		||||
     * @private
 | 
			
		||||
     */
 | 
			
		||||
    listenForEvents_() {
 | 
			
		||||
        this.on('newListener', (event) => {
 | 
			
		||||
            if (event === 'complete') {
 | 
			
		||||
                this.completeListeners++;
 | 
			
		||||
                if (!this.hasActiveListeners) {
 | 
			
		||||
                    this.hasActiveListeners = true;
 | 
			
		||||
                    this.startPolling_();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        this.on('removeListener', (event) => {
 | 
			
		||||
            if (event === 'complete' && --this.completeListeners === 0) {
 | 
			
		||||
                this.hasActiveListeners = false;
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Poll for a status update. Returns null for an incomplete
 | 
			
		||||
     * status, and metadata for a complete status.
 | 
			
		||||
     *
 | 
			
		||||
     * @private
 | 
			
		||||
     */
 | 
			
		||||
    poll_(callback) {
 | 
			
		||||
        this.getMetadata((err, body) => {
 | 
			
		||||
            if (err || body.error) {
 | 
			
		||||
                callback(err || body.error);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            if (!body.done) {
 | 
			
		||||
                callback(null);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            callback(null, body);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Poll `getMetadata` to check the operation's status. This runs a loop to
 | 
			
		||||
     * ping the API on an interval.
 | 
			
		||||
     *
 | 
			
		||||
     * Note: This method is automatically called once a "complete" event handler
 | 
			
		||||
     * is registered on the operation.
 | 
			
		||||
     *
 | 
			
		||||
     * @private
 | 
			
		||||
     */
 | 
			
		||||
    async startPolling_() {
 | 
			
		||||
        if (!this.hasActiveListeners) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        try {
 | 
			
		||||
            const metadata = await util_1.promisify(this.poll_.bind(this))();
 | 
			
		||||
            if (!metadata) {
 | 
			
		||||
                setTimeout(this.startPolling_.bind(this), 500);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            this.emit('complete', metadata);
 | 
			
		||||
        }
 | 
			
		||||
        catch (err) {
 | 
			
		||||
            this.emit('error', err);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.Operation = Operation;
 | 
			
		||||
//# sourceMappingURL=operation.js.map
 | 
			
		||||
							
								
								
									
										210
									
								
								node_modules/@google-cloud/common/build/src/service-object.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										210
									
								
								node_modules/@google-cloud/common/build/src/service-object.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,210 @@
 | 
			
		||||
/*!
 | 
			
		||||
 * Copyright 2015 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.
 | 
			
		||||
 */
 | 
			
		||||
/// <reference types="node" />
 | 
			
		||||
import { EventEmitter } from 'events';
 | 
			
		||||
import * as r from 'teeny-request';
 | 
			
		||||
import { ApiError, BodyResponseCallback, DecorateRequestOptions } from './util';
 | 
			
		||||
export declare type RequestResponse = [Metadata, r.Response];
 | 
			
		||||
export interface ServiceObjectParent {
 | 
			
		||||
    Promise?: PromiseConstructor;
 | 
			
		||||
    requestStream(reqOpts: DecorateRequestOptions): r.Request;
 | 
			
		||||
    request(reqOpts: DecorateRequestOptions, callback: BodyResponseCallback): void;
 | 
			
		||||
}
 | 
			
		||||
export interface Interceptor {
 | 
			
		||||
    request(opts: r.Options): DecorateRequestOptions;
 | 
			
		||||
}
 | 
			
		||||
export declare type GetMetadataOptions = object;
 | 
			
		||||
export declare type Metadata = any;
 | 
			
		||||
export declare type MetadataResponse = [Metadata, r.Response];
 | 
			
		||||
export declare type MetadataCallback = (err: Error | null, metadata?: Metadata, apiResponse?: r.Response) => void;
 | 
			
		||||
export declare type ExistsOptions = object;
 | 
			
		||||
export interface ExistsCallback {
 | 
			
		||||
    (err: Error | null, exists?: boolean): void;
 | 
			
		||||
}
 | 
			
		||||
export interface ServiceObjectConfig {
 | 
			
		||||
    /**
 | 
			
		||||
     * The base URL to make API requests to.
 | 
			
		||||
     */
 | 
			
		||||
    baseUrl?: string;
 | 
			
		||||
    /**
 | 
			
		||||
     * The method which creates this object.
 | 
			
		||||
     */
 | 
			
		||||
    createMethod?: Function;
 | 
			
		||||
    /**
 | 
			
		||||
     * The identifier of the object. For example, the name of a Storage bucket or
 | 
			
		||||
     * Pub/Sub topic.
 | 
			
		||||
     */
 | 
			
		||||
    id?: string;
 | 
			
		||||
    /**
 | 
			
		||||
     * A map of each method name that should be inherited.
 | 
			
		||||
     */
 | 
			
		||||
    methods?: Methods;
 | 
			
		||||
    /**
 | 
			
		||||
     * The parent service instance. For example, an instance of Storage if the
 | 
			
		||||
     * object is Bucket.
 | 
			
		||||
     */
 | 
			
		||||
    parent: ServiceObjectParent;
 | 
			
		||||
}
 | 
			
		||||
export interface Methods {
 | 
			
		||||
    [methodName: string]: {
 | 
			
		||||
        reqOpts?: r.CoreOptions;
 | 
			
		||||
    } | boolean;
 | 
			
		||||
}
 | 
			
		||||
export interface InstanceResponseCallback<T> {
 | 
			
		||||
    (err: ApiError | null, instance?: T | null, apiResponse?: r.Response): void;
 | 
			
		||||
}
 | 
			
		||||
export interface CreateOptions {
 | 
			
		||||
}
 | 
			
		||||
export declare type CreateResponse<T> = any[];
 | 
			
		||||
export interface CreateCallback<T> {
 | 
			
		||||
    (err: ApiError | null, instance?: T | null, ...args: any[]): void;
 | 
			
		||||
}
 | 
			
		||||
export declare type DeleteOptions = object;
 | 
			
		||||
export interface DeleteCallback {
 | 
			
		||||
    (err: Error | null, apiResponse?: r.Response): void;
 | 
			
		||||
}
 | 
			
		||||
export interface GetConfig {
 | 
			
		||||
    /**
 | 
			
		||||
     * Create the object if it doesn't already exist.
 | 
			
		||||
     */
 | 
			
		||||
    autoCreate?: boolean;
 | 
			
		||||
}
 | 
			
		||||
declare type GetOrCreateOptions = GetConfig & CreateOptions;
 | 
			
		||||
export declare type GetResponse<T> = [T, r.Response];
 | 
			
		||||
export interface ResponseCallback {
 | 
			
		||||
    (err?: Error | null, apiResponse?: r.Response): void;
 | 
			
		||||
}
 | 
			
		||||
export declare type SetMetadataResponse = [Metadata];
 | 
			
		||||
export declare type SetMetadataOptions = object;
 | 
			
		||||
/**
 | 
			
		||||
 * ServiceObject is a base class, meant to be inherited from by a "service
 | 
			
		||||
 * object," like a BigQuery dataset or Storage bucket.
 | 
			
		||||
 *
 | 
			
		||||
 * Most of the time, these objects share common functionality; they can be
 | 
			
		||||
 * created or deleted, and you can get or set their metadata.
 | 
			
		||||
 *
 | 
			
		||||
 * By inheriting from this class, a service object will be extended with these
 | 
			
		||||
 * shared behaviors. Note that any method can be overridden when the service
 | 
			
		||||
 * object requires specific behavior.
 | 
			
		||||
 */
 | 
			
		||||
declare class ServiceObject<T = any> extends EventEmitter {
 | 
			
		||||
    metadata: Metadata;
 | 
			
		||||
    baseUrl?: string;
 | 
			
		||||
    parent: ServiceObjectParent;
 | 
			
		||||
    id?: string;
 | 
			
		||||
    private createMethod?;
 | 
			
		||||
    protected methods: Methods;
 | 
			
		||||
    protected interceptors: Interceptor[];
 | 
			
		||||
    Promise?: PromiseConstructor;
 | 
			
		||||
    constructor(config: ServiceObjectConfig);
 | 
			
		||||
    /**
 | 
			
		||||
     * Create the object.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object=} options - Configuration object.
 | 
			
		||||
     * @param {function} callback - The callback function.
 | 
			
		||||
     * @param {?error} callback.err - An error returned while making this request.
 | 
			
		||||
     * @param {object} callback.instance - The instance.
 | 
			
		||||
     * @param {object} callback.apiResponse - The full API response.
 | 
			
		||||
     */
 | 
			
		||||
    create(options?: CreateOptions): Promise<CreateResponse<T>>;
 | 
			
		||||
    create(options: CreateOptions, callback: CreateCallback<T>): void;
 | 
			
		||||
    create(callback: CreateCallback<T>): void;
 | 
			
		||||
    /**
 | 
			
		||||
     * Delete the object.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {function=} callback - The callback function.
 | 
			
		||||
     * @param {?error} callback.err - An error returned while making this request.
 | 
			
		||||
     * @param {object} callback.apiResponse - The full API response.
 | 
			
		||||
     */
 | 
			
		||||
    delete(options?: DeleteOptions): Promise<[r.Response]>;
 | 
			
		||||
    delete(options: DeleteOptions, callback: DeleteCallback): void;
 | 
			
		||||
    delete(callback: DeleteCallback): void;
 | 
			
		||||
    /**
 | 
			
		||||
     * Check if the object exists.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {function} callback - The callback function.
 | 
			
		||||
     * @param {?error} callback.err - An error returned while making this request.
 | 
			
		||||
     * @param {boolean} callback.exists - Whether the object exists or not.
 | 
			
		||||
     */
 | 
			
		||||
    exists(options?: ExistsOptions): Promise<[boolean]>;
 | 
			
		||||
    exists(options: ExistsOptions, callback: ExistsCallback): void;
 | 
			
		||||
    exists(callback: ExistsCallback): void;
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the object if it exists. Optionally have the object created if an
 | 
			
		||||
     * options object is provided with `autoCreate: true`.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object=} options - The configuration object that will be used to
 | 
			
		||||
     *     create the object if necessary.
 | 
			
		||||
     * @param {boolean} options.autoCreate - Create the object if it doesn't already exist.
 | 
			
		||||
     * @param {function} callback - The callback function.
 | 
			
		||||
     * @param {?error} callback.err - An error returned while making this request.
 | 
			
		||||
     * @param {object} callback.instance - The instance.
 | 
			
		||||
     * @param {object} callback.apiResponse - The full API response.
 | 
			
		||||
     */
 | 
			
		||||
    get(options?: GetOrCreateOptions): Promise<GetResponse<T>>;
 | 
			
		||||
    get(callback: InstanceResponseCallback<T>): void;
 | 
			
		||||
    get(options: GetOrCreateOptions, callback: InstanceResponseCallback<T>): void;
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the metadata of this object.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {function} callback - The callback function.
 | 
			
		||||
     * @param {?error} callback.err - An error returned while making this request.
 | 
			
		||||
     * @param {object} callback.metadata - The metadata for this object.
 | 
			
		||||
     * @param {object} callback.apiResponse - The full API response.
 | 
			
		||||
     */
 | 
			
		||||
    getMetadata(options?: GetMetadataOptions): Promise<MetadataResponse>;
 | 
			
		||||
    getMetadata(options: GetMetadataOptions, callback: MetadataCallback): void;
 | 
			
		||||
    getMetadata(callback: MetadataCallback): void;
 | 
			
		||||
    /**
 | 
			
		||||
     * Set the metadata for this object.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} metadata - The metadata to set on this object.
 | 
			
		||||
     * @param {object=} options - Configuration options.
 | 
			
		||||
     * @param {function=} callback - The callback function.
 | 
			
		||||
     * @param {?error} callback.err - An error returned while making this request.
 | 
			
		||||
     * @param {object} callback.apiResponse - The full API response.
 | 
			
		||||
     */
 | 
			
		||||
    setMetadata(metadata: Metadata, options?: SetMetadataOptions): Promise<SetMetadataResponse>;
 | 
			
		||||
    setMetadata(metadata: Metadata, callback: MetadataCallback): void;
 | 
			
		||||
    setMetadata(metadata: Metadata, options: SetMetadataOptions, callback: MetadataCallback): void;
 | 
			
		||||
    /**
 | 
			
		||||
     * Make an authenticated API request.
 | 
			
		||||
     *
 | 
			
		||||
     * @private
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} reqOpts - Request options that are passed to `request`.
 | 
			
		||||
     * @param {string} reqOpts.uri - A URI relative to the baseUrl.
 | 
			
		||||
     * @param {function} callback - The callback function passed to `request`.
 | 
			
		||||
     */
 | 
			
		||||
    private request_;
 | 
			
		||||
    /**
 | 
			
		||||
     * Make an authenticated API request.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} reqOpts - Request options that are passed to `request`.
 | 
			
		||||
     * @param {string} reqOpts.uri - A URI relative to the baseUrl.
 | 
			
		||||
     * @param {function} callback - The callback function passed to `request`.
 | 
			
		||||
     */
 | 
			
		||||
    request(reqOpts: DecorateRequestOptions): Promise<RequestResponse>;
 | 
			
		||||
    request(reqOpts: DecorateRequestOptions, callback: BodyResponseCallback): void;
 | 
			
		||||
    /**
 | 
			
		||||
     * Make an authenticated API request.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} reqOpts - Request options that are passed to `request`.
 | 
			
		||||
     * @param {string} reqOpts.uri - A URI relative to the baseUrl.
 | 
			
		||||
     */
 | 
			
		||||
    requestStream(reqOpts: DecorateRequestOptions): r.Request;
 | 
			
		||||
}
 | 
			
		||||
export { ServiceObject };
 | 
			
		||||
							
								
								
									
										248
									
								
								node_modules/@google-cloud/common/build/src/service-object.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										248
									
								
								node_modules/@google-cloud/common/build/src/service-object.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,248 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
/*!
 | 
			
		||||
 * Copyright 2015 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.
 | 
			
		||||
 */
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
/*!
 | 
			
		||||
 * @module common/service-object
 | 
			
		||||
 */
 | 
			
		||||
const promisify_1 = require("@google-cloud/promisify");
 | 
			
		||||
const arrify = require("arrify");
 | 
			
		||||
const events_1 = require("events");
 | 
			
		||||
const extend = require("extend");
 | 
			
		||||
const util_1 = require("./util");
 | 
			
		||||
/**
 | 
			
		||||
 * ServiceObject is a base class, meant to be inherited from by a "service
 | 
			
		||||
 * object," like a BigQuery dataset or Storage bucket.
 | 
			
		||||
 *
 | 
			
		||||
 * Most of the time, these objects share common functionality; they can be
 | 
			
		||||
 * created or deleted, and you can get or set their metadata.
 | 
			
		||||
 *
 | 
			
		||||
 * By inheriting from this class, a service object will be extended with these
 | 
			
		||||
 * shared behaviors. Note that any method can be overridden when the service
 | 
			
		||||
 * object requires specific behavior.
 | 
			
		||||
 */
 | 
			
		||||
// tslint:disable-next-line no-any
 | 
			
		||||
class ServiceObject extends events_1.EventEmitter {
 | 
			
		||||
    /*
 | 
			
		||||
     * @constructor
 | 
			
		||||
     * @alias module:common/service-object
 | 
			
		||||
     *
 | 
			
		||||
     * @private
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} config - Configuration object.
 | 
			
		||||
     * @param {string} config.baseUrl - The base URL to make API requests to.
 | 
			
		||||
     * @param {string} config.createMethod - The method which creates this object.
 | 
			
		||||
     * @param {string=} config.id - The identifier of the object. For example, the
 | 
			
		||||
     *     name of a Storage bucket or Pub/Sub topic.
 | 
			
		||||
     * @param {object=} config.methods - A map of each method name that should be inherited.
 | 
			
		||||
     * @param {object} config.methods[].reqOpts - Default request options for this
 | 
			
		||||
     *     particular method. A common use case is when `setMetadata` requires a
 | 
			
		||||
     *     `PUT` method to override the default `PATCH`.
 | 
			
		||||
     * @param {object} config.parent - The parent service instance. For example, an
 | 
			
		||||
     *     instance of Storage if the object is Bucket.
 | 
			
		||||
     */
 | 
			
		||||
    constructor(config) {
 | 
			
		||||
        super();
 | 
			
		||||
        this.metadata = {};
 | 
			
		||||
        this.baseUrl = config.baseUrl;
 | 
			
		||||
        this.parent = config.parent; // Parent class.
 | 
			
		||||
        this.id = config.id; // Name or ID (e.g. dataset ID, bucket name, etc).
 | 
			
		||||
        this.createMethod = config.createMethod;
 | 
			
		||||
        this.methods = config.methods || {};
 | 
			
		||||
        this.interceptors = [];
 | 
			
		||||
        this.Promise = this.parent ? this.parent.Promise : undefined;
 | 
			
		||||
        if (config.methods) {
 | 
			
		||||
            Object.getOwnPropertyNames(ServiceObject.prototype)
 | 
			
		||||
                .filter(methodName => {
 | 
			
		||||
                return (
 | 
			
		||||
                // All ServiceObjects need `request`.
 | 
			
		||||
                // clang-format off
 | 
			
		||||
                !/^request/.test(methodName) &&
 | 
			
		||||
                    // clang-format on
 | 
			
		||||
                    // The ServiceObject didn't redefine the method.
 | 
			
		||||
                    // tslint:disable-next-line no-any
 | 
			
		||||
                    this[methodName] ===
 | 
			
		||||
                        // tslint:disable-next-line no-any
 | 
			
		||||
                        ServiceObject.prototype[methodName] &&
 | 
			
		||||
                    // This method isn't wanted.
 | 
			
		||||
                    !config.methods[methodName]);
 | 
			
		||||
            })
 | 
			
		||||
                .forEach(methodName => {
 | 
			
		||||
                // tslint:disable-next-line no-any
 | 
			
		||||
                this[methodName] = undefined;
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    create(optionsOrCallback, callback) {
 | 
			
		||||
        const self = this;
 | 
			
		||||
        const args = [this.id];
 | 
			
		||||
        if (typeof optionsOrCallback === 'function') {
 | 
			
		||||
            callback = optionsOrCallback;
 | 
			
		||||
        }
 | 
			
		||||
        if (typeof optionsOrCallback === 'object') {
 | 
			
		||||
            args.push(optionsOrCallback);
 | 
			
		||||
        }
 | 
			
		||||
        // Wrap the callback to return *this* instance of the object, not the
 | 
			
		||||
        // newly-created one.
 | 
			
		||||
        // tslint: disable-next-line no-any
 | 
			
		||||
        function onCreate(...args) {
 | 
			
		||||
            const [err, instance] = args;
 | 
			
		||||
            if (!err) {
 | 
			
		||||
                self.metadata = instance.metadata;
 | 
			
		||||
                args[1] = self; // replace the created `instance` with this one.
 | 
			
		||||
            }
 | 
			
		||||
            callback(...args);
 | 
			
		||||
        }
 | 
			
		||||
        args.push(onCreate);
 | 
			
		||||
        this.createMethod.apply(null, args);
 | 
			
		||||
    }
 | 
			
		||||
    delete(optionsOrCallback, cb) {
 | 
			
		||||
        const [options, callback] = util_1.util.maybeOptionsOrCallback(optionsOrCallback, cb);
 | 
			
		||||
        const methodConfig = (typeof this.methods.delete === 'object' && this.methods.delete) || {};
 | 
			
		||||
        const reqOpts = extend(true, {
 | 
			
		||||
            method: 'DELETE',
 | 
			
		||||
            uri: '',
 | 
			
		||||
        }, methodConfig.reqOpts, {
 | 
			
		||||
            qs: options,
 | 
			
		||||
        });
 | 
			
		||||
        // The `request` method may have been overridden to hold any special
 | 
			
		||||
        // behavior. Ensure we call the original `request` method.
 | 
			
		||||
        ServiceObject.prototype.request.call(this, reqOpts, callback);
 | 
			
		||||
    }
 | 
			
		||||
    exists(optionsOrCallback, cb) {
 | 
			
		||||
        const [options, callback] = util_1.util.maybeOptionsOrCallback(optionsOrCallback, cb);
 | 
			
		||||
        this.get(options, err => {
 | 
			
		||||
            if (err) {
 | 
			
		||||
                if (err.code === 404) {
 | 
			
		||||
                    callback(null, false);
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    callback(err);
 | 
			
		||||
                }
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            callback(null, true);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    get(optionsOrCallback, cb) {
 | 
			
		||||
        const self = this;
 | 
			
		||||
        const [opts, callback] = util_1.util.maybeOptionsOrCallback(optionsOrCallback, cb);
 | 
			
		||||
        const options = Object.assign({}, opts);
 | 
			
		||||
        const autoCreate = options.autoCreate && typeof this.create === 'function';
 | 
			
		||||
        delete options.autoCreate;
 | 
			
		||||
        function onCreate(err, instance, apiResponse) {
 | 
			
		||||
            if (err) {
 | 
			
		||||
                if (err.code === 409) {
 | 
			
		||||
                    self.get(options, callback);
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
                callback(err, null, apiResponse);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            callback(null, instance, apiResponse);
 | 
			
		||||
        }
 | 
			
		||||
        this.getMetadata(options, (err, metadata) => {
 | 
			
		||||
            if (err) {
 | 
			
		||||
                if (err.code === 404 && autoCreate) {
 | 
			
		||||
                    const args = [];
 | 
			
		||||
                    if (Object.keys(options).length > 0) {
 | 
			
		||||
                        args.push(options);
 | 
			
		||||
                    }
 | 
			
		||||
                    args.push(onCreate);
 | 
			
		||||
                    self.create(...args);
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
                callback(err, null, metadata);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            callback(null, self, metadata);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    getMetadata(optionsOrCallback, cb) {
 | 
			
		||||
        const [options, callback] = util_1.util.maybeOptionsOrCallback(optionsOrCallback, cb);
 | 
			
		||||
        const methodConfig = (typeof this.methods.getMetadata === 'object' &&
 | 
			
		||||
            this.methods.getMetadata) ||
 | 
			
		||||
            {};
 | 
			
		||||
        const reqOpts = extend(true, {
 | 
			
		||||
            uri: '',
 | 
			
		||||
        }, methodConfig.reqOpts, {
 | 
			
		||||
            qs: options,
 | 
			
		||||
        });
 | 
			
		||||
        // The `request` method may have been overridden to hold any special
 | 
			
		||||
        // behavior. Ensure we call the original `request` method.
 | 
			
		||||
        ServiceObject.prototype.request.call(this, reqOpts, (err, body, res) => {
 | 
			
		||||
            this.metadata = body;
 | 
			
		||||
            callback(err, this.metadata, res);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    setMetadata(metadata, optionsOrCallback, cb) {
 | 
			
		||||
        const [options, callback] = util_1.util.maybeOptionsOrCallback(optionsOrCallback, cb);
 | 
			
		||||
        const methodConfig = (typeof this.methods.setMetadata === 'object' &&
 | 
			
		||||
            this.methods.setMetadata) ||
 | 
			
		||||
            {};
 | 
			
		||||
        const reqOpts = extend(true, {}, {
 | 
			
		||||
            method: 'PATCH',
 | 
			
		||||
            uri: '',
 | 
			
		||||
        }, methodConfig.reqOpts, {
 | 
			
		||||
            json: metadata,
 | 
			
		||||
            qs: options,
 | 
			
		||||
        });
 | 
			
		||||
        // The `request` method may have been overridden to hold any special
 | 
			
		||||
        // behavior. Ensure we call the original `request` method.
 | 
			
		||||
        ServiceObject.prototype.request.call(this, reqOpts, (err, body, res) => {
 | 
			
		||||
            this.metadata = body;
 | 
			
		||||
            callback(err, this.metadata, res);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    request_(reqOpts, callback) {
 | 
			
		||||
        reqOpts = extend(true, {}, reqOpts);
 | 
			
		||||
        const isAbsoluteUrl = reqOpts.uri.indexOf('http') === 0;
 | 
			
		||||
        const uriComponents = [this.baseUrl, this.id || '', reqOpts.uri];
 | 
			
		||||
        if (isAbsoluteUrl) {
 | 
			
		||||
            uriComponents.splice(0, uriComponents.indexOf(reqOpts.uri));
 | 
			
		||||
        }
 | 
			
		||||
        reqOpts.uri = uriComponents
 | 
			
		||||
            .filter(x => x.trim()) // Limit to non-empty strings.
 | 
			
		||||
            .map(uriComponent => {
 | 
			
		||||
            const trimSlashesRegex = /^\/*|\/*$/g;
 | 
			
		||||
            return uriComponent.replace(trimSlashesRegex, '');
 | 
			
		||||
        })
 | 
			
		||||
            .join('/');
 | 
			
		||||
        const childInterceptors = arrify(reqOpts.interceptors_);
 | 
			
		||||
        const localInterceptors = [].slice.call(this.interceptors);
 | 
			
		||||
        reqOpts.interceptors_ = childInterceptors.concat(localInterceptors);
 | 
			
		||||
        if (reqOpts.shouldReturnStream) {
 | 
			
		||||
            return this.parent.requestStream(reqOpts);
 | 
			
		||||
        }
 | 
			
		||||
        this.parent.request(reqOpts, callback);
 | 
			
		||||
    }
 | 
			
		||||
    request(reqOpts, callback) {
 | 
			
		||||
        this.request_(reqOpts, callback);
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Make an authenticated API request.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} reqOpts - Request options that are passed to `request`.
 | 
			
		||||
     * @param {string} reqOpts.uri - A URI relative to the baseUrl.
 | 
			
		||||
     */
 | 
			
		||||
    requestStream(reqOpts) {
 | 
			
		||||
        const opts = extend(true, reqOpts, { shouldReturnStream: true });
 | 
			
		||||
        return this.request_(opts);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.ServiceObject = ServiceObject;
 | 
			
		||||
promisify_1.promisifyAll(ServiceObject);
 | 
			
		||||
//# sourceMappingURL=service-object.js.map
 | 
			
		||||
							
								
								
									
										113
									
								
								node_modules/@google-cloud/common/build/src/service.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								node_modules/@google-cloud/common/build/src/service.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,113 @@
 | 
			
		||||
/*!
 | 
			
		||||
 * Copyright 2015 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.
 | 
			
		||||
 */
 | 
			
		||||
import { GoogleAuth, GoogleAuthOptions } from 'google-auth-library';
 | 
			
		||||
import * as r from 'teeny-request';
 | 
			
		||||
import { Interceptor } from './service-object';
 | 
			
		||||
import { BodyResponseCallback, DecorateRequestOptions, MakeAuthenticatedRequest, PackageJson } from './util';
 | 
			
		||||
export interface StreamRequestOptions extends DecorateRequestOptions {
 | 
			
		||||
    shouldReturnStream: true;
 | 
			
		||||
}
 | 
			
		||||
export interface ServiceConfig {
 | 
			
		||||
    /**
 | 
			
		||||
     * The base URL to make API requests to.
 | 
			
		||||
     */
 | 
			
		||||
    baseUrl: string;
 | 
			
		||||
    /**
 | 
			
		||||
     * The API Endpoint to use when connecting to the service.
 | 
			
		||||
     * Example:  storage.googleapis.com
 | 
			
		||||
     */
 | 
			
		||||
    apiEndpoint: string;
 | 
			
		||||
    /**
 | 
			
		||||
     * The scopes required for the request.
 | 
			
		||||
     */
 | 
			
		||||
    scopes: string[];
 | 
			
		||||
    projectIdRequired?: boolean;
 | 
			
		||||
    packageJson: PackageJson;
 | 
			
		||||
    /**
 | 
			
		||||
     * Reuse an existing GoogleAuth client instead of creating a new one.
 | 
			
		||||
     */
 | 
			
		||||
    authClient?: GoogleAuth;
 | 
			
		||||
}
 | 
			
		||||
export interface ServiceOptions extends GoogleAuthOptions {
 | 
			
		||||
    interceptors_?: Interceptor[];
 | 
			
		||||
    promise?: PromiseConstructor;
 | 
			
		||||
    email?: string;
 | 
			
		||||
    token?: string;
 | 
			
		||||
    timeout?: number;
 | 
			
		||||
}
 | 
			
		||||
export declare class Service {
 | 
			
		||||
    baseUrl: string;
 | 
			
		||||
    private globalInterceptors;
 | 
			
		||||
    private interceptors;
 | 
			
		||||
    private packageJson;
 | 
			
		||||
    projectId: string;
 | 
			
		||||
    private projectIdRequired;
 | 
			
		||||
    Promise: PromiseConstructor;
 | 
			
		||||
    makeAuthenticatedRequest: MakeAuthenticatedRequest;
 | 
			
		||||
    authClient: GoogleAuth;
 | 
			
		||||
    private getCredentials;
 | 
			
		||||
    readonly apiEndpoint: string;
 | 
			
		||||
    timeout?: number;
 | 
			
		||||
    /**
 | 
			
		||||
     * Service is a base class, meant to be inherited from by a "service," like
 | 
			
		||||
     * BigQuery or Storage.
 | 
			
		||||
     *
 | 
			
		||||
     * This handles making authenticated requests by exposing a `makeReq_`
 | 
			
		||||
     * function.
 | 
			
		||||
     *
 | 
			
		||||
     * @constructor
 | 
			
		||||
     * @alias module:common/service
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} config - Configuration object.
 | 
			
		||||
     * @param {string} config.baseUrl - The base URL to make API requests to.
 | 
			
		||||
     * @param {string[]} config.scopes - The scopes required for the request.
 | 
			
		||||
     * @param {object=} options - [Configuration object](#/docs).
 | 
			
		||||
     */
 | 
			
		||||
    constructor(config: ServiceConfig, options?: ServiceOptions);
 | 
			
		||||
    /**
 | 
			
		||||
     * Get and update the Service's project ID.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {function} callback - The callback function.
 | 
			
		||||
     */
 | 
			
		||||
    getProjectId(): Promise<string>;
 | 
			
		||||
    getProjectId(callback: (err: Error | null, projectId?: string) => void): void;
 | 
			
		||||
    protected getProjectIdAsync(): Promise<string>;
 | 
			
		||||
    /**
 | 
			
		||||
     * Make an authenticated API request.
 | 
			
		||||
     *
 | 
			
		||||
     * @private
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} reqOpts - Request options that are passed to `request`.
 | 
			
		||||
     * @param {string} reqOpts.uri - A URI relative to the baseUrl.
 | 
			
		||||
     * @param {function} callback - The callback function passed to `request`.
 | 
			
		||||
     */
 | 
			
		||||
    private request_;
 | 
			
		||||
    /**
 | 
			
		||||
     * Make an authenticated API request.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} reqOpts - Request options that are passed to `request`.
 | 
			
		||||
     * @param {string} reqOpts.uri - A URI relative to the baseUrl.
 | 
			
		||||
     * @param {function} callback - The callback function passed to `request`.
 | 
			
		||||
     */
 | 
			
		||||
    request(reqOpts: DecorateRequestOptions, callback: BodyResponseCallback): void;
 | 
			
		||||
    /**
 | 
			
		||||
     * Make an authenticated API request.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} reqOpts - Request options that are passed to `request`.
 | 
			
		||||
     * @param {string} reqOpts.uri - A URI relative to the baseUrl.
 | 
			
		||||
     */
 | 
			
		||||
    requestStream(reqOpts: DecorateRequestOptions): r.Request;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										154
									
								
								node_modules/@google-cloud/common/build/src/service.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										154
									
								
								node_modules/@google-cloud/common/build/src/service.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,154 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
/*!
 | 
			
		||||
 * Copyright 2015 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.
 | 
			
		||||
 */
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
/*!
 | 
			
		||||
 * @module common/service
 | 
			
		||||
 */
 | 
			
		||||
const arrify = require("arrify");
 | 
			
		||||
const extend = require("extend");
 | 
			
		||||
const util_1 = require("./util");
 | 
			
		||||
const PROJECT_ID_TOKEN = '{{projectId}}';
 | 
			
		||||
class Service {
 | 
			
		||||
    /**
 | 
			
		||||
     * Service is a base class, meant to be inherited from by a "service," like
 | 
			
		||||
     * BigQuery or Storage.
 | 
			
		||||
     *
 | 
			
		||||
     * This handles making authenticated requests by exposing a `makeReq_`
 | 
			
		||||
     * function.
 | 
			
		||||
     *
 | 
			
		||||
     * @constructor
 | 
			
		||||
     * @alias module:common/service
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} config - Configuration object.
 | 
			
		||||
     * @param {string} config.baseUrl - The base URL to make API requests to.
 | 
			
		||||
     * @param {string[]} config.scopes - The scopes required for the request.
 | 
			
		||||
     * @param {object=} options - [Configuration object](#/docs).
 | 
			
		||||
     */
 | 
			
		||||
    constructor(config, options = {}) {
 | 
			
		||||
        this.baseUrl = config.baseUrl;
 | 
			
		||||
        this.apiEndpoint = config.apiEndpoint;
 | 
			
		||||
        this.timeout = options.timeout;
 | 
			
		||||
        this.globalInterceptors = arrify(options.interceptors_);
 | 
			
		||||
        this.interceptors = [];
 | 
			
		||||
        this.packageJson = config.packageJson;
 | 
			
		||||
        this.projectId = options.projectId || PROJECT_ID_TOKEN;
 | 
			
		||||
        this.projectIdRequired = config.projectIdRequired !== false;
 | 
			
		||||
        this.Promise = options.promise || Promise;
 | 
			
		||||
        const reqCfg = extend({}, config, {
 | 
			
		||||
            projectIdRequired: this.projectIdRequired,
 | 
			
		||||
            projectId: this.projectId,
 | 
			
		||||
            credentials: options.credentials,
 | 
			
		||||
            keyFile: options.keyFilename,
 | 
			
		||||
            email: options.email,
 | 
			
		||||
            token: options.token,
 | 
			
		||||
        });
 | 
			
		||||
        this.makeAuthenticatedRequest = util_1.util.makeAuthenticatedRequestFactory(reqCfg);
 | 
			
		||||
        this.authClient = this.makeAuthenticatedRequest.authClient;
 | 
			
		||||
        this.getCredentials = this.makeAuthenticatedRequest.getCredentials;
 | 
			
		||||
        const isCloudFunctionEnv = !!process.env.FUNCTION_NAME;
 | 
			
		||||
        if (isCloudFunctionEnv) {
 | 
			
		||||
            this.interceptors.push({
 | 
			
		||||
                request(reqOpts) {
 | 
			
		||||
                    reqOpts.forever = false;
 | 
			
		||||
                    return reqOpts;
 | 
			
		||||
                },
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    getProjectId(callback) {
 | 
			
		||||
        if (!callback) {
 | 
			
		||||
            return this.getProjectIdAsync();
 | 
			
		||||
        }
 | 
			
		||||
        this.getProjectIdAsync().then(p => callback(null, p), callback);
 | 
			
		||||
    }
 | 
			
		||||
    async getProjectIdAsync() {
 | 
			
		||||
        const projectId = await this.authClient.getProjectId();
 | 
			
		||||
        if (this.projectId === PROJECT_ID_TOKEN && projectId) {
 | 
			
		||||
            this.projectId = projectId;
 | 
			
		||||
        }
 | 
			
		||||
        return this.projectId;
 | 
			
		||||
    }
 | 
			
		||||
    request_(reqOpts, callback) {
 | 
			
		||||
        reqOpts = extend(true, {}, reqOpts, { timeout: this.timeout });
 | 
			
		||||
        const isAbsoluteUrl = reqOpts.uri.indexOf('http') === 0;
 | 
			
		||||
        const uriComponents = [this.baseUrl];
 | 
			
		||||
        if (this.projectIdRequired) {
 | 
			
		||||
            uriComponents.push('projects');
 | 
			
		||||
            uriComponents.push(this.projectId);
 | 
			
		||||
        }
 | 
			
		||||
        uriComponents.push(reqOpts.uri);
 | 
			
		||||
        if (isAbsoluteUrl) {
 | 
			
		||||
            uriComponents.splice(0, uriComponents.indexOf(reqOpts.uri));
 | 
			
		||||
        }
 | 
			
		||||
        reqOpts.uri = uriComponents
 | 
			
		||||
            .map(uriComponent => {
 | 
			
		||||
            const trimSlashesRegex = /^\/*|\/*$/g;
 | 
			
		||||
            return uriComponent.replace(trimSlashesRegex, '');
 | 
			
		||||
        })
 | 
			
		||||
            .join('/')
 | 
			
		||||
            // Some URIs have colon separators.
 | 
			
		||||
            // Bad: https://.../projects/:list
 | 
			
		||||
            // Good: https://.../projects:list
 | 
			
		||||
            .replace(/\/:/g, ':');
 | 
			
		||||
        // Interceptors should be called in the order they were assigned.
 | 
			
		||||
        const combinedInterceptors = [].slice
 | 
			
		||||
            .call(this.globalInterceptors)
 | 
			
		||||
            .concat(this.interceptors)
 | 
			
		||||
            .concat(arrify(reqOpts.interceptors_));
 | 
			
		||||
        let interceptor;
 | 
			
		||||
        while (
 | 
			
		||||
        // tslint:disable-next-line:no-conditional-assignment
 | 
			
		||||
        (interceptor = combinedInterceptors.shift()) &&
 | 
			
		||||
            interceptor.request) {
 | 
			
		||||
            reqOpts = interceptor.request(reqOpts);
 | 
			
		||||
        }
 | 
			
		||||
        delete reqOpts.interceptors_;
 | 
			
		||||
        const pkg = this.packageJson;
 | 
			
		||||
        reqOpts.headers = extend({}, reqOpts.headers, {
 | 
			
		||||
            'User-Agent': util_1.util.getUserAgentFromPackageJson(pkg),
 | 
			
		||||
            'x-goog-api-client': `gl-node/${process.versions.node} gccl/${pkg.version}`,
 | 
			
		||||
        });
 | 
			
		||||
        if (reqOpts.shouldReturnStream) {
 | 
			
		||||
            return this.makeAuthenticatedRequest(reqOpts);
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            this.makeAuthenticatedRequest(reqOpts, callback);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Make an authenticated API request.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} reqOpts - Request options that are passed to `request`.
 | 
			
		||||
     * @param {string} reqOpts.uri - A URI relative to the baseUrl.
 | 
			
		||||
     * @param {function} callback - The callback function passed to `request`.
 | 
			
		||||
     */
 | 
			
		||||
    request(reqOpts, callback) {
 | 
			
		||||
        Service.prototype.request_.call(this, reqOpts, callback);
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Make an authenticated API request.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} reqOpts - Request options that are passed to `request`.
 | 
			
		||||
     * @param {string} reqOpts.uri - A URI relative to the baseUrl.
 | 
			
		||||
     */
 | 
			
		||||
    requestStream(reqOpts) {
 | 
			
		||||
        const opts = extend(true, reqOpts, { shouldReturnStream: true });
 | 
			
		||||
        return Service.prototype.request_.call(this, opts);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.Service = Service;
 | 
			
		||||
//# sourceMappingURL=service.js.map
 | 
			
		||||
							
								
								
									
										308
									
								
								node_modules/@google-cloud/common/build/src/util.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										308
									
								
								node_modules/@google-cloud/common/build/src/util.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,308 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Copyright 2014 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.
 | 
			
		||||
 */
 | 
			
		||||
/// <reference types="node" />
 | 
			
		||||
import { GoogleAuth, GoogleAuthOptions } from 'google-auth-library';
 | 
			
		||||
import { CredentialBody } from 'google-auth-library';
 | 
			
		||||
import * as r from 'teeny-request';
 | 
			
		||||
import { Duplex, DuplexOptions, Readable, Writable } from 'stream';
 | 
			
		||||
import { Interceptor } from './service-object';
 | 
			
		||||
export declare type ResponseBody = any;
 | 
			
		||||
export interface DuplexifyOptions extends DuplexOptions {
 | 
			
		||||
    autoDestroy?: boolean;
 | 
			
		||||
    end?: boolean;
 | 
			
		||||
}
 | 
			
		||||
export interface Duplexify extends Duplex {
 | 
			
		||||
    readonly destroyed: boolean;
 | 
			
		||||
    setWritable(writable: Writable | false | null): void;
 | 
			
		||||
    setReadable(readable: Readable | false | null): void;
 | 
			
		||||
}
 | 
			
		||||
export interface DuplexifyConstructor {
 | 
			
		||||
    obj(writable?: Writable | false | null, readable?: Readable | false | null, options?: DuplexifyOptions): Duplexify;
 | 
			
		||||
    new (writable?: Writable | false | null, readable?: Readable | false | null, options?: DuplexifyOptions): Duplexify;
 | 
			
		||||
    (writable?: Writable | false | null, readable?: Readable | false | null, options?: DuplexifyOptions): Duplexify;
 | 
			
		||||
}
 | 
			
		||||
export interface ParsedHttpRespMessage {
 | 
			
		||||
    resp: r.Response;
 | 
			
		||||
    err?: ApiError;
 | 
			
		||||
}
 | 
			
		||||
export interface MakeAuthenticatedRequest {
 | 
			
		||||
    (reqOpts: DecorateRequestOptions): Duplexify;
 | 
			
		||||
    (reqOpts: DecorateRequestOptions, options?: MakeAuthenticatedRequestOptions): void | Abortable;
 | 
			
		||||
    (reqOpts: DecorateRequestOptions, callback?: BodyResponseCallback): void | Abortable;
 | 
			
		||||
    (reqOpts: DecorateRequestOptions, optionsOrCallback?: MakeAuthenticatedRequestOptions | BodyResponseCallback): void | Abortable | Duplexify;
 | 
			
		||||
    getCredentials: (callback: (err?: Error | null, credentials?: CredentialBody) => void) => void;
 | 
			
		||||
    authClient: GoogleAuth;
 | 
			
		||||
}
 | 
			
		||||
export interface Abortable {
 | 
			
		||||
    abort(): void;
 | 
			
		||||
}
 | 
			
		||||
export declare type AbortableDuplex = Duplexify & Abortable;
 | 
			
		||||
export interface PackageJson {
 | 
			
		||||
    name: string;
 | 
			
		||||
    version: string;
 | 
			
		||||
}
 | 
			
		||||
export interface MakeAuthenticatedRequestFactoryConfig extends GoogleAuthOptions {
 | 
			
		||||
    /**
 | 
			
		||||
     * Automatically retry requests if the response is related to rate limits or
 | 
			
		||||
     * certain intermittent server errors. We will exponentially backoff
 | 
			
		||||
     * subsequent requests by default. (default: true)
 | 
			
		||||
     */
 | 
			
		||||
    autoRetry?: boolean;
 | 
			
		||||
    /**
 | 
			
		||||
     * If true, just return the provided request options. Default: false.
 | 
			
		||||
     */
 | 
			
		||||
    customEndpoint?: boolean;
 | 
			
		||||
    /**
 | 
			
		||||
     * Account email address, required for PEM/P12 usage.
 | 
			
		||||
     */
 | 
			
		||||
    email?: string;
 | 
			
		||||
    /**
 | 
			
		||||
     * Maximum number of automatic retries attempted before returning the error.
 | 
			
		||||
     * (default: 3)
 | 
			
		||||
     */
 | 
			
		||||
    maxRetries?: number;
 | 
			
		||||
    stream?: Duplexify;
 | 
			
		||||
    /**
 | 
			
		||||
     * A pre-instantiated GoogleAuth client that should be used.
 | 
			
		||||
     * A new will be created if this is not set.
 | 
			
		||||
     */
 | 
			
		||||
    authClient?: GoogleAuth;
 | 
			
		||||
}
 | 
			
		||||
export interface MakeAuthenticatedRequestOptions {
 | 
			
		||||
    onAuthenticated: OnAuthenticatedCallback;
 | 
			
		||||
}
 | 
			
		||||
export interface OnAuthenticatedCallback {
 | 
			
		||||
    (err: Error | null, reqOpts?: DecorateRequestOptions): void;
 | 
			
		||||
}
 | 
			
		||||
export interface GoogleErrorBody {
 | 
			
		||||
    code: number;
 | 
			
		||||
    errors?: GoogleInnerError[];
 | 
			
		||||
    response: r.Response;
 | 
			
		||||
    message?: string;
 | 
			
		||||
}
 | 
			
		||||
export interface GoogleInnerError {
 | 
			
		||||
    reason?: string;
 | 
			
		||||
    message?: string;
 | 
			
		||||
}
 | 
			
		||||
export interface MakeWritableStreamOptions {
 | 
			
		||||
    /**
 | 
			
		||||
     * A connection instance used to get a token with and send the request
 | 
			
		||||
     * through.
 | 
			
		||||
     */
 | 
			
		||||
    connection?: {};
 | 
			
		||||
    /**
 | 
			
		||||
     * Metadata to send at the head of the request.
 | 
			
		||||
     */
 | 
			
		||||
    metadata?: {
 | 
			
		||||
        contentType?: string;
 | 
			
		||||
    };
 | 
			
		||||
    /**
 | 
			
		||||
     * Request object, in the format of a standard Node.js http.request() object.
 | 
			
		||||
     */
 | 
			
		||||
    request?: r.Options;
 | 
			
		||||
    makeAuthenticatedRequest(reqOpts: r.OptionsWithUri, fnobj: {
 | 
			
		||||
        onAuthenticated(err: Error | null, authenticatedReqOpts?: r.Options): void;
 | 
			
		||||
    }): void;
 | 
			
		||||
}
 | 
			
		||||
export interface DecorateRequestOptions extends r.CoreOptions {
 | 
			
		||||
    autoPaginate?: boolean;
 | 
			
		||||
    autoPaginateVal?: boolean;
 | 
			
		||||
    objectMode?: boolean;
 | 
			
		||||
    maxRetries?: number;
 | 
			
		||||
    uri: string;
 | 
			
		||||
    interceptors_?: Interceptor[];
 | 
			
		||||
    shouldReturnStream?: boolean;
 | 
			
		||||
}
 | 
			
		||||
export interface ParsedHttpResponseBody {
 | 
			
		||||
    body: ResponseBody;
 | 
			
		||||
    err?: Error;
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
 * Custom error type for API errors.
 | 
			
		||||
 *
 | 
			
		||||
 * @param {object} errorBody - Error object.
 | 
			
		||||
 */
 | 
			
		||||
export declare class ApiError extends Error {
 | 
			
		||||
    code?: number;
 | 
			
		||||
    errors?: GoogleInnerError[];
 | 
			
		||||
    response?: r.Response;
 | 
			
		||||
    constructor(errorMessage: string);
 | 
			
		||||
    constructor(errorBody: GoogleErrorBody);
 | 
			
		||||
    /**
 | 
			
		||||
     * Pieces together an error message by combining all unique error messages
 | 
			
		||||
     * returned from a single GoogleError
 | 
			
		||||
     *
 | 
			
		||||
     * @private
 | 
			
		||||
     *
 | 
			
		||||
     * @param {GoogleErrorBody} err The original error.
 | 
			
		||||
     * @param {GoogleInnerError[]} [errors] Inner errors, if any.
 | 
			
		||||
     * @returns {string}
 | 
			
		||||
     */
 | 
			
		||||
    static createMultiErrorMessage(err: GoogleErrorBody, errors?: GoogleInnerError[]): string;
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
 * Custom error type for partial errors returned from the API.
 | 
			
		||||
 *
 | 
			
		||||
 * @param {object} b - Error object.
 | 
			
		||||
 */
 | 
			
		||||
export declare class PartialFailureError extends Error {
 | 
			
		||||
    errors?: GoogleInnerError[];
 | 
			
		||||
    response?: r.Response;
 | 
			
		||||
    constructor(b: GoogleErrorBody);
 | 
			
		||||
}
 | 
			
		||||
export interface BodyResponseCallback {
 | 
			
		||||
    (err: Error | ApiError | null, body?: ResponseBody, res?: r.Response): void;
 | 
			
		||||
}
 | 
			
		||||
export interface MakeRequestConfig {
 | 
			
		||||
    /**
 | 
			
		||||
     * Automatically retry requests if the response is related to rate limits or
 | 
			
		||||
     * certain intermittent server errors. We will exponentially backoff
 | 
			
		||||
     * subsequent requests by default. (default: true)
 | 
			
		||||
     */
 | 
			
		||||
    autoRetry?: boolean;
 | 
			
		||||
    /**
 | 
			
		||||
     * Maximum number of automatic retries attempted before returning the error.
 | 
			
		||||
     * (default: 3)
 | 
			
		||||
     */
 | 
			
		||||
    maxRetries?: number;
 | 
			
		||||
    retries?: number;
 | 
			
		||||
    stream?: Duplexify;
 | 
			
		||||
    shouldRetryFn?: (response?: r.Response) => boolean;
 | 
			
		||||
}
 | 
			
		||||
export declare class Util {
 | 
			
		||||
    ApiError: typeof ApiError;
 | 
			
		||||
    PartialFailureError: typeof PartialFailureError;
 | 
			
		||||
    /**
 | 
			
		||||
     * No op.
 | 
			
		||||
     *
 | 
			
		||||
     * @example
 | 
			
		||||
     * function doSomething(callback) {
 | 
			
		||||
     *   callback = callback || noop;
 | 
			
		||||
     * }
 | 
			
		||||
     */
 | 
			
		||||
    noop(): void;
 | 
			
		||||
    /**
 | 
			
		||||
     * Uniformly process an API response.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {*} err - Error value.
 | 
			
		||||
     * @param {*} resp - Response value.
 | 
			
		||||
     * @param {*} body - Body value.
 | 
			
		||||
     * @param {function} callback - The callback function.
 | 
			
		||||
     */
 | 
			
		||||
    handleResp(err: Error | null, resp?: r.Response | null, body?: ResponseBody, callback?: BodyResponseCallback): void;
 | 
			
		||||
    /**
 | 
			
		||||
     * Sniff an incoming HTTP response message for errors.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} httpRespMessage - An incoming HTTP response message from `request`.
 | 
			
		||||
     * @return {object} parsedHttpRespMessage - The parsed response.
 | 
			
		||||
     * @param {?error} parsedHttpRespMessage.err - An error detected.
 | 
			
		||||
     * @param {object} parsedHttpRespMessage.resp - The original response object.
 | 
			
		||||
     */
 | 
			
		||||
    parseHttpRespMessage(httpRespMessage: r.Response): ParsedHttpRespMessage;
 | 
			
		||||
    /**
 | 
			
		||||
     * Parse the response body from an HTTP request.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} body - The response body.
 | 
			
		||||
     * @return {object} parsedHttpRespMessage - The parsed response.
 | 
			
		||||
     * @param {?error} parsedHttpRespMessage.err - An error detected.
 | 
			
		||||
     * @param {object} parsedHttpRespMessage.body - The original body value provided
 | 
			
		||||
     *     will try to be JSON.parse'd. If it's successful, the parsed value will
 | 
			
		||||
     * be returned here, otherwise the original value and an error will be returned.
 | 
			
		||||
     */
 | 
			
		||||
    parseHttpRespBody(body: ResponseBody): ParsedHttpResponseBody;
 | 
			
		||||
    /**
 | 
			
		||||
     * Take a Duplexify stream, fetch an authenticated connection header, and
 | 
			
		||||
     * create an outgoing writable stream.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {Duplexify} dup - Duplexify stream.
 | 
			
		||||
     * @param {object} options - Configuration object.
 | 
			
		||||
     * @param {module:common/connection} options.connection - A connection instance used to get a token with and send the request through.
 | 
			
		||||
     * @param {object} options.metadata - Metadata to send at the head of the request.
 | 
			
		||||
     * @param {object} options.request - Request object, in the format of a standard Node.js http.request() object.
 | 
			
		||||
     * @param {string=} options.request.method - Default: "POST".
 | 
			
		||||
     * @param {string=} options.request.qs.uploadType - Default: "multipart".
 | 
			
		||||
     * @param {string=} options.streamContentType - Default: "application/octet-stream".
 | 
			
		||||
     * @param {function} onComplete - Callback, executed after the writable Request stream has completed.
 | 
			
		||||
     */
 | 
			
		||||
    makeWritableStream(dup: Duplexify, options: MakeWritableStreamOptions, onComplete?: Function): void;
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns true if the API request should be retried, given the error that was
 | 
			
		||||
     * given the first time the request was attempted. This is used for rate limit
 | 
			
		||||
     * related errors as well as intermittent server errors.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {error} err - The API error to check if it is appropriate to retry.
 | 
			
		||||
     * @return {boolean} True if the API request should be retried, false otherwise.
 | 
			
		||||
     */
 | 
			
		||||
    shouldRetryRequest(err?: ApiError): boolean;
 | 
			
		||||
    /**
 | 
			
		||||
     * Get a function for making authenticated requests.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} config - Configuration object.
 | 
			
		||||
     * @param {boolean=} config.autoRetry - Automatically retry requests if the
 | 
			
		||||
     *     response is related to rate limits or certain intermittent server
 | 
			
		||||
     * errors. We will exponentially backoff subsequent requests by default.
 | 
			
		||||
     * (default: true)
 | 
			
		||||
     * @param {object=} config.credentials - Credentials object.
 | 
			
		||||
     * @param {boolean=} config.customEndpoint - If true, just return the provided request options. Default: false.
 | 
			
		||||
     * @param {string=} config.email - Account email address, required for PEM/P12 usage.
 | 
			
		||||
     * @param {number=} config.maxRetries - Maximum number of automatic retries attempted before returning the error. (default: 3)
 | 
			
		||||
     * @param {string=} config.keyFile - Path to a .json, .pem, or .p12 keyfile.
 | 
			
		||||
     * @param {array} config.scopes - Array of scopes required for the API.
 | 
			
		||||
     */
 | 
			
		||||
    makeAuthenticatedRequestFactory(config: MakeAuthenticatedRequestFactoryConfig): MakeAuthenticatedRequest;
 | 
			
		||||
    /**
 | 
			
		||||
     * Make a request through the `retryRequest` module with built-in error
 | 
			
		||||
     * handling and exponential back off.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} reqOpts - Request options in the format `request` expects.
 | 
			
		||||
     * @param {object=} config - Configuration object.
 | 
			
		||||
     * @param {boolean=} config.autoRetry - Automatically retry requests if the
 | 
			
		||||
     *     response is related to rate limits or certain intermittent server
 | 
			
		||||
     * errors. We will exponentially backoff subsequent requests by default.
 | 
			
		||||
     * (default: true)
 | 
			
		||||
     * @param {number=} config.maxRetries - Maximum number of automatic retries
 | 
			
		||||
     *     attempted before returning the error. (default: 3)
 | 
			
		||||
     * @param {object=} config.request - HTTP module for request calls.
 | 
			
		||||
     * @param {function} callback - The callback function.
 | 
			
		||||
     */
 | 
			
		||||
    makeRequest(reqOpts: DecorateRequestOptions, config: MakeRequestConfig, callback: BodyResponseCallback): void | Abortable;
 | 
			
		||||
    /**
 | 
			
		||||
     * Decorate the options about to be made in a request.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} reqOpts - The options to be passed to `request`.
 | 
			
		||||
     * @param {string} projectId - The project ID.
 | 
			
		||||
     * @return {object} reqOpts - The decorated reqOpts.
 | 
			
		||||
     */
 | 
			
		||||
    decorateRequest(reqOpts: DecorateRequestOptions, projectId: string): DecorateRequestOptions;
 | 
			
		||||
    isCustomType(unknown: any, module: string): boolean;
 | 
			
		||||
    /**
 | 
			
		||||
     * Create a properly-formatted User-Agent string from a package.json file.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} packageJson - A module's package.json file.
 | 
			
		||||
     * @return {string} userAgent - The formatted User-Agent string.
 | 
			
		||||
     */
 | 
			
		||||
    getUserAgentFromPackageJson(packageJson: PackageJson): string;
 | 
			
		||||
    /**
 | 
			
		||||
     * Given two parameters, figure out if this is either:
 | 
			
		||||
     *  - Just a callback function
 | 
			
		||||
     *  - An options object, and then a callback function
 | 
			
		||||
     * @param optionsOrCallback An options object or callback.
 | 
			
		||||
     * @param cb A potentially undefined callback.
 | 
			
		||||
     */
 | 
			
		||||
    maybeOptionsOrCallback<T = {}, C = (err?: Error) => void>(optionsOrCallback?: T | C, cb?: C): [T, C];
 | 
			
		||||
}
 | 
			
		||||
declare const util: Util;
 | 
			
		||||
export { util };
 | 
			
		||||
							
								
								
									
										523
									
								
								node_modules/@google-cloud/common/build/src/util.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										523
									
								
								node_modules/@google-cloud/common/build/src/util.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,523 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
/**
 | 
			
		||||
 * Copyright 2014 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.
 | 
			
		||||
 */
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
/*!
 | 
			
		||||
 * @module common/util
 | 
			
		||||
 */
 | 
			
		||||
const projectify_1 = require("@google-cloud/projectify");
 | 
			
		||||
const ent = require("ent");
 | 
			
		||||
const extend = require("extend");
 | 
			
		||||
const google_auth_library_1 = require("google-auth-library");
 | 
			
		||||
const retryRequest = require("retry-request");
 | 
			
		||||
const stream_1 = require("stream");
 | 
			
		||||
const teeny_request_1 = require("teeny-request");
 | 
			
		||||
const duplexify = require('duplexify');
 | 
			
		||||
const requestDefaults = {
 | 
			
		||||
    timeout: 60000,
 | 
			
		||||
    gzip: true,
 | 
			
		||||
    forever: true,
 | 
			
		||||
    pool: {
 | 
			
		||||
        maxSockets: Infinity,
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
/**
 | 
			
		||||
 * Custom error type for API errors.
 | 
			
		||||
 *
 | 
			
		||||
 * @param {object} errorBody - Error object.
 | 
			
		||||
 */
 | 
			
		||||
class ApiError extends Error {
 | 
			
		||||
    constructor(errorBodyOrMessage) {
 | 
			
		||||
        super();
 | 
			
		||||
        if (typeof errorBodyOrMessage !== 'object') {
 | 
			
		||||
            this.message = errorBodyOrMessage || '';
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        const errorBody = errorBodyOrMessage;
 | 
			
		||||
        this.code = errorBody.code;
 | 
			
		||||
        this.errors = errorBody.errors;
 | 
			
		||||
        this.response = errorBody.response;
 | 
			
		||||
        try {
 | 
			
		||||
            this.errors = JSON.parse(this.response.body).error.errors;
 | 
			
		||||
        }
 | 
			
		||||
        catch (e) {
 | 
			
		||||
            this.errors = errorBody.errors;
 | 
			
		||||
        }
 | 
			
		||||
        this.message = ApiError.createMultiErrorMessage(errorBody, this.errors);
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Pieces together an error message by combining all unique error messages
 | 
			
		||||
     * returned from a single GoogleError
 | 
			
		||||
     *
 | 
			
		||||
     * @private
 | 
			
		||||
     *
 | 
			
		||||
     * @param {GoogleErrorBody} err The original error.
 | 
			
		||||
     * @param {GoogleInnerError[]} [errors] Inner errors, if any.
 | 
			
		||||
     * @returns {string}
 | 
			
		||||
     */
 | 
			
		||||
    static createMultiErrorMessage(err, errors) {
 | 
			
		||||
        const messages = new Set();
 | 
			
		||||
        if (err.message) {
 | 
			
		||||
            messages.add(err.message);
 | 
			
		||||
        }
 | 
			
		||||
        if (errors && errors.length) {
 | 
			
		||||
            errors.forEach(({ message }) => messages.add(message));
 | 
			
		||||
        }
 | 
			
		||||
        else if (err.response && err.response.body) {
 | 
			
		||||
            messages.add(ent.decode(err.response.body.toString()));
 | 
			
		||||
        }
 | 
			
		||||
        else if (!err.message) {
 | 
			
		||||
            messages.add('A failure occurred during this request.');
 | 
			
		||||
        }
 | 
			
		||||
        let messageArr = Array.from(messages);
 | 
			
		||||
        if (messageArr.length > 1) {
 | 
			
		||||
            messageArr = messageArr.map((message, i) => `    ${i + 1}. ${message}`);
 | 
			
		||||
            messageArr.unshift('Multiple errors occurred during the request. Please see the `errors` array for complete details.\n');
 | 
			
		||||
            messageArr.push('\n');
 | 
			
		||||
        }
 | 
			
		||||
        return messageArr.join('\n');
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.ApiError = ApiError;
 | 
			
		||||
/**
 | 
			
		||||
 * Custom error type for partial errors returned from the API.
 | 
			
		||||
 *
 | 
			
		||||
 * @param {object} b - Error object.
 | 
			
		||||
 */
 | 
			
		||||
class PartialFailureError extends Error {
 | 
			
		||||
    constructor(b) {
 | 
			
		||||
        super();
 | 
			
		||||
        const errorObject = b;
 | 
			
		||||
        this.errors = errorObject.errors;
 | 
			
		||||
        this.name = 'PartialFailureError';
 | 
			
		||||
        this.response = errorObject.response;
 | 
			
		||||
        this.message = ApiError.createMultiErrorMessage(errorObject, this.errors);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.PartialFailureError = PartialFailureError;
 | 
			
		||||
class Util {
 | 
			
		||||
    constructor() {
 | 
			
		||||
        this.ApiError = ApiError;
 | 
			
		||||
        this.PartialFailureError = PartialFailureError;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * No op.
 | 
			
		||||
     *
 | 
			
		||||
     * @example
 | 
			
		||||
     * function doSomething(callback) {
 | 
			
		||||
     *   callback = callback || noop;
 | 
			
		||||
     * }
 | 
			
		||||
     */
 | 
			
		||||
    noop() { }
 | 
			
		||||
    /**
 | 
			
		||||
     * Uniformly process an API response.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {*} err - Error value.
 | 
			
		||||
     * @param {*} resp - Response value.
 | 
			
		||||
     * @param {*} body - Body value.
 | 
			
		||||
     * @param {function} callback - The callback function.
 | 
			
		||||
     */
 | 
			
		||||
    handleResp(err, resp, body, callback) {
 | 
			
		||||
        callback = callback || util.noop;
 | 
			
		||||
        const parsedResp = extend(true, { err: err || null }, resp && util.parseHttpRespMessage(resp), body && util.parseHttpRespBody(body));
 | 
			
		||||
        // Assign the parsed body to resp.body, even if { json: false } was passed
 | 
			
		||||
        // as a request option.
 | 
			
		||||
        // We assume that nobody uses the previously unparsed value of resp.body.
 | 
			
		||||
        if (!parsedResp.err && resp && typeof parsedResp.body === 'object') {
 | 
			
		||||
            parsedResp.resp.body = parsedResp.body;
 | 
			
		||||
        }
 | 
			
		||||
        if (parsedResp.err && resp) {
 | 
			
		||||
            parsedResp.err.response = resp;
 | 
			
		||||
        }
 | 
			
		||||
        callback(parsedResp.err, parsedResp.body, parsedResp.resp);
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Sniff an incoming HTTP response message for errors.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} httpRespMessage - An incoming HTTP response message from `request`.
 | 
			
		||||
     * @return {object} parsedHttpRespMessage - The parsed response.
 | 
			
		||||
     * @param {?error} parsedHttpRespMessage.err - An error detected.
 | 
			
		||||
     * @param {object} parsedHttpRespMessage.resp - The original response object.
 | 
			
		||||
     */
 | 
			
		||||
    parseHttpRespMessage(httpRespMessage) {
 | 
			
		||||
        const parsedHttpRespMessage = {
 | 
			
		||||
            resp: httpRespMessage,
 | 
			
		||||
        };
 | 
			
		||||
        if (httpRespMessage.statusCode < 200 || httpRespMessage.statusCode > 299) {
 | 
			
		||||
            // Unknown error. Format according to ApiError standard.
 | 
			
		||||
            parsedHttpRespMessage.err = new ApiError({
 | 
			
		||||
                errors: new Array(),
 | 
			
		||||
                code: httpRespMessage.statusCode,
 | 
			
		||||
                message: httpRespMessage.statusMessage,
 | 
			
		||||
                response: httpRespMessage,
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        return parsedHttpRespMessage;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Parse the response body from an HTTP request.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} body - The response body.
 | 
			
		||||
     * @return {object} parsedHttpRespMessage - The parsed response.
 | 
			
		||||
     * @param {?error} parsedHttpRespMessage.err - An error detected.
 | 
			
		||||
     * @param {object} parsedHttpRespMessage.body - The original body value provided
 | 
			
		||||
     *     will try to be JSON.parse'd. If it's successful, the parsed value will
 | 
			
		||||
     * be returned here, otherwise the original value and an error will be returned.
 | 
			
		||||
     */
 | 
			
		||||
    parseHttpRespBody(body) {
 | 
			
		||||
        const parsedHttpRespBody = {
 | 
			
		||||
            body,
 | 
			
		||||
        };
 | 
			
		||||
        if (typeof body === 'string') {
 | 
			
		||||
            try {
 | 
			
		||||
                parsedHttpRespBody.body = JSON.parse(body);
 | 
			
		||||
            }
 | 
			
		||||
            catch (err) {
 | 
			
		||||
                parsedHttpRespBody.err = new ApiError(`Cannot parse response as JSON: ${body}`);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (parsedHttpRespBody.body && parsedHttpRespBody.body.error) {
 | 
			
		||||
            // Error from JSON API.
 | 
			
		||||
            parsedHttpRespBody.err = new ApiError(parsedHttpRespBody.body.error);
 | 
			
		||||
        }
 | 
			
		||||
        return parsedHttpRespBody;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Take a Duplexify stream, fetch an authenticated connection header, and
 | 
			
		||||
     * create an outgoing writable stream.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {Duplexify} dup - Duplexify stream.
 | 
			
		||||
     * @param {object} options - Configuration object.
 | 
			
		||||
     * @param {module:common/connection} options.connection - A connection instance used to get a token with and send the request through.
 | 
			
		||||
     * @param {object} options.metadata - Metadata to send at the head of the request.
 | 
			
		||||
     * @param {object} options.request - Request object, in the format of a standard Node.js http.request() object.
 | 
			
		||||
     * @param {string=} options.request.method - Default: "POST".
 | 
			
		||||
     * @param {string=} options.request.qs.uploadType - Default: "multipart".
 | 
			
		||||
     * @param {string=} options.streamContentType - Default: "application/octet-stream".
 | 
			
		||||
     * @param {function} onComplete - Callback, executed after the writable Request stream has completed.
 | 
			
		||||
     */
 | 
			
		||||
    makeWritableStream(dup, options, onComplete) {
 | 
			
		||||
        onComplete = onComplete || util.noop;
 | 
			
		||||
        const writeStream = new stream_1.PassThrough();
 | 
			
		||||
        dup.setWritable(writeStream);
 | 
			
		||||
        const defaultReqOpts = {
 | 
			
		||||
            method: 'POST',
 | 
			
		||||
            qs: {
 | 
			
		||||
                uploadType: 'multipart',
 | 
			
		||||
            },
 | 
			
		||||
            timeout: 0,
 | 
			
		||||
            maxRetries: 0,
 | 
			
		||||
        };
 | 
			
		||||
        const metadata = options.metadata || {};
 | 
			
		||||
        const reqOpts = extend(true, defaultReqOpts, options.request, {
 | 
			
		||||
            multipart: [
 | 
			
		||||
                {
 | 
			
		||||
                    'Content-Type': 'application/json',
 | 
			
		||||
                    body: JSON.stringify(metadata),
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    'Content-Type': metadata.contentType || 'application/octet-stream',
 | 
			
		||||
                    body: writeStream,
 | 
			
		||||
                },
 | 
			
		||||
            ],
 | 
			
		||||
        });
 | 
			
		||||
        options.makeAuthenticatedRequest(reqOpts, {
 | 
			
		||||
            onAuthenticated(err, authenticatedReqOpts) {
 | 
			
		||||
                if (err) {
 | 
			
		||||
                    dup.destroy(err);
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
                const request = teeny_request_1.teenyRequest.defaults(requestDefaults);
 | 
			
		||||
                request(authenticatedReqOpts, (err, resp, body) => {
 | 
			
		||||
                    util.handleResp(err, resp, body, (err, data) => {
 | 
			
		||||
                        if (err) {
 | 
			
		||||
                            dup.destroy(err);
 | 
			
		||||
                            return;
 | 
			
		||||
                        }
 | 
			
		||||
                        dup.emit('response', resp);
 | 
			
		||||
                        onComplete(data);
 | 
			
		||||
                    });
 | 
			
		||||
                });
 | 
			
		||||
            },
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns true if the API request should be retried, given the error that was
 | 
			
		||||
     * given the first time the request was attempted. This is used for rate limit
 | 
			
		||||
     * related errors as well as intermittent server errors.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {error} err - The API error to check if it is appropriate to retry.
 | 
			
		||||
     * @return {boolean} True if the API request should be retried, false otherwise.
 | 
			
		||||
     */
 | 
			
		||||
    shouldRetryRequest(err) {
 | 
			
		||||
        if (err) {
 | 
			
		||||
            if ([429, 500, 502, 503].indexOf(err.code) !== -1) {
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
            if (err.errors) {
 | 
			
		||||
                for (const e of err.errors) {
 | 
			
		||||
                    const reason = e.reason;
 | 
			
		||||
                    if (reason === 'rateLimitExceeded') {
 | 
			
		||||
                        return true;
 | 
			
		||||
                    }
 | 
			
		||||
                    if (reason === 'userRateLimitExceeded') {
 | 
			
		||||
                        return true;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Get a function for making authenticated requests.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} config - Configuration object.
 | 
			
		||||
     * @param {boolean=} config.autoRetry - Automatically retry requests if the
 | 
			
		||||
     *     response is related to rate limits or certain intermittent server
 | 
			
		||||
     * errors. We will exponentially backoff subsequent requests by default.
 | 
			
		||||
     * (default: true)
 | 
			
		||||
     * @param {object=} config.credentials - Credentials object.
 | 
			
		||||
     * @param {boolean=} config.customEndpoint - If true, just return the provided request options. Default: false.
 | 
			
		||||
     * @param {string=} config.email - Account email address, required for PEM/P12 usage.
 | 
			
		||||
     * @param {number=} config.maxRetries - Maximum number of automatic retries attempted before returning the error. (default: 3)
 | 
			
		||||
     * @param {string=} config.keyFile - Path to a .json, .pem, or .p12 keyfile.
 | 
			
		||||
     * @param {array} config.scopes - Array of scopes required for the API.
 | 
			
		||||
     */
 | 
			
		||||
    makeAuthenticatedRequestFactory(config) {
 | 
			
		||||
        const googleAutoAuthConfig = extend({}, config);
 | 
			
		||||
        if (googleAutoAuthConfig.projectId === '{{projectId}}') {
 | 
			
		||||
            delete googleAutoAuthConfig.projectId;
 | 
			
		||||
        }
 | 
			
		||||
        const authClient = googleAutoAuthConfig.authClient || new google_auth_library_1.GoogleAuth(googleAutoAuthConfig);
 | 
			
		||||
        function makeAuthenticatedRequest(reqOpts, optionsOrCallback) {
 | 
			
		||||
            let stream;
 | 
			
		||||
            const reqConfig = extend({}, config);
 | 
			
		||||
            let activeRequest_;
 | 
			
		||||
            if (!optionsOrCallback) {
 | 
			
		||||
                stream = duplexify();
 | 
			
		||||
                reqConfig.stream = stream;
 | 
			
		||||
            }
 | 
			
		||||
            const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : undefined;
 | 
			
		||||
            const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : undefined;
 | 
			
		||||
            const onAuthenticated = (err, authenticatedReqOpts) => {
 | 
			
		||||
                const autoAuthFailed = err &&
 | 
			
		||||
                    err.message.indexOf('Could not load the default credentials') > -1;
 | 
			
		||||
                if (autoAuthFailed) {
 | 
			
		||||
                    // Even though authentication failed, the API might not actually
 | 
			
		||||
                    // care.
 | 
			
		||||
                    authenticatedReqOpts = reqOpts;
 | 
			
		||||
                }
 | 
			
		||||
                if (!err || autoAuthFailed) {
 | 
			
		||||
                    // tslint:disable-next-line:no-any
 | 
			
		||||
                    let projectId = authClient._cachedProjectId;
 | 
			
		||||
                    if (config.projectId && config.projectId !== '{{projectId}}') {
 | 
			
		||||
                        projectId = config.projectId;
 | 
			
		||||
                    }
 | 
			
		||||
                    try {
 | 
			
		||||
                        authenticatedReqOpts = util.decorateRequest(authenticatedReqOpts, projectId);
 | 
			
		||||
                        err = null;
 | 
			
		||||
                    }
 | 
			
		||||
                    catch (e) {
 | 
			
		||||
                        // A projectId was required, but we don't have one.
 | 
			
		||||
                        // Re-use the "Could not load the default credentials error" if
 | 
			
		||||
                        // auto auth failed.
 | 
			
		||||
                        err = err || e;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                if (err) {
 | 
			
		||||
                    if (stream) {
 | 
			
		||||
                        stream.destroy(err);
 | 
			
		||||
                    }
 | 
			
		||||
                    else {
 | 
			
		||||
                        const fn = options && options.onAuthenticated
 | 
			
		||||
                            ? options.onAuthenticated
 | 
			
		||||
                            : callback;
 | 
			
		||||
                        fn(err);
 | 
			
		||||
                    }
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
                if (options && options.onAuthenticated) {
 | 
			
		||||
                    options.onAuthenticated(null, authenticatedReqOpts);
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    activeRequest_ = util.makeRequest(authenticatedReqOpts, reqConfig, callback);
 | 
			
		||||
                }
 | 
			
		||||
            };
 | 
			
		||||
            if (reqConfig.customEndpoint) {
 | 
			
		||||
                // Using a custom API override. Do not use `google-auth-library` for
 | 
			
		||||
                // authentication. (ex: connecting to a local Datastore server)
 | 
			
		||||
                onAuthenticated(null, reqOpts);
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                authClient.authorizeRequest(reqOpts).then(res => {
 | 
			
		||||
                    const opts = extend(true, {}, reqOpts, res);
 | 
			
		||||
                    onAuthenticated(null, opts);
 | 
			
		||||
                }, err => {
 | 
			
		||||
                    onAuthenticated(err);
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
            if (stream) {
 | 
			
		||||
                return stream;
 | 
			
		||||
            }
 | 
			
		||||
            return {
 | 
			
		||||
                abort() {
 | 
			
		||||
                    setImmediate(() => {
 | 
			
		||||
                        if (activeRequest_) {
 | 
			
		||||
                            activeRequest_.abort();
 | 
			
		||||
                            activeRequest_ = null;
 | 
			
		||||
                        }
 | 
			
		||||
                    });
 | 
			
		||||
                },
 | 
			
		||||
            };
 | 
			
		||||
        }
 | 
			
		||||
        const mar = makeAuthenticatedRequest;
 | 
			
		||||
        mar.getCredentials = authClient.getCredentials.bind(authClient);
 | 
			
		||||
        mar.authClient = authClient;
 | 
			
		||||
        return mar;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Make a request through the `retryRequest` module with built-in error
 | 
			
		||||
     * handling and exponential back off.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} reqOpts - Request options in the format `request` expects.
 | 
			
		||||
     * @param {object=} config - Configuration object.
 | 
			
		||||
     * @param {boolean=} config.autoRetry - Automatically retry requests if the
 | 
			
		||||
     *     response is related to rate limits or certain intermittent server
 | 
			
		||||
     * errors. We will exponentially backoff subsequent requests by default.
 | 
			
		||||
     * (default: true)
 | 
			
		||||
     * @param {number=} config.maxRetries - Maximum number of automatic retries
 | 
			
		||||
     *     attempted before returning the error. (default: 3)
 | 
			
		||||
     * @param {object=} config.request - HTTP module for request calls.
 | 
			
		||||
     * @param {function} callback - The callback function.
 | 
			
		||||
     */
 | 
			
		||||
    makeRequest(reqOpts, config, callback) {
 | 
			
		||||
        const options = {
 | 
			
		||||
            request: teeny_request_1.teenyRequest.defaults(requestDefaults),
 | 
			
		||||
            retries: config.autoRetry !== false ? config.maxRetries || 3 : 0,
 | 
			
		||||
            shouldRetryFn(httpRespMessage) {
 | 
			
		||||
                const err = util.parseHttpRespMessage(httpRespMessage).err;
 | 
			
		||||
                return err && util.shouldRetryRequest(err);
 | 
			
		||||
            },
 | 
			
		||||
        };
 | 
			
		||||
        if (typeof reqOpts.maxRetries === 'number') {
 | 
			
		||||
            options.retries = reqOpts.maxRetries;
 | 
			
		||||
        }
 | 
			
		||||
        if (!config.stream) {
 | 
			
		||||
            return retryRequest(reqOpts, options, (err, response, body) => {
 | 
			
		||||
                util.handleResp(err, response, body, callback);
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        const dup = config.stream;
 | 
			
		||||
        // tslint:disable-next-line:no-any
 | 
			
		||||
        let requestStream;
 | 
			
		||||
        const isGetRequest = (reqOpts.method || 'GET').toUpperCase() === 'GET';
 | 
			
		||||
        if (isGetRequest) {
 | 
			
		||||
            requestStream = retryRequest(reqOpts, options);
 | 
			
		||||
            dup.setReadable(requestStream);
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            // Streaming writable HTTP requests cannot be retried.
 | 
			
		||||
            requestStream = options.request(reqOpts);
 | 
			
		||||
            dup.setWritable(requestStream);
 | 
			
		||||
        }
 | 
			
		||||
        // Replay the Request events back to the stream.
 | 
			
		||||
        requestStream
 | 
			
		||||
            .on('error', dup.destroy.bind(dup))
 | 
			
		||||
            .on('response', dup.emit.bind(dup, 'response'))
 | 
			
		||||
            .on('complete', dup.emit.bind(dup, 'complete'));
 | 
			
		||||
        dup.abort = requestStream.abort;
 | 
			
		||||
        return dup;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Decorate the options about to be made in a request.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} reqOpts - The options to be passed to `request`.
 | 
			
		||||
     * @param {string} projectId - The project ID.
 | 
			
		||||
     * @return {object} reqOpts - The decorated reqOpts.
 | 
			
		||||
     */
 | 
			
		||||
    decorateRequest(reqOpts, projectId) {
 | 
			
		||||
        delete reqOpts.autoPaginate;
 | 
			
		||||
        delete reqOpts.autoPaginateVal;
 | 
			
		||||
        delete reqOpts.objectMode;
 | 
			
		||||
        if (reqOpts.qs !== null && typeof reqOpts.qs === 'object') {
 | 
			
		||||
            delete reqOpts.qs.autoPaginate;
 | 
			
		||||
            delete reqOpts.qs.autoPaginateVal;
 | 
			
		||||
            reqOpts.qs = projectify_1.replaceProjectIdToken(reqOpts.qs, projectId);
 | 
			
		||||
        }
 | 
			
		||||
        if (Array.isArray(reqOpts.multipart)) {
 | 
			
		||||
            reqOpts.multipart = reqOpts.multipart.map(part => {
 | 
			
		||||
                return projectify_1.replaceProjectIdToken(part, projectId);
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        if (reqOpts.json !== null && typeof reqOpts.json === 'object') {
 | 
			
		||||
            delete reqOpts.json.autoPaginate;
 | 
			
		||||
            delete reqOpts.json.autoPaginateVal;
 | 
			
		||||
            reqOpts.json = projectify_1.replaceProjectIdToken(reqOpts.json, projectId);
 | 
			
		||||
        }
 | 
			
		||||
        reqOpts.uri = projectify_1.replaceProjectIdToken(reqOpts.uri, projectId);
 | 
			
		||||
        return reqOpts;
 | 
			
		||||
    }
 | 
			
		||||
    // tslint:disable-next-line:no-any
 | 
			
		||||
    isCustomType(unknown, module) {
 | 
			
		||||
        function getConstructorName(obj) {
 | 
			
		||||
            return obj.constructor && obj.constructor.name.toLowerCase();
 | 
			
		||||
        }
 | 
			
		||||
        const moduleNameParts = module.split('/');
 | 
			
		||||
        const parentModuleName = moduleNameParts[0] && moduleNameParts[0].toLowerCase();
 | 
			
		||||
        const subModuleName = moduleNameParts[1] && moduleNameParts[1].toLowerCase();
 | 
			
		||||
        if (subModuleName && getConstructorName(unknown) !== subModuleName) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        let walkingModule = unknown;
 | 
			
		||||
        while (true) {
 | 
			
		||||
            if (getConstructorName(walkingModule) === parentModuleName) {
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
            walkingModule = walkingModule.parent;
 | 
			
		||||
            if (!walkingModule) {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Create a properly-formatted User-Agent string from a package.json file.
 | 
			
		||||
     *
 | 
			
		||||
     * @param {object} packageJson - A module's package.json file.
 | 
			
		||||
     * @return {string} userAgent - The formatted User-Agent string.
 | 
			
		||||
     */
 | 
			
		||||
    getUserAgentFromPackageJson(packageJson) {
 | 
			
		||||
        const hyphenatedPackageName = packageJson.name
 | 
			
		||||
            .replace('@google-cloud', 'gcloud-node') // For legacy purposes.
 | 
			
		||||
            .replace('/', '-'); // For UA spec-compliance purposes.
 | 
			
		||||
        return hyphenatedPackageName + '/' + packageJson.version;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Given two parameters, figure out if this is either:
 | 
			
		||||
     *  - Just a callback function
 | 
			
		||||
     *  - An options object, and then a callback function
 | 
			
		||||
     * @param optionsOrCallback An options object or callback.
 | 
			
		||||
     * @param cb A potentially undefined callback.
 | 
			
		||||
     */
 | 
			
		||||
    maybeOptionsOrCallback(optionsOrCallback, cb) {
 | 
			
		||||
        return typeof optionsOrCallback === 'function'
 | 
			
		||||
            ? [{}, optionsOrCallback]
 | 
			
		||||
            : [optionsOrCallback, cb];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.Util = Util;
 | 
			
		||||
const util = new Util();
 | 
			
		||||
exports.util = util;
 | 
			
		||||
//# sourceMappingURL=util.js.map
 | 
			
		||||
							
								
								
									
										110
									
								
								node_modules/@google-cloud/common/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								node_modules/@google-cloud/common/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,110 @@
 | 
			
		||||
{
 | 
			
		||||
  "_from": "@google-cloud/common@^2.1.1",
 | 
			
		||||
  "_id": "@google-cloud/common@2.1.2",
 | 
			
		||||
  "_inBundle": false,
 | 
			
		||||
  "_integrity": "sha512-VAjWRrTEgcGujj/MgTTAtjjzeDoQqs/FDT6DG7004QFZoJsSwBmx2vGpI5TJmCuxLWvhEc0Xs5AMOvhgt7FLSw==",
 | 
			
		||||
  "_location": "/@google-cloud/common",
 | 
			
		||||
  "_phantomChildren": {},
 | 
			
		||||
  "_requested": {
 | 
			
		||||
    "type": "range",
 | 
			
		||||
    "registry": true,
 | 
			
		||||
    "raw": "@google-cloud/common@^2.1.1",
 | 
			
		||||
    "name": "@google-cloud/common",
 | 
			
		||||
    "escapedName": "@google-cloud%2fcommon",
 | 
			
		||||
    "scope": "@google-cloud",
 | 
			
		||||
    "rawSpec": "^2.1.1",
 | 
			
		||||
    "saveSpec": null,
 | 
			
		||||
    "fetchSpec": "^2.1.1"
 | 
			
		||||
  },
 | 
			
		||||
  "_requiredBy": [
 | 
			
		||||
    "/@google-cloud/storage"
 | 
			
		||||
  ],
 | 
			
		||||
  "_resolved": "https://registry.npmjs.org/@google-cloud/common/-/common-2.1.2.tgz",
 | 
			
		||||
  "_shasum": "cefab7522d652d4ee48ab4719e2fe2d6c117db4c",
 | 
			
		||||
  "_spec": "@google-cloud/common@^2.1.1",
 | 
			
		||||
  "_where": "C:\\Users\\matia\\Documents\\GitHub\\FutoX-Musix\\node_modules\\@google-cloud\\storage",
 | 
			
		||||
  "author": {
 | 
			
		||||
    "name": "Google Inc."
 | 
			
		||||
  },
 | 
			
		||||
  "bugs": {
 | 
			
		||||
    "url": "https://github.com/googleapis/nodejs-common/issues"
 | 
			
		||||
  },
 | 
			
		||||
  "bundleDependencies": false,
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "@google-cloud/projectify": "^1.0.0",
 | 
			
		||||
    "@google-cloud/promisify": "^1.0.0",
 | 
			
		||||
    "arrify": "^2.0.0",
 | 
			
		||||
    "duplexify": "^3.6.0",
 | 
			
		||||
    "ent": "^2.2.0",
 | 
			
		||||
    "extend": "^3.0.2",
 | 
			
		||||
    "google-auth-library": "^5.0.0",
 | 
			
		||||
    "retry-request": "^4.0.0",
 | 
			
		||||
    "teeny-request": "^5.2.1"
 | 
			
		||||
  },
 | 
			
		||||
  "deprecated": false,
 | 
			
		||||
  "description": "Common components for Cloud APIs Node.js Client Libraries",
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "@compodoc/compodoc": "^1.1.9",
 | 
			
		||||
    "@types/ent": "^2.2.1",
 | 
			
		||||
    "@types/extend": "^3.0.1",
 | 
			
		||||
    "@types/mocha": "^5.2.6",
 | 
			
		||||
    "@types/mv": "^2.1.0",
 | 
			
		||||
    "@types/ncp": "^2.0.1",
 | 
			
		||||
    "@types/nock": "^10.0.0",
 | 
			
		||||
    "@types/node": "^11.13.0",
 | 
			
		||||
    "@types/proxyquire": "^1.3.28",
 | 
			
		||||
    "@types/request": "^2.48.1",
 | 
			
		||||
    "@types/sinon": "^7.0.10",
 | 
			
		||||
    "@types/tmp": "0.1.0",
 | 
			
		||||
    "codecov": "^3.2.0",
 | 
			
		||||
    "gts": "^1.0.0",
 | 
			
		||||
    "ink-docstrap": "^1.3.2",
 | 
			
		||||
    "intelli-espower-loader": "^1.0.1",
 | 
			
		||||
    "js-green-licenses": "^1.0.0",
 | 
			
		||||
    "linkinator": "^1.1.7",
 | 
			
		||||
    "mocha": "^6.0.2",
 | 
			
		||||
    "mv": "^2.1.1",
 | 
			
		||||
    "ncp": "^2.0.0",
 | 
			
		||||
    "nock": "^10.0.6",
 | 
			
		||||
    "nyc": "^14.0.0",
 | 
			
		||||
    "power-assert": "^1.6.1",
 | 
			
		||||
    "proxyquire": "^2.1.0",
 | 
			
		||||
    "sinon": "^7.3.0",
 | 
			
		||||
    "source-map-support": "^0.5.11",
 | 
			
		||||
    "tmp": "0.1.0",
 | 
			
		||||
    "typescript": "~3.5.0"
 | 
			
		||||
  },
 | 
			
		||||
  "engines": {
 | 
			
		||||
    "node": ">=8.10.0"
 | 
			
		||||
  },
 | 
			
		||||
  "files": [
 | 
			
		||||
    "build/src",
 | 
			
		||||
    "!build/src/**/*.map"
 | 
			
		||||
  ],
 | 
			
		||||
  "homepage": "https://github.com/googleapis/nodejs-common#readme",
 | 
			
		||||
  "license": "Apache-2.0",
 | 
			
		||||
  "main": "./build/src/index.js",
 | 
			
		||||
  "name": "@google-cloud/common",
 | 
			
		||||
  "repository": {
 | 
			
		||||
    "type": "git",
 | 
			
		||||
    "url": "git+https://github.com/googleapis/nodejs-common.git"
 | 
			
		||||
  },
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "compile": "tsc -p .",
 | 
			
		||||
    "docs": "compodoc src/",
 | 
			
		||||
    "docs-test": "linkinator docs",
 | 
			
		||||
    "fix": "gts fix",
 | 
			
		||||
    "license-check": "jsgl --local .",
 | 
			
		||||
    "lint": "gts check",
 | 
			
		||||
    "posttest": "npm run lint && npm run license-check",
 | 
			
		||||
    "predocs-test": "npm run docs",
 | 
			
		||||
    "prepare": "npm run compile",
 | 
			
		||||
    "presystem-test": "npm run compile",
 | 
			
		||||
    "pretest": "npm run compile",
 | 
			
		||||
    "samples-test": "cd samples/ && npm link ../ && npm test && cd ../",
 | 
			
		||||
    "system-test": "mocha build/system-test",
 | 
			
		||||
    "test": "nyc mocha build/test"
 | 
			
		||||
  },
 | 
			
		||||
  "types": "./build/src/index.d.ts",
 | 
			
		||||
  "version": "2.1.2"
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user