@teardown/ingest-api 0.0.21-alpha.6 → 0.0.21-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/client.d.ts +3 -18
- package/dist/client/types.d.ts +18 -34
- package/dist/vendored/schemas/identify.d.ts +6 -0
- package/dist/vendored/schemas/identify.js +61 -26
- package/package.json +4 -4
- package/dist/schemas/identify.schema.d.ts +0 -222
- package/dist/schemas/identify.schema.js +0 -168
package/dist/client/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { edenFetch } from "@elysiajs/eden";
|
|
2
2
|
import type { IngestApp } from "@teardown/ingest/types";
|
|
3
|
-
export type ClientConfig = NonNullable<Parameters<typeof edenFetch<IngestApp>>[1]>;
|
|
3
|
+
export type ClientConfig = NonNullable<Parameters<typeof edenFetch<typeof IngestApp>>[1]>;
|
|
4
4
|
export declare const client: (server: string, config?: import("@elysiajs/eden/fetch").EdenFetch.Config) => import("@elysiajs/eden/fetch").EdenFetch.Fn<{
|
|
5
5
|
"/health": {
|
|
6
6
|
get: {
|
|
@@ -10,21 +10,13 @@ export declare const client: (server: string, config?: import("@elysiajs/eden/fe
|
|
|
10
10
|
headers: unknown;
|
|
11
11
|
response: {
|
|
12
12
|
200: {
|
|
13
|
-
error: string;
|
|
14
|
-
message: string;
|
|
15
|
-
status: number;
|
|
16
|
-
} | {
|
|
17
|
-
error: string;
|
|
18
|
-
status: number;
|
|
19
|
-
message?: undefined;
|
|
20
|
-
} | {
|
|
21
13
|
status: string;
|
|
22
14
|
timestamp: string;
|
|
23
15
|
};
|
|
24
16
|
};
|
|
25
17
|
};
|
|
26
18
|
};
|
|
27
|
-
} & {
|
|
19
|
+
} & {
|
|
28
20
|
"/v1/identify": {
|
|
29
21
|
post: {
|
|
30
22
|
body: {
|
|
@@ -136,14 +128,6 @@ export declare const client: (server: string, config?: import("@elysiajs/eden/fe
|
|
|
136
128
|
headers: unknown;
|
|
137
129
|
response: {
|
|
138
130
|
200: {
|
|
139
|
-
error: string;
|
|
140
|
-
message: string;
|
|
141
|
-
status: number;
|
|
142
|
-
} | {
|
|
143
|
-
error: string;
|
|
144
|
-
status: number;
|
|
145
|
-
message?: undefined;
|
|
146
|
-
} | {
|
|
147
131
|
message: string;
|
|
148
132
|
version: string;
|
|
149
133
|
};
|
|
@@ -156,3 +140,4 @@ export type RequestOptions = Omit<NonNullable<Parameters<Client>[1]>, "headers">
|
|
|
156
140
|
headers?: Record<string, string>;
|
|
157
141
|
};
|
|
158
142
|
export type Endpoints = Parameters<Client>[0];
|
|
143
|
+
export type App = typeof IngestApp;
|
package/dist/client/types.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
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,5 +1,6 @@
|
|
|
1
1
|
import { DevicePlatformEnum } from "../types/generated-consts";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
export { DevicePlatformEnum };
|
|
3
4
|
/**
|
|
4
5
|
* Application info schema
|
|
5
6
|
*/
|
|
@@ -220,3 +221,8 @@ export declare const IdentifyErrorResponseSchema: z.ZodObject<{
|
|
|
220
221
|
}, z.core.$strip>], "code">;
|
|
221
222
|
}, z.core.$strip>;
|
|
222
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>;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { DevicePlatformEnum } from "../types/generated-consts";
|
|
2
|
+
import { ValidationError } from "elysia";
|
|
2
3
|
import { z } from "zod";
|
|
4
|
+
export { DevicePlatformEnum };
|
|
3
5
|
/**
|
|
4
6
|
* Application info schema
|
|
5
7
|
*/
|
|
6
8
|
export const ApplicationInfoSchema = z.object({
|
|
7
|
-
version: z.string(),
|
|
8
|
-
build_number: z.string(),
|
|
9
|
+
version: z.string("version is required"),
|
|
10
|
+
build_number: z.string("build_number is required"),
|
|
11
|
+
}, {
|
|
12
|
+
error: "Application info is required",
|
|
9
13
|
});
|
|
10
14
|
/**
|
|
11
15
|
* OS info schema
|
|
@@ -14,45 +18,53 @@ export const OSInfoSchema = z.object({
|
|
|
14
18
|
/**
|
|
15
19
|
* Device platform
|
|
16
20
|
*/
|
|
17
|
-
platform: z.enum(DevicePlatformEnum),
|
|
21
|
+
platform: z.enum(DevicePlatformEnum, "platform is required"),
|
|
18
22
|
/**
|
|
19
23
|
* OS name
|
|
20
24
|
*/
|
|
21
|
-
name: z.string(),
|
|
25
|
+
name: z.string("name is required"),
|
|
22
26
|
/**
|
|
23
27
|
* OS version
|
|
24
28
|
*/
|
|
25
|
-
version: z.string(),
|
|
29
|
+
version: z.string("version is required"),
|
|
30
|
+
}, {
|
|
31
|
+
error: "OS info is required",
|
|
26
32
|
});
|
|
27
33
|
/**
|
|
28
34
|
* Hardware info schema
|
|
29
35
|
*/
|
|
30
36
|
export const HardwareInfoSchema = z.object({
|
|
31
|
-
device_name: z.string(),
|
|
32
|
-
device_type: z.string(),
|
|
33
|
-
device_brand: z.string(),
|
|
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",
|
|
34
42
|
});
|
|
35
43
|
export const EmergencyLaunchSchema = z.union([
|
|
36
44
|
z.object({
|
|
37
45
|
is_emergency_launch: z.literal(true),
|
|
38
|
-
reason: z.string(),
|
|
46
|
+
reason: z.string("reason is required when is_emergency_launch is true"),
|
|
39
47
|
}),
|
|
40
48
|
z.object({
|
|
41
49
|
is_emergency_launch: z.literal(false),
|
|
42
50
|
reason: z.never().optional(),
|
|
43
51
|
}),
|
|
44
|
-
]
|
|
52
|
+
], {
|
|
53
|
+
error: "Emergency launch is required",
|
|
54
|
+
});
|
|
45
55
|
/**
|
|
46
56
|
* Update info schema
|
|
47
57
|
*/
|
|
48
58
|
export const UpdateInfoSchema = z.object({
|
|
49
59
|
is_enabled: z.boolean(),
|
|
50
|
-
update_id: z.string(),
|
|
51
|
-
update_channel: z.string(),
|
|
52
|
-
runtime_version: z.string(),
|
|
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"),
|
|
53
63
|
emergency_launch: EmergencyLaunchSchema,
|
|
54
|
-
is_embedded_launch: z.boolean(),
|
|
64
|
+
is_embedded_launch: z.boolean("is_embedded_launch is required"),
|
|
55
65
|
created_at: z.coerce.date(),
|
|
66
|
+
}, {
|
|
67
|
+
error: "Update info is required",
|
|
56
68
|
});
|
|
57
69
|
export var NotificationPlatform;
|
|
58
70
|
(function (NotificationPlatform) {
|
|
@@ -64,13 +76,17 @@ export var NotificationPlatform;
|
|
|
64
76
|
* Push notification info schema
|
|
65
77
|
*/
|
|
66
78
|
export const PushNotificationInfoSchema = z.object({
|
|
67
|
-
enabled: z.boolean(),
|
|
68
|
-
granted: z.boolean(),
|
|
69
|
-
token: z.string().nullable(),
|
|
70
|
-
platform: z.enum(NotificationPlatform),
|
|
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",
|
|
71
85
|
});
|
|
72
86
|
export const NotificationsInfoSchema = z.object({
|
|
73
87
|
push: PushNotificationInfoSchema,
|
|
88
|
+
}, {
|
|
89
|
+
error: "Notifications info is required",
|
|
74
90
|
});
|
|
75
91
|
/**
|
|
76
92
|
* Device info schema
|
|
@@ -79,7 +95,7 @@ export const DeviceInfoSchema = z.object({
|
|
|
79
95
|
/**
|
|
80
96
|
* Timestamp of collection on device (optional, generated server-side if not provided)
|
|
81
97
|
*/
|
|
82
|
-
timestamp: z.coerce.date().optional(),
|
|
98
|
+
timestamp: z.coerce.date("timestamp is required").optional(),
|
|
83
99
|
/**
|
|
84
100
|
* Application info, required
|
|
85
101
|
*/
|
|
@@ -100,20 +116,24 @@ export const DeviceInfoSchema = z.object({
|
|
|
100
116
|
* Notifications info, required
|
|
101
117
|
*/
|
|
102
118
|
notifications: NotificationsInfoSchema,
|
|
119
|
+
}, {
|
|
120
|
+
error: "Device info is required",
|
|
103
121
|
});
|
|
104
122
|
/**
|
|
105
123
|
* Persona info schema (optional fields)
|
|
106
124
|
* Matches personas table structure
|
|
107
125
|
*/
|
|
108
126
|
export const PersonaInfoSchema = z.object({
|
|
109
|
-
user_id: z.string().optional(),
|
|
127
|
+
user_id: z.string("user_id is required").optional(),
|
|
110
128
|
email: z
|
|
111
|
-
.string()
|
|
129
|
+
.string("email is required")
|
|
112
130
|
.refine((val) => !val || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(val), {
|
|
113
131
|
message: "Invalid email format",
|
|
114
132
|
})
|
|
115
133
|
.optional(),
|
|
116
|
-
name: z.string().optional(),
|
|
134
|
+
name: z.string("name is required").optional(),
|
|
135
|
+
}, {
|
|
136
|
+
error: "Persona info is required",
|
|
117
137
|
});
|
|
118
138
|
/**
|
|
119
139
|
* Identify request schema
|
|
@@ -122,16 +142,20 @@ export const PersonaInfoSchema = z.object({
|
|
|
122
142
|
export const IdentifyRequestSchema = z.object({
|
|
123
143
|
device: DeviceInfoSchema,
|
|
124
144
|
persona: PersonaInfoSchema.optional(),
|
|
145
|
+
}, {
|
|
146
|
+
error: "Identify request is required",
|
|
125
147
|
});
|
|
126
148
|
/**
|
|
127
149
|
* Identify response schema
|
|
128
150
|
*/
|
|
129
151
|
export const IdentifyResponseSchema = z.object({
|
|
130
152
|
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
|
|
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",
|
|
135
159
|
});
|
|
136
160
|
export const IdentifyErrorResponseSchema = z.object({
|
|
137
161
|
success: z.literal(false),
|
|
@@ -165,4 +189,15 @@ export const IdentifyErrorResponseSchema = z.object({
|
|
|
165
189
|
message: z.string(),
|
|
166
190
|
}),
|
|
167
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",
|
|
168
201
|
});
|
|
202
|
+
// export type ValidationError = z.infer<typeof ValidationErrorSchema>;
|
|
203
|
+
ValidationError;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teardown/ingest-api",
|
|
3
|
-
"version": "0.0.21-alpha.
|
|
3
|
+
"version": "0.0.21-alpha.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"build": "bun x tsc --project ./tsconfig.lib.json",
|
|
33
33
|
"dev": "bun x tsc --watch --project ./tsconfig.lib.json",
|
|
34
34
|
"check:types": "bun x tsc --noEmit --project ./tsconfig.lib.json",
|
|
35
|
-
"prepublishOnly": "bun run build"
|
|
35
|
+
"prepublishOnly": "bun x turbo run build"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@elysiajs/eden": "1.4.
|
|
38
|
+
"@elysiajs/eden": "1.4.5"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"typescript": "^5.9.3",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"elysia": ">= 1.4.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@types/bun": "1.
|
|
46
|
+
"@types/bun": "1.3.3",
|
|
47
47
|
"@teardown/ingest": "0.0.1",
|
|
48
48
|
"@teardown/tsconfig": "1.0.0",
|
|
49
49
|
"elysia": "1.4.0"
|
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
import { DevicePlatformEnum } from "@teardown/types";
|
|
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>;
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { DevicePlatformEnum } from "@teardown/types";
|
|
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
|
-
});
|