@crowdin/app-project-module 0.28.0-8 → 0.28.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.
@@ -26,7 +26,7 @@ function handle(config, integration) {
26
26
  return res.status(200).send({ message: 'Sync is not configured' });
27
27
  }
28
28
  if ((_b = integration.webhooks) === null || _b === void 0 ? void 0 : _b.crowdinWebhookInterceptor) {
29
- filesToSync = yield integration.webhooks.crowdinWebhookInterceptor(projectId, crowdinClient.client, rootFolder, appSettings, syncSettings, req.body);
29
+ filesToSync = yield integration.webhooks.crowdinWebhookInterceptor(projectId, crowdinClient.client, rootFolder, appSettings, syncSettings);
30
30
  }
31
31
  else {
32
32
  filesToSync = (0, webhooks_1.filterSyncFiles)(req.body.events, JSON.parse(syncSettings.files));
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
5
  }) : (function(o, m, k, k2) {
10
6
  if (k2 === undefined) k2 = k;
11
7
  o[k2] = m[k];
@@ -39,7 +35,7 @@ function handle() {
39
35
  const id = req.query.id;
40
36
  const data = (yield storage.getStorage().getMetadata(id)) || {};
41
37
  return res.send({
42
- formData: data,
38
+ data,
43
39
  });
44
40
  }));
45
41
  }
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
5
  }) : (function(o, m, k, k2) {
10
6
  if (k2 === undefined) k2 = k;
11
7
  o[k2] = m[k];
package/out/index.js CHANGED
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
5
  }) : (function(o, m, k, k2) {
10
6
  if (k2 === undefined) k2 = k;
11
7
  o[k2] = m[k];
@@ -131,6 +127,8 @@ function addCrowdinEndpoints(app, plainConfig) {
131
127
  app.get('/', (0, crowdin_client_1.default)(config, true, false), (0, integration_credentials_1.default)(config, integrationLogic, true), (0, main_1.default)(config, integrationLogic));
132
128
  app.get('/api/subscription-info', json_response_1.default, (0, crowdin_client_1.default)(config), (0, subscription_info_1.default)(config));
133
129
  app.post('/api/settings', (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, settings_save_1.default)(config, integrationLogic));
130
+ app.get('/api/form-data', json_response_1.default, (0, crowdin_client_1.default)(config), (0, form_data_display_1.default)());
131
+ app.post('/api/form-data', (0, crowdin_client_1.default)(config), (0, form_data_save_1.default)());
134
132
  app.post('/api/login', (0, crowdin_client_1.default)(config, false, false), (0, integration_login_1.default)(config, integrationLogic));
135
133
  app.post('/api/logout', (0, crowdin_client_1.default)(config, false, false), (0, integration_credentials_1.default)(config, integrationLogic), (0, integration_logout_1.default)(config, integrationLogic));
136
134
  app.get('/api/crowdin/files', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, crowdin_files_1.default)(config, integrationLogic));
@@ -167,7 +165,7 @@ function addCrowdinEndpoints(app, plainConfig) {
167
165
  : '/api/integration/webhook'}`, (0, integration_webhook_1.default)(config, integrationLogic));
168
166
  }
169
167
  if ((_c = integrationLogic.webhooks) === null || _c === void 0 ? void 0 : _c.queueUrl) {
170
- (0, webhooks_1.listenQueueMessage)(config, integrationLogic, integrationLogic.webhooks.queueUrl, config.identifier);
168
+ (0, webhooks_1.listenQueueMessage)(config, integrationLogic, integrationLogic.webhooks.queueUrl, config.name);
171
169
  }
172
170
  }
173
171
  }
@@ -204,13 +202,6 @@ function addCrowdinEndpoints(app, plainConfig) {
204
202
  app.get('/logo/reports/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.projectReports) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath || (0, path_1.join)(__dirname, 'logo.png')); });
205
203
  app.use('/reports', (0, ui_module_1.default)(config, config.projectReports.allowUnauthorized), (0, render_ui_module_1.default)(config, config.projectReports));
206
204
  }
207
- if (Object.keys(config).some((moduleKey) => {
208
- const moduleConfig = config[moduleKey];
209
- return typeof moduleConfig === 'object' && moduleConfig.hasOwnProperty('formSchema');
210
- })) {
211
- app.get('/api/form-data', json_response_1.default, (0, crowdin_client_1.default)(config), (0, form_data_display_1.default)());
212
- app.post('/api/form-data', (0, crowdin_client_1.default)(config), (0, form_data_save_1.default)());
213
- }
214
205
  return {
215
206
  getMetadata: storage.getStorage().getMetadata.bind(storage.getStorage()),
216
207
  saveMetadata: (id, metadata) => __awaiter(this, void 0, void 0, function* () {
@@ -15,17 +15,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const express_1 = __importDefault(require("express"));
16
16
  const util_1 = require("../util");
17
17
  function handle(config, moduleConfig) {
18
- return (0, util_1.runAsyncWrapper)((req, res, next) => __awaiter(this, void 0, void 0, function* () {
18
+ return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
19
19
  if (moduleConfig.formSchema) {
20
20
  return res.render('form', {
21
- formGetDataUrl: moduleConfig.formGetDataUrl ? moduleConfig.formGetDataUrl : '/api/form-data',
22
- formPostDataUrl: moduleConfig.formPostDataUrl ? moduleConfig.formPostDataUrl : '/api/form-data',
21
+ formDataUrl: moduleConfig.formDataUrl ? moduleConfig.formDataUrl : '/api/form-data',
23
22
  formSchema: JSON.stringify(moduleConfig.formSchema),
24
- formUiSchema: moduleConfig.formUiSchema ? JSON.stringify(moduleConfig.formUiSchema) : '{}',
25
23
  });
26
24
  }
27
25
  if (moduleConfig.uiPath) {
28
- return express_1.default.static(moduleConfig.uiPath)(req, res, next);
26
+ return express_1.default.static(moduleConfig.uiPath);
29
27
  }
30
28
  throw new Error('uiPath or formSchema should be provided for module');
31
29
  }), config.onError);
@@ -250,7 +250,7 @@ export interface IntegrationLogic {
250
250
  */
251
251
  webhooks?: Webhooks;
252
252
  }
253
- export type FormEntity = FormField | FormDelimeter;
253
+ export declare type FormEntity = FormField | FormDelimeter;
254
254
  export interface FormDelimeter {
255
255
  label: string;
256
256
  }
@@ -403,13 +403,13 @@ export interface ExtendedResult<T> {
403
403
  message?: string;
404
404
  stopPagination?: boolean;
405
405
  }
406
- export type TreeItem = File | Folder;
406
+ export declare type TreeItem = File | Folder;
407
407
  /**
408
408
  * 0 - folder
409
409
  * 1 - file
410
410
  * 2 - branch
411
411
  */
412
- type IntegrationTreeElementType = '0' | '1' | '2';
412
+ declare type IntegrationTreeElementType = '0' | '1' | '2';
413
413
  export interface File {
414
414
  id: string;
415
415
  name: string;
@@ -602,19 +602,10 @@ export interface UiModule {
602
602
  */
603
603
  formSchema?: object;
604
604
  /**
605
- * URL to custom endpoint that can be used instead of default one to save form data.
606
- * Endpoint should accept POST requests.
605
+ * URL to custom endpoint that can be used instead of default one to save and retrieve form data.
606
+ * Endpoint should accept both POST requests for data saving and GET requests for data retrieving.
607
607
  */
608
- formPostDataUrl?: string;
609
- /**
610
- * URL to custom endpoint that can be used instead of default one to retrieve form data.
611
- * Endpoint should accept GET requests.
612
- */
613
- formGetDataUrl?: string;
614
- /**
615
- * Additional attributes for react-jsonschema-doc
616
- */
617
- formUiSchema?: object;
608
+ formDataUrl?: string;
618
609
  /**
619
610
  * path to ui folder (e.g. {@example join(__dirname, 'public')})
620
611
  */
@@ -684,8 +675,8 @@ export interface Webhooks {
684
675
  urlParam?: string;
685
676
  crowdinWebhooks?: (client: Crowdin, projectId: number, available: boolean, config?: any) => Promise<void>;
686
677
  integrationWebhooks?: (apiCredentials: any, urlParam: string, available: boolean, config?: any, syncSettings?: any) => Promise<void>;
687
- crowdinWebhookInterceptor?: (projectId: number, client: Crowdin, appRootFolder?: SourceFilesModel.Directory, config?: any, syncSettings?: any, webhookRequest?: any) => Promise<UpdateIntegrationRequest>;
688
- integrationWebhookInterceptor?: (projectId: number, client: Crowdin, apiCredentials: any, appRootFolder?: SourceFilesModel.Directory, config?: any, syncSettings?: any, webhookRequest?: any) => Promise<IntegrationFile[]>;
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[]>;
689
680
  queueUrl: string;
690
681
  }
691
682
  export declare enum SyncCondition {
@@ -698,13 +689,13 @@ export declare enum SyncType {
698
689
  SCHEDULE = 1,
699
690
  WEBHOOKS = 2
700
691
  }
701
- export type Payload = {
692
+ export declare type Payload = {
702
693
  event: string;
703
694
  projectId: string;
704
695
  language: string;
705
696
  fileId: string;
706
697
  };
707
- export type WebhookUrlParams = {
698
+ export declare type WebhookUrlParams = {
708
699
  projectId: number;
709
700
  crowdinId: string;
710
701
  clientId: string;