@crowdin/app-project-module 0.44.0 → 0.45.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/index.d.ts +3 -3
- package/out/index.js +52 -59
- package/out/middlewares/crowdin-client.d.ts +1 -1
- package/out/middlewares/crowdin-client.js +3 -2
- package/out/middlewares/integration-credentials.d.ts +2 -2
- package/out/middlewares/render-ui-module.d.ts +2 -2
- package/out/middlewares/ui-module.d.ts +2 -2
- package/out/middlewares/ui-module.js +3 -3
- package/out/{util → modules}/api/api.d.ts +2 -1
- package/out/{util → modules}/api/api.js +22 -22
- package/out/modules/api/index.d.ts +6 -0
- package/out/modules/api/index.js +14 -0
- package/out/modules/api/types.d.ts +20 -0
- package/out/modules/api/types.js +11 -0
- package/out/modules/context-menu/index.d.ts +1 -1
- package/out/modules/context-menu/index.js +2 -2
- package/out/modules/context-menu/types.d.ts +27 -0
- package/out/modules/context-menu/types.js +18 -0
- package/out/modules/custom-mt/handlers/translate.d.ts +1 -1
- package/out/modules/custom-mt/index.d.ts +1 -1
- package/out/modules/custom-mt/types.d.ts +1 -1
- package/out/modules/custom-spell-check/handlers/get-languages-list.d.ts +1 -1
- package/out/modules/custom-spell-check/handlers/spell-check.d.ts +1 -1
- package/out/modules/custom-spell-check/index.d.ts +1 -1
- package/out/modules/custom-spell-check/index.js +2 -2
- package/out/modules/custom-spell-check/types.d.ts +1 -1
- package/out/modules/editor-right-panel/index.d.ts +1 -1
- package/out/modules/editor-right-panel/index.js +2 -2
- package/out/modules/editor-right-panel/types.d.ts +1 -1
- package/out/modules/editor-themes/index.d.ts +1 -1
- package/out/modules/editor-themes/types.d.ts +17 -0
- package/out/modules/editor-themes/types.js +2 -0
- package/out/modules/file-processing/handlers/custom-file-format.d.ts +1 -1
- package/out/modules/file-processing/handlers/custom-file-format.js +1 -1
- package/out/modules/file-processing/handlers/file-download.d.ts +2 -2
- package/out/modules/file-processing/handlers/pre-post-process.d.ts +1 -1
- package/out/modules/file-processing/handlers/pre-post-process.js +1 -1
- package/out/modules/file-processing/index.d.ts +1 -1
- package/out/modules/file-processing/index.js +1 -1
- package/out/modules/file-processing/types.d.ts +1 -1
- package/out/modules/file-processing/util/defaults.d.ts +3 -0
- package/out/modules/file-processing/util/defaults.js +30 -0
- package/out/modules/file-processing/util/files.d.ts +6 -0
- package/out/modules/file-processing/util/files.js +47 -0
- package/out/modules/form-data-display.d.ts +1 -1
- package/out/modules/form-data-save.d.ts +1 -1
- package/out/modules/install.d.ts +2 -2
- package/out/modules/install.js +3 -3
- package/out/modules/integration/handlers/crowdin-file-progress.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-files.d.ts +2 -2
- package/out/modules/integration/handlers/crowdin-files.js +1 -1
- package/out/modules/integration/handlers/crowdin-project.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-update.d.ts +2 -2
- package/out/modules/integration/handlers/crowdin-update.js +7 -7
- package/out/modules/integration/handlers/crowdin-webhook.d.ts +2 -2
- package/out/modules/integration/handlers/crowdin-webhook.js +16 -5
- package/out/modules/integration/handlers/integration-data.d.ts +1 -1
- package/out/modules/integration/handlers/integration-data.js +2 -2
- package/out/modules/integration/handlers/integration-login.d.ts +1 -1
- package/out/modules/integration/handlers/integration-logout.d.ts +2 -2
- package/out/modules/integration/handlers/integration-logout.js +11 -4
- package/out/modules/integration/handlers/integration-update.d.ts +2 -2
- package/out/modules/integration/handlers/integration-update.js +7 -6
- package/out/modules/integration/handlers/integration-webhook.d.ts +2 -2
- package/out/modules/integration/handlers/integration-webhook.js +7 -2
- package/out/modules/integration/handlers/job-cancel.d.ts +1 -1
- package/out/modules/integration/handlers/job-cancel.js +2 -2
- package/out/modules/integration/handlers/job-info.d.ts +1 -1
- package/out/modules/integration/handlers/job-info.js +2 -2
- package/out/modules/integration/handlers/main.d.ts +2 -2
- package/out/modules/integration/handlers/main.js +3 -3
- package/out/modules/integration/handlers/oauth-login.d.ts +2 -2
- package/out/modules/integration/handlers/oauth-login.js +1 -1
- package/out/modules/integration/handlers/oauth-url.d.ts +1 -1
- package/out/modules/integration/handlers/oauth-url.js +1 -1
- package/out/modules/integration/handlers/settings-save.d.ts +2 -2
- package/out/modules/integration/handlers/settings-save.js +25 -8
- package/out/modules/integration/handlers/settings.d.ts +1 -1
- package/out/modules/integration/handlers/subscription-info.d.ts +1 -1
- package/out/modules/integration/handlers/subscription-info.js +2 -2
- package/out/modules/integration/handlers/sync-settings-save.d.ts +2 -2
- package/out/modules/integration/handlers/sync-settings-save.js +15 -7
- package/out/modules/integration/handlers/sync-settings.d.ts +1 -1
- package/out/modules/integration/handlers/user-errors.d.ts +1 -1
- package/out/modules/integration/index.d.ts +1 -1
- package/out/modules/integration/index.js +15 -10
- package/out/modules/integration/types.d.ts +2 -13
- package/out/modules/integration/util/cron.d.ts +27 -0
- package/out/{util → modules/integration/util}/cron.js +92 -23
- package/out/{util → modules/integration/util}/defaults.d.ts +2 -6
- package/out/{util → modules/integration/util}/defaults.js +1 -46
- package/out/modules/integration/util/files.d.ts +5 -0
- package/out/{util → modules/integration/util}/files.js +9 -40
- package/out/{util → modules/integration/util}/job.d.ts +1 -1
- package/out/{util → modules/integration/util}/job.js +11 -11
- package/out/{util/file-snapshot.d.ts → modules/integration/util/snapshot.d.ts} +2 -4
- package/out/{util/file-snapshot.js → modules/integration/util/snapshot.js} +4 -63
- package/out/{models/job.d.ts → modules/integration/util/types.d.ts} +14 -0
- package/out/modules/integration/util/webhooks.d.ts +48 -0
- package/out/{util → modules/integration/util}/webhooks.js +92 -46
- package/out/modules/manifest.d.ts +1 -1
- package/out/modules/manifest.js +27 -66
- package/out/modules/modal/index.d.ts +1 -1
- package/out/modules/modal/index.js +2 -2
- package/out/modules/organization-menu/index.d.ts +1 -1
- package/out/modules/organization-menu/index.js +1 -2
- package/out/modules/profile-resources-menu/index.d.ts +1 -1
- package/out/modules/profile-resources-menu/index.js +1 -2
- package/out/modules/project-menu/index.d.ts +1 -1
- package/out/modules/project-menu/index.js +2 -2
- package/out/modules/project-menu-crowdsource/index.d.ts +1 -1
- package/out/modules/project-menu-crowdsource/index.js +2 -2
- package/out/modules/project-reports/index.d.ts +1 -1
- package/out/modules/project-reports/index.js +1 -2
- package/out/modules/project-tools/index.d.ts +1 -1
- package/out/modules/project-tools/index.js +1 -2
- package/out/modules/subscription-paid.d.ts +1 -1
- package/out/modules/subscription-paid.js +2 -2
- package/out/modules/uninstall.d.ts +2 -2
- package/out/modules/uninstall.js +6 -2
- package/out/storage/index.d.ts +3 -2
- package/out/storage/mysql.d.ts +3 -2
- package/out/storage/mysql.js +3 -3
- package/out/storage/postgre.d.ts +3 -2
- package/out/storage/postgre.js +3 -3
- package/out/storage/sqlite.d.ts +3 -2
- package/out/storage/sqlite.js +3 -3
- package/out/storage/types.d.ts +9 -0
- package/out/storage/types.js +2 -0
- package/out/{models/index.d.ts → types.d.ts} +16 -84
- package/out/{models/index.js → types.js} +1 -24
- package/out/util/connection.d.ts +1 -9
- package/out/util/connection.js +54 -150
- package/out/util/handlebars.d.ts +1 -0
- package/out/util/handlebars.js +34 -0
- package/out/util/index.d.ts +2 -3
- package/out/util/index.js +6 -6
- package/out/util/logger.d.ts +1 -1
- package/out/util/subscription.d.ts +9 -0
- package/out/util/subscription.js +111 -0
- package/package.json +1 -1
- package/out/util/cron.d.ts +0 -8
- package/out/util/files.d.ts +0 -10
- package/out/util/webhooks.d.ts +0 -29
- /package/out/{util → modules}/api/base.d.ts +0 -0
- /package/out/{util → modules}/api/base.js +0 -0
- /package/out/{util → modules}/api/components.d.ts +0 -0
- /package/out/{util → modules}/api/components.js +0 -0
- /package/out/{models/job.js → modules/integration/util/types.js} +0 -0
|
@@ -35,15 +35,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.listenQueueMessage = exports.updateCrowdinFromWebhookRequest = exports.prepareWebhookData = exports.unregisterAllCrowdinWebhooks = exports.
|
|
38
|
+
exports.listenQueueMessage = exports.updateCrowdinFromWebhookRequest = exports.prepareWebhookData = exports.unregisterAllCrowdinWebhooks = exports.unregisterWebhooks = exports.registerWebhooks = exports.HookEvents = void 0;
|
|
39
39
|
const crowdinAppFunctions = __importStar(require("@crowdin/crowdin-apps-functions"));
|
|
40
40
|
const amqplib_1 = __importDefault(require("amqplib"));
|
|
41
|
-
const
|
|
42
|
-
const
|
|
41
|
+
const types_1 = require("../types");
|
|
42
|
+
const storage_1 = require("../../../storage");
|
|
43
|
+
const connection_1 = require("../../../util/connection");
|
|
43
44
|
const defaults_1 = require("./defaults");
|
|
44
|
-
const index_1 = require("
|
|
45
|
-
const logger_1 = require("
|
|
46
|
-
const types_1 = require("../modules/integration/types");
|
|
45
|
+
const index_1 = require("../../../util/index");
|
|
46
|
+
const logger_1 = require("../../../util/logger");
|
|
47
47
|
const prefetchCount = 20;
|
|
48
48
|
const forceProcessDelay = 5000;
|
|
49
49
|
exports.HookEvents = {
|
|
@@ -58,7 +58,7 @@ const HookConditionEvents = {
|
|
|
58
58
|
TRANSLATED: [exports.HookEvents.fileTranslated, exports.HookEvents.fileDeleted],
|
|
59
59
|
APPROVED: [exports.HookEvents.fileApproved, exports.HookEvents.fileDeleted],
|
|
60
60
|
};
|
|
61
|
-
function encodedUrlParam(config, integration,
|
|
61
|
+
function encodedUrlParam({ config, crowdinContext, integration, }) {
|
|
62
62
|
var _a;
|
|
63
63
|
const params = {
|
|
64
64
|
projectId: +crowdinContext.jwtPayload.context.project_id,
|
|
@@ -68,44 +68,61 @@ function encodedUrlParam(config, integration, crowdinContext) {
|
|
|
68
68
|
const encryptedParams = (0, index_1.encryptData)(config, JSON.stringify(params));
|
|
69
69
|
return `${(_a = integration.webhooks) === null || _a === void 0 ? void 0 : _a.urlParam}=${encodeURIComponent(encryptedParams)}`;
|
|
70
70
|
}
|
|
71
|
-
exports.encodedUrlParam = encodedUrlParam;
|
|
72
71
|
function decodedUrlParam(config, data) {
|
|
73
72
|
const params = (0, index_1.decryptData)(config, data);
|
|
74
73
|
return JSON.parse(params);
|
|
75
74
|
}
|
|
76
|
-
|
|
77
|
-
function makeCrowdinWebhookUrl(config, integration, crowdinContext) {
|
|
75
|
+
function makeCrowdinWebhookUrl({ config, crowdinContext, integration, }) {
|
|
78
76
|
var _a;
|
|
79
|
-
const urlParam = encodedUrlParam(config, integration, crowdinContext);
|
|
77
|
+
const urlParam = encodedUrlParam({ config, integration, crowdinContext });
|
|
80
78
|
return (`${config.baseUrl}${((_a = integration.webhooks) === null || _a === void 0 ? void 0 : _a.crowdinWebhookUrl) ? integration.webhooks.crowdinWebhookUrl : '/api/crowdin/webhook'}` + `?${urlParam}`);
|
|
81
79
|
}
|
|
82
|
-
|
|
83
|
-
function registerWebhooks(config, integration, client, crowdinContext, apiCredentials, appSettings) {
|
|
80
|
+
function registerWebhooks({ config, apiCredentials, appSettings, client, crowdinContext, integration, }) {
|
|
84
81
|
var _a, _b;
|
|
85
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
83
|
const isWebhookSync = Number(appSettings.schedule) !== types_1.SyncSchedule.DISABLED;
|
|
87
84
|
const projectId = crowdinContext.jwtPayload.context.project_id;
|
|
88
|
-
const urlParam = encodedUrlParam(config, integration, crowdinContext);
|
|
85
|
+
const urlParam = encodedUrlParam({ config, integration, crowdinContext });
|
|
89
86
|
if ((_a = integration.webhooks) === null || _a === void 0 ? void 0 : _a.crowdinWebhooks) {
|
|
90
87
|
yield integration.webhooks.crowdinWebhooks(client, projectId, isWebhookSync, appSettings);
|
|
91
88
|
}
|
|
92
89
|
else {
|
|
93
90
|
const webhookName = `${config.name} application hook ${crowdinContext.jwtPayload.sub}`;
|
|
94
|
-
const webhookUrl = makeCrowdinWebhookUrl(
|
|
91
|
+
const webhookUrl = makeCrowdinWebhookUrl({
|
|
92
|
+
config,
|
|
93
|
+
integration,
|
|
94
|
+
crowdinContext,
|
|
95
|
+
});
|
|
95
96
|
const syncCondition = types_1.SyncCondition[Number(appSettings.condition)];
|
|
96
97
|
const events = [...HookConditionEvents[syncCondition]];
|
|
97
|
-
const webhook = yield getCrowdinProjectWebhook(
|
|
98
|
+
const webhook = yield getCrowdinProjectWebhook({
|
|
99
|
+
client,
|
|
100
|
+
projectId,
|
|
101
|
+
name: webhookName,
|
|
102
|
+
});
|
|
98
103
|
if (appSettings['new-crowdin-files']) {
|
|
99
104
|
events.push(exports.HookEvents.fileAdded);
|
|
100
105
|
}
|
|
101
106
|
if (isWebhookSync && webhook) {
|
|
102
|
-
yield updateCrowdinWebhooks(
|
|
107
|
+
yield updateCrowdinWebhooks({
|
|
108
|
+
client,
|
|
109
|
+
projectId,
|
|
110
|
+
webhook,
|
|
111
|
+
events,
|
|
112
|
+
url: webhookUrl,
|
|
113
|
+
});
|
|
103
114
|
}
|
|
104
115
|
else if (isWebhookSync && !webhook) {
|
|
105
|
-
yield registerCrowdinWebhook(
|
|
116
|
+
yield registerCrowdinWebhook({
|
|
117
|
+
config,
|
|
118
|
+
url: webhookUrl,
|
|
119
|
+
client,
|
|
120
|
+
crowdinContext,
|
|
121
|
+
events,
|
|
122
|
+
});
|
|
106
123
|
}
|
|
107
124
|
else if (!isWebhookSync && webhook) {
|
|
108
|
-
yield unregisterCrowdinWebhooks(
|
|
125
|
+
yield unregisterCrowdinWebhooks({ client, projectId, webhook });
|
|
109
126
|
}
|
|
110
127
|
}
|
|
111
128
|
if ((_b = integration.webhooks) === null || _b === void 0 ? void 0 : _b.integrationWebhooks) {
|
|
@@ -114,7 +131,7 @@ function registerWebhooks(config, integration, client, crowdinContext, apiCreden
|
|
|
114
131
|
});
|
|
115
132
|
}
|
|
116
133
|
exports.registerWebhooks = registerWebhooks;
|
|
117
|
-
function unregisterWebhooks(
|
|
134
|
+
function unregisterWebhooks({ apiCredentials, appSettings, client, config, crowdinContext, integration, }) {
|
|
118
135
|
var _a, _b;
|
|
119
136
|
return __awaiter(this, void 0, void 0, function* () {
|
|
120
137
|
if ((_a = integration.webhooks) === null || _a === void 0 ? void 0 : _a.crowdinWebhooks) {
|
|
@@ -122,32 +139,38 @@ function unregisterWebhooks(config, integration, client, crowdinContext, apiCred
|
|
|
122
139
|
}
|
|
123
140
|
else {
|
|
124
141
|
const webhookName = `${config.name} application hook ${crowdinContext.jwtPayload.sub}`;
|
|
125
|
-
const webhook = yield getCrowdinProjectWebhook(
|
|
142
|
+
const webhook = yield getCrowdinProjectWebhook({
|
|
143
|
+
client,
|
|
144
|
+
projectId: crowdinContext.jwtPayload.context.project_id,
|
|
145
|
+
name: webhookName,
|
|
146
|
+
});
|
|
126
147
|
if (webhook) {
|
|
127
|
-
yield unregisterCrowdinWebhooks(
|
|
148
|
+
yield unregisterCrowdinWebhooks({
|
|
149
|
+
client,
|
|
150
|
+
projectId: crowdinContext.jwtPayload.context.project_id,
|
|
151
|
+
webhook,
|
|
152
|
+
});
|
|
128
153
|
}
|
|
129
154
|
}
|
|
130
155
|
if ((_b = integration.webhooks) === null || _b === void 0 ? void 0 : _b.integrationWebhooks) {
|
|
131
|
-
const urlParam = encodedUrlParam(config, integration, crowdinContext);
|
|
156
|
+
const urlParam = encodedUrlParam({ config, integration, crowdinContext });
|
|
132
157
|
yield integration.webhooks.integrationWebhooks(apiCredentials, urlParam, false, appSettings);
|
|
133
158
|
}
|
|
134
159
|
});
|
|
135
160
|
}
|
|
136
161
|
exports.unregisterWebhooks = unregisterWebhooks;
|
|
137
|
-
function getCrowdinProjectWebhook(
|
|
162
|
+
function getCrowdinProjectWebhook({ client, name, projectId, }) {
|
|
138
163
|
return __awaiter(this, void 0, void 0, function* () {
|
|
139
164
|
const hooks = (yield client.webhooksApi.withFetchAll().listWebhooks(projectId)).data.map((e) => e.data);
|
|
140
165
|
return hooks.find((h) => h.name === name);
|
|
141
166
|
});
|
|
142
167
|
}
|
|
143
|
-
|
|
144
|
-
function getAllCrowdinProjectWebhooks(config, client, projectId) {
|
|
168
|
+
function getAllCrowdinProjectWebhooks({ client, config, projectId, }) {
|
|
145
169
|
return __awaiter(this, void 0, void 0, function* () {
|
|
146
170
|
const hooks = (yield client.webhooksApi.withFetchAll().listWebhooks(projectId)).data.map((e) => e.data);
|
|
147
171
|
return hooks.filter((h) => h.name.startsWith(`${config.name} application hook `));
|
|
148
172
|
});
|
|
149
173
|
}
|
|
150
|
-
exports.getAllCrowdinProjectWebhooks = getAllCrowdinProjectWebhooks;
|
|
151
174
|
function createPayload(events) {
|
|
152
175
|
const payload = {};
|
|
153
176
|
for (const event of events) {
|
|
@@ -160,7 +183,7 @@ function createPayload(events) {
|
|
|
160
183
|
}
|
|
161
184
|
return payload;
|
|
162
185
|
}
|
|
163
|
-
function registerCrowdinWebhook(config,
|
|
186
|
+
function registerCrowdinWebhook({ client, config, crowdinContext, events, url, }) {
|
|
164
187
|
return __awaiter(this, void 0, void 0, function* () {
|
|
165
188
|
const name = `${config.name} application hook ${crowdinContext.jwtPayload.sub}`;
|
|
166
189
|
const payload = createPayload(events);
|
|
@@ -174,8 +197,7 @@ function registerCrowdinWebhook(config, url, client, crowdinContext, events) {
|
|
|
174
197
|
});
|
|
175
198
|
});
|
|
176
199
|
}
|
|
177
|
-
|
|
178
|
-
function updateCrowdinWebhooks(config, client, projectId, webhook, events, url) {
|
|
200
|
+
function updateCrowdinWebhooks({ client, events, projectId, url, webhook, }) {
|
|
179
201
|
return __awaiter(this, void 0, void 0, function* () {
|
|
180
202
|
const payload = createPayload(events);
|
|
181
203
|
yield client.webhooksApi.editWebhook(projectId, webhook.id, [
|
|
@@ -197,14 +219,12 @@ function updateCrowdinWebhooks(config, client, projectId, webhook, events, url)
|
|
|
197
219
|
]);
|
|
198
220
|
});
|
|
199
221
|
}
|
|
200
|
-
|
|
201
|
-
function unregisterCrowdinWebhooks(config, client, projectId, webhook) {
|
|
222
|
+
function unregisterCrowdinWebhooks({ client, projectId, webhook, }) {
|
|
202
223
|
return __awaiter(this, void 0, void 0, function* () {
|
|
203
224
|
yield client.webhooksApi.deleteWebhook(projectId, webhook.id);
|
|
204
225
|
});
|
|
205
226
|
}
|
|
206
|
-
|
|
207
|
-
function unregisterAllCrowdinWebhooks(config, integration, crowdinId) {
|
|
227
|
+
function unregisterAllCrowdinWebhooks({ config, crowdinId, integration, }) {
|
|
208
228
|
return __awaiter(this, void 0, void 0, function* () {
|
|
209
229
|
if (integration.webhooks) {
|
|
210
230
|
const crowdinCredentials = yield (0, storage_1.getStorage)().getCrowdinCredentials(crowdinId);
|
|
@@ -213,15 +233,25 @@ function unregisterAllCrowdinWebhooks(config, integration, crowdinId) {
|
|
|
213
233
|
const projectIds = credentials.map((c) => crowdinAppFunctions.getProjectId(c.id));
|
|
214
234
|
const crowdinClient = yield (0, connection_1.prepareCrowdinClient)({ config, credentials: crowdinCredentials });
|
|
215
235
|
yield Promise.all(projectIds.map((projectId) => __awaiter(this, void 0, void 0, function* () {
|
|
216
|
-
const webhooks = yield getAllCrowdinProjectWebhooks(
|
|
217
|
-
|
|
236
|
+
const webhooks = yield getAllCrowdinProjectWebhooks({
|
|
237
|
+
config,
|
|
238
|
+
client: crowdinClient.client,
|
|
239
|
+
projectId,
|
|
240
|
+
});
|
|
241
|
+
yield Promise.all(webhooks.map((hook) => __awaiter(this, void 0, void 0, function* () {
|
|
242
|
+
return yield unregisterCrowdinWebhooks({
|
|
243
|
+
client: crowdinClient.client,
|
|
244
|
+
projectId,
|
|
245
|
+
webhook: hook,
|
|
246
|
+
});
|
|
247
|
+
})));
|
|
218
248
|
})));
|
|
219
249
|
}
|
|
220
250
|
}
|
|
221
251
|
});
|
|
222
252
|
}
|
|
223
253
|
exports.unregisterAllCrowdinWebhooks = unregisterAllCrowdinWebhooks;
|
|
224
|
-
function prepareWebhookData(config, integration, webhookUrlParam,
|
|
254
|
+
function prepareWebhookData({ config, integration, provider, webhookUrlParam, }) {
|
|
225
255
|
return __awaiter(this, void 0, void 0, function* () {
|
|
226
256
|
let rootFolder = undefined;
|
|
227
257
|
let syncSettings = null;
|
|
@@ -298,13 +328,13 @@ function updateCrowdinFromWebhookRequest(args) {
|
|
|
298
328
|
});
|
|
299
329
|
}
|
|
300
330
|
exports.updateCrowdinFromWebhookRequest = updateCrowdinFromWebhookRequest;
|
|
301
|
-
function listenQueueMessage(config, integration, queueUrl,
|
|
331
|
+
function listenQueueMessage({ config, integration, queueName, queueUrl, }) {
|
|
302
332
|
return __awaiter(this, void 0, void 0, function* () {
|
|
303
333
|
try {
|
|
304
334
|
const connection = yield amqplib_1.default.connect(queueUrl);
|
|
305
335
|
connection.once('close', function () {
|
|
306
336
|
setTimeout(() => {
|
|
307
|
-
listenQueueMessage(config, integration, queueUrl, queueName);
|
|
337
|
+
listenQueueMessage({ config, integration, queueUrl, queueName });
|
|
308
338
|
}, 3000);
|
|
309
339
|
return;
|
|
310
340
|
});
|
|
@@ -312,18 +342,19 @@ function listenQueueMessage(config, integration, queueUrl, queueName) {
|
|
|
312
342
|
if (channel) {
|
|
313
343
|
yield channel.assertQueue(queueName, { durable: true });
|
|
314
344
|
yield channel.prefetch(prefetchCount);
|
|
315
|
-
|
|
345
|
+
const onMessage = consumer({ channel, config, integration });
|
|
346
|
+
yield channel.consume(queueName, onMessage, { noAck: false });
|
|
316
347
|
}
|
|
317
348
|
}
|
|
318
349
|
catch (e) {
|
|
319
350
|
setTimeout(() => {
|
|
320
|
-
listenQueueMessage(config, integration, queueUrl, queueName);
|
|
351
|
+
listenQueueMessage({ config, integration, queueUrl, queueName });
|
|
321
352
|
}, 3000);
|
|
322
353
|
}
|
|
323
354
|
});
|
|
324
355
|
}
|
|
325
356
|
exports.listenQueueMessage = listenQueueMessage;
|
|
326
|
-
function consumer(channel, config, integration) {
|
|
357
|
+
function consumer({ channel, config, integration, }) {
|
|
327
358
|
let messagesCounter = 0;
|
|
328
359
|
let webhooksInfo = {};
|
|
329
360
|
let webhooksData = [];
|
|
@@ -350,7 +381,12 @@ function consumer(channel, config, integration) {
|
|
|
350
381
|
webhooksInfo[clientId] = {};
|
|
351
382
|
webhooksInfo[clientId].data = [data];
|
|
352
383
|
webhooksInfo[clientId].integration = integration;
|
|
353
|
-
webhooksData.push(prepareWebhookData(
|
|
384
|
+
webhooksData.push(prepareWebhookData({
|
|
385
|
+
config,
|
|
386
|
+
integration,
|
|
387
|
+
webhookUrlParam,
|
|
388
|
+
provider: types_1.Provider.INTEGRATION,
|
|
389
|
+
}).then((res) => {
|
|
354
390
|
webhooksInfo[clientId].webhookData = res;
|
|
355
391
|
}));
|
|
356
392
|
}
|
|
@@ -360,13 +396,23 @@ function consumer(channel, config, integration) {
|
|
|
360
396
|
if (messagesCounter < prefetchCount) {
|
|
361
397
|
// if all messages are not received, wait 5 seconds to force process messages
|
|
362
398
|
timeoutId = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
363
|
-
yield processMessages(
|
|
399
|
+
yield processMessages({
|
|
400
|
+
webhooksData,
|
|
401
|
+
webhooksInfo,
|
|
402
|
+
channel,
|
|
403
|
+
msg,
|
|
404
|
+
});
|
|
364
405
|
resetStateVariables();
|
|
365
406
|
}), forceProcessDelay);
|
|
366
407
|
return;
|
|
367
408
|
}
|
|
368
409
|
clearTimeout(timeoutId);
|
|
369
|
-
yield processMessages(
|
|
410
|
+
yield processMessages({
|
|
411
|
+
webhooksData,
|
|
412
|
+
webhooksInfo,
|
|
413
|
+
channel,
|
|
414
|
+
msg,
|
|
415
|
+
});
|
|
370
416
|
resetStateVariables();
|
|
371
417
|
}
|
|
372
418
|
catch (e) {
|
|
@@ -375,7 +421,7 @@ function consumer(channel, config, integration) {
|
|
|
375
421
|
});
|
|
376
422
|
};
|
|
377
423
|
}
|
|
378
|
-
function processMessages(webhooksData, webhooksInfo,
|
|
424
|
+
function processMessages({ channel, msg, webhooksData, webhooksInfo, }) {
|
|
379
425
|
return __awaiter(this, void 0, void 0, function* () {
|
|
380
426
|
yield Promise.all(webhooksData);
|
|
381
427
|
for (const { data, integration, webhookData } of Object.values(webhooksInfo)) {
|
package/out/modules/manifest.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const types_1 = require("../types");
|
|
4
4
|
const util_1 = require("../util");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const subscription_1 = require("../util/subscription");
|
|
6
|
+
const api_1 = require("./api/api");
|
|
7
7
|
function normalizeEnvironments(environments) {
|
|
8
8
|
if (Array.isArray(environments)) {
|
|
9
9
|
return environments;
|
|
@@ -14,14 +14,9 @@ function handle(config) {
|
|
|
14
14
|
const modules = {};
|
|
15
15
|
if (config.projectIntegration) {
|
|
16
16
|
modules['project-integrations'] = [
|
|
17
|
-
{
|
|
18
|
-
key: config.identifier + '-int',
|
|
19
|
-
name: config.name,
|
|
20
|
-
description: config.description,
|
|
21
|
-
logo: (0, util_1.getLogoUrl)(config.projectIntegration, '/integration'),
|
|
22
|
-
url: '/',
|
|
17
|
+
Object.assign({ key: config.identifier + '-int', name: config.name, description: config.description, logo: (0, util_1.getLogoUrl)(config.projectIntegration, '/integration'), url: '/' }, (!!config.projectIntegration.environments && {
|
|
23
18
|
environments: normalizeEnvironments(config.projectIntegration.environments),
|
|
24
|
-
},
|
|
19
|
+
})),
|
|
25
20
|
];
|
|
26
21
|
}
|
|
27
22
|
if (config.customFileFormat) {
|
|
@@ -77,14 +72,9 @@ function handle(config) {
|
|
|
77
72
|
}
|
|
78
73
|
if (config.customMT) {
|
|
79
74
|
modules['custom-mt'] = [
|
|
80
|
-
{
|
|
81
|
-
key: config.identifier + '-mt',
|
|
82
|
-
name: config.name,
|
|
83
|
-
logo: (0, util_1.getLogoUrl)(config.customMT, '/mt'),
|
|
84
|
-
url: '/translate',
|
|
75
|
+
Object.assign({ key: config.identifier + '-mt', name: config.name, logo: (0, util_1.getLogoUrl)(config.customMT, '/mt'), url: '/translate', withContext: !!config.customMT.withContext }, (!!config.customMT.environments && {
|
|
85
76
|
environments: normalizeEnvironments(config.customMT.environments),
|
|
86
|
-
|
|
87
|
-
},
|
|
77
|
+
})),
|
|
88
78
|
];
|
|
89
79
|
}
|
|
90
80
|
if (config.organizationMenu) {
|
|
@@ -99,46 +89,30 @@ function handle(config) {
|
|
|
99
89
|
}
|
|
100
90
|
if (config.profileResourcesMenu) {
|
|
101
91
|
modules['profile-resources-menu'] = [
|
|
102
|
-
{
|
|
103
|
-
key: config.identifier + '-profile-resources-menu',
|
|
104
|
-
name: config.profileResourcesMenu.name || config.name,
|
|
105
|
-
url: '/resources/' + (config.profileResourcesMenu.fileName || 'index.html'),
|
|
106
|
-
icon: (0, util_1.getLogoUrl)(config.profileResourcesMenu, '/resources'),
|
|
92
|
+
Object.assign({ key: config.identifier + '-profile-resources-menu', name: config.profileResourcesMenu.name || config.name, url: '/resources/' + (config.profileResourcesMenu.fileName || 'index.html'), icon: (0, util_1.getLogoUrl)(config.profileResourcesMenu, '/resources') }, (!!config.profileResourcesMenu.environments && {
|
|
107
93
|
environments: normalizeEnvironments(config.profileResourcesMenu.environments),
|
|
108
|
-
},
|
|
94
|
+
})),
|
|
109
95
|
];
|
|
110
96
|
}
|
|
111
97
|
if (config.editorRightPanel) {
|
|
112
98
|
modules['editor-right-panel'] = [
|
|
113
|
-
{
|
|
114
|
-
key: config.identifier + '-editor-panels',
|
|
115
|
-
name: config.editorRightPanel.name || config.name,
|
|
116
|
-
url: '/editor-panels/' + (config.editorRightPanel.fileName || 'index.html'),
|
|
117
|
-
modes: config.editorRightPanel.modes,
|
|
99
|
+
Object.assign({ key: config.identifier + '-editor-panels', name: config.editorRightPanel.name || config.name, url: '/editor-panels/' + (config.editorRightPanel.fileName || 'index.html'), modes: config.editorRightPanel.modes }, (!!config.editorRightPanel.environments && {
|
|
118
100
|
environments: normalizeEnvironments(config.editorRightPanel.environments),
|
|
119
|
-
},
|
|
101
|
+
})),
|
|
120
102
|
];
|
|
121
103
|
}
|
|
122
104
|
if (config.editorThemes) {
|
|
123
105
|
modules['editor-themes'] = [
|
|
124
|
-
{
|
|
125
|
-
key: config.identifier + '-editor-themes',
|
|
126
|
-
name: config.editorThemes.name || config.name,
|
|
127
|
-
logo: (0, util_1.getLogoUrl)(config.editorThemes, '/editor-themes'),
|
|
128
|
-
styles: config.editorThemes.styles,
|
|
129
|
-
modes: config.editorThemes.modes,
|
|
106
|
+
Object.assign({ key: config.identifier + '-editor-themes', name: config.editorThemes.name || config.name, logo: (0, util_1.getLogoUrl)(config.editorThemes, '/editor-themes'), styles: config.editorThemes.styles, modes: config.editorThemes.modes }, (!!config.editorThemes.environments && {
|
|
130
107
|
environments: normalizeEnvironments(config.editorThemes.environments),
|
|
131
|
-
},
|
|
108
|
+
})),
|
|
132
109
|
];
|
|
133
110
|
}
|
|
134
111
|
if (config.projectMenu) {
|
|
135
112
|
modules['project-menu'] = [
|
|
136
|
-
{
|
|
137
|
-
key: config.identifier + '-project-menu',
|
|
138
|
-
name: config.projectMenu.name || config.name,
|
|
139
|
-
url: '/project-menu/' + (config.projectMenu.fileName || 'index.html'),
|
|
113
|
+
Object.assign({ key: config.identifier + '-project-menu', name: config.projectMenu.name || config.name, url: '/project-menu/' + (config.projectMenu.fileName || 'index.html') }, (!!config.projectMenu.environments && {
|
|
140
114
|
environments: normalizeEnvironments(config.projectMenu.environments),
|
|
141
|
-
},
|
|
115
|
+
})),
|
|
142
116
|
];
|
|
143
117
|
}
|
|
144
118
|
if (config.projectMenuCrowdsource) {
|
|
@@ -152,14 +126,9 @@ function handle(config) {
|
|
|
152
126
|
}
|
|
153
127
|
if (config.projectTools) {
|
|
154
128
|
modules['project-tools'] = [
|
|
155
|
-
{
|
|
156
|
-
key: config.identifier + '-tools',
|
|
157
|
-
name: config.projectTools.name || config.name,
|
|
158
|
-
description: config.description,
|
|
159
|
-
logo: (0, util_1.getLogoUrl)(config.projectTools, '/tools'),
|
|
160
|
-
url: '/tools/' + (config.projectTools.fileName || 'index.html'),
|
|
129
|
+
Object.assign({ key: config.identifier + '-tools', name: config.projectTools.name || config.name, description: config.description, logo: (0, util_1.getLogoUrl)(config.projectTools, '/tools'), url: '/tools/' + (config.projectTools.fileName || 'index.html') }, (!!config.projectTools.environments && {
|
|
161
130
|
environments: normalizeEnvironments(config.projectTools.environments),
|
|
162
|
-
},
|
|
131
|
+
})),
|
|
163
132
|
];
|
|
164
133
|
}
|
|
165
134
|
if (config.projectReports) {
|
|
@@ -175,30 +144,20 @@ function handle(config) {
|
|
|
175
144
|
}
|
|
176
145
|
if (config.modal) {
|
|
177
146
|
modules['modal'] = [
|
|
178
|
-
{
|
|
179
|
-
key: config.identifier + '-modal',
|
|
180
|
-
name: config.modal.name || config.name,
|
|
181
|
-
url: config.modal.url || '/modal/' + (config.modal.fileName || 'index.html'),
|
|
182
|
-
environments: normalizeEnvironments(config.modal.environments),
|
|
183
|
-
},
|
|
147
|
+
Object.assign({ key: config.identifier + '-modal', name: config.modal.name || config.name, url: config.modal.url || '/modal/' + (config.modal.fileName || 'index.html') }, (!!config.modal.environments && { environments: normalizeEnvironments(config.modal.environments) })),
|
|
184
148
|
];
|
|
185
149
|
}
|
|
186
150
|
if (config.contextMenu) {
|
|
187
151
|
modules['context-menu'] = [
|
|
188
|
-
{
|
|
189
|
-
key: config.identifier + '-context-menu',
|
|
190
|
-
name: config.contextMenu.name || config.name,
|
|
191
|
-
description: config.description,
|
|
192
|
-
options: Object.assign(Object.assign({ location: config.contextMenu.location, type: config.contextMenu.type }, (config.contextMenu.module
|
|
152
|
+
Object.assign({ key: config.identifier + '-context-menu', name: config.contextMenu.name || config.name, description: config.description, options: Object.assign(Object.assign({ location: config.contextMenu.location, type: config.contextMenu.type }, (config.contextMenu.module
|
|
193
153
|
? {
|
|
194
154
|
module: {
|
|
195
155
|
[config.contextMenu.module]: modules[config.contextMenu.module][0].key,
|
|
196
156
|
},
|
|
197
157
|
}
|
|
198
|
-
: {})), { url: '/context/' + (config.contextMenu.fileName || 'index.html') }),
|
|
199
|
-
signaturePatterns: config.contextMenu.signaturePatterns,
|
|
158
|
+
: {})), { url: '/context/' + (config.contextMenu.fileName || 'index.html') }), signaturePatterns: config.contextMenu.signaturePatterns }, (!!config.contextMenu.environments && {
|
|
200
159
|
environments: normalizeEnvironments(config.contextMenu.environments),
|
|
201
|
-
},
|
|
160
|
+
})),
|
|
202
161
|
];
|
|
203
162
|
}
|
|
204
163
|
if (config.api) {
|
|
@@ -207,21 +166,23 @@ function handle(config) {
|
|
|
207
166
|
if (config.customSpellchecker) {
|
|
208
167
|
const uiModule = config.customSpellchecker.settingsUiModule;
|
|
209
168
|
modules['custom-spellchecker'] = [
|
|
210
|
-
Object.assign({ key: config.identifier + '-spellchecker', name: config.customSpellchecker.name || config.name, description: config.customSpellchecker.description || config.description, listSupportedLanguagesUrl: '/languages', checkSpellingUrl: '/spellcheck',
|
|
169
|
+
Object.assign(Object.assign({ key: config.identifier + '-spellchecker', name: config.customSpellchecker.name || config.name, description: config.customSpellchecker.description || config.description, listSupportedLanguagesUrl: '/languages', checkSpellingUrl: '/spellcheck' }, (!!config.customSpellchecker.environments && {
|
|
170
|
+
environments: normalizeEnvironments(config.customSpellchecker.environments),
|
|
171
|
+
})), (uiModule ? { url: '/settings/' + (uiModule.fileName || 'index.html') } : {})),
|
|
211
172
|
];
|
|
212
173
|
}
|
|
213
174
|
const events = {
|
|
214
175
|
installed: '/installed',
|
|
215
176
|
uninstall: '/uninstall',
|
|
216
177
|
};
|
|
217
|
-
if (!(0,
|
|
178
|
+
if (!(0, subscription_1.isAppFree)(config)) {
|
|
218
179
|
events['subscription_paid'] = '/subscription-paid';
|
|
219
180
|
}
|
|
220
181
|
return (_req, res) => {
|
|
221
182
|
const manifest = Object.assign(Object.assign({ identifier: config.identifier, name: config.name, logo: (0, util_1.getLogoUrl)(), baseUrl: config.baseUrl, authentication: {
|
|
222
|
-
type: config.authenticationType ||
|
|
183
|
+
type: config.authenticationType || types_1.AuthenticationType.APP,
|
|
223
184
|
clientId: config.clientId,
|
|
224
|
-
}, events, scopes: config.scopes ? config.scopes : [
|
|
185
|
+
}, events, scopes: config.scopes ? config.scopes : [types_1.Scope.PROJECTS] }, (config.defaultPermissions && { default_permissions: config.defaultPermissions })), { modules });
|
|
225
186
|
res.send(manifest);
|
|
226
187
|
};
|
|
227
188
|
}
|
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.register = void 0;
|
|
7
7
|
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
8
8
|
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
9
|
-
const
|
|
9
|
+
const util_1 = require("../../util");
|
|
10
10
|
function register({ config, app }) {
|
|
11
11
|
var _a, _b;
|
|
12
|
-
const allowUnauthorized = !(0,
|
|
12
|
+
const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
|
|
13
13
|
if (((_a = config.modal) === null || _a === void 0 ? void 0 : _a.uiPath) || ((_b = config.modal) === null || _b === void 0 ? void 0 : _b.formSchema)) {
|
|
14
14
|
app.use('/modal', (0, ui_module_1.default)(config, allowUnauthorized), (0, render_ui_module_1.default)(config.modal));
|
|
15
15
|
}
|
|
@@ -7,12 +7,11 @@ exports.register = void 0;
|
|
|
7
7
|
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
8
8
|
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
9
9
|
const util_1 = require("../../util");
|
|
10
|
-
const defaults_1 = require("../../util/defaults");
|
|
11
10
|
function register({ config, app }) {
|
|
12
11
|
if (!config.organizationMenu) {
|
|
13
12
|
return;
|
|
14
13
|
}
|
|
15
|
-
const allowUnauthorized = !(0,
|
|
14
|
+
const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
|
|
16
15
|
app.get((0, util_1.getLogoUrl)(config.organizationMenu, '/resources'), (req, res) => { var _a; return res.sendFile(((_a = config.organizationMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
|
|
17
16
|
app.use('/resources', (0, ui_module_1.default)(config, allowUnauthorized), (0, render_ui_module_1.default)(config.organizationMenu));
|
|
18
17
|
}
|
|
@@ -7,13 +7,12 @@ exports.register = void 0;
|
|
|
7
7
|
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
8
8
|
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
9
9
|
const util_1 = require("../../util");
|
|
10
|
-
const defaults_1 = require("../../util/defaults");
|
|
11
10
|
function register({ config, app }) {
|
|
12
11
|
if (!config.profileResourcesMenu) {
|
|
13
12
|
return;
|
|
14
13
|
}
|
|
15
14
|
app.get((0, util_1.getLogoUrl)(config.profileResourcesMenu, '/resources'), (req, res) => { var _a; return res.sendFile(((_a = config.profileResourcesMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
|
|
16
|
-
const allowUnauthorized = !(0,
|
|
15
|
+
const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
|
|
17
16
|
app.use('/resources', (0, ui_module_1.default)(config, allowUnauthorized), (0, render_ui_module_1.default)(config.profileResourcesMenu));
|
|
18
17
|
}
|
|
19
18
|
exports.register = register;
|
|
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.register = void 0;
|
|
7
7
|
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
8
8
|
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
9
|
-
const
|
|
9
|
+
const util_1 = require("../../util");
|
|
10
10
|
function register({ config, app }) {
|
|
11
11
|
if (!config.projectMenu) {
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
|
-
const allowUnauthorized = !(0,
|
|
14
|
+
const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
|
|
15
15
|
app.use('/project-menu', (0, ui_module_1.default)(config, allowUnauthorized), (0, render_ui_module_1.default)(config.projectMenu));
|
|
16
16
|
}
|
|
17
17
|
exports.register = register;
|
|
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.register = void 0;
|
|
7
7
|
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
8
8
|
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
9
|
-
const
|
|
9
|
+
const util_1 = require("../../util");
|
|
10
10
|
function register({ config, app }) {
|
|
11
11
|
if (!config.projectMenuCrowdsource) {
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
|
-
const allowUnauthorized = !(0,
|
|
14
|
+
const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
|
|
15
15
|
app.use('/project-menu-crowdsource', (0, ui_module_1.default)(config, allowUnauthorized), (0, render_ui_module_1.default)(config.projectMenuCrowdsource));
|
|
16
16
|
}
|
|
17
17
|
exports.register = register;
|
|
@@ -7,12 +7,11 @@ exports.register = void 0;
|
|
|
7
7
|
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
8
8
|
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
9
9
|
const util_1 = require("../../util");
|
|
10
|
-
const defaults_1 = require("../../util/defaults");
|
|
11
10
|
function register({ config, app }) {
|
|
12
11
|
if (!config.projectReports) {
|
|
13
12
|
return;
|
|
14
13
|
}
|
|
15
|
-
const allowUnauthorized = !(0,
|
|
14
|
+
const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
|
|
16
15
|
app.get((0, util_1.getLogoUrl)(config.projectReports, '/reports'), (req, res) => { var _a; return res.sendFile(((_a = config.projectReports) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
|
|
17
16
|
app.use('/reports', (0, ui_module_1.default)(config, allowUnauthorized), (0, render_ui_module_1.default)(config.projectReports));
|
|
18
17
|
}
|