@teardown/schemas 0.1.41 → 0.1.43
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/package.json +7 -7
- package/src/index.ts +1 -1
- package/src/modules/builds/schemas.ts +7 -5
- package/src/modules/devices/schemas.ts +1 -1
- package/src/modules/identify/schemas.ts +13 -8
- package/src/modules/index.ts +1 -1
- package/src/modules/orgs/schemas.ts +114 -1
- package/src/modules/project-users/schemas.ts +123 -0
- package/src/modules/versions/schemas.ts +7 -4
- package/src/modules/personas/schemas.ts +0 -123
- /package/src/modules/{personas → project-users}/index.ts +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teardown/schemas",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.43",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -48,10 +48,10 @@
|
|
|
48
48
|
"import": "./src/modules/orgs/index.ts",
|
|
49
49
|
"default": "./src/modules/orgs/index.ts"
|
|
50
50
|
},
|
|
51
|
-
"./
|
|
52
|
-
"types": "./src/modules/
|
|
53
|
-
"import": "./src/modules/
|
|
54
|
-
"default": "./src/modules/
|
|
51
|
+
"./project-users": {
|
|
52
|
+
"types": "./src/modules/project-users/index.ts",
|
|
53
|
+
"import": "./src/modules/project-users/index.ts",
|
|
54
|
+
"default": "./src/modules/project-users/index.ts"
|
|
55
55
|
},
|
|
56
56
|
"./projects": {
|
|
57
57
|
"types": "./src/modules/projects/index.ts",
|
|
@@ -93,11 +93,11 @@
|
|
|
93
93
|
},
|
|
94
94
|
"dependencies": {
|
|
95
95
|
"@sinclair/typebox": "^0.34.41",
|
|
96
|
-
"@teardown/types": "0.1.
|
|
96
|
+
"@teardown/types": "0.1.43"
|
|
97
97
|
},
|
|
98
98
|
"devDependencies": {
|
|
99
99
|
"@biomejs/biome": "2.3.8",
|
|
100
|
-
"@teardown/tsconfig": "0.1.
|
|
100
|
+
"@teardown/tsconfig": "0.1.43",
|
|
101
101
|
"typescript": "5.9.3"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -10,7 +10,7 @@ export * from "./modules/events";
|
|
|
10
10
|
export * from "./modules/identify";
|
|
11
11
|
export * from "./modules/me";
|
|
12
12
|
export * from "./modules/orgs";
|
|
13
|
-
export * from "./modules/
|
|
13
|
+
export * from "./modules/project-users";
|
|
14
14
|
export * from "./modules/projects";
|
|
15
15
|
export * from "./modules/sessions";
|
|
16
16
|
export * from "./modules/versions";
|
|
@@ -18,7 +18,7 @@ export const BuildSchema = Type.Object({
|
|
|
18
18
|
version_id: Type.String({ format: "uuid" }),
|
|
19
19
|
build_number: Type.Integer({ minimum: 0 }),
|
|
20
20
|
name: Type.Union([Type.String(), Type.Null()]),
|
|
21
|
-
|
|
21
|
+
notes: Type.Union([Type.String({ maxLength: 500 }), Type.Null()]),
|
|
22
22
|
commit_sha: Type.Union([Type.String(), Type.Null()]),
|
|
23
23
|
platform: DevicePlatformSchema,
|
|
24
24
|
status: BuildStatusSchema,
|
|
@@ -142,12 +142,14 @@ export type BuildRequestResponse = Static<typeof BuildRequestResponseSchema>;
|
|
|
142
142
|
export type _CheckBuildRow = AssertTrue<AssertSchemaCompatibleWithRow<Build, "version_builds">>;
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
|
-
* Update build
|
|
145
|
+
* Update build request body schema
|
|
146
|
+
* Supports updating status and/or notes
|
|
146
147
|
*/
|
|
147
|
-
export const
|
|
148
|
-
status: BuildStatusSchema,
|
|
148
|
+
export const UpdateBuildBodySchema = Type.Object({
|
|
149
|
+
status: Type.Optional(BuildStatusSchema),
|
|
150
|
+
notes: Type.Optional(Type.Union([Type.String({ maxLength: 500 }), Type.Null()])),
|
|
149
151
|
});
|
|
150
|
-
export type
|
|
152
|
+
export type UpdateBuildBody = Static<typeof UpdateBuildBodySchema>;
|
|
151
153
|
|
|
152
154
|
/**
|
|
153
155
|
* Add UPDATE_FAILED error code for update operations
|
|
@@ -69,7 +69,7 @@ export function parseDevicePlatformEnum(value: unknown): DevicePlatformEnum | nu
|
|
|
69
69
|
*/
|
|
70
70
|
export const DeviceSchema = Type.Object({
|
|
71
71
|
id: Type.String({ format: "uuid" }),
|
|
72
|
-
|
|
72
|
+
user_id: Type.String({ format: "uuid" }),
|
|
73
73
|
environment_id: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
|
|
74
74
|
device_id: Type.String(),
|
|
75
75
|
platform: Type.Union([DevicePlatformSchema, Type.Null()]),
|
|
@@ -118,23 +118,28 @@ export const DeviceInfoSchema = Type.Object({
|
|
|
118
118
|
export type DeviceInfo = Static<typeof DeviceInfoSchema>;
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
|
-
*
|
|
122
|
-
* Matches
|
|
121
|
+
* User info schema (optional fields)
|
|
122
|
+
* Matches project_users table structure
|
|
123
123
|
*/
|
|
124
|
-
export const
|
|
124
|
+
export const UserInfoSchema = Type.Object({
|
|
125
125
|
user_id: Type.Optional(Type.String({ error: "user_id is required" })),
|
|
126
126
|
email: Type.Optional(EmailSchema),
|
|
127
127
|
name: Type.Optional(Type.String({ error: "name is required" })),
|
|
128
128
|
});
|
|
129
|
-
export type
|
|
129
|
+
export type UserInfo = Static<typeof UserInfoSchema>;
|
|
130
|
+
|
|
131
|
+
/** @deprecated Use UserInfoSchema instead */
|
|
132
|
+
export const PersonaInfoSchema = UserInfoSchema;
|
|
133
|
+
/** @deprecated Use UserInfo instead */
|
|
134
|
+
export type PersonaInfo = UserInfo;
|
|
130
135
|
|
|
131
136
|
/**
|
|
132
137
|
* Identify request schema
|
|
133
|
-
* Ties a device to a
|
|
138
|
+
* Ties a device to a user with optional user data
|
|
134
139
|
*/
|
|
135
140
|
export const IdentifyRequestSchema = Type.Object({
|
|
136
141
|
device: DeviceInfoSchema,
|
|
137
|
-
persona: Type.Optional(
|
|
142
|
+
persona: Type.Optional(UserInfoSchema),
|
|
138
143
|
});
|
|
139
144
|
export type IdentifyRequest = Static<typeof IdentifyRequestSchema>;
|
|
140
145
|
|
|
@@ -210,7 +215,7 @@ export const IdentifyResponseSchema = Type.Object({
|
|
|
210
215
|
data: Type.Object({
|
|
211
216
|
session_id: Type.String({ error: "session_id is required" }),
|
|
212
217
|
device_id: Type.String({ error: "device_id is required" }),
|
|
213
|
-
|
|
218
|
+
user_id: Type.String({ error: "user_id is required" }),
|
|
214
219
|
token: Type.String({ error: "token is required" }), // JWT token for session authentication
|
|
215
220
|
version_info: VersionInfoSchema,
|
|
216
221
|
}),
|
|
@@ -249,7 +254,7 @@ export const IdentifyErrorResponseSchema = Type.Object({
|
|
|
249
254
|
message: Type.String(),
|
|
250
255
|
}),
|
|
251
256
|
Type.Object({
|
|
252
|
-
code: Type.Literal("
|
|
257
|
+
code: Type.Literal("NO_USER_ID_GENERATED"),
|
|
253
258
|
message: Type.String(),
|
|
254
259
|
}),
|
|
255
260
|
]),
|
package/src/modules/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ export * from "./events/schemas";
|
|
|
6
6
|
export * from "./identify/schemas";
|
|
7
7
|
export * from "./me/schemas";
|
|
8
8
|
export * from "./orgs/schemas";
|
|
9
|
-
export * from "./
|
|
9
|
+
export * from "./project-users/schemas";
|
|
10
10
|
export * from "./projects/schemas";
|
|
11
11
|
export * from "./sessions/schemas";
|
|
12
12
|
export * from "./versions/schemas";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Static, Type } from "@sinclair/typebox";
|
|
2
|
-
import { OrgRoleTypeEnum, OrgTypeEnum } from "@teardown/types";
|
|
2
|
+
import { OrgInvitationStatusEnum, OrgRoleTypeEnum, OrgTypeEnum } from "@teardown/types";
|
|
3
3
|
import {
|
|
4
4
|
type AssertSchemaCompatibleWithInsert,
|
|
5
5
|
type AssertSchemaCompatibleWithRow,
|
|
@@ -158,6 +158,83 @@ export const AddOrgRoleSchema = Type.Object({
|
|
|
158
158
|
});
|
|
159
159
|
export type AddOrgRole = Static<typeof AddOrgRoleSchema>;
|
|
160
160
|
|
|
161
|
+
/**
|
|
162
|
+
* Org invitation schema
|
|
163
|
+
* Represents org_invitations table structure
|
|
164
|
+
*/
|
|
165
|
+
export const OrgInvitationSchema = Type.Object({
|
|
166
|
+
id: Type.String({ format: "uuid" }),
|
|
167
|
+
org_id: Type.String({ format: "uuid" }),
|
|
168
|
+
email: Type.String({ format: "email" }),
|
|
169
|
+
role: Type.Enum(OrgRoleTypeEnum),
|
|
170
|
+
status: Type.Enum(OrgInvitationStatusEnum),
|
|
171
|
+
invited_by: Type.String({ format: "uuid" }),
|
|
172
|
+
expires_at: Type.String(),
|
|
173
|
+
created_at: Type.String(),
|
|
174
|
+
updated_at: Type.String(),
|
|
175
|
+
});
|
|
176
|
+
export type OrgInvitation = Static<typeof OrgInvitationSchema>;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Parse and validate an OrgInvitationStatusEnum value
|
|
180
|
+
*/
|
|
181
|
+
export function parseOrgInvitationStatusEnum(value: unknown): OrgInvitationStatusEnum {
|
|
182
|
+
switch (value) {
|
|
183
|
+
case OrgInvitationStatusEnum.PENDING:
|
|
184
|
+
return OrgInvitationStatusEnum.PENDING;
|
|
185
|
+
case OrgInvitationStatusEnum.ACCEPTED:
|
|
186
|
+
return OrgInvitationStatusEnum.ACCEPTED;
|
|
187
|
+
case OrgInvitationStatusEnum.CANCELLED:
|
|
188
|
+
return OrgInvitationStatusEnum.CANCELLED;
|
|
189
|
+
case OrgInvitationStatusEnum.EXPIRED:
|
|
190
|
+
return OrgInvitationStatusEnum.EXPIRED;
|
|
191
|
+
default:
|
|
192
|
+
throw new Error(
|
|
193
|
+
`Invalid OrgInvitationStatusEnum value: ${value}. Expected one of: ${Object.values(OrgInvitationStatusEnum).join(", ")}`
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Create org invitation request schema
|
|
200
|
+
*/
|
|
201
|
+
export const CreateOrgInvitationSchema = Type.Object({
|
|
202
|
+
email: Type.String({ format: "email" }),
|
|
203
|
+
role: Type.Enum(OrgRoleTypeEnum),
|
|
204
|
+
});
|
|
205
|
+
export type CreateOrgInvitation = Static<typeof CreateOrgInvitationSchema>;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Org member with user info schema
|
|
209
|
+
* Used for displaying members in the UI
|
|
210
|
+
*/
|
|
211
|
+
export const OrgMemberSchema = Type.Object({
|
|
212
|
+
id: Type.String({ format: "uuid" }),
|
|
213
|
+
user_id: Type.String({ format: "uuid" }),
|
|
214
|
+
role: Type.Enum(OrgRoleTypeEnum),
|
|
215
|
+
email: Type.Union([Type.String(), Type.Null()]),
|
|
216
|
+
name: Type.Union([Type.String(), Type.Null()]),
|
|
217
|
+
avatar_url: Type.Union([Type.String(), Type.Null()]),
|
|
218
|
+
created_at: Type.String(),
|
|
219
|
+
});
|
|
220
|
+
export type OrgMember = Static<typeof OrgMemberSchema>;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Update member role request schema
|
|
224
|
+
*/
|
|
225
|
+
export const UpdateOrgMemberRoleSchema = Type.Object({
|
|
226
|
+
role: Type.Enum(OrgRoleTypeEnum),
|
|
227
|
+
});
|
|
228
|
+
export type UpdateOrgMemberRole = Static<typeof UpdateOrgMemberRoleSchema>;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Transfer ownership request schema
|
|
232
|
+
*/
|
|
233
|
+
export const TransferOwnershipSchema = Type.Object({
|
|
234
|
+
new_owner_user_id: Type.String({ format: "uuid" }),
|
|
235
|
+
});
|
|
236
|
+
export type TransferOwnership = Static<typeof TransferOwnershipSchema>;
|
|
237
|
+
|
|
161
238
|
/**
|
|
162
239
|
* Single org response schema
|
|
163
240
|
*/
|
|
@@ -238,6 +315,42 @@ export const OrgErrorSchema = Type.Union([
|
|
|
238
315
|
code: Type.Literal("ROLE_CREATION_FAILED"),
|
|
239
316
|
message: Type.String(),
|
|
240
317
|
}),
|
|
318
|
+
Type.Object({
|
|
319
|
+
code: Type.Literal("INVITATION_NOT_FOUND"),
|
|
320
|
+
message: Type.String(),
|
|
321
|
+
}),
|
|
322
|
+
Type.Object({
|
|
323
|
+
code: Type.Literal("INVITATION_ALREADY_EXISTS"),
|
|
324
|
+
message: Type.String(),
|
|
325
|
+
}),
|
|
326
|
+
Type.Object({
|
|
327
|
+
code: Type.Literal("ALREADY_MEMBER"),
|
|
328
|
+
message: Type.String(),
|
|
329
|
+
}),
|
|
330
|
+
Type.Object({
|
|
331
|
+
code: Type.Literal("CANNOT_REMOVE_OWNER"),
|
|
332
|
+
message: Type.String(),
|
|
333
|
+
}),
|
|
334
|
+
Type.Object({
|
|
335
|
+
code: Type.Literal("CANNOT_INVITE_AS_OWNER"),
|
|
336
|
+
message: Type.String(),
|
|
337
|
+
}),
|
|
338
|
+
Type.Object({
|
|
339
|
+
code: Type.Literal("MEMBER_NOT_FOUND"),
|
|
340
|
+
message: Type.String(),
|
|
341
|
+
}),
|
|
342
|
+
Type.Object({
|
|
343
|
+
code: Type.Literal("NOT_OWNER"),
|
|
344
|
+
message: Type.String(),
|
|
345
|
+
}),
|
|
346
|
+
Type.Object({
|
|
347
|
+
code: Type.Literal("CANNOT_LEAVE_AS_OWNER"),
|
|
348
|
+
message: Type.String(),
|
|
349
|
+
}),
|
|
350
|
+
Type.Object({
|
|
351
|
+
code: Type.Literal("CANNOT_CHANGE_OWNER_ROLE"),
|
|
352
|
+
message: Type.String(),
|
|
353
|
+
}),
|
|
241
354
|
]);
|
|
242
355
|
export type OrgError = Static<typeof OrgErrorSchema>;
|
|
243
356
|
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { type Static, Type } from "@sinclair/typebox";
|
|
2
|
+
import type { AssertSchemaCompatibleWithRow, AssertTrue } from "../../common";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Base project user schema
|
|
6
|
+
* Represents project_users table structure
|
|
7
|
+
*/
|
|
8
|
+
export const ProjectUserSchema = Type.Object({
|
|
9
|
+
id: Type.String({ format: "uuid" }),
|
|
10
|
+
environment_id: Type.String({ format: "uuid" }),
|
|
11
|
+
user_id: Type.Union([Type.String(), Type.Null()]),
|
|
12
|
+
name: Type.Union([Type.String(), Type.Null()]),
|
|
13
|
+
email: Type.Union([Type.String({ format: "email" }), Type.Null()]),
|
|
14
|
+
created_at: Type.String(),
|
|
15
|
+
updated_at: Type.String(),
|
|
16
|
+
});
|
|
17
|
+
export type ProjectUser = Static<typeof ProjectUserSchema>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Project user params schema
|
|
21
|
+
*/
|
|
22
|
+
export const ProjectUserParamsSchema = Type.Object({
|
|
23
|
+
user_id: Type.String({ format: "uuid" }),
|
|
24
|
+
});
|
|
25
|
+
export type ProjectUserParams = Static<typeof ProjectUserParamsSchema>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Search project users query schema
|
|
29
|
+
* Supports pagination, search, and sorting
|
|
30
|
+
*/
|
|
31
|
+
export const SearchProjectUsersQuerySchema = Type.Object({
|
|
32
|
+
project_id: Type.String({ format: "uuid" }),
|
|
33
|
+
page: Type.Number({ minimum: 1, default: 1 }),
|
|
34
|
+
limit: Type.Number({ minimum: 1, maximum: 100, default: 20 }),
|
|
35
|
+
search: Type.Optional(Type.String()),
|
|
36
|
+
sort_by: Type.Union([Type.Literal("created_at"), Type.Literal("updated_at"), Type.Literal("name"), Type.Literal("email")], {
|
|
37
|
+
default: "created_at",
|
|
38
|
+
}),
|
|
39
|
+
sort_order: Type.Union([Type.Literal("asc"), Type.Literal("desc")], { default: "desc" }),
|
|
40
|
+
});
|
|
41
|
+
export type SearchProjectUsersQuery = Static<typeof SearchProjectUsersQuerySchema>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Search project users query schema without project_id (injected from headers)
|
|
45
|
+
*/
|
|
46
|
+
export const SearchProjectUsersQueryParamsSchema = Type.Omit(SearchProjectUsersQuerySchema, ["project_id"]);
|
|
47
|
+
export type SearchProjectUsersQueryParams = Static<typeof SearchProjectUsersQueryParamsSchema>;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Project users by IDs request schema
|
|
51
|
+
*/
|
|
52
|
+
export const ProjectUsersByIdsSchema = Type.Object({
|
|
53
|
+
user_ids: Type.Array(Type.String({ format: "uuid" }), { minItems: 1, maxItems: 100 }),
|
|
54
|
+
});
|
|
55
|
+
export type ProjectUsersByIds = Static<typeof ProjectUsersByIdsSchema>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Paginated project users response schema
|
|
59
|
+
*/
|
|
60
|
+
export const ProjectUsersResponseSchema = Type.Object({
|
|
61
|
+
users: Type.Array(ProjectUserSchema),
|
|
62
|
+
pagination: Type.Object({
|
|
63
|
+
page: Type.Integer({ minimum: 1 }),
|
|
64
|
+
limit: Type.Integer({ minimum: 1 }),
|
|
65
|
+
total: Type.Integer({ minimum: 0 }),
|
|
66
|
+
total_pages: Type.Integer({ minimum: 0 }),
|
|
67
|
+
}),
|
|
68
|
+
});
|
|
69
|
+
export type ProjectUsersResponse = Static<typeof ProjectUsersResponseSchema>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Single project user response schema
|
|
73
|
+
*/
|
|
74
|
+
export const ProjectUserResponseSchema = Type.Object({
|
|
75
|
+
success: Type.Literal(true),
|
|
76
|
+
data: ProjectUserSchema,
|
|
77
|
+
});
|
|
78
|
+
export type ProjectUserResponse = Static<typeof ProjectUserResponseSchema>;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Project user error response schema
|
|
82
|
+
* Discriminated union by error code
|
|
83
|
+
*/
|
|
84
|
+
export const ProjectUserErrorSchema = Type.Union([
|
|
85
|
+
Type.Object({
|
|
86
|
+
code: Type.Literal("USER_NOT_FOUND"),
|
|
87
|
+
message: Type.String(),
|
|
88
|
+
}),
|
|
89
|
+
Type.Object({
|
|
90
|
+
code: Type.Literal("PROJECT_NOT_FOUND"),
|
|
91
|
+
message: Type.String(),
|
|
92
|
+
}),
|
|
93
|
+
Type.Object({
|
|
94
|
+
code: Type.Literal("FORBIDDEN"),
|
|
95
|
+
message: Type.String(),
|
|
96
|
+
}),
|
|
97
|
+
Type.Object({
|
|
98
|
+
code: Type.Literal("FETCH_FAILED"),
|
|
99
|
+
message: Type.String(),
|
|
100
|
+
}),
|
|
101
|
+
Type.Object({
|
|
102
|
+
code: Type.Literal("INVALID_PARAMS"),
|
|
103
|
+
message: Type.String(),
|
|
104
|
+
}),
|
|
105
|
+
]);
|
|
106
|
+
export type ProjectUserError = Static<typeof ProjectUserErrorSchema>;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Project user error response wrapper
|
|
110
|
+
*/
|
|
111
|
+
export const ProjectUserErrorResponseSchema = Type.Object({
|
|
112
|
+
success: Type.Literal(false),
|
|
113
|
+
error: ProjectUserErrorSchema,
|
|
114
|
+
});
|
|
115
|
+
export type ProjectUserErrorResponse = Static<typeof ProjectUserErrorResponseSchema>;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Project user request response schema
|
|
119
|
+
*/
|
|
120
|
+
export const ProjectUserRequestResponseSchema = Type.Union([ProjectUserResponseSchema, ProjectUserErrorResponseSchema]);
|
|
121
|
+
export type ProjectUserRequestResponse = Static<typeof ProjectUserRequestResponseSchema>;
|
|
122
|
+
|
|
123
|
+
export type _CheckProjectUserRow = AssertTrue<AssertSchemaCompatibleWithRow<ProjectUser, "project_users">>;
|
|
@@ -43,6 +43,7 @@ export const VersionSchema = Type.Object({
|
|
|
43
43
|
major: Type.Number(), // Matches type number, not integer constraint (db type numeric)
|
|
44
44
|
minor: Type.Number(),
|
|
45
45
|
patch: Type.Number(),
|
|
46
|
+
notes: Type.Union([Type.String({ maxLength: 500 }), Type.Null()]),
|
|
46
47
|
status: VersionBuildStatusSchema, // SUPPORTED, UPDATE_AVAILABLE, UPDATE_RECOMMENDED, UPDATE_REQUIRED - controls if version is active
|
|
47
48
|
created_at: Type.String(),
|
|
48
49
|
updated_at: Type.String(),
|
|
@@ -164,12 +165,14 @@ export type VersionRequestResponse = Static<typeof VersionRequestResponseSchema>
|
|
|
164
165
|
export type _CheckVersionRow = AssertTrue<AssertSchemaCompatibleWithRow<Version, "project_versions">>;
|
|
165
166
|
|
|
166
167
|
/**
|
|
167
|
-
* Update version
|
|
168
|
+
* Update version request body schema
|
|
169
|
+
* Supports updating status and/or notes
|
|
168
170
|
*/
|
|
169
|
-
export const
|
|
170
|
-
status: VersionBuildStatusSchema,
|
|
171
|
+
export const UpdateVersionBodySchema = Type.Object({
|
|
172
|
+
status: Type.Optional(VersionBuildStatusSchema),
|
|
173
|
+
notes: Type.Optional(Type.Union([Type.String({ maxLength: 500 }), Type.Null()])),
|
|
171
174
|
});
|
|
172
|
-
export type
|
|
175
|
+
export type UpdateVersionBody = Static<typeof UpdateVersionBodySchema>;
|
|
173
176
|
|
|
174
177
|
/**
|
|
175
178
|
* Add UPDATE_FAILED error code for update operations
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { type Static, Type } from "@sinclair/typebox";
|
|
2
|
-
import type { AssertSchemaCompatibleWithRow, AssertTrue } from "../../common";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Base persona schema
|
|
6
|
-
* Represents personas table structure
|
|
7
|
-
*/
|
|
8
|
-
export const PersonaSchema = Type.Object({
|
|
9
|
-
id: Type.String({ format: "uuid" }),
|
|
10
|
-
environment_id: Type.String({ format: "uuid" }),
|
|
11
|
-
user_id: Type.Union([Type.String(), Type.Null()]),
|
|
12
|
-
name: Type.Union([Type.String(), Type.Null()]),
|
|
13
|
-
email: Type.Union([Type.String({ format: "email" }), Type.Null()]),
|
|
14
|
-
created_at: Type.String(),
|
|
15
|
-
updated_at: Type.String(),
|
|
16
|
-
});
|
|
17
|
-
export type Persona = Static<typeof PersonaSchema>;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Persona params schema
|
|
21
|
-
*/
|
|
22
|
-
export const PersonaParamsSchema = Type.Object({
|
|
23
|
-
persona_id: Type.String({ format: "uuid" }),
|
|
24
|
-
});
|
|
25
|
-
export type PersonaParams = Static<typeof PersonaParamsSchema>;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Search personas query schema
|
|
29
|
-
* Supports pagination, search, and sorting
|
|
30
|
-
*/
|
|
31
|
-
export const SearchPersonasQuerySchema = Type.Object({
|
|
32
|
-
project_id: Type.String({ format: "uuid" }),
|
|
33
|
-
page: Type.Number({ minimum: 1, default: 1 }),
|
|
34
|
-
limit: Type.Number({ minimum: 1, maximum: 100, default: 20 }),
|
|
35
|
-
search: Type.Optional(Type.String()),
|
|
36
|
-
sort_by: Type.Union([Type.Literal("created_at"), Type.Literal("updated_at"), Type.Literal("name"), Type.Literal("email")], {
|
|
37
|
-
default: "created_at",
|
|
38
|
-
}),
|
|
39
|
-
sort_order: Type.Union([Type.Literal("asc"), Type.Literal("desc")], { default: "desc" }),
|
|
40
|
-
});
|
|
41
|
-
export type SearchPersonasQuery = Static<typeof SearchPersonasQuerySchema>;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Search personas query schema without project_id (injected from headers)
|
|
45
|
-
*/
|
|
46
|
-
export const SearchPersonasQueryParamsSchema = Type.Omit(SearchPersonasQuerySchema, ["project_id"]);
|
|
47
|
-
export type SearchPersonasQueryParams = Static<typeof SearchPersonasQueryParamsSchema>;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Personas by IDs request schema
|
|
51
|
-
*/
|
|
52
|
-
export const PersonasByIdsSchema = Type.Object({
|
|
53
|
-
persona_ids: Type.Array(Type.String({ format: "uuid" }), { minItems: 1, maxItems: 100 }),
|
|
54
|
-
});
|
|
55
|
-
export type PersonasByIds = Static<typeof PersonasByIdsSchema>;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Paginated personas response schema
|
|
59
|
-
*/
|
|
60
|
-
export const PersonasResponseSchema = Type.Object({
|
|
61
|
-
personas: Type.Array(PersonaSchema),
|
|
62
|
-
pagination: Type.Object({
|
|
63
|
-
page: Type.Integer({ minimum: 1 }),
|
|
64
|
-
limit: Type.Integer({ minimum: 1 }),
|
|
65
|
-
total: Type.Integer({ minimum: 0 }),
|
|
66
|
-
total_pages: Type.Integer({ minimum: 0 }),
|
|
67
|
-
}),
|
|
68
|
-
});
|
|
69
|
-
export type PersonasResponse = Static<typeof PersonasResponseSchema>;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Single persona response schema
|
|
73
|
-
*/
|
|
74
|
-
export const PersonaResponseSchema = Type.Object({
|
|
75
|
-
success: Type.Literal(true),
|
|
76
|
-
data: PersonaSchema,
|
|
77
|
-
});
|
|
78
|
-
export type PersonaResponse = Static<typeof PersonaResponseSchema>;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Persona error response schema
|
|
82
|
-
* Discriminated union by error code
|
|
83
|
-
*/
|
|
84
|
-
export const PersonaErrorSchema = Type.Union([
|
|
85
|
-
Type.Object({
|
|
86
|
-
code: Type.Literal("PERSONA_NOT_FOUND"),
|
|
87
|
-
message: Type.String(),
|
|
88
|
-
}),
|
|
89
|
-
Type.Object({
|
|
90
|
-
code: Type.Literal("PROJECT_NOT_FOUND"),
|
|
91
|
-
message: Type.String(),
|
|
92
|
-
}),
|
|
93
|
-
Type.Object({
|
|
94
|
-
code: Type.Literal("FORBIDDEN"),
|
|
95
|
-
message: Type.String(),
|
|
96
|
-
}),
|
|
97
|
-
Type.Object({
|
|
98
|
-
code: Type.Literal("FETCH_FAILED"),
|
|
99
|
-
message: Type.String(),
|
|
100
|
-
}),
|
|
101
|
-
Type.Object({
|
|
102
|
-
code: Type.Literal("INVALID_PARAMS"),
|
|
103
|
-
message: Type.String(),
|
|
104
|
-
}),
|
|
105
|
-
]);
|
|
106
|
-
export type PersonaError = Static<typeof PersonaErrorSchema>;
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Persona error response wrapper
|
|
110
|
-
*/
|
|
111
|
-
export const PersonaErrorResponseSchema = Type.Object({
|
|
112
|
-
success: Type.Literal(false),
|
|
113
|
-
error: PersonaErrorSchema,
|
|
114
|
-
});
|
|
115
|
-
export type PersonaErrorResponse = Static<typeof PersonaErrorResponseSchema>;
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Persona request response schema
|
|
119
|
-
*/
|
|
120
|
-
export const PersonaRequestResponseSchema = Type.Union([PersonaResponseSchema, PersonaErrorResponseSchema]);
|
|
121
|
-
export type PersonaRequestResponse = Static<typeof PersonaRequestResponseSchema>;
|
|
122
|
-
|
|
123
|
-
export type _CheckPersonaRow = AssertTrue<AssertSchemaCompatibleWithRow<Persona, "personas">>;
|
|
File without changes
|