Skip to content

Commit bdcc9fb

Browse files
committed
docs: update jsdoc
1 parent bcd929c commit bdcc9fb

File tree

3 files changed

+79
-3
lines changed

3 files changed

+79
-3
lines changed

src/index.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ export const UnityChangeset = UnityChangesetClass;
1717
export type UnityChangeset = UnityChangesetClass;
1818
export { UnityReleaseEntitlement, UnityReleaseStream };
1919

20+
/**
21+
* Retrieves the Unity changeset for a specific version.
22+
* @param version - The Unity version string (e.g., "2020.1.14f1").
23+
* @returns A Promise that resolves to the UnityChangeset object.
24+
* @throws Error if the version is not found.
25+
*/
2026
export async function getUnityChangeset(
2127
version: string,
2228
): Promise<UnityChangeset> {
@@ -117,6 +123,15 @@ export enum FormatMode {
117123
PrettyJson = "pretty-json",
118124
}
119125

126+
/**
127+
* Lists Unity changesets based on search, filter, group, output, and format options.
128+
* @param searchMode - The search mode to use.
129+
* @param filterOptions - The filter options to apply.
130+
* @param groupMode - The group mode to use.
131+
* @param outputMode - The output mode for the results.
132+
* @param formatMode - The format mode for the output.
133+
* @returns A Promise that resolves to a formatted string of the results.
134+
*/
120135
export function listChangesets(
121136
searchMode: SearchMode,
122137
filterOptions: FilterOptions,
@@ -160,6 +175,12 @@ export function listChangesets(
160175
});
161176
}
162177

178+
/**
179+
* Searches for Unity changesets based on the specified search mode.
180+
* @param searchMode - The search mode to use.
181+
* @returns A Promise that resolves to an array of UnityChangeset objects.
182+
* @throws Error if the search mode is not supported.
183+
*/
163184
export async function searchChangesets(
164185
searchMode: SearchMode,
165186
): Promise<UnityChangeset[]> {
@@ -182,6 +203,12 @@ export async function searchChangesets(
182203
}
183204
}
184205

206+
/**
207+
* Filters an array of Unity changesets based on the provided options.
208+
* @param changesets - The array of UnityChangeset objects to filter.
209+
* @param options - The filter options.
210+
* @returns An array of filtered UnityChangeset objects.
211+
*/
185212
export function filterChangesets(
186213
changesets: UnityChangeset[],
187214
options: FilterOptions,
@@ -216,6 +243,13 @@ export function filterChangesets(
216243
);
217244
}
218245

246+
/**
247+
* Groups an array of Unity changesets based on the specified group mode.
248+
* @param changesets - The array of UnityChangeset objects to group.
249+
* @param groupMode - The group mode to use.
250+
* @returns An array of grouped UnityChangeset objects.
251+
* @throws Error if the group mode is not supported.
252+
*/
219253
export function groupChangesets(
220254
changesets: UnityChangeset[],
221255
groupMode: GroupMode,
@@ -243,6 +277,11 @@ export function groupChangesets(
243277
}
244278
}
245279

280+
/**
281+
* Retrieves all Unity changesets from the database.
282+
* @returns A Promise that resolves to an array of all UnityChangeset objects from the database.
283+
* @throws Error if the database cannot be fetched or is invalid.
284+
*/
246285
export function getAllChangesetsFromDb(): Promise<UnityChangeset[]> {
247286
return fetch(UNITY_CHANGESETS_DB_URL)
248287
.then((res) => {
@@ -262,6 +301,11 @@ export function getAllChangesetsFromDb(): Promise<UnityChangeset[]> {
262301
});
263302
}
264303

304+
/**
305+
* Searches for Unity changesets from the database based on the specified search mode.
306+
* @param searchMode - The search mode to use.
307+
* @returns A Promise that resolves to an array of UnityChangeset objects from the database.
308+
*/
265309
export function searchChangesetsFromDb(
266310
searchMode: SearchMode,
267311
): Promise<UnityChangeset[]> {

src/unityChangeset.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ export enum UnityReleaseEntitlement {
2121
U7_ALPHA = "U7_ALPHA",
2222
}
2323

24-
/*
25-
Unity Changeset
26-
*/
24+
/**
25+
* Represents a Unity changeset with version, changeset hash, and metadata.
26+
*/
2727
export class UnityChangeset {
2828
version = "";
2929
changeset = "";
@@ -35,6 +35,14 @@ export class UnityChangeset {
3535
entitlements: UnityReleaseEntitlement[] = [];
3636
xlts = false;
3737

38+
/**
39+
* Creates a new UnityChangeset instance.
40+
* @param version - The Unity version string.
41+
* @param changeset - The changeset hash.
42+
* @param stream - The release stream.
43+
* @param entitlements - The entitlements array.
44+
* @throws Error if version or changeset is invalid.
45+
*/
3846
constructor(
3947
version: string,
4048
changeset: string,
@@ -64,10 +72,20 @@ export class UnityChangeset {
6472
}
6573
}
6674

75+
/**
76+
* Returns a string representation of the changeset in the format "version\tchangeset".
77+
* @returns The string representation.
78+
*/
6779
toString = (): string => {
6880
return `${this.version}\t${this.changeset}`;
6981
};
7082

83+
/**
84+
* Converts a Unity version string to a numerical representation for comparison.
85+
* @param version - The Unity version string.
86+
* @param max - If true, treats missing parts as maximum values; otherwise, as minimum.
87+
* @returns The numerical representation of the version.
88+
*/
7189
static toNumber = (version: string, max: boolean): number => {
7290
const match = version.toString().match(REGEXP_UNITY_NUM);
7391
if (match === null) return 0;

src/unityGraphQL.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ async function requestWithErrorHandling<T>(
8888
}
8989
}
9090

91+
/**
92+
* Retrieves Unity releases from the GraphQL API based on version, stream, and entitlements.
93+
* @param version - The version pattern to search for.
94+
* @param stream - The array of release streams to filter by.
95+
* @param entitlements - The array of entitlements to filter by.
96+
* @returns A Promise that resolves to an array of UnityChangeset objects.
97+
* @throws Error if the API response is invalid.
98+
*/
9199
export async function getUnityReleases(
92100
version: string,
93101
stream: UnityReleaseStream[] = [],
@@ -176,6 +184,12 @@ query GetRelease($limit: Int, $skip: Int, $version: String!, $stream: [UnityRele
176184
return results;
177185
}
178186

187+
/**
188+
* Retrieves Unity releases in LTS from the GraphQL API based on entitlements.
189+
* @param entitlements - The array of entitlements to filter by.
190+
* @returns A Promise that resolves to an array of UnityChangeset objects.
191+
* @throws Error if the API response is invalid.
192+
*/
179193
export async function getUnityReleasesInLTS(
180194
entitlements: UnityReleaseEntitlement[] = [],
181195
): Promise<UnityChangeset[]> {

0 commit comments

Comments
 (0)