@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/static/js/main.js
CHANGED
package/out/util/logger.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Config } from '../models';
|
|
1
|
+
import { Config, CrowdinContextInfo } from '../models';
|
|
2
2
|
export type LogFunction = (message: string) => void;
|
|
3
3
|
export type LogErrorFunction = (error: any) => void;
|
|
4
4
|
export type LogContext = {
|
|
@@ -7,8 +7,9 @@ export type LogContext = {
|
|
|
7
7
|
projectId: number;
|
|
8
8
|
};
|
|
9
9
|
export declare function initialize(config: Config): void;
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
10
|
+
export declare function preprareContext(context: CrowdinContextInfo): LogContext;
|
|
11
|
+
export declare function withContext(context: CrowdinContextInfo): LogFunction;
|
|
12
|
+
export declare function withContextError(context: CrowdinContextInfo): LogFunction;
|
|
13
|
+
export declare function log(message: string, context?: CrowdinContextInfo): void;
|
|
14
|
+
export declare function logError(e: any, context?: CrowdinContextInfo): void;
|
|
14
15
|
export declare function getErrorMessage(err: any): any;
|
package/out/util/logger.js
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getErrorMessage = exports.logError = exports.log = exports.withContextError = exports.withContext = exports.initialize = void 0;
|
|
26
|
+
exports.getErrorMessage = exports.logError = exports.log = exports.withContextError = exports.withContext = exports.preprareContext = exports.initialize = void 0;
|
|
27
|
+
const logsFormatter = __importStar(require("@crowdin/logs-formatter"));
|
|
4
28
|
let logConfig;
|
|
5
29
|
let onError;
|
|
6
30
|
function initialize(config) {
|
|
@@ -8,6 +32,14 @@ function initialize(config) {
|
|
|
8
32
|
onError = config.onError;
|
|
9
33
|
}
|
|
10
34
|
exports.initialize = initialize;
|
|
35
|
+
function preprareContext(context) {
|
|
36
|
+
return {
|
|
37
|
+
orgId: context.crowdinId,
|
|
38
|
+
userId: context.clientId,
|
|
39
|
+
projectId: context.jwtPayload.context.project_id,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
exports.preprareContext = preprareContext;
|
|
11
43
|
function withContext(context) {
|
|
12
44
|
return (message) => log(message, context);
|
|
13
45
|
}
|
|
@@ -24,7 +56,16 @@ function log(message, context) {
|
|
|
24
56
|
else {
|
|
25
57
|
let prefix = `[${new Date().toISOString()}]`;
|
|
26
58
|
if (context) {
|
|
27
|
-
|
|
59
|
+
logsFormatter.setContext({
|
|
60
|
+
project: {
|
|
61
|
+
id: context.jwtPayload.context.project_id,
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
63
|
+
organization_id: context.jwtPayload.context.organization_id,
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
65
|
+
user_id: context.jwtPayload.context.user_id,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
prefix += ` Context [${JSON.stringify(preprareContext(context))}]`;
|
|
28
69
|
}
|
|
29
70
|
// eslint-disable-next-line no-console
|
|
30
71
|
console.log(`${prefix} ${message}`);
|
|
@@ -39,7 +80,16 @@ function logError(e, context) {
|
|
|
39
80
|
else {
|
|
40
81
|
let message = `[${new Date().toISOString()}] Error.`;
|
|
41
82
|
if (context) {
|
|
42
|
-
|
|
83
|
+
logsFormatter.setContext({
|
|
84
|
+
project: {
|
|
85
|
+
id: context.jwtPayload.context.project_id,
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
87
|
+
organization_id: context.jwtPayload.context.organization_id,
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
89
|
+
user_id: context.jwtPayload.context.user_id,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
message += ` Context ${JSON.stringify(preprareContext(context))}`;
|
|
43
93
|
}
|
|
44
94
|
if (isAxiosError(e)) {
|
|
45
95
|
const request = e.config ? { url: e.config.url, method: e.config.method, data: e.config.data } : {};
|
|
@@ -176,9 +176,21 @@
|
|
|
176
176
|
{{/ifeq}}
|
|
177
177
|
{{else}}
|
|
178
178
|
{{#if labelHtml}}
|
|
179
|
-
|
|
179
|
+
<crowdin-p
|
|
180
|
+
{{#if dependencySettings}}
|
|
181
|
+
data-dependency="{{dependencySettings}}"
|
|
182
|
+
{{/if}}
|
|
183
|
+
>
|
|
184
|
+
{{{labelHtml}}}
|
|
185
|
+
</crowdin-p>
|
|
180
186
|
{{else}}
|
|
181
|
-
|
|
187
|
+
<crowdin-p
|
|
188
|
+
{{#if dependencySettings}}
|
|
189
|
+
data-dependency="{{dependencySettings}}"
|
|
190
|
+
{{/if}}
|
|
191
|
+
>
|
|
192
|
+
{{label}}
|
|
193
|
+
</crowdin-p>
|
|
182
194
|
{{/if}}
|
|
183
195
|
{{/if}}
|
|
184
196
|
<div
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crowdin/app-project-module",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.2",
|
|
4
4
|
"description": "Module that generates for you all common endpoints for serving standalone Crowdin App",
|
|
5
5
|
"main": "out/index.js",
|
|
6
6
|
"types": "out/index.d.ts",
|
|
@@ -15,26 +15,27 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@crowdin/crowdin-apps-functions": "0.5.1",
|
|
18
|
+
"@crowdin/logs-formatter": "^2.0.3",
|
|
18
19
|
"@godaddy/terminus": "^4.12.1",
|
|
19
|
-
"@types/pg": "^8.
|
|
20
|
+
"@types/pg": "^8.10.2",
|
|
20
21
|
"amqplib": "^0.10.3",
|
|
21
22
|
"crypto-js": "^4.0.0",
|
|
22
23
|
"express": "4.18.2",
|
|
23
24
|
"express-handlebars": "^5.3.5",
|
|
24
25
|
"mysql2": "^2.3.3",
|
|
25
26
|
"node-cron": "^3.0.2",
|
|
26
|
-
"pg": "^8.
|
|
27
|
+
"pg": "^8.11.3",
|
|
27
28
|
"redoc-express": "^2.1.0",
|
|
28
29
|
"sqlite3": "^5.1.6",
|
|
29
30
|
"swagger-jsdoc": "^6.2.8",
|
|
30
31
|
"uuid": "^8.3.2"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
|
-
"@babel/preset-react": "^7.22.
|
|
34
|
+
"@babel/preset-react": "^7.22.5",
|
|
34
35
|
"@emotion/react": "^11.11.1",
|
|
35
36
|
"@emotion/styled": "^11.11.0",
|
|
36
|
-
"@mui/icons-material": "^5.
|
|
37
|
-
"@mui/material": "^5.14.
|
|
37
|
+
"@mui/icons-material": "^5.14.7",
|
|
38
|
+
"@mui/material": "^5.14.7",
|
|
38
39
|
"@rjsf/core": "^5.7.3",
|
|
39
40
|
"@rjsf/mui": "^5.7.3",
|
|
40
41
|
"@rjsf/utils": "^5.7.3",
|