Skip to content

Commit

Permalink
feat(api-client): Synced with latest API
Browse files Browse the repository at this point in the history
  • Loading branch information
rajdip-b committed Sep 15, 2024
1 parent 1f864df commit 27f4309
Show file tree
Hide file tree
Showing 10 changed files with 264 additions and 327 deletions.
15 changes: 15 additions & 0 deletions packages/api-client/src/controllers/secret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
GetAllSecretsOfEnvironmentResponse,
GetAllSecretsOfProjectRequest,
GetAllSecretsOfProjectResponse,
GetRevisionsOfSecretRequest,
GetRevisionsOfSecretResponse,
RollBackSecretRequest,
RollBackSecretResponse,
UpdateSecretRequest,
Expand Down Expand Up @@ -100,4 +102,17 @@ export default class SecretController {

return await parseResponse<GetAllSecretsOfEnvironmentResponse>(response)
}

async getRevisionsOfSecret(
request: GetRevisionsOfSecretRequest,
headers?: Record<string, string>
): Promise<ClientResponse<GetRevisionsOfSecretResponse>> {
const url = parsePaginationUrl(
`/api/secret/${request.secretSlug}/revisions/${request.environmentSlug}`,
request
)
const response = await this.apiClient.get(url, headers)

return await parseResponse<GetRevisionsOfSecretResponse>(response)
}
}
15 changes: 15 additions & 0 deletions packages/api-client/src/controllers/variable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
GetAllVariablesOfEnvironmentResponse,
GetAllVariablesOfProjectRequest,
GetAllVariablesOfProjectResponse,
GetRevisionsOfVariableRequest,
GetRevisionsOfVariableResponse,
RollBackVariableRequest,
RollBackVariableResponse,
UpdateVariableRequest,
Expand Down Expand Up @@ -96,4 +98,17 @@ export default class VariableController {

return await parseResponse<GetAllVariablesOfEnvironmentResponse>(response)
}

async getRevisionsOfVariable(
request: GetRevisionsOfVariableRequest,
headers: Record<string, string>
): Promise<ClientResponse<GetRevisionsOfVariableResponse>> {
const url = parsePaginationUrl(
`/api/variable/${request.variableSlug}/revisions/${request.environmentSlug}`,
request
)
const response = await this.apiClient.get(url, headers)

return await parseResponse<GetRevisionsOfVariableResponse>(response)
}
}
2 changes: 1 addition & 1 deletion packages/api-client/src/core/pagination-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { PageRequest } from '@api-client/types/index.types'
*/
export function parsePaginationUrl(
baseUrl: string,
request: PageRequest
request: Partial<PageRequest>
): string {
let url = `${baseUrl}?`
request.page && (url += `page=${request.page}&`)
Expand Down
61 changes: 20 additions & 41 deletions packages/api-client/src/types/environment.types.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { PageRequest, PageResponse } from './index.types'

export interface CreateEnvironmentRequest {
name: string
description?: string
projectId: string
}

export interface CreateEnvironmentResponse {
interface Environment {
id: string
name: string
slug: string
Expand All @@ -17,57 +11,42 @@ export interface CreateEnvironmentResponse {
projectId: string
}

export interface UpdateEnvironmentRequest {
slug: string
name?: string
export interface CreateEnvironmentRequest {
name: string
description?: string
projectId: string
}

export interface UpdateEnvironmentResponse {
id: string
name: string
export interface CreateEnvironmentResponse extends Environment {}

export interface UpdateEnvironmentRequest
extends Partial<Omit<CreateEnvironmentRequest, 'projectId'>> {
slug: string
description: string | null
createdAt: string
updatedAt: string
lastUpdatedById: string
projectId: string
}

export interface UpdateEnvironmentResponse extends Environment {}

export interface GetEnvironmentRequest {
slug: string
}

export interface GetEnvironmentResponse {
id: string
name: string
slug: string
description: string | null
createdAt: string
updatedAt: string
lastUpdatedById: string
projectId: string
}
export interface GetEnvironmentResponse extends Environment {}

export interface GetAllEnvironmentsOfProjectRequest extends PageRequest {
projectSlug: string
}

export interface GetAllEnvironmentsOfProjectResponse
extends PageResponse<{
id: string
slug: string
name: string
description: string | null
createdAt: string
updatedAt: string
lastUpdatedBy: {
id: string
name: string
email: string
profilePictureUrl: string | null
extends PageResponse<
Environment & {
lastUpdatedBy: {
id: string
name: string
email: string
profilePictureUrl: string | null
}
}
}> {}
> {}

export interface DeleteEnvironmentRequest {
slug: string
Expand Down
72 changes: 16 additions & 56 deletions packages/api-client/src/types/integration.types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,8 @@ export enum EventType {
INTEGRATION_UPDATED,
INTEGRATION_DELETED
}
export interface CreateIntegrationRequest {
workspaceSlug?: string
projectSlug?: string
name: string
type: string
notifyOn: [string]
metadata: Record<string, string>
environmentSlug: string
}

export interface CreateIntegrationResponse {
interface Integration {
id: string
name: string
slug: string
Expand All @@ -60,31 +51,25 @@ export interface CreateIntegrationResponse {
environmentId: string
}

export interface UpdateIntegrationRequest {
integrationSlug: string
export interface CreateIntegrationRequest {
workspaceSlug?: string
projectSlug?: string
name?: string
type?: IntegrationType
notifyOn?: EventType[]
metadata?: Record<string, string>
environmentId?: string
}

export interface UpdateIntegrationResponse {
id: string
name: string
slug: string
type: string
notifyOn: [string]
metadata: Record<string, string>
createdAt: string
updatedAt: string
type: IntegrationType
notifyOn: EventType[]
workspaceId: string
projectId: string
environmentId: string
environmentSlug: string
}

export interface CreateIntegrationResponse extends Integration {}

export interface UpdateIntegrationRequest
extends Partial<Omit<CreateIntegrationRequest, 'workspaceSlug'>> {
integrationSlug: string
}

export interface UpdateIntegrationResponse extends Integration {}

export interface DeleteIntegrationResponse {}

export interface DeleteIntegrationRequest {
Expand All @@ -95,35 +80,10 @@ export interface GetIntegrationRequest {
integrationSlug: string
}

export interface GetIntegrationResponse {
id: string
name: string
slug: string
metadata: Record<string, string>
createdAt: string
updatedAt: string
type: IntegrationType
notifyOn: EventType[]
workspaceId: string
projectId: string
environmentId: string
}
export interface GetIntegrationResponse extends Integration {}

export interface GetAllIntegrationRequest extends PageRequest {
workspaceSlug: string
}

export interface GetAllIntegrationResponse
extends PageResponse<{
id: string
name: string
slug: string
metadata: Record<string, string>
createdAt: string
updatedAt: string
type: IntegrationType
notifyOn: EventType[]
workspaceId: string
projectId: string
environmentId: string
}> {}
export interface GetAllIntegrationResponse extends PageResponse<Integration> {}
Loading

0 comments on commit 27f4309

Please sign in to comment.