@apiverve/invoicegenerator 1.1.12 → 1.1.14
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 +8 -7
- package/index.js +103 -18
- package/package.json +17 -4
- package/examples/basic.js +0 -71
- package/tmp/build.dat +0 -1
package/README.md
CHANGED
|
@@ -5,8 +5,9 @@ Invoice Generator is a simple tool for generating invoices. It returns a PDF of
|
|
|
5
5
|

|
|
6
6
|

|
|
7
7
|

|
|
8
|
+
[](https://www.npmjs.com/package/@apiverve/invoicegenerator)
|
|
8
9
|
|
|
9
|
-
This is a Javascript Wrapper for the [Invoice Generator API](https://apiverve.com/marketplace/invoicegenerator)
|
|
10
|
+
This is a Javascript Wrapper for the [Invoice Generator API](https://apiverve.com/marketplace/invoicegenerator?utm_source=npm&utm_medium=readme)
|
|
10
11
|
|
|
11
12
|
---
|
|
12
13
|
|
|
@@ -27,15 +28,15 @@ yarn add @apiverve/invoicegenerator
|
|
|
27
28
|
## Configuration
|
|
28
29
|
|
|
29
30
|
Before using the Invoice Generator 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 Invoice Generator API documentation is found here: [https://docs.apiverve.com/ref/invoicegenerator](https://docs.apiverve.com/ref/invoicegenerator).
|
|
39
|
+
The Invoice Generator API documentation is found here: [https://docs.apiverve.com/ref/invoicegenerator](https://docs.apiverve.com/ref/invoicegenerator?utm_source=npm&utm_medium=readme).
|
|
39
40
|
You can find parameters, example responses, and status codes documented here.
|
|
40
41
|
|
|
41
42
|
### Setup
|
|
@@ -231,7 +232,7 @@ async function makeRequest() {
|
|
|
231
232
|
|
|
232
233
|
## Customer Support
|
|
233
234
|
|
|
234
|
-
Need any assistance? [Get in touch with Customer Support](https://apiverve.com/contact).
|
|
235
|
+
Need any assistance? [Get in touch with Customer Support](https://apiverve.com/contact?utm_source=npm&utm_medium=readme).
|
|
235
236
|
|
|
236
237
|
---
|
|
237
238
|
|
|
@@ -243,14 +244,14 @@ Stay up to date by following [@apiverveHQ](https://twitter.com/apiverveHQ) on Tw
|
|
|
243
244
|
|
|
244
245
|
## Legal
|
|
245
246
|
|
|
246
|
-
All usage of the APIVerve website, API, and services is subject to the [APIVerve Terms of Service](https://apiverve.com/terms)
|
|
247
|
+
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).
|
|
247
248
|
|
|
248
249
|
---
|
|
249
250
|
|
|
250
251
|
## License
|
|
251
252
|
Licensed under the The MIT License (MIT)
|
|
252
253
|
|
|
253
|
-
Copyright (©)
|
|
254
|
+
Copyright (©) 2026 APIVerve, and EvlarSoft LLC
|
|
254
255
|
|
|
255
256
|
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:
|
|
256
257
|
|
package/index.js
CHANGED
|
@@ -13,16 +13,10 @@ class invoicegeneratorWrapper {
|
|
|
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') {
|
|
@@ -34,6 +28,102 @@ class invoicegeneratorWrapper {
|
|
|
34
28
|
|
|
35
29
|
// secure is deprecated, all requests must be made over HTTPS
|
|
36
30
|
this.baseURL = 'https://api.apiverve.com/v1/invoicegenerator';
|
|
31
|
+
|
|
32
|
+
// Validation rules for parameters (generated from schema)
|
|
33
|
+
this.validationRules = {"invoiceNumber":{"type":"string","required":true},"date":{"type":"string","required":false,"format":"date"},"from_name":{"type":"string","required":true},"from_street":{"type":"string","required":true},"from_city":{"type":"string","required":true},"from_state":{"type":"string","required":true,"maxLength":2},"from_zip":{"type":"string","required":true,"minLength":5,"maxLength":10},"to_name":{"type":"string","required":true},"to_street":{"type":"string","required":true},"to_city":{"type":"string","required":true},"to_state":{"type":"string","required":true,"maxLength":2},"to_zip":{"type":"string","required":true,"minLength":5,"maxLength":10},"job":{"type":"string","required":false},"paymentTerms":{"type":"string","required":false},"dueDate":{"type":"string","required":false,"format":"date"},"discount":{"type":"number","required":false,"min":0},"salesTax":{"type":"number","required":false,"min":0,"max":100},"currency":{"type":"string","required":false},"items":{"type":"array","required":true}};
|
|
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/invoicegenerator`);
|
|
126
|
+
}
|
|
37
127
|
}
|
|
38
128
|
|
|
39
129
|
async execute(query, callback) {
|
|
@@ -58,14 +148,8 @@ class invoicegeneratorWrapper {
|
|
|
58
148
|
}
|
|
59
149
|
}
|
|
60
150
|
|
|
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/invoicegenerator`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
151
|
+
// Validate parameters against schema rules
|
|
152
|
+
this.validateParams(query);
|
|
69
153
|
|
|
70
154
|
const method = 'POST';
|
|
71
155
|
const url = method === 'POST' ? this.baseURL : this.constructURL(query);
|
|
@@ -108,7 +192,7 @@ class invoicegeneratorWrapper {
|
|
|
108
192
|
constructURL(query) {
|
|
109
193
|
let url = this.baseURL;
|
|
110
194
|
|
|
111
|
-
if(query && typeof query === 'object')
|
|
195
|
+
if(query && typeof query === 'object')
|
|
112
196
|
{
|
|
113
197
|
if (Object.keys(query).length > 0) {
|
|
114
198
|
const queryString = Object.keys(query)
|
|
@@ -119,6 +203,7 @@ class invoicegeneratorWrapper {
|
|
|
119
203
|
}
|
|
120
204
|
return url;
|
|
121
205
|
}
|
|
206
|
+
|
|
122
207
|
}
|
|
123
208
|
|
|
124
209
|
module.exports = invoicegeneratorWrapper;
|
package/package.json
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apiverve/invoicegenerator",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.14",
|
|
4
4
|
"description": "Invoice Generator is a simple tool for generating invoices. It returns a PDF of the generated invoice.",
|
|
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/invoicegenerator-api/issues"
|
|
23
36
|
},
|
|
24
|
-
"homepage": "https://apiverve.com/marketplace/invoicegenerator?utm_source=npm",
|
|
37
|
+
"homepage": "https://apiverve.com/marketplace/invoicegenerator?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,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Basic Example - Invoice Generator API
|
|
3
|
-
*
|
|
4
|
-
* This example demonstrates how to use the Invoice Generator 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 invoicegeneratorAPI = require('../index.js');
|
|
10
|
-
|
|
11
|
-
// Initialize the API client
|
|
12
|
-
const api = new invoicegeneratorAPI({
|
|
13
|
-
api_key: process.env.API_KEY || '[YOUR_API_KEY]'
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
// Example query
|
|
17
|
-
var query = {
|
|
18
|
-
"invoiceNumber": "INV000001",
|
|
19
|
-
"date": "2025-02-01",
|
|
20
|
-
"dueDate": "2025-11-30",
|
|
21
|
-
"from": {
|
|
22
|
-
"from_name": "John Doe",
|
|
23
|
-
"from_street": "123 Elm St",
|
|
24
|
-
"from_city": "Springfield",
|
|
25
|
-
"from_state": "IL",
|
|
26
|
-
"from_zip": "62701"
|
|
27
|
-
},
|
|
28
|
-
"to": {
|
|
29
|
-
"to_name": "Jane Smith",
|
|
30
|
-
"to_street": "456 Oak St",
|
|
31
|
-
"to_city": "Springfield",
|
|
32
|
-
"to_state": "IL",
|
|
33
|
-
"to_zip": "62702"
|
|
34
|
-
},
|
|
35
|
-
"job": "Web Development",
|
|
36
|
-
"paymentTerms": "Net 30",
|
|
37
|
-
"discount": 10,
|
|
38
|
-
"salesTax": 37.07,
|
|
39
|
-
"currency": "USD",
|
|
40
|
-
"items": [
|
|
41
|
-
{
|
|
42
|
-
"qty": 2,
|
|
43
|
-
"description": "Web Design Services",
|
|
44
|
-
"unit_price": 500
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"qty": 1,
|
|
48
|
-
"description": "Domain Registration",
|
|
49
|
-
"unit_price": 100
|
|
50
|
-
}
|
|
51
|
-
]
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
// Make the API request using callback
|
|
55
|
-
console.log('Making request to Invoice Generator API...\n');
|
|
56
|
-
|
|
57
|
-
api.execute(query, function (error, data) {
|
|
58
|
-
if (error) {
|
|
59
|
-
console.error('Error occurred:');
|
|
60
|
-
if (error.error) {
|
|
61
|
-
console.error('Message:', error.error);
|
|
62
|
-
console.error('Status:', error.status);
|
|
63
|
-
} else {
|
|
64
|
-
console.error(JSON.stringify(error, null, 2));
|
|
65
|
-
}
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
console.log('Response:');
|
|
70
|
-
console.log(JSON.stringify(data, null, 2));
|
|
71
|
-
});
|
package/tmp/build.dat
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#
|