16
16
*/
17
17
18
18
import * as legacy from '@firebase/firestore-types' ;
19
- import * as exp from '../index' ;
20
19
21
20
import { FieldPath as FieldPathExp , Bytes as BytesExp } from '../../exp/index' ;
22
- import {
23
- isPlainObject ,
24
- validateSetOptions
25
- } from '../../src/util/input_validation' ;
26
21
import { Compat } from '../../src/compat/compat' ;
27
- import {
28
- Firestore ,
29
- DocumentReference ,
30
- DocumentSnapshot
31
- } from '../../src/api/database' ;
32
22
33
23
export { GeoPoint , Timestamp } from '../index' ;
34
24
@@ -38,72 +28,6 @@ export { GeoPoint, Timestamp } from '../index';
38
28
// of the experimental SDK. This shim is used to run integration tests against
39
29
// both SDK versions.
40
30
41
- export class Transaction
42
- extends Compat < exp . Transaction >
43
- implements legacy . Transaction {
44
- constructor (
45
- private readonly _firestore : Firestore ,
46
- delegate : exp . Transaction
47
- ) {
48
- super ( delegate ) ;
49
- }
50
-
51
- get < T > ( documentRef : DocumentReference < T > ) : Promise < DocumentSnapshot < T > > {
52
- return this . _delegate
53
- . get ( documentRef . _delegate )
54
- . then ( result => new DocumentSnapshot ( this . _firestore , result ) ) ;
55
- }
56
-
57
- set < T > (
58
- documentRef : DocumentReference < T > ,
59
- data : T ,
60
- options ?: legacy . SetOptions
61
- ) : Transaction {
62
- if ( options ) {
63
- validateSetOptions ( 'Transaction.set' , options ) ;
64
- this . _delegate . set ( documentRef . _delegate , unwrap ( data ) , options ) ;
65
- } else {
66
- this . _delegate . set ( documentRef . _delegate , unwrap ( data ) ) ;
67
- }
68
- return this ;
69
- }
70
-
71
- update (
72
- documentRef : DocumentReference < any > ,
73
- data : legacy . UpdateData
74
- ) : Transaction ;
75
- update (
76
- documentRef : DocumentReference < any > ,
77
- field : string | FieldPath ,
78
- value : any ,
79
- ...moreFieldsAndValues : any [ ]
80
- ) : Transaction ;
81
- update (
82
- documentRef : DocumentReference < any > ,
83
- dataOrField : any ,
84
- value ?: any ,
85
- ...moreFieldsAndValues : any [ ]
86
- ) : Transaction {
87
- if ( arguments . length === 2 ) {
88
- this . _delegate . update ( documentRef . _delegate , unwrap ( dataOrField ) ) ;
89
- } else {
90
- this . _delegate . update (
91
- documentRef . _delegate ,
92
- unwrap ( dataOrField ) ,
93
- unwrap ( value ) ,
94
- ...unwrap ( moreFieldsAndValues )
95
- ) ;
96
- }
97
-
98
- return this ;
99
- }
100
-
101
- delete ( documentRef : DocumentReference < any > ) : Transaction {
102
- this . _delegate . delete ( documentRef . _delegate ) ;
103
- return this ;
104
- }
105
- }
106
-
107
31
export class FieldPath
108
32
extends Compat < FieldPathExp >
109
33
implements legacy . FieldPath {
@@ -141,27 +65,3 @@ export class Blob extends Compat<BytesExp> implements legacy.Blob {
141
65
return this . _delegate . isEqual ( other . _delegate ) ;
142
66
}
143
67
}
144
-
145
- /**
146
- * Takes user data that uses API types from this shim and replaces them
147
- * with the the firestore-exp API types.
148
- */
149
- function unwrap ( value : any ) : any {
150
- if ( Array . isArray ( value ) ) {
151
- return value . map ( v => unwrap ( v ) ) ;
152
- } else if ( value instanceof Compat ) {
153
- return value . _delegate ;
154
- } else if ( value instanceof FieldPath ) {
155
- return value . _delegate ;
156
- } else if ( isPlainObject ( value ) ) {
157
- const obj : any = { } ;
158
- for ( const key in value ) {
159
- if ( value . hasOwnProperty ( key ) ) {
160
- obj [ key ] = unwrap ( value [ key ] ) ;
161
- }
162
- }
163
- return obj ;
164
- } else {
165
- return value ;
166
- }
167
- }
0 commit comments