@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.
- package/.github/workflows/basic.yml +39 -0
- package/.github/workflows/publish.yml +34 -0
- package/README.md +2 -1
- package/package.json +1 -1
- package/out/handlers/crowdin-file-progress.d.ts +0 -4
- package/out/handlers/crowdin-file-progress.js +0 -22
- package/out/handlers/crowdin-files.d.ts +0 -4
- package/out/handlers/crowdin-files.js +0 -31
- package/out/handlers/crowdin-project.d.ts +0 -4
- package/out/handlers/crowdin-project.js +0 -22
- package/out/handlers/crowdin-update.d.ts +0 -4
- package/out/handlers/crowdin-update.js +0 -26
- package/out/handlers/custom-file-format/download.d.ts +0 -4
- package/out/handlers/custom-file-format/download.js +0 -32
- package/out/handlers/custom-file-format/process.d.ts +0 -4
- package/out/handlers/custom-file-format/process.js +0 -134
- package/out/handlers/custom-mt/translate.d.ts +0 -4
- package/out/handlers/custom-mt/translate.js +0 -42
- package/out/handlers/install.d.ts +0 -4
- package/out/handlers/install.js +0 -45
- package/out/handlers/integration-data.d.ts +0 -4
- package/out/handlers/integration-data.js +0 -21
- package/out/handlers/integration-login.d.ts +0 -4
- package/out/handlers/integration-login.js +0 -30
- package/out/handlers/integration-logout.d.ts +0 -4
- package/out/handlers/integration-logout.js +0 -23
- package/out/handlers/integration-update.d.ts +0 -4
- package/out/handlers/integration-update.js +0 -25
- package/out/handlers/main.d.ts +0 -4
- package/out/handlers/main.js +0 -64
- package/out/handlers/manifest.d.ts +0 -3
- package/out/handlers/manifest.js +0 -120
- package/out/handlers/oauth-login.d.ts +0 -4
- package/out/handlers/oauth-login.js +0 -69
- package/out/handlers/settings-save.d.ts +0 -4
- package/out/handlers/settings-save.js +0 -21
- package/out/handlers/subscription-info.d.ts +0 -3
- package/out/handlers/subscription-info.js +0 -15
- package/out/handlers/sync-settings-save.d.ts +0 -4
- package/out/handlers/sync-settings-save.js +0 -29
- package/out/handlers/sync-settings.d.ts +0 -4
- package/out/handlers/sync-settings.js +0 -27
- package/out/handlers/uninstall.d.ts +0 -4
- package/out/handlers/uninstall.js +0 -27
- package/out/index.d.ts +0 -5
- package/out/index.js +0 -186
- package/out/logo.png +0 -0
- package/out/middlewares/crowdin-client.d.ts +0 -10
- package/out/middlewares/crowdin-client.js +0 -88
- package/out/middlewares/integration-credentials.d.ts +0 -4
- package/out/middlewares/integration-credentials.js +0 -39
- package/out/middlewares/json-response.d.ts +0 -2
- package/out/middlewares/json-response.js +0 -7
- package/out/middlewares/ui-module.d.ts +0 -4
- package/out/middlewares/ui-module.js +0 -39
- package/out/models/index.d.ts +0 -534
- package/out/models/index.js +0 -41
- package/out/static/css/styles.css +0 -57
- package/out/static/js/main.js +0 -130
- package/out/static/js/polyfills/fetch.js +0 -494
- package/out/static/js/polyfills/promise.js +0 -375
- package/out/storage/index.d.ts +0 -22
- package/out/storage/index.js +0 -319
- package/out/util/connection.d.ts +0 -10
- package/out/util/connection.js +0 -213
- package/out/util/cron.d.ts +0 -3
- package/out/util/cron.js +0 -103
- package/out/util/defaults.d.ts +0 -5
- package/out/util/defaults.js +0 -153
- package/out/util/index.d.ts +0 -11
- package/out/util/index.js +0 -105
- package/out/views/install.handlebars +0 -16
- package/out/views/login.handlebars +0 -115
- package/out/views/main.handlebars +0 -471
- package/out/views/oauth.handlebars +0 -4
- package/out/views/partials/head.handlebars +0 -20
- package/out/views/subscription.handlebars +0 -26
package/out/handlers/main.d.ts
DELETED
|
@@ -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;
|
package/out/handlers/main.js
DELETED
|
@@ -1,64 +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 connection_1 = require("../util/connection");
|
|
14
|
-
const defaults_1 = require("../util/defaults");
|
|
15
|
-
function constructOauthUrl(config, integration) {
|
|
16
|
-
var _a, _b, _c;
|
|
17
|
-
const oauth = integration.oauthLogin;
|
|
18
|
-
let url = (oauth === null || oauth === void 0 ? void 0 : oauth.authorizationUrl) || '';
|
|
19
|
-
url += `?${((_a = oauth === null || oauth === void 0 ? void 0 : oauth.fieldsMapping) === null || _a === void 0 ? void 0 : _a.clientId) || 'client_id'}=${oauth === null || oauth === void 0 ? void 0 : oauth.clientId}`;
|
|
20
|
-
url += `&${((_b = oauth === null || oauth === void 0 ? void 0 : oauth.fieldsMapping) === null || _b === void 0 ? void 0 : _b.redirectUri) || 'redirect_uri'}=${config.baseUrl}${(0, defaults_1.getOauthRoute)(integration)}`;
|
|
21
|
-
if (oauth === null || oauth === void 0 ? void 0 : oauth.scope) {
|
|
22
|
-
url += `&${((_c = oauth === null || oauth === void 0 ? void 0 : oauth.fieldsMapping) === null || _c === void 0 ? void 0 : _c.scope) || 'scope'}=${oauth === null || oauth === void 0 ? void 0 : oauth.scope}`;
|
|
23
|
-
}
|
|
24
|
-
if (oauth === null || oauth === void 0 ? void 0 : oauth.extraAutorizationUrlParameters) {
|
|
25
|
-
Object.entries(oauth === null || oauth === void 0 ? void 0 : oauth.extraAutorizationUrlParameters).forEach(([key, value]) => (url += `&${key}=${value}`));
|
|
26
|
-
}
|
|
27
|
-
return url;
|
|
28
|
-
}
|
|
29
|
-
function handle(config, integration) {
|
|
30
|
-
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
var _a;
|
|
32
|
-
const installed = !!req.crowdinApiClient;
|
|
33
|
-
const loggedIn = !!req.integrationCredentials;
|
|
34
|
-
const options = {
|
|
35
|
-
name: config.name,
|
|
36
|
-
};
|
|
37
|
-
let view = 'main';
|
|
38
|
-
if (!installed) {
|
|
39
|
-
view = 'install';
|
|
40
|
-
}
|
|
41
|
-
else if (!loggedIn) {
|
|
42
|
-
view = 'login';
|
|
43
|
-
options.loginFields = (_a = integration.loginForm) === null || _a === void 0 ? void 0 : _a.fields;
|
|
44
|
-
if (integration.oauthLogin) {
|
|
45
|
-
options.oauthUrl = constructOauthUrl(config, integration);
|
|
46
|
-
(0, util_1.log)(`Adding oauth url ${options.oauthUrl}`, config.logger);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else if (integration.getConfiguration) {
|
|
50
|
-
const configurationFields = yield integration.getConfiguration(req.crowdinContext.jwtPayload.context.project_id, req.crowdinApiClient, req.integrationCredentials);
|
|
51
|
-
options.configurationFields = configurationFields;
|
|
52
|
-
options.config = JSON.stringify(req.integrationSettings || {});
|
|
53
|
-
options.reloadOnConfigSave = !!integration.reloadOnConfigSave;
|
|
54
|
-
(0, util_1.log)(`Adding configuration fields ${JSON.stringify(configurationFields, null, 2)}`, config.logger);
|
|
55
|
-
}
|
|
56
|
-
options.infoModal = integration.infoModal;
|
|
57
|
-
options.withCronSync = integration.withCronSync;
|
|
58
|
-
options.withWebhookSync = integration.withWebhookSync;
|
|
59
|
-
options.checkSubscription = !(0, connection_1.isAppFree)(config);
|
|
60
|
-
(0, util_1.log)(`Routing user to ${view} view`, config.logger);
|
|
61
|
-
return res.render(view, options);
|
|
62
|
-
}), config.onError);
|
|
63
|
-
}
|
|
64
|
-
exports.default = handle;
|
package/out/handlers/manifest.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const models_1 = require("../models");
|
|
4
|
-
function handle(config) {
|
|
5
|
-
const modules = {};
|
|
6
|
-
if (config.projectIntegration) {
|
|
7
|
-
modules['project-integrations'] = [
|
|
8
|
-
{
|
|
9
|
-
key: config.identifier + '-int',
|
|
10
|
-
name: config.name,
|
|
11
|
-
description: config.description,
|
|
12
|
-
logo: '/logo/integration/logo.png',
|
|
13
|
-
url: '/',
|
|
14
|
-
},
|
|
15
|
-
];
|
|
16
|
-
}
|
|
17
|
-
if (config.customFileFormat) {
|
|
18
|
-
modules['custom-file-format'] = [
|
|
19
|
-
{
|
|
20
|
-
key: config.identifier + '-ff',
|
|
21
|
-
type: config.customFileFormat.type,
|
|
22
|
-
stringsExport: !!config.customFileFormat.stringsExport,
|
|
23
|
-
multilingual: !!config.customFileFormat.multilingual,
|
|
24
|
-
extensions: config.customFileFormat.extensions,
|
|
25
|
-
signaturePatterns: config.customFileFormat.signaturePatterns,
|
|
26
|
-
url: '/process',
|
|
27
|
-
},
|
|
28
|
-
];
|
|
29
|
-
}
|
|
30
|
-
if (config.customMT) {
|
|
31
|
-
modules['custom-mt'] = [
|
|
32
|
-
{
|
|
33
|
-
key: config.identifier + '-mt',
|
|
34
|
-
name: config.name,
|
|
35
|
-
url: '/translate',
|
|
36
|
-
},
|
|
37
|
-
];
|
|
38
|
-
}
|
|
39
|
-
if (config.organizationMenu) {
|
|
40
|
-
modules['organization-menu'] = [
|
|
41
|
-
{
|
|
42
|
-
key: config.identifier + '-resources',
|
|
43
|
-
name: config.name,
|
|
44
|
-
url: '/resources/' + (config.organizationMenu.fileName || 'index.html'),
|
|
45
|
-
icon: '/logo/resources/logo.png',
|
|
46
|
-
},
|
|
47
|
-
];
|
|
48
|
-
}
|
|
49
|
-
if (config.profileResourcesMenu) {
|
|
50
|
-
modules['profile-resources-menu'] = [
|
|
51
|
-
{
|
|
52
|
-
key: config.identifier + '-profile-resources-menu',
|
|
53
|
-
name: config.name,
|
|
54
|
-
url: '/resources/' + (config.profileResourcesMenu.fileName || 'index.html'),
|
|
55
|
-
icon: '/logo/resources/logo.png',
|
|
56
|
-
},
|
|
57
|
-
];
|
|
58
|
-
}
|
|
59
|
-
if (config.editorRightPanel) {
|
|
60
|
-
modules['editor-right-panel'] = [
|
|
61
|
-
{
|
|
62
|
-
key: config.identifier + '-editor-panels',
|
|
63
|
-
name: config.name,
|
|
64
|
-
url: '/editor-panels/' + (config.editorRightPanel.fileName || 'index.html'),
|
|
65
|
-
modes: config.editorRightPanel.modes,
|
|
66
|
-
},
|
|
67
|
-
];
|
|
68
|
-
}
|
|
69
|
-
if (config.projectMenu) {
|
|
70
|
-
modules['project-menu'] = [
|
|
71
|
-
{
|
|
72
|
-
key: config.identifier + '-project-menu',
|
|
73
|
-
name: config.name,
|
|
74
|
-
url: '/project-menu/' + (config.projectMenu.fileName || 'index.html'),
|
|
75
|
-
},
|
|
76
|
-
];
|
|
77
|
-
}
|
|
78
|
-
if (config.projectTools) {
|
|
79
|
-
modules['project-tools'] = [
|
|
80
|
-
{
|
|
81
|
-
key: config.identifier + '-tools',
|
|
82
|
-
name: config.name,
|
|
83
|
-
description: config.description,
|
|
84
|
-
logo: '/logo/tools/logo.png',
|
|
85
|
-
url: '/tools/' + (config.projectTools.fileName || 'index.html'),
|
|
86
|
-
},
|
|
87
|
-
];
|
|
88
|
-
}
|
|
89
|
-
if (config.projectReports) {
|
|
90
|
-
modules['project-reports'] = [
|
|
91
|
-
{
|
|
92
|
-
key: config.identifier + '-project-reports',
|
|
93
|
-
name: config.name,
|
|
94
|
-
description: config.description,
|
|
95
|
-
logo: '/logo/reports/logo.png',
|
|
96
|
-
url: '/reports/' + (config.projectReports.fileName || 'index.html'),
|
|
97
|
-
},
|
|
98
|
-
];
|
|
99
|
-
}
|
|
100
|
-
return (_req, res) => {
|
|
101
|
-
const manifest = {
|
|
102
|
-
identifier: config.identifier,
|
|
103
|
-
name: config.name,
|
|
104
|
-
logo: '/logo.png',
|
|
105
|
-
baseUrl: config.baseUrl,
|
|
106
|
-
authentication: {
|
|
107
|
-
type: 'authorization_code',
|
|
108
|
-
clientId: config.clientId,
|
|
109
|
-
},
|
|
110
|
-
events: {
|
|
111
|
-
installed: '/installed',
|
|
112
|
-
uninstall: '/uninstall',
|
|
113
|
-
},
|
|
114
|
-
scopes: config.scopes ? config.scopes : [models_1.Scope.PROJECTS],
|
|
115
|
-
modules,
|
|
116
|
-
};
|
|
117
|
-
res.send(manifest);
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
exports.default = handle;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/// <reference types="qs" />
|
|
2
|
-
import { Request, Response } from 'express';
|
|
3
|
-
import { Config, IntegrationLogic } from '../models';
|
|
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;
|
|
@@ -1,69 +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 util_1 = require("../util");
|
|
17
|
-
const defaults_1 = require("../util/defaults");
|
|
18
|
-
function handle(config, integration) {
|
|
19
|
-
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
21
|
-
const message = {
|
|
22
|
-
uid: 'oauth_popup',
|
|
23
|
-
};
|
|
24
|
-
const code = req.query[((_b = (_a = integration.oauthLogin) === null || _a === void 0 ? void 0 : _a.fieldsMapping) === null || _b === void 0 ? void 0 : _b.code) || 'code'];
|
|
25
|
-
(0, util_1.log)(`Recieved request from OAuth login callback. Code ${code}`, config.logger);
|
|
26
|
-
try {
|
|
27
|
-
const oauthLogin = integration.oauthLogin;
|
|
28
|
-
let credentials;
|
|
29
|
-
if (oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.performGetTokenRequest) {
|
|
30
|
-
(0, util_1.log)('Performing custom get bearer token request', config.logger);
|
|
31
|
-
credentials = yield oauthLogin.performGetTokenRequest(code);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
const request = {};
|
|
35
|
-
const oauthLogin = integration.oauthLogin;
|
|
36
|
-
request[((_c = oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.fieldsMapping) === null || _c === void 0 ? void 0 : _c.code) || 'code'] = code;
|
|
37
|
-
request[((_d = oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.fieldsMapping) === null || _d === void 0 ? void 0 : _d.clientId) || 'client_id'] = oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.clientId;
|
|
38
|
-
request[((_e = oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.fieldsMapping) === null || _e === void 0 ? void 0 : _e.clientSecret) || 'client_secret'] = oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.clientSecret;
|
|
39
|
-
request[((_f = oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.fieldsMapping) === null || _f === void 0 ? void 0 : _f.redirectUri) || 'redirect_uri'] = `${config.baseUrl}${(0, defaults_1.getOauthRoute)(integration)}`;
|
|
40
|
-
if (oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.extraAccessTokenParameters) {
|
|
41
|
-
Object.entries(oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.extraAccessTokenParameters).forEach(([key, value]) => (request[key] = value));
|
|
42
|
-
}
|
|
43
|
-
credentials = (yield axios_1.default.post(((_g = integration.oauthLogin) === null || _g === void 0 ? void 0 : _g.accessTokenUrl) || '', request, {
|
|
44
|
-
headers: { Accept: 'application/json' },
|
|
45
|
-
})).data;
|
|
46
|
-
}
|
|
47
|
-
const oauthCredentials = {};
|
|
48
|
-
oauthCredentials.accessToken = credentials[((_h = oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.fieldsMapping) === null || _h === void 0 ? void 0 : _h.accessToken) || 'access_token'];
|
|
49
|
-
if (oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.refresh) {
|
|
50
|
-
oauthCredentials.refreshToken = credentials[((_j = oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.fieldsMapping) === null || _j === void 0 ? void 0 : _j.refreshToken) || 'refresh_token'];
|
|
51
|
-
oauthCredentials.expireIn =
|
|
52
|
-
Number(credentials[((_k = oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.fieldsMapping) === null || _k === void 0 ? void 0 : _k.expiresIn) || 'expires_in']) + Date.now() / 1000;
|
|
53
|
-
}
|
|
54
|
-
message.data = oauthCredentials;
|
|
55
|
-
return res.render('oauth', { message: JSON.stringify(message) });
|
|
56
|
-
}
|
|
57
|
-
catch (e) {
|
|
58
|
-
if (config.onError) {
|
|
59
|
-
config.onError(e);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
console.error(e);
|
|
63
|
-
}
|
|
64
|
-
message.data = { error: (0, util_1.getMessage)(e) };
|
|
65
|
-
return res.render('oauth', { message: JSON.stringify(message) });
|
|
66
|
-
}
|
|
67
|
-
}), config.onError);
|
|
68
|
-
}
|
|
69
|
-
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,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 storage_1 = require("../storage");
|
|
13
|
-
const util_1 = require("../util");
|
|
14
|
-
function handle(config) {
|
|
15
|
-
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
(0, util_1.log)(`Saving settings ${JSON.stringify(req.body.config, null, 2)}`, config.logger);
|
|
17
|
-
yield (0, storage_1.updateIntegrationConfig)(req.crowdinContext.clientId, JSON.stringify(req.body.config));
|
|
18
|
-
res.status(204).end();
|
|
19
|
-
}), config.onError);
|
|
20
|
-
}
|
|
21
|
-
exports.default = handle;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const models_1 = require("../models");
|
|
4
|
-
function handle(config) {
|
|
5
|
-
return (req, res) => {
|
|
6
|
-
var _a;
|
|
7
|
-
const subscriptionInfo = req.subscriptionInfo;
|
|
8
|
-
let showInfo = (subscriptionInfo === null || subscriptionInfo === void 0 ? void 0 : subscriptionInfo.type) === models_1.SubscriptionInfoType.TRIAL;
|
|
9
|
-
if (showInfo && ((_a = config.pricing) === null || _a === void 0 ? void 0 : _a.infoDisplayDaysThreshold)) {
|
|
10
|
-
showInfo = config.pricing.infoDisplayDaysThreshold >= ((subscriptionInfo === null || subscriptionInfo === void 0 ? void 0 : subscriptionInfo.daysLeft) || 0);
|
|
11
|
-
}
|
|
12
|
-
res.send(Object.assign(Object.assign({}, (subscriptionInfo || {})), { showInfo }));
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
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,29 +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) {
|
|
15
|
-
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
const { files, type, provider } = req.body;
|
|
17
|
-
const existingSettings = yield (0, storage_1.getSyncSettings)(req.crowdinContext.clientId, req.crowdinContext.crowdinId, type, provider);
|
|
18
|
-
if (existingSettings) {
|
|
19
|
-
(0, util_1.log)(`Updating sync settings for type ${type} and provider ${provider} ${JSON.stringify(files, null, 2)}`, config.logger);
|
|
20
|
-
yield (0, storage_1.updateSyncSettings)(JSON.stringify(files), req.crowdinContext.clientId, req.crowdinContext.crowdinId, type, provider);
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
(0, util_1.log)(`Saving sync settings for type ${type} and provider ${provider} ${JSON.stringify(files, null, 2)}`, config.logger);
|
|
24
|
-
yield (0, storage_1.saveSyncSettings)(JSON.stringify(files), req.crowdinContext.clientId, req.crowdinContext.crowdinId, type, provider);
|
|
25
|
-
}
|
|
26
|
-
res.status(204).end();
|
|
27
|
-
}), config.onError);
|
|
28
|
-
}
|
|
29
|
-
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,27 +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) {
|
|
15
|
-
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
let files = {};
|
|
17
|
-
const provider = req.params.provider;
|
|
18
|
-
(0, util_1.log)(`Loading sync settings for provider ${provider}`, config.logger);
|
|
19
|
-
const syncSettings = yield (0, storage_1.getSyncSettingsByProvider)(req.crowdinContext.clientId, provider);
|
|
20
|
-
if (syncSettings) {
|
|
21
|
-
files = JSON.parse(syncSettings.files) || [];
|
|
22
|
-
}
|
|
23
|
-
(0, util_1.log)(`Returning sync settings ${JSON.stringify(files, null, 2)}`, config.logger);
|
|
24
|
-
res.send(files);
|
|
25
|
-
}), config.onError);
|
|
26
|
-
}
|
|
27
|
-
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,27 +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) {
|
|
15
|
-
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
const event = req.body;
|
|
17
|
-
(0, util_1.log)(`Recieved uninstall request ${JSON.stringify(event, null, 2)}`, config.logger);
|
|
18
|
-
const organization = (event.domain || event.organizationId).toString();
|
|
19
|
-
yield (0, storage_1.deleteCrowdinCredentials)(organization);
|
|
20
|
-
if (config.onUninstall) {
|
|
21
|
-
yield config.onUninstall(organization);
|
|
22
|
-
}
|
|
23
|
-
(0, util_1.log)('App has been uninstalled', config.logger);
|
|
24
|
-
res.status(204).end();
|
|
25
|
-
}), config.onError);
|
|
26
|
-
}
|
|
27
|
-
exports.default = handle;
|
package/out/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Express } from 'express';
|
|
2
|
-
import { Config, CrowdinAppUtilities } from './models';
|
|
3
|
-
export { Scope } from './models';
|
|
4
|
-
export declare function addCrowdinEndpoints(app: Express, config: Config): CrowdinAppUtilities;
|
|
5
|
-
export declare function createApp(config: Config): void;
|
package/out/index.js
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
-
};
|
|
33
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
exports.createApp = exports.addCrowdinEndpoints = exports.Scope = void 0;
|
|
35
|
-
const express_1 = __importDefault(require("express"));
|
|
36
|
-
const express_handlebars_1 = __importDefault(require("express-handlebars"));
|
|
37
|
-
const cron = __importStar(require("node-cron"));
|
|
38
|
-
const path_1 = require("path");
|
|
39
|
-
const crowdin_file_progress_1 = __importDefault(require("./handlers/crowdin-file-progress"));
|
|
40
|
-
const crowdin_files_1 = __importDefault(require("./handlers/crowdin-files"));
|
|
41
|
-
const crowdin_project_1 = __importDefault(require("./handlers/crowdin-project"));
|
|
42
|
-
const crowdin_update_1 = __importDefault(require("./handlers/crowdin-update"));
|
|
43
|
-
const download_1 = __importDefault(require("./handlers/custom-file-format/download"));
|
|
44
|
-
const process_1 = __importDefault(require("./handlers/custom-file-format/process"));
|
|
45
|
-
const translate_1 = __importDefault(require("./handlers/custom-mt/translate"));
|
|
46
|
-
const install_1 = __importDefault(require("./handlers/install"));
|
|
47
|
-
const integration_data_1 = __importDefault(require("./handlers/integration-data"));
|
|
48
|
-
const integration_login_1 = __importDefault(require("./handlers/integration-login"));
|
|
49
|
-
const integration_logout_1 = __importDefault(require("./handlers/integration-logout"));
|
|
50
|
-
const integration_update_1 = __importDefault(require("./handlers/integration-update"));
|
|
51
|
-
const main_1 = __importDefault(require("./handlers/main"));
|
|
52
|
-
const manifest_1 = __importDefault(require("./handlers/manifest"));
|
|
53
|
-
const oauth_login_1 = __importDefault(require("./handlers/oauth-login"));
|
|
54
|
-
const settings_save_1 = __importDefault(require("./handlers/settings-save"));
|
|
55
|
-
const subscription_info_1 = __importDefault(require("./handlers/subscription-info"));
|
|
56
|
-
const sync_settings_1 = __importDefault(require("./handlers/sync-settings"));
|
|
57
|
-
const sync_settings_save_1 = __importDefault(require("./handlers/sync-settings-save"));
|
|
58
|
-
const uninstall_1 = __importDefault(require("./handlers/uninstall"));
|
|
59
|
-
const crowdin_client_1 = __importStar(require("./middlewares/crowdin-client"));
|
|
60
|
-
const integration_credentials_1 = __importDefault(require("./middlewares/integration-credentials"));
|
|
61
|
-
const json_response_1 = __importDefault(require("./middlewares/json-response"));
|
|
62
|
-
const ui_module_1 = __importDefault(require("./middlewares/ui-module"));
|
|
63
|
-
const storage = __importStar(require("./storage"));
|
|
64
|
-
const cron_1 = require("./util/cron");
|
|
65
|
-
const defaults_1 = require("./util/defaults");
|
|
66
|
-
var models_1 = require("./models");
|
|
67
|
-
Object.defineProperty(exports, "Scope", { enumerable: true, get: function () { return models_1.Scope; } });
|
|
68
|
-
function addCrowdinEndpoints(app, config) {
|
|
69
|
-
storage.connect(config.dbFolder);
|
|
70
|
-
app.use(express_1.default.json({ limit: '50mb' }));
|
|
71
|
-
app.use('/assets', express_1.default.static((0, path_1.join)(__dirname, 'static')));
|
|
72
|
-
app.set('views', (0, path_1.join)(__dirname, 'views'));
|
|
73
|
-
app.engine('handlebars', (0, express_handlebars_1.default)({
|
|
74
|
-
layoutsDir: '',
|
|
75
|
-
defaultLayout: '',
|
|
76
|
-
helpers: {
|
|
77
|
-
ifeq: function (a, b, options) {
|
|
78
|
-
if (a === b) {
|
|
79
|
-
return options.fn(this);
|
|
80
|
-
}
|
|
81
|
-
return options.inverse(this);
|
|
82
|
-
},
|
|
83
|
-
checkLength: function (a, b, options) {
|
|
84
|
-
if (a.length > b) {
|
|
85
|
-
return options.fn(this);
|
|
86
|
-
}
|
|
87
|
-
return options.inverse(this);
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
}));
|
|
91
|
-
app.set('view engine', 'handlebars');
|
|
92
|
-
app.get('/logo.png', (req, res) => res.sendFile(config.imagePath || (0, path_1.join)(__dirname, 'logo.png')));
|
|
93
|
-
app.post('/installed', (0, install_1.default)(config));
|
|
94
|
-
app.post('/uninstall', (0, uninstall_1.default)(config));
|
|
95
|
-
app.get('/manifest.json', json_response_1.default, (0, manifest_1.default)(config));
|
|
96
|
-
const integrationLogic = config.projectIntegration;
|
|
97
|
-
if (integrationLogic) {
|
|
98
|
-
(0, defaults_1.applyDefaults)(config, integrationLogic);
|
|
99
|
-
app.get('/logo/integration/logo.png', (req, res) => res.sendFile(integrationLogic.imagePath || config.imagePath || (0, path_1.join)(__dirname, 'logo.png')));
|
|
100
|
-
app.get('/', (0, crowdin_client_1.default)(config, true, false), (0, integration_credentials_1.default)(config, integrationLogic, true), (0, main_1.default)(config, integrationLogic));
|
|
101
|
-
app.get('/api/subscription-info', json_response_1.default, (0, crowdin_client_1.default)(config), (0, subscription_info_1.default)(config));
|
|
102
|
-
app.post('/api/settings', (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, settings_save_1.default)(config));
|
|
103
|
-
app.post('/api/login', (0, crowdin_client_1.default)(config, false, false), (0, integration_login_1.default)(config, integrationLogic));
|
|
104
|
-
app.post('/api/logout', (0, crowdin_client_1.default)(config, false, false), (0, integration_logout_1.default)(config));
|
|
105
|
-
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));
|
|
106
|
-
app.get('/api/crowdin/project', json_response_1.default, (0, crowdin_client_1.default)(config), (0, crowdin_project_1.default)(config));
|
|
107
|
-
app.get('/api/crowdin/file-progress/:fileId', (0, crowdin_client_1.default)(config), (0, crowdin_file_progress_1.default)(config));
|
|
108
|
-
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)(config, integrationLogic));
|
|
109
|
-
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));
|
|
110
|
-
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));
|
|
111
|
-
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)(config));
|
|
112
|
-
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));
|
|
113
|
-
if (integrationLogic.oauthLogin) {
|
|
114
|
-
app.get((0, defaults_1.getOauthRoute)(integrationLogic), (0, oauth_login_1.default)(config, integrationLogic));
|
|
115
|
-
}
|
|
116
|
-
if (integrationLogic.cronJobs) {
|
|
117
|
-
integrationLogic.cronJobs.forEach(job => {
|
|
118
|
-
cron.schedule(job.expression, () => (0, cron_1.runJob)(config, integrationLogic, job).catch(console.error));
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
if (integrationLogic.withCronSync) {
|
|
122
|
-
cron.schedule('0 * * * *', () => (0, cron_1.filesCron)(config, integrationLogic, '1').catch(console.error));
|
|
123
|
-
cron.schedule('0 */3 * * *', () => (0, cron_1.filesCron)(config, integrationLogic, '3').catch(console.error));
|
|
124
|
-
cron.schedule('0 */6 * * *', () => (0, cron_1.filesCron)(config, integrationLogic, '6').catch(console.error));
|
|
125
|
-
cron.schedule('0 */12 * * *', () => (0, cron_1.filesCron)(config, integrationLogic, '12').catch(console.error));
|
|
126
|
-
cron.schedule('0 0 * * *', () => (0, cron_1.filesCron)(config, integrationLogic, '24').catch(console.error));
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
if (config.customFileFormat) {
|
|
130
|
-
app.post('/process', (0, crowdin_client_1.default)(config), (0, process_1.default)(config, config.baseUrl, config.customFileFormat.filesFolder || config.dbFolder, config.customFileFormat));
|
|
131
|
-
app.get('/file/download', (0, download_1.default)(config, config.customFileFormat.filesFolder || config.dbFolder));
|
|
132
|
-
}
|
|
133
|
-
if (config.customMT) {
|
|
134
|
-
app.post('/translate', (0, crowdin_client_1.default)(config), (0, translate_1.default)(config, config.customMT));
|
|
135
|
-
}
|
|
136
|
-
if (config.profileResourcesMenu) {
|
|
137
|
-
app.get('/logo/resources/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.profileResourcesMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath || (0, path_1.join)(__dirname, 'logo.png')); });
|
|
138
|
-
app.use('/resources', (0, ui_module_1.default)(config), express_1.default.static(config.profileResourcesMenu.uiPath));
|
|
139
|
-
}
|
|
140
|
-
if (config.organizationMenu) {
|
|
141
|
-
app.get('/logo/resources/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.organizationMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath || (0, path_1.join)(__dirname, 'logo.png')); });
|
|
142
|
-
app.use('/resources', (0, ui_module_1.default)(config), express_1.default.static(config.organizationMenu.uiPath));
|
|
143
|
-
}
|
|
144
|
-
if (config.editorRightPanel) {
|
|
145
|
-
app.use('/editor-panels', (0, ui_module_1.default)(config), express_1.default.static(config.editorRightPanel.uiPath));
|
|
146
|
-
}
|
|
147
|
-
if (config.projectMenu) {
|
|
148
|
-
app.use('/project-menu', (0, ui_module_1.default)(config), express_1.default.static(config.projectMenu.uiPath));
|
|
149
|
-
}
|
|
150
|
-
if (config.projectTools) {
|
|
151
|
-
app.get('/logo/tools/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.projectTools) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath || (0, path_1.join)(__dirname, 'logo.png')); });
|
|
152
|
-
app.use('/tools', (0, ui_module_1.default)(config), express_1.default.static(config.projectTools.uiPath));
|
|
153
|
-
}
|
|
154
|
-
if (config.projectReports) {
|
|
155
|
-
app.get('/logo/reports/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.projectReports) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath || (0, path_1.join)(__dirname, 'logo.png')); });
|
|
156
|
-
app.use('/reports', (0, ui_module_1.default)(config), express_1.default.static(config.projectReports.uiPath));
|
|
157
|
-
}
|
|
158
|
-
return {
|
|
159
|
-
getMetadata: storage.getMetadata,
|
|
160
|
-
saveMetadata: (id, metadata) => __awaiter(this, void 0, void 0, function* () {
|
|
161
|
-
const existing = yield storage.getMetadata(id);
|
|
162
|
-
if (existing) {
|
|
163
|
-
yield storage.updateMetadata(id, metadata);
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
yield storage.saveMetadata(id, metadata);
|
|
167
|
-
}
|
|
168
|
-
}),
|
|
169
|
-
deleteMetadata: storage.deleteMetadata,
|
|
170
|
-
getUserSettings: (clientId) => __awaiter(this, void 0, void 0, function* () {
|
|
171
|
-
const integrationCredentials = yield storage.getIntegrationCredentials(clientId);
|
|
172
|
-
if (integrationCredentials === null || integrationCredentials === void 0 ? void 0 : integrationCredentials.config) {
|
|
173
|
-
return JSON.parse(integrationCredentials.config);
|
|
174
|
-
}
|
|
175
|
-
}),
|
|
176
|
-
establishCrowdinConnection: jwtToken => (0, crowdin_client_1.prepareCrowdinRequest)(jwtToken, config),
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
exports.addCrowdinEndpoints = addCrowdinEndpoints;
|
|
180
|
-
function createApp(config) {
|
|
181
|
-
const app = (0, express_1.default)();
|
|
182
|
-
addCrowdinEndpoints(app, config);
|
|
183
|
-
/* eslint no-console: "off" */
|
|
184
|
-
app.listen(config.port || 3000, () => console.log(`App started on port ${config.port || 3000}`));
|
|
185
|
-
}
|
|
186
|
-
exports.createApp = createApp;
|
package/out/logo.png
DELETED
|
Binary file
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/// <reference types="qs" />
|
|
2
|
-
import Crowdin from '@crowdin/crowdin-api-client';
|
|
3
|
-
import { Response } from 'express';
|
|
4
|
-
import { Config, CrowdinContextInfo, SubscriptionInfo } from '../models';
|
|
5
|
-
export declare function prepareCrowdinRequest(jwtToken: string, config: Config, optional?: boolean, checkSubscriptionExpiration?: boolean): Promise<{
|
|
6
|
-
context: CrowdinContextInfo;
|
|
7
|
-
client?: Crowdin;
|
|
8
|
-
subscriptionInfo?: SubscriptionInfo;
|
|
9
|
-
}>;
|
|
10
|
-
export default function handle(config: Config, optional?: boolean, checkSubscriptionExpiration?: boolean): (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;
|