@dichovsky/testrail-api-client 1.0.0 → 2.1.0
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/README.md +22 -0
- package/dist/cli/auth.d.ts +21 -0
- package/dist/cli/auth.js +16 -0
- package/dist/cli/body.d.ts +42 -0
- package/dist/cli/body.js +89 -0
- package/dist/cli/dispatch.d.ts +16 -0
- package/dist/cli/dispatch.js +87 -0
- package/dist/cli/handler-context.d.ts +43 -0
- package/dist/cli/handler-context.js +2 -0
- package/dist/cli/handlers/case-write.d.ts +4 -0
- package/dist/cli/handlers/case-write.js +26 -0
- package/dist/cli/handlers/case.d.ts +4 -0
- package/dist/cli/handlers/case.js +11 -0
- package/dist/cli/handlers/milestone.d.ts +4 -0
- package/dist/cli/handlers/milestone.js +15 -0
- package/dist/cli/handlers/project.d.ts +4 -0
- package/dist/cli/handlers/project.js +11 -0
- package/dist/cli/handlers/result-write.d.ts +4 -0
- package/dist/cli/handlers/result-write.js +40 -0
- package/dist/cli/handlers/result.d.ts +3 -0
- package/dist/cli/handlers/result.js +11 -0
- package/dist/cli/handlers/run-write.d.ts +10 -0
- package/dist/cli/handlers/run-write.js +29 -0
- package/dist/cli/handlers/run.d.ts +4 -0
- package/dist/cli/handlers/run.js +15 -0
- package/dist/cli/handlers/suite.d.ts +4 -0
- package/dist/cli/handlers/suite.js +10 -0
- package/dist/cli/handlers/user.d.ts +4 -0
- package/dist/cli/handlers/user.js +11 -0
- package/dist/cli/ids.d.ts +6 -0
- package/dist/cli/ids.js +20 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.js +198 -0
- package/dist/cli/install-skill.d.ts +35 -0
- package/dist/cli/install-skill.js +71 -0
- package/dist/cli/metadata.d.ts +37 -0
- package/dist/cli/metadata.js +151 -0
- package/dist/cli/output.d.ts +28 -0
- package/dist/cli/output.js +84 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +1 -266
- package/dist/client-core.d.ts +16 -7
- package/dist/client-core.js +153 -27
- package/dist/client.d.ts +274 -118
- package/dist/client.js +404 -463
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/errors.d.ts +11 -9
- package/dist/errors.js +12 -8
- package/dist/index.d.ts +4 -2
- package/dist/index.js +2 -1
- package/dist/modules/attachments.d.ts +19 -0
- package/dist/modules/attachments.js +64 -0
- package/dist/modules/cases.d.ts +13 -0
- package/dist/modules/cases.js +58 -0
- package/dist/modules/configurations.d.ts +14 -0
- package/dist/modules/configurations.js +37 -0
- package/dist/modules/datasets.d.ts +12 -0
- package/dist/modules/datasets.js +28 -0
- package/dist/modules/metadata.d.ts +14 -0
- package/dist/modules/metadata.js +31 -0
- package/dist/modules/milestones.d.ts +12 -0
- package/dist/modules/milestones.js +36 -0
- package/dist/modules/plans.d.ts +16 -0
- package/dist/modules/plans.js +59 -0
- package/dist/modules/projects.d.ts +36 -0
- package/dist/modules/projects.js +55 -0
- package/dist/modules/reports.d.ts +9 -0
- package/dist/modules/reports.js +16 -0
- package/dist/modules/results.d.ts +14 -0
- package/dist/modules/results.js +69 -0
- package/dist/modules/runs.d.ts +14 -0
- package/dist/modules/runs.js +57 -0
- package/dist/modules/sections.d.ts +16 -0
- package/dist/modules/sections.js +37 -0
- package/dist/modules/sharedSteps.d.ts +12 -0
- package/dist/modules/sharedSteps.js +28 -0
- package/dist/modules/suites.d.ts +37 -0
- package/dist/modules/suites.js +54 -0
- package/dist/modules/tests.d.ts +9 -0
- package/dist/modules/tests.js +25 -0
- package/dist/modules/users.d.ts +18 -0
- package/dist/modules/users.js +62 -0
- package/dist/modules/variables.d.ts +11 -0
- package/dist/modules/variables.js +24 -0
- package/dist/schemas.d.ts +544 -0
- package/dist/schemas.js +419 -0
- package/dist/types.d.ts +1 -55
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +4 -0
- package/package.json +23 -15
- package/skill/SKILL.md +395 -0
- package/src/cli/auth.ts +37 -0
- package/src/cli/body.ts +100 -0
- package/src/cli/dispatch.ts +91 -0
- package/src/cli/handler-context.ts +46 -0
- package/src/cli/handlers/case-write.ts +26 -0
- package/src/cli/handlers/case.ts +13 -0
- package/src/cli/handlers/milestone.ts +19 -0
- package/src/cli/handlers/project.ts +13 -0
- package/src/cli/handlers/result-write.ts +40 -0
- package/src/cli/handlers/result.ts +14 -0
- package/src/cli/handlers/run-write.ts +30 -0
- package/src/cli/handlers/run.ts +19 -0
- package/src/cli/handlers/suite.ts +12 -0
- package/src/cli/handlers/user.ts +13 -0
- package/src/cli/ids.ts +20 -0
- package/src/cli/index.ts +224 -0
- package/src/cli/install-skill.ts +89 -0
- package/src/cli/metadata.ts +194 -0
- package/src/cli/output.ts +96 -0
- package/src/cli.ts +1 -286
- package/src/client-core.ts +183 -67
- package/src/client.ts +414 -483
- package/src/constants.ts +1 -0
- package/src/errors.ts +18 -11
- package/src/index.ts +50 -8
- package/src/modules/attachments.ts +125 -0
- package/src/modules/cases.ts +78 -0
- package/src/modules/configurations.ts +68 -0
- package/src/modules/datasets.ts +44 -0
- package/src/modules/metadata.ts +63 -0
- package/src/modules/milestones.ts +54 -0
- package/src/modules/plans.ts +89 -0
- package/src/modules/projects.ts +67 -0
- package/src/modules/reports.ts +23 -0
- package/src/modules/results.ts +90 -0
- package/src/modules/runs.ts +70 -0
- package/src/modules/sections.ts +55 -0
- package/src/modules/sharedSteps.ts +44 -0
- package/src/modules/suites.ts +67 -0
- package/src/modules/tests.ts +28 -0
- package/src/modules/users.ts +87 -0
- package/src/modules/variables.ts +36 -0
- package/src/schemas.ts +551 -0
- package/src/types.ts +11 -60
- package/src/utils.ts +5 -0
package/src/schemas.ts
ADDED
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const zObject = <T extends z.ZodRawShape>(shape: T) => z.object(shape).passthrough();
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Core schemas for common TestRail API structures.
|
|
7
|
+
* These are used to validate API responses and provide static type inference via `z.infer`.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// ── Common & Foundational Schemas ─────────────────────────────────────────────
|
|
11
|
+
|
|
12
|
+
export const PaginationSchema = zObject({
|
|
13
|
+
limit: z.number().optional(),
|
|
14
|
+
offset: z.number().optional(),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const TestRailConfigSchema = zObject({
|
|
18
|
+
baseUrl: z.string().url(),
|
|
19
|
+
email: z.string().email(),
|
|
20
|
+
apiKey: z.string().min(1),
|
|
21
|
+
timeout: z.number().optional(),
|
|
22
|
+
maxRetries: z.number().int().nonnegative().optional(),
|
|
23
|
+
enableCache: z.boolean().optional(),
|
|
24
|
+
cacheTtl: z.number().int().positive().optional(),
|
|
25
|
+
cacheCleanupInterval: z.number().int().positive().optional(),
|
|
26
|
+
maxCacheSize: z.number().int().positive().optional(),
|
|
27
|
+
rateLimiter: zObject({
|
|
28
|
+
maxRequests: z.number().int().positive(),
|
|
29
|
+
windowMs: z.number().int().positive(),
|
|
30
|
+
}).optional(),
|
|
31
|
+
allowInsecure: z.boolean().optional(),
|
|
32
|
+
allowPrivateHosts: z.boolean().optional(),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export type TestRailConfig = z.infer<typeof TestRailConfigSchema>;
|
|
36
|
+
|
|
37
|
+
// ── Identity & User Schemas ───────────────────────────────────────────────────
|
|
38
|
+
|
|
39
|
+
export const UserSchema = zObject({
|
|
40
|
+
id: z.number(),
|
|
41
|
+
name: z.string(),
|
|
42
|
+
email: z.string().email(),
|
|
43
|
+
is_active: z.boolean(),
|
|
44
|
+
role_id: z.number().optional(),
|
|
45
|
+
role: z.string().optional(),
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export type User = z.infer<typeof UserSchema>;
|
|
49
|
+
|
|
50
|
+
export const RoleSchema = zObject({
|
|
51
|
+
id: z.number(),
|
|
52
|
+
name: z.string(),
|
|
53
|
+
is_default: z.boolean(),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export type Role = z.infer<typeof RoleSchema>;
|
|
57
|
+
|
|
58
|
+
export const GroupSchema = zObject({
|
|
59
|
+
id: z.number(),
|
|
60
|
+
name: z.string(),
|
|
61
|
+
user_ids: z.array(z.number()).optional(),
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export type Group = z.infer<typeof GroupSchema>;
|
|
65
|
+
|
|
66
|
+
// ── Project & Suite Schemas ────────────────────────────────────────────────────
|
|
67
|
+
|
|
68
|
+
export const ProjectSchema = zObject({
|
|
69
|
+
id: z.number(),
|
|
70
|
+
name: z.string(),
|
|
71
|
+
announcement: z.string().optional(),
|
|
72
|
+
show_announcement: z.boolean().optional(),
|
|
73
|
+
is_completed: z.boolean().optional(),
|
|
74
|
+
completed_on: z.number().optional(),
|
|
75
|
+
suite_mode: z.number(),
|
|
76
|
+
url: z.string(),
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
export type Project = z.infer<typeof ProjectSchema>;
|
|
80
|
+
|
|
81
|
+
export const SuiteSchema = zObject({
|
|
82
|
+
id: z.number(),
|
|
83
|
+
name: z.string(),
|
|
84
|
+
description: z.string().optional(),
|
|
85
|
+
project_id: z.number(),
|
|
86
|
+
is_master: z.boolean().optional(),
|
|
87
|
+
is_baseline: z.boolean().optional(),
|
|
88
|
+
is_completed: z.boolean().optional(),
|
|
89
|
+
completed_on: z.number().optional(),
|
|
90
|
+
url: z.string(),
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
export type Suite = z.infer<typeof SuiteSchema>;
|
|
94
|
+
|
|
95
|
+
// ── Case & Section Schemas ─────────────────────────────────────────────────────
|
|
96
|
+
|
|
97
|
+
export const CaseSchema = zObject({
|
|
98
|
+
id: z.number(),
|
|
99
|
+
title: z.string(),
|
|
100
|
+
section_id: z.number(),
|
|
101
|
+
template_id: z.number().optional(),
|
|
102
|
+
type_id: z.number().optional(),
|
|
103
|
+
priority_id: z.number().optional(),
|
|
104
|
+
milestone_id: z.number().optional(),
|
|
105
|
+
refs: z.string().optional(),
|
|
106
|
+
created_by: z.number(),
|
|
107
|
+
created_on: z.number(),
|
|
108
|
+
updated_by: z.number(),
|
|
109
|
+
updated_on: z.number(),
|
|
110
|
+
estimate: z.string().optional(),
|
|
111
|
+
estimate_forecast: z.string().optional(),
|
|
112
|
+
suite_id: z.number(),
|
|
113
|
+
display_order: z.number().optional(),
|
|
114
|
+
is_deleted: z.number().optional(),
|
|
115
|
+
custom_fields: z.record(z.string(), z.unknown()).optional(),
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
export type Case = z.infer<typeof CaseSchema>;
|
|
119
|
+
|
|
120
|
+
export const SectionSchema = zObject({
|
|
121
|
+
id: z.number(),
|
|
122
|
+
suite_id: z.number(),
|
|
123
|
+
name: z.string(),
|
|
124
|
+
description: z.string().optional(),
|
|
125
|
+
parent_id: z.number().optional(),
|
|
126
|
+
display_order: z.number(),
|
|
127
|
+
depth: z.number(),
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
export type Section = z.infer<typeof SectionSchema>;
|
|
131
|
+
|
|
132
|
+
// ── Run Schema (forward declaration needed for PlanEntry) ─────────────────────
|
|
133
|
+
|
|
134
|
+
export const RunSchema = zObject({
|
|
135
|
+
id: z.number(),
|
|
136
|
+
suite_id: z.number(),
|
|
137
|
+
name: z.string(),
|
|
138
|
+
description: z.string().optional(),
|
|
139
|
+
milestone_id: z.number().optional(),
|
|
140
|
+
assignedto_id: z.number().optional(),
|
|
141
|
+
include_all: z.boolean(),
|
|
142
|
+
is_completed: z.boolean(),
|
|
143
|
+
completed_on: z.number().optional(),
|
|
144
|
+
config: z.string().optional(),
|
|
145
|
+
config_ids: z.array(z.number()).optional(),
|
|
146
|
+
passed_count: z.number(),
|
|
147
|
+
blocked_count: z.number(),
|
|
148
|
+
untested_count: z.number(),
|
|
149
|
+
retest_count: z.number(),
|
|
150
|
+
failed_count: z.number(),
|
|
151
|
+
custom_status1_count: z.number().optional(),
|
|
152
|
+
custom_status2_count: z.number().optional(),
|
|
153
|
+
custom_status3_count: z.number().optional(),
|
|
154
|
+
custom_status4_count: z.number().optional(),
|
|
155
|
+
custom_status5_count: z.number().optional(),
|
|
156
|
+
custom_status6_count: z.number().optional(),
|
|
157
|
+
custom_status7_count: z.number().optional(),
|
|
158
|
+
project_id: z.number(),
|
|
159
|
+
plan_id: z.number().optional(),
|
|
160
|
+
created_on: z.number(),
|
|
161
|
+
created_by: z.number(),
|
|
162
|
+
refs: z.string().optional(),
|
|
163
|
+
url: z.string(),
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
export type Run = z.infer<typeof RunSchema>;
|
|
167
|
+
|
|
168
|
+
// ── Plan Entry & Plan Schemas ─────────────────────────────────────────────────
|
|
169
|
+
|
|
170
|
+
export const PlanEntrySchema = zObject({
|
|
171
|
+
id: z.string(),
|
|
172
|
+
suite_id: z.number(),
|
|
173
|
+
name: z.string(),
|
|
174
|
+
description: z.string().optional(),
|
|
175
|
+
assignedto_id: z.number().optional(),
|
|
176
|
+
include_all: z.boolean(),
|
|
177
|
+
case_ids: z.array(z.number()).optional(),
|
|
178
|
+
config_ids: z.array(z.number()).optional(),
|
|
179
|
+
runs: z.array(RunSchema),
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
export type PlanEntry = z.infer<typeof PlanEntrySchema>;
|
|
183
|
+
|
|
184
|
+
export const PlanSchema = zObject({
|
|
185
|
+
id: z.number(),
|
|
186
|
+
name: z.string(),
|
|
187
|
+
description: z.string().optional(),
|
|
188
|
+
milestone_id: z.number().optional(),
|
|
189
|
+
assignedto_id: z.number().optional(),
|
|
190
|
+
is_completed: z.boolean(),
|
|
191
|
+
completed_on: z.number().optional(),
|
|
192
|
+
passed_count: z.number(),
|
|
193
|
+
blocked_count: z.number(),
|
|
194
|
+
untested_count: z.number(),
|
|
195
|
+
retest_count: z.number(),
|
|
196
|
+
failed_count: z.number(),
|
|
197
|
+
custom_status1_count: z.number().optional(),
|
|
198
|
+
custom_status2_count: z.number().optional(),
|
|
199
|
+
custom_status3_count: z.number().optional(),
|
|
200
|
+
custom_status4_count: z.number().optional(),
|
|
201
|
+
custom_status5_count: z.number().optional(),
|
|
202
|
+
custom_status6_count: z.number().optional(),
|
|
203
|
+
custom_status7_count: z.number().optional(),
|
|
204
|
+
project_id: z.number(),
|
|
205
|
+
created_on: z.number(),
|
|
206
|
+
created_by: z.number(),
|
|
207
|
+
url: z.string(),
|
|
208
|
+
entries: z.array(PlanEntrySchema).optional(),
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
export type Plan = z.infer<typeof PlanSchema>;
|
|
212
|
+
|
|
213
|
+
// ── Test & Result Schemas ─────────────────────────────────────────────────────
|
|
214
|
+
|
|
215
|
+
export const TestSchema = zObject({
|
|
216
|
+
id: z.number(),
|
|
217
|
+
case_id: z.number(),
|
|
218
|
+
status_id: z.number(),
|
|
219
|
+
assignedto_id: z.number().optional(),
|
|
220
|
+
run_id: z.number(),
|
|
221
|
+
title: z.string(),
|
|
222
|
+
template_id: z.number().optional(),
|
|
223
|
+
type_id: z.number().optional(),
|
|
224
|
+
priority_id: z.number().optional(),
|
|
225
|
+
estimate: z.string().optional(),
|
|
226
|
+
estimate_forecast: z.string().optional(),
|
|
227
|
+
refs: z.string().optional(),
|
|
228
|
+
milestone_id: z.number().optional(),
|
|
229
|
+
custom_fields: z.record(z.string(), z.unknown()).optional(),
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
export type Test = z.infer<typeof TestSchema>;
|
|
233
|
+
|
|
234
|
+
export const ResultSchema = zObject({
|
|
235
|
+
id: z.number().optional(),
|
|
236
|
+
test_id: z.number().optional(),
|
|
237
|
+
status_id: z.number(),
|
|
238
|
+
comment: z.string().optional(),
|
|
239
|
+
version: z.string().optional(),
|
|
240
|
+
elapsed: z.string().optional(),
|
|
241
|
+
defects: z.string().optional(),
|
|
242
|
+
assignedto_id: z.number().optional(),
|
|
243
|
+
created_by: z.number().optional(),
|
|
244
|
+
created_on: z.number().optional(),
|
|
245
|
+
custom_fields: z.record(z.string(), z.unknown()).optional(),
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
export type Result = z.infer<typeof ResultSchema>;
|
|
249
|
+
|
|
250
|
+
// ── Milestone Schema ──────────────────────────────────────────────────────────
|
|
251
|
+
|
|
252
|
+
export const MilestoneSchema = zObject({
|
|
253
|
+
id: z.number(),
|
|
254
|
+
name: z.string(),
|
|
255
|
+
description: z.string().optional(),
|
|
256
|
+
start_on: z.number().optional(),
|
|
257
|
+
started_on: z.number().optional(),
|
|
258
|
+
is_completed: z.boolean(),
|
|
259
|
+
completed_on: z.number().optional(),
|
|
260
|
+
due_on: z.number().optional(),
|
|
261
|
+
project_id: z.number(),
|
|
262
|
+
parent_id: z.number().optional(),
|
|
263
|
+
refs: z.string().optional(),
|
|
264
|
+
url: z.string(),
|
|
265
|
+
// Sub-milestones are typed as unknown[] to avoid a recursive schema definition.
|
|
266
|
+
milestones: z.array(z.unknown()).optional(),
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
export type Milestone = z.infer<typeof MilestoneSchema>;
|
|
270
|
+
|
|
271
|
+
// ── Status & Priority Schemas ──────────────────────────────────────────────────
|
|
272
|
+
|
|
273
|
+
export const StatusSchema = zObject({
|
|
274
|
+
id: z.number(),
|
|
275
|
+
name: z.string(),
|
|
276
|
+
label: z.string(),
|
|
277
|
+
color_dark: z.number(),
|
|
278
|
+
color_medium: z.number(),
|
|
279
|
+
color_bright: z.number(),
|
|
280
|
+
is_system: z.boolean(),
|
|
281
|
+
is_untested: z.boolean(),
|
|
282
|
+
is_final: z.boolean(),
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
export type Status = z.infer<typeof StatusSchema>;
|
|
286
|
+
|
|
287
|
+
export const PrioritySchema = zObject({
|
|
288
|
+
id: z.number(),
|
|
289
|
+
name: z.string(),
|
|
290
|
+
short_name: z.string(),
|
|
291
|
+
is_default: z.boolean(),
|
|
292
|
+
priority: z.number(),
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
export type Priority = z.infer<typeof PrioritySchema>;
|
|
296
|
+
|
|
297
|
+
// ── Field Config Schemas ──────────────────────────────────────────────────────
|
|
298
|
+
|
|
299
|
+
const FieldConfigOptionsSchema = zObject({
|
|
300
|
+
is_required: z.boolean(),
|
|
301
|
+
default_value: z.string(),
|
|
302
|
+
items: z.string().optional(),
|
|
303
|
+
format: z.string().optional(),
|
|
304
|
+
rows: z.string().optional(),
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
const FieldConfigContextSchema = zObject({
|
|
308
|
+
is_global: z.boolean(),
|
|
309
|
+
project_ids: z.array(z.number()),
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
export const CaseFieldConfigSchema = zObject({
|
|
313
|
+
context: FieldConfigContextSchema,
|
|
314
|
+
options: FieldConfigOptionsSchema,
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
export type CaseFieldConfig = z.infer<typeof CaseFieldConfigSchema>;
|
|
318
|
+
|
|
319
|
+
export const CaseFieldSchema = zObject({
|
|
320
|
+
id: z.number(),
|
|
321
|
+
system_name: z.string(),
|
|
322
|
+
label: z.string(),
|
|
323
|
+
name: z.string(),
|
|
324
|
+
type_id: z.number(),
|
|
325
|
+
display_order: z.number(),
|
|
326
|
+
configs: z.array(CaseFieldConfigSchema),
|
|
327
|
+
is_active: z.boolean(),
|
|
328
|
+
include_all: z.boolean(),
|
|
329
|
+
template_ids: z.array(z.number()),
|
|
330
|
+
description: z.string().optional(),
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
export type CaseField = z.infer<typeof CaseFieldSchema>;
|
|
334
|
+
|
|
335
|
+
export const ResultFieldConfigSchema = zObject({
|
|
336
|
+
context: FieldConfigContextSchema,
|
|
337
|
+
options: FieldConfigOptionsSchema,
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
export type ResultFieldConfig = z.infer<typeof ResultFieldConfigSchema>;
|
|
341
|
+
|
|
342
|
+
export const ResultFieldSchema = zObject({
|
|
343
|
+
id: z.number(),
|
|
344
|
+
system_name: z.string(),
|
|
345
|
+
label: z.string(),
|
|
346
|
+
name: z.string(),
|
|
347
|
+
type_id: z.number(),
|
|
348
|
+
display_order: z.number(),
|
|
349
|
+
configs: z.array(ResultFieldConfigSchema),
|
|
350
|
+
is_active: z.boolean(),
|
|
351
|
+
include_all: z.boolean(),
|
|
352
|
+
template_ids: z.array(z.number()),
|
|
353
|
+
description: z.string().optional(),
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
export type ResultField = z.infer<typeof ResultFieldSchema>;
|
|
357
|
+
|
|
358
|
+
// ── Case Type & Template Schemas ──────────────────────────────────────────────
|
|
359
|
+
|
|
360
|
+
export const CaseTypeSchema = zObject({
|
|
361
|
+
id: z.number(),
|
|
362
|
+
name: z.string(),
|
|
363
|
+
is_default: z.boolean(),
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
export type CaseType = z.infer<typeof CaseTypeSchema>;
|
|
367
|
+
|
|
368
|
+
export const TemplateSchema = zObject({
|
|
369
|
+
id: z.number(),
|
|
370
|
+
name: z.string(),
|
|
371
|
+
is_default: z.boolean(),
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
export type Template = z.infer<typeof TemplateSchema>;
|
|
375
|
+
|
|
376
|
+
// ── Configuration Schemas ─────────────────────────────────────────────────────
|
|
377
|
+
|
|
378
|
+
export const ConfigurationSchema = zObject({
|
|
379
|
+
id: z.number(),
|
|
380
|
+
name: z.string(),
|
|
381
|
+
group_id: z.number(),
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
export type Configuration = z.infer<typeof ConfigurationSchema>;
|
|
385
|
+
|
|
386
|
+
export const ConfigurationGroupSchema = zObject({
|
|
387
|
+
id: z.number(),
|
|
388
|
+
name: z.string(),
|
|
389
|
+
project_id: z.number(),
|
|
390
|
+
configs: z.array(ConfigurationSchema),
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
export type ConfigurationGroup = z.infer<typeof ConfigurationGroupSchema>;
|
|
394
|
+
|
|
395
|
+
// ── Attachment Schema ─────────────────────────────────────────────────────────
|
|
396
|
+
|
|
397
|
+
export const AttachmentSchema = zObject({
|
|
398
|
+
attachment_id: z.number(),
|
|
399
|
+
name: z.string(),
|
|
400
|
+
filename: z.string().optional(),
|
|
401
|
+
size: z.number().optional(),
|
|
402
|
+
created_on: z.number().optional(),
|
|
403
|
+
created_by: z.number().optional(),
|
|
404
|
+
entity_id: z.number().optional(),
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
export type Attachment = z.infer<typeof AttachmentSchema>;
|
|
408
|
+
|
|
409
|
+
// ── Shared Steps Schema ───────────────────────────────────────────────────────
|
|
410
|
+
|
|
411
|
+
export const SharedStepSchema = zObject({
|
|
412
|
+
id: z.number(),
|
|
413
|
+
title: z.string(),
|
|
414
|
+
project_id: z.number().optional(),
|
|
415
|
+
case_ids: z.array(z.number()).optional(),
|
|
416
|
+
created_on: z.number().optional(),
|
|
417
|
+
created_by: z.number().optional(),
|
|
418
|
+
updated_on: z.number().optional(),
|
|
419
|
+
updated_by: z.number().optional(),
|
|
420
|
+
custom_steps_separated: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
export type SharedStep = z.infer<typeof SharedStepSchema>;
|
|
424
|
+
|
|
425
|
+
// ── Variable & Dataset Schemas ────────────────────────────────────────────────
|
|
426
|
+
|
|
427
|
+
export const VariableSchema = zObject({
|
|
428
|
+
id: z.number(),
|
|
429
|
+
name: z.string(),
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
export type Variable = z.infer<typeof VariableSchema>;
|
|
433
|
+
|
|
434
|
+
export const DatasetSchema = zObject({
|
|
435
|
+
id: z.number(),
|
|
436
|
+
name: z.string(),
|
|
437
|
+
project_id: z.number().optional(),
|
|
438
|
+
created_on: z.number().optional(),
|
|
439
|
+
created_by: z.number().optional(),
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
export type Dataset = z.infer<typeof DatasetSchema>;
|
|
443
|
+
|
|
444
|
+
// ── Report Schemas ────────────────────────────────────────────────────────────
|
|
445
|
+
|
|
446
|
+
export const ReportSchema = zObject({
|
|
447
|
+
id: z.number(),
|
|
448
|
+
name: z.string(),
|
|
449
|
+
description: z.string().optional(),
|
|
450
|
+
is_shared: z.boolean().optional(),
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
export type Report = z.infer<typeof ReportSchema>;
|
|
454
|
+
|
|
455
|
+
export const ReportResultSchema = zObject({
|
|
456
|
+
report_url: z.string(),
|
|
457
|
+
user_report_url: z.string().optional(),
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
export type ReportResult = z.infer<typeof ReportResultSchema>;
|
|
461
|
+
|
|
462
|
+
// ── Write Payload Schemas ─────────────────────────────────────────────────────
|
|
463
|
+
// Source-of-truth schemas for POST bodies sent by the TestRail client. Each is
|
|
464
|
+
// `.passthrough()` via `zObject`, so TestRail's user-configured `custom_*`
|
|
465
|
+
// fields (or any other forward-compatible extension) pass through unchanged.
|
|
466
|
+
// TypeScript payload types are derived via `z.infer` and exported alongside
|
|
467
|
+
// each schema; no separate handwritten interface lives in `src/types.ts`.
|
|
468
|
+
|
|
469
|
+
export const AddCasePayloadSchema = zObject({
|
|
470
|
+
title: z.string(),
|
|
471
|
+
template_id: z.number().optional(),
|
|
472
|
+
type_id: z.number().optional(),
|
|
473
|
+
priority_id: z.number().optional(),
|
|
474
|
+
estimate: z.string().optional(),
|
|
475
|
+
milestone_id: z.number().optional(),
|
|
476
|
+
refs: z.string().optional(),
|
|
477
|
+
custom_fields: z.record(z.string(), z.unknown()).optional(),
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
export type AddCasePayload = z.infer<typeof AddCasePayloadSchema>;
|
|
481
|
+
|
|
482
|
+
export const UpdateCasePayloadSchema = zObject({
|
|
483
|
+
title: z.string().optional(),
|
|
484
|
+
template_id: z.number().optional(),
|
|
485
|
+
type_id: z.number().optional(),
|
|
486
|
+
priority_id: z.number().optional(),
|
|
487
|
+
estimate: z.string().optional(),
|
|
488
|
+
milestone_id: z.number().optional(),
|
|
489
|
+
refs: z.string().optional(),
|
|
490
|
+
custom_fields: z.record(z.string(), z.unknown()).optional(),
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
export type UpdateCasePayload = z.infer<typeof UpdateCasePayloadSchema>;
|
|
494
|
+
|
|
495
|
+
export const AddRunPayloadSchema = zObject({
|
|
496
|
+
name: z.string(),
|
|
497
|
+
suite_id: z.number().optional(),
|
|
498
|
+
description: z.string().optional(),
|
|
499
|
+
milestone_id: z.number().optional(),
|
|
500
|
+
assignedto_id: z.number().optional(),
|
|
501
|
+
include_all: z.boolean().optional(),
|
|
502
|
+
case_ids: z.array(z.number()).optional(),
|
|
503
|
+
refs: z.string().optional(),
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
export type AddRunPayload = z.infer<typeof AddRunPayloadSchema>;
|
|
507
|
+
|
|
508
|
+
export const UpdateRunPayloadSchema = zObject({
|
|
509
|
+
name: z.string().optional(),
|
|
510
|
+
description: z.string().optional(),
|
|
511
|
+
milestone_id: z.number().optional(),
|
|
512
|
+
assignedto_id: z.number().optional(),
|
|
513
|
+
include_all: z.boolean().optional(),
|
|
514
|
+
case_ids: z.array(z.number()).optional(),
|
|
515
|
+
refs: z.string().optional(),
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
export type UpdateRunPayload = z.infer<typeof UpdateRunPayloadSchema>;
|
|
519
|
+
|
|
520
|
+
export const AddResultPayloadSchema = zObject({
|
|
521
|
+
status_id: z.number(),
|
|
522
|
+
comment: z.string().optional(),
|
|
523
|
+
version: z.string().optional(),
|
|
524
|
+
elapsed: z.string().optional(),
|
|
525
|
+
defects: z.string().optional(),
|
|
526
|
+
assignedto_id: z.number().optional(),
|
|
527
|
+
custom_fields: z.record(z.string(), z.unknown()).optional(),
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
export type AddResultPayload = z.infer<typeof AddResultPayloadSchema>;
|
|
531
|
+
|
|
532
|
+
// Inlined rather than `.extend(AddResultPayloadSchema)` so the passthrough()
|
|
533
|
+
// behavior is unambiguous and the inferred type stays a plain object literal.
|
|
534
|
+
export const AddResultForCasePayloadSchema = zObject({
|
|
535
|
+
case_id: z.number(),
|
|
536
|
+
status_id: z.number(),
|
|
537
|
+
comment: z.string().optional(),
|
|
538
|
+
version: z.string().optional(),
|
|
539
|
+
elapsed: z.string().optional(),
|
|
540
|
+
defects: z.string().optional(),
|
|
541
|
+
assignedto_id: z.number().optional(),
|
|
542
|
+
custom_fields: z.record(z.string(), z.unknown()).optional(),
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
export type AddResultForCasePayload = z.infer<typeof AddResultForCasePayloadSchema>;
|
|
546
|
+
|
|
547
|
+
export const AddResultsForCasesPayloadSchema = zObject({
|
|
548
|
+
results: z.array(AddResultForCasePayloadSchema),
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
export type AddResultsForCasesPayload = z.infer<typeof AddResultsForCasesPayloadSchema>;
|
package/src/types.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
// AddRunPayload is the source-of-truth payload type derived from
|
|
2
|
+
// `AddRunPayloadSchema` in `./schemas.ts`. It's re-imported here because
|
|
3
|
+
// `AddPlanEntryPayload` / `UpdatePlanEntryPayload` (which remain handwritten
|
|
4
|
+
// in this file as part of v2.1 scope) contain `runs?: AddRunPayload[]`.
|
|
5
|
+
import type { AddRunPayload } from './schemas.js';
|
|
6
|
+
|
|
1
7
|
/**
|
|
2
8
|
* TestRail API client configuration options
|
|
3
9
|
*/
|
|
@@ -253,27 +259,8 @@ export interface Priority {
|
|
|
253
259
|
priority: number; // weight/level
|
|
254
260
|
}
|
|
255
261
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
template_id?: number;
|
|
259
|
-
type_id?: number;
|
|
260
|
-
priority_id?: number;
|
|
261
|
-
estimate?: string;
|
|
262
|
-
milestone_id?: number;
|
|
263
|
-
refs?: string;
|
|
264
|
-
custom_fields?: Record<string, unknown>;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
export interface UpdateCasePayload {
|
|
268
|
-
title?: string;
|
|
269
|
-
template_id?: number;
|
|
270
|
-
type_id?: number;
|
|
271
|
-
priority_id?: number;
|
|
272
|
-
estimate?: string;
|
|
273
|
-
milestone_id?: number;
|
|
274
|
-
refs?: string;
|
|
275
|
-
custom_fields?: Record<string, unknown>;
|
|
276
|
-
}
|
|
262
|
+
// AddCasePayload and UpdateCasePayload now live in `./schemas.ts` as Zod
|
|
263
|
+
// schemas (source of truth for runtime validation + inferred TS types).
|
|
277
264
|
|
|
278
265
|
/**
|
|
279
266
|
* Filter options for `getCases()`.
|
|
@@ -342,45 +329,9 @@ export interface UpdatePlanEntryPayload {
|
|
|
342
329
|
runs?: AddRunPayload[];
|
|
343
330
|
}
|
|
344
331
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
description?: string;
|
|
349
|
-
milestone_id?: number;
|
|
350
|
-
assignedto_id?: number;
|
|
351
|
-
include_all?: boolean;
|
|
352
|
-
case_ids?: number[];
|
|
353
|
-
refs?: string;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
export interface UpdateRunPayload {
|
|
357
|
-
name?: string;
|
|
358
|
-
description?: string;
|
|
359
|
-
milestone_id?: number;
|
|
360
|
-
assignedto_id?: number;
|
|
361
|
-
include_all?: boolean;
|
|
362
|
-
case_ids?: number[];
|
|
363
|
-
refs?: string;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
export interface AddResultPayload {
|
|
367
|
-
/** e.g., 1=Passed */
|
|
368
|
-
status_id: number;
|
|
369
|
-
comment?: string;
|
|
370
|
-
version?: string;
|
|
371
|
-
elapsed?: string; // e.g. "5m 30s"
|
|
372
|
-
defects?: string;
|
|
373
|
-
assignedto_id?: number;
|
|
374
|
-
custom_fields?: Record<string, unknown>;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
export interface AddResultsForCasesPayload {
|
|
378
|
-
results: AddResultForCasePayload[];
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
export interface AddResultForCasePayload extends AddResultPayload {
|
|
382
|
-
case_id: number;
|
|
383
|
-
}
|
|
332
|
+
// AddRunPayload, UpdateRunPayload, AddResultPayload, AddResultsForCasesPayload,
|
|
333
|
+
// and AddResultForCasePayload now live in `./schemas.ts` as Zod schemas
|
|
334
|
+
// (source of truth for runtime validation + inferred TS types).
|
|
384
335
|
|
|
385
336
|
export interface AddSectionPayload {
|
|
386
337
|
name: string;
|
package/src/utils.ts
CHANGED
|
@@ -13,3 +13,8 @@ export function base64Encode(str: string): string {
|
|
|
13
13
|
export function sleep(ms: number): Promise<void> {
|
|
14
14
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
15
15
|
}
|
|
16
|
+
|
|
17
|
+
/** Serializes numeric ID filters for TestRail list endpoints. */
|
|
18
|
+
export function serializeIdList(ids?: number[]): string | undefined {
|
|
19
|
+
return ids !== undefined && ids.length > 0 ? ids.join(',') : undefined;
|
|
20
|
+
}
|