-
Notifications
You must be signed in to change notification settings - Fork 307
Expand file tree
/
Copy pathpublicApiSchemas.ts
More file actions
113 lines (100 loc) · 5.29 KB
/
Copy pathpublicApiSchemas.ts
File metadata and controls
113 lines (100 loc) · 5.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
import z from 'zod';
import {
findRelatedSymbolsRequestSchema,
findRelatedSymbolsResponseSchema,
} from '../features/codeNav/types.js';
import {
commitAuthorSchema,
commitDetailSchema,
commitSchema,
fileBlameRequestSchema,
fileBlameResponseSchema,
fileSourceRequestSchema,
fileSourceResponseSchema,
getCommitQueryParamsSchema,
getDiffRequestSchema,
getDiffResponseSchema,
getTreeRequestSchema,
listCommitAuthorsQueryParamsSchema,
listCommitsQueryParamsSchema,
} from '../features/git/schemas.js';
import {
searchRequestSchema,
searchResponseSchema,
} from '../features/search/types.js';
import { serviceErrorSchema } from '../lib/serviceError.js';
import { getVersionResponseSchema, listReposQueryParamsSchema, listReposResponseSchema } from '../lib/schemas.js';
let hasExtendedZod = false;
if (!hasExtendedZod) {
extendZodWithOpenApi(z);
hasExtendedZod = true;
}
export const publicServiceErrorSchema = serviceErrorSchema.openapi('PublicApiServiceError', {
description: 'Structured error response returned by Sourcebot public API endpoints.',
});
export const publicSearchRequestSchema = searchRequestSchema.openapi('PublicSearchRequest');
export const publicSearchResponseSchema = searchResponseSchema.openapi('PublicSearchResponse');
export const publicGetTreeRequestSchema = getTreeRequestSchema.openapi('PublicGetTreeRequest');
export const publicFileSourceRequestSchema = fileSourceRequestSchema.openapi('PublicFileSourceRequest');
export const publicFileSourceResponseSchema = fileSourceResponseSchema.openapi('PublicFileSourceResponse');
export const publicFileBlameRequestSchema = fileBlameRequestSchema.openapi('PublicFileBlameRequest');
export const publicFileBlameResponseSchema = fileBlameResponseSchema.openapi('PublicFileBlameResponse');
export const publicVersionResponseSchema = getVersionResponseSchema.openapi('PublicVersionResponse');
export const publicListReposQueryParamsSchema = listReposQueryParamsSchema.openapi('PublicListReposQuery');
export const publicListReposResponseSchema = listReposResponseSchema.openapi('PublicListReposResponse');
export const publicGetDiffRequestSchema = getDiffRequestSchema.openapi('PublicGetDiffRequest');
export const publicGetDiffResponseSchema = getDiffResponseSchema.openapi('PublicGetDiffResponse');
export const publicFindSymbolsRequestSchema = findRelatedSymbolsRequestSchema.openapi('PublicFindSymbolsRequest');
export const publicFindSymbolsResponseSchema = findRelatedSymbolsResponseSchema.openapi('PublicFindSymbolsResponse');
export const publicListCommitsQuerySchema = listCommitsQueryParamsSchema.openapi('PublicListCommitsQuery');
export const publicCommitSchema = commitSchema.openapi('PublicCommit');
export const publicListCommitsResponseSchema = z.array(publicCommitSchema).openapi('PublicListCommitsResponse');
export const publicGetCommitQuerySchema = getCommitQueryParamsSchema.openapi('PublicGetCommitQuery');
export const publicCommitDetailSchema = commitDetailSchema.openapi('PublicCommitDetail');
export const publicListCommitAuthorsQuerySchema = listCommitAuthorsQueryParamsSchema.openapi('PublicListCommitAuthorsQuery');
export const publicCommitAuthorSchema = commitAuthorSchema.openapi('PublicCommitAuthor');
export const publicListCommitAuthorsResponseSchema = z.array(publicCommitAuthorSchema).openapi('PublicListCommitAuthorsResponse');
export const publicHealthResponseSchema = z.object({
status: z.enum(['ok']),
}).openapi('PublicHealthResponse');
// EE: User Management
export const publicEeUserSchema = z.object({
name: z.string().nullable(),
email: z.string(),
createdAt: z.string().datetime(),
updatedAt: z.string().datetime(),
}).openapi('PublicEeUser');
export const publicEeUserListItemSchema = z.object({
id: z.string(),
name: z.string().nullable(),
email: z.string(),
role: z.enum(['OWNER', 'MEMBER']),
createdAt: z.string().datetime(),
lastActivityAt: z.string().datetime().nullable(),
}).openapi('PublicEeUserListItem');
export const publicEeUsersResponseSchema = z.array(publicEeUserListItemSchema).openapi('PublicEeUsersResponse');
export const publicEeDeleteUserResponseSchema = z.object({
success: z.boolean(),
message: z.string(),
}).openapi('PublicEeDeleteUserResponse');
// EE: Audit
export const publicEeAuditQuerySchema = z.object({
since: z.string().datetime().optional().describe('Return records at or after this timestamp (ISO 8601).'),
until: z.string().datetime().optional().describe('Return records at or before this timestamp (ISO 8601).'),
page: z.coerce.number().int().positive().default(1),
perPage: z.coerce.number().int().positive().max(100).default(50),
}).openapi('PublicEeAuditQuery');
export const publicEeAuditRecordSchema = z.object({
id: z.string(),
timestamp: z.string().datetime(),
action: z.string().describe('The audited action (e.g. `user.read`, `user.delete`, `audit.fetch`).'),
actorId: z.string(),
actorType: z.string(),
targetId: z.string(),
targetType: z.string(),
sourcebotVersion: z.string(),
metadata: z.record(z.unknown()).nullable(),
orgId: z.number(),
}).openapi('PublicEeAuditRecord');
export const publicEeAuditResponseSchema = z.array(publicEeAuditRecordSchema).openapi('PublicEeAuditResponse');