@zilfu/sdk 1.0.2 → 1.2.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/package.json CHANGED
@@ -1,9 +1,15 @@
1
1
  {
2
2
  "name": "@zilfu/sdk",
3
- "version": "1.0.2",
3
+ "version": "1.2.0",
4
4
  "description": "Official TypeScript SDK for the Zilfu API",
5
5
  "license": "MIT",
6
+ "files": [
7
+ "dist",
8
+ "README.md",
9
+ "LICENSE"
10
+ ],
6
11
  "type": "module",
12
+ "sideEffects": false,
7
13
  "main": "./dist/index.cjs",
8
14
  "module": "./dist/index.js",
9
15
  "types": "./dist/index.d.ts",
@@ -15,33 +21,25 @@
15
21
  },
16
22
  "./package.json": "./package.json"
17
23
  },
18
- "files": [
19
- "dist",
20
- "README.md",
21
- "LICENSE"
22
- ],
23
- "engines": {
24
- "node": ">=18.17"
25
- },
26
- "sideEffects": false,
27
- "packageManager": "pnpm@10.30.0",
28
24
  "publishConfig": {
29
25
  "access": "public"
30
26
  },
31
27
  "scripts": {
28
+ "pregenerate": "node ../../scripts/api-spec.mjs --ensure",
32
29
  "generate": "openapi-ts",
33
30
  "prebuild": "pnpm generate",
34
31
  "build": "tsup",
35
32
  "typecheck": "tsc --noEmit",
36
- "lint": "oxlint",
37
- "prepublishOnly": "pnpm lint && pnpm typecheck && pnpm build"
33
+ "prepublishOnly": "pnpm -w lint && pnpm typecheck && pnpm build"
38
34
  },
39
- "dependencies": {},
40
35
  "devDependencies": {
41
36
  "@hey-api/openapi-ts": "^0.97.1",
42
37
  "@types/node": "^22.10.0",
43
- "oxlint": "^1.61.0",
44
38
  "tsup": "^8.5.0",
45
39
  "typescript": "^5.9.3"
46
- }
40
+ },
41
+ "engines": {
42
+ "node": ">=18.17"
43
+ },
44
+ "packageManager": "pnpm@10.30.0"
47
45
  }
package/README.md DELETED
@@ -1,143 +0,0 @@
1
- # @zilfu/sdk
2
-
3
- Official TypeScript SDK for the [Zilfu](https://zilfu.app) API.
4
-
5
- ## Install
6
-
7
- ```sh
8
- pnpm add @zilfu/sdk
9
- # or
10
- npm install @zilfu/sdk
11
- ```
12
-
13
- Requires Node 18.17+ (or any runtime with global `fetch`).
14
-
15
- ## Quickstart
16
-
17
- ```ts
18
- import { createZilfuClient } from "@zilfu/sdk";
19
-
20
- const api = createZilfuClient({
21
- baseUrl: "https://zilfu.app/api",
22
- token: process.env.ZILFU_TOKEN!,
23
- });
24
-
25
- const spaces = await api.spaces.list();
26
- ```
27
-
28
- ## Auth
29
-
30
- Mint a personal-access token at **Settings → API tokens** (or via `POST /api/api-tokens`). Pass it as a string or as a function for refresh logic:
31
-
32
- ```ts
33
- const api = createZilfuClient({
34
- token: async () => await getTokenFromVault(),
35
- });
36
- ```
37
-
38
- The `Authorization: Bearer <token>` header is added automatically to every request.
39
-
40
- ## Examples
41
-
42
- ```ts
43
- // List posts in a space
44
- await api.posts.list({ path: { space: 1 } });
45
-
46
- // Create a multi-account post (a "cluster")
47
- await api.posts.create({
48
- path: { space: 1 },
49
- body: {
50
- space_id: 1,
51
- items: [{ account_id: 1, social: "threads", main: { content: "Hello" } }],
52
- },
53
- });
54
-
55
- // Update an entire cluster
56
- await api.clusters.update({
57
- path: { space: 1, cluster_id: "abc-123" },
58
- body: { /* same shape as create */ },
59
- });
60
-
61
- // Reorder a bio link block
62
- await api.bio.blocks.reorder({
63
- path: { space: 1, block: 7 },
64
- body: { sort_order: 2 },
65
- });
66
-
67
- // Upload media (FormData)
68
- const fd = new FormData();
69
- fd.append("file", file);
70
- await api.media.create({ body: fd });
71
- ```
72
-
73
- ## Errors
74
-
75
- Non-2xx responses throw a typed `ZilfuApiError`:
76
-
77
- ```ts
78
- import { ZilfuApiError } from "@zilfu/sdk";
79
-
80
- try {
81
- await api.posts.create({ /* ... */ });
82
- } catch (e) {
83
- if (e instanceof ZilfuApiError) {
84
- console.error(e.status, e.errors); // Laravel validation: { field: ["msg"] }
85
- }
86
- }
87
- ```
88
-
89
- ## Types
90
-
91
- ```ts
92
- import type {
93
- PostResource,
94
- SpaceResource,
95
- AccountResource,
96
- WebhookResource,
97
- } from "@zilfu/sdk";
98
- ```
99
-
100
- All request/response shapes are exported as named types.
101
-
102
- ## Custom fetch
103
-
104
- ```ts
105
- import { fetch as undiciFetch } from "undici";
106
-
107
- const api = createZilfuClient({
108
- token,
109
- fetch: undiciFetch,
110
- });
111
- ```
112
-
113
- ## Regenerating from the API spec
114
-
115
- The package is generated from the live OpenAPI spec at `https://zilfu.app/docs/api.json` (Scramble).
116
-
117
- ```sh
118
- pnpm sync:spec # fetches openapi.json
119
- pnpm generate # regenerates src/generated
120
- pnpm typecheck # verifies the smoke file still compiles
121
- pnpm build
122
- ```
123
-
124
- Override the spec source for staging or local Herd:
125
-
126
- ```sh
127
- SCRAMBLE_SPEC_URL=http://zilfu.test/docs/api.json pnpm sync:spec
128
- ```
129
-
130
- The generated `src/generated/` directory is committed; PRs that bump the spec show a reviewable diff of API surface changes.
131
-
132
- A daily GitHub Actions cron (`.github/workflows/sync-spec.yml`) does this automatically and opens a PR if anything changed — review and merge, then cut a release with:
133
-
134
- ```sh
135
- pnpm version <patch|minor|major>
136
- git push --follow-tags
137
- ```
138
-
139
- The release workflow (`.github/workflows/release.yml`) publishes to npm with provenance and creates a GitHub release on every `v*` tag.
140
-
141
- ## License
142
-
143
- MIT