@loculabs/api-client 1.0.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/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # 1.0.0 (2025-12-31)
2
+
3
+
4
+ ### Features
5
+
6
+ * initial release of @locu/api-client ([a339860](https://github.com/loculabs/api-client/commit/a3398608245e493b8cadf92580653a532e075572))
7
+
8
+ # Changelog
9
+
10
+ All notable changes to this project will be documented in this file.
11
+
12
+ This changelog is automatically generated by [semantic-release](https://github.com/semantic-release/semantic-release).
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Locu Labs
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,99 @@
1
+ # @loculabs/api-client
2
+
3
+ TypeScript client for the Locu REST API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @loculabs/api-client
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { createLocuClient } from '@loculabs/api-client'
15
+
16
+ const locu = createLocuClient({
17
+ token: 'your-api-token',
18
+ })
19
+
20
+ // Tasks
21
+ const { data: tasks } = await locu.tasks.list()
22
+ const task = await locu.tasks.create({ name: 'My task', section: 'today' })
23
+ await locu.tasks.update(task.id, { done: 'completed' })
24
+
25
+ // Projects
26
+ const { data: projects } = await locu.projects.list()
27
+
28
+ // Notes
29
+ const { data: notes } = await locu.notes.list()
30
+
31
+ // Sessions
32
+ const { data: sessions } = await locu.sessions.list()
33
+
34
+ // Timer
35
+ const timer = await locu.timer.get()
36
+ await locu.timer.start({ taskId: 'task-id' })
37
+ await locu.timer.stop()
38
+
39
+ // Webhooks
40
+ const webhook = await locu.webhooks.create({ url: 'https://example.com/webhook' })
41
+ console.log('Secret:', webhook.secret) // Save this!
42
+ ```
43
+
44
+ ## Webhook Signature Verification
45
+
46
+ ```typescript
47
+ import { verifyWebhookSignature, parseWebhookPayload } from '@loculabs/api-client'
48
+
49
+ app.post('/webhook', (req, res) => {
50
+ const result = verifyWebhookSignature(
51
+ process.env.WEBHOOK_SECRET,
52
+ req.headers['x-webhook-signature'],
53
+ req.body,
54
+ { maxAge: 300 }
55
+ )
56
+
57
+ if (!result.valid) {
58
+ return res.status(401).json({ error: result.error })
59
+ }
60
+
61
+ const payload = parseWebhookPayload(req.body)
62
+ console.log('Event:', payload.event, 'Data:', payload.data)
63
+ res.sendStatus(200)
64
+ })
65
+ ```
66
+
67
+ ## Development
68
+
69
+ ### Generating the Client
70
+
71
+ The client code is generated from a declarative configuration that validates against the OpenAPI spec. This ensures you never forget to add new endpoints.
72
+
73
+ ```bash
74
+ # Generate types from OpenAPI spec + generate client code
75
+ npm run generate
76
+
77
+ # Or for local development (uses localhost API)
78
+ npm run generate:dev
79
+ ```
80
+
81
+ If the API has new endpoints that aren't covered by the client, the generator will **fail with an error** listing the missing paths:
82
+
83
+ ```
84
+ ❌ ERROR: The following API paths are NOT covered by the client:
85
+ - /users
86
+ - /users/{id}
87
+
88
+ Add them to RESOURCES in scripts/generate-client.ts
89
+ ```
90
+
91
+ ### Adding New Endpoints
92
+
93
+ 1. Add the new resource to `RESOURCES` in [scripts/generate-client.ts](scripts/generate-client.ts)
94
+ 2. Run `npm run generate`
95
+ 3. The client will be regenerated with the new endpoints
96
+
97
+ ## License
98
+
99
+ MIT