@crowdin/app-project-module 0.54.1 → 0.55.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.
- package/out/app-test/integration/mocks/crowdin-storage.d.ts +3 -1
- package/out/index.js +2 -0
- package/out/modules/ai-prompt-provider/handlers/compile.d.ts +5 -0
- package/out/modules/ai-prompt-provider/handlers/compile.js +28 -0
- package/out/modules/ai-prompt-provider/index.d.ts +6 -0
- package/out/modules/ai-prompt-provider/index.js +23 -0
- package/out/modules/ai-prompt-provider/types.d.ts +8 -0
- package/out/modules/ai-prompt-provider/types.js +2 -0
- package/out/modules/integration/util/webhooks.d.ts +7 -0
- package/out/modules/integration/util/webhooks.js +21 -9
- package/out/modules/manifest.js +9 -0
- package/out/static/css/styles.css +22 -0
- package/out/static/js/form.js +1 -1
- package/out/types.d.ts +9 -0
- package/out/util/connection.js +38 -2
- package/package.json +5 -5
package/out/types.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { PostgreStorageConfig } from './storage/postgre';
|
|
|
13
13
|
import { ApiModule } from './modules/api/types';
|
|
14
14
|
import { LogErrorFunction, LogFunction } from './util/logger';
|
|
15
15
|
import { AiProviderModule } from './modules/ai-provider/types';
|
|
16
|
+
import { AiPromptProviderModule } from './modules/ai-prompt-provider/types';
|
|
16
17
|
export interface ClientConfig extends ImagePath {
|
|
17
18
|
/**
|
|
18
19
|
* Authentication Crowdin App type: "authorization_code", "crowdin_app". Default: "crowdin_app"
|
|
@@ -42,6 +43,10 @@ export interface ClientConfig extends ImagePath {
|
|
|
42
43
|
* define custom Crowdin urls (e.g. to work against local Crowdin server)
|
|
43
44
|
*/
|
|
44
45
|
crowdinUrls?: CrowdinUrls;
|
|
46
|
+
/**
|
|
47
|
+
* define custom User Agent in requests to Crowdin
|
|
48
|
+
*/
|
|
49
|
+
crowdinApiUserAgent?: string;
|
|
45
50
|
/**
|
|
46
51
|
* Set of scopes requested by this app (default 'project')
|
|
47
52
|
*/
|
|
@@ -176,6 +181,10 @@ export interface ClientConfig extends ImagePath {
|
|
|
176
181
|
* ai provider module
|
|
177
182
|
*/
|
|
178
183
|
aiProvider?: AiProviderModule & ImagePath;
|
|
184
|
+
/**
|
|
185
|
+
* ai prompt provider module
|
|
186
|
+
*/
|
|
187
|
+
aiPromptProvider?: AiPromptProviderModule & ImagePath;
|
|
179
188
|
}
|
|
180
189
|
export interface Environments {
|
|
181
190
|
environments?: Environment | Environment[];
|
package/out/util/connection.js
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
3
|
+
"version": "0.55.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",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"out/**/*"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@aws-sdk/client-s3": "^3.
|
|
22
|
-
"@aws-sdk/s3-request-presigner": "^3.
|
|
23
|
-
"@crowdin/crowdin-apps-functions": "0.
|
|
24
|
-
"@crowdin/logs-formatter": "^2.1.
|
|
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
|
+
"@crowdin/logs-formatter": "^2.1.4",
|
|
25
25
|
"@godaddy/terminus": "^4.12.1",
|
|
26
26
|
"amqplib": "^0.10.3",
|
|
27
27
|
"crypto-js": "^4.2.0",
|