@runnerpro/backend 1.0.11 → 1.0.12

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/lib/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchIA = exports.err = exports.sendMail = exports.batchQuery = exports.query = exports.sleep = exports.sendNotification = void 0;
3
+ exports.LANGUAGES = exports.translate = exports.fetchIA = exports.err = exports.sendMail = exports.batchQuery = exports.query = exports.sleep = exports.sendNotification = void 0;
4
4
  const sendNotification_1 = require("./sendNotification");
5
5
  Object.defineProperty(exports, "sendNotification", { enumerable: true, get: function () { return sendNotification_1.sendNotification; } });
6
6
  const sleep_1 = require("./sleep");
@@ -14,3 +14,6 @@ const err_1 = require("./err");
14
14
  Object.defineProperty(exports, "err", { enumerable: true, get: function () { return err_1.err; } });
15
15
  const fetchIA_1 = require("./fetch/fetchIA");
16
16
  Object.defineProperty(exports, "fetchIA", { enumerable: true, get: function () { return fetchIA_1.fetchIA; } });
17
+ const translation_1 = require("./translation");
18
+ Object.defineProperty(exports, "translate", { enumerable: true, get: function () { return translation_1.translate; } });
19
+ Object.defineProperty(exports, "LANGUAGES", { enumerable: true, get: function () { return translation_1.LANGUAGES; } });
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.translate = exports.LANGUAGES = void 0;
13
+ const { TranslationServiceClient } = require('@google-cloud/translate');
14
+ const LANGUAGES = {
15
+ EN: 'en',
16
+ ES: 'es',
17
+ FR: 'fr',
18
+ };
19
+ exports.LANGUAGES = LANGUAGES;
20
+ const translate = (text, { fromLanguage, toLanguage, }) => __awaiter(void 0, void 0, void 0, function* () {
21
+ const projectId = process.env.GCP_PROYECT_ID;
22
+ const location = 'global';
23
+ const translationClient = new TranslationServiceClient();
24
+ const request = {
25
+ parent: `projects/${projectId}/locations/${location}`,
26
+ contents: [text],
27
+ mimeType: 'text/plain',
28
+ sourceLanguageCode: fromLanguage,
29
+ targetLanguageCode: toLanguage,
30
+ };
31
+ const [response] = yield translationClient.translateText(request);
32
+ return response.translations[0].translatedText;
33
+ });
34
+ exports.translate = translate;
@@ -4,5 +4,6 @@ import { query, batchQuery } from './db';
4
4
  import { sendMail } from './sendMail';
5
5
  import { err } from './err';
6
6
  import { fetchIA } from './fetch/fetchIA';
7
- export { sendNotification, sleep, query, batchQuery, sendMail, err, fetchIA };
7
+ import { translate, LANGUAGES } from './translation';
8
+ export { sendNotification, sleep, query, batchQuery, sendMail, err, fetchIA, translate, LANGUAGES, };
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EACL,gBAAgB,EAChB,KAAK,EACL,KAAK,EACL,UAAU,EACV,QAAQ,EACR,GAAG,EACH,OAAO,EACP,SAAS,EACT,SAAS,GACV,CAAC"}
@@ -0,0 +1,12 @@
1
+ declare const LANGUAGES: {
2
+ readonly EN: "en";
3
+ readonly ES: "es";
4
+ readonly FR: "fr";
5
+ };
6
+ type LANGUAGES_TYPE = keyof typeof LANGUAGES;
7
+ declare const translate: (text: string, { fromLanguage, toLanguage, }: {
8
+ fromLanguage: LANGUAGES_TYPE;
9
+ toLanguage: LANGUAGES_TYPE;
10
+ }) => Promise<string>;
11
+ export { LANGUAGES, translate };
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/translation/index.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,SAAS;;;;CAIL,CAAC;AAEX,KAAK,cAAc,GAAG,MAAM,OAAO,SAAS,CAAC;AAE7C,QAAA,MAAM,SAAS,SACP,MAAM;kBAIO,cAAc;gBAAc,cAAc;MAC5D,QAAQ,MAAM,CAgBhB,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"
@@ -44,8 +44,11 @@
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@parse/node-apn": "6.0.1",
47
+ "axios": "^1.6.7",
47
48
  "nodemailer": "6.9.9",
48
- "pg": "8.11.3",
49
- "axios": "^1.6.7"
49
+ "pg": "8.11.3"
50
+ },
51
+ "dependencies": {
52
+ "@google-cloud/translate": "^8.3.0"
50
53
  }
51
54
  }