@crowdin/app-project-module 0.17.3 → 0.17.5

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.
Files changed (77) hide show
  1. package/.github/workflows/basic.yml +39 -0
  2. package/.github/workflows/publish.yml +34 -0
  3. package/README.md +2 -1
  4. package/package.json +1 -1
  5. package/out/handlers/crowdin-file-progress.d.ts +0 -4
  6. package/out/handlers/crowdin-file-progress.js +0 -22
  7. package/out/handlers/crowdin-files.d.ts +0 -4
  8. package/out/handlers/crowdin-files.js +0 -31
  9. package/out/handlers/crowdin-project.d.ts +0 -4
  10. package/out/handlers/crowdin-project.js +0 -22
  11. package/out/handlers/crowdin-update.d.ts +0 -4
  12. package/out/handlers/crowdin-update.js +0 -26
  13. package/out/handlers/custom-file-format/download.d.ts +0 -4
  14. package/out/handlers/custom-file-format/download.js +0 -32
  15. package/out/handlers/custom-file-format/process.d.ts +0 -4
  16. package/out/handlers/custom-file-format/process.js +0 -134
  17. package/out/handlers/custom-mt/translate.d.ts +0 -4
  18. package/out/handlers/custom-mt/translate.js +0 -42
  19. package/out/handlers/install.d.ts +0 -4
  20. package/out/handlers/install.js +0 -45
  21. package/out/handlers/integration-data.d.ts +0 -4
  22. package/out/handlers/integration-data.js +0 -21
  23. package/out/handlers/integration-login.d.ts +0 -4
  24. package/out/handlers/integration-login.js +0 -30
  25. package/out/handlers/integration-logout.d.ts +0 -4
  26. package/out/handlers/integration-logout.js +0 -23
  27. package/out/handlers/integration-update.d.ts +0 -4
  28. package/out/handlers/integration-update.js +0 -25
  29. package/out/handlers/main.d.ts +0 -4
  30. package/out/handlers/main.js +0 -64
  31. package/out/handlers/manifest.d.ts +0 -3
  32. package/out/handlers/manifest.js +0 -120
  33. package/out/handlers/oauth-login.d.ts +0 -4
  34. package/out/handlers/oauth-login.js +0 -69
  35. package/out/handlers/settings-save.d.ts +0 -4
  36. package/out/handlers/settings-save.js +0 -21
  37. package/out/handlers/subscription-info.d.ts +0 -3
  38. package/out/handlers/subscription-info.js +0 -15
  39. package/out/handlers/sync-settings-save.d.ts +0 -4
  40. package/out/handlers/sync-settings-save.js +0 -29
  41. package/out/handlers/sync-settings.d.ts +0 -4
  42. package/out/handlers/sync-settings.js +0 -27
  43. package/out/handlers/uninstall.d.ts +0 -4
  44. package/out/handlers/uninstall.js +0 -27
  45. package/out/index.d.ts +0 -5
  46. package/out/index.js +0 -186
  47. package/out/logo.png +0 -0
  48. package/out/middlewares/crowdin-client.d.ts +0 -10
  49. package/out/middlewares/crowdin-client.js +0 -88
  50. package/out/middlewares/integration-credentials.d.ts +0 -4
  51. package/out/middlewares/integration-credentials.js +0 -39
  52. package/out/middlewares/json-response.d.ts +0 -2
  53. package/out/middlewares/json-response.js +0 -7
  54. package/out/middlewares/ui-module.d.ts +0 -4
  55. package/out/middlewares/ui-module.js +0 -39
  56. package/out/models/index.d.ts +0 -534
  57. package/out/models/index.js +0 -41
  58. package/out/static/css/styles.css +0 -57
  59. package/out/static/js/main.js +0 -130
  60. package/out/static/js/polyfills/fetch.js +0 -494
  61. package/out/static/js/polyfills/promise.js +0 -375
  62. package/out/storage/index.d.ts +0 -22
  63. package/out/storage/index.js +0 -319
  64. package/out/util/connection.d.ts +0 -10
  65. package/out/util/connection.js +0 -213
  66. package/out/util/cron.d.ts +0 -3
  67. package/out/util/cron.js +0 -103
  68. package/out/util/defaults.d.ts +0 -5
  69. package/out/util/defaults.js +0 -153
  70. package/out/util/index.d.ts +0 -11
  71. package/out/util/index.js +0 -105
  72. package/out/views/install.handlebars +0 -16
  73. package/out/views/login.handlebars +0 -115
  74. package/out/views/main.handlebars +0 -471
  75. package/out/views/oauth.handlebars +0 -4
  76. package/out/views/partials/head.handlebars +0 -20
  77. package/out/views/subscription.handlebars +0 -26
@@ -0,0 +1,39 @@
1
+ name: Basic CI
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [ "master" ]
6
+
7
+ jobs:
8
+ build:
9
+
10
+ strategy:
11
+ matrix:
12
+ node-version: [ 14.x, 16.x ]
13
+ os: [ ubuntu-latest, windows-latest ]
14
+
15
+ runs-on: ${{ matrix.os }}
16
+
17
+ steps:
18
+ - uses: actions/checkout@v3
19
+ - name: Use Node.js ${{ matrix.node-version }}
20
+ uses: actions/setup-node@v3
21
+ with:
22
+ node-version: ${{ matrix.node-version }}
23
+ cache: 'npm'
24
+
25
+ - name: Install dependencies
26
+ run: |
27
+ npm install
28
+
29
+ - name: Lint
30
+ run: |
31
+ npm run lint-ci
32
+
33
+ - name: Build
34
+ run: |
35
+ npm run build
36
+
37
+ - name: Tests
38
+ run: |
39
+ npm run test
@@ -0,0 +1,34 @@
1
+ name: Publish
2
+
3
+ on:
4
+ release:
5
+ types: [created]
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ - uses: actions/setup-node@v2
13
+ with:
14
+ node-version: 16
15
+ registry-url: https://registry.npmjs.org/
16
+ - run: npm ci
17
+ env:
18
+ NODE_AUTH_TOKEN: ${{secrets.npm_token}}
19
+
20
+ publish-npm:
21
+ needs: build
22
+ runs-on: ubuntu-latest
23
+ steps:
24
+ - uses: actions/checkout@v2
25
+ - uses: actions/setup-node@v2
26
+ with:
27
+ node-version: 16
28
+ registry-url: https://registry.npmjs.org/
29
+ - run: npm ci
30
+ env:
31
+ NODE_AUTH_TOKEN: ${{secrets.npm_token}}
32
+ - run: npm publish
33
+ env:
34
+ NODE_AUTH_TOKEN: ${{secrets.npm_token}}
package/README.md CHANGED
@@ -489,12 +489,13 @@ const configuration = {
489
489
  signaturePatterns: {
490
490
  fileName: '^.+\.xml$'
491
491
  },
492
+ customSrxSupported: true,
492
493
  parseFile: async (file, req, client, context, projectId) => {
493
494
  const xml = convert.xml2json(file, { compact: true, spaces: 4 });
494
495
  const fileContent = JSON.parse(xml);
495
496
  //parse logic
496
497
  const strings = [];
497
- return { strings };
498
+ return { strings, error: 'Some error message' };
498
499
  },
499
500
  buildFile: async (file, req, strings, client, context, projectId) => {
500
501
  const xml = convert.xml2json(file, { compact: true, spaces: 4 });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "0.17.3",
3
+ "version": "0.17.5",
4
4
  "description": "Module that generates for you all common endpoints for serving standalone Crowdin App",
5
5
  "main": "out/index.js",
6
6
  "types": "out/index.d.ts",
@@ -1,4 +0,0 @@
1
- /// <reference types="qs" />
2
- import { Response } from 'express';
3
- import { Config } from '../models';
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;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const util_1 = require("../util");
13
- function handle(config) {
14
- return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
15
- const fileId = Number(req.params.fileId);
16
- (0, util_1.log)(`Loading translation progress for file ${fileId}`, config.logger);
17
- const progress = yield req.crowdinApiClient.translationStatusApi.getFileProgress(req.crowdinContext.jwtPayload.context.project_id, fileId);
18
- (0, util_1.log)(`Translation progress for file ${fileId} ${JSON.stringify(progress.data, null, 2)}`, config.logger);
19
- res.send({ [fileId]: progress.data.map(e => e.data) });
20
- }), config.onError);
21
- }
22
- exports.default = handle;
@@ -1,4 +0,0 @@
1
- /// <reference types="qs" />
2
- import { Response } from 'express';
3
- import { Config, IntegrationLogic } from '../models';
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;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const util_1 = require("../util");
13
- const defaults_1 = require("../util/defaults");
14
- function handle(config, integration) {
15
- return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
16
- (0, util_1.log)('Loading crowdin files', config.logger);
17
- if (integration.getCrowdinFiles) {
18
- const rootFolder = yield (0, defaults_1.getRootFolder)(config, integration, req.crowdinApiClient, req.crowdinContext.jwtPayload.context.project_id);
19
- (0, util_1.log)(`Loading files ${rootFolder ? `from folder ${rootFolder.id}` : 'from root'}`, config.logger);
20
- const files = integration.getCrowdinFiles
21
- ? yield integration.getCrowdinFiles(req.crowdinContext.jwtPayload.context.project_id, req.crowdinApiClient, rootFolder, req.integrationSettings)
22
- : [];
23
- (0, util_1.log)(`Returning files ${JSON.stringify(files, null, 2)}`, config.logger);
24
- res.send(files);
25
- }
26
- else {
27
- res.send([]);
28
- }
29
- }), config.onError);
30
- }
31
- exports.default = handle;
@@ -1,4 +0,0 @@
1
- /// <reference types="qs" />
2
- import { Response } from 'express';
3
- import { Config } from '../models';
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;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const util_1 = require("../util");
13
- function handle(config) {
14
- return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
15
- const projectId = req.crowdinContext.jwtPayload.context.project_id;
16
- (0, util_1.log)(`Loading crowdin project ${projectId}`, config.logger);
17
- const project = yield req.crowdinApiClient.projectsGroupsApi.getProject(projectId);
18
- (0, util_1.log)(`Loaded crowdin project ${JSON.stringify(project, null, 2)}`, config.logger);
19
- res.send(project.data);
20
- }), config.onError);
21
- }
22
- exports.default = handle;
@@ -1,4 +0,0 @@
1
- /// <reference types="qs" />
2
- import { Response } from 'express';
3
- import { Config, IntegrationLogic } from '../models';
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;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const util_1 = require("../util");
13
- const defaults_1 = require("../util/defaults");
14
- function handle(config, integration) {
15
- return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
16
- const projectId = req.crowdinContext.jwtPayload.context.project_id;
17
- (0, util_1.log)(`Upading crowdin project ${projectId}`, config.logger);
18
- const rootFolder = yield (0, defaults_1.getRootFolder)(config, integration, req.crowdinApiClient, projectId);
19
- if (rootFolder) {
20
- (0, util_1.log)(`Upading crowdin files under folder ${rootFolder.id}`, config.logger);
21
- }
22
- yield integration.updateCrowdin(projectId, req.crowdinApiClient, req.integrationCredentials, req.body, rootFolder, req.integrationSettings);
23
- res.status(204).end();
24
- }), config.onError);
25
- }
26
- exports.default = handle;
@@ -1,4 +0,0 @@
1
- /// <reference types="qs" />
2
- import { Request, Response } from 'express';
3
- import { Config } from '../../models';
4
- export default function handle(config: Config, folder: string): (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;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const fs_1 = __importDefault(require("fs"));
16
- const path_1 = __importDefault(require("path"));
17
- const util_1 = require("../../util");
18
- function handle(config, folder) {
19
- return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
20
- const filePath = path_1.default.join(folder, 'custom-file-format', req.query.file);
21
- (0, util_1.log)(`Downloading file ${filePath}`, config.logger);
22
- res.download(filePath, function (err) {
23
- if (err) {
24
- console.error(err);
25
- }
26
- else {
27
- fs_1.default.unlinkSync(filePath);
28
- }
29
- });
30
- }), config.onError);
31
- }
32
- exports.default = handle;
@@ -1,4 +0,0 @@
1
- /// <reference types="qs" />
2
- import { Response } from 'express';
3
- import { Config, CustomFileFormatLogic } from '../../models';
4
- export default function handle(baseConfig: Config, baseUrl: string, folder: string, config: CustomFileFormatLogic): (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;
@@ -1,134 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const axios_1 = __importDefault(require("axios"));
16
- const fs_1 = __importDefault(require("fs"));
17
- const path_1 = __importDefault(require("path"));
18
- const models_1 = require("../../models");
19
- const util_1 = require("../../util");
20
- const MAX_BODY_SIZE = 5 * 1024 * 1024; //5mb
21
- function storeFile(fileContent, folder) {
22
- const fileName = `file${Date.now()}`;
23
- return new Promise((res, rej) => fs_1.default.writeFile(path_1.default.join(folder, 'custom-file-format', fileName), fileContent, err => {
24
- if (err) {
25
- rej(err);
26
- }
27
- else {
28
- res(fileName);
29
- }
30
- }));
31
- }
32
- function handleBuildFile(baseUrl, dataFolder, config, req, client, context, projectId, file) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- const response = {};
35
- if (!req.strings && !req.stringsUrl) {
36
- throw new Error('Bad payload received: No strings found');
37
- }
38
- let strings;
39
- if (req.strings) {
40
- strings = req.strings;
41
- }
42
- else {
43
- strings = (yield axios_1.default.get(req.stringsUrl)).data;
44
- }
45
- let res;
46
- if ((req.file.id || !file) && config.exportStrings) {
47
- res = yield config.exportStrings(req, strings, client, context, projectId);
48
- }
49
- else if (file && config.buildFile) {
50
- res = yield config.buildFile(file, req, strings, client, context, projectId);
51
- }
52
- else {
53
- return response;
54
- }
55
- const contentFileEncoded = Buffer.from(res.contentFile).toString('base64');
56
- if (Buffer.byteLength(contentFileEncoded, 'utf8') < MAX_BODY_SIZE) {
57
- response.content = contentFileEncoded;
58
- }
59
- else {
60
- const storedFile = yield storeFile(res.contentFile, dataFolder);
61
- response.contentUrl = `${baseUrl}?file=${storedFile}`;
62
- }
63
- return response;
64
- });
65
- }
66
- function handleParseFile(baseUrl, dataFolder, config, req, client, context, projectId, file) {
67
- return __awaiter(this, void 0, void 0, function* () {
68
- const response = {};
69
- if (!config.parseFile || !file) {
70
- return response;
71
- }
72
- const res = yield config.parseFile(file, req, client, context, projectId);
73
- if (res.previewFile) {
74
- const previewFileEncoded = Buffer.from(res.previewFile).toString('base64');
75
- if (Buffer.byteLength(previewFileEncoded, 'utf8') < MAX_BODY_SIZE) {
76
- response.preview = previewFileEncoded;
77
- }
78
- else {
79
- const storedFile = yield storeFile(res.previewFile, dataFolder);
80
- response.previewUrl = `${baseUrl}?file=${storedFile}`;
81
- }
82
- }
83
- if (res.strings) {
84
- let strings = res.strings;
85
- if (config.autoUploadTranslations) {
86
- strings = strings.map(string => {
87
- const translations = {};
88
- req.targetLanguages
89
- .map(targetLanguage => targetLanguage.id)
90
- .forEach(targetLanguage => (translations[targetLanguage] = { text: string.text }));
91
- return Object.assign(Object.assign({}, string), { translations });
92
- });
93
- }
94
- const stringsJson = JSON.stringify(strings);
95
- if (Buffer.byteLength(stringsJson, 'utf8') < MAX_BODY_SIZE) {
96
- response.strings = strings;
97
- }
98
- else {
99
- const storedFile = yield storeFile(stringsJson, dataFolder);
100
- response.stringsUrl = `${baseUrl}?file=${storedFile}`;
101
- }
102
- }
103
- return response;
104
- });
105
- }
106
- function handle(baseConfig, baseUrl, folder, config) {
107
- if (!fs_1.default.existsSync(path_1.default.join(folder, 'custom-file-format'))) {
108
- fs_1.default.mkdirSync(path_1.default.join(folder, 'custom-file-format'), { recursive: true });
109
- }
110
- return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
111
- const baseFilesUrl = `${baseUrl}/file/download`;
112
- const body = req.body;
113
- (0, util_1.log)(`Recieved request to process file ${JSON.stringify(body, null, 2)}`, baseConfig.logger);
114
- let file;
115
- if (body.file.content) {
116
- file = Buffer.from(body.file.content, 'base64').toString();
117
- }
118
- else if (body.file.contentUrl) {
119
- file = (yield axios_1.default.get(body.file.contentUrl)).data;
120
- }
121
- let response = {};
122
- switch (body.jobType) {
123
- case models_1.ProcessFileJobType.BUILD_FILE:
124
- response = yield handleBuildFile(baseFilesUrl, folder, config, body, req.crowdinApiClient, req.crowdinContext, req.crowdinContext.jwtPayload.context.project_id, file);
125
- break;
126
- case models_1.ProcessFileJobType.PARSE_FILE:
127
- response = yield handleParseFile(baseFilesUrl, folder, config, body, req.crowdinApiClient, req.crowdinContext, req.crowdinContext.jwtPayload.context.project_id, file);
128
- break;
129
- }
130
- (0, util_1.log)(`Returning response from process file action ${JSON.stringify(response, null, 2)}`, baseConfig.logger);
131
- res.send({ data: response });
132
- }), baseConfig.onError);
133
- }
134
- exports.default = handle;
@@ -1,4 +0,0 @@
1
- /// <reference types="qs" />
2
- import { Response } from 'express';
3
- import { Config, CustomMTLogic } from '../../models';
4
- export default function handle(baseConfig: Config, config: CustomMTLogic): (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;
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const util_1 = require("../../util");
13
- function handle(baseConfig, config) {
14
- return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
15
- const source = req.query.source;
16
- const target = req.query.target;
17
- const body = req.body;
18
- (0, util_1.log)('Recieved request for custom mt', baseConfig.logger);
19
- (0, util_1.log)(`Source language ${source}, target language ${target}`, baseConfig.logger);
20
- (0, util_1.log)(`Payload ${JSON.stringify(body, null, 2)}`, baseConfig.logger);
21
- const projectId = Number(req.query.project_id);
22
- try {
23
- if (source === 'en' && target === 'de' && body.strings && body.strings[0] === 'validation') {
24
- if (config.validate) {
25
- yield config.validate(req.crowdinApiClient);
26
- }
27
- res.send({ data: { translations: [] } });
28
- }
29
- else {
30
- const translations = yield config.translate(req.crowdinApiClient, req.crowdinContext, projectId, source, target, body.strings);
31
- res.send({ data: { translations } });
32
- }
33
- }
34
- catch (e) {
35
- const message = (0, util_1.getMessage)(e);
36
- res.send({
37
- error: { message },
38
- });
39
- }
40
- }), baseConfig.onError);
41
- }
42
- exports.default = handle;
@@ -1,4 +0,0 @@
1
- /// <reference types="qs" />
2
- import { Request, Response } from 'express';
3
- import { Config } from '../models';
4
- export default function handle(config: Config): (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;
@@ -1,45 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const crowdin_apps_functions_1 = require("@crowdin/crowdin-apps-functions");
13
- const models_1 = require("../models");
14
- const storage_1 = require("../storage");
15
- const util_1 = require("../util");
16
- function handle(config) {
17
- return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
18
- const event = req.body;
19
- (0, util_1.log)(`Recieved install request ${JSON.stringify(event, null, 2)}`, config.logger);
20
- const token = yield (0, crowdin_apps_functions_1.generateOAuthToken)(config.clientId, config.clientSecret, event.code);
21
- const credentials = {
22
- id: (event.domain || event.organizationId).toString(),
23
- appSecret: event.appSecret,
24
- domain: event.domain,
25
- userId: event.userId,
26
- organizationId: event.organizationId,
27
- baseUrl: event.baseUrl,
28
- accessToken: (0, util_1.encryptData)(config, token.accessToken),
29
- refreshToken: (0, util_1.encryptData)(config, token.refreshToken),
30
- expire: (new Date().getTime() / 1000 + token.expiresIn).toString(),
31
- type: event.domain ? models_1.AccountType.ENTERPRISE : models_1.AccountType.NORMAL,
32
- };
33
- const existingCredentials = yield (0, storage_1.getCrowdinCredentials)(credentials.id);
34
- if (!!existingCredentials) {
35
- yield (0, storage_1.updateCrowdinCredentials)(credentials);
36
- (0, util_1.log)('An existing App has been reinstalled', config.logger);
37
- }
38
- else {
39
- yield (0, storage_1.saveCrowdinCredentials)(credentials);
40
- (0, util_1.log)('A new App has been installed', config.logger);
41
- }
42
- res.status(204).end();
43
- }), config.onError);
44
- }
45
- exports.default = handle;
@@ -1,4 +0,0 @@
1
- /// <reference types="qs" />
2
- import { Response } from 'express';
3
- import { Config, IntegrationLogic } from '../models';
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;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const util_1 = require("../util");
13
- function handle(config, integration) {
14
- return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
15
- (0, util_1.log)('Recieved request to get integration data', config.logger);
16
- const files = yield integration.getIntegrationFiles(req.integrationCredentials, req.integrationSettings);
17
- (0, util_1.log)(`Integration data response ${JSON.stringify(files, null, 2)}`, config.logger);
18
- res.send(files);
19
- }), config.onError);
20
- }
21
- exports.default = handle;
@@ -1,4 +0,0 @@
1
- /// <reference types="qs" />
2
- import { Response } from 'express';
3
- import { Config, IntegrationLogic } from '../models';
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;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const storage_1 = require("../storage");
13
- const util_1 = require("../util");
14
- function handle(config, integration) {
15
- return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
16
- (0, util_1.log)('Recieved integration login request', config.logger);
17
- if (integration.checkConnection) {
18
- (0, util_1.log)('Checking the integration credentials', config.logger);
19
- yield integration.checkConnection(req.body.credentials);
20
- }
21
- const existing = yield (0, storage_1.getIntegrationCredentials)(req.crowdinContext.clientId);
22
- if (!!existing) {
23
- (0, util_1.log)('Deleting old credentials', config.logger);
24
- yield (0, storage_1.deleteIntegrationCredentials)(req.crowdinContext.clientId);
25
- }
26
- yield (0, storage_1.saveIntegrationCredentials)(req.crowdinContext.clientId, (0, util_1.encryptData)(config, JSON.stringify(req.body.credentials)), req.crowdinContext.crowdinId);
27
- res.status(204).end();
28
- }), config.onError);
29
- }
30
- exports.default = handle;
@@ -1,4 +0,0 @@
1
- /// <reference types="qs" />
2
- import { Response } from 'express';
3
- import { Config } from '../models';
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;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const storage_1 = require("../storage");
13
- const util_1 = require("../util");
14
- const connection_1 = require("../util/connection");
15
- function handle(config) {
16
- return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
17
- (0, util_1.log)('Recieved integration logout request', config.logger);
18
- yield (0, storage_1.deleteIntegrationCredentials)(req.crowdinContext.clientId);
19
- (0, connection_1.clearCache)(req.crowdinContext.crowdinId);
20
- res.status(204).end();
21
- }), config.onError);
22
- }
23
- exports.default = handle;
@@ -1,4 +0,0 @@
1
- /// <reference types="qs" />
2
- import { Response } from 'express';
3
- import { Config, IntegrationLogic } from '../models';
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;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const util_1 = require("../util");
13
- const defaults_1 = require("../util/defaults");
14
- function handle(config, integration) {
15
- return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
16
- (0, util_1.log)('Upading integratino data', config.logger);
17
- const rootFolder = yield (0, defaults_1.getRootFolder)(config, integration, req.crowdinApiClient, req.crowdinContext.jwtPayload.context.project_id);
18
- if (rootFolder) {
19
- (0, util_1.log)(`Upading integration data for crowding root folder ${rootFolder.id}`, config.logger);
20
- }
21
- yield integration.updateIntegration(req.crowdinContext.jwtPayload.context.project_id, req.crowdinApiClient, req.integrationCredentials, req.body, rootFolder, req.integrationSettings);
22
- res.status(204).end();
23
- }), config.onError);
24
- }
25
- exports.default = handle;