diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 5fdd883..c3f1463 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.1.0" + ".": "1.2.0" } diff --git a/.stats.yml b/.stats.yml index 4a4c195..58a5c1f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 5 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-b7fdba3d3f97c7debc22c7ca30b828bce81bcd64648df8c94029b27a3321ebb9.yml openapi_spec_hash: 03f1315f1d32ada42445ca920f047dff -config_hash: 1de8a243a3962065e289ca915dfc6127 +config_hash: d9c1f7b95d5659724df3e026c4fab291 diff --git a/CHANGELOG.md b/CHANGELOG.md index f79c38b..edcbd1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 1.2.0 (2025-08-18) + +Full Changelog: [v1.1.0...v1.2.0](https://github.com/CASParser/cas-parser-node/compare/v1.1.0...v1.2.0) + +### Features + +* **api:** manual updates ([f7c2421](https://github.com/CASParser/cas-parser-node/commit/f7c24211d125ede213446dea411d633f571c4c41)) + ## 1.1.0 (2025-08-18) Full Changelog: [v1.0.0...v1.1.0](https://github.com/CASParser/cas-parser-node/compare/v1.0.0...v1.1.0) diff --git a/README.md b/README.md index 07c0f95..8b3f9ad 100644 --- a/README.md +++ b/README.md @@ -24,10 +24,12 @@ import CasParser from 'cas-parser-node'; const client = new CasParser({ apiKey: process.env['CAS_PARSER_API_KEY'], // This is the default and can be omitted - environment: 'local', // defaults to 'production' }); -const unifiedResponse = await client.casParser.camsKfintech(); +const unifiedResponse = await client.casParser.smartParse({ + password: 'ABCDF', + pdf_url: 'https://your-cas-pdf-url-here.com', +}); console.log(unifiedResponse.demat_accounts); ``` @@ -42,10 +44,13 @@ import CasParser from 'cas-parser-node'; const client = new CasParser({ apiKey: process.env['CAS_PARSER_API_KEY'], // This is the default and can be omitted - environment: 'local', // defaults to 'production' }); -const unifiedResponse: CasParser.UnifiedResponse = await client.casParser.camsKfintech(); +const params: CasParser.CasParserSmartParseParams = { + password: 'ABCDF', + pdf_url: 'https://you-cas-pdf-url-here.com', +}; +const unifiedResponse: CasParser.UnifiedResponse = await client.casParser.smartParse(params); ``` Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors. @@ -58,15 +63,17 @@ a subclass of `APIError` will be thrown: ```ts -const unifiedResponse = await client.casParser.camsKfintech().catch(async (err) => { - if (err instanceof CasParser.APIError) { - console.log(err.status); // 400 - console.log(err.name); // BadRequestError - console.log(err.headers); // {server: 'nginx', ...} - } else { - throw err; - } -}); +const unifiedResponse = await client.casParser + .smartParse({ password: 'ABCDF', pdf_url: 'https://you-cas-pdf-url-here.com' }) + .catch(async (err) => { + if (err instanceof CasParser.APIError) { + console.log(err.status); // 400 + console.log(err.name); // BadRequestError + console.log(err.headers); // {server: 'nginx', ...} + } else { + throw err; + } + }); ``` Error codes are as follows: @@ -98,7 +105,7 @@ const client = new CasParser({ }); // Or, configure per-request: -await client.casParser.camsKfintech({ +await client.casParser.smartParse({ password: 'ABCDF', pdf_url: 'https://you-cas-pdf-url-here.com' }, { maxRetries: 5, }); ``` @@ -115,7 +122,7 @@ const client = new CasParser({ }); // Override per-request: -await client.casParser.camsKfintech({ +await client.casParser.smartParse({ password: 'ABCDF', pdf_url: 'https://you-cas-pdf-url-here.com' }, { timeout: 5 * 1000, }); ``` @@ -138,11 +145,15 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse ```ts const client = new CasParser(); -const response = await client.casParser.camsKfintech().asResponse(); +const response = await client.casParser + .smartParse({ password: 'ABCDF', pdf_url: 'https://you-cas-pdf-url-here.com' }) + .asResponse(); console.log(response.headers.get('X-My-Header')); console.log(response.statusText); // access the underlying Response object -const { data: unifiedResponse, response: raw } = await client.casParser.camsKfintech().withResponse(); +const { data: unifiedResponse, response: raw } = await client.casParser + .smartParse({ password: 'ABCDF', pdf_url: 'https://you-cas-pdf-url-here.com' }) + .withResponse(); console.log(raw.headers.get('X-My-Header')); console.log(unifiedResponse.demat_accounts); ``` @@ -224,7 +235,7 @@ parameter. This library doesn't validate at runtime that the request matches the send will be sent as-is. ```ts -client.casParser.camsKfintech({ +client.casParser.smartParse({ // ... // @ts-expect-error baz is not yet public baz: 'undocumented option', diff --git a/package.json b/package.json index 405c86a..aa24a10 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cas-parser-node", - "version": "1.1.0", + "version": "1.2.0", "description": "The official TypeScript library for the Cas Parser API", "author": "Cas Parser ", "types": "dist/index.d.ts", diff --git a/packages/mcp-server/README.md b/packages/mcp-server/README.md index 5295fc0..1e3c6ee 100644 --- a/packages/mcp-server/README.md +++ b/packages/mcp-server/README.md @@ -10,7 +10,6 @@ You can run the MCP Server directly via `npx`: ```sh export CAS_PARSER_API_KEY="My API Key" -export CAS_PARSER_ENVIRONMENT="production" npx -y cas-parser-node-mcp@latest ``` @@ -28,8 +27,7 @@ For clients with a configuration JSON, it might look something like this: "command": "npx", "args": ["-y", "cas-parser-node-mcp", "--client=claude", "--tools=all"], "env": { - "CAS_PARSER_API_KEY": "My API Key", - "CAS_PARSER_ENVIRONMENT": "production" + "CAS_PARSER_API_KEY": "My API Key" } } } diff --git a/packages/mcp-server/package.json b/packages/mcp-server/package.json index ef3cae5..7b10b87 100644 --- a/packages/mcp-server/package.json +++ b/packages/mcp-server/package.json @@ -1,6 +1,6 @@ { "name": "cas-parser-node-mcp", - "version": "1.1.0", + "version": "1.2.0", "description": "The official MCP Server for the Cas Parser API", "author": "Cas Parser ", "types": "dist/index.d.ts", diff --git a/packages/mcp-server/src/server.ts b/packages/mcp-server/src/server.ts index 1c2aa54..9a17e7f 100644 --- a/packages/mcp-server/src/server.ts +++ b/packages/mcp-server/src/server.ts @@ -26,7 +26,7 @@ export const newMcpServer = () => new McpServer( { name: 'cas_parser_node_api', - version: '1.1.0', + version: '1.2.0', }, { capabilities: { tools: {}, logging: {} } }, ); @@ -80,12 +80,7 @@ export function init(params: { }; const client = - params.client || - new CasParser({ - environment: (readEnv('CAS_PARSER_ENVIRONMENT') || undefined) as any, - defaultHeaders: { 'X-Stainless-MCP': 'true' }, - logger: logger, - }); + params.client || new CasParser({ defaultHeaders: { 'X-Stainless-MCP': 'true' }, logger: logger }); server.setRequestHandler(ListToolsRequestSchema, async () => { return { diff --git a/src/client.ts b/src/client.ts index 2d2e581..bbfe9c2 100644 --- a/src/client.ts +++ b/src/client.ts @@ -42,12 +42,6 @@ import { } from './internal/utils/log'; import { isEmptyObj } from './internal/utils/values'; -const environments = { - production: 'https://portfolio-parser.api.casparser.in', - local: 'http://localhost:5000', -}; -type Environment = keyof typeof environments; - export interface ClientOptions { /** * Your API key for authentication. @@ -56,15 +50,6 @@ export interface ClientOptions { */ apiKey?: string | undefined; - /** - * Specifies the environment to use for the API. - * - * Each environment maps to a different base URL: - * - `production` corresponds to `https://portfolio-parser.api.casparser.in` - * - `local` corresponds to `http://localhost:5000` - */ - environment?: Environment | undefined; - /** * Override the default base URL for the API, e.g., "https://api.example.com/v2/" * @@ -156,7 +141,6 @@ export class CasParser { * API Client for interfacing with the Cas Parser API. * * @param {string | undefined} [opts.apiKey=process.env['CAS_PARSER_API_KEY'] ?? undefined] - * @param {Environment} [opts.environment=production] - Specifies the environment URL to use for the API. * @param {string} [opts.baseURL=process.env['CAS_PARSER_BASE_URL'] ?? https://portfolio-parser.api.casparser.in] - Override the default base URL for the API. * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out. * @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls. @@ -179,17 +163,10 @@ export class CasParser { const options: ClientOptions = { apiKey, ...opts, - baseURL, - environment: opts.environment ?? 'production', + baseURL: baseURL || `https://portfolio-parser.api.casparser.in`, }; - if (baseURL && opts.environment) { - throw new Errors.CasParserError( - 'Ambiguous URL; The `baseURL` option (or CAS_PARSER_BASE_URL env var) and the `environment` option are given. If you want to use the environment you must pass baseURL: null', - ); - } - - this.baseURL = options.baseURL || environments[options.environment || 'production']; + this.baseURL = options.baseURL!; this.timeout = options.timeout ?? CasParser.DEFAULT_TIMEOUT /* 1 minute */; this.logger = options.logger ?? console; const defaultLogLevel = 'warn'; @@ -215,8 +192,7 @@ export class CasParser { withOptions(options: Partial): this { const client = new (this.constructor as any as new (props: ClientOptions) => typeof this)({ ...this._options, - environment: options.environment ? options.environment : undefined, - baseURL: options.environment ? undefined : this.baseURL, + baseURL: this.baseURL, maxRetries: this.maxRetries, timeout: this.timeout, logger: this.logger, @@ -233,7 +209,7 @@ export class CasParser { * Check whether the base URL is set to its default. */ #baseURLOverridden(): boolean { - return this.baseURL !== environments[this._options.environment || 'production']; + return this.baseURL !== 'https://portfolio-parser.api.casparser.in'; } protected defaultQuery(): Record | undefined { diff --git a/src/version.ts b/src/version.ts index c80f975..54c8a47 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '1.1.0'; // x-release-please-version +export const VERSION = '1.2.0'; // x-release-please-version diff --git a/tests/index.test.ts b/tests/index.test.ts index f29d131..235b554 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -315,19 +315,6 @@ describe('instantiate client', () => { expect(client.baseURL).toEqual('https://portfolio-parser.api.casparser.in'); }); - test('env variable with environment', () => { - process.env['CAS_PARSER_BASE_URL'] = 'https://example.com/from_env'; - - expect( - () => new CasParser({ apiKey: 'My API Key', environment: 'production' }), - ).toThrowErrorMatchingInlineSnapshot( - `"Ambiguous URL; The \`baseURL\` option (or CAS_PARSER_BASE_URL env var) and the \`environment\` option are given. If you want to use the environment you must pass baseURL: null"`, - ); - - const client = new CasParser({ apiKey: 'My API Key', baseURL: null, environment: 'production' }); - expect(client.baseURL).toEqual('https://portfolio-parser.api.casparser.in'); - }); - test('in request options', () => { const client = new CasParser({ apiKey: 'My API Key' }); expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual(