@konversi/konversi-client 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/axiosAPI.ts ADDED
@@ -0,0 +1,23 @@
1
+ import axios from 'axios';
2
+
3
+ const baseURL = 'https://us.api.konversi.net/api'
4
+ const timeout = 30000
5
+
6
+ const instance = axios.create({
7
+ baseURL,
8
+ timeout
9
+ })
10
+
11
+ export const setAuthToken = (token: string) => {
12
+ instance.defaults.headers.common.authorization = `Bearer ${token}`
13
+ }
14
+
15
+ export const setCompanyId = (companyId: string) => {
16
+ instance.defaults.headers.common['Company'] = companyId;
17
+ }
18
+
19
+ export const clearAuthToken = () => {
20
+ instance.defaults.headers.common.authorization = ''
21
+ }
22
+
23
+ export default instance;
@@ -0,0 +1,71 @@
1
+ export const COMPANY_PERMISSION = 'company-permission';
2
+ export const COMPANY_OPTION = 'company-option';
3
+ export const INVITATION = 'user/invitation';
4
+
5
+ export const CUSTOMER = 'contact/customer';
6
+
7
+ export const PRODUCT = 'product'
8
+ export const PRODUCT_ITEM = 'product/product-item'
9
+ export const PRODUCT_GROUP = 'product-group'
10
+
11
+ export const PURCHASE_ORDER = 'order/purchase-order'
12
+ export const PURCHASE_ORDER_LINE = 'order/purchase-order-line'
13
+ export const QUOTE = 'order/quote'
14
+ export const QUOTE_LINE = 'order/quote-line'
15
+ export const SALES_ORDER = 'order/sales-order'
16
+ export const SALES_ORDER_LINE = 'order/sales-order-line'
17
+ export const RENTAL_ORDER = 'order/rental-order'
18
+ export const RENTAL_ORDER_LINE = 'order/rental-order-line'
19
+ export const SUPPLIER = 'contact/supplier'
20
+ export const WAREHOUSE = 'warehouse'
21
+
22
+ // Deliveries
23
+ export const INCOMING_DELIVERY = 'delivery/incoming-delivery'
24
+ export const INCOMING_DELIVERY_LINE = 'delivery/incoming-delivery-line'
25
+ export const OUTGOING_DELIVERY = 'delivery/outgoing-delivery'
26
+ export const OUTGOING_DELIVERY_LINE = 'delivery/outgoing-delivery-line'
27
+ export const INTERNAL_DELIVERY = 'delivery/internal-delivery'
28
+ export const INTERNAL_DELIVERY_LINE = 'delivery/internal-delivery-line'
29
+
30
+ // Finance
31
+ export const INVOICE = 'invoice'
32
+ export const INVOICE_LINE = 'invoice/invoice-line'
33
+ export const PAYMENT = 'accounting/payment'
34
+ export const INCOMING_PAYMENT_METHOD = 'accounting/incoming-payment-method'
35
+ export const FIXED_ASSET = 'fixed-asset'
36
+
37
+ // ECommerce
38
+ export const STORE = 'store'
39
+ export const STORE_PRODUCT = 'store/store-product'
40
+ export const STORE_PRODUCT_GROUP = 'store/store-product-group'
41
+
42
+ // Accounting
43
+ export const ACCOUNT = 'accounting/account';
44
+ export const JOURNAL_ENTRY = 'accounting/journal-entry';
45
+ export const JOURNAL_ENTRY_LINE = 'accounting/journal-entry-line';
46
+
47
+ // Manufacturing
48
+ export const BILL_OF_MATERIALS = 'manufacturing/bill-of-materials'
49
+ export const BOM_COMPONENT = 'manufacturing/bom-component'
50
+ export const PRODUCTION_ORDER = 'manufacturing/production-order'
51
+ export const PRODUCTION_ORDER_LINE = 'manufacturing/production-order-line'
52
+
53
+ export const SUBSIDIARY = 'subsidiary'
54
+
55
+ // HR
56
+ export const EMPLOYEE = 'human-resources/employee'
57
+ export const ATTENDANCE = 'human-resources/attendance'
58
+
59
+ // TODO: Deprecate
60
+ export const INCOMING_SHIPMENT = 'shipment/incoming-shipment'
61
+ export const OUTGOING_SHIPMENT = 'shipment/outgoing-shipment'
62
+ ///
63
+
64
+ export const STOCK_ADJUSTMENT = 'stock-adjustment'
65
+
66
+ export const PURCHASE_ORDER_APPROVER = 'approval/approver/purchase-order'
67
+ export const SALES_ORDER_APPROVER = 'approval/approver/sales-order'
68
+
69
+ export const CUSTOM_FIELD = 'custom-field'
70
+
71
+ export const AUDIT_LOG = 'audit-log'
package/index.ts ADDED
@@ -0,0 +1,43 @@
1
+ import axiosAPI, { setAuthToken } from "./axiosAPI";
2
+
3
+ function setToken(token: string) {
4
+ setAuthToken(token);
5
+ }
6
+
7
+ async function getAllObjects(entity, queryParams = {}) {
8
+ const response = await axiosAPI.get(`${entity}`, {
9
+ params: queryParams
10
+ })
11
+ return response.data;
12
+ }
13
+
14
+ async function getObjectById(entity, id) {
15
+ const response = await axiosAPI.get(`${entity}/${id}`)
16
+ return response.data;
17
+ }
18
+
19
+ async function updateObject(entity, id, newData) {
20
+ const response = await axiosAPI.put(`${entity}/${id}`, newData)
21
+ return response.data;
22
+ }
23
+
24
+ async function createObject(entity, data) {
25
+ const response = await axiosAPI.post(`${entity}`, data)
26
+
27
+ return response.data;
28
+ }
29
+
30
+ async function deleteObject(entity, id) {
31
+ const response = await axiosAPI.delete(`${entity}/${id}`)
32
+
33
+ return response.data;
34
+ }
35
+
36
+ const konversiAPI = {
37
+ setToken,
38
+ getAllObjects,
39
+ getObjectById,
40
+ updateObject,
41
+ createObject,
42
+ deleteObject
43
+ }
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "@konversi/konversi-client",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1"
7
+ },
8
+ "keywords": [],
9
+ "author": "",
10
+ "license": "ISC",
11
+ "dependencies": {
12
+ "axios": "^1.6.8"
13
+ },
14
+ "devDependencies": {},
15
+ "description": ""
16
+ }