diff --git a/lex-gen/builder/def-builder.ts b/lex-gen/builder/def-builder.ts index 8594880..3287b6d 100644 --- a/lex-gen/builder/def-builder.ts +++ b/lex-gen/builder/def-builder.ts @@ -348,7 +348,7 @@ export class LexDefBuilder { type: `{ ${properties.join(";")} }`, schemaType: (ref) => `l.TypedObjectSchema, l.Validator>>`, - schema: async (ref) => + schema: (ref) => this.pure( `l.typedObject<${ref.typeName}>($nsid, ${ JSON.stringify(hash) @@ -391,7 +391,7 @@ export class LexDefBuilder { validationUtils, }: { type?: string | ((ref: ResolvedRef) => string); - schema?: string | ((ref: ResolvedRef) => Promise); + schema?: string | ((ref: ResolvedRef) => Promise | string); schemaType?: string | ((ref: ResolvedRef) => string); objectUtils?: boolean; validationUtils?: boolean; diff --git a/lex-gen/tests/method-generation_test.ts b/lex-gen/tests/method-generation_test.ts index 1511041..fb78a60 100644 --- a/lex-gen/tests/method-generation_test.ts +++ b/lex-gen/tests/method-generation_test.ts @@ -14,7 +14,7 @@ class DummyIndexer implements LexiconIndexer, AsyncIterable { this.#docs = new Map(docs.map((doc) => [doc.id, doc])); } - async get(id: string): Promise { + get(id: string): LexiconDocument { const doc = this.#docs.get(id); if (!doc) { throw new Error(`Document not found: ${id}`); diff --git a/lex/document/indexer.ts b/lex/document/indexer.ts index 2814372..76b2c4a 100644 --- a/lex/document/indexer.ts +++ b/lex/document/indexer.ts @@ -1,13 +1,12 @@ import type { LexiconDocument } from "./lexicon.ts"; export interface LexiconIndexer { - get(nsid: string): Promise; + get(nsid: string): Promise | LexiconDocument; [Symbol.asyncDispose]?: () => Promise; [Symbol.asyncIterator]?: () => AsyncIterator; } -export class LexiconIterableIndexer - implements LexiconIndexer, AsyncDisposable { +export class LexiconIterableIndexer implements LexiconIndexer, AsyncDisposable { readonly #lexicons: Map = new Map(); readonly #iterator: | AsyncIterator @@ -18,10 +17,9 @@ export class LexiconIterableIndexer | AsyncIterable | Iterable, ) { - this.#iterator = - Symbol.asyncIterator in source - ? source[Symbol.asyncIterator]() - : source[Symbol.iterator](); + this.#iterator = Symbol.asyncIterator in source + ? source[Symbol.asyncIterator]() + : source[Symbol.iterator](); } async get(id: string): Promise { diff --git a/xrpc/client.ts b/xrpc/client.ts index dcc978a..3d61b45 100644 --- a/xrpc/client.ts +++ b/xrpc/client.ts @@ -20,6 +20,7 @@ import { httpResponseBodyParse, isErrorResponseBody, } from "./util.ts"; +import type { DidString } from "../lex/core/string-format.ts"; type XrpcMethod = Query | Procedure; @@ -38,7 +39,7 @@ export class XrpcClient { this.fetchHandler = this.agent.fetchHandler; } - get did() { + get did(): DidString | undefined { return this.agent.did; }