@teardown/ingest-api 0.0.20 → 0.0.21-alpha.10

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,9 +1,143 @@
1
1
  import { edenFetch } from "@elysiajs/eden";
2
- import type { IngestApp } from "../types/app";
3
- export type ClientConfig = NonNullable<Parameters<typeof edenFetch<IngestApp>>[1]>;
4
- export declare const client: (server: string, config?: import("@elysiajs/eden/fetch").EdenFetch.Config) => import("@elysiajs/eden/fetch").EdenFetch.Fn<unknown>;
2
+ import type { IngestApp } from "@teardown/ingest/types";
3
+ export type ClientConfig = NonNullable<Parameters<typeof edenFetch<typeof IngestApp>>[1]>;
4
+ export declare const client: (server: string, config?: import("@elysiajs/eden/fetch").EdenFetch.Config) => import("@elysiajs/eden/fetch").EdenFetch.Fn<{
5
+ "/health": {
6
+ get: {
7
+ body: unknown;
8
+ params: {};
9
+ query: unknown;
10
+ headers: unknown;
11
+ response: {
12
+ 200: {
13
+ status: string;
14
+ timestamp: string;
15
+ };
16
+ };
17
+ };
18
+ };
19
+ } & {
20
+ "/v1/identify": {
21
+ post: {
22
+ body: {
23
+ device: {
24
+ application: {
25
+ version: string;
26
+ build_number: string;
27
+ };
28
+ update: {
29
+ is_enabled: boolean;
30
+ update_id: string;
31
+ update_channel: string;
32
+ runtime_version: string;
33
+ emergency_launch: {
34
+ is_emergency_launch: true;
35
+ reason: string;
36
+ } | {
37
+ is_emergency_launch: false;
38
+ reason?: undefined;
39
+ };
40
+ is_embedded_launch: boolean;
41
+ created_at: Date;
42
+ } | null;
43
+ hardware: {
44
+ device_name: string;
45
+ device_type: string;
46
+ device_brand: string;
47
+ };
48
+ os: {
49
+ platform: import("@teardown/types").DevicePlatformEnum;
50
+ name: string;
51
+ version: string;
52
+ };
53
+ notifications: {
54
+ push: {
55
+ enabled: boolean;
56
+ granted: boolean;
57
+ token: string | null;
58
+ platform: import("@teardown/schemas/identify").NotificationPlatform;
59
+ };
60
+ };
61
+ timestamp?: Date | undefined;
62
+ };
63
+ persona?: {
64
+ user_id?: string | undefined;
65
+ email?: string | undefined;
66
+ name?: string | undefined;
67
+ } | undefined;
68
+ };
69
+ params: {};
70
+ query: unknown;
71
+ headers: {
72
+ "td-org-id": string;
73
+ "td-project-id": string;
74
+ "td-environment-slug": string;
75
+ authorization?: string | undefined;
76
+ };
77
+ response: {
78
+ 200: {
79
+ success: true;
80
+ session_id: string;
81
+ device_id: string;
82
+ persona_id: string;
83
+ token: string;
84
+ };
85
+ 400: {
86
+ success: false;
87
+ error: {
88
+ code: "MISSING_ORG_ID";
89
+ message: string;
90
+ } | {
91
+ code: "MISSING_PROJECT_ID";
92
+ message: string;
93
+ } | {
94
+ code: "MISSING_ENVIRONMENT_SLUG";
95
+ message: string;
96
+ } | {
97
+ code: "IDENTIFY_FAILED";
98
+ message: string;
99
+ } | {
100
+ code: "NO_SESSION_ID_GENERATED";
101
+ message: string;
102
+ } | {
103
+ code: "NO_DEVICE_ID_GENERATED";
104
+ message: string;
105
+ } | {
106
+ code: "NO_PERSONA_ID_GENERATED";
107
+ message: string;
108
+ };
109
+ };
110
+ 422: {
111
+ type: "validation";
112
+ on: string;
113
+ summary?: string;
114
+ message?: string;
115
+ found?: unknown;
116
+ property?: string;
117
+ expected?: string;
118
+ };
119
+ };
120
+ };
121
+ };
122
+ } & {
123
+ "": {
124
+ get: {
125
+ body: unknown;
126
+ params: {};
127
+ query: unknown;
128
+ headers: unknown;
129
+ response: {
130
+ 200: {
131
+ message: string;
132
+ version: string;
133
+ };
134
+ };
135
+ };
136
+ };
137
+ }>;
5
138
  export type Client = ReturnType<typeof client>;
6
139
  export type RequestOptions = Omit<NonNullable<Parameters<Client>[1]>, "headers"> & {
7
140
  headers?: Record<string, string>;
8
141
  };
9
142
  export type Endpoints = Parameters<Client>[0];
143
+ export type App = typeof IngestApp;
@@ -17,7 +17,23 @@ export type UnionToIntersect<U> = (U extends any ? (arg: U) => any : never) exte
17
17
  export type IsAny<T> = 0 extends 1 & T ? true : false;
18
18
  export type IsNever<T> = [T] extends [never] ? true : false;
19
19
  export type IsUnknown<T> = IsAny<T> extends true ? false : unknown extends T ? true : false;
20
- export type AnyTypedRoute = {
20
+ export type IsExactlyUnknown<T> = [T] extends [unknown] ? ([unknown] extends [T] ? true : false) : false;
21
+ export type IsUndefined<T> = [T] extends [undefined] ? true : false;
22
+ export type IsMatchingEmptyObject<T> = [T] extends [{}] ? ([{}] extends [T] ? true : false) : false;
23
+ export type MaybeEmptyObject<TObj, TKey extends PropertyKey, TFallback = Record<string, unknown>> = IsUndefined<TObj> extends true ? {
24
+ [K in TKey]?: TFallback;
25
+ } : IsExactlyUnknown<TObj> extends true ? {
26
+ [K in TKey]?: TFallback;
27
+ } : IsMatchingEmptyObject<TObj> extends true ? {
28
+ [K in TKey]?: TObj;
29
+ } : undefined extends TObj ? {
30
+ [K in TKey]?: TObj;
31
+ } : null extends TObj ? {
32
+ [K in TKey]?: TObj;
33
+ } : {
34
+ [K in TKey]: TObj;
35
+ };
36
+ type AnyTypedRoute = {
21
37
  body?: unknown;
22
38
  headers?: unknown;
23
39
  query?: unknown;
@@ -39,36 +55,4 @@ export type TreatyToPath<T, Path extends string = ""> = UnionToIntersect<T exten
39
55
  } : TreatyToPath<T[K], `${Path}/${K & string}`>;
40
56
  }[keyof T] : {}>;
41
57
  export type Not<T> = T extends true ? false : true;
42
- export type Fn<Schema extends Record<string, any>> = <Endpoint extends keyof Schema, Method extends Uppercase<Extract<keyof Schema[Endpoint], string>>, Route extends Schema[Endpoint][Lowercase<Method>]>(endpoint: Endpoint, options: Omit<RequestInit, "body" | "method" | "headers"> & ("GET" extends Method ? {
43
- method?: Method;
44
- } : {
45
- method: Method;
46
- }) & (IsNever<keyof Route["params"]> extends true ? {
47
- params?: Record<never, string>;
48
- } : {
49
- params: Route["params"];
50
- }) & (IsNever<keyof Route["query"]> extends true ? {
51
- query?: Record<never, string>;
52
- } : {
53
- query: Route["query"];
54
- }) & (undefined extends Route["headers"] ? {
55
- headers?: Record<string, string>;
56
- } : {
57
- headers: Route["headers"];
58
- }) & (IsUnknown<Route["body"]> extends false ? {
59
- body: Route["body"];
60
- } : {
61
- body?: unknown;
62
- })) => Promise<Prettify<{
63
- data: Awaited<Route["response"][200]>;
64
- error: null;
65
- status: number;
66
- headers: Record<string, unknown>;
67
- retry(): Promise<void>;
68
- } | {
69
- data: null;
70
- error: MapError<Route["response"]> extends infer Errors ? IsNever<Errors> extends true ? EdenFetchError<number, string> : Errors : EdenFetchError<number, string>;
71
- status: number;
72
- headers: Record<string, unknown>;
73
- retry(): Promise<void>;
74
- }>>;
58
+ export {};
@@ -1 +1 @@
1
- export * from "./identify.schema";
1
+ export * from "../vendored/schemas/identify";
@@ -1 +1 @@
1
- export * from "./identify.schema";
1
+ export * from "../vendored/schemas/identify";
@@ -1,2 +1,3 @@
1
- export type { OSType, DeviceType, ApplicationInfo, OSInfo, HardwareInfo, UpdateInfo, DeviceInfo, PersonaInfo, IdentifyRequest, IdentifyResponse, IdentifyErrorResponse, } from "../schemas/identify.schema";
2
- export type { IngestApp } from "./app";
1
+ import * as EnvironmentSchemas from "@teardown/schemas/environment";
2
+ import * as IdentifySchemas from "../vendored/schemas/identify";
3
+ export { EnvironmentSchemas, IdentifySchemas };
@@ -1 +1,3 @@
1
- export {};
1
+ import * as EnvironmentSchemas from "@teardown/schemas/environment";
2
+ import * as IdentifySchemas from "../vendored/schemas/identify";
3
+ export { EnvironmentSchemas, IdentifySchemas };
@@ -1,19 +1,6 @@
1
+ import { DevicePlatformEnum } from "../types/generated-consts";
1
2
  import { z } from "zod";
2
- /**
3
- * OS types
4
- */
5
- export declare enum OSType {
6
- IOS = "IOS",
7
- ANDROID = "ANDROID",
8
- WEB = "WEB",
9
- WINDOWS = "WINDOWS",
10
- MACOS = "MACOS",
11
- LINUX = "LINUX"
12
- }
13
- /**
14
- * Device types
15
- */
16
- export type DeviceType = "UNKNOWN" | "PHONE" | "TABLET" | "DESKTOP" | "CONSOLE" | "TV" | "WEARABLE" | "GAME_CONSOLE" | "VR" | "OTHER";
3
+ export { DevicePlatformEnum };
17
4
  /**
18
5
  * Application info schema
19
6
  */
@@ -26,7 +13,7 @@ export type ApplicationInfo = z.infer<typeof ApplicationInfoSchema>;
26
13
  * OS info schema
27
14
  */
28
15
  export declare const OSInfoSchema: z.ZodObject<{
29
- type: z.ZodEnum<typeof OSType>;
16
+ platform: z.ZodEnum<typeof DevicePlatformEnum>;
30
17
  name: z.ZodString;
31
18
  version: z.ZodString;
32
19
  }, z.core.$strip>;
@@ -67,22 +54,35 @@ export declare const UpdateInfoSchema: z.ZodObject<{
67
54
  created_at: z.ZodCoercedDate<unknown>;
68
55
  }, z.core.$strip>;
69
56
  export type UpdateInfo = z.infer<typeof UpdateInfoSchema>;
57
+ export declare enum NotificationPlatform {
58
+ APNS = "APNS",// Apple Push Notification Service
59
+ FCM = "FCM",// Firebase Cloud Messaging
60
+ EXPO = "EXPO"
61
+ }
70
62
  /**
71
63
  * Push notification info schema
72
64
  */
73
65
  export declare const PushNotificationInfoSchema: z.ZodObject<{
74
- token: z.ZodString;
75
- platform: z.ZodEnum<{
76
- APNS: "APNS";
77
- FCM: "FCM";
78
- EXPO: "EXPO";
79
- }>;
66
+ enabled: z.ZodBoolean;
67
+ granted: z.ZodBoolean;
68
+ token: z.ZodNullable<z.ZodString>;
69
+ platform: z.ZodEnum<typeof NotificationPlatform>;
80
70
  }, z.core.$strip>;
81
71
  export type PushNotificationInfo = z.infer<typeof PushNotificationInfoSchema>;
72
+ export declare const NotificationsInfoSchema: z.ZodObject<{
73
+ push: z.ZodObject<{
74
+ enabled: z.ZodBoolean;
75
+ granted: z.ZodBoolean;
76
+ token: z.ZodNullable<z.ZodString>;
77
+ platform: z.ZodEnum<typeof NotificationPlatform>;
78
+ }, z.core.$strip>;
79
+ }, z.core.$strip>;
80
+ export type NotificationsInfo = z.infer<typeof NotificationsInfoSchema>;
82
81
  /**
83
82
  * Device info schema
84
83
  */
85
84
  export declare const DeviceInfoSchema: z.ZodObject<{
85
+ timestamp: z.ZodOptional<z.ZodCoercedDate<unknown>>;
86
86
  application: z.ZodObject<{
87
87
  version: z.ZodString;
88
88
  build_number: z.ZodString;
@@ -108,18 +108,18 @@ export declare const DeviceInfoSchema: z.ZodObject<{
108
108
  device_brand: z.ZodString;
109
109
  }, z.core.$strip>;
110
110
  os: z.ZodObject<{
111
- type: z.ZodEnum<typeof OSType>;
111
+ platform: z.ZodEnum<typeof DevicePlatformEnum>;
112
112
  name: z.ZodString;
113
113
  version: z.ZodString;
114
114
  }, z.core.$strip>;
115
- push_notification: z.ZodOptional<z.ZodObject<{
116
- token: z.ZodString;
117
- platform: z.ZodEnum<{
118
- APNS: "APNS";
119
- FCM: "FCM";
120
- EXPO: "EXPO";
121
- }>;
122
- }, z.core.$strip>>;
115
+ notifications: z.ZodObject<{
116
+ push: z.ZodObject<{
117
+ enabled: z.ZodBoolean;
118
+ granted: z.ZodBoolean;
119
+ token: z.ZodNullable<z.ZodString>;
120
+ platform: z.ZodEnum<typeof NotificationPlatform>;
121
+ }, z.core.$strip>;
122
+ }, z.core.$strip>;
123
123
  }, z.core.$strip>;
124
124
  export type DeviceInfo = z.infer<typeof DeviceInfoSchema>;
125
125
  /**
@@ -138,6 +138,7 @@ export type PersonaInfo = z.infer<typeof PersonaInfoSchema>;
138
138
  */
139
139
  export declare const IdentifyRequestSchema: z.ZodObject<{
140
140
  device: z.ZodObject<{
141
+ timestamp: z.ZodOptional<z.ZodCoercedDate<unknown>>;
141
142
  application: z.ZodObject<{
142
143
  version: z.ZodString;
143
144
  build_number: z.ZodString;
@@ -163,18 +164,18 @@ export declare const IdentifyRequestSchema: z.ZodObject<{
163
164
  device_brand: z.ZodString;
164
165
  }, z.core.$strip>;
165
166
  os: z.ZodObject<{
166
- type: z.ZodEnum<typeof OSType>;
167
+ platform: z.ZodEnum<typeof DevicePlatformEnum>;
167
168
  name: z.ZodString;
168
169
  version: z.ZodString;
169
170
  }, z.core.$strip>;
170
- push_notification: z.ZodOptional<z.ZodObject<{
171
- token: z.ZodString;
172
- platform: z.ZodEnum<{
173
- APNS: "APNS";
174
- FCM: "FCM";
175
- EXPO: "EXPO";
176
- }>;
177
- }, z.core.$strip>>;
171
+ notifications: z.ZodObject<{
172
+ push: z.ZodObject<{
173
+ enabled: z.ZodBoolean;
174
+ granted: z.ZodBoolean;
175
+ token: z.ZodNullable<z.ZodString>;
176
+ platform: z.ZodEnum<typeof NotificationPlatform>;
177
+ }, z.core.$strip>;
178
+ }, z.core.$strip>;
178
179
  }, z.core.$strip>;
179
180
  persona: z.ZodOptional<z.ZodObject<{
180
181
  user_id: z.ZodOptional<z.ZodString>;
@@ -191,13 +192,37 @@ export declare const IdentifyResponseSchema: z.ZodObject<{
191
192
  session_id: z.ZodString;
192
193
  device_id: z.ZodString;
193
194
  persona_id: z.ZodString;
195
+ token: z.ZodString;
194
196
  }, z.core.$strip>;
195
197
  export type IdentifyResponse = z.infer<typeof IdentifyResponseSchema>;
196
198
  export declare const IdentifyErrorResponseSchema: z.ZodObject<{
197
199
  success: z.ZodLiteral<false>;
198
- error: z.ZodObject<{
199
- code: z.ZodString;
200
+ error: z.ZodDiscriminatedUnion<[z.ZodObject<{
201
+ code: z.ZodLiteral<"MISSING_ORG_ID">;
200
202
  message: z.ZodString;
201
- }, z.core.$strip>;
203
+ }, z.core.$strip>, z.ZodObject<{
204
+ code: z.ZodLiteral<"MISSING_PROJECT_ID">;
205
+ message: z.ZodString;
206
+ }, z.core.$strip>, z.ZodObject<{
207
+ code: z.ZodLiteral<"MISSING_ENVIRONMENT_SLUG">;
208
+ message: z.ZodString;
209
+ }, z.core.$strip>, z.ZodObject<{
210
+ code: z.ZodLiteral<"IDENTIFY_FAILED">;
211
+ message: z.ZodString;
212
+ }, z.core.$strip>, z.ZodObject<{
213
+ code: z.ZodLiteral<"NO_SESSION_ID_GENERATED">;
214
+ message: z.ZodString;
215
+ }, z.core.$strip>, z.ZodObject<{
216
+ code: z.ZodLiteral<"NO_DEVICE_ID_GENERATED">;
217
+ message: z.ZodString;
218
+ }, z.core.$strip>, z.ZodObject<{
219
+ code: z.ZodLiteral<"NO_PERSONA_ID_GENERATED">;
220
+ message: z.ZodString;
221
+ }, z.core.$strip>], "code">;
202
222
  }, z.core.$strip>;
203
223
  export type IdentifyErrorResponse = z.infer<typeof IdentifyErrorResponseSchema>;
224
+ export declare const ValidationErrorSchema: z.ZodObject<{
225
+ success: z.ZodLiteral<false>;
226
+ error: z.ZodLiteral<"VALIDATION">;
227
+ message: z.ZodString;
228
+ }, z.core.$strip>;
@@ -0,0 +1,203 @@
1
+ import { DevicePlatformEnum } from "../types/generated-consts";
2
+ import { ValidationError } from "elysia";
3
+ import { z } from "zod";
4
+ export { DevicePlatformEnum };
5
+ /**
6
+ * Application info schema
7
+ */
8
+ export const ApplicationInfoSchema = z.object({
9
+ version: z.string("version is required"),
10
+ build_number: z.string("build_number is required"),
11
+ }, {
12
+ error: "Application info is required",
13
+ });
14
+ /**
15
+ * OS info schema
16
+ */
17
+ export const OSInfoSchema = z.object({
18
+ /**
19
+ * Device platform
20
+ */
21
+ platform: z.enum(DevicePlatformEnum, "platform is required"),
22
+ /**
23
+ * OS name
24
+ */
25
+ name: z.string("name is required"),
26
+ /**
27
+ * OS version
28
+ */
29
+ version: z.string("version is required"),
30
+ }, {
31
+ error: "OS info is required",
32
+ });
33
+ /**
34
+ * Hardware info schema
35
+ */
36
+ export const HardwareInfoSchema = z.object({
37
+ device_name: z.string("device_name is required"),
38
+ device_type: z.string("device_type is required"),
39
+ device_brand: z.string("device_brand is required"),
40
+ }, {
41
+ error: "Hardware info is required",
42
+ });
43
+ export const EmergencyLaunchSchema = z.union([
44
+ z.object({
45
+ is_emergency_launch: z.literal(true),
46
+ reason: z.string("reason is required when is_emergency_launch is true"),
47
+ }),
48
+ z.object({
49
+ is_emergency_launch: z.literal(false),
50
+ reason: z.never().optional(),
51
+ }),
52
+ ], {
53
+ error: "Emergency launch is required",
54
+ });
55
+ /**
56
+ * Update info schema
57
+ */
58
+ export const UpdateInfoSchema = z.object({
59
+ is_enabled: z.boolean(),
60
+ update_id: z.string("update_id is required"),
61
+ update_channel: z.string("update_channel is required"),
62
+ runtime_version: z.string("runtime_version is required"),
63
+ emergency_launch: EmergencyLaunchSchema,
64
+ is_embedded_launch: z.boolean("is_embedded_launch is required"),
65
+ created_at: z.coerce.date(),
66
+ }, {
67
+ error: "Update info is required",
68
+ });
69
+ export var NotificationPlatform;
70
+ (function (NotificationPlatform) {
71
+ NotificationPlatform["APNS"] = "APNS";
72
+ NotificationPlatform["FCM"] = "FCM";
73
+ NotificationPlatform["EXPO"] = "EXPO";
74
+ })(NotificationPlatform || (NotificationPlatform = {}));
75
+ /**
76
+ * Push notification info schema
77
+ */
78
+ export const PushNotificationInfoSchema = z.object({
79
+ enabled: z.boolean("enabled is required"),
80
+ granted: z.boolean("granted is required"),
81
+ token: z.string("token is required").nullable(),
82
+ platform: z.enum(NotificationPlatform, "platform is required"),
83
+ }, {
84
+ error: "Push notification info is required",
85
+ });
86
+ export const NotificationsInfoSchema = z.object({
87
+ push: PushNotificationInfoSchema,
88
+ }, {
89
+ error: "Notifications info is required",
90
+ });
91
+ /**
92
+ * Device info schema
93
+ */
94
+ export const DeviceInfoSchema = z.object({
95
+ /**
96
+ * Timestamp of collection on device (optional, generated server-side if not provided)
97
+ */
98
+ timestamp: z.coerce.date("timestamp is required").optional(),
99
+ /**
100
+ * Application info, required
101
+ */
102
+ application: ApplicationInfoSchema,
103
+ /**
104
+ * Update info (optional) - not all builds will have an update
105
+ */
106
+ update: UpdateInfoSchema.nullable(),
107
+ /**
108
+ * Hardware info, required
109
+ */
110
+ hardware: HardwareInfoSchema,
111
+ /**
112
+ * OS info, required
113
+ */
114
+ os: OSInfoSchema,
115
+ /**
116
+ * Notifications info, required
117
+ */
118
+ notifications: NotificationsInfoSchema,
119
+ }, {
120
+ error: "Device info is required",
121
+ });
122
+ /**
123
+ * Persona info schema (optional fields)
124
+ * Matches personas table structure
125
+ */
126
+ export const PersonaInfoSchema = z.object({
127
+ user_id: z.string("user_id is required").optional(),
128
+ email: z
129
+ .string("email is required")
130
+ .refine((val) => !val || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(val), {
131
+ message: "Invalid email format",
132
+ })
133
+ .optional(),
134
+ name: z.string("name is required").optional(),
135
+ }, {
136
+ error: "Persona info is required",
137
+ });
138
+ /**
139
+ * Identify request schema
140
+ * Ties a device to a persona with optional persona data
141
+ */
142
+ export const IdentifyRequestSchema = z.object({
143
+ device: DeviceInfoSchema,
144
+ persona: PersonaInfoSchema.optional(),
145
+ }, {
146
+ error: "Identify request is required",
147
+ });
148
+ /**
149
+ * Identify response schema
150
+ */
151
+ export const IdentifyResponseSchema = z.object({
152
+ success: z.literal(true),
153
+ session_id: z.string("session_id is required"),
154
+ device_id: z.string("device_id is required"),
155
+ persona_id: z.string("persona_id is required"),
156
+ token: z.string("token is required"), // JWT token for session authentication
157
+ }, {
158
+ error: "Identify response is required",
159
+ });
160
+ export const IdentifyErrorResponseSchema = z.object({
161
+ success: z.literal(false),
162
+ error: z.discriminatedUnion("code", [
163
+ z.object({
164
+ code: z.literal("MISSING_ORG_ID"),
165
+ message: z.string(),
166
+ }),
167
+ z.object({
168
+ code: z.literal("MISSING_PROJECT_ID"),
169
+ message: z.string(),
170
+ }),
171
+ z.object({
172
+ code: z.literal("MISSING_ENVIRONMENT_SLUG"),
173
+ message: z.string(),
174
+ }),
175
+ z.object({
176
+ code: z.literal("IDENTIFY_FAILED"),
177
+ message: z.string(),
178
+ }),
179
+ z.object({
180
+ code: z.literal("NO_SESSION_ID_GENERATED"),
181
+ message: z.string(),
182
+ }),
183
+ z.object({
184
+ code: z.literal("NO_DEVICE_ID_GENERATED"),
185
+ message: z.string(),
186
+ }),
187
+ z.object({
188
+ code: z.literal("NO_PERSONA_ID_GENERATED"),
189
+ message: z.string(),
190
+ }),
191
+ ]),
192
+ }, {
193
+ error: "Identify error response is required",
194
+ });
195
+ export const ValidationErrorSchema = z.object({
196
+ success: z.literal(false),
197
+ error: z.literal("VALIDATION"),
198
+ message: z.string(),
199
+ }, {
200
+ error: "Validation error is required",
201
+ });
202
+ // export type ValidationError = z.infer<typeof ValidationErrorSchema>;
203
+ ValidationError;
@@ -0,0 +1,47 @@
1
+ export declare enum DevicePlatformEnum {
2
+ IOS = "IOS",
3
+ ANDROID = "ANDROID",
4
+ WEB = "WEB",
5
+ WINDOWS = "WINDOWS",
6
+ MACOS = "MACOS",
7
+ LINUX = "LINUX",
8
+ PHONE = "PHONE",
9
+ TABLET = "TABLET",
10
+ DESKTOP = "DESKTOP",
11
+ CONSOLE = "CONSOLE",
12
+ TV = "TV",
13
+ WEARABLE = "WEARABLE",
14
+ GAME_CONSOLE = "GAME_CONSOLE",
15
+ VR = "VR",
16
+ UNKNOWN = "UNKNOWN",
17
+ OTHER = "OTHER"
18
+ }
19
+ export declare enum EnvironmentTypeEnum {
20
+ DEVELOPMENT = "DEVELOPMENT",
21
+ STAGING = "STAGING",
22
+ PRODUCTION = "PRODUCTION"
23
+ }
24
+ export declare enum OrgRoleTypeEnum {
25
+ OWNER = "OWNER",
26
+ ADMIN = "ADMIN",
27
+ ENGINEER = "ENGINEER"
28
+ }
29
+ export declare enum OrgTypeEnum {
30
+ PERSONAL = "PERSONAL",
31
+ START_UP = "START_UP",
32
+ SCALE_UP = "SCALE_UP",
33
+ AGENCY = "AGENCY",
34
+ ENTERPRISE = "ENTERPRISE"
35
+ }
36
+ export declare enum ProjectApiKeyKindEnum {
37
+ publishable = "publishable",
38
+ secret = "secret"
39
+ }
40
+ export declare enum ProjectTypeEnum {
41
+ REACT_NATIVE = "REACT_NATIVE",
42
+ EXPO = "EXPO"
43
+ }
44
+ export declare enum VersionStatusEnum {
45
+ LIVE = "LIVE",
46
+ DISABLED = "DISABLED"
47
+ }
@@ -0,0 +1,54 @@
1
+ export var DevicePlatformEnum;
2
+ (function (DevicePlatformEnum) {
3
+ DevicePlatformEnum["IOS"] = "IOS";
4
+ DevicePlatformEnum["ANDROID"] = "ANDROID";
5
+ DevicePlatformEnum["WEB"] = "WEB";
6
+ DevicePlatformEnum["WINDOWS"] = "WINDOWS";
7
+ DevicePlatformEnum["MACOS"] = "MACOS";
8
+ DevicePlatformEnum["LINUX"] = "LINUX";
9
+ DevicePlatformEnum["PHONE"] = "PHONE";
10
+ DevicePlatformEnum["TABLET"] = "TABLET";
11
+ DevicePlatformEnum["DESKTOP"] = "DESKTOP";
12
+ DevicePlatformEnum["CONSOLE"] = "CONSOLE";
13
+ DevicePlatformEnum["TV"] = "TV";
14
+ DevicePlatformEnum["WEARABLE"] = "WEARABLE";
15
+ DevicePlatformEnum["GAME_CONSOLE"] = "GAME_CONSOLE";
16
+ DevicePlatformEnum["VR"] = "VR";
17
+ DevicePlatformEnum["UNKNOWN"] = "UNKNOWN";
18
+ DevicePlatformEnum["OTHER"] = "OTHER";
19
+ })(DevicePlatformEnum || (DevicePlatformEnum = {}));
20
+ export var EnvironmentTypeEnum;
21
+ (function (EnvironmentTypeEnum) {
22
+ EnvironmentTypeEnum["DEVELOPMENT"] = "DEVELOPMENT";
23
+ EnvironmentTypeEnum["STAGING"] = "STAGING";
24
+ EnvironmentTypeEnum["PRODUCTION"] = "PRODUCTION";
25
+ })(EnvironmentTypeEnum || (EnvironmentTypeEnum = {}));
26
+ export var OrgRoleTypeEnum;
27
+ (function (OrgRoleTypeEnum) {
28
+ OrgRoleTypeEnum["OWNER"] = "OWNER";
29
+ OrgRoleTypeEnum["ADMIN"] = "ADMIN";
30
+ OrgRoleTypeEnum["ENGINEER"] = "ENGINEER";
31
+ })(OrgRoleTypeEnum || (OrgRoleTypeEnum = {}));
32
+ export var OrgTypeEnum;
33
+ (function (OrgTypeEnum) {
34
+ OrgTypeEnum["PERSONAL"] = "PERSONAL";
35
+ OrgTypeEnum["START_UP"] = "START_UP";
36
+ OrgTypeEnum["SCALE_UP"] = "SCALE_UP";
37
+ OrgTypeEnum["AGENCY"] = "AGENCY";
38
+ OrgTypeEnum["ENTERPRISE"] = "ENTERPRISE";
39
+ })(OrgTypeEnum || (OrgTypeEnum = {}));
40
+ export var ProjectApiKeyKindEnum;
41
+ (function (ProjectApiKeyKindEnum) {
42
+ ProjectApiKeyKindEnum["publishable"] = "publishable";
43
+ ProjectApiKeyKindEnum["secret"] = "secret";
44
+ })(ProjectApiKeyKindEnum || (ProjectApiKeyKindEnum = {}));
45
+ export var ProjectTypeEnum;
46
+ (function (ProjectTypeEnum) {
47
+ ProjectTypeEnum["REACT_NATIVE"] = "REACT_NATIVE";
48
+ ProjectTypeEnum["EXPO"] = "EXPO";
49
+ })(ProjectTypeEnum || (ProjectTypeEnum = {}));
50
+ export var VersionStatusEnum;
51
+ (function (VersionStatusEnum) {
52
+ VersionStatusEnum["LIVE"] = "LIVE";
53
+ VersionStatusEnum["DISABLED"] = "DISABLED";
54
+ })(VersionStatusEnum || (VersionStatusEnum = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teardown/ingest-api",
3
- "version": "0.0.20",
3
+ "version": "0.0.21-alpha.10",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -24,29 +24,33 @@
24
24
  },
25
25
  "./types": {
26
26
  "types": "./dist/types/index.d.ts"
27
+ },
28
+ "./vendored/consts": {
29
+ "types": "./dist/vendored/types/generated-consts.d.ts",
30
+ "import": "./dist/vendored/types/generated-consts.js",
31
+ "default": "./dist/vendored/types/generated-consts.js"
27
32
  }
28
33
  },
29
34
  "scripts": {
30
- "sync:schemas": "bun run scripts/sync-schemas.ts",
31
- "postinstall": "bun run sync:schemas",
32
- "build": "tsc --project ./tsconfig.lib.json",
33
- "predev": "bun run sync:schemas",
34
- "dev": "rm -rf dist; bun x tsc --watch --project ./tsconfig.lib.json",
35
- "check:types": "tsc --noEmit --project ./tsconfig.lib.json",
36
- "prepublishOnly": "bun run sync:schemas && bun run build"
35
+ "copy:schemas": "bun run scripts/copy-schemas.ts",
36
+ "prebuild": "bun run copy:schemas",
37
+ "build": "bun x tsc --project ./tsconfig.lib.json",
38
+ "dev": "bun x tsc --watch --project ./tsconfig.lib.json",
39
+ "check:types": "bun x tsc --noEmit --project ./tsconfig.lib.json",
40
+ "prepublishOnly": "bun x turbo run build"
37
41
  },
38
42
  "dependencies": {
39
- "@elysiajs/eden": "^1.4.4",
40
- "elysia": "^1.4.13"
43
+ "@elysiajs/eden": "1.4.5"
41
44
  },
42
45
  "peerDependencies": {
43
- "typescript": "^5",
44
- "zod": "^4"
46
+ "typescript": "^5.9.3",
47
+ "zod": "^4",
48
+ "elysia": ">= 1.4.0"
45
49
  },
46
50
  "devDependencies": {
47
- "@types/bun": "latest",
51
+ "@types/bun": "1.3.3",
48
52
  "@teardown/ingest": "0.0.1",
49
53
  "@teardown/tsconfig": "1.0.0",
50
- "@teardown/types": "0.0.1"
54
+ "elysia": "1.4.0"
51
55
  }
52
56
  }
@@ -1,131 +0,0 @@
1
- import { z } from "zod";
2
- /**
3
- * OS types
4
- */
5
- export var OSType;
6
- (function (OSType) {
7
- OSType["IOS"] = "IOS";
8
- OSType["ANDROID"] = "ANDROID";
9
- OSType["WEB"] = "WEB";
10
- OSType["WINDOWS"] = "WINDOWS";
11
- OSType["MACOS"] = "MACOS";
12
- OSType["LINUX"] = "LINUX";
13
- })(OSType || (OSType = {}));
14
- /**
15
- * Application info schema
16
- */
17
- export const ApplicationInfoSchema = z.object({
18
- version: z.string(),
19
- build_number: z.string(),
20
- });
21
- /**
22
- * OS info schema
23
- */
24
- export const OSInfoSchema = z.object({
25
- /**
26
- * OS type
27
- */
28
- type: z.enum(OSType),
29
- name: z.string(),
30
- version: z.string(),
31
- });
32
- /**
33
- * Hardware info schema
34
- */
35
- export const HardwareInfoSchema = z.object({
36
- device_name: z.string(),
37
- device_type: z.string(),
38
- device_brand: z.string(),
39
- });
40
- export const EmergencyLaunchSchema = z.union([
41
- z.object({
42
- is_emergency_launch: z.literal(true),
43
- reason: z.string(),
44
- }),
45
- z.object({
46
- is_emergency_launch: z.literal(false),
47
- reason: z.never().optional(),
48
- }),
49
- ]);
50
- /**
51
- * Update info schema
52
- */
53
- export const UpdateInfoSchema = z.object({
54
- is_enabled: z.boolean(),
55
- update_id: z.string(),
56
- update_channel: z.string(),
57
- runtime_version: z.string(),
58
- emergency_launch: EmergencyLaunchSchema,
59
- is_embedded_launch: z.boolean(),
60
- created_at: z.coerce.date(),
61
- });
62
- /**
63
- * Push notification info schema
64
- */
65
- export const PushNotificationInfoSchema = z.object({
66
- token: z.string(),
67
- platform: z.enum(["APNS", "FCM", "EXPO"]),
68
- });
69
- /**
70
- * Device info schema
71
- */
72
- export const DeviceInfoSchema = z.object({
73
- /**
74
- * Application info, required
75
- */
76
- application: ApplicationInfoSchema,
77
- /**
78
- * Update info (optional) - not all builds will have an update
79
- */
80
- update: UpdateInfoSchema.nullable(),
81
- /**
82
- * Hardware info, required
83
- */
84
- hardware: HardwareInfoSchema,
85
- /**
86
- * OS info, required
87
- */
88
- os: OSInfoSchema,
89
- /**
90
- * Push notification info, optional
91
- */
92
- push_notification: PushNotificationInfoSchema.optional(),
93
- });
94
- /**
95
- * Persona info schema (optional fields)
96
- * Matches personas table structure
97
- */
98
- export const PersonaInfoSchema = z.object({
99
- user_id: z.string().optional(),
100
- email: z
101
- .string()
102
- .refine((val) => !val || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(val), {
103
- message: "Invalid email format",
104
- })
105
- .optional(),
106
- name: z.string().optional(),
107
- });
108
- /**
109
- * Identify request schema
110
- * Ties a device to a persona with optional persona data
111
- */
112
- export const IdentifyRequestSchema = z.object({
113
- device: DeviceInfoSchema,
114
- persona: PersonaInfoSchema.optional(),
115
- });
116
- /**
117
- * Identify response schema
118
- */
119
- export const IdentifyResponseSchema = z.object({
120
- success: z.literal(true),
121
- session_id: z.string(),
122
- device_id: z.string(),
123
- persona_id: z.string(),
124
- });
125
- export const IdentifyErrorResponseSchema = z.object({
126
- success: z.literal(false),
127
- error: z.object({
128
- code: z.string(),
129
- message: z.string(),
130
- }),
131
- });
@@ -1,9 +0,0 @@
1
- import type { Elysia } from "elysia";
2
- /**
3
- * Type placeholder for IngestApp
4
- * This should match the type from @teardown/ingest but is defined here
5
- * to avoid runtime dependency on the private package
6
- *
7
- * When developing locally, you can override this with the actual type from @teardown/ingest
8
- */
9
- export type IngestApp = Elysia<any>;
package/dist/types/app.js DELETED
@@ -1 +0,0 @@
1
- export {};