From 33b1cf85ca7098609c1fcc57454922c669cfffb1 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 21 Aug 2024 12:27:15 -0600 Subject: [PATCH] Rename VectorQueryOptions to FindNearestOptions for cross-SDK consistency --- api-report/firestore.api.md | 58 +++++++++---------- dev/src/index.ts | 2 +- ...ery-options.ts => find-nearest-options.ts} | 2 +- dev/src/reference/query.ts | 14 ++--- dev/src/reference/vector-query.ts | 4 +- dev/system-test/firestore.ts | 2 +- types/firestore.d.ts | 6 +- 7 files changed, 44 insertions(+), 44 deletions(-) rename dev/src/reference/{vector-query-options.ts => find-nearest-options.ts} (98%) diff --git a/api-report/firestore.api.md b/api-report/firestore.api.md index 7bc66053b..c62fc618c 100644 --- a/api-report/firestore.api.md +++ b/api-report/firestore.api.md @@ -748,6 +748,16 @@ export abstract class Filter { static where(fieldPath: string | firestore.FieldPath, opStr: firestore.WhereFilterOp, value: unknown): Filter; } +// @public +export interface FindNearestOptions { + distanceMeasure: 'EUCLIDEAN' | 'COSINE' | 'DOT_PRODUCT'; + distanceResultField?: string | firestore.FieldPath; + distanceThreshold?: number; + limit: number; + queryVector: firestore.VectorValue | Array; + vectorField: string | firestore.FieldPath; +} + // Warning: (tsdoc-undefined-tag) The TSDoc tag "@class" is not defined in this configuration // // @public @@ -1048,9 +1058,9 @@ export class Query; - findNearest(options: VectorQueryOptions): VectorQuery; + findNearest(options: FindNearestOptions): VectorQuery; // (undocumented) - _findNearest(options: VectorQueryOptions): VectorQuery; + _findNearest(options: FindNearestOptions): VectorQuery; // Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag // Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@" // Warning: (tsdoc-undefined-tag) The TSDoc tag "@type" is not defined in this configuration @@ -1459,7 +1469,7 @@ export class VectorQuery, _options: VectorQueryOptions); + constructor(_query: Query, _options: FindNearestOptions); // Warning: (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration // // @internal @@ -1489,16 +1499,6 @@ export class VectorQuery; - vectorField: string | firestore.FieldPath; -} - // @public export class VectorQuerySnapshot implements firestore.VectorQuerySnapshot { // Warning: (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration @@ -1685,22 +1685,22 @@ export class WriteResult implements firestore.WriteResult { // build/src/reference/field-order.d.ts:22:4 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration // build/src/reference/field-order.d.ts:24:4 - (tsdoc-undefined-tag) The TSDoc tag "@class" is not defined in this configuration // build/src/reference/query-options.d.ts:27:4 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration -// build/src/reference/query.d.ts:418:8 - (tsdoc-undefined-tag) The TSDoc tag "@return" is not defined in this configuration -// build/src/reference/query.d.ts:424:8 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration -// build/src/reference/query.d.ts:426:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen -// build/src/reference/query.d.ts:434:8 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration -// build/src/reference/query.d.ts:436:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen -// build/src/reference/query.d.ts:436:15 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}' -// build/src/reference/query.d.ts:438:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen -// build/src/reference/query.d.ts:438:15 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}' -// build/src/reference/query.d.ts:440:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen -// build/src/reference/query.d.ts:442:24 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag -// build/src/reference/query.d.ts:442:17 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@" -// build/src/reference/query.d.ts:451:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen -// build/src/reference/query.d.ts:453:8 - (tsdoc-undefined-tag) The TSDoc tag "@return" is not defined in this configuration -// build/src/reference/query.d.ts:455:8 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration -// build/src/reference/query.d.ts:641:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen -// build/src/reference/query.d.ts:642:8 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration +// build/src/reference/query.d.ts:425:8 - (tsdoc-undefined-tag) The TSDoc tag "@return" is not defined in this configuration +// build/src/reference/query.d.ts:431:8 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration +// build/src/reference/query.d.ts:433:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen +// build/src/reference/query.d.ts:441:8 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration +// build/src/reference/query.d.ts:443:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen +// build/src/reference/query.d.ts:443:15 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}' +// build/src/reference/query.d.ts:445:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen +// build/src/reference/query.d.ts:445:15 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}' +// build/src/reference/query.d.ts:447:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen +// build/src/reference/query.d.ts:449:24 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag +// build/src/reference/query.d.ts:449:17 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@" +// build/src/reference/query.d.ts:458:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen +// build/src/reference/query.d.ts:460:8 - (tsdoc-undefined-tag) The TSDoc tag "@return" is not defined in this configuration +// build/src/reference/query.d.ts:462:8 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration +// build/src/reference/query.d.ts:648:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen +// build/src/reference/query.d.ts:649:8 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration // build/src/reference/vector-query.d.ts:50:8 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration // build/src/reference/vector-query.d.ts:55:8 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration // build/src/reference/vector-query.d.ts:60:8 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration diff --git a/dev/src/index.ts b/dev/src/index.ts index 0b2f195af..56f607128 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -103,7 +103,7 @@ export type {AggregateQuery} from './reference/aggregate-query'; export type {AggregateQuerySnapshot} from './reference/aggregate-query-snapshot'; export type {VectorQuery} from './reference/vector-query'; export type {VectorQuerySnapshot} from './reference/vector-query-snapshot'; -export type {VectorQueryOptions} from './reference/vector-query-options'; +export type {FindNearestOptions} from './reference/find-nearest-options'; export {BulkWriter} from './bulk-writer'; export type {BulkWriterError} from './bulk-writer'; export type {BundleBuilder} from './bundle'; diff --git a/dev/src/reference/vector-query-options.ts b/dev/src/reference/find-nearest-options.ts similarity index 98% rename from dev/src/reference/vector-query-options.ts rename to dev/src/reference/find-nearest-options.ts index 10a851a96..2888f7555 100644 --- a/dev/src/reference/vector-query-options.ts +++ b/dev/src/reference/find-nearest-options.ts @@ -19,7 +19,7 @@ import * as firestore from '@google-cloud/firestore'; /** * Specifies the behavior of the {@link VectorQuery} generated by a call to {@link Query.findNearest}. */ -export interface VectorQueryOptions { +export interface FindNearestOptions { /** * A string or {@link FieldPath} specifying the vector field to search on. */ diff --git a/dev/src/reference/query.ts b/dev/src/reference/query.ts index d578bee84..46eb58397 100644 --- a/dev/src/reference/query.ts +++ b/dev/src/reference/query.ts @@ -37,7 +37,7 @@ import {FilterInternal} from './filter-internal'; import {FieldFilterInternal} from './field-filter-internal'; import {CompositeFilterInternal} from './composite-filter-internal'; import {comparisonOperators, directionOperators} from './constants'; -import {VectorQueryOptions} from './vector-query-options'; +import {FindNearestOptions} from './find-nearest-options'; import {DocumentReference} from './document-reference'; import {QuerySnapshot} from './query-snapshot'; import {Serializer} from '../serializer'; @@ -668,14 +668,14 @@ export class Query< * querySnapshot.forEach(...); * ``` * @param options - An argument specifying the behavior of the {@link VectorQuery} returned by this function. - * See {@link VectorQueryOptions}. + * See {@link FindNearestOptions}. */ findNearest( - options: VectorQueryOptions + options: FindNearestOptions ): VectorQuery; findNearest( - vectorFieldOrOptions: string | firestore.FieldPath | VectorQueryOptions, + vectorFieldOrOptions: string | firestore.FieldPath | FindNearestOptions, queryVector?: firestore.VectorValue | Array, options?: { limit?: number; @@ -686,7 +686,7 @@ export class Query< typeof vectorFieldOrOptions === 'string' || vectorFieldOrOptions instanceof FieldPath ) { - const fnOptions: VectorQueryOptions = { + const fnOptions: FindNearestOptions = { distanceMeasure: options!.distanceMeasure!, limit: options!.limit!, queryVector: queryVector!, @@ -694,12 +694,12 @@ export class Query< }; return this._findNearest(fnOptions); } else { - return this._findNearest(vectorFieldOrOptions as VectorQueryOptions); + return this._findNearest(vectorFieldOrOptions as FindNearestOptions); } } _findNearest( - options: VectorQueryOptions + options: FindNearestOptions ): VectorQuery { validateFieldPath('vectorField', options.vectorField); diff --git a/dev/src/reference/vector-query.ts b/dev/src/reference/vector-query.ts index 3fe36194f..bab57dc96 100644 --- a/dev/src/reference/vector-query.ts +++ b/dev/src/reference/vector-query.ts @@ -26,7 +26,7 @@ import {DocumentChange} from '../document-change'; import {isPrimitiveArrayEqual} from '../util'; import {QueryUtil} from './query-util'; import {Query} from './query'; -import {VectorQueryOptions} from './vector-query-options'; +import {FindNearestOptions} from './find-nearest-options'; import {VectorQuerySnapshot} from './vector-query-snapshot'; import {ExplainResults} from '../query-profile'; import {QueryResponse} from './types'; @@ -56,7 +56,7 @@ export class VectorQuery< */ constructor( private readonly _query: Query, - private readonly _options: VectorQueryOptions + private readonly _options: FindNearestOptions ) { this._queryUtil = new QueryUtil< AppModelType, diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index cf2a31299..f0299b13b 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -2538,7 +2538,7 @@ describe('Query class', () => { expect(res.docs[0].get('distance')).to.equal(1); }); - it.only('supports select queries', async () => { + it('supports select queries', async () => { const indexTestHelper = new IndexTestHelper(firestore); const collectionReference = await indexTestHelper.setTestDocs({ diff --git a/types/firestore.d.ts b/types/firestore.d.ts index d13632ca0..1c2fd8898 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -2091,10 +2091,10 @@ declare namespace FirebaseFirestore { * querySnapshot.forEach(...); * ``` * @param options - An argument specifying the behavior of the {@link VectorQuery} returned by this function. - * See {@link VectorQueryOptions}. + * See {@link FindNearestOptions}. */ findNearest( - options: VectorQueryOptions + options: FindNearestOptions ): VectorQuery; /** @@ -3231,7 +3231,7 @@ declare namespace FirebaseFirestore { /** * Specifies the behavior of the {@link VectorQuery} generated by a call to {@link Query.findNearest}. */ - export interface VectorQueryOptions { + export interface FindNearestOptions { /** * A string or {@link FieldPath} specifying the vector field to search on. */