File tree Expand file tree Collapse file tree 4 files changed +61
-1
lines changed
Expand file tree Collapse file tree 4 files changed +61
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @squarecloud/api " : patch
3+ ---
4+
5+ New structure for deployments. It's used at ` deploys.list() ` method.
Original file line number Diff line number Diff line change 1+ import { DeploymentState } from "@squarecloud/api-types/v2" ;
2+ import { z } from "zod" ;
3+
4+ import { assertAPIObject } from "./common" ;
5+
6+ const DeploymentSchema = z . object ( {
7+ id : z . string ( ) ,
8+ state : z . nativeEnum ( DeploymentState ) ,
9+ date : z . coerce . date ( ) ,
10+ } ) ;
11+
12+ export function assertDeployment (
13+ value : unknown ,
14+ ) : asserts value is z . infer < typeof DeploymentSchema > {
15+ assertAPIObject ( {
16+ schema : DeploymentSchema ,
17+ value,
18+ code : "DEPLOYMENT" ,
19+ route : "/apps/{app_id}/deployments" ,
20+ } ) ;
21+ }
Original file line number Diff line number Diff line change 11import { assertString } from "@/assertions/literal" ;
22import { Routes } from "@/lib/routes" ;
33import type { BaseApplication } from "@/structures" ;
4+ import { Deployment } from "@/structures/deploy" ;
45
56export class DeploysModule {
67 constructor ( public readonly application : BaseApplication ) { }
@@ -29,7 +30,9 @@ export class DeploysModule {
2930 Routes . apps . deployments . list ( this . application . id ) ,
3031 ) ;
3132
32- return data . response ;
33+ return data . response . map (
34+ ( deployment ) => new Deployment ( this . application , deployment ) ,
35+ ) ;
3336 }
3437
3538 /**
Original file line number Diff line number Diff line change 1+ import type { APIDeployment , DeploymentState } from "@squarecloud/api-types/v2" ;
2+
3+ import { assertDeployment } from "@/assertions/deploy" ;
4+ import type { BaseApplication } from "./application/base" ;
5+
6+ export class Deployment {
7+ /** The ID of the deploy. */
8+ id : `git-${string } `;
9+
10+ /** The current state of the deploy. */
11+ state : DeploymentState ;
12+
13+ /** The date the deploy was created. */
14+ createdAt : Date ;
15+
16+ /** The date the deploy was created in millisseconds. */
17+ createdTimestamp : number ;
18+
19+ constructor (
20+ public readonly application : BaseApplication ,
21+ data : APIDeployment ,
22+ ) {
23+ assertDeployment ( data ) ;
24+ const { id, state, date } = data ;
25+
26+ this . id = id ;
27+ this . state = state ;
28+ this . createdAt = new Date ( date ) ;
29+ this . createdTimestamp = this . createdAt . getTime ( ) ;
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments