@firebase/firestore 4.7.5 → 4.7.6-canary.144bc3709

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.
@@ -3,9 +3,10 @@ import { Component } from '@firebase/component';
3
3
  import { Logger, LogLevel } from '@firebase/logger';
4
4
  import { inspect } from 'util';
5
5
  import { FirebaseError, getDefaultEmulatorHostnameAndPort, createMockUserToken, getModularInstance, deepEqual } from '@firebase/util';
6
+ import { Integer } from '@firebase/webchannel-wrapper/bloom-blob';
6
7
  import { randomBytes as randomBytes$1 } from 'crypto';
7
8
 
8
- const version$1 = "4.7.5";
9
+ const version$1 = "4.7.6-canary.144bc3709";
9
10
 
10
11
  /**
11
12
  * @license
@@ -58,7 +59,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
58
59
  User.FIRST_PARTY = new User('first-party-uid');
59
60
  User.MOCK_USER = new User('mock-user');
60
61
 
61
- const version = "11.0.2";
62
+ const version = "11.2.0-canary.144bc3709";
62
63
 
63
64
  /**
64
65
  * @license
@@ -800,25 +801,53 @@ class BasePath {
800
801
  toArray() {
801
802
  return this.segments.slice(this.offset, this.limit());
802
803
  }
804
+ /**
805
+ * Compare 2 paths segment by segment, prioritizing numeric IDs
806
+ * (e.g., "__id123__") in numeric ascending order, followed by string
807
+ * segments in lexicographical order.
808
+ */
803
809
  static comparator(p1, p2) {
804
810
  const len = Math.min(p1.length, p2.length);
805
811
  for (let i = 0; i < len; i++) {
806
- const left = p1.get(i);
807
- const right = p2.get(i);
808
- if (left < right) {
809
- return -1;
810
- }
811
- if (left > right) {
812
- return 1;
812
+ const comparison = BasePath.compareSegments(p1.get(i), p2.get(i));
813
+ if (comparison !== 0) {
814
+ return comparison;
813
815
  }
814
816
  }
815
- if (p1.length < p2.length) {
817
+ return Math.sign(p1.length - p2.length);
818
+ }
819
+ static compareSegments(lhs, rhs) {
820
+ const isLhsNumeric = BasePath.isNumericId(lhs);
821
+ const isRhsNumeric = BasePath.isNumericId(rhs);
822
+ if (isLhsNumeric && !isRhsNumeric) {
823
+ // Only lhs is numeric
816
824
  return -1;
817
825
  }
818
- if (p1.length > p2.length) {
826
+ else if (!isLhsNumeric && isRhsNumeric) {
827
+ // Only rhs is numeric
819
828
  return 1;
820
829
  }
821
- return 0;
830
+ else if (isLhsNumeric && isRhsNumeric) {
831
+ // both numeric
832
+ return BasePath.extractNumericId(lhs).compare(BasePath.extractNumericId(rhs));
833
+ }
834
+ else {
835
+ // both non-numeric
836
+ if (lhs < rhs) {
837
+ return -1;
838
+ }
839
+ if (lhs > rhs) {
840
+ return 1;
841
+ }
842
+ return 0;
843
+ }
844
+ }
845
+ // Checks if a segment is a numeric ID (starts with "__id" and ends with "__").
846
+ static isNumericId(segment) {
847
+ return segment.startsWith('__id') && segment.endsWith('__');
848
+ }
849
+ static extractNumericId(segment) {
850
+ return Integer.fromString(segment.substring(4, segment.length - 2));
822
851
  }
823
852
  }
824
853
  /**