Skip to content

Commit

Permalink
docs: update tsdocs to reduce gaps (#13700)
Browse files Browse the repository at this point in the history
* Update TSDoc Comments
  • Loading branch information
jjarvisp authored Aug 19, 2024
1 parent a8f0747 commit 7c1ed91
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/api-rest/src/errors/CanceledError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export class CanceledError extends RestApiError {
*
* @note This function works **ONLY** for errors thrown by REST API. For GraphQL APIs, use `client.isCancelError(error)`
* instead. `client` is generated from `generateClient()` API from `aws-amplify/api`.
*
* @param {unknown} error The unknown exception to be checked.
* @returns - A boolean indicating if the error was from an upload cancellation
*/
export const isCancelError = (error: unknown): error is CanceledError =>
!!error && error instanceof CanceledError;
3 changes: 3 additions & 0 deletions packages/api/src/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { Amplify } from '@aws-amplify/core';

/**
* Generates an API client that can work with models or raw GraphQL
*
* @returns {@link V6Client}
* @throws {@link Error} - Throws error when client cannot be generated due to configuration issues.
*/
export function generateClient<T extends Record<any, any> = never>(
options: CommonPublicClientOptions = {},
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/singleton/Auth/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ export function assertIdentityPoolIdConfig(
);
}

/**
* Decodes payload of JWT token
*
* @param {String} token A string representing a token to be decoded
* @throws {@link Error} - Throws error when token is invalid or payload malformed.
*/
export function decodeJWT(token: string): JWT {
const tokenParts = token.split('.');

Expand Down
9 changes: 9 additions & 0 deletions packages/core/src/singleton/apis/fetchAuthSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ import { AuthSession, FetchAuthSessionOptions } from '../Auth/types';

import { fetchAuthSession as fetchAuthSessionInternal } from './internal/fetchAuthSession';

/**
* Fetch the auth session including the tokens and credentials if they are available. By default it
* does not refresh the auth tokens or credentials if they are loaded in storage already. You can force a refresh
* with `{ forceRefresh: true }` input.
*
* @param options - Options configuring the fetch behavior.
* @throws {@link AuthError} - Throws error when session information cannot be refreshed.
* @returns Promise<AuthSession>
*/
export const fetchAuthSession = (
options?: FetchAuthSessionOptions,
): Promise<AuthSession> => {
Expand Down
2 changes: 2 additions & 0 deletions packages/storage/src/errors/CanceledError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export class CanceledError extends StorageError {
/**
* Check if an error is caused by user calling `cancel()` on a upload/download task. If an overwriting error is
* supplied to `task.cancel(errorOverwrite)`, this function will return `false`.
* @param {unknown} error The unknown exception to be checked.
* @returns - A boolean indicating if the error was from an upload cancellation
*/
export const isCancelError = (error: unknown): error is CanceledError =>
!!error && error instanceof CanceledError;

0 comments on commit 7c1ed91

Please sign in to comment.