@crowdin/app-project-module 0.71.2 → 0.73.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.
@@ -67,6 +67,10 @@
67
67
  margin: 0;
68
68
  }
69
69
 
70
+ .m-2 {
71
+ margin: 16px;
72
+ }
73
+
70
74
  .info-text {
71
75
  max-width: 800px;
72
76
  }
@@ -259,3 +263,76 @@
259
263
  display: none;
260
264
  }
261
265
  }
266
+
267
+ .confirm-users-block .flex > div {
268
+ width: 40%;
269
+ margin-bottom: 8px
270
+ }
271
+
272
+ .confirm-users-block crowdin-p {
273
+ line-height: 1;
274
+ }
275
+
276
+ table {
277
+ width: 100%;
278
+ border-collapse: separate;
279
+ border-spacing: 0;
280
+ }
281
+ th, td {
282
+ padding: 16px;
283
+ text-align: left;
284
+ border-bottom: 1px solid var(--crowdin-border-color);
285
+ }
286
+ th {
287
+ font-size: 14px;
288
+ }
289
+ .permission-description {
290
+ font-size: 12px;
291
+ color: var(--crowdin-text-muted);
292
+ margin-top: 4px;
293
+ }
294
+ .affected-users {
295
+ ul {
296
+ list-style: none;
297
+ padding: 0;
298
+ margin: 0;
299
+ }
300
+
301
+ li {
302
+ font-size: 14px;
303
+
304
+ &:not(:last-child) {
305
+ margin-bottom: 4px;
306
+ }
307
+ }
308
+ }
309
+
310
+ .badge {
311
+ display: inline-block;
312
+ padding: 4px 12px;
313
+ border-radius: 15px;
314
+ font-size: 12px;
315
+ font-weight: 500;
316
+ text-align: center;
317
+ position: relative;
318
+ cursor: default;
319
+ }
320
+ .badge-granted {
321
+ background-color: var(--crowdin-success);
322
+ color: var(--crowdin-white);
323
+ }
324
+
325
+ .badge-will-be-granted {
326
+ background-color: var(--crowdin-warning-bg);
327
+ color: var(--crowdin-warning);
328
+ }
329
+
330
+ .badge-not-available {
331
+ background-color: var(--crowdin-danger);
332
+ color: var(--crowdin-white);
333
+ }
334
+
335
+ .status {
336
+ position: relative;
337
+ text-align: right;
338
+ }
@@ -11,6 +11,7 @@ export interface Storage {
11
11
  deleteCrowdinCredentials(id: string): Promise<void>;
12
12
  saveIntegrationCredentials(id: string, credentials: any, crowdinId: string): Promise<void>;
13
13
  updateIntegrationCredentials(id: string, credentials: any): Promise<void>;
14
+ updateIntegrationManagers(id: string, managers: any): Promise<void>;
14
15
  getIntegrationCredentials(id: string): Promise<IntegrationCredentials | undefined>;
15
16
  getAllIntegrationCredentials(crowdinId: string): Promise<IntegrationCredentials[]>;
16
17
  deleteIntegrationCredentials(id: string): Promise<void>;
@@ -28,6 +28,7 @@ export declare class MySQLStorage implements Storage {
28
28
  deleteCrowdinCredentials(id: string): Promise<void>;
29
29
  saveIntegrationCredentials(id: string, credentials: any, crowdinId: string): Promise<void>;
30
30
  updateIntegrationCredentials(id: string, credentials: any): Promise<void>;
31
+ updateIntegrationManagers(id: string, managers: any): Promise<void>;
31
32
  getIntegrationCredentials(id: string): Promise<IntegrationCredentials | undefined>;
32
33
  getAllIntegrationCredentials(crowdinId: string): Promise<IntegrationCredentials[]>;
33
34
  deleteIntegrationCredentials(id: string): Promise<void>;
@@ -84,7 +84,8 @@ class MySQLStorage {
84
84
  (
85
85
  id varchar(255) primary key,
86
86
  credentials text,
87
- crowdin_id varchar(255) not null
87
+ crowdin_id varchar(255) not null,
88
+ managers text
88
89
  )
89
90
  `);
90
91
  yield connection.execute(`
@@ -266,11 +267,17 @@ class MySQLStorage {
266
267
  yield this.executeQuery((connection) => connection.execute('UPDATE integration_credentials SET credentials = ? WHERE id = ?', [credentials, id]));
267
268
  });
268
269
  }
270
+ updateIntegrationManagers(id, managers) {
271
+ return __awaiter(this, void 0, void 0, function* () {
272
+ yield this.dbPromise;
273
+ yield this.executeQuery((connection) => connection.execute('UPDATE integration_credentials SET managers = ? WHERE id = ?', [managers, id]));
274
+ });
275
+ }
269
276
  getIntegrationCredentials(id) {
270
277
  return __awaiter(this, void 0, void 0, function* () {
271
278
  yield this.dbPromise;
272
279
  return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
273
- const [rows] = yield connection.execute('SELECT id, credentials, crowdin_id as "crowdinId" FROM integration_credentials WHERE id = ?', [id]);
280
+ const [rows] = yield connection.execute('SELECT id, credentials, crowdin_id as "crowdinId", managers FROM integration_credentials WHERE id = ?', [id]);
274
281
  return (rows || [])[0];
275
282
  }));
276
283
  });
@@ -279,7 +286,7 @@ class MySQLStorage {
279
286
  return __awaiter(this, void 0, void 0, function* () {
280
287
  yield this.dbPromise;
281
288
  return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
282
- const [rows] = yield connection.execute('SELECT id, credentials, crowdin_id as "crowdinId" FROM integration_credentials WHERE crowdin_id = ?', [crowdinId]);
289
+ const [rows] = yield connection.execute('SELECT id, credentials, crowdin_id as "crowdinId", managers FROM integration_credentials WHERE crowdin_id = ?', [crowdinId]);
283
290
  return rows || [];
284
291
  }));
285
292
  });
@@ -35,6 +35,7 @@ export declare class PostgreStorage implements Storage {
35
35
  deleteCrowdinCredentials(id: string): Promise<void>;
36
36
  saveIntegrationCredentials(id: string, credentials: any, crowdinId: string): Promise<void>;
37
37
  updateIntegrationCredentials(id: string, credentials: any): Promise<void>;
38
+ updateIntegrationManagers(id: string, managers: any): Promise<void>;
38
39
  getIntegrationCredentials(id: string): Promise<IntegrationCredentials | undefined>;
39
40
  getAllIntegrationCredentials(crowdinId: string): Promise<IntegrationCredentials[]>;
40
41
  deleteIntegrationCredentials(id: string): Promise<void>;
@@ -112,7 +112,8 @@ class PostgreStorage {
112
112
  (
113
113
  id varchar primary key,
114
114
  credentials varchar,
115
- crowdin_id varchar not null
115
+ crowdin_id varchar not null,
116
+ managers varchar
116
117
  )
117
118
  `);
118
119
  yield client.query(`
@@ -293,11 +294,17 @@ class PostgreStorage {
293
294
  yield this.executeQuery((client) => client.query('UPDATE integration_credentials SET credentials = $1 WHERE id = $2', [credentials, id]));
294
295
  });
295
296
  }
297
+ updateIntegrationManagers(id, managers) {
298
+ return __awaiter(this, void 0, void 0, function* () {
299
+ yield this.dbPromise;
300
+ yield this.executeQuery((client) => client.query('UPDATE integration_credentials SET managers = $1 WHERE id = $2', [managers, id]));
301
+ });
302
+ }
296
303
  getIntegrationCredentials(id) {
297
304
  return __awaiter(this, void 0, void 0, function* () {
298
305
  yield this.dbPromise;
299
306
  return this.executeQuery((client) => __awaiter(this, void 0, void 0, function* () {
300
- const res = yield client.query('SELECT id, credentials, crowdin_id as "crowdinId" FROM integration_credentials WHERE id = $1', [id]);
307
+ const res = yield client.query('SELECT id, credentials, crowdin_id as "crowdinId", managers FROM integration_credentials WHERE id = $1', [id]);
301
308
  return res === null || res === void 0 ? void 0 : res.rows[0];
302
309
  }));
303
310
  });
@@ -306,7 +313,7 @@ class PostgreStorage {
306
313
  return __awaiter(this, void 0, void 0, function* () {
307
314
  yield this.dbPromise;
308
315
  return this.executeQuery((client) => __awaiter(this, void 0, void 0, function* () {
309
- const res = yield client.query('SELECT id, credentials, crowdin_id as "crowdinId" FROM integration_credentials WHERE crowdin_id = $1', [crowdinId]);
316
+ const res = yield client.query('SELECT id, credentials, crowdin_id as "crowdinId", managers FROM integration_credentials WHERE crowdin_id = $1', [crowdinId]);
310
317
  return (res === null || res === void 0 ? void 0 : res.rows) || [];
311
318
  }));
312
319
  });
@@ -22,6 +22,7 @@ export declare class SQLiteStorage implements Storage {
22
22
  private addColumn;
23
23
  private updateTables;
24
24
  private moveIntegrationSettings;
25
+ private migrateManagers;
25
26
  migrate(): Promise<void>;
26
27
  saveCrowdinCredentials(credentials: CrowdinCredentials): Promise<void>;
27
28
  updateCrowdinCredentials(credentials: CrowdinCredentials): Promise<void>;
@@ -30,6 +31,7 @@ export declare class SQLiteStorage implements Storage {
30
31
  deleteCrowdinCredentials(id: string): Promise<void>;
31
32
  saveIntegrationCredentials(id: string, credentials: any, crowdinId: string): Promise<void>;
32
33
  updateIntegrationCredentials(id: string, credentials: any): Promise<void>;
34
+ updateIntegrationManagers(id: string, managers: any): Promise<void>;
33
35
  getIntegrationCredentials(id: string): Promise<IntegrationCredentials | undefined>;
34
36
  getAllIntegrationCredentials(crowdinId: string): Promise<IntegrationCredentials[]>;
35
37
  deleteIntegrationCredentials(id: string): Promise<void>;
@@ -145,6 +145,26 @@ class SQLiteStorage {
145
145
  yield this.removeColumns('config', 'integration_credentials');
146
146
  });
147
147
  }
148
+ migrateManagers() {
149
+ return __awaiter(this, void 0, void 0, function* () {
150
+ const tableInfo = yield this.each('PRAGMA table_info(integration_credentials);', []);
151
+ const exists = tableInfo.some((columnInfo) => columnInfo.name === 'managers');
152
+ if (exists) {
153
+ return;
154
+ }
155
+ yield this.addColumn('integration_credentials', 'managers', 'null');
156
+ const integrationSettings = yield this.each('SELECT integration_id, config FROM integration_settings', []);
157
+ for (const settings of integrationSettings) {
158
+ const config = JSON.parse(settings.config);
159
+ if (config.managers) {
160
+ yield this.run('UPDATE integration_credentials SET managers = ? WHERE id = ?', [
161
+ JSON.stringify(config.managers),
162
+ settings.integration_id,
163
+ ]);
164
+ }
165
+ }
166
+ });
167
+ }
148
168
  migrate() {
149
169
  return __awaiter(this, void 0, void 0, function* () {
150
170
  let _connection_res;
@@ -186,7 +206,8 @@ class SQLiteStorage {
186
206
  (
187
207
  id varchar not null primary key,
188
208
  credentials varchar not null,
189
- crowdin_id varchar not null
209
+ crowdin_id varchar not null,
210
+ managers varchar null
190
211
  );
191
212
  `, []);
192
213
  yield this._run(`
@@ -283,6 +304,7 @@ class SQLiteStorage {
283
304
  // TODO: temporary code
284
305
  yield this.updateTables();
285
306
  yield this.moveIntegrationSettings();
307
+ yield this.migrateManagers();
286
308
  }
287
309
  catch (e) {
288
310
  this._rej && this._rej(e);
@@ -353,16 +375,19 @@ class SQLiteStorage {
353
375
  updateIntegrationCredentials(id, credentials) {
354
376
  return this.run('UPDATE integration_credentials SET credentials = ? WHERE id = ?', [credentials, id]);
355
377
  }
378
+ updateIntegrationManagers(id, managers) {
379
+ return this.run('UPDATE integration_credentials SET managers = ? WHERE id = ?', [managers, id]);
380
+ }
356
381
  getIntegrationCredentials(id) {
357
382
  return __awaiter(this, void 0, void 0, function* () {
358
- const row = yield this.get('SELECT id, credentials, crowdin_id as crowdinId FROM integration_credentials WHERE id = ?', [id]);
383
+ const row = yield this.get('SELECT id, credentials, crowdin_id as crowdinId, managers FROM integration_credentials WHERE id = ?', [id]);
359
384
  if (row) {
360
385
  return row;
361
386
  }
362
387
  });
363
388
  }
364
389
  getAllIntegrationCredentials(crowdinId) {
365
- return this.each('SELECT id, credentials, crowdin_id as crowdinId FROM integration_credentials WHERE crowdin_id = ?', [crowdinId]);
390
+ return this.each('SELECT id, credentials, crowdin_id as crowdinId, managers FROM integration_credentials WHERE crowdin_id = ?', [crowdinId]);
366
391
  }
367
392
  deleteIntegrationCredentials(id) {
368
393
  return __awaiter(this, void 0, void 0, function* () {
package/out/types.d.ts CHANGED
@@ -281,7 +281,8 @@ export declare enum Scope {
281
281
  AI = "ai",
282
282
  AI_PROVIDERS = "ai.provider",
283
283
  AI_PROMPTS = "ai.prompt",
284
- AI_PROXIES = "ai.proxy"
284
+ AI_PROXIES = "ai.proxy",
285
+ APPLICATIONS = "application"
285
286
  }
286
287
  export interface CrowdinClientRequest extends Request {
287
288
  crowdinApiClient: Crowdin;
@@ -423,7 +424,8 @@ export declare enum UserPermissions {
423
424
  OWNER = "owner",
424
425
  MANAGERS = "managers",
425
426
  ALL_MEMBERS = "all",
426
- GUESTS = "guests"
427
+ GUESTS = "guests",
428
+ RESTRICTED = "restricted"
427
429
  }
428
430
  export declare enum ProjectPermissions {
429
431
  OWN = "own",
package/out/types.js CHANGED
@@ -34,6 +34,7 @@ var Scope;
34
34
  Scope["AI_PROVIDERS"] = "ai.provider";
35
35
  Scope["AI_PROMPTS"] = "ai.prompt";
36
36
  Scope["AI_PROXIES"] = "ai.proxy";
37
+ Scope["APPLICATIONS"] = "application";
37
38
  })(Scope = exports.Scope || (exports.Scope = {}));
38
39
  var AccountType;
39
40
  (function (AccountType) {
@@ -58,6 +59,7 @@ var UserPermissions;
58
59
  UserPermissions["MANAGERS"] = "managers";
59
60
  UserPermissions["ALL_MEMBERS"] = "all";
60
61
  UserPermissions["GUESTS"] = "guests";
62
+ UserPermissions["RESTRICTED"] = "restricted";
61
63
  })(UserPermissions = exports.UserPermissions || (exports.UserPermissions = {}));
62
64
  var ProjectPermissions;
63
65
  (function (ProjectPermissions) {
@@ -13,3 +13,4 @@ export declare function isAuthorizedConfig(config: Config | UnauthorizedConfig):
13
13
  export declare function isJson(string: string): boolean;
14
14
  export declare function getPreviousDate(days: number): Date;
15
15
  export declare function prepareFormDataMetadataId(req: CrowdinClientRequest, config: Config): Promise<string>;
16
+ export declare function validateEmail(email: string | number): boolean;
package/out/util/index.js CHANGED
@@ -32,7 +32,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
32
32
  });
33
33
  };
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.prepareFormDataMetadataId = exports.getPreviousDate = exports.isJson = exports.isAuthorizedConfig = exports.getLogoUrl = exports.executeWithRetry = exports.decryptData = exports.encryptData = exports.runAsyncWrapper = exports.CodeError = void 0;
35
+ exports.validateEmail = exports.prepareFormDataMetadataId = exports.getPreviousDate = exports.isJson = exports.isAuthorizedConfig = exports.getLogoUrl = exports.executeWithRetry = exports.decryptData = exports.encryptData = exports.runAsyncWrapper = exports.CodeError = void 0;
36
36
  const crypto = __importStar(require("crypto-js"));
37
37
  const storage_1 = require("../storage");
38
38
  const types_1 = require("../types");
@@ -151,3 +151,14 @@ function prepareFormDataMetadataId(req, config) {
151
151
  });
152
152
  }
153
153
  exports.prepareFormDataMetadataId = prepareFormDataMetadataId;
154
+ function validateEmail(email) {
155
+ if (!isNaN(+email)) {
156
+ return false;
157
+ }
158
+ if (`${email}`.trim().length > 76) {
159
+ return false;
160
+ }
161
+ const emailRegExp = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
162
+ return emailRegExp.test(String(email).toLowerCase());
163
+ }
164
+ exports.validateEmail = validateEmail;