smartling-api-sdk-nodejs 3.5.0 → 3.6.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.
- package/.env.example +2 -1
- package/api/estimates/dto/effective-rates-range-dto.ts +7 -0
- package/api/estimates/dto/estimate-report-dto.ts +34 -0
- package/api/estimates/dto/estimate-report-status-dto.ts +13 -0
- package/api/estimates/dto/estimate-report-tags-dto.ts +5 -0
- package/api/estimates/dto/fuzzy-match-tier-dto.ts +17 -0
- package/api/estimates/dto/generated-estimate-report-dto.ts +10 -0
- package/api/estimates/dto/locale-estimate-dto.ts +17 -0
- package/api/estimates/dto/locale-workflow-pair-dto.ts +6 -0
- package/api/estimates/dto/locale-workflow-step-pair-dto.ts +6 -0
- package/api/estimates/dto/price-information-dto.ts +12 -0
- package/api/estimates/dto/workflow-estimate-dto.ts +18 -0
- package/api/estimates/dto/workflow-step-estimate-dto.ts +21 -0
- package/api/estimates/index.ts +102 -0
- package/api/estimates/params/estimate-report-content-coverage.ts +4 -0
- package/api/estimates/params/estimate-report-status.ts +9 -0
- package/api/estimates/params/estimate-report-type.ts +4 -0
- package/api/estimates/params/fuzzy-match-type-code.ts +4 -0
- package/api/estimates/params/generate-job-estimate-report-parameters.ts +46 -0
- package/api/estimates/params/job-content-type.ts +6 -0
- package/api/estimates/params/list-job-estimate-reports-parameters.ts +64 -0
- package/api/estimates/params/modify-estimate-report-tags-parameters.ts +9 -0
- package/built/api/estimates/dto/effective-rates-range-dto.d.ts +6 -0
- package/built/api/estimates/dto/effective-rates-range-dto.js +3 -0
- package/built/api/estimates/dto/effective-rates-range-dto.js.map +1 -0
- package/built/api/estimates/dto/estimate-report-dto.d.ts +30 -0
- package/built/api/estimates/dto/estimate-report-dto.js +3 -0
- package/built/api/estimates/dto/estimate-report-dto.js.map +1 -0
- package/built/api/estimates/dto/estimate-report-status-dto.d.ts +11 -0
- package/built/api/estimates/dto/estimate-report-status-dto.js +3 -0
- package/built/api/estimates/dto/estimate-report-status-dto.js.map +1 -0
- package/built/api/estimates/dto/estimate-report-tags-dto.d.ts +4 -0
- package/built/api/estimates/dto/estimate-report-tags-dto.js +3 -0
- package/built/api/estimates/dto/estimate-report-tags-dto.js.map +1 -0
- package/built/api/estimates/dto/fuzzy-match-tier-dto.d.ts +12 -0
- package/built/api/estimates/dto/fuzzy-match-tier-dto.js +3 -0
- package/built/api/estimates/dto/fuzzy-match-tier-dto.js.map +1 -0
- package/built/api/estimates/dto/generated-estimate-report-dto.d.ts +8 -0
- package/built/api/estimates/dto/generated-estimate-report-dto.js +3 -0
- package/built/api/estimates/dto/generated-estimate-report-dto.js.map +1 -0
- package/built/api/estimates/dto/locale-estimate-dto.d.ts +13 -0
- package/built/api/estimates/dto/locale-estimate-dto.js +3 -0
- package/built/api/estimates/dto/locale-estimate-dto.js.map +1 -0
- package/built/api/estimates/dto/locale-workflow-pair-dto.d.ts +5 -0
- package/built/api/estimates/dto/locale-workflow-pair-dto.js +3 -0
- package/built/api/estimates/dto/locale-workflow-pair-dto.js.map +1 -0
- package/built/api/estimates/dto/locale-workflow-step-pair-dto.d.ts +5 -0
- package/built/api/estimates/dto/locale-workflow-step-pair-dto.js +3 -0
- package/built/api/estimates/dto/locale-workflow-step-pair-dto.js.map +1 -0
- package/built/api/estimates/dto/price-information-dto.d.ts +9 -0
- package/built/api/estimates/dto/price-information-dto.js +3 -0
- package/built/api/estimates/dto/price-information-dto.js.map +1 -0
- package/built/api/estimates/dto/workflow-estimate-dto.d.ts +13 -0
- package/built/api/estimates/dto/workflow-estimate-dto.js +3 -0
- package/built/api/estimates/dto/workflow-estimate-dto.js.map +1 -0
- package/built/api/estimates/dto/workflow-step-estimate-dto.d.ts +17 -0
- package/built/api/estimates/dto/workflow-step-estimate-dto.js +3 -0
- package/built/api/estimates/dto/workflow-step-estimate-dto.js.map +1 -0
- package/built/api/estimates/index.d.ts +23 -0
- package/built/api/estimates/index.js +68 -0
- package/built/api/estimates/index.js.map +1 -0
- package/built/api/estimates/params/estimate-report-content-coverage.d.ts +4 -0
- package/built/api/estimates/params/estimate-report-content-coverage.js +9 -0
- package/built/api/estimates/params/estimate-report-content-coverage.js.map +1 -0
- package/built/api/estimates/params/estimate-report-status.d.ts +9 -0
- package/built/api/estimates/params/estimate-report-status.js +14 -0
- package/built/api/estimates/params/estimate-report-status.js.map +1 -0
- package/built/api/estimates/params/estimate-report-type.d.ts +4 -0
- package/built/api/estimates/params/estimate-report-type.js +9 -0
- package/built/api/estimates/params/estimate-report-type.js.map +1 -0
- package/built/api/estimates/params/fuzzy-match-type-code.d.ts +4 -0
- package/built/api/estimates/params/fuzzy-match-type-code.js +9 -0
- package/built/api/estimates/params/fuzzy-match-type-code.js.map +1 -0
- package/built/api/estimates/params/generate-job-estimate-report-parameters.d.ts +12 -0
- package/built/api/estimates/params/generate-job-estimate-report-parameters.js +32 -0
- package/built/api/estimates/params/generate-job-estimate-report-parameters.js.map +1 -0
- package/built/api/estimates/params/job-content-type.d.ts +6 -0
- package/built/api/estimates/params/job-content-type.js +11 -0
- package/built/api/estimates/params/job-content-type.js.map +1 -0
- package/built/api/estimates/params/list-job-estimate-reports-parameters.d.ts +15 -0
- package/built/api/estimates/params/list-job-estimate-reports-parameters.js +44 -0
- package/built/api/estimates/params/list-job-estimate-reports-parameters.js.map +1 -0
- package/built/api/estimates/params/modify-estimate-report-tags-parameters.d.ts +4 -0
- package/built/api/estimates/params/modify-estimate-report-tags-parameters.js +12 -0
- package/built/api/estimates/params/modify-estimate-report-tags-parameters.js.map +1 -0
- package/built/index.d.ts +21 -0
- package/built/index.js +21 -0
- package/built/index.js.map +1 -1
- package/built/package.json +1 -1
- package/built/test/estimates.spec.d.ts +1 -0
- package/built/test/estimates.spec.js +191 -0
- package/built/test/estimates.spec.js.map +1 -0
- package/built/test/integration/estimates.spec.d.ts +1 -0
- package/built/test/integration/estimates.spec.js +182 -0
- package/built/test/integration/estimates.spec.js.map +1 -0
- package/built/test/integration/helpers/log-response.js +1 -2
- package/built/test/integration/helpers/log-response.js.map +1 -1
- package/index.ts +21 -0
- package/package.json +1 -1
- package/test/estimates.spec.ts +242 -0
- package/test/integration/estimates.spec.ts +271 -0
- package/test/integration/helpers/log-response.ts +5 -3
|
@@ -0,0 +1,191 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const sinon_1 = __importDefault(require("sinon"));
|
|
16
|
+
const mock_1 = require("./mock");
|
|
17
|
+
const index_1 = require("../api/estimates/index");
|
|
18
|
+
const list_job_estimate_reports_parameters_1 = require("../api/estimates/params/list-job-estimate-reports-parameters");
|
|
19
|
+
const generate_job_estimate_report_parameters_1 = require("../api/estimates/params/generate-job-estimate-report-parameters");
|
|
20
|
+
const modify_estimate_report_tags_parameters_1 = require("../api/estimates/params/modify-estimate-report-tags-parameters");
|
|
21
|
+
const estimate_report_status_1 = require("../api/estimates/params/estimate-report-status");
|
|
22
|
+
const estimate_report_content_coverage_1 = require("../api/estimates/params/estimate-report-content-coverage");
|
|
23
|
+
const job_content_type_1 = require("../api/estimates/params/job-content-type");
|
|
24
|
+
describe("SmartlingEstimatesApi class tests.", () => {
|
|
25
|
+
const projectId = "testProjectId";
|
|
26
|
+
const translationJobUid = "testJobUid";
|
|
27
|
+
const reportUid = "testReportUid";
|
|
28
|
+
let estimatesApi;
|
|
29
|
+
let estimatesApiFetchStub;
|
|
30
|
+
let estimatesApiUaStub;
|
|
31
|
+
let responseMockJsonStub;
|
|
32
|
+
beforeEach(() => {
|
|
33
|
+
estimatesApi = new index_1.SmartlingEstimatesApi("https://test.com", mock_1.authMock, mock_1.loggerMock);
|
|
34
|
+
estimatesApiFetchStub = sinon_1.default.stub(estimatesApi, "fetch");
|
|
35
|
+
estimatesApiUaStub = sinon_1.default.stub(estimatesApi, "ua");
|
|
36
|
+
responseMockJsonStub = sinon_1.default.stub(mock_1.responseMock, "json");
|
|
37
|
+
estimatesApiUaStub.returns("test_user_agent");
|
|
38
|
+
estimatesApiFetchStub.returns(mock_1.responseMock);
|
|
39
|
+
responseMockJsonStub.returns({
|
|
40
|
+
response: {}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
afterEach(() => {
|
|
44
|
+
estimatesApiFetchStub.restore();
|
|
45
|
+
responseMockJsonStub.restore();
|
|
46
|
+
estimatesApiUaStub.restore();
|
|
47
|
+
});
|
|
48
|
+
describe("Methods", () => {
|
|
49
|
+
it("Get job fuzzy estimate reports", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
+
const params = new list_job_estimate_reports_parameters_1.ListJobEstimateReportsParameters()
|
|
51
|
+
.setReportStatus(estimate_report_status_1.EstimateReportStatus.COMPLETED)
|
|
52
|
+
.setContentCoverage(estimate_report_content_coverage_1.EstimateReportContentCoverage.FULL)
|
|
53
|
+
.setCreatorUserUids(["creatorUserUid1"])
|
|
54
|
+
.setTranslationJobSchemaContents([job_content_type_1.JobContentType.ALL_CONTENT])
|
|
55
|
+
.setTags(["tag1", "tag2"])
|
|
56
|
+
.setCreatedFrom(new Date("2020-01-01T00:00:00.000Z"))
|
|
57
|
+
.setCreatedTo(new Date("2020-02-01T00:00:00.000Z"))
|
|
58
|
+
.setLimit(100)
|
|
59
|
+
.setOffset(10);
|
|
60
|
+
yield estimatesApi.getJobFuzzyEstimateReports(projectId, translationJobUid, params);
|
|
61
|
+
sinon_1.default.assert.calledOnce(estimatesApiFetchStub);
|
|
62
|
+
sinon_1.default.assert.calledWithExactly(estimatesApiFetchStub, `https://test.com/estimates-api/v2/projects/${projectId}/jobs/${translationJobUid}/reports/fuzzy?reportStatus=COMPLETED&contentCoverage=FULL&creatorUserUids=creatorUserUid1&translationJobSchemaContents=ALL_CONTENT&tags=tag1&tags=tag2&createdFrom=2020-01-01T00%3A00%3A00Z&createdTo=2020-02-01T00%3A00%3A00Z&limit=100&offset=10`, {
|
|
63
|
+
headers: {
|
|
64
|
+
Authorization: "test_token_type test_access_token",
|
|
65
|
+
"Content-Type": "application/json",
|
|
66
|
+
"User-Agent": "test_user_agent"
|
|
67
|
+
},
|
|
68
|
+
method: "get"
|
|
69
|
+
});
|
|
70
|
+
}));
|
|
71
|
+
it("Generate job fuzzy estimate report", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
72
|
+
const params = new generate_job_estimate_report_parameters_1.GenerateJobEstimateReportParameters()
|
|
73
|
+
.setContentType(job_content_type_1.JobContentType.ALL_CONTENT)
|
|
74
|
+
.setTags(["tag1"])
|
|
75
|
+
.setLocaleWorkflowStepsFilter([
|
|
76
|
+
{ targetLocaleId: "es-CR", workflowStepUid: "9358c9ed8748" }
|
|
77
|
+
]);
|
|
78
|
+
yield estimatesApi.generateJobFuzzyEstimateReport(projectId, translationJobUid, params);
|
|
79
|
+
sinon_1.default.assert.calledOnce(estimatesApiFetchStub);
|
|
80
|
+
sinon_1.default.assert.calledWithExactly(estimatesApiFetchStub, `https://test.com/estimates-api/v2/projects/${projectId}/jobs/${translationJobUid}/reports/fuzzy`, {
|
|
81
|
+
body: "{\"contentType\":\"ALL_CONTENT\",\"tags\":[\"tag1\"],\"localeWorkflowStepsFilter\":[{\"targetLocaleId\":\"es-CR\",\"workflowStepUid\":\"9358c9ed8748\"}]}",
|
|
82
|
+
headers: {
|
|
83
|
+
Authorization: "test_token_type test_access_token",
|
|
84
|
+
"Content-Type": "application/json",
|
|
85
|
+
"User-Agent": "test_user_agent"
|
|
86
|
+
},
|
|
87
|
+
method: "post"
|
|
88
|
+
});
|
|
89
|
+
}));
|
|
90
|
+
it("Get job cost estimate reports", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
91
|
+
const params = new list_job_estimate_reports_parameters_1.ListJobEstimateReportsParameters()
|
|
92
|
+
.setLimit(50)
|
|
93
|
+
.setOffset(0);
|
|
94
|
+
yield estimatesApi.getJobCostEstimateReports(projectId, translationJobUid, params);
|
|
95
|
+
sinon_1.default.assert.calledOnce(estimatesApiFetchStub);
|
|
96
|
+
sinon_1.default.assert.calledWithExactly(estimatesApiFetchStub, `https://test.com/estimates-api/v2/projects/${projectId}/jobs/${translationJobUid}/reports/cost?limit=50&offset=0`, {
|
|
97
|
+
headers: {
|
|
98
|
+
Authorization: "test_token_type test_access_token",
|
|
99
|
+
"Content-Type": "application/json",
|
|
100
|
+
"User-Agent": "test_user_agent"
|
|
101
|
+
},
|
|
102
|
+
method: "get"
|
|
103
|
+
});
|
|
104
|
+
}));
|
|
105
|
+
it("Generate job cost estimate report", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
106
|
+
const params = new generate_job_estimate_report_parameters_1.GenerateJobEstimateReportParameters()
|
|
107
|
+
.setContentType(job_content_type_1.JobContentType.UNAUTHORIZED)
|
|
108
|
+
.setTags(["tag1", "tag2"])
|
|
109
|
+
.setLocaleWorkflows([{ targetLocaleId: "en-FR", workflowUid: "783d9d255523" }])
|
|
110
|
+
.setFuzzyProfileUid("uid123456")
|
|
111
|
+
.setRushRequest(true)
|
|
112
|
+
.setLocaleWorkflowStepsFilter([
|
|
113
|
+
{ targetLocaleId: "es-CR", workflowStepUid: "9358c9ed8748" }
|
|
114
|
+
]);
|
|
115
|
+
yield estimatesApi.generateJobCostEstimateReport(projectId, translationJobUid, params);
|
|
116
|
+
sinon_1.default.assert.calledOnce(estimatesApiFetchStub);
|
|
117
|
+
sinon_1.default.assert.calledWithExactly(estimatesApiFetchStub, `https://test.com/estimates-api/v2/projects/${projectId}/jobs/${translationJobUid}/reports/cost`, {
|
|
118
|
+
body: "{\"contentType\":\"UNAUTHORIZED\",\"tags\":[\"tag1\",\"tag2\"],\"localeWorkflows\":[{\"targetLocaleId\":\"en-FR\",\"workflowUid\":\"783d9d255523\"}],\"fuzzyProfileUid\":\"uid123456\",\"rushRequest\":true,\"localeWorkflowStepsFilter\":[{\"targetLocaleId\":\"es-CR\",\"workflowStepUid\":\"9358c9ed8748\"}]}",
|
|
119
|
+
headers: {
|
|
120
|
+
Authorization: "test_token_type test_access_token",
|
|
121
|
+
"Content-Type": "application/json",
|
|
122
|
+
"User-Agent": "test_user_agent"
|
|
123
|
+
},
|
|
124
|
+
method: "post"
|
|
125
|
+
});
|
|
126
|
+
}));
|
|
127
|
+
it("Get estimate report", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
128
|
+
yield estimatesApi.getEstimateReport(projectId, reportUid);
|
|
129
|
+
sinon_1.default.assert.calledOnce(estimatesApiFetchStub);
|
|
130
|
+
sinon_1.default.assert.calledWithExactly(estimatesApiFetchStub, `https://test.com/estimates-api/v2/projects/${projectId}/reports/${reportUid}`, {
|
|
131
|
+
headers: {
|
|
132
|
+
Authorization: "test_token_type test_access_token",
|
|
133
|
+
"Content-Type": "application/json",
|
|
134
|
+
"User-Agent": "test_user_agent"
|
|
135
|
+
},
|
|
136
|
+
method: "get"
|
|
137
|
+
});
|
|
138
|
+
}));
|
|
139
|
+
it("Delete estimate report", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
140
|
+
yield estimatesApi.deleteEstimateReport(projectId, reportUid);
|
|
141
|
+
sinon_1.default.assert.calledOnce(estimatesApiFetchStub);
|
|
142
|
+
sinon_1.default.assert.calledWithExactly(estimatesApiFetchStub, `https://test.com/estimates-api/v2/projects/${projectId}/reports/${reportUid}`, {
|
|
143
|
+
headers: {
|
|
144
|
+
Authorization: "test_token_type test_access_token",
|
|
145
|
+
"Content-Type": "application/json",
|
|
146
|
+
"User-Agent": "test_user_agent"
|
|
147
|
+
},
|
|
148
|
+
method: "delete"
|
|
149
|
+
});
|
|
150
|
+
}));
|
|
151
|
+
it("Get estimate report status", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
152
|
+
yield estimatesApi.getEstimateReportStatus(projectId, reportUid);
|
|
153
|
+
sinon_1.default.assert.calledOnce(estimatesApiFetchStub);
|
|
154
|
+
sinon_1.default.assert.calledWithExactly(estimatesApiFetchStub, `https://test.com/estimates-api/v2/projects/${projectId}/reports/${reportUid}/status`, {
|
|
155
|
+
headers: {
|
|
156
|
+
Authorization: "test_token_type test_access_token",
|
|
157
|
+
"Content-Type": "application/json",
|
|
158
|
+
"User-Agent": "test_user_agent"
|
|
159
|
+
},
|
|
160
|
+
method: "get"
|
|
161
|
+
});
|
|
162
|
+
}));
|
|
163
|
+
it("Modify estimate report tags", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
164
|
+
const params = new modify_estimate_report_tags_parameters_1.ModifyEstimateReportTagsParameters().setTags(["AdminJob", "NEWTAG1"]);
|
|
165
|
+
yield estimatesApi.modifyEstimateReportTags(projectId, reportUid, params);
|
|
166
|
+
sinon_1.default.assert.calledOnce(estimatesApiFetchStub);
|
|
167
|
+
sinon_1.default.assert.calledWithExactly(estimatesApiFetchStub, `https://test.com/estimates-api/v2/projects/${projectId}/reports/${reportUid}/tags`, {
|
|
168
|
+
body: "{\"tags\":[\"AdminJob\",\"NEWTAG1\"]}",
|
|
169
|
+
headers: {
|
|
170
|
+
Authorization: "test_token_type test_access_token",
|
|
171
|
+
"Content-Type": "application/json",
|
|
172
|
+
"User-Agent": "test_user_agent"
|
|
173
|
+
},
|
|
174
|
+
method: "put"
|
|
175
|
+
});
|
|
176
|
+
}));
|
|
177
|
+
it("Download estimate report", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
178
|
+
yield estimatesApi.downloadEstimateReport(projectId, reportUid);
|
|
179
|
+
sinon_1.default.assert.calledOnce(estimatesApiFetchStub);
|
|
180
|
+
sinon_1.default.assert.calledWithExactly(estimatesApiFetchStub, `https://test.com/estimates-api/v2/projects/${projectId}/reports/${reportUid}/download?format=csv`, {
|
|
181
|
+
headers: {
|
|
182
|
+
Authorization: "test_token_type test_access_token",
|
|
183
|
+
"Content-Type": "application/json",
|
|
184
|
+
"User-Agent": "test_user_agent"
|
|
185
|
+
},
|
|
186
|
+
method: "get"
|
|
187
|
+
});
|
|
188
|
+
}));
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
//# sourceMappingURL=estimates.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"estimates.spec.js","sourceRoot":"","sources":["../../test/estimates.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,iCAA4D;AAC5D,kDAA+D;AAE/D,uHAAgH;AAChH,6HAAsH;AACtH,2HAAoH;AACpH,2FAAsF;AACtF,+GAAyG;AACzG,+EAA0E;AAE1E,QAAQ,CAAC,oCAAoC,EAAE,GAAG,EAAE;IAChD,MAAM,SAAS,GAAG,eAAe,CAAC;IAClC,MAAM,iBAAiB,GAAG,YAAY,CAAC;IACvC,MAAM,SAAS,GAAG,eAAe,CAAC;IAClC,IAAI,YAAY,CAAC;IACjB,IAAI,qBAAqB,CAAC;IAC1B,IAAI,kBAAkB,CAAC;IACvB,IAAI,oBAAoB,CAAC;IAEzB,UAAU,CAAC,GAAG,EAAE;QACZ,YAAY,GAAG,IAAI,6BAAqB,CACpC,kBAAkB,EAAE,eAAuC,EAAE,iBAAU,CAC1E,CAAC;QACF,qBAAqB,GAAG,eAAK,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QAC1D,kBAAkB,GAAG,eAAK,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,C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CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,182 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
16
|
+
const assert_1 = __importDefault(require("assert"));
|
|
17
|
+
const index_1 = require("../../api/builder/index");
|
|
18
|
+
const index_2 = require("../../api/estimates/index");
|
|
19
|
+
const index_3 = require("../../api/jobs/index");
|
|
20
|
+
const index_4 = require("../../api/projects/index");
|
|
21
|
+
const index_5 = require("../../api/files/index");
|
|
22
|
+
const create_job_parameters_1 = require("../../api/jobs/params/create-job-parameters");
|
|
23
|
+
const cancel_job_parameters_1 = require("../../api/jobs/params/cancel-job-parameters");
|
|
24
|
+
const add_file_parameters_1 = require("../../api/jobs/params/add-file-parameters");
|
|
25
|
+
const authorize_job_parameters_1 = require("../../api/jobs/params/authorize-job-parameters");
|
|
26
|
+
const upload_file_parameters_1 = require("../../api/files/params/upload-file-parameters");
|
|
27
|
+
const file_type_1 = require("../../api/files/params/file-type");
|
|
28
|
+
const generate_job_estimate_report_parameters_1 = require("../../api/estimates/params/generate-job-estimate-report-parameters");
|
|
29
|
+
const list_job_estimate_reports_parameters_1 = require("../../api/estimates/params/list-job-estimate-reports-parameters");
|
|
30
|
+
const modify_estimate_report_tags_parameters_1 = require("../../api/estimates/params/modify-estimate-report-tags-parameters");
|
|
31
|
+
const job_content_type_1 = require("../../api/estimates/params/job-content-type");
|
|
32
|
+
const estimate_report_status_1 = require("../../api/estimates/params/estimate-report-status");
|
|
33
|
+
const log_response_1 = require("./helpers/log-response");
|
|
34
|
+
dotenv_1.default.config();
|
|
35
|
+
const baseSmartlingApiUrl = process.env.SMARTLING_API_BASE_URL || "https://api.smartling.com";
|
|
36
|
+
const accountUid = process.env.SMARTLING_ACCOUNT_UID;
|
|
37
|
+
const userId = process.env.SMARTLING_USER_ID;
|
|
38
|
+
const userSecret = process.env.SMARTLING_USER_SECRET;
|
|
39
|
+
const hasCredentials = Boolean(accountUid && userId && userSecret);
|
|
40
|
+
const TERMINAL_REPORT_STATUSES = [
|
|
41
|
+
estimate_report_status_1.EstimateReportStatus.COMPLETED,
|
|
42
|
+
estimate_report_status_1.EstimateReportStatus.FAILED,
|
|
43
|
+
estimate_report_status_1.EstimateReportStatus.TIMEOUT,
|
|
44
|
+
estimate_report_status_1.EstimateReportStatus.CANCELED,
|
|
45
|
+
estimate_report_status_1.EstimateReportStatus.NOT_FOUND
|
|
46
|
+
];
|
|
47
|
+
function delay(milliseconds) {
|
|
48
|
+
return new Promise((resolve) => {
|
|
49
|
+
setTimeout(resolve, milliseconds);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
describe("SmartlingEstimatesApi integration tests.", function integrationSuite() {
|
|
53
|
+
this.timeout(180000);
|
|
54
|
+
let estimatesApi;
|
|
55
|
+
let jobsApi;
|
|
56
|
+
let projectsApi;
|
|
57
|
+
let filesApi;
|
|
58
|
+
let projectId;
|
|
59
|
+
let translationJobUid;
|
|
60
|
+
let fileUri;
|
|
61
|
+
let fuzzyReportUid;
|
|
62
|
+
let costReportUid;
|
|
63
|
+
before(function skipWithoutCredentials() {
|
|
64
|
+
if (!hasCredentials) {
|
|
65
|
+
console.log("Skipping Estimates integration tests: set SMARTLING_ACCOUNT_UID, SMARTLING_USER_ID, SMARTLING_USER_SECRET in .env");
|
|
66
|
+
this.skip();
|
|
67
|
+
}
|
|
68
|
+
estimatesApi = new index_1.SmartlingApiClientBuilder()
|
|
69
|
+
.setBaseSmartlingApiUrl(baseSmartlingApiUrl)
|
|
70
|
+
.authWithUserIdAndUserSecret(userId, userSecret)
|
|
71
|
+
.build(index_2.SmartlingEstimatesApi);
|
|
72
|
+
jobsApi = new index_1.SmartlingApiClientBuilder()
|
|
73
|
+
.setBaseSmartlingApiUrl(baseSmartlingApiUrl)
|
|
74
|
+
.authWithUserIdAndUserSecret(userId, userSecret)
|
|
75
|
+
.build(index_3.SmartlingJobsApi);
|
|
76
|
+
projectsApi = new index_1.SmartlingApiClientBuilder()
|
|
77
|
+
.setBaseSmartlingApiUrl(baseSmartlingApiUrl)
|
|
78
|
+
.authWithUserIdAndUserSecret(userId, userSecret)
|
|
79
|
+
.build(index_4.SmartlingProjectsApi);
|
|
80
|
+
filesApi = new index_1.SmartlingApiClientBuilder()
|
|
81
|
+
.setBaseSmartlingApiUrl(baseSmartlingApiUrl)
|
|
82
|
+
.authWithUserIdAndUserSecret(userId, userSecret)
|
|
83
|
+
.build(index_5.SmartlingFilesApi);
|
|
84
|
+
});
|
|
85
|
+
before(() => __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
const projects = yield projectsApi.listProjects(accountUid);
|
|
87
|
+
(0, log_response_1.logResponse)("listProjects", projects);
|
|
88
|
+
assert_1.default.ok(projects.items.length > 0, "Test account must have at least one project to run Estimates integration tests");
|
|
89
|
+
({ projectId } = projects.items[0]);
|
|
90
|
+
const project = yield projectsApi.getProjectDetails(projectId);
|
|
91
|
+
(0, log_response_1.logResponse)("getProjectDetails", project);
|
|
92
|
+
const targetLocaleIds = project.targetLocales.map((locale) => locale.localeId);
|
|
93
|
+
const job = yield jobsApi.createJob(projectId, new create_job_parameters_1.CreateJobParameters()
|
|
94
|
+
.setName(`api-sdk-nodejs estimates integration test ${Date.now()}`)
|
|
95
|
+
.setTargetLocaleIds(targetLocaleIds));
|
|
96
|
+
(0, log_response_1.logResponse)("createJob", job);
|
|
97
|
+
({ translationJobUid } = job);
|
|
98
|
+
fileUri = `api-sdk-nodejs-estimates-integration-test-${Date.now()}.json`;
|
|
99
|
+
const uploaded = yield filesApi.uploadFile(projectId, new upload_file_parameters_1.UploadFileParameters()
|
|
100
|
+
.setFileUri(fileUri)
|
|
101
|
+
.setFileType(file_type_1.FileType.JSON)
|
|
102
|
+
.setFileContent(JSON.stringify({
|
|
103
|
+
greeting: "Hello, welcome to our service!",
|
|
104
|
+
farewell: "Thank you for using our application, we hope to see you again soon.",
|
|
105
|
+
description: "This is a sample piece of content used to generate a translation estimate for integration testing purposes."
|
|
106
|
+
})));
|
|
107
|
+
(0, log_response_1.logResponse)("uploadFile", uploaded);
|
|
108
|
+
const addedFile = yield jobsApi.addFileToJob(projectId, translationJobUid, new add_file_parameters_1.AddFileParameters().setFileUri(fileUri).setTargetLocaleIds(targetLocaleIds));
|
|
109
|
+
(0, log_response_1.logResponse)("addFileToJob", addedFile);
|
|
110
|
+
const authorized = yield jobsApi.authorizeJob(projectId, translationJobUid, new authorize_job_parameters_1.AuthorizeJobParameters());
|
|
111
|
+
(0, log_response_1.logResponse)("authorizeJob", authorized);
|
|
112
|
+
}));
|
|
113
|
+
after(() => __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
if (fuzzyReportUid) {
|
|
115
|
+
yield estimatesApi.deleteEstimateReport(projectId, fuzzyReportUid);
|
|
116
|
+
}
|
|
117
|
+
if (costReportUid) {
|
|
118
|
+
yield estimatesApi.deleteEstimateReport(projectId, costReportUid);
|
|
119
|
+
}
|
|
120
|
+
if (translationJobUid) {
|
|
121
|
+
yield jobsApi.cancelJob(projectId, translationJobUid, new cancel_job_parameters_1.CancelJobParameters().setReason("api-sdk-nodejs integration test cleanup"));
|
|
122
|
+
yield jobsApi.deleteJob(projectId, translationJobUid);
|
|
123
|
+
}
|
|
124
|
+
if (fileUri) {
|
|
125
|
+
yield filesApi.deleteFile(projectId, fileUri);
|
|
126
|
+
}
|
|
127
|
+
}));
|
|
128
|
+
function waitForReportCompletion(reportUid) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
for (let attempt = 0; attempt < 30; attempt += 1) {
|
|
131
|
+
const status = yield estimatesApi.getEstimateReportStatus(projectId, reportUid);
|
|
132
|
+
(0, log_response_1.logResponse)("getEstimateReportStatus", status);
|
|
133
|
+
if (TERMINAL_REPORT_STATUSES.includes(status.reportStatus)) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
yield delay(3000);
|
|
137
|
+
}
|
|
138
|
+
throw new Error(`Timed out waiting for report ${reportUid} to complete`);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
it("generates, reads, lists, tags, downloads and deletes a fuzzy estimate report", () => __awaiter(this, void 0, void 0, function* () {
|
|
142
|
+
const generated = yield estimatesApi.generateJobFuzzyEstimateReport(projectId, translationJobUid, new generate_job_estimate_report_parameters_1.GenerateJobEstimateReportParameters().setContentType(job_content_type_1.JobContentType.ALL_CONTENT));
|
|
143
|
+
(0, log_response_1.logResponse)("generateJobFuzzyEstimateReport", generated);
|
|
144
|
+
assert_1.default.ok(generated.reportUid);
|
|
145
|
+
const { reportUid } = generated;
|
|
146
|
+
fuzzyReportUid = reportUid;
|
|
147
|
+
yield waitForReportCompletion(reportUid);
|
|
148
|
+
const report = yield estimatesApi.getEstimateReport(projectId, reportUid);
|
|
149
|
+
(0, log_response_1.logResponse)("getEstimateReport", report);
|
|
150
|
+
assert_1.default.equal(report.reportUid, reportUid);
|
|
151
|
+
assert_1.default.ok(report.totalStrings > 0, "expected non-zero totalStrings now the job has real content");
|
|
152
|
+
const list = yield estimatesApi.getJobFuzzyEstimateReports(projectId, translationJobUid, new list_job_estimate_reports_parameters_1.ListJobEstimateReportsParameters().setLimit(10).setOffset(0));
|
|
153
|
+
(0, log_response_1.logResponse)("getJobFuzzyEstimateReports", list);
|
|
154
|
+
assert_1.default.ok(list.items.some((item) => item.reportUid === reportUid));
|
|
155
|
+
const tagged = yield estimatesApi.modifyEstimateReportTags(projectId, reportUid, new modify_estimate_report_tags_parameters_1.ModifyEstimateReportTagsParameters().setTags(["api-sdk-nodejs-integration"]));
|
|
156
|
+
(0, log_response_1.logResponse)("modifyEstimateReportTags", tagged);
|
|
157
|
+
assert_1.default.deepEqual(tagged.tags, ["api-sdk-nodejs-integration"]);
|
|
158
|
+
const downloaded = yield estimatesApi.downloadEstimateReport(projectId, reportUid);
|
|
159
|
+
(0, log_response_1.logResponse)("downloadEstimateReport", `<${downloaded.byteLength} bytes>`);
|
|
160
|
+
assert_1.default.ok(downloaded.byteLength > 0);
|
|
161
|
+
yield estimatesApi.deleteEstimateReport(projectId, reportUid);
|
|
162
|
+
fuzzyReportUid = undefined;
|
|
163
|
+
}));
|
|
164
|
+
it("generates and reads a cost estimate report", () => __awaiter(this, void 0, void 0, function* () {
|
|
165
|
+
const generated = yield estimatesApi.generateJobCostEstimateReport(projectId, translationJobUid, new generate_job_estimate_report_parameters_1.GenerateJobEstimateReportParameters().setContentType(job_content_type_1.JobContentType.ALL_CONTENT));
|
|
166
|
+
(0, log_response_1.logResponse)("generateJobCostEstimateReport", generated);
|
|
167
|
+
assert_1.default.ok(generated.reportUid);
|
|
168
|
+
const { reportUid } = generated;
|
|
169
|
+
costReportUid = reportUid;
|
|
170
|
+
yield waitForReportCompletion(reportUid);
|
|
171
|
+
const report = yield estimatesApi.getEstimateReport(projectId, reportUid);
|
|
172
|
+
(0, log_response_1.logResponse)("getEstimateReport (cost)", report);
|
|
173
|
+
assert_1.default.equal(report.reportUid, reportUid);
|
|
174
|
+
assert_1.default.ok(report.totalStrings > 0, "expected non-zero totalStrings now the job has real content");
|
|
175
|
+
const list = yield estimatesApi.getJobCostEstimateReports(projectId, translationJobUid, new list_job_estimate_reports_parameters_1.ListJobEstimateReportsParameters().setLimit(10).setOffset(0));
|
|
176
|
+
(0, log_response_1.logResponse)("getJobCostEstimateReports", list);
|
|
177
|
+
assert_1.default.ok(list.items.some((item) => item.reportUid === reportUid));
|
|
178
|
+
yield estimatesApi.deleteEstimateReport(projectId, reportUid);
|
|
179
|
+
costReportUid = undefined;
|
|
180
|
+
}));
|
|
181
|
+
});
|
|
182
|
+
//# sourceMappingURL=estimates.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"estimates.spec.js","sourceRoot":"","sources":["../../../test/integration/estimates.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,oDAA4B;AAC5B,oDAA4B;AAC5B,mDAAoE;AACpE,qDAAkE;AAClE,gDAAwD;AACxD,oDAAgE;AAChE,iDAA0D;AAC1D,uFAAkF;AAClF,uFAAkF;AAClF,mFAA8E;AAC9E,6FAAwF;AACxF,0FAAqF;AACrF,gEAA4D;AAC5D,gIAAyH;AACzH,0HAAmH;AACnH,8HAAuH;AACvH,kFAA6E;AAC7E,8FAAyF;AACzF,yDAAqD;AAErD,gBAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,2BAA2B,CAAC;AAC9F,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,qBAA+B,CAAC;AAC/D,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,iBAA2B,CAAC;AACvD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,qBAA+B,CAAC;AAC/D,MAAM,cAAc,GAAG,OAAO,CAAC,UAAU,IAAI,MAAM,IAAI,UAAU,CAAC,CAAC;AAEnE,MAAM,wBAAwB,GAAG;IAC7B,6CAAoB,CAAC,SAAS;IAC9B,6CAAoB,CAAC,MAAM;IA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,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.logResponse = void 0;
|
|
4
|
-
const logResponsesEnabled = process.env.SMARTLING_LOG_RESPONSES === "true";
|
|
5
4
|
function logResponse(label, response) {
|
|
6
|
-
if (
|
|
5
|
+
if (process.env.SMARTLING_LOG_RESPONSES !== "true") {
|
|
7
6
|
return;
|
|
8
7
|
}
|
|
9
8
|
console.log(`\n--- ${label} ---\n${JSON.stringify(response, null, 2)}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-response.js","sourceRoot":"","sources":["../../../../test/integration/helpers/log-response.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"log-response.js","sourceRoot":"","sources":["../../../../test/integration/helpers/log-response.ts"],"names":[],"mappings":";;;AAAA,SAAgB,WAAW,CAAC,KAAa,EAAE,QAAiB;IAKxD,IAAI,OAAO,CAAC,GAAG,CAAC,uBAAuB,KAAK,MAAM,EAAE;QAChD,OAAO;KACV;IAGD,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AAC5E,CAAC;AAXD,kCAWC"}
|
package/index.ts
CHANGED
|
@@ -290,3 +290,24 @@ export * from "./api/translation-memory/dto/tm-dto";
|
|
|
290
290
|
export * from "./api/translation-memory/dto/user-dto";
|
|
291
291
|
export * from "./api/translation-memory/dto/tm-locale-dto";
|
|
292
292
|
export * from "./api/translation-memory/dto/locale-summary-dto";
|
|
293
|
+
export * from "./api/estimates/index";
|
|
294
|
+
export * from "./api/estimates/params/estimate-report-type";
|
|
295
|
+
export * from "./api/estimates/params/estimate-report-status";
|
|
296
|
+
export * from "./api/estimates/params/estimate-report-content-coverage";
|
|
297
|
+
export * from "./api/estimates/params/job-content-type";
|
|
298
|
+
export * from "./api/estimates/params/fuzzy-match-type-code";
|
|
299
|
+
export * from "./api/estimates/params/list-job-estimate-reports-parameters";
|
|
300
|
+
export * from "./api/estimates/params/generate-job-estimate-report-parameters";
|
|
301
|
+
export * from "./api/estimates/params/modify-estimate-report-tags-parameters";
|
|
302
|
+
export * from "./api/estimates/dto/estimate-report-dto";
|
|
303
|
+
export * from "./api/estimates/dto/generated-estimate-report-dto";
|
|
304
|
+
export * from "./api/estimates/dto/estimate-report-status-dto";
|
|
305
|
+
export * from "./api/estimates/dto/estimate-report-tags-dto";
|
|
306
|
+
export * from "./api/estimates/dto/price-information-dto";
|
|
307
|
+
export * from "./api/estimates/dto/effective-rates-range-dto";
|
|
308
|
+
export * from "./api/estimates/dto/fuzzy-match-tier-dto";
|
|
309
|
+
export * from "./api/estimates/dto/workflow-step-estimate-dto";
|
|
310
|
+
export * from "./api/estimates/dto/workflow-estimate-dto";
|
|
311
|
+
export * from "./api/estimates/dto/locale-estimate-dto";
|
|
312
|
+
export * from "./api/estimates/dto/locale-workflow-pair-dto";
|
|
313
|
+
export * from "./api/estimates/dto/locale-workflow-step-pair-dto";
|