@mestra-dev/contract 0.0.13 → 0.0.14

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 CHANGED
@@ -27,9 +27,18 @@ import { hc } from 'hono/client'
27
27
  const client = hc<AppType>('https://api.mestra.chat/')
28
28
 
29
29
  const res = await client.auth.me.$get()
30
- const data = await res.json()
30
+
31
+ if (res.ok) {
32
+ const data = await res.json()
33
+ } else if (res.status === 403) {
34
+ const err = await res.json() // { success: false, error: string }
35
+ } else if (res.status === 404) {
36
+ const err = await res.json()
37
+ }
31
38
  ```
32
39
 
40
+ `AppType` includes per-route error bodies (400/403/404/…) plus global middleware errors (JWT, workspace access, rate limit → 400/401/403/404/429/500).
41
+
33
42
  Always use `import type` so the bundler never pulls server code.
34
43
 
35
44
  ## Build (maintainers)
package/dist/index.d.ts CHANGED
@@ -1,6 +1,12 @@
1
- import { JwtVariables } from 'hono/jwt';
1
+ import type { ApplyGlobalResponse } from 'hono/client';
2
+ import type { JwtVariables } from 'hono/jwt';
2
3
 
3
4
  type Variables = JwtVariables;
5
+ /** Shared error body for middleware / HTTPException responses (typed into AppType). */
6
+ export type ApiError = {
7
+ success: false;
8
+ error: string;
9
+ };
4
10
  declare const routes: import("hono/hono-base").HonoBase<{
5
11
  Variables: Variables;
6
12
  }, ({
@@ -16156,4 +16162,25 @@ declare const routes: import("hono/hono-base").HonoBase<{
16156
16162
  };
16157
16163
  };
16158
16164
  }, "/notifications">, "/", "/">;
16159
- export type AppType = typeof routes;
16165
+ type GlobalErrorResponses = {
16166
+ 400: {
16167
+ json: ApiError;
16168
+ };
16169
+ 401: {
16170
+ json: ApiError;
16171
+ };
16172
+ 403: {
16173
+ json: ApiError;
16174
+ };
16175
+ 404: {
16176
+ json: ApiError;
16177
+ };
16178
+ 429: {
16179
+ json: ApiError;
16180
+ };
16181
+ 500: {
16182
+ json: ApiError;
16183
+ };
16184
+ };
16185
+ /** AppType for `hc` — includes route responses plus global auth/middleware error statuses. */
16186
+ export type AppType = ApplyGlobalResponse<typeof routes, GlobalErrorResponses>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mestra-dev/contract",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "Types-only Hono AppType contract for the Mestra auth API",
5
5
  "type": "module",
6
6
  "sideEffects": false,