Skip to content

Commit

Permalink
FIX - API Import Return Type (#17)
Browse files Browse the repository at this point in the history
* 馃悰 fix: `api.import.json` return type

* 鈾伙笍 refactor: use `ReturnType`

---------

Co-authored-by: david-vaclavek <[email protected]>
  • Loading branch information
david-vaclavek and david-vaclavek committed Apr 23, 2024
1 parent d7a5095 commit 10ec450
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/api/methods/api-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export class ApiImport extends ApiBase {
*
* @see {@link https://localazy.com/docs/api/import#import-content-to-a-project Localazy API Docs}
*/
public async json(request: ImportJsonRequest, config?: RequestConfig): Promise<File> {
public async json(
request: ImportJsonRequest,
config?: RequestConfig,
): Promise<ReturnType<ApiImport['getImportedFile']>> {
const { project, json }: ImportJsonRequest = request;
const projectId: string = ApiBase.getId(project, 'project');
const chunks: I18nJson[] = JsonUtils.slice(json);
Expand All @@ -36,7 +39,11 @@ export class ApiImport extends ApiBase {
return this.getImportedFile(project, data, result);
}

protected async getImportedFile(project: string | Project, data: ImportData, importBatch: string): Promise<File> {
protected async getImportedFile(
project: string | Project,
data: ImportData,
importBatch: string,
): Promise<File & { importBatch: string }> {
const files: File[] = await this.api.files.list({ project });
const file: File | undefined = files.find((f: File): boolean =>
data.files.some(
Expand Down

0 comments on commit 10ec450

Please sign in to comment.