@atproto/lexicon 0.3.3 → 0.4.1-rc.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.
Files changed (62) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/blob-refs.d.ts +5 -4
  3. package/dist/blob-refs.d.ts.map +1 -0
  4. package/dist/blob-refs.js +82 -0
  5. package/dist/blob-refs.js.map +1 -0
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +20 -15097
  9. package/dist/index.js.map +1 -7
  10. package/dist/lexicons.d.ts +54 -2
  11. package/dist/lexicons.d.ts.map +1 -0
  12. package/dist/lexicons.js +242 -0
  13. package/dist/lexicons.js.map +1 -0
  14. package/dist/serialize.d.ts +1 -0
  15. package/dist/serialize.d.ts.map +1 -0
  16. package/dist/serialize.js +80 -0
  17. package/dist/serialize.js.map +1 -0
  18. package/dist/types.d.ts +4864 -4103
  19. package/dist/types.d.ts.map +1 -0
  20. package/dist/types.js +333 -0
  21. package/dist/types.js.map +1 -0
  22. package/dist/util.d.ts +3 -4
  23. package/dist/util.d.ts.map +1 -0
  24. package/dist/util.js +65 -0
  25. package/dist/util.js.map +1 -0
  26. package/dist/validation.d.ts +1 -0
  27. package/dist/validation.d.ts.map +1 -0
  28. package/dist/validation.js +49 -0
  29. package/dist/validation.js.map +1 -0
  30. package/dist/validators/blob.d.ts +1 -0
  31. package/dist/validators/blob.d.ts.map +1 -0
  32. package/dist/validators/blob.js +17 -0
  33. package/dist/validators/blob.js.map +1 -0
  34. package/dist/validators/complex.d.ts +3 -1
  35. package/dist/validators/complex.d.ts.map +1 -0
  36. package/dist/validators/complex.js +196 -0
  37. package/dist/validators/complex.js.map +1 -0
  38. package/dist/validators/formats.d.ts +3 -0
  39. package/dist/validators/formats.d.ts.map +1 -0
  40. package/dist/validators/formats.js +151 -0
  41. package/dist/validators/formats.js.map +1 -0
  42. package/dist/validators/primitives.d.ts +1 -0
  43. package/dist/validators/primitives.d.ts.map +1 -0
  44. package/dist/validators/primitives.js +293 -0
  45. package/dist/validators/primitives.js.map +1 -0
  46. package/dist/validators/xrpc.d.ts +1 -0
  47. package/dist/validators/xrpc.d.ts.map +1 -0
  48. package/dist/validators/xrpc.js +67 -0
  49. package/dist/validators/xrpc.js.map +1 -0
  50. package/jest.config.js +4 -3
  51. package/package.json +10 -9
  52. package/src/lexicons.ts +18 -3
  53. package/src/types.ts +2 -0
  54. package/src/util.ts +2 -95
  55. package/src/validation.ts +18 -5
  56. package/src/validators/complex.ts +102 -11
  57. package/src/validators/formats.ts +28 -0
  58. package/src/validators/primitives.ts +4 -0
  59. package/tsconfig.build.json +6 -2
  60. package/tsconfig.json +3 -10
  61. package/tsconfig.tests.json +7 -0
  62. package/build.js +0 -14
package/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # @atproto/lexicon
2
2
 
3
+ ## 0.4.1-rc.0
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2483](https://github.com/bluesky-social/atproto/pull/2483) [`2ded0156b`](https://github.com/bluesky-social/atproto/commit/2ded0156b9adf33b9cce66583a375bff922d383b) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Add the ability to instantiate a Lexicon from an iterable, and to use a Lexicon as iterable.
8
+
9
+ - [#2483](https://github.com/bluesky-social/atproto/pull/2483) [`2ded0156b`](https://github.com/bluesky-social/atproto/commit/2ded0156b9adf33b9cce66583a375bff922d383b) Thanks [@matthieusieben](https://github.com/matthieusieben)! - **New Features**:
10
+
11
+ 1. Improved Separation of Concerns: We've restructured the XRPC HTTP call
12
+ dispatcher into a distinct class. This means cleaner code organization and
13
+ better clarity on responsibilities.
14
+ 2. Enhanced Evolutivity: With this refactor, the XRPC client is now more
15
+ adaptable to various use cases. You can easily extend and customize the
16
+ dispatcher perform session management, retries, and more.
17
+
18
+ **Compatibility**:
19
+
20
+ Most of the changes introduced in this version are backward-compatible. However,
21
+ there are a couple of breaking changes you should be aware of:
22
+
23
+ - Customizing `fetchHandler`: The ability to customize the fetchHandler on the
24
+ XRPC Client and AtpAgent classes has been modified. Please review your code if
25
+ you rely on custom fetch handlers.
26
+ - Managing Sessions: Previously, you had the ability to manage sessions directly
27
+ through AtpAgent instances. Now, session management must be handled through a
28
+ dedicated `SessionManager` instance. If you were making authenticated
29
+ requests, you'll need to update your code to use explicit session management.
30
+ - The `fetch()` method, as well as WhatWG compliant `Request` and `Headers`
31
+ constructors, must be globally available in your environment.
32
+
33
+ ## 0.4.0
34
+
35
+ ### Minor Changes
36
+
37
+ - [#2169](https://github.com/bluesky-social/atproto/pull/2169) [`f689bd51a`](https://github.com/bluesky-social/atproto/commit/f689bd51a2f4e02d4eca40eb2568a1fcb95494e9) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Build system rework, stop bundling dependencies.
38
+
39
+ ### Patch Changes
40
+
41
+ - Updated dependencies [[`f689bd51a`](https://github.com/bluesky-social/atproto/commit/f689bd51a2f4e02d4eca40eb2568a1fcb95494e9)]:
42
+ - @atproto/common-web@0.3.0
43
+ - @atproto/syntax@0.3.0
44
+
3
45
  ## 0.3.3
4
46
 
5
47
  ### Patch Changes
@@ -21,11 +21,11 @@ export declare const untypedJsonBlobRef: z.ZodObject<{
21
21
  cid: z.ZodString;
22
22
  mimeType: z.ZodString;
23
23
  }, "strict", z.ZodTypeAny, {
24
- cid: string;
25
24
  mimeType: string;
26
- }, {
27
25
  cid: string;
26
+ }, {
28
27
  mimeType: string;
28
+ cid: string;
29
29
  }>;
30
30
  export type UntypedJsonBlobRef = z.infer<typeof untypedJsonBlobRef>;
31
31
  export declare const jsonBlobRef: z.ZodUnion<[z.ZodObject<{
@@ -47,11 +47,11 @@ export declare const jsonBlobRef: z.ZodUnion<[z.ZodObject<{
47
47
  cid: z.ZodString;
48
48
  mimeType: z.ZodString;
49
49
  }, "strict", z.ZodTypeAny, {
50
- cid: string;
51
50
  mimeType: string;
52
- }, {
53
51
  cid: string;
52
+ }, {
54
53
  mimeType: string;
54
+ cid: string;
55
55
  }>]>;
56
56
  export type JsonBlobRef = z.infer<typeof jsonBlobRef>;
57
57
  export declare class BlobRef {
@@ -65,3 +65,4 @@ export declare class BlobRef {
65
65
  ipld(): TypedJsonBlobRef;
66
66
  toJSON(): unknown;
67
67
  }
68
+ //# sourceMappingURL=blob-refs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blob-refs.d.ts","sourceRoot":"","sources":["../src/blob-refs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;EAOlB,CAAA;AACX,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAE/D,eAAO,MAAM,kBAAkB;;;;;;;;;EAKpB,CAAA;AACX,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAEnE,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;IAAkD,CAAA;AAC1E,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAA;AAErD,qBAAa,OAAO;IAIT,GAAG,EAAE,GAAG;IACR,QAAQ,EAAE,MAAM;IAChB,IAAI,EAAE,MAAM;IALd,QAAQ,EAAE,WAAW,CAAA;gBAGnB,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,WAAW;IAUxB,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI;IAO9C,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO;IAQ9C,IAAI,IAAI,gBAAgB;IASxB,MAAM;CAGP"}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BlobRef = exports.jsonBlobRef = exports.untypedJsonBlobRef = exports.typedJsonBlobRef = void 0;
4
+ const common_web_1 = require("@atproto/common-web");
5
+ const cid_1 = require("multiformats/cid");
6
+ const zod_1 = require("zod");
7
+ exports.typedJsonBlobRef = zod_1.z
8
+ .object({
9
+ $type: zod_1.z.literal('blob'),
10
+ ref: common_web_1.schema.cid,
11
+ mimeType: zod_1.z.string(),
12
+ size: zod_1.z.number(),
13
+ })
14
+ .strict();
15
+ exports.untypedJsonBlobRef = zod_1.z
16
+ .object({
17
+ cid: zod_1.z.string(),
18
+ mimeType: zod_1.z.string(),
19
+ })
20
+ .strict();
21
+ exports.jsonBlobRef = zod_1.z.union([exports.typedJsonBlobRef, exports.untypedJsonBlobRef]);
22
+ class BlobRef {
23
+ constructor(ref, mimeType, size, original) {
24
+ Object.defineProperty(this, "ref", {
25
+ enumerable: true,
26
+ configurable: true,
27
+ writable: true,
28
+ value: ref
29
+ });
30
+ Object.defineProperty(this, "mimeType", {
31
+ enumerable: true,
32
+ configurable: true,
33
+ writable: true,
34
+ value: mimeType
35
+ });
36
+ Object.defineProperty(this, "size", {
37
+ enumerable: true,
38
+ configurable: true,
39
+ writable: true,
40
+ value: size
41
+ });
42
+ Object.defineProperty(this, "original", {
43
+ enumerable: true,
44
+ configurable: true,
45
+ writable: true,
46
+ value: void 0
47
+ });
48
+ this.original = original ?? {
49
+ $type: 'blob',
50
+ ref,
51
+ mimeType,
52
+ size,
53
+ };
54
+ }
55
+ static asBlobRef(obj) {
56
+ if (common_web_1.check.is(obj, exports.jsonBlobRef)) {
57
+ return BlobRef.fromJsonRef(obj);
58
+ }
59
+ return null;
60
+ }
61
+ static fromJsonRef(json) {
62
+ if (common_web_1.check.is(json, exports.typedJsonBlobRef)) {
63
+ return new BlobRef(json.ref, json.mimeType, json.size);
64
+ }
65
+ else {
66
+ return new BlobRef(cid_1.CID.parse(json.cid), json.mimeType, -1, json);
67
+ }
68
+ }
69
+ ipld() {
70
+ return {
71
+ $type: 'blob',
72
+ ref: this.ref,
73
+ mimeType: this.mimeType,
74
+ size: this.size,
75
+ };
76
+ }
77
+ toJSON() {
78
+ return (0, common_web_1.ipldToJson)(this.ipld());
79
+ }
80
+ }
81
+ exports.BlobRef = BlobRef;
82
+ //# sourceMappingURL=blob-refs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blob-refs.js","sourceRoot":"","sources":["../src/blob-refs.ts"],"names":[],"mappings":";;;AAAA,oDAA+D;AAC/D,0CAAsC;AACtC,6BAAuB;AAEV,QAAA,gBAAgB,GAAG,OAAC;KAC9B,MAAM,CAAC;IACN,KAAK,EAAE,OAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACxB,GAAG,EAAE,mBAAM,CAAC,GAAG;IACf,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;IACpB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;CACjB,CAAC;KACD,MAAM,EAAE,CAAA;AAGE,QAAA,kBAAkB,GAAG,OAAC;KAChC,MAAM,CAAC;IACN,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;IACf,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;CACrB,CAAC;KACD,MAAM,EAAE,CAAA;AAGE,QAAA,WAAW,GAAG,OAAC,CAAC,KAAK,CAAC,CAAC,wBAAgB,EAAE,0BAAkB,CAAC,CAAC,CAAA;AAG1E,MAAa,OAAO;IAGlB,YACS,GAAQ,EACR,QAAgB,EAChB,IAAY,EACnB,QAAsB;QAHtB;;;;mBAAO,GAAG;WAAK;QACf;;;;mBAAO,QAAQ;WAAQ;QACvB;;;;mBAAO,IAAI;WAAQ;QALd;;;;;WAAqB;QAQ1B,IAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI;YAC1B,KAAK,EAAE,MAAM;YACb,GAAG;YACH,QAAQ;YACR,IAAI;SACL,CAAA;IACH,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,GAAY;QAC3B,IAAI,kBAAK,CAAC,EAAE,CAAC,GAAG,EAAE,mBAAW,CAAC,EAAE,CAAC;YAC/B,OAAO,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;QACjC,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,IAAiB;QAClC,IAAI,kBAAK,CAAC,EAAE,CAAC,IAAI,EAAE,wBAAgB,CAAC,EAAE,CAAC;YACrC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,OAAO,CAAC,SAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,CAAA;QAClE,CAAC;IACH,CAAC;IAED,IAAI;QACF,OAAO;YACL,KAAK,EAAE,MAAM;YACb,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAA;IACH,CAAC;IAED,MAAM;QACJ,OAAO,IAAA,uBAAU,EAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;IAChC,CAAC;CACF;AA5CD,0BA4CC"}
package/dist/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export * from './types';
2
2
  export * from './lexicons';
3
3
  export * from './blob-refs';
4
4
  export * from './serialize';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}