@crowdin/app-project-module 0.71.1 → 0.72.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.
@@ -147,7 +147,7 @@ function applyIntegrationModuleDefaults(config, integration) {
147
147
  fields = yield getUserSettings(projectId, crowdinClient, integrationCredentials);
148
148
  }
149
149
  const defaultSettings = [];
150
- const mangers = yield getManagers(projectId, crowdinClient, integrationCredentials);
150
+ const mangers = yield getManagers(crowdinClient, projectId, integrationCredentials.ownerId);
151
151
  if (mangers.length) {
152
152
  defaultSettings.push({
153
153
  key: 'managers',
@@ -320,17 +320,30 @@ function getOAuthLoginFormId(clientId) {
320
320
  return `oauth_form_${clientId}`;
321
321
  }
322
322
  exports.getOAuthLoginFormId = getOAuthLoginFormId;
323
- function getManagers(projectId, client, integrationCredentials) {
323
+ function getManagers(client, projectId, ownerId) {
324
324
  return __awaiter(this, void 0, void 0, function* () {
325
325
  const managers = [];
326
326
  if (client.organization) {
327
- const admins = (yield client.usersApi.listUsers()).data.filter((user) => user.data.isAdmin);
328
- managers.push(...admins.map((admin) => admin.data));
327
+ try {
328
+ const admins = (yield client.usersApi.withFetchAll().listUsers()).data.filter((user) => user.data.isAdmin);
329
+ managers.push(...admins.map((admin) => admin.data));
330
+ }
331
+ catch (e) {
332
+ console.error('Failed to get organization users', e);
333
+ }
329
334
  }
330
- const projectMembers = (yield client.usersApi.listProjectMembers(projectId)).data.filter((user) => 'role' in user.data ? ['owner', 'manager'].includes(user.data.role) : user.data.isManager);
335
+ const projectMembers = (yield client.usersApi.withFetchAll().listProjectMembers(projectId)).data.filter((user) => 'role' in user.data ? ['owner', 'manager'].includes(user.data.role) : user.data.isManager);
331
336
  managers.push(...projectMembers.map((members) => members.data));
332
- return managers
333
- .filter((manager) => manager.id !== +integrationCredentials.ownerId)
334
- .filter((manager, index, self) => self.findIndex((m) => m.id === manager.id) === index);
337
+ const uniqueManagers = new Map();
338
+ managers.forEach((manager) => {
339
+ if (manager.id !== ownerId && !uniqueManagers.has(manager.id)) {
340
+ uniqueManagers.set(manager.id, manager);
341
+ }
342
+ });
343
+ return Array.from(uniqueManagers.values()).sort((a, b) => {
344
+ const aValue = a.firstName || a.username || '';
345
+ const bValue = b.firstName || b.username || '';
346
+ return aValue.localeCompare(bValue);
347
+ });
335
348
  });
336
349
  }
@@ -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({ key: workflowStep.key, name: workflowStep.name || config.name, description: workflowStep.description || config.description, boundaries: workflowStep.boundaries, 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({ 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) } : {})));
279
279
  }
280
280
  }
281
281
  const events = {
@@ -68,9 +68,7 @@ function webhookHandler(config, webhooks) {
68
68
  const json = JSON.parse(req.body.toString());
69
69
  for (const webhook of webhooks) {
70
70
  if (webhook.key === moduleKey) {
71
- for (const event of json.events) {
72
- yield webhook.callback({ credentials, event, client });
73
- }
71
+ yield webhook.callback({ credentials, events: json.events, client });
74
72
  }
75
73
  }
76
74
  }));
@@ -10,7 +10,7 @@ export interface Webhook extends ModuleKey {
10
10
  */
11
11
  callback: (data: {
12
12
  credentials: CrowdinCredentials;
13
- event: Event;
13
+ events: Event[];
14
14
  client: Crowdin;
15
15
  }) => Promise<void>;
16
16
  }
@@ -26,6 +26,10 @@ export interface WorkflowStepTypeModule extends ModuleKey {
26
26
  * settings UI module
27
27
  */
28
28
  settingsUiModule?: UiModule;
29
+ /**
30
+ * Editor mode that will be used in the editor for this module
31
+ */
32
+ editorMode?: EditorMode;
29
33
  /**
30
34
  * input and output boundaries for the module
31
35
  */
@@ -54,4 +58,9 @@ export interface WorkflowStepTypeModule extends ModuleKey {
54
58
  client: Crowdin;
55
59
  }) => Promise<void>;
56
60
  }
61
+ export declare enum EditorMode {
62
+ comfortable = "comfortable",
63
+ sideBySide = "side-by-side",
64
+ multilingual = "multilingual"
65
+ }
57
66
  export {};
@@ -1,2 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EditorMode = void 0;
4
+ var EditorMode;
5
+ (function (EditorMode) {
6
+ EditorMode["comfortable"] = "comfortable";
7
+ EditorMode["sideBySide"] = "side-by-side";
8
+ EditorMode["multilingual"] = "multilingual";
9
+ })(EditorMode = exports.EditorMode || (exports.EditorMode = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "0.71.1",
3
+ "version": "0.72.0",
4
4
  "description": "Module that generates for you all common endpoints for serving standalone Crowdin App",
5
5
  "main": "out/index.js",
6
6
  "types": "out/index.d.ts",