@crowdin/app-project-module 0.29.1 → 0.29.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/handlers/crowdin-webhook.js +11 -2
- package/out/handlers/form-data-save.js +2 -2
- package/out/handlers/integration-webhook.js +1 -1
- package/out/index.js +3 -3
- package/out/models/index.d.ts +8 -3
- package/out/static/js/form.js +32 -32
- package/out/storage/index.d.ts +2 -2
- package/out/storage/mysql.d.ts +2 -2
- package/out/storage/mysql.js +15 -5
- package/out/storage/postgre.d.ts +2 -2
- package/out/storage/postgre.js +15 -5
- package/out/storage/sqlite.d.ts +3 -2
- package/out/storage/sqlite.js +26 -11
- package/out/util/api/api.js +17 -2
- package/out/util/cron.d.ts +3 -1
- package/out/util/cron.js +2 -1
- package/out/util/webhooks.d.ts +2 -3
- package/out/util/webhooks.js +18 -4
- package/out/views/form.handlebars +1 -0
- package/package.json +1 -1
|
@@ -12,6 +12,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
const models_1 = require("../models");
|
|
13
13
|
const util_1 = require("../util");
|
|
14
14
|
const webhooks_1 = require("../util/webhooks");
|
|
15
|
+
const storage_1 = require("../storage");
|
|
16
|
+
const file_snapshot_1 = require("../util/file-snapshot");
|
|
17
|
+
const cron_1 = require("../util/cron");
|
|
15
18
|
function handle(config, integration) {
|
|
16
19
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
17
20
|
var _a, _b;
|
|
@@ -27,12 +30,18 @@ function handle(config, integration) {
|
|
|
27
30
|
return res.status(200).send({ message: 'Sync is not configured' });
|
|
28
31
|
}
|
|
29
32
|
if ((_b = integration.webhooks) === null || _b === void 0 ? void 0 : _b.crowdinWebhookInterceptor) {
|
|
30
|
-
filesToSync = yield integration.webhooks.crowdinWebhookInterceptor(projectId, crowdinClient.client, rootFolder, appSettings, syncSettings, req.body
|
|
33
|
+
filesToSync = yield integration.webhooks.crowdinWebhookInterceptor(projectId, crowdinClient.client, rootFolder, appSettings, syncSettings, req.body);
|
|
31
34
|
}
|
|
32
35
|
else {
|
|
33
36
|
filesToSync = (0, webhooks_1.filterSyncFiles)(req.body.events, JSON.parse(syncSettings.files));
|
|
34
37
|
}
|
|
35
|
-
const
|
|
38
|
+
const crowdinFiles = yield (0, cron_1.skipFoldersFromIntegrationRequest)(config, integration, projectId, Object.assign(Object.assign({}, filesToSync), newFiles), crowdinClient.client);
|
|
39
|
+
const result = yield integration.updateIntegration(projectId, crowdinClient.client, preparedIntegrationCredentials, crowdinFiles, rootFolder, appSettings);
|
|
40
|
+
if (newFiles) {
|
|
41
|
+
yield (0, storage_1.getStorage)().updateSyncSettings(JSON.stringify(Object.assign(Object.assign({}, filesToSync), newFiles)), syncSettings.integrationId, syncSettings.crowdinId, 'schedule', syncSettings.provider);
|
|
42
|
+
const currentFileSnapshot = yield (0, file_snapshot_1.getCrowdinSnapshot)(config, integration, crowdinClient.client, projectId, appSettings);
|
|
43
|
+
yield (0, storage_1.getStorage)().updateFilesSnapshot(JSON.stringify(currentFileSnapshot), syncSettings.integrationId, syncSettings.crowdinId, syncSettings.provider);
|
|
44
|
+
}
|
|
36
45
|
let message;
|
|
37
46
|
if ((0, util_1.isExtendedResultType)(result)) {
|
|
38
47
|
message = result.message;
|
|
@@ -41,10 +41,10 @@ function handle() {
|
|
|
41
41
|
const existing = yield storage.getStorage().getMetadata(id);
|
|
42
42
|
try {
|
|
43
43
|
if (!!existing) {
|
|
44
|
-
yield storage.getStorage().updateMetadata(id, metadata);
|
|
44
|
+
yield storage.getStorage().updateMetadata(id, metadata, req.crowdinContext.crowdinId);
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
|
-
yield storage.getStorage().saveMetadata(id, metadata);
|
|
47
|
+
yield storage.getStorage().saveMetadata(id, metadata, req.crowdinContext.crowdinId);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
catch (e) {
|
|
@@ -25,7 +25,7 @@ function handle(config, integration) {
|
|
|
25
25
|
if (!webhookData.syncSettings) {
|
|
26
26
|
return res.status(200).send({ message: 'Sync is not configured' });
|
|
27
27
|
}
|
|
28
|
-
const result = yield (0, webhooks_1.updateCrowdinFromWebhookRequest)(integration, webhookData, req);
|
|
28
|
+
const result = yield (0, webhooks_1.updateCrowdinFromWebhookRequest)({ integration, webhookData, req });
|
|
29
29
|
let message;
|
|
30
30
|
if ((0, util_1.isExtendedResultType)(result)) {
|
|
31
31
|
message = result.message;
|
package/out/index.js
CHANGED
|
@@ -244,13 +244,13 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
244
244
|
}
|
|
245
245
|
return {
|
|
246
246
|
getMetadata: storage.getStorage().getMetadata.bind(storage.getStorage()),
|
|
247
|
-
saveMetadata: (id, metadata) => __awaiter(this, void 0, void 0, function* () {
|
|
247
|
+
saveMetadata: (id, metadata, crowdinId) => __awaiter(this, void 0, void 0, function* () {
|
|
248
248
|
const existing = yield storage.getStorage().getMetadata(id);
|
|
249
249
|
if (existing) {
|
|
250
|
-
yield storage.getStorage().updateMetadata(id, metadata);
|
|
250
|
+
yield storage.getStorage().updateMetadata(id, metadata, crowdinId);
|
|
251
251
|
}
|
|
252
252
|
else {
|
|
253
|
-
yield storage.getStorage().saveMetadata(id, metadata);
|
|
253
|
+
yield storage.getStorage().saveMetadata(id, metadata, crowdinId);
|
|
254
254
|
}
|
|
255
255
|
}),
|
|
256
256
|
deleteMetadata: storage.getStorage().deleteMetadata.bind(storage.getStorage()),
|
package/out/models/index.d.ts
CHANGED
|
@@ -745,7 +745,7 @@ export declare enum ContextOptionsTypes {
|
|
|
745
745
|
REDIRECT = "redirect"
|
|
746
746
|
}
|
|
747
747
|
export interface CrowdinAppUtilities {
|
|
748
|
-
saveMetadata: (id: string, metadata: any) => Promise<void>;
|
|
748
|
+
saveMetadata: (id: string, metadata: any, crowdinId?: string) => Promise<void>;
|
|
749
749
|
getMetadata: (id: string) => Promise<any | undefined>;
|
|
750
750
|
deleteMetadata: (id: string) => Promise<void>;
|
|
751
751
|
/**
|
|
@@ -827,8 +827,8 @@ export interface Webhooks {
|
|
|
827
827
|
urlParam?: string;
|
|
828
828
|
crowdinWebhooks?: (client: Crowdin, projectId: number, available: boolean, config?: any) => Promise<void>;
|
|
829
829
|
integrationWebhooks?: (apiCredentials: any, urlParam: string, available: boolean, config?: any, syncSettings?: any) => Promise<void>;
|
|
830
|
-
crowdinWebhookInterceptor?: (projectId: number, client: Crowdin, appRootFolder?: SourceFilesModel.Directory, config?: any, syncSettings?: any, webhookRequest?: any
|
|
831
|
-
integrationWebhookInterceptor?: (projectId: number, client: Crowdin, apiCredentials: any, appRootFolder?: SourceFilesModel.Directory, config?: any, syncSettings?: any, webhookRequest?: any
|
|
830
|
+
crowdinWebhookInterceptor?: (projectId: number, client: Crowdin, appRootFolder?: SourceFilesModel.Directory, config?: any, syncSettings?: any, webhookRequest?: any) => Promise<UpdateIntegrationRequest>;
|
|
831
|
+
integrationWebhookInterceptor?: (projectId: number, client: Crowdin, apiCredentials: any, appRootFolder?: SourceFilesModel.Directory, config?: any, syncSettings?: any, webhookRequest?: any) => Promise<IntegrationFile[]>;
|
|
832
832
|
queueUrl: string;
|
|
833
833
|
}
|
|
834
834
|
export declare enum SyncCondition {
|
|
@@ -863,4 +863,9 @@ export interface GetAllNewFilesArgs {
|
|
|
863
863
|
integrationSettings: any;
|
|
864
864
|
syncSettings: IntegrationSyncSettings;
|
|
865
865
|
}
|
|
866
|
+
export interface UpdateCrowdinWebhookPayloadsArgs {
|
|
867
|
+
integration: IntegrationLogic;
|
|
868
|
+
webhookData: any;
|
|
869
|
+
req: Request;
|
|
870
|
+
}
|
|
866
871
|
export {};
|