@atproto/lex 0.3.8 → 0.3.11

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,32 @@
1
1
  # @atproto/lex
2
2
 
3
+ ## 0.3.11
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @atproto/lex-installer@0.1.20
9
+
10
+ ## 0.3.10
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [[`fe4087e`](https://github.com/bluesky-social/atproto/commit/fe4087ecb7a7cc53c7081c9f97d49121e5251c36)]:
15
+ - @atproto/lex-builder@0.1.15
16
+ - @atproto/lex-installer@0.1.19
17
+
18
+ ## 0.3.9
19
+
20
+ ### Patch Changes
21
+
22
+ - [#5426](https://github.com/bluesky-social/atproto/pull/5426) [`ed0b7d3`](https://github.com/bluesky-social/atproto/commit/ed0b7d38811bb24952a3f1da988b02e39934d222) Thanks [@bigmoves](https://github.com/bigmoves)! - Add `walk` utility to browse a generated namespace.
23
+
24
+ - Updated dependencies [[`ed0b7d3`](https://github.com/bluesky-social/atproto/commit/ed0b7d38811bb24952a3f1da988b02e39934d222), [`ed0b7d3`](https://github.com/bluesky-social/atproto/commit/ed0b7d38811bb24952a3f1da988b02e39934d222)]:
25
+ - @atproto/lex-schema@0.2.7
26
+ - @atproto/lex-builder@0.1.14
27
+ - @atproto/lex-client@0.3.6
28
+ - @atproto/lex-installer@0.1.18
29
+
3
30
  ## 0.3.8
4
31
 
5
32
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -108,4 +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
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;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jC,cAAc,WAAW,CAAA"}
package/dist/index.js CHANGED
@@ -93,4 +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
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","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"]}
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"]}
package/dist/walk.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { Procedure, Query, Schema, Subscription } from '@atproto/lex-schema';
2
+ export declare function walk(ns: Record<string, unknown>): Generator<Schema | Procedure | Subscription | Query>;
3
+ //# sourceMappingURL=walk.d.ts.map
@@ -0,0 +1 @@
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,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC1B,SAAS,CAAC,MAAM,GAAG,SAAS,GAAG,YAAY,GAAG,KAAK,CAAC,CAwCtD"}
package/dist/walk.js ADDED
@@ -0,0 +1,37 @@
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;
6
+ const visited = new Set();
7
+ for (const [key, value] of Object.entries(ns)) {
8
+ // Ignore helpers
9
+ if (key.startsWith('$')) {
10
+ continue;
11
+ }
12
+ // Ignore non-objects (should never happen)
13
+ if (!isObject(value)) {
14
+ continue;
15
+ }
16
+ // Ignore "main" re-exported as "default"
17
+ if (key === 'default' && value === ns['main']) {
18
+ continue;
19
+ }
20
+ // De-dupe
21
+ if (visited.has(value)) {
22
+ continue;
23
+ }
24
+ visited.add(value);
25
+ if (value instanceof Schema ||
26
+ value instanceof Procedure ||
27
+ value instanceof Subscription ||
28
+ value instanceof Query) {
29
+ yield value;
30
+ }
31
+ else if (isPlainProto(value)) {
32
+ // child namespace
33
+ yield* walk(value);
34
+ }
35
+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AAI,CAAC,KAAK,CAAC,CAAA;QACpB,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: Record<string, unknown>,\n): Generator<Schema | Procedure | Subscription | Query> {\n if (!isPlainObject(ns)) return\n\n const visited = new Set<unknown>()\n\n for (const [key, value] of Object.entries(ns)) {\n // Ignore helpers\n if (key.startsWith('$')) {\n continue\n }\n\n // Ignore non-objects (should never happen)\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* walk(value)\n }\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/lex",
3
- "version": "0.3.8",
3
+ "version": "0.3.11",
4
4
  "license": "MIT",
5
5
  "description": "Lexicon tooling for AT",
6
6
  "keywords": [
@@ -38,12 +38,12 @@
38
38
  "dependencies": {
39
39
  "tslib": "^2.8.1",
40
40
  "yargs": "^18.0.0",
41
- "@atproto/lex-builder": "^0.1.13",
42
- "@atproto/lex-data": "^0.1.7",
43
- "@atproto/lex-installer": "^0.1.17",
41
+ "@atproto/lex-builder": "^0.1.15",
42
+ "@atproto/lex-client": "^0.3.6",
43
+ "@atproto/lex-installer": "^0.1.20",
44
44
  "@atproto/lex-json": "^0.1.6",
45
- "@atproto/lex-schema": "^0.2.6",
46
- "@atproto/lex-client": "^0.3.5"
45
+ "@atproto/lex-data": "^0.1.7",
46
+ "@atproto/lex-schema": "^0.2.7"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@types/yargs": "^17.0.33",