Skip to content

Remove Cyclic Dependencies #4160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 51 commits into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
5599705
Move FieldMask
schmidt-sebastian Dec 3, 2020
b8efc13
Move normalizeTimestamp
schmidt-sebastian Dec 3, 2020
6af13ee
Move TypeOrder
schmidt-sebastian Dec 3, 2020
f315c89
Move query
schmidt-sebastian Dec 3, 2020
bf8f746
Move toDouble, toInteger
schmidt-sebastian Dec 3, 2020
fb16170
Move Serializer
schmidt-sebastian Dec 3, 2020
b682857
Move PersistenceTransaction
schmidt-sebastian Dec 3, 2020
6e32f92
Move ExponentialBackoff
schmidt-sebastian Dec 3, 2020
e2846a9
Move LocalStoreImpl
schmidt-sebastian Dec 3, 2020
8fcc47b
LruGarbageCollector
schmidt-sebastian Dec 3, 2020
3456d83
Move PRIMARY_LEASE_LOST_ERROR_MSG
schmidt-sebastian Dec 3, 2020
0fba935
BundleReader
schmidt-sebastian Dec 3, 2020
3e69755
Move BundleLoader
schmidt-sebastian Dec 3, 2020
a4758a0
IndexedDbBundleCache
schmidt-sebastian Dec 3, 2020
1b1a67d
IndexedDbIndexManager
schmidt-sebastian Dec 3, 2020
11df697
Clean up IndexedDbPersistence
schmidt-sebastian Dec 3, 2020
1159302
Remove unused imports
schmidt-sebastian Dec 3, 2020
e5b9a81
removeMutationBatch/DocumentKey
schmidt-sebastian Dec 3, 2020
b639a29
IndexedDbSchemaConverter
schmidt-sebastian Dec 3, 2020
a503100
IndexedDbBundleCache
schmidt-sebastian Dec 3, 2020
cccabf2
MemoryTargetCache
schmidt-sebastian Dec 3, 2020
0b518f0
Move FieldValue
schmidt-sebastian Dec 3, 2020
cb07140
Move FieldValue implementations
schmidt-sebastian Dec 3, 2020
d9c66ec
Fix Components
schmidt-sebastian Dec 3, 2020
c06dd59
Make Reference unique
schmidt-sebastian Dec 3, 2020
d03efd3
Move ensureClientConfigured/configureClient
schmidt-sebastian Dec 3, 2020
c2f951e
Move SnapshotMetadata
schmidt-sebastian Dec 3, 2020
2c0faa2
Fix lite/.../query.ts
schmidt-sebastian Dec 3, 2020
97b2189
Move UserDataWriter
schmidt-sebastian Dec 3, 2020
ec5ac56
Add onwarn
schmidt-sebastian Dec 3, 2020
fef7824
Cleanup
schmidt-sebastian Dec 3, 2020
7fb2de0
Fix unit tests
schmidt-sebastian Dec 3, 2020
2e666fe
Cleanup imports/exports
schmidt-sebastian Dec 3, 2020
fde4f7f
FieldValue exports
schmidt-sebastian Dec 3, 2020
f324093
Manual cleanup
schmidt-sebastian Dec 4, 2020
a1f8f77
Merge
schmidt-sebastian Dec 4, 2020
e66d39d
Add separate FieldMask
schmidt-sebastian Dec 4, 2020
57ff562
Add TypeOrder comment
schmidt-sebastian Dec 4, 2020
a4001fc
s/numberSerializer/valueSerializer
schmidt-sebastian Dec 4, 2020
618017d
AsyncQueue/AsyncQueueImpl
schmidt-sebastian Dec 5, 2020
a35b1d6
s/_methods/_impl
schmidt-sebastian Dec 5, 2020
a8e3409
getStore
schmidt-sebastian Dec 5, 2020
0294aa3
BATCHID_UNKNOWN
schmidt-sebastian Dec 5, 2020
6482dae
removeMutationBatch
schmidt-sebastian Dec 5, 2020
b15d996
DocumentKey
schmidt-sebastian Dec 5, 2020
045f33f
FirestoreService
schmidt-sebastian Dec 5, 2020
55fb014
Fix bad merge
schmidt-sebastian Dec 5, 2020
d41071c
Feedback
schmidt-sebastian Dec 8, 2020
9f9cfaf
Merge
schmidt-sebastian Dec 8, 2020
25d414c
Fix bundles
schmidt-sebastian Dec 8, 2020
d180871
Undo API Extractor
schmidt-sebastian Dec 8, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions packages/firestore/rollup.config.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ export default [
treeshake: {
moduleSideEffects: false
}
},
{
input: pkg.esm2017,
output: { file: pkg.module, format: 'es', sourcemap: true },
plugins: util.es2017ToEs5Plugins(/* mangled= */ true),
external: util.resolveBrowserExterns,
treeshake: {
moduleSideEffects: false
}
}
// {
// input: pkg.esm2017,
// output: { file: pkg.module, format: 'es', sourcemap: true },
// plugins: util.es2017ToEs5Plugins(/* mangled= */ true),
// external: util.resolveBrowserExterns,
// treeshake: {
// moduleSideEffects: false
// }
// }
];
7 changes: 5 additions & 2 deletions packages/firestore/src/api/user_data_reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { Timestamp } from './timestamp';
import { DatabaseId } from '../core/database_info';
import { DocumentKey } from '../model/document_key';
import {
FieldMask,
FieldTransform,
Mutation,
PatchMutation,
Expand All @@ -42,7 +41,11 @@ import { debugAssert, fail } from '../util/assert';
import { Code, FirestoreError } from '../util/error';
import { isPlainObject, valueDescription } from '../util/input_validation';
import { Dict, forEach, isEmpty } from '../util/obj';
import { ObjectValue, ObjectValueBuilder } from '../model/object_value';
import {
FieldMask,
ObjectValue,
ObjectValueBuilder
} from '../model/object_value';
import {
JsonProtoSerializer,
toBytes,
Expand Down
44 changes: 1 addition & 43 deletions packages/firestore/src/model/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
UnknownDocument
} from './document';
import { DocumentKey } from './document_key';
import { ObjectValue, ObjectValueBuilder } from './object_value';
import { FieldMask, ObjectValue, ObjectValueBuilder } from './object_value';
import { FieldPath } from './path';
import {
applyTransformOperationToLocalView,
Expand All @@ -39,48 +39,6 @@ import {
} from './transform_operation';
import { arrayEquals } from '../util/misc';

/**
* Provides a set of fields that can be used to partially patch a document.
* FieldMask is used in conjunction with ObjectValue.
* Examples:
* foo - Overwrites foo entirely with the provided value. If foo is not
* present in the companion ObjectValue, the field is deleted.
* foo.bar - Overwrites only the field bar of the object foo.
* If foo is not an object, foo is replaced with an object
* containing foo
*/
export class FieldMask {
constructor(readonly fields: FieldPath[]) {
// TODO(dimond): validation of FieldMask
// Sort the field mask to support `FieldMask.isEqual()` and assert below.
fields.sort(FieldPath.comparator);
debugAssert(
!fields.some((v, i) => i !== 0 && v.isEqual(fields[i - 1])),
'FieldMask contains field that is not unique: ' +
fields.find((v, i) => i !== 0 && v.isEqual(fields[i - 1]))!
);
}

/**
* Verifies that `fieldPath` is included by at least one field in this field
* mask.
*
* This is an O(n) operation, where `n` is the size of the field mask.
*/
covers(fieldPath: FieldPath): boolean {
for (const fieldMaskPath of this.fields) {
if (fieldMaskPath.isPrefixOf(fieldPath)) {
return true;
}
}
return false;
}

isEqual(other: FieldMask): boolean {
return arrayEquals(this.fields, other.fields, (l, r) => l.isEqual(r));
}
}

/** A field path and the TransformOperation to perform upon it. */
export class FieldTransform {
constructor(
Expand Down
44 changes: 43 additions & 1 deletion packages/firestore/src/model/object_value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,53 @@ import {
} from '../protos/firestore_proto_api';

import { debugAssert } from '../util/assert';
import { FieldMask } from './mutation';
import { FieldPath } from './path';
import { isServerTimestamp } from './server_timestamps';
import { valueEquals, isMapValue, typeOrder } from './values';
import { forEach } from '../util/obj';
import { arrayEquals } from '../util/misc';

/**
* Provides a set of fields that can be used to partially patch a document.
* FieldMask is used in conjunction with ObjectValue.
* Examples:
* foo - Overwrites foo entirely with the provided value. If foo is not
* present in the companion ObjectValue, the field is deleted.
* foo.bar - Overwrites only the field bar of the object foo.
* If foo is not an object, foo is replaced with an object
* containing foo
*/
export class FieldMask {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FieldMask is in a separate file on other platforms. In some cases (e.g database.ts) I know circularity is impossible to avoid and so we have to dump them all in a single file, but elsewhere keeping classes separate and matching structure across platforms is helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Works without any adjustments.

constructor(readonly fields: FieldPath[]) {
// TODO(dimond): validation of FieldMask
// Sort the field mask to support `FieldMask.isEqual()` and assert below.
fields.sort(FieldPath.comparator);
debugAssert(
!fields.some((v, i) => i !== 0 && v.isEqual(fields[i - 1])),
'FieldMask contains field that is not unique: ' +
fields.find((v, i) => i !== 0 && v.isEqual(fields[i - 1]))!
);
}

/**
* Verifies that `fieldPath` is included by at least one field in this field
* mask.
*
* This is an O(n) operation, where `n` is the size of the field mask.
*/
covers(fieldPath: FieldPath): boolean {
for (const fieldMaskPath of this.fields) {
if (fieldMaskPath.isPrefixOf(fieldPath)) {
return true;
}
}
return false;
}

isEqual(other: FieldMask): boolean {
return arrayEquals(this.fields, other.fields, (l, r) => l.isEqual(r));
}
}

export interface JsonObject<T> {
[name: string]: T;
Expand Down
3 changes: 1 addition & 2 deletions packages/firestore/src/remote/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ import { TargetId } from '../core/types';
import { TargetData, TargetPurpose } from '../local/target_data';
import { Document, MaybeDocument, NoDocument } from '../model/document';
import { DocumentKey } from '../model/document_key';
import { ObjectValue } from '../model/object_value';
import { FieldMask, ObjectValue } from '../model/object_value';
import {
DeleteMutation,
FieldMask,
FieldTransform,
Mutation,
MutationResult,
Expand Down