@atproto/common 0.5.13 → 0.5.15

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @atproto/common
2
2
 
3
+ ## 0.5.15
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`6a88461`](https://github.com/bluesky-social/atproto/commit/6a88461c5aa9486269f0769b7a3d52f384581786)]:
8
+ - @atproto/lex-data@0.0.14
9
+ - @atproto/common-web@0.4.19
10
+ - @atproto/lex-cbor@0.0.15
11
+
12
+ ## 0.5.14
13
+
14
+ ### Patch Changes
15
+
16
+ - [#4689](https://github.com/bluesky-social/atproto/pull/4689) [`f7c2610`](https://github.com/bluesky-social/atproto/commit/f7c26103a6d4e24e5bedbb6fd908be140420e0dd) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Remove unnecessary validation of already properly formatted ISO date string
17
+
18
+ - Updated dependencies [[`52834ab`](https://github.com/bluesky-social/atproto/commit/52834aba182da8df3611fd9dff924e6c6a3973a7), [`f7c2610`](https://github.com/bluesky-social/atproto/commit/f7c26103a6d4e24e5bedbb6fd908be140420e0dd), [`f7c2610`](https://github.com/bluesky-social/atproto/commit/f7c26103a6d4e24e5bedbb6fd908be140420e0dd), [`52834ab`](https://github.com/bluesky-social/atproto/commit/52834aba182da8df3611fd9dff924e6c6a3973a7)]:
19
+ - @atproto/lex-data@0.0.13
20
+ - @atproto/common-web@0.4.18
21
+ - @atproto/lex-cbor@0.0.14
22
+
3
23
  ## 0.5.13
4
24
 
5
25
  ### Patch Changes
package/dist/dates.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare function toSimplifiedISOSafe(dateStr: string): `${string}-${string}-${string}T${string}:${string}:${string}Z`;
1
+ export declare function toSimplifiedISOSafe(dateStr: string): string;
2
2
  //# sourceMappingURL=dates.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dates.d.ts","sourceRoot":"","sources":["../src/dates.ts"],"names":[],"mappings":"AAIA,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,kEAWlD"}
1
+ {"version":3,"file":"dates.d.ts","sourceRoot":"","sources":["../src/dates.ts"],"names":[],"mappings":"AAEA,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,UAiBlD"}
package/dist/dates.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toSimplifiedISOSafe = toSimplifiedISOSafe;
4
- const iso_datestring_validator_1 = require("iso-datestring-validator");
5
4
  // Normalize date strings to simplified ISO so that the lexical sort preserves temporal sort.
6
5
  // Rather than failing on an invalid date format, returns valid unix epoch.
7
6
  function toSimplifiedISOSafe(dateStr) {
@@ -10,8 +9,12 @@ function toSimplifiedISOSafe(dateStr) {
10
9
  return new Date(0).toISOString();
11
10
  }
12
11
  const iso = date.toISOString();
13
- if (!(0, iso_datestring_validator_1.isValidISODateString)(iso)) {
14
- // Occurs in rare cases, e.g. where resulting UTC year is negative. These also don't preserve lexical sort.
12
+ // Date.toISOString() always returns `YYYY-MM-DDTHH:mm:ss.sssZ` or
13
+ // `±YYYYYY-MM-DDTHH:mm:ss.sssZ`
14
+ // (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
15
+ // However, the leading `±` and 6 digit year can break lexical sorting, so we
16
+ // need to catch those cases and return a safe value.
17
+ if (iso.startsWith('-') || iso.startsWith('+')) {
15
18
  return new Date(0).toISOString();
16
19
  }
17
20
  return iso; // YYYY-MM-DDTHH:mm:ss.sssZ
package/dist/dates.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"dates.js","sourceRoot":"","sources":["../src/dates.ts"],"names":[],"mappings":";;AAIA,kDAWC;AAfD,uEAA+D;AAE/D,6FAA6F;AAC7F,2EAA2E;AAC3E,SAAgB,mBAAmB,CAAC,OAAe;IACjD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,CAAA;IAC9B,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;QAC1B,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;IAClC,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,EAAE,CAAA;IAC9B,IAAI,CAAC,IAAA,+CAAoB,EAAC,GAAG,CAAC,EAAE,CAAC;QAC/B,2GAA2G;QAC3G,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;IAClC,CAAC;IACD,OAAO,GAAG,CAAA,CAAC,2BAA2B;AACxC,CAAC","sourcesContent":["import { isValidISODateString } from 'iso-datestring-validator'\n\n// Normalize date strings to simplified ISO so that the lexical sort preserves temporal sort.\n// Rather than failing on an invalid date format, returns valid unix epoch.\nexport function toSimplifiedISOSafe(dateStr: string) {\n const date = new Date(dateStr)\n if (isNaN(date.getTime())) {\n return new Date(0).toISOString()\n }\n const iso = date.toISOString()\n if (!isValidISODateString(iso)) {\n // Occurs in rare cases, e.g. where resulting UTC year is negative. These also don't preserve lexical sort.\n return new Date(0).toISOString()\n }\n return iso // YYYY-MM-DDTHH:mm:ss.sssZ\n}\n"]}
1
+ {"version":3,"file":"dates.js","sourceRoot":"","sources":["../src/dates.ts"],"names":[],"mappings":";;AAEA,kDAiBC;AAnBD,6FAA6F;AAC7F,2EAA2E;AAC3E,SAAgB,mBAAmB,CAAC,OAAe;IACjD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,CAAA;IAC9B,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;QAC1B,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;IAClC,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,EAAE,CAAA;IAE9B,kEAAkE;IAClE,gCAAgC;IAChC,sGAAsG;IACtG,6EAA6E;IAC7E,qDAAqD;IACrD,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;IAClC,CAAC;IAED,OAAO,GAAG,CAAA,CAAC,2BAA2B;AACxC,CAAC","sourcesContent":["// Normalize date strings to simplified ISO so that the lexical sort preserves temporal sort.\n// Rather than failing on an invalid date format, returns valid unix epoch.\nexport function toSimplifiedISOSafe(dateStr: string) {\n const date = new Date(dateStr)\n if (isNaN(date.getTime())) {\n return new Date(0).toISOString()\n }\n const iso = date.toISOString()\n\n // Date.toISOString() always returns `YYYY-MM-DDTHH:mm:ss.sssZ` or\n // `±YYYYYY-MM-DDTHH:mm:ss.sssZ`\n // (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)\n // However, the leading `±` and 6 digit year can break lexical sorting, so we\n // need to catch those cases and return a safe value.\n if (iso.startsWith('-') || iso.startsWith('+')) {\n return new Date(0).toISOString()\n }\n\n return iso // YYYY-MM-DDTHH:mm:ss.sssZ\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/common",
3
- "version": "0.5.13",
3
+ "version": "0.5.15",
4
4
  "license": "MIT",
5
5
  "description": "Shared web-platform-friendly code for atproto libraries",
6
6
  "keywords": [
@@ -18,12 +18,11 @@
18
18
  "node": ">=18.7.0"
19
19
  },
20
20
  "dependencies": {
21
- "iso-datestring-validator": "^2.2.2",
22
21
  "multiformats": "^9.9.0",
23
22
  "pino": "^8.21.0",
24
- "@atproto/common-web": "^0.4.17",
25
- "@atproto/lex-cbor": "^0.0.13",
26
- "@atproto/lex-data": "^0.0.12"
23
+ "@atproto/common-web": "^0.4.19",
24
+ "@atproto/lex-data": "^0.0.14",
25
+ "@atproto/lex-cbor": "^0.0.15"
27
26
  },
28
27
  "devDependencies": {
29
28
  "jest": "^28.1.2",
package/src/dates.ts CHANGED
@@ -1,5 +1,3 @@
1
- import { isValidISODateString } from 'iso-datestring-validator'
2
-
3
1
  // Normalize date strings to simplified ISO so that the lexical sort preserves temporal sort.
4
2
  // Rather than failing on an invalid date format, returns valid unix epoch.
5
3
  export function toSimplifiedISOSafe(dateStr: string) {
@@ -8,9 +6,15 @@ export function toSimplifiedISOSafe(dateStr: string) {
8
6
  return new Date(0).toISOString()
9
7
  }
10
8
  const iso = date.toISOString()
11
- if (!isValidISODateString(iso)) {
12
- // Occurs in rare cases, e.g. where resulting UTC year is negative. These also don't preserve lexical sort.
9
+
10
+ // Date.toISOString() always returns `YYYY-MM-DDTHH:mm:ss.sssZ` or
11
+ // `±YYYYYY-MM-DDTHH:mm:ss.sssZ`
12
+ // (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
13
+ // However, the leading `±` and 6 digit year can break lexical sorting, so we
14
+ // need to catch those cases and return a safe value.
15
+ if (iso.startsWith('-') || iso.startsWith('+')) {
13
16
  return new Date(0).toISOString()
14
17
  }
18
+
15
19
  return iso // YYYY-MM-DDTHH:mm:ss.sssZ
16
20
  }