@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.
Files changed (137) hide show
  1. package/README.md +22 -0
  2. package/dist/cli/auth.d.ts +21 -0
  3. package/dist/cli/auth.js +16 -0
  4. package/dist/cli/body.d.ts +42 -0
  5. package/dist/cli/body.js +89 -0
  6. package/dist/cli/dispatch.d.ts +16 -0
  7. package/dist/cli/dispatch.js +87 -0
  8. package/dist/cli/handler-context.d.ts +43 -0
  9. package/dist/cli/handler-context.js +2 -0
  10. package/dist/cli/handlers/case-write.d.ts +4 -0
  11. package/dist/cli/handlers/case-write.js +26 -0
  12. package/dist/cli/handlers/case.d.ts +4 -0
  13. package/dist/cli/handlers/case.js +11 -0
  14. package/dist/cli/handlers/milestone.d.ts +4 -0
  15. package/dist/cli/handlers/milestone.js +15 -0
  16. package/dist/cli/handlers/project.d.ts +4 -0
  17. package/dist/cli/handlers/project.js +11 -0
  18. package/dist/cli/handlers/result-write.d.ts +4 -0
  19. package/dist/cli/handlers/result-write.js +40 -0
  20. package/dist/cli/handlers/result.d.ts +3 -0
  21. package/dist/cli/handlers/result.js +11 -0
  22. package/dist/cli/handlers/run-write.d.ts +10 -0
  23. package/dist/cli/handlers/run-write.js +29 -0
  24. package/dist/cli/handlers/run.d.ts +4 -0
  25. package/dist/cli/handlers/run.js +15 -0
  26. package/dist/cli/handlers/suite.d.ts +4 -0
  27. package/dist/cli/handlers/suite.js +10 -0
  28. package/dist/cli/handlers/user.d.ts +4 -0
  29. package/dist/cli/handlers/user.js +11 -0
  30. package/dist/cli/ids.d.ts +6 -0
  31. package/dist/cli/ids.js +20 -0
  32. package/dist/cli/index.d.ts +3 -0
  33. package/dist/cli/index.js +198 -0
  34. package/dist/cli/install-skill.d.ts +35 -0
  35. package/dist/cli/install-skill.js +71 -0
  36. package/dist/cli/metadata.d.ts +37 -0
  37. package/dist/cli/metadata.js +151 -0
  38. package/dist/cli/output.d.ts +28 -0
  39. package/dist/cli/output.js +84 -0
  40. package/dist/cli.d.ts +1 -1
  41. package/dist/cli.js +1 -266
  42. package/dist/client-core.d.ts +16 -7
  43. package/dist/client-core.js +153 -27
  44. package/dist/client.d.ts +274 -118
  45. package/dist/client.js +404 -463
  46. package/dist/constants.d.ts +1 -0
  47. package/dist/constants.js +1 -0
  48. package/dist/errors.d.ts +11 -9
  49. package/dist/errors.js +12 -8
  50. package/dist/index.d.ts +4 -2
  51. package/dist/index.js +2 -1
  52. package/dist/modules/attachments.d.ts +19 -0
  53. package/dist/modules/attachments.js +64 -0
  54. package/dist/modules/cases.d.ts +13 -0
  55. package/dist/modules/cases.js +58 -0
  56. package/dist/modules/configurations.d.ts +14 -0
  57. package/dist/modules/configurations.js +37 -0
  58. package/dist/modules/datasets.d.ts +12 -0
  59. package/dist/modules/datasets.js +28 -0
  60. package/dist/modules/metadata.d.ts +14 -0
  61. package/dist/modules/metadata.js +31 -0
  62. package/dist/modules/milestones.d.ts +12 -0
  63. package/dist/modules/milestones.js +36 -0
  64. package/dist/modules/plans.d.ts +16 -0
  65. package/dist/modules/plans.js +59 -0
  66. package/dist/modules/projects.d.ts +36 -0
  67. package/dist/modules/projects.js +55 -0
  68. package/dist/modules/reports.d.ts +9 -0
  69. package/dist/modules/reports.js +16 -0
  70. package/dist/modules/results.d.ts +14 -0
  71. package/dist/modules/results.js +69 -0
  72. package/dist/modules/runs.d.ts +14 -0
  73. package/dist/modules/runs.js +57 -0
  74. package/dist/modules/sections.d.ts +16 -0
  75. package/dist/modules/sections.js +37 -0
  76. package/dist/modules/sharedSteps.d.ts +12 -0
  77. package/dist/modules/sharedSteps.js +28 -0
  78. package/dist/modules/suites.d.ts +37 -0
  79. package/dist/modules/suites.js +54 -0
  80. package/dist/modules/tests.d.ts +9 -0
  81. package/dist/modules/tests.js +25 -0
  82. package/dist/modules/users.d.ts +18 -0
  83. package/dist/modules/users.js +62 -0
  84. package/dist/modules/variables.d.ts +11 -0
  85. package/dist/modules/variables.js +24 -0
  86. package/dist/schemas.d.ts +544 -0
  87. package/dist/schemas.js +419 -0
  88. package/dist/types.d.ts +1 -55
  89. package/dist/utils.d.ts +2 -0
  90. package/dist/utils.js +4 -0
  91. package/package.json +23 -15
  92. package/skill/SKILL.md +395 -0
  93. package/src/cli/auth.ts +37 -0
  94. package/src/cli/body.ts +100 -0
  95. package/src/cli/dispatch.ts +91 -0
  96. package/src/cli/handler-context.ts +46 -0
  97. package/src/cli/handlers/case-write.ts +26 -0
  98. package/src/cli/handlers/case.ts +13 -0
  99. package/src/cli/handlers/milestone.ts +19 -0
  100. package/src/cli/handlers/project.ts +13 -0
  101. package/src/cli/handlers/result-write.ts +40 -0
  102. package/src/cli/handlers/result.ts +14 -0
  103. package/src/cli/handlers/run-write.ts +30 -0
  104. package/src/cli/handlers/run.ts +19 -0
  105. package/src/cli/handlers/suite.ts +12 -0
  106. package/src/cli/handlers/user.ts +13 -0
  107. package/src/cli/ids.ts +20 -0
  108. package/src/cli/index.ts +224 -0
  109. package/src/cli/install-skill.ts +89 -0
  110. package/src/cli/metadata.ts +194 -0
  111. package/src/cli/output.ts +96 -0
  112. package/src/cli.ts +1 -286
  113. package/src/client-core.ts +183 -67
  114. package/src/client.ts +414 -483
  115. package/src/constants.ts +1 -0
  116. package/src/errors.ts +18 -11
  117. package/src/index.ts +50 -8
  118. package/src/modules/attachments.ts +125 -0
  119. package/src/modules/cases.ts +78 -0
  120. package/src/modules/configurations.ts +68 -0
  121. package/src/modules/datasets.ts +44 -0
  122. package/src/modules/metadata.ts +63 -0
  123. package/src/modules/milestones.ts +54 -0
  124. package/src/modules/plans.ts +89 -0
  125. package/src/modules/projects.ts +67 -0
  126. package/src/modules/reports.ts +23 -0
  127. package/src/modules/results.ts +90 -0
  128. package/src/modules/runs.ts +70 -0
  129. package/src/modules/sections.ts +55 -0
  130. package/src/modules/sharedSteps.ts +44 -0
  131. package/src/modules/suites.ts +67 -0
  132. package/src/modules/tests.ts +28 -0
  133. package/src/modules/users.ts +87 -0
  134. package/src/modules/variables.ts +36 -0
  135. package/src/schemas.ts +551 -0
  136. package/src/types.ts +11 -60
  137. package/src/utils.ts +5 -0
@@ -0,0 +1,16 @@
1
+ import { ReportSchema, ReportResultSchema } from '../schemas.js';
2
+ export class ReportModule {
3
+ client;
4
+ constructor(client) {
5
+ this.client = client;
6
+ }
7
+ async getReports(projectId) {
8
+ this.client.validateId(projectId, 'projectId');
9
+ return this.client.parse(ReportSchema.array(), await this.client.request('GET', `get_reports/${projectId}`));
10
+ }
11
+ async runReport(reportTemplateId) {
12
+ this.client.validateId(reportTemplateId, 'reportTemplateId');
13
+ return this.client.parse(ReportResultSchema, await this.client.request('GET', `run_report/${reportTemplateId}`));
14
+ }
15
+ }
16
+ //# sourceMappingURL=reports.js.map
@@ -0,0 +1,14 @@
1
+ import { TestRailClientCore } from '../client-core.js';
2
+ import type { Result, GetResultsOptions } from '../types.js';
3
+ import type { AddResultPayload, AddResultsForCasesPayload } from '../schemas.js';
4
+ export declare class ResultModule {
5
+ private readonly client;
6
+ constructor(client: TestRailClientCore);
7
+ getResults(testId: number, options?: GetResultsOptions): Promise<Result[]>;
8
+ getResultsForCase(runId: number, caseId: number, options?: GetResultsOptions): Promise<Result[]>;
9
+ getResultsForRun(runId: number, options?: GetResultsOptions): Promise<Result[]>;
10
+ addResult(testId: number, payload: AddResultPayload): Promise<Result>;
11
+ addResultForCase(runId: number, caseId: number, payload: AddResultPayload): Promise<Result>;
12
+ addResultsForCases(runId: number, payload: AddResultsForCasesPayload): Promise<Result[]>;
13
+ }
14
+ //# sourceMappingURL=results.d.ts.map
@@ -0,0 +1,69 @@
1
+ import { ResultSchema } from '../schemas.js';
2
+ import { serializeIdList } from '../utils.js';
3
+ import { z } from 'zod';
4
+ export class ResultModule {
5
+ client;
6
+ constructor(client) {
7
+ this.client = client;
8
+ }
9
+ async getResults(testId, options) {
10
+ this.client.validateId(testId, 'testId');
11
+ this.client.validatePaginationParams(options?.limit, options?.offset);
12
+ const endpoint = this.client.buildEndpoint(`get_results/${testId}`, {
13
+ created_after: options?.created_after,
14
+ created_before: options?.created_before,
15
+ created_by: serializeIdList(options?.created_by),
16
+ status_id: serializeIdList(options?.status_id),
17
+ limit: options?.limit,
18
+ offset: options?.offset,
19
+ });
20
+ const raw = await this.client.request('GET', endpoint);
21
+ return (this.client.parse(z.object({ results: z.array(ResultSchema).optional() }), raw)
22
+ .results ?? []);
23
+ }
24
+ async getResultsForCase(runId, caseId, options) {
25
+ this.client.validateId(runId, 'runId');
26
+ this.client.validateId(caseId, 'caseId');
27
+ this.client.validatePaginationParams(options?.limit, options?.offset);
28
+ const endpoint = this.client.buildEndpoint(`get_results_for_case/${runId}/${caseId}`, {
29
+ created_after: options?.created_after,
30
+ created_before: options?.created_before,
31
+ created_by: serializeIdList(options?.created_by),
32
+ status_id: serializeIdList(options?.status_id),
33
+ limit: options?.limit,
34
+ offset: options?.offset,
35
+ });
36
+ const raw = await this.client.request('GET', endpoint);
37
+ return (this.client.parse(z.object({ results: z.array(ResultSchema).optional() }), raw)
38
+ .results ?? []);
39
+ }
40
+ async getResultsForRun(runId, options) {
41
+ this.client.validateId(runId, 'runId');
42
+ this.client.validatePaginationParams(options?.limit, options?.offset);
43
+ const endpoint = this.client.buildEndpoint(`get_results_for_run/${runId}`, {
44
+ created_after: options?.created_after,
45
+ created_before: options?.created_before,
46
+ created_by: serializeIdList(options?.created_by),
47
+ status_id: serializeIdList(options?.status_id),
48
+ limit: options?.limit,
49
+ offset: options?.offset,
50
+ });
51
+ const raw = await this.client.request('GET', endpoint);
52
+ return (this.client.parse(z.object({ results: z.array(ResultSchema).optional() }), raw)
53
+ .results ?? []);
54
+ }
55
+ async addResult(testId, payload) {
56
+ this.client.validateId(testId, 'testId');
57
+ return this.client.parse(ResultSchema, await this.client.request('POST', `add_result/${testId}`, payload));
58
+ }
59
+ async addResultForCase(runId, caseId, payload) {
60
+ this.client.validateId(runId, 'runId');
61
+ this.client.validateId(caseId, 'caseId');
62
+ return this.client.parse(ResultSchema, await this.client.request('POST', `add_result_for_case/${runId}/${caseId}`, payload));
63
+ }
64
+ async addResultsForCases(runId, payload) {
65
+ this.client.validateId(runId, 'runId');
66
+ return this.client.parse(z.array(ResultSchema), await this.client.request('POST', `add_results_for_cases/${runId}`, payload));
67
+ }
68
+ }
69
+ //# sourceMappingURL=results.js.map
@@ -0,0 +1,14 @@
1
+ import { TestRailClientCore } from '../client-core.js';
2
+ import type { Run, GetRunsOptions } from '../types.js';
3
+ import type { AddRunPayload, UpdateRunPayload } from '../schemas.js';
4
+ export declare class RunModule {
5
+ private readonly client;
6
+ constructor(client: TestRailClientCore);
7
+ getRun(runId: number): Promise<Run>;
8
+ getRuns(projectId: number, options?: GetRunsOptions): Promise<Run[]>;
9
+ addRun(projectId: number, payload: AddRunPayload): Promise<Run>;
10
+ updateRun(runId: number, payload: UpdateRunPayload): Promise<Run>;
11
+ closeRun(runId: number): Promise<Run>;
12
+ deleteRun(runId: number): Promise<void>;
13
+ }
14
+ //# sourceMappingURL=runs.d.ts.map
@@ -0,0 +1,57 @@
1
+ import { RunSchema } from '../schemas.js';
2
+ import { z } from 'zod';
3
+ export class RunModule {
4
+ client;
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ async getRun(runId) {
9
+ this.client.validateId(runId, 'runId');
10
+ return this.client.parse(RunSchema, await this.client.request('GET', `get_run/${runId}`));
11
+ }
12
+ async getRuns(projectId, options) {
13
+ this.client.validateId(projectId, 'projectId');
14
+ const { createdAfter, createdBefore, createdBy, isCompleted, milestoneId, refsFilter, suiteId, limit, offset } = options ?? {};
15
+ this.client.validatePaginationParams(limit, offset);
16
+ if (milestoneId !== undefined) {
17
+ this.client.validateId(milestoneId, 'milestoneId');
18
+ }
19
+ if (suiteId !== undefined) {
20
+ this.client.validateId(suiteId, 'suiteId');
21
+ }
22
+ if (createdBy !== undefined) {
23
+ createdBy.forEach((userId) => this.client.validateId(userId, 'createdBy'));
24
+ }
25
+ const createdByFilter = createdBy && createdBy.length > 0 ? createdBy.join(',') : undefined;
26
+ const endpoint = this.client.buildEndpoint(`get_runs/${projectId}`, {
27
+ created_after: createdAfter,
28
+ created_before: createdBefore,
29
+ created_by: createdByFilter,
30
+ is_completed: isCompleted !== undefined ? (isCompleted ? 1 : 0) : undefined,
31
+ milestone_id: milestoneId,
32
+ refs_filter: refsFilter,
33
+ suite_id: suiteId,
34
+ limit,
35
+ offset,
36
+ });
37
+ const raw = await this.client.request('GET', endpoint);
38
+ return this.client.parse(z.object({ runs: z.array(RunSchema).optional() }), raw).runs ?? [];
39
+ }
40
+ async addRun(projectId, payload) {
41
+ this.client.validateId(projectId, 'projectId');
42
+ return this.client.parse(RunSchema, await this.client.request('POST', `add_run/${projectId}`, payload));
43
+ }
44
+ async updateRun(runId, payload) {
45
+ this.client.validateId(runId, 'runId');
46
+ return this.client.parse(RunSchema, await this.client.request('POST', `update_run/${runId}`, payload));
47
+ }
48
+ async closeRun(runId) {
49
+ this.client.validateId(runId, 'runId');
50
+ return this.client.parse(RunSchema, await this.client.request('POST', `close_run/${runId}`));
51
+ }
52
+ async deleteRun(runId) {
53
+ this.client.validateId(runId, 'runId');
54
+ await this.client.request('POST', `delete_run/${runId}`);
55
+ }
56
+ }
57
+ //# sourceMappingURL=runs.js.map
@@ -0,0 +1,16 @@
1
+ import { TestRailClientCore } from '../client-core.js';
2
+ import type { Section, AddSectionPayload, UpdateSectionPayload } from '../types.js';
3
+ export declare class SectionModule {
4
+ private readonly client;
5
+ constructor(client: TestRailClientCore);
6
+ getSection(sectionId: number): Promise<Section>;
7
+ getSections(projectId: number, options?: {
8
+ suiteId?: number;
9
+ limit?: number;
10
+ offset?: number;
11
+ }): Promise<Section[]>;
12
+ addSection(projectId: number, payload: AddSectionPayload): Promise<Section>;
13
+ updateSection(sectionId: number, payload: UpdateSectionPayload): Promise<Section>;
14
+ deleteSection(sectionId: number): Promise<void>;
15
+ }
16
+ //# sourceMappingURL=sections.d.ts.map
@@ -0,0 +1,37 @@
1
+ import { SectionSchema } from '../schemas.js';
2
+ import { z } from 'zod';
3
+ export class SectionModule {
4
+ client;
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ async getSection(sectionId) {
9
+ this.client.validateId(sectionId, 'sectionId');
10
+ return this.client.parse(SectionSchema, await this.client.request('GET', `get_section/${sectionId}`));
11
+ }
12
+ async getSections(projectId, options) {
13
+ this.client.validateId(projectId, 'projectId');
14
+ const { suiteId, limit, offset } = options ?? {};
15
+ if (suiteId !== undefined) {
16
+ this.client.validateId(suiteId, 'suiteId');
17
+ }
18
+ this.client.validatePaginationParams(limit, offset);
19
+ const endpoint = this.client.buildEndpoint(`get_sections/${projectId}`, { suite_id: suiteId, limit, offset });
20
+ const raw = await this.client.request('GET', endpoint);
21
+ return (this.client.parse(z.object({ sections: z.array(SectionSchema).optional() }), raw)
22
+ .sections ?? []);
23
+ }
24
+ async addSection(projectId, payload) {
25
+ this.client.validateId(projectId, 'projectId');
26
+ return this.client.parse(SectionSchema, await this.client.request('POST', `add_section/${projectId}`, payload));
27
+ }
28
+ async updateSection(sectionId, payload) {
29
+ this.client.validateId(sectionId, 'sectionId');
30
+ return this.client.parse(SectionSchema, await this.client.request('POST', `update_section/${sectionId}`, payload));
31
+ }
32
+ async deleteSection(sectionId) {
33
+ this.client.validateId(sectionId, 'sectionId');
34
+ await this.client.request('POST', `delete_section/${sectionId}`);
35
+ }
36
+ }
37
+ //# sourceMappingURL=sections.js.map
@@ -0,0 +1,12 @@
1
+ import { TestRailClientCore } from '../client-core.js';
2
+ import type { SharedStep, AddSharedStepPayload, UpdateSharedStepPayload } from '../types.js';
3
+ export declare class SharedStepModule {
4
+ private readonly client;
5
+ constructor(client: TestRailClientCore);
6
+ getSharedStep(sharedStepId: number): Promise<SharedStep>;
7
+ getSharedSteps(projectId: number): Promise<SharedStep[]>;
8
+ addSharedStep(projectId: number, payload: AddSharedStepPayload): Promise<SharedStep>;
9
+ updateSharedStep(sharedStepId: number, payload: UpdateSharedStepPayload): Promise<SharedStep>;
10
+ deleteSharedStep(sharedStepId: number): Promise<void>;
11
+ }
12
+ //# sourceMappingURL=sharedSteps.d.ts.map
@@ -0,0 +1,28 @@
1
+ import { SharedStepSchema } from '../schemas.js';
2
+ export class SharedStepModule {
3
+ client;
4
+ constructor(client) {
5
+ this.client = client;
6
+ }
7
+ async getSharedStep(sharedStepId) {
8
+ this.client.validateId(sharedStepId, 'sharedStepId');
9
+ return this.client.parse(SharedStepSchema, await this.client.request('GET', `get_shared_step/${sharedStepId}`));
10
+ }
11
+ async getSharedSteps(projectId) {
12
+ this.client.validateId(projectId, 'projectId');
13
+ return this.client.parse(SharedStepSchema.array(), await this.client.request('GET', `get_shared_steps/${projectId}`));
14
+ }
15
+ async addSharedStep(projectId, payload) {
16
+ this.client.validateId(projectId, 'projectId');
17
+ return this.client.parse(SharedStepSchema, await this.client.request('POST', `add_shared_step/${projectId}`, payload));
18
+ }
19
+ async updateSharedStep(sharedStepId, payload) {
20
+ this.client.validateId(sharedStepId, 'sharedStepId');
21
+ return this.client.parse(SharedStepSchema, await this.client.request('POST', `update_shared_step/${sharedStepId}`, payload));
22
+ }
23
+ async deleteSharedStep(sharedStepId) {
24
+ this.client.validateId(sharedStepId, 'sharedStepId');
25
+ await this.client.request('POST', `delete_shared_step/${sharedStepId}`);
26
+ }
27
+ }
28
+ //# sourceMappingURL=sharedSteps.js.map
@@ -0,0 +1,37 @@
1
+ import { TestRailClientCore } from '../client-core.js';
2
+ import type { Suite, AddSuitePayload, UpdateSuitePayload } from '../types.js';
3
+ export declare class SuiteModule {
4
+ private readonly client;
5
+ constructor(client: TestRailClientCore);
6
+ /**
7
+ * Get a suite by ID.
8
+ * @throws {TestRailValidationError} When suiteId is invalid
9
+ * @throws {TestRailApiError} When the API request fails
10
+ */
11
+ getSuite(suiteId: number): Promise<Suite>;
12
+ /**
13
+ * Get all suites for a project.
14
+ * @throws {TestRailValidationError} When projectId is invalid
15
+ * @throws {TestRailApiError} When the API request fails
16
+ */
17
+ getSuites(projectId: number): Promise<Suite[]>;
18
+ /**
19
+ * Add a suite to a project.
20
+ * @throws {TestRailValidationError} When projectId is invalid
21
+ * @throws {TestRailApiError} When the API request fails
22
+ */
23
+ addSuite(projectId: number, payload: AddSuitePayload): Promise<Suite>;
24
+ /**
25
+ * Update a suite.
26
+ * @throws {TestRailValidationError} When suiteId is invalid
27
+ * @throws {TestRailApiError} When the API request fails
28
+ */
29
+ updateSuite(suiteId: number, payload: UpdateSuitePayload): Promise<Suite>;
30
+ /**
31
+ * Delete a suite.
32
+ * @throws {TestRailValidationError} When suiteId is invalid
33
+ * @throws {TestRailApiError} When the API request fails
34
+ */
35
+ deleteSuite(suiteId: number): Promise<void>;
36
+ }
37
+ //# sourceMappingURL=suites.d.ts.map
@@ -0,0 +1,54 @@
1
+ import { SuiteSchema } from '../schemas.js';
2
+ import { z } from 'zod';
3
+ export class SuiteModule {
4
+ client;
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ /**
9
+ * Get a suite by ID.
10
+ * @throws {TestRailValidationError} When suiteId is invalid
11
+ * @throws {TestRailApiError} When the API request fails
12
+ */
13
+ async getSuite(suiteId) {
14
+ this.client.validateId(suiteId, 'suiteId');
15
+ return this.client.parse(SuiteSchema, await this.client.request('GET', `get_suite/${suiteId}`));
16
+ }
17
+ /**
18
+ * Get all suites for a project.
19
+ * @throws {TestRailValidationError} When projectId is invalid
20
+ * @throws {TestRailApiError} When the API request fails
21
+ */
22
+ async getSuites(projectId) {
23
+ this.client.validateId(projectId, 'projectId');
24
+ return this.client.parse(z.array(SuiteSchema), await this.client.request('GET', `get_suites/${projectId}`));
25
+ }
26
+ /**
27
+ * Add a suite to a project.
28
+ * @throws {TestRailValidationError} When projectId is invalid
29
+ * @throws {TestRailApiError} When the API request fails
30
+ */
31
+ async addSuite(projectId, payload) {
32
+ this.client.validateId(projectId, 'projectId');
33
+ return this.client.parse(SuiteSchema, await this.client.request('POST', `add_suite/${projectId}`, payload));
34
+ }
35
+ /**
36
+ * Update a suite.
37
+ * @throws {TestRailValidationError} When suiteId is invalid
38
+ * @throws {TestRailApiError} When the API request fails
39
+ */
40
+ async updateSuite(suiteId, payload) {
41
+ this.client.validateId(suiteId, 'suiteId');
42
+ return this.client.parse(SuiteSchema, await this.client.request('POST', `update_suite/${suiteId}`, payload));
43
+ }
44
+ /**
45
+ * Delete a suite.
46
+ * @throws {TestRailValidationError} When suiteId is invalid
47
+ * @throws {TestRailApiError} When the API request fails
48
+ */
49
+ async deleteSuite(suiteId) {
50
+ this.client.validateId(suiteId, 'suiteId');
51
+ await this.client.request('POST', `delete_suite/${suiteId}`);
52
+ }
53
+ }
54
+ //# sourceMappingURL=suites.js.map
@@ -0,0 +1,9 @@
1
+ import { TestRailClientCore } from '../client-core.js';
2
+ import type { Test, GetTestsOptions } from '../types.js';
3
+ export declare class TestModule {
4
+ private readonly client;
5
+ constructor(client: TestRailClientCore);
6
+ getTest(testId: number): Promise<Test>;
7
+ getTests(runId: number, options?: GetTestsOptions): Promise<Test[]>;
8
+ }
9
+ //# sourceMappingURL=tests.d.ts.map
@@ -0,0 +1,25 @@
1
+ import { TestSchema } from '../schemas.js';
2
+ import { serializeIdList } from '../utils.js';
3
+ import { z } from 'zod';
4
+ export class TestModule {
5
+ client;
6
+ constructor(client) {
7
+ this.client = client;
8
+ }
9
+ async getTest(testId) {
10
+ this.client.validateId(testId, 'testId');
11
+ return this.client.parse(TestSchema, await this.client.request('GET', `get_test/${testId}`));
12
+ }
13
+ async getTests(runId, options) {
14
+ this.client.validateId(runId, 'runId');
15
+ this.client.validatePaginationParams(options?.limit, options?.offset);
16
+ const endpoint = this.client.buildEndpoint(`get_tests/${runId}`, {
17
+ status_id: serializeIdList(options?.status_id),
18
+ limit: options?.limit,
19
+ offset: options?.offset,
20
+ });
21
+ const raw = await this.client.request('GET', endpoint);
22
+ return (this.client.parse(z.object({ tests: z.array(TestSchema).optional() }), raw).tests ?? []);
23
+ }
24
+ }
25
+ //# sourceMappingURL=tests.js.map
@@ -0,0 +1,18 @@
1
+ import { TestRailClientCore } from '../client-core.js';
2
+ import type { AddGroupPayload, AddUserPayload, Group, UpdateGroupPayload, UpdateUserPayload, User } from '../types.js';
3
+ export declare class UsersModule {
4
+ private readonly client;
5
+ constructor(client: TestRailClientCore);
6
+ getUser(userId: number): Promise<User>;
7
+ getUserByEmail(email: string): Promise<User>;
8
+ getUsers(limit?: number, offset?: number, projectId?: number): Promise<User[]>;
9
+ getCurrentUser(): Promise<User>;
10
+ addUser(payload: AddUserPayload): Promise<User>;
11
+ updateUser(userId: number, payload: UpdateUserPayload): Promise<User>;
12
+ getGroup(groupId: number): Promise<Group>;
13
+ getGroups(): Promise<Group[]>;
14
+ addGroup(payload: AddGroupPayload): Promise<Group>;
15
+ updateGroup(groupId: number, payload: UpdateGroupPayload): Promise<Group>;
16
+ deleteGroup(groupId: number): Promise<void>;
17
+ }
18
+ //# sourceMappingURL=users.d.ts.map
@@ -0,0 +1,62 @@
1
+ import { z } from 'zod';
2
+ import { TestRailValidationError } from '../errors.js';
3
+ import { UserSchema, GroupSchema } from '../schemas.js';
4
+ const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
5
+ export class UsersModule {
6
+ client;
7
+ constructor(client) {
8
+ this.client = client;
9
+ }
10
+ async getUser(userId) {
11
+ this.client.validateId(userId, 'userId');
12
+ return this.client.parse(UserSchema, await this.client.request('GET', `get_user/${userId}`));
13
+ }
14
+ async getUserByEmail(email) {
15
+ if (!EMAIL_REGEX.test(email)) {
16
+ throw new TestRailValidationError('Invalid email format');
17
+ }
18
+ const endpoint = this.client.buildEndpoint('get_user_by_email', { email });
19
+ return this.client.parse(UserSchema, await this.client.request('GET', endpoint));
20
+ }
21
+ async getUsers(limit, offset, projectId) {
22
+ this.client.validatePaginationParams(limit, offset);
23
+ if (projectId !== undefined) {
24
+ this.client.validateId(projectId, 'projectId');
25
+ }
26
+ const endpoint = this.client.buildEndpoint(projectId !== undefined ? `get_users/${projectId}` : 'get_users', {
27
+ limit,
28
+ offset,
29
+ });
30
+ const raw = await this.client.request('GET', endpoint);
31
+ return (this.client.parse(z.object({ users: z.array(UserSchema).optional() }), raw).users ?? []);
32
+ }
33
+ async getCurrentUser() {
34
+ return this.client.parse(UserSchema, await this.client.request('GET', 'get_current_user'));
35
+ }
36
+ async addUser(payload) {
37
+ return this.client.parse(UserSchema, await this.client.request('POST', 'add_user', payload));
38
+ }
39
+ async updateUser(userId, payload) {
40
+ this.client.validateId(userId, 'userId');
41
+ return this.client.parse(UserSchema, await this.client.request('POST', `update_user/${userId}`, payload));
42
+ }
43
+ async getGroup(groupId) {
44
+ this.client.validateId(groupId, 'groupId');
45
+ return this.client.parse(GroupSchema, await this.client.request('GET', `get_group/${groupId}`));
46
+ }
47
+ async getGroups() {
48
+ return this.client.parse(z.array(GroupSchema), await this.client.request('GET', 'get_groups'));
49
+ }
50
+ async addGroup(payload) {
51
+ return this.client.parse(GroupSchema, await this.client.request('POST', 'add_group', payload));
52
+ }
53
+ async updateGroup(groupId, payload) {
54
+ this.client.validateId(groupId, 'groupId');
55
+ return this.client.parse(GroupSchema, await this.client.request('POST', `update_group/${groupId}`, payload));
56
+ }
57
+ async deleteGroup(groupId) {
58
+ this.client.validateId(groupId, 'groupId');
59
+ await this.client.request('POST', `delete_group/${groupId}`);
60
+ }
61
+ }
62
+ //# sourceMappingURL=users.js.map
@@ -0,0 +1,11 @@
1
+ import { TestRailClientCore } from '../client-core.js';
2
+ import type { Variable, AddVariablePayload, UpdateVariablePayload } from '../types.js';
3
+ export declare class VariableModule {
4
+ private readonly client;
5
+ constructor(client: TestRailClientCore);
6
+ getVariables(projectId: number): Promise<Variable[]>;
7
+ addVariable(projectId: number, payload: AddVariablePayload): Promise<Variable>;
8
+ updateVariable(variableId: number, payload: UpdateVariablePayload): Promise<Variable>;
9
+ deleteVariable(variableId: number): Promise<void>;
10
+ }
11
+ //# sourceMappingURL=variables.d.ts.map
@@ -0,0 +1,24 @@
1
+ import { VariableSchema } from '../schemas.js';
2
+ export class VariableModule {
3
+ client;
4
+ constructor(client) {
5
+ this.client = client;
6
+ }
7
+ async getVariables(projectId) {
8
+ this.client.validateId(projectId, 'projectId');
9
+ return this.client.parse(VariableSchema.array(), await this.client.request('GET', `get_variables/${projectId}`));
10
+ }
11
+ async addVariable(projectId, payload) {
12
+ this.client.validateId(projectId, 'projectId');
13
+ return this.client.parse(VariableSchema, await this.client.request('POST', `add_variable/${projectId}`, payload));
14
+ }
15
+ async updateVariable(variableId, payload) {
16
+ this.client.validateId(variableId, 'variableId');
17
+ return this.client.parse(VariableSchema, await this.client.request('POST', `update_variable/${variableId}`, payload));
18
+ }
19
+ async deleteVariable(variableId) {
20
+ this.client.validateId(variableId, 'variableId');
21
+ await this.client.request('POST', `delete_variable/${variableId}`);
22
+ }
23
+ }
24
+ //# sourceMappingURL=variables.js.map