@crowdin/app-project-module 0.28.3 → 0.28.5

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.
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const models_1 = require("../models");
4
4
  const connection_1 = require("../util/connection");
5
+ const util_1 = require("../util");
5
6
  function handle(config) {
6
7
  const modules = {};
7
8
  if (config.projectIntegration) {
@@ -10,7 +11,7 @@ function handle(config) {
10
11
  key: config.identifier + '-int',
11
12
  name: config.name,
12
13
  description: config.description,
13
- logo: '/logo/integration/logo.png',
14
+ logo: (0, util_1.getLogoUrl)(config, config.projectIntegration, '/integration'),
14
15
  url: '/',
15
16
  environments: config.projectIntegration.environments,
16
17
  },
@@ -72,9 +73,10 @@ function handle(config) {
72
73
  {
73
74
  key: config.identifier + '-mt',
74
75
  name: config.name,
75
- logo: '/logo/mt/logo.png',
76
+ logo: (0, util_1.getLogoUrl)(config, config.customMT, '/mt'),
76
77
  url: '/translate',
77
78
  environments: config.customMT.environments,
79
+ withContext: !!config.customMT.withContext,
78
80
  },
79
81
  ];
80
82
  }
@@ -84,7 +86,7 @@ function handle(config) {
84
86
  key: config.identifier + '-resources',
85
87
  name: config.name,
86
88
  url: '/resources/' + (config.organizationMenu.fileName || 'index.html'),
87
- icon: '/logo/resources/logo.png',
89
+ icon: (0, util_1.getLogoUrl)(config, config.organizationMenu, '/resources'),
88
90
  },
89
91
  ];
90
92
  }
@@ -94,7 +96,7 @@ function handle(config) {
94
96
  key: config.identifier + '-profile-resources-menu',
95
97
  name: config.name,
96
98
  url: '/resources/' + (config.profileResourcesMenu.fileName || 'index.html'),
97
- icon: '/logo/resources/logo.png',
99
+ icon: (0, util_1.getLogoUrl)(config, config.profileResourcesMenu, '/resources'),
98
100
  environments: config.profileResourcesMenu.environments,
99
101
  },
100
102
  ];
@@ -135,7 +137,7 @@ function handle(config) {
135
137
  key: config.identifier + '-tools',
136
138
  name: config.name,
137
139
  description: config.description,
138
- logo: '/logo/tools/logo.png',
140
+ logo: (0, util_1.getLogoUrl)(config, config.projectTools, '/tools'),
139
141
  url: '/tools/' + (config.projectTools.fileName || 'index.html'),
140
142
  environments: config.projectTools.environments,
141
143
  },
@@ -147,7 +149,7 @@ function handle(config) {
147
149
  key: config.identifier + '-project-reports',
148
150
  name: config.name,
149
151
  description: config.description,
150
- logo: '/logo/reports/logo.png',
152
+ logo: (0, util_1.getLogoUrl)(config, config.projectReports, '/reports'),
151
153
  url: '/reports/' + (config.projectReports.fileName || 'index.html'),
152
154
  },
153
155
  ];
@@ -190,7 +192,7 @@ function handle(config) {
190
192
  const manifest = {
191
193
  identifier: config.identifier,
192
194
  name: config.name,
193
- logo: '/logo.png',
195
+ logo: (0, util_1.getLogoUrl)(config),
194
196
  baseUrl: config.baseUrl,
195
197
  authentication: {
196
198
  type: config.authenticationType || models_1.AuthenticationType.APP,
package/out/index.js CHANGED
@@ -119,7 +119,7 @@ function addCrowdinEndpoints(app, clientConfig) {
119
119
  },
120
120
  }));
121
121
  app.set('view engine', 'handlebars');
122
- app.get('/logo.png', (req, res) => res.sendFile(config.imagePath));
122
+ app.get((0, util_1.getLogoUrl)(config), (req, res) => res.sendFile(config.imagePath));
123
123
  app.post('/installed', (0, install_1.default)(config));
124
124
  app.post('/uninstall', (0, uninstall_1.default)(config));
125
125
  app.get('/manifest.json', json_response_1.default, (0, manifest_1.default)(config));
@@ -129,7 +129,7 @@ function addCrowdinEndpoints(app, clientConfig) {
129
129
  const integrationLogic = config.projectIntegration;
130
130
  if (integrationLogic) {
131
131
  (0, defaults_1.applyIntegrationModuleDefaults)(config, integrationLogic);
132
- app.get('/logo/integration/logo.png', (req, res) => res.sendFile(integrationLogic.imagePath || config.imagePath));
132
+ app.get((0, util_1.getLogoUrl)(config, integrationLogic, '/integration'), (req, res) => res.sendFile(integrationLogic.imagePath || config.imagePath));
133
133
  app.get('/', (0, crowdin_client_1.default)(config, true, false), (0, integration_credentials_1.default)(config, integrationLogic, true), (0, main_1.default)(config, integrationLogic));
134
134
  app.get('/api/subscription-info', json_response_1.default, (0, crowdin_client_1.default)(config), (0, subscription_info_1.default)(config));
135
135
  app.post('/api/settings', (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, settings_save_1.default)(config, integrationLogic));
@@ -194,15 +194,15 @@ function addCrowdinEndpoints(app, clientConfig) {
194
194
  app.get(`/file/download/${models_1.ProcessFileJobType.POST_EXPORT}`, (0, file_download_1.default)(config, config.filePostExport, models_1.ProcessFileJobType.POST_EXPORT));
195
195
  }
196
196
  if (config.customMT) {
197
- app.get('/logo/mt/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.customMT) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
197
+ app.get((0, util_1.getLogoUrl)(config, config.customMT, '/mt'), (req, res) => { var _a; return res.sendFile(((_a = config.customMT) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
198
198
  app.post('/translate', (0, crowdin_client_1.default)(config), (0, translate_1.default)(config, config.customMT));
199
199
  }
200
200
  if (config.profileResourcesMenu) {
201
- app.get('/logo/resources/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.profileResourcesMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
201
+ app.get((0, util_1.getLogoUrl)(config, config.profileResourcesMenu, '/resources'), (req, res) => { var _a; return res.sendFile(((_a = config.profileResourcesMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
202
202
  app.use('/resources', (0, ui_module_1.default)(config, config.profileResourcesMenu.allowUnauthorized), (0, render_ui_module_1.default)(config, config.profileResourcesMenu));
203
203
  }
204
204
  if (config.organizationMenu) {
205
- app.get('/logo/resources/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.organizationMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
205
+ app.get((0, util_1.getLogoUrl)(config, config.organizationMenu, '/resources'), (req, res) => { var _a; return res.sendFile(((_a = config.organizationMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
206
206
  app.use('/resources', (0, ui_module_1.default)(config, config.organizationMenu.allowUnauthorized), (0, render_ui_module_1.default)(config, config.organizationMenu));
207
207
  }
208
208
  if (config.editorRightPanel) {
@@ -215,11 +215,11 @@ function addCrowdinEndpoints(app, clientConfig) {
215
215
  app.use('/project-menu-crowdsource', (0, ui_module_1.default)(config, config.projectMenuCrowdsource.allowUnauthorized), (0, render_ui_module_1.default)(config, config.projectMenuCrowdsource));
216
216
  }
217
217
  if (config.projectTools) {
218
- app.get('/logo/tools/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.projectTools) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
218
+ app.get((0, util_1.getLogoUrl)(config, config.projectTools, '/tools'), (req, res) => { var _a; return res.sendFile(((_a = config.projectTools) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
219
219
  app.use('/tools', (0, ui_module_1.default)(config, config.projectTools.allowUnauthorized), (0, render_ui_module_1.default)(config, config.projectTools));
220
220
  }
221
221
  if (config.projectReports) {
222
- app.get('/logo/reports/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.projectReports) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
222
+ app.get((0, util_1.getLogoUrl)(config, config.projectReports, '/reports'), (req, res) => { var _a; return res.sendFile(((_a = config.projectReports) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
223
223
  app.use('/reports', (0, ui_module_1.default)(config, config.projectReports.allowUnauthorized), (0, render_ui_module_1.default)(config, config.projectReports));
224
224
  }
225
225
  if (((_d = config.modal) === null || _d === void 0 ? void 0 : _d.uiPath) || ((_e = config.modal) === null || _e === void 0 ? void 0 : _e.formSchema)) {
@@ -632,12 +632,25 @@ export interface StringTranslations {
632
632
  };
633
633
  }
634
634
  export interface CustomMTLogic {
635
- translate: (client: Crowdin, context: CrowdinContextInfo, projectId: number, source: string, target: string, strings: string[]) => Promise<string[]>;
635
+ withContext?: boolean;
636
+ translate: (client: Crowdin, context: CrowdinContextInfo, projectId: number, source: string, target: string, strings: CustomMtString[]) => Promise<string[]>;
636
637
  validate?: (client: Crowdin) => Promise<void>;
637
638
  }
638
639
  export interface CustomMTRequest {
639
- strings: string[];
640
+ strings: CustomMtString[];
640
641
  }
642
+ export type CustomMtString = string | {
643
+ id: number;
644
+ projectId: number;
645
+ fileId: number;
646
+ identifier: string;
647
+ context: string;
648
+ maxLength: number;
649
+ isHidden: boolean;
650
+ text: string | SourceStringsModel.PluralText;
651
+ isPlural: boolean;
652
+ pluralForm: any;
653
+ };
641
654
  export interface UiModule {
642
655
  /**
643
656
  * Form schema for react-jsonschema-doc to be used as front-end
@@ -727,7 +740,7 @@ export interface IntegrationSyncSettings {
727
740
  crowdinId: string;
728
741
  provider: 'integration' | 'crowdin';
729
742
  }
730
- interface ImagePath {
743
+ export interface ImagePath {
731
744
  /**
732
745
  * path to app logo (e.g. {@example join(__dirname, 'logo.png')})
733
746
  */