@google-cloud/vectorsearch 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +134 -0
  3. package/build/protos/google/cloud/vectorsearch/v1beta/common.proto +34 -0
  4. package/build/protos/google/cloud/vectorsearch/v1beta/data_object.proto +92 -0
  5. package/build/protos/google/cloud/vectorsearch/v1beta/data_object_search_service.proto +428 -0
  6. package/build/protos/google/cloud/vectorsearch/v1beta/data_object_service.proto +233 -0
  7. package/build/protos/google/cloud/vectorsearch/v1beta/embedding_config.proto +71 -0
  8. package/build/protos/google/cloud/vectorsearch/v1beta/vectorsearch_service.proto +631 -0
  9. package/build/protos/protos.d.ts +15049 -0
  10. package/build/protos/protos.js +39060 -0
  11. package/build/protos/protos.json +4174 -0
  12. package/build/src/index.d.ts +17 -0
  13. package/build/src/index.js +32 -0
  14. package/build/src/index.js.map +1 -0
  15. package/build/src/v1beta/data_object_search_service_client.d.ts +574 -0
  16. package/build/src/v1beta/data_object_search_service_client.js +849 -0
  17. package/build/src/v1beta/data_object_search_service_client.js.map +1 -0
  18. package/build/src/v1beta/data_object_search_service_client_config.json +58 -0
  19. package/build/src/v1beta/data_object_search_service_proto_list.json +8 -0
  20. package/build/src/v1beta/data_object_service_client.d.ts +486 -0
  21. package/build/src/v1beta/data_object_service_client.js +767 -0
  22. package/build/src/v1beta/data_object_service_client.js.map +1 -0
  23. package/build/src/v1beta/data_object_service_client_config.json +73 -0
  24. package/build/src/v1beta/data_object_service_proto_list.json +8 -0
  25. package/build/src/v1beta/gapic_metadata.json +277 -0
  26. package/build/src/v1beta/index.d.ts +3 -0
  27. package/build/src/v1beta/index.js +27 -0
  28. package/build/src/v1beta/index.js.map +1 -0
  29. package/build/src/v1beta/vector_search_service_client.d.ts +1020 -0
  30. package/build/src/v1beta/vector_search_service_client.js +1387 -0
  31. package/build/src/v1beta/vector_search_service_client.js.map +1 -0
  32. package/build/src/v1beta/vector_search_service_client_config.json +88 -0
  33. package/build/src/v1beta/vector_search_service_proto_list.json +8 -0
  34. package/package.json +70 -0
@@ -0,0 +1,849 @@
1
+ "use strict";
2
+ // Copyright 2025 Google LLC
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // https://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ //
16
+ // ** This file is automatically generated by gapic-generator-typescript. **
17
+ // ** https://github.com/googleapis/gapic-generator-typescript **
18
+ // ** All changes to this file may be overwritten. **
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.DataObjectSearchServiceClient = void 0;
21
+ const jsonProtos = require("../../protos/protos.json");
22
+ const google_gax_1 = require("google-gax");
23
+ /**
24
+ * Client JSON configuration object, loaded from
25
+ * `src/v1beta/data_object_search_service_client_config.json`.
26
+ * This file defines retry strategy and timeouts for all API methods in this library.
27
+ */
28
+ const gapicConfig = require("./data_object_search_service_client_config.json");
29
+ const version = require('../../../package.json').version;
30
+ /**
31
+ * Service for searching data objects.
32
+ * @class
33
+ * @memberof v1beta
34
+ */
35
+ class DataObjectSearchServiceClient {
36
+ _terminated = false;
37
+ _opts;
38
+ _providedCustomServicePath;
39
+ _gaxModule;
40
+ _gaxGrpc;
41
+ _protos;
42
+ _defaults;
43
+ _universeDomain;
44
+ _servicePath;
45
+ _log = google_gax_1.loggingUtils.log('vectorsearch');
46
+ auth;
47
+ descriptors = {
48
+ page: {},
49
+ stream: {},
50
+ longrunning: {},
51
+ batching: {},
52
+ };
53
+ warn;
54
+ innerApiCalls;
55
+ locationsClient;
56
+ pathTemplates;
57
+ dataObjectSearchServiceStub;
58
+ /**
59
+ * Construct an instance of DataObjectSearchServiceClient.
60
+ *
61
+ * @param {object} [options] - The configuration object.
62
+ * The options accepted by the constructor are described in detail
63
+ * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
64
+ * The common options are:
65
+ * @param {object} [options.credentials] - Credentials object.
66
+ * @param {string} [options.credentials.client_email]
67
+ * @param {string} [options.credentials.private_key]
68
+ * @param {string} [options.email] - Account email address. Required when
69
+ * using a .pem or .p12 keyFilename.
70
+ * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
71
+ * .p12 key downloaded from the Google Developers Console. If you provide
72
+ * a path to a JSON file, the projectId option below is not necessary.
73
+ * NOTE: .pem and .p12 require you to specify options.email as well.
74
+ * @param {number} [options.port] - The port on which to connect to
75
+ * the remote host.
76
+ * @param {string} [options.projectId] - The project ID from the Google
77
+ * Developer's Console, e.g. 'grape-spaceship-123'. We will also check
78
+ * the environment variable GCLOUD_PROJECT for your project ID. If your
79
+ * app is running in an environment which supports
80
+ * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials},
81
+ * your project ID will be detected automatically.
82
+ * @param {string} [options.apiEndpoint] - The domain name of the
83
+ * API remote host.
84
+ * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
85
+ * Follows the structure of {@link gapicConfig}.
86
+ * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode.
87
+ * For more information, please check the
88
+ * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
89
+ * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
90
+ * need to avoid loading the default gRPC version and want to use the fallback
91
+ * HTTP implementation. Load only fallback version and pass it to the constructor:
92
+ * ```
93
+ * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
94
+ * const client = new DataObjectSearchServiceClient({fallback: true}, gax);
95
+ * ```
96
+ */
97
+ constructor(opts, gaxInstance) {
98
+ // Ensure that options include all the required fields.
99
+ const staticMembers = this.constructor;
100
+ if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) {
101
+ throw new Error('Please set either universe_domain or universeDomain, but not both.');
102
+ }
103
+ const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined;
104
+ this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com';
105
+ this._servicePath = 'vectorsearch.' + this._universeDomain;
106
+ const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath;
107
+ this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint);
108
+ const port = opts?.port || staticMembers.port;
109
+ const clientConfig = opts?.clientConfig ?? {};
110
+ const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function');
111
+ opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
112
+ // Request numeric enum values if REST transport is used.
113
+ opts.numericEnums = true;
114
+ // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
115
+ if (servicePath !== this._servicePath && !('scopes' in opts)) {
116
+ opts['scopes'] = staticMembers.scopes;
117
+ }
118
+ // Load google-gax module synchronously if needed
119
+ if (!gaxInstance) {
120
+ gaxInstance = require('google-gax');
121
+ }
122
+ // Choose either gRPC or proto-over-HTTP implementation of google-gax.
123
+ this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance;
124
+ // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
125
+ this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
126
+ // Save options to use in initialize() method.
127
+ this._opts = opts;
128
+ // Save the auth object to the client, for use by other methods.
129
+ this.auth = this._gaxGrpc.auth;
130
+ // Set useJWTAccessWithScope on the auth object.
131
+ this.auth.useJWTAccessWithScope = true;
132
+ // Set defaultServicePath on the auth object.
133
+ this.auth.defaultServicePath = this._servicePath;
134
+ // Set the default scopes in auth client if needed.
135
+ if (servicePath === this._servicePath) {
136
+ this.auth.defaultScopes = staticMembers.scopes;
137
+ }
138
+ this.locationsClient = new this._gaxModule.LocationsClient(this._gaxGrpc, opts);
139
+ // Determine the client header string.
140
+ const clientHeader = [
141
+ `gax/${this._gaxModule.version}`,
142
+ `gapic/${version}`,
143
+ ];
144
+ if (typeof process === 'object' && 'versions' in process) {
145
+ clientHeader.push(`gl-node/${process.versions.node}`);
146
+ }
147
+ else {
148
+ clientHeader.push(`gl-web/${this._gaxModule.version}`);
149
+ }
150
+ if (!opts.fallback) {
151
+ clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
152
+ }
153
+ else {
154
+ clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
155
+ }
156
+ if (opts.libName && opts.libVersion) {
157
+ clientHeader.push(`${opts.libName}/${opts.libVersion}`);
158
+ }
159
+ // Load the applicable protos.
160
+ this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
161
+ // This API contains "path templates"; forward-slash-separated
162
+ // identifiers to uniquely identify resources within the API.
163
+ // Create useful helper objects for these.
164
+ this.pathTemplates = {
165
+ collectionPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}/collections/{collection}'),
166
+ dataObjectPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}/collections/{collection}/dataObjects/{dataObject}'),
167
+ indexPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}/collections/{collection}/indexes/{index}'),
168
+ };
169
+ // Some of the methods on this service return "paged" results,
170
+ // (e.g. 50 results at a time, with tokens to get subsequent
171
+ // pages). Denote the keys used for pagination and results.
172
+ this.descriptors.page = {
173
+ searchDataObjects: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'results'),
174
+ queryDataObjects: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'dataObjects')
175
+ };
176
+ // Put together the default options sent with requests.
177
+ this._defaults = this._gaxGrpc.constructSettings('google.cloud.vectorsearch.v1beta.DataObjectSearchService', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
178
+ // Set up a dictionary of "inner API calls"; the core implementation
179
+ // of calling the API is handled in `google-gax`, with this code
180
+ // merely providing the destination and request information.
181
+ this.innerApiCalls = {};
182
+ // Add a warn function to the client constructor so it can be easily tested.
183
+ this.warn = this._gaxModule.warn;
184
+ }
185
+ /**
186
+ * Initialize the client.
187
+ * Performs asynchronous operations (such as authentication) and prepares the client.
188
+ * This function will be called automatically when any class method is called for the
189
+ * first time, but if you need to initialize it before calling an actual method,
190
+ * feel free to call initialize() directly.
191
+ *
192
+ * You can await on this method if you want to make sure the client is initialized.
193
+ *
194
+ * @returns {Promise} A promise that resolves to an authenticated service stub.
195
+ */
196
+ initialize() {
197
+ // If the client stub promise is already initialized, return immediately.
198
+ if (this.dataObjectSearchServiceStub) {
199
+ return this.dataObjectSearchServiceStub;
200
+ }
201
+ // Put together the "service stub" for
202
+ // google.cloud.vectorsearch.v1beta.DataObjectSearchService.
203
+ this.dataObjectSearchServiceStub = this._gaxGrpc.createStub(this._opts.fallback ?
204
+ this._protos.lookupService('google.cloud.vectorsearch.v1beta.DataObjectSearchService') :
205
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
206
+ this._protos.google.cloud.vectorsearch.v1beta.DataObjectSearchService, this._opts, this._providedCustomServicePath);
207
+ // Iterate over each of the methods that the service provides
208
+ // and create an API call method for each.
209
+ const dataObjectSearchServiceStubMethods = ['searchDataObjects', 'queryDataObjects', 'aggregateDataObjects', 'batchSearchDataObjects'];
210
+ for (const methodName of dataObjectSearchServiceStubMethods) {
211
+ const callPromise = this.dataObjectSearchServiceStub.then(stub => (...args) => {
212
+ if (this._terminated) {
213
+ return Promise.reject('The client has already been closed.');
214
+ }
215
+ const func = stub[methodName];
216
+ return func.apply(stub, args);
217
+ }, (err) => () => {
218
+ throw err;
219
+ });
220
+ const descriptor = this.descriptors.page[methodName] ||
221
+ undefined;
222
+ const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor, this._opts.fallback);
223
+ this.innerApiCalls[methodName] = apiCall;
224
+ }
225
+ return this.dataObjectSearchServiceStub;
226
+ }
227
+ /**
228
+ * The DNS address for this API service.
229
+ * @deprecated Use the apiEndpoint method of the client instance.
230
+ * @returns {string} The DNS address for this service.
231
+ */
232
+ static get servicePath() {
233
+ if (typeof process === 'object' && typeof process.emitWarning === 'function') {
234
+ process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning');
235
+ }
236
+ return 'vectorsearch.googleapis.com';
237
+ }
238
+ /**
239
+ * The DNS address for this API service - same as servicePath.
240
+ * @deprecated Use the apiEndpoint method of the client instance.
241
+ * @returns {string} The DNS address for this service.
242
+ */
243
+ static get apiEndpoint() {
244
+ if (typeof process === 'object' && typeof process.emitWarning === 'function') {
245
+ process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning');
246
+ }
247
+ return 'vectorsearch.googleapis.com';
248
+ }
249
+ /**
250
+ * The DNS address for this API service.
251
+ * @returns {string} The DNS address for this service.
252
+ */
253
+ get apiEndpoint() {
254
+ return this._servicePath;
255
+ }
256
+ get universeDomain() {
257
+ return this._universeDomain;
258
+ }
259
+ /**
260
+ * The port for this API service.
261
+ * @returns {number} The default port for this service.
262
+ */
263
+ static get port() {
264
+ return 443;
265
+ }
266
+ /**
267
+ * The scopes needed to make gRPC calls for every method defined
268
+ * in this service.
269
+ * @returns {string[]} List of default scopes.
270
+ */
271
+ static get scopes() {
272
+ return [
273
+ 'https://www.googleapis.com/auth/cloud-platform'
274
+ ];
275
+ }
276
+ /**
277
+ * Return the project ID used by this class.
278
+ * @returns {Promise} A promise that resolves to string containing the project ID.
279
+ */
280
+ getProjectId(callback) {
281
+ if (callback) {
282
+ this.auth.getProjectId(callback);
283
+ return;
284
+ }
285
+ return this.auth.getProjectId();
286
+ }
287
+ aggregateDataObjects(request, optionsOrCallback, callback) {
288
+ request = request || {};
289
+ let options;
290
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
291
+ callback = optionsOrCallback;
292
+ options = {};
293
+ }
294
+ else {
295
+ options = optionsOrCallback;
296
+ }
297
+ options = options || {};
298
+ options.otherArgs = options.otherArgs || {};
299
+ options.otherArgs.headers = options.otherArgs.headers || {};
300
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
301
+ 'parent': request.parent ?? '',
302
+ });
303
+ this.initialize().catch(err => { throw err; });
304
+ this._log.info('aggregateDataObjects request %j', request);
305
+ const wrappedCallback = callback
306
+ ? (error, response, options, rawResponse) => {
307
+ this._log.info('aggregateDataObjects response %j', response);
308
+ callback(error, response, options, rawResponse); // We verified callback above.
309
+ }
310
+ : undefined;
311
+ return this.innerApiCalls.aggregateDataObjects(request, options, wrappedCallback)
312
+ ?.then(([response, options, rawResponse]) => {
313
+ this._log.info('aggregateDataObjects response %j', response);
314
+ return [response, options, rawResponse];
315
+ }).catch((error) => {
316
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
317
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
318
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
319
+ }
320
+ throw error;
321
+ });
322
+ }
323
+ batchSearchDataObjects(request, optionsOrCallback, callback) {
324
+ request = request || {};
325
+ let options;
326
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
327
+ callback = optionsOrCallback;
328
+ options = {};
329
+ }
330
+ else {
331
+ options = optionsOrCallback;
332
+ }
333
+ options = options || {};
334
+ options.otherArgs = options.otherArgs || {};
335
+ options.otherArgs.headers = options.otherArgs.headers || {};
336
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
337
+ 'parent': request.parent ?? '',
338
+ });
339
+ this.initialize().catch(err => { throw err; });
340
+ this._log.info('batchSearchDataObjects request %j', request);
341
+ const wrappedCallback = callback
342
+ ? (error, response, options, rawResponse) => {
343
+ this._log.info('batchSearchDataObjects response %j', response);
344
+ callback(error, response, options, rawResponse); // We verified callback above.
345
+ }
346
+ : undefined;
347
+ return this.innerApiCalls.batchSearchDataObjects(request, options, wrappedCallback)
348
+ ?.then(([response, options, rawResponse]) => {
349
+ this._log.info('batchSearchDataObjects response %j', response);
350
+ return [response, options, rawResponse];
351
+ }).catch((error) => {
352
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
353
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
354
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
355
+ }
356
+ throw error;
357
+ });
358
+ }
359
+ searchDataObjects(request, optionsOrCallback, callback) {
360
+ request = request || {};
361
+ let options;
362
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
363
+ callback = optionsOrCallback;
364
+ options = {};
365
+ }
366
+ else {
367
+ options = optionsOrCallback;
368
+ }
369
+ options = options || {};
370
+ options.otherArgs = options.otherArgs || {};
371
+ options.otherArgs.headers = options.otherArgs.headers || {};
372
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
373
+ 'parent': request.parent ?? '',
374
+ });
375
+ this.initialize().catch(err => { throw err; });
376
+ const wrappedCallback = callback
377
+ ? (error, values, nextPageRequest, rawResponse) => {
378
+ this._log.info('searchDataObjects values %j', values);
379
+ callback(error, values, nextPageRequest, rawResponse); // We verified callback above.
380
+ }
381
+ : undefined;
382
+ this._log.info('searchDataObjects request %j', request);
383
+ return this.innerApiCalls
384
+ .searchDataObjects(request, options, wrappedCallback)
385
+ ?.then(([response, input, output]) => {
386
+ this._log.info('searchDataObjects values %j', response);
387
+ return [response, input, output];
388
+ });
389
+ }
390
+ /**
391
+ * Equivalent to `searchDataObjects`, but returns a NodeJS Stream object.
392
+ * @param {Object} request
393
+ * The request object that will be sent.
394
+ * @param {google.cloud.vectorsearch.v1beta.VectorSearch} request.vectorSearch
395
+ * A vector search operation.
396
+ * @param {google.cloud.vectorsearch.v1beta.SemanticSearch} request.semanticSearch
397
+ * A semantic search operation.
398
+ * @param {google.cloud.vectorsearch.v1beta.TextSearch} [request.textSearch]
399
+ * Optional. A text search operation.
400
+ * @param {string} request.parent
401
+ * Required. The resource name of the Collection for which to search.
402
+ * Format: `projects/{project}/locations/{location}/collections/{collection}`
403
+ * @param {number} [request.pageSize]
404
+ * Optional. The standard list page size.
405
+ * @param {string} [request.pageToken]
406
+ * Optional. The standard list page token.
407
+ * Typically obtained via
408
+ * {@link protos.google.cloud.vectorsearch.v1beta.SearchDataObjectsResponse.next_page_token|SearchDataObjectsResponse.next_page_token}
409
+ * of the previous
410
+ * {@link protos.google.cloud.vectorsearch.v1beta.DataObjectSearchService.SearchDataObjects|DataObjectSearchService.SearchDataObjects}
411
+ * call.
412
+ * @param {object} [options]
413
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
414
+ * @returns {Stream}
415
+ * An object stream which emits an object representing {@link protos.google.cloud.vectorsearch.v1beta.SearchResult|SearchResult} on 'data' event.
416
+ * The client library will perform auto-pagination by default: it will call the API as many
417
+ * times as needed. Note that it can affect your quota.
418
+ * We recommend using `searchDataObjectsAsync()`
419
+ * method described below for async iteration which you can stop as needed.
420
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
421
+ * for more details and examples.
422
+ */
423
+ searchDataObjectsStream(request, options) {
424
+ request = request || {};
425
+ options = options || {};
426
+ options.otherArgs = options.otherArgs || {};
427
+ options.otherArgs.headers = options.otherArgs.headers || {};
428
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
429
+ 'parent': request.parent ?? '',
430
+ });
431
+ const defaultCallSettings = this._defaults['searchDataObjects'];
432
+ const callSettings = defaultCallSettings.merge(options);
433
+ this.initialize().catch(err => { throw err; });
434
+ this._log.info('searchDataObjects stream %j', request);
435
+ return this.descriptors.page.searchDataObjects.createStream(this.innerApiCalls.searchDataObjects, request, callSettings);
436
+ }
437
+ /**
438
+ * Equivalent to `searchDataObjects`, but returns an iterable object.
439
+ *
440
+ * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
441
+ * @param {Object} request
442
+ * The request object that will be sent.
443
+ * @param {google.cloud.vectorsearch.v1beta.VectorSearch} request.vectorSearch
444
+ * A vector search operation.
445
+ * @param {google.cloud.vectorsearch.v1beta.SemanticSearch} request.semanticSearch
446
+ * A semantic search operation.
447
+ * @param {google.cloud.vectorsearch.v1beta.TextSearch} [request.textSearch]
448
+ * Optional. A text search operation.
449
+ * @param {string} request.parent
450
+ * Required. The resource name of the Collection for which to search.
451
+ * Format: `projects/{project}/locations/{location}/collections/{collection}`
452
+ * @param {number} [request.pageSize]
453
+ * Optional. The standard list page size.
454
+ * @param {string} [request.pageToken]
455
+ * Optional. The standard list page token.
456
+ * Typically obtained via
457
+ * {@link protos.google.cloud.vectorsearch.v1beta.SearchDataObjectsResponse.next_page_token|SearchDataObjectsResponse.next_page_token}
458
+ * of the previous
459
+ * {@link protos.google.cloud.vectorsearch.v1beta.DataObjectSearchService.SearchDataObjects|DataObjectSearchService.SearchDataObjects}
460
+ * call.
461
+ * @param {object} [options]
462
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
463
+ * @returns {Object}
464
+ * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
465
+ * When you iterate the returned iterable, each element will be an object representing
466
+ * {@link protos.google.cloud.vectorsearch.v1beta.SearchResult|SearchResult}. The API will be called under the hood as needed, once per the page,
467
+ * so you can stop the iteration when you don't need more results.
468
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
469
+ * for more details and examples.
470
+ * @example <caption>include:samples/generated/v1beta/data_object_search_service.search_data_objects.js</caption>
471
+ * region_tag:vectorsearch_v1beta_generated_DataObjectSearchService_SearchDataObjects_async
472
+ */
473
+ searchDataObjectsAsync(request, options) {
474
+ request = request || {};
475
+ options = options || {};
476
+ options.otherArgs = options.otherArgs || {};
477
+ options.otherArgs.headers = options.otherArgs.headers || {};
478
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
479
+ 'parent': request.parent ?? '',
480
+ });
481
+ const defaultCallSettings = this._defaults['searchDataObjects'];
482
+ const callSettings = defaultCallSettings.merge(options);
483
+ this.initialize().catch(err => { throw err; });
484
+ this._log.info('searchDataObjects iterate %j', request);
485
+ return this.descriptors.page.searchDataObjects.asyncIterate(this.innerApiCalls['searchDataObjects'], request, callSettings);
486
+ }
487
+ queryDataObjects(request, optionsOrCallback, callback) {
488
+ request = request || {};
489
+ let options;
490
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
491
+ callback = optionsOrCallback;
492
+ options = {};
493
+ }
494
+ else {
495
+ options = optionsOrCallback;
496
+ }
497
+ options = options || {};
498
+ options.otherArgs = options.otherArgs || {};
499
+ options.otherArgs.headers = options.otherArgs.headers || {};
500
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
501
+ 'parent': request.parent ?? '',
502
+ });
503
+ this.initialize().catch(err => { throw err; });
504
+ const wrappedCallback = callback
505
+ ? (error, values, nextPageRequest, rawResponse) => {
506
+ this._log.info('queryDataObjects values %j', values);
507
+ callback(error, values, nextPageRequest, rawResponse); // We verified callback above.
508
+ }
509
+ : undefined;
510
+ this._log.info('queryDataObjects request %j', request);
511
+ return this.innerApiCalls
512
+ .queryDataObjects(request, options, wrappedCallback)
513
+ ?.then(([response, input, output]) => {
514
+ this._log.info('queryDataObjects values %j', response);
515
+ return [response, input, output];
516
+ });
517
+ }
518
+ /**
519
+ * Equivalent to `queryDataObjects`, but returns a NodeJS Stream object.
520
+ * @param {Object} request
521
+ * The request object that will be sent.
522
+ * @param {string} request.parent
523
+ * Required. The resource name of the Collection for which to query.
524
+ * Format: `projects/{project}/locations/{location}/collections/{collection}`
525
+ * @param {google.protobuf.Struct} [request.filter]
526
+ * Optional. A JSON filter expression, e.g. {"genre": {"$eq": "sci-fi"}},
527
+ * represented as a google.protobuf.Struct.
528
+ * @param {google.cloud.vectorsearch.v1beta.OutputFields} [request.outputFields]
529
+ * Optional. Mask specifying which fields to return.
530
+ * @param {number} [request.pageSize]
531
+ * Optional. The standard list page size.
532
+ * @param {string} [request.pageToken]
533
+ * Optional. The standard list page token.
534
+ * Typically obtained via
535
+ * {@link protos.google.cloud.vectorsearch.v1beta.QueryDataObjectsResponse.next_page_token|QueryDataObjectsResponse.next_page_token}
536
+ * of the previous
537
+ * {@link protos.google.cloud.vectorsearch.v1beta.DataObjectSearchService.QueryDataObjects|DataObjectSearchService.QueryDataObjects}
538
+ * call.
539
+ * @param {object} [options]
540
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
541
+ * @returns {Stream}
542
+ * An object stream which emits an object representing {@link protos.google.cloud.vectorsearch.v1beta.DataObject|DataObject} on 'data' event.
543
+ * The client library will perform auto-pagination by default: it will call the API as many
544
+ * times as needed. Note that it can affect your quota.
545
+ * We recommend using `queryDataObjectsAsync()`
546
+ * method described below for async iteration which you can stop as needed.
547
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
548
+ * for more details and examples.
549
+ */
550
+ queryDataObjectsStream(request, options) {
551
+ request = request || {};
552
+ options = options || {};
553
+ options.otherArgs = options.otherArgs || {};
554
+ options.otherArgs.headers = options.otherArgs.headers || {};
555
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
556
+ 'parent': request.parent ?? '',
557
+ });
558
+ const defaultCallSettings = this._defaults['queryDataObjects'];
559
+ const callSettings = defaultCallSettings.merge(options);
560
+ this.initialize().catch(err => { throw err; });
561
+ this._log.info('queryDataObjects stream %j', request);
562
+ return this.descriptors.page.queryDataObjects.createStream(this.innerApiCalls.queryDataObjects, request, callSettings);
563
+ }
564
+ /**
565
+ * Equivalent to `queryDataObjects`, but returns an iterable object.
566
+ *
567
+ * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
568
+ * @param {Object} request
569
+ * The request object that will be sent.
570
+ * @param {string} request.parent
571
+ * Required. The resource name of the Collection for which to query.
572
+ * Format: `projects/{project}/locations/{location}/collections/{collection}`
573
+ * @param {google.protobuf.Struct} [request.filter]
574
+ * Optional. A JSON filter expression, e.g. {"genre": {"$eq": "sci-fi"}},
575
+ * represented as a google.protobuf.Struct.
576
+ * @param {google.cloud.vectorsearch.v1beta.OutputFields} [request.outputFields]
577
+ * Optional. Mask specifying which fields to return.
578
+ * @param {number} [request.pageSize]
579
+ * Optional. The standard list page size.
580
+ * @param {string} [request.pageToken]
581
+ * Optional. The standard list page token.
582
+ * Typically obtained via
583
+ * {@link protos.google.cloud.vectorsearch.v1beta.QueryDataObjectsResponse.next_page_token|QueryDataObjectsResponse.next_page_token}
584
+ * of the previous
585
+ * {@link protos.google.cloud.vectorsearch.v1beta.DataObjectSearchService.QueryDataObjects|DataObjectSearchService.QueryDataObjects}
586
+ * call.
587
+ * @param {object} [options]
588
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
589
+ * @returns {Object}
590
+ * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
591
+ * When you iterate the returned iterable, each element will be an object representing
592
+ * {@link protos.google.cloud.vectorsearch.v1beta.DataObject|DataObject}. The API will be called under the hood as needed, once per the page,
593
+ * so you can stop the iteration when you don't need more results.
594
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
595
+ * for more details and examples.
596
+ * @example <caption>include:samples/generated/v1beta/data_object_search_service.query_data_objects.js</caption>
597
+ * region_tag:vectorsearch_v1beta_generated_DataObjectSearchService_QueryDataObjects_async
598
+ */
599
+ queryDataObjectsAsync(request, options) {
600
+ request = request || {};
601
+ options = options || {};
602
+ options.otherArgs = options.otherArgs || {};
603
+ options.otherArgs.headers = options.otherArgs.headers || {};
604
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
605
+ 'parent': request.parent ?? '',
606
+ });
607
+ const defaultCallSettings = this._defaults['queryDataObjects'];
608
+ const callSettings = defaultCallSettings.merge(options);
609
+ this.initialize().catch(err => { throw err; });
610
+ this._log.info('queryDataObjects iterate %j', request);
611
+ return this.descriptors.page.queryDataObjects.asyncIterate(this.innerApiCalls['queryDataObjects'], request, callSettings);
612
+ }
613
+ /**
614
+ * Gets information about a location.
615
+ *
616
+ * @param {Object} request
617
+ * The request object that will be sent.
618
+ * @param {string} request.name
619
+ * Resource name for the location.
620
+ * @param {object} [options]
621
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details.
622
+ * @returns {Promise} - The promise which resolves to an array.
623
+ * The first element of the array is an object representing {@link google.cloud.location.Location | Location}.
624
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
625
+ * for more details and examples.
626
+ * @example
627
+ * ```
628
+ * const [response] = await client.getLocation(request);
629
+ * ```
630
+ */
631
+ getLocation(request, options, callback) {
632
+ return this.locationsClient.getLocation(request, options, callback);
633
+ }
634
+ /**
635
+ * Lists information about the supported locations for this service. Returns an iterable object.
636
+ *
637
+ * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
638
+ * @param {Object} request
639
+ * The request object that will be sent.
640
+ * @param {string} request.name
641
+ * The resource that owns the locations collection, if applicable.
642
+ * @param {string} request.filter
643
+ * The standard list filter.
644
+ * @param {number} request.pageSize
645
+ * The standard list page size.
646
+ * @param {string} request.pageToken
647
+ * The standard list page token.
648
+ * @param {object} [options]
649
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
650
+ * @returns {Object}
651
+ * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
652
+ * When you iterate the returned iterable, each element will be an object representing
653
+ * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page,
654
+ * so you can stop the iteration when you don't need more results.
655
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
656
+ * for more details and examples.
657
+ * @example
658
+ * ```
659
+ * const iterable = client.listLocationsAsync(request);
660
+ * for await (const response of iterable) {
661
+ * // process response
662
+ * }
663
+ * ```
664
+ */
665
+ listLocationsAsync(request, options) {
666
+ return this.locationsClient.listLocationsAsync(request, options);
667
+ }
668
+ // --------------------
669
+ // -- Path templates --
670
+ // --------------------
671
+ /**
672
+ * Return a fully-qualified collection resource name string.
673
+ *
674
+ * @param {string} project
675
+ * @param {string} location
676
+ * @param {string} collection
677
+ * @returns {string} Resource name string.
678
+ */
679
+ collectionPath(project, location, collection) {
680
+ return this.pathTemplates.collectionPathTemplate.render({
681
+ project: project,
682
+ location: location,
683
+ collection: collection,
684
+ });
685
+ }
686
+ /**
687
+ * Parse the project from Collection resource.
688
+ *
689
+ * @param {string} collectionName
690
+ * A fully-qualified path representing Collection resource.
691
+ * @returns {string} A string representing the project.
692
+ */
693
+ matchProjectFromCollectionName(collectionName) {
694
+ return this.pathTemplates.collectionPathTemplate.match(collectionName).project;
695
+ }
696
+ /**
697
+ * Parse the location from Collection resource.
698
+ *
699
+ * @param {string} collectionName
700
+ * A fully-qualified path representing Collection resource.
701
+ * @returns {string} A string representing the location.
702
+ */
703
+ matchLocationFromCollectionName(collectionName) {
704
+ return this.pathTemplates.collectionPathTemplate.match(collectionName).location;
705
+ }
706
+ /**
707
+ * Parse the collection from Collection resource.
708
+ *
709
+ * @param {string} collectionName
710
+ * A fully-qualified path representing Collection resource.
711
+ * @returns {string} A string representing the collection.
712
+ */
713
+ matchCollectionFromCollectionName(collectionName) {
714
+ return this.pathTemplates.collectionPathTemplate.match(collectionName).collection;
715
+ }
716
+ /**
717
+ * Return a fully-qualified dataObject resource name string.
718
+ *
719
+ * @param {string} project
720
+ * @param {string} location
721
+ * @param {string} collection
722
+ * @param {string} dataObject
723
+ * @returns {string} Resource name string.
724
+ */
725
+ dataObjectPath(project, location, collection, dataObject) {
726
+ return this.pathTemplates.dataObjectPathTemplate.render({
727
+ project: project,
728
+ location: location,
729
+ collection: collection,
730
+ dataObject: dataObject,
731
+ });
732
+ }
733
+ /**
734
+ * Parse the project from DataObject resource.
735
+ *
736
+ * @param {string} dataObjectName
737
+ * A fully-qualified path representing DataObject resource.
738
+ * @returns {string} A string representing the project.
739
+ */
740
+ matchProjectFromDataObjectName(dataObjectName) {
741
+ return this.pathTemplates.dataObjectPathTemplate.match(dataObjectName).project;
742
+ }
743
+ /**
744
+ * Parse the location from DataObject resource.
745
+ *
746
+ * @param {string} dataObjectName
747
+ * A fully-qualified path representing DataObject resource.
748
+ * @returns {string} A string representing the location.
749
+ */
750
+ matchLocationFromDataObjectName(dataObjectName) {
751
+ return this.pathTemplates.dataObjectPathTemplate.match(dataObjectName).location;
752
+ }
753
+ /**
754
+ * Parse the collection from DataObject resource.
755
+ *
756
+ * @param {string} dataObjectName
757
+ * A fully-qualified path representing DataObject resource.
758
+ * @returns {string} A string representing the collection.
759
+ */
760
+ matchCollectionFromDataObjectName(dataObjectName) {
761
+ return this.pathTemplates.dataObjectPathTemplate.match(dataObjectName).collection;
762
+ }
763
+ /**
764
+ * Parse the dataObject from DataObject resource.
765
+ *
766
+ * @param {string} dataObjectName
767
+ * A fully-qualified path representing DataObject resource.
768
+ * @returns {string} A string representing the dataObject.
769
+ */
770
+ matchDataObjectFromDataObjectName(dataObjectName) {
771
+ return this.pathTemplates.dataObjectPathTemplate.match(dataObjectName).dataObject;
772
+ }
773
+ /**
774
+ * Return a fully-qualified index resource name string.
775
+ *
776
+ * @param {string} project
777
+ * @param {string} location
778
+ * @param {string} collection
779
+ * @param {string} index
780
+ * @returns {string} Resource name string.
781
+ */
782
+ indexPath(project, location, collection, index) {
783
+ return this.pathTemplates.indexPathTemplate.render({
784
+ project: project,
785
+ location: location,
786
+ collection: collection,
787
+ index: index,
788
+ });
789
+ }
790
+ /**
791
+ * Parse the project from Index resource.
792
+ *
793
+ * @param {string} indexName
794
+ * A fully-qualified path representing Index resource.
795
+ * @returns {string} A string representing the project.
796
+ */
797
+ matchProjectFromIndexName(indexName) {
798
+ return this.pathTemplates.indexPathTemplate.match(indexName).project;
799
+ }
800
+ /**
801
+ * Parse the location from Index resource.
802
+ *
803
+ * @param {string} indexName
804
+ * A fully-qualified path representing Index resource.
805
+ * @returns {string} A string representing the location.
806
+ */
807
+ matchLocationFromIndexName(indexName) {
808
+ return this.pathTemplates.indexPathTemplate.match(indexName).location;
809
+ }
810
+ /**
811
+ * Parse the collection from Index resource.
812
+ *
813
+ * @param {string} indexName
814
+ * A fully-qualified path representing Index resource.
815
+ * @returns {string} A string representing the collection.
816
+ */
817
+ matchCollectionFromIndexName(indexName) {
818
+ return this.pathTemplates.indexPathTemplate.match(indexName).collection;
819
+ }
820
+ /**
821
+ * Parse the index from Index resource.
822
+ *
823
+ * @param {string} indexName
824
+ * A fully-qualified path representing Index resource.
825
+ * @returns {string} A string representing the index.
826
+ */
827
+ matchIndexFromIndexName(indexName) {
828
+ return this.pathTemplates.indexPathTemplate.match(indexName).index;
829
+ }
830
+ /**
831
+ * Terminate the gRPC channel and close the client.
832
+ *
833
+ * The client will no longer be usable and all future behavior is undefined.
834
+ * @returns {Promise} A promise that resolves when the client is closed.
835
+ */
836
+ close() {
837
+ if (this.dataObjectSearchServiceStub && !this._terminated) {
838
+ return this.dataObjectSearchServiceStub.then(stub => {
839
+ this._log.info('ending gRPC channel');
840
+ this._terminated = true;
841
+ stub.close();
842
+ this.locationsClient.close().catch(err => { throw err; });
843
+ });
844
+ }
845
+ return Promise.resolve();
846
+ }
847
+ }
848
+ exports.DataObjectSearchServiceClient = DataObjectSearchServiceClient;
849
+ //# sourceMappingURL=data_object_search_service_client.js.map