smartling-api-sdk-nodejs 2.24.6 → 2.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/.eslintrc +1 -0
  2. package/.scannerwork/report-task.txt +2 -2
  3. package/api/job-batches/params/list-batches-parameters.ts +0 -1
  4. package/api/reports/dto/report-response.ts +6 -0
  5. package/api/reports/dto/step-types.ts +5 -0
  6. package/api/reports/dto/word-count-dto.ts +26 -0
  7. package/api/reports/index.ts +31 -0
  8. package/api/reports/params/date-formatter.ts +5 -0
  9. package/api/reports/params/word-count-parameters.ts +64 -0
  10. package/api/strings/index.ts +1 -1
  11. package/built/api/reports/dto/report-response.d.ts +5 -0
  12. package/built/api/reports/dto/report-response.js +3 -0
  13. package/built/api/reports/dto/report-response.js.map +1 -0
  14. package/built/api/reports/dto/step-types.d.ts +4 -0
  15. package/built/api/reports/dto/step-types.js +3 -0
  16. package/built/api/reports/dto/step-types.js.map +1 -0
  17. package/built/api/reports/dto/word-count-dto.d.ts +25 -0
  18. package/built/api/reports/dto/word-count-dto.js +3 -0
  19. package/built/api/reports/dto/word-count-dto.js.map +1 -0
  20. package/built/api/reports/index.d.ts +12 -0
  21. package/built/api/reports/index.js +32 -0
  22. package/built/api/reports/index.js.map +1 -0
  23. package/built/api/reports/params/date-formatter.d.ts +2 -0
  24. package/built/api/reports/params/date-formatter.js +8 -0
  25. package/built/api/reports/params/date-formatter.js.map +1 -0
  26. package/built/api/reports/params/word-count-parameters.d.ts +15 -0
  27. package/built/api/reports/params/word-count-parameters.js +57 -0
  28. package/built/api/reports/params/word-count-parameters.js.map +1 -0
  29. package/built/api/strings/index.d.ts +1 -1
  30. package/built/package.json +2 -2
  31. package/package.json +2 -2
  32. package/test/files.spec.ts +0 -1
  33. package/test/jobs.spec.ts +0 -1
  34. package/test/locales.spec.ts +4 -2
  35. package/test/mt.spec.ts +2 -1
  36. package/test/published-files.spec.ts +2 -1
  37. package/test/report-api.spec.ts +146 -0
  38. package/test/stream-to-string.ts +2 -2
  39. package/test/strings.spec.ts +13 -7
package/.eslintrc CHANGED
@@ -26,6 +26,7 @@
26
26
  }
27
27
  },
28
28
  rules: {
29
+ "lines-between-class-members": "off",
29
30
  "no-return-await": "off",
30
31
  "import/extensions": "off",
31
32
  "no-shadow": "off",
@@ -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=AZk-_ZM1JYLo-yRQ8Fjz
6
- ceTaskUrl=https://sonar-next.connectors.stg.smartling.net/api/ce/task?id=AZk-_ZM1JYLo-yRQ8Fjz
5
+ ceTaskId=AZnNaTBHjzZQmJO_qatF
6
+ ceTaskUrl=https://sonar-next.connectors.stg.smartling.net/api/ce/task?id=AZnNaTBHjzZQmJO_qatF
@@ -38,4 +38,3 @@ export class ListBatchesParameters extends BaseParameters {
38
38
  return this;
39
39
  }
40
40
  }
41
-
@@ -0,0 +1,6 @@
1
+ interface ReportResponse<T> {
2
+ resultsTruncated: boolean;
3
+ items: Array<T>;
4
+ }
5
+
6
+ export { ReportResponse };
@@ -0,0 +1,5 @@
1
+ interface StepTypeDto {
2
+ workflowStepType: string
3
+ }
4
+
5
+ export { StepTypeDto };
@@ -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,31 @@
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
+ }
@@ -0,0 +1,5 @@
1
+ function formatDate(date: Date): string {
2
+ return date.toISOString().split("T")[0];
3
+ }
4
+
5
+ export { formatDate };
@@ -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
+ }
@@ -39,7 +39,7 @@ export class SmartlingStringsApi extends SmartlingBaseApi {
39
39
  async getCreateStringStatus(
40
40
  projectUid: string,
41
41
  processUid: string
42
- ): Promise<SmartlingListResponse<ProcessStatusDto>> {
42
+ ): Promise<ProcessStatusDto> {
43
43
  return await this.makeRequest(
44
44
  "get",
45
45
  `${this.entrypoint}/${projectUid}/processes/${processUid}`
@@ -0,0 +1,5 @@
1
+ interface ReportResponse<T> {
2
+ resultsTruncated: boolean;
3
+ items: Array<T>;
4
+ }
5
+ export { ReportResponse };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=report-response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report-response.js","sourceRoot":"","sources":["../../../../api/reports/dto/report-response.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ interface StepTypeDto {
2
+ workflowStepType: string;
3
+ }
4
+ export { StepTypeDto };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=step-types.js.map
@@ -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,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=word-count-dto.js.map
@@ -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,12 @@
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
+ }
@@ -0,0 +1,32 @@
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
+ }
31
+ exports.SmartlingReportServiceApi = SmartlingReportServiceApi;
32
+ //# 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;CACJ;AAtBD,8DAsBC"}
@@ -0,0 +1,2 @@
1
+ declare function formatDate(date: Date): string;
2
+ export { formatDate };
@@ -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"}
@@ -11,5 +11,5 @@ export declare class SmartlingStringsApi extends SmartlingBaseApi {
11
11
  constructor(smartlingApiBaseUrl: string, authApi: AccessTokenProvider, logger: Logger);
12
12
  getSourceStrings(projectId: string, params: FetchSourceStringsParameters): Promise<SmartlingListResponse<SourceStringDto>>;
13
13
  createStrings(projectUid: string, params: CreateStringsParameters): Promise<CreateStringsResponseDto>;
14
- getCreateStringStatus(projectUid: string, processUid: string): Promise<SmartlingListResponse<ProcessStatusDto>>;
14
+ getCreateStringStatus(projectUid: string, processUid: string): Promise<ProcessStatusDto>;
15
15
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smartling-api-sdk-nodejs",
3
- "version": "2.24.6",
3
+ "version": "2.25.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": "^16.1.0",
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smartling-api-sdk-nodejs",
3
- "version": "2.24.6",
3
+ "version": "2.25.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": "^16.1.0",
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",
@@ -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
@@ -59,7 +59,6 @@ describe("SmartlingJobsAPI class tests.", () => {
59
59
  .setTargetLocaleIds(["pt-PT"])
60
60
  .setCallbackUrl("testCallbackUrl");
61
61
 
62
-
63
62
  await jobApi.createJob(projectId, params);
64
63
 
65
64
  sinon.assert.calledOnce(jobServiceApiFetchStub);
@@ -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,146 @@
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
+ });
@@ -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
  }
@@ -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",