Skip to content

Commit 613579f

Browse files
committed
fix Application#fetch request loop
1 parent 966ebe0 commit 613579f

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

.changeset/funny-steaks-divide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@squarecloud/api": patch
3+
---
4+
5+
Fix `Application#fetch` request loop

src/managers/application/index.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { assertPathLike, assertString } from "@/assertions/literal";
22
import {
3-
type Application,
3+
Application,
4+
type BaseApplication,
45
type Collection,
56
SimpleApplicationStatus,
67
type SquareCloudAPI,
78
SquareCloudAPIError,
89
User,
910
} from "@/index";
10-
import type { BaseApplication } from "@/structures/application/base";
1111
import type { RESTPostAPIApplicationUploadResult } from "@squarecloud/api-types/v2";
1212
import FormData from "form-data";
1313
import { readFile } from "fs/promises";
@@ -19,15 +19,13 @@ export class ApplicationManager {
1919
* If the ID is provided, it will return an application that you can manage or get information
2020
* If the ID is not provided, it will return a collection of applications
2121
*
22-
* @param appId - The application ID, you must own the application
22+
* @param applicationId - The application ID, you must own the application
2323
*/
2424
async get(): Promise<Collection<string, BaseApplication>>;
25-
async get(applicationId: string): Promise<Application>;
25+
async get(applicationId: string): Promise<BaseApplication>;
2626
async get(
2727
applicationId?: string,
28-
): Promise<
29-
Application | BaseApplication | Collection<string, BaseApplication>
30-
> {
28+
): Promise<BaseApplication | Collection<string, BaseApplication>> {
3129
const { response } = await this.client.api.user();
3230
const user = new User(this.client, response);
3331

@@ -90,6 +88,17 @@ export class ApplicationManager {
9088
(status) => new SimpleApplicationStatus(this.client, status),
9189
);
9290
}
91+
92+
/**
93+
* Returns an application that you can manage or get information
94+
*
95+
* @param applicationId - The application ID, you must own the application
96+
*/
97+
async fetch(applicationId: string): Promise<Application> {
98+
const { response } = await this.client.api.application("", applicationId);
99+
100+
return new Application(this.client, response);
101+
}
93102
}
94103

95104
export * from "./backup";

src/structures/application/base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class BaseApplication {
5252
}
5353

5454
async fetch(): Promise<Application> {
55-
return this.client.applications.get(this.id);
55+
return this.client.applications.fetch(this.id);
5656
}
5757

5858
/** @returns The application current status information */

0 commit comments

Comments
 (0)