@ductape/mcp 0.1.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 +82 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +757 -0
- package/dist/proxy-client.d.ts +29 -0
- package/dist/proxy-client.d.ts.map +1 -0
- package/dist/proxy-client.js +49 -0
- package/docs/TOOLS.md +204 -0
- package/package.json +37 -0
- package/src/index.ts +813 -0
- package/src/proxy-client.ts +117 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client for the Ductape backend SDK proxy using Publishable Key.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export const API_BASE_URL = 'https://api.ductape.app';
|
|
6
|
+
|
|
7
|
+
export type SDKModule =
|
|
8
|
+
| 'product'
|
|
9
|
+
| 'app'
|
|
10
|
+
| 'databases'
|
|
11
|
+
| 'graph'
|
|
12
|
+
| 'webhooks'
|
|
13
|
+
| 'notifications'
|
|
14
|
+
| 'messageBrokers'
|
|
15
|
+
| 'storage'
|
|
16
|
+
| 'vector'
|
|
17
|
+
| 'caches'
|
|
18
|
+
| 'sessions'
|
|
19
|
+
| 'quotas'
|
|
20
|
+
| 'actions'
|
|
21
|
+
| 'features'
|
|
22
|
+
| 'jobs'
|
|
23
|
+
| 'logs'
|
|
24
|
+
| 'resilience'
|
|
25
|
+
| 'health'
|
|
26
|
+
| 'fallback'
|
|
27
|
+
| 'secrets';
|
|
28
|
+
|
|
29
|
+
interface ProxyResponse<T = unknown> {
|
|
30
|
+
status?: boolean;
|
|
31
|
+
data?: {
|
|
32
|
+
data: T;
|
|
33
|
+
};
|
|
34
|
+
message?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Execute an SDK operation via the backend proxy using a Publishable Key.
|
|
39
|
+
*/
|
|
40
|
+
export async function executeViaProxy<T = unknown>(
|
|
41
|
+
publishable_key: string,
|
|
42
|
+
module: SDKModule,
|
|
43
|
+
method: string,
|
|
44
|
+
params: unknown[] = []
|
|
45
|
+
): Promise<T> {
|
|
46
|
+
const url = `${API_BASE_URL.replace(/\/$/, '')}/proxy/v1/sdk-proxy/execute`;
|
|
47
|
+
const res = await fetch(url, {
|
|
48
|
+
method: 'POST',
|
|
49
|
+
headers: {
|
|
50
|
+
'Content-Type': 'application/json',
|
|
51
|
+
},
|
|
52
|
+
body: JSON.stringify({
|
|
53
|
+
publishable_key,
|
|
54
|
+
module,
|
|
55
|
+
method,
|
|
56
|
+
params,
|
|
57
|
+
}),
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const body = (await res.json()) as ProxyResponse<T>;
|
|
61
|
+
if (!res.ok) {
|
|
62
|
+
throw new Error(body.message ?? `Proxy request failed: ${res.status}`);
|
|
63
|
+
}
|
|
64
|
+
if (typeof body.status === 'boolean' && !body.status) {
|
|
65
|
+
throw new Error(body.message ?? 'SDK operation failed');
|
|
66
|
+
}
|
|
67
|
+
return body.data?.data as T;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface IGenerateExecutablePayloadRequest {
|
|
71
|
+
workspace_id: string;
|
|
72
|
+
user_id: string;
|
|
73
|
+
public_key: string;
|
|
74
|
+
product_tag: string;
|
|
75
|
+
env_slug: string;
|
|
76
|
+
operation_family: string;
|
|
77
|
+
method: string;
|
|
78
|
+
targets?: Record<string, unknown>;
|
|
79
|
+
include_session?: boolean;
|
|
80
|
+
include_cache?: boolean;
|
|
81
|
+
schema_mode?: 'strict' | 'best_effort';
|
|
82
|
+
input_hint?: Record<string, unknown>;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface IGenerateExecutablePayloadResponse {
|
|
86
|
+
payload: Record<string, unknown>;
|
|
87
|
+
meta: Record<string, unknown>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
interface GenericResponse<T = unknown> {
|
|
91
|
+
status?: boolean;
|
|
92
|
+
data?: T;
|
|
93
|
+
message?: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export async function generateExecutablePayload<T = IGenerateExecutablePayloadResponse>(
|
|
97
|
+
request: IGenerateExecutablePayloadRequest,
|
|
98
|
+
): Promise<T> {
|
|
99
|
+
const url = `${API_BASE_URL.replace(/\/$/, '')}/integrations/v1/payloads/generate`;
|
|
100
|
+
const res = await fetch(url, {
|
|
101
|
+
method: 'POST',
|
|
102
|
+
headers: {
|
|
103
|
+
'Content-Type': 'application/json',
|
|
104
|
+
'x-access-key': request.public_key,
|
|
105
|
+
},
|
|
106
|
+
body: JSON.stringify(request),
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const body = (await res.json()) as GenericResponse<T>;
|
|
110
|
+
if (!res.ok) {
|
|
111
|
+
throw new Error(body.message ?? `Payload generation request failed: ${res.status}`);
|
|
112
|
+
}
|
|
113
|
+
if (typeof body.status === 'boolean' && !body.status) {
|
|
114
|
+
throw new Error(body.message ?? 'Payload generation failed');
|
|
115
|
+
}
|
|
116
|
+
return body.data as T;
|
|
117
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"outDir": "dist",
|
|
7
|
+
"rootDir": "src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"declaration": true,
|
|
12
|
+
"declarationMap": true
|
|
13
|
+
},
|
|
14
|
+
"include": ["src/**/*"],
|
|
15
|
+
"exclude": ["node_modules"]
|
|
16
|
+
}
|