@kyro-cms/core 0.13.0 → 0.13.2
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 +145 -77
- package/dist/WebhookService-BOJMgjBm.d.cts +143 -0
- package/dist/WebhookService-CFe6Zd0_.d.cts +143 -0
- package/dist/WebhookService-CGxHtw7E.d.cts +143 -0
- package/dist/WebhookService-CNC1lYz7.d.ts +143 -0
- package/dist/WebhookService-CVXmjbtQ.d.cts +143 -0
- package/dist/WebhookService-Dk1lzSrG.d.cts +143 -0
- package/dist/WebhookService-I6hdue2Y.d.ts +143 -0
- package/dist/WebhookService-KnQ2UDlW.d.ts +143 -0
- package/dist/WebhookService-fk0FGRlk.d.ts +143 -0
- package/dist/WebhookService-vsFnWrOh.d.ts +143 -0
- package/dist/api-handler-graphql.cjs +1 -1
- package/dist/api-handler-graphql.js +1 -1
- package/dist/api-handler-trpc.cjs +1 -1
- package/dist/api-handler-trpc.js +1 -1
- package/dist/api-handler.cjs +1 -1
- package/dist/api-handler.js +1 -1
- package/dist/base-B-i-tjm1.d.ts +218 -0
- package/dist/base-B-siit_y.d.cts +218 -0
- package/dist/base-B8SyZI4D.d.ts +218 -0
- package/dist/base-BCgFt3Yx.d.ts +218 -0
- package/dist/base-BHRGJ40F.d.cts +218 -0
- package/dist/base-BaOJ5uWd.d.cts +218 -0
- package/dist/base-BfPaVEAE.d.cts +218 -0
- package/dist/base-BxrX5EPU.d.cts +218 -0
- package/dist/base-CcZIEll-.d.ts +218 -0
- package/dist/base-OYfoYPYP.d.ts +218 -0
- package/dist/chunk-E4H3ZZ7U.js +4 -0
- package/dist/chunk-FDKU7HJX.js +2 -0
- package/dist/chunk-GV2IB4WQ.cjs +56 -0
- package/dist/chunk-JZ7Z6WC2.cjs +3 -0
- package/dist/chunk-MFNN5DYG.cjs +1 -0
- package/dist/chunk-SMQ6736Y.js +57 -0
- package/dist/client.cjs +11 -11
- package/dist/client.d.cts +18 -1
- package/dist/client.d.ts +18 -1
- package/dist/client.js +11 -11
- package/dist/drizzle/index.d.cts +3 -3
- package/dist/drizzle/index.d.ts +3 -3
- package/dist/fields/index.d.cts +2 -2
- package/dist/fields/index.d.ts +2 -2
- package/dist/graphql/index.d.cts +3 -3
- package/dist/graphql/index.d.ts +3 -3
- package/dist/index-8Ino7vKq.d.ts +105 -0
- package/dist/index-ByOM1Y5x.d.ts +105 -0
- package/dist/index-C6xmtRio.d.cts +105 -0
- package/dist/index-CTI3K_uq.d.cts +105 -0
- package/dist/index-CTL4zv_u.d.ts +105 -0
- package/dist/index-CaDbioSg.d.ts +105 -0
- package/dist/index-DS3DpJli.d.cts +105 -0
- package/dist/index-NGnJpSgf.d.ts +105 -0
- package/dist/index-Zrg3sZ6R.d.cts +105 -0
- package/dist/index-rm7uyOK1.d.cts +105 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +1 -1
- package/dist/mongodb/index.d.cts +3 -3
- package/dist/mongodb/index.d.ts +3 -3
- package/dist/rest/index.d.cts +4 -4
- package/dist/rest/index.d.ts +4 -4
- package/dist/templates/index.cjs +1 -1
- package/dist/templates/index.d.cts +2 -2
- package/dist/templates/index.d.ts +2 -2
- package/dist/templates/index.js +1 -1
- package/dist/trpc/index.d.cts +3 -3
- package/dist/trpc/index.d.ts +3 -3
- package/dist/types-6ShQp2EM.d.cts +839 -0
- package/dist/types-B9oXBEKI.d.cts +330 -0
- package/dist/types-B9oXBEKI.d.ts +330 -0
- package/dist/types-BCOhfwHC.d.ts +839 -0
- package/dist/types-BRDBNacn.d.ts +839 -0
- package/dist/types-C8yIAV6K.d.cts +839 -0
- package/dist/types-CORUQhY-.d.ts +839 -0
- package/dist/types-Cdssrcbz.d.cts +839 -0
- package/dist/types-CjGqxBd3.d.cts +330 -0
- package/dist/types-CjGqxBd3.d.ts +330 -0
- package/dist/types-DBGR-eQl.d.cts +839 -0
- package/dist/types-DxaK39ix.d.cts +330 -0
- package/dist/types-DxaK39ix.d.ts +330 -0
- package/dist/types-IeKFn7Ky.d.ts +839 -0
- package/dist/types-QglJ7PwT.d.cts +839 -0
- package/dist/types-zt5qIvje.d.ts +839 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,33 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
|
-
**Astro-native headless CMS with multi-database adapters, multi-protocol APIs, and
|
|
5
|
+
**Astro-native headless CMS with multi-database adapters, multi-protocol APIs, and a built-in React admin dashboard.**
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/@kyro-cms/core)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
9
9
|
[](https://www.typescriptlang.org/)
|
|
10
10
|
|
|
11
|
-
<br />
|
|
12
|
-
|
|
13
11
|
</div>
|
|
14
12
|
|
|
15
13
|
---
|
|
16
14
|
|
|
17
15
|
## What Kyro Gives You
|
|
18
16
|
|
|
19
|
-
Kyro turns a single TypeScript config into a full CMS backend for Astro
|
|
17
|
+
Kyro turns a single TypeScript config (`kyro.config.ts`) into a full CMS backend for Astro:
|
|
20
18
|
|
|
21
|
-
- **REST, GraphQL, tRPC, and WebSocket
|
|
22
|
-
- **
|
|
23
|
-
- **Auto-generated
|
|
24
|
-
- **End-to-
|
|
25
|
-
- **
|
|
19
|
+
- **Unified Multi-Protocol APIs**: Auto-generated REST, GraphQL, tRPC, and WebSocket endpoints from the same collection schema.
|
|
20
|
+
- **Multi-Database Adapters**: Instant local SQLite development plus production PostgreSQL (Drizzle) and MongoDB adapters.
|
|
21
|
+
- **Built-in Admin Dashboard**: Auto-generated React UI with field builders, live preview, version history, media manager, auth, and RBAC.
|
|
22
|
+
- **End-to-End Type Safety**: Schema types and validation powered by TypeScript and Zod.
|
|
23
|
+
- **Extensible Architecture**: Custom plugins, lifecycle hooks, field components, and dashboard widgets.
|
|
26
24
|
|
|
27
25
|
---
|
|
28
26
|
|
|
29
27
|
## Quick Start
|
|
30
28
|
|
|
31
|
-
### Create a
|
|
29
|
+
### 1. Create a New Kyro Project
|
|
32
30
|
|
|
33
31
|
```bash
|
|
34
32
|
pnpm create @kyro-cms@latest my-project
|
|
@@ -43,14 +41,13 @@ pnpm dev
|
|
|
43
41
|
```
|
|
44
42
|
|
|
45
43
|
Open:
|
|
44
|
+
- `http://localhost:4321` — Public Astro site
|
|
45
|
+
- `http://localhost:4321/admin` — CMS Admin Dashboard
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
- `http://localhost:4321/admin` — admin dashboard
|
|
49
|
-
|
|
50
|
-
### Add Kyro to an existing project
|
|
47
|
+
### 2. Add Kyro to an Existing Astro Project
|
|
51
48
|
|
|
52
49
|
```bash
|
|
53
|
-
pnpm
|
|
50
|
+
pnpm add @kyro-cms/core @kyro-cms/admin
|
|
54
51
|
```
|
|
55
52
|
|
|
56
53
|
```typescript
|
|
@@ -58,83 +55,145 @@ pnpm install @kyro-cms/core
|
|
|
58
55
|
import { defineKyroConfig, createLocalAdapter } from "@kyro-cms/core";
|
|
59
56
|
|
|
60
57
|
export default defineKyroConfig({
|
|
61
|
-
name: "my-app",
|
|
62
58
|
adapter: createLocalAdapter({ path: "./data/kyro.db" }),
|
|
63
|
-
collections:
|
|
64
|
-
|
|
59
|
+
collections: [
|
|
60
|
+
{
|
|
65
61
|
slug: "posts",
|
|
66
62
|
label: "Posts",
|
|
63
|
+
admin: {
|
|
64
|
+
useAsTitle: "title",
|
|
65
|
+
icon: "lucide:Newspaper",
|
|
66
|
+
group: "Content",
|
|
67
|
+
defaultColumns: ["title", "slug", "updatedAt"],
|
|
68
|
+
},
|
|
67
69
|
fields: [
|
|
68
70
|
{ name: "title", type: "text", required: true },
|
|
69
|
-
{
|
|
71
|
+
{
|
|
72
|
+
name: "slug",
|
|
73
|
+
type: "text",
|
|
74
|
+
required: true,
|
|
75
|
+
admin: { position: "sidebar", autoGenerate: "title" },
|
|
76
|
+
},
|
|
70
77
|
{ name: "content", type: "richtext" },
|
|
71
|
-
{
|
|
78
|
+
{
|
|
79
|
+
name: "published",
|
|
80
|
+
type: "checkbox",
|
|
81
|
+
defaultValue: false,
|
|
82
|
+
admin: { position: "sidebar" },
|
|
83
|
+
},
|
|
72
84
|
],
|
|
73
85
|
},
|
|
74
|
-
|
|
86
|
+
],
|
|
75
87
|
});
|
|
76
88
|
```
|
|
77
89
|
|
|
78
90
|
---
|
|
79
91
|
|
|
80
|
-
##
|
|
92
|
+
## Core Concepts
|
|
81
93
|
|
|
82
|
-
|
|
94
|
+
### Database Adapters
|
|
83
95
|
|
|
84
|
-
|
|
85
|
-
- **High-performance engine:** batched relationship population, zero-latency access control checks, and ~99% smaller ESM entrypoints
|
|
86
|
-
- **Unified API surface:** one schema powers REST, GraphQL, tRPC, and WebSockets
|
|
87
|
-
- **Production-ready:** swap adapters without rewriting collections
|
|
88
|
-
- **Admin experience:** auto-generated UIs, auth, RBAC, and draft workflows
|
|
96
|
+
Kyro uses a shared adapter layer so the same collection schema works across different databases without code changes:
|
|
89
97
|
|
|
90
|
-
|
|
98
|
+
- **SQLite (`createLocalAdapter`)** — Zero-config instant local file database.
|
|
99
|
+
- **PostgreSQL (`createDrizzleAdapter`)** — Production SQL powered by Drizzle ORM.
|
|
100
|
+
- **MongoDB (`createMongoDBAdapter`)** — Flexible document store for scalable applications.
|
|
91
101
|
|
|
92
|
-
|
|
102
|
+
### API Protocols
|
|
103
|
+
|
|
104
|
+
One schema definition automatically powers four API layers:
|
|
93
105
|
|
|
94
|
-
|
|
106
|
+
- **REST** (`/api/:collection`) — Standard JSON CRUD endpoints.
|
|
107
|
+
- **GraphQL** (`/api/graphql`) — Type-safe nested queries, mutations, and schema introspection.
|
|
108
|
+
- **tRPC** (`/api/trpc`) — End-to-end type-safe RPC client without schema generation.
|
|
109
|
+
- **WebSocket** (`/api/ws`) — Real-time live subscriptions and document presence.
|
|
95
110
|
|
|
96
|
-
|
|
111
|
+
### Modular Packages
|
|
97
112
|
|
|
98
|
-
-
|
|
99
|
-
-
|
|
100
|
-
-
|
|
113
|
+
- **`@kyro-cms/core`**: Core engine, database adapters, auth, and API handlers.
|
|
114
|
+
- **`@kyro-cms/admin`**: Auto-generated admin dashboard with media manager, RBAC, and draft workflows.
|
|
115
|
+
- **`@kyro-cms/astro`**: Astro integration, Content Layer loaders, and Astro Dev Toolbar widget.
|
|
116
|
+
- **`@kyro-cms/connect`**: Universal, type-safe client SDK and CLI codegen.
|
|
117
|
+
- **`@kyro-cms/ai`**: AI-powered content generation and admin assistance via Vercel AI SDK.
|
|
101
118
|
|
|
102
|
-
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Collection Admin Configuration
|
|
122
|
+
|
|
123
|
+
Configure how collections look and behave inside the admin UI using the `admin` property:
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
export const foodMenuCollection: CollectionConfig = {
|
|
127
|
+
slug: "food-menu",
|
|
128
|
+
label: "Food Menu",
|
|
129
|
+
admin: {
|
|
130
|
+
group: "Restaurant Menu", // Collapsible sidebar section name
|
|
131
|
+
order: 1, // Sorting position inside the section
|
|
132
|
+
icon: "lucide:Utensils", // "lucide:<name>", "hero:<name>", or "hero-solid:<name>"
|
|
133
|
+
useAsTitle: "name", // Field to display as title in lists & relation dropdowns
|
|
134
|
+
defaultColumns: ["name", "category", "price"], // Default table columns
|
|
135
|
+
description: "Manage restaurant food items and pricing",
|
|
136
|
+
},
|
|
137
|
+
fields: [ /* ... */ ],
|
|
138
|
+
};
|
|
139
|
+
```
|
|
103
140
|
|
|
104
|
-
|
|
141
|
+
| Property | Type | Description |
|
|
142
|
+
| :--- | :--- | :--- |
|
|
143
|
+
| `group` / `folder` | `string` | Categorizes the collection under a collapsible sidebar navigation drawer (e.g. `"Commerce"`, `"Restaurant Menu"`). |
|
|
144
|
+
| `order` | `number` | Controls the sorting order within the sidebar group (lower numbers first). |
|
|
145
|
+
| `icon` | `string` | Icon from [Lucide](https://lucide.dev/icons) (`"lucide:Utensils"`, `"Receipt"`) or [Heroicons](https://heroicons.com/) (`"hero:Sparkles"`, `"hero-solid:Fire"`). |
|
|
146
|
+
| `useAsTitle` | `string` | Field key displayed as the main title in list views, breadcrumbs, and relation pickers. |
|
|
147
|
+
| `defaultColumns` | `string[]` | Array of field keys rendered as default columns in the list table. |
|
|
148
|
+
| `description` | `string` | Subtitle description shown beneath the collection header. |
|
|
149
|
+
| `hidden` | `boolean` | When `true`, hides the collection from sidebar navigation while keeping APIs active. |
|
|
150
|
+
| `disablePreview` | `boolean` | Disables the live preview split view for this collection. |
|
|
151
|
+
| `disableDuplicate` | `boolean` | Hides the document duplicate action in the edit form. |
|
|
105
152
|
|
|
106
|
-
|
|
107
|
-
- **GraphQL** for nested queries and schema introspection
|
|
108
|
-
- **tRPC** for fully type-safe client-server calls
|
|
109
|
-
- **WebSocket** for real-time subscriptions and live updates
|
|
153
|
+
---
|
|
110
154
|
|
|
111
|
-
|
|
155
|
+
## Field Admin Configuration
|
|
112
156
|
|
|
113
|
-
|
|
157
|
+
Customize individual fields in edit forms with the `admin` property:
|
|
114
158
|
|
|
115
|
-
|
|
116
|
-
|
|
159
|
+
```typescript
|
|
160
|
+
{
|
|
161
|
+
name: "items",
|
|
162
|
+
type: "array",
|
|
163
|
+
label: "Order Items",
|
|
164
|
+
admin: {
|
|
165
|
+
readOnly: true,
|
|
166
|
+
display: "pills", // Displays items as compact inline pill capsules with count multipliers
|
|
167
|
+
},
|
|
168
|
+
fields: [
|
|
169
|
+
{ name: "name", type: "text", label: "Item Name" },
|
|
170
|
+
{ name: "quantity", type: "number", label: "Qty" },
|
|
171
|
+
{ name: "total", type: "number", label: "Total" },
|
|
172
|
+
],
|
|
173
|
+
}
|
|
174
|
+
```
|
|
117
175
|
|
|
118
|
-
|
|
176
|
+
| Property | Type | Description |
|
|
177
|
+
| :--- | :--- | :--- |
|
|
178
|
+
| `position` | `"sidebar" \| "main"` | Places the field in the sticky sidebar panel (ideal for status, dates, slug, badges) vs main form. |
|
|
179
|
+
| `display` | `"pills" \| "default"` | Array layout mode. `"pills"` renders compact line-item badge capsules with count multipliers and totals. |
|
|
180
|
+
| `collapsible` | `boolean` | Renders group fields with interactive collapsible accordion headers. |
|
|
181
|
+
| `initCollapsed` | `boolean` | Starts accordions, groups, and array cards closed by default. |
|
|
182
|
+
| `autoGenerate` | `string` | Auto-generates slug values from another field (e.g. `autoGenerate: "title"`). |
|
|
183
|
+
| `readOnly` | `boolean \| Function` | Displays field value as read-only. |
|
|
184
|
+
| `hidden` | `boolean \| Function` | Hides field from the admin UI form completely. |
|
|
119
185
|
|
|
120
|
-
Kyro is designed as a modular ecosystem:
|
|
121
|
-
- `@kyro-cms/astro` — Astro 5+ & 7+ integration, Content Layer loaders, Astro Dev Toolbar widget, and Zero-JS UI components.
|
|
122
|
-
- `@kyro-cms/admin` — Auto-generated React admin dashboard with media manager, auth, RBAC, and draft workflows.
|
|
123
|
-
- `@kyro-cms/connect` — Universal, type-safe API client and codegen for any framework.
|
|
124
|
-
- `@kyro-cms/ai` — Vercel AI SDK integration for automated content generation and AI admin assistance.
|
|
125
|
-
- `@kyro-cms/rich-text-react` — Headless React renderer for Kyro RichText content schemas.
|
|
126
|
-
- `@kyro-cms/field-locations` — Pre-built geographic SelectFields for Kyro CMS.
|
|
127
186
|
---
|
|
128
187
|
|
|
129
|
-
##
|
|
188
|
+
## API Examples
|
|
130
189
|
|
|
131
190
|
### REST
|
|
132
191
|
|
|
133
192
|
```bash
|
|
134
|
-
GET
|
|
135
|
-
GET
|
|
136
|
-
POST
|
|
137
|
-
PATCH
|
|
193
|
+
GET /api/posts
|
|
194
|
+
GET /api/posts/:id
|
|
195
|
+
POST /api/posts
|
|
196
|
+
PATCH /api/posts/:id
|
|
138
197
|
DELETE /api/posts/:id
|
|
139
198
|
```
|
|
140
199
|
|
|
@@ -153,15 +212,28 @@ query {
|
|
|
153
212
|
}
|
|
154
213
|
```
|
|
155
214
|
|
|
156
|
-
###
|
|
215
|
+
### Server-Side (Astro Pages & Endpoints)
|
|
157
216
|
|
|
158
|
-
|
|
159
|
-
|
|
217
|
+
Query the database directly with zero network overhead:
|
|
218
|
+
|
|
219
|
+
```astro
|
|
220
|
+
---
|
|
221
|
+
import { getKyro } from "@kyro-cms/astro";
|
|
222
|
+
|
|
223
|
+
const kyro = await getKyro();
|
|
224
|
+
const { docs: posts } = await kyro.find({ collection: "posts", limit: 10 });
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
<ul>
|
|
228
|
+
{posts.map((post) => (
|
|
229
|
+
<li>{post.title}</li>
|
|
230
|
+
))}
|
|
231
|
+
</ul>
|
|
160
232
|
```
|
|
161
233
|
|
|
162
|
-
###
|
|
234
|
+
### Client SDK (`@kyro-cms/connect`)
|
|
163
235
|
|
|
164
|
-
Type-safe client
|
|
236
|
+
Type-safe client for frontend frameworks (Next.js, Remix, SvelteKit, React):
|
|
165
237
|
|
|
166
238
|
```bash
|
|
167
239
|
pnpm add @kyro-cms/connect
|
|
@@ -169,28 +241,24 @@ pnpm add @kyro-cms/connect
|
|
|
169
241
|
|
|
170
242
|
```typescript
|
|
171
243
|
import { createClient } from "@kyro-cms/connect";
|
|
172
|
-
import type { KyroAppRouter } from "./kyro.generated";
|
|
173
244
|
|
|
174
|
-
const api = createClient
|
|
175
|
-
|
|
176
|
-
apiKey: "kyro_xxx",
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
const posts = await api["posts"].find.query({ page: 1, limit: 10 });
|
|
245
|
+
const api = createClient({ url: "http://localhost:4321/api/trpc" });
|
|
246
|
+
const { docs: posts } = await api.posts.find({ limit: 10 });
|
|
180
247
|
```
|
|
181
248
|
|
|
182
249
|
---
|
|
183
250
|
|
|
184
|
-
##
|
|
251
|
+
## Documentation
|
|
252
|
+
|
|
253
|
+
Comprehensive guides, API references, and architecture docs are available in the **[`kyro-docs`](https://kyro-cms.com)** site:
|
|
185
254
|
|
|
186
|
-
-
|
|
187
|
-
-
|
|
188
|
-
-
|
|
189
|
-
-
|
|
190
|
-
- [ROADMAP.md](file:///Users/macbook/Dev/Web/Astro/kyro-cms/ROADMAP.md) — product & innovation roadmap
|
|
255
|
+
- **[Getting Started Guide](https://kyro-cms.com/getting-started.html)** — First-time setup & walkthrough
|
|
256
|
+
- **[Configuration Reference](https://kyro-cms.com/reference/configuration.html)** — Full `kyro.config.ts` reference
|
|
257
|
+
- **[Field Types Reference](https://kyro-cms.com/guides/field-types.html)** — All 25+ schema field types
|
|
258
|
+
- **[Admin Customization](https://kyro-cms.com/guides/admin-customization.html)** — Layouts, plugins, and overrides
|
|
191
259
|
|
|
192
260
|
---
|
|
193
261
|
|
|
194
262
|
## License
|
|
195
263
|
|
|
196
|
-
MIT
|
|
264
|
+
MIT © [Kyro CMS](https://kyro-cms.com)
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { B as BaseAdapter } from './types-DBGR-eQl.cjs';
|
|
2
|
+
|
|
3
|
+
declare const WEBHOOK_EVENTS: {
|
|
4
|
+
readonly COLLECTION_CREATE: "collection.create";
|
|
5
|
+
readonly COLLECTION_UPDATE: "collection.update";
|
|
6
|
+
readonly COLLECTION_DELETE: "collection.delete";
|
|
7
|
+
readonly MEDIA_UPLOAD: "media.upload";
|
|
8
|
+
readonly MEDIA_DELETE: "media.delete";
|
|
9
|
+
readonly AUTH_LOGIN: "auth.login";
|
|
10
|
+
readonly AUTH_REGISTER: "auth.register";
|
|
11
|
+
readonly AUTH_LOGOUT: "auth.logout";
|
|
12
|
+
readonly ORDER_CREATED: "order.created";
|
|
13
|
+
readonly ORDER_PAID: "order.paid";
|
|
14
|
+
readonly ORDER_SHIPPED: "order.shipped";
|
|
15
|
+
readonly ORDER_DELIVERED: "order.delivered";
|
|
16
|
+
};
|
|
17
|
+
type WebhookEvent = (typeof WEBHOOK_EVENTS)[keyof typeof WEBHOOK_EVENTS];
|
|
18
|
+
declare const ALL_WEBHOOK_EVENTS: WebhookEvent[];
|
|
19
|
+
type WebhookActionType = "generic" | "github-push";
|
|
20
|
+
interface WebhookActionConfig {
|
|
21
|
+
githubOwner?: string;
|
|
22
|
+
githubRepo?: string;
|
|
23
|
+
githubBranch?: string;
|
|
24
|
+
}
|
|
25
|
+
interface WebhookConfig {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
url: string;
|
|
29
|
+
events: WebhookEvent[];
|
|
30
|
+
collections?: string[];
|
|
31
|
+
status: "active" | "inactive" | "error";
|
|
32
|
+
secret?: string;
|
|
33
|
+
headers?: Record<string, string>;
|
|
34
|
+
action?: WebhookActionType;
|
|
35
|
+
config?: WebhookActionConfig;
|
|
36
|
+
lastTriggered?: string;
|
|
37
|
+
lastError?: string;
|
|
38
|
+
createdAt: string;
|
|
39
|
+
updatedAt: string;
|
|
40
|
+
}
|
|
41
|
+
interface CreateWebhookData {
|
|
42
|
+
name: string;
|
|
43
|
+
url: string;
|
|
44
|
+
events: (WebhookEvent | "create" | "update" | "delete")[];
|
|
45
|
+
collections?: string[];
|
|
46
|
+
status?: "active" | "inactive";
|
|
47
|
+
secret?: string;
|
|
48
|
+
headers?: Record<string, string>;
|
|
49
|
+
action?: WebhookActionType;
|
|
50
|
+
config?: WebhookActionConfig;
|
|
51
|
+
}
|
|
52
|
+
interface UpdateWebhookData {
|
|
53
|
+
name?: string;
|
|
54
|
+
url?: string;
|
|
55
|
+
events?: (WebhookEvent | "create" | "update" | "delete")[];
|
|
56
|
+
collections?: string[];
|
|
57
|
+
status?: "active" | "inactive" | "error";
|
|
58
|
+
secret?: string;
|
|
59
|
+
headers?: Record<string, string>;
|
|
60
|
+
action?: WebhookActionType;
|
|
61
|
+
config?: WebhookActionConfig;
|
|
62
|
+
lastTriggered?: string | null;
|
|
63
|
+
lastError?: string | null;
|
|
64
|
+
}
|
|
65
|
+
interface WebhookPayload {
|
|
66
|
+
id: string;
|
|
67
|
+
event: WebhookEvent;
|
|
68
|
+
timestamp: string;
|
|
69
|
+
collection?: string;
|
|
70
|
+
operation?: "create" | "update" | "delete";
|
|
71
|
+
data?: unknown;
|
|
72
|
+
previousData?: unknown;
|
|
73
|
+
user?: {
|
|
74
|
+
id: string;
|
|
75
|
+
email?: string;
|
|
76
|
+
role?: string;
|
|
77
|
+
};
|
|
78
|
+
tenantId?: string;
|
|
79
|
+
metadata?: Record<string, unknown>;
|
|
80
|
+
}
|
|
81
|
+
interface WebhookDelivery {
|
|
82
|
+
id: string;
|
|
83
|
+
webhookId: string;
|
|
84
|
+
event: WebhookEvent;
|
|
85
|
+
payload: WebhookPayload;
|
|
86
|
+
attempt: number;
|
|
87
|
+
status: "pending" | "success" | "failed" | "retrying";
|
|
88
|
+
responseStatus?: number;
|
|
89
|
+
responseBody?: string;
|
|
90
|
+
error?: string;
|
|
91
|
+
duration?: number;
|
|
92
|
+
createdAt: string;
|
|
93
|
+
deliveredAt?: string;
|
|
94
|
+
nextRetryAt?: string;
|
|
95
|
+
}
|
|
96
|
+
interface WebhookTriggerResult {
|
|
97
|
+
deliveryId: string;
|
|
98
|
+
webhookId: string;
|
|
99
|
+
event: WebhookEvent;
|
|
100
|
+
status: "queued" | "success" | "failed";
|
|
101
|
+
responseStatus?: number;
|
|
102
|
+
duration?: number;
|
|
103
|
+
error?: string;
|
|
104
|
+
}
|
|
105
|
+
declare const WEBHOOK_COLLECTION = "_webhooks";
|
|
106
|
+
declare const WEBHOOK_DELIVERY_COLLECTION = "_webhook_deliveries";
|
|
107
|
+
interface DeliveryResult {
|
|
108
|
+
success: boolean;
|
|
109
|
+
status: number;
|
|
110
|
+
statusText?: string;
|
|
111
|
+
body?: string;
|
|
112
|
+
duration: number;
|
|
113
|
+
error?: string;
|
|
114
|
+
}
|
|
115
|
+
interface DeliveryOptions {
|
|
116
|
+
timeout?: number;
|
|
117
|
+
maxRetries?: number;
|
|
118
|
+
retryDelay?: number;
|
|
119
|
+
onRetry?: (attempt: number, error: string) => void;
|
|
120
|
+
onSuccess?: (result: DeliveryResult) => void;
|
|
121
|
+
onFailure?: (error: string) => void;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
declare class WebhookService {
|
|
125
|
+
private db;
|
|
126
|
+
constructor(db: BaseAdapter);
|
|
127
|
+
getWebhooks(filters?: {
|
|
128
|
+
status?: string;
|
|
129
|
+
event?: WebhookEvent;
|
|
130
|
+
}): Promise<WebhookConfig[]>;
|
|
131
|
+
getWebhookById(id: string): Promise<WebhookConfig | null>;
|
|
132
|
+
createWebhook(data: CreateWebhookData): Promise<WebhookConfig>;
|
|
133
|
+
updateWebhook(id: string, data: UpdateWebhookData): Promise<WebhookConfig | null>;
|
|
134
|
+
deleteWebhook(id: string): Promise<void>;
|
|
135
|
+
trigger(event: WebhookEvent, payloadData: Omit<WebhookPayload, "id" | "event" | "timestamp">): Promise<WebhookTriggerResult[]>;
|
|
136
|
+
triggerWebhook(webhook: WebhookConfig, payload: WebhookPayload): Promise<WebhookTriggerResult>;
|
|
137
|
+
testWebhook(webhookId: string): Promise<WebhookTriggerResult | null>;
|
|
138
|
+
getDeliveryHistory(webhookId: string, limit?: number): Promise<WebhookDelivery[]>;
|
|
139
|
+
retryDelivery(deliveryId: string): Promise<WebhookTriggerResult | null>;
|
|
140
|
+
}
|
|
141
|
+
declare function createWebhookService(db: BaseAdapter): WebhookService;
|
|
142
|
+
|
|
143
|
+
export { ALL_WEBHOOK_EVENTS as A, type CreateWebhookData as C, type DeliveryResult as D, type UpdateWebhookData as U, type WebhookPayload as W, type WebhookDelivery as a, type WebhookConfig as b, type DeliveryOptions as c, WebhookService as d, WEBHOOK_COLLECTION as e, WEBHOOK_DELIVERY_COLLECTION as f, WEBHOOK_EVENTS as g, type WebhookEvent as h, type WebhookTriggerResult as i, createWebhookService as j };
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { B as BaseAdapter } from './types-6ShQp2EM.cjs';
|
|
2
|
+
|
|
3
|
+
declare const WEBHOOK_EVENTS: {
|
|
4
|
+
readonly COLLECTION_CREATE: "collection.create";
|
|
5
|
+
readonly COLLECTION_UPDATE: "collection.update";
|
|
6
|
+
readonly COLLECTION_DELETE: "collection.delete";
|
|
7
|
+
readonly MEDIA_UPLOAD: "media.upload";
|
|
8
|
+
readonly MEDIA_DELETE: "media.delete";
|
|
9
|
+
readonly AUTH_LOGIN: "auth.login";
|
|
10
|
+
readonly AUTH_REGISTER: "auth.register";
|
|
11
|
+
readonly AUTH_LOGOUT: "auth.logout";
|
|
12
|
+
readonly ORDER_CREATED: "order.created";
|
|
13
|
+
readonly ORDER_PAID: "order.paid";
|
|
14
|
+
readonly ORDER_SHIPPED: "order.shipped";
|
|
15
|
+
readonly ORDER_DELIVERED: "order.delivered";
|
|
16
|
+
};
|
|
17
|
+
type WebhookEvent = (typeof WEBHOOK_EVENTS)[keyof typeof WEBHOOK_EVENTS];
|
|
18
|
+
declare const ALL_WEBHOOK_EVENTS: WebhookEvent[];
|
|
19
|
+
type WebhookActionType = "generic" | "github-push";
|
|
20
|
+
interface WebhookActionConfig {
|
|
21
|
+
githubOwner?: string;
|
|
22
|
+
githubRepo?: string;
|
|
23
|
+
githubBranch?: string;
|
|
24
|
+
}
|
|
25
|
+
interface WebhookConfig {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
url: string;
|
|
29
|
+
events: WebhookEvent[];
|
|
30
|
+
collections?: string[];
|
|
31
|
+
status: "active" | "inactive" | "error";
|
|
32
|
+
secret?: string;
|
|
33
|
+
headers?: Record<string, string>;
|
|
34
|
+
action?: WebhookActionType;
|
|
35
|
+
config?: WebhookActionConfig;
|
|
36
|
+
lastTriggered?: string;
|
|
37
|
+
lastError?: string;
|
|
38
|
+
createdAt: string;
|
|
39
|
+
updatedAt: string;
|
|
40
|
+
}
|
|
41
|
+
interface CreateWebhookData {
|
|
42
|
+
name: string;
|
|
43
|
+
url: string;
|
|
44
|
+
events: (WebhookEvent | "create" | "update" | "delete")[];
|
|
45
|
+
collections?: string[];
|
|
46
|
+
status?: "active" | "inactive";
|
|
47
|
+
secret?: string;
|
|
48
|
+
headers?: Record<string, string>;
|
|
49
|
+
action?: WebhookActionType;
|
|
50
|
+
config?: WebhookActionConfig;
|
|
51
|
+
}
|
|
52
|
+
interface UpdateWebhookData {
|
|
53
|
+
name?: string;
|
|
54
|
+
url?: string;
|
|
55
|
+
events?: (WebhookEvent | "create" | "update" | "delete")[];
|
|
56
|
+
collections?: string[];
|
|
57
|
+
status?: "active" | "inactive" | "error";
|
|
58
|
+
secret?: string;
|
|
59
|
+
headers?: Record<string, string>;
|
|
60
|
+
action?: WebhookActionType;
|
|
61
|
+
config?: WebhookActionConfig;
|
|
62
|
+
lastTriggered?: string | null;
|
|
63
|
+
lastError?: string | null;
|
|
64
|
+
}
|
|
65
|
+
interface WebhookPayload {
|
|
66
|
+
id: string;
|
|
67
|
+
event: WebhookEvent;
|
|
68
|
+
timestamp: string;
|
|
69
|
+
collection?: string;
|
|
70
|
+
operation?: "create" | "update" | "delete";
|
|
71
|
+
data?: unknown;
|
|
72
|
+
previousData?: unknown;
|
|
73
|
+
user?: {
|
|
74
|
+
id: string;
|
|
75
|
+
email?: string;
|
|
76
|
+
role?: string;
|
|
77
|
+
};
|
|
78
|
+
tenantId?: string;
|
|
79
|
+
metadata?: Record<string, unknown>;
|
|
80
|
+
}
|
|
81
|
+
interface WebhookDelivery {
|
|
82
|
+
id: string;
|
|
83
|
+
webhookId: string;
|
|
84
|
+
event: WebhookEvent;
|
|
85
|
+
payload: WebhookPayload;
|
|
86
|
+
attempt: number;
|
|
87
|
+
status: "pending" | "success" | "failed" | "retrying";
|
|
88
|
+
responseStatus?: number;
|
|
89
|
+
responseBody?: string;
|
|
90
|
+
error?: string;
|
|
91
|
+
duration?: number;
|
|
92
|
+
createdAt: string;
|
|
93
|
+
deliveredAt?: string;
|
|
94
|
+
nextRetryAt?: string;
|
|
95
|
+
}
|
|
96
|
+
interface WebhookTriggerResult {
|
|
97
|
+
deliveryId: string;
|
|
98
|
+
webhookId: string;
|
|
99
|
+
event: WebhookEvent;
|
|
100
|
+
status: "queued" | "success" | "failed";
|
|
101
|
+
responseStatus?: number;
|
|
102
|
+
duration?: number;
|
|
103
|
+
error?: string;
|
|
104
|
+
}
|
|
105
|
+
declare const WEBHOOK_COLLECTION = "_webhooks";
|
|
106
|
+
declare const WEBHOOK_DELIVERY_COLLECTION = "_webhook_deliveries";
|
|
107
|
+
interface DeliveryResult {
|
|
108
|
+
success: boolean;
|
|
109
|
+
status: number;
|
|
110
|
+
statusText?: string;
|
|
111
|
+
body?: string;
|
|
112
|
+
duration: number;
|
|
113
|
+
error?: string;
|
|
114
|
+
}
|
|
115
|
+
interface DeliveryOptions {
|
|
116
|
+
timeout?: number;
|
|
117
|
+
maxRetries?: number;
|
|
118
|
+
retryDelay?: number;
|
|
119
|
+
onRetry?: (attempt: number, error: string) => void;
|
|
120
|
+
onSuccess?: (result: DeliveryResult) => void;
|
|
121
|
+
onFailure?: (error: string) => void;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
declare class WebhookService {
|
|
125
|
+
private db;
|
|
126
|
+
constructor(db: BaseAdapter);
|
|
127
|
+
getWebhooks(filters?: {
|
|
128
|
+
status?: string;
|
|
129
|
+
event?: WebhookEvent;
|
|
130
|
+
}): Promise<WebhookConfig[]>;
|
|
131
|
+
getWebhookById(id: string): Promise<WebhookConfig | null>;
|
|
132
|
+
createWebhook(data: CreateWebhookData): Promise<WebhookConfig>;
|
|
133
|
+
updateWebhook(id: string, data: UpdateWebhookData): Promise<WebhookConfig | null>;
|
|
134
|
+
deleteWebhook(id: string): Promise<void>;
|
|
135
|
+
trigger(event: WebhookEvent, payloadData: Omit<WebhookPayload, "id" | "event" | "timestamp">): Promise<WebhookTriggerResult[]>;
|
|
136
|
+
triggerWebhook(webhook: WebhookConfig, payload: WebhookPayload): Promise<WebhookTriggerResult>;
|
|
137
|
+
testWebhook(webhookId: string): Promise<WebhookTriggerResult | null>;
|
|
138
|
+
getDeliveryHistory(webhookId: string, limit?: number): Promise<WebhookDelivery[]>;
|
|
139
|
+
retryDelivery(deliveryId: string): Promise<WebhookTriggerResult | null>;
|
|
140
|
+
}
|
|
141
|
+
declare function createWebhookService(db: BaseAdapter): WebhookService;
|
|
142
|
+
|
|
143
|
+
export { ALL_WEBHOOK_EVENTS as A, type CreateWebhookData as C, type DeliveryResult as D, type UpdateWebhookData as U, type WebhookPayload as W, type WebhookDelivery as a, type WebhookConfig as b, type DeliveryOptions as c, WebhookService as d, WEBHOOK_COLLECTION as e, WEBHOOK_DELIVERY_COLLECTION as f, WEBHOOK_EVENTS as g, type WebhookEvent as h, type WebhookTriggerResult as i, createWebhookService as j };
|