@crowdin/app-project-module 0.32.2 → 0.33.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/handlers/file-processing/custom-file-format.js +3 -2
- package/out/handlers/integration/crowdin-update.js +1 -10
- package/out/index.js +0 -2
- package/out/models/index.d.ts +8 -12
- package/out/storage/index.d.ts +1 -4
- package/out/storage/mysql.d.ts +1 -4
- package/out/storage/mysql.js +0 -38
- package/out/storage/postgre.d.ts +1 -4
- package/out/storage/postgre.js +0 -38
- package/out/storage/sqlite.d.ts +1 -4
- package/out/storage/sqlite.js +0 -31
- package/out/util/defaults.js +7 -4
- package/out/views/main.handlebars +24 -73
- package/package.json +1 -1
- package/out/handlers/integration/synced-files.d.ts +0 -3
- package/out/handlers/integration/synced-files.js +0 -26
- package/out/util/synced-files.d.ts +0 -2
- package/out/util/synced-files.js +0 -31
|
@@ -34,10 +34,11 @@ function handle(baseUrl, folder, config) {
|
|
|
34
34
|
req.logInfo(`Received request to process file ${JSON.stringify(logData, null, 2)}`);
|
|
35
35
|
let file;
|
|
36
36
|
if (body.file.content) {
|
|
37
|
-
file = Buffer.from(body.file.content, 'base64')
|
|
37
|
+
file = Buffer.from(body.file.content, 'base64');
|
|
38
38
|
}
|
|
39
39
|
else if (body.file.contentUrl) {
|
|
40
|
-
|
|
40
|
+
const rawContent = yield (0, files_1.getFileContent)(body.file.contentUrl);
|
|
41
|
+
file = Buffer.from(rawContent).toString('base64');
|
|
41
42
|
}
|
|
42
43
|
let response = {};
|
|
43
44
|
let error;
|
|
@@ -11,10 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const util_1 = require("../../util");
|
|
13
13
|
const defaults_1 = require("../../util/defaults");
|
|
14
|
-
const synced_files_1 = require("../../util/synced-files");
|
|
15
14
|
function handle(config, integration) {
|
|
16
15
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
var _a, _b
|
|
16
|
+
var _a, _b;
|
|
18
17
|
const projectId = req.crowdinContext.jwtPayload.context.project_id || (req === null || req === void 0 ? void 0 : req.body.projectId);
|
|
19
18
|
const uploadTranslations = req.query.uploadTranslations === 'true' || ((_a = req.body) === null || _a === void 0 ? void 0 : _a.uploadTranslations);
|
|
20
19
|
req.logInfo(`Updating crowdin project ${projectId}`);
|
|
@@ -28,18 +27,10 @@ function handle(config, integration) {
|
|
|
28
27
|
}
|
|
29
28
|
const result = yield integration.updateCrowdin(projectId, req.crowdinApiClient, req.integrationCredentials, req.body, rootFolder, req.integrationSettings, uploadTranslations);
|
|
30
29
|
let message;
|
|
31
|
-
let fileIds;
|
|
32
30
|
if ((0, util_1.isExtendedResultType)(result)) {
|
|
33
31
|
message = result.message;
|
|
34
|
-
fileIds = result.syncedFiles;
|
|
35
32
|
}
|
|
36
33
|
res.send({ message });
|
|
37
|
-
if ((_c = integration.filtering) === null || _c === void 0 ? void 0 : _c.syncStatus) {
|
|
38
|
-
if (!fileIds) {
|
|
39
|
-
fileIds = req.body.map((file) => file.id);
|
|
40
|
-
}
|
|
41
|
-
(0, synced_files_1.createOrUpdateSyncedFiles)({ req, fileIds });
|
|
42
|
-
}
|
|
43
34
|
}));
|
|
44
35
|
}
|
|
45
36
|
exports.default = handle;
|
package/out/index.js
CHANGED
|
@@ -63,7 +63,6 @@ const settings_save_1 = __importDefault(require("./handlers/integration/settings
|
|
|
63
63
|
const subscription_info_1 = __importDefault(require("./handlers/integration/subscription-info"));
|
|
64
64
|
const sync_settings_1 = __importDefault(require("./handlers/integration/sync-settings"));
|
|
65
65
|
const sync_settings_save_1 = __importDefault(require("./handlers/integration/sync-settings-save"));
|
|
66
|
-
const synced_files_1 = __importDefault(require("./handlers/integration/synced-files"));
|
|
67
66
|
const manifest_1 = __importDefault(require("./handlers/manifest"));
|
|
68
67
|
const subscription_paid_1 = __importDefault(require("./handlers/subscription-paid"));
|
|
69
68
|
const uninstall_1 = __importDefault(require("./handlers/uninstall"));
|
|
@@ -151,7 +150,6 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
151
150
|
app.post('/api/integration/update', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, integration_update_1.default)(config, integrationLogic));
|
|
152
151
|
app.get('/api/sync-settings/:provider', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, sync_settings_1.default)());
|
|
153
152
|
app.post('/api/sync-settings', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, sync_settings_save_1.default)(config, integrationLogic));
|
|
154
|
-
app.get('/api/synced-files', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, synced_files_1.default)());
|
|
155
153
|
if (integrationLogic.oauthLogin) {
|
|
156
154
|
app.get((0, defaults_1.getOauthRoute)(integrationLogic), (0, oauth_login_1.default)(config, integrationLogic));
|
|
157
155
|
app.post('/api/oauth-url', json_response_1.default, (0, crowdin_client_1.default)(config, false, false), (0, oauth_url_1.default)(config, integrationLogic));
|
package/out/models/index.d.ts
CHANGED
|
@@ -265,7 +265,6 @@ export interface IntegrationLogic {
|
|
|
265
265
|
};
|
|
266
266
|
filtering?: {
|
|
267
267
|
crowdinLanguages: boolean;
|
|
268
|
-
syncStatus: boolean;
|
|
269
268
|
};
|
|
270
269
|
/**
|
|
271
270
|
* Enable integration folder open event
|
|
@@ -447,7 +446,6 @@ export interface ExtendedResult<T> {
|
|
|
447
446
|
data?: T;
|
|
448
447
|
message?: string;
|
|
449
448
|
stopPagination?: boolean;
|
|
450
|
-
syncedFiles: string[];
|
|
451
449
|
}
|
|
452
450
|
export type TreeItem = File | Folder;
|
|
453
451
|
/**
|
|
@@ -456,6 +454,12 @@ export type TreeItem = File | Folder;
|
|
|
456
454
|
* 2 - branch
|
|
457
455
|
*/
|
|
458
456
|
type IntegrationTreeElementType = '0' | '1' | '2';
|
|
457
|
+
type LabelTreeElementType = 'primary' | 'secondary' | 'success' | 'warning' | 'info' | 'danger' | 'dark' | 'light';
|
|
458
|
+
export interface LabelTreeElement {
|
|
459
|
+
text: string;
|
|
460
|
+
type?: LabelTreeElementType;
|
|
461
|
+
color?: string;
|
|
462
|
+
}
|
|
459
463
|
export interface File {
|
|
460
464
|
id: string;
|
|
461
465
|
name: string;
|
|
@@ -463,6 +467,7 @@ export interface File {
|
|
|
463
467
|
parentId?: string;
|
|
464
468
|
nodeType?: IntegrationTreeElementType;
|
|
465
469
|
customContent?: string;
|
|
470
|
+
labels?: LabelTreeElement;
|
|
466
471
|
}
|
|
467
472
|
export interface Folder {
|
|
468
473
|
id: string;
|
|
@@ -470,6 +475,7 @@ export interface Folder {
|
|
|
470
475
|
parentId?: string;
|
|
471
476
|
nodeType?: IntegrationTreeElementType;
|
|
472
477
|
customContent?: string;
|
|
478
|
+
labels?: LabelTreeElement;
|
|
473
479
|
}
|
|
474
480
|
export interface IntegrationRequest extends CrowdinClientRequest {
|
|
475
481
|
integrationCredentials: any;
|
|
@@ -885,16 +891,6 @@ export interface UpdateCrowdinWebhookPayloadsArgs {
|
|
|
885
891
|
webhookData: any;
|
|
886
892
|
req: Request;
|
|
887
893
|
}
|
|
888
|
-
export interface CreateOrUpdateSyncedFilesArgs {
|
|
889
|
-
req: IntegrationRequest;
|
|
890
|
-
fileIds: string[];
|
|
891
|
-
}
|
|
892
|
-
export interface IntegrationSyncedFiles {
|
|
893
|
-
id: number;
|
|
894
|
-
fileIds?: any;
|
|
895
|
-
integrationId: string;
|
|
896
|
-
crowdinId: string;
|
|
897
|
-
}
|
|
898
894
|
export declare enum UserPermissions {
|
|
899
895
|
OWNER = "owner",
|
|
900
896
|
MANAGERS = "managers",
|
package/out/storage/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Config, CrowdinCredentials, IntegrationCredentials, IntegrationFilesSnapshot,
|
|
1
|
+
import { Config, CrowdinCredentials, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncSettings, Provider } from '../models';
|
|
2
2
|
export interface Storage {
|
|
3
3
|
migrate(): Promise<void>;
|
|
4
4
|
saveCrowdinCredentials(credentials: CrowdinCredentials): Promise<void>;
|
|
@@ -25,9 +25,6 @@ export interface Storage {
|
|
|
25
25
|
saveFilesSnapshot(files: any, integrationId: string, crowdinId: string, provider: Provider): Promise<void>;
|
|
26
26
|
updateFilesSnapshot(files: any, integrationId: string, crowdinId: string, provider: Provider): Promise<void>;
|
|
27
27
|
getFilesSnapshot(integrationId: string, crowdinId: string, provider: Provider): Promise<IntegrationFilesSnapshot | undefined>;
|
|
28
|
-
saveSyncedFiles(fileIds: any, integrationId: string, crowdinId: string): Promise<void>;
|
|
29
|
-
updateSyncedFiles(fileIds: any, integrationId: string, crowdinId: string): Promise<void>;
|
|
30
|
-
getSyncedFiles(integrationId: string, crowdinId: string): Promise<IntegrationSyncedFiles | undefined>;
|
|
31
28
|
}
|
|
32
29
|
export declare function initialize(config: Config): Promise<void>;
|
|
33
30
|
export declare function getStorage(): Storage;
|
package/out/storage/mysql.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Storage } from '.';
|
|
2
|
-
import { CrowdinCredentials, IntegrationCredentials, IntegrationFilesSnapshot,
|
|
2
|
+
import { CrowdinCredentials, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncSettings } from '../models';
|
|
3
3
|
export interface MySQLStorageConfig {
|
|
4
4
|
uri?: string;
|
|
5
5
|
host?: string;
|
|
@@ -42,7 +42,4 @@ export declare class MySQLStorage implements Storage {
|
|
|
42
42
|
saveFilesSnapshot(files: any, integrationId: string, crowdinId: string, provider: string): Promise<void>;
|
|
43
43
|
updateFilesSnapshot(files: any, integrationId: string, crowdinId: string, provider: string): Promise<void>;
|
|
44
44
|
getFilesSnapshot(integrationId: string, crowdinId: string, provider: string): Promise<IntegrationFilesSnapshot | undefined>;
|
|
45
|
-
saveSyncedFiles(fileIds: any, integrationId: string, crowdinId: string): Promise<void>;
|
|
46
|
-
updateSyncedFiles(fileIds: any, integrationId: string, crowdinId: string): Promise<void>;
|
|
47
|
-
getSyncedFiles(integrationId: string, crowdinId: string): Promise<IntegrationSyncedFiles | undefined>;
|
|
48
45
|
}
|
package/out/storage/mysql.js
CHANGED
|
@@ -114,15 +114,6 @@ class MySQLStorage {
|
|
|
114
114
|
provider varchar(255) not null
|
|
115
115
|
)
|
|
116
116
|
`);
|
|
117
|
-
yield connection.execute(`
|
|
118
|
-
create table if not exists synced_files
|
|
119
|
-
(
|
|
120
|
-
id int auto_increment primary key,
|
|
121
|
-
integration_id varchar(255) not null,
|
|
122
|
-
crowdin_id varchar(255) not null,
|
|
123
|
-
file_ids text
|
|
124
|
-
)
|
|
125
|
-
`);
|
|
126
117
|
});
|
|
127
118
|
}
|
|
128
119
|
saveCrowdinCredentials(credentials) {
|
|
@@ -345,34 +336,5 @@ class MySQLStorage {
|
|
|
345
336
|
}));
|
|
346
337
|
});
|
|
347
338
|
}
|
|
348
|
-
saveSyncedFiles(fileIds, integrationId, crowdinId) {
|
|
349
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
350
|
-
yield this.dbPromise;
|
|
351
|
-
yield this.executeQuery((connection) => connection.execute('INSERT INTO synced_files(file_ids, integration_id, crowdin_id) VALUES (?, ?, ?)', [
|
|
352
|
-
fileIds,
|
|
353
|
-
integrationId,
|
|
354
|
-
crowdinId,
|
|
355
|
-
]));
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
updateSyncedFiles(fileIds, integrationId, crowdinId) {
|
|
359
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
360
|
-
yield this.dbPromise;
|
|
361
|
-
yield this.executeQuery((connection) => connection.execute('UPDATE synced_files SET file_ids = ? WHERE integration_id = ? AND crowdin_id = ?', [
|
|
362
|
-
fileIds,
|
|
363
|
-
integrationId,
|
|
364
|
-
crowdinId,
|
|
365
|
-
]));
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
getSyncedFiles(integrationId, crowdinId) {
|
|
369
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
370
|
-
yield this.dbPromise;
|
|
371
|
-
return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
|
|
372
|
-
const [rows] = yield connection.execute('SELECT id, file_ids as "fileIds", integration_id as "integrationId", crowdin_id as "crowdinId" FROM synced_files WHERE integration_id = ? AND crowdin_id = ?', [integrationId, crowdinId]);
|
|
373
|
-
return (rows || [])[0];
|
|
374
|
-
}));
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
339
|
}
|
|
378
340
|
exports.MySQLStorage = MySQLStorage;
|
package/out/storage/postgre.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Client } from 'pg';
|
|
2
2
|
import { Storage } from '.';
|
|
3
|
-
import { CrowdinCredentials, IntegrationCredentials, IntegrationFilesSnapshot,
|
|
3
|
+
import { CrowdinCredentials, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncSettings } from '../models';
|
|
4
4
|
export interface PostgreStorageConfig {
|
|
5
5
|
host?: string;
|
|
6
6
|
connectionString?: string;
|
|
@@ -47,7 +47,4 @@ export declare class PostgreStorage implements Storage {
|
|
|
47
47
|
saveFilesSnapshot(files: any, integrationId: string, crowdinId: string, provider: string): Promise<void>;
|
|
48
48
|
updateFilesSnapshot(files: any, integrationId: string, crowdinId: string, provider: string): Promise<void>;
|
|
49
49
|
getFilesSnapshot(integrationId: string, crowdinId: string, provider: string): Promise<IntegrationFilesSnapshot | undefined>;
|
|
50
|
-
saveSyncedFiles(fileIds: any, integrationId: string, crowdinId: string): Promise<void>;
|
|
51
|
-
updateSyncedFiles(fileIds: any, integrationId: string, crowdinId: string): Promise<void>;
|
|
52
|
-
getSyncedFiles(integrationId: string, crowdinId: string): Promise<IntegrationSyncedFiles | undefined>;
|
|
53
50
|
}
|
package/out/storage/postgre.js
CHANGED
|
@@ -128,15 +128,6 @@ class PostgreStorage {
|
|
|
128
128
|
provider varchar not null
|
|
129
129
|
)
|
|
130
130
|
`);
|
|
131
|
-
yield client.query(`
|
|
132
|
-
create table if not exists synced_files
|
|
133
|
-
(
|
|
134
|
-
id serial primary key,
|
|
135
|
-
integration_id varchar not null,
|
|
136
|
-
crowdin_id varchar not null,
|
|
137
|
-
file_ids varchar
|
|
138
|
-
)
|
|
139
|
-
`);
|
|
140
131
|
});
|
|
141
132
|
}
|
|
142
133
|
saveCrowdinCredentials(credentials) {
|
|
@@ -359,34 +350,5 @@ class PostgreStorage {
|
|
|
359
350
|
}));
|
|
360
351
|
});
|
|
361
352
|
}
|
|
362
|
-
saveSyncedFiles(fileIds, integrationId, crowdinId) {
|
|
363
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
364
|
-
yield this.dbPromise;
|
|
365
|
-
yield this.executeQuery((client) => client.query('INSERT INTO synced_files(file_ids, integration_id, crowdin_id) VALUES ($1, $2, $3)', [
|
|
366
|
-
fileIds,
|
|
367
|
-
integrationId,
|
|
368
|
-
crowdinId,
|
|
369
|
-
]));
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
updateSyncedFiles(fileIds, integrationId, crowdinId) {
|
|
373
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
374
|
-
yield this.dbPromise;
|
|
375
|
-
yield this.executeQuery((client) => client.query('UPDATE synced_files SET file_ids = $1 WHERE integration_id = $2 AND crowdin_id = $3', [
|
|
376
|
-
fileIds,
|
|
377
|
-
integrationId,
|
|
378
|
-
crowdinId,
|
|
379
|
-
]));
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
getSyncedFiles(integrationId, crowdinId) {
|
|
383
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
384
|
-
yield this.dbPromise;
|
|
385
|
-
return this.executeQuery((client) => __awaiter(this, void 0, void 0, function* () {
|
|
386
|
-
const res = yield client.query('SELECT id, file_ids as "fileIds", integration_id as "integrationId", crowdin_id as "crowdinId" FROM synced_files WHERE integration_id = $1 AND crowdin_id = $2', [integrationId, crowdinId]);
|
|
387
|
-
return res === null || res === void 0 ? void 0 : res.rows[0];
|
|
388
|
-
}));
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
353
|
}
|
|
392
354
|
exports.PostgreStorage = PostgreStorage;
|
package/out/storage/sqlite.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Storage } from '.';
|
|
2
|
-
import { CrowdinCredentials, IntegrationCredentials, IntegrationFilesSnapshot,
|
|
2
|
+
import { CrowdinCredentials, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncSettings } from '../models';
|
|
3
3
|
export interface SQLiteStorageConfig {
|
|
4
4
|
dbFolder: string;
|
|
5
5
|
}
|
|
@@ -41,7 +41,4 @@ export declare class SQLiteStorage implements Storage {
|
|
|
41
41
|
saveFilesSnapshot(files: any, integrationId: string, crowdinId: string, provider: string): Promise<void>;
|
|
42
42
|
updateFilesSnapshot(files: any, integrationId: string, crowdinId: string, provider: string): Promise<void>;
|
|
43
43
|
getFilesSnapshot(integrationId: string, crowdinId: string, provider: string): Promise<IntegrationFilesSnapshot | undefined>;
|
|
44
|
-
saveSyncedFiles(fileIds: any, integrationId: string, crowdinId: string): Promise<void>;
|
|
45
|
-
updateSyncedFiles(fileIds: any, integrationId: string, crowdinId: string): Promise<void>;
|
|
46
|
-
getSyncedFiles(integrationId: string, crowdinId: string): Promise<IntegrationSyncedFiles | undefined>;
|
|
47
44
|
}
|
package/out/storage/sqlite.js
CHANGED
|
@@ -185,15 +185,6 @@ class SQLiteStorage {
|
|
|
185
185
|
files varchar null,
|
|
186
186
|
provider varchar not null
|
|
187
187
|
);
|
|
188
|
-
`, []);
|
|
189
|
-
yield this._run(`
|
|
190
|
-
create table if not exists synced_files
|
|
191
|
-
(
|
|
192
|
-
id integer not null primary key autoincrement,
|
|
193
|
-
integration_id varchar not null,
|
|
194
|
-
crowdin_id varchar not null,
|
|
195
|
-
file_ids varchar null
|
|
196
|
-
);
|
|
197
188
|
`, []);
|
|
198
189
|
this._res && this._res();
|
|
199
190
|
// TODO: temporary code
|
|
@@ -360,27 +351,5 @@ class SQLiteStorage {
|
|
|
360
351
|
}
|
|
361
352
|
});
|
|
362
353
|
}
|
|
363
|
-
saveSyncedFiles(fileIds, integrationId, crowdinId) {
|
|
364
|
-
return this.run('INSERT INTO synced_files(file_ids, integration_id, crowdin_id) VALUES (?, ?, ?)', [
|
|
365
|
-
fileIds,
|
|
366
|
-
integrationId,
|
|
367
|
-
crowdinId,
|
|
368
|
-
]);
|
|
369
|
-
}
|
|
370
|
-
updateSyncedFiles(fileIds, integrationId, crowdinId) {
|
|
371
|
-
return this.run('UPDATE synced_files SET file_ids = ? WHERE integration_id = ? AND crowdin_id = ?', [
|
|
372
|
-
fileIds,
|
|
373
|
-
integrationId,
|
|
374
|
-
crowdinId,
|
|
375
|
-
]);
|
|
376
|
-
}
|
|
377
|
-
getSyncedFiles(integrationId, crowdinId) {
|
|
378
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
379
|
-
const row = yield this.get('SELECT id, file_ids as fileIds, integration_id as integrationId, crowdin_id as crowdinId FROM synced_files WHERE integration_id = ? AND crowdin_id = ?', [integrationId, crowdinId]);
|
|
380
|
-
if (row) {
|
|
381
|
-
return row;
|
|
382
|
-
}
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
354
|
}
|
|
386
355
|
exports.SQLiteStorage = SQLiteStorage;
|
package/out/util/defaults.js
CHANGED
|
@@ -58,7 +58,7 @@ function getOauthRoute(integration) {
|
|
|
58
58
|
}
|
|
59
59
|
exports.getOauthRoute = getOauthRoute;
|
|
60
60
|
function applyIntegrationModuleDefaults(config, integration) {
|
|
61
|
-
var _a;
|
|
61
|
+
var _a, _b;
|
|
62
62
|
if (!integration.getCrowdinFiles) {
|
|
63
63
|
integration.getCrowdinFiles = (projectId, client, rootFolder) => __awaiter(this, void 0, void 0, function* () {
|
|
64
64
|
const allBranches = (yield client.sourceFilesApi.withFetchAll().listProjectBranches(projectId)).data.map((d) => d.data);
|
|
@@ -142,7 +142,7 @@ function applyIntegrationModuleDefaults(config, integration) {
|
|
|
142
142
|
if (integration.withCronSync || integration.webhooks) {
|
|
143
143
|
const getUserSettings = integration.getConfiguration;
|
|
144
144
|
integration.getConfiguration = (projectId, crowdinClient, integrationCredentials) => __awaiter(this, void 0, void 0, function* () {
|
|
145
|
-
var
|
|
145
|
+
var _c, _d;
|
|
146
146
|
let fields = [];
|
|
147
147
|
if (getUserSettings) {
|
|
148
148
|
fields = yield getUserSettings(projectId, crowdinClient, integrationCredentials);
|
|
@@ -211,7 +211,7 @@ function applyIntegrationModuleDefaults(config, integration) {
|
|
|
211
211
|
label: 'Webhooks',
|
|
212
212
|
});
|
|
213
213
|
}
|
|
214
|
-
if ((
|
|
214
|
+
if ((_c = integration.syncNewElements) === null || _c === void 0 ? void 0 : _c.crowdin) {
|
|
215
215
|
defaultSettings.push({
|
|
216
216
|
key: 'new-crowdin-files',
|
|
217
217
|
label: 'Sync all new items from Crowdin',
|
|
@@ -221,7 +221,7 @@ function applyIntegrationModuleDefaults(config, integration) {
|
|
|
221
221
|
]),
|
|
222
222
|
});
|
|
223
223
|
}
|
|
224
|
-
if ((
|
|
224
|
+
if ((_d = integration.syncNewElements) === null || _d === void 0 ? void 0 : _d.integration) {
|
|
225
225
|
defaultSettings.push({
|
|
226
226
|
key: 'new-integration-files',
|
|
227
227
|
label: `Sync all new items from ${config.name}`,
|
|
@@ -268,6 +268,9 @@ function applyIntegrationModuleDefaults(config, integration) {
|
|
|
268
268
|
if (integration.webhooks && !((_a = integration.webhooks) === null || _a === void 0 ? void 0 : _a.urlParam)) {
|
|
269
269
|
integration.webhooks.urlParam = 'crowdinData';
|
|
270
270
|
}
|
|
271
|
+
if (!((_b = integration.filtering) === null || _b === void 0 ? void 0 : _b.hasOwnProperty('crowdinLanguages'))) {
|
|
272
|
+
integration.filtering = Object.assign(Object.assign({}, (integration.filtering || {})), { crowdinLanguages: true });
|
|
273
|
+
}
|
|
271
274
|
}
|
|
272
275
|
exports.applyIntegrationModuleDefaults = applyIntegrationModuleDefaults;
|
|
273
276
|
function constructOauthUrl(config, integration) {
|
|
@@ -13,27 +13,14 @@
|
|
|
13
13
|
</div>
|
|
14
14
|
</crowdin-alert>
|
|
15
15
|
{{/if}}
|
|
16
|
-
<div
|
|
17
|
-
{{#if
|
|
18
|
-
<
|
|
19
|
-
<crowdin-integration-filter
|
|
20
|
-
{{#if filtering.syncStatus}}
|
|
21
|
-
enable-sync-status-filter
|
|
22
|
-
{{/if}}
|
|
23
|
-
integration-logo="logo.png"
|
|
24
|
-
></crowdin-integration-filter>
|
|
25
|
-
</div>
|
|
16
|
+
<div>
|
|
17
|
+
{{#if infoModal}}
|
|
18
|
+
<crowdin-button icon-before="info" onclick="infoModal.open();">{{infoModal.title}}</crowdin-button>
|
|
26
19
|
{{/if}}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
{{/if}}
|
|
32
|
-
{{#if configurationFields}}
|
|
33
|
-
<crowdin-button icon-before="settings" onclick="settingsModal.open();fillSettingsForm();">Settings</crowdin-button>
|
|
34
|
-
{{/if}}
|
|
35
|
-
<crowdin-button icon-before="account_circle" onclick="integrationLogout()">Log out</crowdin-button>
|
|
36
|
-
</div>
|
|
20
|
+
{{#if configurationFields}}
|
|
21
|
+
<crowdin-button icon-before="settings" onclick="settingsModal.open();fillSettingsForm();">Settings</crowdin-button>
|
|
22
|
+
{{/if}}
|
|
23
|
+
<crowdin-button icon-before="account_circle" onclick="integrationLogout()">Log out</crowdin-button>
|
|
37
24
|
</div>
|
|
38
25
|
{{#if uploadTranslations}}
|
|
39
26
|
<crowdin-alert id="translation-info" no-icon="true" style="display: none;">
|
|
@@ -75,6 +62,9 @@
|
|
|
75
62
|
{{#if uploadTranslations}}
|
|
76
63
|
integration-button-menu-items='[{"label":"Upload Translations", "action":"uploadTranslations"}]'
|
|
77
64
|
{{/if}}
|
|
65
|
+
{{#if filtering.crowdinLanguages}}
|
|
66
|
+
crowdin-filter
|
|
67
|
+
{{/if}}
|
|
78
68
|
>
|
|
79
69
|
</crowdin-simple-integration>
|
|
80
70
|
</div>
|
|
@@ -263,11 +253,6 @@
|
|
|
263
253
|
const appComponent = document.querySelector('crowdin-simple-integration');
|
|
264
254
|
const subscriptionModal = document.getElementById('subscription-modal');
|
|
265
255
|
|
|
266
|
-
{{#if filtering}}
|
|
267
|
-
let syncedFiles = [];
|
|
268
|
-
const filterIntegration = document.querySelector('crowdin-integration-filter');
|
|
269
|
-
{{/if}}
|
|
270
|
-
|
|
271
256
|
const folderType = '0';
|
|
272
257
|
const fileType = '1';
|
|
273
258
|
const branchType = '2';
|
|
@@ -299,6 +284,7 @@
|
|
|
299
284
|
name: e.name,
|
|
300
285
|
id: e.id,
|
|
301
286
|
customContent: e.customContent,
|
|
287
|
+
labels: e.labels,
|
|
302
288
|
};
|
|
303
289
|
if (e.type) {
|
|
304
290
|
item.type = e.type;
|
|
@@ -317,16 +303,10 @@
|
|
|
317
303
|
.then((res) => {
|
|
318
304
|
project = res;
|
|
319
305
|
appComponent.setCrowdinLanguagesData(project.targetLanguages)
|
|
320
|
-
{{#if filtering}}
|
|
321
|
-
filterIntegration.setLanguages(project.targetLanguages)
|
|
322
|
-
{{/if}}
|
|
323
306
|
})
|
|
324
307
|
{{#or withCronSync webhooks}}
|
|
325
308
|
.then(() => getSyncSettings('crowdin'))
|
|
326
309
|
{{/or}}
|
|
327
|
-
{{#if filtering}}
|
|
328
|
-
.then(() => getSyncedFiles())
|
|
329
|
-
{{/if}}
|
|
330
310
|
.catch(e => catchRejection(e, 'Can\'t fetch Crowdin data'))
|
|
331
311
|
.finally(() => (appComponent.setAttribute('is-crowdin-loading', false)));
|
|
332
312
|
}
|
|
@@ -345,6 +325,7 @@
|
|
|
345
325
|
name: e.name,
|
|
346
326
|
id: e.id,
|
|
347
327
|
customContent: e.customContent,
|
|
328
|
+
labels: e.labels,
|
|
348
329
|
};
|
|
349
330
|
if (e.type) {
|
|
350
331
|
item.type = e.type;
|
|
@@ -489,23 +470,21 @@
|
|
|
489
470
|
|
|
490
471
|
function fillSettingsForm() {
|
|
491
472
|
Object.entries(config).forEach(([key, value]) => {
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
if (el) {
|
|
495
|
-
if (el.
|
|
496
|
-
|
|
497
|
-
el.value = JSON.stringify(value);
|
|
498
|
-
} else {
|
|
499
|
-
el.value = JSON.stringify([value]);
|
|
500
|
-
}
|
|
501
|
-
} else if (el.tagName.toLowerCase() === 'crowdin-checkbox') {
|
|
502
|
-
el.checked = !!value;
|
|
473
|
+
const el = document.getElementById(`${key}-settings`);
|
|
474
|
+
if (el && (value || el.tagName.toLowerCase() === 'crowdin-checkbox')) {
|
|
475
|
+
if (el.tagName.toLowerCase() === 'crowdin-select') {
|
|
476
|
+
if (el.hasAttribute('is-multi')) {
|
|
477
|
+
el.value = JSON.stringify(value);
|
|
503
478
|
} else {
|
|
504
|
-
el.value = value;
|
|
479
|
+
el.value = JSON.stringify([value]);
|
|
505
480
|
}
|
|
506
|
-
|
|
507
|
-
|
|
481
|
+
} else if (el.tagName.toLowerCase() === 'crowdin-checkbox') {
|
|
482
|
+
el.checked = !!value;
|
|
483
|
+
} else {
|
|
484
|
+
el.value = value;
|
|
508
485
|
}
|
|
486
|
+
|
|
487
|
+
triggerEvent(el, 'change');
|
|
509
488
|
}
|
|
510
489
|
});
|
|
511
490
|
}
|
|
@@ -787,34 +766,6 @@
|
|
|
787
766
|
}
|
|
788
767
|
checkAlert(translationInfo);
|
|
789
768
|
{{/if}}
|
|
790
|
-
|
|
791
|
-
{{#if filtering}}
|
|
792
|
-
document.body.addEventListener("integrationFilterChange", filterFiles);
|
|
793
|
-
|
|
794
|
-
function filterFiles(event) {
|
|
795
|
-
const filter = event.detail;
|
|
796
|
-
|
|
797
|
-
if (filter.languages) {
|
|
798
|
-
const languageIds = filter.languages === 'all' ? [] : [filter.languages];
|
|
799
|
-
appComponent.filterCrowdinFilesByLanguages(languageIds);
|
|
800
|
-
}
|
|
801
|
-
if (filter.sync) {
|
|
802
|
-
const fileId = filter.sync === 'all' ? [] : syncedFiles;
|
|
803
|
-
appComponent.filterIntegrationFilesByIds(fileId, filter.sync !== 'not_synced');
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
function getSyncedFiles() {
|
|
808
|
-
checkOrigin()
|
|
809
|
-
.then(restParams => fetch('/api/synced-files' + restParams))
|
|
810
|
-
.then(checkResponse)
|
|
811
|
-
.then((res) => {
|
|
812
|
-
syncedFiles = res;
|
|
813
|
-
})
|
|
814
|
-
.catch(e => catchRejection(e, 'Can\'t fetch file progress'));
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
{{/if}}
|
|
818
769
|
</script>
|
|
819
770
|
|
|
820
771
|
</html>
|
package/package.json
CHANGED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
/// <reference types="qs" />
|
|
2
|
-
import { Response } from 'express';
|
|
3
|
-
export default function handle(): (req: import("../../models").CrowdinClientRequest | import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const storage_1 = require("../../storage");
|
|
13
|
-
const util_1 = require("../../util");
|
|
14
|
-
function handle() {
|
|
15
|
-
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
let fileIds = [];
|
|
17
|
-
req.logInfo('Loading synced files');
|
|
18
|
-
const syncedFiles = yield (0, storage_1.getStorage)().getSyncedFiles(req.crowdinContext.clientId, req.crowdinContext.crowdinId);
|
|
19
|
-
if (syncedFiles) {
|
|
20
|
-
fileIds = JSON.parse(syncedFiles.fileIds) || [];
|
|
21
|
-
}
|
|
22
|
-
req.logInfo(`Returning synced files ${JSON.stringify(fileIds, null, 2)}`);
|
|
23
|
-
res.send(fileIds);
|
|
24
|
-
}));
|
|
25
|
-
}
|
|
26
|
-
exports.default = handle;
|
package/out/util/synced-files.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.createOrUpdateSyncedFiles = void 0;
|
|
13
|
-
const storage_1 = require("../storage");
|
|
14
|
-
const logger_1 = require("./logger");
|
|
15
|
-
function createOrUpdateSyncedFiles(args) {
|
|
16
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
const { req } = args;
|
|
18
|
-
let fileIds = args.fileIds;
|
|
19
|
-
const existingFiles = yield (0, storage_1.getStorage)().getSyncedFiles(req.crowdinContext.clientId, req.crowdinContext.crowdinId);
|
|
20
|
-
if (existingFiles) {
|
|
21
|
-
fileIds = [...new Set([...JSON.parse(existingFiles.fileIds), ...fileIds])];
|
|
22
|
-
(0, logger_1.log)(`Updating synced files ${JSON.stringify(fileIds, null, 2)}`);
|
|
23
|
-
yield (0, storage_1.getStorage)().updateSyncedFiles(JSON.stringify(fileIds), req.crowdinContext.clientId, req.crowdinContext.crowdinId);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
(0, logger_1.log)(`Saving synced files ${JSON.stringify(fileIds, null, 2)}`);
|
|
27
|
-
yield (0, storage_1.getStorage)().saveSyncedFiles(JSON.stringify(fileIds), req.crowdinContext.clientId, req.crowdinContext.crowdinId);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
exports.createOrUpdateSyncedFiles = createOrUpdateSyncedFiles;
|