dymo-api 1.0.99 → 1.1.1
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.cjs +31 -2
- package/dist/cjs/dymo-api.cjs +16 -0
- package/dist/esm/branches/private.js +29 -1
- package/dist/esm/dymo-api.js +16 -0
- package/dist/types/branches/private.d.ts +14 -0
- package/dist/types/dymo-api.d.ts +14 -0
- package/dist/types/lib/interfaces.d.ts +40 -0
- package/package.json +1 -1
|
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.getRandom = exports.sendEmail = exports.isValidData = void 0;
|
|
39
|
+
exports.extractWithTextly = exports.getRandom = exports.sendEmail = exports.isValidData = void 0;
|
|
40
40
|
const path_1 = __importDefault(require("path"));
|
|
41
41
|
const react_1 = __importDefault(require("react"));
|
|
42
42
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
@@ -67,7 +67,7 @@ const convertTailwindToInlineCss = (htmlContent) => {
|
|
|
67
67
|
const isValidData = async (token, data) => {
|
|
68
68
|
if (token === null)
|
|
69
69
|
throw customError(3000, "Invalid private token.");
|
|
70
|
-
if (!Object.keys(data).some((key) => ["email", "phone", "domain", "creditCard", "ip", "wallet"].includes(key) && data.hasOwnProperty(key)))
|
|
70
|
+
if (!Object.keys(data).some((key) => ["url", "email", "phone", "domain", "creditCard", "ip", "wallet"].includes(key) && data.hasOwnProperty(key)))
|
|
71
71
|
throw customError(1500, "You must provide at least one parameter.");
|
|
72
72
|
try {
|
|
73
73
|
const response = await config_1.axiosApiUrl.post("/private/secure/verify", data, { headers: { "Content-Type": "application/json", "Authorization": token } });
|
|
@@ -184,3 +184,32 @@ const getRandom = async (token, data) => {
|
|
|
184
184
|
}
|
|
185
185
|
};
|
|
186
186
|
exports.getRandom = getRandom;
|
|
187
|
+
/**
|
|
188
|
+
* Extracts structured data from a given string using a secure endpoint.
|
|
189
|
+
*
|
|
190
|
+
* @param token - A string or null representing the authentication token. Must not be null.
|
|
191
|
+
* @param data - An object adhering to the ExtractWithTextly interface, containing 'data' and 'format' fields.
|
|
192
|
+
* The 'data' field is the string from which structured data should be extracted.
|
|
193
|
+
* The 'format' field is an object defining the structure of the data to be extracted.
|
|
194
|
+
*
|
|
195
|
+
* @returns A promise that resolves to the response data containing the extracted structured data.
|
|
196
|
+
*
|
|
197
|
+
* @throws Will throw an error if the token is null, if 'data' or 'format' are not defined,
|
|
198
|
+
* or if an error occurs during the request to the extraction endpoint.
|
|
199
|
+
*/
|
|
200
|
+
const extractWithTextly = async (token, data) => {
|
|
201
|
+
if (token === null)
|
|
202
|
+
throw customError(3000, "Invalid private token.");
|
|
203
|
+
if (!data.data)
|
|
204
|
+
throw customError(1500, "No data provided.");
|
|
205
|
+
if (!data.format)
|
|
206
|
+
throw customError(1500, "No format provided.");
|
|
207
|
+
try {
|
|
208
|
+
const response = await config_1.axiosApiUrl.post("/private/textly/extract", data, { headers: { "Content-Type": "application/json", "Authorization": token } });
|
|
209
|
+
return response.data;
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
throw customError(5000, error.response?.data?.message || error.message);
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
exports.extractWithTextly = extractWithTextly;
|
package/dist/cjs/dymo-api.cjs
CHANGED
|
@@ -72,6 +72,7 @@ class DymoAPI {
|
|
|
72
72
|
* If neither is set, it will throw an error.
|
|
73
73
|
*
|
|
74
74
|
* @param {Object} data - The data to be validated.
|
|
75
|
+
* @param {string} [data.url] - Optional URL to be validated.
|
|
75
76
|
* @param {string} [data.email] - Optional email address to be validated.
|
|
76
77
|
* @param {Interfaces.PhoneData} [data.phone] - Optional phone number data to be validated.
|
|
77
78
|
* @param {string} [data.domain] - Optional domain name to be validated.
|
|
@@ -136,6 +137,21 @@ class DymoAPI {
|
|
|
136
137
|
async getRandom(data) {
|
|
137
138
|
return await PrivateAPI.getRandom(this.rootApiKey || this.apiKey, data);
|
|
138
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Extracts structured data from a given string using Textly.
|
|
142
|
+
*
|
|
143
|
+
* This method requires either the root API key or the API key to be set.
|
|
144
|
+
* If neither is set, it will throw an error.
|
|
145
|
+
*
|
|
146
|
+
* @param {Interfaces.ExtractWithTextly} data - The data to be sent, containing the string to be processed and the format schema.
|
|
147
|
+
* @returns {Promise<any>} A promise that resolves to the extracted structured data.
|
|
148
|
+
* @throws Will throw an error if there is an issue with the extraction process.
|
|
149
|
+
*
|
|
150
|
+
* [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/textly/text-extraction)
|
|
151
|
+
*/
|
|
152
|
+
async extractWithTextly(data) {
|
|
153
|
+
return await PrivateAPI.extractWithTextly(this.rootApiKey || this.apiKey, data);
|
|
154
|
+
}
|
|
139
155
|
// FUNCTIONS / Public.
|
|
140
156
|
/**
|
|
141
157
|
* Retrieves the prayer times for the given location.
|
|
@@ -28,7 +28,7 @@ const convertTailwindToInlineCss = (htmlContent) => {
|
|
|
28
28
|
export const isValidData = async (token, data) => {
|
|
29
29
|
if (token === null)
|
|
30
30
|
throw customError(3000, "Invalid private token.");
|
|
31
|
-
if (!Object.keys(data).some((key) => ["email", "phone", "domain", "creditCard", "ip", "wallet"].includes(key) && data.hasOwnProperty(key)))
|
|
31
|
+
if (!Object.keys(data).some((key) => ["url", "email", "phone", "domain", "creditCard", "ip", "wallet"].includes(key) && data.hasOwnProperty(key)))
|
|
32
32
|
throw customError(1500, "You must provide at least one parameter.");
|
|
33
33
|
try {
|
|
34
34
|
const response = await axiosApiUrl.post("/private/secure/verify", data, { headers: { "Content-Type": "application/json", "Authorization": token } });
|
|
@@ -142,3 +142,31 @@ export const getRandom = async (token, data) => {
|
|
|
142
142
|
throw customError(5000, error.response?.data?.message || error.message);
|
|
143
143
|
}
|
|
144
144
|
};
|
|
145
|
+
/**
|
|
146
|
+
* Extracts structured data from a given string using a secure endpoint.
|
|
147
|
+
*
|
|
148
|
+
* @param token - A string or null representing the authentication token. Must not be null.
|
|
149
|
+
* @param data - An object adhering to the ExtractWithTextly interface, containing 'data' and 'format' fields.
|
|
150
|
+
* The 'data' field is the string from which structured data should be extracted.
|
|
151
|
+
* The 'format' field is an object defining the structure of the data to be extracted.
|
|
152
|
+
*
|
|
153
|
+
* @returns A promise that resolves to the response data containing the extracted structured data.
|
|
154
|
+
*
|
|
155
|
+
* @throws Will throw an error if the token is null, if 'data' or 'format' are not defined,
|
|
156
|
+
* or if an error occurs during the request to the extraction endpoint.
|
|
157
|
+
*/
|
|
158
|
+
export const extractWithTextly = async (token, data) => {
|
|
159
|
+
if (token === null)
|
|
160
|
+
throw customError(3000, "Invalid private token.");
|
|
161
|
+
if (!data.data)
|
|
162
|
+
throw customError(1500, "No data provided.");
|
|
163
|
+
if (!data.format)
|
|
164
|
+
throw customError(1500, "No format provided.");
|
|
165
|
+
try {
|
|
166
|
+
const response = await axiosApiUrl.post("/private/textly/extract", data, { headers: { "Content-Type": "application/json", "Authorization": token } });
|
|
167
|
+
return response.data;
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
throw customError(5000, error.response?.data?.message || error.message);
|
|
171
|
+
}
|
|
172
|
+
};
|
package/dist/esm/dymo-api.js
CHANGED
|
@@ -37,6 +37,7 @@ class DymoAPI {
|
|
|
37
37
|
* If neither is set, it will throw an error.
|
|
38
38
|
*
|
|
39
39
|
* @param {Object} data - The data to be validated.
|
|
40
|
+
* @param {string} [data.url] - Optional URL to be validated.
|
|
40
41
|
* @param {string} [data.email] - Optional email address to be validated.
|
|
41
42
|
* @param {Interfaces.PhoneData} [data.phone] - Optional phone number data to be validated.
|
|
42
43
|
* @param {string} [data.domain] - Optional domain name to be validated.
|
|
@@ -101,6 +102,21 @@ class DymoAPI {
|
|
|
101
102
|
async getRandom(data) {
|
|
102
103
|
return await PrivateAPI.getRandom(this.rootApiKey || this.apiKey, data);
|
|
103
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Extracts structured data from a given string using Textly.
|
|
107
|
+
*
|
|
108
|
+
* This method requires either the root API key or the API key to be set.
|
|
109
|
+
* If neither is set, it will throw an error.
|
|
110
|
+
*
|
|
111
|
+
* @param {Interfaces.ExtractWithTextly} data - The data to be sent, containing the string to be processed and the format schema.
|
|
112
|
+
* @returns {Promise<any>} A promise that resolves to the extracted structured data.
|
|
113
|
+
* @throws Will throw an error if there is an issue with the extraction process.
|
|
114
|
+
*
|
|
115
|
+
* [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/textly/text-extraction)
|
|
116
|
+
*/
|
|
117
|
+
async extractWithTextly(data) {
|
|
118
|
+
return await PrivateAPI.extractWithTextly(this.rootApiKey || this.apiKey, data);
|
|
119
|
+
}
|
|
104
120
|
// FUNCTIONS / Public.
|
|
105
121
|
/**
|
|
106
122
|
* Retrieves the prayer times for the given location.
|
|
@@ -42,3 +42,17 @@ export declare const sendEmail: (token: string | null, data: Interfaces.SendEmai
|
|
|
42
42
|
* or if an error occurs during the request to the random number generator endpoint.
|
|
43
43
|
*/
|
|
44
44
|
export declare const getRandom: (token: string | null, data: Interfaces.SRNG) => Promise<any>;
|
|
45
|
+
/**
|
|
46
|
+
* Extracts structured data from a given string using a secure endpoint.
|
|
47
|
+
*
|
|
48
|
+
* @param token - A string or null representing the authentication token. Must not be null.
|
|
49
|
+
* @param data - An object adhering to the ExtractWithTextly interface, containing 'data' and 'format' fields.
|
|
50
|
+
* The 'data' field is the string from which structured data should be extracted.
|
|
51
|
+
* The 'format' field is an object defining the structure of the data to be extracted.
|
|
52
|
+
*
|
|
53
|
+
* @returns A promise that resolves to the response data containing the extracted structured data.
|
|
54
|
+
*
|
|
55
|
+
* @throws Will throw an error if the token is null, if 'data' or 'format' are not defined,
|
|
56
|
+
* or if an error occurs during the request to the extraction endpoint.
|
|
57
|
+
*/
|
|
58
|
+
export declare const extractWithTextly: (token: string | null, data: Interfaces.ExtractWithTextly) => Promise<any>;
|
package/dist/types/dymo-api.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ declare class DymoAPI {
|
|
|
34
34
|
* If neither is set, it will throw an error.
|
|
35
35
|
*
|
|
36
36
|
* @param {Object} data - The data to be validated.
|
|
37
|
+
* @param {string} [data.url] - Optional URL to be validated.
|
|
37
38
|
* @param {string} [data.email] - Optional email address to be validated.
|
|
38
39
|
* @param {Interfaces.PhoneData} [data.phone] - Optional phone number data to be validated.
|
|
39
40
|
* @param {string} [data.domain] - Optional domain name to be validated.
|
|
@@ -90,6 +91,19 @@ declare class DymoAPI {
|
|
|
90
91
|
* [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/secure-random-number-generator)
|
|
91
92
|
*/
|
|
92
93
|
getRandom(data: Interfaces.SRNG): Promise<Interfaces.SRNSummary>;
|
|
94
|
+
/**
|
|
95
|
+
* Extracts structured data from a given string using Textly.
|
|
96
|
+
*
|
|
97
|
+
* This method requires either the root API key or the API key to be set.
|
|
98
|
+
* If neither is set, it will throw an error.
|
|
99
|
+
*
|
|
100
|
+
* @param {Interfaces.ExtractWithTextly} data - The data to be sent, containing the string to be processed and the format schema.
|
|
101
|
+
* @returns {Promise<any>} A promise that resolves to the extracted structured data.
|
|
102
|
+
* @throws Will throw an error if there is an issue with the extraction process.
|
|
103
|
+
*
|
|
104
|
+
* [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/textly/text-extraction)
|
|
105
|
+
*/
|
|
106
|
+
extractWithTextly(data: Interfaces.ExtractWithTextly): Promise<any>;
|
|
93
107
|
/**
|
|
94
108
|
* Retrieves the prayer times for the given location.
|
|
95
109
|
*
|
|
@@ -11,6 +11,7 @@ export interface CreditCardData {
|
|
|
11
11
|
}
|
|
12
12
|
export type VerifyPlugins = "blocklist" | "compromiseDetector" | "nsfw" | "reputation" | "torNetwork" | "typosquatting" | "urlShortener";
|
|
13
13
|
export interface Validator {
|
|
14
|
+
url?: string;
|
|
14
15
|
email?: string;
|
|
15
16
|
phone?: PhoneData;
|
|
16
17
|
domain?: string;
|
|
@@ -164,6 +165,23 @@ export interface PasswordValidationResult {
|
|
|
164
165
|
details: ValidationDetail[];
|
|
165
166
|
}
|
|
166
167
|
export interface DataValidationAnalysis {
|
|
168
|
+
url: {
|
|
169
|
+
valid: boolean;
|
|
170
|
+
fraud: boolean;
|
|
171
|
+
freeSubdomain: boolean;
|
|
172
|
+
customTLD: boolean;
|
|
173
|
+
url: string;
|
|
174
|
+
domain: string;
|
|
175
|
+
plugins: {
|
|
176
|
+
blocklist?: boolean;
|
|
177
|
+
compromiseDetector?: boolean;
|
|
178
|
+
nsfw?: boolean;
|
|
179
|
+
reputation?: "low" | "medium" | "high" | "very-high" | "education" | "governmental" | "unknown";
|
|
180
|
+
torNetwork?: boolean;
|
|
181
|
+
typosquatting?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
|
|
182
|
+
urlShortener?: boolean;
|
|
183
|
+
};
|
|
184
|
+
};
|
|
167
185
|
email: {
|
|
168
186
|
valid: boolean;
|
|
169
187
|
fraud: boolean;
|
|
@@ -274,3 +292,25 @@ export interface DataValidationAnalysis {
|
|
|
274
292
|
};
|
|
275
293
|
};
|
|
276
294
|
}
|
|
295
|
+
export type SchemaType = "string" | "number" | "boolean" | "array" | "object";
|
|
296
|
+
export interface JsonSchemaProperty {
|
|
297
|
+
type: SchemaType;
|
|
298
|
+
items?: JsonSchemaProperty;
|
|
299
|
+
properties?: Record<string, JsonSchemaProperty>;
|
|
300
|
+
required?: string[];
|
|
301
|
+
description?: string;
|
|
302
|
+
format?: string;
|
|
303
|
+
enum?: unknown[];
|
|
304
|
+
minimum?: number;
|
|
305
|
+
maximum?: number;
|
|
306
|
+
minLength?: number;
|
|
307
|
+
maxLength?: number;
|
|
308
|
+
pattern?: string;
|
|
309
|
+
[key: string]: unknown;
|
|
310
|
+
}
|
|
311
|
+
export interface ExtractWithTextly {
|
|
312
|
+
data: string;
|
|
313
|
+
format: {
|
|
314
|
+
[key: string]: JsonSchemaProperty;
|
|
315
|
+
};
|
|
316
|
+
}
|