Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 118 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"author": "Jan Cizmar",
"license": "MIT",
"dependencies": {
"@stomp/stompjs": "^7.1.1",
"ajv": "^8.17.1",
"ansi-colors": "^4.1.3",
"base32-decode": "^1.0.0",
Expand All @@ -38,10 +39,12 @@
"json5": "^2.2.3",
"jsonschema": "^1.5.0",
"openapi-fetch": "0.13.1",
"sockjs-client": "^1.6.1",
"tinyglobby": "^0.2.12",
"unescape-js": "^1.1.4",
"vscode-oniguruma": "^2.0.1",
"vscode-textmate": "^9.1.0",
"ws": "^8.18.3",
"yauzl": "^3.2.0"
},
"devDependencies": {
Expand Down
12 changes: 10 additions & 2 deletions src/client/ExportClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { ApiClient } from './ApiClient.js';
export type ExportRequest = Omit<
BodyOf<'/v2/projects/{projectId}/export', 'post'>,
'zip'
>;
> & {
ifModifiedSince?: string;
};

type SingleExportRequest = Omit<ExportRequest, 'languages'> & {
languages: [string];
Expand All @@ -18,10 +20,16 @@ type ExportClientProps = {
export const createExportClient = ({ apiClient }: ExportClientProps) => {
return {
async export(req: ExportRequest) {
const body = { ...req, zip: true };
const { ifModifiedSince, ...exportReq } = req;
const body = { ...exportReq, zip: true };
const headers: Record<string, string> = {};
if (ifModifiedSince) {
headers['If-Modified-Since'] = ifModifiedSince;
}
const loadable = await apiClient.POST('/v2/projects/{projectId}/export', {
params: { path: { projectId: apiClient.getProjectId() } },
body: body,
headers,
parseAs: 'blob',
});
return { ...loadable, data: loadable.data as unknown as Blob };
Expand Down
8 changes: 7 additions & 1 deletion src/client/TolgeeClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { exitWithError } from './../utils/logger.js';

Check warning on line 1 in src/client/TolgeeClient.ts

View workflow job for this annotation

GitHub Actions / ESLint

'exitWithError' is defined but never used. Allowed unused vars must match /^_/u
import { ApiClientProps, createApiClient } from './ApiClient.js';
import { createExportClient } from './ExportClient.js';
import { createImportClient } from './ImportClient.js';
Expand All @@ -22,8 +22,14 @@

export const handleLoadableError = (loadable: LoadableData) => {
if (loadable.error) {
exitWithError(errorFromLoadable(loadable));
throw new LoadableError(loadable);
}
};

export class LoadableError extends Error {
constructor(public loadable: LoadableData) {
super(errorFromLoadable(loadable));
}
}

export type TolgeeClient = ReturnType<typeof createTolgeeClient>;
Loading
Loading