@crowdin/app-project-module 0.43.0 → 0.44.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.
Files changed (152) hide show
  1. package/out/index.d.ts +1 -1
  2. package/out/index.js +57 -166
  3. package/out/middlewares/integration-credentials.d.ts +2 -1
  4. package/out/middlewares/ui-module.d.ts +2 -2
  5. package/out/middlewares/ui-module.js +4 -0
  6. package/out/models/index.d.ts +52 -698
  7. package/out/models/index.js +2 -26
  8. package/out/modules/context-menu/index.d.ts +6 -0
  9. package/out/modules/context-menu/index.js +17 -0
  10. package/out/{handlers/custom-mt → modules/custom-mt/handlers}/translate.d.ts +2 -1
  11. package/out/{handlers/custom-mt → modules/custom-mt/handlers}/translate.js +2 -2
  12. package/out/modules/custom-mt/index.d.ts +6 -0
  13. package/out/modules/custom-mt/index.js +17 -0
  14. package/out/modules/custom-mt/types.d.ts +22 -0
  15. package/out/modules/custom-mt/types.js +2 -0
  16. package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/get-languages-list.d.ts +2 -1
  17. package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/get-languages-list.js +2 -2
  18. package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/spell-check.d.ts +2 -1
  19. package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/spell-check.js +5 -3
  20. package/out/modules/custom-spell-check/index.d.ts +6 -0
  21. package/out/modules/custom-spell-check/index.js +32 -0
  22. package/out/modules/custom-spell-check/types.d.ts +56 -0
  23. package/out/modules/custom-spell-check/types.js +2 -0
  24. package/out/modules/editor-right-panel/index.d.ts +6 -0
  25. package/out/modules/editor-right-panel/index.js +17 -0
  26. package/out/modules/editor-right-panel/types.d.ts +7 -0
  27. package/out/modules/editor-right-panel/types.js +2 -0
  28. package/out/modules/editor-themes/index.d.ts +6 -0
  29. package/out/modules/editor-themes/index.js +11 -0
  30. package/out/{handlers/file-processing → modules/file-processing/handlers}/custom-file-format.d.ts +2 -1
  31. package/out/{handlers/file-processing → modules/file-processing/handlers}/custom-file-format.js +5 -5
  32. package/out/modules/file-processing/handlers/file-download.d.ts +5 -0
  33. package/out/{handlers/file-processing → modules/file-processing/handlers}/file-download.js +2 -2
  34. package/out/{handlers/file-processing → modules/file-processing/handlers}/pre-post-process.d.ts +2 -1
  35. package/out/{handlers/file-processing → modules/file-processing/handlers}/pre-post-process.js +8 -8
  36. package/out/modules/file-processing/index.d.ts +22 -0
  37. package/out/modules/file-processing/index.js +57 -0
  38. package/out/modules/file-processing/types.d.ts +133 -0
  39. package/out/modules/file-processing/types.js +12 -0
  40. package/out/{handlers/integration/crowdin-project.d.ts → modules/form-data-display.d.ts} +1 -1
  41. package/out/modules/form-data-save.d.ts +4 -0
  42. package/out/{handlers/integration → modules/integration/handlers}/crowdin-file-progress.d.ts +2 -1
  43. package/out/{handlers/integration → modules/integration/handlers}/crowdin-file-progress.js +2 -2
  44. package/out/modules/integration/handlers/crowdin-files.d.ts +5 -0
  45. package/out/{handlers/integration → modules/integration/handlers}/crowdin-files.js +3 -3
  46. package/out/modules/integration/handlers/crowdin-project.d.ts +4 -0
  47. package/out/{handlers/integration → modules/integration/handlers}/crowdin-project.js +1 -1
  48. package/out/modules/integration/handlers/crowdin-update.d.ts +5 -0
  49. package/out/{handlers/integration → modules/integration/handlers}/crowdin-update.js +6 -6
  50. package/out/modules/integration/handlers/crowdin-webhook.d.ts +5 -0
  51. package/out/{handlers/integration → modules/integration/handlers}/crowdin-webhook.js +7 -7
  52. package/out/modules/integration/handlers/integration-data.d.ts +4 -0
  53. package/out/{handlers/integration → modules/integration/handlers}/integration-data.js +4 -4
  54. package/out/{handlers/integration → modules/integration/handlers}/integration-login.d.ts +2 -1
  55. package/out/{handlers/integration → modules/integration/handlers}/integration-login.js +3 -3
  56. package/out/modules/integration/handlers/integration-logout.d.ts +5 -0
  57. package/out/{handlers/integration → modules/integration/handlers}/integration-logout.js +5 -5
  58. package/out/modules/integration/handlers/integration-update.d.ts +5 -0
  59. package/out/{handlers/integration → modules/integration/handlers}/integration-update.js +5 -5
  60. package/out/modules/integration/handlers/integration-webhook.d.ts +5 -0
  61. package/out/{handlers/integration → modules/integration/handlers}/integration-webhook.js +4 -4
  62. package/out/modules/integration/handlers/job-cancel.d.ts +3 -0
  63. package/out/{handlers/integration → modules/integration/handlers}/job-cancel.js +3 -3
  64. package/out/modules/integration/handlers/job-info.d.ts +3 -0
  65. package/out/{handlers/integration → modules/integration/handlers}/job-info.js +3 -3
  66. package/out/modules/integration/handlers/main.d.ts +5 -0
  67. package/out/{handlers/integration → modules/integration/handlers}/main.js +4 -4
  68. package/out/modules/integration/handlers/oauth-login.d.ts +5 -0
  69. package/out/{handlers/integration → modules/integration/handlers}/oauth-login.js +3 -3
  70. package/out/{handlers/integration → modules/integration/handlers}/oauth-url.d.ts +2 -1
  71. package/out/{handlers/integration → modules/integration/handlers}/oauth-url.js +2 -2
  72. package/out/modules/integration/handlers/settings-save.d.ts +5 -0
  73. package/out/{handlers/integration → modules/integration/handlers}/settings-save.js +10 -10
  74. package/out/modules/integration/handlers/settings.d.ts +3 -0
  75. package/out/{handlers/integration → modules/integration/handlers}/settings.js +1 -1
  76. package/out/{handlers/integration → modules/integration/handlers}/subscription-info.d.ts +1 -1
  77. package/out/{handlers/integration → modules/integration/handlers}/subscription-info.js +1 -1
  78. package/out/modules/integration/handlers/sync-settings-save.d.ts +5 -0
  79. package/out/{handlers/integration → modules/integration/handlers}/sync-settings-save.js +5 -5
  80. package/out/modules/integration/handlers/sync-settings.d.ts +3 -0
  81. package/out/{handlers/integration → modules/integration/handlers}/sync-settings.js +2 -2
  82. package/out/modules/integration/handlers/user-errors.d.ts +3 -0
  83. package/out/{handlers/integration → modules/integration/handlers}/user-errors.js +2 -2
  84. package/out/modules/integration/index.d.ts +6 -0
  85. package/out/modules/integration/index.js +113 -0
  86. package/out/modules/integration/types.d.ts +446 -0
  87. package/out/modules/integration/types.js +19 -0
  88. package/out/modules/manifest.d.ts +3 -0
  89. package/out/{handlers → modules}/manifest.js +16 -10
  90. package/out/modules/modal/index.d.ts +6 -0
  91. package/out/modules/modal/index.js +17 -0
  92. package/out/modules/organization-menu/index.d.ts +6 -0
  93. package/out/modules/organization-menu/index.js +19 -0
  94. package/out/modules/profile-resources-menu/index.d.ts +6 -0
  95. package/out/modules/profile-resources-menu/index.js +19 -0
  96. package/out/modules/project-menu/index.d.ts +6 -0
  97. package/out/modules/project-menu/index.js +17 -0
  98. package/out/modules/project-menu-crowdsource/index.d.ts +6 -0
  99. package/out/modules/project-menu-crowdsource/index.js +17 -0
  100. package/out/modules/project-reports/index.d.ts +6 -0
  101. package/out/modules/project-reports/index.js +19 -0
  102. package/out/modules/project-tools/index.d.ts +6 -0
  103. package/out/modules/project-tools/index.js +19 -0
  104. package/out/storage/index.d.ts +3 -2
  105. package/out/storage/mysql.d.ts +2 -1
  106. package/out/storage/mysql.js +1 -1
  107. package/out/storage/postgre.d.ts +2 -1
  108. package/out/storage/postgre.js +9 -7
  109. package/out/storage/sqlite.d.ts +2 -1
  110. package/out/util/api/api.d.ts +2 -2
  111. package/out/util/api/api.js +10 -10
  112. package/out/util/connection.d.ts +3 -2
  113. package/out/util/cron.d.ts +2 -1
  114. package/out/util/cron.js +6 -6
  115. package/out/util/defaults.d.ts +5 -2
  116. package/out/util/defaults.js +13 -3
  117. package/out/util/file-snapshot.d.ts +2 -1
  118. package/out/util/file-snapshot.js +5 -5
  119. package/out/util/files.d.ts +2 -1
  120. package/out/util/index.d.ts +2 -1
  121. package/out/util/logger.d.ts +2 -2
  122. package/out/util/webhooks.d.ts +2 -1
  123. package/out/util/webhooks.js +5 -5
  124. package/package.json +1 -1
  125. package/out/handlers/file-processing/file-download.d.ts +0 -4
  126. package/out/handlers/form-data-display.d.ts +0 -3
  127. package/out/handlers/form-data-save.d.ts +0 -3
  128. package/out/handlers/integration/crowdin-files.d.ts +0 -4
  129. package/out/handlers/integration/crowdin-update.d.ts +0 -4
  130. package/out/handlers/integration/crowdin-webhook.d.ts +0 -4
  131. package/out/handlers/integration/integration-data.d.ts +0 -4
  132. package/out/handlers/integration/integration-logout.d.ts +0 -4
  133. package/out/handlers/integration/integration-update.d.ts +0 -4
  134. package/out/handlers/integration/integration-webhook.d.ts +0 -4
  135. package/out/handlers/integration/job-cancel.d.ts +0 -3
  136. package/out/handlers/integration/job-info.d.ts +0 -3
  137. package/out/handlers/integration/main.d.ts +0 -4
  138. package/out/handlers/integration/oauth-login.d.ts +0 -4
  139. package/out/handlers/integration/settings-save.d.ts +0 -4
  140. package/out/handlers/integration/settings.d.ts +0 -3
  141. package/out/handlers/integration/sync-settings-save.d.ts +0 -4
  142. package/out/handlers/integration/sync-settings.d.ts +0 -3
  143. package/out/handlers/integration/user-errors.d.ts +0 -3
  144. package/out/handlers/manifest.d.ts +0 -3
  145. /package/out/{handlers → modules}/form-data-display.js +0 -0
  146. /package/out/{handlers → modules}/form-data-save.js +0 -0
  147. /package/out/{handlers → modules}/install.d.ts +0 -0
  148. /package/out/{handlers → modules}/install.js +0 -0
  149. /package/out/{handlers → modules}/subscription-paid.d.ts +0 -0
  150. /package/out/{handlers → modules}/subscription-paid.js +0 -0
  151. /package/out/{handlers → modules}/uninstall.d.ts +0 -0
  152. /package/out/{handlers → modules}/uninstall.js +0 -0
@@ -1,11 +1,14 @@
1
- /// <reference types="node" />
2
- import Crowdin, { LanguagesModel, SourceFilesModel, SourceStringsModel, TranslationStatusModel } from '@crowdin/crowdin-api-client';
1
+ import Crowdin from '@crowdin/crowdin-api-client';
3
2
  import { JwtPayload, VerifyOptions } from '@crowdin/crowdin-apps-functions';
4
3
  import { Request } from 'express';
4
+ import { CustomMTLogic } from '../modules/custom-mt/types';
5
+ import { CustomSpellcheckerModule } from '../modules/custom-spell-check/types';
6
+ import { EditorPanels } from '../modules/editor-right-panel/types';
7
+ import { CustomFileFormatLogic, FilePostExportLogic, FilePostImportLogic, FilePreExportLogic, FilePreImportLogic } from '../modules/file-processing/types';
8
+ import { IntegrationLogic } from '../modules/integration/types';
5
9
  import { MySQLStorageConfig } from '../storage/mysql';
6
10
  import { PostgreStorageConfig } from '../storage/postgre';
7
11
  import { LogErrorFunction, LogFunction } from '../util/logger';
8
- import { JobClient } from './job';
9
12
  export interface ClientConfig extends ImagePath {
10
13
  /**
11
14
  * Authentication Crowdin App type: "authorization_code", "crowdin_app". Default: "crowdin_app"
@@ -166,6 +169,10 @@ export interface ClientConfig extends ImagePath {
166
169
  awsConfig?: AWSConfig;
167
170
  customSpellchecker?: CustomSpellcheckerModule;
168
171
  }
172
+ export interface Environments {
173
+ environments: Environment | Environment[];
174
+ }
175
+ type Environment = 'crowdin' | 'crowdin-enterprise';
169
176
  export type Config = ClientConfig & {
170
177
  baseUrl: string;
171
178
  clientId: string;
@@ -174,9 +181,14 @@ export type Config = ClientConfig & {
174
181
  dbFolder: string;
175
182
  imagePath: string;
176
183
  };
184
+ export type UnauthorizedConfig = Omit<Config, 'clientId' | 'clientSecret'> & {
185
+ clientId?: string;
186
+ clientSecret?: string;
187
+ };
177
188
  export declare enum AuthenticationType {
178
189
  CODE = "authorization_code",
179
- APP = "crowdin_app"
190
+ APP = "crowdin_app",
191
+ NONE = "none"
180
192
  }
181
193
  export interface CrowdinUrls {
182
194
  apiUrl?: string;
@@ -203,339 +215,6 @@ export declare enum Scope {
203
215
  SECURITY_LOGS = "security-log",
204
216
  VENDORS = "vendor"
205
217
  }
206
- export interface IntegrationLogic {
207
- /**
208
- * Customize your app login form
209
- */
210
- loginForm: LoginForm;
211
- /**
212
- * Define login process via OAuth2 protocol
213
- */
214
- oauthLogin?: OAuthLogin;
215
- /**
216
- * name of the root folder in Crowdin where files from integration will be stored, default your app name, will be ignored in case if {@link withRootFolder} is false
217
- */
218
- appFolderName?: string;
219
- /**
220
- * flag that defines if the app should have a dedicated root folder in Crowdin files, default 'false'
221
- */
222
- withRootFolder?: boolean;
223
- /**
224
- * function which will be used to check connection with integration service
225
- */
226
- checkConnection?: (apiCredentials: any) => Promise<void>;
227
- /**
228
- * function to get crowdin files that are related with this integration
229
- */
230
- getCrowdinFiles?: (projectId: number, client: Crowdin, appRootFolder?: SourceFilesModel.Directory, config?: any) => Promise<TreeItem[]>;
231
- /**
232
- * function to get data from integration
233
- */
234
- getIntegrationFiles: (apiCredentials: any, config?: any, parentId?: any, search?: any, page?: any) => Promise<TreeItem[] | ExtendedResult<TreeItem[]>>;
235
- /**
236
- * function to update crowdin files (e.g. pull integration data to crowdin source files)
237
- */
238
- updateCrowdin: ({ projectId, client, credentials, request, rootFolder, appSettings, uploadTranslations, job, }: {
239
- projectId: number;
240
- client: Crowdin;
241
- credentials: any;
242
- request: IntegrationFile[];
243
- rootFolder?: SourceFilesModel.Directory;
244
- appSettings?: any;
245
- uploadTranslations?: boolean;
246
- job: JobClient;
247
- }) => Promise<void | ExtendedResult<void>>;
248
- /**
249
- * function to update integration content (e.g. load crowdin translations and push them to integration service)
250
- */
251
- updateIntegration: ({ projectId, client, credentials, request, rootFolder, appSettings, job, }: {
252
- projectId: number;
253
- client: Crowdin;
254
- credentials: any;
255
- request: UpdateIntegrationRequest;
256
- rootFolder?: SourceFilesModel.Directory;
257
- appSettings?: any;
258
- job: JobClient;
259
- }) => Promise<void | ExtendedResult<void>>;
260
- /**
261
- * function to define configuration(settings) modal for you app (by default app will not have any custom settings)
262
- */
263
- getConfiguration?: (projectId: number, client: Crowdin, apiCredentials: any) => Promise<FormEntity[]>;
264
- /**
265
- * Logout hook for cleanup logic
266
- */
267
- onLogout?: (projectId: number, client: Crowdin, apiCredentials: any, config?: any) => Promise<void>;
268
- /**
269
- * flag to turn on auto reload of the tree whenever user updates the configuration
270
- */
271
- reloadOnConfigSave?: boolean;
272
- /**
273
- * define info modal (help section) for you app (by default app will not have own info section)
274
- */
275
- infoModal?: {
276
- title: string;
277
- content: string;
278
- };
279
- /**
280
- * background jobs that will be executed for each crowdin project and user
281
- */
282
- cronJobs?: CronJob[];
283
- /**
284
- * Enable new file sync when syncing via cron or webhook
285
- */
286
- syncNewElements?: {
287
- crowdin: boolean;
288
- integration: boolean;
289
- };
290
- withCronSync?: {
291
- crowdin: boolean;
292
- integration: boolean;
293
- };
294
- withWebhookSync?: {
295
- crowdin: boolean;
296
- integration: boolean;
297
- };
298
- filtering?: {
299
- crowdinLanguages: boolean;
300
- };
301
- /**
302
- * Enable integration folder open event
303
- */
304
- integrationOneLevelFetching?: boolean;
305
- /**
306
- * Enable integration search event
307
- */
308
- integrationSearchListener?: boolean;
309
- /**
310
- * Enable integration next page event
311
- */
312
- integrationPagination?: boolean;
313
- /**
314
- * Enable the option to upload translations to crowdin that are already present in the integration.
315
- */
316
- uploadTranslations?: boolean;
317
- /**
318
- * function to get crowdin file translation progress
319
- */
320
- getFileProgress?: (projectId: number, client: Crowdin, fileId: number) => Promise<{
321
- [key: number]: TranslationStatusModel.LanguageProgress[];
322
- }>;
323
- /**
324
- * Register Crowdin webhook to get notified when translations are ready
325
- */
326
- webhooks?: Webhooks;
327
- /**
328
- * define a notification for your application at the top of the screen
329
- */
330
- notice?: {
331
- title: string;
332
- content: string;
333
- type: NoticeType;
334
- icon: boolean;
335
- close: boolean;
336
- };
337
- skipIntegrationNodes?: SkipIntegrationNodes;
338
- /**
339
- * Async progress checking time interval to update job progress, im ms.
340
- *
341
- * Default 1000
342
- */
343
- asyncProgress?: {
344
- checkInterval?: number;
345
- };
346
- }
347
- export interface SkipIntegrationNodes {
348
- fileNamePattern?: string;
349
- folderNamePattern?: string;
350
- }
351
- export type FormEntity = FormField | FormDelimiter;
352
- export interface FormDelimiter {
353
- label?: string;
354
- labelHtml?: string;
355
- }
356
- export interface LoginForm {
357
- fields: FormEntity[];
358
- }
359
- export interface OAuthLogin {
360
- /**
361
- * Extra field for login form
362
- */
363
- loginFields?: FormField[];
364
- /**
365
- * Authorization url (e.g. https://github.com/login/oauth/authorize or https://accounts.google.com/o/oauth2/v2/auth)
366
- */
367
- authorizationUrl?: string;
368
- /**
369
- * Authorization url getter
370
- */
371
- getAuthorizationUrl?: (redirectUrl: string, loginForm?: any) => string;
372
- /**
373
- * Access token url (e.g. https://github.com/login/oauth/access_token)
374
- */
375
- accessTokenUrl: string;
376
- /**
377
- * Url to refresh token, default will use {@link accessTokenUrl}. Needed when {@link refresh} is enabled
378
- */
379
- refreshTokenUrl?: string;
380
- /**
381
- * The scopes of access, usually expressed as a list of space-delimited, case-sensitive strings
382
- */
383
- scope?: string;
384
- /**
385
- * Client id
386
- */
387
- clientId: string;
388
- /**
389
- * Client secret
390
- */
391
- clientSecret: string;
392
- /**
393
- * default '/oauth/code'
394
- */
395
- redirectUriRoute?: string;
396
- /**
397
- * request/response fields mapping
398
- */
399
- fieldsMapping?: {
400
- /**
401
- * default 'client_id'
402
- */
403
- clientId?: string;
404
- /**
405
- * default 'client_secret'
406
- */
407
- clientSecret?: string;
408
- /**
409
- * default 'scope'
410
- */
411
- scope?: string;
412
- /**
413
- * default 'redirect_uri'
414
- */
415
- redirectUri?: string;
416
- /**
417
- * default 'code'
418
- */
419
- code: string;
420
- /**
421
- * default 'access_token'
422
- */
423
- accessToken?: string;
424
- /**
425
- * default 'refresh_token'
426
- */
427
- refreshToken?: string;
428
- /**
429
- * default 'expires_in'
430
- */
431
- expiresIn?: string;
432
- };
433
- /**
434
- * default 'false' which means that the access token has no expiration date
435
- */
436
- refresh?: boolean;
437
- /**
438
- * Additional URL parameters for authorizarion url
439
- */
440
- extraAutorizationUrlParameters?: {
441
- [key: string]: string;
442
- };
443
- /**
444
- * Additional parameters for access token request
445
- */
446
- extraAccessTokenParameters?: {
447
- [key: string]: any;
448
- };
449
- /**
450
- * Additional parameters for refresh token request
451
- */
452
- extraRefreshTokenParameters?: {
453
- [key: string]: any;
454
- };
455
- /**
456
- * Override to implement request for retrieving access token (and refresh token if 'refresh' is enabled)
457
- */
458
- performGetTokenRequest?: (code: string, query: {
459
- [key: string]: any;
460
- }, url: string) => Promise<any>;
461
- /**
462
- * Override to implement request for refreshing token (only if 'refresh' is enabled)
463
- */
464
- performRefreshTokenRequest?: (currentCredentials: any) => Promise<any>;
465
- }
466
- export interface Environments {
467
- environments: 'crowdin' | 'crowdin-enterprise';
468
- }
469
- export interface FormField {
470
- key: string;
471
- helpText?: string;
472
- helpTextHtml?: string;
473
- label: string;
474
- type?: 'text' | 'password' | 'checkbox' | 'select' | 'textarea' | 'file';
475
- defaultValue?: any;
476
- /**
477
- * only for select
478
- */
479
- isMulti?: boolean;
480
- /**
481
- * only for select
482
- */
483
- isSearchable?: boolean;
484
- /**
485
- * only for select
486
- */
487
- options?: {
488
- label: string;
489
- value: string;
490
- }[];
491
- /**
492
- * only for type file
493
- */
494
- accept?: string;
495
- /**
496
- * field dependency settings
497
- */
498
- dependencySettings?: string;
499
- }
500
- export interface ExtendedResult<T> {
501
- data?: T;
502
- message?: string;
503
- stopPagination?: boolean;
504
- }
505
- export type TreeItem = File | Folder;
506
- /**
507
- * 0 - folder
508
- * 1 - file
509
- * 2 - branch
510
- */
511
- type IntegrationTreeElementType = '0' | '1' | '2';
512
- type LabelTreeElementType = 'primary' | 'secondary' | 'success' | 'warning' | 'info' | 'danger' | 'dark' | 'light';
513
- export interface LabelTreeElement {
514
- text: string;
515
- type?: LabelTreeElementType;
516
- color?: string;
517
- }
518
- export interface File {
519
- id: string;
520
- name: string;
521
- type: SourceFilesModel.FileType;
522
- parentId?: string;
523
- nodeType?: IntegrationTreeElementType;
524
- customContent?: string;
525
- labels?: LabelTreeElement;
526
- }
527
- export interface Folder {
528
- id: string;
529
- name: string;
530
- parentId?: string;
531
- nodeType?: IntegrationTreeElementType;
532
- customContent?: string;
533
- labels?: LabelTreeElement;
534
- }
535
- export interface IntegrationRequest extends CrowdinClientRequest {
536
- integrationCredentials: any;
537
- integrationSettings?: any;
538
- }
539
218
  export interface CrowdinClientRequest extends Request {
540
219
  crowdinApiClient: Crowdin;
541
220
  crowdinContext: CrowdinContextInfo;
@@ -575,228 +254,6 @@ export interface SubscriptionInfo {
575
254
  daysLeft?: number;
576
255
  type?: SubscriptionInfoType;
577
256
  }
578
- export interface IntegrationCredentials {
579
- id: string;
580
- credentials: any;
581
- crowdinId: string;
582
- }
583
- export interface IntegrationConfig {
584
- id: number;
585
- integrationId: string;
586
- crowdinId: string;
587
- config: any;
588
- }
589
- export interface IntegrationFile {
590
- id: string;
591
- name: string;
592
- type: SourceFilesModel.FileType;
593
- parentId: string;
594
- nodeType?: IntegrationTreeElementType;
595
- }
596
- export interface UpdateIntegrationRequest {
597
- [fileId: string]: string[];
598
- }
599
- export interface CronJob {
600
- task: (projectId: number, client: Crowdin, apiCredentials: any, appRootFolder?: SourceFilesModel.Directory, config?: any) => Promise<void>;
601
- expression: string;
602
- }
603
- export interface FileProcessLogic {
604
- /**
605
- * Folder where larger file will be temporary stored (default "{@link dbFolder}/custom-file-format")
606
- */
607
- filesFolder?: string;
608
- /**
609
- * Contains fileName and/or fileContent regular expressions used to detect file type when uploading a new source file via UI (or via API without specified type parameter). If the file matches regular expressions, it's labeled as a custom format file.
610
- */
611
- signaturePatterns?: SignaturePatterns;
612
- /**
613
- * Override to store huge responses (by default they will be stored in fs)
614
- */
615
- storeFile?: (content: Buffer) => Promise<string>;
616
- }
617
- export interface CustomFileFormatLogic extends FileProcessLogic {
618
- /**
619
- * The type parameter value for a custom file format. Used for a custom format file upload via API.
620
- */
621
- type: string;
622
- /**
623
- * This parameter is used to combine the content of multiple languages into one request when uploading and downloading translations in your Crowdin project.
624
- */
625
- multilingual?: boolean;
626
- /**
627
- * Flag to automatically upload translations
628
- */
629
- autoUploadTranslations?: boolean;
630
- /**
631
- * Enable strings export
632
- */
633
- stringsExport?: boolean;
634
- /**
635
- * File extensions (used for strings export)
636
- */
637
- extensions?: string[];
638
- /**
639
- * Enable custom srx
640
- */
641
- customSrxSupported?: boolean;
642
- /**
643
- * Enable multi language strings export
644
- */
645
- multilingualExport?: boolean;
646
- /**
647
- * Used for initial source file upload, source file update, and translation upload
648
- */
649
- parseFile?: (fileContent: Buffer, req: Omit<ProcessFileRequest, 'jobType' | 'file'>, client: Crowdin, context: CrowdinContextInfo, projectId: number) => Promise<ParseFileResponse>;
650
- /**
651
- * Used for translation download
652
- */
653
- buildFile?: (fileContent: Buffer, req: Omit<ProcessFileRequest, 'jobType' | 'file'>, strings: ProcessFileString[], client: Crowdin, context: CrowdinContextInfo, projectId: number) => Promise<BuildFileResponse>;
654
- /**
655
- * Used for strings export
656
- */
657
- exportStrings?: (req: Omit<ProcessFileRequest, 'jobType'>, strings: ProcessFileString[], client: Crowdin, context: CrowdinContextInfo, projectId: number) => Promise<BuildFileResponse>;
658
- }
659
- export type FileImportExportLogic = FilePreImportLogic | FilePostImportLogic | FilePreExportLogic | FilePostExportLogic;
660
- export type FileImportExportContent = ProcessFileString[] | Buffer | undefined;
661
- export interface FilePreImportLogic extends FileProcessLogic {
662
- fileProcess: (req: ProcessFileRequest, content: FileImportExportContent, client: Crowdin, context: CrowdinContextInfo, projectId: number) => Promise<ContentFileResponse>;
663
- }
664
- export interface FilePostImportLogic extends FileProcessLogic {
665
- fileProcess: (req: ProcessFileRequest, content: FileImportExportContent, client: Crowdin, context: CrowdinContextInfo, projectId: number) => Promise<StringsFileResponse>;
666
- }
667
- export interface FilePreExportLogic extends FileProcessLogic {
668
- fileProcess: (req: ProcessFileRequest, content: FileImportExportContent, client: Crowdin, context: CrowdinContextInfo, projectId: number) => Promise<StringsFileResponse>;
669
- }
670
- export interface FilePostExportLogic extends FileProcessLogic {
671
- fileProcess: (req: ProcessFileRequest, content: FileImportExportContent, client: Crowdin, context: CrowdinContextInfo, projectId: number) => Promise<ContentFileResponse>;
672
- }
673
- export interface SignaturePatterns {
674
- fileName?: string;
675
- fileContent?: string;
676
- }
677
- export interface ProcessFileRequest {
678
- jobType: ProcessFileJobType;
679
- file: ProcessFileRecord;
680
- sourceLanguage: LanguagesModel.Language;
681
- targetLanguages: LanguagesModel.Language[];
682
- strings: ProcessFileString[];
683
- stringsUrl: string;
684
- getRawContent?: (encoding: BufferEncoding) => Promise<string | Buffer>;
685
- }
686
- export interface ProcessFileRecord {
687
- content?: string;
688
- contentUrl?: string;
689
- path?: string;
690
- id?: number;
691
- name?: string;
692
- }
693
- export declare enum ProcessFileJobType {
694
- PARSE_FILE = "parse-file",
695
- BUILD_FILE = "build-file",
696
- PRE_IMPORT = "pre-import-file",
697
- POST_IMPORT = "post-import-file",
698
- PRE_EXPORT = "pre-export-file",
699
- POST_EXPORT = "post-export-file"
700
- }
701
- export interface ParseFileResponse {
702
- previewFile?: Buffer;
703
- strings?: ProcessFileString[];
704
- error?: string;
705
- }
706
- export interface BuildFileResponse {
707
- contentFile: Buffer;
708
- error?: string;
709
- fileName?: string;
710
- fileType?: string;
711
- }
712
- export interface StringsFileResponse extends Omit<ParseFileResponse, 'previewFile'> {
713
- notModified?: boolean;
714
- }
715
- export interface ContentFileResponse extends BuildFileResponse {
716
- notModified?: boolean;
717
- }
718
- export interface ProcessFileString {
719
- previewId?: number;
720
- id: number;
721
- identifier: string;
722
- context?: string;
723
- customData?: string;
724
- maxLength?: number;
725
- isHidden?: boolean;
726
- hasPlurals?: boolean;
727
- labels?: string[];
728
- text: string | SourceStringsModel.PluralText;
729
- translations?: StringTranslations;
730
- uniqId?: string;
731
- }
732
- export interface StringTranslations {
733
- [language: string]: {
734
- text: string | SourceStringsModel.PluralText;
735
- };
736
- }
737
- export interface CustomMTLogic {
738
- withContext?: boolean;
739
- translate: (client: Crowdin, context: CrowdinContextInfo, projectId: number, source: string, target: string, strings: CustomMtString[]) => Promise<string[]>;
740
- validate?: (client: Crowdin) => Promise<void>;
741
- }
742
- export interface CustomMTRequest {
743
- strings: CustomMtString[];
744
- }
745
- export type CustomMtString = string | {
746
- id: number;
747
- projectId: number;
748
- fileId: number;
749
- identifier: string;
750
- context: string;
751
- maxLength: number;
752
- isHidden: boolean;
753
- text: string | SourceStringsModel.PluralText;
754
- isPlural: boolean;
755
- pluralForm: any;
756
- };
757
- export interface UiModule {
758
- /**
759
- * Form schema for react-jsonschema-doc to be used as front-end
760
- * https://rjsf-team.github.io/react-jsonschema-form/docs
761
- */
762
- formSchema?: object;
763
- /**
764
- * URL to custom endpoint that can be used instead of default one to save form data.
765
- * Endpoint should accept POST requests.
766
- */
767
- formPostDataUrl?: string;
768
- /**
769
- * URL to custom endpoint that can be used instead of default one to retrieve form data.
770
- * Endpoint should accept GET requests.
771
- */
772
- formGetDataUrl?: string;
773
- /**
774
- * Additional attributes for react-jsonschema-doc
775
- */
776
- formUiSchema?: object;
777
- /**
778
- * path to ui folder (e.g. {@example join(__dirname, 'public')})
779
- */
780
- uiPath?: string;
781
- /**
782
- * page name (default index.html)
783
- */
784
- fileName?: string;
785
- /**
786
- * make module publicly available without crowdin context
787
- */
788
- allowUnauthorized?: boolean;
789
- /**
790
- * Module name
791
- */
792
- name?: string;
793
- }
794
- export interface EditorPanels extends UiModule {
795
- /**
796
- * The Editor's mode list where the module will be available.
797
- */
798
- modes: EditorMode[];
799
- }
800
257
  export interface EditorThemes {
801
258
  /**
802
259
  * Module name
@@ -838,6 +295,10 @@ export interface ContextModule {
838
295
  */
839
296
  signaturePatterns?: SignaturePatterns;
840
297
  }
298
+ export interface SignaturePatterns {
299
+ fileName?: string;
300
+ fileContent?: string;
301
+ }
841
302
  export declare enum ContextOptionsLocations {
842
303
  TM = "tm",
843
304
  GLOSSARY = "glossary",
@@ -874,30 +335,38 @@ export interface CrowdinMetadataStore {
874
335
  */
875
336
  getUserSettings: (clientId: string) => Promise<any | undefined>;
876
337
  }
877
- export declare enum Provider {
878
- CROWDIN = "crowdin",
879
- INTEGRATION = "integration"
880
- }
881
- export interface IntegrationSyncSettings {
882
- id: number;
883
- files?: any;
884
- integrationId: string;
885
- crowdinId: string;
886
- provider: Provider;
887
- }
888
- export interface IntegrationFilesSnapshot {
889
- id: number;
890
- files?: any;
891
- integrationId: string;
892
- crowdinId: string;
893
- provider: Provider;
894
- }
895
- export interface IntegrationWebhooks {
896
- id: number;
897
- fileId: number;
898
- integrationId: string;
899
- crowdinId: string;
900
- provider: Provider;
338
+ export interface UiModule {
339
+ /**
340
+ * Form schema for react-jsonschema-doc to be used as front-end
341
+ * https://rjsf-team.github.io/react-jsonschema-form/docs
342
+ */
343
+ formSchema?: object;
344
+ /**
345
+ * URL to custom endpoint that can be used instead of default one to save form data.
346
+ * Endpoint should accept POST requests.
347
+ */
348
+ formPostDataUrl?: string;
349
+ /**
350
+ * URL to custom endpoint that can be used instead of default one to retrieve form data.
351
+ * Endpoint should accept GET requests.
352
+ */
353
+ formGetDataUrl?: string;
354
+ /**
355
+ * Additional attributes for react-jsonschema-doc
356
+ */
357
+ formUiSchema?: object;
358
+ /**
359
+ * path to ui folder (e.g. {@example join(__dirname, 'public')})
360
+ */
361
+ uiPath?: string;
362
+ /**
363
+ * page name (default index.html)
364
+ */
365
+ fileName?: string;
366
+ /**
367
+ * Module name
368
+ */
369
+ name?: string;
901
370
  }
902
371
  export interface UserErrors {
903
372
  id: number;
@@ -934,60 +403,6 @@ export interface ApiModule {
934
403
  endpoints?: ApiEndpoints[];
935
404
  docFile?: string;
936
405
  }
937
- export interface CustomSpellCheckRequest {
938
- language: string;
939
- texts: string[];
940
- }
941
- export type SpellCheckCategory = 'typography' | 'casing' | 'grammar' | 'typos' | 'punctuation' | 'confused_words' | 'redundancy' | 'style' | 'gender_neutrality' | 'semantics' | 'colloquialisms' | 'wikipedia' | 'barbarism' | 'misc';
942
- export interface SupportedLanguage {
943
- code: string;
944
- name: string;
945
- }
946
- export interface SpellCheckMatch {
947
- category: SpellCheckCategory;
948
- message: string;
949
- shortMessage: string;
950
- offset: number;
951
- length: number;
952
- replacements: string[];
953
- }
954
- export interface CustomSpellCheckResponse {
955
- texts: {
956
- text: string;
957
- matches: SpellCheckMatch[];
958
- }[];
959
- error?: string;
960
- }
961
- export interface CustomSpellcheckerModule extends Environments {
962
- /**
963
- * module description
964
- */
965
- description?: string;
966
- /**
967
- * module name
968
- */
969
- name?: string;
970
- /**
971
- * Settings UI module
972
- */
973
- settingsUiModule?: UiModule;
974
- /**
975
- * function to get list of supported languages that are supports by current spellchecker
976
- */
977
- getSupportedLanguage: ({ client, context, }: {
978
- client: Crowdin;
979
- context: CrowdinContextInfo;
980
- }) => Promise<SupportedLanguage[]>;
981
- /**
982
- * function to check spelling
983
- */
984
- runSpellCheck: ({ client, context, language, texts, }: {
985
- client: Crowdin;
986
- context: CrowdinContextInfo;
987
- language: string;
988
- texts: string[];
989
- }) => Promise<CustomSpellCheckResponse>;
990
- }
991
406
  export interface Logger {
992
407
  enabled: boolean;
993
408
  log?: (message: string, context?: CrowdinContextInfo) => void;
@@ -1000,66 +415,6 @@ export interface Pricing {
1000
415
  cachingSeconds?: number;
1001
416
  infoDisplayDaysThreshold?: number;
1002
417
  }
1003
- export interface Webhooks {
1004
- crowdinWebhookUrl?: string;
1005
- integrationWebhookUrl?: string;
1006
- urlParam?: string;
1007
- crowdinWebhooks?: (client: Crowdin, projectId: number, available: boolean, config?: AppSettings) => Promise<void>;
1008
- integrationWebhooks?: (apiCredentials: any, urlParam: string, available: boolean, config?: AppSettings, syncSettings?: any) => Promise<void>;
1009
- crowdinWebhookInterceptor?: (projectId: number, client: Crowdin, appRootFolder?: SourceFilesModel.Directory, config?: any, syncSettings?: any, webhookRequest?: any) => Promise<UpdateIntegrationRequest>;
1010
- integrationWebhookInterceptor?: (projectId: number, client: Crowdin, apiCredentials: any, appRootFolder?: SourceFilesModel.Directory, config?: AppSettings, syncSettings?: any, webhookRequests?: any) => Promise<IntegrationFile[]>;
1011
- queueUrl: string;
1012
- }
1013
- export declare enum SyncCondition {
1014
- ALL = 0,
1015
- TRANSLATED = 1,
1016
- APPROVED = 2
1017
- }
1018
- export declare enum SyncSchedule {
1019
- DISABLED = 0,
1020
- ACTIVE
1021
- }
1022
- export type Payload = {
1023
- event: string;
1024
- projectId: string;
1025
- language: string;
1026
- fileId: string;
1027
- };
1028
- export type WebhookUrlParams = {
1029
- projectId: number;
1030
- crowdinId: string;
1031
- clientId: string;
1032
- };
1033
- export interface GetAllNewFilesArgs {
1034
- config: Config;
1035
- integration: IntegrationLogic;
1036
- crowdinApiClient: Crowdin;
1037
- crowdinId: string;
1038
- integrationCredentials: any;
1039
- integrationId: string;
1040
- projectId: number;
1041
- integrationSettings: any;
1042
- syncSettings: IntegrationSyncSettings;
1043
- }
1044
- export interface UpdateCrowdinWebhookPayloadsArgs {
1045
- integration: IntegrationLogic;
1046
- webhookData: any;
1047
- req: Request[];
1048
- }
1049
- export interface FilterSyncFilesArgs {
1050
- projectId: number;
1051
- crowdinClient: Crowdin;
1052
- events: Payload[];
1053
- syncFileSettings: UpdateIntegrationRequest;
1054
- appSettings: AppSettings;
1055
- }
1056
- export interface AppSettings {
1057
- schedule?: number;
1058
- condition?: number;
1059
- 'new-crowdin-files'?: boolean;
1060
- 'new-integration-files'?: boolean;
1061
- [key: string]: any;
1062
- }
1063
418
  export declare enum UserPermissions {
1064
419
  OWNER = "owner",
1065
420
  MANAGERS = "managers",
@@ -1074,7 +429,6 @@ export interface DefaultPermissions {
1074
429
  user?: UserPermissions;
1075
430
  project?: ProjectPermissions;
1076
431
  }
1077
- type NoticeType = 'info' | 'warning' | 'danger' | 'success' | 'error' | 'dataLostWarning';
1078
432
  export interface AWSConfig {
1079
433
  /**
1080
434
  * AWS bucket name for temporary files