dymo-api 1.0.85 → 1.0.87

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.
@@ -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 = (isLocal) => {
17
- exports.BASE_URL = BASE_URL = isLocal ? "http://localhost:3050" : config.env.baseUrl;
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;
@@ -45,7 +45,7 @@ class DymoAPI {
45
45
  * @param {Object} options - Options to create the DymoAPI instance.
46
46
  * @param {string} [options.rootApiKey] - The root API key.
47
47
  * @param {string} [options.apiKey] - The API key.
48
- * @param {boolean} [options.local] - Whether to use a local server instead of the cloud server.
48
+ * @param {string} [options.baseUrl] - Whether to use a local server instead of the cloud server.
49
49
  * @param {Object} [options.serverEmailConfig] - The server email config.
50
50
  * @description
51
51
  * This is the main class to interact with the Dymo API. It should be
@@ -55,16 +55,15 @@ class DymoAPI {
55
55
  * @example
56
56
  * const dymoApi = new DymoAPI({
57
57
  * rootApiKey: "6bfb7675-6b69-4f8d-9f43-5a6f7f02c6c5",
58
- * apiKey: "4c8b7675-6b69-4f8d-9f43-5a6f7f02c6c5",
59
- * local: true
58
+ * apiKey: "4c8b7675-6b69-4f8d-9f43-5a6f7f02c6c5"
60
59
  * });
61
60
  */
62
- constructor({ rootApiKey = null, apiKey = null, local = false, serverEmailConfig = undefined } = {}) {
61
+ constructor({ rootApiKey = null, apiKey = null, baseUrl = "https://api.tpeoficial.com", serverEmailConfig = undefined } = {}) {
63
62
  this.rootApiKey = rootApiKey;
64
63
  this.apiKey = apiKey;
65
64
  this.serverEmailConfig = serverEmailConfig;
66
- this.local = rootApiKey ? local : false; // Only allow setting local if rootApiKey is defined.
67
- (0, config_1.setBaseUrl)(this.local);
65
+ this.baseUrl = baseUrl;
66
+ (0, config_1.setBaseUrl)(baseUrl);
68
67
  this.autoupdate();
69
68
  }
70
69
  /**
@@ -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 = (isLocal) => {
13
- BASE_URL = isLocal ? "http://localhost:3050" : config.env.baseUrl;
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 };
@@ -10,7 +10,7 @@ class DymoAPI {
10
10
  * @param {Object} options - Options to create the DymoAPI instance.
11
11
  * @param {string} [options.rootApiKey] - The root API key.
12
12
  * @param {string} [options.apiKey] - The API key.
13
- * @param {boolean} [options.local] - Whether to use a local server instead of the cloud server.
13
+ * @param {string} [options.baseUrl] - Whether to use a local server instead of the cloud server.
14
14
  * @param {Object} [options.serverEmailConfig] - The server email config.
15
15
  * @description
16
16
  * This is the main class to interact with the Dymo API. It should be
@@ -20,16 +20,15 @@ class DymoAPI {
20
20
  * @example
21
21
  * const dymoApi = new DymoAPI({
22
22
  * rootApiKey: "6bfb7675-6b69-4f8d-9f43-5a6f7f02c6c5",
23
- * apiKey: "4c8b7675-6b69-4f8d-9f43-5a6f7f02c6c5",
24
- * local: true
23
+ * apiKey: "4c8b7675-6b69-4f8d-9f43-5a6f7f02c6c5"
25
24
  * });
26
25
  */
27
- constructor({ rootApiKey = null, apiKey = null, local = false, serverEmailConfig = undefined } = {}) {
26
+ constructor({ rootApiKey = null, apiKey = null, baseUrl = "https://api.tpeoficial.com", serverEmailConfig = undefined } = {}) {
28
27
  this.rootApiKey = rootApiKey;
29
28
  this.apiKey = apiKey;
30
29
  this.serverEmailConfig = serverEmailConfig;
31
- this.local = rootApiKey ? local : false; // Only allow setting local if rootApiKey is defined.
32
- setBaseUrl(this.local);
30
+ this.baseUrl = baseUrl;
31
+ setBaseUrl(baseUrl);
33
32
  this.autoupdate();
34
33
  }
35
34
  /**
@@ -9,5 +9,5 @@ declare const config: {
9
9
  };
10
10
  export default config;
11
11
  declare let BASE_URL: string;
12
- export declare const setBaseUrl: (isLocal: boolean) => void;
12
+ export declare const setBaseUrl: (baseUrl: string) => void;
13
13
  export { BASE_URL };
@@ -3,12 +3,12 @@ declare class DymoAPI {
3
3
  private rootApiKey;
4
4
  private apiKey;
5
5
  private serverEmailConfig?;
6
- private local;
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 {boolean} [options.local] - Whether to use a local server instead of the cloud server.
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,14 +18,13 @@ 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, local, serverEmailConfig }?: {
24
+ constructor({ rootApiKey, apiKey, baseUrl, serverEmailConfig }?: {
26
25
  rootApiKey?: string | null;
27
26
  apiKey?: string | null;
28
- local?: boolean;
27
+ baseUrl?: string;
29
28
  serverEmailConfig?: Interfaces.ServerEmailConfig;
30
29
  });
31
30
  /**
@@ -1,3 +1,4 @@
1
+ import type * as React from "react";
1
2
  export interface PhoneData {
2
3
  iso: any;
3
4
  phone: string;
@@ -43,20 +44,24 @@ export interface ServerEmailConfig {
43
44
  privateKey: string;
44
45
  };
45
46
  }
46
- export interface SendEmail {
47
+ export type SendEmail = {
47
48
  from: string;
48
49
  to: string;
49
50
  subject: string;
50
- html?: string;
51
- react?: never;
51
+ attachments?: Attachment[];
52
52
  options?: {
53
- priority?: "high" | "normal" | "low" | undefined;
53
+ priority?: "high" | "normal" | "low";
54
54
  composeTailwindClasses?: boolean;
55
55
  compileToCssSafe?: boolean;
56
56
  onlyVerifiedEmails?: boolean;
57
57
  };
58
- attachments?: Attachment[];
59
- }
58
+ } & ({
59
+ html: string;
60
+ react?: never;
61
+ } | {
62
+ react: React.ReactNode;
63
+ html?: never;
64
+ });
60
65
  export interface PrayerTimesData {
61
66
  lat?: number;
62
67
  lon?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dymo-api",
3
- "version": "1.0.85",
3
+ "version": "1.0.87",
4
4
  "description": "Flow system for Dymo API.",
5
5
  "main": "dist/cjs/dymo-api.js",
6
6
  "module": "dist/esm/dymo-api.js",