@atproto/lex 0.3.2 → 0.3.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 +14 -0
- package/README.md +8 -24
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atproto/lex
|
|
2
2
|
|
|
3
|
+
## 0.3.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#5295](https://github.com/bluesky-social/atproto/pull/5295) [`6a3d607`](https://github.com/bluesky-social/atproto/commit/6a3d6073cb66c527b5b109242049c85c36b9658c) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Update vitest dependencies
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`6a3d607`](https://github.com/bluesky-social/atproto/commit/6a3d6073cb66c527b5b109242049c85c36b9658c)]:
|
|
10
|
+
- @atproto/lex-installer@0.1.12
|
|
11
|
+
- @atproto/lex-builder@0.1.10
|
|
12
|
+
- @atproto/lex-client@0.3.2
|
|
13
|
+
- @atproto/lex-schema@0.2.4
|
|
14
|
+
- @atproto/lex-data@0.1.7
|
|
15
|
+
- @atproto/lex-json@0.1.6
|
|
16
|
+
|
|
3
17
|
## 0.3.2
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -347,9 +347,7 @@ import { l } from '@atproto/lex'
|
|
|
347
347
|
import * as app from './lexicons/app.js'
|
|
348
348
|
|
|
349
349
|
declare const data:
|
|
350
|
-
| app.bsky.feed.
|
|
351
|
-
| app.bsky.feed.like.Main
|
|
352
|
-
| l.Unknown$TypedObject
|
|
350
|
+
app.bsky.feed.post.Main | app.bsky.feed.like.Main | l.Unknown$TypedObject
|
|
353
351
|
|
|
354
352
|
// Discriminate by $type without re-validating
|
|
355
353
|
if (app.bsky.feed.post.$isTypeOf(data)) {
|
|
@@ -631,9 +629,7 @@ import { Client } from '@atproto/lex'
|
|
|
631
629
|
import { OAuthClient } from '@atproto/oauth-client-node'
|
|
632
630
|
|
|
633
631
|
// Setup OAuth client (see @atproto/oauth-client documentation)
|
|
634
|
-
const oauthClient = new OAuthClient({
|
|
635
|
-
/* ... */
|
|
636
|
-
})
|
|
632
|
+
const oauthClient = new OAuthClient({/* ... */})
|
|
637
633
|
const session = await oauthClient.restore(userDid)
|
|
638
634
|
|
|
639
635
|
// Create authenticated client
|
|
@@ -713,9 +709,7 @@ const profile = await client.call(app.bsky.actor.getProfile, {
|
|
|
713
709
|
|
|
714
710
|
// Procedure (POST request)
|
|
715
711
|
const result = await client.call(app.bsky.feed.sendInteractions, {
|
|
716
|
-
interactions: [
|
|
717
|
-
/* ... */
|
|
718
|
-
],
|
|
712
|
+
interactions: [/* ... */],
|
|
719
713
|
})
|
|
720
714
|
|
|
721
715
|
// With options
|
|
@@ -1189,9 +1183,7 @@ The most ergonomic style is to use a namespace import and reference schemas thro
|
|
|
1189
1183
|
```typescript
|
|
1190
1184
|
import * as com from './lexicons/com.js'
|
|
1191
1185
|
|
|
1192
|
-
await client.call(com.atproto.repo.getRecord, {
|
|
1193
|
-
/* ... */
|
|
1194
|
-
})
|
|
1186
|
+
await client.call(com.atproto.repo.getRecord, {/* ... */})
|
|
1195
1187
|
```
|
|
1196
1188
|
|
|
1197
1189
|
This style is convenient and reads naturally as it mirrors the NSID of the schema. However, it produces the largest bundles. From the bundler's point of view, `com.atproto.repo.getRecord` is the whole schema namespace (which contains the `main` schema as well as helpers, and any other definitions). The bundler cannot know that `client.call()` only consumes the `main` schema, so it has to keep the rest of the namespace alive in the bundle.
|
|
@@ -1203,9 +1195,7 @@ You can mitigate the bundle-size cost by explicitly naming the `main` definition
|
|
|
1203
1195
|
```typescript
|
|
1204
1196
|
import * as com from './lexicons/com.js'
|
|
1205
1197
|
|
|
1206
|
-
await client.call(com.atproto.repo.getRecord.main, {
|
|
1207
|
-
/* ... */
|
|
1208
|
-
})
|
|
1198
|
+
await client.call(com.atproto.repo.getRecord.main, {/* ... */})
|
|
1209
1199
|
```
|
|
1210
1200
|
|
|
1211
1201
|
This lets the bundler drop the sibling definitions inside `getRecord` that aren't referenced. The drawback is that it leaks an implementation detail: the `main` segment of the path. In Lexicon, `main` is typically implicit:
|
|
@@ -1222,9 +1212,7 @@ You can also import the `main` schema directly from the file that defines it:
|
|
|
1222
1212
|
```typescript
|
|
1223
1213
|
import { main as getRecord } from './lexicons/com/atproto/repo/getRecord.js'
|
|
1224
1214
|
|
|
1225
|
-
await client.call(getRecord, {
|
|
1226
|
-
/* ... */
|
|
1227
|
-
})
|
|
1215
|
+
await client.call(getRecord, {/* ... */})
|
|
1228
1216
|
```
|
|
1229
1217
|
|
|
1230
1218
|
This produces equally small bundles as the explicit `.main` reference, but it still surfaces the `main` identifier: you have to know to import `main` and likely rename it.
|
|
@@ -1245,12 +1233,8 @@ This means you can write:
|
|
|
1245
1233
|
import getRecord from './lexicons/com/atproto/repo/getRecord.js'
|
|
1246
1234
|
import post from './lexicons/app/bsky/feed/post.js'
|
|
1247
1235
|
|
|
1248
|
-
await client.call(getRecord, {
|
|
1249
|
-
|
|
1250
|
-
})
|
|
1251
|
-
await client.create(post, {
|
|
1252
|
-
/* ... */
|
|
1253
|
-
})
|
|
1236
|
+
await client.call(getRecord, {/* ... */})
|
|
1237
|
+
await client.create(post, {/* ... */})
|
|
1254
1238
|
```
|
|
1255
1239
|
|
|
1256
1240
|
This is the most bundle-friendly style: the bundler only pulls in the `main` schema, and the import name doesn't have to mention `main` at all. This helps keeping application code aligned with how Lexicons are usually identified.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/lex",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Lexicon tooling for AT",
|
|
6
6
|
"keywords": [
|
|
@@ -38,16 +38,16 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"tslib": "^2.8.1",
|
|
40
40
|
"yargs": "^18.0.0",
|
|
41
|
-
"@atproto/lex-
|
|
42
|
-
"@atproto/lex-
|
|
43
|
-
"@atproto/lex-json": "^0.1.
|
|
44
|
-
"@atproto/lex-
|
|
45
|
-
"@atproto/lex-
|
|
46
|
-
"@atproto/lex-schema": "^0.2.
|
|
41
|
+
"@atproto/lex-builder": "^0.1.10",
|
|
42
|
+
"@atproto/lex-client": "^0.3.2",
|
|
43
|
+
"@atproto/lex-json": "^0.1.6",
|
|
44
|
+
"@atproto/lex-data": "^0.1.7",
|
|
45
|
+
"@atproto/lex-installer": "^0.1.12",
|
|
46
|
+
"@atproto/lex-schema": "^0.2.4"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/yargs": "^17.0.33",
|
|
50
|
-
"vitest": "^4.
|
|
50
|
+
"vitest": "^4.1.10"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"codegen:lex": "./bin/lex build --override --indexFile --lexicons ./lexicons --out ./tests/lexicons --lib @atproto/lex-schema",
|