@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.
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
@@ -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>;
@@ -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"
@@ -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>;
@@ -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"
@@ -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>;
@@ -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.6.2",
3
+ "version": "1.7.1",
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.12.5",
23
- "@crowdin/logs-formatter": "^2.1.10",
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",