@teardown/schemas 0.1.0
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/index.d.ts +3 -0
- package/dist/common/index.js +3 -0
- package/dist/common/primitives.d.ts +11 -0
- package/dist/common/primitives.js +9 -0
- package/dist/common/responses.d.ts +27 -0
- package/dist/common/responses.js +13 -0
- package/dist/common/type-checks.d.ts +58 -0
- package/dist/common/type-checks.js +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +14 -0
- package/dist/modules/analytics/index.d.ts +1 -0
- package/dist/modules/analytics/index.js +1 -0
- package/dist/modules/analytics/schemas.d.ts +239 -0
- package/dist/modules/analytics/schemas.js +136 -0
- package/dist/modules/builds/index.d.ts +1 -0
- package/dist/modules/builds/index.js +1 -0
- package/dist/modules/builds/schemas.d.ts +248 -0
- package/dist/modules/builds/schemas.js +137 -0
- package/dist/modules/devices/index.d.ts +1 -0
- package/dist/modules/devices/index.js +1 -0
- package/dist/modules/devices/schemas.d.ts +207 -0
- package/dist/modules/devices/schemas.js +165 -0
- package/dist/modules/environment/index.d.ts +1 -0
- package/dist/modules/environment/index.js +1 -0
- package/dist/modules/environment/schemas.d.ts +56 -0
- package/dist/modules/environment/schemas.js +57 -0
- package/dist/modules/events/index.d.ts +1 -0
- package/dist/modules/events/index.js +1 -0
- package/dist/modules/events/schemas.d.ts +138 -0
- package/dist/modules/events/schemas.js +116 -0
- package/dist/modules/identify/index.d.ts +1 -0
- package/dist/modules/identify/index.js +1 -0
- package/dist/modules/identify/schemas.d.ts +377 -0
- package/dist/modules/identify/schemas.js +221 -0
- package/dist/modules/index.d.ts +12 -0
- package/dist/modules/index.js +12 -0
- package/dist/modules/me/index.d.ts +1 -0
- package/dist/modules/me/index.js +1 -0
- package/dist/modules/me/schemas.d.ts +75 -0
- package/dist/modules/me/schemas.js +76 -0
- package/dist/modules/orgs/index.d.ts +1 -0
- package/dist/modules/orgs/index.js +1 -0
- package/dist/modules/orgs/schemas.d.ts +308 -0
- package/dist/modules/orgs/schemas.js +214 -0
- package/dist/modules/personas/index.d.ts +1 -0
- package/dist/modules/personas/index.js +1 -0
- package/dist/modules/personas/schemas.d.ts +170 -0
- package/dist/modules/personas/schemas.js +100 -0
- package/dist/modules/projects/index.d.ts +1 -0
- package/dist/modules/projects/index.js +1 -0
- package/dist/modules/projects/schemas.d.ts +222 -0
- package/dist/modules/projects/schemas.js +145 -0
- package/dist/modules/sessions/index.d.ts +1 -0
- package/dist/modules/sessions/index.js +1 -0
- package/dist/modules/sessions/schemas.d.ts +258 -0
- package/dist/modules/sessions/schemas.js +128 -0
- package/dist/modules/versions/index.d.ts +1 -0
- package/dist/modules/versions/index.js +1 -0
- package/dist/modules/versions/schemas.d.ts +248 -0
- package/dist/modules/versions/schemas.js +155 -0
- package/package.json +106 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./schemas";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./schemas";
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { type Static } from "elysia";
|
|
2
|
+
import type { AssertSchemaCompatibleWithRow, AssertTrue } from "../../common";
|
|
3
|
+
/**
|
|
4
|
+
* Base persona schema
|
|
5
|
+
* Represents personas table structure
|
|
6
|
+
*/
|
|
7
|
+
export declare const PersonaSchema: import("@sinclair/typebox").TObject<{
|
|
8
|
+
id: import("@sinclair/typebox").TString;
|
|
9
|
+
environment_id: import("@sinclair/typebox").TString;
|
|
10
|
+
user_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
11
|
+
name: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
12
|
+
email: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
13
|
+
created_at: import("@sinclair/typebox").TString;
|
|
14
|
+
updated_at: import("@sinclair/typebox").TString;
|
|
15
|
+
}>;
|
|
16
|
+
export type Persona = Static<typeof PersonaSchema>;
|
|
17
|
+
/**
|
|
18
|
+
* Persona params schema
|
|
19
|
+
*/
|
|
20
|
+
export declare const PersonaParamsSchema: import("@sinclair/typebox").TObject<{
|
|
21
|
+
persona_id: import("@sinclair/typebox").TString;
|
|
22
|
+
}>;
|
|
23
|
+
export type PersonaParams = Static<typeof PersonaParamsSchema>;
|
|
24
|
+
/**
|
|
25
|
+
* Search personas query schema
|
|
26
|
+
* Supports pagination, search, and sorting
|
|
27
|
+
*/
|
|
28
|
+
export declare const SearchPersonasQuerySchema: import("@sinclair/typebox").TObject<{
|
|
29
|
+
project_id: import("@sinclair/typebox").TString;
|
|
30
|
+
page: import("@sinclair/typebox").TNumber;
|
|
31
|
+
limit: import("@sinclair/typebox").TNumber;
|
|
32
|
+
search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
33
|
+
sort_by: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"created_at">, import("@sinclair/typebox").TLiteral<"updated_at">, import("@sinclair/typebox").TLiteral<"name">, import("@sinclair/typebox").TLiteral<"email">]>;
|
|
34
|
+
sort_order: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"asc">, import("@sinclair/typebox").TLiteral<"desc">]>;
|
|
35
|
+
}>;
|
|
36
|
+
export type SearchPersonasQuery = Static<typeof SearchPersonasQuerySchema>;
|
|
37
|
+
/**
|
|
38
|
+
* Search personas query schema without project_id (injected from headers)
|
|
39
|
+
*/
|
|
40
|
+
export declare const SearchPersonasQueryParamsSchema: import("@sinclair/typebox").TObject<{
|
|
41
|
+
search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
42
|
+
limit: import("@sinclair/typebox").TNumber;
|
|
43
|
+
page: import("@sinclair/typebox").TNumber;
|
|
44
|
+
sort_by: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"created_at">, import("@sinclair/typebox").TLiteral<"updated_at">, import("@sinclair/typebox").TLiteral<"name">, import("@sinclair/typebox").TLiteral<"email">]>;
|
|
45
|
+
sort_order: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"asc">, import("@sinclair/typebox").TLiteral<"desc">]>;
|
|
46
|
+
}>;
|
|
47
|
+
export type SearchPersonasQueryParams = Static<typeof SearchPersonasQueryParamsSchema>;
|
|
48
|
+
/**
|
|
49
|
+
* Personas by IDs request schema
|
|
50
|
+
*/
|
|
51
|
+
export declare const PersonasByIdsSchema: import("@sinclair/typebox").TObject<{
|
|
52
|
+
persona_ids: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
|
|
53
|
+
}>;
|
|
54
|
+
export type PersonasByIds = Static<typeof PersonasByIdsSchema>;
|
|
55
|
+
/**
|
|
56
|
+
* Paginated personas response schema
|
|
57
|
+
*/
|
|
58
|
+
export declare const PersonasResponseSchema: import("@sinclair/typebox").TObject<{
|
|
59
|
+
personas: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
60
|
+
id: import("@sinclair/typebox").TString;
|
|
61
|
+
environment_id: import("@sinclair/typebox").TString;
|
|
62
|
+
user_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
63
|
+
name: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
64
|
+
email: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
65
|
+
created_at: import("@sinclair/typebox").TString;
|
|
66
|
+
updated_at: import("@sinclair/typebox").TString;
|
|
67
|
+
}>>;
|
|
68
|
+
pagination: import("@sinclair/typebox").TObject<{
|
|
69
|
+
page: import("@sinclair/typebox").TInteger;
|
|
70
|
+
limit: import("@sinclair/typebox").TInteger;
|
|
71
|
+
total: import("@sinclair/typebox").TInteger;
|
|
72
|
+
total_pages: import("@sinclair/typebox").TInteger;
|
|
73
|
+
}>;
|
|
74
|
+
}>;
|
|
75
|
+
export type PersonasResponse = Static<typeof PersonasResponseSchema>;
|
|
76
|
+
/**
|
|
77
|
+
* Single persona response schema
|
|
78
|
+
*/
|
|
79
|
+
export declare const PersonaResponseSchema: import("@sinclair/typebox").TObject<{
|
|
80
|
+
success: import("@sinclair/typebox").TLiteral<true>;
|
|
81
|
+
data: import("@sinclair/typebox").TObject<{
|
|
82
|
+
id: import("@sinclair/typebox").TString;
|
|
83
|
+
environment_id: import("@sinclair/typebox").TString;
|
|
84
|
+
user_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
85
|
+
name: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
86
|
+
email: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
87
|
+
created_at: import("@sinclair/typebox").TString;
|
|
88
|
+
updated_at: import("@sinclair/typebox").TString;
|
|
89
|
+
}>;
|
|
90
|
+
}>;
|
|
91
|
+
export type PersonaResponse = Static<typeof PersonaResponseSchema>;
|
|
92
|
+
/**
|
|
93
|
+
* Persona error response schema
|
|
94
|
+
* Discriminated union by error code
|
|
95
|
+
*/
|
|
96
|
+
export declare const PersonaErrorSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
97
|
+
code: import("@sinclair/typebox").TLiteral<"PERSONA_NOT_FOUND">;
|
|
98
|
+
message: import("@sinclair/typebox").TString;
|
|
99
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
100
|
+
code: import("@sinclair/typebox").TLiteral<"PROJECT_NOT_FOUND">;
|
|
101
|
+
message: import("@sinclair/typebox").TString;
|
|
102
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
103
|
+
code: import("@sinclair/typebox").TLiteral<"FORBIDDEN">;
|
|
104
|
+
message: import("@sinclair/typebox").TString;
|
|
105
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
106
|
+
code: import("@sinclair/typebox").TLiteral<"FETCH_FAILED">;
|
|
107
|
+
message: import("@sinclair/typebox").TString;
|
|
108
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
109
|
+
code: import("@sinclair/typebox").TLiteral<"INVALID_PARAMS">;
|
|
110
|
+
message: import("@sinclair/typebox").TString;
|
|
111
|
+
}>]>;
|
|
112
|
+
export type PersonaError = Static<typeof PersonaErrorSchema>;
|
|
113
|
+
/**
|
|
114
|
+
* Persona error response wrapper
|
|
115
|
+
*/
|
|
116
|
+
export declare const PersonaErrorResponseSchema: import("@sinclair/typebox").TObject<{
|
|
117
|
+
success: import("@sinclair/typebox").TLiteral<false>;
|
|
118
|
+
error: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
119
|
+
code: import("@sinclair/typebox").TLiteral<"PERSONA_NOT_FOUND">;
|
|
120
|
+
message: import("@sinclair/typebox").TString;
|
|
121
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
122
|
+
code: import("@sinclair/typebox").TLiteral<"PROJECT_NOT_FOUND">;
|
|
123
|
+
message: import("@sinclair/typebox").TString;
|
|
124
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
125
|
+
code: import("@sinclair/typebox").TLiteral<"FORBIDDEN">;
|
|
126
|
+
message: import("@sinclair/typebox").TString;
|
|
127
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
128
|
+
code: import("@sinclair/typebox").TLiteral<"FETCH_FAILED">;
|
|
129
|
+
message: import("@sinclair/typebox").TString;
|
|
130
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
131
|
+
code: import("@sinclair/typebox").TLiteral<"INVALID_PARAMS">;
|
|
132
|
+
message: import("@sinclair/typebox").TString;
|
|
133
|
+
}>]>;
|
|
134
|
+
}>;
|
|
135
|
+
export type PersonaErrorResponse = Static<typeof PersonaErrorResponseSchema>;
|
|
136
|
+
/**
|
|
137
|
+
* Persona request response schema
|
|
138
|
+
*/
|
|
139
|
+
export declare const PersonaRequestResponseSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
140
|
+
success: import("@sinclair/typebox").TLiteral<true>;
|
|
141
|
+
data: import("@sinclair/typebox").TObject<{
|
|
142
|
+
id: import("@sinclair/typebox").TString;
|
|
143
|
+
environment_id: import("@sinclair/typebox").TString;
|
|
144
|
+
user_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
145
|
+
name: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
146
|
+
email: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
147
|
+
created_at: import("@sinclair/typebox").TString;
|
|
148
|
+
updated_at: import("@sinclair/typebox").TString;
|
|
149
|
+
}>;
|
|
150
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
151
|
+
success: import("@sinclair/typebox").TLiteral<false>;
|
|
152
|
+
error: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
153
|
+
code: import("@sinclair/typebox").TLiteral<"PERSONA_NOT_FOUND">;
|
|
154
|
+
message: import("@sinclair/typebox").TString;
|
|
155
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
156
|
+
code: import("@sinclair/typebox").TLiteral<"PROJECT_NOT_FOUND">;
|
|
157
|
+
message: import("@sinclair/typebox").TString;
|
|
158
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
159
|
+
code: import("@sinclair/typebox").TLiteral<"FORBIDDEN">;
|
|
160
|
+
message: import("@sinclair/typebox").TString;
|
|
161
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
162
|
+
code: import("@sinclair/typebox").TLiteral<"FETCH_FAILED">;
|
|
163
|
+
message: import("@sinclair/typebox").TString;
|
|
164
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
165
|
+
code: import("@sinclair/typebox").TLiteral<"INVALID_PARAMS">;
|
|
166
|
+
message: import("@sinclair/typebox").TString;
|
|
167
|
+
}>]>;
|
|
168
|
+
}>]>;
|
|
169
|
+
export type PersonaRequestResponse = Static<typeof PersonaRequestResponseSchema>;
|
|
170
|
+
export type _CheckPersonaRow = AssertTrue<AssertSchemaCompatibleWithRow<Persona, "personas">>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { t } from "elysia";
|
|
2
|
+
/**
|
|
3
|
+
* Base persona schema
|
|
4
|
+
* Represents personas table structure
|
|
5
|
+
*/
|
|
6
|
+
export const PersonaSchema = t.Object({
|
|
7
|
+
id: t.String({ format: "uuid" }),
|
|
8
|
+
environment_id: t.String({ format: "uuid" }),
|
|
9
|
+
user_id: t.Union([t.String(), t.Null()]),
|
|
10
|
+
name: t.Union([t.String(), t.Null()]),
|
|
11
|
+
email: t.Union([t.String({ format: "email" }), t.Null()]),
|
|
12
|
+
created_at: t.String(),
|
|
13
|
+
updated_at: t.String(),
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* Persona params schema
|
|
17
|
+
*/
|
|
18
|
+
export const PersonaParamsSchema = t.Object({
|
|
19
|
+
persona_id: t.String({ format: "uuid" }),
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Search personas query schema
|
|
23
|
+
* Supports pagination, search, and sorting
|
|
24
|
+
*/
|
|
25
|
+
export const SearchPersonasQuerySchema = t.Object({
|
|
26
|
+
project_id: t.String({ format: "uuid" }),
|
|
27
|
+
page: t.Numeric({ minimum: 1, default: 1 }),
|
|
28
|
+
limit: t.Numeric({ minimum: 1, maximum: 100, default: 20 }),
|
|
29
|
+
search: t.Optional(t.String()),
|
|
30
|
+
sort_by: t.Union([t.Literal("created_at"), t.Literal("updated_at"), t.Literal("name"), t.Literal("email")], {
|
|
31
|
+
default: "created_at",
|
|
32
|
+
}),
|
|
33
|
+
sort_order: t.Union([t.Literal("asc"), t.Literal("desc")], { default: "desc" }),
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* Search personas query schema without project_id (injected from headers)
|
|
37
|
+
*/
|
|
38
|
+
export const SearchPersonasQueryParamsSchema = t.Omit(SearchPersonasQuerySchema, ["project_id"]);
|
|
39
|
+
/**
|
|
40
|
+
* Personas by IDs request schema
|
|
41
|
+
*/
|
|
42
|
+
export const PersonasByIdsSchema = t.Object({
|
|
43
|
+
persona_ids: t.Array(t.String({ format: "uuid" }), { minItems: 1, maxItems: 100 }),
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* Paginated personas response schema
|
|
47
|
+
*/
|
|
48
|
+
export const PersonasResponseSchema = t.Object({
|
|
49
|
+
personas: t.Array(PersonaSchema),
|
|
50
|
+
pagination: t.Object({
|
|
51
|
+
page: t.Integer({ minimum: 1 }),
|
|
52
|
+
limit: t.Integer({ minimum: 1 }),
|
|
53
|
+
total: t.Integer({ minimum: 0 }),
|
|
54
|
+
total_pages: t.Integer({ minimum: 0 }),
|
|
55
|
+
}),
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Single persona response schema
|
|
59
|
+
*/
|
|
60
|
+
export const PersonaResponseSchema = t.Object({
|
|
61
|
+
success: t.Literal(true),
|
|
62
|
+
data: PersonaSchema,
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* Persona error response schema
|
|
66
|
+
* Discriminated union by error code
|
|
67
|
+
*/
|
|
68
|
+
export const PersonaErrorSchema = t.Union([
|
|
69
|
+
t.Object({
|
|
70
|
+
code: t.Literal("PERSONA_NOT_FOUND"),
|
|
71
|
+
message: t.String(),
|
|
72
|
+
}),
|
|
73
|
+
t.Object({
|
|
74
|
+
code: t.Literal("PROJECT_NOT_FOUND"),
|
|
75
|
+
message: t.String(),
|
|
76
|
+
}),
|
|
77
|
+
t.Object({
|
|
78
|
+
code: t.Literal("FORBIDDEN"),
|
|
79
|
+
message: t.String(),
|
|
80
|
+
}),
|
|
81
|
+
t.Object({
|
|
82
|
+
code: t.Literal("FETCH_FAILED"),
|
|
83
|
+
message: t.String(),
|
|
84
|
+
}),
|
|
85
|
+
t.Object({
|
|
86
|
+
code: t.Literal("INVALID_PARAMS"),
|
|
87
|
+
message: t.String(),
|
|
88
|
+
}),
|
|
89
|
+
]);
|
|
90
|
+
/**
|
|
91
|
+
* Persona error response wrapper
|
|
92
|
+
*/
|
|
93
|
+
export const PersonaErrorResponseSchema = t.Object({
|
|
94
|
+
success: t.Literal(false),
|
|
95
|
+
error: PersonaErrorSchema,
|
|
96
|
+
});
|
|
97
|
+
/**
|
|
98
|
+
* Persona request response schema
|
|
99
|
+
*/
|
|
100
|
+
export const PersonaRequestResponseSchema = t.Union([PersonaResponseSchema, PersonaErrorResponseSchema]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./schemas";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./schemas";
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { ProjectStatusEnum, ProjectTypeEnum } from "@teardown/types";
|
|
2
|
+
import { type Static } from "elysia";
|
|
3
|
+
import { type AssertSchemaCompatibleWithInsert, type AssertSchemaCompatibleWithRow, type AssertSchemaCompatibleWithUpdate, type AssertTrue } from "../../common";
|
|
4
|
+
/**
|
|
5
|
+
* Parse and validate a ProjectTypeEnum value
|
|
6
|
+
* Uses a switch statement to ensure type safety and runtime validation
|
|
7
|
+
* @param value - The value to parse
|
|
8
|
+
* @returns The validated ProjectTypeEnum value
|
|
9
|
+
* @throws Error if the value is not a valid ProjectTypeEnum
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseProjectTypeEnum(value: unknown): ProjectTypeEnum;
|
|
12
|
+
/**
|
|
13
|
+
* Parse and validate a ProjectStatusEnum value
|
|
14
|
+
* Uses a switch statement to ensure type safety and runtime validation
|
|
15
|
+
* @param value - The value to parse
|
|
16
|
+
* @returns The validated ProjectStatusEnum value
|
|
17
|
+
* @throws Error if the value is not a valid ProjectStatusEnum
|
|
18
|
+
*/
|
|
19
|
+
export declare function parseProjectStatusEnum(value: unknown): ProjectStatusEnum;
|
|
20
|
+
/**
|
|
21
|
+
* Base project schema
|
|
22
|
+
* Represents projects table structure
|
|
23
|
+
*/
|
|
24
|
+
export declare const ProjectSchema: import("@sinclair/typebox").TObject<{
|
|
25
|
+
id: import("@sinclair/typebox").TString;
|
|
26
|
+
org_id: import("@sinclair/typebox").TString;
|
|
27
|
+
name: import("@sinclair/typebox").TString;
|
|
28
|
+
slug: import("@sinclair/typebox").TString;
|
|
29
|
+
type: import("@sinclair/typebox").TEnum<typeof ProjectTypeEnum>;
|
|
30
|
+
status: import("@sinclair/typebox").TEnum<typeof ProjectStatusEnum>;
|
|
31
|
+
created_at: import("@sinclair/typebox").TString;
|
|
32
|
+
updated_at: import("@sinclair/typebox").TString;
|
|
33
|
+
}>;
|
|
34
|
+
export type Project = Static<typeof ProjectSchema>;
|
|
35
|
+
export declare const ProjectParamsSchema: import("@sinclair/typebox").TObject<{
|
|
36
|
+
project_id_or_slug: import("@sinclair/typebox").TString;
|
|
37
|
+
}>;
|
|
38
|
+
export type ProjectParams = Static<typeof ProjectParamsSchema>;
|
|
39
|
+
/**
|
|
40
|
+
* Create project request schema
|
|
41
|
+
*/
|
|
42
|
+
export declare const CreateProjectSchema: import("@sinclair/typebox").TObject<{
|
|
43
|
+
name: import("@sinclair/typebox").TString;
|
|
44
|
+
slug: import("@sinclair/typebox").TString;
|
|
45
|
+
type: import("@sinclair/typebox").TEnum<typeof ProjectTypeEnum>;
|
|
46
|
+
org_id: import("@sinclair/typebox").TString;
|
|
47
|
+
}>;
|
|
48
|
+
export type CreateProject = Static<typeof CreateProjectSchema>;
|
|
49
|
+
/**
|
|
50
|
+
* Update project request schema
|
|
51
|
+
*/
|
|
52
|
+
export declare const UpdateProjectSchema: import("@sinclair/typebox").TObject<{
|
|
53
|
+
name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
54
|
+
slug: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
55
|
+
}>;
|
|
56
|
+
export type UpdateProject = Static<typeof UpdateProjectSchema>;
|
|
57
|
+
/**
|
|
58
|
+
* Single project response schema
|
|
59
|
+
*/
|
|
60
|
+
export declare const ProjectResponseSchema: import("@sinclair/typebox").TObject<{
|
|
61
|
+
success: import("@sinclair/typebox").TLiteral<true>;
|
|
62
|
+
data: import("@sinclair/typebox").TObject<{
|
|
63
|
+
id: import("@sinclair/typebox").TString;
|
|
64
|
+
org_id: import("@sinclair/typebox").TString;
|
|
65
|
+
name: import("@sinclair/typebox").TString;
|
|
66
|
+
slug: import("@sinclair/typebox").TString;
|
|
67
|
+
type: import("@sinclair/typebox").TEnum<typeof ProjectTypeEnum>;
|
|
68
|
+
status: import("@sinclair/typebox").TEnum<typeof ProjectStatusEnum>;
|
|
69
|
+
created_at: import("@sinclair/typebox").TString;
|
|
70
|
+
updated_at: import("@sinclair/typebox").TString;
|
|
71
|
+
}>;
|
|
72
|
+
}>;
|
|
73
|
+
export type ProjectResponse = Static<typeof ProjectResponseSchema>;
|
|
74
|
+
/**
|
|
75
|
+
* Multiple projects response schema
|
|
76
|
+
*/
|
|
77
|
+
export declare const ProjectsResponseSchema: import("@sinclair/typebox").TObject<{
|
|
78
|
+
projects: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
79
|
+
id: import("@sinclair/typebox").TString;
|
|
80
|
+
org_id: import("@sinclair/typebox").TString;
|
|
81
|
+
name: import("@sinclair/typebox").TString;
|
|
82
|
+
slug: import("@sinclair/typebox").TString;
|
|
83
|
+
type: import("@sinclair/typebox").TEnum<typeof ProjectTypeEnum>;
|
|
84
|
+
status: import("@sinclair/typebox").TEnum<typeof ProjectStatusEnum>;
|
|
85
|
+
created_at: import("@sinclair/typebox").TString;
|
|
86
|
+
updated_at: import("@sinclair/typebox").TString;
|
|
87
|
+
}>>;
|
|
88
|
+
}>;
|
|
89
|
+
export type ProjectsResponse = Static<typeof ProjectsResponseSchema>;
|
|
90
|
+
/**
|
|
91
|
+
* Project error response schema
|
|
92
|
+
* Discriminated union by error code
|
|
93
|
+
*/
|
|
94
|
+
export declare const ProjectErrorSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
95
|
+
code: import("@sinclair/typebox").TLiteral<"PROJECT_NOT_FOUND">;
|
|
96
|
+
message: import("@sinclair/typebox").TString;
|
|
97
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
98
|
+
code: import("@sinclair/typebox").TLiteral<"PROJECT_NOT_IN_ORG">;
|
|
99
|
+
message: import("@sinclair/typebox").TString;
|
|
100
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
101
|
+
code: import("@sinclair/typebox").TLiteral<"INVALID_SLUG">;
|
|
102
|
+
message: import("@sinclair/typebox").TString;
|
|
103
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
104
|
+
code: import("@sinclair/typebox").TLiteral<"SLUG_ALREADY_EXISTS">;
|
|
105
|
+
message: import("@sinclair/typebox").TString;
|
|
106
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
107
|
+
code: import("@sinclair/typebox").TLiteral<"FORBIDDEN">;
|
|
108
|
+
message: import("@sinclair/typebox").TString;
|
|
109
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
110
|
+
code: import("@sinclair/typebox").TLiteral<"CREATE_FAILED">;
|
|
111
|
+
message: import("@sinclair/typebox").TString;
|
|
112
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
113
|
+
code: import("@sinclair/typebox").TLiteral<"UPDATE_FAILED">;
|
|
114
|
+
message: import("@sinclair/typebox").TString;
|
|
115
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
116
|
+
code: import("@sinclair/typebox").TLiteral<"DELETE_FAILED">;
|
|
117
|
+
message: import("@sinclair/typebox").TString;
|
|
118
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
119
|
+
code: import("@sinclair/typebox").TLiteral<"FETCH_FAILED">;
|
|
120
|
+
message: import("@sinclair/typebox").TString;
|
|
121
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
122
|
+
code: import("@sinclair/typebox").TLiteral<"ARCHIVE_FAILED">;
|
|
123
|
+
message: import("@sinclair/typebox").TString;
|
|
124
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
125
|
+
code: import("@sinclair/typebox").TLiteral<"INVALID_REQUEST">;
|
|
126
|
+
message: import("@sinclair/typebox").TString;
|
|
127
|
+
}>]>;
|
|
128
|
+
export type ProjectError = Static<typeof ProjectErrorSchema>;
|
|
129
|
+
/**
|
|
130
|
+
* Project error response wrapper
|
|
131
|
+
*/
|
|
132
|
+
export declare const ProjectErrorResponseSchema: import("@sinclair/typebox").TObject<{
|
|
133
|
+
success: import("@sinclair/typebox").TLiteral<false>;
|
|
134
|
+
error: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
135
|
+
code: import("@sinclair/typebox").TLiteral<"PROJECT_NOT_FOUND">;
|
|
136
|
+
message: import("@sinclair/typebox").TString;
|
|
137
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
138
|
+
code: import("@sinclair/typebox").TLiteral<"PROJECT_NOT_IN_ORG">;
|
|
139
|
+
message: import("@sinclair/typebox").TString;
|
|
140
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
141
|
+
code: import("@sinclair/typebox").TLiteral<"INVALID_SLUG">;
|
|
142
|
+
message: import("@sinclair/typebox").TString;
|
|
143
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
144
|
+
code: import("@sinclair/typebox").TLiteral<"SLUG_ALREADY_EXISTS">;
|
|
145
|
+
message: import("@sinclair/typebox").TString;
|
|
146
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
147
|
+
code: import("@sinclair/typebox").TLiteral<"FORBIDDEN">;
|
|
148
|
+
message: import("@sinclair/typebox").TString;
|
|
149
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
150
|
+
code: import("@sinclair/typebox").TLiteral<"CREATE_FAILED">;
|
|
151
|
+
message: import("@sinclair/typebox").TString;
|
|
152
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
153
|
+
code: import("@sinclair/typebox").TLiteral<"UPDATE_FAILED">;
|
|
154
|
+
message: import("@sinclair/typebox").TString;
|
|
155
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
156
|
+
code: import("@sinclair/typebox").TLiteral<"DELETE_FAILED">;
|
|
157
|
+
message: import("@sinclair/typebox").TString;
|
|
158
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
159
|
+
code: import("@sinclair/typebox").TLiteral<"FETCH_FAILED">;
|
|
160
|
+
message: import("@sinclair/typebox").TString;
|
|
161
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
162
|
+
code: import("@sinclair/typebox").TLiteral<"ARCHIVE_FAILED">;
|
|
163
|
+
message: import("@sinclair/typebox").TString;
|
|
164
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
165
|
+
code: import("@sinclair/typebox").TLiteral<"INVALID_REQUEST">;
|
|
166
|
+
message: import("@sinclair/typebox").TString;
|
|
167
|
+
}>]>;
|
|
168
|
+
}>;
|
|
169
|
+
export type ProjectErrorResponse = Static<typeof ProjectErrorResponseSchema>;
|
|
170
|
+
export declare const ProjectRequestResponseSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
171
|
+
success: import("@sinclair/typebox").TLiteral<true>;
|
|
172
|
+
data: import("@sinclair/typebox").TObject<{
|
|
173
|
+
id: import("@sinclair/typebox").TString;
|
|
174
|
+
org_id: import("@sinclair/typebox").TString;
|
|
175
|
+
name: import("@sinclair/typebox").TString;
|
|
176
|
+
slug: import("@sinclair/typebox").TString;
|
|
177
|
+
type: import("@sinclair/typebox").TEnum<typeof ProjectTypeEnum>;
|
|
178
|
+
status: import("@sinclair/typebox").TEnum<typeof ProjectStatusEnum>;
|
|
179
|
+
created_at: import("@sinclair/typebox").TString;
|
|
180
|
+
updated_at: import("@sinclair/typebox").TString;
|
|
181
|
+
}>;
|
|
182
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
183
|
+
success: import("@sinclair/typebox").TLiteral<false>;
|
|
184
|
+
error: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
185
|
+
code: import("@sinclair/typebox").TLiteral<"PROJECT_NOT_FOUND">;
|
|
186
|
+
message: import("@sinclair/typebox").TString;
|
|
187
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
188
|
+
code: import("@sinclair/typebox").TLiteral<"PROJECT_NOT_IN_ORG">;
|
|
189
|
+
message: import("@sinclair/typebox").TString;
|
|
190
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
191
|
+
code: import("@sinclair/typebox").TLiteral<"INVALID_SLUG">;
|
|
192
|
+
message: import("@sinclair/typebox").TString;
|
|
193
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
194
|
+
code: import("@sinclair/typebox").TLiteral<"SLUG_ALREADY_EXISTS">;
|
|
195
|
+
message: import("@sinclair/typebox").TString;
|
|
196
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
197
|
+
code: import("@sinclair/typebox").TLiteral<"FORBIDDEN">;
|
|
198
|
+
message: import("@sinclair/typebox").TString;
|
|
199
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
200
|
+
code: import("@sinclair/typebox").TLiteral<"CREATE_FAILED">;
|
|
201
|
+
message: import("@sinclair/typebox").TString;
|
|
202
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
203
|
+
code: import("@sinclair/typebox").TLiteral<"UPDATE_FAILED">;
|
|
204
|
+
message: import("@sinclair/typebox").TString;
|
|
205
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
206
|
+
code: import("@sinclair/typebox").TLiteral<"DELETE_FAILED">;
|
|
207
|
+
message: import("@sinclair/typebox").TString;
|
|
208
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
209
|
+
code: import("@sinclair/typebox").TLiteral<"FETCH_FAILED">;
|
|
210
|
+
message: import("@sinclair/typebox").TString;
|
|
211
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
212
|
+
code: import("@sinclair/typebox").TLiteral<"ARCHIVE_FAILED">;
|
|
213
|
+
message: import("@sinclair/typebox").TString;
|
|
214
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
215
|
+
code: import("@sinclair/typebox").TLiteral<"INVALID_REQUEST">;
|
|
216
|
+
message: import("@sinclair/typebox").TString;
|
|
217
|
+
}>]>;
|
|
218
|
+
}>]>;
|
|
219
|
+
export type ProjectRequestResponse = Static<typeof ProjectRequestResponseSchema>;
|
|
220
|
+
export type _CheckProjectRow = AssertTrue<AssertSchemaCompatibleWithRow<Project, "projects">>;
|
|
221
|
+
export type _CheckCreateProject = AssertTrue<AssertSchemaCompatibleWithInsert<CreateProject, "projects">>;
|
|
222
|
+
export type _CheckUpdateProject = AssertTrue<AssertSchemaCompatibleWithUpdate<UpdateProject, "projects">>;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { ProjectStatusEnum, ProjectTypeEnum } from "@teardown/types";
|
|
2
|
+
import { t } from "elysia";
|
|
3
|
+
import { SlugSchema, } from "../../common";
|
|
4
|
+
/**
|
|
5
|
+
* Parse and validate a ProjectTypeEnum value
|
|
6
|
+
* Uses a switch statement to ensure type safety and runtime validation
|
|
7
|
+
* @param value - The value to parse
|
|
8
|
+
* @returns The validated ProjectTypeEnum value
|
|
9
|
+
* @throws Error if the value is not a valid ProjectTypeEnum
|
|
10
|
+
*/
|
|
11
|
+
export function parseProjectTypeEnum(value) {
|
|
12
|
+
switch (value) {
|
|
13
|
+
case ProjectTypeEnum.REACT_NATIVE:
|
|
14
|
+
return ProjectTypeEnum.REACT_NATIVE;
|
|
15
|
+
case ProjectTypeEnum.EXPO:
|
|
16
|
+
return ProjectTypeEnum.EXPO;
|
|
17
|
+
default:
|
|
18
|
+
throw new Error(`Invalid ProjectTypeEnum value: ${value}. Expected one of: ${Object.values(ProjectTypeEnum).join(", ")}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Parse and validate a ProjectStatusEnum value
|
|
23
|
+
* Uses a switch statement to ensure type safety and runtime validation
|
|
24
|
+
* @param value - The value to parse
|
|
25
|
+
* @returns The validated ProjectStatusEnum value
|
|
26
|
+
* @throws Error if the value is not a valid ProjectStatusEnum
|
|
27
|
+
*/
|
|
28
|
+
export function parseProjectStatusEnum(value) {
|
|
29
|
+
switch (value) {
|
|
30
|
+
case ProjectStatusEnum.PENDING_SETUP:
|
|
31
|
+
return ProjectStatusEnum.PENDING_SETUP;
|
|
32
|
+
case ProjectStatusEnum.ACTIVE:
|
|
33
|
+
return ProjectStatusEnum.ACTIVE;
|
|
34
|
+
case ProjectStatusEnum.PAUSED:
|
|
35
|
+
return ProjectStatusEnum.PAUSED;
|
|
36
|
+
case ProjectStatusEnum.ARCHIVED:
|
|
37
|
+
return ProjectStatusEnum.ARCHIVED;
|
|
38
|
+
default:
|
|
39
|
+
throw new Error(`Invalid ProjectStatusEnum value: ${value}. Expected one of: ${Object.values(ProjectStatusEnum).join(", ")}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Base project schema
|
|
44
|
+
* Represents projects table structure
|
|
45
|
+
*/
|
|
46
|
+
export const ProjectSchema = t.Object({
|
|
47
|
+
id: t.String({ format: "uuid" }),
|
|
48
|
+
org_id: t.String({ format: "uuid" }),
|
|
49
|
+
name: t.String({ minLength: 1 }),
|
|
50
|
+
slug: SlugSchema,
|
|
51
|
+
type: t.Enum(ProjectTypeEnum),
|
|
52
|
+
status: t.Enum(ProjectStatusEnum),
|
|
53
|
+
created_at: t.String(),
|
|
54
|
+
updated_at: t.String(),
|
|
55
|
+
});
|
|
56
|
+
export const ProjectParamsSchema = t.Object({
|
|
57
|
+
project_id_or_slug: t.String(),
|
|
58
|
+
});
|
|
59
|
+
/**
|
|
60
|
+
* Create project request schema
|
|
61
|
+
*/
|
|
62
|
+
export const CreateProjectSchema = t.Object({
|
|
63
|
+
name: t.String({ minLength: 1, maxLength: 255 }),
|
|
64
|
+
slug: SlugSchema,
|
|
65
|
+
type: t.Enum(ProjectTypeEnum),
|
|
66
|
+
org_id: t.String(),
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* Update project request schema
|
|
70
|
+
*/
|
|
71
|
+
export const UpdateProjectSchema = t.Object({
|
|
72
|
+
name: t.Optional(t.String({ minLength: 1, maxLength: 255 })),
|
|
73
|
+
slug: t.Optional(SlugSchema),
|
|
74
|
+
});
|
|
75
|
+
/**
|
|
76
|
+
* Single project response schema
|
|
77
|
+
*/
|
|
78
|
+
export const ProjectResponseSchema = t.Object({
|
|
79
|
+
success: t.Literal(true),
|
|
80
|
+
data: ProjectSchema,
|
|
81
|
+
});
|
|
82
|
+
/**
|
|
83
|
+
* Multiple projects response schema
|
|
84
|
+
*/
|
|
85
|
+
export const ProjectsResponseSchema = t.Object({
|
|
86
|
+
projects: t.Array(ProjectSchema),
|
|
87
|
+
});
|
|
88
|
+
/**
|
|
89
|
+
* Project error response schema
|
|
90
|
+
* Discriminated union by error code
|
|
91
|
+
*/
|
|
92
|
+
export const ProjectErrorSchema = t.Union([
|
|
93
|
+
t.Object({
|
|
94
|
+
code: t.Literal("PROJECT_NOT_FOUND"),
|
|
95
|
+
message: t.String(),
|
|
96
|
+
}),
|
|
97
|
+
t.Object({
|
|
98
|
+
code: t.Literal("PROJECT_NOT_IN_ORG"),
|
|
99
|
+
message: t.String(),
|
|
100
|
+
}),
|
|
101
|
+
t.Object({
|
|
102
|
+
code: t.Literal("INVALID_SLUG"),
|
|
103
|
+
message: t.String(),
|
|
104
|
+
}),
|
|
105
|
+
t.Object({
|
|
106
|
+
code: t.Literal("SLUG_ALREADY_EXISTS"),
|
|
107
|
+
message: t.String(),
|
|
108
|
+
}),
|
|
109
|
+
t.Object({
|
|
110
|
+
code: t.Literal("FORBIDDEN"),
|
|
111
|
+
message: t.String(),
|
|
112
|
+
}),
|
|
113
|
+
t.Object({
|
|
114
|
+
code: t.Literal("CREATE_FAILED"),
|
|
115
|
+
message: t.String(),
|
|
116
|
+
}),
|
|
117
|
+
t.Object({
|
|
118
|
+
code: t.Literal("UPDATE_FAILED"),
|
|
119
|
+
message: t.String(),
|
|
120
|
+
}),
|
|
121
|
+
t.Object({
|
|
122
|
+
code: t.Literal("DELETE_FAILED"),
|
|
123
|
+
message: t.String(),
|
|
124
|
+
}),
|
|
125
|
+
t.Object({
|
|
126
|
+
code: t.Literal("FETCH_FAILED"),
|
|
127
|
+
message: t.String(),
|
|
128
|
+
}),
|
|
129
|
+
t.Object({
|
|
130
|
+
code: t.Literal("ARCHIVE_FAILED"),
|
|
131
|
+
message: t.String(),
|
|
132
|
+
}),
|
|
133
|
+
t.Object({
|
|
134
|
+
code: t.Literal("INVALID_REQUEST"),
|
|
135
|
+
message: t.String(),
|
|
136
|
+
}),
|
|
137
|
+
]);
|
|
138
|
+
/**
|
|
139
|
+
* Project error response wrapper
|
|
140
|
+
*/
|
|
141
|
+
export const ProjectErrorResponseSchema = t.Object({
|
|
142
|
+
success: t.Literal(false),
|
|
143
|
+
error: ProjectErrorSchema,
|
|
144
|
+
});
|
|
145
|
+
export const ProjectRequestResponseSchema = t.Union([ProjectResponseSchema, ProjectErrorResponseSchema]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./schemas";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./schemas";
|