@chneau/hyperaccounts 0.0.3 → 0.0.5

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