@edium/halifax 2.2.0 → 2.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.
- package/README.md +17 -46
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -65,69 +65,40 @@ Halifax ships as two packages from the same repository:
|
|
|
65
65
|
| [`@edium/halifax`](https://www.npmjs.com/package/@edium/halifax) | Server — auto-CRUD engine, adapters, auth, caching, OpenAPI |
|
|
66
66
|
| [`@edium/halifax-client`](https://www.npmjs.com/package/@edium/halifax-client) | Browser/Node client — typed CRUD, query builder, TanStack Query integration |
|
|
67
67
|
|
|
68
|
-
## Browser Client
|
|
68
|
+
## Browser Client
|
|
69
69
|
|
|
70
70
|
[`@edium/halifax-client`](https://www.npmjs.com/package/@edium/halifax-client) is the companion
|
|
71
71
|
frontend package. It ships a fully-typed resource client, a fluent query builder, and **built-in
|
|
72
72
|
TanStack Query option factories** so list/detail queries and mutations wire up in a few lines —
|
|
73
|
-
with automatic cache invalidation on writes.
|
|
73
|
+
with automatic cache invalidation on writes. Five HTTP transports ship out of the box: `fetch`
|
|
74
|
+
(default), `axios`, `ky`, `ofetch`, and `superagent` — swap with one line.
|
|
74
75
|
|
|
75
76
|
```bash
|
|
76
77
|
pnpm add @edium/halifax-client
|
|
77
|
-
|
|
78
|
-
# add whichever TanStack Query adapter your framework uses
|
|
79
78
|
pnpm add @tanstack/react-query # React
|
|
80
79
|
pnpm add @tanstack/vue-query # Vue
|
|
81
80
|
```
|
|
82
81
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
```tsx
|
|
86
|
-
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
|
87
|
-
import { HalifaxClient } from '@edium/halifax-client'
|
|
82
|
+
```ts
|
|
83
|
+
import { HalifaxClient, QueryBuilder, SqlComparison } from '@edium/halifax-client'
|
|
88
84
|
|
|
89
85
|
const client = new HalifaxClient({ baseUrl: '/api/v1' })
|
|
90
|
-
const posts = client.resource<Post,
|
|
91
|
-
|
|
92
|
-
// Paginated list — queryKey is managed for you
|
|
93
|
-
function usePostList(page: number) {
|
|
94
|
-
return useQuery(posts.getManyOptions({ limit: 20, offset: page * 20 }))
|
|
95
|
-
}
|
|
86
|
+
const posts = client.resource<Post, Omit<Post, 'id'>, Partial<Omit<Post, 'id'>>>('posts')
|
|
96
87
|
|
|
97
|
-
//
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
...posts.createOneMutation(),
|
|
102
|
-
onSuccess: () => qc.invalidateQueries({ queryKey: posts.queryKey() })
|
|
103
|
-
})
|
|
104
|
-
}
|
|
105
|
-
```
|
|
88
|
+
// CRUD
|
|
89
|
+
const { results, count } = await posts.getMany({ limit: 20 })
|
|
90
|
+
const post = await posts.getOne(1)
|
|
91
|
+
await posts.createOne({ title: 'Hello', published: false })
|
|
106
92
|
|
|
107
|
-
|
|
93
|
+
// Query builder — sends to POST /posts/query
|
|
94
|
+
const q = new QueryBuilder().where('published', SqlComparison.Equal, true).limit(10)
|
|
95
|
+
const { results: published } = await posts.query(q)
|
|
108
96
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
import { useQuery, useMutation, useQueryClient } from '@tanstack/vue-query'
|
|
112
|
-
import { HalifaxClient } from '@edium/halifax-client'
|
|
113
|
-
|
|
114
|
-
const client = new HalifaxClient({ baseUrl: '/api/v1' })
|
|
115
|
-
const posts = client.resource<Post, NewPost, PatchPost>('posts')
|
|
116
|
-
|
|
117
|
-
// Reactive query — re-fetches automatically when page changes
|
|
118
|
-
const page = ref(0)
|
|
119
|
-
const postList = useQuery(computed(() => posts.getManyOptions({ limit: 20, offset: page.value * 20 })))
|
|
120
|
-
|
|
121
|
-
// Mutation with cache invalidation
|
|
122
|
-
const qc = useQueryClient()
|
|
123
|
-
const createPost = useMutation({
|
|
124
|
-
...posts.createOneMutation(),
|
|
125
|
-
onSuccess: () => qc.invalidateQueries({ queryKey: posts.queryKey() })
|
|
126
|
-
})
|
|
97
|
+
// React — queryKey + queryFn wired automatically
|
|
98
|
+
const { data } = useQuery(posts.getManyOptions({ limit: 20 }))
|
|
127
99
|
```
|
|
128
100
|
|
|
129
|
-
|
|
130
|
-
`superagent` — swap with one line. Full docs: [README_CLIENT.md](./README_CLIENT.md).
|
|
101
|
+
Full docs: [README_CLIENT.md](./README_CLIENT.md) · [npm](https://www.npmjs.com/package/@edium/halifax-client)
|
|
131
102
|
|
|
132
103
|
---
|
|
133
104
|
|
|
@@ -188,7 +159,7 @@ app.listen(3000)
|
|
|
188
159
|
|
|
189
160
|
| Guide | Contents |
|
|
190
161
|
| ---------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
191
|
-
| [README_CLIENT.md](./README_CLIENT.md)
|
|
162
|
+
| [README_CLIENT.md](./README_CLIENT.md) · [npm](https://www.npmjs.com/package/@edium/halifax-client) | `@edium/halifax-client` — install, transports, query builder, React & Vue TanStack Query examples |
|
|
192
163
|
| [README_AUTOCRUD.md](./README_AUTOCRUD.md) | Resource definitions, field flags, ID types, pagination, query-string filtering, error shapes |
|
|
193
164
|
| [README_REPO_ADAPTERS.md](./README_REPO_ADAPTERS.md) | Prisma 7 (and 6) setup, `PrismaAdapter`, `DrizzleAdapter`, capabilities, custom repositories |
|
|
194
165
|
| [README_HTTP_ADAPTERS.md](./README_HTTP_ADAPTERS.md) | Express, Fastify, HyperExpress & Ultimate Express adapters, and custom HTTP adapters |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edium/halifax",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Auto-generate type-safe REST CRUD APIs from your data models. Adapter-driven: Express/Fastify/HyperExpress, Prisma (PostgreSQL, MySQL, MariaDB, SQL Server, CockroachDB, SQLite), JWT/API-key auth, multi-tenancy, a dynamic query builder, and pluggable Redis caching.",
|
|
5
5
|
"author": "David LaTour <david@edium.com>",
|
|
6
6
|
"homepage": "https://github.com/splayfee/halifax#readme",
|
|
@@ -166,7 +166,7 @@
|
|
|
166
166
|
],
|
|
167
167
|
"dependencies": {
|
|
168
168
|
"uuid": "^14.0.0",
|
|
169
|
-
"@edium/halifax-types": "
|
|
169
|
+
"@edium/halifax-types": "2.2.1"
|
|
170
170
|
},
|
|
171
171
|
"scripts": {
|
|
172
172
|
"preinstall": "node -e \"const ua = process.env.npm_config_user_agent; if (ua && !ua.startsWith('pnpm')) { console.error('\\nERROR: This repo requires pnpm. Run: pnpm install\\n'); process.exit(1); }\"",
|