@crowdin/app-project-module 0.12.1 → 0.12.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/README.md CHANGED
@@ -591,6 +591,7 @@ const configuration = {
591
591
  dbFolder: __dirname,
592
592
  imagePath: __dirname + '/' + 'logo.png',
593
593
  reports: { //can be editorPanels, projectMenu, tools
594
+ imagePath: __dirname + '/' + 'reports.png',
594
595
  fileName: 'reports.html', //optional, only needed if file is not index.html
595
596
  uiPath: __dirname + '/' + 'public' // folder where UI of the module is located (js, html, css files)
596
597
  },
@@ -2,13 +2,26 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  function handle(config) {
4
4
  const modules = {};
5
+ // TEMPORARY CODE drop on step 3 of CN-30453
5
6
  if (config.integration) {
6
7
  modules.integrations = [
7
8
  {
8
9
  key: config.identifier + '-int',
9
10
  name: config.name,
10
11
  description: config.description,
11
- logo: '/logo.png',
12
+ logo: '/logo/integration/logo.png',
13
+ url: '/',
14
+ },
15
+ ];
16
+ }
17
+ // END OF TEMPORARY CODE
18
+ if (config.projectIntegration) {
19
+ modules['project-integrations'] = [
20
+ {
21
+ key: config.identifier + '-int',
22
+ name: config.name,
23
+ description: config.description,
24
+ logo: '/logo/integration/logo.png',
12
25
  url: '/',
13
26
  },
14
27
  ];
@@ -32,13 +45,14 @@ function handle(config) {
32
45
  },
33
46
  ];
34
47
  }
48
+ // TEMPORARY CODE drop on step 3 of CN-30453
35
49
  if (config.resources) {
36
50
  modules['organization-menu'] = [
37
51
  {
38
52
  key: config.identifier + '-resources',
39
53
  name: config.name,
40
54
  url: '/resources/' + (config.resources.fileName || 'index.html'),
41
- icon: '/logo.png',
55
+ icon: '/logo/resources/logo.png',
42
56
  },
43
57
  ];
44
58
  modules['resources'] = [
@@ -46,10 +60,32 @@ function handle(config) {
46
60
  key: config.identifier + '-resources',
47
61
  name: config.name,
48
62
  url: '/resources/' + (config.resources.fileName || 'index.html'),
49
- icon: '/logo.png',
63
+ icon: '/logo/resources/logo.png',
64
+ },
65
+ ];
66
+ }
67
+ // END OF TEMPORARY CODE
68
+ if (config.organizationMenu) {
69
+ modules['organization-menu'] = [
70
+ {
71
+ key: config.identifier + '-resources',
72
+ name: config.name,
73
+ url: '/resources/' + (config.organizationMenu.fileName || 'index.html'),
74
+ icon: '/logo/resources/logo.png',
75
+ },
76
+ ];
77
+ }
78
+ if (config.profileResourcesMenu) {
79
+ modules['profile-resources-menu'] = [
80
+ {
81
+ key: config.identifier + '-profile-resources-menu',
82
+ name: config.name,
83
+ url: '/resources/' + (config.profileResourcesMenu.fileName || 'index.html'),
84
+ icon: '/logo/resources/logo.png',
50
85
  },
51
86
  ];
52
87
  }
88
+ // TEMPORARY CODE drop on step 3 of CN-30453
53
89
  if (config.editorPanels) {
54
90
  modules['editor-panels'] = [
55
91
  {
@@ -61,6 +97,17 @@ function handle(config) {
61
97
  },
62
98
  ];
63
99
  }
100
+ // END OF TEMPORARY CODE
101
+ if (config.editorRightPanel) {
102
+ modules['editor-right-panel'] = [
103
+ {
104
+ key: config.identifier + '-editor-panels',
105
+ name: config.name,
106
+ url: '/editor-panels/' + (config.editorRightPanel.fileName || 'index.html'),
107
+ modes: config.editorRightPanel.modes,
108
+ },
109
+ ];
110
+ }
64
111
  if (config.projectMenu) {
65
112
  modules['project-menu'] = [
66
113
  {
@@ -70,28 +117,54 @@ function handle(config) {
70
117
  },
71
118
  ];
72
119
  }
120
+ // TEMPORARY CODE drop on step 3 of CN-30453
73
121
  if (config.tools) {
74
122
  modules['tools'] = [
75
123
  {
76
124
  key: config.identifier + '-tools',
77
125
  name: config.name,
78
126
  description: config.description,
79
- logo: '/logo.png',
80
- icon: '/logo.png',
127
+ logo: '/logo/tools/logo.png',
81
128
  url: '/tools/' + (config.tools.fileName || 'index.html'),
82
129
  },
83
130
  ];
84
131
  }
132
+ // END OF TEMPORARY CODE
133
+ if (config.projectTools) {
134
+ modules['project-tools'] = [
135
+ {
136
+ key: config.identifier + '-tools',
137
+ name: config.name,
138
+ description: config.description,
139
+ logo: '/logo/tools/logo.png',
140
+ url: '/tools/' + (config.projectTools.fileName || 'index.html'),
141
+ },
142
+ ];
143
+ }
144
+ // TEMPORARY CODE drop on step 3 of CN-30453
85
145
  if (config.reports) {
86
146
  modules['reports'] = [
87
147
  {
88
148
  key: config.identifier + '-reports',
89
149
  name: config.name,
90
150
  description: config.description,
151
+ logo: '/logo/reports/logo.png',
91
152
  url: '/reports/' + (config.reports.fileName || 'index.html'),
92
153
  },
93
154
  ];
94
155
  }
156
+ // END OF TEMPORARY CODE
157
+ if (config.projectReports) {
158
+ modules['project-reports'] = [
159
+ {
160
+ key: config.identifier + '-project-reports',
161
+ name: config.name,
162
+ description: config.description,
163
+ logo: '/logo/reports/logo.png',
164
+ url: '/reports/' + (config.projectReports.fileName || 'index.html'),
165
+ },
166
+ ];
167
+ }
95
168
  return (_req, res) => {
96
169
  const manifest = {
97
170
  identifier: config.identifier,
package/out/index.js CHANGED
@@ -88,9 +88,10 @@ function addCrowdinEndpoints(app, config) {
88
88
  app.post('/installed', (0, install_1.default)(config));
89
89
  app.post('/uninstall', (0, uninstall_1.default)(config));
90
90
  app.get('/manifest.json', json_response_1.default, (0, manifest_1.default)(config));
91
- const integrationLogic = config.integration;
91
+ const integrationLogic = config.integration || config.projectIntegration;
92
92
  if (integrationLogic) {
93
93
  (0, util_1.applyDefaults)(config, integrationLogic);
94
+ app.get('/logo/integration/logo.png', (req, res) => res.sendFile(integrationLogic.imagePath || config.imagePath || (0, path_1.join)(__dirname, 'logo.png')));
94
95
  app.get('/', (0, crowdin_client_1.default)(config, true), (0, integration_credentials_1.default)(config, integrationLogic, true), (0, main_1.default)(config, integrationLogic));
95
96
  app.post('/api/settings', (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, settings_save_1.default)(config));
96
97
  app.post('/api/login', (0, crowdin_client_1.default)(config), (0, integration_login_1.default)(config, integrationLogic));
@@ -126,21 +127,51 @@ function addCrowdinEndpoints(app, config) {
126
127
  if (config.customMT) {
127
128
  app.post('/translate', (0, crowdin_client_1.default)(config), (0, translate_1.default)(config, config.customMT));
128
129
  }
130
+ // TEMPORARY CODE drop on step 3 of CN-30453
129
131
  if (config.resources) {
132
+ app.get('/logo/resources/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.resources) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath || (0, path_1.join)(__dirname, 'logo.png')); });
130
133
  app.use('/resources', express_1.default.static(config.resources.uiPath));
131
134
  }
135
+ // END OF TEMPORARY CODE
136
+ if (config.profileResourcesMenu) {
137
+ app.get('/logo/resources/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.profileResourcesMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath || (0, path_1.join)(__dirname, 'logo.png')); });
138
+ app.use('/resources', express_1.default.static(config.profileResourcesMenu.uiPath));
139
+ }
140
+ if (config.organizationMenu) {
141
+ app.get('/logo/resources/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.organizationMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath || (0, path_1.join)(__dirname, 'logo.png')); });
142
+ app.use('/resources', express_1.default.static(config.organizationMenu.uiPath));
143
+ }
144
+ // TEMPORARY CODE drop on step 3 of CN-30453
132
145
  if (config.editorPanels) {
133
146
  app.use('/editor-panels', express_1.default.static(config.editorPanels.uiPath));
134
147
  }
148
+ // END OF TEMPORARY CODE
149
+ if (config.editorRightPanel) {
150
+ app.use('/editor-panels', express_1.default.static(config.editorRightPanel.uiPath));
151
+ }
135
152
  if (config.projectMenu) {
136
153
  app.use('/project-menu', express_1.default.static(config.projectMenu.uiPath));
137
154
  }
155
+ // TEMPORARY CODE drop on step 3 of CN-30453
138
156
  if (config.tools) {
157
+ app.get('/logo/tools/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.tools) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath || (0, path_1.join)(__dirname, 'logo.png')); });
139
158
  app.use('/tools', express_1.default.static(config.tools.uiPath));
140
159
  }
160
+ // END OF TEMPORARY CODE
161
+ if (config.projectTools) {
162
+ app.get('/logo/tools/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.projectTools) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath || (0, path_1.join)(__dirname, 'logo.png')); });
163
+ app.use('/tools', express_1.default.static(config.projectTools.uiPath));
164
+ }
165
+ // TEMPORARY CODE drop on step 3 of CN-30453
141
166
  if (config.reports) {
167
+ app.get('/logo/reports/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.reports) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath || (0, path_1.join)(__dirname, 'logo.png')); });
142
168
  app.use('/reports', express_1.default.static(config.reports.uiPath));
143
169
  }
170
+ // END OF TEMPORARY CODE
171
+ if (config.projectReports) {
172
+ 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')); });
173
+ app.use('/reports', express_1.default.static(config.projectReports.uiPath));
174
+ }
144
175
  return {
145
176
  getMetadata: storage.getMetadata,
146
177
  saveMetadata: (id, metadata) => __awaiter(this, void 0, void 0, function* () {
@@ -1,7 +1,7 @@
1
1
  import Crowdin, { LanguagesModel, SourceFilesModel, SourceStringsModel } from '@crowdin/crowdin-api-client';
2
2
  import { JwtPayload } from '@crowdin/crowdin-apps-functions';
3
3
  import { Request } from 'express';
4
- export interface Config {
4
+ export interface Config extends ImagePath {
5
5
  /**
6
6
  * client id that we received when registering the app
7
7
  */
@@ -35,13 +35,13 @@ export interface Config {
35
35
  */
36
36
  dbFolder: string;
37
37
  /**
38
- * path to app logo (e.g. {@example join(__dirname, 'logo.png')})
38
+ * integration module logic
39
39
  */
40
- imagePath?: string;
40
+ integration?: IntegrationLogic & ImagePath;
41
41
  /**
42
42
  * integration module logic
43
43
  */
44
- integration?: IntegrationLogic;
44
+ projectIntegration?: IntegrationLogic & ImagePath;
45
45
  /**
46
46
  * custom file format module logic
47
47
  */
@@ -53,11 +53,23 @@ export interface Config {
53
53
  /**
54
54
  * resources module
55
55
  */
56
- resources?: UiModule;
56
+ resources?: UiModule & ImagePath;
57
+ /**
58
+ * resources module
59
+ */
60
+ profileResourcesMenu?: UiModule & ImagePath;
61
+ /**
62
+ * organization-menu module
63
+ */
64
+ organizationMenu?: UiModule & ImagePath;
57
65
  /**
58
66
  * editor-panels module
59
67
  */
60
68
  editorPanels?: EditorPanels;
69
+ /**
70
+ * editor-right-panel module
71
+ */
72
+ editorRightPanel?: EditorPanels;
61
73
  /**
62
74
  * project menu module
63
75
  */
@@ -65,11 +77,19 @@ export interface Config {
65
77
  /**
66
78
  * tools module
67
79
  */
68
- tools?: UiModule;
80
+ tools?: UiModule & ImagePath;
81
+ /**
82
+ * tools module
83
+ */
84
+ projectTools?: UiModule & ImagePath;
85
+ /**
86
+ * reports module
87
+ */
88
+ reports?: UiModule & ImagePath;
69
89
  /**
70
90
  * reports module
71
91
  */
72
- reports?: UiModule;
92
+ projectReports?: UiModule & ImagePath;
73
93
  /**
74
94
  * Uninstall hook for cleanup logic
75
95
  */
@@ -439,3 +459,10 @@ export interface IntegrationSyncSettings {
439
459
  crowdinId: string;
440
460
  provider: string;
441
461
  }
462
+ interface ImagePath {
463
+ /**
464
+ * path to app logo (e.g. {@example join(__dirname, 'logo.png')})
465
+ */
466
+ imagePath?: string;
467
+ }
468
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
4
4
  "description": "Module that generates for you all common endpoints for serving standalone Crowdin App",
5
5
  "main": "out/index.js",
6
6
  "types": "out/index.d.ts",