@glance-il/sdk 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Glance
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,179 @@
1
+ # @glance/sdk
2
+
3
+ Official TypeScript SDK for the [Glance](https://www.glance.co.il) API — a fully-typed, ergonomic client for invoicing, inventory, and business management.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @glance/sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { GlanceClient } from "@glance/sdk";
15
+
16
+ const glance = new GlanceClient({
17
+ apiKey: process.env.GLANCE_API_KEY!,
18
+ });
19
+ ```
20
+
21
+ ## Usage Examples
22
+
23
+ ### List Clients
24
+
25
+ ```typescript
26
+ const { data: clients, pagination } = await glance.clients.list({
27
+ search: "acme",
28
+ limit: 20,
29
+ });
30
+
31
+ console.log(`Found ${pagination.total} clients`);
32
+ clients.forEach((c) => console.log(c.name));
33
+ ```
34
+
35
+ ### Create an Invoice
36
+
37
+ ```typescript
38
+ const { data: invoice } = await glance.documents.create("invoice", {
39
+ clientId: "C-001",
40
+ products: [
41
+ {
42
+ description: "Web Development Services",
43
+ units: 40,
44
+ price: 150,
45
+ typeOfUnit: "hours",
46
+ },
47
+ ],
48
+ payments: [
49
+ {
50
+ amount: 6000,
51
+ paymentMethod: "bankTransfer",
52
+ },
53
+ ],
54
+ sendToClient: true,
55
+ });
56
+
57
+ console.log(`Invoice ${invoice.visibleId} created — total: ${invoice.totalWithTax}`);
58
+ ```
59
+
60
+ ### Manage Inventory
61
+
62
+ ```typescript
63
+ // Adjust inventory for a product
64
+ await glance.inventory.adjust("INV-001", {
65
+ quantity: 50,
66
+ warehouseId: "WH-001",
67
+ notes: "Initial stock",
68
+ });
69
+
70
+ // List inventory movements
71
+ const { data: movements } = await glance.inventoryMovements.list({
72
+ warehouseId: "WH-001",
73
+ limit: 50,
74
+ });
75
+ ```
76
+
77
+ ### Generate Reports
78
+
79
+ ```typescript
80
+ const { data: report } = await glance.reports.income({
81
+ dateFrom: "2026-01-01",
82
+ dateTo: "2026-03-31",
83
+ });
84
+
85
+ console.log(`Revenue: ${report.total}`);
86
+ ```
87
+
88
+ ## Error Handling
89
+
90
+ All API errors are typed and can be caught by class:
91
+
92
+ ```typescript
93
+ import {
94
+ GlanceClient,
95
+ GlanceApiError,
96
+ GlanceAuthenticationError,
97
+ GlanceNotFoundError,
98
+ GlanceValidationError,
99
+ GlanceRateLimitError,
100
+ } from "@glance/sdk";
101
+
102
+ try {
103
+ const { data } = await glance.clients.get("non-existent");
104
+ } catch (error) {
105
+ if (error instanceof GlanceNotFoundError) {
106
+ console.error("Client not found");
107
+ } else if (error instanceof GlanceValidationError) {
108
+ console.error("Validation failed:", error.message);
109
+ } else if (error instanceof GlanceAuthenticationError) {
110
+ console.error("Invalid API key");
111
+ } else if (error instanceof GlanceRateLimitError) {
112
+ console.error("Rate limit hit — retry after", error.retryAfter, "ms");
113
+ } else if (error instanceof GlanceApiError) {
114
+ console.error(`API Error ${error.status}: ${error.message} (${error.code})`);
115
+ }
116
+ }
117
+ ```
118
+
119
+ ## TypeScript Support
120
+
121
+ The SDK is written in TypeScript and ships with full `.d.ts` declarations. All request and response types are exported:
122
+
123
+ ```typescript
124
+ import type {
125
+ Client,
126
+ CreateClientParams,
127
+ GlanceDocument,
128
+ CreateDocumentParams,
129
+ Product,
130
+ PaginationMeta,
131
+ } from "@glance/sdk";
132
+
133
+ function processClient(client: Client): void {
134
+ console.log(`${client.name} — ${client.email}`);
135
+ }
136
+ ```
137
+
138
+ ## Available Resources
139
+
140
+ | Resource | Property | Description |
141
+ |---|---|---|
142
+ | Clients | `glance.clients` | Business clients / customers |
143
+ | Contacts | `glance.contacts` | Contacts associated with clients |
144
+ | Addresses | `glance.addresses` | Addresses for clients |
145
+ | Products | `glance.products` | Products and services catalog |
146
+ | Product Serials | `glance.productSerials` | Serial numbers for physical products |
147
+ | Warehouses | `glance.warehouses` | Warehouse locations |
148
+ | Inventory | `glance.inventory` | Stock levels per product/warehouse |
149
+ | Inventory Movements | `glance.inventoryMovements` | Stock movement history |
150
+ | Documents | `glance.documents` | Invoices, receipts, quotes, and more |
151
+ | Vendors | `glance.vendors` | Suppliers and vendors |
152
+ | Purchase | `glance.purchase` | Purchase orders and vendor invoices |
153
+ | Expenses | `glance.expenses` | Business expenses |
154
+ | Retainers | `glance.retainers` | Recurring retainer agreements |
155
+ | Reports | `glance.reports` | Income, expenses, VAT reports |
156
+ | Employees | `glance.employees` | Employee management |
157
+ | Files | `glance.files` | File attachments |
158
+ | Custom Fields | `glance.customFields` | Custom metadata fields |
159
+ | Payments | `glance.payments` | Payment processing and transactions |
160
+ | Settings | `glance.settings` | Account settings |
161
+
162
+ ## Configuration
163
+
164
+ ```typescript
165
+ const glance = new GlanceClient({
166
+ apiKey: "your-api-key", // required
167
+ baseUrl: "https://api.glance.co.il", // optional, defaults to production
168
+ timeout: 30_000, // optional, milliseconds (default: 30s)
169
+ });
170
+ ```
171
+
172
+ ## Requirements
173
+
174
+ - Node.js >= 18 (uses native `fetch`)
175
+ - TypeScript >= 5.0 (optional, works with plain JS too)
176
+
177
+ ## License
178
+
179
+ MIT