@crowdin/app-project-module 0.43.1 → 0.45.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.
- package/out/index.d.ts +3 -3
- package/out/index.js +103 -219
- package/out/middlewares/crowdin-client.d.ts +1 -1
- package/out/middlewares/crowdin-client.js +3 -2
- package/out/middlewares/integration-credentials.d.ts +3 -2
- package/out/middlewares/render-ui-module.d.ts +2 -2
- package/out/middlewares/ui-module.d.ts +2 -2
- package/out/middlewares/ui-module.js +5 -1
- package/out/{util → modules}/api/api.d.ts +3 -2
- package/out/{util → modules}/api/api.js +22 -22
- package/out/modules/api/index.d.ts +6 -0
- package/out/modules/api/index.js +14 -0
- package/out/modules/api/types.d.ts +20 -0
- package/out/modules/api/types.js +11 -0
- package/out/modules/context-menu/index.d.ts +6 -0
- package/out/modules/context-menu/index.js +17 -0
- package/out/modules/context-menu/types.d.ts +27 -0
- package/out/modules/context-menu/types.js +18 -0
- package/out/{handlers/custom-mt → modules/custom-mt/handlers}/translate.d.ts +2 -1
- package/out/{handlers/custom-mt → modules/custom-mt/handlers}/translate.js +2 -2
- package/out/modules/custom-mt/index.d.ts +6 -0
- package/out/modules/custom-mt/index.js +17 -0
- package/out/modules/custom-mt/types.d.ts +22 -0
- package/out/modules/custom-mt/types.js +2 -0
- package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/get-languages-list.d.ts +2 -1
- package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/get-languages-list.js +2 -2
- package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/spell-check.d.ts +2 -1
- package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/spell-check.js +5 -3
- package/out/modules/custom-spell-check/index.d.ts +6 -0
- package/out/modules/custom-spell-check/index.js +32 -0
- package/out/modules/custom-spell-check/types.d.ts +56 -0
- package/out/modules/custom-spell-check/types.js +2 -0
- package/out/modules/editor-right-panel/index.d.ts +6 -0
- package/out/modules/editor-right-panel/index.js +17 -0
- package/out/modules/editor-right-panel/types.d.ts +7 -0
- package/out/modules/editor-right-panel/types.js +2 -0
- package/out/modules/editor-themes/index.d.ts +6 -0
- package/out/modules/editor-themes/index.js +11 -0
- package/out/modules/editor-themes/types.d.ts +17 -0
- package/out/modules/editor-themes/types.js +2 -0
- package/out/{handlers/file-processing → modules/file-processing/handlers}/custom-file-format.d.ts +2 -1
- package/out/{handlers/file-processing → modules/file-processing/handlers}/custom-file-format.js +5 -5
- package/out/modules/file-processing/handlers/file-download.d.ts +5 -0
- package/out/{handlers/file-processing → modules/file-processing/handlers}/file-download.js +2 -2
- package/out/{handlers/file-processing → modules/file-processing/handlers}/pre-post-process.d.ts +2 -1
- package/out/{handlers/file-processing → modules/file-processing/handlers}/pre-post-process.js +8 -8
- package/out/modules/file-processing/index.d.ts +22 -0
- package/out/modules/file-processing/index.js +57 -0
- package/out/modules/file-processing/types.d.ts +133 -0
- package/out/modules/file-processing/types.js +12 -0
- package/out/modules/file-processing/util/defaults.d.ts +3 -0
- package/out/modules/file-processing/util/defaults.js +30 -0
- package/out/modules/file-processing/util/files.d.ts +6 -0
- package/out/modules/file-processing/util/files.js +47 -0
- package/out/{handlers/integration/crowdin-project.d.ts → modules/form-data-display.d.ts} +1 -1
- package/out/modules/form-data-save.d.ts +4 -0
- package/out/modules/install.d.ts +4 -0
- package/out/{handlers → modules}/install.js +3 -3
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-file-progress.d.ts +2 -1
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-file-progress.js +2 -2
- package/out/modules/integration/handlers/crowdin-files.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-files.js +3 -3
- package/out/modules/integration/handlers/crowdin-project.d.ts +4 -0
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-project.js +1 -1
- package/out/modules/integration/handlers/crowdin-update.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-update.js +9 -9
- package/out/modules/integration/handlers/crowdin-webhook.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-webhook.js +19 -8
- package/out/modules/integration/handlers/integration-data.d.ts +4 -0
- package/out/{handlers/integration → modules/integration/handlers}/integration-data.js +5 -5
- package/out/{handlers/integration → modules/integration/handlers}/integration-login.d.ts +2 -1
- package/out/{handlers/integration → modules/integration/handlers}/integration-login.js +3 -3
- package/out/modules/integration/handlers/integration-logout.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/integration-logout.js +14 -7
- package/out/modules/integration/handlers/integration-update.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/integration-update.js +9 -8
- package/out/modules/integration/handlers/integration-webhook.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/integration-webhook.js +9 -4
- package/out/modules/integration/handlers/job-cancel.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/job-cancel.js +4 -4
- package/out/modules/integration/handlers/job-info.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/job-info.js +4 -4
- package/out/modules/integration/handlers/main.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/main.js +5 -5
- package/out/modules/integration/handlers/oauth-login.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/oauth-login.js +3 -3
- package/out/{handlers/integration → modules/integration/handlers}/oauth-url.d.ts +2 -1
- package/out/{handlers/integration → modules/integration/handlers}/oauth-url.js +2 -2
- package/out/modules/integration/handlers/settings-save.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/settings-save.js +28 -11
- package/out/modules/integration/handlers/settings.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/settings.js +1 -1
- package/out/{handlers/integration → modules/integration/handlers}/subscription-info.d.ts +1 -1
- package/out/{handlers/integration → modules/integration/handlers}/subscription-info.js +2 -2
- package/out/modules/integration/handlers/sync-settings-save.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/sync-settings-save.js +16 -8
- package/out/modules/integration/handlers/sync-settings.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/sync-settings.js +2 -2
- package/out/modules/integration/handlers/user-errors.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/user-errors.js +2 -2
- package/out/modules/integration/index.d.ts +6 -0
- package/out/modules/integration/index.js +118 -0
- package/out/modules/integration/types.d.ts +435 -0
- package/out/modules/integration/types.js +19 -0
- package/out/modules/integration/util/cron.d.ts +27 -0
- package/out/{util → modules/integration/util}/cron.js +97 -28
- package/out/{util → modules/integration/util}/defaults.d.ts +2 -3
- package/out/{util → modules/integration/util}/defaults.js +1 -36
- package/out/modules/integration/util/files.d.ts +5 -0
- package/out/{util → modules/integration/util}/files.js +9 -40
- package/out/{util → modules/integration/util}/job.d.ts +1 -1
- package/out/{util → modules/integration/util}/job.js +11 -11
- package/out/{util/file-snapshot.d.ts → modules/integration/util/snapshot.d.ts} +2 -3
- package/out/{util/file-snapshot.js → modules/integration/util/snapshot.js} +6 -65
- package/out/{models/job.d.ts → modules/integration/util/types.d.ts} +14 -0
- package/out/modules/integration/util/webhooks.d.ts +48 -0
- package/out/{util → modules/integration/util}/webhooks.js +95 -49
- package/out/modules/manifest.d.ts +3 -0
- package/out/{handlers → modules}/manifest.js +22 -16
- package/out/modules/modal/index.d.ts +6 -0
- package/out/modules/modal/index.js +17 -0
- package/out/modules/organization-menu/index.d.ts +6 -0
- package/out/modules/organization-menu/index.js +18 -0
- package/out/modules/profile-resources-menu/index.d.ts +6 -0
- package/out/modules/profile-resources-menu/index.js +18 -0
- package/out/modules/project-menu/index.d.ts +6 -0
- package/out/modules/project-menu/index.js +17 -0
- package/out/modules/project-menu-crowdsource/index.d.ts +6 -0
- package/out/modules/project-menu-crowdsource/index.js +17 -0
- package/out/modules/project-reports/index.d.ts +6 -0
- package/out/modules/project-reports/index.js +18 -0
- package/out/modules/project-tools/index.d.ts +6 -0
- package/out/modules/project-tools/index.js +18 -0
- package/out/modules/subscription-paid.d.ts +3 -0
- package/out/{handlers → modules}/subscription-paid.js +2 -2
- package/out/modules/uninstall.d.ts +4 -0
- package/out/{handlers → modules}/uninstall.js +6 -2
- package/out/storage/index.d.ts +5 -3
- package/out/storage/mysql.d.ts +4 -2
- package/out/storage/mysql.js +3 -3
- package/out/storage/postgre.d.ts +4 -2
- package/out/storage/postgre.js +3 -3
- package/out/storage/sqlite.d.ts +4 -2
- package/out/storage/sqlite.js +3 -3
- package/out/storage/types.d.ts +9 -0
- package/out/storage/types.js +2 -0
- package/out/types.d.ts +374 -0
- package/out/types.js +59 -0
- package/out/util/connection.d.ts +2 -9
- package/out/util/connection.js +54 -150
- package/out/util/handlebars.d.ts +1 -0
- package/out/util/handlebars.js +34 -0
- package/out/util/index.d.ts +2 -2
- package/out/util/index.js +6 -6
- package/out/util/logger.d.ts +2 -2
- package/out/util/subscription.d.ts +9 -0
- package/out/util/subscription.js +111 -0
- package/package.json +1 -1
- package/out/handlers/file-processing/file-download.d.ts +0 -4
- package/out/handlers/form-data-display.d.ts +0 -3
- package/out/handlers/form-data-save.d.ts +0 -3
- package/out/handlers/install.d.ts +0 -4
- package/out/handlers/integration/crowdin-files.d.ts +0 -4
- package/out/handlers/integration/crowdin-update.d.ts +0 -4
- package/out/handlers/integration/crowdin-webhook.d.ts +0 -4
- package/out/handlers/integration/integration-data.d.ts +0 -4
- package/out/handlers/integration/integration-logout.d.ts +0 -4
- package/out/handlers/integration/integration-update.d.ts +0 -4
- package/out/handlers/integration/integration-webhook.d.ts +0 -4
- package/out/handlers/integration/job-cancel.d.ts +0 -3
- package/out/handlers/integration/job-info.d.ts +0 -3
- package/out/handlers/integration/main.d.ts +0 -4
- package/out/handlers/integration/oauth-login.d.ts +0 -4
- package/out/handlers/integration/settings-save.d.ts +0 -4
- package/out/handlers/integration/settings.d.ts +0 -3
- package/out/handlers/integration/sync-settings-save.d.ts +0 -4
- package/out/handlers/integration/sync-settings.d.ts +0 -3
- package/out/handlers/integration/user-errors.d.ts +0 -3
- package/out/handlers/manifest.d.ts +0 -3
- package/out/handlers/subscription-paid.d.ts +0 -3
- package/out/handlers/uninstall.d.ts +0 -4
- package/out/models/index.d.ts +0 -1088
- package/out/models/index.js +0 -106
- package/out/util/cron.d.ts +0 -7
- package/out/util/files.d.ts +0 -9
- package/out/util/webhooks.d.ts +0 -28
- /package/out/{util → modules}/api/base.d.ts +0 -0
- /package/out/{util → modules}/api/base.js +0 -0
- /package/out/{util → modules}/api/components.d.ts +0 -0
- /package/out/{util → modules}/api/components.js +0 -0
- /package/out/{handlers → modules}/form-data-display.js +0 -0
- /package/out/{handlers → modules}/form-data-save.js +0 -0
- /package/out/{models/job.js → modules/integration/util/types.js} +0 -0
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
import Crowdin, { SourceFilesModel, TranslationStatusModel } from '@crowdin/crowdin-api-client';
|
|
2
|
+
import { Request } from 'express';
|
|
3
|
+
import { CrowdinClientRequest } from '../../types';
|
|
4
|
+
import { JobClient } from './util/types';
|
|
5
|
+
export interface IntegrationLogic {
|
|
6
|
+
/**
|
|
7
|
+
* Customize your app login form
|
|
8
|
+
*/
|
|
9
|
+
loginForm: LoginForm;
|
|
10
|
+
/**
|
|
11
|
+
* Define login process via OAuth2 protocol
|
|
12
|
+
*/
|
|
13
|
+
oauthLogin?: OAuthLogin;
|
|
14
|
+
/**
|
|
15
|
+
* 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
|
|
16
|
+
*/
|
|
17
|
+
appFolderName?: string;
|
|
18
|
+
/**
|
|
19
|
+
* flag that defines if the app should have a dedicated root folder in Crowdin files, default 'false'
|
|
20
|
+
*/
|
|
21
|
+
withRootFolder?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* function which will be used to check connection with integration service
|
|
24
|
+
*/
|
|
25
|
+
checkConnection?: (apiCredentials: any) => Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* function to get crowdin files that are related with this integration
|
|
28
|
+
*/
|
|
29
|
+
getCrowdinFiles?: (projectId: number, client: Crowdin, appRootFolder?: SourceFilesModel.Directory, config?: any) => Promise<TreeItem[]>;
|
|
30
|
+
/**
|
|
31
|
+
* function to get data from integration
|
|
32
|
+
*/
|
|
33
|
+
getIntegrationFiles: (apiCredentials: any, config?: any, parentId?: any, search?: any, page?: any) => Promise<TreeItem[] | ExtendedResult<TreeItem[]>>;
|
|
34
|
+
/**
|
|
35
|
+
* function to update crowdin files (e.g. pull integration data to crowdin source files)
|
|
36
|
+
*/
|
|
37
|
+
updateCrowdin: ({ projectId, client, credentials, request, rootFolder, appSettings, uploadTranslations, job, }: {
|
|
38
|
+
projectId: number;
|
|
39
|
+
client: Crowdin;
|
|
40
|
+
credentials: any;
|
|
41
|
+
request: IntegrationFile[];
|
|
42
|
+
rootFolder?: SourceFilesModel.Directory;
|
|
43
|
+
appSettings?: any;
|
|
44
|
+
uploadTranslations?: boolean;
|
|
45
|
+
job: JobClient;
|
|
46
|
+
}) => Promise<void | ExtendedResult<void>>;
|
|
47
|
+
/**
|
|
48
|
+
* function to update integration content (e.g. load crowdin translations and push them to integration service)
|
|
49
|
+
*/
|
|
50
|
+
updateIntegration: ({ projectId, client, credentials, request, rootFolder, appSettings, job, }: {
|
|
51
|
+
projectId: number;
|
|
52
|
+
client: Crowdin;
|
|
53
|
+
credentials: any;
|
|
54
|
+
request: UpdateIntegrationRequest;
|
|
55
|
+
rootFolder?: SourceFilesModel.Directory;
|
|
56
|
+
appSettings?: any;
|
|
57
|
+
job: JobClient;
|
|
58
|
+
}) => Promise<void | ExtendedResult<void>>;
|
|
59
|
+
/**
|
|
60
|
+
* function to define configuration(settings) modal for you app (by default app will not have any custom settings)
|
|
61
|
+
*/
|
|
62
|
+
getConfiguration?: (projectId: number, client: Crowdin, apiCredentials: any) => Promise<FormEntity[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Logout hook for cleanup logic
|
|
65
|
+
*/
|
|
66
|
+
onLogout?: (projectId: number, client: Crowdin, apiCredentials: any, config?: any) => Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* flag to turn on auto reload of the tree whenever user updates the configuration
|
|
69
|
+
*/
|
|
70
|
+
reloadOnConfigSave?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* define info modal (help section) for you app (by default app will not have own info section)
|
|
73
|
+
*/
|
|
74
|
+
infoModal?: {
|
|
75
|
+
title: string;
|
|
76
|
+
content: string;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* background jobs that will be executed for each crowdin project and user
|
|
80
|
+
*/
|
|
81
|
+
cronJobs?: CronJob[];
|
|
82
|
+
/**
|
|
83
|
+
* Enable new file sync when syncing via cron or webhook
|
|
84
|
+
*/
|
|
85
|
+
syncNewElements?: {
|
|
86
|
+
crowdin: boolean;
|
|
87
|
+
integration: boolean;
|
|
88
|
+
};
|
|
89
|
+
withCronSync?: {
|
|
90
|
+
crowdin: boolean;
|
|
91
|
+
integration: boolean;
|
|
92
|
+
};
|
|
93
|
+
withWebhookSync?: {
|
|
94
|
+
crowdin: boolean;
|
|
95
|
+
integration: boolean;
|
|
96
|
+
};
|
|
97
|
+
filtering?: {
|
|
98
|
+
crowdinLanguages: boolean;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Enable integration folder open event
|
|
102
|
+
*/
|
|
103
|
+
integrationOneLevelFetching?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Enable integration search event
|
|
106
|
+
*/
|
|
107
|
+
integrationSearchListener?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Enable integration next page event
|
|
110
|
+
*/
|
|
111
|
+
integrationPagination?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Enable the option to upload translations to crowdin that are already present in the integration.
|
|
114
|
+
*/
|
|
115
|
+
uploadTranslations?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* function to get crowdin file translation progress
|
|
118
|
+
*/
|
|
119
|
+
getFileProgress?: (projectId: number, client: Crowdin, fileId: number) => Promise<{
|
|
120
|
+
[key: number]: TranslationStatusModel.LanguageProgress[];
|
|
121
|
+
}>;
|
|
122
|
+
/**
|
|
123
|
+
* Register Crowdin webhook to get notified when translations are ready
|
|
124
|
+
*/
|
|
125
|
+
webhooks?: Webhooks;
|
|
126
|
+
/**
|
|
127
|
+
* define a notification for your application at the top of the screen
|
|
128
|
+
*/
|
|
129
|
+
notice?: {
|
|
130
|
+
title: string;
|
|
131
|
+
content: string;
|
|
132
|
+
type: NoticeType;
|
|
133
|
+
icon: boolean;
|
|
134
|
+
close: boolean;
|
|
135
|
+
};
|
|
136
|
+
skipIntegrationNodes?: SkipIntegrationNodes;
|
|
137
|
+
/**
|
|
138
|
+
* Async progress checking time interval to update job progress, im ms.
|
|
139
|
+
*
|
|
140
|
+
* Default 1000
|
|
141
|
+
*/
|
|
142
|
+
asyncProgress?: {
|
|
143
|
+
checkInterval?: number;
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
export interface LoginForm {
|
|
147
|
+
fields: FormEntity[];
|
|
148
|
+
}
|
|
149
|
+
export interface OAuthLogin {
|
|
150
|
+
/**
|
|
151
|
+
* Extra field for login form
|
|
152
|
+
*/
|
|
153
|
+
loginFields?: FormField[];
|
|
154
|
+
/**
|
|
155
|
+
* Authorization url (e.g. https://github.com/login/oauth/authorize or https://accounts.google.com/o/oauth2/v2/auth)
|
|
156
|
+
*/
|
|
157
|
+
authorizationUrl?: string;
|
|
158
|
+
/**
|
|
159
|
+
* Authorization url getter
|
|
160
|
+
*/
|
|
161
|
+
getAuthorizationUrl?: (redirectUrl: string, loginForm?: any) => string;
|
|
162
|
+
/**
|
|
163
|
+
* Access token url (e.g. https://github.com/login/oauth/access_token)
|
|
164
|
+
*/
|
|
165
|
+
accessTokenUrl: string;
|
|
166
|
+
/**
|
|
167
|
+
* Url to refresh token, default will use {@link accessTokenUrl}. Needed when {@link refresh} is enabled
|
|
168
|
+
*/
|
|
169
|
+
refreshTokenUrl?: string;
|
|
170
|
+
/**
|
|
171
|
+
* The scopes of access, usually expressed as a list of space-delimited, case-sensitive strings
|
|
172
|
+
*/
|
|
173
|
+
scope?: string;
|
|
174
|
+
/**
|
|
175
|
+
* Client id
|
|
176
|
+
*/
|
|
177
|
+
clientId: string;
|
|
178
|
+
/**
|
|
179
|
+
* Client secret
|
|
180
|
+
*/
|
|
181
|
+
clientSecret: string;
|
|
182
|
+
/**
|
|
183
|
+
* default '/oauth/code'
|
|
184
|
+
*/
|
|
185
|
+
redirectUriRoute?: string;
|
|
186
|
+
/**
|
|
187
|
+
* request/response fields mapping
|
|
188
|
+
*/
|
|
189
|
+
fieldsMapping?: {
|
|
190
|
+
/**
|
|
191
|
+
* default 'client_id'
|
|
192
|
+
*/
|
|
193
|
+
clientId?: string;
|
|
194
|
+
/**
|
|
195
|
+
* default 'client_secret'
|
|
196
|
+
*/
|
|
197
|
+
clientSecret?: string;
|
|
198
|
+
/**
|
|
199
|
+
* default 'scope'
|
|
200
|
+
*/
|
|
201
|
+
scope?: string;
|
|
202
|
+
/**
|
|
203
|
+
* default 'redirect_uri'
|
|
204
|
+
*/
|
|
205
|
+
redirectUri?: string;
|
|
206
|
+
/**
|
|
207
|
+
* default 'code'
|
|
208
|
+
*/
|
|
209
|
+
code: string;
|
|
210
|
+
/**
|
|
211
|
+
* default 'access_token'
|
|
212
|
+
*/
|
|
213
|
+
accessToken?: string;
|
|
214
|
+
/**
|
|
215
|
+
* default 'refresh_token'
|
|
216
|
+
*/
|
|
217
|
+
refreshToken?: string;
|
|
218
|
+
/**
|
|
219
|
+
* default 'expires_in'
|
|
220
|
+
*/
|
|
221
|
+
expiresIn?: string;
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* default 'false' which means that the access token has no expiration date
|
|
225
|
+
*/
|
|
226
|
+
refresh?: boolean;
|
|
227
|
+
/**
|
|
228
|
+
* Additional URL parameters for authorizarion url
|
|
229
|
+
*/
|
|
230
|
+
extraAutorizationUrlParameters?: {
|
|
231
|
+
[key: string]: string;
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Additional parameters for access token request
|
|
235
|
+
*/
|
|
236
|
+
extraAccessTokenParameters?: {
|
|
237
|
+
[key: string]: any;
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* Additional parameters for refresh token request
|
|
241
|
+
*/
|
|
242
|
+
extraRefreshTokenParameters?: {
|
|
243
|
+
[key: string]: any;
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* Override to implement request for retrieving access token (and refresh token if 'refresh' is enabled)
|
|
247
|
+
*/
|
|
248
|
+
performGetTokenRequest?: (code: string, query: {
|
|
249
|
+
[key: string]: any;
|
|
250
|
+
}, url: string) => Promise<any>;
|
|
251
|
+
/**
|
|
252
|
+
* Override to implement request for refreshing token (only if 'refresh' is enabled)
|
|
253
|
+
*/
|
|
254
|
+
performRefreshTokenRequest?: (currentCredentials: any) => Promise<any>;
|
|
255
|
+
}
|
|
256
|
+
export interface File {
|
|
257
|
+
id: string;
|
|
258
|
+
name: string;
|
|
259
|
+
type: SourceFilesModel.FileType;
|
|
260
|
+
parentId?: string;
|
|
261
|
+
nodeType?: IntegrationTreeElementType;
|
|
262
|
+
customContent?: string;
|
|
263
|
+
labels?: LabelTreeElement;
|
|
264
|
+
}
|
|
265
|
+
export interface Folder {
|
|
266
|
+
id: string;
|
|
267
|
+
name: string;
|
|
268
|
+
parentId?: string;
|
|
269
|
+
nodeType?: IntegrationTreeElementType;
|
|
270
|
+
customContent?: string;
|
|
271
|
+
labels?: LabelTreeElement;
|
|
272
|
+
}
|
|
273
|
+
export type TreeItem = File | Folder;
|
|
274
|
+
/**
|
|
275
|
+
* 0 - folder
|
|
276
|
+
* 1 - file
|
|
277
|
+
* 2 - branch
|
|
278
|
+
*/
|
|
279
|
+
type IntegrationTreeElementType = '0' | '1' | '2';
|
|
280
|
+
export type FormEntity = FormField | FormDelimiter;
|
|
281
|
+
export interface FormDelimiter {
|
|
282
|
+
label?: string;
|
|
283
|
+
labelHtml?: string;
|
|
284
|
+
}
|
|
285
|
+
export interface FormField {
|
|
286
|
+
key: string;
|
|
287
|
+
helpText?: string;
|
|
288
|
+
helpTextHtml?: string;
|
|
289
|
+
label: string;
|
|
290
|
+
type?: 'text' | 'password' | 'checkbox' | 'select' | 'textarea' | 'file';
|
|
291
|
+
defaultValue?: any;
|
|
292
|
+
/**
|
|
293
|
+
* only for select
|
|
294
|
+
*/
|
|
295
|
+
isMulti?: boolean;
|
|
296
|
+
/**
|
|
297
|
+
* only for select
|
|
298
|
+
*/
|
|
299
|
+
isSearchable?: boolean;
|
|
300
|
+
/**
|
|
301
|
+
* only for select
|
|
302
|
+
*/
|
|
303
|
+
options?: {
|
|
304
|
+
label: string;
|
|
305
|
+
value: string;
|
|
306
|
+
}[];
|
|
307
|
+
/**
|
|
308
|
+
* only for type file
|
|
309
|
+
*/
|
|
310
|
+
accept?: string;
|
|
311
|
+
/**
|
|
312
|
+
* field dependency settings
|
|
313
|
+
*/
|
|
314
|
+
dependencySettings?: string;
|
|
315
|
+
}
|
|
316
|
+
type NoticeType = 'info' | 'warning' | 'danger' | 'success' | 'error' | 'dataLostWarning';
|
|
317
|
+
export interface IntegrationCredentials {
|
|
318
|
+
id: string;
|
|
319
|
+
credentials: any;
|
|
320
|
+
crowdinId: string;
|
|
321
|
+
}
|
|
322
|
+
export interface IntegrationConfig {
|
|
323
|
+
id: number;
|
|
324
|
+
integrationId: string;
|
|
325
|
+
crowdinId: string;
|
|
326
|
+
config: any;
|
|
327
|
+
}
|
|
328
|
+
export interface IntegrationFile {
|
|
329
|
+
id: string;
|
|
330
|
+
name: string;
|
|
331
|
+
type: SourceFilesModel.FileType;
|
|
332
|
+
parentId: string;
|
|
333
|
+
nodeType?: IntegrationTreeElementType;
|
|
334
|
+
}
|
|
335
|
+
export interface UpdateIntegrationRequest {
|
|
336
|
+
[fileId: string]: string[];
|
|
337
|
+
}
|
|
338
|
+
export interface IntegrationRequest extends CrowdinClientRequest {
|
|
339
|
+
integrationCredentials: any;
|
|
340
|
+
integrationSettings?: any;
|
|
341
|
+
}
|
|
342
|
+
export interface CronJob {
|
|
343
|
+
task: (projectId: number, client: Crowdin, apiCredentials: any, appRootFolder?: SourceFilesModel.Directory, config?: any) => Promise<void>;
|
|
344
|
+
expression: string;
|
|
345
|
+
}
|
|
346
|
+
export interface ExtendedResult<T> {
|
|
347
|
+
data?: T;
|
|
348
|
+
message?: string;
|
|
349
|
+
stopPagination?: boolean;
|
|
350
|
+
}
|
|
351
|
+
type LabelTreeElementType = 'primary' | 'secondary' | 'success' | 'warning' | 'info' | 'danger' | 'dark' | 'light';
|
|
352
|
+
export interface LabelTreeElement {
|
|
353
|
+
text: string;
|
|
354
|
+
type?: LabelTreeElementType;
|
|
355
|
+
color?: string;
|
|
356
|
+
}
|
|
357
|
+
export declare enum Provider {
|
|
358
|
+
CROWDIN = "crowdin",
|
|
359
|
+
INTEGRATION = "integration"
|
|
360
|
+
}
|
|
361
|
+
export interface IntegrationSyncSettings {
|
|
362
|
+
id: number;
|
|
363
|
+
files?: any;
|
|
364
|
+
integrationId: string;
|
|
365
|
+
crowdinId: string;
|
|
366
|
+
provider: Provider;
|
|
367
|
+
}
|
|
368
|
+
export interface IntegrationFilesSnapshot {
|
|
369
|
+
id: number;
|
|
370
|
+
files?: any;
|
|
371
|
+
integrationId: string;
|
|
372
|
+
crowdinId: string;
|
|
373
|
+
provider: Provider;
|
|
374
|
+
}
|
|
375
|
+
export interface IntegrationWebhooks {
|
|
376
|
+
id: number;
|
|
377
|
+
fileId: number;
|
|
378
|
+
integrationId: string;
|
|
379
|
+
crowdinId: string;
|
|
380
|
+
provider: Provider;
|
|
381
|
+
}
|
|
382
|
+
export interface SkipIntegrationNodes {
|
|
383
|
+
fileNamePattern?: string;
|
|
384
|
+
folderNamePattern?: string;
|
|
385
|
+
}
|
|
386
|
+
export interface Webhooks {
|
|
387
|
+
crowdinWebhookUrl?: string;
|
|
388
|
+
integrationWebhookUrl?: string;
|
|
389
|
+
urlParam?: string;
|
|
390
|
+
crowdinWebhooks?: (client: Crowdin, projectId: number, available: boolean, config?: AppSettings) => Promise<void>;
|
|
391
|
+
integrationWebhooks?: (apiCredentials: any, urlParam: string, available: boolean, config?: AppSettings, syncSettings?: any) => Promise<void>;
|
|
392
|
+
crowdinWebhookInterceptor?: (projectId: number, client: Crowdin, appRootFolder?: SourceFilesModel.Directory, config?: any, syncSettings?: any, webhookRequest?: any) => Promise<UpdateIntegrationRequest>;
|
|
393
|
+
integrationWebhookInterceptor?: (projectId: number, client: Crowdin, apiCredentials: any, appRootFolder?: SourceFilesModel.Directory, config?: AppSettings, syncSettings?: any, webhookRequests?: any) => Promise<IntegrationFile[]>;
|
|
394
|
+
queueUrl: string;
|
|
395
|
+
}
|
|
396
|
+
export declare enum SyncCondition {
|
|
397
|
+
ALL = 0,
|
|
398
|
+
TRANSLATED = 1,
|
|
399
|
+
APPROVED = 2
|
|
400
|
+
}
|
|
401
|
+
export declare enum SyncSchedule {
|
|
402
|
+
DISABLED = 0,
|
|
403
|
+
ACTIVE
|
|
404
|
+
}
|
|
405
|
+
export type Payload = {
|
|
406
|
+
event: string;
|
|
407
|
+
projectId: string;
|
|
408
|
+
language: string;
|
|
409
|
+
fileId: string;
|
|
410
|
+
};
|
|
411
|
+
export type WebhookUrlParams = {
|
|
412
|
+
projectId: number;
|
|
413
|
+
crowdinId: string;
|
|
414
|
+
clientId: string;
|
|
415
|
+
};
|
|
416
|
+
export interface UpdateCrowdinWebhookPayloadsArgs {
|
|
417
|
+
integration: IntegrationLogic;
|
|
418
|
+
webhookData: any;
|
|
419
|
+
req: Request[];
|
|
420
|
+
}
|
|
421
|
+
export interface FilterSyncFilesArgs {
|
|
422
|
+
projectId: number;
|
|
423
|
+
crowdinClient: Crowdin;
|
|
424
|
+
events: Payload[];
|
|
425
|
+
syncFileSettings: UpdateIntegrationRequest;
|
|
426
|
+
appSettings: AppSettings;
|
|
427
|
+
}
|
|
428
|
+
export interface AppSettings {
|
|
429
|
+
schedule?: number;
|
|
430
|
+
condition?: number;
|
|
431
|
+
'new-crowdin-files'?: boolean;
|
|
432
|
+
'new-integration-files'?: boolean;
|
|
433
|
+
[key: string]: any;
|
|
434
|
+
}
|
|
435
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SyncSchedule = exports.SyncCondition = exports.Provider = void 0;
|
|
4
|
+
var Provider;
|
|
5
|
+
(function (Provider) {
|
|
6
|
+
Provider["CROWDIN"] = "crowdin";
|
|
7
|
+
Provider["INTEGRATION"] = "integration";
|
|
8
|
+
})(Provider = exports.Provider || (exports.Provider = {}));
|
|
9
|
+
var SyncCondition;
|
|
10
|
+
(function (SyncCondition) {
|
|
11
|
+
SyncCondition[SyncCondition["ALL"] = 0] = "ALL";
|
|
12
|
+
SyncCondition[SyncCondition["TRANSLATED"] = 1] = "TRANSLATED";
|
|
13
|
+
SyncCondition[SyncCondition["APPROVED"] = 2] = "APPROVED";
|
|
14
|
+
})(SyncCondition = exports.SyncCondition || (exports.SyncCondition = {}));
|
|
15
|
+
var SyncSchedule;
|
|
16
|
+
(function (SyncSchedule) {
|
|
17
|
+
SyncSchedule[SyncSchedule["DISABLED"] = 0] = "DISABLED";
|
|
18
|
+
SyncSchedule[SyncSchedule["ACTIVE"] = 1 || 3 || 6 || 12 || 24] = "ACTIVE";
|
|
19
|
+
})(SyncSchedule = exports.SyncSchedule || (exports.SyncSchedule = {}));
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Crowdin from '@crowdin/crowdin-api-client';
|
|
2
|
+
import { Config } from '../../../types';
|
|
3
|
+
import { CronJob, IntegrationLogic, IntegrationRequest, Provider, UpdateIntegrationRequest } from '../types';
|
|
4
|
+
export declare function runJob({ config, integration, job, }: {
|
|
5
|
+
config: Config;
|
|
6
|
+
integration: IntegrationLogic;
|
|
7
|
+
job: CronJob;
|
|
8
|
+
}): Promise<void>;
|
|
9
|
+
export declare function filesCron({ config, integration, period, }: {
|
|
10
|
+
config: Config;
|
|
11
|
+
integration: IntegrationLogic;
|
|
12
|
+
period: string;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
export declare function skipFoldersFromIntegrationRequest({ config, integration, projectId, crowdinClient, crowdinFiles, }: {
|
|
15
|
+
config: Config;
|
|
16
|
+
integration: IntegrationLogic;
|
|
17
|
+
projectId: number;
|
|
18
|
+
crowdinFiles: UpdateIntegrationRequest;
|
|
19
|
+
crowdinClient: Crowdin;
|
|
20
|
+
}): Promise<UpdateIntegrationRequest>;
|
|
21
|
+
export declare function createOrUpdateSyncSettings({ req, files, provider, onlyCreate, }: {
|
|
22
|
+
req: IntegrationRequest;
|
|
23
|
+
files: any;
|
|
24
|
+
provider: Provider;
|
|
25
|
+
onlyCreate?: boolean;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
export declare function removeFinishedJobs(): Promise<void>;
|