testit-js-commons 1.1.5

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 (85) hide show
  1. package/lib/client/client.d.ts +11 -0
  2. package/lib/client/client.js +16 -0
  3. package/lib/client/client.type.d.ts +8 -0
  4. package/lib/client/client.type.js +2 -0
  5. package/lib/client/index.d.ts +2 -0
  6. package/lib/client/index.js +18 -0
  7. package/lib/common/base.converter.d.ts +24 -0
  8. package/lib/common/base.converter.js +47 -0
  9. package/lib/common/index.d.ts +3 -0
  10. package/lib/common/index.js +19 -0
  11. package/lib/common/types/common.type.d.ts +60 -0
  12. package/lib/common/types/common.type.js +2 -0
  13. package/lib/common/types/config.type.d.ts +33 -0
  14. package/lib/common/types/config.type.js +2 -0
  15. package/lib/common/types/index.d.ts +2 -0
  16. package/lib/common/types/index.js +18 -0
  17. package/lib/common/utils/index.d.ts +1 -0
  18. package/lib/common/utils/index.js +17 -0
  19. package/lib/common/utils/utils.d.ts +14 -0
  20. package/lib/common/utils/utils.js +73 -0
  21. package/lib/helpers/additions/additions.helper.d.ts +16 -0
  22. package/lib/helpers/additions/additions.helper.js +41 -0
  23. package/lib/helpers/additions/additions.type.d.ts +7 -0
  24. package/lib/helpers/additions/additions.type.js +2 -0
  25. package/lib/helpers/additions/index.d.ts +2 -0
  26. package/lib/helpers/additions/index.js +18 -0
  27. package/lib/helpers/config/config.helper.d.ts +7 -0
  28. package/lib/helpers/config/config.helper.js +61 -0
  29. package/lib/helpers/config/config.type.d.ts +5 -0
  30. package/lib/helpers/config/config.type.js +2 -0
  31. package/lib/helpers/config/index.d.ts +2 -0
  32. package/lib/helpers/config/index.js +18 -0
  33. package/lib/helpers/index.d.ts +2 -0
  34. package/lib/helpers/index.js +18 -0
  35. package/lib/index.d.ts +6 -0
  36. package/lib/index.js +22 -0
  37. package/lib/services/attachments/attachments.service.d.ts +11 -0
  38. package/lib/services/attachments/attachments.service.js +52 -0
  39. package/lib/services/attachments/attachments.type.d.ts +5 -0
  40. package/lib/services/attachments/attachments.type.js +2 -0
  41. package/lib/services/attachments/index.d.ts +2 -0
  42. package/lib/services/attachments/index.js +18 -0
  43. package/lib/services/autotests/autotests.converter.d.ts +12 -0
  44. package/lib/services/autotests/autotests.converter.js +28 -0
  45. package/lib/services/autotests/autotests.handler.d.ts +1 -0
  46. package/lib/services/autotests/autotests.handler.js +13 -0
  47. package/lib/services/autotests/autotests.service.d.ts +18 -0
  48. package/lib/services/autotests/autotests.service.js +85 -0
  49. package/lib/services/autotests/autotests.type.d.ts +34 -0
  50. package/lib/services/autotests/autotests.type.js +2 -0
  51. package/lib/services/autotests/index.d.ts +3 -0
  52. package/lib/services/autotests/index.js +19 -0
  53. package/lib/services/base.service.d.ts +5 -0
  54. package/lib/services/base.service.js +19 -0
  55. package/lib/services/index.d.ts +3 -0
  56. package/lib/services/index.js +19 -0
  57. package/lib/services/testruns/index.d.ts +2 -0
  58. package/lib/services/testruns/index.js +18 -0
  59. package/lib/services/testruns/testruns.converter.d.ts +19 -0
  60. package/lib/services/testruns/testruns.converter.js +56 -0
  61. package/lib/services/testruns/testruns.handler.d.ts +4 -0
  62. package/lib/services/testruns/testruns.handler.js +21 -0
  63. package/lib/services/testruns/testruns.service.d.ts +17 -0
  64. package/lib/services/testruns/testruns.service.js +86 -0
  65. package/lib/services/testruns/testruns.type.d.ts +54 -0
  66. package/lib/services/testruns/testruns.type.js +2 -0
  67. package/lib/storage/index.d.ts +1 -0
  68. package/lib/storage/index.js +5 -0
  69. package/lib/storage/storage.d.ts +5 -0
  70. package/lib/storage/storage.js +16 -0
  71. package/lib/strategy/base.strategy.d.ts +14 -0
  72. package/lib/strategy/base.strategy.js +48 -0
  73. package/lib/strategy/first.strategy.d.ts +7 -0
  74. package/lib/strategy/first.strategy.js +12 -0
  75. package/lib/strategy/index.d.ts +6 -0
  76. package/lib/strategy/index.js +22 -0
  77. package/lib/strategy/second.strategy.d.ts +9 -0
  78. package/lib/strategy/second.strategy.js +11 -0
  79. package/lib/strategy/strategy.factory.d.ts +6 -0
  80. package/lib/strategy/strategy.factory.js +21 -0
  81. package/lib/strategy/strategy.type.d.ts +9 -0
  82. package/lib/strategy/strategy.type.js +2 -0
  83. package/lib/strategy/zero.strategy.d.ts +9 -0
  84. package/lib/strategy/zero.strategy.js +13 -0
  85. package/package.json +32 -0
@@ -0,0 +1,11 @@
1
+ import { AdapterConfig } from "../common";
2
+ import { type IAttachmentsService, type IAutotestService, type ITestRunsService } from "../services";
3
+ import { IClient } from "./client.type";
4
+ export declare class Client implements IClient {
5
+ private readonly config;
6
+ attachments: IAttachmentsService;
7
+ autoTests: IAutotestService;
8
+ testRuns: ITestRunsService;
9
+ constructor(config: AdapterConfig);
10
+ getConfig(): Readonly<AdapterConfig>;
11
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Client = void 0;
4
+ const services_1 = require("../services");
5
+ class Client {
6
+ constructor(config) {
7
+ this.config = config;
8
+ this.attachments = new services_1.AttachmentsService(config);
9
+ this.autoTests = new services_1.AutotestsService(config);
10
+ this.testRuns = new services_1.TestRunsService(config);
11
+ }
12
+ getConfig() {
13
+ return this.config;
14
+ }
15
+ }
16
+ exports.Client = Client;
@@ -0,0 +1,8 @@
1
+ import type { IAttachmentsService, IAutotestService, ITestRunsService } from "../services";
2
+ import type { AdapterConfig } from "../common";
3
+ export interface IClient {
4
+ attachments: IAttachmentsService;
5
+ autoTests: IAutotestService;
6
+ testRuns: ITestRunsService;
7
+ getConfig(): AdapterConfig;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from "./client";
2
+ export * from "./client.type";
@@ -0,0 +1,18 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./client"), exports);
18
+ __exportStar(require("./client.type"), exports);
@@ -0,0 +1,24 @@
1
+ import { AvailableTestResultOutcome, LinkPostModel, LinkType as OriginLinkType, AttachmentPutModelAutoTestStepResultsModel, LinkPutModel, AutoTestStepModel } from "testit-api-client";
2
+ import { AdapterConfig, Link, LinkType, Outcome, ShortStep, Step } from "./types";
3
+ export interface IBaseConverter {
4
+ toOriginOutcome(outcome: Outcome): AvailableTestResultOutcome;
5
+ toLocalOutcome(outcome: AvailableTestResultOutcome): Outcome;
6
+ toOriginLinkType(linkType: LinkType): OriginLinkType;
7
+ toLocalLinkType(linkType: OriginLinkType): LinkType;
8
+ toOriginLink(link: Link): LinkPostModel;
9
+ toLocalLink(link: LinkPutModel): Link;
10
+ toLocalShortStep(step: AutoTestStepModel): ShortStep;
11
+ toOriginStep(step: Step): AttachmentPutModelAutoTestStepResultsModel;
12
+ }
13
+ export declare class BaseConverter implements IBaseConverter {
14
+ protected readonly config: AdapterConfig;
15
+ constructor(config: AdapterConfig);
16
+ toOriginOutcome(outcome: Outcome): AvailableTestResultOutcome;
17
+ toLocalOutcome(outcome: AvailableTestResultOutcome): Outcome;
18
+ toOriginLinkType(linkType: LinkType): OriginLinkType;
19
+ toLocalLinkType(linkType: OriginLinkType): LinkType;
20
+ toOriginLink(link: Link): LinkPostModel;
21
+ toLocalLink(link: LinkPutModel): Link;
22
+ toLocalShortStep(step: AutoTestStepModel): ShortStep;
23
+ toOriginStep(step: Step): AttachmentPutModelAutoTestStepResultsModel;
24
+ }
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseConverter = void 0;
4
+ const testit_api_client_1 = require("testit-api-client");
5
+ class BaseConverter {
6
+ constructor(config) {
7
+ this.config = config;
8
+ }
9
+ toOriginOutcome(outcome) {
10
+ return testit_api_client_1.AvailableTestResultOutcome[outcome];
11
+ }
12
+ toLocalOutcome(outcome) {
13
+ return testit_api_client_1.AvailableTestResultOutcome[outcome];
14
+ }
15
+ toOriginLinkType(linkType) {
16
+ return testit_api_client_1.LinkType[linkType];
17
+ }
18
+ toLocalLinkType(linkType) {
19
+ return testit_api_client_1.LinkType[linkType];
20
+ }
21
+ toOriginLink(link) {
22
+ return Object.assign(Object.assign({}, link), { type: link.type ? this.toOriginLinkType(link.type) : undefined });
23
+ }
24
+ toLocalLink(link) {
25
+ var _a, _b;
26
+ return {
27
+ url: link.url,
28
+ title: (_a = link.title) !== null && _a !== void 0 ? _a : link.url,
29
+ description: (_b = link.description) !== null && _b !== void 0 ? _b : undefined,
30
+ type: link.type ? this.toLocalLinkType(link.type) : undefined,
31
+ hasInfo: link.hasInfo,
32
+ };
33
+ }
34
+ toLocalShortStep(step) {
35
+ var _a, _b;
36
+ return {
37
+ title: step.title,
38
+ description: (_a = step.description) !== null && _a !== void 0 ? _a : undefined,
39
+ steps: (_b = step.steps) === null || _b === void 0 ? void 0 : _b.map((step) => this.toLocalShortStep(step)),
40
+ };
41
+ }
42
+ toOriginStep(step) {
43
+ var _a;
44
+ return Object.assign(Object.assign({}, step), { outcome: step.outcome ? this.toOriginOutcome(step.outcome) : undefined, stepResults: (_a = step.steps) === null || _a === void 0 ? void 0 : _a.map((step) => this.toOriginStep(step)) });
45
+ }
46
+ }
47
+ exports.BaseConverter = BaseConverter;
@@ -0,0 +1,3 @@
1
+ export * from "./types";
2
+ export * from "./utils";
3
+ export * from "./base.converter";
@@ -0,0 +1,19 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
18
+ __exportStar(require("./utils"), exports);
19
+ __exportStar(require("./base.converter"), exports);
@@ -0,0 +1,60 @@
1
+ export type LinkType = "Related" | "BlockedBy" | "Defect" | "Issue" | "Requirement" | "Repository";
2
+ export type Outcome = "Passed" | "Failed" | "Blocked" | "Skipped";
3
+ export interface Link {
4
+ title: string;
5
+ url: string;
6
+ description?: string;
7
+ type?: LinkType;
8
+ hasInfo?: boolean;
9
+ }
10
+ export interface Label {
11
+ name: string;
12
+ globalId?: number;
13
+ }
14
+ export interface Attachment {
15
+ id: string;
16
+ }
17
+ export interface Step {
18
+ title: string;
19
+ description?: string;
20
+ info?: string;
21
+ startedOn?: Date;
22
+ completedOn?: Date;
23
+ duration?: number;
24
+ outcome?: Outcome;
25
+ steps?: Array<Step>;
26
+ attachments?: Array<Attachment>;
27
+ parameters?: {
28
+ [key: string]: string;
29
+ };
30
+ }
31
+ export interface ShortStep {
32
+ title: string;
33
+ description?: string;
34
+ steps?: Array<ShortStep>;
35
+ }
36
+ export interface Metadata {
37
+ externalId?: string;
38
+ displayName?: string;
39
+ title?: string;
40
+ description?: string;
41
+ workItemsIds?: string[];
42
+ links?: Link[];
43
+ labels?: string[];
44
+ classname?: string;
45
+ namespace?: string;
46
+ properties?: {
47
+ [key: string]: string;
48
+ };
49
+ parameters?: {
50
+ [key: string]: string;
51
+ };
52
+ shouldCreateWorkItem?: boolean;
53
+ }
54
+ export interface DynamicMethods {
55
+ addAttachments(paths: string[]): Promise<Attachment[]>;
56
+ addAttachments(content: string, fileName?: string): Promise<Attachment[]>;
57
+ addLinks(link: Link): void;
58
+ addLinks(links: Link[]): void;
59
+ addMessage(message: string): void;
60
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,33 @@
1
+ export type AdapterMode = 0 | 1 | 2;
2
+ export interface CliOptions {
3
+ tmsUrl: string;
4
+ tmsPrivateToken: string;
5
+ tmsProjectId: string;
6
+ tmsConfigurationId: string;
7
+ tmsTestRunId: string;
8
+ tmsTestRunName: string;
9
+ tmsAdapterMode: AdapterMode;
10
+ tmsConfigFile: string;
11
+ tmsAutomaticCreationTestCases: boolean;
12
+ }
13
+ export interface EnvironmentOptions {
14
+ TMS_URL: string;
15
+ TMS_PRIVATE_TOKEN: string;
16
+ TMS_PROJECT_ID: string;
17
+ TMS_CONFIGURATION_ID: string;
18
+ TMS_TEST_RUN_ID: string;
19
+ TMS_TEST_RUN_NAME: string;
20
+ TMS_ADAPTER_MODE: AdapterMode;
21
+ TMS_CONFIG_FILE: string;
22
+ TMS_AUTOMATIC_CREATION_TEST_CASES: boolean;
23
+ }
24
+ export interface AdapterConfig {
25
+ url: string;
26
+ privateToken: string;
27
+ projectId: string;
28
+ configurationId: string;
29
+ testRunId: string;
30
+ testRunName?: string;
31
+ adapterMode?: AdapterMode;
32
+ automaticCreationTestCases?: boolean;
33
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from "./config.type";
2
+ export * from "./common.type";
@@ -0,0 +1,18 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./config.type"), exports);
18
+ __exportStar(require("./common.type"), exports);
@@ -0,0 +1 @@
1
+ export * from "./utils";
@@ -0,0 +1,17 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./utils"), exports);
@@ -0,0 +1,14 @@
1
+ /// <reference types="node" />
2
+ import fs from "fs";
3
+ export declare namespace Utils {
4
+ function getHash(input: string): string;
5
+ function getDir(file: string): string;
6
+ function removeDir(path: string): void;
7
+ function getFileName(file: string): string;
8
+ function getExtName(path: string): string;
9
+ function generateFileName(prefix?: string): string;
10
+ function readFile(path: string): string;
11
+ function writeFile(path: string, content: string): void;
12
+ function createTempDir(): string;
13
+ function readStream(path: string): fs.ReadStream;
14
+ }
@@ -0,0 +1,73 @@
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 (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.Utils = void 0;
27
+ const crypto_1 = require("crypto");
28
+ const path_1 = require("path");
29
+ const fs_1 = __importStar(require("fs"));
30
+ const os_1 = require("os");
31
+ var Utils;
32
+ (function (Utils) {
33
+ function getHash(input) {
34
+ return (0, crypto_1.createHash)("md5").update(input).digest("hex");
35
+ }
36
+ Utils.getHash = getHash;
37
+ function getDir(file) {
38
+ return (0, path_1.dirname)(file);
39
+ }
40
+ Utils.getDir = getDir;
41
+ function removeDir(path) {
42
+ (0, fs_1.rmSync)(path, { recursive: true });
43
+ }
44
+ Utils.removeDir = removeDir;
45
+ function getFileName(file) {
46
+ return (0, path_1.basename)(file);
47
+ }
48
+ Utils.getFileName = getFileName;
49
+ function getExtName(path) {
50
+ return (0, path_1.extname)(path);
51
+ }
52
+ Utils.getExtName = getExtName;
53
+ function generateFileName(prefix) {
54
+ return `${prefix || "file"}-${(0, crypto_1.randomUUID)()}.txt`;
55
+ }
56
+ Utils.generateFileName = generateFileName;
57
+ function readFile(path) {
58
+ return fs_1.default.readFileSync(path).toString();
59
+ }
60
+ Utils.readFile = readFile;
61
+ function writeFile(path, content) {
62
+ (0, fs_1.writeFileSync)(path, content);
63
+ }
64
+ Utils.writeFile = writeFile;
65
+ function createTempDir() {
66
+ return (0, fs_1.mkdtempSync)((0, path_1.join)((0, os_1.tmpdir)(), "tms-"));
67
+ }
68
+ Utils.createTempDir = createTempDir;
69
+ function readStream(path) {
70
+ return fs_1.default.createReadStream(path);
71
+ }
72
+ Utils.readStream = readStream;
73
+ })(Utils || (exports.Utils = Utils = {}));
@@ -0,0 +1,16 @@
1
+ import type { IClient } from "../../client";
2
+ import type { Link, Attachment } from "../../common";
3
+ import type { IAdditions } from "./additions.type";
4
+ export declare class Additions implements IAdditions {
5
+ private client;
6
+ links: Link[];
7
+ attachments: Attachment[];
8
+ messages: string[];
9
+ constructor(client: IClient);
10
+ addAttachments(paths: string[]): Promise<Attachment[]>;
11
+ addAttachments(content: string, fileName?: string): Promise<Attachment[]>;
12
+ addLinks(link: Link): void;
13
+ addLinks(links: Link[]): void;
14
+ addMessage(message: string): void;
15
+ clear(): void;
16
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Additions = void 0;
13
+ class Additions {
14
+ constructor(client) {
15
+ this.client = client;
16
+ this.links = [];
17
+ this.attachments = [];
18
+ this.messages = [];
19
+ }
20
+ addAttachments(pathsOrContent, fileName) {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ const ids = Array.isArray(pathsOrContent)
23
+ ? yield this.client.attachments.uploadAttachments(pathsOrContent)
24
+ : yield this.client.attachments.uploadTextAttachment(pathsOrContent, fileName);
25
+ this.attachments.push(...ids);
26
+ return ids;
27
+ });
28
+ }
29
+ addLinks(links) {
30
+ Array.isArray(links) ? this.links.push(...links) : this.links.push(links);
31
+ }
32
+ addMessage(message) {
33
+ this.messages.push(message);
34
+ }
35
+ clear() {
36
+ this.attachments = [];
37
+ this.messages = [];
38
+ this.links = [];
39
+ }
40
+ }
41
+ exports.Additions = Additions;
@@ -0,0 +1,7 @@
1
+ import type { Attachment, DynamicMethods, Link } from "../../common";
2
+ export interface IAdditions extends DynamicMethods {
3
+ readonly links: Link[];
4
+ readonly attachments: Attachment[];
5
+ readonly messages: string[];
6
+ clear(): void;
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from "./additions.helper";
2
+ export * from "./additions.type";
@@ -0,0 +1,18 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./additions.helper"), exports);
18
+ __exportStar(require("./additions.type"), exports);
@@ -0,0 +1,7 @@
1
+ import { AdapterConfig, EnvironmentOptions } from "../../common";
2
+ import { IConfigComposer } from "./config.type";
3
+ export declare const DEFAULT_CONFIG_FILE = "tms.config.json";
4
+ export declare class ConfigComposer implements IConfigComposer {
5
+ compose(base?: Partial<AdapterConfig>): AdapterConfig;
6
+ merge(file: AdapterConfig, env?: Partial<EnvironmentOptions>, base?: Partial<AdapterConfig>): AdapterConfig;
7
+ }
@@ -0,0 +1,61 @@
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 (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.ConfigComposer = exports.DEFAULT_CONFIG_FILE = void 0;
27
+ const dotenv = __importStar(require("dotenv"));
28
+ const common_1 = require("../../common");
29
+ exports.DEFAULT_CONFIG_FILE = "tms.config.json";
30
+ class ConfigComposer {
31
+ compose(base) {
32
+ var _a;
33
+ const environment = parseEnvConfig();
34
+ const content = common_1.Utils.readFile((_a = environment === null || environment === void 0 ? void 0 : environment.TMS_CONFIG_FILE) !== null && _a !== void 0 ? _a : exports.DEFAULT_CONFIG_FILE);
35
+ const config = JSON.parse(content);
36
+ if (config.privateToken) {
37
+ console.warn(`
38
+ The configuration file specifies a private token. It is not safe.
39
+ Use TMS_PRIVATE_TOKEN environment variable
40
+ `);
41
+ }
42
+ return this.merge(config, environment, base);
43
+ }
44
+ merge(file, env, base) {
45
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
46
+ return {
47
+ url: (_b = (_a = base === null || base === void 0 ? void 0 : base.url) !== null && _a !== void 0 ? _a : env === null || env === void 0 ? void 0 : env.TMS_URL) !== null && _b !== void 0 ? _b : file.url,
48
+ projectId: (_d = (_c = base === null || base === void 0 ? void 0 : base.projectId) !== null && _c !== void 0 ? _c : env === null || env === void 0 ? void 0 : env.TMS_PROJECT_ID) !== null && _d !== void 0 ? _d : file.projectId,
49
+ testRunId: (_f = (_e = base === null || base === void 0 ? void 0 : base.testRunId) !== null && _e !== void 0 ? _e : env === null || env === void 0 ? void 0 : env.TMS_TEST_RUN_ID) !== null && _f !== void 0 ? _f : file.testRunId,
50
+ testRunName: (_h = (_g = base === null || base === void 0 ? void 0 : base.testRunName) !== null && _g !== void 0 ? _g : env === null || env === void 0 ? void 0 : env.TMS_TEST_RUN_NAME) !== null && _h !== void 0 ? _h : file.testRunName,
51
+ privateToken: (_k = (_j = base === null || base === void 0 ? void 0 : base.privateToken) !== null && _j !== void 0 ? _j : env === null || env === void 0 ? void 0 : env.TMS_PRIVATE_TOKEN) !== null && _k !== void 0 ? _k : file.privateToken,
52
+ adapterMode: (_o = (_m = (_l = base === null || base === void 0 ? void 0 : base.adapterMode) !== null && _l !== void 0 ? _l : env === null || env === void 0 ? void 0 : env.TMS_ADAPTER_MODE) !== null && _m !== void 0 ? _m : file.adapterMode) !== null && _o !== void 0 ? _o : 0,
53
+ configurationId: (_q = (_p = base === null || base === void 0 ? void 0 : base.configurationId) !== null && _p !== void 0 ? _p : env === null || env === void 0 ? void 0 : env.TMS_CONFIGURATION_ID) !== null && _q !== void 0 ? _q : file.configurationId,
54
+ automaticCreationTestCases: (_t = (_s = (_r = base === null || base === void 0 ? void 0 : base.automaticCreationTestCases) !== null && _r !== void 0 ? _r : env === null || env === void 0 ? void 0 : env.TMS_AUTOMATIC_CREATION_TEST_CASES) !== null && _s !== void 0 ? _s : file.automaticCreationTestCases) !== null && _t !== void 0 ? _t : false,
55
+ };
56
+ }
57
+ }
58
+ exports.ConfigComposer = ConfigComposer;
59
+ function parseEnvConfig() {
60
+ return dotenv.config({ path: ".env" }).parsed;
61
+ }
@@ -0,0 +1,5 @@
1
+ import { AdapterConfig, EnvironmentOptions } from "../../common";
2
+ export interface IConfigComposer {
3
+ compose(base?: Partial<AdapterConfig>): AdapterConfig;
4
+ merge(file: AdapterConfig, env?: Partial<EnvironmentOptions>, base?: Partial<AdapterConfig>): AdapterConfig;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from "./config.helper";
2
+ export * from "./config.type";
@@ -0,0 +1,18 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./config.helper"), exports);
18
+ __exportStar(require("./config.type"), exports);
@@ -0,0 +1,2 @@
1
+ export * from "./additions";
2
+ export * from "./config";
@@ -0,0 +1,18 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./additions"), exports);
18
+ __exportStar(require("./config"), exports);
package/lib/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from "./common";
2
+ export * from "./client";
3
+ export * from "./helpers";
4
+ export * from "./services";
5
+ export * from "./storage";
6
+ export * from "./strategy";