@lexd/stdlib-atproto 0.1.0
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/LICENSE +21 -0
- package/package.json +25 -0
- package/src/com.atproto.label.defs.lexd +45 -0
- package/src/com.atproto.repo.applyWrites.lexd +62 -0
- package/src/com.atproto.repo.createRecord.lexd +31 -0
- package/src/com.atproto.repo.defs.lexd +6 -0
- package/src/com.atproto.repo.getRecord.lexd +23 -0
- package/src/com.atproto.repo.listRecords.lexd +26 -0
- package/src/com.atproto.repo.strongRef.lexd +7 -0
- package/src/com.atproto.server.describeServer.lexd +26 -0
- package/src/com.atproto.sync.subscribeRepos.lexd +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Harvey Randall
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lexd/stdlib-atproto",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Curated com.atproto.* Lexicon DSL sources for lexd",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/harveyrandall/lexd.git",
|
|
9
|
+
"directory": "packages/stdlib-atproto"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"lexd": "src",
|
|
16
|
+
"files": [
|
|
17
|
+
"src"
|
|
18
|
+
],
|
|
19
|
+
"exports": {
|
|
20
|
+
"./package.json": "./package.json"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "node -e \"process.exit(0)\""
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
namespace com.atproto.label.defs {
|
|
2
|
+
@description("Metadata tag on an atproto resource (eg, repo or record).")
|
|
3
|
+
type label {
|
|
4
|
+
@description("The AT Protocol version of the label object.") ver?: integer
|
|
5
|
+
@description("DID of the actor who created this label.") @format("did") src: string
|
|
6
|
+
@description("AT URI of the record, repository (account), or other resource that this label applies to.") @format("uri") uri: string
|
|
7
|
+
@description("Optionally, CID specifying the specific version of 'uri' resource this label applies to.") @format("cid") cid?: string
|
|
8
|
+
@description("The short string name of the value or type of this label.") @maxLength(128) val: string
|
|
9
|
+
@description("If true, this is a negation label, overwriting a previous label.") neg?: boolean
|
|
10
|
+
@description("Timestamp when this label was created.") @format("datetime") cts: string
|
|
11
|
+
@description("Timestamp at which this label expires (no longer applies).") @format("datetime") exp?: string
|
|
12
|
+
@description("Signature of dag-cbor encoded label.") sig?: bytes
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@description("Metadata tags on an atproto record, published by the author within the record.")
|
|
16
|
+
type selfLabels {
|
|
17
|
+
@maxLength(10) values: selfLabel[]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@description("Metadata tag on an atproto record, published by the author within the record. Note that schemas should use #selfLabels, not #selfLabel.")
|
|
21
|
+
type selfLabel {
|
|
22
|
+
@description("The short string name of the value or type of this label.") @maxLength(128) val: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@description("Declares a label value and its expected interpretations and behaviors.")
|
|
26
|
+
type labelValueDefinition {
|
|
27
|
+
@description("The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+).") @maxGraphemes(100) @maxLength(100) identifier: string
|
|
28
|
+
@description("How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing.") @knownValues("inform", "alert", "none") severity: string
|
|
29
|
+
@description("What should this label hide in the UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; 'none' hides nothing.") @knownValues("content", "media", "none") blurs: string
|
|
30
|
+
@description("The default setting for this label.") @default("warn") @knownValues("ignore", "warn", "hide") defaultSetting?: string
|
|
31
|
+
@description("Does the user need to have adult content enabled in order to configure this label?") adultOnly?: boolean
|
|
32
|
+
locales: labelValueDefinitionStrings[]
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@description("Strings which describe the label in the UI, localized into a specific language.")
|
|
36
|
+
type labelValueDefinitionStrings {
|
|
37
|
+
@description("The code of the language these strings are written in.") @format("language") lang: string
|
|
38
|
+
@description("A short human-readable name for the label.") @maxGraphemes(64) @maxLength(640) name: string
|
|
39
|
+
@description("A longer description of what the label means and why it might be applied.") @maxGraphemes(10000) @maxLength(100000) description: string
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@scalar("string")
|
|
43
|
+
@knownValues("!hide", "!warn", "!no-unauthenticated", "porn", "sexual", "nudity", "graphic-media", "bot")
|
|
44
|
+
type labelValue {}
|
|
45
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { commitMeta } from "com.atproto.repo.defs"
|
|
2
|
+
|
|
3
|
+
namespace com.atproto.repo {
|
|
4
|
+
@procedure
|
|
5
|
+
@description("Apply a batch transaction of repository creates, updates, and deletes. Requires auth, implemented by PDS.")
|
|
6
|
+
type applyWrites {
|
|
7
|
+
input {
|
|
8
|
+
encoding: "application/json"
|
|
9
|
+
schema {
|
|
10
|
+
@description("The handle or DID of the repo (aka, current account).") @format("at-identifier") repo: string
|
|
11
|
+
@description("Can be set to 'false' to skip Lexicon schema validation of record data across all operations, 'true' to require it, or leave unset to validate only for known Lexicons.") validate?: boolean
|
|
12
|
+
writes: closed union(#create, #update, #delete)[]
|
|
13
|
+
@description("If provided, the entire operation will fail if the current repo commit CID does not match this value. Used to prevent conflicting repo mutations.") @format("cid") swapCommit?: string
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
output {
|
|
17
|
+
encoding: "application/json"
|
|
18
|
+
schema {
|
|
19
|
+
commit?: commitMeta
|
|
20
|
+
results?: closed union(#createResult, #updateResult, #deleteResult)[]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
errors {
|
|
24
|
+
InvalidSwap: "Indicates that the 'swapCommit' parameter did not match current commit."
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@description("Operation which creates a new record.")
|
|
29
|
+
type create {
|
|
30
|
+
@format("nsid") collection: string
|
|
31
|
+
@description("NOTE: maxLength is redundant with record-key format. Keeping it temporarily to ensure backwards compatibility.") @format("record-key") @maxLength(512) rkey?: string
|
|
32
|
+
value: unknown
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@description("Operation which updates an existing record.")
|
|
36
|
+
type update {
|
|
37
|
+
@format("nsid") collection: string
|
|
38
|
+
@format("record-key") rkey: string
|
|
39
|
+
value: unknown
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@description("Operation which deletes an existing record.")
|
|
43
|
+
type delete {
|
|
44
|
+
@format("nsid") collection: string
|
|
45
|
+
@format("record-key") rkey: string
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type createResult {
|
|
49
|
+
@format("at-uri") uri: string
|
|
50
|
+
@format("cid") cid: string
|
|
51
|
+
@knownValues("valid", "unknown") validationStatus?: string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
type updateResult {
|
|
55
|
+
@format("at-uri") uri: string
|
|
56
|
+
@format("cid") cid: string
|
|
57
|
+
@knownValues("valid", "unknown") validationStatus?: string
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
type deleteResult {
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { commitMeta } from "com.atproto.repo.defs"
|
|
2
|
+
|
|
3
|
+
namespace com.atproto.repo {
|
|
4
|
+
@procedure
|
|
5
|
+
@description("Create a single new repository record. Requires auth, implemented by PDS.")
|
|
6
|
+
type createRecord {
|
|
7
|
+
input {
|
|
8
|
+
encoding: "application/json"
|
|
9
|
+
schema {
|
|
10
|
+
@description("The handle or DID of the repo (aka, current account).") @format("at-identifier") repo: string
|
|
11
|
+
@description("The NSID of the record collection.") @format("nsid") collection: string
|
|
12
|
+
@description("The Record Key.") @format("record-key") @maxLength(512) rkey?: string
|
|
13
|
+
@description("Can be set to 'false' to skip Lexicon schema validation of record data, 'true' to require it, or leave unset to validate only for known Lexicons.") validate?: boolean
|
|
14
|
+
@description("The record itself. Must contain a $type field.") record: unknown
|
|
15
|
+
@description("Compare and swap with the previous commit by CID.") @format("cid") swapCommit?: string
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
output {
|
|
19
|
+
encoding: "application/json"
|
|
20
|
+
schema {
|
|
21
|
+
@format("at-uri") uri: string
|
|
22
|
+
@format("cid") cid: string
|
|
23
|
+
commit?: commitMeta
|
|
24
|
+
@knownValues("valid", "unknown") validationStatus?: string
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
errors {
|
|
28
|
+
InvalidSwap: "Indicates that 'swapCommit' didn't match current repo commit."
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
namespace com.atproto.repo {
|
|
2
|
+
@query
|
|
3
|
+
@description("Get a single record from a repository. Does not require auth.")
|
|
4
|
+
type getRecord {
|
|
5
|
+
params {
|
|
6
|
+
@description("The handle or DID of the repo.") @format("at-identifier") repo: string
|
|
7
|
+
@description("The NSID of the record collection.") @format("nsid") collection: string
|
|
8
|
+
@description("The Record Key.") @format("record-key") rkey: string
|
|
9
|
+
@description("The CID of the version of the record. If not specified, then return the most recent version.") @format("cid") cid?: string
|
|
10
|
+
}
|
|
11
|
+
output {
|
|
12
|
+
encoding: "application/json"
|
|
13
|
+
schema {
|
|
14
|
+
@format("at-uri") uri: string
|
|
15
|
+
@format("cid") cid?: string
|
|
16
|
+
value: unknown
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
errors {
|
|
20
|
+
RecordNotFound
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
namespace com.atproto.repo {
|
|
2
|
+
@query
|
|
3
|
+
@description("List a range of records in a repository, matching a specific collection. Does not require auth.")
|
|
4
|
+
type listRecords {
|
|
5
|
+
params {
|
|
6
|
+
@description("The handle or DID of the repo.") @format("at-identifier") repo: string
|
|
7
|
+
@description("The NSID of the record type.") @format("nsid") collection: string
|
|
8
|
+
@description("The number of records to return.") @minimum(1) @maximum(100) @default(50) limit?: integer
|
|
9
|
+
cursor?: string
|
|
10
|
+
@description("Flag to reverse the order of the returned records.") reverse?: boolean
|
|
11
|
+
}
|
|
12
|
+
output {
|
|
13
|
+
encoding: "application/json"
|
|
14
|
+
schema {
|
|
15
|
+
cursor?: string
|
|
16
|
+
records: record[]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type record {
|
|
22
|
+
@format("at-uri") uri: string
|
|
23
|
+
@format("cid") cid: string
|
|
24
|
+
value: unknown
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
namespace com.atproto.server {
|
|
2
|
+
@query
|
|
3
|
+
@description("Describes the server's account creation requirements and capabilities. Implemented by PDS.")
|
|
4
|
+
type describeServer {
|
|
5
|
+
output {
|
|
6
|
+
encoding: "application/json"
|
|
7
|
+
schema {
|
|
8
|
+
@description("If true, an invite code must be supplied to create an account on this instance.") inviteCodeRequired?: boolean
|
|
9
|
+
@description("If true, a phone verification token must be supplied to create an account on this instance.") phoneVerificationRequired?: boolean
|
|
10
|
+
@description("List of domain suffixes that can be used in account handles.") availableUserDomains: string[]
|
|
11
|
+
@description("URLs of service policy documents.") links?: links
|
|
12
|
+
@description("Contact information") contact?: contact
|
|
13
|
+
@format("did") did: string
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type links {
|
|
19
|
+
@format("uri") privacyPolicy?: string
|
|
20
|
+
@format("uri") termsOfService?: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type contact {
|
|
24
|
+
email?: string
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
namespace com.atproto.sync {
|
|
2
|
+
@subscription
|
|
3
|
+
@description("Repository event stream, aka Firehose endpoint. Outputs repo commits with diff data, and identity update events, for all repositories on the current server. See the atproto specifications for details around stream sequencing, repo versioning, CAR diff format, and more. Public and does not require auth; implemented by PDS and Relay.")
|
|
4
|
+
type subscribeRepos {
|
|
5
|
+
params {
|
|
6
|
+
@description("The last known event seq number to backfill from.") cursor?: integer
|
|
7
|
+
}
|
|
8
|
+
message {
|
|
9
|
+
schema: union(#commit, #sync, #identity, #account, #info)
|
|
10
|
+
}
|
|
11
|
+
errors {
|
|
12
|
+
FutureCursor
|
|
13
|
+
ConsumerTooSlow: "If the consumer of the stream can not keep up with events, and a backlog gets too large, the server will drop the connection."
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@description("Represents an update of repository state. Note that empty commits are allowed, which include no repo data changes, but an update to rev and signature.")
|
|
18
|
+
type commit {
|
|
19
|
+
@description("The stream sequence number of this message.") seq: integer
|
|
20
|
+
@description("DEPRECATED -- unused") rebase: boolean
|
|
21
|
+
@description("DEPRECATED -- replaced by #sync event and data limits. Indicates that this commit contained too many ops, or data size was too large. Consumers will need to make a separate request to get missing data.") tooBig: boolean
|
|
22
|
+
@description("The repo this event comes from. Note that all other message types name this field 'did'.") @format("did") repo: string
|
|
23
|
+
@description("Repo commit object CID.") commit: cid-link
|
|
24
|
+
@description("The rev of the emitted commit. Note that this information is also in the commit object included in blocks, unless this is a tooBig event.") @format("tid") rev: string
|
|
25
|
+
@description("The rev of the last emitted commit from this repo (if any).") @format("tid") @nullable since: string
|
|
26
|
+
@description("CAR file containing relevant blocks, as a diff since the previous repo state. The commit must be included as a block, and the commit block CID must be the first entry in the CAR header 'roots' list.") @maxLength(2000000) blocks: bytes
|
|
27
|
+
@maxLength(200) ops: repoOp[]
|
|
28
|
+
blobs: cid-link[]
|
|
29
|
+
@description("The root CID of the MST tree for the previous commit from this repo (indicated by the 'since' revision field in this message). Corresponds to the 'data' field in the repo commit object. NOTE: this field is effectively required for the 'inductive' version of firehose.") prevData?: cid-link
|
|
30
|
+
@description("Timestamp of when this message was originally broadcast.") @format("datetime") time: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@description("Updates the repo to a new state, without necessarily including that state on the firehose. Used to recover from broken commit streams, data loss incidents, or in situations where upstream host does not know recent state of the repository.")
|
|
34
|
+
type sync {
|
|
35
|
+
@description("The stream sequence number of this message.") seq: integer
|
|
36
|
+
@description("The account this repo event corresponds to. Must match that in the commit object.") @format("did") did: string
|
|
37
|
+
@description("CAR file containing the commit, as a block. The CAR header must include the commit block CID as the first 'root'.") @maxLength(10000) blocks: bytes
|
|
38
|
+
@description("The rev of the commit. This value must match that in the commit object.") rev: string
|
|
39
|
+
@description("Timestamp of when this message was originally broadcast.") @format("datetime") time: string
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@description("Represents a change to an account's identity. Could be an updated handle, signing key, or pds hosting endpoint. Serves as a prod to all downstream services to refresh their identity cache.")
|
|
43
|
+
type identity {
|
|
44
|
+
seq: integer
|
|
45
|
+
@format("did") did: string
|
|
46
|
+
@format("datetime") time: string
|
|
47
|
+
@description("The current handle for the account, or 'handle.invalid' if validation fails. This field is optional, might have been validated or passed-through from an upstream source. Semantics and behaviors for PDS vs Relay may evolve in the future; see atproto specs for more details.") @format("handle") handle?: string
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@description("Represents a change to an account's status on a host (eg, PDS or Relay). The semantics of this event are that the status is at the host which emitted the event, not necessarily that at the currently active PDS. Eg, a Relay takedown would emit a takedown with active=false, even if the PDS is still active.")
|
|
51
|
+
type account {
|
|
52
|
+
seq: integer
|
|
53
|
+
@format("did") did: string
|
|
54
|
+
@format("datetime") time: string
|
|
55
|
+
@description("Indicates that the account has a repository which can be fetched from the host that emitted this event.") active: boolean
|
|
56
|
+
@description("If active=false, this optional field indicates a reason for why the account is not active.") @knownValues("takendown", "suspended", "deleted", "deactivated", "desynchronized", "throttled") status?: string
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
type info {
|
|
60
|
+
@knownValues("OutdatedCursor") name: string
|
|
61
|
+
message?: string
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@description("A repo operation, ie a mutation of a single record.")
|
|
65
|
+
type repoOp {
|
|
66
|
+
@knownValues("create", "update", "delete") action: string
|
|
67
|
+
path: string
|
|
68
|
+
@description("For creates and updates, the new record CID. For deletions, null.") @nullable cid: cid-link
|
|
69
|
+
@description("For updates and deletes, the previous record CID (required for inductive firehose). For creations, field should not be defined.") prev?: cid-link
|
|
70
|
+
}
|
|
71
|
+
}
|