@crowdin/app-project-module 1.6.2 → 1.7.1

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.
@@ -80,6 +80,7 @@ function handle(config, integration) {
80
80
  client: req.crowdinApiClient,
81
81
  jobType: types_1.JobClientType.MANUAL,
82
82
  jobStoreType: integration.jobStoreType,
83
+ initiatedBy: String(req.crowdinContext.jwtPayload.context.user_id),
83
84
  jobCallback: () => __awaiter(this, void 0, void 0, function* () {
84
85
  yield integration.updateFilesTargetLanguages({
85
86
  projectId,
@@ -85,6 +85,7 @@ function handle(config, integration) {
85
85
  client: req.crowdinApiClient,
86
86
  jobType: types_1.JobClientType.MANUAL,
87
87
  jobStoreType: integration.jobStoreType,
88
+ initiatedBy: String(req.crowdinContext.jwtPayload.context.user_id),
88
89
  jobCallback: (job) => __awaiter(this, void 0, void 0, function* () {
89
90
  if (payload && (payload === null || payload === void 0 ? void 0 : payload.length)) {
90
91
  payload = yield (0, files_1.expandFilesTree)(payload, req, integration, job);
@@ -89,6 +89,7 @@ function handle(config, integration) {
89
89
  client,
90
90
  jobType: types_1.JobClientType.MANUAL,
91
91
  jobStoreType: integration.jobStoreType,
92
+ initiatedBy: String(req.crowdinContext.jwtPayload.context.user_id),
92
93
  jobCallback: (job) => __awaiter(this, void 0, void 0, function* () {
93
94
  const result = yield integration.updateIntegration({
94
95
  projectId,
@@ -29,12 +29,14 @@ function handle() {
29
29
  return;
30
30
  }
31
31
  const filteredJobs = jobs.map((job) => {
32
+ var _a;
32
33
  const baseJob = {
33
34
  id: job.id,
34
35
  progress: job.progress,
35
36
  status: job.status,
36
37
  title: job.title,
37
38
  type: job.type,
39
+ initiatedBy: (_a = job.initiatedBy) !== null && _a !== void 0 ? _a : null,
38
40
  createdAt: new Date(+job.createdAt).toISOString(),
39
41
  finishedAt: job.finishedAt ? new Date(+job.finishedAt).toISOString() : null,
40
42
  };
@@ -47,6 +47,7 @@ function handle(config, integration) {
47
47
  client: req.crowdinApiClient,
48
48
  jobType: types_1.JobClientType.MANUAL,
49
49
  jobStoreType: integration.jobStoreType,
50
+ initiatedBy: String(req.crowdinContext.jwtPayload.context.user_id),
50
51
  jobCallback: (job) => __awaiter(this, void 0, void 0, function* () {
51
52
  var _a;
52
53
  if (Array.isArray(expandIntegrationFolders) && expandIntegrationFolders.length) {
@@ -7,7 +7,7 @@ export declare function runJob({ config, integration, job, }: {
7
7
  integration: IntegrationLogic;
8
8
  job: CronJob;
9
9
  }): Promise<void>;
10
- export declare function runUpdateProviderJob({ integrationId, crowdinId, type, title, payload, jobType, projectId, client, integration, context, credentials, rootFolder, settings, reRunJobId, }: {
10
+ export declare function runUpdateProviderJob({ integrationId, crowdinId, type, title, payload, jobType, projectId, client, integration, context, credentials, rootFolder, settings, reRunJobId, initiatedBy, }: {
11
11
  integrationId: string;
12
12
  crowdinId: string;
13
13
  type: JobType;
@@ -22,6 +22,7 @@ export declare function runUpdateProviderJob({ integrationId, crowdinId, type, t
22
22
  rootFolder?: SourceFilesModel.Directory;
23
23
  settings?: any;
24
24
  reRunJobId?: string;
25
+ initiatedBy?: string;
25
26
  }): Promise<void>;
26
27
  export declare function filesCron({ config, integration, period, }: {
27
28
  config: Config;
@@ -102,7 +102,7 @@ function runJob(_a) {
102
102
  });
103
103
  }
104
104
  function runUpdateProviderJob(_a) {
105
- return __awaiter(this, arguments, void 0, function* ({ integrationId, crowdinId, type, title, payload, jobType, projectId, client, integration, context, credentials, rootFolder, settings, reRunJobId, }) {
105
+ return __awaiter(this, arguments, void 0, function* ({ integrationId, crowdinId, type, title, payload, jobType, projectId, client, integration, context, credentials, rootFolder, settings, reRunJobId, initiatedBy, }) {
106
106
  try {
107
107
  yield (0, job_1.runAsJob)({
108
108
  integrationId,
@@ -114,6 +114,7 @@ function runUpdateProviderJob(_a) {
114
114
  projectId,
115
115
  client,
116
116
  reRunJobId,
117
+ initiatedBy,
117
118
  jobStoreType: integration.jobStoreType,
118
119
  jobCallback: (job) => __awaiter(this, void 0, void 0, function* () {
119
120
  if (type === types_2.JobType.UPDATE_TO_CROWDIN) {
@@ -380,6 +381,7 @@ function processSyncSettings(_a) {
380
381
  credentials,
381
382
  rootFolder,
382
383
  settings: intConfig,
384
+ initiatedBy: 'autosync',
383
385
  });
384
386
  }
385
387
  catch (e) {
@@ -452,6 +454,7 @@ function processSyncSettings(_a) {
452
454
  credentials,
453
455
  rootFolder,
454
456
  settings: intConfig,
457
+ initiatedBy: 'autosync',
455
458
  });
456
459
  }
457
460
  catch (e) {
@@ -2,7 +2,7 @@ import { JobClient, JobClientType, JobStoreType, JobType } from './types';
2
2
  import { Response } from 'express';
3
3
  import Crowdin from '@crowdin/crowdin-api-client';
4
4
  import { Config } from '../../../types';
5
- export declare function runAsJob({ integrationId, crowdinId, type, title, payload, res, projectId, client, jobType, jobStoreType, jobCallback, onError, reRunJobId, forcePushTranslations, }: {
5
+ export declare function runAsJob({ integrationId, crowdinId, type, title, payload, res, projectId, client, jobType, jobStoreType, jobCallback, onError, reRunJobId, forcePushTranslations, initiatedBy, }: {
6
6
  integrationId: string;
7
7
  crowdinId: string;
8
8
  type: JobType;
@@ -17,5 +17,6 @@ export declare function runAsJob({ integrationId, crowdinId, type, title, payloa
17
17
  onError?: (e: any, job: JobClient) => Promise<void>;
18
18
  reRunJobId?: string;
19
19
  forcePushTranslations?: boolean;
20
+ initiatedBy?: string;
20
21
  }): Promise<void>;
21
22
  export declare function reRunInProgressJobs(config: Config): Promise<void>;
@@ -61,7 +61,7 @@ const blockingJobs = {
61
61
  const maxAttempts = 3;
62
62
  const store = {};
63
63
  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, }) {
64
+ return __awaiter(this, arguments, void 0, function* ({ integrationId, crowdinId, type, title, payload, res, projectId, client, jobType, jobStoreType, jobCallback, onError, reRunJobId, forcePushTranslations, initiatedBy, }) {
65
65
  let jobId;
66
66
  const storage = (0, storage_1.getStorage)();
67
67
  if (!reRunJobId) {
@@ -82,6 +82,7 @@ function runAsJob(_a) {
82
82
  type,
83
83
  title: title || '',
84
84
  payload: JSON.stringify(payload),
85
+ initiatedBy,
85
86
  });
86
87
  }
87
88
  else {
@@ -42,10 +42,11 @@ export interface Job {
42
42
  attempt?: number;
43
43
  errors?: string;
44
44
  processedEntities?: string;
45
+ initiatedBy?: string;
45
46
  }
46
47
  export type GetJobParams = Pick<Job, 'id'>;
47
48
  export type GetActiveJobsParams = Pick<Job, 'integrationId' | 'crowdinId'>;
48
- export type CreateJobParams = Pick<Job, 'integrationId' | 'crowdinId' | 'type' | 'payload' | 'title'>;
49
+ export type CreateJobParams = Pick<Job, 'integrationId' | 'crowdinId' | 'type' | 'payload' | 'title' | 'initiatedBy'>;
49
50
  export type UpdateJobParams = {
50
51
  id: string;
51
52
  progress?: number;
@@ -1416,15 +1416,19 @@
1416
1416
  new Promise((resolve) => {
1417
1417
  AP.getUsers((res) => {
1418
1418
  const users = Object.values(res).filter((user) => user.id !== Number(userId));
1419
- resolve(users
1420
- .map((user) => `<option value="${user.id}">${sanitizeHTML(getUserFullName(user))}</option>`)
1421
- .join(''));
1419
+ resolve(users);
1422
1420
  });
1423
1421
  }),
1424
1422
  ])
1425
1423
  .then(([managers, users]) => {
1426
- select.innerHTML = users;
1427
- select.value = managers;
1424
+ const parsedManagers = (JSON.parse(managers) || []);
1425
+ const availableUsers = users;
1426
+ const validUserIds = new Set(availableUsers.map((user) => `${user.id}`));
1427
+ const filteredManagers = parsedManagers.filter((id) => validUserIds.has(id));
1428
+ select.innerHTML = availableUsers
1429
+ .map((user) => `<option value="${user.id}">${sanitizeHTML(getUserFullName(user))}</option>`)
1430
+ .join('');
1431
+ select.value = JSON.stringify(filteredManagers);
1428
1432
  })
1429
1433
  .catch((e) => catchRejection(e, "Can't fetch users"))
1430
1434
  .finally(() => unsetLoader('#permissions-modal'));