@crowdin/app-project-module 0.33.0 → 0.34.2
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/index.js +5 -0
- package/out/middlewares/crowdin-client.js +3 -8
- package/out/middlewares/ui-module.js +3 -3
- package/out/models/index.d.ts +7 -3
- package/out/static/js/form.js +7 -7
- package/out/static/js/main.js +1 -0
- package/out/util/logger.d.ts +6 -5
- package/out/util/logger.js +53 -3
- package/out/views/main.handlebars +14 -2
- package/package.json +7 -6
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"));
|
|
@@ -96,6 +97,10 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
96
97
|
storage.initialize(config);
|
|
97
98
|
logger.initialize(config);
|
|
98
99
|
app.use(terminus_express_1.default.json({ limit: '50mb' }));
|
|
100
|
+
if (!config.disableLogsFormatter) {
|
|
101
|
+
logsFormatter.setup();
|
|
102
|
+
app.use(logsFormatter.expressMiddleware());
|
|
103
|
+
}
|
|
99
104
|
app.use('/assets', terminus_express_1.default.static((0, path_1.join)(__dirname, 'static')));
|
|
100
105
|
app.set('views', (0, path_1.join)(__dirname, 'views'));
|
|
101
106
|
app.engine('handlebars', (0, express_handlebars_1.default)({
|
|
@@ -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) {
|
|
@@ -41,7 +36,7 @@ function prepareCrowdinRequest(jwtToken, config, optional = false, checkSubscrip
|
|
|
41
36
|
throw new Error("Can't find organization by id");
|
|
42
37
|
}
|
|
43
38
|
logInfo('Building crowdin client instance');
|
|
44
|
-
const { client, token } = yield (0, connection_1.prepareCrowdinClient)({ config, credentials });
|
|
39
|
+
const { client, token } = yield (0, connection_1.prepareCrowdinClient)({ config, credentials, autoRenew: true });
|
|
45
40
|
let subscriptionInfo;
|
|
46
41
|
if (checkSubscriptionExpiration) {
|
|
47
42
|
subscriptionInfo = yield (0, connection_1.checkSubscription)({
|
|
@@ -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;
|
|
@@ -834,7 +838,7 @@ export interface ApiModule {
|
|
|
834
838
|
}
|
|
835
839
|
export interface Logger {
|
|
836
840
|
enabled: boolean;
|
|
837
|
-
log?: (message: string, context?:
|
|
841
|
+
log?: (message: string, context?: CrowdinContextInfo) => void;
|
|
838
842
|
}
|
|
839
843
|
export interface Pricing {
|
|
840
844
|
planType: 'free' | 'recurring';
|