11import { assertApplication } from "@/assertions/application" ;
2- import { ApplicationStatus , type SquareCloudAPI } from "@/index" ;
3- import { Routes } from "@/lib/routes" ;
4- import type {
5- APIApplication ,
6- ApplicationLanguage ,
7- } from "@squarecloud/api-types/v2" ;
2+ import type { SquareCloudAPI , WebsiteApplication } from "@/index" ;
3+ import type { APIApplication } from "@squarecloud/api-types/v2" ;
84import { BaseApplication } from "./base" ;
9- import type { WebsiteApplication } from "./website" ;
105
116/**
127 * Represents a Square Cloud application
@@ -16,72 +11,12 @@ import type { WebsiteApplication } from "./website";
1611 * @param data - The data from this application
1712 */
1813export class Application extends BaseApplication {
19- /** The application ID */
20- id : string ;
21- /** The application display name */
22- name : string ;
23- /** The application description */
24- description ?: string ;
25- /** The url to manage the application via web */
26- url : string ;
27- /** The application current cluster */
28- cluster : string ;
29- /** The application total ram */
30- ram : number ;
31- /**
32- * The application programming language
33- *
34- * - `javascript`
35- * - `typescript`
36- * - `python`
37- * - `java`
38- * - `elixir`
39- * - `rust`
40- * - `go`
41- * - `php`
42- * - `dotnet`
43- * - `static`
44- */
45- language : ApplicationLanguage ;
46-
4714 constructor (
4815 public readonly client : SquareCloudAPI ,
4916 data : APIApplication ,
5017 ) {
5118 assertApplication ( data ) ;
5219 super ( client , { ...data , lang : data . language } ) ;
53-
54- const { id, name, desc, cluster, ram, language } = data ;
55-
56- this . id = id ;
57- this . name = name ;
58- this . description = desc ;
59- this . cluster = cluster ;
60- this . ram = ram ;
61- this . language = language ;
62- this . url = `https://squarecloud.app/dashboard/app/${ id } ` ;
63- }
64-
65- /** @returns The application current status information */
66- async getStatus ( ) : Promise < ApplicationStatus > {
67- const data = await this . client . api . request ( Routes . apps . status ( this . id ) ) ;
68- const status = new ApplicationStatus ( this . client , data . response , this . id ) ;
69-
70- this . client . emit ( "statusUpdate" , this , this . cache . status , status ) ;
71- this . cache . set ( "status" , status ) ;
72-
73- return status ;
74- }
75-
76- /** @returns The application logs */
77- async getLogs ( ) : Promise < string > {
78- const data = await this . client . api . request ( Routes . apps . logs ( this . id ) ) ;
79- const { logs } = data . response ;
80-
81- this . client . emit ( "logsUpdate" , this , this . cache . logs , logs ) ;
82- this . cache . set ( "logs" , logs ) ;
83-
84- return logs ;
8520 }
8621
8722 isWebsite ( ) : this is WebsiteApplication {
0 commit comments