@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.
Files changed (76) hide show
  1. package/package.json +49 -52
  2. package/src/common/primitives.ts +21 -0
  3. package/src/common/responses.ts +25 -0
  4. package/{dist/common/type-checks.d.ts → src/common/type-checks.ts} +23 -4
  5. package/{dist/index.js → src/index.ts} +1 -0
  6. package/src/modules/analytics/schemas.ts +178 -0
  7. package/src/modules/builds/schemas.ts +171 -0
  8. package/src/modules/devices/schemas.ts +196 -0
  9. package/src/modules/environment/schemas.ts +81 -0
  10. package/src/modules/events/index.ts +2 -0
  11. package/src/modules/events/schemas.ts +129 -0
  12. package/src/modules/identify/schemas.ts +257 -0
  13. package/src/modules/me/schemas.ts +87 -0
  14. package/src/modules/orgs/schemas.ts +260 -0
  15. package/src/modules/personas/schemas.ts +123 -0
  16. package/src/modules/projects/schemas.ts +179 -0
  17. package/src/modules/sessions/schemas.ts +158 -0
  18. package/src/modules/versions/schemas.ts +192 -0
  19. package/dist/common/index.js +0 -3
  20. package/dist/common/primitives.d.ts +0 -11
  21. package/dist/common/primitives.js +0 -8
  22. package/dist/common/responses.d.ts +0 -27
  23. package/dist/common/responses.js +0 -13
  24. package/dist/common/type-checks.js +0 -1
  25. package/dist/index.d.ts +0 -13
  26. package/dist/modules/analytics/schemas.d.ts +0 -239
  27. package/dist/modules/analytics/schemas.js +0 -136
  28. package/dist/modules/builds/schemas.d.ts +0 -248
  29. package/dist/modules/builds/schemas.js +0 -137
  30. package/dist/modules/devices/schemas.d.ts +0 -207
  31. package/dist/modules/devices/schemas.js +0 -165
  32. package/dist/modules/environment/schemas.d.ts +0 -56
  33. package/dist/modules/environment/schemas.js +0 -57
  34. package/dist/modules/events/schemas.d.ts +0 -138
  35. package/dist/modules/events/schemas.js +0 -116
  36. package/dist/modules/identify/index.js +0 -1
  37. package/dist/modules/identify/schemas.d.ts +0 -377
  38. package/dist/modules/identify/schemas.js +0 -221
  39. package/dist/modules/index.js +0 -12
  40. package/dist/modules/me/index.d.ts +0 -1
  41. package/dist/modules/me/index.js +0 -1
  42. package/dist/modules/me/schemas.d.ts +0 -75
  43. package/dist/modules/me/schemas.js +0 -76
  44. package/dist/modules/orgs/index.d.ts +0 -1
  45. package/dist/modules/orgs/index.js +0 -1
  46. package/dist/modules/orgs/schemas.d.ts +0 -308
  47. package/dist/modules/orgs/schemas.js +0 -214
  48. package/dist/modules/personas/index.d.ts +0 -1
  49. package/dist/modules/personas/index.js +0 -1
  50. package/dist/modules/personas/schemas.d.ts +0 -170
  51. package/dist/modules/personas/schemas.js +0 -100
  52. package/dist/modules/projects/index.d.ts +0 -1
  53. package/dist/modules/projects/index.js +0 -1
  54. package/dist/modules/projects/schemas.d.ts +0 -222
  55. package/dist/modules/projects/schemas.js +0 -145
  56. package/dist/modules/sessions/index.d.ts +0 -1
  57. package/dist/modules/sessions/index.js +0 -1
  58. package/dist/modules/sessions/schemas.d.ts +0 -258
  59. package/dist/modules/sessions/schemas.js +0 -128
  60. package/dist/modules/versions/index.d.ts +0 -1
  61. package/dist/modules/versions/index.js +0 -1
  62. package/dist/modules/versions/schemas.d.ts +0 -248
  63. package/dist/modules/versions/schemas.js +0 -155
  64. /package/{dist/common/index.d.ts → src/common/index.ts} +0 -0
  65. /package/{dist/modules/analytics/index.d.ts → src/modules/analytics/index.ts} +0 -0
  66. /package/{dist/modules/analytics/index.js → src/modules/builds/index.ts} +0 -0
  67. /package/{dist/modules/builds/index.d.ts → src/modules/devices/index.ts} +0 -0
  68. /package/{dist/modules/builds/index.js → src/modules/environment/index.ts} +0 -0
  69. /package/{dist/modules/devices/index.d.ts → src/modules/identify/index.ts} +0 -0
  70. /package/{dist/modules/index.d.ts → src/modules/index.ts} +0 -0
  71. /package/{dist/modules/devices/index.js → src/modules/me/index.ts} +0 -0
  72. /package/{dist/modules/environment/index.d.ts → src/modules/orgs/index.ts} +0 -0
  73. /package/{dist/modules/environment/index.js → src/modules/personas/index.ts} +0 -0
  74. /package/{dist/modules/events/index.d.ts → src/modules/projects/index.ts} +0 -0
  75. /package/{dist/modules/events/index.js → src/modules/sessions/index.ts} +0 -0
  76. /package/{dist/modules/identify/index.d.ts → src/modules/versions/index.ts} +0 -0
@@ -1,155 +0,0 @@
1
- import { Type } from "@sinclair/typebox";
2
- import { VersionBuildStatusEnum } from "@teardown/types";
3
- /**
4
- * Version status enum matching database
5
- */
6
- export const VersionBuildStatusSchema = Type.Enum(VersionBuildStatusEnum);
7
- /**
8
- * Parse and validate a VersionBuildStatusEnum value
9
- * Uses a switch statement to ensure type safety and runtime validation
10
- * @param value - The value to parse
11
- * @returns The validated VersionBuildStatusEnum value
12
- * @throws Error if the value is not a valid VersionBuildStatusEnum
13
- */
14
- export function parseVersionStatusEnum(value) {
15
- switch (value) {
16
- case VersionBuildStatusEnum.SUPPORTED:
17
- return VersionBuildStatusEnum.SUPPORTED;
18
- case VersionBuildStatusEnum.UPDATE_AVAILABLE:
19
- return VersionBuildStatusEnum.UPDATE_AVAILABLE;
20
- case VersionBuildStatusEnum.UPDATE_RECOMMENDED:
21
- case VersionBuildStatusEnum.UPDATE_REQUIRED:
22
- return VersionBuildStatusEnum.UPDATE_REQUIRED;
23
- default:
24
- throw new Error(`Invalid VersionBuildStatusEnum value: ${value}. Expected one of: ${Object.values(VersionBuildStatusEnum).join(", ")}`);
25
- }
26
- }
27
- /**
28
- * Base version schema
29
- * Represents project_versions table structure
30
- */
31
- export const VersionSchema = Type.Object({
32
- id: Type.String({ format: "uuid" }),
33
- project_id: Type.String({ format: "uuid" }),
34
- name: Type.String(),
35
- major: Type.Number(), // Matches type number, not integer constraint (db type numeric)
36
- minor: Type.Number(),
37
- patch: Type.Number(),
38
- status: VersionBuildStatusSchema, // SUPPORTED, UPDATE_AVAILABLE, UPDATE_RECOMMENDED, UPDATE_REQUIRED - controls if version is active
39
- created_at: Type.String(),
40
- updated_at: Type.String(),
41
- });
42
- /**
43
- * Version params schema
44
- */
45
- export const VersionParamsSchema = Type.Object({
46
- version_id: Type.String({ format: "uuid" }),
47
- });
48
- /**
49
- * Search versions query schema
50
- * Supports pagination, search, and sorting
51
- */
52
- export const SearchVersionsQuerySchema = Type.Object({
53
- project_id: Type.String({ format: "uuid" }),
54
- page: Type.Number({ minimum: 1, default: 1 }),
55
- limit: Type.Number({ minimum: 1, maximum: 100, default: 20 }),
56
- search: Type.Optional(Type.String()),
57
- sort_by: Type.Union([
58
- Type.Literal("created_at"),
59
- Type.Literal("updated_at"),
60
- Type.Literal("name"),
61
- Type.Literal("major"),
62
- Type.Literal("minor"),
63
- Type.Literal("patch"),
64
- ], { default: "created_at" }),
65
- sort_order: Type.Union([Type.Literal("asc"), Type.Literal("desc")], { default: "desc" }),
66
- });
67
- /**
68
- * Search versions query schema without project_id (injected from headers)
69
- */
70
- export const SearchVersionsQueryParamsSchema = Type.Omit(SearchVersionsQuerySchema, ["project_id"]);
71
- /**
72
- * Versions by IDs request schema
73
- */
74
- export const VersionsByIdsSchema = Type.Object({
75
- version_ids: Type.Array(Type.String({ format: "uuid" }), { minItems: 1, maxItems: 100 }),
76
- });
77
- /**
78
- * Paginated versions response schema
79
- */
80
- export const VersionsResponseSchema = Type.Object({
81
- versions: Type.Array(VersionSchema),
82
- pagination: Type.Object({
83
- page: Type.Integer({ minimum: 1 }),
84
- limit: Type.Integer({ minimum: 1 }),
85
- total: Type.Integer({ minimum: 0 }),
86
- total_pages: Type.Integer({ minimum: 0 }),
87
- }),
88
- });
89
- /**
90
- * Single version response schema
91
- */
92
- export const VersionResponseSchema = Type.Object({
93
- success: Type.Literal(true),
94
- data: VersionSchema,
95
- });
96
- /**
97
- * Version error response schema
98
- * Discriminated union by error code
99
- */
100
- export const VersionErrorSchema = Type.Union([
101
- Type.Object({
102
- code: Type.Literal("VERSION_NOT_FOUND"),
103
- message: Type.String(),
104
- }),
105
- Type.Object({
106
- code: Type.Literal("PROJECT_NOT_FOUND"),
107
- message: Type.String(),
108
- }),
109
- Type.Object({
110
- code: Type.Literal("FORBIDDEN"),
111
- message: Type.String(),
112
- }),
113
- Type.Object({
114
- code: Type.Literal("FETCH_FAILED"),
115
- message: Type.String(),
116
- }),
117
- Type.Object({
118
- code: Type.Literal("INVALID_PARAMS"),
119
- message: Type.String(),
120
- }),
121
- ]);
122
- /**
123
- * Version error response wrapper
124
- */
125
- export const VersionErrorResponseSchema = Type.Object({
126
- success: Type.Literal(false),
127
- error: VersionErrorSchema,
128
- });
129
- /**
130
- * Version request response schema
131
- */
132
- export const VersionRequestResponseSchema = Type.Union([VersionResponseSchema, VersionErrorResponseSchema]);
133
- /**
134
- * Update version status request body schema
135
- */
136
- export const UpdateVersionStatusBodySchema = Type.Object({
137
- status: VersionBuildStatusSchema,
138
- });
139
- /**
140
- * Add UPDATE_FAILED error code for update operations
141
- */
142
- export const VersionErrorSchemaWithUpdate = Type.Union([
143
- VersionErrorSchema,
144
- Type.Object({
145
- code: Type.Literal("UPDATE_FAILED"),
146
- message: Type.String(),
147
- }),
148
- ]);
149
- /**
150
- * Version error response wrapper with update error
151
- */
152
- export const VersionErrorResponseWithUpdateSchema = Type.Object({
153
- success: Type.Literal(false),
154
- error: VersionErrorSchemaWithUpdate,
155
- });
File without changes