@crowdin/app-project-module 0.29.4 → 0.30.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.
@@ -11,9 +11,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const util_1 = require("../util");
13
13
  const defaults_1 = require("../util/defaults");
14
+ const synced_files_1 = require("../util/synced-files");
14
15
  function handle(config, integration) {
15
16
  return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
16
- var _a, _b;
17
+ var _a, _b, _c;
17
18
  const projectId = req.crowdinContext.jwtPayload.context.project_id || (req === null || req === void 0 ? void 0 : req.body.projectId);
18
19
  const uploadTranslations = req.query.uploadTranslations === 'true' || ((_a = req.body) === null || _a === void 0 ? void 0 : _a.uploadTranslations);
19
20
  (0, util_1.log)(`Updating crowdin project ${projectId}`, config.logger);
@@ -27,10 +28,18 @@ function handle(config, integration) {
27
28
  }
28
29
  const result = yield integration.updateCrowdin(projectId, req.crowdinApiClient, req.integrationCredentials, req.body, rootFolder, req.integrationSettings, uploadTranslations);
29
30
  let message;
31
+ let fileIds;
30
32
  if ((0, util_1.isExtendedResultType)(result)) {
31
33
  message = result.message;
34
+ fileIds = result.syncedFiles;
32
35
  }
33
36
  res.send({ message });
37
+ if ((_c = integration.filtering) === null || _c === void 0 ? void 0 : _c.syncStatus) {
38
+ if (!fileIds) {
39
+ fileIds = req.body.map((file) => file.id);
40
+ }
41
+ (0, synced_files_1.createOrUpdateSyncedFiles)({ config, req, fileIds });
42
+ }
34
43
  }), config.onError);
35
44
  }
36
45
  exports.default = handle;
@@ -45,6 +45,7 @@ function handle(config, integration) {
45
45
  }
46
46
  options.infoModal = integration.infoModal;
47
47
  options.syncNewElements = integration.syncNewElements;
48
+ options.filtering = integration.filtering;
48
49
  options.withCronSync = integration.withCronSync;
49
50
  options.webhooks = integration.webhooks
50
51
  ? {
@@ -0,0 +1,4 @@
1
+ /// <reference types="qs" />
2
+ import { Response } from 'express';
3
+ import { Config } from '../models';
4
+ export default function handle(config: Config): (req: 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;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const storage_1 = require("../storage");
13
+ const util_1 = require("../util");
14
+ function handle(config) {
15
+ return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
16
+ let fileIds = [];
17
+ (0, util_1.log)('Loading synced files', config.logger);
18
+ const syncedFiles = yield (0, storage_1.getStorage)().getSyncedFiles(req.crowdinContext.clientId, req.crowdinContext.crowdinId);
19
+ if (syncedFiles) {
20
+ fileIds = JSON.parse(syncedFiles.fileIds) || [];
21
+ }
22
+ (0, util_1.log)(`Returning synced files ${JSON.stringify(fileIds, null, 2)}`, config.logger);
23
+ res.send(fileIds);
24
+ }), config.onError);
25
+ }
26
+ exports.default = handle;
package/out/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { Express } from 'express';
2
+ import express from './util/terminus-express';
2
3
  import { ClientConfig, Config, CrowdinAppUtilities } from './models';
3
4
  export { Scope } from './models';
5
+ export { express };
4
6
  export declare function addCrowdinEndpoints(app: Express, clientConfig: Config | ClientConfig): CrowdinAppUtilities;
5
7
  export declare function createApp(clientConfig: ClientConfig): void;
package/out/index.js CHANGED
@@ -35,11 +35,12 @@ 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.createApp = exports.addCrowdinEndpoints = exports.Scope = void 0;
39
- const express_1 = __importDefault(require("express"));
38
+ exports.createApp = exports.addCrowdinEndpoints = exports.express = exports.Scope = void 0;
40
39
  const express_handlebars_1 = __importDefault(require("express-handlebars"));
41
40
  const cron = __importStar(require("node-cron"));
42
41
  const path_1 = require("path");
42
+ const terminus_express_1 = __importDefault(require("./util/terminus-express"));
43
+ exports.express = terminus_express_1.default;
43
44
  const crowdin_file_progress_1 = __importDefault(require("./handlers/crowdin-file-progress"));
44
45
  const crowdin_files_1 = __importDefault(require("./handlers/crowdin-files"));
45
46
  const crowdin_project_1 = __importDefault(require("./handlers/crowdin-project"));
@@ -66,6 +67,7 @@ const subscription_info_1 = __importDefault(require("./handlers/subscription-inf
66
67
  const subscription_paid_1 = __importDefault(require("./handlers/subscription-paid"));
67
68
  const sync_settings_1 = __importDefault(require("./handlers/sync-settings"));
68
69
  const sync_settings_save_1 = __importDefault(require("./handlers/sync-settings-save"));
70
+ const synced_files_1 = __importDefault(require("./handlers/synced-files"));
69
71
  const uninstall_1 = __importDefault(require("./handlers/uninstall"));
70
72
  const crowdin_client_1 = __importStar(require("./middlewares/crowdin-client"));
71
73
  const integration_credentials_1 = __importDefault(require("./middlewares/integration-credentials"));
@@ -89,8 +91,8 @@ function addCrowdinEndpoints(app, clientConfig) {
89
91
  handleUncaughtErrors(config);
90
92
  }
91
93
  storage.initialize(config);
92
- app.use(express_1.default.json({ limit: '50mb' }));
93
- app.use('/assets', express_1.default.static((0, path_1.join)(__dirname, 'static')));
94
+ app.use(terminus_express_1.default.json({ limit: '50mb' }));
95
+ app.use('/assets', terminus_express_1.default.static((0, path_1.join)(__dirname, 'static')));
94
96
  app.set('views', (0, path_1.join)(__dirname, 'views'));
95
97
  app.engine('handlebars', (0, express_handlebars_1.default)({
96
98
  layoutsDir: '',
@@ -144,6 +146,7 @@ function addCrowdinEndpoints(app, clientConfig) {
144
146
  app.post('/api/integration/update', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, integration_update_1.default)(config, integrationLogic));
145
147
  app.get('/api/sync-settings/:provider', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, sync_settings_1.default)(config));
146
148
  app.post('/api/sync-settings', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, sync_settings_save_1.default)(config, integrationLogic));
149
+ app.get('/api/synced-files', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, synced_files_1.default)(config));
147
150
  if (integrationLogic.oauthLogin) {
148
151
  app.get((0, defaults_1.getOauthRoute)(integrationLogic), (0, oauth_login_1.default)(config, integrationLogic));
149
152
  app.post('/api/oauth-url', json_response_1.default, (0, crowdin_client_1.default)(config, false, false), (0, oauth_url_1.default)(config, integrationLogic));
@@ -284,7 +287,7 @@ function addCrowdinEndpoints(app, clientConfig) {
284
287
  }
285
288
  exports.addCrowdinEndpoints = addCrowdinEndpoints;
286
289
  function createApp(clientConfig) {
287
- const app = (0, express_1.default)();
290
+ const app = (0, terminus_express_1.default)();
288
291
  const config = (0, defaults_1.convertClientConfig)(clientConfig);
289
292
  addCrowdinEndpoints(app, config);
290
293
  /* eslint no-console: "off" */
@@ -254,6 +254,10 @@ export interface IntegrationLogic {
254
254
  crowdin: boolean;
255
255
  integration: boolean;
256
256
  };
257
+ filtering?: {
258
+ crowdinLanguages: boolean;
259
+ syncStatus: boolean;
260
+ };
257
261
  /**
258
262
  * Enable integration folder open event
259
263
  */
@@ -434,6 +438,7 @@ export interface ExtendedResult<T> {
434
438
  data?: T;
435
439
  message?: string;
436
440
  stopPagination?: boolean;
441
+ syncedFiles: string[];
437
442
  }
438
443
  export type TreeItem = File | Folder;
439
444
  /**
@@ -868,4 +873,15 @@ export interface UpdateCrowdinWebhookPayloadsArgs {
868
873
  webhookData: any;
869
874
  req: Request;
870
875
  }
876
+ export interface CreateOrUpdateSyncedFilesArgs {
877
+ config: Config;
878
+ req: IntegrationRequest;
879
+ fileIds: string[];
880
+ }
881
+ export interface IntegrationSyncedFiles {
882
+ id: number;
883
+ fileIds?: any;
884
+ integrationId: string;
885
+ crowdinId: string;
886
+ }
871
887
  export {};
@@ -23,6 +23,12 @@
23
23
  margin-bottom: 10px;
24
24
  }
25
25
 
26
+ .top-button {
27
+ text-align: left;
28
+ display: flex;
29
+ justify-content: space-between;
30
+ }
31
+
26
32
  .login {
27
33
  margin-bottom: 10px;
28
34
  overflow: unset;
@@ -65,6 +71,10 @@
65
71
  margin: 12px 0 12px 0;
66
72
  }
67
73
 
74
+ #subscription-info .ce-alert {
75
+ margin-bottom: 12px;
76
+ }
77
+
68
78
  .dismiss-alert {
69
79
  position: absolute;
70
80
  top: 0;