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