@chneau/hyperaccounts 0.0.3 → 0.0.4

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.
Files changed (2) hide show
  1. package/README.md +93 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,93 @@
1
+ # @chneau/hyperaccounts
2
+
3
+ A TypeScript client for the HyperAccounts REST API for Sage 50cloud, featuring type-safe requests and responses using Zod.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @chneau/hyperaccounts
9
+ # or
10
+ bun add @chneau/hyperaccounts
11
+ # or
12
+ yarn add @chneau/hyperaccounts
13
+ # or
14
+ pnpm add @chneau/hyperaccounts
15
+ ```
16
+
17
+ ## Getting Started
18
+
19
+ Initialize the client with your HyperAccounts base URL and authentication token.
20
+
21
+ ```typescript
22
+ import { HyperAccountsClient } from "@chneau/hyperaccounts";
23
+
24
+ const client = new HyperAccountsClient({
25
+ baseURL: "https://your-hyperaccounts-api-url.com",
26
+ authToken: "YOUR_AUTH_TOKEN",
27
+ });
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ All API methods return a Promise that resolves to a typed response validated by Zod schemas.
33
+
34
+ ### Check API Status
35
+
36
+ ```typescript
37
+ const status = await client.readApiStatus();
38
+ console.log(status);
39
+ ```
40
+
41
+ ### Search for a Customer
42
+
43
+ ```typescript
44
+ const customers = await client.searchCustomer([
45
+ {
46
+ field: "name",
47
+ type: "like",
48
+ value: "Acme%",
49
+ },
50
+ ]);
51
+
52
+ if (customers.success && customers.results) {
53
+ customers.results.forEach((customer) => {
54
+ console.log(`Found customer: ${customer.name} (${customer.accountRef})`);
55
+ });
56
+ }
57
+ ```
58
+
59
+ ### Read a Specific Customer
60
+
61
+ ```typescript
62
+ const customer = await client.readCustomer({ customer: "ACME001" });
63
+ console.log(customer.response);
64
+ ```
65
+
66
+ ### Create a Sales Order
67
+
68
+ ```typescript
69
+ const newOrder = await client.createSalesOrder({
70
+ customerAccountRef: "ACME001",
71
+ orderDate: "2023-10-27",
72
+ invoiceItems: [
73
+ {
74
+ stockCode: "WIDGET-01",
75
+ quantity: 10,
76
+ unitPrice: 15.50,
77
+ description: "Premium Widget",
78
+ taxCode: 1,
79
+ },
80
+ ],
81
+ });
82
+
83
+ if (newOrder.success) {
84
+ console.log(`Order created successfully: ${newOrder.response}`);
85
+ }
86
+ ```
87
+
88
+ ## Features
89
+
90
+ - **Type-Safe**: Full TypeScript definitions for inputs and outputs.
91
+ - **Runtime Validation**: Uses [Zod](https://zod.dev) to validate API responses, ensuring your application handles data correctly.
92
+ - **Promise-Based**: Modern async/await API.
93
+ - **Comprehensive Coverage**: Supports a wide range of HyperAccounts endpoints including Company Settings, Customers, Suppliers, Products, Stock, Sales Orders, Purchase Orders, and more.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chneau/hyperaccounts",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "dependencies": {