@tiden/reporter-commons 0.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 (174) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE +201 -0
  3. package/README.md +34 -0
  4. package/dist/client/interface.d.ts +8 -0
  5. package/dist/client/interface.js +2 -0
  6. package/dist/client/reporter-api-models.d.ts +96 -0
  7. package/dist/client/reporter-api-models.js +2 -0
  8. package/dist/client/reporter-api.d.ts +14 -0
  9. package/dist/client/reporter-api.js +25 -0
  10. package/dist/client/services/api-error-handler.d.ts +10 -0
  11. package/dist/client/services/api-error-handler.js +44 -0
  12. package/dist/client/services/attachment-service.d.ts +29 -0
  13. package/dist/client/services/attachment-service.js +268 -0
  14. package/dist/client/services/result-transformer.d.ts +21 -0
  15. package/dist/client/services/result-transformer.js +180 -0
  16. package/dist/client/services/run-service.d.ts +20 -0
  17. package/dist/client/services/run-service.js +68 -0
  18. package/dist/client/tiden-client.d.ts +34 -0
  19. package/dist/client/tiden-client.js +99 -0
  20. package/dist/client/tiden-http.d.ts +11 -0
  21. package/dist/client/tiden-http.js +23 -0
  22. package/dist/config/config-loader-interface.d.ts +4 -0
  23. package/dist/config/config-loader-interface.js +2 -0
  24. package/dist/config/config-loader.d.ts +10 -0
  25. package/dist/config/config-loader.js +60 -0
  26. package/dist/config/config-type.d.ts +2 -0
  27. package/dist/config/config-type.js +2 -0
  28. package/dist/config/config-validation-schema.d.ts +212 -0
  29. package/dist/config/config-validation-schema.js +213 -0
  30. package/dist/config/index.d.ts +4 -0
  31. package/dist/config/index.js +7 -0
  32. package/dist/core/options-resolver.d.ts +19 -0
  33. package/dist/core/options-resolver.js +47 -0
  34. package/dist/core/reporter-factory.d.ts +18 -0
  35. package/dist/core/reporter-factory.js +63 -0
  36. package/dist/core/status-processor.d.ts +17 -0
  37. package/dist/core/status-processor.js +48 -0
  38. package/dist/env/env-enum.d.ts +64 -0
  39. package/dist/env/env-enum.js +75 -0
  40. package/dist/env/env-to-config.d.ts +7 -0
  41. package/dist/env/env-to-config.js +60 -0
  42. package/dist/env/env-type.d.ts +29 -0
  43. package/dist/env/env-type.js +3 -0
  44. package/dist/env/env-validation-schema.d.ts +6 -0
  45. package/dist/env/env-validation-schema.js +113 -0
  46. package/dist/env/index.d.ts +4 -0
  47. package/dist/env/index.js +13 -0
  48. package/dist/formatter/formatter-interface.d.ts +3 -0
  49. package/dist/formatter/formatter-interface.js +2 -0
  50. package/dist/formatter/index.d.ts +4 -0
  51. package/dist/formatter/index.js +9 -0
  52. package/dist/formatter/json-formatter.d.ts +13 -0
  53. package/dist/formatter/json-formatter.js +28 -0
  54. package/dist/formatter/jsonp-formatter.d.ts +13 -0
  55. package/dist/formatter/jsonp-formatter.js +29 -0
  56. package/dist/formatter/report-serializer.d.ts +20 -0
  57. package/dist/formatter/report-serializer.js +92 -0
  58. package/dist/index.d.ts +14 -0
  59. package/dist/index.js +30 -0
  60. package/dist/internal/filter-positive-ids.d.ts +17 -0
  61. package/dist/internal/filter-positive-ids.js +38 -0
  62. package/dist/internal/ids-parser.d.ts +9 -0
  63. package/dist/internal/ids-parser.js +21 -0
  64. package/dist/internal/index.d.ts +8 -0
  65. package/dist/internal/index.js +15 -0
  66. package/dist/internal/step-parser.d.ts +11 -0
  67. package/dist/internal/step-parser.js +28 -0
  68. package/dist/internal/suite-file.d.ts +13 -0
  69. package/dist/internal/suite-file.js +16 -0
  70. package/dist/internal/suite-normalizer.d.ts +6 -0
  71. package/dist/internal/suite-normalizer.js +11 -0
  72. package/dist/internal/title.d.ts +5 -0
  73. package/dist/internal/title.js +15 -0
  74. package/dist/models/attachment.d.ts +8 -0
  75. package/dist/models/attachment.js +2 -0
  76. package/dist/models/config/TidenOptionsType.d.ts +33 -0
  77. package/dist/models/config/TidenOptionsType.js +2 -0
  78. package/dist/models/configuration.d.ts +12 -0
  79. package/dist/models/configuration.js +2 -0
  80. package/dist/models/error.d.ts +7 -0
  81. package/dist/models/error.js +24 -0
  82. package/dist/models/execution-sum.d.ts +6 -0
  83. package/dist/models/execution-sum.js +2 -0
  84. package/dist/models/host-data.d.ts +12 -0
  85. package/dist/models/host-data.js +2 -0
  86. package/dist/models/index.d.ts +11 -0
  87. package/dist/models/index.js +15 -0
  88. package/dist/models/report.d.ts +14 -0
  89. package/dist/models/report.js +2 -0
  90. package/dist/models/short-result.d.ts +7 -0
  91. package/dist/models/short-result.js +2 -0
  92. package/dist/models/stats.d.ts +9 -0
  93. package/dist/models/stats.js +2 -0
  94. package/dist/models/step-data.d.ts +19 -0
  95. package/dist/models/step-data.js +2 -0
  96. package/dist/models/step-execution.d.ts +13 -0
  97. package/dist/models/step-execution.js +23 -0
  98. package/dist/models/test-execution.d.ts +20 -0
  99. package/dist/models/test-execution.js +32 -0
  100. package/dist/models/test-result.d.ts +44 -0
  101. package/dist/models/test-result.js +50 -0
  102. package/dist/models/test-step.d.ts +18 -0
  103. package/dist/models/test-step.js +53 -0
  104. package/dist/options/composeOptions.d.ts +8 -0
  105. package/dist/options/composeOptions.js +12 -0
  106. package/dist/options/index.d.ts +3 -0
  107. package/dist/options/index.js +7 -0
  108. package/dist/options/mode-enum.d.ts +8 -0
  109. package/dist/options/mode-enum.js +12 -0
  110. package/dist/options/options-type.d.ts +38 -0
  111. package/dist/options/options-type.js +3 -0
  112. package/dist/profilers/abstract-profiler.d.ts +5 -0
  113. package/dist/profilers/abstract-profiler.js +6 -0
  114. package/dist/profilers/fetch-interceptor.d.ts +60 -0
  115. package/dist/profilers/fetch-interceptor.js +277 -0
  116. package/dist/profilers/http-interceptor.d.ts +76 -0
  117. package/dist/profilers/http-interceptor.js +252 -0
  118. package/dist/profilers/index.d.ts +5 -0
  119. package/dist/profilers/index.js +11 -0
  120. package/dist/profilers/network-profiler.d.ts +61 -0
  121. package/dist/profilers/network-profiler.js +94 -0
  122. package/dist/reporters/abstract-reporter.d.ts +68 -0
  123. package/dist/reporters/abstract-reporter.js +78 -0
  124. package/dist/reporters/index.d.ts +3 -0
  125. package/dist/reporters/index.js +9 -0
  126. package/dist/reporters/report-reporter.d.ts +50 -0
  127. package/dist/reporters/report-reporter.js +167 -0
  128. package/dist/reporters/run-reporter.d.ts +65 -0
  129. package/dist/reporters/run-reporter.js +155 -0
  130. package/dist/reporters/shared/fallback-coordinator.d.ts +47 -0
  131. package/dist/reporters/shared/fallback-coordinator.js +119 -0
  132. package/dist/reporters/shared/run-constants.d.ts +11 -0
  133. package/dist/reporters/shared/run-constants.js +14 -0
  134. package/dist/state/state.d.ts +16 -0
  135. package/dist/state/state.js +70 -0
  136. package/dist/steps/step.d.ts +16 -0
  137. package/dist/steps/step.js +86 -0
  138. package/dist/tiden.d.ts +48 -0
  139. package/dist/tiden.js +223 -0
  140. package/dist/utils/disabled-exception.d.ts +6 -0
  141. package/dist/utils/disabled-exception.js +10 -0
  142. package/dist/utils/get-package-version.d.ts +5 -0
  143. package/dist/utils/get-package-version.js +25 -0
  144. package/dist/utils/hostData.d.ts +8 -0
  145. package/dist/utils/hostData.js +140 -0
  146. package/dist/utils/is-axios-error.d.ts +6 -0
  147. package/dist/utils/is-axios-error.js +11 -0
  148. package/dist/utils/logger.d.ts +33 -0
  149. package/dist/utils/logger.js +141 -0
  150. package/dist/utils/mimeTypes.d.ts +5 -0
  151. package/dist/utils/mimeTypes.js +50 -0
  152. package/dist/utils/project-mapping-utils.d.ts +17 -0
  153. package/dist/utils/project-mapping-utils.js +29 -0
  154. package/dist/utils/signature.d.ts +11 -0
  155. package/dist/utils/signature.js +34 -0
  156. package/dist/utils/status-mapping-utils.d.ts +14 -0
  157. package/dist/utils/status-mapping-utils.js +45 -0
  158. package/dist/utils/test-status-utils.d.ts +8 -0
  159. package/dist/utils/test-status-utils.js +152 -0
  160. package/dist/utils/tiden-error.d.ts +18 -0
  161. package/dist/utils/tiden-error.js +19 -0
  162. package/dist/utils/token-masker.d.ts +11 -0
  163. package/dist/utils/token-masker.js +26 -0
  164. package/dist/utils/validate-json.d.ts +20 -0
  165. package/dist/utils/validate-json.js +41 -0
  166. package/dist/writer/driver-enum.d.ts +13 -0
  167. package/dist/writer/driver-enum.js +18 -0
  168. package/dist/writer/fs-writer.d.ts +40 -0
  169. package/dist/writer/fs-writer.js +139 -0
  170. package/dist/writer/index.d.ts +3 -0
  171. package/dist/writer/index.js +8 -0
  172. package/dist/writer/writer-interface.d.ts +7 -0
  173. package/dist/writer/writer-interface.js +2 -0
  174. package/package.json +83 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,25 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ Initial Tiden fork release of `@tiden/reporter-commons`.
6
+
7
+ - Forked from [`qase-javascript-commons`](https://github.com/qase-tms/qase-javascript) at commit
8
+ [`d77a157`](https://github.com/qase-tms/qase-javascript/commit/d77a157020fea088ea323050a36b9bf874ad089d)
9
+ (Apache-2.0); wire transport retargeted from Qase TestOps to Tiden's Test Runs API.
10
+ - **JSON API calls use a purpose-built reporter transport.** `CreateTestRun`, `ReportResults`
11
+ and `CompleteTestRun` share the axios instance from `tiden-http.ts`, so baseURL,
12
+ `Authorization`, and the 30s timeout stay in one place without pulling the full generated API
13
+ client into every reporter installation.
14
+ - Reporter DTOs follow the generated models: lowerCamelCase JSON (`testopsIds`, `paramGroups`,
15
+ `suitePath`, `clientMeta`, step `expectedResult`/`inputData`) and int64 `duration` as a string.
16
+ A compile-time test checks them against the private generated OpenAPI snapshot, and wire tests
17
+ verify the paths and serialization.
18
+ - The local `report`-mode file format is unchanged — it keeps its own snake_case contract.
19
+ - Attachment upload stays hand-written: `POST /v1/products/{product}/attachments:upload` is a
20
+ multipart route absent from the OpenAPI spec, so no generated operation exists. It shares the
21
+ same axios instance, and retries/backoff are unchanged.
22
+ - `@tiden/api-client` is not a runtime dependency and is not published to npm. The generated
23
+ workspace is marked private and serves only as a repository-local contract snapshot.
24
+ - See the [root README](../README.md#lineage) for full fork lineage, and this package's
25
+ [README](./README.md) for the current shared config/env layer this package provides.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright (c) 2026 Qase Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # @tiden/reporter-commons
2
+
3
+ Shared reporter core for Tiden's JavaScript test framework reporters: config loading
4
+ (`tiden.config.json`), environment-variable resolution (`TIDEN_*`), the narrow Tiden API transport, result
5
+ formatting, status mapping/filtering, and the HTTP network profiler.
6
+
7
+ See the [root README](https://github.com/qase-tms/tiden-javascript/blob/main/README.md#lineage) for this package's fork lineage.
8
+
9
+ ## Who uses this
10
+
11
+ This package is **not meant to be installed or configured directly** in a test project — it's a
12
+ dependency of framework-specific reporters (currently [`@tiden/playwright-reporter`](https://github.com/qase-tms/tiden-javascript/blob/main/playwright/README.md)).
13
+ Install and configure the reporter for your framework instead; it composes this package's config
14
+ loader, env resolver, and API transport internally.
15
+
16
+ ## Configuration & environment variables
17
+
18
+ The `tiden.config.json` schema and the full `TIDEN_*` environment variable table (which this
19
+ package's `env-enum.ts` defines and every consuming reporter shares) are documented once, in the
20
+ consumer-facing [`playwright/README.md`](https://github.com/qase-tms/tiden-javascript/blob/main/playwright/README.md#configuration) — see that file
21
+ for the config example, the env-var reference table, and the note on how these variables line up
22
+ with the `tiden` CLI's own environment variables.
23
+
24
+ ## If you're building a new reporter
25
+
26
+ If you're adding a reporter for another framework, this package provides the pieces you'll wire
27
+ up: `ConfigLoader` (file), `envToConfig`/`envValidationSchema` (env), `TidenReporter` (orchestrator
28
+ with fallback handling), `RunReporter` / `ReportReporter` (the two reporting modes), and
29
+ `TidenApiClient` (the reporter-facing Tiden Test Runs transport). Read the source under `src/` — there is no
30
+ separate contributor guide yet.
31
+
32
+ ## License
33
+
34
+ Apache License 2.0. See [LICENSE](https://github.com/qase-tms/tiden-javascript/blob/main/LICENSE) for details.
@@ -0,0 +1,8 @@
1
+ import { Attachment, TestResultType } from "../models";
2
+ export interface IClient {
3
+ createRun(): Promise<number>;
4
+ completeRun(runId: number): Promise<void>;
5
+ uploadResults(runId: number, results: TestResultType[]): Promise<void>;
6
+ uploadAttachment(attachment: Attachment): Promise<string>;
7
+ enablePublicReport(runId: number): Promise<void>;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,96 @@
1
+ /**
2
+ * The reporter-facing slice of the Tiden public API contract.
3
+ *
4
+ * These types intentionally live in reporter-commons so installing a reporter
5
+ * does not pull the full generated API client into the user's dependency tree.
6
+ * `commons/test/client/reporter-api-contract.test.ts` checks this slice against
7
+ * the generated OpenAPI models kept in this repository.
8
+ */
9
+ export interface CreateTestRunBody {
10
+ title?: string;
11
+ description?: string;
12
+ environment?: string;
13
+ branch?: string;
14
+ configurations?: Record<string, string>;
15
+ buildSha?: string;
16
+ startedAt?: string;
17
+ clientMeta?: Record<string, string>;
18
+ }
19
+ export interface ReporterTestRun {
20
+ seqNum?: number;
21
+ }
22
+ export interface CreateTestRunResponse {
23
+ run?: ReporterTestRun;
24
+ }
25
+ export interface ParamGroup {
26
+ names?: string[];
27
+ }
28
+ export interface ResultExecution {
29
+ status?: string;
30
+ startTime?: number;
31
+ endTime?: number;
32
+ duration?: string;
33
+ stacktrace?: string;
34
+ thread?: string;
35
+ }
36
+ export interface ResultStepData {
37
+ action?: string;
38
+ expectedResult?: string;
39
+ inputData?: string;
40
+ attachments?: string[];
41
+ }
42
+ export interface ResultStepExecution {
43
+ status?: string;
44
+ startTime?: number;
45
+ endTime?: number;
46
+ duration?: string;
47
+ comment?: string;
48
+ attachments?: string[];
49
+ }
50
+ export interface StepCode {
51
+ file?: string;
52
+ line?: number;
53
+ }
54
+ export interface ResultStep {
55
+ type?: string;
56
+ data?: ResultStepData;
57
+ execution?: ResultStepExecution;
58
+ code?: StepCode;
59
+ steps?: ResultStep[];
60
+ }
61
+ export interface SuiteSegment {
62
+ title?: string;
63
+ externalId?: string;
64
+ }
65
+ export interface ResultCreate {
66
+ id?: string;
67
+ title?: string;
68
+ signature?: string;
69
+ externalId?: string;
70
+ testopsIds?: number[];
71
+ execution?: ResultExecution;
72
+ fields?: Record<string, string>;
73
+ attachments?: string[];
74
+ steps?: ResultStep[];
75
+ stepsType?: string;
76
+ params?: Record<string, string>;
77
+ paramGroups?: ParamGroup[];
78
+ suitePath?: SuiteSegment[];
79
+ message?: string;
80
+ defect?: boolean;
81
+ }
82
+ export interface ReportResultsBody {
83
+ results?: ResultCreate[];
84
+ }
85
+ export interface ReportError {
86
+ index?: number;
87
+ resultId?: string;
88
+ code?: string;
89
+ message?: string;
90
+ }
91
+ export interface ReportResultsResponse {
92
+ status?: boolean;
93
+ accepted?: string;
94
+ duplicates?: string;
95
+ errors?: ReportError[];
96
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,14 @@
1
+ import type { AxiosInstance, AxiosResponse } from 'axios';
2
+ import type { CreateTestRunBody, CreateTestRunResponse, ReportResultsBody, ReportResultsResponse } from './reporter-api-models';
3
+ /**
4
+ * Purpose-built transport for the three JSON operations used by reporters.
5
+ * Authentication, base URL and timeout are owned by the injected axios
6
+ * instance; this layer owns only the OpenAPI paths and request/response DTOs.
7
+ */
8
+ export declare class ReporterApi {
9
+ private readonly http;
10
+ constructor(http: AxiosInstance);
11
+ createTestRun(productId: string, body: CreateTestRunBody): Promise<AxiosResponse<CreateTestRunResponse>>;
12
+ completeTestRun(productId: string, runSeq: number): Promise<AxiosResponse<unknown>>;
13
+ reportResults(productId: string, runSeq: number, body: ReportResultsBody): Promise<AxiosResponse<ReportResultsResponse>>;
14
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReporterApi = void 0;
4
+ const pathSegment = (value) => encodeURIComponent(String(value));
5
+ /**
6
+ * Purpose-built transport for the three JSON operations used by reporters.
7
+ * Authentication, base URL and timeout are owned by the injected axios
8
+ * instance; this layer owns only the OpenAPI paths and request/response DTOs.
9
+ */
10
+ class ReporterApi {
11
+ http;
12
+ constructor(http) {
13
+ this.http = http;
14
+ }
15
+ createTestRun(productId, body) {
16
+ return this.http.post(`/v1/products/${pathSegment(productId)}/runs`, body);
17
+ }
18
+ completeTestRun(productId, runSeq) {
19
+ return this.http.post(`/v1/products/${pathSegment(productId)}/runs/${pathSegment(runSeq)}:complete`, {});
20
+ }
21
+ reportResults(productId, runSeq, body) {
22
+ return this.http.post(`/v1/products/${pathSegment(productId)}/runs/${pathSegment(runSeq)}/results:report`, body);
23
+ }
24
+ }
25
+ exports.ReporterApi = ReporterApi;
@@ -0,0 +1,10 @@
1
+ import { TidenError } from '../../utils/tiden-error';
2
+ export declare enum ApiErrorCode {
3
+ UNAUTHORIZED = 401,
4
+ FORBIDDEN = 403,
5
+ NOT_FOUND = 404,
6
+ BAD_REQUEST = 400,
7
+ UNPROCESSABLE_ENTITY = 422
8
+ }
9
+ export declare function processError(error: unknown, message: string, model?: object): TidenError;
10
+ export declare function getErrorMessage(error: unknown): string;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiErrorCode = void 0;
4
+ exports.processError = processError;
5
+ exports.getErrorMessage = getErrorMessage;
6
+ const is_axios_error_1 = require("../../utils/is-axios-error");
7
+ const tiden_error_1 = require("../../utils/tiden-error");
8
+ var ApiErrorCode;
9
+ (function (ApiErrorCode) {
10
+ ApiErrorCode[ApiErrorCode["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
11
+ ApiErrorCode[ApiErrorCode["FORBIDDEN"] = 403] = "FORBIDDEN";
12
+ ApiErrorCode[ApiErrorCode["NOT_FOUND"] = 404] = "NOT_FOUND";
13
+ ApiErrorCode[ApiErrorCode["BAD_REQUEST"] = 400] = "BAD_REQUEST";
14
+ ApiErrorCode[ApiErrorCode["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
15
+ })(ApiErrorCode || (exports.ApiErrorCode = ApiErrorCode = {}));
16
+ function processError(error, message, model) {
17
+ if (!(0, is_axios_error_1.isAxiosError)(error)) {
18
+ return new tiden_error_1.TidenError(message, { cause: error });
19
+ }
20
+ const err = error;
21
+ const errorData = err.response?.data;
22
+ const status = err.response?.status;
23
+ switch (status) {
24
+ case ApiErrorCode.UNAUTHORIZED:
25
+ return new tiden_error_1.TidenError(`${message}: Unauthorized. Please check your API token.`);
26
+ case ApiErrorCode.FORBIDDEN:
27
+ return new tiden_error_1.TidenError(`${message}: ${errorData?.errorMessage ?? 'Forbidden'}`);
28
+ case ApiErrorCode.NOT_FOUND:
29
+ return new tiden_error_1.TidenError(`${message}: Not found.`);
30
+ case ApiErrorCode.BAD_REQUEST:
31
+ case ApiErrorCode.UNPROCESSABLE_ENTITY:
32
+ return new tiden_error_1.TidenError(`${message}: Bad request\n${JSON.stringify(errorData)}\nBody: ${JSON.stringify(model)}`);
33
+ default:
34
+ return new tiden_error_1.TidenError(message, { cause: err });
35
+ }
36
+ }
37
+ function getErrorMessage(error) {
38
+ if ((0, is_axios_error_1.isAxiosError)(error)) {
39
+ const err = error;
40
+ const errorData = err.response?.data;
41
+ return errorData?.errorMessage ?? errorData?.error ?? errorData?.message ?? 'Unknown API error';
42
+ }
43
+ return error instanceof Error ? error.message : 'Unknown error';
44
+ }
@@ -0,0 +1,29 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { Attachment } from '../../models';
3
+ import { LoggerInterface } from '../../utils/logger';
4
+ export declare class AttachmentService {
5
+ private readonly logger;
6
+ private readonly http;
7
+ constructor(logger: LoggerInterface, http: AxiosInstance);
8
+ uploadAttachment(projectCode: string, attachment: Attachment): Promise<string>;
9
+ uploadAttachments(projectCode: string, attachments: Attachment[], uploadEnabled: boolean): Promise<string[]>;
10
+ private groupIntoBatches;
11
+ /** POST one multipart batch to Tiden. Returns the upstream-shaped
12
+ * `{data: {result: [{hash}]}}` envelope so callers stay unchanged
13
+ * (Tiden's response body is `{status, result: [{hash, ...}]}`).
14
+ *
15
+ * Hand-written on purpose: `POST /v1/products/{product}/attachments:upload`
16
+ * is a multipart route that is NOT in the OpenAPI spec, so
17
+ * The generated OpenAPI snapshot has no operation for it (the path appears
18
+ * there only inside a doc comment on testRunServiceGetRunAttachment). It
19
+ * still goes over the same axios instance as the reporter JSON calls, so
20
+ * baseURL/auth/timeout stay shared; only the request building is local.
21
+ * If the route is ever added to the spec, replace this with the generated
22
+ * operation. */
23
+ private postAttachmentBatch;
24
+ private uploadWithRetry;
25
+ private getRetryAfter;
26
+ private delay;
27
+ private ensureAttachmentSize;
28
+ private prepareAttachmentData;
29
+ }