@crowdin/app-project-module 0.36.0 → 0.38.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.
@@ -113,6 +113,18 @@ function handle(config) {
113
113
  },
114
114
  ];
115
115
  }
116
+ if (config.editorThemes) {
117
+ modules['editor-themes'] = [
118
+ {
119
+ key: config.identifier + '-editor-themes',
120
+ name: config.editorThemes.name || config.name,
121
+ logo: (0, util_1.getLogoUrl)(config.editorThemes, '/editor-themes'),
122
+ styles: config.editorThemes.styles,
123
+ modes: config.editorThemes.modes,
124
+ environments: config.editorThemes.environments,
125
+ },
126
+ ];
127
+ }
116
128
  if (config.projectMenu) {
117
129
  modules['project-menu'] = [
118
130
  {
package/out/index.js CHANGED
@@ -225,6 +225,9 @@ function addCrowdinEndpoints(app, clientConfig) {
225
225
  if (config.editorRightPanel) {
226
226
  app.use('/editor-panels', (0, ui_module_1.default)(config, config.editorRightPanel.allowUnauthorized), (0, render_ui_module_1.default)(config.editorRightPanel));
227
227
  }
228
+ if (config.editorThemes) {
229
+ app.get((0, util_1.getLogoUrl)(config.editorThemes, '/editor-themes'), (req, res) => { var _a; return res.sendFile(((_a = config.editorThemes) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
230
+ }
228
231
  if (config.projectMenu) {
229
232
  app.use('/project-menu', (0, ui_module_1.default)(config, config.projectMenu.allowUnauthorized), (0, render_ui_module_1.default)(config.projectMenu));
230
233
  }
@@ -36,7 +36,7 @@ function prepareCrowdinRequest(jwtToken, config, optional = false, checkSubscrip
36
36
  throw new Error("Can't find organization by id");
37
37
  }
38
38
  logInfo('Building crowdin client instance');
39
- const { client, token } = yield (0, connection_1.prepareCrowdinClient)({ config, credentials, autoRenew: true });
39
+ const { client, token } = yield (0, connection_1.prepareCrowdinClient)({ config, credentials, autoRenew: true, context });
40
40
  let subscriptionInfo;
41
41
  if (checkSubscriptionExpiration) {
42
42
  subscriptionInfo = yield (0, connection_1.checkSubscription)({
@@ -27,18 +27,19 @@ function handle(config, allowUnauthorized = false) {
27
27
  (0, logger_1.log)('Validating jwt token from incoming request');
28
28
  const jwtPayload = yield (0, crowdin_apps_functions_1.validateJwtToken)(jwtToken, config.clientSecret, config.jwtValidationOptions);
29
29
  const id = `${jwtPayload.domain || jwtPayload.context.organization_id}`;
30
- const logInfo = (0, logger_1.withContext)({
30
+ const context = {
31
31
  jwtPayload,
32
32
  clientId: (0, crowdin_apps_functions_1.constructCrowdinIdFromJwtPayload)(jwtPayload),
33
33
  crowdinId: id,
34
- });
34
+ };
35
+ const logInfo = (0, logger_1.withContext)(context);
35
36
  logInfo('Loading crowdin credentials');
36
37
  const credentials = yield (0, storage_1.getStorage)().getCrowdinCredentials(id);
37
38
  if (!credentials) {
38
39
  throw new Error("Can't find organization by id");
39
40
  }
40
41
  logInfo('Building crowdin client instance');
41
- const { token } = yield (0, connection_1.prepareCrowdinClient)({ config, credentials });
42
+ const { token } = yield (0, connection_1.prepareCrowdinClient)({ config, credentials, context });
42
43
  const { expired, subscribeLink } = yield (0, connection_1.checkSubscription)({
43
44
  config,
44
45
  token,
@@ -94,6 +94,10 @@ export interface ClientConfig extends ImagePath {
94
94
  * editor-right-panel module
95
95
  */
96
96
  editorRightPanel?: EditorPanels & Environments;
97
+ /**
98
+ * editor-themes module
99
+ */
100
+ editorThemes?: EditorThemes & ImagePath & Environments;
97
101
  /**
98
102
  * project menu module
99
103
  */
@@ -754,9 +758,25 @@ export interface EditorPanels extends UiModule {
754
758
  /**
755
759
  * The Editor's mode list where the module will be available.
756
760
  */
757
- modes: EditorPanelsMode[];
761
+ modes: EditorMode[];
762
+ }
763
+ export interface EditorThemes {
764
+ /**
765
+ * Module name
766
+ */
767
+ name?: string;
768
+ /**
769
+ * Defines a set of CSS custom variables for theming purposes
770
+ */
771
+ styles: {
772
+ [key: string]: string;
773
+ };
774
+ /**
775
+ * The Editor's mode list where the module will be available.
776
+ */
777
+ modes: EditorMode[];
758
778
  }
759
- export declare enum EditorPanelsMode {
779
+ export declare enum EditorMode {
760
780
  ASSETS = "assets",
761
781
  REVIEW = "review",
762
782
  TRANSLATE = "TRANSLATE",
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProjectPermissions = exports.UserPermissions = exports.SyncSchedule = exports.SyncCondition = exports.RequestMethods = exports.Provider = exports.ContextOptionsTypes = exports.ContextOptionsLocations = exports.EditorPanelsMode = exports.ProcessFileJobType = exports.SubscriptionInfoType = exports.AccountType = exports.Scope = exports.AuthenticationType = void 0;
3
+ exports.ProjectPermissions = exports.UserPermissions = exports.SyncSchedule = exports.SyncCondition = exports.RequestMethods = exports.Provider = exports.ContextOptionsTypes = exports.ContextOptionsLocations = exports.EditorMode = exports.ProcessFileJobType = exports.SubscriptionInfoType = exports.AccountType = exports.Scope = exports.AuthenticationType = void 0;
4
4
  var AuthenticationType;
5
5
  (function (AuthenticationType) {
6
6
  AuthenticationType["CODE"] = "authorization_code";
@@ -44,13 +44,13 @@ var ProcessFileJobType;
44
44
  ProcessFileJobType["PRE_EXPORT"] = "pre-export-file";
45
45
  ProcessFileJobType["POST_EXPORT"] = "post-export-file";
46
46
  })(ProcessFileJobType = exports.ProcessFileJobType || (exports.ProcessFileJobType = {}));
47
- var EditorPanelsMode;
48
- (function (EditorPanelsMode) {
49
- EditorPanelsMode["ASSETS"] = "assets";
50
- EditorPanelsMode["REVIEW"] = "review";
51
- EditorPanelsMode["TRANSLATE"] = "TRANSLATE";
52
- EditorPanelsMode["PROOFREAD"] = "proofread";
53
- })(EditorPanelsMode = exports.EditorPanelsMode || (exports.EditorPanelsMode = {}));
47
+ var EditorMode;
48
+ (function (EditorMode) {
49
+ EditorMode["ASSETS"] = "assets";
50
+ EditorMode["REVIEW"] = "review";
51
+ EditorMode["TRANSLATE"] = "TRANSLATE";
52
+ EditorMode["PROOFREAD"] = "proofread";
53
+ })(EditorMode = exports.EditorMode || (exports.EditorMode = {}));
54
54
  var ContextOptionsLocations;
55
55
  (function (ContextOptionsLocations) {
56
56
  ContextOptionsLocations["TM"] = "tm";