@crowdin/app-project-module 1.8.1 → 1.10.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 (42) hide show
  1. package/out/middlewares/crowdin-client.js +5 -5
  2. package/out/middlewares/integration-access-denied.d.ts +1 -1
  3. package/out/middlewares/integration-access-denied.js +2 -35
  4. package/out/middlewares/ui-module.js +3 -3
  5. package/out/modules/custom-mt/index.js +2 -1
  6. package/out/modules/file-processing/handlers/file-download.js +2 -1
  7. package/out/modules/file-processing/handlers/pre-post-process.js +2 -1
  8. package/out/modules/file-processing/handlers/translations-alignment.js +2 -1
  9. package/out/modules/file-processing/index.js +3 -2
  10. package/out/modules/file-processing/util/folder.d.ts +1 -0
  11. package/out/modules/file-processing/util/folder.js +13 -0
  12. package/out/modules/install.js +7 -7
  13. package/out/modules/integration/handlers/integration-logout.js +2 -35
  14. package/out/modules/integration/handlers/job-list.js +4 -1
  15. package/out/modules/integration/handlers/oauth-login.js +2 -2
  16. package/out/modules/integration/handlers/settings-save.js +56 -41
  17. package/out/modules/integration/handlers/sync-settings-save.js +57 -3
  18. package/out/modules/integration/types.d.ts +7 -0
  19. package/out/modules/integration/util/cron.js +7 -40
  20. package/out/modules/integration/util/defaults.js +2 -35
  21. package/out/modules/integration/util/files.js +19 -7
  22. package/out/modules/integration/util/job.d.ts +4 -3
  23. package/out/modules/integration/util/job.js +8 -40
  24. package/out/modules/integration/util/types.d.ts +4 -2
  25. package/out/modules/integration/util/types.js +2 -0
  26. package/out/modules/integration/util/webhooks.d.ts +1 -1
  27. package/out/modules/integration/util/webhooks.js +7 -7
  28. package/out/static/ui/form.bundle.js +99 -44
  29. package/out/static/ui/form.bundle.js.map +1 -1
  30. package/out/static/ui/main.bundle.js +94 -3
  31. package/out/static/ui/main.bundle.js.map +1 -1
  32. package/out/types.d.ts +45 -1
  33. package/out/types.js +11 -1
  34. package/out/util/app-functions/crowdin.d.ts +104 -0
  35. package/out/util/app-functions/crowdin.js +245 -0
  36. package/out/util/app-functions/token.d.ts +71 -0
  37. package/out/util/app-functions/token.js +192 -0
  38. package/out/util/connection.js +11 -12
  39. package/out/util/credentials-masker.js +2 -2
  40. package/out/util/index.js +2 -2
  41. package/out/util/subscription.js +3 -3
  42. package/package.json +26 -2
@@ -1,37 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -48,17 +15,17 @@ exports.filesCron = filesCron;
48
15
  exports.filterFilesFromIntegrationRequest = filterFilesFromIntegrationRequest;
49
16
  exports.createOrUpdateSyncSettings = createOrUpdateSyncSettings;
50
17
  exports.removeFinishedJobs = removeFinishedJobs;
51
- const crowdinAppFunctions = __importStar(require("@crowdin/crowdin-apps-functions"));
52
18
  const storage_1 = require("../../../storage");
19
+ const token_1 = require("../../../util/app-functions/token");
53
20
  const connection_1 = require("../../../util/connection");
54
- const defaults_1 = require("./defaults");
55
- const snapshot_1 = require("./snapshot");
56
21
  const logger_1 = require("../../../util/logger");
22
+ const subscription_1 = require("../../../util/subscription");
57
23
  const types_1 = require("../types");
24
+ const defaults_1 = require("./defaults");
25
+ const files_1 = require("./files");
58
26
  const job_1 = require("./job");
27
+ const snapshot_1 = require("./snapshot");
59
28
  const types_2 = require("./types");
60
- const subscription_1 = require("../../../util/subscription");
61
- const files_1 = require("./files");
62
29
  function runJob(_a) {
63
30
  return __awaiter(this, arguments, void 0, function* ({ config, integration, job, }) {
64
31
  (0, logger_1.log)(`Starting cron job with expression [${job.expression}]`);
@@ -83,7 +50,7 @@ function runJob(_a) {
83
50
  const allIntegrationConfigs = yield (0, storage_1.getStorage)().getAllIntegrationConfigs(crowdinCredentials.id);
84
51
  for (const integrationCredentials of integrationCredentialsList) {
85
52
  const integrationConfig = allIntegrationConfigs.find(({ integrationId }) => integrationId === integrationCredentials.id);
86
- const projectId = crowdinAppFunctions.getProjectId(integrationCredentials.id);
53
+ const projectId = (0, token_1.getProjectId)(integrationCredentials.id);
87
54
  const credentials = yield (0, connection_1.prepareIntegrationCredentials)(config, integration, integrationCredentials);
88
55
  const rootFolder = yield (0, defaults_1.getRootFolder)(config, integration, crowdinClient, projectId);
89
56
  const intConfig = (integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.config) ? JSON.parse(integrationConfig.config) : undefined;
@@ -202,7 +169,7 @@ function processSyncSettings(_a) {
202
169
  if (period !== intConfig.schedule) {
203
170
  return;
204
171
  }
205
- const projectId = crowdinAppFunctions.getProjectId(integrationCredentials.id);
172
+ const projectId = (0, token_1.getProjectId)(integrationCredentials.id);
206
173
  const context = {
207
174
  jwtPayload: {
208
175
  context: {
@@ -1,37 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -50,7 +17,7 @@ exports.getOAuthPollingId = getOAuthPollingId;
50
17
  exports.getOAuthLoginFormId = getOAuthLoginFormId;
51
18
  exports.groupFieldsByCategory = groupFieldsByCategory;
52
19
  exports.buildMenuItems = buildMenuItems;
53
- const crowdinAppFunctions = __importStar(require("@crowdin/crowdin-apps-functions"));
20
+ const crowdin_1 = require("../../../util/app-functions/crowdin");
54
21
  const types_1 = require("../types");
55
22
  function getRootFolder(config, integration, client, projectId) {
56
23
  return __awaiter(this, void 0, void 0, function* () {
@@ -59,7 +26,7 @@ function getRootFolder(config, integration, client, projectId) {
59
26
  }
60
27
  const folder = integration.appFolderName || config.name;
61
28
  const directories = (yield client.sourceFilesApi.withFetchAll().listProjectDirectories(projectId)).data.map((d) => d.data);
62
- const { folder: rootFolder } = yield crowdinAppFunctions.getOrCreateFolder({
29
+ const { folder: rootFolder } = yield (0, crowdin_1.getOrCreateFolder)({
63
30
  directories,
64
31
  client,
65
32
  projectId,
@@ -59,13 +59,16 @@ function skipFilesByRegex(files, skipIntegrationNodes) {
59
59
  }
60
60
  function expandFilesTree(nodes, req, integration, job) {
61
61
  return __awaiter(this, void 0, void 0, function* () {
62
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
62
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
63
63
  if (job && types_2.JobStatus.CANCELED === ((_a = (yield job.get())) === null || _a === void 0 ? void 0 : _a.status)) {
64
64
  throw new Error('Job canceled');
65
65
  }
66
66
  const files = nodes.filter((file) => file.nodeType === undefined || file.nodeType === '1');
67
67
  const folders = nodes.filter((folder) => folder.nodeType === '0' && !nodes.find((node) => node.parentId === folder.id));
68
68
  for (const { id, name } of folders) {
69
+ if (job && types_2.JobStatus.CANCELED === ((_b = (yield job.get())) === null || _b === void 0 ? void 0 : _b.status)) {
70
+ throw new Error('Job canceled');
71
+ }
69
72
  let integrationData = [];
70
73
  try {
71
74
  integrationData = yield integration.getIntegrationFiles({
@@ -95,13 +98,16 @@ function expandFilesTree(nodes, req, integration, job) {
95
98
  const checkNodes = integrationTreeItems
96
99
  .filter((item) => item.id !== id)
97
100
  .map((item) => (Object.assign(Object.assign({}, item), { nodeType: item.nodeType || ('type' in item ? '1' : '0') })));
101
+ if (job && types_2.JobStatus.CANCELED === ((_c = (yield job.get())) === null || _c === void 0 ? void 0 : _c.status)) {
102
+ throw new Error('Job canceled');
103
+ }
98
104
  const expandedResult = yield expandFilesTree(checkNodes, req, integration, job);
99
105
  files.push(...expandedResult);
100
106
  }
101
- const needsFileStatus = ((_c = (_b = integration.filtering) === null || _b === void 0 ? void 0 : _b.integrationFileStatus) === null || _c === void 0 ? void 0 : _c.isNew) ||
102
- ((_e = (_d = integration.filtering) === null || _d === void 0 ? void 0 : _d.integrationFileStatus) === null || _e === void 0 ? void 0 : _e.isUpdated) ||
103
- ((_g = (_f = integration.filtering) === null || _f === void 0 ? void 0 : _f.integrationFileStatus) === null || _g === void 0 ? void 0 : _g.notSynced) ||
104
- ((_j = (_h = integration.filtering) === null || _h === void 0 ? void 0 : _h.integrationFileStatus) === null || _j === void 0 ? void 0 : _j.synced) ||
107
+ const needsFileStatus = ((_e = (_d = integration.filtering) === null || _d === void 0 ? void 0 : _d.integrationFileStatus) === null || _e === void 0 ? void 0 : _e.isNew) ||
108
+ ((_g = (_f = integration.filtering) === null || _f === void 0 ? void 0 : _f.integrationFileStatus) === null || _g === void 0 ? void 0 : _g.isUpdated) ||
109
+ ((_j = (_h = integration.filtering) === null || _h === void 0 ? void 0 : _h.integrationFileStatus) === null || _j === void 0 ? void 0 : _j.notSynced) ||
110
+ ((_l = (_k = integration.filtering) === null || _k === void 0 ? void 0 : _k.integrationFileStatus) === null || _l === void 0 ? void 0 : _l.synced) ||
105
111
  integration.forcePushSources === true;
106
112
  if (needsFileStatus) {
107
113
  const { crowdinId, clientId } = req.crowdinContext;
@@ -159,19 +165,22 @@ function attachFileStatus(files, clientId, crowdinId, integration) {
159
165
  }
160
166
  function expandFilesTreeWithPagination(nodes, req, integration, job) {
161
167
  return __awaiter(this, void 0, void 0, function* () {
162
- var _a, _b;
168
+ var _a, _b, _c, _d;
163
169
  if (job && types_2.JobStatus.CANCELED === ((_a = (yield job.get())) === null || _a === void 0 ? void 0 : _a.status)) {
164
170
  throw new Error('Job canceled');
165
171
  }
166
172
  const files = nodes.filter((file) => file.nodeType === undefined || file.nodeType === '1');
167
173
  const folders = nodes.filter((folder) => folder.nodeType === '0' && !nodes.find((node) => node.parentId === folder.id));
168
174
  for (const folder of folders) {
175
+ if (job && types_2.JobStatus.CANCELED === ((_b = (yield job.get())) === null || _b === void 0 ? void 0 : _b.status)) {
176
+ throw new Error('Job canceled');
177
+ }
169
178
  const allFolderFiles = [];
170
179
  let paginationData = undefined;
171
180
  let hasMore = true;
172
181
  let pageCount = 0;
173
182
  while (hasMore) {
174
- if (job && types_2.JobStatus.CANCELED === ((_b = (yield job.get())) === null || _b === void 0 ? void 0 : _b.status)) {
183
+ if (job && types_2.JobStatus.CANCELED === ((_c = (yield job.get())) === null || _c === void 0 ? void 0 : _c.status)) {
175
184
  throw new Error('Job canceled');
176
185
  }
177
186
  pageCount++;
@@ -225,6 +234,9 @@ function expandFilesTreeWithPagination(nodes, req, integration, job) {
225
234
  const checkNodes = allFolderFiles
226
235
  .filter((item) => item.id !== folder.id)
227
236
  .map((item) => (Object.assign(Object.assign({}, item), { nodeType: item.nodeType || ('type' in item ? '1' : '0') })));
237
+ if (job && types_2.JobStatus.CANCELED === ((_d = (yield job.get())) === null || _d === void 0 ? void 0 : _d.status)) {
238
+ throw new Error('Job canceled');
239
+ }
228
240
  const expandedResult = yield expandFilesTreeWithPagination(checkNodes, req, integration, job);
229
241
  files.push(...expandedResult);
230
242
  }
@@ -1,8 +1,8 @@
1
- import { JobClient, JobClientType, JobStoreType, JobType } from './types';
2
- import { Response } from 'express';
3
1
  import Crowdin from '@crowdin/crowdin-api-client';
2
+ import { Response } from 'express';
4
3
  import { Config } from '../../../types';
5
- export declare function runAsJob({ integrationId, crowdinId, type, title, payload, res, projectId, client, jobType, jobStoreType, jobCallback, onError, reRunJobId, forcePushTranslations, initiatedBy, }: {
4
+ import { JobClient, JobClientType, JobStoreType, JobType } from './types';
5
+ export declare function runAsJob({ integrationId, crowdinId, type, title, payload, res, projectId, client, jobType, jobStoreType, responseData, jobCallback, onError, reRunJobId, forcePushTranslations, initiatedBy, }: {
6
6
  integrationId: string;
7
7
  crowdinId: string;
8
8
  type: JobType;
@@ -13,6 +13,7 @@ export declare function runAsJob({ integrationId, crowdinId, type, title, payloa
13
13
  client: Crowdin;
14
14
  jobType: JobClientType;
15
15
  jobStoreType: JobStoreType;
16
+ responseData?: Record<string, any>;
16
17
  jobCallback: (arg1: JobClient) => Promise<any>;
17
18
  onError?: (e: any, job: JobClient) => Promise<void>;
18
19
  reRunJobId?: string;
@@ -1,37 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -44,24 +11,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
44
11
  Object.defineProperty(exports, "__esModule", { value: true });
45
12
  exports.runAsJob = runAsJob;
46
13
  exports.reRunInProgressJobs = reRunInProgressJobs;
47
- const types_1 = require("./types");
48
14
  const storage_1 = require("../../../storage");
49
- const logger_1 = require("../../../util/logger");
50
- const crowdinAppFunctions = __importStar(require("@crowdin/crowdin-apps-functions"));
15
+ const token_1 = require("../../../util/app-functions/token");
51
16
  const connection_1 = require("../../../util/connection");
52
- const defaults_1 = require("./defaults");
17
+ const logger_1 = require("../../../util/logger");
53
18
  const cron_1 = require("./cron");
19
+ const defaults_1 = require("./defaults");
20
+ const types_1 = require("./types");
54
21
  const blockingJobs = {
55
22
  [types_1.JobType.UPDATE_TO_CROWDIN]: [types_1.JobType.UPDATE_TO_CROWDIN, types_1.JobType.UPDATE_TO_INTEGRATION],
56
23
  [types_1.JobType.UPDATE_TO_INTEGRATION]: [types_1.JobType.UPDATE_TO_CROWDIN, types_1.JobType.UPDATE_TO_INTEGRATION],
57
24
  [types_1.JobType.UPDATE_TARGET_LANGUAGES]: [types_1.JobType.UPDATE_TARGET_LANGUAGES],
58
25
  [types_1.JobType.CROWDIN_SYNC_SETTINGS_SAVE]: [types_1.JobType.CROWDIN_SYNC_SETTINGS_SAVE],
59
26
  [types_1.JobType.INTEGRATION_SYNC_SETTINGS_SAVE]: [types_1.JobType.INTEGRATION_SYNC_SETTINGS_SAVE],
27
+ [types_1.JobType.INTEGRATION_SETTINGS_SAVE]: [types_1.JobType.INTEGRATION_SETTINGS_SAVE],
60
28
  };
61
29
  const maxAttempts = 3;
62
30
  const store = {};
63
31
  function runAsJob(_a) {
64
- return __awaiter(this, arguments, void 0, function* ({ integrationId, crowdinId, type, title, payload, res, projectId, client, jobType, jobStoreType, jobCallback, onError, reRunJobId, forcePushTranslations, initiatedBy, }) {
32
+ return __awaiter(this, arguments, void 0, function* ({ integrationId, crowdinId, type, title, payload, res, projectId, client, jobType, jobStoreType, responseData, jobCallback, onError, reRunJobId, forcePushTranslations, initiatedBy, }) {
65
33
  let jobId;
66
34
  const storage = (0, storage_1.getStorage)();
67
35
  if (!reRunJobId) {
@@ -89,7 +57,7 @@ function runAsJob(_a) {
89
57
  jobId = reRunJobId;
90
58
  }
91
59
  if (res) {
92
- res.status(202).send({ jobId });
60
+ res.status(202).send(Object.assign({ jobId }, responseData));
93
61
  }
94
62
  const isDbStore = jobStoreType === 'db';
95
63
  const job = {
@@ -268,7 +236,7 @@ function reRunInProgressJobs(config) {
268
236
  if (!integrationCredentials || !crowdinCredentials) {
269
237
  return;
270
238
  }
271
- const projectId = crowdinAppFunctions.getProjectId(integrationCredentials.id);
239
+ const projectId = (0, token_1.getProjectId)(integrationCredentials.id);
272
240
  const context = {
273
241
  jwtPayload: {
274
242
  context: {
@@ -9,7 +9,8 @@ export declare enum JobType {
9
9
  UPDATE_TO_INTEGRATION = "updateIntegration",
10
10
  UPDATE_TARGET_LANGUAGES = "updateTargetLanguages",
11
11
  CROWDIN_SYNC_SETTINGS_SAVE = "crowdinSyncSettingsSave",
12
- INTEGRATION_SYNC_SETTINGS_SAVE = "integrationSyncSettingsSave"
12
+ INTEGRATION_SYNC_SETTINGS_SAVE = "integrationSyncSettingsSave",
13
+ INTEGRATION_SETTINGS_SAVE = "integrationSettingsSave"
13
14
  }
14
15
  export declare enum JobStatus {
15
16
  CREATED = "created",
@@ -21,7 +22,8 @@ export declare enum JobStatus {
21
22
  export declare enum JobClientType {
22
23
  CRON = "cron",
23
24
  MANUAL = "manual",
24
- RERUN = "rerun"
25
+ RERUN = "rerun",
26
+ HIDDEN = "hidden"
25
27
  }
26
28
  export type JobStoreType = 'db' | 'in-memory';
27
29
  export interface Job {
@@ -8,6 +8,7 @@ var JobType;
8
8
  JobType["UPDATE_TARGET_LANGUAGES"] = "updateTargetLanguages";
9
9
  JobType["CROWDIN_SYNC_SETTINGS_SAVE"] = "crowdinSyncSettingsSave";
10
10
  JobType["INTEGRATION_SYNC_SETTINGS_SAVE"] = "integrationSyncSettingsSave";
11
+ JobType["INTEGRATION_SETTINGS_SAVE"] = "integrationSettingsSave";
11
12
  })(JobType || (exports.JobType = JobType = {}));
12
13
  var JobStatus;
13
14
  (function (JobStatus) {
@@ -22,4 +23,5 @@ var JobClientType;
22
23
  JobClientType["CRON"] = "cron";
23
24
  JobClientType["MANUAL"] = "manual";
24
25
  JobClientType["RERUN"] = "rerun";
26
+ JobClientType["HIDDEN"] = "hidden";
25
27
  })(JobClientType || (exports.JobClientType = JobClientType = {}));
@@ -1,6 +1,6 @@
1
1
  import Crowdin from '@crowdin/crowdin-api-client';
2
- import { AppSettings, IntegrationLogic, IntegrationSyncSettings, Provider, UpdateCrowdinWebhookPayloadsArgs } from '../types';
3
2
  import { Config, CrowdinContextInfo } from '../../../types';
3
+ import { AppSettings, IntegrationLogic, IntegrationSyncSettings, Provider, UpdateCrowdinWebhookPayloadsArgs } from '../types';
4
4
  export declare const HookEvents: any;
5
5
  export declare function registerWebhooks({ config, credentials, settings, client, crowdinContext, integration, }: {
6
6
  config: Config;
@@ -53,15 +53,15 @@ exports.prepareWebhookData = prepareWebhookData;
53
53
  exports.updateCrowdinFromWebhookRequest = updateCrowdinFromWebhookRequest;
54
54
  exports.listenQueueMessage = listenQueueMessage;
55
55
  const logsFormatter = __importStar(require("@crowdin/logs-formatter"));
56
- const crowdinAppFunctions = __importStar(require("@crowdin/crowdin-apps-functions"));
57
56
  const amqplib_1 = __importDefault(require("amqplib"));
58
- const types_1 = require("../types");
59
57
  const storage_1 = require("../../../storage");
60
58
  const connection_1 = require("../../../util/connection");
61
- const defaults_1 = require("./defaults");
62
59
  const index_1 = require("../../../util/index");
63
60
  const logger_1 = require("../../../util/logger");
61
+ const types_1 = require("../types");
62
+ const defaults_1 = require("./defaults");
64
63
  const files_1 = require("./files");
64
+ const token_1 = require("../../../util/app-functions/token");
65
65
  const prefetchCount = 10;
66
66
  const forceProcessDelay = 10000;
67
67
  const maxReconnectAttempts = 5;
@@ -108,7 +108,7 @@ function registerWebhooks(_a) {
108
108
  yield integration.webhooks.crowdinWebhooks({ client, projectId, available: isWebhookSync, settings });
109
109
  }
110
110
  else {
111
- const { userId } = crowdinAppFunctions.parseCrowdinId(crowdinContext.clientId);
111
+ const { userId } = (0, token_1.parseCrowdinId)(crowdinContext.clientId);
112
112
  const webhookName = `${config.name} application hook ${userId}`;
113
113
  const webhookUrl = makeCrowdinWebhookUrl({
114
114
  config,
@@ -167,7 +167,7 @@ function unregisterWebhooks(_a) {
167
167
  });
168
168
  }
169
169
  else {
170
- const { userId } = crowdinAppFunctions.parseCrowdinId(crowdinContext.clientId);
170
+ const { userId } = (0, token_1.parseCrowdinId)(crowdinContext.clientId);
171
171
  const webhookName = `${config.name} application hook ${userId}`;
172
172
  const webhook = yield getCrowdinProjectWebhook({
173
173
  client,
@@ -214,7 +214,7 @@ function createPayload(events) {
214
214
  }
215
215
  function registerCrowdinWebhook(_a) {
216
216
  return __awaiter(this, arguments, void 0, function* ({ client, config, crowdinContext, events, url, }) {
217
- const { userId } = crowdinAppFunctions.parseCrowdinId(crowdinContext.clientId);
217
+ const { userId } = (0, token_1.parseCrowdinId)(crowdinContext.clientId);
218
218
  const name = `${config.name} application hook ${userId}`;
219
219
  const payload = createPayload(events);
220
220
  yield client.webhooksApi.addWebhook(crowdinContext.jwtPayload.context.project_id, {
@@ -255,7 +255,7 @@ function unregisterAllCrowdinWebhooks(_a) {
255
255
  const crowdinCredentials = yield (0, storage_1.getStorage)().getCrowdinCredentials(crowdinId);
256
256
  if (crowdinCredentials) {
257
257
  const credentials = yield (0, storage_1.getStorage)().getAllIntegrationCredentials(crowdinId);
258
- const projectIds = credentials.map((c) => crowdinAppFunctions.getProjectId(c.id));
258
+ const projectIds = credentials.map((c) => (0, token_1.getProjectId)(c.id));
259
259
  const crowdinClient = yield (0, connection_1.prepareCrowdinClient)({ config, credentials: crowdinCredentials });
260
260
  yield Promise.all(projectIds.map((projectId) => __awaiter(this, void 0, void 0, function* () {
261
261
  const webhooks = yield getAllCrowdinProjectWebhooks({