@atproto/xrpc-server 0.10.2 → 0.10.4
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/CHANGELOG.md +18 -0
- package/package.json +7 -7
- package/tests/subscriptions.test.ts +58 -28
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atproto/xrpc-server
|
|
2
2
|
|
|
3
|
+
## 0.10.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`b4a76ba`](https://github.com/bluesky-social/atproto/commit/b4a76bae7bef1189302488d43ce49a03fd61f957)]:
|
|
8
|
+
- @atproto/ws-client@0.0.4
|
|
9
|
+
|
|
10
|
+
## 0.10.3
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [[`693784c`](https://github.com/bluesky-social/atproto/commit/693784c3a0dee4b6a29aa1e018fce682dcae148f), [`d551b0e`](https://github.com/bluesky-social/atproto/commit/d551b0e3527714c111c3ec6e4c90ad7f46369fab), [`7e1d458`](https://github.com/bluesky-social/atproto/commit/7e1d45877bca0f615e7b1313cfcc66823b3de758)]:
|
|
15
|
+
- @atproto/lex-data@0.0.3
|
|
16
|
+
- @atproto/lexicon@0.6.0
|
|
17
|
+
- @atproto/lex-cbor@0.0.3
|
|
18
|
+
- @atproto/common@0.5.3
|
|
19
|
+
- @atproto/xrpc@0.7.7
|
|
20
|
+
|
|
3
21
|
## 0.10.2
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/xrpc-server",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "atproto HTTP API (XRPC) server library",
|
|
6
6
|
"keywords": [
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
"rate-limiter-flexible": "^2.4.1",
|
|
26
26
|
"ws": "^8.12.0",
|
|
27
27
|
"zod": "^3.23.8",
|
|
28
|
-
"@atproto/common": "^0.5.
|
|
28
|
+
"@atproto/common": "^0.5.3",
|
|
29
29
|
"@atproto/crypto": "^0.4.5",
|
|
30
|
-
"@atproto/lex-data": "0.0.
|
|
31
|
-
"@atproto/
|
|
32
|
-
"@atproto/
|
|
33
|
-
"@atproto/
|
|
34
|
-
"@atproto/
|
|
30
|
+
"@atproto/lex-data": "0.0.3",
|
|
31
|
+
"@atproto/lex-cbor": "0.0.3",
|
|
32
|
+
"@atproto/lexicon": "^0.6.0",
|
|
33
|
+
"@atproto/xrpc": "^0.7.7",
|
|
34
|
+
"@atproto/ws-client": "^0.0.4"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/express": "^4.17.13",
|
|
@@ -27,13 +27,14 @@ const LEXICONS: LexiconDoc[] = [
|
|
|
27
27
|
},
|
|
28
28
|
},
|
|
29
29
|
message: {
|
|
30
|
-
schema: {
|
|
31
|
-
type: 'object',
|
|
32
|
-
required: ['count'],
|
|
33
|
-
properties: { count: { type: 'integer' } },
|
|
34
|
-
},
|
|
30
|
+
schema: { type: 'union', refs: ['#countdownStatus'] },
|
|
35
31
|
},
|
|
36
32
|
},
|
|
33
|
+
countdownStatus: {
|
|
34
|
+
type: 'object',
|
|
35
|
+
required: ['count'],
|
|
36
|
+
properties: { count: { type: 'integer' } },
|
|
37
|
+
},
|
|
37
38
|
},
|
|
38
39
|
},
|
|
39
40
|
{
|
|
@@ -74,6 +75,30 @@ const LEXICONS: LexiconDoc[] = [
|
|
|
74
75
|
defs: {
|
|
75
76
|
main: {
|
|
76
77
|
type: 'subscription',
|
|
78
|
+
message: {
|
|
79
|
+
schema: { type: 'union', refs: ['#auth'] },
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
auth: {
|
|
83
|
+
type: 'object',
|
|
84
|
+
properties: {
|
|
85
|
+
credentials: { type: 'ref', ref: '#credentials' },
|
|
86
|
+
artifacts: { type: 'ref', ref: '#artifacts' },
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
credentials: {
|
|
90
|
+
type: 'object',
|
|
91
|
+
required: ['username'],
|
|
92
|
+
properties: {
|
|
93
|
+
username: { type: 'string' },
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
artifacts: {
|
|
97
|
+
type: 'object',
|
|
98
|
+
required: ['original'],
|
|
99
|
+
properties: {
|
|
100
|
+
original: { type: 'string' },
|
|
101
|
+
},
|
|
77
102
|
},
|
|
78
103
|
},
|
|
79
104
|
},
|
|
@@ -89,7 +114,7 @@ describe('Subscriptions', () => {
|
|
|
89
114
|
const countdown = Number(params.countdown ?? 0)
|
|
90
115
|
for (let i = countdown; i >= 0; i--) {
|
|
91
116
|
await wait(0)
|
|
92
|
-
yield { count: i }
|
|
117
|
+
yield { $type: '#countdownStatus', count: i }
|
|
93
118
|
}
|
|
94
119
|
})
|
|
95
120
|
|
|
@@ -110,7 +135,7 @@ describe('Subscriptions', () => {
|
|
|
110
135
|
server.streamMethod('io.example.streamAuth', {
|
|
111
136
|
auth: createBasicAuth({ username: 'admin', password: 'password' }),
|
|
112
137
|
handler: async function* ({ auth }) {
|
|
113
|
-
yield auth
|
|
138
|
+
yield { ...auth, $type: 'io.example.streamAuth#auth' }
|
|
114
139
|
},
|
|
115
140
|
})
|
|
116
141
|
|
|
@@ -135,12 +160,12 @@ describe('Subscriptions', () => {
|
|
|
135
160
|
}
|
|
136
161
|
|
|
137
162
|
expect(frames).toEqual([
|
|
138
|
-
new MessageFrame({ count: 5 }),
|
|
139
|
-
new MessageFrame({ count: 4 }),
|
|
140
|
-
new MessageFrame({ count: 3 }),
|
|
141
|
-
new MessageFrame({ count: 2 }),
|
|
142
|
-
new MessageFrame({ count: 1 }),
|
|
143
|
-
new MessageFrame({ count: 0 }),
|
|
163
|
+
new MessageFrame({ count: 5 }, { type: '#countdownStatus' }),
|
|
164
|
+
new MessageFrame({ count: 4 }, { type: '#countdownStatus' }),
|
|
165
|
+
new MessageFrame({ count: 3 }, { type: '#countdownStatus' }),
|
|
166
|
+
new MessageFrame({ count: 2 }, { type: '#countdownStatus' }),
|
|
167
|
+
new MessageFrame({ count: 1 }, { type: '#countdownStatus' }),
|
|
168
|
+
new MessageFrame({ count: 0 }, { type: '#countdownStatus' }),
|
|
144
169
|
])
|
|
145
170
|
})
|
|
146
171
|
|
|
@@ -182,14 +207,19 @@ describe('Subscriptions', () => {
|
|
|
182
207
|
}
|
|
183
208
|
|
|
184
209
|
expect(frames).toEqual([
|
|
185
|
-
new MessageFrame(
|
|
186
|
-
|
|
187
|
-
|
|
210
|
+
new MessageFrame(
|
|
211
|
+
{
|
|
212
|
+
credentials: {
|
|
213
|
+
username: 'admin',
|
|
214
|
+
},
|
|
215
|
+
artifacts: {
|
|
216
|
+
original: 'YWRtaW46cGFzc3dvcmQ=',
|
|
217
|
+
},
|
|
188
218
|
},
|
|
189
|
-
|
|
190
|
-
|
|
219
|
+
{
|
|
220
|
+
type: '#auth',
|
|
191
221
|
},
|
|
192
|
-
|
|
222
|
+
),
|
|
193
223
|
])
|
|
194
224
|
})
|
|
195
225
|
|
|
@@ -266,10 +296,10 @@ describe('Subscriptions', () => {
|
|
|
266
296
|
}
|
|
267
297
|
|
|
268
298
|
expect(messages).toEqual([
|
|
269
|
-
{ count: 5 },
|
|
270
|
-
{ count: 3 },
|
|
271
|
-
{ count: 1 },
|
|
272
|
-
{ count: 0 },
|
|
299
|
+
{ $type: 'io.example.streamOne#countdownStatus', count: 5 },
|
|
300
|
+
{ $type: 'io.example.streamOne#countdownStatus', count: 3 },
|
|
301
|
+
{ $type: 'io.example.streamOne#countdownStatus', count: 1 },
|
|
302
|
+
{ $type: 'io.example.streamOne#countdownStatus', count: 0 },
|
|
273
303
|
])
|
|
274
304
|
})
|
|
275
305
|
|
|
@@ -338,11 +368,11 @@ describe('Subscriptions', () => {
|
|
|
338
368
|
|
|
339
369
|
expect(error).toEqual(new Error('Oops!'))
|
|
340
370
|
expect(messages).toEqual([
|
|
341
|
-
{ count: 10 },
|
|
342
|
-
{ count: 9 },
|
|
343
|
-
{ count: 8 },
|
|
344
|
-
{ count: 7 },
|
|
345
|
-
{ count: 6 },
|
|
371
|
+
{ $type: 'io.example.streamOne#countdownStatus', count: 10 },
|
|
372
|
+
{ $type: 'io.example.streamOne#countdownStatus', count: 9 },
|
|
373
|
+
{ $type: 'io.example.streamOne#countdownStatus', count: 8 },
|
|
374
|
+
{ $type: 'io.example.streamOne#countdownStatus', count: 7 },
|
|
375
|
+
{ $type: 'io.example.streamOne#countdownStatus', count: 6 },
|
|
346
376
|
])
|
|
347
377
|
})
|
|
348
378
|
})
|