@crowdin/app-project-module 0.30.1 → 0.30.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/handlers/{crowdin-file-progress.d.ts → integration/crowdin-file-progress.d.ts} +1 -1
- package/out/handlers/{crowdin-file-progress.js → integration/crowdin-file-progress.js} +1 -1
- package/out/handlers/{crowdin-files.d.ts → integration/crowdin-files.d.ts} +1 -1
- package/out/handlers/{crowdin-files.js → integration/crowdin-files.js} +2 -2
- package/out/handlers/{crowdin-project.d.ts → integration/crowdin-project.d.ts} +1 -1
- package/out/handlers/{crowdin-project.js → integration/crowdin-project.js} +1 -1
- package/out/handlers/{crowdin-update.d.ts → integration/crowdin-update.d.ts} +1 -1
- package/out/handlers/{crowdin-update.js → integration/crowdin-update.js} +3 -3
- package/out/handlers/{crowdin-webhook.d.ts → integration/crowdin-webhook.d.ts} +1 -1
- package/out/handlers/{crowdin-webhook.js → integration/crowdin-webhook.js} +6 -6
- package/out/handlers/{integration-data.d.ts → integration/integration-data.d.ts} +1 -1
- package/out/handlers/{integration-data.js → integration/integration-data.js} +1 -1
- package/out/handlers/{integration-login.d.ts → integration/integration-login.d.ts} +1 -1
- package/out/handlers/{integration-login.js → integration/integration-login.js} +2 -2
- package/out/handlers/{integration-logout.d.ts → integration/integration-logout.d.ts} +1 -1
- package/out/handlers/{integration-logout.js → integration/integration-logout.js} +4 -4
- package/out/handlers/{integration-update.d.ts → integration/integration-update.d.ts} +1 -1
- package/out/handlers/{integration-update.js → integration/integration-update.js} +2 -2
- package/out/handlers/{integration-webhook.d.ts → integration/integration-webhook.d.ts} +1 -1
- package/out/handlers/{integration-webhook.js → integration/integration-webhook.js} +3 -3
- package/out/handlers/{main.d.ts → integration/main.d.ts} +1 -1
- package/out/handlers/{main.js → integration/main.js} +3 -3
- package/out/handlers/{oauth-login.d.ts → integration/oauth-login.d.ts} +1 -1
- package/out/handlers/{oauth-login.js → integration/oauth-login.js} +2 -2
- package/out/handlers/{oauth-url.d.ts → integration/oauth-url.d.ts} +1 -1
- package/out/handlers/{oauth-url.js → integration/oauth-url.js} +2 -2
- package/out/handlers/{settings-save.d.ts → integration/settings-save.d.ts} +1 -1
- package/out/handlers/{settings-save.js → integration/settings-save.js} +6 -6
- package/out/handlers/{settings.d.ts → integration/settings.d.ts} +1 -1
- package/out/handlers/{settings.js → integration/settings.js} +1 -1
- package/out/handlers/{subscription-info.d.ts → integration/subscription-info.d.ts} +1 -1
- package/out/handlers/{subscription-info.js → integration/subscription-info.js} +1 -1
- package/out/handlers/{sync-settings-save.d.ts → integration/sync-settings-save.d.ts} +1 -1
- package/out/handlers/{sync-settings-save.js → integration/sync-settings-save.js} +3 -3
- package/out/handlers/{sync-settings.d.ts → integration/sync-settings.d.ts} +1 -1
- package/out/handlers/{sync-settings.js → integration/sync-settings.js} +2 -2
- package/out/handlers/{synced-files.d.ts → integration/synced-files.d.ts} +1 -1
- package/out/handlers/{synced-files.js → integration/synced-files.js} +2 -2
- package/out/index.d.ts +1 -1
- package/out/index.js +21 -21
- package/out/util/api/api.d.ts +1 -1
- package/out/util/api/api.js +13 -13
- package/out/util/axios.d.ts +10 -0
- package/out/util/axios.js +42 -0
- package/out/util/connection.d.ts +1 -1
- package/out/util/connection.js +148 -6
- package/out/util/cron.d.ts +1 -1
- package/out/util/cron.js +6 -21
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { Config, IntegrationLogic } from '
|
|
3
|
+
import { Config, IntegrationLogic } from '../../models';
|
|
4
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;
|
|
@@ -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(config, integration) {
|
|
14
14
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
15
15
|
const fileId = Number(req.params.fileId || req.body.fileId);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { Config, IntegrationLogic } from '
|
|
3
|
+
import { Config, IntegrationLogic } from '../../models';
|
|
4
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;
|
|
@@ -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
|
(0, util_1.log)('Loading crowdin files', config.logger);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { Config } from '
|
|
3
|
+
import { Config } from '../../models';
|
|
4
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;
|
|
@@ -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(config) {
|
|
14
14
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
15
15
|
const projectId = req.crowdinContext.jwtPayload.context.project_id;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { Config, IntegrationLogic } from '
|
|
3
|
+
import { Config, IntegrationLogic } from '../../models';
|
|
4
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;
|
|
@@ -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 util_1 = require("
|
|
13
|
-
const defaults_1 = require("
|
|
14
|
-
const synced_files_1 = require("
|
|
12
|
+
const util_1 = require("../../util");
|
|
13
|
+
const defaults_1 = require("../../util/defaults");
|
|
14
|
+
const synced_files_1 = require("../../util/synced-files");
|
|
15
15
|
function handle(config, integration) {
|
|
16
16
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
var _a, _b, _c;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
|
-
import { Config, IntegrationLogic } from '../models';
|
|
3
2
|
import { Request, Response } from 'express';
|
|
3
|
+
import { Config, IntegrationLogic } from '../../models';
|
|
4
4
|
export default function handle(config: Config, integration: IntegrationLogic): (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;
|
|
@@ -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 models_1 = require("
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const file_snapshot_1 = require("
|
|
17
|
-
const
|
|
12
|
+
const models_1 = require("../../models");
|
|
13
|
+
const storage_1 = require("../../storage");
|
|
14
|
+
const util_1 = require("../../util");
|
|
15
|
+
const cron_1 = require("../../util/cron");
|
|
16
|
+
const file_snapshot_1 = require("../../util/file-snapshot");
|
|
17
|
+
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
|
var _a, _b;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { Config, IntegrationLogic } from '
|
|
3
|
+
import { Config, IntegrationLogic } from '../../models';
|
|
4
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;
|
|
@@ -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(config, integration) {
|
|
14
14
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
15
15
|
const { parent_id: parentId, search, page } = req.query;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { Config, IntegrationLogic } from '
|
|
3
|
+
import { Config, IntegrationLogic } from '../../models';
|
|
4
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;
|
|
@@ -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(config, integration) {
|
|
15
15
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
(0, util_1.log)('Received integration login request', config.logger);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { Config, IntegrationLogic } from '
|
|
3
|
+
import { Config, IntegrationLogic } from '../../models';
|
|
4
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;
|
|
@@ -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 storage_1 = require("
|
|
13
|
-
const util_1 = require("
|
|
14
|
-
const connection_1 = require("
|
|
15
|
-
const webhooks_1 = require("
|
|
12
|
+
const storage_1 = require("../../storage");
|
|
13
|
+
const util_1 = require("../../util");
|
|
14
|
+
const connection_1 = require("../../util/connection");
|
|
15
|
+
const webhooks_1 = require("../../util/webhooks");
|
|
16
16
|
function handle(config, integration) {
|
|
17
17
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
(0, util_1.log)('Received integration logout request', config.logger);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { Config, IntegrationLogic } from '
|
|
3
|
+
import { Config, IntegrationLogic } from '../../models';
|
|
4
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;
|
|
@@ -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
|
var _a;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
|
-
import { Config, IntegrationLogic } from '../models';
|
|
3
2
|
import { Request, Response } from 'express';
|
|
3
|
+
import { Config, IntegrationLogic } from '../../models';
|
|
4
4
|
export default function handle(config: Config, integration: IntegrationLogic): (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;
|
|
@@ -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 models_1 = require("
|
|
13
|
-
const util_1 = require("
|
|
14
|
-
const webhooks_1 = require("
|
|
12
|
+
const models_1 = require("../../models");
|
|
13
|
+
const util_1 = require("../../util");
|
|
14
|
+
const webhooks_1 = require("../../util/webhooks");
|
|
15
15
|
function handle(config, integration) {
|
|
16
16
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
var _a, _b;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { Config, IntegrationLogic } from '
|
|
3
|
+
import { Config, IntegrationLogic } from '../../models';
|
|
4
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;
|
|
@@ -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 util_1 = require("
|
|
13
|
-
const connection_1 = require("
|
|
14
|
-
const defaults_1 = require("
|
|
12
|
+
const util_1 = require("../../util");
|
|
13
|
+
const connection_1 = require("../../util/connection");
|
|
14
|
+
const defaults_1 = require("../../util/defaults");
|
|
15
15
|
function handle(config, integration) {
|
|
16
16
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
var _a;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
|
-
import { Config, IntegrationLogic } from '
|
|
3
|
+
import { Config, IntegrationLogic } from '../../models';
|
|
4
4
|
export default function handle(config: Config, integration: IntegrationLogic): (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;
|
|
@@ -13,8 +13,8 @@ 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("
|
|
16
|
+
const util_1 = require("../../util");
|
|
17
|
+
const defaults_1 = require("../../util/defaults");
|
|
18
18
|
function handle(config, integration) {
|
|
19
19
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { Config, IntegrationLogic } from '
|
|
3
|
+
import { Config, IntegrationLogic } from '../../models';
|
|
4
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;
|
|
@@ -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
|
(0, util_1.log)('Received OAuth login url request', config.logger);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { Config, IntegrationLogic } from '
|
|
3
|
+
import { Config, IntegrationLogic } from '../../models';
|
|
4
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;
|
|
@@ -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 models_1 = require("
|
|
13
|
-
const storage_1 = require("
|
|
14
|
-
const util_1 = require("
|
|
15
|
-
const
|
|
16
|
-
const file_snapshot_1 = require("
|
|
17
|
-
const
|
|
12
|
+
const models_1 = require("../../models");
|
|
13
|
+
const storage_1 = require("../../storage");
|
|
14
|
+
const util_1 = require("../../util");
|
|
15
|
+
const cron_1 = require("../../util/cron");
|
|
16
|
+
const file_snapshot_1 = require("../../util/file-snapshot");
|
|
17
|
+
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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { Config } from '
|
|
3
|
+
import { Config } from '../../models';
|
|
4
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;
|
|
@@ -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(config) {
|
|
14
14
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
15
15
|
let settings = {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { Config, IntegrationLogic } from '
|
|
3
|
+
import { Config, IntegrationLogic } from '../../models';
|
|
4
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;
|
|
@@ -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 util_1 = require("
|
|
13
|
-
const
|
|
14
|
-
const
|
|
12
|
+
const util_1 = require("../../util");
|
|
13
|
+
const cron_1 = require("../../util/cron");
|
|
14
|
+
const file_snapshot_1 = require("../../util/file-snapshot");
|
|
15
15
|
function handle(config, integration) {
|
|
16
16
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
var _a;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { Config } from '
|
|
3
|
+
import { Config } from '../../models';
|
|
4
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;
|
|
@@ -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(config) {
|
|
15
15
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
let files = {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { Config } from '
|
|
3
|
+
import { Config } from '../../models';
|
|
4
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;
|
|
@@ -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(config) {
|
|
15
15
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
let fileIds = [];
|
package/out/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Express } from 'express';
|
|
2
|
-
import express from './util/terminus-express';
|
|
3
2
|
import { ClientConfig, Config, CrowdinAppUtilities } from './models';
|
|
3
|
+
import express from './util/terminus-express';
|
|
4
4
|
export { Scope } from './models';
|
|
5
5
|
export { express };
|
|
6
6
|
export declare function addCrowdinEndpoints(app: Express, clientConfig: Config | ClientConfig): CrowdinAppUtilities;
|
package/out/index.js
CHANGED
|
@@ -39,13 +39,6 @@ exports.createApp = exports.addCrowdinEndpoints = exports.express = exports.Scop
|
|
|
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 terminus_express_1 = __importDefault(require("./util/terminus-express"));
|
|
43
|
-
exports.express = terminus_express_1.default;
|
|
44
|
-
const crowdin_file_progress_1 = __importDefault(require("./handlers/crowdin-file-progress"));
|
|
45
|
-
const crowdin_files_1 = __importDefault(require("./handlers/crowdin-files"));
|
|
46
|
-
const crowdin_project_1 = __importDefault(require("./handlers/crowdin-project"));
|
|
47
|
-
const crowdin_update_1 = __importDefault(require("./handlers/crowdin-update"));
|
|
48
|
-
const crowdin_webhook_1 = __importDefault(require("./handlers/crowdin-webhook"));
|
|
49
42
|
const translate_1 = __importDefault(require("./handlers/custom-mt/translate"));
|
|
50
43
|
const custom_file_format_1 = __importDefault(require("./handlers/file-processing/custom-file-format"));
|
|
51
44
|
const file_download_1 = __importDefault(require("./handlers/file-processing/file-download"));
|
|
@@ -53,21 +46,26 @@ const pre_post_process_1 = __importDefault(require("./handlers/file-processing/p
|
|
|
53
46
|
const form_data_display_1 = __importDefault(require("./handlers/form-data-display"));
|
|
54
47
|
const form_data_save_1 = __importDefault(require("./handlers/form-data-save"));
|
|
55
48
|
const install_1 = __importDefault(require("./handlers/install"));
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
const
|
|
49
|
+
const crowdin_file_progress_1 = __importDefault(require("./handlers/integration/crowdin-file-progress"));
|
|
50
|
+
const crowdin_files_1 = __importDefault(require("./handlers/integration/crowdin-files"));
|
|
51
|
+
const crowdin_project_1 = __importDefault(require("./handlers/integration/crowdin-project"));
|
|
52
|
+
const crowdin_update_1 = __importDefault(require("./handlers/integration/crowdin-update"));
|
|
53
|
+
const crowdin_webhook_1 = __importDefault(require("./handlers/integration/crowdin-webhook"));
|
|
54
|
+
const integration_data_1 = __importDefault(require("./handlers/integration/integration-data"));
|
|
55
|
+
const integration_login_1 = __importDefault(require("./handlers/integration/integration-login"));
|
|
56
|
+
const integration_logout_1 = __importDefault(require("./handlers/integration/integration-logout"));
|
|
57
|
+
const integration_update_1 = __importDefault(require("./handlers/integration/integration-update"));
|
|
58
|
+
const integration_webhook_1 = __importDefault(require("./handlers/integration/integration-webhook"));
|
|
59
|
+
const main_1 = __importDefault(require("./handlers/integration/main"));
|
|
60
|
+
const oauth_login_1 = __importDefault(require("./handlers/integration/oauth-login"));
|
|
61
|
+
const oauth_url_1 = __importDefault(require("./handlers/integration/oauth-url"));
|
|
62
|
+
const settings_save_1 = __importDefault(require("./handlers/integration/settings-save"));
|
|
63
|
+
const subscription_info_1 = __importDefault(require("./handlers/integration/subscription-info"));
|
|
64
|
+
const sync_settings_1 = __importDefault(require("./handlers/integration/sync-settings"));
|
|
65
|
+
const sync_settings_save_1 = __importDefault(require("./handlers/integration/sync-settings-save"));
|
|
66
|
+
const synced_files_1 = __importDefault(require("./handlers/integration/synced-files"));
|
|
62
67
|
const manifest_1 = __importDefault(require("./handlers/manifest"));
|
|
63
|
-
const oauth_login_1 = __importDefault(require("./handlers/oauth-login"));
|
|
64
|
-
const oauth_url_1 = __importDefault(require("./handlers/oauth-url"));
|
|
65
|
-
const settings_save_1 = __importDefault(require("./handlers/settings-save"));
|
|
66
|
-
const subscription_info_1 = __importDefault(require("./handlers/subscription-info"));
|
|
67
68
|
const subscription_paid_1 = __importDefault(require("./handlers/subscription-paid"));
|
|
68
|
-
const sync_settings_1 = __importDefault(require("./handlers/sync-settings"));
|
|
69
|
-
const sync_settings_save_1 = __importDefault(require("./handlers/sync-settings-save"));
|
|
70
|
-
const synced_files_1 = __importDefault(require("./handlers/synced-files"));
|
|
71
69
|
const uninstall_1 = __importDefault(require("./handlers/uninstall"));
|
|
72
70
|
const crowdin_client_1 = __importStar(require("./middlewares/crowdin-client"));
|
|
73
71
|
const integration_credentials_1 = __importDefault(require("./middlewares/integration-credentials"));
|
|
@@ -77,11 +75,13 @@ const ui_module_1 = __importDefault(require("./middlewares/ui-module"));
|
|
|
77
75
|
const models_1 = require("./models");
|
|
78
76
|
const storage = __importStar(require("./storage"));
|
|
79
77
|
const util_1 = require("./util");
|
|
78
|
+
const api_1 = require("./util/api/api");
|
|
80
79
|
const connection_1 = require("./util/connection");
|
|
81
80
|
const cron_1 = require("./util/cron");
|
|
82
81
|
const defaults_1 = require("./util/defaults");
|
|
82
|
+
const terminus_express_1 = __importDefault(require("./util/terminus-express"));
|
|
83
|
+
exports.express = terminus_express_1.default;
|
|
83
84
|
const webhooks_1 = require("./util/webhooks");
|
|
84
|
-
const api_1 = require("./util/api/api");
|
|
85
85
|
var models_2 = require("./models");
|
|
86
86
|
Object.defineProperty(exports, "Scope", { enumerable: true, get: function () { return models_2.Scope; } });
|
|
87
87
|
function addCrowdinEndpoints(app, clientConfig) {
|
package/out/util/api/api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ApiEndpoints, ApiModule, Config, CrowdinClientRequest, CrowdinContextInfo } from '../../models';
|
|
2
1
|
import { Express } from 'express';
|
|
2
|
+
import { ApiEndpoints, ApiModule, Config, CrowdinClientRequest, CrowdinContextInfo } from '../../models';
|
|
3
3
|
export declare function getApiManifest(config: Config, apiModule: ApiModule): ApiEndpoints[];
|
|
4
4
|
export declare function updateCrowdinContext(req: CrowdinClientRequest, context: CrowdinContextInfo): CrowdinContextInfo;
|
|
5
5
|
export declare function addDefaultApiEndpoints(app: Express, config: Config): void;
|
package/out/util/api/api.js
CHANGED
|
@@ -4,23 +4,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.addSwagerApiDocumentation = exports.addDefaultApiEndpoints = exports.updateCrowdinContext = exports.getApiManifest = void 0;
|
|
7
|
-
const
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const redoc_express_1 = __importDefault(require("redoc-express"));
|
|
9
9
|
const swagger_jsdoc_1 = __importDefault(require("swagger-jsdoc"));
|
|
10
|
-
const
|
|
10
|
+
const crowdin_file_progress_1 = __importDefault(require("../../handlers/integration/crowdin-file-progress"));
|
|
11
|
+
const crowdin_files_1 = __importDefault(require("../../handlers/integration/crowdin-files"));
|
|
12
|
+
const crowdin_update_1 = __importDefault(require("../../handlers/integration/crowdin-update"));
|
|
13
|
+
const integration_data_1 = __importDefault(require("../../handlers/integration/integration-data"));
|
|
14
|
+
const integration_login_1 = __importDefault(require("../../handlers/integration/integration-login"));
|
|
15
|
+
const integration_update_1 = __importDefault(require("../../handlers/integration/integration-update"));
|
|
16
|
+
const settings_1 = __importDefault(require("../../handlers/integration/settings"));
|
|
17
|
+
const settings_save_1 = __importDefault(require("../../handlers/integration/settings-save"));
|
|
18
|
+
const sync_settings_1 = __importDefault(require("../../handlers/integration/sync-settings"));
|
|
19
|
+
const sync_settings_save_1 = __importDefault(require("../../handlers/integration/sync-settings-save"));
|
|
11
20
|
const crowdin_client_1 = __importDefault(require("../../middlewares/crowdin-client"));
|
|
12
21
|
const integration_credentials_1 = __importDefault(require("../../middlewares/integration-credentials"));
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const crowdin_file_progress_1 = __importDefault(require("../../handlers/crowdin-file-progress"));
|
|
16
|
-
const crowdin_update_1 = __importDefault(require("../../handlers/crowdin-update"));
|
|
17
|
-
const sync_settings_1 = __importDefault(require("../../handlers/sync-settings"));
|
|
18
|
-
const sync_settings_save_1 = __importDefault(require("../../handlers/sync-settings-save"));
|
|
19
|
-
const settings_save_1 = __importDefault(require("../../handlers/settings-save"));
|
|
20
|
-
const settings_1 = __importDefault(require("../../handlers/settings"));
|
|
21
|
-
const integration_update_1 = __importDefault(require("../../handlers/integration-update"));
|
|
22
|
-
const path_1 = __importDefault(require("path"));
|
|
23
|
-
const integration_login_1 = __importDefault(require("../../handlers/integration-login"));
|
|
22
|
+
const json_response_1 = __importDefault(require("../../middlewares/json-response"));
|
|
23
|
+
const models_1 = require("../../models");
|
|
24
24
|
function getApiManifest(config, apiModule) {
|
|
25
25
|
const apiModuleManifest = [];
|
|
26
26
|
if (apiModule.endpoints) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
export declare class AxiosProvider {
|
|
3
|
+
private static readonly CROWDIN_API_MAX_CONCURRENT_REQUESTS;
|
|
4
|
+
private static readonly CROWDIN_API_REQUESTS_INTERVAL_MS;
|
|
5
|
+
private pendingRequests;
|
|
6
|
+
axios: AxiosInstance;
|
|
7
|
+
constructor();
|
|
8
|
+
private configureRequest;
|
|
9
|
+
private configureResponse;
|
|
10
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AxiosProvider = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
//copy from api client to control throughput
|
|
9
|
+
class AxiosProvider {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.pendingRequests = 0;
|
|
12
|
+
this.axios = axios_1.default.create({});
|
|
13
|
+
this.configureRequest();
|
|
14
|
+
this.configureResponse();
|
|
15
|
+
}
|
|
16
|
+
configureRequest() {
|
|
17
|
+
this.axios.interceptors.request.use((config) => {
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
19
|
+
return new Promise((resolve) => {
|
|
20
|
+
const interval = setInterval(() => {
|
|
21
|
+
if (this.pendingRequests < AxiosProvider.CROWDIN_API_MAX_CONCURRENT_REQUESTS) {
|
|
22
|
+
this.pendingRequests++;
|
|
23
|
+
clearInterval(interval);
|
|
24
|
+
resolve(config);
|
|
25
|
+
}
|
|
26
|
+
}, AxiosProvider.CROWDIN_API_REQUESTS_INTERVAL_MS);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
configureResponse() {
|
|
31
|
+
this.axios.interceptors.response.use((response) => {
|
|
32
|
+
this.pendingRequests = Math.max(0, this.pendingRequests - 1);
|
|
33
|
+
return Promise.resolve(response);
|
|
34
|
+
}, (error) => {
|
|
35
|
+
this.pendingRequests = Math.max(0, this.pendingRequests - 1);
|
|
36
|
+
return Promise.reject(error);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.AxiosProvider = AxiosProvider;
|
|
41
|
+
AxiosProvider.CROWDIN_API_MAX_CONCURRENT_REQUESTS = 15;
|
|
42
|
+
AxiosProvider.CROWDIN_API_REQUESTS_INTERVAL_MS = 10;
|
package/out/util/connection.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Crowdin from '@crowdin/crowdin-api-client';
|
|
2
2
|
import { AccountType, Config, CrowdinCredentials, IntegrationCredentials, IntegrationLogic, SubscriptionInfo } from '../models';
|
|
3
|
-
export declare function prepareCrowdinClient(config: Config, credentials: CrowdinCredentials): Promise<{
|
|
3
|
+
export declare function prepareCrowdinClient(config: Config, credentials: CrowdinCredentials, autoRenew?: boolean): Promise<{
|
|
4
4
|
client: Crowdin;
|
|
5
5
|
token: string;
|
|
6
6
|
}>;
|
package/out/util/connection.js
CHANGED
|
@@ -19,6 +19,8 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
19
19
|
const _1 = require(".");
|
|
20
20
|
const models_1 = require("../models");
|
|
21
21
|
const storage_1 = require("../storage");
|
|
22
|
+
const axios_2 = require("./axios");
|
|
23
|
+
const axiosCustom = new axios_2.AxiosProvider().axios;
|
|
22
24
|
function refreshToken(config, credentials) {
|
|
23
25
|
var _a, _b;
|
|
24
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -51,23 +53,163 @@ function refreshToken(config, credentials) {
|
|
|
51
53
|
};
|
|
52
54
|
});
|
|
53
55
|
}
|
|
54
|
-
function prepareCrowdinClient(config, credentials) {
|
|
56
|
+
function prepareCrowdinClient(config, credentials, autoRenew = false) {
|
|
55
57
|
var _a, _b;
|
|
56
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
59
|
//2 min as an extra buffer
|
|
58
60
|
const isExpired = +credentials.expire - 120 < Date.now() / 1000;
|
|
59
61
|
const organization = credentials.type === models_1.AccountType.ENTERPRISE ? credentials.id : undefined;
|
|
62
|
+
let token;
|
|
63
|
+
let crowdinCreds;
|
|
60
64
|
if (!isExpired) {
|
|
61
|
-
|
|
65
|
+
token = (0, _1.decryptData)(config, credentials.accessToken);
|
|
66
|
+
crowdinCreds = credentials;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const res = yield refreshCrowdinCreds({ config, credentials });
|
|
70
|
+
token = res.token;
|
|
71
|
+
crowdinCreds = res.credentials;
|
|
72
|
+
}
|
|
73
|
+
if (!autoRenew) {
|
|
62
74
|
return {
|
|
63
75
|
client: new crowdin_api_client_1.default({ token, organization, baseUrl: (_a = config.crowdinUrls) === null || _a === void 0 ? void 0 : _a.apiUrl }),
|
|
64
76
|
token,
|
|
65
77
|
};
|
|
66
78
|
}
|
|
79
|
+
const getHttpConfig = (config) => {
|
|
80
|
+
if (!config) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
return { headers: Object.assign(Object.assign({}, config.headers), { Authorization: `Bearer ${token}` }) };
|
|
84
|
+
};
|
|
85
|
+
const renewToken = () => __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
const res = yield refreshCrowdinCreds({ config, credentials: crowdinCreds });
|
|
87
|
+
token = res.token;
|
|
88
|
+
crowdinCreds = res.credentials;
|
|
89
|
+
});
|
|
90
|
+
const isExpiredCause = (error) => {
|
|
91
|
+
var _a, _b;
|
|
92
|
+
const errorObj = (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error;
|
|
93
|
+
return (errorObj === null || errorObj === void 0 ? void 0 : errorObj.code) === 401 && (errorObj === null || errorObj === void 0 ? void 0 : errorObj.message) === 'Unauthorized';
|
|
94
|
+
};
|
|
95
|
+
//providing custom http client to handle expirations and renew token on the fly
|
|
96
|
+
//needed for long running jobs with single Crowdin client instance
|
|
97
|
+
return {
|
|
98
|
+
client: new crowdin_api_client_1.default({
|
|
99
|
+
token,
|
|
100
|
+
organization,
|
|
101
|
+
baseUrl: (_b = config.crowdinUrls) === null || _b === void 0 ? void 0 : _b.apiUrl,
|
|
102
|
+
}, {
|
|
103
|
+
httpClient: {
|
|
104
|
+
get(url, httpConfig) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
try {
|
|
107
|
+
const res = yield axiosCustom.get(url, getHttpConfig(httpConfig));
|
|
108
|
+
return res.data;
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
if (isExpiredCause(e)) {
|
|
112
|
+
yield renewToken();
|
|
113
|
+
const res = yield axiosCustom.get(url, getHttpConfig(httpConfig));
|
|
114
|
+
return res.data;
|
|
115
|
+
}
|
|
116
|
+
throw e;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
delete(url, httpConfig) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
try {
|
|
123
|
+
const res = yield axiosCustom.delete(url, getHttpConfig(httpConfig));
|
|
124
|
+
return res.data;
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
if (isExpiredCause(e)) {
|
|
128
|
+
yield renewToken();
|
|
129
|
+
const res = yield axiosCustom.delete(url, getHttpConfig(httpConfig));
|
|
130
|
+
return res.data;
|
|
131
|
+
}
|
|
132
|
+
throw e;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
head(url, httpConfig) {
|
|
137
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
try {
|
|
139
|
+
const res = yield axiosCustom.head(url, getHttpConfig(httpConfig));
|
|
140
|
+
return res.data;
|
|
141
|
+
}
|
|
142
|
+
catch (e) {
|
|
143
|
+
if (isExpiredCause(e)) {
|
|
144
|
+
yield renewToken();
|
|
145
|
+
const res = yield axiosCustom.head(url, getHttpConfig(httpConfig));
|
|
146
|
+
return res.data;
|
|
147
|
+
}
|
|
148
|
+
throw e;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
},
|
|
152
|
+
patch(url, data, httpConfig) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
try {
|
|
155
|
+
const res = yield axiosCustom.patch(url, data, getHttpConfig(httpConfig));
|
|
156
|
+
return res.data;
|
|
157
|
+
}
|
|
158
|
+
catch (e) {
|
|
159
|
+
if (isExpiredCause(e)) {
|
|
160
|
+
yield renewToken();
|
|
161
|
+
const res = yield axiosCustom.patch(url, data, getHttpConfig(httpConfig));
|
|
162
|
+
return res.data;
|
|
163
|
+
}
|
|
164
|
+
throw e;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
},
|
|
168
|
+
post(url, data, httpConfig) {
|
|
169
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
170
|
+
try {
|
|
171
|
+
const res = yield axiosCustom.post(url, data, getHttpConfig(httpConfig));
|
|
172
|
+
return res.data;
|
|
173
|
+
}
|
|
174
|
+
catch (e) {
|
|
175
|
+
if (isExpiredCause(e)) {
|
|
176
|
+
yield renewToken();
|
|
177
|
+
const res = yield axiosCustom.post(url, data, getHttpConfig(httpConfig));
|
|
178
|
+
return res.data;
|
|
179
|
+
}
|
|
180
|
+
throw e;
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
},
|
|
184
|
+
put(url, data, httpConfig) {
|
|
185
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
+
try {
|
|
187
|
+
const res = yield axiosCustom.put(url, data, getHttpConfig(httpConfig));
|
|
188
|
+
return res.data;
|
|
189
|
+
}
|
|
190
|
+
catch (e) {
|
|
191
|
+
if (isExpiredCause(e)) {
|
|
192
|
+
yield renewToken();
|
|
193
|
+
const res = yield axiosCustom.put(url, data, getHttpConfig(httpConfig));
|
|
194
|
+
return res.data;
|
|
195
|
+
}
|
|
196
|
+
throw e;
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
}),
|
|
202
|
+
token,
|
|
203
|
+
};
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
exports.prepareCrowdinClient = prepareCrowdinClient;
|
|
207
|
+
function refreshCrowdinCreds({ config, credentials }) {
|
|
208
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
209
|
(0, _1.log)('Crowdin credentials have expired. Requesting a new credentials', config.logger);
|
|
68
210
|
const newCredentials = yield refreshToken(config, credentials);
|
|
69
211
|
(0, _1.log)('Saving updated crowdin credentials in the database', config.logger);
|
|
70
|
-
|
|
212
|
+
const newCrowdinCredentials = {
|
|
71
213
|
id: credentials.id,
|
|
72
214
|
appSecret: credentials.appSecret,
|
|
73
215
|
domain: credentials.domain,
|
|
@@ -78,15 +220,15 @@ function prepareCrowdinClient(config, credentials) {
|
|
|
78
220
|
accessToken: newCredentials.accessToken,
|
|
79
221
|
expire: (new Date().getTime() / 1000 + newCredentials.expiresIn).toString(),
|
|
80
222
|
type: credentials.type,
|
|
81
|
-
}
|
|
223
|
+
};
|
|
224
|
+
yield (0, storage_1.getStorage)().updateCrowdinCredentials(newCrowdinCredentials);
|
|
82
225
|
const token = (0, _1.decryptData)(config, newCredentials.accessToken);
|
|
83
226
|
return {
|
|
84
|
-
|
|
227
|
+
credentials: newCrowdinCredentials,
|
|
85
228
|
token,
|
|
86
229
|
};
|
|
87
230
|
});
|
|
88
231
|
}
|
|
89
|
-
exports.prepareCrowdinClient = prepareCrowdinClient;
|
|
90
232
|
function prepareIntegrationCredentials(config, integration, integrationCredentials) {
|
|
91
233
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
92
234
|
return __awaiter(this, void 0, void 0, function* () {
|
package/out/util/cron.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Crowdin from '@crowdin/crowdin-api-client';
|
|
2
|
-
import { Config, CronJob, IntegrationLogic,
|
|
2
|
+
import { Config, CronJob, IntegrationLogic, IntegrationRequest, Provider, UpdateIntegrationRequest } from '../models';
|
|
3
3
|
export declare function runJob(config: Config, integration: IntegrationLogic, job: CronJob): Promise<void>;
|
|
4
4
|
export declare function filesCron(config: Config, integration: IntegrationLogic, period: string): Promise<void>;
|
|
5
5
|
export declare function skipFoldersFromIntegrationRequest(config: Config, integration: IntegrationLogic, projectId: number, crowdinFiles: UpdateIntegrationRequest, crowdinClient: Crowdin): Promise<UpdateIntegrationRequest>;
|
package/out/util/cron.js
CHANGED
|
@@ -45,16 +45,14 @@ function runJob(config, integration, job) {
|
|
|
45
45
|
(0, _1.log)(`Starting cron job with expression [${job.expression}]`, config.logger);
|
|
46
46
|
const crowdinCredentialsList = yield (0, storage_1.getStorage)().getAllCrowdinCredentials();
|
|
47
47
|
yield Promise.all(crowdinCredentialsList.map((crowdinCredentials) => __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
const { token } = yield (0, connection_1.prepareCrowdinClient)(config, crowdinCredentials);
|
|
48
|
+
const { token, client: crowdinClient } = yield (0, connection_1.prepareCrowdinClient)(config, crowdinCredentials, true);
|
|
49
49
|
const { expired } = yield (0, connection_1.checkSubscription)(config, token, crowdinCredentials.id, crowdinCredentials.type);
|
|
50
50
|
if (expired) {
|
|
51
51
|
(0, _1.log)(`Subscription expired. Skipping job [${job.expression}] for organization ${crowdinCredentials.id}`);
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
54
|
const integrationCredentialsList = yield (0, storage_1.getStorage)().getAllIntegrationCredentials(crowdinCredentials.id);
|
|
55
|
-
//executing in non-parallel way to properly prepare crowdin client (avoid expriration issues)
|
|
56
55
|
for (const integrationCredentials of integrationCredentialsList) {
|
|
57
|
-
const { client: crowdinClient } = yield (0, connection_1.prepareCrowdinClient)(config, crowdinCredentials);
|
|
58
56
|
const projectId = crowdinAppFunctions.getProjectId(integrationCredentials.id);
|
|
59
57
|
const apiCredentials = yield (0, connection_1.prepareIntegrationCredentials)(config, integration, integrationCredentials);
|
|
60
58
|
const rootFolder = yield (0, defaults_1.getRootFolder)(config, integration, crowdinClient, projectId);
|
|
@@ -88,7 +86,7 @@ function filesCron(config, integration, period) {
|
|
|
88
86
|
return;
|
|
89
87
|
}
|
|
90
88
|
const projectId = crowdinAppFunctions.getProjectId(integrationCredentials.id);
|
|
91
|
-
const { client: crowdinClient, token } = yield (0, connection_1.prepareCrowdinClient)(config, crowdinCredentials);
|
|
89
|
+
const { client: crowdinClient, token } = yield (0, connection_1.prepareCrowdinClient)(config, crowdinCredentials, true);
|
|
92
90
|
const { expired } = yield (0, connection_1.checkSubscription)(config, token, crowdinCredentials.id, crowdinCredentials.type);
|
|
93
91
|
if (expired) {
|
|
94
92
|
(0, _1.log)(`Subscription expired. Skipping job [${period}] for organization ${crowdinCredentials.id}`);
|
|
@@ -96,8 +94,6 @@ function filesCron(config, integration, period) {
|
|
|
96
94
|
}
|
|
97
95
|
const rootFolder = yield (0, defaults_1.getRootFolder)(config, integration, crowdinClient, projectId);
|
|
98
96
|
const apiCredentials = yield (0, connection_1.prepareIntegrationCredentials)(config, integration, integrationCredentials);
|
|
99
|
-
//split invocation into chunks to avoid expiration issues
|
|
100
|
-
const chunkSize = 10;
|
|
101
97
|
if ((_a = integration.syncNewElements) === null || _a === void 0 ? void 0 : _a[syncSettings.provider]) {
|
|
102
98
|
newFiles = yield (0, file_snapshot_1.getAllNewFiles)({
|
|
103
99
|
config,
|
|
@@ -126,15 +122,8 @@ function filesCron(config, integration, period) {
|
|
|
126
122
|
return;
|
|
127
123
|
}
|
|
128
124
|
}
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
const chunk = filesArr.slice(i, i + chunkSize);
|
|
132
|
-
const filesChunk = {};
|
|
133
|
-
chunk.forEach((f) => (filesChunk[f] = filesToProcess[f]));
|
|
134
|
-
const apiCredentials = yield (0, connection_1.prepareIntegrationCredentials)(config, integration, integrationCredentials);
|
|
135
|
-
const { client } = yield (0, connection_1.prepareCrowdinClient)(config, crowdinCredentials);
|
|
136
|
-
yield integration.updateIntegration(projectId, client, apiCredentials, filesChunk, rootFolder, intConfig);
|
|
137
|
-
}
|
|
125
|
+
const apiCredentials = yield (0, connection_1.prepareIntegrationCredentials)(config, integration, integrationCredentials);
|
|
126
|
+
yield integration.updateIntegration(projectId, crowdinClient, apiCredentials, filesToProcess, rootFolder, intConfig);
|
|
138
127
|
if (newFiles) {
|
|
139
128
|
yield (0, storage_1.getStorage)().updateSyncSettings(JSON.stringify(Object.assign(Object.assign({}, files), newFiles)), syncSettings.integrationId, syncSettings.crowdinId, 'schedule', syncSettings.provider);
|
|
140
129
|
const currentFileSnapshot = yield (0, file_snapshot_1.getCrowdinSnapshot)(config, integration, crowdinClient, projectId, intConfig);
|
|
@@ -150,12 +139,8 @@ function filesCron(config, integration, period) {
|
|
|
150
139
|
node_type: file.nodeType || file.node_type }, (file.type ? { type: file.type } : {}))));
|
|
151
140
|
const intFiles = allIntFiles.filter((file) => 'type' in file);
|
|
152
141
|
(0, _1.log)(`Executing updateCrowdin task for files cron job with period [${period}] for project ${projectId}. Files ${intFiles.length}`, config.logger);
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const apiCredentials = yield (0, connection_1.prepareIntegrationCredentials)(config, integration, integrationCredentials);
|
|
156
|
-
const { client } = yield (0, connection_1.prepareCrowdinClient)(config, crowdinCredentials);
|
|
157
|
-
yield integration.updateCrowdin(projectId, client, apiCredentials, chunk, rootFolder, intConfig);
|
|
158
|
-
}
|
|
142
|
+
const apiCredentials = yield (0, connection_1.prepareIntegrationCredentials)(config, integration, integrationCredentials);
|
|
143
|
+
yield integration.updateCrowdin(projectId, crowdinClient, apiCredentials, intFiles, rootFolder, intConfig);
|
|
159
144
|
const newSyncSettingsFiels = allIntFiles.map((file) => (Object.assign(Object.assign({}, file), { schedule: true, sync: false })));
|
|
160
145
|
if (newFiles) {
|
|
161
146
|
yield (0, storage_1.getStorage)().updateSyncSettings(JSON.stringify(newSyncSettingsFiels), syncSettings.integrationId, syncSettings.crowdinId, 'schedule', syncSettings.provider);
|
package/package.json
CHANGED