timber-node 0.4.4 → 0.4.6
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 +127 -123
- package/dist/auth.js +1 -1
- package/dist/bankStatement.js +4 -2
- package/dist/billPayment.js +4 -4
- package/dist/cheque.js +2 -2
- package/dist/company.d.ts +15 -1
- package/dist/company.js +4 -4
- package/dist/customer.d.ts +1 -0
- package/dist/customer.js +52 -12
- package/dist/employee.js +1 -1
- package/dist/expense.js +5 -5
- package/dist/expenseCategory.js +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/invoice.js +35 -38
- package/dist/invoiceItem.js +4 -4
- package/dist/invoiceNumber.js +3 -3
- package/dist/invoicePayment.js +7 -5
- package/dist/{invoiceTemplates.d.ts → invoiceSettings.d.ts} +19 -19
- package/dist/{invoiceTemplates.js → invoiceSettings.js} +18 -18
- package/dist/rawExpense.js +3 -3
- package/dist/salary.js +4 -4
- package/dist/taxRate.d.ts +24 -2
- package/dist/taxRate.js +24 -4
- package/dist/utils/convertToFormData.d.ts +8 -0
- package/dist/utils/convertToFormData.js +71 -0
- package/dist/vendorPayment.js +6 -6
- package/package.json +63 -63
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertToFormData = convertToFormData;
|
|
4
|
+
/**
|
|
5
|
+
* Converts a nested object to FormData
|
|
6
|
+
* @param obj - The object to convert
|
|
7
|
+
* @param formData - The FormData instance (optional, creates new if not provided)
|
|
8
|
+
* @param parentKey - The parent key for nested properties (used internally)
|
|
9
|
+
* @returns FormData instance
|
|
10
|
+
*/
|
|
11
|
+
function convertToFormData(obj, formData = new FormData(), parentKey = '') {
|
|
12
|
+
if (obj === null || obj === undefined) {
|
|
13
|
+
return formData;
|
|
14
|
+
}
|
|
15
|
+
Object.keys(obj).forEach((key) => {
|
|
16
|
+
const value = obj[key];
|
|
17
|
+
const formKey = parentKey ? `${parentKey}[${key}]` : key;
|
|
18
|
+
// Handle null or undefined values - skip them
|
|
19
|
+
if (value === null || value === undefined) {
|
|
20
|
+
formData.append(formKey, '');
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
// Handle File objects
|
|
24
|
+
if (value instanceof File) {
|
|
25
|
+
formData.append(formKey, value);
|
|
26
|
+
}
|
|
27
|
+
// Handle Blob objects
|
|
28
|
+
else if (value instanceof Blob) {
|
|
29
|
+
formData.append(formKey, value);
|
|
30
|
+
}
|
|
31
|
+
// Handle Date objects
|
|
32
|
+
else if (value instanceof Date) {
|
|
33
|
+
formData.append(formKey, value.toISOString());
|
|
34
|
+
}
|
|
35
|
+
// Handle Arrays
|
|
36
|
+
else if (Array.isArray(value)) {
|
|
37
|
+
// Handle empty arrays - mark them so backend can reconstruct
|
|
38
|
+
if (value.length === 0) {
|
|
39
|
+
formData.append(formKey, '[]');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
value.forEach((item, index) => {
|
|
43
|
+
const arrayKey = `${formKey}[${index}]`;
|
|
44
|
+
// If array item is an object, recurse
|
|
45
|
+
if (typeof item === 'object' &&
|
|
46
|
+
item !== null &&
|
|
47
|
+
!(item instanceof File) &&
|
|
48
|
+
!(item instanceof Blob)) {
|
|
49
|
+
convertToFormData(item, formData, arrayKey);
|
|
50
|
+
}
|
|
51
|
+
// If array item is a primitive or File/Blob, append with indexed key
|
|
52
|
+
else if (item !== null && item !== undefined) {
|
|
53
|
+
formData.append(arrayKey, item);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
// Handle nested objects (but not File/Blob/Date)
|
|
58
|
+
else if (typeof value === 'object' &&
|
|
59
|
+
!(value instanceof File) &&
|
|
60
|
+
!(value instanceof Blob) &&
|
|
61
|
+
!(value instanceof Date)) {
|
|
62
|
+
convertToFormData(value, formData, formKey);
|
|
63
|
+
}
|
|
64
|
+
// Handle primitives (string, number, boolean)
|
|
65
|
+
else {
|
|
66
|
+
// Convert booleans and numbers to strings
|
|
67
|
+
formData.append(formKey, String(value));
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return formData;
|
|
71
|
+
}
|
package/dist/vendorPayment.js
CHANGED
|
@@ -30,7 +30,7 @@ class VendorPaymentService {
|
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
32
|
async list(params) {
|
|
33
|
-
return await this.http.get('/customer/purchase', {
|
|
33
|
+
return await this.http.get('/user/sdk/customer/purchase', {
|
|
34
34
|
params,
|
|
35
35
|
});
|
|
36
36
|
}
|
|
@@ -47,7 +47,7 @@ class VendorPaymentService {
|
|
|
47
47
|
* ```
|
|
48
48
|
*/
|
|
49
49
|
async get(id) {
|
|
50
|
-
return await this.http.get(`/customer/purchase/${id}`);
|
|
50
|
+
return await this.http.get(`/user/sdk/customer/purchase/${id}`);
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
53
|
* Create a new vendor payment.
|
|
@@ -150,7 +150,7 @@ class VendorPaymentService {
|
|
|
150
150
|
if (data.logo) {
|
|
151
151
|
formData.append('file', data.logo);
|
|
152
152
|
}
|
|
153
|
-
return await this.http.post('/customer/purchase', formData, {
|
|
153
|
+
return await this.http.post('/user/sdk/customer/purchase', formData, {
|
|
154
154
|
headers,
|
|
155
155
|
});
|
|
156
156
|
}
|
|
@@ -210,7 +210,7 @@ class VendorPaymentService {
|
|
|
210
210
|
if (data.logo) {
|
|
211
211
|
formData.append('file', data.logo);
|
|
212
212
|
}
|
|
213
|
-
return await this.http.put(`/customer/purchase/${id}`, formData, {
|
|
213
|
+
return await this.http.put(`/user/sdk/customer/purchase/${id}`, formData, {
|
|
214
214
|
headers,
|
|
215
215
|
});
|
|
216
216
|
}
|
|
@@ -227,7 +227,7 @@ class VendorPaymentService {
|
|
|
227
227
|
* ```
|
|
228
228
|
*/
|
|
229
229
|
async delete(id) {
|
|
230
|
-
return await this.http.patch(`/customer/purchase/${id}`);
|
|
230
|
+
return await this.http.patch(`/user/sdk/customer/purchase/${id}`);
|
|
231
231
|
}
|
|
232
232
|
/**
|
|
233
233
|
* Download a vendor payment PDF by ID.
|
|
@@ -242,7 +242,7 @@ class VendorPaymentService {
|
|
|
242
242
|
* ```
|
|
243
243
|
*/
|
|
244
244
|
async download(id) {
|
|
245
|
-
return await this.http.get(`/customer/purchase/download/${id}`, {
|
|
245
|
+
return await this.http.get(`/user/sdk/customer/purchase/download/${id}`, {
|
|
246
246
|
responseType: 'arraybuffer', // Important: tells Axios to treat the response as binary
|
|
247
247
|
});
|
|
248
248
|
}
|
package/package.json
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "timber-node",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"description": "Simplifying accounting and tax filing for businesses",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"timber"
|
|
7
|
-
],
|
|
8
|
-
"homepage": "https://github.com/TImber-UAE/timber-be-sdk-s#readme",
|
|
9
|
-
"bugs": {
|
|
10
|
-
"url": "https://github.com/TImber-UAE/timber-be-sdk-s/issues"
|
|
11
|
-
},
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/TImber-UAE/timber-be-sdk-s.git"
|
|
15
|
-
},
|
|
16
|
-
"license": "MIT",
|
|
17
|
-
"author": "timberaccounting",
|
|
18
|
-
"main": "dist/index.js",
|
|
19
|
-
"types": "dist/index.d.ts",
|
|
20
|
-
"exports": {
|
|
21
|
-
".": {
|
|
22
|
-
"require": "./dist/index.js",
|
|
23
|
-
"default": "./dist/index.js"
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
"scripts": {
|
|
27
|
-
"dev": "nodemon src/index.js",
|
|
28
|
-
"build": "tsc",
|
|
29
|
-
"docs": "typedoc",
|
|
30
|
-
"prepare": "husky",
|
|
31
|
-
"lint": "eslint . --ext .ts,.js",
|
|
32
|
-
"lint:fix": "eslint . --ext .ts,.js --fix"
|
|
33
|
-
},
|
|
34
|
-
"lint-staged": {
|
|
35
|
-
"*.{js,ts,json,md}": [
|
|
36
|
-
"prettier --write",
|
|
37
|
-
"eslint --fix"
|
|
38
|
-
]
|
|
39
|
-
},
|
|
40
|
-
"dependencies": {
|
|
41
|
-
"axios": "^1.10.0",
|
|
42
|
-
"form-data": "^4.0.3",
|
|
43
|
-
"timber-node": "^0.0.5",
|
|
44
|
-
"typescript-eslint": "^8.35.0"
|
|
45
|
-
},
|
|
46
|
-
"devDependencies": {
|
|
47
|
-
"@commitlint/cli": "^19.8.1",
|
|
48
|
-
"@commitlint/config-conventional": "^19.8.1",
|
|
49
|
-
"@types/node": "^24.0.4",
|
|
50
|
-
"@typescript-eslint/eslint-plugin": "^8.35.0",
|
|
51
|
-
"@typescript-eslint/parser": "^8.35.0",
|
|
52
|
-
"eslint": "^9.29.0",
|
|
53
|
-
"eslint-config-prettier": "^10.1.5",
|
|
54
|
-
"eslint-plugin-prettier": "^5.5.1",
|
|
55
|
-
"globals": "^16.2.0",
|
|
56
|
-
"husky": "^8.0.3",
|
|
57
|
-
"nodemon": "^3.1.10",
|
|
58
|
-
"prettier": "^3.6.2",
|
|
59
|
-
"typedoc": "^0.28.5",
|
|
60
|
-
"typedoc-plugin-markdown": "^4.7.0",
|
|
61
|
-
"typescript": "^5.8.3"
|
|
62
|
-
}
|
|
63
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "timber-node",
|
|
3
|
+
"version": "0.4.6",
|
|
4
|
+
"description": "Simplifying accounting and tax filing for businesses",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"timber"
|
|
7
|
+
],
|
|
8
|
+
"homepage": "https://github.com/TImber-UAE/timber-be-sdk-s#readme",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/TImber-UAE/timber-be-sdk-s/issues"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/TImber-UAE/timber-be-sdk-s.git"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"author": "timberaccounting",
|
|
18
|
+
"main": "dist/index.js",
|
|
19
|
+
"types": "dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"require": "./dist/index.js",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"dev": "nodemon src/index.js",
|
|
28
|
+
"build": "tsc",
|
|
29
|
+
"docs": "typedoc",
|
|
30
|
+
"prepare": "husky",
|
|
31
|
+
"lint": "eslint . --ext .ts,.js",
|
|
32
|
+
"lint:fix": "eslint . --ext .ts,.js --fix"
|
|
33
|
+
},
|
|
34
|
+
"lint-staged": {
|
|
35
|
+
"*.{js,ts,json,md}": [
|
|
36
|
+
"prettier --write",
|
|
37
|
+
"eslint --fix"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"axios": "^1.10.0",
|
|
42
|
+
"form-data": "^4.0.3",
|
|
43
|
+
"timber-node": "^0.0.5",
|
|
44
|
+
"typescript-eslint": "^8.35.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@commitlint/cli": "^19.8.1",
|
|
48
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
49
|
+
"@types/node": "^24.0.4",
|
|
50
|
+
"@typescript-eslint/eslint-plugin": "^8.35.0",
|
|
51
|
+
"@typescript-eslint/parser": "^8.35.0",
|
|
52
|
+
"eslint": "^9.29.0",
|
|
53
|
+
"eslint-config-prettier": "^10.1.5",
|
|
54
|
+
"eslint-plugin-prettier": "^5.5.1",
|
|
55
|
+
"globals": "^16.2.0",
|
|
56
|
+
"husky": "^8.0.3",
|
|
57
|
+
"nodemon": "^3.1.10",
|
|
58
|
+
"prettier": "^3.6.2",
|
|
59
|
+
"typedoc": "^0.28.5",
|
|
60
|
+
"typedoc-plugin-markdown": "^4.7.0",
|
|
61
|
+
"typescript": "^5.8.3"
|
|
62
|
+
}
|
|
63
|
+
}
|