@atcute/jetstream 1.1.3 → 2.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.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from './subscription.ts';
2
- export * from './types.ts';
3
2
  export * from './typedefs.ts';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from './subscription.js';
2
- export * from './types.js';
3
2
  export * from './typedefs.js';
4
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC"}
@@ -2,7 +2,6 @@ import type { Did } from '@atcute/lexicons';
2
2
  import { EventIterator } from '@mary-ext/event-iterator';
3
3
  import type { CloseEvent, ErrorEvent, Options } from 'partysocket/ws';
4
4
  import type { ReadonlyDeep } from 'type-fest';
5
- import type { JetstreamEvent } from './types.ts';
6
5
  export interface JetstreamSubscriptionOptions {
7
6
  url: string | string[];
8
7
  cursor?: number;
@@ -24,6 +23,11 @@ export interface JetstreamSubscriptionOptions {
24
23
  onConnectionOpen?: (event: Event) => void;
25
24
  onConnectionClose?: (event: CloseEvent) => void;
26
25
  onConnectionError?: (event: ErrorEvent) => void;
26
+ /**
27
+ * called when an event fails schema validation. the error is a valibot `ValiError` carrying
28
+ * the validation issues. without a handler, invalid events are silently dropped.
29
+ */
30
+ onError?: (err: unknown) => void;
27
31
  /**
28
32
  * WebSocket connection options
29
33
  */
@@ -32,7 +36,71 @@ export interface JetstreamSubscriptionOptions {
32
36
  export declare class JetstreamSubscription {
33
37
  #private;
34
38
  constructor(options: JetstreamSubscriptionOptions);
35
- [Symbol.asyncIterator](): EventIterator<JetstreamEvent>;
39
+ [Symbol.asyncIterator](): EventIterator<({
40
+ did: `did:${string}:${string}`;
41
+ time_us: number;
42
+ kind: "commit";
43
+ commit: ({
44
+ rev: string;
45
+ collection: `${string}.${string}.${string}`;
46
+ rkey: string;
47
+ operation: "create";
48
+ cid: string;
49
+ record: {
50
+ [x: string]: unknown;
51
+ };
52
+ } & {
53
+ [key: string]: unknown;
54
+ }) | ({
55
+ rev: string;
56
+ collection: `${string}.${string}.${string}`;
57
+ rkey: string;
58
+ operation: "update";
59
+ cid: string;
60
+ record: {
61
+ [x: string]: unknown;
62
+ };
63
+ } & {
64
+ [key: string]: unknown;
65
+ }) | ({
66
+ rev: string;
67
+ collection: `${string}.${string}.${string}`;
68
+ rkey: string;
69
+ operation: "delete";
70
+ } & {
71
+ [key: string]: unknown;
72
+ });
73
+ } & {
74
+ [key: string]: unknown;
75
+ }) | ({
76
+ did: `did:${string}:${string}`;
77
+ time_us: number;
78
+ kind: "identity";
79
+ identity: {
80
+ did: `did:${string}:${string}`;
81
+ handle: `${string}.${string}`;
82
+ seq: number;
83
+ time: string;
84
+ } & {
85
+ [key: string]: unknown;
86
+ };
87
+ } & {
88
+ [key: string]: unknown;
89
+ }) | ({
90
+ did: `did:${string}:${string}`;
91
+ time_us: number;
92
+ kind: "account";
93
+ account: {
94
+ did: `did:${string}:${string}`;
95
+ active: boolean;
96
+ seq: number;
97
+ time: string;
98
+ } & {
99
+ [key: string]: unknown;
100
+ };
101
+ } & {
102
+ [key: string]: unknown;
103
+ })>;
36
104
  get cursor(): number;
37
105
  getOptions(): ReadonlyDeep<JetstreamSubscriptionOptions>;
38
106
  updateOptions(options: Partial<JetstreamSubscriptionOptions>): void;
@@ -1 +1 @@
1
- {"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../lib/subscription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGzD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAG9C,OAAO,KAAK,EAAE,cAAc,EAAsB,MAAM,YAAY,CAAC;AAErE,MAAM,WAAW,4BAA4B;IAC5C,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAEvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B;;;OAGG;IACH,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;IAEnB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC1C,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IAChD,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IAEhD;;OAEG;IACH,EAAE,CAAC,EAAE,OAAO,CAAC;CACb;AAID,qBAAa,qBAAqB;;IAUjC,YAAY,OAAO,EAAE,4BAA4B,EAQhD;IA4GD,CAAC,MAAM,CAAC,aAAa,CAAC,kCAkBrB;IAED,IAAI,MAAM,WAET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;;;;;;;;;;;;;QAkBrB;IAED,IAAI,MAAM,WAET;IAED,UAAU,IAAI,YAAY,CAAC,4BAA4B,CAAC,CAEvD;IAED,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,4BAA4B,CAAC,GAAG,IAAI,CAsBlE;CACD"}
@@ -1,8 +1,8 @@
1
1
  import { EventIterator } from '@mary-ext/event-iterator';
2
2
  import { SimpleEventEmitter } from '@mary-ext/simple-event-emitter';
3
3
  import { WebSocket as ReconnectingWebSocket } from 'partysocket';
4
+ import * as v from 'valibot';
4
5
  import { jetstreamEventSchema } from './typedefs.js';
5
- const PARSE_OPTIONS = { mode: 'passthrough' };
6
6
  export class JetstreamSubscription {
7
7
  #listening = 0;
8
8
  #ws;
@@ -36,7 +36,7 @@ export class JetstreamSubscription {
36
36
  if (this.#ws !== undefined) {
37
37
  return;
38
38
  }
39
- const { url: wsUrls, ws: wsOptions, validateEvents = true, onConnectionClose, onConnectionError, onConnectionOpen, } = this.#options;
39
+ const { url: wsUrls, ws: wsOptions, validateEvents = true, onConnectionClose, onConnectionError, onConnectionOpen, onError, } = this.#options;
40
40
  const emitter = this.#emitter;
41
41
  let selectedUrl;
42
42
  const getUrl = () => {
@@ -70,11 +70,12 @@ export class JetstreamSubscription {
70
70
  const raw = JSON.parse(ev.data);
71
71
  let event;
72
72
  if (validateEvents) {
73
- const result = jetstreamEventSchema.try(raw, PARSE_OPTIONS);
74
- if (!result.ok) {
73
+ const result = v.safeParse(jetstreamEventSchema, raw);
74
+ if (!result.success) {
75
+ onError?.(new v.ValiError(result.issues));
75
76
  return;
76
77
  }
77
- event = result.value;
78
+ event = result.output;
78
79
  }
79
80
  else {
80
81
  event = raw;
@@ -119,21 +120,24 @@ export class JetstreamSubscription {
119
120
  return this.#options;
120
121
  }
121
122
  updateOptions(options) {
123
+ const previousCursor = this.#cursor;
122
124
  this.#options = { ...this.#options, ...options };
123
125
  if (options.cursor !== undefined) {
124
126
  this.#cursor = options.cursor;
125
127
  }
126
128
  if (this.#ws !== undefined) {
127
- const isOptionsUpdate = Object.keys(options).every((key) => {
128
- return key === 'wantedCollections' || key === 'wantedDids';
129
+ const cursorChanged = this.#cursor !== previousCursor;
130
+ const filtersChanged = 'wantedCollections' in options || 'wantedDids' in options;
131
+ const otherKeys = Object.keys(options).some((key) => {
132
+ return key !== 'wantedCollections' && key !== 'wantedDids' && key !== 'cursor';
129
133
  });
130
- if (isOptionsUpdate) {
131
- this.#sendOptionsUpdate();
132
- }
133
- else {
134
+ if (cursorChanged || otherKeys) {
134
135
  this.#destroy();
135
136
  this.#create();
136
137
  }
138
+ else if (filtersChanged) {
139
+ this.#sendOptionsUpdate();
140
+ }
137
141
  }
138
142
  }
139
143
  }
@@ -1 +1 @@
1
- {"version":3,"file":"subscription.js","sourceRoot":"","sources":["../lib/subscription.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,SAAS,IAAI,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAIjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAmCrD,MAAM,aAAa,GAAG,EAAE,IAAI,EAAE,aAAa,EAAW,CAAC;AAEvD,MAAM,OAAO,qBAAqB;IACjC,UAAU,GAAG,CAAC,CAAC;IACf,GAAG,CAAyB;IAE5B,QAAQ,GAAG,IAAI,kBAAkB,EAA2B,CAAC;IAE7D,QAAQ,CAA+B;IACvC,OAAO,CAAS;IAChB,YAAY,CAAU;IAEtB,YAAY,OAAqC;QAChD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;QAEpD,0EAA0E;QAC1E,sEAAsE;QACtE,6BAA6B;QAC7B,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC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,EAAE,CAAC;gBAChB,IAAI,CAAC,OAAO,EAAE,CAAC;YAChB,CAAC;iBAAM,IAAI,cAAc,EAAE,CAAC;gBAC3B,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC3B,CAAC;QACF,CAAC;IACF,CAAC;CACD"}
@@ -1,16 +1,182 @@
1
- import * as v from '@badrap/valita';
2
- import type * as t from './types.ts';
3
- export declare const createCommitSchema: v.Type<t.CreateCommit>;
4
- export declare const updateCommitSchema: v.Type<t.UpdateCommit>;
5
- export declare const deleteCommitSchema: v.Type<t.DeleteCommit>;
6
- export declare const commitOperationSchema: v.Type<t.CommitOperation>;
7
- export declare const commitEventSchema: v.Type<t.CommitEvent>;
8
- export declare const identityDataSchema: v.Type<t.IdentityData>;
9
- export declare const identityEventSchema: v.Type<t.IdentityEvent>;
10
- export declare const accountDataSchema: v.Type<t.AccountData>;
11
- export declare const accountEventSchema: v.Type<t.AccountEvent>;
12
- export declare const jetstreamEventSchema: v.Type<t.JetstreamEvent>;
13
- export declare const optionsUpdatePayloadSchema: v.Type<t.OptionsUpdatePayload>;
14
- export declare const optionsUpdateProcedureSchema: v.Type<t.OptionsUpdateProcedure>;
15
- export declare const jetstreamProcedureSchema: v.Type<t.JetstreamProcedure>;
1
+ import * as v from 'valibot';
2
+ export declare const createCommitSchema: v.LooseObjectSchema<{
3
+ readonly rev: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
4
+ readonly collection: v.CustomSchema<`${string}.${string}.${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
5
+ readonly rkey: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
6
+ readonly operation: v.LiteralSchema<"create", undefined>;
7
+ readonly cid: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
8
+ readonly record: v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>;
9
+ }, undefined>;
10
+ export declare const updateCommitSchema: v.LooseObjectSchema<{
11
+ readonly rev: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
12
+ readonly collection: v.CustomSchema<`${string}.${string}.${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
13
+ readonly rkey: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
14
+ readonly operation: v.LiteralSchema<"update", undefined>;
15
+ readonly cid: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
16
+ readonly record: v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>;
17
+ }, undefined>;
18
+ export declare const deleteCommitSchema: v.LooseObjectSchema<{
19
+ readonly rev: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
20
+ readonly collection: v.CustomSchema<`${string}.${string}.${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
21
+ readonly rkey: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
22
+ readonly operation: v.LiteralSchema<"delete", undefined>;
23
+ }, undefined>;
24
+ export declare const commitOperationSchema: v.VariantSchema<"operation", [v.LooseObjectSchema<{
25
+ readonly rev: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
26
+ readonly collection: v.CustomSchema<`${string}.${string}.${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
27
+ readonly rkey: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
28
+ readonly operation: v.LiteralSchema<"create", undefined>;
29
+ readonly cid: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
30
+ readonly record: v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>;
31
+ }, undefined>, v.LooseObjectSchema<{
32
+ readonly rev: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
33
+ readonly collection: v.CustomSchema<`${string}.${string}.${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
34
+ readonly rkey: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
35
+ readonly operation: v.LiteralSchema<"update", undefined>;
36
+ readonly cid: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
37
+ readonly record: v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>;
38
+ }, undefined>, v.LooseObjectSchema<{
39
+ readonly rev: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
40
+ readonly collection: v.CustomSchema<`${string}.${string}.${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
41
+ readonly rkey: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
42
+ readonly operation: v.LiteralSchema<"delete", undefined>;
43
+ }, undefined>], undefined>;
44
+ export declare const commitEventSchema: v.LooseObjectSchema<{
45
+ readonly did: v.CustomSchema<`did:${string}:${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
46
+ readonly time_us: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
47
+ readonly kind: v.LiteralSchema<"commit", undefined>;
48
+ readonly commit: v.VariantSchema<"operation", [v.LooseObjectSchema<{
49
+ readonly rev: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
50
+ readonly collection: v.CustomSchema<`${string}.${string}.${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
51
+ readonly rkey: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
52
+ readonly operation: v.LiteralSchema<"create", undefined>;
53
+ readonly cid: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
54
+ readonly record: v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>;
55
+ }, undefined>, v.LooseObjectSchema<{
56
+ readonly rev: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
57
+ readonly collection: v.CustomSchema<`${string}.${string}.${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
58
+ readonly rkey: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
59
+ readonly operation: v.LiteralSchema<"update", undefined>;
60
+ readonly cid: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
61
+ readonly record: v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>;
62
+ }, undefined>, v.LooseObjectSchema<{
63
+ readonly rev: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
64
+ readonly collection: v.CustomSchema<`${string}.${string}.${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
65
+ readonly rkey: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
66
+ readonly operation: v.LiteralSchema<"delete", undefined>;
67
+ }, undefined>], undefined>;
68
+ }, undefined>;
69
+ export declare const identityDataSchema: v.LooseObjectSchema<{
70
+ readonly did: v.CustomSchema<`did:${string}:${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
71
+ readonly handle: v.CustomSchema<`${string}.${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
72
+ readonly seq: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
73
+ readonly time: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
74
+ }, undefined>;
75
+ export declare const identityEventSchema: v.LooseObjectSchema<{
76
+ readonly did: v.CustomSchema<`did:${string}:${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
77
+ readonly time_us: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
78
+ readonly kind: v.LiteralSchema<"identity", undefined>;
79
+ readonly identity: v.LooseObjectSchema<{
80
+ readonly did: v.CustomSchema<`did:${string}:${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
81
+ readonly handle: v.CustomSchema<`${string}.${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
82
+ readonly seq: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
83
+ readonly time: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
84
+ }, undefined>;
85
+ }, undefined>;
86
+ export declare const accountDataSchema: v.LooseObjectSchema<{
87
+ readonly did: v.CustomSchema<`did:${string}:${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
88
+ readonly active: v.BooleanSchema<undefined>;
89
+ readonly seq: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
90
+ readonly time: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
91
+ }, undefined>;
92
+ export declare const accountEventSchema: v.LooseObjectSchema<{
93
+ readonly did: v.CustomSchema<`did:${string}:${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
94
+ readonly time_us: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
95
+ readonly kind: v.LiteralSchema<"account", undefined>;
96
+ readonly account: v.LooseObjectSchema<{
97
+ readonly did: v.CustomSchema<`did:${string}:${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
98
+ readonly active: v.BooleanSchema<undefined>;
99
+ readonly seq: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
100
+ readonly time: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
101
+ }, undefined>;
102
+ }, undefined>;
103
+ export declare const jetstreamEventSchema: v.VariantSchema<"kind", [v.LooseObjectSchema<{
104
+ readonly did: v.CustomSchema<`did:${string}:${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
105
+ readonly time_us: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
106
+ readonly kind: v.LiteralSchema<"commit", undefined>;
107
+ readonly commit: v.VariantSchema<"operation", [v.LooseObjectSchema<{
108
+ readonly rev: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
109
+ readonly collection: v.CustomSchema<`${string}.${string}.${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
110
+ readonly rkey: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
111
+ readonly operation: v.LiteralSchema<"create", undefined>;
112
+ readonly cid: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
113
+ readonly record: v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>;
114
+ }, undefined>, v.LooseObjectSchema<{
115
+ readonly rev: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
116
+ readonly collection: v.CustomSchema<`${string}.${string}.${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
117
+ readonly rkey: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
118
+ readonly operation: v.LiteralSchema<"update", undefined>;
119
+ readonly cid: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
120
+ readonly record: v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>;
121
+ }, undefined>, v.LooseObjectSchema<{
122
+ readonly rev: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
123
+ readonly collection: v.CustomSchema<`${string}.${string}.${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
124
+ readonly rkey: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
125
+ readonly operation: v.LiteralSchema<"delete", undefined>;
126
+ }, undefined>], undefined>;
127
+ }, undefined>, v.LooseObjectSchema<{
128
+ readonly did: v.CustomSchema<`did:${string}:${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
129
+ readonly time_us: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
130
+ readonly kind: v.LiteralSchema<"identity", undefined>;
131
+ readonly identity: v.LooseObjectSchema<{
132
+ readonly did: v.CustomSchema<`did:${string}:${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
133
+ readonly handle: v.CustomSchema<`${string}.${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
134
+ readonly seq: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
135
+ readonly time: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
136
+ }, undefined>;
137
+ }, undefined>, v.LooseObjectSchema<{
138
+ readonly did: v.CustomSchema<`did:${string}:${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
139
+ readonly time_us: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
140
+ readonly kind: v.LiteralSchema<"account", undefined>;
141
+ readonly account: v.LooseObjectSchema<{
142
+ readonly did: v.CustomSchema<`did:${string}:${string}`, v.ErrorMessage<v.CustomIssue> | undefined>;
143
+ readonly active: v.BooleanSchema<undefined>;
144
+ readonly seq: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
145
+ readonly time: v.CustomSchema<string, v.ErrorMessage<v.CustomIssue> | undefined>;
146
+ }, undefined>;
147
+ }, undefined>], undefined>;
148
+ export declare const optionsUpdatePayloadSchema: v.LooseObjectSchema<{
149
+ readonly wantedCollections: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
150
+ readonly wantedDids: v.OptionalSchema<v.ArraySchema<v.CustomSchema<`did:${string}:${string}`, v.ErrorMessage<v.CustomIssue> | undefined>, undefined>, undefined>;
151
+ readonly maxMessageSizeBytes: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
152
+ }, undefined>;
153
+ export declare const optionsUpdateProcedureSchema: v.LooseObjectSchema<{
154
+ readonly type: v.LiteralSchema<"options_update", undefined>;
155
+ readonly payload: v.LooseObjectSchema<{
156
+ readonly wantedCollections: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
157
+ readonly wantedDids: v.OptionalSchema<v.ArraySchema<v.CustomSchema<`did:${string}:${string}`, v.ErrorMessage<v.CustomIssue> | undefined>, undefined>, undefined>;
158
+ readonly maxMessageSizeBytes: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
159
+ }, undefined>;
160
+ }, undefined>;
161
+ export declare const jetstreamProcedureSchema: v.VariantSchema<"type", [v.LooseObjectSchema<{
162
+ readonly type: v.LiteralSchema<"options_update", undefined>;
163
+ readonly payload: v.LooseObjectSchema<{
164
+ readonly wantedCollections: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
165
+ readonly wantedDids: v.OptionalSchema<v.ArraySchema<v.CustomSchema<`did:${string}:${string}`, v.ErrorMessage<v.CustomIssue> | undefined>, undefined>, undefined>;
166
+ readonly maxMessageSizeBytes: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
167
+ }, undefined>;
168
+ }, undefined>], undefined>;
169
+ export type CreateCommit = v.InferOutput<typeof createCommitSchema>;
170
+ export type UpdateCommit = v.InferOutput<typeof updateCommitSchema>;
171
+ export type DeleteCommit = v.InferOutput<typeof deleteCommitSchema>;
172
+ export type CommitOperation = v.InferOutput<typeof commitOperationSchema>;
173
+ export type CommitEvent = v.InferOutput<typeof commitEventSchema>;
174
+ export type IdentityData = v.InferOutput<typeof identityDataSchema>;
175
+ export type IdentityEvent = v.InferOutput<typeof identityEventSchema>;
176
+ export type AccountData = v.InferOutput<typeof accountDataSchema>;
177
+ export type AccountEvent = v.InferOutput<typeof accountEventSchema>;
178
+ export type JetstreamEvent = v.InferOutput<typeof jetstreamEventSchema>;
179
+ export type OptionsUpdatePayload = v.InferOutput<typeof optionsUpdatePayloadSchema>;
180
+ export type OptionsUpdateProcedure = v.InferOutput<typeof optionsUpdateProcedureSchema>;
181
+ export type JetstreamProcedure = v.InferOutput<typeof jetstreamProcedureSchema>;
16
182
  //# sourceMappingURL=typedefs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"typedefs.d.ts","sourceRoot":"","sources":["../lib/typedefs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAEpC,OAAO,KAAK,KAAK,CAAC,MAAM,YAAY,CAAC;AAoBrC,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAIpD,CAAC;AAEH,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAIpD,CAAC;AAEH,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAEpD,CAAC;AAEH,eAAO,MAAM,qBAAqB,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAI3D,CAAC;AAOF,eAAO,MAAM,iBAAiB,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAGlD,CAAC;AAEH,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAKpD,CAAC;AAEH,eAAO,MAAM,mBAAmB,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAGtD,CAAC;AAEH,eAAO,MAAM,iBAAiB,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAKlD,CAAC;AAEH,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,IAAI,CAAC,C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AAC,CAAC,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACpE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACpE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACpE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE1E,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAClE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACpE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACtE,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAClE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACpE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,0BAA0B,CAAC,CAAC;AACpF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,4BAA4B,CAAC,CAAC;AACxF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
package/dist/typedefs.js CHANGED
@@ -1,71 +1,83 @@
1
- import { isCid, isDatetime, isDid, isHandle, isNsid, isRecordKey, isTid } from '@atcute/lexicons/syntax';
2
- import * as v from '@badrap/valita';
3
- const cidString = v.string().assert(isCid, `must be a cid`);
4
- const datetimeString = v.string().assert(isDatetime, `must be a datetime`);
5
- const didString = v.string().assert(isDid, `must be a did`);
6
- const handleString = v.string().assert(isHandle, `must be a handle`);
7
- const nsidString = v.string().assert(isNsid, `must be an nsid`);
8
- const rkeyString = v.string().assert(isRecordKey, `must be a rkey`);
9
- const tidString = v.string().assert(isTid, `must be a tid`);
10
- const integer = v
11
- .number()
12
- .assert((input) => input >= 0 && Number.isSafeInteger(input), `must be a nonnegative integer`);
13
- const baseCommit = v.object({
1
+ import { isCid, isDatetime, isDid, isHandle, isNsid, isRecordKey, isTid, } from '@atcute/lexicons/syntax';
2
+ import * as v from 'valibot';
3
+ const cidString = v.custom(isCid, `must be a cid`);
4
+ const datetimeString = v.custom(isDatetime, `must be a datetime`);
5
+ const didString = v.custom(isDid, `must be a did`);
6
+ const handleString = v.custom(isHandle, `must be a handle`);
7
+ const nsidString = v.custom(isNsid, `must be an nsid`);
8
+ const rkeyString = v.custom(isRecordKey, `must be a rkey`);
9
+ const tidString = v.custom(isTid, `must be a tid`);
10
+ const integer = v.pipe(v.number(), v.safeInteger(), v.minValue(0));
11
+ const baseCommitEntries = {
14
12
  rev: tidString,
15
13
  collection: nsidString,
16
14
  rkey: rkeyString,
17
- });
18
- export const createCommitSchema = baseCommit.extend({
15
+ };
16
+ export const createCommitSchema = v.looseObject({
17
+ ...baseCommitEntries,
19
18
  operation: v.literal('create'),
20
19
  cid: cidString,
21
- record: v.record(v.unknown()),
20
+ record: v.record(v.string(), v.unknown()),
22
21
  });
23
- export const updateCommitSchema = baseCommit.extend({
22
+ export const updateCommitSchema = v.looseObject({
23
+ ...baseCommitEntries,
24
24
  operation: v.literal('update'),
25
25
  cid: cidString,
26
- record: v.record(v.unknown()),
26
+ record: v.record(v.string(), v.unknown()),
27
27
  });
28
- export const deleteCommitSchema = baseCommit.extend({
28
+ export const deleteCommitSchema = v.looseObject({
29
+ ...baseCommitEntries,
29
30
  operation: v.literal('delete'),
30
31
  });
31
- export const commitOperationSchema = v.union(createCommitSchema, updateCommitSchema, deleteCommitSchema);
32
- const baseEvent = v.object({
32
+ export const commitOperationSchema = v.variant('operation', [
33
+ createCommitSchema,
34
+ updateCommitSchema,
35
+ deleteCommitSchema,
36
+ ]);
37
+ const baseEventEntries = {
33
38
  did: didString,
34
39
  time_us: integer,
35
- });
36
- export const commitEventSchema = baseEvent.extend({
40
+ };
41
+ export const commitEventSchema = v.looseObject({
42
+ ...baseEventEntries,
37
43
  kind: v.literal('commit'),
38
44
  commit: commitOperationSchema,
39
45
  });
40
- export const identityDataSchema = v.object({
46
+ export const identityDataSchema = v.looseObject({
41
47
  did: didString,
42
48
  handle: handleString,
43
49
  seq: integer,
44
50
  time: datetimeString,
45
51
  });
46
- export const identityEventSchema = baseEvent.extend({
52
+ export const identityEventSchema = v.looseObject({
53
+ ...baseEventEntries,
47
54
  kind: v.literal('identity'),
48
55
  identity: identityDataSchema,
49
56
  });
50
- export const accountDataSchema = v.object({
57
+ export const accountDataSchema = v.looseObject({
51
58
  did: didString,
52
59
  active: v.boolean(),
53
60
  seq: integer,
54
61
  time: datetimeString,
55
62
  });
56
- export const accountEventSchema = baseEvent.extend({
63
+ export const accountEventSchema = v.looseObject({
64
+ ...baseEventEntries,
57
65
  kind: v.literal('account'),
58
66
  account: accountDataSchema,
59
67
  });
60
- export const jetstreamEventSchema = v.union(commitEventSchema, identityEventSchema, accountEventSchema);
61
- export const optionsUpdatePayloadSchema = v.object({
62
- wantedCollections: v.array(v.string()).optional(),
63
- wantedDids: v.array(didString).optional(),
64
- maxMessageSizeBytes: integer.optional(),
68
+ export const jetstreamEventSchema = v.variant('kind', [
69
+ commitEventSchema,
70
+ identityEventSchema,
71
+ accountEventSchema,
72
+ ]);
73
+ export const optionsUpdatePayloadSchema = v.looseObject({
74
+ wantedCollections: v.optional(v.array(v.string())),
75
+ wantedDids: v.optional(v.array(didString)),
76
+ maxMessageSizeBytes: v.optional(integer),
65
77
  });
66
- export const optionsUpdateProcedureSchema = v.object({
78
+ export const optionsUpdateProcedureSchema = v.looseObject({
67
79
  type: v.literal('options_update'),
68
80
  payload: optionsUpdatePayloadSchema,
69
81
  });
70
- export const jetstreamProcedureSchema = v.union(optionsUpdateProcedureSchema);
82
+ export const jetstreamProcedureSchema = v.variant('type', [optionsUpdateProcedureSchema]);
71
83
  //# sourceMappingURL=typedefs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"typedefs.js","sourceRoot":"","sources":["../lib/typedefs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEzG,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAIpC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;AAC5D,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAAC;AAC3E,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;AAC5D,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;AACrE,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAChE,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;AACpE,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;AAE5D,MAAM,OAAO,GAAG,CAAC;KACf,MAAM,EAAE;KACR,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,I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AAM,wBAAwB,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,4BAA4B,CAAC,CAAC,CAAC"}
package/lib/index.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export * from './subscription.ts';
2
- export * from './types.ts';
3
2
  export * from './typedefs.ts';
@@ -5,9 +5,9 @@ import { SimpleEventEmitter } from '@mary-ext/simple-event-emitter';
5
5
  import { WebSocket as ReconnectingWebSocket } from 'partysocket';
6
6
  import type { CloseEvent, ErrorEvent, Options } from 'partysocket/ws';
7
7
  import type { ReadonlyDeep } from 'type-fest';
8
+ import * as v from 'valibot';
8
9
 
9
- import { jetstreamEventSchema } from './typedefs.ts';
10
- import type { JetstreamEvent, JetstreamProcedure } from './types.ts';
10
+ import { jetstreamEventSchema, type JetstreamEvent, type JetstreamProcedure } from './typedefs.ts';
11
11
 
12
12
  export interface JetstreamSubscriptionOptions {
13
13
  url: string | string[];
@@ -34,6 +34,11 @@ export interface JetstreamSubscriptionOptions {
34
34
  onConnectionOpen?: (event: Event) => void;
35
35
  onConnectionClose?: (event: CloseEvent) => void;
36
36
  onConnectionError?: (event: ErrorEvent) => void;
37
+ /**
38
+ * called when an event fails schema validation. the error is a valibot `ValiError` carrying
39
+ * the validation issues. without a handler, invalid events are silently dropped.
40
+ */
41
+ onError?: (err: unknown) => void;
37
42
 
38
43
  /**
39
44
  * WebSocket connection options
@@ -41,8 +46,6 @@ export interface JetstreamSubscriptionOptions {
41
46
  ws?: Options;
42
47
  }
43
48
 
44
- const PARSE_OPTIONS = { mode: 'passthrough' } as const;
45
-
46
49
  export class JetstreamSubscription {
47
50
  #listening = 0;
48
51
  #ws?: ReconnectingWebSocket;
@@ -92,6 +95,7 @@ export class JetstreamSubscription {
92
95
  onConnectionClose,
93
96
  onConnectionError,
94
97
  onConnectionOpen,
98
+ onError,
95
99
  } = this.#options;
96
100
  const emitter = this.#emitter;
97
101
 
@@ -136,12 +140,13 @@ export class JetstreamSubscription {
136
140
 
137
141
  let event: JetstreamEvent;
138
142
  if (validateEvents) {
139
- const result = jetstreamEventSchema.try(raw, PARSE_OPTIONS);
140
- if (!result.ok) {
143
+ const result = v.safeParse(jetstreamEventSchema, raw);
144
+ if (!result.success) {
145
+ onError?.(new v.ValiError(result.issues));
141
146
  return;
142
147
  }
143
148
 
144
- event = result.value;
149
+ event = result.output;
145
150
  } else {
146
151
  event = raw;
147
152
  }
@@ -198,21 +203,25 @@ export class JetstreamSubscription {
198
203
  }
199
204
 
200
205
  updateOptions(options: Partial<JetstreamSubscriptionOptions>): void {
206
+ const previousCursor = this.#cursor;
207
+
201
208
  this.#options = { ...this.#options, ...options };
202
209
  if (options.cursor !== undefined) {
203
210
  this.#cursor = options.cursor;
204
211
  }
205
212
 
206
213
  if (this.#ws !== undefined) {
207
- const isOptionsUpdate = Object.keys(options).every((key) => {
208
- return key === 'wantedCollections' || key === 'wantedDids';
214
+ const cursorChanged = this.#cursor !== previousCursor;
215
+ const filtersChanged = 'wantedCollections' in options || 'wantedDids' in options;
216
+ const otherKeys = Object.keys(options).some((key) => {
217
+ return key !== 'wantedCollections' && key !== 'wantedDids' && key !== 'cursor';
209
218
  });
210
219
 
211
- if (isOptionsUpdate) {
212
- this.#sendOptionsUpdate();
213
- } else {
220
+ if (cursorChanged || otherKeys) {
214
221
  this.#destroy();
215
222
  this.#create();
223
+ } else if (filtersChanged) {
224
+ this.#sendOptionsUpdate();
216
225
  }
217
226
  }
218
227
  }
package/lib/typedefs.ts CHANGED
@@ -1,98 +1,131 @@
1
- import { isCid, isDatetime, isDid, isHandle, isNsid, isRecordKey, isTid } from '@atcute/lexicons/syntax';
2
-
3
- import * as v from '@badrap/valita';
4
-
5
- import type * as t from './types.ts';
6
-
7
- const cidString = v.string().assert(isCid, `must be a cid`);
8
- const datetimeString = v.string().assert(isDatetime, `must be a datetime`);
9
- const didString = v.string().assert(isDid, `must be a did`);
10
- const handleString = v.string().assert(isHandle, `must be a handle`);
11
- const nsidString = v.string().assert(isNsid, `must be an nsid`);
12
- const rkeyString = v.string().assert(isRecordKey, `must be a rkey`);
13
- const tidString = v.string().assert(isTid, `must be a tid`);
14
-
15
- const integer = v
16
- .number()
17
- .assert((input) => input >= 0 && Number.isSafeInteger(input), `must be a nonnegative integer`);
18
-
19
- const baseCommit = v.object({
1
+ import {
2
+ isCid,
3
+ isDatetime,
4
+ isDid,
5
+ isHandle,
6
+ isNsid,
7
+ isRecordKey,
8
+ isTid,
9
+ type Cid,
10
+ type Datetime,
11
+ type Did,
12
+ type Handle,
13
+ type Nsid,
14
+ type RecordKey,
15
+ type Tid,
16
+ } from '@atcute/lexicons/syntax';
17
+
18
+ import * as v from 'valibot';
19
+
20
+ const cidString = v.custom<Cid>(isCid, `must be a cid`);
21
+ const datetimeString = v.custom<Datetime>(isDatetime, `must be a datetime`);
22
+ const didString = v.custom<Did>(isDid, `must be a did`);
23
+ const handleString = v.custom<Handle>(isHandle, `must be a handle`);
24
+ const nsidString = v.custom<Nsid>(isNsid, `must be an nsid`);
25
+ const rkeyString = v.custom<RecordKey>(isRecordKey, `must be a rkey`);
26
+ const tidString = v.custom<Tid>(isTid, `must be a tid`);
27
+
28
+ const integer = v.pipe(v.number(), v.safeInteger(), v.minValue(0));
29
+
30
+ const baseCommitEntries = {
20
31
  rev: tidString,
21
32
  collection: nsidString,
22
33
  rkey: rkeyString,
23
- });
34
+ };
24
35
 
25
- export const createCommitSchema: v.Type<t.CreateCommit> = baseCommit.extend({
36
+ export const createCommitSchema = v.looseObject({
37
+ ...baseCommitEntries,
26
38
  operation: v.literal('create'),
27
39
  cid: cidString,
28
- record: v.record(v.unknown()),
40
+ record: v.record(v.string(), v.unknown()),
29
41
  });
30
42
 
31
- export const updateCommitSchema: v.Type<t.UpdateCommit> = baseCommit.extend({
43
+ export const updateCommitSchema = v.looseObject({
44
+ ...baseCommitEntries,
32
45
  operation: v.literal('update'),
33
46
  cid: cidString,
34
- record: v.record(v.unknown()),
47
+ record: v.record(v.string(), v.unknown()),
35
48
  });
36
49
 
37
- export const deleteCommitSchema: v.Type<t.DeleteCommit> = baseCommit.extend({
50
+ export const deleteCommitSchema = v.looseObject({
51
+ ...baseCommitEntries,
38
52
  operation: v.literal('delete'),
39
53
  });
40
54
 
41
- export const commitOperationSchema: v.Type<t.CommitOperation> = v.union(
55
+ export const commitOperationSchema = v.variant('operation', [
42
56
  createCommitSchema,
43
57
  updateCommitSchema,
44
58
  deleteCommitSchema,
45
- );
59
+ ]);
46
60
 
47
- const baseEvent = v.object({
61
+ const baseEventEntries = {
48
62
  did: didString,
49
63
  time_us: integer,
50
- });
64
+ };
51
65
 
52
- export const commitEventSchema: v.Type<t.CommitEvent> = baseEvent.extend({
66
+ export const commitEventSchema = v.looseObject({
67
+ ...baseEventEntries,
53
68
  kind: v.literal('commit'),
54
69
  commit: commitOperationSchema,
55
70
  });
56
71
 
57
- export const identityDataSchema: v.Type<t.IdentityData> = v.object({
72
+ export const identityDataSchema = v.looseObject({
58
73
  did: didString,
59
74
  handle: handleString,
60
75
  seq: integer,
61
76
  time: datetimeString,
62
77
  });
63
78
 
64
- export const identityEventSchema: v.Type<t.IdentityEvent> = baseEvent.extend({
79
+ export const identityEventSchema = v.looseObject({
80
+ ...baseEventEntries,
65
81
  kind: v.literal('identity'),
66
82
  identity: identityDataSchema,
67
83
  });
68
84
 
69
- export const accountDataSchema: v.Type<t.AccountData> = v.object({
85
+ export const accountDataSchema = v.looseObject({
70
86
  did: didString,
71
87
  active: v.boolean(),
72
88
  seq: integer,
73
89
  time: datetimeString,
74
90
  });
75
91
 
76
- export const accountEventSchema: v.Type<t.AccountEvent> = baseEvent.extend({
92
+ export const accountEventSchema = v.looseObject({
93
+ ...baseEventEntries,
77
94
  kind: v.literal('account'),
78
95
  account: accountDataSchema,
79
96
  });
80
97
 
81
- export const jetstreamEventSchema: v.Type<t.JetstreamEvent> = v.union(
98
+ export const jetstreamEventSchema = v.variant('kind', [
82
99
  commitEventSchema,
83
100
  identityEventSchema,
84
101
  accountEventSchema,
85
- );
102
+ ]);
86
103
 
87
- export const optionsUpdatePayloadSchema: v.Type<t.OptionsUpdatePayload> = v.object({
88
- wantedCollections: v.array(v.string()).optional(),
89
- wantedDids: v.array(didString).optional(),
90
- maxMessageSizeBytes: integer.optional(),
104
+ export const optionsUpdatePayloadSchema = v.looseObject({
105
+ wantedCollections: v.optional(v.array(v.string())),
106
+ wantedDids: v.optional(v.array(didString)),
107
+ maxMessageSizeBytes: v.optional(integer),
91
108
  });
92
109
 
93
- export const optionsUpdateProcedureSchema: v.Type<t.OptionsUpdateProcedure> = v.object({
110
+ export const optionsUpdateProcedureSchema = v.looseObject({
94
111
  type: v.literal('options_update'),
95
112
  payload: optionsUpdatePayloadSchema,
96
113
  });
97
114
 
98
- export const jetstreamProcedureSchema: v.Type<t.JetstreamProcedure> = v.union(optionsUpdateProcedureSchema);
115
+ export const jetstreamProcedureSchema = v.variant('type', [optionsUpdateProcedureSchema]);
116
+
117
+ export type CreateCommit = v.InferOutput<typeof createCommitSchema>;
118
+ export type UpdateCommit = v.InferOutput<typeof updateCommitSchema>;
119
+ export type DeleteCommit = v.InferOutput<typeof deleteCommitSchema>;
120
+ export type CommitOperation = v.InferOutput<typeof commitOperationSchema>;
121
+
122
+ export type CommitEvent = v.InferOutput<typeof commitEventSchema>;
123
+ export type IdentityData = v.InferOutput<typeof identityDataSchema>;
124
+ export type IdentityEvent = v.InferOutput<typeof identityEventSchema>;
125
+ export type AccountData = v.InferOutput<typeof accountDataSchema>;
126
+ export type AccountEvent = v.InferOutput<typeof accountEventSchema>;
127
+ export type JetstreamEvent = v.InferOutput<typeof jetstreamEventSchema>;
128
+
129
+ export type OptionsUpdatePayload = v.InferOutput<typeof optionsUpdatePayloadSchema>;
130
+ export type OptionsUpdateProcedure = v.InferOutput<typeof optionsUpdateProcedureSchema>;
131
+ export type JetstreamProcedure = v.InferOutput<typeof jetstreamProcedureSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atcute/jetstream",
3
- "version": "1.1.3",
3
+ "version": "2.0.0",
4
4
  "description": "lightweight and cute Jetstream subscriber for AT Protocol",
5
5
  "license": "0BSD",
6
6
  "repository": {
@@ -22,15 +22,15 @@
22
22
  "access": "public"
23
23
  },
24
24
  "dependencies": {
25
- "@badrap/valita": "^0.4.6",
26
25
  "@mary-ext/event-iterator": "^1.0.0",
27
26
  "@mary-ext/simple-event-emitter": "^1.0.1",
28
27
  "partysocket": "^1.1.18",
29
28
  "type-fest": "^4.41.0",
30
- "@atcute/lexicons": "^1.3.1"
29
+ "valibot": "^1.4.0",
30
+ "@atcute/lexicons": "^2.0.0"
31
31
  },
32
32
  "peerDependencies": {
33
- "@atcute/lexicons": "^1.0.0"
33
+ "@atcute/lexicons": "^2.0.0"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "tsgo",
package/dist/types.d.ts DELETED
@@ -1,61 +0,0 @@
1
- import type { Cid, Datetime, Did, Handle, Nsid, RecordKey, Tid } from '@atcute/lexicons/syntax';
2
- interface BaseCommit {
3
- rev: Tid;
4
- collection: Nsid;
5
- rkey: RecordKey;
6
- }
7
- export interface CreateCommit extends BaseCommit {
8
- operation: 'create';
9
- cid: Cid;
10
- record: unknown;
11
- }
12
- export interface UpdateCommit extends BaseCommit {
13
- operation: 'update';
14
- cid: Cid;
15
- record: unknown;
16
- }
17
- export interface DeleteCommit extends BaseCommit {
18
- operation: 'delete';
19
- }
20
- export type CommitOperation = CreateCommit | UpdateCommit | DeleteCommit;
21
- interface BaseEvent {
22
- did: Did;
23
- time_us: number;
24
- }
25
- export interface CommitEvent extends BaseEvent {
26
- kind: 'commit';
27
- commit: CommitOperation;
28
- }
29
- export interface IdentityData {
30
- did: Did;
31
- handle: Handle;
32
- seq: number;
33
- time: Datetime;
34
- }
35
- export interface IdentityEvent extends BaseEvent {
36
- kind: 'identity';
37
- identity: IdentityData;
38
- }
39
- export interface AccountData {
40
- did: Did;
41
- active: boolean;
42
- seq: number;
43
- time: Datetime;
44
- }
45
- export interface AccountEvent extends BaseEvent {
46
- kind: 'account';
47
- account: AccountData;
48
- }
49
- export type JetstreamEvent = CommitEvent | IdentityEvent | AccountEvent;
50
- export interface OptionsUpdatePayload {
51
- wantedCollections?: string[];
52
- wantedDids?: Did[];
53
- maxMessageSizeBytes?: number;
54
- }
55
- export interface OptionsUpdateProcedure {
56
- type: 'options_update';
57
- payload: OptionsUpdatePayload;
58
- }
59
- export type JetstreamProcedure = OptionsUpdateProcedure;
60
- export {};
61
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAEhG,UAAU,UAAU;IACnB,GAAG,EAAE,GAAG,CAAC;IACT,UAAU,EAAE,IAAI,CAAC;IACjB,IAAI,EAAE,SAAS,CAAC;CAChB;AAED,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC/C,SAAS,EAAE,QAAQ,CAAC;IACpB,GAAG,EAAE,GAAG,CAAC;IACT,MAAM,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC/C,SAAS,EAAE,QAAQ,CAAC;IACpB,GAAG,EAAE,GAAG,CAAC;IACT,MAAM,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC/C,SAAS,EAAE,QAAQ,CAAC;CACpB;AAED,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,YAAY,GAAG,YAAY,CAAC;AAEzE,UAAU,SAAS;IAClB,GAAG,EAAE,GAAG,CAAC;IACT,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC7C,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,eAAe,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC5B,GAAG,EAAE,GAAG,CAAC;IACT,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,QAAQ,CAAC;CACf;AAED,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC/C,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,YAAY,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC3B,GAAG,EAAE,GAAG,CAAC;IACT,MAAM,EAAE,OAAO,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,QAAQ,CAAC;CACf;AAED,MAAM,WAAW,YAAa,SAAQ,SAAS;IAC9C,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,WAAW,CAAC;CACrB;AAED,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,aAAa,GAAG,YAAY,CAAC;AAExE,MAAM,WAAW,oBAAoB;IACpC,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;IACnB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,sBAAsB;IACtC,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,EAAE,oBAAoB,CAAC;CAC9B;AAED,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,CAAC"}
package/dist/types.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":""}
package/lib/types.ts DELETED
@@ -1,74 +0,0 @@
1
- import type { Cid, Datetime, Did, Handle, Nsid, RecordKey, Tid } from '@atcute/lexicons/syntax';
2
-
3
- interface BaseCommit {
4
- rev: Tid;
5
- collection: Nsid;
6
- rkey: RecordKey;
7
- }
8
-
9
- export interface CreateCommit extends BaseCommit {
10
- operation: 'create';
11
- cid: Cid;
12
- record: unknown;
13
- }
14
-
15
- export interface UpdateCommit extends BaseCommit {
16
- operation: 'update';
17
- cid: Cid;
18
- record: unknown;
19
- }
20
-
21
- export interface DeleteCommit extends BaseCommit {
22
- operation: 'delete';
23
- }
24
-
25
- export type CommitOperation = CreateCommit | UpdateCommit | DeleteCommit;
26
-
27
- interface BaseEvent {
28
- did: Did;
29
- time_us: number;
30
- }
31
-
32
- export interface CommitEvent extends BaseEvent {
33
- kind: 'commit';
34
- commit: CommitOperation;
35
- }
36
-
37
- export interface IdentityData {
38
- did: Did;
39
- handle: Handle;
40
- seq: number;
41
- time: Datetime;
42
- }
43
-
44
- export interface IdentityEvent extends BaseEvent {
45
- kind: 'identity';
46
- identity: IdentityData;
47
- }
48
-
49
- export interface AccountData {
50
- did: Did;
51
- active: boolean;
52
- seq: number;
53
- time: Datetime;
54
- }
55
-
56
- export interface AccountEvent extends BaseEvent {
57
- kind: 'account';
58
- account: AccountData;
59
- }
60
-
61
- export type JetstreamEvent = CommitEvent | IdentityEvent | AccountEvent;
62
-
63
- export interface OptionsUpdatePayload {
64
- wantedCollections?: string[];
65
- wantedDids?: Did[];
66
- maxMessageSizeBytes?: number;
67
- }
68
-
69
- export interface OptionsUpdateProcedure {
70
- type: 'options_update';
71
- payload: OptionsUpdatePayload;
72
- }
73
-
74
- export type JetstreamProcedure = OptionsUpdateProcedure;