@teardown/ingest-api 0.1.47-alpha-01 → 0.1.48

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.
@@ -8,12 +8,6 @@ export declare const baseApp: Elysia<"", {
8
8
  }, {
9
9
  typebox: {};
10
10
  error: {};
11
- } & {
12
- typebox: {};
13
- error: {};
14
- } & {
15
- typebox: {};
16
- error: {};
17
11
  } & {
18
12
  typebox: {};
19
13
  error: {
@@ -36,20 +30,6 @@ export declare const baseApp: Elysia<"", {
36
30
  macroFn: {};
37
31
  parser: {};
38
32
  response: {};
39
- } & {
40
- schema: {};
41
- standaloneSchema: {};
42
- macro: {};
43
- macroFn: {};
44
- parser: {};
45
- response: {};
46
- } & {
47
- schema: {};
48
- standaloneSchema: {};
49
- macro: {};
50
- macroFn: {};
51
- parser: {};
52
- response: {};
53
33
  } & {
54
34
  schema: {};
55
35
  standaloneSchema: {};
@@ -71,23 +51,12 @@ export declare const baseApp: Elysia<"", {
71
51
  body: unknown;
72
52
  params: {};
73
53
  query: unknown;
74
- headers: {
75
- "td-api-version"?: string | undefined;
76
- };
54
+ headers: unknown;
77
55
  response: {
78
56
  200: import("@teardown/errors").ErrorResponse | {
79
57
  message: string;
80
58
  version: string;
81
59
  };
82
- 422: {
83
- type: "validation";
84
- on: string;
85
- summary?: string;
86
- message?: string;
87
- found?: unknown;
88
- property?: string;
89
- expected?: string;
90
- };
91
60
  };
92
61
  };
93
62
  } & {
@@ -96,9 +65,7 @@ export declare const baseApp: Elysia<"", {
96
65
  body: unknown;
97
66
  params: {};
98
67
  query: unknown;
99
- headers: {
100
- "td-api-version"?: string | undefined;
101
- };
68
+ headers: unknown;
102
69
  response: {
103
70
  200: import("@teardown/errors").ErrorResponse | {
104
71
  status: string;
@@ -106,15 +73,6 @@ export declare const baseApp: Elysia<"", {
106
73
  build_id: string;
107
74
  service_id: string | undefined;
108
75
  };
109
- 422: {
110
- type: "validation";
111
- on: string;
112
- summary?: string;
113
- message?: string;
114
- found?: unknown;
115
- property?: string;
116
- expected?: string;
117
- };
118
76
  };
119
77
  };
120
78
  };
@@ -125,18 +83,12 @@ export declare const baseApp: Elysia<"", {
125
83
  identify: {
126
84
  post: {
127
85
  body: {
128
- user?: {
129
- name?: string | undefined;
130
- persona_id?: string | undefined;
131
- user_id?: string | undefined;
132
- email?: string | undefined;
133
- } | undefined;
134
86
  device: {
135
87
  timestamp?: Date | undefined;
136
88
  os: {
89
+ platform: import("@teardown/types").DevicePlatformEnum;
137
90
  name: string;
138
91
  version: string;
139
- platform: import("@teardown/types").DevicePlatformEnum;
140
92
  };
141
93
  application: {
142
94
  version: string;
@@ -156,13 +108,19 @@ export declare const baseApp: Elysia<"", {
156
108
  is_emergency_launch: true;
157
109
  reason: string;
158
110
  } | {
159
- reason?: undefined;
160
111
  is_emergency_launch: false;
112
+ reason?: undefined;
161
113
  };
162
114
  is_embedded_launch: boolean;
163
115
  created_at: string;
164
116
  } | null;
165
117
  };
118
+ user?: {
119
+ persona_id?: string | undefined;
120
+ user_id?: string | undefined;
121
+ email?: string | undefined;
122
+ name?: string | undefined;
123
+ } | undefined;
166
124
  };
167
125
  params: {};
168
126
  query: unknown;
@@ -178,9 +136,9 @@ export declare const baseApp: Elysia<"", {
178
136
  200: {
179
137
  success: true;
180
138
  data: {
181
- user_id: string;
182
139
  session_id: string;
183
140
  device_id: string;
141
+ user_id: string;
184
142
  token: string;
185
143
  version_info: {
186
144
  status: import("@teardown/schemas").IdentifyVersionStatusEnum;
@@ -188,16 +146,16 @@ export declare const baseApp: Elysia<"", {
188
146
  status: import("@teardown/schemas").IdentifyVersionStatusEnum.UPDATE_AVAILABLE;
189
147
  update: {
190
148
  version: string;
191
- update_id: string;
192
149
  build: string;
150
+ update_id: string;
193
151
  effective_date: Date;
194
152
  };
195
153
  } | {
196
154
  status: import("@teardown/schemas").IdentifyVersionStatusEnum.UPDATE_RECOMMENDED;
197
155
  update: {
198
156
  version: string;
199
- update_id: string;
200
157
  build: string;
158
+ update_id: string;
201
159
  effective_date: Date;
202
160
  };
203
161
  } | null;
@@ -205,6 +163,7 @@ export declare const baseApp: Elysia<"", {
205
163
  };
206
164
  };
207
165
  400: {
166
+ success: false;
208
167
  error: {
209
168
  code: "MISSING_ORG_ID";
210
169
  message: string;
@@ -230,16 +189,15 @@ export declare const baseApp: Elysia<"", {
230
189
  code: "NO_USER_ID_GENERATED";
231
190
  message: string;
232
191
  };
233
- success: false;
234
192
  };
235
193
  422: {
236
194
  type: "validation";
237
195
  on: string;
238
- summary?: string;
239
- message?: string;
196
+ summary?: string | undefined;
197
+ message?: string | undefined;
240
198
  found?: unknown;
241
- property?: string;
242
- expected?: string;
199
+ property?: string | undefined;
200
+ expected?: string | undefined;
243
201
  };
244
202
  };
245
203
  };
@@ -252,16 +210,16 @@ export declare const baseApp: Elysia<"", {
252
210
  events: {
253
211
  post: {
254
212
  body: {
255
- session_id?: string | undefined;
256
- device_id?: string | undefined;
257
213
  events: {
214
+ event_name: string;
215
+ event_type: "action" | "custom" | "screen_view";
258
216
  properties?: {} | undefined;
259
217
  timestamp?: string | undefined;
260
218
  session_id?: string | undefined;
261
219
  device_id?: string | undefined;
262
- event_name: string;
263
- event_type: "action" | "screen_view" | "custom";
264
220
  }[];
221
+ session_id?: string | undefined;
222
+ device_id?: string | undefined;
265
223
  };
266
224
  params: {};
267
225
  query: unknown;
@@ -283,6 +241,7 @@ export declare const baseApp: Elysia<"", {
283
241
  };
284
242
  };
285
243
  400: {
244
+ success: false;
286
245
  error: {
287
246
  code: "MISSING_ORG_ID";
288
247
  message: string;
@@ -311,16 +270,15 @@ export declare const baseApp: Elysia<"", {
311
270
  code: "VALIDATION_ERROR";
312
271
  message: string;
313
272
  };
314
- success: false;
315
273
  };
316
274
  422: {
317
275
  type: "validation";
318
276
  on: string;
319
- summary?: string;
320
- message?: string;
277
+ summary?: string | undefined;
278
+ message?: string | undefined;
321
279
  found?: unknown;
322
- property?: string;
323
- expected?: string;
280
+ property?: string | undefined;
281
+ expected?: string | undefined;
324
282
  };
325
283
  };
326
284
  };
@@ -334,10 +292,7 @@ export declare const baseApp: Elysia<"", {
334
292
  response: {};
335
293
  }, {
336
294
  derive: {};
337
- resolve: {
338
- readonly apiVersion: "2024-12-12";
339
- readonly requestedVersion: string | null;
340
- };
295
+ resolve: {};
341
296
  schema: import("elysia").UnwrapRoute<{
342
297
  headers: z.ZodObject<{
343
298
  authorization: z.ZodOptional<z.ZodString>;
@@ -350,10 +305,7 @@ export declare const baseApp: Elysia<"", {
350
305
  }, z.core.$strip>;
351
306
  }, {}, "">;
352
307
  standaloneSchema: {};
353
- response: import("elysia").ExtractErrorFromHandle<{
354
- readonly apiVersion: "2024-12-12";
355
- readonly requestedVersion: string | null;
356
- }>;
308
+ response: {};
357
309
  } & {
358
310
  derive: {};
359
311
  resolve: {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teardown/ingest-api",
3
- "version": "0.1.47-alpha-01",
3
+ "version": "0.1.48",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "scripts": {
31
31
  "dev": "bun run typecheck --watch",
32
- "typecheck": "tsc --noEmit --project ./tsconfig.lib.json",
32
+ "typecheck": "bun x tsgo --noEmit --project ./tsconfig.lib.json",
33
33
  "generate:types": "bun run scripts/generate-types.ts",
34
34
  "build": "bun run generate:types",
35
35
  "prepublishOnly": "bun run generate:types",
@@ -39,9 +39,9 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@elysiajs/eden": "1.4.5",
42
- "@teardown/errors": "0.1.46",
43
- "@teardown/schemas": "0.1.46",
44
- "@teardown/types": "0.1.46",
42
+ "@teardown/errors": "0.1.48",
43
+ "@teardown/schemas": "0.1.48",
44
+ "@teardown/types": "0.1.48",
45
45
  "zod": "4.1.13"
46
46
  },
47
47
  "peerDependencies": {
@@ -50,7 +50,7 @@
50
50
  "devDependencies": {
51
51
  "@biomejs/biome": "2.3.8",
52
52
  "@types/bun": "1.3.4",
53
- "@teardown/tsconfig": "0.1.46",
54
- "elysia": "1.4.17"
53
+ "@teardown/tsconfig": "0.1.48",
54
+ "elysia": "1.4.19"
55
55
  }
56
56
  }
@@ -12,5 +12,4 @@ export type RequestOptions = Omit<NonNullable<Parameters<Client>[1]>, "headers">
12
12
  };
13
13
 
14
14
  export type Endpoints = Parameters<Client>[0];
15
-
16
15
  export type App = typeof IngestApp;
@@ -1,3 +1 @@
1
1
  export * from "./client";
2
- export * from "./types";
3
- export * from "./ingest.client";
package/tsconfig.lib.json CHANGED
@@ -6,7 +6,6 @@
6
6
  ],
7
7
  "compilerOptions": {
8
8
  "noEmit": true,
9
- "baseUrl": ".",
10
9
  "rootDir": ".",
11
10
  "paths": {
12
11
  "@/*": ["./src/*"]
@@ -1,171 +0,0 @@
1
- import { edenFetch } from "@elysiajs/eden";
2
- import { API_VERSION_HEADER } from "@teardown/schemas/contracts";
3
- import type { IdentifyRequest, IdentifyResponse } from "@teardown/schemas/identify";
4
- import type { IngestApp } from "../../generated/app";
5
- import type { ClientConfig, RequestOptions } from "./client";
6
-
7
- /**
8
- * Ingest API Target Version
9
- *
10
- * This is the API contract version this client is built for.
11
- * The client will send this version in the td-api-version header.
12
- * Ingest API will validate and respond with the version used.
13
- */
14
- export const INGEST_TARGET_API_VERSION = "2024-12-12";
15
-
16
- export type IngestApiClientOptions = {
17
- /**
18
- * Base URL for the Ingest API
19
- */
20
- url: string;
21
- /**
22
- * API key for authentication
23
- */
24
- apiKey: string;
25
- /**
26
- * Organization ID
27
- */
28
- orgId: string;
29
- /**
30
- * Project ID
31
- */
32
- projectId: string;
33
- /**
34
- * Environment slug (e.g., "production", "staging")
35
- */
36
- environmentSlug: string;
37
- /**
38
- * Device ID (unique identifier for this device)
39
- */
40
- deviceId: string;
41
- /**
42
- * Session ID (optional, set after identify)
43
- */
44
- sessionId?: string;
45
- /**
46
- * Override the API version to use.
47
- * Defaults to INGEST_TARGET_API_VERSION.
48
- */
49
- apiVersion?: string;
50
- /**
51
- * Optional Eden fetch config
52
- */
53
- config?: ClientConfig;
54
- /**
55
- * Hook to modify request options before each request
56
- */
57
- onRequest?: (endpoint: string, options: RequestOptions) => Promise<RequestOptions>;
58
- };
59
-
60
- type IngestClient = ReturnType<typeof edenFetch<typeof IngestApp>>;
61
-
62
- export class IngestApiClient {
63
- private readonly client: IngestClient;
64
- private readonly apiVersion: string;
65
- private sessionId: string | undefined;
66
-
67
- constructor(private readonly options: IngestApiClientOptions) {
68
- this.client = edenFetch<typeof IngestApp>(this.options.url, this.options.config);
69
- this.apiVersion = options.apiVersion ?? INGEST_TARGET_API_VERSION;
70
- this.sessionId = options.sessionId;
71
- }
72
-
73
- /**
74
- * Get the API version this client is using
75
- */
76
- getApiVersion(): string {
77
- return this.apiVersion;
78
- }
79
-
80
- /**
81
- * Get the current session ID (if set)
82
- */
83
- getSessionId(): string | undefined {
84
- return this.sessionId;
85
- }
86
-
87
- /**
88
- * Set the session ID (typically after identify)
89
- */
90
- setSessionId(sessionId: string): void {
91
- this.sessionId = sessionId;
92
- }
93
-
94
- /**
95
- * Generate base headers for all requests
96
- */
97
- generateBaseHeaders(): Record<string, string> {
98
- const headers: Record<string, string> = {
99
- // Always send API version header
100
- [API_VERSION_HEADER]: this.apiVersion,
101
- "td-api-key": this.options.apiKey,
102
- "td-org-id": this.options.orgId,
103
- "td-project-id": this.options.projectId,
104
- "td-environment-slug": this.options.environmentSlug,
105
- "td-device-id": this.options.deviceId,
106
- };
107
-
108
- if (this.sessionId) {
109
- headers["td-session-id"] = this.sessionId;
110
- }
111
-
112
- return headers;
113
- }
114
-
115
- /**
116
- * Make a fetch request to the Ingest API
117
- * @internal Use typed convenience methods like identify() instead
118
- */
119
- // biome-ignore lint/suspicious/noExplicitAny: Eden types are complex, using any for flexibility
120
- async fetch(endpoint: string, options?: Record<string, any>): Promise<any> {
121
- const baseHeaders = this.generateBaseHeaders();
122
- const baseOptions = {
123
- ...options,
124
- headers: {
125
- ...baseHeaders,
126
- ...options?.headers,
127
- },
128
- };
129
-
130
- const requestOptions = this.options.onRequest
131
- ? await this.options.onRequest(endpoint, baseOptions as RequestOptions)
132
- : baseOptions;
133
-
134
- // biome-ignore lint/suspicious/noExplicitAny: Eden types require any cast
135
- const result = await this.client(endpoint as any, requestOptions as any);
136
-
137
- if (result.error) {
138
- throw result.error;
139
- }
140
-
141
- return result;
142
- }
143
-
144
- /**
145
- * Identify the current device/user
146
- * This should be called at app startup to establish a session
147
- */
148
- async identify(request: IdentifyRequest): Promise<IdentifyResponse> {
149
- const baseHeaders = this.generateBaseHeaders();
150
-
151
- // biome-ignore lint/suspicious/noExplicitAny: Eden types are complex
152
- const result = await this.client("/v1/identify" as any, {
153
- method: "POST",
154
- body: request,
155
- headers: baseHeaders,
156
- } as any);
157
-
158
- if (result.error) {
159
- throw result.error;
160
- }
161
-
162
- const data = result.data as IdentifyResponse;
163
-
164
- // Automatically set session ID from response
165
- if (data.success && data.data.session_id) {
166
- this.setSessionId(data.data.session_id);
167
- }
168
-
169
- return data;
170
- }
171
- }
@@ -1,84 +0,0 @@
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
-
7
- export type Range<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>;
8
- export type Enumerate<N extends number, Acc extends number[] = []> = Acc["length"] extends N
9
- ? Acc[number]
10
- : Enumerate<N, [...Acc, Acc["length"]]>;
11
- export type ErrorRange = Range<300, 599>;
12
- export type MapError<T extends Record<number, unknown>> = [
13
- {
14
- [K in keyof T]-?: K extends ErrorRange ? K : never;
15
- }[keyof T],
16
- ] extends [infer A extends number]
17
- ? {
18
- [K in A]: EdenFetchError<K, T[K]>;
19
- }[A]
20
- : false;
21
- export type UnionToIntersect<U> = (U extends any ? (arg: U) => any : never) extends (arg: infer I) => void ? I : never;
22
- export type IsAny<T> = 0 extends 1 & T ? true : false;
23
- export type IsNever<T> = [T] extends [never] ? true : false;
24
- export type IsUnknown<T> = IsAny<T> extends true ? false : unknown extends T ? true : false;
25
- export type IsExactlyUnknown<T> = [T] extends [unknown] ? ([unknown] extends [T] ? true : false) : false;
26
- export type IsUndefined<T> = [T] extends [undefined] ? true : false;
27
- export type IsMatchingEmptyObject<T> = [T] extends [{}] ? ([{}] extends [T] ? true : false) : false;
28
- export type MaybeEmptyObject<
29
- TObj,
30
- TKey extends PropertyKey,
31
- TFallback = Record<string, unknown>,
32
- > = IsUndefined<TObj> extends true
33
- ? {
34
- [K in TKey]?: TFallback;
35
- }
36
- : IsExactlyUnknown<TObj> extends true
37
- ? {
38
- [K in TKey]?: TFallback;
39
- }
40
- : IsMatchingEmptyObject<TObj> extends true
41
- ? {
42
- [K in TKey]?: TObj;
43
- }
44
- : undefined extends TObj
45
- ? {
46
- [K in TKey]?: TObj;
47
- }
48
- : null extends TObj
49
- ? {
50
- [K in TKey]?: TObj;
51
- }
52
- : {
53
- [K in TKey]: TObj;
54
- };
55
- type AnyTypedRoute = {
56
- body?: unknown;
57
- headers?: unknown;
58
- query?: unknown;
59
- params?: unknown;
60
- response: Record<number, unknown>;
61
- };
62
- export type Prettify<T> = {
63
- [K in keyof T]: T[K];
64
- } & {};
65
- export type TreatyToPath<T, Path extends string = ""> = UnionToIntersect<
66
- T extends Record<string, unknown>
67
- ? {
68
- [K in keyof T]: T[K] extends AnyTypedRoute
69
- ? {
70
- [path in Path]: {
71
- [method in K]: T[K];
72
- };
73
- }
74
- : unknown extends T[K]
75
- ? {
76
- [path in Path]: {
77
- [method in K]: T[K];
78
- };
79
- }
80
- : TreatyToPath<T[K], `${Path}/${K & string}`>;
81
- }[keyof T]
82
- : {}
83
- >;
84
- export type Not<T> = T extends true ? false : true;