Skip to content

Commit

Permalink
replacing discloud.app/utils to @discloudapp/util
Browse files Browse the repository at this point in the history
  • Loading branch information
Gorniaky committed Sep 13, 2023
1 parent 4b123a9 commit 4e1e805
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 40 deletions.
4 changes: 2 additions & 2 deletions packages/discloud.app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"homepage": "https://github.com/discloud/discloud.app#readme",
"dependencies": {
"@discloudapp/api-types": "^0.4.0",
"@discloudapp/rest": "^0.7.3",
"@discloudapp/util": "^0.4.7",
"@discloudapp/rest": "^0.8.0",
"@discloudapp/util": "^0.5.1",
"source-map-support": "^0.5.21",
"tslib": "^2.6.2",
"undici": "^5.24.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/discloud.app/src/@types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type Constructor<T> = new (...args: any[]) => T;
export type If<T extends boolean, A, B = undefined> = T extends true ? A : T extends false ? B : A | B;

export interface DiscloudAppOptions {
rest?: RESTOptions
rest?: Partial<RESTOptions>
}

export const ProfileOptions = z.object({
Expand Down
3 changes: 2 additions & 1 deletion packages/discloud.app/src/discloudApp/DiscloudApp.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ApiUser } from "@discloudapp/api-types/v2";
import { REST, RESTEvents } from "@discloudapp/rest";
import { mergeDefaults } from "@discloudapp/util";
import EventEmitter from "node:events";
import { env } from "node:process";
import { ClientEvents, DiscloudAppOptions } from "../@types";
Expand All @@ -8,7 +9,7 @@ import AppManager from "../managers/AppManager";
import AppTeamManager from "../managers/AppTeamManager";
import TeamAppManager from "../managers/TeamAppManager";
import User from "../structures/User";
import { DefaultDiscloudAppOptions, mergeDefaults } from "../util";
import { DefaultDiscloudAppOptions } from "../util";

/**
* Client for Discloud API
Expand Down
14 changes: 7 additions & 7 deletions packages/discloud.app/src/structures/User.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiUser, RESTGetApiUserResult, RESTPutApiLocaleResult, Routes } from "@discloudapp/api-types/v2";
import { calculatePercentage } from "..";
import { calculatePercentage } from "@discloudapp/util";
import { LocaleString } from "../@types";
import DiscloudApp from "../discloudApp/DiscloudApp";
import Base from "./Base";
Expand Down Expand Up @@ -54,7 +54,7 @@ export default class User extends Base {
this._patch(data);
}

protected _patch(data: ApiUser): this {
protected _patch(data: Partial<ApiUser>): this {
if ("apps" in data)
if (Array.isArray(data.apps)) {
this.appIDs.clear();
Expand All @@ -74,21 +74,21 @@ export default class User extends Base {
}

if ("userID" in data)
this.id = data.userID;
this.id = data.userID!;

if ("locale" in data)
this.locale = data.locale;
this.locale = data.locale!;

if ("plan" in data)
this.plan = data.plan;
this.plan = data.plan!;

if ("planDataEnd" in data) {
this.planDataEnd = new Date(data.planDataEnd!);
this.planDataEndTimestamp = this.planDataEnd.valueOf();
}

if ("ramUsedMb" in data)
this.ramUsedMb = data.ramUsedMb;
this.ramUsedMb = data.ramUsedMb!;

if ("subdomains" in data)
if (Array.isArray(data.subdomains)) {
Expand All @@ -100,7 +100,7 @@ export default class User extends Base {
}

if ("totalRamMb" in data)
this.totalRamMb = data.totalRamMb;
this.totalRamMb = data.totalRamMb!;

if ("ramUsedMb" in this && "totalRamMb" in this)
this.ramUsage = calculatePercentage(this.ramUsedMb, this.totalRamMb);
Expand Down
2 changes: 2 additions & 0 deletions packages/discloud.app/src/util/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DefaultRestOptions } from "@discloudapp/rest";
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { env } from "node:process";
Expand All @@ -9,6 +10,7 @@ export const version: string = JSON.parse(readFileSync(join(__dirname, "..", "..
* Library default options
*/
export const DefaultDiscloudAppOptions: DiscloudAppOptions & { token?: string } = {
rest: DefaultRestOptions,
/** The token to authenticate on Discloud API */
token: env.DISCLOUD_TOKEN,
};
1 change: 0 additions & 1 deletion packages/discloud.app/src/util/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from "./constants";
export * from "./utils";

18 changes: 0 additions & 18 deletions packages/discloud.app/src/util/utils.ts

This file was deleted.

12 changes: 2 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@
dependencies:
"@jridgewell/trace-mapping" "0.3.9"

"@discloudapp/util@^0.4.7":
version "0.4.7"
resolved "https://registry.yarnpkg.com/@discloudapp/util/-/util-0.4.7.tgz#b67224ca56456e2791d30b3b932251e03fb7141b"
integrity sha512-Oyuz85eOkQ/u+ts4dazLJYk5bYZER+CaKKu8qFGXSNNUG1MSUo1zDQlo0WBYPSQxCA1ts+xDkkjD/Pa7bU88RA==
dependencies:
glob "^10.3.3"
undici "^5.23.0"

"@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0":
version "4.4.0"
resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59"
Expand Down Expand Up @@ -675,7 +667,7 @@ glob-parent@^6.0.2:
dependencies:
is-glob "^4.0.3"

glob@^10.2.5, glob@^10.3.3, glob@^10.3.4:
glob@^10.2.5, glob@^10.3.4:
version "10.3.4"
resolved "https://registry.yarnpkg.com/glob/-/glob-10.3.4.tgz#c85c9c7ab98669102b6defda76d35c5b1ef9766f"
integrity sha512-6LFElP3A+i/Q8XQKEvZjkEWEOTgAIALR9AO2rwT8bgPhDd1anmqDJDZ6lLddI4ehxxxR1S5RIqKe1uapMQfYaQ==
Expand Down Expand Up @@ -1293,7 +1285,7 @@ uglify-js@^3.1.4:
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.17.4.tgz#61678cf5fa3f5b7eb789bb345df29afb8257c22c"
integrity sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==

undici@^5.23.0, undici@^5.24.0:
undici@^5.24.0:
version "5.24.0"
resolved "https://registry.yarnpkg.com/undici/-/undici-5.24.0.tgz#6133630372894cfeb3c3dab13b4c23866bd344b5"
integrity sha512-OKlckxBjFl0oXxcj9FU6oB8fDAaiRUq+D8jrFWGmOfI/gIyjk/IeS75LMzgYKUaeHzLUcYvf9bbJGSrUwTfwwQ==
Expand Down

0 comments on commit 4e1e805

Please sign in to comment.