dymo-api 1.0.56 → 1.0.58
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/dist/cjs/branches/private.js +2 -2
- package/dist/esm/branches/private.js +18 -50
- package/dist/esm/branches/public.js +11 -44
- package/dist/esm/config/index.js +4 -8
- package/dist/esm/dymo-api.js +12 -40
- package/dist/esm/lib/interfaces.js +1 -2
- package/dist/esm/services/autoupdate.js +5 -11
- package/package.json +2 -2
|
@@ -31,7 +31,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
31
31
|
const axios_1 = __importDefault(require("axios"));
|
|
32
32
|
const react_1 = __importDefault(require("react"));
|
|
33
33
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
34
|
-
const
|
|
34
|
+
const tw_to_css_1 = require("tw-to-css");
|
|
35
35
|
const config_1 = __importStar(require("../config"));
|
|
36
36
|
const render_1 = require("@react-email/render");
|
|
37
37
|
const customError = (code, message) => {
|
|
@@ -39,7 +39,7 @@ const customError = (code, message) => {
|
|
|
39
39
|
};
|
|
40
40
|
const convertTailwindToInlineCss = (htmlContent) => {
|
|
41
41
|
return htmlContent.replace(/class="([^"]+)"/g, (match, classList) => {
|
|
42
|
-
return match.replace("class", "style").replace(classList, twi(classList, { minify: true, merge: true }));
|
|
42
|
+
return match.replace("class", "style").replace(classList, (0, tw_to_css_1.twi)(classList, { minify: true, merge: true }));
|
|
43
43
|
});
|
|
44
44
|
};
|
|
45
45
|
/**
|
|
@@ -1,41 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 path_1 = __importDefault(require("path"));
|
|
31
|
-
const axios_1 = __importDefault(require("axios"));
|
|
32
|
-
const react_1 = __importDefault(require("react"));
|
|
33
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
34
|
-
const { twi } = require("tw-to-css");
|
|
35
|
-
const config_1 = __importStar(require("../config"));
|
|
36
|
-
const render_1 = require("@react-email/render");
|
|
1
|
+
import path from "path";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import fs from "fs/promises";
|
|
5
|
+
import { twi } from "tw-to-css";
|
|
6
|
+
import config, { BASE_URL } from "../config";
|
|
7
|
+
import { render } from "@react-email/render";
|
|
37
8
|
const customError = (code, message) => {
|
|
38
|
-
return Object.assign(new Error(), { code, message: `[${
|
|
9
|
+
return Object.assign(new Error(), { code, message: `[${config.lib.name}] ${message}` });
|
|
39
10
|
};
|
|
40
11
|
const convertTailwindToInlineCss = (htmlContent) => {
|
|
41
12
|
return htmlContent.replace(/class="([^"]+)"/g, (match, classList) => {
|
|
@@ -54,20 +25,19 @@ const convertTailwindToInlineCss = (htmlContent) => {
|
|
|
54
25
|
* @throws Will throw an error if the token is null, if none of the required fields are present in the data,
|
|
55
26
|
* or if an error occurs during the verification request.
|
|
56
27
|
*/
|
|
57
|
-
const isValidData = async (token, data) => {
|
|
28
|
+
export const isValidData = async (token, data) => {
|
|
58
29
|
if (token === null)
|
|
59
30
|
throw customError(3000, "Invalid private token.");
|
|
60
31
|
if (!Object.keys(data).some((key) => ["email", "phone", "domain", "creditCard", "ip", "wallet"].includes(key) && data.hasOwnProperty(key)))
|
|
61
32
|
throw customError(1500, "You must provide at least one parameter.");
|
|
62
33
|
try {
|
|
63
|
-
const response = await
|
|
34
|
+
const response = await axios.post(`${BASE_URL}/v1/private/secure/verify`, data, { headers: { "Authorization": token } });
|
|
64
35
|
return response.data;
|
|
65
36
|
}
|
|
66
37
|
catch (error) {
|
|
67
38
|
throw customError(5000, error.response?.data?.message || error.message);
|
|
68
39
|
}
|
|
69
40
|
};
|
|
70
|
-
exports.isValidData = isValidData;
|
|
71
41
|
/**
|
|
72
42
|
* Sends an email using a secure sending endpoint.
|
|
73
43
|
*
|
|
@@ -81,7 +51,7 @@ exports.isValidData = isValidData;
|
|
|
81
51
|
* if the 'react' field is not a valid React element, if the 'attachments' field exceeds the maximum allowed size of 40 MB,
|
|
82
52
|
* or if an error occurs during the sending request.
|
|
83
53
|
*/
|
|
84
|
-
const sendEmail = async (token, data) => {
|
|
54
|
+
export const sendEmail = async (token, data) => {
|
|
85
55
|
if (token === null)
|
|
86
56
|
throw customError(3000, "Invalid private token.");
|
|
87
57
|
if (!data.from)
|
|
@@ -90,14 +60,14 @@ const sendEmail = async (token, data) => {
|
|
|
90
60
|
throw customError(1500, "You must provide an email to be sent to.");
|
|
91
61
|
if (!data.subject)
|
|
92
62
|
throw customError(1500, "You must provide a subject for the email to be sent.");
|
|
93
|
-
if (!data.html && !data.react && !
|
|
63
|
+
if (!data.html && !data.react && !React.isValidElement(data.react))
|
|
94
64
|
throw customError(1500, "You must provide HTML or a React component.");
|
|
95
65
|
if (data.html && data.react)
|
|
96
66
|
throw customError(1500, "You must provide only HTML or a React component, not both.");
|
|
97
67
|
try {
|
|
98
68
|
if (data.react) {
|
|
99
69
|
//@ts-ignore
|
|
100
|
-
data.html = await
|
|
70
|
+
data.html = await render(data.react);
|
|
101
71
|
delete data.react;
|
|
102
72
|
}
|
|
103
73
|
if (data.options && data.options.composeTailwindClasses) {
|
|
@@ -116,28 +86,27 @@ const sendEmail = async (token, data) => {
|
|
|
116
86
|
throw customError(1500, "You must provide either 'path' or 'content', not both.");
|
|
117
87
|
let contentBuffer;
|
|
118
88
|
if (attachment.path)
|
|
119
|
-
contentBuffer = await
|
|
89
|
+
contentBuffer = await fs.readFile(path.resolve(attachment.path));
|
|
120
90
|
else if (attachment.content)
|
|
121
91
|
contentBuffer = attachment.content instanceof Buffer ? attachment.content : Buffer.from(attachment.content);
|
|
122
92
|
totalSize += Buffer.byteLength(contentBuffer);
|
|
123
93
|
if (totalSize > 40 * 1024 * 1024)
|
|
124
94
|
throw customError(1500, "Attachments exceed the maximum allowed size of 40 MB.");
|
|
125
95
|
return {
|
|
126
|
-
filename: attachment.filename ||
|
|
96
|
+
filename: attachment.filename || path.basename(attachment.path || ""),
|
|
127
97
|
content: contentBuffer,
|
|
128
98
|
cid: attachment.cid || attachment.filename
|
|
129
99
|
};
|
|
130
100
|
}));
|
|
131
101
|
data.attachments = processedAttachments;
|
|
132
102
|
}
|
|
133
|
-
const response = await
|
|
103
|
+
const response = await axios.post(`${BASE_URL}/v1/private/sender/sendEmail`, data, { headers: { "Authorization": token } });
|
|
134
104
|
return response.data;
|
|
135
105
|
}
|
|
136
106
|
catch (error) {
|
|
137
107
|
throw customError(5000, error.response?.data?.message || error.message);
|
|
138
108
|
}
|
|
139
109
|
};
|
|
140
|
-
exports.sendEmail = sendEmail;
|
|
141
110
|
/**
|
|
142
111
|
* Retrieves a random number within a specified range using a secure endpoint.
|
|
143
112
|
*
|
|
@@ -151,7 +120,7 @@ exports.sendEmail = sendEmail;
|
|
|
151
120
|
* if 'min' is not less than 'max', if 'min' or 'max' are out of the allowed range,
|
|
152
121
|
* or if an error occurs during the request to the random number generator endpoint.
|
|
153
122
|
*/
|
|
154
|
-
const getRandom = async (token, data) => {
|
|
123
|
+
export const getRandom = async (token, data) => {
|
|
155
124
|
if (token === null)
|
|
156
125
|
throw customError(3000, "Invalid private token.");
|
|
157
126
|
if (!data.min || !data.max)
|
|
@@ -163,11 +132,10 @@ const getRandom = async (token, data) => {
|
|
|
163
132
|
if (data.max < -1000000000 || data.max > 1000000000)
|
|
164
133
|
throw customError(1500, "'max' must be an integer in the interval [-1000000000}, 1000000000].");
|
|
165
134
|
try {
|
|
166
|
-
const response = await
|
|
135
|
+
const response = await axios.post(`${BASE_URL}/v1/private/srng`, data, { headers: { "Authorization": token } });
|
|
167
136
|
return response.data;
|
|
168
137
|
}
|
|
169
138
|
catch (error) {
|
|
170
139
|
throw customError(5000, error.response?.data?.message || error.message);
|
|
171
140
|
}
|
|
172
141
|
};
|
|
173
|
-
exports.getRandom = getRandom;
|
|
@@ -1,68 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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"));
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import config, { BASE_URL } from "../config";
|
|
32
3
|
const customError = (code, message) => {
|
|
33
|
-
return Object.assign(new Error(), { code, message: `[${
|
|
4
|
+
return Object.assign(new Error(), { code, message: `[${config.lib.name}] ${message}` });
|
|
34
5
|
};
|
|
35
6
|
;
|
|
36
7
|
;
|
|
37
8
|
;
|
|
38
9
|
;
|
|
39
|
-
const getPrayerTimes = async (data) => {
|
|
10
|
+
export const getPrayerTimes = async (data) => {
|
|
40
11
|
const { lat, lon } = data;
|
|
41
12
|
if (lat === undefined || lon === undefined)
|
|
42
13
|
throw customError(1000, "You must provide a latitude and longitude.");
|
|
43
14
|
try {
|
|
44
|
-
const response = await
|
|
15
|
+
const response = await axios.get(`${BASE_URL}/v1/public/islam/prayertimes`, { params: data });
|
|
45
16
|
return response.data;
|
|
46
17
|
}
|
|
47
18
|
catch (error) {
|
|
48
19
|
throw customError(5000, error.response?.data?.message || error.message);
|
|
49
20
|
}
|
|
50
21
|
};
|
|
51
|
-
|
|
52
|
-
const satinizer = async (data) => {
|
|
22
|
+
export const satinizer = async (data) => {
|
|
53
23
|
const { input } = data;
|
|
54
24
|
if (input === undefined)
|
|
55
25
|
throw customError(1000, "You must specify at least the input.");
|
|
56
26
|
try {
|
|
57
|
-
const response = await
|
|
27
|
+
const response = await axios.get(`${BASE_URL}/v1/public/inputSatinizer`, { params: { input: encodeURIComponent(input) } });
|
|
58
28
|
return response.data;
|
|
59
29
|
}
|
|
60
30
|
catch (error) {
|
|
61
31
|
throw customError(5000, error.response?.data?.message || error.message);
|
|
62
32
|
}
|
|
63
33
|
};
|
|
64
|
-
|
|
65
|
-
const isValidPwd = async (data) => {
|
|
34
|
+
export const isValidPwd = async (data) => {
|
|
66
35
|
let { email, password, bannedWords, min, max } = data;
|
|
67
36
|
if (password === undefined)
|
|
68
37
|
throw customError(1000, "You must specify at least the password.");
|
|
@@ -90,24 +59,22 @@ const isValidPwd = async (data) => {
|
|
|
90
59
|
if (max !== undefined)
|
|
91
60
|
params.max = max;
|
|
92
61
|
try {
|
|
93
|
-
const response = await
|
|
62
|
+
const response = await axios.get(`${BASE_URL}/v1/public/validPwd`, { params });
|
|
94
63
|
return response.data;
|
|
95
64
|
}
|
|
96
65
|
catch (error) {
|
|
97
66
|
throw customError(5000, error.response?.data?.message || error.message);
|
|
98
67
|
}
|
|
99
68
|
};
|
|
100
|
-
|
|
101
|
-
const newURLEncrypt = async (data) => {
|
|
69
|
+
export const newURLEncrypt = async (data) => {
|
|
102
70
|
const { url } = data;
|
|
103
71
|
if (url === undefined || (!url.startsWith("https://") && !url.startsWith("http://")))
|
|
104
72
|
throw customError(1500, "You must provide a valid url.");
|
|
105
73
|
try {
|
|
106
|
-
const response = await
|
|
74
|
+
const response = await axios.get(`${BASE_URL}/v1/public/url-encrypt`, { params: data });
|
|
107
75
|
return response.data;
|
|
108
76
|
}
|
|
109
77
|
catch (error) {
|
|
110
78
|
throw customError(5000, error.response?.data?.message || error.message);
|
|
111
79
|
}
|
|
112
80
|
};
|
|
113
|
-
exports.newURLEncrypt = newURLEncrypt;
|
package/dist/esm/config/index.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BASE_URL = exports.setBaseUrl = void 0;
|
|
4
1
|
const config = {
|
|
5
2
|
lib: {
|
|
6
3
|
name: "Dymo API",
|
|
@@ -10,10 +7,9 @@ const config = {
|
|
|
10
7
|
baseUrl: "https://api.tpeoficial.com"
|
|
11
8
|
}
|
|
12
9
|
};
|
|
13
|
-
|
|
10
|
+
export default config;
|
|
14
11
|
let BASE_URL = config.env.baseUrl;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
exports.BASE_URL = BASE_URL = isLocal ? "http://localhost:3050" : config.env.baseUrl;
|
|
12
|
+
export const setBaseUrl = (isLocal) => {
|
|
13
|
+
BASE_URL = isLocal ? "http://localhost:3050" : config.env.baseUrl;
|
|
18
14
|
};
|
|
19
|
-
|
|
15
|
+
export { BASE_URL };
|
package/dist/esm/dymo-api.js
CHANGED
|
@@ -1,38 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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");
|
|
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";
|
|
34
6
|
const customError = (code, message) => {
|
|
35
|
-
return Object.assign(new Error(), { code, message: `[${
|
|
7
|
+
return Object.assign(new Error(), { code, message: `[${config.lib.name}] ${message}` });
|
|
36
8
|
};
|
|
37
9
|
;
|
|
38
10
|
;
|
|
@@ -63,7 +35,7 @@ class DymoAPI {
|
|
|
63
35
|
this.lastFetchTime = null;
|
|
64
36
|
this.serverEmailConfig = serverEmailConfig;
|
|
65
37
|
this.local = rootApiKey ? local : false; // Only allow setting local if rootApiKey is defined.
|
|
66
|
-
|
|
38
|
+
setBaseUrl(this.local);
|
|
67
39
|
this.autoupdate();
|
|
68
40
|
this.initializeTokens(); // Calls the function to obtain tokens when creating the object.
|
|
69
41
|
}
|
|
@@ -85,7 +57,7 @@ class DymoAPI {
|
|
|
85
57
|
async getTokens() {
|
|
86
58
|
const currentTime = new Date();
|
|
87
59
|
if (this.tokensResponse && this.lastFetchTime && (currentTime.getTime() - this.lastFetchTime.getTime()) < 5 * 60 * 1000) {
|
|
88
|
-
console.log(`[${
|
|
60
|
+
console.log(`[${config.lib.name}] Using cached tokens response.`);
|
|
89
61
|
return this.tokensResponse;
|
|
90
62
|
}
|
|
91
63
|
;
|
|
@@ -97,14 +69,14 @@ class DymoAPI {
|
|
|
97
69
|
try {
|
|
98
70
|
if (Object.keys(tokens).length === 0)
|
|
99
71
|
return;
|
|
100
|
-
const response = await
|
|
72
|
+
const response = await axios.post(`${BASE_URL}/v1/dvr/tokens`, { tokens });
|
|
101
73
|
if (tokens.root && response.data.root === false)
|
|
102
74
|
throw customError(3000, "Invalid root token.");
|
|
103
75
|
if (tokens.api && response.data.api === false)
|
|
104
76
|
throw customError(3000, "Invalid API token.");
|
|
105
77
|
this.tokensResponse = response.data;
|
|
106
78
|
this.lastFetchTime = currentTime;
|
|
107
|
-
console.log(`[${
|
|
79
|
+
console.log(`[${config.lib.name}] Tokens initialized successfully.`);
|
|
108
80
|
return this.tokensResponse;
|
|
109
81
|
}
|
|
110
82
|
catch (error) {
|
|
@@ -139,7 +111,7 @@ class DymoAPI {
|
|
|
139
111
|
*/
|
|
140
112
|
async autoupdate() {
|
|
141
113
|
try {
|
|
142
|
-
await
|
|
114
|
+
await checkForUpdates();
|
|
143
115
|
}
|
|
144
116
|
catch (error) {
|
|
145
117
|
throw customError(5000, `Error checking the latest version in npmjs: ${error.message}`);
|
|
@@ -269,4 +241,4 @@ class DymoAPI {
|
|
|
269
241
|
return await PublicAPI.newURLEncrypt(data);
|
|
270
242
|
}
|
|
271
243
|
}
|
|
272
|
-
|
|
244
|
+
export default DymoAPI;
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
|
|
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"));
|
|
1
|
+
import axios from "axios";
|
|
8
2
|
//@ts-ignore
|
|
9
|
-
|
|
10
|
-
const localVersion =
|
|
11
|
-
async function checkForUpdates() {
|
|
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() {
|
|
12
6
|
try {
|
|
13
|
-
const response = await
|
|
7
|
+
const response = await axios.get("https://registry.npmjs.org/dymo-api/latest");
|
|
14
8
|
const latestVersion = response.data.version;
|
|
15
9
|
if (localVersion !== latestVersion)
|
|
16
10
|
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.
|
|
3
|
+
"version": "1.0.58",
|
|
4
4
|
"description": "Flow system for Dymo API.",
|
|
5
5
|
"main": "dist/cjs/dymo-api.js",
|
|
6
6
|
"module": "dist/esm/dymo-api.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"bugs": {
|
|
38
38
|
"url": "https://github.com/TPEOficial/dymo-api-node/issues"
|
|
39
39
|
},
|
|
40
|
-
"homepage": "https://dymo.tpeoficial.com",
|
|
40
|
+
"homepage": "https://dymo.tpeoficial.com/",
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@react-email/render": "1.0.1",
|
|
43
43
|
"@types/react": "^18.3.5",
|