@crowdin/app-project-module 0.32.2 → 0.34.1
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 +5 -2
- package/out/middlewares/crowdin-client.js +2 -7
- package/out/middlewares/ui-module.js +3 -3
- package/out/models/index.d.ts +15 -15
- package/out/static/js/form.js +7 -7
- package/out/static/js/main.js +1 -0
- 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/util/logger.d.ts +6 -5
- package/out/util/logger.js +53 -3
- package/out/views/main.handlebars +38 -75
- package/package.json +7 -6
- 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
|
@@ -39,6 +39,7 @@ exports.createApp = exports.addCrowdinEndpoints = exports.express = exports.User
|
|
|
39
39
|
const express_handlebars_1 = __importDefault(require("express-handlebars"));
|
|
40
40
|
const cron = __importStar(require("node-cron"));
|
|
41
41
|
const path_1 = require("path");
|
|
42
|
+
const logsFormatter = __importStar(require("@crowdin/logs-formatter"));
|
|
42
43
|
const translate_1 = __importDefault(require("./handlers/custom-mt/translate"));
|
|
43
44
|
const custom_file_format_1 = __importDefault(require("./handlers/file-processing/custom-file-format"));
|
|
44
45
|
const file_download_1 = __importDefault(require("./handlers/file-processing/file-download"));
|
|
@@ -63,7 +64,6 @@ const settings_save_1 = __importDefault(require("./handlers/integration/settings
|
|
|
63
64
|
const subscription_info_1 = __importDefault(require("./handlers/integration/subscription-info"));
|
|
64
65
|
const sync_settings_1 = __importDefault(require("./handlers/integration/sync-settings"));
|
|
65
66
|
const sync_settings_save_1 = __importDefault(require("./handlers/integration/sync-settings-save"));
|
|
66
|
-
const synced_files_1 = __importDefault(require("./handlers/integration/synced-files"));
|
|
67
67
|
const manifest_1 = __importDefault(require("./handlers/manifest"));
|
|
68
68
|
const subscription_paid_1 = __importDefault(require("./handlers/subscription-paid"));
|
|
69
69
|
const uninstall_1 = __importDefault(require("./handlers/uninstall"));
|
|
@@ -97,6 +97,10 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
97
97
|
storage.initialize(config);
|
|
98
98
|
logger.initialize(config);
|
|
99
99
|
app.use(terminus_express_1.default.json({ limit: '50mb' }));
|
|
100
|
+
if (!config.disableLogsFormatter) {
|
|
101
|
+
logsFormatter.setup();
|
|
102
|
+
app.use(logsFormatter.expressMiddleware());
|
|
103
|
+
}
|
|
100
104
|
app.use('/assets', terminus_express_1.default.static((0, path_1.join)(__dirname, 'static')));
|
|
101
105
|
app.set('views', (0, path_1.join)(__dirname, 'views'));
|
|
102
106
|
app.engine('handlebars', (0, express_handlebars_1.default)({
|
|
@@ -151,7 +155,6 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
151
155
|
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
156
|
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
157
|
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
158
|
if (integrationLogic.oauthLogin) {
|
|
156
159
|
app.get((0, defaults_1.getOauthRoute)(integrationLogic), (0, oauth_login_1.default)(config, integrationLogic));
|
|
157
160
|
app.post('/api/oauth-url', json_response_1.default, (0, crowdin_client_1.default)(config, false, false), (0, oauth_url_1.default)(config, integrationLogic));
|
|
@@ -25,13 +25,8 @@ function prepareCrowdinRequest(jwtToken, config, optional = false, checkSubscrip
|
|
|
25
25
|
clientId: (0, crowdin_apps_functions_1.constructCrowdinIdFromJwtPayload)(jwtPayload),
|
|
26
26
|
crowdinId: `${jwtPayload.domain || jwtPayload.context.organization_id}`,
|
|
27
27
|
};
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
userId: context.clientId,
|
|
31
|
-
projectId: jwtPayload.context.project_id,
|
|
32
|
-
};
|
|
33
|
-
const logInfo = (0, logger_1.withContext)(logContext);
|
|
34
|
-
const logError = (0, logger_1.withContextError)(logContext);
|
|
28
|
+
const logInfo = (0, logger_1.withContext)(context);
|
|
29
|
+
const logError = (0, logger_1.withContextError)(context);
|
|
35
30
|
logInfo('Loading crowdin credentials');
|
|
36
31
|
const credentials = yield (0, storage_1.getStorage)().getCrowdinCredentials(context.crowdinId);
|
|
37
32
|
if (!credentials) {
|
|
@@ -28,9 +28,9 @@ function handle(config, allowUnauthorized = false) {
|
|
|
28
28
|
const jwtPayload = yield (0, crowdin_apps_functions_1.validateJwtToken)(jwtToken, config.clientSecret, config.jwtValidationOptions);
|
|
29
29
|
const id = `${jwtPayload.domain || jwtPayload.context.organization_id}`;
|
|
30
30
|
const logInfo = (0, logger_1.withContext)({
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
jwtPayload,
|
|
32
|
+
clientId: (0, crowdin_apps_functions_1.constructCrowdinIdFromJwtPayload)(jwtPayload),
|
|
33
|
+
crowdinId: id,
|
|
34
34
|
});
|
|
35
35
|
logInfo('Loading crowdin credentials');
|
|
36
36
|
const credentials = yield (0, storage_1.getStorage)().getCrowdinCredentials(id);
|
package/out/models/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { JwtPayload, VerifyOptions } from '@crowdin/crowdin-apps-functions';
|
|
|
3
3
|
import { Request } from 'express';
|
|
4
4
|
import { MySQLStorageConfig } from '../storage/mysql';
|
|
5
5
|
import { PostgreStorageConfig } from '../storage/postgre';
|
|
6
|
-
import {
|
|
6
|
+
import { LogErrorFunction, LogFunction } from '../util/logger';
|
|
7
7
|
export interface ClientConfig extends ImagePath {
|
|
8
8
|
/**
|
|
9
9
|
* Authentication Crowdin App type: "authorization_code", "crowdin_app". Default: "crowdin_app"
|
|
@@ -131,7 +131,7 @@ export interface ClientConfig extends ImagePath {
|
|
|
131
131
|
/**
|
|
132
132
|
* Error interceptor (can be used to log error in centralized place)
|
|
133
133
|
*/
|
|
134
|
-
onError?: (error: any, context?:
|
|
134
|
+
onError?: (error: any, context?: CrowdinContextInfo) => void;
|
|
135
135
|
/**
|
|
136
136
|
* Disable global error handling of unhandledRejection and uncaughtException events
|
|
137
137
|
*/
|
|
@@ -152,6 +152,10 @@ export interface ClientConfig extends ImagePath {
|
|
|
152
152
|
* sentry dsn identifier of sentry project
|
|
153
153
|
*/
|
|
154
154
|
sentryDsn?: string;
|
|
155
|
+
/**
|
|
156
|
+
* Disable formatting logs
|
|
157
|
+
*/
|
|
158
|
+
disableLogsFormatter?: boolean;
|
|
155
159
|
}
|
|
156
160
|
export type Config = ClientConfig & {
|
|
157
161
|
baseUrl: string;
|
|
@@ -265,7 +269,6 @@ export interface IntegrationLogic {
|
|
|
265
269
|
};
|
|
266
270
|
filtering?: {
|
|
267
271
|
crowdinLanguages: boolean;
|
|
268
|
-
syncStatus: boolean;
|
|
269
272
|
};
|
|
270
273
|
/**
|
|
271
274
|
* Enable integration folder open event
|
|
@@ -447,7 +450,6 @@ export interface ExtendedResult<T> {
|
|
|
447
450
|
data?: T;
|
|
448
451
|
message?: string;
|
|
449
452
|
stopPagination?: boolean;
|
|
450
|
-
syncedFiles: string[];
|
|
451
453
|
}
|
|
452
454
|
export type TreeItem = File | Folder;
|
|
453
455
|
/**
|
|
@@ -456,6 +458,12 @@ export type TreeItem = File | Folder;
|
|
|
456
458
|
* 2 - branch
|
|
457
459
|
*/
|
|
458
460
|
type IntegrationTreeElementType = '0' | '1' | '2';
|
|
461
|
+
type LabelTreeElementType = 'primary' | 'secondary' | 'success' | 'warning' | 'info' | 'danger' | 'dark' | 'light';
|
|
462
|
+
export interface LabelTreeElement {
|
|
463
|
+
text: string;
|
|
464
|
+
type?: LabelTreeElementType;
|
|
465
|
+
color?: string;
|
|
466
|
+
}
|
|
459
467
|
export interface File {
|
|
460
468
|
id: string;
|
|
461
469
|
name: string;
|
|
@@ -463,6 +471,7 @@ export interface File {
|
|
|
463
471
|
parentId?: string;
|
|
464
472
|
nodeType?: IntegrationTreeElementType;
|
|
465
473
|
customContent?: string;
|
|
474
|
+
labels?: LabelTreeElement;
|
|
466
475
|
}
|
|
467
476
|
export interface Folder {
|
|
468
477
|
id: string;
|
|
@@ -470,6 +479,7 @@ export interface Folder {
|
|
|
470
479
|
parentId?: string;
|
|
471
480
|
nodeType?: IntegrationTreeElementType;
|
|
472
481
|
customContent?: string;
|
|
482
|
+
labels?: LabelTreeElement;
|
|
473
483
|
}
|
|
474
484
|
export interface IntegrationRequest extends CrowdinClientRequest {
|
|
475
485
|
integrationCredentials: any;
|
|
@@ -828,7 +838,7 @@ export interface ApiModule {
|
|
|
828
838
|
}
|
|
829
839
|
export interface Logger {
|
|
830
840
|
enabled: boolean;
|
|
831
|
-
log?: (message: string, context?:
|
|
841
|
+
log?: (message: string, context?: CrowdinContextInfo) => void;
|
|
832
842
|
}
|
|
833
843
|
export interface Pricing {
|
|
834
844
|
planType: 'free' | 'recurring';
|
|
@@ -885,16 +895,6 @@ export interface UpdateCrowdinWebhookPayloadsArgs {
|
|
|
885
895
|
webhookData: any;
|
|
886
896
|
req: Request;
|
|
887
897
|
}
|
|
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
898
|
export declare enum UserPermissions {
|
|
899
899
|
OWNER = "owner",
|
|
900
900
|
MANAGERS = "managers",
|