@contractspec/example.integration-hub 3.0.0 → 3.1.1

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.
@@ -2,3 +2,11 @@
2
2
  * Connection status enum.
3
3
  */
4
4
  export declare const ConnectionStatusEnum: import("@contractspec/lib.schema").EnumType<[string, string, string, string, string]>;
5
+ /**
6
+ * Authentication method used by a connection.
7
+ */
8
+ export declare const AuthTypeEnum: import("@contractspec/lib.schema").EnumType<[string, string, string, string, string, string, string]>;
9
+ /**
10
+ * Transport protocol for communicating with the external system.
11
+ */
12
+ export declare const TransportTypeEnum: import("@contractspec/lib.schema").EnumType<[string, string, string, string]>;
@@ -8,6 +8,23 @@ var ConnectionStatusEnum = defineEnum("ConnectionStatus", [
8
8
  "ERROR",
9
9
  "EXPIRED"
10
10
  ]);
11
+ var AuthTypeEnum = defineEnum("AuthType", [
12
+ "api_key",
13
+ "oauth2",
14
+ "bearer",
15
+ "header",
16
+ "basic",
17
+ "webhook_signing",
18
+ "service_account"
19
+ ]);
20
+ var TransportTypeEnum = defineEnum("TransportType", [
21
+ "rest",
22
+ "mcp",
23
+ "webhook",
24
+ "sdk"
25
+ ]);
11
26
  export {
12
- ConnectionStatusEnum
27
+ TransportTypeEnum,
28
+ ConnectionStatusEnum,
29
+ AuthTypeEnum
13
30
  };
@@ -18,6 +18,22 @@ export declare const CreateConnectionContract: import("@contractspec/lib.contrac
18
18
  type: import("@contractspec/lib.schema").FieldType<unknown, unknown>;
19
19
  isOptional: true;
20
20
  };
21
+ transport: {
22
+ type: import("@contractspec/lib.schema").EnumType<[string, string, string, string]>;
23
+ isOptional: true;
24
+ };
25
+ authMethod: {
26
+ type: import("@contractspec/lib.schema").EnumType<[string, string, string, string, string, string, string]>;
27
+ isOptional: true;
28
+ };
29
+ apiVersion: {
30
+ type: import("@contractspec/lib.schema").FieldType<string, string>;
31
+ isOptional: true;
32
+ };
33
+ ownershipMode: {
34
+ type: import("@contractspec/lib.schema").FieldType<string, string>;
35
+ isOptional: true;
36
+ };
21
37
  }>, import("@contractspec/lib.schema").SchemaModel<{
22
38
  id: {
23
39
  type: import("@contractspec/lib.schema").FieldType<string, string>;
@@ -55,6 +71,22 @@ export declare const CreateConnectionContract: import("@contractspec/lib.contrac
55
71
  type: import("@contractspec/lib.schema").FieldType<string, string>;
56
72
  isOptional: true;
57
73
  };
74
+ transport: {
75
+ type: import("@contractspec/lib.schema").EnumType<[string, string, string, string]>;
76
+ isOptional: true;
77
+ };
78
+ authMethod: {
79
+ type: import("@contractspec/lib.schema").EnumType<[string, string, string, string, string, string, string]>;
80
+ isOptional: true;
81
+ };
82
+ apiVersion: {
83
+ type: import("@contractspec/lib.schema").FieldType<string, string>;
84
+ isOptional: true;
85
+ };
86
+ ownershipMode: {
87
+ type: import("@contractspec/lib.schema").FieldType<string, string>;
88
+ isOptional: true;
89
+ };
58
90
  }>, {
59
91
  key: string;
60
92
  version: string;
@@ -96,5 +128,21 @@ export declare const CreateConnectionContract: import("@contractspec/lib.contrac
96
128
  type: import("@contractspec/lib.schema").FieldType<string, string>;
97
129
  isOptional: true;
98
130
  };
131
+ transport: {
132
+ type: import("@contractspec/lib.schema").EnumType<[string, string, string, string]>;
133
+ isOptional: true;
134
+ };
135
+ authMethod: {
136
+ type: import("@contractspec/lib.schema").EnumType<[string, string, string, string, string, string, string]>;
137
+ isOptional: true;
138
+ };
139
+ apiVersion: {
140
+ type: import("@contractspec/lib.schema").FieldType<string, string>;
141
+ isOptional: true;
142
+ };
143
+ ownershipMode: {
144
+ type: import("@contractspec/lib.schema").FieldType<string, string>;
145
+ isOptional: true;
146
+ };
99
147
  }>;
100
148
  }[]>;
@@ -8,6 +8,21 @@ var ConnectionStatusEnum = defineEnum("ConnectionStatus", [
8
8
  "ERROR",
9
9
  "EXPIRED"
10
10
  ]);
11
+ var AuthTypeEnum = defineEnum("AuthType", [
12
+ "api_key",
13
+ "oauth2",
14
+ "bearer",
15
+ "header",
16
+ "basic",
17
+ "webhook_signing",
18
+ "service_account"
19
+ ]);
20
+ var TransportTypeEnum = defineEnum("TransportType", [
21
+ "rest",
22
+ "mcp",
23
+ "webhook",
24
+ "sdk"
25
+ ]);
11
26
 
12
27
  // src/connection/connection.schema.ts
13
28
  import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
@@ -28,7 +43,11 @@ var ConnectionModel = defineSchemaModel({
28
43
  },
29
44
  connectedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
30
45
  lastHealthCheck: { type: ScalarTypeEnum.DateTime(), isOptional: true },
31
- healthStatus: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
46
+ healthStatus: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
47
+ transport: { type: TransportTypeEnum, isOptional: true },
48
+ authMethod: { type: AuthTypeEnum, isOptional: true },
49
+ apiVersion: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
50
+ ownershipMode: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
32
51
  }
33
52
  });
34
53
  var CreateConnectionInputModel = defineSchemaModel({
@@ -40,7 +59,11 @@ var CreateConnectionInputModel = defineSchemaModel({
40
59
  },
41
60
  name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
42
61
  authType: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
43
- credentials: { type: ScalarTypeEnum.JSON(), isOptional: true }
62
+ credentials: { type: ScalarTypeEnum.JSON(), isOptional: true },
63
+ transport: { type: TransportTypeEnum, isOptional: true },
64
+ authMethod: { type: AuthTypeEnum, isOptional: true },
65
+ apiVersion: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
66
+ ownershipMode: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
44
67
  }
45
68
  });
46
69
 
@@ -8,6 +8,21 @@ var ConnectionStatusEnum = defineEnum("ConnectionStatus", [
8
8
  "ERROR",
9
9
  "EXPIRED"
10
10
  ]);
11
+ var AuthTypeEnum = defineEnum("AuthType", [
12
+ "api_key",
13
+ "oauth2",
14
+ "bearer",
15
+ "header",
16
+ "basic",
17
+ "webhook_signing",
18
+ "service_account"
19
+ ]);
20
+ var TransportTypeEnum = defineEnum("TransportType", [
21
+ "rest",
22
+ "mcp",
23
+ "webhook",
24
+ "sdk"
25
+ ]);
11
26
 
12
27
  // src/connection/connection.schema.ts
13
28
  import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
@@ -28,7 +43,11 @@ var ConnectionModel = defineSchemaModel({
28
43
  },
29
44
  connectedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
30
45
  lastHealthCheck: { type: ScalarTypeEnum.DateTime(), isOptional: true },
31
- healthStatus: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
46
+ healthStatus: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
47
+ transport: { type: TransportTypeEnum, isOptional: true },
48
+ authMethod: { type: AuthTypeEnum, isOptional: true },
49
+ apiVersion: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
50
+ ownershipMode: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
32
51
  }
33
52
  });
34
53
  var CreateConnectionInputModel = defineSchemaModel({
@@ -40,7 +59,11 @@ var CreateConnectionInputModel = defineSchemaModel({
40
59
  },
41
60
  name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
42
61
  authType: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
43
- credentials: { type: ScalarTypeEnum.JSON(), isOptional: true }
62
+ credentials: { type: ScalarTypeEnum.JSON(), isOptional: true },
63
+ transport: { type: TransportTypeEnum, isOptional: true },
64
+ authMethod: { type: AuthTypeEnum, isOptional: true },
65
+ apiVersion: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
66
+ ownershipMode: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
44
67
  }
45
68
  });
46
69
 
@@ -38,6 +38,22 @@ export declare const ConnectionModel: import("@contractspec/lib.schema").SchemaM
38
38
  type: import("@contractspec/lib.schema").FieldType<string, string>;
39
39
  isOptional: true;
40
40
  };
41
+ transport: {
42
+ type: import("@contractspec/lib.schema").EnumType<[string, string, string, string]>;
43
+ isOptional: true;
44
+ };
45
+ authMethod: {
46
+ type: import("@contractspec/lib.schema").EnumType<[string, string, string, string, string, string, string]>;
47
+ isOptional: true;
48
+ };
49
+ apiVersion: {
50
+ type: import("@contractspec/lib.schema").FieldType<string, string>;
51
+ isOptional: true;
52
+ };
53
+ ownershipMode: {
54
+ type: import("@contractspec/lib.schema").FieldType<string, string>;
55
+ isOptional: true;
56
+ };
41
57
  }>;
42
58
  /**
43
59
  * Input for creating a connection.
@@ -59,4 +75,20 @@ export declare const CreateConnectionInputModel: import("@contractspec/lib.schem
59
75
  type: import("@contractspec/lib.schema").FieldType<unknown, unknown>;
60
76
  isOptional: true;
61
77
  };
78
+ transport: {
79
+ type: import("@contractspec/lib.schema").EnumType<[string, string, string, string]>;
80
+ isOptional: true;
81
+ };
82
+ authMethod: {
83
+ type: import("@contractspec/lib.schema").EnumType<[string, string, string, string, string, string, string]>;
84
+ isOptional: true;
85
+ };
86
+ apiVersion: {
87
+ type: import("@contractspec/lib.schema").FieldType<string, string>;
88
+ isOptional: true;
89
+ };
90
+ ownershipMode: {
91
+ type: import("@contractspec/lib.schema").FieldType<string, string>;
92
+ isOptional: true;
93
+ };
62
94
  }>;
@@ -8,6 +8,21 @@ var ConnectionStatusEnum = defineEnum("ConnectionStatus", [
8
8
  "ERROR",
9
9
  "EXPIRED"
10
10
  ]);
11
+ var AuthTypeEnum = defineEnum("AuthType", [
12
+ "api_key",
13
+ "oauth2",
14
+ "bearer",
15
+ "header",
16
+ "basic",
17
+ "webhook_signing",
18
+ "service_account"
19
+ ]);
20
+ var TransportTypeEnum = defineEnum("TransportType", [
21
+ "rest",
22
+ "mcp",
23
+ "webhook",
24
+ "sdk"
25
+ ]);
11
26
 
12
27
  // src/connection/connection.schema.ts
13
28
  import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
@@ -28,7 +43,11 @@ var ConnectionModel = defineSchemaModel({
28
43
  },
29
44
  connectedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
30
45
  lastHealthCheck: { type: ScalarTypeEnum.DateTime(), isOptional: true },
31
- healthStatus: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
46
+ healthStatus: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
47
+ transport: { type: TransportTypeEnum, isOptional: true },
48
+ authMethod: { type: AuthTypeEnum, isOptional: true },
49
+ apiVersion: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
50
+ ownershipMode: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
32
51
  }
33
52
  });
34
53
  var CreateConnectionInputModel = defineSchemaModel({
@@ -40,7 +59,11 @@ var CreateConnectionInputModel = defineSchemaModel({
40
59
  },
41
60
  name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
42
61
  authType: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
43
- credentials: { type: ScalarTypeEnum.JSON(), isOptional: true }
62
+ credentials: { type: ScalarTypeEnum.JSON(), isOptional: true },
63
+ transport: { type: TransportTypeEnum, isOptional: true },
64
+ authMethod: { type: AuthTypeEnum, isOptional: true },
65
+ apiVersion: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
66
+ ownershipMode: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
44
67
  }
45
68
  });
46
69
  export {
@@ -8,6 +8,21 @@ var ConnectionStatusEnum = defineEnum("ConnectionStatus", [
8
8
  "ERROR",
9
9
  "EXPIRED"
10
10
  ]);
11
+ var AuthTypeEnum = defineEnum("AuthType", [
12
+ "api_key",
13
+ "oauth2",
14
+ "bearer",
15
+ "header",
16
+ "basic",
17
+ "webhook_signing",
18
+ "service_account"
19
+ ]);
20
+ var TransportTypeEnum = defineEnum("TransportType", [
21
+ "rest",
22
+ "mcp",
23
+ "webhook",
24
+ "sdk"
25
+ ]);
11
26
 
12
27
  // src/connection/connection.schema.ts
13
28
  import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
@@ -28,7 +43,11 @@ var ConnectionModel = defineSchemaModel({
28
43
  },
29
44
  connectedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
30
45
  lastHealthCheck: { type: ScalarTypeEnum.DateTime(), isOptional: true },
31
- healthStatus: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
46
+ healthStatus: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
47
+ transport: { type: TransportTypeEnum, isOptional: true },
48
+ authMethod: { type: AuthTypeEnum, isOptional: true },
49
+ apiVersion: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
50
+ ownershipMode: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
32
51
  }
33
52
  });
34
53
  var CreateConnectionInputModel = defineSchemaModel({
@@ -40,7 +59,11 @@ var CreateConnectionInputModel = defineSchemaModel({
40
59
  },
41
60
  name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
42
61
  authType: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
43
- credentials: { type: ScalarTypeEnum.JSON(), isOptional: true }
62
+ credentials: { type: ScalarTypeEnum.JSON(), isOptional: true },
63
+ transport: { type: TransportTypeEnum, isOptional: true },
64
+ authMethod: { type: AuthTypeEnum, isOptional: true },
65
+ apiVersion: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
66
+ ownershipMode: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
44
67
  }
45
68
  });
46
69
 
@@ -229,6 +229,49 @@ function createIntegrationHandlers(db) {
229
229
  ])).rows;
230
230
  return rowToSyncConfig(rows[0]);
231
231
  }
232
+ async function validateByokKey(input) {
233
+ const rows = (await db.query(`SELECT * FROM integration_connection WHERE id = ?`, [
234
+ input.connectionId
235
+ ])).rows;
236
+ if (!rows[0]) {
237
+ return {
238
+ valid: false,
239
+ provider: "unknown",
240
+ keyPrefix: "",
241
+ error: `Connection ${input.connectionId} not found`
242
+ };
243
+ }
244
+ const keyPrefix = input.providerKey.slice(0, 8);
245
+ const looksValid = input.providerKey.length >= 16;
246
+ return {
247
+ valid: looksValid,
248
+ provider: rows[0].name,
249
+ keyPrefix: `${keyPrefix}...`,
250
+ expiresAt: looksValid ? new Date(Date.now() + 90 * 24 * 60 * 60 * 1000).toISOString() : undefined,
251
+ error: looksValid ? undefined : "Key must be at least 16 characters"
252
+ };
253
+ }
254
+ async function refreshOAuth2Token(input) {
255
+ const now = new Date().toISOString();
256
+ await db.execute(`UPDATE integration_connection SET updatedAt = ? WHERE id = ?`, [now, input.connectionId]);
257
+ return {
258
+ refreshed: true,
259
+ expiresAt: new Date(Date.now() + 3600 * 1000).toISOString(),
260
+ tokenType: "Bearer",
261
+ scopes: ["read", "write", "sync"]
262
+ };
263
+ }
264
+ async function getTransportOptions(input) {
265
+ return {
266
+ integrationId: input.integrationId,
267
+ transports: [
268
+ { transport: "rest", supported: true, defaultVersion: "v2" },
269
+ { transport: "mcp", supported: true, defaultVersion: "v1" },
270
+ { transport: "webhook", supported: true },
271
+ { transport: "sdk", supported: false }
272
+ ]
273
+ };
274
+ }
232
275
  return {
233
276
  listIntegrations,
234
277
  createIntegration,
@@ -239,7 +282,10 @@ function createIntegrationHandlers(db) {
239
282
  configureSync,
240
283
  mapFields,
241
284
  getFieldMappings,
242
- runSync
285
+ runSync,
286
+ validateByokKey,
287
+ refreshOAuth2Token,
288
+ getTransportOptions
243
289
  };
244
290
  }
245
291
  export {
@@ -111,6 +111,38 @@ export interface ListSyncConfigsOutput {
111
111
  configs: SyncConfig[];
112
112
  total: number;
113
113
  }
114
+ export interface ValidateByokKeyInput {
115
+ connectionId: string;
116
+ providerKey: string;
117
+ }
118
+ export interface ValidateByokKeyOutput {
119
+ valid: boolean;
120
+ provider: string;
121
+ keyPrefix: string;
122
+ expiresAt?: string;
123
+ error?: string;
124
+ }
125
+ export interface RefreshOAuth2TokenInput {
126
+ connectionId: string;
127
+ }
128
+ export interface RefreshOAuth2TokenOutput {
129
+ refreshed: boolean;
130
+ expiresAt: string;
131
+ tokenType: string;
132
+ scopes: string[];
133
+ }
134
+ export interface TransportOption {
135
+ transport: 'rest' | 'mcp' | 'webhook' | 'sdk';
136
+ supported: boolean;
137
+ defaultVersion?: string;
138
+ }
139
+ export interface GetTransportOptionsInput {
140
+ integrationId: string;
141
+ }
142
+ export interface GetTransportOptionsOutput {
143
+ integrationId: string;
144
+ transports: TransportOption[];
145
+ }
114
146
  export declare function createIntegrationHandlers(db: DatabasePort): {
115
147
  listIntegrations: (input: ListIntegrationsInput) => Promise<ListIntegrationsOutput>;
116
148
  createIntegration: (input: CreateIntegrationInput, context: {
@@ -125,5 +157,8 @@ export declare function createIntegrationHandlers(db: DatabasePort): {
125
157
  mapFields: (input: MapFieldsInput) => Promise<FieldMapping[]>;
126
158
  getFieldMappings: (syncConfigId: string) => Promise<FieldMapping[]>;
127
159
  runSync: (syncConfigId: string) => Promise<SyncConfig>;
160
+ validateByokKey: (input: ValidateByokKeyInput) => Promise<ValidateByokKeyOutput>;
161
+ refreshOAuth2Token: (input: RefreshOAuth2TokenInput) => Promise<RefreshOAuth2TokenOutput>;
162
+ getTransportOptions: (input: GetTransportOptionsInput) => Promise<GetTransportOptionsOutput>;
128
163
  };
129
164
  export type IntegrationHandlers = ReturnType<typeof createIntegrationHandlers>;
@@ -229,6 +229,49 @@ function createIntegrationHandlers(db) {
229
229
  ])).rows;
230
230
  return rowToSyncConfig(rows[0]);
231
231
  }
232
+ async function validateByokKey(input) {
233
+ const rows = (await db.query(`SELECT * FROM integration_connection WHERE id = ?`, [
234
+ input.connectionId
235
+ ])).rows;
236
+ if (!rows[0]) {
237
+ return {
238
+ valid: false,
239
+ provider: "unknown",
240
+ keyPrefix: "",
241
+ error: `Connection ${input.connectionId} not found`
242
+ };
243
+ }
244
+ const keyPrefix = input.providerKey.slice(0, 8);
245
+ const looksValid = input.providerKey.length >= 16;
246
+ return {
247
+ valid: looksValid,
248
+ provider: rows[0].name,
249
+ keyPrefix: `${keyPrefix}...`,
250
+ expiresAt: looksValid ? new Date(Date.now() + 90 * 24 * 60 * 60 * 1000).toISOString() : undefined,
251
+ error: looksValid ? undefined : "Key must be at least 16 characters"
252
+ };
253
+ }
254
+ async function refreshOAuth2Token(input) {
255
+ const now = new Date().toISOString();
256
+ await db.execute(`UPDATE integration_connection SET updatedAt = ? WHERE id = ?`, [now, input.connectionId]);
257
+ return {
258
+ refreshed: true,
259
+ expiresAt: new Date(Date.now() + 3600 * 1000).toISOString(),
260
+ tokenType: "Bearer",
261
+ scopes: ["read", "write", "sync"]
262
+ };
263
+ }
264
+ async function getTransportOptions(input) {
265
+ return {
266
+ integrationId: input.integrationId,
267
+ transports: [
268
+ { transport: "rest", supported: true, defaultVersion: "v2" },
269
+ { transport: "mcp", supported: true, defaultVersion: "v1" },
270
+ { transport: "webhook", supported: true },
271
+ { transport: "sdk", supported: false }
272
+ ]
273
+ };
274
+ }
232
275
  return {
233
276
  listIntegrations,
234
277
  createIntegration,
@@ -239,7 +282,10 @@ function createIntegrationHandlers(db) {
239
282
  configureSync,
240
283
  mapFields,
241
284
  getFieldMappings,
242
- runSync
285
+ runSync,
286
+ validateByokKey,
287
+ refreshOAuth2Token,
288
+ getTransportOptions
243
289
  };
244
290
  }
245
291
  export {
package/dist/index.js CHANGED
@@ -8,6 +8,21 @@ var ConnectionStatusEnum = defineEnum("ConnectionStatus", [
8
8
  "ERROR",
9
9
  "EXPIRED"
10
10
  ]);
11
+ var AuthTypeEnum = defineEnum("AuthType", [
12
+ "api_key",
13
+ "oauth2",
14
+ "bearer",
15
+ "header",
16
+ "basic",
17
+ "webhook_signing",
18
+ "service_account"
19
+ ]);
20
+ var TransportTypeEnum = defineEnum("TransportType", [
21
+ "rest",
22
+ "mcp",
23
+ "webhook",
24
+ "sdk"
25
+ ]);
11
26
 
12
27
  // src/connection/connection.schema.ts
13
28
  import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
@@ -28,7 +43,11 @@ var ConnectionModel = defineSchemaModel({
28
43
  },
29
44
  connectedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
30
45
  lastHealthCheck: { type: ScalarTypeEnum.DateTime(), isOptional: true },
31
- healthStatus: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
46
+ healthStatus: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
47
+ transport: { type: TransportTypeEnum, isOptional: true },
48
+ authMethod: { type: AuthTypeEnum, isOptional: true },
49
+ apiVersion: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
50
+ ownershipMode: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
32
51
  }
33
52
  });
34
53
  var CreateConnectionInputModel = defineSchemaModel({
@@ -40,7 +59,11 @@ var CreateConnectionInputModel = defineSchemaModel({
40
59
  },
41
60
  name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
42
61
  authType: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
43
- credentials: { type: ScalarTypeEnum.JSON(), isOptional: true }
62
+ credentials: { type: ScalarTypeEnum.JSON(), isOptional: true },
63
+ transport: { type: TransportTypeEnum, isOptional: true },
64
+ authMethod: { type: AuthTypeEnum, isOptional: true },
65
+ apiVersion: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
66
+ ownershipMode: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
44
67
  }
45
68
  });
46
69
 
@@ -327,6 +350,49 @@ function createIntegrationHandlers(db) {
327
350
  ])).rows;
328
351
  return rowToSyncConfig(rows[0]);
329
352
  }
353
+ async function validateByokKey(input) {
354
+ const rows = (await db.query(`SELECT * FROM integration_connection WHERE id = ?`, [
355
+ input.connectionId
356
+ ])).rows;
357
+ if (!rows[0]) {
358
+ return {
359
+ valid: false,
360
+ provider: "unknown",
361
+ keyPrefix: "",
362
+ error: `Connection ${input.connectionId} not found`
363
+ };
364
+ }
365
+ const keyPrefix = input.providerKey.slice(0, 8);
366
+ const looksValid = input.providerKey.length >= 16;
367
+ return {
368
+ valid: looksValid,
369
+ provider: rows[0].name,
370
+ keyPrefix: `${keyPrefix}...`,
371
+ expiresAt: looksValid ? new Date(Date.now() + 90 * 24 * 60 * 60 * 1000).toISOString() : undefined,
372
+ error: looksValid ? undefined : "Key must be at least 16 characters"
373
+ };
374
+ }
375
+ async function refreshOAuth2Token(input) {
376
+ const now = new Date().toISOString();
377
+ await db.execute(`UPDATE integration_connection SET updatedAt = ? WHERE id = ?`, [now, input.connectionId]);
378
+ return {
379
+ refreshed: true,
380
+ expiresAt: new Date(Date.now() + 3600 * 1000).toISOString(),
381
+ tokenType: "Bearer",
382
+ scopes: ["read", "write", "sync"]
383
+ };
384
+ }
385
+ async function getTransportOptions(input) {
386
+ return {
387
+ integrationId: input.integrationId,
388
+ transports: [
389
+ { transport: "rest", supported: true, defaultVersion: "v2" },
390
+ { transport: "mcp", supported: true, defaultVersion: "v1" },
391
+ { transport: "webhook", supported: true },
392
+ { transport: "sdk", supported: false }
393
+ ]
394
+ };
395
+ }
330
396
  return {
331
397
  listIntegrations,
332
398
  createIntegration,
@@ -337,7 +403,10 @@ function createIntegrationHandlers(db) {
337
403
  configureSync,
338
404
  mapFields,
339
405
  getFieldMappings,
340
- runSync
406
+ runSync,
407
+ validateByokKey,
408
+ refreshOAuth2Token,
409
+ getTransportOptions
341
410
  };
342
411
  }
343
412
 
@@ -1571,6 +1640,7 @@ var DEFAULT_STDIO_ARGS = [
1571
1640
  ];
1572
1641
  async function runIntegrationHubMcpExampleFromEnv() {
1573
1642
  const mode = resolveMode();
1643
+ const transport = resolveTransport();
1574
1644
  const config = buildMcpConfigFromEnv();
1575
1645
  const toolset = await createMcpToolsets([config], {
1576
1646
  onNameCollision: "error"
@@ -1581,8 +1651,10 @@ async function runIntegrationHubMcpExampleFromEnv() {
1581
1651
  mode,
1582
1652
  server: {
1583
1653
  name: config.name,
1584
- transport: config.transport ?? "stdio"
1654
+ transport
1585
1655
  },
1656
+ authMethod: process.env.CONTRACTSPEC_INTEGRATION_HUB_MCP_AUTH_METHOD,
1657
+ apiVersion: process.env.CONTRACTSPEC_INTEGRATION_HUB_MCP_API_VERSION,
1586
1658
  tools: toolNames
1587
1659
  };
1588
1660
  if (mode === "call") {
@@ -1624,9 +1696,10 @@ function buildMcpConfigFromEnv() {
1624
1696
  }
1625
1697
  const accessToken = process.env.CONTRACTSPEC_INTEGRATION_HUB_MCP_ACCESS_TOKEN;
1626
1698
  const accessTokenEnvVar = process.env.CONTRACTSPEC_INTEGRATION_HUB_MCP_ACCESS_TOKEN_ENV;
1699
+ const mcpTransport = transport === "webhook" || transport === "http" ? "http" : "sse";
1627
1700
  return {
1628
1701
  name,
1629
- transport,
1702
+ transport: mcpTransport,
1630
1703
  url: requireEnv("CONTRACTSPEC_INTEGRATION_HUB_MCP_URL"),
1631
1704
  headers: parseStringRecordEnv("CONTRACTSPEC_INTEGRATION_HUB_MCP_HEADERS_JSON"),
1632
1705
  accessToken,
@@ -1643,10 +1716,10 @@ function resolveMode() {
1643
1716
  }
1644
1717
  function resolveTransport() {
1645
1718
  const rawTransport = process.env.CONTRACTSPEC_INTEGRATION_HUB_MCP_TRANSPORT?.toLowerCase() ?? "stdio";
1646
- if (rawTransport === "stdio" || rawTransport === "http" || rawTransport === "sse") {
1719
+ if (rawTransport === "stdio" || rawTransport === "http" || rawTransport === "sse" || rawTransport === "webhook") {
1647
1720
  return rawTransport;
1648
1721
  }
1649
- throw new Error(`Unsupported CONTRACTSPEC_INTEGRATION_HUB_MCP_TRANSPORT: ${rawTransport}. Use "stdio", "http", or "sse".`);
1722
+ throw new Error(`Unsupported CONTRACTSPEC_INTEGRATION_HUB_MCP_TRANSPORT: ${rawTransport}. Use "stdio", "http", "sse", or "webhook".`);
1650
1723
  }
1651
1724
  function parseStringArrayEnv(key, fallback) {
1652
1725
  const raw = process.env[key];
@@ -3,8 +3,10 @@ interface IntegrationHubMcpOutput {
3
3
  mode: IntegrationHubMcpMode;
4
4
  server: {
5
5
  name: string;
6
- transport: 'stdio' | 'http' | 'sse';
6
+ transport: 'stdio' | 'http' | 'sse' | 'webhook';
7
7
  };
8
+ authMethod?: string;
9
+ apiVersion?: string;
8
10
  tools: string[];
9
11
  toolCall?: {
10
12
  name: string;