@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
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPackageVersion = void 0;
4
+ const fs_1 = require("fs");
5
+ /**
6
+ * @param {string} name
7
+ * @returns {undefined | string}
8
+ */
9
+ const getPackageVersion = (name) => {
10
+ try {
11
+ const pathToPackageJson = require.resolve(`${name}/package.json`, {
12
+ paths: [process.cwd()],
13
+ });
14
+ const packageString = (0, fs_1.readFileSync)(pathToPackageJson, 'utf8');
15
+ const packageObject = JSON.parse(packageString);
16
+ if (typeof packageObject === 'object' &&
17
+ packageObject &&
18
+ 'version' in packageObject) {
19
+ return String(packageObject.version);
20
+ }
21
+ }
22
+ catch { /* ignore */ }
23
+ return undefined;
24
+ };
25
+ exports.getPackageVersion = getPackageVersion;
@@ -0,0 +1,8 @@
1
+ import { HostData } from '../models/host-data';
2
+ /**
3
+ * Gets information about the current host environment
4
+ * @param {string} framework The framework name to check version for
5
+ * @param {string} reporterName The reporter name to check version for
6
+ * @returns {HostData} Host information object
7
+ */
8
+ export declare function getHostInfo(framework: string, reporterName: string): HostData;
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getHostInfo = getHostInfo;
37
+ const os = __importStar(require("os"));
38
+ const cp = __importStar(require("child_process"));
39
+ const fs = __importStar(require("fs"));
40
+ const get_package_version_1 = require("./get-package-version");
41
+ /**
42
+ * Normalizes platform name to unified format
43
+ * @param {string} platform - process.platform value
44
+ * @returns {string} Normalized platform name
45
+ */
46
+ function normalizePlatform(platform) {
47
+ if (platform === 'win32')
48
+ return 'windows';
49
+ return platform;
50
+ }
51
+ /**
52
+ * Gets detailed OS information based on the platform
53
+ * @returns {string} Detailed OS information
54
+ */
55
+ function getDetailedOSInfo() {
56
+ const platform = process.platform;
57
+ try {
58
+ if (platform === 'win32') {
59
+ // Windows
60
+ return cp.execSync('ver').toString().trim();
61
+ }
62
+ else if (platform === 'darwin') {
63
+ // macOS
64
+ return cp.execSync('sw_vers -productVersion').toString().trim();
65
+ }
66
+ else {
67
+ // Linux and others
68
+ try {
69
+ const osRelease = fs.readFileSync('/etc/os-release', 'utf8');
70
+ const prettyName = osRelease.match(/PRETTY_NAME="(.+)"/);
71
+ if (prettyName?.[1]) {
72
+ return prettyName[1];
73
+ }
74
+ }
75
+ catch {
76
+ // Fallback if /etc/os-release doesn't exist or can't be read
77
+ }
78
+ return os.release();
79
+ }
80
+ }
81
+ catch (error) {
82
+ console.error('Error getting detailed OS info:', error);
83
+ return os.release();
84
+ }
85
+ }
86
+ /**
87
+ * Gets npm version from environment or by executing npm command
88
+ * @returns {string} npm version string
89
+ */
90
+ function getNpmVersion() {
91
+ const userAgent = process.env['npm_config_user_agent'];
92
+ if (userAgent) {
93
+ const match = userAgent.match(/^npm\/(\S+)/);
94
+ if (match?.[1]) {
95
+ return match[1];
96
+ }
97
+ }
98
+ try {
99
+ return cp.execSync('npm --version', { stdio: 'pipe' }).toString().trim();
100
+ }
101
+ catch {
102
+ return '';
103
+ }
104
+ }
105
+ /**
106
+ * Gets information about the current host environment
107
+ * @param {string} framework The framework name to check version for
108
+ * @param {string} reporterName The reporter name to check version for
109
+ * @returns {HostData} Host information object
110
+ */
111
+ function getHostInfo(framework, reporterName) {
112
+ try {
113
+ return {
114
+ system: normalizePlatform(process.platform),
115
+ machineName: os.hostname(),
116
+ release: os.release(),
117
+ version: getDetailedOSInfo(),
118
+ arch: os.arch(),
119
+ language: process.version,
120
+ packageManager: getNpmVersion(),
121
+ framework: (0, get_package_version_1.getPackageVersion)(framework) ?? '',
122
+ reporter: (0, get_package_version_1.getPackageVersion)(reporterName) ?? '',
123
+ commons: (0, get_package_version_1.getPackageVersion)('@tiden/reporter-commons') ?? '',
124
+ };
125
+ }
126
+ catch (error) {
127
+ return {
128
+ system: normalizePlatform(process.platform),
129
+ machineName: os.hostname() || '',
130
+ release: os.release(),
131
+ version: '',
132
+ arch: os.arch(),
133
+ language: '',
134
+ packageManager: '',
135
+ framework: '',
136
+ reporter: '',
137
+ commons: '',
138
+ };
139
+ }
140
+ }
@@ -0,0 +1,6 @@
1
+ import { AxiosError } from 'axios';
2
+ /**
3
+ * @param error
4
+ * @returns {error is AxiosError}
5
+ */
6
+ export declare const isAxiosError: (error: unknown) => error is AxiosError;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAxiosError = void 0;
4
+ /**
5
+ * @param error
6
+ * @returns {error is AxiosError}
7
+ */
8
+ const isAxiosError = (error) => error instanceof Error
9
+ && 'isAxiosError' in error
10
+ && Boolean(error.isAxiosError);
11
+ exports.isAxiosError = isAxiosError;
@@ -0,0 +1,33 @@
1
+ export interface LoggerInterface {
2
+ log(message: string): void;
3
+ logError(message: string, error?: unknown): void;
4
+ logDebug(message: string): void;
5
+ }
6
+ export declare class Logger implements LoggerInterface {
7
+ private readonly debug;
8
+ private readonly filePath;
9
+ private readonly consoleEnabled;
10
+ private readonly fileEnabled;
11
+ constructor(options: {
12
+ debug?: boolean | undefined;
13
+ dir?: string;
14
+ consoleLogging?: boolean | undefined;
15
+ fileLogging?: boolean | undefined;
16
+ });
17
+ log(message: string): void;
18
+ logError(message: string, error?: unknown): void;
19
+ logDebug(message: string): void;
20
+ private logToFile;
21
+ private doLogError;
22
+ /**
23
+ * @param {AxiosError} error
24
+ * @private
25
+ */
26
+ private logApiError;
27
+ /**
28
+ * @param errorFields
29
+ * @returns {string | undefined}
30
+ * @private
31
+ */
32
+ private formatErrorFields;
33
+ }
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.Logger = void 0;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const is_axios_error_1 = require("./is-axios-error");
40
+ const tiden_error_1 = require("./tiden-error");
41
+ class Logger {
42
+ debug;
43
+ filePath;
44
+ consoleEnabled;
45
+ fileEnabled;
46
+ constructor(options) {
47
+ this.debug = options.debug;
48
+ // Determine console logging: if explicitly set, use that value; otherwise default to true
49
+ this.consoleEnabled = options.consoleLogging !== undefined ? options.consoleLogging : true;
50
+ // Determine file logging: if explicitly set, use that value; otherwise use debug setting
51
+ this.fileEnabled = options.fileLogging !== undefined ? options.fileLogging : (this.debug ?? false);
52
+ const dir = options.dir ?? './logs';
53
+ if (this.fileEnabled && !fs.existsSync(dir)) {
54
+ fs.mkdirSync(dir);
55
+ }
56
+ this.filePath = path.join(dir, 'log.txt');
57
+ }
58
+ log(message) {
59
+ const logMessage = `[INFO] tiden: ${message}`;
60
+ if (this.consoleEnabled) {
61
+ console.log(logMessage);
62
+ }
63
+ if (this.fileEnabled) {
64
+ this.logToFile(logMessage);
65
+ }
66
+ }
67
+ logError(message, error) {
68
+ const logMessage = `[ERROR] tiden: ${this.doLogError(message, error)}`;
69
+ if (this.consoleEnabled) {
70
+ console.error(logMessage);
71
+ }
72
+ if (this.fileEnabled) {
73
+ this.logToFile(logMessage);
74
+ }
75
+ }
76
+ logDebug(message) {
77
+ if (this.debug) {
78
+ const logMessage = `[DEBUG] tiden: ${message}`;
79
+ if (this.consoleEnabled) {
80
+ console.log(logMessage);
81
+ }
82
+ if (this.fileEnabled) {
83
+ this.logToFile(logMessage);
84
+ }
85
+ }
86
+ }
87
+ logToFile(message) {
88
+ const formattedMessage = `[${new Date().toISOString()}] ${message}\n`;
89
+ fs.appendFileSync(this.filePath, formattedMessage);
90
+ }
91
+ doLogError(message, error) {
92
+ let logMessage = message;
93
+ if (error instanceof Error) {
94
+ if ((0, is_axios_error_1.isAxiosError)(error)) {
95
+ logMessage += this.logApiError(error);
96
+ }
97
+ else if (error instanceof tiden_error_1.TidenError && error.cause) {
98
+ logMessage += this.doLogError('\n Caused by:', error.cause);
99
+ }
100
+ logMessage += `\n ${error.stack ?? `${error.name}: ${error.message}`}`;
101
+ }
102
+ else {
103
+ logMessage += `\n ${String(error)}`;
104
+ }
105
+ return logMessage;
106
+ }
107
+ /**
108
+ * @param {AxiosError} error
109
+ * @private
110
+ */
111
+ logApiError(error) {
112
+ if (!error.response?.data) {
113
+ return `\nMessage: ${error.message || 'Unknown error'}`;
114
+ }
115
+ const response = error.response.data;
116
+ const statusText = error.response.statusText;
117
+ const errorMessage = response.errorMessage
118
+ ?? response.error
119
+ ?? statusText;
120
+ const errorFields = this.formatErrorFields(response.errorFields);
121
+ let logMessage = `\nMessage: ${errorMessage}`;
122
+ if (errorFields) {
123
+ logMessage += `\n${errorFields}`;
124
+ }
125
+ return logMessage;
126
+ }
127
+ /**
128
+ * @param errorFields
129
+ * @returns {string | undefined}
130
+ * @private
131
+ */
132
+ formatErrorFields(errorFields) {
133
+ if (!errorFields?.length) {
134
+ return undefined;
135
+ }
136
+ return errorFields
137
+ .map(({ field, error }) => `${field}: ${error}`)
138
+ .join('\n');
139
+ }
140
+ }
141
+ exports.Logger = Logger;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Get mime type of the file
3
+ * @param {string} filePath
4
+ */
5
+ export declare function getMimeTypes(filePath: string): string;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getMimeTypes = getMimeTypes;
37
+ const path = __importStar(require("path"));
38
+ const mime = __importStar(require("mime-types"));
39
+ /**
40
+ * Get mime type of the file
41
+ * @param {string} filePath
42
+ */
43
+ function getMimeTypes(filePath) {
44
+ const fileName = path.basename(filePath);
45
+ const mimeType = mime.contentType(fileName);
46
+ if (!mimeType && typeof mimeType !== 'string') {
47
+ return 'application/octet-stream';
48
+ }
49
+ return mimeType;
50
+ }
@@ -0,0 +1,17 @@
1
+ import { LoggerInterface } from './logger';
2
+ /**
3
+ * Result of parsing "(Tiden ID: n)" markers from a test title.
4
+ * - legacyIds: from "(Tiden ID: 123)" or "(Tiden ID: 123,124)".
5
+ * - cleanedTitle: title with all such patterns removed.
6
+ */
7
+ export interface ParsedTidenId {
8
+ legacyIds: number[];
9
+ cleanedTitle: string;
10
+ }
11
+ /**
12
+ * Parse "(Tiden ID: …)" markers from a test title.
13
+ *
14
+ * @param title — test title that may contain "(Tiden ID: …)".
15
+ * @returns legacyIds and cleanedTitle with all markers stripped.
16
+ */
17
+ export declare function parseTidenIdFromTitle(title: string, logger?: LoggerInterface): ParsedTidenId;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseTidenIdFromTitle = parseTidenIdFromTitle;
4
+ const filter_positive_ids_1 = require("../internal/filter-positive-ids");
5
+ /** Matches "(Tiden ID: 123)" or "(Tiden ID: 123,124)". Allows negative numbers. */
6
+ const TIDEN_ID_MARKER_REGEXP = /\(Tiden\s+ID:\s*([-\d,]+)\)/gi;
7
+ /**
8
+ * Parse "(Tiden ID: …)" markers from a test title.
9
+ *
10
+ * @param title — test title that may contain "(Tiden ID: …)".
11
+ * @returns legacyIds and cleanedTitle with all markers stripped.
12
+ */
13
+ function parseTidenIdFromTitle(title, logger) {
14
+ const legacyIds = [];
15
+ let cleanedTitle = title;
16
+ let m;
17
+ const re = new RegExp(TIDEN_ID_MARKER_REGEXP.source, 'gi');
18
+ while ((m = re.exec(title)) !== null) {
19
+ const idsStr = m[1] ?? '';
20
+ const rawIds = idsStr
21
+ .split(',')
22
+ .map((s) => parseInt(s, 10))
23
+ .filter((n) => !Number.isNaN(n));
24
+ legacyIds.push(...(0, filter_positive_ids_1.filterPositiveIds)(rawIds, logger));
25
+ cleanedTitle = cleanedTitle.replace(m[0], '');
26
+ }
27
+ cleanedTitle = cleanedTitle.replace(/\s+/g, ' ').trim();
28
+ return { legacyIds, cleanedTitle };
29
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Generates a signature string from case IDs and suites.
3
+ *
4
+ * Param-free by design: signature is the case-level identity input, kept
5
+ * stable across every parameter combination of a parametrized case. Params
6
+ * are hashed separately (at the attempt level) rather than folded in here.
7
+ * @param caseIds - Array of case IDs or null
8
+ * @param suites - Array of suite names
9
+ * @returns Formatted signature string
10
+ */
11
+ export declare const generateSignature: (caseIds: number[] | null, suites: string[]) => string;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateSignature = void 0;
4
+ /**
5
+ * Generates a signature string from case IDs and suites.
6
+ *
7
+ * Param-free by design: signature is the case-level identity input, kept
8
+ * stable across every parameter combination of a parametrized case. Params
9
+ * are hashed separately (at the attempt level) rather than folded in here.
10
+ * @param caseIds - Array of case IDs or null
11
+ * @param suites - Array of suite names
12
+ * @returns Formatted signature string
13
+ */
14
+ const generateSignature = (caseIds, suites) => {
15
+ const parts = [];
16
+ if (caseIds && caseIds.length > 0) {
17
+ parts.push(caseIds.join('-'));
18
+ }
19
+ if (suites.length > 0) {
20
+ const processedSuites = suites
21
+ .map(suite => suite.trim())
22
+ .map(suite => suite.replace(/\\/g, '/'))
23
+ .flatMap(suite => suite.split('::'))
24
+ .map(suite => suite.trim())
25
+ .flatMap(suite => suite.split('\t'))
26
+ .map(suite => suite.trim())
27
+ .map(suite => suite.replace(/\s+/g, '_'))
28
+ .map(suite => suite.toLowerCase())
29
+ .filter(suite => suite.length > 0);
30
+ parts.push(processedSuites.join('::'));
31
+ }
32
+ return parts.join('::');
33
+ };
34
+ exports.generateSignature = generateSignature;
@@ -0,0 +1,14 @@
1
+ import { TestStatusEnum } from '../models/test-execution';
2
+ /**
3
+ * Applies status mapping configuration to a test status
4
+ * @param status - Original test status
5
+ * @param statusMapping - Status mapping configuration
6
+ * @returns Mapped test status or original if no mapping found
7
+ */
8
+ export declare function applyStatusMapping(status: TestStatusEnum, statusMapping?: Record<string, string>): TestStatusEnum;
9
+ /**
10
+ * Validates status mapping configuration
11
+ * @param statusMapping - Status mapping configuration to validate
12
+ * @returns Array of validation errors (empty if valid)
13
+ */
14
+ export declare function validateStatusMapping(statusMapping: Record<string, string>): string[];
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applyStatusMapping = applyStatusMapping;
4
+ exports.validateStatusMapping = validateStatusMapping;
5
+ const test_execution_1 = require("../models/test-execution");
6
+ /**
7
+ * Applies status mapping configuration to a test status
8
+ * @param status - Original test status
9
+ * @param statusMapping - Status mapping configuration
10
+ * @returns Mapped test status or original if no mapping found
11
+ */
12
+ function applyStatusMapping(status, statusMapping) {
13
+ if (!statusMapping) {
14
+ return status;
15
+ }
16
+ const mappedStatus = statusMapping[status];
17
+ if (!mappedStatus) {
18
+ return status;
19
+ }
20
+ // Validate that the mapped status is a valid TestStatusEnum value
21
+ const validStatuses = Object.values(test_execution_1.TestStatusEnum);
22
+ if (!validStatuses.includes(mappedStatus)) {
23
+ console.warn(`Invalid status mapping: "${status}" -> "${mappedStatus}". Valid statuses are: ${validStatuses.join(', ')}`);
24
+ return status;
25
+ }
26
+ return mappedStatus;
27
+ }
28
+ /**
29
+ * Validates status mapping configuration
30
+ * @param statusMapping - Status mapping configuration to validate
31
+ * @returns Array of validation errors (empty if valid)
32
+ */
33
+ function validateStatusMapping(statusMapping) {
34
+ const errors = [];
35
+ const validStatuses = Object.values(test_execution_1.TestStatusEnum);
36
+ for (const [fromStatus, toStatus] of Object.entries(statusMapping)) {
37
+ if (!validStatuses.includes(fromStatus)) {
38
+ errors.push(`Invalid source status "${fromStatus}". Valid statuses are: ${validStatuses.join(', ')}`);
39
+ }
40
+ if (!validStatuses.includes(toStatus)) {
41
+ errors.push(`Invalid target status "${toStatus}". Valid statuses are: ${validStatuses.join(', ')}`);
42
+ }
43
+ }
44
+ return errors;
45
+ }
@@ -0,0 +1,8 @@
1
+ import { TestStatusEnum } from '../models/test-execution';
2
+ /**
3
+ * Determines test status based on error type
4
+ * @param error - Error object or null
5
+ * @param originalStatus - Original test status from test runner
6
+ * @returns TestStatusEnum - failed for assertion errors, invalid for other errors
7
+ */
8
+ export declare function determineTestStatus(error: Error | null, originalStatus: string): TestStatusEnum;