@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,47 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.OptionsResolver = void 0;
7
+ const env_schema_1 = __importDefault(require("env-schema"));
8
+ const env_1 = require("../env");
9
+ const options_1 = require("../options");
10
+ const state_1 = require("../state/state");
11
+ /**
12
+ * Composes the final options used by TidenReporter:
13
+ * - restores mode / runId from state (when withState is active)
14
+ * - merges env-derived config with user options
15
+ * - determines effective mode / fallback values
16
+ */
17
+ class OptionsResolver {
18
+ resolve(options) {
19
+ const withState = this.detectWithState(options);
20
+ if (withState) {
21
+ this.restoreFromState();
22
+ }
23
+ const env = (0, env_1.envToConfig)((0, env_schema_1.default)({ schema: env_1.envValidationSchema }));
24
+ const composed = (0, options_1.composeOptions)(options, env);
25
+ return {
26
+ effectiveMode: composed.mode ?? options_1.ModeEnum.off,
27
+ effectiveFallback: composed.fallback ?? options_1.ModeEnum.off,
28
+ composed,
29
+ withState,
30
+ };
31
+ }
32
+ detectWithState(options) {
33
+ return options.frameworkName === 'cypress' || !options.frameworkName;
34
+ }
35
+ restoreFromState() {
36
+ if (!state_1.StateManager.isStateExists())
37
+ return;
38
+ const state = state_1.StateManager.getState();
39
+ if (state.IsModeChanged && state.Mode) {
40
+ process.env[env_1.EnvEnum.mode] = state.Mode.toString();
41
+ }
42
+ if (state.RunId) {
43
+ process.env[env_1.EnvRunEnum.id] = state.RunId.toString();
44
+ }
45
+ }
46
+ }
47
+ exports.OptionsResolver = OptionsResolver;
@@ -0,0 +1,18 @@
1
+ import { InternalReporterInterface } from '../reporters';
2
+ import { ModeEnum, OptionsType } from '../options';
3
+ import { ConfigType } from '../config';
4
+ import { LoggerInterface } from '../utils/logger';
5
+ import { HostData } from '../models/host-data';
6
+ /**
7
+ * Builds a mode-specific InternalReporterInterface. Throws DisabledException
8
+ * for `ModeEnum.off` so callers can distinguish "disabled-by-config" from a
9
+ * real failure.
10
+ */
11
+ export declare class ReporterFactory {
12
+ private readonly logger;
13
+ private readonly hostData;
14
+ constructor(logger: LoggerInterface, hostData: HostData);
15
+ create(mode: ModeEnum, options: ConfigType & OptionsType, withState: boolean): InternalReporterInterface;
16
+ private createRunReporter;
17
+ private createReport;
18
+ }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReporterFactory = void 0;
4
+ const reporters_1 = require("../reporters");
5
+ const options_1 = require("../options");
6
+ const env_1 = require("../env");
7
+ const disabled_exception_1 = require("../utils/disabled-exception");
8
+ const tiden_client_1 = require("../client/tiden-client");
9
+ const writer_1 = require("../writer");
10
+ /**
11
+ * Builds a mode-specific InternalReporterInterface. Throws DisabledException
12
+ * for `ModeEnum.off` so callers can distinguish "disabled-by-config" from a
13
+ * real failure.
14
+ */
15
+ class ReporterFactory {
16
+ logger;
17
+ hostData;
18
+ constructor(logger, hostData) {
19
+ this.logger = logger;
20
+ this.hostData = hostData;
21
+ }
22
+ create(mode, options, withState) {
23
+ switch (mode) {
24
+ case options_1.ModeEnum.tiden:
25
+ return this.createRunReporter(options, withState);
26
+ case options_1.ModeEnum.report:
27
+ return this.createReport(options);
28
+ case options_1.ModeEnum.off:
29
+ throw new disabled_exception_1.DisabledException();
30
+ default:
31
+ throw new Error(`Unknown mode type`);
32
+ }
33
+ }
34
+ createRunReporter(options, withState) {
35
+ if (!options.tiden?.api?.token) {
36
+ throw new Error(`Either "tiden.api.token" parameter or "${env_1.EnvApiEnum.token}" environment variable is required in "tiden" mode`);
37
+ }
38
+ if (!options.tiden.product) {
39
+ throw new Error(`Either "tiden.product" parameter or "${env_1.EnvTidenEnum.product}" environment variable is required in "tiden" mode`);
40
+ }
41
+ if (!options.tiden?.api?.baseUrl) {
42
+ throw new Error(`Either "tiden.api.baseUrl" parameter or "${env_1.EnvApiEnum.baseUrl}" environment variable is required in "tiden" mode`);
43
+ }
44
+ const tiden = options.tiden;
45
+ tiden.clientMeta = {
46
+ framework: options.frameworkName ?? '',
47
+ reporter: options.reporterName ?? '',
48
+ framework_version: this.hostData.framework,
49
+ reporter_version: this.hostData.reporter,
50
+ commons_version: this.hostData.commons,
51
+ os: this.hostData.system,
52
+ node: this.hostData.language,
53
+ };
54
+ const apiClient = new tiden_client_1.TidenApiClient(this.logger, tiden, options.environment, options.rootSuite);
55
+ return new reporters_1.RunReporter(this.logger, apiClient, withState, tiden.product, tiden.batch?.size, tiden.run?.id);
56
+ }
57
+ createReport(options) {
58
+ const localOptions = options.report?.connections?.[writer_1.DriverEnum.local];
59
+ const writer = new writer_1.FsWriter(localOptions);
60
+ return new reporters_1.ReportReporter(this.logger, writer, options.frameworkPackage, options.reporterName, options.environment, options.rootSuite, options.tiden?.run?.id, this.hostData);
61
+ }
62
+ }
63
+ exports.ReporterFactory = ReporterFactory;
@@ -0,0 +1,17 @@
1
+ import { TestResultType } from '../models';
2
+ import { LoggerInterface } from '../utils/logger';
3
+ /**
4
+ * Applies status mapping (rename rule) and status filter (drop rule) to a test
5
+ * result. Mutates `result.execution.status` when a mapping rule matches, then
6
+ * returns either the (possibly mutated) result or `null` if it should be
7
+ * filtered out.
8
+ */
9
+ export declare class StatusProcessor {
10
+ private readonly logger;
11
+ private readonly statusMapping;
12
+ private readonly statusFilter;
13
+ constructor(logger: LoggerInterface, statusMapping: Record<string, string> | undefined, statusFilter: string[] | undefined);
14
+ process(result: TestResultType): TestResultType | null;
15
+ private applyMapping;
16
+ private shouldFilter;
17
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StatusProcessor = void 0;
4
+ const status_mapping_utils_1 = require("../utils/status-mapping-utils");
5
+ /**
6
+ * Applies status mapping (rename rule) and status filter (drop rule) to a test
7
+ * result. Mutates `result.execution.status` when a mapping rule matches, then
8
+ * returns either the (possibly mutated) result or `null` if it should be
9
+ * filtered out.
10
+ */
11
+ class StatusProcessor {
12
+ logger;
13
+ statusMapping;
14
+ statusFilter;
15
+ constructor(logger, statusMapping, statusFilter) {
16
+ this.logger = logger;
17
+ this.statusMapping = statusMapping;
18
+ this.statusFilter = statusFilter;
19
+ }
20
+ process(result) {
21
+ this.applyMapping(result);
22
+ if (this.shouldFilter(result)) {
23
+ this.logger.logDebug(`Filtering out test result with status: ${result.execution.status}`);
24
+ return null;
25
+ }
26
+ return result;
27
+ }
28
+ applyMapping(result) {
29
+ if (!this.statusMapping)
30
+ return;
31
+ const originalStatus = result.execution.status;
32
+ const mapped = (0, status_mapping_utils_1.applyStatusMapping)(originalStatus, this.statusMapping);
33
+ if (mapped !== originalStatus) {
34
+ this.logger.logDebug(`Status mapping applied: ${originalStatus} -> ${mapped}`);
35
+ result.execution.status = mapped;
36
+ }
37
+ }
38
+ shouldFilter(result) {
39
+ if (!this.statusFilter || this.statusFilter.length === 0)
40
+ return false;
41
+ const statusString = result.execution.status.toString();
42
+ this.logger.logDebug(`Checking filter: status="${statusString}", filter=${JSON.stringify(this.statusFilter)}`);
43
+ const shouldFilter = this.statusFilter.includes(statusString);
44
+ this.logger.logDebug(`Filter result: ${shouldFilter ? 'FILTERED' : 'NOT FILTERED'}`);
45
+ return shouldFilter;
46
+ }
47
+ }
48
+ exports.StatusProcessor = StatusProcessor;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * @enum {string}
3
+ */
4
+ export declare enum EnvEnum {
5
+ mode = "TIDEN_MODE",
6
+ fallback = "TIDEN_FALLBACK",
7
+ debug = "TIDEN_DEBUG",
8
+ environment = "TIDEN_ENVIRONMENT",
9
+ captureLogs = "TIDEN_CAPTURE_LOGS",
10
+ rootSuite = "TIDEN_ROOT_SUITE",
11
+ statusMapping = "TIDEN_STATUS_MAPPING"
12
+ }
13
+ /**
14
+ * @enum {string}
15
+ */
16
+ export declare enum EnvTidenEnum {
17
+ product = "TIDEN_PRODUCT_ID",
18
+ uploadAttachments = "TIDEN_UPLOAD_ATTACHMENTS",
19
+ defect = "TIDEN_DEFECT",
20
+ statusFilter = "TIDEN_STATUS_FILTER"
21
+ }
22
+ /**
23
+ * @enum {string}
24
+ */
25
+ export declare enum EnvApiEnum {
26
+ token = "TIDEN_API_TOKEN",
27
+ baseUrl = "TIDEN_BASE_URL"
28
+ }
29
+ /**
30
+ * @enum {string}
31
+ */
32
+ export declare enum EnvRunEnum {
33
+ id = "TIDEN_RUN_ID",
34
+ title = "TIDEN_RUN_TITLE",
35
+ description = "TIDEN_RUN_DESCRIPTION",
36
+ complete = "TIDEN_RUN_COMPLETE",
37
+ branch = "TIDEN_BRANCH"
38
+ }
39
+ /**
40
+ * @enum {string}
41
+ */
42
+ export declare enum EnvBatchEnum {
43
+ size = "TIDEN_BATCH_SIZE"
44
+ }
45
+ /**
46
+ * @enum {string}
47
+ */
48
+ export declare enum EnvConfigurationsEnum {
49
+ values = "TIDEN_CONFIGURATIONS_VALUES"
50
+ }
51
+ /**
52
+ * @enum {string}
53
+ */
54
+ export declare enum EnvLocalEnum {
55
+ path = "TIDEN_REPORT_CONNECTION_PATH",
56
+ format = "TIDEN_REPORT_CONNECTION_FORMAT"
57
+ }
58
+ /**
59
+ * @enum {string}
60
+ */
61
+ export declare enum EnvLoggingEnum {
62
+ console = "TIDEN_LOGGING_CONSOLE",
63
+ file = "TIDEN_LOGGING_FILE"
64
+ }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EnvLoggingEnum = exports.EnvLocalEnum = exports.EnvConfigurationsEnum = exports.EnvBatchEnum = exports.EnvRunEnum = exports.EnvApiEnum = exports.EnvTidenEnum = exports.EnvEnum = void 0;
4
+ /**
5
+ * @enum {string}
6
+ */
7
+ var EnvEnum;
8
+ (function (EnvEnum) {
9
+ EnvEnum["mode"] = "TIDEN_MODE";
10
+ EnvEnum["fallback"] = "TIDEN_FALLBACK";
11
+ EnvEnum["debug"] = "TIDEN_DEBUG";
12
+ EnvEnum["environment"] = "TIDEN_ENVIRONMENT";
13
+ EnvEnum["captureLogs"] = "TIDEN_CAPTURE_LOGS";
14
+ EnvEnum["rootSuite"] = "TIDEN_ROOT_SUITE";
15
+ EnvEnum["statusMapping"] = "TIDEN_STATUS_MAPPING";
16
+ })(EnvEnum || (exports.EnvEnum = EnvEnum = {}));
17
+ /**
18
+ * @enum {string}
19
+ */
20
+ var EnvTidenEnum;
21
+ (function (EnvTidenEnum) {
22
+ EnvTidenEnum["product"] = "TIDEN_PRODUCT_ID";
23
+ EnvTidenEnum["uploadAttachments"] = "TIDEN_UPLOAD_ATTACHMENTS";
24
+ EnvTidenEnum["defect"] = "TIDEN_DEFECT";
25
+ EnvTidenEnum["statusFilter"] = "TIDEN_STATUS_FILTER";
26
+ })(EnvTidenEnum || (exports.EnvTidenEnum = EnvTidenEnum = {}));
27
+ /**
28
+ * @enum {string}
29
+ */
30
+ var EnvApiEnum;
31
+ (function (EnvApiEnum) {
32
+ EnvApiEnum["token"] = "TIDEN_API_TOKEN";
33
+ EnvApiEnum["baseUrl"] = "TIDEN_BASE_URL";
34
+ })(EnvApiEnum || (exports.EnvApiEnum = EnvApiEnum = {}));
35
+ /**
36
+ * @enum {string}
37
+ */
38
+ var EnvRunEnum;
39
+ (function (EnvRunEnum) {
40
+ EnvRunEnum["id"] = "TIDEN_RUN_ID";
41
+ EnvRunEnum["title"] = "TIDEN_RUN_TITLE";
42
+ EnvRunEnum["description"] = "TIDEN_RUN_DESCRIPTION";
43
+ EnvRunEnum["complete"] = "TIDEN_RUN_COMPLETE";
44
+ EnvRunEnum["branch"] = "TIDEN_BRANCH";
45
+ })(EnvRunEnum || (exports.EnvRunEnum = EnvRunEnum = {}));
46
+ /**
47
+ * @enum {string}
48
+ */
49
+ var EnvBatchEnum;
50
+ (function (EnvBatchEnum) {
51
+ EnvBatchEnum["size"] = "TIDEN_BATCH_SIZE";
52
+ })(EnvBatchEnum || (exports.EnvBatchEnum = EnvBatchEnum = {}));
53
+ /**
54
+ * @enum {string}
55
+ */
56
+ var EnvConfigurationsEnum;
57
+ (function (EnvConfigurationsEnum) {
58
+ EnvConfigurationsEnum["values"] = "TIDEN_CONFIGURATIONS_VALUES";
59
+ })(EnvConfigurationsEnum || (exports.EnvConfigurationsEnum = EnvConfigurationsEnum = {}));
60
+ /**
61
+ * @enum {string}
62
+ */
63
+ var EnvLocalEnum;
64
+ (function (EnvLocalEnum) {
65
+ EnvLocalEnum["path"] = "TIDEN_REPORT_CONNECTION_PATH";
66
+ EnvLocalEnum["format"] = "TIDEN_REPORT_CONNECTION_FORMAT";
67
+ })(EnvLocalEnum || (exports.EnvLocalEnum = EnvLocalEnum = {}));
68
+ /**
69
+ * @enum {string}
70
+ */
71
+ var EnvLoggingEnum;
72
+ (function (EnvLoggingEnum) {
73
+ EnvLoggingEnum["console"] = "TIDEN_LOGGING_CONSOLE";
74
+ EnvLoggingEnum["file"] = "TIDEN_LOGGING_FILE";
75
+ })(EnvLoggingEnum || (exports.EnvLoggingEnum = EnvLoggingEnum = {}));
@@ -0,0 +1,7 @@
1
+ import { EnvType } from './env-type';
2
+ import { ConfigType } from '../config';
3
+ /**
4
+ * @param {EnvType} env
5
+ * @returns {ConfigType}
6
+ */
7
+ export declare const envToConfig: (env: EnvType) => ConfigType;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.envToConfig = void 0;
4
+ const env_enum_1 = require("./env-enum");
5
+ const writer_1 = require("../writer");
6
+ /**
7
+ * @param {EnvType} env
8
+ * @returns {ConfigType}
9
+ */
10
+ const envToConfig = (env) => ({
11
+ mode: env[env_enum_1.EnvEnum.mode],
12
+ debug: env[env_enum_1.EnvEnum.debug],
13
+ environment: env[env_enum_1.EnvEnum.environment],
14
+ captureLogs: env[env_enum_1.EnvEnum.captureLogs],
15
+ rootSuite: env[env_enum_1.EnvEnum.rootSuite],
16
+ statusMapping: env[env_enum_1.EnvEnum.statusMapping] ?
17
+ Object.fromEntries(env[env_enum_1.EnvEnum.statusMapping].split(',').map(item => {
18
+ const [from, to] = item.split('=');
19
+ return [from?.trim() || '', to?.trim() || ''];
20
+ })) : undefined,
21
+ tiden: {
22
+ product: env[env_enum_1.EnvTidenEnum.product],
23
+ uploadAttachments: env[env_enum_1.EnvTidenEnum.uploadAttachments],
24
+ statusFilter: env[env_enum_1.EnvTidenEnum.statusFilter]?.split(',').map(status => status.trim()) ?? undefined,
25
+ api: {
26
+ token: env[env_enum_1.EnvApiEnum.token],
27
+ baseUrl: env[env_enum_1.EnvApiEnum.baseUrl],
28
+ },
29
+ run: {
30
+ id: env[env_enum_1.EnvRunEnum.id],
31
+ title: env[env_enum_1.EnvRunEnum.title],
32
+ description: env[env_enum_1.EnvRunEnum.description],
33
+ complete: env[env_enum_1.EnvRunEnum.complete],
34
+ branch: env[env_enum_1.EnvRunEnum.branch],
35
+ },
36
+ batch: {
37
+ size: env[env_enum_1.EnvBatchEnum.size],
38
+ },
39
+ defect: env[env_enum_1.EnvTidenEnum.defect],
40
+ configurations: env[env_enum_1.EnvConfigurationsEnum.values] ? {
41
+ values: env[env_enum_1.EnvConfigurationsEnum.values].split(',').map(item => {
42
+ const [name, value] = item.split('=');
43
+ return { name: (name ?? '').trim(), value: value ? value.trim() : '' };
44
+ }),
45
+ } : undefined,
46
+ },
47
+ report: {
48
+ connections: {
49
+ [writer_1.DriverEnum.local]: {
50
+ path: env[env_enum_1.EnvLocalEnum.path],
51
+ format: env[env_enum_1.EnvLocalEnum.format],
52
+ },
53
+ },
54
+ },
55
+ logging: (env[env_enum_1.EnvLoggingEnum.console] !== undefined || env[env_enum_1.EnvLoggingEnum.file] !== undefined) ? {
56
+ console: env[env_enum_1.EnvLoggingEnum.console],
57
+ file: env[env_enum_1.EnvLoggingEnum.file],
58
+ } : undefined,
59
+ });
60
+ exports.envToConfig = envToConfig;
@@ -0,0 +1,29 @@
1
+ import { EnvEnum, EnvTidenEnum, EnvApiEnum, EnvRunEnum, EnvLocalEnum, EnvBatchEnum, EnvConfigurationsEnum, EnvLoggingEnum } from './env-enum';
2
+ import { ModeEnum } from '../options';
3
+ import { FormatEnum } from '../writer';
4
+ export interface EnvType {
5
+ [EnvEnum.mode]?: `${ModeEnum}`;
6
+ [EnvEnum.fallback]?: `${ModeEnum}`;
7
+ [EnvEnum.debug]?: boolean;
8
+ [EnvEnum.environment]?: string;
9
+ [EnvEnum.captureLogs]?: boolean;
10
+ [EnvEnum.rootSuite]?: string;
11
+ [EnvEnum.statusMapping]?: string;
12
+ [EnvTidenEnum.product]?: string;
13
+ [EnvTidenEnum.uploadAttachments]?: boolean;
14
+ [EnvTidenEnum.defect]?: boolean;
15
+ [EnvTidenEnum.statusFilter]?: string;
16
+ [EnvApiEnum.token]?: string;
17
+ [EnvApiEnum.baseUrl]?: string;
18
+ [EnvRunEnum.id]?: number;
19
+ [EnvRunEnum.title]?: string;
20
+ [EnvRunEnum.description]?: string;
21
+ [EnvRunEnum.complete]?: boolean;
22
+ [EnvRunEnum.branch]?: string;
23
+ [EnvBatchEnum.size]?: number;
24
+ [EnvConfigurationsEnum.values]?: string;
25
+ [EnvLocalEnum.path]?: string;
26
+ [EnvLocalEnum.format]?: `${FormatEnum}`;
27
+ [EnvLoggingEnum.console]?: boolean;
28
+ [EnvLoggingEnum.file]?: boolean;
29
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const env_enum_1 = require("./env-enum");
@@ -0,0 +1,6 @@
1
+ import { JSONSchemaType } from 'env-schema';
2
+ import { EnvType } from './env-type';
3
+ /**
4
+ * @type {JSONSchemaType<EnvType>}
5
+ */
6
+ export declare const envValidationSchema: JSONSchemaType<EnvType>;
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.envValidationSchema = void 0;
4
+ const env_enum_1 = require("./env-enum");
5
+ const options_1 = require("../options");
6
+ const writer_1 = require("../writer");
7
+ /**
8
+ * @type {JSONSchemaType<EnvType>}
9
+ */
10
+ exports.envValidationSchema = {
11
+ type: 'object',
12
+ properties: {
13
+ [env_enum_1.EnvEnum.mode]: {
14
+ type: 'string',
15
+ enum: [options_1.ModeEnum.report, options_1.ModeEnum.tiden, options_1.ModeEnum.off],
16
+ nullable: true,
17
+ },
18
+ [env_enum_1.EnvEnum.fallback]: {
19
+ type: 'string',
20
+ enum: [options_1.ModeEnum.report, options_1.ModeEnum.tiden, options_1.ModeEnum.off],
21
+ nullable: true,
22
+ },
23
+ [env_enum_1.EnvEnum.debug]: {
24
+ type: 'boolean',
25
+ nullable: true,
26
+ },
27
+ [env_enum_1.EnvEnum.environment]: {
28
+ type: 'string',
29
+ nullable: true,
30
+ },
31
+ [env_enum_1.EnvEnum.captureLogs]: {
32
+ type: 'boolean',
33
+ nullable: true,
34
+ },
35
+ [env_enum_1.EnvEnum.rootSuite]: {
36
+ type: 'string',
37
+ nullable: true,
38
+ },
39
+ [env_enum_1.EnvEnum.statusMapping]: {
40
+ type: 'string',
41
+ nullable: true,
42
+ },
43
+ [env_enum_1.EnvTidenEnum.product]: {
44
+ type: 'string',
45
+ nullable: true,
46
+ },
47
+ [env_enum_1.EnvTidenEnum.uploadAttachments]: {
48
+ type: 'boolean',
49
+ nullable: true,
50
+ },
51
+ [env_enum_1.EnvTidenEnum.defect]: {
52
+ type: 'boolean',
53
+ nullable: true,
54
+ },
55
+ [env_enum_1.EnvTidenEnum.statusFilter]: {
56
+ type: 'string',
57
+ nullable: true,
58
+ },
59
+ [env_enum_1.EnvApiEnum.token]: {
60
+ type: 'string',
61
+ nullable: true,
62
+ },
63
+ [env_enum_1.EnvApiEnum.baseUrl]: {
64
+ type: 'string',
65
+ nullable: true,
66
+ },
67
+ [env_enum_1.EnvRunEnum.id]: {
68
+ type: 'number',
69
+ nullable: true,
70
+ },
71
+ [env_enum_1.EnvRunEnum.title]: {
72
+ type: 'string',
73
+ nullable: true,
74
+ },
75
+ [env_enum_1.EnvRunEnum.description]: {
76
+ type: 'string',
77
+ nullable: true,
78
+ },
79
+ [env_enum_1.EnvRunEnum.complete]: {
80
+ type: 'boolean',
81
+ nullable: true,
82
+ },
83
+ [env_enum_1.EnvRunEnum.branch]: {
84
+ type: 'string',
85
+ nullable: true,
86
+ },
87
+ [env_enum_1.EnvBatchEnum.size]: {
88
+ type: 'number',
89
+ nullable: true,
90
+ },
91
+ [env_enum_1.EnvConfigurationsEnum.values]: {
92
+ type: 'string',
93
+ nullable: true,
94
+ },
95
+ [env_enum_1.EnvLocalEnum.path]: {
96
+ type: 'string',
97
+ nullable: true,
98
+ },
99
+ [env_enum_1.EnvLocalEnum.format]: {
100
+ type: 'string',
101
+ enum: [writer_1.FormatEnum.json, writer_1.FormatEnum.jsonp],
102
+ nullable: true,
103
+ },
104
+ [env_enum_1.EnvLoggingEnum.console]: {
105
+ type: 'boolean',
106
+ nullable: true,
107
+ },
108
+ [env_enum_1.EnvLoggingEnum.file]: {
109
+ type: 'boolean',
110
+ nullable: true,
111
+ },
112
+ },
113
+ };
@@ -0,0 +1,4 @@
1
+ export { EnvEnum, EnvTidenEnum, EnvApiEnum, EnvRunEnum, EnvLocalEnum, } from './env-enum';
2
+ export { type EnvType } from './env-type';
3
+ export { envValidationSchema } from './env-validation-schema';
4
+ export { envToConfig } from './env-to-config';
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.envToConfig = exports.envValidationSchema = exports.EnvLocalEnum = exports.EnvRunEnum = exports.EnvApiEnum = exports.EnvTidenEnum = exports.EnvEnum = void 0;
4
+ var env_enum_1 = require("./env-enum");
5
+ Object.defineProperty(exports, "EnvEnum", { enumerable: true, get: function () { return env_enum_1.EnvEnum; } });
6
+ Object.defineProperty(exports, "EnvTidenEnum", { enumerable: true, get: function () { return env_enum_1.EnvTidenEnum; } });
7
+ Object.defineProperty(exports, "EnvApiEnum", { enumerable: true, get: function () { return env_enum_1.EnvApiEnum; } });
8
+ Object.defineProperty(exports, "EnvRunEnum", { enumerable: true, get: function () { return env_enum_1.EnvRunEnum; } });
9
+ Object.defineProperty(exports, "EnvLocalEnum", { enumerable: true, get: function () { return env_enum_1.EnvLocalEnum; } });
10
+ var env_validation_schema_1 = require("./env-validation-schema");
11
+ Object.defineProperty(exports, "envValidationSchema", { enumerable: true, get: function () { return env_validation_schema_1.envValidationSchema; } });
12
+ var env_to_config_1 = require("./env-to-config");
13
+ Object.defineProperty(exports, "envToConfig", { enumerable: true, get: function () { return env_to_config_1.envToConfig; } });
@@ -0,0 +1,3 @@
1
+ export interface FormatterInterface {
2
+ format(result: unknown): Promise<string>;
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ export { type FormatterInterface } from './formatter-interface';
2
+ export { JsonFormatter } from './json-formatter';
3
+ export { JsonpFormatter } from './jsonp-formatter';
4
+ export { ReportSerializer, type ReportSerializerInterface } from './report-serializer';
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReportSerializer = exports.JsonpFormatter = exports.JsonFormatter = void 0;
4
+ var json_formatter_1 = require("./json-formatter");
5
+ Object.defineProperty(exports, "JsonFormatter", { enumerable: true, get: function () { return json_formatter_1.JsonFormatter; } });
6
+ var jsonp_formatter_1 = require("./jsonp-formatter");
7
+ Object.defineProperty(exports, "JsonpFormatter", { enumerable: true, get: function () { return jsonp_formatter_1.JsonpFormatter; } });
8
+ var report_serializer_1 = require("./report-serializer");
9
+ Object.defineProperty(exports, "ReportSerializer", { enumerable: true, get: function () { return report_serializer_1.ReportSerializer; } });
@@ -0,0 +1,13 @@
1
+ import { FormatterInterface } from './formatter-interface';
2
+ export interface JsonFormatterOptionsType {
3
+ space?: number | undefined;
4
+ }
5
+ /**
6
+ * @class JsonFormatter
7
+ * @implements FormatterInterface
8
+ */
9
+ export declare class JsonFormatter implements FormatterInterface {
10
+ private space;
11
+ constructor(options?: JsonFormatterOptionsType);
12
+ format(object: unknown): Promise<string>;
13
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.JsonFormatter = void 0;
7
+ const strip_ansi_1 = __importDefault(require("strip-ansi"));
8
+ /**
9
+ * @class JsonFormatter
10
+ * @implements FormatterInterface
11
+ */
12
+ class JsonFormatter {
13
+ space;
14
+ constructor(options = {}) {
15
+ const { space = 4 } = options;
16
+ this.space = space;
17
+ }
18
+ // eslint-disable-next-line @typescript-eslint/require-await
19
+ async format(object) {
20
+ return JSON.stringify(object, (key, value) => {
21
+ if (key === 'error' && value instanceof Error) {
22
+ return (0, strip_ansi_1.default)(String(value));
23
+ }
24
+ return value;
25
+ }, this.space);
26
+ }
27
+ }
28
+ exports.JsonFormatter = JsonFormatter;
@@ -0,0 +1,13 @@
1
+ import { FormatterInterface } from './formatter-interface';
2
+ export interface JsonpFormatterOptionsType {
3
+ space?: number | undefined;
4
+ }
5
+ /**
6
+ * @class JsonFormatter
7
+ * @implements FormatterInterface
8
+ */
9
+ export declare class JsonpFormatter implements FormatterInterface {
10
+ private space;
11
+ constructor(options?: JsonpFormatterOptionsType);
12
+ format(object: unknown): Promise<string>;
13
+ }