@atproto/lexicon 0.6.0 → 0.6.1
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,15 @@
|
|
|
1
1
|
# @atproto/lexicon
|
|
2
2
|
|
|
3
|
+
## 0.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#4571](https://github.com/bluesky-social/atproto/pull/4571) [`99963d0`](https://github.com/bluesky-social/atproto/commit/99963d002a9e030e79aed5fba700e0a68f31e101) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Refactor uri validation to use `@atproto/syntax`
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`99963d0`](https://github.com/bluesky-social/atproto/commit/99963d002a9e030e79aed5fba700e0a68f31e101), [`7310b97`](https://github.com/bluesky-social/atproto/commit/7310b9704de678a3b389a741784d58bb7f79b10b), [`99963d0`](https://github.com/bluesky-social/atproto/commit/99963d002a9e030e79aed5fba700e0a68f31e101), [`99963d0`](https://github.com/bluesky-social/atproto/commit/99963d002a9e030e79aed5fba700e0a68f31e101), [`99963d0`](https://github.com/bluesky-social/atproto/commit/99963d002a9e030e79aed5fba700e0a68f31e101)]:
|
|
10
|
+
- @atproto/syntax@0.4.3
|
|
11
|
+
- @atproto/common-web@0.4.13
|
|
12
|
+
|
|
3
13
|
## 0.6.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
package/LICENSE.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Dual MIT/Apache-2.0 License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2022-
|
|
3
|
+
Copyright (c) 2022-2026 Bluesky Social PBC, and Contributors
|
|
4
4
|
|
|
5
5
|
Except as otherwise noted in individual files, this software is licensed under the MIT license (<http://opensource.org/licenses/MIT>), or the Apache License, Version 2.0 (<http://www.apache.org/licenses/LICENSE-2.0>).
|
|
6
6
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formats.d.ts","sourceRoot":"","sources":["../../src/validators/formats.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formats.d.ts","sourceRoot":"","sources":["../../src/validators/formats.ts"],"names":[],"mappings":"AAcA,OAAO,EAAmB,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAE5D,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,CActE;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAQjE;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAWnE;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAWjE;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAWpE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAc1E;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAYlE;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAUjE;AAGD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAUtE;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,CASjE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAUvE"}
|
|
@@ -32,8 +32,7 @@ function datetime(path, value) {
|
|
|
32
32
|
return { success: true, value };
|
|
33
33
|
}
|
|
34
34
|
function uri(path, value) {
|
|
35
|
-
|
|
36
|
-
if (!isUri) {
|
|
35
|
+
if (!(0, syntax_1.isValidUri)(value)) {
|
|
37
36
|
return {
|
|
38
37
|
success: false,
|
|
39
38
|
error: new types_1.ValidationError(`${path} must be a uri`),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formats.js","sourceRoot":"","sources":["../../src/validators/formats.ts"],"names":[],"mappings":";AAAA,yCAAyC;;
|
|
1
|
+
{"version":3,"file":"formats.js","sourceRoot":"","sources":["../../src/validators/formats.ts"],"names":[],"mappings":";AAAA,yCAAyC;;AAgBzC,4BAcC;AAED,kBAQC;AAED,sBAWC;AAED,kBAWC;AAED,wBAWC;AAED,oCAcC;AAED,oBAYC;AAED,kBAUC;AAGD,4BAUC;AAED,kBASC;AAED,8BAUC;AA3JD,uEAA+D;AAC/D,0CAAsC;AACtC,oDAAsD;AACtD,4CAQwB;AACxB,oCAA4D;AAE5D,SAAgB,QAAQ,CAAC,IAAY,EAAE,KAAa;IAClD,IAAI,CAAC;QACH,IAAI,CAAC,IAAA,+CAAoB,EAAC,KAAK,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,EAAE,CAAA;QACnB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,IAAI,uBAAe,CACxB,GAAG,IAAI,iEAAiE,CACzE;SACF,CAAA;IACH,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;AACjC,CAAC;AAED,SAAgB,GAAG,CAAC,IAAY,EAAE,KAAa;IAC7C,IAAI,CAAC,IAAA,mBAAU,EAAC,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,IAAI,uBAAe,CAAC,GAAG,IAAI,gBAA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,EAAE,IAAI,uBAAe,CACxB,GAAG,IAAI,4CAA4C,CACpD;KACF,CAAA;AACH,CAAC;AAED,SAAgB,GAAG,CAAC,IAAY,EAAE,KAAa;IAC7C,IAAI,IAAA,mBAAU,EAAC,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;IACjC,CAAC;IAED,OAAO;QACL,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,IAAI,uBAAe,CAAC,GAAG,IAAI,sBAAsB,CAAC;KAC1D,CAAA;AACH,CAAC;AAED,SAAgB,SAAS,CAAC,IAAY,EAAE,KAAa;IACnD,IAAI,CAAC;QACH,IAAA,6BAAoB,EAAC,KAAK,CAAC,CAAA;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,IAAI,uBAAe,CAAC,GAAG,IAAI,6BAA6B,CAAC;SACjE,CAAA;IACH,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;AACjC,CAAC","sourcesContent":["/* eslint-disable import/no-deprecated */\n\nimport { isValidISODateString } from 'iso-datestring-validator'\nimport { CID } from 'multiformats/cid'\nimport { validateLanguage } from '@atproto/common-web'\nimport {\n ensureValidAtUri,\n ensureValidDid,\n ensureValidHandle,\n ensureValidRecordKey,\n isValidNsid,\n isValidTid,\n isValidUri,\n} from '@atproto/syntax'\nimport { ValidationError, ValidationResult } from '../types'\n\nexport function datetime(path: string, value: string): ValidationResult {\n try {\n if (!isValidISODateString(value)) {\n throw new Error()\n }\n } catch {\n return {\n success: false,\n error: new ValidationError(\n `${path} must be an valid atproto datetime (both RFC-3339 and ISO-8601)`,\n ),\n }\n }\n return { success: true, value }\n}\n\nexport function uri(path: string, value: string): ValidationResult {\n if (!isValidUri(value)) {\n return {\n success: false,\n error: new ValidationError(`${path} must be a uri`),\n }\n }\n return { success: true, value }\n}\n\nexport function atUri(path: string, value: string): ValidationResult {\n try {\n ensureValidAtUri(value)\n } catch {\n return {\n success: false,\n error: new ValidationError(`${path} must be a valid at-uri`),\n }\n }\n\n return { success: true, value }\n}\n\nexport function did(path: string, value: string): ValidationResult {\n try {\n ensureValidDid(value)\n } catch {\n return {\n success: false,\n error: new ValidationError(`${path} must be a valid did`),\n }\n }\n\n return { success: true, value }\n}\n\nexport function handle(path: string, value: string): ValidationResult {\n try {\n ensureValidHandle(value)\n } catch {\n return {\n success: false,\n error: new ValidationError(`${path} must be a valid handle`),\n }\n }\n\n return { success: true, value }\n}\n\nexport function atIdentifier(path: string, value: string): ValidationResult {\n // We can discriminate based on the \"did:\" prefix\n if (value.startsWith('did:')) {\n const didResult = did(path, value)\n if (didResult.success) return didResult\n } else {\n const handleResult = handle(path, value)\n if (handleResult.success) return handleResult\n }\n\n return {\n success: false,\n error: new ValidationError(`${path} must be a valid did or a handle`),\n }\n}\n\nexport function nsid(path: string, value: string): ValidationResult {\n if (isValidNsid(value)) {\n return {\n success: true,\n value,\n }\n } else {\n return {\n success: false,\n error: new ValidationError(`${path} must be a valid nsid`),\n }\n }\n}\n\nexport function cid(path: string, value: string): ValidationResult {\n try {\n CID.parse(value)\n } catch {\n return {\n success: false,\n error: new ValidationError(`${path} must be a cid string`),\n }\n }\n return { success: true, value }\n}\n\n// The language format validates well-formed BCP 47 language tags: https://www.rfc-editor.org/info/bcp47\nexport function language(path: string, value: string): ValidationResult {\n if (validateLanguage(value)) {\n return { success: true, value }\n }\n return {\n success: false,\n error: new ValidationError(\n `${path} must be a well-formed BCP 47 language tag`,\n ),\n }\n}\n\nexport function tid(path: string, value: string): ValidationResult {\n if (isValidTid(value)) {\n return { success: true, value }\n }\n\n return {\n success: false,\n error: new ValidationError(`${path} must be a valid TID`),\n }\n}\n\nexport function recordKey(path: string, value: string): ValidationResult {\n try {\n ensureValidRecordKey(value)\n } catch {\n return {\n success: false,\n error: new ValidationError(`${path} must be a valid Record Key`),\n }\n }\n return { success: true, value }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/lexicon",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "atproto Lexicon schema language library",
|
|
6
6
|
"keywords": [
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"iso-datestring-validator": "^2.2.2",
|
|
20
20
|
"multiformats": "^9.9.0",
|
|
21
21
|
"zod": "^3.23.8",
|
|
22
|
-
"@atproto/common-web": "^0.4.
|
|
23
|
-
"@atproto/syntax": "^0.4.
|
|
22
|
+
"@atproto/common-web": "^0.4.13",
|
|
23
|
+
"@atproto/syntax": "^0.4.3"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"jest": "^28.1.2",
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
ensureValidRecordKey,
|
|
11
11
|
isValidNsid,
|
|
12
12
|
isValidTid,
|
|
13
|
+
isValidUri,
|
|
13
14
|
} from '@atproto/syntax'
|
|
14
15
|
import { ValidationError, ValidationResult } from '../types'
|
|
15
16
|
|
|
@@ -30,8 +31,7 @@ export function datetime(path: string, value: string): ValidationResult {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
export function uri(path: string, value: string): ValidationResult {
|
|
33
|
-
|
|
34
|
-
if (!isUri) {
|
|
34
|
+
if (!isValidUri(value)) {
|
|
35
35
|
return {
|
|
36
36
|
success: false,
|
|
37
37
|
error: new ValidationError(`${path} must be a uri`),
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"root":["./tests/general.test.ts","./tests/_scaffolds/lexicons.ts"],"version":"5.8.3"}
|