diff --git a/.changeset/brave-boats-arrive.md b/.changeset/brave-boats-arrive.md new file mode 100644 index 00000000000..1e2f703ddb3 --- /dev/null +++ b/.changeset/brave-boats-arrive.md @@ -0,0 +1,7 @@ +--- +'@firebase/remote-config': patch +'@firebase/analytics': patch +'firebase': patch +--- + +Add rollup config to generate modular typings for google3 diff --git a/.changeset/brown-pens-confess.md b/.changeset/brown-pens-confess.md new file mode 100644 index 00000000000..038b177796e --- /dev/null +++ b/.changeset/brown-pens-confess.md @@ -0,0 +1,6 @@ +--- +"@firebase/storage": patch +"@firebase/util": patch +--- + +Fixed issue where Storage on Firebase Studio throws CORS errors. diff --git a/.changeset/giant-lamps-live.md b/.changeset/giant-lamps-live.md new file mode 100644 index 00000000000..f66c22deb86 --- /dev/null +++ b/.changeset/giant-lamps-live.md @@ -0,0 +1,5 @@ +--- +'@firebase/app': patch +--- + +Add "react-native" entry point to @firebase/app diff --git a/.changeset/long-pets-sell.md b/.changeset/long-pets-sell.md new file mode 100644 index 00000000000..d340f7da82c --- /dev/null +++ b/.changeset/long-pets-sell.md @@ -0,0 +1,5 @@ +--- +'@firebase/firestore': patch +--- + +Internal listener registration change for IndexedDB "versionchange" events. diff --git a/.changeset/moody-comics-speak.md b/.changeset/moody-comics-speak.md new file mode 100644 index 00000000000..9a178a6605b --- /dev/null +++ b/.changeset/moody-comics-speak.md @@ -0,0 +1,8 @@ +--- +'@firebase/firestore': minor +'firebase': minor +--- + +Added support for Firestore result types to be serialized with `toJSON` and then deserialized with `fromJSON` methods on the objects. + +Addeed support to resume `onSnapshot` listeners in the CSR phase based on serialized `DataSnapshot`s and `QuerySnapshot`s built in the SSR phase. diff --git a/.changeset/old-candles-confess.md b/.changeset/old-candles-confess.md new file mode 100644 index 00000000000..6fbe742818f --- /dev/null +++ b/.changeset/old-candles-confess.md @@ -0,0 +1,5 @@ +--- +'@firebase/ai': patch +--- + +Add deprecation label to `totalBillableCharacters`. `totalTokens` should be used instead. diff --git a/.github/ISSUE_TEMPLATE/bug_report_v2.yaml b/.github/ISSUE_TEMPLATE/bug_report_v2.yaml index 24cc0efb53e..b466840862d 100644 --- a/.github/ISSUE_TEMPLATE/bug_report_v2.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report_v2.yaml @@ -58,6 +58,7 @@ body: description: Select the Firebase product(s) relevant to your issue. You can select multiple options in the dropdown. multiple: true options: + - AI - Analytics - AppCheck - Auth @@ -72,7 +73,6 @@ body: - Performance - Remote-Config - Storage - - VertexAI validations: required: true - type: textarea diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 0857860571f..fbf43beada1 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -30,8 +30,8 @@ jobs: defaults: run: - # Run any command steps in the /e2e subdir - working-directory: './e2e' + # Run any command steps in the /e2e/smoke-tests subdir + working-directory: './e2e/smoke-tests' steps: - name: Checkout Repo @@ -53,7 +53,9 @@ jobs: - name: Poll npm until version to test is available for install run: | echo "Polling npm for firebase@${{ github.event.client_payload.versionOrTag }}" - node ../scripts/release/poll-npm-publish.js + node ./scripts/release/poll-npm-publish.js + # run in root + working-directory: '.' env: VERSION: ${{ github.event.client_payload.versionOrTag }} - name: Yarn install diff --git a/.gitignore b/.gitignore index 5aaf5c0b5be..a989576ccf3 100644 --- a/.gitignore +++ b/.gitignore @@ -103,4 +103,4 @@ vertexai-sdk-test-data mocks-lookup.ts # temp changeset output -changeset-temp.json \ No newline at end of file +changeset-temp.json diff --git a/.vscode/launch.json b/.vscode/launch.json index df14c96daa6..1f627304b61 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,7 +9,7 @@ "type": "node", "request": "launch", "program": "${workspaceFolder}/node_modules/.bin/_mocha", - "cwd": "${workspaceRoot}/packages/vertexai", + "cwd": "${workspaceRoot}/packages/ai", "args": [ "--require", "ts-node/register", @@ -24,6 +24,26 @@ }, "sourceMaps": true }, + { + "name": "AI Integration Tests (node)", + "type": "node", + "request": "launch", + "program": "${workspaceFolder}/node_modules/.bin/_mocha", + "cwd": "${workspaceRoot}/packages/ai", + "args": [ + "--require", + "ts-node/register", + "--require", + "src/index.node.ts", + "--timeout", + "5000", + "integration/**/*.test.ts" + ], + "env": { + "TS_NODE_COMPILER_OPTIONS": "{\"module\":\"commonjs\"}" + }, + "sourceMaps": true + }, { "type": "node", "request": "launch", diff --git a/README.md b/README.md index d1947bd7fe6..1db82c79608 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,8 @@ and follow the instructions to login. For more information, visit https://firebase.google.com/docs/storage/web/download-files#cors_configuration +Then, make sure you have anonymous sign-in provider enabled: + #### Authentication Support Visit the authentication config in your project and enable the `Anonymous` diff --git a/common/api-review/ai.api.md b/common/api-review/ai.api.md index 523b51d7533..ab79447798f 100644 --- a/common/api-review/ai.api.md +++ b/common/api-review/ai.api.md @@ -164,6 +164,7 @@ export interface CountTokensRequest { // @public export interface CountTokensResponse { promptTokensDetails?: ModalityTokenCount[]; + // @deprecated (undocumented) totalBillableCharacters?: number; totalTokens: number; } @@ -791,6 +792,9 @@ export abstract class Schema implements SchemaInterface { format?: string; // (undocumented) static integer(integerParams?: SchemaParams): IntegerSchema; + items?: SchemaInterface; + maxItems?: number; + minItems?: number; nullable: boolean; // (undocumented) static number(numberParams?: SchemaParams): NumberSchema; @@ -833,7 +837,9 @@ export interface SchemaShared { format?: string; items?: T; maximum?: number; + maxItems?: number; minimum?: number; + minItems?: number; nullable?: boolean; properties?: { [k: string]: T; diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index 35d31345e12..46b85a0efc5 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -9,54 +9,14 @@ import { FirebaseApp } from '@firebase/app'; import { FirebaseError } from '@firebase/util'; import { LogLevelString as LogLevel } from '@firebase/logger'; -// @beta -export interface Accumulator { - // (undocumented) - accumulator: true; -} - -// @beta -export type AccumulatorTarget = ExprWithAlias; - -// @beta (undocumented) -export class Add extends FirestoreFunction { - constructor(left: Constant, right: Constant); - } - -// @beta -export function add(left: Constant, right: Constant): Add; - -// @beta -export function add(left: Constant, right: any): Add; - -// @beta -export function add(left: string, right: Constant): Add; - -// @beta -export function add(left: string, right: any): Add; - // @public export function addDoc(reference: CollectionReference, data: WithFieldValue): Promise>; -// @beta (undocumented) -export class AddFields implements Stage { - constructor(fields: Map); - // (undocumented) - name: string; -} - // @public export type AddPrefixToKeys> = { [K in keyof T & string as `${Prefix}.${K}`]+?: string extends K ? any : T[K]; }; -// @beta (undocumented) -export class Aggregate implements Stage { - constructor(accumulators: Map, groups: Map); - // (undocumented) - name: string; -} - // @public export class AggregateField { readonly aggregateType: AggregateType; @@ -93,159 +53,30 @@ export type AggregateSpecData = { // @public export type AggregateType = 'count' | 'avg' | 'sum'; -// @beta (undocumented) -export class And extends FirestoreFunction implements FilterCondition { - constructor(conditions: FilterExpr[]); - // (undocumented) - filterable: true; -} - // @public export function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; -// @beta (undocumented) -export class ArrayConcat extends FirestoreFunction { - constructor(array: Constant, elements: Constant[]); - } - -// @beta -export function arrayConcat(array: Constant, elements: Constant[]): ArrayConcat; - -// @beta -export function arrayConcat(array: Constant, elements: any[]): ArrayConcat; - -// @beta -export function arrayConcat(array: string, elements: Constant[]): ArrayConcat; - -// @beta -export function arrayConcat(array: string, elements: any[]): ArrayConcat; - -// @beta (undocumented) -export class ArrayContains extends FirestoreFunction implements FilterCondition { - constructor(array: Constant, element: Constant); - // (undocumented) - filterable: true; -} - -// @beta -export function arrayContains(array: Constant, element: Constant): ArrayContains; - -// @beta -export function arrayContains(array: Constant, element: any): ArrayContains; - -// @beta -export function arrayContains(array: string, element: Constant): ArrayContains; - -// @beta -export function arrayContains(array: string, element: any): ArrayContains; - -// @beta (undocumented) -export class ArrayContainsAll extends FirestoreFunction implements FilterCondition { - constructor(array: Constant, values: Constant[]); - // (undocumented) - filterable: true; - } - -// @beta -export function arrayContainsAll(array: Constant, values: Constant[]): ArrayContainsAll; - -// @beta -export function arrayContainsAll(array: Constant, values: any[]): ArrayContainsAll; - -// @beta -export function arrayContainsAll(array: string, values: Constant[]): ArrayContainsAll; - -// @beta -export function arrayContainsAll(array: string, values: any[]): ArrayContainsAll; - -// @beta (undocumented) -export class ArrayContainsAny extends FirestoreFunction implements FilterCondition { - constructor(array: Constant, values: Constant[]); - // (undocumented) - filterable: true; - } - -// @beta -export function arrayContainsAny(array: Constant, values: Constant[]): ArrayContainsAny; - -// @beta -export function arrayContainsAny(array: Constant, values: any[]): ArrayContainsAny; - -// @beta -export function arrayContainsAny(array: string, values: Constant[]): ArrayContainsAny; - -// @beta -export function arrayContainsAny(array: string, values: any[]): ArrayContainsAny; - -// @beta (undocumented) -export class ArrayElement extends FirestoreFunction { - constructor(); -} - -// @beta (undocumented) -export class ArrayLength extends FirestoreFunction { - constructor(array: Constant); - } - -// @beta -export function arrayLength(array: Constant): ArrayLength; - // @public export function arrayRemove(...elements: unknown[]): FieldValue; -// @beta (undocumented) -export class ArrayReverse extends FirestoreFunction { - constructor(array: Constant); - } - // @public export function arrayUnion(...elements: unknown[]): FieldValue; -// @beta -export function ascending(expr: Constant): Ordering; - // @public export function average(field: string | FieldPath): AggregateField; -// @beta (undocumented) -export class Avg extends FirestoreFunction implements Accumulator { - constructor(value: Constant, distinct: boolean); - // (undocumented) - accumulator: true; - } - -// @beta (undocumented) -export class ByteLength extends FirestoreFunction { - constructor(value: Constant); - } - -// @beta -export function byteLength(expr: Constant): ByteLength; - -// @beta -export function byteLength(field: string): ByteLength; - // @public export class Bytes { static fromBase64String(base64: string): Bytes; + static fromJSON(json: object): Bytes; static fromUint8Array(array: Uint8Array): Bytes; isEqual(other: Bytes): boolean; toBase64(): string; + toJSON(): object; toString(): string; toUint8Array(): Uint8Array; } -// @beta (undocumented) -export class CharLength extends FirestoreFunction { - constructor(value: Constant); - } - -// @beta -export function charLength(field: string): CharLength; - -// @beta -export function charLength(expr: Constant): CharLength; - // @public export type ChildUpdateFields = V extends Record ? AddPrefixToKeys> : never; @@ -261,13 +92,6 @@ export function collection(refer // @public export function collectionGroup(firestore: Firestore, collectionId: string): Query; -// @beta (undocumented) -export class CollectionGroupSource implements Stage { - constructor(collectionId: string); - // (undocumented) - name: string; -} - // @public export class CollectionReference extends Query { get id(): string; @@ -278,208 +102,20 @@ export class CollectionReference; } -// @beta (undocumented) -export class CollectionSource implements Stage { - constructor(collectionPath: string); - // (undocumented) - name: string; -} - // @public export function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: { mockUserToken?: EmulatorMockTokenOptions | string; }): void; -// @beta -export class Constant { - add(other: Constant): Add; - add(other: any): Add; - arrayConcat(arrays: Constant[]): ArrayConcat; - arrayConcat(arrays: any[]): ArrayConcat; - arrayContains(element: Constant): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Constant[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Constant[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; - ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Constant): CosineDistance; - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; - descending(): Ordering; - divide(other: Constant): Divide; - divide(other: any): Divide; - dotProduct(other: Constant): DotProduct; - dotProduct(other: VectorValue): DotProduct; - // (undocumented) - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Constant): EndsWith; - eq(other: Constant): Eq; - eq(other: any): Eq; - euclideanDistance(other: Constant): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; - // (undocumented) - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; - // (undocumented) - exprType: ExprType; - gt(other: Constant): Gt; - gt(other: any): Gt; - gte(other: Constant): Gte; - gte(other: any): Gte; - in(...others: Constant[]): In; - // (undocumented) - in(...others: any[]): In; - isNaN(): IsNan; - like(pattern: string): Like; - // (undocumented) - like(pattern: Constant): Like; - logicalMax(other: Constant): LogicalMax; - logicalMax(other: any): LogicalMax; - logicalMin(other: Constant): LogicalMin; - logicalMin(other: any): LogicalMin; - lt(other: Constant): Lt; - lt(other: any): Lt; - lte(other: Constant): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - max(): Max; - min(): Min; - mod(other: Constant): Mod; - mod(other: any): Mod; - multiply(other: Constant): Multiply; - multiply(other: any): Multiply; - neq(other: Constant): Neq; - neq(other: any): Neq; - static of(value: number): 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: DocumentReference): Constant; - static of(value: any[]): Constant; - static of(value: Map): Constant; - static of(value: VectorValue): Constant; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Constant): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Constant): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Constant, replace: Constant): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Constant, replace: Constant): ReplaceFirst; - reverse(): Reverse; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Constant): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Constant): StrContains; - subtract(other: Constant): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Constant, amount: Constant): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Constant, amount: Constant): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; - static vector(value: number[] | VectorValue): Constant; - vectorLength(): VectorLength; -} - -// @beta (undocumented) -export class CosineDistance extends FirestoreFunction { - constructor(vector1: Constant, vector2: Constant); - } - -// @beta -export function cosineDistance(expr: string, other: number[]): CosineDistance; - -// @beta -export function cosineDistance(expr: string, other: VectorValue): CosineDistance; - -// @beta -export function cosineDistance(expr: string, other: Constant): CosineDistance; - -// @beta -export function cosineDistance(expr: Constant, other: number[]): CosineDistance; - -// @beta -export function cosineDistance(expr: Constant, other: VectorValue): CosineDistance; - -// @beta -export function cosineDistance(expr: Constant, other: Constant): CosineDistance; - -// @beta (undocumented) -export class Count extends FirestoreFunction implements Accumulator { - constructor(value: Constant | undefined, distinct: boolean); - // (undocumented) - accumulator: true; - } - // @public export function count(): AggregateField; -// @beta -export function countAll(): Count; - -// @beta (undocumented) -export class DatabaseSource implements Stage { - // (undocumented) - name: string; -} - // @public export function deleteDoc(reference: DocumentReference): Promise; // @public export function deleteField(): FieldValue; -// @beta -export function descending(expr: Constant): Ordering; - -// @beta (undocumented) -export class Distinct implements Stage { - constructor(groups: Map); - // (undocumented) - name: string; -} - -// @beta (undocumented) -export class Divide extends FirestoreFunction { - constructor(left: Constant, right: Constant); - } - -// @beta -export function divide(left: Constant, right: Constant): Divide; - -// @beta -export function divide(left: Constant, right: any): Divide; - -// @beta -export function divide(left: string, right: Constant): Divide; - -// @beta -export function divide(left: string, right: any): Divide; - // @public export function doc(firestore: Firestore, path: string, ...pathSegments: string[]): DocumentReference; @@ -501,9 +137,12 @@ export function documentId(): FieldPath; export class DocumentReference { readonly converter: FirestoreDataConverter | null; readonly firestore: Firestore; + static fromJSON(firestore: Firestore, json: object): DocumentReference; + static fromJSON(firestore: Firestore, json: object, converter: FirestoreDataConverter): DocumentReference; get id(): string; get parent(): CollectionReference; get path(): string; + toJSON(): object; readonly type = "document"; withConverter(converter: FirestoreDataConverter): DocumentReference; withConverter(converter: null): DocumentReference; @@ -519,38 +158,6 @@ export class DocumentSnapshot; } -// @beta (undocumented) -export class DocumentsSource implements Stage { - constructor(docPaths: string[]); - // (undocumented) - name: string; - // (undocumented) - static of(refs: DocumentReference[]): DocumentsSource; -} - -// @beta (undocumented) -export class DotProduct extends FirestoreFunction { - constructor(vector1: Constant, vector2: Constant); - } - -// @beta -export function dotProduct(expr: string, other: number[]): DotProduct; - -// @beta -export function dotProduct(expr: string, other: VectorValue): DotProduct; - -// @beta -export function dotProduct(expr: string, other: Constant): DotProduct; - -// @beta -export function dotProduct(expr: Constant, other: number[]): DotProduct; - -// @beta -export function dotProduct(expr: Constant, other: VectorValue): DotProduct; - -// @beta -export function dotProduct(expr: Constant, other: Constant): DotProduct; - export { EmulatorMockTokenOptions } // @public @@ -565,458 +172,20 @@ export function endBefore(snapsh // @public export function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint; -// @beta (undocumented) -export class EndsWith extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant, suffix: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function endsWith(expr: string, suffix: string): EndsWith; - -// @beta -export function endsWith(expr: string, suffix: Constant): EndsWith; - -// @beta -export function endsWith(expr: Constant, suffix: string): EndsWith; - -// @beta -export function endsWith(expr: Constant, suffix: Constant): EndsWith; - -// @beta (undocumented) -export class Eq extends FirestoreFunction implements FilterCondition { - constructor(left: Constant, right: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function eq(left: Constant, right: Constant): Eq; - -// @beta -export function eq(left: Constant, right: any): Eq; - -// @beta -export function eq(left: string, right: Constant): Eq; - -// @beta -export function eq(left: string, right: any): Eq; - -// @beta (undocumented) -export class EuclideanDistance extends FirestoreFunction { - constructor(vector1: Constant, vector2: Constant); - } - -// @beta -export function euclideanDistance(expr: string, other: number[]): EuclideanDistance; - -// @beta -export function euclideanDistance(expr: string, other: VectorValue): EuclideanDistance; - -// @beta -export function euclideanDistance(expr: string, other: Constant): EuclideanDistance; - -// @beta -export function euclideanDistance(expr: Constant, other: number[]): EuclideanDistance; - -// @beta -export function euclideanDistance(expr: Constant, other: VectorValue): EuclideanDistance; - -// @beta -export function euclideanDistance(expr: Constant, other: Constant): EuclideanDistance; - -// @beta -export function execute(pipeline: Pipeline): Promise>>; - -// @beta (undocumented) -export class Exists extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant); - // (undocumented) - filterable: true; -} - -// @beta -export function exists(value: Constant): Exists; - -// @beta -export function exists(field: string): Exists; - -// @beta -export type ExprType = 'Field' | 'Constant' | 'Function' | 'ListOfExprs' | 'ExprWithAlias'; - -// @beta (undocumented) -export class ExprWithAlias implements Selectable { - constructor(expr: T, alias: string); - add(other: Constant): Add; - add(other: any): Add; - // (undocumented) - alias: string; - arrayConcat(arrays: Constant[]): ArrayConcat; - arrayConcat(arrays: any[]): ArrayConcat; - arrayContains(element: Constant): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Constant[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Constant[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; - ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Constant): CosineDistance; - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; - descending(): Ordering; - divide(other: Constant): Divide; - divide(other: any): Divide; - dotProduct(other: Constant): DotProduct; - dotProduct(other: VectorValue): DotProduct; - // (undocumented) - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Constant): EndsWith; - eq(other: Constant): Eq; - eq(other: any): Eq; - euclideanDistance(other: Constant): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; - // (undocumented) - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; - // (undocumented) - expr: T; - // (undocumented) - exprType: ExprType; - gt(other: Constant): Gt; - gt(other: any): Gt; - gte(other: Constant): Gte; - gte(other: any): Gte; - in(...others: Constant[]): In; - // (undocumented) - in(...others: any[]): In; - isNaN(): IsNan; - like(pattern: string): Like; - // (undocumented) - like(pattern: Constant): Like; - logicalMax(other: Constant): LogicalMax; - logicalMax(other: any): LogicalMax; - logicalMin(other: Constant): LogicalMin; - logicalMin(other: any): LogicalMin; - lt(other: Constant): Lt; - lt(other: any): Lt; - lte(other: Constant): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - max(): Max; - min(): Min; - mod(other: Constant): Mod; - mod(other: any): Mod; - multiply(other: Constant): Multiply; - multiply(other: any): Multiply; - neq(other: Constant): Neq; - neq(other: any): Neq; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Constant): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Constant): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Constant, replace: Constant): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Constant, replace: Constant): ReplaceFirst; - reverse(): Reverse; - // (undocumented) - selectable: true; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Constant): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Constant): StrContains; - subtract(other: Constant): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Constant, amount: Constant): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Constant, amount: Constant): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; - vectorLength(): VectorLength; -} - -// @beta -export class Field implements Selectable { - add(other: Constant): Add; - add(other: any): Add; - arrayConcat(arrays: Constant[]): ArrayConcat; - arrayConcat(arrays: any[]): ArrayConcat; - arrayContains(element: Constant): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Constant[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Constant[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; - ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Constant): CosineDistance; - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; - descending(): Ordering; - divide(other: Constant): Divide; - divide(other: any): Divide; - dotProduct(other: Constant): DotProduct; - dotProduct(other: VectorValue): DotProduct; - // (undocumented) - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Constant): EndsWith; - eq(other: Constant): Eq; - eq(other: any): Eq; - euclideanDistance(other: Constant): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; - // (undocumented) - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; - // (undocumented) - exprType: ExprType; - // (undocumented) - fieldName(): string; - gt(other: Constant): Gt; - gt(other: any): Gt; - gte(other: Constant): Gte; - gte(other: any): Gte; - in(...others: Constant[]): In; - // (undocumented) - in(...others: any[]): In; - isNaN(): IsNan; - like(pattern: string): Like; - // (undocumented) - like(pattern: Constant): Like; - logicalMax(other: Constant): LogicalMax; - logicalMax(other: any): LogicalMax; - logicalMin(other: Constant): LogicalMin; - logicalMin(other: any): LogicalMin; - lt(other: Constant): Lt; - lt(other: any): Lt; - lte(other: Constant): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - max(): Max; - min(): Min; - mod(other: Constant): Mod; - mod(other: any): Mod; - multiply(other: Constant): Multiply; - multiply(other: any): Multiply; - neq(other: Constant): Neq; - neq(other: any): Neq; - static of(name: string): Field; - // (undocumented) - static of(path: FieldPath): Field; - // (undocumented) - static of(pipeline: Pipeline, name: string): Field; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Constant): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Constant): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Constant, replace: Constant): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Constant, replace: Constant): ReplaceFirst; - reverse(): Reverse; - // (undocumented) - selectable: true; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Constant): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Constant): StrContains; - subtract(other: Constant): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Constant, amount: Constant): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Constant, amount: Constant): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; - vectorLength(): VectorLength; -} - // @public export class FieldPath { constructor(...fieldNames: string[]); isEqual(other: FieldPath): boolean; } -// @beta (undocumented) -export class Fields implements Selectable { - add(other: Constant): Add; - add(other: any): Add; - arrayConcat(arrays: Constant[]): ArrayConcat; - arrayConcat(arrays: any[]): ArrayConcat; - arrayContains(element: Constant): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Constant[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Constant[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; - ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Constant): CosineDistance; - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; - descending(): Ordering; - divide(other: Constant): Divide; - divide(other: any): Divide; - dotProduct(other: Constant): DotProduct; - dotProduct(other: VectorValue): DotProduct; - // (undocumented) - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Constant): EndsWith; - eq(other: Constant): Eq; - eq(other: any): Eq; - euclideanDistance(other: Constant): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; - // (undocumented) - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; - // (undocumented) - exprType: ExprType; - // (undocumented) - fieldList(): Field[]; - gt(other: Constant): Gt; - gt(other: any): Gt; - gte(other: Constant): Gte; - gte(other: any): Gte; - in(...others: Constant[]): In; - // (undocumented) - in(...others: any[]): In; - isNaN(): IsNan; - like(pattern: string): Like; - // (undocumented) - like(pattern: Constant): Like; - logicalMax(other: Constant): LogicalMax; - logicalMax(other: any): LogicalMax; - logicalMin(other: Constant): LogicalMin; - logicalMin(other: any): LogicalMin; - lt(other: Constant): Lt; - lt(other: any): Lt; - lte(other: Constant): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - max(): Max; - min(): Min; - mod(other: Constant): Mod; - mod(other: any): Mod; - multiply(other: Constant): Multiply; - multiply(other: any): Multiply; - neq(other: Constant): Neq; - neq(other: any): Neq; - // (undocumented) - static of(name: string, ...others: string[]): Fields; - // (undocumented) - static ofAll(): Fields; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Constant): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Constant): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Constant, replace: Constant): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Constant, replace: Constant): ReplaceFirst; - reverse(): Reverse; - // (undocumented) - selectable: true; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Constant): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Constant): StrContains; - subtract(other: Constant): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Constant, amount: Constant): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Constant, amount: Constant): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; - vectorLength(): VectorLength; -} - // @public export abstract class FieldValue { abstract isEqual(other: FieldValue): boolean; } -// @beta -export interface FilterCondition { - // (undocumented) - filterable: true; -} - -// @beta -export type FilterExpr = Constant & FilterCondition; - -// @beta (undocumented) -export class FindNearest implements Stage { - // (undocumented) - name: string; -} - -// @beta (undocumented) -export interface FindNearestOptions { - // (undocumented) - distanceField?: string; - // (undocumented) - distanceMeasure: 'euclidean' | 'cosine' | 'dot_product'; - // (undocumented) - field: Field; - // (undocumented) - limit?: number; - // (undocumented) - vectorValue: VectorValue | number[]; -} - // @public export class Firestore { get app(): FirebaseApp; - // Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta - pipeline(): PipelineSource; toJSON(): object; type: 'firestore-lite' | 'firestore'; } @@ -1033,490 +202,73 @@ export class FirestoreError extends FirebaseError { readonly code: FirestoreErrorCode; readonly message: string; readonly stack?: string; -} - -// @public -export type FirestoreErrorCode = 'cancelled' | 'unknown' | 'invalid-argument' | 'deadline-exceeded' | 'not-found' | 'already-exists' | 'permission-denied' | 'resource-exhausted' | 'failed-precondition' | 'aborted' | 'out-of-range' | 'unimplemented' | 'internal' | 'unavailable' | 'data-loss' | 'unauthenticated'; - -// @beta -export class FirestoreFunction { - constructor(name: string, params: Constant[]); - add(other: Constant): Add; - add(other: any): Add; - arrayConcat(arrays: Constant[]): ArrayConcat; - arrayConcat(arrays: any[]): ArrayConcat; - arrayContains(element: Constant): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Constant[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Constant[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; - ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Constant): CosineDistance; - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; - descending(): Ordering; - divide(other: Constant): Divide; - divide(other: any): Divide; - dotProduct(other: Constant): DotProduct; - dotProduct(other: VectorValue): DotProduct; - // (undocumented) - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Constant): EndsWith; - eq(other: Constant): Eq; - eq(other: any): Eq; - euclideanDistance(other: Constant): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; - // (undocumented) - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; - // (undocumented) - exprType: ExprType; - gt(other: Constant): Gt; - gt(other: any): Gt; - gte(other: Constant): Gte; - gte(other: any): Gte; - in(...others: Constant[]): In; - // (undocumented) - in(...others: any[]): In; - isNaN(): IsNan; - like(pattern: string): Like; - // (undocumented) - like(pattern: Constant): Like; - logicalMax(other: Constant): LogicalMax; - logicalMax(other: any): LogicalMax; - logicalMin(other: Constant): LogicalMin; - logicalMin(other: any): LogicalMin; - lt(other: Constant): Lt; - lt(other: any): Lt; - lte(other: Constant): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - max(): Max; - min(): Min; - mod(other: Constant): Mod; - mod(other: any): Mod; - multiply(other: Constant): Multiply; - multiply(other: any): Multiply; - neq(other: Constant): Neq; - neq(other: any): Neq; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Constant): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Constant): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Constant, replace: Constant): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Constant, replace: Constant): ReplaceFirst; - reverse(): Reverse; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Constant): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Constant): StrContains; - subtract(other: Constant): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Constant, amount: Constant): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Constant, amount: Constant): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; - vectorLength(): VectorLength; -} - -// @beta -export function genericFunction(name: string, params: Constant[]): FirestoreFunction; - -// @beta (undocumented) -export class GenericStage implements Stage { - constructor(name: string, params: unknown[]); - // (undocumented) - name: string; -} - -// @public -export class GeoPoint { - constructor(latitude: number, longitude: number); - isEqual(other: GeoPoint): boolean; - get latitude(): number; - get longitude(): number; - toJSON(): { - latitude: number; - longitude: number; - }; -} - -// @public -export function getAggregate(query: Query, aggregateSpec: AggregateSpecType): Promise>; - -// @public -export function getCount(query: Query): Promise; -}, AppModelType, DbModelType>>; - -// @public -export function getDoc(reference: DocumentReference): Promise>; - -// @public -export function getDocs(query: Query): Promise>; - -// @public -export function getFirestore(): Firestore; - -// @public -export function getFirestore(app: FirebaseApp): Firestore; - -// @beta -export function getFirestore(databaseId: string): Firestore; - -// @beta -export function getFirestore(app: FirebaseApp, databaseId: string): Firestore; - -// @beta (undocumented) -export class Gt extends FirestoreFunction implements FilterCondition { - constructor(left: Constant, right: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function gt(left: Constant, right: Constant): Gt; - -// @beta -export function gt(left: Constant, right: any): Gt; - -// @beta -export function gt(left: string, right: Constant): Gt; - -// @beta -export function gt(left: string, right: any): Gt; - -// @beta (undocumented) -export class Gte extends FirestoreFunction implements FilterCondition { - constructor(left: Constant, right: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function gte(left: Constant, right: Constant): Gte; - -// @beta -export function gte(left: Constant, right: any): Gte; - -// @beta -export function gte(left: string, right: Constant): Gte; - -// @beta -export function gte(left: string, right: any): Gte; - -// @beta (undocumented) -export class If extends FirestoreFunction implements FilterCondition { - constructor(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function ifFunction(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant): If; - -// @beta (undocumented) -export class In extends FirestoreFunction implements FilterCondition { - constructor(left: Constant, others: Constant[]); - // (undocumented) - filterable: true; - } - -// @beta -export function inAny(element: Constant, others: Constant[]): In; - -// @beta -export function inAny(element: Constant, others: any[]): In; - -// @beta -export function inAny(element: string, others: Constant[]): In; - -// @beta -export function inAny(element: string, others: any[]): In; - -// @public -export function increment(n: number): FieldValue; - -// @public -export function initializeFirestore(app: FirebaseApp, settings: Settings): Firestore; - -// @beta -export function initializeFirestore(app: FirebaseApp, settings: Settings, databaseId?: string): Firestore; - -// @beta (undocumented) -export class IsNan extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant); - // (undocumented) - filterable: true; -} - -// @beta -export function isNan(value: Constant): IsNan; - -// @beta -export function isNan(value: string): IsNan; - -// @beta (undocumented) -export class Like extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant, pattern: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function like(left: string, pattern: string): Like; - -// @beta -export function like(left: string, pattern: Constant): Like; - -// @beta -export function like(left: Constant, pattern: string): Like; - -// @beta -export function like(left: Constant, pattern: Constant): Like; - -// @beta (undocumented) -export class Limit implements Stage { - constructor(limit: number); - // (undocumented) - name: string; -} - -// @public -export function limit(limit: number): QueryLimitConstraint; - -// @public -export function limitToLast(limit: number): QueryLimitConstraint; - -// @beta (undocumented) -export class LogicalMax extends FirestoreFunction { - constructor(left: Constant, right: Constant); - } - -// @beta -export function logicalMax(left: Constant, right: Constant): LogicalMax; - -// @beta -export function logicalMax(left: Constant, right: any): LogicalMax; - -// @beta -export function logicalMax(left: string, right: Constant): LogicalMax; - -// @beta -export function logicalMax(left: string, right: any): LogicalMax; - -// @beta (undocumented) -export class LogicalMin extends FirestoreFunction { - constructor(left: Constant, right: Constant); - } - -// @beta -export function logicalMin(left: Constant, right: Constant): LogicalMin; - -// @beta -export function logicalMin(left: Constant, right: any): LogicalMin; - -// @beta -export function logicalMin(left: string, right: Constant): LogicalMin; - -// @beta -export function logicalMin(left: string, right: any): LogicalMin; - -export { LogLevel } - -// @beta (undocumented) -export class Lt extends FirestoreFunction implements FilterCondition { - constructor(left: Constant, right: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function lt(left: Constant, right: Constant): Lt; - -// @beta -export function lt(left: Constant, right: any): Lt; - -// @beta -export function lt(left: string, right: Constant): Lt; - -// @beta -export function lt(left: string, right: any): Lt; - -// @beta (undocumented) -export class Lte extends FirestoreFunction implements FilterCondition { - constructor(left: Constant, right: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function lte(left: Constant, right: Constant): Lte; - -// @beta -export function lte(left: Constant, right: any): Lte; - -// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Constant" which is marked as @beta -// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Lte" which is marked as @beta -// -// @public -export function lte(left: string, right: Constant): Lte; - -// @beta -export function lte(left: string, right: any): Lte; - -// @beta (undocumented) -export class MapGet extends FirestoreFunction { - constructor(map: Constant, name: string); -} - -// @beta -export function mapGet(mapField: string, subField: string): MapGet; - -// @beta -export function mapGet(mapExpr: Constant, subField: string): MapGet; - -// @beta (undocumented) -export class Max extends FirestoreFunction implements Accumulator { - constructor(value: Constant, distinct: boolean); - // (undocumented) - accumulator: true; - } - -// @beta -export function max(value: Constant): Max; - -// @beta -export function max(value: string): Max; - -// @beta (undocumented) -export class Min extends FirestoreFunction implements Accumulator { - constructor(value: Constant, distinct: boolean); - // (undocumented) - accumulator: true; - } - -// @beta -export function min(value: Constant): Min; +} -// @beta -export function min(value: string): Min; +// @public +export type FirestoreErrorCode = 'cancelled' | 'unknown' | 'invalid-argument' | 'deadline-exceeded' | 'not-found' | 'already-exists' | 'permission-denied' | 'resource-exhausted' | 'failed-precondition' | 'aborted' | 'out-of-range' | 'unimplemented' | 'internal' | 'unavailable' | 'data-loss' | 'unauthenticated'; -// @beta (undocumented) -export class Mod extends FirestoreFunction { - constructor(left: Constant, right: Constant); - } +// @public +export class GeoPoint { + constructor(latitude: number, longitude: number); + static fromJSON(json: object): GeoPoint; + isEqual(other: GeoPoint): boolean; + get latitude(): number; + get longitude(): number; + toJSON(): { + latitude: number; + longitude: number; + type: string; + }; +} -// @beta -export function mod(left: Constant, right: Constant): Mod; +// @public +export function getAggregate(query: Query, aggregateSpec: AggregateSpecType): Promise>; -// @beta -export function mod(left: Constant, right: any): Mod; +// @public +export function getCount(query: Query): Promise; +}, AppModelType, DbModelType>>; -// @beta -export function mod(left: string, right: Constant): Mod; +// @public +export function getDoc(reference: DocumentReference): Promise>; -// @beta -export function mod(left: string, right: any): Mod; +// @public +export function getDocs(query: Query): Promise>; -// @beta (undocumented) -export class Multiply extends FirestoreFunction { - constructor(left: Constant, right: Constant); - } +// @public +export function getFirestore(): Firestore; -// @beta -export function multiply(left: Constant, right: Constant): Multiply; +// @public +export function getFirestore(app: FirebaseApp): Firestore; // @beta -export function multiply(left: Constant, right: any): Multiply; +export function getFirestore(databaseId: string): Firestore; // @beta -export function multiply(left: string, right: Constant): Multiply; +export function getFirestore(app: FirebaseApp, databaseId: string): Firestore; -// @beta -export function multiply(left: string, right: any): Multiply; +// @public +export function increment(n: number): FieldValue; -// @beta (undocumented) -export class Neq extends FirestoreFunction implements FilterCondition { - constructor(left: Constant, right: Constant); - // (undocumented) - filterable: true; - } +// @public +export function initializeFirestore(app: FirebaseApp, settings: Settings): Firestore; // @beta -export function neq(left: Constant, right: Constant): Neq; +export function initializeFirestore(app: FirebaseApp, settings: Settings, databaseId?: string): Firestore; -// @beta -export function neq(left: Constant, right: any): Neq; +// @public +export function limit(limit: number): QueryLimitConstraint; -// @beta -export function neq(left: string, right: Constant): Neq; +// @public +export function limitToLast(limit: number): QueryLimitConstraint; -// @beta -export function neq(left: string, right: any): Neq; +export { LogLevel } // @public export type NestedUpdateFields> = UnionToIntersection<{ [K in keyof T & string]: ChildUpdateFields; }[keyof T & string]>; -// @beta (undocumented) -export class Not extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant); - // (undocumented) - filterable: true; -} - -// @beta -export function not(filter: FilterExpr): Not; - -// @beta -export function notInAny(element: Constant, others: Constant[]): Not; - -// @beta -export function notInAny(element: Constant, others: any[]): Not; - -// @beta -export function notInAny(element: string, others: Constant[]): Not; - -// @beta -export function notInAny(element: string, others: any[]): Not; - -// @beta (undocumented) -export class Offset implements Stage { - constructor(offset: number); - // (undocumented) - name: string; - } - -// @beta (undocumented) -export class Or extends FirestoreFunction implements FilterCondition { - constructor(conditions: FilterExpr[]); - // (undocumented) - filterable: true; -} - // @public export function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; @@ -1526,109 +278,11 @@ export function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDir // @public export type OrderByDirection = 'desc' | 'asc'; -// @beta -export class Ordering { - constructor(expr: Constant, direction: 'ascending' | 'descending'); - } - // @public export type PartialWithFieldValue = Partial | (T extends Primitive ? T : T extends {} ? { [K in keyof T]?: PartialWithFieldValue | FieldValue; } : never); -// @public -export class Pipeline { - /* Excluded from this release type: _db */ - // Warning: (ae-incompatible-release-tags) The symbol "addFields" is marked as @public, but its signature references "Selectable" which is marked as @beta - addFields(...fields: Selectable[]): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ - // Warning: (ae-incompatible-release-tags) The symbol "aggregate" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta - aggregate(...accumulators: AccumulatorTarget[]): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ - aggregate(options: { - accumulators: AccumulatorTarget[]; - groups?: Array; - }): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ - // Warning: (ae-incompatible-release-tags) The symbol "distinct" is marked as @public, but its signature references "Selectable" which is marked as @beta - distinct(...groups: Array): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ - // Warning: (ae-incompatible-release-tags) The symbol "execute" is marked as @public, but its signature references "PipelineResult" which is marked as @beta - execute(): Promise>>; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ - // Warning: (ae-incompatible-release-tags) The symbol "findNearest" is marked as @public, but its signature references "FindNearestOptions" which is marked as @beta - // - // (undocumented) - findNearest(options: FindNearestOptions): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ - genericStage(name: string, params: any[]): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ - limit(limit: number): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ - offset(offset: number): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ - // Warning: (ae-incompatible-release-tags) The symbol "select" is marked as @public, but its signature references "Selectable" which is marked as @beta - select(...selections: Array): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ - // Warning: (ae-incompatible-release-tags) The symbol "sort" is marked as @public, but its signature references "Ordering" which is marked as @beta - sort(...orderings: Ordering[]): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ - // (undocumented) - sort(options: { - orderings: Ordering[]; - }): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ - // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "FilterCondition" which is marked as @beta - // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "Constant" which is marked as @beta - where(condition: FilterCondition & Constant): Pipeline; -} - -// Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta -// -// @public -export function pipeline(firestore: Firestore): PipelineSource; - -// @public -export function pipeline(query: Query): Pipeline; - -// @beta -export class PipelineResult { - /* Excluded from this release type: _ref */ - /* Excluded from this release type: _fields */ - /* Excluded from this release type: __constructor */ - get createTime(): Timestamp | undefined; - data(): AppModelType | undefined; - get executionTime(): Timestamp; - get(fieldPath: string | FieldPath): any; - get id(): string | undefined; - get ref(): DocumentReference | undefined; - get updateTime(): Timestamp | undefined; -} - -// @beta -export class PipelineSource { - // (undocumented) - collection(collectionPath: string): Pipeline; - // (undocumented) - collectionGroup(collectionId: string): Pipeline; - // (undocumented) - database(): Pipeline; - // (undocumented) - documents(docs: DocumentReference[]): Pipeline; - } - // @public export type Primitive = string | number | boolean | undefined | null; @@ -1637,7 +291,6 @@ export class Query | null; readonly firestore: Firestore; - pipeline(): Pipeline; readonly type: 'query' | 'collection'; withConverter(converter: null): Query; withConverter(converter: FirestoreDataConverter): Query; @@ -1714,102 +367,9 @@ export class QueryStartAtConstraint extends QueryConstraint { // @public export function refEqual(left: DocumentReference | CollectionReference, right: DocumentReference | CollectionReference): boolean; -// @beta (undocumented) -export class RegexContains extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant, pattern: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function regexContains(left: string, pattern: string): RegexContains; - -// @beta -export function regexContains(left: string, pattern: Constant): RegexContains; - -// @beta -export function regexContains(left: Constant, pattern: string): RegexContains; - -// @beta -export function regexContains(left: Constant, pattern: Constant): RegexContains; - -// @beta (undocumented) -export class RegexMatch extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant, pattern: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function regexMatch(left: string, pattern: string): RegexMatch; - -// @beta -export function regexMatch(left: string, pattern: Constant): RegexMatch; - -// @beta -export function regexMatch(left: Constant, pattern: string): RegexMatch; - -// @beta -export function regexMatch(left: Constant, pattern: Constant): RegexMatch; - -// @beta (undocumented) -export class ReplaceAll extends FirestoreFunction { - constructor(value: Constant, find: Constant, replace: Constant); - } - -// @beta -export function replaceAll(value: Constant, find: string, replace: string): ReplaceAll; - -// @beta -export function replaceAll(value: Constant, find: Constant, replace: Constant): ReplaceAll; - -// @beta -export function replaceAll(field: string, find: string, replace: string): ReplaceAll; - -// @beta (undocumented) -export class ReplaceFirst extends FirestoreFunction { - constructor(value: Constant, find: Constant, replace: Constant); - } - -// @beta -export function replaceFirst(value: Constant, find: string, replace: string): ReplaceFirst; - -// @beta -export function replaceFirst(value: Constant, find: Constant, replace: Constant): ReplaceFirst; - -// @beta -export function replaceFirst(field: string, find: string, replace: string): ReplaceFirst; - -// @beta (undocumented) -export class Reverse extends FirestoreFunction { - constructor(value: Constant); - } - -// @beta -export function reverse(expr: Constant): Reverse; - -// @beta -export function reverse(field: string): Reverse; - // @public export function runTransaction(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise, options?: TransactionOptions): Promise; -// @beta (undocumented) -export class Select implements Stage { - constructor(projections: Map); - // (undocumented) - name: string; - } - -// @beta -export interface Selectable { - // (undocumented) - selectable: true; -} - -// @beta -export type SelectableExpr = Constant & Selectable; - // @public export function serverTimestamp(): FieldValue; @@ -1839,19 +399,6 @@ export interface Settings { // @public export function snapshotEqual(left: DocumentSnapshot | QuerySnapshot, right: DocumentSnapshot | QuerySnapshot): boolean; -// @beta (undocumented) -export class Sort implements Stage { - constructor(orders: Ordering[]); - // (undocumented) - name: string; - } - -// @beta (undocumented) -export interface Stage { - // (undocumented) - name: string; -} - // @public export function startAfter(snapshot: DocumentSnapshot): QueryStartAtConstraint; @@ -1864,79 +411,6 @@ export function startAt(snapshot // @public export function startAt(...fieldValues: unknown[]): QueryStartAtConstraint; -// @beta (undocumented) -export class StartsWith extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant, prefix: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function startsWith(expr: string, prefix: string): StartsWith; - -// @beta -export function startsWith(expr: string, prefix: Constant): StartsWith; - -// @beta -export function startsWith(expr: Constant, prefix: string): StartsWith; - -// @beta -export function startsWith(expr: Constant, prefix: Constant): StartsWith; - -// @beta (undocumented) -export class StrConcat extends FirestoreFunction { - constructor(first: Constant, rest: Constant[]); - } - -// @beta -export function strConcat(first: string, ...elements: Array): StrConcat; - -// @beta -export function strConcat(first: Constant, ...elements: Array): StrConcat; - -// @beta (undocumented) -export class StrContains extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant, substring: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function strContains(left: string, substring: string): StrContains; - -// @beta -export function strContains(left: string, substring: Constant): StrContains; - -// @beta -export function strContains(left: Constant, substring: string): StrContains; - -// @beta -export function strContains(left: Constant, substring: Constant): StrContains; - -// @beta (undocumented) -export class Subtract extends FirestoreFunction { - constructor(left: Constant, right: Constant); - } - -// @beta -export function subtract(left: Constant, right: Constant): Subtract; - -// @beta -export function subtract(left: Constant, right: any): Subtract; - -// @beta -export function subtract(left: string, right: Constant): Subtract; - -// @beta -export function subtract(left: string, right: any): Subtract; - -// @beta (undocumented) -export class Sum extends FirestoreFunction implements Accumulator { - constructor(value: Constant, distinct: boolean); - // (undocumented) - accumulator: true; - } - // @public export function sum(field: string | FieldPath): AggregateField; @@ -1949,6 +423,7 @@ export class Timestamp { seconds: number, nanoseconds: number); static fromDate(date: Date): Timestamp; + static fromJSON(json: object): Timestamp; static fromMillis(milliseconds: number): Timestamp; isEqual(other: Timestamp): boolean; readonly nanoseconds: number; @@ -1958,95 +433,13 @@ export class Timestamp { toJSON(): { seconds: number; nanoseconds: number; + type: string; }; toMillis(): number; toString(): string; valueOf(): string; } -// @beta (undocumented) -export class TimestampAdd extends FirestoreFunction { - constructor(timestamp: Constant, unit: Constant, amount: Constant); - } - -// @beta -export function timestampAdd(timestamp: Constant, unit: Constant, amount: Constant): TimestampAdd; - -// @beta -export function timestampAdd(timestamp: Constant, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - -// @beta -export function timestampAdd(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - -// @beta (undocumented) -export class TimestampSub extends FirestoreFunction { - constructor(timestamp: Constant, unit: Constant, amount: Constant); - } - -// @beta -export function timestampSub(timestamp: Constant, unit: Constant, amount: Constant): TimestampSub; - -// @beta -export function timestampSub(timestamp: Constant, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - -// @beta -export function timestampSub(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - -// @beta (undocumented) -export class TimestampToUnixMicros extends FirestoreFunction { - constructor(input: Constant); - } - -// @beta -export function timestampToUnixMicros(expr: Constant): TimestampToUnixMicros; - -// @beta -export function timestampToUnixMicros(field: string): TimestampToUnixMicros; - -// @beta (undocumented) -export class TimestampToUnixMillis extends FirestoreFunction { - constructor(input: Constant); - } - -// @beta -export function timestampToUnixMillis(expr: Constant): TimestampToUnixMillis; - -// @beta -export function timestampToUnixMillis(field: string): TimestampToUnixMillis; - -// @beta (undocumented) -export class TimestampToUnixSeconds extends FirestoreFunction { - constructor(input: Constant); - } - -// @beta -export function timestampToUnixSeconds(expr: Constant): TimestampToUnixSeconds; - -// @beta -export function timestampToUnixSeconds(field: string): TimestampToUnixSeconds; - -// @beta (undocumented) -export class ToLower extends FirestoreFunction { - constructor(expr: Constant); - } - -// @beta -export function toLower(expr: string): ToLower; - -// @beta -export function toLower(expr: Constant): ToLower; - -// @beta (undocumented) -export class ToUpper extends FirestoreFunction { - constructor(expr: Constant); - } - -// @beta -export function toUpper(expr: string): ToUpper; - -// @beta -export function toUpper(expr: Constant): ToUpper; - // @public export class Transaction { delete(documentRef: DocumentReference): this; @@ -2062,53 +455,9 @@ export interface TransactionOptions { readonly maxAttempts?: number; } -// @beta (undocumented) -export class Trim extends FirestoreFunction { - constructor(expr: Constant); - } - -// @beta -export function trim(expr: string): Trim; - -// @beta -export function trim(expr: Constant): Trim; - // @public export type UnionToIntersection = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never; -// @beta (undocumented) -export class UnixMicrosToTimestamp extends FirestoreFunction { - constructor(input: Constant); - } - -// @beta -export function unixMicrosToTimestamp(expr: Constant): UnixMicrosToTimestamp; - -// @beta -export function unixMicrosToTimestamp(field: string): UnixMicrosToTimestamp; - -// @beta (undocumented) -export class UnixMillisToTimestamp extends FirestoreFunction { - constructor(input: Constant); - } - -// @beta -export function unixMillisToTimestamp(expr: Constant): UnixMillisToTimestamp; - -// @beta -export function unixMillisToTimestamp(field: string): UnixMillisToTimestamp; - -// @beta (undocumented) -export class UnixSecondsToTimestamp extends FirestoreFunction { - constructor(input: Constant); - } - -// @beta -export function unixSecondsToTimestamp(expr: Constant): UnixSecondsToTimestamp; - -// @beta -export function unixSecondsToTimestamp(field: string): UnixSecondsToTimestamp; - // @public export type UpdateData = T extends Primitive ? T : T extends {} ? { [K in keyof T]?: UpdateData | FieldValue; @@ -2120,35 +469,16 @@ export function updateDoc(refere // @public export function updateDoc(reference: DocumentReference, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise; -// @public -export function useFirestorePipelines(): void; - // @public export function vector(values?: number[]): VectorValue; -// @beta (undocumented) -export class VectorLength extends FirestoreFunction { - constructor(value: Constant); - } - -// @beta -export function vectorLength(expr: Constant): VectorLength; - -// @beta -export function vectorLength(field: string): VectorLength; - // @public export class VectorValue { /* Excluded from this release type: __constructor */ + static fromJSON(json: object): VectorValue; isEqual(other: VectorValue): boolean; toArray(): number[]; -} - -// @beta (undocumented) -export class Where implements Stage { - constructor(condition: FilterCondition & Constant); - // (undocumented) - name: string; + toJSON(): object; } // @public @@ -2175,21 +505,5 @@ export class WriteBatch { // @public export function writeBatch(firestore: Firestore): WriteBatch; -// @beta (undocumented) -export class Xor extends FirestoreFunction implements FilterCondition { - constructor(conditions: FilterExpr[]); - // (undocumented) - filterable: true; -} - -// @beta -export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; - - -// Warnings were encountered during analysis: -// -// /home/runner/work/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9177: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/packages/firestore/dist/lite/index.d.ts:9178: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/packages/firestore/dist/lite/index.d.ts:9207: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 212d93972b2..292d81d7a75 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -9,54 +9,14 @@ import { FirebaseApp } from '@firebase/app'; import { FirebaseError } from '@firebase/util'; import { LogLevelString as LogLevel } from '@firebase/logger'; -// @beta -export interface Accumulator { - // (undocumented) - accumulator: true; -} - -// @beta -export type AccumulatorTarget = ExprWithAlias; - -// @beta (undocumented) -export class Add extends FirestoreFunction { - constructor(left: Constant, right: Constant); - } - -// @beta -export function add(left: Constant, right: Constant): Add; - -// @beta -export function add(left: Constant, right: any): Add; - -// @beta -export function add(left: string, right: Constant): Add; - -// @beta -export function add(left: string, right: any): Add; - // @public export function addDoc(reference: CollectionReference, data: WithFieldValue): Promise>; -// @beta (undocumented) -export class AddFields implements Stage { - constructor(fields: Map); - // (undocumented) - name: string; -} - // @public export type AddPrefixToKeys> = { [K in keyof T & string as `${Prefix}.${K}`]+?: string extends K ? any : T[K]; }; -// @beta (undocumented) -export class Aggregate implements Stage { - constructor(accumulators: Map, groups: Map); - // (undocumented) - name: string; -} - // @public export class AggregateField { readonly aggregateType: AggregateType; @@ -93,153 +53,26 @@ export type AggregateSpecData = { // @public export type AggregateType = 'count' | 'avg' | 'sum'; -// @beta (undocumented) -export class And extends FirestoreFunction implements FilterCondition { - constructor(conditions: FilterExpr[]); - // (undocumented) - filterable: true; -} - // @public export function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; -// @beta -export function andFunction(left: FilterExpr, ...right: FilterExpr[]): And; - -// @beta (undocumented) -export class ArrayConcat extends FirestoreFunction { - constructor(array: Constant, elements: Constant[]); - } - -// @beta -export function arrayConcat(array: Constant, elements: Constant[]): ArrayConcat; - -// @beta -export function arrayConcat(array: Constant, elements: any[]): ArrayConcat; - -// @beta -export function arrayConcat(array: string, elements: Constant[]): ArrayConcat; - -// @beta -export function arrayConcat(array: string, elements: any[]): ArrayConcat; - -// @beta (undocumented) -export class ArrayContains extends FirestoreFunction implements FilterCondition { - constructor(array: Constant, element: Constant); - // (undocumented) - filterable: true; -} - -// @beta -export function arrayContains(array: Constant, element: Constant): ArrayContains; - -// @beta -export function arrayContains(array: Constant, element: any): ArrayContains; - -// @beta -export function arrayContains(array: string, element: Constant): ArrayContains; - -// @beta -export function arrayContains(array: string, element: any): ArrayContains; - -// @beta (undocumented) -export class ArrayContainsAll extends FirestoreFunction implements FilterCondition { - constructor(array: Constant, values: Constant[]); - // (undocumented) - filterable: true; - } - -// @beta -export function arrayContainsAll(array: Constant, values: Constant[]): ArrayContainsAll; - -// @beta -export function arrayContainsAll(array: Constant, values: any[]): ArrayContainsAll; - -// @beta -export function arrayContainsAll(array: string, values: Constant[]): ArrayContainsAll; - -// @beta -export function arrayContainsAll(array: string, values: any[]): ArrayContainsAll; - -// @beta (undocumented) -export class ArrayContainsAny extends FirestoreFunction implements FilterCondition { - constructor(array: Constant, values: Constant[]); - // (undocumented) - filterable: true; - } - -// @beta -export function arrayContainsAny(array: Constant, values: Constant[]): ArrayContainsAny; - -// @beta -export function arrayContainsAny(array: Constant, values: any[]): ArrayContainsAny; - -// @beta -export function arrayContainsAny(array: string, values: Constant[]): ArrayContainsAny; - -// @beta -export function arrayContainsAny(array: string, values: any[]): ArrayContainsAny; - -// @beta (undocumented) -export class ArrayElement extends FirestoreFunction { - constructor(); -} - -// @beta (undocumented) -export class ArrayLength extends FirestoreFunction { - constructor(array: Constant); - } - -// @beta -export function arrayLength(array: Constant): ArrayLength; - // @public export function arrayRemove(...elements: unknown[]): FieldValue; -// @beta (undocumented) -export class ArrayReverse extends FirestoreFunction { - constructor(array: Constant); - } - // @public export function arrayUnion(...elements: unknown[]): FieldValue; -// @beta -export function ascending(expr: Constant): Ordering; - // @public export function average(field: string | FieldPath): AggregateField; -// @beta (undocumented) -export class Avg extends FirestoreFunction implements Accumulator { - constructor(value: Constant, distinct: boolean); - // (undocumented) - accumulator: true; - } - -// @beta -export function avgFunction(value: Constant): Avg; - -// @beta -export function avgFunction(value: string): Avg; - -// @beta (undocumented) -export class ByteLength extends FirestoreFunction { - constructor(value: Constant); - } - -// @beta -export function byteLength(expr: Constant): ByteLength; - -// @beta -export function byteLength(field: string): ByteLength; - // @public export class Bytes { static fromBase64String(base64: string): Bytes; + static fromJSON(json: object): Bytes; static fromUint8Array(array: Uint8Array): Bytes; isEqual(other: Bytes): boolean; toBase64(): string; + toJSON(): object; toString(): string; toUint8Array(): Uint8Array; } @@ -247,17 +80,6 @@ export class Bytes { // @public export const CACHE_SIZE_UNLIMITED = -1; -// @beta (undocumented) -export class CharLength extends FirestoreFunction { - constructor(value: Constant); - } - -// @beta -export function charLength(field: string): CharLength; - -// @beta -export function charLength(expr: Constant): CharLength; - // @public export type ChildUpdateFields = V extends Record ? AddPrefixToKeys> : never; @@ -276,13 +98,6 @@ export function collection(refer // @public export function collectionGroup(firestore: Firestore, collectionId: string): Query; -// @beta (undocumented) -export class CollectionGroupSource implements Stage { - constructor(collectionId: string); - // (undocumented) - name: string; -} - // @public export class CollectionReference extends Query { get id(): string; @@ -293,183 +108,14 @@ export class CollectionReference; } -// @beta (undocumented) -export class CollectionSource implements Stage { - constructor(collectionPath: string); - // (undocumented) - name: string; -} - // @public export function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: { mockUserToken?: EmulatorMockTokenOptions | string; }): void; -// @beta -export class Constant { - add(other: Constant): Add; - add(other: any): Add; - arrayConcat(arrays: Constant[]): ArrayConcat; - arrayConcat(arrays: any[]): ArrayConcat; - arrayContains(element: Constant): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Constant[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Constant[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; - ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Constant): CosineDistance; - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; - descending(): Ordering; - divide(other: Constant): Divide; - divide(other: any): Divide; - dotProduct(other: Constant): DotProduct; - dotProduct(other: VectorValue): DotProduct; - // (undocumented) - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Constant): EndsWith; - eq(other: Constant): Eq; - eq(other: any): Eq; - euclideanDistance(other: Constant): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; - // (undocumented) - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; - // (undocumented) - exprType: ExprType; - gt(other: Constant): Gt; - gt(other: any): Gt; - gte(other: Constant): Gte; - gte(other: any): Gte; - in(...others: Constant[]): In; - // (undocumented) - in(...others: any[]): In; - isNaN(): IsNan; - like(pattern: string): Like; - // (undocumented) - like(pattern: Constant): Like; - logicalMax(other: Constant): LogicalMax; - logicalMax(other: any): LogicalMax; - logicalMin(other: Constant): LogicalMin; - logicalMin(other: any): LogicalMin; - lt(other: Constant): Lt; - lt(other: any): Lt; - lte(other: Constant): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - max(): Max; - min(): Min; - mod(other: Constant): Mod; - mod(other: any): Mod; - multiply(other: Constant): Multiply; - multiply(other: any): Multiply; - neq(other: Constant): Neq; - neq(other: any): Neq; - static of(value: number): 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: DocumentReference): Constant; - static of(value: any[]): Constant; - static of(value: Map): Constant; - static of(value: VectorValue): Constant; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Constant): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Constant): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Constant, replace: Constant): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Constant, replace: Constant): ReplaceFirst; - reverse(): Reverse; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Constant): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Constant): StrContains; - subtract(other: Constant): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Constant, amount: Constant): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Constant, amount: Constant): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; - static vector(value: number[] | VectorValue): Constant; - vectorLength(): VectorLength; -} - -// @beta (undocumented) -export class CosineDistance extends FirestoreFunction { - constructor(vector1: Constant, vector2: Constant); - } - -// @beta -export function cosineDistance(expr: string, other: number[]): CosineDistance; - -// @beta -export function cosineDistance(expr: string, other: VectorValue): CosineDistance; - -// @beta -export function cosineDistance(expr: string, other: Constant): CosineDistance; - -// @beta -export function cosineDistance(expr: Constant, other: number[]): CosineDistance; - -// @beta -export function cosineDistance(expr: Constant, other: VectorValue): CosineDistance; - -// @beta -export function cosineDistance(expr: Constant, other: Constant): CosineDistance; - -// @beta (undocumented) -export class Count extends FirestoreFunction implements Accumulator { - constructor(value: Constant | undefined, distinct: boolean); - // (undocumented) - accumulator: true; - } - // @public export function count(): AggregateField; -// @beta -export function countAll(): Count; - -// @beta -export function countFunction(value: Constant): Count; - -// Warning: (ae-incompatible-release-tags) The symbol "countFunction" is marked as @public, but its signature references "Count" which is marked as @beta -// -// @public -export function countFunction(value: string): Count; - -// @beta (undocumented) -export class DatabaseSource implements Stage { - // (undocumented) - name: string; -} - // @public export function deleteAllPersistentCacheIndexes(indexManager: PersistentCacheIndexManager): void; @@ -479,39 +125,12 @@ export function deleteDoc(refere // @public export function deleteField(): FieldValue; -// @beta -export function descending(expr: Constant): Ordering; - // @public export function disableNetwork(firestore: Firestore): Promise; // @public export function disablePersistentCacheIndexAutoCreation(indexManager: PersistentCacheIndexManager): void; -// @beta (undocumented) -export class Distinct implements Stage { - constructor(groups: Map); - // (undocumented) - name: string; -} - -// @beta (undocumented) -export class Divide extends FirestoreFunction { - constructor(left: Constant, right: Constant); - } - -// @beta -export function divide(left: Constant, right: Constant): Divide; - -// @beta -export function divide(left: Constant, right: any): Divide; - -// @beta -export function divide(left: string, right: Constant): Divide; - -// @beta -export function divide(left: string, right: any): Divide; - // @public export function doc(firestore: Firestore, path: string, ...pathSegments: string[]): DocumentReference; @@ -544,9 +163,12 @@ export function documentId(): FieldPath; export class DocumentReference { readonly converter: FirestoreDataConverter | null; readonly firestore: Firestore; + static fromJSON(firestore: Firestore, json: object): DocumentReference; + static fromJSON(firestore: Firestore, json: object, converter: FirestoreDataConverter): DocumentReference; get id(): string; get parent(): CollectionReference; get path(): string; + toJSON(): object; readonly type = "document"; withConverter(converter: FirestoreDataConverter): DocumentReference; withConverter(converter: null): DocumentReference; @@ -561,39 +183,14 @@ export class DocumentSnapshot; + toJSON(): object; } -// @beta (undocumented) -export class DocumentsSource implements Stage { - constructor(docPaths: string[]); - // (undocumented) - name: string; - // (undocumented) - static of(refs: DocumentReference[]): DocumentsSource; -} - -// @beta (undocumented) -export class DotProduct extends FirestoreFunction { - constructor(vector1: Constant, vector2: Constant); - } - -// @beta -export function dotProduct(expr: string, other: number[]): DotProduct; - -// @beta -export function dotProduct(expr: string, other: VectorValue): DotProduct; - -// @beta -export function dotProduct(expr: string, other: Constant): DotProduct; - -// @beta -export function dotProduct(expr: Constant, other: number[]): DotProduct; - -// @beta -export function dotProduct(expr: Constant, other: VectorValue): DotProduct; +// @public +export function documentSnapshotFromJSON(db: Firestore, json: object): DocumentSnapshot; -// @beta -export function dotProduct(expr: Constant, other: Constant): DotProduct; +// @public +export function documentSnapshotFromJSON(db: Firestore, json: object, converter: FirestoreDataConverter): DocumentSnapshot; export { EmulatorMockTokenOptions } @@ -621,463 +218,25 @@ export function endBefore(snapsh // @public export function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint; -// @beta (undocumented) -export class EndsWith extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant, suffix: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function endsWith(expr: string, suffix: string): EndsWith; - -// @beta -export function endsWith(expr: string, suffix: Constant): EndsWith; - -// @beta -export function endsWith(expr: Constant, suffix: string): EndsWith; - -// @beta -export function endsWith(expr: Constant, suffix: Constant): EndsWith; - -// @beta (undocumented) -export class Eq extends FirestoreFunction implements FilterCondition { - constructor(left: Constant, right: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function eq(left: Constant, right: Constant): Eq; - -// @beta -export function eq(left: Constant, right: any): Eq; - -// @beta -export function eq(left: string, right: Constant): Eq; - -// @beta -export function eq(left: string, right: any): Eq; - -// @beta (undocumented) -export class EuclideanDistance extends FirestoreFunction { - constructor(vector1: Constant, vector2: Constant); - } - -// @beta -export function euclideanDistance(expr: string, other: number[]): EuclideanDistance; - -// @beta -export function euclideanDistance(expr: string, other: VectorValue): EuclideanDistance; - -// @beta -export function euclideanDistance(expr: string, other: Constant): EuclideanDistance; - -// @beta -export function euclideanDistance(expr: Constant, other: number[]): EuclideanDistance; - -// @beta -export function euclideanDistance(expr: Constant, other: VectorValue): EuclideanDistance; - -// @beta -export function euclideanDistance(expr: Constant, other: Constant): EuclideanDistance; - -// @beta -export function execute(pipeline: Pipeline): Promise>>; - -// @beta (undocumented) -export class Exists extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant); - // (undocumented) - filterable: true; -} - -// @beta -export function exists(value: Constant): Exists; - -// @beta -export function exists(field: string): Exists; - // @public export interface ExperimentalLongPollingOptions { timeoutSeconds?: number; } -// @beta -export type ExprType = 'Field' | 'Constant' | 'Function' | 'ListOfExprs' | 'ExprWithAlias'; - -// @beta (undocumented) -export class ExprWithAlias implements Selectable { - constructor(expr: T, alias: string); - add(other: Constant): Add; - add(other: any): Add; - // (undocumented) - alias: string; - arrayConcat(arrays: Constant[]): ArrayConcat; - arrayConcat(arrays: any[]): ArrayConcat; - arrayContains(element: Constant): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Constant[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Constant[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; - ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Constant): CosineDistance; - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; - descending(): Ordering; - divide(other: Constant): Divide; - divide(other: any): Divide; - dotProduct(other: Constant): DotProduct; - dotProduct(other: VectorValue): DotProduct; - // (undocumented) - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Constant): EndsWith; - eq(other: Constant): Eq; - eq(other: any): Eq; - euclideanDistance(other: Constant): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; - // (undocumented) - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; - // (undocumented) - expr: T; - // (undocumented) - exprType: ExprType; - gt(other: Constant): Gt; - gt(other: any): Gt; - gte(other: Constant): Gte; - gte(other: any): Gte; - in(...others: Constant[]): In; - // (undocumented) - in(...others: any[]): In; - isNaN(): IsNan; - like(pattern: string): Like; - // (undocumented) - like(pattern: Constant): Like; - logicalMax(other: Constant): LogicalMax; - logicalMax(other: any): LogicalMax; - logicalMin(other: Constant): LogicalMin; - logicalMin(other: any): LogicalMin; - lt(other: Constant): Lt; - lt(other: any): Lt; - lte(other: Constant): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - max(): Max; - min(): Min; - mod(other: Constant): Mod; - mod(other: any): Mod; - multiply(other: Constant): Multiply; - multiply(other: any): Multiply; - neq(other: Constant): Neq; - neq(other: any): Neq; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Constant): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Constant): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Constant, replace: Constant): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Constant, replace: Constant): ReplaceFirst; - reverse(): Reverse; - // (undocumented) - selectable: true; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Constant): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Constant): StrContains; - subtract(other: Constant): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Constant, amount: Constant): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Constant, amount: Constant): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; - vectorLength(): VectorLength; -} - -// @beta -export class Field implements Selectable { - add(other: Constant): Add; - add(other: any): Add; - arrayConcat(arrays: Constant[]): ArrayConcat; - arrayConcat(arrays: any[]): ArrayConcat; - arrayContains(element: Constant): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Constant[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Constant[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; - ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Constant): CosineDistance; - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; - descending(): Ordering; - divide(other: Constant): Divide; - divide(other: any): Divide; - dotProduct(other: Constant): DotProduct; - dotProduct(other: VectorValue): DotProduct; - // (undocumented) - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Constant): EndsWith; - eq(other: Constant): Eq; - eq(other: any): Eq; - euclideanDistance(other: Constant): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; - // (undocumented) - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; - // (undocumented) - exprType: ExprType; - // (undocumented) - fieldName(): string; - gt(other: Constant): Gt; - gt(other: any): Gt; - gte(other: Constant): Gte; - gte(other: any): Gte; - in(...others: Constant[]): In; - // (undocumented) - in(...others: any[]): In; - isNaN(): IsNan; - like(pattern: string): Like; - // (undocumented) - like(pattern: Constant): Like; - logicalMax(other: Constant): LogicalMax; - logicalMax(other: any): LogicalMax; - logicalMin(other: Constant): LogicalMin; - logicalMin(other: any): LogicalMin; - lt(other: Constant): Lt; - lt(other: any): Lt; - lte(other: Constant): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - max(): Max; - min(): Min; - mod(other: Constant): Mod; - mod(other: any): Mod; - multiply(other: Constant): Multiply; - multiply(other: any): Multiply; - neq(other: Constant): Neq; - neq(other: any): Neq; - static of(name: string): Field; - // (undocumented) - static of(path: FieldPath): Field; - // (undocumented) - static of(pipeline: Pipeline, name: string): Field; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Constant): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Constant): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Constant, replace: Constant): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Constant, replace: Constant): ReplaceFirst; - reverse(): Reverse; - // (undocumented) - selectable: true; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Constant): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Constant): StrContains; - subtract(other: Constant): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Constant, amount: Constant): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Constant, amount: Constant): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; - vectorLength(): VectorLength; -} - // @public export class FieldPath { constructor(...fieldNames: string[]); isEqual(other: FieldPath): boolean; } -// @beta (undocumented) -export class Fields implements Selectable { - add(other: Constant): Add; - add(other: any): Add; - arrayConcat(arrays: Constant[]): ArrayConcat; - arrayConcat(arrays: any[]): ArrayConcat; - arrayContains(element: Constant): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Constant[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Constant[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; - ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Constant): CosineDistance; - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; - descending(): Ordering; - divide(other: Constant): Divide; - divide(other: any): Divide; - dotProduct(other: Constant): DotProduct; - dotProduct(other: VectorValue): DotProduct; - // (undocumented) - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Constant): EndsWith; - eq(other: Constant): Eq; - eq(other: any): Eq; - euclideanDistance(other: Constant): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; - // (undocumented) - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; - // (undocumented) - exprType: ExprType; - // (undocumented) - fieldList(): Field[]; - gt(other: Constant): Gt; - gt(other: any): Gt; - gte(other: Constant): Gte; - gte(other: any): Gte; - in(...others: Constant[]): In; - // (undocumented) - in(...others: any[]): In; - isNaN(): IsNan; - like(pattern: string): Like; - // (undocumented) - like(pattern: Constant): Like; - logicalMax(other: Constant): LogicalMax; - logicalMax(other: any): LogicalMax; - logicalMin(other: Constant): LogicalMin; - logicalMin(other: any): LogicalMin; - lt(other: Constant): Lt; - lt(other: any): Lt; - lte(other: Constant): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - max(): Max; - min(): Min; - mod(other: Constant): Mod; - mod(other: any): Mod; - multiply(other: Constant): Multiply; - multiply(other: any): Multiply; - neq(other: Constant): Neq; - neq(other: any): Neq; - // (undocumented) - static of(name: string, ...others: string[]): Fields; - // (undocumented) - static ofAll(): Fields; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Constant): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Constant): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Constant, replace: Constant): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Constant, replace: Constant): ReplaceFirst; - reverse(): Reverse; - // (undocumented) - selectable: true; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Constant): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Constant): StrContains; - subtract(other: Constant): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Constant, amount: Constant): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Constant, amount: Constant): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; - vectorLength(): VectorLength; -} - // @public export abstract class FieldValue { abstract isEqual(other: FieldValue): boolean; } -// @beta -export interface FilterCondition { - // (undocumented) - filterable: true; -} - -// @beta -export type FilterExpr = Constant & FilterCondition; - -// @beta (undocumented) -export class FindNearest implements Stage { - // (undocumented) - name: string; -} - -// @beta (undocumented) -export interface FindNearestOptions { - // (undocumented) - distanceField?: string; - // (undocumented) - distanceMeasure: 'euclidean' | 'cosine' | 'dot_product'; - // (undocumented) - field: Field; - // (undocumented) - limit?: number; - // (undocumented) - vectorValue: VectorValue | number[]; -} - // @public export class Firestore { get app(): FirebaseApp; - // Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta - pipeline(): PipelineSource; toJSON(): object; type: 'firestore-lite' | 'firestore'; } @@ -1099,108 +258,6 @@ export class FirestoreError extends FirebaseError { // @public export type FirestoreErrorCode = 'cancelled' | 'unknown' | 'invalid-argument' | 'deadline-exceeded' | 'not-found' | 'already-exists' | 'permission-denied' | 'resource-exhausted' | 'failed-precondition' | 'aborted' | 'out-of-range' | 'unimplemented' | 'internal' | 'unavailable' | 'data-loss' | 'unauthenticated'; -// @beta -export class FirestoreFunction { - constructor(name: string, params: Constant[]); - add(other: Constant): Add; - add(other: any): Add; - arrayConcat(arrays: Constant[]): ArrayConcat; - arrayConcat(arrays: any[]): ArrayConcat; - arrayContains(element: Constant): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Constant[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Constant[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; - ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Constant): CosineDistance; - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; - descending(): Ordering; - divide(other: Constant): Divide; - divide(other: any): Divide; - dotProduct(other: Constant): DotProduct; - dotProduct(other: VectorValue): DotProduct; - // (undocumented) - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Constant): EndsWith; - eq(other: Constant): Eq; - eq(other: any): Eq; - euclideanDistance(other: Constant): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; - // (undocumented) - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; - // (undocumented) - exprType: ExprType; - gt(other: Constant): Gt; - gt(other: any): Gt; - gte(other: Constant): Gte; - gte(other: any): Gte; - in(...others: Constant[]): In; - // (undocumented) - in(...others: any[]): In; - isNaN(): IsNan; - like(pattern: string): Like; - // (undocumented) - like(pattern: Constant): Like; - logicalMax(other: Constant): LogicalMax; - logicalMax(other: any): LogicalMax; - logicalMin(other: Constant): LogicalMin; - logicalMin(other: any): LogicalMin; - lt(other: Constant): Lt; - lt(other: any): Lt; - lte(other: Constant): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - max(): Max; - min(): Min; - mod(other: Constant): Mod; - mod(other: any): Mod; - multiply(other: Constant): Multiply; - multiply(other: any): Multiply; - neq(other: Constant): Neq; - neq(other: any): Neq; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Constant): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Constant): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Constant, replace: Constant): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Constant, replace: Constant): ReplaceFirst; - reverse(): Reverse; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Constant): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Constant): StrContains; - subtract(other: Constant): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Constant, amount: Constant): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Constant, amount: Constant): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; - vectorLength(): VectorLength; -} - // @public export type FirestoreLocalCache = MemoryLocalCache | PersistentLocalCache; @@ -1216,25 +273,17 @@ export interface FirestoreSettings { ssl?: boolean; } -// @beta -export function genericFunction(name: string, params: Constant[]): FirestoreFunction; - -// @beta (undocumented) -export class GenericStage implements Stage { - constructor(name: string, params: unknown[]); - // (undocumented) - name: string; -} - // @public export class GeoPoint { constructor(latitude: number, longitude: number); + static fromJSON(json: object): GeoPoint; isEqual(other: GeoPoint): boolean; get latitude(): number; get longitude(): number; toJSON(): { latitude: number; longitude: number; + type: string; }; } @@ -1279,73 +328,6 @@ export function getFirestore(app: FirebaseApp, databaseId: string): Firestore; // @public export function getPersistentCacheIndexManager(firestore: Firestore): PersistentCacheIndexManager | null; -// @beta (undocumented) -export class Gt extends FirestoreFunction implements FilterCondition { - constructor(left: Constant, right: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function gt(left: Constant, right: Constant): Gt; - -// @beta -export function gt(left: Constant, right: any): Gt; - -// @beta -export function gt(left: string, right: Constant): Gt; - -// @beta -export function gt(left: string, right: any): Gt; - -// @beta (undocumented) -export class Gte extends FirestoreFunction implements FilterCondition { - constructor(left: Constant, right: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function gte(left: Constant, right: Constant): Gte; - -// @beta -export function gte(left: Constant, right: any): Gte; - -// @beta -export function gte(left: string, right: Constant): Gte; - -// @beta -export function gte(left: string, right: any): Gte; - -// @beta (undocumented) -export class If extends FirestoreFunction implements FilterCondition { - constructor(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function ifFunction(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant): If; - -// @beta (undocumented) -export class In extends FirestoreFunction implements FilterCondition { - constructor(left: Constant, others: Constant[]); - // (undocumented) - filterable: true; - } - -// @beta -export function inAny(element: Constant, others: Constant[]): In; - -// @beta -export function inAny(element: Constant, others: any[]): In; - -// @beta -export function inAny(element: string, others: Constant[]): In; - -// @beta -export function inAny(element: string, others: any[]): In; - // @public export function increment(n: number): FieldValue; @@ -1376,45 +358,6 @@ export interface IndexField { // @public export function initializeFirestore(app: FirebaseApp, settings: FirestoreSettings, databaseId?: string): Firestore; -// @beta (undocumented) -export class IsNan extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant); - // (undocumented) - filterable: true; -} - -// @beta -export function isNan(value: Constant): IsNan; - -// @beta -export function isNan(value: string): IsNan; - -// @beta (undocumented) -export class Like extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant, pattern: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function like(left: string, pattern: string): Like; - -// @beta -export function like(left: string, pattern: Constant): Like; - -// @beta -export function like(left: Constant, pattern: string): Like; - -// @beta -export function like(left: Constant, pattern: Constant): Like; - -// @beta (undocumented) -export class Limit implements Stage { - constructor(limit: number); - // (undocumented) - name: string; -} - // @public export function limit(limit: number): QueryLimitConstraint; @@ -1443,107 +386,8 @@ export interface LoadBundleTaskProgress { totalDocuments: number; } -// @beta (undocumented) -export class LogicalMax extends FirestoreFunction { - constructor(left: Constant, right: Constant); - } - -// @beta -export function logicalMax(left: Constant, right: Constant): LogicalMax; - -// @beta -export function logicalMax(left: Constant, right: any): LogicalMax; - -// @beta -export function logicalMax(left: string, right: Constant): LogicalMax; - -// @beta -export function logicalMax(left: string, right: any): LogicalMax; - -// @beta (undocumented) -export class LogicalMin extends FirestoreFunction { - constructor(left: Constant, right: Constant); - } - -// @beta -export function logicalMin(left: Constant, right: Constant): LogicalMin; - -// @beta -export function logicalMin(left: Constant, right: any): LogicalMin; - -// @beta -export function logicalMin(left: string, right: Constant): LogicalMin; - -// @beta -export function logicalMin(left: string, right: any): LogicalMin; - export { LogLevel } -// @beta (undocumented) -export class Lt extends FirestoreFunction implements FilterCondition { - constructor(left: Constant, right: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function lt(left: Constant, right: Constant): Lt; - -// @beta -export function lt(left: Constant, right: any): Lt; - -// @beta -export function lt(left: string, right: Constant): Lt; - -// @beta -export function lt(left: string, right: any): Lt; - -// @beta (undocumented) -export class Lte extends FirestoreFunction implements FilterCondition { - constructor(left: Constant, right: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function lte(left: Constant, right: Constant): Lte; - -// @beta -export function lte(left: Constant, right: any): Lte; - -// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Constant" which is marked as @beta -// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Lte" which is marked as @beta -// -// @public -export function lte(left: string, right: Constant): Lte; - -// @beta -export function lte(left: string, right: any): Lte; - -// @beta (undocumented) -export class MapGet extends FirestoreFunction { - constructor(map: Constant, name: string); -} - -// @beta -export function mapGet(mapField: string, subField: string): MapGet; - -// @beta -export function mapGet(mapExpr: Constant, subField: string): MapGet; - -// @beta (undocumented) -export class Max extends FirestoreFunction implements Accumulator { - constructor(value: Constant, distinct: boolean); - // (undocumented) - accumulator: true; - } - -// @beta -export function max(value: Constant): Max; - -// @beta -export function max(value: string): Max; - // @public export interface MemoryCacheSettings { garbageCollector?: MemoryGarbageCollector; @@ -1558,131 +402,36 @@ export interface MemoryEagerGarbageCollector { // @public export function memoryEagerGarbageCollector(): MemoryEagerGarbageCollector; -// @public -export type MemoryGarbageCollector = MemoryEagerGarbageCollector | MemoryLruGarbageCollector; - -// @public -export interface MemoryLocalCache { - // (undocumented) - kind: 'memory'; -} - -// @public -export function memoryLocalCache(settings?: MemoryCacheSettings): MemoryLocalCache; - -// @public -export interface MemoryLruGarbageCollector { - // (undocumented) - kind: 'memoryLru'; -} - -// @public -export function memoryLruGarbageCollector(settings?: { - cacheSizeBytes?: number; -}): MemoryLruGarbageCollector; - -// @beta (undocumented) -export class Min extends FirestoreFunction implements Accumulator { - constructor(value: Constant, distinct: boolean); - // (undocumented) - accumulator: true; - } - -// @beta -export function min(value: Constant): Min; - -// @beta -export function min(value: string): Min; - -// @beta (undocumented) -export class Mod extends FirestoreFunction { - constructor(left: Constant, right: Constant); - } - -// @beta -export function mod(left: Constant, right: Constant): Mod; - -// @beta -export function mod(left: Constant, right: any): Mod; - -// @beta -export function mod(left: string, right: Constant): Mod; - -// @beta -export function mod(left: string, right: any): Mod; - -// @beta (undocumented) -export class Multiply extends FirestoreFunction { - constructor(left: Constant, right: Constant); - } - -// @beta -export function multiply(left: Constant, right: Constant): Multiply; - -// @beta -export function multiply(left: Constant, right: any): Multiply; - -// @beta -export function multiply(left: string, right: Constant): Multiply; - -// @beta -export function multiply(left: string, right: any): Multiply; - -// @public -export function namedQuery(firestore: Firestore, name: string): Promise; - -// @beta (undocumented) -export class Neq extends FirestoreFunction implements FilterCondition { - constructor(left: Constant, right: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function neq(left: Constant, right: Constant): Neq; - -// @beta -export function neq(left: Constant, right: any): Neq; - -// @beta -export function neq(left: string, right: Constant): Neq; - -// @beta -export function neq(left: string, right: any): Neq; - -// @public -export type NestedUpdateFields> = UnionToIntersection<{ - [K in keyof T & string]: ChildUpdateFields; -}[keyof T & string]>; +// @public +export type MemoryGarbageCollector = MemoryEagerGarbageCollector | MemoryLruGarbageCollector; -// @beta (undocumented) -export class Not extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant); +// @public +export interface MemoryLocalCache { // (undocumented) - filterable: true; + kind: 'memory'; } -// @beta -export function not(filter: FilterExpr): Not; - -// @beta -export function notInAny(element: Constant, others: Constant[]): Not; +// @public +export function memoryLocalCache(settings?: MemoryCacheSettings): MemoryLocalCache; -// @beta -export function notInAny(element: Constant, others: any[]): Not; +// @public +export interface MemoryLruGarbageCollector { + // (undocumented) + kind: 'memoryLru'; +} -// @beta -export function notInAny(element: string, others: Constant[]): Not; +// @public +export function memoryLruGarbageCollector(settings?: { + cacheSizeBytes?: number; +}): MemoryLruGarbageCollector; -// @beta -export function notInAny(element: string, others: any[]): Not; +// @public +export function namedQuery(firestore: Firestore, name: string): Promise; -// @beta (undocumented) -export class Offset implements Stage { - constructor(offset: number); - // (undocumented) - name: string; - } +// @public +export type NestedUpdateFields> = UnionToIntersection<{ + [K in keyof T & string]: ChildUpdateFields; +}[keyof T & string]>; // @public export function onSnapshot(reference: DocumentReference, observer: { @@ -1724,6 +473,46 @@ export function onSnapshot(query // @public export function onSnapshot(query: Query, options: SnapshotListenOptions, onNext: (snapshot: QuerySnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe; +// @public +export function onSnapshotResume(firestore: Firestore, snapshotJson: object, onNext: (snapshot: QuerySnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void, converter?: FirestoreDataConverter): Unsubscribe; + +// @public +export function onSnapshotResume(firestore: Firestore, snapshotJson: object, onNext: (snapshot: DocumentSnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void, converter?: FirestoreDataConverter): Unsubscribe; + +// @public +export function onSnapshotResume(firestore: Firestore, snapshotJson: object, options: SnapshotListenOptions, onNext: (snapshot: QuerySnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void, converter?: FirestoreDataConverter): Unsubscribe; + +// @public +export function onSnapshotResume(firestore: Firestore, snapshotJson: object, options: SnapshotListenOptions, onNext: (snapshot: DocumentSnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void, converter?: FirestoreDataConverter): Unsubscribe; + +// @public +export function onSnapshotResume(firestore: Firestore, snapshotJson: object, observer: { + next: (snapshot: QuerySnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; +}, converter?: FirestoreDataConverter): Unsubscribe; + +// @public +export function onSnapshotResume(firestore: Firestore, snapshotJson: object, observer: { + next: (snapshot: DocumentSnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; +}, converter?: FirestoreDataConverter): Unsubscribe; + +// @public +export function onSnapshotResume(firestore: Firestore, snapshotJson: object, options: SnapshotListenOptions, observer: { + next: (snapshot: QuerySnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; +}, converter?: FirestoreDataConverter): Unsubscribe; + +// @public +export function onSnapshotResume(firestore: Firestore, snapshotJson: object, options: SnapshotListenOptions, observer: { + next: (snapshot: DocumentSnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; +}, converter?: FirestoreDataConverter): Unsubscribe; + // @public export function onSnapshotsInSync(firestore: Firestore, observer: { next?: (value: void) => void; @@ -1734,13 +523,6 @@ export function onSnapshotsInSync(firestore: Firestore, observer: { // @public export function onSnapshotsInSync(firestore: Firestore, onSync: () => void): Unsubscribe; -// @beta (undocumented) -export class Or extends FirestoreFunction implements FilterCondition { - constructor(conditions: FilterExpr[]); - // (undocumented) - filterable: true; -} - // @public export function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; @@ -1750,14 +532,6 @@ export function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDir // @public export type OrderByDirection = 'desc' | 'asc'; -// @beta -export class Ordering { - constructor(expr: Constant, direction: 'ascending' | 'descending'); - } - -// @beta -export function orFunction(left: FilterExpr, ...right: FilterExpr[]): Or; - // @public export type PartialWithFieldValue = Partial | (T extends Primitive ? T : T extends {} ? { [K in keyof T]?: PartialWithFieldValue | FieldValue; @@ -1814,79 +588,6 @@ export interface PersistentSingleTabManagerSettings { // @public export type PersistentTabManager = PersistentSingleTabManager | PersistentMultipleTabManager; -// @public (undocumented) -export class Pipeline { - /* Excluded from this release type: __constructor */ - // Warning: (ae-incompatible-release-tags) The symbol "addFields" is marked as @public, but its signature references "Selectable" which is marked as @beta - addFields(...fields: Selectable[]): Pipeline; - // Warning: (ae-incompatible-release-tags) The symbol "aggregate" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta - aggregate(...accumulators: AccumulatorTarget[]): Pipeline; - aggregate(options: { accumulators: AccumulatorTarget[]; groups?: Array; }): Pipeline; - // (undocumented) - converter: any; - // Warning: (ae-incompatible-release-tags) The symbol "distinct" is marked as @public, but its signature references "Selectable" which is marked as @beta - distinct(...groups: Array): Pipeline; - // Warning: (ae-incompatible-release-tags) The symbol "execute" is marked as @public, but its signature references "PipelineResult" which is marked as @beta - execute(): Promise>>; - // Warning: (ae-incompatible-release-tags) The symbol "findNearest" is marked as @public, but its signature references "FindNearestOptions" which is marked as @beta - // - // (undocumented) - findNearest(options: FindNearestOptions): Pipeline; - genericStage(name: string, params: any[]): Pipeline; - limit(limit: number): Pipeline; - offset(offset: number): Pipeline; - readUserData: any; - // Warning: (ae-incompatible-release-tags) The symbol "select" is marked as @public, but its signature references "Selectable" which is marked as @beta - select(...selections: Array): Pipeline; - // (undocumented) - selectablesToMap: any; - // Warning: (ae-incompatible-release-tags) The symbol "sort" is marked as @public, but its signature references "Ordering" which is marked as @beta - sort(...orderings: Ordering[]): Pipeline; - // (undocumented) - sort(options: { orderings: Ordering[]; }): Pipeline; - // (undocumented) - stages: any; - // (undocumented) - userDataReader: any; - // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "FilterCondition" which is marked as @beta - // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "Constant" which is marked as @beta - where(condition: FilterCondition & Constant): Pipeline; -} - -// Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta -// -// @public -export function pipeline(firestore: Firestore): PipelineSource; - -// @public -export function pipeline(query: Query): Pipeline; - -// @beta -export class PipelineResult { - /* Excluded from this release type: _ref */ - /* Excluded from this release type: _fields */ - /* Excluded from this release type: __constructor */ - get createTime(): Timestamp | undefined; - data(): AppModelType | undefined; - get executionTime(): Timestamp; - get(fieldPath: string | FieldPath): any; - get id(): string | undefined; - get ref(): DocumentReference | undefined; - get updateTime(): Timestamp | undefined; -} - -// @beta -export class PipelineSource { - // (undocumented) - collection(collectionPath: string): Pipeline; - // (undocumented) - collectionGroup(collectionId: string): Pipeline; - // (undocumented) - database(): Pipeline; - // (undocumented) - documents(docs: DocumentReference[]): Pipeline; - } - // @public export type Primitive = string | number | boolean | undefined | null; @@ -1895,7 +596,6 @@ export class Query | null; readonly firestore: Firestore; - pipeline(): Pipeline; readonly type: 'query' | 'collection'; withConverter(converter: null): Query; withConverter(converter: FirestoreDataConverter): Query; @@ -1964,8 +664,15 @@ export class QuerySnapshot; get size(): number; + toJSON(): object; } +// @public +export function querySnapshotFromJSON(db: Firestore, json: object): QuerySnapshot; + +// @public +export function querySnapshotFromJSON(db: Firestore, json: object, converter: FirestoreDataConverter): QuerySnapshot; + // @public export class QueryStartAtConstraint extends QueryConstraint { readonly type: 'startAt' | 'startAfter'; @@ -1974,102 +681,9 @@ export class QueryStartAtConstraint extends QueryConstraint { // @public export function refEqual(left: DocumentReference | CollectionReference, right: DocumentReference | CollectionReference): boolean; -// @beta (undocumented) -export class RegexContains extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant, pattern: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function regexContains(left: string, pattern: string): RegexContains; - -// @beta -export function regexContains(left: string, pattern: Constant): RegexContains; - -// @beta -export function regexContains(left: Constant, pattern: string): RegexContains; - -// @beta -export function regexContains(left: Constant, pattern: Constant): RegexContains; - -// @beta (undocumented) -export class RegexMatch extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant, pattern: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function regexMatch(left: string, pattern: string): RegexMatch; - -// @beta -export function regexMatch(left: string, pattern: Constant): RegexMatch; - -// @beta -export function regexMatch(left: Constant, pattern: string): RegexMatch; - -// @beta -export function regexMatch(left: Constant, pattern: Constant): RegexMatch; - -// @beta (undocumented) -export class ReplaceAll extends FirestoreFunction { - constructor(value: Constant, find: Constant, replace: Constant); - } - -// @beta -export function replaceAll(value: Constant, find: string, replace: string): ReplaceAll; - -// @beta -export function replaceAll(value: Constant, find: Constant, replace: Constant): ReplaceAll; - -// @beta -export function replaceAll(field: string, find: string, replace: string): ReplaceAll; - -// @beta (undocumented) -export class ReplaceFirst extends FirestoreFunction { - constructor(value: Constant, find: Constant, replace: Constant); - } - -// @beta -export function replaceFirst(value: Constant, find: string, replace: string): ReplaceFirst; - -// @beta -export function replaceFirst(value: Constant, find: Constant, replace: Constant): ReplaceFirst; - -// @beta -export function replaceFirst(field: string, find: string, replace: string): ReplaceFirst; - -// @beta (undocumented) -export class Reverse extends FirestoreFunction { - constructor(value: Constant); - } - -// @beta -export function reverse(expr: Constant): Reverse; - -// @beta -export function reverse(field: string): Reverse; - // @public export function runTransaction(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise, options?: TransactionOptions): Promise; -// @beta (undocumented) -export class Select implements Stage { - constructor(projections: Map); - // (undocumented) - name: string; - } - -// @beta -export interface Selectable { - // (undocumented) - selectable: true; -} - -// @beta -export type SelectableExpr = Constant & Selectable; - // @public export function serverTimestamp(): FieldValue; @@ -2116,19 +730,6 @@ export interface SnapshotOptions { readonly serverTimestamps?: 'estimate' | 'previous' | 'none'; } -// @beta (undocumented) -export class Sort implements Stage { - constructor(orders: Ordering[]); - // (undocumented) - name: string; - } - -// @beta (undocumented) -export interface Stage { - // (undocumented) - name: string; -} - // @public export function startAfter(snapshot: DocumentSnapshot): QueryStartAtConstraint; @@ -2141,88 +742,9 @@ export function startAt(snapshot // @public export function startAt(...fieldValues: unknown[]): QueryStartAtConstraint; -// @beta (undocumented) -export class StartsWith extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant, prefix: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function startsWith(expr: string, prefix: string): StartsWith; - -// @beta -export function startsWith(expr: string, prefix: Constant): StartsWith; - -// @beta -export function startsWith(expr: Constant, prefix: string): StartsWith; - -// @beta -export function startsWith(expr: Constant, prefix: Constant): StartsWith; - -// @beta (undocumented) -export class StrConcat extends FirestoreFunction { - constructor(first: Constant, rest: Constant[]); - } - -// @beta -export function strConcat(first: string, ...elements: Array): StrConcat; - -// @beta -export function strConcat(first: Constant, ...elements: Array): StrConcat; - -// @beta (undocumented) -export class StrContains extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant, substring: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function strContains(left: string, substring: string): StrContains; - -// @beta -export function strContains(left: string, substring: Constant): StrContains; - -// @beta -export function strContains(left: Constant, substring: string): StrContains; - -// @beta -export function strContains(left: Constant, substring: Constant): StrContains; - -// @beta (undocumented) -export class Subtract extends FirestoreFunction { - constructor(left: Constant, right: Constant); - } - -// @beta -export function subtract(left: Constant, right: Constant): Subtract; - -// @beta -export function subtract(left: Constant, right: any): Subtract; - -// @beta -export function subtract(left: string, right: Constant): Subtract; - -// @beta -export function subtract(left: string, right: any): Subtract; - -// @beta (undocumented) -export class Sum extends FirestoreFunction implements Accumulator { - constructor(value: Constant, distinct: boolean); - // (undocumented) - accumulator: true; - } - // @public export function sum(field: string | FieldPath): AggregateField; -// @beta -export function sumFunction(value: Constant): Sum; - -// @beta -export function sumFunction(value: string): Sum; - // @public export type TaskState = 'Error' | 'Running' | 'Success'; @@ -2235,6 +757,7 @@ export class Timestamp { seconds: number, nanoseconds: number); static fromDate(date: Date): Timestamp; + static fromJSON(json: object): Timestamp; static fromMillis(milliseconds: number): Timestamp; isEqual(other: Timestamp): boolean; readonly nanoseconds: number; @@ -2244,95 +767,13 @@ export class Timestamp { toJSON(): { seconds: number; nanoseconds: number; + type: string; }; toMillis(): number; toString(): string; valueOf(): string; } -// @beta (undocumented) -export class TimestampAdd extends FirestoreFunction { - constructor(timestamp: Constant, unit: Constant, amount: Constant); - } - -// @beta -export function timestampAdd(timestamp: Constant, unit: Constant, amount: Constant): TimestampAdd; - -// @beta -export function timestampAdd(timestamp: Constant, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - -// @beta -export function timestampAdd(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - -// @beta (undocumented) -export class TimestampSub extends FirestoreFunction { - constructor(timestamp: Constant, unit: Constant, amount: Constant); - } - -// @beta -export function timestampSub(timestamp: Constant, unit: Constant, amount: Constant): TimestampSub; - -// @beta -export function timestampSub(timestamp: Constant, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - -// @beta -export function timestampSub(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - -// @beta (undocumented) -export class TimestampToUnixMicros extends FirestoreFunction { - constructor(input: Constant); - } - -// @beta -export function timestampToUnixMicros(expr: Constant): TimestampToUnixMicros; - -// @beta -export function timestampToUnixMicros(field: string): TimestampToUnixMicros; - -// @beta (undocumented) -export class TimestampToUnixMillis extends FirestoreFunction { - constructor(input: Constant); - } - -// @beta -export function timestampToUnixMillis(expr: Constant): TimestampToUnixMillis; - -// @beta -export function timestampToUnixMillis(field: string): TimestampToUnixMillis; - -// @beta (undocumented) -export class TimestampToUnixSeconds extends FirestoreFunction { - constructor(input: Constant); - } - -// @beta -export function timestampToUnixSeconds(expr: Constant): TimestampToUnixSeconds; - -// @beta -export function timestampToUnixSeconds(field: string): TimestampToUnixSeconds; - -// @beta (undocumented) -export class ToLower extends FirestoreFunction { - constructor(expr: Constant); - } - -// @beta -export function toLower(expr: string): ToLower; - -// @beta -export function toLower(expr: Constant): ToLower; - -// @beta (undocumented) -export class ToUpper extends FirestoreFunction { - constructor(expr: Constant); - } - -// @beta -export function toUpper(expr: string): ToUpper; - -// @beta -export function toUpper(expr: Constant): ToUpper; - // @public export class Transaction { delete(documentRef: DocumentReference): this; @@ -2348,53 +789,9 @@ export interface TransactionOptions { readonly maxAttempts?: number; } -// @beta (undocumented) -export class Trim extends FirestoreFunction { - constructor(expr: Constant); - } - -// @beta -export function trim(expr: string): Trim; - -// @beta -export function trim(expr: Constant): Trim; - // @public export type UnionToIntersection = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never; -// @beta (undocumented) -export class UnixMicrosToTimestamp extends FirestoreFunction { - constructor(input: Constant); - } - -// @beta -export function unixMicrosToTimestamp(expr: Constant): UnixMicrosToTimestamp; - -// @beta -export function unixMicrosToTimestamp(field: string): UnixMicrosToTimestamp; - -// @beta (undocumented) -export class UnixMillisToTimestamp extends FirestoreFunction { - constructor(input: Constant); - } - -// @beta -export function unixMillisToTimestamp(expr: Constant): UnixMillisToTimestamp; - -// @beta -export function unixMillisToTimestamp(field: string): UnixMillisToTimestamp; - -// @beta (undocumented) -export class UnixSecondsToTimestamp extends FirestoreFunction { - constructor(input: Constant); - } - -// @beta -export function unixSecondsToTimestamp(expr: Constant): UnixSecondsToTimestamp; - -// @beta -export function unixSecondsToTimestamp(field: string): UnixSecondsToTimestamp; - // @public export interface Unsubscribe { (): void; @@ -2411,40 +808,21 @@ export function updateDoc(refere // @public export function updateDoc(reference: DocumentReference, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise; -// @public -export function useFirestorePipelines(): void; - // @public export function vector(values?: number[]): VectorValue; -// @beta (undocumented) -export class VectorLength extends FirestoreFunction { - constructor(value: Constant); - } - -// @beta -export function vectorLength(expr: Constant): VectorLength; - -// @beta -export function vectorLength(field: string): VectorLength; - // @public export class VectorValue { /* Excluded from this release type: __constructor */ + static fromJSON(json: object): VectorValue; isEqual(other: VectorValue): boolean; toArray(): number[]; + toJSON(): object; } // @public export function waitForPendingWrites(firestore: Firestore): Promise; -// @beta (undocumented) -export class Where implements Stage { - constructor(condition: FilterCondition & Constant); - // (undocumented) - name: string; -} - // @public export function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryFieldFilterConstraint; @@ -2469,21 +847,5 @@ export class WriteBatch { // @public export function writeBatch(firestore: Firestore): WriteBatch; -// @beta (undocumented) -export class Xor extends FirestoreFunction implements FilterCondition { - constructor(conditions: FilterExpr[]); - // (undocumented) - filterable: true; -} - -// @beta -export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; - - -// Warnings were encountered during analysis: -// -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10102: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:10102: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:10129: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/common/api-review/util.api.md b/common/api-review/util.api.md index f263f450da3..4ac51fda550 100644 --- a/common/api-review/util.api.md +++ b/common/api-review/util.api.md @@ -270,7 +270,7 @@ export function isBrowserExtension(): boolean; export function isCloudflareWorker(): boolean; // @public -export function isCloudWorkstation(host: string): boolean; +export function isCloudWorkstation(url: string): boolean; // Warning: (ae-missing-release-tag) "isElectron" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // diff --git a/docs-devsite/ai.counttokensresponse.md b/docs-devsite/ai.counttokensresponse.md index 71e64d885d8..8a7181a2e03 100644 --- a/docs-devsite/ai.counttokensresponse.md +++ b/docs-devsite/ai.counttokensresponse.md @@ -23,7 +23,7 @@ export interface CountTokensResponse | Property | Type | Description | | --- | --- | --- | | [promptTokensDetails](./ai.counttokensresponse.md#counttokensresponseprompttokensdetails) | [ModalityTokenCount](./ai.modalitytokencount.md#modalitytokencount_interface)\[\] | The breakdown, by modality, of how many tokens are consumed by the prompt. | -| [totalBillableCharacters](./ai.counttokensresponse.md#counttokensresponsetotalbillablecharacters) | number | The total number of billable characters counted across all instances from the request.This property is only supported when using the Vertex AI Gemini API ([VertexAIBackend](./ai.vertexaibackend.md#vertexaibackend_class)). When using the Gemini Developer API ([GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class)), this property is not supported and will default to 0. | +| [totalBillableCharacters](./ai.counttokensresponse.md#counttokensresponsetotalbillablecharacters) | number | | | [totalTokens](./ai.counttokensresponse.md#counttokensresponsetotaltokens) | number | The total number of tokens counted across all instances from the request. | ## CountTokensResponse.promptTokensDetails @@ -38,9 +38,12 @@ promptTokensDetails?: ModalityTokenCount[]; ## CountTokensResponse.totalBillableCharacters -The total number of billable characters counted across all instances from the request. - -This property is only supported when using the Vertex AI Gemini API ([VertexAIBackend](./ai.vertexaibackend.md#vertexaibackend_class)). When using the Gemini Developer API ([GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class)), this property is not supported and will default to 0. +> Warning: This API is now obsolete. +> +> Use `totalTokens` instead. This property is undefined when using models greater than `gemini-1.5-*`. +> +> The total number of billable characters counted across all instances from the request. +> Signature: diff --git a/docs-devsite/ai.schema.md b/docs-devsite/ai.schema.md index b0681b0cdf3..fa1225c91e5 100644 --- a/docs-devsite/ai.schema.md +++ b/docs-devsite/ai.schema.md @@ -32,6 +32,9 @@ export declare abstract class Schema implements SchemaInterface | [description](./ai.schema.md#schemadescription) | | string | Optional. The description of the property. | | [example](./ai.schema.md#schemaexample) | | unknown | Optional. The example of the property. | | [format](./ai.schema.md#schemaformat) | | string | Optional. The format of the property. Supported formats:
  • for NUMBER type: "float", "double"
  • for INTEGER type: "int32", "int64"
  • for STRING type: "email", "byte", etc
| +| [items](./ai.schema.md#schemaitems) | | [SchemaInterface](./ai.schemainterface.md#schemainterface_interface) | Optional. The items of the property. | +| [maxItems](./ai.schema.md#schemamaxitems) | | number | The maximum number of items (elements) in a schema of type [SchemaType.ARRAY](./ai.md#schematypearray_enummember). | +| [minItems](./ai.schema.md#schemaminitems) | | number | The minimum number of items (elements) in a schema of type [SchemaType.ARRAY](./ai.md#schematypearray_enummember). | | [nullable](./ai.schema.md#schemanullable) | | boolean | Optional. Whether the property is nullable. Defaults to false. | | [type](./ai.schema.md#schematype) | | [SchemaType](./ai.md#schematype) | Optional. The type of the property. [SchemaType](./ai.md#schematype). | @@ -93,6 +96,36 @@ Optional. The format of the property. Supported formats:
  • for NUMBE format?: string; ``` +## Schema.items + +Optional. The items of the property. + +Signature: + +```typescript +items?: SchemaInterface; +``` + +## Schema.maxItems + +The maximum number of items (elements) in a schema of type [SchemaType.ARRAY](./ai.md#schematypearray_enummember). + +Signature: + +```typescript +maxItems?: number; +``` + +## Schema.minItems + +The minimum number of items (elements) in a schema of type [SchemaType.ARRAY](./ai.md#schematypearray_enummember). + +Signature: + +```typescript +minItems?: number; +``` + ## Schema.nullable Optional. Whether the property is nullable. Defaults to false. diff --git a/docs-devsite/ai.schemashared.md b/docs-devsite/ai.schemashared.md index 7f0ed27026c..fb75fc50841 100644 --- a/docs-devsite/ai.schemashared.md +++ b/docs-devsite/ai.schemashared.md @@ -28,7 +28,9 @@ export interface SchemaShared | [format](./ai.schemashared.md#schemasharedformat) | string | Optional. The format of the property. When using the Gemini Developer API ([GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class)), this must be either 'enum' or 'date-time', otherwise requests will fail. | | [items](./ai.schemashared.md#schemashareditems) | T | Optional. The items of the property. | | [maximum](./ai.schemashared.md#schemasharedmaximum) | number | The maximum value of a numeric type. | +| [maxItems](./ai.schemashared.md#schemasharedmaxitems) | number | The maximum number of items (elements) in a schema of type [SchemaType.ARRAY](./ai.md#schematypearray_enummember). | | [minimum](./ai.schemashared.md#schemasharedminimum) | number | The minimum value of a numeric type. | +| [minItems](./ai.schemashared.md#schemasharedminitems) | number | The minimum number of items (elements) in a schema of type [SchemaType.ARRAY](./ai.md#schematypearray_enummember). | | [nullable](./ai.schemashared.md#schemasharednullable) | boolean | Optional. Whether the property is nullable. | | [properties](./ai.schemashared.md#schemasharedproperties) | { \[k: string\]: T; } | Optional. Map of Schema objects. | | [propertyOrdering](./ai.schemashared.md#schemasharedpropertyordering) | string\[\] | A hint suggesting the order in which the keys should appear in the generated JSON string. | @@ -94,6 +96,16 @@ The maximum value of a numeric type. maximum?: number; ``` +## SchemaShared.maxItems + +The maximum number of items (elements) in a schema of type [SchemaType.ARRAY](./ai.md#schematypearray_enummember). + +Signature: + +```typescript +maxItems?: number; +``` + ## SchemaShared.minimum The minimum value of a numeric type. @@ -104,6 +116,16 @@ The minimum value of a numeric type. minimum?: number; ``` +## SchemaShared.minItems + +The minimum number of items (elements) in a schema of type [SchemaType.ARRAY](./ai.md#schematypearray_enummember). + +Signature: + +```typescript +minItems?: number; +``` + ## SchemaShared.nullable Optional. Whether the property is nullable. diff --git a/docs-devsite/firestore_.bytes.md b/docs-devsite/firestore_.bytes.md index 8060d394a45..164ddc1acd9 100644 --- a/docs-devsite/firestore_.bytes.md +++ b/docs-devsite/firestore_.bytes.md @@ -23,9 +23,11 @@ export declare class Bytes | Method | Modifiers | Description | | --- | --- | --- | | [fromBase64String(base64)](./firestore_.bytes.md#bytesfrombase64string) | static | Creates a new Bytes object from the given Base64 string, converting it to bytes. | +| [fromJSON(json)](./firestore_.bytes.md#bytesfromjson) | static | Builds a Bytes instance from a JSON object created by [Bytes.toJSON()](./firestore_.bytes.md#bytestojson). | | [fromUint8Array(array)](./firestore_.bytes.md#bytesfromuint8array) | static | Creates a new Bytes object from the given Uint8Array. | | [isEqual(other)](./firestore_.bytes.md#bytesisequal) | | Returns true if this Bytes object is equal to the provided one. | | [toBase64()](./firestore_.bytes.md#bytestobase64) | | Returns the underlying bytes as a Base64-encoded string. | +| [toJSON()](./firestore_.bytes.md#bytestojson) | | Returns a JSON-serializable representation of this Bytes instance. | | [toString()](./firestore_.bytes.md#bytestostring) | | Returns a string representation of the Bytes object. | | [toUint8Array()](./firestore_.bytes.md#bytestouint8array) | | Returns the underlying bytes in a new Uint8Array. | @@ -49,6 +51,28 @@ static fromBase64String(base64: string): Bytes; [Bytes](./firestore_.bytes.md#bytes_class) +## Bytes.fromJSON() + +Builds a `Bytes` instance from a JSON object created by [Bytes.toJSON()](./firestore_.bytes.md#bytestojson). + +Signature: + +```typescript +static fromJSON(json: object): Bytes; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| json | object | a JSON object represention of a Bytes instance | + +Returns: + +[Bytes](./firestore_.bytes.md#bytes_class) + +an instance of [Bytes](./firestore_.bytes.md#bytes_class) if the JSON object could be parsed. Throws a [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) if an error occurs. + ## Bytes.fromUint8Array() Creates a new `Bytes` object from the given Uint8Array. @@ -106,6 +130,21 @@ string The Base64-encoded string created from the `Bytes` object. +## Bytes.toJSON() + +Returns a JSON-serializable representation of this `Bytes` instance. + +Signature: + +```typescript +toJSON(): object; +``` +Returns: + +object + +a JSON representation of this object. + ## Bytes.toString() Returns a string representation of the `Bytes` object. diff --git a/docs-devsite/firestore_.documentreference.md b/docs-devsite/firestore_.documentreference.md index c63ba6eab0a..ee4be972b0c 100644 --- a/docs-devsite/firestore_.documentreference.md +++ b/docs-devsite/firestore_.documentreference.md @@ -33,6 +33,9 @@ export declare class DocumentReferencestatic | Builds a DocumentReference instance from a JSON object created by [DocumentReference.toJSON()](./firestore_.documentreference.md#documentreferencetojson). | +| [fromJSON(firestore, json, converter)](./firestore_.documentreference.md#documentreferencefromjson) | static | Builds a DocumentReference instance from a JSON object created by [DocumentReference.toJSON()](./firestore_.documentreference.md#documentreferencetojson). | +| [toJSON()](./firestore_.documentreference.md#documentreferencetojson) | | Returns a JSON-serializable representation of this DocumentReference instance. | | [withConverter(converter)](./firestore_.documentreference.md#documentreferencewithconverter) | | Applies a custom data converter to this DocumentReference, allowing you to use your own custom model objects with Firestore. When you call [setDoc()](./firestore_lite.md#setdoc_ee215ad), [getDoc()](./firestore_lite.md#getdoc_4569087), etc. with the returned DocumentReference instance, the provided converter will convert between Firestore data of type NewDbModelType and your custom type NewAppModelType. | | [withConverter(converter)](./firestore_.documentreference.md#documentreferencewithconverter) | | Removes the current converter. | @@ -96,6 +99,68 @@ The type of this Firestore reference. readonly type = "document"; ``` +## DocumentReference.fromJSON() + +Builds a `DocumentReference` instance from a JSON object created by [DocumentReference.toJSON()](./firestore_.documentreference.md#documentreferencetojson). + +Signature: + +```typescript +static fromJSON(firestore: Firestore, json: object): DocumentReference; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance the snapshot should be loaded for. | +| json | object | a JSON object represention of a DocumentReference instance | + +Returns: + +[DocumentReference](./firestore_.documentreference.md#documentreference_class) + +an instance of [DocumentReference](./firestore_.documentreference.md#documentreference_class) if the JSON object could be parsed. Throws a [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) if an error occurs. + +## DocumentReference.fromJSON() + +Builds a `DocumentReference` instance from a JSON object created by [DocumentReference.toJSON()](./firestore_.documentreference.md#documentreferencetojson). + +Signature: + +```typescript +static fromJSON(firestore: Firestore, json: object, converter: FirestoreDataConverter): DocumentReference; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance the snapshot should be loaded for. | +| json | object | a JSON object represention of a DocumentReference instance | +| converter | [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface)<NewAppModelType, NewDbModelType> | Converts objects to and from Firestore. | + +Returns: + +[DocumentReference](./firestore_.documentreference.md#documentreference_class)<NewAppModelType, NewDbModelType> + +an instance of [DocumentReference](./firestore_.documentreference.md#documentreference_class) if the JSON object could be parsed. Throws a [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) if an error occurs. + +## DocumentReference.toJSON() + +Returns a JSON-serializable representation of this `DocumentReference` instance. + +Signature: + +```typescript +toJSON(): object; +``` +Returns: + +object + +a JSON representation of this object. + ## DocumentReference.withConverter() Applies a custom data converter to this `DocumentReference`, allowing you to use your own custom model objects with Firestore. When you call [setDoc()](./firestore_lite.md#setdoc_ee215ad), [getDoc()](./firestore_lite.md#getdoc_4569087), etc. with the returned `DocumentReference` instance, the provided converter will convert between Firestore data of type `NewDbModelType` and your custom type `NewAppModelType`. diff --git a/docs-devsite/firestore_.documentsnapshot.md b/docs-devsite/firestore_.documentsnapshot.md index 476588b78c0..cece3f79deb 100644 --- a/docs-devsite/firestore_.documentsnapshot.md +++ b/docs-devsite/firestore_.documentsnapshot.md @@ -41,6 +41,7 @@ export declare class DocumentSnapshotObject. Returns undefined if the document doesn't exist.By default, serverTimestamp() values that have not yet been set to their final value will be returned as null. You can override this by passing an options object. | | [exists()](./firestore_.documentsnapshot.md#documentsnapshotexists) | | Returns whether or not the data exists. True if the document exists. | | [get(fieldPath, options)](./firestore_.documentsnapshot.md#documentsnapshotget) | | Retrieves the field specified by fieldPath. Returns undefined if the document or field doesn't exist.By default, a serverTimestamp() that has not yet been set to its final value will be returned as null. You can override this by passing an options object. | +| [toJSON()](./firestore_.documentsnapshot.md#documentsnapshottojson) | | Returns a JSON-serializable representation of this DocumentSnapshot instance. | ## DocumentSnapshot.(constructor) @@ -144,3 +145,18 @@ any The data at the specified field location or undefined if no such field exists in the document. +## DocumentSnapshot.toJSON() + +Returns a JSON-serializable representation of this `DocumentSnapshot` instance. + +Signature: + +```typescript +toJSON(): object; +``` +Returns: + +object + +a JSON representation of this object. Throws a [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) if this `DocumentSnapshot` has pending writes. + diff --git a/docs-devsite/firestore_.geopoint.md b/docs-devsite/firestore_.geopoint.md index d4264a39f5f..c88a5289c64 100644 --- a/docs-devsite/firestore_.geopoint.md +++ b/docs-devsite/firestore_.geopoint.md @@ -37,8 +37,9 @@ export declare class GeoPoint | Method | Modifiers | Description | | --- | --- | --- | +| [fromJSON(json)](./firestore_.geopoint.md#geopointfromjson) | static | Builds a GeoPoint instance from a JSON object created by [GeoPoint.toJSON()](./firestore_.geopoint.md#geopointtojson). | | [isEqual(other)](./firestore_.geopoint.md#geopointisequal) | | Returns true if this GeoPoint is equal to the provided one. | -| [toJSON()](./firestore_.geopoint.md#geopointtojson) | | Returns a JSON-serializable representation of this GeoPoint. | +| [toJSON()](./firestore_.geopoint.md#geopointtojson) | | Returns a JSON-serializable representation of this GeoPoint instance. | ## GeoPoint.(constructor) @@ -77,6 +78,28 @@ The longitude of this `GeoPoint` instance. get longitude(): number; ``` +## GeoPoint.fromJSON() + +Builds a `GeoPoint` instance from a JSON object created by [GeoPoint.toJSON()](./firestore_.geopoint.md#geopointtojson). + +Signature: + +```typescript +static fromJSON(json: object): GeoPoint; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| json | object | a JSON object represention of a GeoPoint instance | + +Returns: + +[GeoPoint](./firestore_.geopoint.md#geopoint_class) + +an instance of [GeoPoint](./firestore_.geopoint.md#geopoint_class) if the JSON object could be parsed. Throws a [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) if an error occurs. + ## GeoPoint.isEqual() Returns true if this `GeoPoint` is equal to the provided one. @@ -101,7 +124,7 @@ true if this `GeoPoint` is equal to the provided one. ## GeoPoint.toJSON() -Returns a JSON-serializable representation of this GeoPoint. +Returns a JSON-serializable representation of this `GeoPoint` instance. Signature: @@ -109,9 +132,12 @@ Returns a JSON-serializable representation of this GeoPoint. toJSON(): { latitude: number; longitude: number; + type: string; }; ``` Returns: -{ latitude: number; longitude: number; } +{ latitude: number; longitude: number; type: string; } + +a JSON representation of this object. diff --git a/docs-devsite/firestore_.md b/docs-devsite/firestore_.md index 91d21e32708..5d237fcafea 100644 --- a/docs-devsite/firestore_.md +++ b/docs-devsite/firestore_.md @@ -19,6 +19,11 @@ https://github.com/firebase/firebase-js-sdk | [getFirestore(app)](./firestore_.md#getfirestore_cf608e1) | Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. | | [getFirestore(app, databaseId)](./firestore_.md#getfirestore_48de6cb) | (Public Preview) Returns the existing named [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. | | [initializeFirestore(app, settings, databaseId)](./firestore_.md#initializefirestore_fc7d200) | Initializes a new instance of [Firestore](./firestore_.firestore.md#firestore_class) with the provided settings. Can only be called before any other function, including [getFirestore()](./firestore_.md#getfirestore). If the custom settings are empty, this function is equivalent to calling [getFirestore()](./firestore_.md#getfirestore). | +| function(db, ...) | +| [documentSnapshotFromJSON(db, json)](./firestore_.md#documentsnapshotfromjson_a318ff2) | Builds a DocumentSnapshot instance from a JSON object created by [DocumentSnapshot.toJSON()](./firestore_.documentsnapshot.md#documentsnapshottojson). | +| [documentSnapshotFromJSON(db, json, converter)](./firestore_.md#documentsnapshotfromjson_ddb369d) | Builds a DocumentSnapshot instance from a JSON object created by [DocumentSnapshot.toJSON()](./firestore_.documentsnapshot.md#documentsnapshottojson). | +| [querySnapshotFromJSON(db, json)](./firestore_.md#querysnapshotfromjson_a318ff2) | Builds a QuerySnapshot instance from a JSON object created by [QuerySnapshot.toJSON()](./firestore_.querysnapshot.md#querysnapshottojson). | +| [querySnapshotFromJSON(db, json, converter)](./firestore_.md#querysnapshotfromjson_ddb369d) | Builds a QuerySnapshot instance from a JSON object created by [QuerySnapshot.toJSON()](./firestore_.querysnapshot.md#querysnapshottojson). | | function(firestore, ...) | | [clearIndexedDbPersistence(firestore)](./firestore_.md#clearindexeddbpersistence_231a8e0) | Clears the persistent storage. This includes pending writes and cached documents.Must be called while the [Firestore](./firestore_.firestore.md#firestore_class) instance is not started (after the app is terminated or when the app is first initialized). On startup, this function must be called before other functions (other than [initializeFirestore()](./firestore_.md#initializefirestore_fc7d200) or [getFirestore()](./firestore_.md#getfirestore))). If the [Firestore](./firestore_.firestore.md#firestore_class) instance is still running, the promise will be rejected with the error code of failed-precondition.Note: clearIndexedDbPersistence() is primarily intended to help write reliable tests that use Cloud Firestore. It uses an efficient mechanism for dropping existing data but does not attempt to securely overwrite or otherwise make cached data unrecoverable. For applications that are sensitive to the disclosure of cached data in between user sessions, we strongly recommend not enabling persistence at all. | | [collection(firestore, path, pathSegments)](./firestore_.md#collection_1eb4c23) | Gets a CollectionReference instance that refers to the collection at the specified absolute path. | @@ -32,6 +37,14 @@ https://github.com/firebase/firebase-js-sdk | [getPersistentCacheIndexManager(firestore)](./firestore_.md#getpersistentcacheindexmanager_231a8e0) | Returns the PersistentCache Index Manager used by the given Firestore object. The PersistentCacheIndexManager instance, or null if local persistent storage is not in use. | | [loadBundle(firestore, bundleData)](./firestore_.md#loadbundle_bec5b75) | Loads a Firestore bundle into the local cache. | | [namedQuery(firestore, name)](./firestore_.md#namedquery_6438876) | Reads a Firestore [Query](./firestore_.query.md#query_class) from local cache, identified by the given name.The named queries are packaged into bundles on the server side (along with resulting documents), and loaded to local cache using loadBundle. Once in local cache, use this method to extract a [Query](./firestore_.query.md#query_class) by name. | +| [onSnapshotResume(firestore, snapshotJson, onNext, onError, onCompletion, converter)](./firestore_.md#onsnapshotresume_7c84f5e) | Attaches a listener for QuerySnapshot events based on data generated by invoking [QuerySnapshot.toJSON()](./firestore_.querysnapshot.md#querysnapshottojson) You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | +| [onSnapshotResume(firestore, snapshotJson, onNext, onError, onCompletion, converter)](./firestore_.md#onsnapshotresume_712362a) | Attaches a listener for DocumentSnapshot events based on data generated by invoking [DocumentSnapshot.toJSON()](./firestore_.documentsnapshot.md#documentsnapshottojson). You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | +| [onSnapshotResume(firestore, snapshotJson, options, onNext, onError, onCompletion, converter)](./firestore_.md#onsnapshotresume_8807e6e) | Attaches a listener for QuerySnapshot events based on data generated by invoking [QuerySnapshot.toJSON()](./firestore_.querysnapshot.md#querysnapshottojson). You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | +| [onSnapshotResume(firestore, snapshotJson, options, onNext, onError, onCompletion, converter)](./firestore_.md#onsnapshotresume_301fcec) | Attaches a listener for DocumentSnapshot events based on data generated by invoking [DocumentSnapshot.toJSON()](./firestore_.documentsnapshot.md#documentsnapshottojson). You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | +| [onSnapshotResume(firestore, snapshotJson, observer, converter)](./firestore_.md#onsnapshotresume_b8b5c9d) | Attaches a listener for QuerySnapshot events based on QuerySnapshot data generated by invoking [QuerySnapshot.toJSON()](./firestore_.querysnapshot.md#querysnapshottojson). You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | +| [onSnapshotResume(firestore, snapshotJson, observer, converter)](./firestore_.md#onsnapshotresume_9b75d28) | Attaches a listener for DocumentSnapshot events based on data generated by invoking [DocumentSnapshot.toJSON()](./firestore_.documentsnapshot.md#documentsnapshottojson) You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | +| [onSnapshotResume(firestore, snapshotJson, options, observer, converter)](./firestore_.md#onsnapshotresume_fb80adf) | Attaches a listener for QuerySnapshot events based on QuerySnapshot data generated by invoking [QuerySnapshot.toJSON()](./firestore_.querysnapshot.md#querysnapshottojson) You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | +| [onSnapshotResume(firestore, snapshotJson, options, observer, converter)](./firestore_.md#onsnapshotresume_f76d912) | Attaches a listener for DocumentSnapshot events based on QuerySnapshot data generated by invoking [DocumentSnapshot.toJSON()](./firestore_.documentsnapshot.md#documentsnapshottojson) You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | | [onSnapshotsInSync(firestore, observer)](./firestore_.md#onsnapshotsinsync_2f0dfa4) | Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync event indicates that all listeners affected by a given change have fired, even if a single server-generated change affects multiple listeners.NOTE: The snapshots-in-sync event only indicates that listeners are in sync with each other, but does not relate to whether those snapshots are in sync with the server. Use SnapshotMetadata in the individual listeners to determine if a snapshot is from the cache or the server. | | [onSnapshotsInSync(firestore, onSync)](./firestore_.md#onsnapshotsinsync_1901c06) | Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync event indicates that all listeners affected by a given change have fired, even if a single server-generated change affects multiple listeners.NOTE: The snapshots-in-sync event only indicates that listeners are in sync with each other, but does not relate to whether those snapshots are in sync with the server. Use SnapshotMetadata in the individual listeners to determine if a snapshot is from the cache or the server. | | [runTransaction(firestore, updateFunction, options)](./firestore_.md#runtransaction_6f03ec4) | Executes the given updateFunction and then attempts to commit the changes applied within the transaction. If any document read within the transaction has changed, Cloud Firestore retries the updateFunction. If it fails to commit after 5 attempts, the transaction fails.The maximum number of writes allowed in a single transaction is 500. | @@ -298,6 +311,102 @@ export declare function initializeFirestore(app: FirebaseApp, settings: Firestor A newly initialized [Firestore](./firestore_.firestore.md#firestore_class) instance. +## function(db, ...) + +### documentSnapshotFromJSON(db, json) {:#documentsnapshotfromjson_a318ff2} + +Builds a `DocumentSnapshot` instance from a JSON object created by [DocumentSnapshot.toJSON()](./firestore_.documentsnapshot.md#documentsnapshottojson). + +Signature: + +```typescript +export declare function documentSnapshotFromJSON(db: Firestore, json: object): DocumentSnapshot; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| db | [Firestore](./firestore_.firestore.md#firestore_class) | | +| json | object | a JSON object represention of a DocumentSnapshot instance. | + +Returns: + +[DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class) + +an instance of [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class) if the JSON object could be parsed. Throws a [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) if an error occurs. + +### documentSnapshotFromJSON(db, json, converter) {:#documentsnapshotfromjson_ddb369d} + +Builds a `DocumentSnapshot` instance from a JSON object created by [DocumentSnapshot.toJSON()](./firestore_.documentsnapshot.md#documentsnapshottojson). + +Signature: + +```typescript +export declare function documentSnapshotFromJSON(db: Firestore, json: object, converter: FirestoreDataConverter): DocumentSnapshot; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| db | [Firestore](./firestore_.firestore.md#firestore_class) | | +| json | object | a JSON object represention of a DocumentSnapshot instance. | +| converter | [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface)<AppModelType, DbModelType> | Converts objects to and from Firestore. | + +Returns: + +[DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> + +an instance of [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class) if the JSON object could be parsed. Throws a [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) if an error occurs. + +### querySnapshotFromJSON(db, json) {:#querysnapshotfromjson_a318ff2} + +Builds a `QuerySnapshot` instance from a JSON object created by [QuerySnapshot.toJSON()](./firestore_.querysnapshot.md#querysnapshottojson). + +Signature: + +```typescript +export declare function querySnapshotFromJSON(db: Firestore, json: object): QuerySnapshot; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| db | [Firestore](./firestore_.firestore.md#firestore_class) | | +| json | object | a JSON object represention of a QuerySnapshot instance. | + +Returns: + +[QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class) + +an instance of [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class) if the JSON object could be parsed. Throws a [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) if an error occurs. + +### querySnapshotFromJSON(db, json, converter) {:#querysnapshotfromjson_ddb369d} + +Builds a `QuerySnapshot` instance from a JSON object created by [QuerySnapshot.toJSON()](./firestore_.querysnapshot.md#querysnapshottojson). + +Signature: + +```typescript +export declare function querySnapshotFromJSON(db: Firestore, json: object, converter: FirestoreDataConverter): QuerySnapshot; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| db | [Firestore](./firestore_.firestore.md#firestore_class) | | +| json | object | a JSON object represention of a QuerySnapshot instance. | +| converter | [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface)<AppModelType, DbModelType> | Converts objects to and from Firestore. | + +Returns: + +[QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType> + +an instance of [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class) if the JSON object could be parsed. Throws a [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) if an error occurs. + ## function(firestore, ...) ### clearIndexedDbPersistence(firestore) {:#clearindexeddbpersistence_231a8e0} @@ -617,6 +726,250 @@ Promise<[Query](./firestore_.query.md#query_class) \| null> A `Promise` that is resolved with the Query or `null`. +### onSnapshotResume(firestore, snapshotJson, onNext, onError, onCompletion, converter) {:#onsnapshotresume_7c84f5e} + +Attaches a listener for `QuerySnapshot` events based on data generated by invoking [QuerySnapshot.toJSON()](./firestore_.querysnapshot.md#querysnapshottojson) You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. + +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. + +Signature: + +```typescript +export declare function onSnapshotResume(firestore: Firestore, snapshotJson: object, onNext: (snapshot: QuerySnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void, converter?: FirestoreDataConverter): Unsubscribe; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to enable the listener for. | +| snapshotJson | object | A JSON object generated by invoking [QuerySnapshot.toJSON()](./firestore_.querysnapshot.md#querysnapshottojson). | +| onNext | (snapshot: [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>) => void | A callback to be called every time a new QuerySnapshot is available. | +| onError | (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void | A callback to be called if the listen fails or is cancelled. No further callbacks will occur. | +| onCompletion | () => void | Can be provided, but will not be called since streams are never ending. | +| converter | [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface)<DbModelType> | An optional object that converts objects from Firestore before the onNext listener is invoked. | + +Returns: + +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) + +An unsubscribe function that can be called to cancel the snapshot listener. + +### onSnapshotResume(firestore, snapshotJson, onNext, onError, onCompletion, converter) {:#onsnapshotresume_712362a} + +Attaches a listener for `DocumentSnapshot` events based on data generated by invoking [DocumentSnapshot.toJSON()](./firestore_.documentsnapshot.md#documentsnapshottojson). You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. + +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. + +Signature: + +```typescript +export declare function onSnapshotResume(firestore: Firestore, snapshotJson: object, onNext: (snapshot: DocumentSnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void, converter?: FirestoreDataConverter): Unsubscribe; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to enable the listener for. | +| snapshotJson | object | A JSON object generated by invoking [DocumentSnapshot.toJSON()](./firestore_.documentsnapshot.md#documentsnapshottojson). | +| onNext | (snapshot: [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>) => void | A callback to be called every time a new DocumentSnapshot is available. | +| onError | (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void | A callback to be called if the listen fails or is cancelled. No further callbacks will occur. | +| onCompletion | () => void | Can be provided, but will not be called since streams are never ending. | +| converter | [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface)<DbModelType> | An optional object that converts objects from Firestore before the onNext listener is invoked. | + +Returns: + +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) + +An unsubscribe function that can be called to cancel the snapshot listener. + +### onSnapshotResume(firestore, snapshotJson, options, onNext, onError, onCompletion, converter) {:#onsnapshotresume_8807e6e} + +Attaches a listener for `QuerySnapshot` events based on data generated by invoking [QuerySnapshot.toJSON()](./firestore_.querysnapshot.md#querysnapshottojson). You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. + +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. + +Signature: + +```typescript +export declare function onSnapshotResume(firestore: Firestore, snapshotJson: object, options: SnapshotListenOptions, onNext: (snapshot: QuerySnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void, converter?: FirestoreDataConverter): Unsubscribe; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to enable the listener for. | +| snapshotJson | object | A JSON object generated by invoking [QuerySnapshot.toJSON()](./firestore_.querysnapshot.md#querysnapshottojson). | +| options | [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | Options controlling the listen behavior. | +| onNext | (snapshot: [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>) => void | A callback to be called every time a new QuerySnapshot is available. | +| onError | (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void | A callback to be called if the listen fails or is cancelled. No further callbacks will occur. | +| onCompletion | () => void | Can be provided, but will not be called since streams are never ending. | +| converter | [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface)<DbModelType> | An optional object that converts objects from Firestore before the onNext listener is invoked. | + +Returns: + +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) + +An unsubscribe function that can be called to cancel the snapshot listener. + +### onSnapshotResume(firestore, snapshotJson, options, onNext, onError, onCompletion, converter) {:#onsnapshotresume_301fcec} + +Attaches a listener for `DocumentSnapshot` events based on data generated by invoking [DocumentSnapshot.toJSON()](./firestore_.documentsnapshot.md#documentsnapshottojson). You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. + +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. + +Signature: + +```typescript +export declare function onSnapshotResume(firestore: Firestore, snapshotJson: object, options: SnapshotListenOptions, onNext: (snapshot: DocumentSnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void, converter?: FirestoreDataConverter): Unsubscribe; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to enable the listener for. | +| snapshotJson | object | A JSON object generated by invoking [DocumentSnapshot.toJSON()](./firestore_.documentsnapshot.md#documentsnapshottojson). | +| options | [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | Options controlling the listen behavior. | +| onNext | (snapshot: [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>) => void | A callback to be called every time a new DocumentSnapshot is available. | +| onError | (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void | A callback to be called if the listen fails or is cancelled. No further callbacks will occur. | +| onCompletion | () => void | Can be provided, but will not be called since streams are never ending. | +| converter | [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface)<DbModelType> | An optional object that converts objects from Firestore before the onNext listener is invoked. | + +Returns: + +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) + +An unsubscribe function that can be called to cancel the snapshot listener. + +### onSnapshotResume(firestore, snapshotJson, observer, converter) {:#onsnapshotresume_b8b5c9d} + +Attaches a listener for `QuerySnapshot` events based on QuerySnapshot data generated by invoking [QuerySnapshot.toJSON()](./firestore_.querysnapshot.md#querysnapshottojson). You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. + +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. + +Signature: + +```typescript +export declare function onSnapshotResume(firestore: Firestore, snapshotJson: object, observer: { + next: (snapshot: QuerySnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; +}, converter?: FirestoreDataConverter): Unsubscribe; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to enable the listener for. | +| snapshotJson | object | A JSON object generated by invoking [QuerySnapshot.toJSON()](./firestore_.querysnapshot.md#querysnapshottojson). | +| observer | { next: (snapshot: [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | +| converter | [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface)<DbModelType> | An optional object that converts objects from Firestore before the onNext listener is invoked. | + +Returns: + +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) + +An unsubscribe function that can be called to cancel the snapshot listener. + +### onSnapshotResume(firestore, snapshotJson, observer, converter) {:#onsnapshotresume_9b75d28} + +Attaches a listener for `DocumentSnapshot` events based on data generated by invoking [DocumentSnapshot.toJSON()](./firestore_.documentsnapshot.md#documentsnapshottojson) You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. + +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. + +Signature: + +```typescript +export declare function onSnapshotResume(firestore: Firestore, snapshotJson: object, observer: { + next: (snapshot: DocumentSnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; +}, converter?: FirestoreDataConverter): Unsubscribe; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to enable the listener for. | +| snapshotJson | object | A JSON object generated by invoking [DocumentSnapshot.toJSON()](./firestore_.documentsnapshot.md#documentsnapshottojson). | +| observer | { next: (snapshot: [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | +| converter | [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface)<DbModelType> | An optional object that converts objects from Firestore before the onNext listener is invoked. | + +Returns: + +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) + +An unsubscribe function that can be called to cancel the snapshot listener. + +### onSnapshotResume(firestore, snapshotJson, options, observer, converter) {:#onsnapshotresume_fb80adf} + +Attaches a listener for `QuerySnapshot` events based on QuerySnapshot data generated by invoking [QuerySnapshot.toJSON()](./firestore_.querysnapshot.md#querysnapshottojson) You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. + +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. + +Signature: + +```typescript +export declare function onSnapshotResume(firestore: Firestore, snapshotJson: object, options: SnapshotListenOptions, observer: { + next: (snapshot: QuerySnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; +}, converter?: FirestoreDataConverter): Unsubscribe; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to enable the listener for. | +| snapshotJson | object | A JSON object generated by invoking [QuerySnapshot.toJSON()](./firestore_.querysnapshot.md#querysnapshottojson). | +| options | [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | Options controlling the listen behavior. | +| observer | { next: (snapshot: [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | +| converter | [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface)<DbModelType> | An optional object that converts objects from Firestore before the onNext listener is invoked. | + +Returns: + +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) + +An unsubscribe function that can be called to cancel the snapshot listener. + +### onSnapshotResume(firestore, snapshotJson, options, observer, converter) {:#onsnapshotresume_f76d912} + +Attaches a listener for `DocumentSnapshot` events based on QuerySnapshot data generated by invoking [DocumentSnapshot.toJSON()](./firestore_.documentsnapshot.md#documentsnapshottojson) You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. + +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. + +Signature: + +```typescript +export declare function onSnapshotResume(firestore: Firestore, snapshotJson: object, options: SnapshotListenOptions, observer: { + next: (snapshot: DocumentSnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; +}, converter?: FirestoreDataConverter): Unsubscribe; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to enable the listener for. | +| snapshotJson | object | A JSON object generated by invoking [DocumentSnapshot.toJSON()](./firestore_.documentsnapshot.md#documentsnapshottojson). | +| options | [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | Options controlling the listen behavior. | +| observer | { next: (snapshot: [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | +| converter | [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface)<DbModelType> | An optional object that converts objects from Firestore before the onNext listener is invoked. | + +Returns: + +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) + +An unsubscribe function that can be called to cancel the snapshot listener. + ### onSnapshotsInSync(firestore, observer) {:#onsnapshotsinsync_2f0dfa4} Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync event indicates that all listeners affected by a given change have fired, even if a single server-generated change affects multiple listeners. diff --git a/docs-devsite/firestore_.querysnapshot.md b/docs-devsite/firestore_.querysnapshot.md index d9930c68d90..b574320c8c4 100644 --- a/docs-devsite/firestore_.querysnapshot.md +++ b/docs-devsite/firestore_.querysnapshot.md @@ -34,6 +34,7 @@ export declare class QuerySnapshotQuerySnapshot. | +| [toJSON()](./firestore_.querysnapshot.md#querysnapshottojson) | | Returns a JSON-serializable representation of this QuerySnapshot instance. | ## QuerySnapshot.docs @@ -126,3 +127,18 @@ forEach(callback: (result: QueryDocumentSnapshot) => void +## QuerySnapshot.toJSON() + +Returns a JSON-serializable representation of this `QuerySnapshot` instance. + +Signature: + +```typescript +toJSON(): object; +``` +Returns: + +object + +a JSON representation of this object. Throws a [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) if this `QuerySnapshot` has pending writes. + diff --git a/docs-devsite/firestore_.timestamp.md b/docs-devsite/firestore_.timestamp.md index 6f7a7dd011b..9d7282e5a2a 100644 --- a/docs-devsite/firestore_.timestamp.md +++ b/docs-devsite/firestore_.timestamp.md @@ -40,6 +40,7 @@ export declare class Timestamp | Method | Modifiers | Description | | --- | --- | --- | | [fromDate(date)](./firestore_.timestamp.md#timestampfromdate) | static | Creates a new timestamp from the given date. | +| [fromJSON(json)](./firestore_.timestamp.md#timestampfromjson) | static | Builds a Timestamp instance from a JSON object created by [Timestamp.toJSON()](./firestore_.timestamp.md#timestamptojson). | | [fromMillis(milliseconds)](./firestore_.timestamp.md#timestampfrommillis) | static | Creates a new timestamp from the given number of milliseconds. | | [isEqual(other)](./firestore_.timestamp.md#timestampisequal) | | Returns true if this Timestamp is equal to the provided one. | | [now()](./firestore_.timestamp.md#timestampnow) | static | Creates a new timestamp with the current date, with millisecond precision. | @@ -110,6 +111,26 @@ static fromDate(date: Date): Timestamp; A new `Timestamp` representing the same point in time as the given date. +## Timestamp.fromJSON() + +Builds a `Timestamp` instance from a JSON object created by [Timestamp.toJSON()](./firestore_.timestamp.md#timestamptojson). + +Signature: + +```typescript +static fromJSON(json: object): Timestamp; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| json | object | | + +Returns: + +[Timestamp](./firestore_.timestamp.md#timestamp_class) + ## Timestamp.fromMillis() Creates a new timestamp from the given number of milliseconds. @@ -194,11 +215,12 @@ Returns a JSON-serializable representation of this `Timestamp`. toJSON(): { seconds: number; nanoseconds: number; + type: string; }; ``` Returns: -{ seconds: number; nanoseconds: number; } +{ seconds: number; nanoseconds: number; type: string; } ## Timestamp.toMillis() diff --git a/docs-devsite/firestore_.vectorvalue.md b/docs-devsite/firestore_.vectorvalue.md index e35e96ec9ec..1fc4e2b35ab 100644 --- a/docs-devsite/firestore_.vectorvalue.md +++ b/docs-devsite/firestore_.vectorvalue.md @@ -24,8 +24,32 @@ export declare class VectorValue | Method | Modifiers | Description | | --- | --- | --- | +| [fromJSON(json)](./firestore_.vectorvalue.md#vectorvaluefromjson) | static | Builds a VectorValue instance from a JSON object created by [VectorValue.toJSON()](./firestore_.vectorvalue.md#vectorvaluetojson). | | [isEqual(other)](./firestore_.vectorvalue.md#vectorvalueisequal) | | Returns true if the two VectorValue values have the same raw number arrays, returns false otherwise. | | [toArray()](./firestore_.vectorvalue.md#vectorvaluetoarray) | | Returns a copy of the raw number array form of the vector. | +| [toJSON()](./firestore_.vectorvalue.md#vectorvaluetojson) | | Returns a JSON-serializable representation of this VectorValue instance. | + +## VectorValue.fromJSON() + +Builds a `VectorValue` instance from a JSON object created by [VectorValue.toJSON()](./firestore_.vectorvalue.md#vectorvaluetojson). + +Signature: + +```typescript +static fromJSON(json: object): VectorValue; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| json | object | a JSON object represention of a VectorValue instance. | + +Returns: + +[VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) + +an instance of [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) if the JSON object could be parsed. Throws a [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) if an error occurs. ## VectorValue.isEqual() @@ -60,3 +84,18 @@ toArray(): number[]; number\[\] +## VectorValue.toJSON() + +Returns a JSON-serializable representation of this `VectorValue` instance. + +Signature: + +```typescript +toJSON(): object; +``` +Returns: + +object + +a JSON representation of this object. + diff --git a/docs-devsite/firestore_lite.bytes.md b/docs-devsite/firestore_lite.bytes.md index 51cfb0a9bf0..a26734f90bf 100644 --- a/docs-devsite/firestore_lite.bytes.md +++ b/docs-devsite/firestore_lite.bytes.md @@ -23,9 +23,11 @@ export declare class Bytes | Method | Modifiers | Description | | --- | --- | --- | | [fromBase64String(base64)](./firestore_lite.bytes.md#bytesfrombase64string) | static | Creates a new Bytes object from the given Base64 string, converting it to bytes. | +| [fromJSON(json)](./firestore_lite.bytes.md#bytesfromjson) | static | Builds a Bytes instance from a JSON object created by [Bytes.toJSON()](./firestore_.bytes.md#bytestojson). | | [fromUint8Array(array)](./firestore_lite.bytes.md#bytesfromuint8array) | static | Creates a new Bytes object from the given Uint8Array. | | [isEqual(other)](./firestore_lite.bytes.md#bytesisequal) | | Returns true if this Bytes object is equal to the provided one. | | [toBase64()](./firestore_lite.bytes.md#bytestobase64) | | Returns the underlying bytes as a Base64-encoded string. | +| [toJSON()](./firestore_lite.bytes.md#bytestojson) | | Returns a JSON-serializable representation of this Bytes instance. | | [toString()](./firestore_lite.bytes.md#bytestostring) | | Returns a string representation of the Bytes object. | | [toUint8Array()](./firestore_lite.bytes.md#bytestouint8array) | | Returns the underlying bytes in a new Uint8Array. | @@ -49,6 +51,28 @@ static fromBase64String(base64: string): Bytes; [Bytes](./firestore_lite.bytes.md#bytes_class) +## Bytes.fromJSON() + +Builds a `Bytes` instance from a JSON object created by [Bytes.toJSON()](./firestore_.bytes.md#bytestojson). + +Signature: + +```typescript +static fromJSON(json: object): Bytes; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| json | object | a JSON object represention of a Bytes instance | + +Returns: + +[Bytes](./firestore_lite.bytes.md#bytes_class) + +an instance of [Bytes](./firestore_.bytes.md#bytes_class) if the JSON object could be parsed. Throws a [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) if an error occurs. + ## Bytes.fromUint8Array() Creates a new `Bytes` object from the given Uint8Array. @@ -106,6 +130,21 @@ string The Base64-encoded string created from the `Bytes` object. +## Bytes.toJSON() + +Returns a JSON-serializable representation of this `Bytes` instance. + +Signature: + +```typescript +toJSON(): object; +``` +Returns: + +object + +a JSON representation of this object. + ## Bytes.toString() Returns a string representation of the `Bytes` object. diff --git a/docs-devsite/firestore_lite.documentreference.md b/docs-devsite/firestore_lite.documentreference.md index 2239850b829..2a09e2e5964 100644 --- a/docs-devsite/firestore_lite.documentreference.md +++ b/docs-devsite/firestore_lite.documentreference.md @@ -33,6 +33,9 @@ export declare class DocumentReferencestatic | Builds a DocumentReference instance from a JSON object created by [DocumentReference.toJSON()](./firestore_.documentreference.md#documentreferencetojson). | +| [fromJSON(firestore, json, converter)](./firestore_lite.documentreference.md#documentreferencefromjson) | static | Builds a DocumentReference instance from a JSON object created by [DocumentReference.toJSON()](./firestore_.documentreference.md#documentreferencetojson). | +| [toJSON()](./firestore_lite.documentreference.md#documentreferencetojson) | | Returns a JSON-serializable representation of this DocumentReference instance. | | [withConverter(converter)](./firestore_lite.documentreference.md#documentreferencewithconverter) | | Applies a custom data converter to this DocumentReference, allowing you to use your own custom model objects with Firestore. When you call [setDoc()](./firestore_lite.md#setdoc_ee215ad), [getDoc()](./firestore_lite.md#getdoc_4569087), etc. with the returned DocumentReference instance, the provided converter will convert between Firestore data of type NewDbModelType and your custom type NewAppModelType. | | [withConverter(converter)](./firestore_lite.documentreference.md#documentreferencewithconverter) | | Removes the current converter. | @@ -96,6 +99,68 @@ The type of this Firestore reference. readonly type = "document"; ``` +## DocumentReference.fromJSON() + +Builds a `DocumentReference` instance from a JSON object created by [DocumentReference.toJSON()](./firestore_.documentreference.md#documentreferencetojson). + +Signature: + +```typescript +static fromJSON(firestore: Firestore, json: object): DocumentReference; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance the snapshot should be loaded for. | +| json | object | a JSON object represention of a DocumentReference instance | + +Returns: + +[DocumentReference](./firestore_lite.documentreference.md#documentreference_class) + +an instance of [DocumentReference](./firestore_.documentreference.md#documentreference_class) if the JSON object could be parsed. Throws a [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) if an error occurs. + +## DocumentReference.fromJSON() + +Builds a `DocumentReference` instance from a JSON object created by [DocumentReference.toJSON()](./firestore_.documentreference.md#documentreferencetojson). + +Signature: + +```typescript +static fromJSON(firestore: Firestore, json: object, converter: FirestoreDataConverter): DocumentReference; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance the snapshot should be loaded for. | +| json | object | a JSON object represention of a DocumentReference instance | +| converter | [FirestoreDataConverter](./firestore_lite.firestoredataconverter.md#firestoredataconverter_interface)<NewAppModelType, NewDbModelType> | Converts objects to and from Firestore. | + +Returns: + +[DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<NewAppModelType, NewDbModelType> + +an instance of [DocumentReference](./firestore_.documentreference.md#documentreference_class) if the JSON object could be parsed. Throws a [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) if an error occurs. + +## DocumentReference.toJSON() + +Returns a JSON-serializable representation of this `DocumentReference` instance. + +Signature: + +```typescript +toJSON(): object; +``` +Returns: + +object + +a JSON representation of this object. + ## DocumentReference.withConverter() Applies a custom data converter to this `DocumentReference`, allowing you to use your own custom model objects with Firestore. When you call [setDoc()](./firestore_lite.md#setdoc_ee215ad), [getDoc()](./firestore_lite.md#getdoc_4569087), etc. with the returned `DocumentReference` instance, the provided converter will convert between Firestore data of type `NewDbModelType` and your custom type `NewAppModelType`. diff --git a/docs-devsite/firestore_lite.geopoint.md b/docs-devsite/firestore_lite.geopoint.md index fdd760520c8..6b3396107d2 100644 --- a/docs-devsite/firestore_lite.geopoint.md +++ b/docs-devsite/firestore_lite.geopoint.md @@ -37,8 +37,9 @@ export declare class GeoPoint | Method | Modifiers | Description | | --- | --- | --- | +| [fromJSON(json)](./firestore_lite.geopoint.md#geopointfromjson) | static | Builds a GeoPoint instance from a JSON object created by [GeoPoint.toJSON()](./firestore_.geopoint.md#geopointtojson). | | [isEqual(other)](./firestore_lite.geopoint.md#geopointisequal) | | Returns true if this GeoPoint is equal to the provided one. | -| [toJSON()](./firestore_lite.geopoint.md#geopointtojson) | | Returns a JSON-serializable representation of this GeoPoint. | +| [toJSON()](./firestore_lite.geopoint.md#geopointtojson) | | Returns a JSON-serializable representation of this GeoPoint instance. | ## GeoPoint.(constructor) @@ -77,6 +78,28 @@ The longitude of this `GeoPoint` instance. get longitude(): number; ``` +## GeoPoint.fromJSON() + +Builds a `GeoPoint` instance from a JSON object created by [GeoPoint.toJSON()](./firestore_.geopoint.md#geopointtojson). + +Signature: + +```typescript +static fromJSON(json: object): GeoPoint; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| json | object | a JSON object represention of a GeoPoint instance | + +Returns: + +[GeoPoint](./firestore_lite.geopoint.md#geopoint_class) + +an instance of [GeoPoint](./firestore_.geopoint.md#geopoint_class) if the JSON object could be parsed. Throws a [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) if an error occurs. + ## GeoPoint.isEqual() Returns true if this `GeoPoint` is equal to the provided one. @@ -101,7 +124,7 @@ true if this `GeoPoint` is equal to the provided one. ## GeoPoint.toJSON() -Returns a JSON-serializable representation of this GeoPoint. +Returns a JSON-serializable representation of this `GeoPoint` instance. Signature: @@ -109,9 +132,12 @@ Returns a JSON-serializable representation of this GeoPoint. toJSON(): { latitude: number; longitude: number; + type: string; }; ``` Returns: -{ latitude: number; longitude: number; } +{ latitude: number; longitude: number; type: string; } + +a JSON representation of this object. diff --git a/docs-devsite/firestore_lite.timestamp.md b/docs-devsite/firestore_lite.timestamp.md index 506a6c66ade..0fb35ada682 100644 --- a/docs-devsite/firestore_lite.timestamp.md +++ b/docs-devsite/firestore_lite.timestamp.md @@ -40,6 +40,7 @@ export declare class Timestamp | Method | Modifiers | Description | | --- | --- | --- | | [fromDate(date)](./firestore_lite.timestamp.md#timestampfromdate) | static | Creates a new timestamp from the given date. | +| [fromJSON(json)](./firestore_lite.timestamp.md#timestampfromjson) | static | Builds a Timestamp instance from a JSON object created by [Timestamp.toJSON()](./firestore_.timestamp.md#timestamptojson). | | [fromMillis(milliseconds)](./firestore_lite.timestamp.md#timestampfrommillis) | static | Creates a new timestamp from the given number of milliseconds. | | [isEqual(other)](./firestore_lite.timestamp.md#timestampisequal) | | Returns true if this Timestamp is equal to the provided one. | | [now()](./firestore_lite.timestamp.md#timestampnow) | static | Creates a new timestamp with the current date, with millisecond precision. | @@ -110,6 +111,26 @@ static fromDate(date: Date): Timestamp; A new `Timestamp` representing the same point in time as the given date. +## Timestamp.fromJSON() + +Builds a `Timestamp` instance from a JSON object created by [Timestamp.toJSON()](./firestore_.timestamp.md#timestamptojson). + +Signature: + +```typescript +static fromJSON(json: object): Timestamp; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| json | object | | + +Returns: + +[Timestamp](./firestore_lite.timestamp.md#timestamp_class) + ## Timestamp.fromMillis() Creates a new timestamp from the given number of milliseconds. @@ -194,11 +215,12 @@ Returns a JSON-serializable representation of this `Timestamp`. toJSON(): { seconds: number; nanoseconds: number; + type: string; }; ``` Returns: -{ seconds: number; nanoseconds: number; } +{ seconds: number; nanoseconds: number; type: string; } ## Timestamp.toMillis() diff --git a/docs-devsite/firestore_lite.vectorvalue.md b/docs-devsite/firestore_lite.vectorvalue.md index 28eaf7f5f01..17c18e4c4ed 100644 --- a/docs-devsite/firestore_lite.vectorvalue.md +++ b/docs-devsite/firestore_lite.vectorvalue.md @@ -24,8 +24,32 @@ export declare class VectorValue | Method | Modifiers | Description | | --- | --- | --- | +| [fromJSON(json)](./firestore_lite.vectorvalue.md#vectorvaluefromjson) | static | Builds a VectorValue instance from a JSON object created by [VectorValue.toJSON()](./firestore_.vectorvalue.md#vectorvaluetojson). | | [isEqual(other)](./firestore_lite.vectorvalue.md#vectorvalueisequal) | | Returns true if the two VectorValue values have the same raw number arrays, returns false otherwise. | | [toArray()](./firestore_lite.vectorvalue.md#vectorvaluetoarray) | | Returns a copy of the raw number array form of the vector. | +| [toJSON()](./firestore_lite.vectorvalue.md#vectorvaluetojson) | | Returns a JSON-serializable representation of this VectorValue instance. | + +## VectorValue.fromJSON() + +Builds a `VectorValue` instance from a JSON object created by [VectorValue.toJSON()](./firestore_.vectorvalue.md#vectorvaluetojson). + +Signature: + +```typescript +static fromJSON(json: object): VectorValue; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| json | object | a JSON object represention of a VectorValue instance. | + +Returns: + +[VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) + +an instance of [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) if the JSON object could be parsed. Throws a [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) if an error occurs. ## VectorValue.isEqual() @@ -60,3 +84,18 @@ toArray(): number[]; number\[\] +## VectorValue.toJSON() + +Returns a JSON-serializable representation of this `VectorValue` instance. + +Signature: + +```typescript +toJSON(): object; +``` +Returns: + +object + +a JSON representation of this object. + diff --git a/e2e/README.md b/e2e/README.md index b2674506e8b..25223edb371 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -1,92 +1,11 @@ -# Firebase JS SDK E2E Tests +# E2E Tests -This directory contains end-to-end tests for the Firebase JS SDK package as well as minimal quick start sample apps for debugging and development. +This directory is for Firebase E2E tests that are completely independent of the main SDK workspaces. Packages in here should: -## E2E Tests +* Have a start trigger independent of the main CI PR/push triggers (e.g., manual trigger, repository_dispatch, from an external runner like Kokoro, etc.) + + A common use case might be to clone this repo, cd into the chosen directory under e2e, npm install, and run npm scripts. -### Setup +* Have a self-contained set of NPM dependencies. They should not depend on the local version of Firebase in the SDK nor assume inherited availability of any packages in the top level package.json of this repo (typescript, firebase, karma, etc.). -Before running the tests, you will need: - -- a project config -- a test user with an email/password login which has read/write privileges for Storage, Realtime Database, and Firestore -- an App Check debug token -- to deploy the `callTest` Cloud Function - -#### Project Config and Test User - -Create a file named `firebase-config.js` in the top level of this `e2e/` directory. The contents of the file should be: - -```javascript -// A config for a project -export const config = { - apiKey: ************, - authDomain: ************, - databaseURL: ************, - projectId: ************, - storageBucket: ************, - messagingSenderId: ************, - appId: ************, - measurementId: ************ -}; - * -// A user account with read/write privileges in that project -// for storage, database, firestore -export const testAccount = { - email: ************, - password: ************ -} -``` - -#### App Check Debug Token - -Create an App Check debug token in the Firebase Console. Assign it to an environment variable in your shell named `APP_CHECK_DEBUG_TOKEN`. - -#### Deploy `callTest` Cloud Function - -From the top level of the firebase repo, ensure you have the Firebase CLI (`firebase-tools`) installed (if not, `npm install -g firebase-tools`). - -Ensure you are logged in using the CLI (`firebase login`); - -Then deploy the function with: -`firebase deploy --only functions:callTest --project YOUR_PROJECT_ID` - -### Running the Tests - -To run the tests on the default modular API: - -``` -yarn test:modular -``` - -To run the tests on the compat API: - -``` -yarn test:compat -``` - -## Sample Apps - -Two minimal sample apps are provided for quick debugging and development. These apps import and initialize every product in the SDK and call some basic methods. Products can easily be commented out to focus on one or more products you are interested in looking at. - -### Setup - -The setup is the same as for the E2E tests above. Certain tests can be skipped if you are commenting out that product (e.g, no need to deploy the Cloud Function if you are commenting out the `callFunctions()` line in the sample app, and no need to set the App Check debug token env variable if not using App Check). - -### Running Sample Apps - -To run the modular sample app (uses current default version of the API): - -``` -yarn start:modular -``` - -Then open `localhost:8080` in a browser. - -To run the compat sample app (uses current compat version of the API): - -``` -yarn start:compat -``` - -Then open `localhost:8080` in a browser. \ No newline at end of file +See the `template/` directory for an example. \ No newline at end of file diff --git a/e2e/data-connect/dataconnect-generated/js/default-connector/README.md b/e2e/data-connect/dataconnect-generated/js/default-connector/README.md new file mode 100644 index 00000000000..b3f5971d704 --- /dev/null +++ b/e2e/data-connect/dataconnect-generated/js/default-connector/README.md @@ -0,0 +1,257 @@ +# Table of Contents +- [**Overview**](#generated-typescript-readme) +- [**Accessing the connector**](#accessing-the-connector) + - [*Connecting to the local Emulator*](#connecting-to-the-local-emulator) +- [**Queries**](#queries) + - [*ListMovies*](#listmovies) +- [**Mutations**](#mutations) + - [*CreateMovie*](#createmovie) + +# Generated TypeScript README +This README will guide you through the process of using the generated TypeScript SDK package for the connector `default`. It will also provide examples on how to use your generated SDK to call your Data Connect queries and mutations. + +***NOTE:** This README is generated alongside the generated SDK. If you make changes to this file, they will be overwritten when the SDK is regenerated.* + +You can use this generated SDK by importing from the package `@firebasegen/default-connector` as shown below. Both CommonJS and ESM imports are supported. + +You can also follow the instructions from the [Data Connect documentation](https://firebase.google.com/docs/data-connect/web-sdk#set-client). + +# Accessing the connector +A connector is a collection of Queries and Mutations. One SDK is generated for each connector - this SDK is generated for the connector `default`. + +You can find more information about connectors in the [Data Connect documentation](https://firebase.google.com/docs/data-connect#how-does). + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig } from '@firebasegen/default-connector'; + +const dataConnect = getDataConnect(connectorConfig); +``` + +## Connecting to the local Emulator +By default, the connector will connect to the production service. + +To connect to the emulator, you can use the following code. +You can also follow the emulator instructions from the [Data Connect documentation](https://firebase.google.com/docs/data-connect/web-sdk#instrument-clients). + +```javascript +import { connectDataConnectEmulator, getDataConnect } from 'firebase/data-connect'; +import { connectorConfig } from '@firebasegen/default-connector'; + +const dataConnect = getDataConnect(connectorConfig); +connectDataConnectEmulator(dataConnect, 'localhost', 9399); +``` + +After it's initialized, you can call your Data Connect [queries](#queries) and [mutations](#mutations) from your generated SDK. + +# Queries + +There are two ways to execute a Data Connect Query using the generated Web SDK: +- Using a Query Reference function, which returns a `QueryRef` + - The `QueryRef` can be used as an argument to `executeQuery()`, which will execute the Query and return a `QueryPromise` +- Using an action shortcut function, which returns a `QueryPromise` + - Calling the action shortcut function will execute the Query and return a `QueryPromise` + +The following is true for both the action shortcut function and the `QueryRef` function: +- The `QueryPromise` returned will resolve to the result of the Query once it has finished executing +- If the Query accepts arguments, both the action shortcut function and the `QueryRef` function accept a single argument: an object that contains all the required variables (and the optional variables) for the Query +- Both functions can be called with or without passing in a `DataConnect` instance as an argument. If no `DataConnect` argument is passed in, then the generated SDK will call `getDataConnect(connectorConfig)` behind the scenes for you. + +Below are examples of how to use the `default` connector's generated functions to execute each query. You can also follow the examples from the [Data Connect documentation](https://firebase.google.com/docs/data-connect/web-sdk#using-queries). + +## ListMovies +You can execute the `ListMovies` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [default-connector/index.d.ts](./index.d.ts): +```javascript +listMovies(): QueryPromise; + +listMoviesRef(): QueryRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. +```javascript +listMovies(dc: DataConnect): QueryPromise; + +listMoviesRef(dc: DataConnect): QueryRef; +``` + +### Variables +The `ListMovies` query has no variables. +### Return Type +Recall that executing the `ListMovies` query returns a `QueryPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `ListMoviesData`, which is defined in [default-connector/index.d.ts](./index.d.ts). It has the following fields: +```javascript +export interface ListMoviesData { + movies: ({ + id: UUIDString; + title: string; + imageUrl: string; + genre?: string | null; + } & Movie_Key)[]; +} +``` +### Using `ListMovies`'s action shortcut function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, listMovies } from '@firebasegen/default-connector'; + + +// Call the `listMovies()` function to execute the query. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await listMovies(); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await listMovies(dataConnect); + +console.log(data.movies); + +// Or, you can use the `Promise` API. +listMovies().then((response) => { + const data = response.data; + console.log(data.movies); +}); +``` + +### Using `ListMovies`'s `QueryRef` function + +```javascript +import { getDataConnect, executeQuery } from 'firebase/data-connect'; +import { connectorConfig, listMoviesRef } from '@firebasegen/default-connector'; + + +// Call the `listMoviesRef()` function to get a reference to the query. +const ref = listMoviesRef(); + +// You can also pass in a `DataConnect` instance to the `QueryRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = listMoviesRef(dataConnect); + +// Call `executeQuery()` on the reference to execute the query. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await executeQuery(ref); + +console.log(data.movies); + +// Or, you can use the `Promise` API. +executeQuery(ref).then((response) => { + const data = response.data; + console.log(data.movies); +}); +``` + +# Mutations + +There are two ways to execute a Data Connect Mutation using the generated Web SDK: +- Using a Mutation Reference function, which returns a `MutationRef` + - The `MutationRef` can be used as an argument to `executeMutation()`, which will execute the Mutation and return a `MutationPromise` +- Using an action shortcut function, which returns a `MutationPromise` + - Calling the action shortcut function will execute the Mutation and return a `MutationPromise` + +The following is true for both the action shortcut function and the `MutationRef` function: +- The `MutationPromise` returned will resolve to the result of the Mutation once it has finished executing +- If the Mutation accepts arguments, both the action shortcut function and the `MutationRef` function accept a single argument: an object that contains all the required variables (and the optional variables) for the Mutation +- Both functions can be called with or without passing in a `DataConnect` instance as an argument. If no `DataConnect` argument is passed in, then the generated SDK will call `getDataConnect(connectorConfig)` behind the scenes for you. + +Below are examples of how to use the `default` connector's generated functions to execute each mutation. You can also follow the examples from the [Data Connect documentation](https://firebase.google.com/docs/data-connect/web-sdk#using-mutations). + +## CreateMovie +You can execute the `CreateMovie` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [default-connector/index.d.ts](./index.d.ts): +```javascript +createMovie(vars: CreateMovieVariables): MutationPromise; + +createMovieRef(vars: CreateMovieVariables): MutationRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. +```javascript +createMovie(dc: DataConnect, vars: CreateMovieVariables): MutationPromise; + +createMovieRef(dc: DataConnect, vars: CreateMovieVariables): MutationRef; +``` + +### Variables +The `CreateMovie` mutation requires an argument of type `CreateMovieVariables`, which is defined in [default-connector/index.d.ts](./index.d.ts). It has the following fields: + +```javascript +export interface CreateMovieVariables { + title: string; + genre: string; + imageUrl: string; +} +``` +### Return Type +Recall that executing the `CreateMovie` mutation returns a `MutationPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `CreateMovieData`, which is defined in [default-connector/index.d.ts](./index.d.ts). It has the following fields: +```javascript +export interface CreateMovieData { + movie_insert: Movie_Key; +} +``` +### Using `CreateMovie`'s action shortcut function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, createMovie, CreateMovieVariables } from '@firebasegen/default-connector'; + +// The `CreateMovie` mutation requires an argument of type `CreateMovieVariables`: +const createMovieVars: CreateMovieVariables = { + title: ..., + genre: ..., + imageUrl: ..., +}; + +// Call the `createMovie()` function to execute the mutation. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await createMovie(createMovieVars); +// Variables can be defined inline as well. +const { data } = await createMovie({ title: ..., genre: ..., imageUrl: ..., }); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await createMovie(dataConnect, createMovieVars); + +console.log(data.movie_insert); + +// Or, you can use the `Promise` API. +createMovie(createMovieVars).then((response) => { + const data = response.data; + console.log(data.movie_insert); +}); +``` + +### Using `CreateMovie`'s `MutationRef` function + +```javascript +import { getDataConnect, executeMutation } from 'firebase/data-connect'; +import { connectorConfig, createMovieRef, CreateMovieVariables } from '@firebasegen/default-connector'; + +// The `CreateMovie` mutation requires an argument of type `CreateMovieVariables`: +const createMovieVars: CreateMovieVariables = { + title: ..., + genre: ..., + imageUrl: ..., +}; + +// Call the `createMovieRef()` function to get a reference to the mutation. +const ref = createMovieRef(createMovieVars); +// Variables can be defined inline as well. +const ref = createMovieRef({ title: ..., genre: ..., imageUrl: ..., }); + +// You can also pass in a `DataConnect` instance to the `MutationRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = createMovieRef(dataConnect, createMovieVars); + +// Call `executeMutation()` on the reference to execute the mutation. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await executeMutation(ref); + +console.log(data.movie_insert); + +// Or, you can use the `Promise` API. +executeMutation(ref).then((response) => { + const data = response.data; + console.log(data.movie_insert); +}); +``` + diff --git a/e2e/data-connect/dataconnect-generated/js/default-connector/esm/index.esm.js b/e2e/data-connect/dataconnect-generated/js/default-connector/esm/index.esm.js new file mode 100644 index 00000000000..e88d2d56d35 --- /dev/null +++ b/e2e/data-connect/dataconnect-generated/js/default-connector/esm/index.esm.js @@ -0,0 +1,55 @@ +/** + * @license + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + queryRef, + executeQuery, + mutationRef, + executeMutation, + validateArgs +} from 'firebase/data-connect'; + +export const connectorConfig = { + connector: 'default', + service: 'fdc-test', + location: 'us-central1' +}; + +export function createMovieRef(dcOrVars, vars) { + const { dc: dcInstance, vars: inputVars } = validateArgs( + connectorConfig, + dcOrVars, + vars, + true + ); + dcInstance._useGeneratedSdk(); + return mutationRef(dcInstance, 'CreateMovie', inputVars); +} + +export function createMovie(dcOrVars, vars) { + return executeMutation(createMovieRef(dcOrVars, vars)); +} + +export function listMoviesRef(dc) { + const { dc: dcInstance } = validateArgs(connectorConfig, dc, undefined); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'ListMovies'); +} + +export function listMovies(dc) { + return executeQuery(listMoviesRef(dc)); +} diff --git a/e2e/data-connect/dataconnect-generated/js/default-connector/esm/package.json b/e2e/data-connect/dataconnect-generated/js/default-connector/esm/package.json new file mode 100644 index 00000000000..7c34deb5837 --- /dev/null +++ b/e2e/data-connect/dataconnect-generated/js/default-connector/esm/package.json @@ -0,0 +1 @@ +{"type":"module"} \ No newline at end of file diff --git a/e2e/data-connect/dataconnect-generated/js/default-connector/index.cjs.js b/e2e/data-connect/dataconnect-generated/js/default-connector/index.cjs.js new file mode 100644 index 00000000000..814406ff090 --- /dev/null +++ b/e2e/data-connect/dataconnect-generated/js/default-connector/index.cjs.js @@ -0,0 +1,56 @@ +/** + * @license + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const { + queryRef, + executeQuery, + mutationRef, + executeMutation, + validateArgs +} = require('firebase/data-connect'); + +const connectorConfig = { + connector: 'default', + service: 'fdc-test', + location: 'us-central1' +}; +exports.connectorConfig = connectorConfig; + +exports.createMovieRef = function createMovieRef(dcOrVars, vars) { + const { dc: dcInstance, vars: inputVars } = validateArgs( + connectorConfig, + dcOrVars, + vars, + true + ); + dcInstance._useGeneratedSdk(); + return mutationRef(dcInstance, 'CreateMovie', inputVars); +}; + +exports.createMovie = function createMovie(dcOrVars, vars) { + return executeMutation(createMovieRef(dcOrVars, vars)); +}; + +exports.listMoviesRef = function listMoviesRef(dc) { + const { dc: dcInstance } = validateArgs(connectorConfig, dc, undefined); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'ListMovies'); +}; + +exports.listMovies = function listMovies(dc) { + return executeQuery(listMoviesRef(dc)); +}; diff --git a/e2e/data-connect/dataconnect-generated/js/default-connector/index.d.ts b/e2e/data-connect/dataconnect-generated/js/default-connector/index.d.ts new file mode 100644 index 00000000000..474fefd0f4b --- /dev/null +++ b/e2e/data-connect/dataconnect-generated/js/default-connector/index.d.ts @@ -0,0 +1,86 @@ +/** + * @license + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + ConnectorConfig, + DataConnect, + QueryRef, + QueryPromise, + MutationRef, + MutationPromise +} from 'firebase/data-connect'; + +export const connectorConfig: ConnectorConfig; + +export type TimestampString = string; +export type UUIDString = string; +export type Int64String = string; +export type DateString = string; + +export interface CreateMovieData { + movie_insert: Movie_Key; +} + +export interface CreateMovieVariables { + title: string; + genre: string; + imageUrl: string; +} + +export interface ListMoviesData { + movies: ({ + id: UUIDString; + title: string; + imageUrl: string; + genre?: string | null; + } & Movie_Key)[]; +} + +export interface Movie_Key { + id: UUIDString; + __typename?: 'Movie_Key'; +} + +/* Allow users to create refs without passing in DataConnect */ +export function createMovieRef( + vars: CreateMovieVariables +): MutationRef; +/* Allow users to pass in custom DataConnect instances */ +export function createMovieRef( + dc: DataConnect, + vars: CreateMovieVariables +): MutationRef; + +export function createMovie( + vars: CreateMovieVariables +): MutationPromise; +export function createMovie( + dc: DataConnect, + vars: CreateMovieVariables +): MutationPromise; + +/* Allow users to create refs without passing in DataConnect */ +export function listMoviesRef(): QueryRef; +/* Allow users to pass in custom DataConnect instances */ +export function listMoviesRef( + dc: DataConnect +): QueryRef; + +export function listMovies(): QueryPromise; +export function listMovies( + dc: DataConnect +): QueryPromise; diff --git a/e2e/data-connect/dataconnect-generated/js/default-connector/package.json b/e2e/data-connect/dataconnect-generated/js/default-connector/package.json new file mode 100644 index 00000000000..d0c9852ce3e --- /dev/null +++ b/e2e/data-connect/dataconnect-generated/js/default-connector/package.json @@ -0,0 +1,25 @@ +{ + "name": "@firebasegen/default-connector", + "version": "1.0.0", + "author": "Firebase (https://firebase.google.com/)", + "description": "Generated SDK For default", + "license": "Apache-2.0", + "engines": { + "node": " >=18.0" + }, + "typings": "index.d.ts", + "module": "esm/index.esm.js", + "main": "index.cjs.js", + "browser": "esm/index.esm.js", + "exports": { + ".": { + "types": "./index.d.ts", + "require": "./index.cjs.js", + "default": "./esm/index.esm.js" + }, + "./package.json": "./package.json" + }, + "peerDependencies": { + "firebase": "^10.14.0 || ^11.3.0" + } +} \ No newline at end of file diff --git a/e2e/data-connect/dataconnect/connector/connector.yaml b/e2e/data-connect/dataconnect/connector/connector.yaml new file mode 100644 index 00000000000..b698515fe9f --- /dev/null +++ b/e2e/data-connect/dataconnect/connector/connector.yaml @@ -0,0 +1,6 @@ +connectorId: default +generate: + javascriptSdk: + outputDir: ../../dataconnect-generated/js/default-connector + package: "@firebasegen/default-connector" +# packageJsonDir: ../.. diff --git a/e2e/data-connect/dataconnect/connector/mutations.gql b/e2e/data-connect/dataconnect/connector/mutations.gql new file mode 100644 index 00000000000..2379afeb89c --- /dev/null +++ b/e2e/data-connect/dataconnect/connector/mutations.gql @@ -0,0 +1,33 @@ +# # Example mutations for a simple movie app + +# # Create a movie based on user input +mutation CreateMovie($title: String!, $genre: String!, $imageUrl: String!) +@auth(level: USER_EMAIL_VERIFIED) { + movie_insert(data: { title: $title, genre: $genre, imageUrl: $imageUrl }) +} + +# # Upsert (update or insert) a user's username based on their auth.uid +# mutation UpsertUser($username: String!) @auth(level: USER) { +# # The "auth.uid" server value ensures that users can only register their own user. +# user_upsert(data: { id_expr: "auth.uid", username: $username }) +# } + +# # Add a review for a movie +# mutation AddReview($movieId: UUID!, $rating: Int!, $reviewText: String!) +# @auth(level: USER) { +# review_upsert( +# data: { +# userId_expr: "auth.uid" +# movieId: $movieId +# rating: $rating +# reviewText: $reviewText +# # reviewDate defaults to today in the schema. No need to set it manually. +# } +# ) +# } + +# # Logged in user can delete their review for a movie +# mutation DeleteReview($movieId: UUID!) @auth(level: USER) { +# # The "auth.uid" server value ensures that users can only delete their own reviews. +# review_delete(key: { userId_expr: "auth.uid", movieId: $movieId }) +# } diff --git a/e2e/data-connect/dataconnect/connector/queries.gql b/e2e/data-connect/dataconnect/connector/queries.gql new file mode 100644 index 00000000000..cb1a6f630bc --- /dev/null +++ b/e2e/data-connect/dataconnect/connector/queries.gql @@ -0,0 +1,78 @@ +# # Example queries for a simple movie app. + +# # @auth() directives control who can call each operation. +# # Anyone should be able to list all movies, so the auth level is set to PUBLIC +query ListMovies @auth(level: PUBLIC) { + movies { + id + title + imageUrl + genre + } +} + +# # List all users, only admins should be able to list all users, so we use NO_ACCESS +# query ListUsers @auth(level: NO_ACCESS) { +# users { +# id +# username +# } +# } + +# # Logged in users can list all their reviews and movie titles associated with the review +# # Since the query uses the uid of the current authenticated user, we set auth level to USER +# query ListUserReviews @auth(level: USER) { +# user(key: { id_expr: "auth.uid" }) { +# id +# username +# # _on_ makes it easy to grab info from another table +# # Here, we use it to grab all the reviews written by the user. +# reviews: reviews_on_user { +# rating +# reviewDate +# reviewText +# movie { +# id +# title +# } +# } +# } +# } + +# # Get movie by id +# query GetMovieById($id: UUID!) @auth(level: PUBLIC) { +# movie(id: $id) { +# id +# title +# imageUrl +# genre +# metadata: movieMetadata_on_movie { +# rating +# releaseYear +# description +# } +# reviews: reviews_on_movie { +# reviewText +# reviewDate +# rating +# user { +# id +# username +# } +# } +# } +# } + +# # Search for movies, actors, and reviews +# query SearchMovie($titleInput: String, $genre: String) @auth(level: PUBLIC) { +# movies( +# where: { +# _and: [{ genre: { eq: $genre } }, { title: { contains: $titleInput } }] +# } +# ) { +# id +# title +# genre +# imageUrl +# } +# } diff --git a/e2e/data-connect/dataconnect/dataconnect.yaml b/e2e/data-connect/dataconnect/dataconnect.yaml new file mode 100644 index 00000000000..623fad3e209 --- /dev/null +++ b/e2e/data-connect/dataconnect/dataconnect.yaml @@ -0,0 +1,12 @@ +specVersion: "v1beta" +serviceId: "fdc-test" +location: "us-central1" +schema: + source: "./schema" + datasource: + postgresql: + database: "fdcdb" + cloudSql: + instanceId: "fdc-test-fdc" + # schemaValidation: "COMPATIBLE" +connectorDirs: ["./connector"] diff --git a/e2e/data-connect/dataconnect/schema/schema.gql b/e2e/data-connect/dataconnect/schema/schema.gql new file mode 100644 index 00000000000..f114d9a678a --- /dev/null +++ b/e2e/data-connect/dataconnect/schema/schema.gql @@ -0,0 +1,52 @@ +# # Example schema for simple movie review app + +# # User table is keyed by Firebase Auth UID. +# type User @table { +# # `@default(expr: "auth.uid")` sets it to Firebase Auth UID during insert and upsert. +# id: String! @default(expr: "auth.uid") +# username: String! @col(dataType: "varchar(50)") +# # The `user: User!` field in the Review table generates the following one-to-many query field. +# # reviews_on_user: [Review!]! +# # The `Review` join table the following many-to-many query field. +# # movies_via_Review: [Movie!]! +# } + +# # Movie is keyed by a randomly generated UUID. +type Movie @table { + # If you do not pass a 'key' to `@table`, Data Connect automatically adds the following 'id' column. + # Feel free to uncomment and customize it. + # id: UUID! @default(expr: "uuidV4()") + title: String! + imageUrl: String! + genre: String +} + +# # MovieMetadata is a metadata attached to a Movie. +# # Movie <-> MovieMetadata is a one-to-one relationship +# type MovieMetadata @table { +# # @unique ensures each Movie can only one MovieMetadata. +# movie: Movie! @unique +# # The movie field adds the following foreign key field. Feel free to uncomment and customize it. +# # movieId: UUID! +# rating: Float +# releaseYear: Int +# description: String +# } + +# # Reviews is a join table between User and Movie. +# # It has a composite primary keys `userUid` and `movieId`. +# # A user can leave reviews for many movies. A movie can have reviews from many users. +# # User <-> Review is a one-to-many relationship +# # Movie <-> Review is a one-to-many relationship +# # Movie <-> User is a many-to-many relationship +# type Review @table(name: "Reviews", key: ["movie", "user"]) { +# user: User! +# # The user field adds the following foreign key field. Feel free to uncomment and customize it. +# # userUid: String! +# movie: Movie! +# # The movie field adds the following foreign key field. Feel free to uncomment and customize it. +# # movieId: UUID! +# rating: Int +# reviewText: String +# reviewDate: Date! @default(expr: "request.time") +# } diff --git a/e2e/data-connect/dataconnect/test b/e2e/data-connect/dataconnect/test new file mode 100644 index 00000000000..e69de29bb2d diff --git a/e2e/data-connect/firebase-js-config.json b/e2e/data-connect/firebase-js-config.json new file mode 100644 index 00000000000..0e0dcd235c4 --- /dev/null +++ b/e2e/data-connect/firebase-js-config.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file diff --git a/e2e/data-connect/firebase.json b/e2e/data-connect/firebase.json new file mode 100644 index 00000000000..6c9ad90b440 --- /dev/null +++ b/e2e/data-connect/firebase.json @@ -0,0 +1,10 @@ +{ + "emulators": { + "dataconnect": { + "dataDir": "dataconnect/.dataconnect/pgliteData" + } + }, + "dataconnect": { + "source": "dataconnect" + } +} diff --git a/e2e/data-connect/package.json b/e2e/data-connect/package.json new file mode 100644 index 00000000000..d9d1f234ab1 --- /dev/null +++ b/e2e/data-connect/package.json @@ -0,0 +1,21 @@ +{ + "name": "firebase-dataconnect-kokoro-test", + "version": "1.0.0", + "description": "", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "build": "tsc" + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "@types/node": "18.19.83", + "ts-node": "^10.9.2", + "tslib": "^2.1.0", + "typescript": "5.5.4" + }, + "dependencies": { + "firebase": "11.8.1" + } +} diff --git a/e2e/data-connect/test.ts b/e2e/data-connect/test.ts new file mode 100644 index 00000000000..cc177b8e47c --- /dev/null +++ b/e2e/data-connect/test.ts @@ -0,0 +1,23 @@ +/** + * @license + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { listMovies } from './dataconnect-generated/js/default-connector'; +import * as json from './firebase-js-config.json'; +import { initializeApp } from 'firebase/app'; + +initializeApp(json); +listMovies(); diff --git a/e2e/data-connect/tsconfig.json b/e2e/data-connect/tsconfig.json new file mode 100644 index 00000000000..e3c427a3163 --- /dev/null +++ b/e2e/data-connect/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "target": "ES5", + "module": "CommonJS", + "resolveJsonModule": true, + "sourceMap": true, + "noEmit": true, + "skipLibCheck": false + } + } diff --git a/e2e/data-connect/yarn.lock b/e2e/data-connect/yarn.lock new file mode 100644 index 00000000000..d8d5a981fef --- /dev/null +++ b/e2e/data-connect/yarn.lock @@ -0,0 +1,814 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@cspotcode/source-map-support@^0.8.0": + version "0.8.1" + resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" + integrity sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw== + dependencies: + "@jridgewell/trace-mapping" "0.3.9" + +"@firebase/ai@1.3.0": + version "1.3.0" + resolved "https://registry.npmjs.org/@firebase/ai/-/ai-1.3.0.tgz#66b8edaa32d8e5d46c99be0efc337cbf034dffb7" + integrity sha512-qBxJTtl9hpgZr050kVFTRADX6I0Ss6mEQyp/JEkBgKwwxixKnaRNqEDGFba4OKNL7K8E4Y7LlA/ZW6L8aCKH4A== + dependencies: + "@firebase/app-check-interop-types" "0.3.3" + "@firebase/component" "0.6.17" + "@firebase/logger" "0.4.4" + "@firebase/util" "1.12.0" + tslib "^2.1.0" + +"@firebase/analytics-compat@0.2.22": + version "0.2.22" + resolved "https://registry.npmjs.org/@firebase/analytics-compat/-/analytics-compat-0.2.22.tgz#5ec880cf719642c233742ad805ba95e5b4dad999" + integrity sha512-VogWHgwkdYhjWKh8O1XU04uPrRaiDihkWvE/EMMmtWtaUtVALnpLnUurc3QtSKdPnvTz5uaIGKlW84DGtSPFbw== + dependencies: + "@firebase/analytics" "0.10.16" + "@firebase/analytics-types" "0.8.3" + "@firebase/component" "0.6.17" + "@firebase/util" "1.12.0" + tslib "^2.1.0" + +"@firebase/analytics-types@0.8.3": + version "0.8.3" + resolved "https://registry.yarnpkg.com/@firebase/analytics-types/-/analytics-types-0.8.3.tgz#d08cd39a6209693ca2039ba7a81570dfa6c1518f" + integrity sha512-VrIp/d8iq2g501qO46uGz3hjbDb8xzYMrbu8Tp0ovzIzrvJZ2fvmj649gTjge/b7cCCcjT0H37g1gVtlNhnkbg== + +"@firebase/analytics@0.10.16": + version "0.10.16" + resolved "https://registry.npmjs.org/@firebase/analytics/-/analytics-0.10.16.tgz#516f211465060008538fed46c7f78f0ea14dd549" + integrity sha512-cMtp19He7Fd6uaj/nDEul+8JwvJsN8aRSJyuA1QN3QrKvfDDp+efjVurJO61sJpkVftw9O9nNMdhFbRcTmTfRQ== + dependencies: + "@firebase/component" "0.6.17" + "@firebase/installations" "0.6.17" + "@firebase/logger" "0.4.4" + "@firebase/util" "1.12.0" + tslib "^2.1.0" + +"@firebase/app-check-compat@0.3.25": + version "0.3.25" + resolved "https://registry.npmjs.org/@firebase/app-check-compat/-/app-check-compat-0.3.25.tgz#03d1941dba78626bdacf544f9d1d48b451dbb49c" + integrity sha512-3zrsPZWAKfV7DVC20T2dgfjzjtQnSJS65OfMOiddMUtJL1S5i0nAZKsdX0bOEvvrd0SBIL8jYnfpfDeQRnhV3w== + dependencies: + "@firebase/app-check" "0.10.0" + "@firebase/app-check-types" "0.5.3" + "@firebase/component" "0.6.17" + "@firebase/logger" "0.4.4" + "@firebase/util" "1.12.0" + tslib "^2.1.0" + +"@firebase/app-check-interop-types@0.3.3": + version "0.3.3" + resolved "https://registry.yarnpkg.com/@firebase/app-check-interop-types/-/app-check-interop-types-0.3.3.tgz#ed9c4a4f48d1395ef378f007476db3940aa5351a" + integrity sha512-gAlxfPLT2j8bTI/qfe3ahl2I2YcBQ8cFIBdhAQA4I2f3TndcO+22YizyGYuttLHPQEpWkhmpFW60VCFEPg4g5A== + +"@firebase/app-check-types@0.5.3": + version "0.5.3" + resolved "https://registry.yarnpkg.com/@firebase/app-check-types/-/app-check-types-0.5.3.tgz#38ba954acf4bffe451581a32fffa20337f11d8e5" + integrity sha512-hyl5rKSj0QmwPdsAxrI5x1otDlByQ7bvNvVt8G/XPO2CSwE++rmSVf3VEhaeOR4J8ZFaF0Z0NDSmLejPweZ3ng== + +"@firebase/app-check@0.10.0": + version "0.10.0" + resolved "https://registry.npmjs.org/@firebase/app-check/-/app-check-0.10.0.tgz#dc833ead2b31930eee13b5c9eb028091c630d21b" + integrity sha512-AZlRlVWKcu8BH4Yf8B5EI8sOi2UNGTS8oMuthV45tbt6OVUTSQwFPIEboZzhNJNKY+fPsg7hH8vixUWFZ3lrhw== + dependencies: + "@firebase/component" "0.6.17" + "@firebase/logger" "0.4.4" + "@firebase/util" "1.12.0" + tslib "^2.1.0" + +"@firebase/app-compat@0.4.0": + version "0.4.0" + resolved "https://registry.npmjs.org/@firebase/app-compat/-/app-compat-0.4.0.tgz#4c908115b2a68756e4944ee8f9bc7042d8715f92" + integrity sha512-LjLUrzbUgTa/sCtPoLKT2C7KShvLVHS3crnU1Du02YxnGVLE0CUBGY/NxgfR/Zg84mEbj1q08/dgesojxjn0dA== + dependencies: + "@firebase/app" "0.13.0" + "@firebase/component" "0.6.17" + "@firebase/logger" "0.4.4" + "@firebase/util" "1.12.0" + tslib "^2.1.0" + +"@firebase/app-types@0.9.3": + version "0.9.3" + resolved "https://registry.yarnpkg.com/@firebase/app-types/-/app-types-0.9.3.tgz#8408219eae9b1fb74f86c24e7150a148460414ad" + integrity sha512-kRVpIl4vVGJ4baogMDINbyrIOtOxqhkZQg4jTq3l8Lw6WSk0xfpEYzezFu+Kl4ve4fbPl79dvwRtaFqAC/ucCw== + +"@firebase/app@0.13.0": + version "0.13.0" + resolved "https://registry.npmjs.org/@firebase/app/-/app-0.13.0.tgz#ef67c7e5dc3f47efb430157f9de969a67abd53a7" + integrity sha512-Vj3MST245nq+V5UmmfEkB3isIgPouyUr8yGJlFeL9Trg/umG5ogAvrjAYvQ8gV7daKDoQSRnJKWI2JFpQqRsuQ== + dependencies: + "@firebase/component" "0.6.17" + "@firebase/logger" "0.4.4" + "@firebase/util" "1.12.0" + idb "7.1.1" + tslib "^2.1.0" + +"@firebase/auth-compat@0.5.26": + version "0.5.26" + resolved "https://registry.npmjs.org/@firebase/auth-compat/-/auth-compat-0.5.26.tgz#ff795ad7dd43077dc603a8576bf92e756c6a2064" + integrity sha512-4baB7tR0KukyGzrlD25aeO4t0ChLifwvDQXTBiVJE9WWwJEOjkZpHmoU9Iww0+Vdalsq4sZ3abp6YTNjHyB1dA== + dependencies: + "@firebase/auth" "1.10.6" + "@firebase/auth-types" "0.13.0" + "@firebase/component" "0.6.17" + "@firebase/util" "1.12.0" + tslib "^2.1.0" + +"@firebase/auth-interop-types@0.2.4": + version "0.2.4" + resolved "https://registry.yarnpkg.com/@firebase/auth-interop-types/-/auth-interop-types-0.2.4.tgz#176a08686b0685596ff03d7879b7e4115af53de0" + integrity sha512-JPgcXKCuO+CWqGDnigBtvo09HeBs5u/Ktc2GaFj2m01hLarbxthLNm7Fk8iOP1aqAtXV+fnnGj7U28xmk7IwVA== + +"@firebase/auth-types@0.13.0": + version "0.13.0" + resolved "https://registry.yarnpkg.com/@firebase/auth-types/-/auth-types-0.13.0.tgz#ae6e0015e3bd4bfe18edd0942b48a0a118a098d9" + integrity sha512-S/PuIjni0AQRLF+l9ck0YpsMOdE8GO2KU6ubmBB7P+7TJUCQDa3R1dlgYm9UzGbbePMZsp0xzB93f2b/CgxMOg== + +"@firebase/auth@1.10.6": + version "1.10.6" + resolved "https://registry.npmjs.org/@firebase/auth/-/auth-1.10.6.tgz#2403e92e382034367f7fefd6715f992e061c3e59" + integrity sha512-cFbo2FymQltog4atI9cKTO6CxKxS0dOMXslTQrlNZRH7qhDG44/d7QeI6GXLweFZtrnlecf52ESnNz1DU6ek8w== + dependencies: + "@firebase/component" "0.6.17" + "@firebase/logger" "0.4.4" + "@firebase/util" "1.12.0" + tslib "^2.1.0" + +"@firebase/component@0.6.17": + version "0.6.17" + resolved "https://registry.npmjs.org/@firebase/component/-/component-0.6.17.tgz#6cef28dbe6de80ce393f97147bf3f1ea0a5453ec" + integrity sha512-M6DOg7OySrKEFS8kxA3MU5/xc37fiOpKPMz6cTsMUcsuKB6CiZxxNAvgFta8HGRgEpZbi8WjGIj6Uf+TpOhyzg== + dependencies: + "@firebase/util" "1.12.0" + tslib "^2.1.0" + +"@firebase/data-connect@0.3.9": + version "0.3.9" + resolved "https://registry.npmjs.org/@firebase/data-connect/-/data-connect-0.3.9.tgz#9fe2f30d73c4013367b8ddd7ad57387d0438dce1" + integrity sha512-B5tGEh5uQrQeH0i7RvlU8kbZrKOJUmoyxVIX4zLA8qQJIN6A7D+kfBlGXtSwbPdrvyaejcRPcbOtqsDQ9HPJKw== + dependencies: + "@firebase/auth-interop-types" "0.2.4" + "@firebase/component" "0.6.17" + "@firebase/logger" "0.4.4" + "@firebase/util" "1.12.0" + tslib "^2.1.0" + +"@firebase/database-compat@2.0.10": + version "2.0.10" + resolved "https://registry.npmjs.org/@firebase/database-compat/-/database-compat-2.0.10.tgz#5cfe487b5fdb68752ded5ad17dabd99e763ba152" + integrity sha512-3sjl6oGaDDYJw/Ny0E5bO6v+KM3KoD4Qo/sAfHGdRFmcJ4QnfxOX9RbG9+ce/evI3m64mkPr24LlmTDduqMpog== + dependencies: + "@firebase/component" "0.6.17" + "@firebase/database" "1.0.19" + "@firebase/database-types" "1.0.14" + "@firebase/logger" "0.4.4" + "@firebase/util" "1.12.0" + tslib "^2.1.0" + +"@firebase/database-types@1.0.14": + version "1.0.14" + resolved "https://registry.npmjs.org/@firebase/database-types/-/database-types-1.0.14.tgz#454a33f55da46c243302d6b420b8b319ab80c6ce" + integrity sha512-8a0Q1GrxM0akgF0RiQHliinhmZd+UQPrxEmUv7MnQBYfVFiLtKOgs3g6ghRt/WEGJHyQNslZ+0PocIwNfoDwKw== + dependencies: + "@firebase/app-types" "0.9.3" + "@firebase/util" "1.12.0" + +"@firebase/database@1.0.19": + version "1.0.19" + resolved "https://registry.npmjs.org/@firebase/database/-/database-1.0.19.tgz#2d52e731407431bdc1581990d99b533784700fc6" + integrity sha512-khE+MIYK+XlIndVn/7mAQ9F1fwG5JHrGKaG72hblCC6JAlUBDd3SirICH6SMCf2PQ0iYkruTECth+cRhauacyQ== + dependencies: + "@firebase/app-check-interop-types" "0.3.3" + "@firebase/auth-interop-types" "0.2.4" + "@firebase/component" "0.6.17" + "@firebase/logger" "0.4.4" + "@firebase/util" "1.12.0" + faye-websocket "0.11.4" + tslib "^2.1.0" + +"@firebase/firestore-compat@0.3.51": + version "0.3.51" + resolved "https://registry.npmjs.org/@firebase/firestore-compat/-/firestore-compat-0.3.51.tgz#46ecebe9de16b60febf27d5014c9f21298064703" + integrity sha512-E5iubPhS6aAM7oSsHMx/FGBwfA2nbEHaK/hCs+MD3l3N7rHKnq4SYCGmVu/AraSJaMndZR1I37N9A/BH7aCq5A== + dependencies: + "@firebase/component" "0.6.17" + "@firebase/firestore" "4.7.16" + "@firebase/firestore-types" "3.0.3" + "@firebase/util" "1.12.0" + tslib "^2.1.0" + +"@firebase/firestore-types@3.0.3": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@firebase/firestore-types/-/firestore-types-3.0.3.tgz#7d0c3dd8850c0193d8f5ee0cc8f11961407742c1" + integrity sha512-hD2jGdiWRxB/eZWF89xcK9gF8wvENDJkzpVFb4aGkzfEaKxVRD1kjz1t1Wj8VZEp2LCB53Yx1zD8mrhQu87R6Q== + +"@firebase/firestore@4.7.16": + version "4.7.16" + resolved "https://registry.npmjs.org/@firebase/firestore/-/firestore-4.7.16.tgz#9807d3355965406da106a098ce15d9950585ac51" + integrity sha512-5OpvlwYVUTLEnqewOlXmtIpH8t2ISlZHDW0NDbKROM2D0ATMqFkMHdvl+/wz9zOAcb8GMQYlhCihOnVAliUbpQ== + dependencies: + "@firebase/component" "0.6.17" + "@firebase/logger" "0.4.4" + "@firebase/util" "1.12.0" + "@firebase/webchannel-wrapper" "1.0.3" + "@grpc/grpc-js" "~1.9.0" + "@grpc/proto-loader" "^0.7.8" + tslib "^2.1.0" + +"@firebase/functions-compat@0.3.25": + version "0.3.25" + resolved "https://registry.npmjs.org/@firebase/functions-compat/-/functions-compat-0.3.25.tgz#9022df60d7471c7111766789f05991966ab692f0" + integrity sha512-V0JKUw5W/7aznXf9BQ8LIYHCX6zVCM8Hdw7XUQ/LU1Y9TVP8WKRCnPB/qdPJ0xGjWWn7fhtwIYbgEw/syH4yTQ== + dependencies: + "@firebase/component" "0.6.17" + "@firebase/functions" "0.12.8" + "@firebase/functions-types" "0.6.3" + "@firebase/util" "1.12.0" + tslib "^2.1.0" + +"@firebase/functions-types@0.6.3": + version "0.6.3" + resolved "https://registry.yarnpkg.com/@firebase/functions-types/-/functions-types-0.6.3.tgz#f5faf770248b13f45d256f614230da6a11bfb654" + integrity sha512-EZoDKQLUHFKNx6VLipQwrSMh01A1SaL3Wg6Hpi//x6/fJ6Ee4hrAeswK99I5Ht8roiniKHw4iO0B1Oxj5I4plg== + +"@firebase/functions@0.12.8": + version "0.12.8" + resolved "https://registry.npmjs.org/@firebase/functions/-/functions-0.12.8.tgz#c2e42b4ba82746142c9fe1e120c3f71f0464aa3d" + integrity sha512-p+ft6dQW0CJ3BLLxeDb5Hwk9ARw01kHTZjLqiUdPRzycR6w7Z75ThkegNmL6gCss3S0JEpldgvehgZ3kHybVhA== + dependencies: + "@firebase/app-check-interop-types" "0.3.3" + "@firebase/auth-interop-types" "0.2.4" + "@firebase/component" "0.6.17" + "@firebase/messaging-interop-types" "0.2.3" + "@firebase/util" "1.12.0" + tslib "^2.1.0" + +"@firebase/installations-compat@0.2.17": + version "0.2.17" + resolved "https://registry.npmjs.org/@firebase/installations-compat/-/installations-compat-0.2.17.tgz#5d61fb652658432e43ca82b8f91a17d5d21a459b" + integrity sha512-J7afeCXB7yq25FrrJAgbx8mn1nG1lZEubOLvYgG7ZHvyoOCK00sis5rj7TgDrLYJgdj/SJiGaO1BD3BAp55TeA== + dependencies: + "@firebase/component" "0.6.17" + "@firebase/installations" "0.6.17" + "@firebase/installations-types" "0.5.3" + "@firebase/util" "1.12.0" + tslib "^2.1.0" + +"@firebase/installations-types@0.5.3": + version "0.5.3" + resolved "https://registry.yarnpkg.com/@firebase/installations-types/-/installations-types-0.5.3.tgz#cac8a14dd49f09174da9df8ae453f9b359c3ef2f" + integrity sha512-2FJI7gkLqIE0iYsNQ1P751lO3hER+Umykel+TkLwHj6plzWVxqvfclPUZhcKFVQObqloEBTmpi2Ozn7EkCABAA== + +"@firebase/installations@0.6.17": + version "0.6.17" + resolved "https://registry.npmjs.org/@firebase/installations/-/installations-0.6.17.tgz#f184e49fcf3053ba25015b0509d9de28db99db77" + integrity sha512-zfhqCNJZRe12KyADtRrtOj+SeSbD1H/K8J24oQAJVv/u02eQajEGlhZtcx9Qk7vhGWF5z9dvIygVDYqLL4o1XQ== + dependencies: + "@firebase/component" "0.6.17" + "@firebase/util" "1.12.0" + idb "7.1.1" + tslib "^2.1.0" + +"@firebase/logger@0.4.4": + version "0.4.4" + resolved "https://registry.yarnpkg.com/@firebase/logger/-/logger-0.4.4.tgz#29e8379d20fd1149349a195ee6deee4573a86f48" + integrity sha512-mH0PEh1zoXGnaR8gD1DeGeNZtWFKbnz9hDO91dIml3iou1gpOnLqXQ2dJfB71dj6dpmUjcQ6phY3ZZJbjErr9g== + dependencies: + tslib "^2.1.0" + +"@firebase/messaging-compat@0.2.21": + version "0.2.21" + resolved "https://registry.npmjs.org/@firebase/messaging-compat/-/messaging-compat-0.2.21.tgz#8d4c5b9557ed9890a774fba2ea7e5459860a901b" + integrity sha512-1yMne+4BGLbHbtyu/VyXWcLiefUE1+K3ZGfVTyKM4BH4ZwDFRGoWUGhhx+tKRX4Tu9z7+8JN67SjnwacyNWK5g== + dependencies: + "@firebase/component" "0.6.17" + "@firebase/messaging" "0.12.21" + "@firebase/util" "1.12.0" + tslib "^2.1.0" + +"@firebase/messaging-interop-types@0.2.3": + version "0.2.3" + resolved "https://registry.yarnpkg.com/@firebase/messaging-interop-types/-/messaging-interop-types-0.2.3.tgz#e647c9cd1beecfe6a6e82018a6eec37555e4da3e" + integrity sha512-xfzFaJpzcmtDjycpDeCUj0Ge10ATFi/VHVIvEEjDNc3hodVBQADZ7BWQU7CuFpjSHE+eLuBI13z5F/9xOoGX8Q== + +"@firebase/messaging@0.12.21": + version "0.12.21" + resolved "https://registry.npmjs.org/@firebase/messaging/-/messaging-0.12.21.tgz#05d76039133c3d2a33208416699a3d3ebd2c0012" + integrity sha512-bYJ2Evj167Z+lJ1ach6UglXz5dUKY1zrJZd15GagBUJSR7d9KfiM1W8dsyL0lDxcmhmA/sLaBYAAhF1uilwN0g== + dependencies: + "@firebase/component" "0.6.17" + "@firebase/installations" "0.6.17" + "@firebase/messaging-interop-types" "0.2.3" + "@firebase/util" "1.12.0" + idb "7.1.1" + tslib "^2.1.0" + +"@firebase/performance-compat@0.2.19": + version "0.2.19" + resolved "https://registry.npmjs.org/@firebase/performance-compat/-/performance-compat-0.2.19.tgz#f817a82037285b2240c4c55cc03eb1943ae932d6" + integrity sha512-4cU0T0BJ+LZK/E/UwFcvpBCVdkStgBMQwBztM9fJPT6udrEUk3ugF5/HT+E2Z22FCXtIaXDukJbYkE/c3c6IHw== + dependencies: + "@firebase/component" "0.6.17" + "@firebase/logger" "0.4.4" + "@firebase/performance" "0.7.6" + "@firebase/performance-types" "0.2.3" + "@firebase/util" "1.12.0" + tslib "^2.1.0" + +"@firebase/performance-types@0.2.3": + version "0.2.3" + resolved "https://registry.yarnpkg.com/@firebase/performance-types/-/performance-types-0.2.3.tgz#5ce64e90fa20ab5561f8b62a305010cf9fab86fb" + integrity sha512-IgkyTz6QZVPAq8GSkLYJvwSLr3LS9+V6vNPQr0x4YozZJiLF5jYixj0amDtATf1X0EtYHqoPO48a9ija8GocxQ== + +"@firebase/performance@0.7.6": + version "0.7.6" + resolved "https://registry.npmjs.org/@firebase/performance/-/performance-0.7.6.tgz#36376130c725d8f6df492be4da32c1d1f9a605f8" + integrity sha512-AsOz74dSTlyQGlnnbLWXiHFAsrxhpssPOsFFi4HgOJ5DjzkK7ZdZ/E9uMPrwFoXJyMVoybGRuqsL/wkIbFITsA== + dependencies: + "@firebase/component" "0.6.17" + "@firebase/installations" "0.6.17" + "@firebase/logger" "0.4.4" + "@firebase/util" "1.12.0" + tslib "^2.1.0" + web-vitals "^4.2.4" + +"@firebase/remote-config-compat@0.2.17": + version "0.2.17" + resolved "https://registry.npmjs.org/@firebase/remote-config-compat/-/remote-config-compat-0.2.17.tgz#d91583dfdd85ddb3e8cdd9c0e433d38f02095f1e" + integrity sha512-KelsBD0sXSC0u3esr/r6sJYGRN6pzn3bYuI/6pTvvmZbjBlxQkRabHAVH6d+YhLcjUXKIAYIjZszczd1QJtOyA== + dependencies: + "@firebase/component" "0.6.17" + "@firebase/logger" "0.4.4" + "@firebase/remote-config" "0.6.4" + "@firebase/remote-config-types" "0.4.0" + "@firebase/util" "1.12.0" + tslib "^2.1.0" + +"@firebase/remote-config-types@0.4.0": + version "0.4.0" + resolved "https://registry.yarnpkg.com/@firebase/remote-config-types/-/remote-config-types-0.4.0.tgz#91b9a836d5ca30ced68c1516163b281fbb544537" + integrity sha512-7p3mRE/ldCNYt8fmWMQ/MSGRmXYlJ15Rvs9Rk17t8p0WwZDbeK7eRmoI1tvCPaDzn9Oqh+yD6Lw+sGLsLg4kKg== + +"@firebase/remote-config@0.6.4": + version "0.6.4" + resolved "https://registry.npmjs.org/@firebase/remote-config/-/remote-config-0.6.4.tgz#30610bf52452639a127f1b40a94de096ac6cf43a" + integrity sha512-ZyLJRT46wtycyz2+opEkGaoFUOqRQjt/0NX1WfUISOMCI/PuVoyDjqGpq24uK+e8D5NknyTpiXCVq5dowhScmg== + dependencies: + "@firebase/component" "0.6.17" + "@firebase/installations" "0.6.17" + "@firebase/logger" "0.4.4" + "@firebase/util" "1.12.0" + tslib "^2.1.0" + +"@firebase/storage-compat@0.3.22": + version "0.3.22" + resolved "https://registry.npmjs.org/@firebase/storage-compat/-/storage-compat-0.3.22.tgz#8d5b95b5583d2acac2183e8e3cc302c66c2c3902" + integrity sha512-29j6JgXTjQ76sOIkxmTNHQfYA/hDTeV9qGbn0jolynPXSg/AmzCB0CpCoCYrS0ja0Flgmy1hkA3XYDZ/eiV1Cg== + dependencies: + "@firebase/component" "0.6.17" + "@firebase/storage" "0.13.12" + "@firebase/storage-types" "0.8.3" + "@firebase/util" "1.12.0" + tslib "^2.1.0" + +"@firebase/storage-types@0.8.3": + version "0.8.3" + resolved "https://registry.yarnpkg.com/@firebase/storage-types/-/storage-types-0.8.3.tgz#2531ef593a3452fc12c59117195d6485c6632d3d" + integrity sha512-+Muk7g9uwngTpd8xn9OdF/D48uiQ7I1Fae7ULsWPuKoCH3HU7bfFPhxtJYzyhjdniowhuDpQcfPmuNRAqZEfvg== + +"@firebase/storage@0.13.12": + version "0.13.12" + resolved "https://registry.npmjs.org/@firebase/storage/-/storage-0.13.12.tgz#213c5e7832b77b361e0c454ff8b787437686c45c" + integrity sha512-5JmoFS01MYjW1XMQa5F5rD/kvMwBN10QF03bmcuJWq4lg+BJ3nRgL3sscWnyJPhwM/ZCyv2eRwcfzESVmsYkdQ== + dependencies: + "@firebase/component" "0.6.17" + "@firebase/util" "1.12.0" + tslib "^2.1.0" + +"@firebase/util@1.12.0": + version "1.12.0" + resolved "https://registry.npmjs.org/@firebase/util/-/util-1.12.0.tgz#202e96cfd832f8dde551232e4868861681b8b89a" + integrity sha512-Z4rK23xBCwgKDqmzGVMef+Vb4xso2j5Q8OG0vVL4m4fA5ZjPMYQazu8OJJC3vtQRC3SQ/Pgx/6TPNVsCd70QRw== + dependencies: + tslib "^2.1.0" + +"@firebase/webchannel-wrapper@1.0.3": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@firebase/webchannel-wrapper/-/webchannel-wrapper-1.0.3.tgz#a73bab8eb491d7b8b7be2f0e6c310647835afe83" + integrity sha512-2xCRM9q9FlzGZCdgDMJwc0gyUkWFtkosy7Xxr6sFgQwn+wMNIWd7xIvYNauU1r64B5L5rsGKy/n9TKJ0aAFeqQ== + +"@grpc/grpc-js@~1.9.0": + version "1.9.15" + resolved "https://registry.yarnpkg.com/@grpc/grpc-js/-/grpc-js-1.9.15.tgz#433d7ac19b1754af690ea650ab72190bd700739b" + integrity sha512-nqE7Hc0AzI+euzUwDAy0aY5hCp10r734gMGRdU+qOPX0XSceI2ULrcXB5U2xSc5VkWwalCj4M7GzCAygZl2KoQ== + dependencies: + "@grpc/proto-loader" "^0.7.8" + "@types/node" ">=12.12.47" + +"@grpc/proto-loader@^0.7.8": + version "0.7.13" + resolved "https://registry.yarnpkg.com/@grpc/proto-loader/-/proto-loader-0.7.13.tgz#f6a44b2b7c9f7b609f5748c6eac2d420e37670cf" + integrity sha512-AiXO/bfe9bmxBjxxtYxFAXGZvMaN5s8kO+jBHAJCON8rJoB5YS/D6X7ZNc6XQkuHNmyl4CYaMI1fJ/Gn27RGGw== + dependencies: + lodash.camelcase "^4.3.0" + long "^5.0.0" + protobufjs "^7.2.5" + yargs "^17.7.2" + +"@jridgewell/resolve-uri@^3.0.3": + version "3.1.2" + resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz#7a0ee601f60f99a20c7c7c5ff0c80388c1189bd6" + integrity sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw== + +"@jridgewell/sourcemap-codec@^1.4.10": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz#3188bcb273a414b0d215fd22a58540b989b9409a" + integrity sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ== + +"@jridgewell/trace-mapping@0.3.9": + version "0.3.9" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9" + integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ== + dependencies: + "@jridgewell/resolve-uri" "^3.0.3" + "@jridgewell/sourcemap-codec" "^1.4.10" + +"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf" + integrity sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ== + +"@protobufjs/base64@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/base64/-/base64-1.1.2.tgz#4c85730e59b9a1f1f349047dbf24296034bb2735" + integrity sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg== + +"@protobufjs/codegen@^2.0.4": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@protobufjs/codegen/-/codegen-2.0.4.tgz#7ef37f0d010fb028ad1ad59722e506d9262815cb" + integrity sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg== + +"@protobufjs/eventemitter@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz#355cbc98bafad5978f9ed095f397621f1d066b70" + integrity sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q== + +"@protobufjs/fetch@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/fetch/-/fetch-1.1.0.tgz#ba99fb598614af65700c1619ff06d454b0d84c45" + integrity sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ== + dependencies: + "@protobufjs/aspromise" "^1.1.1" + "@protobufjs/inquire" "^1.1.0" + +"@protobufjs/float@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@protobufjs/float/-/float-1.0.2.tgz#5e9e1abdcb73fc0a7cb8b291df78c8cbd97b87d1" + integrity sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ== + +"@protobufjs/inquire@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/inquire/-/inquire-1.1.0.tgz#ff200e3e7cf2429e2dcafc1140828e8cc638f089" + integrity sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q== + +"@protobufjs/path@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/path/-/path-1.1.2.tgz#6cc2b20c5c9ad6ad0dccfd21ca7673d8d7fbf68d" + integrity sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA== + +"@protobufjs/pool@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/pool/-/pool-1.1.0.tgz#09fd15f2d6d3abfa9b65bc366506d6ad7846ff54" + integrity sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw== + +"@protobufjs/utf8@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" + integrity sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw== + +"@tsconfig/node10@^1.0.7": + version "1.0.11" + resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.11.tgz#6ee46400685f130e278128c7b38b7e031ff5b2f2" + integrity sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw== + +"@tsconfig/node12@^1.0.7": + version "1.0.11" + resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.11.tgz#ee3def1f27d9ed66dac6e46a295cffb0152e058d" + integrity sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag== + +"@tsconfig/node14@^1.0.0": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.3.tgz#e4386316284f00b98435bf40f72f75a09dabf6c1" + integrity sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow== + +"@tsconfig/node16@^1.0.2": + version "1.0.4" + resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.4.tgz#0b92dcc0cc1c81f6f306a381f28e31b1a56536e9" + integrity sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA== + +"@types/node@18.19.83": + version "18.19.83" + resolved "https://registry.npmjs.org/@types/node/-/node-18.19.83.tgz#44d302cd09364640bdd45d001bc75e596f7da920" + integrity sha512-D69JeR5SfFS5H6FLbUaS0vE4r1dGhmMBbG4Ed6BNS4wkDK8GZjsdCShT5LCN59vOHEUHnFCY9J4aclXlIphMkA== + dependencies: + undici-types "~5.26.4" + +"@types/node@>=12.12.47", "@types/node@>=13.7.0": + version "22.14.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.14.0.tgz#d3bfa3936fef0dbacd79ea3eb17d521c628bb47e" + integrity sha512-Kmpl+z84ILoG+3T/zQFyAJsU6EPTmOCj8/2+83fSN6djd6I4o7uOuGIH6vq3PrjY5BGitSbFuMN18j3iknubbA== + dependencies: + undici-types "~6.21.0" + +acorn-walk@^8.1.1: + version "8.3.4" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.3.4.tgz#794dd169c3977edf4ba4ea47583587c5866236b7" + integrity sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g== + dependencies: + acorn "^8.11.0" + +acorn@^8.11.0, acorn@^8.4.1: + version "8.14.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.14.1.tgz#721d5dc10f7d5b5609a891773d47731796935dfb" + integrity sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg== + +ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== + +ansi-styles@^4.0.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== + dependencies: + color-convert "^2.0.1" + +arg@^4.1.0: + version "4.1.3" + resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" + integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== + +cliui@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa" + integrity sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ== + dependencies: + string-width "^4.2.0" + strip-ansi "^6.0.1" + wrap-ansi "^7.0.0" + +color-convert@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" + integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== + dependencies: + color-name "~1.1.4" + +color-name@~1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" + integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== + +create-require@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" + integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== + +diff@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" + integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== + +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + +escalade@^3.1.1: + version "3.2.0" + resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.2.0.tgz#011a3f69856ba189dffa7dc8fcce99d2a87903e5" + integrity sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA== + +faye-websocket@0.11.4: + version "0.11.4" + resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.11.4.tgz#7f0d9275cfdd86a1c963dc8b65fcc451edcbb1da" + integrity sha512-CzbClwlXAuiRQAlUyfqPgvPoNKTckTPGfwZV4ZdAhVcP2lh9KUxJg2b5GkE7XbjKQ3YJnQ9z6D9ntLAlB+tP8g== + dependencies: + websocket-driver ">=0.5.1" + +firebase@11.8.1: + version "11.8.1" + resolved "https://registry.npmjs.org/firebase/-/firebase-11.8.1.tgz#7658c4fed6c10102d8a2b00de576b903af78d767" + integrity sha512-oetXhPCvJZM4DVL/n/06442emMU+KzM0JLZjszpwlU6mqdFZqBwumBxn6hQkLukJyU5wsjihZHUY8HEAE2micg== + dependencies: + "@firebase/ai" "1.3.0" + "@firebase/analytics" "0.10.16" + "@firebase/analytics-compat" "0.2.22" + "@firebase/app" "0.13.0" + "@firebase/app-check" "0.10.0" + "@firebase/app-check-compat" "0.3.25" + "@firebase/app-compat" "0.4.0" + "@firebase/app-types" "0.9.3" + "@firebase/auth" "1.10.6" + "@firebase/auth-compat" "0.5.26" + "@firebase/data-connect" "0.3.9" + "@firebase/database" "1.0.19" + "@firebase/database-compat" "2.0.10" + "@firebase/firestore" "4.7.16" + "@firebase/firestore-compat" "0.3.51" + "@firebase/functions" "0.12.8" + "@firebase/functions-compat" "0.3.25" + "@firebase/installations" "0.6.17" + "@firebase/installations-compat" "0.2.17" + "@firebase/messaging" "0.12.21" + "@firebase/messaging-compat" "0.2.21" + "@firebase/performance" "0.7.6" + "@firebase/performance-compat" "0.2.19" + "@firebase/remote-config" "0.6.4" + "@firebase/remote-config-compat" "0.2.17" + "@firebase/storage" "0.13.12" + "@firebase/storage-compat" "0.3.22" + "@firebase/util" "1.12.0" + +get-caller-file@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" + integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== + +http-parser-js@>=0.5.1: + version "0.5.9" + resolved "https://registry.yarnpkg.com/http-parser-js/-/http-parser-js-0.5.9.tgz#b817b3ca0edea6236225000d795378707c169cec" + integrity sha512-n1XsPy3rXVxlqxVioEWdC+0+M+SQw0DpJynwtOPo1X+ZlvdzTLtDBIJJlDQTnwZIFJrZSzSGmIOUdP8tu+SgLw== + +idb@7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/idb/-/idb-7.1.1.tgz#d910ded866d32c7ced9befc5bfdf36f572ced72b" + integrity sha512-gchesWBzyvGHRO9W8tzUWFDycow5gwjvFKfyV9FF32Y7F50yZMp7mP+T2mJIWFx49zicqyC4uefHM17o6xKIVQ== + +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== + +lodash.camelcase@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" + integrity sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA== + +long@^5.0.0: + version "5.3.1" + resolved "https://registry.yarnpkg.com/long/-/long-5.3.1.tgz#9d4222d3213f38a5ec809674834e0f0ab21abe96" + integrity sha512-ka87Jz3gcx/I7Hal94xaN2tZEOPoUOEVftkQqZx2EeQRN7LGdfLlI3FvZ+7WDplm+vK2Urx9ULrvSowtdCieng== + +make-error@^1.1.1: + version "1.3.6" + resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" + integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== + +protobufjs@^7.2.5: + version "7.4.0" + resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-7.4.0.tgz#7efe324ce9b3b61c82aae5de810d287bc08a248a" + integrity sha512-mRUWCc3KUU4w1jU8sGxICXH/gNS94DvI1gxqDvBzhj1JpcsimQkYiOJfwsPUykUI5ZaspFbSgmBLER8IrQ3tqw== + dependencies: + "@protobufjs/aspromise" "^1.1.2" + "@protobufjs/base64" "^1.1.2" + "@protobufjs/codegen" "^2.0.4" + "@protobufjs/eventemitter" "^1.1.0" + "@protobufjs/fetch" "^1.1.0" + "@protobufjs/float" "^1.0.2" + "@protobufjs/inquire" "^1.1.0" + "@protobufjs/path" "^1.1.2" + "@protobufjs/pool" "^1.1.0" + "@protobufjs/utf8" "^1.1.0" + "@types/node" ">=13.7.0" + long "^5.0.0" + +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== + +safe-buffer@>=5.1.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + +string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +ts-node@^10.9.2: + version "10.9.2" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.2.tgz#70f021c9e185bccdca820e26dc413805c101c71f" + integrity sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ== + dependencies: + "@cspotcode/source-map-support" "^0.8.0" + "@tsconfig/node10" "^1.0.7" + "@tsconfig/node12" "^1.0.7" + "@tsconfig/node14" "^1.0.0" + "@tsconfig/node16" "^1.0.2" + acorn "^8.4.1" + acorn-walk "^8.1.1" + arg "^4.1.0" + create-require "^1.1.0" + diff "^4.0.1" + make-error "^1.1.1" + v8-compile-cache-lib "^3.0.1" + yn "3.1.1" + +tslib@^2.1.0: + version "2.8.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" + integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== + +typescript@5.5.4: + version "5.5.4" + resolved "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba" + integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q== + +undici-types@~5.26.4: + version "5.26.5" + resolved "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" + integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== + +undici-types@~6.21.0: + version "6.21.0" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.21.0.tgz#691d00af3909be93a7faa13be61b3a5b50ef12cb" + integrity sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ== + +v8-compile-cache-lib@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" + integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== + +web-vitals@^4.2.4: + version "4.2.4" + resolved "https://registry.yarnpkg.com/web-vitals/-/web-vitals-4.2.4.tgz#1d20bc8590a37769bd0902b289550936069184b7" + integrity sha512-r4DIlprAGwJ7YM11VZp4R884m0Vmgr6EAKe3P+kO0PPj3Unqyvv59rczf6UiGcb9Z8QxZVcqKNwv/g0WNdWwsw== + +websocket-driver@>=0.5.1: + version "0.7.4" + resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.7.4.tgz#89ad5295bbf64b480abcba31e4953aca706f5760" + integrity sha512-b17KeDIQVjvb0ssuSDF2cYXSg2iztliJ4B9WdsuB6J952qCPKmnVq4DyW5motImXHDC1cBT/1UezrJVsKw5zjg== + dependencies: + http-parser-js ">=0.5.1" + safe-buffer ">=5.1.0" + websocket-extensions ">=0.1.1" + +websocket-extensions@>=0.1.1: + version "0.1.4" + resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.4.tgz#7f8473bc839dfd87608adb95d7eb075211578a42" + integrity sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg== + +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + +y18n@^5.0.5: + version "5.0.8" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" + integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== + +yargs-parser@^21.1.1: + version "21.1.1" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35" + integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== + +yargs@^17.7.2: + version "17.7.2" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269" + integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w== + dependencies: + cliui "^8.0.1" + escalade "^3.1.1" + get-caller-file "^2.0.5" + require-directory "^2.1.1" + string-width "^4.2.3" + y18n "^5.0.5" + yargs-parser "^21.1.1" + +yn@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" + integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== diff --git a/e2e/.gitignore b/e2e/smoke-tests/.gitignore similarity index 100% rename from e2e/.gitignore rename to e2e/smoke-tests/.gitignore diff --git a/e2e/smoke-tests/README.md b/e2e/smoke-tests/README.md new file mode 100644 index 00000000000..eb72486e95e --- /dev/null +++ b/e2e/smoke-tests/README.md @@ -0,0 +1,92 @@ +# Firebase JS SDK E2E Tests + +This directory contains end-to-end tests for the Firebase JS SDK package as well as minimal quick start sample apps for debugging and development. + +## E2E Tests + +### Setup + +Before running the tests, you will need: + +- a project config +- a test user with an email/password login which has read/write privileges for Storage, Realtime Database, and Firestore +- an App Check debug token +- to deploy the `callTest` Cloud Function + +#### Project Config and Test User + +Create a file named `firebase-config.js` in the top level of this `e2e/smoke-tests` directory. The contents of the file should be: + +```javascript +// A config for a project +export const config = { + apiKey: ************, + authDomain: ************, + databaseURL: ************, + projectId: ************, + storageBucket: ************, + messagingSenderId: ************, + appId: ************, + measurementId: ************ +}; + * +// A user account with read/write privileges in that project +// for storage, database, firestore +export const testAccount = { + email: ************, + password: ************ +} +``` + +#### App Check Debug Token + +Create an App Check debug token in the Firebase Console. Assign it to an environment variable in your shell named `APP_CHECK_DEBUG_TOKEN`. + +#### Deploy `callTest` Cloud Function + +From the top level of the firebase repo, ensure you have the Firebase CLI (`firebase-tools`) installed (if not, `npm install -g firebase-tools`). + +Ensure you are logged in using the CLI (`firebase login`); + +Then deploy the function with: +`firebase deploy --only functions:callTest --project YOUR_PROJECT_ID` + +### Running the Tests + +To run the tests on the default modular API: + +``` +yarn test:modular +``` + +To run the tests on the compat API: + +``` +yarn test:compat +``` + +## Sample Apps + +Two minimal sample apps are provided for quick debugging and development. These apps import and initialize every product in the SDK and call some basic methods. Products can easily be commented out to focus on one or more products you are interested in looking at. + +### Setup + +The setup is the same as for the E2E tests above. Certain tests can be skipped if you are commenting out that product (e.g, no need to deploy the Cloud Function if you are commenting out the `callFunctions()` line in the sample app, and no need to set the App Check debug token env variable if not using App Check). + +### Running Sample Apps + +To run the modular sample app (uses current default version of the API): + +``` +yarn start:modular +``` + +Then open `localhost:8080` in a browser. + +To run the compat sample app (uses current compat version of the API): + +``` +yarn start:compat +``` + +Then open `localhost:8080` in a browser. \ No newline at end of file diff --git a/e2e/smoke-tests/babel.config.js b/e2e/smoke-tests/babel.config.js new file mode 100644 index 00000000000..f588a39a23d --- /dev/null +++ b/e2e/smoke-tests/babel.config.js @@ -0,0 +1,23 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +module.exports = { + presets: [ + ['@babel/preset-env', { targets: { node: 'current' } }], + '@babel/preset-typescript' + ] +}; diff --git a/e2e/build/index.html b/e2e/smoke-tests/build/index.html similarity index 100% rename from e2e/build/index.html rename to e2e/smoke-tests/build/index.html diff --git a/e2e/smoke-tests/fix-jsdom-environment.ts b/e2e/smoke-tests/fix-jsdom-environment.ts new file mode 100644 index 00000000000..c2885ab9c45 --- /dev/null +++ b/e2e/smoke-tests/fix-jsdom-environment.ts @@ -0,0 +1,38 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import JSDOMEnvironment from 'jest-environment-jsdom'; + +/** + * JSDOMEnvironment patch to polyfill missing APIs with Node APIs. + */ +// https://github.com/facebook/jest/blob/v29.4.3/website/versioned_docs/version-29.4/Configuration.md#testenvironment-string +export default class FixJSDOMEnvironment extends JSDOMEnvironment { + constructor(...args: ConstructorParameters) { + super(...args); + + // Fetch + // FIXME: https://github.com/jsdom/jsdom/issues/1724 + this.global.fetch = fetch; + this.global.Headers = Headers; + this.global.Request = Request; + this.global.Response = Response; + + // Util + this.global.TextEncoder = TextEncoder; + } +} diff --git a/e2e/jest.config.ts b/e2e/smoke-tests/jest.config.ts similarity index 100% rename from e2e/jest.config.ts rename to e2e/smoke-tests/jest.config.ts diff --git a/e2e/package.json b/e2e/smoke-tests/package.json similarity index 100% rename from e2e/package.json rename to e2e/smoke-tests/package.json diff --git a/e2e/sample-apps/compat.js b/e2e/smoke-tests/sample-apps/compat.js similarity index 99% rename from e2e/sample-apps/compat.js rename to e2e/smoke-tests/sample-apps/compat.js index 478b960d8e0..e77b7d087d0 100644 --- a/e2e/sample-apps/compat.js +++ b/e2e/smoke-tests/sample-apps/compat.js @@ -82,7 +82,7 @@ async function authLogout() { * * Call a deployed function. * This cloud function must be deployed in this project first. See - * e2e/README.md for more info. + * e2e/smoke-test/README.md for more info. */ async function callFunctions() { console.log('[FUNCTIONS] start'); diff --git a/e2e/sample-apps/modular.js b/e2e/smoke-tests/sample-apps/modular.js similarity index 99% rename from e2e/sample-apps/modular.js rename to e2e/smoke-tests/sample-apps/modular.js index d01b5b0139d..2d66b752081 100644 --- a/e2e/sample-apps/modular.js +++ b/e2e/smoke-tests/sample-apps/modular.js @@ -121,7 +121,7 @@ async function authLogout(app) { * * Call a deployed function. * This cloud function must be deployed in this project first. See - * e2e/README.md for more info. + * e2e/smoke-tests/README.md for more info. */ async function callFunctions(app) { console.log('[FUNCTIONS] start'); diff --git a/e2e/tests/compat.test.ts b/e2e/smoke-tests/tests/compat.test.ts similarity index 100% rename from e2e/tests/compat.test.ts rename to e2e/smoke-tests/tests/compat.test.ts diff --git a/e2e/tests/modular.test.ts b/e2e/smoke-tests/tests/modular.test.ts similarity index 100% rename from e2e/tests/modular.test.ts rename to e2e/smoke-tests/tests/modular.test.ts diff --git a/e2e/webpack.config.js b/e2e/smoke-tests/webpack.config.js similarity index 100% rename from e2e/webpack.config.js rename to e2e/smoke-tests/webpack.config.js diff --git a/e2e/yarn.lock b/e2e/smoke-tests/yarn.lock similarity index 96% rename from e2e/yarn.lock rename to e2e/smoke-tests/yarn.lock index c20459aecdd..b9a6d8e4451 100644 --- a/e2e/yarn.lock +++ b/e2e/smoke-tests/yarn.lock @@ -19,16 +19,7 @@ js-tokens "^4.0.0" picocolors "^1.0.0" -"@babel/code-frame@^7.25.9": - version "7.26.0" - resolved "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.26.0.tgz" - integrity sha512-INCKxTtbXtcNbUZ3YXutwMpEleqttcswhAdee7dhuoVrD2cnuc3PqtERBtxkX5nziX9vnBL8WXmSGwv8CuPV6g== - dependencies: - "@babel/helper-validator-identifier" "^7.25.9" - js-tokens "^4.0.0" - picocolors "^1.0.0" - -"@babel/code-frame@^7.26.0": +"@babel/code-frame@^7.25.9", "@babel/code-frame@^7.26.0": version "7.26.0" resolved "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.26.0.tgz" integrity sha512-INCKxTtbXtcNbUZ3YXutwMpEleqttcswhAdee7dhuoVrD2cnuc3PqtERBtxkX5nziX9vnBL8WXmSGwv8CuPV6g== @@ -47,7 +38,7 @@ resolved "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.26.8.tgz" integrity sha512-oH5UPLMWR3L2wEFLnFJ1TZXqHufiTKAiLfqw5zkhS4dKXLJ10yVztfil/twG8EDTA4F/tvVNw9nOl4ZMslB8rQ== -"@babel/core@^7.0.0", "@babel/core@^7.0.0-0", "@babel/core@^7.0.0-0 || ^8.0.0-0 <8.0.0", "@babel/core@^7.12.0", "@babel/core@^7.13.0", "@babel/core@^7.4.0 || ^8.0.0-0 <8.0.0", "@babel/core@^7.8.0", "@babel/core@7.26.8": +"@babel/core@7.26.8": version "7.26.8" resolved "https://registry.npmjs.org/@babel/core/-/core-7.26.8.tgz" integrity sha512-l+lkXCHS6tQEc5oUpK28xBOZ6+HwaH7YwoYQbLFiYb4nS2/l1tKnZEtEWkD0GuiYdvArf9qBS0XlQGXzPMsNqQ== @@ -69,49 +60,7 @@ json5 "^2.2.3" semver "^6.3.1" -"@babel/core@^7.11.6": - version "7.26.0" - resolved "https://registry.npmjs.org/@babel/core/-/core-7.26.0.tgz" - integrity sha512-i1SLeK+DzNnQ3LL/CswPCa/E5u4lh1k6IAEphON8F+cXt0t9euTshDru0q7/IqMa1PMPz5RnHuHscF8/ZJsStg== - dependencies: - "@ampproject/remapping" "^2.2.0" - "@babel/code-frame" "^7.26.0" - "@babel/generator" "^7.26.0" - "@babel/helper-compilation-targets" "^7.25.9" - "@babel/helper-module-transforms" "^7.26.0" - "@babel/helpers" "^7.26.0" - "@babel/parser" "^7.26.0" - "@babel/template" "^7.25.9" - "@babel/traverse" "^7.25.9" - "@babel/types" "^7.26.0" - convert-source-map "^2.0.0" - debug "^4.1.0" - gensync "^1.0.0-beta.2" - json5 "^2.2.3" - semver "^6.3.1" - -"@babel/core@^7.12.3": - version "7.26.0" - resolved "https://registry.npmjs.org/@babel/core/-/core-7.26.0.tgz" - integrity sha512-i1SLeK+DzNnQ3LL/CswPCa/E5u4lh1k6IAEphON8F+cXt0t9euTshDru0q7/IqMa1PMPz5RnHuHscF8/ZJsStg== - dependencies: - "@ampproject/remapping" "^2.2.0" - "@babel/code-frame" "^7.26.0" - "@babel/generator" "^7.26.0" - "@babel/helper-compilation-targets" "^7.25.9" - "@babel/helper-module-transforms" "^7.26.0" - "@babel/helpers" "^7.26.0" - "@babel/parser" "^7.26.0" - "@babel/template" "^7.25.9" - "@babel/traverse" "^7.25.9" - "@babel/types" "^7.26.0" - convert-source-map "^2.0.0" - debug "^4.1.0" - gensync "^1.0.0-beta.2" - json5 "^2.2.3" - semver "^6.3.1" - -"@babel/core@^7.23.9": +"@babel/core@^7.11.6", "@babel/core@^7.12.3", "@babel/core@^7.23.9": version "7.26.0" resolved "https://registry.npmjs.org/@babel/core/-/core-7.26.0.tgz" integrity sha512-i1SLeK+DzNnQ3LL/CswPCa/E5u4lh1k6IAEphON8F+cXt0t9euTshDru0q7/IqMa1PMPz5RnHuHscF8/ZJsStg== @@ -354,34 +303,20 @@ "@babel/template" "^7.26.9" "@babel/types" "^7.26.9" -"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.20.7", "@babel/parser@^7.23.9": +"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.20.7", "@babel/parser@^7.23.9", "@babel/parser@^7.26.3": version "7.26.3" resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.26.3.tgz" integrity sha512-WJ/CvmY8Mea8iDXo6a7RK2wbmJITT5fN3BEkRuFlxVyNx8jOKIIhmC4fSkTcPcf8JyavbBwIe6OpiCOBXt/IcA== dependencies: "@babel/types" "^7.26.3" -"@babel/parser@^7.25.9": - version "7.26.0" - resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.26.0.tgz" - integrity sha512-aP8x5pIw3xvYr/sXT+SEUwyhrXT8rUJRZltK/qN3Db80dcKpTett8cJxHyjk+xYSVXvNnl2SfcJVjbwxpOSscA== - dependencies: - "@babel/types" "^7.26.0" - -"@babel/parser@^7.26.0": +"@babel/parser@^7.25.9", "@babel/parser@^7.26.0": version "7.26.0" resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.26.0.tgz" integrity sha512-aP8x5pIw3xvYr/sXT+SEUwyhrXT8rUJRZltK/qN3Db80dcKpTett8cJxHyjk+xYSVXvNnl2SfcJVjbwxpOSscA== dependencies: "@babel/types" "^7.26.0" -"@babel/parser@^7.26.3": - version "7.26.3" - resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.26.3.tgz" - integrity sha512-WJ/CvmY8Mea8iDXo6a7RK2wbmJITT5fN3BEkRuFlxVyNx8jOKIIhmC4fSkTcPcf8JyavbBwIe6OpiCOBXt/IcA== - dependencies: - "@babel/types" "^7.26.3" - "@babel/parser@^7.26.8", "@babel/parser@^7.26.9": version "7.26.9" resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.26.9.tgz" @@ -1120,15 +1055,7 @@ debug "^4.3.1" globals "^11.1.0" -"@babel/types@^7.0.0": - version "7.26.3" - resolved "https://registry.npmjs.org/@babel/types/-/types-7.26.3.tgz" - integrity sha512-vN5p+1kl59GVKMvTHt55NzzmYVxprfJD+ql7U9NFIfKCBkYE55LYtS+WtPlaYOyzydrKI8Nezd+aZextrd+FMA== - dependencies: - "@babel/helper-string-parser" "^7.25.9" - "@babel/helper-validator-identifier" "^7.25.9" - -"@babel/types@^7.20.7": +"@babel/types@^7.0.0", "@babel/types@^7.20.7", "@babel/types@^7.26.3", "@babel/types@^7.3.3": version "7.26.3" resolved "https://registry.npmjs.org/@babel/types/-/types-7.26.3.tgz" integrity sha512-vN5p+1kl59GVKMvTHt55NzzmYVxprfJD+ql7U9NFIfKCBkYE55LYtS+WtPlaYOyzydrKI8Nezd+aZextrd+FMA== @@ -1144,14 +1071,6 @@ "@babel/helper-string-parser" "^7.25.9" "@babel/helper-validator-identifier" "^7.25.9" -"@babel/types@^7.26.3", "@babel/types@^7.3.3": - version "7.26.3" - resolved "https://registry.npmjs.org/@babel/types/-/types-7.26.3.tgz" - integrity sha512-vN5p+1kl59GVKMvTHt55NzzmYVxprfJD+ql7U9NFIfKCBkYE55LYtS+WtPlaYOyzydrKI8Nezd+aZextrd+FMA== - dependencies: - "@babel/helper-string-parser" "^7.25.9" - "@babel/helper-validator-identifier" "^7.25.9" - "@babel/types@^7.26.8", "@babel/types@^7.26.9": version "7.26.9" resolved "https://registry.npmjs.org/@babel/types/-/types-7.26.9.tgz" @@ -1190,6 +1109,8 @@ "@firebase/analytics-compat@0.2.20-20250512211235": version "0.2.20-20250512211235" + resolved "https://registry.npmjs.org/@firebase/analytics-compat/-/analytics-compat-0.2.20-20250512211235.tgz#725ebf8e94ad9aba4ed22f79206c1a2420190a82" + integrity sha512-2MmqqNlHlbs6454pOnKnNbtz8cF54UYgCiFWc0tXV6VNrSAGAyWgY3Ujve5+ayuSmzMuTaLNKk8kOPC90nNmCA== dependencies: "@firebase/analytics" "0.10.14-20250512211235" "@firebase/analytics-types" "0.8.3" @@ -1204,6 +1125,8 @@ "@firebase/analytics@0.10.14-20250512211235": version "0.10.14-20250512211235" + resolved "https://registry.npmjs.org/@firebase/analytics/-/analytics-0.10.14-20250512211235.tgz#0c9fb8e352e0e641168d1968e616a0c775a4392f" + integrity sha512-yPo0D9Ec5jSWRmI6JYt8PCzTVUHtTvnmhN7s09Wh2ckrbv7kgejIAYOjKOK30Umro+teA6wTsY07Q27C1dOM4A== dependencies: "@firebase/component" "0.6.15-20250512211235" "@firebase/installations" "0.6.15-20250512211235" @@ -1213,6 +1136,8 @@ "@firebase/app-check-compat@0.3.23-20250512211235": version "0.3.23-20250512211235" + resolved "https://registry.npmjs.org/@firebase/app-check-compat/-/app-check-compat-0.3.23-20250512211235.tgz#f060c925f2bcd936299504a5f34bc81ea872388f" + integrity sha512-iI2mGM/f8z4aQhoB57HnErh8vCqyQJFVQS7USLy6dUyL15FcIe5HQ88N4oD9glagu4IDRlZ+Rohlrw9ObbyNxA== dependencies: "@firebase/app-check" "0.10.0-20250512211235" "@firebase/app-check-types" "0.5.3" @@ -1233,6 +1158,8 @@ "@firebase/app-check@0.10.0-20250512211235": version "0.10.0-20250512211235" + resolved "https://registry.npmjs.org/@firebase/app-check/-/app-check-0.10.0-20250512211235.tgz#304ae95ed148d0837f64b94527d6b2b68966b117" + integrity sha512-zFbNyt3j6ixg6/Gh3WdA+FvMhUxIRASEq/NRC+Jtofm5la5ZJ88wdLDJ/kSHtdMINQfKuneHbJJ832u5BTqpYQ== dependencies: "@firebase/component" "0.6.15-20250512211235" "@firebase/logger" "0.4.4" @@ -1241,6 +1168,8 @@ "@firebase/app-compat@0.4.0-20250512211235": version "0.4.0-20250512211235" + resolved "https://registry.npmjs.org/@firebase/app-compat/-/app-compat-0.4.0-20250512211235.tgz#4ae94412aa00afcf4663919af564e321ea17b335" + integrity sha512-epnyKsA97L0FMigDHWOcgJ2TeMnlpuyiGIVZdnQiElKfRs3UFgDvBb6AK5dHgT4REe7ZbXqGa/8TSUUGFhEcmw== dependencies: "@firebase/app" "0.13.0-20250512211235" "@firebase/component" "0.6.15-20250512211235" @@ -1248,13 +1177,15 @@ "@firebase/util" "1.12.0-20250512211235" tslib "^2.1.0" -"@firebase/app-types@0.9.3", "@firebase/app-types@0.x": +"@firebase/app-types@0.9.3": version "0.9.3" resolved "https://registry.npmjs.org/@firebase/app-types/-/app-types-0.9.3.tgz" integrity sha512-kRVpIl4vVGJ4baogMDINbyrIOtOxqhkZQg4jTq3l8Lw6WSk0xfpEYzezFu+Kl4ve4fbPl79dvwRtaFqAC/ucCw== -"@firebase/app@0.13.0-20250512211235", "@firebase/app@0.x": +"@firebase/app@0.13.0-20250512211235": version "0.13.0-20250512211235" + resolved "https://registry.npmjs.org/@firebase/app/-/app-0.13.0-20250512211235.tgz#b8028efcd45ac07b3304ac361008f08b0cfa445f" + integrity sha512-9qcJX9fKMFuZf5+8BxK0Dg1gJU+x4shoH+VFiKnZ7ri6sJ0OP67Y4PnHDYdzKmx7/HJt0KSyZMDUX/hT2Wbl/g== dependencies: "@firebase/component" "0.6.15-20250512211235" "@firebase/logger" "0.4.4" @@ -1264,6 +1195,8 @@ "@firebase/auth-compat@0.5.23-20250512211235": version "0.5.23-20250512211235" + resolved "https://registry.npmjs.org/@firebase/auth-compat/-/auth-compat-0.5.23-20250512211235.tgz#130b8583e137bae9b7e288e8991583ff04b1ab25" + integrity sha512-dWBbbYAiNmrD6+P5m2TgQ9GWPIffjedQ9HRXnPyqKytTiEQzxvYBd91NS3y3YI6bBg1RWAWccMnwtQVjl1eK6A== dependencies: "@firebase/auth" "1.10.3-20250512211235" "@firebase/auth-types" "0.13.0" @@ -1283,6 +1216,8 @@ "@firebase/auth@1.10.3-20250512211235": version "1.10.3-20250512211235" + resolved "https://registry.npmjs.org/@firebase/auth/-/auth-1.10.3-20250512211235.tgz#47f55c228e4eb441050914c6e545ccb1f021a712" + integrity sha512-f7Lov3vogDMyroncY7OipDmNL5bqZcDxdIVe1qN/LEaaKygG2wPxKMa+LjSFwxwo/oGp/i6R4ixT8otMkOL2MQ== dependencies: "@firebase/component" "0.6.15-20250512211235" "@firebase/logger" "0.4.4" @@ -1299,12 +1234,16 @@ "@firebase/component@0.6.15-20250512211235": version "0.6.15-20250512211235" + resolved "https://registry.npmjs.org/@firebase/component/-/component-0.6.15-20250512211235.tgz#91f4f234904480f34d26aa41922b8cf4603944c2" + integrity sha512-8U//EzcIE6frUcWUMcmrVzWBAXLBZt2eGWwt8Of1y+yU6t3Zwwu+1JpCz0hbiHpzXnkuTFjPwWA6fKgZQTk0MQ== dependencies: "@firebase/util" "1.12.0-20250512211235" tslib "^2.1.0" "@firebase/data-connect@0.3.6-20250512211235": version "0.3.6-20250512211235" + resolved "https://registry.npmjs.org/@firebase/data-connect/-/data-connect-0.3.6-20250512211235.tgz#f20ee3c0cc576f000244ad769e1813151e2aa3cd" + integrity sha512-ZMs7lX9/Sd7XNRaylht535sY1mFUasLCY0toKQWF4KIAdUeij0TNzqWpeULNqNJXtczu+eRrG3Nct1rY4JtiiQ== dependencies: "@firebase/auth-interop-types" "0.2.4" "@firebase/component" "0.6.15-20250512211235" @@ -1314,6 +1253,8 @@ "@firebase/database-compat@2.0.7-20250512211235": version "2.0.7-20250512211235" + resolved "https://registry.npmjs.org/@firebase/database-compat/-/database-compat-2.0.7-20250512211235.tgz#0d78c287cab62583d46525c690469576787aca22" + integrity sha512-8bt/9/EXqxce32RDg254yfkEUsG9x9h3K6+IFdsCeLhPH9mQLosrcRBSHusHGX65oNbY1ATgxkt/+v+uhoj+nw== dependencies: "@firebase/component" "0.6.15-20250512211235" "@firebase/database" "1.0.16-20250512211235" @@ -1324,12 +1265,16 @@ "@firebase/database-types@1.0.12-20250512211235": version "1.0.12-20250512211235" + resolved "https://registry.npmjs.org/@firebase/database-types/-/database-types-1.0.12-20250512211235.tgz#4b89e43e99e0fb621fc4abcec792d027c0669f44" + integrity sha512-FsZ/VeSyNLaJWQGLP0Yy955Zonlm/WSPhpdOpof84ToKAekUQobxlI08skPe+Gk2dAUnKrdqfGJPO9pagsByYA== dependencies: "@firebase/app-types" "0.9.3" "@firebase/util" "1.12.0-20250512211235" "@firebase/database@1.0.16-20250512211235": version "1.0.16-20250512211235" + resolved "https://registry.npmjs.org/@firebase/database/-/database-1.0.16-20250512211235.tgz#223f45e9010574d361cbaa53e56b51dab17a804d" + integrity sha512-l2jVH/uCzbuAhCYk37+YWFHE2nIkGyTiFL3RthkDvoT+KHDzvaIxnWmjnbAgrQEYSHaimziiw0DmpQM+Safb0g== dependencies: "@firebase/app-check-interop-types" "0.3.3" "@firebase/auth-interop-types" "0.2.4" @@ -1341,6 +1286,8 @@ "@firebase/firestore-compat@0.3.48-20250512211235": version "0.3.48-20250512211235" + resolved "https://registry.npmjs.org/@firebase/firestore-compat/-/firestore-compat-0.3.48-20250512211235.tgz#547d62fd41bc15495c26f9675d9ed24ff3c3f50c" + integrity sha512-8nWD3QRkN9rUoApULVfBMg112QNYstUWRm58cMwcdp0Wkx6+RV+9YraDYzg7GmsEklL4CnGF36HGNrtzraxOTg== dependencies: "@firebase/component" "0.6.15-20250512211235" "@firebase/firestore" "4.7.13-20250512211235" @@ -1355,6 +1302,8 @@ "@firebase/firestore@4.7.13-20250512211235": version "4.7.13-20250512211235" + resolved "https://registry.npmjs.org/@firebase/firestore/-/firestore-4.7.13-20250512211235.tgz#cdebb6b7ddba2b7738896458327ae064bb6b540e" + integrity sha512-m3xEnbYrsgp58a5if00Vqrrglm/22yU7amZ3CjwqUD+/M6TFSf1a9lvMqF9S33AuPbwHDxUb3hJ4ogpTQ+uSjQ== dependencies: "@firebase/component" "0.6.15-20250512211235" "@firebase/logger" "0.4.4" @@ -1366,6 +1315,8 @@ "@firebase/functions-compat@0.3.22-20250512211235": version "0.3.22-20250512211235" + resolved "https://registry.npmjs.org/@firebase/functions-compat/-/functions-compat-0.3.22-20250512211235.tgz#2ce718de863e7a26a9ec2f7e19ab6a15cb375306" + integrity sha512-/CrVsUlcVKoCtuzpYzIfBYjdiCBtpMkDIY3M2/MIKv5gwB90ydX4E2OP/E57Ne85eiYfezYoGurt27OXSno/Fg== dependencies: "@firebase/component" "0.6.15-20250512211235" "@firebase/functions" "0.12.5-20250512211235" @@ -1380,6 +1331,8 @@ "@firebase/functions@0.12.5-20250512211235": version "0.12.5-20250512211235" + resolved "https://registry.npmjs.org/@firebase/functions/-/functions-0.12.5-20250512211235.tgz#17696d8918136e319459628a43ea45e08e9bfa39" + integrity sha512-3BTjMHjx4ulr22+G1/ut8ZQW6OTGmpS5LC+2MhTl/W8OgSYP+3Hc844OhhlDq4kBjcWO752PG2+I1JwJNK6rPA== dependencies: "@firebase/app-check-interop-types" "0.3.3" "@firebase/auth-interop-types" "0.2.4" @@ -1390,6 +1343,8 @@ "@firebase/installations-compat@0.2.15-20250512211235": version "0.2.15-20250512211235" + resolved "https://registry.npmjs.org/@firebase/installations-compat/-/installations-compat-0.2.15-20250512211235.tgz#5c91a48c29c358164fe34f254f1509b7404373ca" + integrity sha512-i7sV28ZLE8p65lHyy/vni93aiIKIyo7PuOUNyaMnfdam++Sv2mBkNj0koo9B6LidDaWxZ3gZJ2bTxSyPOOukYg== dependencies: "@firebase/component" "0.6.15-20250512211235" "@firebase/installations" "0.6.15-20250512211235" @@ -1404,6 +1359,8 @@ "@firebase/installations@0.6.15-20250512211235": version "0.6.15-20250512211235" + resolved "https://registry.npmjs.org/@firebase/installations/-/installations-0.6.15-20250512211235.tgz#c0b5b07feda48a92b72e7d919a2a2f524a632b35" + integrity sha512-RinZjbNpImsz0JGi6u6B6Yb7ezrE6ej2pdBT7K3ju1cScpBmKRBeWSl7AevD5PEH+W9E5i6U2VX+q2gycI3ZRA== dependencies: "@firebase/component" "0.6.15-20250512211235" "@firebase/util" "1.12.0-20250512211235" @@ -1419,6 +1376,8 @@ "@firebase/messaging-compat@0.2.19-20250512211235": version "0.2.19-20250512211235" + resolved "https://registry.npmjs.org/@firebase/messaging-compat/-/messaging-compat-0.2.19-20250512211235.tgz#1980cc4c931085742e568596d7b28af0853aa020" + integrity sha512-vTL0hMyPosU/WRvZ1xmi01aURJyjUI3zeBByYnnwSUJN01eF0YX7eM1RId/HSFcHoT/HgfsHFvINUFjy58TVUQ== dependencies: "@firebase/component" "0.6.15-20250512211235" "@firebase/messaging" "0.12.19-20250512211235" @@ -1432,6 +1391,8 @@ "@firebase/messaging@0.12.19-20250512211235": version "0.12.19-20250512211235" + resolved "https://registry.npmjs.org/@firebase/messaging/-/messaging-0.12.19-20250512211235.tgz#f225f480879c8a550d2927d314ae62e17f30355f" + integrity sha512-h4fraiJuJrLSOSI6WIFlbV1u6L6/8zPfTzcNxqyjCIVj5eFVpgoLIW5lQ2O+G6h6RQiWG29AJkuWGnp26BOJ6Q== dependencies: "@firebase/component" "0.6.15-20250512211235" "@firebase/installations" "0.6.15-20250512211235" @@ -1442,6 +1403,8 @@ "@firebase/performance-compat@0.2.17-20250512211235": version "0.2.17-20250512211235" + resolved "https://registry.npmjs.org/@firebase/performance-compat/-/performance-compat-0.2.17-20250512211235.tgz#ead4a1201effd57aef5a8e1a4353196d6bde9b41" + integrity sha512-5uUlGWbEyoTzGa0JaS6OIUl5T69VwK4gYRAjcET79kuVSZU85l4M1gsDbXqhl/YH1o/gpQEPmm1T1UrK9bRQbw== dependencies: "@firebase/component" "0.6.15-20250512211235" "@firebase/logger" "0.4.4" @@ -1457,6 +1420,8 @@ "@firebase/performance@0.7.4-20250512211235": version "0.7.4-20250512211235" + resolved "https://registry.npmjs.org/@firebase/performance/-/performance-0.7.4-20250512211235.tgz#fadf55c6e8072320e8660e1b8dd97e3d3561650f" + integrity sha512-defCXX20kxX05/3b4qI+V2PreeH/qwn1Egvp82geS+hGyK6cDRFGgV7q94tIcc6idQJoRhsSW32ABKdI99XpWg== dependencies: "@firebase/component" "0.6.15-20250512211235" "@firebase/installations" "0.6.15-20250512211235" @@ -1467,6 +1432,8 @@ "@firebase/remote-config-compat@0.2.15-20250512211235": version "0.2.15-20250512211235" + resolved "https://registry.npmjs.org/@firebase/remote-config-compat/-/remote-config-compat-0.2.15-20250512211235.tgz#cb391f23f46aea88e3df0a7f1edb15d24000e965" + integrity sha512-DiHaFVywKBG1GGziN/NA5k8qkvJ68gX+AFe63yQOmzAfvH59W+dbxAgSG116pGrfF3xDH/e/lho4Cs3M6tbL8g== dependencies: "@firebase/component" "0.6.15-20250512211235" "@firebase/logger" "0.4.4" @@ -1482,6 +1449,8 @@ "@firebase/remote-config@0.6.2-20250512211235": version "0.6.2-20250512211235" + resolved "https://registry.npmjs.org/@firebase/remote-config/-/remote-config-0.6.2-20250512211235.tgz#c19a7057fdb4493efc70c065cebd85b0841744ee" + integrity sha512-FR/IDz/AkQiSXXZw80OJEl/MT++URfbrrUDev3p1Dgc5yuz2hGCReuiq/YYVTA3n/yppwY+BnRdVidV9dRaHSQ== dependencies: "@firebase/component" "0.6.15-20250512211235" "@firebase/installations" "0.6.15-20250512211235" @@ -1491,6 +1460,8 @@ "@firebase/storage-compat@0.3.19-20250512211235": version "0.3.19-20250512211235" + resolved "https://registry.npmjs.org/@firebase/storage-compat/-/storage-compat-0.3.19-20250512211235.tgz#d81a8cd4fb7c5222d11e8c4f67f83f48c8d064f6" + integrity sha512-Qz3kRo4qc6wRSDq/sCRT9ITqT/Of4puErdhideN+GBi40m42bLWOqBkxpkzPmHphOmFNwKUBA8/9Cksr/fj6IA== dependencies: "@firebase/component" "0.6.15-20250512211235" "@firebase/storage" "0.13.9-20250512211235" @@ -1505,12 +1476,14 @@ "@firebase/storage@0.13.9-20250512211235": version "0.13.9-20250512211235" + resolved "https://registry.npmjs.org/@firebase/storage/-/storage-0.13.9-20250512211235.tgz#1d809b25797bd118ee9b83ac220d8a6ae0eafed8" + integrity sha512-68vuBOmYVUu93Tbri++ubk8ECASRQWYnB1cvPpfBT0WoLSgdgxj+2F/+buXqzFZT/3ae8FBcEdgK6cD0gcT7tA== dependencies: "@firebase/component" "0.6.15-20250512211235" "@firebase/util" "1.12.0-20250512211235" tslib "^2.1.0" -"@firebase/util@1.11.1", "@firebase/util@1.x": +"@firebase/util@1.11.1": version "1.11.1" resolved "https://registry.npmjs.org/@firebase/util/-/util-1.11.1.tgz" integrity sha512-RXg4WE8C2LUrvoV/TMGRTu223zZf9Dq9MR8yHZio9nF9TpLnpCPURw9VWWB2WATDl6HfIdWfl2x2SJYtHkN4hw== @@ -1787,14 +1760,6 @@ resolved "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz" integrity sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ== -"@jridgewell/trace-mapping@^0.3.12", "@jridgewell/trace-mapping@^0.3.18", "@jridgewell/trace-mapping@^0.3.24", "@jridgewell/trace-mapping@^0.3.25": - version "0.3.25" - resolved "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz" - integrity sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ== - dependencies: - "@jridgewell/resolve-uri" "^3.1.0" - "@jridgewell/sourcemap-codec" "^1.4.14" - "@jridgewell/trace-mapping@0.3.9": version "0.3.9" resolved "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz" @@ -1803,6 +1768,14 @@ "@jridgewell/resolve-uri" "^3.0.3" "@jridgewell/sourcemap-codec" "^1.4.10" +"@jridgewell/trace-mapping@^0.3.12", "@jridgewell/trace-mapping@^0.3.18", "@jridgewell/trace-mapping@^0.3.24", "@jridgewell/trace-mapping@^0.3.25": + version "0.3.25" + resolved "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz" + integrity sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ== + dependencies: + "@jridgewell/resolve-uri" "^3.1.0" + "@jridgewell/sourcemap-codec" "^1.4.14" + "@jsonjoy.com/base64@^1.1.1": version "1.1.2" resolved "https://registry.npmjs.org/@jsonjoy.com/base64/-/base64-1.1.2.tgz" @@ -1990,18 +1963,24 @@ "@types/eslint-scope@^3.7.7": version "3.7.7" + resolved "https://registry.npmjs.org/@types/eslint-scope/-/eslint-scope-3.7.7.tgz#3108bd5f18b0cdb277c867b3dd449c9ed7079ac5" + integrity sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg== dependencies: "@types/eslint" "*" "@types/estree" "*" "@types/eslint@*": version "9.6.1" + resolved "https://registry.npmjs.org/@types/eslint/-/eslint-9.6.1.tgz#d5795ad732ce81715f27f75da913004a56751584" + integrity sha512-FXx2pKgId/WyYo2jXw63kk7/+TY7u7AziEJxJAnSFzHlqTAS3Ync6SvgYAN/k4/PQpnnVuzoMuVnByKK2qp0ag== dependencies: "@types/estree" "*" "@types/json-schema" "*" "@types/estree@*", "@types/estree@^1.0.6": version "1.0.7" + resolved "https://registry.npmjs.org/@types/estree/-/estree-1.0.7.tgz#4158d3105276773d5b7695cd4834b1722e4f37a8" + integrity sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ== "@types/express-serve-static-core@*", "@types/express-serve-static-core@^5.0.0": version "5.0.1" @@ -2033,7 +2012,7 @@ "@types/qs" "*" "@types/serve-static" "*" -"@types/express@^4.17.13", "@types/express@^4.17.21": +"@types/express@^4.17.21": version "4.17.21" resolved "https://registry.npmjs.org/@types/express/-/express-4.17.21.tgz" integrity sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ== @@ -2202,7 +2181,7 @@ dependencies: "@types/yargs-parser" "*" -"@webassemblyjs/ast@^1.14.1", "@webassemblyjs/ast@1.14.1": +"@webassemblyjs/ast@1.14.1", "@webassemblyjs/ast@^1.14.1": version "1.14.1" resolved "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.14.1.tgz" integrity sha512-nuBEDgQfm1ccRp/8bCQrx1frohyufl4JlbMMZ4P1wpeOfDhF6FQkxZJ1b/e+PLwr6X1Nhw6OLme5usuBWYBvuQ== @@ -2270,6 +2249,8 @@ "@webassemblyjs/wasm-edit@^1.14.1": version "1.14.1" + resolved "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.14.1.tgz#ac6689f502219b59198ddec42dcd496b1004d597" + integrity sha512-RNJUIQH/J8iA/1NzlE4N7KtyZNHi3w7at7hDjvRNm5rcUXa00z1vRz3glZoULfJ5mpvYhLybmVcwcjGrC1pRrQ== dependencies: "@webassemblyjs/ast" "1.14.1" "@webassemblyjs/helper-buffer" "1.14.1" @@ -2301,7 +2282,7 @@ "@webassemblyjs/wasm-gen" "1.14.1" "@webassemblyjs/wasm-parser" "1.14.1" -"@webassemblyjs/wasm-parser@^1.14.1", "@webassemblyjs/wasm-parser@1.14.1": +"@webassemblyjs/wasm-parser@1.14.1", "@webassemblyjs/wasm-parser@^1.14.1": version "1.14.1" resolved "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.14.1.tgz" integrity sha512-JLBl+KZ0R5qB7mCnud/yyX08jWFw5MsoalJ1pQ4EdFlgj9VdXKGuENGsiCIjegI1W7p91rUlcB/LB5yRJKNTcQ== @@ -2381,6 +2362,8 @@ acorn@^8.1.0, acorn@^8.11.0, acorn@^8.4.1, acorn@^8.8.1: acorn@^8.14.0: version "8.14.1" + resolved "https://registry.npmjs.org/acorn/-/acorn-8.14.1.tgz#721d5dc10f7d5b5609a891773d47731796935dfb" + integrity sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg== acorn@^8.8.2: version "8.13.0" @@ -2413,7 +2396,7 @@ ajv-keywords@^5.1.0: dependencies: fast-deep-equal "^3.1.3" -ajv@^6.12.4, ajv@^6.9.1: +ajv@^6.12.4: version "6.12.6" resolved "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz" integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== @@ -2423,7 +2406,7 @@ ajv@^6.12.4, ajv@^6.9.1: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ajv@^8.0.0, ajv@^8.8.2, ajv@^8.9.0: +ajv@^8.0.0, ajv@^8.9.0: version "8.17.1" resolved "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz" integrity sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g== @@ -2492,7 +2475,7 @@ asynckit@^0.4.0: resolved "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz" integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== -babel-jest@^29.7.0, babel-jest@29.7.0: +babel-jest@29.7.0, babel-jest@^29.7.0: version "29.7.0" resolved "https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz" integrity sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg== @@ -2650,7 +2633,7 @@ braces@^3.0.3, braces@~3.0.2: dependencies: fill-range "^7.1.1" -browserslist@^4.24.0, "browserslist@>= 4.21.0": +browserslist@^4.24.0: version "4.24.2" resolved "https://registry.npmjs.org/browserslist/-/browserslist-4.24.2.tgz" integrity sha512-ZIc+Q62revdMcqC6aChtW4jz3My3klmCO1fEmINZY/8J3EpBg5/A/D0AKmBveUh6pgoeycoMkVMko84tuYS+Gg== @@ -2967,13 +2950,6 @@ data-urls@^3.0.2: whatwg-mimetype "^3.0.0" whatwg-url "^11.0.0" -debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@4: - version "4.3.7" - resolved "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz" - integrity sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ== - dependencies: - ms "^2.1.3" - debug@2.6.9: version "2.6.9" resolved "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz" @@ -2981,6 +2957,13 @@ debug@2.6.9: dependencies: ms "2.0.0" +debug@4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1: + version "4.3.7" + resolved "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz" + integrity sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ== + dependencies: + ms "^2.1.3" + decimal.js@^10.4.2: version "10.4.3" resolved "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz" @@ -3028,16 +3011,16 @@ delayed-stream@~1.0.0: resolved "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz" integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== -depd@~1.1.2: - version "1.1.2" - resolved "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz" - integrity sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ== - depd@2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz" integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== +depd@~1.1.2: + version "1.1.2" + resolved "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz" + integrity sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ== + destroy@1.2.0: version "1.2.0" resolved "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz" @@ -3323,7 +3306,7 @@ fastest-levenshtein@^1.0.12: resolved "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz" integrity sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg== -faye-websocket@^0.11.3, faye-websocket@0.11.4: +faye-websocket@0.11.4, faye-websocket@^0.11.3: version "0.11.4" resolved "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.11.4.tgz" integrity sha512-CzbClwlXAuiRQAlUyfqPgvPoNKTckTPGfwZV4ZdAhVcP2lh9KUxJg2b5GkE7XbjKQ3YJnQ9z6D9ntLAlB+tP8g== @@ -3585,16 +3568,6 @@ http-deceiver@^1.2.7: resolved "https://registry.npmjs.org/http-deceiver/-/http-deceiver-1.2.7.tgz" integrity sha512-LmpOGxTfbpgtGVxJrj5k7asXHCgNZp5nLfp+hWc8QQRqtb7fUy6kRY3BO1h9ddF6yIPYUARgxGOwB42DnxIaNw== -http-errors@~1.6.2: - version "1.6.3" - resolved "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz" - integrity sha512-lks+lVC8dgGyh97jxvxeYTWQFvh4uw4yC12gVl63Cg30sjPX4wuGcdkICVXDAESr6OJGjqGA8Iz5mkeN6zlD7A== - dependencies: - depd "~1.1.2" - inherits "2.0.3" - setprototypeof "1.1.0" - statuses ">= 1.4.0 < 2" - http-errors@2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz" @@ -3606,6 +3579,16 @@ http-errors@2.0.0: statuses "2.0.1" toidentifier "1.0.1" +http-errors@~1.6.2: + version "1.6.3" + resolved "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz" + integrity sha512-lks+lVC8dgGyh97jxvxeYTWQFvh4uw4yC12gVl63Cg30sjPX4wuGcdkICVXDAESr6OJGjqGA8Iz5mkeN6zlD7A== + dependencies: + depd "~1.1.2" + inherits "2.0.3" + setprototypeof "1.1.0" + statuses ">= 1.4.0 < 2" + http-parser-js@>=0.5.1: version "0.5.8" resolved "https://registry.npmjs.org/http-parser-js/-/http-parser-js-0.5.8.tgz" @@ -3698,7 +3681,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.3, inherits@2, inherits@2.0.4: +inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.3: version "2.0.4" resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -3713,16 +3696,16 @@ interpret@^3.1.1: resolved "https://registry.npmjs.org/interpret/-/interpret-3.1.1.tgz" integrity sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ== -ipaddr.js@^2.1.0: - version "2.2.0" - resolved "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.2.0.tgz" - integrity sha512-Ag3wB2o37wslZS19hZqorUnrnzSkpOVy+IiiDEiTqNubEYpYuHWIf6K4psgN2ZWKExS4xhVCrRVfb/wfW8fWJA== - ipaddr.js@1.9.1: version "1.9.1" resolved "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz" integrity sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g== +ipaddr.js@^2.1.0: + version "2.2.0" + resolved "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.2.0.tgz" + integrity sha512-Ag3wB2o37wslZS19hZqorUnrnzSkpOVy+IiiDEiTqNubEYpYuHWIf6K4psgN2ZWKExS4xhVCrRVfb/wfW8fWJA== + is-arrayish@^0.2.1: version "0.2.1" resolved "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz" @@ -4101,7 +4084,7 @@ jest-resolve-dependencies@^29.7.0: jest-regex-util "^29.6.3" jest-snapshot "^29.7.0" -jest-resolve@*, jest-resolve@^29.7.0: +jest-resolve@^29.7.0: version "29.7.0" resolved "https://registry.npmjs.org/jest-resolve/-/jest-resolve-29.7.0.tgz" integrity sha512-IOVhZSrg+UvVAshDSDtHyFCCBUl/Q3AAJv8iZ6ZjnZ74xzvwuzLXid9IIIPgTnY62SJjfuupMKZsZQRsCvxEgA== @@ -4469,16 +4452,16 @@ micromatch@^4.0.2, micromatch@^4.0.4: braces "^3.0.3" picomatch "^2.3.1" -"mime-db@>= 1.43.0 < 2": - version "1.53.0" - resolved "https://registry.npmjs.org/mime-db/-/mime-db-1.53.0.tgz" - integrity sha512-oHlN/w+3MQ3rba9rqFr6V/ypF10LSkdwUysQL7GkXoTgIWeV+tcXGA852TBxH+gsh8UWoyhR1hKcoMJTuWflpg== - mime-db@1.52.0: version "1.52.0" resolved "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz" integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== +"mime-db@>= 1.43.0 < 2": + version "1.53.0" + resolved "https://registry.npmjs.org/mime-db/-/mime-db-1.53.0.tgz" + integrity sha512-oHlN/w+3MQ3rba9rqFr6V/ypF10LSkdwUysQL7GkXoTgIWeV+tcXGA852TBxH+gsh8UWoyhR1hKcoMJTuWflpg== + mime-types@^2.1.12, mime-types@^2.1.27, mime-types@^2.1.31, mime-types@~2.1.17, mime-types@~2.1.24, mime-types@~2.1.34: version "2.1.35" resolved "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz" @@ -4508,16 +4491,16 @@ minimatch@^3.0.4, minimatch@^3.1.1: dependencies: brace-expansion "^1.1.7" -ms@^2.1.3, ms@2.1.3: - version "2.1.3" - resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz" - integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== - ms@2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz" integrity sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A== +ms@2.1.3, ms@^2.1.3: + version "2.1.3" + resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + multicast-dns@^7.2.5: version "7.2.5" resolved "https://registry.npmjs.org/multicast-dns/-/multicast-dns-7.2.5.tgz" @@ -4588,7 +4571,7 @@ obuf@^1.0.0, obuf@^1.1.2: resolved "https://registry.npmjs.org/obuf/-/obuf-1.1.2.tgz" integrity sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg== -on-finished@^2.4.1, on-finished@2.4.1: +on-finished@2.4.1, on-finished@^2.4.1: version "2.4.1" resolved "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz" integrity sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg== @@ -4967,20 +4950,15 @@ run-applescript@^7.0.0: resolved "https://registry.npmjs.org/run-applescript/-/run-applescript-7.0.0.tgz" integrity sha512-9by4Ij99JUr/MCFBUkDKLWK3G9HVXmabKz9U5MlIAIuvuzkiOicRYs8XJLxX+xahD+mLiiCYDqF9dKAgtzKP1A== -safe-buffer@^5.1.0, safe-buffer@>=5.1.0, safe-buffer@~5.2.0, safe-buffer@5.2.1: - version "5.2.1" - resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -safe-buffer@~5.1.0, safe-buffer@~5.1.1: +safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.2" resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -safe-buffer@5.1.2: - version "5.1.2" - resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz" - integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== +safe-buffer@5.2.1, safe-buffer@>=5.1.0, safe-buffer@^5.1.0, safe-buffer@~5.2.0: + version "5.2.1" + resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== "safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0": version "2.1.2" @@ -5041,12 +5019,7 @@ semver@^6.0.0, semver@^6.3.0, semver@^6.3.1: resolved "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz" integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== -semver@^7.5.3: - version "7.6.3" - resolved "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz" - integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A== - -semver@^7.5.4: +semver@^7.5.3, semver@^7.5.4: version "7.6.3" resolved "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz" integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A== @@ -5180,14 +5153,6 @@ sockjs@^0.3.24: uuid "^8.3.2" websocket-driver "^0.7.4" -source-map-support@~0.5.20: - version "0.5.21" - resolved "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz" - integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - source-map-support@0.5.13: version "0.5.13" resolved "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz" @@ -5196,6 +5161,14 @@ source-map-support@0.5.13: buffer-from "^1.0.0" source-map "^0.6.0" +source-map-support@~0.5.20: + version "0.5.21" + resolved "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz" + integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: version "0.6.1" resolved "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz" @@ -5236,29 +5209,15 @@ stack-utils@^2.0.3: dependencies: escape-string-regexp "^2.0.0" -"statuses@>= 1.4.0 < 2": - version "1.5.0" - resolved "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz" - integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== - statuses@2.0.1: version "2.0.1" resolved "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz" integrity sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ== -string_decoder@^1.1.1: - version "1.3.0" - resolved "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz" - integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== - dependencies: - safe-buffer "~5.2.0" - -string_decoder@~1.1.1: - version "1.1.1" - resolved "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz" - integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== - dependencies: - safe-buffer "~5.1.0" +"statuses@>= 1.4.0 < 2": + version "1.5.0" + resolved "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz" + integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== string-length@^4.0.1: version "4.0.2" @@ -5277,6 +5236,20 @@ string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.1" +string_decoder@^1.1.1: + version "1.3.0" + resolved "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz" + integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== + dependencies: + safe-buffer "~5.2.0" + +string_decoder@~1.1.1: + version "1.1.1" + resolved "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz" + integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== + dependencies: + safe-buffer "~5.1.0" + strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz" @@ -5330,6 +5303,8 @@ tapable@^2.1.1, tapable@^2.2.0: terser-webpack-plugin@^5.3.11: version "5.3.14" + resolved "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.14.tgz#9031d48e57ab27567f02ace85c7d690db66c3e06" + integrity sha512-vkZjpUjb6OMS7dhV+tILUW6BhpDR7P2L/aQSAv+Uwk+m8KATX9EccViHTJR2qDtACKPIYndLGCyl3FMo+r2LMw== dependencies: "@jridgewell/trace-mapping" "^0.3.25" jest-worker "^27.4.5" @@ -5405,7 +5380,7 @@ tree-dump@^1.0.1: resolved "https://registry.npmjs.org/tree-dump/-/tree-dump-1.0.2.tgz" integrity sha512-dpev9ABuLWdEubk+cIaI9cHwRNNDjkBBLXTwI4UCUFdQ5xXKqNXoK4FEciw/vxf+NQ7Cb7sGUyeUtORvHIdRXQ== -ts-node@>=9.0.0, ts-node@10.9.2: +ts-node@10.9.2: version "10.9.2" resolved "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz" integrity sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ== @@ -5424,7 +5399,7 @@ ts-node@>=9.0.0, ts-node@10.9.2: v8-compile-cache-lib "^3.0.1" yn "3.1.1" -tslib@^2, tslib@^2.0.0, tslib@^2.1.0, tslib@2: +tslib@^2.0.0, tslib@^2.1.0: version "2.8.0" resolved "https://registry.npmjs.org/tslib/-/tslib-2.8.0.tgz" integrity sha512-jWVzBLplnCmoaTr13V9dYbiQ99wvZRd0vNWaDRg+aVYRcjDF3nDksxFDE/+fkXnKhpnUUkmx5pK/v8mCtLVqZA== @@ -5447,7 +5422,7 @@ type-is@~1.6.18: media-typer "0.3.0" mime-types "~2.1.24" -typescript@>=2.7, typescript@5.5.4: +typescript@5.5.4: version "5.5.4" resolved "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz" integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q== @@ -5485,7 +5460,7 @@ universalify@^0.2.0: resolved "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz" integrity sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg== -unpipe@~1.0.0, unpipe@1.0.0: +unpipe@1.0.0, unpipe@~1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz" integrity sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ== @@ -5586,7 +5561,7 @@ webidl-conversions@^7.0.0: resolved "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz" integrity sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g== -webpack-cli@5.1.4, webpack-cli@5.x.x: +webpack-cli@5.1.4: version "5.1.4" resolved "https://registry.npmjs.org/webpack-cli/-/webpack-cli-5.1.4.tgz" integrity sha512-pIDJHIEI9LR0yxHXQ+Qh95k2EvXpWzZ5l+d+jIo+RdSm9MiHfzazIxwwni/p7+x4eJZuvG1AJwgC4TNQ7NRgsg== @@ -5664,8 +5639,10 @@ webpack-sources@^3.2.3: resolved "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz" integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== -webpack@^5.0.0, webpack@^5.1.0, webpack@>=2, webpack@5.98.0, webpack@5.x.x: +webpack@5.98.0: version "5.98.0" + resolved "https://registry.npmjs.org/webpack/-/webpack-5.98.0.tgz#44ae19a8f2ba97537978246072fb89d10d1fbd17" + integrity sha512-UFynvx+gM44Gv9qFgj0acCQK2VE1CtdfwFdimkapco3hlPCJ/zeq73n2yVKimVbtm+TnApIugGhLJnkU6gjYXA== dependencies: "@types/eslint-scope" "^3.7.7" "@types/estree" "^1.0.6" @@ -5691,7 +5668,7 @@ webpack@^5.0.0, webpack@^5.1.0, webpack@>=2, webpack@5.98.0, webpack@5.x.x: watchpack "^2.4.1" webpack-sources "^3.2.3" -websocket-driver@^0.7.4, websocket-driver@>=0.5.1: +websocket-driver@>=0.5.1, websocket-driver@^0.7.4: version "0.7.4" resolved "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.7.4.tgz" integrity sha512-b17KeDIQVjvb0ssuSDF2cYXSg2iztliJ4B9WdsuB6J952qCPKmnVq4DyW5motImXHDC1cBT/1UezrJVsKw5zjg== diff --git a/e2e/template/README.md b/e2e/template/README.md new file mode 100644 index 00000000000..ef2b2deb997 --- /dev/null +++ b/e2e/template/README.md @@ -0,0 +1,3 @@ +# E2E Test Package Template + +This is a template for an E2E test package. It contains one small dependency (date-fns) not used in the global monorepo workspace to confirm the dependencies in this directory do not affect the global workspace. \ No newline at end of file diff --git a/e2e/template/index.js b/e2e/template/index.js new file mode 100644 index 00000000000..1e3a1a5d9af --- /dev/null +++ b/e2e/template/index.js @@ -0,0 +1,18 @@ +/** + * @license + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +console.log('hello'); diff --git a/e2e/template/package.json b/e2e/template/package.json new file mode 100644 index 00000000000..c07c4c5c080 --- /dev/null +++ b/e2e/template/package.json @@ -0,0 +1,15 @@ +{ + "name": "test-project", + "version": "1.0.0", + "main": "index.js", + "scripts": { + "start": "node index.js", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "description": "", + "dependencies": { + "date-fns": "4.1.0" + } +} diff --git a/e2e/template/yarn.lock b/e2e/template/yarn.lock new file mode 100644 index 00000000000..4d7e448a31b --- /dev/null +++ b/e2e/template/yarn.lock @@ -0,0 +1,8 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +date-fns@4.1.0: + version "4.1.0" + resolved "https://registry.npmjs.org/date-fns/-/date-fns-4.1.0.tgz#64b3d83fff5aa80438f5b1a633c2e83b8a1c2d14" + integrity sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg== diff --git a/integration/compat-interop/package.json b/integration/compat-interop/package.json index 117a8220fc0..f7da859c705 100644 --- a/integration/compat-interop/package.json +++ b/integration/compat-interop/package.json @@ -8,12 +8,12 @@ "test:debug": "karma start --browsers Chrome --auto-watch" }, "dependencies": { - "@firebase/app": "0.13.0", - "@firebase/app-compat": "0.4.0", + "@firebase/app": "0.13.1", + "@firebase/app-compat": "0.4.1", "@firebase/analytics": "0.10.16", "@firebase/analytics-compat": "0.2.22", - "@firebase/auth": "1.10.6", - "@firebase/auth-compat": "0.5.26", + "@firebase/auth": "1.10.7", + "@firebase/auth-compat": "0.5.27", "@firebase/functions": "0.12.8", "@firebase/functions-compat": "0.3.25", "@firebase/messaging": "0.12.21", diff --git a/integration/firestore/package.json b/integration/firestore/package.json index 0c722a5352b..903c182a5c0 100644 --- a/integration/firestore/package.json +++ b/integration/firestore/package.json @@ -14,8 +14,8 @@ "test:memory:debug": "yarn build:memory; karma start --auto-watch --browsers Chrome" }, "dependencies": { - "@firebase/app": "0.13.0", - "@firebase/firestore": "4.7.16" + "@firebase/app": "0.13.1", + "@firebase/firestore": "4.7.17" }, "devDependencies": { "@types/mocha": "9.1.1", diff --git a/integration/messaging/package.json b/integration/messaging/package.json index 9cb2bf233fc..9c62c70ca5b 100644 --- a/integration/messaging/package.json +++ b/integration/messaging/package.json @@ -9,7 +9,7 @@ "test:manual": "mocha --exit" }, "devDependencies": { - "firebase": "11.8.1", + "firebase": "11.9.1", "chai": "4.5.0", "chromedriver": "119.0.1", "express": "4.21.2", diff --git a/packages/ai/CHANGELOG.md b/packages/ai/CHANGELOG.md index 298fb06a9b5..874cdb40e69 100644 --- a/packages/ai/CHANGELOG.md +++ b/packages/ai/CHANGELOG.md @@ -1,5 +1,13 @@ # @firebase/ai +## 1.4.0 + +### Minor Changes + +- [`1933324`](https://github.com/firebase/firebase-js-sdk/commit/1933324e0f3e4c8ed4d4d784f0c701fd0ec6ebc3) [#9026](https://github.com/firebase/firebase-js-sdk/pull/9026) - Add support for `minItems` and `maxItems` to `Schema`. + +- [`40be2db`](https://github.com/firebase/firebase-js-sdk/commit/40be2dbb884b8e1485862af8bb015e23db69ccbf) [#9047](https://github.com/firebase/firebase-js-sdk/pull/9047) - Add `title`, `maximum`, `minimum`, `propertyOrdering` to Schema builder + ## 1.3.0 ### Minor Changes diff --git a/packages/ai/integration/chat.test.ts b/packages/ai/integration/chat.test.ts new file mode 100644 index 00000000000..b6772a38fb1 --- /dev/null +++ b/packages/ai/integration/chat.test.ts @@ -0,0 +1,161 @@ +/** + * @license + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { expect } from 'chai'; +import { + Content, + GenerationConfig, + HarmBlockThreshold, + HarmCategory, + SafetySetting, + getGenerativeModel +} from '../src'; +import { testConfigs, TOKEN_COUNT_DELTA } from './constants'; + +describe('Chat Session', () => { + testConfigs.forEach(testConfig => { + describe(`${testConfig.toString()}`, () => { + const commonGenerationConfig: GenerationConfig = { + temperature: 0, + topP: 0, + responseMimeType: 'text/plain' + }; + + const commonSafetySettings: SafetySetting[] = [ + { + category: HarmCategory.HARM_CATEGORY_HARASSMENT, + threshold: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE + }, + { + category: HarmCategory.HARM_CATEGORY_HATE_SPEECH, + threshold: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE + }, + { + category: HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT, + threshold: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE + }, + { + category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT, + threshold: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE + } + ]; + + const commonSystemInstruction: Content = { + role: 'system', + parts: [ + { + text: 'You are a friendly and helpful assistant.' + } + ] + }; + + it('startChat and sendMessage: text input, text output', async () => { + const model = getGenerativeModel(testConfig.ai, { + model: testConfig.model, + generationConfig: commonGenerationConfig, + safetySettings: commonSafetySettings, + systemInstruction: commonSystemInstruction + }); + + const chat = model.startChat(); + const result1 = await chat.sendMessage( + 'What is the capital of France?' + ); + const response1 = result1.response; + const result2 = await chat.sendMessage('And what about Italy?'); + const response2 = result2.response; + const history = await chat.getHistory(); + + expect(response1.text().trim().toLowerCase()).to.include('paris'); + expect(response1.usageMetadata).to.not.be.null; + expect(response2.text().trim().toLowerCase()).to.include('rome'); + expect(response2.usageMetadata).to.not.be.null; + expect(history.length).to.equal(4); + expect(history[0].role).to.equal('user'); + expect(history[0].parts[0].text).to.equal( + 'What is the capital of France?' + ); + expect(history[1].role).to.equal('model'); + expect(history[1].parts[0].text?.toLowerCase()).to.include('paris'); + expect(history[2].role).to.equal('user'); + expect(history[2].parts[0].text).to.equal('And what about Italy?'); + expect(history[3].role).to.equal('model'); + expect(history[3].parts[0].text?.toLowerCase()).to.include('rome'); + + if (model.model.includes('gemini-2.5-flash')) { + // Token counts can vary slightly in chat context + expect(response1.usageMetadata!.promptTokenCount).to.be.closeTo( + 17, // "What is the capital of France?" + system instruction + TOKEN_COUNT_DELTA + 2 // More variance for chat context + ); + expect(response1.usageMetadata!.candidatesTokenCount).to.be.closeTo( + 8, // "Paris" + TOKEN_COUNT_DELTA + ); + expect(response1.usageMetadata!.totalTokenCount).to.be.closeTo( + 49, // "What is the capital of France?" + system instruction + "Paris" + TOKEN_COUNT_DELTA + 3 // More variance for chat context + ); + expect(response1.usageMetadata!.totalTokenCount).to.be.closeTo( + 49, // "What is the capital of France?" + system instruction + "Paris" + TOKEN_COUNT_DELTA + 3 // More variance for chat context + ); + + expect(response2.usageMetadata!.promptTokenCount).to.be.closeTo( + 32, // History + "And what about Italy?" + system instruction + TOKEN_COUNT_DELTA + 5 // More variance for chat context with history + ); + expect(response2.usageMetadata!.candidatesTokenCount).to.be.closeTo( + 8, + TOKEN_COUNT_DELTA + ); + expect(response2.usageMetadata!.totalTokenCount).to.be.closeTo( + 68, + TOKEN_COUNT_DELTA + 2 + ); + } else if (model.model.includes('gemini-2.0-flash')) { + expect(response1.usageMetadata).to.not.be.null; + // Token counts can vary slightly in chat context + expect(response1.usageMetadata!.promptTokenCount).to.be.closeTo( + 15, // "What is the capital of France?" + system instruction + TOKEN_COUNT_DELTA + 2 // More variance for chat context + ); + expect(response1.usageMetadata!.candidatesTokenCount).to.be.closeTo( + 8, // "Paris" + TOKEN_COUNT_DELTA + ); + expect(response1.usageMetadata!.totalTokenCount).to.be.closeTo( + 23, // "What is the capital of France?" + system instruction + "Paris" + TOKEN_COUNT_DELTA + 3 // More variance for chat context + ); + expect(response2.usageMetadata!.promptTokenCount).to.be.closeTo( + 28, // History + "And what about Italy?" + system instruction + TOKEN_COUNT_DELTA + 5 // More variance for chat context with history + ); + expect(response2.usageMetadata!.candidatesTokenCount).to.be.closeTo( + 8, + TOKEN_COUNT_DELTA + ); + expect(response2.usageMetadata!.totalTokenCount).to.be.closeTo( + 36, + TOKEN_COUNT_DELTA + ); + } + }); + }); + }); +}); diff --git a/packages/ai/integration/constants.ts b/packages/ai/integration/constants.ts new file mode 100644 index 00000000000..1adfa4f47a0 --- /dev/null +++ b/packages/ai/integration/constants.ts @@ -0,0 +1,81 @@ +/** + * @license + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { initializeApp } from '@firebase/app'; +import { + AI, + Backend, + BackendType, + GoogleAIBackend, + VertexAIBackend, + getAI +} from '../src'; +import { FIREBASE_CONFIG } from './firebase-config'; + +const app = initializeApp(FIREBASE_CONFIG); + +/** + * Test config that all tests will be ran against. + */ +export type TestConfig = Readonly<{ + ai: AI; + model: string; + /** This will be used to output the test config at runtime */ + toString: () => string; +}>; + +function formatConfigAsString(config: { ai: AI; model: string }): string { + return `${backendNames.get(config.ai.backend.backendType)} ${config.model}`; +} + +const backends: readonly Backend[] = [ + new GoogleAIBackend(), + new VertexAIBackend() +]; + +const backendNames: Map = new Map([ + [BackendType.GOOGLE_AI, 'Google AI'], + [BackendType.VERTEX_AI, 'Vertex AI'] +]); + +const modelNames: readonly string[] = ['gemini-2.0-flash', 'gemini-2.5-flash']; + +/** + * Array of test configurations that is iterated over to get full coverage + * of backends and models. Contains all combinations of backends and models. + */ +export const testConfigs: readonly TestConfig[] = backends.flatMap(backend => { + return modelNames.map(modelName => { + const ai = getAI(app, { backend }); + return { + ai: getAI(app, { backend }), + model: modelName, + toString: () => formatConfigAsString({ ai, model: modelName }) + }; + }); +}); + +export const TINY_IMG_BASE64 = + 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII='; +export const IMAGE_MIME_TYPE = 'image/png'; +export const TINY_MP3_BASE64 = + 'SUQzBAAAAAAAIlRTU0UAAAAOAAADTGF2ZjYxLjcuMTAwAAAAAAAAAAAAAAD/+0DAAAAAAAAAAAAAAAAAAAAAAABJbmZvAAAADwAAAAUAAAK+AGhoaGhoaGhoaGhoaGhoaGhoaGiOjo6Ojo6Ojo6Ojo6Ojo6Ojo6OjrS0tLS0tLS0tLS0tLS0tLS0tLS02tra2tra2tra2tra2tra2tra2tr//////////////////////////wAAAABMYXZjNjEuMTkAAAAAAAAAAAAAAAAkAwYAAAAAAAACvhC6DYoAAAAAAP/7EMQAA8AAAaQAAAAgAAA0gAAABExBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//sQxCmDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+xDEUwPAAAGkAAAAIAAANIAAAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7EMR8g8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//sQxKYDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVU='; +export const AUDIO_MIME_TYPE = 'audio/mpeg'; + +// Token counts are only expected to differ by at most this number of tokens. +// Set to 1 for whitespace that is not always present. +export const TOKEN_COUNT_DELTA = 1; diff --git a/packages/ai/integration/count-tokens.test.ts b/packages/ai/integration/count-tokens.test.ts new file mode 100644 index 00000000000..3256a9ed9d7 --- /dev/null +++ b/packages/ai/integration/count-tokens.test.ts @@ -0,0 +1,286 @@ +/** + * @license + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { expect } from 'chai'; +import { + Content, + GenerationConfig, + HarmBlockMethod, + HarmBlockThreshold, + HarmCategory, + Modality, + SafetySetting, + getGenerativeModel, + Part, + CountTokensRequest, + InlineDataPart, + FileDataPart, + BackendType +} from '../src'; +import { + AUDIO_MIME_TYPE, + IMAGE_MIME_TYPE, + TINY_IMG_BASE64, + TINY_MP3_BASE64, + testConfigs +} from './constants'; +import { FIREBASE_CONFIG } from './firebase-config'; + +describe('Count Tokens', () => { + testConfigs.forEach(testConfig => { + describe(`${testConfig.toString()}`, () => { + it('text input', async () => { + const generationConfig: GenerationConfig = { + temperature: 0, + topP: 0, + responseMimeType: 'text/plain' + }; + + const safetySettings: SafetySetting[] = [ + { + category: HarmCategory.HARM_CATEGORY_HARASSMENT, + threshold: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE, + method: HarmBlockMethod.PROBABILITY + }, + { + category: HarmCategory.HARM_CATEGORY_HATE_SPEECH, + threshold: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE, + method: HarmBlockMethod.SEVERITY + }, + { + category: HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT, + threshold: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE + }, + { + category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT, + threshold: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE + } + ]; + + const systemInstruction: Content = { + role: 'system', + parts: [ + { + text: 'You are a friendly and helpful assistant.' + } + ] + }; + const model = getGenerativeModel(testConfig.ai, { + model: testConfig.model, + generationConfig, + systemInstruction, + safetySettings + }); + + const response = await model.countTokens('Why is the sky blue?'); + + expect(response.promptTokensDetails).to.exist; + expect(response.promptTokensDetails!.length).to.equal(1); + expect(response.promptTokensDetails![0].modality).to.equal( + Modality.TEXT + ); + if (testConfig.ai.backend.backendType === BackendType.GOOGLE_AI) { + expect(response.totalTokens).to.equal(7); + expect(response.totalBillableCharacters).to.be.undefined; + expect(response.promptTokensDetails![0].tokenCount).to.equal(7); + } else if ( + testConfig.ai.backend.backendType === BackendType.VERTEX_AI + ) { + expect(response.totalTokens).to.equal(6); + expect(response.totalBillableCharacters).to.equal(16); + expect(response.promptTokensDetails![0].tokenCount).to.equal(6); + } + }); + + it('image input', async () => { + const model = getGenerativeModel(testConfig.ai, { + model: testConfig.model + }); + const imagePart: Part = { + inlineData: { + mimeType: IMAGE_MIME_TYPE, + data: TINY_IMG_BASE64 + } + }; + const response = await model.countTokens([imagePart]); + + if (testConfig.ai.backend.backendType === BackendType.GOOGLE_AI) { + const expectedImageTokens = 259; + expect(response.totalTokens).to.equal(expectedImageTokens); + expect(response.totalBillableCharacters).to.be.undefined; // Incorrect behavior + expect(response.promptTokensDetails!.length).to.equal(2); + expect(response.promptTokensDetails![0]).to.deep.equal({ + modality: Modality.TEXT, // Note: 1 unexpected text token observed for Google AI with image-only input. + tokenCount: 1 + }); + expect(response.promptTokensDetails![1]).to.deep.equal({ + modality: Modality.IMAGE, + tokenCount: 258 + }); + } else if ( + testConfig.ai.backend.backendType === BackendType.VERTEX_AI + ) { + const expectedImageTokens = 258; + expect(response.totalTokens).to.equal(expectedImageTokens); + expect(response.totalBillableCharacters).to.be.undefined; // Incorrect behavior + expect(response.promptTokensDetails!.length).to.equal(1); + // Note: No text tokens are present for Vertex AI with image-only input. + expect(response.promptTokensDetails![0]).to.deep.equal({ + modality: Modality.IMAGE, + tokenCount: 258 + }); + expect(response.promptTokensDetails![0].tokenCount).to.equal( + expectedImageTokens + ); + } + }); + + it('audio input', async () => { + const model = getGenerativeModel(testConfig.ai, { + model: testConfig.model + }); + const audioPart: InlineDataPart = { + inlineData: { + mimeType: AUDIO_MIME_TYPE, + data: TINY_MP3_BASE64 + } + }; + + const response = await model.countTokens([audioPart]); + + expect(response.promptTokensDetails).to.exist; + const textDetails = response.promptTokensDetails!.find( + d => d.modality === Modality.TEXT + ); + const audioDetails = response.promptTokensDetails!.find( + d => d.modality === Modality.AUDIO + ); + + if (testConfig.ai.backend.backendType === BackendType.GOOGLE_AI) { + expect(response.totalTokens).to.equal(6); + expect(response.promptTokensDetails!.length).to.equal(2); + expect(textDetails).to.deep.equal({ + modality: Modality.TEXT, + tokenCount: 1 + }); + expect(audioDetails).to.deep.equal({ + modality: Modality.AUDIO, + tokenCount: 5 + }); + } else if ( + testConfig.ai.backend.backendType === BackendType.VERTEX_AI + ) { + expect(response.totalTokens).to.be.undefined; + expect(response.promptTokensDetails!.length).to.equal(1); // Note: Text modality details absent for Vertex AI with audio-only input. + expect(audioDetails).to.deep.equal({ modality: Modality.AUDIO }); // Note: Audio tokenCount is undefined for Vertex AI with audio-only input. + } + + expect(response.totalBillableCharacters).to.be.undefined; // Incorrect behavior + }); + + it('text, image, and audio input', async () => { + const model = getGenerativeModel(testConfig.ai, { + model: testConfig.model + }); + const textPart: Part = { text: 'Describe these:' }; + const imagePart: Part = { + inlineData: { mimeType: IMAGE_MIME_TYPE, data: TINY_IMG_BASE64 } + }; + const audioPart: Part = { + inlineData: { mimeType: AUDIO_MIME_TYPE, data: TINY_MP3_BASE64 } + }; + + const request: CountTokensRequest = { + contents: [{ role: 'user', parts: [textPart, imagePart, audioPart] }] + }; + const response = await model.countTokens(request); + const textDetails = response.promptTokensDetails!.find( + d => d.modality === Modality.TEXT + ); + const imageDetails = response.promptTokensDetails!.find( + d => d.modality === Modality.IMAGE + ); + const audioDetails = response.promptTokensDetails!.find( + d => d.modality === Modality.AUDIO + ); + expect(response.promptTokensDetails).to.exist; + expect(response.promptTokensDetails!.length).to.equal(3); + + expect(imageDetails).to.deep.equal({ + modality: Modality.IMAGE, + tokenCount: 258 + }); + + if (testConfig.ai.backend.backendType === BackendType.GOOGLE_AI) { + expect(response.totalTokens).to.equal(267); + expect(response.totalBillableCharacters).to.be.undefined; + expect(textDetails).to.deep.equal({ + modality: Modality.TEXT, + tokenCount: 4 + }); + expect(audioDetails).to.deep.equal({ + modality: Modality.AUDIO, + tokenCount: 5 + }); + } else if ( + testConfig.ai.backend.backendType === BackendType.VERTEX_AI + ) { + expect(response.totalTokens).to.equal(261); + expect(textDetails).to.deep.equal({ + modality: Modality.TEXT, + tokenCount: 3 + }); + const expectedText = 'Describe these:'; + expect(response.totalBillableCharacters).to.equal( + expectedText.length - 1 + ); // Note: BillableCharacters observed as (text length - 1) for Vertex AI. + expect(audioDetails).to.deep.equal({ modality: Modality.AUDIO }); // Incorrect behavior because there's no tokenCount + } + }); + + it('public storage reference', async () => { + // This test is not expected to pass when using Google AI. + if (testConfig.ai.backend.backendType === BackendType.GOOGLE_AI) { + return; + } + const model = getGenerativeModel(testConfig.ai, { + model: testConfig.model + }); + const filePart: FileDataPart = { + fileData: { + mimeType: IMAGE_MIME_TYPE, + fileUri: `gs://${FIREBASE_CONFIG.storageBucket}/images/tree.png` + } + }; + + const response = await model.countTokens([filePart]); + + const expectedFileTokens = 258; + expect(response.totalTokens).to.equal(expectedFileTokens); + expect(response.totalBillableCharacters).to.be.undefined; + expect(response.promptTokensDetails).to.exist; + expect(response.promptTokensDetails!.length).to.equal(1); + expect(response.promptTokensDetails![0].modality).to.equal( + Modality.IMAGE + ); + expect(response.promptTokensDetails![0].tokenCount).to.equal( + expectedFileTokens + ); + }); + }); + }); +}); diff --git a/packages/ai/integration/firebase-config.ts b/packages/ai/integration/firebase-config.ts new file mode 100644 index 00000000000..2527f020530 --- /dev/null +++ b/packages/ai/integration/firebase-config.ts @@ -0,0 +1,20 @@ +/** + * @license + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as config from '../../../config/ci.config.json'; + +export const FIREBASE_CONFIG = config; diff --git a/packages/ai/integration/generate-content.test.ts b/packages/ai/integration/generate-content.test.ts new file mode 100644 index 00000000000..22e4b0a30ac --- /dev/null +++ b/packages/ai/integration/generate-content.test.ts @@ -0,0 +1,172 @@ +/** + * @license + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { expect } from 'chai'; +import { + Content, + GenerationConfig, + HarmBlockThreshold, + HarmCategory, + Modality, + SafetySetting, + getGenerativeModel +} from '../src'; +import { testConfigs, TOKEN_COUNT_DELTA } from './constants'; + +describe('Generate Content', () => { + testConfigs.forEach(testConfig => { + describe(`${testConfig.toString()}`, () => { + const commonGenerationConfig: GenerationConfig = { + temperature: 0, + topP: 0, + responseMimeType: 'text/plain' + }; + + const commonSafetySettings: SafetySetting[] = [ + { + category: HarmCategory.HARM_CATEGORY_HARASSMENT, + threshold: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE + }, + { + category: HarmCategory.HARM_CATEGORY_HATE_SPEECH, + threshold: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE + }, + { + category: HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT, + threshold: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE + }, + { + category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT, + threshold: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE + } + ]; + + const commonSystemInstruction: Content = { + role: 'system', + parts: [ + { + text: 'You are a friendly and helpful assistant.' + } + ] + }; + + it('generateContent: text input, text output', async () => { + const model = getGenerativeModel(testConfig.ai, { + model: testConfig.model, + generationConfig: commonGenerationConfig, + safetySettings: commonSafetySettings, + systemInstruction: commonSystemInstruction + }); + + const result = await model.generateContent( + 'Where is Google headquarters located? Answer with the city name only.' + ); + const response = result.response; + + const trimmedText = response.text().trim(); + expect(trimmedText).to.equal('Mountain View'); + + expect(response.usageMetadata).to.not.be.null; + + if (model.model.includes('gemini-2.5-flash')) { + expect(response.usageMetadata!.promptTokenCount).to.be.closeTo( + 22, + TOKEN_COUNT_DELTA + ); + expect(response.usageMetadata!.candidatesTokenCount).to.be.closeTo( + 2, + TOKEN_COUNT_DELTA + ); + expect(response.usageMetadata!.totalTokenCount).to.be.closeTo( + 55, + TOKEN_COUNT_DELTA * 2 + ); + expect(response.usageMetadata!.promptTokensDetails).to.not.be.null; + expect(response.usageMetadata!.promptTokensDetails!.length).to.equal( + 1 + ); + expect( + response.usageMetadata!.promptTokensDetails![0].modality + ).to.equal(Modality.TEXT); + expect( + response.usageMetadata!.promptTokensDetails![0].tokenCount + ).to.closeTo(22, TOKEN_COUNT_DELTA); + + // candidatesTokenDetails comes back about half the time, so let's just not test it. + } else if (model.model.includes('gemini-2.0-flash')) { + expect(response.usageMetadata!.promptTokenCount).to.be.closeTo( + 21, + TOKEN_COUNT_DELTA + ); + expect(response.usageMetadata!.candidatesTokenCount).to.be.closeTo( + 4, + TOKEN_COUNT_DELTA + ); + expect(response.usageMetadata!.totalTokenCount).to.be.closeTo( + 25, + TOKEN_COUNT_DELTA * 2 + ); + expect(response.usageMetadata!.promptTokensDetails).to.not.be.null; + expect(response.usageMetadata!.promptTokensDetails!.length).to.equal( + 1 + ); + expect( + response.usageMetadata!.promptTokensDetails![0].modality + ).to.equal(Modality.TEXT); + expect( + response.usageMetadata!.promptTokensDetails![0].tokenCount + ).to.equal(21); + expect(response.usageMetadata!.candidatesTokensDetails).to.not.be + .null; + expect( + response.usageMetadata!.candidatesTokensDetails!.length + ).to.equal(1); + expect( + response.usageMetadata!.candidatesTokensDetails![0].modality + ).to.equal(Modality.TEXT); + expect( + response.usageMetadata!.candidatesTokensDetails![0].tokenCount + ).to.be.closeTo(4, TOKEN_COUNT_DELTA); + } + }); + + it('generateContentStream: text input, text output', async () => { + const model = getGenerativeModel(testConfig.ai, { + model: testConfig.model, + generationConfig: commonGenerationConfig, + safetySettings: commonSafetySettings, + systemInstruction: commonSystemInstruction + }); + + const result = await model.generateContentStream( + 'Where is Google headquarters located? Answer with the city name only.' + ); + + let streamText = ''; + for await (const chunk of result.stream) { + streamText += chunk.text(); + } + expect(streamText.trim()).to.equal('Mountain View'); + + const response = await result.response; + const trimmedText = response.text().trim(); + expect(trimmedText).to.equal('Mountain View'); + expect(response.usageMetadata).to.be.undefined; // Note: This is incorrect behavior. + }); + }); + }); +}); diff --git a/packages/ai/karma.conf.js b/packages/ai/karma.conf.js index 3fe2a2f9633..e64048d5f6d 100644 --- a/packages/ai/karma.conf.js +++ b/packages/ai/karma.conf.js @@ -16,14 +16,28 @@ */ const karmaBase = require('../../config/karma.base'); +const { argv } = require('yargs'); const files = [`src/**/*.test.ts`]; module.exports = function (config) { const karmaConfig = { ...karmaBase, + + preprocessors: { + ...karmaBase.preprocessors, + 'integration/**/*.ts': ['webpack', 'sourcemap'] + }, + // files to load into karma - files, + files: (() => { + if (argv.integration) { + return ['integration/**']; + } else { + return ['src/**/*.test.ts']; + } + })(), + // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ['mocha'] diff --git a/packages/ai/package.json b/packages/ai/package.json index 98e204320bc..468f166ad7e 100644 --- a/packages/ai/package.json +++ b/packages/ai/package.json @@ -1,6 +1,6 @@ { "name": "@firebase/ai", - "version": "1.3.0", + "version": "1.4.0", "description": "The Firebase AI SDK", "author": "Firebase (https://firebase.google.com/)", "engines": { @@ -39,6 +39,7 @@ "test:ci": "yarn testsetup && node ../../scripts/run_tests_in_ci.js -s test", "test:skip-clone": "karma start", "test:browser": "yarn testsetup && karma start", + "test:integration": "karma start --integration", "api-report": "api-extractor run --local --verbose", "typings:public": "node ../../scripts/build/use_typings.js ./dist/ai-public.d.ts", "trusted-type-check": "tsec -p tsconfig.json --noEmit" @@ -56,7 +57,7 @@ }, "license": "Apache-2.0", "devDependencies": { - "@firebase/app": "0.13.0", + "@firebase/app": "0.13.1", "@rollup/plugin-json": "6.1.0", "rollup": "2.79.2", "rollup-plugin-replace": "2.2.0", diff --git a/packages/ai/rollup.config.js b/packages/ai/rollup.config.js index b3a1e5ebcf8..3b155335898 100644 --- a/packages/ai/rollup.config.js +++ b/packages/ai/rollup.config.js @@ -32,7 +32,12 @@ const buildPlugins = [ typescriptPlugin({ typescript, tsconfigOverride: { - exclude: [...tsconfig.exclude, '**/*.test.ts', 'test-utils'], + exclude: [ + ...tsconfig.exclude, + '**/*.test.ts', + 'test-utils', + 'integration' + ], compilerOptions: { target: 'es2017' } diff --git a/packages/ai/src/requests/schema-builder.test.ts b/packages/ai/src/requests/schema-builder.test.ts index ddf655b738d..27de1076c5f 100644 --- a/packages/ai/src/requests/schema-builder.test.ts +++ b/packages/ai/src/requests/schema-builder.test.ts @@ -103,6 +103,93 @@ describe('Schema builder', () => { title: 'Direction' }); }); + describe('Schema.array', () => { + it('builds an array schema with basic items', () => { + const schema = Schema.array({ + items: Schema.string() + }); + expect(schema.toJSON()).to.eql({ + type: 'array', + nullable: false, + items: { + type: 'string', + nullable: false + } + }); + }); + + it('builds an array schema with items and minItems', () => { + const schema = Schema.array({ + items: Schema.number(), + minItems: 1 + }); + expect(schema.toJSON()).to.eql({ + type: 'array', + nullable: false, + items: { + type: 'number', + nullable: false + }, + minItems: 1 + }); + }); + + it('builds an array schema with items and maxItems', () => { + const schema = Schema.array({ + items: Schema.boolean(), + maxItems: 10 + }); + expect(schema.toJSON()).to.eql({ + type: 'array', + nullable: false, + items: { + type: 'boolean', + nullable: false + }, + maxItems: 10 + }); + }); + + it('builds an array schema with items, minItems, and maxItems', () => { + const schema = Schema.array({ + items: Schema.integer(), + minItems: 0, + maxItems: 5 + }); + expect(schema.toJSON()).to.eql({ + type: 'array', + nullable: false, + items: { + type: 'integer', + nullable: false + }, + minItems: 0, + maxItems: 5 + }); + }); + + it('builds an array schema with items, minItems, maxItems, and other options', () => { + const schema = Schema.array({ + items: Schema.string({ description: 'A list of names' }), + minItems: 1, + maxItems: 3, + nullable: true, + description: 'An array of strings' + }); + expect(schema.toJSON()).to.eql({ + type: 'array', + nullable: true, + description: 'An array of strings', + items: { + type: 'string', + description: 'A list of names', + nullable: false + }, + minItems: 1, + maxItems: 3 + }); + }); + }); it('builds an object schema', () => { const schema = Schema.object({ properties: { diff --git a/packages/ai/src/requests/schema-builder.ts b/packages/ai/src/requests/schema-builder.ts index 524cfdb1c20..7d9ece462b3 100644 --- a/packages/ai/src/requests/schema-builder.ts +++ b/packages/ai/src/requests/schema-builder.ts @@ -49,6 +49,12 @@ export abstract class Schema implements SchemaInterface { format?: string; /** Optional. The description of the property. */ description?: string; + /** Optional. The items of the property. */ + items?: SchemaInterface; + /** The minimum number of items (elements) in a schema of type {@link SchemaType.ARRAY}. */ + minItems?: number; + /** The maximum number of items (elements) in a schema of type {@link SchemaType.ARRAY}. */ + maxItems?: number; /** Optional. Whether the property is nullable. Defaults to false. */ nullable: boolean; /** Optional. The example of the property. */ diff --git a/packages/ai/src/requests/stream-reader.test.ts b/packages/ai/src/requests/stream-reader.test.ts index ea832c7816f..f0298082f68 100644 --- a/packages/ai/src/requests/stream-reader.test.ts +++ b/packages/ai/src/requests/stream-reader.test.ts @@ -102,8 +102,8 @@ describe('processStream', () => { expect(response.text()).to.not.be.empty; } const aggregatedResponse = await result.response; - expect(aggregatedResponse.text()).to.include('**Cats:**'); - expect(aggregatedResponse.text()).to.include('to their owners.'); + expect(aggregatedResponse.text()).to.include('Okay'); + expect(aggregatedResponse.text()).to.include('brewing delicious coffee'); }); it('streaming response - long - big chunk', async () => { const fakeResponse = getMockResponseStreaming( @@ -116,8 +116,8 @@ describe('processStream', () => { expect(response.text()).to.not.be.empty; } const aggregatedResponse = await result.response; - expect(aggregatedResponse.text()).to.include('**Cats:**'); - expect(aggregatedResponse.text()).to.include('to their owners.'); + expect(aggregatedResponse.text()).to.include('Okay'); + expect(aggregatedResponse.text()).to.include('brewing delicious coffee'); }); it('streaming response - utf8', async () => { const fakeResponse = getMockResponseStreaming( diff --git a/packages/ai/src/types/responses.ts b/packages/ai/src/types/responses.ts index e33b8a86bd3..71661f9feea 100644 --- a/packages/ai/src/types/responses.ts +++ b/packages/ai/src/types/responses.ts @@ -270,6 +270,8 @@ export interface CountTokensResponse { */ totalTokens: number; /** + * @deprecated Use `totalTokens` instead. This property is undefined when using models greater than `gemini-1.5-*`. + * * The total number of billable characters counted across all instances * from the request. * diff --git a/packages/ai/src/types/schema.ts b/packages/ai/src/types/schema.ts index 9cfdfad654b..3a6c0c7301b 100644 --- a/packages/ai/src/types/schema.ts +++ b/packages/ai/src/types/schema.ts @@ -57,6 +57,10 @@ export interface SchemaShared { title?: string; /** Optional. The items of the property. */ items?: T; + /** The minimum number of items (elements) in a schema of type {@link SchemaType.ARRAY}. */ + minItems?: number; + /** The maximum number of items (elements) in a schema of type {@link SchemaType.ARRAY}. */ + maxItems?: number; /** Optional. Map of `Schema` objects. */ properties?: { [k: string]: T; diff --git a/packages/analytics-compat/package.json b/packages/analytics-compat/package.json index cb8c4c5a2f7..d126569486a 100644 --- a/packages/analytics-compat/package.json +++ b/packages/analytics-compat/package.json @@ -22,7 +22,7 @@ "@firebase/app-compat": "0.x" }, "devDependencies": { - "@firebase/app-compat": "0.4.0", + "@firebase/app-compat": "0.4.1", "rollup": "2.79.2", "@rollup/plugin-json": "6.1.0", "rollup-plugin-typescript2": "0.36.0", diff --git a/packages/analytics/package.json b/packages/analytics/package.json index 2f7b6cfbadf..5d4c4d06735 100644 --- a/packages/analytics/package.json +++ b/packages/analytics/package.json @@ -47,8 +47,9 @@ }, "license": "Apache-2.0", "devDependencies": { - "@firebase/app": "0.13.0", + "@firebase/app": "0.13.1", "rollup": "2.79.2", + "rollup-plugin-dts": "5.3.1", "@rollup/plugin-commonjs": "21.1.0", "@rollup/plugin-json": "6.1.0", "@rollup/plugin-node-resolve": "16.0.0", diff --git a/packages/analytics/rollup.config.js b/packages/analytics/rollup.config.js index a22194d1d4a..529858f147f 100644 --- a/packages/analytics/rollup.config.js +++ b/packages/analytics/rollup.config.js @@ -19,6 +19,7 @@ import json from '@rollup/plugin-json'; import typescriptPlugin from 'rollup-plugin-typescript2'; import replace from 'rollup-plugin-replace'; import typescript from 'typescript'; +import dts from 'rollup-plugin-dts'; import { generateBuildTargetReplaceConfig } from '../../scripts/build/rollup_replace_build_target'; import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; import pkg from './package.json'; @@ -77,4 +78,17 @@ const cjsBuilds = [ } ]; -export default [...esmBuilds, ...cjsBuilds]; +const google3TypingsBuild = { + input: 'dist/src/index.d.ts', + output: { + file: 'dist/src/global_index.d.ts', + format: 'es' + }, + plugins: [ + dts({ + respectExternal: true + }) + ] +}; + +export default [...esmBuilds, ...cjsBuilds, google3TypingsBuild]; diff --git a/packages/app-check-compat/package.json b/packages/app-check-compat/package.json index 15cc2a9273f..29ed9977205 100644 --- a/packages/app-check-compat/package.json +++ b/packages/app-check-compat/package.json @@ -43,7 +43,7 @@ }, "license": "Apache-2.0", "devDependencies": { - "@firebase/app-compat": "0.4.0", + "@firebase/app-compat": "0.4.1", "rollup": "2.79.2", "@rollup/plugin-commonjs": "21.1.0", "@rollup/plugin-json": "6.1.0", diff --git a/packages/app-check/package.json b/packages/app-check/package.json index 4187145ed67..e52ff90dbc7 100644 --- a/packages/app-check/package.json +++ b/packages/app-check/package.json @@ -44,7 +44,7 @@ }, "license": "Apache-2.0", "devDependencies": { - "@firebase/app": "0.13.0", + "@firebase/app": "0.13.1", "rollup": "2.79.2", "@rollup/plugin-commonjs": "21.1.0", "@rollup/plugin-json": "6.1.0", diff --git a/packages/app-compat/CHANGELOG.md b/packages/app-compat/CHANGELOG.md index 6e27613a249..bc8b1b97982 100644 --- a/packages/app-compat/CHANGELOG.md +++ b/packages/app-compat/CHANGELOG.md @@ -1,5 +1,12 @@ # @firebase/app-compat +## 0.4.1 + +### Patch Changes + +- Updated dependencies []: + - @firebase/app@0.13.1 + ## 0.4.0 ### Minor Changes diff --git a/packages/app-compat/package.json b/packages/app-compat/package.json index 3d70accd107..8dba6ff2ff6 100644 --- a/packages/app-compat/package.json +++ b/packages/app-compat/package.json @@ -1,6 +1,6 @@ { "name": "@firebase/app-compat", - "version": "0.4.0", + "version": "0.4.1", "description": "The primary entrypoint to the Firebase JS SDK", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.cjs.js", @@ -37,7 +37,7 @@ }, "license": "Apache-2.0", "dependencies": { - "@firebase/app": "0.13.0", + "@firebase/app": "0.13.1", "@firebase/util": "1.12.0", "@firebase/logger": "0.4.4", "@firebase/component": "0.6.17", diff --git a/packages/app/CHANGELOG.md b/packages/app/CHANGELOG.md index 2b239c453cc..aa13db67c63 100644 --- a/packages/app/CHANGELOG.md +++ b/packages/app/CHANGELOG.md @@ -1,5 +1,11 @@ # @firebase/app +## 0.13.1 + +### Patch Changes + +- Update SDK_VERSION. + ## 0.13.0 ### Minor Changes diff --git a/packages/app/package.json b/packages/app/package.json index 3d385028412..3d6a0ca5dca 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -1,15 +1,17 @@ { "name": "@firebase/app", - "version": "0.13.0", + "version": "0.13.1", "description": "The primary entrypoint to the Firebase JS SDK", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.cjs.js", "browser": "dist/esm/index.esm2017.js", "module": "dist/esm/index.esm2017.js", + "react-native": "dist/index.cjs.js", "exports": { ".": { "types": "./dist/app-public.d.ts", "require": "./dist/index.cjs.js", + "react-native": "./dist/index.cjs.js", "default": "./dist/esm/index.esm2017.js" }, "./package.json": "./package.json" diff --git a/packages/auth-compat/CHANGELOG.md b/packages/auth-compat/CHANGELOG.md index aed6222d935..4dfdf4ce661 100644 --- a/packages/auth-compat/CHANGELOG.md +++ b/packages/auth-compat/CHANGELOG.md @@ -1,5 +1,12 @@ # @firebase/auth-compat +## 0.5.27 + +### Patch Changes + +- Updated dependencies [[`c0617a3`](https://github.com/firebase/firebase-js-sdk/commit/c0617a341a693c2578a21b35a4f7b27b726defef)]: + - @firebase/auth@1.10.7 + ## 0.5.26 ### Patch Changes diff --git a/packages/auth-compat/package.json b/packages/auth-compat/package.json index c8a6f40b357..c27a8e1f31a 100644 --- a/packages/auth-compat/package.json +++ b/packages/auth-compat/package.json @@ -1,6 +1,6 @@ { "name": "@firebase/auth-compat", - "version": "0.5.26", + "version": "0.5.27", "description": "FirebaseAuth compatibility package that uses API style compatible with Firebase@8 and prior versions", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.node.cjs.js", @@ -49,7 +49,7 @@ "@firebase/app-compat": "0.x" }, "dependencies": { - "@firebase/auth": "1.10.6", + "@firebase/auth": "1.10.7", "@firebase/auth-types": "0.13.0", "@firebase/component": "0.6.17", "@firebase/util": "1.12.0", @@ -57,7 +57,7 @@ }, "license": "Apache-2.0", "devDependencies": { - "@firebase/app-compat": "0.4.0", + "@firebase/app-compat": "0.4.1", "@rollup/plugin-json": "6.1.0", "rollup": "2.79.2", "rollup-plugin-replace": "2.2.0", diff --git a/packages/auth/CHANGELOG.md b/packages/auth/CHANGELOG.md index fe546adc28a..5277c61cfa8 100644 --- a/packages/auth/CHANGELOG.md +++ b/packages/auth/CHANGELOG.md @@ -1,5 +1,11 @@ # @firebase/auth +## 1.10.7 + +### Patch Changes + +- [`c0617a3`](https://github.com/firebase/firebase-js-sdk/commit/c0617a341a693c2578a21b35a4f7b27b726defef) [#9075](https://github.com/firebase/firebase-js-sdk/pull/9075) - Fixed issue where Firebase Auth cookie refresh attempts issues in Firebase Studio resulted in CORS errors. + ## 1.10.6 ### Patch Changes diff --git a/packages/auth/package.json b/packages/auth/package.json index ea47732d398..9ec35cfaec2 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@firebase/auth", - "version": "1.10.6", + "version": "1.10.7", "description": "The Firebase Authenticaton component of the Firebase JS SDK.", "author": "Firebase (https://firebase.google.com/)", "main": "dist/node/index.js", @@ -131,7 +131,7 @@ }, "license": "Apache-2.0", "devDependencies": { - "@firebase/app": "0.13.0", + "@firebase/app": "0.13.1", "@rollup/plugin-json": "6.1.0", "@rollup/plugin-strip": "2.1.0", "@types/express": "4.17.21", diff --git a/packages/auth/src/api/authentication/token.test.ts b/packages/auth/src/api/authentication/token.test.ts index c30bf552720..9177b4bd4ad 100644 --- a/packages/auth/src/api/authentication/token.test.ts +++ b/packages/auth/src/api/authentication/token.test.ts @@ -95,6 +95,26 @@ describe('requestStsToken', () => { ); }); + it('should use credentials: include when using Firebase Studio', async () => { + const mock = fetch.mock(endpoint, { + 'access_token': 'new-access-token', + 'expires_in': '3600', + 'refresh_token': 'new-refresh-token' + }); + + auth._logFramework('Mythical'); + auth.emulatorConfig = { + host: 'something.cloudworkstations.dev', + port: 443, + options: { disableWarnings: false }, + protocol: 'https' + }; + await requestStsToken(auth, 'some-refresh-token'); + expect(mock.calls[0].fullRequest?.credentials).to.eq('include'); + + auth.emulatorConfig = null; + }); + it('should include whatever headers come from auth impl', async () => { sinon.stub(auth, '_getAdditionalHeaders').returns( Promise.resolve({ diff --git a/packages/auth/src/api/authentication/token.ts b/packages/auth/src/api/authentication/token.ts index 6646321fbe0..478e9451e8b 100644 --- a/packages/auth/src/api/authentication/token.ts +++ b/packages/auth/src/api/authentication/token.ts @@ -17,7 +17,7 @@ /* eslint-disable camelcase */ -import { querystring } from '@firebase/util'; +import { isCloudWorkstation, querystring } from '@firebase/util'; import { _getFinalTarget, @@ -84,11 +84,18 @@ export async function requestStsToken( const headers = await (auth as AuthInternal)._getAdditionalHeaders(); headers[HttpHeader.CONTENT_TYPE] = 'application/x-www-form-urlencoded'; - return FetchProvider.fetch()(url, { + const options: RequestInit = { method: HttpMethod.POST, headers, body - }); + }; + if ( + auth.emulatorConfig && + isCloudWorkstation(auth.emulatorConfig.host) + ) { + options.credentials = 'include'; + } + return FetchProvider.fetch()(url, options); } ); diff --git a/packages/data-connect/package.json b/packages/data-connect/package.json index a342c7d4f14..99b97e39f3a 100644 --- a/packages/data-connect/package.json +++ b/packages/data-connect/package.json @@ -55,7 +55,7 @@ "tslib": "^2.1.0" }, "devDependencies": { - "@firebase/app": "0.13.0", + "@firebase/app": "0.13.1", "rollup": "2.79.2", "rollup-plugin-typescript2": "0.36.0", "typescript": "5.5.4" diff --git a/packages/database-compat/package.json b/packages/database-compat/package.json index 104f57d56dc..c746b8dde07 100644 --- a/packages/database-compat/package.json +++ b/packages/database-compat/package.json @@ -57,7 +57,7 @@ "tslib": "^2.1.0" }, "devDependencies": { - "@firebase/app-compat": "0.4.0", + "@firebase/app-compat": "0.4.1", "typescript": "5.5.4" }, "repository": { diff --git a/packages/database/package.json b/packages/database/package.json index 0fe42bddeed..54a549b9f68 100644 --- a/packages/database/package.json +++ b/packages/database/package.json @@ -57,7 +57,7 @@ "tslib": "^2.1.0" }, "devDependencies": { - "@firebase/app": "0.13.0", + "@firebase/app": "0.13.1", "rollup": "2.79.2", "rollup-plugin-typescript2": "0.36.0", "typescript": "5.5.4" diff --git a/packages/firebase/CHANGELOG.md b/packages/firebase/CHANGELOG.md index 2a17f24d933..7885817632d 100644 --- a/packages/firebase/CHANGELOG.md +++ b/packages/firebase/CHANGELOG.md @@ -1,5 +1,32 @@ # firebase +## 11.9.1 + +### Patch Changes + +- Updated dependencies [[`0f891d8`](https://github.com/firebase/firebase-js-sdk/commit/0f891d861bdf4e7bac8cd777f5fb32d0b7b9bf8e), [`c0617a3`](https://github.com/firebase/firebase-js-sdk/commit/c0617a341a693c2578a21b35a4f7b27b726defef)]: + - @firebase/storage@0.13.13 + - @firebase/auth@1.10.7 + - @firebase/storage-compat@0.3.23 + - @firebase/auth-compat@0.5.27 + +## 11.9.0 + +### Minor Changes + +- [`1933324`](https://github.com/firebase/firebase-js-sdk/commit/1933324e0f3e4c8ed4d4d784f0c701fd0ec6ebc3) [#9026](https://github.com/firebase/firebase-js-sdk/pull/9026) - Add support for `minItems` and `maxItems` to `Schema`. + +- [`40be2db`](https://github.com/firebase/firebase-js-sdk/commit/40be2dbb884b8e1485862af8bb015e23db69ccbf) [#9047](https://github.com/firebase/firebase-js-sdk/pull/9047) - Add `title`, `maximum`, `minimum`, `propertyOrdering` to Schema builder + +### Patch Changes + +- Updated dependencies [[`1933324`](https://github.com/firebase/firebase-js-sdk/commit/1933324e0f3e4c8ed4d4d784f0c701fd0ec6ebc3), [`9964849`](https://github.com/firebase/firebase-js-sdk/commit/9964849e9540f08d02fa3825ecec32c1bfedc62d), [`40be2db`](https://github.com/firebase/firebase-js-sdk/commit/40be2dbb884b8e1485862af8bb015e23db69ccbf)]: + - @firebase/ai@1.4.0 + - @firebase/app@0.13.1 + - @firebase/firestore@4.7.17 + - @firebase/app-compat@0.4.1 + - @firebase/firestore-compat@0.3.52 + ## 11.8.1 ### Patch Changes diff --git a/packages/firebase/package.json b/packages/firebase/package.json index aec5e6e8fec..4f785d15c8c 100644 --- a/packages/firebase/package.json +++ b/packages/firebase/package.json @@ -1,6 +1,6 @@ { "name": "firebase", - "version": "11.8.1", + "version": "11.9.1", "description": "Firebase JavaScript library for web and Node.js", "author": "Firebase (https://firebase.google.com/)", "license": "Apache-2.0", @@ -411,25 +411,25 @@ "trusted-type-check": "tsec -p tsconfig.json --noEmit" }, "dependencies": { - "@firebase/ai": "1.3.0", - "@firebase/app": "0.13.0", - "@firebase/app-compat": "0.4.0", + "@firebase/ai": "1.4.0", + "@firebase/app": "0.13.1", + "@firebase/app-compat": "0.4.1", "@firebase/app-types": "0.9.3", - "@firebase/auth": "1.10.6", - "@firebase/auth-compat": "0.5.26", + "@firebase/auth": "1.10.7", + "@firebase/auth-compat": "0.5.27", "@firebase/data-connect": "0.3.9", "@firebase/database": "1.0.19", "@firebase/database-compat": "2.0.10", - "@firebase/firestore": "4.7.16", - "@firebase/firestore-compat": "0.3.51", + "@firebase/firestore": "4.7.17", + "@firebase/firestore-compat": "0.3.52", "@firebase/functions": "0.12.8", "@firebase/functions-compat": "0.3.25", "@firebase/installations": "0.6.17", "@firebase/installations-compat": "0.2.17", "@firebase/messaging": "0.12.21", "@firebase/messaging-compat": "0.2.21", - "@firebase/storage": "0.13.12", - "@firebase/storage-compat": "0.3.22", + "@firebase/storage": "0.13.13", + "@firebase/storage-compat": "0.3.23", "@firebase/performance": "0.7.6", "@firebase/performance-compat": "0.2.19", "@firebase/remote-config": "0.6.4", diff --git a/packages/firestore-compat/CHANGELOG.md b/packages/firestore-compat/CHANGELOG.md index 861e35792c5..264da74339b 100644 --- a/packages/firestore-compat/CHANGELOG.md +++ b/packages/firestore-compat/CHANGELOG.md @@ -1,5 +1,12 @@ # @firebase/firestore-compat +## 0.3.52 + +### Patch Changes + +- Updated dependencies [[`9964849`](https://github.com/firebase/firebase-js-sdk/commit/9964849e9540f08d02fa3825ecec32c1bfedc62d)]: + - @firebase/firestore@4.7.17 + ## 0.3.51 ### Patch Changes diff --git a/packages/firestore-compat/package.json b/packages/firestore-compat/package.json index 6e3db51e597..4071cdb236f 100644 --- a/packages/firestore-compat/package.json +++ b/packages/firestore-compat/package.json @@ -1,6 +1,6 @@ { "name": "@firebase/firestore-compat", - "version": "0.3.51", + "version": "0.3.52", "description": "The Cloud Firestore component of the Firebase JS SDK.", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.node.cjs.js", @@ -47,13 +47,13 @@ }, "dependencies": { "@firebase/component": "0.6.17", - "@firebase/firestore": "4.7.16", + "@firebase/firestore": "4.7.17", "@firebase/util": "1.12.0", "@firebase/firestore-types": "3.0.3", "tslib": "^2.1.0" }, "devDependencies": { - "@firebase/app-compat": "0.4.0", + "@firebase/app-compat": "0.4.1", "@types/eslint": "7.29.0", "rollup": "2.79.2", "rollup-plugin-sourcemaps": "0.6.3", diff --git a/packages/firestore/CHANGELOG.md b/packages/firestore/CHANGELOG.md index 0671f0e8c63..3c73ea511d9 100644 --- a/packages/firestore/CHANGELOG.md +++ b/packages/firestore/CHANGELOG.md @@ -1,5 +1,11 @@ # @firebase/firestore +## 4.7.17 + +### Patch Changes + +- [`9964849`](https://github.com/firebase/firebase-js-sdk/commit/9964849e9540f08d02fa3825ecec32c1bfedc62d) [#9041](https://github.com/firebase/firebase-js-sdk/pull/9041) - Clean up leaked WebChannel instances when the Firestore instance is terminated. + ## 4.7.16 ### Patch Changes diff --git a/packages/firestore/package.json b/packages/firestore/package.json index 6fc04a3579d..638b8914483 100644 --- a/packages/firestore/package.json +++ b/packages/firestore/package.json @@ -1,6 +1,6 @@ { "name": "@firebase/firestore", - "version": "4.7.16", + "version": "4.7.17", "engines": { "node": ">=18.0.0" }, @@ -112,9 +112,9 @@ "@firebase/app": "0.x" }, "devDependencies": { - "@firebase/app": "0.13.0", - "@firebase/app-compat": "0.4.0", - "@firebase/auth": "1.10.6", + "@firebase/app": "0.13.1", + "@firebase/app-compat": "0.4.1", + "@firebase/auth": "1.10.7", "@rollup/plugin-alias": "5.1.1", "@rollup/plugin-json": "6.1.0", "@types/eslint": "7.29.0", diff --git a/packages/firestore/src/api.ts b/packages/firestore/src/api.ts index 4d33b925706..5aa85f55637 100644 --- a/packages/firestore/src/api.ts +++ b/packages/firestore/src/api.ts @@ -259,9 +259,11 @@ export { DocumentChange, DocumentChangeType, DocumentSnapshot, + documentSnapshotFromJSON, FirestoreDataConverter, QueryDocumentSnapshot, QuerySnapshot, + querySnapshotFromJSON, snapshotEqual, SnapshotMetadata, SnapshotOptions @@ -331,6 +333,7 @@ export { getDocsFromServer, onSnapshot, onSnapshotsInSync, + onSnapshotResume, setDoc, updateDoc } from './api/reference_impl'; diff --git a/packages/firestore/src/api/reference_impl.ts b/packages/firestore/src/api/reference_impl.ts index 86956a52785..4283453d81d 100644 --- a/packages/firestore/src/api/reference_impl.ts +++ b/packages/firestore/src/api/reference_impl.ts @@ -17,6 +17,7 @@ import { getModularInstance } from '@firebase/util'; +import { loadBundle, namedQuery } from '../api/database'; import { CompleteFn, ErrorFn, @@ -57,13 +58,19 @@ import { parseUpdateData, parseUpdateVarargs } from '../lite-api/user_data_reader'; +import { DocumentKey } from '../model/document_key'; import { DeleteMutation, Mutation, Precondition } from '../model/mutation'; import { debugAssert } from '../util/assert'; -import { FirestoreError } from '../util/error'; +import { Code, FirestoreError } from '../util/error'; import { cast } from '../util/input_validation'; import { ensureFirestoreConfigured, Firestore } from './database'; -import { DocumentSnapshot, QuerySnapshot, SnapshotMetadata } from './snapshot'; +import { + DocumentSnapshot, + FirestoreDataConverter, + QuerySnapshot, + SnapshotMetadata +} from './snapshot'; import { ExpUserDataWriter } from './user_data_writer'; /** @@ -466,12 +473,11 @@ export interface Unsubscribe { // integration tests /** - * Attaches a listener for `DocumentSnapshot` events. You may either pass - * individual `onNext` and `onError` callbacks or pass a single observer - * object with `next` and `error` callbacks. + * Attaches a listener for `DocumentSnapshot` events. You may either pass individual `onNext` and + * `onError` callbacks or pass a single observer object with `next` and `error` callbacks. * - * NOTE: Although an `onCompletion` callback can be provided, it will - * never be called because the snapshot stream is never-ending. + * NOTE: Although an `onCompletion` callback can be provided, it will never be called because the + * snapshot stream is never-ending. * * @param reference - A reference to the document to listen to. * @param observer - A single object containing `next` and `error` callbacks. @@ -487,12 +493,11 @@ export function onSnapshot( } ): Unsubscribe; /** - * Attaches a listener for `DocumentSnapshot` events. You may either pass - * individual `onNext` and `onError` callbacks or pass a single observer - * object with `next` and `error` callbacks. + * Attaches a listener for `DocumentSnapshot` events. You may either pass individual `onNext` and + * `onError` callbacks or pass a single observer object with `next` and `error` callbacks. * - * NOTE: Although an `onCompletion` callback can be provided, it will - * never be called because the snapshot stream is never-ending. + * NOTE: Although an `onCompletion` callback can be provided, it will never be called because the + * snapshot stream is never-ending. * * @param reference - A reference to the document to listen to. * @param options - Options controlling the listen behavior. @@ -510,22 +515,18 @@ export function onSnapshot( } ): Unsubscribe; /** - * Attaches a listener for `DocumentSnapshot` events. You may either pass - * individual `onNext` and `onError` callbacks or pass a single observer - * object with `next` and `error` callbacks. + * Attaches a listener for `DocumentSnapshot` events. You may either pass individual `onNext` and + * `onError` callbacks or pass a single observer object with `next` and `error` callbacks. * - * NOTE: Although an `onCompletion` callback can be provided, it will - * never be called because the snapshot stream is never-ending. + * NOTE: Although an `onCompletion` callback can be provided, it will never be called because the + * snapshot stream is never-ending. * * @param reference - A reference to the document to listen to. - * @param onNext - A callback to be called every time a new `DocumentSnapshot` - * is available. - * @param onError - A callback to be called if the listen fails or is - * cancelled. No further callbacks will occur. - * @param onCompletion - Can be provided, but will not be called since streams are - * never ending. - * @returns An unsubscribe function that can be called to cancel - * the snapshot listener. + * @param onNext - A callback to be called every time a new `DocumentSnapshot` is available. + * @param onError - A callback to be called if the listen fails or is cancelled. No further + * callbacks will occur. + * @param onCompletion - Can be provided, but will not be called since streams are never ending. + * @returns An unsubscribe function that can be called to cancel the snapshot listener. */ export function onSnapshot( reference: DocumentReference, @@ -534,23 +535,19 @@ export function onSnapshot( onCompletion?: () => void ): Unsubscribe; /** - * Attaches a listener for `DocumentSnapshot` events. You may either pass - * individual `onNext` and `onError` callbacks or pass a single observer - * object with `next` and `error` callbacks. + * Attaches a listener for `DocumentSnapshot` events. You may either pass individual `onNext` and + * `onError` callbacks or pass a single observer object with `next` and `error` callbacks. * - * NOTE: Although an `onCompletion` callback can be provided, it will - * never be called because the snapshot stream is never-ending. + * NOTE: Although an `onCompletion` callback can be provided, it will never be called because the + * snapshot stream is never-ending. * * @param reference - A reference to the document to listen to. * @param options - Options controlling the listen behavior. - * @param onNext - A callback to be called every time a new `DocumentSnapshot` - * is available. - * @param onError - A callback to be called if the listen fails or is - * cancelled. No further callbacks will occur. - * @param onCompletion - Can be provided, but will not be called since streams are - * never ending. - * @returns An unsubscribe function that can be called to cancel - * the snapshot listener. + * @param onNext - A callback to be called every time a new `DocumentSnapshot` is available. + * @param onError - A callback to be called if the listen fails or is cancelled. No further + * callbacks will occur. + * @param onCompletion - Can be provided, but will not be called since streams are never ending. + * @returns An unsubscribe function that can be called to cancel the snapshot listener. */ export function onSnapshot( reference: DocumentReference, @@ -560,18 +557,16 @@ export function onSnapshot( onCompletion?: () => void ): Unsubscribe; /** - * Attaches a listener for `QuerySnapshot` events. You may either pass - * individual `onNext` and `onError` callbacks or pass a single observer - * object with `next` and `error` callbacks. The listener can be cancelled by - * calling the function that is returned when `onSnapshot` is called. + * Attaches a listener for `QuerySnapshot` events. You may either pass individual `onNext` and + * `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The + * listener can be cancelled by calling the function that is returned when `onSnapshot` is called. * - * NOTE: Although an `onCompletion` callback can be provided, it will - * never be called because the snapshot stream is never-ending. + * NOTE: Although an `onCompletion` callback can be provided, it will never be called because the + * snapshot stream is never-ending. * * @param query - The query to listen to. * @param observer - A single object containing `next` and `error` callbacks. - * @returns An unsubscribe function that can be called to cancel - * the snapshot listener. + * @returns An unsubscribe function that can be called to cancel the snapshot listener. */ export function onSnapshot( query: Query, @@ -582,19 +577,17 @@ export function onSnapshot( } ): Unsubscribe; /** - * Attaches a listener for `QuerySnapshot` events. You may either pass - * individual `onNext` and `onError` callbacks or pass a single observer - * object with `next` and `error` callbacks. The listener can be cancelled by - * calling the function that is returned when `onSnapshot` is called. + * Attaches a listener for `QuerySnapshot` events. You may either pass individual `onNext` and + * `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The + * listener can be cancelled by calling the function that is returned when `onSnapshot` is called. * - * NOTE: Although an `onCompletion` callback can be provided, it will - * never be called because the snapshot stream is never-ending. + * NOTE: Although an `onCompletion` callback can be provided, it will never be called because the + * snapshot stream is never-ending. * * @param query - The query to listen to. * @param options - Options controlling the listen behavior. * @param observer - A single object containing `next` and `error` callbacks. - * @returns An unsubscribe function that can be called to cancel - * the snapshot listener. + * @returns An unsubscribe function that can be called to cancel the snapshot listener. */ export function onSnapshot( query: Query, @@ -606,23 +599,19 @@ export function onSnapshot( } ): Unsubscribe; /** - * Attaches a listener for `QuerySnapshot` events. You may either pass - * individual `onNext` and `onError` callbacks or pass a single observer - * object with `next` and `error` callbacks. The listener can be cancelled by - * calling the function that is returned when `onSnapshot` is called. + * Attaches a listener for `QuerySnapshot` events. You may either pass individual `onNext` and + * `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The + * listener can be cancelled by calling the function that is returned when `onSnapshot` is called. * - * NOTE: Although an `onCompletion` callback can be provided, it will - * never be called because the snapshot stream is never-ending. + * NOTE: Although an `onCompletion` callback can be provided, it will never be called because the + * snapshot stream is never-ending. * * @param query - The query to listen to. - * @param onNext - A callback to be called every time a new `QuerySnapshot` - * is available. - * @param onCompletion - Can be provided, but will not be called since streams are - * never ending. - * @param onError - A callback to be called if the listen fails or is - * cancelled. No further callbacks will occur. - * @returns An unsubscribe function that can be called to cancel - * the snapshot listener. + * @param onNext - A callback to be called every time a new `QuerySnapshot` is available. + * @param onCompletion - Can be provided, but will not be called since streams are never ending. + * @param onError - A callback to be called if the listen fails or is cancelled. No further + * callbacks will occur. + * @returns An unsubscribe function that can be called to cancel the snapshot listener. */ export function onSnapshot( query: Query, @@ -631,24 +620,20 @@ export function onSnapshot( onCompletion?: () => void ): Unsubscribe; /** - * Attaches a listener for `QuerySnapshot` events. You may either pass - * individual `onNext` and `onError` callbacks or pass a single observer - * object with `next` and `error` callbacks. The listener can be cancelled by - * calling the function that is returned when `onSnapshot` is called. + * Attaches a listener for `QuerySnapshot` events. You may either pass individual `onNext` and + * `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The + * listener can be cancelled by calling the function that is returned when `onSnapshot` is called. * - * NOTE: Although an `onCompletion` callback can be provided, it will - * never be called because the snapshot stream is never-ending. + * NOTE: Although an `onCompletion` callback can be provided, it will never be called because the + * snapshot stream is never-ending. * * @param query - The query to listen to. * @param options - Options controlling the listen behavior. - * @param onNext - A callback to be called every time a new `QuerySnapshot` - * is available. - * @param onCompletion - Can be provided, but will not be called since streams are - * never ending. - * @param onError - A callback to be called if the listen fails or is - * cancelled. No further callbacks will occur. - * @returns An unsubscribe function that can be called to cancel - * the snapshot listener. + * @param onNext - A callback to be called every time a new `QuerySnapshot` is available. + * @param onCompletion - Can be provided, but will not be called since streams are never ending. + * @param onError - A callback to be called if the listen fails or is cancelled. No further + * callbacks will occur. + * @returns An unsubscribe function that can be called to cancel the snapshot listener. */ export function onSnapshot( query: Query, @@ -663,16 +648,15 @@ export function onSnapshot( | DocumentReference, ...args: unknown[] ): Unsubscribe { + // onSnapshot for Query or Document. reference = getModularInstance(reference); - let options: SnapshotListenOptions = { includeMetadataChanges: false, source: 'default' }; let currArg = 0; if (typeof args[currArg] === 'object' && !isPartialObserver(args[currArg])) { - options = args[currArg] as SnapshotListenOptions; - currArg++; + options = args[currArg++] as SnapshotListenOptions; } const internalOptions = { @@ -719,7 +703,6 @@ export function onSnapshot( firestore = cast(query.firestore, Firestore); internalQuery = query._query; const userDataWriter = new ExpUserDataWriter(firestore); - observer = { next: snapshot => { if (args[currArg]) { @@ -744,6 +727,340 @@ export function onSnapshot( ); } +/** + * Attaches a listener for `QuerySnapshot` events based on data generated by invoking + * {@link QuerySnapshot.toJSON} You may either pass individual `onNext` and `onError` callbacks or + * pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by + * calling the function that is returned when `onSnapshot` is called. + * + * NOTE: Although an `onCompletion` callback can be provided, it will never be called because the + * snapshot stream is never-ending. + * + * @param firestore - The {@link Firestore} instance to enable the listener for. + * @param snapshotJson - A JSON object generated by invoking {@link QuerySnapshot.toJSON}. + * @param onNext - A callback to be called every time a new `QuerySnapshot` is available. + * @param onError - A callback to be called if the listen fails or is cancelled. No further + * callbacks will occur. + * @param onCompletion - Can be provided, but will not be called since streams are never ending. + * @param converter - An optional object that converts objects from Firestore before the onNext + * listener is invoked. + * @returns An unsubscribe function that can be called to cancel the snapshot listener. + */ +export function onSnapshotResume< + AppModelType, + DbModelType extends DocumentData +>( + firestore: Firestore, + snapshotJson: object, + onNext: (snapshot: QuerySnapshot) => void, + onError?: (error: FirestoreError) => void, + onCompletion?: () => void, + converter?: FirestoreDataConverter +): Unsubscribe; +/** + * Attaches a listener for `DocumentSnapshot` events based on data generated by invoking + * {@link DocumentSnapshot.toJSON}. You may either pass individual `onNext` and `onError` callbacks or + * pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by + * calling the function that is returned when `onSnapshot` is called. + * + * NOTE: Although an `onCompletion` callback can be provided, it will never be called because the + * snapshot stream is never-ending. + * + * @param firestore - The {@link Firestore} instance to enable the listener for. + * @param snapshotJson - A JSON object generated by invoking {@link DocumentSnapshot.toJSON}. + * @param onNext - A callback to be called every time a new `DocumentSnapshot` is available. + * @param onError - A callback to be called if the listen fails or is cancelled. No further + * callbacks will occur. + * @param onCompletion - Can be provided, but will not be called since streams are + * never ending. + * @param converter - An optional object that converts objects from Firestore before the onNext + * listener is invoked. + * @returns An unsubscribe function that can be called to cancel the snapshot listener. + */ +export function onSnapshotResume< + AppModelType, + DbModelType extends DocumentData +>( + firestore: Firestore, + snapshotJson: object, + onNext: (snapshot: DocumentSnapshot) => void, + onError?: (error: FirestoreError) => void, + onCompletion?: () => void, + converter?: FirestoreDataConverter +): Unsubscribe; +/** + * Attaches a listener for `QuerySnapshot` events based on data generated by invoking + * {@link QuerySnapshot.toJSON}. You may either pass individual `onNext` and `onError` callbacks or + * pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by + * calling the function that is returned when `onSnapshot` is called. + * + * NOTE: Although an `onCompletion` callback can be provided, it will never be called because the + * snapshot stream is never-ending. + * + * @param firestore - The {@link Firestore} instance to enable the listener for. + * @param snapshotJson - A JSON object generated by invoking {@link QuerySnapshot.toJSON}. + * @param options - Options controlling the listen behavior. + * @param onNext - A callback to be called every time a new `QuerySnapshot` is available. + * @param onError - A callback to be called if the listen fails or is cancelled. No further + * callbacks will occur. + * @param onCompletion - Can be provided, but will not be called since streams are never ending. + * @param converter - An optional object that converts objects from Firestore before the onNext + * listener is invoked. + * @returns An unsubscribe function that can be called to cancel the snapshot listener. + */ +export function onSnapshotResume< + AppModelType, + DbModelType extends DocumentData +>( + firestore: Firestore, + snapshotJson: object, + options: SnapshotListenOptions, + onNext: (snapshot: QuerySnapshot) => void, + onError?: (error: FirestoreError) => void, + onCompletion?: () => void, + converter?: FirestoreDataConverter +): Unsubscribe; +/** + * Attaches a listener for `DocumentSnapshot` events based on data generated by invoking + * {@link DocumentSnapshot.toJSON}. You may either pass individual `onNext` and `onError` callbacks + * or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled + * by calling the function that is returned when `onSnapshot` is called. + * + * NOTE: Although an `onCompletion` callback can be provided, it will never be called because the + * snapshot stream is never-ending. + * + * @param firestore - The {@link Firestore} instance to enable the listener for. + * @param snapshotJson - A JSON object generated by invoking {@link DocumentSnapshot.toJSON}. + * @param options - Options controlling the listen behavior. + * @param onNext - A callback to be called every time a new `DocumentSnapshot` is available. + * @param onError - A callback to be called if the listen fails or is cancelled. No further + * callbacks will occur. + * @param onCompletion - Can be provided, but will not be called since streams are never ending. + * @param converter - An optional object that converts objects from Firestore before the onNext + * listener is invoked. + * @returns An unsubscribe function that can be called to cancel + * the snapshot listener. + */ +export function onSnapshotResume< + AppModelType, + DbModelType extends DocumentData +>( + firestore: Firestore, + snapshotJson: object, + options: SnapshotListenOptions, + onNext: (snapshot: DocumentSnapshot) => void, + onError?: (error: FirestoreError) => void, + onCompletion?: () => void, + converter?: FirestoreDataConverter +): Unsubscribe; +/** + * Attaches a listener for `QuerySnapshot` events based on QuerySnapshot data generated by invoking + * {@link QuerySnapshot.toJSON}. You may either pass individual `onNext` and `onError` callbacks or + * pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by + * calling the function that is returned when `onSnapshot` is called. + * + * NOTE: Although an `onCompletion` callback can be provided, it will never be called because the + * snapshot stream is never-ending. + * + * @param firestore - The {@link Firestore} instance to enable the listener for. + * @param snapshotJson - A JSON object generated by invoking {@link QuerySnapshot.toJSON}. + * @param observer - A single object containing `next` and `error` callbacks. + * @param converter - An optional object that converts objects from Firestore before the onNext + * listener is invoked. + * @returns An unsubscribe function that can be called to cancel + * the snapshot listener. + */ +export function onSnapshotResume< + AppModelType, + DbModelType extends DocumentData +>( + firestore: Firestore, + snapshotJson: object, + observer: { + next: (snapshot: QuerySnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; + }, + converter?: FirestoreDataConverter +): Unsubscribe; +/** + * Attaches a listener for `DocumentSnapshot` events based on data generated by invoking + * {@link DocumentSnapshot.toJSON} You may either pass individual `onNext` and `onError` callbacks + * or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled + * by calling the function that is returned when `onSnapshot` is called. + * + * NOTE: Although an `onCompletion` callback can be provided, it will never be called because the + * snapshot stream is never-ending. + * + * @param firestore - The {@link Firestore} instance to enable the listener for. + * @param snapshotJson - A JSON object generated by invoking {@link DocumentSnapshot.toJSON}. + * @param observer - A single object containing `next` and `error` callbacks. + * @param converter - An optional object that converts objects from Firestore before the onNext + * listener is invoked. + * @returns An unsubscribe function that can be called to cancel + * the snapshot listener. + */ +export function onSnapshotResume< + AppModelType, + DbModelType extends DocumentData +>( + firestore: Firestore, + snapshotJson: object, + observer: { + next: (snapshot: DocumentSnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; + }, + converter?: FirestoreDataConverter +): Unsubscribe; +/** + * Attaches a listener for `QuerySnapshot` events based on QuerySnapshot data generated by invoking + * {@link QuerySnapshot.toJSON} You may either pass individual `onNext` and `onError` callbacks or + * pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by + * calling the function that is returned when `onSnapshot` is called. + * + * NOTE: Although an `onCompletion` callback can be provided, it will never be called because the + * snapshot stream is never-ending. + * + * @param firestore - The {@link Firestore} instance to enable the listener for. + * @param snapshotJson - A JSON object generated by invoking {@link QuerySnapshot.toJSON}. + * @param options - Options controlling the listen behavior. + * @param observer - A single object containing `next` and `error` callbacks. + * @param converter - An optional object that converts objects from Firestore before the onNext + * listener is invoked. + * @returns An unsubscribe function that can be called to cancel + * the snapshot listener. + */ +export function onSnapshotResume< + AppModelType, + DbModelType extends DocumentData +>( + firestore: Firestore, + snapshotJson: object, + options: SnapshotListenOptions, + observer: { + next: (snapshot: QuerySnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; + }, + converter?: FirestoreDataConverter +): Unsubscribe; +/** + * Attaches a listener for `DocumentSnapshot` events based on QuerySnapshot data generated by + * invoking {@link DocumentSnapshot.toJSON} You may either pass individual `onNext` and `onError` + * callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be + * cancelled by calling the function that is returned when `onSnapshot` is called. + * + * NOTE: Although an `onCompletion` callback can be provided, it will never be called because the + * snapshot stream is never-ending. + * + * @param firestore - The {@link Firestore} instance to enable the listener for. + * @param snapshotJson - A JSON object generated by invoking {@link DocumentSnapshot.toJSON}. + * @param options - Options controlling the listen behavior. + * @param observer - A single object containing `next` and `error` callbacks. + * @param converter - An optional object that converts objects from Firestore before the onNext + * listener is invoked. + * @returns An unsubscribe function that can be called to cancel the snapshot listener. + */ +export function onSnapshotResume< + AppModelType, + DbModelType extends DocumentData +>( + firestore: Firestore, + snapshotJson: object, + options: SnapshotListenOptions, + observer: { + next: (snapshot: DocumentSnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; + }, + converter?: FirestoreDataConverter +): Unsubscribe; +export function onSnapshotResume< + AppModelType, + DbModelType extends DocumentData +>(reference: Firestore, snapshotJson: object, ...args: unknown[]): Unsubscribe { + const db = getModularInstance(reference); + const json = normalizeSnapshotJsonFields(snapshotJson); + if (json.error) { + throw new FirestoreError(Code.INVALID_ARGUMENT, json.error); + } + let curArg = 0; + let options: SnapshotListenOptions | undefined = undefined; + if (typeof args[curArg] === 'object' && !isPartialObserver(args[curArg])) { + options = args[curArg++] as SnapshotListenOptions; + } + + if (json.bundleSource === 'QuerySnapshot') { + let observer: { + next: (snapshot: QuerySnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; + } | null = null; + if (typeof args[curArg] === 'object' && isPartialObserver(args[curArg])) { + const userObserver = args[curArg++] as PartialObserver< + QuerySnapshot + >; + observer = { + next: userObserver.next!, + error: userObserver.error, + complete: userObserver.complete + }; + } else { + observer = { + next: args[curArg++] as ( + snapshot: QuerySnapshot + ) => void, + error: args[curArg++] as (error: FirestoreError) => void, + complete: args[curArg++] as () => void + }; + } + return onSnapshotQuerySnapshotBundle( + db, + json, + options, + observer!, + args[curArg] as FirestoreDataConverter + ); + } else if (json.bundleSource === 'DocumentSnapshot') { + let observer: { + next: (snapshot: DocumentSnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; + } | null = null; + if (typeof args[curArg] === 'object' && isPartialObserver(args[curArg])) { + const userObserver = args[curArg++] as PartialObserver< + DocumentSnapshot + >; + observer = { + next: userObserver.next!, + error: userObserver.error, + complete: userObserver.complete + }; + } else { + observer = { + next: args[curArg++] as ( + snapshot: DocumentSnapshot + ) => void, + error: args[curArg++] as (error: FirestoreError) => void, + complete: args[curArg++] as () => void + }; + } + return onSnapshotDocumentSnapshotBundle( + db, + json, + options, + observer!, + args[curArg] as FirestoreDataConverter + ); + } else { + throw new FirestoreError( + Code.INVALID_ARGUMENT, + `unsupported bundle source: ${json.bundleSource}` + ); + } +} + // TODO(firestorexp): Make sure these overloads are tested via the Firestore // integration tests @@ -842,3 +1159,186 @@ function convertToDocSnapshot( ref.converter ); } + +/** + * Ensures the data required to construct an {@link onSnapshot} listener exist in a `snapshotJson` + * object that originates from {@link DocumentSnapshot.toJSON} or {@link Querysnapshot.toJSON}. The + * data is normalized into a typed object. + * + * @param snapshotJson - The JSON object that the app provided to {@link onSnapshot}. + * @returns A normalized object that contains all of the required bundle JSON fields. If + * {@link snapshotJson} doesn't contain the required fields, or if the fields exist as empty + * strings, then the {@link snapshotJson.error} field will be a non empty string. + * + * @internal + */ +function normalizeSnapshotJsonFields(snapshotJson: object): { + bundle: string; + bundleName: string; + bundleSource: string; + error?: string; +} { + const result: { + bundle: string; + bundleName: string; + bundleSource: string; + error?: string; + } = { + bundle: '', + bundleName: '', + bundleSource: '' + }; + const requiredKeys = ['bundle', 'bundleName', 'bundleSource']; + for (const key of requiredKeys) { + if (!(key in snapshotJson)) { + result.error = `snapshotJson missing required field: ${key}`; + break; + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const value = (snapshotJson as any)[key]; + if (typeof value !== 'string') { + result.error = `snapshotJson field '${key}' must be a string.`; + break; + } + if (value.length === 0) { + result.error = `snapshotJson field '${key}' cannot be an empty string.`; + break; + } + if (key === 'bundle') { + result.bundle = value; + } else if (key === 'bundleName') { + result.bundleName = value; + } else if (key === 'bundleSource') { + result.bundleSource = value; + } + } + return result; +} + +/** + * Loads the bundle in a separate task and then invokes {@link onSnapshot} with a + * {@link DocumentReference} for the document in the bundle. + * + * @param firestore - The {@link Firestore} instance for the {@link onSnapshot} operation request. + * @param json - The JSON bundle to load, produced by {@link DocumentSnapshot.toJSON}. + * @param options - Options controlling the listen behavior. + * @param observer - A single object containing `next` and `error` callbacks. + * @param converter - An optional object that converts objects from Firestore before the onNext + * listener is invoked. + * @returns An unsubscribe function that can be called to cancel the snapshot + * listener. + * + * @internal + */ +function onSnapshotDocumentSnapshotBundle< + AppModelType, + DbModelType extends DocumentData +>( + db: Firestore, + json: { bundle: string; bundleName: string; bundleSource: string }, + options: SnapshotListenOptions | undefined, + observer: { + next: (snapshot: DocumentSnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; + }, + converter?: FirestoreDataConverter +): Unsubscribe { + let unsubscribed: boolean = false; + let internalUnsubscribe: Unsubscribe | undefined; + const loadTask = loadBundle(db, json.bundle); + loadTask + .then(() => { + if (!unsubscribed) { + const docReference = new DocumentReference( + db, + converter ? converter : null, + DocumentKey.fromPath(json.bundleName) + ); + internalUnsubscribe = onSnapshot( + docReference as DocumentReference, + options ? options : {}, + observer + ); + } + }) + .catch(e => { + if (observer.error) { + observer.error(e); + } + return () => {}; + }); + return () => { + if (unsubscribed) { + return; + } + unsubscribed = true; + if (internalUnsubscribe) { + internalUnsubscribe(); + } + }; +} + +/** + * Loads the bundle in a separate task and then invokes {@link onSnapshot} with a + * {@link Query} that represents the Query in the bundle. + * + * @param firestore - The {@link Firestore} instance for the {@link onSnapshot} operation request. + * @param json - The JSON bundle to load, produced by {@link QuerySnapshot.toJSON}. + * @param options - Options controlling the listen behavior. + * @param observer - A single object containing `next` and `error` callbacks. + * @param converter - An optional object that converts objects from Firestore before the onNext + * listener is invoked. + * @returns An unsubscribe function that can be called to cancel the snapshot + * listener. + * + * @internal + */ +function onSnapshotQuerySnapshotBundle< + AppModelType, + DbModelType extends DocumentData +>( + db: Firestore, + json: { bundle: string; bundleName: string; bundleSource: string }, + options: SnapshotListenOptions | undefined, + observer: { + next: (snapshot: QuerySnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; + }, + converter?: FirestoreDataConverter +): Unsubscribe { + let unsubscribed: boolean = false; + let internalUnsubscribe: Unsubscribe | undefined; + const loadTask = loadBundle(db, json.bundle); + loadTask + .then(() => namedQuery(db, json.bundleName)) + .then(query => { + if (query && !unsubscribed) { + const realQuery: Query = (query as Query)!; + if (converter) { + realQuery.withConverter(converter); + } + internalUnsubscribe = onSnapshot( + query as Query, + options ? options : {}, + observer + ); + } + }) + .catch(e => { + if (observer.error) { + observer.error(e); + } + return () => {}; + }); + return () => { + if (unsubscribed) { + return; + } + unsubscribed = true; + if (internalUnsubscribe) { + internalUnsubscribe(); + } + }; +} diff --git a/packages/firestore/src/api/snapshot.ts b/packages/firestore/src/api/snapshot.ts index 669ac26cafe..c82add0642a 100644 --- a/packages/firestore/src/api/snapshot.ts +++ b/packages/firestore/src/api/snapshot.ts @@ -15,6 +15,8 @@ * limitations under the License. */ +import { BundleLoader } from '../core/bundle_impl'; +import { createBundleReaderSync } from '../core/firestore_client'; import { newQueryComparator } from '../core/query'; import { ChangeType, ViewSnapshot } from '../core/view_snapshot'; import { FieldPath } from '../lite-api/field_path'; @@ -26,6 +28,7 @@ import { SetOptions, WithFieldValue } from '../lite-api/reference'; +import { LiteUserDataWriter } from '../lite-api/reference_impl'; import { DocumentSnapshot as LiteDocumentSnapshot, fieldPathFromArgument, @@ -33,14 +36,30 @@ import { } from '../lite-api/snapshot'; import { UntypedFirestoreDataConverter } from '../lite-api/user_data_reader'; import { AbstractUserDataWriter } from '../lite-api/user_data_writer'; +import { fromBundledQuery } from '../local/local_serializer'; +import { documentKeySet } from '../model/collections'; import { Document } from '../model/document'; import { DocumentKey } from '../model/document_key'; +import { DocumentSet } from '../model/document_set'; +import { ResourcePath } from '../model/path'; +import { newSerializer } from '../platform/serializer'; +import { + buildQuerySnapshotJsonBundle, + buildDocumentSnapshotJsonBundle +} from '../platform/snapshot_to_json'; +import { fromDocument } from '../remote/serializer'; import { debugAssert, fail } from '../util/assert'; import { Code, FirestoreError } from '../util/error'; +// API extractor fails importing 'property' unless we also explicitly import 'Property'. +// eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports-ts +import { Property, property, validateJSON } from '../util/json_validation'; +import { AutoId } from '../util/misc'; import { Firestore } from './database'; import { SnapshotListenOptions } from './reference_impl'; +const NOT_SUPPORTED = 'NOT SUPPORTED'; + /** * Converter used by `withConverter()` to transform user objects of type * `AppModelType` into Firestore data of type `DbModelType`. @@ -496,6 +515,148 @@ export class DocumentSnapshot< } return undefined; } + + static _jsonSchemaVersion: string = 'firestore/documentSnapshot/1.0'; + static _jsonSchema = { + type: property('string', DocumentSnapshot._jsonSchemaVersion), + bundleSource: property('string', 'DocumentSnapshot'), + bundleName: property('string'), + bundle: property('string') + }; + + /** + * Returns a JSON-serializable representation of this `DocumentSnapshot` instance. + * + * @returns a JSON representation of this object. Throws a {@link FirestoreError} if this + * `DocumentSnapshot` has pending writes. + */ + toJSON(): object { + if (this.metadata.hasPendingWrites) { + throw new FirestoreError( + Code.FAILED_PRECONDITION, + 'DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. ' + + 'Await waitForPendingWrites() before invoking toJSON().' + ); + } + const document = this._document; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const result: any = {}; + result['type'] = DocumentSnapshot._jsonSchemaVersion; + result['bundle'] = ''; + result['bundleSource'] = 'DocumentSnapshot'; + result['bundleName'] = this._key.toString(); + + if ( + !document || + !document.isValidDocument() || + !document.isFoundDocument() + ) { + return result; + } + const documentData = this._userDataWriter.convertObjectMap( + document.data.value.mapValue.fields, + 'previous' + ); + result['bundle'] = buildDocumentSnapshotJsonBundle( + this._firestore, + document, + documentData, + this.ref.path + ); + return result; + } +} + +/** + * Builds a `DocumentSnapshot` instance from a JSON object created by + * {@link DocumentSnapshot.toJSON}. + * + * @param firestore - The {@link Firestore} instance the snapshot should be loaded for. + * @param json - a JSON object represention of a `DocumentSnapshot` instance. + * @returns an instance of {@link DocumentSnapshot} if the JSON object could be + * parsed. Throws a {@link FirestoreError} if an error occurs. + */ +export function documentSnapshotFromJSON( + db: Firestore, + json: object +): DocumentSnapshot; +/** + * Builds a `DocumentSnapshot` instance from a JSON object created by + * {@link DocumentSnapshot.toJSON}. + * + * @param firestore - The {@link Firestore} instance the snapshot should be loaded for. + * @param json - a JSON object represention of a `DocumentSnapshot` instance. + * @param converter - Converts objects to and from Firestore. + * @returns an instance of {@link DocumentSnapshot} if the JSON object could be + * parsed. Throws a {@link FirestoreError} if an error occurs. + */ +export function documentSnapshotFromJSON< + AppModelType, + DbModelType extends DocumentData = DocumentData +>( + db: Firestore, + json: object, + converter: FirestoreDataConverter +): DocumentSnapshot; +export function documentSnapshotFromJSON< + AppModelType, + DbModelType extends DocumentData = DocumentData +>( + db: Firestore, + json: object, + converter?: FirestoreDataConverter +): DocumentSnapshot { + if (validateJSON(json, DocumentSnapshot._jsonSchema)) { + if (json.bundle === NOT_SUPPORTED) { + throw new FirestoreError( + Code.INVALID_ARGUMENT, + 'The provided JSON object was created in a client environment, which is not supported.' + ); + } + // Parse the bundle data. + const serializer = newSerializer(db._databaseId); + const bundleReader = createBundleReaderSync(json.bundle, serializer); + const elements = bundleReader.getElements(); + const bundleLoader: BundleLoader = new BundleLoader( + bundleReader.getMetadata(), + serializer + ); + for (const element of elements) { + bundleLoader.addSizedElement(element); + } + + // Ensure that we have the correct number of documents in the bundle. + const bundledDocuments = bundleLoader.documents; + if (bundledDocuments.length !== 1) { + throw new FirestoreError( + Code.INVALID_ARGUMENT, + `Expected bundle data to contain 1 document, but it contains ${bundledDocuments.length} documents.` + ); + } + + // Build out the internal document data. + const document = fromDocument(serializer, bundledDocuments[0].document!); + const documentKey = new DocumentKey( + ResourcePath.fromString(json.bundleName) + ); + + // Return the external facing DocumentSnapshot. + return new DocumentSnapshot( + db, + new LiteUserDataWriter(db), + documentKey, + document, + new SnapshotMetadata( + /* hasPendingWrites= */ false, + /* fromCache= */ false + ), + converter ? converter : null + ); + } + throw new FirestoreError( + Code.INTERNAL, + 'Unexpected error creating DocumentSnapshot from JSON.' + ); } /** @@ -651,6 +812,171 @@ export class QuerySnapshot< return this._cachedChanges; } + + static _jsonSchemaVersion: string = 'firestore/querySnapshot/1.0'; + static _jsonSchema = { + type: property('string', QuerySnapshot._jsonSchemaVersion), + bundleSource: property('string', 'QuerySnapshot'), + bundleName: property('string'), + bundle: property('string') + }; + + /** + * Returns a JSON-serializable representation of this `QuerySnapshot` instance. + * + * @returns a JSON representation of this object. Throws a {@link FirestoreError} if this + * `QuerySnapshot` has pending writes. + */ + toJSON(): object { + if (this.metadata.hasPendingWrites) { + throw new FirestoreError( + Code.FAILED_PRECONDITION, + 'QuerySnapshot.toJSON() attempted to serialize a document with pending writes. ' + + 'Await waitForPendingWrites() before invoking toJSON().' + ); + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const result: any = {}; + result['type'] = QuerySnapshot._jsonSchemaVersion; + result['bundleSource'] = 'QuerySnapshot'; + result['bundleName'] = AutoId.newId(); + + const databaseId = this._firestore._databaseId.database; + const projectId = this._firestore._databaseId.projectId; + const parent = `projects/${projectId}/databases/${databaseId}/documents`; + const documents: Document[] = []; + const documentData: DocumentData[] = []; + const paths: string[] = []; + + this.docs.forEach(doc => { + if (doc._document === null) { + return; + } + documents.push(doc._document); + documentData.push( + this._userDataWriter.convertObjectMap( + doc._document.data.value.mapValue.fields, + 'previous' + ) + ); + paths.push(doc.ref.path); + }); + result['bundle'] = buildQuerySnapshotJsonBundle( + this._firestore, + this.query._query, + result['bundleName'], + parent, + paths, + documents, + documentData + ); + return result; + } +} + +/** + * Builds a `QuerySnapshot` instance from a JSON object created by + * {@link QuerySnapshot.toJSON}. + * + * @param firestore - The {@link Firestore} instance the snapshot should be loaded for. + * @param json - a JSON object represention of a `QuerySnapshot` instance. + * @returns an instance of {@link QuerySnapshot} if the JSON object could be + * parsed. Throws a {@link FirestoreError} if an error occurs. + */ +export function querySnapshotFromJSON( + db: Firestore, + json: object +): QuerySnapshot; +/** + * Builds a `QuerySnapshot` instance from a JSON object created by + * {@link QuerySnapshot.toJSON}. + * + * @param firestore - The {@link Firestore} instance the snapshot should be loaded for. + * @param json - a JSON object represention of a `QuerySnapshot` instance. + * @param converter - Converts objects to and from Firestore. + * @returns an instance of {@link QuerySnapshot} if the JSON object could be + * parsed. Throws a {@link FirestoreError} if an error occurs. + */ +export function querySnapshotFromJSON< + AppModelType, + DbModelType extends DocumentData = DocumentData +>( + db: Firestore, + json: object, + converter: FirestoreDataConverter +): QuerySnapshot; +export function querySnapshotFromJSON< + AppModelType, + DbModelType extends DocumentData +>( + db: Firestore, + json: object, + converter?: FirestoreDataConverter +): QuerySnapshot { + if (validateJSON(json, QuerySnapshot._jsonSchema)) { + if (json.bundle === NOT_SUPPORTED) { + throw new FirestoreError( + Code.INVALID_ARGUMENT, + 'The provided JSON object was created in a client environment, which is not supported.' + ); + } + // Parse the bundle data. + const serializer = newSerializer(db._databaseId); + const bundleReader = createBundleReaderSync(json.bundle, serializer); + const elements = bundleReader.getElements(); + const bundleLoader: BundleLoader = new BundleLoader( + bundleReader.getMetadata(), + serializer + ); + for (const element of elements) { + bundleLoader.addSizedElement(element); + } + + if (bundleLoader.queries.length !== 1) { + throw new FirestoreError( + Code.INVALID_ARGUMENT, + `Snapshot data expected 1 query but found ${bundleLoader.queries.length} queries.` + ); + } + + // Create an internal Query object from the named query in the bundle. + const query = fromBundledQuery(bundleLoader.queries[0].bundledQuery!); + + // Construct the arrays of document data for the query. + const bundledDocuments = bundleLoader.documents; + let documentSet = new DocumentSet(); + bundledDocuments.map(bundledDocument => { + const document = fromDocument(serializer, bundledDocument.document!); + documentSet = documentSet.add(document); + }); + // Create a view snapshot of the query and documents. + const viewSnapshot = ViewSnapshot.fromInitialDocuments( + query, + documentSet, + documentKeySet() /* Zero mutated keys signifies no pending writes. */, + /* fromCache= */ false, + /* hasCachedResults= */ false + ); + + // Create an external Query object, required to construct the QuerySnapshot. + const externalQuery = new Query( + db, + converter ? converter : null, + query + ); + + // Return a new QuerySnapshot with all of the collected data. + return new QuerySnapshot( + db, + new LiteUserDataWriter(db), + externalQuery, + viewSnapshot + ); + } + throw new FirestoreError( + Code.INTERNAL, + 'Unexpected error creating QuerySnapshot from JSON.' + ); } /** Calculates the array of `DocumentChange`s for a given `ViewSnapshot`. */ diff --git a/packages/firestore/src/core/bundle_impl.ts b/packages/firestore/src/core/bundle_impl.ts index 9a42e43261f..b91933f1349 100644 --- a/packages/firestore/src/core/bundle_impl.ts +++ b/packages/firestore/src/core/bundle_impl.ts @@ -82,27 +82,42 @@ export class BundleConverterImpl implements BundleConverter { } /** - * A class to process the elements from a bundle, load them into local + * A class to process the elements from a bundle, and optionally load them into local * storage and provide progress update while loading. */ export class BundleLoader { /** The current progress of loading */ private progress: LoadBundleTaskProgress; /** Batched queries to be saved into storage */ - private queries: ProtoNamedQuery[] = []; + private _queries: ProtoNamedQuery[] = []; /** Batched documents to be saved into storage */ - private documents: BundledDocuments = []; + private _documents: BundledDocuments = []; /** The collection groups affected by this bundle. */ private collectionGroups = new Set(); constructor( private bundleMetadata: ProtoBundleMetadata, - private localStore: LocalStore, private serializer: JsonProtoSerializer ) { this.progress = bundleInitialProgress(bundleMetadata); } + /** + * Returns the named queries that have been parsed from the SizeBundleElements added by + * calling {@link adSizedElement}. + */ + get queries(): ProtoNamedQuery[] { + return this._queries; + } + + /** + * Returns the BundledDocuments that have been parsed from the SizeBundleElements added by + * calling {@link addSizedElement}. + */ + get documents(): BundledDocuments { + return this._documents; + } + /** * Adds an element from the bundle to the loader. * @@ -117,9 +132,9 @@ export class BundleLoader { let documentsLoaded = this.progress.documentsLoaded; if (element.payload.namedQuery) { - this.queries.push(element.payload.namedQuery); + this._queries.push(element.payload.namedQuery); } else if (element.payload.documentMetadata) { - this.documents.push({ metadata: element.payload.documentMetadata }); + this._documents.push({ metadata: element.payload.documentMetadata }); if (!element.payload.documentMetadata.exists) { ++documentsLoaded; } @@ -133,12 +148,12 @@ export class BundleLoader { this.collectionGroups.add(path.get(path.length - 2)); } else if (element.payload.document) { debugAssert( - this.documents.length > 0 && - this.documents[this.documents.length - 1].metadata.name === + this._documents.length > 0 && + this._documents[this._documents.length - 1].metadata.name === element.payload.document.name, 'The document being added does not match the stored metadata.' ); - this.documents[this.documents.length - 1].document = + this._documents[this._documents.length - 1].document = element.payload.document; ++documentsLoaded; } @@ -176,26 +191,28 @@ export class BundleLoader { /** * Update the progress to 'Success' and return the updated progress. */ - async complete(): Promise { + async completeAndStoreAsync( + localStore: LocalStore + ): Promise { debugAssert( - this.documents[this.documents.length - 1]?.metadata.exists !== true || - !!this.documents[this.documents.length - 1].document, + this._documents[this._documents.length - 1]?.metadata.exists !== true || + !!this._documents[this._documents.length - 1].document, 'Bundled documents end with a document metadata element instead of a document.' ); debugAssert(!!this.bundleMetadata.id, 'Bundle ID must be set.'); const changedDocs = await localStoreApplyBundledDocuments( - this.localStore, + localStore, new BundleConverterImpl(this.serializer), - this.documents, + this._documents, this.bundleMetadata.id! ); const queryDocumentMap = this.getQueryDocumentMapping(this.documents); - for (const q of this.queries) { + for (const q of this._queries) { await localStoreSaveNamedQuery( - this.localStore, + localStore, q, queryDocumentMap.get(q.name!) ); diff --git a/packages/firestore/src/core/firestore_client.ts b/packages/firestore/src/core/firestore_client.ts index ad485c7f77a..141f348d7bf 100644 --- a/packages/firestore/src/core/firestore_client.ts +++ b/packages/firestore/src/core/firestore_client.ts @@ -59,8 +59,9 @@ import { JsonProtoSerializer } from '../remote/serializer'; import { debugAssert } from '../util/assert'; import { AsyncObserver } from '../util/async_observer'; import { AsyncQueue, wrapInUserErrorIfRecoverable } from '../util/async_queue'; -import { BundleReader } from '../util/bundle_reader'; +import { BundleReader, BundleReaderSync } from '../util/bundle_reader'; import { newBundleReader } from '../util/bundle_reader_impl'; +import { newBundleReaderSync } from '../util/bundle_reader_sync_impl'; import { Code, FirestoreError } from '../util/error'; import { logDebug, logWarn } from '../util/log'; import { AutoId } from '../util/misc'; @@ -236,11 +237,23 @@ export async function setOfflineComponentProvider( } }); - // When a user calls clearPersistence() in one client, all other clients - // need to be terminated to allow the delete to succeed. - offlineComponentProvider.persistence.setDatabaseDeletedListener(() => - client.terminate() - ); + offlineComponentProvider.persistence.setDatabaseDeletedListener(() => { + logWarn('Terminating Firestore due to IndexedDb database deletion'); + client + .terminate() + .then(() => { + logDebug( + 'Terminating Firestore due to IndexedDb database deletion ' + + 'completed successfully' + ); + }) + .catch(error => { + logWarn( + 'Terminating Firestore due to IndexedDb database deletion failed', + error + ); + }); + }); client._offlineComponents = offlineComponentProvider; } @@ -345,7 +358,7 @@ async function ensureOfflineComponents( return client._offlineComponents!; } -async function ensureOnlineComponents( +export async function ensureOnlineComponents( client: FirestoreClient ): Promise { if (!client._onlineComponents) { @@ -844,6 +857,13 @@ function createBundleReader( return newBundleReader(toByteStreamReader(content), serializer); } +export function createBundleReaderSync( + bundleData: string, + serializer: JsonProtoSerializer +): BundleReaderSync { + return newBundleReaderSync(bundleData, serializer); +} + export function firestoreClientSetIndexConfiguration( client: FirestoreClient, indexes: FieldIndex[] diff --git a/packages/firestore/src/core/sync_engine_impl.ts b/packages/firestore/src/core/sync_engine_impl.ts index 404d4663a47..f00acb5a4ee 100644 --- a/packages/firestore/src/core/sync_engine_impl.ts +++ b/packages/firestore/src/core/sync_engine_impl.ts @@ -1697,11 +1697,7 @@ async function loadBundleImpl( task._updateProgress(bundleInitialProgress(metadata)); - const loader = new BundleLoader( - metadata, - syncEngine.localStore, - reader.serializer - ); + const loader = new BundleLoader(metadata, reader.serializer); let element = await reader.nextElement(); while (element) { debugAssert( @@ -1716,7 +1712,7 @@ async function loadBundleImpl( element = await reader.nextElement(); } - const result = await loader.complete(); + const result = await loader.completeAndStoreAsync(syncEngine.localStore); await syncEngineEmitNewSnapsAndNotifyLocalStore( syncEngine, result.changedDocs, diff --git a/packages/firestore/src/lite-api/bytes.ts b/packages/firestore/src/lite-api/bytes.ts index ef16bc54463..225ad7918af 100644 --- a/packages/firestore/src/lite-api/bytes.ts +++ b/packages/firestore/src/lite-api/bytes.ts @@ -17,6 +17,9 @@ import { ByteString } from '../util/byte_string'; import { Code, FirestoreError } from '../util/error'; +// API extractor fails importing property unless we also explicitly import Property. +// eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports-ts +import { Property, property, validateJSON } from '../util/json_validation'; /** * An immutable object representing an array of bytes. @@ -91,4 +94,39 @@ export class Bytes { isEqual(other: Bytes): boolean { return this._byteString.isEqual(other._byteString); } + + static _jsonSchemaVersion: string = 'firestore/bytes/1.0'; + static _jsonSchema = { + type: property('string', Bytes._jsonSchemaVersion), + bytes: property('string') + }; + + /** + * Returns a JSON-serializable representation of this `Bytes` instance. + * + * @returns a JSON representation of this object. + */ + toJSON(): object { + return { + type: Bytes._jsonSchemaVersion, + bytes: this.toBase64() + }; + } + + /** + * Builds a `Bytes` instance from a JSON object created by {@link Bytes.toJSON}. + * + * @param json a JSON object represention of a `Bytes` instance + * @returns an instance of {@link Bytes} if the JSON object could be parsed. Throws a + * {@link FirestoreError} if an error occurs. + */ + static fromJSON(json: object): Bytes { + if (validateJSON(json, Bytes._jsonSchema)) { + return Bytes.fromBase64String(json.bytes); + } + throw new FirestoreError( + Code.INVALID_ARGUMENT, + 'Unexpected error creating Bytes from JSON.' + ); + } } diff --git a/packages/firestore/src/lite-api/geo_point.ts b/packages/firestore/src/lite-api/geo_point.ts index 3e2944cde29..75194049f89 100644 --- a/packages/firestore/src/lite-api/geo_point.ts +++ b/packages/firestore/src/lite-api/geo_point.ts @@ -16,6 +16,9 @@ */ import { Code, FirestoreError } from '../util/error'; +// API extractor fails importing 'property' unless we also explicitly import 'Property'. +// eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports-ts +import { Property, property, validateJSON } from '../util/json_validation'; import { primitiveComparator } from '../util/misc'; /** @@ -79,11 +82,6 @@ export class GeoPoint { return this._lat === other._lat && this._long === other._long; } - /** Returns a JSON-serializable representation of this GeoPoint. */ - toJSON(): { latitude: number; longitude: number } { - return { latitude: this._lat, longitude: this._long }; - } - /** * Actually private to JS consumers of our API, so this function is prefixed * with an underscore. @@ -94,4 +92,41 @@ export class GeoPoint { primitiveComparator(this._long, other._long) ); } + + static _jsonSchemaVersion: string = 'firestore/geoPoint/1.0'; + static _jsonSchema = { + type: property('string', GeoPoint._jsonSchemaVersion), + latitude: property('number'), + longitude: property('number') + }; + + /** + * Returns a JSON-serializable representation of this `GeoPoint` instance. + * + * @returns a JSON representation of this object. + */ + toJSON(): { latitude: number; longitude: number; type: string } { + return { + latitude: this._lat, + longitude: this._long, + type: GeoPoint._jsonSchemaVersion + }; + } + + /** + * Builds a `GeoPoint` instance from a JSON object created by {@link GeoPoint.toJSON}. + * + * @param json a JSON object represention of a `GeoPoint` instance + * @returns an instance of {@link GeoPoint} if the JSON object could be parsed. Throws a + * {@link FirestoreError} if an error occurs. + */ + static fromJSON(json: object): GeoPoint { + if (validateJSON(json, GeoPoint._jsonSchema)) { + return new GeoPoint(json.latitude, json.longitude); + } + throw new FirestoreError( + Code.INVALID_ARGUMENT, + 'Unexpected error creating GeoPoint from JSON.' + ); + } } diff --git a/packages/firestore/src/lite-api/reference.ts b/packages/firestore/src/lite-api/reference.ts index 71b789227fc..8319761766d 100644 --- a/packages/firestore/src/lite-api/reference.ts +++ b/packages/firestore/src/lite-api/reference.ts @@ -32,6 +32,9 @@ import { validateDocumentPath, validateNonEmptyArgument } from '../util/input_validation'; +// API extractor fails importing property unless we also explicitly import Property. +// eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports-ts +import { Property, property, validateJSON } from '../util/json_validation'; import { AutoId } from '../util/misc'; import { Firestore } from './database'; @@ -288,6 +291,73 @@ export class DocumentReference< this._key ); } + + static _jsonSchemaVersion: string = 'firestore/documentReference/1.0'; + static _jsonSchema = { + type: property('string', DocumentReference._jsonSchemaVersion), + referencePath: property('string') + }; + + /** + * Returns a JSON-serializable representation of this `DocumentReference` instance. + * + * @returns a JSON representation of this object. + */ + toJSON(): object { + return { + type: DocumentReference._jsonSchemaVersion, + referencePath: this._key.toString() + }; + } + + /** + * Builds a `DocumentReference` instance from a JSON object created by + * {@link DocumentReference.toJSON}. + * + * @param firestore - The {@link Firestore} instance the snapshot should be loaded for. + * @param json a JSON object represention of a `DocumentReference` instance + * @returns an instance of {@link DocumentReference} if the JSON object could be parsed. Throws a + * {@link FirestoreError} if an error occurs. + */ + static fromJSON(firestore: Firestore, json: object): DocumentReference; + /** + * Builds a `DocumentReference` instance from a JSON object created by + * {@link DocumentReference.toJSON}. + * + * @param firestore - The {@link Firestore} instance the snapshot should be loaded for. + * @param json a JSON object represention of a `DocumentReference` instance + * @param converter - Converts objects to and from Firestore. + * @returns an instance of {@link DocumentReference} if the JSON object could be parsed. Throws a + * {@link FirestoreError} if an error occurs. + */ + static fromJSON< + NewAppModelType = DocumentData, + NewDbModelType extends DocumentData = DocumentData + >( + firestore: Firestore, + json: object, + converter: FirestoreDataConverter + ): DocumentReference; + static fromJSON< + NewAppModelType = DocumentData, + NewDbModelType extends DocumentData = DocumentData + >( + firestore: Firestore, + json: object, + converter?: FirestoreDataConverter + ): DocumentReference { + if (validateJSON(json, DocumentReference._jsonSchema)) { + return new DocumentReference( + firestore, + converter ? converter : null, + new DocumentKey(ResourcePath.fromString(json.referencePath)) + ); + } + throw new FirestoreError( + Code.INVALID_ARGUMENT, + 'Unexpected error creating Bytes from JSON.' + ); + } } /** diff --git a/packages/firestore/src/lite-api/timestamp.ts b/packages/firestore/src/lite-api/timestamp.ts index e3d945aaf30..48c514feca8 100644 --- a/packages/firestore/src/lite-api/timestamp.ts +++ b/packages/firestore/src/lite-api/timestamp.ts @@ -16,6 +16,9 @@ */ import { Code, FirestoreError } from '../util/error'; +// API extractor fails importing 'property' unless we also explicitly import 'Property'. +// eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports-ts +import { Property, property, validateJSON } from '../util/json_validation'; import { primitiveComparator } from '../util/misc'; // The earliest date supported by Firestore timestamps (0001-01-01T00:00:00Z). @@ -174,9 +177,35 @@ export class Timestamp { ); } - /** Returns a JSON-serializable representation of this `Timestamp`. */ - toJSON(): { seconds: number; nanoseconds: number } { - return { seconds: this.seconds, nanoseconds: this.nanoseconds }; + static _jsonSchemaVersion: string = 'firestore/timestamp/1.0'; + static _jsonSchema = { + type: property('string', Timestamp._jsonSchemaVersion), + seconds: property('number'), + nanoseconds: property('number') + }; + + /** + * Returns a JSON-serializable representation of this `Timestamp`. + */ + toJSON(): { seconds: number; nanoseconds: number; type: string } { + return { + type: Timestamp._jsonSchemaVersion, + seconds: this.seconds, + nanoseconds: this.nanoseconds + }; + } + + /** + * Builds a `Timestamp` instance from a JSON object created by {@link Timestamp.toJSON}. + */ + static fromJSON(json: object): Timestamp { + if (validateJSON(json, Timestamp._jsonSchema)) { + return new Timestamp(json.seconds, json.nanoseconds); + } + throw new FirestoreError( + Code.INVALID_ARGUMENT, + 'Unexpected error creating Timestamp from JSON.' + ); } /** diff --git a/packages/firestore/src/lite-api/user_data_reader.ts b/packages/firestore/src/lite-api/user_data_reader.ts index bd073c2f50b..2179d7854b3 100644 --- a/packages/firestore/src/lite-api/user_data_reader.ts +++ b/packages/firestore/src/lite-api/user_data_reader.ts @@ -780,7 +780,7 @@ export function parseData( } } -function parseObject( +export function parseObject( obj: Dict, context: ParseContextImpl ): { mapValue: ProtoMapValue } { diff --git a/packages/firestore/src/lite-api/vector_value.ts b/packages/firestore/src/lite-api/vector_value.ts index 9ac9753fef5..c48feaeff3b 100644 --- a/packages/firestore/src/lite-api/vector_value.ts +++ b/packages/firestore/src/lite-api/vector_value.ts @@ -16,6 +16,10 @@ */ import { isPrimitiveArrayEqual } from '../util/array'; +import { Code, FirestoreError } from '../util/error'; +// API extractor fails importing 'property' unless we also explicitly import 'Property'. +// eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports-ts +import { Property, property, validateJSON } from '../util/json_validation'; /** * Represents a vector type in Firestore documents. @@ -48,4 +52,48 @@ export class VectorValue { isEqual(other: VectorValue): boolean { return isPrimitiveArrayEqual(this._values, other._values); } + + static _jsonSchemaVersion: string = 'firestore/vectorValue/1.0'; + static _jsonSchema = { + type: property('string', VectorValue._jsonSchemaVersion), + vectorValues: property('object') + }; + + /** + * Returns a JSON-serializable representation of this `VectorValue` instance. + * + * @returns a JSON representation of this object. + */ + toJSON(): object { + return { + type: VectorValue._jsonSchemaVersion, + vectorValues: this._values + }; + } + + /** + * Builds a `VectorValue` instance from a JSON object created by {@link VectorValue.toJSON}. + * + * @param json a JSON object represention of a `VectorValue` instance. + * @returns an instance of {@link VectorValue} if the JSON object could be parsed. Throws a + * {@link FirestoreError} if an error occurs. + */ + static fromJSON(json: object): VectorValue { + if (validateJSON(json, VectorValue._jsonSchema)) { + if ( + Array.isArray(json.vectorValues) && + json.vectorValues.every(element => typeof element === 'number') + ) { + return new VectorValue(json.vectorValues); + } + throw new FirestoreError( + Code.INVALID_ARGUMENT, + "Expected 'vectorValues' field to be a number array" + ); + } + throw new FirestoreError( + Code.INVALID_ARGUMENT, + 'Unexpected error creating Timestamp from JSON.' + ); + } } diff --git a/packages/firestore/src/local/indexeddb_persistence.ts b/packages/firestore/src/local/indexeddb_persistence.ts index 57c26ea5baa..0ec2baabfe4 100644 --- a/packages/firestore/src/local/indexeddb_persistence.ts +++ b/packages/firestore/src/local/indexeddb_persistence.ts @@ -58,7 +58,11 @@ import { IndexedDbTargetCache } from './indexeddb_target_cache'; import { getStore, IndexedDbTransaction } from './indexeddb_transaction'; import { LocalSerializer } from './local_serializer'; import { LruParams } from './lru_garbage_collector'; -import { Persistence, PrimaryStateListener } from './persistence'; +import { + DatabaseDeletedListener, + Persistence, + PrimaryStateListener +} from './persistence'; import { PersistencePromise } from './persistence_promise'; import { PersistenceTransaction, @@ -324,20 +328,25 @@ export class IndexedDbPersistence implements Persistence { } /** - * Registers a listener that gets called when the database receives a - * version change event indicating that it has deleted. + * Registers a listener that gets called when the underlying database receives + * an event indicating that it either has been deleted or is pending deletion + * and must be closed. + * + * For example, this callback will be called in the case that multi-tab + * IndexedDB persistence is in use and another tab calls + * clearIndexedDbPersistence(). In that case, this Firestore instance must + * close its IndexedDB connection in order to allow the deletion initiated by + * the other tab to proceed. + * + * This method may only be called once; subsequent invocations will result in + * an exception, refusing to supersede the previously-registered listener. * * PORTING NOTE: This is only used for Web multi-tab. */ setDatabaseDeletedListener( - databaseDeletedListener: () => Promise + databaseDeletedListener: DatabaseDeletedListener ): void { - this.simpleDb.setVersionChangeListener(async event => { - // Check if an attempt is made to delete IndexedDB. - if (event.newVersion === null) { - await databaseDeletedListener(); - } - }); + this.simpleDb.setDatabaseDeletedListener(databaseDeletedListener); } /** diff --git a/packages/firestore/src/local/persistence.ts b/packages/firestore/src/local/persistence.ts index b014a6479ac..113efe7b7d3 100644 --- a/packages/firestore/src/local/persistence.ts +++ b/packages/firestore/src/local/persistence.ts @@ -98,6 +98,8 @@ export interface ReferenceDelegate { ): PersistencePromise; } +export type DatabaseDeletedListener = () => void; + /** * Persistence is the lowest-level shared interface to persistent storage in * Firestore. @@ -151,13 +153,23 @@ export interface Persistence { shutdown(): Promise; /** - * Registers a listener that gets called when the database receives a - * version change event indicating that it has deleted. + * Registers a listener that gets called when the underlying database receives + * an event indicating that it either has been deleted or is pending deletion + * and must be closed. + * + * For example, this callback will be called in the case that multi-tab + * IndexedDB persistence is in use and another tab calls + * clearIndexedDbPersistence(). In that case, this Firestore instance must + * close its IndexedDB connection in order to allow the deletion initiated by + * the other tab to proceed. + * + * This method may only be called once; subsequent invocations will result in + * an exception, refusing to supersede the previously-registered listener. * * PORTING NOTE: This is only used for Web multi-tab. */ setDatabaseDeletedListener( - databaseDeletedListener: () => Promise + databaseDeletedListener: DatabaseDeletedListener ): void; /** diff --git a/packages/firestore/src/local/simple_db.ts b/packages/firestore/src/local/simple_db.ts index 6d27702e725..1e315c5dae6 100644 --- a/packages/firestore/src/local/simple_db.ts +++ b/packages/firestore/src/local/simple_db.ts @@ -19,9 +19,10 @@ import { getGlobal, getUA, isIndexedDBAvailable } from '@firebase/util'; import { debugAssert } from '../util/assert'; import { Code, FirestoreError } from '../util/error'; -import { logDebug, logError } from '../util/log'; +import { logDebug, logError, logWarn } from '../util/log'; import { Deferred } from '../util/promise'; +import { DatabaseDeletedListener } from './persistence'; import { PersistencePromise } from './persistence_promise'; // References to `indexedDB` are guarded by SimpleDb.isAvailable() and getGlobal() @@ -158,8 +159,8 @@ export class SimpleDbTransaction { */ export class SimpleDb { private db?: IDBDatabase; + private databaseDeletedListener?: DatabaseDeletedListener; private lastClosedDbVersion: number | null = null; - private versionchangelistener?: (event: IDBVersionChangeEvent) => void; /** Deletes the specified database. */ static delete(name: string): Promise { @@ -392,22 +393,35 @@ export class SimpleDb { ); } - if (this.versionchangelistener) { - this.db.onversionchange = event => this.versionchangelistener!(event); - } + this.db.addEventListener( + 'versionchange', + event => { + // Notify the listener if another tab attempted to delete the IndexedDb + // database, such as by calling clearIndexedDbPersistence(). + if (event.newVersion === null) { + logWarn( + `Received "versionchange" event with newVersion===null; ` + + 'notifying the registered DatabaseDeletedListener, if any' + ); + this.databaseDeletedListener?.(); + } + }, + { passive: true } + ); return this.db; } - setVersionChangeListener( - versionChangeListener: (event: IDBVersionChangeEvent) => void + setDatabaseDeletedListener( + databaseDeletedListener: DatabaseDeletedListener ): void { - this.versionchangelistener = versionChangeListener; - if (this.db) { - this.db.onversionchange = (event: IDBVersionChangeEvent) => { - return versionChangeListener(event); - }; + if (this.databaseDeletedListener) { + throw new Error( + 'setDatabaseDeletedListener() may only be called once, ' + + 'and it has already been called' + ); } + this.databaseDeletedListener = databaseDeletedListener; } async runTransaction( diff --git a/packages/firestore/src/platform/browser/snapshot_to_json.ts b/packages/firestore/src/platform/browser/snapshot_to_json.ts new file mode 100644 index 00000000000..37c1a0b556d --- /dev/null +++ b/packages/firestore/src/platform/browser/snapshot_to_json.ts @@ -0,0 +1,43 @@ +/** + * @license + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** Return the Platform-specific build JSON bundle implementations. */ +import { Firestore } from '../../api/database'; +import { Query } from '../../core/query'; +import { DocumentData } from '../../lite-api/reference'; +import { Document } from '../../model/document'; + +export function buildDocumentSnapshotJsonBundle( + db: Firestore, + document: Document, + docData: DocumentData, + path: string +): string { + return 'NOT SUPPORTED'; +} + +export function buildQuerySnapshotJsonBundle( + db: Firestore, + query: Query, + bundleName: string, + parent: string, + paths: string[], + docs: Document[], + documentData: DocumentData[] +): string { + return 'NOT SUPPORTED'; +} diff --git a/packages/firestore/src/platform/browser_lite/snapshot_to_json.ts b/packages/firestore/src/platform/browser_lite/snapshot_to_json.ts new file mode 100644 index 00000000000..4012dc496b2 --- /dev/null +++ b/packages/firestore/src/platform/browser_lite/snapshot_to_json.ts @@ -0,0 +1,18 @@ +/** + * @license + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from '../browser/snapshot_to_json'; diff --git a/packages/firestore/src/platform/node/snapshot_to_json.ts b/packages/firestore/src/platform/node/snapshot_to_json.ts new file mode 100644 index 00000000000..61987fbbc3c --- /dev/null +++ b/packages/firestore/src/platform/node/snapshot_to_json.ts @@ -0,0 +1,84 @@ +/** + * @license + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** Return the Platform-specific build JSON bundle implementations. */ +import { Firestore } from '../../api/database'; +import { Query } from '../../core/query'; +import { DocumentData } from '../../lite-api/reference'; +import { Document } from '../../model/document'; +import { + BundleBuilder, + DocumentSnapshotBundleData, + QuerySnapshotBundleData +} from '../../util/bundle_builder_impl'; +import { AutoId } from '../../util/misc'; + +export function buildDocumentSnapshotJsonBundle( + db: Firestore, + document: Document, + docData: DocumentData, + path: string +): string { + const builder: BundleBuilder = new BundleBuilder(db, AutoId.newId()); + builder.addBundleDocument( + documentToDocumentSnapshotBundleData(path, docData, document) + ); + return builder.build(); +} + +export function buildQuerySnapshotJsonBundle( + db: Firestore, + query: Query, + bundleName: string, + parent: string, + paths: string[], + docs: Document[], + documentData: DocumentData[] +): string { + const docBundleDataArray: DocumentSnapshotBundleData[] = []; + for (let i = 0; i < docs.length; i++) { + docBundleDataArray.push( + documentToDocumentSnapshotBundleData(paths[i], documentData[i], docs[i]) + ); + } + const bundleData: QuerySnapshotBundleData = { + name: bundleName, + query, + parent, + docBundleDataArray + }; + const builder: BundleBuilder = new BundleBuilder(db, bundleName); + builder.addBundleQuery(bundleData); + return builder.build(); +} + +// Formats Document data for bundling a DocumentSnapshot. +function documentToDocumentSnapshotBundleData( + path: string, + documentData: DocumentData, + document: Document +): DocumentSnapshotBundleData { + return { + documentData, + documentKey: document.mutableCopy().key, + documentPath: path, + documentExists: true, + createdTime: document.createTime.toTimestamp(), + readTime: document.readTime.toTimestamp(), + versionTime: document.version.toTimestamp() + }; +} diff --git a/packages/firestore/src/platform/node_lite/snapshot_to_json.ts b/packages/firestore/src/platform/node_lite/snapshot_to_json.ts new file mode 100644 index 00000000000..ba6bbb8424b --- /dev/null +++ b/packages/firestore/src/platform/node_lite/snapshot_to_json.ts @@ -0,0 +1,18 @@ +/** + * @license + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from '../node/snapshot_to_json'; diff --git a/packages/firestore/src/platform/rn/snapshot_to_json.ts b/packages/firestore/src/platform/rn/snapshot_to_json.ts new file mode 100644 index 00000000000..551f586d20e --- /dev/null +++ b/packages/firestore/src/platform/rn/snapshot_to_json.ts @@ -0,0 +1,21 @@ +/** + * @license + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { + buildDocumentSnapshotJsonBundle, + buildQuerySnapshotJsonBundle +} from '../browser/snapshot_to_json'; diff --git a/packages/firestore/src/platform/rn_lite/snapshot_to_json.ts b/packages/firestore/src/platform/rn_lite/snapshot_to_json.ts new file mode 100644 index 00000000000..709509c8a4e --- /dev/null +++ b/packages/firestore/src/platform/rn_lite/snapshot_to_json.ts @@ -0,0 +1,18 @@ +/** + * @license + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { toByteStreamReader } from '../browser/byte_stream_reader'; diff --git a/packages/firestore/src/platform/snapshot_to_json.ts b/packages/firestore/src/platform/snapshot_to_json.ts new file mode 100644 index 00000000000..1eae948eb45 --- /dev/null +++ b/packages/firestore/src/platform/snapshot_to_json.ts @@ -0,0 +1,62 @@ +/** + * @license + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Firestore } from '../api/database'; +import { Query } from '../core/query'; +import { DocumentData } from '../lite-api/reference'; +import { Document } from '../model/document'; + +// This file is only used under ts-node. +// eslint-disable-next-line @typescript-eslint/no-require-imports +const platform = require(`./${ + process.env.TEST_PLATFORM ?? 'node' +}/snapshot_to_json`); + +/** + * Constructs the bundle data for a DocumentSnapshot used in its toJSON serialization. + */ +export function buildDocumentSnapshotJsonBundle( + db: Firestore, + document: Document, + docData: DocumentData, + path: string +): string { + return platform.buildDocumentSnapshotJsonBundle(db, document, docData, path); +} + +/** + * Constructs the bundle data for a QuerySnapshot used in its toJSON serialization. + */ +export function buildQuerySnapshotJsonBundle( + db: Firestore, + query: Query, + bundleName: string, + parent: string, + paths: string[], + docs: Document[], + documentData: DocumentData[] +): string { + return platform.buildQuerySnapshotJsonBundle( + db, + query, + bundleName, + parent, + paths, + docs, + documentData + ); +} diff --git a/packages/firestore/src/remote/serializer.ts b/packages/firestore/src/remote/serializer.ts index 06f581e294d..9a683ffe47c 100644 --- a/packages/firestore/src/remote/serializer.ts +++ b/packages/firestore/src/remote/serializer.ts @@ -233,6 +233,9 @@ export function toTimestamp( } } +/** + * Returns a Timestamp typed object given protobuf timestamp value. + */ export function fromTimestamp(date: ProtoTimestamp): Timestamp { const timestamp = normalizeTimestamp(date); return new Timestamp(timestamp.seconds, timestamp.nanos); diff --git a/packages/firestore/src/util/bundle_builder_impl.ts b/packages/firestore/src/util/bundle_builder_impl.ts new file mode 100644 index 00000000000..dc94ebca495 --- /dev/null +++ b/packages/firestore/src/util/bundle_builder_impl.ts @@ -0,0 +1,284 @@ +/** + * @license + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + JsonProtoSerializer, + fromTimestamp, + toName, + toQueryTarget, + toTimestamp +} from '../../src/remote/serializer'; +import { encoder } from '../../test/unit/util/bundle_data'; +import { Firestore } from '../api/database'; +import { DatabaseId } from '../core/database_info'; +import { Query, queryToTarget } from '../core/query'; +import { DocumentData } from '../lite-api/reference'; +import { Timestamp } from '../lite-api/timestamp'; +import { + parseObject, + UserDataReader, + UserDataSource +} from '../lite-api/user_data_reader'; +import { DocumentKey } from '../model/document_key'; +import { + BundledDocumentMetadata as ProtoBundledDocumentMetadata, + BundleElement as ProtoBundleElement, + BundleMetadata as ProtoBundleMetadata, + NamedQuery as ProtoNamedQuery +} from '../protos/firestore_bundle_proto'; +import { + Document as ProtoDocument, + Document +} from '../protos/firestore_proto_api'; + +const BUNDLE_VERSION = 1; + +/** + * Builds a Firestore data bundle with results from the given document and query snapshots. + */ +export class BundleBuilder { + // Resulting documents for the bundle, keyed by full document path. + private documents: Map = new Map(); + // Named queries saved in the bundle, keyed by query name. + private namedQueries: Map = new Map(); + + // The latest read time among all bundled documents and queries. + private latestReadTime = new Timestamp(0, 0); + + // Database identifier which is part of the serialized bundle. + private databaseId: DatabaseId; + + // Tools to convert public data types into their serialized form. + private readonly serializer: JsonProtoSerializer; + private readonly userDataReader: UserDataReader; + + constructor(private firestore: Firestore, readonly bundleId: string) { + this.databaseId = firestore._databaseId; + + // useProto3Json is true because the objects will be serialized to JSON string + // before being written to the bundle buffer. + this.serializer = new JsonProtoSerializer( + this.databaseId, + /*useProto3Json=*/ true + ); + + this.userDataReader = new UserDataReader( + this.databaseId, + true, + this.serializer + ); + } + + /** + * Adds data from a DocumentSnapshot to the bundle. + * @internal + * @param docBundleData A DocumentSnapshotBundleData containing information from the + * DocumentSnapshot. Note we cannot accept a DocumentSnapshot directly due to a circular + * dependency error. + * @param queryName The name of the QuerySnapshot if this document is part of a Query. + */ + addBundleDocument( + docBundleData: DocumentSnapshotBundleData, + queryName?: string + ): void { + const originalDocument = this.documents.get(docBundleData.documentPath); + const originalQueries = originalDocument?.metadata.queries; + const docReadTime: Timestamp | undefined = docBundleData.readTime; + const origDocReadTime: Timestamp | null = !!originalDocument?.metadata + .readTime + ? fromTimestamp(originalDocument.metadata.readTime) + : null; + + const neitherHasReadTime: boolean = !docReadTime && origDocReadTime == null; + const docIsNewer: boolean = + docReadTime !== undefined && + (origDocReadTime == null || origDocReadTime < docReadTime); + if (neitherHasReadTime || docIsNewer) { + // Store document. + this.documents.set(docBundleData.documentPath, { + document: this.toBundleDocument(docBundleData), + metadata: { + name: toName(this.serializer, docBundleData.documentKey), + readTime: !!docReadTime + ? toTimestamp(this.serializer, docReadTime) // Convert Timestamp to proto format. + : undefined, + exists: docBundleData.documentExists + } + }); + } + if (docReadTime && docReadTime > this.latestReadTime) { + this.latestReadTime = docReadTime; + } + // Update `queries` to include both original and `queryName`. + if (queryName) { + const newDocument = this.documents.get(docBundleData.documentPath)!; + newDocument.metadata.queries = originalQueries || []; + newDocument.metadata.queries!.push(queryName); + } + } + + /** + * Adds data from a QuerySnapshot to the bundle. + * @internal + * @param docBundleData A QuerySnapshotBundleData containing information from the + * QuerySnapshot. Note we cannot accept a QuerySnapshot directly due to a circular + * dependency error. + */ + addBundleQuery(queryBundleData: QuerySnapshotBundleData): void { + if (this.namedQueries.has(queryBundleData.name)) { + throw new Error(`Query name conflict: ${name} has already been added.`); + } + let latestReadTime = new Timestamp(0, 0); + for (const docBundleData of queryBundleData.docBundleDataArray) { + this.addBundleDocument(docBundleData, queryBundleData.name); + if (docBundleData.readTime && docBundleData.readTime > latestReadTime) { + latestReadTime = docBundleData.readTime; + } + } + const queryTarget = toQueryTarget( + this.serializer, + queryToTarget(queryBundleData.query) + ); + const bundledQuery = { + parent: queryBundleData.parent, + structuredQuery: queryTarget.queryTarget.structuredQuery + }; + this.namedQueries.set(queryBundleData.name, { + name: queryBundleData.name, + bundledQuery, + readTime: toTimestamp(this.serializer, latestReadTime) + }); + } + + /** + * Convert data from a DocumentSnapshot into the serialized form within a bundle. + * @private + * @internal + * @param docBundleData a DocumentSnapshotBundleData containing the data required to + * serialize a document. + */ + private toBundleDocument( + docBundleData: DocumentSnapshotBundleData + ): ProtoDocument { + // a parse context is typically used for validating and parsing user data, but in this + // case we are using it internally to convert DocumentData to Proto3 JSON + const context = this.userDataReader.createContext( + UserDataSource.ArrayArgument, + 'internal toBundledDocument' + ); + const proto3Fields = parseObject(docBundleData.documentData, context); + + return { + name: toName(this.serializer, docBundleData.documentKey), + fields: proto3Fields.mapValue.fields, + updateTime: toTimestamp(this.serializer, docBundleData.versionTime), + createTime: toTimestamp(this.serializer, docBundleData.createdTime) + }; + } + + /** + * Converts a IBundleElement to a Buffer whose content is the length prefixed JSON representation + * of the element. + * @private + * @internal + * @param bundleElement A ProtoBundleElement that is expected to be Proto3 JSON compatible. + */ + private lengthPrefixedString(bundleElement: ProtoBundleElement): string { + const str = JSON.stringify(bundleElement); + // TODO: it's not ideal to have to re-encode all of these strings multiple times + // It may be more performant to return a UInt8Array that is concatenated to other + // UInt8Arrays instead of returning and concatenating strings and then + // converting the full string to UInt8Array. + const l = encoder.encode(str).byteLength; + return `${l}${str}`; + } + + /** + * Construct a serialized string containing document and query information that has previously + * been added to the BundleBuilder through the addBundleDocument and addBundleQuery methods. + * @internal + */ + build(): string { + let bundleString = ''; + + for (const namedQuery of this.namedQueries.values()) { + bundleString += this.lengthPrefixedString({ namedQuery }); + } + + for (const bundledDocument of this.documents.values()) { + const documentMetadata: ProtoBundledDocumentMetadata = + bundledDocument.metadata; + + bundleString += this.lengthPrefixedString({ documentMetadata }); + // Write to the bundle if document exists. + const document = bundledDocument.document; + if (document) { + bundleString += this.lengthPrefixedString({ document }); + } + } + + const metadata: ProtoBundleMetadata = { + id: this.bundleId, + createTime: toTimestamp(this.serializer, this.latestReadTime), + version: BUNDLE_VERSION, + totalDocuments: this.documents.size, + // TODO: it's not ideal to have to re-encode all of these strings multiple times + totalBytes: encoder.encode(bundleString).length + }; + // Prepends the metadata element to the bundleBuffer: `bundleBuffer` is the second argument to `Buffer.concat`. + bundleString = this.lengthPrefixedString({ metadata }) + bundleString; + + return bundleString; + } +} + +/** + * Interface for an object that contains data required to bundle a DocumentSnapshot. + * @internal + */ +export interface DocumentSnapshotBundleData { + documentData: DocumentData; + documentKey: DocumentKey; + documentPath: string; + documentExists: boolean; + createdTime: Timestamp; + readTime?: Timestamp; + versionTime: Timestamp; +} + +/** + * Interface for an object that contains data required to bundle a QuerySnapshot. + * @internal + */ +export interface QuerySnapshotBundleData { + name: string; + query: Query; + parent: string; + docBundleDataArray: DocumentSnapshotBundleData[]; +} + +/** + * Convenient class to hold both the metadata and the actual content of a document to be bundled. + * @private + * @internal + */ +class BundledDocument { + constructor( + readonly metadata: ProtoBundledDocumentMetadata, + readonly document?: Document + ) {} +} diff --git a/packages/firestore/src/util/bundle_reader.ts b/packages/firestore/src/util/bundle_reader.ts index 6ebfb2d5e8e..cca1c61a538 100644 --- a/packages/firestore/src/util/bundle_reader.ts +++ b/packages/firestore/src/util/bundle_reader.ts @@ -65,3 +65,24 @@ export interface BundleReader { */ nextElement(): Promise; } + +/** + * A class representing a synchronized bundle reader. + * + * Takes a bundle string buffer, parses the data, and provides accessors to the data contained + * within it. + */ +export interface BundleReaderSync { + serializer: JsonProtoSerializer; + + /** + * Returns the metadata of the bundle. + */ + getMetadata(): BundleMetadata; + + /** + * Returns BundleElements parsed from the bundle. Returns an empty array if no bundle elements + * exist. + */ + getElements(): SizedBundleElement[]; +} diff --git a/packages/firestore/src/util/bundle_reader_sync_impl.ts b/packages/firestore/src/util/bundle_reader_sync_impl.ts new file mode 100644 index 00000000000..9379bb5a5a7 --- /dev/null +++ b/packages/firestore/src/util/bundle_reader_sync_impl.ts @@ -0,0 +1,129 @@ +/** + * @license + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { BundleMetadata } from '../protos/firestore_bundle_proto'; +import { JsonProtoSerializer } from '../remote/serializer'; +import { Code, FirestoreError } from '../util/error'; + +import { BundleReaderSync, SizedBundleElement } from './bundle_reader'; + +/** + * A class that can parse a bundle form the string serialization of a bundle. + */ +export class BundleReaderSyncImpl implements BundleReaderSync { + private metadata: BundleMetadata; + private elements: SizedBundleElement[]; + private cursor: number; + constructor( + private bundleData: string, + readonly serializer: JsonProtoSerializer + ) { + this.cursor = 0; + this.elements = []; + + let element = this.nextElement(); + if (element && element.isBundleMetadata()) { + this.metadata = element as BundleMetadata; + } else { + throw new Error(`The first element of the bundle is not a metadata object, it is + ${JSON.stringify(element?.payload)}`); + } + + do { + element = this.nextElement(); + if (element !== null) { + this.elements.push(element); + } + } while (element !== null); + } + + /* Returns the parsed metadata of the bundle. */ + getMetadata(): BundleMetadata { + return this.metadata; + } + + /* Returns the DocumentSnapshot or NamedQuery elements of the bundle. */ + getElements(): SizedBundleElement[] { + return this.elements; + } + + /** + * Parses the next element of the bundle. + * + * @returns a SizedBundleElement representation of the next element in the bundle, or null if + * no more elements exist. + */ + private nextElement(): SizedBundleElement | null { + if (this.cursor === this.bundleData.length) { + return null; + } + const length: number = this.readLength(); + const jsonString = this.readJsonString(length); + return new SizedBundleElement(JSON.parse(jsonString), length); + } + + /** + * Reads from a specified position from the bundleData string, for a specified + * number of bytes. + * + * @param length how many characters to read. + * @returns a string parsed from the bundle. + */ + private readJsonString(length: number): string { + if (this.cursor + length > this.bundleData.length) { + throw new FirestoreError( + Code.INTERNAL, + 'Reached the end of bundle when more is expected.' + ); + } + const result = this.bundleData.slice(this.cursor, (this.cursor += length)); + return result; + } + + /** + * Reads from the current cursor until the first '{'. + * + * @returns A string to integer represention of the parsed value. + * @throws An {@link Error} if the cursor has reached the end of the stream, since lengths + * prefix bundle objects. + */ + private readLength(): number { + const startIndex = this.cursor; + let curIndex = this.cursor; + while (curIndex < this.bundleData.length) { + if (this.bundleData[curIndex] === '{') { + if (curIndex === startIndex) { + throw new Error('First character is a bracket and not a number'); + } + this.cursor = curIndex; + return Number(this.bundleData.slice(startIndex, curIndex)); + } + curIndex++; + } + throw new Error('Reached the end of bundle when more is expected.'); + } +} + +/** + * Creates an instance of BundleReader without exposing the BundleReaderSyncImpl class type. + */ +export function newBundleReaderSync( + bundleData: string, + serializer: JsonProtoSerializer +): BundleReaderSync { + return new BundleReaderSyncImpl(bundleData, serializer); +} diff --git a/packages/firestore/src/util/json_validation.ts b/packages/firestore/src/util/json_validation.ts new file mode 100644 index 00000000000..771a7f91ef3 --- /dev/null +++ b/packages/firestore/src/util/json_validation.ts @@ -0,0 +1,142 @@ +/** + * @license + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { isPlainObject } from '../util/input_validation'; + +import { Code, FirestoreError } from './error'; + +/** + * A list of data types Firestore objects may serialize in their toJSON implemenetations. + * @private + * @internal + */ +export type JsonTypeDesc = + | 'object' + | 'string' + | 'number' + | 'boolean' + | 'null' + | 'undefined'; + +/** + * An association of JsonTypeDesc values to their native types. + * @private + * @internal + */ +export type TSType = T extends 'object' + ? object + : T extends 'string' + ? string + : T extends 'number' + ? number + : T extends 'boolean' + ? boolean + : T extends 'null' + ? null + : T extends 'undefined' + ? undefined + : never; + +/** + * The representation of a JSON object property name and its type value. + * @private + * @internal + */ +export interface Property { + value?: TSType; + typeString: JsonTypeDesc; +} + +/** + * A type Firestore data types may use to define the fields used in their JSON serialization. + * @private + * @internal + */ +export interface JsonSchema { + [key: string]: Property; +} + +/** + * Associates the JSON property type to the native type and sets them to be Required. + * @private + * @internal + */ +export type Json = { + [K in keyof T]: Required['value']; +}; + +/** + * Helper function to define a JSON schema {@link Property}. + * @private + * @internal + */ +export function property( + typeString: T, + optionalValue?: TSType +): Property { + const result: Property = { + typeString + }; + if (optionalValue) { + result.value = optionalValue; + } + return result; +} + +/** + * Validates the JSON object based on the provided schema, and narrows the type to the provided + * JSON schema. + * @private + * @internal + * + * @param json A JSON object to validate. + * @param scheme a {@link JsonSchema} that defines the properties to validate. + * @returns true if the JSON schema exists within the object. Throws a FirestoreError otherwise. + */ +export function validateJSON( + json: object, + schema: S +): json is Json { + if (!isPlainObject(json)) { + throw new FirestoreError(Code.INVALID_ARGUMENT, 'JSON must be an object'); + } + let error: string | undefined = undefined; + for (const key in schema) { + if (schema[key]) { + const typeString = schema[key].typeString; + const value: { value: unknown } | undefined = + 'value' in schema[key] ? { value: schema[key].value } : undefined; + if (!(key in json)) { + error = `JSON missing required field: '${key}'`; + break; + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const fieldValue = (json as any)[key]; + if (typeString && typeof fieldValue !== typeString) { + error = `JSON field '${key}' must be a ${typeString}.`; + break; + } else if (value !== undefined && fieldValue !== value.value) { + error = `Expected '${key}' field to equal '${value.value}'`; + break; + } + } + } + if (error) { + throw new FirestoreError(Code.INVALID_ARGUMENT, error); + } + return true; +} diff --git a/packages/firestore/test/integration/api/database.test.ts b/packages/firestore/test/integration/api/database.test.ts index 9675e02efeb..b63c03a4f62 100644 --- a/packages/firestore/test/integration/api/database.test.ts +++ b/packages/firestore/test/integration/api/database.test.ts @@ -16,7 +16,7 @@ */ import { deleteApp } from '@firebase/app'; -import { Deferred } from '@firebase/util'; +import { Deferred, isNode } from '@firebase/util'; import { expect, use } from 'chai'; import chaiAsPromised from 'chai-as-promised'; @@ -33,6 +33,7 @@ import { DocumentData, documentId, DocumentSnapshot, + documentSnapshotFromJSON, enableIndexedDbPersistence, enableNetwork, getDoc, @@ -42,6 +43,7 @@ import { initializeFirestore, limit, onSnapshot, + onSnapshotResume, onSnapshotsInSync, orderBy, query, @@ -66,6 +68,7 @@ import { newTestApp, FirestoreError, QuerySnapshot, + querySnapshotFromJSON, vector, getDocsFromServer } from '../util/firebase_export'; @@ -1206,6 +1209,429 @@ apiDescribe('Database', persistence => { }); }); + it('DocumentSnapshot events for snapshot created by a bundle', async () => { + if (isNode()) { + const initialData = { a: 1 }; + const finalData = { a: 2 }; + await withTestDocAndInitialData( + persistence, + initialData, + async (docRef, db) => { + const doc = await getDoc(docRef); + const accumulator = new EventsAccumulator(); + const unsubscribe = onSnapshotResume( + db, + doc.toJSON(), + accumulator.storeEvent + ); + await accumulator + .awaitEvent() + .then(snap => { + console.error('DEDB accumulator event 1'); + expect(snap.exists()).to.be.true; + expect(snap.data()).to.deep.equal(initialData); + }) + .then(() => setDoc(docRef, finalData)) + .then(() => accumulator.awaitEvent()) + .then(snap => { + expect(snap.exists()).to.be.true; + expect(snap.data()).to.deep.equal(finalData); + }); + unsubscribe(); + } + ); + } + }); + + it('DocumentSnapshot updated doc events in snapshot created by a bundle accumulator', async () => { + if (isNode()) { + const initialData = { a: 1 }; + const finalData = { a: 2 }; + await withTestDocAndInitialData( + persistence, + initialData, + async (docRef, db) => { + const doc = await getDoc(docRef); + const accumulator = new EventsAccumulator(); + const unsubscribe = onSnapshotResume( + db, + doc.toJSON(), + accumulator.storeEvent + ); + await accumulator + .awaitEvent() + .then(snap => { + expect(snap.exists()).to.be.true; + expect(snap.data()).to.deep.equal(initialData); + }) + .then(() => setDoc(docRef, finalData)) + .then(() => accumulator.awaitEvent()) + .then(snap => { + expect(snap.exists()).to.be.true; + expect(snap.data()).to.deep.equal(finalData); + }); + unsubscribe(); + } + ); + } + }); + + it('DocumentSnapshot observer events for snapshot created by a bundle', async () => { + if (isNode()) { + const initialData = { a: 1 }; + const finalData = { a: 2 }; + await withTestDocAndInitialData( + persistence, + initialData, + async (docRef, db) => { + const doc = await getDoc(docRef); + const accumulator = new EventsAccumulator(); + const unsubscribe = onSnapshotResume(db, doc.toJSON(), { + next: accumulator.storeEvent + }); + await accumulator + .awaitEvent() + .then(snap => { + expect(snap.exists()).to.be.true; + expect(snap.data()).to.deep.equal(initialData); + }) + .then(() => setDoc(docRef, finalData)) + .then(() => accumulator.awaitEvent()) + .then(snap => { + expect(snap.exists()).to.be.true; + expect(snap.data()).to.deep.equal(finalData); + }); + unsubscribe(); + } + ); + } + }); + + it('DocumentSnapshot error events for snapshot created by a bundle', async () => { + return withTestDb(persistence, async db => { + const json = { + bundle: 'BadData', + bundleName: 'bundleName', + bundleSource: 'DocumentSnapshot' + }; + const deferred = new Deferred(); + const unsubscribe = onSnapshotResume( + db, + json, + ds => { + expect(ds).to.not.exist; + deferred.resolve(); + }, + err => { + expect(err.name).to.exist; + expect(err.message).to.exist; + deferred.resolve(); + } + ); + await deferred.promise; + unsubscribe(); + }); + }); + + it('DocumentSnapshot observer error events for snapshot created by a bundle', async () => { + return withTestDb(persistence, async db => { + const json = { + bundle: 'BadData', + bundleName: 'bundleName', + bundleSource: 'QuerySnapshot' + }; + const deferred = new Deferred(); + const unsubscribe = onSnapshotResume(db, json, { + next: ds => { + expect(ds).to.not.exist; + deferred.resolve(); + }, + error: err => { + expect(err.name).to.exist; + expect(err.message).to.exist; + deferred.resolve(); + } + }); + await deferred.promise; + unsubscribe(); + }); + }); + + it('DocumentSnapshot updated doc events in snapshot created by fromJSON bundle', async () => { + if (isNode()) { + const initialData = { a: 1 }; + const finalData = { a: 2 }; + await withTestDocAndInitialData( + persistence, + initialData, + async (docRef, db) => { + const doc = await getDoc(docRef); + const fromJsonDoc = documentSnapshotFromJSON(db, doc.toJSON()); + const accumulator = new EventsAccumulator(); + const unsubscribe = onSnapshotResume( + db, + fromJsonDoc.toJSON(), + accumulator.storeEvent + ); + await accumulator + .awaitEvent() + .then(snap => { + expect(snap.exists()).to.be.true; + expect(snap.data()).to.deep.equal(initialData); + }) + .then(() => setDoc(docRef, finalData)) + .then(() => accumulator.awaitEvent()) + .then(snap => { + expect(snap.exists()).to.be.true; + expect(snap.data()).to.deep.equal(finalData); + }); + unsubscribe(); + } + ); + } + }); + + it('DocumentSnapshot updated doc events in snapshot created by fromJSON doc ref', async () => { + if (isNode()) { + const initialData = { a: 1 }; + const finalData = { a: 2 }; + await withTestDocAndInitialData( + persistence, + initialData, + async (docRef, db) => { + const doc = await getDoc(docRef); + const fromJsonDoc = documentSnapshotFromJSON(db, doc.toJSON()); + const accumulator = new EventsAccumulator(); + const unsubscribe = onSnapshot( + fromJsonDoc.ref, + accumulator.storeEvent + ); + await accumulator + .awaitEvent() + .then(snap => { + expect(snap.exists()).to.be.true; + expect(snap.data()).to.deep.equal(initialData); + }) + .then(() => setDoc(docRef, finalData)) + .then(() => accumulator.awaitEvent()) + .then(snap => { + expect(snap.exists()).to.be.true; + expect(snap.data()).to.deep.equal(finalData); + }); + unsubscribe(); + } + ); + } + }); + + it('Querysnapshot events for snapshot created by a bundle', async () => { + if (isNode()) { + const testDocs = { + a: { foo: 1 }, + b: { bar: 2 } + }; + await withTestCollection(persistence, testDocs, async (coll, db) => { + const querySnap = await getDocs(query(coll, orderBy(documentId()))); + const accumulator = new EventsAccumulator(); + const unsubscribe = onSnapshotResume( + db, + querySnap.toJSON(), + accumulator.storeEvent + ); + await accumulator.awaitEvent().then(snap => { + expect(snap.docs).not.to.be.null; + expect(snap.docs.length).to.equal(2); + expect(snap.docs[0].data()).to.deep.equal(testDocs.a); + expect(snap.docs[1].data()).to.deep.equal(testDocs.b); + }); + unsubscribe(); + }); + } + }); + + it('Querysnapshot observer events for snapshot created by a bundle', async () => { + if (isNode()) { + const testDocs = { + a: { foo: 1 }, + b: { bar: 2 } + }; + await withTestCollection(persistence, testDocs, async (coll, db) => { + const querySnap = await getDocs(query(coll, orderBy(documentId()))); + const accumulator = new EventsAccumulator(); + const unsubscribe = onSnapshotResume(db, querySnap.toJSON(), { + next: accumulator.storeEvent + }); + await accumulator.awaitEvent().then(snap => { + expect(snap.docs).not.to.be.null; + expect(snap.docs.length).to.equal(2); + expect(snap.docs[0].data()).to.deep.equal(testDocs.a); + expect(snap.docs[1].data()).to.deep.equal(testDocs.b); + }); + unsubscribe(); + }); + } + }); + + it('QuerySnapshot error events for snapshot created by a bundle', async () => { + return withTestDb(persistence, async db => { + const json = { + bundle: 'BadData', + bundleName: 'bundleName', + bundleSource: 'QuerySnapshot' + }; + const deferred = new Deferred(); + const unsubscribe = onSnapshotResume( + db, + json, + qs => { + expect(qs).to.not.exist; + deferred.resolve(); + }, + err => { + expect(err.name).to.exist; + expect(err.message).to.exist; + deferred.resolve(); + } + ); + await deferred.promise; + unsubscribe(); + }); + }); + + it('QuerySnapshot observer error events for snapshot created by a bundle', async () => { + return withTestDb(persistence, async db => { + const json = { + bundle: 'BadData', + bundleName: 'bundleName', + bundleSource: 'QuerySnapshot' + }; + const deferred = new Deferred(); + const unsubscribe = onSnapshotResume(db, json, { + next: qs => { + expect(qs).to.not.exist; + deferred.resolve(); + }, + error: err => { + expect(err.name).to.exist; + expect(err.message).to.exist; + deferred.resolve(); + } + }); + await deferred.promise; + unsubscribe(); + }); + }); + + it('QuerySnapshot updated doc events in snapshot created by a bundle', async () => { + if (isNode()) { + const testDocs = { + a: { foo: 1 }, + b: { bar: 2 } + }; + await withTestCollection(persistence, testDocs, async (coll, db) => { + const querySnap = await getDocs(query(coll, orderBy(documentId()))); + const refForDocA = querySnap.docs[0].ref; + const accumulator = new EventsAccumulator(); + const unsubscribe = onSnapshotResume( + db, + querySnap.toJSON(), + accumulator.storeEvent + ); + await accumulator + .awaitEvent() + .then(snap => { + expect(snap.docs).not.to.be.null; + expect(snap.docs.length).to.equal(2); + expect(snap.docs[0].data()).to.deep.equal(testDocs.a); + expect(snap.docs[1].data()).to.deep.equal(testDocs.b); + }) + .then(() => setDoc(refForDocA, { foo: 0 })) + .then(() => accumulator.awaitEvent()) + .then(snap => { + expect(snap.docs).not.to.be.null; + expect(snap.docs.length).to.equal(2); + expect(snap.docs[0].data()).to.deep.equal({ foo: 0 }); + expect(snap.docs[1].data()).to.deep.equal(testDocs.b); + }); + unsubscribe(); + }); + } + }); + + it('QuerySnapshot updated doc events in snapshot created by fromJSON ', async () => { + if (isNode()) { + const testDocs = { + a: { foo: 1 }, + b: { bar: 2 } + }; + await withTestCollection(persistence, testDocs, async (coll, db) => { + const querySnap = await getDocs(query(coll, orderBy(documentId()))); + const querySnapFromJson = querySnapshotFromJSON(db, querySnap.toJSON()); + const refForDocA = querySnapFromJson.docs[0].ref; + const accumulator = new EventsAccumulator(); + + const unsubscribe = onSnapshotResume( + db, + querySnapFromJson.toJSON(), + accumulator.storeEvent + ); + await accumulator + .awaitEvent() + .then(snap => { + expect(snap.docs).not.to.be.null; + expect(snap.docs.length).to.equal(2); + expect(snap.docs[0].data()).to.deep.equal(testDocs.a); + expect(snap.docs[1].data()).to.deep.equal(testDocs.b); + }) + .then(() => setDoc(refForDocA, { foo: 0 })) + .then(() => accumulator.awaitEvent()) + .then(snap => { + expect(snap.docs).not.to.be.null; + expect(snap.docs.length).to.equal(2); + expect(snap.docs[0].data()).to.deep.equal({ foo: 0 }); + expect(snap.docs[1].data()).to.deep.equal(testDocs.b); + }); + unsubscribe(); + }); + } + }); + + it('QuerySnapshot updated doc events in snapshot created by fromJSON query ref', async () => { + if (isNode()) { + const testDocs = { + a: { foo: 1 }, + b: { bar: 2 } + }; + await withTestCollection(persistence, testDocs, async (coll, db) => { + const querySnap = await getDocs(query(coll, orderBy(documentId()))); + const querySnapFromJson = querySnapshotFromJSON(db, querySnap.toJSON()); + const refForDocA = querySnapFromJson.docs[0].ref; + const accumulator = new EventsAccumulator(); + const unsubscribe = onSnapshot( + querySnapFromJson.query, + accumulator.storeEvent + ); + await accumulator + .awaitEvent() + .then(snap => { + expect(snap.docs).not.to.be.null; + expect(snap.docs.length).to.equal(2); + expect(snap.docs[0].data()).to.deep.equal(testDocs.a); + expect(snap.docs[1].data()).to.deep.equal(testDocs.b); + }) + .then(() => setDoc(refForDocA, { foo: 0 })) + .then(() => accumulator.awaitEvent()) + .then(snap => { + expect(snap.docs).not.to.be.null; + expect(snap.docs.length).to.equal(2); + expect(snap.docs[0].data()).to.deep.equal({ foo: 0 }); + expect(snap.docs[1].data()).to.deep.equal(testDocs.b); + }); + unsubscribe(); + }); + } + }); + it('Metadata only changes are not fired when no options provided', () => { return withTestDoc(persistence, docRef => { const secondUpdateFound = new Deferred(); diff --git a/packages/firestore/test/integration/api/query.test.ts b/packages/firestore/test/integration/api/query.test.ts index 0f3c1c82a2d..a12c843bf26 100644 --- a/packages/firestore/test/integration/api/query.test.ts +++ b/packages/firestore/test/integration/api/query.test.ts @@ -15,6 +15,7 @@ * limitations under the License. */ +import { isNode } from '@firebase/util'; import { expect } from 'chai'; import { addEqualityMatcher } from '../../util/equality_matcher'; @@ -37,9 +38,11 @@ import { endAt, endBefore, GeoPoint, + getDocFromCache, getDocs, limit, limitToLast, + loadBundle, onSnapshot, or, orderBy, @@ -74,6 +77,47 @@ import { captureExistenceFilterMismatches } from '../util/testing_hooks_util'; apiDescribe('Queries', persistence => { addEqualityMatcher(); + it('QuerySnapshot.toJSON bundle getDocFromCache', async () => { + if (isNode()) { + let path: string | null = null; + let jsonBundle: object | null = null; + const testDocs = { + a: { k: 'a' }, + b: { k: 'b' }, + c: { k: 'c' } + }; + // Write an initial document in an isolated Firestore instance so it's not stored in the cache. + await withTestCollection(persistence, testDocs, async collection => { + await getDocs(query(collection)).then(querySnapshot => { + expect(querySnapshot.docs.length).to.equal(3); + // Find the path to a known doc. + querySnapshot.docs.forEach(docSnapshot => { + if (docSnapshot.ref.path.endsWith('a')) { + path = docSnapshot.ref.path; + } + }); + expect(path).to.not.be.null; + jsonBundle = querySnapshot.toJSON(); + }); + }); + expect(jsonBundle).to.not.be.null; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const json = (jsonBundle as any).bundle; + expect(json).to.exist; + expect(json.length).to.be.greaterThan(0); + + if (path !== null) { + await withTestDb(persistence, async db => { + const docRef = doc(db, path!); + await loadBundle(db, json); + const docSnap = await getDocFromCache(docRef); + expect(docSnap.exists); + expect(docSnap.data()).to.deep.equal(testDocs.a); + }); + } + } + }); + it('can issue limit queries', () => { const testDocs = { a: { k: 'a' }, diff --git a/packages/firestore/test/lite/integration.test.ts b/packages/firestore/test/lite/integration.test.ts index 780db5f4f9c..7fb7eafcb1e 100644 --- a/packages/firestore/test/lite/integration.test.ts +++ b/packages/firestore/test/lite/integration.test.ts @@ -423,6 +423,20 @@ describe('getDoc()', () => { expect(docSnap.exists()).to.be.true; }); }); + + it('can get doc with a deserialized reference', () => { + return withTestDocAndInitialData({ val: 1 }, async docRef => { + const docSnap = await getDoc(docRef); + expect(docSnap.exists()).to.be.true; + const json = docRef.toJSON(); + const deserializedDocRef = DocumentReference.fromJSON( + docSnap._firestore, + json + ); + const docSnap2 = await getDoc(deserializedDocRef); + expect(docSnap2.exists()).to.be.true; + }); + }); }); /** diff --git a/packages/firestore/test/unit/api/bytes.test.ts b/packages/firestore/test/unit/api/bytes.test.ts index afc37400d8e..8fa8919b1e2 100644 --- a/packages/firestore/test/unit/api/bytes.test.ts +++ b/packages/firestore/test/unit/api/bytes.test.ts @@ -55,4 +55,52 @@ describe('Bytes', () => { expectEqual(blob(1, 2, 3), blob(1, 2, 3)); expectNotEqual(blob(1, 2, 3), blob(4, 5, 6)); }); + + it('fromJSON reconstructs the value from toJSON', () => { + const bytes = Bytes.fromUint8Array(new Uint8Array([0, 1, 2, 3, 4, 5])); + expect(() => { + Bytes.fromJSON(bytes.toJSON()); + }).to.not.throw; + expect(Bytes.fromJSON(bytes.toJSON()).isEqual(bytes)).to.be.true; + }); + + it('fromJSON parameter order does not matter', () => { + const type = 'firestore/bytes/1.0'; + const bytes = 'AA=='; + expect(() => { + Bytes.fromJSON({ bytes, type }); + }).to.not.throw; + expect(() => { + Bytes.fromJSON({ type, bytes }); + }).to.not.throw; + }); + + it('toJSON -> fromJSON bytes comparison', () => { + Object.keys(base64Mappings).forEach(base64Str => { + const bytesToSerialize = Bytes.fromBase64String(base64Str); + const deserializedBytes = Bytes.fromJSON(bytesToSerialize.toJSON()); + expectEqual(bytesToSerialize, deserializedBytes); + const expectedUint8Array = base64Mappings[base64Str]; + const actualUint8Array = deserializedBytes.toUint8Array(); + expect(actualUint8Array.length).to.equal(expectedUint8Array.length); + for (let i = 0; i < actualUint8Array.length; i++) { + expect(actualUint8Array[i]).to.equal(expectedUint8Array[i]); + } + }); + }); + + it('fromJSON misisng fields throws', () => { + expect(() => { + Bytes.fromJSON({ type: 'firestore/bytes/1.0' /* missing bytes data */ }); + }).to.throw; + expect(() => { + Bytes.fromJSON({ bytes: 'AA==' /* missing type */ }); + }).to.throw; + expect(() => { + Bytes.fromJSON({ type: 1, bytes: 'AA==' }); + }).to.throw; + expect(() => { + Bytes.fromJSON({ type: 'firestore/bytes/1.0', bytes: 1 }); + }).to.throw; + }); }); diff --git a/packages/firestore/test/unit/api/database.test.ts b/packages/firestore/test/unit/api/database.test.ts index 46e4c65f180..7f8ce10ffd7 100644 --- a/packages/firestore/test/unit/api/database.test.ts +++ b/packages/firestore/test/unit/api/database.test.ts @@ -15,10 +15,17 @@ * limitations under the License. */ +import { isNode } from '@firebase/util'; import { expect } from 'chai'; import { + DocumentReference, + DocumentSnapshot, + documentSnapshotFromJSON, + QuerySnapshot, + querySnapshotFromJSON, connectFirestoreEmulator, + loadBundle, refEqual, snapshotEqual, queryEqual @@ -29,12 +36,22 @@ import { collectionReference, documentReference, documentSnapshot, + firestore, newTestFirestore, query, querySnapshot } from '../../util/api_helpers'; import { keys } from '../../util/helpers'; +describe('Bundle', () => { + it('loadBundle does not throw with an empty bundle string)', async () => { + const db = newTestFirestore(); + expect(async () => { + await loadBundle(db, ''); + }).to.not.throw; + }); +}); + describe('CollectionReference', () => { it('support equality checking with isEqual()', () => { expect(refEqual(collectionReference('foo'), collectionReference('foo'))).to @@ -61,6 +78,151 @@ describe('DocumentReference', () => { it('JSON.stringify() does not throw', () => { JSON.stringify(documentReference('foo/bar')); }); + + it('toJSON() does not throw', () => { + expect(() => { + documentReference('foo/bar').toJSON(); + }).to.not.throw; + }); + + it('toJSON() includes correct JSON fields', () => { + const docRef = documentReference('foo/bar'); + const json = docRef.toJSON(); + expect(json).to.deep.equal({ + type: 'firestore/documentReference/1.0', + referencePath: 'foo/bar' + }); + }); + + it('fromJSON() throws with invalid data', () => { + const db = newTestFirestore(); + expect(() => { + DocumentReference.fromJSON(db, {}); + }).to.throw("JSON missing required field: 'type'"); + }); + + it('fromJSON() throws with missing type data', () => { + const db = newTestFirestore(); + expect(() => { + documentSnapshotFromJSON(db, { + bundleSource: 'DocumentSnapshot', + bundleName: 'test name', + bundle: 'test bundle' + }); + }).to.throw("JSON missing required field: 'type'"); + }); + + it('fromJSON() throws with invalid type data', () => { + const db = newTestFirestore(); + expect(() => { + documentSnapshotFromJSON(db, { + type: 1, + bundleSource: 'DocumentSnapshot', + bundleName: 'test name', + bundle: 'test bundle' + }); + }).to.throw("JSON field 'type' must be a string"); + }); + + it('fromJSON() throws with missing bundleSource', () => { + const db = newTestFirestore(); + expect(() => { + documentSnapshotFromJSON(db, { + type: DocumentSnapshot._jsonSchemaVersion, + bundleName: 'test name', + bundle: 'test bundle' + }); + }).to.throw("JSON missing required field: 'bundleSource'"); + }); + + it('fromJSON() throws with invalid bundleSource type', () => { + const db = newTestFirestore(); + expect(() => { + documentSnapshotFromJSON(db, { + type: DocumentSnapshot._jsonSchemaVersion, + bundleSource: 1, + bundleName: 'test name', + bundle: 'test bundle' + }); + }).to.throw("JSON field 'bundleSource' must be a string"); + }); + + it('fromJSON() throws with invalid bundleSource value', () => { + const db = newTestFirestore(); + expect(() => { + documentSnapshotFromJSON(db, { + type: DocumentSnapshot._jsonSchemaVersion, + bundleSource: 'QuerySnapshot', + bundleName: 'test name', + bundle: 'test bundle' + }); + }).to.throw("Expected 'bundleSource' field to equal 'DocumentSnapshot'"); + }); + + it('fromJSON() throws with missing bundleName', () => { + const db = newTestFirestore(); + expect(() => { + documentSnapshotFromJSON(db, { + type: DocumentSnapshot._jsonSchemaVersion, + bundleSource: 'DocumentSnapshot', + bundle: 'test bundle' + }); + }).to.throw("JSON missing required field: 'bundleName'"); + }); + + it('fromJSON() throws with invalid bundleName', () => { + const db = newTestFirestore(); + expect(() => { + documentSnapshotFromJSON(db, { + type: DocumentSnapshot._jsonSchemaVersion, + bundleSource: 'DocumentSnapshot', + bundleName: 1, + bundle: 'test bundle' + }); + }).to.throw("JSON field 'bundleName' must be a string"); + }); + + it('fromJSON() throws with missing bundle', () => { + const db = newTestFirestore(); + expect(() => { + documentSnapshotFromJSON(db, { + type: DocumentSnapshot._jsonSchemaVersion, + bundleSource: 'DocumentSnapshot', + bundleName: 'test name' + }); + }).to.throw("JSON missing required field: 'bundle'"); + }); + + it('fromJSON() throws with invalid bundle', () => { + const db = newTestFirestore(); + expect(() => { + documentSnapshotFromJSON(db, { + type: DocumentSnapshot._jsonSchemaVersion, + bundleSource: 'DocumentSnapshot', + bundleName: 'test name', + bundle: 1 + }); + }).to.throw("JSON field 'bundle' must be a string"); + }); + + it('fromJSON() does not throw', () => { + const db = newTestFirestore(); + const docRef = documentReference('foo/bar'); + const json = docRef.toJSON(); + expect(() => { + DocumentReference.fromJSON(db, json); + }).to.not.throw; + }); + + it('fromJSON() equals original docRef', () => { + const db = newTestFirestore(); + const docRef = documentReference('foo/bar'); + const json = docRef.toJSON(); + const deserializedDocRef = DocumentReference.fromJSON(db, json); + expect(docRef.id).to.equal(deserializedDocRef.id); + expect(docRef.path).to.equal(deserializedDocRef.path); + expect(docRef.toJSON()).to.deep.equal(deserializedDocRef.toJSON()); + }); }); describe('DocumentSnapshot', () => { @@ -107,6 +269,108 @@ describe('DocumentSnapshot', () => { it('JSON.stringify() does not throw', () => { JSON.stringify(documentSnapshot('foo/bar', { a: 1 }, true)); }); + + it('toJSON returns a bundle', () => { + const snapshotJson = documentSnapshot( + 'foo/bar', + { a: 1 }, + /*fromCache=*/ true + ).toJSON(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const json = snapshotJson as any; + expect(json.bundle).to.exist; + expect(json.bundle.length).to.be.greaterThan(0); + }); + + it('toJSON returns a bundle containing NOT_SUPPORTED in non-node environments', () => { + if (!isNode()) { + const snapshotJson = documentSnapshot( + 'foo/bar', + { a: 1 }, + /*fromCache=*/ true + ).toJSON(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const json = snapshotJson as any; + expect(json.bundle).to.exist; + expect(json.bundle).to.equal('NOT SUPPORTED'); + } + }); + + it('toJSON returns an empty bundle when there are no documents', () => { + if (isNode()) { + const snapshotJson = documentSnapshot( + 'foo/bar', + /*data=*/ null, + /*fromCache=*/ true + ).toJSON(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const json = snapshotJson as any; + expect(json.bundle).to.exist; + expect(json.bundle.length).to.equal(0); + } + }); + + it('toJSON throws when there are pending writes', () => { + expect(() => { + documentSnapshot( + 'foo/bar', + {}, + /*fromCache=*/ true, + /*hasPendingWrites=*/ true + ).toJSON(); + }).to.throw( + `DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. ` + + `Await waitForPendingWrites() before invoking toJSON().` + ); + }); + + it('fromJSON throws when parsing client-side toJSON result', () => { + if (!isNode()) { + const docSnap = documentSnapshot( + 'foo/bar', + { a: 1 }, + /*fromCache=*/ true + ); + expect(() => { + documentSnapshotFromJSON(docSnap._firestore, docSnap.toJSON()); + }).to.throw; + } + }); + + it('fromJSON parses toJSON result', () => { + if (isNode()) { + const docSnap = documentSnapshot( + 'foo/bar', + { a: 1 }, + /*fromCache=*/ true + ); + expect(() => { + documentSnapshotFromJSON(docSnap._firestore, docSnap.toJSON()); + }).to.not.throw; + } + }); + + it('fromJSON produces valid snapshot data.', () => { + if (isNode()) { + const docSnap = documentSnapshot( + 'foo/bar', + { a: 1 }, + /*fromCache=*/ true + ); + const db = firestore(); + const docSnapFromJSON = documentSnapshotFromJSON(db, docSnap.toJSON()); + expect(docSnapFromJSON).to.exist; + const data = docSnapFromJSON.data(); + expect(docSnapFromJSON).to.not.be.undefined; + expect(docSnapFromJSON).to.not.be.null; + if (data) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + expect((data as any).a).to.exist; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + expect((data as any).a).to.equal(1); + } + } + }); }); describe('Query', () => { @@ -229,6 +493,259 @@ describe('QuerySnapshot', () => { querySnapshot('foo', {}, { a: { a: 1 } }, keys(), false, false) ); }); + + it('toJSON returns a bundle', () => { + const snapshotJson = querySnapshot( + 'foo', + {}, + { a: { a: 1 } }, + keys(), // An empty set of mutaded document keys signifies that there are no pending writes. + false, + false + ).toJSON(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const json = snapshotJson as any; + expect(json.bundle).to.exist; + expect(json.bundle.length).to.be.greaterThan(0); + }); + + it('toJSON returns a bundle containing NOT_SUPPORTED in non-node environments', () => { + if (!isNode()) { + const snapshotJson = querySnapshot( + 'foo', + {}, + { a: { a: 1 } }, + keys(), // An empty set of mutaded document keys signifies that there are no pending writes. + false, + false + ).toJSON(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const json = snapshotJson as any; + expect(json.bundle).to.exist; + expect(json.bundle).to.equal('NOT SUPPORTED'); + } + }); + + it('toJSON returns a bundle when there are no documents', () => { + if (isNode()) { + const snapshotJson = querySnapshot( + 'foo', + {}, + {}, + keys(), + false, + false + ).toJSON(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const json = snapshotJson as any; + expect(json.bundle).to.exist; + expect(json.bundle.length).to.be.greaterThan(0); + } + }); + + it('toJSON throws when there are pending writes', () => { + expect(() => + querySnapshot( + 'foo', + {}, + { a: { a: 1 } }, + keys('foo/a'), // A non empty set of mutated keys signifies pending writes. + false, + false + ).toJSON() + ).to.throw( + `QuerySnapshot.toJSON() attempted to serialize a document with pending writes. ` + + `Await waitForPendingWrites() before invoking toJSON().` + ); + }); + + it('fromJSON() throws with invalid data', () => { + const db = newTestFirestore(); + expect(() => { + querySnapshotFromJSON(db, {}); + }).to.throw("JSON missing required field: 'type'"); + }); + + it('fromJSON() throws with missing type data', () => { + const db = newTestFirestore(); + expect(() => { + querySnapshotFromJSON(db, { + bundleSource: 'QuerySnapshot', + bundleName: 'test name', + bundle: 'test bundle' + }); + }).to.throw("JSON missing required field: 'type'"); + }); + + it('fromJSON() throws with invalid type data', () => { + const db = newTestFirestore(); + expect(() => { + querySnapshotFromJSON(db, { + type: 1, + bundleSource: 'QuerySnapshot', + bundleName: 'test name', + bundle: 'test bundle' + }); + }).to.throw("JSON field 'type' must be a string"); + }); + + it('fromJSON() throws with missing bundle source data', () => { + const db = newTestFirestore(); + expect(() => { + querySnapshotFromJSON(db, { + type: QuerySnapshot._jsonSchemaVersion, + bundleName: 'test name', + bundle: 'test bundle' + }); + }).to.throw("JSON missing required field: 'bundleSource'"); + }); + + it('fromJSON() throws with invalid bundleSource type', () => { + const db = newTestFirestore(); + expect(() => { + querySnapshotFromJSON(db, { + type: QuerySnapshot._jsonSchemaVersion, + bundleSource: 1, + bundleName: 'test name', + bundle: 'test bundle' + }); + }).to.throw("JSON field 'bundleSource' must be a string"); + }); + + it('fromJSON() throws with invalid bundleSource value', () => { + const db = newTestFirestore(); + expect(() => { + querySnapshotFromJSON(db, { + type: QuerySnapshot._jsonSchemaVersion, + bundleSource: 'DocumentSnapshot', + bundleName: 'test name', + bundle: 'test bundle' + }); + }).to.throw("Expected 'bundleSource' field to equal 'QuerySnapshot'"); + }); + + it('fromJSON() throws with missing bundleName', () => { + const db = newTestFirestore(); + expect(() => { + querySnapshotFromJSON(db, { + type: QuerySnapshot._jsonSchemaVersion, + bundleSource: 'QuerySnapshot', + bundle: 'test bundle' + }); + }).to.throw("JSON missing required field: 'bundleName'"); + }); + + it('fromJSON() throws with invalid bundleName', () => { + const db = newTestFirestore(); + expect(() => { + querySnapshotFromJSON(db, { + type: QuerySnapshot._jsonSchemaVersion, + bundleSource: 'QuerySnapshot', + bundleName: 1, + bundle: 'test bundle' + }); + }).to.throw("JSON field 'bundleName' must be a string"); + }); + + it('fromJSON() throws with missing bundle field', () => { + const db = newTestFirestore(); + expect(() => { + querySnapshotFromJSON(db, { + type: QuerySnapshot._jsonSchemaVersion, + bundleSource: 'QuerySnapshot', + bundleName: 'test name' + }); + }).to.throw("JSON missing required field: 'bundle'"); + }); + + it('fromJSON() throws with invalid bundle field', () => { + const db = newTestFirestore(); + expect(() => { + querySnapshotFromJSON(db, { + type: QuerySnapshot._jsonSchemaVersion, + bundleSource: 'QuerySnapshot', + bundleName: 'test name', + bundle: 1 + }); + }).to.throw("JSON field 'bundle' must be a string"); + }); + + it('fromJSON does not throw', () => { + if (isNode()) { + const snapshot = querySnapshot( + 'foo', + {}, + { + a: { a: 1 }, + b: { bar: 2 } + }, + keys(), // An empty set of mutaded document keys signifies that there are no pending writes. + false, + false + ); + const db = firestore(); + expect(() => { + querySnapshotFromJSON(db, snapshot.toJSON()); + }).to.not.throw; + } + }); + + it('fromJSON produces valid snapshot data', () => { + if (isNode()) { + const snapshot = querySnapshot( + 'foo', + {}, + { + a: { a: 1 }, + b: { bar: 2 } + }, + keys(), // An empty set of mutaded document keys signifies that there are no pending writes. + false, + false + ); + const db = firestore(); + const querySnap = querySnapshotFromJSON(db, snapshot.toJSON()); + expect(querySnap).to.exist; + if (querySnap !== undefined) { + const docs = querySnap.docs; + expect(docs).to.not.be.undefined; + expect(docs).to.not.be.null; + if (docs) { + expect(docs.length).to.equal(2); + if (docs.length === 2) { + let docData = docs[0].data(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let data = docData as any; + expect(data.a).to.exist; + expect(data.a).to.equal(1); + + docData = docs[1].data(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + data = docData as any; + expect(data.bar).to.exist; + expect(data.bar).to.equal(2); + } + } + } + } + }); + + it('fromJSON throws when parsing client-side toJSON result', () => { + if (!isNode()) { + const querySnap = querySnapshot( + 'foo', + {}, + { a: { a: 1 } }, + keys(), // An empty set of mutaded document keys signifies that there are no pending writes. + false, + false + ); + const json = querySnap.toJSON(); + expect(() => { + querySnapshotFromJSON(querySnap._firestore, json); + }).to.throw; + } + }); }); describe('SnapshotMetadata', () => { diff --git a/packages/firestore/test/unit/api/geo_point.test.ts b/packages/firestore/test/unit/api/geo_point.test.ts index f2cdb4c27f5..dc744ceb63f 100644 --- a/packages/firestore/test/unit/api/geo_point.test.ts +++ b/packages/firestore/test/unit/api/geo_point.test.ts @@ -105,15 +105,96 @@ describe('GeoPoint', () => { it('serializes to JSON', () => { expect(new GeoPoint(1, 2).toJSON()).to.deep.equal({ latitude: 1, - longitude: 2 + longitude: 2, + 'type': GeoPoint._jsonSchemaVersion }); expect(new GeoPoint(0, 0).toJSON()).to.deep.equal({ latitude: 0, - longitude: 0 + longitude: 0, + 'type': GeoPoint._jsonSchemaVersion }); expect(new GeoPoint(90, 180).toJSON()).to.deep.equal({ latitude: 90, - longitude: 180 + longitude: 180, + 'type': GeoPoint._jsonSchemaVersion }); }); + it('fromJSON does not throw', () => { + const geoPoint = new GeoPoint(1, 2); + expect(() => { + GeoPoint.fromJSON(geoPoint.toJSON()); + }).to.not.throw; + }); + + it('fromJSON reconstructs seconds and nanoseconds', () => { + const geoPoint = new GeoPoint(1, 2); + const deserializedGeoPoint = GeoPoint.fromJSON(geoPoint.toJSON()); + expect(deserializedGeoPoint).to.exist; + expect(geoPoint.latitude).to.equal(deserializedGeoPoint.latitude); + expect(geoPoint.longitude).to.equal(deserializedGeoPoint.longitude); + }); + + it('toJSON -> fromJSON timestamp comparison', () => { + const geoPoint = new GeoPoint(1, 2); + const deserializedGeoPoint = GeoPoint.fromJSON(geoPoint.toJSON()); + expect(deserializedGeoPoint.isEqual(geoPoint)).to.be.true; + }); + + it('fromJSON parameter order does not matter', () => { + const type = 'firestore/geopoint/1.0'; + const latitude = 90; + const longitude = 180; + const control = new GeoPoint(90, 180); + expect(() => { + expect(GeoPoint.fromJSON({ latitude, longitude, type }).isEqual(control)) + .to.be.true; + }).to.not.throw; + expect(() => { + expect(GeoPoint.fromJSON({ longitude, type, latitude }).isEqual(control)) + .to.be.true; + }).to.not.throw; + expect(() => { + expect(GeoPoint.fromJSON({ type, latitude, longitude }).isEqual(control)) + .to.be.true; + }).to.not.throw; + expect(() => { + expect(GeoPoint.fromJSON({ latitude, type, longitude }).isEqual(control)) + .to.be.true; + }).to.not.throw; + }); + + it('fromJSON missing fields throws', () => { + const type = 'firestore/geopoint/1.0'; + const latitude = 90; + const longitude = 180; + + expect(() => { + GeoPoint.fromJSON({ type, latitude }); + }).to.throw; + expect(() => { + GeoPoint.fromJSON({ type, longitude }); + }).to.throw; + expect(() => { + GeoPoint.fromJSON({ latitude, longitude }); + }).to.throw; + }); + + it('fromJSON field errant field type throws', () => { + const type = 'firestore/geopoint/1.0'; + const latitude = 90; + const longitude = 180; + + expect(() => { + GeoPoint.fromJSON({ type, latitude, longitude: 'wrong' }); + }).to.throw; + expect(() => { + GeoPoint.fromJSON({ type, longitude, latitude: 'wrong' }); + }).to.throw; + expect(() => { + GeoPoint.fromJSON({ latitude, longitude, type: 1 }); + }).to.throw; + expect(() => { + GeoPoint.fromJSON({ latitude, longitude, type: 'firestore/wrong/1.0' }); + }).to.throw; + }); }); diff --git a/packages/firestore/test/unit/api/timestamp.test.ts b/packages/firestore/test/unit/api/timestamp.test.ts index ef883f33a92..81773520698 100644 --- a/packages/firestore/test/unit/api/timestamp.test.ts +++ b/packages/firestore/test/unit/api/timestamp.test.ts @@ -143,15 +143,101 @@ describe('Timestamp', () => { it('serializes to JSON', () => { expect(new Timestamp(123, 456).toJSON()).to.deep.equal({ seconds: 123, - nanoseconds: 456 + nanoseconds: 456, + type: 'firestore/timestamp/1.0' }); expect(new Timestamp(0, 0).toJSON()).to.deep.equal({ seconds: 0, - nanoseconds: 0 + nanoseconds: 0, + type: 'firestore/timestamp/1.0' }); expect(new Timestamp(-123, 456).toJSON()).to.deep.equal({ seconds: -123, - nanoseconds: 456 + nanoseconds: 456, + type: 'firestore/timestamp/1.0' }); }); + + it('fromJSON does not throw', () => { + const timestamp = new Timestamp(123, 456); + expect(() => { + Timestamp.fromJSON(timestamp.toJSON()); + }).to.not.throw; + }); + + it('fromJSON reconstructs seconds and nanoseconds', () => { + const timestamp = new Timestamp(123, 456); + const deserializedTimestamp = Timestamp.fromJSON(timestamp.toJSON()); + expect(deserializedTimestamp).to.exist; + expect(timestamp.nanoseconds).to.equal(deserializedTimestamp.nanoseconds); + expect(timestamp.seconds).to.equal(deserializedTimestamp.seconds); + }); + + it('toJSON -> fromJSON timestamp comparison', () => { + const timestamp = new Timestamp(123, 456); + const deserializedTimestamp = Timestamp.fromJSON(timestamp.toJSON()); + expect(deserializedTimestamp.isEqual(timestamp)).to.be.true; + }); + + it('fromJSON parameter order does not matter', () => { + const type = 'firestore/timestamp/1.0'; + const seconds = 123; + const nanoseconds = 456; + const control = new Timestamp(seconds, nanoseconds); + expect(() => { + expect( + Timestamp.fromJSON({ seconds, nanoseconds, type }).isEqual(control) + ).to.be.true; + }).to.not.throw; + expect(() => { + expect( + Timestamp.fromJSON({ nanoseconds, type, seconds }).isEqual(control) + ).to.be.true; + }).to.not.throw; + expect(() => { + expect( + Timestamp.fromJSON({ type, seconds, nanoseconds }).isEqual(control) + ).to.be.true; + }).to.not.throw; + expect(() => { + expect( + Timestamp.fromJSON({ seconds, type, nanoseconds }).isEqual(control) + ).to.be.true; + }).to.not.throw; + }); + + it('fromJSON missing fields throws', () => { + const type = 'firestore/timestamp/1.0'; + const seconds = 123; + const nanoseconds = 456; + + expect(() => { + Timestamp.fromJSON({ type, seconds }); + }).to.throw; + expect(() => { + Timestamp.fromJSON({ type, nanoseconds }); + }).to.throw; + expect(() => { + Timestamp.fromJSON({ seconds, nanoseconds }); + }).to.throw; + }); + + it('fromJSON field errant field type throws', () => { + const type = 'firestore/timestamp/1.0'; + const seconds = 123; + const nanoseconds = 456; + + expect(() => { + Timestamp.fromJSON({ type, seconds, nanoseconds: 'wrong' }); + }).to.throw; + expect(() => { + Timestamp.fromJSON({ type, nanoseconds, seconds: 'wrong' }); + }).to.throw; + expect(() => { + Timestamp.fromJSON({ seconds, nanoseconds, type: 1 }); + }).to.throw; + expect(() => { + Timestamp.fromJSON({ seconds, nanoseconds, type: 'firestore/wrong/1.0' }); + }).to.throw; + }); }); diff --git a/packages/firestore/test/unit/api/vector_value.test.ts b/packages/firestore/test/unit/api/vector_value.test.ts new file mode 100644 index 00000000000..c0944a64934 --- /dev/null +++ b/packages/firestore/test/unit/api/vector_value.test.ts @@ -0,0 +1,73 @@ +/** + * @license + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { expect } from 'chai'; + +import { VectorValue } from '../../../src'; + +describe('VectorValue', () => { + it('fromJSON reconstructs the value from toJSON', () => { + const num: number[] = [1, 2, 3]; + const vectorValue = new VectorValue(num); + const json = vectorValue.toJSON(); + const parsedVectorValue = VectorValue.fromJSON(json); + expect(vectorValue.isEqual(parsedVectorValue)).to.be.true; + }); + + it('fromJSON parameter order does not matter', () => { + const type = VectorValue._jsonSchemaVersion; + const vectorValues = [1, 2, 3]; + const control = new VectorValue(vectorValues); + + expect(() => { + expect(VectorValue.fromJSON({ vectorValues, type }).isEqual(control)).to + .be.true; + }).to.not.throw; + expect(() => { + expect(VectorValue.fromJSON({ type, vectorValues }).isEqual(control)).to + .be.true; + }).to.not.throw; + }); + + it('fromJSON empty array does not throw', () => { + const type = VectorValue._jsonSchemaVersion; + const vectorValues = [1, 2, 3]; + expect(() => { + VectorValue.fromJSON({ type, vectorValues }); + }).to.not.throw; + }); + + it('fromJSON missing fields throws', () => { + const type = VectorValue._jsonSchemaVersion; + const vectorValues = [1, 2, 3]; + expect(() => { + VectorValue.fromJSON({ type /* missing data */ }); + }).to.throw; + expect(() => { + VectorValue.fromJSON({ vectorValues /* missing type */ }); + }).to.throw; + expect(() => { + VectorValue.fromJSON({ type: 1, vectorValues }); + }).to.throw; + expect(() => { + VectorValue.fromJSON({ type: 'firestore/bytes/1.0', vectorValues }); + }).to.throw; + expect(() => { + VectorValue.fromJSON({ type, vectorValues: 'not a number' }); + }); + }); +}); diff --git a/packages/firestore/test/unit/local/indexeddb_persistence.test.ts b/packages/firestore/test/unit/local/indexeddb_persistence.test.ts index 1240c977cee..9fa872101b1 100644 --- a/packages/firestore/test/unit/local/indexeddb_persistence.test.ts +++ b/packages/firestore/test/unit/local/indexeddb_persistence.test.ts @@ -316,10 +316,14 @@ describe('IndexedDbSchema: createOrUpgradeDb', () => { lastRemoteSnapshotVersion: { seconds: 1, nanoseconds: 1 }, targetCount: 1 }; + const timestamp = SnapshotVersion.min().toTimestamp(); const resetTargetGlobal: DbTargetGlobal = { highestTargetId: 0, highestListenSequenceNumber: 0, - lastRemoteSnapshotVersion: SnapshotVersion.min().toTimestamp(), + lastRemoteSnapshotVersion: { + seconds: timestamp.seconds, + nanoseconds: timestamp.nanoseconds + }, targetCount: 0 }; diff --git a/packages/firestore/test/unit/specs/spec_test_runner.ts b/packages/firestore/test/unit/specs/spec_test_runner.ts index 51d2229b8a1..daa513edb68 100644 --- a/packages/firestore/test/unit/specs/spec_test_runner.ts +++ b/packages/firestore/test/unit/specs/spec_test_runner.ts @@ -365,8 +365,14 @@ abstract class TestRunner { this.eventManager.onLastRemoteStoreUnlisten = triggerRemoteStoreUnlisten.bind(null, this.syncEngine); - await this.persistence.setDatabaseDeletedListener(async () => { - await this.shutdown(); + this.persistence.setDatabaseDeletedListener(() => { + this.shutdown().catch(error => { + console.warn( + 'WARNING: this.shutdown() failed in callback ' + + 'specified to persistence.setDatabaseDeletedListener', + error + ); + }); }); this.started = true; diff --git a/packages/firestore/test/util/api_helpers.ts b/packages/firestore/test/util/api_helpers.ts index 517167be323..dc66a70a85b 100644 --- a/packages/firestore/test/util/api_helpers.ts +++ b/packages/firestore/test/util/api_helpers.ts @@ -79,8 +79,10 @@ export function documentReference(path: string): DocumentReference { export function documentSnapshot( path: string, data: JsonObject | null, - fromCache: boolean + fromCache: boolean, + hasPendingWrites?: boolean ): DocumentSnapshot { + hasPendingWrites = !!hasPendingWrites; const db = firestore(); const userDataWriter = new ExpUserDataWriter(db); if (data) { @@ -89,7 +91,7 @@ export function documentSnapshot( userDataWriter, key(path), doc(path, 1, data), - new SnapshotMetadata(/* hasPendingWrites= */ false, fromCache), + new SnapshotMetadata(hasPendingWrites, fromCache), /* converter= */ null ); } else { @@ -98,7 +100,7 @@ export function documentSnapshot( userDataWriter, key(path), null, - new SnapshotMetadata(/* hasPendingWrites= */ false, fromCache), + new SnapshotMetadata(hasPendingWrites, fromCache), /* converter= */ null ); } diff --git a/packages/functions-compat/package.json b/packages/functions-compat/package.json index 09a4514114c..24a8efb46d8 100644 --- a/packages/functions-compat/package.json +++ b/packages/functions-compat/package.json @@ -29,7 +29,7 @@ "@firebase/app-compat": "0.x" }, "devDependencies": { - "@firebase/app-compat": "0.4.0", + "@firebase/app-compat": "0.4.1", "rollup": "2.79.2", "@rollup/plugin-json": "6.1.0", "rollup-plugin-typescript2": "0.36.0", diff --git a/packages/functions/package.json b/packages/functions/package.json index 004181eeb39..6354ed4dadb 100644 --- a/packages/functions/package.json +++ b/packages/functions/package.json @@ -49,7 +49,7 @@ "@firebase/app": "0.x" }, "devDependencies": { - "@firebase/app": "0.13.0", + "@firebase/app": "0.13.1", "rollup": "2.79.2", "@rollup/plugin-json": "6.1.0", "rollup-plugin-typescript2": "0.36.0", diff --git a/packages/installations-compat/package.json b/packages/installations-compat/package.json index 11f1838f66c..cb5f6f730a6 100644 --- a/packages/installations-compat/package.json +++ b/packages/installations-compat/package.json @@ -44,7 +44,7 @@ "url": "https://github.com/firebase/firebase-js-sdk/issues" }, "devDependencies": { - "@firebase/app-compat": "0.4.0", + "@firebase/app-compat": "0.4.1", "rollup": "2.79.2", "@rollup/plugin-commonjs": "21.1.0", "@rollup/plugin-json": "6.1.0", diff --git a/packages/installations/package.json b/packages/installations/package.json index be4d1b4a79f..a1d89e48321 100644 --- a/packages/installations/package.json +++ b/packages/installations/package.json @@ -49,7 +49,7 @@ "url": "https://github.com/firebase/firebase-js-sdk/issues" }, "devDependencies": { - "@firebase/app": "0.13.0", + "@firebase/app": "0.13.1", "rollup": "2.79.2", "@rollup/plugin-commonjs": "21.1.0", "@rollup/plugin-json": "6.1.0", diff --git a/packages/messaging-compat/package.json b/packages/messaging-compat/package.json index fd145f06bf7..c536cbef067 100644 --- a/packages/messaging-compat/package.json +++ b/packages/messaging-compat/package.json @@ -44,7 +44,7 @@ "tslib": "^2.1.0" }, "devDependencies": { - "@firebase/app-compat": "0.4.0", + "@firebase/app-compat": "0.4.1", "@rollup/plugin-json": "6.1.0", "rollup-plugin-typescript2": "0.36.0", "ts-essentials": "9.4.2", diff --git a/packages/messaging/package.json b/packages/messaging/package.json index 9d8cfc71926..4419ad3acf4 100644 --- a/packages/messaging/package.json +++ b/packages/messaging/package.json @@ -60,7 +60,7 @@ "tslib": "^2.1.0" }, "devDependencies": { - "@firebase/app": "0.13.0", + "@firebase/app": "0.13.1", "rollup": "2.79.2", "rollup-plugin-typescript2": "0.36.0", "@rollup/plugin-json": "6.1.0", diff --git a/packages/performance-compat/package.json b/packages/performance-compat/package.json index 0ec3cc56e66..0e84088a37d 100644 --- a/packages/performance-compat/package.json +++ b/packages/performance-compat/package.json @@ -51,7 +51,7 @@ "rollup-plugin-replace": "2.2.0", "rollup-plugin-typescript2": "0.36.0", "typescript": "5.5.4", - "@firebase/app-compat": "0.4.0" + "@firebase/app-compat": "0.4.1" }, "repository": { "directory": "packages/performance-compat", diff --git a/packages/performance/package.json b/packages/performance/package.json index b3495c8a566..27ff0073509 100644 --- a/packages/performance/package.json +++ b/packages/performance/package.json @@ -47,7 +47,7 @@ }, "license": "Apache-2.0", "devDependencies": { - "@firebase/app": "0.13.0", + "@firebase/app": "0.13.1", "rollup": "2.79.2", "@rollup/plugin-json": "6.1.0", "rollup-plugin-typescript2": "0.36.0", diff --git a/packages/remote-config-compat/package.json b/packages/remote-config-compat/package.json index 84c66d579bc..507bce652f3 100644 --- a/packages/remote-config-compat/package.json +++ b/packages/remote-config-compat/package.json @@ -50,7 +50,7 @@ "rollup-plugin-replace": "2.2.0", "rollup-plugin-typescript2": "0.36.0", "typescript": "5.5.4", - "@firebase/app-compat": "0.4.0" + "@firebase/app-compat": "0.4.1" }, "repository": { "directory": "packages/remote-config-compat", diff --git a/packages/remote-config/package.json b/packages/remote-config/package.json index 09dd8b6531e..43648d267d4 100644 --- a/packages/remote-config/package.json +++ b/packages/remote-config/package.json @@ -48,8 +48,9 @@ }, "license": "Apache-2.0", "devDependencies": { - "@firebase/app": "0.13.0", + "@firebase/app": "0.13.1", "rollup": "2.79.2", + "rollup-plugin-dts": "5.3.1", "rollup-plugin-typescript2": "0.36.0", "typescript": "5.5.4" }, diff --git a/packages/remote-config/rollup.config.js b/packages/remote-config/rollup.config.js index 36622f4dae2..d8eb3abd315 100644 --- a/packages/remote-config/rollup.config.js +++ b/packages/remote-config/rollup.config.js @@ -19,6 +19,7 @@ import json from '@rollup/plugin-json'; // Enables package.json import in TypeSc import typescriptPlugin from 'rollup-plugin-typescript2'; import replace from 'rollup-plugin-replace'; import typescript from 'typescript'; +import dts from 'rollup-plugin-dts'; import { generateBuildTargetReplaceConfig } from '../../scripts/build/rollup_replace_build_target'; import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; import pkg from './package.json'; @@ -70,4 +71,17 @@ const cjsBuild = { ] }; -export default [esmBuild, cjsBuild]; +const google3TypingsBuild = { + input: 'dist/src/index.d.ts', + output: { + file: 'dist/src/global_index.d.ts', + format: 'es' + }, + plugins: [ + dts({ + respectExternal: true + }) + ] +}; + +export default [esmBuild, cjsBuild, google3TypingsBuild]; diff --git a/packages/storage-compat/CHANGELOG.md b/packages/storage-compat/CHANGELOG.md index 48117be7e87..7988847b87b 100644 --- a/packages/storage-compat/CHANGELOG.md +++ b/packages/storage-compat/CHANGELOG.md @@ -1,5 +1,12 @@ # @firebase/storage-compat +## 0.3.23 + +### Patch Changes + +- Updated dependencies [[`0f891d8`](https://github.com/firebase/firebase-js-sdk/commit/0f891d861bdf4e7bac8cd777f5fb32d0b7b9bf8e)]: + - @firebase/storage@0.13.13 + ## 0.3.22 ### Patch Changes diff --git a/packages/storage-compat/package.json b/packages/storage-compat/package.json index 724685153ce..c5a31d6c6f0 100644 --- a/packages/storage-compat/package.json +++ b/packages/storage-compat/package.json @@ -1,6 +1,6 @@ { "name": "@firebase/storage-compat", - "version": "0.3.22", + "version": "0.3.23", "description": "The Firebase Firestore compatibility package", "author": "Firebase (https://firebase.google.com/)", "main": "./dist/index.cjs.js", @@ -37,15 +37,15 @@ "@firebase/app-compat": "0.x" }, "dependencies": { - "@firebase/storage": "0.13.12", + "@firebase/storage": "0.13.13", "@firebase/storage-types": "0.8.3", "@firebase/util": "1.12.0", "@firebase/component": "0.6.17", "tslib": "^2.1.0" }, "devDependencies": { - "@firebase/app-compat": "0.4.0", - "@firebase/auth-compat": "0.5.26", + "@firebase/app-compat": "0.4.1", + "@firebase/auth-compat": "0.5.27", "rollup": "2.79.2", "@rollup/plugin-json": "6.1.0", "rollup-plugin-typescript2": "0.36.0", diff --git a/packages/storage/CHANGELOG.md b/packages/storage/CHANGELOG.md index cabce495546..af1ec2bd2f0 100644 --- a/packages/storage/CHANGELOG.md +++ b/packages/storage/CHANGELOG.md @@ -1,5 +1,11 @@ #Unreleased +## 0.13.13 + +### Patch Changes + +- [`0f891d8`](https://github.com/firebase/firebase-js-sdk/commit/0f891d861bdf4e7bac8cd777f5fb32d0b7b9bf8e) [#9059](https://github.com/firebase/firebase-js-sdk/pull/9059) - Fixed issue where Firebase Studio wasn't populating cookies for Storage users + ## 0.13.12 ### Patch Changes diff --git a/packages/storage/package.json b/packages/storage/package.json index f7d52a2e8e2..bb4a5004840 100644 --- a/packages/storage/package.json +++ b/packages/storage/package.json @@ -1,6 +1,6 @@ { "name": "@firebase/storage", - "version": "0.13.12", + "version": "0.13.13", "description": "", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.node.cjs.js", @@ -54,8 +54,8 @@ "@firebase/app": "0.x" }, "devDependencies": { - "@firebase/app": "0.13.0", - "@firebase/auth": "1.10.6", + "@firebase/app": "0.13.1", + "@firebase/auth": "1.10.7", "rollup": "2.79.2", "@rollup/plugin-alias": "5.1.1", "@rollup/plugin-json": "6.1.0", diff --git a/packages/storage/src/service.ts b/packages/storage/src/service.ts index 97d1407bb52..a4252c77870 100644 --- a/packages/storage/src/service.ts +++ b/packages/storage/src/service.ts @@ -150,7 +150,7 @@ export function connectStorageEmulator( const useSsl = isCloudWorkstation(host); // Workaround to get cookies in Firebase Studio if (useSsl) { - void pingServer(`https://${storage.host}`); + void pingServer(`https://${storage.host}/b`); updateEmulatorBanner('Storage', true); } storage._isUsingEmulator = true; diff --git a/packages/storage/test/browser/connection.test.ts b/packages/storage/test/browser/connection.test.ts index 2a0320d0c02..4cb4d4cb919 100644 --- a/packages/storage/test/browser/connection.test.ts +++ b/packages/storage/test/browser/connection.test.ts @@ -35,7 +35,7 @@ describe('Connections', () => { const fakeXHR = useFakeXMLHttpRequest(); const connection = new XhrBytesConnection(); const sendPromise = connection.send( - 'https://abc.cloudworkstations.dev', + 'https://abc.cloudworkstations.dev/test', 'GET', true ); diff --git a/packages/template/package.json b/packages/template/package.json index 6d178ded575..9274862e9d1 100644 --- a/packages/template/package.json +++ b/packages/template/package.json @@ -48,7 +48,7 @@ }, "license": "Apache-2.0", "devDependencies": { - "@firebase/app": "0.13.0", + "@firebase/app": "0.13.1", "rollup": "2.79.2", "rollup-plugin-typescript2": "0.36.0", "typescript": "5.5.4" diff --git a/packages/util/src/url.ts b/packages/util/src/url.ts index e41d26594c2..6de92584979 100644 --- a/packages/util/src/url.ts +++ b/packages/util/src/url.ts @@ -19,8 +19,20 @@ * Checks whether host is a cloud workstation or not. * @public */ -export function isCloudWorkstation(host: string): boolean { - return host.endsWith('.cloudworkstations.dev'); +export function isCloudWorkstation(url: string): boolean { + // `isCloudWorkstation` is called without protocol in certain connect*Emulator functions + // In HTTP request builders, it's called with the protocol. + // If called with protocol prefix, it's a valid URL, so we extract the hostname + // If called without, we assume the string is the hostname. + try { + const host = + url.startsWith('http://') || url.startsWith('https://') + ? new URL(url).hostname + : url; + return host.endsWith('.cloudworkstations.dev'); + } catch { + return false; + } } /** diff --git a/packages/util/test/errors.test.ts b/packages/util/test/errors.test.ts index 4980b101ee1..6cb6273d326 100644 --- a/packages/util/test/errors.test.ts +++ b/packages/util/test/errors.test.ts @@ -89,8 +89,8 @@ describe('FirebaseError', () => { throw e; } catch (error) { assert.isDefined((error as Error).stack); - // Multi-line match trick - .* does not match \n - assert.match((error as Error).stack!, /FirebaseError[\s\S]/); + // Firefox no longer puts the error class name in the stack + // as of 139.0 so we don't have a string to match on. } }); diff --git a/repo-scripts/size-analysis/package.json b/repo-scripts/size-analysis/package.json index 184020a8acc..5084ee78d04 100644 --- a/repo-scripts/size-analysis/package.json +++ b/repo-scripts/size-analysis/package.json @@ -20,7 +20,7 @@ }, "license": "Apache-2.0", "devDependencies": { - "@firebase/app": "0.13.0", + "@firebase/app": "0.13.1", "@firebase/logger": "0.4.4", "@firebase/util": "1.12.0", "@rollup/plugin-commonjs": "21.1.0", diff --git a/scripts/run_tests_in_ci.js b/scripts/run_tests_in_ci.js index 0cf6a7f5d3c..7252b6acc3c 100644 --- a/scripts/run_tests_in_ci.js +++ b/scripts/run_tests_in_ci.js @@ -27,7 +27,9 @@ const crossBrowserPackages = { 'packages/auth': 'test:browser:unit', 'packages/auth-compat': 'test:browser:unit', 'packages/firestore': 'test:browser:unit', - 'packages/firestore-compat': 'test:browser' + 'packages/firestore-compat': 'test:browser', + 'packages/storage': 'test:browser:unit', + 'packages/storage-compat': 'test:browser:unit' }; function writeLogs(status, name, logText) { @@ -59,17 +61,27 @@ const argv = yargs.options({ const myPath = argv.d; let scriptName = argv.s; const dir = path.resolve(myPath); - const { name } = require(`${dir}/package.json`); + const { name, scripts } = require(`${dir}/package.json`); let testProcessOutput = ''; try { if (process.env?.BROWSERS) { + if (scripts['test:browser']) { + scriptName = 'test:browser'; + } for (const package in crossBrowserPackages) { if (dir.endsWith(package)) { scriptName = crossBrowserPackages[package]; } } } + + console.log( + `[${name}][${ + process.env.BROWSERS ?? 'chrome/node' + }]: Running script ${scriptName}` + ); + const testProcess = spawn('yarn', ['--cwd', dir, scriptName]); testProcess.childProcess.stdout.on('data', data => { diff --git a/scripts/update_vertexai_responses.sh b/scripts/update_vertexai_responses.sh index 680a71ff776..f6557ab0c0a 100755 --- a/scripts/update_vertexai_responses.sh +++ b/scripts/update_vertexai_responses.sh @@ -17,7 +17,7 @@ # This script replaces mock response files for Vertex AI unit tests with a fresh # clone of the shared repository of Vertex AI test data. -RESPONSES_VERSION='v11.*' # The major version of mock responses to use +RESPONSES_VERSION='v14.*' # The major version of mock responses to use REPO_NAME="vertexai-sdk-test-data" REPO_LINK="https://github.com/FirebaseExtended/$REPO_NAME.git" diff --git a/yarn.lock b/yarn.lock index c531d0c3c9c..8e108902d5c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -268,11 +268,11 @@ "@babel/types" "^7.26.7" "@babel/parser@^7.20.15": - version "7.27.3" - resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.27.3.tgz#1b7533f0d908ad2ac545c4d05cbe2fb6dc8cfaaf" - integrity sha512-xyYxRj6+tLNDTWi0KCBcZ9V7yg3/lwL9DWh9Uwh/RIVlIfFidggcgxKX3GCXwCiswwcGRawBKbEg2LG/Y8eJhw== + version "7.27.7" + resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.27.7.tgz#1687f5294b45039c159730e3b9c1f1b242e425e9" + integrity sha512-qnzXzDXdr/po3bOTbTIQZ7+TxNKxpkN5IifVLXS+r7qwynkZfPyjZfE7hCXbo7IoO9TNcSyibgONsf2HauUd3Q== dependencies: - "@babel/types" "^7.27.3" + "@babel/types" "^7.27.7" "@babel/parser@^7.26.8": version "7.26.8" @@ -1030,10 +1030,10 @@ "@babel/helper-string-parser" "^7.25.9" "@babel/helper-validator-identifier" "^7.25.9" -"@babel/types@^7.27.3": - version "7.27.3" - resolved "https://registry.npmjs.org/@babel/types/-/types-7.27.3.tgz#c0257bedf33aad6aad1f406d35c44758321eb3ec" - integrity sha512-Y1GkI4ktrtvmawoSq+4FCVHNryea6uR+qUQy0AGxLSsjCX0nVmkYQMBLHDkXZuo5hGx7eYdnIaslsdBFm7zbUw== +"@babel/types@^7.27.7": + version "7.27.7" + resolved "https://registry.npmjs.org/@babel/types/-/types-7.27.7.tgz#40eabd562049b2ee1a205fa589e629f945dce20f" + integrity sha512-8OLQgDScAOHXnAz2cV+RfzzNMipuLVBz2biuAJFMV9bfkNf393je3VM8CLkjQodW5+iWsSJdSgSWT6rsZoXHPw== dependencies: "@babel/helper-string-parser" "^7.27.1" "@babel/helper-validator-identifier" "^7.27.1"