Socket
Socket
Sign inDemoInstall

@google-cloud/vision

Package Overview
Dependencies
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google-cloud/vision - npm Package Compare versions

Comparing version 1.10.0 to 1.11.0

2

build/src/index.d.ts

@@ -19,1 +19,3 @@ import * as v1 from './v1';

export default _default;
import * as protos from '../protos/protos';
export { protos };

@@ -51,2 +51,4 @@ "use strict";

};
const protos = require("../protos/protos");
exports.protos = protos;
//# sourceMappingURL=index.js.map

@@ -16,5 +16,10 @@ import * as gax from 'google-gax';

private _terminated;
private _opts;
private _gaxModule;
private _gaxGrpc;
private _protos;
private _defaults;
auth: gax.GoogleAuth;
operationsClient: gax.OperationsClient;
imageAnnotatorStub: Promise<{
imageAnnotatorStub?: Promise<{
[name: string]: Function;

@@ -44,4 +49,2 @@ }>;

* your project ID will be detected automatically.
* @param {function} [options.promise] - Custom promise module to use instead
* of native Promises.
* @param {string} [options.apiEndpoint] - The domain name of the

@@ -52,2 +55,16 @@ * API remote host.

/**
* Initialize the client.
* Performs asynchronous operations (such as authentication) and prepares the client.
* This function will be called automatically when any class method is called for the
* first time, but if you need to initialize it before calling an actual method,
* feel free to call initialize() directly.
*
* You can await on this method if you want to make sure the client is initialized.
*
* @returns {Promise} A promise that resolves to an authenticated service stub.
*/
initialize(): Promise<{
[name: string]: Function;
}>;
/**
* The DNS address for this API service.

@@ -54,0 +71,0 @@ */

69

build/src/v1/image_annotator_client.js

@@ -54,4 +54,2 @@ "use strict";

* your project ID will be detected automatically.
* @param {function} [options.promise] - Custom promise module to use instead
* of native Promises.
* @param {string} [options.apiEndpoint] - The domain name of the

@@ -84,11 +82,13 @@ * API remote host.

// But if we were explicitly requested to use fallback, let's do it now.
const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
// Create a `gaxGrpc` object, with any grpc-specific options
// sent to the client.
opts.scopes = this.constructor.scopes;
const gaxGrpc = new gaxModule.GrpcClient(opts);
this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
// Save options to use in initialize() method.
this._opts = opts;
// Save the auth object to the client, for use by other methods.
this.auth = gaxGrpc.auth;
this.auth = this._gaxGrpc.auth;
// Determine the client header string.
const clientHeader = [`gax/${gaxModule.version}`, `gapic/${version}`];
const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
if (typeof process !== 'undefined' && 'versions' in process) {

@@ -98,6 +98,6 @@ clientHeader.push(`gl-node/${process.versions.node}`);

else {
clientHeader.push(`gl-web/${gaxModule.version}`);
clientHeader.push(`gl-web/${this._gaxModule.version}`);
}
if (!opts.fallback) {
clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`);
clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
}

@@ -111,3 +111,3 @@ if (opts.libName && opts.libVersion) {

const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json');
const protos = gaxGrpc.loadProto(opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath);
this._protos = this._gaxGrpc.loadProto(opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath);
// This API contains "path templates"; forward-slash-separated

@@ -117,5 +117,5 @@ // identifiers to uniquely identify resources within the API.

this._pathTemplates = {
productPathTemplate: new gaxModule.PathTemplate('projects/{project}/locations/{location}/products/{product}'),
productSetPathTemplate: new gaxModule.PathTemplate('projects/{project}/locations/{location}/productSets/{product_set}'),
referenceImagePathTemplate: new gaxModule.PathTemplate('projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}'),
productPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}/products/{product}'),
productSetPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}/productSets/{product_set}'),
referenceImagePathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}'),
};

@@ -126,8 +126,8 @@ // This API contains "long-running operations", which return a

const protoFilesRoot = opts.fallback
? gaxModule.protobuf.Root.fromJSON(require('../../protos/protos.json'))
: gaxModule.protobuf.loadSync(nodejsProtoPath);
this.operationsClient = gaxModule
? this._gaxModule.protobuf.Root.fromJSON(require('../../protos/protos.json'))
: this._gaxModule.protobuf.loadSync(nodejsProtoPath);
this.operationsClient = this._gaxModule
.lro({
auth: this.auth,
grpc: 'grpc' in gaxGrpc ? gaxGrpc.grpc : undefined,
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
})

@@ -140,7 +140,7 @@ .operationsClient(opts);

this._descriptors.longrunning = {
asyncBatchAnnotateImages: new gaxModule.LongrunningDescriptor(this.operationsClient, asyncBatchAnnotateImagesResponse.decode.bind(asyncBatchAnnotateImagesResponse), asyncBatchAnnotateImagesMetadata.decode.bind(asyncBatchAnnotateImagesMetadata)),
asyncBatchAnnotateFiles: new gaxModule.LongrunningDescriptor(this.operationsClient, asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)),
asyncBatchAnnotateImages: new this._gaxModule.LongrunningDescriptor(this.operationsClient, asyncBatchAnnotateImagesResponse.decode.bind(asyncBatchAnnotateImagesResponse), asyncBatchAnnotateImagesMetadata.decode.bind(asyncBatchAnnotateImagesMetadata)),
asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor(this.operationsClient, asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)),
};
// Put together the default options sent with requests.
const defaults = gaxGrpc.constructSettings('google.cloud.vision.v1.ImageAnnotator', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
this._defaults = this._gaxGrpc.constructSettings('google.cloud.vision.v1.ImageAnnotator', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
// Set up a dictionary of "inner API calls"; the core implementation

@@ -150,8 +150,25 @@ // of calling the API is handled in `google-gax`, with this code

this._innerApiCalls = {};
}
/**
* Initialize the client.
* Performs asynchronous operations (such as authentication) and prepares the client.
* This function will be called automatically when any class method is called for the
* first time, but if you need to initialize it before calling an actual method,
* feel free to call initialize() directly.
*
* You can await on this method if you want to make sure the client is initialized.
*
* @returns {Promise} A promise that resolves to an authenticated service stub.
*/
initialize() {
// If the client stub promise is already initialized, return immediately.
if (this.imageAnnotatorStub) {
return this.imageAnnotatorStub;
}
// Put together the "service stub" for
// google.cloud.vision.v1.ImageAnnotator.
this.imageAnnotatorStub = gaxGrpc.createStub(opts.fallback
? protos.lookupService('google.cloud.vision.v1.ImageAnnotator')
this.imageAnnotatorStub = this._gaxGrpc.createStub(this._opts.fallback
? this._protos.lookupService('google.cloud.vision.v1.ImageAnnotator')
: // tslint:disable-next-line no-any
protos.google.cloud.vision.v1.ImageAnnotator, opts);
this._protos.google.cloud.vision.v1.ImageAnnotator, this._opts);
// Iterate over each of the methods that the service provides

@@ -174,3 +191,3 @@ // and create an API call method for each.

});
const apiCall = gaxModule.createApiCall(innerCallPromise, defaults[methodName], this._descriptors.page[methodName] ||
const apiCall = this._gaxModule.createApiCall(innerCallPromise, this._defaults[methodName], this._descriptors.page[methodName] ||
this._descriptors.stream[methodName] ||

@@ -182,2 +199,3 @@ this._descriptors.longrunning[methodName]);

}
return this.imageAnnotatorStub;
}

@@ -267,2 +285,3 @@ /**

});
this.initialize();
return this._innerApiCalls.batchAnnotateImages(request, options, callback);

@@ -319,2 +338,3 @@ }

});
this.initialize();
return this._innerApiCalls.batchAnnotateFiles(request, options, callback);

@@ -374,2 +394,3 @@ }

});
this.initialize();
return this._innerApiCalls.asyncBatchAnnotateImages(request, options, callback);

@@ -424,2 +445,3 @@ }

});
this.initialize();
return this._innerApiCalls.asyncBatchAnnotateFiles(request, options, callback);

@@ -586,2 +608,3 @@ }

close() {
this.initialize();
if (!this._terminated) {

@@ -588,0 +611,0 @@ return this.imageAnnotatorStub.then(stub => {

@@ -10,3 +10,3 @@ /// <reference types="node" />

*
* - The API has a collection of [ProductSet][google.cloud.vision.v1.ProductSet] resources, named
* - The API has a collection of {@link google.cloud.vision.v1.ProductSet|ProductSet} resources, named
* `projects/* /locations/* /productSets/*`, which acts as a way to put different

@@ -17,6 +17,6 @@ * products into groups to limit identification.

*
* - The API has a collection of [Product][google.cloud.vision.v1.Product] resources, named
* - The API has a collection of {@link google.cloud.vision.v1.Product|Product} resources, named
* `projects/* /locations/* /products/*`
*
* - Each [Product][google.cloud.vision.v1.Product] has a collection of [ReferenceImage][google.cloud.vision.v1.ReferenceImage] resources, named
* - Each {@link google.cloud.vision.v1.Product|Product} has a collection of {@link google.cloud.vision.v1.ReferenceImage|ReferenceImage} resources, named
* `projects/* /locations/* /products/* /referenceImages/*`

@@ -31,5 +31,10 @@ * @class

private _terminated;
private _opts;
private _gaxModule;
private _gaxGrpc;
private _protos;
private _defaults;
auth: gax.GoogleAuth;
operationsClient: gax.OperationsClient;
productSearchStub: Promise<{
productSearchStub?: Promise<{
[name: string]: Function;

@@ -59,4 +64,2 @@ }>;

* your project ID will be detected automatically.
* @param {function} [options.promise] - Custom promise module to use instead
* of native Promises.
* @param {string} [options.apiEndpoint] - The domain name of the

@@ -67,2 +70,16 @@ * API remote host.

/**
* Initialize the client.
* Performs asynchronous operations (such as authentication) and prepares the client.
* This function will be called automatically when any class method is called for the
* first time, but if you need to initialize it before calling an actual method,
* feel free to call initialize() directly.
*
* You can await on this method if you want to make sure the client is initialized.
*
* @returns {Promise} A promise that resolves to an authenticated service stub.
*/
initialize(): Promise<{
[name: string]: Function;
}>;
/**
* The DNS address for this API service.

@@ -69,0 +86,0 @@ */

@@ -15,4 +15,9 @@ import * as gax from 'google-gax';

private _terminated;
private _opts;
private _gaxModule;
private _gaxGrpc;
private _protos;
private _defaults;
auth: gax.GoogleAuth;
imageAnnotatorStub: Promise<{
imageAnnotatorStub?: Promise<{
[name: string]: Function;

@@ -42,4 +47,2 @@ }>;

* your project ID will be detected automatically.
* @param {function} [options.promise] - Custom promise module to use instead
* of native Promises.
* @param {string} [options.apiEndpoint] - The domain name of the

@@ -50,2 +53,16 @@ * API remote host.

/**
* Initialize the client.
* Performs asynchronous operations (such as authentication) and prepares the client.
* This function will be called automatically when any class method is called for the
* first time, but if you need to initialize it before calling an actual method,
* feel free to call initialize() directly.
*
* You can await on this method if you want to make sure the client is initialized.
*
* @returns {Promise} A promise that resolves to an authenticated service stub.
*/
initialize(): Promise<{
[name: string]: Function;
}>;
/**
* The DNS address for this API service.

@@ -52,0 +69,0 @@ */

@@ -54,4 +54,2 @@ "use strict";

* your project ID will be detected automatically.
* @param {function} [options.promise] - Custom promise module to use instead
* of native Promises.
* @param {string} [options.apiEndpoint] - The domain name of the

@@ -84,11 +82,13 @@ * API remote host.

// But if we were explicitly requested to use fallback, let's do it now.
const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
// Create a `gaxGrpc` object, with any grpc-specific options
// sent to the client.
opts.scopes = this.constructor.scopes;
const gaxGrpc = new gaxModule.GrpcClient(opts);
this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
// Save options to use in initialize() method.
this._opts = opts;
// Save the auth object to the client, for use by other methods.
this.auth = gaxGrpc.auth;
this.auth = this._gaxGrpc.auth;
// Determine the client header string.
const clientHeader = [`gax/${gaxModule.version}`, `gapic/${version}`];
const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
if (typeof process !== 'undefined' && 'versions' in process) {

@@ -98,6 +98,6 @@ clientHeader.push(`gl-node/${process.versions.node}`);

else {
clientHeader.push(`gl-web/${gaxModule.version}`);
clientHeader.push(`gl-web/${this._gaxModule.version}`);
}
if (!opts.fallback) {
clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`);
clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
}

@@ -111,5 +111,5 @@ if (opts.libName && opts.libVersion) {

const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json');
const protos = gaxGrpc.loadProto(opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath);
this._protos = this._gaxGrpc.loadProto(opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath);
// Put together the default options sent with requests.
const defaults = gaxGrpc.constructSettings('google.cloud.vision.v1p1beta1.ImageAnnotator', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
this._defaults = this._gaxGrpc.constructSettings('google.cloud.vision.v1p1beta1.ImageAnnotator', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
// Set up a dictionary of "inner API calls"; the core implementation

@@ -119,8 +119,25 @@ // of calling the API is handled in `google-gax`, with this code

this._innerApiCalls = {};
}
/**
* Initialize the client.
* Performs asynchronous operations (such as authentication) and prepares the client.
* This function will be called automatically when any class method is called for the
* first time, but if you need to initialize it before calling an actual method,
* feel free to call initialize() directly.
*
* You can await on this method if you want to make sure the client is initialized.
*
* @returns {Promise} A promise that resolves to an authenticated service stub.
*/
initialize() {
// If the client stub promise is already initialized, return immediately.
if (this.imageAnnotatorStub) {
return this.imageAnnotatorStub;
}
// Put together the "service stub" for
// google.cloud.vision.v1p1beta1.ImageAnnotator.
this.imageAnnotatorStub = gaxGrpc.createStub(opts.fallback
? protos.lookupService('google.cloud.vision.v1p1beta1.ImageAnnotator')
this.imageAnnotatorStub = this._gaxGrpc.createStub(this._opts.fallback
? this._protos.lookupService('google.cloud.vision.v1p1beta1.ImageAnnotator')
: // tslint:disable-next-line no-any
protos.google.cloud.vision.v1p1beta1.ImageAnnotator, opts);
this._protos.google.cloud.vision.v1p1beta1.ImageAnnotator, this._opts);
// Iterate over each of the methods that the service provides

@@ -138,3 +155,3 @@ // and create an API call method for each.

});
const apiCall = gaxModule.createApiCall(innerCallPromise, defaults[methodName], this._descriptors.page[methodName] ||
const apiCall = this._gaxModule.createApiCall(innerCallPromise, this._defaults[methodName], this._descriptors.page[methodName] ||
this._descriptors.stream[methodName] ||

@@ -146,2 +163,3 @@ this._descriptors.longrunning[methodName]);

}
return this.imageAnnotatorStub;
}

@@ -213,2 +231,3 @@ /**

options = options || {};
this.initialize();
return this._innerApiCalls.batchAnnotateImages(request, options, callback);

@@ -222,2 +241,3 @@ }

close() {
this.initialize();
if (!this._terminated) {

@@ -224,0 +244,0 @@ return this.imageAnnotatorStub.then(stub => {

@@ -15,5 +15,10 @@ import * as gax from 'google-gax';

private _terminated;
private _opts;
private _gaxModule;
private _gaxGrpc;
private _protos;
private _defaults;
auth: gax.GoogleAuth;
operationsClient: gax.OperationsClient;
imageAnnotatorStub: Promise<{
imageAnnotatorStub?: Promise<{
[name: string]: Function;

@@ -43,4 +48,2 @@ }>;

* your project ID will be detected automatically.
* @param {function} [options.promise] - Custom promise module to use instead
* of native Promises.
* @param {string} [options.apiEndpoint] - The domain name of the

@@ -51,2 +54,16 @@ * API remote host.

/**
* Initialize the client.
* Performs asynchronous operations (such as authentication) and prepares the client.
* This function will be called automatically when any class method is called for the
* first time, but if you need to initialize it before calling an actual method,
* feel free to call initialize() directly.
*
* You can await on this method if you want to make sure the client is initialized.
*
* @returns {Promise} A promise that resolves to an authenticated service stub.
*/
initialize(): Promise<{
[name: string]: Function;
}>;
/**
* The DNS address for this API service.

@@ -53,0 +70,0 @@ */

@@ -54,4 +54,2 @@ "use strict";

* your project ID will be detected automatically.
* @param {function} [options.promise] - Custom promise module to use instead
* of native Promises.
* @param {string} [options.apiEndpoint] - The domain name of the

@@ -84,11 +82,13 @@ * API remote host.

// But if we were explicitly requested to use fallback, let's do it now.
const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
// Create a `gaxGrpc` object, with any grpc-specific options
// sent to the client.
opts.scopes = this.constructor.scopes;
const gaxGrpc = new gaxModule.GrpcClient(opts);
this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
// Save options to use in initialize() method.
this._opts = opts;
// Save the auth object to the client, for use by other methods.
this.auth = gaxGrpc.auth;
this.auth = this._gaxGrpc.auth;
// Determine the client header string.
const clientHeader = [`gax/${gaxModule.version}`, `gapic/${version}`];
const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
if (typeof process !== 'undefined' && 'versions' in process) {

@@ -98,6 +98,6 @@ clientHeader.push(`gl-node/${process.versions.node}`);

else {
clientHeader.push(`gl-web/${gaxModule.version}`);
clientHeader.push(`gl-web/${this._gaxModule.version}`);
}
if (!opts.fallback) {
clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`);
clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
}

@@ -111,3 +111,3 @@ if (opts.libName && opts.libVersion) {

const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json');
const protos = gaxGrpc.loadProto(opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath);
this._protos = this._gaxGrpc.loadProto(opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath);
// This API contains "long-running operations", which return a

@@ -117,8 +117,8 @@ // an Operation object that allows for tracking of the operation,

const protoFilesRoot = opts.fallback
? gaxModule.protobuf.Root.fromJSON(require('../../protos/protos.json'))
: gaxModule.protobuf.loadSync(nodejsProtoPath);
this.operationsClient = gaxModule
? this._gaxModule.protobuf.Root.fromJSON(require('../../protos/protos.json'))
: this._gaxModule.protobuf.loadSync(nodejsProtoPath);
this.operationsClient = this._gaxModule
.lro({
auth: this.auth,
grpc: 'grpc' in gaxGrpc ? gaxGrpc.grpc : undefined,
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
})

@@ -129,6 +129,6 @@ .operationsClient(opts);

this._descriptors.longrunning = {
asyncBatchAnnotateFiles: new gaxModule.LongrunningDescriptor(this.operationsClient, asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)),
asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor(this.operationsClient, asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)),
};
// Put together the default options sent with requests.
const defaults = gaxGrpc.constructSettings('google.cloud.vision.v1p2beta1.ImageAnnotator', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
this._defaults = this._gaxGrpc.constructSettings('google.cloud.vision.v1p2beta1.ImageAnnotator', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
// Set up a dictionary of "inner API calls"; the core implementation

@@ -138,8 +138,25 @@ // of calling the API is handled in `google-gax`, with this code

this._innerApiCalls = {};
}
/**
* Initialize the client.
* Performs asynchronous operations (such as authentication) and prepares the client.
* This function will be called automatically when any class method is called for the
* first time, but if you need to initialize it before calling an actual method,
* feel free to call initialize() directly.
*
* You can await on this method if you want to make sure the client is initialized.
*
* @returns {Promise} A promise that resolves to an authenticated service stub.
*/
initialize() {
// If the client stub promise is already initialized, return immediately.
if (this.imageAnnotatorStub) {
return this.imageAnnotatorStub;
}
// Put together the "service stub" for
// google.cloud.vision.v1p2beta1.ImageAnnotator.
this.imageAnnotatorStub = gaxGrpc.createStub(opts.fallback
? protos.lookupService('google.cloud.vision.v1p2beta1.ImageAnnotator')
this.imageAnnotatorStub = this._gaxGrpc.createStub(this._opts.fallback
? this._protos.lookupService('google.cloud.vision.v1p2beta1.ImageAnnotator')
: // tslint:disable-next-line no-any
protos.google.cloud.vision.v1p2beta1.ImageAnnotator, opts);
this._protos.google.cloud.vision.v1p2beta1.ImageAnnotator, this._opts);
// Iterate over each of the methods that the service provides

@@ -160,3 +177,3 @@ // and create an API call method for each.

});
const apiCall = gaxModule.createApiCall(innerCallPromise, defaults[methodName], this._descriptors.page[methodName] ||
const apiCall = this._gaxModule.createApiCall(innerCallPromise, this._defaults[methodName], this._descriptors.page[methodName] ||
this._descriptors.stream[methodName] ||

@@ -168,2 +185,3 @@ this._descriptors.longrunning[methodName]);

}
return this.imageAnnotatorStub;
}

@@ -235,2 +253,3 @@ /**

options = options || {};
this.initialize();
return this._innerApiCalls.batchAnnotateImages(request, options, callback);

@@ -267,2 +286,3 @@ }

options = options || {};
this.initialize();
return this._innerApiCalls.asyncBatchAnnotateFiles(request, options, callback);

@@ -276,2 +296,3 @@ }

close() {
this.initialize();
if (!this._terminated) {

@@ -278,0 +299,0 @@ return this.imageAnnotatorStub.then(stub => {

@@ -16,5 +16,10 @@ import * as gax from 'google-gax';

private _terminated;
private _opts;
private _gaxModule;
private _gaxGrpc;
private _protos;
private _defaults;
auth: gax.GoogleAuth;
operationsClient: gax.OperationsClient;
imageAnnotatorStub: Promise<{
imageAnnotatorStub?: Promise<{
[name: string]: Function;

@@ -44,4 +49,2 @@ }>;

* your project ID will be detected automatically.
* @param {function} [options.promise] - Custom promise module to use instead
* of native Promises.
* @param {string} [options.apiEndpoint] - The domain name of the

@@ -52,2 +55,16 @@ * API remote host.

/**
* Initialize the client.
* Performs asynchronous operations (such as authentication) and prepares the client.
* This function will be called automatically when any class method is called for the
* first time, but if you need to initialize it before calling an actual method,
* feel free to call initialize() directly.
*
* You can await on this method if you want to make sure the client is initialized.
*
* @returns {Promise} A promise that resolves to an authenticated service stub.
*/
initialize(): Promise<{
[name: string]: Function;
}>;
/**
* The DNS address for this API service.

@@ -54,0 +71,0 @@ */

@@ -54,4 +54,2 @@ "use strict";

* your project ID will be detected automatically.
* @param {function} [options.promise] - Custom promise module to use instead
* of native Promises.
* @param {string} [options.apiEndpoint] - The domain name of the

@@ -84,11 +82,13 @@ * API remote host.

// But if we were explicitly requested to use fallback, let's do it now.
const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
// Create a `gaxGrpc` object, with any grpc-specific options
// sent to the client.
opts.scopes = this.constructor.scopes;
const gaxGrpc = new gaxModule.GrpcClient(opts);
this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
// Save options to use in initialize() method.
this._opts = opts;
// Save the auth object to the client, for use by other methods.
this.auth = gaxGrpc.auth;
this.auth = this._gaxGrpc.auth;
// Determine the client header string.
const clientHeader = [`gax/${gaxModule.version}`, `gapic/${version}`];
const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
if (typeof process !== 'undefined' && 'versions' in process) {

@@ -98,6 +98,6 @@ clientHeader.push(`gl-node/${process.versions.node}`);

else {
clientHeader.push(`gl-web/${gaxModule.version}`);
clientHeader.push(`gl-web/${this._gaxModule.version}`);
}
if (!opts.fallback) {
clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`);
clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
}

@@ -111,3 +111,3 @@ if (opts.libName && opts.libVersion) {

const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json');
const protos = gaxGrpc.loadProto(opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath);
this._protos = this._gaxGrpc.loadProto(opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath);
// This API contains "path templates"; forward-slash-separated

@@ -117,5 +117,5 @@ // identifiers to uniquely identify resources within the API.

this._pathTemplates = {
productPathTemplate: new gaxModule.PathTemplate('projects/{project}/locations/{location}/products/{product}'),
productSetPathTemplate: new gaxModule.PathTemplate('projects/{project}/locations/{location}/productSets/{product_set}'),
referenceImagePathTemplate: new gaxModule.PathTemplate('projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}'),
productPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}/products/{product}'),
productSetPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}/productSets/{product_set}'),
referenceImagePathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}'),
};

@@ -126,8 +126,8 @@ // This API contains "long-running operations", which return a

const protoFilesRoot = opts.fallback
? gaxModule.protobuf.Root.fromJSON(require('../../protos/protos.json'))
: gaxModule.protobuf.loadSync(nodejsProtoPath);
this.operationsClient = gaxModule
? this._gaxModule.protobuf.Root.fromJSON(require('../../protos/protos.json'))
: this._gaxModule.protobuf.loadSync(nodejsProtoPath);
this.operationsClient = this._gaxModule
.lro({
auth: this.auth,
grpc: 'grpc' in gaxGrpc ? gaxGrpc.grpc : undefined,
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
})

@@ -138,6 +138,6 @@ .operationsClient(opts);

this._descriptors.longrunning = {
asyncBatchAnnotateFiles: new gaxModule.LongrunningDescriptor(this.operationsClient, asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)),
asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor(this.operationsClient, asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)),
};
// Put together the default options sent with requests.
const defaults = gaxGrpc.constructSettings('google.cloud.vision.v1p3beta1.ImageAnnotator', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
this._defaults = this._gaxGrpc.constructSettings('google.cloud.vision.v1p3beta1.ImageAnnotator', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
// Set up a dictionary of "inner API calls"; the core implementation

@@ -147,8 +147,25 @@ // of calling the API is handled in `google-gax`, with this code

this._innerApiCalls = {};
}
/**
* Initialize the client.
* Performs asynchronous operations (such as authentication) and prepares the client.
* This function will be called automatically when any class method is called for the
* first time, but if you need to initialize it before calling an actual method,
* feel free to call initialize() directly.
*
* You can await on this method if you want to make sure the client is initialized.
*
* @returns {Promise} A promise that resolves to an authenticated service stub.
*/
initialize() {
// If the client stub promise is already initialized, return immediately.
if (this.imageAnnotatorStub) {
return this.imageAnnotatorStub;
}
// Put together the "service stub" for
// google.cloud.vision.v1p3beta1.ImageAnnotator.
this.imageAnnotatorStub = gaxGrpc.createStub(opts.fallback
? protos.lookupService('google.cloud.vision.v1p3beta1.ImageAnnotator')
this.imageAnnotatorStub = this._gaxGrpc.createStub(this._opts.fallback
? this._protos.lookupService('google.cloud.vision.v1p3beta1.ImageAnnotator')
: // tslint:disable-next-line no-any
protos.google.cloud.vision.v1p3beta1.ImageAnnotator, opts);
this._protos.google.cloud.vision.v1p3beta1.ImageAnnotator, this._opts);
// Iterate over each of the methods that the service provides

@@ -169,3 +186,3 @@ // and create an API call method for each.

});
const apiCall = gaxModule.createApiCall(innerCallPromise, defaults[methodName], this._descriptors.page[methodName] ||
const apiCall = this._gaxModule.createApiCall(innerCallPromise, this._defaults[methodName], this._descriptors.page[methodName] ||
this._descriptors.stream[methodName] ||

@@ -177,2 +194,3 @@ this._descriptors.longrunning[methodName]);

}
return this.imageAnnotatorStub;
}

@@ -244,2 +262,3 @@ /**

options = options || {};
this.initialize();
return this._innerApiCalls.batchAnnotateImages(request, options, callback);

@@ -276,2 +295,3 @@ }

options = options || {};
this.initialize();
return this._innerApiCalls.asyncBatchAnnotateFiles(request, options, callback);

@@ -438,2 +458,3 @@ }

close() {
this.initialize();
if (!this._terminated) {

@@ -440,0 +461,0 @@ return this.imageAnnotatorStub.then(stub => {

@@ -10,3 +10,3 @@ /// <reference types="node" />

*
* - The API has a collection of [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] resources, named
* - The API has a collection of {@link google.cloud.vision.v1p3beta1.ProductSet|ProductSet} resources, named
* `projects/* /locations/* /productSets/*`, which acts as a way to put different

@@ -17,6 +17,6 @@ * products into groups to limit identification.

*
* - The API has a collection of [Product][google.cloud.vision.v1p3beta1.Product] resources, named
* - The API has a collection of {@link google.cloud.vision.v1p3beta1.Product|Product} resources, named
* `projects/* /locations/* /products/*`
*
* - Each [Product][google.cloud.vision.v1p3beta1.Product] has a collection of [ReferenceImage][google.cloud.vision.v1p3beta1.ReferenceImage] resources, named
* - Each {@link google.cloud.vision.v1p3beta1.Product|Product} has a collection of {@link google.cloud.vision.v1p3beta1.ReferenceImage|ReferenceImage} resources, named
* `projects/* /locations/* /products/* /referenceImages/*`

@@ -31,5 +31,10 @@ * @class

private _terminated;
private _opts;
private _gaxModule;
private _gaxGrpc;
private _protos;
private _defaults;
auth: gax.GoogleAuth;
operationsClient: gax.OperationsClient;
productSearchStub: Promise<{
productSearchStub?: Promise<{
[name: string]: Function;

@@ -59,4 +64,2 @@ }>;

* your project ID will be detected automatically.
* @param {function} [options.promise] - Custom promise module to use instead
* of native Promises.
* @param {string} [options.apiEndpoint] - The domain name of the

@@ -67,2 +70,16 @@ * API remote host.

/**
* Initialize the client.
* Performs asynchronous operations (such as authentication) and prepares the client.
* This function will be called automatically when any class method is called for the
* first time, but if you need to initialize it before calling an actual method,
* feel free to call initialize() directly.
*
* You can await on this method if you want to make sure the client is initialized.
*
* @returns {Promise} A promise that resolves to an authenticated service stub.
*/
initialize(): Promise<{
[name: string]: Function;
}>;
/**
* The DNS address for this API service.

@@ -69,0 +86,0 @@ */

@@ -16,5 +16,10 @@ import * as gax from 'google-gax';

private _terminated;
private _opts;
private _gaxModule;
private _gaxGrpc;
private _protos;
private _defaults;
auth: gax.GoogleAuth;
operationsClient: gax.OperationsClient;
imageAnnotatorStub: Promise<{
imageAnnotatorStub?: Promise<{
[name: string]: Function;

@@ -44,4 +49,2 @@ }>;

* your project ID will be detected automatically.
* @param {function} [options.promise] - Custom promise module to use instead
* of native Promises.
* @param {string} [options.apiEndpoint] - The domain name of the

@@ -52,2 +55,16 @@ * API remote host.

/**
* Initialize the client.
* Performs asynchronous operations (such as authentication) and prepares the client.
* This function will be called automatically when any class method is called for the
* first time, but if you need to initialize it before calling an actual method,
* feel free to call initialize() directly.
*
* You can await on this method if you want to make sure the client is initialized.
*
* @returns {Promise} A promise that resolves to an authenticated service stub.
*/
initialize(): Promise<{
[name: string]: Function;
}>;
/**
* The DNS address for this API service.

@@ -54,0 +71,0 @@ */

@@ -54,4 +54,2 @@ "use strict";

* your project ID will be detected automatically.
* @param {function} [options.promise] - Custom promise module to use instead
* of native Promises.
* @param {string} [options.apiEndpoint] - The domain name of the

@@ -84,11 +82,13 @@ * API remote host.

// But if we were explicitly requested to use fallback, let's do it now.
const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
// Create a `gaxGrpc` object, with any grpc-specific options
// sent to the client.
opts.scopes = this.constructor.scopes;
const gaxGrpc = new gaxModule.GrpcClient(opts);
this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
// Save options to use in initialize() method.
this._opts = opts;
// Save the auth object to the client, for use by other methods.
this.auth = gaxGrpc.auth;
this.auth = this._gaxGrpc.auth;
// Determine the client header string.
const clientHeader = [`gax/${gaxModule.version}`, `gapic/${version}`];
const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
if (typeof process !== 'undefined' && 'versions' in process) {

@@ -98,6 +98,6 @@ clientHeader.push(`gl-node/${process.versions.node}`);

else {
clientHeader.push(`gl-web/${gaxModule.version}`);
clientHeader.push(`gl-web/${this._gaxModule.version}`);
}
if (!opts.fallback) {
clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`);
clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
}

@@ -111,3 +111,3 @@ if (opts.libName && opts.libVersion) {

const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json');
const protos = gaxGrpc.loadProto(opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath);
this._protos = this._gaxGrpc.loadProto(opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath);
// This API contains "path templates"; forward-slash-separated

@@ -117,5 +117,5 @@ // identifiers to uniquely identify resources within the API.

this._pathTemplates = {
productPathTemplate: new gaxModule.PathTemplate('projects/{project}/locations/{location}/products/{product}'),
productSetPathTemplate: new gaxModule.PathTemplate('projects/{project}/locations/{location}/productSets/{product_set}'),
referenceImagePathTemplate: new gaxModule.PathTemplate('projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}'),
productPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}/products/{product}'),
productSetPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}/productSets/{product_set}'),
referenceImagePathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}'),
};

@@ -126,8 +126,8 @@ // This API contains "long-running operations", which return a

const protoFilesRoot = opts.fallback
? gaxModule.protobuf.Root.fromJSON(require('../../protos/protos.json'))
: gaxModule.protobuf.loadSync(nodejsProtoPath);
this.operationsClient = gaxModule
? this._gaxModule.protobuf.Root.fromJSON(require('../../protos/protos.json'))
: this._gaxModule.protobuf.loadSync(nodejsProtoPath);
this.operationsClient = this._gaxModule
.lro({
auth: this.auth,
grpc: 'grpc' in gaxGrpc ? gaxGrpc.grpc : undefined,
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
})

@@ -140,7 +140,7 @@ .operationsClient(opts);

this._descriptors.longrunning = {
asyncBatchAnnotateImages: new gaxModule.LongrunningDescriptor(this.operationsClient, asyncBatchAnnotateImagesResponse.decode.bind(asyncBatchAnnotateImagesResponse), asyncBatchAnnotateImagesMetadata.decode.bind(asyncBatchAnnotateImagesMetadata)),
asyncBatchAnnotateFiles: new gaxModule.LongrunningDescriptor(this.operationsClient, asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)),
asyncBatchAnnotateImages: new this._gaxModule.LongrunningDescriptor(this.operationsClient, asyncBatchAnnotateImagesResponse.decode.bind(asyncBatchAnnotateImagesResponse), asyncBatchAnnotateImagesMetadata.decode.bind(asyncBatchAnnotateImagesMetadata)),
asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor(this.operationsClient, asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)),
};
// Put together the default options sent with requests.
const defaults = gaxGrpc.constructSettings('google.cloud.vision.v1p4beta1.ImageAnnotator', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
this._defaults = this._gaxGrpc.constructSettings('google.cloud.vision.v1p4beta1.ImageAnnotator', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
// Set up a dictionary of "inner API calls"; the core implementation

@@ -150,8 +150,25 @@ // of calling the API is handled in `google-gax`, with this code

this._innerApiCalls = {};
}
/**
* Initialize the client.
* Performs asynchronous operations (such as authentication) and prepares the client.
* This function will be called automatically when any class method is called for the
* first time, but if you need to initialize it before calling an actual method,
* feel free to call initialize() directly.
*
* You can await on this method if you want to make sure the client is initialized.
*
* @returns {Promise} A promise that resolves to an authenticated service stub.
*/
initialize() {
// If the client stub promise is already initialized, return immediately.
if (this.imageAnnotatorStub) {
return this.imageAnnotatorStub;
}
// Put together the "service stub" for
// google.cloud.vision.v1p4beta1.ImageAnnotator.
this.imageAnnotatorStub = gaxGrpc.createStub(opts.fallback
? protos.lookupService('google.cloud.vision.v1p4beta1.ImageAnnotator')
this.imageAnnotatorStub = this._gaxGrpc.createStub(this._opts.fallback
? this._protos.lookupService('google.cloud.vision.v1p4beta1.ImageAnnotator')
: // tslint:disable-next-line no-any
protos.google.cloud.vision.v1p4beta1.ImageAnnotator, opts);
this._protos.google.cloud.vision.v1p4beta1.ImageAnnotator, this._opts);
// Iterate over each of the methods that the service provides

@@ -174,3 +191,3 @@ // and create an API call method for each.

});
const apiCall = gaxModule.createApiCall(innerCallPromise, defaults[methodName], this._descriptors.page[methodName] ||
const apiCall = this._gaxModule.createApiCall(innerCallPromise, this._defaults[methodName], this._descriptors.page[methodName] ||
this._descriptors.stream[methodName] ||

@@ -182,2 +199,3 @@ this._descriptors.longrunning[methodName]);

}
return this.imageAnnotatorStub;
}

@@ -249,2 +267,3 @@ /**

options = options || {};
this.initialize();
return this._innerApiCalls.batchAnnotateImages(request, options, callback);

@@ -283,2 +302,3 @@ }

options = options || {};
this.initialize();
return this._innerApiCalls.batchAnnotateFiles(request, options, callback);

@@ -320,2 +340,3 @@ }

options = options || {};
this.initialize();
return this._innerApiCalls.asyncBatchAnnotateImages(request, options, callback);

@@ -352,2 +373,3 @@ }

options = options || {};
this.initialize();
return this._innerApiCalls.asyncBatchAnnotateFiles(request, options, callback);

@@ -514,2 +536,3 @@ }

close() {
this.initialize();
if (!this._terminated) {

@@ -516,0 +539,0 @@ return this.imageAnnotatorStub.then(stub => {

@@ -11,3 +11,3 @@ /// <reference types="node" />

* - The API has a collection of
* [ProductSet][google.cloud.vision.v1p4beta1.ProductSet] resources, named
* {@link google.cloud.vision.v1p4beta1.ProductSet|ProductSet} resources, named
* `projects/* /locations/* /productSets/*`, which acts as a way to put different

@@ -19,7 +19,7 @@ * products into groups to limit identification.

* - The API has a collection of
* [Product][google.cloud.vision.v1p4beta1.Product] resources, named
* {@link google.cloud.vision.v1p4beta1.Product|Product} resources, named
* `projects/* /locations/* /products/*`
*
* - Each [Product][google.cloud.vision.v1p4beta1.Product] has a collection of
* [ReferenceImage][google.cloud.vision.v1p4beta1.ReferenceImage] resources,
* - Each {@link google.cloud.vision.v1p4beta1.Product|Product} has a collection of
* {@link google.cloud.vision.v1p4beta1.ReferenceImage|ReferenceImage} resources,
* named

@@ -35,5 +35,10 @@ * `projects/* /locations/* /products/* /referenceImages/*`

private _terminated;
private _opts;
private _gaxModule;
private _gaxGrpc;
private _protos;
private _defaults;
auth: gax.GoogleAuth;
operationsClient: gax.OperationsClient;
productSearchStub: Promise<{
productSearchStub?: Promise<{
[name: string]: Function;

@@ -63,4 +68,2 @@ }>;

* your project ID will be detected automatically.
* @param {function} [options.promise] - Custom promise module to use instead
* of native Promises.
* @param {string} [options.apiEndpoint] - The domain name of the

@@ -71,2 +74,16 @@ * API remote host.

/**
* Initialize the client.
* Performs asynchronous operations (such as authentication) and prepares the client.
* This function will be called automatically when any class method is called for the
* first time, but if you need to initialize it before calling an actual method,
* feel free to call initialize() directly.
*
* You can await on this method if you want to make sure the client is initialized.
*
* @returns {Promise} A promise that resolves to an authenticated service stub.
*/
initialize(): Promise<{
[name: string]: Function;
}>;
/**
* The DNS address for this API service.

@@ -73,0 +90,0 @@ */

@@ -7,2 +7,10 @@ # Changelog

## [1.11.0](https://www.github.com/googleapis/nodejs-vision/compare/v1.10.0...v1.11.0) (2020-03-11)
### Features
* deferred client initialization ([#551](https://www.github.com/googleapis/nodejs-vision/issues/551)) ([8866d89](https://www.github.com/googleapis/nodejs-vision/commit/8866d8905750dfc0627f585c30c0b19bb205172d))
* export protos from src/index.ts ([#547](https://www.github.com/googleapis/nodejs-vision/issues/547)) ([41c736c](https://www.github.com/googleapis/nodejs-vision/commit/41c736c8f234f6fba20120fa5c17353519f2d45d))
## [1.10.0](https://www.github.com/googleapis/nodejs-vision/compare/v1.9.0...v1.10.0) (2020-03-03)

@@ -9,0 +17,0 @@

{
"name": "@google-cloud/vision",
"description": "Google Cloud Vision API client for Node.js",
"version": "1.10.0",
"version": "1.11.0",
"license": "Apache-2.0",

@@ -6,0 +6,0 @@ "author": "Google Inc",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc