dymo-api 1.2.4 → 1.2.6
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/README.md +82 -1
- package/dist/cjs/branches/private/functions/extractWithTextly/index.cjs +33 -0
- package/dist/cjs/branches/private/functions/getRandom/index.cjs +37 -0
- package/dist/cjs/branches/private/functions/isValidData/index.cjs +33 -0
- package/dist/cjs/branches/private/functions/isValidEmail/index.cjs +73 -0
- package/dist/cjs/branches/private/functions/sendEmail/index.cjs +88 -0
- package/dist/cjs/branches/private/index.cjs +21 -0
- package/dist/cjs/branches/public/functions/getPrayerTimes/index.cjs +31 -0
- package/dist/cjs/branches/public/functions/isValidPwd/index.cjs +65 -0
- package/dist/cjs/branches/public/functions/satinize/index.cjs +26 -0
- package/dist/cjs/branches/public/index.cjs +19 -0
- package/dist/cjs/config/index.cjs +0 -21
- package/dist/cjs/dymo-api.cjs +46 -15
- package/dist/cjs/lib/types/interfaces.cjs +0 -1
- package/dist/cjs/lib/types/well-known-bots.cjs +739 -0
- package/dist/cjs/utils/basics.cjs +18 -0
- package/dist/esm/branches/private/functions/extractWithTextly/index.js +29 -0
- package/dist/esm/branches/private/functions/getRandom/index.js +33 -0
- package/dist/esm/branches/private/functions/isValidData/index.js +29 -0
- package/dist/esm/branches/private/functions/isValidEmail/index.js +69 -0
- package/dist/esm/branches/private/functions/sendEmail/index.js +81 -0
- package/dist/esm/branches/private/index.js +5 -0
- package/dist/esm/branches/public/functions/getPrayerTimes/index.js +27 -0
- package/dist/esm/branches/{public.js → public/functions/isValidPwd/index.js} +28 -30
- package/dist/esm/branches/public/functions/satinize/index.js +22 -0
- package/dist/esm/branches/public/index.js +3 -0
- package/dist/esm/config/index.js +0 -15
- package/dist/esm/dymo-api.js +43 -15
- package/dist/esm/lib/types/interfaces.js +0 -1
- package/dist/esm/lib/types/well-known-bots.js +736 -0
- package/dist/esm/utils/basics.js +10 -0
- package/dist/types/branches/private/functions/extractWithTextly/index.d.ts +16 -0
- package/dist/types/branches/private/functions/getRandom/index.d.ts +16 -0
- package/dist/types/branches/private/functions/isValidData/index.d.ts +15 -0
- package/dist/types/branches/private/functions/isValidEmail/index.d.ts +20 -0
- package/dist/types/branches/private/functions/sendEmail/index.d.ts +18 -0
- package/dist/types/branches/private/index.d.ts +5 -0
- package/dist/types/branches/public/functions/getPrayerTimes/index.d.ts +17 -0
- package/dist/types/branches/public/functions/isValidPwd/index.d.ts +28 -0
- package/dist/types/branches/public/functions/satinize/index.d.ts +12 -0
- package/dist/types/branches/public/index.d.ts +3 -0
- package/dist/types/config/index.d.ts +0 -4
- package/dist/types/dymo-api.d.ts +18 -2
- package/dist/types/lib/types/interfaces.d.ts +0 -3
- package/dist/types/lib/types/rules.d.ts +10 -0
- package/dist/types/lib/types/well-known-bots.d.ts +4 -0
- package/dist/types/utils/basics.d.ts +2 -0
- package/package.json +12 -4
- package/dist/cjs/branches/private.cjs +0 -284
- package/dist/cjs/branches/public.cjs +0 -102
- package/dist/esm/branches/private.js +0 -240
- package/dist/types/branches/private.d.ts +0 -76
- package/dist/types/branches/public.d.ts +0 -4
package/dist/cjs/dymo-api.cjs
CHANGED
|
@@ -32,10 +32,15 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const config_1 =
|
|
37
|
-
const PublicAPI = __importStar(require("./branches/public.cjs"));
|
|
38
|
-
const PrivateAPI = __importStar(require("./branches/private.cjs"));
|
|
39
|
+
const config_1 = __importDefault(require("./config/index.cjs"));
|
|
40
|
+
const PublicAPI = __importStar(require("./branches/public/index.cjs"));
|
|
41
|
+
const PrivateAPI = __importStar(require("./branches/private/index.cjs"));
|
|
42
|
+
const axios_1 = __importDefault(require("axios"));
|
|
43
|
+
const basics_1 = require("./utils/basics.cjs");
|
|
39
44
|
const customError = (code, message) => {
|
|
40
45
|
return Object.assign(new Error(), { code, message: `[${config_1.default.lib.name}] ${message}` });
|
|
41
46
|
};
|
|
@@ -54,20 +59,30 @@ class DymoAPI {
|
|
|
54
59
|
* @example
|
|
55
60
|
* const dymoApi = new DymoAPI({
|
|
56
61
|
* rootApiKey: "6bfb7675-6b69-4f8d-9f43-5a6f7f02c6c5",
|
|
57
|
-
* apiKey: "
|
|
62
|
+
* apiKey: "dm_4c8b7675-6b69-4f8d-9f43-5a6f7f02c6c5"
|
|
58
63
|
* });
|
|
59
64
|
*/
|
|
60
65
|
constructor({ rootApiKey = null, apiKey = null, baseUrl = "https://api.tpeoficial.com", serverEmailConfig = undefined, rules = {} } = {}) {
|
|
61
66
|
this.rules = {
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
bot: { mode: "LIVE", allow: [] },
|
|
68
|
+
email: { mode: "LIVE", deny: ["FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"] },
|
|
69
|
+
sensitiveInfo: { mode: "LIVE", deny: ["EMAIL", "PHONE", "CREDIT_CARD"] },
|
|
64
70
|
...rules
|
|
65
71
|
};
|
|
66
72
|
this.rootApiKey = rootApiKey;
|
|
67
73
|
this.apiKey = apiKey;
|
|
68
74
|
this.serverEmailConfig = serverEmailConfig;
|
|
69
75
|
this.baseUrl = baseUrl;
|
|
70
|
-
|
|
76
|
+
// We created the Axios client with the appropriate settings.
|
|
77
|
+
this.axiosClient = axios_1.default.create({
|
|
78
|
+
baseURL: `${(0, basics_1.validBaseURL)(this.baseUrl)}/v1`,
|
|
79
|
+
headers: {
|
|
80
|
+
"User-Agent": "DymoAPISDK/1.0.0"
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
// We set the authorization in the Axios client to make requests.
|
|
84
|
+
if (this.rootApiKey || this.apiKey)
|
|
85
|
+
this.axiosClient.defaults.headers.Authorization = `Bearer ${this.rootApiKey || this.apiKey}`;
|
|
71
86
|
}
|
|
72
87
|
;
|
|
73
88
|
// FUNCTIONS / Private.
|
|
@@ -93,7 +108,7 @@ class DymoAPI {
|
|
|
93
108
|
* [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/data-verifier)
|
|
94
109
|
*/
|
|
95
110
|
async isValidData(data) {
|
|
96
|
-
return await PrivateAPI.isValidData(this.
|
|
111
|
+
return await PrivateAPI.isValidData(this.axiosClient, data);
|
|
97
112
|
}
|
|
98
113
|
;
|
|
99
114
|
/**
|
|
@@ -115,7 +130,7 @@ class DymoAPI {
|
|
|
115
130
|
* @see [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/data-verifier)
|
|
116
131
|
*/
|
|
117
132
|
async isValidEmail(email, rules = this.rules.email) {
|
|
118
|
-
return await PrivateAPI.isValidEmail(this.
|
|
133
|
+
return await PrivateAPI.isValidEmail(this.axiosClient, email, rules);
|
|
119
134
|
}
|
|
120
135
|
;
|
|
121
136
|
/**
|
|
@@ -147,7 +162,7 @@ class DymoAPI {
|
|
|
147
162
|
async sendEmail(data) {
|
|
148
163
|
if (!this.serverEmailConfig && !this.rootApiKey)
|
|
149
164
|
console.error(`[${config_1.default.lib.name}] You must configure the email client settings.`);
|
|
150
|
-
return await PrivateAPI.sendEmail(this.
|
|
165
|
+
return await PrivateAPI.sendEmail(this.axiosClient, { serverEmailConfig: this.serverEmailConfig, ...data });
|
|
151
166
|
}
|
|
152
167
|
;
|
|
153
168
|
/**
|
|
@@ -166,7 +181,7 @@ class DymoAPI {
|
|
|
166
181
|
* [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/secure-random-number-generator)
|
|
167
182
|
*/
|
|
168
183
|
async getRandom(data) {
|
|
169
|
-
return await PrivateAPI.getRandom(this.
|
|
184
|
+
return await PrivateAPI.getRandom(this.axiosClient, data);
|
|
170
185
|
}
|
|
171
186
|
;
|
|
172
187
|
/**
|
|
@@ -182,7 +197,7 @@ class DymoAPI {
|
|
|
182
197
|
* [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/textly/text-extraction)
|
|
183
198
|
*/
|
|
184
199
|
async extractWithTextly(data) {
|
|
185
|
-
return await PrivateAPI.extractWithTextly(this.
|
|
200
|
+
return await PrivateAPI.extractWithTextly(this.axiosClient, data);
|
|
186
201
|
}
|
|
187
202
|
;
|
|
188
203
|
// FUNCTIONS / Public.
|
|
@@ -201,13 +216,14 @@ class DymoAPI {
|
|
|
201
216
|
* [Documentation](https://docs.tpeoficial.com/docs/dymo-api/public/prayertimes)
|
|
202
217
|
*/
|
|
203
218
|
async getPrayerTimes(data) {
|
|
204
|
-
return await PublicAPI.getPrayerTimes(data);
|
|
219
|
+
return await PublicAPI.getPrayerTimes(this.axiosClient, data);
|
|
205
220
|
}
|
|
206
221
|
;
|
|
207
222
|
/**
|
|
208
223
|
* Satinizes the input, replacing any special characters with their HTML
|
|
209
224
|
* entities.
|
|
210
225
|
*
|
|
226
|
+
* @deprecated Use `satinize` instead. This feature will be removed soon.
|
|
211
227
|
* @param {Object} data - The data to be sent.
|
|
212
228
|
* @param {string} data.input - The input to be satinized.
|
|
213
229
|
* @returns {Promise<Interfaces.SatinizedInputAnalysis>} A promise that resolves to the response from the server.
|
|
@@ -216,7 +232,22 @@ class DymoAPI {
|
|
|
216
232
|
* [Documentation](https://docs.tpeoficial.com/docs/dymo-api/public/input-satinizer)
|
|
217
233
|
*/
|
|
218
234
|
async satinizer(data) {
|
|
219
|
-
return await PublicAPI.
|
|
235
|
+
return await PublicAPI.satinize(this.axiosClient, data.input);
|
|
236
|
+
}
|
|
237
|
+
;
|
|
238
|
+
/**
|
|
239
|
+
* Satinizes the input, replacing any special characters with their HTML
|
|
240
|
+
* entities.
|
|
241
|
+
*
|
|
242
|
+
* @param {Object} data - The data to be sent.
|
|
243
|
+
* @param {string} data.input - The input to be satinized.
|
|
244
|
+
* @returns {Promise<Interfaces.SatinizedInputAnalysis>} A promise that resolves to the response from the server.
|
|
245
|
+
* @throws Will throw an error if there is an issue with the satinization process.
|
|
246
|
+
*
|
|
247
|
+
* [Documentation](https://docs.tpeoficial.com/docs/dymo-api/public/input-satinizer)
|
|
248
|
+
*/
|
|
249
|
+
async satinize(input) {
|
|
250
|
+
return await PublicAPI.satinize(this.axiosClient, input);
|
|
220
251
|
}
|
|
221
252
|
;
|
|
222
253
|
/**
|
|
@@ -245,7 +276,7 @@ class DymoAPI {
|
|
|
245
276
|
* [Documentation](https://docs.tpeoficial.com/docs/dymo-api/public/password-validator)
|
|
246
277
|
*/
|
|
247
278
|
async isValidPwd(data) {
|
|
248
|
-
return await PublicAPI.isValidPwd(data);
|
|
279
|
+
return await PublicAPI.isValidPwd(this.axiosClient, data);
|
|
249
280
|
}
|
|
250
281
|
;
|
|
251
282
|
}
|