@crowdin/app-project-module 0.40.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/handlers/integration/settings-save.js +8 -1
- package/out/handlers/uninstall.js +4 -2
- package/out/index.js +1 -1
- package/out/middlewares/integration-credentials.js +3 -2
- package/out/models/index.d.ts +6 -1
- package/out/static/js/form.js +13 -13
- package/out/storage/index.d.ts +5 -2
- package/out/storage/mysql.d.ts +5 -2
- package/out/storage/mysql.js +49 -10
- package/out/storage/postgre.d.ts +5 -2
- package/out/storage/postgre.js +46 -9
- package/out/storage/sqlite.d.ts +8 -3
- package/out/storage/sqlite.js +64 -14
- package/out/util/cron.js +6 -3
- package/out/util/webhooks.js +3 -2
- package/package.json +10 -10
|
@@ -18,8 +18,15 @@ 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;
|
|
21
|
+
const clientId = req.crowdinContext.clientId;
|
|
21
22
|
req.logInfo(`Saving settings ${JSON.stringify(appSettings, null, 2)}`);
|
|
22
|
-
yield (0, storage_1.getStorage)().
|
|
23
|
+
const integrationConfig = yield (0, storage_1.getStorage)().getIntegrationConfig(clientId);
|
|
24
|
+
if (!integrationConfig) {
|
|
25
|
+
yield (0, storage_1.getStorage)().saveIntegrationConfig(clientId, req.crowdinContext.crowdinId, JSON.stringify(appSettings));
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
yield (0, storage_1.getStorage)().updateIntegrationConfig(clientId, JSON.stringify(appSettings));
|
|
29
|
+
}
|
|
23
30
|
if (integration.webhooks) {
|
|
24
31
|
yield (0, webhooks_1.registerWebhooks)(config, integration, req.crowdinApiClient, req.crowdinContext, req.integrationCredentials, appSettings);
|
|
25
32
|
}
|
|
@@ -24,10 +24,12 @@ function handle(config) {
|
|
|
24
24
|
let allCredentials = [];
|
|
25
25
|
if (projectIntegration) {
|
|
26
26
|
const loadedCredentials = yield (0, storage_1.getStorage)().getAllIntegrationCredentials(organization);
|
|
27
|
+
const allIntegrationConfigs = yield (0, storage_1.getStorage)().getAllIntegrationConfigs(organization);
|
|
27
28
|
allCredentials = yield Promise.all(loadedCredentials.map((creds) => __awaiter(this, void 0, void 0, function* () {
|
|
28
29
|
let settings;
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
const integrationConfig = allIntegrationConfigs.find(({ integrationId }) => integrationId === creds.id);
|
|
31
|
+
if (integrationConfig) {
|
|
32
|
+
settings = JSON.parse(integrationConfig.config);
|
|
31
33
|
}
|
|
32
34
|
const credentials = yield (0, connection_1.prepareIntegrationCredentials)(config, projectIntegration, creds);
|
|
33
35
|
return { settings, credentials };
|
package/out/index.js
CHANGED
|
@@ -108,7 +108,7 @@ exports.metadataStore = {
|
|
|
108
108
|
return storage.getStorage().deleteMetadata(id);
|
|
109
109
|
},
|
|
110
110
|
getUserSettings: (clientId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
111
|
-
const integrationCredentials = yield storage.getStorage().
|
|
111
|
+
const integrationCredentials = yield storage.getStorage().getIntegrationConfig(clientId);
|
|
112
112
|
if (integrationCredentials === null || integrationCredentials === void 0 ? void 0 : integrationCredentials.config) {
|
|
113
113
|
return JSON.parse(integrationCredentials.config);
|
|
114
114
|
}
|
|
@@ -17,14 +17,15 @@ function handle(config, integration, optional = false) {
|
|
|
17
17
|
const clientId = req.crowdinContext.clientId;
|
|
18
18
|
req.logInfo(`Loading integration credentials for client ${clientId}`);
|
|
19
19
|
const integrationCredentials = yield (0, storage_1.getStorage)().getIntegrationCredentials(clientId);
|
|
20
|
+
const integrationConfig = yield (0, storage_1.getStorage)().getIntegrationConfig(clientId);
|
|
20
21
|
if (!integrationCredentials) {
|
|
21
22
|
if (optional) {
|
|
22
23
|
return next();
|
|
23
24
|
}
|
|
24
25
|
return res.status(403).send({ error: 'Access denied' });
|
|
25
26
|
}
|
|
26
|
-
if (
|
|
27
|
-
req.integrationSettings = JSON.parse(
|
|
27
|
+
if (integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.config) {
|
|
28
|
+
req.integrationSettings = JSON.parse(integrationConfig.config);
|
|
28
29
|
}
|
|
29
30
|
try {
|
|
30
31
|
req.integrationCredentials = yield (0, connection_1.prepareIntegrationCredentials)(config, integration, integrationCredentials);
|
package/out/models/index.d.ts
CHANGED
|
@@ -577,7 +577,12 @@ export interface IntegrationCredentials {
|
|
|
577
577
|
id: string;
|
|
578
578
|
credentials: any;
|
|
579
579
|
crowdinId: string;
|
|
580
|
-
|
|
580
|
+
}
|
|
581
|
+
export interface IntegrationConfig {
|
|
582
|
+
id: number;
|
|
583
|
+
integrationId: string;
|
|
584
|
+
crowdinId: string;
|
|
585
|
+
config: any;
|
|
581
586
|
}
|
|
582
587
|
export interface IntegrationFile {
|
|
583
588
|
id: string;
|