@crowdin/app-project-module 0.108.0 → 1.0.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.
Files changed (202) hide show
  1. package/out/app-test/integration/get-integration-files.js +16 -4
  2. package/out/app-test/integration/types.d.ts +1 -1
  3. package/out/app-test/integration/update-crowdin.js +2 -2
  4. package/out/app-test/integration/update-integration.js +2 -2
  5. package/out/index.d.ts +2 -1
  6. package/out/index.js +73 -30
  7. package/out/middlewares/auto-credentials-masker.d.ts +4 -0
  8. package/out/middlewares/auto-credentials-masker.js +45 -0
  9. package/out/middlewares/crowdin-client.d.ts +1 -1
  10. package/out/middlewares/integration-credentials.d.ts +2 -2
  11. package/out/middlewares/integration-credentials.js +7 -4
  12. package/out/middlewares/render-ui-module.d.ts +3 -3
  13. package/out/middlewares/render-ui-module.js +10 -13
  14. package/out/middlewares/ui-module.d.ts +1 -1
  15. package/out/middlewares/ui-module.js +11 -1
  16. package/out/modules/about.d.ts +2 -1
  17. package/out/modules/about.js +10 -3
  18. package/out/modules/ai-prompt-provider/handlers/compile.d.ts +1 -1
  19. package/out/modules/ai-prompt-provider/handlers/compile.js +7 -1
  20. package/out/modules/ai-prompt-provider/index.js +2 -2
  21. package/out/modules/ai-prompt-provider/types.d.ts +7 -1
  22. package/out/modules/ai-provider/handlers/chat-completions.d.ts +1 -1
  23. package/out/modules/ai-provider/handlers/chat-completions.js +1 -1
  24. package/out/modules/ai-provider/handlers/get-model-list.d.ts +1 -1
  25. package/out/modules/ai-provider/index.js +2 -2
  26. package/out/modules/ai-provider/types.d.ts +4 -4
  27. package/out/modules/ai-request-processors/handler.d.ts +1 -1
  28. package/out/modules/ai-request-processors/handler.js +12 -2
  29. package/out/modules/ai-request-processors/types.d.ts +12 -2
  30. package/out/modules/ai-tools/handlers/tool-calls.d.ts +1 -1
  31. package/out/modules/ai-tools/handlers/tool-calls.js +1 -1
  32. package/out/modules/ai-tools/index.js +1 -1
  33. package/out/modules/ai-tools/types.d.ts +1 -1
  34. package/out/modules/auth-guard/handlers/verify.d.ts +1 -1
  35. package/out/modules/auth-guard/index.js +1 -1
  36. package/out/modules/automation-action/handlers/execute.d.ts +1 -1
  37. package/out/modules/automation-action/handlers/execute.js +1 -1
  38. package/out/modules/automation-action/handlers/input-schema.d.ts +1 -1
  39. package/out/modules/automation-action/handlers/output-schema.d.ts +1 -1
  40. package/out/modules/automation-action/handlers/validate-settings.d.ts +1 -1
  41. package/out/modules/automation-action/handlers/validate-settings.js +1 -1
  42. package/out/modules/automation-action/index.js +1 -1
  43. package/out/modules/automation-action/types.d.ts +4 -4
  44. package/out/modules/automation-action/util/index.js +2 -5
  45. package/out/modules/context-menu/index.js +2 -2
  46. package/out/modules/custom-mt/handlers/translate.d.ts +1 -1
  47. package/out/modules/custom-mt/handlers/translate.js +25 -9
  48. package/out/modules/custom-mt/index.js +3 -3
  49. package/out/modules/custom-mt/types.d.ts +10 -2
  50. package/out/modules/custom-spell-check/handlers/get-languages-list.d.ts +1 -1
  51. package/out/modules/custom-spell-check/handlers/spell-check.d.ts +1 -1
  52. package/out/modules/custom-spell-check/index.js +4 -4
  53. package/out/modules/editor-right-panel/index.js +1 -1
  54. package/out/modules/external-qa-check/handlers/validate.d.ts +1 -1
  55. package/out/modules/external-qa-check/index.js +2 -2
  56. package/out/modules/file-processing/handlers/custom-file-format.d.ts +7 -2
  57. package/out/modules/file-processing/handlers/custom-file-format.js +62 -22
  58. package/out/modules/file-processing/handlers/file-download.d.ts +1 -1
  59. package/out/modules/file-processing/handlers/file-download.js +5 -0
  60. package/out/modules/file-processing/handlers/pre-post-process.d.ts +1 -1
  61. package/out/modules/file-processing/handlers/pre-post-process.js +41 -15
  62. package/out/modules/file-processing/handlers/translations-alignment.d.ts +1 -1
  63. package/out/modules/file-processing/handlers/translations-alignment.js +10 -4
  64. package/out/modules/file-processing/index.js +12 -2
  65. package/out/modules/file-processing/types.d.ts +36 -5
  66. package/out/modules/file-processing/util/defaults.js +50 -6
  67. package/out/modules/file-processing/util/files.js +2 -1
  68. package/out/modules/form-data-display.d.ts +1 -1
  69. package/out/modules/form-data-save.d.ts +1 -1
  70. package/out/modules/install.d.ts +1 -1
  71. package/out/modules/integration/handlers/crowdin-file-progress.d.ts +1 -1
  72. package/out/modules/integration/handlers/crowdin-file-progress.js +5 -1
  73. package/out/modules/integration/handlers/crowdin-files-target-languages.d.ts +5 -0
  74. package/out/modules/integration/handlers/crowdin-files-target-languages.js +103 -0
  75. package/out/modules/integration/handlers/crowdin-files.d.ts +1 -1
  76. package/out/modules/integration/handlers/crowdin-files.js +7 -1
  77. package/out/modules/integration/handlers/crowdin-project.d.ts +1 -1
  78. package/out/modules/integration/handlers/crowdin-update.d.ts +1 -1
  79. package/out/modules/integration/handlers/crowdin-update.js +59 -18
  80. package/out/modules/integration/handlers/crowdin-webhook.d.ts +1 -1
  81. package/out/modules/integration/handlers/crowdin-webhook.js +15 -8
  82. package/out/modules/integration/handlers/integration-data.d.ts +1 -1
  83. package/out/modules/integration/handlers/integration-data.js +13 -6
  84. package/out/modules/integration/handlers/integration-login.d.ts +1 -1
  85. package/out/modules/integration/handlers/integration-logout.d.ts +1 -1
  86. package/out/modules/integration/handlers/integration-logout.js +8 -3
  87. package/out/modules/integration/handlers/integration-update.d.ts +1 -1
  88. package/out/modules/integration/handlers/integration-update.js +44 -6
  89. package/out/modules/integration/handlers/integration-webhook.d.ts +1 -1
  90. package/out/modules/integration/handlers/invite-users.d.ts +1 -1
  91. package/out/modules/integration/handlers/job-cancel.d.ts +1 -1
  92. package/out/modules/integration/handlers/job-info-deprecated.d.ts +1 -1
  93. package/out/modules/integration/handlers/job-info-deprecated.js +3 -2
  94. package/out/modules/integration/handlers/job-info.d.ts +1 -1
  95. package/out/modules/integration/handlers/job-list.d.ts +1 -1
  96. package/out/modules/integration/handlers/main.d.ts +1 -1
  97. package/out/modules/integration/handlers/main.js +32 -2
  98. package/out/modules/integration/handlers/oauth-login.d.ts +1 -1
  99. package/out/modules/integration/handlers/oauth-login.js +28 -6
  100. package/out/modules/integration/handlers/oauth-polling.d.ts +1 -1
  101. package/out/modules/integration/handlers/oauth-url.d.ts +1 -1
  102. package/out/modules/integration/handlers/settings-save.d.ts +1 -1
  103. package/out/modules/integration/handlers/settings-save.js +9 -9
  104. package/out/modules/integration/handlers/settings.d.ts +1 -1
  105. package/out/modules/integration/handlers/sync-settings-save.d.ts +1 -1
  106. package/out/modules/integration/handlers/sync-settings-save.js +5 -9
  107. package/out/modules/integration/handlers/sync-settings.d.ts +1 -1
  108. package/out/modules/integration/handlers/user-errors.d.ts +1 -1
  109. package/out/modules/integration/handlers/users.d.ts +1 -1
  110. package/out/modules/integration/index.js +19 -33
  111. package/out/modules/integration/types.d.ts +133 -29
  112. package/out/modules/integration/types.js +1 -0
  113. package/out/modules/integration/util/cron.d.ts +2 -2
  114. package/out/modules/integration/util/cron.js +40 -24
  115. package/out/modules/integration/util/defaults.d.ts +4 -0
  116. package/out/modules/integration/util/defaults.js +175 -15
  117. package/out/modules/integration/util/files.d.ts +2 -1
  118. package/out/modules/integration/util/files.js +19 -8
  119. package/out/modules/integration/util/job.js +4 -3
  120. package/out/modules/integration/util/snapshot.js +19 -3
  121. package/out/modules/integration/util/types.d.ts +1 -0
  122. package/out/modules/integration/util/types.js +1 -0
  123. package/out/modules/integration/util/webhooks.d.ts +8 -8
  124. package/out/modules/integration/util/webhooks.js +34 -17
  125. package/out/modules/manifest.js +12 -12
  126. package/out/modules/modal/index.js +2 -2
  127. package/out/modules/organization-menu/index.js +5 -4
  128. package/out/modules/organization-settings-menu/index.js +5 -4
  129. package/out/modules/profile-resources-menu/index.js +5 -4
  130. package/out/modules/profile-settings-menu/index.js +5 -4
  131. package/out/modules/project-menu/index.js +1 -1
  132. package/out/modules/project-menu-crowdsource/index.js +1 -1
  133. package/out/modules/project-reports/index.js +3 -2
  134. package/out/modules/project-tools/index.js +3 -2
  135. package/out/modules/status.d.ts +1 -1
  136. package/out/modules/status.js +12 -3
  137. package/out/modules/subscription-paid.d.ts +1 -1
  138. package/out/modules/uninstall.d.ts +1 -1
  139. package/out/modules/uninstall.js +1 -1
  140. package/out/modules/webhooks/handlers/webhook-handler.d.ts +2 -2
  141. package/out/modules/webhooks/handlers/webhook-handler.js +33 -22
  142. package/out/modules/webhooks/types.d.ts +7 -0
  143. package/out/modules/workflow-step-type/handlers/delete-step.d.ts +1 -1
  144. package/out/modules/workflow-step-type/handlers/step-settings-save.d.ts +1 -1
  145. package/out/modules/workflow-step-type/index.js +2 -2
  146. package/out/modules/workflow-step-type/util/index.js +3 -6
  147. package/out/static/js/dependent.js +16 -7
  148. package/out/static/ui/error.bundle.js +474 -0
  149. package/out/static/ui/error.bundle.js.map +1 -0
  150. package/out/static/ui/install.bundle.js +459 -0
  151. package/out/static/ui/install.bundle.js.map +1 -0
  152. package/out/static/ui/login.bundle.js +630 -0
  153. package/out/static/ui/login.bundle.js.map +1 -0
  154. package/out/static/ui/main.bundle.js +2109 -0
  155. package/out/static/ui/main.bundle.js.map +1 -0
  156. package/out/static/ui/oauth.bundle.js +467 -0
  157. package/out/static/ui/oauth.bundle.js.map +1 -0
  158. package/out/storage/d1.d.ts +107 -0
  159. package/out/storage/d1.js +831 -0
  160. package/out/storage/index.js +8 -1
  161. package/out/storage/mysql.js +22 -19
  162. package/out/storage/postgre.d.ts +0 -1
  163. package/out/storage/postgre.js +20 -30
  164. package/out/storage/sqlite.d.ts +2 -5
  165. package/out/storage/sqlite.js +29 -69
  166. package/out/types.d.ts +78 -18
  167. package/out/util/connection.js +1 -1
  168. package/out/util/credentials-masker.d.ts +3 -3
  169. package/out/util/credentials-masker.js +14 -20
  170. package/out/util/cron.d.ts +29 -0
  171. package/out/util/cron.js +87 -0
  172. package/out/util/index.d.ts +14 -1
  173. package/out/util/index.js +121 -10
  174. package/out/util/jsx-renderer.d.ts +14 -0
  175. package/out/util/jsx-renderer.js +35 -0
  176. package/out/util/logger.d.ts +1 -0
  177. package/out/util/logger.js +2 -2
  178. package/out/util/static-files.d.ts +19 -0
  179. package/out/util/static-files.js +87 -0
  180. package/out/util/subscription.js +1 -1
  181. package/out/views/AboutPage.d.ts +10 -0
  182. package/out/views/AboutPage.js +76 -0
  183. package/out/views/FormPage.d.ts +14 -0
  184. package/out/views/FormPage.js +28 -0
  185. package/out/views/SubscriptionPage.d.ts +7 -0
  186. package/out/views/SubscriptionPage.js +26 -0
  187. package/out/views/index.d.ts +8 -0
  188. package/out/views/index.js +15 -0
  189. package/out/views/layout/Head.d.ts +9 -0
  190. package/out/views/layout/Head.js +54 -0
  191. package/package.json +43 -41
  192. package/out/util/handlebars.d.ts +0 -1
  193. package/out/util/handlebars.js +0 -46
  194. package/out/views/about.handlebars +0 -102
  195. package/out/views/error.handlebars +0 -54
  196. package/out/views/form.handlebars +0 -31
  197. package/out/views/install.handlebars +0 -16
  198. package/out/views/login.handlebars +0 -332
  199. package/out/views/main.handlebars +0 -2042
  200. package/out/views/oauth.handlebars +0 -11
  201. package/out/views/partials/head.handlebars +0 -53
  202. package/out/views/subscription.handlebars +0 -26
@@ -16,9 +16,9 @@ function register({ config, app }) {
16
16
  return;
17
17
  }
18
18
  if (config.aiProvider.settingsUiModule) {
19
- app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true, moduleType: config.aiProvider.key }), (0, render_ui_module_1.default)(config.aiProvider.settingsUiModule));
19
+ app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true, moduleType: config.aiProvider.key }), (0, render_ui_module_1.default)(config.aiProvider.settingsUiModule, config));
20
20
  }
21
- app.get((0, util_1.getLogoUrl)(config.aiProvider, '/aiprovider'), (req, res) => { var _a; return res.sendFile(((_a = config.aiProvider) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
21
+ app.use('/logo/aiprovider', (0, util_1.serveLogo)(config, config.aiProvider));
22
22
  app.get('/ai-provider/models', json_response_1.default, (0, crowdin_client_1.default)({
23
23
  config,
24
24
  optional: false,
@@ -5,11 +5,11 @@ export interface AiProviderModule extends Environments, ModuleKey {
5
5
  /**
6
6
  * module name
7
7
  */
8
- name: string;
8
+ name?: string;
9
9
  /**
10
10
  * module description
11
11
  */
12
- description: string;
12
+ description?: string;
13
13
  /**
14
14
  * Settings UI module
15
15
  */
@@ -17,14 +17,14 @@ export interface AiProviderModule extends Environments, ModuleKey {
17
17
  /**
18
18
  * processes a sequence of conversation messages and generates responses from the assistant
19
19
  */
20
- chatCompletions: ({ messages, model, action, responseFormat, client, context, req, isStream, sendEvent, tools, toolChoice, }: {
20
+ chatCompletions: ({ messages, model, action, responseFormat, client, context, request, isStream, sendEvent, tools, toolChoice, }: {
21
21
  messages: ChatCompletionMessage[];
22
22
  model: string;
23
23
  action: string;
24
24
  responseFormat: string;
25
25
  client: Crowdin;
26
26
  context: CrowdinContextInfo;
27
- req: CrowdinClientRequest;
27
+ request: CrowdinClientRequest;
28
28
  isStream: boolean;
29
29
  sendEvent: (chunk: ChatCompletionChunkMessage) => Promise<void>;
30
30
  tools?: ChatCompletionTool[];
@@ -2,4 +2,4 @@
2
2
  import { Response } from 'express';
3
3
  import { CrowdinClientRequest } from '../../types';
4
4
  import { AiRequestProcessorModule, AiStreamProcessorModule } from './types';
5
- export default function handle(module: AiRequestProcessorModule | AiStreamProcessorModule, canHandleStream?: boolean): (req: CrowdinClientRequest | 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;
5
+ export default function handle(module: AiRequestProcessorModule | AiStreamProcessorModule, canHandleStream?: boolean): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
@@ -30,7 +30,12 @@ function handle(module, canHandleStream = false) {
30
30
  let chunkStr = chunk.toString();
31
31
  // actually we checked if processStream exists already, but need do to this again to calm down TS compiler
32
32
  chunkStr = module.processStream
33
- ? yield module.processStream(chunkStr, req.query, req.crowdinApiClient, req.crowdinContext)
33
+ ? yield module.processStream({
34
+ chunk: chunkStr,
35
+ requestContext: req.query,
36
+ client: req.crowdinApiClient,
37
+ context: req.crowdinContext,
38
+ })
34
39
  : chunkStr;
35
40
  if (!chunkStr && typeof chunkStr !== 'string') {
36
41
  res.write(BUFFERING_FLAG);
@@ -49,7 +54,12 @@ function handle(module, canHandleStream = false) {
49
54
  });
50
55
  return;
51
56
  }
52
- const result = yield module.processRequest(req.body, req.query, req.crowdinApiClient, req.crowdinContext);
57
+ const result = yield module.processRequest({
58
+ requestData: req.body,
59
+ requestContext: req.query,
60
+ client: req.crowdinApiClient,
61
+ context: req.crowdinContext,
62
+ });
53
63
  res.send(result);
54
64
  }
55
65
  catch (e) {
@@ -4,11 +4,21 @@ export interface AiRequestProcessorModule extends ModuleKey {
4
4
  /**
5
5
  * updates request data
6
6
  */
7
- processRequest: (requestData: any, requestContext: any, client: Crowdin, context: CrowdinContextInfo) => Promise<never>;
7
+ processRequest: (options: {
8
+ requestData: any;
9
+ requestContext: any;
10
+ client: Crowdin;
11
+ context: CrowdinContextInfo;
12
+ }) => Promise<never>;
8
13
  }
9
14
  export interface AiStreamProcessorModule extends AiRequestProcessorModule {
10
15
  /**
11
16
  * updates request data
12
17
  */
13
- processStream?: (chunk: any, requestContext: any, client: Crowdin, context: CrowdinContextInfo) => Promise<string | null>;
18
+ processStream?: (options: {
19
+ chunk: any;
20
+ requestContext: any;
21
+ client: Crowdin;
22
+ context: CrowdinContextInfo;
23
+ }) => Promise<string | null>;
14
24
  }
@@ -2,4 +2,4 @@
2
2
  import { Response } from 'express';
3
3
  import { CrowdinClientRequest } from '../../../types';
4
4
  import { AiTool } from '../types';
5
- export default function handle(aiTool: AiTool): (req: CrowdinClientRequest | 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;
5
+ export default function handle(aiTool: AiTool): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
@@ -32,7 +32,7 @@ function handle(aiTool) {
32
32
  projectId,
33
33
  payload,
34
34
  context,
35
- req,
35
+ request: req,
36
36
  });
37
37
  res.send({
38
38
  data: {
@@ -37,7 +37,7 @@ function registerAiToolWidgets({ config, app }) {
37
37
  const tools = Array.isArray(config.aiToolsWidget) ? config.aiToolsWidget : [config.aiToolsWidget];
38
38
  for (const tool of tools) {
39
39
  if ((0, util_1.isUniqueFunctionName)(tool)) {
40
- app.use((0, util_1.getAiToolWidgetUrl)(tool), (0, ui_module_1.default)({ config, moduleType: tool.key }), (0, render_ui_module_1.default)(tool));
40
+ app.use((0, util_1.getAiToolWidgetUrl)(tool), (0, ui_module_1.default)({ config, moduleType: tool.key }), (0, render_ui_module_1.default)(tool, config));
41
41
  }
42
42
  else {
43
43
  throw new Error(`The function name '${tool.function.name}' is not unique within aiTools and aiToolsWidget`);
@@ -42,7 +42,7 @@ interface AiToolArguments {
42
42
  projectId: number;
43
43
  payload: AiToolPayload;
44
44
  context: CrowdinContextInfo;
45
- req: CrowdinClientRequest;
45
+ request: CrowdinClientRequest;
46
46
  }
47
47
  interface AiToolPayload {
48
48
  function: {
@@ -2,4 +2,4 @@
2
2
  import { Response } from 'express';
3
3
  import { CrowdinClientRequest } from '../../../types';
4
4
  import { AuthGuardModule } from '../types';
5
- export default function verifyHandler(authGuardModules: AuthGuardModule[]): (req: CrowdinClientRequest | 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;
5
+ export default function verifyHandler(authGuardModules: AuthGuardModule[]): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
@@ -22,7 +22,7 @@ function register({ config, app }) {
22
22
  authGuardModules.forEach((module, index) => {
23
23
  if (module.settingsUiModule) {
24
24
  const moduleKey = module.key || `${config.identifier}-auth-guard-${index}`;
25
- app.use(`/auth-guard/${moduleKey}/settings`, (0, ui_module_1.default)({ config, moduleType: moduleKey }), (0, render_ui_module_1.default)(module.settingsUiModule));
25
+ app.use(`/auth-guard/${moduleKey}/settings`, (0, ui_module_1.default)({ config, moduleType: moduleKey }), (0, render_ui_module_1.default)(module.settingsUiModule, config));
26
26
  }
27
27
  });
28
28
  // Register verification endpoint
@@ -2,4 +2,4 @@
2
2
  import { Response } from 'express';
3
3
  import { CrowdinClientRequest } from '../../../types';
4
4
  import { AutomationActionModule } from '../types';
5
- export default function getExecuteHandler(automationAction: AutomationActionModule): (req: CrowdinClientRequest | 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;
5
+ export default function getExecuteHandler(automationAction: AutomationActionModule): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
@@ -40,7 +40,7 @@ function getExecuteHandler(automationAction) {
40
40
  inputData,
41
41
  validationErrors,
42
42
  context: req.crowdinContext,
43
- req: req.body,
43
+ request: req.body,
44
44
  });
45
45
  if (result) {
46
46
  const responseJson = JSON.stringify(result);
@@ -2,4 +2,4 @@
2
2
  import { Response } from 'express';
3
3
  import { AutomationActionModule } from '../types';
4
4
  import { CrowdinClientRequest } from '../../../types';
5
- export default function getInputSchemaHandler(automationAction: AutomationActionModule): (req: CrowdinClientRequest | 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;
5
+ export default function getInputSchemaHandler(automationAction: AutomationActionModule): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
@@ -2,4 +2,4 @@
2
2
  import { Response } from 'express';
3
3
  import { AutomationActionModule } from '../types';
4
4
  import { CrowdinClientRequest } from '../../../types';
5
- export default function getOutputSchemaHandler(automationAction: AutomationActionModule): (req: CrowdinClientRequest | 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;
5
+ export default function getOutputSchemaHandler(automationAction: AutomationActionModule): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
@@ -2,4 +2,4 @@
2
2
  import { Response } from 'express';
3
3
  import { AutomationActionModule } from '../types';
4
4
  import { CrowdinClientRequest } from '../../../types';
5
- export default function getInputSchemaHandler(automationAction: AutomationActionModule): (req: CrowdinClientRequest | 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;
5
+ export default function getInputSchemaHandler(automationAction: AutomationActionModule): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
@@ -21,7 +21,7 @@ function getInputSchemaHandler(automationAction) {
21
21
  client: req.crowdinApiClient,
22
22
  settings: ((_a = req === null || req === void 0 ? void 0 : req.body) === null || _a === void 0 ? void 0 : _a.settings) || [],
23
23
  context: req.crowdinContext,
24
- req: req.body,
24
+ request: req.body,
25
25
  });
26
26
  }
27
27
  res.json({ data: result });
@@ -38,7 +38,7 @@ function register({ config, app }) {
38
38
  moduleKey: automationAction.key,
39
39
  }), (0, execute_1.default)(automationAction));
40
40
  if (automationAction.settingsUiModule) {
41
- app.use((0, util_1.getAutomationActionUrl)('/automation-action', automationAction), (0, ui_module_1.default)({ config, moduleType: automationAction.key }), (0, render_ui_module_1.default)(automationAction.settingsUiModule));
41
+ app.use((0, util_1.getAutomationActionUrl)('/automation-action', automationAction), (0, ui_module_1.default)({ config, moduleType: automationAction.key }), (0, render_ui_module_1.default)(automationAction.settingsUiModule, config));
42
42
  }
43
43
  }
44
44
  }
@@ -21,21 +21,21 @@ export interface AutomationActionModule extends ModuleKey, ImagePath {
21
21
  * JSON schema defining the structure of input parameters expected by the automation action
22
22
  */
23
23
  inputSchema?: any;
24
- validateSettings?: ({ client, settings, context, req, }: {
24
+ validateSettings?: ({ client, settings, context, request, }: {
25
25
  client: Crowdin;
26
26
  settings: any;
27
27
  context: CrowdinContextInfo;
28
- req: any;
28
+ request: any;
29
29
  }) => Promise<any>;
30
30
  /**
31
31
  * function to execute the automation action
32
32
  */
33
- execute: ({ client, inputData, validationErrors, context, req, }: {
33
+ execute: ({ client, inputData, validationErrors, context, request, }: {
34
34
  client: Crowdin;
35
35
  inputData: any;
36
36
  validationErrors?: Record<string, string> | undefined;
37
37
  context: CrowdinContextInfo;
38
- req: any;
38
+ request: any;
39
39
  }) => Promise<any>;
40
40
  /**
41
41
  * Settings UI module
@@ -1,12 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.getAutomationActionUrl = exports.getAutomationActionKey = void 0;
7
- const lodash_kebabcase_1 = __importDefault(require("lodash.kebabcase"));
4
+ const util_1 = require("../../../util");
8
5
  function getAutomationActionKey(automationAction) {
9
- return (0, lodash_kebabcase_1.default)(automationAction.name);
6
+ return (0, util_1.kebabCase)(automationAction.name);
10
7
  }
11
8
  exports.getAutomationActionKey = getAutomationActionKey;
12
9
  function getAutomationActionUrl(path, automationAction) {
@@ -16,14 +16,14 @@ function register({ config, app }) {
16
16
  if (Array.isArray(config.contextMenu)) {
17
17
  config.contextMenu.forEach((contextMenu) => {
18
18
  if ((contextMenu === null || contextMenu === void 0 ? void 0 : contextMenu.uiPath) || (contextMenu === null || contextMenu === void 0 ? void 0 : contextMenu.formSchema)) {
19
- app.use(`/context-${contextMenu.key}`, (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: contextMenu.key }), (0, render_ui_module_1.default)(contextMenu));
19
+ app.use(`/context-${contextMenu.key}`, (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: contextMenu.key }), (0, render_ui_module_1.default)(contextMenu, config));
20
20
  }
21
21
  });
22
22
  }
23
23
  else {
24
24
  // backward compatibility will be removed after migration
25
25
  if (((_a = config.contextMenu) === null || _a === void 0 ? void 0 : _a.uiPath) || ((_b = config.contextMenu) === null || _b === void 0 ? void 0 : _b.formSchema)) {
26
- app.use('/context', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.contextMenu.key }), (0, render_ui_module_1.default)(config.contextMenu));
26
+ app.use('/context', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.contextMenu.key }), (0, render_ui_module_1.default)(config.contextMenu, config));
27
27
  }
28
28
  }
29
29
  }
@@ -2,4 +2,4 @@
2
2
  import { Response } from 'express';
3
3
  import { CrowdinClientRequest } from '../../../types';
4
4
  import { CustomMTHandleOptions } from '../types';
5
- export default function handle({ baseUrl, folder, config }: CustomMTHandleOptions): (req: CrowdinClientRequest | 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;
5
+ export default function handle({ baseUrl, folder, config, fileStore }: CustomMTHandleOptions): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
@@ -17,10 +17,13 @@ const path_1 = __importDefault(require("path"));
17
17
  const util_1 = require("../../../util");
18
18
  const logger_1 = require("../../../util/logger");
19
19
  const files_1 = require("../../file-processing/util/files");
20
- function handle({ baseUrl, folder, config }) {
21
- const dataFolder = path_1.default.join(folder, 'custom-mt');
22
- if (!fs_1.default.existsSync(dataFolder)) {
23
- fs_1.default.mkdirSync(dataFolder, { recursive: true });
20
+ function handle({ baseUrl, folder, config, fileStore }) {
21
+ let dataFolder = '';
22
+ if (!fileStore) {
23
+ dataFolder = path_1.default.join(folder, 'custom-mt');
24
+ if (!fs_1.default.existsSync(dataFolder)) {
25
+ fs_1.default.mkdirSync(dataFolder, { recursive: true });
26
+ }
24
27
  }
25
28
  const baseFilesUrl = `${baseUrl}/file/download/custom-mt`;
26
29
  return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
@@ -50,7 +53,14 @@ function handle({ baseUrl, folder, config }) {
50
53
  res.send({ data: { translations: [] } });
51
54
  return;
52
55
  }
53
- const translations = yield config.translate(req.crowdinApiClient, req.crowdinContext, projectId, source, target, strings);
56
+ const translations = yield config.translate({
57
+ client: req.crowdinApiClient,
58
+ context: req.crowdinContext,
59
+ projectId,
60
+ source,
61
+ target,
62
+ strings,
63
+ });
54
64
  if (!Array.isArray(translations)) {
55
65
  res.send({ data: { translations } });
56
66
  return;
@@ -62,12 +72,18 @@ function handle({ baseUrl, folder, config }) {
62
72
  }
63
73
  else {
64
74
  let url;
65
- if (config.storeFile) {
66
- url = yield config.storeFile(bufferData);
75
+ if (fileStore) {
76
+ const fileRef = yield fileStore.storeFile(bufferData);
77
+ url = `${baseFilesUrl}?file=${fileRef}`;
67
78
  }
68
79
  else {
69
- const storedFile = yield (0, files_1.storeFile)(bufferData, dataFolder);
70
- url = `${baseFilesUrl}?file=${storedFile}`;
80
+ if (config.storeFile) {
81
+ url = yield config.storeFile(bufferData);
82
+ }
83
+ else {
84
+ const storedFile = yield (0, files_1.storeFile)(bufferData, dataFolder);
85
+ url = `${baseFilesUrl}?file=${storedFile}`;
86
+ }
71
87
  }
72
88
  res.send({ data: { translationsUrl: url } });
73
89
  }
@@ -13,20 +13,20 @@ function register({ config, app }) {
13
13
  return;
14
14
  }
15
15
  const folder = config.customMT.filesFolder || config.dbFolder;
16
- app.get((0, util_1.getLogoUrl)(config.customMT, '/mt'), (req, res) => { var _a; return res.sendFile(((_a = config.customMT) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
16
+ app.use('/logo/mt', (0, util_1.serveLogo)(config, config.customMT));
17
17
  app.post('/mt/translate', (0, crowdin_client_1.default)({
18
18
  config,
19
19
  optional: false,
20
20
  checkSubscriptionExpiration: true,
21
21
  moduleKey: config.customMT.key,
22
- }), (0, translate_1.default)({ baseUrl: config.baseUrl, folder, config: config.customMT }));
22
+ }), (0, translate_1.default)({ baseUrl: config.baseUrl, folder, config: config.customMT, fileStore: config.fileStore }));
23
23
  app.get('/file/download/custom-mt', (0, file_download_1.default)(config, config.customMT, 'custom-mt'));
24
24
  // TEMPORARY CODE: it needs to support old path
25
25
  app.post('/translate', (0, crowdin_client_1.default)({
26
26
  config,
27
27
  optional: false,
28
28
  checkSubscriptionExpiration: true,
29
- }), (0, translate_1.default)({ baseUrl: config.baseUrl, folder, config: config.customMT }));
29
+ }), (0, translate_1.default)({ baseUrl: config.baseUrl, folder, config: config.customMT, fileStore: config.fileStore }));
30
30
  // END TEMPORARY CODE
31
31
  }
32
32
  exports.register = register;
@@ -1,14 +1,21 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
3
  import Crowdin, { SourceStringsModel } from '@crowdin/crowdin-api-client';
4
- import { CrowdinContextInfo, ModuleKey } from '../../types';
4
+ import { CrowdinContextInfo, FileStore, ModuleKey } from '../../types';
5
5
  export interface CustomMTLogic extends ModuleKey {
6
6
  withContext?: boolean;
7
7
  splitStringsIntoChunks?: boolean;
8
8
  batchSize?: number;
9
9
  maskEntities?: boolean;
10
10
  filesFolder?: string;
11
- translate: (client: Crowdin, context: CrowdinContextInfo, projectId: number | null, source: string, target: string, strings: CustomMtString[]) => Promise<string[]>;
11
+ translate: (options: {
12
+ client: Crowdin;
13
+ context: CrowdinContextInfo;
14
+ projectId: number | null;
15
+ source: string;
16
+ target: string;
17
+ strings: CustomMtString[];
18
+ }) => Promise<string[]>;
12
19
  validate?: (client: Crowdin) => Promise<void>;
13
20
  storeFile?: (fileContent: Buffer) => Promise<string>;
14
21
  }
@@ -20,6 +27,7 @@ export interface CustomMTHandleOptions {
20
27
  baseUrl: string;
21
28
  folder: string;
22
29
  config: CustomMTLogic;
30
+ fileStore?: FileStore;
23
31
  }
24
32
  export type CustomMtString = string | {
25
33
  id: number;
@@ -2,4 +2,4 @@
2
2
  import { Response } from 'express';
3
3
  import { CrowdinClientRequest } from '../../../types';
4
4
  import { CustomSpellcheckerModule } from '../types';
5
- export default function handle(customSpellchecker: CustomSpellcheckerModule): (req: CrowdinClientRequest | 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;
5
+ export default function handle(customSpellchecker: CustomSpellcheckerModule): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
@@ -2,4 +2,4 @@
2
2
  import { Response } from 'express';
3
3
  import { CrowdinClientRequest } from '../../../types';
4
4
  import { CustomSpellcheckerModule } from '../types';
5
- export default function handle(customSpellchecker: CustomSpellcheckerModule): (req: CrowdinClientRequest | 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;
5
+ export default function handle(customSpellchecker: CustomSpellcheckerModule): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
@@ -17,9 +17,9 @@ function register({ config, app }) {
17
17
  }
18
18
  if ((0, util_1.isAuthorizedConfig)(config)) {
19
19
  if (config.customSpellchecker.settingsUiModule) {
20
- app.use('/spellchecker/settings', (0, ui_module_1.default)({ config, moduleType: config.customSpellchecker.key }), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule));
20
+ app.use('/spellchecker/settings', (0, ui_module_1.default)({ config, moduleType: config.customSpellchecker.key }), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule, config));
21
21
  // TEMPORARY CODE: it needs to support old path
22
- app.use('/settings', (0, ui_module_1.default)({ config }), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule));
22
+ app.use('/settings', (0, ui_module_1.default)({ config }), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule, config));
23
23
  // END TEMPORARY CODE
24
24
  }
25
25
  app.get('/spellchecker/languages', json_response_1.default, (0, crowdin_client_1.default)({
@@ -49,9 +49,9 @@ function register({ config, app }) {
49
49
  return;
50
50
  }
51
51
  if (config.customSpellchecker.settingsUiModule) {
52
- app.use('/spellchecker/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true, moduleType: config.customSpellchecker.key }), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule));
52
+ app.use('/spellchecker/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true, moduleType: config.customSpellchecker.key }), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule, config));
53
53
  // TEMPORARY CODE: it needs to support old path
54
- app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true }), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule));
54
+ app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true }), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule, config));
55
55
  // END TEMPORARY CODE
56
56
  }
57
57
  app.get('/spellchecker/languages', json_response_1.default, (0, get_languages_list_1.default)(config.customSpellchecker));
@@ -12,6 +12,6 @@ function register({ config, app }) {
12
12
  return;
13
13
  }
14
14
  const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
15
- app.use('/editor-panels', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.editorRightPanel.key }), (0, render_ui_module_1.default)(config.editorRightPanel));
15
+ app.use('/editor-panels', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.editorRightPanel.key }), (0, render_ui_module_1.default)(config.editorRightPanel, config));
16
16
  }
17
17
  exports.register = register;
@@ -2,4 +2,4 @@
2
2
  import { Response } from 'express';
3
3
  import { CrowdinClientRequest } from '../../../types';
4
4
  import { ExternalQaCheckModule } from '../types';
5
- export default function handle(externalQaCheck: ExternalQaCheckModule): (req: CrowdinClientRequest | 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;
5
+ export default function handle(externalQaCheck: ExternalQaCheckModule): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
@@ -38,9 +38,9 @@ function register({ config, app }) {
38
38
  }), (0, validate_1.default)(qaCheck));
39
39
  // END TEMPORARY CODE
40
40
  if (qaCheck.settingsUiModule) {
41
- app.use('/qa-check/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true, moduleType: qaCheck.key }), (0, render_ui_module_1.default)(qaCheck.settingsUiModule));
41
+ app.use('/qa-check/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true, moduleType: qaCheck.key }), (0, render_ui_module_1.default)(qaCheck.settingsUiModule, config));
42
42
  // TEMPORARY CODE: it needs to support old path
43
- app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true }), (0, render_ui_module_1.default)(qaCheck.settingsUiModule));
43
+ app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true }), (0, render_ui_module_1.default)(qaCheck.settingsUiModule, config));
44
44
  // END TEMPORARY CODE
45
45
  }
46
46
  }
@@ -1,5 +1,10 @@
1
1
  /// <reference types="qs" />
2
2
  import { Response } from 'express';
3
- import { CrowdinClientRequest } from '../../../types';
3
+ import { CrowdinClientRequest, FileStore } from '../../../types';
4
4
  import { CustomFileFormatLogic } from '../types';
5
- export default function handle(baseUrl: string, folder: string, config: CustomFileFormatLogic): (req: CrowdinClientRequest | 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;
5
+ export default function handle({ baseUrl, folder, config, fileStore, }: {
6
+ baseUrl: string;
7
+ folder: string;
8
+ config: CustomFileFormatLogic;
9
+ fileStore?: FileStore;
10
+ }): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;