@crowdin/app-project-module 0.28.0 → 0.28.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.
- package/CONTRIBUTING.md +19 -1
- package/README.md +1 -984
- package/out/handlers/crowdin-webhook.js +1 -1
- package/out/handlers/{custom-file-format/process.js → file-processing/custom-file-format.js} +8 -23
- package/out/handlers/file-processing/file-download.d.ts +4 -0
- package/out/handlers/{custom-file-format/download.js → file-processing/file-download.js} +3 -2
- package/out/handlers/file-processing/pre-post-process.d.ts +4 -0
- package/out/handlers/file-processing/pre-post-process.js +99 -0
- package/out/handlers/form-data-display.js +6 -2
- package/out/handlers/form-data-save.js +5 -1
- package/out/handlers/manifest.js +63 -0
- package/out/index.d.ts +3 -3
- package/out/index.js +64 -30
- package/out/middlewares/render-ui-module.js +5 -3
- package/out/models/index.d.ts +104 -28
- package/out/models/index.js +20 -1
- package/out/static/js/form.js +1 -1
- package/out/storage/index.js +4 -7
- package/out/util/cron.js +5 -1
- package/out/util/defaults.d.ts +3 -2
- package/out/util/defaults.js +21 -4
- package/out/util/files.d.ts +3 -0
- package/out/util/files.js +43 -0
- package/out/util/index.js +5 -1
- package/out/util/webhooks.js +15 -4
- package/out/views/form.handlebars +6 -2
- package/package.json +15 -15
- package/out/handlers/custom-file-format/download.d.ts +0 -4
- package/rollup.config.mjs +0 -31
- /package/out/handlers/{custom-file-format/process.d.ts → file-processing/custom-file-format.d.ts} +0 -0
package/out/models/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { JwtPayload, VerifyOptions } from '@crowdin/crowdin-apps-functions';
|
|
|
3
3
|
import { Request } from 'express';
|
|
4
4
|
import { MySQLStorageConfig } from '../storage/mysql';
|
|
5
5
|
import { PostgreStorageConfig } from '../storage/postgre';
|
|
6
|
-
export interface
|
|
6
|
+
export interface ClientConfig extends ImagePath {
|
|
7
7
|
/**
|
|
8
8
|
* Authentication Crowdin App type: "authorization_code", "crowdin_app". Default: "crowdin_app"
|
|
9
9
|
*/
|
|
@@ -11,11 +11,11 @@ export interface Config extends ImagePath {
|
|
|
11
11
|
/**
|
|
12
12
|
* client id that we received when registering the app
|
|
13
13
|
*/
|
|
14
|
-
clientId
|
|
14
|
+
clientId?: string;
|
|
15
15
|
/**
|
|
16
16
|
* client secret that we received when registering the app
|
|
17
17
|
*/
|
|
18
|
-
clientSecret
|
|
18
|
+
clientSecret?: string;
|
|
19
19
|
/**
|
|
20
20
|
* Secret to encrypt/decrypt credentials (by default @clientSecret will be used)
|
|
21
21
|
*/
|
|
@@ -27,7 +27,7 @@ export interface Config extends ImagePath {
|
|
|
27
27
|
/**
|
|
28
28
|
* https url where an app is reachable from the internet (e.g. the one that ngrok generates for us)
|
|
29
29
|
*/
|
|
30
|
-
baseUrl
|
|
30
|
+
baseUrl?: string;
|
|
31
31
|
/**
|
|
32
32
|
* define custom Crowdin urls (e.g. to work against local Crowdin server)
|
|
33
33
|
*/
|
|
@@ -104,6 +104,14 @@ export interface Config extends ImagePath {
|
|
|
104
104
|
* reports module
|
|
105
105
|
*/
|
|
106
106
|
projectReports?: UiModule & ImagePath;
|
|
107
|
+
/**
|
|
108
|
+
* context menu module
|
|
109
|
+
*/
|
|
110
|
+
contextMenu?: ContextModule & UiModule & Environments;
|
|
111
|
+
/**
|
|
112
|
+
* modal module
|
|
113
|
+
*/
|
|
114
|
+
modal?: ModuleContent & UiModule & Environments;
|
|
107
115
|
/**
|
|
108
116
|
* Uninstall hook for cleanup logic
|
|
109
117
|
*/
|
|
@@ -127,7 +135,19 @@ export interface Config extends ImagePath {
|
|
|
127
135
|
* Configuration of app pricing
|
|
128
136
|
*/
|
|
129
137
|
pricing?: Pricing;
|
|
138
|
+
filePreImport?: FilePreImportLogic;
|
|
139
|
+
filePostImport?: FilePostImportLogic;
|
|
140
|
+
filePreExport?: FilePreExportLogic;
|
|
141
|
+
filePostExport?: FilePostExportLogic;
|
|
130
142
|
}
|
|
143
|
+
export type Config = ClientConfig & {
|
|
144
|
+
baseUrl: string;
|
|
145
|
+
clientId: string;
|
|
146
|
+
clientSecret: string;
|
|
147
|
+
port: number;
|
|
148
|
+
dbFolder: string;
|
|
149
|
+
imagePath: string;
|
|
150
|
+
};
|
|
131
151
|
export declare enum AuthenticationType {
|
|
132
152
|
CODE = "authorization_code",
|
|
133
153
|
APP = "crowdin_app"
|
|
@@ -250,7 +270,7 @@ export interface IntegrationLogic {
|
|
|
250
270
|
*/
|
|
251
271
|
webhooks?: Webhooks;
|
|
252
272
|
}
|
|
253
|
-
export
|
|
273
|
+
export type FormEntity = FormField | FormDelimeter;
|
|
254
274
|
export interface FormDelimeter {
|
|
255
275
|
label: string;
|
|
256
276
|
}
|
|
@@ -403,13 +423,13 @@ export interface ExtendedResult<T> {
|
|
|
403
423
|
message?: string;
|
|
404
424
|
stopPagination?: boolean;
|
|
405
425
|
}
|
|
406
|
-
export
|
|
426
|
+
export type TreeItem = File | Folder;
|
|
407
427
|
/**
|
|
408
428
|
* 0 - folder
|
|
409
429
|
* 1 - file
|
|
410
430
|
* 2 - branch
|
|
411
431
|
*/
|
|
412
|
-
|
|
432
|
+
type IntegrationTreeElementType = '0' | '1' | '2';
|
|
413
433
|
export interface File {
|
|
414
434
|
id: string;
|
|
415
435
|
name: string;
|
|
@@ -484,23 +504,29 @@ export interface CronJob {
|
|
|
484
504
|
task: (projectId: number, client: Crowdin, apiCredentials: any, appRootFolder?: SourceFilesModel.Directory, config?: any) => Promise<void>;
|
|
485
505
|
expression: string;
|
|
486
506
|
}
|
|
487
|
-
export interface
|
|
488
|
-
/**
|
|
489
|
-
* The type parameter value for a custom file format. Used for a custom format file upload via API.
|
|
490
|
-
*/
|
|
491
|
-
type: string;
|
|
507
|
+
export interface FileProcessLogic {
|
|
492
508
|
/**
|
|
493
509
|
* Folder where larger file will be temporary stored (default "{@link dbFolder}/custom-file-format")
|
|
494
510
|
*/
|
|
495
511
|
filesFolder?: string;
|
|
496
|
-
/**
|
|
497
|
-
* This parameter is used to combine the content of multiple languages into one request when uploading and downloading translations in your Crowdin project.
|
|
498
|
-
*/
|
|
499
|
-
multilingual?: boolean;
|
|
500
512
|
/**
|
|
501
513
|
* 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.
|
|
502
514
|
*/
|
|
503
515
|
signaturePatterns?: SignaturePatterns;
|
|
516
|
+
/**
|
|
517
|
+
* Override to store huge responses (by default they will be stored in fs)
|
|
518
|
+
*/
|
|
519
|
+
storeFile?: (content: string) => Promise<string>;
|
|
520
|
+
}
|
|
521
|
+
export interface CustomFileFormatLogic extends FileProcessLogic {
|
|
522
|
+
/**
|
|
523
|
+
* The type parameter value for a custom file format. Used for a custom format file upload via API.
|
|
524
|
+
*/
|
|
525
|
+
type: string;
|
|
526
|
+
/**
|
|
527
|
+
* This parameter is used to combine the content of multiple languages into one request when uploading and downloading translations in your Crowdin project.
|
|
528
|
+
*/
|
|
529
|
+
multilingual?: boolean;
|
|
504
530
|
/**
|
|
505
531
|
* Flag to automatically upload translations
|
|
506
532
|
*/
|
|
@@ -533,10 +559,19 @@ export interface CustomFileFormatLogic {
|
|
|
533
559
|
* Used for strings export
|
|
534
560
|
*/
|
|
535
561
|
exportStrings?: (req: Omit<ProcessFileRequest, 'jobType'>, strings: ProcessFileString[], client: Crowdin, context: CrowdinContextInfo, projectId: number) => Promise<BuildFileResponse>;
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
562
|
+
}
|
|
563
|
+
export type FileImportExportLogic = FilePreImportLogic | FilePostImportLogic | FilePreExportLogic | FilePostExportLogic;
|
|
564
|
+
export interface FilePreImportLogic extends FileProcessLogic {
|
|
565
|
+
fileProcess: (req: ProcessFileRequest, content: string, client: Crowdin, context: CrowdinContextInfo, projectId: number) => Promise<BuildFileResponse>;
|
|
566
|
+
}
|
|
567
|
+
export interface FilePostImportLogic extends FileProcessLogic {
|
|
568
|
+
fileProcess: (req: ProcessFileRequest, content: string, client: Crowdin, context: CrowdinContextInfo, projectId: number) => Promise<ParseFileResponse>;
|
|
569
|
+
}
|
|
570
|
+
export interface FilePreExportLogic extends FileProcessLogic {
|
|
571
|
+
fileProcess: (req: ProcessFileRequest, content: string, client: Crowdin, context: CrowdinContextInfo, projectId: number) => Promise<ParseFileResponse>;
|
|
572
|
+
}
|
|
573
|
+
export interface FilePostExportLogic extends FileProcessLogic {
|
|
574
|
+
fileProcess: (req: ProcessFileRequest, content: string, client: Crowdin, context: CrowdinContextInfo, projectId: number) => Promise<BuildFileResponse>;
|
|
540
575
|
}
|
|
541
576
|
export interface SignaturePatterns {
|
|
542
577
|
fileName?: string;
|
|
@@ -559,7 +594,11 @@ export interface ProcessFileRecord {
|
|
|
559
594
|
}
|
|
560
595
|
export declare enum ProcessFileJobType {
|
|
561
596
|
PARSE_FILE = "parse-file",
|
|
562
|
-
BUILD_FILE = "build-file"
|
|
597
|
+
BUILD_FILE = "build-file",
|
|
598
|
+
PRE_IMPORT = "pre-import-file",
|
|
599
|
+
POST_IMPORT = "post-import-file",
|
|
600
|
+
PRE_EXPORT = "pre-export-file",
|
|
601
|
+
POST_EXPORT = "post-export-file"
|
|
563
602
|
}
|
|
564
603
|
export interface ParseFileResponse {
|
|
565
604
|
previewFile?: string;
|
|
@@ -568,7 +607,10 @@ export interface ParseFileResponse {
|
|
|
568
607
|
}
|
|
569
608
|
export interface BuildFileResponse {
|
|
570
609
|
contentFile: string;
|
|
610
|
+
base64EncodedContent?: string;
|
|
571
611
|
error?: string;
|
|
612
|
+
fileName?: string;
|
|
613
|
+
fileType?: string;
|
|
572
614
|
}
|
|
573
615
|
export interface ProcessFileString {
|
|
574
616
|
previewId?: number;
|
|
@@ -582,6 +624,7 @@ export interface ProcessFileString {
|
|
|
582
624
|
labels?: string[];
|
|
583
625
|
text: string | SourceStringsModel.PluralText;
|
|
584
626
|
translations?: StringTranslations;
|
|
627
|
+
uniqId?: string;
|
|
585
628
|
}
|
|
586
629
|
export interface StringTranslations {
|
|
587
630
|
[language: string]: {
|
|
@@ -602,10 +645,19 @@ export interface UiModule {
|
|
|
602
645
|
*/
|
|
603
646
|
formSchema?: object;
|
|
604
647
|
/**
|
|
605
|
-
* URL to custom endpoint that can be used instead of default one to save
|
|
606
|
-
* Endpoint should accept
|
|
648
|
+
* URL to custom endpoint that can be used instead of default one to save form data.
|
|
649
|
+
* Endpoint should accept POST requests.
|
|
650
|
+
*/
|
|
651
|
+
formPostDataUrl?: string;
|
|
652
|
+
/**
|
|
653
|
+
* URL to custom endpoint that can be used instead of default one to retrieve form data.
|
|
654
|
+
* Endpoint should accept GET requests.
|
|
655
|
+
*/
|
|
656
|
+
formGetDataUrl?: string;
|
|
657
|
+
/**
|
|
658
|
+
* Additional attributes for react-jsonschema-doc
|
|
607
659
|
*/
|
|
608
|
-
|
|
660
|
+
formUiSchema?: object;
|
|
609
661
|
/**
|
|
610
662
|
* path to ui folder (e.g. {@example join(__dirname, 'public')})
|
|
611
663
|
*/
|
|
@@ -631,6 +683,30 @@ export declare enum EditorPanelsMode {
|
|
|
631
683
|
TRANSLATE = "TRANSLATE",
|
|
632
684
|
PROOFREAD = "proofread"
|
|
633
685
|
}
|
|
686
|
+
interface ModuleContent {
|
|
687
|
+
/**
|
|
688
|
+
* relative URL to the content page of the module
|
|
689
|
+
*/
|
|
690
|
+
url?: string;
|
|
691
|
+
}
|
|
692
|
+
export interface ContextModule {
|
|
693
|
+
location: ContextOptionsLocations;
|
|
694
|
+
type: ContextOptionsTypes;
|
|
695
|
+
module: string;
|
|
696
|
+
}
|
|
697
|
+
export declare enum ContextOptionsLocations {
|
|
698
|
+
TM = "tm",
|
|
699
|
+
GLOSSARY = "glossary",
|
|
700
|
+
LANGUAGE = "language",
|
|
701
|
+
SCREENSHOT = "screenshot",
|
|
702
|
+
SOURCE_FILE = "source_file",
|
|
703
|
+
TRANSLATED_FILE = "translated_file"
|
|
704
|
+
}
|
|
705
|
+
export declare enum ContextOptionsTypes {
|
|
706
|
+
MODAL = "modal",
|
|
707
|
+
NEW_TAB = "new_tab",
|
|
708
|
+
REDIRECT = "redirect"
|
|
709
|
+
}
|
|
634
710
|
export interface CrowdinAppUtilities {
|
|
635
711
|
saveMetadata: (id: string, metadata: any) => Promise<void>;
|
|
636
712
|
getMetadata: (id: string) => Promise<any | undefined>;
|
|
@@ -675,8 +751,8 @@ export interface Webhooks {
|
|
|
675
751
|
urlParam?: string;
|
|
676
752
|
crowdinWebhooks?: (client: Crowdin, projectId: number, available: boolean, config?: any) => Promise<void>;
|
|
677
753
|
integrationWebhooks?: (apiCredentials: any, urlParam: string, available: boolean, config?: any, syncSettings?: any) => Promise<void>;
|
|
678
|
-
crowdinWebhookInterceptor?: (projectId: number, client: Crowdin, appRootFolder?: SourceFilesModel.Directory, config?: any, syncSettings?: any) => Promise<UpdateIntegrationRequest>;
|
|
679
|
-
integrationWebhookInterceptor?: (projectId: number, client: Crowdin, appRootFolder?: SourceFilesModel.Directory, config?: any, syncSettings?: any, webhookRequest?: any) => Promise<IntegrationFile[]>;
|
|
754
|
+
crowdinWebhookInterceptor?: (projectId: number, client: Crowdin, appRootFolder?: SourceFilesModel.Directory, config?: any, syncSettings?: any, webhookRequest?: any) => Promise<UpdateIntegrationRequest>;
|
|
755
|
+
integrationWebhookInterceptor?: (projectId: number, client: Crowdin, apiCredentials: any, appRootFolder?: SourceFilesModel.Directory, config?: any, syncSettings?: any, webhookRequest?: any) => Promise<IntegrationFile[]>;
|
|
680
756
|
queueUrl: string;
|
|
681
757
|
}
|
|
682
758
|
export declare enum SyncCondition {
|
|
@@ -689,13 +765,13 @@ export declare enum SyncType {
|
|
|
689
765
|
SCHEDULE = 1,
|
|
690
766
|
WEBHOOKS = 2
|
|
691
767
|
}
|
|
692
|
-
export
|
|
768
|
+
export type Payload = {
|
|
693
769
|
event: string;
|
|
694
770
|
projectId: string;
|
|
695
771
|
language: string;
|
|
696
772
|
fileId: string;
|
|
697
773
|
};
|
|
698
|
-
export
|
|
774
|
+
export type WebhookUrlParams = {
|
|
699
775
|
projectId: number;
|
|
700
776
|
crowdinId: string;
|
|
701
777
|
clientId: string;
|
package/out/models/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SyncType = exports.SyncCondition = exports.EditorPanelsMode = exports.ProcessFileJobType = exports.SubscriptionInfoType = exports.AccountType = exports.Scope = exports.AuthenticationType = void 0;
|
|
3
|
+
exports.SyncType = exports.SyncCondition = exports.ContextOptionsTypes = exports.ContextOptionsLocations = exports.EditorPanelsMode = exports.ProcessFileJobType = exports.SubscriptionInfoType = exports.AccountType = exports.Scope = exports.AuthenticationType = void 0;
|
|
4
4
|
var AuthenticationType;
|
|
5
5
|
(function (AuthenticationType) {
|
|
6
6
|
AuthenticationType["CODE"] = "authorization_code";
|
|
@@ -39,6 +39,10 @@ var ProcessFileJobType;
|
|
|
39
39
|
(function (ProcessFileJobType) {
|
|
40
40
|
ProcessFileJobType["PARSE_FILE"] = "parse-file";
|
|
41
41
|
ProcessFileJobType["BUILD_FILE"] = "build-file";
|
|
42
|
+
ProcessFileJobType["PRE_IMPORT"] = "pre-import-file";
|
|
43
|
+
ProcessFileJobType["POST_IMPORT"] = "post-import-file";
|
|
44
|
+
ProcessFileJobType["PRE_EXPORT"] = "pre-export-file";
|
|
45
|
+
ProcessFileJobType["POST_EXPORT"] = "post-export-file";
|
|
42
46
|
})(ProcessFileJobType = exports.ProcessFileJobType || (exports.ProcessFileJobType = {}));
|
|
43
47
|
var EditorPanelsMode;
|
|
44
48
|
(function (EditorPanelsMode) {
|
|
@@ -47,6 +51,21 @@ var EditorPanelsMode;
|
|
|
47
51
|
EditorPanelsMode["TRANSLATE"] = "TRANSLATE";
|
|
48
52
|
EditorPanelsMode["PROOFREAD"] = "proofread";
|
|
49
53
|
})(EditorPanelsMode = exports.EditorPanelsMode || (exports.EditorPanelsMode = {}));
|
|
54
|
+
var ContextOptionsLocations;
|
|
55
|
+
(function (ContextOptionsLocations) {
|
|
56
|
+
ContextOptionsLocations["TM"] = "tm";
|
|
57
|
+
ContextOptionsLocations["GLOSSARY"] = "glossary";
|
|
58
|
+
ContextOptionsLocations["LANGUAGE"] = "language";
|
|
59
|
+
ContextOptionsLocations["SCREENSHOT"] = "screenshot";
|
|
60
|
+
ContextOptionsLocations["SOURCE_FILE"] = "source_file";
|
|
61
|
+
ContextOptionsLocations["TRANSLATED_FILE"] = "translated_file";
|
|
62
|
+
})(ContextOptionsLocations = exports.ContextOptionsLocations || (exports.ContextOptionsLocations = {}));
|
|
63
|
+
var ContextOptionsTypes;
|
|
64
|
+
(function (ContextOptionsTypes) {
|
|
65
|
+
ContextOptionsTypes["MODAL"] = "modal";
|
|
66
|
+
ContextOptionsTypes["NEW_TAB"] = "new_tab";
|
|
67
|
+
ContextOptionsTypes["REDIRECT"] = "redirect";
|
|
68
|
+
})(ContextOptionsTypes = exports.ContextOptionsTypes || (exports.ContextOptionsTypes = {}));
|
|
50
69
|
var SyncCondition;
|
|
51
70
|
(function (SyncCondition) {
|
|
52
71
|
SyncCondition[SyncCondition["ALL"] = 0] = "ALL";
|