@atproto/lex 0.0.7 → 0.0.8
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 +10 -0
- package/README.md +15 -15
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atproto/lex
|
|
2
2
|
|
|
3
|
+
## 0.0.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`9af7a2d`](https://github.com/bluesky-social/atproto/commit/9af7a2d12240e91248610ce4fe7d93387733c59c), [`9af7a2d`](https://github.com/bluesky-social/atproto/commit/9af7a2d12240e91248610ce4fe7d93387733c59c), [`9af7a2d`](https://github.com/bluesky-social/atproto/commit/9af7a2d12240e91248610ce4fe7d93387733c59c), [`9af7a2d`](https://github.com/bluesky-social/atproto/commit/9af7a2d12240e91248610ce4fe7d93387733c59c), [`9af7a2d`](https://github.com/bluesky-social/atproto/commit/9af7a2d12240e91248610ce4fe7d93387733c59c), [`9af7a2d`](https://github.com/bluesky-social/atproto/commit/9af7a2d12240e91248610ce4fe7d93387733c59c), [`9af7a2d`](https://github.com/bluesky-social/atproto/commit/9af7a2d12240e91248610ce4fe7d93387733c59c), [`9af7a2d`](https://github.com/bluesky-social/atproto/commit/9af7a2d12240e91248610ce4fe7d93387733c59c), [`9af7a2d`](https://github.com/bluesky-social/atproto/commit/9af7a2d12240e91248610ce4fe7d93387733c59c), [`9af7a2d`](https://github.com/bluesky-social/atproto/commit/9af7a2d12240e91248610ce4fe7d93387733c59c), [`9af7a2d`](https://github.com/bluesky-social/atproto/commit/9af7a2d12240e91248610ce4fe7d93387733c59c)]:
|
|
8
|
+
- @atproto/lex-schema@0.0.6
|
|
9
|
+
- @atproto/lex-builder@0.0.8
|
|
10
|
+
- @atproto/lex-client@0.0.6
|
|
11
|
+
- @atproto/lex-installer@0.0.8
|
|
12
|
+
|
|
3
13
|
## 0.0.7
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -624,7 +624,7 @@ if (result.success) {
|
|
|
624
624
|
if (result.error === 'Unknown') {
|
|
625
625
|
// Unable to perform the request
|
|
626
626
|
const { reason } = result
|
|
627
|
-
if (reason instanceof
|
|
627
|
+
if (reason instanceof LexRpcResponseError) {
|
|
628
628
|
// The server returned a syntactically valid XRPC error response, but
|
|
629
629
|
// used an error code that is not declared for this method
|
|
630
630
|
reason.error // string (e.g. "AuthenticationRequired", "RateLimitExceeded", etc.)
|
|
@@ -632,7 +632,7 @@ if (result.success) {
|
|
|
632
632
|
reason.status // number
|
|
633
633
|
reason.headers // Headers
|
|
634
634
|
reason.payload // { body: { error: string, message?: string }; encoding: string }
|
|
635
|
-
} else if (reason instanceof
|
|
635
|
+
} else if (reason instanceof LexRpcUpstreamError) {
|
|
636
636
|
// The response was incomplete (e.g. connection dropped), or
|
|
637
637
|
// invalid (e.g. malformed JSON, data does not match schema).
|
|
638
638
|
reason.error // "InvalidResponse"
|
|
@@ -645,7 +645,7 @@ if (result.success) {
|
|
|
645
645
|
}
|
|
646
646
|
} else {
|
|
647
647
|
// A declared error for that method
|
|
648
|
-
result //
|
|
648
|
+
result // LexRpcResponseError<"HandleNotFound">
|
|
649
649
|
result.error // "HandleNotFound"
|
|
650
650
|
result.message // string
|
|
651
651
|
}
|
|
@@ -654,38 +654,38 @@ if (result.success) {
|
|
|
654
654
|
|
|
655
655
|
The `ResponseFailure<M>` type is a union with three possible error types:
|
|
656
656
|
|
|
657
|
-
1. **Declared errors** - Errors explicitly listed in the method's Lexicon schema will be represented as an `
|
|
657
|
+
1. **Declared errors** - Errors explicitly listed in the method's Lexicon schema will be represented as an `LexRpcResponseError<N>` instance:
|
|
658
658
|
|
|
659
659
|
```typescript
|
|
660
|
-
//
|
|
661
|
-
type
|
|
660
|
+
// LexRpcResponseError<N>
|
|
661
|
+
type KnownLexRpcResponseFailure<N extends string> = {
|
|
662
662
|
success: false
|
|
663
663
|
name: N
|
|
664
|
-
error:
|
|
664
|
+
error: LexRpcResponseError<N>
|
|
665
665
|
|
|
666
666
|
// Additional response details
|
|
667
667
|
status: number
|
|
668
668
|
headers: Headers
|
|
669
669
|
encoding: undefined | string
|
|
670
|
-
body:
|
|
670
|
+
body: LexErrorData<N>
|
|
671
671
|
}
|
|
672
672
|
```
|
|
673
673
|
|
|
674
674
|
2. **Unknown errors** - Server errors not declared in the method's schema:
|
|
675
675
|
|
|
676
676
|
```typescript
|
|
677
|
-
//
|
|
678
|
-
type
|
|
677
|
+
// LexRpcResponseFailure<'Unexpected', LexRpcResponseError>
|
|
678
|
+
type UnknownLexRpcResponseFailure = {
|
|
679
679
|
success: false
|
|
680
680
|
name: 'Unexpected'
|
|
681
|
-
error:
|
|
681
|
+
error: LexRpcResponseError<string>
|
|
682
682
|
}
|
|
683
683
|
```
|
|
684
684
|
|
|
685
685
|
3. **Unexpected errors** - Network errors, invalid responses, or other client-side errors:
|
|
686
686
|
```typescript
|
|
687
|
-
//
|
|
688
|
-
type
|
|
687
|
+
// LexRpcResponseFailure<'UnexpectedError', unknown>
|
|
688
|
+
type UnexpectedLexRpcResponseFailure = {
|
|
689
689
|
success: false
|
|
690
690
|
name: 'UnexpectedError'
|
|
691
691
|
error: unknown // Could be anything (network error, parsing error, etc.)
|
|
@@ -1216,7 +1216,7 @@ await client.call(unfollow, { followUri: uri })
|
|
|
1216
1216
|
#### Updating Profile with Retry Logic
|
|
1217
1217
|
|
|
1218
1218
|
```typescript
|
|
1219
|
-
import { Action,
|
|
1219
|
+
import { Action, LexRpcResponseError } from '@atproto/lex'
|
|
1220
1220
|
import * as app from './lexicons/app.js'
|
|
1221
1221
|
import * as com from './lexicons/com.js'
|
|
1222
1222
|
|
|
@@ -1258,7 +1258,7 @@ export const updateProfile: Action<ProfileUpdate, void> = async (
|
|
|
1258
1258
|
} catch (error) {
|
|
1259
1259
|
// Retry on swap/concurrent modification errors
|
|
1260
1260
|
if (
|
|
1261
|
-
error instanceof
|
|
1261
|
+
error instanceof LexRpcResponseError &&
|
|
1262
1262
|
error.name === 'SwapError' &&
|
|
1263
1263
|
attempt < maxRetries - 1
|
|
1264
1264
|
) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/lex",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Lexicon tooling for AT",
|
|
6
6
|
"keywords": [
|
|
@@ -36,18 +36,18 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"tslib": "^2.8.1",
|
|
38
38
|
"yargs": "^17.0.0",
|
|
39
|
-
"@atproto/lex-builder": "0.0.
|
|
40
|
-
"@atproto/lex-client": "0.0.
|
|
41
|
-
"@atproto/lex-installer": "0.0.
|
|
42
|
-
"@atproto/lex-schema": "0.0.
|
|
39
|
+
"@atproto/lex-builder": "0.0.8",
|
|
40
|
+
"@atproto/lex-client": "0.0.6",
|
|
41
|
+
"@atproto/lex-installer": "0.0.8",
|
|
42
|
+
"@atproto/lex-schema": "0.0.6"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/yargs": "^17.0.33",
|
|
46
|
-
"
|
|
46
|
+
"vitest": "^4.0.16"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"prebuild": "./bin/lex build --clear --lexicons ./lexicons --out ./tests/lexicons --lib @atproto/lex-schema -- ignore additional npm args",
|
|
50
50
|
"build": "tsc --build tsconfig.build.json",
|
|
51
|
-
"test": "
|
|
51
|
+
"test": "vitest run"
|
|
52
52
|
}
|
|
53
53
|
}
|