@teardown/schemas 0.1.21 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +49 -52
- package/src/common/primitives.ts +21 -0
- package/src/common/responses.ts +25 -0
- package/{dist/common/type-checks.d.ts → src/common/type-checks.ts} +23 -4
- package/{dist/index.js → src/index.ts} +1 -0
- package/src/modules/analytics/schemas.ts +178 -0
- package/src/modules/builds/schemas.ts +171 -0
- package/src/modules/devices/schemas.ts +196 -0
- package/src/modules/environment/schemas.ts +81 -0
- package/src/modules/events/index.ts +2 -0
- package/src/modules/events/schemas.ts +129 -0
- package/src/modules/identify/schemas.ts +257 -0
- package/src/modules/me/schemas.ts +87 -0
- package/src/modules/orgs/schemas.ts +260 -0
- package/src/modules/personas/schemas.ts +123 -0
- package/src/modules/projects/schemas.ts +179 -0
- package/src/modules/sessions/schemas.ts +158 -0
- package/src/modules/versions/schemas.ts +192 -0
- package/dist/common/index.js +0 -3
- package/dist/common/primitives.d.ts +0 -11
- package/dist/common/primitives.js +0 -8
- package/dist/common/responses.d.ts +0 -27
- package/dist/common/responses.js +0 -13
- package/dist/common/type-checks.js +0 -1
- package/dist/index.d.ts +0 -13
- package/dist/modules/analytics/schemas.d.ts +0 -239
- package/dist/modules/analytics/schemas.js +0 -136
- package/dist/modules/builds/schemas.d.ts +0 -248
- package/dist/modules/builds/schemas.js +0 -137
- package/dist/modules/devices/schemas.d.ts +0 -207
- package/dist/modules/devices/schemas.js +0 -165
- package/dist/modules/environment/schemas.d.ts +0 -56
- package/dist/modules/environment/schemas.js +0 -57
- package/dist/modules/events/schemas.d.ts +0 -138
- package/dist/modules/events/schemas.js +0 -116
- package/dist/modules/identify/index.js +0 -1
- package/dist/modules/identify/schemas.d.ts +0 -377
- package/dist/modules/identify/schemas.js +0 -221
- package/dist/modules/index.js +0 -12
- package/dist/modules/me/index.d.ts +0 -1
- package/dist/modules/me/index.js +0 -1
- package/dist/modules/me/schemas.d.ts +0 -75
- package/dist/modules/me/schemas.js +0 -76
- package/dist/modules/orgs/index.d.ts +0 -1
- package/dist/modules/orgs/index.js +0 -1
- package/dist/modules/orgs/schemas.d.ts +0 -308
- package/dist/modules/orgs/schemas.js +0 -214
- package/dist/modules/personas/index.d.ts +0 -1
- package/dist/modules/personas/index.js +0 -1
- package/dist/modules/personas/schemas.d.ts +0 -170
- package/dist/modules/personas/schemas.js +0 -100
- package/dist/modules/projects/index.d.ts +0 -1
- package/dist/modules/projects/index.js +0 -1
- package/dist/modules/projects/schemas.d.ts +0 -222
- package/dist/modules/projects/schemas.js +0 -145
- package/dist/modules/sessions/index.d.ts +0 -1
- package/dist/modules/sessions/index.js +0 -1
- package/dist/modules/sessions/schemas.d.ts +0 -258
- package/dist/modules/sessions/schemas.js +0 -128
- package/dist/modules/versions/index.d.ts +0 -1
- package/dist/modules/versions/index.js +0 -1
- package/dist/modules/versions/schemas.d.ts +0 -248
- package/dist/modules/versions/schemas.js +0 -155
- /package/{dist/common/index.d.ts → src/common/index.ts} +0 -0
- /package/{dist/modules/analytics/index.d.ts → src/modules/analytics/index.ts} +0 -0
- /package/{dist/modules/analytics/index.js → src/modules/builds/index.ts} +0 -0
- /package/{dist/modules/builds/index.d.ts → src/modules/devices/index.ts} +0 -0
- /package/{dist/modules/builds/index.js → src/modules/environment/index.ts} +0 -0
- /package/{dist/modules/devices/index.d.ts → src/modules/identify/index.ts} +0 -0
- /package/{dist/modules/index.d.ts → src/modules/index.ts} +0 -0
- /package/{dist/modules/devices/index.js → src/modules/me/index.ts} +0 -0
- /package/{dist/modules/environment/index.d.ts → src/modules/orgs/index.ts} +0 -0
- /package/{dist/modules/environment/index.js → src/modules/personas/index.ts} +0 -0
- /package/{dist/modules/events/index.d.ts → src/modules/projects/index.ts} +0 -0
- /package/{dist/modules/events/index.js → src/modules/sessions/index.ts} +0 -0
- /package/{dist/modules/identify/index.d.ts → src/modules/versions/index.ts} +0 -0
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { Type } from "@sinclair/typebox";
|
|
2
|
-
import { VersionBuildStatusEnum } from "@teardown/types";
|
|
3
|
-
/**
|
|
4
|
-
* Version status enum matching database
|
|
5
|
-
*/
|
|
6
|
-
export const VersionBuildStatusSchema = Type.Enum(VersionBuildStatusEnum);
|
|
7
|
-
/**
|
|
8
|
-
* Parse and validate a VersionBuildStatusEnum value
|
|
9
|
-
* Uses a switch statement to ensure type safety and runtime validation
|
|
10
|
-
* @param value - The value to parse
|
|
11
|
-
* @returns The validated VersionBuildStatusEnum value
|
|
12
|
-
* @throws Error if the value is not a valid VersionBuildStatusEnum
|
|
13
|
-
*/
|
|
14
|
-
export function parseVersionStatusEnum(value) {
|
|
15
|
-
switch (value) {
|
|
16
|
-
case VersionBuildStatusEnum.SUPPORTED:
|
|
17
|
-
return VersionBuildStatusEnum.SUPPORTED;
|
|
18
|
-
case VersionBuildStatusEnum.UPDATE_AVAILABLE:
|
|
19
|
-
return VersionBuildStatusEnum.UPDATE_AVAILABLE;
|
|
20
|
-
case VersionBuildStatusEnum.UPDATE_RECOMMENDED:
|
|
21
|
-
case VersionBuildStatusEnum.UPDATE_REQUIRED:
|
|
22
|
-
return VersionBuildStatusEnum.UPDATE_REQUIRED;
|
|
23
|
-
default:
|
|
24
|
-
throw new Error(`Invalid VersionBuildStatusEnum value: ${value}. Expected one of: ${Object.values(VersionBuildStatusEnum).join(", ")}`);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Base version schema
|
|
29
|
-
* Represents project_versions table structure
|
|
30
|
-
*/
|
|
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
|
-
status: VersionBuildStatusSchema, // SUPPORTED, UPDATE_AVAILABLE, UPDATE_RECOMMENDED, UPDATE_REQUIRED - controls if version is active
|
|
39
|
-
created_at: Type.String(),
|
|
40
|
-
updated_at: Type.String(),
|
|
41
|
-
});
|
|
42
|
-
/**
|
|
43
|
-
* Version params schema
|
|
44
|
-
*/
|
|
45
|
-
export const VersionParamsSchema = Type.Object({
|
|
46
|
-
version_id: Type.String({ format: "uuid" }),
|
|
47
|
-
});
|
|
48
|
-
/**
|
|
49
|
-
* Search versions query schema
|
|
50
|
-
* Supports pagination, search, and sorting
|
|
51
|
-
*/
|
|
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
|
-
], { default: "created_at" }),
|
|
65
|
-
sort_order: Type.Union([Type.Literal("asc"), Type.Literal("desc")], { default: "desc" }),
|
|
66
|
-
});
|
|
67
|
-
/**
|
|
68
|
-
* Search versions query schema without project_id (injected from headers)
|
|
69
|
-
*/
|
|
70
|
-
export const SearchVersionsQueryParamsSchema = Type.Omit(SearchVersionsQuerySchema, ["project_id"]);
|
|
71
|
-
/**
|
|
72
|
-
* Versions by IDs request schema
|
|
73
|
-
*/
|
|
74
|
-
export const VersionsByIdsSchema = Type.Object({
|
|
75
|
-
version_ids: Type.Array(Type.String({ format: "uuid" }), { minItems: 1, maxItems: 100 }),
|
|
76
|
-
});
|
|
77
|
-
/**
|
|
78
|
-
* Paginated versions response schema
|
|
79
|
-
*/
|
|
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
|
-
}),
|
|
88
|
-
});
|
|
89
|
-
/**
|
|
90
|
-
* Single version response schema
|
|
91
|
-
*/
|
|
92
|
-
export const VersionResponseSchema = Type.Object({
|
|
93
|
-
success: Type.Literal(true),
|
|
94
|
-
data: VersionSchema,
|
|
95
|
-
});
|
|
96
|
-
/**
|
|
97
|
-
* Version error response schema
|
|
98
|
-
* Discriminated union by error code
|
|
99
|
-
*/
|
|
100
|
-
export const VersionErrorSchema = Type.Union([
|
|
101
|
-
Type.Object({
|
|
102
|
-
code: Type.Literal("VERSION_NOT_FOUND"),
|
|
103
|
-
message: Type.String(),
|
|
104
|
-
}),
|
|
105
|
-
Type.Object({
|
|
106
|
-
code: Type.Literal("PROJECT_NOT_FOUND"),
|
|
107
|
-
message: Type.String(),
|
|
108
|
-
}),
|
|
109
|
-
Type.Object({
|
|
110
|
-
code: Type.Literal("FORBIDDEN"),
|
|
111
|
-
message: Type.String(),
|
|
112
|
-
}),
|
|
113
|
-
Type.Object({
|
|
114
|
-
code: Type.Literal("FETCH_FAILED"),
|
|
115
|
-
message: Type.String(),
|
|
116
|
-
}),
|
|
117
|
-
Type.Object({
|
|
118
|
-
code: Type.Literal("INVALID_PARAMS"),
|
|
119
|
-
message: Type.String(),
|
|
120
|
-
}),
|
|
121
|
-
]);
|
|
122
|
-
/**
|
|
123
|
-
* Version error response wrapper
|
|
124
|
-
*/
|
|
125
|
-
export const VersionErrorResponseSchema = Type.Object({
|
|
126
|
-
success: Type.Literal(false),
|
|
127
|
-
error: VersionErrorSchema,
|
|
128
|
-
});
|
|
129
|
-
/**
|
|
130
|
-
* Version request response schema
|
|
131
|
-
*/
|
|
132
|
-
export const VersionRequestResponseSchema = Type.Union([VersionResponseSchema, VersionErrorResponseSchema]);
|
|
133
|
-
/**
|
|
134
|
-
* Update version status request body schema
|
|
135
|
-
*/
|
|
136
|
-
export const UpdateVersionStatusBodySchema = Type.Object({
|
|
137
|
-
status: VersionBuildStatusSchema,
|
|
138
|
-
});
|
|
139
|
-
/**
|
|
140
|
-
* Add UPDATE_FAILED error code for update operations
|
|
141
|
-
*/
|
|
142
|
-
export const VersionErrorSchemaWithUpdate = Type.Union([
|
|
143
|
-
VersionErrorSchema,
|
|
144
|
-
Type.Object({
|
|
145
|
-
code: Type.Literal("UPDATE_FAILED"),
|
|
146
|
-
message: Type.String(),
|
|
147
|
-
}),
|
|
148
|
-
]);
|
|
149
|
-
/**
|
|
150
|
-
* Version error response wrapper with update error
|
|
151
|
-
*/
|
|
152
|
-
export const VersionErrorResponseWithUpdateSchema = Type.Object({
|
|
153
|
-
success: Type.Literal(false),
|
|
154
|
-
error: VersionErrorSchemaWithUpdate,
|
|
155
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|