@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.
@@ -1,4 +1,4 @@
1
- import { type Static } from "elysia";
1
+ import { type Static } from "@sinclair/typebox";
2
2
  import type { AssertSchemaCompatibleWithRow, AssertTrue } from "../../common";
3
3
  /**
4
4
  * Base session schema
@@ -32,19 +32,19 @@ export declare const SessionWithDeviceSchema: import("@sinclair/typebox").TObjec
32
32
  id: import("@sinclair/typebox").TString;
33
33
  created_at: import("@sinclair/typebox").TString;
34
34
  updated_at: import("@sinclair/typebox").TString;
35
- device_id: import("@sinclair/typebox").TString;
36
- ota_update_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
37
- version_build_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
38
35
  version_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
39
36
  started_at: import("@sinclair/typebox").TString;
40
37
  os_version: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
38
+ device_id: import("@sinclair/typebox").TString;
41
39
  metadata: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>, import("@sinclair/typebox").TNull]>;
42
40
  version: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
43
41
  is_emergency_launch: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull]>;
44
42
  is_embedded_launch: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull]>;
45
43
  token: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
44
+ version_build_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
46
45
  ota_updates_enabled: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull]>;
47
46
  emergency_launch_reason: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
47
+ ota_update_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
48
48
  ota_update_runtime_version: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
49
49
  ota_update_created_at: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
50
50
  device: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
@@ -100,19 +100,19 @@ export declare const SessionsResponseSchema: import("@sinclair/typebox").TObject
100
100
  id: import("@sinclair/typebox").TString;
101
101
  created_at: import("@sinclair/typebox").TString;
102
102
  updated_at: import("@sinclair/typebox").TString;
103
- device_id: import("@sinclair/typebox").TString;
104
- ota_update_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
105
- version_build_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
106
103
  version_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
107
104
  started_at: import("@sinclair/typebox").TString;
108
105
  os_version: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
106
+ device_id: import("@sinclair/typebox").TString;
109
107
  metadata: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>, import("@sinclair/typebox").TNull]>;
110
108
  version: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
111
109
  is_emergency_launch: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull]>;
112
110
  is_embedded_launch: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull]>;
113
111
  token: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
112
+ version_build_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
114
113
  ota_updates_enabled: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull]>;
115
114
  emergency_launch_reason: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
115
+ ota_update_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
116
116
  ota_update_runtime_version: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
117
117
  ota_update_created_at: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
118
118
  device: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
@@ -138,19 +138,19 @@ export declare const SessionResponseSchema: import("@sinclair/typebox").TObject<
138
138
  id: import("@sinclair/typebox").TString;
139
139
  created_at: import("@sinclair/typebox").TString;
140
140
  updated_at: import("@sinclair/typebox").TString;
141
- device_id: import("@sinclair/typebox").TString;
142
- ota_update_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
143
- version_build_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
144
141
  version_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
145
142
  started_at: import("@sinclair/typebox").TString;
146
143
  os_version: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
144
+ device_id: import("@sinclair/typebox").TString;
147
145
  metadata: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>, import("@sinclair/typebox").TNull]>;
148
146
  version: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
149
147
  is_emergency_launch: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull]>;
150
148
  is_embedded_launch: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull]>;
151
149
  token: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
150
+ version_build_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
152
151
  ota_updates_enabled: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull]>;
153
152
  emergency_launch_reason: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
153
+ ota_update_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
154
154
  ota_update_runtime_version: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
155
155
  ota_update_created_at: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
156
156
  device: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
@@ -214,19 +214,19 @@ export declare const SessionRequestResponseSchema: import("@sinclair/typebox").T
214
214
  id: import("@sinclair/typebox").TString;
215
215
  created_at: import("@sinclair/typebox").TString;
216
216
  updated_at: import("@sinclair/typebox").TString;
217
- device_id: import("@sinclair/typebox").TString;
218
- ota_update_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
219
- version_build_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
220
217
  version_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
221
218
  started_at: import("@sinclair/typebox").TString;
222
219
  os_version: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
220
+ device_id: import("@sinclair/typebox").TString;
223
221
  metadata: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>, import("@sinclair/typebox").TNull]>;
224
222
  version: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
225
223
  is_emergency_launch: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull]>;
226
224
  is_embedded_launch: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull]>;
227
225
  token: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
226
+ version_build_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
228
227
  ota_updates_enabled: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull]>;
229
228
  emergency_launch_reason: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
229
+ ota_update_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
230
230
  ota_update_runtime_version: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
231
231
  ota_update_created_at: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
232
232
  device: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
@@ -1,128 +1,128 @@
1
- import { t } from "elysia";
1
+ import { Type } from "@sinclair/typebox";
2
2
  /**
3
3
  * Base session schema
4
4
  * Represents device_sessions table structure
5
5
  */
6
- export const SessionSchema = t.Object({
7
- id: t.String({ format: "uuid" }),
8
- device_id: t.String({ format: "uuid" }),
9
- token: t.Union([t.String(), t.Null()]),
10
- version: t.Union([t.String(), t.Null()]),
11
- version_id: t.Union([t.String({ format: "uuid" }), t.Null()]),
12
- version_build_id: t.Union([t.String({ format: "uuid" }), t.Null()]),
13
- os_version: t.Union([t.String(), t.Null()]),
14
- ota_updates_enabled: t.Union([t.Boolean(), t.Null()]),
15
- is_emergency_launch: t.Union([t.Boolean(), t.Null()]),
16
- emergency_launch_reason: t.Union([t.String(), t.Null()]),
17
- is_embedded_launch: t.Union([t.Boolean(), t.Null()]),
18
- ota_update_id: t.Union([t.String({ format: "uuid" }), t.Null()]),
19
- ota_update_runtime_version: t.Union([t.String(), t.Null()]),
20
- ota_update_created_at: t.Union([t.String(), t.Null()]),
21
- metadata: t.Union([t.Record(t.String(), t.Unknown()), t.Null()]),
22
- started_at: t.String(),
23
- created_at: t.String(),
24
- updated_at: t.String(),
6
+ export const SessionSchema = Type.Object({
7
+ id: Type.String({ format: "uuid" }),
8
+ device_id: Type.String({ format: "uuid" }),
9
+ token: Type.Union([Type.String(), Type.Null()]),
10
+ version: Type.Union([Type.String(), Type.Null()]),
11
+ version_id: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
12
+ version_build_id: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
13
+ os_version: Type.Union([Type.String(), Type.Null()]),
14
+ ota_updates_enabled: Type.Union([Type.Boolean(), Type.Null()]),
15
+ is_emergency_launch: Type.Union([Type.Boolean(), Type.Null()]),
16
+ emergency_launch_reason: Type.Union([Type.String(), Type.Null()]),
17
+ is_embedded_launch: Type.Union([Type.Boolean(), Type.Null()]),
18
+ ota_update_id: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
19
+ ota_update_runtime_version: Type.Union([Type.String(), Type.Null()]),
20
+ ota_update_created_at: Type.Union([Type.String(), Type.Null()]),
21
+ metadata: Type.Union([Type.Record(Type.String(), Type.Unknown()), Type.Null()]),
22
+ started_at: Type.String(),
23
+ created_at: Type.String(),
24
+ updated_at: Type.String(),
25
25
  });
26
26
  /**
27
27
  * Session with device info for joined queries
28
28
  */
29
- export const SessionWithDeviceSchema = t.Composite([
29
+ export const SessionWithDeviceSchema = Type.Composite([
30
30
  SessionSchema,
31
- t.Object({
32
- device: t.Optional(t.Object({
33
- device_id: t.String(),
34
- device_name: t.Union([t.String(), t.Null()]),
35
- platform: t.Union([t.String(), t.Null()]),
31
+ Type.Object({
32
+ device: Type.Optional(Type.Object({
33
+ device_id: Type.String(),
34
+ device_name: Type.Union([Type.String(), Type.Null()]),
35
+ platform: Type.Union([Type.String(), Type.Null()]),
36
36
  })),
37
37
  }),
38
38
  ]);
39
39
  /**
40
40
  * Session params schema
41
41
  */
42
- export const SessionParamsSchema = t.Object({
43
- session_id: t.String({ format: "uuid" }),
42
+ export const SessionParamsSchema = Type.Object({
43
+ session_id: Type.String({ format: "uuid" }),
44
44
  });
45
45
  /**
46
46
  * Search sessions query schema
47
47
  * Supports pagination, search, and sorting
48
48
  */
49
- export const SearchSessionsQuerySchema = t.Object({
50
- project_id: t.String({ format: "uuid" }),
51
- page: t.Numeric({ minimum: 1, default: 1 }),
52
- limit: t.Numeric({ minimum: 1, maximum: 100, default: 20 }),
53
- search: t.Optional(t.String()),
54
- sort_by: t.Union([
55
- t.Literal("started_at"),
56
- t.Literal("created_at"),
57
- t.Literal("updated_at"),
58
- t.Literal("version"),
59
- t.Literal("os_version"),
49
+ export const SearchSessionsQuerySchema = Type.Object({
50
+ project_id: Type.String({ format: "uuid" }),
51
+ page: Type.Number({ minimum: 1, default: 1 }),
52
+ limit: Type.Number({ minimum: 1, maximum: 100, default: 20 }),
53
+ search: Type.Optional(Type.String()),
54
+ sort_by: Type.Union([
55
+ Type.Literal("started_at"),
56
+ Type.Literal("created_at"),
57
+ Type.Literal("updated_at"),
58
+ Type.Literal("version"),
59
+ Type.Literal("os_version"),
60
60
  ], { default: "started_at" }),
61
- sort_order: t.Union([t.Literal("asc"), t.Literal("desc")], { default: "desc" }),
61
+ sort_order: Type.Union([Type.Literal("asc"), Type.Literal("desc")], { default: "desc" }),
62
62
  });
63
63
  /**
64
64
  * Search sessions query schema without project_id (injected from headers)
65
65
  */
66
- export const SearchSessionsQueryParamsSchema = t.Omit(SearchSessionsQuerySchema, ["project_id"]);
66
+ export const SearchSessionsQueryParamsSchema = Type.Omit(SearchSessionsQuerySchema, ["project_id"]);
67
67
  /**
68
68
  * Sessions by IDs request schema
69
69
  */
70
- export const SessionsByIdsSchema = t.Object({
71
- session_ids: t.Array(t.String({ format: "uuid" }), { minItems: 1, maxItems: 100 }),
70
+ export const SessionsByIdsSchema = Type.Object({
71
+ session_ids: Type.Array(Type.String({ format: "uuid" }), { minItems: 1, maxItems: 100 }),
72
72
  });
73
73
  /**
74
74
  * Paginated sessions response schema
75
75
  */
76
- export const SessionsResponseSchema = t.Object({
77
- sessions: t.Array(SessionWithDeviceSchema),
78
- pagination: t.Object({
79
- page: t.Integer({ minimum: 1 }),
80
- limit: t.Integer({ minimum: 1 }),
81
- total: t.Integer({ minimum: 0 }),
82
- total_pages: t.Integer({ minimum: 0 }),
76
+ export const SessionsResponseSchema = Type.Object({
77
+ sessions: Type.Array(SessionWithDeviceSchema),
78
+ pagination: Type.Object({
79
+ page: Type.Integer({ minimum: 1 }),
80
+ limit: Type.Integer({ minimum: 1 }),
81
+ total: Type.Integer({ minimum: 0 }),
82
+ total_pages: Type.Integer({ minimum: 0 }),
83
83
  }),
84
84
  });
85
85
  /**
86
86
  * Single session response schema
87
87
  */
88
- export const SessionResponseSchema = t.Object({
89
- success: t.Literal(true),
88
+ export const SessionResponseSchema = Type.Object({
89
+ success: Type.Literal(true),
90
90
  data: SessionWithDeviceSchema,
91
91
  });
92
92
  /**
93
93
  * Session error response schema
94
94
  * Discriminated union by error code
95
95
  */
96
- export const SessionErrorSchema = t.Union([
97
- t.Object({
98
- code: t.Literal("SESSION_NOT_FOUND"),
99
- message: t.String(),
96
+ export const SessionErrorSchema = Type.Union([
97
+ Type.Object({
98
+ code: Type.Literal("SESSION_NOT_FOUND"),
99
+ message: Type.String(),
100
100
  }),
101
- t.Object({
102
- code: t.Literal("PROJECT_NOT_FOUND"),
103
- message: t.String(),
101
+ Type.Object({
102
+ code: Type.Literal("PROJECT_NOT_FOUND"),
103
+ message: Type.String(),
104
104
  }),
105
- t.Object({
106
- code: t.Literal("FORBIDDEN"),
107
- message: t.String(),
105
+ Type.Object({
106
+ code: Type.Literal("FORBIDDEN"),
107
+ message: Type.String(),
108
108
  }),
109
- t.Object({
110
- code: t.Literal("FETCH_FAILED"),
111
- message: t.String(),
109
+ Type.Object({
110
+ code: Type.Literal("FETCH_FAILED"),
111
+ message: Type.String(),
112
112
  }),
113
- t.Object({
114
- code: t.Literal("INVALID_PARAMS"),
115
- message: t.String(),
113
+ Type.Object({
114
+ code: Type.Literal("INVALID_PARAMS"),
115
+ message: Type.String(),
116
116
  }),
117
117
  ]);
118
118
  /**
119
119
  * Session error response wrapper
120
120
  */
121
- export const SessionErrorResponseSchema = t.Object({
122
- success: t.Literal(false),
121
+ export const SessionErrorResponseSchema = Type.Object({
122
+ success: Type.Literal(false),
123
123
  error: SessionErrorSchema,
124
124
  });
125
125
  /**
126
126
  * Session request response schema
127
127
  */
128
- export const SessionRequestResponseSchema = t.Union([SessionResponseSchema, SessionErrorResponseSchema]);
128
+ export const SessionRequestResponseSchema = Type.Union([SessionResponseSchema, SessionErrorResponseSchema]);
@@ -1,5 +1,5 @@
1
+ import { type Static } from "@sinclair/typebox";
1
2
  import { VersionBuildStatusEnum } from "@teardown/types";
2
- import { type Static } from "elysia";
3
3
  import type { AssertSchemaCompatibleWithRow, AssertTrue } from "../../common";
4
4
  /**
5
5
  * Version status enum matching database
@@ -1,9 +1,9 @@
1
+ import { Type } from "@sinclair/typebox";
1
2
  import { VersionBuildStatusEnum } from "@teardown/types";
2
- import { t } from "elysia";
3
3
  /**
4
4
  * Version status enum matching database
5
5
  */
6
- export const VersionBuildStatusSchema = t.Enum(VersionBuildStatusEnum);
6
+ export const VersionBuildStatusSchema = Type.Enum(VersionBuildStatusEnum);
7
7
  /**
8
8
  * Parse and validate a VersionBuildStatusEnum value
9
9
  * Uses a switch statement to ensure type safety and runtime validation
@@ -28,128 +28,128 @@ export function parseVersionStatusEnum(value) {
28
28
  * Base version schema
29
29
  * Represents project_versions table structure
30
30
  */
31
- export const VersionSchema = t.Object({
32
- id: t.String({ format: "uuid" }),
33
- project_id: t.String({ format: "uuid" }),
34
- name: t.String(),
35
- major: t.Number(), // Matches type number, not integer constraint (db type numeric)
36
- minor: t.Number(),
37
- patch: t.Number(),
31
+ export const VersionSchema = Type.Object({
32
+ id: Type.String({ format: "uuid" }),
33
+ project_id: Type.String({ format: "uuid" }),
34
+ name: Type.String(),
35
+ major: Type.Number(), // Matches type number, not integer constraint (db type numeric)
36
+ minor: Type.Number(),
37
+ patch: Type.Number(),
38
38
  status: VersionBuildStatusSchema, // SUPPORTED, UPDATE_AVAILABLE, UPDATE_RECOMMENDED, UPDATE_REQUIRED - controls if version is active
39
- created_at: t.String(),
40
- updated_at: t.String(),
39
+ created_at: Type.String(),
40
+ updated_at: Type.String(),
41
41
  });
42
42
  /**
43
43
  * Version params schema
44
44
  */
45
- export const VersionParamsSchema = t.Object({
46
- version_id: t.String({ format: "uuid" }),
45
+ export const VersionParamsSchema = Type.Object({
46
+ version_id: Type.String({ format: "uuid" }),
47
47
  });
48
48
  /**
49
49
  * Search versions query schema
50
50
  * Supports pagination, search, and sorting
51
51
  */
52
- export const SearchVersionsQuerySchema = t.Object({
53
- project_id: t.String({ format: "uuid" }),
54
- page: t.Numeric({ minimum: 1, default: 1 }),
55
- limit: t.Numeric({ minimum: 1, maximum: 100, default: 20 }),
56
- search: t.Optional(t.String()),
57
- sort_by: t.Union([
58
- t.Literal("created_at"),
59
- t.Literal("updated_at"),
60
- t.Literal("name"),
61
- t.Literal("major"),
62
- t.Literal("minor"),
63
- t.Literal("patch"),
52
+ export const SearchVersionsQuerySchema = Type.Object({
53
+ project_id: Type.String({ format: "uuid" }),
54
+ page: Type.Number({ minimum: 1, default: 1 }),
55
+ limit: Type.Number({ minimum: 1, maximum: 100, default: 20 }),
56
+ search: Type.Optional(Type.String()),
57
+ sort_by: Type.Union([
58
+ Type.Literal("created_at"),
59
+ Type.Literal("updated_at"),
60
+ Type.Literal("name"),
61
+ Type.Literal("major"),
62
+ Type.Literal("minor"),
63
+ Type.Literal("patch"),
64
64
  ], { default: "created_at" }),
65
- sort_order: t.Union([t.Literal("asc"), t.Literal("desc")], { default: "desc" }),
65
+ sort_order: Type.Union([Type.Literal("asc"), Type.Literal("desc")], { default: "desc" }),
66
66
  });
67
67
  /**
68
68
  * Search versions query schema without project_id (injected from headers)
69
69
  */
70
- export const SearchVersionsQueryParamsSchema = t.Omit(SearchVersionsQuerySchema, ["project_id"]);
70
+ export const SearchVersionsQueryParamsSchema = Type.Omit(SearchVersionsQuerySchema, ["project_id"]);
71
71
  /**
72
72
  * Versions by IDs request schema
73
73
  */
74
- export const VersionsByIdsSchema = t.Object({
75
- version_ids: t.Array(t.String({ format: "uuid" }), { minItems: 1, maxItems: 100 }),
74
+ export const VersionsByIdsSchema = Type.Object({
75
+ version_ids: Type.Array(Type.String({ format: "uuid" }), { minItems: 1, maxItems: 100 }),
76
76
  });
77
77
  /**
78
78
  * Paginated versions response schema
79
79
  */
80
- export const VersionsResponseSchema = t.Object({
81
- versions: t.Array(VersionSchema),
82
- pagination: t.Object({
83
- page: t.Integer({ minimum: 1 }),
84
- limit: t.Integer({ minimum: 1 }),
85
- total: t.Integer({ minimum: 0 }),
86
- total_pages: t.Integer({ minimum: 0 }),
80
+ export const VersionsResponseSchema = Type.Object({
81
+ versions: Type.Array(VersionSchema),
82
+ pagination: Type.Object({
83
+ page: Type.Integer({ minimum: 1 }),
84
+ limit: Type.Integer({ minimum: 1 }),
85
+ total: Type.Integer({ minimum: 0 }),
86
+ total_pages: Type.Integer({ minimum: 0 }),
87
87
  }),
88
88
  });
89
89
  /**
90
90
  * Single version response schema
91
91
  */
92
- export const VersionResponseSchema = t.Object({
93
- success: t.Literal(true),
92
+ export const VersionResponseSchema = Type.Object({
93
+ success: Type.Literal(true),
94
94
  data: VersionSchema,
95
95
  });
96
96
  /**
97
97
  * Version error response schema
98
98
  * Discriminated union by error code
99
99
  */
100
- export const VersionErrorSchema = t.Union([
101
- t.Object({
102
- code: t.Literal("VERSION_NOT_FOUND"),
103
- message: t.String(),
100
+ export const VersionErrorSchema = Type.Union([
101
+ Type.Object({
102
+ code: Type.Literal("VERSION_NOT_FOUND"),
103
+ message: Type.String(),
104
104
  }),
105
- t.Object({
106
- code: t.Literal("PROJECT_NOT_FOUND"),
107
- message: t.String(),
105
+ Type.Object({
106
+ code: Type.Literal("PROJECT_NOT_FOUND"),
107
+ message: Type.String(),
108
108
  }),
109
- t.Object({
110
- code: t.Literal("FORBIDDEN"),
111
- message: t.String(),
109
+ Type.Object({
110
+ code: Type.Literal("FORBIDDEN"),
111
+ message: Type.String(),
112
112
  }),
113
- t.Object({
114
- code: t.Literal("FETCH_FAILED"),
115
- message: t.String(),
113
+ Type.Object({
114
+ code: Type.Literal("FETCH_FAILED"),
115
+ message: Type.String(),
116
116
  }),
117
- t.Object({
118
- code: t.Literal("INVALID_PARAMS"),
119
- message: t.String(),
117
+ Type.Object({
118
+ code: Type.Literal("INVALID_PARAMS"),
119
+ message: Type.String(),
120
120
  }),
121
121
  ]);
122
122
  /**
123
123
  * Version error response wrapper
124
124
  */
125
- export const VersionErrorResponseSchema = t.Object({
126
- success: t.Literal(false),
125
+ export const VersionErrorResponseSchema = Type.Object({
126
+ success: Type.Literal(false),
127
127
  error: VersionErrorSchema,
128
128
  });
129
129
  /**
130
130
  * Version request response schema
131
131
  */
132
- export const VersionRequestResponseSchema = t.Union([VersionResponseSchema, VersionErrorResponseSchema]);
132
+ export const VersionRequestResponseSchema = Type.Union([VersionResponseSchema, VersionErrorResponseSchema]);
133
133
  /**
134
134
  * Update version status request body schema
135
135
  */
136
- export const UpdateVersionStatusBodySchema = t.Object({
136
+ export const UpdateVersionStatusBodySchema = Type.Object({
137
137
  status: VersionBuildStatusSchema,
138
138
  });
139
139
  /**
140
140
  * Add UPDATE_FAILED error code for update operations
141
141
  */
142
- export const VersionErrorSchemaWithUpdate = t.Union([
142
+ export const VersionErrorSchemaWithUpdate = Type.Union([
143
143
  VersionErrorSchema,
144
- t.Object({
145
- code: t.Literal("UPDATE_FAILED"),
146
- message: t.String(),
144
+ Type.Object({
145
+ code: Type.Literal("UPDATE_FAILED"),
146
+ message: Type.String(),
147
147
  }),
148
148
  ]);
149
149
  /**
150
150
  * Version error response wrapper with update error
151
151
  */
152
- export const VersionErrorResponseWithUpdateSchema = t.Object({
153
- success: t.Literal(false),
152
+ export const VersionErrorResponseWithUpdateSchema = Type.Object({
153
+ success: Type.Literal(false),
154
154
  error: VersionErrorSchemaWithUpdate,
155
155
  });
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "@teardown/schemas",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
8
  "type": "module",
9
- "files": ["dist/**/*"],
9
+ "files": [
10
+ "dist/**/*"
11
+ ],
10
12
  "main": "./dist/index.js",
11
13
  "module": "./dist/index.js",
12
14
  "types": "./dist/index.d.ts",
@@ -92,8 +94,8 @@
92
94
  "prepublishOnly": "bun x turbo run build"
93
95
  },
94
96
  "dependencies": {
95
- "@teardown/types": "0.0.2",
96
- "elysia": "1.4.16"
97
+ "@sinclair/typebox": "^0.34.41",
98
+ "@teardown/types": "0.0.3"
97
99
  },
98
100
  "devDependencies": {
99
101
  "@biomejs/biome": "2.3.7",
@@ -103,4 +105,4 @@
103
105
  "peerDependencies": {
104
106
  "typescript": "^5.9.3"
105
107
  }
106
- }
108
+ }