@crowdin/app-project-module 0.31.0 → 0.32.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/custom-mt/translate.d.ts +2 -2
- package/out/handlers/custom-mt/translate.js +8 -6
- package/out/handlers/file-processing/custom-file-format.d.ts +2 -2
- package/out/handlers/file-processing/custom-file-format.js +4 -4
- package/out/handlers/file-processing/file-download.d.ts +1 -1
- package/out/handlers/file-processing/file-download.js +3 -2
- package/out/handlers/file-processing/pre-post-process.d.ts +2 -2
- package/out/handlers/file-processing/pre-post-process.js +11 -3
- package/out/handlers/form-data-display.d.ts +1 -1
- package/out/handlers/form-data-save.d.ts +1 -1
- package/out/handlers/install.d.ts +1 -1
- package/out/handlers/install.js +5 -3
- package/out/handlers/integration/crowdin-file-progress.d.ts +2 -2
- package/out/handlers/integration/crowdin-file-progress.js +4 -4
- package/out/handlers/integration/crowdin-files.d.ts +1 -1
- package/out/handlers/integration/crowdin-files.js +4 -4
- package/out/handlers/integration/crowdin-project.d.ts +2 -2
- package/out/handlers/integration/crowdin-project.js +4 -4
- package/out/handlers/integration/crowdin-update.d.ts +1 -1
- package/out/handlers/integration/crowdin-update.js +4 -4
- package/out/handlers/integration/crowdin-webhook.d.ts +1 -1
- package/out/handlers/integration/crowdin-webhook.js +1 -1
- package/out/handlers/integration/integration-data.d.ts +2 -2
- package/out/handlers/integration/integration-data.js +4 -4
- package/out/handlers/integration/integration-login.d.ts +2 -2
- package/out/handlers/integration/integration-login.js +4 -4
- package/out/handlers/integration/integration-logout.d.ts +1 -1
- package/out/handlers/integration/integration-logout.js +4 -4
- package/out/handlers/integration/integration-update.d.ts +1 -1
- package/out/handlers/integration/integration-update.js +3 -3
- package/out/handlers/integration/integration-webhook.d.ts +1 -1
- package/out/handlers/integration/integration-webhook.js +1 -1
- package/out/handlers/integration/main.d.ts +1 -1
- package/out/handlers/integration/main.js +5 -3
- package/out/handlers/integration/oauth-login.d.ts +1 -1
- package/out/handlers/integration/oauth-login.js +6 -10
- package/out/handlers/integration/oauth-url.d.ts +2 -2
- package/out/handlers/integration/oauth-url.js +3 -3
- package/out/handlers/integration/settings-save.d.ts +1 -1
- package/out/handlers/integration/settings-save.js +2 -2
- package/out/handlers/integration/settings.d.ts +1 -2
- package/out/handlers/integration/settings.js +2 -2
- package/out/handlers/integration/sync-settings-save.d.ts +1 -1
- package/out/handlers/integration/sync-settings-save.js +1 -1
- package/out/handlers/integration/sync-settings.d.ts +1 -2
- package/out/handlers/integration/sync-settings.js +4 -4
- package/out/handlers/integration/synced-files.d.ts +1 -2
- package/out/handlers/integration/synced-files.js +4 -4
- package/out/handlers/manifest.js +7 -7
- package/out/handlers/subscription-paid.d.ts +1 -2
- package/out/handlers/subscription-paid.js +4 -3
- package/out/handlers/uninstall.d.ts +1 -1
- package/out/handlers/uninstall.js +7 -6
- package/out/index.d.ts +1 -1
- package/out/index.js +36 -33
- package/out/middlewares/crowdin-client.d.ts +4 -1
- package/out/middlewares/crowdin-client.js +26 -16
- package/out/middlewares/integration-credentials.d.ts +1 -1
- package/out/middlewares/integration-credentials.js +2 -2
- package/out/middlewares/render-ui-module.d.ts +2 -2
- package/out/middlewares/render-ui-module.js +2 -2
- package/out/middlewares/ui-module.d.ts +1 -1
- package/out/middlewares/ui-module.js +17 -6
- package/out/models/index.d.ts +8 -4
- package/out/models/index.js +1 -0
- package/out/storage/index.js +4 -4
- package/out/util/api/api.js +4 -4
- package/out/util/connection.d.ts +11 -2
- package/out/util/connection.js +17 -16
- package/out/util/cron.js +43 -25
- package/out/util/file-snapshot.d.ts +1 -1
- package/out/util/file-snapshot.js +4 -4
- package/out/util/index.d.ts +3 -6
- package/out/util/index.js +12 -42
- package/out/util/logger.d.ts +14 -0
- package/out/util/logger.js +71 -0
- package/out/util/synced-files.js +4 -4
- package/out/util/webhooks.d.ts +1 -1
- package/out/util/webhooks.js +6 -6
- package/package.json +1 -1
|
@@ -13,10 +13,10 @@ const util_1 = require("../../util");
|
|
|
13
13
|
const defaults_1 = require("../../util/defaults");
|
|
14
14
|
function handle(config, integration) {
|
|
15
15
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
|
|
16
|
+
req.logInfo('Received OAuth login url request');
|
|
17
17
|
const { oauthLogin } = integration;
|
|
18
18
|
if (!oauthLogin) {
|
|
19
|
-
|
|
19
|
+
req.logInfo('OAuth login url request is not supported');
|
|
20
20
|
res.status(400).end();
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
@@ -25,6 +25,6 @@ function handle(config, integration) {
|
|
|
25
25
|
? oauthLogin.getAuthorizationUrl(`${config.baseUrl}${(0, defaults_1.getOauthRoute)(integration)}`, loginForm)
|
|
26
26
|
: (0, defaults_1.constructOauthUrl)(config, integration);
|
|
27
27
|
res.send({ url });
|
|
28
|
-
})
|
|
28
|
+
}));
|
|
29
29
|
}
|
|
30
30
|
exports.default = handle;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { Config, IntegrationLogic } from '../../models';
|
|
4
|
-
export default function handle(config: Config, integration: IntegrationLogic): (req: 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;
|
|
4
|
+
export default function handle(config: Config, integration: IntegrationLogic): (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;
|
|
@@ -18,7 +18,7 @@ const webhooks_1 = require("../../util/webhooks");
|
|
|
18
18
|
function handle(config, integration) {
|
|
19
19
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
const appSettings = req.body.config;
|
|
21
|
-
|
|
21
|
+
req.logInfo(`Saving settings ${JSON.stringify(appSettings, null, 2)}`);
|
|
22
22
|
yield (0, storage_1.getStorage)().updateIntegrationConfig(req.crowdinContext.clientId, JSON.stringify(appSettings));
|
|
23
23
|
if (integration.webhooks) {
|
|
24
24
|
yield (0, webhooks_1.registerWebhooks)(config, integration, req.crowdinApiClient, req.crowdinContext, req.integrationCredentials, appSettings);
|
|
@@ -34,6 +34,6 @@ function handle(config, integration) {
|
|
|
34
34
|
yield (0, cron_1.createOrUpdateSyncSettings)(config, req, [], models_1.Provider.INTEGRATION, true);
|
|
35
35
|
}
|
|
36
36
|
res.status(204).end();
|
|
37
|
-
})
|
|
37
|
+
}));
|
|
38
38
|
}
|
|
39
39
|
exports.default = handle;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
|
|
4
|
-
export default function handle(config: Config): (req: 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;
|
|
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;
|
|
@@ -10,13 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const util_1 = require("../../util");
|
|
13
|
-
function handle(
|
|
13
|
+
function handle() {
|
|
14
14
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
15
15
|
let settings = {};
|
|
16
16
|
if (req.integrationSettings) {
|
|
17
17
|
settings = req.integrationSettings;
|
|
18
18
|
}
|
|
19
19
|
res.send(settings);
|
|
20
|
-
})
|
|
20
|
+
}));
|
|
21
21
|
}
|
|
22
22
|
exports.default = handle;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { Config, IntegrationLogic } from '../../models';
|
|
4
|
-
export default function handle(config: Config, integration: IntegrationLogic): (req: 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;
|
|
4
|
+
export default function handle(config: Config, integration: IntegrationLogic): (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,4 +1,3 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
|
|
4
|
-
export default function handle(config: Config): (req: 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;
|
|
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;
|
|
@@ -11,17 +11,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const storage_1 = require("../../storage");
|
|
13
13
|
const util_1 = require("../../util");
|
|
14
|
-
function handle(
|
|
14
|
+
function handle() {
|
|
15
15
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
let files = {};
|
|
17
17
|
const provider = req.params.provider || req.body.provider;
|
|
18
|
-
|
|
18
|
+
req.logInfo(`Loading sync settings for provider ${provider}`);
|
|
19
19
|
const syncSettings = yield (0, storage_1.getStorage)().getSyncSettingsByProvider(req.crowdinContext.clientId, provider);
|
|
20
20
|
if (syncSettings) {
|
|
21
21
|
files = JSON.parse(syncSettings.files) || [];
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
req.logInfo(`Returning sync settings ${JSON.stringify(files, null, 2)}`);
|
|
24
24
|
res.send(files);
|
|
25
|
-
})
|
|
25
|
+
}));
|
|
26
26
|
}
|
|
27
27
|
exports.default = handle;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
|
|
4
|
-
export default function handle(config: Config): (req: 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;
|
|
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;
|
|
@@ -11,16 +11,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const storage_1 = require("../../storage");
|
|
13
13
|
const util_1 = require("../../util");
|
|
14
|
-
function handle(
|
|
14
|
+
function handle() {
|
|
15
15
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
let fileIds = [];
|
|
17
|
-
|
|
17
|
+
req.logInfo('Loading synced files');
|
|
18
18
|
const syncedFiles = yield (0, storage_1.getStorage)().getSyncedFiles(req.crowdinContext.clientId, req.crowdinContext.crowdinId);
|
|
19
19
|
if (syncedFiles) {
|
|
20
20
|
fileIds = JSON.parse(syncedFiles.fileIds) || [];
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
req.logInfo(`Returning synced files ${JSON.stringify(fileIds, null, 2)}`);
|
|
23
23
|
res.send(fileIds);
|
|
24
|
-
})
|
|
24
|
+
}));
|
|
25
25
|
}
|
|
26
26
|
exports.default = handle;
|
package/out/handlers/manifest.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const models_1 = require("../models");
|
|
4
|
-
const connection_1 = require("../util/connection");
|
|
5
4
|
const util_1 = require("../util");
|
|
6
5
|
const api_1 = require("../util/api/api");
|
|
6
|
+
const connection_1 = require("../util/connection");
|
|
7
7
|
function handle(config) {
|
|
8
8
|
const modules = {};
|
|
9
9
|
if (config.projectIntegration) {
|
|
@@ -12,7 +12,7 @@ function handle(config) {
|
|
|
12
12
|
key: config.identifier + '-int',
|
|
13
13
|
name: config.name,
|
|
14
14
|
description: config.description,
|
|
15
|
-
logo: (0, util_1.getLogoUrl)(config
|
|
15
|
+
logo: (0, util_1.getLogoUrl)(config.projectIntegration, '/integration'),
|
|
16
16
|
url: '/',
|
|
17
17
|
environments: config.projectIntegration.environments,
|
|
18
18
|
},
|
|
@@ -74,7 +74,7 @@ function handle(config) {
|
|
|
74
74
|
{
|
|
75
75
|
key: config.identifier + '-mt',
|
|
76
76
|
name: config.name,
|
|
77
|
-
logo: (0, util_1.getLogoUrl)(config
|
|
77
|
+
logo: (0, util_1.getLogoUrl)(config.customMT, '/mt'),
|
|
78
78
|
url: '/translate',
|
|
79
79
|
environments: config.customMT.environments,
|
|
80
80
|
withContext: !!config.customMT.withContext,
|
|
@@ -87,7 +87,7 @@ function handle(config) {
|
|
|
87
87
|
key: config.identifier + '-resources',
|
|
88
88
|
name: config.organizationMenu.name || config.name,
|
|
89
89
|
url: '/resources/' + (config.organizationMenu.fileName || 'index.html'),
|
|
90
|
-
icon: (0, util_1.getLogoUrl)(config
|
|
90
|
+
icon: (0, util_1.getLogoUrl)(config.organizationMenu, '/resources'),
|
|
91
91
|
},
|
|
92
92
|
];
|
|
93
93
|
}
|
|
@@ -97,7 +97,7 @@ function handle(config) {
|
|
|
97
97
|
key: config.identifier + '-profile-resources-menu',
|
|
98
98
|
name: config.profileResourcesMenu.name || config.name,
|
|
99
99
|
url: '/resources/' + (config.profileResourcesMenu.fileName || 'index.html'),
|
|
100
|
-
icon: (0, util_1.getLogoUrl)(config
|
|
100
|
+
icon: (0, util_1.getLogoUrl)(config.profileResourcesMenu, '/resources'),
|
|
101
101
|
environments: config.profileResourcesMenu.environments,
|
|
102
102
|
},
|
|
103
103
|
];
|
|
@@ -138,7 +138,7 @@ function handle(config) {
|
|
|
138
138
|
key: config.identifier + '-tools',
|
|
139
139
|
name: config.projectTools.name || config.name,
|
|
140
140
|
description: config.description,
|
|
141
|
-
logo: (0, util_1.getLogoUrl)(config
|
|
141
|
+
logo: (0, util_1.getLogoUrl)(config.projectTools, '/tools'),
|
|
142
142
|
url: '/tools/' + (config.projectTools.fileName || 'index.html'),
|
|
143
143
|
environments: config.projectTools.environments,
|
|
144
144
|
},
|
|
@@ -150,7 +150,7 @@ function handle(config) {
|
|
|
150
150
|
key: config.identifier + '-project-reports',
|
|
151
151
|
name: config.projectReports.name || config.name,
|
|
152
152
|
description: config.description,
|
|
153
|
-
logo: (0, util_1.getLogoUrl)(config
|
|
153
|
+
logo: (0, util_1.getLogoUrl)(config.projectReports, '/reports'),
|
|
154
154
|
url: '/reports/' + (config.projectReports.fileName || 'index.html'),
|
|
155
155
|
},
|
|
156
156
|
];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
|
-
|
|
4
|
-
export default function handle(config: Config): (req: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
3
|
+
export default function handle(): (req: import("../models").CrowdinClientRequest | Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -11,12 +11,13 @@ 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 connection_1 = require("../util/connection");
|
|
14
|
-
|
|
14
|
+
const logger_1 = require("../util/logger");
|
|
15
|
+
function handle() {
|
|
15
16
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
16
17
|
const organizationId = (req.query || {})['organization_id'] || (req.body || {})['organization_id'];
|
|
17
|
-
(0,
|
|
18
|
+
(0, logger_1.log)(`Received subscription paid request for organization ${organizationId}`);
|
|
18
19
|
(0, connection_1.clearCache)(organizationId);
|
|
19
20
|
res.status(204).end();
|
|
20
|
-
})
|
|
21
|
+
}));
|
|
21
22
|
}
|
|
22
23
|
exports.default = handle;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
3
|
import { Config } from '../models';
|
|
4
|
-
export default function handle(config: Config): (req: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
4
|
+
export default function handle(config: Config): (req: import("../models").CrowdinClientRequest | Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -12,11 +12,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
const storage_1 = require("../storage");
|
|
13
13
|
const util_1 = require("../util");
|
|
14
14
|
const connection_1 = require("../util/connection");
|
|
15
|
+
const logger_1 = require("../util/logger");
|
|
15
16
|
const webhooks_1 = require("../util/webhooks");
|
|
16
17
|
function handle(config) {
|
|
17
18
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
18
19
|
const event = req.body;
|
|
19
|
-
(0,
|
|
20
|
+
(0, logger_1.log)(`Received uninstall request ${JSON.stringify(event, null, 2)}`);
|
|
20
21
|
const projectIntegration = config.projectIntegration;
|
|
21
22
|
const organization = (event.domain || event.organizationId).toString();
|
|
22
23
|
if (config.onUninstall) {
|
|
@@ -32,20 +33,20 @@ function handle(config) {
|
|
|
32
33
|
return { settings, credentials };
|
|
33
34
|
})));
|
|
34
35
|
}
|
|
35
|
-
(0,
|
|
36
|
+
(0, logger_1.log)('Invoking onUninstall hook');
|
|
36
37
|
yield config.onUninstall(organization, allCredentials);
|
|
37
38
|
}
|
|
38
39
|
if (projectIntegration) {
|
|
39
40
|
if (projectIntegration.webhooks) {
|
|
40
41
|
yield (0, webhooks_1.unregisterAllCrowdinWebhooks)(config, projectIntegration, organization);
|
|
41
42
|
}
|
|
42
|
-
(0,
|
|
43
|
+
(0, logger_1.log)(`Deleting all integration credentials for ${organization} organization`);
|
|
43
44
|
yield (0, storage_1.getStorage)().deleteAllIntegrationCredentials(organization);
|
|
44
45
|
}
|
|
45
|
-
(0,
|
|
46
|
+
(0, logger_1.log)(`Deleting crowdin credentials for ${organization} organization`);
|
|
46
47
|
yield (0, storage_1.getStorage)().deleteCrowdinCredentials(organization);
|
|
47
|
-
(0,
|
|
48
|
+
(0, logger_1.log)('App has been uninstalled');
|
|
48
49
|
res.status(204).end();
|
|
49
|
-
})
|
|
50
|
+
}));
|
|
50
51
|
}
|
|
51
52
|
exports.default = handle;
|
package/out/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Express } from 'express';
|
|
2
2
|
import { ClientConfig, Config, CrowdinAppUtilities } from './models';
|
|
3
3
|
import express from './util/terminus-express';
|
|
4
|
-
export { Scope, UserPermissions
|
|
4
|
+
export { ProjectPermissions, Scope, UserPermissions } from './models';
|
|
5
5
|
export { express };
|
|
6
6
|
export declare function addCrowdinEndpoints(app: Express, clientConfig: Config | ClientConfig): CrowdinAppUtilities;
|
|
7
7
|
export declare function createApp(clientConfig: ClientConfig): void;
|
package/out/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.createApp = exports.addCrowdinEndpoints = exports.express = exports.
|
|
38
|
+
exports.createApp = exports.addCrowdinEndpoints = exports.express = exports.UserPermissions = exports.Scope = exports.ProjectPermissions = void 0;
|
|
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");
|
|
@@ -79,20 +79,23 @@ const api_1 = require("./util/api/api");
|
|
|
79
79
|
const connection_1 = require("./util/connection");
|
|
80
80
|
const cron_1 = require("./util/cron");
|
|
81
81
|
const defaults_1 = require("./util/defaults");
|
|
82
|
+
const logger = __importStar(require("./util/logger"));
|
|
83
|
+
const logger_1 = require("./util/logger");
|
|
82
84
|
const terminus_express_1 = __importDefault(require("./util/terminus-express"));
|
|
83
85
|
exports.express = terminus_express_1.default;
|
|
84
86
|
const webhooks_1 = require("./util/webhooks");
|
|
85
87
|
var models_2 = require("./models");
|
|
88
|
+
Object.defineProperty(exports, "ProjectPermissions", { enumerable: true, get: function () { return models_2.ProjectPermissions; } });
|
|
86
89
|
Object.defineProperty(exports, "Scope", { enumerable: true, get: function () { return models_2.Scope; } });
|
|
87
90
|
Object.defineProperty(exports, "UserPermissions", { enumerable: true, get: function () { return models_2.UserPermissions; } });
|
|
88
|
-
Object.defineProperty(exports, "ProjectPermissions", { enumerable: true, get: function () { return models_2.ProjectPermissions; } });
|
|
89
91
|
function addCrowdinEndpoints(app, clientConfig) {
|
|
90
92
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
91
93
|
const config = (0, defaults_1.convertClientConfig)(clientConfig);
|
|
92
94
|
if (!config.disableGlobalErrorHandling) {
|
|
93
|
-
handleUncaughtErrors(
|
|
95
|
+
handleUncaughtErrors();
|
|
94
96
|
}
|
|
95
97
|
storage.initialize(config);
|
|
98
|
+
logger.initialize(config);
|
|
96
99
|
app.use(terminus_express_1.default.json({ limit: '50mb' }));
|
|
97
100
|
app.use('/assets', terminus_express_1.default.static((0, path_1.join)(__dirname, 'static')));
|
|
98
101
|
app.set('views', (0, path_1.join)(__dirname, 'views'));
|
|
@@ -124,31 +127,31 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
124
127
|
},
|
|
125
128
|
}));
|
|
126
129
|
app.set('view engine', 'handlebars');
|
|
127
|
-
app.get((0, util_1.getLogoUrl)(
|
|
130
|
+
app.get((0, util_1.getLogoUrl)(), (req, res) => res.sendFile(config.imagePath));
|
|
128
131
|
app.post('/installed', (0, install_1.default)(config));
|
|
129
132
|
app.post('/uninstall', (0, uninstall_1.default)(config));
|
|
130
133
|
app.get('/manifest.json', json_response_1.default, (0, manifest_1.default)(config));
|
|
131
134
|
if (!(0, connection_1.isAppFree)(config)) {
|
|
132
|
-
app.post('/subscription-paid', (0, subscription_paid_1.default)(
|
|
135
|
+
app.post('/subscription-paid', (0, subscription_paid_1.default)());
|
|
133
136
|
}
|
|
134
137
|
const integrationLogic = config.projectIntegration;
|
|
135
138
|
if (integrationLogic) {
|
|
136
139
|
(0, defaults_1.applyIntegrationModuleDefaults)(config, integrationLogic);
|
|
137
|
-
app.get((0, util_1.getLogoUrl)(
|
|
140
|
+
app.get((0, util_1.getLogoUrl)(integrationLogic, '/integration'), (req, res) => res.sendFile(integrationLogic.imagePath || config.imagePath));
|
|
138
141
|
app.get('/', (0, crowdin_client_1.default)(config, true, false), (0, integration_credentials_1.default)(config, integrationLogic, true), (0, main_1.default)(config, integrationLogic));
|
|
139
142
|
app.get('/api/subscription-info', json_response_1.default, (0, crowdin_client_1.default)(config), (0, subscription_info_1.default)(config));
|
|
140
143
|
app.post('/api/settings', (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, settings_save_1.default)(config, integrationLogic));
|
|
141
144
|
app.post('/api/login', (0, crowdin_client_1.default)(config, false, false), (0, integration_login_1.default)(config, integrationLogic));
|
|
142
145
|
app.post('/api/logout', (0, crowdin_client_1.default)(config, false, false), (0, integration_credentials_1.default)(config, integrationLogic), (0, integration_logout_1.default)(config, integrationLogic));
|
|
143
146
|
app.get('/api/crowdin/files', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, crowdin_files_1.default)(config, integrationLogic));
|
|
144
|
-
app.get('/api/crowdin/project', json_response_1.default, (0, crowdin_client_1.default)(config), (0, crowdin_project_1.default)(
|
|
145
|
-
app.get('/api/crowdin/file-progress/:fileId', (0, crowdin_client_1.default)(config), (0, crowdin_file_progress_1.default)(
|
|
146
|
-
app.get('/api/integration/data', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, integration_data_1.default)(
|
|
147
|
+
app.get('/api/crowdin/project', json_response_1.default, (0, crowdin_client_1.default)(config), (0, crowdin_project_1.default)());
|
|
148
|
+
app.get('/api/crowdin/file-progress/:fileId', (0, crowdin_client_1.default)(config), (0, crowdin_file_progress_1.default)(integrationLogic));
|
|
149
|
+
app.get('/api/integration/data', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, integration_data_1.default)(integrationLogic));
|
|
147
150
|
app.post('/api/crowdin/update', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, crowdin_update_1.default)(config, integrationLogic));
|
|
148
151
|
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));
|
|
149
|
-
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)(
|
|
152
|
+
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)());
|
|
150
153
|
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));
|
|
151
|
-
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)(
|
|
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)());
|
|
152
155
|
if (integrationLogic.oauthLogin) {
|
|
153
156
|
app.get((0, defaults_1.getOauthRoute)(integrationLogic), (0, oauth_login_1.default)(config, integrationLogic));
|
|
154
157
|
app.post('/api/oauth-url', json_response_1.default, (0, crowdin_client_1.default)(config, false, false), (0, oauth_url_1.default)(config, integrationLogic));
|
|
@@ -180,7 +183,7 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
180
183
|
}
|
|
181
184
|
}
|
|
182
185
|
if (config.customFileFormat) {
|
|
183
|
-
app.post('/process', (0, crowdin_client_1.default)(config), (0, custom_file_format_1.default)(config
|
|
186
|
+
app.post('/process', (0, crowdin_client_1.default)(config), (0, custom_file_format_1.default)(config.baseUrl, config.customFileFormat.filesFolder || config.dbFolder, config.customFileFormat));
|
|
184
187
|
app.get('/file/download', (0, file_download_1.default)(config, config.customFileFormat, 'custom-file-format'));
|
|
185
188
|
}
|
|
186
189
|
if (config.filePreImport) {
|
|
@@ -200,39 +203,39 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
200
203
|
app.get(`/file/download/${models_1.ProcessFileJobType.POST_EXPORT}`, (0, file_download_1.default)(config, config.filePostExport, models_1.ProcessFileJobType.POST_EXPORT));
|
|
201
204
|
}
|
|
202
205
|
if (config.customMT) {
|
|
203
|
-
app.get((0, util_1.getLogoUrl)(config
|
|
204
|
-
app.post('/translate', (0, crowdin_client_1.default)(config), (0, translate_1.default)(config
|
|
206
|
+
app.get((0, util_1.getLogoUrl)(config.customMT, '/mt'), (req, res) => { var _a; return res.sendFile(((_a = config.customMT) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
|
|
207
|
+
app.post('/translate', (0, crowdin_client_1.default)(config), (0, translate_1.default)(config.customMT));
|
|
205
208
|
}
|
|
206
209
|
if (config.profileResourcesMenu) {
|
|
207
|
-
app.get((0, util_1.getLogoUrl)(config
|
|
208
|
-
app.use('/resources', (0, ui_module_1.default)(config, config.profileResourcesMenu.allowUnauthorized), (0, render_ui_module_1.default)(config
|
|
210
|
+
app.get((0, util_1.getLogoUrl)(config.profileResourcesMenu, '/resources'), (req, res) => { var _a; return res.sendFile(((_a = config.profileResourcesMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
|
|
211
|
+
app.use('/resources', (0, ui_module_1.default)(config, config.profileResourcesMenu.allowUnauthorized), (0, render_ui_module_1.default)(config.profileResourcesMenu));
|
|
209
212
|
}
|
|
210
213
|
if (config.organizationMenu) {
|
|
211
|
-
app.get((0, util_1.getLogoUrl)(config
|
|
212
|
-
app.use('/resources', (0, ui_module_1.default)(config, config.organizationMenu.allowUnauthorized), (0, render_ui_module_1.default)(config
|
|
214
|
+
app.get((0, util_1.getLogoUrl)(config.organizationMenu, '/resources'), (req, res) => { var _a; return res.sendFile(((_a = config.organizationMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
|
|
215
|
+
app.use('/resources', (0, ui_module_1.default)(config, config.organizationMenu.allowUnauthorized), (0, render_ui_module_1.default)(config.organizationMenu));
|
|
213
216
|
}
|
|
214
217
|
if (config.editorRightPanel) {
|
|
215
|
-
app.use('/editor-panels', (0, ui_module_1.default)(config, config.editorRightPanel.allowUnauthorized), (0, render_ui_module_1.default)(config
|
|
218
|
+
app.use('/editor-panels', (0, ui_module_1.default)(config, config.editorRightPanel.allowUnauthorized), (0, render_ui_module_1.default)(config.editorRightPanel));
|
|
216
219
|
}
|
|
217
220
|
if (config.projectMenu) {
|
|
218
|
-
app.use('/project-menu', (0, ui_module_1.default)(config, config.projectMenu.allowUnauthorized), (0, render_ui_module_1.default)(config
|
|
221
|
+
app.use('/project-menu', (0, ui_module_1.default)(config, config.projectMenu.allowUnauthorized), (0, render_ui_module_1.default)(config.projectMenu));
|
|
219
222
|
}
|
|
220
223
|
if (config.projectMenuCrowdsource) {
|
|
221
|
-
app.use('/project-menu-crowdsource', (0, ui_module_1.default)(config, config.projectMenuCrowdsource.allowUnauthorized), (0, render_ui_module_1.default)(config
|
|
224
|
+
app.use('/project-menu-crowdsource', (0, ui_module_1.default)(config, config.projectMenuCrowdsource.allowUnauthorized), (0, render_ui_module_1.default)(config.projectMenuCrowdsource));
|
|
222
225
|
}
|
|
223
226
|
if (config.projectTools) {
|
|
224
|
-
app.get((0, util_1.getLogoUrl)(config
|
|
225
|
-
app.use('/tools', (0, ui_module_1.default)(config, config.projectTools.allowUnauthorized), (0, render_ui_module_1.default)(config
|
|
227
|
+
app.get((0, util_1.getLogoUrl)(config.projectTools, '/tools'), (req, res) => { var _a; return res.sendFile(((_a = config.projectTools) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
|
|
228
|
+
app.use('/tools', (0, ui_module_1.default)(config, config.projectTools.allowUnauthorized), (0, render_ui_module_1.default)(config.projectTools));
|
|
226
229
|
}
|
|
227
230
|
if (config.projectReports) {
|
|
228
|
-
app.get((0, util_1.getLogoUrl)(config
|
|
229
|
-
app.use('/reports', (0, ui_module_1.default)(config, config.projectReports.allowUnauthorized), (0, render_ui_module_1.default)(config
|
|
231
|
+
app.get((0, util_1.getLogoUrl)(config.projectReports, '/reports'), (req, res) => { var _a; return res.sendFile(((_a = config.projectReports) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
|
|
232
|
+
app.use('/reports', (0, ui_module_1.default)(config, config.projectReports.allowUnauthorized), (0, render_ui_module_1.default)(config.projectReports));
|
|
230
233
|
}
|
|
231
234
|
if (((_d = config.modal) === null || _d === void 0 ? void 0 : _d.uiPath) || ((_e = config.modal) === null || _e === void 0 ? void 0 : _e.formSchema)) {
|
|
232
|
-
app.use('/modal', (0, ui_module_1.default)(config, config.modal.allowUnauthorized), (0, render_ui_module_1.default)(config
|
|
235
|
+
app.use('/modal', (0, ui_module_1.default)(config, config.modal.allowUnauthorized), (0, render_ui_module_1.default)(config.modal));
|
|
233
236
|
}
|
|
234
237
|
if (((_f = config.contextMenu) === null || _f === void 0 ? void 0 : _f.uiPath) || ((_g = config.contextMenu) === null || _g === void 0 ? void 0 : _g.formSchema)) {
|
|
235
|
-
app.use('/context', (0, ui_module_1.default)(config, config.contextMenu.allowUnauthorized), (0, render_ui_module_1.default)(config
|
|
238
|
+
app.use('/context', (0, ui_module_1.default)(config, config.contextMenu.allowUnauthorized), (0, render_ui_module_1.default)(config.contextMenu));
|
|
236
239
|
}
|
|
237
240
|
if (config.api) {
|
|
238
241
|
if (config.api.default) {
|
|
@@ -278,11 +281,11 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
278
281
|
encryptCrowdinConnection: (data) => (0, util_1.encryptData)(config, JSON.stringify(data)),
|
|
279
282
|
dencryptCrowdinConnection: (hash) => __awaiter(this, void 0, void 0, function* () {
|
|
280
283
|
const { crowdinId, extra } = JSON.parse((0, util_1.decryptData)(config, hash));
|
|
281
|
-
const
|
|
282
|
-
if (!
|
|
284
|
+
const credentials = yield storage.getStorage().getCrowdinCredentials(crowdinId);
|
|
285
|
+
if (!credentials) {
|
|
283
286
|
throw new Error('Failed to find Crowdin credentials');
|
|
284
287
|
}
|
|
285
|
-
const { client } = yield (0, connection_1.prepareCrowdinClient)(config,
|
|
288
|
+
const { client } = yield (0, connection_1.prepareCrowdinClient)({ config, credentials });
|
|
286
289
|
return { client, extra };
|
|
287
290
|
}),
|
|
288
291
|
};
|
|
@@ -296,14 +299,14 @@ function createApp(clientConfig) {
|
|
|
296
299
|
app.listen(config.port, () => console.log(`App started on port ${config.port}`));
|
|
297
300
|
}
|
|
298
301
|
exports.createApp = createApp;
|
|
299
|
-
function handleUncaughtErrors(
|
|
302
|
+
function handleUncaughtErrors() {
|
|
300
303
|
process
|
|
301
304
|
.on('unhandledRejection', (reason) => {
|
|
302
305
|
const error = `Unhandled Rejection. Reason: ${reason.stack || reason}`;
|
|
303
|
-
(0,
|
|
306
|
+
(0, logger_1.logError)(error);
|
|
304
307
|
})
|
|
305
308
|
.on('uncaughtException', (reason) => {
|
|
306
309
|
const error = `Uncaught Exception. Reason: ${reason.stack || reason}`;
|
|
307
|
-
(0,
|
|
310
|
+
(0, logger_1.logError)(error);
|
|
308
311
|
});
|
|
309
312
|
}
|
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
import Crowdin from '@crowdin/crowdin-api-client';
|
|
3
3
|
import { Response } from 'express';
|
|
4
4
|
import { Config, CrowdinClientRequest, CrowdinContextInfo, SubscriptionInfo } from '../models';
|
|
5
|
+
import { LogErrorFunction, LogFunction } from '../util/logger';
|
|
5
6
|
export declare function prepareCrowdinRequest(jwtToken: string, config: Config, optional?: boolean, checkSubscriptionExpiration?: boolean): Promise<{
|
|
6
7
|
context: CrowdinContextInfo;
|
|
8
|
+
logInfo: LogFunction;
|
|
9
|
+
logError: LogErrorFunction;
|
|
7
10
|
client?: Crowdin;
|
|
8
11
|
subscriptionInfo?: SubscriptionInfo;
|
|
9
12
|
}>;
|
|
10
|
-
export default function handle(config: Config, optional?: boolean, checkSubscriptionExpiration?: boolean): (req: 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;
|
|
13
|
+
export default function handle(config: Config, optional?: boolean, checkSubscriptionExpiration?: boolean): (req: 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;
|
|
11
14
|
export declare function getToken(req: CrowdinClientRequest): string | undefined;
|
|
@@ -13,35 +13,48 @@ exports.getToken = exports.prepareCrowdinRequest = void 0;
|
|
|
13
13
|
const crowdin_apps_functions_1 = require("@crowdin/crowdin-apps-functions");
|
|
14
14
|
const storage_1 = require("../storage");
|
|
15
15
|
const util_1 = require("../util");
|
|
16
|
-
const connection_1 = require("../util/connection");
|
|
17
16
|
const api_1 = require("../util/api/api");
|
|
17
|
+
const connection_1 = require("../util/connection");
|
|
18
|
+
const logger_1 = require("../util/logger");
|
|
18
19
|
function prepareCrowdinRequest(jwtToken, config, optional = false, checkSubscriptionExpiration = true) {
|
|
19
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
(0,
|
|
21
|
+
(0, logger_1.log)('Validating jwt token from incoming request');
|
|
21
22
|
const jwtPayload = yield (0, crowdin_apps_functions_1.validateJwtToken)(jwtToken, config.clientSecret, config.jwtValidationOptions);
|
|
22
23
|
const context = {
|
|
23
24
|
jwtPayload,
|
|
24
25
|
clientId: (0, crowdin_apps_functions_1.constructCrowdinIdFromJwtPayload)(jwtPayload),
|
|
25
26
|
crowdinId: `${jwtPayload.domain || jwtPayload.context.organization_id}`,
|
|
26
27
|
};
|
|
27
|
-
|
|
28
|
+
const logContext = {
|
|
29
|
+
orgId: context.crowdinId,
|
|
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);
|
|
35
|
+
logInfo('Loading crowdin credentials');
|
|
28
36
|
const credentials = yield (0, storage_1.getStorage)().getCrowdinCredentials(context.crowdinId);
|
|
29
37
|
if (!credentials) {
|
|
30
38
|
if (optional) {
|
|
31
|
-
return { context };
|
|
39
|
+
return { context, logInfo, logError };
|
|
32
40
|
}
|
|
33
41
|
throw new Error("Can't find organization by id");
|
|
34
42
|
}
|
|
35
|
-
(
|
|
36
|
-
const { client, token } = yield (0, connection_1.prepareCrowdinClient)(config, credentials);
|
|
43
|
+
logInfo('Building crowdin client instance');
|
|
44
|
+
const { client, token } = yield (0, connection_1.prepareCrowdinClient)({ config, credentials });
|
|
37
45
|
let subscriptionInfo;
|
|
38
46
|
if (checkSubscriptionExpiration) {
|
|
39
|
-
subscriptionInfo = yield (0, connection_1.checkSubscription)(
|
|
47
|
+
subscriptionInfo = yield (0, connection_1.checkSubscription)({
|
|
48
|
+
config,
|
|
49
|
+
token,
|
|
50
|
+
organization: credentials.id,
|
|
51
|
+
accountType: credentials.type,
|
|
52
|
+
});
|
|
40
53
|
if (subscriptionInfo.expired) {
|
|
41
54
|
throw new util_1.CodeError(subscriptionInfo.subscribeLink || '', 402);
|
|
42
55
|
}
|
|
43
56
|
}
|
|
44
|
-
return { context, client, subscriptionInfo };
|
|
57
|
+
return { context, client, subscriptionInfo, logInfo, logError };
|
|
45
58
|
});
|
|
46
59
|
}
|
|
47
60
|
exports.prepareCrowdinRequest = prepareCrowdinRequest;
|
|
@@ -62,22 +75,19 @@ function handle(config, optional = false, checkSubscriptionExpiration = true) {
|
|
|
62
75
|
req.crowdinApiClient = data.client;
|
|
63
76
|
}
|
|
64
77
|
req.subscriptionInfo = data.subscriptionInfo;
|
|
78
|
+
req.logInfo = data.logInfo;
|
|
79
|
+
req.logError = data.logError;
|
|
65
80
|
next();
|
|
66
81
|
}
|
|
67
82
|
catch (e) {
|
|
83
|
+
(0, logger_1.logError)(e);
|
|
68
84
|
if (e instanceof util_1.CodeError) {
|
|
69
85
|
throw e;
|
|
70
86
|
}
|
|
71
|
-
|
|
72
|
-
config.onError(e);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
console.error(e);
|
|
76
|
-
}
|
|
77
|
-
const message = typeof e === 'string' ? e : e.message;
|
|
87
|
+
const message = (0, logger_1.getErrorMessage)(e);
|
|
78
88
|
return res.status(403).send({ error: message || 'Error' });
|
|
79
89
|
}
|
|
80
|
-
})
|
|
90
|
+
}));
|
|
81
91
|
}
|
|
82
92
|
exports.default = handle;
|
|
83
93
|
function getToken(req) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { Config, IntegrationLogic } from '../models';
|
|
4
|
-
export default function handle(config: Config, integration: IntegrationLogic, optional?: boolean): (req: 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;
|
|
4
|
+
export default function handle(config: Config, integration: IntegrationLogic, optional?: boolean): (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;
|
|
@@ -15,7 +15,7 @@ const connection_1 = require("../util/connection");
|
|
|
15
15
|
function handle(config, integration, optional = false) {
|
|
16
16
|
return (0, util_1.runAsyncWrapper)((req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
const clientId = req.crowdinContext.clientId;
|
|
18
|
-
|
|
18
|
+
req.logInfo(`Loading integration credentials for client ${clientId}`);
|
|
19
19
|
const integrationCredentials = yield (0, storage_1.getStorage)().getIntegrationCredentials(clientId);
|
|
20
20
|
if (!integrationCredentials) {
|
|
21
21
|
if (optional) {
|
|
@@ -34,6 +34,6 @@ function handle(config, integration, optional = false) {
|
|
|
34
34
|
throw new util_1.CodeError('Credentials to integration either exprired or invalid', 401);
|
|
35
35
|
}
|
|
36
36
|
next();
|
|
37
|
-
})
|
|
37
|
+
}));
|
|
38
38
|
}
|
|
39
39
|
exports.default = handle;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import express from 'express';
|
|
3
|
-
import {
|
|
4
|
-
export default function handle(
|
|
3
|
+
import { UiModule } from '../models';
|
|
4
|
+
export default function handle(moduleConfig: UiModule): (req: import("../models").CrowdinClientRequest | express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>, next: Function) => void;
|