@crowdin/app-project-module 0.54.0 → 0.54.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/types.d.ts CHANGED
@@ -42,6 +42,10 @@ export interface ClientConfig extends ImagePath {
42
42
  * define custom Crowdin urls (e.g. to work against local Crowdin server)
43
43
  */
44
44
  crowdinUrls?: CrowdinUrls;
45
+ /**
46
+ * define custom User Agent in requests to Crowdin
47
+ */
48
+ crowdinApiUserAgent?: string;
45
49
  /**
46
50
  * Set of scopes requested by this app (default 'project')
47
51
  */
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
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);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
27
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -21,10 +44,18 @@ const storage_1 = require("../storage");
21
44
  const types_1 = require("../types");
22
45
  const axios_2 = require("./axios");
23
46
  const logger_1 = require("./logger");
47
+ const os = __importStar(require("os"));
24
48
  const axiosCustom = new axios_2.AxiosProvider().axios;
25
49
  function prepareCrowdinClient({ config, credentials, autoRenew = false, context, }) {
26
50
  var _a, _b;
27
51
  return __awaiter(this, void 0, void 0, function* () {
52
+ let userAgent;
53
+ if (config.crowdinApiUserAgent) {
54
+ userAgent = config.crowdinApiUserAgent;
55
+ }
56
+ else {
57
+ userAgent = `app/${config.name} node/v${process.versions.node} ${os.type()}/${os.platform()}/${os.release()}`;
58
+ }
28
59
  //2 min as an extra buffer
29
60
  const isExpired = +credentials.expire - 120 < Date.now() / 1000;
30
61
  const organization = credentials.type === types_1.AccountType.ENTERPRISE ? credentials.id : undefined;
@@ -41,7 +72,7 @@ function prepareCrowdinClient({ config, credentials, autoRenew = false, context,
41
72
  }
42
73
  if (!autoRenew) {
43
74
  return {
44
- client: new crowdin_api_client_1.default({ token, organization, baseUrl: (_a = config.crowdinUrls) === null || _a === void 0 ? void 0 : _a.apiUrl }),
75
+ client: new crowdin_api_client_1.default({ token, organization, baseUrl: (_a = config.crowdinUrls) === null || _a === void 0 ? void 0 : _a.apiUrl }, { userAgent }),
45
76
  token,
46
77
  };
47
78
  }
@@ -49,7 +80,11 @@ function prepareCrowdinClient({ config, credentials, autoRenew = false, context,
49
80
  if (!config) {
50
81
  return;
51
82
  }
52
- return { headers: Object.assign(Object.assign({}, config.headers), { Authorization: `Bearer ${token}` }) };
83
+ const headers = Object.assign(Object.assign({}, config.headers), { Authorization: `Bearer ${token}` });
84
+ if (userAgent) {
85
+ headers['User-Agent'] = userAgent;
86
+ }
87
+ return { headers };
53
88
  };
54
89
  const renewToken = () => __awaiter(this, void 0, void 0, function* () {
55
90
  const res = yield refreshCrowdinCreds({ config, credentials: crowdinCreds });
@@ -173,6 +208,7 @@ function prepareCrowdinClient({ config, credentials, autoRenew = false, context,
173
208
  });
174
209
  },
175
210
  },
211
+ userAgent,
176
212
  }),
177
213
  token,
178
214
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "0.54.0",
3
+ "version": "0.54.2",
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",
@@ -18,9 +18,9 @@
18
18
  "out/**/*"
19
19
  ],
20
20
  "dependencies": {
21
- "@aws-sdk/client-s3": "^3.540.0",
22
- "@aws-sdk/s3-request-presigner": "^3.484.0",
23
- "@crowdin/crowdin-apps-functions": "0.6.0",
21
+ "@aws-sdk/client-s3": "^3.598.0",
22
+ "@aws-sdk/s3-request-presigner": "^3.598.0",
23
+ "@crowdin/crowdin-apps-functions": "0.7.0",
24
24
  "@crowdin/logs-formatter": "^2.1.3",
25
25
  "@godaddy/terminus": "^4.12.1",
26
26
  "amqplib": "^0.10.3",
@@ -40,8 +40,8 @@
40
40
  "@babel/preset-react": "^7.24.1",
41
41
  "@emotion/react": "^11.11.4",
42
42
  "@emotion/styled": "^11.11.5",
43
- "@mui/icons-material": "^5.15.19",
44
- "@mui/material": "^5.15.19",
43
+ "@mui/icons-material": "^5.15.20",
44
+ "@mui/material": "^5.15.20",
45
45
  "@rjsf/core": "^5.18.4",
46
46
  "@rjsf/mui": "^5.18.4",
47
47
  "@rjsf/utils": "^5.18.4",
@@ -56,7 +56,7 @@
56
56
  "@types/crypto-js": "^4.2.2",
57
57
  "@types/express": "4.17.21",
58
58
  "@types/express-handlebars": "^5.3.1",
59
- "@types/jest": "^29.5.5",
59
+ "@types/jest": "^29.5.12",
60
60
  "@types/lodash.uniqby": "^4.7.9",
61
61
  "@types/node": "^16.18.69",
62
62
  "@types/node-cron": "^3.0.11",
@@ -74,7 +74,7 @@
74
74
  "react": "^18.3.1",
75
75
  "react-dom": "^18.3.1",
76
76
  "rollup": "^3.29.4",
77
- "ts-jest": "^29.1.1",
77
+ "ts-jest": "^29.1.5",
78
78
  "typescript": "^4.9.5"
79
79
  },
80
80
  "repository": {