@firebase/firestore-compat 0.1.3-2021822203916 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,64 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- import {
19
- FieldPath as ExpFieldPath,
20
- _FieldPath as InternalFieldPath
21
- } from '@firebase/firestore';
22
- import { FieldPath as PublicFieldPath } from '@firebase/firestore-types';
23
- import { Compat, getModularInstance } from '@firebase/util';
24
-
25
- // The objects that are a part of this API are exposed to third-parties as
26
- // compiled javascript so we want to flag our private members with a leading
27
- // underscore to discourage their use.
28
-
29
- /**
30
- * A `FieldPath` refers to a field in a document. The path may consist of a
31
- * single field name (referring to a top-level field in the document), or a list
32
- * of field names (referring to a nested field in the document).
33
- */
34
- export class FieldPath implements PublicFieldPath, Compat<ExpFieldPath> {
35
- readonly _delegate: ExpFieldPath;
36
- /**
37
- * Creates a FieldPath from the provided field names. If more than one field
38
- * name is provided, the path will point to a nested field in a document.
39
- *
40
- * @param fieldNames - A list of field names.
41
- */
42
- constructor(...fieldNames: string[]) {
43
- this._delegate = new ExpFieldPath(...fieldNames);
44
- }
45
-
46
- static documentId(): FieldPath {
47
- /**
48
- * Internal Note: The backend doesn't technically support querying by
49
- * document ID. Instead it queries by the entire document name (full path
50
- * included), but in the cases we currently support documentId(), the net
51
- * effect is the same.
52
- */
53
- return new FieldPath(InternalFieldPath.keyField().canonicalString());
54
- }
55
-
56
- isEqual(other: PublicFieldPath): boolean {
57
- other = getModularInstance(other);
58
-
59
- if (!(other instanceof ExpFieldPath)) {
60
- return false;
61
- }
62
- return this._delegate._internalPath.isEqual(other._internalPath);
63
- }
64
- }
@@ -1,65 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- import {
19
- arrayRemove,
20
- arrayUnion,
21
- deleteField,
22
- FieldValue as FieldValue1,
23
- increment,
24
- serverTimestamp
25
- } from '@firebase/firestore';
26
- import { FieldValue as PublicFieldValue } from '@firebase/firestore-types';
27
- import { Compat } from '@firebase/util';
28
-
29
- export class FieldValue implements PublicFieldValue, Compat<FieldValue1> {
30
- static serverTimestamp(): FieldValue {
31
- const delegate = serverTimestamp();
32
- delegate._methodName = 'FieldValue.serverTimestamp';
33
- return new FieldValue(delegate);
34
- }
35
-
36
- static delete(): FieldValue {
37
- const delegate = deleteField();
38
- delegate._methodName = 'FieldValue.delete';
39
- return new FieldValue(delegate);
40
- }
41
-
42
- static arrayUnion(...elements: unknown[]): FieldValue {
43
- const delegate = arrayUnion(...elements);
44
- delegate._methodName = 'FieldValue.arrayUnion';
45
- return new FieldValue(delegate);
46
- }
47
-
48
- static arrayRemove(...elements: unknown[]): FieldValue {
49
- const delegate = arrayRemove(...elements);
50
- delegate._methodName = 'FieldValue.arrayRemove';
51
- return new FieldValue(delegate);
52
- }
53
-
54
- static increment(n: number): FieldValue {
55
- const delegate = increment(n);
56
- delegate._methodName = 'FieldValue.increment';
57
- return new FieldValue(delegate);
58
- }
59
-
60
- constructor(readonly _delegate: FieldValue1) {}
61
-
62
- isEqual(other: FieldValue): boolean {
63
- return this._delegate.isEqual(other._delegate);
64
- }
65
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- export { GeoPoint } from '@firebase/firestore';
@@ -1,54 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- import { FirestoreError } from '@firebase/firestore';
19
-
20
- /**
21
- * Observer/Subscribe interfaces.
22
- */
23
- export type NextFn<T> = (value: T) => void;
24
- export type ErrorFn = (error: FirestoreError) => void;
25
- export type CompleteFn = () => void;
26
-
27
- // Allow for any of the Observer methods to be undefined.
28
- export interface PartialObserver<T> {
29
- next?: NextFn<T>;
30
- error?: ErrorFn;
31
- complete?: CompleteFn;
32
- }
33
-
34
- export function isPartialObserver<T>(obj: unknown): obj is PartialObserver<T> {
35
- return implementsAnyMethods(obj, ['next', 'error', 'complete']);
36
- }
37
-
38
- /**
39
- * Returns true if obj is an object and contains at least one of the specified
40
- * methods.
41
- */
42
- function implementsAnyMethods(obj: unknown, methods: string[]): boolean {
43
- if (typeof obj !== 'object' || obj === null) {
44
- return false;
45
- }
46
-
47
- const object = obj as Record<string, unknown>;
48
- for (const method of methods) {
49
- if (method in object && typeof object[method] === 'function') {
50
- return true;
51
- }
52
- }
53
- return false;
54
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- export { Timestamp } from '@firebase/firestore';
package/src/config.ts DELETED
@@ -1,90 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2021 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- // eslint-disable-next-line import/no-extraneous-dependencies
19
- import { FirebaseApp } from '@firebase/app-compat';
20
- import { FirebaseNamespace } from '@firebase/app-types';
21
- import { _FirebaseNamespace } from '@firebase/app-types/private';
22
- import { Component, ComponentType } from '@firebase/component';
23
- import {
24
- Firestore as ModularFirestore,
25
- CACHE_SIZE_UNLIMITED,
26
- GeoPoint,
27
- Timestamp
28
- } from '@firebase/firestore';
29
-
30
- import { Blob } from './api/blob';
31
- import {
32
- Firestore,
33
- Transaction,
34
- CollectionReference,
35
- DocumentReference,
36
- DocumentSnapshot,
37
- Query,
38
- QueryDocumentSnapshot,
39
- QuerySnapshot,
40
- WriteBatch,
41
- setLogLevel
42
- } from './api/database';
43
- import { FieldPath } from './api/field_path';
44
- import { FieldValue } from './api/field_value';
45
-
46
- const firestoreNamespace = {
47
- Firestore,
48
- GeoPoint,
49
- Timestamp,
50
- Blob,
51
- Transaction,
52
- WriteBatch,
53
- DocumentReference,
54
- DocumentSnapshot,
55
- Query,
56
- QueryDocumentSnapshot,
57
- QuerySnapshot,
58
- CollectionReference,
59
- FieldPath,
60
- FieldValue,
61
- setLogLevel,
62
- CACHE_SIZE_UNLIMITED
63
- };
64
-
65
- /**
66
- * Configures Firestore as part of the Firebase SDK by calling registerComponent.
67
- *
68
- * @param firebase - The FirebaseNamespace to register Firestore with
69
- * @param firestoreFactory - A factory function that returns a new Firestore
70
- * instance.
71
- */
72
- export function configureForFirebase(
73
- firebase: FirebaseNamespace,
74
- firestoreFactory: (
75
- app: FirebaseApp,
76
- firestoreExp: ModularFirestore
77
- ) => Firestore
78
- ): void {
79
- (firebase as _FirebaseNamespace).INTERNAL.registerComponent(
80
- new Component(
81
- 'firestore-compat',
82
- container => {
83
- const app = container.getProvider('app-compat').getImmediate()!;
84
- const firestoreExp = container.getProvider('firestore').getImmediate()!;
85
- return firestoreFactory(app, firestoreExp);
86
- },
87
- ComponentType.PUBLIC
88
- ).setServiceProps({ ...firestoreNamespace })
89
- );
90
- }
@@ -1,111 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2019 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
19
- import { Provider } from '@firebase/component';
20
- import {
21
- _DatabaseId,
22
- Firestore as FirestoreExp,
23
- FirestoreError,
24
- _EmptyCredentialsProvider
25
- } from '@firebase/firestore';
26
-
27
- import {
28
- Firestore as FirestoreCompat,
29
- PersistenceProvider
30
- } from './api/database';
31
-
32
- export {
33
- CollectionReference,
34
- DocumentReference,
35
- DocumentSnapshot,
36
- QuerySnapshot
37
- } from './api/database';
38
- export { Blob } from './api/blob';
39
- export { GeoPoint } from './api/geo_point';
40
- export { FieldPath } from './api/field_path';
41
- export { FieldValue } from './api/field_value';
42
- export { Timestamp } from './api/timestamp';
43
-
44
- export interface FirestoreDatabase {
45
- projectId: string;
46
- database?: string;
47
- }
48
-
49
- const MEMORY_ONLY_PERSISTENCE_ERROR_MESSAGE =
50
- 'You are using the memory-only build of Firestore. Persistence support is ' +
51
- 'only available via the @firebase/firestore bundle or the ' +
52
- 'firebase-firestore.js build.';
53
-
54
- /**
55
- * The persistence provider included with the memory-only SDK. This provider
56
- * errors for all attempts to access persistence.
57
- */
58
- export class MemoryPersistenceProvider implements PersistenceProvider {
59
- enableIndexedDbPersistence(
60
- firestore: FirestoreCompat,
61
- forceOwnership: boolean
62
- ): Promise<void> {
63
- throw new FirestoreError(
64
- 'failed-precondition',
65
- MEMORY_ONLY_PERSISTENCE_ERROR_MESSAGE
66
- );
67
- }
68
-
69
- enableMultiTabIndexedDbPersistence(firestore: Firestore): Promise<void> {
70
- throw new FirestoreError(
71
- 'failed-precondition',
72
- MEMORY_ONLY_PERSISTENCE_ERROR_MESSAGE
73
- );
74
- }
75
-
76
- clearIndexedDbPersistence(firestore: Firestore): Promise<void> {
77
- throw new FirestoreError(
78
- 'failed-precondition',
79
- MEMORY_ONLY_PERSISTENCE_ERROR_MESSAGE
80
- );
81
- }
82
- }
83
-
84
- /** Firestore class that exposes the constructor expected by the Console. */
85
- export class Firestore extends FirestoreCompat {
86
- constructor(
87
- firestoreDatabase: FirestoreDatabase,
88
- authProvider: Provider<FirebaseAuthInternalName>
89
- ) {
90
- super(
91
- databaseIdFromFirestoreDatabase(firestoreDatabase),
92
- new FirestoreExp(
93
- databaseIdFromFirestoreDatabase(firestoreDatabase),
94
- new _EmptyCredentialsProvider()
95
- ),
96
- new MemoryPersistenceProvider()
97
- );
98
- }
99
- }
100
-
101
- function databaseIdFromFirestoreDatabase(
102
- firestoreDatabase: FirestoreDatabase
103
- ): _DatabaseId {
104
- if (!firestoreDatabase.projectId) {
105
- throw new FirestoreError('invalid-argument', 'Must provide projectId');
106
- }
107
- return new _DatabaseId(
108
- firestoreDatabase.projectId,
109
- firestoreDatabase.database
110
- );
111
- }
package/src/index.node.ts DELETED
@@ -1,40 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- // eslint-disable-next-line import/no-extraneous-dependencies
19
- import firebase from '@firebase/app-compat';
20
- import { FirebaseNamespace } from '@firebase/app-types';
21
-
22
- import { name, version } from '../package.json';
23
-
24
- import { Firestore, IndexedDbPersistenceProvider } from './api/database';
25
- import { configureForFirebase } from './config';
26
-
27
- /**
28
- * Registers the main Firestore Node build with the components framework.
29
- * Persistence can be enabled via `firebase.firestore().enablePersistence()`.
30
- */
31
- export function registerFirestore(instance: FirebaseNamespace): void {
32
- configureForFirebase(
33
- instance,
34
- (app, firestoreExp) =>
35
- new Firestore(app, firestoreExp, new IndexedDbPersistenceProvider())
36
- );
37
- instance.registerVersion(name, version, 'node');
38
- }
39
-
40
- registerFirestore(firebase as unknown as FirebaseNamespace);
package/src/index.rn.ts DELETED
@@ -1,39 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2020 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- // eslint-disable-next-line import/no-extraneous-dependencies
19
- import firebase from '@firebase/app-compat';
20
- import { FirebaseNamespace } from '@firebase/app-types';
21
-
22
- import { name, version } from '../package.json';
23
-
24
- import { Firestore, IndexedDbPersistenceProvider } from './api/database';
25
- import { configureForFirebase } from './config';
26
- /**
27
- * Registers the main Firestore ReactNative build with the components framework.
28
- * Persistence can be enabled via `firebase.firestore().enablePersistence()`.
29
- */
30
- export function registerFirestore(instance: FirebaseNamespace): void {
31
- configureForFirebase(
32
- instance,
33
- (app, firestoreExp) =>
34
- new Firestore(app, firestoreExp, new IndexedDbPersistenceProvider())
35
- );
36
- instance.registerVersion(name, version, 'rn');
37
- }
38
-
39
- registerFirestore(firebase as unknown as FirebaseNamespace);
package/src/index.ts DELETED
@@ -1,69 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2020 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- // eslint-disable-next-line import/no-extraneous-dependencies
19
- import firebase from '@firebase/app-compat';
20
- import { FirebaseNamespace } from '@firebase/app-types';
21
- import * as types from '@firebase/firestore-types';
22
-
23
- import { name, version } from '../package.json';
24
-
25
- import { Firestore, IndexedDbPersistenceProvider } from './api/database';
26
- import { configureForFirebase } from './config';
27
-
28
- import './register-module';
29
-
30
- /**
31
- * Registers the main Firestore build with the components framework.
32
- * Persistence can be enabled via `firebase.firestore().enablePersistence()`.
33
- */
34
- export function registerFirestore(instance: FirebaseNamespace): void {
35
- configureForFirebase(
36
- instance,
37
- (app, firestoreExp) =>
38
- new Firestore(app, firestoreExp, new IndexedDbPersistenceProvider())
39
- );
40
- instance.registerVersion(name, version);
41
- }
42
-
43
- registerFirestore(firebase as unknown as FirebaseNamespace);
44
-
45
- declare module '@firebase/app-compat' {
46
- interface FirebaseNamespace {
47
- firestore: {
48
- (app?: FirebaseApp): types.FirebaseFirestore;
49
- Blob: typeof types.Blob;
50
- CollectionReference: typeof types.CollectionReference;
51
- DocumentReference: typeof types.DocumentReference;
52
- DocumentSnapshot: typeof types.DocumentSnapshot;
53
- FieldPath: typeof types.FieldPath;
54
- FieldValue: typeof types.FieldValue;
55
- Firestore: typeof types.FirebaseFirestore;
56
- GeoPoint: typeof types.GeoPoint;
57
- Query: typeof types.Query;
58
- QueryDocumentSnapshot: typeof types.QueryDocumentSnapshot;
59
- QuerySnapshot: typeof types.QuerySnapshot;
60
- Timestamp: typeof types.Timestamp;
61
- Transaction: typeof types.Transaction;
62
- WriteBatch: typeof types.WriteBatch;
63
- setLogLevel: typeof types.setLogLevel;
64
- };
65
- }
66
- interface FirebaseApp {
67
- firestore?(): types.FirebaseFirestore;
68
- }
69
- }
@@ -1,44 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2020 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- import * as types from '@firebase/firestore-types';
19
-
20
- declare module '@firebase/app-compat' {
21
- interface FirebaseNamespace {
22
- firestore: {
23
- (app?: FirebaseApp): types.FirebaseFirestore;
24
- Blob: typeof types.Blob;
25
- CollectionReference: typeof types.CollectionReference;
26
- DocumentReference: typeof types.DocumentReference;
27
- DocumentSnapshot: typeof types.DocumentSnapshot;
28
- FieldPath: typeof types.FieldPath;
29
- FieldValue: typeof types.FieldValue;
30
- Firestore: typeof types.FirebaseFirestore;
31
- GeoPoint: typeof types.GeoPoint;
32
- Query: typeof types.Query;
33
- QueryDocumentSnapshot: typeof types.QueryDocumentSnapshot;
34
- QuerySnapshot: typeof types.QuerySnapshot;
35
- Timestamp: typeof types.Timestamp;
36
- Transaction: typeof types.Transaction;
37
- WriteBatch: typeof types.WriteBatch;
38
- setLogLevel: typeof types.setLogLevel;
39
- };
40
- }
41
- interface FirebaseApp {
42
- firestore?(): types.FirebaseFirestore;
43
- }
44
- }
@@ -1,40 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2021 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- import { FirestoreError } from '@firebase/firestore';
19
- import { SetOptions } from '@firebase/firestore-types';
20
-
21
- export function validateSetOptions(
22
- methodName: string,
23
- options: SetOptions | undefined
24
- ): SetOptions {
25
- if (options === undefined) {
26
- return {
27
- merge: false
28
- };
29
- }
30
-
31
- if (options.mergeFields !== undefined && options.merge !== undefined) {
32
- throw new FirestoreError(
33
- 'invalid-argument',
34
- `Invalid options passed to function ${methodName}(): You cannot ` +
35
- 'specify both "merge" and "mergeFields".'
36
- );
37
- }
38
-
39
- return options;
40
- }