@crowdin/app-project-module 0.65.1 → 0.65.2
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.js +2 -2
- package/out/modules/form-data-display.d.ts +2 -2
- package/out/modules/form-data-display.js +5 -2
- package/out/modules/form-data-save.d.ts +2 -2
- package/out/modules/form-data-save.js +5 -2
- package/out/modules/integration/handlers/crowdin-webhook.js +1 -1
- package/out/modules/integration/types.d.ts +4 -0
- package/out/modules/integration/util/cron.d.ts +1 -1
- package/out/modules/integration/util/cron.js +7 -4
- package/out/modules/integration/util/job.js +1 -1
- package/out/static/js/form.js +12 -12
- package/out/storage/mysql.js +2 -2
- package/out/storage/postgre.js +2 -2
- package/out/storage/sqlite.js +2 -2
- package/out/util/credentials-masker.d.ts +4 -1
- package/out/util/credentials-masker.js +11 -6
- package/out/util/index.d.ts +1 -0
- package/out/util/index.js +18 -1
- package/package.json +9 -9
package/out/index.js
CHANGED
|
@@ -206,8 +206,8 @@ function addFormSchema({ app, config }) {
|
|
|
206
206
|
return false;
|
|
207
207
|
});
|
|
208
208
|
if (shouldAddRoutes) {
|
|
209
|
-
app.get('/api/form-data', json_response_1.default, (0, crowdin_client_1.default)(config), (0, credentials_masker_1.getRequestCredentialsMasker)(moduleConfigWithForm), (0, form_data_display_1.default)());
|
|
210
|
-
app.post('/api/form-data', (0, crowdin_client_1.default)(config), (0, credentials_masker_1.postRequestCredentialsMasker)(moduleConfigWithForm), (0, form_data_save_1.default)());
|
|
209
|
+
app.get('/api/form-data', json_response_1.default, (0, crowdin_client_1.default)(config), (0, credentials_masker_1.getRequestCredentialsMasker)({ moduleConfig: moduleConfigWithForm }), (0, form_data_display_1.default)(config));
|
|
210
|
+
app.post('/api/form-data', (0, crowdin_client_1.default)(config), (0, credentials_masker_1.postRequestCredentialsMasker)(moduleConfigWithForm), (0, form_data_save_1.default)(config));
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
function convertClientConfig(clientConfig) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
|
-
import { CrowdinClientRequest } from '../types';
|
|
2
|
+
import { Config, CrowdinClientRequest } from '../types';
|
|
3
3
|
import { Response } from 'express';
|
|
4
|
-
export default function handle(): (req: CrowdinClientRequest | 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;
|
|
4
|
+
export default function handle(config: Config): (req: CrowdinClientRequest | 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;
|
|
@@ -34,9 +34,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
const util_1 = require("../util");
|
|
36
36
|
const storage = __importStar(require("../storage"));
|
|
37
|
-
function handle() {
|
|
37
|
+
function handle(config) {
|
|
38
38
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
const id = req
|
|
39
|
+
const id = yield (0, util_1.prepareFormDataMetadataId)(req, config);
|
|
40
|
+
if (id !== req.query.id) {
|
|
41
|
+
return res.status(403).send({ error: 'Access denied' });
|
|
42
|
+
}
|
|
40
43
|
const data = (yield storage.getStorage().getMetadata(id)) || {};
|
|
41
44
|
return res.send({
|
|
42
45
|
formData: data,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
|
-
import { CrowdinClientRequest } from '../types';
|
|
2
|
+
import { Config, CrowdinClientRequest } from '../types';
|
|
3
3
|
import { Response } from 'express';
|
|
4
|
-
export default function handle(): (req: CrowdinClientRequest | 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;
|
|
4
|
+
export default function handle(config: Config): (req: CrowdinClientRequest | 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;
|
|
@@ -34,9 +34,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
const util_1 = require("../util");
|
|
36
36
|
const storage = __importStar(require("../storage"));
|
|
37
|
-
function handle() {
|
|
37
|
+
function handle(config) {
|
|
38
38
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
const id = req
|
|
39
|
+
const id = yield (0, util_1.prepareFormDataMetadataId)(req, config);
|
|
40
|
+
if (id !== req.query.id) {
|
|
41
|
+
return res.status(403).send({ error: 'Access denied' });
|
|
42
|
+
}
|
|
40
43
|
const metadata = req.body.data;
|
|
41
44
|
const existing = yield storage.getStorage().getMetadata(id);
|
|
42
45
|
try {
|
|
@@ -108,7 +108,7 @@ function handle(config, integration) {
|
|
|
108
108
|
delete syncFileSettings[eventPayload.fileId];
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
const crowdinFiles = yield (0, cron_1.
|
|
111
|
+
const crowdinFiles = yield (0, cron_1.filterFilesFromIntegrationRequest)({
|
|
112
112
|
config,
|
|
113
113
|
integration,
|
|
114
114
|
projectId,
|
|
@@ -146,6 +146,10 @@ export interface IntegrationLogic {
|
|
|
146
146
|
* The duration for storing user errors, default is 30 days.
|
|
147
147
|
*/
|
|
148
148
|
userErrorLifetimeDays: number;
|
|
149
|
+
/**
|
|
150
|
+
* When true, folder filtering during automatic translation sync is bypassed, and the file tree is returned unchanged.
|
|
151
|
+
*/
|
|
152
|
+
skipAutoSyncFoldersFilter?: boolean;
|
|
149
153
|
}
|
|
150
154
|
export interface LoginForm {
|
|
151
155
|
fields: FormEntity[];
|
|
@@ -28,7 +28,7 @@ export declare function filesCron({ config, integration, period, }: {
|
|
|
28
28
|
integration: IntegrationLogic;
|
|
29
29
|
period: string;
|
|
30
30
|
}): Promise<void>;
|
|
31
|
-
export declare function
|
|
31
|
+
export declare function filterFilesFromIntegrationRequest({ config, integration, projectId, crowdinClient, crowdinFiles, }: {
|
|
32
32
|
config: Config;
|
|
33
33
|
integration: IntegrationLogic;
|
|
34
34
|
projectId: number;
|
|
@@ -32,7 +32,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.removeFinishedJobs = exports.createOrUpdateSyncSettings = exports.
|
|
35
|
+
exports.removeFinishedJobs = exports.createOrUpdateSyncSettings = exports.filterFilesFromIntegrationRequest = exports.filesCron = exports.runUpdateProviderJob = exports.runJob = void 0;
|
|
36
36
|
const crowdinAppFunctions = __importStar(require("@crowdin/crowdin-apps-functions"));
|
|
37
37
|
const storage_1 = require("../../../storage");
|
|
38
38
|
const connection_1 = require("../../../util/connection");
|
|
@@ -249,7 +249,7 @@ function processSyncSettings({ config, integration, period, syncSettings, }) {
|
|
|
249
249
|
yield (0, storage_1.getStorage)().deleteWebhooks(webhooksFileIds, syncSettings.integrationId, syncSettings.crowdinId, syncSettings.provider);
|
|
250
250
|
}
|
|
251
251
|
if (syncSettings.provider === types_1.Provider.CROWDIN) {
|
|
252
|
-
const crowdinFiles = yield
|
|
252
|
+
const crowdinFiles = yield filterFilesFromIntegrationRequest({
|
|
253
253
|
config,
|
|
254
254
|
integration,
|
|
255
255
|
projectId,
|
|
@@ -468,9 +468,12 @@ function getOnlyTranslatedOrApprovedFiles({ projectId, crowdinFiles, crowdinClie
|
|
|
468
468
|
return filteredFiles;
|
|
469
469
|
});
|
|
470
470
|
}
|
|
471
|
-
function
|
|
471
|
+
function filterFilesFromIntegrationRequest({ config, integration, projectId, crowdinClient, crowdinFiles, }) {
|
|
472
472
|
var _a;
|
|
473
473
|
return __awaiter(this, void 0, void 0, function* () {
|
|
474
|
+
if (integration.skipAutoSyncFoldersFilter) {
|
|
475
|
+
return crowdinFiles;
|
|
476
|
+
}
|
|
474
477
|
let folders;
|
|
475
478
|
if ((_a = config.projectIntegration) === null || _a === void 0 ? void 0 : _a.withRootFolder) {
|
|
476
479
|
const rootFolder = yield (0, defaults_1.getRootFolder)(config, integration, crowdinClient, projectId);
|
|
@@ -494,7 +497,7 @@ function skipFoldersFromIntegrationRequest({ config, integration, projectId, cro
|
|
|
494
497
|
return crowdinFiles;
|
|
495
498
|
});
|
|
496
499
|
}
|
|
497
|
-
exports.
|
|
500
|
+
exports.filterFilesFromIntegrationRequest = filterFilesFromIntegrationRequest;
|
|
498
501
|
function createOrUpdateSyncSettings({ req, files, provider, onlyCreate = false, }) {
|
|
499
502
|
return __awaiter(this, void 0, void 0, function* () {
|
|
500
503
|
const existingSettings = yield (0, storage_1.getStorage)().getSyncSettings(req.crowdinContext.clientId, req.crowdinContext.crowdinId, 'schedule', provider);
|
|
@@ -179,7 +179,7 @@ function reRunInProgressJobs(config) {
|
|
|
179
179
|
return;
|
|
180
180
|
}
|
|
181
181
|
yield Promise.all(inProgressJobs.map((activeJob) => __awaiter(this, void 0, void 0, function* () {
|
|
182
|
-
if (activeJob &&
|
|
182
|
+
if (activeJob && ![types_1.JobStatus.IN_PROGRESS, types_1.JobStatus.CREATED].includes(activeJob.status)) {
|
|
183
183
|
return;
|
|
184
184
|
}
|
|
185
185
|
if (activeJob.attempt && activeJob.attempt >= maxAttempts) {
|