@crowdin/app-project-module 0.98.0-cf-0 → 0.98.0-cf-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/out/index.js +11 -6
- package/out/middlewares/crowdin-client.d.ts +1 -1
- package/out/middlewares/integration-credentials.d.ts +1 -1
- package/out/middlewares/render-ui-module.d.ts +1 -1
- package/out/middlewares/ui-module.d.ts +1 -1
- package/out/modules/ai-prompt-provider/handlers/compile.d.ts +1 -1
- package/out/modules/ai-provider/handlers/chat-completions.d.ts +1 -1
- package/out/modules/ai-provider/handlers/get-model-list.d.ts +1 -1
- package/out/modules/ai-request-processors/handler.d.ts +1 -1
- package/out/modules/ai-tools/handlers/tool-calls.d.ts +1 -1
- package/out/modules/custom-mt/handlers/translate.d.ts +1 -1
- package/out/modules/custom-spell-check/handlers/get-languages-list.d.ts +1 -1
- package/out/modules/custom-spell-check/handlers/spell-check.d.ts +1 -1
- package/out/modules/external-qa-check/handlers/validate.d.ts +1 -1
- package/out/modules/file-processing/handlers/custom-file-format.d.ts +1 -1
- package/out/modules/file-processing/handlers/file-download.d.ts +1 -1
- package/out/modules/file-processing/handlers/pre-post-process.d.ts +1 -1
- package/out/modules/form-data-display.d.ts +1 -1
- package/out/modules/form-data-save.d.ts +1 -1
- package/out/modules/install.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-file-progress.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-files.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-project.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-update.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-webhook.d.ts +1 -1
- package/out/modules/integration/handlers/integration-data.d.ts +1 -1
- package/out/modules/integration/handlers/integration-login.d.ts +1 -1
- package/out/modules/integration/handlers/integration-logout.d.ts +1 -1
- package/out/modules/integration/handlers/integration-update.d.ts +1 -1
- package/out/modules/integration/handlers/integration-webhook.d.ts +1 -1
- package/out/modules/integration/handlers/invite-users.d.ts +1 -1
- package/out/modules/integration/handlers/job-cancel.d.ts +1 -1
- package/out/modules/integration/handlers/job-info.d.ts +1 -1
- package/out/modules/integration/handlers/main.d.ts +1 -1
- package/out/modules/integration/handlers/oauth-login.d.ts +1 -1
- package/out/modules/integration/handlers/oauth-polling.d.ts +1 -1
- package/out/modules/integration/handlers/oauth-url.d.ts +1 -1
- package/out/modules/integration/handlers/settings-save.d.ts +1 -1
- package/out/modules/integration/handlers/settings.d.ts +1 -1
- package/out/modules/integration/handlers/sync-settings-save.d.ts +1 -1
- package/out/modules/integration/handlers/sync-settings.d.ts +1 -1
- package/out/modules/integration/handlers/user-errors.d.ts +1 -1
- package/out/modules/integration/handlers/users.d.ts +1 -1
- package/out/modules/integration/index.d.ts +3 -1
- package/out/modules/integration/index.js +11 -2
- package/out/modules/status.d.ts +1 -1
- package/out/modules/subscription-paid.d.ts +1 -1
- package/out/modules/uninstall.d.ts +1 -1
- package/out/modules/webhooks/handlers/webhook-handler.d.ts +1 -1
- package/out/modules/workflow-step-type/handlers/delete-step.d.ts +1 -1
- package/out/modules/workflow-step-type/handlers/step-settings-save.d.ts +1 -1
- package/out/types.d.ts +2 -1
- package/out/util/credentials-masker.d.ts +1 -1
- package/out/util/index.d.ts +1 -0
- package/out/util/index.js +7 -1
- package/out/util/static-files.js +4 -4
- package/package.json +1 -1
package/out/index.js
CHANGED
|
@@ -152,6 +152,13 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
152
152
|
next(error);
|
|
153
153
|
}
|
|
154
154
|
}));
|
|
155
|
+
// Middleware to detect and cache baseUrl from request if not provided
|
|
156
|
+
app.use((req, res, next) => {
|
|
157
|
+
if (!config.baseUrl) {
|
|
158
|
+
config.baseUrl = (0, util_1.extractBaseUrlFromRequest)(req);
|
|
159
|
+
}
|
|
160
|
+
next();
|
|
161
|
+
});
|
|
155
162
|
app.use((req, res, next) => {
|
|
156
163
|
if (config.webhooks && req.path === '/webhooks') {
|
|
157
164
|
return terminus_express_1.default.raw({ type: '*/*', limit: '50mb' })(req, res, next);
|
|
@@ -214,7 +221,7 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
214
221
|
* /util -> folder for utilities
|
|
215
222
|
* /handlers -> for http handlers
|
|
216
223
|
*/
|
|
217
|
-
integrationApp.register({ config, app });
|
|
224
|
+
const { cronExecutions } = integrationApp.register({ config, app });
|
|
218
225
|
customMTApp.register({ config, app });
|
|
219
226
|
fileProcessingApps.registerCustomFileFormat({ config, app });
|
|
220
227
|
fileProcessingApps.registerFilePreImport({ config, app });
|
|
@@ -231,7 +238,8 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
231
238
|
workflowStepType.register({ config, app });
|
|
232
239
|
aiRequestProcessors.register({ config, app });
|
|
233
240
|
addFormSchema({ config, app });
|
|
234
|
-
return Object.assign(Object.assign({}, exports.metadataStore), {
|
|
241
|
+
return Object.assign(Object.assign({}, exports.metadataStore), { //TODO for backward compatibility (needs to be removed)
|
|
242
|
+
cronExecutions, storage: storage.getStorage(), establishCrowdinConnection: (authRequest, moduleKey) => {
|
|
235
243
|
let jwtToken = '';
|
|
236
244
|
if (typeof authRequest === 'string') {
|
|
237
245
|
jwtToken = authRequest;
|
|
@@ -285,9 +293,6 @@ function convertClientConfig(clientConfig) {
|
|
|
285
293
|
const clientSecret = clientConfig.clientSecret || process.env.CROWDIN_CLIENT_SECRET;
|
|
286
294
|
const port = clientConfig.port || process.env.PORT || 3000;
|
|
287
295
|
const { region = process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION, tmpBucketName = process.env.AWS_TMP_BUCKET_NAME, } = clientConfig.awsConfig || {};
|
|
288
|
-
if (!baseUrl) {
|
|
289
|
-
throw new Error('Missing baseUrl parameter');
|
|
290
|
-
}
|
|
291
296
|
if (clientConfig.authenticationType !== types_1.AuthenticationType.NONE) {
|
|
292
297
|
if (!clientId && !clientSecret) {
|
|
293
298
|
throw new Error('Missing [clientId, clientSecret] parameters');
|
|
@@ -297,7 +302,7 @@ function convertClientConfig(clientConfig) {
|
|
|
297
302
|
clientConfig.api = Object.assign({ default: true }, clientConfig.api);
|
|
298
303
|
}
|
|
299
304
|
clientConfig.enableStatusPage = Object.assign({ database: true, filesystem: true }, (clientConfig.enableStatusPage || {}));
|
|
300
|
-
return Object.assign(Object.assign({}, clientConfig), { baseUrl: baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl, clientId,
|
|
305
|
+
return Object.assign(Object.assign({}, clientConfig), { baseUrl: baseUrl ? (baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl) : undefined, clientId,
|
|
301
306
|
clientSecret, awsConfig: {
|
|
302
307
|
tmpBucketName,
|
|
303
308
|
region,
|
|
@@ -21,5 +21,5 @@ export default function handle({ config, optional, checkSubscriptionExpiration,
|
|
|
21
21
|
optional: boolean;
|
|
22
22
|
checkSubscriptionExpiration: boolean;
|
|
23
23
|
moduleKey?: string[] | string | undefined;
|
|
24
|
-
}): (req:
|
|
24
|
+
}): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
25
25
|
export declare function getToken(req: CrowdinClientRequest): string | undefined;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { Config } from '../types';
|
|
4
4
|
import { IntegrationLogic } from '../modules/integration/types';
|
|
5
|
-
export default function handle(config: Config, integration: IntegrationLogic, optional?: boolean): (req: import("
|
|
5
|
+
export default function handle(config: Config, integration: IntegrationLogic, optional?: boolean): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
3
|
import { UiModule, Config, UnauthorizedConfig } from '../types';
|
|
4
|
-
export default function handle(moduleConfig: UiModule, config: Config | UnauthorizedConfig): (req:
|
|
4
|
+
export default function handle(moduleConfig: UiModule, config: Config | UnauthorizedConfig): (req: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -5,4 +5,4 @@ export default function handle({ config, allowUnauthorized, moduleType, }: {
|
|
|
5
5
|
config: Config | UnauthorizedConfig;
|
|
6
6
|
allowUnauthorized?: boolean;
|
|
7
7
|
moduleType?: string | undefined;
|
|
8
|
-
}): (req:
|
|
8
|
+
}): (req: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { AiPromptProviderModule } from '../types';
|
|
5
|
-
export default function handle(aiPromptProvider: AiPromptProviderModule): (req:
|
|
5
|
+
export default function handle(aiPromptProvider: AiPromptProviderModule): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { AiProviderModule } from '../types';
|
|
5
|
-
export default function handle(aiProvider: AiProviderModule): (req:
|
|
5
|
+
export default function handle(aiProvider: AiProviderModule): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -3,4 +3,4 @@ import { Response } from 'express';
|
|
|
3
3
|
import { CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { AiProviderModule } from '../types';
|
|
5
5
|
export declare const CONTEXT_WINDOW_LIMIT = 4096;
|
|
6
|
-
export default function handle(aiProvider: AiProviderModule): (req:
|
|
6
|
+
export default function handle(aiProvider: AiProviderModule): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { CrowdinClientRequest } from '../../types';
|
|
4
4
|
import { AiRequestProcessorModule, AiStreamProcessorModule } from './types';
|
|
5
|
-
export default function handle(module: AiRequestProcessorModule | AiStreamProcessorModule, canHandleStream?: boolean): (req:
|
|
5
|
+
export default function handle(module: AiRequestProcessorModule | AiStreamProcessorModule, canHandleStream?: boolean): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { AiTool } from '../types';
|
|
5
|
-
export default function handle(aiTool: AiTool): (req:
|
|
5
|
+
export default function handle(aiTool: AiTool): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { CustomMTLogic } from '../types';
|
|
5
|
-
export default function handle(config: CustomMTLogic): (req:
|
|
5
|
+
export default function handle(config: CustomMTLogic): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { CustomSpellcheckerModule } from '../types';
|
|
5
|
-
export default function handle(customSpellchecker: CustomSpellcheckerModule): (req:
|
|
5
|
+
export default function handle(customSpellchecker: CustomSpellcheckerModule): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { CustomSpellcheckerModule } from '../types';
|
|
5
|
-
export default function handle(customSpellchecker: CustomSpellcheckerModule): (req:
|
|
5
|
+
export default function handle(customSpellchecker: CustomSpellcheckerModule): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { ExternalQaCheckModule } from '../types';
|
|
5
|
-
export default function handle(externalQaCheck: ExternalQaCheckModule): (req:
|
|
5
|
+
export default function handle(externalQaCheck: ExternalQaCheckModule): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { CustomFileFormatLogic } from '../types';
|
|
5
|
-
export default function handle(baseUrl: string, folder: string, config: CustomFileFormatLogic): (req:
|
|
5
|
+
export default function handle(baseUrl: string, folder: string, config: CustomFileFormatLogic): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
3
|
import { Config } from '../../../types';
|
|
4
4
|
import { FileProcessLogic } from '../types';
|
|
5
|
-
export default function handle(config: Config, processingConfig: FileProcessLogic, folderName: string): (req:
|
|
5
|
+
export default function handle(config: Config, processingConfig: FileProcessLogic, folderName: string): (req: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { Config, CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { FileImportExportLogic } from '../types';
|
|
5
|
-
export default function handle(baseConfig: Config, config: FileImportExportLogic, folderName: string): (req:
|
|
5
|
+
export default function handle(baseConfig: Config, config: FileImportExportLogic, folderName: string): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Config, CrowdinClientRequest } from '../types';
|
|
3
3
|
import { Response } from 'express';
|
|
4
|
-
export default function handle(config: Config): (req:
|
|
4
|
+
export default function handle(config: Config): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Config, CrowdinClientRequest } from '../types';
|
|
3
3
|
import { Response } from 'express';
|
|
4
|
-
export default function handle(config: Config): (req:
|
|
4
|
+
export default function handle(config: Config): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
package/out/modules/install.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
3
|
import { Config } from '../types';
|
|
4
|
-
export default function handle(config: Config): (req:
|
|
4
|
+
export default function handle(config: Config): (req: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { IntegrationLogic } from '../types';
|
|
5
|
-
export default function handle(integration: IntegrationLogic): (req:
|
|
5
|
+
export default function handle(integration: IntegrationLogic): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { Config } from '../../../types';
|
|
4
4
|
import { IntegrationLogic } from '../types';
|
|
5
|
-
export default function handle(config: Config, integration: IntegrationLogic): (req: import("
|
|
5
|
+
export default function handle(config: Config, integration: IntegrationLogic): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { CrowdinClientRequest } from '../../../types';
|
|
4
|
-
export default function handle(): (req:
|
|
4
|
+
export default function handle(): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { Config } from '../../../types';
|
|
4
4
|
import { IntegrationLogic } from '../types';
|
|
5
|
-
export default function handle(config: Config, integration: IntegrationLogic): (req: import("
|
|
5
|
+
export default function handle(config: Config, integration: IntegrationLogic): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
3
|
import { Config } from '../../../types';
|
|
4
4
|
import { IntegrationLogic } from '../types';
|
|
5
|
-
export default function handle(config: Config, integration: IntegrationLogic): (req:
|
|
5
|
+
export default function handle(config: Config, integration: IntegrationLogic): (req: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { IntegrationLogic } from '../types';
|
|
4
|
-
export default function handle(integration: IntegrationLogic): (req: import("
|
|
4
|
+
export default function handle(integration: IntegrationLogic): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { Config, CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { IntegrationLogic } from '../types';
|
|
5
|
-
export default function handle(config: Config, integration: IntegrationLogic): (req:
|
|
5
|
+
export default function handle(config: Config, integration: IntegrationLogic): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { Config } from '../../../types';
|
|
4
4
|
import { IntegrationLogic } from '../types';
|
|
5
|
-
export default function handle(config: Config, integration: IntegrationLogic): (req: import("
|
|
5
|
+
export default function handle(config: Config, integration: IntegrationLogic): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { Config } from '../../../types';
|
|
4
4
|
import { IntegrationLogic } from '../types';
|
|
5
|
-
export default function handle(config: Config, integration: IntegrationLogic): (req: import("
|
|
5
|
+
export default function handle(config: Config, integration: IntegrationLogic): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
3
|
import { Config } from '../../../types';
|
|
4
4
|
import { IntegrationLogic } from '../types';
|
|
5
|
-
export default function handle(config: Config, integration: IntegrationLogic): (req:
|
|
5
|
+
export default function handle(config: Config, integration: IntegrationLogic): (req: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
export default function handle(): (req: import("
|
|
3
|
+
export default function handle(): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
export default function handle(): (req: import("
|
|
3
|
+
export default function handle(): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { Config } from '../../../types';
|
|
4
|
-
export default function handle(config: Config): (req: import("
|
|
4
|
+
export default function handle(config: Config): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { Config } from '../../../types';
|
|
4
4
|
import { IntegrationLogic } from '../types';
|
|
5
|
-
export default function handle(config: Config, integration: IntegrationLogic): (req: import("
|
|
5
|
+
export default function handle(config: Config, integration: IntegrationLogic): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
3
|
import { Config } from '../../../types';
|
|
4
4
|
import { IntegrationLogic } from '../types';
|
|
5
|
-
export default function handle(config: Config, integration: IntegrationLogic): (req:
|
|
5
|
+
export default function handle(config: Config, integration: IntegrationLogic): (req: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { IntegrationLogic } from '../types';
|
|
5
|
-
export default function handle(integration: IntegrationLogic): (req:
|
|
5
|
+
export default function handle(integration: IntegrationLogic): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { Config, CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { IntegrationLogic } from '../types';
|
|
5
|
-
export default function handle(config: Config, integration: IntegrationLogic): (req:
|
|
5
|
+
export default function handle(config: Config, integration: IntegrationLogic): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { Config } from '../../../types';
|
|
4
4
|
import { IntegrationLogic } from '../types';
|
|
5
|
-
export default function handle(config: Config, integration: IntegrationLogic): (req: import("
|
|
5
|
+
export default function handle(config: Config, integration: IntegrationLogic): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
export default function handle(): (req: import("
|
|
3
|
+
export default function handle(): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { Config } from '../../../types';
|
|
4
4
|
import { IntegrationLogic } from '../types';
|
|
5
|
-
export default function handle(config: Config, integration: IntegrationLogic): (req: import("
|
|
5
|
+
export default function handle(config: Config, integration: IntegrationLogic): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
export default function handle(): (req: import("
|
|
3
|
+
export default function handle(): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
export default function handle(): (req: import("
|
|
3
|
+
export default function handle(): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import Crowdin, { UsersModel } from '@crowdin/crowdin-api-client';
|
|
3
3
|
import { Response } from 'express';
|
|
4
4
|
export type ProjectMember = UsersModel.ProjectMember | UsersModel.EnterpriseProjectMember;
|
|
5
|
-
export default function handle(): (req: import("
|
|
5
|
+
export default function handle(): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
6
6
|
export declare function isManager({ client, projectId, memberId, }: {
|
|
7
7
|
client: Crowdin;
|
|
8
8
|
projectId: number;
|
|
@@ -70,9 +70,10 @@ const cron_1 = require("./util/cron");
|
|
|
70
70
|
const storage_1 = require("../../storage");
|
|
71
71
|
function register({ config, app }) {
|
|
72
72
|
var _a, _b, _c;
|
|
73
|
+
let cronExecutions = {};
|
|
73
74
|
const integrationLogic = config.projectIntegration;
|
|
74
75
|
if (!integrationLogic) {
|
|
75
|
-
return;
|
|
76
|
+
return { cronExecutions };
|
|
76
77
|
}
|
|
77
78
|
(0, defaults_1.applyIntegrationModuleDefaults)(config, integrationLogic);
|
|
78
79
|
app.get((0, util_1.getLogoUrl)(integrationLogic, '/integration'), (0, static_files_1.serveFile)(config, integrationLogic.imagePath || config.imagePath));
|
|
@@ -207,7 +208,14 @@ function register({ config, app }) {
|
|
|
207
208
|
cron.schedule('0 0 1 * *', () => (0, cron_1.removeFinishedJobs)());
|
|
208
209
|
})
|
|
209
210
|
.catch(() => {
|
|
210
|
-
// node-cron not available (e.g., Cloudflare Workers)
|
|
211
|
+
// node-cron not available (e.g., Cloudflare Workers), delegating to external cron handler
|
|
212
|
+
cronExecutions = {
|
|
213
|
+
'0 * * * *': (0, cron_1.filesCron)({ config, integration: integrationLogic, period: '1' }).catch(console.error),
|
|
214
|
+
'0 */3 * * *': (0, cron_1.filesCron)({ config, integration: integrationLogic, period: '3' }).catch(console.error),
|
|
215
|
+
'0 */6 * * *': (0, cron_1.filesCron)({ config, integration: integrationLogic, period: '6' }).catch(console.error),
|
|
216
|
+
'0 */12 * * *': (0, cron_1.filesCron)({ config, integration: integrationLogic, period: '12' }).catch(console.error),
|
|
217
|
+
'0 0 * * *': (0, cron_1.filesCron)({ config, integration: integrationLogic, period: '24' }).catch(console.error),
|
|
218
|
+
};
|
|
211
219
|
});
|
|
212
220
|
if (integrationLogic.webhooks) {
|
|
213
221
|
app.post(`${integrationLogic.webhooks.crowdinWebhookUrl
|
|
@@ -245,5 +253,6 @@ function register({ config, app }) {
|
|
|
245
253
|
checkSubscriptionExpiration: true,
|
|
246
254
|
moduleKey: integrationLogic.key,
|
|
247
255
|
}), (0, integration_credentials_1.default)(config, integrationLogic), (0, invite_users_1.default)());
|
|
256
|
+
return { cronExecutions };
|
|
248
257
|
}
|
|
249
258
|
exports.register = register;
|
package/out/modules/status.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
3
|
import { Config, UnauthorizedConfig } from '../types';
|
|
4
|
-
export default function handle(config: Config | UnauthorizedConfig): (req:
|
|
4
|
+
export default function handle(config: Config | UnauthorizedConfig): (req: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
|
-
export default function handle(): (req:
|
|
3
|
+
export default function handle(): (req: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
3
|
import { Config } from '../types';
|
|
4
|
-
export default function handle(config: Config): (req:
|
|
4
|
+
export default function handle(config: Config): (req: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Config, CrowdinClientRequest } from '../../../types';
|
|
3
3
|
import { Response } from 'express';
|
|
4
4
|
import { Webhook } from '../types';
|
|
5
|
-
export declare function webhookHandler(config: Config, webhooks: Webhook[]): (req:
|
|
5
|
+
export declare function webhookHandler(config: Config, webhooks: Webhook[]): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { WorkflowStepTypeModule } from '../types';
|
|
5
|
-
export default function handle(workflowStep: WorkflowStepTypeModule): (req:
|
|
5
|
+
export default function handle(workflowStep: WorkflowStepTypeModule): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { WorkflowStepTypeModule } from '../types';
|
|
5
|
-
export default function handle(workflowStep: WorkflowStepTypeModule): (req:
|
|
5
|
+
export default function handle(workflowStep: WorkflowStepTypeModule): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
package/out/types.d.ts
CHANGED
|
@@ -278,7 +278,7 @@ export interface Environments {
|
|
|
278
278
|
}
|
|
279
279
|
type Environment = 'crowdin' | 'crowdin-enterprise';
|
|
280
280
|
export type Config = ClientConfig & {
|
|
281
|
-
baseUrl
|
|
281
|
+
baseUrl?: string;
|
|
282
282
|
clientId: string;
|
|
283
283
|
clientSecret: string;
|
|
284
284
|
port: number;
|
|
@@ -402,6 +402,7 @@ export interface CrowdinAppUtilities extends CrowdinMetadataStore {
|
|
|
402
402
|
extra: Record<string, any>;
|
|
403
403
|
}>;
|
|
404
404
|
storage: Storage;
|
|
405
|
+
cronExecutions?: Record<string, () => Promise<void>>;
|
|
405
406
|
}
|
|
406
407
|
export interface CrowdinMetadataStore {
|
|
407
408
|
saveMetadata: (id: string, metadata: any, crowdinId: string) => Promise<void>;
|
|
@@ -6,5 +6,5 @@ declare function getRequestCredentialsMasker({ moduleConfig, dataPath, }: {
|
|
|
6
6
|
moduleConfig?: UiModule;
|
|
7
7
|
dataPath?: string;
|
|
8
8
|
}): (req: Request | CrowdinClientRequest, res: Response, next: Function) => any;
|
|
9
|
-
declare function postRequestCredentialsMasker(moduleConfig?: UiModule, credentialsExtractor?: Function): (req:
|
|
9
|
+
declare function postRequestCredentialsMasker(moduleConfig?: UiModule, credentialsExtractor?: Function): (req: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
10
10
|
export { getRequestCredentialsMasker, postRequestCredentialsMasker, maskKey };
|
package/out/util/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare class CodeError extends Error {
|
|
|
5
5
|
code: number | undefined;
|
|
6
6
|
constructor(message: string, code?: number);
|
|
7
7
|
}
|
|
8
|
+
export declare function extractBaseUrlFromRequest(req: Request): string;
|
|
8
9
|
export declare function runAsyncWrapper(callback: Function): (req: Request | CrowdinClientRequest, res: Response, next: Function) => void;
|
|
9
10
|
export declare function encryptData(config: Config, data: string): string;
|
|
10
11
|
export declare function decryptData(config: Config, data: string): string;
|
package/out/util/index.js
CHANGED
|
@@ -32,7 +32,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.getFormattedDate = exports.validateEmail = exports.prepareFormDataMetadataId = exports.getPreviousDate = exports.isJson = exports.isAuthorizedConfig = exports.getLogoUrl = exports.executeWithRetry = exports.decryptData = exports.encryptData = exports.runAsyncWrapper = exports.CodeError = exports.renderJSX = void 0;
|
|
35
|
+
exports.getFormattedDate = exports.validateEmail = exports.prepareFormDataMetadataId = exports.getPreviousDate = exports.isJson = exports.isAuthorizedConfig = exports.getLogoUrl = exports.executeWithRetry = exports.decryptData = exports.encryptData = exports.runAsyncWrapper = exports.extractBaseUrlFromRequest = exports.CodeError = exports.renderJSX = void 0;
|
|
36
36
|
const crypto = __importStar(require("crypto-js"));
|
|
37
37
|
const storage_1 = require("../storage");
|
|
38
38
|
const types_1 = require("../types");
|
|
@@ -49,6 +49,12 @@ class CodeError extends Error {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
exports.CodeError = CodeError;
|
|
52
|
+
function extractBaseUrlFromRequest(req) {
|
|
53
|
+
const protocol = req.protocol;
|
|
54
|
+
const host = req.get('host');
|
|
55
|
+
return `${protocol}://${host}`;
|
|
56
|
+
}
|
|
57
|
+
exports.extractBaseUrlFromRequest = extractBaseUrlFromRequest;
|
|
52
58
|
function isCrowdinClientRequest(req) {
|
|
53
59
|
return req.crowdinContext;
|
|
54
60
|
}
|
package/out/util/static-files.js
CHANGED
|
@@ -22,10 +22,10 @@ const path_1 = __importDefault(require("path"));
|
|
|
22
22
|
/**
|
|
23
23
|
* Proxy Workers Assets response to Express response
|
|
24
24
|
*/
|
|
25
|
-
function proxyAssetsResponse(fetcher, assetPath, req, res, next) {
|
|
25
|
+
function proxyAssetsResponse(fetcher, assetPath, baseUrl, req, res, next) {
|
|
26
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
try {
|
|
28
|
-
const assetUrl = new URL(assetPath,
|
|
28
|
+
const assetUrl = new URL(assetPath, baseUrl);
|
|
29
29
|
const response = yield fetcher.fetch(assetUrl.toString());
|
|
30
30
|
if (!response.ok) {
|
|
31
31
|
return next();
|
|
@@ -52,7 +52,7 @@ function serveStatic(config, staticPath) {
|
|
|
52
52
|
const assetsFetcher = config.assets;
|
|
53
53
|
return (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
54
54
|
const assetPath = staticPath.startsWith('/') ? `${staticPath}${req.path}` : `/${staticPath}${req.path}`;
|
|
55
|
-
yield proxyAssetsResponse(assetsFetcher, assetPath, req, res, next);
|
|
55
|
+
yield proxyAssetsResponse(assetsFetcher, assetPath, config.baseUrl, req, res, next);
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
const absolutePath = path_1.default.isAbsolute(staticPath) ? staticPath : path_1.default.join(__dirname, staticPath);
|
|
@@ -69,7 +69,7 @@ function serveFile(config, filePath) {
|
|
|
69
69
|
if (config.assets) {
|
|
70
70
|
const assetsFetcher = config.assets;
|
|
71
71
|
const assetPath = filePath.startsWith('/') ? filePath : `/${filePath}`;
|
|
72
|
-
yield proxyAssetsResponse(assetsFetcher, assetPath, req, res, next);
|
|
72
|
+
yield proxyAssetsResponse(assetsFetcher, assetPath, config.baseUrl, req, res, next);
|
|
73
73
|
}
|
|
74
74
|
else {
|
|
75
75
|
const absolutePath = path_1.default.isAbsolute(filePath) ? filePath : path_1.default.join(__dirname, filePath);
|
package/package.json
CHANGED