Skip to content

Commit

Permalink
Fix typedoc warnings for API ref
Browse files Browse the repository at this point in the history
  • Loading branch information
jrodewig committed Oct 31, 2024
1 parent d4e2e33 commit e6f38e0
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 39 deletions.
4 changes: 2 additions & 2 deletions overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ docs](https://docs.fauna.com/fauna/current/build/drivers/js-client/).

## Important classes and methods

- [Client](classes/Client.html): Use instances of this class to send requests to Fauna.
- [query()](classes/Client.html#query): Use this method to run queries.
- {@link Client}: Use instances of this class to send requests to Fauna.
- {@link Client.query}: Use this method to run queries.

## All modules

Expand Down
2 changes: 1 addition & 1 deletion src/client-configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface ClientConfiguration {
client_timeout_buffer_ms?: number;

/**
* The {@link URL} of Fauna to call. See {@link endpoints} for some default options.
* The {@link https://developer.mozilla.org/en-US/docs/Web/API/URL|URL} of Fauna to call. See {@link endpoints} for some default options.
*/
endpoint?: URL;

Expand Down
10 changes: 4 additions & 6 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export class Client {
* Initialize a streaming request to Fauna
* @typeParam T - The expected type of the response from Fauna. T can be inferred
* if the provided query used a type parameter.
* @param query - A string-encoded streaming token, or a {@link Query}
* @param tokenOrQuery - A string-encoded token for an {@link EventSource}, or a {@link Query}
* @returns A {@link StreamClient} that which can be used to listen to a stream
* of events
*
Expand Down Expand Up @@ -383,7 +383,7 @@ export class Client {
* feed events.
* @typeParam T - The expected type of the response from Fauna. T can be inferred
* if the provided query used a type parameter.
* @param query - A string-encoded streaming token, or a {@link Query}
* @param tokenOrQuery - A string-encoded token for an {@link EventSource}, or a {@link Query}
* @returns A {@link FeedClient} that which can be used to listen to a feed
* of events
*
Expand Down Expand Up @@ -741,10 +741,8 @@ export class StreamClient<T extends QueryValue = any> {

/**
*
* @param query - A lambda that returns a promise for a {@link EventSource}
* @param token - A lambda that returns a promise for a {@link EventSource}
* @param clientConfiguration - The {@link ClientConfiguration} to apply
* @param httpStreamClient - The underlying {@link HTTPStreamClient} that will
* execute the actual HTTP calls
* @example
* ```typescript
* const streamClient = client.stream(eventSource);
Expand Down Expand Up @@ -958,7 +956,7 @@ export class FeedClient<T extends QueryValue = any> {

/**
*
* @param query - A lambda that returns a promise for a {@link EventSource}
* @param token - A lambda that returns a promise for a {@link EventSource}
* @param clientConfiguration - The {@link FeedClientConfiguration} to apply
* @example
* ```typescript
Expand Down
6 changes: 3 additions & 3 deletions src/http-client/node-http2-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ export class NodeHTTP2Client implements HTTPClient, HTTPStreamClient {
}

/**
* Gets a {@link NodeHTTP2Client} matching the {@link HTTTPClientOptions}
* @param httpClientOptions - the {@link HTTTPClientOptions}
* @returns a {@link NodeHTTP2Client} matching the {@link HTTTPClientOptions}
* Gets a {@link NodeHTTP2Client} matching the {@link HTTPClientOptions}
* @param httpClientOptions - the {@link HTTPClientOptions}
* @returns a {@link NodeHTTP2Client} matching the {@link HTTPClientOptions}
*/
static getClient(httpClientOptions: HTTPClientOptions): NodeHTTP2Client {
const clientKey = NodeHTTP2Client.#getClientKey(httpClientOptions);
Expand Down
49 changes: 42 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,60 @@ export {
ServiceInternalError,
ThrottlingError,
} from "./errors";
export { type Query, type QueryArgument, fql } from "./query-builder";
export { LONG_MAX, LONG_MIN, TaggedTypeFormat } from "./tagged-type";
export {
type QueryValueObject,
type QueryValue,
fql,
type Query,
type QueryArgument,
type QueryArgumentObject,
} from "./query-builder";
export {
DecodeOptions,
LONG_MAX,
LONG_MIN,
TaggedTypeFormat,
} from "./tagged-type";
export {
type ArrayFragment,
type ConstraintFailure,
type EncodedObject,
type FeedError,
type FeedRequest,
type FeedSuccess,
type FQLFragment,
type ObjectFragment,
type QueryFailure,
type QueryInfo,
type QueryInterpolation,
type QueryOptions,
type QueryRequest,
type QueryStats,
type QuerySuccess,
type QueryValue,
type QueryValueObject,
type Span,
type StreamEventData,
type StreamEventError,
type StreamEventStatus,
type StreamRequest,
type TaggedBytes,
type TaggedDate,
type TaggedDouble,
type TaggedInt,
type TaggedLong,
type TaggedMod,
type TaggedObject,
type TaggedRef,
type TaggedTime,
type TaggedType,
type ValueFormat,
type ValueFragment,
type FeedRequest,
type FeedSuccess,
type FeedError,
} from "./wire-protocol";
export {
DateStub,
Document,
DocumentReference,
EmbeddedSet,
FlattenedSetIterator,
Module,
NamedDocument,
NamedDocumentReference,
Expand All @@ -61,11 +92,15 @@ export {
type DocumentT,
} from "./values";
export {
FaunaAPIPaths,
FetchClient,
getDefaultHTTPClient,
HTTPClientOptions,
HTTPStreamRequest,
isHTTPResponse,
isStreamClient,
NodeHTTP2Client,
SupportedFaunaAPIPaths,
type HTTPClient,
type HTTPRequest,
type HTTPResponse,
Expand Down
2 changes: 1 addition & 1 deletion src/query-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type QueryArgument =
/**
* Creates a new Query. Accepts template literal inputs.
* @typeParam T - The expected type of the response from Fauna when evaluated.
* @param queryFragments - a {@link TemplateStringsArray} that constitute
* @param queryFragments - An array that constitutes
* the strings that are the basis of the query.
* @param queryArgs - an Array\<QueryValue | Query\> that
* constitute the arguments to inject between the queryFragments.
Expand Down
54 changes: 35 additions & 19 deletions src/values/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class SetIterator<T extends QueryValue>
constructor(
client: Client,
initial: Page<T> | EmbeddedSet | (() => Promise<T | Page<T> | EmbeddedSet>),
options?: QueryOptions
options?: QueryOptions,
) {
options = options ?? {};
if (initial instanceof Function) {
Expand All @@ -78,8 +78,8 @@ export class SetIterator<T extends QueryValue>
} else {
throw new TypeError(
`Expected 'Page<T> | EmbeddedSet | (() => Promise<T | Page<T> | EmbeddedSet>)', but received ${JSON.stringify(
initial
)}`
initial,
)}`,
);
}
}
Expand All @@ -93,18 +93,18 @@ export class SetIterator<T extends QueryValue>
static fromQuery<T extends QueryValue>(
client: Client,
query: Query,
options?: QueryOptions
options?: QueryOptions,
): SetIterator<T> {
return new SetIterator<T>(
client,
async () => {
const response = await client.query<T | Page<T> | EmbeddedSet>(
query,
options
options,
);
return response.data;
},
options
options,
);
}

Expand All @@ -118,7 +118,7 @@ export class SetIterator<T extends QueryValue>
static fromPageable<T extends QueryValue>(
client: Client,
pageable: Page<T> | EmbeddedSet,
options?: QueryOptions
options?: QueryOptions,
): SetIterator<T> {
return new SetIterator<T>(client, pageable, options);
}
Expand All @@ -132,22 +132,30 @@ export class SetIterator<T extends QueryValue>
return new FlattenedSetIterator(this);
}

/** Implement {@link AsyncGenerator.next} */
/** Implement
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator/next| AsyncGenerator.next}
* */
async next(): Promise<IteratorResult<T[], void>> {
return this.#generator.next();
}

/** Implement {@link AsyncGenerator.return} */
/** Implement
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator/return| AsyncGenerator.return}
* */
async return(): Promise<IteratorResult<T[], void>> {
return this.#generator.return();
}

/** Implement {@link AsyncGenerator.throw} */
/** Implement
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator/throw| AsyncGenerator.throw}
* */
async throw(e: any): Promise<IteratorResult<T[], void>> {
return this.#generator.throw(e);
}

/** Implement {@link AsyncGenerator} */
/** Implement
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator| AsyncGenerator}
* */
[Symbol.asyncIterator]() {
return this;
}
Expand Down Expand Up @@ -178,22 +186,30 @@ export class FlattenedSetIterator<T extends QueryValue>
this.#generator = generateItems(setIterator);
}

/** Implement {@link AsyncGenerator.next} */
/** Implement
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator/next| AsyncGenerator.next}
* */
async next(): Promise<IteratorResult<T, void>> {
return this.#generator.next();
}

/** Implement {@link AsyncGenerator.return} */
/** Implement
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator/return| AsyncGenerator.return}
* */
async return(): Promise<IteratorResult<T, void>> {
return this.#generator.return();
}

/** Implement {@link AsyncGenerator.throw} */
/** Implement
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator/throw| AsyncGenerator.throw}
* */
async throw(e: any): Promise<IteratorResult<T, void>> {
return this.#generator.throw(e);
}

/** Implement {@link AsyncGenerator} */
/** Implement
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator| AsyncGenerator}
* */
[Symbol.asyncIterator]() {
return this;
}
Expand All @@ -206,7 +222,7 @@ export class FlattenedSetIterator<T extends QueryValue>
async function* generatePages<T extends QueryValue>(
client: Client,
initial: Page<T> | EmbeddedSet,
options: QueryOptions
options: QueryOptions,
): AsyncGenerator<T[], void, unknown> {
let currentPage = initial;

Expand All @@ -233,15 +249,15 @@ async function* generatePages<T extends QueryValue>(
async function* generateFromThunk<T extends QueryValue>(
client: Client,
thunk: () => Promise<T | Page<T> | EmbeddedSet>,
options: QueryOptions
options: QueryOptions,
): AsyncGenerator<T[], void, unknown> {
const result = await thunk();

if (result instanceof Page || result instanceof EmbeddedSet) {
for await (const page of generatePages(
client,
result as Page<T> | EmbeddedSet,
options
options,
)) {
yield page;
}
Expand All @@ -255,7 +271,7 @@ async function* generateFromThunk<T extends QueryValue>(
* Internal async generator function that flattens a {@link SetIterator}
*/
async function* generateItems<T extends QueryValue>(
setIterator: SetIterator<T>
setIterator: SetIterator<T>,
) {
for await (const page of setIterator) {
for (const item of page) {
Expand Down

0 comments on commit e6f38e0

Please sign in to comment.