smartling-api-sdk-nodejs 2.21.1 → 2.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.scannerwork/report-task.txt +2 -2
- package/api/base/index.ts +2 -1
- package/api/tags/dto/project-id-tag-dto.ts +5 -0
- package/api/tags/dto/string-tags-dto.ts +6 -0
- package/api/tags/dto/tag-dto.ts +3 -0
- package/api/tags/index.ts +87 -0
- package/api/tags/params/add-tags-to-strings-parameters.ts +4 -0
- package/api/tags/params/base-tags-strings-parameters.ts +40 -0
- package/api/tags/params/list-account-tags-parameters.ts +40 -0
- package/api/tags/params/list-project-tags-parameters.ts +30 -0
- package/api/tags/params/remove-all-tags-from-strings-parameters.ts +18 -0
- package/api/tags/params/remove-tags-from-strings-parameters.ts +4 -0
- package/api/tags/params/search-string-tags-parameters.ts +18 -0
- package/api/webhooks/dto/scrollable-response.ts +7 -0
- package/api/webhooks/dto/subscription-attempted-event-dto.ts +10 -0
- package/api/webhooks/dto/subscription-dto.ts +18 -0
- package/api/webhooks/dto/subscription-event-attempt-dto.ts +16 -0
- package/api/webhooks/dto/subscription-event-attempt-status.ts +8 -0
- package/api/webhooks/dto/subscription-event-dto.ts +8 -0
- package/api/webhooks/dto/subscription-event-trigger-type.ts +6 -0
- package/api/webhooks/dto/subscription-secret-dto.ts +5 -0
- package/api/webhooks/dto/subscription-statistics-dto.ts +8 -0
- package/api/webhooks/dto/webhook-event-type.dto.ts +7 -0
- package/api/webhooks/index.ts +17 -0
- package/api/webhooks/params/create-subscription-parameters.ts +9 -0
- package/api/webhooks/params/create-update-subscription-parameters.ts +70 -0
- package/api/webhooks/params/get-subscription-events-parameters.ts +38 -0
- package/api/webhooks/params/subscription-event.ts +6 -0
- package/api/webhooks/params/subscription-request-header.ts +6 -0
- package/api/webhooks/params/update-subscription-parameters.ts +19 -0
- package/api/webhooks/params/update-subscription-secret-parameters.ts +14 -0
- package/api/webhooks/smartling-webhooks-api.ts +190 -0
- package/built/api/base/index.js +2 -1
- package/built/api/base/index.js.map +1 -1
- package/built/api/tags/dto/project-id-tag-dto.d.ts +4 -0
- package/built/api/tags/dto/project-id-tag-dto.js +3 -0
- package/built/api/tags/dto/project-id-tag-dto.js.map +1 -0
- package/built/api/tags/dto/string-tags-dto.d.ts +5 -0
- package/built/api/tags/dto/string-tags-dto.js +3 -0
- package/built/api/tags/dto/string-tags-dto.js.map +1 -0
- package/built/api/tags/dto/tag-dto.d.ts +3 -0
- package/built/api/tags/dto/tag-dto.js +3 -0
- package/built/api/tags/dto/tag-dto.js.map +1 -0
- package/built/api/tags/index.d.ts +22 -0
- package/built/api/tags/index.js +52 -0
- package/built/api/tags/index.js.map +1 -0
- package/built/api/tags/params/add-tags-to-strings-parameters.d.ts +3 -0
- package/built/api/tags/params/add-tags-to-strings-parameters.js +8 -0
- package/built/api/tags/params/add-tags-to-strings-parameters.js.map +1 -0
- package/built/api/tags/params/base-tags-strings-parameters.d.ts +5 -0
- package/built/api/tags/params/base-tags-strings-parameters.js +34 -0
- package/built/api/tags/params/base-tags-strings-parameters.js.map +1 -0
- package/built/api/tags/params/list-account-tags-parameters.d.ts +7 -0
- package/built/api/tags/params/list-account-tags-parameters.js +34 -0
- package/built/api/tags/params/list-account-tags-parameters.js.map +1 -0
- package/built/api/tags/params/list-project-tags-parameters.d.ts +6 -0
- package/built/api/tags/params/list-project-tags-parameters.js +27 -0
- package/built/api/tags/params/list-project-tags-parameters.js.map +1 -0
- package/built/api/tags/params/remove-all-tags-from-strings-parameters.d.ts +4 -0
- package/built/api/tags/params/remove-all-tags-from-strings-parameters.js +19 -0
- package/built/api/tags/params/remove-all-tags-from-strings-parameters.js.map +1 -0
- package/built/api/tags/params/remove-tags-from-strings-parameters.d.ts +3 -0
- package/built/api/tags/params/remove-tags-from-strings-parameters.js +8 -0
- package/built/api/tags/params/remove-tags-from-strings-parameters.js.map +1 -0
- package/built/api/tags/params/search-string-tags-parameters.d.ts +4 -0
- package/built/api/tags/params/search-string-tags-parameters.js +19 -0
- package/built/api/tags/params/search-string-tags-parameters.js.map +1 -0
- package/built/api/webhooks/dto/scrollable-response.d.ts +6 -0
- package/built/api/webhooks/dto/scrollable-response.js +3 -0
- package/built/api/webhooks/dto/scrollable-response.js.map +1 -0
- package/built/api/webhooks/dto/subscription-attempted-event-dto.d.ts +8 -0
- package/built/api/webhooks/dto/subscription-attempted-event-dto.js +3 -0
- package/built/api/webhooks/dto/subscription-attempted-event-dto.js.map +1 -0
- package/built/api/webhooks/dto/subscription-dto.d.ts +16 -0
- package/built/api/webhooks/dto/subscription-dto.js +3 -0
- package/built/api/webhooks/dto/subscription-dto.js.map +1 -0
- package/built/api/webhooks/dto/subscription-event-attempt-dto.d.ts +14 -0
- package/built/api/webhooks/dto/subscription-event-attempt-dto.js +3 -0
- package/built/api/webhooks/dto/subscription-event-attempt-dto.js.map +1 -0
- package/built/api/webhooks/dto/subscription-event-attempt-status.d.ts +7 -0
- package/built/api/webhooks/dto/subscription-event-attempt-status.js +12 -0
- package/built/api/webhooks/dto/subscription-event-attempt-status.js.map +1 -0
- package/built/api/webhooks/dto/subscription-event-dto.d.ts +7 -0
- package/built/api/webhooks/dto/subscription-event-dto.js +3 -0
- package/built/api/webhooks/dto/subscription-event-dto.js.map +1 -0
- package/built/api/webhooks/dto/subscription-event-trigger-type.d.ts +5 -0
- package/built/api/webhooks/dto/subscription-event-trigger-type.js +10 -0
- package/built/api/webhooks/dto/subscription-event-trigger-type.js.map +1 -0
- package/built/api/webhooks/dto/subscription-secret-dto.d.ts +4 -0
- package/built/api/webhooks/dto/subscription-secret-dto.js +3 -0
- package/built/api/webhooks/dto/subscription-secret-dto.js.map +1 -0
- package/built/api/webhooks/dto/subscription-statistics-dto.d.ts +7 -0
- package/built/api/webhooks/dto/subscription-statistics-dto.js +3 -0
- package/built/api/webhooks/dto/subscription-statistics-dto.js.map +1 -0
- package/built/api/webhooks/dto/webhook-event-type.dto.d.ts +6 -0
- package/built/api/webhooks/dto/webhook-event-type.dto.js +7 -0
- package/built/api/webhooks/dto/webhook-event-type.dto.js.map +1 -0
- package/built/api/webhooks/index.d.ts +17 -0
- package/built/api/webhooks/index.js +20 -0
- package/built/api/webhooks/index.js.map +1 -0
- package/built/api/webhooks/params/create-subscription-parameters.d.ts +4 -0
- package/built/api/webhooks/params/create-subscription-parameters.js +12 -0
- package/built/api/webhooks/params/create-subscription-parameters.js.map +1 -0
- package/built/api/webhooks/params/create-update-subscription-parameters.d.ts +9 -0
- package/built/api/webhooks/params/create-update-subscription-parameters.js +54 -0
- package/built/api/webhooks/params/create-update-subscription-parameters.js.map +1 -0
- package/built/api/webhooks/params/get-subscription-events-parameters.d.ts +11 -0
- package/built/api/webhooks/params/get-subscription-events-parameters.js +35 -0
- package/built/api/webhooks/params/get-subscription-events-parameters.js.map +1 -0
- package/built/api/webhooks/params/subscription-event.d.ts +5 -0
- package/built/api/webhooks/params/subscription-event.js +3 -0
- package/built/api/webhooks/params/subscription-event.js.map +1 -0
- package/built/api/webhooks/params/subscription-request-header.d.ts +5 -0
- package/built/api/webhooks/params/subscription-request-header.js +3 -0
- package/built/api/webhooks/params/subscription-request-header.js.map +1 -0
- package/built/api/webhooks/params/update-subscription-parameters.d.ts +5 -0
- package/built/api/webhooks/params/update-subscription-parameters.js +12 -0
- package/built/api/webhooks/params/update-subscription-parameters.js.map +1 -0
- package/built/api/webhooks/params/update-subscription-secret-parameters.d.ts +4 -0
- package/built/api/webhooks/params/update-subscription-secret-parameters.js +16 -0
- package/built/api/webhooks/params/update-subscription-secret-parameters.js.map +1 -0
- package/built/api/webhooks/smartling-webhooks-api.d.ts +35 -0
- package/built/api/webhooks/smartling-webhooks-api.js +61 -0
- package/built/api/webhooks/smartling-webhooks-api.js.map +1 -0
- package/built/index.d.ts +12 -0
- package/built/index.js +12 -0
- package/built/index.js.map +1 -1
- package/built/package.json +3 -3
- package/index.ts +12 -0
- package/package.json +3 -3
- package/test/tags.spec.ts +472 -0
- package/test/webhooks.spec.ts +610 -0
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,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,oEAAkD;AAClD,0EAAwD;AACxD,6EAA2D;AAC3D,4EAA0D;AAC1D,+DAA6C;AAC7C,8EAA4D;AAC5D,yEAAuD;AACvD,2EAAyD;AACzD,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,+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"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,kEAAgD;AAChD,0EAAwD;AACxD,mEAAiD;AACjD,mDAAiC;AACjC,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,oEAAkD;AAClD,0EAAwD;AACxD,6EAA2D;AAC3D,4EAA0D;AAC1D,+DAA6C;AAC7C,8EAA4D;AAC5D,yEAAuD;AACvD,2EAAyD;AACzD,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"}
|
package/built/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smartling-api-sdk-nodejs",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.23.0",
|
|
4
4
|
"description": "Package for Smartling API",
|
|
5
5
|
"main": "built/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/Smartling/api-sdk-nodejs#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@types/node": "^16.4.7",
|
|
32
31
|
"@types/mocha": "^9.0.0",
|
|
32
|
+
"@types/node": "^18.19.115",
|
|
33
33
|
"cross-fetch": "^3.1.4",
|
|
34
34
|
"default-user-agent": "^1.0.0",
|
|
35
35
|
"form-data": "^4.0.4",
|
|
36
36
|
"merge-deep": "^3.0.3",
|
|
37
37
|
"querystring": "^0.2.1",
|
|
38
38
|
"string-to-file-stream": "^2.0.0",
|
|
39
|
-
"typescript": "^4.
|
|
39
|
+
"typescript": "^4.9.5",
|
|
40
40
|
"semver": "^5.7.2"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
package/index.ts
CHANGED
|
@@ -109,6 +109,17 @@ export * from "./api/strings/index";
|
|
|
109
109
|
export * from "./api/strings/dto/source-string-dto";
|
|
110
110
|
export * from "./api/strings/dto/source-string-key-dto";
|
|
111
111
|
export * from "./api/strings/params/fetch-source-strings-parameters";
|
|
112
|
+
export * from "./api/tags/index";
|
|
113
|
+
export * from "./api/tags/dto/tag-dto";
|
|
114
|
+
export * from "./api/tags/dto/project-id-tag-dto";
|
|
115
|
+
export * from "./api/tags/dto/string-tags-dto";
|
|
116
|
+
export * from "./api/tags/params/list-account-tags-parameters";
|
|
117
|
+
export * from "./api/tags/params/list-project-tags-parameters";
|
|
118
|
+
export * from "./api/tags/params/search-string-tags-parameters";
|
|
119
|
+
export * from "./api/tags/params/base-tags-strings-parameters";
|
|
120
|
+
export * from "./api/tags/params/add-tags-to-strings-parameters";
|
|
121
|
+
export * from "./api/tags/params/remove-tags-from-strings-parameters";
|
|
122
|
+
export * from "./api/tags/params/remove-all-tags-from-strings-parameters";
|
|
112
123
|
export * from "./api/logger";
|
|
113
124
|
export * from "./api/jobs/params/add-file-parameters";
|
|
114
125
|
export * from "./api/files/params/download-file-all-translations-parameters";
|
|
@@ -124,3 +135,4 @@ export * from "./api/mt/index";
|
|
|
124
135
|
export * from "./api/mt/params/smartling-mt-parameters";
|
|
125
136
|
export * from "./api/mt/params/source-text-item";
|
|
126
137
|
export * from "./api/mt/dto/translation-text-item-dto";
|
|
138
|
+
export * from "./api/webhooks";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smartling-api-sdk-nodejs",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.23.0",
|
|
4
4
|
"description": "Package for Smartling API",
|
|
5
5
|
"main": "built/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/Smartling/api-sdk-nodejs#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@types/node": "^16.4.7",
|
|
32
31
|
"@types/mocha": "^9.0.0",
|
|
32
|
+
"@types/node": "^18.19.115",
|
|
33
33
|
"cross-fetch": "^3.1.4",
|
|
34
34
|
"default-user-agent": "^1.0.0",
|
|
35
35
|
"form-data": "^4.0.4",
|
|
36
36
|
"merge-deep": "^3.0.3",
|
|
37
37
|
"querystring": "^0.2.1",
|
|
38
38
|
"string-to-file-stream": "^2.0.0",
|
|
39
|
-
"typescript": "^4.
|
|
39
|
+
"typescript": "^4.9.5",
|
|
40
40
|
"semver": "^5.7.2"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
import * as sinon from "sinon";
|
|
2
|
+
import * as assert from "assert";
|
|
3
|
+
import { loggerMock, authMock, responseMock } from "./mock";
|
|
4
|
+
import { SmartlingTagsApi } from "../api/tags/index";
|
|
5
|
+
import { SmartlingAuthApi } from "../api/auth/index";
|
|
6
|
+
import { ListAccountTagsParameters } from "../api/tags/params/list-account-tags-parameters";
|
|
7
|
+
import { ListProjectTagsParameters } from "../api/tags/params/list-project-tags-parameters";
|
|
8
|
+
import { SearchStringTagsParameters } from "../api/tags/params/search-string-tags-parameters";
|
|
9
|
+
import { AddTagsToStringsParameters } from "../api/tags/params/add-tags-to-strings-parameters";
|
|
10
|
+
import { RemoveTagsFromStringsParameters } from "../api/tags/params/remove-tags-from-strings-parameters";
|
|
11
|
+
import { RemoveAllTagsFromStringsParameters } from "../api/tags/params/remove-all-tags-from-strings-parameters";
|
|
12
|
+
|
|
13
|
+
describe("SmartlingTagsAPI class tests.", () => {
|
|
14
|
+
const accountUid = "testAccountUid";
|
|
15
|
+
const projectId = "testProjectId";
|
|
16
|
+
let tagsApi;
|
|
17
|
+
let tagsServiceApiFetchStub;
|
|
18
|
+
let tagsServiceApiUaStub;
|
|
19
|
+
let responseMockJsonStub;
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
tagsApi = new SmartlingTagsApi("https://test.com", authMock as unknown as SmartlingAuthApi, loggerMock);
|
|
23
|
+
tagsServiceApiFetchStub = sinon.stub(tagsApi, "fetch");
|
|
24
|
+
tagsServiceApiUaStub = sinon.stub(tagsApi, "ua");
|
|
25
|
+
responseMockJsonStub = sinon.stub(responseMock, "json");
|
|
26
|
+
|
|
27
|
+
tagsServiceApiUaStub.returns("test_user_agent");
|
|
28
|
+
tagsServiceApiFetchStub.returns(responseMock);
|
|
29
|
+
responseMockJsonStub.returns({
|
|
30
|
+
response: {}
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
tagsServiceApiFetchStub.restore();
|
|
36
|
+
responseMockJsonStub.restore();
|
|
37
|
+
tagsServiceApiUaStub.restore();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe("Methods", () => {
|
|
41
|
+
it("List account tags", async () => {
|
|
42
|
+
const params = new ListAccountTagsParameters()
|
|
43
|
+
.setProjectIds(["project1", "project2"])
|
|
44
|
+
.setTagMask("test")
|
|
45
|
+
.setLimit(100)
|
|
46
|
+
.setOffset(0);
|
|
47
|
+
|
|
48
|
+
await tagsApi.listAccountTags(accountUid, params);
|
|
49
|
+
|
|
50
|
+
sinon.assert.calledOnce(tagsServiceApiFetchStub);
|
|
51
|
+
sinon.assert.calledWithExactly(
|
|
52
|
+
tagsServiceApiFetchStub,
|
|
53
|
+
`https://test.com/tags-api/v2/accounts/${accountUid}/tags`,
|
|
54
|
+
{
|
|
55
|
+
body: "{\"projectIds\":[\"project1\",\"project2\"],\"tagMask\":\"test\",\"limit\":100,\"offset\":0}",
|
|
56
|
+
headers: {
|
|
57
|
+
Authorization: "test_token_type test_access_token",
|
|
58
|
+
"Content-Type": "application/json",
|
|
59
|
+
"User-Agent": "test_user_agent"
|
|
60
|
+
},
|
|
61
|
+
method: "post"
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("List account tags with minimal parameters", async () => {
|
|
67
|
+
const params = new ListAccountTagsParameters()
|
|
68
|
+
.setLimit(50);
|
|
69
|
+
|
|
70
|
+
await tagsApi.listAccountTags(accountUid, params);
|
|
71
|
+
|
|
72
|
+
sinon.assert.calledOnce(tagsServiceApiFetchStub);
|
|
73
|
+
sinon.assert.calledWithExactly(
|
|
74
|
+
tagsServiceApiFetchStub,
|
|
75
|
+
`https://test.com/tags-api/v2/accounts/${accountUid}/tags`,
|
|
76
|
+
{
|
|
77
|
+
body: "{\"limit\":50}",
|
|
78
|
+
headers: {
|
|
79
|
+
Authorization: "test_token_type test_access_token",
|
|
80
|
+
"Content-Type": "application/json",
|
|
81
|
+
"User-Agent": "test_user_agent"
|
|
82
|
+
},
|
|
83
|
+
method: "post"
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("List project tags", async () => {
|
|
89
|
+
const params = new ListProjectTagsParameters()
|
|
90
|
+
.setTagMask("frontend")
|
|
91
|
+
.setLimit(50)
|
|
92
|
+
.setOffset(10);
|
|
93
|
+
|
|
94
|
+
await tagsApi.listProjectTags(projectId, params);
|
|
95
|
+
|
|
96
|
+
sinon.assert.calledOnce(tagsServiceApiFetchStub);
|
|
97
|
+
sinon.assert.calledWithExactly(
|
|
98
|
+
tagsServiceApiFetchStub,
|
|
99
|
+
`https://test.com/tags-api/v2/projects/${projectId}/tags?tagMask=frontend&limit=50&offset=10`,
|
|
100
|
+
{
|
|
101
|
+
headers: {
|
|
102
|
+
Authorization: "test_token_type test_access_token",
|
|
103
|
+
"Content-Type": "application/json",
|
|
104
|
+
"User-Agent": "test_user_agent"
|
|
105
|
+
},
|
|
106
|
+
method: "get"
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("List project tags with no parameters", async () => {
|
|
112
|
+
const params = new ListProjectTagsParameters();
|
|
113
|
+
|
|
114
|
+
await tagsApi.listProjectTags(projectId, params);
|
|
115
|
+
|
|
116
|
+
sinon.assert.calledOnce(tagsServiceApiFetchStub);
|
|
117
|
+
sinon.assert.calledWithExactly(
|
|
118
|
+
tagsServiceApiFetchStub,
|
|
119
|
+
`https://test.com/tags-api/v2/projects/${projectId}/tags?`,
|
|
120
|
+
{
|
|
121
|
+
headers: {
|
|
122
|
+
Authorization: "test_token_type test_access_token",
|
|
123
|
+
"Content-Type": "application/json",
|
|
124
|
+
"User-Agent": "test_user_agent"
|
|
125
|
+
},
|
|
126
|
+
method: "get"
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("Search string tags", async () => {
|
|
132
|
+
const params = new SearchStringTagsParameters()
|
|
133
|
+
.setStringHashcodes(["hash1", "hash2", "hash3"]);
|
|
134
|
+
|
|
135
|
+
await tagsApi.searchStringTags(projectId, params);
|
|
136
|
+
|
|
137
|
+
sinon.assert.calledOnce(tagsServiceApiFetchStub);
|
|
138
|
+
sinon.assert.calledWithExactly(
|
|
139
|
+
tagsServiceApiFetchStub,
|
|
140
|
+
`https://test.com/tags-api/v2/projects/${projectId}/strings/tags/search`,
|
|
141
|
+
{
|
|
142
|
+
body: "{\"stringHashcodes\":[\"hash1\",\"hash2\",\"hash3\"]}",
|
|
143
|
+
headers: {
|
|
144
|
+
Authorization: "test_token_type test_access_token",
|
|
145
|
+
"Content-Type": "application/json",
|
|
146
|
+
"User-Agent": "test_user_agent"
|
|
147
|
+
},
|
|
148
|
+
method: "post"
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it("Add tags to strings", async () => {
|
|
154
|
+
const params = new AddTagsToStringsParameters()
|
|
155
|
+
.setTags(["urgent", "frontend", "ui"])
|
|
156
|
+
.setStringHashcodes(["hash1", "hash2"]);
|
|
157
|
+
|
|
158
|
+
await tagsApi.addTagsToStrings(projectId, params);
|
|
159
|
+
|
|
160
|
+
sinon.assert.calledOnce(tagsServiceApiFetchStub);
|
|
161
|
+
sinon.assert.calledWithExactly(
|
|
162
|
+
tagsServiceApiFetchStub,
|
|
163
|
+
`https://test.com/tags-api/v2/projects/${projectId}/strings/tags/add`,
|
|
164
|
+
{
|
|
165
|
+
body: "{\"tags\":[\"urgent\",\"frontend\",\"ui\"],\"stringHashcodes\":[\"hash1\",\"hash2\"]}",
|
|
166
|
+
headers: {
|
|
167
|
+
Authorization: "test_token_type test_access_token",
|
|
168
|
+
"Content-Type": "application/json",
|
|
169
|
+
"User-Agent": "test_user_agent"
|
|
170
|
+
},
|
|
171
|
+
method: "post"
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it("Remove tags from strings", async () => {
|
|
177
|
+
const params = new RemoveTagsFromStringsParameters()
|
|
178
|
+
.setTags(["urgent", "deprecated"])
|
|
179
|
+
.setStringHashcodes(["hash1", "hash2", "hash3"]);
|
|
180
|
+
|
|
181
|
+
await tagsApi.removeTagsFromStrings(projectId, params);
|
|
182
|
+
|
|
183
|
+
sinon.assert.calledOnce(tagsServiceApiFetchStub);
|
|
184
|
+
sinon.assert.calledWithExactly(
|
|
185
|
+
tagsServiceApiFetchStub,
|
|
186
|
+
`https://test.com/tags-api/v2/projects/${projectId}/strings/tags/remove`,
|
|
187
|
+
{
|
|
188
|
+
body: "{\"tags\":[\"urgent\",\"deprecated\"],\"stringHashcodes\":[\"hash1\",\"hash2\",\"hash3\"]}",
|
|
189
|
+
headers: {
|
|
190
|
+
Authorization: "test_token_type test_access_token",
|
|
191
|
+
"Content-Type": "application/json",
|
|
192
|
+
"User-Agent": "test_user_agent"
|
|
193
|
+
},
|
|
194
|
+
method: "post"
|
|
195
|
+
}
|
|
196
|
+
);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it("Remove all tags from strings", async () => {
|
|
200
|
+
const params = new RemoveAllTagsFromStringsParameters()
|
|
201
|
+
.setStringHashcodes(["hash1", "hash2", "hash3", "hash4"]);
|
|
202
|
+
|
|
203
|
+
await tagsApi.removeAllTagsFromStrings(projectId, params);
|
|
204
|
+
|
|
205
|
+
sinon.assert.calledOnce(tagsServiceApiFetchStub);
|
|
206
|
+
sinon.assert.calledWithExactly(
|
|
207
|
+
tagsServiceApiFetchStub,
|
|
208
|
+
`https://test.com/tags-api/v2/projects/${projectId}/strings/tags/remove/all`,
|
|
209
|
+
{
|
|
210
|
+
body: "{\"stringHashcodes\":[\"hash1\",\"hash2\",\"hash3\",\"hash4\"]}",
|
|
211
|
+
headers: {
|
|
212
|
+
Authorization: "test_token_type test_access_token",
|
|
213
|
+
"Content-Type": "application/json",
|
|
214
|
+
"User-Agent": "test_user_agent"
|
|
215
|
+
},
|
|
216
|
+
method: "post"
|
|
217
|
+
}
|
|
218
|
+
);
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
describe("Parameter validation", () => {
|
|
223
|
+
it("ListAccountTagsParameters should validate project IDs limit", () => {
|
|
224
|
+
const params = new ListAccountTagsParameters();
|
|
225
|
+
const tooManyProjects = Array(1001).fill("project");
|
|
226
|
+
|
|
227
|
+
try {
|
|
228
|
+
params.setProjectIds(tooManyProjects);
|
|
229
|
+
throw new Error("Exception is not thrown.");
|
|
230
|
+
} catch (e) {
|
|
231
|
+
assert.equal(e.constructor.name, "SmartlingException");
|
|
232
|
+
assert.equal(e.message, "Project IDs array must not exceed 1000 items");
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it("ListAccountTagsParameters should validate limit range", () => {
|
|
237
|
+
const params = new ListAccountTagsParameters();
|
|
238
|
+
|
|
239
|
+
try {
|
|
240
|
+
params.setLimit(0);
|
|
241
|
+
throw new Error("Exception is not thrown.");
|
|
242
|
+
} catch (e) {
|
|
243
|
+
assert.equal(e.constructor.name, "SmartlingException");
|
|
244
|
+
assert.equal(e.message, "Limit must be between 1 and 1500");
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
try {
|
|
248
|
+
params.setLimit(1501);
|
|
249
|
+
throw new Error("Exception is not thrown.");
|
|
250
|
+
} catch (e) {
|
|
251
|
+
assert.equal(e.constructor.name, "SmartlingException");
|
|
252
|
+
assert.equal(e.message, "Limit must be between 1 and 1500");
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
it("ListAccountTagsParameters should validate offset", () => {
|
|
257
|
+
const params = new ListAccountTagsParameters();
|
|
258
|
+
|
|
259
|
+
try {
|
|
260
|
+
params.setOffset(-1);
|
|
261
|
+
throw new Error("Exception is not thrown.");
|
|
262
|
+
} catch (e) {
|
|
263
|
+
assert.equal(e.constructor.name, "SmartlingException");
|
|
264
|
+
assert.equal(e.message, "Offset must be non-negative");
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it("ListProjectTagsParameters should validate limit range", () => {
|
|
269
|
+
const params = new ListProjectTagsParameters();
|
|
270
|
+
|
|
271
|
+
try {
|
|
272
|
+
params.setLimit(-1);
|
|
273
|
+
throw new Error("Exception is not thrown.");
|
|
274
|
+
} catch (e) {
|
|
275
|
+
assert.equal(e.constructor.name, "SmartlingException");
|
|
276
|
+
assert.equal(e.message, "Limit must be between 0 and 100");
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
try {
|
|
280
|
+
params.setLimit(101);
|
|
281
|
+
throw new Error("Exception is not thrown.");
|
|
282
|
+
} catch (e) {
|
|
283
|
+
assert.equal(e.constructor.name, "SmartlingException");
|
|
284
|
+
assert.equal(e.message, "Limit must be between 0 and 100");
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it("SearchStringTagsParameters should require string hashcodes", () => {
|
|
289
|
+
const params = new SearchStringTagsParameters();
|
|
290
|
+
|
|
291
|
+
try {
|
|
292
|
+
params.setStringHashcodes([]);
|
|
293
|
+
throw new Error("Exception is not thrown.");
|
|
294
|
+
} catch (e) {
|
|
295
|
+
assert.equal(e.constructor.name, "SmartlingException");
|
|
296
|
+
assert.equal(e.message, "String hashcodes array is required");
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
try {
|
|
300
|
+
params.setStringHashcodes(null as unknown as Array<string>);
|
|
301
|
+
throw new Error("Exception is not thrown.");
|
|
302
|
+
} catch (e) {
|
|
303
|
+
assert.equal(e.constructor.name, "SmartlingException");
|
|
304
|
+
assert.equal(e.message, "String hashcodes array is required");
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it("SearchStringTagsParameters should validate hashcodes limit", () => {
|
|
309
|
+
const params = new SearchStringTagsParameters();
|
|
310
|
+
const tooManyHashcodes = Array(1001).fill("hash");
|
|
311
|
+
|
|
312
|
+
try {
|
|
313
|
+
params.setStringHashcodes(tooManyHashcodes);
|
|
314
|
+
throw new Error("Exception is not thrown.");
|
|
315
|
+
} catch (e) {
|
|
316
|
+
assert.equal(e.constructor.name, "SmartlingException");
|
|
317
|
+
assert.equal(e.message, "String hashcodes array must not exceed 1000 items");
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it("AddTagsToStringsParameters should validate tags array", () => {
|
|
322
|
+
const params = new AddTagsToStringsParameters();
|
|
323
|
+
|
|
324
|
+
try {
|
|
325
|
+
params.setTags([]);
|
|
326
|
+
throw new Error("Exception is not thrown.");
|
|
327
|
+
} catch (e) {
|
|
328
|
+
assert.equal(e.constructor.name, "SmartlingException");
|
|
329
|
+
assert.equal(e.message, "Tags array is required");
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
try {
|
|
333
|
+
params.setTags(null as unknown as Array<string>);
|
|
334
|
+
throw new Error("Exception is not thrown.");
|
|
335
|
+
} catch (e) {
|
|
336
|
+
assert.equal(e.constructor.name, "SmartlingException");
|
|
337
|
+
assert.equal(e.message, "Tags array is required");
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const tooManyTags = Array(101).fill("tag");
|
|
341
|
+
try {
|
|
342
|
+
params.setTags(tooManyTags);
|
|
343
|
+
throw new Error("Exception is not thrown.");
|
|
344
|
+
} catch (e) {
|
|
345
|
+
assert.equal(e.constructor.name, "SmartlingException");
|
|
346
|
+
assert.equal(e.message, "Tags array must not exceed 100 items");
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it("AddTagsToStringsParameters should validate tag length", () => {
|
|
351
|
+
const params = new AddTagsToStringsParameters();
|
|
352
|
+
const longTag = "a".repeat(129);
|
|
353
|
+
|
|
354
|
+
try {
|
|
355
|
+
params.setTags([longTag]);
|
|
356
|
+
throw new Error("Exception is not thrown.");
|
|
357
|
+
} catch (e) {
|
|
358
|
+
assert.equal(e.constructor.name, "SmartlingException");
|
|
359
|
+
assert.equal(e.message, "Tag length must not exceed 128 characters");
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
it("AddTagsToStringsParameters should validate string hashcodes", () => {
|
|
364
|
+
const params = new AddTagsToStringsParameters();
|
|
365
|
+
|
|
366
|
+
try {
|
|
367
|
+
params.setStringHashcodes([]);
|
|
368
|
+
throw new Error("Exception is not thrown.");
|
|
369
|
+
} catch (e) {
|
|
370
|
+
assert.equal(e.constructor.name, "SmartlingException");
|
|
371
|
+
assert.equal(e.message, "String hashcodes array is required");
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const tooManyHashcodes = Array(1001).fill("hash");
|
|
375
|
+
try {
|
|
376
|
+
params.setStringHashcodes(tooManyHashcodes);
|
|
377
|
+
throw new Error("Exception is not thrown.");
|
|
378
|
+
} catch (e) {
|
|
379
|
+
assert.equal(e.constructor.name, "SmartlingException");
|
|
380
|
+
assert.equal(e.message, "String hashcodes array must not exceed 1000 items");
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
it("RemoveTagsFromStringsParameters should validate tags and hashcodes", () => {
|
|
385
|
+
const params = new RemoveTagsFromStringsParameters();
|
|
386
|
+
|
|
387
|
+
try {
|
|
388
|
+
params.setTags([]);
|
|
389
|
+
throw new Error("Exception is not thrown.");
|
|
390
|
+
} catch (e) {
|
|
391
|
+
assert.equal(e.constructor.name, "SmartlingException");
|
|
392
|
+
assert.equal(e.message, "Tags array is required");
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
try {
|
|
396
|
+
params.setStringHashcodes([]);
|
|
397
|
+
throw new Error("Exception is not thrown.");
|
|
398
|
+
} catch (e) {
|
|
399
|
+
assert.equal(e.constructor.name, "SmartlingException");
|
|
400
|
+
assert.equal(e.message, "String hashcodes array is required");
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
const longTag = "a".repeat(129);
|
|
404
|
+
try {
|
|
405
|
+
params.setTags([longTag]);
|
|
406
|
+
throw new Error("Exception is not thrown.");
|
|
407
|
+
} catch (e) {
|
|
408
|
+
assert.equal(e.constructor.name, "SmartlingException");
|
|
409
|
+
assert.equal(e.message, "Tag length must not exceed 128 characters");
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
it("RemoveAllTagsFromStringsParameters should validate string hashcodes", () => {
|
|
414
|
+
const params = new RemoveAllTagsFromStringsParameters();
|
|
415
|
+
|
|
416
|
+
try {
|
|
417
|
+
params.setStringHashcodes([]);
|
|
418
|
+
throw new Error("Exception is not thrown.");
|
|
419
|
+
} catch (e) {
|
|
420
|
+
assert.equal(e.constructor.name, "SmartlingException");
|
|
421
|
+
assert.equal(e.message, "String hashcodes array is required");
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
const tooManyHashcodes = Array(1001).fill("hash");
|
|
425
|
+
try {
|
|
426
|
+
params.setStringHashcodes(tooManyHashcodes);
|
|
427
|
+
throw new Error("Exception is not thrown.");
|
|
428
|
+
} catch (e) {
|
|
429
|
+
assert.equal(e.constructor.name, "SmartlingException");
|
|
430
|
+
assert.equal(e.message, "String hashcodes array must not exceed 1000 items");
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
describe("Edge cases", () => {
|
|
436
|
+
it("Should handle maximum allowed project IDs", () => {
|
|
437
|
+
const params = new ListAccountTagsParameters();
|
|
438
|
+
const maxProjects = Array(1000).fill("project");
|
|
439
|
+
|
|
440
|
+
// Should not throw
|
|
441
|
+
params.setProjectIds(maxProjects);
|
|
442
|
+
assert.deepStrictEqual(params.export().projectIds, maxProjects);
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
it("Should handle maximum allowed tags", () => {
|
|
446
|
+
const params = new AddTagsToStringsParameters();
|
|
447
|
+
const maxTags = Array(100).fill("tag");
|
|
448
|
+
|
|
449
|
+
// Should not throw
|
|
450
|
+
params.setTags(maxTags);
|
|
451
|
+
assert.deepStrictEqual(params.export().tags, maxTags);
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
it("Should handle maximum allowed string hashcodes", () => {
|
|
455
|
+
const params = new SearchStringTagsParameters();
|
|
456
|
+
const maxHashcodes = Array(1000).fill("hash");
|
|
457
|
+
|
|
458
|
+
// Should not throw
|
|
459
|
+
params.setStringHashcodes(maxHashcodes);
|
|
460
|
+
assert.deepStrictEqual(params.export().stringHashcodes, maxHashcodes);
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
it("Should handle maximum tag length", () => {
|
|
464
|
+
const params = new AddTagsToStringsParameters();
|
|
465
|
+
const maxLengthTag = "a".repeat(128);
|
|
466
|
+
|
|
467
|
+
// Should not throw
|
|
468
|
+
params.setTags([maxLengthTag]);
|
|
469
|
+
assert.deepStrictEqual(params.export().tags, [maxLengthTag]);
|
|
470
|
+
});
|
|
471
|
+
});
|
|
472
|
+
});
|