Skip to content

Commit 036e3f4

Browse files
authored
Merge pull request #351 from platformsh/add-and-fix-types
add and fix types
2 parents c0bea1b + 04670f9 commit 036e3f4

14 files changed

+321
-69
lines changed

src/index.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import type { ClientConfiguration } from "./config";
66
import { getConfig, setConfig } from "./config";
77
import { entities } from "./model";
88
import type { Activity } from "./model/Activity";
9+
import type { EnvironmentAccessRole } from "./model/EnvironmentAccess";
910
import type {
1011
CreateAccessParams,
1112
DeleteAccessParams,
1213
UpdateAccessParams
1314
} from "./model/EnvironmentType";
15+
import type { InvitationEnvironmentType } from "./model/Invitation";
1416
import type { Me } from "./model/Me";
1517
import type { APIObject } from "./model/Ressource";
1618
import type { TicketQueryParams } from "./model/Ticket";
@@ -113,12 +115,6 @@ export default class Client {
113115

114116
/**
115117
* Get a single project by its ID.
116-
*
117-
* @param string id
118-
* @param string hostname
119-
* @param bool https
120-
*
121-
* @return Project|false
122118
*/
123119
async getProject(id: string) {
124120
return entities.Project.get({ id });
@@ -158,7 +154,7 @@ export default class Client {
158154
async getEnvironmentActivities(
159155
projectId: string,
160156
environmentId: string,
161-
type?: string,
157+
type?: string | string[],
162158
starts_at?: Date
163159
) {
164160
const startsAt = starts_at?.toISOString();
@@ -365,7 +361,7 @@ export default class Client {
365361
async getIntegrationActivities(
366362
projectId: string,
367363
integrationId: string,
368-
type: string,
364+
type: string | string[],
369365
starts_at?: Date
370366
) {
371367
const { api_url } = getConfig();
@@ -1389,7 +1385,7 @@ export default class Client {
13891385
*
13901386
* @return Promise<Ticket>
13911387
*/
1392-
async updateTicketStatus(ticketId: string, status: string) {
1388+
async updateTicketStatus(ticketId: string | number, status: string) {
13931389
return entities.Ticket.patch(ticketId, { status }).then(ticket => ticket);
13941390
}
13951391

@@ -1426,7 +1422,7 @@ export default class Client {
14261422
*
14271423
* @return Promise<Attachment[]>
14281424
*/
1429-
async getTicketAttachments(ticketId: string) {
1425+
async getTicketAttachments(ticketId: string | number) {
14301426
const response = await entities.Ticket.getAttachments(ticketId);
14311427
const { attachments } = response;
14321428
return Object.entries(attachments || {}).map(([filename, attachment]) => ({
@@ -1443,7 +1439,7 @@ export default class Client {
14431439
*
14441440
* @return Promise<Attachment[]>
14451441
*/
1446-
async getAllTicketAttachments(ticketId: string) {
1442+
async getAllTicketAttachments(ticketId: string | number) {
14471443
const response = await entities.Ticket.getAllAttachments(ticketId);
14481444
return response.map(attachment => ({
14491445
filename: attachment.filename,
@@ -1518,7 +1514,7 @@ export default class Client {
15181514
* Updates the user profile picture
15191515
*
15201516
* @param {string} userId User identifier
1521-
* @param {FormData} FormData object containign picture File object to be
1517+
* @param {FormData} picture object containing picture File object to be
15221518
* uploaded.
15231519
*
15241520
* @returns {Promise<{url: string}>} Promise that returns the url to the new
@@ -1624,8 +1620,8 @@ export default class Client {
16241620
projectId: string,
16251621
role: string,
16261622
permissions: {
1627-
type: "production" | "development" | "staging";
1628-
role: "viewer" | "contributor" | "admin";
1623+
type: InvitationEnvironmentType;
1624+
role: EnvironmentAccessRole;
16291625
}[],
16301626
force = false
16311627
) {

src/model/Deployment.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ export type DeploymentService = {
255255
hooks: ServiceHooks;
256256
crons: Record<string, any>;
257257
instance_count?: number;
258+
stack?: unknown;
259+
worker?: Record<string, Record<string, string>>;
258260
};
259261

260262
export type DeploymentGetParams = {

src/model/EnvironmentAccess.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@ export type EnvironmentAccessQueryParams = {
3030
environmentId: string;
3131
};
3232

33+
export type EnvironmentAccessRole = "admin" | "contributor" | "viewer";
34+
export type ConsoleAccessRole = EnvironmentAccessRole | "no-access";
35+
3336
export class EnvironmentAccess extends Ressource {
3437
id: string;
3538
user: string;
3639
email: string;
37-
role: string;
40+
role: EnvironmentAccessRole;
3841
project: string;
3942
environment: string;
4043

src/model/EnvironmentType.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { authenticatedRequest } from "../api";
22
import { getConfig } from "../config";
33

4+
import type { EnvironmentAccessRole } from "./EnvironmentAccess";
45
import { ProjectAccess } from "./ProjectAccess";
56
import type { APIObject } from "./Ressource";
67
import { Ressource } from "./Ressource";
@@ -18,21 +19,19 @@ export type EnvironmentTypeQueryParams = {
1819
projectId: string;
1920
};
2021

21-
export type AccessRole = "admin" | "contributor" | "viewer";
22-
2322
export type CreateAccessParams = {
2423
projectId: string;
2524
environmentTypeId: string;
2625
email?: string;
27-
role: AccessRole;
26+
role: EnvironmentAccessRole;
2827
user?: string;
2928
};
3029

3130
export type UpdateAccessParams = {
3231
projectId: string;
3332
environmentTypeId: string;
3433
accessId: string;
35-
role: AccessRole;
34+
role: EnvironmentAccessRole;
3635
};
3736

3837
export type DeleteAccessParams = {

src/model/Integration.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ type BitbucketAddonCredentials = {
102102
export class Integration extends Ressource {
103103
id: string;
104104
type: string;
105+
token_type?: string;
105106

106107
// These properties may or may not exist on this object, depending on which
107108
// type of integration it is.
@@ -200,6 +201,7 @@ export class Integration extends Ressource {
200201

201202
this.id = integration.id;
202203
this.type = integration.type;
204+
this.token_type = integration.token_type;
203205
this.app_credentials = integration.app_credentials;
204206
this.addon_credentials = integration.addon_credentials;
205207
this.repository = integration.repository;

src/model/Invitation.ts

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { authenticatedRequest } from "../api";
22
import { getConfig } from "../config";
33

4+
import type { ConsoleAccessRole } from "./EnvironmentAccess";
45
import type { APIObject } from "./Ressource";
56
import { Ressource } from "./Ressource";
67

@@ -16,16 +17,37 @@ const creatableField = [
1617
"force"
1718
];
1819

20+
export type InvitationRole = "admin" | "viewer";
21+
22+
export type InvitationEnvironmentType =
23+
| "production"
24+
| "development"
25+
| "staging";
26+
1927
export class Invitation extends Ressource {
2028
id: string;
21-
owner: any;
29+
owner: {
30+
id: string;
31+
display_name: string;
32+
};
33+
2234
projectId: string;
23-
environments: any[]; // This field is deprecated, use permissions instead
35+
/** @deprecated This field is deprecated, use permissions instead */
36+
environments: {
37+
id?: string;
38+
type: InvitationEnvironmentType;
39+
role: ConsoleAccessRole;
40+
title?: string;
41+
}[];
42+
2443
permissions: any[];
2544
state: string;
2645
email: string;
27-
role: string;
46+
role: InvitationRole;
2847
force: boolean;
48+
created_at: string;
49+
updated_at: string;
50+
finished_at: string;
2951

3052
constructor(invitation: APIObject, url?: string) {
3153
const { projectId, id } = invitation;
@@ -51,6 +73,9 @@ export class Invitation extends Ressource {
5173
this.email = invitation.email;
5274
this.role = invitation.role;
5375
this.force = invitation.force;
76+
this.created_at = invitation.created_at;
77+
this.updated_at = invitation.updated_at;
78+
this.finished_at = invitation.finished_at;
5479
}
5580

5681
static async get(projectId: string, id: string) {

src/model/Order.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ export type OrderLineItem = {
3131
end: string;
3232
unit_price: number;
3333
quantity: string | number;
34-
35-
consumption: number;
34+
consumption: string | number;
3635
duration: number;
37-
id: false;
36+
exclude_from_invoice?: boolean;
37+
id: string;
3838
organization: string;
3939
plan_record_id: string;
4040
proration: number;
@@ -47,6 +47,7 @@ export type OrderLineItem = {
4747
}[];
4848
total_price: number;
4949
total_price_formatted: string;
50+
unit_price_formatted?: string;
5051
};
5152

5253
export class Order extends Ressource {

src/model/OrganizationSubscription.ts

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,38 @@ export type OrganizationSubscriptionQueryParams = {
2222

2323
// @ts-expect-error solve the query function inheritance ts error
2424
export class OrganizationSubscription extends Subscription {
25-
organization_id: string;
26-
project_region: string;
25+
agency_site: boolean;
26+
big_dev: null;
27+
big_dev_service: null;
28+
continuous_profiling: null;
29+
created_at: string;
30+
enterprise_tag: string;
31+
environments: number;
32+
fastly_service_ids: null;
33+
green: boolean;
34+
hipaa: boolean;
35+
id: string;
36+
invoiced: boolean;
37+
is_trial_plan: boolean;
38+
locked: null;
39+
options_url: string;
40+
owner: string;
41+
owner_info: {
42+
type: string;
43+
};
44+
45+
plan: string;
46+
project_id: string;
47+
project_notes: string;
48+
project_region_label: string;
49+
project_title: string;
50+
project_ui: string;
51+
services: unknown[];
52+
storage: number;
53+
support_tier: string;
54+
updated_at: string;
55+
user_licenses: number;
56+
vendor: string;
2757

2858
constructor(subscription: APIObject, customUrl?: string) {
2959
const { organizationId } = subscription;
@@ -39,8 +69,35 @@ export class OrganizationSubscription extends Subscription {
3969
this._required = ["project_region", "organization_id"];
4070
this._creatableField.push("organizationId");
4171

42-
this.organization_id = organizationId;
43-
this.project_region = subscription.project_region;
72+
this.agency_site = subscription.agency_site;
73+
this.big_dev = subscription.big_dev;
74+
this.big_dev_service = subscription.big_dev_service;
75+
this.continuous_profiling = subscription.continuous_profiling;
76+
this.created_at = subscription.created_at;
77+
this.enterprise_tag = subscription.enterprise_tag;
78+
this.environments = subscription.environments;
79+
this.fastly_service_ids = subscription.fastly_service_ids;
80+
this.green = subscription.green;
81+
this.hipaa = subscription.hipaa;
82+
this.id = subscription.id;
83+
this.invoiced = subscription.invoiced;
84+
this.is_trial_plan = subscription.is_trial_plan;
85+
this.locked = subscription.locked;
86+
this.options_url = subscription.options_url;
87+
this.owner = subscription.owner;
88+
this.owner_info = subscription.owner_info;
89+
this.plan = subscription.plan;
90+
this.project_id = subscription.project_id;
91+
this.project_notes = subscription.project_notes;
92+
this.project_region_label = subscription.project_region_label;
93+
this.project_title = subscription.project_title;
94+
this.project_ui = subscription.project_ui;
95+
this.services = subscription.services;
96+
this.storage = subscription.storage;
97+
this.support_tier = subscription.support_tier;
98+
this.updated_at = subscription.updated_at;
99+
this.user_licenses = subscription.user_licenses;
100+
this.vendor = subscription.vendor;
44101
}
45102

46103
static async get(

0 commit comments

Comments
 (0)