@atcute/jetstream 1.1.1 → 1.1.3
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 +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/subscription.d.ts +2 -45
- package/dist/subscription.d.ts.map +1 -1
- package/dist/subscription.js +1 -1
- package/dist/subscription.js.map +1 -1
- package/dist/typedefs.d.ts +16 -0
- package/dist/typedefs.d.ts.map +1 -0
- package/dist/typedefs.js +71 -0
- package/dist/typedefs.js.map +1 -0
- package/dist/types.d.ts +59 -249
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -93
- package/dist/types.js.map +1 -1
- package/lib/index.ts +3 -2
- package/lib/subscription.ts +2 -3
- package/lib/typedefs.ts +98 -0
- package/lib/types.ts +47 -259
- package/package.json +13 -12
package/lib/types.ts
CHANGED
|
@@ -1,286 +1,74 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { Cid, Datetime, Did, Handle, Nsid, RecordKey, Tid } from '@atcute/lexicons/syntax';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const cidStringSchema = _cidStringSchema as cidStringSchema.$schema;
|
|
8
|
-
declare namespace cidStringSchema {
|
|
9
|
-
export {};
|
|
10
|
-
|
|
11
|
-
type $schematype = typeof _cidStringSchema;
|
|
12
|
-
export interface $schema extends $schematype {}
|
|
13
|
-
}
|
|
14
|
-
const _datetimeStringSchema = v.string().assert(syntax.isDatetime, `must be a datetime`);
|
|
15
|
-
|
|
16
|
-
const datetimeStringSchema = _datetimeStringSchema as datetimeStringSchema.$schema;
|
|
17
|
-
declare namespace datetimeStringSchema {
|
|
18
|
-
export {};
|
|
19
|
-
|
|
20
|
-
type $schematype = typeof _datetimeStringSchema;
|
|
21
|
-
export interface $schema extends $schematype {}
|
|
22
|
-
}
|
|
23
|
-
const _didStringSchema = v.string().assert(syntax.isDid, `must be a did`);
|
|
24
|
-
|
|
25
|
-
const didStringSchema = _didStringSchema as didStringSchema.$schema;
|
|
26
|
-
declare namespace didStringSchema {
|
|
27
|
-
export {};
|
|
28
|
-
|
|
29
|
-
type $schematype = typeof _didStringSchema;
|
|
30
|
-
export interface $schema extends $schematype {}
|
|
31
|
-
}
|
|
32
|
-
const _handleStringSchema = v.string().assert(syntax.isHandle, `must be a handle`);
|
|
33
|
-
|
|
34
|
-
const handleStringSchema = _handleStringSchema as handleStringSchema.$schema;
|
|
35
|
-
declare namespace handleStringSchema {
|
|
36
|
-
export {};
|
|
37
|
-
|
|
38
|
-
type $schematype = typeof _handleStringSchema;
|
|
39
|
-
export interface $schema extends $schematype {}
|
|
40
|
-
}
|
|
41
|
-
const _nsidStringSchema = v.string().assert(syntax.isNsid, `must be an nsid`);
|
|
42
|
-
|
|
43
|
-
const nsidStringSchema = _nsidStringSchema as nsidStringSchema.$schema;
|
|
44
|
-
declare namespace nsidStringSchema {
|
|
45
|
-
export {};
|
|
46
|
-
|
|
47
|
-
type $schematype = typeof _nsidStringSchema;
|
|
48
|
-
export interface $schema extends $schematype {}
|
|
49
|
-
}
|
|
50
|
-
const _rkeyStringSchema = v.string().assert(syntax.isRecordKey, `must be a rkey`);
|
|
51
|
-
|
|
52
|
-
const rkeyStringSchema = _rkeyStringSchema as rkeyStringSchema.$schema;
|
|
53
|
-
declare namespace rkeyStringSchema {
|
|
54
|
-
export {};
|
|
55
|
-
|
|
56
|
-
type $schematype = typeof _rkeyStringSchema;
|
|
57
|
-
export interface $schema extends $schematype {}
|
|
58
|
-
}
|
|
59
|
-
const _tidStringSchema = v.string().assert(syntax.isTid, `must be a tid`);
|
|
60
|
-
|
|
61
|
-
const tidStringSchema = _tidStringSchema as tidStringSchema.$schema;
|
|
62
|
-
declare namespace tidStringSchema {
|
|
63
|
-
export {};
|
|
64
|
-
|
|
65
|
-
type $schematype = typeof _tidStringSchema;
|
|
66
|
-
export interface $schema extends $schematype {}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const _integerSchema = v
|
|
70
|
-
.number()
|
|
71
|
-
.assert((input) => input >= 0 && Number.isSafeInteger(input), `must be a nonnegative integer`);
|
|
72
|
-
|
|
73
|
-
const integerSchema = _integerSchema as integerSchema.$schema;
|
|
74
|
-
declare namespace integerSchema {
|
|
75
|
-
export {};
|
|
76
|
-
|
|
77
|
-
type $schematype = typeof _integerSchema;
|
|
78
|
-
export interface $schema extends $schematype {}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const _baseCommitSchema = v.object({
|
|
82
|
-
rev: tidStringSchema,
|
|
83
|
-
collection: nsidStringSchema,
|
|
84
|
-
rkey: rkeyStringSchema,
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
const baseCommitSchema = _baseCommitSchema as baseCommitSchema.$schema;
|
|
88
|
-
declare namespace baseCommitSchema {
|
|
89
|
-
export {};
|
|
90
|
-
|
|
91
|
-
type $schematype = typeof _baseCommitSchema;
|
|
92
|
-
export interface $schema extends $schematype {}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const _createCommitSchema = baseCommitSchema.extend({
|
|
96
|
-
operation: v.literal('create'),
|
|
97
|
-
cid: cidStringSchema,
|
|
98
|
-
record: v.record(v.unknown()),
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
export const createCommitSchema = _createCommitSchema as createCommitSchema.$schema;
|
|
102
|
-
export interface CreateCommit extends v.Infer<typeof createCommitSchema> {}
|
|
103
|
-
export declare namespace createCommitSchema {
|
|
104
|
-
export {};
|
|
105
|
-
|
|
106
|
-
type $schematype = typeof _createCommitSchema;
|
|
107
|
-
export interface $schema extends $schematype {}
|
|
3
|
+
interface BaseCommit {
|
|
4
|
+
rev: Tid;
|
|
5
|
+
collection: Nsid;
|
|
6
|
+
rkey: RecordKey;
|
|
108
7
|
}
|
|
109
8
|
|
|
110
|
-
|
|
111
|
-
operation:
|
|
112
|
-
cid:
|
|
113
|
-
record:
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
export const updateCommitSchema = _updateCommitSchema as updateCommitSchema.$schema;
|
|
117
|
-
export interface UpdateCommit extends v.Infer<typeof updateCommitSchema> {}
|
|
118
|
-
export declare namespace updateCommitSchema {
|
|
119
|
-
export {};
|
|
120
|
-
|
|
121
|
-
type $schematype = typeof _updateCommitSchema;
|
|
122
|
-
export interface $schema extends $schematype {}
|
|
9
|
+
export interface CreateCommit extends BaseCommit {
|
|
10
|
+
operation: 'create';
|
|
11
|
+
cid: Cid;
|
|
12
|
+
record: unknown;
|
|
123
13
|
}
|
|
124
14
|
|
|
125
|
-
|
|
126
|
-
operation:
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
export const deleteCommitSchema = _deleteCommitSchema as deleteCommitSchema.$schema;
|
|
130
|
-
export interface DeleteCommit extends v.Infer<typeof deleteCommitSchema> {}
|
|
131
|
-
export declare namespace deleteCommitSchema {
|
|
132
|
-
export {};
|
|
133
|
-
|
|
134
|
-
type $schematype = typeof _deleteCommitSchema;
|
|
135
|
-
export interface $schema extends $schematype {}
|
|
15
|
+
export interface UpdateCommit extends BaseCommit {
|
|
16
|
+
operation: 'update';
|
|
17
|
+
cid: Cid;
|
|
18
|
+
record: unknown;
|
|
136
19
|
}
|
|
137
20
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
export const commitOperationSchema = _commitOperationSchema as commitSchema.$schema;
|
|
141
|
-
export type CommitOperation = v.Infer<typeof commitOperationSchema>;
|
|
142
|
-
export declare namespace commitSchema {
|
|
143
|
-
export {};
|
|
144
|
-
|
|
145
|
-
type $schematype = typeof _commitOperationSchema;
|
|
146
|
-
export interface $schema extends $schematype {}
|
|
21
|
+
export interface DeleteCommit extends BaseCommit {
|
|
22
|
+
operation: 'delete';
|
|
147
23
|
}
|
|
148
24
|
|
|
149
|
-
|
|
150
|
-
did: didStringSchema,
|
|
151
|
-
time_us: integerSchema,
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
const baseEventSchema = _baseEventSchema as baseEventSchema.$schema;
|
|
155
|
-
declare namespace baseEventSchema {
|
|
156
|
-
export {};
|
|
25
|
+
export type CommitOperation = CreateCommit | UpdateCommit | DeleteCommit;
|
|
157
26
|
|
|
158
|
-
|
|
159
|
-
|
|
27
|
+
interface BaseEvent {
|
|
28
|
+
did: Did;
|
|
29
|
+
time_us: number;
|
|
160
30
|
}
|
|
161
31
|
|
|
162
|
-
|
|
163
|
-
kind:
|
|
164
|
-
commit:
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
export const commitEventSchema = _commitEventSchema as commitEventSchema.$schema;
|
|
168
|
-
export interface CommitEvent extends v.Infer<typeof commitEventSchema> {}
|
|
169
|
-
export declare namespace commitEventSchema {
|
|
170
|
-
export {};
|
|
171
|
-
|
|
172
|
-
type $schematype = typeof _commitEventSchema;
|
|
173
|
-
export interface $schema extends $schematype {}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const _identityDataSchema = v.object({
|
|
177
|
-
did: didStringSchema,
|
|
178
|
-
handle: handleStringSchema,
|
|
179
|
-
seq: integerSchema,
|
|
180
|
-
time: datetimeStringSchema,
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
export const identityDataSchema = _identityDataSchema as identityData.$schema;
|
|
184
|
-
export interface IdentityData extends v.Infer<typeof identityDataSchema> {}
|
|
185
|
-
export declare namespace identityData {
|
|
186
|
-
export {};
|
|
187
|
-
|
|
188
|
-
type $schematype = typeof _identityDataSchema;
|
|
189
|
-
export interface $schema extends $schematype {}
|
|
32
|
+
export interface CommitEvent extends BaseEvent {
|
|
33
|
+
kind: 'commit';
|
|
34
|
+
commit: CommitOperation;
|
|
190
35
|
}
|
|
191
36
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
export const identityEventSchema = _identityEventSchema as identityEventSchema.$schema;
|
|
198
|
-
export interface IdentityEvent extends v.Infer<typeof identityEventSchema> {}
|
|
199
|
-
export declare namespace identityEventSchema {
|
|
200
|
-
export {};
|
|
201
|
-
|
|
202
|
-
type $schematype = typeof _identityEventSchema;
|
|
203
|
-
export interface $schema extends $schematype {}
|
|
37
|
+
export interface IdentityData {
|
|
38
|
+
did: Did;
|
|
39
|
+
handle: Handle;
|
|
40
|
+
seq: number;
|
|
41
|
+
time: Datetime;
|
|
204
42
|
}
|
|
205
43
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
seq: integerSchema,
|
|
210
|
-
time: datetimeStringSchema,
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
export const accountDataSchema = _accountDataSchema as accountDataSchema.$schema;
|
|
214
|
-
export interface AccountData extends v.Infer<typeof accountDataSchema> {}
|
|
215
|
-
export declare namespace accountDataSchema {
|
|
216
|
-
export {};
|
|
217
|
-
|
|
218
|
-
type $schematype = typeof _accountDataSchema;
|
|
219
|
-
export interface $schema extends $schematype {}
|
|
44
|
+
export interface IdentityEvent extends BaseEvent {
|
|
45
|
+
kind: 'identity';
|
|
46
|
+
identity: IdentityData;
|
|
220
47
|
}
|
|
221
48
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
export const accountEventSchema = _accountEventSchema as accountEventSchema.$schema;
|
|
228
|
-
export interface AccountEvent extends v.Infer<typeof accountEventSchema> {}
|
|
229
|
-
export declare namespace accountEventSchema {
|
|
230
|
-
export {};
|
|
231
|
-
|
|
232
|
-
type $schematype = typeof _accountEventSchema;
|
|
233
|
-
export interface $schema extends $schematype {}
|
|
49
|
+
export interface AccountData {
|
|
50
|
+
did: Did;
|
|
51
|
+
active: boolean;
|
|
52
|
+
seq: number;
|
|
53
|
+
time: Datetime;
|
|
234
54
|
}
|
|
235
55
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
export type JetstreamEvent = v.Infer<typeof jetstreamEventSchema>;
|
|
240
|
-
export declare namespace jetstreamEventSchema {
|
|
241
|
-
export {};
|
|
242
|
-
|
|
243
|
-
type $schematype = typeof _jetstreamEventSchema;
|
|
244
|
-
export interface $schema extends $schematype {}
|
|
56
|
+
export interface AccountEvent extends BaseEvent {
|
|
57
|
+
kind: 'account';
|
|
58
|
+
account: AccountData;
|
|
245
59
|
}
|
|
246
60
|
|
|
247
|
-
|
|
248
|
-
wantedCollections: v.array(v.string()).optional(),
|
|
249
|
-
wantedDids: v.array(didStringSchema).optional(),
|
|
250
|
-
maxMessageSizeBytes: integerSchema.optional(),
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
export const optionsUpdatePayloadSchema = _optionsUpdatePayloadSchema as optionsUpdatePayloadSchema.$schema;
|
|
254
|
-
export interface OptionsUpdatePayload extends v.Infer<typeof optionsUpdatePayloadSchema> {}
|
|
255
|
-
export declare namespace optionsUpdatePayloadSchema {
|
|
256
|
-
export {};
|
|
61
|
+
export type JetstreamEvent = CommitEvent | IdentityEvent | AccountEvent;
|
|
257
62
|
|
|
258
|
-
|
|
259
|
-
|
|
63
|
+
export interface OptionsUpdatePayload {
|
|
64
|
+
wantedCollections?: string[];
|
|
65
|
+
wantedDids?: Did[];
|
|
66
|
+
maxMessageSizeBytes?: number;
|
|
260
67
|
}
|
|
261
68
|
|
|
262
|
-
|
|
263
|
-
type:
|
|
264
|
-
payload:
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
export const optionsUpdateProcedureSchema =
|
|
268
|
-
_optionsUpdateProcedureSchema as optionsUpdateProcedureSchema.$schema;
|
|
269
|
-
export interface OptionsUpdateProcedure extends v.Infer<typeof optionsUpdateProcedureSchema> {}
|
|
270
|
-
export declare namespace optionsUpdateProcedureSchema {
|
|
271
|
-
export {};
|
|
272
|
-
|
|
273
|
-
type $schematype = typeof _optionsUpdateProcedureSchema;
|
|
274
|
-
export interface $schema extends $schematype {}
|
|
69
|
+
export interface OptionsUpdateProcedure {
|
|
70
|
+
type: 'options_update';
|
|
71
|
+
payload: OptionsUpdatePayload;
|
|
275
72
|
}
|
|
276
73
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
export const jetstreamProcedureSchema = _jetstreamProcedureSchema as jetstreamProcedureSchema.$schema;
|
|
280
|
-
export type JetstreamProcedure = v.Infer<typeof jetstreamProcedureSchema>;
|
|
281
|
-
export declare namespace jetstreamProcedureSchema {
|
|
282
|
-
export {};
|
|
283
|
-
|
|
284
|
-
type $schematype = typeof _jetstreamProcedureSchema;
|
|
285
|
-
export interface $schema extends $schematype {}
|
|
286
|
-
}
|
|
74
|
+
export type JetstreamProcedure = OptionsUpdateProcedure;
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"type": "module",
|
|
3
2
|
"name": "@atcute/jetstream",
|
|
4
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
5
4
|
"description": "lightweight and cute Jetstream subscriber for AT Protocol",
|
|
6
5
|
"license": "0BSD",
|
|
7
6
|
"repository": {
|
|
@@ -12,27 +11,29 @@
|
|
|
12
11
|
"dist/",
|
|
13
12
|
"lib/",
|
|
14
13
|
"!lib/**/*.bench.ts",
|
|
15
|
-
"!lib/**/*.test.ts"
|
|
14
|
+
"!lib/**/*.test.ts",
|
|
15
|
+
"!dist/**/*.{test,bench}.*"
|
|
16
16
|
],
|
|
17
|
+
"type": "module",
|
|
17
18
|
"exports": {
|
|
18
19
|
".": "./dist/index.js"
|
|
19
20
|
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
20
24
|
"dependencies": {
|
|
21
25
|
"@badrap/valita": "^0.4.6",
|
|
22
26
|
"@mary-ext/event-iterator": "^1.0.0",
|
|
23
|
-
"@mary-ext/simple-event-emitter": "^1.0.
|
|
24
|
-
"partysocket": "^1.1.
|
|
27
|
+
"@mary-ext/simple-event-emitter": "^1.0.1",
|
|
28
|
+
"partysocket": "^1.1.18",
|
|
25
29
|
"type-fest": "^4.41.0",
|
|
26
|
-
"
|
|
27
|
-
"@atcute/lexicons": "^1.2.2"
|
|
30
|
+
"@atcute/lexicons": "^1.3.1"
|
|
28
31
|
},
|
|
29
|
-
"
|
|
30
|
-
"@
|
|
31
|
-
"vitest": "^3.2.4"
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@atcute/lexicons": "^1.0.0"
|
|
32
34
|
},
|
|
33
35
|
"scripts": {
|
|
34
|
-
"build": "
|
|
35
|
-
"test": "vitest run --coverage",
|
|
36
|
+
"build": "tsgo",
|
|
36
37
|
"prepublish": "rm -rf dist; pnpm run build"
|
|
37
38
|
}
|
|
38
39
|
}
|