effect-jetstream 1.0.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 (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +182 -0
  3. package/dist/BlueskyRecord.d.ts +214 -0
  4. package/dist/BlueskyRecord.d.ts.map +1 -0
  5. package/dist/BlueskyRecord.js +88 -0
  6. package/dist/BlueskyRecord.js.map +1 -0
  7. package/dist/Jetstream.d.ts +47 -0
  8. package/dist/Jetstream.d.ts.map +1 -0
  9. package/dist/Jetstream.js +22 -0
  10. package/dist/Jetstream.js.map +1 -0
  11. package/dist/JetstreamClient.d.ts +51 -0
  12. package/dist/JetstreamClient.d.ts.map +1 -0
  13. package/dist/JetstreamClient.js +17 -0
  14. package/dist/JetstreamClient.js.map +1 -0
  15. package/dist/JetstreamConfig.d.ts +83 -0
  16. package/dist/JetstreamConfig.d.ts.map +1 -0
  17. package/dist/JetstreamConfig.js +23 -0
  18. package/dist/JetstreamConfig.js.map +1 -0
  19. package/dist/JetstreamError.d.ts +61 -0
  20. package/dist/JetstreamError.d.ts.map +1 -0
  21. package/dist/JetstreamError.js +45 -0
  22. package/dist/JetstreamError.js.map +1 -0
  23. package/dist/JetstreamMessage.d.ts +126 -0
  24. package/dist/JetstreamMessage.d.ts.map +1 -0
  25. package/dist/JetstreamMessage.js +96 -0
  26. package/dist/JetstreamMessage.js.map +1 -0
  27. package/dist/index.d.ts +10 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +10 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/internal/client.d.ts +51 -0
  32. package/dist/internal/client.d.ts.map +1 -0
  33. package/dist/internal/client.js +122 -0
  34. package/dist/internal/client.js.map +1 -0
  35. package/dist/internal/decoder.d.ts +9 -0
  36. package/dist/internal/decoder.d.ts.map +1 -0
  37. package/dist/internal/decoder.js +152 -0
  38. package/dist/internal/decoder.js.map +1 -0
  39. package/dist/internal/jetstream.d.ts +47 -0
  40. package/dist/internal/jetstream.d.ts.map +1 -0
  41. package/dist/internal/jetstream.js +120 -0
  42. package/dist/internal/jetstream.js.map +1 -0
  43. package/dist/internal/websocket.d.ts +12 -0
  44. package/dist/internal/websocket.d.ts.map +1 -0
  45. package/dist/internal/websocket.js +36 -0
  46. package/dist/internal/websocket.js.map +1 -0
  47. package/package.json +50 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 pookzilla
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,182 @@
1
+ # effect-jetstream
2
+
3
+ A pure Effect TypeScript client library for [Bluesky Jetstream](https://github.com/bluesky-social/jetstream) - a simplified JSON event stream for the AT Protocol.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add effect-jetstream
9
+ ```
10
+
11
+ This package depends on `effect` and `@effect/platform`; Bun will install them automatically. If you already use those packages, keep versions aligned.
12
+
13
+ ## Runtime
14
+
15
+ `Jetstream.live` uses the global `WebSocket` (works in Bun and browsers). If your runtime does not provide one, use `Jetstream.layer` and supply `Socket.WebSocketConstructor` from `@effect/platform/Socket`.
16
+
17
+ ## Usage
18
+
19
+ ### Stream-Based (Low-Level)
20
+
21
+ ```typescript
22
+ import { Effect, Stream } from "effect"
23
+ import { Jetstream, JetstreamConfig } from "effect-jetstream"
24
+
25
+ const config = JetstreamConfig.JetstreamConfig.make({
26
+ wantedCollections: ["app.bsky.feed.post", "app.bsky.feed.like"]
27
+ })
28
+
29
+ const program = Effect.gen(function* () {
30
+ const jetstream = yield* Jetstream.Jetstream
31
+
32
+ yield* jetstream.stream.pipe(
33
+ Stream.filter((msg) => msg._tag === "CommitCreate"),
34
+ Stream.tap((msg) => Effect.log(`New ${msg.commit.collection}: ${msg.commit.rkey}`)),
35
+ Stream.runDrain
36
+ )
37
+ })
38
+
39
+ program.pipe(
40
+ Effect.provide(Jetstream.live(config)),
41
+ Effect.runPromise
42
+ )
43
+ ```
44
+
45
+ ### PubSub-Based (High-Level)
46
+
47
+ ```typescript
48
+ import { Effect, Layer } from "effect"
49
+ import { Jetstream, JetstreamClient, JetstreamConfig } from "effect-jetstream"
50
+
51
+ const config = JetstreamConfig.JetstreamConfig.make({
52
+ wantedCollections: ["app.bsky.feed.post", "app.bsky.feed.like"]
53
+ })
54
+
55
+ const program = Effect.gen(function* () {
56
+ const client = yield* JetstreamClient.JetstreamClient
57
+
58
+ yield* client.onCreate("app.bsky.feed.post", (event) =>
59
+ Effect.log(`New post from ${event.did}: ${event.commit.record.text}`)
60
+ )
61
+
62
+ yield* client.onCreate("app.bsky.feed.like", (event) =>
63
+ Effect.log(`${event.did} liked ${event.commit.record.subject.uri}`)
64
+ )
65
+
66
+ yield* client.run
67
+ })
68
+
69
+ const MainLayer = JetstreamClient.layer.pipe(
70
+ Layer.provide(Jetstream.live(config))
71
+ )
72
+
73
+ program.pipe(Effect.provide(MainLayer), Effect.runPromise)
74
+ ```
75
+
76
+ ## Configuration
77
+
78
+ ```typescript
79
+ JetstreamConfig.JetstreamConfig.make({
80
+ // WebSocket endpoint (default: wss://jetstream1.us-east.bsky.network/subscribe)
81
+ endpoint: "wss://jetstream2.us-east.bsky.network/subscribe",
82
+
83
+ // Collections to subscribe to (supports wildcards like "app.bsky.feed.*")
84
+ wantedCollections: ["app.bsky.feed.post"],
85
+
86
+ // DIDs to filter by
87
+ wantedDids: ["did:plc:..."],
88
+
89
+ // Unix microseconds cursor for replay
90
+ cursor: 1725911162329308,
91
+
92
+ // Max message size (0 = no limit)
93
+ maxMessageSizeBytes: 1000000,
94
+
95
+ // Enable zstd compression (Jetstream uses a custom dictionary)
96
+ compress: false,
97
+
98
+ // Optional decoder for compressed payloads
99
+ // If omitted, Bun.zstdDecompress is used without a dictionary and a warning is logged.
100
+ // decoder: (data) => Effect.tryPromise(() => Bun.zstdDecompress(data))
101
+ })
102
+ ```
103
+
104
+ When `compress` is true, provide a decoder that understands Jetstream's dictionary. If you omit it, the client falls back to `Bun.zstdDecompress` without a dictionary and logs a warning.
105
+
106
+ ## Behavior
107
+
108
+ - Malformed messages are logged and dropped; the stream continues.
109
+ - Record decode failures in `JetstreamClient` are logged and dropped.
110
+ - Handler failures are logged and do not stop processing.
111
+ - Outbound messages are buffered; `send` waits for a ready socket and resends after reconnect.
112
+
113
+ ## Event Types
114
+
115
+ - `CommitCreate` - New record created
116
+ - `CommitUpdate` - Record updated
117
+ - `CommitDelete` - Record deleted
118
+ - `IdentityEvent` - Handle or DID document changes
119
+ - `AccountEvent` - Account status changes
120
+
121
+ ## Bluesky Record Types
122
+
123
+ - `Post` - app.bsky.feed.post
124
+ - `Like` - app.bsky.feed.like
125
+ - `Repost` - app.bsky.feed.repost
126
+ - `Follow` - app.bsky.graph.follow
127
+ - `Block` - app.bsky.graph.block
128
+ - `Profile` - app.bsky.actor.profile
129
+
130
+ ## API
131
+
132
+ ### Jetstream Service (Low-Level)
133
+
134
+ ```typescript
135
+ interface Jetstream {
136
+ // Stream of parsed messages
137
+ readonly stream: Stream<JetstreamMessage, JetstreamError>
138
+
139
+ // Send a message to the server
140
+ readonly send: (message: SubscriberSourcedMessage) => Effect<void, JetstreamError>
141
+
142
+ // Update subscription options
143
+ readonly updateOptions: (options: OptionsUpdate) => Effect<void, JetstreamError>
144
+ }
145
+ ```
146
+
147
+ ### JetstreamClient Service (High-Level)
148
+
149
+ ```typescript
150
+ interface JetstreamClient {
151
+ // Register handler for new records in a collection
152
+ readonly onCreate: <C extends Collection>(
153
+ collection: C,
154
+ handler: (event: CommitCreate & { readonly commit: { readonly record: RecordFor<C> } }) => Effect<void>
155
+ ) => Effect<void>
156
+
157
+ // Register handler for updated records
158
+ readonly onUpdate: <C extends Collection>(
159
+ collection: C,
160
+ handler: (event: CommitUpdate & { readonly commit: { readonly record: RecordFor<C> } }) => Effect<void>
161
+ ) => Effect<void>
162
+
163
+ // Register handler for deleted records
164
+ readonly onDelete: <C extends Collection>(
165
+ collection: C,
166
+ handler: (event: CommitDelete) => Effect<void>
167
+ ) => Effect<void>
168
+
169
+ // Register handler for event kinds (commit, identity, account)
170
+ readonly on: <K extends EventKind>(
171
+ kind: K,
172
+ handler: (event: EventFor<K>) => Effect<void>
173
+ ) => Effect<void>
174
+
175
+ // Run the client (blocks forever)
176
+ readonly run: Effect<never, JetstreamError>
177
+ }
178
+ ```
179
+
180
+ ## License
181
+
182
+ MIT
@@ -0,0 +1,214 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import * as Schema from "effect/Schema";
5
+ /**
6
+ * @since 1.0.0
7
+ * @category schemas
8
+ */
9
+ export declare const Did: Schema.brand<Schema.filter<typeof Schema.String>, "Did">;
10
+ /**
11
+ * @since 1.0.0
12
+ * @category types
13
+ */
14
+ export type Did = typeof Did.Type;
15
+ declare const StrongRef_base: Schema.Class<StrongRef, {
16
+ uri: typeof Schema.String;
17
+ cid: typeof Schema.String;
18
+ }, Schema.Struct.Encoded<{
19
+ uri: typeof Schema.String;
20
+ cid: typeof Schema.String;
21
+ }>, never, {
22
+ readonly uri: string;
23
+ } & {
24
+ readonly cid: string;
25
+ }, {}, {}>;
26
+ /**
27
+ * @since 1.0.0
28
+ * @category schemas
29
+ */
30
+ export declare class StrongRef extends StrongRef_base {
31
+ }
32
+ declare const Post_base: Schema.Class<Post, {
33
+ $type: Schema.Literal<["app.bsky.feed.post"]>;
34
+ text: typeof Schema.String;
35
+ createdAt: typeof Schema.String;
36
+ langs: Schema.optional<Schema.Array$<typeof Schema.String>>;
37
+ reply: Schema.optional<Schema.Struct<{
38
+ root: typeof StrongRef;
39
+ parent: typeof StrongRef;
40
+ }>>;
41
+ embed: Schema.optional<typeof Schema.Unknown>;
42
+ facets: Schema.optional<Schema.Array$<typeof Schema.Unknown>>;
43
+ }, Schema.Struct.Encoded<{
44
+ $type: Schema.Literal<["app.bsky.feed.post"]>;
45
+ text: typeof Schema.String;
46
+ createdAt: typeof Schema.String;
47
+ langs: Schema.optional<Schema.Array$<typeof Schema.String>>;
48
+ reply: Schema.optional<Schema.Struct<{
49
+ root: typeof StrongRef;
50
+ parent: typeof StrongRef;
51
+ }>>;
52
+ embed: Schema.optional<typeof Schema.Unknown>;
53
+ facets: Schema.optional<Schema.Array$<typeof Schema.Unknown>>;
54
+ }>, never, {
55
+ readonly text: string;
56
+ } & {
57
+ readonly createdAt: string;
58
+ } & {
59
+ readonly $type: "app.bsky.feed.post";
60
+ } & {
61
+ readonly langs?: readonly string[] | undefined;
62
+ } & {
63
+ readonly reply?: {
64
+ readonly root: StrongRef;
65
+ readonly parent: StrongRef;
66
+ } | undefined;
67
+ } & {
68
+ readonly embed?: unknown;
69
+ } & {
70
+ readonly facets?: readonly unknown[] | undefined;
71
+ }, {}, {}>;
72
+ /**
73
+ * @since 1.0.0
74
+ * @category schemas
75
+ */
76
+ export declare class Post extends Post_base {
77
+ }
78
+ declare const Like_base: Schema.Class<Like, {
79
+ $type: Schema.Literal<["app.bsky.feed.like"]>;
80
+ subject: typeof StrongRef;
81
+ createdAt: typeof Schema.String;
82
+ }, Schema.Struct.Encoded<{
83
+ $type: Schema.Literal<["app.bsky.feed.like"]>;
84
+ subject: typeof StrongRef;
85
+ createdAt: typeof Schema.String;
86
+ }>, never, {
87
+ readonly createdAt: string;
88
+ } & {
89
+ readonly $type: "app.bsky.feed.like";
90
+ } & {
91
+ readonly subject: StrongRef;
92
+ }, {}, {}>;
93
+ /**
94
+ * @since 1.0.0
95
+ * @category schemas
96
+ */
97
+ export declare class Like extends Like_base {
98
+ }
99
+ declare const Follow_base: Schema.Class<Follow, {
100
+ $type: Schema.Literal<["app.bsky.graph.follow"]>;
101
+ subject: Schema.brand<Schema.filter<typeof Schema.String>, "Did">;
102
+ createdAt: typeof Schema.String;
103
+ }, Schema.Struct.Encoded<{
104
+ $type: Schema.Literal<["app.bsky.graph.follow"]>;
105
+ subject: Schema.brand<Schema.filter<typeof Schema.String>, "Did">;
106
+ createdAt: typeof Schema.String;
107
+ }>, never, {
108
+ readonly createdAt: string;
109
+ } & {
110
+ readonly $type: "app.bsky.graph.follow";
111
+ } & {
112
+ readonly subject: string & import("effect/Brand").Brand<"Did">;
113
+ }, {}, {}>;
114
+ /**
115
+ * @since 1.0.0
116
+ * @category schemas
117
+ */
118
+ export declare class Follow extends Follow_base {
119
+ }
120
+ declare const Repost_base: Schema.Class<Repost, {
121
+ $type: Schema.Literal<["app.bsky.feed.repost"]>;
122
+ subject: typeof StrongRef;
123
+ createdAt: typeof Schema.String;
124
+ }, Schema.Struct.Encoded<{
125
+ $type: Schema.Literal<["app.bsky.feed.repost"]>;
126
+ subject: typeof StrongRef;
127
+ createdAt: typeof Schema.String;
128
+ }>, never, {
129
+ readonly createdAt: string;
130
+ } & {
131
+ readonly $type: "app.bsky.feed.repost";
132
+ } & {
133
+ readonly subject: StrongRef;
134
+ }, {}, {}>;
135
+ /**
136
+ * @since 1.0.0
137
+ * @category schemas
138
+ */
139
+ export declare class Repost extends Repost_base {
140
+ }
141
+ declare const Block_base: Schema.Class<Block, {
142
+ $type: Schema.Literal<["app.bsky.graph.block"]>;
143
+ subject: Schema.brand<Schema.filter<typeof Schema.String>, "Did">;
144
+ createdAt: typeof Schema.String;
145
+ }, Schema.Struct.Encoded<{
146
+ $type: Schema.Literal<["app.bsky.graph.block"]>;
147
+ subject: Schema.brand<Schema.filter<typeof Schema.String>, "Did">;
148
+ createdAt: typeof Schema.String;
149
+ }>, never, {
150
+ readonly createdAt: string;
151
+ } & {
152
+ readonly $type: "app.bsky.graph.block";
153
+ } & {
154
+ readonly subject: string & import("effect/Brand").Brand<"Did">;
155
+ }, {}, {}>;
156
+ /**
157
+ * @since 1.0.0
158
+ * @category schemas
159
+ */
160
+ export declare class Block extends Block_base {
161
+ }
162
+ declare const Profile_base: Schema.Class<Profile, {
163
+ $type: Schema.Literal<["app.bsky.actor.profile"]>;
164
+ displayName: Schema.optional<typeof Schema.String>;
165
+ description: Schema.optional<typeof Schema.String>;
166
+ avatar: Schema.optional<typeof Schema.Unknown>;
167
+ banner: Schema.optional<typeof Schema.Unknown>;
168
+ }, Schema.Struct.Encoded<{
169
+ $type: Schema.Literal<["app.bsky.actor.profile"]>;
170
+ displayName: Schema.optional<typeof Schema.String>;
171
+ description: Schema.optional<typeof Schema.String>;
172
+ avatar: Schema.optional<typeof Schema.Unknown>;
173
+ banner: Schema.optional<typeof Schema.Unknown>;
174
+ }>, never, {
175
+ readonly $type: "app.bsky.actor.profile";
176
+ } & {
177
+ readonly displayName?: string | undefined;
178
+ } & {
179
+ readonly description?: string | undefined;
180
+ } & {
181
+ readonly avatar?: unknown;
182
+ } & {
183
+ readonly banner?: unknown;
184
+ }, {}, {}>;
185
+ /**
186
+ * @since 1.0.0
187
+ * @category schemas
188
+ */
189
+ export declare class Profile extends Profile_base {
190
+ }
191
+ /**
192
+ * @since 1.0.0
193
+ * @category types
194
+ */
195
+ export type Collection = "app.bsky.feed.post" | "app.bsky.feed.like" | "app.bsky.feed.repost" | "app.bsky.graph.follow" | "app.bsky.graph.block" | "app.bsky.actor.profile";
196
+ /**
197
+ * @since 1.0.0
198
+ * @category types
199
+ */
200
+ export type CollectionRecord = {
201
+ "app.bsky.feed.post": Post;
202
+ "app.bsky.feed.like": Like;
203
+ "app.bsky.feed.repost": Repost;
204
+ "app.bsky.graph.follow": Follow;
205
+ "app.bsky.graph.block": Block;
206
+ "app.bsky.actor.profile": Profile;
207
+ };
208
+ /**
209
+ * @since 1.0.0
210
+ * @category types
211
+ */
212
+ export type RecordFor<C extends Collection> = CollectionRecord[C];
213
+ export {};
214
+ //# sourceMappingURL=BlueskyRecord.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BlueskyRecord.d.ts","sourceRoot":"","sources":["../src/BlueskyRecord.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC;;;GAGG;AACH,eAAO,MAAM,GAAG,0DAGf,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,GAAG,GAAG,OAAO,GAAG,CAAC,IAAI,CAAA;;;;;;;;;;;;AAEjC;;;GAGG;AACH,qBAAa,SAAU,SAAQ,cAG7B;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEL;;;GAGG;AACH,qBAAa,IAAK,SAAQ,SAWxB;CAAG;;;;;;;;;;;;;;;;AAEL;;;GAGG;AACH,qBAAa,IAAK,SAAQ,SAIxB;CAAG;;;;;;;;;;;;;;;;AAEL;;;GAGG;AACH,qBAAa,MAAO,SAAQ,WAI1B;CAAG;;;;;;;;;;;;;;;;AAEL;;;GAGG;AACH,qBAAa,MAAO,SAAQ,WAI1B;CAAG;;;;;;;;;;;;;;;;AAEL;;;GAGG;AACH,qBAAa,KAAM,SAAQ,UAIzB;CAAG;;;;;;;;;;;;;;;;;;;;;;;;AAEL;;;GAGG;AACH,qBAAa,OAAQ,SAAQ,YAM3B;CAAG;AAEL;;;GAGG;AACH,MAAM,MAAM,UAAU,GAClB,oBAAoB,GACpB,oBAAoB,GACpB,sBAAsB,GACtB,uBAAuB,GACvB,sBAAsB,GACtB,wBAAwB,CAAA;AAE5B;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,oBAAoB,EAAE,IAAI,CAAA;IAC1B,oBAAoB,EAAE,IAAI,CAAA;IAC1B,sBAAsB,EAAE,MAAM,CAAA;IAC9B,uBAAuB,EAAE,MAAM,CAAA;IAC/B,sBAAsB,EAAE,KAAK,CAAA;IAC7B,wBAAwB,EAAE,OAAO,CAAA;CAClC,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,UAAU,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAA"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import * as Schema from "effect/Schema";
5
+ /**
6
+ * @since 1.0.0
7
+ * @category schemas
8
+ */
9
+ export const Did = Schema.String.pipe(Schema.pattern(/^did:[a-z]+:[a-zA-Z0-9._:%-]+$/), Schema.brand("Did"));
10
+ /**
11
+ * @since 1.0.0
12
+ * @category schemas
13
+ */
14
+ export class StrongRef extends Schema.Class("StrongRef")({
15
+ uri: Schema.String,
16
+ cid: Schema.String
17
+ }) {
18
+ }
19
+ /**
20
+ * @since 1.0.0
21
+ * @category schemas
22
+ */
23
+ export class Post extends Schema.Class("Post")({
24
+ $type: Schema.Literal("app.bsky.feed.post"),
25
+ text: Schema.String,
26
+ createdAt: Schema.String,
27
+ langs: Schema.optional(Schema.Array(Schema.String)),
28
+ reply: Schema.optional(Schema.Struct({
29
+ root: StrongRef,
30
+ parent: StrongRef
31
+ })),
32
+ embed: Schema.optional(Schema.Unknown),
33
+ facets: Schema.optional(Schema.Array(Schema.Unknown))
34
+ }) {
35
+ }
36
+ /**
37
+ * @since 1.0.0
38
+ * @category schemas
39
+ */
40
+ export class Like extends Schema.Class("Like")({
41
+ $type: Schema.Literal("app.bsky.feed.like"),
42
+ subject: StrongRef,
43
+ createdAt: Schema.String
44
+ }) {
45
+ }
46
+ /**
47
+ * @since 1.0.0
48
+ * @category schemas
49
+ */
50
+ export class Follow extends Schema.Class("Follow")({
51
+ $type: Schema.Literal("app.bsky.graph.follow"),
52
+ subject: Did,
53
+ createdAt: Schema.String
54
+ }) {
55
+ }
56
+ /**
57
+ * @since 1.0.0
58
+ * @category schemas
59
+ */
60
+ export class Repost extends Schema.Class("Repost")({
61
+ $type: Schema.Literal("app.bsky.feed.repost"),
62
+ subject: StrongRef,
63
+ createdAt: Schema.String
64
+ }) {
65
+ }
66
+ /**
67
+ * @since 1.0.0
68
+ * @category schemas
69
+ */
70
+ export class Block extends Schema.Class("Block")({
71
+ $type: Schema.Literal("app.bsky.graph.block"),
72
+ subject: Did,
73
+ createdAt: Schema.String
74
+ }) {
75
+ }
76
+ /**
77
+ * @since 1.0.0
78
+ * @category schemas
79
+ */
80
+ export class Profile extends Schema.Class("Profile")({
81
+ $type: Schema.Literal("app.bsky.actor.profile"),
82
+ displayName: Schema.optional(Schema.String),
83
+ description: Schema.optional(Schema.String),
84
+ avatar: Schema.optional(Schema.Unknown),
85
+ banner: Schema.optional(Schema.Unknown)
86
+ }) {
87
+ }
88
+ //# sourceMappingURL=BlueskyRecord.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BlueskyRecord.js","sourceRoot":"","sources":["../src/BlueskyRecord.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC;;;GAGG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CACnC,MAAM,CAAC,OAAO,CAAC,gCAAgC,CAAC,EAChD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CACpB,CAAA;AAQD;;;GAGG;AACH,MAAM,OAAO,SAAU,SAAQ,MAAM,CAAC,KAAK,CAAY,WAAW,CAAC,CAAC;IAClE,GAAG,EAAE,MAAM,CAAC,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K,EAAE,MAAM,CAAC,OAAO,CAAC,sBAAsB,CAAC;IAC7C,OAAO,EAAE,SAAS;IAClB,SAAS,EAAE,MAAM,CAAC,MAAM;CACzB,CAAC;CAAG;AAEL;;;GAGG;AACH,MAAM,OAAO,KAAM,SAAQ,MAAM,CAAC,KAAK,CAAQ,OAAO,CAAC,CAAC;IACtD,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,sBAAsB,CAAC;IAC7C,OAAO,EAAE,GAAG;IACZ,SAAS,EAAE,MAAM,CAAC,MAAM;CACzB,CAAC;CAAG;AAEL;;;GAGG;AACH,MAAM,OAAO,OAAQ,SAAQ,MAAM,CAAC,KAAK,CAAU,SAAS,CAAC,CAAC;IAC5D,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,wBAAwB,CAAC;IAC/C,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IAC3C,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IAC3C,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC;CACxC,CAAC;CAAG"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import type * as Socket from "@effect/platform/Socket";
5
+ import type * as Effect from "effect/Effect";
6
+ import type * as Layer from "effect/Layer";
7
+ import type * as Stream from "effect/Stream";
8
+ import type { JetstreamConfig, OptionsUpdate, SubscriberSourcedMessage } from "./JetstreamConfig.js";
9
+ import type { JetstreamError } from "./JetstreamError.js";
10
+ import type { JetstreamMessage } from "./JetstreamMessage.js";
11
+ import * as internal from "./internal/jetstream.js";
12
+ /**
13
+ * @since 1.0.0
14
+ * @category symbols
15
+ */
16
+ export declare const TypeId: typeof internal.TypeId;
17
+ /**
18
+ * @since 1.0.0
19
+ * @category symbols
20
+ */
21
+ export type TypeId = typeof TypeId;
22
+ /**
23
+ * @since 1.0.0
24
+ * @category models
25
+ */
26
+ export interface Jetstream {
27
+ readonly [TypeId]: TypeId;
28
+ readonly stream: Stream.Stream<JetstreamMessage, JetstreamError>;
29
+ readonly send: (message: SubscriberSourcedMessage) => Effect.Effect<void, JetstreamError>;
30
+ readonly updateOptions: (options: OptionsUpdate) => Effect.Effect<void, JetstreamError>;
31
+ }
32
+ /**
33
+ * @since 1.0.0
34
+ * @category tags
35
+ */
36
+ export declare const Jetstream: typeof internal.tag;
37
+ /**
38
+ * @since 1.0.0
39
+ * @category layers
40
+ */
41
+ export declare const layer: (config: JetstreamConfig) => Layer.Layer<Jetstream, JetstreamError, Socket.WebSocketConstructor>;
42
+ /**
43
+ * @since 1.0.0
44
+ * @category layers
45
+ */
46
+ export declare const live: (config: JetstreamConfig) => Layer.Layer<Jetstream, JetstreamError>;
47
+ //# sourceMappingURL=Jetstream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Jetstream.d.ts","sourceRoot":"","sources":["../src/Jetstream.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,MAAM,yBAAyB,CAAA;AACtD,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AACpG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAA;AAEnD;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,OAAO,QAAQ,CAAC,MAAwB,CAAA;AAE7D;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAA;AAElC;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAA;IAChE,QAAQ,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,CAAA;IACzF,QAAQ,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,CAAA;CACxF;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,OAAO,QAAQ,CAAC,GAAkB,CAAA;AAE1D;;;GAGG;AACH,eAAO,MAAM,KAAK,EAAE,CAClB,MAAM,EAAE,eAAe,KACpB,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,cAAc,EAAE,MAAM,CAAC,oBAAoB,CAAkB,CAAA;AAEzF;;;GAGG;AACH,eAAO,MAAM,IAAI,EAAE,CACjB,MAAM,EAAE,eAAe,KACpB,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,cAAc,CAAiB,CAAA"}
@@ -0,0 +1,22 @@
1
+ import * as internal from "./internal/jetstream.js";
2
+ /**
3
+ * @since 1.0.0
4
+ * @category symbols
5
+ */
6
+ export const TypeId = internal.TypeId;
7
+ /**
8
+ * @since 1.0.0
9
+ * @category tags
10
+ */
11
+ export const Jetstream = internal.tag;
12
+ /**
13
+ * @since 1.0.0
14
+ * @category layers
15
+ */
16
+ export const layer = internal.layer;
17
+ /**
18
+ * @since 1.0.0
19
+ * @category layers
20
+ */
21
+ export const live = internal.live;
22
+ //# sourceMappingURL=Jetstream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Jetstream.js","sourceRoot":"","sources":["../src/Jetstream.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAA;AAEnD;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAA2B,QAAQ,CAAC,MAAM,CAAA;AAmB7D;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAwB,QAAQ,CAAC,GAAG,CAAA;AAE1D;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAEyD,QAAQ,CAAC,KAAK,CAAA;AAEzF;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAE6B,QAAQ,CAAC,IAAI,CAAA"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import type * as Effect from "effect/Effect";
5
+ import type * as Layer from "effect/Layer";
6
+ import type { Collection, RecordFor } from "./BlueskyRecord.js";
7
+ import type { JetstreamError } from "./JetstreamError.js";
8
+ import type { CommitCreate, CommitDelete, CommitUpdate, EventFor, EventKind } from "./JetstreamMessage.js";
9
+ import * as internal from "./internal/client.js";
10
+ import type { Jetstream } from "./internal/jetstream.js";
11
+ /**
12
+ * @since 1.0.0
13
+ * @category symbols
14
+ */
15
+ export declare const TypeId: typeof internal.TypeId;
16
+ /**
17
+ * @since 1.0.0
18
+ * @category symbols
19
+ */
20
+ export type TypeId = typeof TypeId;
21
+ /**
22
+ * @since 1.0.0
23
+ * @category models
24
+ */
25
+ export interface JetstreamClient {
26
+ readonly [TypeId]: TypeId;
27
+ readonly onCreate: <C extends Collection>(collection: C, handler: (event: CommitCreate & {
28
+ readonly commit: {
29
+ readonly record: RecordFor<C>;
30
+ };
31
+ }) => Effect.Effect<void>) => Effect.Effect<void>;
32
+ readonly onUpdate: <C extends Collection>(collection: C, handler: (event: CommitUpdate & {
33
+ readonly commit: {
34
+ readonly record: RecordFor<C>;
35
+ };
36
+ }) => Effect.Effect<void>) => Effect.Effect<void>;
37
+ readonly onDelete: <C extends Collection>(collection: C, handler: (event: CommitDelete) => Effect.Effect<void>) => Effect.Effect<void>;
38
+ readonly on: <K extends EventKind>(kind: K, handler: (event: EventFor<K>) => Effect.Effect<void>) => Effect.Effect<void>;
39
+ readonly run: Effect.Effect<never, JetstreamError>;
40
+ }
41
+ /**
42
+ * @since 1.0.0
43
+ * @category tags
44
+ */
45
+ export declare const JetstreamClient: typeof internal.tag;
46
+ /**
47
+ * @since 1.0.0
48
+ * @category layers
49
+ */
50
+ export declare const layer: Layer.Layer<JetstreamClient, never, Jetstream>;
51
+ //# sourceMappingURL=JetstreamClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JetstreamClient.d.ts","sourceRoot":"","sources":["../src/JetstreamClient.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAC1G,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAA;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAExD;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,OAAO,QAAQ,CAAC,MAAwB,CAAA;AAE7D;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAA;AAElC;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,SAAS,UAAU,EACtC,UAAU,EAAE,CAAC,EACb,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,G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EAAE,SAAS,CAAkB,CAAA"}
@@ -0,0 +1,17 @@
1
+ import * as internal from "./internal/client.js";
2
+ /**
3
+ * @since 1.0.0
4
+ * @category symbols
5
+ */
6
+ export const TypeId = internal.TypeId;
7
+ /**
8
+ * @since 1.0.0
9
+ * @category tags
10
+ */
11
+ export const JetstreamClient = internal.tag;
12
+ /**
13
+ * @since 1.0.0
14
+ * @category layers
15
+ */
16
+ export const layer = internal.layer;
17
+ //# sourceMappingURL=JetstreamClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JetstreamClient.js","sourceRoot":"","sources":["../src/JetstreamClient.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAA;AAGhD;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAA2B,QAAQ,CAAC,MAAM,CAAA;AAiC7D;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAwB,QAAQ,CAAC,GAAG,CAAA;AAEhE;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAmD,QAAQ,CAAC,KAAK,CAAA"}