@utcp/http 1.0.11 → 1.0.13
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/index.cjs +26 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +26 -15
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -319,6 +319,7 @@ interface OpenApiConverterOptions {
|
|
|
319
319
|
specUrl?: string;
|
|
320
320
|
callTemplateName?: string;
|
|
321
321
|
authTools?: Auth;
|
|
322
|
+
baseUrl?: string;
|
|
322
323
|
}
|
|
323
324
|
/**
|
|
324
325
|
* REQUIRED
|
|
@@ -332,6 +333,7 @@ interface OpenApiConverterOptions {
|
|
|
332
333
|
declare class OpenApiConverter {
|
|
333
334
|
private spec;
|
|
334
335
|
private spec_url;
|
|
336
|
+
private base_url;
|
|
335
337
|
private auth_tools;
|
|
336
338
|
private placeholder_counter;
|
|
337
339
|
private call_template_name;
|
|
@@ -339,10 +341,11 @@ declare class OpenApiConverter {
|
|
|
339
341
|
* Initializes the OpenAPI converter.
|
|
340
342
|
*
|
|
341
343
|
* @param openapi_spec Parsed OpenAPI specification as a dictionary.
|
|
342
|
-
* @param options Optional settings including spec_url, call_template_name, and
|
|
344
|
+
* @param options Optional settings including spec_url, call_template_name, auth_tools, and baseUrl.
|
|
343
345
|
* - specUrl: URL where the specification was retrieved from.
|
|
344
346
|
* - callTemplateName: Custom name for the call_template if spec title not provided.
|
|
345
347
|
* - authTools: Optional auth configuration for generated tools.
|
|
348
|
+
* - baseUrl: Optional base URL override for all API endpoints.
|
|
346
349
|
*/
|
|
347
350
|
constructor(openapi_spec: Record<string, any>, options?: OpenApiConverterOptions);
|
|
348
351
|
private _generateUuid;
|
package/dist/index.d.ts
CHANGED
|
@@ -319,6 +319,7 @@ interface OpenApiConverterOptions {
|
|
|
319
319
|
specUrl?: string;
|
|
320
320
|
callTemplateName?: string;
|
|
321
321
|
authTools?: Auth;
|
|
322
|
+
baseUrl?: string;
|
|
322
323
|
}
|
|
323
324
|
/**
|
|
324
325
|
* REQUIRED
|
|
@@ -332,6 +333,7 @@ interface OpenApiConverterOptions {
|
|
|
332
333
|
declare class OpenApiConverter {
|
|
333
334
|
private spec;
|
|
334
335
|
private spec_url;
|
|
336
|
+
private base_url;
|
|
335
337
|
private auth_tools;
|
|
336
338
|
private placeholder_counter;
|
|
337
339
|
private call_template_name;
|
|
@@ -339,10 +341,11 @@ declare class OpenApiConverter {
|
|
|
339
341
|
* Initializes the OpenAPI converter.
|
|
340
342
|
*
|
|
341
343
|
* @param openapi_spec Parsed OpenAPI specification as a dictionary.
|
|
342
|
-
* @param options Optional settings including spec_url, call_template_name, and
|
|
344
|
+
* @param options Optional settings including spec_url, call_template_name, auth_tools, and baseUrl.
|
|
343
345
|
* - specUrl: URL where the specification was retrieved from.
|
|
344
346
|
* - callTemplateName: Custom name for the call_template if spec title not provided.
|
|
345
347
|
* - authTools: Optional auth configuration for generated tools.
|
|
348
|
+
* - baseUrl: Optional base URL override for all API endpoints.
|
|
346
349
|
*/
|
|
347
350
|
constructor(openapi_spec: Record<string, any>, options?: OpenApiConverterOptions);
|
|
348
351
|
private _generateUuid;
|
package/dist/index.js
CHANGED
|
@@ -4203,6 +4203,7 @@ import { UtcpManualSerializer } from "@utcp/sdk";
|
|
|
4203
4203
|
var OpenApiConverter = class {
|
|
4204
4204
|
spec;
|
|
4205
4205
|
spec_url;
|
|
4206
|
+
base_url;
|
|
4206
4207
|
auth_tools;
|
|
4207
4208
|
placeholder_counter = 0;
|
|
4208
4209
|
call_template_name;
|
|
@@ -4210,14 +4211,16 @@ var OpenApiConverter = class {
|
|
|
4210
4211
|
* Initializes the OpenAPI converter.
|
|
4211
4212
|
*
|
|
4212
4213
|
* @param openapi_spec Parsed OpenAPI specification as a dictionary.
|
|
4213
|
-
* @param options Optional settings including spec_url, call_template_name, and
|
|
4214
|
+
* @param options Optional settings including spec_url, call_template_name, auth_tools, and baseUrl.
|
|
4214
4215
|
* - specUrl: URL where the specification was retrieved from.
|
|
4215
4216
|
* - callTemplateName: Custom name for the call_template if spec title not provided.
|
|
4216
4217
|
* - authTools: Optional auth configuration for generated tools.
|
|
4218
|
+
* - baseUrl: Optional base URL override for all API endpoints.
|
|
4217
4219
|
*/
|
|
4218
4220
|
constructor(openapi_spec, options) {
|
|
4219
4221
|
this.spec = openapi_spec;
|
|
4220
4222
|
this.spec_url = options?.specUrl;
|
|
4223
|
+
this.base_url = options?.baseUrl;
|
|
4221
4224
|
this.auth_tools = options?.authTools;
|
|
4222
4225
|
this.placeholder_counter = 0;
|
|
4223
4226
|
let callTemplateName = options?.callTemplateName;
|
|
@@ -4252,10 +4255,15 @@ var OpenApiConverter = class {
|
|
|
4252
4255
|
this.placeholder_counter = 0;
|
|
4253
4256
|
const tools = [];
|
|
4254
4257
|
let baseUrl = "/";
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4258
|
+
if (this.base_url) {
|
|
4259
|
+
baseUrl = this.base_url;
|
|
4260
|
+
} else if (this.spec.servers && Array.isArray(this.spec.servers) && this.spec.servers.length > 0 && this.spec.servers[0].url) {
|
|
4261
|
+
baseUrl = this.spec.servers[0].url;
|
|
4262
|
+
} else if (this.spec.host) {
|
|
4263
|
+
const scheme = this.spec.schemes?.[0] || "https";
|
|
4264
|
+
const basePath = this.spec.basePath || "";
|
|
4265
|
+
baseUrl = `${scheme}://${this.spec.host}${basePath}`;
|
|
4266
|
+
} else if (this.spec_url && (this.spec_url.startsWith("http://") || this.spec_url.startsWith("https://"))) {
|
|
4259
4267
|
try {
|
|
4260
4268
|
const parsedUrl = new URL(this.spec_url);
|
|
4261
4269
|
baseUrl = `${parsedUrl.protocol}//${parsedUrl.host}`;
|
|
@@ -4263,7 +4271,7 @@ var OpenApiConverter = class {
|
|
|
4263
4271
|
console.error(`[OpenApiConverter] Invalid spec_url provided: ${this.spec_url}`);
|
|
4264
4272
|
}
|
|
4265
4273
|
} else {
|
|
4266
|
-
console.warn("[OpenApiConverter] No server info
|
|
4274
|
+
console.warn("[OpenApiConverter] No server info found in OpenAPI spec. Using fallback base URL: '/'. Tools may not work correctly without a valid base URL.");
|
|
4267
4275
|
}
|
|
4268
4276
|
const paths = this.spec.paths || {};
|
|
4269
4277
|
for (const [path, pathItem] of Object.entries(paths)) {
|
|
@@ -4833,11 +4841,12 @@ var HttpCommunicationProtocol = class {
|
|
|
4833
4841
|
if (!apiKeyAuth.api_key) {
|
|
4834
4842
|
throw new Error("API key for ApiKeyAuth is empty.");
|
|
4835
4843
|
}
|
|
4836
|
-
|
|
4844
|
+
const location = apiKeyAuth.location || "header";
|
|
4845
|
+
if (location === "header") {
|
|
4837
4846
|
requestConfig.headers = { ...requestConfig.headers, [apiKeyAuth.var_name]: apiKeyAuth.api_key };
|
|
4838
|
-
} else if (
|
|
4847
|
+
} else if (location === "query") {
|
|
4839
4848
|
requestConfig.params = { ...requestConfig.params, [apiKeyAuth.var_name]: apiKeyAuth.api_key };
|
|
4840
|
-
} else if (
|
|
4849
|
+
} else if (location === "cookie") {
|
|
4841
4850
|
cookies[apiKeyAuth.var_name] = apiKeyAuth.api_key;
|
|
4842
4851
|
}
|
|
4843
4852
|
} else if (httpCallTemplate.auth.auth_type === "basic") {
|
|
@@ -4978,11 +4987,12 @@ var StreamableHttpCommunicationProtocol = class {
|
|
|
4978
4987
|
if ("api_key" in provider.auth) {
|
|
4979
4988
|
const apiKeyAuth = provider.auth;
|
|
4980
4989
|
if (apiKeyAuth.api_key) {
|
|
4981
|
-
|
|
4990
|
+
const location = apiKeyAuth.location || "header";
|
|
4991
|
+
if (location === "header") {
|
|
4982
4992
|
headers[apiKeyAuth.var_name] = apiKeyAuth.api_key;
|
|
4983
|
-
} else if (
|
|
4993
|
+
} else if (location === "query") {
|
|
4984
4994
|
queryParams[apiKeyAuth.var_name] = apiKeyAuth.api_key;
|
|
4985
|
-
} else if (
|
|
4995
|
+
} else if (location === "cookie") {
|
|
4986
4996
|
cookies[apiKeyAuth.var_name] = apiKeyAuth.api_key;
|
|
4987
4997
|
}
|
|
4988
4998
|
} else {
|
|
@@ -5109,11 +5119,12 @@ var SseCommunicationProtocol = class {
|
|
|
5109
5119
|
if ("api_key" in provider.auth) {
|
|
5110
5120
|
const apiKeyAuth = provider.auth;
|
|
5111
5121
|
if (apiKeyAuth.api_key) {
|
|
5112
|
-
|
|
5122
|
+
const location = apiKeyAuth.location || "header";
|
|
5123
|
+
if (location === "header") {
|
|
5113
5124
|
headers[apiKeyAuth.var_name] = apiKeyAuth.api_key;
|
|
5114
|
-
} else if (
|
|
5125
|
+
} else if (location === "query") {
|
|
5115
5126
|
queryParams[apiKeyAuth.var_name] = apiKeyAuth.api_key;
|
|
5116
|
-
} else if (
|
|
5127
|
+
} else if (location === "cookie") {
|
|
5117
5128
|
cookies[apiKeyAuth.var_name] = apiKeyAuth.api_key;
|
|
5118
5129
|
}
|
|
5119
5130
|
} else {
|