@atproto/lex 0.1.0-next.0 → 0.1.1
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 +31 -12
- package/README.md +51 -8
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,28 +1,47 @@
|
|
|
1
1
|
# @atproto/lex
|
|
2
2
|
|
|
3
|
-
## 0.1.
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#4895](https://github.com/bluesky-social/atproto/pull/4895) [`25e0233`](https://github.com/bluesky-social/atproto/commit/25e02339a383740e762c9a9633a701d2fb0cab86) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Add `applyWrites()` method to Lex SDK client class
|
|
8
|
+
|
|
9
|
+
Thank you [@TrySound](https://github.com/TrySound) for the suggestion
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`e6c6343`](https://github.com/bluesky-social/atproto/commit/e6c6343bd3727455bd0da12300bb4929a944e4f1), [`e6c6343`](https://github.com/bluesky-social/atproto/commit/e6c6343bd3727455bd0da12300bb4929a944e4f1), [`fb1b403`](https://github.com/bluesky-social/atproto/commit/fb1b40350d46f3c49e512b7e24b071b03902e3b8), [`25e0233`](https://github.com/bluesky-social/atproto/commit/25e02339a383740e762c9a9633a701d2fb0cab86)]:
|
|
12
|
+
- @atproto/lex-client@0.1.1
|
|
13
|
+
- @atproto/lex-data@0.1.1
|
|
14
|
+
- @atproto/lex-builder@0.1.1
|
|
15
|
+
|
|
16
|
+
## 0.1.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
|
6
19
|
|
|
7
|
-
- [#4929](https://github.com/bluesky-social/atproto/pull/4929) [`
|
|
20
|
+
- [#4929](https://github.com/bluesky-social/atproto/pull/4929) [`f01c59f`](https://github.com/bluesky-social/atproto/commit/f01c59f5bd3f75fb8b47a9eecd4858b84033fb7c) Thanks [@devinivy](https://github.com/devinivy)! - **BREAKING:** Drop support for Node.js 18 and 20. Node.js 22 is now the minimum supported version. Docker images now use Node.js 24.
|
|
8
21
|
|
|
9
|
-
- [#4943](https://github.com/bluesky-social/atproto/pull/4943) [`
|
|
22
|
+
- [#4943](https://github.com/bluesky-social/atproto/pull/4943) [`c459153`](https://github.com/bluesky-social/atproto/commit/c459153395a30ce89e050892c8fab7dc98e019b9) Thanks [@devinivy](https://github.com/devinivy)! - **BREAKING:** Convert to pure ESM. All packages now ship `"type": "module"` with ES module output and Node16 module resolution.
|
|
10
23
|
|
|
11
24
|
Node.js 22's `require()` compatibility layer can still load these packages in CommonJS code.
|
|
12
25
|
|
|
13
|
-
- [#4930](https://github.com/bluesky-social/atproto/pull/4930) [`
|
|
26
|
+
- [#4930](https://github.com/bluesky-social/atproto/pull/4930) [`908bece`](https://github.com/bluesky-social/atproto/commit/908bece169258bff5ad121e5eec157d6ded6f705) Thanks [@devinivy](https://github.com/devinivy)! - Build with TypeScript 6.0.
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- Updated dependencies [[`f01c59f`](https://github.com/bluesky-social/atproto/commit/f01c59f5bd3f75fb8b47a9eecd4858b84033fb7c), [`c459153`](https://github.com/bluesky-social/atproto/commit/c459153395a30ce89e050892c8fab7dc98e019b9), [`affb50c`](https://github.com/bluesky-social/atproto/commit/affb50c040b497a12631df99a6310f8e78cab557), [`908bece`](https://github.com/bluesky-social/atproto/commit/908bece169258bff5ad121e5eec157d6ded6f705)]:
|
|
31
|
+
- @atproto/lex-builder@0.1.0
|
|
32
|
+
- @atproto/lex-client@0.1.0
|
|
33
|
+
- @atproto/lex-data@0.1.0
|
|
34
|
+
- @atproto/lex-installer@0.1.0
|
|
35
|
+
- @atproto/lex-json@0.1.0
|
|
36
|
+
- @atproto/lex-schema@0.1.0
|
|
14
37
|
|
|
15
|
-
|
|
38
|
+
## 0.0.27
|
|
16
39
|
|
|
17
40
|
### Patch Changes
|
|
18
41
|
|
|
19
|
-
- Updated dependencies [[`
|
|
20
|
-
- @atproto/lex-
|
|
21
|
-
- @atproto/lex-
|
|
22
|
-
- @atproto/lex-data@0.1.0-next.0
|
|
23
|
-
- @atproto/lex-installer@0.1.0-next.0
|
|
24
|
-
- @atproto/lex-json@0.1.0-next.0
|
|
25
|
-
- @atproto/lex-schema@0.1.0-next.0
|
|
42
|
+
- Updated dependencies [[`d8b2374`](https://github.com/bluesky-social/atproto/commit/d8b2374e1592d1dec65a33439791bc141f02397a)]:
|
|
43
|
+
- @atproto/lex-client@0.0.22
|
|
44
|
+
- @atproto/lex-installer@0.0.27
|
|
26
45
|
|
|
27
46
|
## 0.0.26
|
|
28
47
|
|
package/README.md
CHANGED
|
@@ -231,7 +231,7 @@ import * as app from './lexicons/app.js'
|
|
|
231
231
|
const post = app.bsky.feed.post.$build({
|
|
232
232
|
// No need to specify $type when using $build
|
|
233
233
|
text: 'Hello, world!',
|
|
234
|
-
createdAt: l.
|
|
234
|
+
createdAt: l.currentDatetimeString(),
|
|
235
235
|
})
|
|
236
236
|
|
|
237
237
|
// For runtime validation, use $parse()/$validate() instead
|
|
@@ -275,7 +275,7 @@ import * as app from './lexicons/app.js'
|
|
|
275
275
|
const data = {
|
|
276
276
|
$type: 'app.bsky.feed.post',
|
|
277
277
|
text: 'Hello!',
|
|
278
|
-
createdAt: l.
|
|
278
|
+
createdAt: l.currentDatetimeString(),
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
if (app.bsky.feed.post.$check(data)) {
|
|
@@ -296,7 +296,7 @@ try {
|
|
|
296
296
|
const post = app.bsky.feed.post.$main.$parse({
|
|
297
297
|
$type: 'app.bsky.feed.post',
|
|
298
298
|
text: 'Hello!',
|
|
299
|
-
createdAt: l.
|
|
299
|
+
createdAt: l.currentDatetimeString(),
|
|
300
300
|
})
|
|
301
301
|
// post is now typed and validated
|
|
302
302
|
console.log(post.text)
|
|
@@ -320,7 +320,7 @@ import * as app from './lexicons/app.js'
|
|
|
320
320
|
const value = {
|
|
321
321
|
$type: 'app.bsky.feed.post',
|
|
322
322
|
text: 'Hello!',
|
|
323
|
-
createdAt: l.
|
|
323
|
+
createdAt: l.currentDatetimeString(),
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
// Throws if no valid
|
|
@@ -340,7 +340,7 @@ import * as app from './lexicons/app.js'
|
|
|
340
340
|
const result = app.bsky.feed.post.$safeParse({
|
|
341
341
|
$type: 'app.bsky.feed.post',
|
|
342
342
|
text: 'Hello!',
|
|
343
|
-
createdAt: l.
|
|
343
|
+
createdAt: l.currentDatetimeString(),
|
|
344
344
|
})
|
|
345
345
|
|
|
346
346
|
if (result.success) {
|
|
@@ -374,7 +374,7 @@ const like = app.bsky.feed.like.$build({
|
|
|
374
374
|
uri: 'at://did:plc:abc/app.bsky.feed.post/123',
|
|
375
375
|
cid: 'bafyrei...',
|
|
376
376
|
},
|
|
377
|
-
createdAt: l.
|
|
377
|
+
createdAt: l.currentDatetimeString(),
|
|
378
378
|
})
|
|
379
379
|
```
|
|
380
380
|
|
|
@@ -655,7 +655,7 @@ import * as app from './lexicons/app.js'
|
|
|
655
655
|
|
|
656
656
|
const result = await client.create(app.bsky.feed.post, {
|
|
657
657
|
text: 'Hello, world!',
|
|
658
|
-
createdAt: l.
|
|
658
|
+
createdAt: l.currentDatetimeString(),
|
|
659
659
|
})
|
|
660
660
|
|
|
661
661
|
console.log(result.uri) // at://did:plc:...
|
|
@@ -749,6 +749,49 @@ if (result.cursor) {
|
|
|
749
749
|
}
|
|
750
750
|
```
|
|
751
751
|
|
|
752
|
+
#### `client.applyWrites()`
|
|
753
|
+
|
|
754
|
+
Perform an atomic batch of create, update, and delete operations in a single request.
|
|
755
|
+
|
|
756
|
+
```typescript
|
|
757
|
+
import { l } from '@atproto/lex'
|
|
758
|
+
import * as app from './lexicons/app.js'
|
|
759
|
+
|
|
760
|
+
const response = await client.applyWrites((op) => [
|
|
761
|
+
// Create a new post
|
|
762
|
+
op.create(app.bsky.feed.post, {
|
|
763
|
+
text: 'Hello, world!',
|
|
764
|
+
createdAt: l.currentDatetimeString(),
|
|
765
|
+
}),
|
|
766
|
+
|
|
767
|
+
// Update profile
|
|
768
|
+
op.update(app.bsky.actor.profile, {
|
|
769
|
+
displayName: 'Alice',
|
|
770
|
+
description: 'Updated bio',
|
|
771
|
+
}),
|
|
772
|
+
|
|
773
|
+
// Delete an existing post by rkey
|
|
774
|
+
op.delete(app.bsky.feed.post, {
|
|
775
|
+
rkey: '3jxf7z2k3q2',
|
|
776
|
+
}),
|
|
777
|
+
])
|
|
778
|
+
|
|
779
|
+
// Check results
|
|
780
|
+
for (const result of response.body.results) {
|
|
781
|
+
console.log(result.uri, result.cid)
|
|
782
|
+
}
|
|
783
|
+
```
|
|
784
|
+
|
|
785
|
+
Options:
|
|
786
|
+
|
|
787
|
+
- `repo` - Repository identifier (defaults to authenticated user's DID)
|
|
788
|
+
- `validate` - Asks the PDS to validate records against schema
|
|
789
|
+
- `swapCommit` - CID for optimistic concurrency control
|
|
790
|
+
|
|
791
|
+
> [!NOTE]
|
|
792
|
+
>
|
|
793
|
+
> All operations in an `applyWrites()` call are atomic - they either all succeed or all fail together. This is useful for maintaining consistency when making multiple related changes.
|
|
794
|
+
|
|
752
795
|
### Error Handling
|
|
753
796
|
|
|
754
797
|
By default, all client methods throw errors when requests fail. For more ergonomic error handling, the client provides "Safe" variants that return errors instead of throwing them.
|
|
@@ -1174,7 +1217,7 @@ export const likePost: Action<
|
|
|
1174
1217
|
app.bsky.feed.like,
|
|
1175
1218
|
{
|
|
1176
1219
|
subject: { uri, cid },
|
|
1177
|
-
createdAt: l.
|
|
1220
|
+
createdAt: l.currentDatetimeString(),
|
|
1178
1221
|
},
|
|
1179
1222
|
options,
|
|
1180
1223
|
)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/lex",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=22"
|
|
6
6
|
},
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"tslib": "^2.8.1",
|
|
39
39
|
"yargs": "^17.0.0",
|
|
40
|
-
"@atproto/lex-
|
|
41
|
-
"@atproto/lex-
|
|
42
|
-
"@atproto/lex-
|
|
43
|
-
"@atproto/lex-
|
|
44
|
-
"@atproto/lex-
|
|
45
|
-
"@atproto/lex-
|
|
40
|
+
"@atproto/lex-builder": "^0.1.1",
|
|
41
|
+
"@atproto/lex-client": "^0.1.1",
|
|
42
|
+
"@atproto/lex-data": "^0.1.1",
|
|
43
|
+
"@atproto/lex-json": "^0.1.0",
|
|
44
|
+
"@atproto/lex-installer": "^0.1.0",
|
|
45
|
+
"@atproto/lex-schema": "^0.1.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/yargs": "^17.0.33",
|