@ireceipt.pro/js 2.0.5 → 2.0.7
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/dist/cjs/index.js +9 -10
- package/dist/cjs/methods/createFile.js +4 -5
- package/dist/cjs/methods/index.js +2 -3
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/utils/constants.js +0 -1
- package/dist/cjs/utils/handleError.js +0 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/methods/createFile.js +2 -3
- package/dist/esm/methods/index.js +1 -2
- package/dist/esm/utils/constants.js +0 -1
- package/dist/esm/utils/handleError.js +0 -1
- package/package.json +5 -6
- package/dist/types/index.d.ts +0 -130
- package/dist/types/methods/createFile.d.ts +0 -6
- package/dist/types/methods/index.d.ts +0 -2
- package/dist/types/utils/constants.d.ts +0 -1
- package/dist/types/utils/handleError.d.ts +0 -2
package/dist/cjs/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.IReceiptPRO = void 0;
|
|
4
|
-
const
|
|
4
|
+
const index_js_1 = require("./methods/index.js");
|
|
5
5
|
class IReceiptPRO {
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
@@ -29,7 +29,7 @@ class IReceiptPRO {
|
|
|
29
29
|
createJpgFromPublicTemplate(templateId, args, size) {
|
|
30
30
|
if (!this.apiKey)
|
|
31
31
|
throw new Error("Initialization is required before use");
|
|
32
|
-
return (0,
|
|
32
|
+
return (0, index_js_1.createFile)(this.apiKey, "jpg", "public", templateId, args, size);
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Create PDF File from public template
|
|
@@ -42,7 +42,7 @@ class IReceiptPRO {
|
|
|
42
42
|
createPdfFromPublicTemplate(templateId, args, size) {
|
|
43
43
|
if (!this.apiKey)
|
|
44
44
|
throw new Error("Initialization is required before use");
|
|
45
|
-
return (0,
|
|
45
|
+
return (0, index_js_1.createFile)(this.apiKey, "pdf", "public", templateId, args, size);
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* Create PNG Image from public template
|
|
@@ -55,7 +55,7 @@ class IReceiptPRO {
|
|
|
55
55
|
createPngFromPublicTemplate(templateId, args, size) {
|
|
56
56
|
if (!this.apiKey)
|
|
57
57
|
throw new Error("Initialization is required before use");
|
|
58
|
-
return (0,
|
|
58
|
+
return (0, index_js_1.createFile)(this.apiKey, "png", "public", templateId, args, size);
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
61
|
* Create WEBP Image from public template
|
|
@@ -68,7 +68,7 @@ class IReceiptPRO {
|
|
|
68
68
|
createWebpFromPublicTemplate(templateId, args, size) {
|
|
69
69
|
if (!this.apiKey)
|
|
70
70
|
throw new Error("Initialization is required before use");
|
|
71
|
-
return (0,
|
|
71
|
+
return (0, index_js_1.createFile)(this.apiKey, "webp", "public", templateId, args, size);
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
74
|
* Create JPG Image from private template,
|
|
@@ -82,7 +82,7 @@ class IReceiptPRO {
|
|
|
82
82
|
createJpgFromPrivateTemplate(templateId, args, size) {
|
|
83
83
|
if (!this.apiKey)
|
|
84
84
|
throw new Error("Initialization is required before use");
|
|
85
|
-
return (0,
|
|
85
|
+
return (0, index_js_1.createFile)(this.apiKey, "jpg", "private", templateId, args, size);
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
88
|
* Create PDF File from private template,
|
|
@@ -96,7 +96,7 @@ class IReceiptPRO {
|
|
|
96
96
|
createPdfFromPrivateTemplate(templateId, args, size) {
|
|
97
97
|
if (!this.apiKey)
|
|
98
98
|
throw new Error("Initialization is required before use");
|
|
99
|
-
return (0,
|
|
99
|
+
return (0, index_js_1.createFile)(this.apiKey, "pdf", "private", templateId, args, size);
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
102
|
* Create PNG Image from private template,
|
|
@@ -110,7 +110,7 @@ class IReceiptPRO {
|
|
|
110
110
|
createPngFromPrivateTemplate(templateId, args, size) {
|
|
111
111
|
if (!this.apiKey)
|
|
112
112
|
throw new Error("Initialization is required before use");
|
|
113
|
-
return (0,
|
|
113
|
+
return (0, index_js_1.createFile)(this.apiKey, "png", "private", templateId, args, size);
|
|
114
114
|
}
|
|
115
115
|
/**
|
|
116
116
|
* Create WEBP Image from private template,
|
|
@@ -124,8 +124,7 @@ class IReceiptPRO {
|
|
|
124
124
|
createWebpFromPrivateTemplate(templateId, args, size) {
|
|
125
125
|
if (!this.apiKey)
|
|
126
126
|
throw new Error("Initialization is required before use");
|
|
127
|
-
return (0,
|
|
127
|
+
return (0, index_js_1.createFile)(this.apiKey, "webp", "private", templateId, args, size);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
exports.IReceiptPRO = IReceiptPRO;
|
|
131
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createFile = void 0;
|
|
4
4
|
const axios_1 = require("axios");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const constants_js_1 = require("../utils/constants.js");
|
|
6
|
+
const handleError_js_1 = require("../utils/handleError.js");
|
|
7
7
|
const createFile = async (apiKey, type, templateType, templateId, args, size) => {
|
|
8
8
|
let attempt = 1;
|
|
9
9
|
let buffer;
|
|
10
10
|
let error;
|
|
11
11
|
while (attempt <= 5 && !buffer) {
|
|
12
12
|
try {
|
|
13
|
-
const res = await axios_1.default.post(`${
|
|
13
|
+
const res = await axios_1.default.post(`${constants_js_1.apiUrl}${type}/${templateType}/${templateId}`, {
|
|
14
14
|
variables: args || {},
|
|
15
15
|
size,
|
|
16
16
|
}, {
|
|
@@ -28,7 +28,7 @@ const createFile = async (apiKey, type, templateType, templateId, args, size) =>
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
catch (err) {
|
|
31
|
-
error = (0,
|
|
31
|
+
error = (0, handleError_js_1.handleError)(err);
|
|
32
32
|
}
|
|
33
33
|
attempt += 1;
|
|
34
34
|
if (!buffer)
|
|
@@ -41,4 +41,3 @@ const createFile = async (apiKey, type, templateType, templateId, args, size) =>
|
|
|
41
41
|
return buffer;
|
|
42
42
|
};
|
|
43
43
|
exports.createFile = createFile;
|
|
44
|
-
//# sourceMappingURL=createFile.js.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createFile = void 0;
|
|
4
|
-
const
|
|
5
|
-
Object.defineProperty(exports, "createFile", { enumerable: true, get: function () { return
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
4
|
+
const createFile_js_1 = require("./createFile.js");
|
|
5
|
+
Object.defineProperty(exports, "createFile", { enumerable: true, get: function () { return createFile_js_1.createFile; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createFile } from
|
|
1
|
+
import { createFile } from "./methods/index.js";
|
|
2
2
|
export class IReceiptPRO {
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
@@ -124,4 +124,3 @@ export class IReceiptPRO {
|
|
|
124
124
|
return createFile(this.apiKey, "webp", "private", templateId, args, size);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
|
-
import { apiUrl } from
|
|
3
|
-
import { handleError } from
|
|
2
|
+
import { apiUrl } from "../utils/constants.js";
|
|
3
|
+
import { handleError } from "../utils/handleError.js";
|
|
4
4
|
export const createFile = async (apiKey, type, templateType, templateId, args, size) => {
|
|
5
5
|
let attempt = 1;
|
|
6
6
|
let buffer;
|
|
@@ -37,4 +37,3 @@ export const createFile = async (apiKey, type, templateType, templateId, args, s
|
|
|
37
37
|
throw error;
|
|
38
38
|
return buffer;
|
|
39
39
|
};
|
|
40
|
-
//# sourceMappingURL=createFile.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ireceipt.pro/js",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
4
4
|
"description": "Create PDF files or images (JPG, PNG, WEBP) from your HTML template.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
|
-
"dist/esm/**/*.js",
|
|
23
|
-
"dist/cjs/**/*.js",
|
|
22
|
+
"dist/esm/**/*.js{,on}",
|
|
23
|
+
"dist/cjs/**/*.js{,on}",
|
|
24
24
|
"dist/types/**/*",
|
|
25
25
|
"README.md",
|
|
26
26
|
"LICENSE"
|
|
@@ -29,13 +29,12 @@
|
|
|
29
29
|
"test": "tsx --test test/library.test.ts",
|
|
30
30
|
"cov": "node_modules/.bin/nyc npm run test",
|
|
31
31
|
"prebuild": "node_modules/.bin/eslint src/**/*.ts",
|
|
32
|
-
"build": "npm run clean && npm run build:types && npm run build:cjs && npm run build:esm && npm run build:package
|
|
32
|
+
"build": "npm run clean && npm run build:types && npm run build:cjs && npm run build:esm && npm run build:package",
|
|
33
33
|
"clean": "rm -rf dist lib",
|
|
34
34
|
"build:types": "tsc --project tsconfig.types.json",
|
|
35
35
|
"build:cjs": "tsc --project tsconfig.cjs.json",
|
|
36
36
|
"build:esm": "tsc --project tsconfig.esm.json",
|
|
37
37
|
"build:package": "echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
|
|
38
|
-
"fix:esm": "node scripts/fix-esm-imports.mjs",
|
|
39
38
|
"update": "eval \"$(node -e 'const t = require(`./package.json`);const ignore = require(`./ignoreUpdatesModules.json`);console.log(`npm i ${(Object.keys(t.dependencies || {}).filter((e)=>ignore.base.indexOf(e) === -1).map((e)=>(`${e}@latest`)).join(` `))} --save&&npm i ${(Object.keys(t.devDependencies || {}).filter((e)=>ignore.dev.indexOf(e) === -1).map((e)=>(`${e}@latest`)).join(` `))} --save-dev`);')\""
|
|
40
39
|
},
|
|
41
40
|
"author": {
|
|
@@ -91,7 +90,7 @@
|
|
|
91
90
|
"typescript-eslint": "^8.46.1"
|
|
92
91
|
},
|
|
93
92
|
"engines": {
|
|
94
|
-
"node": ">=
|
|
93
|
+
"node": ">=16"
|
|
95
94
|
},
|
|
96
95
|
"directories": {
|
|
97
96
|
"test": "./test/"
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
export declare class IReceiptPRO {
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* @param apiKey - IReceipt PRO API KEY, you can get it on <https://dashboard.ireceipt.pro>
|
|
5
|
-
*/
|
|
6
|
-
constructor(apiKey: string);
|
|
7
|
-
private apiKey;
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* @param apiKey - IReceipt PRO API KEY, you can get it on <https://dashboard.ireceipt.pro>
|
|
11
|
-
* @returns
|
|
12
|
-
*/
|
|
13
|
-
static useApiKey(apiKey: string): IReceiptPRO;
|
|
14
|
-
/**
|
|
15
|
-
* Create JPG Image from public template
|
|
16
|
-
*
|
|
17
|
-
* @param templateId - template id, you can find it on <https://dashboard.ireceipt.pro>
|
|
18
|
-
* @param args - arguments for substitution in the template
|
|
19
|
-
* @param size - the size of the file being created
|
|
20
|
-
* @returns
|
|
21
|
-
*/
|
|
22
|
-
createJpgFromPublicTemplate(templateId: string, args: {
|
|
23
|
-
[key: string]: unknown;
|
|
24
|
-
}, size?: {
|
|
25
|
-
width: number;
|
|
26
|
-
height: number;
|
|
27
|
-
}): Promise<Buffer<ArrayBufferLike>>;
|
|
28
|
-
/**
|
|
29
|
-
* Create PDF File from public template
|
|
30
|
-
*
|
|
31
|
-
* @param templateId - template id, you can find it on <https://dashboard.ireceipt.pro>
|
|
32
|
-
* @param args - arguments for substitution in the template
|
|
33
|
-
* @param size - the size of the file being created
|
|
34
|
-
* @returns
|
|
35
|
-
*/
|
|
36
|
-
createPdfFromPublicTemplate(templateId: string, args: {
|
|
37
|
-
[key: string]: unknown;
|
|
38
|
-
}, size?: {
|
|
39
|
-
width: number;
|
|
40
|
-
height: number;
|
|
41
|
-
}): Promise<Buffer<ArrayBufferLike>>;
|
|
42
|
-
/**
|
|
43
|
-
* Create PNG Image from public template
|
|
44
|
-
*
|
|
45
|
-
* @param templateId - template id, you can find it on <https://dashboard.ireceipt.pro>
|
|
46
|
-
* @param args - arguments for substitution in the template
|
|
47
|
-
* @param size - the size of the file being created
|
|
48
|
-
* @returns
|
|
49
|
-
*/
|
|
50
|
-
createPngFromPublicTemplate(templateId: string, args: {
|
|
51
|
-
[key: string]: unknown;
|
|
52
|
-
}, size?: {
|
|
53
|
-
width: number;
|
|
54
|
-
height: number;
|
|
55
|
-
}): Promise<Buffer<ArrayBufferLike>>;
|
|
56
|
-
/**
|
|
57
|
-
* Create WEBP Image from public template
|
|
58
|
-
*
|
|
59
|
-
* @param templateId - template id, you can find it on <https://dashboard.ireceipt.pro>
|
|
60
|
-
* @param args - arguments for substitution in the template
|
|
61
|
-
* @param size - the size of the file being created
|
|
62
|
-
* @returns
|
|
63
|
-
*/
|
|
64
|
-
createWebpFromPublicTemplate(templateId: string, args: {
|
|
65
|
-
[key: string]: unknown;
|
|
66
|
-
}, size?: {
|
|
67
|
-
width: number;
|
|
68
|
-
height: number;
|
|
69
|
-
}): Promise<Buffer<ArrayBufferLike>>;
|
|
70
|
-
/**
|
|
71
|
-
* Create JPG Image from private template,
|
|
72
|
-
* you can manage it on <https://dashboard.ireceipt.pro>
|
|
73
|
-
*
|
|
74
|
-
* @param templateId - template id, you can find it on <https://dashboard.ireceipt.pro>
|
|
75
|
-
* @param args - arguments for substitution in the template
|
|
76
|
-
* @param size - the size of the file being created
|
|
77
|
-
* @returns
|
|
78
|
-
*/
|
|
79
|
-
createJpgFromPrivateTemplate(templateId: string, args: {
|
|
80
|
-
[key: string]: unknown;
|
|
81
|
-
}, size?: {
|
|
82
|
-
width: number;
|
|
83
|
-
height: number;
|
|
84
|
-
}): Promise<Buffer<ArrayBufferLike>>;
|
|
85
|
-
/**
|
|
86
|
-
* Create PDF File from private template,
|
|
87
|
-
* you can manage it on <https://dashboard.ireceipt.pro>
|
|
88
|
-
*
|
|
89
|
-
* @param templateId - template id, you can find it on <https://dashboard.ireceipt.pro>
|
|
90
|
-
* @param args - arguments for substitution in the template
|
|
91
|
-
* @param size - the size of the file being created
|
|
92
|
-
* @returns
|
|
93
|
-
*/
|
|
94
|
-
createPdfFromPrivateTemplate(templateId: string, args: {
|
|
95
|
-
[key: string]: unknown;
|
|
96
|
-
}, size?: {
|
|
97
|
-
width: number;
|
|
98
|
-
height: number;
|
|
99
|
-
}): Promise<Buffer<ArrayBufferLike>>;
|
|
100
|
-
/**
|
|
101
|
-
* Create PNG Image from private template,
|
|
102
|
-
* you can manage it on <https://dashboard.ireceipt.pro>
|
|
103
|
-
*
|
|
104
|
-
* @param templateId - template id, you can find it on <https://dashboard.ireceipt.pro>
|
|
105
|
-
* @param args - arguments for substitution in the template
|
|
106
|
-
* @param size - the size of the file being created
|
|
107
|
-
* @returns
|
|
108
|
-
*/
|
|
109
|
-
createPngFromPrivateTemplate(templateId: string, args: {
|
|
110
|
-
[key: string]: unknown;
|
|
111
|
-
}, size?: {
|
|
112
|
-
width: number;
|
|
113
|
-
height: number;
|
|
114
|
-
}): Promise<Buffer<ArrayBufferLike>>;
|
|
115
|
-
/**
|
|
116
|
-
* Create WEBP Image from private template,
|
|
117
|
-
* you can manage it on <https://dashboard.ireceipt.pro>
|
|
118
|
-
*
|
|
119
|
-
* @param templateId - template id, you can find it on <https://dashboard.ireceipt.pro>
|
|
120
|
-
* @param args - arguments for substitution in the template
|
|
121
|
-
* @param size - the size of the file being created
|
|
122
|
-
* @returns
|
|
123
|
-
*/
|
|
124
|
-
createWebpFromPrivateTemplate(templateId: string, args: {
|
|
125
|
-
[key: string]: unknown;
|
|
126
|
-
}, size?: {
|
|
127
|
-
width: number;
|
|
128
|
-
height: number;
|
|
129
|
-
}): Promise<Buffer<ArrayBufferLike>>;
|
|
130
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const apiUrl = "https://api.ireceipt.pro/v1/";
|