@crowdin/app-project-module 0.43.1 → 0.45.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/index.d.ts +3 -3
- package/out/index.js +103 -219
- package/out/middlewares/crowdin-client.d.ts +1 -1
- package/out/middlewares/crowdin-client.js +3 -2
- package/out/middlewares/integration-credentials.d.ts +3 -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 +5 -1
- package/out/{util → modules}/api/api.d.ts +3 -2
- 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 +6 -0
- package/out/modules/context-menu/index.js +17 -0
- package/out/modules/context-menu/types.d.ts +27 -0
- package/out/modules/context-menu/types.js +18 -0
- package/out/{handlers/custom-mt → modules/custom-mt/handlers}/translate.d.ts +2 -1
- package/out/{handlers/custom-mt → modules/custom-mt/handlers}/translate.js +2 -2
- package/out/modules/custom-mt/index.d.ts +6 -0
- package/out/modules/custom-mt/index.js +17 -0
- package/out/modules/custom-mt/types.d.ts +22 -0
- package/out/modules/custom-mt/types.js +2 -0
- package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/get-languages-list.d.ts +2 -1
- package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/get-languages-list.js +2 -2
- package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/spell-check.d.ts +2 -1
- package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/spell-check.js +5 -3
- package/out/modules/custom-spell-check/index.d.ts +6 -0
- package/out/modules/custom-spell-check/index.js +32 -0
- package/out/modules/custom-spell-check/types.d.ts +56 -0
- package/out/modules/custom-spell-check/types.js +2 -0
- package/out/modules/editor-right-panel/index.d.ts +6 -0
- package/out/modules/editor-right-panel/index.js +17 -0
- package/out/modules/editor-right-panel/types.d.ts +7 -0
- package/out/modules/editor-right-panel/types.js +2 -0
- package/out/modules/editor-themes/index.d.ts +6 -0
- package/out/modules/editor-themes/index.js +11 -0
- package/out/modules/editor-themes/types.d.ts +17 -0
- package/out/modules/editor-themes/types.js +2 -0
- package/out/{handlers/file-processing → modules/file-processing/handlers}/custom-file-format.d.ts +2 -1
- package/out/{handlers/file-processing → modules/file-processing/handlers}/custom-file-format.js +5 -5
- package/out/modules/file-processing/handlers/file-download.d.ts +5 -0
- package/out/{handlers/file-processing → modules/file-processing/handlers}/file-download.js +2 -2
- package/out/{handlers/file-processing → modules/file-processing/handlers}/pre-post-process.d.ts +2 -1
- package/out/{handlers/file-processing → modules/file-processing/handlers}/pre-post-process.js +8 -8
- package/out/modules/file-processing/index.d.ts +22 -0
- package/out/modules/file-processing/index.js +57 -0
- package/out/modules/file-processing/types.d.ts +133 -0
- package/out/modules/file-processing/types.js +12 -0
- 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/{handlers/integration/crowdin-project.d.ts → modules/form-data-display.d.ts} +1 -1
- package/out/modules/form-data-save.d.ts +4 -0
- package/out/modules/install.d.ts +4 -0
- package/out/{handlers → modules}/install.js +3 -3
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-file-progress.d.ts +2 -1
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-file-progress.js +2 -2
- package/out/modules/integration/handlers/crowdin-files.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-files.js +3 -3
- package/out/modules/integration/handlers/crowdin-project.d.ts +4 -0
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-project.js +1 -1
- package/out/modules/integration/handlers/crowdin-update.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-update.js +9 -9
- package/out/modules/integration/handlers/crowdin-webhook.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-webhook.js +19 -8
- package/out/modules/integration/handlers/integration-data.d.ts +4 -0
- package/out/{handlers/integration → modules/integration/handlers}/integration-data.js +5 -5
- package/out/{handlers/integration → modules/integration/handlers}/integration-login.d.ts +2 -1
- package/out/{handlers/integration → modules/integration/handlers}/integration-login.js +3 -3
- package/out/modules/integration/handlers/integration-logout.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/integration-logout.js +14 -7
- package/out/modules/integration/handlers/integration-update.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/integration-update.js +9 -8
- package/out/modules/integration/handlers/integration-webhook.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/integration-webhook.js +9 -4
- package/out/modules/integration/handlers/job-cancel.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/job-cancel.js +4 -4
- package/out/modules/integration/handlers/job-info.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/job-info.js +4 -4
- package/out/modules/integration/handlers/main.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/main.js +5 -5
- package/out/modules/integration/handlers/oauth-login.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/oauth-login.js +3 -3
- package/out/{handlers/integration → modules/integration/handlers}/oauth-url.d.ts +2 -1
- package/out/{handlers/integration → modules/integration/handlers}/oauth-url.js +2 -2
- package/out/modules/integration/handlers/settings-save.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/settings-save.js +28 -11
- package/out/modules/integration/handlers/settings.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/settings.js +1 -1
- package/out/{handlers/integration → modules/integration/handlers}/subscription-info.d.ts +1 -1
- package/out/{handlers/integration → modules/integration/handlers}/subscription-info.js +2 -2
- package/out/modules/integration/handlers/sync-settings-save.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/sync-settings-save.js +16 -8
- package/out/modules/integration/handlers/sync-settings.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/sync-settings.js +2 -2
- package/out/modules/integration/handlers/user-errors.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/user-errors.js +2 -2
- package/out/modules/integration/index.d.ts +6 -0
- package/out/modules/integration/index.js +118 -0
- package/out/modules/integration/types.d.ts +435 -0
- package/out/modules/integration/types.js +19 -0
- package/out/modules/integration/util/cron.d.ts +27 -0
- package/out/{util → modules/integration/util}/cron.js +97 -28
- package/out/{util → modules/integration/util}/defaults.d.ts +2 -3
- package/out/{util → modules/integration/util}/defaults.js +1 -36
- 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 -3
- package/out/{util/file-snapshot.js → modules/integration/util/snapshot.js} +6 -65
- 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 +95 -49
- package/out/modules/manifest.d.ts +3 -0
- package/out/{handlers → modules}/manifest.js +22 -16
- package/out/modules/modal/index.d.ts +6 -0
- package/out/modules/modal/index.js +17 -0
- package/out/modules/organization-menu/index.d.ts +6 -0
- package/out/modules/organization-menu/index.js +18 -0
- package/out/modules/profile-resources-menu/index.d.ts +6 -0
- package/out/modules/profile-resources-menu/index.js +18 -0
- package/out/modules/project-menu/index.d.ts +6 -0
- package/out/modules/project-menu/index.js +17 -0
- package/out/modules/project-menu-crowdsource/index.d.ts +6 -0
- package/out/modules/project-menu-crowdsource/index.js +17 -0
- package/out/modules/project-reports/index.d.ts +6 -0
- package/out/modules/project-reports/index.js +18 -0
- package/out/modules/project-tools/index.d.ts +6 -0
- package/out/modules/project-tools/index.js +18 -0
- package/out/modules/subscription-paid.d.ts +3 -0
- package/out/{handlers → modules}/subscription-paid.js +2 -2
- package/out/modules/uninstall.d.ts +4 -0
- package/out/{handlers → modules}/uninstall.js +6 -2
- package/out/storage/index.d.ts +5 -3
- package/out/storage/mysql.d.ts +4 -2
- package/out/storage/mysql.js +3 -3
- package/out/storage/postgre.d.ts +4 -2
- package/out/storage/postgre.js +3 -3
- package/out/storage/sqlite.d.ts +4 -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/types.d.ts +374 -0
- package/out/types.js +59 -0
- package/out/util/connection.d.ts +2 -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 -2
- package/out/util/index.js +6 -6
- package/out/util/logger.d.ts +2 -2
- package/out/util/subscription.d.ts +9 -0
- package/out/util/subscription.js +111 -0
- package/package.json +1 -1
- package/out/handlers/file-processing/file-download.d.ts +0 -4
- package/out/handlers/form-data-display.d.ts +0 -3
- package/out/handlers/form-data-save.d.ts +0 -3
- package/out/handlers/install.d.ts +0 -4
- package/out/handlers/integration/crowdin-files.d.ts +0 -4
- package/out/handlers/integration/crowdin-update.d.ts +0 -4
- package/out/handlers/integration/crowdin-webhook.d.ts +0 -4
- package/out/handlers/integration/integration-data.d.ts +0 -4
- package/out/handlers/integration/integration-logout.d.ts +0 -4
- package/out/handlers/integration/integration-update.d.ts +0 -4
- package/out/handlers/integration/integration-webhook.d.ts +0 -4
- package/out/handlers/integration/job-cancel.d.ts +0 -3
- package/out/handlers/integration/job-info.d.ts +0 -3
- package/out/handlers/integration/main.d.ts +0 -4
- package/out/handlers/integration/oauth-login.d.ts +0 -4
- package/out/handlers/integration/settings-save.d.ts +0 -4
- package/out/handlers/integration/settings.d.ts +0 -3
- package/out/handlers/integration/sync-settings-save.d.ts +0 -4
- package/out/handlers/integration/sync-settings.d.ts +0 -3
- package/out/handlers/integration/user-errors.d.ts +0 -3
- package/out/handlers/manifest.d.ts +0 -3
- package/out/handlers/subscription-paid.d.ts +0 -3
- package/out/handlers/uninstall.d.ts +0 -4
- package/out/models/index.d.ts +0 -1088
- package/out/models/index.js +0 -106
- package/out/util/cron.d.ts +0 -7
- package/out/util/files.d.ts +0 -9
- package/out/util/webhooks.d.ts +0 -28
- /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/{handlers → modules}/form-data-display.js +0 -0
- /package/out/{handlers → modules}/form-data-save.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 storage_1 = require("
|
|
43
|
-
const connection_1 = require("
|
|
41
|
+
const types_1 = require("../types");
|
|
42
|
+
const storage_1 = require("../../../storage");
|
|
43
|
+
const connection_1 = require("../../../util/connection");
|
|
44
44
|
const defaults_1 = require("./defaults");
|
|
45
|
-
const index_1 = require("
|
|
46
|
-
const logger_1 = require("
|
|
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
|
-
const isWebhookSync = Number(appSettings.schedule) !==
|
|
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(
|
|
95
|
-
|
|
91
|
+
const webhookUrl = makeCrowdinWebhookUrl({
|
|
92
|
+
config,
|
|
93
|
+
integration,
|
|
94
|
+
crowdinContext,
|
|
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;
|
|
@@ -250,7 +280,7 @@ function prepareWebhookData(config, integration, webhookUrlParam, provider) {
|
|
|
250
280
|
const preparedIntegrationCredentials = yield (0, connection_1.prepareIntegrationCredentials)(config, integration, integrationCredentials);
|
|
251
281
|
if (integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.config) {
|
|
252
282
|
appSettings = JSON.parse(integrationConfig.config);
|
|
253
|
-
const isWebhookSync = Number(appSettings.schedule) !==
|
|
283
|
+
const isWebhookSync = Number(appSettings.schedule) !== types_1.SyncSchedule.DISABLED;
|
|
254
284
|
if (isWebhookSync) {
|
|
255
285
|
syncSettings = (yield (0, storage_1.getStorage)().getSyncSettings(clientId, crowdinId, 'schedule', provider));
|
|
256
286
|
rootFolder = yield (0, defaults_1.getRootFolder)(config, integration, crowdinClient.client, projectId);
|
|
@@ -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)) {
|
|
@@ -1,9 +1,15 @@
|
|
|
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
|
+
function normalizeEnvironments(environments) {
|
|
8
|
+
if (Array.isArray(environments)) {
|
|
9
|
+
return environments;
|
|
10
|
+
}
|
|
11
|
+
return [environments];
|
|
12
|
+
}
|
|
7
13
|
function handle(config) {
|
|
8
14
|
const modules = {};
|
|
9
15
|
if (config.projectIntegration) {
|
|
@@ -14,7 +20,7 @@ function handle(config) {
|
|
|
14
20
|
description: config.description,
|
|
15
21
|
logo: (0, util_1.getLogoUrl)(config.projectIntegration, '/integration'),
|
|
16
22
|
url: '/',
|
|
17
|
-
environments: config.projectIntegration.environments,
|
|
23
|
+
environments: normalizeEnvironments(config.projectIntegration.environments),
|
|
18
24
|
},
|
|
19
25
|
];
|
|
20
26
|
}
|
|
@@ -76,7 +82,7 @@ function handle(config) {
|
|
|
76
82
|
name: config.name,
|
|
77
83
|
logo: (0, util_1.getLogoUrl)(config.customMT, '/mt'),
|
|
78
84
|
url: '/translate',
|
|
79
|
-
environments: config.customMT.environments,
|
|
85
|
+
environments: normalizeEnvironments(config.customMT.environments),
|
|
80
86
|
withContext: !!config.customMT.withContext,
|
|
81
87
|
},
|
|
82
88
|
];
|
|
@@ -98,7 +104,7 @@ function handle(config) {
|
|
|
98
104
|
name: config.profileResourcesMenu.name || config.name,
|
|
99
105
|
url: '/resources/' + (config.profileResourcesMenu.fileName || 'index.html'),
|
|
100
106
|
icon: (0, util_1.getLogoUrl)(config.profileResourcesMenu, '/resources'),
|
|
101
|
-
environments: config.profileResourcesMenu.environments,
|
|
107
|
+
environments: normalizeEnvironments(config.profileResourcesMenu.environments),
|
|
102
108
|
},
|
|
103
109
|
];
|
|
104
110
|
}
|
|
@@ -109,7 +115,7 @@ function handle(config) {
|
|
|
109
115
|
name: config.editorRightPanel.name || config.name,
|
|
110
116
|
url: '/editor-panels/' + (config.editorRightPanel.fileName || 'index.html'),
|
|
111
117
|
modes: config.editorRightPanel.modes,
|
|
112
|
-
environments: config.editorRightPanel.environments,
|
|
118
|
+
environments: normalizeEnvironments(config.editorRightPanel.environments),
|
|
113
119
|
},
|
|
114
120
|
];
|
|
115
121
|
}
|
|
@@ -121,7 +127,7 @@ function handle(config) {
|
|
|
121
127
|
logo: (0, util_1.getLogoUrl)(config.editorThemes, '/editor-themes'),
|
|
122
128
|
styles: config.editorThemes.styles,
|
|
123
129
|
modes: config.editorThemes.modes,
|
|
124
|
-
environments: config.editorThemes.environments,
|
|
130
|
+
environments: normalizeEnvironments(config.editorThemes.environments),
|
|
125
131
|
},
|
|
126
132
|
];
|
|
127
133
|
}
|
|
@@ -131,7 +137,7 @@ function handle(config) {
|
|
|
131
137
|
key: config.identifier + '-project-menu',
|
|
132
138
|
name: config.projectMenu.name || config.name,
|
|
133
139
|
url: '/project-menu/' + (config.projectMenu.fileName || 'index.html'),
|
|
134
|
-
environments: config.projectMenu.environments,
|
|
140
|
+
environments: normalizeEnvironments(config.projectMenu.environments),
|
|
135
141
|
},
|
|
136
142
|
];
|
|
137
143
|
}
|
|
@@ -152,7 +158,7 @@ function handle(config) {
|
|
|
152
158
|
description: config.description,
|
|
153
159
|
logo: (0, util_1.getLogoUrl)(config.projectTools, '/tools'),
|
|
154
160
|
url: '/tools/' + (config.projectTools.fileName || 'index.html'),
|
|
155
|
-
environments: config.projectTools.environments,
|
|
161
|
+
environments: normalizeEnvironments(config.projectTools.environments),
|
|
156
162
|
},
|
|
157
163
|
];
|
|
158
164
|
}
|
|
@@ -173,7 +179,7 @@ function handle(config) {
|
|
|
173
179
|
key: config.identifier + '-modal',
|
|
174
180
|
name: config.modal.name || config.name,
|
|
175
181
|
url: config.modal.url || '/modal/' + (config.modal.fileName || 'index.html'),
|
|
176
|
-
environments: config.modal.environments,
|
|
182
|
+
environments: normalizeEnvironments(config.modal.environments),
|
|
177
183
|
},
|
|
178
184
|
];
|
|
179
185
|
}
|
|
@@ -191,7 +197,7 @@ function handle(config) {
|
|
|
191
197
|
}
|
|
192
198
|
: {})), { url: '/context/' + (config.contextMenu.fileName || 'index.html') }),
|
|
193
199
|
signaturePatterns: config.contextMenu.signaturePatterns,
|
|
194
|
-
environments: config.contextMenu.environments,
|
|
200
|
+
environments: normalizeEnvironments(config.contextMenu.environments),
|
|
195
201
|
},
|
|
196
202
|
];
|
|
197
203
|
}
|
|
@@ -201,21 +207,21 @@ function handle(config) {
|
|
|
201
207
|
if (config.customSpellchecker) {
|
|
202
208
|
const uiModule = config.customSpellchecker.settingsUiModule;
|
|
203
209
|
modules['custom-spellchecker'] = [
|
|
204
|
-
Object.assign({ key: config.identifier + '-spellchecker', name: config.customSpellchecker.name || config.name, description: config.customSpellchecker.description || config.description, listSupportedLanguagesUrl: '/languages', checkSpellingUrl: '/spellcheck', environments: config.customSpellchecker.environments }, (uiModule ? { url: '/settings/' + (uiModule.fileName || 'index.html') } : {})),
|
|
210
|
+
Object.assign({ key: config.identifier + '-spellchecker', name: config.customSpellchecker.name || config.name, description: config.customSpellchecker.description || config.description, listSupportedLanguagesUrl: '/languages', checkSpellingUrl: '/spellcheck', environments: normalizeEnvironments(config.customSpellchecker.environments) }, (uiModule ? { url: '/settings/' + (uiModule.fileName || 'index.html') } : {})),
|
|
205
211
|
];
|
|
206
212
|
}
|
|
207
213
|
const events = {
|
|
208
214
|
installed: '/installed',
|
|
209
215
|
uninstall: '/uninstall',
|
|
210
216
|
};
|
|
211
|
-
if (!(0,
|
|
217
|
+
if (!(0, subscription_1.isAppFree)(config)) {
|
|
212
218
|
events['subscription_paid'] = '/subscription-paid';
|
|
213
219
|
}
|
|
214
220
|
return (_req, res) => {
|
|
215
221
|
const manifest = Object.assign(Object.assign({ identifier: config.identifier, name: config.name, logo: (0, util_1.getLogoUrl)(), baseUrl: config.baseUrl, authentication: {
|
|
216
|
-
type: config.authenticationType ||
|
|
222
|
+
type: config.authenticationType || types_1.AuthenticationType.APP,
|
|
217
223
|
clientId: config.clientId,
|
|
218
|
-
}, events, scopes: config.scopes ? config.scopes : [
|
|
224
|
+
}, events, scopes: config.scopes ? config.scopes : [types_1.Scope.PROJECTS] }, (config.defaultPermissions && { default_permissions: config.defaultPermissions })), { modules });
|
|
219
225
|
res.send(manifest);
|
|
220
226
|
};
|
|
221
227
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.register = void 0;
|
|
7
|
+
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
8
|
+
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
9
|
+
const util_1 = require("../../util");
|
|
10
|
+
function register({ config, app }) {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
|
|
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
|
+
app.use('/modal', (0, ui_module_1.default)(config, allowUnauthorized), (0, render_ui_module_1.default)(config.modal));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.register = register;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.register = void 0;
|
|
7
|
+
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
8
|
+
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
9
|
+
const util_1 = require("../../util");
|
|
10
|
+
function register({ config, app }) {
|
|
11
|
+
if (!config.organizationMenu) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
|
|
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); });
|
|
16
|
+
app.use('/resources', (0, ui_module_1.default)(config, allowUnauthorized), (0, render_ui_module_1.default)(config.organizationMenu));
|
|
17
|
+
}
|
|
18
|
+
exports.register = register;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.register = void 0;
|
|
7
|
+
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
8
|
+
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
9
|
+
const util_1 = require("../../util");
|
|
10
|
+
function register({ config, app }) {
|
|
11
|
+
if (!config.profileResourcesMenu) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
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); });
|
|
15
|
+
const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
|
|
16
|
+
app.use('/resources', (0, ui_module_1.default)(config, allowUnauthorized), (0, render_ui_module_1.default)(config.profileResourcesMenu));
|
|
17
|
+
}
|
|
18
|
+
exports.register = register;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.register = void 0;
|
|
7
|
+
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
8
|
+
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
9
|
+
const util_1 = require("../../util");
|
|
10
|
+
function register({ config, app }) {
|
|
11
|
+
if (!config.projectMenu) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
|
|
15
|
+
app.use('/project-menu', (0, ui_module_1.default)(config, allowUnauthorized), (0, render_ui_module_1.default)(config.projectMenu));
|
|
16
|
+
}
|
|
17
|
+
exports.register = register;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.register = void 0;
|
|
7
|
+
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
8
|
+
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
9
|
+
const util_1 = require("../../util");
|
|
10
|
+
function register({ config, app }) {
|
|
11
|
+
if (!config.projectMenuCrowdsource) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
|
|
15
|
+
app.use('/project-menu-crowdsource', (0, ui_module_1.default)(config, allowUnauthorized), (0, render_ui_module_1.default)(config.projectMenuCrowdsource));
|
|
16
|
+
}
|
|
17
|
+
exports.register = register;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.register = void 0;
|
|
7
|
+
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
8
|
+
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
9
|
+
const util_1 = require("../../util");
|
|
10
|
+
function register({ config, app }) {
|
|
11
|
+
if (!config.projectReports) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
|
|
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); });
|
|
16
|
+
app.use('/reports', (0, ui_module_1.default)(config, allowUnauthorized), (0, render_ui_module_1.default)(config.projectReports));
|
|
17
|
+
}
|
|
18
|
+
exports.register = register;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.register = void 0;
|
|
7
|
+
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
8
|
+
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
9
|
+
const util_1 = require("../../util");
|
|
10
|
+
function register({ config, app }) {
|
|
11
|
+
if (!config.projectTools) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
|
|
15
|
+
app.get((0, util_1.getLogoUrl)(config.projectTools, '/tools'), (req, res) => { var _a; return res.sendFile(((_a = config.projectTools) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
|
|
16
|
+
app.use('/tools', (0, ui_module_1.default)(config, allowUnauthorized), (0, render_ui_module_1.default)(config.projectTools));
|
|
17
|
+
}
|
|
18
|
+
exports.register = register;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
export default function handle(): (req: import("../types").CrowdinClientRequest | Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
|