Skip to content

Commit

Permalink
docs: fix tsdoc annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberglot committed Oct 10, 2024
1 parent f79de60 commit afae094
Show file tree
Hide file tree
Showing 16 changed files with 125 additions and 138 deletions.
2 changes: 1 addition & 1 deletion packages/client-react-hooks/src/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import debug from "debug";

/**
* `Log` is a debug logger that can be used to log messages to the console.
* @param message: string
* @param message - string
*/
export const Log = debug("nillion:react-hooks");
46 changes: 22 additions & 24 deletions packages/client-react-hooks/src/nil-hook-base.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { UseMutationResult } from "@tanstack/react-query";

/**
* NilHookState is a set of states that a NilHook can be in:
* - Idle: waiting to receive a request
* - Loading: waiting for the request to complete
* - Success: the request was successful
* - Error: the request had an error
@enum
* `NilHookState` is a set of states that a NilHook can be in:
* - Idle: Waiting to receive a request
* - Loading: Waiting for the request to complete
* - Success: The request was successful
* - Error: The request had an error
*/
export const NilHookState = {
Idle: {
Expand Down Expand Up @@ -41,7 +40,6 @@ export const NilHookState = {

/**
* `UseNilHook` is a hook that allows you to execute a NilHook operation, and check its status.
* @type
*/
export type UseNilHook<ExecuteArgs, ExecuteResult> = NilHookBaseResult<
ExecuteArgs,
Expand Down Expand Up @@ -82,11 +80,11 @@ export interface NilHookIdleResult {

/**
* NilHookLoadingResult is a set of states that a NilHook can be in when it is loading.
* @property status - The status of the NilHook.
* @property isLoading - Whether the NilHook is loading.
* @property isSuccess - Whether the NilHook is successful.
* @property isError - Whether the NilHook has an error.
* @property isIdle - Whether the NilHook is idle.
* status - The status of the NilHook, namely "loading".
* isLoading - Whether the NilHook is loading.
* isSuccess - Whether the NilHook is successful.
* isError - Whether the NilHook has an error.
* isIdle - Whether the NilHook is idle.
*/
export interface NilHookLoadingResult {
status: "loading";
Expand All @@ -98,12 +96,12 @@ export interface NilHookLoadingResult {

/**
* NilHookSuccessResult is a set of states that a NilHook can be in when it is successful.
* @property status - The status of the NilHook.
* @property data - The data of the NilHook.
* @property isLoading - Whether the NilHook is loading.
* @property isSuccess - Whether the NilHook is successful.
* @property isError - Whether the NilHook has an error.
* @property isIdle - Whether the NilHook is idle.
* status - The status of the NilHook namely "success".
* data - The data of the NilHook.
* isLoading - Whether the NilHook is loading.
* isSuccess - Whether the NilHook is successful.
* isError - Whether the NilHook has an error.
* isIdle - Whether the NilHook is idle.
*/
export interface NilHookSuccessResult<R> {
status: "success";
Expand All @@ -116,12 +114,12 @@ export interface NilHookSuccessResult<R> {

/**
* NilHookErrorResult is a set of states that a NilHook can be in when it has an error.
* @property status - The status of the NilHook.
* @property error - The error of the NilHook.
* @property isLoading - Whether the NilHook is loading.
* @property isSuccess - Whether the NilHook is successful.
* @property isError - Whether the NilHook has an error.
* @property isIdle - Whether the NilHook is idle.
* status - The status of the NilHook namely "error".
* error - The error of the NilHook.
* isLoading - Whether the NilHook is loading.
* isSuccess - Whether the NilHook is successful.
* isError - Whether the NilHook has an error.
* isIdle - Whether the NilHook is idle.
*/
export interface NilHookErrorResult {
status: "error";
Expand Down
45 changes: 22 additions & 23 deletions packages/client-react-hooks/src/nillion-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,54 +25,53 @@ import { NetworkConfig, NillionClient } from "@nillion/client-vms";
import { Log } from "./logging";

/**
* WithConfigProps
* @property config is a ProviderNetworkConfig
* @property network is a NamedNetwork
* @property client is not allowed
* `WithConfigProps`
* `config` is a ProviderNetworkConfig
* `network` is a NamedNetwork
* `client` is not allowed
**/
export interface WithConfigProps {
interface WithConfigProps {
config?: ProviderNetworkConfig;
network?: NamedNetwork;
client?: never;
}

/**
* ProviderNetworkConfig
* @property bootnodes is an array of Multiaddr or string
* @property clusterId is a ClusterId or string
* @property nilChainId is a ChainId or string
* @property nilChainEndpoint is a Url or string
* `ProviderNetworkConfig`
* `bootnodes` is an array of Multiaddr or string
* `clusterId` is a ClusterId or string
* `nilChainId` is a ChainId or string
* `nilChainEndpoint` is a Url or string
*/
export interface ProviderNetworkConfig {
interface ProviderNetworkConfig {
bootnodes?: (Multiaddr | string)[];
clusterId?: ClusterId | string;
nilChainId?: ChainId | string;
nilChainEndpoint?: Url | string;
}

/**
* WithClientProps
* @property client is a NillionClient
* @property config is not allowed
* @property network is not allowed
* `WithClientProps`
* `client` is a `NillionClient`
* `config` is not allowed
* `network` is not allowed
*/
export interface WithClientProps {
interface WithClientProps {
client: NillionClient;
config?: never;
network?: never;
}

/**
* NillionProviderProps
* @type Alias for either WithConfigProps or WithClientProps
* `NillionProviderProps`
* Alias for either WithConfigProps or WithClientProps
*/
export type NillionProviderProps = WithConfigProps | WithClientProps;

/**
* NillionContext
* @property client is a NillionClient
* @property logout is a function that returns a Promise<void>
* @interface
* `NillionContext`
* `client` is a NillionClient
* `logout` is a function that returns a Promise<void>
*/
export interface NillionContext {
client: NillionClient;
Expand All @@ -92,7 +91,7 @@ const client = NillionClient.create();

/**
* NillionProvider
* @param NillionProviderProps & { children: ReactNode }
* @param NillionProviderProps - expects provider props or a `ReactNode`
* @returns ReactNode
*/
export const NillionProvider: React.FC<
Expand Down
5 changes: 2 additions & 3 deletions packages/client-react-hooks/src/use-nil-compute-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useNillion } from "./use-nillion";

/**
* `ExecuteArgs` is an interface that can be passed to the `execute` function.
* @param id: `ComputeOutputId` or `string`
* @param id - `ComputeOutputId` or `string`
*/
interface ExecuteArgs {
id: ComputeOutputId | string;
Expand All @@ -21,12 +21,11 @@ type ExecuteResult = Record<string, NadaPrimitiveValue>;
* @property executeAsync - It executes the NilHook asynchronously, allowing the usage of `async/await` or `.then()`.
* @type
*/
export type UseNilComputeOutput = UseNilHook<ExecuteArgs, ExecuteResult>;
type UseNilComputeOutput = UseNilHook<ExecuteArgs, ExecuteResult>;

/**
* `useNilComputeOutput` is a hook that allows you to execute a compute output.
* @returns {@link UseNilComputeOutput}
* @interface
*/
export const useNilComputeOutput = (): UseNilComputeOutput => {
const { client: nilClient } = useNillion();
Expand Down
14 changes: 7 additions & 7 deletions packages/client-react-hooks/src/use-nil-compute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { nilHookBaseResult, UseNilHook } from "./nil-hook-base";
import { useNillion } from "./use-nillion";

/** ExecuteArgs is an interface that can be passed to the `execute` function.
* @param bindings: `ProgramBindings`
* @param values?: `NadaValues`
* @param storeIds?: array of `StoreId`s or strings
* @param bindings - `ProgramBindings`
* @param values? - `NadaValues`
* @param storeIds? - array of `StoreId`s or strings
*/
export interface ExecuteArgs {
interface ExecuteArgs {
bindings: ProgramBindings;
values?: NadaValues;
storeIds?: (StoreId | string)[];
Expand All @@ -24,11 +24,11 @@ type ExecuteResult = ComputeOutputId;

/**
* `UseNilCompute` is a hook that allows you to execute a compute operation on Nillion.
* @property execute - It executes the NilHook synchronously, allowing the user to check for its status via {@link isSuccess} and {@link isError}.
* @property executeAsync - It executes the NilHook asynchronously, allowing the usage of `async/await` or `.then()`.
* execute - It executes the NilHook synchronously, allowing the user to check for its status via {@link isSuccess} and {@link isError}.
* executeAsync - It executes the NilHook asynchronously, allowing the usage of `async/await` or `.then()`.
* @type
*/
export type UseNilCompute = UseNilHook<ExecuteArgs, ExecuteResult>;
type UseNilCompute = UseNilHook<ExecuteArgs, ExecuteResult>;

/**
* `useNilCompute` is a hook that allows you to execute a compute.
Expand Down
11 changes: 5 additions & 6 deletions packages/client-react-hooks/src/use-nil-delete-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,20 @@ import { useNillion } from "./use-nillion";

/**
* `ExecuteArgs` is an interface that can be passed to the `execute` function
* @param id: `StoreId` or `string`
* @param id - `StoreId` or `string`
*/
export interface ExecuteArgs {
interface ExecuteArgs {
id: StoreId | string;
}

type ExecuteResult = StoreId;

/**
* `UseNilDeleteValue` is a hook that allows you to delete a value from a store.
* @property execute - It executes the NilHook synchronously, allowing the user to check for its status via {@link isSuccess} and {@link isError}.
* @property executeAsync - It executes the NilHook asynchronously, allowing the usage of `async/await` or `.then()`.
* @interface
* execute - It executes the NilHook synchronously, allowing the user to check for its status via {@link isSuccess} and {@link isError}.
* executeAsync - It executes the NilHook asynchronously, allowing the usage of `async/await` or `.then()`.
*/
export type UseNilDeleteValue = UseNilHook<ExecuteArgs, ExecuteResult>;
type UseNilDeleteValue = UseNilHook<ExecuteArgs, ExecuteResult>;

/**
* `useNilDeleteValue` is a hook that allows you to delete a value from a store.
Expand Down
12 changes: 5 additions & 7 deletions packages/client-react-hooks/src/use-nil-fetch-store-acl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,23 @@ import { useNillion } from "./use-nillion";

/**
* `ExecuteArgs` is an interface that can be passed to the `execute` function.
* @param id: `StoreId` or `string`
* @param id - `StoreId` or `string`
*/
export interface ExecuteArgs {
interface ExecuteArgs {
id: StoreId | string;
}
type ExecuteResult = StoreAcl;

/**
* `UseNilFetchStoreAcl` is a hook that allows you to fetch a store acl.
* @property execute executes the NilHook synchronously, allowing the user to check for its status via {@link isSuccess} and {@link isError}.
* @property executeAsync executes the NilHook asynchronously, allowing the usage of `async/await` or `.then()`.
* @interface
* execute - executes the NilHook synchronously, allowing the user to check for its status via {@link isSuccess} and {@link isError}.
* executeAsync - executes the NilHook asynchronously, allowing the usage of `async/await` or `.then()`.
*/
export type UseNilFetchStoreAcl = UseNilHook<ExecuteArgs, ExecuteResult>;
type UseNilFetchStoreAcl = UseNilHook<ExecuteArgs, ExecuteResult>;

/**
* `useNilFetchStoreAcl` is a hook that allows you to fetch a store acl.
* @returns {@link UseNilFetchStoreAcl}
* @interface
*/
export const useNilFetchStoreAcl = (): UseNilFetchStoreAcl => {
const { client } = useNillion();
Expand Down
19 changes: 9 additions & 10 deletions packages/client-react-hooks/src/use-nil-fetch-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,31 @@ import { useNillion } from "./use-nillion";

/**
* `Options` is an interface that can be passed to the `useNilFetchValue` hook.
* @param type: `NadaValueType`
* @param staleAfter?: `number`
* @param type - `NadaValueType`
* @param staleAfter? - `number`
*/
export interface Options {
interface Options {
type: NadaValueType;
staleAfter?: number;
}

/**
* `ExecuteArgs` is an interface that can be passed to the `execute` function.
* @param id: `StoreId` or `string`
* @param name: `NamedValue` or `string`
* @param id - `StoreId` or `string`
* @param name - `NamedValue` or `string`
*/
export interface ExecuteArgs {
interface ExecuteArgs {
id: StoreId | string;
name: NamedValue | string;
}
type ExecuteResult = NadaPrimitiveValue;

/**
* `UseNilFetchValue` is a hook that allows you to fetch a value from a store.
* @property execute - It executes the NilHook synchronously, allowing the user to check for its status via {@link isSuccess} and {@link isError}.
* @property executeAsync - It executes the NilHook asynchronously, allowing the usage of `async/await` or `.then()`.
* @interface
* execute - It executes the NilHook synchronously, allowing the user to check for its status via {@link isSuccess} and {@link isError}.
* executeAsync - It executes the NilHook asynchronously, allowing the usage of `async/await` or `.then()`.
*/
export type UseNilFetchValue = UseNilHook<ExecuteArgs, ExecuteResult>;
type UseNilFetchValue = UseNilHook<ExecuteArgs, ExecuteResult>;

/**
* `useNilFetchValue` is a hook that allows you to fetch a value from a store.
Expand Down
12 changes: 5 additions & 7 deletions packages/client-react-hooks/src/use-nil-set-store-acl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,19 @@ import { useNillion } from "./use-nillion";

/**
* `ExecuteArgs` is an interface that can be passed to the `execute` function.
* @param id: `StoreId` or `string`
* @param acl: `StoreAcl`
* @param id - `StoreId` or `string`
* @param acl - `StoreAcl`
*/
export interface ExecuteArgs {
interface ExecuteArgs {
id: StoreId | string;
acl: StoreAcl;
}
type ExecuteResult = ActionId;

/**
* `UseNilSetStoreAcl` is a hook that allows you to set a store acl.
* @property execute - It executes the NilHook synchronously, allowing the user to check for its status via {@link isSuccess} and {@link isError}.
* @property executeAsync - It executes the NilHook asynchronously, allowing the usage of `async/await` or `.then()`.
* @interface
* @notExported
* execute - It executes the NilHook synchronously, allowing the user to check for its status via {@link isSuccess} and {@link isError}.
* executeAsync - It executes the NilHook asynchronously, allowing the usage of `async/await` or `.then()`.
*/
type UseNilSetStoreAcl = UseNilHook<ExecuteArgs, ExecuteResult>;

Expand Down
6 changes: 3 additions & 3 deletions packages/client-react-hooks/src/use-nil-store-program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { useNillion } from "./use-nillion";

/**
* `ExecuteArgs` is an interface that can be passed to the `execute` function.
* @param name: `ProgramName` or `string`
* @param program: `Uint
* @param name - `ProgramName` or `string`
* @param program - `Uint
*/
export interface ExecuteArgs {
interface ExecuteArgs {
name: ProgramName | string;
program: Uint8Array;
}
Expand Down
10 changes: 5 additions & 5 deletions packages/client-react-hooks/src/use-nil-store-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import { nilHookBaseResult, UseNilHook } from "./nil-hook-base";
import { useNillion } from "./use-nillion";

/** `ExecuteArgs` is an interface that can be passed to the `execute` function
* @param name: `NamedValue` or `string`
* @param data: `NadaPrimitiveValue`
* @param ttl: `Days` or `number`
* @param acl?: `StoreAcl`
* @param name - `NamedValue` or `string`
* @param data - `NadaPrimitiveValue`
* @param ttl - `Days` or `number`
* @param acl? - `StoreAcl`
*/
export interface ExecuteArgs {
interface ExecuteArgs {
name: NamedValue | string;
data: NadaPrimitiveValue;
ttl: Days | number;
Expand Down
Loading

0 comments on commit afae094

Please sign in to comment.