dymo-api 1.0.86 → 1.0.88
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/config/index.cjs +5 -2
- package/dist/cjs/dymo-api.cjs +5 -25
- package/dist/esm/config/index.js +5 -2
- package/dist/esm/dymo-api.js +5 -25
- package/dist/types/config/index.d.ts +1 -1
- package/dist/types/dymo-api.d.ts +5 -16
- package/package.json +1 -1
- package/dist/cjs/services/autoupdate.cjs +0 -27
- package/dist/esm/services/autoupdate.js +0 -21
- package/dist/types/services/autoupdate.d.ts +0 -1
|
@@ -13,7 +13,10 @@ const config = {
|
|
|
13
13
|
exports.default = config;
|
|
14
14
|
let BASE_URL = config.env.baseUrl;
|
|
15
15
|
exports.BASE_URL = BASE_URL;
|
|
16
|
-
const setBaseUrl = (
|
|
17
|
-
|
|
16
|
+
const setBaseUrl = (baseUrl) => {
|
|
17
|
+
if (/^(https:\/\/api\.tpeoficial\.com$|http:\/\/(localhost:\d+|dymoapi:\d+))$/.test(baseUrl))
|
|
18
|
+
exports.BASE_URL = BASE_URL = baseUrl;
|
|
19
|
+
else
|
|
20
|
+
throw new Error("[Dymo API] Invalid URL. It must be https://api.tpeoficial.com or start with http://localhost or http://dymoapi followed by a port.");
|
|
18
21
|
};
|
|
19
22
|
exports.setBaseUrl = setBaseUrl;
|
package/dist/cjs/dymo-api.cjs
CHANGED
|
@@ -36,7 +36,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
const PublicAPI = __importStar(require("./branches/public.cjs"));
|
|
37
37
|
const PrivateAPI = __importStar(require("./branches/private.cjs"));
|
|
38
38
|
const config_1 = __importStar(require("./config/index.cjs"));
|
|
39
|
-
const autoupdate_1 = require("./services/autoupdate.cjs");
|
|
40
39
|
const customError = (code, message) => {
|
|
41
40
|
return Object.assign(new Error(), { code, message: `[${config_1.default.lib.name}] ${message}` });
|
|
42
41
|
};
|
|
@@ -45,7 +44,7 @@ class DymoAPI {
|
|
|
45
44
|
* @param {Object} options - Options to create the DymoAPI instance.
|
|
46
45
|
* @param {string} [options.rootApiKey] - The root API key.
|
|
47
46
|
* @param {string} [options.apiKey] - The API key.
|
|
48
|
-
* @param {
|
|
47
|
+
* @param {string} [options.baseUrl] - Whether to use a local server instead of the cloud server.
|
|
49
48
|
* @param {Object} [options.serverEmailConfig] - The server email config.
|
|
50
49
|
* @description
|
|
51
50
|
* This is the main class to interact with the Dymo API. It should be
|
|
@@ -55,34 +54,15 @@ class DymoAPI {
|
|
|
55
54
|
* @example
|
|
56
55
|
* const dymoApi = new DymoAPI({
|
|
57
56
|
* rootApiKey: "6bfb7675-6b69-4f8d-9f43-5a6f7f02c6c5",
|
|
58
|
-
* apiKey: "4c8b7675-6b69-4f8d-9f43-5a6f7f02c6c5"
|
|
59
|
-
* local: true
|
|
57
|
+
* apiKey: "4c8b7675-6b69-4f8d-9f43-5a6f7f02c6c5"
|
|
60
58
|
* });
|
|
61
59
|
*/
|
|
62
|
-
constructor({ rootApiKey = null, apiKey = null,
|
|
60
|
+
constructor({ rootApiKey = null, apiKey = null, baseUrl = "https://api.tpeoficial.com", serverEmailConfig = undefined } = {}) {
|
|
63
61
|
this.rootApiKey = rootApiKey;
|
|
64
62
|
this.apiKey = apiKey;
|
|
65
63
|
this.serverEmailConfig = serverEmailConfig;
|
|
66
|
-
this.
|
|
67
|
-
(0, config_1.setBaseUrl)(
|
|
68
|
-
this.autoupdate();
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Checks for updates and logs a message if a new version is available.
|
|
72
|
-
*
|
|
73
|
-
* This method is called in the constructor and will throw an error if the
|
|
74
|
-
* update check fails.
|
|
75
|
-
*
|
|
76
|
-
* @throws Will throw an error if there is an issue with the update check
|
|
77
|
-
* process.
|
|
78
|
-
*/
|
|
79
|
-
async autoupdate() {
|
|
80
|
-
try {
|
|
81
|
-
await (0, autoupdate_1.checkForUpdates)();
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
console.error(`[${config_1.default.lib.name}] Error checking the latest version in npmjs: ${error.message}`);
|
|
85
|
-
}
|
|
64
|
+
this.baseUrl = baseUrl;
|
|
65
|
+
(0, config_1.setBaseUrl)(baseUrl);
|
|
86
66
|
}
|
|
87
67
|
// FUNCTIONS / Private.
|
|
88
68
|
/**
|
package/dist/esm/config/index.js
CHANGED
|
@@ -9,7 +9,10 @@ const config = {
|
|
|
9
9
|
};
|
|
10
10
|
export default config;
|
|
11
11
|
let BASE_URL = config.env.baseUrl;
|
|
12
|
-
export const setBaseUrl = (
|
|
13
|
-
|
|
12
|
+
export const setBaseUrl = (baseUrl) => {
|
|
13
|
+
if (/^(https:\/\/api\.tpeoficial\.com$|http:\/\/(localhost:\d+|dymoapi:\d+))$/.test(baseUrl))
|
|
14
|
+
BASE_URL = baseUrl;
|
|
15
|
+
else
|
|
16
|
+
throw new Error("[Dymo API] Invalid URL. It must be https://api.tpeoficial.com or start with http://localhost or http://dymoapi followed by a port.");
|
|
14
17
|
};
|
|
15
18
|
export { BASE_URL };
|
package/dist/esm/dymo-api.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as PublicAPI from "./branches/public.js";
|
|
2
2
|
import * as PrivateAPI from "./branches/private.js";
|
|
3
3
|
import config, { setBaseUrl } from "./config/index.js";
|
|
4
|
-
import { checkForUpdates } from "./services/autoupdate.js";
|
|
5
4
|
const customError = (code, message) => {
|
|
6
5
|
return Object.assign(new Error(), { code, message: `[${config.lib.name}] ${message}` });
|
|
7
6
|
};
|
|
@@ -10,7 +9,7 @@ class DymoAPI {
|
|
|
10
9
|
* @param {Object} options - Options to create the DymoAPI instance.
|
|
11
10
|
* @param {string} [options.rootApiKey] - The root API key.
|
|
12
11
|
* @param {string} [options.apiKey] - The API key.
|
|
13
|
-
* @param {
|
|
12
|
+
* @param {string} [options.baseUrl] - Whether to use a local server instead of the cloud server.
|
|
14
13
|
* @param {Object} [options.serverEmailConfig] - The server email config.
|
|
15
14
|
* @description
|
|
16
15
|
* This is the main class to interact with the Dymo API. It should be
|
|
@@ -20,34 +19,15 @@ class DymoAPI {
|
|
|
20
19
|
* @example
|
|
21
20
|
* const dymoApi = new DymoAPI({
|
|
22
21
|
* rootApiKey: "6bfb7675-6b69-4f8d-9f43-5a6f7f02c6c5",
|
|
23
|
-
* apiKey: "4c8b7675-6b69-4f8d-9f43-5a6f7f02c6c5"
|
|
24
|
-
* local: true
|
|
22
|
+
* apiKey: "4c8b7675-6b69-4f8d-9f43-5a6f7f02c6c5"
|
|
25
23
|
* });
|
|
26
24
|
*/
|
|
27
|
-
constructor({ rootApiKey = null, apiKey = null,
|
|
25
|
+
constructor({ rootApiKey = null, apiKey = null, baseUrl = "https://api.tpeoficial.com", serverEmailConfig = undefined } = {}) {
|
|
28
26
|
this.rootApiKey = rootApiKey;
|
|
29
27
|
this.apiKey = apiKey;
|
|
30
28
|
this.serverEmailConfig = serverEmailConfig;
|
|
31
|
-
this.
|
|
32
|
-
setBaseUrl(
|
|
33
|
-
this.autoupdate();
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Checks for updates and logs a message if a new version is available.
|
|
37
|
-
*
|
|
38
|
-
* This method is called in the constructor and will throw an error if the
|
|
39
|
-
* update check fails.
|
|
40
|
-
*
|
|
41
|
-
* @throws Will throw an error if there is an issue with the update check
|
|
42
|
-
* process.
|
|
43
|
-
*/
|
|
44
|
-
async autoupdate() {
|
|
45
|
-
try {
|
|
46
|
-
await checkForUpdates();
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
console.error(`[${config.lib.name}] Error checking the latest version in npmjs: ${error.message}`);
|
|
50
|
-
}
|
|
29
|
+
this.baseUrl = baseUrl;
|
|
30
|
+
setBaseUrl(baseUrl);
|
|
51
31
|
}
|
|
52
32
|
// FUNCTIONS / Private.
|
|
53
33
|
/**
|
package/dist/types/dymo-api.d.ts
CHANGED
|
@@ -3,12 +3,12 @@ declare class DymoAPI {
|
|
|
3
3
|
private rootApiKey;
|
|
4
4
|
private apiKey;
|
|
5
5
|
private serverEmailConfig?;
|
|
6
|
-
private
|
|
6
|
+
private baseUrl;
|
|
7
7
|
/**
|
|
8
8
|
* @param {Object} options - Options to create the DymoAPI instance.
|
|
9
9
|
* @param {string} [options.rootApiKey] - The root API key.
|
|
10
10
|
* @param {string} [options.apiKey] - The API key.
|
|
11
|
-
* @param {
|
|
11
|
+
* @param {string} [options.baseUrl] - Whether to use a local server instead of the cloud server.
|
|
12
12
|
* @param {Object} [options.serverEmailConfig] - The server email config.
|
|
13
13
|
* @description
|
|
14
14
|
* This is the main class to interact with the Dymo API. It should be
|
|
@@ -18,26 +18,15 @@ declare class DymoAPI {
|
|
|
18
18
|
* @example
|
|
19
19
|
* const dymoApi = new DymoAPI({
|
|
20
20
|
* rootApiKey: "6bfb7675-6b69-4f8d-9f43-5a6f7f02c6c5",
|
|
21
|
-
* apiKey: "4c8b7675-6b69-4f8d-9f43-5a6f7f02c6c5"
|
|
22
|
-
* local: true
|
|
21
|
+
* apiKey: "4c8b7675-6b69-4f8d-9f43-5a6f7f02c6c5"
|
|
23
22
|
* });
|
|
24
23
|
*/
|
|
25
|
-
constructor({ rootApiKey, apiKey,
|
|
24
|
+
constructor({ rootApiKey, apiKey, baseUrl, serverEmailConfig }?: {
|
|
26
25
|
rootApiKey?: string | null;
|
|
27
26
|
apiKey?: string | null;
|
|
28
|
-
|
|
27
|
+
baseUrl?: string;
|
|
29
28
|
serverEmailConfig?: Interfaces.ServerEmailConfig;
|
|
30
29
|
});
|
|
31
|
-
/**
|
|
32
|
-
* Checks for updates and logs a message if a new version is available.
|
|
33
|
-
*
|
|
34
|
-
* This method is called in the constructor and will throw an error if the
|
|
35
|
-
* update check fails.
|
|
36
|
-
*
|
|
37
|
-
* @throws Will throw an error if there is an issue with the update check
|
|
38
|
-
* process.
|
|
39
|
-
*/
|
|
40
|
-
private autoupdate;
|
|
41
30
|
/**
|
|
42
31
|
* Validates the given data against the configured validation settings.
|
|
43
32
|
*
|
package/package.json
CHANGED
|
@@ -1,27 +0,0 @@
|
|
|
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"));
|
|
8
|
-
//@ts-ignore
|
|
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() {
|
|
12
|
-
try {
|
|
13
|
-
const response = await axios_1.default.get("https://registry.npmjs.org/dymo-api/latest");
|
|
14
|
-
const latestVersion = response.data.version;
|
|
15
|
-
if (localVersion !== latestVersion)
|
|
16
|
-
console.log(`[Dymo API] A new version of dymo-api is available: ${latestVersion}. You are using ${localVersion}. Consider updating.`);
|
|
17
|
-
}
|
|
18
|
-
catch (error) {
|
|
19
|
-
if (error.response)
|
|
20
|
-
console.error("[Dymo API] Error fetching the latest version:", error.response.data);
|
|
21
|
-
else if (error.request)
|
|
22
|
-
console.error("[Dymo API] No response received from the server:", error.request);
|
|
23
|
-
else
|
|
24
|
-
console.error("[Dymo API] An unknown error occurred:", error.message);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
//@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() {
|
|
6
|
-
try {
|
|
7
|
-
const response = await axios.get("https://registry.npmjs.org/dymo-api/latest");
|
|
8
|
-
const latestVersion = response.data.version;
|
|
9
|
-
if (localVersion !== latestVersion)
|
|
10
|
-
console.log(`[Dymo API] A new version of dymo-api is available: ${latestVersion}. You are using ${localVersion}. Consider updating.`);
|
|
11
|
-
}
|
|
12
|
-
catch (error) {
|
|
13
|
-
if (error.response)
|
|
14
|
-
console.error("[Dymo API] Error fetching the latest version:", error.response.data);
|
|
15
|
-
else if (error.request)
|
|
16
|
-
console.error("[Dymo API] No response received from the server:", error.request);
|
|
17
|
-
else
|
|
18
|
-
console.error("[Dymo API] An unknown error occurred:", error.message);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function checkForUpdates(): Promise<void>;
|