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
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import type * as Effect from "effect/Effect";
5
+ import * as Schema from "effect/Schema";
6
+ import type { ParseError } from "./JetstreamError.js";
7
+ /**
8
+ * @since 1.1.0
9
+ * @category models
10
+ */
11
+ export type JetstreamDecoder = (data: Uint8Array) => Effect.Effect<Uint8Array, ParseError>;
12
+ declare const JetstreamConfig_base: Schema.Class<JetstreamConfig, {
13
+ endpoint: Schema.optionalWith<typeof Schema.String, {
14
+ default: () => string;
15
+ }>;
16
+ wantedCollections: Schema.optionalWith<Schema.Array$<typeof Schema.String>, {
17
+ default: () => never[];
18
+ }>;
19
+ wantedDids: Schema.optionalWith<Schema.Array$<typeof Schema.String>, {
20
+ default: () => never[];
21
+ }>;
22
+ cursor: Schema.optional<typeof Schema.Number>;
23
+ maxMessageSizeBytes: Schema.optional<typeof Schema.Number>;
24
+ compress: Schema.optionalWith<typeof Schema.Boolean, {
25
+ default: () => false;
26
+ }>;
27
+ decoder: Schema.optional<Schema.declare<JetstreamDecoder, JetstreamDecoder, readonly [], never>>;
28
+ }, Schema.Struct.Encoded<{
29
+ endpoint: Schema.optionalWith<typeof Schema.String, {
30
+ default: () => string;
31
+ }>;
32
+ wantedCollections: Schema.optionalWith<Schema.Array$<typeof Schema.String>, {
33
+ default: () => never[];
34
+ }>;
35
+ wantedDids: Schema.optionalWith<Schema.Array$<typeof Schema.String>, {
36
+ default: () => never[];
37
+ }>;
38
+ cursor: Schema.optional<typeof Schema.Number>;
39
+ maxMessageSizeBytes: Schema.optional<typeof Schema.Number>;
40
+ compress: Schema.optionalWith<typeof Schema.Boolean, {
41
+ default: () => false;
42
+ }>;
43
+ decoder: Schema.optional<Schema.declare<JetstreamDecoder, JetstreamDecoder, readonly [], never>>;
44
+ }>, never, {
45
+ readonly endpoint?: string;
46
+ } & {
47
+ readonly wantedCollections?: readonly string[];
48
+ } & {
49
+ readonly wantedDids?: readonly string[];
50
+ } & {
51
+ readonly cursor?: number | undefined;
52
+ } & {
53
+ readonly maxMessageSizeBytes?: number | undefined;
54
+ } & {
55
+ readonly compress?: boolean;
56
+ } & {
57
+ readonly decoder?: JetstreamDecoder | undefined;
58
+ }, {}, {}>;
59
+ /**
60
+ * @since 1.0.0
61
+ * @category schemas
62
+ */
63
+ export declare class JetstreamConfig extends JetstreamConfig_base {
64
+ }
65
+ /**
66
+ * @since 1.0.0
67
+ * @category models
68
+ */
69
+ export interface OptionsUpdate {
70
+ readonly wantedCollections?: ReadonlyArray<string>;
71
+ readonly wantedDids?: ReadonlyArray<string>;
72
+ readonly maxMessageSizeBytes?: number;
73
+ }
74
+ /**
75
+ * @since 1.0.0
76
+ * @category models
77
+ */
78
+ export interface SubscriberSourcedMessage {
79
+ readonly type: "options_update";
80
+ readonly payload: OptionsUpdate;
81
+ }
82
+ export {};
83
+ //# sourceMappingURL=JetstreamConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JetstreamConfig.d.ts","sourceRoot":"","sources":["../src/JetstreamConfig.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAErD;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,UAAU,KAAK,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAM1F;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,oBAcnC;CAAG;AAEL;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,iBAAiB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAClD,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC3C,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAA;CACtC;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAA;IAC/B,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAA;CAChC"}
@@ -0,0 +1,23 @@
1
+ import * as Schema from "effect/Schema";
2
+ const JetstreamDecoderSchema = Schema.declare((u) => typeof u === "function");
3
+ /**
4
+ * @since 1.0.0
5
+ * @category schemas
6
+ */
7
+ export class JetstreamConfig extends Schema.Class("JetstreamConfig")({
8
+ endpoint: Schema.optionalWith(Schema.String, {
9
+ default: () => "wss://jetstream1.us-east.bsky.network/subscribe"
10
+ }),
11
+ wantedCollections: Schema.optionalWith(Schema.Array(Schema.String), {
12
+ default: () => []
13
+ }),
14
+ wantedDids: Schema.optionalWith(Schema.Array(Schema.String), {
15
+ default: () => []
16
+ }),
17
+ cursor: Schema.optional(Schema.Number),
18
+ maxMessageSizeBytes: Schema.optional(Schema.Number),
19
+ compress: Schema.optionalWith(Schema.Boolean, { default: () => false }),
20
+ decoder: Schema.optional(JetstreamDecoderSchema)
21
+ }) {
22
+ }
23
+ //# sourceMappingURL=JetstreamConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JetstreamConfig.js","sourceRoot":"","sources":["../src/JetstreamConfig.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AASvC,MAAM,sBAAsB,GAAG,MAAM,CAAC,OAAO,CAC3C,CAAC,CAAC,EAAyB,EAAE,CAAC,OAAO,CAAC,KAAK,UAAU,CACtD,CAAA;AAED;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,MAAM,CAAC,KAAK,CAAkB,iBAAiB,CAAC,CAAC;IACpF,QAAQ,EAAE,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE;QAC3C,OAAO,EAAE,GAAG,EAAE,CAAC,iDAAiD;KACjE,CAAC;IACF,iBAAiB,EAAE,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;QAClE,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE;KAClB,CAAC;IACF,UAAU,EAAE,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;QAC3D,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE;KAClB,CAAC;IACF,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACtC,mBAAmB,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACnD,QAAQ,EAAE,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC;IACvE,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,sBAAsB,CAAC;CACjD,CAAC;CAAG"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import * as Schema from "effect/Schema";
5
+ /**
6
+ * @since 1.0.0
7
+ * @category symbols
8
+ */
9
+ export declare const TypeId: unique symbol;
10
+ /**
11
+ * @since 1.0.0
12
+ * @category symbols
13
+ */
14
+ export type TypeId = typeof TypeId;
15
+ declare const ConnectionError_base: Schema.TaggedErrorClass<ConnectionError, "ConnectionError", {
16
+ readonly _tag: Schema.tag<"ConnectionError">;
17
+ } & {
18
+ reason: Schema.Literal<["Connect", "Timeout", "Closed", "Reconnecting"]>;
19
+ cause: Schema.optional<typeof Schema.Unknown>;
20
+ }>;
21
+ /**
22
+ * @since 1.0.0
23
+ * @category errors
24
+ */
25
+ export declare class ConnectionError extends ConnectionError_base {
26
+ readonly [TypeId]: TypeId;
27
+ get message(): string;
28
+ }
29
+ declare const ParseError_base: Schema.TaggedErrorClass<ParseError, "ParseError", {
30
+ readonly _tag: Schema.tag<"ParseError">;
31
+ } & {
32
+ message: typeof Schema.String;
33
+ raw: Schema.optional<typeof Schema.String>;
34
+ }>;
35
+ /**
36
+ * @since 1.0.0
37
+ * @category errors
38
+ */
39
+ export declare class ParseError extends ParseError_base {
40
+ readonly [TypeId]: TypeId;
41
+ }
42
+ declare const SubscriptionError_base: Schema.TaggedErrorClass<SubscriptionError, "SubscriptionError", {
43
+ readonly _tag: Schema.tag<"SubscriptionError">;
44
+ } & {
45
+ reason: Schema.Literal<["InvalidCursor", "TooManyCollections", "TooManyDids"]>;
46
+ }>;
47
+ /**
48
+ * @since 1.0.0
49
+ * @category errors
50
+ */
51
+ export declare class SubscriptionError extends SubscriptionError_base {
52
+ readonly [TypeId]: TypeId;
53
+ get message(): string;
54
+ }
55
+ /**
56
+ * @since 1.0.0
57
+ * @category types
58
+ */
59
+ export type JetstreamError = ConnectionError | ParseError | SubscriptionError;
60
+ export {};
61
+ //# sourceMappingURL=JetstreamError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JetstreamError.d.ts","sourceRoot":"","sources":["../src/JetstreamError.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,OAAO,MAAsD,CAAA;AAElF;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAA;;;;;;;AAElC;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,oBAMpC;IACC,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAS;IAElC,IAAa,OAAO,IAAI,MAAM,CAE7B;CACF;;;;;;;AAED;;;GAGG;AACH,qBAAa,UAAW,SAAQ,eAM/B;IACC,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAS;CACnC;;;;;;AAED;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,sBAKtC;IACC,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAS;IAElC,IAAa,OAAO,IAAI,MAAM,CAE7B;CACF;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG,UAAU,GAAG,iBAAiB,CAAA"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import * as Schema from "effect/Schema";
5
+ /**
6
+ * @since 1.0.0
7
+ * @category symbols
8
+ */
9
+ export const TypeId = Symbol.for("effect-jetstream/JetstreamError");
10
+ /**
11
+ * @since 1.0.0
12
+ * @category errors
13
+ */
14
+ export class ConnectionError extends Schema.TaggedError()("ConnectionError", {
15
+ reason: Schema.Literal("Connect", "Timeout", "Closed", "Reconnecting"),
16
+ cause: Schema.optional(Schema.Unknown)
17
+ }) {
18
+ [TypeId] = TypeId;
19
+ get message() {
20
+ return `Connection ${this.reason}${this.cause ? `: ${this.cause}` : ""}`;
21
+ }
22
+ }
23
+ /**
24
+ * @since 1.0.0
25
+ * @category errors
26
+ */
27
+ export class ParseError extends Schema.TaggedError()("ParseError", {
28
+ message: Schema.String,
29
+ raw: Schema.optional(Schema.String)
30
+ }) {
31
+ [TypeId] = TypeId;
32
+ }
33
+ /**
34
+ * @since 1.0.0
35
+ * @category errors
36
+ */
37
+ export class SubscriptionError extends Schema.TaggedError()("SubscriptionError", {
38
+ reason: Schema.Literal("InvalidCursor", "TooManyCollections", "TooManyDids")
39
+ }) {
40
+ [TypeId] = TypeId;
41
+ get message() {
42
+ return `Subscription error: ${this.reason}`;
43
+ }
44
+ }
45
+ //# sourceMappingURL=JetstreamError.js.map
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,IAAI,CAAC,MAAM,EAAE,CAAA;IAC7C,CAAC;CACF"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import * as Schema from "effect/Schema";
5
+ declare const CommitCreate_base: Schema.TaggedClass<CommitCreate, "CommitCreate", {
6
+ readonly _tag: Schema.tag<"CommitCreate">;
7
+ } & {
8
+ did: Schema.brand<Schema.filter<typeof Schema.String>, "Did">;
9
+ time_us: typeof Schema.Number;
10
+ kind: Schema.Literal<["commit"]>;
11
+ commit: Schema.Struct<{
12
+ rev: typeof Schema.String;
13
+ operation: Schema.Literal<["create"]>;
14
+ collection: typeof Schema.String;
15
+ rkey: typeof Schema.String;
16
+ record: typeof Schema.Unknown;
17
+ cid: Schema.optional<typeof Schema.String>;
18
+ }>;
19
+ }>;
20
+ /**
21
+ * @since 1.0.0
22
+ * @category schemas
23
+ */
24
+ export declare class CommitCreate extends CommitCreate_base {
25
+ }
26
+ declare const CommitUpdate_base: Schema.TaggedClass<CommitUpdate, "CommitUpdate", {
27
+ readonly _tag: Schema.tag<"CommitUpdate">;
28
+ } & {
29
+ did: Schema.brand<Schema.filter<typeof Schema.String>, "Did">;
30
+ time_us: typeof Schema.Number;
31
+ kind: Schema.Literal<["commit"]>;
32
+ commit: Schema.Struct<{
33
+ rev: typeof Schema.String;
34
+ operation: Schema.Literal<["update"]>;
35
+ collection: typeof Schema.String;
36
+ rkey: typeof Schema.String;
37
+ record: typeof Schema.Unknown;
38
+ cid: Schema.optional<typeof Schema.String>;
39
+ }>;
40
+ }>;
41
+ /**
42
+ * @since 1.0.0
43
+ * @category schemas
44
+ */
45
+ export declare class CommitUpdate extends CommitUpdate_base {
46
+ }
47
+ declare const CommitDelete_base: Schema.TaggedClass<CommitDelete, "CommitDelete", {
48
+ readonly _tag: Schema.tag<"CommitDelete">;
49
+ } & {
50
+ did: Schema.brand<Schema.filter<typeof Schema.String>, "Did">;
51
+ time_us: typeof Schema.Number;
52
+ kind: Schema.Literal<["commit"]>;
53
+ commit: Schema.Struct<{
54
+ rev: typeof Schema.String;
55
+ operation: Schema.Literal<["delete"]>;
56
+ collection: typeof Schema.String;
57
+ rkey: typeof Schema.String;
58
+ }>;
59
+ }>;
60
+ /**
61
+ * @since 1.0.0
62
+ * @category schemas
63
+ */
64
+ export declare class CommitDelete extends CommitDelete_base {
65
+ }
66
+ declare const IdentityEvent_base: Schema.TaggedClass<IdentityEvent, "IdentityEvent", {
67
+ readonly _tag: Schema.tag<"IdentityEvent">;
68
+ } & {
69
+ did: Schema.brand<Schema.filter<typeof Schema.String>, "Did">;
70
+ time_us: typeof Schema.Number;
71
+ kind: Schema.Literal<["identity"]>;
72
+ identity: Schema.Struct<{
73
+ did: Schema.brand<Schema.filter<typeof Schema.String>, "Did">;
74
+ handle: typeof Schema.String;
75
+ seq: typeof Schema.Number;
76
+ time: typeof Schema.String;
77
+ }>;
78
+ }>;
79
+ /**
80
+ * @since 1.0.0
81
+ * @category schemas
82
+ */
83
+ export declare class IdentityEvent extends IdentityEvent_base {
84
+ }
85
+ declare const AccountEvent_base: Schema.TaggedClass<AccountEvent, "AccountEvent", {
86
+ readonly _tag: Schema.tag<"AccountEvent">;
87
+ } & {
88
+ did: Schema.brand<Schema.filter<typeof Schema.String>, "Did">;
89
+ time_us: typeof Schema.Number;
90
+ kind: Schema.Literal<["account"]>;
91
+ account: Schema.Struct<{
92
+ active: typeof Schema.Boolean;
93
+ did: Schema.brand<Schema.filter<typeof Schema.String>, "Did">;
94
+ seq: typeof Schema.Number;
95
+ time: typeof Schema.String;
96
+ status: Schema.optional<Schema.Literal<["deactivated", "suspended", "deleted"]>>;
97
+ }>;
98
+ }>;
99
+ /**
100
+ * @since 1.0.0
101
+ * @category schemas
102
+ */
103
+ export declare class AccountEvent extends AccountEvent_base {
104
+ }
105
+ /**
106
+ * @since 1.0.0
107
+ * @category types
108
+ */
109
+ export type JetstreamMessage = CommitCreate | CommitUpdate | CommitDelete | IdentityEvent | AccountEvent;
110
+ /**
111
+ * @since 1.0.0
112
+ * @category schemas
113
+ */
114
+ export declare const JetstreamMessage: Schema.Union<[typeof CommitCreate, typeof CommitUpdate, typeof CommitDelete, typeof IdentityEvent, typeof AccountEvent]>;
115
+ /**
116
+ * @since 1.0.0
117
+ * @category types
118
+ */
119
+ export type EventKind = "commit" | "identity" | "account";
120
+ /**
121
+ * @since 1.0.0
122
+ * @category types
123
+ */
124
+ export type EventFor<K extends EventKind> = K extends "commit" ? CommitCreate | CommitUpdate | CommitDelete : K extends "identity" ? IdentityEvent : K extends "account" ? AccountEvent : never;
125
+ export {};
126
+ //# sourceMappingURL=JetstreamMessage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JetstreamMessage.d.ts","sourceRoot":"","sources":["../src/JetstreamMessage.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;;;;;;;;;;;;;;;;AAGvC;;;GAGG;AACH,qBAAa,YAAa,SAAQ,iBAYhC;CAAG;;;;;;;;;;;;;;;;AAEL;;;GAGG;AACH,qBAAa,YAAa,SAAQ,iBAYhC;CAAG;;;;;;;;;;;;;;AAEL;;;GAGG;AACH,qBAAa,YAAa,SAAQ,iBAUhC;CAAG;;;;;;;;;;;;;;AAEL;;;GAGG;AACH,qBAAa,aAAc,SAAQ,kBAUjC;CAAG;;;;;;;;;;;;;;;AAEL;;;GAGG;AACH,qBAAa,YAAa,SAAQ,iBAWhC;CAAG;AAEL;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,YAAY,GAAG,YAAY,GAAG,aAAa,GAAG,YAAY,CAAA;AAExG;;;GAGG;AACH,eAAO,MAAM,gBAAgB,0HAM5B,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAA;AAEzD;;;GAGG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,SAAS,IAAI,CAAC,SAAS,QAAQ,GAC1D,YAAY,GAAG,YAAY,GAAG,YAAY,GAC1C,CAAC,SAAS,UAAU,GACpB,aAAa,GACb,CAAC,SAAS,SAAS,GACnB,YAAY,GACZ,KAAK,CAAA"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import * as Schema from "effect/Schema";
5
+ import { Did } from "./BlueskyRecord.js";
6
+ /**
7
+ * @since 1.0.0
8
+ * @category schemas
9
+ */
10
+ export class CommitCreate extends Schema.TaggedClass()("CommitCreate", {
11
+ did: Did,
12
+ time_us: Schema.Number,
13
+ kind: Schema.Literal("commit"),
14
+ commit: Schema.Struct({
15
+ rev: Schema.String,
16
+ operation: Schema.Literal("create"),
17
+ collection: Schema.String,
18
+ rkey: Schema.String,
19
+ record: Schema.Unknown,
20
+ cid: Schema.optional(Schema.String)
21
+ })
22
+ }) {
23
+ }
24
+ /**
25
+ * @since 1.0.0
26
+ * @category schemas
27
+ */
28
+ export class CommitUpdate extends Schema.TaggedClass()("CommitUpdate", {
29
+ did: Did,
30
+ time_us: Schema.Number,
31
+ kind: Schema.Literal("commit"),
32
+ commit: Schema.Struct({
33
+ rev: Schema.String,
34
+ operation: Schema.Literal("update"),
35
+ collection: Schema.String,
36
+ rkey: Schema.String,
37
+ record: Schema.Unknown,
38
+ cid: Schema.optional(Schema.String)
39
+ })
40
+ }) {
41
+ }
42
+ /**
43
+ * @since 1.0.0
44
+ * @category schemas
45
+ */
46
+ export class CommitDelete extends Schema.TaggedClass()("CommitDelete", {
47
+ did: Did,
48
+ time_us: Schema.Number,
49
+ kind: Schema.Literal("commit"),
50
+ commit: Schema.Struct({
51
+ rev: Schema.String,
52
+ operation: Schema.Literal("delete"),
53
+ collection: Schema.String,
54
+ rkey: Schema.String
55
+ })
56
+ }) {
57
+ }
58
+ /**
59
+ * @since 1.0.0
60
+ * @category schemas
61
+ */
62
+ export class IdentityEvent extends Schema.TaggedClass()("IdentityEvent", {
63
+ did: Did,
64
+ time_us: Schema.Number,
65
+ kind: Schema.Literal("identity"),
66
+ identity: Schema.Struct({
67
+ did: Did,
68
+ handle: Schema.String,
69
+ seq: Schema.Number,
70
+ time: Schema.String
71
+ })
72
+ }) {
73
+ }
74
+ /**
75
+ * @since 1.0.0
76
+ * @category schemas
77
+ */
78
+ export class AccountEvent extends Schema.TaggedClass()("AccountEvent", {
79
+ did: Did,
80
+ time_us: Schema.Number,
81
+ kind: Schema.Literal("account"),
82
+ account: Schema.Struct({
83
+ active: Schema.Boolean,
84
+ did: Did,
85
+ seq: Schema.Number,
86
+ time: Schema.String,
87
+ status: Schema.optional(Schema.Literal("deactivated", "suspended", "deleted"))
88
+ })
89
+ }) {
90
+ }
91
+ /**
92
+ * @since 1.0.0
93
+ * @category schemas
94
+ */
95
+ export const JetstreamMessage = Schema.Union(CommitCreate, CommitUpdate, CommitDelete, IdentityEvent, AccountEvent);
96
+ //# sourceMappingURL=JetstreamMessage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JetstreamMessage.js","sourceRoot":"","sources":["../src/JetstreamMessage.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAA;AAExC;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,MAAM,CAAC,WAAW,EAAgB,CAAC,cAAc,EAAE;IACnF,GAAG,EAAE,GAAG;IACR,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;QACpB,GAAG,EAAE,MAAM,CAAC,MAAM;QAClB,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;QACnC,UAAU,EAAE,MAAM,CAAC,MAAM;QACzB,IAAI,EAAE,MAAM,CAAC,MAAM;QACnB,MAAM,EAAE,MAAM,CAAC,OAAO;QACtB,GAA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AAM,CAAC,OAAO,CAAC,UAAU,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC;QACtB,GAAG,EAAE,GAAG;QACR,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,GAAG,EAAE,MAAM,CAAC,MAAM;QAClB,IAAI,EAAE,MAAM,CAAC,MAAM;KACpB,CAAC;CACH,CAAC;CAAG;AAEL;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,MAAM,CAAC,WAAW,EAAgB,CAAC,cAAc,EAAE;IACnF,GAAG,EAAE,GAAG;IACR,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC;QACrB,MAAM,EAAE,MAAM,CAAC,OAAO;QACtB,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,MAAM,CAAC,MAAM;QAClB,IAAI,EAAE,MAAM,CAAC,MAAM;QACnB,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;KAC/E,CAAC;CACH,CAAC;CAAG;AAQL;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,KAAK,CAC1C,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,YAAY,CACb,CAAA"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ export * as BlueskyRecord from "./BlueskyRecord.js";
5
+ export * as Jetstream from "./Jetstream.js";
6
+ export * as JetstreamClient from "./JetstreamClient.js";
7
+ export * as JetstreamConfig from "./JetstreamConfig.js";
8
+ export * as JetstreamError from "./JetstreamError.js";
9
+ export * as JetstreamMessage from "./JetstreamMessage.js";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AACrD,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ export * as BlueskyRecord from "./BlueskyRecord.js";
5
+ export * as Jetstream from "./Jetstream.js";
6
+ export * as JetstreamClient from "./JetstreamClient.js";
7
+ export * as JetstreamConfig from "./JetstreamConfig.js";
8
+ export * as JetstreamError from "./JetstreamError.js";
9
+ export * as JetstreamMessage from "./JetstreamMessage.js";
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AACrD,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAA"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import * as Context from "effect/Context";
5
+ import * as Effect from "effect/Effect";
6
+ import * as Layer from "effect/Layer";
7
+ import { type Collection, type RecordFor } from "../BlueskyRecord.js";
8
+ import { type JetstreamError } from "../JetstreamError.js";
9
+ import type { CommitCreate, CommitDelete, CommitUpdate, EventFor, EventKind } from "../JetstreamMessage.js";
10
+ import { type Jetstream } from "./jetstream.js";
11
+ /**
12
+ * @since 1.0.0
13
+ * @category symbols
14
+ */
15
+ export declare const TypeId: unique symbol;
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 tag: Context.Tag<JetstreamClient, JetstreamClient>;
46
+ /**
47
+ * @since 1.0.0
48
+ * @category layers
49
+ */
50
+ export declare const layer: Layer.Layer<JetstreamClient, never, Jetstream>;
51
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/internal/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAIrC,OAAO,EAOL,KAAK,UAAU,EACf,KAAK,SAAS,EACf,MAAM,qBAAqB,CAAA;AAC5B,OAA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