@atproto/xrpc-server 0.10.2 → 0.10.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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @atproto/xrpc-server
2
2
 
3
+ ## 0.10.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 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)]:
8
+ - @atproto/lex-data@0.0.3
9
+ - @atproto/lexicon@0.6.0
10
+ - @atproto/lex-cbor@0.0.3
11
+ - @atproto/common@0.5.3
12
+ - @atproto/xrpc@0.7.7
13
+
3
14
  ## 0.10.2
4
15
 
5
16
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/xrpc-server",
3
- "version": "0.10.2",
3
+ "version": "0.10.3",
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.2",
28
+ "@atproto/common": "^0.5.3",
29
29
  "@atproto/crypto": "^0.4.5",
30
- "@atproto/lex-data": "0.0.2",
31
- "@atproto/lexicon": "^0.5.2",
32
- "@atproto/lex-cbor": "0.0.2",
30
+ "@atproto/lex-data": "0.0.3",
31
+ "@atproto/lex-cbor": "0.0.3",
32
+ "@atproto/lexicon": "^0.6.0",
33
33
  "@atproto/ws-client": "^0.0.3",
34
- "@atproto/xrpc": "^0.7.6"
34
+ "@atproto/xrpc": "^0.7.7"
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
- credentials: {
187
- username: 'admin',
210
+ new MessageFrame(
211
+ {
212
+ credentials: {
213
+ username: 'admin',
214
+ },
215
+ artifacts: {
216
+ original: 'YWRtaW46cGFzc3dvcmQ=',
217
+ },
188
218
  },
189
- artifacts: {
190
- original: 'YWRtaW46cGFzc3dvcmQ=',
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
  })