@sharpapi/sharpapi-node-paraphrase 1.0.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/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0 - 2024-10-06
4
+
5
+ - Initial release of the SharpAPI Node.js Paraphrase SDK.
6
+ - Included comprehensive documentation and examples.
@@ -0,0 +1,53 @@
1
+ ## Contributing
2
+
3
+ We welcome contributions to the SharpAPI Node.js Paraphrase SDK! If you'd like to contribute, please follow these steps:
4
+
5
+ 1. **Fork the Repository**
6
+
7
+ Click the "Fork" button at the top-right corner of the repository page to create your own fork.
8
+
9
+ 2. **Clone the Forked Repository**
10
+
11
+ ```bash
12
+ git clone https://github.com/yourusername/sharpapi-node-client.git
13
+ ```
14
+
15
+ 3. **Navigate to the Project Directory**
16
+
17
+ ```bash
18
+ cd sharpapi-node-client
19
+ ```
20
+
21
+ 4. **Create a New Branch**
22
+
23
+ ```bash
24
+ git checkout -b feature/your-feature-name
25
+ ```
26
+
27
+ 5. **Make Your Changes**
28
+
29
+ Implement your feature or bug fix.
30
+
31
+ 6. **Commit Your Changes**
32
+
33
+ ```bash
34
+ git add .
35
+ git commit -m "Add feature: Your Feature Name"
36
+ ```
37
+
38
+ 7. **Push to Your Fork**
39
+
40
+ ```bash
41
+ git push origin feature/your-feature-name
42
+ ```
43
+
44
+ 8. **Create a Pull Request**
45
+
46
+ Go to the original repository on GitHub and create a pull request from your forked repository.
47
+
48
+ ### Guidelines
49
+
50
+ - **Follow Coding Standards:** Ensure your code adheres to the existing coding style.
51
+ - **Write Tests:** Add tests for your new features or bug fixes.
52
+ - **Update Documentation:** If your changes affect the usage, update the documentation accordingly.
53
+ - **Provide Clear Descriptions:** Make sure your commit messages and pull request descriptions are clear and concise.
package/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ MIT License
2
+
3
+ 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:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ 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/README.md ADDED
@@ -0,0 +1,273 @@
1
+ ![SharpAPI GitHub cover](https://sharpapi.com/sharpapi-github-php-bg.jpg "SharpAPI Node.js Paraphrase")
2
+
3
+ # SharpAPI NodeJS Paraphrase SDK
4
+
5
+ ## 🚀 Automate text paraphrasing with AI-powered API
6
+
7
+ ### Leverage AI API to generate paraphrased versions of your text content for content creation, SEO, and more.
8
+
9
+ **SharpAPI.com Node.js Paraphrase SDK** enables developers to integrate advanced text paraphrasing capabilities into their Node.js applications. This SDK simplifies interaction with the SharpAPI paraphrasing service, providing a seamless way to generate alternative versions of your text content.
10
+
11
+ See more at [SharpAPI.com Website »](https://sharpapi.com/)
12
+
13
+ [![Version](https://img.shields.io/npm/v/@sharpapi/sharpapi-node-paraphrase.svg)](https://www.npmjs.com/package/@sharpapi/sharpapi-node-paraphrase)
14
+ [![License](https://img.shields.io/npm/l/@sharpapi/sharpapi-node-paraphrase.svg)](https://github.com/sharpapi/sharpapi-node-client/blob/master/LICENSE.md)
15
+
16
+ ## Requirements
17
+
18
+ - Node.js >= 16.x
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ npm i @sharpapi/sharpapi-node-paraphrase
24
+ ```
25
+
26
+ ---
27
+
28
+ ## Table of Contents
29
+
30
+ 1. [Installation](#installation)
31
+ 2. [Configuration](#configuration)
32
+ 3. [Usage](#usage)
33
+ - [Initialization](#initialization)
34
+ - [Available Methods](#available-methods)
35
+ 4. [Examples](#examples)
36
+ 5. [Contributing](#contributing)
37
+ 6. [License](#license)
38
+
39
+ ---
40
+
41
+ ## Installation
42
+
43
+ ### Prerequisites
44
+
45
+ - **Node.js** v16 or higher
46
+ - **npm** (Node Package Manager)
47
+
48
+ ### Install via npm
49
+
50
+ You can install the SharpAPI Node.js Paraphrase SDK using npm:
51
+
52
+ ```bash
53
+ npm install @sharpapi/sharpapi-node-paraphrase
54
+ ```
55
+
56
+ ### Install via Yarn
57
+
58
+ Alternatively, if you prefer using Yarn:
59
+
60
+ ```bash
61
+ yarn add @sharpapi/sharpapi-node-paraphrase
62
+ ```
63
+
64
+ ---
65
+
66
+ ## Configuration
67
+
68
+ ### Setting Up Environment Variables
69
+
70
+ To protect your credentials, it's recommended to use a `.env` file to store your SharpAPI API key. Follow these steps:
71
+
72
+ 1. **Create a `.env` File**
73
+
74
+ In the root directory of your project, create a file named `.env`:
75
+
76
+ ```plaintext
77
+ SHARP_API_KEY=your_actual_api_key_here
78
+ ```
79
+
80
+ 2. **Install `dotenv` Package**
81
+
82
+ To load environment variables from the `.env` file, install the `dotenv` package:
83
+
84
+ ```bash
85
+ npm install dotenv
86
+ ```
87
+
88
+ 3. **Load Environment Variables**
89
+
90
+ At the beginning of your application (e.g., in `app.js` or `index.js`), add the following line to load the environment variables:
91
+
92
+ ```javascript
93
+ require('dotenv').config();
94
+ ```
95
+
96
+ 4. **Ensure `.env` is Ignored**
97
+
98
+ Add `.env` to your `.gitignore` file to prevent sensitive information from being committed to version control:
99
+
100
+ ```plaintext
101
+ # .gitignore
102
+ .env
103
+ ```
104
+
105
+ ---
106
+
107
+ ## Usage
108
+
109
+ ### Initialization
110
+
111
+ First, import and initialize the `SharpApiParaphraseService` with your API key:
112
+
113
+ ```javascript
114
+ // Load environment variables
115
+ require('dotenv').config();
116
+
117
+ // Import the SharpApiParaphraseService
118
+ const { SharpApiParaphraseService } = require('@sharpapi/sharpapi-node-paraphrase');
119
+
120
+ // Initialize the SharpApiParaphraseService
121
+ const apiKey = process.env.SHARP_API_KEY;
122
+ const paraphraseService = new SharpApiParaphraseService(apiKey);
123
+ ```
124
+
125
+ ### Available Methods
126
+
127
+ The `SharpApiParaphraseService` class provides a method to paraphrase text:
128
+
129
+ #### paraphrase(text, language, maxLength, voiceTone, context)
130
+
131
+ - **Description:** Generates a paraphrased version of the provided text.
132
+ - **Parameters:**
133
+ - `text` (string): The text to paraphrase.
134
+ - `language` (string, optional): Language of the paraphrase (default: 'English').
135
+ - `maxLength` (number, optional): Maximum length of the paraphrased text.
136
+ - `voiceTone` (string, optional): Tone of the voice in the paraphrase (e.g., 'Neutral').
137
+ - `context` (string, optional): Additional context for paraphrasing.
138
+ - **Returns:** A Promise that resolves to a status URL.
139
+ - **Usage:**
140
+ ```javascript
141
+ const statusUrl = await paraphraseService.paraphrase(
142
+ "Original text to paraphrase.",
143
+ "English",
144
+ 100,
145
+ "Neutral",
146
+ null
147
+ );
148
+
149
+ // Fetch the results using the core service
150
+ const { SharpApiCoreService } = require('@sharpapi/sharpapi-node-core');
151
+ const coreService = new SharpApiCoreService(apiKey);
152
+ const resultJob = await coreService.fetchResults(statusUrl);
153
+ console.log(resultJob.getResultJson());
154
+ ```
155
+
156
+ ## Examples
157
+
158
+ ### Basic Paraphrasing
159
+
160
+ ```javascript
161
+ require('dotenv').config();
162
+ const { SharpApiParaphraseService } = require('@sharpapi/sharpapi-node-paraphrase');
163
+ const { SharpApiCoreService } = require('@sharpapi/sharpapi-node-core');
164
+
165
+ async function paraphraseExample() {
166
+ const apiKey = process.env.SHARP_API_KEY;
167
+ const paraphraseService = new SharpApiParaphraseService(apiKey);
168
+ const coreService = new SharpApiCoreService(apiKey);
169
+
170
+ try {
171
+ // Original text to paraphrase
172
+ const originalText = "The quick brown fox jumps over the lazy dog.";
173
+
174
+ // Paraphrase the text
175
+ const statusUrl = await paraphraseService.paraphrase(originalText);
176
+
177
+ // Fetch the results
178
+ const resultJob = await coreService.fetchResults(statusUrl);
179
+ const result = resultJob.getResultJson();
180
+
181
+ console.log("Original Text:", originalText);
182
+ console.log("Paraphrased Text:", result.paraphrased_text);
183
+ } catch (error) {
184
+ console.error("Error:", error.message);
185
+ }
186
+ }
187
+
188
+ paraphraseExample();
189
+ ```
190
+
191
+ ### Advanced Paraphrasing with Options
192
+
193
+ ```javascript
194
+ require('dotenv').config();
195
+ const { SharpApiParaphraseService } = require('@sharpapi/sharpapi-node-paraphrase');
196
+ const { SharpApiCoreService } = require('@sharpapi/sharpapi-node-core');
197
+
198
+ async function advancedParaphraseExample() {
199
+ const apiKey = process.env.SHARP_API_KEY;
200
+ const paraphraseService = new SharpApiParaphraseService(apiKey);
201
+ const coreService = new SharpApiCoreService(apiKey);
202
+
203
+ try {
204
+ // Original text to paraphrase
205
+ const originalText = "The company has experienced significant growth in the last quarter, with revenue increasing by 25%.";
206
+
207
+ // Paraphrase the text with specific options
208
+ const statusUrl = await paraphraseService.paraphrase(
209
+ originalText,
210
+ "English",
211
+ 150,
212
+ "Professional",
213
+ "Financial report"
214
+ );
215
+
216
+ // Fetch the results
217
+ const resultJob = await coreService.fetchResults(statusUrl);
218
+ const result = resultJob.getResultJson();
219
+
220
+ console.log("Original Text:", originalText);
221
+ console.log("Paraphrased Text:", result.paraphrased_text);
222
+ } catch (error) {
223
+ console.error("Error:", error.message);
224
+ }
225
+ }
226
+
227
+ advancedParaphraseExample();
228
+ ```
229
+
230
+ ---
231
+
232
+ ## API Documentation
233
+
234
+ For detailed usage and API methods, please refer to the [SharpAPI.com Documentation](https://sharpapi.com/documentation).
235
+
236
+ ---
237
+
238
+ ## Changelog
239
+
240
+ Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
241
+
242
+ ---
243
+
244
+ ## Contributing
245
+
246
+ Check [CONTRIBUTION.md](CONTRIBUTION.md) file for details.
247
+
248
+ ---
249
+
250
+ ## License
251
+
252
+ This project is licensed under the [MIT License](LICENSE.md).
253
+
254
+ ---
255
+
256
+ ## Support
257
+
258
+ If you encounter any issues or have questions, feel free to open an issue on the [GitHub repository](https://github.com/sharpapi/sharpapi-node-client/issues) or contact support at [contact@sharpapi.com](mailto:contact@sharpapi.com).
259
+
260
+ ---
261
+
262
+ ## Social Media
263
+
264
+ 🚀 For the latest news, tutorials, and case studies, don't forget to follow us on:
265
+ - [SharpAPI X (formerly Twitter)](https://x.com/SharpAPI)
266
+ - [SharpAPI YouTube](https://www.youtube.com/@SharpAPI)
267
+ - [SharpAPI Vimeo](https://vimeo.com/SharpAPI)
268
+ - [SharpAPI LinkedIn](https://www.linkedin.com/products/a2z-web-ltd-sharpapicom-automate-with-aipowered-api/)
269
+ - [SharpAPI Facebook](https://www.facebook.com/profile.php?id=61554115896974)
270
+
271
+ ---
272
+
273
+ **Happy Coding with SharpAPI Node.js Paraphrase SDK!**
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@sharpapi/sharpapi-node-paraphrase",
3
+ "version": "1.0.0",
4
+ "description": "SharpAPI.com Node.js SDK for paraphrasing text",
5
+ "main": "src/index.js",
6
+ "scripts": {
7
+ "test": "jest"
8
+ },
9
+ "keywords": [
10
+ "sharpapi",
11
+ "ai-powered",
12
+ "ai capabilities",
13
+ "api",
14
+ "ai api",
15
+ "api integration",
16
+ "artificial intelligence",
17
+ "natural language processing",
18
+ "restful api",
19
+ "nodejs",
20
+ "software development",
21
+ "content analysis",
22
+ "paraphrasing",
23
+ "text processing"
24
+ ],
25
+ "author": "Dawid Makowski <contact@sharpapi.com>",
26
+ "license": "MIT",
27
+ "dependencies": {
28
+ "@sharpapi/sharpapi-node-core": "file:../sharpapi-node-core"
29
+ },
30
+ "devDependencies": {
31
+ "jest": "^29.7.0"
32
+ },
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://github.com/sharpapi/sharpapi-node-paraphrase.git"
39
+ }
40
+ }
@@ -0,0 +1,29 @@
1
+ const { SharpApiCoreService, SharpApiJobTypeEnum } = require('@sharpapi/sharpapi-node-core');
2
+
3
+ /**
4
+ * Service for paraphrasing text using SharpAPI.com
5
+ */
6
+ class SharpApiParaphraseService extends SharpApiCoreService {
7
+ /**
8
+ * Generates a paraphrased version of the provided text.
9
+ *
10
+ * @param {string} text
11
+ * @param {string|null} language
12
+ * @param {number|null} maxLength
13
+ * @param {string|null} voiceTone
14
+ * @param {string|null} context
15
+ * @returns {Promise<string>} - The status URL.
16
+ */
17
+ async paraphrase(text, language = null, maxLength = null, voiceTone = null, context = null) {
18
+ const data = { content: text };
19
+ if (language) data.language = language;
20
+ if (maxLength) data.max_length = maxLength;
21
+ if (voiceTone) data.voice_tone = voiceTone;
22
+ if (context) data.context = context;
23
+
24
+ const response = await this.makeRequest('POST', SharpApiJobTypeEnum.CONTENT_PARAPHRASE.url, data);
25
+ return this.parseStatusUrl(response);
26
+ }
27
+ }
28
+
29
+ module.exports = { SharpApiParaphraseService };
package/src/index.js ADDED
@@ -0,0 +1,6 @@
1
+ // sharpapi-node-paraphrase/src/index.js
2
+ const { SharpApiParaphraseService } = require('./SharpApiParaphraseService');
3
+
4
+ module.exports = {
5
+ SharpApiParaphraseService,
6
+ };