@contractspec/integration.providers-impls 2.10.0 → 3.0.0
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 +7 -1
- package/dist/impls/async-event-queue.d.ts +8 -0
- package/dist/impls/async-event-queue.js +47 -0
- package/dist/impls/health/base-health-provider.d.ts +64 -13
- package/dist/impls/health/base-health-provider.js +506 -156
- package/dist/impls/health/hybrid-health-providers.d.ts +34 -0
- package/dist/impls/health/hybrid-health-providers.js +1088 -0
- package/dist/impls/health/official-health-providers.d.ts +78 -0
- package/dist/impls/health/official-health-providers.js +968 -0
- package/dist/impls/health/provider-normalizers.d.ts +28 -0
- package/dist/impls/health/provider-normalizers.js +287 -0
- package/dist/impls/health/providers.d.ts +2 -39
- package/dist/impls/health/providers.js +895 -184
- package/dist/impls/health-provider-factory.js +1009 -196
- package/dist/impls/index.d.ts +6 -0
- package/dist/impls/index.js +1950 -278
- package/dist/impls/messaging-github.d.ts +17 -0
- package/dist/impls/messaging-github.js +110 -0
- package/dist/impls/messaging-slack.d.ts +14 -0
- package/dist/impls/messaging-slack.js +80 -0
- package/dist/impls/messaging-whatsapp-meta.d.ts +13 -0
- package/dist/impls/messaging-whatsapp-meta.js +52 -0
- package/dist/impls/messaging-whatsapp-twilio.d.ts +13 -0
- package/dist/impls/messaging-whatsapp-twilio.js +82 -0
- package/dist/impls/mistral-conversational.d.ts +23 -0
- package/dist/impls/mistral-conversational.js +476 -0
- package/dist/impls/mistral-conversational.session.d.ts +32 -0
- package/dist/impls/mistral-conversational.session.js +206 -0
- package/dist/impls/mistral-stt.d.ts +17 -0
- package/dist/impls/mistral-stt.js +167 -0
- package/dist/impls/provider-factory.d.ts +5 -1
- package/dist/impls/provider-factory.js +1943 -277
- package/dist/impls/stripe-payments.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1953 -278
- package/dist/messaging.d.ts +1 -0
- package/dist/messaging.js +3 -0
- package/dist/node/impls/async-event-queue.js +46 -0
- package/dist/node/impls/health/base-health-provider.js +506 -156
- package/dist/node/impls/health/hybrid-health-providers.js +1087 -0
- package/dist/node/impls/health/official-health-providers.js +967 -0
- package/dist/node/impls/health/provider-normalizers.js +286 -0
- package/dist/node/impls/health/providers.js +895 -184
- package/dist/node/impls/health-provider-factory.js +1009 -196
- package/dist/node/impls/index.js +1950 -278
- package/dist/node/impls/messaging-github.js +109 -0
- package/dist/node/impls/messaging-slack.js +79 -0
- package/dist/node/impls/messaging-whatsapp-meta.js +51 -0
- package/dist/node/impls/messaging-whatsapp-twilio.js +81 -0
- package/dist/node/impls/mistral-conversational.js +475 -0
- package/dist/node/impls/mistral-conversational.session.js +205 -0
- package/dist/node/impls/mistral-stt.js +166 -0
- package/dist/node/impls/provider-factory.js +1943 -277
- package/dist/node/impls/stripe-payments.js +1 -1
- package/dist/node/index.js +1953 -278
- package/dist/node/messaging.js +2 -0
- package/package.json +156 -12
package/README.md
CHANGED
|
@@ -75,7 +75,8 @@ Connection config example:
|
|
|
75
75
|
"allowUnofficial": false,
|
|
76
76
|
"unofficialAllowList": ["health.peloton"],
|
|
77
77
|
"apiBaseUrl": "https://api.provider.example",
|
|
78
|
-
"mcpUrl": "https://mcp.provider.example"
|
|
78
|
+
"mcpUrl": "https://mcp.provider.example",
|
|
79
|
+
"oauthTokenUrl": "https://api.provider.example/oauth/token"
|
|
79
80
|
}
|
|
80
81
|
```
|
|
81
82
|
|
|
@@ -85,6 +86,10 @@ Secret payload example (`secretRef` target value):
|
|
|
85
86
|
{
|
|
86
87
|
"apiKey": "provider-api-key",
|
|
87
88
|
"accessToken": "oauth-access-token",
|
|
89
|
+
"refreshToken": "oauth-refresh-token",
|
|
90
|
+
"clientId": "oauth-client-id",
|
|
91
|
+
"clientSecret": "oauth-client-secret",
|
|
92
|
+
"tokenExpiresAt": "2026-02-01T00:00:00.000Z",
|
|
88
93
|
"mcpAccessToken": "mcp-access-token",
|
|
89
94
|
"webhookSecret": "webhook-signature-secret"
|
|
90
95
|
}
|
|
@@ -94,6 +99,7 @@ Notes:
|
|
|
94
99
|
|
|
95
100
|
- Unofficial routing is disabled unless `allowUnofficial: true`.
|
|
96
101
|
- When `unofficialAllowList` is provided, only listed `health.*` keys can use unofficial routing.
|
|
102
|
+
- Unofficial routing expects MCP transport (`mcpUrl`) plus either `mcpAccessToken` or automation credentials.
|
|
97
103
|
- If a selected strategy is unavailable, the resolver falls through `strategyOrder`.
|
|
98
104
|
|
|
99
105
|
## Supabase integrations
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/impls/async-event-queue.ts
|
|
3
|
+
class AsyncEventQueue {
|
|
4
|
+
values = [];
|
|
5
|
+
waiters = [];
|
|
6
|
+
done = false;
|
|
7
|
+
push(value) {
|
|
8
|
+
if (this.done) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const waiter = this.waiters.shift();
|
|
12
|
+
if (waiter) {
|
|
13
|
+
waiter({ value, done: false });
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
this.values.push(value);
|
|
17
|
+
}
|
|
18
|
+
close() {
|
|
19
|
+
if (this.done) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
this.done = true;
|
|
23
|
+
for (const waiter of this.waiters) {
|
|
24
|
+
waiter({ value: undefined, done: true });
|
|
25
|
+
}
|
|
26
|
+
this.waiters.length = 0;
|
|
27
|
+
}
|
|
28
|
+
[Symbol.asyncIterator]() {
|
|
29
|
+
return {
|
|
30
|
+
next: async () => {
|
|
31
|
+
const value = this.values.shift();
|
|
32
|
+
if (value != null) {
|
|
33
|
+
return { value, done: false };
|
|
34
|
+
}
|
|
35
|
+
if (this.done) {
|
|
36
|
+
return { value: undefined, done: true };
|
|
37
|
+
}
|
|
38
|
+
return new Promise((resolve) => {
|
|
39
|
+
this.waiters.push(resolve);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
AsyncEventQueue
|
|
47
|
+
};
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import type { HealthConnectionStatus, HealthDataSource, HealthListActivitiesParams, HealthListActivitiesResult, HealthListBiometricsParams, HealthListBiometricsResult, HealthListNutritionParams, HealthListNutritionResult, HealthListSleepParams, HealthListSleepResult, HealthListWorkoutsParams, HealthListWorkoutsResult, HealthProvider, HealthSyncRequest, HealthSyncResult, HealthWebhookEvent, HealthWebhookRequest } from '../../health';
|
|
1
|
+
import type { HealthActivity, HealthBiometric, HealthConnectionStatus, HealthDataSource, HealthListActivitiesParams, HealthListActivitiesResult, HealthListBiometricsParams, HealthListBiometricsResult, HealthListNutritionParams, HealthListNutritionResult, HealthListSleepParams, HealthListSleepResult, HealthListWorkoutsParams, HealthListWorkoutsResult, HealthNutrition, HealthProvider, HealthSleep, HealthSyncRequest, HealthSyncResult, HealthWebhookEvent, HealthWebhookRequest, HealthWorkout } from '../../health';
|
|
2
2
|
import type { HealthTransportStrategy } from '@contractspec/integration.runtime/runtime';
|
|
3
|
+
type UnknownRecord = Record<string, unknown>;
|
|
4
|
+
interface OAuthOptions {
|
|
5
|
+
tokenUrl?: string;
|
|
6
|
+
refreshToken?: string;
|
|
7
|
+
clientId?: string;
|
|
8
|
+
clientSecret?: string;
|
|
9
|
+
tokenExpiresAt?: string;
|
|
10
|
+
}
|
|
3
11
|
export interface BaseHealthProviderOptions {
|
|
4
12
|
providerKey: string;
|
|
5
13
|
transport: HealthTransportStrategy;
|
|
@@ -9,25 +17,51 @@ export interface BaseHealthProviderOptions {
|
|
|
9
17
|
accessToken?: string;
|
|
10
18
|
mcpAccessToken?: string;
|
|
11
19
|
webhookSecret?: string;
|
|
20
|
+
webhookSignatureHeader?: string;
|
|
21
|
+
route?: 'primary' | 'fallback';
|
|
22
|
+
aggregatorKey?: string;
|
|
23
|
+
oauth?: OAuthOptions;
|
|
12
24
|
fetchFn?: typeof fetch;
|
|
13
25
|
}
|
|
26
|
+
interface DatasetFetchConfig<P, T> {
|
|
27
|
+
apiPath?: string;
|
|
28
|
+
mcpTool: string;
|
|
29
|
+
listKeys?: readonly string[];
|
|
30
|
+
method?: 'GET' | 'POST';
|
|
31
|
+
buildQuery?: (params: P) => UnknownRecord;
|
|
32
|
+
buildBody?: (params: P) => UnknownRecord;
|
|
33
|
+
mapItem: (item: UnknownRecord, params: P) => T | undefined;
|
|
34
|
+
}
|
|
35
|
+
interface ConnectionStatusConfig {
|
|
36
|
+
apiPath?: string;
|
|
37
|
+
mcpTool: string;
|
|
38
|
+
}
|
|
39
|
+
export declare class HealthProviderCapabilityError extends Error {
|
|
40
|
+
readonly code = "NOT_SUPPORTED";
|
|
41
|
+
constructor(message: string);
|
|
42
|
+
}
|
|
14
43
|
export declare class BaseHealthProvider implements HealthProvider {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
private readonly apiBaseUrl
|
|
44
|
+
protected readonly providerKey: string;
|
|
45
|
+
protected readonly transport: HealthTransportStrategy;
|
|
46
|
+
private readonly apiBaseUrl?;
|
|
18
47
|
private readonly mcpUrl?;
|
|
19
48
|
private readonly apiKey?;
|
|
20
|
-
private
|
|
49
|
+
private accessToken?;
|
|
50
|
+
private refreshToken?;
|
|
21
51
|
private readonly mcpAccessToken?;
|
|
22
52
|
private readonly webhookSecret?;
|
|
53
|
+
private readonly webhookSignatureHeader;
|
|
54
|
+
private readonly route;
|
|
55
|
+
private readonly aggregatorKey?;
|
|
56
|
+
private readonly oauth;
|
|
23
57
|
private readonly fetchFn;
|
|
24
58
|
private mcpRequestId;
|
|
25
59
|
constructor(options: BaseHealthProviderOptions);
|
|
26
|
-
listActivities(
|
|
27
|
-
listWorkouts(
|
|
28
|
-
listSleep(
|
|
29
|
-
listBiometrics(
|
|
30
|
-
listNutrition(
|
|
60
|
+
listActivities(_params: HealthListActivitiesParams): Promise<HealthListActivitiesResult>;
|
|
61
|
+
listWorkouts(_params: HealthListWorkoutsParams): Promise<HealthListWorkoutsResult>;
|
|
62
|
+
listSleep(_params: HealthListSleepParams): Promise<HealthListSleepResult>;
|
|
63
|
+
listBiometrics(_params: HealthListBiometricsParams): Promise<HealthListBiometricsResult>;
|
|
64
|
+
listNutrition(_params: HealthListNutritionParams): Promise<HealthListNutritionResult>;
|
|
31
65
|
getConnectionStatus(params: {
|
|
32
66
|
tenantId: string;
|
|
33
67
|
connectionId: string;
|
|
@@ -39,9 +73,26 @@ export declare class BaseHealthProvider implements HealthProvider {
|
|
|
39
73
|
syncNutrition(params: HealthSyncRequest): Promise<HealthSyncResult>;
|
|
40
74
|
parseWebhook(request: HealthWebhookRequest): Promise<HealthWebhookEvent>;
|
|
41
75
|
verifyWebhook(request: HealthWebhookRequest): Promise<boolean>;
|
|
76
|
+
protected fetchActivities(params: HealthListActivitiesParams, config: DatasetFetchConfig<HealthListActivitiesParams, HealthActivity>): Promise<HealthListActivitiesResult>;
|
|
77
|
+
protected fetchWorkouts(params: HealthListWorkoutsParams, config: DatasetFetchConfig<HealthListWorkoutsParams, HealthWorkout>): Promise<HealthListWorkoutsResult>;
|
|
78
|
+
protected fetchSleep(params: HealthListSleepParams, config: DatasetFetchConfig<HealthListSleepParams, HealthSleep>): Promise<HealthListSleepResult>;
|
|
79
|
+
protected fetchBiometrics(params: HealthListBiometricsParams, config: DatasetFetchConfig<HealthListBiometricsParams, HealthBiometric>): Promise<HealthListBiometricsResult>;
|
|
80
|
+
protected fetchNutrition(params: HealthListNutritionParams, config: DatasetFetchConfig<HealthListNutritionParams, HealthNutrition>): Promise<HealthListNutritionResult>;
|
|
81
|
+
protected fetchConnectionStatus(params: {
|
|
82
|
+
tenantId: string;
|
|
83
|
+
connectionId: string;
|
|
84
|
+
}, config: ConnectionStatusConfig): Promise<HealthConnectionStatus>;
|
|
85
|
+
protected currentSource(): HealthDataSource;
|
|
86
|
+
protected providerSlug(): string;
|
|
87
|
+
protected unsupported(capability: string): HealthProviderCapabilityError;
|
|
88
|
+
private syncFromList;
|
|
42
89
|
private fetchList;
|
|
43
|
-
private
|
|
44
|
-
private
|
|
90
|
+
private fetchPayload;
|
|
91
|
+
private isMcpTransport;
|
|
92
|
+
private requestApi;
|
|
45
93
|
private callMcpTool;
|
|
46
|
-
|
|
94
|
+
private authorizationHeaders;
|
|
95
|
+
private refreshAccessToken;
|
|
96
|
+
private readResponsePayload;
|
|
47
97
|
}
|
|
98
|
+
export {};
|