@crowdin/app-project-module 0.63.2 → 0.64.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/out/modules/integration/handlers/user-errors.js +1 -1
- package/out/modules/integration/util/job.js +19 -11
- package/out/modules/integration/util/types.d.ts +7 -4
- package/out/storage/index.d.ts +3 -2
- package/out/storage/mysql.d.ts +3 -2
- package/out/storage/mysql.js +14 -1
- package/out/storage/postgre.d.ts +3 -2
- package/out/storage/postgre.js +15 -2
- package/out/storage/sqlite.d.ts +3 -2
- package/out/storage/sqlite.js +10 -1
- package/out/views/main.handlebars +5 -0
- package/package.json +1 -1
|
@@ -31,7 +31,7 @@ function handle() {
|
|
|
31
31
|
hour12: false,
|
|
32
32
|
timeZone: userTimezone,
|
|
33
33
|
}).format(date);
|
|
34
|
-
return Object.assign(Object.assign({}, userError), {
|
|
34
|
+
return Object.assign(Object.assign({}, userError), { formattedDate });
|
|
35
35
|
});
|
|
36
36
|
req.logInfo(`Returning ${userErrors === null || userErrors === void 0 ? void 0 : userErrors.length} user errors`);
|
|
37
37
|
res.send(userErrors);
|
|
@@ -67,7 +67,7 @@ function runAsJob({ integrationId, crowdinId, type, title, payload, res, project
|
|
|
67
67
|
},
|
|
68
68
|
type: jobType,
|
|
69
69
|
fetchTranslation: ({ fileId, languageId }) => __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
const translationCache = yield storage.
|
|
70
|
+
const translationCache = yield storage.getFileTranslationCacheByLanguage({
|
|
71
71
|
integrationId,
|
|
72
72
|
crowdinId,
|
|
73
73
|
fileId,
|
|
@@ -89,20 +89,28 @@ function runAsJob({ integrationId, crowdinId, type, title, payload, res, project
|
|
|
89
89
|
}
|
|
90
90
|
return translation;
|
|
91
91
|
}),
|
|
92
|
-
translationUploaded: ({ fileId, languageId, etag }) =>
|
|
93
|
-
|
|
92
|
+
// translationUploaded: async ({ fileId, languageId, etag }) => {
|
|
93
|
+
translationUploaded: ({ fileId, translationParams }) => __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
const translationCache = (yield storage.getFileTranslationCache({
|
|
94
95
|
integrationId,
|
|
95
96
|
crowdinId,
|
|
96
97
|
fileId,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
98
|
+
})) || [];
|
|
99
|
+
const cacheMap = new Map(translationCache.map((cache) => [cache.languageId, cache]));
|
|
100
|
+
const updates = [];
|
|
101
|
+
const inserts = [];
|
|
102
|
+
for (const { languageId, etag } of translationParams) {
|
|
103
|
+
const cache = cacheMap.get(languageId);
|
|
104
|
+
if (cache) {
|
|
105
|
+
(0, logger_1.log)(`Updating etag translation for file ${fileId} in language ${languageId}`);
|
|
106
|
+
updates.push(storage.updateTranslationCache({ integrationId, crowdinId, fileId, languageId, etag }));
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
(0, logger_1.log)(`Saving new etag translation for file ${fileId} in language ${languageId}`);
|
|
110
|
+
inserts.push(storage.saveTranslationCache({ integrationId, crowdinId, fileId, languageId, etag }));
|
|
111
|
+
}
|
|
105
112
|
}
|
|
113
|
+
yield Promise.all([...updates, ...inserts]);
|
|
106
114
|
}),
|
|
107
115
|
};
|
|
108
116
|
try {
|
|
@@ -67,10 +67,12 @@ export interface GetAllNewFilesArgs {
|
|
|
67
67
|
integrationSettings: any;
|
|
68
68
|
syncSettings: IntegrationSyncSettings;
|
|
69
69
|
}
|
|
70
|
-
export type SaveUploadedFileTranslation = ({ fileId,
|
|
70
|
+
export type SaveUploadedFileTranslation = ({ fileId, translationParams, }: {
|
|
71
71
|
fileId: number;
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
translationParams: {
|
|
73
|
+
languageId: string;
|
|
74
|
+
etag: string;
|
|
75
|
+
}[];
|
|
74
76
|
}) => Promise<void>;
|
|
75
77
|
export type FetchTranslation = ({ fileId, languageId, }: {
|
|
76
78
|
fileId: number;
|
|
@@ -83,5 +85,6 @@ export interface TranslationCache {
|
|
|
83
85
|
languageId: string;
|
|
84
86
|
etag?: string;
|
|
85
87
|
}
|
|
86
|
-
export type
|
|
88
|
+
export type GetFileTranslationCache = Pick<TranslationCache, 'integrationId' | 'crowdinId' | 'fileId'>;
|
|
89
|
+
export type GetFileTranslationCacheByLanguageParams = Pick<TranslationCache, 'integrationId' | 'crowdinId' | 'fileId' | 'languageId'>;
|
|
87
90
|
export type UpdateTranslationCacheParams = Pick<TranslationCache, 'integrationId' | 'crowdinId' | 'fileId' | 'languageId' | 'etag'>;
|
package/out/storage/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IntegrationConfig, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncSettings, IntegrationWebhooks, Provider } from '../modules/integration/types';
|
|
2
2
|
import { Config, CrowdinCredentials, UnauthorizedConfig } from '../types';
|
|
3
|
-
import { CreateJobParams, GetActiveJobsParams, GetJobParams,
|
|
3
|
+
import { CreateJobParams, GetActiveJobsParams, GetJobParams, GetFileTranslationCacheByLanguageParams, Job, TranslationCache, UpdateJobParams, UpdateTranslationCacheParams, GetFileTranslationCache } from '../modules/integration/util/types';
|
|
4
4
|
import { UserErrors } from './types';
|
|
5
5
|
export interface Storage {
|
|
6
6
|
migrate(): Promise<void>;
|
|
@@ -44,7 +44,8 @@ export interface Storage {
|
|
|
44
44
|
getActiveJobs(params: GetActiveJobsParams): Promise<Job[] | undefined>;
|
|
45
45
|
deleteFinishedJobs(): Promise<void>;
|
|
46
46
|
saveTranslationCache(params: TranslationCache): Promise<void>;
|
|
47
|
-
|
|
47
|
+
getFileTranslationCache(params: GetFileTranslationCache): Promise<TranslationCache[] | undefined>;
|
|
48
|
+
getFileTranslationCacheByLanguage(params: GetFileTranslationCacheByLanguageParams): Promise<TranslationCache | undefined>;
|
|
48
49
|
updateTranslationCache(params: UpdateTranslationCacheParams): Promise<void>;
|
|
49
50
|
}
|
|
50
51
|
export declare function initialize(config: Config | UnauthorizedConfig): Promise<void>;
|
package/out/storage/mysql.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Storage } from '.';
|
|
2
2
|
import { CrowdinCredentials } from '../types';
|
|
3
|
-
import { CreateJobParams, GetActiveJobsParams, GetJobParams,
|
|
3
|
+
import { CreateJobParams, GetActiveJobsParams, GetJobParams, GetFileTranslationCacheByLanguageParams, Job, TranslationCache, UpdateJobParams, UpdateTranslationCacheParams, GetFileTranslationCache } from '../modules/integration/util/types';
|
|
4
4
|
import { IntegrationConfig, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncSettings, IntegrationWebhooks } from '../modules/integration/types';
|
|
5
5
|
import { UserErrors } from './types';
|
|
6
6
|
export interface MySQLStorageConfig {
|
|
@@ -61,6 +61,7 @@ export declare class MySQLStorage implements Storage {
|
|
|
61
61
|
getActiveJobs({ integrationId, crowdinId }: GetActiveJobsParams): Promise<Job[] | undefined>;
|
|
62
62
|
deleteFinishedJobs(): Promise<void>;
|
|
63
63
|
saveTranslationCache({ integrationId, crowdinId, fileId, languageId, etag, }: TranslationCache): Promise<void>;
|
|
64
|
-
|
|
64
|
+
getFileTranslationCache({ integrationId, crowdinId, fileId, }: GetFileTranslationCache): Promise<TranslationCache[] | undefined>;
|
|
65
|
+
getFileTranslationCacheByLanguage({ integrationId, crowdinId, fileId, languageId, }: GetFileTranslationCacheByLanguageParams): Promise<TranslationCache | undefined>;
|
|
65
66
|
updateTranslationCache({ integrationId, crowdinId, fileId, languageId, etag, }: UpdateTranslationCacheParams): Promise<void>;
|
|
66
67
|
}
|
package/out/storage/mysql.js
CHANGED
|
@@ -598,7 +598,20 @@ class MySQLStorage {
|
|
|
598
598
|
`, [integrationId, crowdinId, fileId, languageId, etag]));
|
|
599
599
|
});
|
|
600
600
|
}
|
|
601
|
-
|
|
601
|
+
getFileTranslationCache({ integrationId, crowdinId, fileId, }) {
|
|
602
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
603
|
+
yield this.dbPromise;
|
|
604
|
+
return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
|
|
605
|
+
const [rows] = yield connection.execute(`
|
|
606
|
+
SELECT integration_id as integrationId, crowdin_id as crowdinId, file_id as fileId, language_id as languageId, etag
|
|
607
|
+
FROM translation_file_cache
|
|
608
|
+
WHERE integration_id = ? AND crowdin_id = ? AND file_id = ?
|
|
609
|
+
`, [integrationId, crowdinId, fileId]);
|
|
610
|
+
return rows || [];
|
|
611
|
+
}));
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
getFileTranslationCacheByLanguage({ integrationId, crowdinId, fileId, languageId, }) {
|
|
602
615
|
return __awaiter(this, void 0, void 0, function* () {
|
|
603
616
|
yield this.dbPromise;
|
|
604
617
|
return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
|
package/out/storage/postgre.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Client } from 'pg';
|
|
|
2
2
|
import { Storage } from '.';
|
|
3
3
|
import { CrowdinCredentials } from '../types';
|
|
4
4
|
import { IntegrationConfig, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncSettings, IntegrationWebhooks } from '../modules/integration/types';
|
|
5
|
-
import { CreateJobParams, GetActiveJobsParams, GetJobParams,
|
|
5
|
+
import { CreateJobParams, GetActiveJobsParams, GetJobParams, GetFileTranslationCacheByLanguageParams, Job, TranslationCache, UpdateJobParams, UpdateTranslationCacheParams, GetFileTranslationCache } from '../modules/integration/util/types';
|
|
6
6
|
import { UserErrors } from './types';
|
|
7
7
|
export interface PostgreStorageConfig {
|
|
8
8
|
host?: string;
|
|
@@ -67,6 +67,7 @@ export declare class PostgreStorage implements Storage {
|
|
|
67
67
|
getActiveJobs({ integrationId, crowdinId }: GetActiveJobsParams): Promise<Job[] | undefined>;
|
|
68
68
|
deleteFinishedJobs(): Promise<void>;
|
|
69
69
|
saveTranslationCache({ integrationId, crowdinId, fileId, languageId, etag, }: TranslationCache): Promise<void>;
|
|
70
|
-
|
|
70
|
+
getFileTranslationCache({ integrationId, crowdinId, fileId, }: GetFileTranslationCache): Promise<TranslationCache[] | undefined>;
|
|
71
|
+
getFileTranslationCacheByLanguage({ integrationId, crowdinId, fileId, languageId, }: GetFileTranslationCacheByLanguageParams): Promise<TranslationCache | undefined>;
|
|
71
72
|
updateTranslationCache({ integrationId, crowdinId, fileId, languageId, etag, }: UpdateTranslationCacheParams): Promise<void>;
|
|
72
73
|
}
|
package/out/storage/postgre.js
CHANGED
|
@@ -51,7 +51,7 @@ class PostgreStorage {
|
|
|
51
51
|
yield this.executeQuery(this.addTables);
|
|
52
52
|
this._res && this._res();
|
|
53
53
|
// TODO: temporary code
|
|
54
|
-
yield this.executeQuery(this.alterTables);
|
|
54
|
+
yield this.executeQuery((client) => this.alterTables(client));
|
|
55
55
|
}
|
|
56
56
|
catch (e) {
|
|
57
57
|
console.error(e);
|
|
@@ -619,7 +619,20 @@ class PostgreStorage {
|
|
|
619
619
|
`, [integrationId, crowdinId, fileId, languageId, etag]));
|
|
620
620
|
});
|
|
621
621
|
}
|
|
622
|
-
|
|
622
|
+
getFileTranslationCache({ integrationId, crowdinId, fileId, }) {
|
|
623
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
624
|
+
yield this.dbPromise;
|
|
625
|
+
return this.executeQuery((client) => __awaiter(this, void 0, void 0, function* () {
|
|
626
|
+
const res = yield client.query(`
|
|
627
|
+
SELECT integration_id as integrationId, crowdin_id as crowdinId, file_id as fileId, language_id as languageId, etag
|
|
628
|
+
FROM translation_file_cache
|
|
629
|
+
WHERE integration_id = $1 AND crowdin_id = $2 AND file_id = $3
|
|
630
|
+
`, [integrationId, crowdinId, fileId]);
|
|
631
|
+
return (res === null || res === void 0 ? void 0 : res.rows) || [];
|
|
632
|
+
}));
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
getFileTranslationCacheByLanguage({ integrationId, crowdinId, fileId, languageId, }) {
|
|
623
636
|
return __awaiter(this, void 0, void 0, function* () {
|
|
624
637
|
yield this.dbPromise;
|
|
625
638
|
return this.executeQuery((client) => __awaiter(this, void 0, void 0, function* () {
|
package/out/storage/sqlite.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Storage } from '.';
|
|
2
2
|
import { CrowdinCredentials } from '../types';
|
|
3
3
|
import { IntegrationConfig, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncSettings, IntegrationWebhooks } from '../modules/integration/types';
|
|
4
|
-
import { CreateJobParams, GetActiveJobsParams, GetJobParams,
|
|
4
|
+
import { CreateJobParams, GetActiveJobsParams, GetJobParams, GetFileTranslationCacheByLanguageParams, Job, TranslationCache, UpdateJobParams, UpdateTranslationCacheParams, GetFileTranslationCache } from '../modules/integration/util/types';
|
|
5
5
|
import { UserErrors } from './types';
|
|
6
6
|
export interface SQLiteStorageConfig {
|
|
7
7
|
dbFolder: string;
|
|
@@ -62,6 +62,7 @@ export declare class SQLiteStorage implements Storage {
|
|
|
62
62
|
getActiveJobs({ integrationId, crowdinId }: GetActiveJobsParams): Promise<Job[] | undefined>;
|
|
63
63
|
deleteFinishedJobs(): Promise<void>;
|
|
64
64
|
saveTranslationCache({ integrationId, crowdinId, fileId, languageId, etag }: TranslationCache): Promise<void>;
|
|
65
|
-
|
|
65
|
+
getFileTranslationCache({ integrationId, crowdinId, fileId, }: GetFileTranslationCache): Promise<TranslationCache[] | undefined>;
|
|
66
|
+
getFileTranslationCacheByLanguage({ integrationId, crowdinId, fileId, languageId, }: GetFileTranslationCacheByLanguageParams): Promise<TranslationCache | undefined>;
|
|
66
67
|
updateTranslationCache({ integrationId, crowdinId, fileId, languageId, etag, }: UpdateTranslationCacheParams): Promise<void>;
|
|
67
68
|
}
|
package/out/storage/sqlite.js
CHANGED
|
@@ -594,7 +594,16 @@ class SQLiteStorage {
|
|
|
594
594
|
VALUES (?, ?, ?, ?, ?)
|
|
595
595
|
`, [integrationId, crowdinId, fileId, languageId, etag]);
|
|
596
596
|
}
|
|
597
|
-
|
|
597
|
+
getFileTranslationCache({ integrationId, crowdinId, fileId, }) {
|
|
598
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
599
|
+
return this.each(`
|
|
600
|
+
SELECT integration_id as integrationId, crowdin_id as crowdinId, file_id as fileId, language_id as languageId, etag
|
|
601
|
+
FROM translation_file_cache
|
|
602
|
+
WHERE integration_id = ? AND crowdin_id = ? AND file_id = ?
|
|
603
|
+
`, [integrationId, crowdinId, fileId]);
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
getFileTranslationCacheByLanguage({ integrationId, crowdinId, fileId, languageId, }) {
|
|
598
607
|
return __awaiter(this, void 0, void 0, function* () {
|
|
599
608
|
const row = yield this.get(`
|
|
600
609
|
SELECT integration_id as integrationId, crowdin_id as crowdinId, file_id as fileId, language_id as languageId, etag
|
|
@@ -1143,6 +1143,10 @@
|
|
|
1143
1143
|
modal.innerHTML = getUserErrorDetail(item);
|
|
1144
1144
|
};
|
|
1145
1145
|
|
|
1146
|
+
const formatDate = (field, index, item) => {
|
|
1147
|
+
return item.formattedDate;
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1146
1150
|
table.setTableConfig && table.setTableConfig({
|
|
1147
1151
|
defaultSortingColumn: "createdAt",
|
|
1148
1152
|
defaultSortingDir: "desc",
|
|
@@ -1152,6 +1156,7 @@
|
|
|
1152
1156
|
name: "Date",
|
|
1153
1157
|
isSortable: true,
|
|
1154
1158
|
clickFn: clickRow,
|
|
1159
|
+
formatFn: formatDate,
|
|
1155
1160
|
},
|
|
1156
1161
|
{
|
|
1157
1162
|
field: "action",
|
package/package.json
CHANGED