@ductape/mcp 0.1.28 → 0.1.30
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/dist/proxy-client.d.ts.map +1 -1
- package/dist/proxy-client.js +33 -4
- package/package.json +1 -1
- package/src/proxy-client.ts +36 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy-client.d.ts","sourceRoot":"","sources":["../src/proxy-client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,YAAY,4BAA4B,CAAC;AAEtD,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,KAAK,GACL,WAAW,GACX,OAAO,GACP,UAAU,GACV,eAAe,GACf,gBAAgB,GAChB,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,UAAU,GACV,QAAQ,GACR,SAAS,GACT,UAAU,GACV,MAAM,GACN,MAAM,GACN,YAAY,GACZ,QAAQ,GACR,UAAU,GACV,SAAS,CAAC;AAUd;;GAEG;AACH,wBAAsB,eAAe,CAAC,CAAC,GAAG,OAAO,EAC/C,eAAe,EAAE,MAAM,EACvB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,OAAO,EAAO,GACrB,OAAO,CAAC,CAAC,CAAC,CAuBZ;AAED,MAAM,WAAW,iCAAiC;IAChD,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,QAAQ,GAAG,aAAa,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CA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AO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AASD,wBAAsB,eAAe,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAYvE;AA4BD,wBAAsB,yBAAyB,CAAC,CAAC,GAAG,kCAAkC,EACpF,OAAO,EAAE,iCAAiC,GACzC,OAAO,CAAC,CAAC,CAAC,CAwBZ"}
|
package/dist/proxy-client.js
CHANGED
|
@@ -41,22 +41,51 @@ export async function getAssetSchemas(module) {
|
|
|
41
41
|
}
|
|
42
42
|
return body.data;
|
|
43
43
|
}
|
|
44
|
+
function normalizeTargets(targets) {
|
|
45
|
+
const result = { ...targets };
|
|
46
|
+
const renames = [
|
|
47
|
+
['feature', 'feature_tag'],
|
|
48
|
+
['database', 'database_tag'],
|
|
49
|
+
['action', 'action_tag'],
|
|
50
|
+
['app', 'access_tag'],
|
|
51
|
+
['graph', 'graph_tag'],
|
|
52
|
+
['vector', 'vector_tag'],
|
|
53
|
+
['storage', 'storage_tag'],
|
|
54
|
+
['notification', 'notification_tag'],
|
|
55
|
+
['message', 'message_tag'],
|
|
56
|
+
['broker', 'broker_tag'],
|
|
57
|
+
['topic', 'topic_tag'],
|
|
58
|
+
['session', 'session_tag'],
|
|
59
|
+
['cache', 'cache_tag'],
|
|
60
|
+
];
|
|
61
|
+
for (const [from, to] of renames) {
|
|
62
|
+
if (from in result && !(to in result)) {
|
|
63
|
+
result[to] = result[from];
|
|
64
|
+
delete result[from];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
44
69
|
export async function generateExecutablePayload(request) {
|
|
70
|
+
const normalizedRequest = {
|
|
71
|
+
...request,
|
|
72
|
+
targets: request.targets ? normalizeTargets(request.targets) : request.targets,
|
|
73
|
+
};
|
|
45
74
|
const url = `${API_BASE_URL.replace(/\/$/, '')}/integrations/v1/payloads/generate`;
|
|
46
75
|
const res = await fetch(url, {
|
|
47
76
|
method: 'POST',
|
|
48
77
|
headers: {
|
|
49
78
|
'Content-Type': 'application/json',
|
|
50
|
-
'x-access-key': request.publishable_key,
|
|
51
79
|
},
|
|
52
|
-
body: JSON.stringify(
|
|
80
|
+
body: JSON.stringify(normalizedRequest),
|
|
53
81
|
});
|
|
54
82
|
const body = (await res.json());
|
|
83
|
+
const detail = (b) => b.message ?? (typeof b.errors === 'string' ? b.errors : b.errors ? JSON.stringify(b.errors) : undefined);
|
|
55
84
|
if (!res.ok) {
|
|
56
|
-
throw new Error(body
|
|
85
|
+
throw new Error(detail(body) ?? `Payload generation request failed: ${res.status}`);
|
|
57
86
|
}
|
|
58
87
|
if (typeof body.status === 'boolean' && !body.status) {
|
|
59
|
-
throw new Error(body
|
|
88
|
+
throw new Error(detail(body) ?? 'Payload generation failed');
|
|
60
89
|
}
|
|
61
90
|
return body.data;
|
|
62
91
|
}
|
package/package.json
CHANGED
package/src/proxy-client.ts
CHANGED
|
@@ -89,6 +89,7 @@ interface GenericResponse<T = unknown> {
|
|
|
89
89
|
status?: boolean;
|
|
90
90
|
data?: T;
|
|
91
91
|
message?: string;
|
|
92
|
+
errors?: unknown;
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
export async function getAssetSchemas(module?: string): Promise<unknown> {
|
|
@@ -105,25 +106,56 @@ export async function getAssetSchemas(module?: string): Promise<unknown> {
|
|
|
105
106
|
return body.data;
|
|
106
107
|
}
|
|
107
108
|
|
|
109
|
+
function normalizeTargets(targets: Record<string, unknown>): Record<string, unknown> {
|
|
110
|
+
const result = { ...targets };
|
|
111
|
+
const renames: Array<[string, string]> = [
|
|
112
|
+
['feature', 'feature_tag'],
|
|
113
|
+
['database', 'database_tag'],
|
|
114
|
+
['action', 'action_tag'],
|
|
115
|
+
['app', 'access_tag'],
|
|
116
|
+
['graph', 'graph_tag'],
|
|
117
|
+
['vector', 'vector_tag'],
|
|
118
|
+
['storage', 'storage_tag'],
|
|
119
|
+
['notification', 'notification_tag'],
|
|
120
|
+
['message', 'message_tag'],
|
|
121
|
+
['broker', 'broker_tag'],
|
|
122
|
+
['topic', 'topic_tag'],
|
|
123
|
+
['session', 'session_tag'],
|
|
124
|
+
['cache', 'cache_tag'],
|
|
125
|
+
];
|
|
126
|
+
for (const [from, to] of renames) {
|
|
127
|
+
if (from in result && !(to in result)) {
|
|
128
|
+
result[to] = result[from];
|
|
129
|
+
delete result[from];
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
|
|
108
135
|
export async function generateExecutablePayload<T = IGenerateExecutablePayloadResponse>(
|
|
109
136
|
request: IGenerateExecutablePayloadRequest,
|
|
110
137
|
): Promise<T> {
|
|
138
|
+
const normalizedRequest = {
|
|
139
|
+
...request,
|
|
140
|
+
targets: request.targets ? normalizeTargets(request.targets as Record<string, unknown>) : request.targets,
|
|
141
|
+
};
|
|
111
142
|
const url = `${API_BASE_URL.replace(/\/$/, '')}/integrations/v1/payloads/generate`;
|
|
112
143
|
const res = await fetch(url, {
|
|
113
144
|
method: 'POST',
|
|
114
145
|
headers: {
|
|
115
146
|
'Content-Type': 'application/json',
|
|
116
|
-
'x-access-key': request.publishable_key,
|
|
117
147
|
},
|
|
118
|
-
body: JSON.stringify(
|
|
148
|
+
body: JSON.stringify(normalizedRequest),
|
|
119
149
|
});
|
|
120
150
|
|
|
121
151
|
const body = (await res.json()) as GenericResponse<T>;
|
|
152
|
+
const detail = (b: GenericResponse<T>) =>
|
|
153
|
+
b.message ?? (typeof b.errors === 'string' ? b.errors : b.errors ? JSON.stringify(b.errors) : undefined);
|
|
122
154
|
if (!res.ok) {
|
|
123
|
-
throw new Error(body
|
|
155
|
+
throw new Error(detail(body) ?? `Payload generation request failed: ${res.status}`);
|
|
124
156
|
}
|
|
125
157
|
if (typeof body.status === 'boolean' && !body.status) {
|
|
126
|
-
throw new Error(body
|
|
158
|
+
throw new Error(detail(body) ?? 'Payload generation failed');
|
|
127
159
|
}
|
|
128
160
|
return body.data as T;
|
|
129
161
|
}
|