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