@@ -16,11 +16,19 @@ import type {
1616
1717/**
1818 * Extracts the short name of a resource.
19+ * @param {string } url The resource URL.
20+ * @param {string } entrypointUrl The API entrypoint URL.
21+ * @returns {string } The short name of the resource.
1922 */
2023function guessNameFromUrl ( url : string , entrypointUrl : string ) : string {
2124 return url . slice ( entrypointUrl . length + 1 ) ;
2225}
2326
27+ /**
28+ * Gets the title or label from an ExpandedOperation object.
29+ * @param {ExpandedOperation } obj The operation object.
30+ * @returns {string } The title or label.
31+ */
2432function getTitleOrLabel ( obj : ExpandedOperation ) : string {
2533 const a =
2634 obj [ "http://www.w3.org/2000/01/rdf-schema#label" ] ??
@@ -36,6 +44,9 @@ function getTitleOrLabel(obj: ExpandedOperation): string {
3644
3745/**
3846 * Finds the description of the class with the given id.
47+ * @param {ExpandedDoc[] } docs The expanded documentation array.
48+ * @param {string } classToFind The class ID to find.
49+ * @returns {ExpandedClass } The matching expanded class.
3950 */
4051function findSupportedClass (
4152 docs : ExpandedDoc [ ] ,
@@ -87,6 +98,9 @@ export function getDocumentationUrlFromHeaders(headers: Headers): string {
8798
8899/**
89100 * Retrieves Hydra's entrypoint and API docs.
101+ * @param {string } entrypointUrl The URL of the API entrypoint.
102+ * @param {RequestInitExtended } [options] Optional fetch options.
103+ * @returns {Promise<{ entrypointUrl: string; docsUrl: string; response: Response; entrypoint: Entrypoint[]; docs: ExpandedDoc[]; }> } An object containing entrypointUrl, docsUrl, response, entrypoint, and docs.
90104 */
91105async function fetchEntrypointAndDocs (
92106 entrypointUrl : string ,
@@ -98,6 +112,11 @@ async function fetchEntrypointAndDocs(
98112 entrypoint : Entrypoint [ ] ;
99113 docs : ExpandedDoc [ ] ;
100114} > {
115+ /**
116+ * Loads a JSON-LD document from the given input.
117+ * @param {string } input The URL or IRI to load.
118+ * @returns {Promise<any> } The fetched JSON-LD response.
119+ */
101120 async function documentLoader ( input : string ) {
102121 const response = await fetchJsonLd ( input , options ) ;
103122 if ( ! ( "body" in response ) ) {
@@ -154,6 +173,12 @@ async function fetchEntrypointAndDocs(
154173 }
155174}
156175
176+ /**
177+ * Finds the related class for a property.
178+ * @param {ExpandedDoc[] } docs The expanded documentation array.
179+ * @param {ExpandedRdfProperty } property The property to find the related class for.
180+ * @returns {ExpandedClass } The related expanded class.
181+ */
157182function findRelatedClass (
158183 docs : ExpandedDoc [ ] ,
159184 property : ExpandedRdfProperty ,
@@ -213,6 +238,9 @@ function findRelatedClass(
213238
214239/**
215240 * Parses Hydra documentation and converts it to an intermediate representation.
241+ * @param {string } entrypointUrl The API entrypoint URL.
242+ * @param {RequestInitExtended } [options] Optional fetch options.
243+ * @returns {Promise<{ api: Api; response: Response; status: number; }> } The parsed API, response, and status.
216244 */
217245export default async function parseHydraDocumentation (
218246 entrypointUrl : string ,
@@ -470,8 +498,12 @@ export default async function parseHydraDocumentation(
470498 } ) ;
471499
472500 resource . parameters = [ ] ;
473- resource . getParameters = ( ) : Promise < Parameter [ ] > =>
474- getParameters ( resource , options ) ;
501+ resource . getParameters =
502+ /**
503+ * Gets the parameters for the resource.
504+ * @returns {Promise<Parameter[]> } The parameters for the resource.
505+ */
506+ ( ) : Promise < Parameter [ ] > => getParameters ( resource , options ) ;
475507
476508 resources . push ( resource ) ;
477509 }
0 commit comments