@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
@@ -9,4 +9,5 @@ export declare const DEFAULT_CACHE_CLEANUP_INTERVAL_MS = 60000;
9
9
  export declare const DEFAULT_MAX_CACHE_SIZE = 1000;
10
10
  export declare const DEFAULT_RATE_LIMIT_MAX_REQUESTS = 100;
11
11
  export declare const DEFAULT_RATE_LIMIT_WINDOW_MS = 60000;
12
+ export declare const DEFAULT_DNS_VALIDATION_MAX_WAIT_MS = 2000;
12
13
  //# sourceMappingURL=constants.d.ts.map
package/dist/constants.js CHANGED
@@ -11,4 +11,5 @@ export const DEFAULT_CACHE_CLEANUP_INTERVAL_MS = 60000; // 1 minute
11
11
  export const DEFAULT_MAX_CACHE_SIZE = 1000;
12
12
  export const DEFAULT_RATE_LIMIT_MAX_REQUESTS = 100;
13
13
  export const DEFAULT_RATE_LIMIT_WINDOW_MS = 60000; // 1 minute
14
+ export const DEFAULT_DNS_VALIDATION_MAX_WAIT_MS = 2000;
14
15
  //# sourceMappingURL=constants.js.map
package/dist/errors.d.ts CHANGED
@@ -1,20 +1,22 @@
1
+ import { ZodError } from 'zod';
1
2
  /**
2
3
  * Thrown when the TestRail API returns a non-2xx response or a network error occurs.
3
- *
4
- * @property status - HTTP status code (if available)
5
- * @property statusText - HTTP status text (if available)
6
- * @property response - Raw response body (if available)
7
4
  */
8
5
  export declare class TestRailApiError extends Error {
9
- readonly status?: number | undefined;
10
- readonly statusText?: string | undefined;
11
- readonly response?: string | undefined;
12
- constructor(message: string, status?: number | undefined, statusText?: string | undefined, response?: string | undefined);
6
+ readonly status: number;
7
+ readonly statusText: string;
8
+ readonly response?: unknown | undefined;
9
+ constructor(status: number, statusText: string, response?: unknown | undefined);
13
10
  }
14
11
  /**
15
12
  * Thrown when client configuration or method parameters fail validation.
16
13
  */
17
14
  export declare class TestRailValidationError extends Error {
18
- constructor(message: string);
15
+ readonly details?: unknown | undefined;
16
+ constructor(message: string, details?: unknown | undefined);
19
17
  }
18
+ /**
19
+ * Utility to convert ZodError into TestRailValidationError.
20
+ */
21
+ export declare function handleZodError(error: ZodError): TestRailValidationError;
20
22
  //# sourceMappingURL=errors.d.ts.map
package/dist/errors.js CHANGED
@@ -1,16 +1,12 @@
1
1
  /**
2
2
  * Thrown when the TestRail API returns a non-2xx response or a network error occurs.
3
- *
4
- * @property status - HTTP status code (if available)
5
- * @property statusText - HTTP status text (if available)
6
- * @property response - Raw response body (if available)
7
3
  */
8
4
  export class TestRailApiError extends Error {
9
5
  status;
10
6
  statusText;
11
7
  response;
12
- constructor(message, status, statusText, response) {
13
- super(message);
8
+ constructor(status, statusText, response) {
9
+ super(`TestRail API error: ${status} ${statusText}`);
14
10
  this.status = status;
15
11
  this.statusText = statusText;
16
12
  this.response = response;
@@ -21,9 +17,17 @@ export class TestRailApiError extends Error {
21
17
  * Thrown when client configuration or method parameters fail validation.
22
18
  */
23
19
  export class TestRailValidationError extends Error {
24
- constructor(message) {
25
- super(message);
20
+ details;
21
+ constructor(message, details) {
22
+ super(`TestRail Validation Error: ${message}`);
23
+ this.details = details;
26
24
  this.name = 'TestRailValidationError';
27
25
  }
28
26
  }
27
+ /**
28
+ * Utility to convert ZodError into TestRailValidationError.
29
+ */
30
+ export function handleZodError(error) {
31
+ return new TestRailValidationError('Schema validation failed', error.format());
32
+ }
29
33
  //# sourceMappingURL=errors.js.map
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export { TestRailClient } from './client.js';
2
- export { TestRailApiError, TestRailValidationError } from './errors.js';
3
- export type { TestRailConfig, RateLimiterConfig, Case, Suite, AddSuitePayload, UpdateSuitePayload, Section, Project, Plan, PlanEntry, Run, Test, Result, Milestone, User, Status, Priority, AddCasePayload, UpdateCasePayload, AddPlanPayload, UpdatePlanPayload, AddPlanEntryPayload, UpdatePlanEntryPayload, AddRunPayload, UpdateRunPayload, AddResultPayload, AddResultsForCasesPayload, AddResultForCasePayload, AddSectionPayload, UpdateSectionPayload, AddMilestonePayload, UpdateMilestonePayload, AddProjectPayload, UpdateProjectPayload, GetCasesOptions, GetPlansOptions, GetTestsOptions, GetResultsOptions, GetMilestonesOptions, GetRunsOptions, ResultField, ResultFieldConfig, CaseField, CaseFieldConfig, CaseType, Template, ConfigurationGroup, Configuration, AddConfigurationGroupPayload, UpdateConfigurationGroupPayload, AddConfigurationPayload, UpdateConfigurationPayload, AddUserPayload, UpdateUserPayload, Role, Group, AddGroupPayload, UpdateGroupPayload, Attachment, SharedStep, AddSharedStepPayload, UpdateSharedStepPayload, Variable, AddVariablePayload, UpdateVariablePayload, Dataset, AddDatasetPayload, UpdateDatasetPayload, Report, ReportResult, } from './types.js';
2
+ export { TestRailApiError, TestRailValidationError, handleZodError } from './errors.js';
3
+ export { TestRailConfigSchema, PaginationSchema, UserSchema, RoleSchema, GroupSchema, ProjectSchema, SuiteSchema, CaseSchema, SectionSchema, RunSchema, PlanEntrySchema, PlanSchema, TestSchema, ResultSchema, MilestoneSchema, StatusSchema, PrioritySchema, CaseFieldConfigSchema, CaseFieldSchema, ResultFieldConfigSchema, ResultFieldSchema, CaseTypeSchema, TemplateSchema, ConfigurationSchema, ConfigurationGroupSchema, AttachmentSchema, SharedStepSchema, VariableSchema, DatasetSchema, ReportSchema, ReportResultSchema, AddCasePayloadSchema, UpdateCasePayloadSchema, AddRunPayloadSchema, UpdateRunPayloadSchema, AddResultPayloadSchema, AddResultForCasePayloadSchema, AddResultsForCasesPayloadSchema, } from './schemas.js';
4
+ export type { AddCasePayload, UpdateCasePayload, AddRunPayload, UpdateRunPayload, AddResultPayload, AddResultForCasePayload, AddResultsForCasesPayload, } from './schemas.js';
5
+ export type { TestRailConfig, RateLimiterConfig, Case, Suite, AddSuitePayload, UpdateSuitePayload, Section, Project, Plan, PlanEntry, Run, Test, Result, Milestone, User, Status, Priority, AddPlanPayload, UpdatePlanPayload, AddPlanEntryPayload, UpdatePlanEntryPayload, AddSectionPayload, UpdateSectionPayload, AddMilestonePayload, UpdateMilestonePayload, AddProjectPayload, UpdateProjectPayload, GetCasesOptions, GetPlansOptions, GetTestsOptions, GetResultsOptions, GetMilestonesOptions, GetRunsOptions, ResultField, ResultFieldConfig, CaseField, CaseFieldConfig, CaseType, Template, ConfigurationGroup, Configuration, AddConfigurationGroupPayload, UpdateConfigurationGroupPayload, AddConfigurationPayload, UpdateConfigurationPayload, AddUserPayload, UpdateUserPayload, Role, Group, AddGroupPayload, UpdateGroupPayload, Attachment, SharedStep, AddSharedStepPayload, UpdateSharedStepPayload, Variable, AddVariablePayload, UpdateVariablePayload, Dataset, AddDatasetPayload, UpdateDatasetPayload, Report, ReportResult, } from './types.js';
4
6
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export { TestRailClient } from './client.js';
2
- export { TestRailApiError, TestRailValidationError } from './errors.js';
2
+ export { TestRailApiError, TestRailValidationError, handleZodError } from './errors.js';
3
+ export { TestRailConfigSchema, PaginationSchema, UserSchema, RoleSchema, GroupSchema, ProjectSchema, SuiteSchema, CaseSchema, SectionSchema, RunSchema, PlanEntrySchema, PlanSchema, TestSchema, ResultSchema, MilestoneSchema, StatusSchema, PrioritySchema, CaseFieldConfigSchema, CaseFieldSchema, ResultFieldConfigSchema, ResultFieldSchema, CaseTypeSchema, TemplateSchema, ConfigurationSchema, ConfigurationGroupSchema, AttachmentSchema, SharedStepSchema, VariableSchema, DatasetSchema, ReportSchema, ReportResultSchema, AddCasePayloadSchema, UpdateCasePayloadSchema, AddRunPayloadSchema, UpdateRunPayloadSchema, AddResultPayloadSchema, AddResultForCasePayloadSchema, AddResultsForCasesPayloadSchema, } from './schemas.js';
3
4
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,19 @@
1
+ import { TestRailClientCore } from '../client-core.js';
2
+ import type { Attachment } from '../types.js';
3
+ export declare class AttachmentModule {
4
+ private readonly client;
5
+ constructor(client: TestRailClientCore);
6
+ getAttachmentsForCase(caseId: number): Promise<Attachment[]>;
7
+ getAttachmentsForRun(runId: number): Promise<Attachment[]>;
8
+ getAttachmentsForTest(testId: number): Promise<Attachment[]>;
9
+ getAttachmentsForPlan(planId: number): Promise<Attachment[]>;
10
+ getAttachmentsForPlanEntry(planId: number, entryId: number): Promise<Attachment[]>;
11
+ getAttachment(attachmentId: number): Promise<ArrayBuffer>;
12
+ addAttachmentToCase(caseId: number, file: globalThis.Blob | Uint8Array | globalThis.File, filename: string): Promise<Attachment>;
13
+ addAttachmentToResult(resultId: number, file: globalThis.Blob | Uint8Array | globalThis.File, filename: string): Promise<Attachment>;
14
+ addAttachmentToRun(runId: number, file: globalThis.Blob | Uint8Array | globalThis.File, filename: string): Promise<Attachment>;
15
+ addAttachmentToPlan(planId: number, file: globalThis.Blob | Uint8Array | globalThis.File, filename: string): Promise<Attachment>;
16
+ addAttachmentToPlanEntry(planId: number, entryId: number, file: globalThis.Blob | Uint8Array | globalThis.File, filename: string): Promise<Attachment>;
17
+ deleteAttachment(attachmentId: number): Promise<void>;
18
+ }
19
+ //# sourceMappingURL=attachments.d.ts.map
@@ -0,0 +1,64 @@
1
+ import { z } from 'zod';
2
+ import { AttachmentSchema } from '../schemas.js';
3
+ export class AttachmentModule {
4
+ client;
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ async getAttachmentsForCase(caseId) {
9
+ this.client.validateId(caseId, 'caseId');
10
+ const raw = await this.client.request('GET', `get_attachments_for_case/${caseId}`);
11
+ return (this.client.parse(z.object({ attachments: z.array(AttachmentSchema).optional() }), raw).attachments ?? []);
12
+ }
13
+ async getAttachmentsForRun(runId) {
14
+ this.client.validateId(runId, 'runId');
15
+ const raw = await this.client.request('GET', `get_attachments_for_run/${runId}`);
16
+ return (this.client.parse(z.object({ attachments: z.array(AttachmentSchema).optional() }), raw).attachments ?? []);
17
+ }
18
+ async getAttachmentsForTest(testId) {
19
+ this.client.validateId(testId, 'testId');
20
+ const raw = await this.client.request('GET', `get_attachments_for_test/${testId}`);
21
+ return (this.client.parse(z.object({ attachments: z.array(AttachmentSchema).optional() }), raw).attachments ?? []);
22
+ }
23
+ async getAttachmentsForPlan(planId) {
24
+ this.client.validateId(planId, 'planId');
25
+ const raw = await this.client.request('GET', `get_attachments_for_plan/${planId}`);
26
+ return (this.client.parse(z.object({ attachments: z.array(AttachmentSchema).optional() }), raw).attachments ?? []);
27
+ }
28
+ async getAttachmentsForPlanEntry(planId, entryId) {
29
+ this.client.validateId(planId, 'planId');
30
+ this.client.validateId(entryId, 'entryId');
31
+ const raw = await this.client.request('GET', `get_attachments_for_plan_entry/${planId}/${entryId}`);
32
+ return (this.client.parse(z.object({ attachments: z.array(AttachmentSchema).optional() }), raw).attachments ?? []);
33
+ }
34
+ async getAttachment(attachmentId) {
35
+ this.client.validateId(attachmentId, 'attachmentId');
36
+ return this.client.requestBinary(`get_attachment/${attachmentId}`);
37
+ }
38
+ async addAttachmentToCase(caseId, file, filename) {
39
+ this.client.validateId(caseId, 'caseId');
40
+ return this.client.requestMultipart(`add_attachment_to_case/${caseId}`, file, filename);
41
+ }
42
+ async addAttachmentToResult(resultId, file, filename) {
43
+ this.client.validateId(resultId, 'resultId');
44
+ return this.client.requestMultipart(`add_attachment_to_result/${resultId}`, file, filename);
45
+ }
46
+ async addAttachmentToRun(runId, file, filename) {
47
+ this.client.validateId(runId, 'runId');
48
+ return this.client.requestMultipart(`add_attachment_to_run/${runId}`, file, filename);
49
+ }
50
+ async addAttachmentToPlan(planId, file, filename) {
51
+ this.client.validateId(planId, 'planId');
52
+ return this.client.requestMultipart(`add_attachment_to_plan/${planId}`, file, filename);
53
+ }
54
+ async addAttachmentToPlanEntry(planId, entryId, file, filename) {
55
+ this.client.validateId(planId, 'planId');
56
+ this.client.validateId(entryId, 'entryId');
57
+ return this.client.requestMultipart(`add_attachment_to_plan_entry/${planId}/${entryId}`, file, filename);
58
+ }
59
+ async deleteAttachment(attachmentId) {
60
+ this.client.validateId(attachmentId, 'attachmentId');
61
+ await this.client.request('POST', `delete_attachment/${attachmentId}`);
62
+ }
63
+ }
64
+ //# sourceMappingURL=attachments.js.map
@@ -0,0 +1,13 @@
1
+ import { TestRailClientCore } from '../client-core.js';
2
+ import type { Case, GetCasesOptions } from '../types.js';
3
+ import type { AddCasePayload, UpdateCasePayload } from '../schemas.js';
4
+ export declare class CaseModule {
5
+ private readonly client;
6
+ constructor(client: TestRailClientCore);
7
+ getCase(caseId: number): Promise<Case>;
8
+ getCases(projectId: number, options?: GetCasesOptions): Promise<Case[]>;
9
+ addCase(sectionId: number, payload: AddCasePayload): Promise<Case>;
10
+ updateCase(caseId: number, payload: UpdateCasePayload): Promise<Case>;
11
+ deleteCase(caseId: number): Promise<void>;
12
+ }
13
+ //# sourceMappingURL=cases.d.ts.map
@@ -0,0 +1,58 @@
1
+ import { CaseSchema } from '../schemas.js';
2
+ import { z } from 'zod';
3
+ export class CaseModule {
4
+ client;
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ async getCase(caseId) {
9
+ this.client.validateId(caseId, 'caseId');
10
+ return this.client.parse(CaseSchema, await this.client.request('GET', `get_case/${caseId}`));
11
+ }
12
+ async getCases(projectId, options) {
13
+ this.client.validateId(projectId, 'projectId');
14
+ const { suiteId, sectionId, typeId, priorityId, templateId, milestoneId, createdAfter, createdBefore, updatedAfter, updatedBefore, limit, offset, } = options ?? {};
15
+ if (suiteId !== undefined)
16
+ this.client.validateId(suiteId, 'suiteId');
17
+ if (sectionId !== undefined)
18
+ this.client.validateId(sectionId, 'sectionId');
19
+ if (typeId !== undefined)
20
+ this.client.validateId(typeId, 'typeId');
21
+ if (priorityId !== undefined)
22
+ this.client.validateId(priorityId, 'priorityId');
23
+ if (templateId !== undefined)
24
+ this.client.validateId(templateId, 'templateId');
25
+ if (milestoneId !== undefined)
26
+ this.client.validateId(milestoneId, 'milestoneId');
27
+ this.client.validatePaginationParams(limit, offset);
28
+ const endpoint = this.client.buildEndpoint(`get_cases/${projectId}`, {
29
+ suite_id: suiteId,
30
+ section_id: sectionId,
31
+ type_id: typeId,
32
+ priority_id: priorityId,
33
+ template_id: templateId,
34
+ milestone_id: milestoneId,
35
+ created_after: createdAfter,
36
+ created_before: createdBefore,
37
+ updated_after: updatedAfter,
38
+ updated_before: updatedBefore,
39
+ limit,
40
+ offset,
41
+ });
42
+ const raw = await this.client.request('GET', endpoint);
43
+ return (this.client.parse(z.object({ cases: z.array(CaseSchema).optional() }), raw).cases ?? []);
44
+ }
45
+ async addCase(sectionId, payload) {
46
+ this.client.validateId(sectionId, 'sectionId');
47
+ return this.client.parse(CaseSchema, await this.client.request('POST', `add_case/${sectionId}`, payload));
48
+ }
49
+ async updateCase(caseId, payload) {
50
+ this.client.validateId(caseId, 'caseId');
51
+ return this.client.parse(CaseSchema, await this.client.request('POST', `update_case/${caseId}`, payload));
52
+ }
53
+ async deleteCase(caseId) {
54
+ this.client.validateId(caseId, 'caseId');
55
+ await this.client.request('POST', `delete_case/${caseId}`);
56
+ }
57
+ }
58
+ //# sourceMappingURL=cases.js.map
@@ -0,0 +1,14 @@
1
+ import { TestRailClientCore } from '../client-core.js';
2
+ import type { ConfigurationGroup, Configuration, AddConfigurationGroupPayload, UpdateConfigurationGroupPayload, AddConfigurationPayload, UpdateConfigurationPayload } from '../types.js';
3
+ export declare class ConfigurationModule {
4
+ private readonly client;
5
+ constructor(client: TestRailClientCore);
6
+ getConfigurations(projectId: number): Promise<ConfigurationGroup[]>;
7
+ addConfigurationGroup(projectId: number, payload: AddConfigurationGroupPayload): Promise<ConfigurationGroup>;
8
+ updateConfigurationGroup(configGroupId: number, payload: UpdateConfigurationGroupPayload): Promise<ConfigurationGroup>;
9
+ deleteConfigurationGroup(configGroupId: number): Promise<void>;
10
+ addConfiguration(configGroupId: number, payload: AddConfigurationPayload): Promise<Configuration>;
11
+ updateConfiguration(configId: number, payload: UpdateConfigurationPayload): Promise<Configuration>;
12
+ deleteConfiguration(configId: number): Promise<void>;
13
+ }
14
+ //# sourceMappingURL=configurations.d.ts.map
@@ -0,0 +1,37 @@
1
+ import { ConfigurationGroupSchema, ConfigurationSchema } from '../schemas.js';
2
+ import { z } from 'zod';
3
+ export class ConfigurationModule {
4
+ client;
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ async getConfigurations(projectId) {
9
+ this.client.validateId(projectId, 'projectId');
10
+ return this.client.parse(z.array(ConfigurationGroupSchema), await this.client.request('GET', `get_configs/${projectId}`));
11
+ }
12
+ async addConfigurationGroup(projectId, payload) {
13
+ this.client.validateId(projectId, 'projectId');
14
+ return this.client.parse(ConfigurationGroupSchema, await this.client.request('POST', `add_config_group/${projectId}`, payload));
15
+ }
16
+ async updateConfigurationGroup(configGroupId, payload) {
17
+ this.client.validateId(configGroupId, 'configGroupId');
18
+ return this.client.parse(ConfigurationGroupSchema, await this.client.request('POST', `update_config_group/${configGroupId}`, payload));
19
+ }
20
+ async deleteConfigurationGroup(configGroupId) {
21
+ this.client.validateId(configGroupId, 'configGroupId');
22
+ await this.client.request('POST', `delete_config_group/${configGroupId}`);
23
+ }
24
+ async addConfiguration(configGroupId, payload) {
25
+ this.client.validateId(configGroupId, 'configGroupId');
26
+ return this.client.parse(ConfigurationSchema, await this.client.request('POST', `add_config/${configGroupId}`, payload));
27
+ }
28
+ async updateConfiguration(configId, payload) {
29
+ this.client.validateId(configId, 'configId');
30
+ return this.client.parse(ConfigurationSchema, await this.client.request('POST', `update_config/${configId}`, payload));
31
+ }
32
+ async deleteConfiguration(configId) {
33
+ this.client.validateId(configId, 'configId');
34
+ await this.client.request('POST', `delete_config/${configId}`);
35
+ }
36
+ }
37
+ //# sourceMappingURL=configurations.js.map
@@ -0,0 +1,12 @@
1
+ import { TestRailClientCore } from '../client-core.js';
2
+ import type { Dataset, AddDatasetPayload, UpdateDatasetPayload } from '../types.js';
3
+ export declare class DatasetModule {
4
+ private readonly client;
5
+ constructor(client: TestRailClientCore);
6
+ getDataset(datasetId: number): Promise<Dataset>;
7
+ getDatasets(projectId: number): Promise<Dataset[]>;
8
+ addDataset(projectId: number, payload: AddDatasetPayload): Promise<Dataset>;
9
+ updateDataset(datasetId: number, payload: UpdateDatasetPayload): Promise<Dataset>;
10
+ deleteDataset(datasetId: number): Promise<void>;
11
+ }
12
+ //# sourceMappingURL=datasets.d.ts.map
@@ -0,0 +1,28 @@
1
+ import { DatasetSchema } from '../schemas.js';
2
+ export class DatasetModule {
3
+ client;
4
+ constructor(client) {
5
+ this.client = client;
6
+ }
7
+ async getDataset(datasetId) {
8
+ this.client.validateId(datasetId, 'datasetId');
9
+ return this.client.parse(DatasetSchema, await this.client.request('GET', `get_dataset/${datasetId}`));
10
+ }
11
+ async getDatasets(projectId) {
12
+ this.client.validateId(projectId, 'projectId');
13
+ return this.client.parse(DatasetSchema.array(), await this.client.request('GET', `get_datasets/${projectId}`));
14
+ }
15
+ async addDataset(projectId, payload) {
16
+ this.client.validateId(projectId, 'projectId');
17
+ return this.client.parse(DatasetSchema, await this.client.request('POST', `add_dataset/${projectId}`, payload));
18
+ }
19
+ async updateDataset(datasetId, payload) {
20
+ this.client.validateId(datasetId, 'datasetId');
21
+ return this.client.parse(DatasetSchema, await this.client.request('POST', `update_dataset/${datasetId}`, payload));
22
+ }
23
+ async deleteDataset(datasetId) {
24
+ this.client.validateId(datasetId, 'datasetId');
25
+ await this.client.request('POST', `delete_dataset/${datasetId}`);
26
+ }
27
+ }
28
+ //# sourceMappingURL=datasets.js.map
@@ -0,0 +1,14 @@
1
+ import { TestRailClientCore } from '../client-core.js';
2
+ import type { Status, Priority, ResultField, CaseField, CaseType, Template, Role } from '../types.js';
3
+ export declare class MetadataModule {
4
+ private readonly client;
5
+ constructor(client: TestRailClientCore);
6
+ getStatuses(): Promise<Status[]>;
7
+ getPriorities(): Promise<Priority[]>;
8
+ getResultFields(): Promise<ResultField[]>;
9
+ getCaseFields(): Promise<CaseField[]>;
10
+ getCaseTypes(): Promise<CaseType[]>;
11
+ getTemplates(projectId: number): Promise<Template[]>;
12
+ getRoles(): Promise<Role[]>;
13
+ }
14
+ //# sourceMappingURL=metadata.d.ts.map
@@ -0,0 +1,31 @@
1
+ import { StatusSchema, PrioritySchema, ResultFieldSchema, CaseFieldSchema, CaseTypeSchema, TemplateSchema, RoleSchema, } from '../schemas.js';
2
+ import { z } from 'zod';
3
+ export class MetadataModule {
4
+ client;
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ async getStatuses() {
9
+ return this.client.parse(z.array(StatusSchema), await this.client.request('GET', 'get_statuses'));
10
+ }
11
+ async getPriorities() {
12
+ return this.client.parse(z.array(PrioritySchema), await this.client.request('GET', 'get_priorities'));
13
+ }
14
+ async getResultFields() {
15
+ return this.client.parse(z.array(ResultFieldSchema), await this.client.request('GET', 'get_result_fields'));
16
+ }
17
+ async getCaseFields() {
18
+ return this.client.parse(z.array(CaseFieldSchema), await this.client.request('GET', 'get_case_fields'));
19
+ }
20
+ async getCaseTypes() {
21
+ return this.client.parse(z.array(CaseTypeSchema), await this.client.request('GET', 'get_case_types'));
22
+ }
23
+ async getTemplates(projectId) {
24
+ this.client.validateId(projectId, 'projectId');
25
+ return this.client.parse(z.array(TemplateSchema), await this.client.request('GET', `get_templates/${projectId}`));
26
+ }
27
+ async getRoles() {
28
+ return this.client.parse(z.array(RoleSchema), await this.client.request('GET', 'get_roles'));
29
+ }
30
+ }
31
+ //# sourceMappingURL=metadata.js.map
@@ -0,0 +1,12 @@
1
+ import { TestRailClientCore } from '../client-core.js';
2
+ import type { Milestone, GetMilestonesOptions, AddMilestonePayload, UpdateMilestonePayload } from '../types.js';
3
+ export declare class MilestoneModule {
4
+ private readonly client;
5
+ constructor(client: TestRailClientCore);
6
+ getMilestone(milestoneId: number): Promise<Milestone>;
7
+ getMilestones(projectId: number, options?: GetMilestonesOptions): Promise<Milestone[]>;
8
+ addMilestone(projectId: number, payload: AddMilestonePayload): Promise<Milestone>;
9
+ updateMilestone(milestoneId: number, payload: UpdateMilestonePayload): Promise<Milestone>;
10
+ deleteMilestone(milestoneId: number): Promise<void>;
11
+ }
12
+ //# sourceMappingURL=milestones.d.ts.map
@@ -0,0 +1,36 @@
1
+ import { MilestoneSchema } from '../schemas.js';
2
+ import { z } from 'zod';
3
+ export class MilestoneModule {
4
+ client;
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ async getMilestone(milestoneId) {
9
+ this.client.validateId(milestoneId, 'milestoneId');
10
+ return this.client.parse(MilestoneSchema, await this.client.request('GET', `get_milestone/${milestoneId}`));
11
+ }
12
+ async getMilestones(projectId, options) {
13
+ this.client.validateId(projectId, 'projectId');
14
+ this.client.validatePaginationParams(options?.limit, options?.offset);
15
+ const endpoint = this.client.buildEndpoint(`get_milestones/${projectId}`, {
16
+ is_completed: options?.is_completed,
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({ milestones: z.array(MilestoneSchema).optional() }), raw).milestones ?? []);
22
+ }
23
+ async addMilestone(projectId, payload) {
24
+ this.client.validateId(projectId, 'projectId');
25
+ return this.client.parse(MilestoneSchema, await this.client.request('POST', `add_milestone/${projectId}`, payload));
26
+ }
27
+ async updateMilestone(milestoneId, payload) {
28
+ this.client.validateId(milestoneId, 'milestoneId');
29
+ return this.client.parse(MilestoneSchema, await this.client.request('POST', `update_milestone/${milestoneId}`, payload));
30
+ }
31
+ async deleteMilestone(milestoneId) {
32
+ this.client.validateId(milestoneId, 'milestoneId');
33
+ await this.client.request('POST', `delete_milestone/${milestoneId}`);
34
+ }
35
+ }
36
+ //# sourceMappingURL=milestones.js.map
@@ -0,0 +1,16 @@
1
+ import { TestRailClientCore } from '../client-core.js';
2
+ import type { Plan, PlanEntry, GetPlansOptions, AddPlanPayload, UpdatePlanPayload, AddPlanEntryPayload, UpdatePlanEntryPayload } from '../types.js';
3
+ export declare class PlanModule {
4
+ private readonly client;
5
+ constructor(client: TestRailClientCore);
6
+ getPlan(planId: number): Promise<Plan>;
7
+ getPlans(projectId: number, options?: GetPlansOptions): Promise<Plan[]>;
8
+ addPlan(projectId: number, payload: AddPlanPayload): Promise<Plan>;
9
+ updatePlan(planId: number, payload: UpdatePlanPayload): Promise<Plan>;
10
+ closePlan(planId: number): Promise<Plan>;
11
+ deletePlan(planId: number): Promise<void>;
12
+ addPlanEntry(planId: number, payload: AddPlanEntryPayload): Promise<PlanEntry>;
13
+ updatePlanEntry(planId: number, entryId: string, payload: UpdatePlanEntryPayload): Promise<PlanEntry>;
14
+ deletePlanEntry(planId: number, entryId: string): Promise<void>;
15
+ }
16
+ //# sourceMappingURL=plans.d.ts.map
@@ -0,0 +1,59 @@
1
+ import { PlanSchema, PlanEntrySchema } from '../schemas.js';
2
+ import { serializeIdList } from '../utils.js';
3
+ import { z } from 'zod';
4
+ export class PlanModule {
5
+ client;
6
+ constructor(client) {
7
+ this.client = client;
8
+ }
9
+ async getPlan(planId) {
10
+ this.client.validateId(planId, 'planId');
11
+ return this.client.parse(PlanSchema, await this.client.request('GET', `get_plan/${planId}`));
12
+ }
13
+ async getPlans(projectId, options) {
14
+ this.client.validateId(projectId, 'projectId');
15
+ this.client.validatePaginationParams(options?.limit, options?.offset);
16
+ const endpoint = this.client.buildEndpoint(`get_plans/${projectId}`, {
17
+ created_after: options?.created_after,
18
+ created_before: options?.created_before,
19
+ created_by: serializeIdList(options?.created_by),
20
+ is_completed: options?.is_completed,
21
+ milestone_id: serializeIdList(options?.milestone_id),
22
+ limit: options?.limit,
23
+ offset: options?.offset,
24
+ });
25
+ const raw = await this.client.request('GET', endpoint);
26
+ return (this.client.parse(z.object({ plans: z.array(PlanSchema).optional() }), raw).plans ?? []);
27
+ }
28
+ async addPlan(projectId, payload) {
29
+ this.client.validateId(projectId, 'projectId');
30
+ return this.client.parse(PlanSchema, await this.client.request('POST', `add_plan/${projectId}`, payload));
31
+ }
32
+ async updatePlan(planId, payload) {
33
+ this.client.validateId(planId, 'planId');
34
+ return this.client.parse(PlanSchema, await this.client.request('POST', `update_plan/${planId}`, payload));
35
+ }
36
+ async closePlan(planId) {
37
+ this.client.validateId(planId, 'planId');
38
+ return this.client.parse(PlanSchema, await this.client.request('POST', `close_plan/${planId}`));
39
+ }
40
+ async deletePlan(planId) {
41
+ this.client.validateId(planId, 'planId');
42
+ await this.client.request('POST', `delete_plan/${planId}`);
43
+ }
44
+ async addPlanEntry(planId, payload) {
45
+ this.client.validateId(planId, 'planId');
46
+ return this.client.parse(PlanEntrySchema, await this.client.request('POST', `add_plan_entry/${planId}`, payload));
47
+ }
48
+ async updatePlanEntry(planId, entryId, payload) {
49
+ this.client.validateId(planId, 'planId');
50
+ this.client.validateEntryId(entryId);
51
+ return this.client.parse(PlanEntrySchema, await this.client.request('POST', `update_plan_entry/${planId}/${entryId}`, payload));
52
+ }
53
+ async deletePlanEntry(planId, entryId) {
54
+ this.client.validateId(planId, 'planId');
55
+ this.client.validateEntryId(entryId);
56
+ await this.client.request('POST', `delete_plan_entry/${planId}/${entryId}`);
57
+ }
58
+ }
59
+ //# sourceMappingURL=plans.js.map
@@ -0,0 +1,36 @@
1
+ import { TestRailClientCore } from '../client-core.js';
2
+ import type { Project, AddProjectPayload, UpdateProjectPayload } from '../types.js';
3
+ export declare class ProjectModule {
4
+ private readonly client;
5
+ constructor(client: TestRailClientCore);
6
+ /**
7
+ * Get a project by ID.
8
+ * @throws {TestRailValidationError} When projectId is invalid
9
+ * @throws {TestRailApiError} When the API request fails
10
+ */
11
+ getProject(projectId: number): Promise<Project>;
12
+ /**
13
+ * Get all projects.
14
+ * @throws {TestRailValidationError} When limit or offset is invalid
15
+ * @throws {TestRailApiError} When the API request fails
16
+ */
17
+ getProjects(limit?: number, offset?: number): Promise<Project[]>;
18
+ /**
19
+ * Add a new project.
20
+ * @throws {TestRailApiError} When the API request fails
21
+ */
22
+ addProject(payload: AddProjectPayload): Promise<Project>;
23
+ /**
24
+ * Update an existing project.
25
+ * @throws {TestRailValidationError} When projectId is invalid
26
+ * @throws {TestRailApiError} When the API request fails
27
+ */
28
+ updateProject(projectId: number, payload: UpdateProjectPayload): Promise<Project>;
29
+ /**
30
+ * Delete a project.
31
+ * @throws {TestRailValidationError} When projectId is invalid
32
+ * @throws {TestRailApiError} When the API request fails
33
+ */
34
+ deleteProject(projectId: number): Promise<void>;
35
+ }
36
+ //# sourceMappingURL=projects.d.ts.map
@@ -0,0 +1,55 @@
1
+ import { ProjectSchema } from '../schemas.js';
2
+ import { z } from 'zod';
3
+ export class ProjectModule {
4
+ client;
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ /**
9
+ * Get a project by ID.
10
+ * @throws {TestRailValidationError} When projectId is invalid
11
+ * @throws {TestRailApiError} When the API request fails
12
+ */
13
+ async getProject(projectId) {
14
+ this.client.validateId(projectId, 'projectId');
15
+ return this.client.parse(ProjectSchema, await this.client.request('GET', `get_project/${projectId}`));
16
+ }
17
+ /**
18
+ * Get all projects.
19
+ * @throws {TestRailValidationError} When limit or offset is invalid
20
+ * @throws {TestRailApiError} When the API request fails
21
+ */
22
+ async getProjects(limit, offset) {
23
+ this.client.validatePaginationParams(limit, offset);
24
+ const endpoint = this.client.buildEndpoint('get_projects', { limit, offset });
25
+ const raw = await this.client.request('GET', endpoint);
26
+ return (this.client.parse(z.object({ projects: z.array(ProjectSchema).optional() }), raw)
27
+ .projects ?? []);
28
+ }
29
+ /**
30
+ * Add a new project.
31
+ * @throws {TestRailApiError} When the API request fails
32
+ */
33
+ async addProject(payload) {
34
+ return this.client.parse(ProjectSchema, await this.client.request('POST', 'add_project', payload));
35
+ }
36
+ /**
37
+ * Update an existing project.
38
+ * @throws {TestRailValidationError} When projectId is invalid
39
+ * @throws {TestRailApiError} When the API request fails
40
+ */
41
+ async updateProject(projectId, payload) {
42
+ this.client.validateId(projectId, 'projectId');
43
+ return this.client.parse(ProjectSchema, await this.client.request('POST', `update_project/${projectId}`, payload));
44
+ }
45
+ /**
46
+ * Delete a project.
47
+ * @throws {TestRailValidationError} When projectId is invalid
48
+ * @throws {TestRailApiError} When the API request fails
49
+ */
50
+ async deleteProject(projectId) {
51
+ this.client.validateId(projectId, 'projectId');
52
+ await this.client.request('POST', `delete_project/${projectId}`);
53
+ }
54
+ }
55
+ //# sourceMappingURL=projects.js.map
@@ -0,0 +1,9 @@
1
+ import { TestRailClientCore } from '../client-core.js';
2
+ import type { Report, ReportResult } from '../types.js';
3
+ export declare class ReportModule {
4
+ private readonly client;
5
+ constructor(client: TestRailClientCore);
6
+ getReports(projectId: number): Promise<Report[]>;
7
+ runReport(reportTemplateId: number): Promise<ReportResult>;
8
+ }
9
+ //# sourceMappingURL=reports.d.ts.map