@crowdin/app-project-module 0.98.0-cf-1 → 0.98.0-cf-3
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
CHANGED
|
@@ -221,7 +221,7 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
221
221
|
* /util -> folder for utilities
|
|
222
222
|
* /handlers -> for http handlers
|
|
223
223
|
*/
|
|
224
|
-
integrationApp.register({ config, app });
|
|
224
|
+
const { cronExecutions } = integrationApp.register({ config, app });
|
|
225
225
|
customMTApp.register({ config, app });
|
|
226
226
|
fileProcessingApps.registerCustomFileFormat({ config, app });
|
|
227
227
|
fileProcessingApps.registerFilePreImport({ config, app });
|
|
@@ -238,7 +238,8 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
238
238
|
workflowStepType.register({ config, app });
|
|
239
239
|
aiRequestProcessors.register({ config, app });
|
|
240
240
|
addFormSchema({ config, app });
|
|
241
|
-
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) => {
|
|
242
243
|
let jwtToken = '';
|
|
243
244
|
if (typeof authRequest === 'string') {
|
|
244
245
|
jwtToken = authRequest;
|
|
@@ -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/types.d.ts
CHANGED
|
@@ -107,9 +107,9 @@ export interface ClientConfig extends ImagePath {
|
|
|
107
107
|
*/
|
|
108
108
|
d1Config?: D1StorageConfig;
|
|
109
109
|
/**
|
|
110
|
-
* Cloudflare Workers Assets
|
|
110
|
+
* Cloudflare Workers Assets configuration
|
|
111
111
|
*/
|
|
112
|
-
|
|
112
|
+
assetsConfig?: AssetsConfig;
|
|
113
113
|
/**
|
|
114
114
|
* integration module logic
|
|
115
115
|
*/
|
|
@@ -273,6 +273,12 @@ export interface ClientConfig extends ImagePath {
|
|
|
273
273
|
*/
|
|
274
274
|
restrictAiToSameApp?: boolean;
|
|
275
275
|
}
|
|
276
|
+
export interface AssetsConfig {
|
|
277
|
+
/**
|
|
278
|
+
* Cloudflare Workers Assets Fetcher
|
|
279
|
+
*/
|
|
280
|
+
fetcher: Fetcher;
|
|
281
|
+
}
|
|
276
282
|
export interface Environments {
|
|
277
283
|
environments?: Environment | Environment[];
|
|
278
284
|
}
|
|
@@ -402,6 +408,7 @@ export interface CrowdinAppUtilities extends CrowdinMetadataStore {
|
|
|
402
408
|
extra: Record<string, any>;
|
|
403
409
|
}>;
|
|
404
410
|
storage: Storage;
|
|
411
|
+
cronExecutions?: Record<string, () => Promise<void>>;
|
|
405
412
|
}
|
|
406
413
|
export interface CrowdinMetadataStore {
|
|
407
414
|
saveMetadata: (id: string, metadata: any, crowdinId: string) => Promise<void>;
|
package/out/util/static-files.js
CHANGED
|
@@ -48,8 +48,9 @@ function proxyAssetsResponse(fetcher, assetPath, baseUrl, req, res, next) {
|
|
|
48
48
|
* @param staticPath - Path to static directory
|
|
49
49
|
*/
|
|
50
50
|
function serveStatic(config, staticPath) {
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
var _a;
|
|
52
|
+
if ((_a = config.assetsConfig) === null || _a === void 0 ? void 0 : _a.fetcher) {
|
|
53
|
+
const assetsFetcher = config.assetsConfig.fetcher;
|
|
53
54
|
return (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
54
55
|
const assetPath = staticPath.startsWith('/') ? `${staticPath}${req.path}` : `/${staticPath}${req.path}`;
|
|
55
56
|
yield proxyAssetsResponse(assetsFetcher, assetPath, config.baseUrl, req, res, next);
|
|
@@ -66,8 +67,9 @@ exports.serveStatic = serveStatic;
|
|
|
66
67
|
*/
|
|
67
68
|
function serveFile(config, filePath) {
|
|
68
69
|
return (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
var _a;
|
|
71
|
+
if ((_a = config.assetsConfig) === null || _a === void 0 ? void 0 : _a.fetcher) {
|
|
72
|
+
const assetsFetcher = config.assetsConfig.fetcher;
|
|
71
73
|
const assetPath = filePath.startsWith('/') ? filePath : `/${filePath}`;
|
|
72
74
|
yield proxyAssetsResponse(assetsFetcher, assetPath, config.baseUrl, req, res, next);
|
|
73
75
|
}
|
package/package.json
CHANGED