@teardown/ingest-api 0.0.21-alpha.3 → 0.0.21-alpha.4

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 +1 @@
1
- export * from "@teardown/schemas/identify";
1
+ export * from "../vendored/schemas/identify";
@@ -1 +1 @@
1
- export * from "@teardown/schemas/identify";
1
+ export * from "../vendored/schemas/identify";
@@ -1,2 +1,2 @@
1
1
  export type * from "@teardown/schemas/environment";
2
- export type * from "@teardown/schemas/identify";
2
+ export type * from "../vendored/schemas/identify";
@@ -0,0 +1,222 @@
1
+ import { DevicePlatformEnum } from "../types/generated-consts";
2
+ import { z } from "zod";
3
+ /**
4
+ * Application info schema
5
+ */
6
+ export declare const ApplicationInfoSchema: z.ZodObject<{
7
+ version: z.ZodString;
8
+ build_number: z.ZodString;
9
+ }, z.core.$strip>;
10
+ export type ApplicationInfo = z.infer<typeof ApplicationInfoSchema>;
11
+ /**
12
+ * OS info schema
13
+ */
14
+ export declare const OSInfoSchema: z.ZodObject<{
15
+ platform: z.ZodEnum<typeof DevicePlatformEnum>;
16
+ name: z.ZodString;
17
+ version: z.ZodString;
18
+ }, z.core.$strip>;
19
+ export type OSInfo = z.infer<typeof OSInfoSchema>;
20
+ /**
21
+ * Hardware info schema
22
+ */
23
+ export declare const HardwareInfoSchema: z.ZodObject<{
24
+ device_name: z.ZodString;
25
+ device_type: z.ZodString;
26
+ device_brand: z.ZodString;
27
+ }, z.core.$strip>;
28
+ export type HardwareInfo = z.infer<typeof HardwareInfoSchema>;
29
+ export declare const EmergencyLaunchSchema: z.ZodUnion<readonly [z.ZodObject<{
30
+ is_emergency_launch: z.ZodLiteral<true>;
31
+ reason: z.ZodString;
32
+ }, z.core.$strip>, z.ZodObject<{
33
+ is_emergency_launch: z.ZodLiteral<false>;
34
+ reason: z.ZodOptional<z.ZodNever>;
35
+ }, z.core.$strip>]>;
36
+ export type EmergencyLaunch = z.infer<typeof EmergencyLaunchSchema>;
37
+ /**
38
+ * Update info schema
39
+ */
40
+ export declare const UpdateInfoSchema: z.ZodObject<{
41
+ is_enabled: z.ZodBoolean;
42
+ update_id: z.ZodString;
43
+ update_channel: z.ZodString;
44
+ runtime_version: z.ZodString;
45
+ emergency_launch: z.ZodUnion<readonly [z.ZodObject<{
46
+ is_emergency_launch: z.ZodLiteral<true>;
47
+ reason: z.ZodString;
48
+ }, z.core.$strip>, z.ZodObject<{
49
+ is_emergency_launch: z.ZodLiteral<false>;
50
+ reason: z.ZodOptional<z.ZodNever>;
51
+ }, z.core.$strip>]>;
52
+ is_embedded_launch: z.ZodBoolean;
53
+ created_at: z.ZodCoercedDate<unknown>;
54
+ }, z.core.$strip>;
55
+ export type UpdateInfo = z.infer<typeof UpdateInfoSchema>;
56
+ export declare enum NotificationPlatform {
57
+ APNS = "APNS",// Apple Push Notification Service
58
+ FCM = "FCM",// Firebase Cloud Messaging
59
+ EXPO = "EXPO"
60
+ }
61
+ /**
62
+ * Push notification info schema
63
+ */
64
+ export declare const PushNotificationInfoSchema: z.ZodObject<{
65
+ enabled: z.ZodBoolean;
66
+ granted: z.ZodBoolean;
67
+ token: z.ZodNullable<z.ZodString>;
68
+ platform: z.ZodEnum<typeof NotificationPlatform>;
69
+ }, z.core.$strip>;
70
+ export type PushNotificationInfo = z.infer<typeof PushNotificationInfoSchema>;
71
+ export declare const NotificationsInfoSchema: z.ZodObject<{
72
+ push: z.ZodObject<{
73
+ enabled: z.ZodBoolean;
74
+ granted: z.ZodBoolean;
75
+ token: z.ZodNullable<z.ZodString>;
76
+ platform: z.ZodEnum<typeof NotificationPlatform>;
77
+ }, z.core.$strip>;
78
+ }, z.core.$strip>;
79
+ export type NotificationsInfo = z.infer<typeof NotificationsInfoSchema>;
80
+ /**
81
+ * Device info schema
82
+ */
83
+ export declare const DeviceInfoSchema: z.ZodObject<{
84
+ timestamp: z.ZodOptional<z.ZodCoercedDate<unknown>>;
85
+ application: z.ZodObject<{
86
+ version: z.ZodString;
87
+ build_number: z.ZodString;
88
+ }, z.core.$strip>;
89
+ update: z.ZodNullable<z.ZodObject<{
90
+ is_enabled: z.ZodBoolean;
91
+ update_id: z.ZodString;
92
+ update_channel: z.ZodString;
93
+ runtime_version: z.ZodString;
94
+ emergency_launch: z.ZodUnion<readonly [z.ZodObject<{
95
+ is_emergency_launch: z.ZodLiteral<true>;
96
+ reason: z.ZodString;
97
+ }, z.core.$strip>, z.ZodObject<{
98
+ is_emergency_launch: z.ZodLiteral<false>;
99
+ reason: z.ZodOptional<z.ZodNever>;
100
+ }, z.core.$strip>]>;
101
+ is_embedded_launch: z.ZodBoolean;
102
+ created_at: z.ZodCoercedDate<unknown>;
103
+ }, z.core.$strip>>;
104
+ hardware: z.ZodObject<{
105
+ device_name: z.ZodString;
106
+ device_type: z.ZodString;
107
+ device_brand: z.ZodString;
108
+ }, z.core.$strip>;
109
+ os: z.ZodObject<{
110
+ platform: z.ZodEnum<typeof DevicePlatformEnum>;
111
+ name: z.ZodString;
112
+ version: z.ZodString;
113
+ }, z.core.$strip>;
114
+ notifications: z.ZodObject<{
115
+ push: z.ZodObject<{
116
+ enabled: z.ZodBoolean;
117
+ granted: z.ZodBoolean;
118
+ token: z.ZodNullable<z.ZodString>;
119
+ platform: z.ZodEnum<typeof NotificationPlatform>;
120
+ }, z.core.$strip>;
121
+ }, z.core.$strip>;
122
+ }, z.core.$strip>;
123
+ export type DeviceInfo = z.infer<typeof DeviceInfoSchema>;
124
+ /**
125
+ * Persona info schema (optional fields)
126
+ * Matches personas table structure
127
+ */
128
+ export declare const PersonaInfoSchema: z.ZodObject<{
129
+ user_id: z.ZodOptional<z.ZodString>;
130
+ email: z.ZodOptional<z.ZodString>;
131
+ name: z.ZodOptional<z.ZodString>;
132
+ }, z.core.$strip>;
133
+ export type PersonaInfo = z.infer<typeof PersonaInfoSchema>;
134
+ /**
135
+ * Identify request schema
136
+ * Ties a device to a persona with optional persona data
137
+ */
138
+ export declare const IdentifyRequestSchema: z.ZodObject<{
139
+ device: z.ZodObject<{
140
+ timestamp: z.ZodOptional<z.ZodCoercedDate<unknown>>;
141
+ application: z.ZodObject<{
142
+ version: z.ZodString;
143
+ build_number: z.ZodString;
144
+ }, z.core.$strip>;
145
+ update: z.ZodNullable<z.ZodObject<{
146
+ is_enabled: z.ZodBoolean;
147
+ update_id: z.ZodString;
148
+ update_channel: z.ZodString;
149
+ runtime_version: z.ZodString;
150
+ emergency_launch: z.ZodUnion<readonly [z.ZodObject<{
151
+ is_emergency_launch: z.ZodLiteral<true>;
152
+ reason: z.ZodString;
153
+ }, z.core.$strip>, z.ZodObject<{
154
+ is_emergency_launch: z.ZodLiteral<false>;
155
+ reason: z.ZodOptional<z.ZodNever>;
156
+ }, z.core.$strip>]>;
157
+ is_embedded_launch: z.ZodBoolean;
158
+ created_at: z.ZodCoercedDate<unknown>;
159
+ }, z.core.$strip>>;
160
+ hardware: z.ZodObject<{
161
+ device_name: z.ZodString;
162
+ device_type: z.ZodString;
163
+ device_brand: z.ZodString;
164
+ }, z.core.$strip>;
165
+ os: z.ZodObject<{
166
+ platform: z.ZodEnum<typeof DevicePlatformEnum>;
167
+ name: z.ZodString;
168
+ version: z.ZodString;
169
+ }, z.core.$strip>;
170
+ notifications: z.ZodObject<{
171
+ push: z.ZodObject<{
172
+ enabled: z.ZodBoolean;
173
+ granted: z.ZodBoolean;
174
+ token: z.ZodNullable<z.ZodString>;
175
+ platform: z.ZodEnum<typeof NotificationPlatform>;
176
+ }, z.core.$strip>;
177
+ }, z.core.$strip>;
178
+ }, z.core.$strip>;
179
+ persona: z.ZodOptional<z.ZodObject<{
180
+ user_id: z.ZodOptional<z.ZodString>;
181
+ email: z.ZodOptional<z.ZodString>;
182
+ name: z.ZodOptional<z.ZodString>;
183
+ }, z.core.$strip>>;
184
+ }, z.core.$strip>;
185
+ export type IdentifyRequest = z.infer<typeof IdentifyRequestSchema>;
186
+ /**
187
+ * Identify response schema
188
+ */
189
+ export declare const IdentifyResponseSchema: z.ZodObject<{
190
+ success: z.ZodLiteral<true>;
191
+ session_id: z.ZodString;
192
+ device_id: z.ZodString;
193
+ persona_id: z.ZodString;
194
+ token: z.ZodString;
195
+ }, z.core.$strip>;
196
+ export type IdentifyResponse = z.infer<typeof IdentifyResponseSchema>;
197
+ export declare const IdentifyErrorResponseSchema: z.ZodObject<{
198
+ success: z.ZodLiteral<false>;
199
+ error: z.ZodDiscriminatedUnion<[z.ZodObject<{
200
+ code: z.ZodLiteral<"MISSING_ORG_ID">;
201
+ message: z.ZodString;
202
+ }, z.core.$strip>, z.ZodObject<{
203
+ code: z.ZodLiteral<"MISSING_PROJECT_ID">;
204
+ message: z.ZodString;
205
+ }, z.core.$strip>, z.ZodObject<{
206
+ code: z.ZodLiteral<"MISSING_ENVIRONMENT_SLUG">;
207
+ message: z.ZodString;
208
+ }, z.core.$strip>, z.ZodObject<{
209
+ code: z.ZodLiteral<"IDENTIFY_FAILED">;
210
+ message: z.ZodString;
211
+ }, z.core.$strip>, z.ZodObject<{
212
+ code: z.ZodLiteral<"NO_SESSION_ID_GENERATED">;
213
+ message: z.ZodString;
214
+ }, z.core.$strip>, z.ZodObject<{
215
+ code: z.ZodLiteral<"NO_DEVICE_ID_GENERATED">;
216
+ message: z.ZodString;
217
+ }, z.core.$strip>, z.ZodObject<{
218
+ code: z.ZodLiteral<"NO_PERSONA_ID_GENERATED">;
219
+ message: z.ZodString;
220
+ }, z.core.$strip>], "code">;
221
+ }, z.core.$strip>;
222
+ export type IdentifyErrorResponse = z.infer<typeof IdentifyErrorResponseSchema>;
@@ -0,0 +1,168 @@
1
+ import { DevicePlatformEnum } from "../types/generated-consts";
2
+ import { z } from "zod";
3
+ /**
4
+ * Application info schema
5
+ */
6
+ export const ApplicationInfoSchema = z.object({
7
+ version: z.string(),
8
+ build_number: z.string(),
9
+ });
10
+ /**
11
+ * OS info schema
12
+ */
13
+ export const OSInfoSchema = z.object({
14
+ /**
15
+ * Device platform
16
+ */
17
+ platform: z.enum(DevicePlatformEnum),
18
+ /**
19
+ * OS name
20
+ */
21
+ name: z.string(),
22
+ /**
23
+ * OS version
24
+ */
25
+ version: z.string(),
26
+ });
27
+ /**
28
+ * Hardware info schema
29
+ */
30
+ export const HardwareInfoSchema = z.object({
31
+ device_name: z.string(),
32
+ device_type: z.string(),
33
+ device_brand: z.string(),
34
+ });
35
+ export const EmergencyLaunchSchema = z.union([
36
+ z.object({
37
+ is_emergency_launch: z.literal(true),
38
+ reason: z.string(),
39
+ }),
40
+ z.object({
41
+ is_emergency_launch: z.literal(false),
42
+ reason: z.never().optional(),
43
+ }),
44
+ ]);
45
+ /**
46
+ * Update info schema
47
+ */
48
+ export const UpdateInfoSchema = z.object({
49
+ is_enabled: z.boolean(),
50
+ update_id: z.string(),
51
+ update_channel: z.string(),
52
+ runtime_version: z.string(),
53
+ emergency_launch: EmergencyLaunchSchema,
54
+ is_embedded_launch: z.boolean(),
55
+ created_at: z.coerce.date(),
56
+ });
57
+ export var NotificationPlatform;
58
+ (function (NotificationPlatform) {
59
+ NotificationPlatform["APNS"] = "APNS";
60
+ NotificationPlatform["FCM"] = "FCM";
61
+ NotificationPlatform["EXPO"] = "EXPO";
62
+ })(NotificationPlatform || (NotificationPlatform = {}));
63
+ /**
64
+ * Push notification info schema
65
+ */
66
+ export const PushNotificationInfoSchema = z.object({
67
+ enabled: z.boolean(),
68
+ granted: z.boolean(),
69
+ token: z.string().nullable(),
70
+ platform: z.enum(NotificationPlatform),
71
+ });
72
+ export const NotificationsInfoSchema = z.object({
73
+ push: PushNotificationInfoSchema,
74
+ });
75
+ /**
76
+ * Device info schema
77
+ */
78
+ export const DeviceInfoSchema = z.object({
79
+ /**
80
+ * Timestamp of collection on device (optional, generated server-side if not provided)
81
+ */
82
+ timestamp: z.coerce.date().optional(),
83
+ /**
84
+ * Application info, required
85
+ */
86
+ application: ApplicationInfoSchema,
87
+ /**
88
+ * Update info (optional) - not all builds will have an update
89
+ */
90
+ update: UpdateInfoSchema.nullable(),
91
+ /**
92
+ * Hardware info, required
93
+ */
94
+ hardware: HardwareInfoSchema,
95
+ /**
96
+ * OS info, required
97
+ */
98
+ os: OSInfoSchema,
99
+ /**
100
+ * Notifications info, required
101
+ */
102
+ notifications: NotificationsInfoSchema,
103
+ });
104
+ /**
105
+ * Persona info schema (optional fields)
106
+ * Matches personas table structure
107
+ */
108
+ export const PersonaInfoSchema = z.object({
109
+ user_id: z.string().optional(),
110
+ email: z
111
+ .string()
112
+ .refine((val) => !val || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(val), {
113
+ message: "Invalid email format",
114
+ })
115
+ .optional(),
116
+ name: z.string().optional(),
117
+ });
118
+ /**
119
+ * Identify request schema
120
+ * Ties a device to a persona with optional persona data
121
+ */
122
+ export const IdentifyRequestSchema = z.object({
123
+ device: DeviceInfoSchema,
124
+ persona: PersonaInfoSchema.optional(),
125
+ });
126
+ /**
127
+ * Identify response schema
128
+ */
129
+ export const IdentifyResponseSchema = z.object({
130
+ success: z.literal(true),
131
+ session_id: z.string(),
132
+ device_id: z.string(),
133
+ persona_id: z.string(),
134
+ token: z.string(), // JWT token for session authentication
135
+ });
136
+ export const IdentifyErrorResponseSchema = z.object({
137
+ success: z.literal(false),
138
+ error: z.discriminatedUnion("code", [
139
+ z.object({
140
+ code: z.literal("MISSING_ORG_ID"),
141
+ message: z.string(),
142
+ }),
143
+ z.object({
144
+ code: z.literal("MISSING_PROJECT_ID"),
145
+ message: z.string(),
146
+ }),
147
+ z.object({
148
+ code: z.literal("MISSING_ENVIRONMENT_SLUG"),
149
+ message: z.string(),
150
+ }),
151
+ z.object({
152
+ code: z.literal("IDENTIFY_FAILED"),
153
+ message: z.string(),
154
+ }),
155
+ z.object({
156
+ code: z.literal("NO_SESSION_ID_GENERATED"),
157
+ message: z.string(),
158
+ }),
159
+ z.object({
160
+ code: z.literal("NO_DEVICE_ID_GENERATED"),
161
+ message: z.string(),
162
+ }),
163
+ z.object({
164
+ code: z.literal("NO_PERSONA_ID_GENERATED"),
165
+ message: z.string(),
166
+ }),
167
+ ]),
168
+ });
@@ -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.21-alpha.3",
3
+ "version": "0.0.21-alpha.4",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -27,14 +27,15 @@
27
27
  }
28
28
  },
29
29
  "scripts": {
30
+ "copy:schemas": "bun run scripts/copy-schemas.ts",
31
+ "prebuild": "bun run copy:schemas",
30
32
  "build": "bun x tsc --project ./tsconfig.lib.json",
31
33
  "dev": "bun x tsc --watch --project ./tsconfig.lib.json",
32
34
  "check:types": "bun x tsc --noEmit --project ./tsconfig.lib.json",
33
35
  "prepublishOnly": "bun run build"
34
36
  },
35
37
  "dependencies": {
36
- "@elysiajs/eden": "1.4.4",
37
- "@teardown/schemas": "0.1.0"
38
+ "@elysiajs/eden": "1.4.4"
38
39
  },
39
40
  "peerDependencies": {
40
41
  "typescript": "^5.9.3",
@@ -45,7 +46,6 @@
45
46
  "@types/bun": "1.1.14",
46
47
  "@teardown/ingest": "0.0.1",
47
48
  "@teardown/tsconfig": "1.0.0",
48
- "@teardown/types": "0.0.2",
49
49
  "elysia": "1.4.0"
50
50
  }
51
51
  }