@crowdin/app-project-module 0.43.1 → 0.45.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/index.d.ts +3 -3
- package/out/index.js +103 -219
- package/out/middlewares/crowdin-client.d.ts +1 -1
- package/out/middlewares/crowdin-client.js +3 -2
- package/out/middlewares/integration-credentials.d.ts +3 -2
- package/out/middlewares/render-ui-module.d.ts +2 -2
- package/out/middlewares/ui-module.d.ts +2 -2
- package/out/middlewares/ui-module.js +5 -1
- package/out/{util → modules}/api/api.d.ts +3 -2
- package/out/{util → modules}/api/api.js +22 -22
- package/out/modules/api/index.d.ts +6 -0
- package/out/modules/api/index.js +14 -0
- package/out/modules/api/types.d.ts +20 -0
- package/out/modules/api/types.js +11 -0
- package/out/modules/context-menu/index.d.ts +6 -0
- package/out/modules/context-menu/index.js +17 -0
- package/out/modules/context-menu/types.d.ts +27 -0
- package/out/modules/context-menu/types.js +18 -0
- package/out/{handlers/custom-mt → modules/custom-mt/handlers}/translate.d.ts +2 -1
- package/out/{handlers/custom-mt → modules/custom-mt/handlers}/translate.js +2 -2
- package/out/modules/custom-mt/index.d.ts +6 -0
- package/out/modules/custom-mt/index.js +17 -0
- package/out/modules/custom-mt/types.d.ts +22 -0
- package/out/modules/custom-mt/types.js +2 -0
- package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/get-languages-list.d.ts +2 -1
- package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/get-languages-list.js +2 -2
- package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/spell-check.d.ts +2 -1
- package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/spell-check.js +5 -3
- package/out/modules/custom-spell-check/index.d.ts +6 -0
- package/out/modules/custom-spell-check/index.js +32 -0
- package/out/modules/custom-spell-check/types.d.ts +56 -0
- package/out/modules/custom-spell-check/types.js +2 -0
- package/out/modules/editor-right-panel/index.d.ts +6 -0
- package/out/modules/editor-right-panel/index.js +17 -0
- package/out/modules/editor-right-panel/types.d.ts +7 -0
- package/out/modules/editor-right-panel/types.js +2 -0
- package/out/modules/editor-themes/index.d.ts +6 -0
- package/out/modules/editor-themes/index.js +11 -0
- package/out/modules/editor-themes/types.d.ts +17 -0
- package/out/modules/editor-themes/types.js +2 -0
- package/out/{handlers/file-processing → modules/file-processing/handlers}/custom-file-format.d.ts +2 -1
- package/out/{handlers/file-processing → modules/file-processing/handlers}/custom-file-format.js +5 -5
- package/out/modules/file-processing/handlers/file-download.d.ts +5 -0
- package/out/{handlers/file-processing → modules/file-processing/handlers}/file-download.js +2 -2
- package/out/{handlers/file-processing → modules/file-processing/handlers}/pre-post-process.d.ts +2 -1
- package/out/{handlers/file-processing → modules/file-processing/handlers}/pre-post-process.js +8 -8
- package/out/modules/file-processing/index.d.ts +22 -0
- package/out/modules/file-processing/index.js +57 -0
- package/out/modules/file-processing/types.d.ts +133 -0
- package/out/modules/file-processing/types.js +12 -0
- package/out/modules/file-processing/util/defaults.d.ts +3 -0
- package/out/modules/file-processing/util/defaults.js +30 -0
- package/out/modules/file-processing/util/files.d.ts +6 -0
- package/out/modules/file-processing/util/files.js +47 -0
- package/out/{handlers/integration/crowdin-project.d.ts → modules/form-data-display.d.ts} +1 -1
- package/out/modules/form-data-save.d.ts +4 -0
- package/out/modules/install.d.ts +4 -0
- package/out/{handlers → modules}/install.js +3 -3
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-file-progress.d.ts +2 -1
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-file-progress.js +2 -2
- package/out/modules/integration/handlers/crowdin-files.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-files.js +3 -3
- package/out/modules/integration/handlers/crowdin-project.d.ts +4 -0
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-project.js +1 -1
- package/out/modules/integration/handlers/crowdin-update.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-update.js +9 -9
- package/out/modules/integration/handlers/crowdin-webhook.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-webhook.js +19 -8
- package/out/modules/integration/handlers/integration-data.d.ts +4 -0
- package/out/{handlers/integration → modules/integration/handlers}/integration-data.js +5 -5
- package/out/{handlers/integration → modules/integration/handlers}/integration-login.d.ts +2 -1
- package/out/{handlers/integration → modules/integration/handlers}/integration-login.js +3 -3
- package/out/modules/integration/handlers/integration-logout.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/integration-logout.js +14 -7
- package/out/modules/integration/handlers/integration-update.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/integration-update.js +9 -8
- package/out/modules/integration/handlers/integration-webhook.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/integration-webhook.js +9 -4
- package/out/modules/integration/handlers/job-cancel.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/job-cancel.js +4 -4
- package/out/modules/integration/handlers/job-info.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/job-info.js +4 -4
- package/out/modules/integration/handlers/main.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/main.js +5 -5
- package/out/modules/integration/handlers/oauth-login.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/oauth-login.js +3 -3
- package/out/{handlers/integration → modules/integration/handlers}/oauth-url.d.ts +2 -1
- package/out/{handlers/integration → modules/integration/handlers}/oauth-url.js +2 -2
- package/out/modules/integration/handlers/settings-save.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/settings-save.js +28 -11
- package/out/modules/integration/handlers/settings.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/settings.js +1 -1
- package/out/{handlers/integration → modules/integration/handlers}/subscription-info.d.ts +1 -1
- package/out/{handlers/integration → modules/integration/handlers}/subscription-info.js +2 -2
- package/out/modules/integration/handlers/sync-settings-save.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/sync-settings-save.js +16 -8
- package/out/modules/integration/handlers/sync-settings.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/sync-settings.js +2 -2
- package/out/modules/integration/handlers/user-errors.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/user-errors.js +2 -2
- package/out/modules/integration/index.d.ts +6 -0
- package/out/modules/integration/index.js +118 -0
- package/out/modules/integration/types.d.ts +435 -0
- package/out/modules/integration/types.js +19 -0
- package/out/modules/integration/util/cron.d.ts +27 -0
- package/out/{util → modules/integration/util}/cron.js +97 -28
- package/out/{util → modules/integration/util}/defaults.d.ts +2 -3
- package/out/{util → modules/integration/util}/defaults.js +1 -36
- package/out/modules/integration/util/files.d.ts +5 -0
- package/out/{util → modules/integration/util}/files.js +9 -40
- package/out/{util → modules/integration/util}/job.d.ts +1 -1
- package/out/{util → modules/integration/util}/job.js +11 -11
- package/out/{util/file-snapshot.d.ts → modules/integration/util/snapshot.d.ts} +2 -3
- package/out/{util/file-snapshot.js → modules/integration/util/snapshot.js} +6 -65
- package/out/{models/job.d.ts → modules/integration/util/types.d.ts} +14 -0
- package/out/modules/integration/util/webhooks.d.ts +48 -0
- package/out/{util → modules/integration/util}/webhooks.js +95 -49
- package/out/modules/manifest.d.ts +3 -0
- package/out/{handlers → modules}/manifest.js +22 -16
- package/out/modules/modal/index.d.ts +6 -0
- package/out/modules/modal/index.js +17 -0
- package/out/modules/organization-menu/index.d.ts +6 -0
- package/out/modules/organization-menu/index.js +18 -0
- package/out/modules/profile-resources-menu/index.d.ts +6 -0
- package/out/modules/profile-resources-menu/index.js +18 -0
- package/out/modules/project-menu/index.d.ts +6 -0
- package/out/modules/project-menu/index.js +17 -0
- package/out/modules/project-menu-crowdsource/index.d.ts +6 -0
- package/out/modules/project-menu-crowdsource/index.js +17 -0
- package/out/modules/project-reports/index.d.ts +6 -0
- package/out/modules/project-reports/index.js +18 -0
- package/out/modules/project-tools/index.d.ts +6 -0
- package/out/modules/project-tools/index.js +18 -0
- package/out/modules/subscription-paid.d.ts +3 -0
- package/out/{handlers → modules}/subscription-paid.js +2 -2
- package/out/modules/uninstall.d.ts +4 -0
- package/out/{handlers → modules}/uninstall.js +6 -2
- package/out/storage/index.d.ts +5 -3
- package/out/storage/mysql.d.ts +4 -2
- package/out/storage/mysql.js +3 -3
- package/out/storage/postgre.d.ts +4 -2
- package/out/storage/postgre.js +3 -3
- package/out/storage/sqlite.d.ts +4 -2
- package/out/storage/sqlite.js +3 -3
- package/out/storage/types.d.ts +9 -0
- package/out/storage/types.js +2 -0
- package/out/types.d.ts +374 -0
- package/out/types.js +59 -0
- package/out/util/connection.d.ts +2 -9
- package/out/util/connection.js +54 -150
- package/out/util/handlebars.d.ts +1 -0
- package/out/util/handlebars.js +34 -0
- package/out/util/index.d.ts +2 -2
- package/out/util/index.js +6 -6
- package/out/util/logger.d.ts +2 -2
- package/out/util/subscription.d.ts +9 -0
- package/out/util/subscription.js +111 -0
- package/package.json +1 -1
- package/out/handlers/file-processing/file-download.d.ts +0 -4
- package/out/handlers/form-data-display.d.ts +0 -3
- package/out/handlers/form-data-save.d.ts +0 -3
- package/out/handlers/install.d.ts +0 -4
- package/out/handlers/integration/crowdin-files.d.ts +0 -4
- package/out/handlers/integration/crowdin-update.d.ts +0 -4
- package/out/handlers/integration/crowdin-webhook.d.ts +0 -4
- package/out/handlers/integration/integration-data.d.ts +0 -4
- package/out/handlers/integration/integration-logout.d.ts +0 -4
- package/out/handlers/integration/integration-update.d.ts +0 -4
- package/out/handlers/integration/integration-webhook.d.ts +0 -4
- package/out/handlers/integration/job-cancel.d.ts +0 -3
- package/out/handlers/integration/job-info.d.ts +0 -3
- package/out/handlers/integration/main.d.ts +0 -4
- package/out/handlers/integration/oauth-login.d.ts +0 -4
- package/out/handlers/integration/settings-save.d.ts +0 -4
- package/out/handlers/integration/settings.d.ts +0 -3
- package/out/handlers/integration/sync-settings-save.d.ts +0 -4
- package/out/handlers/integration/sync-settings.d.ts +0 -3
- package/out/handlers/integration/user-errors.d.ts +0 -3
- package/out/handlers/manifest.d.ts +0 -3
- package/out/handlers/subscription-paid.d.ts +0 -3
- package/out/handlers/uninstall.d.ts +0 -4
- package/out/models/index.d.ts +0 -1088
- package/out/models/index.js +0 -106
- package/out/util/cron.d.ts +0 -7
- package/out/util/files.d.ts +0 -9
- package/out/util/webhooks.d.ts +0 -28
- /package/out/{util → modules}/api/base.d.ts +0 -0
- /package/out/{util → modules}/api/base.js +0 -0
- /package/out/{util → modules}/api/components.d.ts +0 -0
- /package/out/{util → modules}/api/components.js +0 -0
- /package/out/{handlers → modules}/form-data-display.js +0 -0
- /package/out/{handlers → modules}/form-data-save.js +0 -0
- /package/out/{models/job.js → modules/integration/util/types.js} +0 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
import { Response } from 'express';
|
|
3
|
+
export default function handle(): (req: import("../../../types").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;
|
|
@@ -9,9 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const
|
|
13
|
-
const util_1 = require("
|
|
14
|
-
const storage_1 = require("
|
|
12
|
+
const types_1 = require("../util/types");
|
|
13
|
+
const util_1 = require("../../../util");
|
|
14
|
+
const storage_1 = require("../../../storage");
|
|
15
15
|
function handle() {
|
|
16
16
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
const id = req.query.job_id || req.body.job_id;
|
|
@@ -21,7 +21,7 @@ function handle() {
|
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
req.logInfo(`User has been canceled the job id: ${id}`);
|
|
24
|
-
yield (0, storage_1.getStorage)().updateJob({ id, status:
|
|
24
|
+
yield (0, storage_1.getStorage)().updateJob({ id, status: types_1.JobStatus.CANCELED });
|
|
25
25
|
res.sendStatus(204);
|
|
26
26
|
}));
|
|
27
27
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
import { Response } from 'express';
|
|
3
|
+
export default function handle(): (req: import("../../../types").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;
|
|
@@ -9,9 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const
|
|
13
|
-
const util_1 = require("
|
|
14
|
-
const storage_1 = require("
|
|
12
|
+
const types_1 = require("../util/types");
|
|
13
|
+
const util_1 = require("../../../util");
|
|
14
|
+
const storage_1 = require("../../../storage");
|
|
15
15
|
function getHumanETA(ms) {
|
|
16
16
|
const seconds = Math.floor(ms / 1000);
|
|
17
17
|
let minutes = Math.floor(seconds / 60);
|
|
@@ -43,7 +43,7 @@ function handle() {
|
|
|
43
43
|
}
|
|
44
44
|
req.logInfo(`Get job info for id ${id}`);
|
|
45
45
|
const job = yield (0, storage_1.getStorage)().getJob({ id });
|
|
46
|
-
if (job && job.status ===
|
|
46
|
+
if (job && job.status === types_1.JobStatus.IN_PROGRESS && job.progress > 5 && job.updatedAt) {
|
|
47
47
|
job.eta = ((Date.now() - job.createdAt) / job.progress) * (100 - job.progress);
|
|
48
48
|
job.info = getHumanETA(job.eta) + (job.info ? `\n${job.info}` : '');
|
|
49
49
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
import { Response } from 'express';
|
|
3
|
+
import { Config } from '../../../types';
|
|
4
|
+
import { IntegrationLogic } from '../types';
|
|
5
|
+
export default function handle(config: Config, integration: IntegrationLogic): (req: import("../../../types").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;
|
|
@@ -9,10 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const util_1 = require("
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
12
|
+
const util_1 = require("../../../util");
|
|
13
|
+
const logger_1 = require("../../../util/logger");
|
|
14
|
+
const subscription_1 = require("../../../util/subscription");
|
|
15
|
+
const defaults_1 = require("../util/defaults");
|
|
16
16
|
function handle(config, integration) {
|
|
17
17
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
var _a, _b;
|
|
@@ -57,7 +57,7 @@ function handle(config, integration) {
|
|
|
57
57
|
: {};
|
|
58
58
|
options.integrationOneLevelFetching = integration.integrationOneLevelFetching;
|
|
59
59
|
options.integrationSearchListener = integration.integrationSearchListener;
|
|
60
|
-
options.checkSubscription = !(0,
|
|
60
|
+
options.checkSubscription = !(0, subscription_1.isAppFree)(config);
|
|
61
61
|
options.uploadTranslations = integration.uploadTranslations;
|
|
62
62
|
options.sentryData = process.env.SENTRY_DSN
|
|
63
63
|
? {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import { Config } from '../../../types';
|
|
4
|
+
import { IntegrationLogic } from '../types';
|
|
5
|
+
export default function handle(config: Config, integration: IntegrationLogic): (req: import("../../../types").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;
|
|
@@ -13,9 +13,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const axios_1 = __importDefault(require("axios"));
|
|
16
|
-
const util_1 = require("
|
|
17
|
-
const defaults_1 = require("
|
|
18
|
-
const logger_1 = require("
|
|
16
|
+
const util_1 = require("../../../util");
|
|
17
|
+
const defaults_1 = require("../util/defaults");
|
|
18
|
+
const logger_1 = require("../../../util/logger");
|
|
19
19
|
function handle(config, integration) {
|
|
20
20
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
21
21
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { Config, CrowdinClientRequest
|
|
3
|
+
import { Config, CrowdinClientRequest } from '../../../types';
|
|
4
|
+
import { IntegrationLogic } from '../types';
|
|
4
5
|
export default function handle(config: Config, integration: IntegrationLogic): (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;
|
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const util_1 = require("
|
|
13
|
-
const defaults_1 = require("
|
|
12
|
+
const util_1 = require("../../../util");
|
|
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');
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
import { Response } from 'express';
|
|
3
|
+
import { Config } from '../../../types';
|
|
4
|
+
import { IntegrationLogic } from '../types';
|
|
5
|
+
export default function handle(config: Config, integration: IntegrationLogic): (req: import("../../../types").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;
|
|
@@ -9,12 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
12
|
+
const storage_1 = require("../../../storage");
|
|
13
|
+
const util_1 = require("../../../util");
|
|
14
|
+
const snapshot_1 = require("../util/snapshot");
|
|
15
|
+
const webhooks_1 = require("../util/webhooks");
|
|
16
|
+
const types_1 = require("../types");
|
|
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
20
|
const appSettings = req.body.config;
|
|
@@ -28,19 +28,36 @@ function handle(config, integration) {
|
|
|
28
28
|
yield (0, storage_1.getStorage)().updateIntegrationConfig(clientId, JSON.stringify(appSettings));
|
|
29
29
|
}
|
|
30
30
|
if (integration.webhooks) {
|
|
31
|
-
yield (0, webhooks_1.registerWebhooks)(
|
|
31
|
+
yield (0, webhooks_1.registerWebhooks)({
|
|
32
|
+
config,
|
|
33
|
+
integration,
|
|
34
|
+
client: req.crowdinApiClient,
|
|
35
|
+
crowdinContext: req.crowdinContext,
|
|
36
|
+
apiCredentials: req.integrationCredentials,
|
|
37
|
+
appSettings,
|
|
38
|
+
});
|
|
32
39
|
}
|
|
33
40
|
else {
|
|
34
41
|
if (appSettings['new-crowdin-files']) {
|
|
35
|
-
(0,
|
|
42
|
+
(0, snapshot_1.createOrUpdateFileSnapshot)(config, integration, req, types_1.Provider.CROWDIN);
|
|
36
43
|
}
|
|
37
44
|
if (appSettings['new-integration-files']) {
|
|
38
|
-
(0,
|
|
45
|
+
(0, snapshot_1.createOrUpdateFileSnapshot)(config, integration, req, types_1.Provider.INTEGRATION);
|
|
39
46
|
}
|
|
40
47
|
}
|
|
41
48
|
if (integration.syncNewElements) {
|
|
42
|
-
yield (0, cron_1.createOrUpdateSyncSettings)(
|
|
43
|
-
|
|
49
|
+
yield (0, cron_1.createOrUpdateSyncSettings)({
|
|
50
|
+
req,
|
|
51
|
+
files: {},
|
|
52
|
+
provider: types_1.Provider.CROWDIN,
|
|
53
|
+
onlyCreate: true,
|
|
54
|
+
});
|
|
55
|
+
yield (0, cron_1.createOrUpdateSyncSettings)({
|
|
56
|
+
req,
|
|
57
|
+
files: [],
|
|
58
|
+
provider: types_1.Provider.INTEGRATION,
|
|
59
|
+
onlyCreate: true,
|
|
60
|
+
});
|
|
44
61
|
}
|
|
45
62
|
res.status(204).end();
|
|
46
63
|
}));
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
import { Response } from 'express';
|
|
3
|
+
export default function handle(): (req: import("../../../types").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;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const util_1 = require("
|
|
12
|
+
const util_1 = require("../../../util");
|
|
13
13
|
function handle() {
|
|
14
14
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
15
15
|
let settings = {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const types_1 = require("../../../types");
|
|
4
4
|
function handle(config) {
|
|
5
5
|
return (req, res) => {
|
|
6
6
|
var _a;
|
|
7
7
|
const subscriptionInfo = req.subscriptionInfo;
|
|
8
|
-
let showInfo = (subscriptionInfo === null || subscriptionInfo === void 0 ? void 0 : subscriptionInfo.type) ===
|
|
8
|
+
let showInfo = (subscriptionInfo === null || subscriptionInfo === void 0 ? void 0 : subscriptionInfo.type) === types_1.SubscriptionInfoType.TRIAL;
|
|
9
9
|
if (showInfo && ((_a = config.pricing) === null || _a === void 0 ? void 0 : _a.infoDisplayDaysThreshold)) {
|
|
10
10
|
showInfo = config.pricing.infoDisplayDaysThreshold >= ((subscriptionInfo === null || subscriptionInfo === void 0 ? void 0 : subscriptionInfo.daysLeft) || 0);
|
|
11
11
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
import { Response } from 'express';
|
|
3
|
+
import { Config } from '../../../types';
|
|
4
|
+
import { IntegrationLogic } from '../types';
|
|
5
|
+
export default function handle(config: Config, integration: IntegrationLogic): (req: import("../../../types").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;
|
|
@@ -13,11 +13,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const lodash_uniqby_1 = __importDefault(require("lodash.uniqby"));
|
|
16
|
-
const util_1 = require("
|
|
17
|
-
const cron_1 = require("
|
|
18
|
-
const
|
|
19
|
-
const files_1 = require("
|
|
20
|
-
const job_1 = require("
|
|
16
|
+
const util_1 = require("../../../util");
|
|
17
|
+
const cron_1 = require("../util/cron");
|
|
18
|
+
const snapshot_1 = require("../util/snapshot");
|
|
19
|
+
const files_1 = require("../util/files");
|
|
20
|
+
const job_1 = require("../util/job");
|
|
21
21
|
function handle(config, integration) {
|
|
22
22
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
23
23
|
const { files, provider, expandIntegrationFolders } = req.body;
|
|
@@ -42,14 +42,22 @@ function handle(config, integration) {
|
|
|
42
42
|
sync: false,
|
|
43
43
|
type: node.type,
|
|
44
44
|
}));
|
|
45
|
-
yield (0, cron_1.createOrUpdateSyncSettings)(
|
|
45
|
+
yield (0, cron_1.createOrUpdateSyncSettings)({
|
|
46
|
+
req,
|
|
47
|
+
files: (0, lodash_uniqby_1.default)([...files, ...allFiles], 'id'),
|
|
48
|
+
provider,
|
|
49
|
+
});
|
|
46
50
|
}
|
|
47
51
|
else {
|
|
48
|
-
yield (0, cron_1.createOrUpdateSyncSettings)(
|
|
52
|
+
yield (0, cron_1.createOrUpdateSyncSettings)({
|
|
53
|
+
req,
|
|
54
|
+
files,
|
|
55
|
+
provider,
|
|
56
|
+
});
|
|
49
57
|
}
|
|
50
58
|
const appSettings = req.integrationSettings || {};
|
|
51
59
|
if (((_a = integration.syncNewElements) === null || _a === void 0 ? void 0 : _a[provider]) && appSettings[`new-${provider}-files`]) {
|
|
52
|
-
yield (0,
|
|
60
|
+
yield (0, snapshot_1.createOrUpdateFileSnapshot)(config, integration, req, provider);
|
|
53
61
|
}
|
|
54
62
|
}),
|
|
55
63
|
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
import { Response } from 'express';
|
|
3
|
+
export default function handle(): (req: import("../../../types").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;
|
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const storage_1 = require("
|
|
13
|
-
const util_1 = require("
|
|
12
|
+
const storage_1 = require("../../../storage");
|
|
13
|
+
const util_1 = require("../../../util");
|
|
14
14
|
function handle() {
|
|
15
15
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
let files = {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
import { Response } from 'express';
|
|
3
|
+
export default function handle(): (req: import("../../../types").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;
|
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const storage_1 = require("
|
|
13
|
-
const util_1 = require("
|
|
12
|
+
const storage_1 = require("../../../storage");
|
|
13
|
+
const util_1 = require("../../../util");
|
|
14
14
|
function handle() {
|
|
15
15
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
var _a;
|
|
@@ -0,0 +1,118 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.register = void 0;
|
|
30
|
+
const cron = __importStar(require("node-cron"));
|
|
31
|
+
const crowdin_client_1 = __importDefault(require("../../middlewares/crowdin-client"));
|
|
32
|
+
const integration_credentials_1 = __importDefault(require("../../middlewares/integration-credentials"));
|
|
33
|
+
const json_response_1 = __importDefault(require("../../middlewares/json-response"));
|
|
34
|
+
const util_1 = require("../../util");
|
|
35
|
+
const defaults_1 = require("./util/defaults");
|
|
36
|
+
const webhooks_1 = require("./util/webhooks");
|
|
37
|
+
const crowdin_file_progress_1 = __importDefault(require("./handlers/crowdin-file-progress"));
|
|
38
|
+
const crowdin_files_1 = __importDefault(require("./handlers/crowdin-files"));
|
|
39
|
+
const crowdin_project_1 = __importDefault(require("./handlers/crowdin-project"));
|
|
40
|
+
const crowdin_update_1 = __importDefault(require("./handlers/crowdin-update"));
|
|
41
|
+
const crowdin_webhook_1 = __importDefault(require("./handlers/crowdin-webhook"));
|
|
42
|
+
const integration_data_1 = __importDefault(require("./handlers/integration-data"));
|
|
43
|
+
const integration_login_1 = __importDefault(require("./handlers/integration-login"));
|
|
44
|
+
const integration_logout_1 = __importDefault(require("./handlers/integration-logout"));
|
|
45
|
+
const integration_update_1 = __importDefault(require("./handlers/integration-update"));
|
|
46
|
+
const integration_webhook_1 = __importDefault(require("./handlers/integration-webhook"));
|
|
47
|
+
const job_cancel_1 = __importDefault(require("./handlers/job-cancel"));
|
|
48
|
+
const job_info_1 = __importDefault(require("./handlers/job-info"));
|
|
49
|
+
const main_1 = __importDefault(require("./handlers/main"));
|
|
50
|
+
const oauth_login_1 = __importDefault(require("./handlers/oauth-login"));
|
|
51
|
+
const oauth_url_1 = __importDefault(require("./handlers/oauth-url"));
|
|
52
|
+
const settings_save_1 = __importDefault(require("./handlers/settings-save"));
|
|
53
|
+
const subscription_info_1 = __importDefault(require("./handlers/subscription-info"));
|
|
54
|
+
const sync_settings_1 = __importDefault(require("./handlers/sync-settings"));
|
|
55
|
+
const sync_settings_save_1 = __importDefault(require("./handlers/sync-settings-save"));
|
|
56
|
+
const user_errors_1 = __importDefault(require("./handlers/user-errors"));
|
|
57
|
+
const cron_1 = require("./util/cron");
|
|
58
|
+
function register({ config, app }) {
|
|
59
|
+
var _a, _b, _c;
|
|
60
|
+
const integrationLogic = config.projectIntegration;
|
|
61
|
+
if (!integrationLogic) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
(0, defaults_1.applyIntegrationModuleDefaults)(config, integrationLogic);
|
|
65
|
+
app.get((0, util_1.getLogoUrl)(integrationLogic, '/integration'), (req, res) => res.sendFile(integrationLogic.imagePath || config.imagePath));
|
|
66
|
+
app.get('/', (0, crowdin_client_1.default)(config, true, false), (0, integration_credentials_1.default)(config, integrationLogic, true), (0, main_1.default)(config, integrationLogic));
|
|
67
|
+
app.get('/api/subscription-info', json_response_1.default, (0, crowdin_client_1.default)(config), (0, subscription_info_1.default)(config));
|
|
68
|
+
app.get('/api/jobs', json_response_1.default, (0, crowdin_client_1.default)(config), (0, job_info_1.default)());
|
|
69
|
+
app.delete('/api/jobs', json_response_1.default, (0, crowdin_client_1.default)(config), (0, job_cancel_1.default)());
|
|
70
|
+
app.post('/api/settings', (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, settings_save_1.default)(config, integrationLogic));
|
|
71
|
+
app.post('/api/login', (0, crowdin_client_1.default)(config, false, false), (0, integration_login_1.default)(config, integrationLogic));
|
|
72
|
+
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));
|
|
73
|
+
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));
|
|
74
|
+
app.get('/api/crowdin/project', json_response_1.default, (0, crowdin_client_1.default)(config), (0, crowdin_project_1.default)());
|
|
75
|
+
app.get('/api/crowdin/file-progress/:fileId', (0, crowdin_client_1.default)(config), (0, crowdin_file_progress_1.default)(integrationLogic));
|
|
76
|
+
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));
|
|
77
|
+
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));
|
|
78
|
+
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));
|
|
79
|
+
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)());
|
|
80
|
+
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));
|
|
81
|
+
if (integrationLogic.oauthLogin) {
|
|
82
|
+
app.get((0, defaults_1.getOauthRoute)(integrationLogic), (0, oauth_login_1.default)(config, integrationLogic));
|
|
83
|
+
app.post('/api/oauth-url', json_response_1.default, (0, crowdin_client_1.default)(config, false, false), (0, oauth_url_1.default)(config, integrationLogic));
|
|
84
|
+
}
|
|
85
|
+
if (integrationLogic.cronJobs) {
|
|
86
|
+
integrationLogic.cronJobs.forEach((job) => {
|
|
87
|
+
cron.schedule(job.expression, () => (0, cron_1.runJob)({ config, integration: integrationLogic, job }).catch(console.error));
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
if (integrationLogic.withCronSync) {
|
|
91
|
+
cron.schedule('0 * * * *', () => (0, cron_1.filesCron)({ config, integration: integrationLogic, period: '1' }).catch(console.error));
|
|
92
|
+
cron.schedule('0 */3 * * *', () => (0, cron_1.filesCron)({ config, integration: integrationLogic, period: '3' }).catch(console.error));
|
|
93
|
+
cron.schedule('0 */6 * * *', () => (0, cron_1.filesCron)({ config, integration: integrationLogic, period: '6' }).catch(console.error));
|
|
94
|
+
cron.schedule('0 */12 * * *', () => (0, cron_1.filesCron)({ config, integration: integrationLogic, period: '12' }).catch(console.error));
|
|
95
|
+
cron.schedule('0 0 * * *', () => (0, cron_1.filesCron)({ config, integration: integrationLogic, period: '24' }).catch(console.error));
|
|
96
|
+
}
|
|
97
|
+
if (integrationLogic.webhooks) {
|
|
98
|
+
app.post(`${integrationLogic.webhooks.crowdinWebhookUrl
|
|
99
|
+
? integrationLogic.webhooks.crowdinWebhookUrl
|
|
100
|
+
: '/api/crowdin/webhook'}`, json_response_1.default, (0, crowdin_webhook_1.default)(config, integrationLogic));
|
|
101
|
+
if (((_a = integrationLogic.webhooks) === null || _a === void 0 ? void 0 : _a.integrationWebhookInterceptor) && !((_b = integrationLogic.webhooks) === null || _b === void 0 ? void 0 : _b.queueUrl)) {
|
|
102
|
+
app.post(`${integrationLogic.webhooks.integrationWebhookUrl
|
|
103
|
+
? integrationLogic.webhooks.integrationWebhookUrl
|
|
104
|
+
: '/api/integration/webhook'}`, (0, integration_webhook_1.default)(config, integrationLogic));
|
|
105
|
+
}
|
|
106
|
+
if ((_c = integrationLogic.webhooks) === null || _c === void 0 ? void 0 : _c.queueUrl) {
|
|
107
|
+
(0, webhooks_1.listenQueueMessage)({
|
|
108
|
+
config,
|
|
109
|
+
integration: integrationLogic,
|
|
110
|
+
queueUrl: integrationLogic.webhooks.queueUrl,
|
|
111
|
+
queueName: config.identifier,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
app.get('/api/user-errors', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, user_errors_1.default)());
|
|
116
|
+
cron.schedule('0 0 1 * *', () => (0, cron_1.removeFinishedJobs)());
|
|
117
|
+
}
|
|
118
|
+
exports.register = register;
|