@crowdin/app-project-module 0.29.0 → 0.29.2

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.
@@ -13,8 +13,8 @@ export interface Storage {
13
13
  getAllIntegrationCredentials(crowdinId: string): Promise<IntegrationCredentials[]>;
14
14
  deleteIntegrationCredentials(id: string): Promise<void>;
15
15
  deleteAllIntegrationCredentials(crowdinId: string): Promise<void>;
16
- saveMetadata(id: string, metadata: any): Promise<void>;
17
- updateMetadata(id: string, metadata: any): Promise<void>;
16
+ saveMetadata(id: string, metadata: any, crowdinId?: string): Promise<void>;
17
+ updateMetadata(id: string, metadata: any, crowdinId?: string): Promise<void>;
18
18
  getMetadata(id: string): Promise<any | undefined>;
19
19
  deleteMetadata(id: string): Promise<void>;
20
20
  getSyncSettingsByProvider(integrationId: string, provider: Provider): Promise<IntegrationSyncSettings | undefined>;
@@ -30,8 +30,8 @@ export declare class MySQLStorage implements Storage {
30
30
  getAllIntegrationCredentials(crowdinId: string): Promise<IntegrationCredentials[]>;
31
31
  deleteIntegrationCredentials(id: string): Promise<void>;
32
32
  deleteAllIntegrationCredentials(crowdinId: string): Promise<void>;
33
- saveMetadata(id: string, metadata: any): Promise<void>;
34
- updateMetadata(id: string, metadata: any): Promise<void>;
33
+ saveMetadata(id: string, metadata: any, crowdinId: string): Promise<void>;
34
+ updateMetadata(id: string, metadata: any, crowdinId?: string): Promise<void>;
35
35
  getMetadata(id: string): Promise<any>;
36
36
  deleteMetadata(id: string): Promise<void>;
37
37
  getSyncSettingsByProvider(integrationId: string, provider: string): Promise<IntegrationSyncSettings | undefined>;
@@ -100,7 +100,8 @@ class MySQLStorage {
100
100
  create table if not exists app_metadata
101
101
  (
102
102
  id varchar(255) primary key,
103
- data text
103
+ data text,
104
+ crowdin_id text
104
105
  )
105
106
  `);
106
107
  yield connection.execute(`
@@ -173,6 +174,7 @@ class MySQLStorage {
173
174
  yield connection.execute('DELETE FROM crowdin_credentials where id = ?', [id]);
174
175
  yield connection.execute('DELETE FROM integration_credentials where crowdin_id = ?', [id]);
175
176
  yield connection.execute('DELETE FROM sync_settings WHERE crowdin_id = ?', [id]);
177
+ yield connection.execute('DELETE FROM app_metadata WHERE crowdin_id = ?', [id]);
176
178
  yield connection.execute('DELETE FROM files_snapshot WHERE crowdin_id = ?', [id]);
177
179
  }));
178
180
  });
@@ -237,16 +239,24 @@ class MySQLStorage {
237
239
  }));
238
240
  });
239
241
  }
240
- saveMetadata(id, metadata) {
242
+ saveMetadata(id, metadata, crowdinId) {
241
243
  return __awaiter(this, void 0, void 0, function* () {
242
244
  yield this.dbPromise;
243
- yield this.executeQuery((connection) => connection.execute('INSERT INTO app_metadata(id, data) VALUES (?, ?)', [id, JSON.stringify(metadata)]));
245
+ yield this.executeQuery((connection) => connection.execute('INSERT INTO app_metadata(id, data, crowdin_id) VALUES (?, ?, ?)', [
246
+ id,
247
+ JSON.stringify(metadata),
248
+ crowdinId,
249
+ ]));
244
250
  });
245
251
  }
246
- updateMetadata(id, metadata) {
252
+ updateMetadata(id, metadata, crowdinId) {
247
253
  return __awaiter(this, void 0, void 0, function* () {
248
254
  yield this.dbPromise;
249
- yield this.executeQuery((connection) => connection.execute('UPDATE app_metadata SET data = ? WHERE id = ?', [JSON.stringify(metadata), id]));
255
+ yield this.executeQuery((connection) => connection.execute('UPDATE app_metadata SET data = ?, crowdin_id = ? WHERE id = ?', [
256
+ JSON.stringify(metadata),
257
+ crowdinId,
258
+ id,
259
+ ]));
250
260
  });
251
261
  }
252
262
  getMetadata(id) {
@@ -34,8 +34,8 @@ export declare class PostgreStorage implements Storage {
34
34
  getAllIntegrationCredentials(crowdinId: string): Promise<IntegrationCredentials[]>;
35
35
  deleteIntegrationCredentials(id: string): Promise<void>;
36
36
  deleteAllIntegrationCredentials(crowdinId: string): Promise<void>;
37
- saveMetadata(id: string, metadata: any): Promise<void>;
38
- updateMetadata(id: string, metadata: any): Promise<void>;
37
+ saveMetadata(id: string, metadata: any, crowdinId: string): Promise<void>;
38
+ updateMetadata(id: string, metadata: any, crowdinId?: string): Promise<void>;
39
39
  getMetadata(id: string): Promise<any>;
40
40
  deleteMetadata(id: string): Promise<void>;
41
41
  getSyncSettingsByProvider(integrationId: string, provider: string): Promise<IntegrationSyncSettings | undefined>;
@@ -96,7 +96,8 @@ class PostgreStorage {
96
96
  create table if not exists app_metadata
97
97
  (
98
98
  id varchar primary key,
99
- data varchar
99
+ data varchar,
100
+ crowdin_id varchar,
100
101
  )
101
102
  `);
102
103
  yield client.query(`
@@ -170,6 +171,7 @@ class PostgreStorage {
170
171
  yield client.query('DELETE FROM integration_credentials where crowdin_id = $1', [id]);
171
172
  yield client.query('DELETE FROM sync_settings WHERE crowdin_id = $1', [id]);
172
173
  yield client.query('DELETE FROM files_snapshot WHERE crowdin_id = $1', [id]);
174
+ yield client.query('DELETE FROM app_metadata WHERE crowdin_id = $1', [id]);
173
175
  }));
174
176
  });
175
177
  }
@@ -233,16 +235,24 @@ class PostgreStorage {
233
235
  }));
234
236
  });
235
237
  }
236
- saveMetadata(id, metadata) {
238
+ saveMetadata(id, metadata, crowdinId) {
237
239
  return __awaiter(this, void 0, void 0, function* () {
238
240
  yield this.dbPromise;
239
- yield this.executeQuery((client) => client.query('INSERT INTO app_metadata(id, data) VALUES ($1, $2)', [id, JSON.stringify(metadata)]));
241
+ yield this.executeQuery((client) => client.query('INSERT INTO app_metadata(id, data, crowdin_id) VALUES ($1, $2, $3)', [
242
+ id,
243
+ JSON.stringify(metadata),
244
+ crowdinId,
245
+ ]));
240
246
  });
241
247
  }
242
- updateMetadata(id, metadata) {
248
+ updateMetadata(id, metadata, crowdinId) {
243
249
  return __awaiter(this, void 0, void 0, function* () {
244
250
  yield this.dbPromise;
245
- yield this.executeQuery((client) => client.query('UPDATE app_metadata SET data = $1 WHERE id = $2', [JSON.stringify(metadata), id]));
251
+ yield this.executeQuery((client) => client.query('UPDATE app_metadata SET data = $1, crowdin_id = $2 WHERE id = $3', [
252
+ JSON.stringify(metadata),
253
+ crowdinId,
254
+ id,
255
+ ]));
246
256
  });
247
257
  }
248
258
  getMetadata(id) {
@@ -14,6 +14,7 @@ export declare class SQLiteStorage implements Storage {
14
14
  private run;
15
15
  private get;
16
16
  private each;
17
+ private updateTable;
17
18
  private addColumns;
18
19
  migrate(): Promise<void>;
19
20
  saveCrowdinCredentials(credentials: CrowdinCredentials): Promise<void>;
@@ -28,8 +29,8 @@ export declare class SQLiteStorage implements Storage {
28
29
  getAllIntegrationCredentials(crowdinId: string): Promise<IntegrationCredentials[]>;
29
30
  deleteIntegrationCredentials(id: string): Promise<void>;
30
31
  deleteAllIntegrationCredentials(crowdinId: string): Promise<void>;
31
- saveMetadata(id: string, metadata: any): Promise<void>;
32
- updateMetadata(id: string, metadata: any): Promise<void>;
32
+ saveMetadata(id: string, metadata: any, crowdinId?: string): Promise<void>;
33
+ updateMetadata(id: string, metadata: any, crowdinId?: string): Promise<void>;
33
34
  getMetadata(id: string): Promise<any>;
34
35
  deleteMetadata(id: string): Promise<void>;
35
36
  getSyncSettingsByProvider(integrationId: string, provider: string): Promise<IntegrationSyncSettings | undefined>;
@@ -92,22 +92,27 @@ class SQLiteStorage {
92
92
  });
93
93
  });
94
94
  }
95
- addColumns() {
95
+ updateTable(newColumns, tableName) {
96
96
  return __awaiter(this, void 0, void 0, function* () {
97
- const newColumns = ['app_secret', 'domain', 'user_id', 'organization_id', 'base_url'];
98
- const crowdinCredentialsInfo = yield this.each('PRAGMA table_info(crowdin_credentials);', []);
97
+ const tableInfo = yield this.each(`PRAGMA table_info(${tableName});`, []);
99
98
  //@ts-ignore
100
- crowdinCredentialsInfo.map((columnInfo) => __awaiter(this, void 0, void 0, function* () {
99
+ tableInfo.map((columnInfo) => __awaiter(this, void 0, void 0, function* () {
101
100
  const index = newColumns.indexOf(columnInfo.name);
102
101
  if (~index) {
103
102
  newColumns.splice(index, 1);
104
103
  }
105
104
  }));
106
105
  for (const column of newColumns) {
107
- yield this.run(`ALTER TABLE crowdin_credentials ADD COLUMN ${column} varchar null;`, []);
106
+ yield this.run(`ALTER TABLE ${tableName} ADD COLUMN ${column} varchar null;`, []);
108
107
  }
109
108
  });
110
109
  }
110
+ addColumns() {
111
+ return __awaiter(this, void 0, void 0, function* () {
112
+ yield this.updateTable(['app_secret', 'domain', 'user_id', 'organization_id', 'base_url'], 'crowdin_credentials');
113
+ yield this.updateTable(['crowdin_id'], 'app_metadata');
114
+ });
115
+ }
111
116
  migrate() {
112
117
  return __awaiter(this, void 0, void 0, function* () {
113
118
  let _connection_res;
@@ -166,8 +171,9 @@ class SQLiteStorage {
166
171
  yield this._run(`
167
172
  create table if not exists app_metadata
168
173
  (
169
- id varchar not null primary key,
170
- data varchar null
174
+ id varchar not null primary key,
175
+ data varchar null,
176
+ crowdin_id varchar null
171
177
  );
172
178
  `, []);
173
179
  yield this._run(`
@@ -232,6 +238,7 @@ class SQLiteStorage {
232
238
  yield this.run('DELETE FROM crowdin_credentials where id = ?', [id]);
233
239
  yield this.run('DELETE FROM integration_credentials where crowdin_id = ?', [id]);
234
240
  yield this.run('DELETE FROM sync_settings WHERE crowdin_id = ?', [id]);
241
+ yield this.run('DELETE FROM app_metadata WHERE crowdin_id = ?', [id]);
235
242
  yield this.run('DELETE FROM files_snapshot WHERE crowdin_id = ?', [id]);
236
243
  });
237
244
  }
@@ -273,11 +280,19 @@ class SQLiteStorage {
273
280
  yield this.run('DELETE FROM files_snapshot where crowdin_id = ?', [crowdinId]);
274
281
  });
275
282
  }
276
- saveMetadata(id, metadata) {
277
- return this.run('INSERT INTO app_metadata(id, data) VALUES (?, ?)', [id, JSON.stringify(metadata)]);
283
+ saveMetadata(id, metadata, crowdinId) {
284
+ return this.run('INSERT INTO app_metadata(id, data, crowdin_id) VALUES (?, ?, ?)', [
285
+ id,
286
+ JSON.stringify(metadata),
287
+ crowdinId,
288
+ ]);
278
289
  }
279
- updateMetadata(id, metadata) {
280
- return this.run('UPDATE app_metadata SET data = ? WHERE id = ?', [JSON.stringify(metadata), id]);
290
+ updateMetadata(id, metadata, crowdinId) {
291
+ return this.run('UPDATE app_metadata SET data = ?, crowdin_id = ? WHERE id = ?', [
292
+ JSON.stringify(metadata),
293
+ crowdinId,
294
+ id,
295
+ ]);
281
296
  }
282
297
  getMetadata(id) {
283
298
  return __awaiter(this, void 0, void 0, function* () {
@@ -45,91 +45,83 @@ function getUsersApiManifest(endpoints) {
45
45
  return apiModuleManifest;
46
46
  }
47
47
  function getDefaultApiEndpointsManifest(config) {
48
- var _a;
49
- const apiModuleManifest = [
50
- {
48
+ const apiModuleManifest = [];
49
+ if (config.projectIntegration) {
50
+ apiModuleManifest.push({
51
51
  key: 'crowdin-files-api',
52
52
  name: 'Get Crowdin Files',
53
53
  url: '/crowdin-files',
54
54
  method: models_1.RequestMethods.GET,
55
55
  description: 'Get a list of synced files',
56
56
  documentationUrl: '/api-docs#tag/Files/operation/crowdin.files',
57
- },
58
- {
57
+ }, {
59
58
  key: 'crowdin-files-api',
60
59
  name: 'File Translation Progress',
61
60
  url: '/file-progress',
62
61
  method: models_1.RequestMethods.GET,
63
62
  description: 'Get file translation progress',
64
63
  documentationUrl: '/api-docs#tag/Files/operation/file.progress',
65
- },
66
- {
64
+ }, {
67
65
  key: 'integration-files-api',
68
66
  name: 'Get Integration Files',
69
67
  url: '/integration-files',
70
68
  method: models_1.RequestMethods.GET,
71
69
  description: 'Get integration data',
72
70
  documentationUrl: '/api-docs#tag/Files/operation/integration.files',
73
- },
74
- {
71
+ }, {
75
72
  key: 'crowdin-update-api',
76
73
  name: 'Update Crowdin',
77
74
  url: '/crowdin-update',
78
75
  method: models_1.RequestMethods.POST,
79
76
  description: 'Update crowdin data',
80
77
  documentationUrl: '/api-docs#tag/Files/operation/crowdin.update',
81
- },
82
- {
78
+ }, {
83
79
  key: 'integration-update-api',
84
80
  name: 'Update Integration',
85
81
  url: '/integration-update',
86
82
  method: models_1.RequestMethods.POST,
87
83
  description: 'Update integration data',
88
84
  documentationUrl: '/api-docs#tag/Files/operation/integration.update',
89
- },
90
- {
85
+ }, {
91
86
  key: 'settings-api',
92
87
  name: 'Get App Settings',
93
88
  url: '/settings',
94
89
  method: models_1.RequestMethods.GET,
95
90
  documentationUrl: '/api-docs#tag/Settings/operation/settings.get',
96
- },
97
- {
91
+ }, {
98
92
  key: 'settings-update-api',
99
93
  name: 'Update App Settings',
100
94
  url: '/settings',
101
95
  method: models_1.RequestMethods.POST,
102
96
  documentationUrl: '/api-docs#tag/Settings/operation/settings.update',
103
- },
104
- {
97
+ }, {
105
98
  key: 'sync-settings-api',
106
99
  name: 'Get Sync Settings',
107
100
  url: '/sync-settings',
108
101
  method: models_1.RequestMethods.GET,
109
102
  documentationUrl: '/api-docs#tag/Settings/operation/sync.settings.get',
110
- },
111
- {
103
+ }, {
112
104
  key: 'sync-settings-update-api',
113
105
  name: 'Update Sync Settings',
114
106
  url: '/sync-settings',
115
107
  method: models_1.RequestMethods.POST,
116
108
  documentationUrl: '/api-docs#tag/Settings/operation/sync.settings.update',
117
- },
118
- ];
119
- if ((_a = config.projectIntegration) === null || _a === void 0 ? void 0 : _a.loginForm) {
120
- apiModuleManifest.push({
121
- key: 'login-data',
122
- name: 'Get Login Fields',
123
- url: '/login-fields',
124
- method: models_1.RequestMethods.GET,
125
- documentationUrl: '/api-docs#tag/Login/operation/integration.fields',
126
- }, {
127
- key: 'login',
128
- name: 'Login',
129
- url: '/login',
130
- method: models_1.RequestMethods.POST,
131
- documentationUrl: '/api-docs#tag/Login/operation/integration.login',
132
109
  });
110
+ if (config.projectIntegration.loginForm) {
111
+ apiModuleManifest.push({
112
+ key: 'login-data',
113
+ name: 'Get Login Fields',
114
+ url: '/login-fields',
115
+ method: models_1.RequestMethods.GET,
116
+ documentationUrl: '/api-docs#tag/Login/operation/integration.fields',
117
+ }, {
118
+ key: 'login',
119
+ name: 'Login',
120
+ url: '/login',
121
+ method: models_1.RequestMethods.POST,
122
+ documentationUrl: '/api-docs#tag/Login/operation/integration.login',
123
+ });
124
+ }
133
125
  }
134
126
  return apiModuleManifest;
135
127
  }
@@ -7,6 +7,7 @@
7
7
  style='max-width:680px; position: relative;'
8
8
  >
9
9
  <crowdin-card
10
+ id="card"
10
11
  is-shadowed
11
12
  >
12
13
  <div id="form"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "0.29.0",
3
+ "version": "0.29.2",
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",