@crowdin/app-project-module 0.39.1 → 0.41.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 (46) hide show
  1. package/out/handlers/integration/crowdin-update.js +36 -17
  2. package/out/handlers/integration/integration-data.js +2 -0
  3. package/out/handlers/integration/integration-update.js +35 -17
  4. package/out/handlers/integration/integration-webhook.js +1 -1
  5. package/out/handlers/integration/job-cancel.d.ts +3 -0
  6. package/out/handlers/integration/job-cancel.js +28 -0
  7. package/out/handlers/integration/job-info.d.ts +3 -0
  8. package/out/handlers/integration/job-info.js +54 -0
  9. package/out/handlers/integration/main.js +6 -3
  10. package/out/handlers/integration/settings-save.js +8 -1
  11. package/out/handlers/integration/user-errors.d.ts +3 -0
  12. package/out/handlers/{user-errors.js → integration/user-errors.js} +2 -2
  13. package/out/handlers/uninstall.js +4 -2
  14. package/out/index.d.ts +2 -1
  15. package/out/index.js +35 -27
  16. package/out/middlewares/crowdin-client.js +1 -0
  17. package/out/middlewares/integration-credentials.js +3 -2
  18. package/out/middlewares/ui-module.js +1 -0
  19. package/out/models/index.d.ts +54 -18
  20. package/out/models/index.js +1 -0
  21. package/out/models/job.d.ts +44 -0
  22. package/out/models/job.js +16 -0
  23. package/out/static/js/form.js +13 -13
  24. package/out/static/js/main.js +1 -1
  25. package/out/storage/index.d.ts +11 -2
  26. package/out/storage/index.js +3 -0
  27. package/out/storage/mysql.d.ts +11 -2
  28. package/out/storage/mysql.js +155 -10
  29. package/out/storage/postgre.d.ts +11 -2
  30. package/out/storage/postgre.js +153 -9
  31. package/out/storage/sqlite.d.ts +14 -3
  32. package/out/storage/sqlite.js +160 -14
  33. package/out/util/cron.d.ts +1 -0
  34. package/out/util/cron.js +53 -6
  35. package/out/util/defaults.js +4 -11
  36. package/out/util/file-snapshot.js +2 -0
  37. package/out/util/files.d.ts +2 -1
  38. package/out/util/files.js +19 -1
  39. package/out/util/index.js +3 -1
  40. package/out/util/job.d.ts +12 -0
  41. package/out/util/job.js +88 -0
  42. package/out/util/logger.js +4 -0
  43. package/out/util/webhooks.js +53 -6
  44. package/out/views/main.handlebars +153 -5
  45. package/package.json +16 -15
  46. package/out/handlers/user-errors.d.ts +0 -3
@@ -5,6 +5,7 @@ import { Request } from 'express';
5
5
  import { MySQLStorageConfig } from '../storage/mysql';
6
6
  import { PostgreStorageConfig } from '../storage/postgre';
7
7
  import { LogErrorFunction, LogFunction } from '../util/logger';
8
+ import { JobClient } from './job';
8
9
  export interface ClientConfig extends ImagePath {
9
10
  /**
10
11
  * Authentication Crowdin App type: "authorization_code", "crowdin_app". Default: "crowdin_app"
@@ -153,10 +154,6 @@ export interface ClientConfig extends ImagePath {
153
154
  filePostImport?: FilePostImportLogic;
154
155
  filePreExport?: FilePreExportLogic;
155
156
  filePostExport?: FilePostExportLogic;
156
- /**
157
- * sentry dsn identifier of sentry project
158
- */
159
- sentryDsn?: string;
160
157
  /**
161
158
  * Disable formatting logs
162
159
  */
@@ -201,7 +198,8 @@ export declare enum Scope {
201
198
  SOURCE_FILES_AND_STRINGS = "project.source",
202
199
  WEBHOOKS = "project.webhook",
203
200
  TRANSLATIONS = "project.translation",
204
- SCREENSHOTS = "project.screenshot"
201
+ SCREENSHOTS = "project.screenshot",
202
+ SECURITY_LOGS = "security-log"
205
203
  }
206
204
  export interface IntegrationLogic {
207
205
  /**
@@ -235,11 +233,28 @@ export interface IntegrationLogic {
235
233
  /**
236
234
  * function to update crowdin files (e.g. pull integration data to crowdin source files)
237
235
  */
238
- updateCrowdin: (projectId: number, client: Crowdin, apiCredentials: any, request: IntegrationFile[], appRootFolder?: SourceFilesModel.Directory, config?: any, uploadTranslations?: boolean) => Promise<void | ExtendedResult<void>>;
236
+ updateCrowdin: ({ projectId, client, credentials, request, rootFolder, appSettings, uploadTranslations, job, }: {
237
+ projectId: number;
238
+ client: Crowdin;
239
+ credentials: any;
240
+ request: IntegrationFile[];
241
+ rootFolder?: SourceFilesModel.Directory;
242
+ appSettings?: any;
243
+ uploadTranslations?: boolean;
244
+ job: JobClient;
245
+ }) => Promise<void | ExtendedResult<void>>;
239
246
  /**
240
247
  * function to update integration content (e.g. load crowdin translations and push them to integration service)
241
248
  */
242
- updateIntegration: (projectId: number, client: Crowdin, apiCredentials: any, request: UpdateIntegrationRequest, appRootFolder?: SourceFilesModel.Directory, config?: any) => Promise<void | ExtendedResult<void>>;
249
+ updateIntegration: ({ projectId, client, credentials, request, rootFolder, appSettings, job, }: {
250
+ projectId: number;
251
+ client: Crowdin;
252
+ credentials: any;
253
+ request: UpdateIntegrationRequest;
254
+ rootFolder?: SourceFilesModel.Directory;
255
+ appSettings?: any;
256
+ job: JobClient;
257
+ }) => Promise<void | ExtendedResult<void>>;
243
258
  /**
244
259
  * function to define configuration(settings) modal for you app (by default app will not have any custom settings)
245
260
  */
@@ -317,6 +332,19 @@ export interface IntegrationLogic {
317
332
  icon: boolean;
318
333
  close: boolean;
319
334
  };
335
+ skipIntegrationNodes?: SkipIntegrationNodes;
336
+ /**
337
+ * Async progress checking time interval to update job progress, im ms.
338
+ *
339
+ * Default 1000
340
+ */
341
+ asyncProgress?: {
342
+ checkInterval?: number;
343
+ };
344
+ }
345
+ export interface SkipIntegrationNodes {
346
+ fileNamePattern?: string;
347
+ folderNamePattern?: string;
320
348
  }
321
349
  export type FormEntity = FormField | FormDelimiter;
322
350
  export interface FormDelimiter {
@@ -533,6 +561,7 @@ export interface CrowdinContextInfo {
533
561
  jwtPayload: JwtPayload;
534
562
  crowdinId: string;
535
563
  clientId: string;
564
+ appIdentifier: string;
536
565
  }
537
566
  export declare enum SubscriptionInfoType {
538
567
  TRIAL = "trial",
@@ -548,7 +577,12 @@ export interface IntegrationCredentials {
548
577
  id: string;
549
578
  credentials: any;
550
579
  crowdinId: string;
551
- config?: any;
580
+ }
581
+ export interface IntegrationConfig {
582
+ id: number;
583
+ integrationId: string;
584
+ crowdinId: string;
585
+ config: any;
552
586
  }
553
587
  export interface IntegrationFile {
554
588
  id: string;
@@ -814,14 +848,7 @@ export declare enum ContextOptionsTypes {
814
848
  NEW_TAB = "new_tab",
815
849
  REDIRECT = "redirect"
816
850
  }
817
- export interface CrowdinAppUtilities {
818
- saveMetadata: (id: string, metadata: any, crowdinId?: string) => Promise<void>;
819
- getMetadata: (id: string) => Promise<any | undefined>;
820
- deleteMetadata: (id: string) => Promise<void>;
821
- /**
822
- * Settings that users manage in the integration module
823
- */
824
- getUserSettings: (clientId: string) => Promise<any | undefined>;
851
+ export interface CrowdinAppUtilities extends CrowdinMetadataStore {
825
852
  establishCrowdinConnection: (authRequest: string | CrowdinClientRequest) => Promise<{
826
853
  context: CrowdinContextInfo;
827
854
  client?: Crowdin;
@@ -835,6 +862,15 @@ export interface CrowdinAppUtilities {
835
862
  extra: Record<string, any>;
836
863
  }>;
837
864
  }
865
+ export interface CrowdinMetadataStore {
866
+ saveMetadata: (id: string, metadata: any, crowdinId?: string) => Promise<void>;
867
+ getMetadata: (id: string) => Promise<any | undefined>;
868
+ deleteMetadata: (id: string) => Promise<void>;
869
+ /**
870
+ * Settings that users manage in the integration module
871
+ */
872
+ getUserSettings: (clientId: string) => Promise<any | undefined>;
873
+ }
838
874
  export declare enum Provider {
839
875
  CROWDIN = "crowdin",
840
876
  INTEGRATION = "integration"
@@ -914,7 +950,7 @@ export interface Webhooks {
914
950
  crowdinWebhooks?: (client: Crowdin, projectId: number, available: boolean, config?: AppSettings) => Promise<void>;
915
951
  integrationWebhooks?: (apiCredentials: any, urlParam: string, available: boolean, config?: AppSettings, syncSettings?: any) => Promise<void>;
916
952
  crowdinWebhookInterceptor?: (projectId: number, client: Crowdin, appRootFolder?: SourceFilesModel.Directory, config?: any, syncSettings?: any, webhookRequest?: any) => Promise<UpdateIntegrationRequest>;
917
- integrationWebhookInterceptor?: (projectId: number, client: Crowdin, apiCredentials: any, appRootFolder?: SourceFilesModel.Directory, config?: AppSettings, syncSettings?: any, webhookRequest?: any) => Promise<IntegrationFile[]>;
953
+ integrationWebhookInterceptor?: (projectId: number, client: Crowdin, apiCredentials: any, appRootFolder?: SourceFilesModel.Directory, config?: AppSettings, syncSettings?: any, webhookRequests?: any) => Promise<IntegrationFile[]>;
918
954
  queueUrl: string;
919
955
  }
920
956
  export declare enum SyncCondition {
@@ -951,7 +987,7 @@ export interface GetAllNewFilesArgs {
951
987
  export interface UpdateCrowdinWebhookPayloadsArgs {
952
988
  integration: IntegrationLogic;
953
989
  webhookData: any;
954
- req: Request;
990
+ req: Request[];
955
991
  }
956
992
  export interface FilterSyncFilesArgs {
957
993
  projectId: number;
@@ -24,6 +24,7 @@ var Scope;
24
24
  Scope["WEBHOOKS"] = "project.webhook";
25
25
  Scope["TRANSLATIONS"] = "project.translation";
26
26
  Scope["SCREENSHOTS"] = "project.screenshot";
27
+ Scope["SECURITY_LOGS"] = "security-log";
27
28
  })(Scope = exports.Scope || (exports.Scope = {}));
28
29
  var AccountType;
29
30
  (function (AccountType) {
@@ -0,0 +1,44 @@
1
+ export declare enum JobType {
2
+ UPDATE_TO_CROWDIN = "updateCrowdin",
3
+ UPDATE_TO_INTEGRATION = "updateIntegration"
4
+ }
5
+ export declare enum JobStatus {
6
+ CREATED = "created",
7
+ IN_PROGRESS = "inProgress",
8
+ FINISHED = "finished",
9
+ FAILED = "failed",
10
+ CANCELED = "canceled"
11
+ }
12
+ export interface Job {
13
+ id: string;
14
+ integrationId: string;
15
+ crowdinId: string;
16
+ type: JobType;
17
+ title: string;
18
+ progress: number;
19
+ status: JobStatus;
20
+ payload?: any;
21
+ data?: any;
22
+ createdAt: number;
23
+ updatedAt?: number;
24
+ finishedAt?: number;
25
+ eta?: number;
26
+ info?: string;
27
+ }
28
+ export type GetJobParams = Pick<Job, 'id'>;
29
+ export type GetActiveJobsParams = Pick<Job, 'integrationId' | 'crowdinId'>;
30
+ export type CreateJobParams = Pick<Job, 'integrationId' | 'crowdinId' | 'type' | 'payload' | 'title'>;
31
+ export type UpdateJobParams = {
32
+ id: string;
33
+ progress?: number;
34
+ status?: JobStatus;
35
+ info?: string;
36
+ data?: string;
37
+ };
38
+ export type JobClient = {
39
+ get: () => Promise<Job | undefined>;
40
+ update: UpdateJobProgress;
41
+ };
42
+ export type UpdateJobProgress = ({ progress, status, info, data, }: Omit<UpdateJobParams, 'id'>) => Promise<{
43
+ isCanceled: boolean;
44
+ }>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JobStatus = exports.JobType = void 0;
4
+ var JobType;
5
+ (function (JobType) {
6
+ JobType["UPDATE_TO_CROWDIN"] = "updateCrowdin";
7
+ JobType["UPDATE_TO_INTEGRATION"] = "updateIntegration";
8
+ })(JobType = exports.JobType || (exports.JobType = {}));
9
+ var JobStatus;
10
+ (function (JobStatus) {
11
+ JobStatus["CREATED"] = "created";
12
+ JobStatus["IN_PROGRESS"] = "inProgress";
13
+ JobStatus["FINISHED"] = "finished";
14
+ JobStatus["FAILED"] = "failed";
15
+ JobStatus["CANCELED"] = "canceled";
16
+ })(JobStatus = exports.JobStatus || (exports.JobStatus = {}));