@teardown/types 0.1.45 → 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.
- package/package.json +8 -3
- package/src/eden-treaty.types.ts +153 -0
- package/src/generated-types.ts +34 -7
- package/src/index.ts +3 -0
- package/tsconfig.lib.json +0 -1
- package/tsconfig.scripts.json +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teardown/types",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.48",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -27,6 +27,11 @@
|
|
|
27
27
|
"import": "./src/interfaces/*.ts",
|
|
28
28
|
"default": "./src/interfaces/*.ts"
|
|
29
29
|
},
|
|
30
|
+
"./eden-treaty": {
|
|
31
|
+
"types": "./src/eden-treaty.types.ts",
|
|
32
|
+
"import": "./src/eden-treaty.types.ts",
|
|
33
|
+
"default": "./src/eden-treaty.types.ts"
|
|
34
|
+
},
|
|
30
35
|
"./package.json": "./package.json"
|
|
31
36
|
},
|
|
32
37
|
"scripts": {
|
|
@@ -35,14 +40,14 @@
|
|
|
35
40
|
"generate": "bun run generate:types && bun run generate:consts",
|
|
36
41
|
"pull": "bun run generate",
|
|
37
42
|
"dev": "bun run typecheck --watch",
|
|
38
|
-
"typecheck": "
|
|
43
|
+
"typecheck": "bun x tsgo --noEmit --project ./tsconfig.lib.json",
|
|
39
44
|
"fmt": "bun x biome format --write ./src",
|
|
40
45
|
"lint": "bun x biome lint --write ./src",
|
|
41
46
|
"check": "bun x biome check ./src"
|
|
42
47
|
},
|
|
43
48
|
"devDependencies": {
|
|
44
49
|
"@biomejs/biome": "2.3.8",
|
|
45
|
-
"@teardown/tsconfig": "0.1.
|
|
50
|
+
"@teardown/tsconfig": "0.1.48",
|
|
46
51
|
"@types/bun": "1.3.4"
|
|
47
52
|
},
|
|
48
53
|
"peerDependencies": {
|
|
@@ -0,0 +1,153 @@
|
|
|
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
|
+
// biome-ignore lint/suspicious/noExplicitAny: Complex type utility that requires any for union to intersection conversion
|
|
22
|
+
export type UnionToIntersect<U> = (U extends any ? (arg: U) => any : never) extends (arg: infer I) => void ? I : never;
|
|
23
|
+
export type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
24
|
+
export type IsNever<T> = [T] extends [never] ? true : false;
|
|
25
|
+
export type IsUnknown<T> = IsAny<T> extends true ? false : unknown extends T ? true : false;
|
|
26
|
+
export type IsExactlyUnknown<T> = [T] extends [unknown] ? ([unknown] extends [T] ? true : false) : false;
|
|
27
|
+
export type IsUndefined<T> = [T] extends [undefined] ? true : false;
|
|
28
|
+
// biome-ignore lint/complexity/noBannedTypes: Empty object type required for type matching utility
|
|
29
|
+
export type IsMatchingEmptyObject<T> = [T] extends [{}] ? ([{}] extends [T] ? true : false) : false;
|
|
30
|
+
export type MaybeEmptyObject<
|
|
31
|
+
TObj,
|
|
32
|
+
TKey extends PropertyKey,
|
|
33
|
+
TFallback = Record<string, unknown>,
|
|
34
|
+
> = IsUndefined<TObj> extends true
|
|
35
|
+
? {
|
|
36
|
+
[K in TKey]?: TFallback;
|
|
37
|
+
}
|
|
38
|
+
: IsExactlyUnknown<TObj> extends true
|
|
39
|
+
? {
|
|
40
|
+
[K in TKey]?: TFallback;
|
|
41
|
+
}
|
|
42
|
+
: IsMatchingEmptyObject<TObj> extends true
|
|
43
|
+
? {
|
|
44
|
+
[K in TKey]?: TObj;
|
|
45
|
+
}
|
|
46
|
+
: undefined extends TObj
|
|
47
|
+
? {
|
|
48
|
+
[K in TKey]?: TObj;
|
|
49
|
+
}
|
|
50
|
+
: null extends TObj
|
|
51
|
+
? {
|
|
52
|
+
[K in TKey]?: TObj;
|
|
53
|
+
}
|
|
54
|
+
: {
|
|
55
|
+
[K in TKey]: TObj;
|
|
56
|
+
};
|
|
57
|
+
export type AnyTypedRoute = {
|
|
58
|
+
body?: unknown;
|
|
59
|
+
headers?: unknown;
|
|
60
|
+
query?: unknown;
|
|
61
|
+
params?: unknown;
|
|
62
|
+
response: Record<number, unknown>;
|
|
63
|
+
};
|
|
64
|
+
export type Prettify<T> = {
|
|
65
|
+
[K in keyof T]: T[K];
|
|
66
|
+
} & {};
|
|
67
|
+
export type TreatyToPath<T, Path extends string = ""> = UnionToIntersect<
|
|
68
|
+
T extends Record<string, unknown>
|
|
69
|
+
? {
|
|
70
|
+
[K in keyof T]: T[K] extends AnyTypedRoute
|
|
71
|
+
? {
|
|
72
|
+
[path in Path]: {
|
|
73
|
+
[method in K]: T[K];
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
: unknown extends T[K]
|
|
77
|
+
? {
|
|
78
|
+
[path in Path]: {
|
|
79
|
+
[method in K]: T[K];
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
: TreatyToPath<T[K], `${Path}/${K & string}`>;
|
|
83
|
+
}[keyof T]
|
|
84
|
+
: // biome-ignore lint/complexity/noBannedTypes: Empty object type required for recursive type utility
|
|
85
|
+
{}
|
|
86
|
+
>;
|
|
87
|
+
export type Not<T> = T extends true ? false : true;
|
|
88
|
+
|
|
89
|
+
// biome-ignore lint/suspicious/noExplicitAny: Schema type requires any for flexible endpoint definitions
|
|
90
|
+
export type Fn<Schema extends Record<string, any>> = <
|
|
91
|
+
Endpoint extends keyof Schema,
|
|
92
|
+
Method extends Uppercase<Extract<keyof Schema[Endpoint], string>>,
|
|
93
|
+
Route extends Schema[Endpoint][Lowercase<Method>],
|
|
94
|
+
>(
|
|
95
|
+
endpoint: Endpoint,
|
|
96
|
+
options: Omit<RequestInit, "body" | "method" | "headers"> &
|
|
97
|
+
("GET" extends Method
|
|
98
|
+
? {
|
|
99
|
+
method?: Method;
|
|
100
|
+
}
|
|
101
|
+
: {
|
|
102
|
+
method: Method;
|
|
103
|
+
}) &
|
|
104
|
+
(IsNever<keyof Route["params"]> extends true
|
|
105
|
+
? {
|
|
106
|
+
params?: Record<never, string>;
|
|
107
|
+
}
|
|
108
|
+
: {
|
|
109
|
+
params: Route["params"];
|
|
110
|
+
}) &
|
|
111
|
+
(IsNever<keyof Route["query"]> extends true
|
|
112
|
+
? {
|
|
113
|
+
query?: Record<never, string>;
|
|
114
|
+
}
|
|
115
|
+
: {
|
|
116
|
+
query: Route["query"];
|
|
117
|
+
}) &
|
|
118
|
+
(undefined extends Route["headers"]
|
|
119
|
+
? {
|
|
120
|
+
headers?: Record<string, string>;
|
|
121
|
+
}
|
|
122
|
+
: {
|
|
123
|
+
headers: Route["headers"];
|
|
124
|
+
}) &
|
|
125
|
+
(IsUnknown<Route["body"]> extends false
|
|
126
|
+
? {
|
|
127
|
+
body: Route["body"];
|
|
128
|
+
}
|
|
129
|
+
: {
|
|
130
|
+
body?: unknown;
|
|
131
|
+
})
|
|
132
|
+
) => Promise<
|
|
133
|
+
Prettify<
|
|
134
|
+
| {
|
|
135
|
+
data: Awaited<Route["response"][200]>;
|
|
136
|
+
error: null;
|
|
137
|
+
status: number;
|
|
138
|
+
headers: Record<string, unknown>;
|
|
139
|
+
retry(): Promise<void>;
|
|
140
|
+
}
|
|
141
|
+
| {
|
|
142
|
+
data: null;
|
|
143
|
+
error: MapError<Route["response"]> extends infer Errors
|
|
144
|
+
? IsNever<Errors> extends true
|
|
145
|
+
? EdenFetchError<number, string>
|
|
146
|
+
: Errors
|
|
147
|
+
: EdenFetchError<number, string>;
|
|
148
|
+
status: number;
|
|
149
|
+
headers: Record<string, unknown>;
|
|
150
|
+
retry(): Promise<void>;
|
|
151
|
+
}
|
|
152
|
+
>
|
|
153
|
+
>;
|
package/src/generated-types.ts
CHANGED
|
@@ -30,8 +30,8 @@ export type Database = {
|
|
|
30
30
|
ota_update_id: string | null
|
|
31
31
|
ota_update_runtime_version: string | null
|
|
32
32
|
ota_updates_enabled: boolean | null
|
|
33
|
-
sdk_name: string
|
|
34
|
-
sdk_version: string
|
|
33
|
+
sdk_name: string | null
|
|
34
|
+
sdk_version: string | null
|
|
35
35
|
started_at: string
|
|
36
36
|
token: string
|
|
37
37
|
token_expires_at: string
|
|
@@ -55,8 +55,8 @@ export type Database = {
|
|
|
55
55
|
ota_update_id?: string | null
|
|
56
56
|
ota_update_runtime_version?: string | null
|
|
57
57
|
ota_updates_enabled?: boolean | null
|
|
58
|
-
sdk_name
|
|
59
|
-
sdk_version?: string
|
|
58
|
+
sdk_name?: string | null
|
|
59
|
+
sdk_version?: string | null
|
|
60
60
|
started_at?: string
|
|
61
61
|
token: string
|
|
62
62
|
token_expires_at: string
|
|
@@ -80,8 +80,8 @@ export type Database = {
|
|
|
80
80
|
ota_update_id?: string | null
|
|
81
81
|
ota_update_runtime_version?: string | null
|
|
82
82
|
ota_updates_enabled?: boolean | null
|
|
83
|
-
sdk_name?: string
|
|
84
|
-
sdk_version?: string
|
|
83
|
+
sdk_name?: string | null
|
|
84
|
+
sdk_version?: string | null
|
|
85
85
|
started_at?: string
|
|
86
86
|
token?: string
|
|
87
87
|
token_expires_at?: string
|
|
@@ -1107,6 +1107,16 @@ export type Database = {
|
|
|
1107
1107
|
Args: { p_project_id: string }
|
|
1108
1108
|
Returns: undefined
|
|
1109
1109
|
}
|
|
1110
|
+
get_admin_stats: {
|
|
1111
|
+
Args: { top_n?: number }
|
|
1112
|
+
Returns: Database["public"]["CompositeTypes"]["admin_stats_result"]
|
|
1113
|
+
SetofOptions: {
|
|
1114
|
+
from: "*"
|
|
1115
|
+
to: "admin_stats_result"
|
|
1116
|
+
isOneToOne: true
|
|
1117
|
+
isSetofReturn: false
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1110
1120
|
resolve_project_id_from_session: {
|
|
1111
1121
|
Args: { _env_id: string; _version_id: string }
|
|
1112
1122
|
Returns: string
|
|
@@ -1124,6 +1134,7 @@ export type Database = {
|
|
|
1124
1134
|
device_id: string
|
|
1125
1135
|
device_platform: string
|
|
1126
1136
|
session_id: string
|
|
1137
|
+
user_id: string
|
|
1127
1138
|
version_build_id: string
|
|
1128
1139
|
version_id: string
|
|
1129
1140
|
version_name: string
|
|
@@ -1198,7 +1209,23 @@ export type Database = {
|
|
|
1198
1209
|
| "UPDATE_REQUIRED"
|
|
1199
1210
|
}
|
|
1200
1211
|
CompositeTypes: {
|
|
1201
|
-
|
|
1212
|
+
admin_stats_result: {
|
|
1213
|
+
total_orgs: number | null
|
|
1214
|
+
total_projects: number | null
|
|
1215
|
+
total_users: number | null
|
|
1216
|
+
total_sessions: number | null
|
|
1217
|
+
top_orgs:
|
|
1218
|
+
| Database["public"]["CompositeTypes"]["admin_top_org_stats"][]
|
|
1219
|
+
| null
|
|
1220
|
+
}
|
|
1221
|
+
admin_top_org_stats: {
|
|
1222
|
+
id: string | null
|
|
1223
|
+
name: string | null
|
|
1224
|
+
slug: string | null
|
|
1225
|
+
project_count: number | null
|
|
1226
|
+
session_count: number | null
|
|
1227
|
+
last_active: string | null
|
|
1228
|
+
}
|
|
1202
1229
|
}
|
|
1203
1230
|
}
|
|
1204
1231
|
}
|
package/src/index.ts
CHANGED
|
@@ -45,5 +45,8 @@ export type Result<Success, Error = string> = SuccessResult<Success> | ErrorResu
|
|
|
45
45
|
*/
|
|
46
46
|
export type AsyncResult<Success, Error = string> = Promise<Result<Success, Error>>;
|
|
47
47
|
|
|
48
|
+
// Export Eden Treaty types for query utilities
|
|
49
|
+
export * from "./eden-treaty.types";
|
|
50
|
+
|
|
48
51
|
// Export Service class and related types
|
|
49
52
|
export { type LoggingContext, Service } from "./interfaces/service.interface";
|
package/tsconfig.lib.json
CHANGED