@crowdin/app-project-module 0.73.2 → 0.74.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.
@@ -10,7 +10,7 @@ export interface ContextModule {
10
10
  /**
11
11
  * Support fileName pattern only. Contains fileName field regular expressions used to detect the file type. If the file name matches any of the regular expressions, the context menu will be displayed.
12
12
  */
13
- signaturePatterns?: SignaturePatterns;
13
+ signaturePatterns?: ContextSignaturePatterns;
14
14
  }
15
15
  export declare enum ContextOptionsLocations {
16
16
  TM = "tm",
@@ -25,3 +25,7 @@ export declare enum ContextOptionsTypes {
25
25
  NEW_TAB = "new_tab",
26
26
  REDIRECT = "redirect"
27
27
  }
28
+ export type ElementNodeType = 0 | 1 | 2;
29
+ export type ContextSignaturePatterns = SignaturePatterns & {
30
+ nodeType?: ElementNodeType[];
31
+ };
@@ -275,7 +275,7 @@ function handle(config) {
275
275
  workflowStep.key = config.identifier + '-' + (0, util_3.getWorkflowStepKey)(workflowStep);
276
276
  }
277
277
  const uiModule = ((_a = workflowStep === null || workflowStep === void 0 ? void 0 : workflowStep.settingsUiModule) === null || _a === void 0 ? void 0 : _a.formSchema) || ((_b = workflowStep === null || workflowStep === void 0 ? void 0 : workflowStep.settingsUiModule) === null || _b === void 0 ? void 0 : _b.fileName);
278
- modules['workflow-step-type'].push(Object.assign(Object.assign(Object.assign({ key: workflowStep.key, name: workflowStep.name || config.name, description: workflowStep.description || config.description, boundaries: workflowStep.boundaries }, (workflowStep.editorMode ? { editorMode: workflowStep.editorMode } : {})), { updateSettingsUrl: (0, util_3.getWorkflowStepUrl)('/settings', workflowStep), deleteSettingsUrl: (0, util_3.getWorkflowStepUrl)('/delete', workflowStep) }), (uiModule ? { url: (0, util_3.getWorkflowStepUrl)('/workflow-step', workflowStep) } : {})));
278
+ modules['workflow-step-type'].push(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ key: workflowStep.key, name: workflowStep.name || config.name }, ((workflowStep === null || workflowStep === void 0 ? void 0 : workflowStep.imagePath) ? { logo: (0, util_1.getLogoUrl)(workflowStep, `-${workflowStep.key}`) } : {})), { description: workflowStep.description || config.description, boundaries: workflowStep.boundaries }), (workflowStep.editorMode ? { editorMode: workflowStep.editorMode } : {})), { updateSettingsUrl: (0, util_3.getWorkflowStepUrl)('/settings', workflowStep), deleteSettingsUrl: (0, util_3.getWorkflowStepUrl)('/delete', workflowStep) }), (uiModule ? { url: (0, util_3.getWorkflowStepUrl)('/workflow-step', workflowStep) } : {})));
279
279
  }
280
280
  }
281
281
  const events = {
@@ -47,11 +47,11 @@ function webhookHandler(config, webhooks) {
47
47
  const organizationId = req.headers['x-crowdin-id'];
48
48
  const signature = req.headers['x-crowdin-signature'];
49
49
  const moduleKey = req.headers['x-module-key'];
50
- if (!(0, lodash_isstring_1.default)(domain) || !(0, lodash_isstring_1.default)(organizationId) || !(0, lodash_isstring_1.default)(signature) || !(0, lodash_isstring_1.default)(moduleKey)) {
50
+ if (!(0, lodash_isstring_1.default)(organizationId) || !(0, lodash_isstring_1.default)(signature) || !(0, lodash_isstring_1.default)(moduleKey)) {
51
51
  res.status(400).send({ error: 'Invalid request' });
52
52
  return;
53
53
  }
54
- const crowdinId = domain || organizationId;
54
+ const crowdinId = domain && (0, lodash_isstring_1.default)(domain) ? domain : organizationId;
55
55
  const credentials = yield storage.getStorage().getCrowdinCredentials(crowdinId);
56
56
  if (!credentials) {
57
57
  throw new Error('Failed to find Crowdin credentials');
@@ -10,6 +10,7 @@ const util_1 = require("./util");
10
10
  const crowdin_client_1 = __importDefault(require("../../middlewares/crowdin-client"));
11
11
  const step_settings_save_1 = __importDefault(require("./handlers/step-settings-save"));
12
12
  const delete_step_1 = __importDefault(require("./handlers/delete-step"));
13
+ const util_2 = require("../../util");
13
14
  function register({ config, app }) {
14
15
  if (!config.workflowStepType) {
15
16
  return;
@@ -28,6 +29,9 @@ function register({ config, app }) {
28
29
  checkSubscriptionExpiration: false,
29
30
  moduleKey: workflowStep.key,
30
31
  }), (0, delete_step_1.default)(workflowStep));
32
+ if (workflowStep.imagePath) {
33
+ app.get((0, util_2.getLogoUrl)(workflowStep, `-${workflowStep.key}`), (req, res) => res.sendFile(workflowStep.imagePath || config.imagePath));
34
+ }
31
35
  if (workflowStep.settingsUiModule) {
32
36
  app.use((0, util_1.getWorkflowStepUrl)('/workflow-step', workflowStep), (0, ui_module_1.default)({ config, moduleType: workflowStep.key }), (0, render_ui_module_1.default)(workflowStep.settingsUiModule));
33
37
  }
@@ -1,4 +1,4 @@
1
- import { CrowdinContextInfo, ModuleKey, UiModule } from '../../types';
1
+ import { CrowdinContextInfo, ImagePath, ModuleKey, UiModule } from '../../types';
2
2
  import Crowdin from '@crowdin/crowdin-api-client';
3
3
  interface Boundaries {
4
4
  input: Input;
@@ -13,7 +13,7 @@ interface Output {
13
13
  port: Port;
14
14
  }
15
15
  type Port = 'customCodeFalse' | 'customCodeTrue' | 'untranslated' | 'translated' | 'approved' | 'skipped' | 'all';
16
- export interface WorkflowStepTypeModule extends ModuleKey {
16
+ export interface WorkflowStepTypeModule extends ModuleKey, ImagePath {
17
17
  /**
18
18
  * module name
19
19
  */