@crowdin/app-project-module 0.30.3 → 0.31.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.
@@ -57,6 +57,12 @@ function handle(config, integration) {
57
57
  options.integrationSearchListener = integration.integrationSearchListener;
58
58
  options.checkSubscription = !(0, connection_1.isAppFree)(config);
59
59
  options.uploadTranslations = integration.uploadTranslations;
60
+ options.sentryData = config.sentryDsn
61
+ ? {
62
+ dsn: config.sentryDsn,
63
+ appIdentifier: config.identifier,
64
+ }
65
+ : null;
60
66
  (0, util_1.log)(`Routing user to ${view} view`, config.logger);
61
67
  return res.render(view, options);
62
68
  }), config.onError);
@@ -194,19 +194,10 @@ function handle(config) {
194
194
  events['subscription_paid'] = '/subscription-paid';
195
195
  }
196
196
  return (_req, res) => {
197
- const manifest = {
198
- identifier: config.identifier,
199
- name: config.name,
200
- logo: (0, util_1.getLogoUrl)(config),
201
- baseUrl: config.baseUrl,
202
- authentication: {
197
+ const manifest = Object.assign(Object.assign({ identifier: config.identifier, name: config.name, logo: (0, util_1.getLogoUrl)(config), baseUrl: config.baseUrl, authentication: {
203
198
  type: config.authenticationType || models_1.AuthenticationType.APP,
204
199
  clientId: config.clientId,
205
- },
206
- events,
207
- scopes: config.scopes ? config.scopes : [models_1.Scope.PROJECTS],
208
- modules,
209
- };
200
+ }, events, scopes: config.scopes ? config.scopes : [models_1.Scope.PROJECTS] }, (config.defaultPermissions && { default_permissions: config.defaultPermissions })), { modules });
210
201
  res.send(manifest);
211
202
  };
212
203
  }
package/out/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Express } from 'express';
2
2
  import { ClientConfig, Config, CrowdinAppUtilities } from './models';
3
3
  import express from './util/terminus-express';
4
- export { Scope } from './models';
4
+ export { Scope, UserPermissions, ProjectPermissions } from './models';
5
5
  export { express };
6
6
  export declare function addCrowdinEndpoints(app: Express, clientConfig: Config | ClientConfig): CrowdinAppUtilities;
7
7
  export declare function createApp(clientConfig: ClientConfig): void;
package/out/index.js CHANGED
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.createApp = exports.addCrowdinEndpoints = exports.express = exports.Scope = void 0;
38
+ exports.createApp = exports.addCrowdinEndpoints = exports.express = exports.ProjectPermissions = exports.UserPermissions = exports.Scope = void 0;
39
39
  const express_handlebars_1 = __importDefault(require("express-handlebars"));
40
40
  const cron = __importStar(require("node-cron"));
41
41
  const path_1 = require("path");
@@ -84,6 +84,8 @@ exports.express = terminus_express_1.default;
84
84
  const webhooks_1 = require("./util/webhooks");
85
85
  var models_2 = require("./models");
86
86
  Object.defineProperty(exports, "Scope", { enumerable: true, get: function () { return models_2.Scope; } });
87
+ Object.defineProperty(exports, "UserPermissions", { enumerable: true, get: function () { return models_2.UserPermissions; } });
88
+ Object.defineProperty(exports, "ProjectPermissions", { enumerable: true, get: function () { return models_2.ProjectPermissions; } });
87
89
  function addCrowdinEndpoints(app, clientConfig) {
88
90
  var _a, _b, _c, _d, _e, _f, _g;
89
91
  const config = (0, defaults_1.convertClientConfig)(clientConfig);
@@ -48,6 +48,10 @@ export interface ClientConfig extends ImagePath {
48
48
  * app description
49
49
  */
50
50
  description: string;
51
+ /**
52
+ * Set default app permissions
53
+ */
54
+ defaultPermissions?: DefaultPermissions;
51
55
  /**
52
56
  * port where to start express application
53
57
  */
@@ -143,6 +147,10 @@ export interface ClientConfig extends ImagePath {
143
147
  filePostImport?: FilePostImportLogic;
144
148
  filePreExport?: FilePreExportLogic;
145
149
  filePostExport?: FilePostExportLogic;
150
+ /**
151
+ * sentry dsn identifier of sentry project
152
+ */
153
+ sentryDsn?: string;
146
154
  }
147
155
  export type Config = ClientConfig & {
148
156
  baseUrl: string;
@@ -884,4 +892,17 @@ export interface IntegrationSyncedFiles {
884
892
  integrationId: string;
885
893
  crowdinId: string;
886
894
  }
895
+ export declare enum UserPermissions {
896
+ OWNER = "owner",
897
+ MANAGERS = "managers",
898
+ ALL_MEMBERS = "all"
899
+ }
900
+ export declare enum ProjectPermissions {
901
+ OWN = "own",
902
+ RESTRICTED = "restricted"
903
+ }
904
+ export interface DefaultPermissions {
905
+ user?: UserPermissions;
906
+ project?: ProjectPermissions;
907
+ }
887
908
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SyncType = 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.SyncType = exports.SyncCondition = exports.RequestMethods = exports.Provider = exports.ContextOptionsTypes = exports.ContextOptionsLocations = exports.EditorPanelsMode = 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";
@@ -91,3 +91,14 @@ var SyncType;
91
91
  SyncType[SyncType["SCHEDULE"] = 1] = "SCHEDULE";
92
92
  SyncType[SyncType["WEBHOOKS"] = 2] = "WEBHOOKS";
93
93
  })(SyncType = exports.SyncType || (exports.SyncType = {}));
94
+ var UserPermissions;
95
+ (function (UserPermissions) {
96
+ UserPermissions["OWNER"] = "owner";
97
+ UserPermissions["MANAGERS"] = "managers";
98
+ UserPermissions["ALL_MEMBERS"] = "all";
99
+ })(UserPermissions = exports.UserPermissions || (exports.UserPermissions = {}));
100
+ var ProjectPermissions;
101
+ (function (ProjectPermissions) {
102
+ ProjectPermissions["OWN"] = "own";
103
+ ProjectPermissions["RESTRICTED"] = "restricted";
104
+ })(ProjectPermissions = exports.ProjectPermissions || (exports.ProjectPermissions = {}));
@@ -290,10 +290,11 @@ function convertClientConfig(clientConfig) {
290
290
  const clientId = clientConfig.clientId || process.env.CROWDIN_CLIENT_ID;
291
291
  const clientSecret = clientConfig.clientSecret || process.env.CROWDIN_CLIENT_SECRET;
292
292
  const port = clientConfig.port || process.env.PORT || 3000;
293
+ const sentryDsn = clientConfig.sentryDsn || process.env.SENTRY_DSN;
293
294
  if (!baseUrl || !clientId || !clientSecret) {
294
295
  throw new Error('One of following parameters are not defined [baseUrl, clientId, clientSecret]');
295
296
  }
296
- return Object.assign(Object.assign({}, clientConfig), { baseUrl: baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl, clientId,
297
+ return Object.assign(Object.assign({}, clientConfig), { sentryDsn, baseUrl: baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl, clientId,
297
298
  clientSecret, port: Number(port), dbFolder: clientConfig.dbFolder || (0, path_1.join)(process.cwd(), 'db'), imagePath: clientConfig.imagePath || (0, path_1.join)(process.cwd(), 'logo.png') });
298
299
  }
299
300
  exports.convertClientConfig = convertClientConfig;
@@ -18,4 +18,31 @@
18
18
  margin-left: 10px;
19
19
  }
20
20
  </style>
21
- </head>
21
+ {{#if sentryData}}
22
+ <script
23
+ src="https://browser.sentry-cdn.com/7.60.0/bundle.replay.min.js"
24
+ integrity="sha384-N+VZps2PwFdv9LugkPA8nw+SMI1mGJG7IDe49jaxZlWDDJhHQ+SHakMpwhLQLAka"
25
+ crossorigin="anonymous"
26
+ ></script>
27
+ <script>
28
+ Sentry.init({
29
+ dsn: "{{sentryData.dsn}}",
30
+ environment: "frontend",
31
+ replaysSessionSampleRate: 0,
32
+ replaysOnErrorSampleRate: 1.0,
33
+ integrations: [new Sentry.Replay()],
34
+ });
35
+
36
+ Sentry.configureScope(function(scope) {
37
+ scope.setTag("identifier", "{{sentryData.appIdentifier}}");
38
+
39
+ AP.getContext(contextData => {
40
+ const { user_id, ...rest } = contextData;
41
+
42
+ user_id && scope.setUser({ id: user_id });
43
+ scope.setTags(rest);
44
+ });
45
+ });
46
+ </script>
47
+ {{/if}}
48
+ </head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "0.30.3",
3
+ "version": "0.31.0",
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",