@mestra-dev/contract 0.0.12 → 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 +10 -1
- package/dist/index.d.ts +113 -4
- package/package.json +1 -1
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
|
-
|
|
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 {
|
|
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
|
}, ({
|
|
@@ -20,7 +26,7 @@ declare const routes: import("hono/hono-base").HonoBase<{
|
|
|
20
26
|
readonly openapi: "3.0.3";
|
|
21
27
|
readonly info: {
|
|
22
28
|
readonly title: "Auth Service API";
|
|
23
|
-
readonly version: "1.5.
|
|
29
|
+
readonly version: "1.5.3";
|
|
24
30
|
readonly description: "OpenAPI specification for the Auth, Integrations, Workspace, Tasks, Templates, Tags, Comments, Assignees, Chat, Events, Billings, Files, and Notifications endpoints exposed by the k3-core platform.";
|
|
25
31
|
};
|
|
26
32
|
readonly servers: readonly [
|
|
@@ -96,7 +102,7 @@ declare const routes: import("hono/hono-base").HonoBase<{
|
|
|
96
102
|
},
|
|
97
103
|
{
|
|
98
104
|
readonly name: "Notifications";
|
|
99
|
-
readonly description: "Cursor-based incremental notification sync, plus mark-read
|
|
105
|
+
readonly description: "Cursor-based incremental notification sync, plus mark-read / archive (single or all). Clients store the sync cursor and pass it on the next call; mutations bump updated_at so changes propagate via sync.";
|
|
100
106
|
}
|
|
101
107
|
];
|
|
102
108
|
readonly components: {
|
|
@@ -10178,6 +10184,36 @@ declare const routes: import("hono/hono-base").HonoBase<{
|
|
|
10178
10184
|
};
|
|
10179
10185
|
};
|
|
10180
10186
|
};
|
|
10187
|
+
readonly "/notifications/read-all": {
|
|
10188
|
+
readonly post: {
|
|
10189
|
+
readonly tags: readonly [
|
|
10190
|
+
"Notifications"
|
|
10191
|
+
];
|
|
10192
|
+
readonly summary: "Mark all notifications as read";
|
|
10193
|
+
readonly description: "Sets `read=true` and bumps `updated_at` on every unread notification owned by the authenticated user so the changes are picked up by `/notifications/sync`. Requires a valid access token (no workspace policy check).";
|
|
10194
|
+
readonly security: readonly [
|
|
10195
|
+
never
|
|
10196
|
+
];
|
|
10197
|
+
readonly responses: {
|
|
10198
|
+
readonly 200: {
|
|
10199
|
+
readonly description: "All unread notifications marked as read.";
|
|
10200
|
+
readonly content: {
|
|
10201
|
+
readonly "application/json": {
|
|
10202
|
+
readonly schema: {
|
|
10203
|
+
readonly $ref: "#/components/schemas/SimpleSuccess";
|
|
10204
|
+
};
|
|
10205
|
+
};
|
|
10206
|
+
};
|
|
10207
|
+
};
|
|
10208
|
+
readonly 401: {
|
|
10209
|
+
readonly description: "Unauthorized - Missing or invalid access token.";
|
|
10210
|
+
};
|
|
10211
|
+
readonly 403: {
|
|
10212
|
+
readonly description: "Forbidden - Token issuer is not 'access'.";
|
|
10213
|
+
};
|
|
10214
|
+
};
|
|
10215
|
+
};
|
|
10216
|
+
};
|
|
10181
10217
|
readonly "/notifications/archive": {
|
|
10182
10218
|
readonly post: {
|
|
10183
10219
|
readonly tags: readonly [
|
|
@@ -10238,6 +10274,36 @@ declare const routes: import("hono/hono-base").HonoBase<{
|
|
|
10238
10274
|
};
|
|
10239
10275
|
};
|
|
10240
10276
|
};
|
|
10277
|
+
readonly "/notifications/archive-all": {
|
|
10278
|
+
readonly post: {
|
|
10279
|
+
readonly tags: readonly [
|
|
10280
|
+
"Notifications"
|
|
10281
|
+
];
|
|
10282
|
+
readonly summary: "Archive all notifications";
|
|
10283
|
+
readonly description: "Sets `archive=true` and bumps `updated_at` on every unarchived notification owned by the authenticated user so the changes are picked up by `/notifications/sync`. Requires a valid access token (no workspace policy check).";
|
|
10284
|
+
readonly security: readonly [
|
|
10285
|
+
never
|
|
10286
|
+
];
|
|
10287
|
+
readonly responses: {
|
|
10288
|
+
readonly 200: {
|
|
10289
|
+
readonly description: "All unarchived notifications archived.";
|
|
10290
|
+
readonly content: {
|
|
10291
|
+
readonly "application/json": {
|
|
10292
|
+
readonly schema: {
|
|
10293
|
+
readonly $ref: "#/components/schemas/SimpleSuccess";
|
|
10294
|
+
};
|
|
10295
|
+
};
|
|
10296
|
+
};
|
|
10297
|
+
};
|
|
10298
|
+
readonly 401: {
|
|
10299
|
+
readonly description: "Unauthorized - Missing or invalid access token.";
|
|
10300
|
+
};
|
|
10301
|
+
readonly 403: {
|
|
10302
|
+
readonly description: "Forbidden - Token issuer is not 'access'.";
|
|
10303
|
+
};
|
|
10304
|
+
};
|
|
10305
|
+
};
|
|
10306
|
+
};
|
|
10241
10307
|
readonly "/chat/start": {
|
|
10242
10308
|
readonly post: {
|
|
10243
10309
|
readonly tags: readonly [
|
|
@@ -16046,6 +16112,17 @@ declare const routes: import("hono/hono-base").HonoBase<{
|
|
|
16046
16112
|
status: 200;
|
|
16047
16113
|
};
|
|
16048
16114
|
};
|
|
16115
|
+
} & {
|
|
16116
|
+
"/read-all": {
|
|
16117
|
+
$post: {
|
|
16118
|
+
input: {};
|
|
16119
|
+
output: {
|
|
16120
|
+
success: true;
|
|
16121
|
+
};
|
|
16122
|
+
outputFormat: "json";
|
|
16123
|
+
status: 200;
|
|
16124
|
+
};
|
|
16125
|
+
};
|
|
16049
16126
|
} & {
|
|
16050
16127
|
"/archive": {
|
|
16051
16128
|
$post: {
|
|
@@ -16073,5 +16150,37 @@ declare const routes: import("hono/hono-base").HonoBase<{
|
|
|
16073
16150
|
status: 200;
|
|
16074
16151
|
};
|
|
16075
16152
|
};
|
|
16153
|
+
} & {
|
|
16154
|
+
"/archive-all": {
|
|
16155
|
+
$post: {
|
|
16156
|
+
input: {};
|
|
16157
|
+
output: {
|
|
16158
|
+
success: true;
|
|
16159
|
+
};
|
|
16160
|
+
outputFormat: "json";
|
|
16161
|
+
status: 200;
|
|
16162
|
+
};
|
|
16163
|
+
};
|
|
16076
16164
|
}, "/notifications">, "/", "/">;
|
|
16077
|
-
|
|
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>;
|