-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(schema, api-client): Migrate secret types and schemas to @keysha…
…de/schema (#539) Co-authored-by: Rajdip Bhattacharya <[email protected]>
- Loading branch information
Showing
7 changed files
with
695 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
import { z } from 'zod' | ||
import { PageRequestSchema, PageResponseSchema } from '@/pagination/pagination' | ||
import { rotateAfterEnum } from '@/enums' | ||
|
||
export const SecretSchema = z.object({ | ||
id: z.string(), | ||
name: z.string(), | ||
slug: z.string(), | ||
createdAt: z.string(), | ||
updatedAt: z.string(), | ||
rotateAt: z.string().nullable(), | ||
note: z.string().nullable(), | ||
lastUpdatedById: z.string(), | ||
projectId: z.string(), | ||
project: z.object({ | ||
workspaceId: z.string() | ||
}), | ||
versions: z.array( | ||
z.object({ | ||
id: z.string().optional(), | ||
environmentId: z.string(), | ||
value: z.string(), | ||
environment: z.object({ | ||
id: z.string(), | ||
slug: z.string() | ||
}) | ||
}) | ||
) | ||
}) | ||
|
||
export const CreateSecretRequestSchema = z.object({ | ||
projectSlug: z.string(), | ||
name: z.string(), | ||
note: z.string().optional(), | ||
rotateAfter: rotateAfterEnum.optional(), | ||
entries: z | ||
.array( | ||
z.object({ | ||
value: z.string(), | ||
environmentSlug: z.string() | ||
}) | ||
) | ||
.optional() | ||
}) | ||
|
||
export const CreateSecretResponseSchema = SecretSchema | ||
|
||
export const UpdateSecretRequestSchema = | ||
CreateSecretRequestSchema.partial().extend({ | ||
secretSlug: z.string() | ||
}) | ||
|
||
export const UpdateSecretResponseSchema = z.object({ | ||
secret: z.object({ | ||
id: z.string(), | ||
name: z.string(), | ||
slug: z.string(), | ||
note: z.string().nullable() | ||
}), | ||
updatedVersions: z.array( | ||
z.object({ | ||
id: z.string().optional(), | ||
environmentId: z.string(), | ||
environment: z.object({ | ||
id: z.string(), | ||
slug: z.string() | ||
}), | ||
value: z.string() | ||
}) | ||
) | ||
}) | ||
|
||
export const DeleteSecretRequestSchema = z.object({ | ||
secretSlug: z.string() | ||
}) | ||
|
||
export const DeleteSecretResponseSchema = z.void() | ||
|
||
export const RollBackSecretRequestSchema = z.object({ | ||
environmentSlug: z.string(), | ||
version: z.number(), | ||
secretSlug: z.string() | ||
}) | ||
|
||
export const RollBackSecretResponseSchema = z.object({ | ||
count: z.string() | ||
}) | ||
|
||
export const GetAllSecretsOfProjectRequestSchema = PageRequestSchema.extend({ | ||
projectSlug: z.string() | ||
}) | ||
|
||
export const GetAllSecretsOfProjectResponseSchema = PageResponseSchema( | ||
z.object({ | ||
secret: SecretSchema.omit({ versions: true, project: true }).extend({ | ||
lastUpdatedBy: z.object({ | ||
id: z.string(), | ||
name: z.string() | ||
}) | ||
}), | ||
values: z.object({ | ||
environment: z.object({ | ||
id: z.string(), | ||
name: z.string(), | ||
slug: z.string() | ||
}), | ||
value: z.string(), | ||
version: z.number() | ||
}) | ||
}) | ||
) | ||
|
||
export const GetAllSecretsOfEnvironmentRequestSchema = z.object({ | ||
projectSlug: z.string(), | ||
environmentSlug: z.string() | ||
}) | ||
|
||
export const GetAllSecretsOfEnvironmentResponseSchema = z.array( | ||
z.object({ | ||
name: z.string(), | ||
value: z.string(), | ||
isPlaintext: z.boolean() | ||
}) | ||
) | ||
|
||
export const GetRevisionsOfSecretRequestSchema = | ||
PageRequestSchema.partial().extend({ | ||
secretSlug: z.string(), | ||
environmentSlug: z.string() | ||
}) | ||
|
||
export const GetRevisionsOfSecretResponseSchema = PageResponseSchema( | ||
z.object({ | ||
id: z.string(), | ||
value: z.string(), | ||
version: z.number(), | ||
createdOn: z.string(), | ||
createdById: z.string(), | ||
environmentId: z.string() | ||
}) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { z } from 'zod' | ||
import { | ||
SecretSchema, | ||
CreateSecretRequestSchema, | ||
CreateSecretResponseSchema, | ||
UpdateSecretRequestSchema, | ||
UpdateSecretResponseSchema, | ||
DeleteSecretRequestSchema, | ||
DeleteSecretResponseSchema, | ||
RollBackSecretRequestSchema, | ||
RollBackSecretResponseSchema, | ||
GetAllSecretsOfProjectRequestSchema, | ||
GetAllSecretsOfProjectResponseSchema, | ||
GetAllSecretsOfEnvironmentRequestSchema, | ||
GetAllSecretsOfEnvironmentResponseSchema, | ||
GetRevisionsOfSecretRequestSchema, | ||
GetRevisionsOfSecretResponseSchema | ||
} from '.' | ||
|
||
export type Secret = z.infer<typeof SecretSchema> | ||
|
||
export type CreateSecretRequest = z.infer<typeof CreateSecretRequestSchema> | ||
|
||
export type CreateSecretResponse = z.infer<typeof CreateSecretResponseSchema> | ||
|
||
export type UpdateSecretRequest = z.infer<typeof UpdateSecretRequestSchema> | ||
|
||
export type UpdateSecretResponse = z.infer<typeof UpdateSecretResponseSchema> | ||
|
||
export type DeleteSecretRequest = z.infer<typeof DeleteSecretRequestSchema> | ||
|
||
export type DeleteSecretResponse = z.infer<typeof DeleteSecretResponseSchema> | ||
|
||
export type RollBackSecretRequest = z.infer<typeof RollBackSecretRequestSchema> | ||
|
||
export type RollBackSecretResponse = z.infer< | ||
typeof RollBackSecretResponseSchema | ||
> | ||
|
||
export type GetAllSecretsOfProjectRequest = z.infer< | ||
typeof GetAllSecretsOfProjectRequestSchema | ||
> | ||
|
||
export type GetAllSecretsOfProjectResponse = z.infer< | ||
typeof GetAllSecretsOfProjectResponseSchema | ||
> | ||
|
||
export type GetAllSecretsOfEnvironmentRequest = z.infer< | ||
typeof GetAllSecretsOfEnvironmentRequestSchema | ||
> | ||
|
||
export type GetAllSecretsOfEnvironmentResponse = z.infer< | ||
typeof GetAllSecretsOfEnvironmentResponseSchema | ||
> | ||
|
||
export type GetRevisionsOfSecretRequest = z.infer< | ||
typeof GetRevisionsOfSecretRequestSchema | ||
> | ||
|
||
export type GetRevisionsOfSecretResponse = z.infer< | ||
typeof GetRevisionsOfSecretResponseSchema | ||
> |
Oops, something went wrong.