@ductape/mcp 0.1.61 → 0.2.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.
@@ -1,172 +0,0 @@
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
- | 'events'
16
- | 'storage'
17
- | 'vector'
18
- | 'caches'
19
- | 'sessions'
20
- | 'quotas'
21
- | 'actions'
22
- | 'features'
23
- | 'jobs'
24
- | 'logs'
25
- | 'resilience'
26
- | 'health'
27
- | 'fallback'
28
- | 'secrets';
29
-
30
- interface ProxyResponse<T = unknown> {
31
- status?: boolean;
32
- data?: {
33
- data: T;
34
- };
35
- message?: string;
36
- }
37
-
38
- /**
39
- * Execute an SDK operation via the backend proxy using a Publishable Key.
40
- */
41
- export async function executeViaProxy<T = unknown>(
42
- publishable_key: string,
43
- module: SDKModule,
44
- method: string,
45
- params: unknown[] = []
46
- ): Promise<T> {
47
- const url = `${API_BASE_URL.replace(/\/$/, '')}/proxy/v1/sdk-proxy/execute`;
48
- const res = await fetch(url, {
49
- method: 'POST',
50
- headers: {
51
- 'Content-Type': 'application/json',
52
- },
53
- body: JSON.stringify({
54
- publishable_key,
55
- module: module === 'features' ? 'feature' : module,
56
- method,
57
- params,
58
- }),
59
- });
60
-
61
- const body = (await res.json()) as ProxyResponse<T>;
62
- if (!res.ok) {
63
- throw new Error(body.message ?? `Proxy request failed: ${res.status}`);
64
- }
65
- if (typeof body.status === 'boolean' && !body.status) {
66
- throw new Error(body.message ?? 'SDK operation failed');
67
- }
68
- return body.data?.data as T;
69
- }
70
-
71
- export interface IGenerateExecutablePayloadRequest {
72
- publishable_key: string;
73
- product_tag: string;
74
- env_slug: string;
75
- operation_family: string;
76
- method: string;
77
- targets?: Record<string, unknown>;
78
- include_session?: boolean;
79
- execution_context?: 'user' | 'delegated' | 'system';
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
- errors?: unknown;
95
- }
96
-
97
- export async function getAssetSchemas(module?: string): Promise<unknown> {
98
- const path = module ? `/proxy/v1/schema/${encodeURIComponent(module)}` : '/proxy/v1/schema';
99
- const url = `${API_BASE_URL.replace(/\/$/, '')}${path}`;
100
- const res = await fetch(url);
101
- const body = (await res.json()) as GenericResponse<unknown>;
102
- if (!res.ok) {
103
- throw new Error(body.message ?? `Schema request failed: ${res.status}`);
104
- }
105
- if (typeof body.status === 'boolean' && !body.status) {
106
- throw new Error(body.message ?? 'Schema fetch failed');
107
- }
108
- return body.data;
109
- }
110
-
111
- function normalizeTargets(targets: Record<string, unknown>): Record<string, unknown> {
112
- const result = { ...targets };
113
- const renames: Array<[string, string]> = [
114
- ['feature', 'feature_tag'],
115
- ['database', 'database_tag'],
116
- ['action', 'action_tag'],
117
- ['app', 'access_tag'],
118
- ['graph', 'graph_tag'],
119
- ['vector', 'vector_tag'],
120
- ['storage', 'storage_tag'],
121
- ['notification', 'notification_tag'],
122
- ['message', 'message_tag'],
123
- ['broker', 'broker_tag'],
124
- ['topic', 'topic_tag'],
125
- ['session', 'session_tag'],
126
- ['cache', 'cache_tag'],
127
- ];
128
- for (const [from, to] of renames) {
129
- if (from in result && !(to in result)) {
130
- result[to] = result[from];
131
- delete result[from];
132
- }
133
- }
134
- return result;
135
- }
136
-
137
- export async function generateExecutablePayload<T = IGenerateExecutablePayloadResponse>(
138
- request: IGenerateExecutablePayloadRequest,
139
- ): Promise<T> {
140
- // execution_context is MCP guidance metadata, not part of the integrations
141
- // payload-generator API contract. Keep it for local session-awareness output
142
- // but never forward it to the backend validator.
143
- const { execution_context: _executionContext, ...backendRequest } = request;
144
- const normalizedRequest = {
145
- ...backendRequest,
146
- operation_family: backendRequest.operation_family.toLowerCase() === 'features'
147
- ? 'feature'
148
- : backendRequest.operation_family,
149
- targets: backendRequest.targets
150
- ? normalizeTargets(backendRequest.targets as Record<string, unknown>)
151
- : backendRequest.targets,
152
- };
153
- const url = `${API_BASE_URL.replace(/\/$/, '')}/integrations/v1/payloads/generate`;
154
- const res = await fetch(url, {
155
- method: 'POST',
156
- headers: {
157
- 'Content-Type': 'application/json',
158
- },
159
- body: JSON.stringify(normalizedRequest),
160
- });
161
-
162
- const body = (await res.json()) as GenericResponse<T>;
163
- const detail = (b: GenericResponse<T>) =>
164
- b.message ?? (typeof b.errors === 'string' ? b.errors : b.errors ? JSON.stringify(b.errors) : undefined);
165
- if (!res.ok) {
166
- throw new Error(detail(body) ?? `Payload generation request failed: ${res.status}`);
167
- }
168
- if (typeof body.status === 'boolean' && !body.status) {
169
- throw new Error(detail(body) ?? 'Payload generation failed');
170
- }
171
- return body.data as T;
172
- }
package/tsconfig.json DELETED
@@ -1,17 +0,0 @@
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
- "types": ["node"]
14
- },
15
- "include": ["src/**/*"],
16
- "exclude": ["node_modules"]
17
- }