@vercel/connect 2.5.1 → 2.5.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.
@@ -13,17 +13,11 @@ export interface Experimental_ConnectEventsAdapterOptions {
13
13
  /** Overrides the client transport URL. Connect must authorize the endpoint. */
14
14
  mcpUrl?: string;
15
15
  }
16
- export type Experimental_ConnectEventsSubscribeInput = Pick<McpSubscribeInput, 'name' | 'idempotencyKey'> & {
16
+ export type Experimental_ConnectEventsSubscribeInput = Pick<McpSubscribeInput, 'name' | 'idempotencyKey' | 'ttlMs'> & {
17
17
  arguments: JsonObject;
18
18
  context?: JsonObject;
19
19
  options?: Experimental_ConnectEventsRequestOptions;
20
- } & ({
21
- ttlMs: number;
22
- expiresAt?: never;
23
- } | {
24
- expiresAt: string | null;
25
- ttlMs?: never;
26
- });
20
+ };
27
21
  /** A Connect watch, not an upstream MCP subscription grant. */
28
22
  export type Experimental_ConnectEventsSubscription = Pick<McpSubscription, 'id' | 'name' | 'status' | 'expiresAt' | 'cleanupStatus'> & {
29
23
  arguments: JsonObject;
@@ -20,6 +20,9 @@ export function experimental_connectEventsAdapter({ connector, tokenParams: conf
20
20
  (transport.type === 'custom' ? undefined : transport.url);
21
21
  return {
22
22
  async subscribe(input) {
23
+ if (input.expiresAt !== undefined) {
24
+ throw new TypeError('Use ttlMs instead of expiresAt when creating a subscription.');
25
+ }
23
26
  // Select fields explicitly so extra runtime properties cannot override
24
27
  // the bound scope or turn provider arguments into delivery configuration.
25
28
  return toSubscription(await subscribe(connector, {
@@ -30,7 +33,7 @@ export function experimental_connectEventsAdapter({ connector, tokenParams: conf
30
33
  destination: { path },
31
34
  context: input.context,
32
35
  idempotencyKey: input.idempotencyKey,
33
- ...monitoringLifetime(input),
36
+ ttlMs: input.ttlMs,
34
37
  }, requestOptions(input.options)));
35
38
  },
36
39
  async getSubscription({ id, options }) {
@@ -62,15 +65,6 @@ function requestOptions(options) {
62
65
  maxTotalTimeout: options.maxTotalTimeout,
63
66
  };
64
67
  }
65
- function monitoringLifetime(input) {
66
- if (input.ttlMs !== undefined && input.expiresAt === undefined) {
67
- return { ttlMs: input.ttlMs };
68
- }
69
- if (input.ttlMs === undefined && input.expiresAt !== undefined) {
70
- return { expiresAt: input.expiresAt };
71
- }
72
- throw new TypeError('Provide exactly one of ttlMs or expiresAt.');
73
- }
74
68
  function toSubscription(subscription) {
75
69
  return {
76
70
  id: subscription.id,
@@ -1,5 +1,5 @@
1
1
  /** JSON types kept local so Connect does not require an AI SDK dependency. */
2
- export type JsonValue = null | string | number | boolean | JsonObject | JsonValue[];
2
+ export type JsonValue = null | string | number | boolean | JsonObject | readonly JsonValue[];
3
3
  export type JsonObject = {
4
4
  [key: string]: JsonValue | undefined;
5
5
  };
@@ -40,13 +40,9 @@ export type McpSubscribeInput = McpEventSourceInput & {
40
40
  };
41
41
  context?: Record<string, unknown>;
42
42
  idempotencyKey: string;
43
- } & ({
44
- ttlMs: number;
45
- expiresAt?: never;
46
- } | {
47
- expiresAt: string | null;
48
- ttlMs?: never;
49
- });
43
+ /** Application lifetime in milliseconds (2 minutes to 365 days), or null until stopped. */
44
+ ttlMs: number | null;
45
+ };
50
46
  /** Upstream credential selection, separate from event and pagination fields. */
51
47
  export interface McpEventScope {
52
48
  /** Derive from authenticated application state, never model output. */
@@ -16,7 +16,15 @@ export function listEventTypes(connector, params, options) {
16
16
  url.searchParams.set('sourceUrl', params.mcpUrl);
17
17
  return send(url, { method: 'GET' }, options);
18
18
  }
19
- export function subscribe(connector, params, options) {
19
+ export async function subscribe(connector, params, options) {
20
+ if (params.expiresAt !== undefined) {
21
+ throw new TypeError('Use ttlMs instead of expiresAt when creating a subscription.');
22
+ }
23
+ const { ttlMs } = params;
24
+ if (ttlMs !== null &&
25
+ (!Number.isInteger(ttlMs) || ttlMs < 120_000 || ttlMs > 31_536_000_000)) {
26
+ throw new TypeError('ttlMs must be an integer from 120000 to 31536000000, or null to watch until stopped.');
27
+ }
20
28
  return request(connector, 'subscriptions', params, options);
21
29
  }
22
30
  export function listSubscriptions(connector, params, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/connect",
3
- "version": "2.5.1",
3
+ "version": "2.5.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "repository": {