Skip to content

Commit cfd06d4

Browse files
committedApr 24, 2025
refactor(api): deprecate users in favor of user module
1 parent 1896cf6 commit cfd06d4

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed
 

‎.changeset/eleven-sites-stay.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+
Deprecate `SquareCloudAPI#users` in favor of `SquareCloudAPI#user`. Deprecated property will be removed in the the next major version.

‎src/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export class SquareCloudAPI extends TypedEventEmitter<ClientEvents> {
1414

1515
/** The applications module */
1616
public readonly applications = new ApplicationsModule(this);
17-
/** The users module */
18-
public readonly users = new UserModule(this);
17+
/** The user module */
18+
public readonly user = new UserModule(this);
1919
/** The global cache service */
2020
public readonly cache = new GlobalCacheService();
2121

@@ -30,6 +30,14 @@ export class SquareCloudAPI extends TypedEventEmitter<ClientEvents> {
3030
assertString(apiKey, "API_KEY");
3131
this.api = new APIService(apiKey);
3232
}
33+
34+
/** @deprecated Use SquareCloudAPI#user instead. */
35+
get users() {
36+
console.warn(
37+
"[SquareCloudAPI] The 'users' property is deprecated and will be removed in the next major version. Use SquareCloudAPI#user instead.",
38+
);
39+
return this.user;
40+
}
3341
}
3442

3543
export * from "./structures";

‎src/structures/application/base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export class BaseApplication {
7878
/** @deprecated Use `Application#backups` instead */
7979
get backup() {
8080
console.warn(
81-
"Application#backup is deprecated. Use Application#backups instead.",
81+
"[SquareCloudAPI] The 'backup' property is deprecated and will be removed in the the next major version. Use Application#backups instead.",
8282
);
8383
return this.backups;
8484
}

‎test/user.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ test("UserModule", async (t) => {
66
const client = new SquareCloudAPI(process.env.SQUARE_API_KEY);
77

88
await t.test("should get user information", async () => {
9-
const user = await client.users.get();
9+
const user = await client.user.get();
1010

1111
assert.ok(user);
1212
assert.ok(user.id);
@@ -17,7 +17,7 @@ test("UserModule", async (t) => {
1717
});
1818

1919
await t.test("should update cache on user fetch", async () => {
20-
const firstUser = await client.users.get();
20+
const firstUser = await client.user.get();
2121
const cachedUser = client.cache.get("user");
2222

2323
assert.strictEqual(cachedUser?.id, firstUser.id);
@@ -34,7 +34,7 @@ test("UserModule", async (t) => {
3434
emitted = true;
3535
});
3636

37-
await client.users.get();
37+
await client.user.get();
3838
assert.ok(emitted, "userUpdate event should have been emitted");
3939
});
4040
});

0 commit comments

Comments
 (0)