@atproto/lex 0.0.6 → 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 +26 -0
- package/README.md +41 -27
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/package.json +16 -17
- package/index.cjs +0 -11
- package/index.d.ts +0 -6
- package/index.mjs +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
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
|
+
|
|
13
|
+
## 0.0.7
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#4457](https://github.com/bluesky-social/atproto/pull/4457) [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Fix `main` export in `package.json`
|
|
18
|
+
|
|
19
|
+
- [#4457](https://github.com/bluesky-social/atproto/pull/4457) [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Re-expect everything from `@atproto/lex-client`
|
|
20
|
+
|
|
21
|
+
- [#4457](https://github.com/bluesky-social/atproto/pull/4457) [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Re-export everything from `@atproto/lex-schema`
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [[`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece)]:
|
|
24
|
+
- @atproto/lex-client@0.0.5
|
|
25
|
+
- @atproto/lex-schema@0.0.5
|
|
26
|
+
- @atproto/lex-builder@0.0.7
|
|
27
|
+
- @atproto/lex-installer@0.0.7
|
|
28
|
+
|
|
3
29
|
## 0.0.6
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -617,61 +617,75 @@ const result = await client.xrpcSafe(com.atproto.identity.resolveHandle, {
|
|
|
617
617
|
})
|
|
618
618
|
|
|
619
619
|
if (result.success) {
|
|
620
|
-
//
|
|
620
|
+
// Handle success
|
|
621
621
|
console.log(result.body)
|
|
622
622
|
} else {
|
|
623
|
-
//
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
623
|
+
// Handle failure
|
|
624
|
+
if (result.error === 'Unknown') {
|
|
625
|
+
// Unable to perform the request
|
|
626
|
+
const { reason } = result
|
|
627
|
+
if (reason instanceof LexRpcResponseError) {
|
|
628
|
+
// The server returned a syntactically valid XRPC error response, but
|
|
629
|
+
// used an error code that is not declared for this method
|
|
630
|
+
reason.error // string (e.g. "AuthenticationRequired", "RateLimitExceeded", etc.)
|
|
631
|
+
reason.message // string
|
|
632
|
+
reason.status // number
|
|
633
|
+
reason.headers // Headers
|
|
634
|
+
reason.payload // { body: { error: string, message?: string }; encoding: string }
|
|
635
|
+
} else if (reason instanceof LexRpcUpstreamError) {
|
|
636
|
+
// The response was incomplete (e.g. connection dropped), or
|
|
637
|
+
// invalid (e.g. malformed JSON, data does not match schema).
|
|
638
|
+
reason.error // "InvalidResponse"
|
|
639
|
+
reason.message // string
|
|
640
|
+
reason.response.status // number
|
|
641
|
+
reason.response.headers // Headers
|
|
642
|
+
reason.response.payload // null | { body: unknown; encoding: string }
|
|
643
|
+
} else {
|
|
644
|
+
reason // unknown (fetch failed, other?)
|
|
645
|
+
}
|
|
634
646
|
} else {
|
|
635
|
-
//
|
|
636
|
-
result
|
|
647
|
+
// A declared error for that method
|
|
648
|
+
result // LexRpcResponseError<"HandleNotFound">
|
|
649
|
+
result.error // "HandleNotFound"
|
|
650
|
+
result.message // string
|
|
637
651
|
}
|
|
638
652
|
}
|
|
639
653
|
```
|
|
640
654
|
|
|
641
655
|
The `ResponseFailure<M>` type is a union with three possible error types:
|
|
642
656
|
|
|
643
|
-
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:
|
|
644
658
|
|
|
645
659
|
```typescript
|
|
646
|
-
//
|
|
647
|
-
type
|
|
660
|
+
// LexRpcResponseError<N>
|
|
661
|
+
type KnownLexRpcResponseFailure<N extends string> = {
|
|
648
662
|
success: false
|
|
649
663
|
name: N
|
|
650
|
-
error:
|
|
664
|
+
error: LexRpcResponseError<N>
|
|
651
665
|
|
|
652
666
|
// Additional response details
|
|
653
667
|
status: number
|
|
654
668
|
headers: Headers
|
|
655
669
|
encoding: undefined | string
|
|
656
|
-
body:
|
|
670
|
+
body: LexErrorData<N>
|
|
657
671
|
}
|
|
658
672
|
```
|
|
659
673
|
|
|
660
674
|
2. **Unknown errors** - Server errors not declared in the method's schema:
|
|
661
675
|
|
|
662
676
|
```typescript
|
|
663
|
-
//
|
|
664
|
-
type
|
|
677
|
+
// LexRpcResponseFailure<'Unexpected', LexRpcResponseError>
|
|
678
|
+
type UnknownLexRpcResponseFailure = {
|
|
665
679
|
success: false
|
|
666
|
-
name: '
|
|
667
|
-
error:
|
|
680
|
+
name: 'Unexpected'
|
|
681
|
+
error: LexRpcResponseError<string>
|
|
668
682
|
}
|
|
669
683
|
```
|
|
670
684
|
|
|
671
685
|
3. **Unexpected errors** - Network errors, invalid responses, or other client-side errors:
|
|
672
686
|
```typescript
|
|
673
|
-
//
|
|
674
|
-
type
|
|
687
|
+
// LexRpcResponseFailure<'UnexpectedError', unknown>
|
|
688
|
+
type UnexpectedLexRpcResponseFailure = {
|
|
675
689
|
success: false
|
|
676
690
|
name: 'UnexpectedError'
|
|
677
691
|
error: unknown // Could be anything (network error, parsing error, etc.)
|
|
@@ -1202,7 +1216,7 @@ await client.call(unfollow, { followUri: uri })
|
|
|
1202
1216
|
#### Updating Profile with Retry Logic
|
|
1203
1217
|
|
|
1204
1218
|
```typescript
|
|
1205
|
-
import { Action } from '@atproto/lex'
|
|
1219
|
+
import { Action, LexRpcResponseError } from '@atproto/lex'
|
|
1206
1220
|
import * as app from './lexicons/app.js'
|
|
1207
1221
|
import * as com from './lexicons/com.js'
|
|
1208
1222
|
|
|
@@ -1244,7 +1258,7 @@ export const updateProfile: Action<ProfileUpdate, void> = async (
|
|
|
1244
1258
|
} catch (error) {
|
|
1245
1259
|
// Retry on swap/concurrent modification errors
|
|
1246
1260
|
if (
|
|
1247
|
-
error instanceof
|
|
1261
|
+
error instanceof LexRpcResponseError &&
|
|
1248
1262
|
error.name === 'SwapError' &&
|
|
1249
1263
|
attempt < maxRetries - 1
|
|
1250
1264
|
) {
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("@atproto/lex-schema"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("@atproto/lex-client"), exports);
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,8DAAmC;AACnC,8DAAmC","sourcesContent":["export * from '@atproto/lex-schema'\nexport * from '@atproto/lex-client'\n"]}
|
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": [
|
|
@@ -15,9 +15,7 @@
|
|
|
15
15
|
"directory": "packages/lex/lex"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
|
-
"./
|
|
19
|
-
"./index.mjs",
|
|
20
|
-
"./index.d.ts",
|
|
18
|
+
"./dist",
|
|
21
19
|
"./bin",
|
|
22
20
|
"./CHANGELOG.md"
|
|
23
21
|
],
|
|
@@ -26,29 +24,30 @@
|
|
|
26
24
|
"lex": "./bin/lex"
|
|
27
25
|
},
|
|
28
26
|
"sideEffects": false,
|
|
29
|
-
"
|
|
30
|
-
"
|
|
27
|
+
"type": "commonjs",
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
31
30
|
"exports": {
|
|
32
31
|
".": {
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"require": "./index.cjs",
|
|
36
|
-
"types": "./index.d.ts"
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"default": "./dist/index.js"
|
|
37
34
|
}
|
|
38
35
|
},
|
|
39
36
|
"dependencies": {
|
|
37
|
+
"tslib": "^2.8.1",
|
|
40
38
|
"yargs": "^17.0.0",
|
|
41
|
-
"@atproto/lex-builder": "0.0.
|
|
42
|
-
"@atproto/lex-client": "0.0.
|
|
43
|
-
"@atproto/lex-installer": "0.0.
|
|
44
|
-
"@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"
|
|
45
43
|
},
|
|
46
44
|
"devDependencies": {
|
|
47
45
|
"@types/yargs": "^17.0.33",
|
|
48
|
-
"
|
|
46
|
+
"vitest": "^4.0.16"
|
|
49
47
|
},
|
|
50
48
|
"scripts": {
|
|
51
|
-
"
|
|
52
|
-
"
|
|
49
|
+
"prebuild": "./bin/lex build --clear --lexicons ./lexicons --out ./tests/lexicons --lib @atproto/lex-schema -- ignore additional npm args",
|
|
50
|
+
"build": "tsc --build tsconfig.build.json",
|
|
51
|
+
"test": "vitest run"
|
|
53
52
|
}
|
|
54
53
|
}
|
package/index.cjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
/* eslint-env commonjs */
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
5
|
-
|
|
6
|
-
const { Client, buildAgent } = require('@atproto/lex-client')
|
|
7
|
-
const { l } = require('@atproto/lex-schema')
|
|
8
|
-
|
|
9
|
-
module.exports.Client = Client
|
|
10
|
-
module.exports.buildAgent = buildAgent
|
|
11
|
-
module.exports.l = l
|
package/index.d.ts
DELETED
package/index.mjs
DELETED