smartling-api-sdk-nodejs 2.24.3 → 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/glossaries/dto/date-filter-dto.ts +10 -0
- package/api/glossaries/dto/entry-sorting-dto.ts +8 -0
- package/api/glossaries/dto/export-entries-filter-dto.ts +25 -0
- package/api/glossaries/dto/label-type-dto.ts +6 -0
- package/api/glossaries/dto/user-filter-dto.ts +6 -0
- package/api/glossaries/enums/date-filter-type.ts +6 -0
- package/api/glossaries/enums/entry-state.ts +5 -0
- package/api/glossaries/enums/export-format.ts +5 -0
- package/api/glossaries/enums/filter-level.ts +5 -0
- package/api/glossaries/enums/index.ts +8 -0
- package/api/glossaries/enums/label-type.ts +5 -0
- package/api/glossaries/enums/sort-direction.ts +4 -0
- package/api/glossaries/enums/sort-field.ts +5 -0
- package/api/glossaries/enums/tbx-version.ts +4 -0
- package/api/glossaries/index.ts +13 -0
- package/api/glossaries/params/export-entries-parameters.ts +160 -0
- 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/glossaries/dto/date-filter-dto.d.ts +9 -0
- package/built/api/glossaries/dto/date-filter-dto.js +3 -0
- package/built/api/glossaries/dto/date-filter-dto.js.map +1 -0
- package/built/api/glossaries/dto/entry-sorting-dto.d.ts +7 -0
- package/built/api/glossaries/dto/entry-sorting-dto.js +3 -0
- package/built/api/glossaries/dto/entry-sorting-dto.js.map +1 -0
- package/built/api/glossaries/dto/export-entries-filter-dto.d.ts +24 -0
- package/built/api/glossaries/dto/export-entries-filter-dto.js +3 -0
- package/built/api/glossaries/dto/export-entries-filter-dto.js.map +1 -0
- package/built/api/glossaries/dto/label-type-dto.d.ts +5 -0
- package/built/api/glossaries/dto/label-type-dto.js +3 -0
- package/built/api/glossaries/dto/label-type-dto.js.map +1 -0
- package/built/api/glossaries/dto/user-filter-dto.d.ts +5 -0
- package/built/api/glossaries/dto/user-filter-dto.js +3 -0
- package/built/api/glossaries/dto/user-filter-dto.js.map +1 -0
- package/built/api/glossaries/enums/date-filter-type.d.ts +6 -0
- package/built/api/glossaries/enums/date-filter-type.js +11 -0
- package/built/api/glossaries/enums/date-filter-type.js.map +1 -0
- package/built/api/glossaries/enums/entry-state.d.ts +5 -0
- package/built/api/glossaries/enums/entry-state.js +10 -0
- package/built/api/glossaries/enums/entry-state.js.map +1 -0
- package/built/api/glossaries/enums/export-format.d.ts +5 -0
- package/built/api/glossaries/enums/export-format.js +10 -0
- package/built/api/glossaries/enums/export-format.js.map +1 -0
- package/built/api/glossaries/enums/filter-level.d.ts +5 -0
- package/built/api/glossaries/enums/filter-level.js +10 -0
- package/built/api/glossaries/enums/filter-level.js.map +1 -0
- package/built/api/glossaries/enums/index.d.ts +8 -0
- package/built/api/glossaries/enums/index.js +20 -0
- package/built/api/glossaries/enums/index.js.map +1 -0
- package/built/api/glossaries/enums/label-type.d.ts +5 -0
- package/built/api/glossaries/enums/label-type.js +10 -0
- package/built/api/glossaries/enums/label-type.js.map +1 -0
- package/built/api/glossaries/enums/sort-direction.d.ts +4 -0
- package/built/api/glossaries/enums/sort-direction.js +9 -0
- package/built/api/glossaries/enums/sort-direction.js.map +1 -0
- package/built/api/glossaries/enums/sort-field.d.ts +5 -0
- package/built/api/glossaries/enums/sort-field.js +10 -0
- package/built/api/glossaries/enums/sort-field.js.map +1 -0
- package/built/api/glossaries/enums/tbx-version.d.ts +4 -0
- package/built/api/glossaries/enums/tbx-version.js +9 -0
- package/built/api/glossaries/enums/tbx-version.js.map +1 -0
- package/built/api/glossaries/index.d.ts +2 -0
- package/built/api/glossaries/index.js +5 -0
- package/built/api/glossaries/index.js.map +1 -1
- package/built/api/glossaries/params/export-entries-parameters.d.ts +35 -0
- package/built/api/glossaries/params/export-entries-parameters.js +133 -0
- package/built/api/glossaries/params/export-entries-parameters.js.map +1 -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/glossaries.spec.ts +107 -0
- package/test/strings.spec.ts +180 -0
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/glossaries.spec.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { SmartlingGlossariesApi } from "../api/glossaries/index";
|
|
|
3
3
|
import { loggerMock, authMock, responseMock } from "./mock";
|
|
4
4
|
import { SmartlingAuthApi } from "../api/auth/index";
|
|
5
5
|
import { SearchGlossariesParameters } from "../api/glossaries/params/search-glossaries-parameters";
|
|
6
|
+
import { ExportEntriesParameters } from "../api/glossaries/params/export-entries-parameters";
|
|
7
|
+
import { ExportFormat, TbxVersion, EntryState, FilterLevel, SortField, SortDirection, LabelType, DateFilterType } from "../api/glossaries/enums";
|
|
6
8
|
|
|
7
9
|
describe("SmartlingGlossariesApi class tests.", () => {
|
|
8
10
|
const accountUid = "testAccountUid";
|
|
@@ -85,5 +87,110 @@ describe("SmartlingGlossariesApi class tests.", () => {
|
|
|
85
87
|
}
|
|
86
88
|
);
|
|
87
89
|
});
|
|
90
|
+
|
|
91
|
+
it("Export glossary entries with minimal parameters", async () => {
|
|
92
|
+
const parameters = new ExportEntriesParameters()
|
|
93
|
+
.setFormat(ExportFormat.CSV)
|
|
94
|
+
.setLocaleIds(["en-US", "fr-FR"]);
|
|
95
|
+
|
|
96
|
+
await glossariesApi.exportGlossaryEntries(accountUid, glossaryUid, parameters);
|
|
97
|
+
|
|
98
|
+
sinon.assert.calledOnce(glossariesApiFetchStub);
|
|
99
|
+
sinon.assert.calledWithExactly(
|
|
100
|
+
glossariesApiFetchStub,
|
|
101
|
+
`https://test.com/glossary-api/v3/accounts/${accountUid}/glossaries/${glossaryUid}/entries/download`,
|
|
102
|
+
{
|
|
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
|
+
filter: {},
|
|
111
|
+
localeIds: ["en-US", "fr-FR"],
|
|
112
|
+
format: "CSV"
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("Export glossary entries with full parameters", async () => {
|
|
119
|
+
const parameters = new ExportEntriesParameters()
|
|
120
|
+
.setFormat(ExportFormat.TBX)
|
|
121
|
+
.setTbxVersion(TbxVersion.TBXcoreStructV02)
|
|
122
|
+
.setLocaleIds(["en-US", "uk-UA"])
|
|
123
|
+
.setFocusLocaleId("en-US")
|
|
124
|
+
.setSkipEntries(false)
|
|
125
|
+
.setFilterQuery("P&G term")
|
|
126
|
+
.setFilterLocaleIds(["uk-UA", "en", "en-US"])
|
|
127
|
+
.setFilterEntryUids(["16ed66cc-accc-4bb5-9822-bc84e93429f8", "69dae398-96c2-45f6-9f0d-91470c3464bd"])
|
|
128
|
+
.setFilterEntryState(EntryState.ACTIVE)
|
|
129
|
+
.setFilterMissingTranslationLocaleId("uk-UA")
|
|
130
|
+
.setFilterPresentTranslationLocaleId("uk-UA")
|
|
131
|
+
.setFilterDntLocaleId("uk-UA")
|
|
132
|
+
.setFilterReturnFallbackTranslations(false)
|
|
133
|
+
.setFilterLabels({ type: LabelType.EMPTY })
|
|
134
|
+
.setFilterDntTermSet(false)
|
|
135
|
+
.setFilterCreated({ level: FilterLevel.ANY, type: DateFilterType.AFTER, date: "2023-02-01T11:45:00.000Z" })
|
|
136
|
+
.setFilterLastModified({ level: FilterLevel.ANY, type: DateFilterType.AFTER, date: "2023-02-01T11:45:00.000Z" })
|
|
137
|
+
.setFilterCreatedBy({ level: FilterLevel.ANY, userIds: ["user1", "user2"] })
|
|
138
|
+
.setFilterLastModifiedBy({ level: FilterLevel.ANY, userIds: ["user1", "user2"] })
|
|
139
|
+
.setFilterPaging({ offset: 0, limit: 50 })
|
|
140
|
+
.setFilterSorting({ field: SortField.TERM, direction: SortDirection.DESC, localeId: "uk-UA" });
|
|
141
|
+
|
|
142
|
+
await glossariesApi.exportGlossaryEntries(accountUid, glossaryUid, parameters);
|
|
143
|
+
|
|
144
|
+
sinon.assert.calledOnce(glossariesApiFetchStub);
|
|
145
|
+
const callArgs = glossariesApiFetchStub.getCall(0).args;
|
|
146
|
+
const body = JSON.parse(callArgs[1].body);
|
|
147
|
+
|
|
148
|
+
sinon.assert.match(body, {
|
|
149
|
+
format: "TBX",
|
|
150
|
+
tbxVersion: "TBXcoreStructV02",
|
|
151
|
+
localeIds: ["en-US", "uk-UA"],
|
|
152
|
+
focusLocaleId: "en-US",
|
|
153
|
+
skipEntries: false,
|
|
154
|
+
filter: {
|
|
155
|
+
query: "P&G term",
|
|
156
|
+
localeIds: ["uk-UA", "en", "en-US"],
|
|
157
|
+
entryUids: ["16ed66cc-accc-4bb5-9822-bc84e93429f8", "69dae398-96c2-45f6-9f0d-91470c3464bd"],
|
|
158
|
+
entryState: "ACTIVE",
|
|
159
|
+
missingTranslationLocaleId: "uk-UA",
|
|
160
|
+
presentTranslationLocaleId: "uk-UA",
|
|
161
|
+
dntLocaleId: "uk-UA",
|
|
162
|
+
returnFallbackTranslations: false,
|
|
163
|
+
labels: { type: "empty" },
|
|
164
|
+
dntTermSet: false,
|
|
165
|
+
created: {
|
|
166
|
+
level: "ANY",
|
|
167
|
+
date: "2023-02-01T11:45:00.000Z",
|
|
168
|
+
type: "after"
|
|
169
|
+
},
|
|
170
|
+
lastModified: {
|
|
171
|
+
level: "ANY",
|
|
172
|
+
date: "2023-02-01T11:45:00.000Z",
|
|
173
|
+
type: "after"
|
|
174
|
+
},
|
|
175
|
+
createdBy: {
|
|
176
|
+
level: "ANY",
|
|
177
|
+
userIds: ["user1", "user2"]
|
|
178
|
+
},
|
|
179
|
+
lastModifiedBy: {
|
|
180
|
+
level: "ANY",
|
|
181
|
+
userIds: ["user1", "user2"]
|
|
182
|
+
},
|
|
183
|
+
paging: {
|
|
184
|
+
offset: 0,
|
|
185
|
+
limit: 50
|
|
186
|
+
},
|
|
187
|
+
sorting: {
|
|
188
|
+
field: "term",
|
|
189
|
+
direction: "DESC",
|
|
190
|
+
localeId: "uk-UA"
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
});
|
|
88
195
|
});
|
|
89
196
|
});
|
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
|
});
|