@atproto/lexicon 0.2.2 → 0.3.0

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,27 @@
1
1
  # @atproto/lexicon
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1801](https://github.com/bluesky-social/atproto/pull/1801) [`ce49743d`](https://github.com/bluesky-social/atproto/commit/ce49743d7f8800d33116b88001d7b512553c2c89) Thanks [@gaearon](https://github.com/gaearon)! - Methods that accepts lexicons now take `LexiconDoc` type instead of `unknown`
8
+
9
+ ### Patch Changes
10
+
11
+ - [#1788](https://github.com/bluesky-social/atproto/pull/1788) [`84e2d4d2`](https://github.com/bluesky-social/atproto/commit/84e2d4d2b6694f344d80c18672c78b650189d423) Thanks [@bnewbold](https://github.com/bnewbold)! - update license to "MIT or Apache2"
12
+
13
+ - Updated dependencies [[`84e2d4d2`](https://github.com/bluesky-social/atproto/commit/84e2d4d2b6694f344d80c18672c78b650189d423)]:
14
+ - @atproto/common-web@0.2.3
15
+ - @atproto/syntax@0.1.4
16
+
17
+ ## 0.2.3
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [[`35d108ce`](https://github.com/bluesky-social/atproto/commit/35d108ce94866ce1b3d147cd0620a0ba1c4ebcd7)]:
22
+ - @atproto/common-web@0.2.2
23
+ - @atproto/syntax@0.1.3
24
+
3
25
  ## 0.2.2
4
26
 
5
27
  ### Patch Changes
package/LICENSE.txt ADDED
@@ -0,0 +1,7 @@
1
+ Dual MIT/Apache-2.0 License
2
+
3
+ Copyright (c) 2022-2023 Bluesky PBC, and Contributors
4
+
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
+
7
+ Downstream projects and end users may chose either license individually, or both together, at their discretion. The motivation for this dual-licensing is the additional software patent assurance provided by Apache 2.0.
package/README.md CHANGED
@@ -31,4 +31,9 @@ lex.assertValidXrpcOutput('com.example.query', {...})
31
31
 
32
32
  ## License
33
33
 
34
- MIT
34
+ This project is dual-licensed under MIT and Apache 2.0 terms:
35
+
36
+ - MIT license ([LICENSE-MIT.txt](https://github.com/bluesky-social/atproto/blob/main/LICENSE-MIT.txt) or http://opensource.org/licenses/MIT)
37
+ - Apache License, Version 2.0, ([LICENSE-APACHE.txt](https://github.com/bluesky-social/atproto/blob/main/LICENSE-APACHE.txt) or http://www.apache.org/licenses/LICENSE-2.0)
38
+
39
+ Downstream projects and end users may chose either license individually, or both together, at their discretion. The motivation for this dual-licensing is the additional software patent assurance provided by Apache 2.0.
package/dist/index.js CHANGED
@@ -8872,7 +8872,6 @@ __export(src_exports2, {
8872
8872
  BlobRef: () => BlobRef,
8873
8873
  InvalidLexiconError: () => InvalidLexiconError,
8874
8874
  LexiconDefNotFoundError: () => LexiconDefNotFoundError,
8875
- LexiconDocMalformedError: () => LexiconDocMalformedError,
8876
8875
  Lexicons: () => Lexicons,
8877
8876
  ValidationError: () => ValidationError,
8878
8877
  discriminatedObject: () => discriminatedObject,
@@ -8913,6 +8912,7 @@ __export(src_exports2, {
8913
8912
  lexXrpcSubscription: () => lexXrpcSubscription,
8914
8913
  lexXrpcSubscriptionMessage: () => lexXrpcSubscriptionMessage,
8915
8914
  lexiconDoc: () => lexiconDoc,
8915
+ parseLexiconDoc: () => parseLexiconDoc,
8916
8916
  stringifyLex: () => stringifyLex,
8917
8917
  typedJsonBlobRef: () => typedJsonBlobRef,
8918
8918
  untypedJsonBlobRef: () => untypedJsonBlobRef
@@ -13916,6 +13916,25 @@ var validateLanguage = (langTag) => {
13916
13916
  };
13917
13917
  var bcp47Regexp = /^((?<grandfathered>(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang))|((?<language>([A-Za-z]{2,3}(-(?<extlang>[A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-(?<script>[A-Za-z]{4}))?(-(?<region>[A-Za-z]{2}|[0-9]{3}))?(-(?<variant>[A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-(?<extension>[0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(?<privateUseA>x(-[A-Za-z0-9]{1,8})+))?)|(?<privateUseB>x(-[A-Za-z0-9]{1,8})+))$/;
13918
13918
 
13919
+ // ../common-web/src/did-doc.ts
13920
+ var verificationMethod = z.object({
13921
+ id: z.string(),
13922
+ type: z.string(),
13923
+ controller: z.string(),
13924
+ publicKeyMultibase: z.string().optional()
13925
+ });
13926
+ var service = z.object({
13927
+ id: z.string(),
13928
+ type: z.string(),
13929
+ serviceEndpoint: z.union([z.string(), z.record(z.unknown())])
13930
+ });
13931
+ var didDocument = z.object({
13932
+ id: z.string(),
13933
+ alsoKnownAs: z.array(z.string()).optional(),
13934
+ verificationMethod: z.array(verificationMethod).optional(),
13935
+ service: z.array(service).optional()
13936
+ });
13937
+
13919
13938
  // src/validators/formats.ts
13920
13939
  var import_iso_datestring_validator = __toESM(require_dist());
13921
13940
  function datetime(path, value) {
@@ -14764,15 +14783,10 @@ var discriminatedObject = z.object({ $type: z.string() });
14764
14783
  function isDiscriminatedObject(value) {
14765
14784
  return discriminatedObject.safeParse(value).success;
14766
14785
  }
14767
- var LexiconDocMalformedError = class extends Error {
14768
- constructor(message, schemaDef, issues) {
14769
- super(message);
14770
- this.schemaDef = schemaDef;
14771
- this.issues = issues;
14772
- this.schemaDef = schemaDef;
14773
- this.issues = issues;
14774
- }
14775
- };
14786
+ function parseLexiconDoc(v) {
14787
+ lexiconDoc.parse(v);
14788
+ return v;
14789
+ }
14776
14790
  var ValidationError = class extends Error {
14777
14791
  };
14778
14792
  var InvalidLexiconError = class extends Error {
@@ -14853,23 +14867,13 @@ var Lexicons = class {
14853
14867
  }
14854
14868
  }
14855
14869
  add(doc) {
14856
- try {
14857
- lexiconDoc.parse(doc);
14858
- } catch (e) {
14859
- if (e instanceof ZodError) {
14860
- throw new LexiconDocMalformedError(`Failed to parse schema definition ${doc.id}`, doc, e.issues);
14861
- } else {
14862
- throw e;
14863
- }
14864
- }
14865
- const validatedDoc = doc;
14866
- const uri2 = toLexUri(validatedDoc.id);
14870
+ const uri2 = toLexUri(doc.id);
14867
14871
  if (this.docs.has(uri2)) {
14868
14872
  throw new Error(`${uri2} has already been registered`);
14869
14873
  }
14870
- resolveRefUris(validatedDoc, uri2);
14871
- this.docs.set(uri2, validatedDoc);
14872
- for (const [defUri, def2] of iterDefs(validatedDoc)) {
14874
+ resolveRefUris(doc, uri2);
14875
+ this.docs.set(uri2, doc);
14876
+ for (const [defUri, def2] of iterDefs(doc)) {
14873
14877
  this.defs.set(defUri, def2);
14874
14878
  }
14875
14879
  }
@@ -15046,7 +15050,6 @@ var jsonStringToLex = (val) => {
15046
15050
  BlobRef,
15047
15051
  InvalidLexiconError,
15048
15052
  LexiconDefNotFoundError,
15049
- LexiconDocMalformedError,
15050
15053
  Lexicons,
15051
15054
  ValidationError,
15052
15055
  discriminatedObject,
@@ -15087,6 +15090,7 @@ var jsonStringToLex = (val) => {
15087
15090
  lexXrpcSubscription,
15088
15091
  lexXrpcSubscriptionMessage,
15089
15092
  lexiconDoc,
15093
+ parseLexiconDoc,
15090
15094
  stringifyLex,
15091
15095
  typedJsonBlobRef,
15092
15096
  untypedJsonBlobRef