@atproto/lex 0.0.0-spaces-alpha-20260818163953
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 +582 -0
- package/LICENSE.txt +7 -0
- package/README.md +1804 -0
- package/bin/lex +169 -0
- package/dist/index.d.ts +111 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +96 -0
- package/dist/index.js.map +1 -0
- package/package.json +58 -0
package/bin/lex
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/* eslint-env node */
|
|
4
|
+
|
|
5
|
+
// This file is referenced by the "bin" field in package.json. Because of that,
|
|
6
|
+
// we need this file to exist on disk even before the project is built, so it is
|
|
7
|
+
// written in plain JS. This allows package managers to properly link the CLI
|
|
8
|
+
// command when the monorepo is being setup (during initial "pnpm install").
|
|
9
|
+
|
|
10
|
+
import yargs from 'yargs'
|
|
11
|
+
import { hideBin } from 'yargs/helpers'
|
|
12
|
+
|
|
13
|
+
// @TODO lex-builder and lex-installer should both
|
|
14
|
+
// - Define their own CLI commands and options
|
|
15
|
+
// - Expose a "bin" entrypoint so they can be called independently
|
|
16
|
+
// This package should only be a thin wrapper that delegates to those packages.
|
|
17
|
+
|
|
18
|
+
yargs(hideBin(process.argv))
|
|
19
|
+
.strict()
|
|
20
|
+
.command(
|
|
21
|
+
['build', 'b'],
|
|
22
|
+
'Generate TypeScript lexicon schema files from JSON lexicon definitions',
|
|
23
|
+
(yargs) => {
|
|
24
|
+
return yargs.strict().options({
|
|
25
|
+
lexicons: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
demandOption: true,
|
|
28
|
+
default: './lexicons',
|
|
29
|
+
describe: 'directory containing lexicon JSON files',
|
|
30
|
+
},
|
|
31
|
+
out: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
demandOption: true,
|
|
34
|
+
default: './src/lexicons',
|
|
35
|
+
describe: 'output directory for generated TS files',
|
|
36
|
+
},
|
|
37
|
+
clear: {
|
|
38
|
+
type: 'boolean',
|
|
39
|
+
default: false,
|
|
40
|
+
describe: 'clear output directory before generating files',
|
|
41
|
+
},
|
|
42
|
+
override: {
|
|
43
|
+
type: 'boolean',
|
|
44
|
+
default: false,
|
|
45
|
+
describe: 'override existing files (has no effect with --clear)',
|
|
46
|
+
},
|
|
47
|
+
pretty: {
|
|
48
|
+
type: 'boolean',
|
|
49
|
+
default: true,
|
|
50
|
+
describe: 'run prettier on generated files',
|
|
51
|
+
},
|
|
52
|
+
'ignore-errors': {
|
|
53
|
+
type: 'boolean',
|
|
54
|
+
default: false,
|
|
55
|
+
describe: 'how to handle errors when processing input files',
|
|
56
|
+
},
|
|
57
|
+
exclude: {
|
|
58
|
+
array: true,
|
|
59
|
+
type: 'string',
|
|
60
|
+
describe:
|
|
61
|
+
'list of strings or regex patterns to exclude lexicon documents by their IDs',
|
|
62
|
+
},
|
|
63
|
+
include: {
|
|
64
|
+
array: true,
|
|
65
|
+
type: 'string',
|
|
66
|
+
describe:
|
|
67
|
+
'list of strings or regex patterns to include lexicon documents by their IDs',
|
|
68
|
+
},
|
|
69
|
+
lib: {
|
|
70
|
+
type: 'string',
|
|
71
|
+
default: '@atproto/lex',
|
|
72
|
+
describe:
|
|
73
|
+
'package name of the library to import the lex schema utility "l" from',
|
|
74
|
+
},
|
|
75
|
+
'import-ext': {
|
|
76
|
+
type: 'string',
|
|
77
|
+
default: '.js',
|
|
78
|
+
describe:
|
|
79
|
+
'file extension to use for import statements in generated files (e.g. ".ts", ".mts", ".cts"). Use --import-ext "" to generate extension-less imports.',
|
|
80
|
+
},
|
|
81
|
+
'file-ext': {
|
|
82
|
+
type: 'string',
|
|
83
|
+
default: '.ts',
|
|
84
|
+
describe:
|
|
85
|
+
'file extension to use for generated files (e.g. ".ts", ".mts", ".cts")',
|
|
86
|
+
},
|
|
87
|
+
'index-file': {
|
|
88
|
+
type: 'boolean',
|
|
89
|
+
default: false,
|
|
90
|
+
describe:
|
|
91
|
+
'generate an "index.<fileExt>" file that exports all root-level namespaces',
|
|
92
|
+
},
|
|
93
|
+
'defs-export': {
|
|
94
|
+
type: 'boolean',
|
|
95
|
+
default: false,
|
|
96
|
+
describe:
|
|
97
|
+
'when some definitions conflict with child namespaces, this option allows to export lexicon definitions under a separate $defs namespace (e.g. com.example.foo.$defs)',
|
|
98
|
+
},
|
|
99
|
+
'default-export': {
|
|
100
|
+
type: 'boolean',
|
|
101
|
+
default: true,
|
|
102
|
+
describe:
|
|
103
|
+
'whether to generate a default export for the "main" lexicon definition schema in the parent namespace file',
|
|
104
|
+
},
|
|
105
|
+
'ignore-invalid-lexicons': {
|
|
106
|
+
type: 'boolean',
|
|
107
|
+
default: false,
|
|
108
|
+
describe:
|
|
109
|
+
'skip over invalid lexicon files instead of exiting with an error',
|
|
110
|
+
},
|
|
111
|
+
})
|
|
112
|
+
},
|
|
113
|
+
async (argv) => {
|
|
114
|
+
const { build } = await import('@atproto/lex-builder')
|
|
115
|
+
await build(argv)
|
|
116
|
+
},
|
|
117
|
+
)
|
|
118
|
+
.command(
|
|
119
|
+
['install [nsid..]', 'i [nsid..]'],
|
|
120
|
+
'Fetch and install lexicon documents',
|
|
121
|
+
(yargs) => {
|
|
122
|
+
return yargs.strict().options({
|
|
123
|
+
manifest: {
|
|
124
|
+
type: 'string',
|
|
125
|
+
default: './lexicons.json',
|
|
126
|
+
describe: 'path to lexicons.json manifest file',
|
|
127
|
+
},
|
|
128
|
+
save: {
|
|
129
|
+
alias: 's',
|
|
130
|
+
type: 'boolean',
|
|
131
|
+
default: true,
|
|
132
|
+
describe:
|
|
133
|
+
'Updates lexicons.json with installed lexicons (use --no-save to disable)',
|
|
134
|
+
},
|
|
135
|
+
update: {
|
|
136
|
+
type: 'boolean',
|
|
137
|
+
default: false,
|
|
138
|
+
describe:
|
|
139
|
+
'update all installed lexicons to their latest versions by re-resolving and re-installing them',
|
|
140
|
+
},
|
|
141
|
+
ci: {
|
|
142
|
+
type: 'boolean',
|
|
143
|
+
default: false,
|
|
144
|
+
describe:
|
|
145
|
+
'error if the installed lexicons do not match the CIDs in the lexicons.json manifest',
|
|
146
|
+
},
|
|
147
|
+
lexicons: {
|
|
148
|
+
type: 'string',
|
|
149
|
+
demandOption: true,
|
|
150
|
+
default: './lexicons',
|
|
151
|
+
describe: 'directory containing lexicon JSON files',
|
|
152
|
+
},
|
|
153
|
+
})
|
|
154
|
+
},
|
|
155
|
+
async (argv) => {
|
|
156
|
+
const { install } = await import('@atproto/lex-installer')
|
|
157
|
+
await install({
|
|
158
|
+
add: argv.nsid,
|
|
159
|
+
save: argv.save,
|
|
160
|
+
ci: argv.ci,
|
|
161
|
+
update: argv.update,
|
|
162
|
+
lexicons: argv.lexicons,
|
|
163
|
+
manifest: argv.manifest,
|
|
164
|
+
})
|
|
165
|
+
},
|
|
166
|
+
)
|
|
167
|
+
.strictCommands()
|
|
168
|
+
.demandCommand(1)
|
|
169
|
+
.parseAsync()
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
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.
|
|
5
|
+
*
|
|
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:
|
|
35
|
+
*
|
|
36
|
+
* ### Primitive Types
|
|
37
|
+
* - {@link l.string | l.string()} - String values with optional format/length constraints
|
|
38
|
+
* - {@link l.integer | l.integer()} - Integer values with optional min/max constraints
|
|
39
|
+
* - {@link l.boolean | l.boolean()} - Boolean values
|
|
40
|
+
* - {@link l.bytes | l.bytes()} - Binary data (Uint8Array)
|
|
41
|
+
* - {@link l.cid | l.cid()} - Content Identifier values
|
|
42
|
+
* - {@link l.blob | l.blob()} - Blob references with mime type and size
|
|
43
|
+
*
|
|
44
|
+
* ### Composite Types
|
|
45
|
+
* - {@link l.object | l.object()} - Objects with defined property schemas
|
|
46
|
+
* - {@link l.array | l.array()} - Arrays with element type validation
|
|
47
|
+
* - {@link l.union | l.union()} - Union of multiple possible types
|
|
48
|
+
* - {@link l.ref | l.ref()} - Reference to another schema definition
|
|
49
|
+
* - {@link l.literal | l.literal()} - Literal constant values
|
|
50
|
+
* - {@link l.enum | l.enum()} - Enum of allowed string values
|
|
51
|
+
* - {@link l.typedRef | l.typedRef()} - Reference to a {@link l.typedObject | l.typedObject()}
|
|
52
|
+
* - {@link l.typedUnion | l.typedUnion()} - Discriminated union between multiple {@link l.typedRef | l.typedRef()} or {@link l.typedObject | l.typedObject()} types
|
|
53
|
+
*
|
|
54
|
+
* ### Modifiers
|
|
55
|
+
* - {@link l.optional | l.optional()} - Mark a property as optional
|
|
56
|
+
* - {@link l.nullable | l.nullable()} - Allow null values
|
|
57
|
+
* - {@link l.withDefault | l.withDefault()} - Provide a default value
|
|
58
|
+
*
|
|
59
|
+
* ### Lexicon Definitions
|
|
60
|
+
* - {@link l.typedObject | l.typedObject()} - Define a typed object with a `$type` property
|
|
61
|
+
* - {@link l.record | l.record()} - Define a Lexicon record type
|
|
62
|
+
* - {@link l.query | l.query()} - Define a Lexicon query method
|
|
63
|
+
* - {@link l.procedure | l.procedure()} - Define a Lexicon procedure method
|
|
64
|
+
* - {@link l.subscription | l.subscription()} - Define a Lexicon subscription method
|
|
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';
|
|
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';
|
|
110
|
+
export * from '@atproto/lex-json';
|
|
111
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
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.
|
|
5
|
+
*
|
|
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:
|
|
35
|
+
*
|
|
36
|
+
* ### Primitive Types
|
|
37
|
+
* - {@link l.string | l.string()} - String values with optional format/length constraints
|
|
38
|
+
* - {@link l.integer | l.integer()} - Integer values with optional min/max constraints
|
|
39
|
+
* - {@link l.boolean | l.boolean()} - Boolean values
|
|
40
|
+
* - {@link l.bytes | l.bytes()} - Binary data (Uint8Array)
|
|
41
|
+
* - {@link l.cid | l.cid()} - Content Identifier values
|
|
42
|
+
* - {@link l.blob | l.blob()} - Blob references with mime type and size
|
|
43
|
+
*
|
|
44
|
+
* ### Composite Types
|
|
45
|
+
* - {@link l.object | l.object()} - Objects with defined property schemas
|
|
46
|
+
* - {@link l.array | l.array()} - Arrays with element type validation
|
|
47
|
+
* - {@link l.union | l.union()} - Union of multiple possible types
|
|
48
|
+
* - {@link l.ref | l.ref()} - Reference to another schema definition
|
|
49
|
+
* - {@link l.literal | l.literal()} - Literal constant values
|
|
50
|
+
* - {@link l.enum | l.enum()} - Enum of allowed string values
|
|
51
|
+
* - {@link l.typedRef | l.typedRef()} - Reference to a {@link l.typedObject | l.typedObject()}
|
|
52
|
+
* - {@link l.typedUnion | l.typedUnion()} - Discriminated union between multiple {@link l.typedRef | l.typedRef()} or {@link l.typedObject | l.typedObject()} types
|
|
53
|
+
*
|
|
54
|
+
* ### Modifiers
|
|
55
|
+
* - {@link l.optional | l.optional()} - Mark a property as optional
|
|
56
|
+
* - {@link l.nullable | l.nullable()} - Allow null values
|
|
57
|
+
* - {@link l.withDefault | l.withDefault()} - Provide a default value
|
|
58
|
+
*
|
|
59
|
+
* ### Lexicon Definitions
|
|
60
|
+
* - {@link l.typedObject | l.typedObject()} - Define a typed object with a `$type` property
|
|
61
|
+
* - {@link l.record | l.record()} - Define a Lexicon record type
|
|
62
|
+
* - {@link l.query | l.query()} - Define a Lexicon query method
|
|
63
|
+
* - {@link l.procedure | l.procedure()} - Define a Lexicon procedure method
|
|
64
|
+
* - {@link l.subscription | l.subscription()} - Define a Lexicon subscription method
|
|
65
|
+
*/
|
|
66
|
+
l, } from '@atproto/lex-schema';
|
|
67
|
+
export * from '@atproto/lex-schema';
|
|
68
|
+
export {} from '@atproto/lex-data';
|
|
69
|
+
export * from '@atproto/lex-data';
|
|
70
|
+
export {
|
|
71
|
+
/**
|
|
72
|
+
* The `jsonToLex` function takes a plain JavaScript object (typically parsed from
|
|
73
|
+
* JSON) and converts it back into a LexValue, reconstructing any complex types as needed. This is useful
|
|
74
|
+
* for processing data received from the network or loaded from JSON storage.
|
|
75
|
+
*/
|
|
76
|
+
jsonToLex,
|
|
77
|
+
/**
|
|
78
|
+
* The `lexParse` function takes a JSON string and parses it into a LexValue. It
|
|
79
|
+
* performs the necessary conversions to reconstruct complex LexValue types from
|
|
80
|
+
* their JSON representations.
|
|
81
|
+
*/
|
|
82
|
+
lexParse,
|
|
83
|
+
/**
|
|
84
|
+
* The `lexStringify` function takes a LexValue and serializes it to a JSON string.
|
|
85
|
+
* It handles the conversion of complex LexValue types (like BlobRef and Cid) into
|
|
86
|
+
* a JSON-friendly format.
|
|
87
|
+
*/
|
|
88
|
+
lexStringify,
|
|
89
|
+
/**
|
|
90
|
+
* The `lexToJson` function converts a LexValue into a plain JavaScript object
|
|
91
|
+
* that can be safely serialized to JSON. This is useful for preparing data to be
|
|
92
|
+
* sent over the network or stored in a JSON format.
|
|
93
|
+
*/
|
|
94
|
+
lexToJson, } from '@atproto/lex-json';
|
|
95
|
+
export * from '@atproto/lex-json';
|
|
96
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atproto/lex",
|
|
3
|
+
"version": "0.0.0-spaces-alpha-20260818163953",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Lexicon tooling for AT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"atproto",
|
|
8
|
+
"lexicon",
|
|
9
|
+
"lex"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://atproto.com",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/bluesky-social/atproto",
|
|
15
|
+
"directory": "packages/lex/lex"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"./dist",
|
|
19
|
+
"./bin",
|
|
20
|
+
"./README.md",
|
|
21
|
+
"./CHANGELOG.md"
|
|
22
|
+
],
|
|
23
|
+
"bin": {
|
|
24
|
+
"ts-lex": "./bin/lex",
|
|
25
|
+
"lex": "./bin/lex"
|
|
26
|
+
},
|
|
27
|
+
"sideEffects": false,
|
|
28
|
+
"type": "module",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"default": "./dist/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=22"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"tslib": "^2.8.1",
|
|
40
|
+
"yargs": "^18.0.0",
|
|
41
|
+
"@atproto/lex-client": "^0.0.0-spaces-alpha-20260818163953",
|
|
42
|
+
"@atproto/lex-json": "^0.1.6",
|
|
43
|
+
"@atproto/lex-builder": "^0.0.0-spaces-alpha-20260818163953",
|
|
44
|
+
"@atproto/lex-schema": "^0.0.0-spaces-alpha-20260818163953",
|
|
45
|
+
"@atproto/lex-installer": "^0.0.0-spaces-alpha-20260818163953",
|
|
46
|
+
"@atproto/lex-data": "^0.1.7"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/yargs": "^17.0.33",
|
|
50
|
+
"vitest": "^4.1.10"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"codegen:lex": "./bin/lex build --override --indexFile --lexicons ./lexicons --out ./tests/lexicons --lib @atproto/lex-schema",
|
|
54
|
+
"prebuild": "pnpm run '/^(codegen:.+)$/'",
|
|
55
|
+
"build": "tsc --build tsconfig.build.json",
|
|
56
|
+
"test": "vitest run"
|
|
57
|
+
}
|
|
58
|
+
}
|