@atproto/lex 0.4.3 → 0.4.7

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 CHANGED
@@ -1,5 +1,50 @@
1
1
  # @atproto/lex
2
2
 
3
+ ## 0.4.7
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`8c841f6`](https://github.com/bluesky-social/atproto/commit/8c841f6e73c8365c2dfe816c0613aa9c50490361), [`8c841f6`](https://github.com/bluesky-social/atproto/commit/8c841f6e73c8365c2dfe816c0613aa9c50490361), [`8c841f6`](https://github.com/bluesky-social/atproto/commit/8c841f6e73c8365c2dfe816c0613aa9c50490361), [`8c841f6`](https://github.com/bluesky-social/atproto/commit/8c841f6e73c8365c2dfe816c0613aa9c50490361)]:
8
+ - @atproto/lex-data@0.1.10
9
+ - @atproto/lex-cbor@0.1.9
10
+ - @atproto/lex-schema@0.2.11
11
+ - @atproto/lex-client@0.4.2
12
+ - @atproto/lex-installer@0.2.7
13
+ - @atproto/lex-json@0.1.9
14
+ - @atproto/lex-builder@0.1.20
15
+
16
+ ## 0.4.6
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies []:
21
+ - @atproto/lex-installer@0.2.6
22
+
23
+ ## 0.4.5
24
+
25
+ ### Patch Changes
26
+
27
+ - [#5786](https://github.com/bluesky-social/atproto/pull/5786) [`07c25d4`](https://github.com/bluesky-social/atproto/commit/07c25d410d4f4ad8f6ec80fc14efa0dd8ec55545) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Document installing `@atproto/lex` as a dev dependency, and importing from the packages it re-exports when the code is not bundled
28
+
29
+ - [#5786](https://github.com/bluesky-social/atproto/pull/5786) [`07c25d4`](https://github.com/bluesky-social/atproto/commit/07c25d410d4f4ad8f6ec80fc14efa0dd8ec55545) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Re-export `@atproto/lex-cbor` from `@atproto/lex`
30
+
31
+ - [#5786](https://github.com/bluesky-social/atproto/pull/5786) [`07c25d4`](https://github.com/bluesky-social/atproto/commit/07c25d410d4f4ad8f6ec80fc14efa0dd8ec55545) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Move `walk` to `@atproto/lex-schema`, which `@atproto/lex` still re-exports it from
32
+ - Updated dependencies [[`07c25d4`](https://github.com/bluesky-social/atproto/commit/07c25d410d4f4ad8f6ec80fc14efa0dd8ec55545), [`07c25d4`](https://github.com/bluesky-social/atproto/commit/07c25d410d4f4ad8f6ec80fc14efa0dd8ec55545), [`7aa8e7e`](https://github.com/bluesky-social/atproto/commit/7aa8e7e9e1422f053447879def4d4cf92a05adbb), [`7aa8e7e`](https://github.com/bluesky-social/atproto/commit/7aa8e7e9e1422f053447879def4d4cf92a05adbb), [`07c25d4`](https://github.com/bluesky-social/atproto/commit/07c25d410d4f4ad8f6ec80fc14efa0dd8ec55545)]:
33
+ - @atproto/lex-cbor@0.1.8
34
+ - @atproto/lex-client@0.4.1
35
+ - @atproto/lex-data@0.1.9
36
+ - @atproto/lex-json@0.1.8
37
+ - @atproto/lex-schema@0.2.10
38
+ - @atproto/lex-installer@0.2.5
39
+ - @atproto/lex-builder@0.1.19
40
+
41
+ ## 0.4.4
42
+
43
+ ### Patch Changes
44
+
45
+ - Updated dependencies []:
46
+ - @atproto/lex-installer@0.2.4
47
+
3
48
  ## 0.4.3
4
49
 
5
50
  ### Patch Changes
package/README.md CHANGED
@@ -43,6 +43,7 @@ const posts = await client.list(app.bsky.feed.post, { limit: 10 })
43
43
  <!-- START doctoc generated TOC please keep comment here to allow auto update -->
44
44
  <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
45
45
 
46
+ - [Installation](#installation)
46
47
  - [Quick Start](#quick-start)
47
48
  - [Lexicon Schemas](#lexicon-schemas)
48
49
  - [TypeScript Schemas](#typescript-schemas)
@@ -123,6 +124,29 @@ const posts = await client.list(app.bsky.feed.post, { limit: 10 })
123
124
 
124
125
  <!-- END doctoc generated TOC please keep comment here to allow auto update -->
125
126
 
127
+ ## Installation
128
+
129
+ `@atproto/lex` provides the `lex` CLI, and re-exports the runtime packages listed below. The CLI depends on the Lexicon installation and code generation tooling, which your code does not need at runtime. Install `@atproto/lex` as a dev dependency:
130
+
131
+ ```bash
132
+ npm install --save-dev @atproto/lex
133
+ ```
134
+
135
+ Only `import` from `@atproto/lex` directly when your code is bundled (e.g. with Vite, Rolldown, esbuild or webpack): the bundler only includes the code you use, so the tooling never reaches the output. Otherwise, for example in a Node.js service or a published library, `@atproto/lex` would have to be installed at runtime, along with all of its tooling. Depend on the runtime packages it re-exports instead, import from them, and pass `--lib @atproto/lex-schema` to `lex build` so that the generated schemas import from `@atproto/lex-schema` too:
136
+
137
+ ```bash
138
+ npm install @atproto/lex-client @atproto/lex-schema
139
+ lex build --lib @atproto/lex-schema
140
+ ```
141
+
142
+ | Package | Provides |
143
+ | --------------------- | --------------------------------------------------------------------------- |
144
+ | `@atproto/lex-client` | `Client`, `xrpc()`, `xrpcSafe()` and XRPC errors |
145
+ | `@atproto/lex-schema` | The `l` schema utility, identifier and datetime string types and helpers |
146
+ | `@atproto/lex-data` | Data model types and helpers: `LexValue`, `Cid`, blob references, … |
147
+ | `@atproto/lex-json` | JSON encoding: `lexParse()`, `lexStringify()`, `jsonToLex()`, `lexToJson()` |
148
+ | `@atproto/lex-cbor` | CBOR encoding: `encode()`, `decode()`, `cidForLex()` |
149
+
126
150
  ## Quick Start
127
151
 
128
152
  **1. Install Lexicons**
@@ -260,7 +284,7 @@ Options:
260
284
  - `--ignore-invalid-lexicons` - Skip lexicon files that fail validation instead of exiting with an error
261
285
  - `--exclude <patterns...>` - List of strings or regex patterns to exclude lexicon documents by their IDs
262
286
  - `--include <patterns...>` - List of strings or regex patterns to include lexicon documents by their IDs
263
- - `--lib <package>` - Package name of the library to import the lex schema utility "l" from (default: `@atproto/lex`)
287
+ - `--lib <package>` - Package name of the library to import the lex schema utility "l" from (default: `@atproto/lex`; use `@atproto/lex-schema` when `@atproto/lex` is a dev dependency, see [Installation](#installation))
264
288
  - `--import-ext <ext>` - File extension to use for import statements in generated files (default: `.js`). Use `--import-ext ""` to generate extension-less imports
265
289
  - `--file-ext <ext>` - File extension to use for generated files (default: `.ts`)
266
290
  - `--index-file` - Generate an "index" file that re-exports all root-level namespaces (disabled by default)
@@ -590,11 +614,10 @@ const obj = lexToJson({
590
614
 
591
615
  ### CBOR Encoding
592
616
 
593
- Use `@atproto/lex-cbor` to encode/decode the data model to/from CBOR ([DRISL](https://dasl.ing/drisl.html)) format for storage and authentication:
617
+ The package re-exports `@atproto/lex-cbor` to encode/decode the data model to/from CBOR ([DRISL](https://dasl.ing/drisl.html)) format for storage and authentication:
594
618
 
595
619
  ```typescript
596
- import { encode, decode } from '@atproto/lex-cbor'
597
- import type { LexValue } from '@atproto/lex'
620
+ import { encode, decode, type LexValue } from '@atproto/lex'
598
621
 
599
622
  // Encode data model to CBOR bytes
600
623
  const cborBytes = encode(someLexValue)
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The `@atproto/lex` package provides utilities for working with ATProtocol
3
- * lexicons, including data types, JSON encoding/decoding, schema validation,
4
- * and HTTP client functionality.
3
+ * lexicons, including data types, JSON and CBOR encoding/decoding, schema
4
+ * validation, and HTTP client functionality.
5
5
  *
6
6
  * @packageDocumentation
7
7
  */
@@ -108,5 +108,5 @@ lexStringify,
108
108
  */
109
109
  lexToJson, } from '@atproto/lex-json';
110
110
  export * from '@atproto/lex-json';
111
- export * from './walk.js';
111
+ export * from '@atproto/lex-cbor';
112
112
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
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;AAEjC,cAAc,WAAW,CAAA"}
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;AAEjC,cAAc,mBAAmB,CAAA"}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The `@atproto/lex` package provides utilities for working with ATProtocol
3
- * lexicons, including data types, JSON encoding/decoding, schema validation,
4
- * and HTTP client functionality.
3
+ * lexicons, including data types, JSON and CBOR encoding/decoding, schema
4
+ * validation, and HTTP client functionality.
5
5
  *
6
6
  * @packageDocumentation
7
7
  */
@@ -93,5 +93,5 @@ lexStringify,
93
93
  */
94
94
  lexToJson, } from '@atproto/lex-json';
95
95
  export * from '@atproto/lex-json';
96
- export * from './walk.js';
96
+ export * from '@atproto/lex-cbor';
97
97
  //# 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;;;;;;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,EAgBN,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;AAEjC,cAAc,WAAW,CAAA","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\nexport * from './walk.js'\n"]}
1
+ {"version":3,"file":"index.js","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,EAgBN,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;AAEjC,cAAc,mBAAmB,CAAA","sourcesContent":["/**\n * The `@atproto/lex` package provides utilities for working with ATProtocol\n * lexicons, including data types, JSON and CBOR encoding/decoding, schema\n * validation, 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\nexport * from '@atproto/lex-cbor'\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/lex",
3
- "version": "0.4.3",
3
+ "version": "0.4.7",
4
4
  "license": "MIT",
5
5
  "description": "Lexicon tooling for AT",
6
6
  "keywords": [
@@ -36,14 +36,15 @@
36
36
  "node": ">=22"
37
37
  },
38
38
  "dependencies": {
39
+ "@atproto/lex-builder": "^0.1.20",
40
+ "@atproto/lex-cbor": "^0.1.9",
41
+ "@atproto/lex-client": "^0.4.2",
42
+ "@atproto/lex-data": "^0.1.10",
43
+ "@atproto/lex-json": "^0.1.9",
44
+ "@atproto/lex-installer": "^0.2.7",
45
+ "@atproto/lex-schema": "^0.2.11",
39
46
  "tslib": "^2.8.1",
40
- "yargs": "^18.2.0",
41
- "@atproto/lex-builder": "^0.1.18",
42
- "@atproto/lex-client": "^0.4.0",
43
- "@atproto/lex-data": "^0.1.8",
44
- "@atproto/lex-json": "^0.1.7",
45
- "@atproto/lex-installer": "^0.2.3",
46
- "@atproto/lex-schema": "^0.2.9"
47
+ "yargs": "^18.2.0"
47
48
  },
48
49
  "devDependencies": {
49
50
  "@types/yargs": "^17.0.33",
package/dist/walk.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { Procedure, Query, Schema, Subscription } from '@atproto/lex-schema';
2
- export declare function walk(ns: unknown): Generator<Schema | Procedure | Subscription | Query, void, unknown>;
3
- //# sourceMappingURL=walk.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../src/walk.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAE5E,wBAAiB,IAAI,CACnB,EAAE,EAAE,OAAO,GACV,SAAS,CAAC,MAAM,GAAG,SAAS,GAAG,YAAY,GAAG,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAIrE"}
package/dist/walk.js DELETED
@@ -1,39 +0,0 @@
1
- import { isObject, isPlainObject, isPlainProto } from '@atproto/lex-data';
2
- import { Procedure, Query, Schema, Subscription } from '@atproto/lex-schema';
3
- export function* walk(ns) {
4
- if (isPlainObject(ns)) {
5
- return yield* walkInternal(ns, new Set());
6
- }
7
- }
8
- function* walkInternal(ns, visited) {
9
- for (const [key, value] of Object.entries(ns)) {
10
- // Ignore helpers
11
- if (key.startsWith('$')) {
12
- continue;
13
- }
14
- // Ignore non-objects
15
- if (!isObject(value)) {
16
- continue;
17
- }
18
- // Ignore "main" re-exported as "default"
19
- if (key === 'default' && value === ns['main']) {
20
- continue;
21
- }
22
- // De-dupe
23
- if (visited.has(value)) {
24
- continue;
25
- }
26
- visited.add(value);
27
- if (value instanceof Schema ||
28
- value instanceof Procedure ||
29
- value instanceof Subscription ||
30
- value instanceof Query) {
31
- yield value;
32
- }
33
- else if (isPlainProto(value)) {
34
- // child namespace
35
- yield* walkInternal(value, visited);
36
- }
37
- }
38
- }
39
- //# sourceMappingURL=walk.js.map
package/dist/walk.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"walk.js","sourceRoot":"","sources":["../src/walk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAE5E,MAAM,SAAS,CAAC,CAAC,IAAI,CACnB,EAAW;IAEX,IAAI,aAAa,CAAC,EAAE,CAAC,EAAE,CAAC;QACtB,OAAO,KAAK,CAAC,CAAC,YAAY,CAAC,EAAE,EAAE,IAAI,GAAG,EAAW,CAAC,CAAA;IACpD,CAAC;AACH,CAAC;AAED,QAAQ,CAAC,CAAC,YAAY,CACpB,EAA2B,EAC3B,OAAqB;IAErB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;QAC9C,iBAAiB;QACjB,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,SAAQ;QACV,CAAC;QAED,qBAAqB;QACrB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACrB,SAAQ;QACV,CAAC;QAED,yCAAyC;QACzC,IAAI,GAAG,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;YAC9C,SAAQ;QACV,CAAC;QAED,UAAU;QACV,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACvB,SAAQ;QACV,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAElB,IACE,KAAK,YAAY,MAAM;YACvB,KAAK,YAAY,SAAS;YAC1B,KAAK,YAAY,YAAY;YAC7B,KAAK,YAAY,KAAK,EACtB,CAAC;YACD,MAAM,KAAK,CAAA;QACb,CAAC;aAAM,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,kBAAkB;YAClB,KAAK,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QACrC,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { isObject, isPlainObject, isPlainProto } from '@atproto/lex-data'\nimport { Procedure, Query, Schema, Subscription } from '@atproto/lex-schema'\n\nexport function* walk(\n ns: unknown,\n): Generator<Schema | Procedure | Subscription | Query, void, unknown> {\n if (isPlainObject(ns)) {\n return yield* walkInternal(ns, new Set<unknown>())\n }\n}\n\nfunction* walkInternal(\n ns: Record<string, unknown>,\n visited: Set<unknown>,\n): Generator<Schema | Procedure | Subscription | Query, void, unknown> {\n for (const [key, value] of Object.entries(ns)) {\n // Ignore helpers\n if (key.startsWith('$')) {\n continue\n }\n\n // Ignore non-objects\n if (!isObject(value)) {\n continue\n }\n\n // Ignore \"main\" re-exported as \"default\"\n if (key === 'default' && value === ns['main']) {\n continue\n }\n\n // De-dupe\n if (visited.has(value)) {\n continue\n }\n\n visited.add(value)\n\n if (\n value instanceof Schema ||\n value instanceof Procedure ||\n value instanceof Subscription ||\n value instanceof Query\n ) {\n yield value\n } else if (isPlainProto(value)) {\n // child namespace\n yield* walkInternal(value, visited)\n }\n }\n}\n"]}