@apiverve/advice 1.1.13 → 1.2.0
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 +2 -2
- package/index.d.ts +15 -3
- package/index.js +3 -9
- package/package.json +4 -5
package/README.md
CHANGED
|
@@ -116,8 +116,8 @@ async function makeRequest() {
|
|
|
116
116
|
"status": "ok",
|
|
117
117
|
"error": null,
|
|
118
118
|
"data": {
|
|
119
|
-
"id": "
|
|
120
|
-
"advice": "
|
|
119
|
+
"id": "3xx4VZSZ",
|
|
120
|
+
"advice": "Be creative and innovative.",
|
|
121
121
|
"lang": "en"
|
|
122
122
|
}
|
|
123
123
|
}
|
package/index.d.ts
CHANGED
|
@@ -4,18 +4,30 @@ declare module '@apiverve/advice' {
|
|
|
4
4
|
secure?: boolean;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Describes fields the current plan does not unlock. Locked fields arrive as null
|
|
9
|
+
* in `data`; `locked_fields` names them, using dot paths for nested fields.
|
|
10
|
+
* Absent when the plan unlocks everything.
|
|
11
|
+
*/
|
|
12
|
+
export interface PremiumInfo {
|
|
13
|
+
message: string;
|
|
14
|
+
upgrade_url: string;
|
|
15
|
+
locked_fields: string[];
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
export interface adviceResponse {
|
|
8
19
|
status: string;
|
|
9
20
|
error: string | null;
|
|
10
21
|
data: AdviceGeneratorData;
|
|
11
22
|
code?: number;
|
|
23
|
+
premium?: PremiumInfo;
|
|
12
24
|
}
|
|
13
25
|
|
|
14
26
|
|
|
15
27
|
interface AdviceGeneratorData {
|
|
16
|
-
id: string;
|
|
17
|
-
advice: string;
|
|
18
|
-
lang: string;
|
|
28
|
+
id: null | string;
|
|
29
|
+
advice: null | string;
|
|
30
|
+
lang: null | string;
|
|
19
31
|
}
|
|
20
32
|
|
|
21
33
|
export default class adviceWrapper {
|
package/index.js
CHANGED
|
@@ -13,16 +13,10 @@ class adviceWrapper {
|
|
|
13
13
|
throw new Error('API key must be provided as a non-empty string. Get your API key at: https://apiverve.com');
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
// Validate API key format (GUID or alphanumeric
|
|
17
|
-
const apiKeyPattern = /^[a-zA-Z0-
|
|
16
|
+
// Validate API key format (GUID, prefixed keys like apv_xxx, or alphanumeric)
|
|
17
|
+
const apiKeyPattern = /^[a-zA-Z0-9_-]+$/;
|
|
18
18
|
if (!apiKeyPattern.test(api_key)) {
|
|
19
|
-
throw new Error('Invalid API key format. API key must be alphanumeric and may contain hyphens. Get your API key at: https://apiverve.com');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Check minimum length (GUIDs are typically 36 chars with hyphens, or 32 without)
|
|
23
|
-
const trimmedKey = api_key.replace(/-/g, '');
|
|
24
|
-
if (trimmedKey.length < 32) {
|
|
25
|
-
throw new Error('Invalid API key. API key appears to be too short. Get your API key at: https://apiverve.com');
|
|
19
|
+
throw new Error('Invalid API key format. API key must be alphanumeric and may contain hyphens and underscores. Get your API key at: https://apiverve.com');
|
|
26
20
|
}
|
|
27
21
|
|
|
28
22
|
if (typeof secure !== 'boolean') {
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apiverve/advice",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Advice Generator is a simple tool for generating random pieces of advice. It returns a random piece of advice.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"sideEffects": false,
|
|
8
8
|
"engines": {
|
|
9
|
-
"node": ">=
|
|
9
|
+
"node": ">=18.0.0"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"index.js",
|
|
@@ -41,8 +41,7 @@
|
|
|
41
41
|
"dotenv": "^16.4.7"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"axios": "1.13.2"
|
|
44
|
+
"axios": "1.13.2",
|
|
45
|
+
"form-data": "^4.0.1"
|
|
47
46
|
}
|
|
48
47
|
}
|