testit-adapter-jest 1.1.3 → 1.1.4

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.
package/README.md CHANGED
@@ -1,193 +1,173 @@
1
- # Test IT TMS adapters for Jest
2
- ![Test IT](https://raw.githubusercontent.com/testit-tms/adapters-js/master/images/banner.png)
3
-
4
- ## Getting Started
5
-
6
- ### Installation
7
- ```
8
- npm install testit-adapter-jest
9
- ```
10
-
11
- ## Usage
12
-
13
- ### API client
14
-
15
- To use adapter you need to install `testit-api-client`:
16
- ```
17
- npm install testit-api-client
18
- ```
19
-
20
- ### Configuration
21
-
22
- #### File
23
-
24
- 1. You need to set custom jest test environment, setup and teardown in `jest.config.js`.
25
-
26
- ```js
27
- module.exports = {
28
- testEnvironment: 'testit-adapter-jest',
29
- globalSetup: 'testit-adapter-jest/dist/globalSetup.js',
30
- globalTeardown: 'testit-adapter-jest/dist/globalTeardown.js',
31
- testEnvironmentOptions: {
32
- url: '<url>',
33
- privateToken: '<token>',
34
- projectId: '<id>',
35
- configurationId: '<id>',
36
- testRunId: '<optional id>',
37
- },
38
- };
39
- ```
40
-
41
- 2. You also can extract environment configuration to external config and launch tests with `jest --config ./testit.jest.config.js`.
42
-
43
- ```js
44
- // testit.jest.config.js
45
- const defaultConfig = require('./jest.config');
46
-
47
- module.exports = {
48
- ...defaultConfig,
49
- testEnvironment: 'testit-adapter-jest',
50
- globalSetup: 'testit-adapter-jest/dist/globalSetup.js',
51
- globalTeardown: 'testit-adapter-jest/dist/globalTeardown.js',
52
- testEnvironmentOptions: {
53
- url: '<url>',
54
- privateToken: '<token>',
55
- projectId: '<id>',
56
- configurationId: '<id>',
57
- testRunId: '<optional id>',
58
- adapterMode: <optional>,
59
- automaticCreationTestCases: <optional boolean>
60
- },
61
- };
62
- ```
63
-
64
- 3. Fill parameters with your configuration, where:
65
- * `url` - location of the TMS instance
66
-
67
- * `privateToken` - API secret key
68
- 1. go to the https://{DOMAIN}/user-profile profile
69
- 2. copy the API secret key
70
-
71
- * `projectId` - ID of project in TMS instance.
72
-
73
- 1. create a project
74
- 2. open DevTools -> network
75
- 3. go to the project https://{DOMAIN}/projects/{PROJECT_ID}/tests
76
- 4. GET-request project, Preview tab, copy id field
77
-
78
- * `configurationId` - ID of configuration in TMS instance.
79
-
80
- 1. create a project
81
- 2. open DevTools -> network
82
- 3. go to the project https://{DOMAIN}/projects/{PROJECT_ID}/tests
83
- 4. GET-request configurations, Preview tab, copy id field
84
-
85
- * `testRunId` - id of the created test run in TMS instance. `testRunId` is optional. If it is not provided, it is created automatically.
86
-
87
- * `testRunName` - parameter for specifying the name of test run in TMS instance. `testRunName` is optional. If it is not provided, it is created automatically.
88
-
89
- * `adapterMode` - adapter mode. Default value - 0. The adapter supports following modes:
90
- * 0 - in this mode, the adapter filters tests by test run ID and configuration ID, and sends the results to the test run.
91
- * 1 - in this mode, the adapter sends all results to the test run without filtering.
92
- * 2 - in this mode, the adapter creates a new test run and sends results to the new test run.
93
-
94
- * `automaticCreationTestCases` - mode of automatic creation test cases. Default value - false. The adapter supports following modes:
95
- * true - in this mode, the adapter will create a test case linked to the created autotest (not to the updated autotest).
96
- * false - in this mode, the adapter will not create a test case.
97
-
98
- #### Command line
99
-
100
- You can also specify options via cli arguments `jest --testEnvironment testit-adapter-jest --testEnvironmentOptions "{\"url\":\"<url>\",\"privateToken\":\"<token>\",\"projectId\":\"<id>\",\"configurationId\":\"<id>\",\"testRunId\":\"<optional id>\",\"automaticCreationTestCases\": <optional boolean>}" --globalSetup testit-adapter-jest/dist/globalSetup.js --globalTeardown testit-adapter-jest/dist/globalTeardown.js`
101
-
102
-
103
- ### Methods
104
-
105
- Methods can be used to specify information about autotest.
106
-
107
- Description of metadata methods:
108
- - `testit.workItemIds` - linking an autotest to a test case
109
- - `testit.displayName` - name of the autotest in the Test IT system (can be replaced with documentation strings)
110
- - `testit.externalId` - ID of the autotest within the project in the Test IT System
111
- - `testit.title` - title in the autotest card
112
- - `testit.description` - description in the autotest card
113
- - `testit.labels` - tags in the work item
114
- - `testit.link` - links in the autotest card
115
- - `testit.nameSpace` - directory in the TMS system (default - directory's name of test)
116
- - `testit.className` - subdirectory in the TMS system (default - file's name of test)
117
-
118
- Description of methods:
119
- - `testit.addLinks` - links in the autotest result
120
- - `testit.addAttachments` - uploading files in the autotest result
121
- - `testit.addMessage` - information about autotest in the autotest result
122
-
123
- ### Examples
124
-
125
- #### Simple test
126
- ```js
127
- test('All annotations', () => {
128
- testit.externalId('all_annotations');
129
- testit.displayName('All annotations');
130
- testit.title('All annotations title');
131
- testit.description('Test with all annotations');
132
- testit.labels(['label1', 'label2']);
133
-
134
- testit.addMessage('This is a message');
135
- testit.addLinks([
136
- {
137
- url: 'https://www.google.com',
138
- title: 'Google',
139
- description: 'This is a link to Google',
140
- type: 'Related',
141
- },
142
- ]);
143
-
144
- testit.addAttachments([join(__dirname, 'attachment1.txt')]);
145
- testit.addAttachments('This is a custom attachment', 'custom.txt');
146
-
147
- expect(1).toBe(1);
148
- });
149
- ```
150
-
151
- #### Parameterized test
152
- ```js
153
- test.each([1, 2, 3, 4])('Primitive params', (number) => {
154
- testit.params(number);
155
- expect(number).toBe(number);
156
- });
157
-
158
- test.each([
159
- {
160
- a: 1,
161
- b: 2,
162
- sum: 3,
163
- },
164
- {
165
- a: 2,
166
- b: 3,
167
- sum: 5,
168
- },
169
- {
170
- a: 4,
171
- b: 3,
172
- sum: 5,
173
- }
174
- ])('Object params', (params) => {
175
- testit.params(params);
176
- expect(params.a + params.b).toBe(params.sum);
177
- });
178
- ```
179
-
180
-
181
- # Contributing
182
-
183
- You can help to develop the project. Any contributions are **greatly appreciated**.
184
-
185
- * If you have suggestions for adding or removing projects, feel free to [open an issue](https://github.com/testit-tms/adapters-js/issues/new) to discuss it, or directly create a pull request after you edit the *README.md* file with necessary changes.
186
- * Please make sure you check your spelling and grammar.
187
- * Create individual PR for each suggestion.
188
- * Please also read through the [Code Of Conduct](https://github.com/testit-tms/adapters-js/blob/master/CODE_OF_CONDUCT.md) before posting your first idea as well.
189
-
190
- # License
191
-
192
- Distributed under the Apache-2.0 License. See [LICENSE](https://github.com/testit-tms/adapters-js/blob/master/LICENSE.md) for more information.
193
-
1
+ # Test IT TMS adapters for Jest
2
+ ![Test IT](https://raw.githubusercontent.com/testit-tms/adapters-js/master/images/banner.png)
3
+
4
+ ## Getting Started
5
+
6
+ ### Installation
7
+ ```
8
+ npm install testit-adapter-jest
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### API client
14
+
15
+ To use adapter you need to install `testit-api-client`:
16
+ ```
17
+ npm install testit-api-client
18
+ ```
19
+
20
+ ### Configuration
21
+
22
+ | Description | Property | Environment variable | CLI argument |
23
+ |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------|-----------------------------------|-------------------------------|
24
+ | Location of the TMS instance | url | TMS_URL | tmsUrl |
25
+ | API secret key [How to getting API secret key?](https://github.com/testit-tms/.github/tree/main/configuration#privatetoken) | privateToken | TMS_PRIVATE_TOKEN | tmsPrivateToken |
26
+ | ID of project in TMS instance [How to getting project ID?](https://github.com/testit-tms/.github/tree/main/configuration#projectid) | projectId | TMS_PROJECT_ID | tmsProjectId |
27
+ | ID of configuration in TMS instance [How to getting configuration ID?](https://github.com/testit-tms/.github/tree/main/configuration#configurationid) | configurationId | TMS_CONFIGURATION_ID | tmsConfigurationId |
28
+ | ID of the created test run in TMS instance.<br/>It's necessary for **adapterMode** 0 or 1 | testRunId | TMS_TEST_RUN_ID | tmsTestRunId |
29
+ | Parameter for specifying the name of test run in TMS instance (**It's optional**). If it is not provided, it is created automatically | testRunName | TMS_TEST_RUN_NAME | tmsTestRunName |
30
+ | Adapter mode. Default value - 0. The adapter supports following modes:<br/>0 - in this mode, the adapter filters tests by test run ID and configuration ID, and sends the results to the test run<br/>1 - in this mode, the adapter sends all results to the test run without filtering<br/>2 - in this mode, the adapter creates a new test run and sends results to the new test run | adapterMode | TMS_ADAPTER_MODE | tmsAdapterMode |
31
+ | It enables/disables certificate validation (**It's optional**). Default value - true | certValidation | TMS_CERT_VALIDATION | tmsCertValidation |
32
+ | Mode of automatic creation test cases (**It's optional**). Default value - false. The adapter supports following modes:<br/>true - in this mode, the adapter will create a test case linked to the created autotest (not to the updated autotest)<br/>false - in this mode, the adapter will not create a test case | automaticCreationTestCases | TMS_AUTOMATIC_CREATION_TEST_CASES | tmsAutomaticCreationTestCases |
33
+
34
+ #### File
35
+
36
+ 1. You need to set custom jest test environment, setup and teardown in `jest.config.js`.
37
+
38
+ ```js
39
+ module.exports = {
40
+ testEnvironment: 'testit-adapter-jest',
41
+ globalSetup: 'testit-adapter-jest/dist/globalSetup.js',
42
+ globalTeardown: 'testit-adapter-jest/dist/globalTeardown.js',
43
+ testEnvironmentOptions: {
44
+ url: 'URL',
45
+ privateToken: 'USER_PRIVATE_TOKEN',
46
+ projectId: 'PROJECT_ID',
47
+ configurationId: 'CONFIGURATION_ID',
48
+ testRunId: 'TEST_RUN_ID',
49
+ adapterMode: ADAPTER_MODE,
50
+ automaticCreationTestCases: AUTOMATIC_CREATION_TEST_CASES
51
+ },
52
+ };
53
+ ```
54
+
55
+ 2. You also can extract environment configuration to external config and launch tests with `jest --config ./testit.jest.config.js`.
56
+
57
+ ```js
58
+ // testit.jest.config.js
59
+ const defaultConfig = require('./jest.config');
60
+
61
+ module.exports = {
62
+ ...defaultConfig,
63
+ testEnvironment: 'testit-adapter-jest',
64
+ globalSetup: 'testit-adapter-jest/dist/globalSetup.js',
65
+ globalTeardown: 'testit-adapter-jest/dist/globalTeardown.js',
66
+ testEnvironmentOptions: {
67
+ url: 'URL',
68
+ privateToken: 'USER_PRIVATE_TOKEN',
69
+ projectId: 'PROJECT_ID',
70
+ configurationId: 'CONFIGURATION_ID',
71
+ testRunId: 'TEST_RUN_ID',
72
+ adapterMode: ADAPTER_MODE,
73
+ automaticCreationTestCases: AUTOMATIC_CREATION_TEST_CASES
74
+ },
75
+ };
76
+ ```
77
+
78
+ #### Command line
79
+
80
+ You can also specify options via cli arguments `jest --testEnvironment testit-adapter-jest --testEnvironmentOptions "{\"url\":\"URL\",\"privateToken\":\"USER_PRIVATE_TOKEN\",\"projectId\":\"PROJECT_ID\",\"configurationId\":\"CONFIGURATION_ID\",\"testRunId\":\"TEST_RUN_ID\",\"adapterMode\":ADAPTER_MODE,\"automaticCreationTestCases\":AUTOMATIC_CREATION_TEST_CASES}" --globalSetup testit-adapter-jest/dist/globalSetup.js --globalTeardown testit-adapter-jest/dist/globalTeardown.js`
81
+
82
+
83
+ ### Methods
84
+
85
+ Methods can be used to specify information about autotest.
86
+
87
+ Description of metadata methods:
88
+ - `testit.workItemIds` - linking an autotest to a test case
89
+ - `testit.displayName` - name of the autotest in the Test IT system (can be replaced with documentation strings)
90
+ - `testit.externalId` - ID of the autotest within the project in the Test IT System
91
+ - `testit.title` - title in the autotest card
92
+ - `testit.description` - description in the autotest card
93
+ - `testit.labels` - tags in the work item
94
+ - `testit.link` - links in the autotest card
95
+ - `testit.nameSpace` - directory in the TMS system (default - directory's name of test)
96
+ - `testit.className` - subdirectory in the TMS system (default - file's name of test)
97
+
98
+ Description of methods:
99
+ - `testit.addLinks` - links in the autotest result
100
+ - `testit.addAttachments` - uploading files in the autotest result
101
+ - `testit.addMessage` - information about autotest in the autotest result
102
+
103
+ ### Examples
104
+
105
+ #### Simple test
106
+ ```js
107
+ test('All annotations', () => {
108
+ testit.externalId('all_annotations');
109
+ testit.displayName('All annotations');
110
+ testit.title('All annotations title');
111
+ testit.description('Test with all annotations');
112
+ testit.labels(['label1', 'label2']);
113
+
114
+ testit.addMessage('This is a message');
115
+ testit.addLinks([
116
+ {
117
+ url: 'https://www.google.com',
118
+ title: 'Google',
119
+ description: 'This is a link to Google',
120
+ type: 'Related',
121
+ },
122
+ ]);
123
+
124
+ testit.addAttachments([join(__dirname, 'attachment1.txt')]);
125
+ testit.addAttachments('This is a custom attachment', 'custom.txt');
126
+
127
+ expect(1).toBe(1);
128
+ });
129
+ ```
130
+
131
+ #### Parameterized test
132
+ ```js
133
+ test.each([1, 2, 3, 4])('Primitive params', (number) => {
134
+ testit.params(number);
135
+ expect(number).toBe(number);
136
+ });
137
+
138
+ test.each([
139
+ {
140
+ a: 1,
141
+ b: 2,
142
+ sum: 3,
143
+ },
144
+ {
145
+ a: 2,
146
+ b: 3,
147
+ sum: 5,
148
+ },
149
+ {
150
+ a: 4,
151
+ b: 3,
152
+ sum: 5,
153
+ }
154
+ ])('Object params', (params) => {
155
+ testit.params(params);
156
+ expect(params.a + params.b).toBe(params.sum);
157
+ });
158
+ ```
159
+
160
+
161
+ # Contributing
162
+
163
+ You can help to develop the project. Any contributions are **greatly appreciated**.
164
+
165
+ * If you have suggestions for adding or removing projects, feel free to [open an issue](https://github.com/testit-tms/adapters-js/issues/new) to discuss it, or directly create a pull request after you edit the *README.md* file with necessary changes.
166
+ * Please make sure you check your spelling and grammar.
167
+ * Create individual PR for each suggestion.
168
+ * Please also read through the [Code Of Conduct](https://github.com/testit-tms/adapters-js/blob/master/CODE_OF_CONDUCT.md) before posting your first idea as well.
169
+
170
+ # License
171
+
172
+ Distributed under the Apache-2.0 License. See [LICENSE](https://github.com/testit-tms/adapters-js/blob/master/LICENSE.md) for more information.
173
+
package/dist/config.d.ts CHANGED
@@ -1 +1 @@
1
- export type AdapterMode = 0 | 1 | 2;
1
+ export type AdapterMode = 0 | 1 | 2;
package/dist/config.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/debug.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import d from 'debug';
2
- export declare const debug: d.Debugger;
1
+ import d from 'debug';
2
+ export declare const debug: d.Debugger;
package/dist/debug.js CHANGED
@@ -1,8 +1,8 @@
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.debug = void 0;
7
- const debug_1 = __importDefault(require("debug"));
8
- exports.debug = (0, debug_1.default)('testit');
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.debug = void 0;
7
+ const debug_1 = __importDefault(require("debug"));
8
+ exports.debug = (0, debug_1.default)('testit');
@@ -1,3 +1,3 @@
1
- import { Config } from '@jest/reporters';
2
- declare const _default: (globalConfig: Config.GlobalConfig, projectConfig: Config.ProjectConfig) => Promise<void>;
3
- export default _default;
1
+ import { Config } from '@jest/reporters';
2
+ declare const _default: (globalConfig: Config.GlobalConfig, projectConfig: Config.ProjectConfig) => Promise<void>;
3
+ export default _default;
@@ -1,35 +1,35 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const testClient_1 = require("./testClient");
4
- const utils_1 = require("./utils");
5
- exports.default = async (globalConfig, projectConfig) => {
6
- const adapterMode = projectConfig.testEnvironmentOptions?.adapterMode ?? 0;
7
- const automaticCreationTestCases = projectConfig.testEnvironmentOptions?.automaticCreationTestCases ?? false;
8
- let testRunId;
9
- try {
10
- switch (adapterMode) {
11
- case 0:
12
- case 1: {
13
- testRunId = projectConfig.testEnvironmentOptions?.testRunId;
14
- if (!testRunId) {
15
- throw new Error('testRunId is required when mode is 1');
16
- }
17
- globalThis.testClient = new testClient_1.TestClient(projectConfig.testEnvironmentOptions);
18
- break;
19
- }
20
- case 2: {
21
- globalThis.testClient = new testClient_1.TestClient(projectConfig.testEnvironmentOptions);
22
- testRunId = await globalThis.testClient.createTestRun();
23
- break;
24
- }
25
- default:
26
- throw new Error(`Unknown adapter mode ${adapterMode}`);
27
- }
28
- }
29
- catch (err) {
30
- console.error('Failed to setup', (0, utils_1.formatError)(err));
31
- process.exit(1);
32
- }
33
- projectConfig.globals['testRunId'] = testRunId;
34
- projectConfig.globals['automaticCreationTestCases'] = automaticCreationTestCases;
35
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const testClient_1 = require("./testClient");
4
+ const utils_1 = require("./utils");
5
+ exports.default = async (globalConfig, projectConfig) => {
6
+ const adapterMode = projectConfig.testEnvironmentOptions?.adapterMode ?? 0;
7
+ const automaticCreationTestCases = projectConfig.testEnvironmentOptions?.automaticCreationTestCases ?? false;
8
+ let testRunId;
9
+ try {
10
+ switch (adapterMode) {
11
+ case 0:
12
+ case 1: {
13
+ testRunId = projectConfig.testEnvironmentOptions?.testRunId;
14
+ if (!testRunId) {
15
+ throw new Error('testRunId is required when mode is 1');
16
+ }
17
+ globalThis.testClient = new testClient_1.TestClient(projectConfig.testEnvironmentOptions);
18
+ break;
19
+ }
20
+ case 2: {
21
+ globalThis.testClient = new testClient_1.TestClient(projectConfig.testEnvironmentOptions);
22
+ testRunId = await globalThis.testClient.createTestRun();
23
+ break;
24
+ }
25
+ default:
26
+ throw new Error(`Unknown adapter mode ${adapterMode}`);
27
+ }
28
+ }
29
+ catch (err) {
30
+ console.error('Failed to setup', (0, utils_1.formatError)(err));
31
+ process.exit(1);
32
+ }
33
+ projectConfig.globals['testRunId'] = testRunId;
34
+ projectConfig.globals['automaticCreationTestCases'] = automaticCreationTestCases;
35
+ };
@@ -1,3 +1,3 @@
1
- import { Config } from '@jest/reporters';
2
- declare const _default: (globalConfig: Config.GlobalConfig, projectConfig: Config.ProjectConfig) => Promise<void>;
3
- export default _default;
1
+ import { Config } from '@jest/reporters';
2
+ declare const _default: (globalConfig: Config.GlobalConfig, projectConfig: Config.ProjectConfig) => Promise<void>;
3
+ export default _default;
@@ -1,16 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("./utils");
4
- exports.default = async (globalConfig, projectConfig) => {
5
- const testRunId = projectConfig.globals['testRunId'];
6
- if (!testRunId) {
7
- console.error('Looks like globalSetup was not called');
8
- return;
9
- }
10
- try {
11
- await globalThis.testClient.completeTestRun();
12
- }
13
- catch (err) {
14
- console.error('Failed to complete test run', (0, utils_1.formatError)(err));
15
- }
16
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("./utils");
4
+ exports.default = async (globalConfig, projectConfig) => {
5
+ const testRunId = projectConfig.globals['testRunId'];
6
+ if (!testRunId) {
7
+ console.error('Looks like globalSetup was not called');
8
+ return;
9
+ }
10
+ try {
11
+ await globalThis.testClient.completeTestRun();
12
+ }
13
+ catch (err) {
14
+ console.error('Failed to complete test run', (0, utils_1.formatError)(err));
15
+ }
16
+ };
package/dist/mappers.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { AttachmentPut, AttachmentPutModelAutotestStepResults, AutotestStep, Parameters } from 'testit-api-client';
2
- import { StepData } from './types';
3
- export declare function mapDate(date: number): string;
4
- export declare function mapStep(step: StepData): AutotestStep;
5
- export declare function mapParams(params: any): Parameters;
6
- export declare function mapStepResult(step: StepData): AttachmentPutModelAutotestStepResults;
7
- export declare function mapAttachments(attachments: string[]): AttachmentPut[];
1
+ import { AttachmentPut, AttachmentPutModelAutotestStepResults, AutotestStep, Parameters } from 'testit-api-client';
2
+ import { StepData } from './types';
3
+ export declare function mapDate(date: number): string;
4
+ export declare function mapStep(step: StepData): AutotestStep;
5
+ export declare function mapParams(params: any): Parameters;
6
+ export declare function mapStepResult(step: StepData): AttachmentPutModelAutotestStepResults;
7
+ export declare function mapAttachments(attachments: string[]): AttachmentPut[];
package/dist/mappers.js CHANGED
@@ -1,46 +1,46 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mapAttachments = exports.mapStepResult = exports.mapParams = exports.mapStep = exports.mapDate = void 0;
4
- function mapDate(date) {
5
- return new Date(date).toISOString();
6
- }
7
- exports.mapDate = mapDate;
8
- function mapStep(step) {
9
- return {
10
- title: step.title,
11
- description: step.description,
12
- };
13
- }
14
- exports.mapStep = mapStep;
15
- function mapParams(params) {
16
- switch (typeof params) {
17
- case 'string':
18
- case 'bigint':
19
- case 'number':
20
- case 'boolean':
21
- return { value: params.toString() };
22
- case 'object':
23
- if (params === null) {
24
- return {};
25
- }
26
- return Object.keys(params).reduce((acc, key) => {
27
- acc[key] = params[key].toString();
28
- return acc;
29
- }, {});
30
- default:
31
- return {};
32
- }
33
- }
34
- exports.mapParams = mapParams;
35
- function mapStepResult(step) {
36
- return {
37
- title: step.title,
38
- description: step.description,
39
- attachments: mapAttachments(step.attachments),
40
- };
41
- }
42
- exports.mapStepResult = mapStepResult;
43
- function mapAttachments(attachments) {
44
- return attachments.map((id) => ({ id }));
45
- }
46
- exports.mapAttachments = mapAttachments;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapAttachments = exports.mapStepResult = exports.mapParams = exports.mapStep = exports.mapDate = void 0;
4
+ function mapDate(date) {
5
+ return new Date(date).toISOString();
6
+ }
7
+ exports.mapDate = mapDate;
8
+ function mapStep(step) {
9
+ return {
10
+ title: step.title,
11
+ description: step.description,
12
+ };
13
+ }
14
+ exports.mapStep = mapStep;
15
+ function mapParams(params) {
16
+ switch (typeof params) {
17
+ case 'string':
18
+ case 'bigint':
19
+ case 'number':
20
+ case 'boolean':
21
+ return { value: params.toString() };
22
+ case 'object':
23
+ if (params === null) {
24
+ return {};
25
+ }
26
+ return Object.keys(params).reduce((acc, key) => {
27
+ acc[key] = params[key].toString();
28
+ return acc;
29
+ }, {});
30
+ default:
31
+ return {};
32
+ }
33
+ }
34
+ exports.mapParams = mapParams;
35
+ function mapStepResult(step) {
36
+ return {
37
+ title: step.title,
38
+ description: step.description,
39
+ attachments: mapAttachments(step.attachments),
40
+ };
41
+ }
42
+ exports.mapStepResult = mapStepResult;
43
+ function mapAttachments(attachments) {
44
+ return attachments.map((id) => ({ id }));
45
+ }
46
+ exports.mapAttachments = mapAttachments;