@crowdin/app-project-module 0.43.1 → 0.45.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 (193) hide show
  1. package/out/index.d.ts +3 -3
  2. package/out/index.js +103 -219
  3. package/out/middlewares/crowdin-client.d.ts +1 -1
  4. package/out/middlewares/crowdin-client.js +3 -2
  5. package/out/middlewares/integration-credentials.d.ts +3 -2
  6. package/out/middlewares/render-ui-module.d.ts +2 -2
  7. package/out/middlewares/ui-module.d.ts +2 -2
  8. package/out/middlewares/ui-module.js +5 -1
  9. package/out/{util → modules}/api/api.d.ts +3 -2
  10. package/out/{util → modules}/api/api.js +22 -22
  11. package/out/modules/api/index.d.ts +6 -0
  12. package/out/modules/api/index.js +14 -0
  13. package/out/modules/api/types.d.ts +20 -0
  14. package/out/modules/api/types.js +11 -0
  15. package/out/modules/context-menu/index.d.ts +6 -0
  16. package/out/modules/context-menu/index.js +17 -0
  17. package/out/modules/context-menu/types.d.ts +27 -0
  18. package/out/modules/context-menu/types.js +18 -0
  19. package/out/{handlers/custom-mt → modules/custom-mt/handlers}/translate.d.ts +2 -1
  20. package/out/{handlers/custom-mt → modules/custom-mt/handlers}/translate.js +2 -2
  21. package/out/modules/custom-mt/index.d.ts +6 -0
  22. package/out/modules/custom-mt/index.js +17 -0
  23. package/out/modules/custom-mt/types.d.ts +22 -0
  24. package/out/modules/custom-mt/types.js +2 -0
  25. package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/get-languages-list.d.ts +2 -1
  26. package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/get-languages-list.js +2 -2
  27. package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/spell-check.d.ts +2 -1
  28. package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/spell-check.js +5 -3
  29. package/out/modules/custom-spell-check/index.d.ts +6 -0
  30. package/out/modules/custom-spell-check/index.js +32 -0
  31. package/out/modules/custom-spell-check/types.d.ts +56 -0
  32. package/out/modules/custom-spell-check/types.js +2 -0
  33. package/out/modules/editor-right-panel/index.d.ts +6 -0
  34. package/out/modules/editor-right-panel/index.js +17 -0
  35. package/out/modules/editor-right-panel/types.d.ts +7 -0
  36. package/out/modules/editor-right-panel/types.js +2 -0
  37. package/out/modules/editor-themes/index.d.ts +6 -0
  38. package/out/modules/editor-themes/index.js +11 -0
  39. package/out/modules/editor-themes/types.d.ts +17 -0
  40. package/out/modules/editor-themes/types.js +2 -0
  41. package/out/{handlers/file-processing → modules/file-processing/handlers}/custom-file-format.d.ts +2 -1
  42. package/out/{handlers/file-processing → modules/file-processing/handlers}/custom-file-format.js +5 -5
  43. package/out/modules/file-processing/handlers/file-download.d.ts +5 -0
  44. package/out/{handlers/file-processing → modules/file-processing/handlers}/file-download.js +2 -2
  45. package/out/{handlers/file-processing → modules/file-processing/handlers}/pre-post-process.d.ts +2 -1
  46. package/out/{handlers/file-processing → modules/file-processing/handlers}/pre-post-process.js +8 -8
  47. package/out/modules/file-processing/index.d.ts +22 -0
  48. package/out/modules/file-processing/index.js +57 -0
  49. package/out/modules/file-processing/types.d.ts +133 -0
  50. package/out/modules/file-processing/types.js +12 -0
  51. package/out/modules/file-processing/util/defaults.d.ts +3 -0
  52. package/out/modules/file-processing/util/defaults.js +30 -0
  53. package/out/modules/file-processing/util/files.d.ts +6 -0
  54. package/out/modules/file-processing/util/files.js +47 -0
  55. package/out/{handlers/integration/crowdin-project.d.ts → modules/form-data-display.d.ts} +1 -1
  56. package/out/modules/form-data-save.d.ts +4 -0
  57. package/out/modules/install.d.ts +4 -0
  58. package/out/{handlers → modules}/install.js +3 -3
  59. package/out/{handlers/integration → modules/integration/handlers}/crowdin-file-progress.d.ts +2 -1
  60. package/out/{handlers/integration → modules/integration/handlers}/crowdin-file-progress.js +2 -2
  61. package/out/modules/integration/handlers/crowdin-files.d.ts +5 -0
  62. package/out/{handlers/integration → modules/integration/handlers}/crowdin-files.js +3 -3
  63. package/out/modules/integration/handlers/crowdin-project.d.ts +4 -0
  64. package/out/{handlers/integration → modules/integration/handlers}/crowdin-project.js +1 -1
  65. package/out/modules/integration/handlers/crowdin-update.d.ts +5 -0
  66. package/out/{handlers/integration → modules/integration/handlers}/crowdin-update.js +9 -9
  67. package/out/modules/integration/handlers/crowdin-webhook.d.ts +5 -0
  68. package/out/{handlers/integration → modules/integration/handlers}/crowdin-webhook.js +19 -8
  69. package/out/modules/integration/handlers/integration-data.d.ts +4 -0
  70. package/out/{handlers/integration → modules/integration/handlers}/integration-data.js +5 -5
  71. package/out/{handlers/integration → modules/integration/handlers}/integration-login.d.ts +2 -1
  72. package/out/{handlers/integration → modules/integration/handlers}/integration-login.js +3 -3
  73. package/out/modules/integration/handlers/integration-logout.d.ts +5 -0
  74. package/out/{handlers/integration → modules/integration/handlers}/integration-logout.js +14 -7
  75. package/out/modules/integration/handlers/integration-update.d.ts +5 -0
  76. package/out/{handlers/integration → modules/integration/handlers}/integration-update.js +9 -8
  77. package/out/modules/integration/handlers/integration-webhook.d.ts +5 -0
  78. package/out/{handlers/integration → modules/integration/handlers}/integration-webhook.js +9 -4
  79. package/out/modules/integration/handlers/job-cancel.d.ts +3 -0
  80. package/out/{handlers/integration → modules/integration/handlers}/job-cancel.js +4 -4
  81. package/out/modules/integration/handlers/job-info.d.ts +3 -0
  82. package/out/{handlers/integration → modules/integration/handlers}/job-info.js +4 -4
  83. package/out/modules/integration/handlers/main.d.ts +5 -0
  84. package/out/{handlers/integration → modules/integration/handlers}/main.js +5 -5
  85. package/out/modules/integration/handlers/oauth-login.d.ts +5 -0
  86. package/out/{handlers/integration → modules/integration/handlers}/oauth-login.js +3 -3
  87. package/out/{handlers/integration → modules/integration/handlers}/oauth-url.d.ts +2 -1
  88. package/out/{handlers/integration → modules/integration/handlers}/oauth-url.js +2 -2
  89. package/out/modules/integration/handlers/settings-save.d.ts +5 -0
  90. package/out/{handlers/integration → modules/integration/handlers}/settings-save.js +28 -11
  91. package/out/modules/integration/handlers/settings.d.ts +3 -0
  92. package/out/{handlers/integration → modules/integration/handlers}/settings.js +1 -1
  93. package/out/{handlers/integration → modules/integration/handlers}/subscription-info.d.ts +1 -1
  94. package/out/{handlers/integration → modules/integration/handlers}/subscription-info.js +2 -2
  95. package/out/modules/integration/handlers/sync-settings-save.d.ts +5 -0
  96. package/out/{handlers/integration → modules/integration/handlers}/sync-settings-save.js +16 -8
  97. package/out/modules/integration/handlers/sync-settings.d.ts +3 -0
  98. package/out/{handlers/integration → modules/integration/handlers}/sync-settings.js +2 -2
  99. package/out/modules/integration/handlers/user-errors.d.ts +3 -0
  100. package/out/{handlers/integration → modules/integration/handlers}/user-errors.js +2 -2
  101. package/out/modules/integration/index.d.ts +6 -0
  102. package/out/modules/integration/index.js +118 -0
  103. package/out/modules/integration/types.d.ts +435 -0
  104. package/out/modules/integration/types.js +19 -0
  105. package/out/modules/integration/util/cron.d.ts +27 -0
  106. package/out/{util → modules/integration/util}/cron.js +97 -28
  107. package/out/{util → modules/integration/util}/defaults.d.ts +2 -3
  108. package/out/{util → modules/integration/util}/defaults.js +1 -36
  109. package/out/modules/integration/util/files.d.ts +5 -0
  110. package/out/{util → modules/integration/util}/files.js +9 -40
  111. package/out/{util → modules/integration/util}/job.d.ts +1 -1
  112. package/out/{util → modules/integration/util}/job.js +11 -11
  113. package/out/{util/file-snapshot.d.ts → modules/integration/util/snapshot.d.ts} +2 -3
  114. package/out/{util/file-snapshot.js → modules/integration/util/snapshot.js} +6 -65
  115. package/out/{models/job.d.ts → modules/integration/util/types.d.ts} +14 -0
  116. package/out/modules/integration/util/webhooks.d.ts +48 -0
  117. package/out/{util → modules/integration/util}/webhooks.js +95 -49
  118. package/out/modules/manifest.d.ts +3 -0
  119. package/out/{handlers → modules}/manifest.js +22 -16
  120. package/out/modules/modal/index.d.ts +6 -0
  121. package/out/modules/modal/index.js +17 -0
  122. package/out/modules/organization-menu/index.d.ts +6 -0
  123. package/out/modules/organization-menu/index.js +18 -0
  124. package/out/modules/profile-resources-menu/index.d.ts +6 -0
  125. package/out/modules/profile-resources-menu/index.js +18 -0
  126. package/out/modules/project-menu/index.d.ts +6 -0
  127. package/out/modules/project-menu/index.js +17 -0
  128. package/out/modules/project-menu-crowdsource/index.d.ts +6 -0
  129. package/out/modules/project-menu-crowdsource/index.js +17 -0
  130. package/out/modules/project-reports/index.d.ts +6 -0
  131. package/out/modules/project-reports/index.js +18 -0
  132. package/out/modules/project-tools/index.d.ts +6 -0
  133. package/out/modules/project-tools/index.js +18 -0
  134. package/out/modules/subscription-paid.d.ts +3 -0
  135. package/out/{handlers → modules}/subscription-paid.js +2 -2
  136. package/out/modules/uninstall.d.ts +4 -0
  137. package/out/{handlers → modules}/uninstall.js +6 -2
  138. package/out/storage/index.d.ts +5 -3
  139. package/out/storage/mysql.d.ts +4 -2
  140. package/out/storage/mysql.js +3 -3
  141. package/out/storage/postgre.d.ts +4 -2
  142. package/out/storage/postgre.js +3 -3
  143. package/out/storage/sqlite.d.ts +4 -2
  144. package/out/storage/sqlite.js +3 -3
  145. package/out/storage/types.d.ts +9 -0
  146. package/out/storage/types.js +2 -0
  147. package/out/types.d.ts +374 -0
  148. package/out/types.js +59 -0
  149. package/out/util/connection.d.ts +2 -9
  150. package/out/util/connection.js +54 -150
  151. package/out/util/handlebars.d.ts +1 -0
  152. package/out/util/handlebars.js +34 -0
  153. package/out/util/index.d.ts +2 -2
  154. package/out/util/index.js +6 -6
  155. package/out/util/logger.d.ts +2 -2
  156. package/out/util/subscription.d.ts +9 -0
  157. package/out/util/subscription.js +111 -0
  158. package/package.json +1 -1
  159. package/out/handlers/file-processing/file-download.d.ts +0 -4
  160. package/out/handlers/form-data-display.d.ts +0 -3
  161. package/out/handlers/form-data-save.d.ts +0 -3
  162. package/out/handlers/install.d.ts +0 -4
  163. package/out/handlers/integration/crowdin-files.d.ts +0 -4
  164. package/out/handlers/integration/crowdin-update.d.ts +0 -4
  165. package/out/handlers/integration/crowdin-webhook.d.ts +0 -4
  166. package/out/handlers/integration/integration-data.d.ts +0 -4
  167. package/out/handlers/integration/integration-logout.d.ts +0 -4
  168. package/out/handlers/integration/integration-update.d.ts +0 -4
  169. package/out/handlers/integration/integration-webhook.d.ts +0 -4
  170. package/out/handlers/integration/job-cancel.d.ts +0 -3
  171. package/out/handlers/integration/job-info.d.ts +0 -3
  172. package/out/handlers/integration/main.d.ts +0 -4
  173. package/out/handlers/integration/oauth-login.d.ts +0 -4
  174. package/out/handlers/integration/settings-save.d.ts +0 -4
  175. package/out/handlers/integration/settings.d.ts +0 -3
  176. package/out/handlers/integration/sync-settings-save.d.ts +0 -4
  177. package/out/handlers/integration/sync-settings.d.ts +0 -3
  178. package/out/handlers/integration/user-errors.d.ts +0 -3
  179. package/out/handlers/manifest.d.ts +0 -3
  180. package/out/handlers/subscription-paid.d.ts +0 -3
  181. package/out/handlers/uninstall.d.ts +0 -4
  182. package/out/models/index.d.ts +0 -1088
  183. package/out/models/index.js +0 -106
  184. package/out/util/cron.d.ts +0 -7
  185. package/out/util/files.d.ts +0 -9
  186. package/out/util/webhooks.d.ts +0 -28
  187. /package/out/{util → modules}/api/base.d.ts +0 -0
  188. /package/out/{util → modules}/api/base.js +0 -0
  189. /package/out/{util → modules}/api/components.d.ts +0 -0
  190. /package/out/{util → modules}/api/components.js +0 -0
  191. /package/out/{handlers → modules}/form-data-display.js +0 -0
  192. /package/out/{handlers → modules}/form-data-save.js +0 -0
  193. /package/out/{models/job.js → modules/integration/util/types.js} +0 -0
@@ -10,13 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const util_1 = require("../util");
13
- const connection_1 = require("../util/connection");
13
+ const subscription_1 = require("../util/subscription");
14
14
  const logger_1 = require("../util/logger");
15
15
  function handle() {
16
16
  return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
17
17
  const organizationId = (req.query || {})['organization_id'] || (req.body || {})['organization_id'];
18
18
  (0, logger_1.log)(`Received subscription paid request for organization ${organizationId}`);
19
- (0, connection_1.clearCache)(organizationId);
19
+ (0, subscription_1.clearCache)(organizationId);
20
20
  res.status(204).end();
21
21
  }));
22
22
  }
@@ -0,0 +1,4 @@
1
+ /// <reference types="qs" />
2
+ import { Request, Response } from 'express';
3
+ import { Config } from '../types';
4
+ export default function handle(config: Config): (req: import("../types").CrowdinClientRequest | Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
@@ -13,7 +13,7 @@ const storage_1 = require("../storage");
13
13
  const util_1 = require("../util");
14
14
  const connection_1 = require("../util/connection");
15
15
  const logger_1 = require("../util/logger");
16
- const webhooks_1 = require("../util/webhooks");
16
+ const webhooks_1 = require("./integration/util/webhooks");
17
17
  function handle(config) {
18
18
  return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
19
19
  const event = req.body;
@@ -40,7 +40,11 @@ function handle(config) {
40
40
  }
41
41
  if (projectIntegration) {
42
42
  if (projectIntegration.webhooks) {
43
- yield (0, webhooks_1.unregisterAllCrowdinWebhooks)(config, projectIntegration, organization);
43
+ yield (0, webhooks_1.unregisterAllCrowdinWebhooks)({
44
+ config,
45
+ integration: projectIntegration,
46
+ crowdinId: organization,
47
+ });
44
48
  }
45
49
  (0, logger_1.log)(`Deleting all integration credentials for ${organization} organization`);
46
50
  yield (0, storage_1.getStorage)().deleteAllIntegrationCredentials(organization);
@@ -1,5 +1,7 @@
1
- import { Config, CrowdinCredentials, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationConfig, IntegrationSyncSettings, IntegrationWebhooks, Provider, UserErrors } from '../models';
2
- import { CreateJobParams, GetActiveJobsParams, GetJobParams, Job, UpdateJobParams } from '../models/job';
1
+ import { IntegrationConfig, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncSettings, IntegrationWebhooks, Provider } from '../modules/integration/types';
2
+ import { Config, CrowdinCredentials, UnauthorizedConfig } from '../types';
3
+ import { CreateJobParams, GetActiveJobsParams, GetJobParams, Job, UpdateJobParams } from '../modules/integration/util/types';
4
+ import { UserErrors } from './types';
3
5
  export interface Storage {
4
6
  migrate(): Promise<void>;
5
7
  saveCrowdinCredentials(credentials: CrowdinCredentials): Promise<void>;
@@ -42,5 +44,5 @@ export interface Storage {
42
44
  getActiveJobs(params: GetActiveJobsParams): Promise<Job[] | undefined>;
43
45
  deleteFinishedJobs(): Promise<void>;
44
46
  }
45
- export declare function initialize(config: Config): Promise<void>;
47
+ export declare function initialize(config: Config | UnauthorizedConfig): Promise<void>;
46
48
  export declare function getStorage(): Storage;
@@ -1,6 +1,8 @@
1
1
  import { Storage } from '.';
2
- import { CrowdinCredentials, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationConfig, IntegrationSyncSettings, IntegrationWebhooks, UserErrors } from '../models';
3
- import { CreateJobParams, GetActiveJobsParams, GetJobParams, Job, UpdateJobParams } from '../models/job';
2
+ import { CrowdinCredentials } from '../types';
3
+ import { CreateJobParams, GetActiveJobsParams, GetJobParams, Job, UpdateJobParams } from '../modules/integration/util/types';
4
+ import { IntegrationConfig, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncSettings, IntegrationWebhooks } from '../modules/integration/types';
5
+ import { UserErrors } from './types';
4
6
  export interface MySQLStorageConfig {
5
7
  uri?: string;
6
8
  host?: string;
@@ -14,7 +14,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.MySQLStorage = void 0;
16
16
  const uuid_1 = require("uuid");
17
- const job_1 = require("../models/job");
17
+ const types_1 = require("../modules/integration/util/types");
18
18
  const util_1 = require("../util");
19
19
  class MySQLStorage {
20
20
  constructor(config) {
@@ -156,7 +156,7 @@ class MySQLStorage {
156
156
  payload text,
157
157
  title text,
158
158
  progress int 0,
159
- status varchar(255) '${job_1.JobStatus.CREATED}',
159
+ status varchar(255) '${types_1.JobStatus.CREATED}',
160
160
  payload text,
161
161
  info text,
162
162
  data text,
@@ -518,7 +518,7 @@ class MySQLStorage {
518
518
  if (status) {
519
519
  updateFields.push('status = ?');
520
520
  updateParams.push(status);
521
- if (!updateFields.includes('finished_at = ?') && [job_1.JobStatus.FAILED, job_1.JobStatus.CANCELED].includes(status)) {
521
+ if (!updateFields.includes('finished_at = ?') && [types_1.JobStatus.FAILED, types_1.JobStatus.CANCELED].includes(status)) {
522
522
  updateFields.push('finished_at = ?');
523
523
  updateParams.push(Date.now().toString());
524
524
  }
@@ -1,7 +1,9 @@
1
1
  import { Client } from 'pg';
2
2
  import { Storage } from '.';
3
- import { CrowdinCredentials, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationConfig, IntegrationSyncSettings, IntegrationWebhooks, UserErrors } from '../models';
4
- import { CreateJobParams, GetActiveJobsParams, GetJobParams, Job, UpdateJobParams } from '../models/job';
3
+ import { CrowdinCredentials } from '../types';
4
+ import { IntegrationConfig, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncSettings, IntegrationWebhooks } from '../modules/integration/types';
5
+ import { CreateJobParams, GetActiveJobsParams, GetJobParams, Job, UpdateJobParams } from '../modules/integration/util/types';
6
+ import { UserErrors } from './types';
5
7
  export interface PostgreStorageConfig {
6
8
  host?: string;
7
9
  connectionString?: string;
@@ -13,7 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.PostgreStorage = void 0;
14
14
  const pg_1 = require("pg");
15
15
  const uuid_1 = require("uuid");
16
- const job_1 = require("../models/job");
16
+ const types_1 = require("../modules/integration/util/types");
17
17
  const util_1 = require("../util");
18
18
  class PostgreStorage {
19
19
  constructor(config) {
@@ -169,7 +169,7 @@ class PostgreStorage {
169
169
  type varchar not null,
170
170
  title varchar null,
171
171
  progress int default 0,
172
- status varchar default '${job_1.JobStatus.CREATED}',
172
+ status varchar default '${types_1.JobStatus.CREATED}',
173
173
  payload varchar null,
174
174
  info varchar null,
175
175
  data varchar null,
@@ -534,7 +534,7 @@ class PostgreStorage {
534
534
  if (status) {
535
535
  updateFields.push('status = $' + updateParams.length.toString());
536
536
  updateParams.push(status);
537
- if ((!progress || progress <= 100) && [job_1.JobStatus.FAILED, job_1.JobStatus.CANCELED].includes(status)) {
537
+ if ((!progress || progress <= 100) && [types_1.JobStatus.FAILED, types_1.JobStatus.CANCELED].includes(status)) {
538
538
  updateFields.push('finished_at = $' + updateParams.length.toString());
539
539
  updateParams.push(Date.now().toString());
540
540
  }
@@ -1,6 +1,8 @@
1
1
  import { Storage } from '.';
2
- import { CrowdinCredentials, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationConfig, IntegrationSyncSettings, IntegrationWebhooks, UserErrors } from '../models';
3
- import { CreateJobParams, GetActiveJobsParams, GetJobParams, Job, UpdateJobParams } from '../models/job';
2
+ import { CrowdinCredentials } from '../types';
3
+ import { IntegrationConfig, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncSettings, IntegrationWebhooks } from '../modules/integration/types';
4
+ import { CreateJobParams, GetActiveJobsParams, GetJobParams, Job, UpdateJobParams } from '../modules/integration/util/types';
5
+ import { UserErrors } from './types';
4
6
  export interface SQLiteStorageConfig {
5
7
  dbFolder: string;
6
8
  }
@@ -16,7 +16,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.SQLiteStorage = void 0;
17
17
  const path_1 = require("path");
18
18
  const uuid_1 = require("uuid");
19
- const job_1 = require("../models/job");
19
+ const types_1 = require("../modules/integration/util/types");
20
20
  class SQLiteStorage {
21
21
  constructor(config) {
22
22
  this.dbPromise = new Promise((res, rej) => {
@@ -247,7 +247,7 @@ class SQLiteStorage {
247
247
  type varchar not null,
248
248
  title varchar null,
249
249
  progress integer DEFAULT 0,
250
- status varchar DEFAULT '${job_1.JobStatus.CREATED}',
250
+ status varchar DEFAULT '${types_1.JobStatus.CREATED}',
251
251
  payload varchar null,
252
252
  info varchar null,
253
253
  data varchar null,
@@ -524,7 +524,7 @@ class SQLiteStorage {
524
524
  if (status) {
525
525
  updateFields.push('status = ?');
526
526
  updateParams.push(status);
527
- if (!updateFields.includes('finished_at = ?') && [job_1.JobStatus.FAILED, job_1.JobStatus.CANCELED].includes(status)) {
527
+ if (!updateFields.includes('finished_at = ?') && [types_1.JobStatus.FAILED, types_1.JobStatus.CANCELED].includes(status)) {
528
528
  updateFields.push('finished_at = ?');
529
529
  updateParams.push(Date.now().toString());
530
530
  }
@@ -0,0 +1,9 @@
1
+ export interface UserErrors {
2
+ id: number;
3
+ action: string;
4
+ message: string;
5
+ data: any;
6
+ createdAt: string;
7
+ crowdinId: string;
8
+ integrationId?: string;
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/out/types.d.ts ADDED
@@ -0,0 +1,374 @@
1
+ import Crowdin from '@crowdin/crowdin-api-client';
2
+ import { JwtPayload, VerifyOptions } from '@crowdin/crowdin-apps-functions';
3
+ import { Request } from 'express';
4
+ import { ContextModule } from './modules/context-menu/types';
5
+ import { CustomMTLogic } from './modules/custom-mt/types';
6
+ import { CustomSpellcheckerModule } from './modules/custom-spell-check/types';
7
+ import { EditorPanels } from './modules/editor-right-panel/types';
8
+ import { EditorThemes } from './modules/editor-themes/types';
9
+ import { CustomFileFormatLogic, FilePostExportLogic, FilePostImportLogic, FilePreExportLogic, FilePreImportLogic } from './modules/file-processing/types';
10
+ import { IntegrationLogic } from './modules/integration/types';
11
+ import { MySQLStorageConfig } from './storage/mysql';
12
+ import { PostgreStorageConfig } from './storage/postgre';
13
+ import { ApiModule } from './modules/api/types';
14
+ import { LogErrorFunction, LogFunction } from './util/logger';
15
+ export interface ClientConfig extends ImagePath {
16
+ /**
17
+ * Authentication Crowdin App type: "authorization_code", "crowdin_app". Default: "crowdin_app"
18
+ */
19
+ authenticationType?: AuthenticationType;
20
+ /**
21
+ * client id that we received when registering the app
22
+ */
23
+ clientId?: string;
24
+ /**
25
+ * client secret that we received when registering the app
26
+ */
27
+ clientSecret?: string;
28
+ /**
29
+ * Secret to encrypt/decrypt credentials (by default @clientSecret will be used)
30
+ */
31
+ cryptoSecret?: string;
32
+ /**
33
+ * Options to validate Crowdin JWT token
34
+ */
35
+ jwtValidationOptions?: VerifyOptions;
36
+ /**
37
+ * https url where an app is reachable from the internet (e.g. the one that ngrok generates for us)
38
+ */
39
+ baseUrl?: string;
40
+ /**
41
+ * define custom Crowdin urls (e.g. to work against local Crowdin server)
42
+ */
43
+ crowdinUrls?: CrowdinUrls;
44
+ /**
45
+ * Set of scopes requested by this app (default 'project')
46
+ */
47
+ scopes?: Scope[];
48
+ /**
49
+ * app name
50
+ */
51
+ name: string;
52
+ /**
53
+ * app identifier
54
+ */
55
+ identifier: string;
56
+ /**
57
+ * app description
58
+ */
59
+ description: string;
60
+ /**
61
+ * Set default app permissions
62
+ */
63
+ defaultPermissions?: DefaultPermissions;
64
+ /**
65
+ * port where to start express application
66
+ */
67
+ port?: number;
68
+ /**
69
+ * folder where module will create sqlite db file to persist credentials (e.g. {@example __dirname})
70
+ */
71
+ dbFolder?: string;
72
+ /**
73
+ * config to configure PostgreSQL as a storage
74
+ */
75
+ postgreConfig?: PostgreStorageConfig;
76
+ /**
77
+ * config to configure MySQL as a storage
78
+ */
79
+ mysqlConfig?: MySQLStorageConfig;
80
+ /**
81
+ * integration module logic
82
+ */
83
+ projectIntegration?: IntegrationLogic & ImagePath & Environments;
84
+ /**
85
+ * custom file format module logic
86
+ */
87
+ customFileFormat?: CustomFileFormatLogic;
88
+ /**
89
+ * custom MT module logic
90
+ */
91
+ customMT?: CustomMTLogic & ImagePath & Environments;
92
+ /**
93
+ * resources module
94
+ */
95
+ profileResourcesMenu?: UiModule & ImagePath & Environments;
96
+ /**
97
+ * organization-menu module
98
+ */
99
+ organizationMenu?: UiModule & ImagePath;
100
+ /**
101
+ * editor-right-panel module
102
+ */
103
+ editorRightPanel?: EditorPanels & Environments;
104
+ /**
105
+ * editor-themes module
106
+ */
107
+ editorThemes?: EditorThemes & ImagePath & Environments;
108
+ /**
109
+ * project menu module
110
+ */
111
+ projectMenu?: UiModule & Environments;
112
+ /**
113
+ * project menu crowdsource module
114
+ */
115
+ projectMenuCrowdsource?: UiModule;
116
+ /**
117
+ * tools module
118
+ */
119
+ projectTools?: UiModule & ImagePath & Environments;
120
+ /**
121
+ * reports module
122
+ */
123
+ projectReports?: UiModule & ImagePath;
124
+ /**
125
+ * API module
126
+ */
127
+ api?: ApiModule;
128
+ /**
129
+ * context menu module
130
+ */
131
+ contextMenu?: ContextModule & UiModule & Environments;
132
+ /**
133
+ * modal module
134
+ */
135
+ modal?: ModuleContent & UiModule & Environments;
136
+ /**
137
+ * Uninstall hook for cleanup logic
138
+ */
139
+ onUninstall?: (organization: string, allCredentials: {
140
+ settings?: any;
141
+ credentials: any;
142
+ }[]) => Promise<void>;
143
+ /**
144
+ * Error interceptor (can be used to log error in centralized place)
145
+ */
146
+ onError?: (error: any, context?: CrowdinContextInfo) => void;
147
+ /**
148
+ * Disable global error handling of unhandledRejection and uncaughtException events
149
+ */
150
+ disableGlobalErrorHandling?: boolean;
151
+ /**
152
+ * Configuration to log everything that are happening in the app
153
+ */
154
+ logger?: Logger;
155
+ /**
156
+ * Configuration of app pricing
157
+ */
158
+ pricing?: Pricing;
159
+ filePreImport?: FilePreImportLogic;
160
+ filePostImport?: FilePostImportLogic;
161
+ filePreExport?: FilePreExportLogic;
162
+ filePostExport?: FilePostExportLogic;
163
+ /**
164
+ * Disable formatting logs
165
+ */
166
+ disableLogsFormatter?: boolean;
167
+ /**
168
+ * AWS configuration for uploading big files to temporary bucket. Used with customFileFormat and file processors modules.
169
+ *
170
+ * Not necessary to configure if environment variables AWS_REGION and AWS_TMP_BUCKET_NAME are properly set.
171
+ */
172
+ awsConfig?: AWSConfig;
173
+ customSpellchecker?: CustomSpellcheckerModule;
174
+ }
175
+ export interface Environments {
176
+ environments: Environment | Environment[];
177
+ }
178
+ type Environment = 'crowdin' | 'crowdin-enterprise';
179
+ export type Config = ClientConfig & {
180
+ baseUrl: string;
181
+ clientId: string;
182
+ clientSecret: string;
183
+ port: number;
184
+ dbFolder: string;
185
+ imagePath: string;
186
+ };
187
+ export type UnauthorizedConfig = Omit<Config, 'clientId' | 'clientSecret'> & {
188
+ clientId?: string;
189
+ clientSecret?: string;
190
+ };
191
+ export declare enum AuthenticationType {
192
+ CODE = "authorization_code",
193
+ APP = "crowdin_app",
194
+ NONE = "none"
195
+ }
196
+ export interface CrowdinUrls {
197
+ apiUrl?: string;
198
+ accountUrl?: string;
199
+ subscriptionUrl?: string;
200
+ }
201
+ export declare enum Scope {
202
+ ALL_SCOPES = "all",
203
+ NOTIFICATIONS = "notification",
204
+ TRANSLATION_MEMORIES = "tm",
205
+ MACHINE_TRANSLATION_ENGINES = "mt",
206
+ GLOSSARIES = "glossary",
207
+ USERS = "user",
208
+ TEAMS = "team",
209
+ GROUPS = "group",
210
+ PROJECTS = "project",
211
+ TASKS = "project.task",
212
+ REPORTS = "project.report",
213
+ TRANSLATION_STATUS = "project.status",
214
+ SOURCE_FILES_AND_STRINGS = "project.source",
215
+ WEBHOOKS = "project.webhook",
216
+ TRANSLATIONS = "project.translation",
217
+ SCREENSHOTS = "project.screenshot",
218
+ SECURITY_LOGS = "security-log",
219
+ VENDORS = "vendor"
220
+ }
221
+ export interface CrowdinClientRequest extends Request {
222
+ crowdinApiClient: Crowdin;
223
+ crowdinContext: CrowdinContextInfo;
224
+ subscriptionInfo?: SubscriptionInfo;
225
+ logInfo: LogFunction;
226
+ logError: LogErrorFunction;
227
+ }
228
+ export interface CrowdinCredentials {
229
+ id: string;
230
+ appSecret: string;
231
+ domain?: string;
232
+ userId: number;
233
+ organizationId: number;
234
+ baseUrl: string;
235
+ accessToken: string;
236
+ refreshToken: string;
237
+ expire: string;
238
+ type: AccountType;
239
+ }
240
+ export declare enum AccountType {
241
+ NORMAL = "normal",
242
+ ENTERPRISE = "enterprise"
243
+ }
244
+ export interface CrowdinContextInfo {
245
+ jwtPayload: JwtPayload;
246
+ crowdinId: string;
247
+ clientId: string;
248
+ appIdentifier: string;
249
+ }
250
+ export declare enum SubscriptionInfoType {
251
+ TRIAL = "trial",
252
+ SUBSCRIPTION = "subscription"
253
+ }
254
+ export interface SubscriptionInfo {
255
+ expired: boolean;
256
+ subscribeLink?: string;
257
+ daysLeft?: number;
258
+ type?: SubscriptionInfoType;
259
+ }
260
+ export declare enum EditorMode {
261
+ ASSETS = "assets",
262
+ REVIEW = "review",
263
+ TRANSLATE = "TRANSLATE",
264
+ PROOFREAD = "proofread"
265
+ }
266
+ interface ModuleContent {
267
+ /**
268
+ * relative URL to the content page of the module
269
+ */
270
+ url?: string;
271
+ }
272
+ export interface CrowdinAppUtilities extends CrowdinMetadataStore {
273
+ establishCrowdinConnection: (authRequest: string | CrowdinClientRequest) => Promise<{
274
+ context: CrowdinContextInfo;
275
+ client?: Crowdin;
276
+ }>;
277
+ encryptCrowdinConnection: (data: {
278
+ crowdinId: string;
279
+ extra: Record<string, any>;
280
+ }) => string;
281
+ dencryptCrowdinConnection: (hash: string) => Promise<{
282
+ client: Crowdin;
283
+ extra: Record<string, any>;
284
+ }>;
285
+ }
286
+ export interface CrowdinMetadataStore {
287
+ saveMetadata: (id: string, metadata: any, crowdinId?: string) => Promise<void>;
288
+ getMetadata: (id: string) => Promise<any | undefined>;
289
+ deleteMetadata: (id: string) => Promise<void>;
290
+ /**
291
+ * Settings that users manage in the integration module
292
+ */
293
+ getUserSettings: (clientId: string) => Promise<any | undefined>;
294
+ }
295
+ export interface UiModule {
296
+ /**
297
+ * Form schema for react-jsonschema-doc to be used as front-end
298
+ * https://rjsf-team.github.io/react-jsonschema-form/docs
299
+ */
300
+ formSchema?: object;
301
+ /**
302
+ * URL to custom endpoint that can be used instead of default one to save form data.
303
+ * Endpoint should accept POST requests.
304
+ */
305
+ formPostDataUrl?: string;
306
+ /**
307
+ * URL to custom endpoint that can be used instead of default one to retrieve form data.
308
+ * Endpoint should accept GET requests.
309
+ */
310
+ formGetDataUrl?: string;
311
+ /**
312
+ * Additional attributes for react-jsonschema-doc
313
+ */
314
+ formUiSchema?: object;
315
+ /**
316
+ * path to ui folder (e.g. {@example join(__dirname, 'public')})
317
+ */
318
+ uiPath?: string;
319
+ /**
320
+ * page name (default index.html)
321
+ */
322
+ fileName?: string;
323
+ /**
324
+ * Module name
325
+ */
326
+ name?: string;
327
+ }
328
+ export interface ImagePath {
329
+ /**
330
+ * path to app logo (e.g. {@example join(__dirname, 'logo.png')})
331
+ */
332
+ imagePath?: string;
333
+ }
334
+ export interface Logger {
335
+ enabled: boolean;
336
+ log?: (message: string, context?: CrowdinContextInfo) => void;
337
+ }
338
+ export interface Pricing {
339
+ planType: 'free' | 'recurring';
340
+ trial?: number;
341
+ trialCrowdin?: number;
342
+ trialEnterprise?: number;
343
+ cachingSeconds?: number;
344
+ infoDisplayDaysThreshold?: number;
345
+ }
346
+ export declare enum UserPermissions {
347
+ OWNER = "owner",
348
+ MANAGERS = "managers",
349
+ ALL_MEMBERS = "all",
350
+ GUESTS = "guests"
351
+ }
352
+ export declare enum ProjectPermissions {
353
+ OWN = "own",
354
+ RESTRICTED = "restricted"
355
+ }
356
+ export interface DefaultPermissions {
357
+ user?: UserPermissions;
358
+ project?: ProjectPermissions;
359
+ }
360
+ export interface AWSConfig {
361
+ /**
362
+ * AWS bucket name for temporary files
363
+ */
364
+ tmpBucketName?: string;
365
+ /**
366
+ * AWS region
367
+ */
368
+ region?: string;
369
+ }
370
+ export interface SignaturePatterns {
371
+ fileName?: string;
372
+ fileContent?: string;
373
+ }
374
+ export {};
package/out/types.js ADDED
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProjectPermissions = exports.UserPermissions = exports.EditorMode = exports.SubscriptionInfoType = exports.AccountType = exports.Scope = exports.AuthenticationType = void 0;
4
+ var AuthenticationType;
5
+ (function (AuthenticationType) {
6
+ AuthenticationType["CODE"] = "authorization_code";
7
+ AuthenticationType["APP"] = "crowdin_app";
8
+ AuthenticationType["NONE"] = "none";
9
+ })(AuthenticationType = exports.AuthenticationType || (exports.AuthenticationType = {}));
10
+ var Scope;
11
+ (function (Scope) {
12
+ Scope["ALL_SCOPES"] = "all";
13
+ Scope["NOTIFICATIONS"] = "notification";
14
+ Scope["TRANSLATION_MEMORIES"] = "tm";
15
+ Scope["MACHINE_TRANSLATION_ENGINES"] = "mt";
16
+ Scope["GLOSSARIES"] = "glossary";
17
+ Scope["USERS"] = "user";
18
+ Scope["TEAMS"] = "team";
19
+ Scope["GROUPS"] = "group";
20
+ Scope["PROJECTS"] = "project";
21
+ Scope["TASKS"] = "project.task";
22
+ Scope["REPORTS"] = "project.report";
23
+ Scope["TRANSLATION_STATUS"] = "project.status";
24
+ Scope["SOURCE_FILES_AND_STRINGS"] = "project.source";
25
+ Scope["WEBHOOKS"] = "project.webhook";
26
+ Scope["TRANSLATIONS"] = "project.translation";
27
+ Scope["SCREENSHOTS"] = "project.screenshot";
28
+ Scope["SECURITY_LOGS"] = "security-log";
29
+ Scope["VENDORS"] = "vendor";
30
+ })(Scope = exports.Scope || (exports.Scope = {}));
31
+ var AccountType;
32
+ (function (AccountType) {
33
+ AccountType["NORMAL"] = "normal";
34
+ AccountType["ENTERPRISE"] = "enterprise";
35
+ })(AccountType = exports.AccountType || (exports.AccountType = {}));
36
+ var SubscriptionInfoType;
37
+ (function (SubscriptionInfoType) {
38
+ SubscriptionInfoType["TRIAL"] = "trial";
39
+ SubscriptionInfoType["SUBSCRIPTION"] = "subscription";
40
+ })(SubscriptionInfoType = exports.SubscriptionInfoType || (exports.SubscriptionInfoType = {}));
41
+ var EditorMode;
42
+ (function (EditorMode) {
43
+ EditorMode["ASSETS"] = "assets";
44
+ EditorMode["REVIEW"] = "review";
45
+ EditorMode["TRANSLATE"] = "TRANSLATE";
46
+ EditorMode["PROOFREAD"] = "proofread";
47
+ })(EditorMode = exports.EditorMode || (exports.EditorMode = {}));
48
+ var UserPermissions;
49
+ (function (UserPermissions) {
50
+ UserPermissions["OWNER"] = "owner";
51
+ UserPermissions["MANAGERS"] = "managers";
52
+ UserPermissions["ALL_MEMBERS"] = "all";
53
+ UserPermissions["GUESTS"] = "guests";
54
+ })(UserPermissions = exports.UserPermissions || (exports.UserPermissions = {}));
55
+ var ProjectPermissions;
56
+ (function (ProjectPermissions) {
57
+ ProjectPermissions["OWN"] = "own";
58
+ ProjectPermissions["RESTRICTED"] = "restricted";
59
+ })(ProjectPermissions = exports.ProjectPermissions || (exports.ProjectPermissions = {}));
@@ -1,5 +1,6 @@
1
1
  import Crowdin from '@crowdin/crowdin-api-client';
2
- import { AccountType, Config, CrowdinContextInfo, CrowdinCredentials, IntegrationCredentials, IntegrationLogic, SubscriptionInfo } from '../models';
2
+ import { IntegrationCredentials, IntegrationLogic } from '../modules/integration/types';
3
+ import { Config, CrowdinContextInfo, CrowdinCredentials } from '../types';
3
4
  export declare function prepareCrowdinClient({ config, credentials, autoRenew, context, }: {
4
5
  config: Config;
5
6
  credentials: CrowdinCredentials;
@@ -10,11 +11,3 @@ export declare function prepareCrowdinClient({ config, credentials, autoRenew, c
10
11
  token: string;
11
12
  }>;
12
13
  export declare function prepareIntegrationCredentials(config: Config, integration: IntegrationLogic, integrationCredentials: IntegrationCredentials): Promise<any>;
13
- export declare function clearCache(organization: string): void;
14
- export declare function isAppFree(config: Config): boolean;
15
- export declare function checkSubscription({ config, token, organization, accountType, }: {
16
- config: Config;
17
- token: string;
18
- organization: string;
19
- accountType: AccountType;
20
- }): Promise<SubscriptionInfo>;