@atcute/jetstream 1.1.2 → 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/README.md +222 -13
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/subscription.d.ts +70 -2
- package/dist/subscription.d.ts.map +1 -1
- package/dist/subscription.js +15 -11
- package/dist/subscription.js.map +1 -1
- package/dist/typedefs.d.ts +181 -15
- package/dist/typedefs.d.ts.map +1 -1
- package/dist/typedefs.js +46 -34
- package/dist/typedefs.js.map +1 -1
- package/lib/index.ts +2 -3
- package/lib/subscription.ts +21 -14
- package/lib/typedefs.ts +75 -42
- package/package.json +14 -13
- package/dist/types.d.ts +0 -61
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/lib/types.ts +0 -74
package/dist/typedefs.d.ts
CHANGED
|
@@ -1,16 +1,182 @@
|
|
|
1
|
-
import * as v from '
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
package/dist/typedefs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typedefs.d.ts","sourceRoot":"","sources":["../lib/typedefs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"typedefs.d.ts","sourceRoot":"","sources":["../lib/typedefs.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAkB7B,eAAO,MAAM,kBAAkB;;;;;;;aAK7B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;aAK7B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;aAG7B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;0BAIhC,CAAC;AAOH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;aAI5B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;aAK7B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;aAI9B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;aAK5B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;aAI7B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAI/B,CAAC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,71 +1,83 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
const cidString = v.
|
|
4
|
-
const datetimeString = v.
|
|
5
|
-
const didString = v.
|
|
6
|
-
const handleString = v.
|
|
7
|
-
const nsidString = v.
|
|
8
|
-
const rkeyString = v.
|
|
9
|
-
const tidString = v.
|
|
10
|
-
const integer = v
|
|
11
|
-
|
|
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 =
|
|
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 =
|
|
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 =
|
|
28
|
+
export const deleteCommitSchema = v.looseObject({
|
|
29
|
+
...baseCommitEntries,
|
|
29
30
|
operation: v.literal('delete'),
|
|
30
31
|
});
|
|
31
|
-
export const commitOperationSchema = v.
|
|
32
|
-
|
|
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 =
|
|
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.
|
|
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 =
|
|
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.
|
|
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 =
|
|
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.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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.
|
|
78
|
+
export const optionsUpdateProcedureSchema = v.looseObject({
|
|
67
79
|
type: v.literal('options_update'),
|
|
68
80
|
payload: optionsUpdatePayloadSchema,
|
|
69
81
|
});
|
|
70
|
-
export const jetstreamProcedureSchema = v.
|
|
82
|
+
export const jetstreamProcedureSchema = v.variant('type', [optionsUpdateProcedureSchema]);
|
|
71
83
|
//# sourceMappingURL=typedefs.js.map
|
package/dist/typedefs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typedefs.js","sourceRoot":"","sources":["../lib/typedefs.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"typedefs.js","sourceRoot":"","sources":["../lib/typedefs.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,EACL,UAAU,EACV,KAAK,EACL,QAAQ,EACR,MAAM,EACN,WAAW,EACX,KAAK,GAQL,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAM,KAAK,EAAE,eAAe,CAAC,CAAC;AACxD,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAW,UAAU,EAAE,oBAAoB,CAAC,CAAC;AAC5E,MAAM,SAAS,G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AC,SAAS,CAAC;IAC1B,OAAO,EAAE,iBAAiB;CAC1B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE;IACrD,iBAAiB;IACjB,mBAAmB;IACnB,kBAAkB;CAClB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,WAAW,CAAC;IACvD,iBAAiB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAClD,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC1C,mBAAmB,EAAE,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;CACxC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,WAAW,CAAC;IACzD,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC;IACjC,OAAO,EAAE,0BAA0B;CACnC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,4BAA4B,CAAC,CAAC,CAAC"}
|
package/lib/index.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export * from './subscription.
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './typedefs.js';
|
|
1
|
+
export * from './subscription.ts';
|
|
2
|
+
export * from './typedefs.ts';
|
package/lib/subscription.ts
CHANGED
|
@@ -2,14 +2,12 @@ import type { Did } from '@atcute/lexicons';
|
|
|
2
2
|
|
|
3
3
|
import { EventIterator } from '@mary-ext/event-iterator';
|
|
4
4
|
import { SimpleEventEmitter } from '@mary-ext/simple-event-emitter';
|
|
5
|
-
|
|
6
5
|
import { WebSocket as ReconnectingWebSocket } from 'partysocket';
|
|
7
6
|
import type { CloseEvent, ErrorEvent, Options } from 'partysocket/ws';
|
|
8
|
-
|
|
9
7
|
import type { ReadonlyDeep } from 'type-fest';
|
|
8
|
+
import * as v from 'valibot';
|
|
10
9
|
|
|
11
|
-
import type
|
|
12
|
-
import { jetstreamEventSchema } from './typedefs.js';
|
|
10
|
+
import { jetstreamEventSchema, type JetstreamEvent, type JetstreamProcedure } from './typedefs.ts';
|
|
13
11
|
|
|
14
12
|
export interface JetstreamSubscriptionOptions {
|
|
15
13
|
url: string | string[];
|
|
@@ -36,6 +34,11 @@ export interface JetstreamSubscriptionOptions {
|
|
|
36
34
|
onConnectionOpen?: (event: Event) => void;
|
|
37
35
|
onConnectionClose?: (event: CloseEvent) => void;
|
|
38
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;
|
|
39
42
|
|
|
40
43
|
/**
|
|
41
44
|
* WebSocket connection options
|
|
@@ -43,8 +46,6 @@ export interface JetstreamSubscriptionOptions {
|
|
|
43
46
|
ws?: Options;
|
|
44
47
|
}
|
|
45
48
|
|
|
46
|
-
const PARSE_OPTIONS = { mode: 'passthrough' } as const;
|
|
47
|
-
|
|
48
49
|
export class JetstreamSubscription {
|
|
49
50
|
#listening = 0;
|
|
50
51
|
#ws?: ReconnectingWebSocket;
|
|
@@ -94,6 +95,7 @@ export class JetstreamSubscription {
|
|
|
94
95
|
onConnectionClose,
|
|
95
96
|
onConnectionError,
|
|
96
97
|
onConnectionOpen,
|
|
98
|
+
onError,
|
|
97
99
|
} = this.#options;
|
|
98
100
|
const emitter = this.#emitter;
|
|
99
101
|
|
|
@@ -138,12 +140,13 @@ export class JetstreamSubscription {
|
|
|
138
140
|
|
|
139
141
|
let event: JetstreamEvent;
|
|
140
142
|
if (validateEvents) {
|
|
141
|
-
const result =
|
|
142
|
-
if (!result.
|
|
143
|
+
const result = v.safeParse(jetstreamEventSchema, raw);
|
|
144
|
+
if (!result.success) {
|
|
145
|
+
onError?.(new v.ValiError(result.issues));
|
|
143
146
|
return;
|
|
144
147
|
}
|
|
145
148
|
|
|
146
|
-
event = result.
|
|
149
|
+
event = result.output;
|
|
147
150
|
} else {
|
|
148
151
|
event = raw;
|
|
149
152
|
}
|
|
@@ -200,21 +203,25 @@ export class JetstreamSubscription {
|
|
|
200
203
|
}
|
|
201
204
|
|
|
202
205
|
updateOptions(options: Partial<JetstreamSubscriptionOptions>): void {
|
|
206
|
+
const previousCursor = this.#cursor;
|
|
207
|
+
|
|
203
208
|
this.#options = { ...this.#options, ...options };
|
|
204
209
|
if (options.cursor !== undefined) {
|
|
205
210
|
this.#cursor = options.cursor;
|
|
206
211
|
}
|
|
207
212
|
|
|
208
213
|
if (this.#ws !== undefined) {
|
|
209
|
-
const
|
|
210
|
-
|
|
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';
|
|
211
218
|
});
|
|
212
219
|
|
|
213
|
-
if (
|
|
214
|
-
this.#sendOptionsUpdate();
|
|
215
|
-
} else {
|
|
220
|
+
if (cursorChanged || otherKeys) {
|
|
216
221
|
this.#destroy();
|
|
217
222
|
this.#create();
|
|
223
|
+
} else if (filtersChanged) {
|
|
224
|
+
this.#sendOptionsUpdate();
|
|
218
225
|
}
|
|
219
226
|
}
|
|
220
227
|
}
|
package/lib/typedefs.ts
CHANGED
|
@@ -1,98 +1,131 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
|
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
|
|
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
|
|
50
|
+
export const deleteCommitSchema = v.looseObject({
|
|
51
|
+
...baseCommitEntries,
|
|
38
52
|
operation: v.literal('delete'),
|
|
39
53
|
});
|
|
40
54
|
|
|
41
|
-
export const commitOperationSchema
|
|
55
|
+
export const commitOperationSchema = v.variant('operation', [
|
|
42
56
|
createCommitSchema,
|
|
43
57
|
updateCommitSchema,
|
|
44
58
|
deleteCommitSchema,
|
|
45
|
-
);
|
|
59
|
+
]);
|
|
46
60
|
|
|
47
|
-
const
|
|
61
|
+
const baseEventEntries = {
|
|
48
62
|
did: didString,
|
|
49
63
|
time_us: integer,
|
|
50
|
-
}
|
|
64
|
+
};
|
|
51
65
|
|
|
52
|
-
export const commitEventSchema
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
98
|
+
export const jetstreamEventSchema = v.variant('kind', [
|
|
82
99
|
commitEventSchema,
|
|
83
100
|
identityEventSchema,
|
|
84
101
|
accountEventSchema,
|
|
85
|
-
);
|
|
102
|
+
]);
|
|
86
103
|
|
|
87
|
-
export const optionsUpdatePayloadSchema
|
|
88
|
-
wantedCollections: v.array(v.string())
|
|
89
|
-
wantedDids: v.array(didString)
|
|
90
|
-
maxMessageSizeBytes:
|
|
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
|
|
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
|
|
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>;
|