@crowdin/app-project-module 0.98.0-cf-1 → 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
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
|
@@ -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>;
|
package/package.json
CHANGED