aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Source/Public
diff options
context:
space:
mode:
authorGravatar Gil <mcg@google.com>2017-10-03 08:55:22 -0700
committerGravatar GitHub <noreply@github.com>2017-10-03 08:55:22 -0700
commitbde743ed25166a0b320ae157bfb1d68064f531c9 (patch)
tree4dd7525d9df32fa5dbdb721d4b0d4f9b87f5e884 /Firestore/Source/Public
parentbf550507ffa8beee149383a5bf1e2363bccefbb4 (diff)
Release 4.3.0 (#327)
Initial release of Firestore at 0.8.0 Bump FirebaseCommunity to 0.1.3
Diffstat (limited to 'Firestore/Source/Public')
-rw-r--r--Firestore/Source/Public/FIRCollectionReference.h99
-rw-r--r--Firestore/Source/Public/FIRDocumentChange.h70
-rw-r--r--Firestore/Source/Public/FIRDocumentReference.h219
-rw-r--r--Firestore/Source/Public/FIRDocumentSnapshot.h68
-rw-r--r--Firestore/Source/Public/FIRFieldPath.h50
-rw-r--r--Firestore/Source/Public/FIRFieldValue.h45
-rw-r--r--Firestore/Source/Public/FIRFirestore.h145
-rw-r--r--Firestore/Source/Public/FIRFirestoreErrors.h105
-rw-r--r--Firestore/Source/Public/FIRFirestoreSettings.h51
-rw-r--r--Firestore/Source/Public/FIRFirestoreSwiftNameSupport.h29
-rw-r--r--Firestore/Source/Public/FIRGeoPoint.h49
-rw-r--r--Firestore/Source/Public/FIRListenerRegistration.h32
-rw-r--r--Firestore/Source/Public/FIRQuery.h414
-rw-r--r--Firestore/Source/Public/FIRQuerySnapshot.h65
-rw-r--r--Firestore/Source/Public/FIRSetOptions.h46
-rw-r--r--Firestore/Source/Public/FIRSnapshotMetadata.h44
-rw-r--r--Firestore/Source/Public/FIRTransaction.h106
-rw-r--r--Firestore/Source/Public/FIRWriteBatch.h107
18 files changed, 1744 insertions, 0 deletions
diff --git a/Firestore/Source/Public/FIRCollectionReference.h b/Firestore/Source/Public/FIRCollectionReference.h
new file mode 100644
index 0000000..11cb969
--- /dev/null
+++ b/Firestore/Source/Public/FIRCollectionReference.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2017 Google
+ *
+ * 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 <Foundation/Foundation.h>
+
+#import "FIRFirestoreSwiftNameSupport.h"
+#import "FIRQuery.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@class FIRDocumentReference;
+
+/**
+ * A `FIRCollectionReference` object can be used for adding documents, getting document references,
+ * and querying for documents (using the methods inherited from `FIRQuery`).
+ */
+FIR_SWIFT_NAME(CollectionReference)
+@interface FIRCollectionReference : FIRQuery
+
+/** */
+- (id)init __attribute__((unavailable("FIRCollectionReference cannot be created directly.")));
+
+/** ID of the referenced collection. */
+@property(nonatomic, strong, readonly) NSString *collectionID;
+
+/**
+ * For subcollections, `parent` returns the containing `FIRDocumentReference`. For root
+ * collections, nil is returned.
+ */
+@property(nonatomic, strong, nullable, readonly) FIRDocumentReference *parent;
+
+/**
+ * A string containing the slash-separated path to this this `FIRCollectionReference` (relative to
+ * the root of the database).
+ */
+@property(nonatomic, strong, readonly) NSString *path;
+
+/**
+ * Returns a FIRDocumentReference pointing to a new document with an auto-generated ID.
+ *
+ * @return A FIRDocumentReference pointing to a new document with an auto-generated ID.
+ */
+- (FIRDocumentReference *)documentWithAutoID FIR_SWIFT_NAME(document());
+
+/**
+ * Gets a `FIRDocumentReference` referring to the document at the specified path, relative to this
+ * collection's own path.
+ *
+ * @param documentPath The slash-separated relative path of the document for which to get a
+ * `FIRDocumentReference`.
+ *
+ * @return The `FIRDocumentReference` for the specified document path.
+ */
+- (FIRDocumentReference *)documentWithPath:(NSString *)documentPath FIR_SWIFT_NAME(document(_:));
+
+/**
+ * Add a new document to this collection with the specified data, assigning it a document ID
+ * automatically.
+ *
+ * @param data An `NSDictionary` containing the data for the new document.
+ *
+ * @return A `FIRDocumentReference` pointing to the newly created document.
+ */
+- (FIRDocumentReference *)addDocumentWithData:(NSDictionary<NSString *, id> *)data
+ FIR_SWIFT_NAME(addDocument(data:));
+
+/**
+ * Add a new document to this collection with the specified data, assigning it a document ID
+ * automatically.
+ *
+ * @param data An `NSDictionary` containing the data for the new document.
+ * @param completion A block to execute once the document has been successfully written.
+ *
+ * @return A `FIRDocumentReference` pointing to the newly created document.
+ */
+// clang-format off
+// clang-format breaks the FIR_SWIFT_NAME attribute
+- (FIRDocumentReference *)addDocumentWithData:(NSDictionary<NSString *, id> *)data
+ completion:
+ (nullable void (^)(NSError *_Nullable error))completion
+ FIR_SWIFT_NAME(addDocument(data:completion:));
+// clang-format on
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firestore/Source/Public/FIRDocumentChange.h b/Firestore/Source/Public/FIRDocumentChange.h
new file mode 100644
index 0000000..674e3b2
--- /dev/null
+++ b/Firestore/Source/Public/FIRDocumentChange.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2017 Google
+ *
+ * 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 <Foundation/Foundation.h>
+
+#import "FIRFirestoreSwiftNameSupport.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@class FIRDocumentSnapshot;
+
+/** An enumeration of document change types. */
+typedef NS_ENUM(NSInteger, FIRDocumentChangeType) {
+ /** Indicates a new document was added to the set of documents matching the query. */
+ FIRDocumentChangeTypeAdded,
+ /** Indicates a document within the query was modified. */
+ FIRDocumentChangeTypeModified,
+ /**
+ * Indicates a document within the query was removed (either deleted or no longer matches
+ * the query.
+ */
+ FIRDocumentChangeTypeRemoved
+} FIR_SWIFT_NAME(DocumentChangeType);
+
+/**
+ * A `FIRDocumentChange` represents a change to the documents matching a query. It contains the
+ * document affected and the type of change that occurred (added, modified, or removed).
+ */
+FIR_SWIFT_NAME(DocumentChange)
+@interface FIRDocumentChange : NSObject
+
+/** */
+- (id)init __attribute__((unavailable("FIRDocumentChange cannot be created directly.")));
+
+/** The type of change that occurred (added, modified, or removed). */
+@property(nonatomic, readonly) FIRDocumentChangeType type;
+
+/** The document affected by this change. */
+@property(nonatomic, strong, readonly) FIRDocumentSnapshot *document;
+
+/**
+ * The index of the changed document in the result set immediately prior to this FIRDocumentChange
+ * (i.e. supposing that all prior FIRDocumentChange objects have been applied). NSNotFound for
+ * FIRDocumentChangeTypeAdded events.
+ */
+@property(nonatomic, readonly) NSUInteger oldIndex;
+
+/**
+ * The index of the changed document in the result set immediately after this FIRDocumentChange
+ * (i.e. supposing that all prior FIRDocumentChange objects and the current FIRDocumentChange object
+ * have been applied). NSNotFound for FIRDocumentChangeTypeRemoved events.
+ */
+@property(nonatomic, readonly) NSUInteger newIndex;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firestore/Source/Public/FIRDocumentReference.h b/Firestore/Source/Public/FIRDocumentReference.h
new file mode 100644
index 0000000..03340c1
--- /dev/null
+++ b/Firestore/Source/Public/FIRDocumentReference.h
@@ -0,0 +1,219 @@
+/*
+ * Copyright 2017 Google
+ *
+ * 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 <Foundation/Foundation.h>
+
+#import "FIRFirestoreSwiftNameSupport.h"
+#import "FIRListenerRegistration.h"
+
+@class FIRFirestore;
+@class FIRCollectionReference;
+@class FIRDocumentSnapshot;
+@class FIRSetOptions;
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ * Options for use with `[FIRDocumentReference addSnapshotListener]` to control the behavior of the
+ * snapshot listener.
+ */
+FIR_SWIFT_NAME(DocumentListenOptions)
+@interface FIRDocumentListenOptions : NSObject
+
++ (instancetype)options NS_SWIFT_UNAVAILABLE("Use initializer");
+
+- (instancetype)init;
+
+@property(nonatomic, assign, readonly) BOOL includeMetadataChanges;
+
+/**
+ * Sets the includeMetadataChanges option which controls whether metadata-only changes (i.e. only
+ * `FIRDocumentSnapshot.metadata` changed) should trigger snapshot events. Default is NO.
+ *
+ * @param includeMetadataChanges Whether to raise events for metadata-only changes.
+ * @return The receiver is returned for optional method chaining.
+ */
+- (instancetype)includeMetadataChanges:(BOOL)includeMetadataChanges
+ FIR_SWIFT_NAME(includeMetadataChanges(_:));
+
+@end
+
+typedef void (^FIRDocumentSnapshotBlock)(FIRDocumentSnapshot *_Nullable snapshot,
+ NSError *_Nullable error);
+
+/**
+ * A `FIRDocumentReference` refers to a document location in a Firestore database and can be
+ * used to write, read, or listen to the location. The document at the referenced location
+ * may or may not exist. A `FIRDocumentReference` can also be used to create a
+ * `FIRCollectionReference` to a subcollection.
+ */
+FIR_SWIFT_NAME(DocumentReference)
+@interface FIRDocumentReference : NSObject
+
+/** */
+- (instancetype)init
+ __attribute__((unavailable("FIRDocumentReference cannot be created directly.")));
+
+/** The ID of the document referred to. */
+@property(nonatomic, strong, readonly) NSString *documentID;
+
+/** A reference to the collection to which this `DocumentReference` belongs. */
+@property(nonatomic, strong, readonly) FIRCollectionReference *parent;
+
+/** The `FIRFirestore` for the Firestore database (useful for performing transactions, etc.). */
+@property(nonatomic, strong, readonly) FIRFirestore *firestore;
+
+/**
+ * A string representing the path of the referenced document (relative to the root of the
+ * database).
+ */
+@property(nonatomic, strong, readonly) NSString *path;
+
+/**
+ * Gets a `FIRCollectionReference` referring to the collection at the specified
+ * path, relative to this document.
+ *
+ * @param collectionPath The slash-separated relative path of the collection for which to get a
+ * `FIRCollectionReference`.
+ *
+ * @return The `FIRCollectionReference` at the specified _collectionPath_.
+ */
+- (FIRCollectionReference *)collectionWithPath:(NSString *)collectionPath
+ FIR_SWIFT_NAME(collection(_:));
+
+#pragma mark - Writing Data
+
+/**
+ * Writes to the document referred to by `FIRDocumentReference`. If the document doesn't yet exist,
+ * this method creates it and then sets the data. If the document exists, this method overwrites
+ * the document data with the new values.
+ *
+ * @param documentData An `NSDictionary` that contains the fields and data to write to the
+ * document.
+ */
+- (void)setData:(NSDictionary<NSString *, id> *)documentData;
+
+/**
+ * Writes to the document referred to by this DocumentReference. If the document does not yet
+ * exist, it will be created. If you pass `FIRSetOptions`, the provided data will be merged into
+ * an existing document.
+ *
+ * @param documentData An `NSDictionary` that contains the fields and data to write to the
+ * document.
+ * @param options A `FIRSetOptions` used to configure the set behavior.
+ */
+- (void)setData:(NSDictionary<NSString *, id> *)documentData options:(FIRSetOptions *)options;
+
+/**
+ * Overwrites the document referred to by this `FIRDocumentReference`. If no document exists, it
+ * is created. If a document already exists, it is overwritten.
+ *
+ * @param documentData An `NSDictionary` containing the fields that make up the document
+ * to be written.
+ * @param completion A block to execute once the document has been successfully written.
+ */
+- (void)setData:(NSDictionary<NSString *, id> *)documentData
+ completion:(nullable void (^)(NSError *_Nullable error))completion;
+
+/**
+ * Writes to the document referred to by this DocumentReference. If the document does not yet
+ * exist, it will be created. If you pass `FIRSetOptions`, the provided data will be merged into
+ * an existing document.
+ *
+ * @param documentData An `NSDictionary` containing the fields that make up the document
+ * to be written.
+ * @param options A `FIRSetOptions` used to configure the set behavior.
+ * @param completion A block to execute once the document has been successfully written.
+ */
+- (void)setData:(NSDictionary<NSString *, id> *)documentData
+ options:(FIRSetOptions *)options
+ completion:(nullable void (^)(NSError *_Nullable error))completion;
+
+/**
+ * Updates fields in the document referred to by this `FIRDocumentReference`.
+ * If the document does not exist, the update fails (specify a completion block to be notified).
+ *
+ * @param fields An `NSDictionary` containing the fields (expressed as an `NSString` or
+ * `FIRFieldPath`) and values with which to update the document.
+ */
+- (void)updateData:(NSDictionary<id, id> *)fields;
+
+/**
+ * Updates fields in the document referred to by this `FIRDocumentReference`. If the document
+ * does not exist, the update fails and the specified completion block receives an error.
+ *
+ * @param fields An `NSDictionary` containing the fields (expressed as an `NSString` or
+ * `FIRFieldPath`) and values with which to update the document.
+ * @param completion A block to execute when the update is complete. If the update is successful the
+ * error parameter will be nil, otherwise it will give an indication of how the update failed.
+ */
+- (void)updateData:(NSDictionary<id, id> *)fields
+ completion:(nullable void (^)(NSError *_Nullable error))completion;
+
+// NOTE: this is named 'deleteDocument' because 'delete' is a keyword in Objective-C++.
+/** Deletes the document referred to by this `FIRDocumentReference`. */
+// clang-format off
+- (void)deleteDocument FIR_SWIFT_NAME(delete());
+// clang-format on
+
+/**
+ * Deletes the document referred to by this `FIRDocumentReference`.
+ *
+ * @param completion A block to execute once the document has been successfully deleted.
+ */
+// clang-format off
+- (void)deleteDocumentWithCompletion:(nullable void (^)(NSError *_Nullable error))completion
+ FIR_SWIFT_NAME(delete(completion:));
+// clang-format on
+
+#pragma mark - Retrieving Data
+
+/**
+ * Reads the document referenced by this `FIRDocumentReference`.
+ *
+ * @param completion a block to execute once the document has been successfully read.
+ */
+- (void)getDocumentWithCompletion:(FIRDocumentSnapshotBlock)completion
+ FIR_SWIFT_NAME(getDocument(completion:));
+
+/**
+ * Attaches a listener for DocumentSnapshot events.
+ *
+ * @param listener The listener to attach.
+ *
+ * @return A FIRListenerRegistration that can be used to remove this listener.
+ */
+- (id<FIRListenerRegistration>)addSnapshotListener:(FIRDocumentSnapshotBlock)listener
+ FIR_SWIFT_NAME(addSnapshotListener(_:));
+
+/**
+ * Attaches a listener for DocumentSnapshot events.
+ *
+ * @param options Options controlling the listener behavior.
+ * @param listener The listener to attach.
+ *
+ * @return A FIRListenerRegistration that can be used to remove this listener.
+ */
+// clang-format off
+- (id<FIRListenerRegistration>)addSnapshotListenerWithOptions:
+ (nullable FIRDocumentListenOptions *)options
+ listener:(FIRDocumentSnapshotBlock)listener
+ FIR_SWIFT_NAME(addSnapshotListener(options:listener:));
+// clang-format on
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firestore/Source/Public/FIRDocumentSnapshot.h b/Firestore/Source/Public/FIRDocumentSnapshot.h
new file mode 100644
index 0000000..e923e3e
--- /dev/null
+++ b/Firestore/Source/Public/FIRDocumentSnapshot.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2017 Google
+ *
+ * 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 <Foundation/Foundation.h>
+
+#import "FIRFirestoreSwiftNameSupport.h"
+
+@class FIRDocumentReference;
+@class FIRSnapshotMetadata;
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ * A `FIRDocumentSnapshot` contains data read from a document in your Firestore database. The data
+ * can be extracted with the `data` property or by using subscript syntax to access a specific
+ * field.
+ */
+FIR_SWIFT_NAME(DocumentSnapshot)
+@interface FIRDocumentSnapshot : NSObject
+
+/** */
+- (instancetype)init
+ __attribute__((unavailable("FIRDocumentSnapshot cannot be created directly.")));
+
+/** True if the document exists. */
+@property(nonatomic, assign, readonly) BOOL exists;
+
+/** A `FIRDocumentReference` to the document location. */
+@property(nonatomic, strong, readonly) FIRDocumentReference *reference;
+
+/** The ID of the document for which this `FIRDocumentSnapshot` contains data. */
+@property(nonatomic, copy, readonly) NSString *documentID;
+
+/** Metadata about this snapshot concerning its source and if it has local modifications. */
+@property(nonatomic, strong, readonly) FIRSnapshotMetadata *metadata;
+
+/**
+ * Retrieves all fields in the document as an `NSDictionary`.
+ *
+ * @return An `NSDictionary` containing all fields in the document.
+ */
+- (NSDictionary<NSString *, id> *)data;
+
+/**
+ * Retrieves a specific field from the document.
+ *
+ * @param key The field to retrieve.
+ *
+ * @return The value contained in the field or `nil` if the field doesn't exist.
+ */
+- (nullable id)objectForKeyedSubscript:(id)key;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firestore/Source/Public/FIRFieldPath.h b/Firestore/Source/Public/FIRFieldPath.h
new file mode 100644
index 0000000..b80eda7
--- /dev/null
+++ b/Firestore/Source/Public/FIRFieldPath.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2017 Google
+ *
+ * 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 <Foundation/Foundation.h>
+
+#import "FIRFirestoreSwiftNameSupport.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ * A `FieldPath` refers to a field in a document. The path may consist of a single field name
+ * (referring to a top level field in the document), or a list of field names (referring to a nested
+ * field in the document).
+ */
+FIR_SWIFT_NAME(FieldPath)
+@interface FIRFieldPath : NSObject <NSCopying>
+
+- (instancetype)init NS_UNAVAILABLE;
+
+/**
+ * Creates a `FieldPath` from the provided field names. If more than one field name is provided, the
+ * path will point to a nested field in a document.
+ *
+ * @param fieldNames A list of field names.
+ * @return A `FieldPath` that points to a field location in a document.
+ */
+- (instancetype)initWithFields:(NSArray<NSString *> *)fieldNames FIR_SWIFT_NAME(init(_:));
+
+/**
+ * A special sentinel `FieldPath` to refer to the ID of a document. It can be used in queries to
+ * sort or filter by the document ID.
+ */
++ (instancetype)documentID;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firestore/Source/Public/FIRFieldValue.h b/Firestore/Source/Public/FIRFieldValue.h
new file mode 100644
index 0000000..f7d19f0
--- /dev/null
+++ b/Firestore/Source/Public/FIRFieldValue.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2017 Google
+ *
+ * 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 <Foundation/Foundation.h>
+
+#import "FIRFirestoreSwiftNameSupport.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ * Sentinel values that can be used when writing document fields with setData() or updateData().
+ */
+FIR_SWIFT_NAME(FieldValue)
+@interface FIRFieldValue : NSObject
+
+/** */
+- (instancetype)init NS_UNAVAILABLE;
+
+/** Used with updateData() to mark a field for deletion. */
+// clang-format off
++ (instancetype)fieldValueForDelete FIR_SWIFT_NAME(delete());
+// clang-format on
+
+/**
+ * Used with setData() or updateData() to include a server-generated timestamp in the written
+ * data.
+ */
++ (instancetype)fieldValueForServerTimestamp FIR_SWIFT_NAME(serverTimestamp());
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firestore/Source/Public/FIRFirestore.h b/Firestore/Source/Public/FIRFirestore.h
new file mode 100644
index 0000000..c31fef6
--- /dev/null
+++ b/Firestore/Source/Public/FIRFirestore.h
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2017 Google
+ *
+ * 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 <Foundation/Foundation.h>
+
+#import "FIRFirestoreSwiftNameSupport.h"
+
+@class FIRApp;
+@class FIRCollectionReference;
+@class FIRDocumentReference;
+@class FIRFirestoreSettings;
+@class FIRTransaction;
+@class FIRWriteBatch;
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ * `FIRFirestore` represents a Firestore Database and is the entry point for all Firestore
+ * operations.
+ */
+FIR_SWIFT_NAME(Firestore)
+@interface FIRFirestore : NSObject
+
+#pragma mark - Initializing
+/** */
+- (instancetype)init __attribute__((unavailable("Use a static constructor method.")));
+
+/**
+ * Creates, caches, and returns a `FIRFirestore` using the default `FIRApp`. Each subsequent
+ * invocation returns the same `FIRFirestore` object.
+ *
+ * @return The `FIRFirestore` instance.
+ */
++ (instancetype)firestore FIR_SWIFT_NAME(firestore());
+
+/**
+ * Creates, caches, and returns a `FIRFirestore` object for the specified _app_. Each subsequent
+ * invocation returns the same `FIRFirestore` object.
+ *
+ * @param app The `FIRApp` instance to use for authentication and as a source of the Google Cloud
+ * Project ID for your Firestore Database. If you want the default instance, you should explicitly
+ * set it to `[FIRApp defaultApp]`.
+ *
+ * @return The `FIRFirestore` instance.
+ */
++ (instancetype)firestoreForApp:(FIRApp *)app FIR_SWIFT_NAME(firestore(app:));
+
+/**
+ * Custom settings used to configure this `FIRFirestore` object.
+ */
+@property(nonatomic, copy) FIRFirestoreSettings *settings;
+
+/**
+ * The Firebase App associated with this Firestore instance.
+ */
+@property(strong, nonatomic, readonly) FIRApp *app;
+
+#pragma mark - Collections and Documents
+
+/**
+ * Gets a `FIRCollectionReference` referring to the collection at the specified path within the
+ * database.
+ *
+ * @param collectionPath The slash-separated path of the collection for which to get a
+ * `FIRCollectionReference`.
+ *
+ * @return The `FIRCollectionReference` at the specified _collectionPath_.
+ */
+- (FIRCollectionReference *)collectionWithPath:(NSString *)collectionPath
+ FIR_SWIFT_NAME(collection(_:));
+
+/**
+ * Gets a `FIRDocumentReference` referring to the document at the specified path within the
+ * database.
+ *
+ * @param documentPath The slash-separated path of the document for which to get a
+ * `FIRDocumentReference`.
+ *
+ * @return The `FIRDocumentReference` for the specified _documentPath_.
+ */
+- (FIRDocumentReference *)documentWithPath:(NSString *)documentPath FIR_SWIFT_NAME(document(_:));
+
+#pragma mark - Transactions and Write Batches
+
+/**
+ * Executes the given updateBlock and then attempts to commit the changes applied within an atomic
+ * transaction.
+ *
+ * In the updateBlock, a set of reads and writes can be performed atomically using the
+ * `FIRTransaction` object passed to the block. After the updateBlock is run, Firestore will attempt
+ * to apply the changes to the server. If any of the data read has been modified outside of this
+ * transaction since being read, then the transaction will be retried by executing the updateBlock
+ * again. If the transaction still fails after 5 retries, then the transaction will fail.
+ *
+ * Since the updateBlock may be executed multiple times, it should avoiding doing anything that
+ * would cause side effects.
+ *
+ * Any value maybe be returned from the updateBlock. If the transaction is successfully committed,
+ * then the completion block will be passed that value. The updateBlock also has an `NSError` out
+ * parameter. If this is set, then the transaction will not attempt to commit, and the given error
+ * will be passed to the completion block.
+ *
+ * The `FIRTransaction` object passed to the updateBlock contains methods for accessing documents
+ * and collections. Unlike other firestore access, data accessed with the transaction will not
+ * reflect local changes that have not been committed. For this reason, it is required that all
+ * reads are performed before any writes. Transactions must be performed while online. Otherwise,
+ * reads will fail, and the final commit will fail.
+ *
+ * @param updateBlock The block to execute within the transaction context.
+ * @param completion The block to call with the result or error of the transaction.
+ */
+- (void)runTransactionWithBlock:(id _Nullable (^)(FIRTransaction *, NSError **))updateBlock
+ completion:(void (^)(id _Nullable result, NSError *_Nullable error))completion;
+
+/**
+ * Creates a write batch, used for performing multiple writes as a single
+ * atomic operation.
+ *
+ * Unlike transactions, write batches are persisted offline and therefore are preferable when you
+ * don't need to condition your writes on read data.
+ */
+- (FIRWriteBatch *)batch;
+
+#pragma mark - Logging
+
+/** Enables or disables logging from the Firestore client. */
++ (void)enableLogging:(BOOL)logging
+ DEPRECATED_MSG_ATTRIBUTE("Use FIRSetLoggerLevel(FIRLoggerLevelDebug) to enable logging");
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firestore/Source/Public/FIRFirestoreErrors.h b/Firestore/Source/Public/FIRFirestoreErrors.h
new file mode 100644
index 0000000..f2e19d9
--- /dev/null
+++ b/Firestore/Source/Public/FIRFirestoreErrors.h
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2017 Google
+ *
+ * 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 <Foundation/Foundation.h>
+
+#import "FIRFirestoreSwiftNameSupport.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+/** The Cloud Firestore error domain. */
+FOUNDATION_EXPORT NSString *const FIRFirestoreErrorDomain FIR_SWIFT_NAME(FirestoreErrorDomain);
+
+/** Error codes used by Cloud Firestore. */
+typedef NS_ENUM(NSInteger, FIRFirestoreErrorCode) {
+ /**
+ * The operation completed successfully. NSError objects will never have a code with this value.
+ */
+ FIRFirestoreErrorCodeOK = 0,
+
+ /** The operation was cancelled (typically by the caller). */
+ FIRFirestoreErrorCodeCancelled = 1,
+
+ /** Unknown error or an error from a different error domain. */
+ FIRFirestoreErrorCodeUnknown = 2,
+
+ /**
+ * Client specified an invalid argument. Note that this differs from FailedPrecondition.
+ * InvalidArgument indicates arguments that are problematic regardless of the state of the
+ * system (e.g., an invalid field name).
+ */
+ FIRFirestoreErrorCodeInvalidArgument = 3,
+
+ /**
+ * Deadline expired before operation could complete. For operations that change the state of the
+ * system, this error may be returned even if the operation has completed successfully. For
+ * example, a successful response from a server could have been delayed long enough for the
+ * deadline to expire.
+ */
+ FIRFirestoreErrorCodeDeadlineExceeded = 4,
+
+ /** Some requested document was not found. */
+ FIRFirestoreErrorCodeNotFound = 5,
+
+ /** Some document that we attempted to create already exists. */
+ FIRFirestoreErrorCodeAlreadyExists = 6,
+
+ /** The caller does not have permission to execute the specified operation. */
+ FIRFirestoreErrorCodePermissionDenied = 7,
+
+ /**
+ * Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system
+ * is out of space.
+ */
+ FIRFirestoreErrorCodeResourceExhausted = 8,
+
+ /**
+ * Operation was rejected because the system is not in a state required for the operation's
+ * execution.
+ */
+ FIRFirestoreErrorCodeFailedPrecondition = 9,
+
+ /**
+ * The operation was aborted, typically due to a concurrency issue like transaction aborts, etc.
+ */
+ FIRFirestoreErrorCodeAborted = 10,
+
+ /** Operation was attempted past the valid range. */
+ FIRFirestoreErrorCodeOutOfRange = 11,
+
+ /** Operation is not implemented or not supported/enabled. */
+ FIRFirestoreErrorCodeUnimplemented = 12,
+
+ /**
+ * Internal errors. Means some invariants expected by underlying system has been broken. If you
+ * see one of these errors, something is very broken.
+ */
+ FIRFirestoreErrorCodeInternal = 13,
+
+ /**
+ * The service is currently unavailable. This is a most likely a transient condition and may be
+ * corrected by retrying with a backoff.
+ */
+ FIRFirestoreErrorCodeUnavailable = 14,
+
+ /** Unrecoverable data loss or corruption. */
+ FIRFirestoreErrorCodeDataLoss = 15,
+
+ /** The request does not have valid authentication credentials for the operation. */
+ FIRFirestoreErrorCodeUnauthenticated = 16
+} FIR_SWIFT_NAME(FirestoreErrorCode);
+
+NS_ASSUME_NONNULL_END
diff --git a/Firestore/Source/Public/FIRFirestoreSettings.h b/Firestore/Source/Public/FIRFirestoreSettings.h
new file mode 100644
index 0000000..7097e60
--- /dev/null
+++ b/Firestore/Source/Public/FIRFirestoreSettings.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2017 Google
+ *
+ * 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 <Foundation/Foundation.h>
+
+#import "FIRFirestoreSwiftNameSupport.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+/** Settings used to configure a `FIRFirestore` instance. */
+FIR_SWIFT_NAME(FirestoreSettings)
+@interface FIRFirestoreSettings : NSObject <NSCopying>
+
+/**
+ * Creates and returns an empty `FIRFirestoreSettings` object.
+ *
+ * @return The created `FIRFirestoreSettings` object.
+ */
+- (instancetype)init NS_DESIGNATED_INITIALIZER;
+
+/** The hostname to connect to. */
+@property(nonatomic, copy) NSString *host;
+
+/** Whether to use SSL when connecting. */
+@property(nonatomic, getter=isSSLEnabled) BOOL sslEnabled;
+
+/**
+ * A dispatch queue to be used to execute all completion handlers and event handlers. By default,
+ * the main queue is used.
+ */
+@property(nonatomic, strong) dispatch_queue_t dispatchQueue;
+
+/** Set to false to disable local persistent storage. */
+@property(nonatomic, getter=isPersistenceEnabled) BOOL persistenceEnabled;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firestore/Source/Public/FIRFirestoreSwiftNameSupport.h b/Firestore/Source/Public/FIRFirestoreSwiftNameSupport.h
new file mode 100644
index 0000000..216c047
--- /dev/null
+++ b/Firestore/Source/Public/FIRFirestoreSwiftNameSupport.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2017 Google
+ *
+ * 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.
+ */
+
+#ifndef FIR_SWIFT_NAME
+
+#import <Foundation/Foundation.h>
+
+// NS_SWIFT_NAME can only translate factory methods before the iOS 9.3 SDK.
+// Wrap it in our own macro if it's a non-compatible SDK.
+#ifdef __IPHONE_9_3
+#define FIR_SWIFT_NAME(X) NS_SWIFT_NAME(X)
+#else
+#define FIR_SWIFT_NAME(X) // Intentionally blank.
+#endif // #ifdef __IPHONE_9_3
+
+#endif // FIR_SWIFT_NAME
diff --git a/Firestore/Source/Public/FIRGeoPoint.h b/Firestore/Source/Public/FIRGeoPoint.h
new file mode 100644
index 0000000..de409b5
--- /dev/null
+++ b/Firestore/Source/Public/FIRGeoPoint.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2017 Google
+ *
+ * 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 <Foundation/Foundation.h>
+
+#import "FIRFirestoreSwiftNameSupport.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ * An immutable object representing a geographical point in Firestore. The point is represented as
+ * a latitude/longitude pair.
+ *
+ * Latitude values are in the range of [-90, 90].
+ * Longitude values are in the range of [-180, 180].
+ */
+FIR_SWIFT_NAME(GeoPoint)
+@interface FIRGeoPoint : NSObject <NSCopying>
+
+/** */
+- (instancetype)init NS_UNAVAILABLE;
+
+/**
+ * Creates a `GeoPoint` from the provided latitude and longitude degrees.
+ * @param latitude The latitude as number between -90 and 90.
+ * @param longitude The longitude as number between -180 and 180.
+ */
+- (instancetype)initWithLatitude:(double)latitude
+ longitude:(double)longitude NS_DESIGNATED_INITIALIZER;
+
+@property(nonatomic, readonly) double latitude;
+@property(nonatomic, readonly) double longitude;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firestore/Source/Public/FIRListenerRegistration.h b/Firestore/Source/Public/FIRListenerRegistration.h
new file mode 100644
index 0000000..5fe7fd5
--- /dev/null
+++ b/Firestore/Source/Public/FIRListenerRegistration.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2017 Google
+ *
+ * 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 <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+/** Represents a listener that can be removed by calling remove. */
+@protocol FIRListenerRegistration <NSObject>
+
+/**
+ * Removes the listener being tracked by this FIRListenerRegistration. After the initial call,
+ * subsequent calls have no effect.
+ */
+- (void)remove;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firestore/Source/Public/FIRQuery.h b/Firestore/Source/Public/FIRQuery.h
new file mode 100644
index 0000000..5c5546d
--- /dev/null
+++ b/Firestore/Source/Public/FIRQuery.h
@@ -0,0 +1,414 @@
+/*
+ * Copyright 2017 Google
+ *
+ * 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 <Foundation/Foundation.h>
+
+#import "FIRFirestoreSwiftNameSupport.h"
+#import "FIRListenerRegistration.h"
+
+@class FIRFieldPath;
+@class FIRFirestore;
+@class FIRQuerySnapshot;
+@class FIRDocumentSnapshot;
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ * Options for use with `[FIRQuery addSnapshotListener]` to control the behavior of the snapshot
+ * listener.
+ */
+FIR_SWIFT_NAME(QueryListenOptions)
+@interface FIRQueryListenOptions : NSObject
+
++ (instancetype)options NS_SWIFT_UNAVAILABLE("Use initializer");
+
+- (instancetype)init;
+
+@property(nonatomic, assign, readonly) BOOL includeQueryMetadataChanges;
+
+/**
+ * Sets the includeQueryMetadataChanges option which controls whether metadata-only changes on the
+ * query (i.e. only `FIRQuerySnapshot.metadata` changed) should trigger snapshot events. Default is
+ * NO.
+ *
+ * @param includeQueryMetadataChanges Whether to raise events for metadata-only changes on the
+ * query.
+ * @return The receiver is returned for optional method chaining.
+ */
+- (instancetype)includeQueryMetadataChanges:(BOOL)includeQueryMetadataChanges
+ FIR_SWIFT_NAME(includeQueryMetadataChanges(_:));
+
+@property(nonatomic, assign, readonly) BOOL includeDocumentMetadataChanges;
+
+/**
+ * Sets the includeDocumentMetadataChanges option which controls whether document metadata-only
+ * changes (i.e. only `FIRDocumentSnapshot.metadata` on a document contained in the query
+ * changed) should trigger snapshot events. Default is NO.
+ *
+ * @param includeDocumentMetadataChanges Whether to raise events for document metadata-only changes.
+ * @return The receiver is returned for optional method chaining.
+ */
+- (instancetype)includeDocumentMetadataChanges:(BOOL)includeDocumentMetadataChanges
+ FIR_SWIFT_NAME(includeDocumentMetadataChanges(_:));
+
+@end
+
+typedef void (^FIRQuerySnapshotBlock)(FIRQuerySnapshot *_Nullable snapshot,
+ NSError *_Nullable error);
+
+/**
+ * A `FIRQuery` refers to a Query which you can read or listen to. You can also construct
+ * refined `FIRQuery` objects by adding filters and ordering.
+ */
+FIR_SWIFT_NAME(Query)
+@interface FIRQuery : NSObject
+/** */
+- (id)init __attribute__((unavailable("FIRQuery cannot be created directly.")));
+
+/** The `FIRFirestore` for the Firestore database (useful for performing transactions, etc.). */
+@property(nonatomic, strong, readonly) FIRFirestore *firestore;
+
+#pragma mark - Retrieving Data
+/**
+ * Reads the documents matching this query.
+ *
+ * @param completion a block to execute once the documents have been successfully read.
+ * documentSet will be `nil` only if error is `non-nil`.
+ */
+- (void)getDocumentsWithCompletion:(FIRQuerySnapshotBlock)completion
+ FIR_SWIFT_NAME(getDocuments(completion:));
+
+/**
+ * Attaches a listener for QuerySnapshot events.
+ *
+ * @param listener The listener to attach.
+ *
+ * @return A FIRListenerRegistration that can be used to remove this listener.
+ */
+- (id<FIRListenerRegistration>)addSnapshotListener:(FIRQuerySnapshotBlock)listener
+ FIR_SWIFT_NAME(addSnapshotListener(_:));
+
+/**
+ * Attaches a listener for QuerySnapshot events.
+ *
+ * @param options Options controlling the listener behavior.
+ * @param listener The listener to attach.
+ *
+ * @return A FIRListenerRegistration that can be used to remove this listener.
+ */
+// clang-format off
+- (id<FIRListenerRegistration>)addSnapshotListenerWithOptions:
+ (nullable FIRQueryListenOptions *)options
+ listener:(FIRQuerySnapshotBlock)listener
+ FIR_SWIFT_NAME(addSnapshotListener(options:listener:));
+// clang-format on
+
+#pragma mark - Filtering Data
+/**
+ * Creates and returns a new `FIRQuery` with the additional filter that documents must
+ * contain the specified field and the value must be equal to the specified value.
+ *
+ * @param field The name of the field to compare.
+ * @param value The value the field must be equal to.
+ *
+ * @return The created `FIRQuery`.
+ */
+// clang-format off
+- (FIRQuery *)queryWhereField:(NSString *)field
+ isEqualTo:(id)value FIR_SWIFT_NAME(whereField(_:isEqualTo:));
+// clang-format on
+
+/**
+ * Creates and returns a new `FIRQuery` with the additional filter that documents must
+ * contain the specified field and the value must be equal to the specified value.
+ *
+ * @param path The path of the field to compare.
+ * @param value The value the field must be equal to.
+ *
+ * @return The created `FIRQuery`.
+ */
+// clang-format off
+- (FIRQuery *)queryWhereFieldPath:(FIRFieldPath *)path
+ isEqualTo:(id)value FIR_SWIFT_NAME(whereField(_:isEqualTo:));
+// clang-format on
+
+/**
+ * Creates and returns a new `FIRQuery` with the additional filter that documents must
+ * contain the specified field and the value must be less than the specified value.
+ *
+ * @param field The name of the field to compare.
+ * @param value The value the field must be less than.
+ *
+ * @return The created `FIRQuery`.
+ */
+// clang-format off
+- (FIRQuery *)queryWhereField:(NSString *)field
+ isLessThan:(id)value FIR_SWIFT_NAME(whereField(_:isLessThan:));
+// clang-format on
+
+/**
+ * Creates and returns a new `FIRQuery` with the additional filter that documents must
+ * contain the specified field and the value must be less than the specified value.
+ *
+ * @param path The path of the field to compare.
+ * @param value The value the field must be less than.
+ *
+ * @return The created `FIRQuery`.
+ */
+// clang-format off
+- (FIRQuery *)queryWhereFieldPath:(FIRFieldPath *)path
+ isLessThan:(id)value FIR_SWIFT_NAME(whereField(_:isLessThan:));
+// clang-format on
+
+/**
+ * Creates and returns a new `FIRQuery` with the additional filter that documents must
+ * contain the specified field and the value must be less than or equal to the specified value.
+ *
+ * @param field The name of the field to compare
+ * @param value The value the field must be less than or equal to.
+ *
+ * @return The created `FIRQuery`.
+ */
+// clang-format off
+- (FIRQuery *)queryWhereField:(NSString *)field
+ isLessThanOrEqualTo:(id)value FIR_SWIFT_NAME(whereField(_:isLessThanOrEqualTo:));
+// clang-format on
+
+/**
+ * Creates and returns a new `FIRQuery` with the additional filter that documents must
+ * contain the specified field and the value must be less than or equal to the specified value.
+ *
+ * @param path The path of the field to compare
+ * @param value The value the field must be less than or equal to.
+ *
+ * @return The created `FIRQuery`.
+ */
+// clang-format off
+- (FIRQuery *)queryWhereFieldPath:(FIRFieldPath *)path
+ isLessThanOrEqualTo:(id)value FIR_SWIFT_NAME(whereField(_:isLessThanOrEqualTo:));
+// clang-format on
+
+/**
+ * Creates and returns a new `FIRQuery` with the additional filter that documents must
+ * contain the specified field and the value must greater than the specified value.
+ *
+ * @param field The name of the field to compare
+ * @param value The value the field must be greater than.
+ *
+ * @return The created `FIRQuery`.
+ */
+// clang-format off
+- (FIRQuery *)queryWhereField:(NSString *)field
+ isGreaterThan:(id)value FIR_SWIFT_NAME(whereField(_:isGreaterThan:));
+// clang-format on
+
+/**
+ * Creates and returns a new `FIRQuery` with the additional filter that documents must
+ * contain the specified field and the value must greater than the specified value.
+ *
+ * @param path The path of the field to compare
+ * @param value The value the field must be greater than.
+ *
+ * @return The created `FIRQuery`.
+ */
+// clang-format off
+- (FIRQuery *)queryWhereFieldPath:(FIRFieldPath *)path
+ isGreaterThan:(id)value FIR_SWIFT_NAME(whereField(_:isGreaterThan:));
+// clang-format on
+
+/**
+ * Creates and returns a new `FIRQuery` with the additional filter that documents must
+ * contain the specified field and the value must be greater than or equal to the specified value.
+ *
+ * @param field The name of the field to compare
+ * @param value The value the field must be greater than.
+ *
+ * @return The created `FIRQuery`.
+ */
+// clang-format off
+- (FIRQuery *)queryWhereField:(NSString *)field
+ isGreaterThanOrEqualTo:(id)value FIR_SWIFT_NAME(whereField(_:isGreaterThanOrEqualTo:));
+// clang-format on
+
+/**
+ * Creates and returns a new `FIRQuery` with the additional filter that documents must
+ * contain the specified field and the value must be greater than or equal to the specified value.
+ *
+ * @param path The path of the field to compare
+ * @param value The value the field must be greater than.
+ *
+ * @return The created `FIRQuery`.
+ */
+// clang-format off
+- (FIRQuery *)queryWhereFieldPath:(FIRFieldPath *)path
+ isGreaterThanOrEqualTo:(id)value FIR_SWIFT_NAME(whereField(_:isGreaterThanOrEqualTo:));
+// clang-format on
+
+#pragma mark - Sorting Data
+/**
+ * Creates and returns a new `FIRQuery` that's additionally sorted by the specified field.
+ *
+ * @param field The field to sort by.
+ *
+ * @return The created `FIRQuery`.
+ */
+- (FIRQuery *)queryOrderedByField:(NSString *)field FIR_SWIFT_NAME(order(by:));
+
+/**
+ * Creates and returns a new `FIRQuery` that's additionally sorted by the specified field.
+ *
+ * @param path The field to sort by.
+ *
+ * @return The created `FIRQuery`.
+ */
+- (FIRQuery *)queryOrderedByFieldPath:(FIRFieldPath *)path FIR_SWIFT_NAME(order(by:));
+
+/**
+ * Creates and returns a new `FIRQuery` that's additionally sorted by the specified field,
+ * optionally in descending order instead of ascending.
+ *
+ * @param field The field to sort by.
+ * @param descending Whether to sort descending.
+ *
+ * @return The created `FIRQuery`.
+ */
+// clang-format off
+- (FIRQuery *)queryOrderedByField:(NSString *)field
+ descending:(BOOL)descending FIR_SWIFT_NAME(order(by:descending:));
+// clang-format on
+
+/**
+ * Creates and returns a new `FIRQuery` that's additionally sorted by the specified field,
+ * optionally in descending order instead of ascending.
+ *
+ * @param path The field to sort by.
+ * @param descending Whether to sort descending.
+ *
+ * @return The created `FIRQuery`.
+ */
+// clang-format off
+- (FIRQuery *)queryOrderedByFieldPath:(FIRFieldPath *)path
+ descending:(BOOL)descending FIR_SWIFT_NAME(order(by:descending:));
+// clang-format on
+
+#pragma mark - Limiting Data
+/**
+ * Creates and returns a new `FIRQuery` that's additionally limited to only return up to
+ * the specified number of documents.
+ *
+ * @param limit The maximum number of items to return.
+ *
+ * @return The created `FIRQuery`.
+ */
+- (FIRQuery *)queryLimitedTo:(NSInteger)limit FIR_SWIFT_NAME(limit(to:));
+
+#pragma mark - Choosing Endpoints
+/**
+ * Creates and returns a new `FIRQuery` that starts at the provided document (inclusive). The
+ * starting position is relative to the order of the query. The document must contain all of the
+ * fields provided in the orderBy of this query.
+ *
+ * @param document The snapshot of the document to start at.
+ *
+ * @return The created `FIRQuery`.
+ */
+- (FIRQuery *)queryStartingAtDocument:(FIRDocumentSnapshot *)document
+ FIR_SWIFT_NAME(start(atDocument:));
+
+/**
+ * Creates and returns a new `FIRQuery` that starts at the provided fields relative to the order of
+ * the query. The order of the field values must match the order of the order by clauses of the
+ * query.
+ *
+ * @param fieldValues The field values to start this query at, in order of the query's order by.
+ *
+ * @return The created `FIRQuery`.
+ */
+- (FIRQuery *)queryStartingAtValues:(NSArray *)fieldValues FIR_SWIFT_NAME(start(at:));
+
+/**
+ * Creates and returns a new `FIRQuery` that starts after the provided document (exclusive). The
+ * starting position is relative to the order of the query. The document must contain all of the
+ * fields provided in the orderBy of this query.
+ *
+ * @param document The snapshot of the document to start after.
+ *
+ * @return The created `FIRQuery`.
+ */
+- (FIRQuery *)queryStartingAfterDocument:(FIRDocumentSnapshot *)document
+ FIR_SWIFT_NAME(start(afterDocument:));
+
+/**
+ * Creates and returns a new `FIRQuery` that starts after the provided fields relative to the order
+ * of the query. The order of the field values must match the order of the order by clauses of the
+ * query.
+ *
+ * @param fieldValues The field values to start this query after, in order of the query's order
+ * by.
+ *
+ * @return The created `FIRQuery`.
+ */
+- (FIRQuery *)queryStartingAfterValues:(NSArray *)fieldValues FIR_SWIFT_NAME(start(after:));
+
+/**
+ * Creates and returns a new `FIRQuery` that ends before the provided document (exclusive). The end
+ * position is relative to the order of the query. The document must contain all of the fields
+ * provided in the orderBy of this query.
+ *
+ * @param document The snapshot of the document to end before.
+ *
+ * @return The created `FIRQuery`.
+ */
+- (FIRQuery *)queryEndingBeforeDocument:(FIRDocumentSnapshot *)document
+ FIR_SWIFT_NAME(end(beforeDocument:));
+
+/**
+ * Creates and returns a new `FIRQuery` that ends before the provided fields relative to the order
+ * of the query. The order of the field values must match the order of the order by clauses of the
+ * query.
+ *
+ * @param fieldValues The field values to end this query before, in order of the query's order by.
+ *
+ * @return The created `FIRQuery`.
+ */
+- (FIRQuery *)queryEndingBeforeValues:(NSArray *)fieldValues FIR_SWIFT_NAME(end(before:));
+
+/**
+ * Creates and returns a new `FIRQuery` that ends at the provided document (exclusive). The end
+ * position is relative to the order of the query. The document must contain all of the fields
+ * provided in the orderBy of this query.
+ *
+ * @param document The snapshot of the document to end at.
+ *
+ * @return The created `FIRQuery`.
+ */
+- (FIRQuery *)queryEndingAtDocument:(FIRDocumentSnapshot *)document
+ FIR_SWIFT_NAME(end(atDocument:));
+
+/**
+ * Creates and returns a new `FIRQuery` that ends at the provided fields relative to the order of
+ * the query. The order of the field values must match the order of the order by clauses of the
+ * query.
+ *
+ * @param fieldValues The field values to end this query at, in order of the query's order by.
+ *
+ * @return The created `FIRQuery`.
+ */
+- (FIRQuery *)queryEndingAtValues:(NSArray *)fieldValues FIR_SWIFT_NAME(end(at:));
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firestore/Source/Public/FIRQuerySnapshot.h b/Firestore/Source/Public/FIRQuerySnapshot.h
new file mode 100644
index 0000000..800368d
--- /dev/null
+++ b/Firestore/Source/Public/FIRQuerySnapshot.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2017 Google
+ *
+ * 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 <Foundation/Foundation.h>
+
+#import "FIRFirestoreSwiftNameSupport.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@class FIRDocumentChange;
+@class FIRDocumentSnapshot;
+@class FIRQuery;
+@class FIRSnapshotMetadata;
+
+/**
+ * A `FIRQuerySnapshot` contains zero or more `FIRDocumentSnapshot` objects. It can be enumerated
+ * using "for ... in documentSet.documents" and its size can be inspected with `isEmpty` and
+ * `count`.
+ */
+FIR_SWIFT_NAME(QuerySnapshot)
+@interface FIRQuerySnapshot : NSObject
+
+/** */
+- (id)init __attribute__((unavailable("FIRQuerySnapshot cannot be created directly.")));
+
+/**
+ * The query on which you called `getDocuments` or listened to in order to get this
+ * `FIRQuerySnapshot`.
+ */
+@property(nonatomic, strong, readonly) FIRQuery *query;
+
+/** Metadata about this snapshot, concerning its source and if it has local modifications. */
+@property(nonatomic, strong, readonly) FIRSnapshotMetadata *metadata;
+
+/** Indicates whether this `FIRQuerySnapshot` is empty (contains no documents). */
+@property(nonatomic, readonly, getter=isEmpty) BOOL empty;
+
+/** The count of documents in this `FIRQuerySnapshot`. */
+@property(nonatomic, readonly) NSInteger count;
+
+/** An Array of the `FIRDocumentSnapshots` that make up this document set. */
+@property(nonatomic, strong, readonly) NSArray<FIRDocumentSnapshot *> *documents;
+
+/**
+ * An array of the documents that changed since the last snapshot. If this is the first snapshot,
+ * all documents will be in the list as Added changes.
+ */
+@property(nonatomic, strong, readonly) NSArray<FIRDocumentChange *> *documentChanges;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firestore/Source/Public/FIRSetOptions.h b/Firestore/Source/Public/FIRSetOptions.h
new file mode 100644
index 0000000..c865e06
--- /dev/null
+++ b/Firestore/Source/Public/FIRSetOptions.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2017 Google
+ *
+ * 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 <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ * An options object that configures the behavior of setData() calls. By providing the
+ * `FIRSetOptions` objects returned by `merge:`, the setData() methods in `FIRDocumentReference`,
+ * `FIRWriteBatch` and `FIRTransaction` can be configured to perform granular merges instead
+ * of overwriting the target documents in their entirety.
+ */
+NS_SWIFT_NAME(SetOptions)
+@interface FIRSetOptions : NSObject
+
+/** */
+- (id)init NS_UNAVAILABLE;
+/**
+ * Changes the behavior of setData() calls to only replace the values specified in its data
+ * argument. Fields with no corresponding values in the data passed to setData() will remain
+ * untouched.
+ *
+ * @return The created `FIRSetOptions` object
+ */
++ (instancetype)merge;
+
+/** Whether setData() should merge existing data instead of performing an overwrite. */
+@property(nonatomic, readonly, getter=isMerge) BOOL merge;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firestore/Source/Public/FIRSnapshotMetadata.h b/Firestore/Source/Public/FIRSnapshotMetadata.h
new file mode 100644
index 0000000..7fdd49c
--- /dev/null
+++ b/Firestore/Source/Public/FIRSnapshotMetadata.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2017 Google
+ *
+ * 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 <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+/** Metadata about a snapshot, describing the state of the snapshot. */
+@interface FIRSnapshotMetadata : NSObject
+
+- (instancetype)init NS_UNAVAILABLE;
+
+/**
+ * Returns YES if the snapshot contains the result of local writes (e.g. set() or update() calls)
+ * that have not yet been committed to the backend. If your listener has opted into metadata updates
+ * (via `FIRDocumentListenOptions` or `FIRQueryListenOptions`) you will receive another snapshot
+ * with `hasPendingWrites` equal to NO once the writes have been committed to the backend.
+ */
+@property(nonatomic, assign, readonly, getter=hasPendingWrites) BOOL pendingWrites;
+
+/**
+ * Returns YES if the snapshot was created from cached data rather than guaranteed up-to-date server
+ * data. If your listener has opted into metadata updates (via `FIRDocumentListenOptions` or
+ * `FIRQueryListenOptions`) you will receive another snapshot with `isFromCache` equal to NO once
+ * the client has received up-to-date data from the backend.
+ */
+@property(nonatomic, assign, readonly, getter=isFromCache) BOOL fromCache;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firestore/Source/Public/FIRTransaction.h b/Firestore/Source/Public/FIRTransaction.h
new file mode 100644
index 0000000..68e4600
--- /dev/null
+++ b/Firestore/Source/Public/FIRTransaction.h
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2017 Google
+ *
+ * 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 <Foundation/Foundation.h>
+
+#import "FIRFirestoreSwiftNameSupport.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@class FIRDocumentReference;
+@class FIRDocumentSnapshot;
+@class FIRSetOptions;
+
+/**
+ * `FIRTransaction` provides methods to read and write data within a transaction.
+ *
+ * @see FIRFirestore#transaction:completion:
+ */
+FIR_SWIFT_NAME(Transaction)
+@interface FIRTransaction : NSObject
+
+/** */
+- (id)init __attribute__((unavailable("FIRTransaction cannot be created directly.")));
+
+/**
+ * Writes to the document referred to by `document`. If the document doesn't yet exist,
+ * this method creates it and then sets the data. If the document exists, this method overwrites
+ * the document data with the new values.
+ *
+ * @param data An `NSDictionary` that contains the fields and data to write to the document.
+ * @param document A reference to the document whose data should be overwritten.
+ * @return This `FIRTransaction` instance. Used for chaining method calls.
+ */
+// clang-format off
+- (FIRTransaction *)setData:(NSDictionary<NSString *, id> *)data
+ forDocument:(FIRDocumentReference *)document
+ FIR_SWIFT_NAME(setData(_:forDocument:));
+// clang-format on
+
+/**
+ * Writes to the document referred to by `document`. If the document doesn't yet exist,
+ * this method creates it and then sets the data. If you pass `FIRSetOptions`, the provided data
+ * will be merged into an existing document.
+ *
+ * @param data An `NSDictionary` that contains the fields and data to write to the document.
+ * @param document A reference to the document whose data should be overwritten.
+ * @param options A `FIRSetOptions` used to configure the set behavior.
+ * @return This `FIRTransaction` instance. Used for chaining method calls.
+ */
+// clang-format off
+- (FIRTransaction *)setData:(NSDictionary<NSString *, id> *)data
+ forDocument:(FIRDocumentReference *)document
+ options:(FIRSetOptions *)options
+ FIR_SWIFT_NAME(setData(_:forDocument:options:));
+// clang-format on
+
+/**
+ * Updates fields in the document referred to by `document`.
+ * If the document does not exist, the transaction will fail.
+ *
+ * @param fields An `NSDictionary` containing the fields (expressed as an `NSString` or
+ * `FIRFieldPath`) and values with which to update the document.
+ * @param document A reference to the document whose data should be updated.
+ * @return This `FIRTransaction` instance. Used for chaining method calls.
+ */
+// clang-format off
+- (FIRTransaction *)updateData:(NSDictionary<id, id> *)fields
+ forDocument:(FIRDocumentReference *)document
+ FIR_SWIFT_NAME(updateData(_:forDocument:));
+// clang-format on
+
+/**
+ * Deletes the document referred to by `document`.
+ *
+ * @param document A reference to the document that should be deleted.
+ * @return This `FIRTransaction` instance. Used for chaining method calls.
+ */
+- (FIRTransaction *)deleteDocument:(FIRDocumentReference *)document
+ FIR_SWIFT_NAME(deleteDocument(_:));
+
+/**
+ * Reads the document referenced by `document`.
+ *
+ * @param document A reference to the document to be read.
+ * @param error An out parameter to capture an error, if one occurred.
+ */
+- (FIRDocumentSnapshot *_Nullable)getDocument:(FIRDocumentReference *)document
+ error:(NSError *__autoreleasing *)error
+ FIR_SWIFT_NAME(getDocument(_:));
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firestore/Source/Public/FIRWriteBatch.h b/Firestore/Source/Public/FIRWriteBatch.h
new file mode 100644
index 0000000..b88e6cc
--- /dev/null
+++ b/Firestore/Source/Public/FIRWriteBatch.h
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2017 Google
+ *
+ * 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 <Foundation/Foundation.h>
+
+#import "FIRFirestoreSwiftNameSupport.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@class FIRDocumentReference;
+@class FIRSetOptions;
+
+/**
+ * A write batch is used to perform multiple writes as a single atomic unit.
+ *
+ * A WriteBatch object can be acquired by calling [FIRFirestore batch]. It provides methods for
+ * adding writes to the write batch. None of the writes will be committed (or visible locally)
+ * until [FIRWriteBatch commit] is called.
+ *
+ * Unlike transactions, write batches are persisted offline and therefore are preferable when you
+ * don't need to condition your writes on read data.
+ */
+FIR_SWIFT_NAME(WriteBatch)
+@interface FIRWriteBatch : NSObject
+
+/** :nodoc: */
+- (id)init __attribute__((unavailable("FIRWriteBatch cannot be created directly.")));
+
+/**
+ * Writes to the document referred to by `document`. If the document doesn't yet exist,
+ * this method creates it and then sets the data. If the document exists, this method overwrites
+ * the document data with the new values.
+ *
+ * @param data An `NSDictionary` that contains the fields and data to write to the document.
+ * @param document A reference to the document whose data should be overwritten.
+ * @return This `FIRWriteBatch` instance. Used for chaining method calls.
+ */
+// clang-format off
+- (FIRWriteBatch *)setData:(NSDictionary<NSString *, id> *)data
+ forDocument:(FIRDocumentReference *)document FIR_SWIFT_NAME(setData(_:forDocument:));
+// clang-format on
+
+/**
+ * Writes to the document referred to by `document`. If the document doesn't yet exist,
+ * this method creates it and then sets the data. If you pass `FIRSetOptions`, the provided data
+ * will be merged into an existing document.
+ *
+ * @param data An `NSDictionary` that contains the fields and data to write to the document.
+ * @param document A reference to the document whose data should be overwritten.
+ * @param options A `FIRSetOptions` used to configure the set behavior.
+ * @return This `FIRWriteBatch` instance. Used for chaining method calls.
+ */
+// clang-format off
+- (FIRWriteBatch *)setData:(NSDictionary<NSString *, id> *)data
+ forDocument:(FIRDocumentReference *)document
+ options:(FIRSetOptions *)options
+ FIR_SWIFT_NAME(setData(_:forDocument:options:));
+// clang-format on
+
+/**
+ * Updates fields in the document referred to by `document`.
+ * If document does not exist, the write batch will fail.
+ *
+ * @param fields An `NSDictionary` containing the fields (expressed as an `NSString` or
+ * `FIRFieldPath`) and values with which to update the document.
+ * @param document A reference to the document whose data should be updated.
+ * @return This `FIRWriteBatch` instance. Used for chaining method calls.
+ */
+// clang-format off
+- (FIRWriteBatch *)updateData:(NSDictionary<id, id> *)fields
+ forDocument:(FIRDocumentReference *)document
+ FIR_SWIFT_NAME(updateData(_:forDocument:));
+// clang-format on
+
+/**
+ * Deletes the document referred to by `document`.
+ *
+ * @param document A reference to the document that should be deleted.
+ * @return This `FIRWriteBatch` instance. Used for chaining method calls.
+ */
+- (FIRWriteBatch *)deleteDocument:(FIRDocumentReference *)document
+ FIR_SWIFT_NAME(deleteDocument(_:));
+
+/**
+ * Commits all of the writes in this write batch as a single atomic unit.
+ *
+ * @param completion A block to be called once all of the writes in the batch have been
+ * successfully written to the backend as an atomic unit.
+ */
+- (void)commitWithCompletion:(void (^)(NSError *_Nullable error))completion;
+
+@end
+
+NS_ASSUME_NONNULL_END