@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.
Files changed (61) hide show
  1. package/dist/common/index.d.ts +3 -0
  2. package/dist/common/index.js +3 -0
  3. package/dist/common/primitives.d.ts +11 -0
  4. package/dist/common/primitives.js +9 -0
  5. package/dist/common/responses.d.ts +27 -0
  6. package/dist/common/responses.js +13 -0
  7. package/dist/common/type-checks.d.ts +58 -0
  8. package/dist/common/type-checks.js +1 -0
  9. package/dist/index.d.ts +13 -0
  10. package/dist/index.js +14 -0
  11. package/dist/modules/analytics/index.d.ts +1 -0
  12. package/dist/modules/analytics/index.js +1 -0
  13. package/dist/modules/analytics/schemas.d.ts +239 -0
  14. package/dist/modules/analytics/schemas.js +136 -0
  15. package/dist/modules/builds/index.d.ts +1 -0
  16. package/dist/modules/builds/index.js +1 -0
  17. package/dist/modules/builds/schemas.d.ts +248 -0
  18. package/dist/modules/builds/schemas.js +137 -0
  19. package/dist/modules/devices/index.d.ts +1 -0
  20. package/dist/modules/devices/index.js +1 -0
  21. package/dist/modules/devices/schemas.d.ts +207 -0
  22. package/dist/modules/devices/schemas.js +165 -0
  23. package/dist/modules/environment/index.d.ts +1 -0
  24. package/dist/modules/environment/index.js +1 -0
  25. package/dist/modules/environment/schemas.d.ts +56 -0
  26. package/dist/modules/environment/schemas.js +57 -0
  27. package/dist/modules/events/index.d.ts +1 -0
  28. package/dist/modules/events/index.js +1 -0
  29. package/dist/modules/events/schemas.d.ts +138 -0
  30. package/dist/modules/events/schemas.js +116 -0
  31. package/dist/modules/identify/index.d.ts +1 -0
  32. package/dist/modules/identify/index.js +1 -0
  33. package/dist/modules/identify/schemas.d.ts +377 -0
  34. package/dist/modules/identify/schemas.js +221 -0
  35. package/dist/modules/index.d.ts +12 -0
  36. package/dist/modules/index.js +12 -0
  37. package/dist/modules/me/index.d.ts +1 -0
  38. package/dist/modules/me/index.js +1 -0
  39. package/dist/modules/me/schemas.d.ts +75 -0
  40. package/dist/modules/me/schemas.js +76 -0
  41. package/dist/modules/orgs/index.d.ts +1 -0
  42. package/dist/modules/orgs/index.js +1 -0
  43. package/dist/modules/orgs/schemas.d.ts +308 -0
  44. package/dist/modules/orgs/schemas.js +214 -0
  45. package/dist/modules/personas/index.d.ts +1 -0
  46. package/dist/modules/personas/index.js +1 -0
  47. package/dist/modules/personas/schemas.d.ts +170 -0
  48. package/dist/modules/personas/schemas.js +100 -0
  49. package/dist/modules/projects/index.d.ts +1 -0
  50. package/dist/modules/projects/index.js +1 -0
  51. package/dist/modules/projects/schemas.d.ts +222 -0
  52. package/dist/modules/projects/schemas.js +145 -0
  53. package/dist/modules/sessions/index.d.ts +1 -0
  54. package/dist/modules/sessions/index.js +1 -0
  55. package/dist/modules/sessions/schemas.d.ts +258 -0
  56. package/dist/modules/sessions/schemas.js +128 -0
  57. package/dist/modules/versions/index.d.ts +1 -0
  58. package/dist/modules/versions/index.js +1 -0
  59. package/dist/modules/versions/schemas.d.ts +248 -0
  60. package/dist/modules/versions/schemas.js +155 -0
  61. package/package.json +106 -0
@@ -0,0 +1,3 @@
1
+ export * from "./primitives";
2
+ export * from "./responses";
3
+ export * from "./type-checks";
@@ -0,0 +1,3 @@
1
+ export * from "./primitives";
2
+ export * from "./responses";
3
+ export * from "./type-checks";
@@ -0,0 +1,11 @@
1
+ import { type Static } from "elysia";
2
+ export declare const UUIDSchema: import("@sinclair/typebox").TString;
3
+ export declare const SlugSchema: import("@sinclair/typebox").TString;
4
+ export declare const URLSchema: import("@sinclair/typebox").TString;
5
+ export declare const TimestampSchema: import("@sinclair/typebox").TString;
6
+ export type UUID = Static<typeof UUIDSchema>;
7
+ export type Slug = Static<typeof SlugSchema>;
8
+ export type URL = Static<typeof URLSchema>;
9
+ export type Timestamp = Static<typeof TimestampSchema>;
10
+ export declare const EmailSchema: import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TLiteral<"">, import("@sinclair/typebox").TUndefined]>>, string | undefined>;
11
+ export type Email = Static<typeof EmailSchema>;
@@ -0,0 +1,9 @@
1
+ import { Type } from "@sinclair/typebox";
2
+ import { t } from "elysia";
3
+ export const UUIDSchema = t.String({ format: "uuid", error: "Invalid UUID" });
4
+ export const SlugSchema = t.String({ pattern: "^[a-z0-9]+(?:-[a-z0-9]+)*$", error: "Invalid slug" });
5
+ export const URLSchema = t.String({ format: "uri", error: "Invalid URL" });
6
+ export const TimestampSchema = t.String({ format: "date-time", error: "Invalid timestamp" });
7
+ export const EmailSchema = Type.Transform(Type.Optional(Type.Union([Type.String({ format: "email", error: "Invalid email address" }), Type.Literal(""), t.Undefined()])))
8
+ .Decode((value) => (value === "" ? undefined : value))
9
+ .Encode((value) => value ?? "");
@@ -0,0 +1,27 @@
1
+ import { type Static, type TSchema } from "elysia";
2
+ export declare const SuccessResponseSchema: <T extends TSchema>(dataSchema: T) => import("@sinclair/typebox").TObject<{
3
+ success: import("@sinclair/typebox").TLiteral<true>;
4
+ data: T;
5
+ }>;
6
+ export declare const ErrorResponseSchema: import("@sinclair/typebox").TObject<{
7
+ success: import("@sinclair/typebox").TLiteral<false>;
8
+ error: import("@sinclair/typebox").TObject<{
9
+ message: import("@sinclair/typebox").TString;
10
+ code: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
11
+ }>;
12
+ }>;
13
+ export type SuccessResponse<T> = {
14
+ success: true;
15
+ data: T;
16
+ };
17
+ export type ErrorResponse = Static<typeof ErrorResponseSchema>;
18
+ export declare const RequestResponseSchema: <Success extends TSchema>(successSchema: Success) => import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
19
+ success: import("@sinclair/typebox").TLiteral<true>;
20
+ data: Success;
21
+ }>, import("@sinclair/typebox").TObject<{
22
+ success: import("@sinclair/typebox").TLiteral<false>;
23
+ error: import("@sinclair/typebox").TObject<{
24
+ message: import("@sinclair/typebox").TString;
25
+ code: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
26
+ }>;
27
+ }>]>;
@@ -0,0 +1,13 @@
1
+ import { t } from "elysia";
2
+ export const SuccessResponseSchema = (dataSchema) => t.Object({
3
+ success: t.Literal(true),
4
+ data: dataSchema,
5
+ });
6
+ export const ErrorResponseSchema = t.Object({
7
+ success: t.Literal(false),
8
+ error: t.Object({
9
+ message: t.String(),
10
+ code: t.Optional(t.String()),
11
+ }),
12
+ });
13
+ export const RequestResponseSchema = (successSchema) => t.Union([SuccessResponseSchema(successSchema), ErrorResponseSchema]);
@@ -0,0 +1,58 @@
1
+ import type { Insert, Tables, Update } from "@teardown/types";
2
+ /**
3
+ * Forces TypeScript to error if T is not `true`.
4
+ * Wrap assertion types with this to ensure compile-time validation.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * type _Check = AssertTrue<AssertSchemaCompatibleWithRow<Project, "projects">>;
9
+ * ```
10
+ */
11
+ export type AssertTrue<T extends true> = T;
12
+ /**
13
+ * Type-level assertion that ensures SchemaType is compatible with DbType.
14
+ * This will cause a TypeScript error if SchemaType cannot be assigned to DbType.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * type _Check = AssertTrue<AssertCompatible<Project, Tables<"projects">["Row"]>>;
19
+ * ```
20
+ */
21
+ export type AssertCompatible<SchemaType, DbType> = SchemaType extends DbType ? DbType extends SchemaType ? true : never : never;
22
+ /**
23
+ * Type-level assertion that ensures SchemaType can be assigned to DbType.
24
+ * This is less strict than AssertCompatible - it only checks one-way assignment.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * type _Check = AssertAssignable<CreateProject, Insert<"projects">>;
29
+ * ```
30
+ */
31
+ export type AssertAssignable<SchemaType, DbType> = SchemaType extends DbType ? true : never;
32
+ /**
33
+ * Helper to check if a schema type is compatible with a database Row type
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * export type _CheckProjectRow = AssertSchemaCompatibleWithRow<Project, "projects">;
38
+ * ```
39
+ */
40
+ export type AssertSchemaCompatibleWithRow<SchemaType, TableName extends keyof Tables> = AssertCompatible<SchemaType, Tables[TableName]["Row"]>;
41
+ /**
42
+ * Helper to check if a create schema type is compatible with a database Insert type
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * type _CheckCreateProject = AssertSchemaCompatibleWithInsert<CreateProject, "projects">;
47
+ * ```
48
+ */
49
+ export type AssertSchemaCompatibleWithInsert<SchemaType, TableName extends keyof Tables> = AssertAssignable<SchemaType, Insert<TableName>>;
50
+ /**
51
+ * Helper to check if an update schema type is compatible with a database Update type
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * type _CheckUpdateProject = AssertSchemaCompatibleWithUpdate<UpdateProject, "projects">;
56
+ * ```
57
+ */
58
+ export type AssertSchemaCompatibleWithUpdate<SchemaType, TableName extends keyof Tables> = AssertAssignable<SchemaType, Update<TableName>>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ export * from "./common";
2
+ export * from "./modules/analytics";
3
+ export * from "./modules/builds";
4
+ export * from "./modules/devices";
5
+ export * from "./modules/environment";
6
+ export * from "./modules/events";
7
+ export * from "./modules/identify";
8
+ export * from "./modules/me";
9
+ export * from "./modules/orgs";
10
+ export * from "./modules/personas";
11
+ export * from "./modules/projects";
12
+ export * from "./modules/sessions";
13
+ export * from "./modules/versions";
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ // Module schemas
2
+ export * from "./common";
3
+ export * from "./modules/analytics";
4
+ export * from "./modules/builds";
5
+ export * from "./modules/devices";
6
+ export * from "./modules/environment";
7
+ export * from "./modules/events";
8
+ export * from "./modules/identify";
9
+ export * from "./modules/me";
10
+ export * from "./modules/orgs";
11
+ export * from "./modules/personas";
12
+ export * from "./modules/projects";
13
+ export * from "./modules/sessions";
14
+ export * from "./modules/versions";
@@ -0,0 +1 @@
1
+ export * from "./schemas";
@@ -0,0 +1 @@
1
+ export * from "./schemas";
@@ -0,0 +1,239 @@
1
+ import { type Static } from "elysia";
2
+ /**
3
+ * Version adoption schema
4
+ */
5
+ export declare const VersionAdoptionPointSchema: import("@sinclair/typebox").TObject<{
6
+ date: import("@sinclair/typebox").TString;
7
+ versions: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber>;
8
+ }>;
9
+ export type VersionAdoptionPoint = Static<typeof VersionAdoptionPointSchema>;
10
+ export declare const VersionAdoptionResponseSchema: import("@sinclair/typebox").TObject<{
11
+ success: import("@sinclair/typebox").TLiteral<true>;
12
+ data: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
13
+ date: import("@sinclair/typebox").TString;
14
+ versions: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber>;
15
+ }>>;
16
+ }>;
17
+ export type VersionAdoptionResponse = Static<typeof VersionAdoptionResponseSchema>;
18
+ /**
19
+ * Active sessions trend schema
20
+ */
21
+ export declare const ActiveSessionsPointSchema: import("@sinclair/typebox").TObject<{
22
+ date: import("@sinclair/typebox").TString;
23
+ count: import("@sinclair/typebox").TInteger;
24
+ }>;
25
+ export type ActiveSessionsPoint = Static<typeof ActiveSessionsPointSchema>;
26
+ export declare const ActiveSessionsTrendResponseSchema: import("@sinclair/typebox").TObject<{
27
+ success: import("@sinclair/typebox").TLiteral<true>;
28
+ data: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
29
+ date: import("@sinclair/typebox").TString;
30
+ count: import("@sinclair/typebox").TInteger;
31
+ }>>;
32
+ }>;
33
+ export type ActiveSessionsTrendResponse = Static<typeof ActiveSessionsTrendResponseSchema>;
34
+ /**
35
+ * Active users schema (with platform breakdown)
36
+ */
37
+ export declare const ActiveUsersSchema: import("@sinclair/typebox").TObject<{
38
+ total: import("@sinclair/typebox").TInteger;
39
+ ios: import("@sinclair/typebox").TInteger;
40
+ android: import("@sinclair/typebox").TInteger;
41
+ trend: import("@sinclair/typebox").TNumber;
42
+ }>;
43
+ export type ActiveUsers = Static<typeof ActiveUsersSchema>;
44
+ export declare const ActiveUsersResponseSchema: import("@sinclair/typebox").TObject<{
45
+ success: import("@sinclair/typebox").TLiteral<true>;
46
+ data: import("@sinclair/typebox").TObject<{
47
+ total: import("@sinclair/typebox").TInteger;
48
+ ios: import("@sinclair/typebox").TInteger;
49
+ android: import("@sinclair/typebox").TInteger;
50
+ trend: import("@sinclair/typebox").TNumber;
51
+ }>;
52
+ }>;
53
+ export type ActiveUsersResponse = Static<typeof ActiveUsersResponseSchema>;
54
+ /**
55
+ * Active users query params schema
56
+ */
57
+ export declare const ActiveUsersQuerySchema: import("@sinclair/typebox").TObject<{
58
+ start_date: import("@sinclair/typebox").TString;
59
+ end_date: import("@sinclair/typebox").TString;
60
+ }>;
61
+ export type ActiveUsersQuery = Static<typeof ActiveUsersQuerySchema>;
62
+ /**
63
+ * Build adoption schema (with platform breakdown)
64
+ */
65
+ export declare const BuildStatsSchema: import("@sinclair/typebox").TObject<{
66
+ total: import("@sinclair/typebox").TInteger;
67
+ ios: import("@sinclair/typebox").TInteger;
68
+ android: import("@sinclair/typebox").TInteger;
69
+ }>;
70
+ export type BuildStats = Static<typeof BuildStatsSchema>;
71
+ export declare const BuildAdoptionPointSchema: import("@sinclair/typebox").TObject<{
72
+ date: import("@sinclair/typebox").TString;
73
+ builds: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TObject<{
74
+ total: import("@sinclair/typebox").TInteger;
75
+ ios: import("@sinclair/typebox").TInteger;
76
+ android: import("@sinclair/typebox").TInteger;
77
+ }>>;
78
+ }>;
79
+ export type BuildAdoptionPoint = Static<typeof BuildAdoptionPointSchema>;
80
+ export declare const BuildAdoptionResponseSchema: import("@sinclair/typebox").TObject<{
81
+ success: import("@sinclair/typebox").TLiteral<true>;
82
+ data: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
83
+ date: import("@sinclair/typebox").TString;
84
+ builds: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TObject<{
85
+ total: import("@sinclair/typebox").TInteger;
86
+ ios: import("@sinclair/typebox").TInteger;
87
+ android: import("@sinclair/typebox").TInteger;
88
+ }>>;
89
+ }>>;
90
+ }>;
91
+ export type BuildAdoptionResponse = Static<typeof BuildAdoptionResponseSchema>;
92
+ /**
93
+ * Date range query params schema (shared)
94
+ */
95
+ export declare const DateRangeQuerySchema: import("@sinclair/typebox").TObject<{
96
+ start_date: import("@sinclair/typebox").TString;
97
+ end_date: import("@sinclair/typebox").TString;
98
+ }>;
99
+ export type DateRangeQuery = Static<typeof DateRangeQuerySchema>;
100
+ /**
101
+ * Active versions/builds query params schema (with optional search)
102
+ */
103
+ export declare const ActiveVersionsQuerySchema: import("@sinclair/typebox").TObject<{
104
+ start_date: import("@sinclair/typebox").TString;
105
+ end_date: import("@sinclair/typebox").TString;
106
+ search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
107
+ }>;
108
+ export type ActiveVersionsQuery = Static<typeof ActiveVersionsQuerySchema>;
109
+ /**
110
+ * Active versions & builds analytics schema
111
+ * Aggregated session counts by version and build for a date range
112
+ */
113
+ export declare const ActiveBuildStatsSchema: import("@sinclair/typebox").TObject<{
114
+ build_id: import("@sinclair/typebox").TString;
115
+ build_number: import("@sinclair/typebox").TInteger;
116
+ platform: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"IOS">, import("@sinclair/typebox").TLiteral<"ANDROID">]>;
117
+ session_count: import("@sinclair/typebox").TInteger;
118
+ device_count: import("@sinclair/typebox").TInteger;
119
+ }>;
120
+ export type ActiveBuildStats = Static<typeof ActiveBuildStatsSchema>;
121
+ export declare const ActiveVersionStatsSchema: import("@sinclair/typebox").TObject<{
122
+ version_id: import("@sinclair/typebox").TString;
123
+ version_name: import("@sinclair/typebox").TString;
124
+ session_count: import("@sinclair/typebox").TInteger;
125
+ device_count: import("@sinclair/typebox").TInteger;
126
+ ios_count: import("@sinclair/typebox").TInteger;
127
+ android_count: import("@sinclair/typebox").TInteger;
128
+ builds: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
129
+ build_id: import("@sinclair/typebox").TString;
130
+ build_number: import("@sinclair/typebox").TInteger;
131
+ platform: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"IOS">, import("@sinclair/typebox").TLiteral<"ANDROID">]>;
132
+ session_count: import("@sinclair/typebox").TInteger;
133
+ device_count: import("@sinclair/typebox").TInteger;
134
+ }>>;
135
+ }>;
136
+ export type ActiveVersionStats = Static<typeof ActiveVersionStatsSchema>;
137
+ export declare const ActiveVersionsBuildsSchema: import("@sinclair/typebox").TObject<{
138
+ versions: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
139
+ version_id: import("@sinclair/typebox").TString;
140
+ version_name: import("@sinclair/typebox").TString;
141
+ session_count: import("@sinclair/typebox").TInteger;
142
+ device_count: import("@sinclair/typebox").TInteger;
143
+ ios_count: import("@sinclair/typebox").TInteger;
144
+ android_count: import("@sinclair/typebox").TInteger;
145
+ builds: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
146
+ build_id: import("@sinclair/typebox").TString;
147
+ build_number: import("@sinclair/typebox").TInteger;
148
+ platform: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"IOS">, import("@sinclair/typebox").TLiteral<"ANDROID">]>;
149
+ session_count: import("@sinclair/typebox").TInteger;
150
+ device_count: import("@sinclair/typebox").TInteger;
151
+ }>>;
152
+ }>>;
153
+ }>;
154
+ export type ActiveVersionsBuilds = Static<typeof ActiveVersionsBuildsSchema>;
155
+ export declare const ActiveVersionsBuildsResponseSchema: import("@sinclair/typebox").TObject<{
156
+ success: import("@sinclair/typebox").TLiteral<true>;
157
+ data: import("@sinclair/typebox").TObject<{
158
+ versions: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
159
+ version_id: import("@sinclair/typebox").TString;
160
+ version_name: import("@sinclair/typebox").TString;
161
+ session_count: import("@sinclair/typebox").TInteger;
162
+ device_count: import("@sinclair/typebox").TInteger;
163
+ ios_count: import("@sinclair/typebox").TInteger;
164
+ android_count: import("@sinclair/typebox").TInteger;
165
+ builds: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
166
+ build_id: import("@sinclair/typebox").TString;
167
+ build_number: import("@sinclair/typebox").TInteger;
168
+ platform: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"IOS">, import("@sinclair/typebox").TLiteral<"ANDROID">]>;
169
+ session_count: import("@sinclair/typebox").TInteger;
170
+ device_count: import("@sinclair/typebox").TInteger;
171
+ }>>;
172
+ }>>;
173
+ }>;
174
+ }>;
175
+ export type ActiveVersionsBuildsResponse = Static<typeof ActiveVersionsBuildsResponseSchema>;
176
+ /**
177
+ * Session with user/device data for build sessions endpoint
178
+ */
179
+ export declare const SessionDeviceSchema: import("@sinclair/typebox").TObject<{
180
+ id: import("@sinclair/typebox").TString;
181
+ device_name: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
182
+ device_brand: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
183
+ }>;
184
+ export type SessionDevice = Static<typeof SessionDeviceSchema>;
185
+ export declare const SessionUserSchema: import("@sinclair/typebox").TObject<{
186
+ id: import("@sinclair/typebox").TString;
187
+ user_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
188
+ email: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
189
+ name: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
190
+ }>;
191
+ export type SessionUser = Static<typeof SessionUserSchema>;
192
+ export declare const SessionWithUserSchema: import("@sinclair/typebox").TObject<{
193
+ id: import("@sinclair/typebox").TString;
194
+ started_at: import("@sinclair/typebox").TString;
195
+ os_version: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
196
+ device: import("@sinclair/typebox").TObject<{
197
+ id: import("@sinclair/typebox").TString;
198
+ device_name: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
199
+ device_brand: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
200
+ }>;
201
+ user: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
202
+ id: import("@sinclair/typebox").TString;
203
+ user_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
204
+ email: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
205
+ name: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
206
+ }>, import("@sinclair/typebox").TNull]>;
207
+ }>;
208
+ export type SessionWithUser = Static<typeof SessionWithUserSchema>;
209
+ export declare const BuildSessionsQuerySchema: import("@sinclair/typebox").TObject<{
210
+ start_date: import("@sinclair/typebox").TString;
211
+ end_date: import("@sinclair/typebox").TString;
212
+ cursor: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
213
+ limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
214
+ search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
215
+ }>;
216
+ export type BuildSessionsQuery = Static<typeof BuildSessionsQuerySchema>;
217
+ export declare const BuildSessionsResponseSchema: import("@sinclair/typebox").TObject<{
218
+ success: import("@sinclair/typebox").TLiteral<true>;
219
+ data: import("@sinclair/typebox").TObject<{
220
+ sessions: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
221
+ id: import("@sinclair/typebox").TString;
222
+ started_at: import("@sinclair/typebox").TString;
223
+ os_version: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
224
+ device: import("@sinclair/typebox").TObject<{
225
+ id: import("@sinclair/typebox").TString;
226
+ device_name: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
227
+ device_brand: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
228
+ }>;
229
+ user: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
230
+ id: import("@sinclair/typebox").TString;
231
+ user_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
232
+ email: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
233
+ name: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
234
+ }>, import("@sinclair/typebox").TNull]>;
235
+ }>>;
236
+ next_cursor: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
237
+ }>;
238
+ }>;
239
+ export type BuildSessionsResponse = Static<typeof BuildSessionsResponseSchema>;
@@ -0,0 +1,136 @@
1
+ import { t } from "elysia";
2
+ /**
3
+ * Version adoption schema
4
+ */
5
+ export const VersionAdoptionPointSchema = t.Object({
6
+ date: t.String(), // YYYY-MM-DD
7
+ versions: t.Record(t.String(), t.Number()), // version -> count
8
+ });
9
+ export const VersionAdoptionResponseSchema = t.Object({
10
+ success: t.Literal(true),
11
+ data: t.Array(VersionAdoptionPointSchema),
12
+ });
13
+ /**
14
+ * Active sessions trend schema
15
+ */
16
+ export const ActiveSessionsPointSchema = t.Object({
17
+ date: t.String(), // YYYY-MM-DD
18
+ count: t.Integer({ minimum: 0 }),
19
+ });
20
+ export const ActiveSessionsTrendResponseSchema = t.Object({
21
+ success: t.Literal(true),
22
+ data: t.Array(ActiveSessionsPointSchema),
23
+ });
24
+ /**
25
+ * Active users schema (with platform breakdown)
26
+ */
27
+ export const ActiveUsersSchema = t.Object({
28
+ total: t.Integer({ minimum: 0 }),
29
+ ios: t.Integer({ minimum: 0 }),
30
+ android: t.Integer({ minimum: 0 }),
31
+ trend: t.Number(), // percentage change vs previous period
32
+ });
33
+ export const ActiveUsersResponseSchema = t.Object({
34
+ success: t.Literal(true),
35
+ data: ActiveUsersSchema,
36
+ });
37
+ /**
38
+ * Active users query params schema
39
+ */
40
+ export const ActiveUsersQuerySchema = t.Object({
41
+ start_date: t.String({ format: "date-time" }),
42
+ end_date: t.String({ format: "date-time" }),
43
+ });
44
+ /**
45
+ * Build adoption schema (with platform breakdown)
46
+ */
47
+ export const BuildStatsSchema = t.Object({
48
+ total: t.Integer({ minimum: 0 }),
49
+ ios: t.Integer({ minimum: 0 }),
50
+ android: t.Integer({ minimum: 0 }),
51
+ });
52
+ export const BuildAdoptionPointSchema = t.Object({
53
+ date: t.String(), // YYYY-MM-DD
54
+ builds: t.Record(t.String(), BuildStatsSchema), // build_number -> stats
55
+ });
56
+ export const BuildAdoptionResponseSchema = t.Object({
57
+ success: t.Literal(true),
58
+ data: t.Array(BuildAdoptionPointSchema),
59
+ });
60
+ /**
61
+ * Date range query params schema (shared)
62
+ */
63
+ export const DateRangeQuerySchema = t.Object({
64
+ start_date: t.String({ format: "date-time" }),
65
+ end_date: t.String({ format: "date-time" }),
66
+ });
67
+ /**
68
+ * Active versions/builds query params schema (with optional search)
69
+ */
70
+ export const ActiveVersionsQuerySchema = t.Object({
71
+ start_date: t.String({ format: "date-time" }),
72
+ end_date: t.String({ format: "date-time" }),
73
+ search: t.Optional(t.String()),
74
+ });
75
+ /**
76
+ * Active versions & builds analytics schema
77
+ * Aggregated session counts by version and build for a date range
78
+ */
79
+ export const ActiveBuildStatsSchema = t.Object({
80
+ build_id: t.String(),
81
+ build_number: t.Integer({ minimum: 0 }),
82
+ platform: t.Union([t.Literal("IOS"), t.Literal("ANDROID")]),
83
+ session_count: t.Integer({ minimum: 0 }),
84
+ device_count: t.Integer({ minimum: 0 }),
85
+ });
86
+ export const ActiveVersionStatsSchema = t.Object({
87
+ version_id: t.String(),
88
+ version_name: t.String(),
89
+ session_count: t.Integer({ minimum: 0 }),
90
+ device_count: t.Integer({ minimum: 0 }),
91
+ ios_count: t.Integer({ minimum: 0 }),
92
+ android_count: t.Integer({ minimum: 0 }),
93
+ builds: t.Array(ActiveBuildStatsSchema),
94
+ });
95
+ export const ActiveVersionsBuildsSchema = t.Object({
96
+ versions: t.Array(ActiveVersionStatsSchema),
97
+ });
98
+ export const ActiveVersionsBuildsResponseSchema = t.Object({
99
+ success: t.Literal(true),
100
+ data: ActiveVersionsBuildsSchema,
101
+ });
102
+ /**
103
+ * Session with user/device data for build sessions endpoint
104
+ */
105
+ export const SessionDeviceSchema = t.Object({
106
+ id: t.String(),
107
+ device_name: t.Union([t.String(), t.Null()]),
108
+ device_brand: t.Union([t.String(), t.Null()]),
109
+ });
110
+ export const SessionUserSchema = t.Object({
111
+ id: t.String(),
112
+ user_id: t.Union([t.String(), t.Null()]),
113
+ email: t.Union([t.String(), t.Null()]),
114
+ name: t.Union([t.String(), t.Null()]),
115
+ });
116
+ export const SessionWithUserSchema = t.Object({
117
+ id: t.String(),
118
+ started_at: t.String(),
119
+ os_version: t.Union([t.String(), t.Null()]),
120
+ device: SessionDeviceSchema,
121
+ user: t.Union([SessionUserSchema, t.Null()]),
122
+ });
123
+ export const BuildSessionsQuerySchema = t.Object({
124
+ start_date: t.String({ format: "date-time" }),
125
+ end_date: t.String({ format: "date-time" }),
126
+ cursor: t.Optional(t.String()),
127
+ limit: t.Optional(t.String({ default: "20" })),
128
+ search: t.Optional(t.String()),
129
+ });
130
+ export const BuildSessionsResponseSchema = t.Object({
131
+ success: t.Literal(true),
132
+ data: t.Object({
133
+ sessions: t.Array(SessionWithUserSchema),
134
+ next_cursor: t.Union([t.String(), t.Null()]),
135
+ }),
136
+ });
@@ -0,0 +1 @@
1
+ export * from "./schemas";
@@ -0,0 +1 @@
1
+ export * from "./schemas";