@apiverve/anagrampuzzle 1.1.14 → 1.2.2

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.
Files changed (5) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +180 -176
  3. package/index.d.ts +48 -29
  4. package/index.js +209 -209
  5. package/package.json +6 -7
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2025 APIVerve, and EvlarSoft LLC
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 APIVerve and EvlarSoft LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
package/README.md CHANGED
@@ -1,214 +1,218 @@
1
- # Anagram Puzzle Generator API
2
-
3
- Anagram Puzzle Generator creates word puzzles where players rearrange scrambled letters to form valid words, with optional hints.
4
-
5
- ![Build Status](https://img.shields.io/badge/build-passing-green)
6
- ![Code Climate](https://img.shields.io/badge/maintainability-B-purple)
7
- ![Prod Ready](https://img.shields.io/badge/production-ready-blue)
8
- [![npm version](https://img.shields.io/npm/v/@apiverve/anagrampuzzle.svg)](https://www.npmjs.com/package/@apiverve/anagrampuzzle)
9
-
10
- This is a Javascript Wrapper for the [Anagram Puzzle Generator API](https://apiverve.com/marketplace/anagrampuzzle?utm_source=npm&utm_medium=readme)
11
-
12
- ---
13
-
14
- ## Installation
15
-
16
- Using npm:
17
- ```shell
18
- npm install @apiverve/anagrampuzzle
19
- ```
20
-
21
- Using yarn:
22
- ```shell
23
- yarn add @apiverve/anagrampuzzle
24
- ```
25
-
26
- ---
27
-
28
- ## Configuration
29
-
30
- Before using the Anagram Puzzle Generator API client, you have to setup your account and obtain your API Key.
31
- You can get it by signing up at [https://apiverve.com](https://apiverve.com?utm_source=npm&utm_medium=readme)
32
-
33
- ---
34
-
35
- ## Quick Start
36
-
37
- [Get started with the Quick Start Guide](https://docs.apiverve.com/quickstart?utm_source=npm&utm_medium=readme)
38
-
39
- The Anagram Puzzle Generator API documentation is found here: [https://docs.apiverve.com/ref/anagrampuzzle](https://docs.apiverve.com/ref/anagrampuzzle?utm_source=npm&utm_medium=readme).
40
- You can find parameters, example responses, and status codes documented here.
41
-
42
- ### Setup
43
-
44
- ```javascript
45
- const anagrampuzzleAPI = require('@apiverve/anagrampuzzle');
46
- const api = new anagrampuzzleAPI({
47
- api_key: '[YOUR_API_KEY]'
48
- });
49
- ```
50
-
51
- ---
52
-
53
- ## Usage
54
-
55
- ---
56
-
57
- ### Perform Request
58
-
59
- Using the API is simple. All you have to do is make a request. The API will return a response with the data you requested.
60
-
61
- ```javascript
1
+ # Anagram Puzzle Generator API
2
+
3
+ Anagram Puzzle Generator creates word puzzles where players rearrange scrambled letters to form valid words, with optional hints.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@apiverve/anagrampuzzle.svg)](https://www.npmjs.com/package/@apiverve/anagrampuzzle)
6
+
7
+ This is a JavaScript wrapper for the [Anagram Puzzle Generator API](https://apiverve.com/marketplace/anagrampuzzle?utm_source=npm&utm_medium=referral&utm_content=readme)
8
+
9
+ ---
10
+
11
+ ## Installation
12
+
13
+ Using npm:
14
+ ```shell
15
+ npm install @apiverve/anagrampuzzle
16
+ ```
17
+
18
+ Using yarn:
19
+ ```shell
20
+ yarn add @apiverve/anagrampuzzle
21
+ ```
22
+
23
+ ---
24
+
25
+ ## Configuration
26
+
27
+ Before using the Anagram Puzzle Generator API client, you have to setup your account and obtain your API Key.
28
+ You can get it by signing up at [https://apiverve.com](https://apiverve.com?utm_source=npm&utm_medium=referral&utm_content=readme)
29
+
30
+ ---
31
+
32
+ ## Quick Start
33
+
34
+ [Get started with the Quick Start Guide](https://docs.apiverve.com/quickstart?utm_source=npm&utm_medium=referral&utm_content=readme)
35
+
36
+ The Anagram Puzzle Generator API documentation is found here: [https://docs.apiverve.com/ref/anagrampuzzle](https://docs.apiverve.com/ref/anagrampuzzle?utm_source=npm&utm_medium=referral&utm_content=readme).
37
+ You can find parameters, example responses, and status codes documented here.
38
+
39
+ ### Setup
40
+
41
+ ```javascript
42
+ const anagrampuzzleAPI = require('@apiverve/anagrampuzzle');
43
+ const api = new anagrampuzzleAPI({
44
+ api_key: '[YOUR_API_KEY]'
45
+ });
46
+ ```
47
+
48
+ ---
49
+
50
+ ## Usage
51
+
52
+ ---
53
+
54
+ ### Perform Request
55
+
56
+ Using the API is simple. All you have to do is make a request. The API will return a response with the data you requested.
57
+
58
+ ```javascript
62
59
  var query = {
63
60
  word: "listen",
64
61
  count: 1,
65
- difficulty: "medium"
66
- };
67
-
68
- api.execute(query, function (error, data) {
69
- if (error) {
70
- return console.error(error);
71
- } else {
72
- console.log(data);
73
- }
74
- });
75
- ```
76
-
77
- ---
78
-
79
- ### Using Promises
80
-
81
- You can also use promises to make requests. The API returns a promise that you can use to handle the response.
82
-
83
- ```javascript
62
+ difficulty: "medium",
63
+ image: false
64
+ };
65
+
66
+ api.execute(query, function (error, data) {
67
+ if (error) {
68
+ return console.error(error);
69
+ } else {
70
+ console.log(data);
71
+ }
72
+ });
73
+ ```
74
+
75
+ ---
76
+
77
+ ### Using Promises
78
+
79
+ You can also use promises to make requests. The API returns a promise that you can use to handle the response.
80
+
81
+ ```javascript
84
82
  var query = {
85
83
  word: "listen",
86
84
  count: 1,
87
- difficulty: "medium"
88
- };
89
-
90
- api.execute(query)
91
- .then(data => {
92
- console.log(data);
93
- })
94
- .catch(error => {
95
- console.error(error);
96
- });
97
- ```
98
-
99
- ---
100
-
101
- ### Using Async/Await
102
-
103
- You can also use async/await to make requests. The API returns a promise that you can use to handle the response.
104
-
105
- ```javascript
106
- async function makeRequest() {
85
+ difficulty: "medium",
86
+ image: false
87
+ };
88
+
89
+ api.execute(query)
90
+ .then(data => {
91
+ console.log(data);
92
+ })
93
+ .catch(error => {
94
+ console.error(error);
95
+ });
96
+ ```
97
+
98
+ ---
99
+
100
+ ### Using Async/Await
101
+
102
+ You can also use async/await to make requests. The API returns a promise that you can use to handle the response.
103
+
104
+ ```javascript
105
+ async function makeRequest() {
107
106
  var query = {
108
107
  word: "listen",
109
108
  count: 1,
110
- difficulty: "medium"
111
- };
112
-
113
- try {
114
- const data = await api.execute(query);
115
- console.log(data);
116
- } catch (error) {
117
- console.error(error);
118
- }
119
- }
120
- ```
121
-
122
- ---
123
-
124
- ## Example Response
125
-
126
- ```json
109
+ difficulty: "medium",
110
+ image: false
111
+ };
112
+
113
+ try {
114
+ const data = await api.execute(query);
115
+ console.log(data);
116
+ } catch (error) {
117
+ console.error(error);
118
+ }
119
+ }
120
+ ```
121
+
122
+ ---
123
+
124
+ ## Example Response
125
+
126
+ ```json
127
127
  {
128
128
  "status": "ok",
129
129
  "error": null,
130
130
  "data": {
131
131
  "puzzles": [
132
132
  {
133
- "original": "LATIGO",
134
- "scrambled": "TIAGLO",
133
+ "original": "DESPAIR",
134
+ "scrambled": "PDAISRE",
135
135
  "anagrams": [
136
- "GALIOT"
136
+ "ASPIRED",
137
+ "DIAPERS"
137
138
  ],
138
- "letterCount": 6,
139
- "hint": "A strap for tightening a saddle girth. [Western U. S. & Sp. Amer.]"
139
+ "letterCount": 7
140
140
  },
141
141
  {
142
- "original": "INSTAR",
143
- "scrambled": "IATRNS",
142
+ "original": "GREATS",
143
+ "scrambled": "RSGETA",
144
144
  "anagrams": [
145
- "STRAIN"
145
+ "GASTER",
146
+ "GATERS",
147
+ "GRATES"
146
148
  ],
147
- "letterCount": 6,
148
- "hint": "To stud as with stars. [R.] \"A golden throne instarred with gems.\" J. Barlow."
149
+ "letterCount": 6
149
150
  },
150
151
  {
151
- "original": "WARISH",
152
- "scrambled": "SIRAWH",
152
+ "original": "GROANS",
153
+ "scrambled": "SOGNRA",
153
154
  "anagrams": [
154
- "RAWISH"
155
+ "ARGONS"
155
156
  ],
156
- "letterCount": 6,
157
- "hint": "To protect from the effects of; hence, to cure; to heal. [Obs.] My brother shall"
157
+ "letterCount": 6
158
158
  },
159
159
  {
160
- "original": "IRONISH",
161
- "scrambled": "INORHIS",
160
+ "original": "BARGEES",
161
+ "scrambled": "ABEREGS",
162
162
  "anagrams": [
163
- "ROINISH"
163
+ "BAREGES"
164
164
  ],
165
- "letterCount": 7,
166
- "hint": "Resembling iron, as in taste. Wood."
165
+ "letterCount": 7
167
166
  },
168
167
  {
169
- "original": "RADIOUS",
170
- "scrambled": "RIADUOS",
168
+ "original": "CANINES",
169
+ "scrambled": "NISNCEA",
171
170
  "anagrams": [
172
- "SAUROID"
171
+ "ENCINAS"
173
172
  ],
174
- "letterCount": 7,
175
- "hint": "1. Consisting of rays, and light. [R.] Berkeley. 2. Radiating; radiant. [Obs.] G"
173
+ "letterCount": 7
176
174
  }
177
175
  ],
178
176
  "count": 5,
179
177
  "difficulty": "medium",
180
- "html": "<html><head><title>Anagram Puzzle</title><style>body {font-family: Arial, sans-serif; padding: 20px; max-width: 700px; margin: 0 auto;}h1 {text-align: center;}.puzzle {background: #f5f5f5; padding: 25px; margin: 20px 0; border-radius: 10px;}.scrambled {font-size: 32px; font-weight: bold; letter-spacing: 8px; color: #9C27B0; text-align: center; margin: 15px 0;}.letters {display: flex; justify-content: center; gap: 5px; margin: 15px 0;}.letter {width: 40px; height: 40px; background: #fff; border: 2px solid #9C27B0; border-radius: 5px; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: bold;}.hint {font-size: 14px; color: #666; font-style: italic; margin-top: 15px;}.info {font-size: 12px; color: #999; margin-top: 10px;}.answer-area {margin-top: 15px; padding: 10px; border: 2px dashed #ccc; border-radius: 5px; min-height: 30px;}</style></head><body><h1>Anagram Puzzle</h1><p style='text-align:center;'>Rearrange the letters to form a word</p><div class='puzzle'><div class='info'>#1 - 6 letters</div><div class='letters'><div class='letter'>T</div><div class='letter'>I</div><div class='letter'>A</div><div class='letter'>G</div><div class='letter'>L</div><div class='letter'>O</div></div><div class='hint'>Hint: A strap for tightening a saddle girth. [Western U. S. & Sp. Amer.]...</div><div class='answer-area'></div><div class='info'>Bonus: This word has 1 anagram(s)!</div></div><div class='puzzle'><div class='info'>#2 - 6 letters</div><div class='letters'><div class='letter'>I</div><div class='letter'>A</div><div class='letter'>T</div><div class='letter'>R</div><div class='letter'>N</div><div class='letter'>S</div></div><div class='hint'>Hint: To stud as with stars. [R.] 'A golden throne instarred with gems.' J. Barlow....</div><div class='answer-area'></div><div class='info'>Bonus: This word has 1 anagram(s)!</div></div><div class='puzzle'><div class='info'>#3 - 6 letters</div><div class='letters'><div class='letter'>S</div><div class='letter'>I</div><div class='letter'>R</div><div class='letter'>A</div><div class='letter'>W</div><div class='letter'>H</div></div><div class='hint'>Hint: To protect from the effects of; hence, to cure; to heal. [Obs.] My brother shall...</div><div class='answer-area'></div><div class='info'>Bonus: This word has 1 anagram(s)!</div></div><div class='puzzle'><div class='info'>#4 - 7 letters</div><div class='letters'><div class='letter'>I</div><div class='letter'>N</div><div class='letter'>O</div><div class='letter'>R</div><div class='letter'>H</div><div class='letter'>I</div><div class='letter'>S</div></div><div class='hint'>Hint: Resembling iron, as in taste. Wood....</div><div class='answer-area'></div><div class='info'>Bonus: This word has 1 anagram(s)!</div></div><div class='puzzle'><div class='info'>#5 - 7 letters</div><div class='letters'><div class='letter'>R</div><div class='letter'>I</div><div class='letter'>A</div><div class='letter'>D</div><div class='letter'>U</div><div class='letter'>O</div><div class='letter'>S</div></div><div class='hint'>Hint: 1. Consisting of rays, and light. [R.] Berkeley. 2. Radiating; radiant. [Obs.] G...</div><div class='answer-area'></div><div class='info'>Bonus: This word has 1 anagram(s)!</div></div></body></html>"
178
+ "html": "<html><head><title>Anagram Puzzle</title><style>body {font-family: Arial, sans-serif; padding: 20px; max-width: 700px; margin: 0 auto;}h1 {text-align: center;}.puzzle {background: #f5f5f5; padding: 25px; margin: 20px 0; border-radius: 10px;}.scrambled {font-size: 32px; font-weight: bold; letter-spacing: 8px; color: #9C27B0; text-align: center; margin: 15px 0;}.letters {display: flex; justify-content: center; gap: 5px; margin: 15px 0;}.letter {width: 40px; height: 40px; background: #fff; border: 2px solid #9C27B0; border-radius: 5px; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: bold;}.hint {font-size: 14px; color: #666; font-style: italic; margin-top: 15px;}.info {font-size: 12px; color: #999; margin-top: 10px;}.answer-area {margin-top: 15px; padding: 10px; border: 2px dashed #ccc; border-radius: 5px; min-height: 30px;}</style></head><body><h1>Anagram Puzzle</h1><p style='text-align:center;'>Rearrange the letters to form a word</p><div class='puzzle'><div class='info'>#1 - 7 letters</div><div class='letters'><div class='letter'>P</div><div class='letter'>D</div><div class='letter'>A</div><div class='letter'>I</div><div class='letter'>S</div><div class='letter'>R</div><div class='letter'>E</div></div><div class='answer-area'></div><div class='info'>Bonus: This word has 2 anagram(s)!</div></div><div class='puzzle'><div class='info'>#2 - 6 letters</div><div class='letters'><div class='letter'>R</div><div class='letter'>S</div><div class='letter'>G</div><div class='letter'>E</div><div class='letter'>T</div><div class='letter'>A</div></div><div class='answer-area'></div><div class='info'>Bonus: This word has 3 anagram(s)!</div></div><div class='puzzle'><div class='info'>#3 - 6 letters</div><div class='letters'><div class='letter'>S</div><div class='letter'>O</div><div class='letter'>G</div><div class='letter'>N</div><div class='letter'>R</div><div class='letter'>A</div></div><div class='answer-area'></div><div class='info'>Bonus: This word has 1 anagram(s)!</div></div><div class='puzzle'><div class='info'>#4 - 7 letters</div><div class='letters'><div class='letter'>A</div><div class='letter'>B</div><div class='letter'>E</div><div class='letter'>R</div><div class='letter'>E</div><div class='letter'>G</div><div class='letter'>S</div></div><div class='answer-area'></div><div class='info'>Bonus: This word has 1 anagram(s)!</div></div><div class='puzzle'><div class='info'>#5 - 7 letters</div><div class='letters'><div class='letter'>N</div><div class='letter'>I</div><div class='letter'>S</div><div class='letter'>N</div><div class='letter'>C</div><div class='letter'>E</div><div class='letter'>A</div></div><div class='answer-area'></div><div class='info'>Bonus: This word has 1 anagram(s)!</div></div></body></html>",
179
+ "image": {
180
+ "imageName": "d52a76c7-fe99-498f-b616-ab376cc920a5_anagram.png",
181
+ "format": ".png",
182
+ "downloadURL": "https://storage.googleapis.com/apiverve/APIData/anagrampuzzle/d52a76c7-fe99-498f-b616-ab376cc920a5_anagram.png?GoogleAccessId=635500398038-compute%40developer.gserviceaccount.com&Expires=1766009991&Signature=cHugsZLx%2BpnY0TrRpTdO%2Bfh48%2Bw8E1zzZt3SNLI2dNgM%2BZj%2FiC%2FZZjvoyahZdBlBkz6pHxuLRX55%2FLszTxTxyhNLJzUcjDOCjoATtWKevbzyLmwaEyFXLDjdzikxUWjVt9g8MyiPEKSFK6%2BpgY6WCvvSeI%2Fox%2B6lQawatWFMB7k0OKSTr9FO%2Fhqqu5M4%2B37bW0zvBuNtcORufXKayE7Z2KcW%2F2wkk9YwGXrVIvn2xLcOYjdY49GAQ2HW0qxRHLDtYYMY6T32jKz1KC6KBLZzrji7v3N%2FVkxfbECzXNgZB5WcCisCoHrUyj7BO14lLr7ZC4XttlYe70ak4QTqa3qNCw%3D%3D",
183
+ "expires": 1766009991438
184
+ }
181
185
  }
182
- }
183
- ```
184
-
185
- ---
186
-
187
- ## Customer Support
188
-
189
- Need any assistance? [Get in touch with Customer Support](https://apiverve.com/contact?utm_source=npm&utm_medium=readme).
190
-
191
- ---
192
-
193
- ## Updates
194
-
195
- Stay up to date by following [@apiverveHQ](https://twitter.com/apiverveHQ) on Twitter.
196
-
197
- ---
198
-
199
- ## Legal
200
-
201
- 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).
202
-
203
- ---
204
-
205
- ## License
206
- Licensed under the The MIT License (MIT)
207
-
208
- Copyright (&copy;) 2026 APIVerve, and EvlarSoft LLC
209
-
210
- 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:
211
-
212
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
213
-
214
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
186
+ }
187
+ ```
188
+
189
+ ---
190
+
191
+ ## Customer Support
192
+
193
+ Need any assistance? [Get in touch with Customer Support](https://apiverve.com/contact?utm_source=npm&utm_medium=referral&utm_content=readme).
194
+
195
+ ---
196
+
197
+ ## Updates
198
+
199
+ Stay up to date by following [@apiverveHQ](https://twitter.com/apiverveHQ) on Twitter.
200
+
201
+ ---
202
+
203
+ ## Legal
204
+
205
+ 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=referral&utm_content=readme) and [Privacy Policy](https://apiverve.com/privacy?utm_source=npm&utm_medium=referral&utm_content=readme).
206
+
207
+ ---
208
+
209
+ ## License
210
+ Licensed under the MIT License (MIT)
211
+
212
+ Copyright (&copy;) 2026 APIVerve, and EvlarSoft LLC
213
+
214
+ 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:
215
+
216
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
217
+
218
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/index.d.ts CHANGED
@@ -1,37 +1,56 @@
1
- declare module '@apiverve/anagrampuzzle' {
2
- export interface anagrampuzzleOptions {
3
- api_key: string;
4
- secure?: boolean;
5
- }
6
-
7
- export interface anagrampuzzleResponse {
8
- status: string;
9
- error: string | null;
10
- data: AnagramPuzzleGeneratorData;
11
- code?: number;
12
- }
13
-
1
+ declare module '@apiverve/anagrampuzzle' {
2
+ export interface anagrampuzzleOptions {
3
+ api_key: string;
4
+ secure?: boolean;
5
+ }
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
+
18
+ export interface anagrampuzzleResponse {
19
+ status: string;
20
+ error: string | null;
21
+ data: AnagramPuzzleGeneratorData;
22
+ code?: number;
23
+ premium?: PremiumInfo;
24
+ }
25
+
14
26
 
15
27
  interface AnagramPuzzleGeneratorData {
16
28
  puzzles: Puzzle[];
17
- count: number;
18
- difficulty: string;
19
- html: string;
29
+ count: number | null;
30
+ difficulty: null | string;
31
+ html: null | string;
32
+ image: Image;
33
+ }
34
+
35
+ interface Image {
36
+ imageName: null | string;
37
+ format: null | string;
38
+ downloadURL: null | string;
39
+ expires: number | null;
20
40
  }
21
41
 
22
42
  interface Puzzle {
23
- original: string;
24
- scrambled: string;
25
- anagrams: string[];
26
- letterCount: number;
27
- hint: string;
43
+ original: null | string;
44
+ scrambled: null | string;
45
+ anagrams: (null | string)[];
46
+ letterCount: number | null;
28
47
  }
29
48
 
30
- export default class anagrampuzzleWrapper {
31
- constructor(options: anagrampuzzleOptions);
32
-
33
- execute(callback: (error: any, data: anagrampuzzleResponse | null) => void): Promise<anagrampuzzleResponse>;
34
- execute(query: Record<string, any>, callback: (error: any, data: anagrampuzzleResponse | null) => void): Promise<anagrampuzzleResponse>;
35
- execute(query?: Record<string, any>): Promise<anagrampuzzleResponse>;
36
- }
37
- }
49
+ export default class anagrampuzzleWrapper {
50
+ constructor(options: anagrampuzzleOptions);
51
+
52
+ execute(callback: (error: any, data: anagrampuzzleResponse | null) => void): Promise<anagrampuzzleResponse>;
53
+ execute(query: Record<string, any>, callback: (error: any, data: anagrampuzzleResponse | null) => void): Promise<anagrampuzzleResponse>;
54
+ execute(query?: Record<string, any>): Promise<anagrampuzzleResponse>;
55
+ }
56
+ }
package/index.js CHANGED
@@ -1,209 +1,209 @@
1
- const axios = require('axios');
2
-
3
- class anagrampuzzleWrapper {
4
-
5
- constructor(options) {
6
- if (!options || typeof options !== 'object') {
7
- throw new Error('Options object must be provided. See documentation: https://docs.apiverve.com/ref/anagrampuzzle');
8
- }
9
-
10
- const { api_key, secure = true } = options;
11
-
12
- if (!api_key || typeof api_key !== 'string') {
13
- throw new Error('API key must be provided as a non-empty string. Get your API key at: https://apiverve.com');
14
- }
15
-
16
- // Validate API key format (GUID, prefixed keys like apv_xxx, or alphanumeric)
17
- const apiKeyPattern = /^[a-zA-Z0-9_-]+$/;
18
- if (!apiKeyPattern.test(api_key)) {
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');
20
- }
21
-
22
- if (typeof secure !== 'boolean') {
23
- throw new Error('Secure parameter must be a boolean value.');
24
- }
25
-
26
- this.APIKey = api_key;
27
- this.IsSecure = secure;
28
-
29
- // secure is deprecated, all requests must be made over HTTPS
30
- this.baseURL = 'https://api.apiverve.com/v1/anagrampuzzle';
31
-
32
- // Validation rules for parameters (generated from schema)
33
- this.validationRules = {"word":{"type":"string","required":false},"count":{"type":"integer","required":false,"min":1,"max":20,"default":1},"difficulty":{"type":"string","required":false,"default":"medium"}};
34
- }
35
-
36
- /**
37
- * Validate query parameters against schema rules
38
- * @param {Object} query - The query parameters to validate
39
- * @throws {Error} - If validation fails
40
- */
41
- validateParams(query) {
42
- const errors = [];
43
-
44
- for (const [paramName, rules] of Object.entries(this.validationRules)) {
45
- const value = query[paramName];
46
-
47
- // Check required
48
- if (rules.required && (value === undefined || value === null || value === '')) {
49
- errors.push(`Required parameter [${paramName}] is missing.`);
50
- continue;
51
- }
52
-
53
- // Skip validation if value is not provided and not required
54
- if (value === undefined || value === null) {
55
- continue;
56
- }
57
-
58
- // Type validation
59
- if (rules.type === 'integer' || rules.type === 'number') {
60
- const numValue = Number(value);
61
- if (isNaN(numValue)) {
62
- errors.push(`Parameter [${paramName}] must be a valid ${rules.type}.`);
63
- continue;
64
- }
65
-
66
- if (rules.type === 'integer' && !Number.isInteger(numValue)) {
67
- errors.push(`Parameter [${paramName}] must be an integer.`);
68
- continue;
69
- }
70
-
71
- // Min/max validation for numbers
72
- if (rules.min !== undefined && numValue < rules.min) {
73
- errors.push(`Parameter [${paramName}] must be at least ${rules.min}.`);
74
- }
75
- if (rules.max !== undefined && numValue > rules.max) {
76
- errors.push(`Parameter [${paramName}] must be at most ${rules.max}.`);
77
- }
78
- } else if (rules.type === 'string') {
79
- if (typeof value !== 'string') {
80
- errors.push(`Parameter [${paramName}] must be a string.`);
81
- continue;
82
- }
83
-
84
- // Length validation for strings
85
- if (rules.minLength !== undefined && value.length < rules.minLength) {
86
- errors.push(`Parameter [${paramName}] must be at least ${rules.minLength} characters.`);
87
- }
88
- if (rules.maxLength !== undefined && value.length > rules.maxLength) {
89
- errors.push(`Parameter [${paramName}] must be at most ${rules.maxLength} characters.`);
90
- }
91
-
92
- // Format validation
93
- if (rules.format) {
94
- const formatPatterns = {
95
- 'email': /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
96
- 'url': /^https?:\/\/.+/i,
97
- '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}$/,
98
- 'date': /^\d{4}-\d{2}-\d{2}$/,
99
- 'hexColor': /^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/
100
- };
101
-
102
- if (formatPatterns[rules.format] && !formatPatterns[rules.format].test(value)) {
103
- errors.push(`Parameter [${paramName}] must be a valid ${rules.format}.`);
104
- }
105
- }
106
- } else if (rules.type === 'boolean') {
107
- if (typeof value !== 'boolean' && value !== 'true' && value !== 'false') {
108
- errors.push(`Parameter [${paramName}] must be a boolean.`);
109
- }
110
- } else if (rules.type === 'array') {
111
- if (!Array.isArray(value)) {
112
- errors.push(`Parameter [${paramName}] must be an array.`);
113
- }
114
- }
115
-
116
- // Enum validation
117
- if (rules.enum && Array.isArray(rules.enum)) {
118
- if (!rules.enum.includes(value)) {
119
- errors.push(`Parameter [${paramName}] must be one of: ${rules.enum.join(', ')}.`);
120
- }
121
- }
122
- }
123
-
124
- if (errors.length > 0) {
125
- throw new Error(`Validation failed: ${errors.join(' ')} See documentation: https://docs.apiverve.com/ref/anagrampuzzle`);
126
- }
127
- }
128
-
129
- async execute(query, callback) {
130
- // Handle different argument patterns
131
- if(arguments.length === 0) {
132
- // execute() - no args
133
- query = {};
134
- callback = null;
135
- } else if(arguments.length === 1) {
136
- if (typeof query === 'function') {
137
- // execute(callback)
138
- callback = query;
139
- query = {};
140
- } else {
141
- // execute(query)
142
- callback = null;
143
- }
144
- } else {
145
- // execute(query, callback)
146
- if (!query || typeof query !== 'object') {
147
- throw new Error('Query parameters must be provided as an object.');
148
- }
149
- }
150
-
151
- // Validate parameters against schema rules
152
- this.validateParams(query);
153
-
154
- const method = 'GET';
155
- const url = method === 'POST' ? this.baseURL : this.constructURL(query);
156
-
157
- try {
158
- const response = await axios({
159
- method,
160
- url,
161
- headers: {
162
- 'Content-Type': 'application/json',
163
- 'x-api-key': this.APIKey,
164
- 'auth-mode': 'npm-package'
165
- },
166
- data: method === 'POST' ? query : undefined
167
- });
168
-
169
- const data = response.data;
170
- if (callback) callback(null, data);
171
- return data;
172
- } catch (error) {
173
- let apiError;
174
-
175
- if (error.response && error.response.data) {
176
- apiError = error.response.data;
177
- } else if (error.message) {
178
- apiError = { error: error.message, status: 'error' };
179
- } else {
180
- apiError = { error: 'An unknown error occurred', status: 'error' };
181
- }
182
-
183
- if (callback) {
184
- callback(apiError, null);
185
- return; // Don't throw if callback is provided
186
- }
187
-
188
- throw apiError;
189
- }
190
- }
191
-
192
- constructURL(query) {
193
- let url = this.baseURL;
194
-
195
- if(query && typeof query === 'object')
196
- {
197
- if (Object.keys(query).length > 0) {
198
- const queryString = Object.keys(query)
199
- .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(query[key])}`)
200
- .join('&');
201
- url += `?${queryString}`;
202
- }
203
- }
204
- return url;
205
- }
206
-
207
- }
208
-
209
- module.exports = anagrampuzzleWrapper;
1
+ const axios = require('axios');
2
+
3
+ class anagrampuzzleWrapper {
4
+
5
+ constructor(options) {
6
+ if (!options || typeof options !== 'object') {
7
+ throw new Error('Options object must be provided. See documentation: https://docs.apiverve.com/ref/anagrampuzzle');
8
+ }
9
+
10
+ const { api_key, secure = true } = options;
11
+
12
+ if (!api_key || typeof api_key !== 'string') {
13
+ throw new Error('API key must be provided as a non-empty string. Get your API key at: https://apiverve.com');
14
+ }
15
+
16
+ // Validate API key format (GUID, prefixed keys like apv_xxx, or alphanumeric)
17
+ const apiKeyPattern = /^[a-zA-Z0-9_-]+$/;
18
+ if (!apiKeyPattern.test(api_key)) {
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');
20
+ }
21
+
22
+ if (typeof secure !== 'boolean') {
23
+ throw new Error('Secure parameter must be a boolean value.');
24
+ }
25
+
26
+ this.APIKey = api_key;
27
+ this.IsSecure = secure;
28
+
29
+ // secure is deprecated, all requests must be made over HTTPS
30
+ this.baseURL = 'https://api.apiverve.com/v1/anagrampuzzle';
31
+
32
+ // Validation rules for parameters (generated from schema)
33
+ this.validationRules = {"word":{"type":"string","required":false,"maxLength":60},"count":{"type":"integer","required":false,"min":1,"max":20,"default":1},"difficulty":{"type":"string","required":false,"default":"medium"},"image":{"type":"boolean","required":false,"default":false}};
34
+ }
35
+
36
+ /**
37
+ * Validate query parameters against schema rules
38
+ * @param {Object} query - The query parameters to validate
39
+ * @throws {Error} - If validation fails
40
+ */
41
+ validateParams(query) {
42
+ const errors = [];
43
+
44
+ for (const [paramName, rules] of Object.entries(this.validationRules)) {
45
+ const value = query[paramName];
46
+
47
+ // Check required
48
+ if (rules.required && (value === undefined || value === null || value === '')) {
49
+ errors.push(`Required parameter [${paramName}] is missing.`);
50
+ continue;
51
+ }
52
+
53
+ // Skip validation if value is not provided and not required
54
+ if (value === undefined || value === null) {
55
+ continue;
56
+ }
57
+
58
+ // Type validation
59
+ if (rules.type === 'integer' || rules.type === 'number') {
60
+ const numValue = Number(value);
61
+ if (isNaN(numValue)) {
62
+ errors.push(`Parameter [${paramName}] must be a valid ${rules.type}.`);
63
+ continue;
64
+ }
65
+
66
+ if (rules.type === 'integer' && !Number.isInteger(numValue)) {
67
+ errors.push(`Parameter [${paramName}] must be an integer.`);
68
+ continue;
69
+ }
70
+
71
+ // Min/max validation for numbers
72
+ if (rules.min !== undefined && numValue < rules.min) {
73
+ errors.push(`Parameter [${paramName}] must be at least ${rules.min}.`);
74
+ }
75
+ if (rules.max !== undefined && numValue > rules.max) {
76
+ errors.push(`Parameter [${paramName}] must be at most ${rules.max}.`);
77
+ }
78
+ } else if (rules.type === 'string') {
79
+ if (typeof value !== 'string') {
80
+ errors.push(`Parameter [${paramName}] must be a string.`);
81
+ continue;
82
+ }
83
+
84
+ // Length validation for strings
85
+ if (rules.minLength !== undefined && value.length < rules.minLength) {
86
+ errors.push(`Parameter [${paramName}] must be at least ${rules.minLength} characters.`);
87
+ }
88
+ if (rules.maxLength !== undefined && value.length > rules.maxLength) {
89
+ errors.push(`Parameter [${paramName}] must be at most ${rules.maxLength} characters.`);
90
+ }
91
+
92
+ // Format validation
93
+ if (rules.format) {
94
+ const formatPatterns = {
95
+ 'email': /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
96
+ 'url': /^https?:\/\/.+/i,
97
+ '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}$/,
98
+ 'date': /^\d{4}-\d{2}-\d{2}$/,
99
+ 'hexColor': /^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/
100
+ };
101
+
102
+ if (formatPatterns[rules.format] && !formatPatterns[rules.format].test(value)) {
103
+ errors.push(`Parameter [${paramName}] must be a valid ${rules.format}.`);
104
+ }
105
+ }
106
+ } else if (rules.type === 'boolean') {
107
+ if (typeof value !== 'boolean' && value !== 'true' && value !== 'false') {
108
+ errors.push(`Parameter [${paramName}] must be a boolean.`);
109
+ }
110
+ } else if (rules.type === 'array') {
111
+ if (!Array.isArray(value)) {
112
+ errors.push(`Parameter [${paramName}] must be an array.`);
113
+ }
114
+ }
115
+
116
+ // Enum validation
117
+ if (rules.enum && Array.isArray(rules.enum)) {
118
+ if (!rules.enum.includes(value)) {
119
+ errors.push(`Parameter [${paramName}] must be one of: ${rules.enum.join(', ')}.`);
120
+ }
121
+ }
122
+ }
123
+
124
+ if (errors.length > 0) {
125
+ throw new Error(`Validation failed: ${errors.join(' ')} See documentation: https://docs.apiverve.com/ref/anagrampuzzle`);
126
+ }
127
+ }
128
+
129
+ async execute(query, callback) {
130
+ // Handle different argument patterns
131
+ if(arguments.length === 0) {
132
+ // execute() - no args
133
+ query = {};
134
+ callback = null;
135
+ } else if(arguments.length === 1) {
136
+ if (typeof query === 'function') {
137
+ // execute(callback)
138
+ callback = query;
139
+ query = {};
140
+ } else {
141
+ // execute(query)
142
+ callback = null;
143
+ }
144
+ } else {
145
+ // execute(query, callback)
146
+ if (!query || typeof query !== 'object') {
147
+ throw new Error('Query parameters must be provided as an object.');
148
+ }
149
+ }
150
+
151
+ // Validate parameters against schema rules
152
+ this.validateParams(query);
153
+
154
+ const method = 'GET';
155
+ const url = method === 'POST' ? this.baseURL : this.constructURL(query);
156
+
157
+ try {
158
+ const response = await axios({
159
+ method,
160
+ url,
161
+ headers: {
162
+ 'Content-Type': 'application/json',
163
+ 'x-api-key': this.APIKey,
164
+ 'auth-mode': 'npm-package'
165
+ },
166
+ data: method === 'POST' ? query : undefined
167
+ });
168
+
169
+ const data = response.data;
170
+ if (callback) callback(null, data);
171
+ return data;
172
+ } catch (error) {
173
+ let apiError;
174
+
175
+ if (error.response && error.response.data) {
176
+ apiError = error.response.data;
177
+ } else if (error.message) {
178
+ apiError = { error: error.message, status: 'error' };
179
+ } else {
180
+ apiError = { error: 'An unknown error occurred', status: 'error' };
181
+ }
182
+
183
+ if (callback) {
184
+ callback(apiError, null);
185
+ return; // Don't throw if callback is provided
186
+ }
187
+
188
+ throw apiError;
189
+ }
190
+ }
191
+
192
+ constructURL(query) {
193
+ let url = this.baseURL;
194
+
195
+ if(query && typeof query === 'object')
196
+ {
197
+ if (Object.keys(query).length > 0) {
198
+ const queryString = Object.keys(query)
199
+ .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(query[key])}`)
200
+ .join('&');
201
+ url += `?${queryString}`;
202
+ }
203
+ }
204
+ return url;
205
+ }
206
+
207
+ }
208
+
209
+ module.exports = anagrampuzzleWrapper;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@apiverve/anagrampuzzle",
3
- "version": "1.1.14",
3
+ "version": "1.2.2",
4
4
  "description": "Anagram Puzzle Generator creates word puzzles where players rearrange scrambled letters to form valid words, with optional hints.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "sideEffects": false,
8
8
  "engines": {
9
- "node": ">=14.0.0"
9
+ "node": ">=18.0.0"
10
10
  },
11
11
  "files": [
12
12
  "index.js",
@@ -23,7 +23,7 @@
23
23
  "directory": "npm"
24
24
  },
25
25
  "keywords": [
26
- ""
26
+ "anagram", "word puzzle", "rearrange letters", "word game", "vocabulary"
27
27
  ],
28
28
  "author": {
29
29
  "name": "APIVerve",
@@ -34,15 +34,14 @@
34
34
  "bugs": {
35
35
  "url": "https://github.com/apiverve/anagrampuzzle-api/issues"
36
36
  },
37
- "homepage": "https://apiverve.com/marketplace/anagrampuzzle?utm_source=npm&utm_medium=homepage",
37
+ "homepage": "https://apiverve.com/marketplace/anagrampuzzle?utm_source=npm&utm_medium=referral&utm_content=homepage",
38
38
  "devDependencies": {
39
39
  "mocha": "^11.0.1",
40
40
  "chai": "^5.1.2",
41
41
  "dotenv": "^16.4.7"
42
42
  },
43
43
  "dependencies": {
44
- "node-fetch": "^3.3.2",
45
- "promise": "^8.3.0",
46
- "axios": "1.13.2"
44
+ "axios": "1.13.2",
45
+ "form-data": "^4.0.1"
47
46
  }
48
47
  }