@teardown/schemas 0.1.0 → 0.1.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/dist/common/primitives.d.ts +1 -1
- package/dist/common/primitives.js +5 -6
- package/dist/common/responses.d.ts +1 -1
- package/dist/common/responses.js +9 -9
- package/dist/modules/analytics/schemas.d.ts +1 -1
- package/dist/modules/analytics/schemas.js +91 -91
- package/dist/modules/builds/schemas.d.ts +1 -1
- package/dist/modules/builds/schemas.js +64 -64
- package/dist/modules/devices/schemas.d.ts +1 -1
- package/dist/modules/devices/schemas.js +60 -60
- package/dist/modules/environment/schemas.d.ts +1 -1
- package/dist/modules/environment/schemas.js +17 -17
- package/dist/modules/events/schemas.d.ts +1 -1
- package/dist/modules/events/schemas.js +48 -48
- package/dist/modules/identify/schemas.d.ts +6 -6
- package/dist/modules/identify/schemas.js +104 -104
- package/dist/modules/me/schemas.d.ts +2 -2
- package/dist/modules/me/schemas.js +22 -22
- package/dist/modules/orgs/schemas.d.ts +4 -4
- package/dist/modules/orgs/schemas.js +89 -89
- package/dist/modules/personas/schemas.d.ts +1 -1
- package/dist/modules/personas/schemas.js +49 -49
- package/dist/modules/projects/schemas.d.ts +1 -1
- package/dist/modules/projects/schemas.js +59 -59
- package/dist/modules/sessions/schemas.d.ts +13 -13
- package/dist/modules/sessions/schemas.js +71 -71
- package/dist/modules/versions/schemas.d.ts +1 -1
- package/dist/modules/versions/schemas.js +64 -64
- package/package.json +7 -5
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
1
2
|
import { OrgRoleTypeEnum, OrgTypeEnum } from "@teardown/types";
|
|
2
|
-
import { t } from "elysia";
|
|
3
3
|
import { SlugSchema, } from "../../common";
|
|
4
|
-
export const OrgHeadersSchema =
|
|
5
|
-
"td-org-id":
|
|
4
|
+
export const OrgHeadersSchema = Type.Object({
|
|
5
|
+
"td-org-id": Type.String(),
|
|
6
6
|
});
|
|
7
7
|
/**
|
|
8
8
|
* Helper to check if role is admin or owner
|
|
@@ -58,79 +58,79 @@ export function parseOrgTypeEnum(value) {
|
|
|
58
58
|
throw new Error(`Invalid OrgTypeEnum value: ${value}. Expected one of: ${Object.values(OrgTypeEnum).join(", ")}`);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
export const OrgSlugOrIdParamsSchema =
|
|
62
|
-
org_id_or_slug:
|
|
61
|
+
export const OrgSlugOrIdParamsSchema = Type.Object({
|
|
62
|
+
org_id_or_slug: Type.String(),
|
|
63
63
|
});
|
|
64
|
-
export const OrgIdParamsSchema =
|
|
65
|
-
org_id:
|
|
64
|
+
export const OrgIdParamsSchema = Type.Object({
|
|
65
|
+
org_id: Type.String(),
|
|
66
66
|
});
|
|
67
|
-
export const OrgSlugParamsSchema =
|
|
67
|
+
export const OrgSlugParamsSchema = Type.Object({
|
|
68
68
|
// org_slug: SlugSchema,
|
|
69
69
|
});
|
|
70
70
|
/**
|
|
71
71
|
* Base org schema
|
|
72
72
|
* Represents organisation table structure
|
|
73
73
|
*/
|
|
74
|
-
export const OrgSchema =
|
|
75
|
-
id:
|
|
76
|
-
name:
|
|
74
|
+
export const OrgSchema = Type.Object({
|
|
75
|
+
id: Type.String({ format: "uuid" }),
|
|
76
|
+
name: Type.String({ minLength: 1 }),
|
|
77
77
|
slug: SlugSchema,
|
|
78
|
-
type:
|
|
79
|
-
created_at:
|
|
80
|
-
updated_at:
|
|
78
|
+
type: Type.Enum(OrgTypeEnum),
|
|
79
|
+
created_at: Type.String(),
|
|
80
|
+
updated_at: Type.String(),
|
|
81
81
|
});
|
|
82
82
|
/**
|
|
83
83
|
* Org role schema
|
|
84
84
|
* Represents organisation_role table structure
|
|
85
85
|
*/
|
|
86
|
-
export const OrgRoleSchema =
|
|
87
|
-
id:
|
|
88
|
-
org_id:
|
|
89
|
-
user_id:
|
|
90
|
-
role:
|
|
91
|
-
created_at:
|
|
92
|
-
updated_at:
|
|
86
|
+
export const OrgRoleSchema = Type.Object({
|
|
87
|
+
id: Type.String({ format: "uuid" }),
|
|
88
|
+
org_id: Type.String({ format: "uuid" }),
|
|
89
|
+
user_id: Type.String({ format: "uuid" }),
|
|
90
|
+
role: Type.Enum(OrgRoleTypeEnum),
|
|
91
|
+
created_at: Type.String(),
|
|
92
|
+
updated_at: Type.String(),
|
|
93
93
|
});
|
|
94
94
|
/**
|
|
95
95
|
* Extended org role with org name
|
|
96
96
|
* Used for user's org list
|
|
97
97
|
*/
|
|
98
|
-
export const OrgRoleWithOrgSchema =
|
|
98
|
+
export const OrgRoleWithOrgSchema = Type.Composite([
|
|
99
99
|
OrgRoleSchema,
|
|
100
|
-
|
|
101
|
-
org_id:
|
|
102
|
-
org_name:
|
|
100
|
+
Type.Object({
|
|
101
|
+
org_id: Type.String({ format: "uuid" }),
|
|
102
|
+
org_name: Type.String(),
|
|
103
103
|
org_slug: SlugSchema,
|
|
104
104
|
}),
|
|
105
105
|
]);
|
|
106
106
|
/**
|
|
107
107
|
* Create org request schema
|
|
108
108
|
*/
|
|
109
|
-
export const CreateOrgSchema =
|
|
110
|
-
name:
|
|
109
|
+
export const CreateOrgSchema = Type.Object({
|
|
110
|
+
name: Type.String({ minLength: 1, maxLength: 255 }),
|
|
111
111
|
slug: SlugSchema,
|
|
112
|
-
type:
|
|
112
|
+
type: Type.Enum(OrgTypeEnum),
|
|
113
113
|
});
|
|
114
114
|
/**
|
|
115
115
|
* Update org request schema
|
|
116
116
|
*/
|
|
117
|
-
export const UpdateOrgSchema =
|
|
118
|
-
name:
|
|
117
|
+
export const UpdateOrgSchema = Type.Object({
|
|
118
|
+
name: Type.Optional(Type.String({ minLength: 1, maxLength: 255 })),
|
|
119
119
|
});
|
|
120
120
|
/**
|
|
121
121
|
* Add org role request schema
|
|
122
122
|
*/
|
|
123
|
-
export const AddOrgRoleSchema =
|
|
124
|
-
org_id:
|
|
125
|
-
user_id:
|
|
126
|
-
role:
|
|
123
|
+
export const AddOrgRoleSchema = Type.Object({
|
|
124
|
+
org_id: Type.String({ format: "uuid" }),
|
|
125
|
+
user_id: Type.String({ format: "uuid" }),
|
|
126
|
+
role: Type.Enum(OrgRoleTypeEnum),
|
|
127
127
|
});
|
|
128
128
|
/**
|
|
129
129
|
* Single org response schema
|
|
130
130
|
*/
|
|
131
|
-
export const OrgResponseSchema =
|
|
132
|
-
success:
|
|
133
|
-
data:
|
|
131
|
+
export const OrgResponseSchema = Type.Object({
|
|
132
|
+
success: Type.Literal(true),
|
|
133
|
+
data: Type.Object({
|
|
134
134
|
org: OrgRoleWithOrgSchema,
|
|
135
135
|
}),
|
|
136
136
|
});
|
|
@@ -138,77 +138,77 @@ export const OrgResponseSchema = t.Object({
|
|
|
138
138
|
* Org error response schema
|
|
139
139
|
* Discriminated union by error code
|
|
140
140
|
*/
|
|
141
|
-
export const OrgErrorSchema =
|
|
142
|
-
|
|
143
|
-
code:
|
|
144
|
-
message:
|
|
141
|
+
export const OrgErrorSchema = Type.Union([
|
|
142
|
+
Type.Object({
|
|
143
|
+
code: Type.Literal("UNKNOWN_ERROR"),
|
|
144
|
+
message: Type.String(),
|
|
145
145
|
}),
|
|
146
|
-
|
|
147
|
-
code:
|
|
148
|
-
message:
|
|
146
|
+
Type.Object({
|
|
147
|
+
code: Type.Literal("VALIDATION_ERROR"),
|
|
148
|
+
message: Type.String(),
|
|
149
149
|
}),
|
|
150
|
-
|
|
151
|
-
code:
|
|
152
|
-
message:
|
|
150
|
+
Type.Object({
|
|
151
|
+
code: Type.Literal("ORG_ID_MISMATCH"),
|
|
152
|
+
message: Type.String(),
|
|
153
153
|
}),
|
|
154
|
-
|
|
155
|
-
code:
|
|
156
|
-
message:
|
|
154
|
+
Type.Object({
|
|
155
|
+
code: Type.Literal("ORG_NOT_FOUND"),
|
|
156
|
+
message: Type.String(),
|
|
157
157
|
}),
|
|
158
|
-
|
|
159
|
-
code:
|
|
160
|
-
message:
|
|
158
|
+
Type.Object({
|
|
159
|
+
code: Type.Literal("ORG_ROLE_NOT_FOUND"),
|
|
160
|
+
message: Type.String(),
|
|
161
161
|
}),
|
|
162
|
-
|
|
163
|
-
code:
|
|
164
|
-
message:
|
|
162
|
+
Type.Object({
|
|
163
|
+
code: Type.Literal("USER_NOT_IN_ORG"),
|
|
164
|
+
message: Type.String(),
|
|
165
165
|
}),
|
|
166
|
-
|
|
167
|
-
code:
|
|
168
|
-
message:
|
|
166
|
+
Type.Object({
|
|
167
|
+
code: Type.Literal("FORBIDDEN"),
|
|
168
|
+
message: Type.String(),
|
|
169
169
|
}),
|
|
170
|
-
|
|
171
|
-
code:
|
|
172
|
-
message:
|
|
170
|
+
Type.Object({
|
|
171
|
+
code: Type.Literal("UNAUTHORIZED"),
|
|
172
|
+
message: Type.String(),
|
|
173
173
|
}),
|
|
174
|
-
|
|
175
|
-
code:
|
|
176
|
-
message:
|
|
174
|
+
Type.Object({
|
|
175
|
+
code: Type.Literal("INVALID_ROLE"),
|
|
176
|
+
message: Type.String(),
|
|
177
177
|
}),
|
|
178
|
-
|
|
179
|
-
code:
|
|
180
|
-
message:
|
|
178
|
+
Type.Object({
|
|
179
|
+
code: Type.Literal("ORG_ID_REQUIRED"),
|
|
180
|
+
message: Type.String(),
|
|
181
181
|
}),
|
|
182
|
-
|
|
183
|
-
code:
|
|
184
|
-
message:
|
|
182
|
+
Type.Object({
|
|
183
|
+
code: Type.Literal("SLUG_ALREADY_EXISTS"),
|
|
184
|
+
message: Type.String(),
|
|
185
185
|
}),
|
|
186
|
-
|
|
187
|
-
code:
|
|
188
|
-
message:
|
|
186
|
+
Type.Object({
|
|
187
|
+
code: Type.Literal("FETCH_FAILED"),
|
|
188
|
+
message: Type.String(),
|
|
189
189
|
}),
|
|
190
|
-
|
|
191
|
-
code:
|
|
192
|
-
message:
|
|
190
|
+
Type.Object({
|
|
191
|
+
code: Type.Literal("CREATE_FAILED"),
|
|
192
|
+
message: Type.String(),
|
|
193
193
|
}),
|
|
194
|
-
|
|
195
|
-
code:
|
|
196
|
-
message:
|
|
194
|
+
Type.Object({
|
|
195
|
+
code: Type.Literal("UPDATE_FAILED"),
|
|
196
|
+
message: Type.String(),
|
|
197
197
|
}),
|
|
198
|
-
|
|
199
|
-
code:
|
|
200
|
-
message:
|
|
198
|
+
Type.Object({
|
|
199
|
+
code: Type.Literal("DELETE_FAILED"),
|
|
200
|
+
message: Type.String(),
|
|
201
201
|
}),
|
|
202
|
-
|
|
203
|
-
code:
|
|
204
|
-
message:
|
|
202
|
+
Type.Object({
|
|
203
|
+
code: Type.Literal("ROLE_CREATION_FAILED"),
|
|
204
|
+
message: Type.String(),
|
|
205
205
|
}),
|
|
206
206
|
]);
|
|
207
207
|
/**
|
|
208
208
|
* Org error response wrapper
|
|
209
209
|
*/
|
|
210
|
-
export const OrgErrorResponseSchema =
|
|
211
|
-
success:
|
|
210
|
+
export const OrgErrorResponseSchema = Type.Object({
|
|
211
|
+
success: Type.Literal(false),
|
|
212
212
|
error: OrgErrorSchema,
|
|
213
213
|
});
|
|
214
|
-
export const OrgRequestResponseSchema =
|
|
214
|
+
export const OrgRequestResponseSchema = Type.Union([OrgResponseSchema, OrgErrorResponseSchema]);
|
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
2
|
/**
|
|
3
3
|
* Base persona schema
|
|
4
4
|
* Represents personas table structure
|
|
5
5
|
*/
|
|
6
|
-
export const PersonaSchema =
|
|
7
|
-
id:
|
|
8
|
-
environment_id:
|
|
9
|
-
user_id:
|
|
10
|
-
name:
|
|
11
|
-
email:
|
|
12
|
-
created_at:
|
|
13
|
-
updated_at:
|
|
6
|
+
export const PersonaSchema = Type.Object({
|
|
7
|
+
id: Type.String({ format: "uuid" }),
|
|
8
|
+
environment_id: Type.String({ format: "uuid" }),
|
|
9
|
+
user_id: Type.Union([Type.String(), Type.Null()]),
|
|
10
|
+
name: Type.Union([Type.String(), Type.Null()]),
|
|
11
|
+
email: Type.Union([Type.String({ format: "email" }), Type.Null()]),
|
|
12
|
+
created_at: Type.String(),
|
|
13
|
+
updated_at: Type.String(),
|
|
14
14
|
});
|
|
15
15
|
/**
|
|
16
16
|
* Persona params schema
|
|
17
17
|
*/
|
|
18
|
-
export const PersonaParamsSchema =
|
|
19
|
-
persona_id:
|
|
18
|
+
export const PersonaParamsSchema = Type.Object({
|
|
19
|
+
persona_id: Type.String({ format: "uuid" }),
|
|
20
20
|
});
|
|
21
21
|
/**
|
|
22
22
|
* Search personas query schema
|
|
23
23
|
* Supports pagination, search, and sorting
|
|
24
24
|
*/
|
|
25
|
-
export const SearchPersonasQuerySchema =
|
|
26
|
-
project_id:
|
|
27
|
-
page:
|
|
28
|
-
limit:
|
|
29
|
-
search:
|
|
30
|
-
sort_by:
|
|
25
|
+
export const SearchPersonasQuerySchema = Type.Object({
|
|
26
|
+
project_id: Type.String({ format: "uuid" }),
|
|
27
|
+
page: Type.Number({ minimum: 1, default: 1 }),
|
|
28
|
+
limit: Type.Number({ minimum: 1, maximum: 100, default: 20 }),
|
|
29
|
+
search: Type.Optional(Type.String()),
|
|
30
|
+
sort_by: Type.Union([Type.Literal("created_at"), Type.Literal("updated_at"), Type.Literal("name"), Type.Literal("email")], {
|
|
31
31
|
default: "created_at",
|
|
32
32
|
}),
|
|
33
|
-
sort_order:
|
|
33
|
+
sort_order: Type.Union([Type.Literal("asc"), Type.Literal("desc")], { default: "desc" }),
|
|
34
34
|
});
|
|
35
35
|
/**
|
|
36
36
|
* Search personas query schema without project_id (injected from headers)
|
|
37
37
|
*/
|
|
38
|
-
export const SearchPersonasQueryParamsSchema =
|
|
38
|
+
export const SearchPersonasQueryParamsSchema = Type.Omit(SearchPersonasQuerySchema, ["project_id"]);
|
|
39
39
|
/**
|
|
40
40
|
* Personas by IDs request schema
|
|
41
41
|
*/
|
|
42
|
-
export const PersonasByIdsSchema =
|
|
43
|
-
persona_ids:
|
|
42
|
+
export const PersonasByIdsSchema = Type.Object({
|
|
43
|
+
persona_ids: Type.Array(Type.String({ format: "uuid" }), { minItems: 1, maxItems: 100 }),
|
|
44
44
|
});
|
|
45
45
|
/**
|
|
46
46
|
* Paginated personas response schema
|
|
47
47
|
*/
|
|
48
|
-
export const PersonasResponseSchema =
|
|
49
|
-
personas:
|
|
50
|
-
pagination:
|
|
51
|
-
page:
|
|
52
|
-
limit:
|
|
53
|
-
total:
|
|
54
|
-
total_pages:
|
|
48
|
+
export const PersonasResponseSchema = Type.Object({
|
|
49
|
+
personas: Type.Array(PersonaSchema),
|
|
50
|
+
pagination: Type.Object({
|
|
51
|
+
page: Type.Integer({ minimum: 1 }),
|
|
52
|
+
limit: Type.Integer({ minimum: 1 }),
|
|
53
|
+
total: Type.Integer({ minimum: 0 }),
|
|
54
|
+
total_pages: Type.Integer({ minimum: 0 }),
|
|
55
55
|
}),
|
|
56
56
|
});
|
|
57
57
|
/**
|
|
58
58
|
* Single persona response schema
|
|
59
59
|
*/
|
|
60
|
-
export const PersonaResponseSchema =
|
|
61
|
-
success:
|
|
60
|
+
export const PersonaResponseSchema = Type.Object({
|
|
61
|
+
success: Type.Literal(true),
|
|
62
62
|
data: PersonaSchema,
|
|
63
63
|
});
|
|
64
64
|
/**
|
|
65
65
|
* Persona error response schema
|
|
66
66
|
* Discriminated union by error code
|
|
67
67
|
*/
|
|
68
|
-
export const PersonaErrorSchema =
|
|
69
|
-
|
|
70
|
-
code:
|
|
71
|
-
message:
|
|
68
|
+
export const PersonaErrorSchema = Type.Union([
|
|
69
|
+
Type.Object({
|
|
70
|
+
code: Type.Literal("PERSONA_NOT_FOUND"),
|
|
71
|
+
message: Type.String(),
|
|
72
72
|
}),
|
|
73
|
-
|
|
74
|
-
code:
|
|
75
|
-
message:
|
|
73
|
+
Type.Object({
|
|
74
|
+
code: Type.Literal("PROJECT_NOT_FOUND"),
|
|
75
|
+
message: Type.String(),
|
|
76
76
|
}),
|
|
77
|
-
|
|
78
|
-
code:
|
|
79
|
-
message:
|
|
77
|
+
Type.Object({
|
|
78
|
+
code: Type.Literal("FORBIDDEN"),
|
|
79
|
+
message: Type.String(),
|
|
80
80
|
}),
|
|
81
|
-
|
|
82
|
-
code:
|
|
83
|
-
message:
|
|
81
|
+
Type.Object({
|
|
82
|
+
code: Type.Literal("FETCH_FAILED"),
|
|
83
|
+
message: Type.String(),
|
|
84
84
|
}),
|
|
85
|
-
|
|
86
|
-
code:
|
|
87
|
-
message:
|
|
85
|
+
Type.Object({
|
|
86
|
+
code: Type.Literal("INVALID_PARAMS"),
|
|
87
|
+
message: Type.String(),
|
|
88
88
|
}),
|
|
89
89
|
]);
|
|
90
90
|
/**
|
|
91
91
|
* Persona error response wrapper
|
|
92
92
|
*/
|
|
93
|
-
export const PersonaErrorResponseSchema =
|
|
94
|
-
success:
|
|
93
|
+
export const PersonaErrorResponseSchema = Type.Object({
|
|
94
|
+
success: Type.Literal(false),
|
|
95
95
|
error: PersonaErrorSchema,
|
|
96
96
|
});
|
|
97
97
|
/**
|
|
98
98
|
* Persona request response schema
|
|
99
99
|
*/
|
|
100
|
-
export const PersonaRequestResponseSchema =
|
|
100
|
+
export const PersonaRequestResponseSchema = Type.Union([PersonaResponseSchema, PersonaErrorResponseSchema]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { type Static } from "@sinclair/typebox";
|
|
1
2
|
import { ProjectStatusEnum, ProjectTypeEnum } from "@teardown/types";
|
|
2
|
-
import { type Static } from "elysia";
|
|
3
3
|
import { type AssertSchemaCompatibleWithInsert, type AssertSchemaCompatibleWithRow, type AssertSchemaCompatibleWithUpdate, type AssertTrue } from "../../common";
|
|
4
4
|
/**
|
|
5
5
|
* Parse and validate a ProjectTypeEnum value
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
1
2
|
import { ProjectStatusEnum, ProjectTypeEnum } from "@teardown/types";
|
|
2
|
-
import { t } from "elysia";
|
|
3
3
|
import { SlugSchema, } from "../../common";
|
|
4
4
|
/**
|
|
5
5
|
* Parse and validate a ProjectTypeEnum value
|
|
@@ -43,103 +43,103 @@ export function parseProjectStatusEnum(value) {
|
|
|
43
43
|
* Base project schema
|
|
44
44
|
* Represents projects table structure
|
|
45
45
|
*/
|
|
46
|
-
export const ProjectSchema =
|
|
47
|
-
id:
|
|
48
|
-
org_id:
|
|
49
|
-
name:
|
|
46
|
+
export const ProjectSchema = Type.Object({
|
|
47
|
+
id: Type.String({ format: "uuid" }),
|
|
48
|
+
org_id: Type.String({ format: "uuid" }),
|
|
49
|
+
name: Type.String({ minLength: 1 }),
|
|
50
50
|
slug: SlugSchema,
|
|
51
|
-
type:
|
|
52
|
-
status:
|
|
53
|
-
created_at:
|
|
54
|
-
updated_at:
|
|
51
|
+
type: Type.Enum(ProjectTypeEnum),
|
|
52
|
+
status: Type.Enum(ProjectStatusEnum),
|
|
53
|
+
created_at: Type.String(),
|
|
54
|
+
updated_at: Type.String(),
|
|
55
55
|
});
|
|
56
|
-
export const ProjectParamsSchema =
|
|
57
|
-
project_id_or_slug:
|
|
56
|
+
export const ProjectParamsSchema = Type.Object({
|
|
57
|
+
project_id_or_slug: Type.String(),
|
|
58
58
|
});
|
|
59
59
|
/**
|
|
60
60
|
* Create project request schema
|
|
61
61
|
*/
|
|
62
|
-
export const CreateProjectSchema =
|
|
63
|
-
name:
|
|
62
|
+
export const CreateProjectSchema = Type.Object({
|
|
63
|
+
name: Type.String({ minLength: 1, maxLength: 255 }),
|
|
64
64
|
slug: SlugSchema,
|
|
65
|
-
type:
|
|
66
|
-
org_id:
|
|
65
|
+
type: Type.Enum(ProjectTypeEnum),
|
|
66
|
+
org_id: Type.String(),
|
|
67
67
|
});
|
|
68
68
|
/**
|
|
69
69
|
* Update project request schema
|
|
70
70
|
*/
|
|
71
|
-
export const UpdateProjectSchema =
|
|
72
|
-
name:
|
|
73
|
-
slug:
|
|
71
|
+
export const UpdateProjectSchema = Type.Object({
|
|
72
|
+
name: Type.Optional(Type.String({ minLength: 1, maxLength: 255 })),
|
|
73
|
+
slug: Type.Optional(SlugSchema),
|
|
74
74
|
});
|
|
75
75
|
/**
|
|
76
76
|
* Single project response schema
|
|
77
77
|
*/
|
|
78
|
-
export const ProjectResponseSchema =
|
|
79
|
-
success:
|
|
78
|
+
export const ProjectResponseSchema = Type.Object({
|
|
79
|
+
success: Type.Literal(true),
|
|
80
80
|
data: ProjectSchema,
|
|
81
81
|
});
|
|
82
82
|
/**
|
|
83
83
|
* Multiple projects response schema
|
|
84
84
|
*/
|
|
85
|
-
export const ProjectsResponseSchema =
|
|
86
|
-
projects:
|
|
85
|
+
export const ProjectsResponseSchema = Type.Object({
|
|
86
|
+
projects: Type.Array(ProjectSchema),
|
|
87
87
|
});
|
|
88
88
|
/**
|
|
89
89
|
* Project error response schema
|
|
90
90
|
* Discriminated union by error code
|
|
91
91
|
*/
|
|
92
|
-
export const ProjectErrorSchema =
|
|
93
|
-
|
|
94
|
-
code:
|
|
95
|
-
message:
|
|
92
|
+
export const ProjectErrorSchema = Type.Union([
|
|
93
|
+
Type.Object({
|
|
94
|
+
code: Type.Literal("PROJECT_NOT_FOUND"),
|
|
95
|
+
message: Type.String(),
|
|
96
96
|
}),
|
|
97
|
-
|
|
98
|
-
code:
|
|
99
|
-
message:
|
|
97
|
+
Type.Object({
|
|
98
|
+
code: Type.Literal("PROJECT_NOT_IN_ORG"),
|
|
99
|
+
message: Type.String(),
|
|
100
100
|
}),
|
|
101
|
-
|
|
102
|
-
code:
|
|
103
|
-
message:
|
|
101
|
+
Type.Object({
|
|
102
|
+
code: Type.Literal("INVALID_SLUG"),
|
|
103
|
+
message: Type.String(),
|
|
104
104
|
}),
|
|
105
|
-
|
|
106
|
-
code:
|
|
107
|
-
message:
|
|
105
|
+
Type.Object({
|
|
106
|
+
code: Type.Literal("SLUG_ALREADY_EXISTS"),
|
|
107
|
+
message: Type.String(),
|
|
108
108
|
}),
|
|
109
|
-
|
|
110
|
-
code:
|
|
111
|
-
message:
|
|
109
|
+
Type.Object({
|
|
110
|
+
code: Type.Literal("FORBIDDEN"),
|
|
111
|
+
message: Type.String(),
|
|
112
112
|
}),
|
|
113
|
-
|
|
114
|
-
code:
|
|
115
|
-
message:
|
|
113
|
+
Type.Object({
|
|
114
|
+
code: Type.Literal("CREATE_FAILED"),
|
|
115
|
+
message: Type.String(),
|
|
116
116
|
}),
|
|
117
|
-
|
|
118
|
-
code:
|
|
119
|
-
message:
|
|
117
|
+
Type.Object({
|
|
118
|
+
code: Type.Literal("UPDATE_FAILED"),
|
|
119
|
+
message: Type.String(),
|
|
120
120
|
}),
|
|
121
|
-
|
|
122
|
-
code:
|
|
123
|
-
message:
|
|
121
|
+
Type.Object({
|
|
122
|
+
code: Type.Literal("DELETE_FAILED"),
|
|
123
|
+
message: Type.String(),
|
|
124
124
|
}),
|
|
125
|
-
|
|
126
|
-
code:
|
|
127
|
-
message:
|
|
125
|
+
Type.Object({
|
|
126
|
+
code: Type.Literal("FETCH_FAILED"),
|
|
127
|
+
message: Type.String(),
|
|
128
128
|
}),
|
|
129
|
-
|
|
130
|
-
code:
|
|
131
|
-
message:
|
|
129
|
+
Type.Object({
|
|
130
|
+
code: Type.Literal("ARCHIVE_FAILED"),
|
|
131
|
+
message: Type.String(),
|
|
132
132
|
}),
|
|
133
|
-
|
|
134
|
-
code:
|
|
135
|
-
message:
|
|
133
|
+
Type.Object({
|
|
134
|
+
code: Type.Literal("INVALID_REQUEST"),
|
|
135
|
+
message: Type.String(),
|
|
136
136
|
}),
|
|
137
137
|
]);
|
|
138
138
|
/**
|
|
139
139
|
* Project error response wrapper
|
|
140
140
|
*/
|
|
141
|
-
export const ProjectErrorResponseSchema =
|
|
142
|
-
success:
|
|
141
|
+
export const ProjectErrorResponseSchema = Type.Object({
|
|
142
|
+
success: Type.Literal(false),
|
|
143
143
|
error: ProjectErrorSchema,
|
|
144
144
|
});
|
|
145
|
-
export const ProjectRequestResponseSchema =
|
|
145
|
+
export const ProjectRequestResponseSchema = Type.Union([ProjectResponseSchema, ProjectErrorResponseSchema]);
|