@apiverve/unicodeescape 1.1.12 → 1.1.13
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 +68 -11
- package/index.d.ts +9 -3
- package/index.js +100 -9
- package/package.json +17 -4
- package/examples/basic.js +0 -39
- package/tmp/build.dat +0 -1
package/README.md
CHANGED
|
@@ -5,8 +5,9 @@ Unicode Escape/Unescape is a tool for converting characters to Unicode escape se
|
|
|
5
5
|

|
|
6
6
|

|
|
7
7
|

|
|
8
|
+
[](https://www.npmjs.com/package/@apiverve/unicodeescape)
|
|
8
9
|
|
|
9
|
-
This is a Javascript Wrapper for the [Unicode Escape/Unescape API](https://apiverve.com/marketplace/unicodeescape)
|
|
10
|
+
This is a Javascript Wrapper for the [Unicode Escape/Unescape API](https://apiverve.com/marketplace/unicodeescape?utm_source=npm&utm_medium=readme)
|
|
10
11
|
|
|
11
12
|
---
|
|
12
13
|
|
|
@@ -27,15 +28,15 @@ yarn add @apiverve/unicodeescape
|
|
|
27
28
|
## Configuration
|
|
28
29
|
|
|
29
30
|
Before using the Unicode Escape/Unescape API client, you have to setup your account and obtain your API Key.
|
|
30
|
-
You can get it by signing up at [https://apiverve.com](https://apiverve.com)
|
|
31
|
+
You can get it by signing up at [https://apiverve.com](https://apiverve.com?utm_source=npm&utm_medium=readme)
|
|
31
32
|
|
|
32
33
|
---
|
|
33
34
|
|
|
34
35
|
## Quick Start
|
|
35
36
|
|
|
36
|
-
[Get started with the Quick Start Guide](https://docs.apiverve.com/quickstart)
|
|
37
|
+
[Get started with the Quick Start Guide](https://docs.apiverve.com/quickstart?utm_source=npm&utm_medium=readme)
|
|
37
38
|
|
|
38
|
-
The Unicode Escape/Unescape API documentation is found here: [https://docs.apiverve.com/ref/unicodeescape](https://docs.apiverve.com/ref/unicodeescape).
|
|
39
|
+
The Unicode Escape/Unescape API documentation is found here: [https://docs.apiverve.com/ref/unicodeescape](https://docs.apiverve.com/ref/unicodeescape?utm_source=npm&utm_medium=readme).
|
|
39
40
|
You can find parameters, example responses, and status codes documented here.
|
|
40
41
|
|
|
41
42
|
### Setup
|
|
@@ -125,10 +126,66 @@ async function makeRequest() {
|
|
|
125
126
|
"error": null,
|
|
126
127
|
"data": {
|
|
127
128
|
"action": "escape",
|
|
128
|
-
"original": "Hello
|
|
129
|
-
"
|
|
130
|
-
"character_count":
|
|
131
|
-
"
|
|
129
|
+
"original": "Hello World",
|
|
130
|
+
"escaped": "\\u0048\\u0065\\u006C\\u006C\\u006F\\u0020\\u0057\\u006F\\u0072\\u006C\\u0064",
|
|
131
|
+
"character_count": 11,
|
|
132
|
+
"unicode_points": [
|
|
133
|
+
{
|
|
134
|
+
"char": "H",
|
|
135
|
+
"unicode": "\\u0048",
|
|
136
|
+
"codepoint": "U+0048"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"char": "e",
|
|
140
|
+
"unicode": "\\u0065",
|
|
141
|
+
"codepoint": "U+0065"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"char": "l",
|
|
145
|
+
"unicode": "\\u006C",
|
|
146
|
+
"codepoint": "U+006C"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"char": "l",
|
|
150
|
+
"unicode": "\\u006C",
|
|
151
|
+
"codepoint": "U+006C"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"char": "o",
|
|
155
|
+
"unicode": "\\u006F",
|
|
156
|
+
"codepoint": "U+006F"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"char": " ",
|
|
160
|
+
"unicode": "\\u0020",
|
|
161
|
+
"codepoint": "U+0020"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"char": "W",
|
|
165
|
+
"unicode": "\\u0057",
|
|
166
|
+
"codepoint": "U+0057"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"char": "o",
|
|
170
|
+
"unicode": "\\u006F",
|
|
171
|
+
"codepoint": "U+006F"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"char": "r",
|
|
175
|
+
"unicode": "\\u0072",
|
|
176
|
+
"codepoint": "U+0072"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"char": "l",
|
|
180
|
+
"unicode": "\\u006C",
|
|
181
|
+
"codepoint": "U+006C"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"char": "d",
|
|
185
|
+
"unicode": "\\u0064",
|
|
186
|
+
"codepoint": "U+0064"
|
|
187
|
+
}
|
|
188
|
+
]
|
|
132
189
|
}
|
|
133
190
|
}
|
|
134
191
|
```
|
|
@@ -137,7 +194,7 @@ async function makeRequest() {
|
|
|
137
194
|
|
|
138
195
|
## Customer Support
|
|
139
196
|
|
|
140
|
-
Need any assistance? [Get in touch with Customer Support](https://apiverve.com/contact).
|
|
197
|
+
Need any assistance? [Get in touch with Customer Support](https://apiverve.com/contact?utm_source=npm&utm_medium=readme).
|
|
141
198
|
|
|
142
199
|
---
|
|
143
200
|
|
|
@@ -149,14 +206,14 @@ Stay up to date by following [@apiverveHQ](https://twitter.com/apiverveHQ) on Tw
|
|
|
149
206
|
|
|
150
207
|
## Legal
|
|
151
208
|
|
|
152
|
-
All usage of the APIVerve website, API, and services is subject to the [APIVerve Terms of Service](https://apiverve.com/terms)
|
|
209
|
+
All usage of the APIVerve website, API, and services is subject to the [APIVerve Terms of Service](https://apiverve.com/terms?utm_source=npm&utm_medium=readme), [Privacy Policy](https://apiverve.com/privacy?utm_source=npm&utm_medium=readme), and [Refund Policy](https://apiverve.com/refund?utm_source=npm&utm_medium=readme).
|
|
153
210
|
|
|
154
211
|
---
|
|
155
212
|
|
|
156
213
|
## License
|
|
157
214
|
Licensed under the The MIT License (MIT)
|
|
158
215
|
|
|
159
|
-
Copyright (©)
|
|
216
|
+
Copyright (©) 2026 APIVerve, and EvlarSoft LLC
|
|
160
217
|
|
|
161
218
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
162
219
|
|
package/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ declare module '@apiverve/unicodeescape' {
|
|
|
7
7
|
export interface unicodeescapeResponse {
|
|
8
8
|
status: string;
|
|
9
9
|
error: string | null;
|
|
10
|
-
data:
|
|
10
|
+
data: UnicodeEscapeUnescapeData;
|
|
11
11
|
code?: number;
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -15,9 +15,15 @@ declare module '@apiverve/unicodeescape' {
|
|
|
15
15
|
interface UnicodeEscapeUnescapeData {
|
|
16
16
|
action: string;
|
|
17
17
|
original: string;
|
|
18
|
-
|
|
18
|
+
escaped: string;
|
|
19
19
|
characterCount: number;
|
|
20
|
-
|
|
20
|
+
unicodePoints: UnicodePoint[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface UnicodePoint {
|
|
24
|
+
char: string;
|
|
25
|
+
unicode: string;
|
|
26
|
+
codepoint: string;
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
export default class unicodeescapeWrapper {
|
package/index.js
CHANGED
|
@@ -34,6 +34,102 @@ class unicodeescapeWrapper {
|
|
|
34
34
|
|
|
35
35
|
// secure is deprecated, all requests must be made over HTTPS
|
|
36
36
|
this.baseURL = 'https://api.apiverve.com/v1/unicodeescape';
|
|
37
|
+
|
|
38
|
+
// Validation rules for parameters (generated from schema)
|
|
39
|
+
this.validationRules = {"text":{"type":"string","required":true},"action":{"type":"string","required":false,"default":"escape"}};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Validate query parameters against schema rules
|
|
44
|
+
* @param {Object} query - The query parameters to validate
|
|
45
|
+
* @throws {Error} - If validation fails
|
|
46
|
+
*/
|
|
47
|
+
validateParams(query) {
|
|
48
|
+
const errors = [];
|
|
49
|
+
|
|
50
|
+
for (const [paramName, rules] of Object.entries(this.validationRules)) {
|
|
51
|
+
const value = query[paramName];
|
|
52
|
+
|
|
53
|
+
// Check required
|
|
54
|
+
if (rules.required && (value === undefined || value === null || value === '')) {
|
|
55
|
+
errors.push(`Required parameter [${paramName}] is missing.`);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Skip validation if value is not provided and not required
|
|
60
|
+
if (value === undefined || value === null) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Type validation
|
|
65
|
+
if (rules.type === 'integer' || rules.type === 'number') {
|
|
66
|
+
const numValue = Number(value);
|
|
67
|
+
if (isNaN(numValue)) {
|
|
68
|
+
errors.push(`Parameter [${paramName}] must be a valid ${rules.type}.`);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (rules.type === 'integer' && !Number.isInteger(numValue)) {
|
|
73
|
+
errors.push(`Parameter [${paramName}] must be an integer.`);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Min/max validation for numbers
|
|
78
|
+
if (rules.min !== undefined && numValue < rules.min) {
|
|
79
|
+
errors.push(`Parameter [${paramName}] must be at least ${rules.min}.`);
|
|
80
|
+
}
|
|
81
|
+
if (rules.max !== undefined && numValue > rules.max) {
|
|
82
|
+
errors.push(`Parameter [${paramName}] must be at most ${rules.max}.`);
|
|
83
|
+
}
|
|
84
|
+
} else if (rules.type === 'string') {
|
|
85
|
+
if (typeof value !== 'string') {
|
|
86
|
+
errors.push(`Parameter [${paramName}] must be a string.`);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Length validation for strings
|
|
91
|
+
if (rules.minLength !== undefined && value.length < rules.minLength) {
|
|
92
|
+
errors.push(`Parameter [${paramName}] must be at least ${rules.minLength} characters.`);
|
|
93
|
+
}
|
|
94
|
+
if (rules.maxLength !== undefined && value.length > rules.maxLength) {
|
|
95
|
+
errors.push(`Parameter [${paramName}] must be at most ${rules.maxLength} characters.`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Format validation
|
|
99
|
+
if (rules.format) {
|
|
100
|
+
const formatPatterns = {
|
|
101
|
+
'email': /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
|
|
102
|
+
'url': /^https?:\/\/.+/i,
|
|
103
|
+
'ip': /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$|^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/,
|
|
104
|
+
'date': /^\d{4}-\d{2}-\d{2}$/,
|
|
105
|
+
'hexColor': /^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
if (formatPatterns[rules.format] && !formatPatterns[rules.format].test(value)) {
|
|
109
|
+
errors.push(`Parameter [${paramName}] must be a valid ${rules.format}.`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
} else if (rules.type === 'boolean') {
|
|
113
|
+
if (typeof value !== 'boolean' && value !== 'true' && value !== 'false') {
|
|
114
|
+
errors.push(`Parameter [${paramName}] must be a boolean.`);
|
|
115
|
+
}
|
|
116
|
+
} else if (rules.type === 'array') {
|
|
117
|
+
if (!Array.isArray(value)) {
|
|
118
|
+
errors.push(`Parameter [${paramName}] must be an array.`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Enum validation
|
|
123
|
+
if (rules.enum && Array.isArray(rules.enum)) {
|
|
124
|
+
if (!rules.enum.includes(value)) {
|
|
125
|
+
errors.push(`Parameter [${paramName}] must be one of: ${rules.enum.join(', ')}.`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (errors.length > 0) {
|
|
131
|
+
throw new Error(`Validation failed: ${errors.join(' ')} See documentation: https://docs.apiverve.com/ref/unicodeescape`);
|
|
132
|
+
}
|
|
37
133
|
}
|
|
38
134
|
|
|
39
135
|
async execute(query, callback) {
|
|
@@ -58,14 +154,8 @@ class unicodeescapeWrapper {
|
|
|
58
154
|
}
|
|
59
155
|
}
|
|
60
156
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
for (var i = 0; i < requiredParams.length; i++) {
|
|
64
|
-
if (!query[requiredParams[i]]) {
|
|
65
|
-
throw new Error(`Required parameter [${requiredParams[i]}] is missing. See documentation: https://docs.apiverve.com/ref/unicodeescape`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
157
|
+
// Validate parameters against schema rules
|
|
158
|
+
this.validateParams(query);
|
|
69
159
|
|
|
70
160
|
const method = 'POST';
|
|
71
161
|
const url = method === 'POST' ? this.baseURL : this.constructURL(query);
|
|
@@ -108,7 +198,7 @@ class unicodeescapeWrapper {
|
|
|
108
198
|
constructURL(query) {
|
|
109
199
|
let url = this.baseURL;
|
|
110
200
|
|
|
111
|
-
if(query && typeof query === 'object')
|
|
201
|
+
if(query && typeof query === 'object')
|
|
112
202
|
{
|
|
113
203
|
if (Object.keys(query).length > 0) {
|
|
114
204
|
const queryString = Object.keys(query)
|
|
@@ -119,6 +209,7 @@ class unicodeescapeWrapper {
|
|
|
119
209
|
}
|
|
120
210
|
return url;
|
|
121
211
|
}
|
|
212
|
+
|
|
122
213
|
}
|
|
123
214
|
|
|
124
215
|
module.exports = unicodeescapeWrapper;
|
package/package.json
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apiverve/unicodeescape",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.13",
|
|
4
4
|
"description": "Unicode Escape/Unescape is a tool for converting characters to Unicode escape sequences and vice versa. It handles all Unicode characters including emojis and surrogate pairs.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=14.0.0"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"index.js",
|
|
13
|
+
"index.d.ts",
|
|
14
|
+
"LICENSE"
|
|
15
|
+
],
|
|
7
16
|
"scripts": {
|
|
8
17
|
"test": "mocha",
|
|
9
18
|
"example": "node examples/basic.js"
|
|
@@ -14,14 +23,18 @@
|
|
|
14
23
|
"directory": "npm"
|
|
15
24
|
},
|
|
16
25
|
"keywords": [
|
|
17
|
-
"
|
|
26
|
+
""
|
|
18
27
|
],
|
|
19
|
-
"author":
|
|
28
|
+
"author": {
|
|
29
|
+
"name": "APIVerve",
|
|
30
|
+
"email": "hello@apiverve.com",
|
|
31
|
+
"url": "https://apiverve.com"
|
|
32
|
+
},
|
|
20
33
|
"license": "MIT",
|
|
21
34
|
"bugs": {
|
|
22
35
|
"url": "https://github.com/apiverve/unicodeescape-api/issues"
|
|
23
36
|
},
|
|
24
|
-
"homepage": "https://apiverve.com/marketplace/unicodeescape?utm_source=npm",
|
|
37
|
+
"homepage": "https://apiverve.com/marketplace/unicodeescape?utm_source=npm&utm_medium=homepage",
|
|
25
38
|
"devDependencies": {
|
|
26
39
|
"mocha": "^11.0.1",
|
|
27
40
|
"chai": "^5.1.2",
|
package/examples/basic.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Basic Example - Unicode Escape/Unescape API
|
|
3
|
-
*
|
|
4
|
-
* This example demonstrates how to use the Unicode Escape/Unescape API.
|
|
5
|
-
* Make sure to set your API key in the .env file or replace '[YOUR_API_KEY]' below.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
require('dotenv').config();
|
|
9
|
-
const unicodeescapeAPI = require('../index.js');
|
|
10
|
-
|
|
11
|
-
// Initialize the API client
|
|
12
|
-
const api = new unicodeescapeAPI({
|
|
13
|
-
api_key: process.env.API_KEY || '[YOUR_API_KEY]'
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
// Example query
|
|
17
|
-
var query = {
|
|
18
|
-
"text": "Hello World",
|
|
19
|
-
"action": "escape"
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
// Make the API request using callback
|
|
23
|
-
console.log('Making request to Unicode Escape/Unescape API...\n');
|
|
24
|
-
|
|
25
|
-
api.execute(query, function (error, data) {
|
|
26
|
-
if (error) {
|
|
27
|
-
console.error('Error occurred:');
|
|
28
|
-
if (error.error) {
|
|
29
|
-
console.error('Message:', error.error);
|
|
30
|
-
console.error('Status:', error.status);
|
|
31
|
-
} else {
|
|
32
|
-
console.error(JSON.stringify(error, null, 2));
|
|
33
|
-
}
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
console.log('Response:');
|
|
38
|
-
console.log(JSON.stringify(data, null, 2));
|
|
39
|
-
});
|
package/tmp/build.dat
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#
|