@contractspec/integration.runtime 2.10.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.
Files changed (75) hide show
  1. package/dist/channel/dispatcher.d.ts +37 -0
  2. package/dist/channel/dispatcher.js +130 -0
  3. package/dist/channel/dispatcher.test.d.ts +1 -0
  4. package/dist/channel/github.d.ts +47 -0
  5. package/dist/channel/github.js +58 -0
  6. package/dist/channel/github.test.d.ts +1 -0
  7. package/dist/channel/index.d.ts +14 -0
  8. package/dist/channel/index.js +1463 -0
  9. package/dist/channel/memory-store.d.ts +28 -0
  10. package/dist/channel/memory-store.js +223 -0
  11. package/dist/channel/policy.d.ts +23 -0
  12. package/dist/channel/policy.js +119 -0
  13. package/dist/channel/policy.test.d.ts +1 -0
  14. package/dist/channel/postgres-queries.d.ts +11 -0
  15. package/dist/channel/postgres-queries.js +222 -0
  16. package/dist/channel/postgres-schema.d.ts +1 -0
  17. package/dist/channel/postgres-schema.js +94 -0
  18. package/dist/channel/postgres-store.d.ts +21 -0
  19. package/dist/channel/postgres-store.js +498 -0
  20. package/dist/channel/postgres-store.test.d.ts +1 -0
  21. package/dist/channel/replay-fixtures.d.ts +9 -0
  22. package/dist/channel/replay-fixtures.js +42 -0
  23. package/dist/channel/replay.test.d.ts +1 -0
  24. package/dist/channel/service.d.ts +26 -0
  25. package/dist/channel/service.js +319 -0
  26. package/dist/channel/service.test.d.ts +1 -0
  27. package/dist/channel/slack.d.ts +42 -0
  28. package/dist/channel/slack.js +82 -0
  29. package/dist/channel/slack.test.d.ts +1 -0
  30. package/dist/channel/store.d.ts +83 -0
  31. package/dist/channel/store.js +1 -0
  32. package/dist/channel/telemetry.d.ts +17 -0
  33. package/dist/channel/telemetry.js +1 -0
  34. package/dist/channel/types.d.ts +115 -0
  35. package/dist/channel/types.js +1 -0
  36. package/dist/channel/whatsapp-meta.d.ts +55 -0
  37. package/dist/channel/whatsapp-meta.js +66 -0
  38. package/dist/channel/whatsapp-meta.test.d.ts +1 -0
  39. package/dist/channel/whatsapp-twilio.d.ts +20 -0
  40. package/dist/channel/whatsapp-twilio.js +61 -0
  41. package/dist/channel/whatsapp-twilio.test.d.ts +1 -0
  42. package/dist/index.d.ts +2 -0
  43. package/dist/index.js +1621 -1
  44. package/dist/node/channel/dispatcher.js +129 -0
  45. package/dist/node/channel/github.js +57 -0
  46. package/dist/node/channel/index.js +1462 -0
  47. package/dist/node/channel/memory-store.js +222 -0
  48. package/dist/node/channel/policy.js +118 -0
  49. package/dist/node/channel/postgres-queries.js +221 -0
  50. package/dist/node/channel/postgres-schema.js +93 -0
  51. package/dist/node/channel/postgres-store.js +497 -0
  52. package/dist/node/channel/replay-fixtures.js +41 -0
  53. package/dist/node/channel/service.js +318 -0
  54. package/dist/node/channel/slack.js +81 -0
  55. package/dist/node/channel/store.js +0 -0
  56. package/dist/node/channel/telemetry.js +0 -0
  57. package/dist/node/channel/types.js +0 -0
  58. package/dist/node/channel/whatsapp-meta.js +65 -0
  59. package/dist/node/channel/whatsapp-twilio.js +60 -0
  60. package/dist/node/index.js +1621 -1
  61. package/dist/node/transport/auth-resolver.js +51 -0
  62. package/dist/node/transport/index.js +162 -0
  63. package/dist/node/transport/transport-factory.js +77 -0
  64. package/dist/node/transport/version-negotiator.js +36 -0
  65. package/dist/runtime.d.ts +16 -0
  66. package/dist/runtime.health.test.d.ts +1 -0
  67. package/dist/transport/auth-resolver.d.ts +20 -0
  68. package/dist/transport/auth-resolver.js +52 -0
  69. package/dist/transport/index.d.ts +3 -0
  70. package/dist/transport/index.js +163 -0
  71. package/dist/transport/transport-factory.d.ts +31 -0
  72. package/dist/transport/transport-factory.js +78 -0
  73. package/dist/transport/version-negotiator.d.ts +14 -0
  74. package/dist/transport/version-negotiator.js +37 -0
  75. package/package.json +273 -6
@@ -0,0 +1,78 @@
1
+ // @bun
2
+ // src/transport/transport-factory.ts
3
+ import { findTransportConfig } from "@contractspec/lib.contracts-integrations/integrations/transport";
4
+
5
+ class RestTransportClient {
6
+ config;
7
+ authHeaders;
8
+ fetchFn;
9
+ type = "rest";
10
+ constructor(config, authHeaders = {}, fetchFn = globalThis.fetch) {
11
+ this.config = config;
12
+ this.authHeaders = authHeaders;
13
+ this.fetchFn = fetchFn;
14
+ }
15
+ async request(method, path, options) {
16
+ const url = new URL(path, this.config.baseUrl ?? "https://localhost");
17
+ if (options?.queryParams) {
18
+ for (const [key, value] of Object.entries(options.queryParams)) {
19
+ url.searchParams.set(key, value);
20
+ }
21
+ }
22
+ const headers = {
23
+ ...this.config.defaultHeaders,
24
+ ...this.authHeaders,
25
+ ...options?.headers
26
+ };
27
+ if (options?.body && !headers["Content-Type"]) {
28
+ headers["Content-Type"] = "application/json";
29
+ }
30
+ const response = await this.fetchFn(url.toString(), {
31
+ method,
32
+ headers,
33
+ body: options?.body ? JSON.stringify(options.body) : undefined,
34
+ signal: options?.signal
35
+ });
36
+ const responseHeaders = {};
37
+ response.headers.forEach((value, key) => {
38
+ responseHeaders[key] = value;
39
+ });
40
+ const data = await response.json().catch(() => null);
41
+ let rateLimitRemaining;
42
+ let rateLimitReset;
43
+ if (this.config.rateLimitHeaders) {
44
+ const remaining = responseHeaders[this.config.rateLimitHeaders.remaining];
45
+ const reset = responseHeaders[this.config.rateLimitHeaders.reset];
46
+ if (remaining)
47
+ rateLimitRemaining = Number(remaining);
48
+ if (reset)
49
+ rateLimitReset = Number(reset);
50
+ }
51
+ return {
52
+ data,
53
+ status: response.status,
54
+ headers: responseHeaders,
55
+ rateLimitRemaining,
56
+ rateLimitReset
57
+ };
58
+ }
59
+ }
60
+ function createTransportClient(transports, targetType, authHeaders = {}, fetchFn) {
61
+ const config = findTransportConfig(transports, targetType);
62
+ if (!config)
63
+ return;
64
+ switch (config.type) {
65
+ case "rest":
66
+ return new RestTransportClient(config, authHeaders, fetchFn);
67
+ case "mcp":
68
+ case "webhook":
69
+ case "sdk":
70
+ return;
71
+ default:
72
+ return;
73
+ }
74
+ }
75
+ export {
76
+ createTransportClient,
77
+ RestTransportClient
78
+ };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Negotiates and applies API versioning for integration requests.
3
+ */
4
+ import type { IntegrationVersionPolicy } from '@contractspec/lib.contracts-integrations/integrations/versioning';
5
+ export interface VersionNegotiationResult {
6
+ resolvedVersion: string | undefined;
7
+ deprecated: boolean;
8
+ versionHeaders: Record<string, string>;
9
+ versionQueryParams: Record<string, string>;
10
+ }
11
+ /**
12
+ * Negotiate the API version and produce headers/params to include in requests.
13
+ */
14
+ export declare function negotiateVersion(policy: IntegrationVersionPolicy | undefined, connectionOverride?: string): VersionNegotiationResult;
@@ -0,0 +1,37 @@
1
+ // @bun
2
+ // src/transport/version-negotiator.ts
3
+ import {
4
+ resolveApiVersion,
5
+ isVersionDeprecated
6
+ } from "@contractspec/lib.contracts-integrations/integrations/versioning";
7
+ function negotiateVersion(policy, connectionOverride) {
8
+ if (!policy) {
9
+ return {
10
+ resolvedVersion: undefined,
11
+ deprecated: false,
12
+ versionHeaders: {},
13
+ versionQueryParams: {}
14
+ };
15
+ }
16
+ const version = resolveApiVersion(policy, connectionOverride);
17
+ const deprecated = version ? isVersionDeprecated(policy, version) : false;
18
+ const versionHeaders = {};
19
+ const versionQueryParams = {};
20
+ if (version) {
21
+ if (policy.versionHeader) {
22
+ versionHeaders[policy.versionHeader] = version;
23
+ }
24
+ if (policy.versionQueryParam) {
25
+ versionQueryParams[policy.versionQueryParam] = version;
26
+ }
27
+ }
28
+ return {
29
+ resolvedVersion: version,
30
+ deprecated,
31
+ versionHeaders,
32
+ versionQueryParams
33
+ };
34
+ }
35
+ export {
36
+ negotiateVersion
37
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contractspec/integration.runtime",
3
- "version": "2.10.0",
3
+ "version": "3.1.1",
4
4
  "description": "Runtime integration with secret management",
5
5
  "keywords": [
6
6
  "contractspec",
@@ -31,16 +31,19 @@
31
31
  "typecheck": "tsc --noEmit"
32
32
  },
33
33
  "dependencies": {
34
- "@contractspec/lib.contracts-spec": "2.10.0",
35
- "@contractspec/lib.contracts-integrations": "2.10.0",
36
- "@contractspec/lib.logger": "2.9.0",
34
+ "@contractspec/lib.contracts-spec": "3.1.1",
35
+ "@contractspec/lib.contracts-integrations": "3.1.1",
36
+ "@contractspec/lib.logger": "3.1.0",
37
37
  "@google-cloud/secret-manager": "^6.1.1",
38
38
  "google-gax": "^5.0.0"
39
39
  },
40
+ "optionalDependencies": {
41
+ "pg": "^8.20.0"
42
+ },
40
43
  "devDependencies": {
41
- "@contractspec/tool.typescript": "2.9.0",
44
+ "@contractspec/tool.typescript": "3.1.0",
42
45
  "typescript": "^5.9.3",
43
- "@contractspec/tool.bun": "2.9.0"
46
+ "@contractspec/tool.bun": "3.1.0"
44
47
  },
45
48
  "exports": {
46
49
  ".": {
@@ -49,6 +52,108 @@
49
52
  "node": "./dist/node/index.js",
50
53
  "default": "./dist/index.js"
51
54
  },
55
+ "./channel": {
56
+ "types": "./dist/channel/index.d.ts",
57
+ "bun": "./dist/channel/index.js",
58
+ "node": "./dist/node/channel/index.js",
59
+ "default": "./dist/channel/index.js"
60
+ },
61
+ "./channel/dispatcher": {
62
+ "types": "./dist/channel/dispatcher.d.ts",
63
+ "bun": "./dist/channel/dispatcher.js",
64
+ "node": "./dist/node/channel/dispatcher.js",
65
+ "default": "./dist/channel/dispatcher.js"
66
+ },
67
+ "./channel/github": {
68
+ "types": "./dist/channel/github.d.ts",
69
+ "bun": "./dist/channel/github.js",
70
+ "node": "./dist/node/channel/github.js",
71
+ "default": "./dist/channel/github.js"
72
+ },
73
+ "./channel/index": {
74
+ "types": "./dist/channel/index.d.ts",
75
+ "bun": "./dist/channel/index.js",
76
+ "node": "./dist/node/channel/index.js",
77
+ "default": "./dist/channel/index.js"
78
+ },
79
+ "./channel/memory-store": {
80
+ "types": "./dist/channel/memory-store.d.ts",
81
+ "bun": "./dist/channel/memory-store.js",
82
+ "node": "./dist/node/channel/memory-store.js",
83
+ "default": "./dist/channel/memory-store.js"
84
+ },
85
+ "./channel/policy": {
86
+ "types": "./dist/channel/policy.d.ts",
87
+ "bun": "./dist/channel/policy.js",
88
+ "node": "./dist/node/channel/policy.js",
89
+ "default": "./dist/channel/policy.js"
90
+ },
91
+ "./channel/postgres-queries": {
92
+ "types": "./dist/channel/postgres-queries.d.ts",
93
+ "bun": "./dist/channel/postgres-queries.js",
94
+ "node": "./dist/node/channel/postgres-queries.js",
95
+ "default": "./dist/channel/postgres-queries.js"
96
+ },
97
+ "./channel/postgres-schema": {
98
+ "types": "./dist/channel/postgres-schema.d.ts",
99
+ "bun": "./dist/channel/postgres-schema.js",
100
+ "node": "./dist/node/channel/postgres-schema.js",
101
+ "default": "./dist/channel/postgres-schema.js"
102
+ },
103
+ "./channel/postgres-store": {
104
+ "types": "./dist/channel/postgres-store.d.ts",
105
+ "bun": "./dist/channel/postgres-store.js",
106
+ "node": "./dist/node/channel/postgres-store.js",
107
+ "default": "./dist/channel/postgres-store.js"
108
+ },
109
+ "./channel/replay-fixtures": {
110
+ "types": "./dist/channel/replay-fixtures.d.ts",
111
+ "bun": "./dist/channel/replay-fixtures.js",
112
+ "node": "./dist/node/channel/replay-fixtures.js",
113
+ "default": "./dist/channel/replay-fixtures.js"
114
+ },
115
+ "./channel/service": {
116
+ "types": "./dist/channel/service.d.ts",
117
+ "bun": "./dist/channel/service.js",
118
+ "node": "./dist/node/channel/service.js",
119
+ "default": "./dist/channel/service.js"
120
+ },
121
+ "./channel/slack": {
122
+ "types": "./dist/channel/slack.d.ts",
123
+ "bun": "./dist/channel/slack.js",
124
+ "node": "./dist/node/channel/slack.js",
125
+ "default": "./dist/channel/slack.js"
126
+ },
127
+ "./channel/store": {
128
+ "types": "./dist/channel/store.d.ts",
129
+ "bun": "./dist/channel/store.js",
130
+ "node": "./dist/node/channel/store.js",
131
+ "default": "./dist/channel/store.js"
132
+ },
133
+ "./channel/telemetry": {
134
+ "types": "./dist/channel/telemetry.d.ts",
135
+ "bun": "./dist/channel/telemetry.js",
136
+ "node": "./dist/node/channel/telemetry.js",
137
+ "default": "./dist/channel/telemetry.js"
138
+ },
139
+ "./channel/types": {
140
+ "types": "./dist/channel/types.d.ts",
141
+ "bun": "./dist/channel/types.js",
142
+ "node": "./dist/node/channel/types.js",
143
+ "default": "./dist/channel/types.js"
144
+ },
145
+ "./channel/whatsapp-meta": {
146
+ "types": "./dist/channel/whatsapp-meta.d.ts",
147
+ "bun": "./dist/channel/whatsapp-meta.js",
148
+ "node": "./dist/node/channel/whatsapp-meta.js",
149
+ "default": "./dist/channel/whatsapp-meta.js"
150
+ },
151
+ "./channel/whatsapp-twilio": {
152
+ "types": "./dist/channel/whatsapp-twilio.d.ts",
153
+ "bun": "./dist/channel/whatsapp-twilio.js",
154
+ "node": "./dist/node/channel/whatsapp-twilio.js",
155
+ "default": "./dist/channel/whatsapp-twilio.js"
156
+ },
52
157
  "./health": {
53
158
  "types": "./dist/health.d.ts",
54
159
  "bun": "./dist/health.js",
@@ -96,6 +201,36 @@
96
201
  "bun": "./dist/secrets/provider.js",
97
202
  "node": "./dist/node/secrets/provider.js",
98
203
  "default": "./dist/secrets/provider.js"
204
+ },
205
+ "./transport": {
206
+ "types": "./dist/transport/index.d.ts",
207
+ "bun": "./dist/transport/index.js",
208
+ "node": "./dist/node/transport/index.js",
209
+ "default": "./dist/transport/index.js"
210
+ },
211
+ "./transport/auth-resolver": {
212
+ "types": "./dist/transport/auth-resolver.d.ts",
213
+ "bun": "./dist/transport/auth-resolver.js",
214
+ "node": "./dist/node/transport/auth-resolver.js",
215
+ "default": "./dist/transport/auth-resolver.js"
216
+ },
217
+ "./transport/index": {
218
+ "types": "./dist/transport/index.d.ts",
219
+ "bun": "./dist/transport/index.js",
220
+ "node": "./dist/node/transport/index.js",
221
+ "default": "./dist/transport/index.js"
222
+ },
223
+ "./transport/transport-factory": {
224
+ "types": "./dist/transport/transport-factory.d.ts",
225
+ "bun": "./dist/transport/transport-factory.js",
226
+ "node": "./dist/node/transport/transport-factory.js",
227
+ "default": "./dist/transport/transport-factory.js"
228
+ },
229
+ "./transport/version-negotiator": {
230
+ "types": "./dist/transport/version-negotiator.d.ts",
231
+ "bun": "./dist/transport/version-negotiator.js",
232
+ "node": "./dist/node/transport/version-negotiator.js",
233
+ "default": "./dist/transport/version-negotiator.js"
99
234
  }
100
235
  },
101
236
  "publishConfig": {
@@ -107,6 +242,108 @@
107
242
  "node": "./dist/node/index.js",
108
243
  "default": "./dist/index.js"
109
244
  },
245
+ "./channel": {
246
+ "types": "./dist/channel/index.d.ts",
247
+ "bun": "./dist/channel/index.js",
248
+ "node": "./dist/node/channel/index.js",
249
+ "default": "./dist/channel/index.js"
250
+ },
251
+ "./channel/dispatcher": {
252
+ "types": "./dist/channel/dispatcher.d.ts",
253
+ "bun": "./dist/channel/dispatcher.js",
254
+ "node": "./dist/node/channel/dispatcher.js",
255
+ "default": "./dist/channel/dispatcher.js"
256
+ },
257
+ "./channel/github": {
258
+ "types": "./dist/channel/github.d.ts",
259
+ "bun": "./dist/channel/github.js",
260
+ "node": "./dist/node/channel/github.js",
261
+ "default": "./dist/channel/github.js"
262
+ },
263
+ "./channel/index": {
264
+ "types": "./dist/channel/index.d.ts",
265
+ "bun": "./dist/channel/index.js",
266
+ "node": "./dist/node/channel/index.js",
267
+ "default": "./dist/channel/index.js"
268
+ },
269
+ "./channel/memory-store": {
270
+ "types": "./dist/channel/memory-store.d.ts",
271
+ "bun": "./dist/channel/memory-store.js",
272
+ "node": "./dist/node/channel/memory-store.js",
273
+ "default": "./dist/channel/memory-store.js"
274
+ },
275
+ "./channel/policy": {
276
+ "types": "./dist/channel/policy.d.ts",
277
+ "bun": "./dist/channel/policy.js",
278
+ "node": "./dist/node/channel/policy.js",
279
+ "default": "./dist/channel/policy.js"
280
+ },
281
+ "./channel/postgres-queries": {
282
+ "types": "./dist/channel/postgres-queries.d.ts",
283
+ "bun": "./dist/channel/postgres-queries.js",
284
+ "node": "./dist/node/channel/postgres-queries.js",
285
+ "default": "./dist/channel/postgres-queries.js"
286
+ },
287
+ "./channel/postgres-schema": {
288
+ "types": "./dist/channel/postgres-schema.d.ts",
289
+ "bun": "./dist/channel/postgres-schema.js",
290
+ "node": "./dist/node/channel/postgres-schema.js",
291
+ "default": "./dist/channel/postgres-schema.js"
292
+ },
293
+ "./channel/postgres-store": {
294
+ "types": "./dist/channel/postgres-store.d.ts",
295
+ "bun": "./dist/channel/postgres-store.js",
296
+ "node": "./dist/node/channel/postgres-store.js",
297
+ "default": "./dist/channel/postgres-store.js"
298
+ },
299
+ "./channel/replay-fixtures": {
300
+ "types": "./dist/channel/replay-fixtures.d.ts",
301
+ "bun": "./dist/channel/replay-fixtures.js",
302
+ "node": "./dist/node/channel/replay-fixtures.js",
303
+ "default": "./dist/channel/replay-fixtures.js"
304
+ },
305
+ "./channel/service": {
306
+ "types": "./dist/channel/service.d.ts",
307
+ "bun": "./dist/channel/service.js",
308
+ "node": "./dist/node/channel/service.js",
309
+ "default": "./dist/channel/service.js"
310
+ },
311
+ "./channel/slack": {
312
+ "types": "./dist/channel/slack.d.ts",
313
+ "bun": "./dist/channel/slack.js",
314
+ "node": "./dist/node/channel/slack.js",
315
+ "default": "./dist/channel/slack.js"
316
+ },
317
+ "./channel/store": {
318
+ "types": "./dist/channel/store.d.ts",
319
+ "bun": "./dist/channel/store.js",
320
+ "node": "./dist/node/channel/store.js",
321
+ "default": "./dist/channel/store.js"
322
+ },
323
+ "./channel/telemetry": {
324
+ "types": "./dist/channel/telemetry.d.ts",
325
+ "bun": "./dist/channel/telemetry.js",
326
+ "node": "./dist/node/channel/telemetry.js",
327
+ "default": "./dist/channel/telemetry.js"
328
+ },
329
+ "./channel/types": {
330
+ "types": "./dist/channel/types.d.ts",
331
+ "bun": "./dist/channel/types.js",
332
+ "node": "./dist/node/channel/types.js",
333
+ "default": "./dist/channel/types.js"
334
+ },
335
+ "./channel/whatsapp-meta": {
336
+ "types": "./dist/channel/whatsapp-meta.d.ts",
337
+ "bun": "./dist/channel/whatsapp-meta.js",
338
+ "node": "./dist/node/channel/whatsapp-meta.js",
339
+ "default": "./dist/channel/whatsapp-meta.js"
340
+ },
341
+ "./channel/whatsapp-twilio": {
342
+ "types": "./dist/channel/whatsapp-twilio.d.ts",
343
+ "bun": "./dist/channel/whatsapp-twilio.js",
344
+ "node": "./dist/node/channel/whatsapp-twilio.js",
345
+ "default": "./dist/channel/whatsapp-twilio.js"
346
+ },
110
347
  "./health": {
111
348
  "types": "./dist/health.d.ts",
112
349
  "bun": "./dist/health.js",
@@ -154,6 +391,36 @@
154
391
  "bun": "./dist/secrets/provider.js",
155
392
  "node": "./dist/node/secrets/provider.js",
156
393
  "default": "./dist/secrets/provider.js"
394
+ },
395
+ "./transport": {
396
+ "types": "./dist/transport/index.d.ts",
397
+ "bun": "./dist/transport/index.js",
398
+ "node": "./dist/node/transport/index.js",
399
+ "default": "./dist/transport/index.js"
400
+ },
401
+ "./transport/auth-resolver": {
402
+ "types": "./dist/transport/auth-resolver.d.ts",
403
+ "bun": "./dist/transport/auth-resolver.js",
404
+ "node": "./dist/node/transport/auth-resolver.js",
405
+ "default": "./dist/transport/auth-resolver.js"
406
+ },
407
+ "./transport/index": {
408
+ "types": "./dist/transport/index.d.ts",
409
+ "bun": "./dist/transport/index.js",
410
+ "node": "./dist/node/transport/index.js",
411
+ "default": "./dist/transport/index.js"
412
+ },
413
+ "./transport/transport-factory": {
414
+ "types": "./dist/transport/transport-factory.d.ts",
415
+ "bun": "./dist/transport/transport-factory.js",
416
+ "node": "./dist/node/transport/transport-factory.js",
417
+ "default": "./dist/transport/transport-factory.js"
418
+ },
419
+ "./transport/version-negotiator": {
420
+ "types": "./dist/transport/version-negotiator.d.ts",
421
+ "bun": "./dist/transport/version-negotiator.js",
422
+ "node": "./dist/node/transport/version-negotiator.js",
423
+ "default": "./dist/transport/version-negotiator.js"
157
424
  }
158
425
  },
159
426
  "registry": "https://registry.npmjs.org/"