diff --git a/.gitignore b/.gitignore index a9af2af..f14290f 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ node_modules/ dist/ tsp-output/ generated/ -lexicons/ *.tsbuildinfo # Test outputs diff --git a/packages/cli/package.json b/packages/cli/package.json index 8d31480..f867f3f 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@typelex/cli", - "version": "0.2.7", + "version": "0.2.8", "main": "dist/index.js", "type": "module", "bin": { diff --git a/packages/cli/src/commands/compile.ts b/packages/cli/src/commands/compile.ts index 0613541..5afefe0 100644 --- a/packages/cli/src/commands/compile.ts +++ b/packages/cli/src/commands/compile.ts @@ -33,13 +33,17 @@ export async function compileCommand( // Compile TypeSpec using the TypeSpec CLI const entrypoint = resolve(cwd, "typelex/main.tsp"); + + // Normalize path for TypeSpec (remove leading ./) + const normalizedOutDir = outDir.replace(/^\.\//, ''); + const args = [ "compile", entrypoint, "--emit", "@typelex/emitter", "--option", - `@typelex/emitter.emitter-output-dir={project-root}/${outDir}`, + `@typelex/emitter.emitter-output-dir={project-root}/${normalizedOutDir}`, ]; if (options.watch) { diff --git a/packages/example/.gitignore b/packages/example/.gitignore index c451bf6..f848eee 100644 --- a/packages/example/.gitignore +++ b/packages/example/.gitignore @@ -1,13 +1,6 @@ # Dependencies node_modules/ -# Generated lexicons -lexicon/ - -# TypeSpec output (if using default config) -tsp-output/ -generated/ - # OS .DS_Store diff --git a/packages/example/lexicons/app/bsky/actor/defs.json b/packages/example/lexicons/app/bsky/actor/defs.json new file mode 100644 index 0000000..b2ce1f5 --- /dev/null +++ b/packages/example/lexicons/app/bsky/actor/defs.json @@ -0,0 +1,31 @@ +{ + "lexicon": 1, + "id": "app.bsky.actor.defs", + "defs": { + "profileView": { + "type": "object", + "required": ["did", "handle"], + "properties": { + "did": { "type": "string", "format": "did" }, + "handle": { "type": "string", "format": "handle" }, + "displayName": { + "type": "string", + "maxGraphemes": 64, + "maxLength": 640 + }, + "description": { + "type": "string", + "maxGraphemes": 256, + "maxLength": 2560 + }, + "avatar": { "type": "string", "format": "uri" }, + "indexedAt": { "type": "string", "format": "datetime" }, + "createdAt": { "type": "string", "format": "datetime" }, + "labels": { + "type": "array", + "items": { "type": "ref", "ref": "com.atproto.label.defs#label" } + } + } + } + } +} diff --git a/packages/example/lexicons/app/bsky/actor/profile.json b/packages/example/lexicons/app/bsky/actor/profile.json new file mode 100644 index 0000000..911d7a0 --- /dev/null +++ b/packages/example/lexicons/app/bsky/actor/profile.json @@ -0,0 +1,53 @@ +{ + "lexicon": 1, + "id": "app.bsky.actor.profile", + "defs": { + "main": { + "type": "record", + "description": "A declaration of a Bluesky account profile.", + "key": "literal:self", + "record": { + "type": "object", + "properties": { + "displayName": { + "type": "string", + "maxGraphemes": 64, + "maxLength": 640 + }, + "description": { + "type": "string", + "description": "Free-form profile description text.", + "maxGraphemes": 256, + "maxLength": 2560 + }, + "avatar": { + "type": "blob", + "description": "Small image to be displayed next to posts from account. AKA, 'profile picture'", + "accept": ["image/png", "image/jpeg"], + "maxSize": 1000000 + }, + "banner": { + "type": "blob", + "description": "Larger horizontal image to display behind profile view.", + "accept": ["image/png", "image/jpeg"], + "maxSize": 1000000 + }, + "labels": { + "type": "union", + "description": "Self-label values, specific to the Bluesky application, on the overall account.", + "refs": ["com.atproto.label.defs#selfLabels"] + }, + "joinedViaStarterPack": { + "type": "ref", + "ref": "com.atproto.repo.strongRef" + }, + "pinnedPost": { + "type": "ref", + "ref": "com.atproto.repo.strongRef" + }, + "createdAt": { "type": "string", "format": "datetime" } + } + } + } + } +} diff --git a/packages/example/lexicons/com/atproto/label/defs.json b/packages/example/lexicons/com/atproto/label/defs.json new file mode 100644 index 0000000..6f4c1ab --- /dev/null +++ b/packages/example/lexicons/com/atproto/label/defs.json @@ -0,0 +1,156 @@ +{ + "lexicon": 1, + "id": "com.atproto.label.defs", + "defs": { + "label": { + "type": "object", + "description": "Metadata tag on an atproto resource (eg, repo or record).", + "required": ["src", "uri", "val", "cts"], + "properties": { + "ver": { + "type": "integer", + "description": "The AT Protocol version of the label object." + }, + "src": { + "type": "string", + "format": "did", + "description": "DID of the actor who created this label." + }, + "uri": { + "type": "string", + "format": "uri", + "description": "AT URI of the record, repository (account), or other resource that this label applies to." + }, + "cid": { + "type": "string", + "format": "cid", + "description": "Optionally, CID specifying the specific version of 'uri' resource this label applies to." + }, + "val": { + "type": "string", + "maxLength": 128, + "description": "The short string name of the value or type of this label." + }, + "neg": { + "type": "boolean", + "description": "If true, this is a negation label, overwriting a previous label." + }, + "cts": { + "type": "string", + "format": "datetime", + "description": "Timestamp when this label was created." + }, + "exp": { + "type": "string", + "format": "datetime", + "description": "Timestamp at which this label expires (no longer applies)." + }, + "sig": { + "type": "bytes", + "description": "Signature of dag-cbor encoded label." + } + } + }, + "selfLabels": { + "type": "object", + "description": "Metadata tags on an atproto record, published by the author within the record.", + "required": ["values"], + "properties": { + "values": { + "type": "array", + "items": { "type": "ref", "ref": "#selfLabel" }, + "maxLength": 10 + } + } + }, + "selfLabel": { + "type": "object", + "description": "Metadata tag on an atproto record, published by the author within the record. Note that schemas should use #selfLabels, not #selfLabel.", + "required": ["val"], + "properties": { + "val": { + "type": "string", + "maxLength": 128, + "description": "The short string name of the value or type of this label." + } + } + }, + "labelValueDefinition": { + "type": "object", + "description": "Declares a label value and its expected interpretations and behaviors.", + "required": ["identifier", "severity", "blurs", "locales"], + "properties": { + "identifier": { + "type": "string", + "description": "The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+).", + "maxLength": 100, + "maxGraphemes": 100 + }, + "severity": { + "type": "string", + "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"] + }, + "blurs": { + "type": "string", + "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"] + }, + "defaultSetting": { + "type": "string", + "description": "The default setting for this label.", + "knownValues": ["ignore", "warn", "hide"], + "default": "warn" + }, + "adultOnly": { + "type": "boolean", + "description": "Does the user need to have adult content enabled in order to configure this label?" + }, + "locales": { + "type": "array", + "items": { "type": "ref", "ref": "#labelValueDefinitionStrings" } + } + } + }, + "labelValueDefinitionStrings": { + "type": "object", + "description": "Strings which describe the label in the UI, localized into a specific language.", + "required": ["lang", "name", "description"], + "properties": { + "lang": { + "type": "string", + "description": "The code of the language these strings are written in.", + "format": "language" + }, + "name": { + "type": "string", + "description": "A short human-readable name for the label.", + "maxGraphemes": 64, + "maxLength": 640 + }, + "description": { + "type": "string", + "description": "A longer description of what the label means and why it might be applied.", + "maxGraphemes": 10000, + "maxLength": 100000 + } + } + }, + "labelValue": { + "type": "string", + "knownValues": [ + "!hide", + "!no-promote", + "!warn", + "!no-unauthenticated", + "dmca-violation", + "doxxing", + "porn", + "sexual", + "nudity", + "nsfl", + "gore" + ] + } + } +} diff --git a/packages/example/lexicons/com/atproto/repo/applyWrites.json b/packages/example/lexicons/com/atproto/repo/applyWrites.json new file mode 100644 index 0000000..11a1f1f --- /dev/null +++ b/packages/example/lexicons/com/atproto/repo/applyWrites.json @@ -0,0 +1,131 @@ +{ + "lexicon": 1, + "id": "com.atproto.repo.applyWrites", + "defs": { + "main": { + "type": "procedure", + "description": "Apply a batch transaction of repository creates, updates, and deletes. Requires auth, implemented by PDS.", + "input": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["repo", "writes"], + "properties": { + "repo": { + "type": "string", + "format": "at-identifier", + "description": "The handle or DID of the repo (aka, current account)." + }, + "validate": { + "type": "boolean", + "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." + }, + "writes": { + "type": "array", + "items": { + "type": "union", + "refs": ["#create", "#update", "#delete"], + "closed": true + } + }, + "swapCommit": { + "type": "string", + "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" + } + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": [], + "properties": { + "commit": { + "type": "ref", + "ref": "com.atproto.repo.defs#commitMeta" + }, + "results": { + "type": "array", + "items": { + "type": "union", + "refs": ["#createResult", "#updateResult", "#deleteResult"], + "closed": true + } + } + } + } + }, + "errors": [ + { + "name": "InvalidSwap", + "description": "Indicates that the 'swapCommit' parameter did not match current commit." + } + ] + }, + "create": { + "type": "object", + "description": "Operation which creates a new record.", + "required": ["collection", "value"], + "properties": { + "collection": { "type": "string", "format": "nsid" }, + "rkey": { + "type": "string", + "maxLength": 512, + "format": "record-key", + "description": "NOTE: maxLength is redundant with record-key format. Keeping it temporarily to ensure backwards compatibility." + }, + "value": { "type": "unknown" } + } + }, + "update": { + "type": "object", + "description": "Operation which updates an existing record.", + "required": ["collection", "rkey", "value"], + "properties": { + "collection": { "type": "string", "format": "nsid" }, + "rkey": { "type": "string", "format": "record-key" }, + "value": { "type": "unknown" } + } + }, + "delete": { + "type": "object", + "description": "Operation which deletes an existing record.", + "required": ["collection", "rkey"], + "properties": { + "collection": { "type": "string", "format": "nsid" }, + "rkey": { "type": "string", "format": "record-key" } + } + }, + "createResult": { + "type": "object", + "required": ["uri", "cid"], + "properties": { + "uri": { "type": "string", "format": "at-uri" }, + "cid": { "type": "string", "format": "cid" }, + "validationStatus": { + "type": "string", + "knownValues": ["valid", "unknown"] + } + } + }, + "updateResult": { + "type": "object", + "required": ["uri", "cid"], + "properties": { + "uri": { "type": "string", "format": "at-uri" }, + "cid": { "type": "string", "format": "cid" }, + "validationStatus": { + "type": "string", + "knownValues": ["valid", "unknown"] + } + } + }, + "deleteResult": { + "type": "object", + "required": [], + "properties": {} + } + } +} diff --git a/packages/example/lexicons/com/atproto/repo/createRecord.json b/packages/example/lexicons/com/atproto/repo/createRecord.json new file mode 100644 index 0000000..de5f408 --- /dev/null +++ b/packages/example/lexicons/com/atproto/repo/createRecord.json @@ -0,0 +1,73 @@ +{ + "lexicon": 1, + "id": "com.atproto.repo.createRecord", + "defs": { + "main": { + "type": "procedure", + "description": "Create a single new repository record. Requires auth, implemented by PDS.", + "input": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["repo", "collection", "record"], + "properties": { + "repo": { + "type": "string", + "format": "at-identifier", + "description": "The handle or DID of the repo (aka, current account)." + }, + "collection": { + "type": "string", + "format": "nsid", + "description": "The NSID of the record collection." + }, + "rkey": { + "type": "string", + "format": "record-key", + "description": "The Record Key.", + "maxLength": 512 + }, + "validate": { + "type": "boolean", + "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." + }, + "record": { + "type": "unknown", + "description": "The record itself. Must contain a $type field." + }, + "swapCommit": { + "type": "string", + "format": "cid", + "description": "Compare and swap with the previous commit by CID." + } + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["uri", "cid"], + "properties": { + "uri": { "type": "string", "format": "at-uri" }, + "cid": { "type": "string", "format": "cid" }, + "commit": { + "type": "ref", + "ref": "com.atproto.repo.defs#commitMeta" + }, + "validationStatus": { + "type": "string", + "knownValues": ["valid", "unknown"] + } + } + } + }, + "errors": [ + { + "name": "InvalidSwap", + "description": "Indicates that 'swapCommit' didn't match current repo commit." + } + ] + } + } +} diff --git a/packages/example/lexicons/com/atproto/repo/defs.json b/packages/example/lexicons/com/atproto/repo/defs.json new file mode 100644 index 0000000..8752599 --- /dev/null +++ b/packages/example/lexicons/com/atproto/repo/defs.json @@ -0,0 +1,14 @@ +{ + "lexicon": 1, + "id": "com.atproto.repo.defs", + "defs": { + "commitMeta": { + "type": "object", + "required": ["cid", "rev"], + "properties": { + "cid": { "type": "string", "format": "cid" }, + "rev": { "type": "string", "format": "tid" } + } + } + } +} diff --git a/packages/example/lexicons/com/atproto/repo/deleteRecord.json b/packages/example/lexicons/com/atproto/repo/deleteRecord.json new file mode 100644 index 0000000..9831da1 --- /dev/null +++ b/packages/example/lexicons/com/atproto/repo/deleteRecord.json @@ -0,0 +1,57 @@ +{ + "lexicon": 1, + "id": "com.atproto.repo.deleteRecord", + "defs": { + "main": { + "type": "procedure", + "description": "Delete a repository record, or ensure it doesn't exist. Requires auth, implemented by PDS.", + "input": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["repo", "collection", "rkey"], + "properties": { + "repo": { + "type": "string", + "format": "at-identifier", + "description": "The handle or DID of the repo (aka, current account)." + }, + "collection": { + "type": "string", + "format": "nsid", + "description": "The NSID of the record collection." + }, + "rkey": { + "type": "string", + "format": "record-key", + "description": "The Record Key." + }, + "swapRecord": { + "type": "string", + "format": "cid", + "description": "Compare and swap with the previous record by CID." + }, + "swapCommit": { + "type": "string", + "format": "cid", + "description": "Compare and swap with the previous commit by CID." + } + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "properties": { + "commit": { + "type": "ref", + "ref": "com.atproto.repo.defs#commitMeta" + } + } + } + }, + "errors": [{ "name": "InvalidSwap" }] + } + } +} diff --git a/packages/example/lexicons/com/atproto/repo/describeRepo.json b/packages/example/lexicons/com/atproto/repo/describeRepo.json new file mode 100644 index 0000000..b1ce2b6 --- /dev/null +++ b/packages/example/lexicons/com/atproto/repo/describeRepo.json @@ -0,0 +1,51 @@ +{ + "lexicon": 1, + "id": "com.atproto.repo.describeRepo", + "defs": { + "main": { + "type": "query", + "description": "Get information about an account and repository, including the list of collections. Does not require auth.", + "parameters": { + "type": "params", + "required": ["repo"], + "properties": { + "repo": { + "type": "string", + "format": "at-identifier", + "description": "The handle or DID of the repo." + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": [ + "handle", + "did", + "didDoc", + "collections", + "handleIsCorrect" + ], + "properties": { + "handle": { "type": "string", "format": "handle" }, + "did": { "type": "string", "format": "did" }, + "didDoc": { + "type": "unknown", + "description": "The complete DID document for this account." + }, + "collections": { + "type": "array", + "description": "List of all the collections (NSIDs) for which this repo contains at least one record.", + "items": { "type": "string", "format": "nsid" } + }, + "handleIsCorrect": { + "type": "boolean", + "description": "Indicates if handle is currently valid (resolves bi-directionally)" + } + } + } + } + } + } +} diff --git a/packages/example/lexicons/com/atproto/repo/getRecord.json b/packages/example/lexicons/com/atproto/repo/getRecord.json new file mode 100644 index 0000000..388b9c5 --- /dev/null +++ b/packages/example/lexicons/com/atproto/repo/getRecord.json @@ -0,0 +1,49 @@ +{ + "lexicon": 1, + "id": "com.atproto.repo.getRecord", + "defs": { + "main": { + "type": "query", + "description": "Get a single record from a repository. Does not require auth.", + "parameters": { + "type": "params", + "required": ["repo", "collection", "rkey"], + "properties": { + "repo": { + "type": "string", + "format": "at-identifier", + "description": "The handle or DID of the repo." + }, + "collection": { + "type": "string", + "format": "nsid", + "description": "The NSID of the record collection." + }, + "rkey": { + "type": "string", + "description": "The Record Key.", + "format": "record-key" + }, + "cid": { + "type": "string", + "format": "cid", + "description": "The CID of the version of the record. If not specified, then return the most recent version." + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["uri", "value"], + "properties": { + "uri": { "type": "string", "format": "at-uri" }, + "cid": { "type": "string", "format": "cid" }, + "value": { "type": "unknown" } + } + } + }, + "errors": [{ "name": "RecordNotFound" }] + } + } +} diff --git a/packages/example/lexicons/com/atproto/repo/importRepo.json b/packages/example/lexicons/com/atproto/repo/importRepo.json new file mode 100644 index 0000000..fc850b1 --- /dev/null +++ b/packages/example/lexicons/com/atproto/repo/importRepo.json @@ -0,0 +1,13 @@ +{ + "lexicon": 1, + "id": "com.atproto.repo.importRepo", + "defs": { + "main": { + "type": "procedure", + "description": "Import a repo in the form of a CAR file. Requires Content-Length HTTP header to be set.", + "input": { + "encoding": "application/vnd.ipld.car" + } + } + } +} diff --git a/packages/example/lexicons/com/atproto/repo/listMissingBlobs.json b/packages/example/lexicons/com/atproto/repo/listMissingBlobs.json new file mode 100644 index 0000000..c39913d --- /dev/null +++ b/packages/example/lexicons/com/atproto/repo/listMissingBlobs.json @@ -0,0 +1,44 @@ +{ + "lexicon": 1, + "id": "com.atproto.repo.listMissingBlobs", + "defs": { + "main": { + "type": "query", + "description": "Returns a list of missing blobs for the requesting account. Intended to be used in the account migration flow.", + "parameters": { + "type": "params", + "properties": { + "limit": { + "type": "integer", + "minimum": 1, + "maximum": 1000, + "default": 500 + }, + "cursor": { "type": "string" } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["blobs"], + "properties": { + "cursor": { "type": "string" }, + "blobs": { + "type": "array", + "items": { "type": "ref", "ref": "#recordBlob" } + } + } + } + } + }, + "recordBlob": { + "type": "object", + "required": ["cid", "recordUri"], + "properties": { + "cid": { "type": "string", "format": "cid" }, + "recordUri": { "type": "string", "format": "at-uri" } + } + } + } +} diff --git a/packages/example/lexicons/com/atproto/repo/listRecords.json b/packages/example/lexicons/com/atproto/repo/listRecords.json new file mode 100644 index 0000000..bc91c95 --- /dev/null +++ b/packages/example/lexicons/com/atproto/repo/listRecords.json @@ -0,0 +1,69 @@ +{ + "lexicon": 1, + "id": "com.atproto.repo.listRecords", + "defs": { + "main": { + "type": "query", + "description": "List a range of records in a repository, matching a specific collection. Does not require auth.", + "parameters": { + "type": "params", + "required": ["repo", "collection"], + "properties": { + "repo": { + "type": "string", + "format": "at-identifier", + "description": "The handle or DID of the repo." + }, + "collection": { + "type": "string", + "format": "nsid", + "description": "The NSID of the record type." + }, + "limit": { + "type": "integer", + "minimum": 1, + "maximum": 100, + "default": 50, + "description": "The number of records to return." + }, + "cursor": { "type": "string" }, + "rkeyStart": { + "type": "string", + "description": "DEPRECATED: The lowest sort-ordered rkey to start from (exclusive)" + }, + "rkeyEnd": { + "type": "string", + "description": "DEPRECATED: The highest sort-ordered rkey to stop at (exclusive)" + }, + "reverse": { + "type": "boolean", + "description": "Flag to reverse the order of the returned records." + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["records"], + "properties": { + "cursor": { "type": "string" }, + "records": { + "type": "array", + "items": { "type": "ref", "ref": "#record" } + } + } + } + } + }, + "record": { + "type": "object", + "required": ["uri", "cid", "value"], + "properties": { + "uri": { "type": "string", "format": "at-uri" }, + "cid": { "type": "string", "format": "cid" }, + "value": { "type": "unknown" } + } + } + } +} diff --git a/packages/example/lexicons/com/atproto/repo/putRecord.json b/packages/example/lexicons/com/atproto/repo/putRecord.json new file mode 100644 index 0000000..830fade --- /dev/null +++ b/packages/example/lexicons/com/atproto/repo/putRecord.json @@ -0,0 +1,74 @@ +{ + "lexicon": 1, + "id": "com.atproto.repo.putRecord", + "defs": { + "main": { + "type": "procedure", + "description": "Write a repository record, creating or updating it as needed. Requires auth, implemented by PDS.", + "input": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["repo", "collection", "rkey", "record"], + "nullable": ["swapRecord"], + "properties": { + "repo": { + "type": "string", + "format": "at-identifier", + "description": "The handle or DID of the repo (aka, current account)." + }, + "collection": { + "type": "string", + "format": "nsid", + "description": "The NSID of the record collection." + }, + "rkey": { + "type": "string", + "format": "record-key", + "description": "The Record Key.", + "maxLength": 512 + }, + "validate": { + "type": "boolean", + "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." + }, + "record": { + "type": "unknown", + "description": "The record to write." + }, + "swapRecord": { + "type": "string", + "format": "cid", + "description": "Compare and swap with the previous record by CID. WARNING: nullable and optional field; may cause problems with golang implementation" + }, + "swapCommit": { + "type": "string", + "format": "cid", + "description": "Compare and swap with the previous commit by CID." + } + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["uri", "cid"], + "properties": { + "uri": { "type": "string", "format": "at-uri" }, + "cid": { "type": "string", "format": "cid" }, + "commit": { + "type": "ref", + "ref": "com.atproto.repo.defs#commitMeta" + }, + "validationStatus": { + "type": "string", + "knownValues": ["valid", "unknown"] + } + } + } + }, + "errors": [{ "name": "InvalidSwap" }] + } + } +} diff --git a/packages/example/lexicons/com/atproto/repo/strongRef.json b/packages/example/lexicons/com/atproto/repo/strongRef.json new file mode 100644 index 0000000..cb79625 --- /dev/null +++ b/packages/example/lexicons/com/atproto/repo/strongRef.json @@ -0,0 +1,15 @@ +{ + "lexicon": 1, + "id": "com.atproto.repo.strongRef", + "description": "A URI with a content-hash fingerprint.", + "defs": { + "main": { + "type": "object", + "required": ["uri", "cid"], + "properties": { + "uri": { "type": "string", "format": "at-uri" }, + "cid": { "type": "string", "format": "cid" } + } + } + } +} diff --git a/packages/example/lexicons/com/atproto/repo/uploadBlob.json b/packages/example/lexicons/com/atproto/repo/uploadBlob.json new file mode 100644 index 0000000..547a995 --- /dev/null +++ b/packages/example/lexicons/com/atproto/repo/uploadBlob.json @@ -0,0 +1,23 @@ +{ + "lexicon": 1, + "id": "com.atproto.repo.uploadBlob", + "defs": { + "main": { + "type": "procedure", + "description": "Upload a new blob, to be referenced from a repository record. The blob will be deleted if it is not referenced within a time window (eg, minutes). Blob restrictions (mimetype, size, etc) are enforced when the reference is created. Requires auth, implemented by PDS.", + "input": { + "encoding": "*/*" + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["blob"], + "properties": { + "blob": { "type": "blob" } + } + } + } + } + } +} diff --git a/packages/example/lexicons/xyz/statusphere/defs.json b/packages/example/lexicons/xyz/statusphere/defs.json new file mode 100644 index 0000000..1bf88eb --- /dev/null +++ b/packages/example/lexicons/xyz/statusphere/defs.json @@ -0,0 +1,52 @@ +{ + "lexicon": 1, + "id": "xyz.statusphere.defs", + "defs": { + "statusView": { + "type": "object", + "properties": { + "uri": { + "type": "string", + "format": "at-uri" + }, + "status": { + "type": "string", + "maxLength": 32, + "minLength": 1, + "maxGraphemes": 1 + }, + "createdAt": { + "type": "string", + "format": "datetime" + }, + "profile": { + "type": "ref", + "ref": "#profileView" + } + }, + "required": [ + "uri", + "status", + "createdAt", + "profile" + ] + }, + "profileView": { + "type": "object", + "properties": { + "did": { + "type": "string", + "format": "did" + }, + "handle": { + "type": "string", + "format": "handle" + } + }, + "required": [ + "did", + "handle" + ] + } + } +} diff --git a/packages/example/lexicons/xyz/statusphere/getStatuses.json b/packages/example/lexicons/xyz/statusphere/getStatuses.json new file mode 100644 index 0000000..589240d --- /dev/null +++ b/packages/example/lexicons/xyz/statusphere/getStatuses.json @@ -0,0 +1,39 @@ +{ + "lexicon": 1, + "id": "xyz.statusphere.getStatuses", + "defs": { + "main": { + "type": "query", + "description": "Get a list of the most recent statuses on the network.", + "parameters": { + "type": "params", + "properties": { + "limit": { + "type": "integer", + "minimum": 1, + "maximum": 100, + "default": 50 + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "properties": { + "statuses": { + "type": "array", + "items": { + "type": "ref", + "ref": "xyz.statusphere.defs#statusView" + } + } + }, + "required": [ + "statuses" + ] + } + } + } + } +} diff --git a/packages/example/lexicons/xyz/statusphere/getUser.json b/packages/example/lexicons/xyz/statusphere/getUser.json new file mode 100644 index 0000000..1439ce6 --- /dev/null +++ b/packages/example/lexicons/xyz/statusphere/getUser.json @@ -0,0 +1,29 @@ +{ + "lexicon": 1, + "id": "xyz.statusphere.getUser", + "defs": { + "main": { + "type": "query", + "description": "Get the current user's profile and status.", + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "properties": { + "profile": { + "type": "ref", + "ref": "app.bsky.actor.defs#profileView" + }, + "status": { + "type": "ref", + "ref": "xyz.statusphere.defs#statusView" + } + }, + "required": [ + "profile" + ] + } + } + } + } +} diff --git a/packages/example/lexicons/xyz/statusphere/sendStatus.json b/packages/example/lexicons/xyz/statusphere/sendStatus.json new file mode 100644 index 0000000..0ff4315 --- /dev/null +++ b/packages/example/lexicons/xyz/statusphere/sendStatus.json @@ -0,0 +1,42 @@ +{ + "lexicon": 1, + "id": "xyz.statusphere.sendStatus", + "defs": { + "main": { + "type": "procedure", + "description": "Send a status into the ATmosphere.", + "input": { + "encoding": "application/json", + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "maxLength": 32, + "minLength": 1, + "maxGraphemes": 1 + } + }, + "required": [ + "status" + ] + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "properties": { + "status": { + "type": "ref", + "ref": "xyz.statusphere.defs#statusView" + } + }, + "required": [ + "status" + ] + } + } + } + } +} diff --git a/packages/example/lexicons/xyz/statusphere/status.json b/packages/example/lexicons/xyz/statusphere/status.json new file mode 100644 index 0000000..fcec80d --- /dev/null +++ b/packages/example/lexicons/xyz/statusphere/status.json @@ -0,0 +1,29 @@ +{ + "lexicon": 1, + "id": "xyz.statusphere.status", + "defs": { + "main": { + "type": "record", + "key": "tid", + "record": { + "type": "object", + "properties": { + "status": { + "type": "string", + "maxLength": 32, + "minLength": 1, + "maxGraphemes": 1 + }, + "createdAt": { + "type": "string", + "format": "datetime" + } + }, + "required": [ + "status", + "createdAt" + ] + } + } + } +} diff --git a/packages/example/typelex/externals.tsp b/packages/example/typelex/externals.tsp index 1ddeac3..e25e47d 100644 --- a/packages/example/typelex/externals.tsp +++ b/packages/example/typelex/externals.tsp @@ -5,32 +5,7 @@ import "@typelex/emitter"; @external namespace app.bsky.actor.defs { - model AdultContentPref { } - model BskyAppProgressGuide { } - model BskyAppStatePref { } - model ContentLabelPref { } - model FeedViewPref { } - model HiddenPostsPref { } - model InterestsPref { } - model KnownFollowers { } - model LabelerPrefItem { } - model LabelersPref { } - model MutedWord { } - model MutedWordsPref { } - model MutedWordTarget { } - model Nux { } - model PersonalDetailsPref { } - model PostInteractionSettingsPref { } - model ProfileAssociated { } - model ProfileAssociatedChat { } model ProfileView { } - model ProfileViewBasic { } - model ProfileViewDetailed { } - model SavedFeed { } - model SavedFeedsPref { } - model SavedFeedsPrefV2 { } - model ThreadViewPref { } - model ViewerState { } } @external @@ -38,134 +13,6 @@ namespace app.bsky.actor.profile { model Main { } } -@external -namespace app.bsky.embed.defs { - model AspectRatio { } -} - -@external -namespace app.bsky.embed.external { - model External { } - model Main { } - model View { } - model ViewExternal { } -} - -@external -namespace app.bsky.embed.images { - model Image { } - model Main { } - model View { } - model ViewImage { } -} - -@external -namespace app.bsky.embed.`record` { - model Main { } - model View { } - model ViewBlocked { } - model ViewDetached { } - model ViewNotFound { } - model ViewRecord { } -} - -@external -namespace app.bsky.embed.recordWithMedia { - model Main { } - model View { } -} - -@external -namespace app.bsky.embed.video { - model Caption { } - model Main { } - model View { } -} - -@external -namespace app.bsky.feed.defs { - model BlockedAuthor { } - model BlockedPost { } - @token model ClickthroughAuthor { } - @token model ClickthroughEmbed { } - @token model ClickthroughItem { } - @token model ClickthroughReposter { } - @token model ContentModeUnspecified { } - @token model ContentModeVideo { } - model FeedViewPost { } - model GeneratorView { } - model GeneratorViewerState { } - model Interaction { } - @token model InteractionLike { } - @token model InteractionQuote { } - @token model InteractionReply { } - @token model InteractionRepost { } - @token model InteractionSeen { } - @token model InteractionShare { } - model NotFoundPost { } - model PostView { } - model ReasonPin { } - model ReasonRepost { } - model ReplyRef { } - @token model RequestLess { } - @token model RequestMore { } - model SkeletonFeedPost { } - model SkeletonReasonPin { } - model SkeletonReasonRepost { } - model ThreadContext { } - model ThreadgateView { } - model ThreadViewPost { } - model ViewerState { } -} - -@external -namespace app.bsky.feed.postgate { - model DisableRule { } - model Main { } -} - -@external -namespace app.bsky.feed.threadgate { - model FollowerRule { } - model FollowingRule { } - model ListRule { } - model Main { } - model MentionRule { } -} - -@external -namespace app.bsky.graph.defs { - @token model Curatelist { } - model ListItemView { } - model ListPurpose { } - model ListView { } - model ListViewBasic { } - model ListViewerState { } - @token model Modlist { } - model NotFoundActor { } - @token model Referencelist { } - model Relationship { } - model StarterPackView { } - model StarterPackViewBasic { } -} - -@external -namespace app.bsky.labeler.defs { - model LabelerPolicies { } - model LabelerView { } - model LabelerViewDetailed { } - model LabelerViewerState { } -} - -@external -namespace app.bsky.richtext.facet { - model ByteSlice { } - model Link { } - model Main { } - model Mention { } - model Tag { } -} - @external namespace com.atproto.label.defs { model Label { }