smartling-api-sdk-nodejs 2.24.4 → 2.24.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.scannerwork/report-task.txt +2 -2
- package/api/strings/dto/create-strings-response-dto.ts +10 -0
- package/api/strings/dto/created-string-item-dto.ts +9 -0
- package/api/strings/dto/process-state-enum.ts +7 -0
- package/api/strings/dto/process-statistics-dto.ts +8 -0
- package/api/strings/dto/process-status-dto.ts +12 -0
- package/api/strings/index.ts +24 -0
- package/api/strings/params/create-strings-parameters.ts +36 -0
- package/api/strings/params/string-item-parameters.ts +43 -0
- package/built/api/strings/dto/create-strings-response-dto.d.ts +8 -0
- package/built/api/strings/dto/create-strings-response-dto.js +3 -0
- package/built/api/strings/dto/create-strings-response-dto.js.map +1 -0
- package/built/api/strings/dto/created-string-item-dto.d.ts +8 -0
- package/built/api/strings/dto/created-string-item-dto.js +3 -0
- package/built/api/strings/dto/created-string-item-dto.js.map +1 -0
- package/built/api/strings/dto/process-state-enum.d.ts +6 -0
- package/built/api/strings/dto/process-state-enum.js +11 -0
- package/built/api/strings/dto/process-state-enum.js.map +1 -0
- package/built/api/strings/dto/process-statistics-dto.d.ts +7 -0
- package/built/api/strings/dto/process-statistics-dto.js +3 -0
- package/built/api/strings/dto/process-statistics-dto.js.map +1 -0
- package/built/api/strings/dto/process-status-dto.d.ts +10 -0
- package/built/api/strings/dto/process-status-dto.js +6 -0
- package/built/api/strings/dto/process-status-dto.js.map +1 -0
- package/built/api/strings/index.d.ts +5 -0
- package/built/api/strings/index.js +10 -0
- package/built/api/strings/index.js.map +1 -1
- package/built/api/strings/params/create-strings-parameters.d.ts +9 -0
- package/built/api/strings/params/create-strings-parameters.js +35 -0
- package/built/api/strings/params/create-strings-parameters.js.map +1 -0
- package/built/api/strings/params/string-item-parameters.d.ts +16 -0
- package/built/api/strings/params/string-item-parameters.js +34 -0
- package/built/api/strings/params/string-item-parameters.js.map +1 -0
- package/built/index.d.ts +7 -0
- package/built/index.js +7 -0
- package/built/index.js.map +1 -1
- package/built/package.json +1 -1
- package/index.ts +7 -0
- package/package.json +1 -1
- package/test/strings.spec.ts +180 -0
|
@@ -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=AZk98cLrJYLo-yRQ8Fjl
|
|
6
|
+
ceTaskUrl=https://sonar-next.connectors.stg.smartling.net/api/ce/task?id=AZk98cLrJYLo-yRQ8Fjl
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ProcessStatisticsDto } from "./process-statistics-dto";
|
|
2
|
+
import { ProcessState } from "./process-state-enum";
|
|
3
|
+
|
|
4
|
+
interface ProcessStatusDto {
|
|
5
|
+
processUid: string;
|
|
6
|
+
processState: ProcessState;
|
|
7
|
+
createdDate: string;
|
|
8
|
+
modifiedDate: string;
|
|
9
|
+
processStatistics: ProcessStatisticsDto;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { ProcessStatusDto, ProcessState };
|
package/api/strings/index.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { SmartlingBaseApi } from "../base/index";
|
|
2
2
|
import { AccessTokenProvider } from "../auth/access-token-provider";
|
|
3
3
|
import { FetchSourceStringsParameters } from "./params/fetch-source-strings-parameters";
|
|
4
|
+
import { CreateStringsParameters } from "./params/create-strings-parameters";
|
|
4
5
|
import { SmartlingListResponse } from "../http/smartling-list-response";
|
|
5
6
|
import { SourceStringDto } from "./dto/source-string-dto";
|
|
7
|
+
import { CreateStringsResponseDto } from "./dto/create-strings-response-dto";
|
|
8
|
+
import { ProcessStatusDto } from "./dto/process-status-dto";
|
|
6
9
|
import { Logger } from "../logger";
|
|
7
10
|
|
|
8
11
|
export class SmartlingStringsApi extends SmartlingBaseApi {
|
|
@@ -21,4 +24,25 @@ export class SmartlingStringsApi extends SmartlingBaseApi {
|
|
|
21
24
|
params.export()
|
|
22
25
|
);
|
|
23
26
|
}
|
|
27
|
+
|
|
28
|
+
async createStrings(
|
|
29
|
+
projectUid: string,
|
|
30
|
+
params: CreateStringsParameters
|
|
31
|
+
): Promise<CreateStringsResponseDto> {
|
|
32
|
+
return await this.makeRequest(
|
|
33
|
+
"post",
|
|
34
|
+
`${this.entrypoint}/${projectUid}`,
|
|
35
|
+
JSON.stringify(params.export())
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async getCreateStringStatus(
|
|
40
|
+
projectUid: string,
|
|
41
|
+
processUid: string
|
|
42
|
+
): Promise<SmartlingListResponse<ProcessStatusDto>> {
|
|
43
|
+
return await this.makeRequest(
|
|
44
|
+
"get",
|
|
45
|
+
`${this.entrypoint}/${projectUid}/processes/${processUid}`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
24
48
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { BaseParameters } from "../../parameters/index";
|
|
2
|
+
import { StringItemParameters } from "./string-item-parameters";
|
|
3
|
+
|
|
4
|
+
export class CreateStringsParameters extends BaseParameters {
|
|
5
|
+
public setNamespace(namespace: string): CreateStringsParameters {
|
|
6
|
+
this.set("namespace", namespace);
|
|
7
|
+
return this;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public setPlaceholderFormat(placeholderFormat: string): CreateStringsParameters {
|
|
11
|
+
this.set("placeholderFormat", placeholderFormat);
|
|
12
|
+
return this;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public setPlaceholderFormatCustom(placeholderFormatCustom: string): CreateStringsParameters {
|
|
16
|
+
this.set("placeholderFormatCustom", placeholderFormatCustom);
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public setStrings(strings: StringItemParameters[]): CreateStringsParameters {
|
|
21
|
+
if (strings.length > 100) {
|
|
22
|
+
throw new Error("Maximum 100 strings can be posted in any given request");
|
|
23
|
+
}
|
|
24
|
+
this.set("strings", strings);
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public addString(stringItem: StringItemParameters): CreateStringsParameters {
|
|
29
|
+
const currentStrings: StringItemParameters[] = this.parameters.strings || [];
|
|
30
|
+
if (currentStrings.length >= 100) {
|
|
31
|
+
throw new Error("Maximum 100 strings can be posted in any given request");
|
|
32
|
+
}
|
|
33
|
+
this.set("strings", [...currentStrings, stringItem]);
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export class StringItemParameters {
|
|
2
|
+
private stringText: string;
|
|
3
|
+
private variant?: string;
|
|
4
|
+
private callbackUrl?: string;
|
|
5
|
+
private callbackMethod?: string;
|
|
6
|
+
private instruction?: string;
|
|
7
|
+
private format?: string;
|
|
8
|
+
private maxLength?: number;
|
|
9
|
+
|
|
10
|
+
constructor(stringText: string) {
|
|
11
|
+
this.stringText = stringText;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public setVariant(variant: string): StringItemParameters {
|
|
15
|
+
this.variant = variant;
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public setCallbackUrl(callbackUrl: string): StringItemParameters {
|
|
20
|
+
this.callbackUrl = callbackUrl;
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public setCallbackMethod(callbackMethod: string): StringItemParameters {
|
|
25
|
+
this.callbackMethod = callbackMethod;
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public setInstruction(instruction: string): StringItemParameters {
|
|
30
|
+
this.instruction = instruction;
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public setFormat(format: string): StringItemParameters {
|
|
35
|
+
this.format = format;
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public setMaxLength(maxLength: number): StringItemParameters {
|
|
40
|
+
this.maxLength = maxLength;
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-strings-response-dto.js","sourceRoot":"","sources":["../../../../api/strings/dto/create-strings-response-dto.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"created-string-item-dto.js","sourceRoot":"","sources":["../../../../api/strings/dto/created-string-item-dto.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProcessState = void 0;
|
|
4
|
+
var ProcessState;
|
|
5
|
+
(function (ProcessState) {
|
|
6
|
+
ProcessState["OPEN"] = "OPEN";
|
|
7
|
+
ProcessState["CLOSED"] = "CLOSED";
|
|
8
|
+
ProcessState["FAILED"] = "FAILED";
|
|
9
|
+
})(ProcessState || (ProcessState = {}));
|
|
10
|
+
exports.ProcessState = ProcessState;
|
|
11
|
+
//# sourceMappingURL=process-state-enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-state-enum.js","sourceRoot":"","sources":["../../../../api/strings/dto/process-state-enum.ts"],"names":[],"mappings":";;;AAAA,IAAK,YAIJ;AAJD,WAAK,YAAY;IACb,6BAAa,CAAA;IACb,iCAAiB,CAAA;IACjB,iCAAiB,CAAA;AACrB,CAAC,EAJI,YAAY,KAAZ,YAAY,QAIhB;AAEQ,oCAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-statistics-dto.js","sourceRoot":"","sources":["../../../../api/strings/dto/process-statistics-dto.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ProcessStatisticsDto } from "./process-statistics-dto";
|
|
2
|
+
import { ProcessState } from "./process-state-enum";
|
|
3
|
+
interface ProcessStatusDto {
|
|
4
|
+
processUid: string;
|
|
5
|
+
processState: ProcessState;
|
|
6
|
+
createdDate: string;
|
|
7
|
+
modifiedDate: string;
|
|
8
|
+
processStatistics: ProcessStatisticsDto;
|
|
9
|
+
}
|
|
10
|
+
export { ProcessStatusDto, ProcessState };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProcessState = void 0;
|
|
4
|
+
const process_state_enum_1 = require("./process-state-enum");
|
|
5
|
+
Object.defineProperty(exports, "ProcessState", { enumerable: true, get: function () { return process_state_enum_1.ProcessState; } });
|
|
6
|
+
//# sourceMappingURL=process-status-dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-status-dto.js","sourceRoot":"","sources":["../../../../api/strings/dto/process-status-dto.ts"],"names":[],"mappings":";;;AACA,6DAAoD;AAUzB,6FAVlB,iCAAY,OAUkB"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { SmartlingBaseApi } from "../base/index";
|
|
2
2
|
import { AccessTokenProvider } from "../auth/access-token-provider";
|
|
3
3
|
import { FetchSourceStringsParameters } from "./params/fetch-source-strings-parameters";
|
|
4
|
+
import { CreateStringsParameters } from "./params/create-strings-parameters";
|
|
4
5
|
import { SmartlingListResponse } from "../http/smartling-list-response";
|
|
5
6
|
import { SourceStringDto } from "./dto/source-string-dto";
|
|
7
|
+
import { CreateStringsResponseDto } from "./dto/create-strings-response-dto";
|
|
8
|
+
import { ProcessStatusDto } from "./dto/process-status-dto";
|
|
6
9
|
import { Logger } from "../logger";
|
|
7
10
|
export declare class SmartlingStringsApi extends SmartlingBaseApi {
|
|
8
11
|
constructor(smartlingApiBaseUrl: string, authApi: AccessTokenProvider, logger: Logger);
|
|
9
12
|
getSourceStrings(projectId: string, params: FetchSourceStringsParameters): Promise<SmartlingListResponse<SourceStringDto>>;
|
|
13
|
+
createStrings(projectUid: string, params: CreateStringsParameters): Promise<CreateStringsResponseDto>;
|
|
14
|
+
getCreateStringStatus(projectUid: string, processUid: string): Promise<SmartlingListResponse<ProcessStatusDto>>;
|
|
10
15
|
}
|
|
@@ -22,6 +22,16 @@ class SmartlingStringsApi extends index_1.SmartlingBaseApi {
|
|
|
22
22
|
return yield this.makeRequest("get", `${this.entrypoint}/${projectId}/source-strings`, params.export());
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
+
createStrings(projectUid, params) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
return yield this.makeRequest("post", `${this.entrypoint}/${projectUid}`, JSON.stringify(params.export()));
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
getCreateStringStatus(projectUid, processUid) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
return yield this.makeRequest("get", `${this.entrypoint}/${projectUid}/processes/${processUid}`);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
25
35
|
}
|
|
26
36
|
exports.SmartlingStringsApi = SmartlingStringsApi;
|
|
27
37
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../api/strings/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAiD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../api/strings/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAiD;AAUjD,MAAa,mBAAoB,SAAQ,wBAAgB;IACrD,YAAY,mBAA2B,EAAE,OAA4B,EAAE,MAAc;QACjF,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,GAAG,mBAAmB,0BAA0B,CAAC;IACvE,CAAC;IAEK,gBAAgB,CAClB,SAAiB,EAAE,MAAoC;;YAEvD,OAAO,MAAM,IAAI,CAAC,WAAW,CACzB,KAAK,EACL,GAAG,IAAI,CAAC,UAAU,IAAI,SAAS,iBAAiB,EAChD,MAAM,CAAC,MAAM,EAAE,CAClB,CAAC;QACN,CAAC;KAAA;IAEK,aAAa,CACf,UAAkB,EAClB,MAA+B;;YAE/B,OAAO,MAAM,IAAI,CAAC,WAAW,CACzB,MAAM,EACN,GAAG,IAAI,CAAC,UAAU,IAAI,UAAU,EAAE,EAClC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAClC,CAAC;QACN,CAAC;KAAA;IAEK,qBAAqB,CACvB,UAAkB,EAClB,UAAkB;;YAElB,OAAO,MAAM,IAAI,CAAC,WAAW,CACzB,KAAK,EACL,GAAG,IAAI,CAAC,UAAU,IAAI,UAAU,cAAc,UAAU,EAAE,CAC7D,CAAC;QACN,CAAC;KAAA;CACJ;AArCD,kDAqCC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseParameters } from "../../parameters/index";
|
|
2
|
+
import { StringItemParameters } from "./string-item-parameters";
|
|
3
|
+
export declare class CreateStringsParameters extends BaseParameters {
|
|
4
|
+
setNamespace(namespace: string): CreateStringsParameters;
|
|
5
|
+
setPlaceholderFormat(placeholderFormat: string): CreateStringsParameters;
|
|
6
|
+
setPlaceholderFormatCustom(placeholderFormatCustom: string): CreateStringsParameters;
|
|
7
|
+
setStrings(strings: StringItemParameters[]): CreateStringsParameters;
|
|
8
|
+
addString(stringItem: StringItemParameters): CreateStringsParameters;
|
|
9
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateStringsParameters = void 0;
|
|
4
|
+
const index_1 = require("../../parameters/index");
|
|
5
|
+
class CreateStringsParameters extends index_1.BaseParameters {
|
|
6
|
+
setNamespace(namespace) {
|
|
7
|
+
this.set("namespace", namespace);
|
|
8
|
+
return this;
|
|
9
|
+
}
|
|
10
|
+
setPlaceholderFormat(placeholderFormat) {
|
|
11
|
+
this.set("placeholderFormat", placeholderFormat);
|
|
12
|
+
return this;
|
|
13
|
+
}
|
|
14
|
+
setPlaceholderFormatCustom(placeholderFormatCustom) {
|
|
15
|
+
this.set("placeholderFormatCustom", placeholderFormatCustom);
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
setStrings(strings) {
|
|
19
|
+
if (strings.length > 100) {
|
|
20
|
+
throw new Error("Maximum 100 strings can be posted in any given request");
|
|
21
|
+
}
|
|
22
|
+
this.set("strings", strings);
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
addString(stringItem) {
|
|
26
|
+
const currentStrings = this.parameters.strings || [];
|
|
27
|
+
if (currentStrings.length >= 100) {
|
|
28
|
+
throw new Error("Maximum 100 strings can be posted in any given request");
|
|
29
|
+
}
|
|
30
|
+
this.set("strings", [...currentStrings, stringItem]);
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.CreateStringsParameters = CreateStringsParameters;
|
|
35
|
+
//# sourceMappingURL=create-strings-parameters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-strings-parameters.js","sourceRoot":"","sources":["../../../../api/strings/params/create-strings-parameters.ts"],"names":[],"mappings":";;;AAAA,kDAAwD;AAGxD,MAAa,uBAAwB,SAAQ,sBAAc;IAChD,YAAY,CAAC,SAAiB;QACjC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,oBAAoB,CAAC,iBAAyB;QACjD,IAAI,CAAC,GAAG,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,0BAA0B,CAAC,uBAA+B;QAC7D,IAAI,CAAC,GAAG,CAAC,yBAAyB,EAAE,uBAAuB,CAAC,CAAC;QAC7D,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,UAAU,CAAC,OAA+B;QAC7C,IAAI,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE;YACtB,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;SAC7E;QACD,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,SAAS,CAAC,UAAgC;QAC7C,MAAM,cAAc,GAA2B,IAAI,CAAC,UAAU,CAAC,OAAO,IAAI,EAAE,CAAC;QAC7E,IAAI,cAAc,CAAC,MAAM,IAAI,GAAG,EAAE;YAC9B,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;SAC7E;QACD,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,GAAG,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAhCD,0DAgCC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class StringItemParameters {
|
|
2
|
+
private stringText;
|
|
3
|
+
private variant?;
|
|
4
|
+
private callbackUrl?;
|
|
5
|
+
private callbackMethod?;
|
|
6
|
+
private instruction?;
|
|
7
|
+
private format?;
|
|
8
|
+
private maxLength?;
|
|
9
|
+
constructor(stringText: string);
|
|
10
|
+
setVariant(variant: string): StringItemParameters;
|
|
11
|
+
setCallbackUrl(callbackUrl: string): StringItemParameters;
|
|
12
|
+
setCallbackMethod(callbackMethod: string): StringItemParameters;
|
|
13
|
+
setInstruction(instruction: string): StringItemParameters;
|
|
14
|
+
setFormat(format: string): StringItemParameters;
|
|
15
|
+
setMaxLength(maxLength: number): StringItemParameters;
|
|
16
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StringItemParameters = void 0;
|
|
4
|
+
class StringItemParameters {
|
|
5
|
+
constructor(stringText) {
|
|
6
|
+
this.stringText = stringText;
|
|
7
|
+
}
|
|
8
|
+
setVariant(variant) {
|
|
9
|
+
this.variant = variant;
|
|
10
|
+
return this;
|
|
11
|
+
}
|
|
12
|
+
setCallbackUrl(callbackUrl) {
|
|
13
|
+
this.callbackUrl = callbackUrl;
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
setCallbackMethod(callbackMethod) {
|
|
17
|
+
this.callbackMethod = callbackMethod;
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
setInstruction(instruction) {
|
|
21
|
+
this.instruction = instruction;
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
setFormat(format) {
|
|
25
|
+
this.format = format;
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
setMaxLength(maxLength) {
|
|
29
|
+
this.maxLength = maxLength;
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.StringItemParameters = StringItemParameters;
|
|
34
|
+
//# sourceMappingURL=string-item-parameters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string-item-parameters.js","sourceRoot":"","sources":["../../../../api/strings/params/string-item-parameters.ts"],"names":[],"mappings":";;;AAAA,MAAa,oBAAoB;IAS7B,YAAY,UAAkB;QAC1B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAEM,UAAU,CAAC,OAAe;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,cAAc,CAAC,WAAmB;QACrC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,iBAAiB,CAAC,cAAsB;QAC3C,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,cAAc,CAAC,WAAmB;QACrC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,SAAS,CAAC,MAAc;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,YAAY,CAAC,SAAiB;QACjC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AA1CD,oDA0CC"}
|
package/built/index.d.ts
CHANGED
|
@@ -112,7 +112,14 @@ export * from "./api/published-files/params/recently-published-files-parameters"
|
|
|
112
112
|
export * from "./api/strings/index";
|
|
113
113
|
export * from "./api/strings/dto/source-string-dto";
|
|
114
114
|
export * from "./api/strings/dto/source-string-key-dto";
|
|
115
|
+
export * from "./api/strings/dto/create-strings-response-dto";
|
|
116
|
+
export * from "./api/strings/dto/created-string-item-dto";
|
|
117
|
+
export * from "./api/strings/dto/process-status-dto";
|
|
118
|
+
export * from "./api/strings/dto/process-state-enum";
|
|
119
|
+
export * from "./api/strings/dto/process-statistics-dto";
|
|
115
120
|
export * from "./api/strings/params/fetch-source-strings-parameters";
|
|
121
|
+
export * from "./api/strings/params/create-strings-parameters";
|
|
122
|
+
export * from "./api/strings/params/string-item-parameters";
|
|
116
123
|
export * from "./api/tags/index";
|
|
117
124
|
export * from "./api/tags/dto/tag-dto";
|
|
118
125
|
export * from "./api/tags/dto/project-id-tag-dto";
|
package/built/index.js
CHANGED
|
@@ -128,7 +128,14 @@ __exportStar(require("./api/published-files/params/recently-published-files-para
|
|
|
128
128
|
__exportStar(require("./api/strings/index"), exports);
|
|
129
129
|
__exportStar(require("./api/strings/dto/source-string-dto"), exports);
|
|
130
130
|
__exportStar(require("./api/strings/dto/source-string-key-dto"), exports);
|
|
131
|
+
__exportStar(require("./api/strings/dto/create-strings-response-dto"), exports);
|
|
132
|
+
__exportStar(require("./api/strings/dto/created-string-item-dto"), exports);
|
|
133
|
+
__exportStar(require("./api/strings/dto/process-status-dto"), exports);
|
|
134
|
+
__exportStar(require("./api/strings/dto/process-state-enum"), exports);
|
|
135
|
+
__exportStar(require("./api/strings/dto/process-statistics-dto"), exports);
|
|
131
136
|
__exportStar(require("./api/strings/params/fetch-source-strings-parameters"), exports);
|
|
137
|
+
__exportStar(require("./api/strings/params/create-strings-parameters"), exports);
|
|
138
|
+
__exportStar(require("./api/strings/params/string-item-parameters"), exports);
|
|
132
139
|
__exportStar(require("./api/tags/index"), exports);
|
|
133
140
|
__exportStar(require("./api/tags/dto/tag-dto"), exports);
|
|
134
141
|
__exportStar(require("./api/tags/dto/project-id-tag-dto"), exports);
|
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,qEAAmD;AACnD,0DAAwC;AACxC,kEAAgD;AAChD,uEAAqD;AACrD,yEAAuD;AACvD,yEAAuD;AACvD,4EAA0D;AAC1D,oFAAkE;AAClE,oFAAkE;AAClE,mFAAiE;AACjE,kFAAgE;AAChE,wFAAsE;AACtE,2FAAyE;AACzE,wFAAsE;AACtE,0FAAwE;AACxE,wEAAsD;AACtD,wEAAsD;AACtD,mFAAiE;AACjE,6EAA2D;AAC3D,mDAAiC;AACjC,8DAA4C;AAC5C,kFAAgE;AAChE,kEAAgD;AAChD,mEAAiD;AACjD,sEAAoD;AACpD,iEAA+C;AAC/C,yDAAuC;AACvC,iEAA+C;AAC/C,mFAAiE;AACjE,uFAAqE;AACrE,kEAAgD;AAChD,mEAAiD;AACjD,yEAAuD;AACvD,kEAAgD;AAChD,kFAAgE;AAChE,6EAA2D;AAC3D,oEAAkD;AAClD,0EAAwD;AACxD,6EAA2D;AAC3D,4EAA0D;AAC1D,+DAA6C;AAC7C,8EAA4D;AAC5D,yEAAuD;AACvD,2EAAyD;AACzD,uFAAqE;AACrE,0EAAwD;AACxD,yEAAuD;AACvD,2EAAyD;AACzD,0EAAwD;AACxD,yDAAuC;AACvC,yDAAuC;AACvC,uDAAqC;AACrC,iEAA+C;AAC/C,wFAAsE;AACtE,gEAA8C;AAC9C,iFAA+D;AAC/D,8DAA4C;AAC5C,+EAA6D;AAC7D,mGAAiF;AACjF,sDAAoC;AACpC,sEAAoD;AACpD,0EAAwD;AACxD,uFAAqE;AACrE,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,iDAA+B"}
|
|
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,qEAAmD;AACnD,0DAAwC;AACxC,kEAAgD;AAChD,uEAAqD;AACrD,yEAAuD;AACvD,yEAAuD;AACvD,4EAA0D;AAC1D,oFAAkE;AAClE,oFAAkE;AAClE,mFAAiE;AACjE,kFAAgE;AAChE,wFAAsE;AACtE,2FAAyE;AACzE,wFAAsE;AACtE,0FAAwE;AACxE,wEAAsD;AACtD,wEAAsD;AACtD,mFAAiE;AACjE,6EAA2D;AAC3D,mDAAiC;AACjC,8DAA4C;AAC5C,kFAAgE;AAChE,kEAAgD;AAChD,mEAAiD;AACjD,sEAAoD;AACpD,iEAA+C;AAC/C,yDAAuC;AACvC,iEAA+C;AAC/C,mFAAiE;AACjE,uFAAqE;AACrE,kEAAgD;AAChD,mEAAiD;AACjD,yEAAuD;AACvD,kEAAgD;AAChD,kFAAgE;AAChE,6EAA2D;AAC3D,oEAAkD;AAClD,0EAAwD;AACxD,6EAA2D;AAC3D,4EAA0D;AAC1D,+DAA6C;AAC7C,8EAA4D;AAC5D,yEAAuD;AACvD,2EAAyD;AACzD,uFAAqE;AACrE,0EAAwD;AACxD,yEAAuD;AACvD,2EAAyD;AACzD,0EAAwD;AACxD,yDAAuC;AACvC,yDAAuC;AACvC,uDAAqC;AACrC,iEAA+C;AAC/C,wFAAsE;AACtE,gEAA8C;AAC9C,iFAA+D;AAC/D,8DAA4C;AAC5C,+EAA6D;AAC7D,mGAAiF;AACjF,sDAAoC;AACpC,sEAAoD;AACpD,0EAAwD;AACxD,gFAA8D;AAC9D,4EAA0D;AAC1D,uEAAqD;AACrD,uEAAqD;AACrD,2EAAyD;AACzD,uFAAqE;AACrE,iFAA+D;AAC/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,iDAA+B"}
|
package/built/package.json
CHANGED
package/index.ts
CHANGED
|
@@ -112,7 +112,14 @@ export * from "./api/published-files/params/recently-published-files-parameters"
|
|
|
112
112
|
export * from "./api/strings/index";
|
|
113
113
|
export * from "./api/strings/dto/source-string-dto";
|
|
114
114
|
export * from "./api/strings/dto/source-string-key-dto";
|
|
115
|
+
export * from "./api/strings/dto/create-strings-response-dto";
|
|
116
|
+
export * from "./api/strings/dto/created-string-item-dto";
|
|
117
|
+
export * from "./api/strings/dto/process-status-dto";
|
|
118
|
+
export * from "./api/strings/dto/process-state-enum";
|
|
119
|
+
export * from "./api/strings/dto/process-statistics-dto";
|
|
115
120
|
export * from "./api/strings/params/fetch-source-strings-parameters";
|
|
121
|
+
export * from "./api/strings/params/create-strings-parameters";
|
|
122
|
+
export * from "./api/strings/params/string-item-parameters";
|
|
116
123
|
export * from "./api/tags/index";
|
|
117
124
|
export * from "./api/tags/dto/tag-dto";
|
|
118
125
|
export * from "./api/tags/dto/project-id-tag-dto";
|
package/package.json
CHANGED
package/test/strings.spec.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import sinon from "sinon";
|
|
2
|
+
import assert from "assert";
|
|
2
3
|
import { SmartlingStringsApi } from "../api/strings/index";
|
|
3
4
|
import { FetchSourceStringsParameters } from "../api/strings/params/fetch-source-strings-parameters";
|
|
5
|
+
import { CreateStringsParameters } from "../api/strings/params/create-strings-parameters";
|
|
6
|
+
import { StringItemParameters } from "../api/strings/params/string-item-parameters";
|
|
4
7
|
import { loggerMock, authMock, responseMock } from "./mock";
|
|
5
8
|
import { SmartlingAuthApi } from "../api/auth/index";
|
|
6
9
|
|
|
7
10
|
describe("SmartlingStringsApi class tests.", () => {
|
|
8
11
|
const projectId = "testProjectId";
|
|
12
|
+
const testProcessUid = "test-process-uid";
|
|
9
13
|
const fileUri = "testStringsFileUri";
|
|
10
14
|
const limit = 25;
|
|
11
15
|
const offset = 0;
|
|
@@ -17,6 +21,7 @@ describe("SmartlingStringsApi class tests.", () => {
|
|
|
17
21
|
let stringsServiceApiFetchStub;
|
|
18
22
|
let stringsServiceApiUaStub;
|
|
19
23
|
let responseMockJsonStub;
|
|
24
|
+
let responseMockTextStub;
|
|
20
25
|
|
|
21
26
|
beforeEach(() => {
|
|
22
27
|
fetchSourceStringsParameters = new FetchSourceStringsParameters();
|
|
@@ -30,17 +35,20 @@ describe("SmartlingStringsApi class tests.", () => {
|
|
|
30
35
|
stringsServiceApiFetchStub = sinon.stub(stringsApi, "fetch");
|
|
31
36
|
stringsServiceApiUaStub = sinon.stub(stringsApi, "ua");
|
|
32
37
|
responseMockJsonStub = sinon.stub(responseMock, "json");
|
|
38
|
+
responseMockTextStub = sinon.stub(responseMock, "text");
|
|
33
39
|
|
|
34
40
|
stringsServiceApiUaStub.returns("test_user_agent");
|
|
35
41
|
stringsServiceApiFetchStub.returns(responseMock);
|
|
36
42
|
responseMockJsonStub.returns({
|
|
37
43
|
response: {}
|
|
38
44
|
});
|
|
45
|
+
responseMockTextStub.returns("{\"response\": {}}");
|
|
39
46
|
});
|
|
40
47
|
|
|
41
48
|
afterEach(() => {
|
|
42
49
|
stringsServiceApiFetchStub.restore();
|
|
43
50
|
responseMockJsonStub.restore();
|
|
51
|
+
responseMockTextStub.restore();
|
|
44
52
|
stringsServiceApiUaStub.restore();
|
|
45
53
|
});
|
|
46
54
|
|
|
@@ -62,5 +70,177 @@ describe("SmartlingStringsApi class tests.", () => {
|
|
|
62
70
|
}
|
|
63
71
|
);
|
|
64
72
|
});
|
|
73
|
+
|
|
74
|
+
it("Create strings with empty parameters", async () => {
|
|
75
|
+
await stringsApi.createStrings(projectId, new CreateStringsParameters());
|
|
76
|
+
|
|
77
|
+
sinon.assert.calledOnce(stringsServiceApiFetchStub);
|
|
78
|
+
sinon.assert.calledWithExactly(
|
|
79
|
+
stringsServiceApiFetchStub,
|
|
80
|
+
`https://test.com/strings-api/v2/projects/${projectId}`, {
|
|
81
|
+
headers: {
|
|
82
|
+
Authorization: "test_token_type test_access_token",
|
|
83
|
+
"Content-Type": "application/json",
|
|
84
|
+
"User-Agent": "test_user_agent"
|
|
85
|
+
},
|
|
86
|
+
method: "post",
|
|
87
|
+
body: "{}"
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("Create strings with single string", async () => {
|
|
93
|
+
const stringItem = new StringItemParameters("Hello World");
|
|
94
|
+
const parameters = new CreateStringsParameters()
|
|
95
|
+
.addString(stringItem);
|
|
96
|
+
|
|
97
|
+
await stringsApi.createStrings(projectId, parameters);
|
|
98
|
+
|
|
99
|
+
sinon.assert.calledOnce(stringsServiceApiFetchStub);
|
|
100
|
+
sinon.assert.calledWithExactly(
|
|
101
|
+
stringsServiceApiFetchStub,
|
|
102
|
+
`https://test.com/strings-api/v2/projects/${projectId}`, {
|
|
103
|
+
headers: {
|
|
104
|
+
Authorization: "test_token_type test_access_token",
|
|
105
|
+
"Content-Type": "application/json",
|
|
106
|
+
"User-Agent": "test_user_agent"
|
|
107
|
+
},
|
|
108
|
+
method: "post",
|
|
109
|
+
body: JSON.stringify({
|
|
110
|
+
strings: [stringItem]
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("Create strings with full string parameters", async () => {
|
|
117
|
+
const stringItem = new StringItemParameters("Hello World")
|
|
118
|
+
.setVariant("test-variant")
|
|
119
|
+
.setCallbackUrl("https://example.com/callback")
|
|
120
|
+
.setCallbackMethod("POST")
|
|
121
|
+
.setInstruction("Translation instruction")
|
|
122
|
+
.setFormat("html")
|
|
123
|
+
.setMaxLength(100);
|
|
124
|
+
|
|
125
|
+
const parameters = new CreateStringsParameters()
|
|
126
|
+
.addString(stringItem);
|
|
127
|
+
|
|
128
|
+
await stringsApi.createStrings(projectId, parameters);
|
|
129
|
+
|
|
130
|
+
sinon.assert.calledOnce(stringsServiceApiFetchStub);
|
|
131
|
+
sinon.assert.calledWithExactly(
|
|
132
|
+
stringsServiceApiFetchStub,
|
|
133
|
+
`https://test.com/strings-api/v2/projects/${projectId}`, {
|
|
134
|
+
headers: {
|
|
135
|
+
Authorization: "test_token_type test_access_token",
|
|
136
|
+
"Content-Type": "application/json",
|
|
137
|
+
"User-Agent": "test_user_agent"
|
|
138
|
+
},
|
|
139
|
+
method: "post",
|
|
140
|
+
body: JSON.stringify({
|
|
141
|
+
strings: [stringItem]
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("Create strings with namespace and placeholder format", async () => {
|
|
148
|
+
const stringItem = new StringItemParameters("Hello {name}");
|
|
149
|
+
const parameters = new CreateStringsParameters()
|
|
150
|
+
.setNamespace("test.namespace")
|
|
151
|
+
.setPlaceholderFormat("java")
|
|
152
|
+
.setPlaceholderFormatCustom("\\[.+?\\]")
|
|
153
|
+
.addString(stringItem);
|
|
154
|
+
|
|
155
|
+
await stringsApi.createStrings(projectId, parameters);
|
|
156
|
+
|
|
157
|
+
sinon.assert.calledOnce(stringsServiceApiFetchStub);
|
|
158
|
+
sinon.assert.calledWithExactly(
|
|
159
|
+
stringsServiceApiFetchStub,
|
|
160
|
+
`https://test.com/strings-api/v2/projects/${projectId}`, {
|
|
161
|
+
headers: {
|
|
162
|
+
Authorization: "test_token_type test_access_token",
|
|
163
|
+
"Content-Type": "application/json",
|
|
164
|
+
"User-Agent": "test_user_agent"
|
|
165
|
+
},
|
|
166
|
+
method: "post",
|
|
167
|
+
body: JSON.stringify({
|
|
168
|
+
namespace: "test.namespace",
|
|
169
|
+
placeholderFormat: "java",
|
|
170
|
+
placeholderFormatCustom: "\\[.+?\\]",
|
|
171
|
+
strings: [stringItem]
|
|
172
|
+
})
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it("Create strings with multiple strings", async () => {
|
|
178
|
+
const stringItem1 = new StringItemParameters("Hello World");
|
|
179
|
+
const stringItem2 = new StringItemParameters("Goodbye World")
|
|
180
|
+
.setVariant("variant2");
|
|
181
|
+
|
|
182
|
+
const parameters = new CreateStringsParameters()
|
|
183
|
+
.setStrings([stringItem1, stringItem2]);
|
|
184
|
+
|
|
185
|
+
await stringsApi.createStrings(projectId, parameters);
|
|
186
|
+
|
|
187
|
+
sinon.assert.calledOnce(stringsServiceApiFetchStub);
|
|
188
|
+
sinon.assert.calledWithExactly(
|
|
189
|
+
stringsServiceApiFetchStub,
|
|
190
|
+
`https://test.com/strings-api/v2/projects/${projectId}`, {
|
|
191
|
+
headers: {
|
|
192
|
+
Authorization: "test_token_type test_access_token",
|
|
193
|
+
"Content-Type": "application/json",
|
|
194
|
+
"User-Agent": "test_user_agent"
|
|
195
|
+
},
|
|
196
|
+
method: "post",
|
|
197
|
+
body: JSON.stringify({
|
|
198
|
+
strings: [stringItem1, stringItem2]
|
|
199
|
+
})
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it("Should throw error when adding more than 100 strings via addString", () => {
|
|
205
|
+
const parameters = new CreateStringsParameters();
|
|
206
|
+
|
|
207
|
+
// Add 100 strings
|
|
208
|
+
for (let i = 0; i < 100; i += 1) {
|
|
209
|
+
parameters.addString(new StringItemParameters(`String ${i}`));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Adding the 101st string should throw an error
|
|
213
|
+
assert.throws(() => {
|
|
214
|
+
parameters.addString(new StringItemParameters("String 101"));
|
|
215
|
+
}, /Maximum 100 strings can be posted in any given request/);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it("Should throw error when setting more than 100 strings via setStrings", () => {
|
|
219
|
+
// Create 101 strings using Array.from to avoid mutating methods
|
|
220
|
+
const strings = Array.from({ length: 101 }, (_, i) => new StringItemParameters(`String ${i}`));
|
|
221
|
+
|
|
222
|
+
const parameters = new CreateStringsParameters();
|
|
223
|
+
|
|
224
|
+
assert.throws(() => {
|
|
225
|
+
parameters.setStrings(strings);
|
|
226
|
+
}, /Maximum 100 strings can be posted in any given request/);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it("Get create string status", async () => {
|
|
230
|
+
await stringsApi.getCreateStringStatus(projectId, testProcessUid);
|
|
231
|
+
|
|
232
|
+
sinon.assert.calledOnce(stringsServiceApiFetchStub);
|
|
233
|
+
sinon.assert.calledWithExactly(
|
|
234
|
+
stringsServiceApiFetchStub,
|
|
235
|
+
`https://test.com/strings-api/v2/projects/${projectId}/processes/${testProcessUid}`, {
|
|
236
|
+
headers: {
|
|
237
|
+
Authorization: "test_token_type test_access_token",
|
|
238
|
+
"Content-Type": "application/json",
|
|
239
|
+
"User-Agent": "test_user_agent"
|
|
240
|
+
},
|
|
241
|
+
method: "get"
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
|
+
});
|
|
65
245
|
});
|
|
66
246
|
});
|