From a7db1e651dbb5910ac618362a5c339a372b700c4 Mon Sep 17 00:00:00 2001 From: Camila Belo Date: Wed, 13 Mar 2024 12:36:23 +0100 Subject: [PATCH] docs: update api reports Signed-off-by: Camila Belo --- plugins/auth-react/api-report.md | 54 +++++++++++++++++++ .../CookieAuthRefreshProvider.tsx | 5 ++ .../useCookieAuthRefresh.tsx | 6 +++ plugins/auth-react/src/index.ts | 1 + plugins/auth-react/src/types.ts | 4 ++ 5 files changed, 70 insertions(+) create mode 100644 plugins/auth-react/api-report.md diff --git a/plugins/auth-react/api-report.md b/plugins/auth-react/api-report.md new file mode 100644 index 0000000000..f329673996 --- /dev/null +++ b/plugins/auth-react/api-report.md @@ -0,0 +1,54 @@ +## API Report File for "@backstage/plugin-auth-react" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { ApiRef } from '@backstage/core-plugin-api'; +import { AsyncState } from '@react-hookz/web'; +import { default as React_2 } from 'react'; +import { ReactNode } from 'react'; +import { UseAsyncActions } from '@react-hookz/web'; + +// @public +export type AuthApi = { + getCookie(): Promise<{ + expiresAt: string; + }>; +}; + +// @public +export function CookieAuthRefreshProvider({ + apiRef, + children, +}: { + apiRef: ApiRef; + children: ReactNode; +}): + | string + | number + | boolean + | Iterable + | React_2.JSX.Element + | null + | undefined; + +// @public +export function useCookieAuthRefresh({ + apiRef, +}: { + apiRef: ApiRef; +}): { + state: AsyncState< + | { + expiresAt: string; + } + | undefined + >; + actions: UseAsyncActions< + { + expiresAt: string; + }, + [] + >; +}; +``` diff --git a/plugins/auth-react/src/components/CookieAuthRefreshProvider/CookieAuthRefreshProvider.tsx b/plugins/auth-react/src/components/CookieAuthRefreshProvider/CookieAuthRefreshProvider.tsx index 941717f1e1..86fa5a3a6f 100644 --- a/plugins/auth-react/src/components/CookieAuthRefreshProvider/CookieAuthRefreshProvider.tsx +++ b/plugins/auth-react/src/components/CookieAuthRefreshProvider/CookieAuthRefreshProvider.tsx @@ -21,6 +21,11 @@ import { Button } from '@material-ui/core'; import { useCookieAuthRefresh } from '../../hooks'; import { AuthApi } from '../../types'; +/** + * @public + * A provider that will refresh the cookie when it is about to expire. + * It receives an `apiRef` and `children` as props, and expects that apiRef extends the `AuthApi` interface. + */ export function CookieAuthRefreshProvider({ apiRef, children, diff --git a/plugins/auth-react/src/hooks/useCookieAuthRefresh/useCookieAuthRefresh.tsx b/plugins/auth-react/src/hooks/useCookieAuthRefresh/useCookieAuthRefresh.tsx index 7888fa7e81..5c3272d056 100644 --- a/plugins/auth-react/src/hooks/useCookieAuthRefresh/useCookieAuthRefresh.tsx +++ b/plugins/auth-react/src/hooks/useCookieAuthRefresh/useCookieAuthRefresh.tsx @@ -26,6 +26,12 @@ type CookieAuthRefreshMessage = MessageEvent<{ }; }>; +/** + * @public + * It receives an `apiRef` as options, and expects that apiRef extends the `AuthApi` interface. + * @remarks + * This hook expects a `BroadcastChannel` to be available in the global scope. + */ export function useCookieAuthRefresh({ apiRef, }: { diff --git a/plugins/auth-react/src/index.ts b/plugins/auth-react/src/index.ts index 30ac7cfe72..2569454bf3 100644 --- a/plugins/auth-react/src/index.ts +++ b/plugins/auth-react/src/index.ts @@ -25,3 +25,4 @@ export * from './components'; export * from './hooks'; +export * from './types'; diff --git a/plugins/auth-react/src/types.ts b/plugins/auth-react/src/types.ts index b8c74cec8e..dd5eadfdee 100644 --- a/plugins/auth-react/src/types.ts +++ b/plugins/auth-react/src/types.ts @@ -14,4 +14,8 @@ * limitations under the License. */ +/** + * @public + * Defines a minimal inteface for auth apis. + */ export type AuthApi = { getCookie(): Promise<{ expiresAt: string }> };