smartling-api-sdk-nodejs 2.35.3 → 3.1.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/api/files/dto/file-namespace-dto.ts +5 -0
- package/api/files/dto/file-status-for-all-locales-dto.ts +6 -0
- package/api/files/index.ts +16 -1
- package/api/files/params/download-file-all-translations-parameters.ts +7 -1
- package/api/files/params/files-order-by.ts +11 -0
- package/api/files/params/page-count-status.ts +7 -0
- package/api/files/params/recently-uploaded-files.ts +26 -0
- package/api/files/params/retrieval-type.ts +2 -1
- package/api/job-batches/dto/batch-list-item-dto.ts +1 -1
- package/api/job-batches/dto/job-batches-parameters-salt.ts +0 -1
- package/api/job-batches/dto/locale-workflow-content-assignment-dto.ts +6 -0
- package/api/job-batches/dto/locale-workflow-dto.ts +11 -0
- package/api/job-batches/dto/translation-job-workflow-step-due-date-dto.ts +6 -0
- package/api/job-batches/index.ts +4 -0
- package/api/job-batches/params/batch-item-status.ts +1 -0
- package/api/job-batches/params/create-batch-parameters.ts +9 -5
- package/api/job-batches/params/list-batches-parameters.ts +1 -1
- package/api/job-batches/params/upload-batch-file-parameters.ts +6 -0
- package/built/api/files/dto/file-namespace-dto.d.ts +4 -0
- package/built/api/files/dto/file-namespace-dto.js +3 -0
- package/built/api/files/dto/file-namespace-dto.js.map +1 -0
- package/built/api/files/dto/file-status-for-all-locales-dto.d.ts +6 -0
- package/built/api/files/index.d.ts +2 -1
- package/built/api/files/index.js +8 -0
- package/built/api/files/index.js.map +1 -1
- package/built/api/files/params/download-file-all-translations-parameters.d.ts +1 -0
- package/built/api/files/params/download-file-all-translations-parameters.js +4 -0
- package/built/api/files/params/download-file-all-translations-parameters.js.map +1 -1
- package/built/api/files/params/files-order-by.d.ts +11 -0
- package/built/api/files/params/files-order-by.js +16 -0
- package/built/api/files/params/files-order-by.js.map +1 -0
- package/built/api/files/params/page-count-status.d.ts +7 -0
- package/built/api/files/params/page-count-status.js +12 -0
- package/built/api/files/params/page-count-status.js.map +1 -0
- package/built/api/files/params/recently-uploaded-files.d.ts +6 -0
- package/built/api/files/params/recently-uploaded-files.js +16 -0
- package/built/api/files/params/recently-uploaded-files.js.map +1 -1
- package/built/api/files/params/retrieval-type.d.ts +2 -1
- package/built/api/files/params/retrieval-type.js +1 -0
- package/built/api/files/params/retrieval-type.js.map +1 -1
- package/built/api/job-batches/dto/batch-list-item-dto.d.ts +1 -0
- package/built/api/job-batches/dto/job-batches-parameters-salt.d.ts +0 -1
- package/built/api/job-batches/dto/job-batches-parameters-salt.js +0 -1
- package/built/api/job-batches/dto/job-batches-parameters-salt.js.map +1 -1
- package/built/api/job-batches/dto/locale-workflow-content-assignment-dto.d.ts +5 -0
- package/built/api/job-batches/dto/locale-workflow-content-assignment-dto.js +3 -0
- package/built/api/job-batches/dto/locale-workflow-content-assignment-dto.js.map +1 -0
- package/built/api/job-batches/dto/locale-workflow-dto.d.ts +9 -0
- package/built/api/job-batches/dto/locale-workflow-dto.js +3 -0
- package/built/api/job-batches/dto/locale-workflow-dto.js.map +1 -0
- package/built/api/job-batches/dto/translation-job-workflow-step-due-date-dto.d.ts +5 -0
- package/built/api/job-batches/dto/translation-job-workflow-step-due-date-dto.js +3 -0
- package/built/api/job-batches/dto/translation-job-workflow-step-due-date-dto.js.map +1 -0
- package/built/api/job-batches/index.js +5 -0
- package/built/api/job-batches/index.js.map +1 -1
- package/built/api/job-batches/params/batch-item-status.d.ts +1 -0
- package/built/api/job-batches/params/batch-item-status.js +1 -0
- package/built/api/job-batches/params/batch-item-status.js.map +1 -1
- package/built/api/job-batches/params/create-batch-parameters.d.ts +3 -1
- package/built/api/job-batches/params/create-batch-parameters.js +6 -5
- package/built/api/job-batches/params/create-batch-parameters.js.map +1 -1
- package/built/api/job-batches/params/list-batches-parameters.js +1 -1
- package/built/api/job-batches/params/list-batches-parameters.js.map +1 -1
- package/built/api/job-batches/params/upload-batch-file-parameters.d.ts +3 -0
- package/built/api/job-batches/params/upload-batch-file-parameters.js +4 -0
- package/built/api/job-batches/params/upload-batch-file-parameters.js.map +1 -1
- 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/built/test/files.spec.js +61 -0
- package/built/test/files.spec.js.map +1 -1
- package/built/test/job-batches.spec.js +37 -4
- package/built/test/job-batches.spec.js.map +1 -1
- package/docs/superpowers/specs/2026-09-18-mcp-upstream-fixes-design.md +74 -0
- package/index.ts +7 -0
- package/package.json +1 -1
- package/test/files.spec.ts +103 -0
- package/test/job-batches.spec.ts +70 -4
package/index.ts
CHANGED
|
@@ -43,7 +43,9 @@ export * from "./api/files/params/file-filter";
|
|
|
43
43
|
export * from "./api/files/params/file-locale-mode";
|
|
44
44
|
export * from "./api/files/params/file-locales";
|
|
45
45
|
export * from "./api/files/params/recently-uploaded-files";
|
|
46
|
+
export * from "./api/files/params/files-order-by";
|
|
46
47
|
export * from "./api/files/params/retrieval-type";
|
|
48
|
+
export * from "./api/files/params/page-count-status";
|
|
47
49
|
export * from "./api/files/params/file-type";
|
|
48
50
|
export * from "./api/files/params/filename-mode";
|
|
49
51
|
export * from "./api/files/params/translation-file-name-mode";
|
|
@@ -52,9 +54,11 @@ export * from "./api/files/params/import-file-parameters";
|
|
|
52
54
|
export * from "./api/files/params/translation-state";
|
|
53
55
|
export * from "./api/files/dto/file-status-for-all-locales-dto";
|
|
54
56
|
export * from "./api/files/dto/file-status-for-locale-item-dto";
|
|
57
|
+
export * from "./api/files/dto/file-namespace-dto";
|
|
55
58
|
export * from "./api/files/dto/last-modified-for-locale-dto";
|
|
56
59
|
export * from "./api/files/dto/uploaded-file-dto";
|
|
57
60
|
export * from "./api/files/dto/imported-file-dto";
|
|
61
|
+
export * from "./api/files/dto/file-status-for-project-dto";
|
|
58
62
|
export * from "./api/glossaries/index";
|
|
59
63
|
export * from "./api/glossaries/dto/glossary-dto";
|
|
60
64
|
export * from "./api/glossaries/dto/fallback-locale-dto";
|
|
@@ -85,6 +89,9 @@ export * from "./api/job-batches/dto/batch-status-dto";
|
|
|
85
89
|
export * from "./api/job-batches/dto/batch-list-item-dto";
|
|
86
90
|
export * from "./api/job-batches/dto/job-batches-parameters-mode";
|
|
87
91
|
export * from "./api/job-batches/dto/job-batches-parameters-salt";
|
|
92
|
+
export * from "./api/job-batches/dto/locale-workflow-content-assignment-dto";
|
|
93
|
+
export * from "./api/job-batches/dto/translation-job-workflow-step-due-date-dto";
|
|
94
|
+
export * from "./api/job-batches/dto/locale-workflow-dto";
|
|
88
95
|
export * from "./api/job-batches/params/create-batch-parameters";
|
|
89
96
|
export * from "./api/job-batches/params/job-batches-parameters";
|
|
90
97
|
export * from "./api/job-batches/params/upload-batch-file-parameters";
|
package/package.json
CHANGED
package/test/files.spec.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { FileType } from "../api/files/params/file-type";
|
|
|
12
12
|
import { streamToString } from "./stream-to-string";
|
|
13
13
|
import { DownloadFileAllTranslationsParameters } from "../api/files/params/download-file-all-translations-parameters";
|
|
14
14
|
import { RecentlyUploadedFilesParameters } from "../api/files/params/recently-uploaded-files";
|
|
15
|
+
import { FilesOrderBy } from "../api/files/params/files-order-by";
|
|
15
16
|
import { FileNameMode } from "../api/files/params/filename-mode";
|
|
16
17
|
import { DownloadMultipleFilesTranslationsParameters } from "../api/files/params/download-multiple-files-translations-parameters";
|
|
17
18
|
import { FileLocales } from "../api/files/params/file-locales";
|
|
@@ -91,6 +92,33 @@ describe("SmartlingFilesApi class tests.", () => {
|
|
|
91
92
|
);
|
|
92
93
|
});
|
|
93
94
|
|
|
95
|
+
it("Get recently uploaded files for project with all filters", async () => {
|
|
96
|
+
const params = new RecentlyUploadedFilesParameters()
|
|
97
|
+
.setOffset(0)
|
|
98
|
+
.setLimit(99)
|
|
99
|
+
.setUriMask("TEST")
|
|
100
|
+
.setFileTypes([FileType.JSON, FileType.XML])
|
|
101
|
+
.setLastUploadedAfter(new Date("2020-01-01T00:00:00.000Z"))
|
|
102
|
+
.setLastUploadedBefore(new Date("2020-02-01T00:00:00.000Z"))
|
|
103
|
+
.setOrderBy(FilesOrderBy.LAST_UPLOADED_DESC);
|
|
104
|
+
|
|
105
|
+
await filesApi.getRecentlyUploadedFiles(projectId, params);
|
|
106
|
+
|
|
107
|
+
sinon.assert.calledOnce(filesApiFetchStub);
|
|
108
|
+
sinon.assert.calledWithExactly(
|
|
109
|
+
filesApiFetchStub,
|
|
110
|
+
`https://test.com/files-api/v2/projects/${projectId}/files/list?offset=0&limit=99&uriMask=TEST&fileTypes%5B%5D=json&fileTypes%5B%5D=xml&lastUploadedAfter=2020-01-01T00%3A00%3A00Z&lastUploadedBefore=2020-02-01T00%3A00%3A00Z&orderBy=lastUploaded_desc`,
|
|
111
|
+
{
|
|
112
|
+
headers: {
|
|
113
|
+
Authorization: "test_token_type test_access_token",
|
|
114
|
+
"Content-Type": "application/json",
|
|
115
|
+
"User-Agent": "test_user_agent"
|
|
116
|
+
},
|
|
117
|
+
method: "get"
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
|
|
94
122
|
it("Get last modified", async () => {
|
|
95
123
|
await filesApi.getLastModified(projectId, fileUri);
|
|
96
124
|
|
|
@@ -518,6 +546,53 @@ describe("SmartlingFilesApi class tests.", () => {
|
|
|
518
546
|
}
|
|
519
547
|
);
|
|
520
548
|
});
|
|
549
|
+
|
|
550
|
+
it("Supports zip file name parameter", async () => {
|
|
551
|
+
params.setZipFileName("custom-name.zip");
|
|
552
|
+
|
|
553
|
+
await filesApi.downloadFileAllTranslations(projectId, fileUri, params);
|
|
554
|
+
|
|
555
|
+
sinon.assert.calledOnce(filesApiFetchStub);
|
|
556
|
+
sinon.assert.calledWithExactly(
|
|
557
|
+
filesApiFetchStub,
|
|
558
|
+
`https://test.com/files-api/v2/projects/${projectId}/locales/all/file/zip?zipFileName=custom-name.zip&fileUri=testFileUri`,
|
|
559
|
+
{
|
|
560
|
+
headers: {
|
|
561
|
+
Authorization: "test_token_type test_access_token",
|
|
562
|
+
"Content-Type": "application/json",
|
|
563
|
+
"User-Agent": "test_user_agent"
|
|
564
|
+
},
|
|
565
|
+
method: "get"
|
|
566
|
+
}
|
|
567
|
+
);
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
it("Returns an ArrayBuffer", async () => {
|
|
571
|
+
const result = await filesApi
|
|
572
|
+
.downloadFileAllTranslations(projectId, fileUri, params);
|
|
573
|
+
|
|
574
|
+
assert.ok(result instanceof ArrayBuffer);
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
it("Supports contextMatchingInstrumented retrieval type", async () => {
|
|
578
|
+
params.setRetrievalType(RetrievalType.CONTEXT_MATCHING_INSTRUMENTED);
|
|
579
|
+
|
|
580
|
+
await filesApi.downloadFileAllTranslations(projectId, fileUri, params);
|
|
581
|
+
|
|
582
|
+
sinon.assert.calledOnce(filesApiFetchStub);
|
|
583
|
+
sinon.assert.calledWithExactly(
|
|
584
|
+
filesApiFetchStub,
|
|
585
|
+
`https://test.com/files-api/v2/projects/${projectId}/locales/all/file/zip?retrievalType=contextMatchingInstrumented&fileUri=testFileUri`,
|
|
586
|
+
{
|
|
587
|
+
headers: {
|
|
588
|
+
Authorization: "test_token_type test_access_token",
|
|
589
|
+
"Content-Type": "application/json",
|
|
590
|
+
"User-Agent": "test_user_agent"
|
|
591
|
+
},
|
|
592
|
+
method: "get"
|
|
593
|
+
}
|
|
594
|
+
);
|
|
595
|
+
});
|
|
521
596
|
});
|
|
522
597
|
|
|
523
598
|
it("Delete file", async () => {
|
|
@@ -556,6 +631,34 @@ describe("SmartlingFilesApi class tests.", () => {
|
|
|
556
631
|
);
|
|
557
632
|
});
|
|
558
633
|
|
|
634
|
+
it("Rename file", async () => {
|
|
635
|
+
await filesApi.renameFile(projectId, fileUri, "newTestFileUri");
|
|
636
|
+
|
|
637
|
+
sinon.assert.calledOnce(filesApiFetchStub);
|
|
638
|
+
|
|
639
|
+
assert.equal(
|
|
640
|
+
filesApiFetchStub.getCall(0).args[0],
|
|
641
|
+
`https://test.com/files-api/v2/projects/${projectId}/file/rename`
|
|
642
|
+
);
|
|
643
|
+
|
|
644
|
+
assert.equal(
|
|
645
|
+
filesApiFetchStub.getCall(0).args[1].method,
|
|
646
|
+
"post"
|
|
647
|
+
);
|
|
648
|
+
|
|
649
|
+
const body = filesApiFetchStub.getCall(0).args[1].body.getBuffer().toString();
|
|
650
|
+
|
|
651
|
+
assert.equal(
|
|
652
|
+
body.includes(`Content-Disposition: form-data; name="fileUri"\r\n\r\n${fileUri}`),
|
|
653
|
+
true
|
|
654
|
+
);
|
|
655
|
+
|
|
656
|
+
assert.equal(
|
|
657
|
+
body.includes("Content-Disposition: form-data; name=\"newFileUri\"\r\n\r\nnewTestFileUri"),
|
|
658
|
+
true
|
|
659
|
+
);
|
|
660
|
+
});
|
|
661
|
+
|
|
559
662
|
it("Upload file: from disk", async () => {
|
|
560
663
|
const params = new UploadFileParameters();
|
|
561
664
|
|
package/test/job-batches.spec.ts
CHANGED
|
@@ -52,10 +52,23 @@ describe("SmartlingJobBatchesAPI class tests.", () => {
|
|
|
52
52
|
params
|
|
53
53
|
.setTranslationJobUid(jobUid)
|
|
54
54
|
.setAuthorize(true)
|
|
55
|
+
.setRushJob(true)
|
|
55
56
|
.addFileUri("test_file_uri_1")
|
|
56
57
|
.addFileUri("test_file_uri_2")
|
|
57
|
-
.
|
|
58
|
-
|
|
58
|
+
.addLocaleWorkflow({
|
|
59
|
+
targetLocaleId: "fr",
|
|
60
|
+
workflowUid: "wf1",
|
|
61
|
+
contentAssignments: [
|
|
62
|
+
{ workflowStepUid: "step1", userUids: ["user1"] }
|
|
63
|
+
],
|
|
64
|
+
translationJobWorkflowStepDueDates: [
|
|
65
|
+
{ workflowStepUid: "step1", dueDate: "2026-12-31T23:59:59Z" }
|
|
66
|
+
]
|
|
67
|
+
})
|
|
68
|
+
.addLocaleWorkflow({
|
|
69
|
+
targetLocaleId: "de",
|
|
70
|
+
workflowUid: "wf2"
|
|
71
|
+
});
|
|
59
72
|
|
|
60
73
|
await jobBatchesApi.createBatch(projectId, params);
|
|
61
74
|
|
|
@@ -64,7 +77,7 @@ describe("SmartlingJobBatchesAPI class tests.", () => {
|
|
|
64
77
|
jobBatchesApiFetchStub,
|
|
65
78
|
`https://test.com/job-batches-api/v2/projects/${projectId}/batches`,
|
|
66
79
|
{
|
|
67
|
-
body: "{\"fileUris\":[\"test_file_uri_1\",\"test_file_uri_2\"],\"localeWorkflows\":[{\"targetLocaleId\":\"fr\",\"workflowUid\":\"wf1\"},{\"targetLocaleId\":\"de\",\"workflowUid\":\"wf2\"}],\"translationJobUid\":\"testJobUid\",\"authorize\":true}",
|
|
80
|
+
body: "{\"fileUris\":[\"test_file_uri_1\",\"test_file_uri_2\"],\"localeWorkflows\":[{\"targetLocaleId\":\"fr\",\"workflowUid\":\"wf1\",\"contentAssignments\":[{\"workflowStepUid\":\"step1\",\"userUids\":[\"user1\"]}],\"translationJobWorkflowStepDueDates\":[{\"workflowStepUid\":\"step1\",\"dueDate\":\"2026-12-31T23:59:59Z\"}]},{\"targetLocaleId\":\"de\",\"workflowUid\":\"wf2\"}],\"translationJobUid\":\"testJobUid\",\"authorize\":true,\"rushJob\":true}",
|
|
68
81
|
headers: {
|
|
69
82
|
Authorization: "test_token_type test_access_token",
|
|
70
83
|
"Content-Type": "application/json",
|
|
@@ -246,6 +259,59 @@ describe("SmartlingJobBatchesAPI class tests.", () => {
|
|
|
246
259
|
);
|
|
247
260
|
});
|
|
248
261
|
|
|
262
|
+
it("Upload batch file: from buffer", async () => {
|
|
263
|
+
const params = new UploadBatchFileParameters();
|
|
264
|
+
|
|
265
|
+
params
|
|
266
|
+
.setFileContentFromBuffer(fs.readFileSync(
|
|
267
|
+
fs.realpathSync("./test/data/file.xml")
|
|
268
|
+
))
|
|
269
|
+
.setFileUri("test-file-uri")
|
|
270
|
+
.setFileType(FileType.XML)
|
|
271
|
+
.setDirective("foo", "bar")
|
|
272
|
+
.setLocalesToApprove(["fr-FR", "de-DE"])
|
|
273
|
+
.setCallbackUrl("testCallbackUrl")
|
|
274
|
+
.setClientLibId("clientLibId", "clientLibVersion");
|
|
275
|
+
|
|
276
|
+
await jobBatchesApi.uploadBatchFile(projectId, batchUid, params);
|
|
277
|
+
|
|
278
|
+
sinon.assert.calledOnce(jobBatchesApiFetchStub);
|
|
279
|
+
|
|
280
|
+
assert.equal(
|
|
281
|
+
jobBatchesApiFetchStub.getCall(0).args[0],
|
|
282
|
+
`https://test.com/job-batches-api/v2/projects/${projectId}/batches/${batchUid}/file`
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
assert.equal(
|
|
286
|
+
jobBatchesApiFetchStub.getCall(0).args[1].method,
|
|
287
|
+
"post"
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
assert.equal(
|
|
291
|
+
jobBatchesApiFetchStub.getCall(0).args[1].headers.Authorization,
|
|
292
|
+
"test_token_type test_access_token"
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
assert.equal(
|
|
296
|
+
jobBatchesApiFetchStub.getCall(0).args[1].headers["User-Agent"],
|
|
297
|
+
"test_user_agent"
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
const expectedBuffer = fs.readFileSync(
|
|
301
|
+
fs.realpathSync("./test/data/file.xml")
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
assert.ok(
|
|
305
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
306
|
+
jobBatchesApiFetchStub.getCall(0).args[1].body._streams[1].equals(expectedBuffer)
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
assert.ok(
|
|
310
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
311
|
+
jobBatchesApiFetchStub.getCall(0).args[1].body._streams[0].includes("filename=")
|
|
312
|
+
);
|
|
313
|
+
});
|
|
314
|
+
|
|
249
315
|
it("Get batch status", async () => {
|
|
250
316
|
await jobBatchesApi.getBatchStatus(projectId, batchUid);
|
|
251
317
|
|
|
@@ -279,7 +345,7 @@ describe("SmartlingJobBatchesAPI class tests.", () => {
|
|
|
279
345
|
sinon.assert.calledOnce(jobBatchesApiFetchStub);
|
|
280
346
|
sinon.assert.calledWithExactly(
|
|
281
347
|
jobBatchesApiFetchStub,
|
|
282
|
-
`https://test.com/job-batches-api/v2/projects/${projectId}/batches?translationJobUid=${jobUid}&limit=100&offset=10&status=${BatchStatus.COMPLETED}&sortBy=${sortByParam}&
|
|
348
|
+
`https://test.com/job-batches-api/v2/projects/${projectId}/batches?translationJobUid=${jobUid}&limit=100&offset=10&status=${BatchStatus.COMPLETED}&sortBy=${sortByParam}&orderBy=${Order.ASC}`,
|
|
283
349
|
{
|
|
284
350
|
method: "get",
|
|
285
351
|
headers: {
|