@atproto/common 0.5.13 → 0.5.14
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 +11 -0
- package/dist/dates.d.ts +1 -1
- package/dist/dates.d.ts.map +1 -1
- package/dist/dates.js +6 -3
- package/dist/dates.js.map +1 -1
- package/package.json +4 -5
- package/src/dates.ts +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @atproto/common
|
|
2
2
|
|
|
3
|
+
## 0.5.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#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
|
|
8
|
+
|
|
9
|
+
- 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)]:
|
|
10
|
+
- @atproto/lex-data@0.0.13
|
|
11
|
+
- @atproto/common-web@0.4.18
|
|
12
|
+
- @atproto/lex-cbor@0.0.14
|
|
13
|
+
|
|
3
14
|
## 0.5.13
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/dates.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function toSimplifiedISOSafe(dateStr: string):
|
|
1
|
+
export declare function toSimplifiedISOSafe(dateStr: string): string;
|
|
2
2
|
//# sourceMappingURL=dates.d.ts.map
|
package/dist/dates.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dates.d.ts","sourceRoot":"","sources":["../src/dates.ts"],"names":[],"mappings":"
|
|
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
|
-
|
|
14
|
-
|
|
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":";;
|
|
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.
|
|
3
|
+
"version": "0.5.14",
|
|
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.
|
|
25
|
-
"@atproto/lex-cbor": "^0.0.
|
|
26
|
-
"@atproto/lex-data": "^0.0.
|
|
23
|
+
"@atproto/common-web": "^0.4.18",
|
|
24
|
+
"@atproto/lex-cbor": "^0.0.14",
|
|
25
|
+
"@atproto/lex-data": "^0.0.13"
|
|
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
|
-
|
|
12
|
-
|
|
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
|
}
|