@teardown/ingest-api 0.0.15 → 0.0.16
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 +9 -0
- package/dist/client/client.js +2 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +2 -0
- package/dist/client/types.d.ts +74 -0
- package/dist/client/types.js +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/schemas/identify.schema.d.ts +146 -0
- package/dist/schemas/identify.schema.js +83 -0
- package/dist/schemas/index.d.ts +1 -0
- package/dist/schemas/index.js +1 -0
- package/dist/types/app.d.ts +9 -0
- package/dist/types/app.js +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,9 @@
|
|
|
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>;
|
|
5
|
+
export type Client = ReturnType<typeof client>;
|
|
6
|
+
export type RequestOptions = Omit<NonNullable<Parameters<Client>[1]>, "headers"> & {
|
|
7
|
+
headers?: Record<string, string>;
|
|
8
|
+
};
|
|
9
|
+
export type Endpoints = Parameters<Client>[0];
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export declare class EdenFetchError<Status extends number = number, Value = unknown> extends Error {
|
|
2
|
+
status: Status;
|
|
3
|
+
value: Value;
|
|
4
|
+
constructor(status: Status, value: Value);
|
|
5
|
+
}
|
|
6
|
+
export type Range<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>;
|
|
7
|
+
export type Enumerate<N extends number, Acc extends number[] = []> = Acc["length"] extends N ? Acc[number] : Enumerate<N, [...Acc, Acc["length"]]>;
|
|
8
|
+
export type ErrorRange = Range<300, 599>;
|
|
9
|
+
export type MapError<T extends Record<number, unknown>> = [
|
|
10
|
+
{
|
|
11
|
+
[K in keyof T]-?: K extends ErrorRange ? K : never;
|
|
12
|
+
}[keyof T]
|
|
13
|
+
] extends [infer A extends number] ? {
|
|
14
|
+
[K in A]: EdenFetchError<K, T[K]>;
|
|
15
|
+
}[A] : false;
|
|
16
|
+
export type UnionToIntersect<U> = (U extends any ? (arg: U) => any : never) extends (arg: infer I) => void ? I : never;
|
|
17
|
+
export type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
18
|
+
export type IsNever<T> = [T] extends [never] ? true : false;
|
|
19
|
+
export type IsUnknown<T> = IsAny<T> extends true ? false : unknown extends T ? true : false;
|
|
20
|
+
export type AnyTypedRoute = {
|
|
21
|
+
body?: unknown;
|
|
22
|
+
headers?: unknown;
|
|
23
|
+
query?: unknown;
|
|
24
|
+
params?: unknown;
|
|
25
|
+
response: Record<number, unknown>;
|
|
26
|
+
};
|
|
27
|
+
export type Prettify<T> = {
|
|
28
|
+
[K in keyof T]: T[K];
|
|
29
|
+
} & {};
|
|
30
|
+
export type TreatyToPath<T, Path extends string = ""> = UnionToIntersect<T extends Record<string, unknown> ? {
|
|
31
|
+
[K in keyof T]: T[K] extends AnyTypedRoute ? {
|
|
32
|
+
[path in Path]: {
|
|
33
|
+
[method in K]: T[K];
|
|
34
|
+
};
|
|
35
|
+
} : unknown extends T[K] ? {
|
|
36
|
+
[path in Path]: {
|
|
37
|
+
[method in K]: T[K];
|
|
38
|
+
};
|
|
39
|
+
} : TreatyToPath<T[K], `${Path}/${K & string}`>;
|
|
40
|
+
}[keyof T] : {}>;
|
|
41
|
+
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
|
+
}>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* OS types
|
|
4
|
+
*/
|
|
5
|
+
export type OSType = "IOS" | "ANDROID" | "WEB" | "WINDOWS" | "MACOS" | "LINUX" | string;
|
|
6
|
+
/**
|
|
7
|
+
* Device types
|
|
8
|
+
*/
|
|
9
|
+
export type DeviceType = "UNKNOWN" | "PHONE" | "TABLET" | "DESKTOP" | "CONSOLE" | "TV" | "WEARABLE" | "GAME_CONSOLE" | "VR" | "OTHER";
|
|
10
|
+
/**
|
|
11
|
+
* Application info schema
|
|
12
|
+
*/
|
|
13
|
+
export declare const ApplicationInfoSchema: z.ZodObject<{
|
|
14
|
+
version: z.ZodNullable<z.ZodString>;
|
|
15
|
+
buildNumber: z.ZodNullable<z.ZodString>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export type ApplicationInfo = z.infer<typeof ApplicationInfoSchema>;
|
|
18
|
+
/**
|
|
19
|
+
* OS info schema
|
|
20
|
+
*/
|
|
21
|
+
export declare const OSInfoSchema: z.ZodObject<{
|
|
22
|
+
type: z.ZodString;
|
|
23
|
+
name: z.ZodNullable<z.ZodString>;
|
|
24
|
+
version: z.ZodNullable<z.ZodString>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
export type OSInfo = z.infer<typeof OSInfoSchema>;
|
|
27
|
+
/**
|
|
28
|
+
* Hardware info schema
|
|
29
|
+
*/
|
|
30
|
+
export declare const HardwareInfoSchema: z.ZodObject<{
|
|
31
|
+
deviceName: z.ZodNullable<z.ZodString>;
|
|
32
|
+
deviceType: z.ZodNullable<z.ZodString>;
|
|
33
|
+
deviceBrand: z.ZodNullable<z.ZodString>;
|
|
34
|
+
osVersion: z.ZodNullable<z.ZodString>;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
export type HardwareInfo = z.infer<typeof HardwareInfoSchema>;
|
|
37
|
+
/**
|
|
38
|
+
* Update info schema
|
|
39
|
+
*/
|
|
40
|
+
export declare const UpdateInfoSchema: z.ZodObject<{
|
|
41
|
+
isEnabled: z.ZodBoolean;
|
|
42
|
+
updateId: z.ZodNullable<z.ZodString>;
|
|
43
|
+
channel: z.ZodNullable<z.ZodString>;
|
|
44
|
+
runtimeVersion: z.ZodNullable<z.ZodString>;
|
|
45
|
+
isEmergencyLaunch: z.ZodBoolean;
|
|
46
|
+
emergencyLaunchReason: z.ZodNullable<z.ZodString>;
|
|
47
|
+
isEmbeddedLaunch: z.ZodBoolean;
|
|
48
|
+
createdAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
export type UpdateInfo = z.infer<typeof UpdateInfoSchema>;
|
|
51
|
+
/**
|
|
52
|
+
* Device info schema
|
|
53
|
+
*/
|
|
54
|
+
export declare const DeviceInfoSchema: z.ZodObject<{
|
|
55
|
+
applicationInfo: z.ZodNullable<z.ZodObject<{
|
|
56
|
+
version: z.ZodNullable<z.ZodString>;
|
|
57
|
+
buildNumber: z.ZodNullable<z.ZodString>;
|
|
58
|
+
}, z.core.$strip>>;
|
|
59
|
+
updateInfo: z.ZodNullable<z.ZodObject<{
|
|
60
|
+
isEnabled: z.ZodBoolean;
|
|
61
|
+
updateId: z.ZodNullable<z.ZodString>;
|
|
62
|
+
channel: z.ZodNullable<z.ZodString>;
|
|
63
|
+
runtimeVersion: z.ZodNullable<z.ZodString>;
|
|
64
|
+
isEmergencyLaunch: z.ZodBoolean;
|
|
65
|
+
emergencyLaunchReason: z.ZodNullable<z.ZodString>;
|
|
66
|
+
isEmbeddedLaunch: z.ZodBoolean;
|
|
67
|
+
createdAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
68
|
+
}, z.core.$strip>>;
|
|
69
|
+
hardwareInfo: z.ZodNullable<z.ZodObject<{
|
|
70
|
+
deviceName: z.ZodNullable<z.ZodString>;
|
|
71
|
+
deviceType: z.ZodNullable<z.ZodString>;
|
|
72
|
+
deviceBrand: z.ZodNullable<z.ZodString>;
|
|
73
|
+
osVersion: z.ZodNullable<z.ZodString>;
|
|
74
|
+
}, z.core.$strip>>;
|
|
75
|
+
osInfo: z.ZodNullable<z.ZodObject<{
|
|
76
|
+
type: z.ZodString;
|
|
77
|
+
name: z.ZodNullable<z.ZodString>;
|
|
78
|
+
version: z.ZodNullable<z.ZodString>;
|
|
79
|
+
}, z.core.$strip>>;
|
|
80
|
+
}, z.core.$strip>;
|
|
81
|
+
export type DeviceInfo = z.infer<typeof DeviceInfoSchema>;
|
|
82
|
+
/**
|
|
83
|
+
* Persona info schema (optional fields)
|
|
84
|
+
* Matches personas table structure
|
|
85
|
+
*/
|
|
86
|
+
export declare const PersonaInfoSchema: z.ZodObject<{
|
|
87
|
+
user_id: z.ZodOptional<z.ZodString>;
|
|
88
|
+
email: z.ZodOptional<z.ZodString>;
|
|
89
|
+
name: z.ZodOptional<z.ZodString>;
|
|
90
|
+
}, z.core.$strip>;
|
|
91
|
+
export type PersonaInfo = z.infer<typeof PersonaInfoSchema>;
|
|
92
|
+
/**
|
|
93
|
+
* Identify request schema
|
|
94
|
+
* Ties a device to a persona with optional persona data
|
|
95
|
+
*/
|
|
96
|
+
export declare const IdentifyRequestSchema: z.ZodObject<{
|
|
97
|
+
device: z.ZodObject<{
|
|
98
|
+
applicationInfo: z.ZodNullable<z.ZodObject<{
|
|
99
|
+
version: z.ZodNullable<z.ZodString>;
|
|
100
|
+
buildNumber: z.ZodNullable<z.ZodString>;
|
|
101
|
+
}, z.core.$strip>>;
|
|
102
|
+
updateInfo: z.ZodNullable<z.ZodObject<{
|
|
103
|
+
isEnabled: z.ZodBoolean;
|
|
104
|
+
updateId: z.ZodNullable<z.ZodString>;
|
|
105
|
+
channel: z.ZodNullable<z.ZodString>;
|
|
106
|
+
runtimeVersion: z.ZodNullable<z.ZodString>;
|
|
107
|
+
isEmergencyLaunch: z.ZodBoolean;
|
|
108
|
+
emergencyLaunchReason: z.ZodNullable<z.ZodString>;
|
|
109
|
+
isEmbeddedLaunch: z.ZodBoolean;
|
|
110
|
+
createdAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
111
|
+
}, z.core.$strip>>;
|
|
112
|
+
hardwareInfo: z.ZodNullable<z.ZodObject<{
|
|
113
|
+
deviceName: z.ZodNullable<z.ZodString>;
|
|
114
|
+
deviceType: z.ZodNullable<z.ZodString>;
|
|
115
|
+
deviceBrand: z.ZodNullable<z.ZodString>;
|
|
116
|
+
osVersion: z.ZodNullable<z.ZodString>;
|
|
117
|
+
}, z.core.$strip>>;
|
|
118
|
+
osInfo: z.ZodNullable<z.ZodObject<{
|
|
119
|
+
type: z.ZodString;
|
|
120
|
+
name: z.ZodNullable<z.ZodString>;
|
|
121
|
+
version: z.ZodNullable<z.ZodString>;
|
|
122
|
+
}, z.core.$strip>>;
|
|
123
|
+
}, z.core.$strip>;
|
|
124
|
+
persona: z.ZodOptional<z.ZodObject<{
|
|
125
|
+
user_id: z.ZodOptional<z.ZodString>;
|
|
126
|
+
email: z.ZodOptional<z.ZodString>;
|
|
127
|
+
name: z.ZodOptional<z.ZodString>;
|
|
128
|
+
}, z.core.$strip>>;
|
|
129
|
+
}, z.core.$strip>;
|
|
130
|
+
export type IdentifyRequest = z.infer<typeof IdentifyRequestSchema>;
|
|
131
|
+
/**
|
|
132
|
+
* Identify response schema
|
|
133
|
+
*/
|
|
134
|
+
export declare const IdentifyResponseSchema: z.ZodObject<{
|
|
135
|
+
success: z.ZodLiteral<true>;
|
|
136
|
+
session_id: z.ZodString;
|
|
137
|
+
}, z.core.$strip>;
|
|
138
|
+
export type IdentifyResponse = z.infer<typeof IdentifyResponseSchema>;
|
|
139
|
+
export declare const IdentifyErrorResponseSchema: z.ZodObject<{
|
|
140
|
+
success: z.ZodLiteral<false>;
|
|
141
|
+
error: z.ZodObject<{
|
|
142
|
+
code: z.ZodString;
|
|
143
|
+
message: z.ZodString;
|
|
144
|
+
}, z.core.$strip>;
|
|
145
|
+
}, z.core.$strip>;
|
|
146
|
+
export type IdentifyErrorResponse = z.infer<typeof IdentifyErrorResponseSchema>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Application info schema
|
|
4
|
+
*/
|
|
5
|
+
export const ApplicationInfoSchema = z.object({
|
|
6
|
+
version: z.string().nullable(),
|
|
7
|
+
buildNumber: z.string().nullable(),
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* OS info schema
|
|
11
|
+
*/
|
|
12
|
+
export const OSInfoSchema = z.object({
|
|
13
|
+
type: z.string(),
|
|
14
|
+
name: z.string().nullable(),
|
|
15
|
+
version: z.string().nullable(),
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* Hardware info schema
|
|
19
|
+
*/
|
|
20
|
+
export const HardwareInfoSchema = z.object({
|
|
21
|
+
deviceName: z.string().nullable(),
|
|
22
|
+
deviceType: z.string().nullable(),
|
|
23
|
+
deviceBrand: z.string().nullable(),
|
|
24
|
+
osVersion: z.string().nullable(),
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* Update info schema
|
|
28
|
+
*/
|
|
29
|
+
export const UpdateInfoSchema = z.object({
|
|
30
|
+
isEnabled: z.boolean(),
|
|
31
|
+
updateId: z.string().nullable(),
|
|
32
|
+
channel: z.string().nullable(),
|
|
33
|
+
runtimeVersion: z.string().nullable(),
|
|
34
|
+
isEmergencyLaunch: z.boolean(),
|
|
35
|
+
emergencyLaunchReason: z.string().nullable(),
|
|
36
|
+
isEmbeddedLaunch: z.boolean(),
|
|
37
|
+
createdAt: z.coerce.date().nullable(),
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* Device info schema
|
|
41
|
+
*/
|
|
42
|
+
export const DeviceInfoSchema = z.object({
|
|
43
|
+
applicationInfo: ApplicationInfoSchema.nullable(),
|
|
44
|
+
updateInfo: UpdateInfoSchema.nullable(),
|
|
45
|
+
hardwareInfo: HardwareInfoSchema.nullable(),
|
|
46
|
+
osInfo: OSInfoSchema.nullable(),
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* Persona info schema (optional fields)
|
|
50
|
+
* Matches personas table structure
|
|
51
|
+
*/
|
|
52
|
+
export const PersonaInfoSchema = z.object({
|
|
53
|
+
user_id: z.string().optional(),
|
|
54
|
+
email: z
|
|
55
|
+
.string()
|
|
56
|
+
.refine((val) => !val || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(val), {
|
|
57
|
+
message: "Invalid email format",
|
|
58
|
+
})
|
|
59
|
+
.optional(),
|
|
60
|
+
name: z.string().optional(),
|
|
61
|
+
});
|
|
62
|
+
/**
|
|
63
|
+
* Identify request schema
|
|
64
|
+
* Ties a device to a persona with optional persona data
|
|
65
|
+
*/
|
|
66
|
+
export const IdentifyRequestSchema = z.object({
|
|
67
|
+
device: DeviceInfoSchema,
|
|
68
|
+
persona: PersonaInfoSchema.optional(),
|
|
69
|
+
});
|
|
70
|
+
/**
|
|
71
|
+
* Identify response schema
|
|
72
|
+
*/
|
|
73
|
+
export const IdentifyResponseSchema = z.object({
|
|
74
|
+
success: z.literal(true),
|
|
75
|
+
session_id: z.string(),
|
|
76
|
+
});
|
|
77
|
+
export const IdentifyErrorResponseSchema = z.object({
|
|
78
|
+
success: z.literal(false),
|
|
79
|
+
error: z.object({
|
|
80
|
+
code: z.string(),
|
|
81
|
+
message: z.string(),
|
|
82
|
+
}),
|
|
83
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./identify.schema";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./identify.schema";
|
|
@@ -0,0 +1,9 @@
|
|
|
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>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teardown/ingest-api",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -28,11 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"sync:schemas": "bun run scripts/sync-schemas.ts",
|
|
31
|
-
"
|
|
32
|
-
"build": "
|
|
33
|
-
"compile": "rm -rf dist && tsc --project ./tsconfig.lib.json",
|
|
31
|
+
"postinstall": "bun run sync:schemas",
|
|
32
|
+
"build": "tsc --project ./tsconfig.lib.json",
|
|
34
33
|
"predev": "bun run sync:schemas",
|
|
35
|
-
"dev": "rm -rf dist
|
|
34
|
+
"dev": "rm -rf dist; bun x tsc --watch --project ./tsconfig.lib.json",
|
|
36
35
|
"check:types": "tsc --noEmit --project ./tsconfig.lib.json",
|
|
37
36
|
"prepublishOnly": "bun run build"
|
|
38
37
|
},
|
|
@@ -46,6 +45,7 @@
|
|
|
46
45
|
},
|
|
47
46
|
"devDependencies": {
|
|
48
47
|
"@types/bun": "latest",
|
|
48
|
+
"@teardown/ingest": "0.0.1",
|
|
49
49
|
"@teardown/tsconfig": "1.0.0",
|
|
50
50
|
"@teardown/types": "0.0.1"
|
|
51
51
|
}
|