@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,4 +1,4 @@
|
|
|
1
|
-
import { type Static } from "
|
|
1
|
+
import { type Static } from "@sinclair/typebox";
|
|
2
2
|
export declare const UUIDSchema: import("@sinclair/typebox").TString;
|
|
3
3
|
export declare const SlugSchema: import("@sinclair/typebox").TString;
|
|
4
4
|
export declare const URLSchema: import("@sinclair/typebox").TString;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Type } from "@sinclair/typebox";
|
|
2
|
-
|
|
3
|
-
export const
|
|
4
|
-
export const
|
|
5
|
-
export const
|
|
6
|
-
export const
|
|
7
|
-
export const EmailSchema = Type.Transform(Type.Optional(Type.Union([Type.String({ format: "email", error: "Invalid email address" }), Type.Literal(""), t.Undefined()])))
|
|
2
|
+
export const UUIDSchema = Type.String({ format: "uuid", error: "Invalid UUID" });
|
|
3
|
+
export const SlugSchema = Type.String({ pattern: "^[a-z0-9]+(?:-[a-z0-9]+)*$", error: "Invalid slug" });
|
|
4
|
+
export const URLSchema = Type.String({ format: "uri", error: "Invalid URL" });
|
|
5
|
+
export const TimestampSchema = Type.String({ format: "date-time", error: "Invalid timestamp" });
|
|
6
|
+
export const EmailSchema = Type.Transform(Type.Optional(Type.Union([Type.String({ format: "email", error: "Invalid email address" }), Type.Literal(""), Type.Undefined()])))
|
|
8
7
|
.Decode((value) => (value === "" ? undefined : value))
|
|
9
8
|
.Encode((value) => value ?? "");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Static, type TSchema } from "
|
|
1
|
+
import { type Static, type TSchema } from "@sinclair/typebox";
|
|
2
2
|
export declare const SuccessResponseSchema: <T extends TSchema>(dataSchema: T) => import("@sinclair/typebox").TObject<{
|
|
3
3
|
success: import("@sinclair/typebox").TLiteral<true>;
|
|
4
4
|
data: T;
|
package/dist/common/responses.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const SuccessResponseSchema = (dataSchema) =>
|
|
3
|
-
success:
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
|
+
export const SuccessResponseSchema = (dataSchema) => Type.Object({
|
|
3
|
+
success: Type.Literal(true),
|
|
4
4
|
data: dataSchema,
|
|
5
5
|
});
|
|
6
|
-
export const ErrorResponseSchema =
|
|
7
|
-
success:
|
|
8
|
-
error:
|
|
9
|
-
message:
|
|
10
|
-
code:
|
|
6
|
+
export const ErrorResponseSchema = Type.Object({
|
|
7
|
+
success: Type.Literal(false),
|
|
8
|
+
error: Type.Object({
|
|
9
|
+
message: Type.String(),
|
|
10
|
+
code: Type.Optional(Type.String()),
|
|
11
11
|
}),
|
|
12
12
|
});
|
|
13
|
-
export const RequestResponseSchema = (successSchema) =>
|
|
13
|
+
export const RequestResponseSchema = (successSchema) => Type.Union([SuccessResponseSchema(successSchema), ErrorResponseSchema]);
|
|
@@ -1,136 +1,136 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
2
|
/**
|
|
3
3
|
* Version adoption schema
|
|
4
4
|
*/
|
|
5
|
-
export const VersionAdoptionPointSchema =
|
|
6
|
-
date:
|
|
7
|
-
versions:
|
|
5
|
+
export const VersionAdoptionPointSchema = Type.Object({
|
|
6
|
+
date: Type.String(), // YYYY-MM-DD
|
|
7
|
+
versions: Type.Record(Type.String(), Type.Number()), // version -> count
|
|
8
8
|
});
|
|
9
|
-
export const VersionAdoptionResponseSchema =
|
|
10
|
-
success:
|
|
11
|
-
data:
|
|
9
|
+
export const VersionAdoptionResponseSchema = Type.Object({
|
|
10
|
+
success: Type.Literal(true),
|
|
11
|
+
data: Type.Array(VersionAdoptionPointSchema),
|
|
12
12
|
});
|
|
13
13
|
/**
|
|
14
14
|
* Active sessions trend schema
|
|
15
15
|
*/
|
|
16
|
-
export const ActiveSessionsPointSchema =
|
|
17
|
-
date:
|
|
18
|
-
count:
|
|
16
|
+
export const ActiveSessionsPointSchema = Type.Object({
|
|
17
|
+
date: Type.String(), // YYYY-MM-DD
|
|
18
|
+
count: Type.Integer({ minimum: 0 }),
|
|
19
19
|
});
|
|
20
|
-
export const ActiveSessionsTrendResponseSchema =
|
|
21
|
-
success:
|
|
22
|
-
data:
|
|
20
|
+
export const ActiveSessionsTrendResponseSchema = Type.Object({
|
|
21
|
+
success: Type.Literal(true),
|
|
22
|
+
data: Type.Array(ActiveSessionsPointSchema),
|
|
23
23
|
});
|
|
24
24
|
/**
|
|
25
25
|
* Active users schema (with platform breakdown)
|
|
26
26
|
*/
|
|
27
|
-
export const ActiveUsersSchema =
|
|
28
|
-
total:
|
|
29
|
-
ios:
|
|
30
|
-
android:
|
|
31
|
-
trend:
|
|
32
|
-
});
|
|
33
|
-
export const ActiveUsersResponseSchema =
|
|
34
|
-
success:
|
|
27
|
+
export const ActiveUsersSchema = Type.Object({
|
|
28
|
+
total: Type.Integer({ minimum: 0 }),
|
|
29
|
+
ios: Type.Integer({ minimum: 0 }),
|
|
30
|
+
android: Type.Integer({ minimum: 0 }),
|
|
31
|
+
trend: Type.Number(), // percentage change vs previous period
|
|
32
|
+
});
|
|
33
|
+
export const ActiveUsersResponseSchema = Type.Object({
|
|
34
|
+
success: Type.Literal(true),
|
|
35
35
|
data: ActiveUsersSchema,
|
|
36
36
|
});
|
|
37
37
|
/**
|
|
38
38
|
* Active users query params schema
|
|
39
39
|
*/
|
|
40
|
-
export const ActiveUsersQuerySchema =
|
|
41
|
-
start_date:
|
|
42
|
-
end_date:
|
|
40
|
+
export const ActiveUsersQuerySchema = Type.Object({
|
|
41
|
+
start_date: Type.String({ format: "date-time" }),
|
|
42
|
+
end_date: Type.String({ format: "date-time" }),
|
|
43
43
|
});
|
|
44
44
|
/**
|
|
45
45
|
* Build adoption schema (with platform breakdown)
|
|
46
46
|
*/
|
|
47
|
-
export const BuildStatsSchema =
|
|
48
|
-
total:
|
|
49
|
-
ios:
|
|
50
|
-
android:
|
|
47
|
+
export const BuildStatsSchema = Type.Object({
|
|
48
|
+
total: Type.Integer({ minimum: 0 }),
|
|
49
|
+
ios: Type.Integer({ minimum: 0 }),
|
|
50
|
+
android: Type.Integer({ minimum: 0 }),
|
|
51
51
|
});
|
|
52
|
-
export const BuildAdoptionPointSchema =
|
|
53
|
-
date:
|
|
54
|
-
builds:
|
|
52
|
+
export const BuildAdoptionPointSchema = Type.Object({
|
|
53
|
+
date: Type.String(), // YYYY-MM-DD
|
|
54
|
+
builds: Type.Record(Type.String(), BuildStatsSchema), // build_number -> stats
|
|
55
55
|
});
|
|
56
|
-
export const BuildAdoptionResponseSchema =
|
|
57
|
-
success:
|
|
58
|
-
data:
|
|
56
|
+
export const BuildAdoptionResponseSchema = Type.Object({
|
|
57
|
+
success: Type.Literal(true),
|
|
58
|
+
data: Type.Array(BuildAdoptionPointSchema),
|
|
59
59
|
});
|
|
60
60
|
/**
|
|
61
61
|
* Date range query params schema (shared)
|
|
62
62
|
*/
|
|
63
|
-
export const DateRangeQuerySchema =
|
|
64
|
-
start_date:
|
|
65
|
-
end_date:
|
|
63
|
+
export const DateRangeQuerySchema = Type.Object({
|
|
64
|
+
start_date: Type.String({ format: "date-time" }),
|
|
65
|
+
end_date: Type.String({ format: "date-time" }),
|
|
66
66
|
});
|
|
67
67
|
/**
|
|
68
68
|
* Active versions/builds query params schema (with optional search)
|
|
69
69
|
*/
|
|
70
|
-
export const ActiveVersionsQuerySchema =
|
|
71
|
-
start_date:
|
|
72
|
-
end_date:
|
|
73
|
-
search:
|
|
70
|
+
export const ActiveVersionsQuerySchema = Type.Object({
|
|
71
|
+
start_date: Type.String({ format: "date-time" }),
|
|
72
|
+
end_date: Type.String({ format: "date-time" }),
|
|
73
|
+
search: Type.Optional(Type.String()),
|
|
74
74
|
});
|
|
75
75
|
/**
|
|
76
76
|
* Active versions & builds analytics schema
|
|
77
77
|
* Aggregated session counts by version and build for a date range
|
|
78
78
|
*/
|
|
79
|
-
export const ActiveBuildStatsSchema =
|
|
80
|
-
build_id:
|
|
81
|
-
build_number:
|
|
82
|
-
platform:
|
|
83
|
-
session_count:
|
|
84
|
-
device_count:
|
|
85
|
-
});
|
|
86
|
-
export const ActiveVersionStatsSchema =
|
|
87
|
-
version_id:
|
|
88
|
-
version_name:
|
|
89
|
-
session_count:
|
|
90
|
-
device_count:
|
|
91
|
-
ios_count:
|
|
92
|
-
android_count:
|
|
93
|
-
builds:
|
|
94
|
-
});
|
|
95
|
-
export const ActiveVersionsBuildsSchema =
|
|
96
|
-
versions:
|
|
97
|
-
});
|
|
98
|
-
export const ActiveVersionsBuildsResponseSchema =
|
|
99
|
-
success:
|
|
79
|
+
export const ActiveBuildStatsSchema = Type.Object({
|
|
80
|
+
build_id: Type.String(),
|
|
81
|
+
build_number: Type.Integer({ minimum: 0 }),
|
|
82
|
+
platform: Type.Union([Type.Literal("IOS"), Type.Literal("ANDROID")]),
|
|
83
|
+
session_count: Type.Integer({ minimum: 0 }),
|
|
84
|
+
device_count: Type.Integer({ minimum: 0 }),
|
|
85
|
+
});
|
|
86
|
+
export const ActiveVersionStatsSchema = Type.Object({
|
|
87
|
+
version_id: Type.String(),
|
|
88
|
+
version_name: Type.String(),
|
|
89
|
+
session_count: Type.Integer({ minimum: 0 }),
|
|
90
|
+
device_count: Type.Integer({ minimum: 0 }),
|
|
91
|
+
ios_count: Type.Integer({ minimum: 0 }),
|
|
92
|
+
android_count: Type.Integer({ minimum: 0 }),
|
|
93
|
+
builds: Type.Array(ActiveBuildStatsSchema),
|
|
94
|
+
});
|
|
95
|
+
export const ActiveVersionsBuildsSchema = Type.Object({
|
|
96
|
+
versions: Type.Array(ActiveVersionStatsSchema),
|
|
97
|
+
});
|
|
98
|
+
export const ActiveVersionsBuildsResponseSchema = Type.Object({
|
|
99
|
+
success: Type.Literal(true),
|
|
100
100
|
data: ActiveVersionsBuildsSchema,
|
|
101
101
|
});
|
|
102
102
|
/**
|
|
103
103
|
* Session with user/device data for build sessions endpoint
|
|
104
104
|
*/
|
|
105
|
-
export const SessionDeviceSchema =
|
|
106
|
-
id:
|
|
107
|
-
device_name:
|
|
108
|
-
device_brand:
|
|
109
|
-
});
|
|
110
|
-
export const SessionUserSchema =
|
|
111
|
-
id:
|
|
112
|
-
user_id:
|
|
113
|
-
email:
|
|
114
|
-
name:
|
|
115
|
-
});
|
|
116
|
-
export const SessionWithUserSchema =
|
|
117
|
-
id:
|
|
118
|
-
started_at:
|
|
119
|
-
os_version:
|
|
105
|
+
export const SessionDeviceSchema = Type.Object({
|
|
106
|
+
id: Type.String(),
|
|
107
|
+
device_name: Type.Union([Type.String(), Type.Null()]),
|
|
108
|
+
device_brand: Type.Union([Type.String(), Type.Null()]),
|
|
109
|
+
});
|
|
110
|
+
export const SessionUserSchema = Type.Object({
|
|
111
|
+
id: Type.String(),
|
|
112
|
+
user_id: Type.Union([Type.String(), Type.Null()]),
|
|
113
|
+
email: Type.Union([Type.String(), Type.Null()]),
|
|
114
|
+
name: Type.Union([Type.String(), Type.Null()]),
|
|
115
|
+
});
|
|
116
|
+
export const SessionWithUserSchema = Type.Object({
|
|
117
|
+
id: Type.String(),
|
|
118
|
+
started_at: Type.String(),
|
|
119
|
+
os_version: Type.Union([Type.String(), Type.Null()]),
|
|
120
120
|
device: SessionDeviceSchema,
|
|
121
|
-
user:
|
|
122
|
-
});
|
|
123
|
-
export const BuildSessionsQuerySchema =
|
|
124
|
-
start_date:
|
|
125
|
-
end_date:
|
|
126
|
-
cursor:
|
|
127
|
-
limit:
|
|
128
|
-
search:
|
|
129
|
-
});
|
|
130
|
-
export const BuildSessionsResponseSchema =
|
|
131
|
-
success:
|
|
132
|
-
data:
|
|
133
|
-
sessions:
|
|
134
|
-
next_cursor:
|
|
121
|
+
user: Type.Union([SessionUserSchema, Type.Null()]),
|
|
122
|
+
});
|
|
123
|
+
export const BuildSessionsQuerySchema = Type.Object({
|
|
124
|
+
start_date: Type.String({ format: "date-time" }),
|
|
125
|
+
end_date: Type.String({ format: "date-time" }),
|
|
126
|
+
cursor: Type.Optional(Type.String()),
|
|
127
|
+
limit: Type.Optional(Type.String({ default: "20" })),
|
|
128
|
+
search: Type.Optional(Type.String()),
|
|
129
|
+
});
|
|
130
|
+
export const BuildSessionsResponseSchema = Type.Object({
|
|
131
|
+
success: Type.Literal(true),
|
|
132
|
+
data: Type.Object({
|
|
133
|
+
sessions: Type.Array(SessionWithUserSchema),
|
|
134
|
+
next_cursor: Type.Union([Type.String(), Type.Null()]),
|
|
135
135
|
}),
|
|
136
136
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VersionBuildStatusEnum } from "@teardown/types";
|
|
2
|
-
import { type Static } from "
|
|
2
|
+
import { type Static } from "@sinclair/typebox";
|
|
3
3
|
import type { AssertSchemaCompatibleWithRow, AssertTrue } from "../../common";
|
|
4
4
|
/**
|
|
5
5
|
* Build status enum matching database (reuses VersionBuildStatusEnum)
|
|
@@ -1,137 +1,137 @@
|
|
|
1
1
|
import { VersionBuildStatusEnum } from "@teardown/types";
|
|
2
|
-
import {
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
3
|
import { DevicePlatformSchema } from "../devices/schemas";
|
|
4
4
|
/**
|
|
5
5
|
* Build status enum matching database (reuses VersionBuildStatusEnum)
|
|
6
6
|
*/
|
|
7
|
-
export const BuildStatusSchema =
|
|
7
|
+
export const BuildStatusSchema = Type.Enum(VersionBuildStatusEnum);
|
|
8
8
|
/**
|
|
9
9
|
* Base build schema
|
|
10
10
|
* Represents version_builds table structure
|
|
11
11
|
*/
|
|
12
|
-
export const BuildSchema =
|
|
13
|
-
id:
|
|
14
|
-
version_id:
|
|
15
|
-
build_number:
|
|
16
|
-
name:
|
|
17
|
-
summary:
|
|
18
|
-
commit_sha:
|
|
12
|
+
export const BuildSchema = Type.Object({
|
|
13
|
+
id: Type.String({ format: "uuid" }),
|
|
14
|
+
version_id: Type.String({ format: "uuid" }),
|
|
15
|
+
build_number: Type.Integer({ minimum: 0 }),
|
|
16
|
+
name: Type.Union([Type.String(), Type.Null()]),
|
|
17
|
+
summary: Type.Union([Type.String(), Type.Null()]),
|
|
18
|
+
commit_sha: Type.Union([Type.String(), Type.Null()]),
|
|
19
19
|
platform: DevicePlatformSchema,
|
|
20
20
|
status: BuildStatusSchema,
|
|
21
|
-
fingerprint:
|
|
22
|
-
created_at:
|
|
23
|
-
updated_at:
|
|
21
|
+
fingerprint: Type.Union([Type.String(), Type.Null()]),
|
|
22
|
+
created_at: Type.String(),
|
|
23
|
+
updated_at: Type.String(),
|
|
24
24
|
});
|
|
25
25
|
/**
|
|
26
26
|
* Build params schema
|
|
27
27
|
*/
|
|
28
|
-
export const BuildParamsSchema =
|
|
29
|
-
build_id:
|
|
28
|
+
export const BuildParamsSchema = Type.Object({
|
|
29
|
+
build_id: Type.String({ format: "uuid" }),
|
|
30
30
|
});
|
|
31
31
|
/**
|
|
32
32
|
* Search builds query schema
|
|
33
33
|
* Supports pagination, search, and sorting
|
|
34
34
|
*/
|
|
35
|
-
export const SearchBuildsQuerySchema =
|
|
36
|
-
project_id:
|
|
37
|
-
page:
|
|
38
|
-
limit:
|
|
39
|
-
search:
|
|
40
|
-
sort_by:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
export const SearchBuildsQuerySchema = Type.Object({
|
|
36
|
+
project_id: Type.String({ format: "uuid" }),
|
|
37
|
+
page: Type.Number({ minimum: 1, default: 1 }),
|
|
38
|
+
limit: Type.Number({ minimum: 1, maximum: 100, default: 20 }),
|
|
39
|
+
search: Type.Optional(Type.String()),
|
|
40
|
+
sort_by: Type.Union([
|
|
41
|
+
Type.Literal("created_at"),
|
|
42
|
+
Type.Literal("updated_at"),
|
|
43
|
+
Type.Literal("build_number"),
|
|
44
|
+
Type.Literal("platform"),
|
|
45
|
+
Type.Literal("name"),
|
|
46
46
|
], { default: "created_at" }),
|
|
47
|
-
sort_order:
|
|
47
|
+
sort_order: Type.Union([Type.Literal("asc"), Type.Literal("desc")], { default: "desc" }),
|
|
48
48
|
});
|
|
49
49
|
/**
|
|
50
50
|
* Search builds query schema without project_id (injected from headers)
|
|
51
51
|
*/
|
|
52
|
-
export const SearchBuildsQueryParamsSchema =
|
|
52
|
+
export const SearchBuildsQueryParamsSchema = Type.Omit(SearchBuildsQuerySchema, ["project_id"]);
|
|
53
53
|
/**
|
|
54
54
|
* Builds by IDs request schema
|
|
55
55
|
*/
|
|
56
|
-
export const BuildsByIdsSchema =
|
|
57
|
-
build_ids:
|
|
56
|
+
export const BuildsByIdsSchema = Type.Object({
|
|
57
|
+
build_ids: Type.Array(Type.String({ format: "uuid" }), { minItems: 1, maxItems: 100 }),
|
|
58
58
|
});
|
|
59
59
|
/**
|
|
60
60
|
* Paginated builds response schema
|
|
61
61
|
*/
|
|
62
|
-
export const BuildsResponseSchema =
|
|
63
|
-
builds:
|
|
64
|
-
pagination:
|
|
65
|
-
page:
|
|
66
|
-
limit:
|
|
67
|
-
total:
|
|
68
|
-
total_pages:
|
|
62
|
+
export const BuildsResponseSchema = Type.Object({
|
|
63
|
+
builds: Type.Array(BuildSchema),
|
|
64
|
+
pagination: Type.Object({
|
|
65
|
+
page: Type.Integer({ minimum: 1 }),
|
|
66
|
+
limit: Type.Integer({ minimum: 1 }),
|
|
67
|
+
total: Type.Integer({ minimum: 0 }),
|
|
68
|
+
total_pages: Type.Integer({ minimum: 0 }),
|
|
69
69
|
}),
|
|
70
70
|
});
|
|
71
71
|
/**
|
|
72
72
|
* Single build response schema
|
|
73
73
|
*/
|
|
74
|
-
export const BuildResponseSchema =
|
|
75
|
-
success:
|
|
74
|
+
export const BuildResponseSchema = Type.Object({
|
|
75
|
+
success: Type.Literal(true),
|
|
76
76
|
data: BuildSchema,
|
|
77
77
|
});
|
|
78
78
|
/**
|
|
79
79
|
* Build error response schema
|
|
80
80
|
* Discriminated union by error code
|
|
81
81
|
*/
|
|
82
|
-
export const BuildErrorSchema =
|
|
83
|
-
|
|
84
|
-
code:
|
|
85
|
-
message:
|
|
82
|
+
export const BuildErrorSchema = Type.Union([
|
|
83
|
+
Type.Object({
|
|
84
|
+
code: Type.Literal("BUILD_NOT_FOUND"),
|
|
85
|
+
message: Type.String(),
|
|
86
86
|
}),
|
|
87
|
-
|
|
88
|
-
code:
|
|
89
|
-
message:
|
|
87
|
+
Type.Object({
|
|
88
|
+
code: Type.Literal("PROJECT_NOT_FOUND"),
|
|
89
|
+
message: Type.String(),
|
|
90
90
|
}),
|
|
91
|
-
|
|
92
|
-
code:
|
|
93
|
-
message:
|
|
91
|
+
Type.Object({
|
|
92
|
+
code: Type.Literal("FORBIDDEN"),
|
|
93
|
+
message: Type.String(),
|
|
94
94
|
}),
|
|
95
|
-
|
|
96
|
-
code:
|
|
97
|
-
message:
|
|
95
|
+
Type.Object({
|
|
96
|
+
code: Type.Literal("FETCH_FAILED"),
|
|
97
|
+
message: Type.String(),
|
|
98
98
|
}),
|
|
99
|
-
|
|
100
|
-
code:
|
|
101
|
-
message:
|
|
99
|
+
Type.Object({
|
|
100
|
+
code: Type.Literal("INVALID_PARAMS"),
|
|
101
|
+
message: Type.String(),
|
|
102
102
|
}),
|
|
103
103
|
]);
|
|
104
104
|
/**
|
|
105
105
|
* Build error response wrapper
|
|
106
106
|
*/
|
|
107
|
-
export const BuildErrorResponseSchema =
|
|
108
|
-
success:
|
|
107
|
+
export const BuildErrorResponseSchema = Type.Object({
|
|
108
|
+
success: Type.Literal(false),
|
|
109
109
|
error: BuildErrorSchema,
|
|
110
110
|
});
|
|
111
111
|
/**
|
|
112
112
|
* Build request response schema
|
|
113
113
|
*/
|
|
114
|
-
export const BuildRequestResponseSchema =
|
|
114
|
+
export const BuildRequestResponseSchema = Type.Union([BuildResponseSchema, BuildErrorResponseSchema]);
|
|
115
115
|
/**
|
|
116
116
|
* Update build status request body schema
|
|
117
117
|
*/
|
|
118
|
-
export const UpdateBuildStatusBodySchema =
|
|
118
|
+
export const UpdateBuildStatusBodySchema = Type.Object({
|
|
119
119
|
status: BuildStatusSchema,
|
|
120
120
|
});
|
|
121
121
|
/**
|
|
122
122
|
* Add UPDATE_FAILED error code for update operations
|
|
123
123
|
*/
|
|
124
|
-
export const BuildErrorSchemaWithUpdate =
|
|
124
|
+
export const BuildErrorSchemaWithUpdate = Type.Union([
|
|
125
125
|
BuildErrorSchema,
|
|
126
|
-
|
|
127
|
-
code:
|
|
128
|
-
message:
|
|
126
|
+
Type.Object({
|
|
127
|
+
code: Type.Literal("UPDATE_FAILED"),
|
|
128
|
+
message: Type.String(),
|
|
129
129
|
}),
|
|
130
130
|
]);
|
|
131
131
|
/**
|
|
132
132
|
* Build error response wrapper with update error
|
|
133
133
|
*/
|
|
134
|
-
export const BuildErrorResponseWithUpdateSchema =
|
|
135
|
-
success:
|
|
134
|
+
export const BuildErrorResponseWithUpdateSchema = Type.Object({
|
|
135
|
+
success: Type.Literal(false),
|
|
136
136
|
error: BuildErrorSchemaWithUpdate,
|
|
137
137
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { type Static } from "@sinclair/typebox";
|
|
1
2
|
import { DevicePlatformEnum } from "@teardown/types";
|
|
2
|
-
import { type Static } from "elysia";
|
|
3
3
|
import type { AssertSchemaCompatibleWithRow, AssertTrue } from "../../common";
|
|
4
4
|
/**
|
|
5
5
|
* Device platform enum matching database
|