feat(schema): add version schema
This commit is contained in:
parent
e45d498f56
commit
14f39f47c7
@ -1,3 +1,4 @@
|
|||||||
export * from './general'
|
export * from './general'
|
||||||
export * from './user'
|
export * from './user'
|
||||||
export * from './changelog'
|
export * from './changelog'
|
||||||
|
export * from './version'
|
||||||
|
24
packages/schema/src/version/base.ts
Normal file
24
packages/schema/src/version/base.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import { z } from '@hono/zod-openapi'
|
||||||
|
|
||||||
|
export const VersionOutput = z
|
||||||
|
.object({
|
||||||
|
id: z.string().uuid().openapi({
|
||||||
|
example: '9f00f912-f687-42ef-84d7-efde48ca11ef',
|
||||||
|
}),
|
||||||
|
changelogId: z.string().uuid().openapi({
|
||||||
|
example: '8f00f912-f687-42ef-84d7-efde48ca11ef',
|
||||||
|
}),
|
||||||
|
version: z.string().openapi({
|
||||||
|
example: '1.0.0',
|
||||||
|
}),
|
||||||
|
markdown: z.string().openapi({
|
||||||
|
example: '### Changelog\n\n- Added a new feature',
|
||||||
|
}),
|
||||||
|
releasedAt: z.date().optional().openapi({
|
||||||
|
example: '2024-01-01T00:00:00.000Z',
|
||||||
|
}),
|
||||||
|
status: z.enum(['draft', 'review', 'published']).default('draft').openapi({
|
||||||
|
example: 'draft',
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.openapi('Version')
|
14
packages/schema/src/version/byId.ts
Normal file
14
packages/schema/src/version/byId.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { z } from '@hono/zod-openapi'
|
||||||
|
|
||||||
|
export const VersionByIdParams = z.object({
|
||||||
|
id: z
|
||||||
|
.string()
|
||||||
|
.uuid()
|
||||||
|
.openapi({
|
||||||
|
param: {
|
||||||
|
name: 'id',
|
||||||
|
in: 'path',
|
||||||
|
},
|
||||||
|
example: 'a5ed5965-0506-44e6-aaec-0465ff9fe092',
|
||||||
|
}),
|
||||||
|
})
|
15
packages/schema/src/version/create.ts
Normal file
15
packages/schema/src/version/create.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { z } from '@hono/zod-openapi'
|
||||||
|
import { VersionOutput } from './base'
|
||||||
|
|
||||||
|
export const VersionCreateOutput = VersionOutput
|
||||||
|
export const VersionCreateInput = z
|
||||||
|
.object({
|
||||||
|
changelogId: z.string().uuid(),
|
||||||
|
version: z.string(),
|
||||||
|
releasedAt: z.date().or(z.string()).optional(),
|
||||||
|
status: z.enum(['draft', 'review', 'published']).default('draft'),
|
||||||
|
markdown: z.string(),
|
||||||
|
})
|
||||||
|
.openapi({
|
||||||
|
required: ['changelogId', 'version', 'markdown', 'releasedAt'],
|
||||||
|
})
|
5
packages/schema/src/version/index.ts
Normal file
5
packages/schema/src/version/index.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export * from './base'
|
||||||
|
export * from './byId'
|
||||||
|
export * from './create'
|
||||||
|
export * from './list'
|
||||||
|
export * from './update'
|
4
packages/schema/src/version/list.ts
Normal file
4
packages/schema/src/version/list.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import { z } from '@hono/zod-openapi'
|
||||||
|
import { VersionOutput } from './base'
|
||||||
|
|
||||||
|
export const VersionListOutput = z.array(VersionOutput)
|
20
packages/schema/src/version/update.ts
Normal file
20
packages/schema/src/version/update.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { z } from '@hono/zod-openapi'
|
||||||
|
import { VersionOutput } from './base'
|
||||||
|
|
||||||
|
export const VersionUpdateOutput = VersionOutput
|
||||||
|
export const VersionUpdateInput = z
|
||||||
|
.object({
|
||||||
|
markdown: z.string().optional(),
|
||||||
|
status: z
|
||||||
|
.enum(['draft', 'review', 'published'])
|
||||||
|
.default('draft')
|
||||||
|
.optional(),
|
||||||
|
})
|
||||||
|
.openapi({})
|
||||||
|
export const VersionUpdateParams = z
|
||||||
|
.object({
|
||||||
|
id: z.string().uuid(),
|
||||||
|
})
|
||||||
|
.openapi({
|
||||||
|
required: ['id'],
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user