basecamp-client 1.0.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.
- package/README.md +102 -0
- package/dist/index.d.mts +31267 -0
- package/dist/index.d.ts +31267 -0
- package/dist/index.js +3209 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3180 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# basecamp-client
|
|
2
|
+
|
|
3
|
+
Basecamp API client and contract built with `ts-rest`. The package exposes a fully typed contract, a ready-to-use client builder, and OAuth helpers so teams can share a single source of truth across services, CLIs, and tests.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install basecamp-client
|
|
9
|
+
# or
|
|
10
|
+
yarn add basecamp-client
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Create a client
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { buildClient } from 'basecamp-client';
|
|
19
|
+
|
|
20
|
+
const client = buildClient({
|
|
21
|
+
bearerToken: process.env.BASECAMP_ACCESS_TOKEN!,
|
|
22
|
+
accountId: process.env.BASECAMP_ACCOUNT_ID!,
|
|
23
|
+
userAgent: process.env.BASECAMP_USER_AGENT!,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const projects = await client.projects.list({ query: {} });
|
|
27
|
+
console.log(projects.body);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Refresh OAuth tokens
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { getBearerToken } from 'basecamp-client';
|
|
34
|
+
|
|
35
|
+
const bearerToken = await getBearerToken({
|
|
36
|
+
clientId: process.env.BASECAMP_CLIENT_ID!,
|
|
37
|
+
clientSecret: process.env.BASECAMP_CLIENT_SECRET!,
|
|
38
|
+
refreshToken: process.env.BASECAMP_REFRESH_TOKEN!,
|
|
39
|
+
userAgent: process.env.BASECAMP_USER_AGENT!,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const client = buildClient({
|
|
43
|
+
bearerToken: bearerToken,
|
|
44
|
+
accountId: process.env.BASECAMP_ACCOUNT_ID!,
|
|
45
|
+
userAgent: process.env.BASECAMP_USER_AGENT!,
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Contract access
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { contract } from 'basecamp-client';
|
|
53
|
+
import { initClient } from '@ts-rest/core';
|
|
54
|
+
|
|
55
|
+
const client = initClient(contract, { /* custom fetcher config */ });
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Development
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm install
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Scripts
|
|
65
|
+
|
|
66
|
+
- `npm run build` – bundle the package with tsup (CJS + ESM + types).
|
|
67
|
+
- `npm run contract:check` – type-check the contract with `tsc --noEmit`.
|
|
68
|
+
- `npm test` – execute the Vitest live smoke suite *(requires Basecamp credentials and hits the real API)*.
|
|
69
|
+
- `npm run format` / `npm run lint` / `npm run check` – Biome formatting and linting utilities.
|
|
70
|
+
|
|
71
|
+
### Environment variables
|
|
72
|
+
|
|
73
|
+
Live tests and manual scripts expect the following variables (see `tests/utils.ts`):
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
BASECAMP_CLIENT_ID
|
|
77
|
+
BASECAMP_CLIENT_SECRET
|
|
78
|
+
BASECAMP_REFRESH_TOKEN
|
|
79
|
+
BASECAMP_USER_AGENT
|
|
80
|
+
BASECAMP_ACCOUNT_ID
|
|
81
|
+
BASECAMP_BUCKET_ID
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Populate them via `.env` (ignored from git) or your shell environment before running tests.
|
|
85
|
+
|
|
86
|
+
### Running live tests
|
|
87
|
+
|
|
88
|
+
The Vitest suite provisions, updates, and trashes real Basecamp resources in a dedicated sandbox project. To execute the tests:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npm test
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
> These tests are not mocked. Ensure your credentials target an account that is safe for automated writes.
|
|
95
|
+
|
|
96
|
+
## Publishing
|
|
97
|
+
|
|
98
|
+
`prepublishOnly` runs `npm run build`, producing artifacts in `dist/` via tsup. After verifying the bundle and contract typings, publish as usual:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npm publish
|
|
102
|
+
```
|