Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(schema, api-client): Migrate workspace-role schemas and types to @keyshade/schema #568

Merged
merged 3 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,16 @@
"lint:web": "turbo run lint --filter=web",
"lint:platform": "turbo run lint --filter=platform",
"lint:cli": "turbo run lint --filter=cli",
"lint:api-client": "turbo run lint --filter=api-client",
"lint:api-client": "turbo run lint --filter=@keyshade/api-client",
"lint:secret-scan": "turbo run lint --filter=secret-scan",
"lint:schema": "turbo run lint --filter=schema",
"lint:schema": "turbo run lint --filter=@keyshade/schema",
"build": "turbo run build",
"build:api": "pnpm db:generate-types && turbo run build --filter=api",
"build:web": "turbo run build --filter=web",
"build:platform": "turbo run build --filter=platform",
"build:cli": "pnpm build:secret-scan && pnpm build:api-client && turbo run build --filter=cli",
"build:api-client": "pnpm build:schema && turbo run --filter=api-client build",
"build:schema": "turbo run build --filter=schema",
"build:api-client": "pnpm build:schema && turbo run --filter=@keyshade/api-client build",
"build:schema": "turbo run build --filter=@keyshade/schema",
"build:secret-scan": "turbo run build --filter=secret-scan",
"start": "turbo run start",
"start:api": "turbo run start --filter=api",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/src/controllers/workspace-role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
GetWorkspaceRolesOfWorkspaceRequest,
GetWorkspaceRolesOfWorkspaceResponse,
CheckWorkspaceRoleExistsRequest
} from '@api-client/types/workspace-role.types'
} from '@keyshade/schema'

export default class WorkspaceRoleController {
private apiClient: APIClient
Expand Down
67 changes: 0 additions & 67 deletions packages/api-client/src/types/workspace-role.types.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/api-client/tests/workspace-role.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import WorkspaceRoleController from '@api-client/controllers/workspace-role'
import {
CreateWorkspaceRoleRequest,
GetWorkspaceRolesOfWorkspaceRequest
} from '@api-client/types/workspace-role.types'
} from '@keyshade/schema'

describe('Workspace Role Controller Tests', () => {
const backendUrl = process.env.BACKEND_URL
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../tsconfig/base.json",
"extends": "tsconfig/base.json",
muntaxir4 marked this conversation as resolved.
Show resolved Hide resolved
"compilerOptions": {
"baseUrl": ".",
"declaration": true,
Expand Down
20 changes: 10 additions & 10 deletions packages/eslint-config-custom/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "eslint-config-custom",
"license": "MIT",
"version": "0.0.0",
"private": true,
"devDependencies": {
"@vercel/style-guide": "^5.0.0",
"eslint-config-turbo": "^1.10.12",
"typescript": "^4.5.3"
}
}
"name": "eslint-config-custom",
"license": "MIT",
"version": "0.0.0",
"private": true,
"devDependencies": {
"@vercel/style-guide": "^5.0.0",
"eslint-config-turbo": "^2.3.1",
"typescript": "^4.5.3"
}
}
10 changes: 1 addition & 9 deletions packages/schema/src/index.types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import { z } from 'zod'
import {
CreateWorkspaceRoleSchema,
UpdateWorkspaceRoleSchema
} from './workspace-role'

export * from './pagination/index.types'
export * from './auth/index.types'
export * from './environment/index.types'
Expand All @@ -15,6 +9,4 @@ export * from './variable/index.types'
export * from './event/index.types'
export * from './integration/index.types'
export * from './api-key/index.types'

export type TCreateWorkspaceRole = z.infer<typeof CreateWorkspaceRoleSchema>
export type TUpdateWorkspaceRole = z.infer<typeof UpdateWorkspaceRoleSchema>
export * from './workspace-role/index.types'
12 changes: 0 additions & 12 deletions packages/schema/src/workspace-role.ts

This file was deleted.

77 changes: 77 additions & 0 deletions packages/schema/src/workspace-role/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { authorityEnum } from '@/enums'
import { PageRequestSchema, PageResponseSchema } from '@/pagination'
import { BaseProjectSchema } from '@/project'
import { WorkspaceSchema } from '@/workspace'
import { z } from 'zod'

export const WorkspaceRoleSchema = z.object({
id: z.string(),
name: z.string(),
slug: z.string(),
description: z.string().nullable(),
colorCode: z.string().nullable(),
hasAdminAuthority: z.boolean(),
createdAt: z.string().datetime(),
updatedAt: z.string().datetime(),
authorities: z.array(authorityEnum),
workspaceId: WorkspaceSchema.shape.id,
projects: z.array(
z.object({
project: z.object({
id: BaseProjectSchema.shape.id,
name: BaseProjectSchema.shape.name,
slug: BaseProjectSchema.shape.slug
})
})
)
})

export const CreateWorkspaceRoleRequestSchema = z.object({
workspaceSlug: WorkspaceSchema.shape.slug,
name: WorkspaceRoleSchema.shape.name,
description: z.string().optional(),
colorCode: z.string().optional(),
authorities: z.array(authorityEnum).optional(),
projectSlugs: z.array(BaseProjectSchema.shape.slug).optional()
})

export const CreateWorkspaceRoleResponseSchema = WorkspaceRoleSchema

export const UpdateWorkspaceRoleRequestSchema =
CreateWorkspaceRoleRequestSchema.partial().extend({
workspaceRoleSlug: WorkspaceRoleSchema.shape.slug
})

export const UpdateWorkspaceRoleResponseSchema = WorkspaceRoleSchema

export const DeleteWorkspaceRoleRequestSchema = z.object({
workspaceRoleSlug: WorkspaceRoleSchema.shape.slug
})

export const DeleteWorkspaceRoleResponseSchema = z.void()

export const CheckWorkspaceRoleExistsRequestSchema = z.object({
workspaceSlug: WorkspaceSchema.shape.slug,
workspaceRoleName: WorkspaceRoleSchema.shape.name
})

export const CheckWorkspaceRoleExistsResponseSchema = z.object({
exists: z.boolean()
})

export const GetWorkspaceRoleRequestSchema = z.object({
workspaceRoleSlug: WorkspaceRoleSchema.shape.slug
})

export const GetWorkspaceRoleResponseSchema = WorkspaceRoleSchema

export const GetWorkspaceRolesOfWorkspaceRequestSchema =
PageRequestSchema.merge(
z.object({
workspaceSlug: WorkspaceSchema.shape.slug
})
)

export const GetWorkspaceRolesOfWorkspaceResponseSchema = PageResponseSchema(
WorkspaceRoleSchema.omit({ projects: true })
)
67 changes: 67 additions & 0 deletions packages/schema/src/workspace-role/index.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { z } from 'zod'

import {
WorkspaceRoleSchema,
CreateWorkspaceRoleRequestSchema,
CreateWorkspaceRoleResponseSchema,
UpdateWorkspaceRoleRequestSchema,
UpdateWorkspaceRoleResponseSchema,
DeleteWorkspaceRoleRequestSchema,
DeleteWorkspaceRoleResponseSchema,
CheckWorkspaceRoleExistsRequestSchema,
CheckWorkspaceRoleExistsResponseSchema,
GetWorkspaceRoleRequestSchema,
GetWorkspaceRoleResponseSchema,
GetWorkspaceRolesOfWorkspaceRequestSchema,
GetWorkspaceRolesOfWorkspaceResponseSchema
} from './'

export type WorkspaceRole = z.infer<typeof WorkspaceRoleSchema>

export type CreateWorkspaceRoleRequest = z.infer<
typeof CreateWorkspaceRoleRequestSchema
>

export type CreateWorkspaceRoleResponse = z.infer<
typeof CreateWorkspaceRoleResponseSchema
>

export type UpdateWorkspaceRoleRequest = z.infer<
typeof UpdateWorkspaceRoleRequestSchema
>

export type UpdateWorkspaceRoleResponse = z.infer<
typeof UpdateWorkspaceRoleResponseSchema
>

export type DeleteWorkspaceRoleRequest = z.infer<
typeof DeleteWorkspaceRoleRequestSchema
>

export type DeleteWorkspaceRoleResponse = z.infer<
typeof DeleteWorkspaceRoleResponseSchema
>

export type CheckWorkspaceRoleExistsRequest = z.infer<
typeof CheckWorkspaceRoleExistsRequestSchema
>

export type CheckWorkspaceRoleExistsResponse = z.infer<
typeof CheckWorkspaceRoleExistsResponseSchema
>

export type GetWorkspaceRoleRequest = z.infer<
typeof GetWorkspaceRoleRequestSchema
>

export type GetWorkspaceRoleResponse = z.infer<
typeof GetWorkspaceRoleResponseSchema
>

export type GetWorkspaceRolesOfWorkspaceRequest = z.infer<
typeof GetWorkspaceRolesOfWorkspaceRequestSchema
>

export type GetWorkspaceRolesOfWorkspaceResponse = z.infer<
typeof GetWorkspaceRolesOfWorkspaceResponseSchema
>
1 change: 0 additions & 1 deletion packages/schema/tests/enums.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { z } from 'zod'
import {
integrationTypeEnum,
expiresAfterEnum,
Expand Down
Loading