dymo-api 1.0.28 → 1.0.29

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/dymo-api.js CHANGED
@@ -30,6 +30,7 @@ const axios_1 = __importDefault(require("axios"));
30
30
  const PublicAPI = __importStar(require("./branches/public"));
31
31
  const PrivateAPI = __importStar(require("./branches/private"));
32
32
  const config_1 = __importStar(require("./config"));
33
+ const autoupdate_1 = require("./services/autoupdate");
33
34
  const customError = (code, message) => {
34
35
  return Object.assign(new Error(), { code, message: `[${config_1.default.lib.name}] ${message}` });
35
36
  };
@@ -45,6 +46,7 @@ class DymoAPI {
45
46
  this.serverEmailConfig = serverEmailConfig;
46
47
  this.local = rootApiKey ? local : false; // Only allow setting local if rootApiKey is defined.
47
48
  (0, config_1.setBaseUrl)(this.local);
49
+ this.autoupdate();
48
50
  this.initializeTokens(); // Calls the function to obtain tokens when creating the object.
49
51
  }
50
52
  getBaseUrl() {
@@ -87,12 +89,20 @@ class DymoAPI {
87
89
  throw customError(5000, `Error initializing tokens: ${error.message}`);
88
90
  }
89
91
  }
92
+ async autoupdate() {
93
+ try {
94
+ await (0, autoupdate_1.checkForUpdates)();
95
+ }
96
+ catch (error) {
97
+ throw customError(5000, `Error checking the latest version in npmjs: ${error.message}`);
98
+ }
99
+ }
90
100
  // FUNCTIONS / Private.
91
101
  async isValidData(data) {
92
102
  return await PrivateAPI.isValidData(this.apiKey, data);
93
103
  }
94
104
  async sendEmail(data) {
95
- if (this.serverEmailConfig)
105
+ if (!this.serverEmailConfig)
96
106
  throw customError(5000, `You must configure the email client settings.`);
97
107
  return await PrivateAPI.sendEmail(this.apiKey, { serverEmailConfig: this.serverEmailConfig, ...data });
98
108
  }
package/dist/dymo-api.mjs CHANGED
@@ -30,6 +30,7 @@ const axios_1 = __importDefault(require("axios"));
30
30
  const PublicAPI = __importStar(require("./branches/public"));
31
31
  const PrivateAPI = __importStar(require("./branches/private"));
32
32
  const config_1 = __importStar(require("./config"));
33
+ const autoupdate_1 = require("./services/autoupdate");
33
34
  const customError = (code, message) => {
34
35
  return Object.assign(new Error(), { code, message: `[${config_1.default.lib.name}] ${message}` });
35
36
  };
@@ -45,6 +46,7 @@ class DymoAPI {
45
46
  this.serverEmailConfig = serverEmailConfig;
46
47
  this.local = rootApiKey ? local : false; // Only allow setting local if rootApiKey is defined.
47
48
  (0, config_1.setBaseUrl)(this.local);
49
+ this.autoupdate();
48
50
  this.initializeTokens(); // Calls the function to obtain tokens when creating the object.
49
51
  }
50
52
  getBaseUrl() {
@@ -87,12 +89,20 @@ class DymoAPI {
87
89
  throw customError(5000, `Error initializing tokens: ${error.message}`);
88
90
  }
89
91
  }
92
+ async autoupdate() {
93
+ try {
94
+ await (0, autoupdate_1.checkForUpdates)();
95
+ }
96
+ catch (error) {
97
+ throw customError(5000, `Error checking the latest version in npmjs: ${error.message}`);
98
+ }
99
+ }
90
100
  // FUNCTIONS / Private.
91
101
  async isValidData(data) {
92
102
  return await PrivateAPI.isValidData(this.apiKey, data);
93
103
  }
94
104
  async sendEmail(data) {
95
- if (this.serverEmailConfig)
105
+ if (!this.serverEmailConfig)
96
106
  throw customError(5000, `You must configure the email client settings.`);
97
107
  return await PrivateAPI.sendEmail(this.apiKey, { serverEmailConfig: this.serverEmailConfig, ...data });
98
108
  }
@@ -0,0 +1,28 @@
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
+ const child_process_1 = require("child_process");
9
+ 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";
10
+ async function checkForUpdates() {
11
+ try {
12
+ const response = await axios_1.default.get(`https://registry.npmjs.org/dymo-api/latest`);
13
+ const latestVersion = response.data.version;
14
+ if (localVersion !== latestVersion)
15
+ console.log(`A new version of dymo-api is available: ${latestVersion}. You are using ${localVersion}. Consider updating.`);
16
+ else
17
+ console.log(`You are using the latest version of dymo-api: ${localVersion}.`);
18
+ }
19
+ catch (error) {
20
+ if (error.response)
21
+ console.error("Error fetching the latest version:", error.response.data);
22
+ else if (error.request)
23
+ console.error("No response received from the server:", error.request);
24
+ else
25
+ console.error("An unknown error occurred:", error.message);
26
+ }
27
+ }
28
+ ;
@@ -6,6 +6,11 @@ interface ServerEmailConfig {
6
6
  user: string;
7
7
  pass: string;
8
8
  };
9
+ dkim?: {
10
+ domainName: string;
11
+ keySelector: string;
12
+ privateKey: string;
13
+ };
9
14
  }
10
15
  declare class DymoAPI {
11
16
  private rootApiKey;
@@ -23,6 +28,7 @@ declare class DymoAPI {
23
28
  private getBaseUrl;
24
29
  private getTokens;
25
30
  private initializeTokens;
31
+ private autoupdate;
26
32
  isValidData(data: any): Promise<any>;
27
33
  sendEmail(data: any): Promise<any>;
28
34
  getRandom(data: any): Promise<any>;
@@ -0,0 +1 @@
1
+ export declare function checkForUpdates(): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dymo-api",
3
- "version": "1.0.28",
3
+ "version": "1.0.29",
4
4
  "description": "Flow system for Dymo API.",
5
5
  "main": "dist/dymo-api.js",
6
6
  "module": "dist/dymo-api.mjs",