Skip to content

Commit 6db9a52

Browse files
authored
feat: import options in updateOrCreateFile (#71)
1 parent ea2b2d8 commit 6db9a52

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@crowdin/crowdin-apps-functions",
3-
"version": "0.12.0",
3+
"version": "0.12.1",
44
"description": "Utility library to easily and quickly develop Crowdin App",
55
"main": "out/index.js",
66
"types": "out/index.d.ts",

src/crowdin.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ interface UpdateOrCreateFileArgs {
1717
data: any;
1818
file?: SourceFilesModel.File;
1919
excludedTargetLanguages?: string[];
20+
importOptions?: SourceFilesModel.ImportOptions;
2021
}
2122

2223
function isUpdateOrCreateFileArgs(arg: Crowdin | UpdateOrCreateFileArgs): arg is UpdateOrCreateFileArgs {
@@ -61,6 +62,7 @@ export async function updateOrCreateFile(
6162
data?: any,
6263
file?: SourceFilesModel.File,
6364
excludedTargetLanguages?: string[],
65+
importOptions?: SourceFilesModel.ImportOptions,
6466
): Promise<number> {
6567
let options: UpdateOrCreateFileArgs;
6668
if (isUpdateOrCreateFileArgs(clientOrArgs)) {
@@ -78,12 +80,14 @@ export async function updateOrCreateFile(
7880
data,
7981
file,
8082
excludedTargetLanguages,
83+
importOptions,
8184
};
8285
}
8386
const storageFile = await options.client.uploadStorageApi.addStorage(options.name, options.data);
8487
if (options.file) {
8588
await options.client.sourceFilesApi.updateOrRestoreFile(options.projectId, options.file.id, {
8689
storageId: storageFile.data.id,
90+
...(options.importOptions && { importOptions: options.importOptions }),
8791
});
8892

8993
const updates: PatchRequest[] = [];
@@ -117,6 +121,7 @@ export async function updateOrCreateFile(
117121
type: options.type,
118122
directoryId: options.directoryId,
119123
excludedTargetLanguages: options.excludedTargetLanguages,
124+
importOptions: options.importOptions,
120125
});
121126

122127
return newFile.data.id;

tests/crowdin.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ describe('UpdateOrCreateFile function', () => {
6565
title: 'title',
6666
data: 'auto',
6767
directoryId: 2,
68+
importOptions: {
69+
contentSegmentation: false,
70+
},
6871
}).then(result => {
6972
expect(result).toBe(0);
7073
expect(spyProjectId).toBe(1);
@@ -75,6 +78,9 @@ describe('UpdateOrCreateFile function', () => {
7578
directoryId: 2,
7679
type: undefined,
7780
excludedTargetLanguages: undefined,
81+
importOptions: {
82+
contentSegmentation: false,
83+
},
7884
});
7985
});
8086
});

0 commit comments

Comments
 (0)