@helmdesk/sdk 0.2.0 → 0.2.1

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 +231 -35
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # @helmdesk/sdk
2
2
 
3
- Official Node.js SDK for the [Helmdesk](https://helmdesk.dev) API — helpdesk, transactional email, and knowledge base for developers.
3
+ [![npm version](https://img.shields.io/npm/v/@helmdesk/sdk.svg)](https://www.npmjs.com/package/@helmdesk/sdk)
4
+ [![license](https://img.shields.io/npm/l/@helmdesk/sdk.svg)](https://github.com/MoloksInc/helmdesk/blob/main/LICENSE)
5
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-blue.svg)](https://www.typescriptlang.org/)
6
+
7
+ The official Node.js/TypeScript SDK for [Helmdesk](https://helmdesk.dev) -- a unified helpdesk, transactional email gateway, and knowledge base built for developers.
4
8
 
5
9
  ## Install
6
10
 
@@ -8,56 +12,248 @@ Official Node.js SDK for the [Helmdesk](https://helmdesk.dev) API — helpdesk,
8
12
  npm install @helmdesk/sdk
9
13
  ```
10
14
 
11
- ## Quick start
15
+ ## Quick Start
12
16
 
13
17
  ```ts
14
- import { HelmdeskClient } from '@helmdesk/sdk'
18
+ import { HelmdeskClient } from "@helmdesk/sdk";
19
+
20
+ const helmdesk = new HelmdeskClient({ apiKey: process.env.HELMDESK_API_KEY! });
21
+
22
+ const ticket = await helmdesk.tickets.create({
23
+ subject: "Cannot login",
24
+ body: "Getting a 403 error on the dashboard.",
25
+ customerEmail: "jane@example.com",
26
+ });
27
+ ```
28
+
29
+ ## API Reference
15
30
 
16
- const helmdesk = new HelmdeskClient({
17
- apiKey: process.env.HELMDESK_API_KEY!,
18
- })
31
+ ### Tickets
32
+
33
+ Manage support tickets -- create, list, update, and reply.
34
+
35
+ **List tickets**
36
+
37
+ ```ts
38
+ const { tickets, total } = await helmdesk.tickets.list({
39
+ status: "open",
40
+ priority: "high",
41
+ search: "login",
42
+ page: 1,
43
+ limit: 25,
44
+ });
45
+ ```
19
46
 
20
- // Send a transactional email (defaults to 'production' environment)
21
- await helmdesk.emails.send({
22
- templateKey: 'welcome',
23
- to: { email: 'user@example.com', name: 'Jane' },
24
- variables: { activationUrl: 'https://...' },
25
- environment: 'production', // optional: 'production' | 'staging' | 'development'
26
- })
47
+ **Get a ticket**
27
48
 
28
- // Create a support ticket
49
+ ```ts
50
+ const ticket = await helmdesk.tickets.get("ticket_id");
51
+ // Returns full detail: messages, tags, customer info
52
+ ```
53
+
54
+ **Create a ticket**
55
+
56
+ ```ts
29
57
  const ticket = await helmdesk.tickets.create({
30
- subject: 'Cannot login',
31
- body: 'Getting a 403 error...',
32
- customerEmail: 'user@example.com',
33
- })
58
+ subject: "Billing question",
59
+ body: "I was charged twice for my last invoice.",
60
+ customerEmail: "user@example.com",
61
+ customerName: "Jane Doe",
62
+ priority: "high",
63
+ category: "billing",
64
+ });
65
+ ```
66
+
67
+ **Update a ticket**
68
+
69
+ ```ts
70
+ const updated = await helmdesk.tickets.update("ticket_id", {
71
+ status: "resolved",
72
+ priority: "low",
73
+ category: "howto",
74
+ });
75
+ ```
76
+
77
+ **Add a message to a ticket**
78
+
79
+ ```ts
80
+ const message = await helmdesk.tickets.addMessage("ticket_id", {
81
+ body: "We've fixed the issue. Please try again.",
82
+ });
83
+ ```
84
+
85
+ ### Emails
86
+
87
+ Send transactional emails using Handlebars templates managed in your Helmdesk dashboard.
88
+
89
+ **Send an email**
90
+
91
+ ```ts
92
+ const result = await helmdesk.emails.send({
93
+ templateKey: "welcome",
94
+ to: { email: "jane@example.com", name: "Jane" },
95
+ variables: { activationUrl: "https://app.example.com/activate?token=abc" },
96
+ environment: "production",
97
+ });
98
+ ```
99
+
100
+ **Preview an email**
101
+
102
+ ```ts
103
+ const { subject, html } = await helmdesk.emails.preview({
104
+ templateKey: "welcome",
105
+ variables: { activationUrl: "https://example.com" },
106
+ });
107
+ ```
108
+
109
+ **Get a template's variable schema**
110
+
111
+ ```ts
112
+ const schema = await helmdesk.emails.getTemplateSchema("welcome");
113
+ // schema.variables: [{ name: 'activationUrl', type: 'string', required: true }]
114
+ ```
115
+
116
+ ### Articles
117
+
118
+ Search your published knowledge base articles.
34
119
 
35
- // Search knowledge base articles
36
- const results = await helmdesk.articles.search({ q: 'reset password' })
120
+ ```ts
121
+ const { articles, total } = await helmdesk.articles.search({
122
+ q: "reset password",
123
+ category: "account",
124
+ page: 1,
125
+ limit: 10,
126
+ });
127
+ ```
128
+
129
+ ### Customers
37
130
 
38
- // Import a Handlebars template
131
+ Track and manage customer profiles across tickets and emails.
132
+
133
+ **List customers**
134
+
135
+ ```ts
136
+ const { customers, total } = await helmdesk.customers.list({
137
+ search: "jane",
138
+ plan: "pro",
139
+ page: 1,
140
+ limit: 25,
141
+ });
142
+ ```
143
+
144
+ **Get a customer**
145
+
146
+ ```ts
147
+ const customer = await helmdesk.customers.get("customer_id");
148
+ // Includes recentTickets array
149
+ ```
150
+
151
+ **Upsert a customer**
152
+
153
+ ```ts
154
+ const customer = await helmdesk.customers.upsert({
155
+ email: "jane@example.com",
156
+ name: "Jane Doe",
157
+ plan: "pro",
158
+ metadata: JSON.stringify({ companyId: "acme-123" }),
159
+ });
160
+ ```
161
+
162
+ ## Error Handling
163
+
164
+ All API errors throw a `HelmdeskError` with structured fields for programmatic handling.
165
+
166
+ ```ts
167
+ import { HelmdeskClient, HelmdeskError } from "@helmdesk/sdk";
168
+
169
+ try {
170
+ await helmdesk.tickets.get("nonexistent_id");
171
+ } catch (err) {
172
+ if (err instanceof HelmdeskError) {
173
+ console.error(err.status); // 404
174
+ console.error(err.code); // 'not_found'
175
+ console.error(err.message); // 'Ticket not found'
176
+ }
177
+ }
178
+ ```
179
+
180
+ ## Idempotency
181
+
182
+ The `emails.send()` method accepts an optional `idempotencyKey` to safely retry email sends without duplicates. If a request with the same key has already been processed, the API returns the original result.
183
+
184
+ ```ts
185
+ await helmdesk.emails.send(
186
+ {
187
+ templateKey: "order-confirmation",
188
+ to: { email: "buyer@example.com" },
189
+ variables: { orderId: "ORD-4821" },
190
+ },
191
+ { idempotencyKey: "order-4821-confirmation" }
192
+ );
193
+ ```
194
+
195
+ ## Template Import
196
+
197
+ Import Handlebars `.hbs` files as templates, layouts, or partials directly from your codebase or CI pipeline.
198
+
199
+ **Project-scoped template**
200
+
201
+ ```ts
39
202
  await helmdesk.emails.templates.import(
40
- '<h1>Hello {{name}}</h1>',
41
- 'welcome.hbs',
42
- { type: 'template' }
43
- )
203
+ '<h1>Welcome, {{name}}</h1><p>Thanks for signing up.</p>',
204
+ "welcome.hbs",
205
+ {
206
+ type: "template",
207
+ subject: "Welcome to {{brandName}}!",
208
+ }
209
+ );
44
210
  ```
45
211
 
46
- ## Resources
212
+ **Account-scoped partial (shared across all projects)**
213
+
214
+ ```ts
215
+ await helmdesk.emails.templates.import(
216
+ '<footer>{{companyName}} | {{unsubscribeLink}}</footer>',
217
+ "footer.hbs",
218
+ {
219
+ type: "partial",
220
+ scope: "account",
221
+ }
222
+ );
223
+ ```
224
+
225
+ Import options:
226
+
227
+ | Option | Type | Description |
228
+ |---|---|---|
229
+ | `type` | `'template' \| 'layout' \| 'partial'` | File type. Defaults to `'template'`. |
230
+ | `scope` | `'project' \| 'account'` | Project-scoped or shared across all projects. Defaults to `'project'`. |
231
+ | `key` | `string` | Override the template key. Defaults to the filename without `.hbs`. |
232
+ | `name` | `string` | Override the display name. |
233
+ | `subject` | `string` | Subject line. Can also be set via a `{{!-- subject: ... --}}` comment in the template. |
234
+
235
+ ## Runtime Support
236
+
237
+ The SDK uses the native `fetch` API with no Node.js-specific dependencies.
238
+
239
+ - Node.js 18+
240
+ - Deno
241
+ - Bun
242
+ - Cloudflare Workers
243
+
244
+ ## Why Helmdesk?
47
245
 
48
- - `helmdesk.tickets` create, list, get, update, addMessage
49
- - `helmdesk.emails` — send, preview, getTemplateSchema
50
- - `helmdesk.emails.templates` — import (project or account scope)
51
- - `helmdesk.articles` — search
246
+ Most helpdesk tools are built for sales teams, not developers. They charge per seat, lock AI behind usage fees, and offer no API-first workflow.
52
247
 
53
- ## Requirements
248
+ Intercom starts at $29/seat with an additional $0.99 per AI resolution. HelpScout charges $25/user plus $0.75 per AI interaction. Crisp costs $95/workspace for their business tier.
54
249
 
55
- - Node.js 18+ (uses native `fetch`)
56
- - Works in Deno, Bun, and Cloudflare Workers
250
+ Helmdesk is $19/month for up to 5 projects. AI features are included at every tier -- no per-resolution fees, no per-seat pricing. You get a helpdesk, transactional email gateway, and knowledge base in one platform with a full API and this SDK from day one.
57
251
 
58
- ## Documentation
252
+ ## Links
59
253
 
60
- Full API docs at [helmdesk.dev/docs](https://helmdesk.dev/docs)
254
+ - [Homepage](https://helmdesk.dev)
255
+ - [Documentation](https://helmdesk.dev/docs)
256
+ - [Pricing](https://helmdesk.dev/pricing)
61
257
 
62
258
  ## License
63
259
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helmdesk/sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Official Node.js SDK for the Helmdesk API",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",