Commit 2035a96a authored by Robert Knight's avatar Robert Knight

Add types to references to `AuthService`

This found an error in some of the existing types in the `api` service.
parent 78c7f624
......@@ -53,7 +53,7 @@ function authStateFromProfile(profile) {
/**
* @typedef HypothesisAppProps
* @prop {Object} auth
* @prop {import('../services/auth').AuthService} auth
* @prop {Bridge} bridge
* @prop {ServiceUrlGetter} serviceUrl
* @prop {MergedConfig} settings
......
......@@ -66,7 +66,7 @@ function stripInternalProperties(obj) {
* Configuration for an API method.
*
* @typedef {Object} APIMethodOptions
* @prop {() => Promise<string>} getAccessToken -
* @prop {() => Promise<string|null>} getAccessToken -
* Function which acquires a valid access token for making an API request.
* @prop {() => string|null} getClientId -
* Function that returns a per-session client ID to include with the request
......@@ -75,9 +75,6 @@ function stripInternalProperties(obj) {
* @prop {() => any} onRequestFinished - Callback invoked when the API request finishes.
*/
// istanbul ignore next
const noop = () => null;
function get(object, path) {
let cursor = object;
path.split('.').forEach(segment => {
......@@ -92,18 +89,13 @@ function get(object, path) {
* @param links - Object or promise for an object mapping named API routes to
* URL templates and methods
* @param route - The dotted path of the named API route (eg. `annotation.create`)
* @param [APIMethodOptions] - Configuration for the API method
* @param {APIMethodOptions} options - Configuration for the API method
* @return {APICallFunction}
*/
function createAPICall(
links,
route,
{
getAccessToken = noop,
getClientId = noop,
onRequestStarted = noop,
onRequestFinished = noop,
} = {}
{ getAccessToken, getClientId, onRequestStarted, onRequestFinished }
) {
return function (params, data, options = {}) {
onRequestStarted();
......@@ -204,6 +196,7 @@ function createAPICall(
* not use authentication.
*
* @param {import('./api-routes').APIRoutesService} apiRoutes
* @param {import('./auth').AuthService} auth
*/
// @inject
export default function api(apiRoutes, auth, store) {
......
......@@ -22,6 +22,7 @@ const DEFAULT_ORGANIZATION = {
/**
* @param {import('./toast-messenger').ToastMessengerService} toastMessenger
* @param {import('./auth').AuthService} auth
*/
// @inject
export default function groups(
......
......@@ -12,6 +12,8 @@ const CACHE_TTL = 5 * 60 * 1000; // 5 minutes
*
* Access to the current profile is exposed via the `state` property.
*
* @param {import('../store').SidebarStore} store
* @param {import('./auth').AuthService} auth
* @param {import('./toast-messenger').ToastMessengerService} toastMessenger
* @inject
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment