Skip to content

Commit 7e6af39

Browse files
committed
fixes
1 parent a46e633 commit 7e6af39

File tree

12 files changed

+1997
-83
lines changed

12 files changed

+1997
-83
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Tadata Node SDK
22

3-
A Node.js SDK for deploying MCP (Multi-Channel Proxy) servers with your OpenAPI specifications.
3+
A Node.js SDK for deploying Model Context Protocol (MCP) servers with your OpenAPI specifications.
44

55
## Installation
66

@@ -14,16 +14,16 @@ pnpm add @tadata/node-sdk
1414

1515
## Quickstart
1616

17-
Deploy an MCP server with your OpenAPI specification:
17+
Deploy a Model Context Protocol (MCP) server with your OpenAPI specification:
1818

1919
```typescript
20-
import { TadataNodeSDK, OpenApiSource } from '@tadata/node-sdk';
20+
import { TadataNodeSDK, OpenApiSource, ApiVersion } from '@tadata/node-sdk';
2121

2222
// Initialize the SDK
2323
const tadata = new TadataNodeSDK({
2424
apiKey: process.env.TADATA_KEY!,
2525
dev: process.env.NODE_ENV !== 'production',
26-
version: '10-10-2024', // Optional: specify API version
26+
version: ApiVersion.V_05_2025, // Optional: specify API version
2727
logger: pino(), // Optional: use custom logger
2828
});
2929

@@ -37,7 +37,7 @@ const deployment = await tadata.mcp.deploy({
3737
name: 'Acme API', // Optional
3838
});
3939

40-
console.log(`Deployed MCP server: ${deployment.url}`);
40+
console.log(`Deployed Model Context Protocol (MCP) server: ${deployment.url}`);
4141
```
4242

4343
## OpenAPI Source Formats

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
"LICENSE",
1818
"README.md"
1919
],
20+
"publishConfig": {
21+
"access": "public"
22+
},
2023
"scripts": {
2124
"clean": "npx rimraf dist",
2225
"build": "npm run clean && npm run build:cjs && npm run build:esm && npm run build:types",
@@ -62,6 +65,7 @@
6265
"nock": "^13.3.0",
6366
"prettier": "^3.1.0",
6467
"rimraf": "^5.0.5",
68+
"semantic-release": "^24.2.4",
6569
"ts-jest": "^29.1.1",
6670
"ts-node": "^10.9.1",
6771
"typescript": "^5.2.2",

pnpm-lock.yaml

Lines changed: 1666 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/contract/client.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { initClient } from '@ts-rest/core';
22
import axios, { AxiosError } from 'axios';
3-
import { tadataContract } from './tadata-contract';
4-
import { AuthError, NetworkError, ApiError } from '../errors';
53
import { Logger } from '../core/logger';
4+
import { ApiError, AuthError, NetworkError } from '../errors';
5+
import { tadataContract } from './tadata-contract';
66

77
interface ClientOptions {
88
baseUrl: string;
9-
version: string;
9+
version: '05-2025' | 'latest';
1010
timeout?: number;
1111
logger?: Logger;
1212
isDev: boolean;
@@ -32,7 +32,7 @@ export function createApiClient(apiKey: string, options: ClientOptions) {
3232
timeout,
3333
headers: {
3434
'Authorization': `Bearer ${apiKey}`,
35-
'x-api-version': version,
35+
'x-api-version': version as string,
3636
'Content-Type': 'application/json',
3737
},
3838
});
@@ -42,6 +42,8 @@ export function createApiClient(apiKey: string, options: ClientOptions) {
4242
axiosInstance.interceptors.request.use(
4343
config => {
4444
logger.debug(`Making request to ${config.method?.toUpperCase()} ${config.url}`);
45+
// Log API version header specifically
46+
logger.debug(`Using API version: ${config.headers['x-api-version']}`);
4547
return config;
4648
},
4749
error => {

src/core/logger.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
/**
2-
* Logger interface for the SDK
2+
* Logger interface for the SDK.
3+
* Consumers of the SDK can implement this interface to provide a custom logging
4+
* solution (e.g., to integrate with their existing logging infrastructure like Pino or Winston).
5+
* If no logger is provided to `TadataNodeSDK`, a default `ConsoleLogger` will be used.
6+
*
7+
* @since 0.1.0
38
*/
49
export interface Logger {
510
debug(msg: string, ...meta: unknown[]): void;
@@ -10,6 +15,8 @@ export interface Logger {
1015

1116
/**
1217
* Simple console-based logger implementation
18+
*
19+
* @since 0.1.0
1320
*/
1421
export class ConsoleLogger implements Logger {
1522
debug(msg: string, ...meta: unknown[]): void {
@@ -31,6 +38,8 @@ export class ConsoleLogger implements Logger {
3138

3239
/**
3340
* Creates a default console logger
41+
*
42+
* @since 0.1.0
3443
*/
3544
export function createDefaultLogger(): Logger {
3645
return new ConsoleLogger();

src/core/sdk.ts

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,91 @@
11
import { createApiClient } from '../contract';
22
import { McpResource } from '../resources/mcp';
3-
import { Logger, createDefaultLogger } from './logger';
3+
import { createDefaultLogger, Logger } from './logger';
44

55
/**
6-
* Options for initializing the Tadata Node SDK
6+
* Options for initializing the Tadata Node SDK.
7+
* These settings configure the behavior of the SDK client.
8+
*
9+
* @since 0.1.0
710
*/
811
export interface TadataOptions {
912
/**
10-
* API key for authentication
13+
* Your Tadata API key. This is required for authentication.
14+
* You can obtain an API key from the Tadata dashboard.
1115
*/
1216
apiKey: string;
1317

1418
/**
15-
* Whether to use development mode (sandbox)
19+
* Specifies whether to use the development mode (sandbox environment).
20+
* Set to `true` to use the sandbox for testing purposes.
1621
* @default false
1722
*/
1823
dev?: boolean;
1924

2025
/**
21-
* API version to use
22-
* @default latest
26+
* The API version to use for requests.
27+
* It's recommended to use a specific version for stability.
28+
* @default ApiVersion.LATEST
2329
*/
24-
version?: string;
25-
30+
version?: '05-2025' | 'latest';
2631
/**
27-
* Custom logger instance
32+
* A custom logger instance that conforms to the {@link Logger} interface.
33+
* If not provided, a default console logger (`ConsoleLogger`) will be used.
34+
* This allows you to integrate SDK logging with your application's logging solution.
2835
* @default ConsoleLogger
2936
*/
3037
logger?: Logger;
3138
}
3239

3340
/**
34-
* Main class for the Tadata Node SDK
41+
* The main class for interacting with the Tadata API.
42+
* This class provides access to various Tadata resources and functionalities.
3543
*
44+
* @since 0.1.0
3645
* @example
37-
* ```typescript
38-
* import { TadataNodeSDK, OpenApiSource } from '@tadata/node-sdk';
46+
* \`\`\`typescript
47+
* import { TadataNodeSDK, ApiVersion } from '@tadata/node-sdk';
48+
* // Assumes pino is installed for custom logging, otherwise default logger is used.
49+
* // import pino from 'pino';
3950
*
4051
* const tadata = new TadataNodeSDK({
4152
* apiKey: process.env.TADATA_KEY!,
4253
* dev: process.env.NODE_ENV !== 'production',
43-
* version: '10-10-2024',
44-
* logger: pino(), // optional
54+
* version: ApiVersion.V_05_2025, // Optional: Defaults to ApiVersion.LATEST
55+
* // logger: pino(), // Optional: Provide a custom logger
4556
* });
4657
*
47-
* // Load from JSON file
48-
* const source = await OpenApiSource.fromFile('./acme-openapi.json');
49-
* // Or from JSON string or object
50-
* // const source = OpenApiSource.fromJson(jsonString);
51-
* // const source = OpenApiSource.fromObject(specObject);
58+
* async function main() {
59+
* // Example usage (assuming OpenApiSource and MCP deployment)
60+
* // const source = await OpenApiSource.fromFile('./my-api-spec.json');
61+
* // const deployment = await tadata.mcp.deploy({
62+
* // spec: source,
63+
* // specBaseUrl: 'https://api.example.com',
64+
* // name: 'My API Proxy'
65+
* // });
66+
* // console.log('Deployment URL:', deployment.url);
67+
* }
5268
*
53-
* await tadata.mcp.deploy({
54-
* spec: source,
55-
* specBaseUrl: 'https://acme.com/api',
56-
* });
57-
* ```
69+
* main().catch(console.error);
70+
* \`\`\`
5871
*/
5972
export class TadataNodeSDK {
6073
/**
61-
* MCP resource for deploying and managing Multi-Channel Proxies
74+
* Access to Model Context Protocol (MCP) functionalities.
75+
* Use this resource to deploy and manage your Model Context Protocol instances.
76+
* @readonly
6277
*/
6378
public readonly mcp: McpResource;
79+
6480
/**
65-
* Create a new Tadata Node SDK instance
81+
* Creates a new instance of the TadataNodeSDK.
82+
*
83+
* @param options Configuration options for the SDK. See {@link TadataOptions}.
6684
*/
6785
constructor(options: TadataOptions) {
6886
const logger = options.logger || createDefaultLogger();
6987
const isDev = options.dev || false;
70-
71-
// Always use http://localhost:3000 as the baseUrl
72-
// This is a requirement for the current implementation
73-
const baseUrl = 'http://localhost:3000';
88+
const baseUrl = isDev ? 'https://api.stage.tadata.com' : 'https://api.tadata.com';
7489

7590
const client = createApiClient(options.apiKey, {
7691
baseUrl,

0 commit comments

Comments
 (0)