@crowdin/app-project-module 0.107.0 → 1.0.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/app-test/integration/get-integration-files.js +16 -4
- package/out/app-test/integration/types.d.ts +1 -1
- package/out/app-test/integration/update-crowdin.js +2 -2
- package/out/app-test/integration/update-integration.js +2 -2
- package/out/index.d.ts +2 -1
- package/out/index.js +73 -30
- package/out/middlewares/auto-credentials-masker.d.ts +4 -0
- package/out/middlewares/auto-credentials-masker.js +45 -0
- package/out/middlewares/crowdin-client.d.ts +1 -1
- package/out/middlewares/integration-credentials.d.ts +2 -2
- package/out/middlewares/integration-credentials.js +7 -4
- package/out/middlewares/render-ui-module.d.ts +3 -3
- package/out/middlewares/render-ui-module.js +10 -13
- package/out/middlewares/ui-module.d.ts +1 -1
- package/out/middlewares/ui-module.js +11 -1
- package/out/modules/about.d.ts +2 -1
- package/out/modules/about.js +10 -3
- package/out/modules/ai-prompt-provider/handlers/compile.d.ts +1 -1
- package/out/modules/ai-prompt-provider/handlers/compile.js +7 -1
- package/out/modules/ai-prompt-provider/index.js +2 -2
- package/out/modules/ai-prompt-provider/types.d.ts +7 -1
- package/out/modules/ai-provider/handlers/chat-completions.d.ts +1 -1
- package/out/modules/ai-provider/handlers/chat-completions.js +1 -1
- package/out/modules/ai-provider/handlers/get-model-list.d.ts +1 -1
- package/out/modules/ai-provider/index.js +2 -2
- package/out/modules/ai-provider/types.d.ts +4 -4
- package/out/modules/ai-request-processors/handler.d.ts +1 -1
- package/out/modules/ai-request-processors/handler.js +12 -2
- package/out/modules/ai-request-processors/types.d.ts +12 -2
- package/out/modules/ai-tools/handlers/tool-calls.d.ts +1 -1
- package/out/modules/ai-tools/handlers/tool-calls.js +1 -1
- package/out/modules/ai-tools/index.js +1 -1
- package/out/modules/ai-tools/types.d.ts +1 -1
- package/out/modules/api/api.js +58 -7
- package/out/modules/api/base.d.ts +1 -0
- package/out/modules/api/base.js +1 -0
- package/out/modules/api/components.d.ts +251 -27
- package/out/modules/api/components.js +251 -27
- package/out/modules/auth-guard/handlers/verify.d.ts +1 -1
- package/out/modules/auth-guard/index.js +1 -1
- package/out/modules/automation-action/handlers/execute.d.ts +1 -1
- package/out/modules/automation-action/handlers/execute.js +1 -1
- package/out/modules/automation-action/handlers/input-schema.d.ts +1 -1
- package/out/modules/automation-action/handlers/output-schema.d.ts +1 -1
- package/out/modules/automation-action/handlers/validate-settings.d.ts +1 -1
- package/out/modules/automation-action/handlers/validate-settings.js +1 -1
- package/out/modules/automation-action/index.js +1 -1
- package/out/modules/automation-action/types.d.ts +4 -4
- package/out/modules/automation-action/util/index.js +2 -5
- package/out/modules/context-menu/index.js +2 -2
- package/out/modules/custom-mt/handlers/translate.d.ts +1 -1
- package/out/modules/custom-mt/handlers/translate.js +25 -9
- package/out/modules/custom-mt/index.js +3 -3
- package/out/modules/custom-mt/types.d.ts +10 -2
- package/out/modules/custom-spell-check/handlers/get-languages-list.d.ts +1 -1
- package/out/modules/custom-spell-check/handlers/spell-check.d.ts +1 -1
- package/out/modules/custom-spell-check/index.js +4 -4
- package/out/modules/editor-right-panel/index.js +1 -1
- package/out/modules/external-qa-check/handlers/validate.d.ts +1 -1
- package/out/modules/external-qa-check/index.js +2 -2
- package/out/modules/file-processing/handlers/custom-file-format.d.ts +7 -2
- package/out/modules/file-processing/handlers/custom-file-format.js +62 -22
- package/out/modules/file-processing/handlers/file-download.d.ts +1 -1
- package/out/modules/file-processing/handlers/file-download.js +5 -0
- package/out/modules/file-processing/handlers/pre-post-process.d.ts +1 -1
- package/out/modules/file-processing/handlers/pre-post-process.js +41 -15
- package/out/modules/file-processing/handlers/translations-alignment.d.ts +1 -1
- package/out/modules/file-processing/handlers/translations-alignment.js +10 -4
- package/out/modules/file-processing/index.js +12 -2
- package/out/modules/file-processing/types.d.ts +36 -5
- package/out/modules/file-processing/util/defaults.js +50 -6
- package/out/modules/file-processing/util/files.js +2 -1
- package/out/modules/form-data-display.d.ts +1 -1
- package/out/modules/form-data-save.d.ts +1 -1
- package/out/modules/install.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-file-progress.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-file-progress.js +5 -1
- package/out/modules/integration/handlers/crowdin-files-target-languages.d.ts +5 -0
- package/out/modules/integration/handlers/crowdin-files-target-languages.js +103 -0
- package/out/modules/integration/handlers/crowdin-files.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-files.js +7 -1
- package/out/modules/integration/handlers/crowdin-project.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-update.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-update.js +59 -18
- package/out/modules/integration/handlers/crowdin-webhook.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-webhook.js +15 -8
- package/out/modules/integration/handlers/integration-data.d.ts +1 -1
- package/out/modules/integration/handlers/integration-data.js +13 -6
- package/out/modules/integration/handlers/integration-login.d.ts +1 -1
- package/out/modules/integration/handlers/integration-logout.d.ts +1 -1
- package/out/modules/integration/handlers/integration-logout.js +8 -3
- package/out/modules/integration/handlers/integration-update.d.ts +1 -1
- package/out/modules/integration/handlers/integration-update.js +44 -6
- package/out/modules/integration/handlers/integration-webhook.d.ts +1 -1
- package/out/modules/integration/handlers/invite-users.d.ts +1 -1
- package/out/modules/integration/handlers/job-cancel.d.ts +1 -1
- package/out/modules/integration/handlers/job-info-deprecated.d.ts +1 -1
- package/out/modules/integration/handlers/job-info-deprecated.js +3 -2
- package/out/modules/integration/handlers/job-info.d.ts +1 -1
- package/out/modules/integration/handlers/job-list.d.ts +1 -1
- package/out/modules/integration/handlers/main.d.ts +1 -1
- package/out/modules/integration/handlers/main.js +32 -2
- package/out/modules/integration/handlers/oauth-login.d.ts +1 -1
- package/out/modules/integration/handlers/oauth-login.js +28 -6
- package/out/modules/integration/handlers/oauth-polling.d.ts +1 -1
- package/out/modules/integration/handlers/oauth-url.d.ts +1 -1
- package/out/modules/integration/handlers/settings-save.d.ts +1 -1
- package/out/modules/integration/handlers/settings-save.js +9 -9
- package/out/modules/integration/handlers/settings.d.ts +1 -1
- package/out/modules/integration/handlers/sync-settings-save.d.ts +1 -1
- package/out/modules/integration/handlers/sync-settings-save.js +5 -9
- package/out/modules/integration/handlers/sync-settings.d.ts +1 -1
- package/out/modules/integration/handlers/user-errors.d.ts +1 -1
- package/out/modules/integration/handlers/users.d.ts +1 -1
- package/out/modules/integration/index.js +19 -33
- package/out/modules/integration/types.d.ts +133 -29
- package/out/modules/integration/types.js +1 -0
- package/out/modules/integration/util/cron.d.ts +2 -2
- package/out/modules/integration/util/cron.js +40 -24
- package/out/modules/integration/util/defaults.d.ts +4 -0
- package/out/modules/integration/util/defaults.js +175 -15
- package/out/modules/integration/util/files.d.ts +2 -1
- package/out/modules/integration/util/files.js +19 -8
- package/out/modules/integration/util/job.js +4 -3
- package/out/modules/integration/util/snapshot.js +19 -3
- package/out/modules/integration/util/types.d.ts +1 -0
- package/out/modules/integration/util/types.js +1 -0
- package/out/modules/integration/util/webhooks.d.ts +8 -8
- package/out/modules/integration/util/webhooks.js +34 -17
- package/out/modules/manifest.js +12 -12
- package/out/modules/modal/index.js +2 -2
- package/out/modules/organization-menu/index.js +5 -4
- package/out/modules/organization-settings-menu/index.js +5 -4
- package/out/modules/profile-resources-menu/index.js +5 -4
- package/out/modules/profile-settings-menu/index.js +5 -4
- package/out/modules/project-menu/index.js +1 -1
- package/out/modules/project-menu-crowdsource/index.js +1 -1
- package/out/modules/project-reports/index.js +3 -2
- package/out/modules/project-tools/index.js +3 -2
- package/out/modules/status.d.ts +1 -1
- package/out/modules/status.js +12 -3
- package/out/modules/subscription-paid.d.ts +1 -1
- package/out/modules/uninstall.d.ts +1 -1
- package/out/modules/uninstall.js +1 -1
- package/out/modules/webhooks/handlers/webhook-handler.d.ts +2 -2
- package/out/modules/webhooks/handlers/webhook-handler.js +33 -22
- package/out/modules/webhooks/types.d.ts +7 -0
- package/out/modules/workflow-step-type/handlers/delete-step.d.ts +1 -1
- package/out/modules/workflow-step-type/handlers/step-settings-save.d.ts +1 -1
- package/out/modules/workflow-step-type/index.js +2 -2
- package/out/modules/workflow-step-type/types.d.ts +1 -1
- package/out/modules/workflow-step-type/util/index.js +3 -6
- package/out/static/js/dependent.js +16 -7
- package/out/static/ui/error.bundle.js +474 -0
- package/out/static/ui/error.bundle.js.map +1 -0
- package/out/static/ui/install.bundle.js +459 -0
- package/out/static/ui/install.bundle.js.map +1 -0
- package/out/static/ui/login.bundle.js +630 -0
- package/out/static/ui/login.bundle.js.map +1 -0
- package/out/static/ui/main.bundle.js +2109 -0
- package/out/static/ui/main.bundle.js.map +1 -0
- package/out/static/ui/oauth.bundle.js +467 -0
- package/out/static/ui/oauth.bundle.js.map +1 -0
- package/out/storage/d1.d.ts +107 -0
- package/out/storage/d1.js +831 -0
- package/out/storage/index.js +8 -1
- package/out/storage/mysql.js +22 -19
- package/out/storage/postgre.d.ts +0 -1
- package/out/storage/postgre.js +20 -30
- package/out/storage/sqlite.d.ts +2 -5
- package/out/storage/sqlite.js +29 -69
- package/out/types.d.ts +80 -18
- package/out/util/connection.js +16 -5
- package/out/util/credentials-masker.d.ts +3 -3
- package/out/util/credentials-masker.js +14 -20
- package/out/util/cron.d.ts +29 -0
- package/out/util/cron.js +87 -0
- package/out/util/index.d.ts +14 -1
- package/out/util/index.js +121 -10
- package/out/util/jsx-renderer.d.ts +14 -0
- package/out/util/jsx-renderer.js +35 -0
- package/out/util/logger.d.ts +1 -0
- package/out/util/logger.js +2 -2
- package/out/util/static-files.d.ts +19 -0
- package/out/util/static-files.js +87 -0
- package/out/util/subscription.js +1 -1
- package/out/views/AboutPage.d.ts +10 -0
- package/out/views/AboutPage.js +76 -0
- package/out/views/FormPage.d.ts +14 -0
- package/out/views/FormPage.js +28 -0
- package/out/views/SubscriptionPage.d.ts +7 -0
- package/out/views/SubscriptionPage.js +26 -0
- package/out/views/index.d.ts +8 -0
- package/out/views/index.js +15 -0
- package/out/views/layout/Head.d.ts +9 -0
- package/out/views/layout/Head.js +54 -0
- package/package.json +43 -41
- package/out/util/handlebars.d.ts +0 -1
- package/out/util/handlebars.js +0 -46
- package/out/views/about.handlebars +0 -102
- package/out/views/error.handlebars +0 -54
- package/out/views/form.handlebars +0 -31
- package/out/views/install.handlebars +0 -16
- package/out/views/login.handlebars +0 -332
- package/out/views/main.handlebars +0 -2042
- package/out/views/oauth.handlebars +0 -11
- package/out/views/partials/head.handlebars +0 -53
- package/out/views/subscription.handlebars +0 -26
|
@@ -10,6 +10,7 @@ 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
|
+
const jsx_renderer_1 = require("../../../util/jsx-renderer");
|
|
13
14
|
const logger_1 = require("../../../util/logger");
|
|
14
15
|
const subscription_1 = require("../../../util/subscription");
|
|
15
16
|
const defaults_1 = require("../util/defaults");
|
|
@@ -51,7 +52,13 @@ function handle(config, integration) {
|
|
|
51
52
|
parentUrl.searchParams.set('zen-mode', 'true');
|
|
52
53
|
options.zenModeUrl = parentUrl.toString();
|
|
53
54
|
}
|
|
54
|
-
const configurationFields = yield integration.getConfiguration(
|
|
55
|
+
const configurationFields = yield integration.getConfiguration({
|
|
56
|
+
projectId: req.crowdinContext.jwtPayload.context.project_id,
|
|
57
|
+
client: req.crowdinApiClient,
|
|
58
|
+
credentials: req.integrationCredentials,
|
|
59
|
+
settings: req.integrationSettings,
|
|
60
|
+
clientId: req.crowdinContext.clientId,
|
|
61
|
+
});
|
|
55
62
|
options.configurationFields = (0, defaults_1.groupFieldsByCategory)(configurationFields);
|
|
56
63
|
logger(`Adding configuration fields ${JSON.stringify(options.configurationFields, null, 2)}`);
|
|
57
64
|
}
|
|
@@ -83,6 +90,9 @@ function handle(config, integration) {
|
|
|
83
90
|
options.forcePushTranslations = integration.forcePushTranslations;
|
|
84
91
|
options.forcePushSources = integration.forcePushSources;
|
|
85
92
|
options.excludedTargetLanguages = integration.excludedTargetLanguages;
|
|
93
|
+
const menuItems = (0, defaults_1.buildMenuItems)(integration, config.name);
|
|
94
|
+
options.integrationButtonMenuItems = menuItems.integrationButtonMenuItems;
|
|
95
|
+
options.crowdinButtonMenuItems = menuItems.crowdinButtonMenuItems;
|
|
86
96
|
options.sentryData = process.env.SENTRY_DSN
|
|
87
97
|
? {
|
|
88
98
|
dsn: process.env.SENTRY_DSN,
|
|
@@ -94,7 +104,27 @@ function handle(config, integration) {
|
|
|
94
104
|
checkInterval: ((_d = integration.asyncProgress) === null || _d === void 0 ? void 0 : _d.checkInterval) || 1000,
|
|
95
105
|
};
|
|
96
106
|
logger(`Routing user to ${view} view`);
|
|
97
|
-
|
|
107
|
+
let html;
|
|
108
|
+
if (view === 'install') {
|
|
109
|
+
html = (0, jsx_renderer_1.renderJSXOnClient)({
|
|
110
|
+
name: 'install',
|
|
111
|
+
props: options,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
else if (view === 'login') {
|
|
115
|
+
html = (0, jsx_renderer_1.renderJSXOnClient)({
|
|
116
|
+
name: 'login',
|
|
117
|
+
props: options,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
html = (0, jsx_renderer_1.renderJSXOnClient)({
|
|
122
|
+
name: 'main',
|
|
123
|
+
props: options,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
|
127
|
+
return res.send(html);
|
|
98
128
|
}));
|
|
99
129
|
}
|
|
100
130
|
exports.default = handle;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
3
|
import { Config } from '../../../types';
|
|
4
4
|
import { IntegrationLogic } from '../types';
|
|
5
|
-
export default function handle(config: Config, integration: IntegrationLogic): (req:
|
|
5
|
+
export default function handle(config: Config, integration: IntegrationLogic): (req: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -12,12 +12,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const crowdin_apps_functions_1 = require("@crowdin/crowdin-apps-functions");
|
|
15
16
|
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
const storage_1 = require("../../../storage");
|
|
16
18
|
const util_1 = require("../../../util");
|
|
17
|
-
const
|
|
19
|
+
const jsx_renderer_1 = require("../../../util/jsx-renderer");
|
|
18
20
|
const logger_1 = require("../../../util/logger");
|
|
19
|
-
const
|
|
20
|
-
const crowdin_apps_functions_1 = require("@crowdin/crowdin-apps-functions");
|
|
21
|
+
const defaults_1 = require("../util/defaults");
|
|
21
22
|
function handle(config, integration) {
|
|
22
23
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
23
24
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
@@ -37,7 +38,13 @@ function handle(config, integration) {
|
|
|
37
38
|
if (oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.performGetTokenRequest) {
|
|
38
39
|
(0, logger_1.log)('Performing custom get bearer token request');
|
|
39
40
|
const loginForm = yield (0, storage_1.getStorage)().getMetadata((0, defaults_1.getOAuthLoginFormId)(clientId));
|
|
40
|
-
credentials = yield oauthLogin.performGetTokenRequest(
|
|
41
|
+
credentials = yield oauthLogin.performGetTokenRequest({
|
|
42
|
+
code,
|
|
43
|
+
query: req.query,
|
|
44
|
+
url: req.originalUrl,
|
|
45
|
+
redirectUri,
|
|
46
|
+
loginForm,
|
|
47
|
+
});
|
|
41
48
|
}
|
|
42
49
|
else {
|
|
43
50
|
const request = {};
|
|
@@ -66,12 +73,27 @@ function handle(config, integration) {
|
|
|
66
73
|
const encryptedCredentials = (0, util_1.encryptData)(config, JSON.stringify(oauthCredentials));
|
|
67
74
|
yield (0, storage_1.getStorage)().saveMetadata((0, defaults_1.getOAuthPollingId)(clientId), encryptedCredentials, organization);
|
|
68
75
|
}
|
|
69
|
-
|
|
76
|
+
const html = (0, jsx_renderer_1.renderJSXOnClient)({
|
|
77
|
+
name: 'oauth',
|
|
78
|
+
props: {
|
|
79
|
+
message: JSON.stringify(message),
|
|
80
|
+
oauthMode: (_p = integration.oauthLogin) === null || _p === void 0 ? void 0 : _p.mode,
|
|
81
|
+
},
|
|
82
|
+
withHead: false,
|
|
83
|
+
});
|
|
84
|
+
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
|
85
|
+
return res.send(html);
|
|
70
86
|
}
|
|
71
87
|
catch (e) {
|
|
72
88
|
(0, logger_1.logError)(e);
|
|
73
89
|
message.data = { error: (0, logger_1.getErrorMessage)(e) };
|
|
74
|
-
|
|
90
|
+
const html = (0, jsx_renderer_1.renderJSXOnClient)({
|
|
91
|
+
name: 'oauth',
|
|
92
|
+
props: { message: JSON.stringify(message) },
|
|
93
|
+
withHead: false,
|
|
94
|
+
});
|
|
95
|
+
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
|
96
|
+
return res.send(html);
|
|
75
97
|
}
|
|
76
98
|
}));
|
|
77
99
|
}
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { Config, CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { IntegrationLogic } from '../types';
|
|
5
|
-
export default function handle(config: Config, integration: IntegrationLogic): (req:
|
|
5
|
+
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>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { Config, CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { IntegrationLogic } from '../types';
|
|
5
|
-
export default function handle(config: Config, integration: IntegrationLogic): (req:
|
|
5
|
+
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>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { Config } from '../../../types';
|
|
4
4
|
import { IntegrationLogic } from '../types';
|
|
5
|
-
export default function handle(config: Config, integration: IntegrationLogic): (req: import("
|
|
5
|
+
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>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -17,7 +17,7 @@ const types_1 = require("../types");
|
|
|
17
17
|
const cron_1 = require("../util/cron");
|
|
18
18
|
function handle(config, integration) {
|
|
19
19
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const
|
|
20
|
+
const settings = req.body.config;
|
|
21
21
|
if (req.isApiCall && !req.body.config) {
|
|
22
22
|
return res.status(400).json({
|
|
23
23
|
error: {
|
|
@@ -29,7 +29,7 @@ function handle(config, integration) {
|
|
|
29
29
|
const validationResult = yield integration.validateSettings({
|
|
30
30
|
client: req.crowdinApiClient,
|
|
31
31
|
credentials: req.integrationCredentials,
|
|
32
|
-
|
|
32
|
+
settings,
|
|
33
33
|
});
|
|
34
34
|
if (validationResult && Object.keys(validationResult).length > 0) {
|
|
35
35
|
return res.status(400).json({
|
|
@@ -41,13 +41,13 @@ function handle(config, integration) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
const clientId = req.crowdinContext.clientId;
|
|
44
|
-
req.logInfo(`Saving settings ${JSON.stringify(
|
|
44
|
+
req.logInfo(`Saving settings ${JSON.stringify(settings, null, 2)}`);
|
|
45
45
|
const integrationConfig = yield (0, storage_1.getStorage)().getIntegrationConfig(clientId);
|
|
46
46
|
if (!integrationConfig) {
|
|
47
|
-
yield (0, storage_1.getStorage)().saveIntegrationConfig(clientId, req.crowdinContext.crowdinId, JSON.stringify(
|
|
47
|
+
yield (0, storage_1.getStorage)().saveIntegrationConfig(clientId, req.crowdinContext.crowdinId, JSON.stringify(settings));
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
50
|
-
yield (0, storage_1.getStorage)().updateIntegrationConfig(clientId, JSON.stringify(
|
|
50
|
+
yield (0, storage_1.getStorage)().updateIntegrationConfig(clientId, JSON.stringify(settings));
|
|
51
51
|
}
|
|
52
52
|
if (integration.webhooks) {
|
|
53
53
|
yield (0, webhooks_1.registerWebhooks)({
|
|
@@ -55,15 +55,15 @@ function handle(config, integration) {
|
|
|
55
55
|
integration,
|
|
56
56
|
client: req.crowdinApiClient,
|
|
57
57
|
crowdinContext: req.crowdinContext,
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
credentials: req.integrationCredentials,
|
|
59
|
+
settings,
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
63
|
-
if (
|
|
63
|
+
if (settings === null || settings === void 0 ? void 0 : settings['new-crowdin-files']) {
|
|
64
64
|
(0, snapshot_1.createOrUpdateFileSnapshot)(config, integration, req, types_1.Provider.CROWDIN);
|
|
65
65
|
}
|
|
66
|
-
if (
|
|
66
|
+
if (settings === null || settings === void 0 ? void 0 : settings['new-integration-files']) {
|
|
67
67
|
(0, snapshot_1.createOrUpdateFileSnapshot)(config, integration, req, types_1.Provider.INTEGRATION);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
export default function handle(): (req: import("
|
|
3
|
+
export default function handle(): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { Config } from '../../../types';
|
|
4
4
|
import { IntegrationLogic } from '../types';
|
|
5
|
-
export default function handle(config: Config, integration: IntegrationLogic): (req: import("
|
|
5
|
+
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>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -8,11 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const lodash_uniqby_1 = __importDefault(require("lodash.uniqby"));
|
|
16
12
|
const util_1 = require("../../../util");
|
|
17
13
|
const cron_1 = require("../util/cron");
|
|
18
14
|
const snapshot_1 = require("../util/snapshot");
|
|
@@ -20,9 +16,9 @@ const files_1 = require("../util/files");
|
|
|
20
16
|
const job_1 = require("../util/job");
|
|
21
17
|
const types_1 = require("../util/types");
|
|
22
18
|
const types_2 = require("../types");
|
|
23
|
-
function checkAutoSyncSettings(integration,
|
|
19
|
+
function checkAutoSyncSettings(integration, settings, provider) {
|
|
24
20
|
var _a;
|
|
25
|
-
return !!(!integration.webhooks && ((_a = integration.syncNewElements) === null || _a === void 0 ? void 0 : _a[provider]) &&
|
|
21
|
+
return !!(!integration.webhooks && ((_a = integration.syncNewElements) === null || _a === void 0 ? void 0 : _a[provider]) && settings[`new-${provider}-files`]);
|
|
26
22
|
}
|
|
27
23
|
function handle(config, integration) {
|
|
28
24
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -71,7 +67,7 @@ function handle(config, integration) {
|
|
|
71
67
|
req.logInfo(`Expanded ${allFiles.length} files for auto-sync`);
|
|
72
68
|
yield (0, cron_1.createOrUpdateSyncSettings)({
|
|
73
69
|
req,
|
|
74
|
-
files: (0,
|
|
70
|
+
files: (0, util_1.uniqBy)([...files, ...allFiles], 'id'),
|
|
75
71
|
provider,
|
|
76
72
|
});
|
|
77
73
|
}
|
|
@@ -82,8 +78,8 @@ function handle(config, integration) {
|
|
|
82
78
|
provider,
|
|
83
79
|
});
|
|
84
80
|
}
|
|
85
|
-
const
|
|
86
|
-
if (checkAutoSyncSettings(integration,
|
|
81
|
+
const settings = req.integrationSettings || {};
|
|
82
|
+
if (checkAutoSyncSettings(integration, settings, provider)) {
|
|
87
83
|
yield (0, snapshot_1.createOrUpdateFileSnapshot)(config, integration, req, provider);
|
|
88
84
|
}
|
|
89
85
|
}),
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
export default function handle(): (req: import("
|
|
3
|
+
export default function handle(): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
export default function handle(): (req: import("
|
|
3
|
+
export default function handle(): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import Crowdin, { UsersModel } from '@crowdin/crowdin-api-client';
|
|
3
3
|
import { Response } from 'express';
|
|
4
4
|
export type ProjectMember = UsersModel.ProjectMember | UsersModel.EnterpriseProjectMember;
|
|
5
|
-
export default function handle(): (req: import("
|
|
5
|
+
export default function handle(): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
6
6
|
export declare function isManager({ client, projectId, memberId, }: {
|
|
7
7
|
client: Crowdin;
|
|
8
8
|
projectId: number;
|
|
@@ -1,27 +1,4 @@
|
|
|
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
|
-
};
|
|
25
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -36,15 +13,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
13
|
};
|
|
37
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
15
|
exports.register = void 0;
|
|
39
|
-
const cron = __importStar(require("node-cron"));
|
|
40
16
|
const crowdin_client_1 = __importDefault(require("../../middlewares/crowdin-client"));
|
|
41
17
|
const integration_credentials_1 = __importDefault(require("../../middlewares/integration-credentials"));
|
|
42
18
|
const json_response_1 = __importDefault(require("../../middlewares/json-response"));
|
|
43
19
|
const util_1 = require("../../util");
|
|
20
|
+
const util_2 = require("../../util");
|
|
21
|
+
const cron_1 = require("../../util/cron");
|
|
44
22
|
const defaults_1 = require("./util/defaults");
|
|
45
23
|
const webhooks_1 = require("./util/webhooks");
|
|
46
24
|
const crowdin_file_progress_1 = __importDefault(require("./handlers/crowdin-file-progress"));
|
|
47
25
|
const crowdin_files_1 = __importDefault(require("./handlers/crowdin-files"));
|
|
26
|
+
const crowdin_files_target_languages_1 = __importDefault(require("./handlers/crowdin-files-target-languages"));
|
|
48
27
|
const crowdin_project_1 = __importDefault(require("./handlers/crowdin-project"));
|
|
49
28
|
const crowdin_update_1 = __importDefault(require("./handlers/crowdin-update"));
|
|
50
29
|
const crowdin_webhook_1 = __importDefault(require("./handlers/crowdin-webhook"));
|
|
@@ -68,7 +47,7 @@ const sync_settings_save_1 = __importDefault(require("./handlers/sync-settings-s
|
|
|
68
47
|
const user_errors_1 = __importDefault(require("./handlers/user-errors"));
|
|
69
48
|
const users_1 = __importDefault(require("./handlers/users"));
|
|
70
49
|
const invite_users_1 = __importDefault(require("./handlers/invite-users"));
|
|
71
|
-
const
|
|
50
|
+
const cron_2 = require("./util/cron");
|
|
72
51
|
const storage_1 = require("../../storage");
|
|
73
52
|
function register({ config, app }) {
|
|
74
53
|
var _a, _b, _c;
|
|
@@ -77,7 +56,7 @@ function register({ config, app }) {
|
|
|
77
56
|
return;
|
|
78
57
|
}
|
|
79
58
|
(0, defaults_1.applyIntegrationModuleDefaults)(config, integrationLogic);
|
|
80
|
-
app.
|
|
59
|
+
app.use('/logo/integration', (0, util_2.serveLogo)(config, integrationLogic));
|
|
81
60
|
app.get('/', (0, crowdin_client_1.default)({
|
|
82
61
|
config,
|
|
83
62
|
optional: true,
|
|
@@ -162,6 +141,12 @@ function register({ config, app }) {
|
|
|
162
141
|
checkSubscriptionExpiration: true,
|
|
163
142
|
moduleKey: integrationLogic.key,
|
|
164
143
|
}), (0, integration_credentials_1.default)(config, integrationLogic), (0, crowdin_update_1.default)(config, integrationLogic));
|
|
144
|
+
app.post('/api/crowdin/files-target-languages', json_response_1.default, (0, crowdin_client_1.default)({
|
|
145
|
+
config,
|
|
146
|
+
optional: false,
|
|
147
|
+
checkSubscriptionExpiration: true,
|
|
148
|
+
moduleKey: integrationLogic.key,
|
|
149
|
+
}), (0, integration_credentials_1.default)(config, integrationLogic), (0, crowdin_files_target_languages_1.default)(config, integrationLogic));
|
|
165
150
|
app.post('/api/integration/update', json_response_1.default, (0, crowdin_client_1.default)({
|
|
166
151
|
config,
|
|
167
152
|
optional: false,
|
|
@@ -197,17 +182,18 @@ function register({ config, app }) {
|
|
|
197
182
|
}), (0, oauth_polling_1.default)(config, integrationLogic));
|
|
198
183
|
}
|
|
199
184
|
}
|
|
185
|
+
const cron = (0, cron_1.getCron)();
|
|
200
186
|
if (integrationLogic.cronJobs) {
|
|
201
187
|
integrationLogic.cronJobs.forEach((job) => {
|
|
202
|
-
cron.schedule(job.expression, () => (0,
|
|
188
|
+
cron.schedule(job.expression, () => (0, cron_2.runJob)({ config, integration: integrationLogic, job }).catch(console.error));
|
|
203
189
|
});
|
|
204
190
|
}
|
|
205
191
|
if (integrationLogic.withCronSync) {
|
|
206
|
-
cron.schedule('0 * * * *', () => (0,
|
|
207
|
-
cron.schedule('0 */3 * * *', () => (0,
|
|
208
|
-
cron.schedule('0 */6 * * *', () => (0,
|
|
209
|
-
cron.schedule('0 */12 * * *', () => (0,
|
|
210
|
-
cron.schedule('0 0 * * *', () => (0,
|
|
192
|
+
cron.schedule('0 * * * *', () => (0, cron_2.filesCron)({ config, integration: integrationLogic, period: '1' }).catch(console.error));
|
|
193
|
+
cron.schedule('0 */3 * * *', () => (0, cron_2.filesCron)({ config, integration: integrationLogic, period: '3' }).catch(console.error));
|
|
194
|
+
cron.schedule('0 */6 * * *', () => (0, cron_2.filesCron)({ config, integration: integrationLogic, period: '6' }).catch(console.error));
|
|
195
|
+
cron.schedule('0 */12 * * *', () => (0, cron_2.filesCron)({ config, integration: integrationLogic, period: '12' }).catch(console.error));
|
|
196
|
+
cron.schedule('0 0 * * *', () => (0, cron_2.filesCron)({ config, integration: integrationLogic, period: '24' }).catch(console.error));
|
|
211
197
|
}
|
|
212
198
|
// remove user errors
|
|
213
199
|
cron.schedule('0 0 * * *', () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -216,6 +202,7 @@ function register({ config, app }) {
|
|
|
216
202
|
yield (0, storage_1.getStorage)().deleteAllUsersErrorsOlderThan(`${date.getTime()}`);
|
|
217
203
|
}
|
|
218
204
|
}));
|
|
205
|
+
cron.schedule('0 0 1 * *', () => (0, cron_2.removeFinishedJobs)());
|
|
219
206
|
if (integrationLogic.webhooks) {
|
|
220
207
|
app.post(`${integrationLogic.webhooks.crowdinWebhookUrl
|
|
221
208
|
? integrationLogic.webhooks.crowdinWebhookUrl
|
|
@@ -252,6 +239,5 @@ function register({ config, app }) {
|
|
|
252
239
|
checkSubscriptionExpiration: true,
|
|
253
240
|
moduleKey: integrationLogic.key,
|
|
254
241
|
}), (0, integration_credentials_1.default)(config, integrationLogic), (0, invite_users_1.default)());
|
|
255
|
-
cron.schedule('0 0 1 * *', () => (0, cron_1.removeFinishedJobs)());
|
|
256
242
|
}
|
|
257
243
|
exports.register = register;
|