@atproto/lex 0.0.17 → 0.0.19
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 +18 -0
- package/README.md +85 -40
- package/dist/index.d.ts +72 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -31
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atproto/lex
|
|
2
2
|
|
|
3
|
+
## 0.0.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#4672](https://github.com/bluesky-social/atproto/pull/4672) [`38852f0`](https://github.com/bluesky-social/atproto/commit/38852f0ddfa9fbce8036233dc6af87614e9ae4b2) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Improve readme
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`38852f0`](https://github.com/bluesky-social/atproto/commit/38852f0ddfa9fbce8036233dc6af87614e9ae4b2)]:
|
|
10
|
+
- @atproto/lex-client@0.0.14
|
|
11
|
+
- @atproto/lex-installer@0.0.19
|
|
12
|
+
|
|
13
|
+
## 0.0.18
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies []:
|
|
18
|
+
- @atproto/lex-client@0.0.13
|
|
19
|
+
- @atproto/lex-installer@0.0.18
|
|
20
|
+
|
|
3
21
|
## 0.0.17
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,48 +1,47 @@
|
|
|
1
|
-
|
|
1
|
+
> [!IMPORTANT]
|
|
2
|
+
>
|
|
3
|
+
> This package is currently in **preview**. The API and features are subject to change before the stable release. See the [Changelog](./CHANGELOG.md) for version history.
|
|
2
4
|
|
|
3
|
-
Type-safe Lexicon tooling for
|
|
5
|
+
Type-safe Lexicon tooling for AT Protocol data.
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
- Fetch and manage Lexicon schemas, generate TypeScript validators
|
|
8
|
+
- Compile-time and runtime type safety for AT Protocol data structures
|
|
9
|
+
- Fully typed XRPC client with authentication support
|
|
10
|
+
- Tree-shaking and composition friendly
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
- Handle common tasks like OAuth
|
|
12
|
+
```typescript
|
|
13
|
+
// Build data with generated builders and validators
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const newPost = app.bsky.feed.post.$build({
|
|
16
|
+
text: 'Hello, world!',
|
|
17
|
+
createdAt: new Date().toISOString(),
|
|
18
|
+
})
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
app.bsky.actor.profile.$validate({
|
|
21
|
+
$type: 'app.bsky.actor.profile',
|
|
22
|
+
displayName: 'Ha'.repeat(32) + '!',
|
|
23
|
+
}) // Error: grapheme too big (maximum 64) at $.displayName (got 65)
|
|
24
|
+
```
|
|
19
25
|
|
|
20
|
-
|
|
26
|
+
```typescript
|
|
27
|
+
// Trivially make type-safe XRPC requests towards a service
|
|
21
28
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
const profile = await xrpc('https://api.bsky.app', app.bsky.actor.getProfile, {
|
|
30
|
+
params: { actor: 'pfrazee.com' },
|
|
31
|
+
})
|
|
32
|
+
```
|
|
26
33
|
|
|
27
34
|
```typescript
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
// Manipulate records with the Client API in the context of an authenticated session
|
|
36
|
+
|
|
37
|
+
const client = new Client(oauthSession)
|
|
31
38
|
|
|
32
39
|
await client.create(app.bsky.feed.post, {
|
|
33
40
|
text: 'Hello, world!',
|
|
34
41
|
createdAt: new Date().toISOString(),
|
|
35
42
|
})
|
|
36
43
|
|
|
37
|
-
const posts = await client.list(app.bsky.feed.post, {
|
|
38
|
-
limit: 10,
|
|
39
|
-
repo: 'atproto.com',
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
app.bsky.actor.profile.$validate({
|
|
43
|
-
$type: 'app.bsky.actor.profile',
|
|
44
|
-
displayName: 'Ha'.repeat(32) + '!',
|
|
45
|
-
}) // { success: false, error: Error: grapheme too big (maximum 64) at $.displayName (got 65) }
|
|
44
|
+
const posts = await client.list(app.bsky.feed.post, { limit: 10 })
|
|
46
45
|
```
|
|
47
46
|
|
|
48
47
|
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
@@ -59,6 +58,7 @@ app.bsky.actor.profile.$validate({
|
|
|
59
58
|
- [Types](#types)
|
|
60
59
|
- [JSON Encoding](#json-encoding)
|
|
61
60
|
- [CBOR Encoding](#cbor-encoding)
|
|
61
|
+
- [Making simple XRPC Requests](#making-simple-xrpc-requests)
|
|
62
62
|
- [Client API](#client-api)
|
|
63
63
|
- [Creating a Client](#creating-a-client)
|
|
64
64
|
- [Core Methods](#core-methods)
|
|
@@ -135,15 +135,11 @@ This generates TypeScript files in `./src/lexicons` (by default) with type-safe
|
|
|
135
135
|
**4. Use in your code**
|
|
136
136
|
|
|
137
137
|
```typescript
|
|
138
|
-
import {
|
|
139
|
-
import
|
|
138
|
+
import { xrpc } from '@atproto/lex'
|
|
139
|
+
import { app } from './lexicons/index.js'
|
|
140
140
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
// Start making requests using generated schemas
|
|
145
|
-
const response = await client.call(app.bsky.actor.getProfile, {
|
|
146
|
-
actor: 'pfrazee.com',
|
|
141
|
+
const profile = await xrpc('https://api.bsky.app', app.bsky.actor.getProfile, {
|
|
142
|
+
params: { actor: 'pfrazee.com' },
|
|
147
143
|
})
|
|
148
144
|
```
|
|
149
145
|
|
|
@@ -414,7 +410,7 @@ if (isTypedLexMap(data)) {
|
|
|
414
410
|
In JSON, CIDs are represented as `{"$link": "bafyrei..."}` and bytes as `{"$bytes": "base64..."}`. This package provides utilities to parse and stringify data model values to/from JSON:
|
|
415
411
|
|
|
416
412
|
```typescript
|
|
417
|
-
import { lexParse, lexStringify, jsonToLex, lexToJson } from '@atproto/lex'
|
|
413
|
+
import { Cid, lexParse, lexStringify, jsonToLex, lexToJson } from '@atproto/lex'
|
|
418
414
|
|
|
419
415
|
// Parse JSON string → data model (decodes $link and $bytes)
|
|
420
416
|
const parsed = lexParse<{
|
|
@@ -425,6 +421,9 @@ const parsed = lexParse<{
|
|
|
425
421
|
"data": { "$bytes": "SGVsbG8sIHdvcmxkIQ==" }
|
|
426
422
|
}`)
|
|
427
423
|
|
|
424
|
+
assert(isCid(parsed.ref))
|
|
425
|
+
assert(parsed.data instanceof Uint8Array)
|
|
426
|
+
|
|
428
427
|
const someCid = lexParse<Cid>('{"$link": "bafyrei..."}')
|
|
429
428
|
const someBytes = lexParse<Uint8Array>('{"$bytes": "SGVsbG8sIHdvcmxkIQ=="}')
|
|
430
429
|
|
|
@@ -458,8 +457,53 @@ const cborBytes = encode(someLexValue)
|
|
|
458
457
|
const lexValue: LexValue = decode(cborBytes)
|
|
459
458
|
```
|
|
460
459
|
|
|
460
|
+
## Making simple XRPC Requests
|
|
461
|
+
|
|
462
|
+
[XRPC](https://atproto.com/specs/xrpc) (short for "Lexicon RPC") is the set of HTTP conventions used by AT Protocol for client-server and server-server communication. Endpoints follow the pattern `/xrpc/<nsid>`, where the NSID maps to a Lexicon schema that defines the request and response types. XRPC has three method types: **queries** (HTTP GET) for read operations, **procedures** (HTTP POST) for mutations and **subscriptions** (WebSockets) for real-time updates.
|
|
463
|
+
|
|
464
|
+
The `xrpc()` and `xrpcSafe()` functions can be used to make simple XRPC requests. They are typically used in places that don't require an authenticated session, or when more granular control over the request/response is needed. For most use cases, the `Client` API provides a more ergonomic way to work with XRPC in the context of an authenticated session.
|
|
465
|
+
|
|
466
|
+
```typescript
|
|
467
|
+
import { xrpc, xrpcSafe } from '@atproto/lex'
|
|
468
|
+
import * as com from './lexicons/com.js'
|
|
469
|
+
|
|
470
|
+
const response = await xrpc(
|
|
471
|
+
'https://bsky.network',
|
|
472
|
+
com.atproto.identity.resolveHandle,
|
|
473
|
+
{
|
|
474
|
+
params: { handle: 'atproto.com' },
|
|
475
|
+
headers: { 'user-agent': 'MyApp/1.0.0' },
|
|
476
|
+
},
|
|
477
|
+
)
|
|
478
|
+
|
|
479
|
+
response.status // number
|
|
480
|
+
response.headers // Headers
|
|
481
|
+
response.body.did // `did:${string}:${string}`
|
|
482
|
+
|
|
483
|
+
// Or use the safe variant (returns errors instead of throwing)
|
|
484
|
+
const result = await xrpcSafe(
|
|
485
|
+
'https://bsky.network',
|
|
486
|
+
com.atproto.identity.resolveHandle,
|
|
487
|
+
{
|
|
488
|
+
params: { handle: 'atproto.com' },
|
|
489
|
+
signal: AbortSignal.timeout(5000), // Abort after 5 seconds
|
|
490
|
+
},
|
|
491
|
+
)
|
|
492
|
+
|
|
493
|
+
if (result.success) {
|
|
494
|
+
console.log(result.body)
|
|
495
|
+
} else {
|
|
496
|
+
console.error(result.error) // XRPC error code
|
|
497
|
+
console.error(result.message) // Error message
|
|
498
|
+
}
|
|
499
|
+
```
|
|
500
|
+
|
|
461
501
|
## Client API
|
|
462
502
|
|
|
503
|
+
The `Client` class provides high-level helpers for common AT Protocol "repo" operations: `create()`, `get()`, `put()`, `delete()`, `list()`, `uploadBlob()`, and more. A `Client` instance is typically useful for making requests in the context of an authenticated user session, as it automatically handles headers and provides default values based on the authenticated user's DID.
|
|
504
|
+
|
|
505
|
+
A `Client` instance is also useful to encapsulate configuration for a specific service, by specifying the `service` option (for proxying) and `labelers` option (for content labeling). Additionally, a `Client` can be used as an `Agent` for another `Client`, allowing you to compose headers and configuration across multiple services.
|
|
506
|
+
|
|
463
507
|
### Creating a Client
|
|
464
508
|
|
|
465
509
|
#### Unauthenticated Client
|
|
@@ -558,7 +602,7 @@ const timeline = await client.call(
|
|
|
558
602
|
|
|
559
603
|
#### `client.create()`
|
|
560
604
|
|
|
561
|
-
Create a new record.
|
|
605
|
+
Create a new record un the authenticated user's repo.
|
|
562
606
|
|
|
563
607
|
```typescript
|
|
564
608
|
import * as app from './lexicons/app.js'
|
|
@@ -585,6 +629,7 @@ Retrieve a record.
|
|
|
585
629
|
```typescript
|
|
586
630
|
import * as app from './lexicons/app.js'
|
|
587
631
|
|
|
632
|
+
// No need to specify the "rkey" for records with literal keys (e.g. profile)
|
|
588
633
|
const profile = await client.get(app.bsky.actor.profile)
|
|
589
634
|
|
|
590
635
|
console.log(profile.displayName)
|
package/dist/index.d.ts
CHANGED
|
@@ -3,30 +3,35 @@
|
|
|
3
3
|
* lexicons, including data types, JSON encoding/decoding, schema validation,
|
|
4
4
|
* and HTTP client functionality.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
export {
|
|
9
|
+
/**
|
|
10
|
+
* The Client class is the primary interface for interacting with AT Protocol
|
|
11
|
+
* services though an authenticated session. It provides methods for making
|
|
12
|
+
* XRPC requests, handling records, and managing blobs.
|
|
13
|
+
*/
|
|
14
|
+
Client,
|
|
15
|
+
/**
|
|
16
|
+
* The `xrpc` function is a low-level utility for making XRPC requests towards
|
|
17
|
+
* a specific service. It allows for detailed control over the request,
|
|
18
|
+
* including custom parameters, body, and headers. This function is useful for
|
|
19
|
+
* advanced use cases where the higher-level `Client` methods may not provide
|
|
20
|
+
* enough flexibility.
|
|
21
|
+
*/
|
|
22
|
+
xrpc,
|
|
23
|
+
/**
|
|
24
|
+
* The `xrpcSafe` function is a wrapper around `xrpc` that provides additional
|
|
25
|
+
* safety checks and error handling. It ensures that the request is properly
|
|
26
|
+
* formed and that any errors are caught and handled gracefully. This function
|
|
27
|
+
* is recommended for most use cases, as it provides a safer interface for
|
|
28
|
+
* making XRPC requests.
|
|
29
|
+
*/
|
|
30
|
+
xrpcSafe, } from '@atproto/lex-client';
|
|
31
|
+
export * from '@atproto/lex-client';
|
|
32
|
+
export {
|
|
33
|
+
/**
|
|
34
|
+
* The {@link l} namespace (from `@atproto/lex-schema`) provides an imperative API for building schemas:
|
|
30
35
|
*
|
|
31
36
|
* ### Primitive Types
|
|
32
37
|
* - {@link l.string | l.string()} - String values with optional format/length constraints
|
|
@@ -57,11 +62,50 @@
|
|
|
57
62
|
* - {@link l.query | l.query()} - Define a Lexicon query method
|
|
58
63
|
* - {@link l.procedure | l.procedure()} - Define a Lexicon procedure method
|
|
59
64
|
* - {@link l.subscription | l.subscription()} - Define a Lexicon subscription method
|
|
60
|
-
*
|
|
61
|
-
* @packageDocumentation
|
|
62
65
|
*/
|
|
66
|
+
l, } from '@atproto/lex-schema';
|
|
67
|
+
export * from '@atproto/lex-schema';
|
|
68
|
+
export {
|
|
69
|
+
/**
|
|
70
|
+
* The `LexMap` type represents an object with string keys and `LexValue` values.
|
|
71
|
+
* It is used to represent arbitrary objects in Lexicon schemas, where the
|
|
72
|
+
* properties are not predefined. This type allows for flexible data structures
|
|
73
|
+
* while still ensuring that all values conform to the `LexValue` type.
|
|
74
|
+
*/
|
|
75
|
+
type LexMap,
|
|
76
|
+
/**
|
|
77
|
+
* The `LexValue` type represents any valid value that can be used in a
|
|
78
|
+
* Lexicon schema. It is a union of all the primitive and composite types
|
|
79
|
+
* defined in `@atproto/lex-data`, including strings, integers, booleans,
|
|
80
|
+
* bytes, CIDs, blob references, objects, arrays, and maps. This type is used
|
|
81
|
+
* throughout the library to represent data that conforms to Lexicon schemas.
|
|
82
|
+
*/
|
|
83
|
+
type LexValue, } from '@atproto/lex-data';
|
|
63
84
|
export * from '@atproto/lex-data';
|
|
85
|
+
export {
|
|
86
|
+
/**
|
|
87
|
+
* The `jsonToLex` function takes a plain JavaScript object (typically parsed from
|
|
88
|
+
* JSON) and converts it back into a LexValue, reconstructing any complex types as needed. This is useful
|
|
89
|
+
* for processing data received from the network or loaded from JSON storage.
|
|
90
|
+
*/
|
|
91
|
+
jsonToLex,
|
|
92
|
+
/**
|
|
93
|
+
* The `lexParse` function takes a JSON string and parses it into a LexValue. It
|
|
94
|
+
* performs the necessary conversions to reconstruct complex LexValue types from
|
|
95
|
+
* their JSON representations.
|
|
96
|
+
*/
|
|
97
|
+
lexParse,
|
|
98
|
+
/**
|
|
99
|
+
* The `lexStringify` function takes a LexValue and serializes it to a JSON string.
|
|
100
|
+
* It handles the conversion of complex LexValue types (like BlobRef and Cid) into
|
|
101
|
+
* a JSON-friendly format.
|
|
102
|
+
*/
|
|
103
|
+
lexStringify,
|
|
104
|
+
/**
|
|
105
|
+
* The `lexToJson` function converts a LexValue into a plain JavaScript object
|
|
106
|
+
* that can be safely serialized to JSON. This is useful for preparing data to be
|
|
107
|
+
* sent over the network or stored in a JSON format.
|
|
108
|
+
*/
|
|
109
|
+
lexToJson, } from '@atproto/lex-json';
|
|
64
110
|
export * from '@atproto/lex-json';
|
|
65
|
-
export * from '@atproto/lex-schema';
|
|
66
|
-
export * from '@atproto/lex-client';
|
|
67
111
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO;AACL;;;;GAIG;AACH,MAAM;AACN;;;;;;GAMG;AACH,IAAI;AACJ;;;;;;GAMG;AACH,QAAQ,GACT,MAAM,qBAAqB,CAAA;AAC5B,cAAc,qBAAqB,CAAA;AAEnC,OAAO;AACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,CAAC,GACF,MAAM,qBAAqB,CAAA;AAC5B,cAAc,qBAAqB,CAAA;AAEnC,OAAO;AACL;;;;;GAKG;AACH,KAAK,MAAM;AACX;;;;;;GAMG;AACH,KAAK,QAAQ,GACd,MAAM,mBAAmB,CAAA;AAC1B,cAAc,mBAAmB,CAAA;AAEjC,OAAO;AACL;;;;GAIG;AACH,SAAS;AACT;;;;GAIG;AACH,QAAQ;AACR;;;;GAIG;AACH,YAAY;AACZ;;;;GAIG;AACH,SAAS,GACV,MAAM,mBAAmB,CAAA;AAC1B,cAAc,mBAAmB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,36 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
2
|
/**
|
|
6
3
|
* The `@atproto/lex` package provides utilities for working with ATProtocol
|
|
7
4
|
* lexicons, including data types, JSON encoding/decoding, schema validation,
|
|
8
5
|
* and HTTP client functionality.
|
|
9
6
|
*
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.lexToJson = exports.lexStringify = exports.lexParse = exports.jsonToLex = exports.l = exports.xrpcSafe = exports.xrpc = exports.Client = void 0;
|
|
11
|
+
const tslib_1 = require("tslib");
|
|
12
|
+
var lex_client_1 = require("@atproto/lex-client");
|
|
13
|
+
/**
|
|
14
|
+
* The Client class is the primary interface for interacting with AT Protocol
|
|
15
|
+
* services though an authenticated session. It provides methods for making
|
|
16
|
+
* XRPC requests, handling records, and managing blobs.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return lex_client_1.Client; } });
|
|
19
|
+
/**
|
|
20
|
+
* The `xrpc` function is a low-level utility for making XRPC requests towards
|
|
21
|
+
* a specific service. It allows for detailed control over the request,
|
|
22
|
+
* including custom parameters, body, and headers. This function is useful for
|
|
23
|
+
* advanced use cases where the higher-level `Client` methods may not provide
|
|
24
|
+
* enough flexibility.
|
|
25
|
+
*/
|
|
26
|
+
Object.defineProperty(exports, "xrpc", { enumerable: true, get: function () { return lex_client_1.xrpc; } });
|
|
27
|
+
/**
|
|
28
|
+
* The `xrpcSafe` function is a wrapper around `xrpc` that provides additional
|
|
29
|
+
* safety checks and error handling. It ensures that the request is properly
|
|
30
|
+
* formed and that any errors are caught and handled gracefully. This function
|
|
31
|
+
* is recommended for most use cases, as it provides a safer interface for
|
|
32
|
+
* making XRPC requests.
|
|
33
|
+
*/
|
|
34
|
+
Object.defineProperty(exports, "xrpcSafe", { enumerable: true, get: function () { return lex_client_1.xrpcSafe; } });
|
|
35
|
+
tslib_1.__exportStar(require("@atproto/lex-client"), exports);
|
|
36
|
+
var lex_schema_1 = require("@atproto/lex-schema");
|
|
37
|
+
/**
|
|
38
|
+
* The {@link l} namespace (from `@atproto/lex-schema`) provides an imperative API for building schemas:
|
|
34
39
|
*
|
|
35
40
|
* ### Primitive Types
|
|
36
41
|
* - {@link l.string | l.string()} - String values with optional format/length constraints
|
|
@@ -61,11 +66,34 @@ const tslib_1 = require("tslib");
|
|
|
61
66
|
* - {@link l.query | l.query()} - Define a Lexicon query method
|
|
62
67
|
* - {@link l.procedure | l.procedure()} - Define a Lexicon procedure method
|
|
63
68
|
* - {@link l.subscription | l.subscription()} - Define a Lexicon subscription method
|
|
64
|
-
*
|
|
65
|
-
* @packageDocumentation
|
|
66
69
|
*/
|
|
70
|
+
Object.defineProperty(exports, "l", { enumerable: true, get: function () { return lex_schema_1.l; } });
|
|
71
|
+
tslib_1.__exportStar(require("@atproto/lex-schema"), exports);
|
|
67
72
|
tslib_1.__exportStar(require("@atproto/lex-data"), exports);
|
|
73
|
+
var lex_json_1 = require("@atproto/lex-json");
|
|
74
|
+
/**
|
|
75
|
+
* The `jsonToLex` function takes a plain JavaScript object (typically parsed from
|
|
76
|
+
* JSON) and converts it back into a LexValue, reconstructing any complex types as needed. This is useful
|
|
77
|
+
* for processing data received from the network or loaded from JSON storage.
|
|
78
|
+
*/
|
|
79
|
+
Object.defineProperty(exports, "jsonToLex", { enumerable: true, get: function () { return lex_json_1.jsonToLex; } });
|
|
80
|
+
/**
|
|
81
|
+
* The `lexParse` function takes a JSON string and parses it into a LexValue. It
|
|
82
|
+
* performs the necessary conversions to reconstruct complex LexValue types from
|
|
83
|
+
* their JSON representations.
|
|
84
|
+
*/
|
|
85
|
+
Object.defineProperty(exports, "lexParse", { enumerable: true, get: function () { return lex_json_1.lexParse; } });
|
|
86
|
+
/**
|
|
87
|
+
* The `lexStringify` function takes a LexValue and serializes it to a JSON string.
|
|
88
|
+
* It handles the conversion of complex LexValue types (like BlobRef and Cid) into
|
|
89
|
+
* a JSON-friendly format.
|
|
90
|
+
*/
|
|
91
|
+
Object.defineProperty(exports, "lexStringify", { enumerable: true, get: function () { return lex_json_1.lexStringify; } });
|
|
92
|
+
/**
|
|
93
|
+
* The `lexToJson` function converts a LexValue into a plain JavaScript object
|
|
94
|
+
* that can be safely serialized to JSON. This is useful for preparing data to be
|
|
95
|
+
* sent over the network or stored in a JSON format.
|
|
96
|
+
*/
|
|
97
|
+
Object.defineProperty(exports, "lexToJson", { enumerable: true, get: function () { return lex_json_1.lexToJson; } });
|
|
68
98
|
tslib_1.__exportStar(require("@atproto/lex-json"), exports);
|
|
69
|
-
tslib_1.__exportStar(require("@atproto/lex-schema"), exports);
|
|
70
|
-
tslib_1.__exportStar(require("@atproto/lex-client"), exports);
|
|
71
99
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;AAEH,kDAuB4B;AAtB1B;;;;GAIG;AACH,oGAAA,MAAM,OAAA;AACN;;;;;;GAMG;AACH,kGAAA,IAAI,OAAA;AACJ;;;;;;GAMG;AACH,sGAAA,QAAQ,OAAA;AAEV,8DAAmC;AAEnC,kDAmC4B;AAlC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,+FAAA,CAAC,OAAA;AAEH,8DAAmC;AAmBnC,4DAAiC;AAEjC,8CAyB0B;AAxBxB;;;;GAIG;AACH,qGAAA,SAAS,OAAA;AACT;;;;GAIG;AACH,oGAAA,QAAQ,OAAA;AACR;;;;GAIG;AACH,wGAAA,YAAY,OAAA;AACZ;;;;GAIG;AACH,qGAAA,SAAS,OAAA;AAEX,4DAAiC","sourcesContent":["/**\n * The `@atproto/lex` package provides utilities for working with ATProtocol\n * lexicons, including data types, JSON encoding/decoding, schema validation,\n * and HTTP client functionality.\n *\n * @packageDocumentation\n */\n\nexport {\n /**\n * The Client class is the primary interface for interacting with AT Protocol\n * services though an authenticated session. It provides methods for making\n * XRPC requests, handling records, and managing blobs.\n */\n Client,\n /**\n * The `xrpc` function is a low-level utility for making XRPC requests towards\n * a specific service. It allows for detailed control over the request,\n * including custom parameters, body, and headers. This function is useful for\n * advanced use cases where the higher-level `Client` methods may not provide\n * enough flexibility.\n */\n xrpc,\n /**\n * The `xrpcSafe` function is a wrapper around `xrpc` that provides additional\n * safety checks and error handling. It ensures that the request is properly\n * formed and that any errors are caught and handled gracefully. This function\n * is recommended for most use cases, as it provides a safer interface for\n * making XRPC requests.\n */\n xrpcSafe,\n} from '@atproto/lex-client'\nexport * from '@atproto/lex-client'\n\nexport {\n /**\n * The {@link l} namespace (from `@atproto/lex-schema`) provides an imperative API for building schemas:\n *\n * ### Primitive Types\n * - {@link l.string | l.string()} - String values with optional format/length constraints\n * - {@link l.integer | l.integer()} - Integer values with optional min/max constraints\n * - {@link l.boolean | l.boolean()} - Boolean values\n * - {@link l.bytes | l.bytes()} - Binary data (Uint8Array)\n * - {@link l.cid | l.cid()} - Content Identifier values\n * - {@link l.blob | l.blob()} - Blob references with mime type and size\n *\n * ### Composite Types\n * - {@link l.object | l.object()} - Objects with defined property schemas\n * - {@link l.array | l.array()} - Arrays with element type validation\n * - {@link l.union | l.union()} - Union of multiple possible types\n * - {@link l.ref | l.ref()} - Reference to another schema definition\n * - {@link l.literal | l.literal()} - Literal constant values\n * - {@link l.enum | l.enum()} - Enum of allowed string values\n * - {@link l.typedRef | l.typedRef()} - Reference to a {@link l.typedObject | l.typedObject()}\n * - {@link l.typedUnion | l.typedUnion()} - Discriminated union between multiple {@link l.typedRef | l.typedRef()} or {@link l.typedObject | l.typedObject()} types\n *\n * ### Modifiers\n * - {@link l.optional | l.optional()} - Mark a property as optional\n * - {@link l.nullable | l.nullable()} - Allow null values\n * - {@link l.withDefault | l.withDefault()} - Provide a default value\n *\n * ### Lexicon Definitions\n * - {@link l.typedObject | l.typedObject()} - Define a typed object with a `$type` property\n * - {@link l.record | l.record()} - Define a Lexicon record type\n * - {@link l.query | l.query()} - Define a Lexicon query method\n * - {@link l.procedure | l.procedure()} - Define a Lexicon procedure method\n * - {@link l.subscription | l.subscription()} - Define a Lexicon subscription method\n */\n l,\n} from '@atproto/lex-schema'\nexport * from '@atproto/lex-schema'\n\nexport {\n /**\n * The `LexMap` type represents an object with string keys and `LexValue` values.\n * It is used to represent arbitrary objects in Lexicon schemas, where the\n * properties are not predefined. This type allows for flexible data structures\n * while still ensuring that all values conform to the `LexValue` type.\n */\n type LexMap,\n /**\n * The `LexValue` type represents any valid value that can be used in a\n * Lexicon schema. It is a union of all the primitive and composite types\n * defined in `@atproto/lex-data`, including strings, integers, booleans,\n * bytes, CIDs, blob references, objects, arrays, and maps. This type is used\n * throughout the library to represent data that conforms to Lexicon schemas.\n */\n type LexValue,\n} from '@atproto/lex-data'\nexport * from '@atproto/lex-data'\n\nexport {\n /**\n * The `jsonToLex` function takes a plain JavaScript object (typically parsed from\n * JSON) and converts it back into a LexValue, reconstructing any complex types as needed. This is useful\n * for processing data received from the network or loaded from JSON storage.\n */\n jsonToLex,\n /**\n * The `lexParse` function takes a JSON string and parses it into a LexValue. It\n * performs the necessary conversions to reconstruct complex LexValue types from\n * their JSON representations.\n */\n lexParse,\n /**\n * The `lexStringify` function takes a LexValue and serializes it to a JSON string.\n * It handles the conversion of complex LexValue types (like BlobRef and Cid) into\n * a JSON-friendly format.\n */\n lexStringify,\n /**\n * The `lexToJson` function converts a LexValue into a plain JavaScript object\n * that can be safely serialized to JSON. This is useful for preparing data to be\n * sent over the network or stored in a JSON format.\n */\n lexToJson,\n} from '@atproto/lex-json'\nexport * from '@atproto/lex-json'\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/lex",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Lexicon tooling for AT",
|
|
6
6
|
"keywords": [
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"tslib": "^2.8.1",
|
|
40
40
|
"yargs": "^17.0.0",
|
|
41
41
|
"@atproto/lex-builder": "^0.0.16",
|
|
42
|
-
"@atproto/lex-client": "^0.0.
|
|
42
|
+
"@atproto/lex-client": "^0.0.14",
|
|
43
43
|
"@atproto/lex-data": "^0.0.12",
|
|
44
44
|
"@atproto/lex-json": "^0.0.12",
|
|
45
|
-
"@atproto/lex-installer": "^0.0.
|
|
45
|
+
"@atproto/lex-installer": "^0.0.19",
|
|
46
46
|
"@atproto/lex-schema": "^0.0.13"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|