dymo-api 1.0.41 → 1.0.42

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.
@@ -1,10 +1,39 @@
1
- import axios from "axios";
2
- import config, { BASE_URL } from "../config";
3
- import { render } from "@react-email/render";
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
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.getRandom = exports.sendEmail = exports.isValidData = void 0;
30
+ const axios_1 = __importDefault(require("axios"));
31
+ const config_1 = __importStar(require("../config"));
32
+ const render_1 = require("@react-email/render");
4
33
  const customError = (code, message) => {
5
- return Object.assign(new Error(), { code, message: `[${config.lib.name}] ${message}` });
34
+ return Object.assign(new Error(), { code, message: `[${config_1.default.lib.name}] ${message}` });
6
35
  };
7
- export const isValidData = async (token, data) => {
36
+ const isValidData = async (token, data) => {
8
37
  if (token === null)
9
38
  throw customError(3000, "Invalid private token.");
10
39
  let i = false;
@@ -17,14 +46,15 @@ export const isValidData = async (token, data) => {
17
46
  if (!i)
18
47
  throw customError(1500, "You must provide at least one parameter.");
19
48
  try {
20
- const response = await axios.post(`${BASE_URL}/v1/private/secure/verify`, data, { headers: { "Authorization": token } });
49
+ const response = await axios_1.default.post(`${config_1.BASE_URL}/v1/private/secure/verify`, data, { headers: { "Authorization": token } });
21
50
  return response.data;
22
51
  }
23
52
  catch (error) {
24
53
  throw customError(5000, error.response?.data?.message || error.message);
25
54
  }
26
55
  };
27
- export const sendEmail = async (token, data) => {
56
+ exports.isValidData = isValidData;
57
+ const sendEmail = async (token, data) => {
28
58
  if (token === null)
29
59
  throw customError(3000, "Invalid private token.");
30
60
  if (!data.from)
@@ -40,7 +70,7 @@ export const sendEmail = async (token, data) => {
40
70
  try {
41
71
  if (data.react) {
42
72
  //@ts-ignore
43
- data.html = await render(data.react);
73
+ data.html = await (0, render_1.render)(data.react);
44
74
  delete data.react;
45
75
  }
46
76
  }
@@ -48,14 +78,15 @@ export const sendEmail = async (token, data) => {
48
78
  throw customError(1500, `An error occurred while rendering your React component. Details: ${error}`);
49
79
  }
50
80
  try {
51
- const response = await axios.post(`${BASE_URL}/v1/private/sender/sendEmail`, data, { headers: { "Authorization": token } });
81
+ const response = await axios_1.default.post(`${config_1.BASE_URL}/v1/private/sender/sendEmail`, data, { headers: { "Authorization": token } });
52
82
  return response.data;
53
83
  }
54
84
  catch (error) {
55
85
  throw customError(5000, error.response?.data?.message || error.message);
56
86
  }
57
87
  };
58
- export const getRandom = async (token, data) => {
88
+ exports.sendEmail = sendEmail;
89
+ const getRandom = async (token, data) => {
59
90
  if (token === null)
60
91
  throw customError(3000, "Invalid private token.");
61
92
  if (!data.min || !data.max)
@@ -67,10 +98,11 @@ export const getRandom = async (token, data) => {
67
98
  if (data.max < -1000000000 || data.max > 1000000000)
68
99
  throw customError(1500, "'max' must be an integer in the interval [-1000000000}, 1000000000].");
69
100
  try {
70
- const response = await axios.post(`${BASE_URL}/v1/private/srng`, data, { headers: { "Authorization": token } });
101
+ const response = await axios_1.default.post(`${config_1.BASE_URL}/v1/private/srng`, data, { headers: { "Authorization": token } });
71
102
  return response.data;
72
103
  }
73
104
  catch (error) {
74
105
  throw customError(5000, error.response?.data?.message || error.message);
75
106
  }
76
107
  };
108
+ exports.getRandom = getRandom;
@@ -1,37 +1,68 @@
1
- import axios from "axios";
2
- import config, { BASE_URL } from "../config";
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
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.newURLEncrypt = exports.isValidPwd = exports.satinizer = exports.getPrayerTimes = void 0;
30
+ const axios_1 = __importDefault(require("axios"));
31
+ const config_1 = __importStar(require("../config"));
3
32
  const customError = (code, message) => {
4
- return Object.assign(new Error(), { code, message: `[${config.lib.name}] ${message}` });
33
+ return Object.assign(new Error(), { code, message: `[${config_1.default.lib.name}] ${message}` });
5
34
  };
6
35
  ;
7
36
  ;
8
37
  ;
9
38
  ;
10
- export const getPrayerTimes = async (data) => {
39
+ const getPrayerTimes = async (data) => {
11
40
  const { lat, lon } = data;
12
41
  if (lat === undefined || lon === undefined)
13
42
  throw customError(1000, "You must provide a latitude and longitude.");
14
43
  try {
15
- const response = await axios.get(`${BASE_URL}/v1/public/islam/prayertimes`, { params: data });
44
+ const response = await axios_1.default.get(`${config_1.BASE_URL}/v1/public/islam/prayertimes`, { params: data });
16
45
  return response.data;
17
46
  }
18
47
  catch (error) {
19
48
  throw customError(5000, error.response?.data?.message || error.message);
20
49
  }
21
50
  };
22
- export const satinizer = async (data) => {
51
+ exports.getPrayerTimes = getPrayerTimes;
52
+ const satinizer = async (data) => {
23
53
  const { input } = data;
24
54
  if (input === undefined)
25
55
  throw customError(1000, "You must specify at least the input.");
26
56
  try {
27
- const response = await axios.get(`${BASE_URL}/v1/public/inputSatinizer`, { params: { input: encodeURIComponent(input) } });
57
+ const response = await axios_1.default.get(`${config_1.BASE_URL}/v1/public/inputSatinizer`, { params: { input: encodeURIComponent(input) } });
28
58
  return response.data;
29
59
  }
30
60
  catch (error) {
31
61
  throw customError(5000, error.response?.data?.message || error.message);
32
62
  }
33
63
  };
34
- export const isValidPwd = async (data) => {
64
+ exports.satinizer = satinizer;
65
+ const isValidPwd = async (data) => {
35
66
  let { email, password, bannedWords, min, max } = data;
36
67
  if (password === undefined)
37
68
  throw customError(1000, "You must specify at least the password.");
@@ -59,22 +90,24 @@ export const isValidPwd = async (data) => {
59
90
  if (max !== undefined)
60
91
  params.max = max;
61
92
  try {
62
- const response = await axios.get(`${BASE_URL}/v1/public/validPwd`, { params });
93
+ const response = await axios_1.default.get(`${config_1.BASE_URL}/v1/public/validPwd`, { params });
63
94
  return response.data;
64
95
  }
65
96
  catch (error) {
66
97
  throw customError(5000, error.response?.data?.message || error.message);
67
98
  }
68
99
  };
69
- export const newURLEncrypt = async (data) => {
100
+ exports.isValidPwd = isValidPwd;
101
+ const newURLEncrypt = async (data) => {
70
102
  const { url } = data;
71
103
  if (url === undefined || (!url.startsWith("https://") && !url.startsWith("http://")))
72
104
  throw customError(1500, "You must provide a valid url.");
73
105
  try {
74
- const response = await axios.get(`${BASE_URL}/v1/public/url-encrypt`, { params: data });
106
+ const response = await axios_1.default.get(`${config_1.BASE_URL}/v1/public/url-encrypt`, { params: data });
75
107
  return response.data;
76
108
  }
77
109
  catch (error) {
78
110
  throw customError(5000, error.response?.data?.message || error.message);
79
111
  }
80
112
  };
113
+ exports.newURLEncrypt = newURLEncrypt;
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BASE_URL = exports.setBaseUrl = void 0;
1
4
  const config = {
2
5
  lib: {
3
6
  name: "Dymo API",
@@ -7,9 +10,10 @@ const config = {
7
10
  baseUrl: "https://api.tpeoficial.com"
8
11
  }
9
12
  };
10
- export default config;
13
+ exports.default = config;
11
14
  let BASE_URL = config.env.baseUrl;
12
- export const setBaseUrl = (isLocal) => {
13
- BASE_URL = isLocal ? "http://localhost:3050" : config.env.baseUrl;
15
+ exports.BASE_URL = BASE_URL;
16
+ const setBaseUrl = (isLocal) => {
17
+ exports.BASE_URL = BASE_URL = isLocal ? "http://localhost:3050" : config.env.baseUrl;
14
18
  };
15
- export { BASE_URL };
19
+ exports.setBaseUrl = setBaseUrl;
@@ -1,10 +1,38 @@
1
- import axios from "axios";
2
- import * as PublicAPI from "./branches/public";
3
- import * as PrivateAPI from "./branches/private";
4
- import config, { BASE_URL, setBaseUrl } from "./config";
5
- import { checkForUpdates } from "./services/autoupdate";
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
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const axios_1 = __importDefault(require("axios"));
30
+ const PublicAPI = __importStar(require("./branches/public"));
31
+ const PrivateAPI = __importStar(require("./branches/private"));
32
+ const config_1 = __importStar(require("./config"));
33
+ const autoupdate_1 = require("./services/autoupdate");
6
34
  const customError = (code, message) => {
7
- return Object.assign(new Error(), { code, message: `[${config.lib.name}] ${message}` });
35
+ return Object.assign(new Error(), { code, message: `[${config_1.default.lib.name}] ${message}` });
8
36
  };
9
37
  ;
10
38
  ;
@@ -35,7 +63,7 @@ class DymoAPI {
35
63
  this.lastFetchTime = null;
36
64
  this.serverEmailConfig = serverEmailConfig;
37
65
  this.local = rootApiKey ? local : false; // Only allow setting local if rootApiKey is defined.
38
- setBaseUrl(this.local);
66
+ (0, config_1.setBaseUrl)(this.local);
39
67
  this.autoupdate();
40
68
  this.initializeTokens(); // Calls the function to obtain tokens when creating the object.
41
69
  }
@@ -57,7 +85,7 @@ class DymoAPI {
57
85
  async getTokens() {
58
86
  const currentTime = new Date();
59
87
  if (this.tokensResponse && this.lastFetchTime && (currentTime.getTime() - this.lastFetchTime.getTime()) < 5 * 60 * 1000) {
60
- console.log(`[${config.lib.name}] Using cached tokens response.`);
88
+ console.log(`[${config_1.default.lib.name}] Using cached tokens response.`);
61
89
  return this.tokensResponse;
62
90
  }
63
91
  ;
@@ -69,14 +97,14 @@ class DymoAPI {
69
97
  try {
70
98
  if (Object.keys(tokens).length === 0)
71
99
  return;
72
- const response = await axios.post(`${BASE_URL}/v1/dvr/tokens`, { tokens });
100
+ const response = await axios_1.default.post(`${config_1.BASE_URL}/v1/dvr/tokens`, { tokens });
73
101
  if (tokens.root && response.data.root === false)
74
102
  throw customError(3000, "Invalid root token.");
75
103
  if (tokens.api && response.data.api === false)
76
104
  throw customError(3000, "Invalid API token.");
77
105
  this.tokensResponse = response.data;
78
106
  this.lastFetchTime = currentTime;
79
- console.log(`[${config.lib.name}] Tokens initialized successfully.`);
107
+ console.log(`[${config_1.default.lib.name}] Tokens initialized successfully.`);
80
108
  return this.tokensResponse;
81
109
  }
82
110
  catch (error) {
@@ -111,7 +139,7 @@ class DymoAPI {
111
139
  */
112
140
  async autoupdate() {
113
141
  try {
114
- await checkForUpdates();
142
+ await (0, autoupdate_1.checkForUpdates)();
115
143
  }
116
144
  catch (error) {
117
145
  throw customError(5000, `Error checking the latest version in npmjs: ${error.message}`);
@@ -232,4 +260,4 @@ class DymoAPI {
232
260
  return await PublicAPI.newURLEncrypt(data);
233
261
  }
234
262
  }
235
- export default DymoAPI;
263
+ exports.default = DymoAPI;
@@ -1,4 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
1
3
  ;
2
4
  ;
3
5
  ;
4
- export {};
@@ -1,10 +1,16 @@
1
- import axios from "axios";
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.checkForUpdates = checkForUpdates;
7
+ const axios_1 = __importDefault(require("axios"));
2
8
  //@ts-ignore
3
- import { execSync } from "child_process";
4
- const localVersion = execSync("npm list dymo-api --depth=0").toString().match(new RegExp("dymo-api@(\\d+\\.\\d+\\.\\d+)"))?.[1] || "0.0.0";
5
- export async function checkForUpdates() {
9
+ const child_process_1 = require("child_process");
10
+ const localVersion = (0, child_process_1.execSync)("npm list dymo-api --depth=0").toString().match(new RegExp("dymo-api@(\\d+\\.\\d+\\.\\d+)"))?.[1] || "0.0.0";
11
+ async function checkForUpdates() {
6
12
  try {
7
- const response = await axios.get("https://registry.npmjs.org/dymo-api/latest");
13
+ const response = await axios_1.default.get("https://registry.npmjs.org/dymo-api/latest");
8
14
  const latestVersion = response.data.version;
9
15
  if (localVersion !== latestVersion)
10
16
  console.log(`[Dymo API] A new version of dymo-api is available: ${latestVersion}. You are using ${localVersion}. Consider updating.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dymo-api",
3
- "version": "1.0.41",
3
+ "version": "1.0.42",
4
4
  "description": "Flow system for Dymo API.",
5
5
  "main": "dist/cjs/dymo-api.js",
6
6
  "module": "dist/esm/dymo-api.js",
@@ -40,7 +40,8 @@
40
40
  "dependencies": {
41
41
  "@react-email/render": "1.0.1",
42
42
  "@types/react": "^18.3.5",
43
- "axios": "^1.6.8"
43
+ "axios": "^1.6.8",
44
+ "rimraf": "^6.0.1"
44
45
  },
45
46
  "contributors": [
46
47
  "TPEOficial (https://github.com/TPEOficial)",
@@ -52,4 +53,4 @@
52
53
  "ts-node": "^10.9.2",
53
54
  "typescript": "^5.5.4"
54
55
  }
55
- }
56
+ }