@konversi/konversi-client 1.0.5 → 1.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.
@@ -0,0 +1,5 @@
1
+ declare const instance: import("axios").AxiosInstance;
2
+ export declare const setAuthToken: (token: string) => void;
3
+ export declare const setCompanyId: (companyId: string) => void;
4
+ export declare const clearAuthToken: () => void;
5
+ export default instance;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.clearAuthToken = exports.setCompanyId = exports.setAuthToken = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const baseURL = 'https://us.api.konversi.net/api';
9
+ const timeout = 30000;
10
+ const instance = axios_1.default.create({
11
+ baseURL,
12
+ timeout
13
+ });
14
+ const setAuthToken = (token) => {
15
+ instance.defaults.headers.common.authorization = `Bearer ${token}`;
16
+ };
17
+ exports.setAuthToken = setAuthToken;
18
+ const setCompanyId = (companyId) => {
19
+ instance.defaults.headers.common['Company'] = companyId;
20
+ };
21
+ exports.setCompanyId = setCompanyId;
22
+ const clearAuthToken = () => {
23
+ instance.defaults.headers.common.authorization = '';
24
+ };
25
+ exports.clearAuthToken = clearAuthToken;
26
+ exports.default = instance;
@@ -0,0 +1,48 @@
1
+ export declare const COMPANY_PERMISSION = "company-permission";
2
+ export declare const COMPANY_OPTION = "company-option";
3
+ export declare const INVITATION = "user/invitation";
4
+ export declare const CUSTOMER = "contact/customer";
5
+ export declare const PRODUCT = "product";
6
+ export declare const PRODUCT_ITEM = "product/product-item";
7
+ export declare const PRODUCT_GROUP = "product-group";
8
+ export declare const PURCHASE_ORDER = "order/purchase-order";
9
+ export declare const PURCHASE_ORDER_LINE = "order/purchase-order-line";
10
+ export declare const QUOTE = "order/quote";
11
+ export declare const QUOTE_LINE = "order/quote-line";
12
+ export declare const SALES_ORDER = "order/sales-order";
13
+ export declare const SALES_ORDER_LINE = "order/sales-order-line";
14
+ export declare const RENTAL_ORDER = "order/rental-order";
15
+ export declare const RENTAL_ORDER_LINE = "order/rental-order-line";
16
+ export declare const SUPPLIER = "contact/supplier";
17
+ export declare const WAREHOUSE = "warehouse";
18
+ export declare const INCOMING_DELIVERY = "delivery/incoming-delivery";
19
+ export declare const INCOMING_DELIVERY_LINE = "delivery/incoming-delivery-line";
20
+ export declare const OUTGOING_DELIVERY = "delivery/outgoing-delivery";
21
+ export declare const OUTGOING_DELIVERY_LINE = "delivery/outgoing-delivery-line";
22
+ export declare const INTERNAL_DELIVERY = "delivery/internal-delivery";
23
+ export declare const INTERNAL_DELIVERY_LINE = "delivery/internal-delivery-line";
24
+ export declare const INVOICE = "invoice";
25
+ export declare const INVOICE_LINE = "invoice/invoice-line";
26
+ export declare const PAYMENT = "accounting/payment";
27
+ export declare const INCOMING_PAYMENT_METHOD = "accounting/incoming-payment-method";
28
+ export declare const FIXED_ASSET = "fixed-asset";
29
+ export declare const STORE = "store";
30
+ export declare const STORE_PRODUCT = "store/store-product";
31
+ export declare const STORE_PRODUCT_GROUP = "store/store-product-group";
32
+ export declare const ACCOUNT = "accounting/account";
33
+ export declare const JOURNAL_ENTRY = "accounting/journal-entry";
34
+ export declare const JOURNAL_ENTRY_LINE = "accounting/journal-entry-line";
35
+ export declare const BILL_OF_MATERIALS = "manufacturing/bill-of-materials";
36
+ export declare const BOM_COMPONENT = "manufacturing/bom-component";
37
+ export declare const PRODUCTION_ORDER = "manufacturing/production-order";
38
+ export declare const PRODUCTION_ORDER_LINE = "manufacturing/production-order-line";
39
+ export declare const SUBSIDIARY = "subsidiary";
40
+ export declare const EMPLOYEE = "human-resources/employee";
41
+ export declare const ATTENDANCE = "human-resources/attendance";
42
+ export declare const INCOMING_SHIPMENT = "shipment/incoming-shipment";
43
+ export declare const OUTGOING_SHIPMENT = "shipment/outgoing-shipment";
44
+ export declare const STOCK_ADJUSTMENT = "stock-adjustment";
45
+ export declare const PURCHASE_ORDER_APPROVER = "approval/approver/purchase-order";
46
+ export declare const SALES_ORDER_APPROVER = "approval/approver/sales-order";
47
+ export declare const CUSTOM_FIELD = "custom-field";
48
+ export declare const AUDIT_LOG = "audit-log";
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AUDIT_LOG = exports.CUSTOM_FIELD = exports.SALES_ORDER_APPROVER = exports.PURCHASE_ORDER_APPROVER = exports.STOCK_ADJUSTMENT = exports.OUTGOING_SHIPMENT = exports.INCOMING_SHIPMENT = exports.ATTENDANCE = exports.EMPLOYEE = exports.SUBSIDIARY = exports.PRODUCTION_ORDER_LINE = exports.PRODUCTION_ORDER = exports.BOM_COMPONENT = exports.BILL_OF_MATERIALS = exports.JOURNAL_ENTRY_LINE = exports.JOURNAL_ENTRY = exports.ACCOUNT = exports.STORE_PRODUCT_GROUP = exports.STORE_PRODUCT = exports.STORE = exports.FIXED_ASSET = exports.INCOMING_PAYMENT_METHOD = exports.PAYMENT = exports.INVOICE_LINE = exports.INVOICE = exports.INTERNAL_DELIVERY_LINE = exports.INTERNAL_DELIVERY = exports.OUTGOING_DELIVERY_LINE = exports.OUTGOING_DELIVERY = exports.INCOMING_DELIVERY_LINE = exports.INCOMING_DELIVERY = exports.WAREHOUSE = exports.SUPPLIER = exports.RENTAL_ORDER_LINE = exports.RENTAL_ORDER = exports.SALES_ORDER_LINE = exports.SALES_ORDER = exports.QUOTE_LINE = exports.QUOTE = exports.PURCHASE_ORDER_LINE = exports.PURCHASE_ORDER = exports.PRODUCT_GROUP = exports.PRODUCT_ITEM = exports.PRODUCT = exports.CUSTOMER = exports.INVITATION = exports.COMPANY_OPTION = exports.COMPANY_PERMISSION = void 0;
4
+ exports.COMPANY_PERMISSION = 'company-permission';
5
+ exports.COMPANY_OPTION = 'company-option';
6
+ exports.INVITATION = 'user/invitation';
7
+ exports.CUSTOMER = 'contact/customer';
8
+ exports.PRODUCT = 'product';
9
+ exports.PRODUCT_ITEM = 'product/product-item';
10
+ exports.PRODUCT_GROUP = 'product-group';
11
+ exports.PURCHASE_ORDER = 'order/purchase-order';
12
+ exports.PURCHASE_ORDER_LINE = 'order/purchase-order-line';
13
+ exports.QUOTE = 'order/quote';
14
+ exports.QUOTE_LINE = 'order/quote-line';
15
+ exports.SALES_ORDER = 'order/sales-order';
16
+ exports.SALES_ORDER_LINE = 'order/sales-order-line';
17
+ exports.RENTAL_ORDER = 'order/rental-order';
18
+ exports.RENTAL_ORDER_LINE = 'order/rental-order-line';
19
+ exports.SUPPLIER = 'contact/supplier';
20
+ exports.WAREHOUSE = 'warehouse';
21
+ // Deliveries
22
+ exports.INCOMING_DELIVERY = 'delivery/incoming-delivery';
23
+ exports.INCOMING_DELIVERY_LINE = 'delivery/incoming-delivery-line';
24
+ exports.OUTGOING_DELIVERY = 'delivery/outgoing-delivery';
25
+ exports.OUTGOING_DELIVERY_LINE = 'delivery/outgoing-delivery-line';
26
+ exports.INTERNAL_DELIVERY = 'delivery/internal-delivery';
27
+ exports.INTERNAL_DELIVERY_LINE = 'delivery/internal-delivery-line';
28
+ // Finance
29
+ exports.INVOICE = 'invoice';
30
+ exports.INVOICE_LINE = 'invoice/invoice-line';
31
+ exports.PAYMENT = 'accounting/payment';
32
+ exports.INCOMING_PAYMENT_METHOD = 'accounting/incoming-payment-method';
33
+ exports.FIXED_ASSET = 'fixed-asset';
34
+ // ECommerce
35
+ exports.STORE = 'store';
36
+ exports.STORE_PRODUCT = 'store/store-product';
37
+ exports.STORE_PRODUCT_GROUP = 'store/store-product-group';
38
+ // Accounting
39
+ exports.ACCOUNT = 'accounting/account';
40
+ exports.JOURNAL_ENTRY = 'accounting/journal-entry';
41
+ exports.JOURNAL_ENTRY_LINE = 'accounting/journal-entry-line';
42
+ // Manufacturing
43
+ exports.BILL_OF_MATERIALS = 'manufacturing/bill-of-materials';
44
+ exports.BOM_COMPONENT = 'manufacturing/bom-component';
45
+ exports.PRODUCTION_ORDER = 'manufacturing/production-order';
46
+ exports.PRODUCTION_ORDER_LINE = 'manufacturing/production-order-line';
47
+ exports.SUBSIDIARY = 'subsidiary';
48
+ // HR
49
+ exports.EMPLOYEE = 'human-resources/employee';
50
+ exports.ATTENDANCE = 'human-resources/attendance';
51
+ // TODO: Deprecate
52
+ exports.INCOMING_SHIPMENT = 'shipment/incoming-shipment';
53
+ exports.OUTGOING_SHIPMENT = 'shipment/outgoing-shipment';
54
+ ///
55
+ exports.STOCK_ADJUSTMENT = 'stock-adjustment';
56
+ exports.PURCHASE_ORDER_APPROVER = 'approval/approver/purchase-order';
57
+ exports.SALES_ORDER_APPROVER = 'approval/approver/sales-order';
58
+ exports.CUSTOM_FIELD = 'custom-field';
59
+ exports.AUDIT_LOG = 'audit-log';
@@ -0,0 +1,15 @@
1
+ declare function getAllObjects(entity: any, queryParams?: any): Promise<any>;
2
+ declare function getObjectById(entity: any, id: string): Promise<any>;
3
+ declare function updateObject(entity: any, id: string, newData: any): Promise<any>;
4
+ declare function createObject(entity: any, data: any): Promise<any>;
5
+ declare function deleteObject(entity: any, id: string): Promise<any>;
6
+ declare const konversiAPI: {
7
+ setToken: (token: string) => void;
8
+ setCompanyId: (companyId: string) => void;
9
+ getAllObjects: typeof getAllObjects;
10
+ getObjectById: typeof getObjectById;
11
+ updateObject: typeof updateObject;
12
+ createObject: typeof createObject;
13
+ deleteObject: typeof deleteObject;
14
+ };
15
+ export default konversiAPI;
package/dist/index.js ADDED
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ const axiosAPI_1 = __importStar(require("./axiosAPI"));
36
+ function getAllObjects(entity_1) {
37
+ return __awaiter(this, arguments, void 0, function* (entity, queryParams = {}) {
38
+ const response = yield axiosAPI_1.default.get(`${entity}`, {
39
+ params: queryParams
40
+ });
41
+ return response.data;
42
+ });
43
+ }
44
+ function getObjectById(entity, id) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ const response = yield axiosAPI_1.default.get(`${entity}/${id}`);
47
+ return response.data;
48
+ });
49
+ }
50
+ function updateObject(entity, id, newData) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ const response = yield axiosAPI_1.default.put(`${entity}/${id}`, newData);
53
+ return response.data;
54
+ });
55
+ }
56
+ function createObject(entity, data) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ const response = yield axiosAPI_1.default.post(`${entity}`, data);
59
+ return response.data;
60
+ });
61
+ }
62
+ function deleteObject(entity, id) {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ const response = yield axiosAPI_1.default.delete(`${entity}/${id}`);
65
+ return response.data;
66
+ });
67
+ }
68
+ const konversiAPI = {
69
+ setToken: axiosAPI_1.setAuthToken,
70
+ setCompanyId: axiosAPI_1.setCompanyId,
71
+ getAllObjects,
72
+ getObjectById,
73
+ updateObject,
74
+ createObject,
75
+ deleteObject
76
+ };
77
+ exports.default = konversiAPI;
package/package.json CHANGED
@@ -1,15 +1,19 @@
1
1
  {
2
2
  "name": "@konversi/konversi-client",
3
- "version": "1.0.5",
4
- "main": "index.js",
3
+ "version": "1.0.7",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
5
6
  "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "build": "tsc",
9
+ "prepublish": "tsc"
7
10
  },
8
11
  "keywords": [],
9
12
  "author": "",
10
13
  "license": "ISC",
11
14
  "dependencies": {
12
- "axios": "^1.6.8"
15
+ "axios": "^1.6.8",
16
+ "typescript": "^5.4.5"
13
17
  },
14
18
  "description": ""
15
19
  }
package/tsconfig.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es5",
4
+ "module": "commonjs",
5
+ "lib": ["es2017", "es7", "es6", "dom"],
6
+ "declaration": true,
7
+ "outDir": "dist",
8
+ "strict": true,
9
+ "esModuleInterop": true
10
+ },
11
+ "exclude": [
12
+ "node_modules",
13
+ "dist"
14
+ ]
15
+ }