Skip to content

Commit

Permalink
Update TSDoc Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jjarvisp committed Aug 8, 2024
1 parent 6ecb364 commit e82f6bd
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/analytics/src/apis/disable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ import { disableAnalytics } from '../utils';
* @note
* When Analytics is disabled events will not be buffered or transmitted to your selected service. Any auto-tracking
* behavior that you have configured via `configureAutoTrack` will not have any effect while Analytics is disabled.
* @note Does not throw an exception.
*/
export const disable = disableAnalytics;
1 change: 1 addition & 0 deletions packages/analytics/src/apis/enable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ import { enableAnalytics } from '../utils';
*
* @note
* Analytics is enabled by default. You do not need to call this API unless you have disabled Analytics.
* @note Does not throw an exception.
*/
export const enable = enableAnalytics;
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const logger = new ConsoleLogger('Analytics');
* @note
* This API will make a best-effort attempt to flush events from the buffer. Events recorded immediately after invoking
* this API may not be included in the flush.
* @note Does not throw an exception on failure.
*/
export const flushEvents = () => {
const { appId, region, bufferSize, flushSize, flushInterval, resendLimit } =
Expand Down
4 changes: 4 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,10 @@ 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`.
*
* @note Does not throw an exception.
* @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 tokens, and the temporary AWS credentials and identity if they are configured. 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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { dispatchEvent } from './dispatchEvent';
*
* @remarks
* Make sure to call this early in your app at the root entry point after configuring Amplify.
* @note Does not throw an exception.
* @example
* ```ts
* Amplify.configure(config);
Expand Down
3 changes: 3 additions & 0 deletions packages/storage/src/errors/CanceledError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ 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`.
* @note Does not throw an exception.
* @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 e82f6bd

Please sign in to comment.