@decocms/bindings 1.4.8 → 1.4.9

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/bindings",
3
- "version": "1.4.8",
3
+ "version": "1.4.9",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "check": "tsc --noEmit",
package/src/index.ts CHANGED
@@ -49,41 +49,6 @@ export {
49
49
  type EventSubscriberBindingClient,
50
50
  } from "./well-known/event-subscriber";
51
51
 
52
- // Re-export event bus binding types (for interacting with an event bus)
53
- export {
54
- EventPublishInputSchema,
55
- type EventPublishInput,
56
- EventPublishOutputSchema,
57
- type EventPublishOutput,
58
- EventSubscribeInputSchema,
59
- type EventSubscribeInput,
60
- EventSubscribeOutputSchema,
61
- type EventSubscribeOutput,
62
- EventUnsubscribeInputSchema,
63
- type EventUnsubscribeInput,
64
- EventUnsubscribeOutputSchema,
65
- type EventUnsubscribeOutput,
66
- EventCancelInputSchema,
67
- type EventCancelInput,
68
- EventCancelOutputSchema,
69
- type EventCancelOutput,
70
- EventAckInputSchema,
71
- type EventAckInput,
72
- EventAckOutputSchema,
73
- type EventAckOutput,
74
- SubscriptionItemSchema,
75
- type SubscriptionItem,
76
- SubscriptionDetailSchema,
77
- type SubscriptionDetail,
78
- EventSyncSubscriptionsInputSchema,
79
- type EventSyncSubscriptionsInput,
80
- EventSyncSubscriptionsOutputSchema,
81
- type EventSyncSubscriptionsOutput,
82
- EVENT_BUS_BINDING,
83
- EventBusBinding,
84
- type EventBusBindingClient,
85
- } from "./well-known/event-bus";
86
-
87
52
  // Re-export trigger binding types (for connections that can emit triggers)
88
53
  export {
89
54
  TriggerParamSchema,
@@ -1,454 +0,0 @@
1
- /**
2
- * Event Bus Well-Known Binding
3
- *
4
- * Defines the interface for interacting with an event bus via MCP.
5
- * Any MCP that implements this binding can publish events and manage subscriptions.
6
- *
7
- * This binding includes:
8
- * - EVENT_PUBLISH: Publish an event to the bus
9
- * - EVENT_SUBSCRIBE: Subscribe to events of a specific type
10
- * - EVENT_UNSUBSCRIBE: Remove a subscription
11
- *
12
- * Events follow the CloudEvents v1.0 specification.
13
- * @see https://cloudevents.io/
14
- */
15
-
16
- import { z } from "zod";
17
- import { bindingClient, type ToolBinder } from "../core/binder";
18
-
19
- // ============================================================================
20
- // Publish Schemas
21
- // ============================================================================
22
-
23
- /**
24
- * EVENT_PUBLISH Input Schema
25
- *
26
- * Input for publishing an event.
27
- * Note: `source` is automatically set by the event bus from the caller's connection ID.
28
- */
29
- export const EventPublishInputSchema = z.object({
30
- /** Event type (e.g., "order.created", "user.signup") */
31
- type: z.string().min(1).max(255).describe("Event type identifier"),
32
-
33
- /** Optional subject/resource identifier */
34
- subject: z
35
- .string()
36
- .max(255)
37
- .optional()
38
- .describe("Subject/resource identifier (e.g., order ID)"),
39
-
40
- /** Event payload (any JSON value) */
41
- data: z.unknown().optional().describe("Event payload"),
42
-
43
- /**
44
- * Optional scheduled delivery time (ISO 8601 timestamp).
45
- * If provided, the event will not be delivered until this time.
46
- * If omitted, the event is delivered immediately.
47
- * Cannot be used together with `cron`.
48
- */
49
- deliverAt: z
50
- .string()
51
- .datetime()
52
- .optional()
53
- .describe(
54
- "Scheduled delivery time (ISO 8601). Omit for immediate delivery.",
55
- ),
56
-
57
- /**
58
- * Optional cron expression for recurring events.
59
- * If provided, the event will be delivered repeatedly according to the schedule.
60
- * Uses standard cron syntax (5 or 6 fields).
61
- * Cannot be used together with `deliverAt`.
62
- *
63
- * Examples:
64
- * - "0 9 * * 1" - Every Monday at 9:00 AM
65
- * - "0 0 1 * *" - First day of every month at midnight
66
- * - "0/15 * * * *" - Every 15 minutes
67
- */
68
- cron: z
69
- .string()
70
- .max(100)
71
- .optional()
72
- .describe(
73
- "Cron expression for recurring delivery. Use EVENT_CANCEL to stop.",
74
- ),
75
- });
76
-
77
- export type EventPublishInput = z.infer<typeof EventPublishInputSchema>;
78
-
79
- /**
80
- * EVENT_PUBLISH Output Schema
81
- */
82
- export const EventPublishOutputSchema = z.object({
83
- /** Created event ID */
84
- id: z.string().describe("Unique event ID"),
85
-
86
- /** Event type */
87
- type: z.string().describe("Event type"),
88
-
89
- /** Source connection ID */
90
- source: z.string().describe("Source connection ID"),
91
-
92
- /** Event timestamp (ISO 8601) */
93
- time: z.string().describe("Event timestamp"),
94
- });
95
-
96
- export type EventPublishOutput = z.infer<typeof EventPublishOutputSchema>;
97
-
98
- // ============================================================================
99
- // Subscribe Schemas
100
- // ============================================================================
101
-
102
- /**
103
- * EVENT_SUBSCRIBE Input Schema
104
- *
105
- * Input for subscribing to events.
106
- * The subscriber connection ID is automatically set from the caller's token.
107
- */
108
- export const EventSubscribeInputSchema = z.object({
109
- /** Event type pattern to match */
110
- eventType: z.string().min(1).max(255).describe("Event type to subscribe to"),
111
-
112
- /** Optional: Only receive events from this publisher connection */
113
- publisher: z
114
- .string()
115
- .optional()
116
- .describe("Filter events by publisher connection ID"),
117
-
118
- /** Optional: JSONPath filter expression on event data */
119
- filter: z
120
- .string()
121
- .max(1000)
122
- .optional()
123
- .describe("JSONPath filter expression on event data"),
124
- });
125
-
126
- export type EventSubscribeInput = z.infer<typeof EventSubscribeInputSchema>;
127
-
128
- /**
129
- * EVENT_SUBSCRIBE Output Schema
130
- */
131
- export const EventSubscribeOutputSchema = z.object({
132
- /** Created subscription */
133
- subscription: z.object({
134
- /** Subscription ID */
135
- id: z.string().describe("Subscription ID"),
136
-
137
- /** Subscriber connection ID */
138
- connectionId: z.string().describe("Subscriber connection ID"),
139
-
140
- /** Event type pattern */
141
- eventType: z.string().describe("Event type pattern"),
142
-
143
- /** Publisher connection filter */
144
- publisher: z.string().nullable().describe("Publisher connection filter"),
145
-
146
- /** JSONPath filter */
147
- filter: z.string().nullable().describe("JSONPath filter expression"),
148
-
149
- /** Whether subscription is enabled */
150
- enabled: z.boolean().describe("Whether subscription is enabled"),
151
-
152
- /** Created timestamp */
153
- createdAt: z.string().datetime().describe("Created timestamp (ISO 8601)"),
154
-
155
- /** Updated timestamp */
156
- updatedAt: z.string().datetime().describe("Updated timestamp (ISO 8601)"),
157
- }),
158
- });
159
-
160
- export type EventSubscribeOutput = z.infer<typeof EventSubscribeOutputSchema>;
161
-
162
- // ============================================================================
163
- // Sync Subscriptions Schemas
164
- // ============================================================================
165
-
166
- /**
167
- * Subscription item schema for sync operations
168
- */
169
- export const SubscriptionItemSchema = z.object({
170
- /** Event type pattern to match */
171
- eventType: z.string().min(1).max(255).describe("Event type to subscribe to"),
172
-
173
- /** Optional: Only receive events from this publisher connection */
174
- publisher: z
175
- .string()
176
- .optional()
177
- .describe("Filter events by publisher connection ID"),
178
-
179
- /** Optional: JSONPath filter expression on event data */
180
- filter: z
181
- .string()
182
- .max(1000)
183
- .optional()
184
- .describe("JSONPath filter expression on event data"),
185
- });
186
-
187
- export type SubscriptionItem = z.infer<typeof SubscriptionItemSchema>;
188
-
189
- /**
190
- * Subscription detail schema (returned in responses)
191
- */
192
- export const SubscriptionDetailSchema = z.object({
193
- /** Subscription ID */
194
- id: z.string().describe("Subscription ID"),
195
-
196
- /** Subscriber connection ID */
197
- connectionId: z.string().describe("Subscriber connection ID"),
198
-
199
- /** Event type pattern */
200
- eventType: z.string().describe("Event type pattern"),
201
-
202
- /** Publisher connection filter */
203
- publisher: z.string().nullable().describe("Publisher connection filter"),
204
-
205
- /** JSONPath filter */
206
- filter: z.string().nullable().describe("JSONPath filter expression"),
207
-
208
- /** Whether subscription is enabled */
209
- enabled: z.boolean().describe("Whether subscription is enabled"),
210
-
211
- /** Created timestamp */
212
- createdAt: z.string().datetime().describe("Created timestamp (ISO 8601)"),
213
-
214
- /** Updated timestamp */
215
- updatedAt: z.string().datetime().describe("Updated timestamp (ISO 8601)"),
216
- });
217
-
218
- export type SubscriptionDetail = z.infer<typeof SubscriptionDetailSchema>;
219
-
220
- /**
221
- * EVENT_SYNC_SUBSCRIPTIONS Input Schema
222
- *
223
- * Input for syncing subscriptions to a desired state.
224
- * The system will create new, delete removed, and update changed subscriptions.
225
- * Subscriptions are identified by (eventType, publisher) - only one subscription
226
- * per combination is allowed.
227
- */
228
- export const EventSyncSubscriptionsInputSchema = z.object({
229
- /** Desired subscriptions - system will create/update/delete to match */
230
- subscriptions: z
231
- .array(SubscriptionItemSchema)
232
- .describe(
233
- "Desired subscriptions - system will create/update/delete to match",
234
- ),
235
- });
236
-
237
- export type EventSyncSubscriptionsInput = z.infer<
238
- typeof EventSyncSubscriptionsInputSchema
239
- >;
240
-
241
- /**
242
- * EVENT_SYNC_SUBSCRIPTIONS Output Schema
243
- */
244
- export const EventSyncSubscriptionsOutputSchema = z.object({
245
- /** Number of new subscriptions created */
246
- created: z.number().int().min(0).describe("Number of subscriptions created"),
247
-
248
- /** Number of subscriptions with filter updated */
249
- updated: z
250
- .number()
251
- .int()
252
- .min(0)
253
- .describe("Number of subscriptions with filter updated"),
254
-
255
- /** Number of old subscriptions removed */
256
- deleted: z.number().int().min(0).describe("Number of subscriptions removed"),
257
-
258
- /** Number of subscriptions unchanged */
259
- unchanged: z
260
- .number()
261
- .int()
262
- .min(0)
263
- .describe("Number of subscriptions unchanged"),
264
-
265
- /** Current subscriptions after sync */
266
- subscriptions: z
267
- .array(SubscriptionDetailSchema)
268
- .describe("Current subscriptions after sync"),
269
- });
270
-
271
- export type EventSyncSubscriptionsOutput = z.infer<
272
- typeof EventSyncSubscriptionsOutputSchema
273
- >;
274
-
275
- // ============================================================================
276
- // Unsubscribe Schemas
277
- // ============================================================================
278
-
279
- /**
280
- * EVENT_UNSUBSCRIBE Input Schema
281
- */
282
- export const EventUnsubscribeInputSchema = z.object({
283
- /** Subscription ID to remove */
284
- subscriptionId: z.string().describe("Subscription ID to remove"),
285
- });
286
-
287
- export type EventUnsubscribeInput = z.infer<typeof EventUnsubscribeInputSchema>;
288
-
289
- /**
290
- * EVENT_UNSUBSCRIBE Output Schema
291
- */
292
- export const EventUnsubscribeOutputSchema = z.object({
293
- /** Success status */
294
- success: z.boolean().describe("Whether unsubscribe was successful"),
295
-
296
- /** Subscription ID that was removed */
297
- subscriptionId: z.string().describe("Subscription ID that was removed"),
298
- });
299
-
300
- export type EventUnsubscribeOutput = z.infer<
301
- typeof EventUnsubscribeOutputSchema
302
- >;
303
-
304
- // ============================================================================
305
- // Cancel Schemas (for stopping recurring events)
306
- // ============================================================================
307
-
308
- /**
309
- * EVENT_CANCEL Input Schema
310
- *
311
- * Input for cancelling a recurring event.
312
- * Only the publisher connection can cancel its own events.
313
- */
314
- export const EventCancelInputSchema = z.object({
315
- /** Event ID to cancel */
316
- eventId: z.string().describe("Event ID to cancel"),
317
- });
318
-
319
- export type EventCancelInput = z.infer<typeof EventCancelInputSchema>;
320
-
321
- /**
322
- * EVENT_CANCEL Output Schema
323
- */
324
- export const EventCancelOutputSchema = z.object({
325
- /** Success status */
326
- success: z.boolean().describe("Whether cancellation was successful"),
327
-
328
- /** Event ID that was cancelled */
329
- eventId: z.string().describe("Event ID that was cancelled"),
330
- });
331
-
332
- export type EventCancelOutput = z.infer<typeof EventCancelOutputSchema>;
333
-
334
- // ============================================================================
335
- // Ack Schemas (for acknowledging async event processing)
336
- // ============================================================================
337
-
338
- /**
339
- * EVENT_ACK Input Schema
340
- *
341
- * Input for acknowledging an event delivery.
342
- * Used when ON_EVENTS returns retryAfter - the subscriber must call EVENT_ACK
343
- * to confirm successful processing, otherwise the event will be re-delivered.
344
- *
345
- * The subscriber connection ID is determined from the caller's token.
346
- */
347
- export const EventAckInputSchema = z.object({
348
- /** Event ID to acknowledge */
349
- eventId: z.string().describe("Event ID to acknowledge"),
350
- });
351
-
352
- export type EventAckInput = z.infer<typeof EventAckInputSchema>;
353
-
354
- /**
355
- * EVENT_ACK Output Schema
356
- */
357
- export const EventAckOutputSchema = z.object({
358
- /** Success status */
359
- success: z.boolean().describe("Whether ACK was successful"),
360
-
361
- /** Event ID that was acknowledged */
362
- eventId: z.string().describe("Event ID that was acknowledged"),
363
- });
364
-
365
- export type EventAckOutput = z.infer<typeof EventAckOutputSchema>;
366
-
367
- // ============================================================================
368
- // Event Bus Binding
369
- // ============================================================================
370
-
371
- /**
372
- * Event Bus Binding
373
- *
374
- * Defines the interface for interacting with an event bus.
375
- * Implementations must provide PUBLISH, SUBSCRIBE, UNSUBSCRIBE, CANCEL, ACK, and SYNC_SUBSCRIPTIONS tools.
376
- *
377
- * Required tools:
378
- * - EVENT_PUBLISH: Publish an event (supports one-time, scheduled, and recurring via cron)
379
- * - EVENT_SUBSCRIBE: Subscribe to events
380
- * - EVENT_UNSUBSCRIBE: Remove a subscription
381
- * - EVENT_CANCEL: Cancel a recurring event (stops future deliveries)
382
- * - EVENT_ACK: Acknowledge event delivery (for async processing with retryAfter)
383
- * - EVENT_SYNC_SUBSCRIPTIONS: Sync subscriptions to desired state
384
- */
385
- export const EVENT_BUS_BINDING = [
386
- {
387
- name: "EVENT_PUBLISH" as const,
388
- inputSchema: EventPublishInputSchema,
389
- outputSchema: EventPublishOutputSchema,
390
- },
391
- {
392
- name: "EVENT_SUBSCRIBE" as const,
393
- inputSchema: EventSubscribeInputSchema,
394
- outputSchema: EventSubscribeOutputSchema,
395
- },
396
- {
397
- name: "EVENT_UNSUBSCRIBE" as const,
398
- inputSchema: EventUnsubscribeInputSchema,
399
- outputSchema: EventUnsubscribeOutputSchema,
400
- },
401
- {
402
- name: "EVENT_CANCEL" as const,
403
- inputSchema: EventCancelInputSchema,
404
- outputSchema: EventCancelOutputSchema,
405
- },
406
- {
407
- name: "EVENT_ACK" as const,
408
- inputSchema: EventAckInputSchema,
409
- outputSchema: EventAckOutputSchema,
410
- },
411
- {
412
- name: "EVENT_SYNC_SUBSCRIPTIONS" as const,
413
- inputSchema: EventSyncSubscriptionsInputSchema,
414
- outputSchema: EventSyncSubscriptionsOutputSchema,
415
- },
416
- ] satisfies ToolBinder[];
417
-
418
- /**
419
- * Event Bus Binding Client
420
- *
421
- * Use this to create a client for interacting with an event bus.
422
- *
423
- * @example
424
- * ```typescript
425
- * import { EventBusBinding } from "@decocms/bindings/event-bus";
426
- *
427
- * // For a connection
428
- * const client = EventBusBinding.forConnection(connection);
429
- *
430
- * // Publish an event
431
- * const event = await client.EVENT_PUBLISH({
432
- * type: "order.created",
433
- * data: { orderId: "123" }
434
- * });
435
- *
436
- * // Subscribe to events
437
- * const sub = await client.EVENT_SUBSCRIBE({
438
- * eventType: "order.created"
439
- * });
440
- *
441
- * // Unsubscribe
442
- * await client.EVENT_UNSUBSCRIBE({
443
- * subscriptionId: sub.subscription.id
444
- * });
445
- * ```
446
- */
447
- export const EventBusBinding = bindingClient(EVENT_BUS_BINDING);
448
-
449
- /**
450
- * Type helper for the Event Bus binding client
451
- */
452
- export type EventBusBindingClient = ReturnType<
453
- typeof EventBusBinding.forConnection
454
- >;