Skip to content

Commit 85c86de

Browse files
committed
chore: add jsdoc comments to utils
1 parent a30e0d1 commit 85c86de

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

client/src/utils/jsonUtils.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,22 @@ export type DataType =
6363
| "array"
6464
| "null";
6565

66+
/**
67+
* Determines the specific data type of a JSON value
68+
* @param value The JSON value to analyze
69+
* @returns The specific data type including "array" and "null" as distinct types
70+
*/
6671
export function getDataType(value: JsonValue): DataType {
6772
if (Array.isArray(value)) return "array";
6873
if (value === null) return "null";
6974
return typeof value;
7075
}
7176

77+
/**
78+
* Attempts to parse a string as JSON, only for objects and arrays
79+
* @param str The string to parse
80+
* @returns Object with success boolean and either parsed data or original string
81+
*/
7282
export function tryParseJson(str: string): {
7383
success: boolean;
7484
data: JsonValue;

client/src/utils/oauthUtils.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ type CallbackParams =
2424
error_uri: string | null;
2525
};
2626

27+
/**
28+
* Parses OAuth 2.1 callback parameters from a URL search string
29+
* @param location The URL search string (e.g., "?code=abc123" or "?error=access_denied")
30+
* @returns Parsed callback parameters with success/error information
31+
*/
2732
export const parseOAuthCallbackParams = (location: string): CallbackParams => {
2833
const params = new URLSearchParams(location);
2934

@@ -62,6 +67,11 @@ export const generateOAuthState = () => {
6267
);
6368
};
6469

70+
/**
71+
* Generates a human-readable error description from OAuth callback error parameters
72+
* @param params OAuth error callback parameters containing error details
73+
* @returns Formatted multiline error message with error code, description, and optional URI
74+
*/
6575
export const generateOAuthErrorDescription = (
6676
params: Extract<CallbackParams, { successful: false }>,
6777
): string => {

0 commit comments

Comments
 (0)