diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index 07af0bacd6e..7435e2a250e 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -375,14 +375,13 @@ export class Constant { static of(value: string): Constant; static of(value: boolean): Constant; static of(value: null): Constant; - static of(value: undefined): Constant; static of(value: GeoPoint): Constant; static of(value: Timestamp): Constant; static of(value: Date): Constant; - static of(value: Uint8Array): Constant; + static of(value: Bytes): Constant; static of(value: DocumentReference): Constant; static of(value: any[]): Constant; - static of(value: Map): Constant; + static of(value: Record): Constant; static of(value: VectorValue): Constant; regexContains(pattern: string): RegexContains; regexContains(pattern: Constant): RegexContains; @@ -2205,8 +2204,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9244:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9245:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9274:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9238:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9239:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9268:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index 270c71fe955..37317520020 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -390,14 +390,13 @@ export class Constant { static of(value: string): Constant; static of(value: boolean): Constant; static of(value: null): Constant; - static of(value: undefined): Constant; static of(value: GeoPoint): Constant; static of(value: Timestamp): Constant; static of(value: Date): Constant; - static of(value: Uint8Array): Constant; + static of(value: Bytes): Constant; static of(value: DocumentReference): Constant; static of(value: any[]): Constant; - static of(value: Map): Constant; + static of(value: Record): Constant; static of(value: VectorValue): Constant; regexContains(pattern: string): RegexContains; regexContains(pattern: Constant): RegexContains; @@ -2509,8 +2508,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10173:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10173:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10200:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10167:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10167:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10194:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/packages/firestore/src/lite-api/expressions.ts b/packages/firestore/src/lite-api/expressions.ts index 3ec68601e9e..261f8112c4d 100644 --- a/packages/firestore/src/lite-api/expressions.ts +++ b/packages/firestore/src/lite-api/expressions.ts @@ -30,6 +30,7 @@ import { } from '../remote/serializer'; import { hardAssert } from '../util/assert'; +import { Bytes } from './bytes'; import { documentId, FieldPath } from './field_path'; import { GeoPoint } from './geo_point'; import { Pipeline } from './pipeline'; @@ -2084,6 +2085,8 @@ export class Constant extends Expr { /** * Creates a `Constant` instance for an undefined value. + * @private + * @internal * * @param value The undefined value. * @return A new `Constant` instance. @@ -2115,12 +2118,12 @@ export class Constant extends Expr { static of(value: Date): Constant; /** - * Creates a `Constant` instance for a Uint8Array value. + * Creates a `Constant` instance for a Bytes value. * - * @param value The Uint8Array value. + * @param value The Bytes value. * @return A new `Constant` instance. */ - static of(value: Uint8Array): Constant; + static of(value: Bytes): Constant; /** * Creates a `Constant` instance for a DocumentReference value. @@ -2130,9 +2133,9 @@ export class Constant extends Expr { */ static of(value: DocumentReference): Constant; - // TODO(pipeline) if we make this public, then the Proto types should also be documented /** * Creates a `Constant` instance for a Firestore proto value. + * For internal use only. * @private * @internal * @param value The Firestore proto value. @@ -2154,7 +2157,7 @@ export class Constant extends Expr { * @param value The map value. * @return A new `Constant` instance. */ - static of(value: Map): Constant; + static of(value: Record): Constant; /** * Creates a `Constant` instance for a VectorValue value. diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index ddedc966eb4..1376947f482 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -18,6 +18,9 @@ import { expect, use } from 'chai'; import chaiAsPromised from 'chai-as-promised'; +import { Bytes, vector } from '../../../src/api'; +import { GeoPoint } from '../../../src/lite-api/geo_point'; +import { Timestamp } from '../../../src/lite-api/timestamp'; import { addEqualityMatcher } from '../../util/equality_matcher'; import { Deferred } from '../../util/promise'; import { @@ -476,6 +479,114 @@ apiDescribe('Pipelines', persistence => { ); }); + it('accepts and returns all data types', async () => { + const refDate = new Date(); + const refTimestamp = Timestamp.now(); + const constants = [ + Constant.of(1).as('number'), + Constant.of('a string').as('string'), + Constant.of(true).as('boolean'), + Constant.of(null).as('null'), + Constant.of(new GeoPoint(0.1, 0.2)).as('geoPoint'), + Constant.of(refTimestamp).as('timestamp'), + Constant.of(refDate).as('date'), + Constant.of( + Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])) + ).as('bytes'), + Constant.of(doc(firestore, 'foo', 'bar')).as('documentReference'), + Constant.of(vector([1, 2, 3])).as('vectorValue'), + Constant.of({ + 'number': 1, + 'string': 'a string', + 'boolean': true, + 'null': null, + 'geoPoint': new GeoPoint(0.1, 0.2), + 'timestamp': refTimestamp, + 'date': refDate, + 'uint8Array': Bytes.fromUint8Array( + new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0]) + ), + 'documentReference': doc(firestore, 'foo', 'bar'), + 'vectorValue': vector([1, 2, 3]), + 'map': { + 'number': 2, + 'string': 'b string' + }, + 'array': [1, 'c string'] + }).as('map'), + Constant.of([ + 1, + 'a string', + true, + null, + new GeoPoint(0.1, 0.2), + refTimestamp, + refDate, + Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])), + doc(firestore, 'foo', 'bar'), + vector([1, 2, 3]), + { + 'number': 2, + 'string': 'b string' + } + ]).as('array') + ]; + + const results = await randomCol + .pipeline() + .limit(1) + .select(...constants) + .execute(); + + expectResults(results, { + 'number': 1, + 'string': 'a string', + 'boolean': true, + 'null': null, + 'geoPoint': new GeoPoint(0.1, 0.2), + 'timestamp': refTimestamp, + 'date': Timestamp.fromDate(refDate), + 'bytes': Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])), + 'documentReference': doc(firestore, 'foo', 'bar'), + 'vectorValue': vector([1, 2, 3]), + 'map': { + 'number': 1, + 'string': 'a string', + 'boolean': true, + 'null': null, + 'geoPoint': new GeoPoint(0.1, 0.2), + 'timestamp': refTimestamp, + 'date': Timestamp.fromDate(refDate), + 'uint8Array': Bytes.fromUint8Array( + new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0]) + ), + 'documentReference': doc(firestore, 'foo', 'bar'), + 'vectorValue': vector([1, 2, 3]), + 'map': { + 'number': 2, + 'string': 'b string' + }, + 'array': [1, 'c string'] + }, + 'array': [ + 1, + 'a string', + true, + null, + new GeoPoint(0.1, 0.2), + refTimestamp, + Timestamp.fromDate(refDate), + Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])), + doc(firestore, 'foo', 'bar'), + vector([1, 2, 3]), + { + 'number': 2, + 'string': 'b string' + } + ] + }); + }); + it('cond works', async () => { const results = await randomCol .pipeline()