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

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,7 +1,156 @@
1
1
  import { edenFetch } from "@elysiajs/eden";
2
- import type { IngestApp } from "../types/app";
2
+ import type { IngestApp } from "@teardown/ingest/types";
3
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>;
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
+ error: string;
14
+ message: string;
15
+ status: number;
16
+ } | {
17
+ error: string;
18
+ status: number;
19
+ message?: undefined;
20
+ } | {
21
+ status: string;
22
+ timestamp: string;
23
+ };
24
+ };
25
+ };
26
+ };
27
+ } & { "": {
28
+ "/v1/identify": {
29
+ post: {
30
+ body: {
31
+ device: {
32
+ application: {
33
+ version: string;
34
+ build_number: string;
35
+ };
36
+ update: {
37
+ is_enabled: boolean;
38
+ update_id: string;
39
+ update_channel: string;
40
+ runtime_version: string;
41
+ emergency_launch: {
42
+ is_emergency_launch: true;
43
+ reason: string;
44
+ } | {
45
+ is_emergency_launch: false;
46
+ reason?: undefined;
47
+ };
48
+ is_embedded_launch: boolean;
49
+ created_at: Date;
50
+ } | null;
51
+ hardware: {
52
+ device_name: string;
53
+ device_type: string;
54
+ device_brand: string;
55
+ };
56
+ os: {
57
+ platform: import("@teardown/types").DevicePlatformEnum;
58
+ name: string;
59
+ version: string;
60
+ };
61
+ notifications: {
62
+ push: {
63
+ enabled: boolean;
64
+ granted: boolean;
65
+ token: string | null;
66
+ platform: import("@teardown/schemas/identify").NotificationPlatform;
67
+ };
68
+ };
69
+ timestamp?: Date | undefined;
70
+ };
71
+ persona?: {
72
+ user_id?: string | undefined;
73
+ email?: string | undefined;
74
+ name?: string | undefined;
75
+ } | undefined;
76
+ };
77
+ params: {};
78
+ query: unknown;
79
+ headers: {
80
+ "td-org-id": string;
81
+ "td-project-id": string;
82
+ "td-environment-slug": string;
83
+ authorization?: string | undefined;
84
+ };
85
+ response: {
86
+ 200: {
87
+ success: true;
88
+ session_id: string;
89
+ device_id: string;
90
+ persona_id: string;
91
+ token: string;
92
+ };
93
+ 400: {
94
+ success: false;
95
+ error: {
96
+ code: "MISSING_ORG_ID";
97
+ message: string;
98
+ } | {
99
+ code: "MISSING_PROJECT_ID";
100
+ message: string;
101
+ } | {
102
+ code: "MISSING_ENVIRONMENT_SLUG";
103
+ message: string;
104
+ } | {
105
+ code: "IDENTIFY_FAILED";
106
+ message: string;
107
+ } | {
108
+ code: "NO_SESSION_ID_GENERATED";
109
+ message: string;
110
+ } | {
111
+ code: "NO_DEVICE_ID_GENERATED";
112
+ message: string;
113
+ } | {
114
+ code: "NO_PERSONA_ID_GENERATED";
115
+ message: string;
116
+ };
117
+ };
118
+ 422: {
119
+ type: "validation";
120
+ on: string;
121
+ summary?: string;
122
+ message?: string;
123
+ found?: unknown;
124
+ property?: string;
125
+ expected?: string;
126
+ };
127
+ };
128
+ };
129
+ };
130
+ } & {
131
+ "": {
132
+ get: {
133
+ body: unknown;
134
+ params: {};
135
+ query: unknown;
136
+ headers: unknown;
137
+ response: {
138
+ 200: {
139
+ error: string;
140
+ message: string;
141
+ status: number;
142
+ } | {
143
+ error: string;
144
+ status: number;
145
+ message?: undefined;
146
+ } | {
147
+ message: string;
148
+ version: string;
149
+ };
150
+ };
151
+ };
152
+ };
153
+ }>;
5
154
  export type Client = ReturnType<typeof client>;
6
155
  export type RequestOptions = Omit<NonNullable<Parameters<Client>[1]>, "headers"> & {
7
156
  headers?: Record<string, string>;
@@ -1,19 +1,5 @@
1
+ import { DevicePlatformEnum } from "@teardown/types";
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";
17
3
  /**
18
4
  * Application info schema
19
5
  */
@@ -26,7 +12,7 @@ export type ApplicationInfo = z.infer<typeof ApplicationInfoSchema>;
26
12
  * OS info schema
27
13
  */
28
14
  export declare const OSInfoSchema: z.ZodObject<{
29
- type: z.ZodEnum<typeof OSType>;
15
+ platform: z.ZodEnum<typeof DevicePlatformEnum>;
30
16
  name: z.ZodString;
31
17
  version: z.ZodString;
32
18
  }, z.core.$strip>;
@@ -67,10 +53,35 @@ export declare const UpdateInfoSchema: z.ZodObject<{
67
53
  created_at: z.ZodCoercedDate<unknown>;
68
54
  }, z.core.$strip>;
69
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>;
70
80
  /**
71
81
  * Device info schema
72
82
  */
73
83
  export declare const DeviceInfoSchema: z.ZodObject<{
84
+ timestamp: z.ZodOptional<z.ZodCoercedDate<unknown>>;
74
85
  application: z.ZodObject<{
75
86
  version: z.ZodString;
76
87
  build_number: z.ZodString;
@@ -96,10 +107,18 @@ export declare const DeviceInfoSchema: z.ZodObject<{
96
107
  device_brand: z.ZodString;
97
108
  }, z.core.$strip>;
98
109
  os: z.ZodObject<{
99
- type: z.ZodEnum<typeof OSType>;
110
+ platform: z.ZodEnum<typeof DevicePlatformEnum>;
100
111
  name: z.ZodString;
101
112
  version: z.ZodString;
102
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>;
103
122
  }, z.core.$strip>;
104
123
  export type DeviceInfo = z.infer<typeof DeviceInfoSchema>;
105
124
  /**
@@ -118,6 +137,7 @@ export type PersonaInfo = z.infer<typeof PersonaInfoSchema>;
118
137
  */
119
138
  export declare const IdentifyRequestSchema: z.ZodObject<{
120
139
  device: z.ZodObject<{
140
+ timestamp: z.ZodOptional<z.ZodCoercedDate<unknown>>;
121
141
  application: z.ZodObject<{
122
142
  version: z.ZodString;
123
143
  build_number: z.ZodString;
@@ -143,10 +163,18 @@ export declare const IdentifyRequestSchema: z.ZodObject<{
143
163
  device_brand: z.ZodString;
144
164
  }, z.core.$strip>;
145
165
  os: z.ZodObject<{
146
- type: z.ZodEnum<typeof OSType>;
166
+ platform: z.ZodEnum<typeof DevicePlatformEnum>;
147
167
  name: z.ZodString;
148
168
  version: z.ZodString;
149
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>;
150
178
  }, z.core.$strip>;
151
179
  persona: z.ZodOptional<z.ZodObject<{
152
180
  user_id: z.ZodOptional<z.ZodString>;
@@ -163,13 +191,32 @@ export declare const IdentifyResponseSchema: z.ZodObject<{
163
191
  session_id: z.ZodString;
164
192
  device_id: z.ZodString;
165
193
  persona_id: z.ZodString;
194
+ token: z.ZodString;
166
195
  }, z.core.$strip>;
167
196
  export type IdentifyResponse = z.infer<typeof IdentifyResponseSchema>;
168
197
  export declare const IdentifyErrorResponseSchema: z.ZodObject<{
169
198
  success: z.ZodLiteral<false>;
170
- error: z.ZodObject<{
171
- code: z.ZodString;
199
+ error: z.ZodDiscriminatedUnion<[z.ZodObject<{
200
+ code: z.ZodLiteral<"MISSING_ORG_ID">;
172
201
  message: z.ZodString;
173
- }, z.core.$strip>;
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">;
174
221
  }, z.core.$strip>;
175
222
  export type IdentifyErrorResponse = z.infer<typeof IdentifyErrorResponseSchema>;
@@ -1,16 +1,5 @@
1
+ import { DevicePlatformEnum } from "@teardown/types";
1
2
  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
3
  /**
15
4
  * Application info schema
16
5
  */
@@ -23,10 +12,16 @@ export const ApplicationInfoSchema = z.object({
23
12
  */
24
13
  export const OSInfoSchema = z.object({
25
14
  /**
26
- * OS type
15
+ * Device platform
16
+ */
17
+ platform: z.enum(DevicePlatformEnum),
18
+ /**
19
+ * OS name
27
20
  */
28
- type: z.enum(OSType),
29
21
  name: z.string(),
22
+ /**
23
+ * OS version
24
+ */
30
25
  version: z.string(),
31
26
  });
32
27
  /**
@@ -59,10 +54,32 @@ export const UpdateInfoSchema = z.object({
59
54
  is_embedded_launch: z.boolean(),
60
55
  created_at: z.coerce.date(),
61
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
+ });
62
75
  /**
63
76
  * Device info schema
64
77
  */
65
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(),
66
83
  /**
67
84
  * Application info, required
68
85
  */
@@ -79,6 +96,10 @@ export const DeviceInfoSchema = z.object({
79
96
  * OS info, required
80
97
  */
81
98
  os: OSInfoSchema,
99
+ /**
100
+ * Notifications info, required
101
+ */
102
+ notifications: NotificationsInfoSchema,
82
103
  });
83
104
  /**
84
105
  * Persona info schema (optional fields)
@@ -110,11 +131,38 @@ export const IdentifyResponseSchema = z.object({
110
131
  session_id: z.string(),
111
132
  device_id: z.string(),
112
133
  persona_id: z.string(),
134
+ token: z.string(), // JWT token for session authentication
113
135
  });
114
136
  export const IdentifyErrorResponseSchema = z.object({
115
137
  success: z.literal(false),
116
- error: z.object({
117
- code: z.string(),
118
- message: z.string(),
119
- }),
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
+ ]),
120
168
  });
@@ -1 +1 @@
1
- export * from "./identify.schema";
1
+ export * from "@teardown/schemas/identify";
@@ -1 +1 @@
1
- export * from "./identify.schema";
1
+ export * from "@teardown/schemas/identify";
@@ -1,2 +1,2 @@
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
+ export type * from "@teardown/schemas/environment";
2
+ export type * from "@teardown/schemas/identify";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teardown/ingest-api",
3
- "version": "0.0.18",
3
+ "version": "0.0.21-alpha.3",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -27,26 +27,25 @@
27
27
  }
28
28
  },
29
29
  "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"
30
+ "build": "bun x tsc --project ./tsconfig.lib.json",
31
+ "dev": "bun x tsc --watch --project ./tsconfig.lib.json",
32
+ "check:types": "bun x tsc --noEmit --project ./tsconfig.lib.json",
33
+ "prepublishOnly": "bun run build"
37
34
  },
38
35
  "dependencies": {
39
- "@elysiajs/eden": "^1.4.4",
40
- "elysia": "^1.4.13"
36
+ "@elysiajs/eden": "1.4.4",
37
+ "@teardown/schemas": "0.1.0"
41
38
  },
42
39
  "peerDependencies": {
43
- "typescript": "^5",
44
- "zod": "^4"
40
+ "typescript": "^5.9.3",
41
+ "zod": "^4",
42
+ "elysia": ">= 1.4.0"
45
43
  },
46
44
  "devDependencies": {
47
- "@types/bun": "latest",
45
+ "@types/bun": "1.1.14",
48
46
  "@teardown/ingest": "0.0.1",
49
47
  "@teardown/tsconfig": "1.0.0",
50
- "@teardown/types": "0.0.1"
48
+ "@teardown/types": "0.0.2",
49
+ "elysia": "1.4.0"
51
50
  }
52
51
  }
@@ -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 {};