@crowdin/app-project-module 1.6.1 → 1.7.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.
- package/out/modules/integration/handlers/crowdin-files-target-languages.js +1 -0
- package/out/modules/integration/handlers/crowdin-update.js +1 -0
- package/out/modules/integration/handlers/integration-update.js +1 -0
- package/out/modules/integration/handlers/job-list.js +2 -0
- package/out/modules/integration/handlers/sync-settings-save.js +1 -0
- package/out/modules/integration/util/cron.d.ts +2 -1
- package/out/modules/integration/util/cron.js +7 -4
- package/out/modules/integration/util/job.d.ts +2 -1
- package/out/modules/integration/util/job.js +2 -1
- package/out/modules/integration/util/types.d.ts +2 -1
- package/out/storage/d1.js +9 -5
- package/out/storage/mysql.d.ts +1 -1
- package/out/storage/mysql.js +9 -4
- package/out/storage/postgre.d.ts +2 -1
- package/out/storage/postgre.js +15 -7
- package/out/storage/sqlite.d.ts +2 -0
- package/out/storage/sqlite.js +18 -5
- package/package.json +3 -3
|
@@ -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) {
|
|
@@ -515,9 +518,9 @@ function getAllNewFiles(_a) {
|
|
|
515
518
|
function getNewFoldersFile(folders, snapshotFiles) {
|
|
516
519
|
let files = [];
|
|
517
520
|
for (const folder of folders) {
|
|
518
|
-
const
|
|
519
|
-
if (
|
|
520
|
-
files = files.concat(
|
|
521
|
+
const folderFiles = snapshotFiles.filter((file) => Number(file.parentId) === Number(folder.id));
|
|
522
|
+
if (folderFiles.length) {
|
|
523
|
+
files = files.concat(folderFiles);
|
|
521
524
|
}
|
|
522
525
|
}
|
|
523
526
|
files = files.filter((file) => 'type' in file);
|
|
@@ -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;
|
package/out/storage/d1.js
CHANGED
|
@@ -91,6 +91,7 @@ class D1Storage {
|
|
|
91
91
|
attempt varchar DEFAULT 0,
|
|
92
92
|
errors varchar null,
|
|
93
93
|
processed_entities varchar null,
|
|
94
|
+
initiated_by varchar null,
|
|
94
95
|
created_at varchar not null,
|
|
95
96
|
updated_at varchar null,
|
|
96
97
|
finished_at varchar null
|
|
@@ -141,6 +142,7 @@ class D1Storage {
|
|
|
141
142
|
updateTables() {
|
|
142
143
|
return __awaiter(this, void 0, void 0, function* () {
|
|
143
144
|
yield this.addColumn('job', 'processed_entities', 'null');
|
|
145
|
+
yield this.addColumn('job', 'initiated_by', 'null');
|
|
144
146
|
});
|
|
145
147
|
}
|
|
146
148
|
migrate(skipOnboarding) {
|
|
@@ -532,10 +534,11 @@ class D1Storage {
|
|
|
532
534
|
}
|
|
533
535
|
createJob(params) {
|
|
534
536
|
return __awaiter(this, void 0, void 0, function* () {
|
|
537
|
+
var _a;
|
|
535
538
|
const id = (0, crypto_1.randomUUID)();
|
|
536
539
|
yield this.db
|
|
537
|
-
.prepare('INSERT INTO job(id, integration_id, crowdin_id, type, payload, title, created_at) VALUES (?, ?, ?, ?, ?, ?, ?)')
|
|
538
|
-
.bind(id, params.integrationId, params.crowdinId, params.type, params.payload, params.title, Date.now().toString())
|
|
540
|
+
.prepare('INSERT INTO job(id, integration_id, crowdin_id, type, payload, title, initiated_by, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)')
|
|
541
|
+
.bind(id, params.integrationId, params.crowdinId, params.type, params.payload, params.title, (_a = params.initiatedBy) !== null && _a !== void 0 ? _a : null, Date.now().toString())
|
|
539
542
|
.run();
|
|
540
543
|
return id;
|
|
541
544
|
});
|
|
@@ -594,7 +597,7 @@ class D1Storage {
|
|
|
594
597
|
const row = yield this.db
|
|
595
598
|
.prepare(`
|
|
596
599
|
SELECT id, integration_id as integrationId, crowdin_id as crowdinId, type, payload, progress, status,
|
|
597
|
-
title, info, data, attempt, errors, processed_entities as processedEntities, created_at as createdAt, updated_at as updatedAt, finished_at as finishedAt
|
|
600
|
+
title, info, data, attempt, errors, processed_entities as processedEntities, initiated_by as initiatedBy, created_at as createdAt, updated_at as updatedAt, finished_at as finishedAt
|
|
598
601
|
FROM job
|
|
599
602
|
WHERE id = ?
|
|
600
603
|
`)
|
|
@@ -609,7 +612,7 @@ class D1Storage {
|
|
|
609
612
|
return __awaiter(this, void 0, void 0, function* () {
|
|
610
613
|
const result = yield this.db
|
|
611
614
|
.prepare(`
|
|
612
|
-
SELECT id, integration_id as integrationId, crowdin_id as crowdinId, type, payload, progress, status, title, info, data, attempt, errors, processed_entities as processedEntities, created_at as createdAt, updated_at as updatedAt, finished_at as finishedAt
|
|
615
|
+
SELECT id, integration_id as integrationId, crowdin_id as crowdinId, type, payload, progress, status, title, info, data, attempt, errors, processed_entities as processedEntities, initiated_by as initiatedBy, created_at as createdAt, updated_at as updatedAt, finished_at as finishedAt
|
|
613
616
|
FROM job
|
|
614
617
|
WHERE integration_id = ? AND crowdin_id = ? AND finished_at is NULL
|
|
615
618
|
`)
|
|
@@ -627,7 +630,7 @@ class D1Storage {
|
|
|
627
630
|
return __awaiter(this, void 0, void 0, function* () {
|
|
628
631
|
const result = yield this.db
|
|
629
632
|
.prepare(`
|
|
630
|
-
SELECT id, integration_id as integrationId, crowdin_id as crowdinId, type, payload, progress, status, title, info, data, attempt, errors, processed_entities as processedEntities, created_at as createdAt, updated_at as updatedAt, finished_at as finishedAt
|
|
633
|
+
SELECT id, integration_id as integrationId, crowdin_id as crowdinId, type, payload, progress, status, title, info, data, attempt, errors, processed_entities as processedEntities, initiated_by as initiatedBy, created_at as createdAt, updated_at as updatedAt, finished_at as finishedAt
|
|
631
634
|
FROM job
|
|
632
635
|
WHERE status IN (?,?) AND finished_at is NULL
|
|
633
636
|
`)
|
|
@@ -652,6 +655,7 @@ class D1Storage {
|
|
|
652
655
|
info,
|
|
653
656
|
data,
|
|
654
657
|
attempt,
|
|
658
|
+
initiated_by as initiatedBy,
|
|
655
659
|
created_at as createdAt,
|
|
656
660
|
updated_at as updatedAt,
|
|
657
661
|
finished_at as finishedAt
|
package/out/storage/mysql.d.ts
CHANGED
|
@@ -77,7 +77,7 @@ export declare class MySQLStorage implements Storage {
|
|
|
77
77
|
getAllIntegrationConfigs(crowdinId: string): Promise<IntegrationConfig[]>;
|
|
78
78
|
getIntegrationConfig(integrationId: string): Promise<IntegrationConfig | undefined>;
|
|
79
79
|
updateIntegrationConfig(integrationId: string, config: any): Promise<void>;
|
|
80
|
-
createJob({ integrationId, crowdinId, type, title, payload }: CreateJobParams): Promise<string>;
|
|
80
|
+
createJob({ integrationId, crowdinId, type, title, payload, initiatedBy }: CreateJobParams): Promise<string>;
|
|
81
81
|
updateJob({ id, progress, status, info, data, attempt, errors, processedEntities, }: UpdateJobParams): Promise<void>;
|
|
82
82
|
getJob({ id }: GetJobParams): Promise<Job | undefined>;
|
|
83
83
|
getActiveJobs({ integrationId, crowdinId }: GetActiveJobsParams): Promise<Job[] | undefined>;
|
package/out/storage/mysql.js
CHANGED
|
@@ -138,6 +138,7 @@ class MySQLStorage {
|
|
|
138
138
|
attempt int 0,
|
|
139
139
|
errors text,
|
|
140
140
|
processed_entities text,
|
|
141
|
+
initiated_by varchar(255),
|
|
141
142
|
created_at varchar(255) not null,
|
|
142
143
|
updated_at varchar(255),
|
|
143
144
|
finished_at varchar(255)
|
|
@@ -602,13 +603,13 @@ class MySQLStorage {
|
|
|
602
603
|
});
|
|
603
604
|
}
|
|
604
605
|
createJob(_a) {
|
|
605
|
-
return __awaiter(this, arguments, void 0, function* ({ integrationId, crowdinId, type, title, payload }) {
|
|
606
|
+
return __awaiter(this, arguments, void 0, function* ({ integrationId, crowdinId, type, title, payload, initiatedBy }) {
|
|
606
607
|
const id = (0, crypto_1.randomUUID)();
|
|
607
608
|
yield this.dbPromise;
|
|
608
609
|
yield this.executeQuery((connection) => connection.execute(`
|
|
609
|
-
INSERT INTO job(id, integration_id, crowdin_id, type, payload, title, created_at)
|
|
610
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
611
|
-
`, [id, integrationId, crowdinId, type, payload, title, Date.now().toString()]));
|
|
610
|
+
INSERT INTO job(id, integration_id, crowdin_id, type, payload, title, initiated_by, created_at)
|
|
611
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
612
|
+
`, [id, integrationId, crowdinId, type, payload, title, initiatedBy !== null && initiatedBy !== void 0 ? initiatedBy : null, Date.now().toString()]));
|
|
612
613
|
return id;
|
|
613
614
|
});
|
|
614
615
|
}
|
|
@@ -679,6 +680,7 @@ class MySQLStorage {
|
|
|
679
680
|
attempt,
|
|
680
681
|
errors,
|
|
681
682
|
processed_entities as "processedEntities",
|
|
683
|
+
initiated_by as "initiatedBy",
|
|
682
684
|
created_at as "createdAt",
|
|
683
685
|
updated_at as "updatedAt",
|
|
684
686
|
finished_at as "finishedAt"
|
|
@@ -707,6 +709,7 @@ class MySQLStorage {
|
|
|
707
709
|
attempt,
|
|
708
710
|
errors,
|
|
709
711
|
processed_entities as "processedEntities",
|
|
712
|
+
initiated_by as "initiatedBy",
|
|
710
713
|
created_at as "createdAt",
|
|
711
714
|
updated_at as "updatedAt",
|
|
712
715
|
finished_at as "finishedAt"
|
|
@@ -743,6 +746,7 @@ class MySQLStorage {
|
|
|
743
746
|
attempt,
|
|
744
747
|
errors,
|
|
745
748
|
processed_entities as "processedEntities",
|
|
749
|
+
initiated_by as "initiatedBy",
|
|
746
750
|
created_at as "createdAt",
|
|
747
751
|
updated_at as "updatedAt",
|
|
748
752
|
finished_at as "finishedAt"
|
|
@@ -771,6 +775,7 @@ class MySQLStorage {
|
|
|
771
775
|
info,
|
|
772
776
|
data,
|
|
773
777
|
attempt,
|
|
778
|
+
initiated_by as "initiatedBy",
|
|
774
779
|
created_at as "createdAt",
|
|
775
780
|
updated_at as "updatedAt",
|
|
776
781
|
finished_at as "finishedAt"
|
package/out/storage/postgre.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export declare class PostgreStorage implements Storage {
|
|
|
51
51
|
addColumns(client: Client, newColumns: string[], tableName: string): Promise<void>;
|
|
52
52
|
addColumn(client: Client, columnName: string, tableName: string, columnType: string): Promise<void>;
|
|
53
53
|
addTables(client: Client): Promise<void>;
|
|
54
|
+
alterTables(client: Client): Promise<void>;
|
|
54
55
|
saveCrowdinCredentials(credentials: CrowdinCredentials): Promise<void>;
|
|
55
56
|
updateCrowdinCredentials(credentials: CrowdinCredentials): Promise<void>;
|
|
56
57
|
getCrowdinCredentials(id: string): Promise<CrowdinCredentials | undefined>;
|
|
@@ -88,7 +89,7 @@ export declare class PostgreStorage implements Storage {
|
|
|
88
89
|
getAllIntegrationConfigs(crowdinId: string): Promise<IntegrationConfig[]>;
|
|
89
90
|
getIntegrationConfig(integrationId: string): Promise<IntegrationConfig | undefined>;
|
|
90
91
|
updateIntegrationConfig(integrationId: string, config: any): Promise<void>;
|
|
91
|
-
createJob({ integrationId, crowdinId, type, payload, title }: CreateJobParams): Promise<string>;
|
|
92
|
+
createJob({ integrationId, crowdinId, type, payload, title, initiatedBy }: CreateJobParams): Promise<string>;
|
|
92
93
|
updateJob({ id, progress, status, info, data, attempt, errors, processedEntities, }: UpdateJobParams): Promise<void>;
|
|
93
94
|
getJob({ id }: GetJobParams): Promise<Job | undefined>;
|
|
94
95
|
getActiveJobs({ integrationId, crowdinId }: GetActiveJobsParams): Promise<Job[] | undefined>;
|
package/out/storage/postgre.js
CHANGED
|
@@ -103,6 +103,7 @@ class PostgreStorage {
|
|
|
103
103
|
attempt int default 0,
|
|
104
104
|
errors varchar null,
|
|
105
105
|
processed_entities varchar null,
|
|
106
|
+
initiated_by varchar null,
|
|
106
107
|
created_at varchar not null,
|
|
107
108
|
updated_at varchar null,
|
|
108
109
|
finished_at varchar null
|
|
@@ -222,6 +223,7 @@ class PostgreStorage {
|
|
|
222
223
|
yield client.query('SELECT pg_advisory_lock($1)', [this.migrationLockId]);
|
|
223
224
|
try {
|
|
224
225
|
yield this.addTables(client);
|
|
226
|
+
yield this.alterTables(client);
|
|
225
227
|
}
|
|
226
228
|
finally {
|
|
227
229
|
yield client.query('SELECT pg_advisory_unlock($1)', [this.migrationLockId]);
|
|
@@ -271,6 +273,11 @@ class PostgreStorage {
|
|
|
271
273
|
}
|
|
272
274
|
});
|
|
273
275
|
}
|
|
276
|
+
alterTables(client) {
|
|
277
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
278
|
+
yield this.addColumn(client, 'initiated_by', 'job', 'varchar NULL');
|
|
279
|
+
});
|
|
280
|
+
}
|
|
274
281
|
saveCrowdinCredentials(credentials) {
|
|
275
282
|
return __awaiter(this, void 0, void 0, function* () {
|
|
276
283
|
yield this.dbPromise;
|
|
@@ -646,14 +653,14 @@ class PostgreStorage {
|
|
|
646
653
|
});
|
|
647
654
|
}
|
|
648
655
|
createJob(_a) {
|
|
649
|
-
return __awaiter(this, arguments, void 0, function* ({ integrationId, crowdinId, type, payload, title }) {
|
|
656
|
+
return __awaiter(this, arguments, void 0, function* ({ integrationId, crowdinId, type, payload, title, initiatedBy }) {
|
|
650
657
|
const id = (0, crypto_1.randomUUID)();
|
|
651
658
|
yield this.dbPromise;
|
|
652
659
|
yield this.executeQuery((client) => client.query(`
|
|
653
660
|
INSERT
|
|
654
|
-
INTO job(id, integration_id, crowdin_id, type, payload, title, created_at)
|
|
655
|
-
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
|
656
|
-
`, [id, integrationId, crowdinId, type, payload, title, Date.now().toString()]));
|
|
661
|
+
INTO job(id, integration_id, crowdin_id, type, payload, title, initiated_by, created_at)
|
|
662
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
663
|
+
`, [id, integrationId, crowdinId, type, payload, title, initiatedBy !== null && initiatedBy !== void 0 ? initiatedBy : null, Date.now().toString()]));
|
|
657
664
|
return id;
|
|
658
665
|
});
|
|
659
666
|
}
|
|
@@ -723,7 +730,7 @@ class PostgreStorage {
|
|
|
723
730
|
return this.executeQuery((client) => __awaiter(this, void 0, void 0, function* () {
|
|
724
731
|
const res = yield client.query(`
|
|
725
732
|
SELECT id, integration_id as "integrationId", crowdin_id as "crowdinId", type, payload, progress, status,
|
|
726
|
-
title, info, data, attempt, errors, processed_entities as "processedEntities", created_at as "createdAt", updated_at as "updatedAt", finished_at as "finishedAt"
|
|
733
|
+
title, info, data, attempt, errors, processed_entities as "processedEntities", initiated_by as "initiatedBy", created_at as "createdAt", updated_at as "updatedAt", finished_at as "finishedAt"
|
|
727
734
|
FROM job
|
|
728
735
|
WHERE id = $1
|
|
729
736
|
`, [id]);
|
|
@@ -737,7 +744,7 @@ class PostgreStorage {
|
|
|
737
744
|
return this.executeQuery((client) => __awaiter(this, void 0, void 0, function* () {
|
|
738
745
|
const res = yield client.query(`
|
|
739
746
|
SELECT id, integration_id as "integrationId", crowdin_id as "crowdinId", type, payload, progress, status,
|
|
740
|
-
title, info, data, attempt, errors, processed_entities as "processedEntities", created_at as "createdAt", updated_at as "updatedAt", finished_at as "finishedAt"
|
|
747
|
+
title, info, data, attempt, errors, processed_entities as "processedEntities", initiated_by as "initiatedBy", created_at as "createdAt", updated_at as "updatedAt", finished_at as "finishedAt"
|
|
741
748
|
FROM job
|
|
742
749
|
WHERE integration_id = $1 AND crowdin_id = $2 AND finished_at is NULL
|
|
743
750
|
`, [integrationId, crowdinId]);
|
|
@@ -757,7 +764,7 @@ class PostgreStorage {
|
|
|
757
764
|
return this.executeQuery((client) => __awaiter(this, void 0, void 0, function* () {
|
|
758
765
|
const res = yield client.query(`
|
|
759
766
|
SELECT id, integration_id as "integrationId", crowdin_id as "crowdinId", type, payload, progress, status,
|
|
760
|
-
title, info, data, attempt, errors, processed_entities as "processedEntities", created_at as "createdAt", updated_at as "updatedAt", finished_at as "finishedAt"
|
|
767
|
+
title, info, data, attempt, errors, processed_entities as "processedEntities", initiated_by as "initiatedBy", created_at as "createdAt", updated_at as "updatedAt", finished_at as "finishedAt"
|
|
761
768
|
FROM job
|
|
762
769
|
WHERE status IN ($1, $2) AND finished_at is NULL
|
|
763
770
|
`, [types_2.JobStatus.IN_PROGRESS, types_2.JobStatus.CREATED]);
|
|
@@ -782,6 +789,7 @@ class PostgreStorage {
|
|
|
782
789
|
info,
|
|
783
790
|
data,
|
|
784
791
|
attempt,
|
|
792
|
+
initiated_by as "initiatedBy",
|
|
785
793
|
created_at as "createdAt",
|
|
786
794
|
updated_at as "updatedAt",
|
|
787
795
|
finished_at as "finishedAt"
|
package/out/storage/sqlite.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export declare class SQLiteStorage implements Storage {
|
|
|
24
24
|
synced_data: string;
|
|
25
25
|
};
|
|
26
26
|
constructor(config: SQLiteStorageConfig);
|
|
27
|
+
private addColumn;
|
|
28
|
+
private updateTables;
|
|
27
29
|
migrate(skipOnboarding?: boolean): Promise<void>;
|
|
28
30
|
saveCrowdinCredentials(credentials: CrowdinCredentials): Promise<void>;
|
|
29
31
|
updateCrowdinCredentials(credentials: CrowdinCredentials): Promise<void>;
|
package/out/storage/sqlite.js
CHANGED
|
@@ -93,6 +93,7 @@ class SQLiteStorage {
|
|
|
93
93
|
attempt varchar DEFAULT 0,
|
|
94
94
|
errors varchar null,
|
|
95
95
|
processed_entities varchar null,
|
|
96
|
+
initiated_by varchar null,
|
|
96
97
|
created_at varchar not null,
|
|
97
98
|
updated_at varchar null,
|
|
98
99
|
finished_at varchar null
|
|
@@ -122,6 +123,16 @@ class SQLiteStorage {
|
|
|
122
123
|
};
|
|
123
124
|
this.config = config;
|
|
124
125
|
}
|
|
126
|
+
addColumn(tableName, column, defaultValue) {
|
|
127
|
+
const columns = this.db.pragma(`table_info(${tableName})`);
|
|
128
|
+
const exists = columns.some((col) => col.name === column);
|
|
129
|
+
if (!exists) {
|
|
130
|
+
this.db.prepare(`ALTER TABLE ${tableName} ADD COLUMN ${column} varchar ${defaultValue}`).run();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
updateTables() {
|
|
134
|
+
this.addColumn('job', 'initiated_by', 'null');
|
|
135
|
+
}
|
|
125
136
|
migrate(skipOnboarding) {
|
|
126
137
|
return __awaiter(this, void 0, void 0, function* () {
|
|
127
138
|
this.db = require('better-sqlite3')((0, path_1.join)(this.config.dbFolder, types_2.storageFiles.SQLITE));
|
|
@@ -130,6 +141,7 @@ class SQLiteStorage {
|
|
|
130
141
|
for (const [tableName, schema] of Object.entries(this.tables)) {
|
|
131
142
|
this.db.prepare(`CREATE TABLE IF NOT EXISTS ${tableName} ${schema}`).run();
|
|
132
143
|
}
|
|
144
|
+
this.updateTables();
|
|
133
145
|
}
|
|
134
146
|
catch (error) {
|
|
135
147
|
console.error('Error during database migration:', error);
|
|
@@ -511,9 +523,9 @@ class SQLiteStorage {
|
|
|
511
523
|
const id = (0, crypto_1.randomUUID)();
|
|
512
524
|
this.db.prepare(`
|
|
513
525
|
INSERT INTO job
|
|
514
|
-
(id, integration_id, crowdin_id, type, title, payload, created_at)
|
|
526
|
+
(id, integration_id, crowdin_id, type, title, payload, initiated_by, created_at)
|
|
515
527
|
VALUES
|
|
516
|
-
(@id, @integrationId, @crowdinId, @type, @title, @payload, @createdAt)
|
|
528
|
+
(@id, @integrationId, @crowdinId, @type, @title, @payload, @initiatedBy, @createdAt)
|
|
517
529
|
`).run(Object.assign({ id, createdAt: Date.now().toString() }, params));
|
|
518
530
|
return id;
|
|
519
531
|
});
|
|
@@ -571,7 +583,7 @@ class SQLiteStorage {
|
|
|
571
583
|
return __awaiter(this, void 0, void 0, function* () {
|
|
572
584
|
return this.db.prepare(`
|
|
573
585
|
SELECT id, integration_id as integrationId, crowdin_id as crowdinId, type, payload, progress, status,
|
|
574
|
-
title, info, data, attempt, errors, processed_entities as processedEntities, created_at as createdAt, updated_at as updatedAt, finished_at as finishedAt
|
|
586
|
+
title, info, data, attempt, errors, processed_entities as processedEntities, initiated_by as initiatedBy, created_at as createdAt, updated_at as updatedAt, finished_at as finishedAt
|
|
575
587
|
FROM job
|
|
576
588
|
WHERE id = ?
|
|
577
589
|
`).get(params.id);
|
|
@@ -580,7 +592,7 @@ class SQLiteStorage {
|
|
|
580
592
|
getActiveJobs(params) {
|
|
581
593
|
return __awaiter(this, void 0, void 0, function* () {
|
|
582
594
|
return this.db.prepare(`
|
|
583
|
-
SELECT id, integration_id as integrationId, crowdin_id as crowdinId, type, payload, progress, status, title, info, data, attempt, errors, processed_entities as processedEntities, created_at as createdAt, updated_at as updatedAt, finished_at as finishedAt
|
|
595
|
+
SELECT id, integration_id as integrationId, crowdin_id as crowdinId, type, payload, progress, status, title, info, data, attempt, errors, processed_entities as processedEntities, initiated_by as initiatedBy, created_at as createdAt, updated_at as updatedAt, finished_at as finishedAt
|
|
584
596
|
FROM job
|
|
585
597
|
WHERE integration_id = ? AND crowdin_id = ? AND finished_at is NULL
|
|
586
598
|
`).all(params.integrationId, params.crowdinId);
|
|
@@ -594,7 +606,7 @@ class SQLiteStorage {
|
|
|
594
606
|
getAllInProgressJobs() {
|
|
595
607
|
return __awaiter(this, void 0, void 0, function* () {
|
|
596
608
|
return this.db.prepare(`
|
|
597
|
-
SELECT id, integration_id as integrationId, crowdin_id as crowdinId, type, payload, progress, status, title, info, data, attempt, errors, processed_entities as processedEntities, created_at as createdAt, updated_at as updatedAt, finished_at as finishedAt
|
|
609
|
+
SELECT id, integration_id as integrationId, crowdin_id as crowdinId, type, payload, progress, status, title, info, data, attempt, errors, processed_entities as processedEntities, initiated_by as initiatedBy, created_at as createdAt, updated_at as updatedAt, finished_at as finishedAt
|
|
598
610
|
FROM job
|
|
599
611
|
WHERE status IN (?,?) AND finished_at is NULL
|
|
600
612
|
`).all(types_1.JobStatus.IN_PROGRESS, types_1.JobStatus.CREATED);
|
|
@@ -615,6 +627,7 @@ class SQLiteStorage {
|
|
|
615
627
|
info,
|
|
616
628
|
data,
|
|
617
629
|
attempt,
|
|
630
|
+
initiated_by as initiatedBy,
|
|
618
631
|
created_at as createdAt,
|
|
619
632
|
updated_at as updatedAt,
|
|
620
633
|
finished_at as finishedAt
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crowdin/app-project-module",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Module that generates for you all common endpoints for serving standalone Crowdin App",
|
|
5
5
|
"main": "out/index.js",
|
|
6
6
|
"types": "out/index.d.ts",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"out/**/*"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@crowdin/crowdin-apps-functions": "^0.
|
|
23
|
-
"@crowdin/logs-formatter": "^2.
|
|
22
|
+
"@crowdin/crowdin-apps-functions": "^0.13.0",
|
|
23
|
+
"@crowdin/logs-formatter": "^2.2.0",
|
|
24
24
|
"@godaddy/terminus": "^4.12.1",
|
|
25
25
|
"ajv": "^8.17.1",
|
|
26
26
|
"amqplib": "^0.10.9",
|