@teardown/schemas 0.1.21 → 0.1.23
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 +49 -52
- package/src/common/primitives.ts +21 -0
- package/src/common/responses.ts +25 -0
- package/{dist/common/type-checks.d.ts → src/common/type-checks.ts} +23 -4
- package/{dist/index.js → src/index.ts} +1 -0
- package/src/modules/analytics/schemas.ts +178 -0
- package/src/modules/builds/schemas.ts +171 -0
- package/src/modules/devices/schemas.ts +196 -0
- package/src/modules/environment/schemas.ts +81 -0
- package/src/modules/events/index.ts +2 -0
- package/src/modules/events/schemas.ts +129 -0
- package/src/modules/identify/schemas.ts +257 -0
- package/src/modules/me/schemas.ts +87 -0
- package/src/modules/orgs/schemas.ts +260 -0
- package/src/modules/personas/schemas.ts +123 -0
- package/src/modules/projects/schemas.ts +179 -0
- package/src/modules/sessions/schemas.ts +158 -0
- package/src/modules/versions/schemas.ts +192 -0
- package/dist/common/index.js +0 -3
- package/dist/common/primitives.d.ts +0 -11
- package/dist/common/primitives.js +0 -8
- package/dist/common/responses.d.ts +0 -27
- package/dist/common/responses.js +0 -13
- package/dist/common/type-checks.js +0 -1
- package/dist/index.d.ts +0 -13
- package/dist/modules/analytics/schemas.d.ts +0 -239
- package/dist/modules/analytics/schemas.js +0 -136
- package/dist/modules/builds/schemas.d.ts +0 -248
- package/dist/modules/builds/schemas.js +0 -137
- package/dist/modules/devices/schemas.d.ts +0 -207
- package/dist/modules/devices/schemas.js +0 -165
- package/dist/modules/environment/schemas.d.ts +0 -56
- package/dist/modules/environment/schemas.js +0 -57
- package/dist/modules/events/schemas.d.ts +0 -138
- package/dist/modules/events/schemas.js +0 -116
- package/dist/modules/identify/index.js +0 -1
- package/dist/modules/identify/schemas.d.ts +0 -377
- package/dist/modules/identify/schemas.js +0 -221
- package/dist/modules/index.js +0 -12
- package/dist/modules/me/index.d.ts +0 -1
- package/dist/modules/me/index.js +0 -1
- package/dist/modules/me/schemas.d.ts +0 -75
- package/dist/modules/me/schemas.js +0 -76
- package/dist/modules/orgs/index.d.ts +0 -1
- package/dist/modules/orgs/index.js +0 -1
- package/dist/modules/orgs/schemas.d.ts +0 -308
- package/dist/modules/orgs/schemas.js +0 -214
- package/dist/modules/personas/index.d.ts +0 -1
- package/dist/modules/personas/index.js +0 -1
- package/dist/modules/personas/schemas.d.ts +0 -170
- package/dist/modules/personas/schemas.js +0 -100
- package/dist/modules/projects/index.d.ts +0 -1
- package/dist/modules/projects/index.js +0 -1
- package/dist/modules/projects/schemas.d.ts +0 -222
- package/dist/modules/projects/schemas.js +0 -145
- package/dist/modules/sessions/index.d.ts +0 -1
- package/dist/modules/sessions/index.js +0 -1
- package/dist/modules/sessions/schemas.d.ts +0 -258
- package/dist/modules/sessions/schemas.js +0 -128
- package/dist/modules/versions/index.d.ts +0 -1
- package/dist/modules/versions/index.js +0 -1
- package/dist/modules/versions/schemas.d.ts +0 -248
- package/dist/modules/versions/schemas.js +0 -155
- /package/{dist/common/index.d.ts → src/common/index.ts} +0 -0
- /package/{dist/modules/analytics/index.d.ts → src/modules/analytics/index.ts} +0 -0
- /package/{dist/modules/analytics/index.js → src/modules/builds/index.ts} +0 -0
- /package/{dist/modules/builds/index.d.ts → src/modules/devices/index.ts} +0 -0
- /package/{dist/modules/builds/index.js → src/modules/environment/index.ts} +0 -0
- /package/{dist/modules/devices/index.d.ts → src/modules/identify/index.ts} +0 -0
- /package/{dist/modules/index.d.ts → src/modules/index.ts} +0 -0
- /package/{dist/modules/devices/index.js → src/modules/me/index.ts} +0 -0
- /package/{dist/modules/environment/index.d.ts → src/modules/orgs/index.ts} +0 -0
- /package/{dist/modules/environment/index.js → src/modules/personas/index.ts} +0 -0
- /package/{dist/modules/events/index.d.ts → src/modules/projects/index.ts} +0 -0
- /package/{dist/modules/events/index.js → src/modules/sessions/index.ts} +0 -0
- /package/{dist/modules/identify/index.d.ts → src/modules/versions/index.ts} +0 -0
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { VersionBuildStatusEnum } from "@teardown/types";
|
|
2
|
-
import { Type } from "@sinclair/typebox";
|
|
3
|
-
import { DevicePlatformSchema } from "../devices/schemas";
|
|
4
|
-
/**
|
|
5
|
-
* Build status enum matching database (reuses VersionBuildStatusEnum)
|
|
6
|
-
*/
|
|
7
|
-
export const BuildStatusSchema = Type.Enum(VersionBuildStatusEnum);
|
|
8
|
-
/**
|
|
9
|
-
* Base build schema
|
|
10
|
-
* Represents version_builds table structure
|
|
11
|
-
*/
|
|
12
|
-
export const BuildSchema = Type.Object({
|
|
13
|
-
id: Type.String({ format: "uuid" }),
|
|
14
|
-
version_id: Type.String({ format: "uuid" }),
|
|
15
|
-
build_number: Type.Integer({ minimum: 0 }),
|
|
16
|
-
name: Type.Union([Type.String(), Type.Null()]),
|
|
17
|
-
summary: Type.Union([Type.String(), Type.Null()]),
|
|
18
|
-
commit_sha: Type.Union([Type.String(), Type.Null()]),
|
|
19
|
-
platform: DevicePlatformSchema,
|
|
20
|
-
status: BuildStatusSchema,
|
|
21
|
-
fingerprint: Type.Union([Type.String(), Type.Null()]),
|
|
22
|
-
created_at: Type.String(),
|
|
23
|
-
updated_at: Type.String(),
|
|
24
|
-
});
|
|
25
|
-
/**
|
|
26
|
-
* Build params schema
|
|
27
|
-
*/
|
|
28
|
-
export const BuildParamsSchema = Type.Object({
|
|
29
|
-
build_id: Type.String({ format: "uuid" }),
|
|
30
|
-
});
|
|
31
|
-
/**
|
|
32
|
-
* Search builds query schema
|
|
33
|
-
* Supports pagination, search, and sorting
|
|
34
|
-
*/
|
|
35
|
-
export const SearchBuildsQuerySchema = Type.Object({
|
|
36
|
-
project_id: Type.String({ format: "uuid" }),
|
|
37
|
-
page: Type.Number({ minimum: 1, default: 1 }),
|
|
38
|
-
limit: Type.Number({ minimum: 1, maximum: 100, default: 20 }),
|
|
39
|
-
search: Type.Optional(Type.String()),
|
|
40
|
-
sort_by: Type.Union([
|
|
41
|
-
Type.Literal("created_at"),
|
|
42
|
-
Type.Literal("updated_at"),
|
|
43
|
-
Type.Literal("build_number"),
|
|
44
|
-
Type.Literal("platform"),
|
|
45
|
-
Type.Literal("name"),
|
|
46
|
-
], { default: "created_at" }),
|
|
47
|
-
sort_order: Type.Union([Type.Literal("asc"), Type.Literal("desc")], { default: "desc" }),
|
|
48
|
-
});
|
|
49
|
-
/**
|
|
50
|
-
* Search builds query schema without project_id (injected from headers)
|
|
51
|
-
*/
|
|
52
|
-
export const SearchBuildsQueryParamsSchema = Type.Omit(SearchBuildsQuerySchema, ["project_id"]);
|
|
53
|
-
/**
|
|
54
|
-
* Builds by IDs request schema
|
|
55
|
-
*/
|
|
56
|
-
export const BuildsByIdsSchema = Type.Object({
|
|
57
|
-
build_ids: Type.Array(Type.String({ format: "uuid" }), { minItems: 1, maxItems: 100 }),
|
|
58
|
-
});
|
|
59
|
-
/**
|
|
60
|
-
* Paginated builds response schema
|
|
61
|
-
*/
|
|
62
|
-
export const BuildsResponseSchema = Type.Object({
|
|
63
|
-
builds: Type.Array(BuildSchema),
|
|
64
|
-
pagination: Type.Object({
|
|
65
|
-
page: Type.Integer({ minimum: 1 }),
|
|
66
|
-
limit: Type.Integer({ minimum: 1 }),
|
|
67
|
-
total: Type.Integer({ minimum: 0 }),
|
|
68
|
-
total_pages: Type.Integer({ minimum: 0 }),
|
|
69
|
-
}),
|
|
70
|
-
});
|
|
71
|
-
/**
|
|
72
|
-
* Single build response schema
|
|
73
|
-
*/
|
|
74
|
-
export const BuildResponseSchema = Type.Object({
|
|
75
|
-
success: Type.Literal(true),
|
|
76
|
-
data: BuildSchema,
|
|
77
|
-
});
|
|
78
|
-
/**
|
|
79
|
-
* Build error response schema
|
|
80
|
-
* Discriminated union by error code
|
|
81
|
-
*/
|
|
82
|
-
export const BuildErrorSchema = Type.Union([
|
|
83
|
-
Type.Object({
|
|
84
|
-
code: Type.Literal("BUILD_NOT_FOUND"),
|
|
85
|
-
message: Type.String(),
|
|
86
|
-
}),
|
|
87
|
-
Type.Object({
|
|
88
|
-
code: Type.Literal("PROJECT_NOT_FOUND"),
|
|
89
|
-
message: Type.String(),
|
|
90
|
-
}),
|
|
91
|
-
Type.Object({
|
|
92
|
-
code: Type.Literal("FORBIDDEN"),
|
|
93
|
-
message: Type.String(),
|
|
94
|
-
}),
|
|
95
|
-
Type.Object({
|
|
96
|
-
code: Type.Literal("FETCH_FAILED"),
|
|
97
|
-
message: Type.String(),
|
|
98
|
-
}),
|
|
99
|
-
Type.Object({
|
|
100
|
-
code: Type.Literal("INVALID_PARAMS"),
|
|
101
|
-
message: Type.String(),
|
|
102
|
-
}),
|
|
103
|
-
]);
|
|
104
|
-
/**
|
|
105
|
-
* Build error response wrapper
|
|
106
|
-
*/
|
|
107
|
-
export const BuildErrorResponseSchema = Type.Object({
|
|
108
|
-
success: Type.Literal(false),
|
|
109
|
-
error: BuildErrorSchema,
|
|
110
|
-
});
|
|
111
|
-
/**
|
|
112
|
-
* Build request response schema
|
|
113
|
-
*/
|
|
114
|
-
export const BuildRequestResponseSchema = Type.Union([BuildResponseSchema, BuildErrorResponseSchema]);
|
|
115
|
-
/**
|
|
116
|
-
* Update build status request body schema
|
|
117
|
-
*/
|
|
118
|
-
export const UpdateBuildStatusBodySchema = Type.Object({
|
|
119
|
-
status: BuildStatusSchema,
|
|
120
|
-
});
|
|
121
|
-
/**
|
|
122
|
-
* Add UPDATE_FAILED error code for update operations
|
|
123
|
-
*/
|
|
124
|
-
export const BuildErrorSchemaWithUpdate = Type.Union([
|
|
125
|
-
BuildErrorSchema,
|
|
126
|
-
Type.Object({
|
|
127
|
-
code: Type.Literal("UPDATE_FAILED"),
|
|
128
|
-
message: Type.String(),
|
|
129
|
-
}),
|
|
130
|
-
]);
|
|
131
|
-
/**
|
|
132
|
-
* Build error response wrapper with update error
|
|
133
|
-
*/
|
|
134
|
-
export const BuildErrorResponseWithUpdateSchema = Type.Object({
|
|
135
|
-
success: Type.Literal(false),
|
|
136
|
-
error: BuildErrorSchemaWithUpdate,
|
|
137
|
-
});
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import { type Static } from "@sinclair/typebox";
|
|
2
|
-
import { DevicePlatformEnum } from "@teardown/types";
|
|
3
|
-
import type { AssertSchemaCompatibleWithRow, AssertTrue } from "../../common";
|
|
4
|
-
/**
|
|
5
|
-
* Device platform enum matching database
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Device platform
|
|
9
|
-
*/
|
|
10
|
-
export declare const DevicePlatformSchema: import("@sinclair/typebox").TEnum<typeof DevicePlatformEnum>;
|
|
11
|
-
export type DevicePlatform = Static<typeof DevicePlatformSchema>;
|
|
12
|
-
/**
|
|
13
|
-
* Parse and validate a DevicePlatformEnum value
|
|
14
|
-
* Uses a switch statement to ensure type safety and runtime validation
|
|
15
|
-
* @param value - The value to parse
|
|
16
|
-
* @returns The validated DevicePlatformEnum value or null
|
|
17
|
-
* @throws Error if the value is not a valid DevicePlatformEnum and not null
|
|
18
|
-
*/
|
|
19
|
-
export declare function parseDevicePlatformEnum(value: unknown): DevicePlatformEnum | null;
|
|
20
|
-
/**
|
|
21
|
-
* Base device schema
|
|
22
|
-
* Represents devices table structure
|
|
23
|
-
*/
|
|
24
|
-
export declare const DeviceSchema: import("@sinclair/typebox").TObject<{
|
|
25
|
-
id: import("@sinclair/typebox").TString;
|
|
26
|
-
persona_id: import("@sinclair/typebox").TString;
|
|
27
|
-
environment_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
28
|
-
device_id: import("@sinclair/typebox").TString;
|
|
29
|
-
platform: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TEnum<typeof DevicePlatformEnum>, import("@sinclair/typebox").TNull]>;
|
|
30
|
-
os_type: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
31
|
-
os_name: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
32
|
-
device_name: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
33
|
-
device_brand: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
34
|
-
metadata: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>, import("@sinclair/typebox").TNull]>;
|
|
35
|
-
created_at: import("@sinclair/typebox").TString;
|
|
36
|
-
updated_at: import("@sinclair/typebox").TString;
|
|
37
|
-
}>;
|
|
38
|
-
export type Device = Static<typeof DeviceSchema>;
|
|
39
|
-
/**
|
|
40
|
-
* Device params schema
|
|
41
|
-
*/
|
|
42
|
-
export declare const DeviceParamsSchema: import("@sinclair/typebox").TObject<{
|
|
43
|
-
device_id: import("@sinclair/typebox").TString;
|
|
44
|
-
}>;
|
|
45
|
-
export type DeviceParams = Static<typeof DeviceParamsSchema>;
|
|
46
|
-
/**
|
|
47
|
-
* Search devices query schema
|
|
48
|
-
* Supports pagination, search, and sorting
|
|
49
|
-
*/
|
|
50
|
-
export declare const SearchDevicesQuerySchema: import("@sinclair/typebox").TObject<{
|
|
51
|
-
project_id: import("@sinclair/typebox").TString;
|
|
52
|
-
page: import("@sinclair/typebox").TNumber;
|
|
53
|
-
limit: import("@sinclair/typebox").TNumber;
|
|
54
|
-
search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
55
|
-
sort_by: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"created_at">, import("@sinclair/typebox").TLiteral<"updated_at">, import("@sinclair/typebox").TLiteral<"device_name">, import("@sinclair/typebox").TLiteral<"platform">, import("@sinclair/typebox").TLiteral<"os_name">]>;
|
|
56
|
-
sort_order: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"asc">, import("@sinclair/typebox").TLiteral<"desc">]>;
|
|
57
|
-
}>;
|
|
58
|
-
export type SearchDevicesQuery = Static<typeof SearchDevicesQuerySchema>;
|
|
59
|
-
/**
|
|
60
|
-
* Search devices query schema without project_id (injected from headers)
|
|
61
|
-
*/
|
|
62
|
-
export declare const SearchDevicesQueryParamsSchema: import("@sinclair/typebox").TObject<{
|
|
63
|
-
search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
64
|
-
limit: import("@sinclair/typebox").TNumber;
|
|
65
|
-
page: import("@sinclair/typebox").TNumber;
|
|
66
|
-
sort_by: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"created_at">, import("@sinclair/typebox").TLiteral<"updated_at">, import("@sinclair/typebox").TLiteral<"device_name">, import("@sinclair/typebox").TLiteral<"platform">, import("@sinclair/typebox").TLiteral<"os_name">]>;
|
|
67
|
-
sort_order: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"asc">, import("@sinclair/typebox").TLiteral<"desc">]>;
|
|
68
|
-
}>;
|
|
69
|
-
export type SearchDevicesQueryParams = Static<typeof SearchDevicesQueryParamsSchema>;
|
|
70
|
-
/**
|
|
71
|
-
* Devices by IDs request schema
|
|
72
|
-
*/
|
|
73
|
-
export declare const DevicesByIdsSchema: import("@sinclair/typebox").TObject<{
|
|
74
|
-
device_ids: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
|
|
75
|
-
}>;
|
|
76
|
-
export type DevicesByIds = Static<typeof DevicesByIdsSchema>;
|
|
77
|
-
/**
|
|
78
|
-
* Paginated devices response schema
|
|
79
|
-
*/
|
|
80
|
-
export declare const DevicesResponseSchema: import("@sinclair/typebox").TObject<{
|
|
81
|
-
devices: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
82
|
-
id: import("@sinclair/typebox").TString;
|
|
83
|
-
persona_id: import("@sinclair/typebox").TString;
|
|
84
|
-
environment_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
85
|
-
device_id: import("@sinclair/typebox").TString;
|
|
86
|
-
platform: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TEnum<typeof DevicePlatformEnum>, import("@sinclair/typebox").TNull]>;
|
|
87
|
-
os_type: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
88
|
-
os_name: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
89
|
-
device_name: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
90
|
-
device_brand: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
91
|
-
metadata: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>, import("@sinclair/typebox").TNull]>;
|
|
92
|
-
created_at: import("@sinclair/typebox").TString;
|
|
93
|
-
updated_at: import("@sinclair/typebox").TString;
|
|
94
|
-
}>>;
|
|
95
|
-
pagination: import("@sinclair/typebox").TObject<{
|
|
96
|
-
page: import("@sinclair/typebox").TInteger;
|
|
97
|
-
limit: import("@sinclair/typebox").TInteger;
|
|
98
|
-
total: import("@sinclair/typebox").TInteger;
|
|
99
|
-
total_pages: import("@sinclair/typebox").TInteger;
|
|
100
|
-
}>;
|
|
101
|
-
}>;
|
|
102
|
-
export type DevicesResponse = Static<typeof DevicesResponseSchema>;
|
|
103
|
-
/**
|
|
104
|
-
* Single device response schema
|
|
105
|
-
*/
|
|
106
|
-
export declare const DeviceResponseSchema: import("@sinclair/typebox").TObject<{
|
|
107
|
-
success: import("@sinclair/typebox").TLiteral<true>;
|
|
108
|
-
data: import("@sinclair/typebox").TObject<{
|
|
109
|
-
id: import("@sinclair/typebox").TString;
|
|
110
|
-
persona_id: import("@sinclair/typebox").TString;
|
|
111
|
-
environment_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
112
|
-
device_id: import("@sinclair/typebox").TString;
|
|
113
|
-
platform: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TEnum<typeof DevicePlatformEnum>, import("@sinclair/typebox").TNull]>;
|
|
114
|
-
os_type: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
115
|
-
os_name: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
116
|
-
device_name: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
117
|
-
device_brand: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
118
|
-
metadata: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>, import("@sinclair/typebox").TNull]>;
|
|
119
|
-
created_at: import("@sinclair/typebox").TString;
|
|
120
|
-
updated_at: import("@sinclair/typebox").TString;
|
|
121
|
-
}>;
|
|
122
|
-
}>;
|
|
123
|
-
export type DeviceResponse = Static<typeof DeviceResponseSchema>;
|
|
124
|
-
/**
|
|
125
|
-
* Device error response schema
|
|
126
|
-
* Discriminated union by error code
|
|
127
|
-
*/
|
|
128
|
-
export declare const DeviceErrorSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
129
|
-
code: import("@sinclair/typebox").TLiteral<"DEVICE_NOT_FOUND">;
|
|
130
|
-
message: import("@sinclair/typebox").TString;
|
|
131
|
-
}>, import("@sinclair/typebox").TObject<{
|
|
132
|
-
code: import("@sinclair/typebox").TLiteral<"PROJECT_NOT_FOUND">;
|
|
133
|
-
message: import("@sinclair/typebox").TString;
|
|
134
|
-
}>, import("@sinclair/typebox").TObject<{
|
|
135
|
-
code: import("@sinclair/typebox").TLiteral<"FORBIDDEN">;
|
|
136
|
-
message: import("@sinclair/typebox").TString;
|
|
137
|
-
}>, import("@sinclair/typebox").TObject<{
|
|
138
|
-
code: import("@sinclair/typebox").TLiteral<"FETCH_FAILED">;
|
|
139
|
-
message: import("@sinclair/typebox").TString;
|
|
140
|
-
}>, import("@sinclair/typebox").TObject<{
|
|
141
|
-
code: import("@sinclair/typebox").TLiteral<"INVALID_PARAMS">;
|
|
142
|
-
message: import("@sinclair/typebox").TString;
|
|
143
|
-
}>]>;
|
|
144
|
-
export type DeviceError = Static<typeof DeviceErrorSchema>;
|
|
145
|
-
/**
|
|
146
|
-
* Device error response wrapper
|
|
147
|
-
*/
|
|
148
|
-
export declare const DeviceErrorResponseSchema: import("@sinclair/typebox").TObject<{
|
|
149
|
-
success: import("@sinclair/typebox").TLiteral<false>;
|
|
150
|
-
error: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
151
|
-
code: import("@sinclair/typebox").TLiteral<"DEVICE_NOT_FOUND">;
|
|
152
|
-
message: import("@sinclair/typebox").TString;
|
|
153
|
-
}>, import("@sinclair/typebox").TObject<{
|
|
154
|
-
code: import("@sinclair/typebox").TLiteral<"PROJECT_NOT_FOUND">;
|
|
155
|
-
message: import("@sinclair/typebox").TString;
|
|
156
|
-
}>, import("@sinclair/typebox").TObject<{
|
|
157
|
-
code: import("@sinclair/typebox").TLiteral<"FORBIDDEN">;
|
|
158
|
-
message: import("@sinclair/typebox").TString;
|
|
159
|
-
}>, import("@sinclair/typebox").TObject<{
|
|
160
|
-
code: import("@sinclair/typebox").TLiteral<"FETCH_FAILED">;
|
|
161
|
-
message: import("@sinclair/typebox").TString;
|
|
162
|
-
}>, import("@sinclair/typebox").TObject<{
|
|
163
|
-
code: import("@sinclair/typebox").TLiteral<"INVALID_PARAMS">;
|
|
164
|
-
message: import("@sinclair/typebox").TString;
|
|
165
|
-
}>]>;
|
|
166
|
-
}>;
|
|
167
|
-
export type DeviceErrorResponse = Static<typeof DeviceErrorResponseSchema>;
|
|
168
|
-
/**
|
|
169
|
-
* Device request response schema
|
|
170
|
-
*/
|
|
171
|
-
export declare const DeviceRequestResponseSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
172
|
-
success: import("@sinclair/typebox").TLiteral<true>;
|
|
173
|
-
data: import("@sinclair/typebox").TObject<{
|
|
174
|
-
id: import("@sinclair/typebox").TString;
|
|
175
|
-
persona_id: import("@sinclair/typebox").TString;
|
|
176
|
-
environment_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
177
|
-
device_id: import("@sinclair/typebox").TString;
|
|
178
|
-
platform: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TEnum<typeof DevicePlatformEnum>, import("@sinclair/typebox").TNull]>;
|
|
179
|
-
os_type: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
180
|
-
os_name: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
181
|
-
device_name: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
182
|
-
device_brand: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
183
|
-
metadata: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>, import("@sinclair/typebox").TNull]>;
|
|
184
|
-
created_at: import("@sinclair/typebox").TString;
|
|
185
|
-
updated_at: import("@sinclair/typebox").TString;
|
|
186
|
-
}>;
|
|
187
|
-
}>, import("@sinclair/typebox").TObject<{
|
|
188
|
-
success: import("@sinclair/typebox").TLiteral<false>;
|
|
189
|
-
error: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
190
|
-
code: import("@sinclair/typebox").TLiteral<"DEVICE_NOT_FOUND">;
|
|
191
|
-
message: import("@sinclair/typebox").TString;
|
|
192
|
-
}>, import("@sinclair/typebox").TObject<{
|
|
193
|
-
code: import("@sinclair/typebox").TLiteral<"PROJECT_NOT_FOUND">;
|
|
194
|
-
message: import("@sinclair/typebox").TString;
|
|
195
|
-
}>, import("@sinclair/typebox").TObject<{
|
|
196
|
-
code: import("@sinclair/typebox").TLiteral<"FORBIDDEN">;
|
|
197
|
-
message: import("@sinclair/typebox").TString;
|
|
198
|
-
}>, import("@sinclair/typebox").TObject<{
|
|
199
|
-
code: import("@sinclair/typebox").TLiteral<"FETCH_FAILED">;
|
|
200
|
-
message: import("@sinclair/typebox").TString;
|
|
201
|
-
}>, import("@sinclair/typebox").TObject<{
|
|
202
|
-
code: import("@sinclair/typebox").TLiteral<"INVALID_PARAMS">;
|
|
203
|
-
message: import("@sinclair/typebox").TString;
|
|
204
|
-
}>]>;
|
|
205
|
-
}>]>;
|
|
206
|
-
export type DeviceRequestResponse = Static<typeof DeviceRequestResponseSchema>;
|
|
207
|
-
export type _CheckDeviceRow = AssertTrue<AssertSchemaCompatibleWithRow<Device, "devices">>;
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { Type } from "@sinclair/typebox";
|
|
2
|
-
import { DevicePlatformEnum } from "@teardown/types";
|
|
3
|
-
/**
|
|
4
|
-
* Device platform enum matching database
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Device platform
|
|
8
|
-
*/
|
|
9
|
-
export const DevicePlatformSchema = Type.Enum(DevicePlatformEnum, { error: "platform is required" });
|
|
10
|
-
/**
|
|
11
|
-
* Parse and validate a DevicePlatformEnum value
|
|
12
|
-
* Uses a switch statement to ensure type safety and runtime validation
|
|
13
|
-
* @param value - The value to parse
|
|
14
|
-
* @returns The validated DevicePlatformEnum value or null
|
|
15
|
-
* @throws Error if the value is not a valid DevicePlatformEnum and not null
|
|
16
|
-
*/
|
|
17
|
-
export function parseDevicePlatformEnum(value) {
|
|
18
|
-
if (value === null || value === undefined) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
switch (value) {
|
|
22
|
-
case DevicePlatformEnum.IOS:
|
|
23
|
-
return DevicePlatformEnum.IOS;
|
|
24
|
-
case DevicePlatformEnum.ANDROID:
|
|
25
|
-
return DevicePlatformEnum.ANDROID;
|
|
26
|
-
case DevicePlatformEnum.WEB:
|
|
27
|
-
return DevicePlatformEnum.WEB;
|
|
28
|
-
case DevicePlatformEnum.WINDOWS:
|
|
29
|
-
return DevicePlatformEnum.WINDOWS;
|
|
30
|
-
case DevicePlatformEnum.MACOS:
|
|
31
|
-
return DevicePlatformEnum.MACOS;
|
|
32
|
-
case DevicePlatformEnum.LINUX:
|
|
33
|
-
return DevicePlatformEnum.LINUX;
|
|
34
|
-
case DevicePlatformEnum.PHONE:
|
|
35
|
-
return DevicePlatformEnum.PHONE;
|
|
36
|
-
case DevicePlatformEnum.TABLET:
|
|
37
|
-
return DevicePlatformEnum.TABLET;
|
|
38
|
-
case DevicePlatformEnum.DESKTOP:
|
|
39
|
-
return DevicePlatformEnum.DESKTOP;
|
|
40
|
-
case DevicePlatformEnum.CONSOLE:
|
|
41
|
-
return DevicePlatformEnum.CONSOLE;
|
|
42
|
-
case DevicePlatformEnum.TV:
|
|
43
|
-
return DevicePlatformEnum.TV;
|
|
44
|
-
case DevicePlatformEnum.WEARABLE:
|
|
45
|
-
return DevicePlatformEnum.WEARABLE;
|
|
46
|
-
case DevicePlatformEnum.GAME_CONSOLE:
|
|
47
|
-
return DevicePlatformEnum.GAME_CONSOLE;
|
|
48
|
-
case DevicePlatformEnum.VR:
|
|
49
|
-
return DevicePlatformEnum.VR;
|
|
50
|
-
case DevicePlatformEnum.UNKNOWN:
|
|
51
|
-
return DevicePlatformEnum.UNKNOWN;
|
|
52
|
-
case DevicePlatformEnum.OTHER:
|
|
53
|
-
return DevicePlatformEnum.OTHER;
|
|
54
|
-
default:
|
|
55
|
-
throw new Error(`Invalid DevicePlatformEnum value: ${value}. Expected one of: ${Object.values(DevicePlatformEnum).join(", ")}`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Base device schema
|
|
60
|
-
* Represents devices table structure
|
|
61
|
-
*/
|
|
62
|
-
export const DeviceSchema = Type.Object({
|
|
63
|
-
id: Type.String({ format: "uuid" }),
|
|
64
|
-
persona_id: Type.String({ format: "uuid" }),
|
|
65
|
-
environment_id: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
|
|
66
|
-
device_id: Type.String(),
|
|
67
|
-
platform: Type.Union([DevicePlatformSchema, Type.Null()]),
|
|
68
|
-
os_type: Type.Union([Type.String(), Type.Null()]),
|
|
69
|
-
os_name: Type.Union([Type.String(), Type.Null()]),
|
|
70
|
-
device_name: Type.Union([Type.String(), Type.Null()]),
|
|
71
|
-
device_brand: Type.Union([Type.String(), Type.Null()]),
|
|
72
|
-
metadata: Type.Union([Type.Record(Type.String(), Type.Unknown()), Type.Null()]),
|
|
73
|
-
created_at: Type.String(),
|
|
74
|
-
updated_at: Type.String(),
|
|
75
|
-
});
|
|
76
|
-
/**
|
|
77
|
-
* Device params schema
|
|
78
|
-
*/
|
|
79
|
-
export const DeviceParamsSchema = Type.Object({
|
|
80
|
-
device_id: Type.String({ format: "uuid" }),
|
|
81
|
-
});
|
|
82
|
-
/**
|
|
83
|
-
* Search devices query schema
|
|
84
|
-
* Supports pagination, search, and sorting
|
|
85
|
-
*/
|
|
86
|
-
export const SearchDevicesQuerySchema = Type.Object({
|
|
87
|
-
project_id: Type.String({ format: "uuid" }),
|
|
88
|
-
page: Type.Number({ minimum: 1, default: 1 }),
|
|
89
|
-
limit: Type.Number({ minimum: 1, maximum: 100, default: 20 }),
|
|
90
|
-
search: Type.Optional(Type.String()),
|
|
91
|
-
sort_by: Type.Union([
|
|
92
|
-
Type.Literal("created_at"),
|
|
93
|
-
Type.Literal("updated_at"),
|
|
94
|
-
Type.Literal("device_name"),
|
|
95
|
-
Type.Literal("platform"),
|
|
96
|
-
Type.Literal("os_name"),
|
|
97
|
-
], { default: "created_at" }),
|
|
98
|
-
sort_order: Type.Union([Type.Literal("asc"), Type.Literal("desc")], { default: "desc" }),
|
|
99
|
-
});
|
|
100
|
-
/**
|
|
101
|
-
* Search devices query schema without project_id (injected from headers)
|
|
102
|
-
*/
|
|
103
|
-
export const SearchDevicesQueryParamsSchema = Type.Omit(SearchDevicesQuerySchema, ["project_id"]);
|
|
104
|
-
/**
|
|
105
|
-
* Devices by IDs request schema
|
|
106
|
-
*/
|
|
107
|
-
export const DevicesByIdsSchema = Type.Object({
|
|
108
|
-
device_ids: Type.Array(Type.String({ format: "uuid" }), { minItems: 1, maxItems: 100 }),
|
|
109
|
-
});
|
|
110
|
-
/**
|
|
111
|
-
* Paginated devices response schema
|
|
112
|
-
*/
|
|
113
|
-
export const DevicesResponseSchema = Type.Object({
|
|
114
|
-
devices: Type.Array(DeviceSchema),
|
|
115
|
-
pagination: Type.Object({
|
|
116
|
-
page: Type.Integer({ minimum: 1 }),
|
|
117
|
-
limit: Type.Integer({ minimum: 1 }),
|
|
118
|
-
total: Type.Integer({ minimum: 0 }),
|
|
119
|
-
total_pages: Type.Integer({ minimum: 0 }),
|
|
120
|
-
}),
|
|
121
|
-
});
|
|
122
|
-
/**
|
|
123
|
-
* Single device response schema
|
|
124
|
-
*/
|
|
125
|
-
export const DeviceResponseSchema = Type.Object({
|
|
126
|
-
success: Type.Literal(true),
|
|
127
|
-
data: DeviceSchema,
|
|
128
|
-
});
|
|
129
|
-
/**
|
|
130
|
-
* Device error response schema
|
|
131
|
-
* Discriminated union by error code
|
|
132
|
-
*/
|
|
133
|
-
export const DeviceErrorSchema = Type.Union([
|
|
134
|
-
Type.Object({
|
|
135
|
-
code: Type.Literal("DEVICE_NOT_FOUND"),
|
|
136
|
-
message: Type.String(),
|
|
137
|
-
}),
|
|
138
|
-
Type.Object({
|
|
139
|
-
code: Type.Literal("PROJECT_NOT_FOUND"),
|
|
140
|
-
message: Type.String(),
|
|
141
|
-
}),
|
|
142
|
-
Type.Object({
|
|
143
|
-
code: Type.Literal("FORBIDDEN"),
|
|
144
|
-
message: Type.String(),
|
|
145
|
-
}),
|
|
146
|
-
Type.Object({
|
|
147
|
-
code: Type.Literal("FETCH_FAILED"),
|
|
148
|
-
message: Type.String(),
|
|
149
|
-
}),
|
|
150
|
-
Type.Object({
|
|
151
|
-
code: Type.Literal("INVALID_PARAMS"),
|
|
152
|
-
message: Type.String(),
|
|
153
|
-
}),
|
|
154
|
-
]);
|
|
155
|
-
/**
|
|
156
|
-
* Device error response wrapper
|
|
157
|
-
*/
|
|
158
|
-
export const DeviceErrorResponseSchema = Type.Object({
|
|
159
|
-
success: Type.Literal(false),
|
|
160
|
-
error: DeviceErrorSchema,
|
|
161
|
-
});
|
|
162
|
-
/**
|
|
163
|
-
* Device request response schema
|
|
164
|
-
*/
|
|
165
|
-
export const DeviceRequestResponseSchema = Type.Union([DeviceResponseSchema, DeviceErrorResponseSchema]);
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { type Static } from "@sinclair/typebox";
|
|
2
|
-
import { EnvironmentTypeEnum } from "@teardown/types";
|
|
3
|
-
import type { AssertSchemaCompatibleWithInsert, AssertSchemaCompatibleWithRow, AssertSchemaCompatibleWithUpdate, AssertTrue } from "../../common";
|
|
4
|
-
/**
|
|
5
|
-
* Environment type enum (re-exported for backward compatibility)
|
|
6
|
-
* @deprecated Use EnvironmentTypeEnum from @teardown/types instead
|
|
7
|
-
*/
|
|
8
|
-
export { EnvironmentTypeEnum as EnvironmentType };
|
|
9
|
-
/**
|
|
10
|
-
* Environment schema
|
|
11
|
-
* Represents an environment within a project
|
|
12
|
-
*/
|
|
13
|
-
export declare const EnvironmentSchema: import("@sinclair/typebox").TObject<{
|
|
14
|
-
id: import("@sinclair/typebox").TString;
|
|
15
|
-
project_id: import("@sinclair/typebox").TString;
|
|
16
|
-
name: import("@sinclair/typebox").TString;
|
|
17
|
-
slug: import("@sinclair/typebox").TString;
|
|
18
|
-
type: import("@sinclair/typebox").TEnum<typeof EnvironmentTypeEnum>;
|
|
19
|
-
created_at: import("@sinclair/typebox").TString;
|
|
20
|
-
updated_at: import("@sinclair/typebox").TString;
|
|
21
|
-
}>;
|
|
22
|
-
/**
|
|
23
|
-
* Parse and validate an EnvironmentTypeEnum value
|
|
24
|
-
* Uses a switch statement to ensure type safety and runtime validation
|
|
25
|
-
* @param value - The value to parse
|
|
26
|
-
* @returns The validated EnvironmentTypeEnum value
|
|
27
|
-
* @throws Error if the value is not a valid EnvironmentTypeEnum
|
|
28
|
-
*/
|
|
29
|
-
export declare function parseEnvironmentTypeEnum(value: unknown): EnvironmentTypeEnum;
|
|
30
|
-
/**
|
|
31
|
-
* Create environment schema
|
|
32
|
-
* Used for creating new environments
|
|
33
|
-
*/
|
|
34
|
-
export declare const CreateEnvironmentSchema: import("@sinclair/typebox").TObject<{
|
|
35
|
-
project_id: import("@sinclair/typebox").TString;
|
|
36
|
-
name: import("@sinclair/typebox").TString;
|
|
37
|
-
slug: import("@sinclair/typebox").TString;
|
|
38
|
-
type: import("@sinclair/typebox").TEnum<typeof EnvironmentTypeEnum>;
|
|
39
|
-
}>;
|
|
40
|
-
/**
|
|
41
|
-
* Update environment schema
|
|
42
|
-
* Used for updating existing environments
|
|
43
|
-
*/
|
|
44
|
-
export declare const UpdateEnvironmentSchema: import("@sinclair/typebox").TObject<{
|
|
45
|
-
name: import("@sinclair/typebox").TString;
|
|
46
|
-
type: import("@sinclair/typebox").TEnum<typeof EnvironmentTypeEnum>;
|
|
47
|
-
}>;
|
|
48
|
-
/**
|
|
49
|
-
* TypeScript types inferred from schemas
|
|
50
|
-
*/
|
|
51
|
-
export type Environment = Static<typeof EnvironmentSchema>;
|
|
52
|
-
export type CreateEnvironment = Static<typeof CreateEnvironmentSchema>;
|
|
53
|
-
export type UpdateEnvironment = Static<typeof UpdateEnvironmentSchema>;
|
|
54
|
-
export type _CheckEnvironmentRow = AssertTrue<AssertSchemaCompatibleWithRow<Environment, "environments">>;
|
|
55
|
-
export type _CheckCreateEnvironment = AssertTrue<AssertSchemaCompatibleWithInsert<CreateEnvironment, "environments">>;
|
|
56
|
-
export type _CheckUpdateEnvironment = AssertTrue<AssertSchemaCompatibleWithUpdate<UpdateEnvironment, "environments">>;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { Type } from "@sinclair/typebox";
|
|
2
|
-
import { EnvironmentTypeEnum } from "@teardown/types";
|
|
3
|
-
/**
|
|
4
|
-
* Environment type enum (re-exported for backward compatibility)
|
|
5
|
-
* @deprecated Use EnvironmentTypeEnum from @teardown/types instead
|
|
6
|
-
*/
|
|
7
|
-
export { EnvironmentTypeEnum as EnvironmentType };
|
|
8
|
-
/**
|
|
9
|
-
* Environment schema
|
|
10
|
-
* Represents an environment within a project
|
|
11
|
-
*/
|
|
12
|
-
export const EnvironmentSchema = Type.Object({
|
|
13
|
-
id: Type.String({ format: "uuid" }),
|
|
14
|
-
project_id: Type.String({ format: "uuid" }),
|
|
15
|
-
name: Type.String({ minLength: 1 }),
|
|
16
|
-
slug: Type.String({ minLength: 1 }),
|
|
17
|
-
type: Type.Enum(EnvironmentTypeEnum),
|
|
18
|
-
created_at: Type.String(),
|
|
19
|
-
updated_at: Type.String(),
|
|
20
|
-
});
|
|
21
|
-
/**
|
|
22
|
-
* Parse and validate an EnvironmentTypeEnum value
|
|
23
|
-
* Uses a switch statement to ensure type safety and runtime validation
|
|
24
|
-
* @param value - The value to parse
|
|
25
|
-
* @returns The validated EnvironmentTypeEnum value
|
|
26
|
-
* @throws Error if the value is not a valid EnvironmentTypeEnum
|
|
27
|
-
*/
|
|
28
|
-
export function parseEnvironmentTypeEnum(value) {
|
|
29
|
-
switch (value) {
|
|
30
|
-
case EnvironmentTypeEnum.DEVELOPMENT:
|
|
31
|
-
return EnvironmentTypeEnum.DEVELOPMENT;
|
|
32
|
-
case EnvironmentTypeEnum.STAGING:
|
|
33
|
-
return EnvironmentTypeEnum.STAGING;
|
|
34
|
-
case EnvironmentTypeEnum.PRODUCTION:
|
|
35
|
-
return EnvironmentTypeEnum.PRODUCTION;
|
|
36
|
-
default:
|
|
37
|
-
throw new Error(`Invalid EnvironmentTypeEnum value: ${value}. Expected one of: ${Object.values(EnvironmentTypeEnum).join(", ")}`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Create environment schema
|
|
42
|
-
* Used for creating new environments
|
|
43
|
-
*/
|
|
44
|
-
export const CreateEnvironmentSchema = Type.Object({
|
|
45
|
-
project_id: Type.String({ format: "uuid" }),
|
|
46
|
-
name: Type.String({ minLength: 1 }),
|
|
47
|
-
slug: Type.String({ minLength: 1 }),
|
|
48
|
-
type: Type.Enum(EnvironmentTypeEnum),
|
|
49
|
-
});
|
|
50
|
-
/**
|
|
51
|
-
* Update environment schema
|
|
52
|
-
* Used for updating existing environments
|
|
53
|
-
*/
|
|
54
|
-
export const UpdateEnvironmentSchema = Type.Object({
|
|
55
|
-
name: Type.String({ minLength: 1 }),
|
|
56
|
-
type: Type.Enum(EnvironmentTypeEnum),
|
|
57
|
-
});
|