@locusai/shared 0.1.7 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/schemas.d.ts +154 -9
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +73 -1
- package/package.json +1 -1
- package/src/common.ts +106 -0
- package/src/enums.ts +56 -0
- package/src/index.ts +3 -2
- package/src/models/activity.ts +237 -0
- package/src/models/agent.ts +13 -0
- package/src/models/auth.ts +188 -0
- package/src/models/ci.ts +21 -0
- package/src/models/doc-group.ts +42 -0
- package/src/models/doc.ts +66 -0
- package/src/models/index.ts +12 -0
- package/src/models/invitation.ts +83 -0
- package/src/models/organization.ts +105 -0
- package/src/models/sprint.ts +71 -0
- package/src/models/task.ts +110 -0
- package/src/models/user.ts +35 -0
- package/src/models/workspace.ts +90 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/schemas.ts +0 -69
- package/src/types.ts +0 -112
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { BaseEntitySchema } from "../common";
|
|
3
|
+
import { EventType, SprintStatus, TaskStatus } from "../enums";
|
|
4
|
+
|
|
5
|
+
export const CommentSchema = BaseEntitySchema.extend({
|
|
6
|
+
taskId: z.string().uuid(),
|
|
7
|
+
author: z.string().min(1),
|
|
8
|
+
text: z.string().min(1),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export type Comment = z.infer<typeof CommentSchema>;
|
|
12
|
+
|
|
13
|
+
export const ArtifactSchema = BaseEntitySchema.extend({
|
|
14
|
+
taskId: z.string().uuid(),
|
|
15
|
+
type: z.string().min(1),
|
|
16
|
+
title: z.string().min(1),
|
|
17
|
+
contentText: z.string().optional(),
|
|
18
|
+
filePath: z.string().optional(),
|
|
19
|
+
url: z.string().optional(),
|
|
20
|
+
size: z.string().optional(),
|
|
21
|
+
createdBy: z.string().min(1),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export type Artifact = z.infer<typeof ArtifactSchema>;
|
|
25
|
+
|
|
26
|
+
// ============================================================================
|
|
27
|
+
// Event Payloads
|
|
28
|
+
// ============================================================================
|
|
29
|
+
|
|
30
|
+
export const TaskCreatedPayloadSchema = z.object({
|
|
31
|
+
title: z.string(),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const TaskDeletedPayloadSchema = z.object({
|
|
35
|
+
title: z.string(),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export const StatusChangedPayloadSchema = z.object({
|
|
39
|
+
title: z.string(),
|
|
40
|
+
oldStatus: z.nativeEnum(TaskStatus),
|
|
41
|
+
newStatus: z.nativeEnum(TaskStatus),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export const CommentAddedPayloadSchema = z.object({
|
|
45
|
+
title: z.string(),
|
|
46
|
+
author: z.string(),
|
|
47
|
+
text: z.string(),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export const WorkspaceCreatedPayloadSchema = z.object({
|
|
51
|
+
name: z.string(),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export const MemberAddedPayloadSchema = z.object({
|
|
55
|
+
userId: z.string(),
|
|
56
|
+
role: z.string(),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export const MemberInvitedPayloadSchema = z.object({
|
|
60
|
+
email: z.string(),
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export const SprintCreatedPayloadSchema = z.object({
|
|
64
|
+
name: z.string(),
|
|
65
|
+
sprintId: z.string().uuid(),
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export const SprintStatusChangedPayloadSchema = z.object({
|
|
69
|
+
name: z.string(),
|
|
70
|
+
sprintId: z.string().uuid(),
|
|
71
|
+
oldStatus: z.nativeEnum(SprintStatus),
|
|
72
|
+
newStatus: z.nativeEnum(SprintStatus),
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export const ChecklistInitializedPayloadSchema = z.object({
|
|
76
|
+
itemCount: z.number(),
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
export const CiRanPayloadSchema = z.object({
|
|
80
|
+
preset: z.string(),
|
|
81
|
+
ok: z.boolean(),
|
|
82
|
+
summary: z.string(),
|
|
83
|
+
source: z.string(),
|
|
84
|
+
deferred: z.boolean(),
|
|
85
|
+
processed: z.boolean(),
|
|
86
|
+
commands: z.array(z.object({ cmd: z.string(), exitCode: z.number() })),
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
export const EventPayloadSchema = z.discriminatedUnion("type", [
|
|
90
|
+
z.object({
|
|
91
|
+
type: z.literal(EventType.TASK_CREATED),
|
|
92
|
+
payload: TaskCreatedPayloadSchema,
|
|
93
|
+
}),
|
|
94
|
+
z.object({
|
|
95
|
+
type: z.literal(EventType.TASK_DELETED),
|
|
96
|
+
payload: TaskDeletedPayloadSchema,
|
|
97
|
+
}),
|
|
98
|
+
z.object({
|
|
99
|
+
type: z.literal(EventType.STATUS_CHANGED),
|
|
100
|
+
payload: StatusChangedPayloadSchema,
|
|
101
|
+
}),
|
|
102
|
+
z.object({
|
|
103
|
+
type: z.literal(EventType.COMMENT_ADDED),
|
|
104
|
+
payload: CommentAddedPayloadSchema,
|
|
105
|
+
}),
|
|
106
|
+
z.object({
|
|
107
|
+
type: z.literal(EventType.WORKSPACE_CREATED),
|
|
108
|
+
payload: WorkspaceCreatedPayloadSchema,
|
|
109
|
+
}),
|
|
110
|
+
z.object({
|
|
111
|
+
type: z.literal(EventType.MEMBER_ADDED),
|
|
112
|
+
payload: MemberAddedPayloadSchema,
|
|
113
|
+
}),
|
|
114
|
+
z.object({
|
|
115
|
+
type: z.literal(EventType.MEMBER_INVITED),
|
|
116
|
+
payload: MemberInvitedPayloadSchema,
|
|
117
|
+
}),
|
|
118
|
+
z.object({
|
|
119
|
+
type: z.literal(EventType.SPRINT_CREATED),
|
|
120
|
+
payload: SprintCreatedPayloadSchema,
|
|
121
|
+
}),
|
|
122
|
+
z.object({
|
|
123
|
+
type: z.literal(EventType.SPRINT_STATUS_CHANGED),
|
|
124
|
+
payload: SprintStatusChangedPayloadSchema,
|
|
125
|
+
}),
|
|
126
|
+
z.object({
|
|
127
|
+
type: z.literal(EventType.CHECKLIST_INITIALIZED),
|
|
128
|
+
payload: ChecklistInitializedPayloadSchema,
|
|
129
|
+
}),
|
|
130
|
+
z.object({
|
|
131
|
+
type: z.literal(EventType.CI_RAN),
|
|
132
|
+
payload: CiRanPayloadSchema,
|
|
133
|
+
}),
|
|
134
|
+
]);
|
|
135
|
+
|
|
136
|
+
export type EventPayload = z.infer<typeof EventPayloadSchema>;
|
|
137
|
+
|
|
138
|
+
export const EventSchema = z.object({
|
|
139
|
+
id: z.string(),
|
|
140
|
+
workspaceId: z.string(),
|
|
141
|
+
taskId: z.string().uuid().optional().nullable(),
|
|
142
|
+
userId: z.string().optional().nullable(),
|
|
143
|
+
type: z.nativeEnum(EventType),
|
|
144
|
+
payload: z.record(z.string(), z.unknown()),
|
|
145
|
+
createdAt: z.union([z.date(), z.number()]),
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
export type Event = z.infer<typeof EventSchema>;
|
|
149
|
+
|
|
150
|
+
// ============================================================================
|
|
151
|
+
// Parameter & Query Schemas
|
|
152
|
+
// ============================================================================
|
|
153
|
+
|
|
154
|
+
export const ArtifactParamSchema = z.object({
|
|
155
|
+
taskId: z.string().uuid("Invalid Task ID"),
|
|
156
|
+
type: z.string().min(1, "Artifact type required"),
|
|
157
|
+
filename: z.string().min(1, "Filename required"),
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
export type ArtifactParam = z.infer<typeof ArtifactParamSchema>;
|
|
161
|
+
|
|
162
|
+
export const TaskIdOnlyParamSchema = z.object({
|
|
163
|
+
taskId: z.string().uuid("Invalid Task ID"),
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
export type TaskIdOnlyParam = z.infer<typeof TaskIdOnlyParamSchema>;
|
|
167
|
+
|
|
168
|
+
export const EventQuerySchema = z.object({
|
|
169
|
+
taskId: z.string().uuid("Invalid Task ID").optional(),
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
export type EventQuery = z.infer<typeof EventQuerySchema>;
|
|
173
|
+
|
|
174
|
+
export const EventResponseSchema = z.object({
|
|
175
|
+
event: EventSchema,
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
export type EventResponse = z.infer<typeof EventResponseSchema>;
|
|
179
|
+
|
|
180
|
+
export const EventsResponseSchema = z.object({
|
|
181
|
+
events: z.array(EventSchema),
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
export type EventsResponse = z.infer<typeof EventsResponseSchema>;
|
|
185
|
+
|
|
186
|
+
export const ActivityResponseSchema = z.object({
|
|
187
|
+
activity: z.array(EventSchema),
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
export type ActivityResponse = z.infer<typeof ActivityResponseSchema>;
|
|
191
|
+
|
|
192
|
+
export const CommentResponseSchema = z.object({
|
|
193
|
+
comment: CommentSchema,
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
export type CommentResponse = z.infer<typeof CommentResponseSchema>;
|
|
197
|
+
|
|
198
|
+
// ============================================================================
|
|
199
|
+
// Response Schemas
|
|
200
|
+
// ============================================================================
|
|
201
|
+
|
|
202
|
+
export const ArtifactResponseSchema = z.object({
|
|
203
|
+
artifact: ArtifactSchema,
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
export type ArtifactResponse = z.infer<typeof ArtifactResponseSchema>;
|
|
207
|
+
|
|
208
|
+
export const ArtifactsResponseSchema = z.object({
|
|
209
|
+
artifacts: z.array(ArtifactSchema),
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
export type ArtifactsResponse = z.infer<typeof ArtifactsResponseSchema>;
|
|
213
|
+
|
|
214
|
+
export const CreateArtifactSchema = z.object({
|
|
215
|
+
taskId: z.string().uuid(),
|
|
216
|
+
type: z.string().min(1),
|
|
217
|
+
title: z.string().min(1),
|
|
218
|
+
contentText: z.string().optional(),
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
export type CreateArtifact = z.infer<typeof CreateArtifactSchema>;
|
|
222
|
+
|
|
223
|
+
export const ReportCiResultSchema = z.object({
|
|
224
|
+
workspaceId: z.string().uuid(),
|
|
225
|
+
taskId: z.string().uuid().optional(),
|
|
226
|
+
preset: z.string(),
|
|
227
|
+
ok: z.boolean(),
|
|
228
|
+
summary: z.string(),
|
|
229
|
+
commands: z.array(
|
|
230
|
+
z.object({
|
|
231
|
+
cmd: z.string(),
|
|
232
|
+
exitCode: z.number(),
|
|
233
|
+
})
|
|
234
|
+
),
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
export type ReportCiResult = z.infer<typeof ReportCiResultSchema>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const LockSchema = z.object({
|
|
4
|
+
agentId: z.string().min(1),
|
|
5
|
+
ttlSeconds: z.number().positive(),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export const UnlockSchema = z.object({
|
|
9
|
+
agentId: z.string().min(1),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export type Lock = z.infer<typeof LockSchema>;
|
|
13
|
+
export type Unlock = z.infer<typeof UnlockSchema>;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication Models and Schemas
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { UserRole } from "../enums";
|
|
7
|
+
import { UserSchema } from "./user";
|
|
8
|
+
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// Authenticated User Types (for request context)
|
|
11
|
+
// ============================================================================
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* User authenticated via JWT (web dashboard)
|
|
15
|
+
*/
|
|
16
|
+
export const JwtAuthUserSchema = z.object({
|
|
17
|
+
authType: z.literal("jwt"),
|
|
18
|
+
id: z.string().uuid(),
|
|
19
|
+
email: z.string().email(),
|
|
20
|
+
name: z.string(),
|
|
21
|
+
role: z.nativeEnum(UserRole),
|
|
22
|
+
orgId: z.string().uuid().nullable().optional(),
|
|
23
|
+
workspaceId: z.string().uuid().nullable().optional(),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export type JwtAuthUser = z.infer<typeof JwtAuthUserSchema>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* User authenticated via API Key (CLI/agents)
|
|
30
|
+
* Note: API keys don't have a real user ID - they represent organization-level access
|
|
31
|
+
*/
|
|
32
|
+
export const ApiKeyAuthUserSchema = z.object({
|
|
33
|
+
authType: z.literal("api_key"),
|
|
34
|
+
apiKeyId: z.string().uuid(),
|
|
35
|
+
apiKeyName: z.string(),
|
|
36
|
+
orgId: z.string().uuid(),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export type ApiKeyAuthUser = z.infer<typeof ApiKeyAuthUserSchema>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Union type for any authenticated request
|
|
43
|
+
*/
|
|
44
|
+
export const AuthenticatedUserSchema = z.discriminatedUnion("authType", [
|
|
45
|
+
JwtAuthUserSchema,
|
|
46
|
+
ApiKeyAuthUserSchema,
|
|
47
|
+
]);
|
|
48
|
+
|
|
49
|
+
export type AuthenticatedUser = z.infer<typeof AuthenticatedUserSchema>;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Type guard to check if user is JWT authenticated
|
|
53
|
+
*/
|
|
54
|
+
export function isJwtUser(user: AuthenticatedUser): user is JwtAuthUser {
|
|
55
|
+
return user.authType === "jwt";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Type guard to check if user is API key authenticated
|
|
60
|
+
*/
|
|
61
|
+
export function isApiKeyUser(user: AuthenticatedUser): user is ApiKeyAuthUser {
|
|
62
|
+
return user.authType === "api_key";
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get the user ID for event logging. Returns null for API key users.
|
|
67
|
+
* Use this when you need to store a reference to the user in the database.
|
|
68
|
+
*/
|
|
69
|
+
export function getAuthUserId(user: AuthenticatedUser): string | null {
|
|
70
|
+
return isJwtUser(user) ? user.id : null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ============================================================================
|
|
74
|
+
// Auth Responses
|
|
75
|
+
// ============================================================================
|
|
76
|
+
|
|
77
|
+
export const AuthResponseSchema = z.object({
|
|
78
|
+
token: z.string(),
|
|
79
|
+
user: UserSchema,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
export type AuthResponse = z.infer<typeof AuthResponseSchema>;
|
|
83
|
+
export type LoginResponse = AuthResponse;
|
|
84
|
+
|
|
85
|
+
// ============================================================================
|
|
86
|
+
// OTP-Based Auth (Cloud)
|
|
87
|
+
// ============================================================================
|
|
88
|
+
|
|
89
|
+
export const OtpRequestSchema = z.object({
|
|
90
|
+
email: z.string().email("Invalid email address"),
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
export type OtpRequest = z.infer<typeof OtpRequestSchema>;
|
|
94
|
+
|
|
95
|
+
export const VerifyOtpSchema = z.object({
|
|
96
|
+
email: z.string().email("Invalid email address"),
|
|
97
|
+
otp: z.string().length(6, "Verification code must be 6 digits"),
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
export type VerifyOtp = z.infer<typeof VerifyOtpSchema>;
|
|
101
|
+
|
|
102
|
+
export const CompleteRegistrationSchema = z.object({
|
|
103
|
+
email: z.string().email("Invalid email address"),
|
|
104
|
+
otp: z.string().length(6, "Verification code must be 6 digits"),
|
|
105
|
+
name: z.string().min(1, "Name is required").max(100),
|
|
106
|
+
companyName: z.string().max(100).optional(),
|
|
107
|
+
teamSize: z.enum(["solo", "2-10", "11-50", "51-200", "200+"]).optional(),
|
|
108
|
+
userRole: z
|
|
109
|
+
.enum(["developer", "designer", "product_manager", "other"])
|
|
110
|
+
.optional(),
|
|
111
|
+
workspaceName: z.string().max(100).optional(),
|
|
112
|
+
invitedEmails: z.array(z.string().email()).optional(),
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
export type CompleteRegistration = z.infer<typeof CompleteRegistrationSchema>;
|
|
116
|
+
|
|
117
|
+
// ============================================================================
|
|
118
|
+
// Internal Context & API Keys
|
|
119
|
+
// ============================================================================
|
|
120
|
+
|
|
121
|
+
export const JWTPayloadSchema = z.object({
|
|
122
|
+
sub: z.string(), // User ID
|
|
123
|
+
email: z.string().email(),
|
|
124
|
+
name: z.string(),
|
|
125
|
+
role: z.string(),
|
|
126
|
+
orgId: z.string().uuid().optional(),
|
|
127
|
+
iat: z.number(),
|
|
128
|
+
exp: z.number(),
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
export type JWTPayload = z.infer<typeof JWTPayloadSchema>;
|
|
132
|
+
|
|
133
|
+
export const AuthContextSchema = z.object({
|
|
134
|
+
userId: z.string(),
|
|
135
|
+
email: z.string().email(),
|
|
136
|
+
name: z.string(),
|
|
137
|
+
role: z.string(),
|
|
138
|
+
orgId: z.string().uuid().optional(),
|
|
139
|
+
workspaceId: z.string().uuid().optional(),
|
|
140
|
+
authType: z.enum(["jwt", "api_key", "local"]),
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
export type AuthContext = z.infer<typeof AuthContextSchema>;
|
|
144
|
+
|
|
145
|
+
export const APIKeySchema = z.object({
|
|
146
|
+
id: z.string(),
|
|
147
|
+
name: z.string(),
|
|
148
|
+
keyPrefix: z.string(),
|
|
149
|
+
workspaceId: z.string(),
|
|
150
|
+
lastUsedAt: z.number().nullable(),
|
|
151
|
+
createdAt: z.number(),
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
export type APIKey = z.infer<typeof APIKeySchema>;
|
|
155
|
+
|
|
156
|
+
export const APIKeyCreateResponseSchema = z.object({
|
|
157
|
+
id: z.string(),
|
|
158
|
+
name: z.string(),
|
|
159
|
+
keyPrefix: z.string(),
|
|
160
|
+
key: z.string(),
|
|
161
|
+
createdAt: z.number(),
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
export type APIKeyCreateResponse = z.infer<typeof APIKeyCreateResponseSchema>;
|
|
165
|
+
|
|
166
|
+
// ============================================================================
|
|
167
|
+
// Parameter & Query Schemas
|
|
168
|
+
// ============================================================================
|
|
169
|
+
|
|
170
|
+
export const ApiKeyIdParamSchema = z.object({
|
|
171
|
+
id: z.string().uuid("Invalid API Key ID"),
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
export type ApiKeyIdParam = z.infer<typeof ApiKeyIdParamSchema>;
|
|
175
|
+
|
|
176
|
+
export const ApiKeyQuerySchema = z.object({
|
|
177
|
+
workspaceId: z.string().uuid("Invalid Workspace ID").optional(),
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
export type ApiKeyQuery = z.infer<typeof ApiKeyQuerySchema>;
|
|
181
|
+
|
|
182
|
+
export const CreateApiKeySchema = z.object({
|
|
183
|
+
workspaceId: z.string().uuid("Invalid Workspace ID").optional(),
|
|
184
|
+
name: z.string().min(1, "Name is required").max(100),
|
|
185
|
+
expiresInDays: z.number().int().positive().optional(),
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
export type CreateApiKey = z.infer<typeof CreateApiKeySchema>;
|
package/src/models/ci.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const RecordCiSchema = z.object({
|
|
4
|
+
taskId: z.string().uuid(),
|
|
5
|
+
workspaceId: z.string().uuid(),
|
|
6
|
+
result: z.object({
|
|
7
|
+
ok: z.boolean(),
|
|
8
|
+
summary: z.string(),
|
|
9
|
+
commands: z.array(
|
|
10
|
+
z.object({
|
|
11
|
+
cmd: z.string(),
|
|
12
|
+
exitCode: z.number(),
|
|
13
|
+
durationMs: z.number().optional(),
|
|
14
|
+
error: z.string().optional(),
|
|
15
|
+
})
|
|
16
|
+
),
|
|
17
|
+
preset: z.string(),
|
|
18
|
+
}),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export type RecordCi = z.infer<typeof RecordCiSchema>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { BaseEntitySchema } from "../common";
|
|
3
|
+
|
|
4
|
+
export const DocGroupSchema = BaseEntitySchema.extend({
|
|
5
|
+
workspaceId: z.string().uuid(),
|
|
6
|
+
name: z.string().min(1, "Name is required"),
|
|
7
|
+
order: z.number().default(0),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export type DocGroup = z.infer<typeof DocGroupSchema>;
|
|
11
|
+
|
|
12
|
+
export const CreateDocGroupSchema = z.object({
|
|
13
|
+
name: z.string().min(1, "Name is required"),
|
|
14
|
+
order: z.number().optional(),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export type CreateDocGroup = z.infer<typeof CreateDocGroupSchema>;
|
|
18
|
+
|
|
19
|
+
export const UpdateDocGroupSchema = z.object({
|
|
20
|
+
name: z.string().min(1).optional(),
|
|
21
|
+
order: z.number().optional(),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export type UpdateDocGroup = z.infer<typeof UpdateDocGroupSchema>;
|
|
25
|
+
|
|
26
|
+
export const DocGroupResponseSchema = z.object({
|
|
27
|
+
group: DocGroupSchema,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export type DocGroupResponse = z.infer<typeof DocGroupResponseSchema>;
|
|
31
|
+
|
|
32
|
+
export const DocGroupsResponseSchema = z.object({
|
|
33
|
+
groups: z.array(DocGroupSchema),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export type DocGroupsResponse = z.infer<typeof DocGroupsResponseSchema>;
|
|
37
|
+
|
|
38
|
+
export const DocGroupIdParamSchema = z.object({
|
|
39
|
+
id: z.string().uuid("Invalid Group ID"),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export type DocGroupIdParam = z.infer<typeof DocGroupIdParamSchema>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { BaseEntitySchema } from "../common";
|
|
3
|
+
|
|
4
|
+
// Forward declaration for circular reference
|
|
5
|
+
export const DocGroupSchemaForDoc = z.object({
|
|
6
|
+
id: z.string().uuid(),
|
|
7
|
+
name: z.string(),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export const DocSchema = BaseEntitySchema.extend({
|
|
11
|
+
workspaceId: z.string().uuid(),
|
|
12
|
+
groupId: z.string().uuid().nullable().optional(),
|
|
13
|
+
title: z.string().min(1, "Title is required"),
|
|
14
|
+
content: z.string().default(""),
|
|
15
|
+
group: DocGroupSchemaForDoc.nullable().optional(),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export type Doc = z.infer<typeof DocSchema>;
|
|
19
|
+
|
|
20
|
+
export const CreateDocSchema = z.object({
|
|
21
|
+
title: z.string().min(1, "Title is required"),
|
|
22
|
+
content: z.string().optional(),
|
|
23
|
+
groupId: z.string().uuid().optional(),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export type CreateDoc = z.infer<typeof CreateDocSchema>;
|
|
27
|
+
|
|
28
|
+
export const UpdateDocSchema = z.object({
|
|
29
|
+
title: z.string().min(1).optional(),
|
|
30
|
+
content: z.string().optional(),
|
|
31
|
+
groupId: z.string().uuid().nullable().optional(),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export type UpdateDoc = z.infer<typeof UpdateDocSchema>;
|
|
35
|
+
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// Response Schemas
|
|
38
|
+
// ============================================================================
|
|
39
|
+
|
|
40
|
+
export const DocResponseSchema = z.object({
|
|
41
|
+
doc: DocSchema,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export type DocResponse = z.infer<typeof DocResponseSchema>;
|
|
45
|
+
|
|
46
|
+
export const DocsResponseSchema = z.object({
|
|
47
|
+
docs: z.array(DocSchema),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export type DocsResponse = z.infer<typeof DocsResponseSchema>;
|
|
51
|
+
|
|
52
|
+
// ============================================================================
|
|
53
|
+
// Parameter & Query Schemas
|
|
54
|
+
// ============================================================================
|
|
55
|
+
|
|
56
|
+
export const DocIdParamSchema = z.object({
|
|
57
|
+
id: z.string().uuid("Invalid Doc ID"),
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export type DocIdParam = z.infer<typeof DocIdParamSchema>;
|
|
61
|
+
|
|
62
|
+
export const DocQuerySchema = z.object({
|
|
63
|
+
workspaceId: z.string().uuid("Invalid Workspace ID").optional(),
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export type DocQuery = z.infer<typeof DocQuerySchema>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from "./activity";
|
|
2
|
+
export * from "./agent";
|
|
3
|
+
export * from "./auth";
|
|
4
|
+
export * from "./ci";
|
|
5
|
+
export * from "./doc";
|
|
6
|
+
export * from "./doc-group";
|
|
7
|
+
export * from "./invitation";
|
|
8
|
+
export * from "./organization";
|
|
9
|
+
export * from "./sprint";
|
|
10
|
+
export * from "./task";
|
|
11
|
+
export * from "./user";
|
|
12
|
+
export * from "./workspace";
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { BaseEntitySchema } from "../common";
|
|
3
|
+
import { MembershipRole } from "../enums";
|
|
4
|
+
|
|
5
|
+
export const InvitationSchema = BaseEntitySchema.extend({
|
|
6
|
+
orgId: z.string().uuid("Invalid Organization ID"),
|
|
7
|
+
email: z.string().email("Invalid email address"),
|
|
8
|
+
role: z.nativeEnum(MembershipRole),
|
|
9
|
+
token: z.string(),
|
|
10
|
+
expiresAt: z.number(),
|
|
11
|
+
acceptedAt: z.number().nullable().optional(),
|
|
12
|
+
invitedBy: z.string().uuid(),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export type Invitation = z.infer<typeof InvitationSchema>;
|
|
16
|
+
|
|
17
|
+
export const CreateInvitationSchema = z.object({
|
|
18
|
+
orgId: z.string().uuid("Invalid Organization ID"),
|
|
19
|
+
email: z.string().email("Invalid email address"),
|
|
20
|
+
role: z.nativeEnum(MembershipRole).default(MembershipRole.MEMBER),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export type CreateInvitation = z.infer<typeof CreateInvitationSchema>;
|
|
24
|
+
|
|
25
|
+
export const AcceptInvitationSchema = z.object({
|
|
26
|
+
token: z.string().min(1, "Invitation token is required"),
|
|
27
|
+
name: z.string().min(1, "Name is required").optional(),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export type AcceptInvitation = z.infer<typeof AcceptInvitationSchema>;
|
|
31
|
+
|
|
32
|
+
// ============================================================================
|
|
33
|
+
// Parameter & Query Schemas
|
|
34
|
+
// ============================================================================
|
|
35
|
+
|
|
36
|
+
export const InvitationIdParamSchema = z.object({
|
|
37
|
+
id: z.string().uuid("Invalid Invitation ID"),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export type InvitationIdParam = z.infer<typeof InvitationIdParamSchema>;
|
|
41
|
+
|
|
42
|
+
export const InvitationVerifyParamSchema = z.object({
|
|
43
|
+
token: z.string().min(1, "Token required"),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export type InvitationVerifyParam = z.infer<typeof InvitationVerifyParamSchema>;
|
|
47
|
+
|
|
48
|
+
export const InvitationQuerySchema = z.object({
|
|
49
|
+
orgId: z.string().uuid("Invalid Organization ID").optional(),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export type InvitationQuery = z.infer<typeof InvitationQuerySchema>;
|
|
53
|
+
|
|
54
|
+
// ============================================================================
|
|
55
|
+
// Response Schemas
|
|
56
|
+
// ============================================================================
|
|
57
|
+
|
|
58
|
+
export const InvitationResponseSchema = z.object({
|
|
59
|
+
invitation: InvitationSchema,
|
|
60
|
+
userExists: z.boolean().optional(),
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export type InvitationResponse = z.infer<typeof InvitationResponseSchema>;
|
|
64
|
+
|
|
65
|
+
export const InvitationsResponseSchema = z.object({
|
|
66
|
+
invitations: z.array(InvitationSchema),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
export type InvitationsResponse = z.infer<typeof InvitationsResponseSchema>;
|
|
70
|
+
|
|
71
|
+
export const AcceptInvitationResponseSchema = z.object({
|
|
72
|
+
membership: z.object({
|
|
73
|
+
id: z.string().uuid(),
|
|
74
|
+
userId: z.string().uuid(),
|
|
75
|
+
orgId: z.string().uuid(),
|
|
76
|
+
role: z.nativeEnum(MembershipRole),
|
|
77
|
+
createdAt: z.number(),
|
|
78
|
+
}),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export type AcceptInvitationResponse = z.infer<
|
|
82
|
+
typeof AcceptInvitationResponseSchema
|
|
83
|
+
>;
|