smartling-api-sdk-nodejs 2.24.7 → 2.26.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/.eslintrc +1 -0
- package/.scannerwork/report-task.txt +2 -2
- package/api/job-batches/params/list-batches-parameters.ts +0 -1
- package/api/reports/dto/report-response.ts +6 -0
- package/api/reports/dto/step-types.ts +5 -0
- package/api/reports/dto/word-count-dto.ts +26 -0
- package/api/reports/index.ts +40 -0
- package/api/reports/params/date-formatter.ts +5 -0
- package/api/reports/params/word-count-parameters.ts +64 -0
- package/built/api/reports/dto/report-response.d.ts +5 -0
- package/built/api/reports/dto/report-response.js +3 -0
- package/built/api/reports/dto/report-response.js.map +1 -0
- package/built/api/reports/dto/step-types.d.ts +4 -0
- package/built/api/reports/dto/step-types.js +3 -0
- package/built/api/reports/dto/step-types.js.map +1 -0
- package/built/api/reports/dto/word-count-dto.d.ts +25 -0
- package/built/api/reports/dto/word-count-dto.js +3 -0
- package/built/api/reports/dto/word-count-dto.js.map +1 -0
- package/built/api/reports/index.d.ts +13 -0
- package/built/api/reports/index.js +37 -0
- package/built/api/reports/index.js.map +1 -0
- package/built/api/reports/params/date-formatter.d.ts +2 -0
- package/built/api/reports/params/date-formatter.js +8 -0
- package/built/api/reports/params/date-formatter.js.map +1 -0
- package/built/api/reports/params/word-count-parameters.d.ts +15 -0
- package/built/api/reports/params/word-count-parameters.js +57 -0
- package/built/api/reports/params/word-count-parameters.js.map +1 -0
- package/built/index.d.ts +5 -0
- package/built/index.js +5 -0
- package/built/index.js.map +1 -1
- package/built/package.json +2 -2
- package/index.ts +5 -0
- package/package.json +2 -2
- package/test/files.spec.ts +0 -1
- package/test/jobs.spec.ts +0 -1
- package/test/locales.spec.ts +4 -2
- package/test/mt.spec.ts +2 -1
- package/test/published-files.spec.ts +2 -1
- package/test/report-api.spec.ts +201 -0
- package/test/stream-to-string.ts +2 -2
- package/test/strings.spec.ts +13 -7
package/.eslintrc
CHANGED
|
@@ -2,5 +2,5 @@ projectKey=smartling-api-sdk-nodejs
|
|
|
2
2
|
serverUrl=https://sonar-next.connectors.stg.smartling.net
|
|
3
3
|
serverVersion=8.6.1.40680
|
|
4
4
|
dashboardUrl=https://sonar-next.connectors.stg.smartling.net/dashboard?id=smartling-api-sdk-nodejs
|
|
5
|
-
ceTaskId=
|
|
6
|
-
ceTaskUrl=https://sonar-next.connectors.stg.smartling.net/api/ce/task?id=
|
|
5
|
+
ceTaskId=AZnj7zHG5pumWNxcJ_G9
|
|
6
|
+
ceTaskUrl=https://sonar-next.connectors.stg.smartling.net/api/ce/task?id=AZnj7zHG5pumWNxcJ_G9
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
interface WordCountDto {
|
|
2
|
+
accountUid: string;
|
|
3
|
+
accountName: string;
|
|
4
|
+
projectId: string;
|
|
5
|
+
projectName: string;
|
|
6
|
+
targetLocaleId: string;
|
|
7
|
+
targetLocale: string;
|
|
8
|
+
jobUid: string;
|
|
9
|
+
jobName: string;
|
|
10
|
+
jobReferenceNumber: string;
|
|
11
|
+
jobNumber: string;
|
|
12
|
+
translationResourceUid: string;
|
|
13
|
+
translationResourceName: string;
|
|
14
|
+
agencyUid: string;
|
|
15
|
+
agencyName: string;
|
|
16
|
+
workflowStepType: string;
|
|
17
|
+
workflowStepUid: string;
|
|
18
|
+
workflowStepName: string;
|
|
19
|
+
fuzzyProfileName: string;
|
|
20
|
+
fuzzyTier: string;
|
|
21
|
+
wordCount: number;
|
|
22
|
+
characterCount: number;
|
|
23
|
+
weightedWordCount: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { WordCountDto };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { WordCountParameters } from "./params/word-count-parameters";
|
|
2
|
+
import { WordCountDto } from "./dto/word-count-dto";
|
|
3
|
+
import { ReportResponse } from "./dto/report-response";
|
|
4
|
+
import { StepTypeDto } from "./dto/step-types";
|
|
5
|
+
import { SmartlingBaseApi } from "../base";
|
|
6
|
+
import { AccessTokenProvider } from "../auth/access-token-provider";
|
|
7
|
+
import { Logger } from "../logger";
|
|
8
|
+
|
|
9
|
+
export class SmartlingReportServiceApi extends SmartlingBaseApi {
|
|
10
|
+
constructor(smartlingApiBaseUrl: string, authApi: AccessTokenProvider, logger: Logger) {
|
|
11
|
+
super(logger);
|
|
12
|
+
|
|
13
|
+
this.authApi = authApi;
|
|
14
|
+
this.entrypoint = `${smartlingApiBaseUrl}/reports-api/v3`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async getWorkflowStepTypes(): Promise<ReportResponse<StepTypeDto>> {
|
|
18
|
+
return await this.makeRequest(
|
|
19
|
+
"GET",
|
|
20
|
+
`${this.entrypoint}/word-count/dictionary/step-types`
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async getWordsCountReport(params: WordCountParameters): Promise<ReportResponse<WordCountDto>> {
|
|
25
|
+
return await this.makeRequest(
|
|
26
|
+
"GET",
|
|
27
|
+
`${this.entrypoint}/word-count`,
|
|
28
|
+
params.export()
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async getWordsCountReportCsv(params: WordCountParameters): Promise<string> {
|
|
33
|
+
return await this.makeRequest(
|
|
34
|
+
"GET",
|
|
35
|
+
`${this.entrypoint}/word-count/csv`,
|
|
36
|
+
params.export(),
|
|
37
|
+
true
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { formatDate } from "./date-formatter";
|
|
2
|
+
import { BaseParameters } from "../../parameters";
|
|
3
|
+
|
|
4
|
+
export class WordCountParameters extends BaseParameters {
|
|
5
|
+
public setStartDate(startDate: Date): WordCountParameters {
|
|
6
|
+
this.set("startDate", formatDate(startDate));
|
|
7
|
+
return this;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public setEndDate(endDate: Date): WordCountParameters {
|
|
11
|
+
this.set("endDate", formatDate(endDate));
|
|
12
|
+
return this;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public setAccountUid(accountUid: string): WordCountParameters {
|
|
16
|
+
this.set("accountUid", accountUid);
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public setProjectIds(projectIds: Array<string>): WordCountParameters {
|
|
21
|
+
this.set("projectIds", projectIds);
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public setJobUids(jobUids: Array<string>): WordCountParameters {
|
|
26
|
+
this.set("jobUids", jobUids);
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public setAgencyUid(agencyUid: string): WordCountParameters {
|
|
31
|
+
this.set("agencyUid", agencyUid);
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public setUserUids(userUids: Array<string>): WordCountParameters {
|
|
36
|
+
this.set("userUids", userUids);
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public setTargetLocaleIds(targetLocaleIds: Array<string>): WordCountParameters {
|
|
41
|
+
this.set("targetLocaleIds", targetLocaleIds);
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public setWorkflowStepTypes(workflowStepTypes: Array<string>): WordCountParameters {
|
|
46
|
+
this.set("workflowStepTypes", workflowStepTypes);
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public setFields(fields: string): WordCountParameters {
|
|
51
|
+
this.set("fields", fields);
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public setLimit(limit: number): WordCountParameters {
|
|
56
|
+
this.set("limit", limit);
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public setOffset(offset: number): WordCountParameters {
|
|
61
|
+
this.set("offset", offset);
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report-response.js","sourceRoot":"","sources":["../../../../api/reports/dto/report-response.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-types.js","sourceRoot":"","sources":["../../../../api/reports/dto/step-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
interface WordCountDto {
|
|
2
|
+
accountUid: string;
|
|
3
|
+
accountName: string;
|
|
4
|
+
projectId: string;
|
|
5
|
+
projectName: string;
|
|
6
|
+
targetLocaleId: string;
|
|
7
|
+
targetLocale: string;
|
|
8
|
+
jobUid: string;
|
|
9
|
+
jobName: string;
|
|
10
|
+
jobReferenceNumber: string;
|
|
11
|
+
jobNumber: string;
|
|
12
|
+
translationResourceUid: string;
|
|
13
|
+
translationResourceName: string;
|
|
14
|
+
agencyUid: string;
|
|
15
|
+
agencyName: string;
|
|
16
|
+
workflowStepType: string;
|
|
17
|
+
workflowStepUid: string;
|
|
18
|
+
workflowStepName: string;
|
|
19
|
+
fuzzyProfileName: string;
|
|
20
|
+
fuzzyTier: string;
|
|
21
|
+
wordCount: number;
|
|
22
|
+
characterCount: number;
|
|
23
|
+
weightedWordCount: number;
|
|
24
|
+
}
|
|
25
|
+
export { WordCountDto };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"word-count-dto.js","sourceRoot":"","sources":["../../../../api/reports/dto/word-count-dto.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { WordCountParameters } from "./params/word-count-parameters";
|
|
2
|
+
import { WordCountDto } from "./dto/word-count-dto";
|
|
3
|
+
import { ReportResponse } from "./dto/report-response";
|
|
4
|
+
import { StepTypeDto } from "./dto/step-types";
|
|
5
|
+
import { SmartlingBaseApi } from "../base";
|
|
6
|
+
import { AccessTokenProvider } from "../auth/access-token-provider";
|
|
7
|
+
import { Logger } from "../logger";
|
|
8
|
+
export declare class SmartlingReportServiceApi extends SmartlingBaseApi {
|
|
9
|
+
constructor(smartlingApiBaseUrl: string, authApi: AccessTokenProvider, logger: Logger);
|
|
10
|
+
getWorkflowStepTypes(): Promise<ReportResponse<StepTypeDto>>;
|
|
11
|
+
getWordsCountReport(params: WordCountParameters): Promise<ReportResponse<WordCountDto>>;
|
|
12
|
+
getWordsCountReportCsv(params: WordCountParameters): Promise<string>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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.SmartlingReportServiceApi = void 0;
|
|
13
|
+
const base_1 = require("../base");
|
|
14
|
+
class SmartlingReportServiceApi extends base_1.SmartlingBaseApi {
|
|
15
|
+
constructor(smartlingApiBaseUrl, authApi, logger) {
|
|
16
|
+
super(logger);
|
|
17
|
+
this.authApi = authApi;
|
|
18
|
+
this.entrypoint = `${smartlingApiBaseUrl}/reports-api/v3`;
|
|
19
|
+
}
|
|
20
|
+
getWorkflowStepTypes() {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
return yield this.makeRequest("GET", `${this.entrypoint}/word-count/dictionary/step-types`);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
getWordsCountReport(params) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
return yield this.makeRequest("GET", `${this.entrypoint}/word-count`, params.export());
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
getWordsCountReportCsv(params) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
return yield this.makeRequest("GET", `${this.entrypoint}/word-count/csv`, params.export(), true);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.SmartlingReportServiceApi = SmartlingReportServiceApi;
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../api/reports/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,kCAA2C;AAI3C,MAAa,yBAA0B,SAAQ,uBAAgB;IAC3D,YAAY,mBAA2B,EAAE,OAA4B,EAAE,MAAc;QACjF,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,GAAG,mBAAmB,iBAAiB,CAAC;IAC9D,CAAC;IAEK,oBAAoB;;YACtB,OAAO,MAAM,IAAI,CAAC,WAAW,CACzB,KAAK,EACL,GAAG,IAAI,CAAC,UAAU,mCAAmC,CACxD,CAAC;QACN,CAAC;KAAA;IAEK,mBAAmB,CAAC,MAA2B;;YACjD,OAAO,MAAM,IAAI,CAAC,WAAW,CACzB,KAAK,EACL,GAAG,IAAI,CAAC,UAAU,aAAa,EAC/B,MAAM,CAAC,MAAM,EAAE,CAClB,CAAC;QACN,CAAC;KAAA;IAEK,sBAAsB,CAAC,MAA2B;;YACpD,OAAO,MAAM,IAAI,CAAC,WAAW,CACzB,KAAK,EACL,GAAG,IAAI,CAAC,UAAU,iBAAiB,EACnC,MAAM,CAAC,MAAM,EAAE,EACf,IAAI,CACP,CAAC;QACN,CAAC;KAAA;CACJ;AA/BD,8DA+BC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatDate = void 0;
|
|
4
|
+
function formatDate(date) {
|
|
5
|
+
return date.toISOString().split("T")[0];
|
|
6
|
+
}
|
|
7
|
+
exports.formatDate = formatDate;
|
|
8
|
+
//# sourceMappingURL=date-formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-formatter.js","sourceRoot":"","sources":["../../../../api/reports/params/date-formatter.ts"],"names":[],"mappings":";;;AAAA,SAAS,UAAU,CAAC,IAAU;IAC1B,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5C,CAAC;AAEQ,gCAAU"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseParameters } from "../../parameters";
|
|
2
|
+
export declare class WordCountParameters extends BaseParameters {
|
|
3
|
+
setStartDate(startDate: Date): WordCountParameters;
|
|
4
|
+
setEndDate(endDate: Date): WordCountParameters;
|
|
5
|
+
setAccountUid(accountUid: string): WordCountParameters;
|
|
6
|
+
setProjectIds(projectIds: Array<string>): WordCountParameters;
|
|
7
|
+
setJobUids(jobUids: Array<string>): WordCountParameters;
|
|
8
|
+
setAgencyUid(agencyUid: string): WordCountParameters;
|
|
9
|
+
setUserUids(userUids: Array<string>): WordCountParameters;
|
|
10
|
+
setTargetLocaleIds(targetLocaleIds: Array<string>): WordCountParameters;
|
|
11
|
+
setWorkflowStepTypes(workflowStepTypes: Array<string>): WordCountParameters;
|
|
12
|
+
setFields(fields: string): WordCountParameters;
|
|
13
|
+
setLimit(limit: number): WordCountParameters;
|
|
14
|
+
setOffset(offset: number): WordCountParameters;
|
|
15
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WordCountParameters = void 0;
|
|
4
|
+
const date_formatter_1 = require("./date-formatter");
|
|
5
|
+
const parameters_1 = require("../../parameters");
|
|
6
|
+
class WordCountParameters extends parameters_1.BaseParameters {
|
|
7
|
+
setStartDate(startDate) {
|
|
8
|
+
this.set("startDate", (0, date_formatter_1.formatDate)(startDate));
|
|
9
|
+
return this;
|
|
10
|
+
}
|
|
11
|
+
setEndDate(endDate) {
|
|
12
|
+
this.set("endDate", (0, date_formatter_1.formatDate)(endDate));
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
setAccountUid(accountUid) {
|
|
16
|
+
this.set("accountUid", accountUid);
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
setProjectIds(projectIds) {
|
|
20
|
+
this.set("projectIds", projectIds);
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
setJobUids(jobUids) {
|
|
24
|
+
this.set("jobUids", jobUids);
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
setAgencyUid(agencyUid) {
|
|
28
|
+
this.set("agencyUid", agencyUid);
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
setUserUids(userUids) {
|
|
32
|
+
this.set("userUids", userUids);
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
setTargetLocaleIds(targetLocaleIds) {
|
|
36
|
+
this.set("targetLocaleIds", targetLocaleIds);
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
setWorkflowStepTypes(workflowStepTypes) {
|
|
40
|
+
this.set("workflowStepTypes", workflowStepTypes);
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
setFields(fields) {
|
|
44
|
+
this.set("fields", fields);
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
setLimit(limit) {
|
|
48
|
+
this.set("limit", limit);
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
setOffset(offset) {
|
|
52
|
+
this.set("offset", offset);
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.WordCountParameters = WordCountParameters;
|
|
57
|
+
//# sourceMappingURL=word-count-parameters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"word-count-parameters.js","sourceRoot":"","sources":["../../../../api/reports/params/word-count-parameters.ts"],"names":[],"mappings":";;;AAAA,qDAA8C;AAC9C,iDAAkD;AAElD,MAAa,mBAAoB,SAAQ,2BAAc;IAC5C,YAAY,CAAC,SAAe;QAC/B,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,IAAA,2BAAU,EAAC,SAAS,CAAC,CAAC,CAAC;QAC7C,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,UAAU,CAAC,OAAa;QAC3B,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,IAAA,2BAAU,EAAC,OAAO,CAAC,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,aAAa,CAAC,UAAkB;QACnC,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,aAAa,CAAC,UAAyB;QAC1C,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,UAAU,CAAC,OAAsB;QACpC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,YAAY,CAAC,SAAiB;QACjC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,WAAW,CAAC,QAAuB;QACtC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC/B,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,kBAAkB,CAAC,eAA8B;QACpD,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,eAAe,CAAC,CAAC;QAC7C,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,oBAAoB,CAAC,iBAAgC;QACxD,IAAI,CAAC,GAAG,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,SAAS,CAAC,MAAc;QAC3B,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,QAAQ,CAAC,KAAa;QACzB,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,SAAS,CAAC,MAAc;QAC3B,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AA5DD,kDA4DC"}
|
package/built/index.d.ts
CHANGED
|
@@ -161,4 +161,9 @@ export * from "./api/mt/index";
|
|
|
161
161
|
export * from "./api/mt/params/smartling-mt-parameters";
|
|
162
162
|
export * from "./api/mt/params/source-text-item";
|
|
163
163
|
export * from "./api/mt/dto/translation-text-item-dto";
|
|
164
|
+
export * from "./api/reports/index";
|
|
165
|
+
export * from "./api/reports/dto/report-response";
|
|
166
|
+
export * from "./api/reports/dto/word-count-dto";
|
|
167
|
+
export * from "./api/reports/params/word-count-parameters";
|
|
168
|
+
export * from "./api/reports/params/date-formatter";
|
|
164
169
|
export * from "./api/webhooks";
|
package/built/index.js
CHANGED
|
@@ -177,5 +177,10 @@ __exportStar(require("./api/mt/index"), exports);
|
|
|
177
177
|
__exportStar(require("./api/mt/params/smartling-mt-parameters"), exports);
|
|
178
178
|
__exportStar(require("./api/mt/params/source-text-item"), exports);
|
|
179
179
|
__exportStar(require("./api/mt/dto/translation-text-item-dto"), exports);
|
|
180
|
+
__exportStar(require("./api/reports/index"), exports);
|
|
181
|
+
__exportStar(require("./api/reports/dto/report-response"), exports);
|
|
182
|
+
__exportStar(require("./api/reports/dto/word-count-dto"), exports);
|
|
183
|
+
__exportStar(require("./api/reports/params/word-count-parameters"), exports);
|
|
184
|
+
__exportStar(require("./api/reports/params/date-formatter"), exports);
|
|
180
185
|
__exportStar(require("./api/webhooks"), exports);
|
|
181
186
|
//# sourceMappingURL=index.js.map
|
package/built/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,kEAAgD;AAChD,0EAAwD;AACxD,mEAAiD;AACjD,mDAAiC;AACjC,qEAAmD;AACnD,sDAAoC;AACpC,sDAAoC;AACpC,wEAAsD;AACtD,6EAA2D;AAC3D,gEAA8C;AAC9C,4EAA0D;AAC1D,uEAAqD;AACrD,0FAAwE;AACxE,oEAAkD;AAClD,iFAA+D;AAC/D,kFAAgE;AAChE,uEAAqD;AACrD,sEAAoD;AACpD,wDAAsC;AACtC,gEAA8C;AAC9C,wFAAsE;AACtE,qFAAmE;AACnE,4FAA0E;AAC1E,+FAA6E;AAC7E,2FAAyE;AACzE,oEAAkD;AAClD,oFAAkE;AAClE,qFAAmE;AACnE,uFAAqE;AACrE,4FAA0E;AAC1E,2EAAyD;AACzD,uEAAqD;AACrD,8EAA4D;AAC5D,4FAA0E;AAC1E,qFAAmE;AACnE,oDAAkC;AAClC,8EAA4D;AAC5D,6EAA2D;AAC3D,oEAAkD;AAClD,+DAA6C;AAC7C,4EAA0D;AAC1D,kFAAgE;AAChE,kFAAgE;AAChE,+EAA6D;AAC7D,oEAAkD;AAClD,yDAAuC;AACvC,oEAAkD;AAClD,2EAAyD;AACzD,sEAAoD;AACpD,mEAAiD;AACjD,uFAAqE;AACrE,oFAAkE;AAClE,iFAA+D;AAC/D,uEAAqD;AACrD,yEAA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/D,8EAA4D;AAC5D,mDAAiC;AACjC,yDAAuC;AACvC,oEAAkD;AAClD,iEAA+C;AAC/C,iFAA+D;AAC/D,iFAA+D;AAC/D,kFAAgE;AAChE,iFAA+D;AAC/D,mFAAiE;AACjE,wFAAsE;AACtE,4FAA0E;AAC1E,+CAA6B;AAC7B,wEAAsD;AACtD,+FAA6E;AAC7E,6EAA2D;AAC3D,gEAA8C;AAC9C,2EAAyD;AACzD,yEAAuD;AACvD,8DAA4C;AAC5C,mEAAiD;AACjD,8EAA4D;AAC5D,sDAAoC;AACpC,iDAA+B;AAC/B,0EAAwD;AACxD,mEAAiD;AACjD,yEAAuD;AACvD,sDAAoC;AACpC,oEAAkD;AAClD,mEAAiD;AACjD,6EAA2D;AAC3D,sEAAoD;AACpD,iDAA+B"}
|
package/built/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smartling-api-sdk-nodejs",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.26.0",
|
|
4
4
|
"description": "Package for Smartling API",
|
|
5
5
|
"main": "built/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"ansi-regex": "^5.0.1",
|
|
46
46
|
"babel-eslint": "^10.1.0",
|
|
47
47
|
"eslint": "^7.31.0",
|
|
48
|
-
"eslint-config-airbnb": "^
|
|
48
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
49
49
|
"eslint-plugin-flowtype": "^2.41.0",
|
|
50
50
|
"eslint-plugin-fp": "^2.3.0",
|
|
51
51
|
"eslint-plugin-import": "^2.8.0",
|
package/index.ts
CHANGED
|
@@ -161,4 +161,9 @@ export * from "./api/mt/index";
|
|
|
161
161
|
export * from "./api/mt/params/smartling-mt-parameters";
|
|
162
162
|
export * from "./api/mt/params/source-text-item";
|
|
163
163
|
export * from "./api/mt/dto/translation-text-item-dto";
|
|
164
|
+
export * from "./api/reports/index";
|
|
165
|
+
export * from "./api/reports/dto/report-response";
|
|
166
|
+
export * from "./api/reports/dto/word-count-dto";
|
|
167
|
+
export * from "./api/reports/params/word-count-parameters";
|
|
168
|
+
export * from "./api/reports/params/date-formatter";
|
|
164
169
|
export * from "./api/webhooks";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smartling-api-sdk-nodejs",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.26.0",
|
|
4
4
|
"description": "Package for Smartling API",
|
|
5
5
|
"main": "built/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"ansi-regex": "^5.0.1",
|
|
46
46
|
"babel-eslint": "^10.1.0",
|
|
47
47
|
"eslint": "^7.31.0",
|
|
48
|
-
"eslint-config-airbnb": "^
|
|
48
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
49
49
|
"eslint-plugin-flowtype": "^2.41.0",
|
|
50
50
|
"eslint-plugin-fp": "^2.3.0",
|
|
51
51
|
"eslint-plugin-import": "^2.8.0",
|
package/test/files.spec.ts
CHANGED
|
@@ -217,7 +217,6 @@ describe("SmartlingFilesApi class tests.", () => {
|
|
|
217
217
|
params = new DownloadFileAllTranslationsParameters();
|
|
218
218
|
});
|
|
219
219
|
|
|
220
|
-
|
|
221
220
|
it("Supports all parameters of single file download", async () => {
|
|
222
221
|
params
|
|
223
222
|
.setRetrievalType(RetrievalType.PUBLISHED)
|
package/test/jobs.spec.ts
CHANGED
package/test/locales.spec.ts
CHANGED
|
@@ -34,7 +34,8 @@ describe("SmartlingLocalesApi class tests.", () => {
|
|
|
34
34
|
sinon.assert.calledOnce(localesApiFetchStub);
|
|
35
35
|
sinon.assert.calledWithExactly(
|
|
36
36
|
localesApiFetchStub,
|
|
37
|
-
"https://test.com/locales-api/v2/dictionary/locales",
|
|
37
|
+
"https://test.com/locales-api/v2/dictionary/locales",
|
|
38
|
+
{
|
|
38
39
|
headers: {
|
|
39
40
|
Authorization: "test_token_type test_access_token",
|
|
40
41
|
"Content-Type": "application/json",
|
|
@@ -55,7 +56,8 @@ describe("SmartlingLocalesApi class tests.", () => {
|
|
|
55
56
|
sinon.assert.calledOnce(localesApiFetchStub);
|
|
56
57
|
sinon.assert.calledWithExactly(
|
|
57
58
|
localesApiFetchStub,
|
|
58
|
-
"https://test.com/locales-api/v2/dictionary/locales?localeIds=fr-FR&localeIds=de-DE&supportedOnly=true",
|
|
59
|
+
"https://test.com/locales-api/v2/dictionary/locales?localeIds=fr-FR&localeIds=de-DE&supportedOnly=true",
|
|
60
|
+
{
|
|
59
61
|
headers: {
|
|
60
62
|
Authorization: "test_token_type test_access_token",
|
|
61
63
|
"Content-Type": "application/json",
|
package/test/mt.spec.ts
CHANGED
|
@@ -45,7 +45,8 @@ describe("SmartlinMachineTranslationsApi class tests.", () => {
|
|
|
45
45
|
sinon.assert.calledOnce(mtApiFetchStub);
|
|
46
46
|
sinon.assert.calledWithExactly(
|
|
47
47
|
mtApiFetchStub,
|
|
48
|
-
`https://test.com/mt-router-api/v2/accounts/${accountUid}/smartling-mt`,
|
|
48
|
+
`https://test.com/mt-router-api/v2/accounts/${accountUid}/smartling-mt`,
|
|
49
|
+
{
|
|
49
50
|
headers: {
|
|
50
51
|
Authorization: "test_token_type test_access_token",
|
|
51
52
|
"Content-Type": "application/json",
|
|
@@ -43,7 +43,8 @@ describe("SmartlingPublishedFilesApi class tests.", () => {
|
|
|
43
43
|
sinon.assert.calledOnce(publishedFilesApiFetchStub);
|
|
44
44
|
sinon.assert.calledWithExactly(
|
|
45
45
|
publishedFilesApiFetchStub,
|
|
46
|
-
"https://test.com/published-files-api/v2/projects/test_project/files/list/recently-published?publishedAfter=2020-09-24T00%3A00%3A00Z&fileUris%5B%5D=test%3A_1.xml&fileUris%5B%5D=test%2Ffile%26_2.xml&localeIds%5B%5D=fr&localeIds%5B%5D=de&offset=0&limit=100",
|
|
46
|
+
"https://test.com/published-files-api/v2/projects/test_project/files/list/recently-published?publishedAfter=2020-09-24T00%3A00%3A00Z&fileUris%5B%5D=test%3A_1.xml&fileUris%5B%5D=test%2Ffile%26_2.xml&localeIds%5B%5D=fr&localeIds%5B%5D=de&offset=0&limit=100",
|
|
47
|
+
{
|
|
47
48
|
headers: {
|
|
48
49
|
Authorization: "test_token_type test_access_token",
|
|
49
50
|
"Content-Type": "application/json",
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import sinon from "sinon";
|
|
2
|
+
import assert from "assert";
|
|
3
|
+
import { SmartlingReportServiceApi } from "../api/reports";
|
|
4
|
+
import { WordCountParameters } from "../api/reports/params/word-count-parameters";
|
|
5
|
+
import { loggerMock, authMock, responseMock } from "./mock";
|
|
6
|
+
import { SmartlingAuthApi } from "../api/auth";
|
|
7
|
+
|
|
8
|
+
describe("SmartlingReportServiceApi class tests.", () => {
|
|
9
|
+
let reportServiceApi: SmartlingReportServiceApi;
|
|
10
|
+
let reportServiceApiFetchStub: sinon.SinonStub;
|
|
11
|
+
let reportServiceApiUaStub: sinon.SinonStub;
|
|
12
|
+
let responseMockTextStub: sinon.SinonStub;
|
|
13
|
+
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
reportServiceApi = new SmartlingReportServiceApi("https://test.com", authMock as unknown as SmartlingAuthApi, loggerMock);
|
|
16
|
+
|
|
17
|
+
reportServiceApiFetchStub = sinon.stub(reportServiceApi, "fetch");
|
|
18
|
+
reportServiceApiUaStub = sinon.stub(reportServiceApi, "ua");
|
|
19
|
+
responseMockTextStub = sinon.stub(responseMock, "text");
|
|
20
|
+
|
|
21
|
+
reportServiceApiUaStub.returns("test_user_agent");
|
|
22
|
+
reportServiceApiFetchStub.returns(responseMock);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
afterEach(() => {
|
|
26
|
+
reportServiceApiFetchStub.restore();
|
|
27
|
+
responseMockTextStub.restore();
|
|
28
|
+
reportServiceApiUaStub.restore();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
function smartlingResponse(body: unknown) {
|
|
32
|
+
return {
|
|
33
|
+
response: {
|
|
34
|
+
code: "SUCCESS",
|
|
35
|
+
data: body
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
describe("getWorkflowStepTypes", () => {
|
|
41
|
+
it("Should call correct endpoint and return workflow step types", async () => {
|
|
42
|
+
const payload = {
|
|
43
|
+
resultsTruncated: false,
|
|
44
|
+
items: [
|
|
45
|
+
{ workflowStepType: "TRANSLATION" },
|
|
46
|
+
{ workflowStepType: "REVIEW" },
|
|
47
|
+
{ workflowStepType: "APPROVAL" }
|
|
48
|
+
]
|
|
49
|
+
};
|
|
50
|
+
const mockResponse = smartlingResponse(payload);
|
|
51
|
+
|
|
52
|
+
responseMockTextStub.returns(JSON.stringify(mockResponse));
|
|
53
|
+
|
|
54
|
+
const result = await reportServiceApi.getWorkflowStepTypes();
|
|
55
|
+
|
|
56
|
+
sinon.assert.calledOnce(reportServiceApiFetchStub);
|
|
57
|
+
const callArgs = reportServiceApiFetchStub.getCall(0).args;
|
|
58
|
+
|
|
59
|
+
assert.strictEqual(callArgs[0], "https://test.com/reports-api/v3/word-count/dictionary/step-types");
|
|
60
|
+
assert.strictEqual(callArgs[1].method, "GET");
|
|
61
|
+
assert.deepStrictEqual(callArgs[1].headers, {
|
|
62
|
+
Authorization: "test_token_type test_access_token",
|
|
63
|
+
"Content-Type": "application/json",
|
|
64
|
+
"User-Agent": "test_user_agent"
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
assert.deepStrictEqual(result, payload);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe("getWordsCountReport", () => {
|
|
72
|
+
it("Should call correct endpoint with parameters", async () => {
|
|
73
|
+
const payload = {
|
|
74
|
+
resultsTruncated: false,
|
|
75
|
+
items: [
|
|
76
|
+
{
|
|
77
|
+
accountUid: "account123",
|
|
78
|
+
accountName: "Test Account",
|
|
79
|
+
projectUid: "project123",
|
|
80
|
+
projectName: "Test Project",
|
|
81
|
+
jobUid: "job123",
|
|
82
|
+
jobName: "Test Job",
|
|
83
|
+
translationResourceUid: "resource123",
|
|
84
|
+
translationResourceName: "Test Resource",
|
|
85
|
+
agencyUid: "agency123",
|
|
86
|
+
agencyName: "Test Agency",
|
|
87
|
+
targetLocale: "es-ES",
|
|
88
|
+
workflowStepType: "TRANSLATION",
|
|
89
|
+
fuzzyProfileName: "Standard",
|
|
90
|
+
fuzzyTier: "100%",
|
|
91
|
+
wordCount: 1000,
|
|
92
|
+
weightedWordCount: 950
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
};
|
|
96
|
+
const mockResponse = smartlingResponse(payload);
|
|
97
|
+
|
|
98
|
+
responseMockTextStub.returns(JSON.stringify(mockResponse));
|
|
99
|
+
|
|
100
|
+
const startDate = new Date("2024-01-01T00:00:00Z");
|
|
101
|
+
const endDate = new Date("2024-12-31T23:59:59Z");
|
|
102
|
+
|
|
103
|
+
const params = new WordCountParameters()
|
|
104
|
+
.setStartDate(startDate)
|
|
105
|
+
.setEndDate(endDate)
|
|
106
|
+
.setAccountUid("account123")
|
|
107
|
+
.setProjectIds(["project123"])
|
|
108
|
+
.setUserUids(["user123"])
|
|
109
|
+
.setAgencyUid("agency123")
|
|
110
|
+
.setJobUids(["job123"])
|
|
111
|
+
.setTargetLocaleIds(["fr-FR"])
|
|
112
|
+
.setWorkflowStepTypes(["TRANSLATION", "REVIEW"])
|
|
113
|
+
.setFields("includeTranslationResource,includeJob,includeFuzzyMatchProfile")
|
|
114
|
+
.setLimit(100)
|
|
115
|
+
.setOffset(0);
|
|
116
|
+
|
|
117
|
+
const result = await reportServiceApi.getWordsCountReport(params);
|
|
118
|
+
|
|
119
|
+
sinon.assert.calledOnce(reportServiceApiFetchStub);
|
|
120
|
+
const callArgs = reportServiceApiFetchStub.getCall(0).args;
|
|
121
|
+
|
|
122
|
+
assert.strictEqual(callArgs[0], "https://test.com/reports-api/v3/word-count"
|
|
123
|
+
+ "?startDate=2024-01-01"
|
|
124
|
+
+ "&endDate=2024-12-31"
|
|
125
|
+
+ "&accountUid=account123"
|
|
126
|
+
+ "&projectIds=project123"
|
|
127
|
+
+ "&userUids=user123"
|
|
128
|
+
+ "&agencyUid=agency123"
|
|
129
|
+
+ "&jobUids=job123"
|
|
130
|
+
+ "&targetLocaleIds=fr-FR"
|
|
131
|
+
+ "&workflowStepTypes=TRANSLATION"
|
|
132
|
+
+ "&workflowStepTypes=REVIEW"
|
|
133
|
+
+ "&fields=includeTranslationResource%2CincludeJob%2CincludeFuzzyMatchProfile"
|
|
134
|
+
+ "&limit=100"
|
|
135
|
+
+ "&offset=0");
|
|
136
|
+
assert.strictEqual(callArgs[1].method, "GET");
|
|
137
|
+
assert.deepStrictEqual(callArgs[1].headers, {
|
|
138
|
+
Authorization: "test_token_type test_access_token",
|
|
139
|
+
"Content-Type": "application/json",
|
|
140
|
+
"User-Agent": "test_user_agent"
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
assert.deepStrictEqual(result, payload);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe("getWordsCountReportCsv", () => {
|
|
148
|
+
it("Should call CSV endpoint and return CSV string", async () => {
|
|
149
|
+
const csvResponse = `projectId,projectName,targetLocaleId,jobUid,jobName,translationResourceName,workflowStepType,wordCount,characterCount
|
|
150
|
+
project123,Test Project,es-ES,job123,Test Job,Test Resource,TRANSLATION,1000,5000
|
|
151
|
+
project123,Test Project,fr-FR,job456,Another Job,Another Resource,REVIEW,500,2500`;
|
|
152
|
+
|
|
153
|
+
responseMockTextStub.returns(csvResponse);
|
|
154
|
+
|
|
155
|
+
const startDate = new Date("2024-01-01T00:00:00Z");
|
|
156
|
+
const endDate = new Date("2024-12-31T23:59:59Z");
|
|
157
|
+
|
|
158
|
+
const params = new WordCountParameters()
|
|
159
|
+
.setStartDate(startDate)
|
|
160
|
+
.setEndDate(endDate)
|
|
161
|
+
.setAccountUid("account123")
|
|
162
|
+
.setProjectIds(["project123"])
|
|
163
|
+
.setUserUids(["user123"])
|
|
164
|
+
.setAgencyUid("agency123")
|
|
165
|
+
.setJobUids(["job123"])
|
|
166
|
+
.setTargetLocaleIds(["fr-FR"])
|
|
167
|
+
.setWorkflowStepTypes(["TRANSLATION", "REVIEW"])
|
|
168
|
+
.setFields("projectId,projectName,targetLocaleId,jobUid,jobName,translationResourceName,workflowStepType,wordCount,characterCount")
|
|
169
|
+
.setLimit(100)
|
|
170
|
+
.setOffset(0);
|
|
171
|
+
|
|
172
|
+
const result = await reportServiceApi.getWordsCountReportCsv(params);
|
|
173
|
+
|
|
174
|
+
sinon.assert.calledOnce(reportServiceApiFetchStub);
|
|
175
|
+
const callArgs = reportServiceApiFetchStub.getCall(0).args;
|
|
176
|
+
|
|
177
|
+
assert.strictEqual(callArgs[0], "https://test.com/reports-api/v3/word-count/csv"
|
|
178
|
+
+ "?startDate=2024-01-01"
|
|
179
|
+
+ "&endDate=2024-12-31"
|
|
180
|
+
+ "&accountUid=account123"
|
|
181
|
+
+ "&projectIds=project123"
|
|
182
|
+
+ "&userUids=user123"
|
|
183
|
+
+ "&agencyUid=agency123"
|
|
184
|
+
+ "&jobUids=job123"
|
|
185
|
+
+ "&targetLocaleIds=fr-FR"
|
|
186
|
+
+ "&workflowStepTypes=TRANSLATION"
|
|
187
|
+
+ "&workflowStepTypes=REVIEW"
|
|
188
|
+
+ "&fields=projectId%2CprojectName%2CtargetLocaleId%2CjobUid%2CjobName%2CtranslationResourceName%2CworkflowStepType%2CwordCount%2CcharacterCount"
|
|
189
|
+
+ "&limit=100"
|
|
190
|
+
+ "&offset=0");
|
|
191
|
+
assert.strictEqual(callArgs[1].method, "GET");
|
|
192
|
+
assert.deepStrictEqual(callArgs[1].headers, {
|
|
193
|
+
Authorization: "test_token_type test_access_token",
|
|
194
|
+
"Content-Type": "application/json",
|
|
195
|
+
"User-Agent": "test_user_agent"
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
assert.strictEqual(result, csvResponse);
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
});
|
package/test/stream-to-string.ts
CHANGED
|
@@ -7,8 +7,8 @@ function streamToString(stream: Readable): Promise<string> {
|
|
|
7
7
|
|
|
8
8
|
return new Promise((resolve, reject) => {
|
|
9
9
|
// eslint-disable-next-line fp/no-mutating-methods
|
|
10
|
-
stream.on("data", chunk => chunks.push(Buffer.from(chunk)));
|
|
11
|
-
stream.on("error", err => reject(err));
|
|
10
|
+
stream.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
|
|
11
|
+
stream.on("error", (err) => reject(err));
|
|
12
12
|
stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")));
|
|
13
13
|
});
|
|
14
14
|
}
|
package/test/strings.spec.ts
CHANGED
|
@@ -14,7 +14,7 @@ describe("SmartlingStringsApi class tests.", () => {
|
|
|
14
14
|
const limit = 25;
|
|
15
15
|
const offset = 0;
|
|
16
16
|
const hashCodes = ["testStringHashCode1", "testStringHashCode2"];
|
|
17
|
-
const hashCodesParams = hashCodes.map(hashCode => `hashcodes=${hashCode}`).join("&");
|
|
17
|
+
const hashCodesParams = hashCodes.map((hashCode) => `hashcodes=${hashCode}`).join("&");
|
|
18
18
|
const expectedFetchSourceStringsParams = `${hashCodesParams}&fileUri=${fileUri}&limit=${limit}&offset=${offset}`;
|
|
19
19
|
let stringsApi: SmartlingStringsApi;
|
|
20
20
|
let fetchSourceStringsParameters: FetchSourceStringsParameters;
|
|
@@ -77,7 +77,8 @@ describe("SmartlingStringsApi class tests.", () => {
|
|
|
77
77
|
sinon.assert.calledOnce(stringsServiceApiFetchStub);
|
|
78
78
|
sinon.assert.calledWithExactly(
|
|
79
79
|
stringsServiceApiFetchStub,
|
|
80
|
-
`https://test.com/strings-api/v2/projects/${projectId}`,
|
|
80
|
+
`https://test.com/strings-api/v2/projects/${projectId}`,
|
|
81
|
+
{
|
|
81
82
|
headers: {
|
|
82
83
|
Authorization: "test_token_type test_access_token",
|
|
83
84
|
"Content-Type": "application/json",
|
|
@@ -99,7 +100,8 @@ describe("SmartlingStringsApi class tests.", () => {
|
|
|
99
100
|
sinon.assert.calledOnce(stringsServiceApiFetchStub);
|
|
100
101
|
sinon.assert.calledWithExactly(
|
|
101
102
|
stringsServiceApiFetchStub,
|
|
102
|
-
`https://test.com/strings-api/v2/projects/${projectId}`,
|
|
103
|
+
`https://test.com/strings-api/v2/projects/${projectId}`,
|
|
104
|
+
{
|
|
103
105
|
headers: {
|
|
104
106
|
Authorization: "test_token_type test_access_token",
|
|
105
107
|
"Content-Type": "application/json",
|
|
@@ -130,7 +132,8 @@ describe("SmartlingStringsApi class tests.", () => {
|
|
|
130
132
|
sinon.assert.calledOnce(stringsServiceApiFetchStub);
|
|
131
133
|
sinon.assert.calledWithExactly(
|
|
132
134
|
stringsServiceApiFetchStub,
|
|
133
|
-
`https://test.com/strings-api/v2/projects/${projectId}`,
|
|
135
|
+
`https://test.com/strings-api/v2/projects/${projectId}`,
|
|
136
|
+
{
|
|
134
137
|
headers: {
|
|
135
138
|
Authorization: "test_token_type test_access_token",
|
|
136
139
|
"Content-Type": "application/json",
|
|
@@ -157,7 +160,8 @@ describe("SmartlingStringsApi class tests.", () => {
|
|
|
157
160
|
sinon.assert.calledOnce(stringsServiceApiFetchStub);
|
|
158
161
|
sinon.assert.calledWithExactly(
|
|
159
162
|
stringsServiceApiFetchStub,
|
|
160
|
-
`https://test.com/strings-api/v2/projects/${projectId}`,
|
|
163
|
+
`https://test.com/strings-api/v2/projects/${projectId}`,
|
|
164
|
+
{
|
|
161
165
|
headers: {
|
|
162
166
|
Authorization: "test_token_type test_access_token",
|
|
163
167
|
"Content-Type": "application/json",
|
|
@@ -187,7 +191,8 @@ describe("SmartlingStringsApi class tests.", () => {
|
|
|
187
191
|
sinon.assert.calledOnce(stringsServiceApiFetchStub);
|
|
188
192
|
sinon.assert.calledWithExactly(
|
|
189
193
|
stringsServiceApiFetchStub,
|
|
190
|
-
`https://test.com/strings-api/v2/projects/${projectId}`,
|
|
194
|
+
`https://test.com/strings-api/v2/projects/${projectId}`,
|
|
195
|
+
{
|
|
191
196
|
headers: {
|
|
192
197
|
Authorization: "test_token_type test_access_token",
|
|
193
198
|
"Content-Type": "application/json",
|
|
@@ -232,7 +237,8 @@ describe("SmartlingStringsApi class tests.", () => {
|
|
|
232
237
|
sinon.assert.calledOnce(stringsServiceApiFetchStub);
|
|
233
238
|
sinon.assert.calledWithExactly(
|
|
234
239
|
stringsServiceApiFetchStub,
|
|
235
|
-
`https://test.com/strings-api/v2/projects/${projectId}/processes/${testProcessUid}`,
|
|
240
|
+
`https://test.com/strings-api/v2/projects/${projectId}/processes/${testProcessUid}`,
|
|
241
|
+
{
|
|
236
242
|
headers: {
|
|
237
243
|
Authorization: "test_token_type test_access_token",
|
|
238
244
|
"Content-Type": "application/json",
|