From c7c17cd05e594d81b830765d2904c95b6387c1d1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 21 Feb 2026 21:17:47 +0000 Subject: [PATCH 1/6] feat(api): api update --- .stats.yml | 6 +- README.md | 20 +-- api.md | 34 ----- packages/mcp-server/src/code-tool.ts | 4 +- packages/mcp-server/src/methods.ts | 30 ---- src/client.ts | 32 ++--- src/resources/access-token.ts | 60 +------- src/resources/credits.ts | 55 +------- src/resources/index.ts | 14 +- src/resources/logs.ts | 167 +---------------------- src/resources/verify-token.ts | 33 +---- tests/api-resources/access-token.test.ts | 30 ---- tests/api-resources/credits.test.ts | 22 --- tests/api-resources/logs.test.ts | 60 -------- tests/api-resources/verify-token.test.ts | 22 --- 15 files changed, 31 insertions(+), 558 deletions(-) delete mode 100644 tests/api-resources/access-token.test.ts delete mode 100644 tests/api-resources/credits.test.ts delete mode 100644 tests/api-resources/logs.test.ts delete mode 100644 tests/api-resources/verify-token.test.ts diff --git a/.stats.yml b/.stats.yml index 56f5a81..80a6900 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 17 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-56b0f699c5437d9e5326626d35dfc972c17d01f12cb416c7f4854c8ea6d0e95e.yml -openapi_spec_hash: 158f405c1880706266d83e6ff16b9d2f +configured_endpoints: 12 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-6a9d3b677dcfb856dc571865c34b3fe401e4d7f0d799edfc743acb9a55800bd0.yml +openapi_spec_hash: 037703a6c741e4310fda3f57c22fa51e config_hash: 41c337f5cda03b13880617490f82bad0 diff --git a/README.md b/README.md index 5bca122..44c42bc 100644 --- a/README.md +++ b/README.md @@ -36,9 +36,9 @@ const client = new CasParser({ environment: 'environment_1', // or 'production' | 'environment_2'; defaults to 'production' }); -const response = await client.credits.check(); +const unifiedResponse = await client.camsKfintech.parse(); -console.log(response.enabled_features); +console.log(unifiedResponse.demat_accounts); ``` ### Request & Response types @@ -54,7 +54,7 @@ const client = new CasParser({ environment: 'environment_1', // or 'production' | 'environment_2'; defaults to 'production' }); -const response: CasParser.CreditCheckResponse = await client.credits.check(); +const unifiedResponse: CasParser.UnifiedResponse = await client.camsKfintech.parse(); ``` Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors. @@ -67,7 +67,7 @@ a subclass of `APIError` will be thrown: ```ts -const response = await client.credits.check().catch(async (err) => { +const unifiedResponse = await client.camsKfintech.parse().catch(async (err) => { if (err instanceof CasParser.APIError) { console.log(err.status); // 400 console.log(err.name); // BadRequestError @@ -107,7 +107,7 @@ const client = new CasParser({ }); // Or, configure per-request: -await client.credits.check({ +await client.camsKfintech.parse({ maxRetries: 5, }); ``` @@ -124,7 +124,7 @@ const client = new CasParser({ }); // Override per-request: -await client.credits.check({ +await client.camsKfintech.parse({ timeout: 5 * 1000, }); ``` @@ -147,13 +147,13 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse ```ts const client = new CasParser(); -const response = await client.credits.check().asResponse(); +const response = await client.camsKfintech.parse().asResponse(); console.log(response.headers.get('X-My-Header')); console.log(response.statusText); // access the underlying Response object -const { data: response, response: raw } = await client.credits.check().withResponse(); +const { data: unifiedResponse, response: raw } = await client.camsKfintech.parse().withResponse(); console.log(raw.headers.get('X-My-Header')); -console.log(response.enabled_features); +console.log(unifiedResponse.demat_accounts); ``` ### Logging @@ -233,7 +233,7 @@ parameter. This library doesn't validate at runtime that the request matches the send will be sent as-is. ```ts -client.credits.check({ +client.camsKfintech.parse({ // ... // @ts-expect-error baz is not yet public baz: 'undocumented option', diff --git a/api.md b/api.md index f660413..c699c73 100644 --- a/api.md +++ b/api.md @@ -1,45 +1,11 @@ # Credits -Types: - -- CreditCheckResponse - -Methods: - -- client.credits.check() -> CreditCheckResponse - # Logs -Types: - -- LogCreateResponse -- LogGetSummaryResponse - -Methods: - -- client.logs.create({ ...params }) -> LogCreateResponse -- client.logs.getSummary({ ...params }) -> LogGetSummaryResponse - # AccessToken -Types: - -- AccessTokenCreateResponse - -Methods: - -- client.accessToken.create({ ...params }) -> AccessTokenCreateResponse - # VerifyToken -Types: - -- VerifyTokenVerifyResponse - -Methods: - -- client.verifyToken.verify() -> VerifyTokenVerifyResponse - # CamsKfintech Types: diff --git a/packages/mcp-server/src/code-tool.ts b/packages/mcp-server/src/code-tool.ts index 0fdea1a..15ece6c 100644 --- a/packages/mcp-server/src/code-tool.ts +++ b/packages/mcp-server/src/code-tool.ts @@ -21,9 +21,9 @@ For example: \`\`\` async function run(client) { - const response = await client.credits.check(); + const unifiedResponse = await client.camsKfintech.parse(); - console.log(response.enabled_features); + console.log(unifiedResponse.demat_accounts); } \`\`\` diff --git a/packages/mcp-server/src/methods.ts b/packages/mcp-server/src/methods.ts index cc3ccfe..f378f2b 100644 --- a/packages/mcp-server/src/methods.ts +++ b/packages/mcp-server/src/methods.ts @@ -10,36 +10,6 @@ export type SdkMethod = { }; export const sdkMethods: SdkMethod[] = [ - { - clientCallName: 'client.credits.check', - fullyQualifiedName: 'credits.check', - httpMethod: 'post', - httpPath: '/credits', - }, - { - clientCallName: 'client.logs.create', - fullyQualifiedName: 'logs.create', - httpMethod: 'post', - httpPath: '/logs', - }, - { - clientCallName: 'client.logs.getSummary', - fullyQualifiedName: 'logs.getSummary', - httpMethod: 'post', - httpPath: '/logs/summary', - }, - { - clientCallName: 'client.accessToken.create', - fullyQualifiedName: 'accessToken.create', - httpMethod: 'post', - httpPath: '/v1/access-token', - }, - { - clientCallName: 'client.verifyToken.verify', - fullyQualifiedName: 'verifyToken.verify', - httpMethod: 'post', - httpPath: '/v1/verify-token', - }, { clientCallName: 'client.camsKfintech.parse', fullyQualifiedName: 'camsKfintech.parse', diff --git a/src/client.ts b/src/client.ts index bc8fec0..50b1bcb 100644 --- a/src/client.ts +++ b/src/client.ts @@ -16,7 +16,7 @@ import * as Errors from './core/error'; import * as Uploads from './core/uploads'; import * as API from './resources/index'; import { APIPromise } from './core/api-promise'; -import { AccessToken, AccessTokenCreateParams, AccessTokenCreateResponse } from './resources/access-token'; +import { AccessToken } from './resources/access-token'; import { CamsKfintech, CamsKfintechParseParams, @@ -25,7 +25,7 @@ import { UnifiedResponse, } from './resources/cams-kfintech'; import { ContractNote, ContractNoteParseParams, ContractNoteParseResponse } from './resources/contract-note'; -import { CreditCheckResponse, Credits } from './resources/credits'; +import { Credits } from './resources/credits'; import { Inbox, InboxCheckConnectionStatusParams, @@ -38,16 +38,10 @@ import { InboxListCasFilesResponse, } from './resources/inbox'; import { Kfintech, KfintechGenerateCasParams, KfintechGenerateCasResponse } from './resources/kfintech'; -import { - LogCreateParams, - LogCreateResponse, - LogGetSummaryParams, - LogGetSummaryResponse, - Logs, -} from './resources/logs'; +import { Logs } from './resources/logs'; import { Nsdl, NsdlParseParams } from './resources/nsdl'; import { Smart, SmartParseCasPdfParams } from './resources/smart'; -import { VerifyToken, VerifyTokenVerifyResponse } from './resources/verify-token'; +import { VerifyToken } from './resources/verify-token'; import { Cdsl, CdslParsePdfParams } from './resources/cdsl/cdsl'; import { type Fetch } from './internal/builtin-types'; import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers'; @@ -817,23 +811,13 @@ CasParser.Smart = Smart; export declare namespace CasParser { export type RequestOptions = Opts.RequestOptions; - export { Credits as Credits, type CreditCheckResponse as CreditCheckResponse }; + export { Credits as Credits }; - export { - Logs as Logs, - type LogCreateResponse as LogCreateResponse, - type LogGetSummaryResponse as LogGetSummaryResponse, - type LogCreateParams as LogCreateParams, - type LogGetSummaryParams as LogGetSummaryParams, - }; + export { Logs as Logs }; - export { - AccessToken as AccessToken, - type AccessTokenCreateResponse as AccessTokenCreateResponse, - type AccessTokenCreateParams as AccessTokenCreateParams, - }; + export { AccessToken as AccessToken }; - export { VerifyToken as VerifyToken, type VerifyTokenVerifyResponse as VerifyTokenVerifyResponse }; + export { VerifyToken as VerifyToken }; export { CamsKfintech as CamsKfintech, diff --git a/src/resources/access-token.ts b/src/resources/access-token.ts index e6927fc..62ba5f5 100644 --- a/src/resources/access-token.ts +++ b/src/resources/access-token.ts @@ -1,63 +1,5 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; -import { APIPromise } from '../core/api-promise'; -import { RequestOptions } from '../internal/request-options'; -export class AccessToken extends APIResource { - /** - * Generate a short-lived access token from your API key. - * - * **Use this endpoint from your backend** to create tokens that can be safely - * passed to frontend/SDK. - * - * Access tokens: - * - * - Are prefixed with `at_` for easy identification - * - Valid for up to 60 minutes - * - Can be used in place of API keys on all v4 endpoints - * - Cannot be used to generate other access tokens - * - * @example - * ```ts - * const accessToken = await client.accessToken.create(); - * ``` - */ - create( - body: AccessTokenCreateParams | null | undefined = {}, - options?: RequestOptions, - ): APIPromise { - return this._client.post('/v1/access-token', { body, ...options }); - } -} - -export interface AccessTokenCreateResponse { - /** - * The at\_ prefixed access token - */ - access_token?: string; - - /** - * Token validity in seconds - */ - expires_in?: number; - - /** - * Always "api_key" - token is a drop-in replacement for x-api-key header - */ - token_type?: string; -} - -export interface AccessTokenCreateParams { - /** - * Token validity in minutes (max 60) - */ - expiry_minutes?: number; -} - -export declare namespace AccessToken { - export { - type AccessTokenCreateResponse as AccessTokenCreateResponse, - type AccessTokenCreateParams as AccessTokenCreateParams, - }; -} +export class AccessToken extends APIResource {} diff --git a/src/resources/credits.ts b/src/resources/credits.ts index a174cfd..68c3387 100644 --- a/src/resources/credits.ts +++ b/src/resources/credits.ts @@ -1,58 +1,5 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; -import { APIPromise } from '../core/api-promise'; -import { RequestOptions } from '../internal/request-options'; -export class Credits extends APIResource { - /** - * Check your remaining API credits and usage for the current billing period. - * - * Returns: - * - * - Number of API calls used and remaining credits - * - Credit limit and reset date - * - List of enabled features for your plan - * - * Credits reset at the start of each billing period. - */ - check(options?: RequestOptions): APIPromise { - return this._client.post('/credits', options); - } -} - -export interface CreditCheckResponse { - /** - * List of API features enabled for your plan - */ - enabled_features?: Array; - - /** - * Whether the account has unlimited credits - */ - is_unlimited?: boolean; - - /** - * Total credit limit for billing period - */ - limit?: number; - - /** - * Remaining credits (null if unlimited) - */ - remaining?: number | null; - - /** - * When credits reset (ISO 8601) - */ - resets_at?: string | null; - - /** - * Number of credits used this billing period - */ - used?: number; -} - -export declare namespace Credits { - export { type CreditCheckResponse as CreditCheckResponse }; -} +export class Credits extends APIResource {} diff --git a/src/resources/index.ts b/src/resources/index.ts index ec82ade..7b19125 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { AccessToken, type AccessTokenCreateResponse, type AccessTokenCreateParams } from './access-token'; +export { AccessToken } from './access-token'; export { CamsKfintech, type LinkedHolder, @@ -10,7 +10,7 @@ export { } from './cams-kfintech'; export { Cdsl, type CdslParsePdfParams } from './cdsl/cdsl'; export { ContractNote, type ContractNoteParseResponse, type ContractNoteParseParams } from './contract-note'; -export { Credits, type CreditCheckResponse } from './credits'; +export { Credits } from './credits'; export { Inbox, type InboxCheckConnectionStatusResponse, @@ -23,13 +23,7 @@ export { type InboxListCasFilesParams, } from './inbox'; export { Kfintech, type KfintechGenerateCasResponse, type KfintechGenerateCasParams } from './kfintech'; -export { - Logs, - type LogCreateResponse, - type LogGetSummaryResponse, - type LogCreateParams, - type LogGetSummaryParams, -} from './logs'; +export { Logs } from './logs'; export { Nsdl, type NsdlParseParams } from './nsdl'; export { Smart, type SmartParseCasPdfParams } from './smart'; -export { VerifyToken, type VerifyTokenVerifyResponse } from './verify-token'; +export { VerifyToken } from './verify-token'; diff --git a/src/resources/logs.ts b/src/resources/logs.ts index 0279193..91b1b1f 100644 --- a/src/resources/logs.ts +++ b/src/resources/logs.ts @@ -1,170 +1,5 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; -import { APIPromise } from '../core/api-promise'; -import { RequestOptions } from '../internal/request-options'; -export class Logs extends APIResource { - /** - * Retrieve detailed API usage logs for your account. - * - * Returns a list of API calls with timestamps, features used, status codes, and - * credits consumed. Useful for monitoring usage patterns and debugging. - * - * @example - * ```ts - * const log = await client.logs.create(); - * ``` - */ - create( - body: LogCreateParams | null | undefined = {}, - options?: RequestOptions, - ): APIPromise { - return this._client.post('/logs', { body, ...options }); - } - - /** - * Get aggregated usage statistics grouped by feature. - * - * Useful for understanding which API features are being used most and tracking - * usage trends. - * - * @example - * ```ts - * const response = await client.logs.getSummary(); - * ``` - */ - getSummary( - body: LogGetSummaryParams | null | undefined = {}, - options?: RequestOptions, - ): APIPromise { - return this._client.post('/logs/summary', { body, ...options }); - } -} - -export interface LogCreateResponse { - /** - * Number of logs returned - */ - count?: number; - - logs?: Array; - - status?: string; -} - -export namespace LogCreateResponse { - export interface Log { - /** - * Credits consumed for this request - */ - credits?: number; - - /** - * API feature used - */ - feature?: string; - - /** - * API endpoint path - */ - path?: string; - - /** - * Unique request identifier - */ - request_id?: string; - - /** - * HTTP response status code - */ - status_code?: number; - - /** - * When the request was made - */ - timestamp?: string; - } -} - -export interface LogGetSummaryResponse { - status?: string; - - summary?: LogGetSummaryResponse.Summary; -} - -export namespace LogGetSummaryResponse { - export interface Summary { - /** - * Usage breakdown by feature - */ - by_feature?: Array; - - /** - * Total credits consumed in the period - */ - total_credits?: number; - - /** - * Total API requests made in the period - */ - total_requests?: number; - } - - export namespace Summary { - export interface ByFeature { - /** - * Credits consumed by this feature - */ - credits?: number; - - /** - * API feature name - */ - feature?: string; - - /** - * Number of requests for this feature - */ - requests?: number; - } - } -} - -export interface LogCreateParams { - /** - * End time filter (ISO 8601). Defaults to now. - */ - end_time?: string; - - /** - * Maximum number of logs to return - */ - limit?: number; - - /** - * Start time filter (ISO 8601). Defaults to 30 days ago. - */ - start_time?: string; -} - -export interface LogGetSummaryParams { - /** - * End time filter (ISO 8601). Defaults to now. - */ - end_time?: string; - - /** - * Start time filter (ISO 8601). Defaults to start of current month. - */ - start_time?: string; -} - -export declare namespace Logs { - export { - type LogCreateResponse as LogCreateResponse, - type LogGetSummaryResponse as LogGetSummaryResponse, - type LogCreateParams as LogCreateParams, - type LogGetSummaryParams as LogGetSummaryParams, - }; -} +export class Logs extends APIResource {} diff --git a/src/resources/verify-token.ts b/src/resources/verify-token.ts index 7e0f3c7..47a0821 100644 --- a/src/resources/verify-token.ts +++ b/src/resources/verify-token.ts @@ -1,36 +1,5 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; -import { APIPromise } from '../core/api-promise'; -import { RequestOptions } from '../internal/request-options'; -export class VerifyToken extends APIResource { - /** - * Verify an access token and check if it's still valid. Useful for debugging token - * issues. - */ - verify(options?: RequestOptions): APIPromise { - return this._client.post('/v1/verify-token', options); - } -} - -export interface VerifyTokenVerifyResponse { - /** - * Error message (only shown if invalid) - */ - error?: string; - - /** - * Masked API key (only shown if valid) - */ - masked_api_key?: string; - - /** - * Whether the token is valid - */ - valid?: boolean; -} - -export declare namespace VerifyToken { - export { type VerifyTokenVerifyResponse as VerifyTokenVerifyResponse }; -} +export class VerifyToken extends APIResource {} diff --git a/tests/api-resources/access-token.test.ts b/tests/api-resources/access-token.test.ts deleted file mode 100644 index 6559771..0000000 --- a/tests/api-resources/access-token.test.ts +++ /dev/null @@ -1,30 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import CasParser from 'cas-parser-node'; - -const client = new CasParser({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); - -describe('resource accessToken', () => { - // Mock server tests are disabled - test.skip('create', async () => { - const responsePromise = client.accessToken.create(); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - // Mock server tests are disabled - test.skip('create: request options and params are passed correctly', async () => { - // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.accessToken.create({ expiry_minutes: 60 }, { path: '/_stainless_unknown_path' }), - ).rejects.toThrow(CasParser.NotFoundError); - }); -}); diff --git a/tests/api-resources/credits.test.ts b/tests/api-resources/credits.test.ts deleted file mode 100644 index 3567262..0000000 --- a/tests/api-resources/credits.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import CasParser from 'cas-parser-node'; - -const client = new CasParser({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); - -describe('resource credits', () => { - // Mock server tests are disabled - test.skip('check', async () => { - const responsePromise = client.credits.check(); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); -}); diff --git a/tests/api-resources/logs.test.ts b/tests/api-resources/logs.test.ts deleted file mode 100644 index 2d1b99a..0000000 --- a/tests/api-resources/logs.test.ts +++ /dev/null @@ -1,60 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import CasParser from 'cas-parser-node'; - -const client = new CasParser({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); - -describe('resource logs', () => { - // Mock server tests are disabled - test.skip('create', async () => { - const responsePromise = client.logs.create(); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - // Mock server tests are disabled - test.skip('create: request options and params are passed correctly', async () => { - // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.logs.create( - { - end_time: '2026-01-31T23:59:59Z', - limit: 1, - start_time: '2026-01-01T00:00:00Z', - }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(CasParser.NotFoundError); - }); - - // Mock server tests are disabled - test.skip('getSummary', async () => { - const responsePromise = client.logs.getSummary(); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - // Mock server tests are disabled - test.skip('getSummary: request options and params are passed correctly', async () => { - // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.logs.getSummary( - { end_time: '2019-12-27T18:11:19.117Z', start_time: '2019-12-27T18:11:19.117Z' }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(CasParser.NotFoundError); - }); -}); diff --git a/tests/api-resources/verify-token.test.ts b/tests/api-resources/verify-token.test.ts deleted file mode 100644 index 75827c6..0000000 --- a/tests/api-resources/verify-token.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import CasParser from 'cas-parser-node'; - -const client = new CasParser({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); - -describe('resource verifyToken', () => { - // Mock server tests are disabled - test.skip('verify', async () => { - const responsePromise = client.verifyToken.verify(); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); -}); From a7e9bf9a5e23696d476b150f3149f853994d4f6c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 22 Feb 2026 23:17:58 +0000 Subject: [PATCH 2/6] feat(api): api update --- .stats.yml | 4 ++-- src/resources/inbox.ts | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 80a6900..1e5b8d1 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 12 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-6a9d3b677dcfb856dc571865c34b3fe401e4d7f0d799edfc743acb9a55800bd0.yml -openapi_spec_hash: 037703a6c741e4310fda3f57c22fa51e +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-e6762e83ef7cdff129d03d0ab8c130db2fb5d1d820142847c27d72b40a0e9f53.yml +openapi_spec_hash: f38fb40a2b28bae4b0c9c4228c1c0e0d config_hash: 41c337f5cda03b13880617490f82bad0 diff --git a/src/resources/inbox.ts b/src/resources/inbox.ts index a10151f..23c3f0e 100644 --- a/src/resources/inbox.ts +++ b/src/resources/inbox.ts @@ -204,6 +204,11 @@ export namespace InboxListCasFilesResponse { */ original_filename?: string; + /** + * Email address of the CAS authority who sent this + */ + sender_email?: string; + /** * File size in bytes */ From 58b6b46652f008b870fa189dc960c2d53e1a3887 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Feb 2026 00:17:50 +0000 Subject: [PATCH 3/6] feat(api): api update --- .stats.yml | 4 ++-- src/resources/inbox.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index 1e5b8d1..b880d0c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 12 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-e6762e83ef7cdff129d03d0ab8c130db2fb5d1d820142847c27d72b40a0e9f53.yml -openapi_spec_hash: f38fb40a2b28bae4b0c9c4228c1c0e0d +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-d9763d006969b49a1473851069fdfa429eb13133b64103a62963bb70ddb22305.yml +openapi_spec_hash: 6aee689b7a759b12c85c088c15e29bc0 config_hash: 41c337f5cda03b13880617490f82bad0 diff --git a/src/resources/inbox.ts b/src/resources/inbox.ts index 23c3f0e..693d7b9 100644 --- a/src/resources/inbox.ts +++ b/src/resources/inbox.ts @@ -205,7 +205,8 @@ export namespace InboxListCasFilesResponse { original_filename?: string; /** - * Email address of the CAS authority who sent this + * Email address of the CAS authority (CDSL, NSDL, CAMS, or KFintech) who + * originally sent this statement */ sender_email?: string; From d666a0b46b2d37de44fd443a92fd4b883a2ba98d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Feb 2026 02:53:21 +0000 Subject: [PATCH 4/6] feat(api): manual updates --- .stats.yml | 4 +- README.md | 20 +- api.md | 50 ++++ packages/mcp-server/src/code-tool.ts | 4 +- packages/mcp-server/src/methods.ts | 54 ++++ src/client.ts | 53 +++- src/resources/access-token.ts | 62 +++- src/resources/credits.ts | 55 +++- src/resources/inbound-email.ts | 332 ++++++++++++++++++++++ src/resources/index.ts | 23 +- src/resources/logs.ts | 171 ++++++++++- src/resources/verify-token.ts | 33 ++- tests/api-resources/access-token.test.ts | 30 ++ tests/api-resources/credits.test.ts | 22 ++ tests/api-resources/inbound-email.test.ts | 86 ++++++ tests/api-resources/logs.test.ts | 60 ++++ tests/api-resources/verify-token.test.ts | 22 ++ 17 files changed, 1051 insertions(+), 30 deletions(-) create mode 100644 src/resources/inbound-email.ts create mode 100644 tests/api-resources/access-token.test.ts create mode 100644 tests/api-resources/credits.test.ts create mode 100644 tests/api-resources/inbound-email.test.ts create mode 100644 tests/api-resources/logs.test.ts create mode 100644 tests/api-resources/verify-token.test.ts diff --git a/.stats.yml b/.stats.yml index b880d0c..cdf3c0a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 12 +configured_endpoints: 21 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-d9763d006969b49a1473851069fdfa429eb13133b64103a62963bb70ddb22305.yml openapi_spec_hash: 6aee689b7a759b12c85c088c15e29bc0 -config_hash: 41c337f5cda03b13880617490f82bad0 +config_hash: d54f39abb185904495bef7c5f8702746 diff --git a/README.md b/README.md index 44c42bc..5bca122 100644 --- a/README.md +++ b/README.md @@ -36,9 +36,9 @@ const client = new CasParser({ environment: 'environment_1', // or 'production' | 'environment_2'; defaults to 'production' }); -const unifiedResponse = await client.camsKfintech.parse(); +const response = await client.credits.check(); -console.log(unifiedResponse.demat_accounts); +console.log(response.enabled_features); ``` ### Request & Response types @@ -54,7 +54,7 @@ const client = new CasParser({ environment: 'environment_1', // or 'production' | 'environment_2'; defaults to 'production' }); -const unifiedResponse: CasParser.UnifiedResponse = await client.camsKfintech.parse(); +const response: CasParser.CreditCheckResponse = await client.credits.check(); ``` Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors. @@ -67,7 +67,7 @@ a subclass of `APIError` will be thrown: ```ts -const unifiedResponse = await client.camsKfintech.parse().catch(async (err) => { +const response = await client.credits.check().catch(async (err) => { if (err instanceof CasParser.APIError) { console.log(err.status); // 400 console.log(err.name); // BadRequestError @@ -107,7 +107,7 @@ const client = new CasParser({ }); // Or, configure per-request: -await client.camsKfintech.parse({ +await client.credits.check({ maxRetries: 5, }); ``` @@ -124,7 +124,7 @@ const client = new CasParser({ }); // Override per-request: -await client.camsKfintech.parse({ +await client.credits.check({ timeout: 5 * 1000, }); ``` @@ -147,13 +147,13 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse ```ts const client = new CasParser(); -const response = await client.camsKfintech.parse().asResponse(); +const response = await client.credits.check().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.camsKfintech.parse().withResponse(); +const { data: response, response: raw } = await client.credits.check().withResponse(); console.log(raw.headers.get('X-My-Header')); -console.log(unifiedResponse.demat_accounts); +console.log(response.enabled_features); ``` ### Logging @@ -233,7 +233,7 @@ parameter. This library doesn't validate at runtime that the request matches the send will be sent as-is. ```ts -client.camsKfintech.parse({ +client.credits.check({ // ... // @ts-expect-error baz is not yet public baz: 'undocumented option', diff --git a/api.md b/api.md index c699c73..50ab7c8 100644 --- a/api.md +++ b/api.md @@ -1,11 +1,45 @@ # Credits +Types: + +- CreditCheckResponse + +Methods: + +- client.credits.check() -> CreditCheckResponse + # Logs +Types: + +- LogCreateResponse +- LogGetSummaryResponse + +Methods: + +- client.logs.create({ ...params }) -> LogCreateResponse +- client.logs.getSummary({ ...params }) -> LogGetSummaryResponse + # AccessToken +Types: + +- AccessTokenCreateResponse + +Methods: + +- client.accessToken.create({ ...params }) -> AccessTokenCreateResponse + # VerifyToken +Types: + +- VerifyTokenVerifyResponse + +Methods: + +- client.verifyToken.verify() -> VerifyTokenVerifyResponse + # CamsKfintech Types: @@ -83,3 +117,19 @@ Methods: Methods: - client.smart.parseCasPdf({ ...params }) -> UnifiedResponse + +# InboundEmail + +Types: + +- InboundEmailCreateResponse +- InboundEmailRetrieveResponse +- InboundEmailListResponse +- InboundEmailDeleteResponse + +Methods: + +- client.inboundEmail.create({ ...params }) -> InboundEmailCreateResponse +- client.inboundEmail.retrieve(inboundEmailID) -> InboundEmailRetrieveResponse +- client.inboundEmail.list({ ...params }) -> InboundEmailListResponse +- client.inboundEmail.delete(inboundEmailID) -> InboundEmailDeleteResponse diff --git a/packages/mcp-server/src/code-tool.ts b/packages/mcp-server/src/code-tool.ts index 15ece6c..0fdea1a 100644 --- a/packages/mcp-server/src/code-tool.ts +++ b/packages/mcp-server/src/code-tool.ts @@ -21,9 +21,9 @@ For example: \`\`\` async function run(client) { - const unifiedResponse = await client.camsKfintech.parse(); + const response = await client.credits.check(); - console.log(unifiedResponse.demat_accounts); + console.log(response.enabled_features); } \`\`\` diff --git a/packages/mcp-server/src/methods.ts b/packages/mcp-server/src/methods.ts index f378f2b..61695cd 100644 --- a/packages/mcp-server/src/methods.ts +++ b/packages/mcp-server/src/methods.ts @@ -10,6 +10,36 @@ export type SdkMethod = { }; export const sdkMethods: SdkMethod[] = [ + { + clientCallName: 'client.credits.check', + fullyQualifiedName: 'credits.check', + httpMethod: 'post', + httpPath: '/v1/credits', + }, + { + clientCallName: 'client.logs.create', + fullyQualifiedName: 'logs.create', + httpMethod: 'post', + httpPath: '/v1/usage', + }, + { + clientCallName: 'client.logs.getSummary', + fullyQualifiedName: 'logs.getSummary', + httpMethod: 'post', + httpPath: '/v1/usage/summary', + }, + { + clientCallName: 'client.accessToken.create', + fullyQualifiedName: 'accessToken.create', + httpMethod: 'post', + httpPath: '/v1/token', + }, + { + clientCallName: 'client.verifyToken.verify', + fullyQualifiedName: 'verifyToken.verify', + httpMethod: 'post', + httpPath: '/v1/token/verify', + }, { clientCallName: 'client.camsKfintech.parse', fullyQualifiedName: 'camsKfintech.parse', @@ -82,6 +112,30 @@ export const sdkMethods: SdkMethod[] = [ httpMethod: 'post', httpPath: '/v4/smart/parse', }, + { + clientCallName: 'client.inboundEmail.create', + fullyQualifiedName: 'inboundEmail.create', + httpMethod: 'post', + httpPath: '/v4/inbound-email', + }, + { + clientCallName: 'client.inboundEmail.retrieve', + fullyQualifiedName: 'inboundEmail.retrieve', + httpMethod: 'get', + httpPath: '/v4/inbound-email/{inbound_email_id}', + }, + { + clientCallName: 'client.inboundEmail.list', + fullyQualifiedName: 'inboundEmail.list', + httpMethod: 'get', + httpPath: '/v4/inbound-email', + }, + { + clientCallName: 'client.inboundEmail.delete', + fullyQualifiedName: 'inboundEmail.delete', + httpMethod: 'delete', + httpPath: '/v4/inbound-email/{inbound_email_id}', + }, ]; function allowedMethodsForCodeTool(options: McpOptions | undefined): SdkMethod[] | undefined { diff --git a/src/client.ts b/src/client.ts index 50b1bcb..7a361c3 100644 --- a/src/client.ts +++ b/src/client.ts @@ -16,7 +16,7 @@ import * as Errors from './core/error'; import * as Uploads from './core/uploads'; import * as API from './resources/index'; import { APIPromise } from './core/api-promise'; -import { AccessToken } from './resources/access-token'; +import { AccessToken, AccessTokenCreateParams, AccessTokenCreateResponse } from './resources/access-token'; import { CamsKfintech, CamsKfintechParseParams, @@ -25,7 +25,16 @@ import { UnifiedResponse, } from './resources/cams-kfintech'; import { ContractNote, ContractNoteParseParams, ContractNoteParseResponse } from './resources/contract-note'; -import { Credits } from './resources/credits'; +import { CreditCheckResponse, Credits } from './resources/credits'; +import { + InboundEmail, + InboundEmailCreateParams, + InboundEmailCreateResponse, + InboundEmailDeleteResponse, + InboundEmailListParams, + InboundEmailListResponse, + InboundEmailRetrieveResponse, +} from './resources/inbound-email'; import { Inbox, InboxCheckConnectionStatusParams, @@ -38,10 +47,16 @@ import { InboxListCasFilesResponse, } from './resources/inbox'; import { Kfintech, KfintechGenerateCasParams, KfintechGenerateCasResponse } from './resources/kfintech'; -import { Logs } from './resources/logs'; +import { + LogCreateParams, + LogCreateResponse, + LogGetSummaryParams, + LogGetSummaryResponse, + Logs, +} from './resources/logs'; import { Nsdl, NsdlParseParams } from './resources/nsdl'; import { Smart, SmartParseCasPdfParams } from './resources/smart'; -import { VerifyToken } from './resources/verify-token'; +import { VerifyToken, VerifyTokenVerifyResponse } from './resources/verify-token'; import { Cdsl, CdslParsePdfParams } from './resources/cdsl/cdsl'; import { type Fetch } from './internal/builtin-types'; import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers'; @@ -794,6 +809,7 @@ export class CasParser { kfintech: API.Kfintech = new API.Kfintech(this); nsdl: API.Nsdl = new API.Nsdl(this); smart: API.Smart = new API.Smart(this); + inboundEmail: API.InboundEmail = new API.InboundEmail(this); } CasParser.Credits = Credits; @@ -807,17 +823,28 @@ CasParser.Inbox = Inbox; CasParser.Kfintech = Kfintech; CasParser.Nsdl = Nsdl; CasParser.Smart = Smart; +CasParser.InboundEmail = InboundEmail; export declare namespace CasParser { export type RequestOptions = Opts.RequestOptions; - export { Credits as Credits }; + export { Credits as Credits, type CreditCheckResponse as CreditCheckResponse }; - export { Logs as Logs }; + export { + Logs as Logs, + type LogCreateResponse as LogCreateResponse, + type LogGetSummaryResponse as LogGetSummaryResponse, + type LogCreateParams as LogCreateParams, + type LogGetSummaryParams as LogGetSummaryParams, + }; - export { AccessToken as AccessToken }; + export { + AccessToken as AccessToken, + type AccessTokenCreateResponse as AccessTokenCreateResponse, + type AccessTokenCreateParams as AccessTokenCreateParams, + }; - export { VerifyToken as VerifyToken }; + export { VerifyToken as VerifyToken, type VerifyTokenVerifyResponse as VerifyTokenVerifyResponse }; export { CamsKfintech as CamsKfintech, @@ -856,4 +883,14 @@ export declare namespace CasParser { export { Nsdl as Nsdl, type NsdlParseParams as NsdlParseParams }; export { Smart as Smart, type SmartParseCasPdfParams as SmartParseCasPdfParams }; + + export { + InboundEmail as InboundEmail, + type InboundEmailCreateResponse as InboundEmailCreateResponse, + type InboundEmailRetrieveResponse as InboundEmailRetrieveResponse, + type InboundEmailListResponse as InboundEmailListResponse, + type InboundEmailDeleteResponse as InboundEmailDeleteResponse, + type InboundEmailCreateParams as InboundEmailCreateParams, + type InboundEmailListParams as InboundEmailListParams, + }; } diff --git a/src/resources/access-token.ts b/src/resources/access-token.ts index 62ba5f5..14b5bb7 100644 --- a/src/resources/access-token.ts +++ b/src/resources/access-token.ts @@ -1,5 +1,65 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; +import { APIPromise } from '../core/api-promise'; +import { RequestOptions } from '../internal/request-options'; -export class AccessToken extends APIResource {} +export class AccessToken extends APIResource { + /** + * Generate a short-lived access token from your API key. + * + * **Use this endpoint from your backend** to create tokens that can be safely + * passed to frontend/SDK. + * + * **Legacy path:** `/v1/access-token` (still supported) + * + * Access tokens: + * + * - Are prefixed with `at_` for easy identification + * - Valid for up to 60 minutes + * - Can be used in place of API keys on all v4 endpoints + * - Cannot be used to generate other access tokens + * + * @example + * ```ts + * const accessToken = await client.accessToken.create(); + * ``` + */ + create( + body: AccessTokenCreateParams | null | undefined = {}, + options?: RequestOptions, + ): APIPromise { + return this._client.post('/v1/token', { body, ...options }); + } +} + +export interface AccessTokenCreateResponse { + /** + * The at\_ prefixed access token + */ + access_token?: string; + + /** + * Token validity in seconds + */ + expires_in?: number; + + /** + * Always "api_key" - token is a drop-in replacement for x-api-key header + */ + token_type?: string; +} + +export interface AccessTokenCreateParams { + /** + * Token validity in minutes (max 60) + */ + expiry_minutes?: number; +} + +export declare namespace AccessToken { + export { + type AccessTokenCreateResponse as AccessTokenCreateResponse, + type AccessTokenCreateParams as AccessTokenCreateParams, + }; +} diff --git a/src/resources/credits.ts b/src/resources/credits.ts index 68c3387..b72459e 100644 --- a/src/resources/credits.ts +++ b/src/resources/credits.ts @@ -1,5 +1,58 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; +import { APIPromise } from '../core/api-promise'; +import { RequestOptions } from '../internal/request-options'; -export class Credits extends APIResource {} +export class Credits extends APIResource { + /** + * Check your remaining API credits and usage for the current billing period. + * + * Returns: + * + * - Number of API calls used and remaining credits + * - Credit limit and reset date + * - List of enabled features for your plan + * + * Credits reset at the start of each billing period. + */ + check(options?: RequestOptions): APIPromise { + return this._client.post('/v1/credits', options); + } +} + +export interface CreditCheckResponse { + /** + * List of API features enabled for your plan + */ + enabled_features?: Array; + + /** + * Whether the account has unlimited credits + */ + is_unlimited?: boolean; + + /** + * Total credit limit for billing period + */ + limit?: number; + + /** + * Remaining credits (null if unlimited) + */ + remaining?: number | null; + + /** + * When credits reset (ISO 8601) + */ + resets_at?: string | null; + + /** + * Number of credits used this billing period + */ + used?: number; +} + +export declare namespace Credits { + export { type CreditCheckResponse as CreditCheckResponse }; +} diff --git a/src/resources/inbound-email.ts b/src/resources/inbound-email.ts new file mode 100644 index 0000000..7fb4d39 --- /dev/null +++ b/src/resources/inbound-email.ts @@ -0,0 +1,332 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../core/resource'; +import { APIPromise } from '../core/api-promise'; +import { RequestOptions } from '../internal/request-options'; +import { path } from '../internal/utils/path'; + +export class InboundEmail extends APIResource { + /** + * Create a dedicated inbound email address for collecting CAS statements via email + * forwarding. + * + * **How it works:** + * + * 1. Create an inbound email with your webhook URL + * 2. Display the email address to your user (e.g., "Forward your CAS to + * ie_xxx@import.casparser.in") + * 3. When an investor forwards a CAS email, we verify the sender and deliver to + * your webhook + * + * **Webhook Delivery:** + * + * - We POST to your `callback_url` with JSON body containing files (matching + * EmailCASFile schema) + * - Failed deliveries are retried automatically with exponential backoff + * + * **Inactivity:** + * + * - Inbound emails with no activity in 30 days are marked inactive + * - Active inbound emails remain operational indefinitely + * + * @example + * ```ts + * const inboundEmail = await client.inboundEmail.create({ + * callback_url: + * 'https://api.yourapp.com/webhooks/cas-email', + * }); + * ``` + */ + create(body: InboundEmailCreateParams, options?: RequestOptions): APIPromise { + return this._client.post('/v4/inbound-email', { body, ...options }); + } + + /** + * Retrieve details of a specific mailbox including statistics. + * + * @example + * ```ts + * const inboundEmail = await client.inboundEmail.retrieve( + * 'ie_a1b2c3d4e5f6', + * ); + * ``` + */ + retrieve(inboundEmailID: string, options?: RequestOptions): APIPromise { + return this._client.get(path`/v4/inbound-email/${inboundEmailID}`, options); + } + + /** + * List all mailboxes associated with your API key. Returns active and inactive + * mailboxes (deleted mailboxes are excluded). + * + * @example + * ```ts + * const inboundEmails = await client.inboundEmail.list(); + * ``` + */ + list( + query: InboundEmailListParams | null | undefined = {}, + options?: RequestOptions, + ): APIPromise { + return this._client.get('/v4/inbound-email', { query, ...options }); + } + + /** + * Permanently delete an inbound email address. It will stop accepting emails. + * + * **Note:** Deletion is immediate and cannot be undone. Any emails received after + * deletion will be rejected. + * + * @example + * ```ts + * const inboundEmail = await client.inboundEmail.delete( + * 'inbound_email_id', + * ); + * ``` + */ + delete(inboundEmailID: string, options?: RequestOptions): APIPromise { + return this._client.delete(path`/v4/inbound-email/${inboundEmailID}`, options); + } +} + +/** + * An inbound email address for receiving forwarded CAS emails + */ +export interface InboundEmailCreateResponse { + /** + * Accepted CAS providers (empty = all) + */ + allowed_sources?: Array<'cdsl' | 'nsdl' | 'cams' | 'kfintech'>; + + /** + * Webhook URL for email notifications + */ + callback_url?: string; + + /** + * When the mailbox was created + */ + created_at?: string; + + /** + * The inbound email address to forward CAS statements to + */ + email?: string; + + /** + * Unique inbound email identifier + */ + inbound_email_id?: string; + + /** + * Custom key-value metadata + */ + metadata?: { [key: string]: string }; + + /** + * Your internal reference identifier + */ + reference?: string | null; + + /** + * Current mailbox status + */ + status?: 'active' | 'paused'; + + /** + * When the mailbox was last updated + */ + updated_at?: string; +} + +/** + * An inbound email address for receiving forwarded CAS emails + */ +export interface InboundEmailRetrieveResponse { + /** + * Accepted CAS providers (empty = all) + */ + allowed_sources?: Array<'cdsl' | 'nsdl' | 'cams' | 'kfintech'>; + + /** + * Webhook URL for email notifications + */ + callback_url?: string; + + /** + * When the mailbox was created + */ + created_at?: string; + + /** + * The inbound email address to forward CAS statements to + */ + email?: string; + + /** + * Unique inbound email identifier + */ + inbound_email_id?: string; + + /** + * Custom key-value metadata + */ + metadata?: { [key: string]: string }; + + /** + * Your internal reference identifier + */ + reference?: string | null; + + /** + * Current mailbox status + */ + status?: 'active' | 'paused'; + + /** + * When the mailbox was last updated + */ + updated_at?: string; +} + +export interface InboundEmailListResponse { + inbound_emails?: Array; + + limit?: number; + + offset?: number; + + status?: string; + + /** + * Total number of inbound emails (for pagination) + */ + total?: number; +} + +export namespace InboundEmailListResponse { + /** + * An inbound email address for receiving forwarded CAS emails + */ + export interface InboundEmail { + /** + * Accepted CAS providers (empty = all) + */ + allowed_sources?: Array<'cdsl' | 'nsdl' | 'cams' | 'kfintech'>; + + /** + * Webhook URL for email notifications + */ + callback_url?: string; + + /** + * When the mailbox was created + */ + created_at?: string; + + /** + * The inbound email address to forward CAS statements to + */ + email?: string; + + /** + * Unique inbound email identifier + */ + inbound_email_id?: string; + + /** + * Custom key-value metadata + */ + metadata?: { [key: string]: string }; + + /** + * Your internal reference identifier + */ + reference?: string | null; + + /** + * Current mailbox status + */ + status?: 'active' | 'paused'; + + /** + * When the mailbox was last updated + */ + updated_at?: string; + } +} + +export interface InboundEmailDeleteResponse { + msg?: string; + + status?: string; +} + +export interface InboundEmailCreateParams { + /** + * Webhook URL where we POST email notifications. Must be HTTPS in production (HTTP + * allowed for localhost during development). + */ + callback_url: string; + + /** + * Optional custom email prefix for user-friendly addresses. + * + * - Must be 3-32 characters + * - Alphanumeric + hyphens only + * - Must start and end with letter/number + * - Example: `john-portfolio@import.casparser.in` + * - If omitted, generates random ID like `ie_abc123xyz@import.casparser.in` + */ + alias?: string; + + /** + * Filter emails by CAS provider. If omitted, accepts all providers. + * + * - `cdsl` → eCAS@cdslstatement.com + * - `nsdl` → NSDL-CAS@nsdl.co.in + * - `cams` → donotreply@camsonline.com + * - `kfintech` → samfS@kfintech.com + */ + allowed_sources?: Array<'cdsl' | 'nsdl' | 'cams' | 'kfintech'>; + + /** + * Optional key-value pairs (max 10) to include in webhook payload. Useful for + * passing context like plan_type, campaign_id, etc. + */ + metadata?: { [key: string]: string }; + + /** + * Your internal identifier (e.g., user_id, account_id). Returned in webhook + * payload for correlation. + */ + reference?: string; +} + +export interface InboundEmailListParams { + /** + * Maximum number of inbound emails to return + */ + limit?: number; + + /** + * Pagination offset + */ + offset?: number; + + /** + * Filter by status + */ + status?: 'active' | 'paused' | 'all'; +} + +export declare namespace InboundEmail { + export { + type InboundEmailCreateResponse as InboundEmailCreateResponse, + type InboundEmailRetrieveResponse as InboundEmailRetrieveResponse, + type InboundEmailListResponse as InboundEmailListResponse, + type InboundEmailDeleteResponse as InboundEmailDeleteResponse, + type InboundEmailCreateParams as InboundEmailCreateParams, + type InboundEmailListParams as InboundEmailListParams, + }; +} diff --git a/src/resources/index.ts b/src/resources/index.ts index 7b19125..6ff779e 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { AccessToken } from './access-token'; +export { AccessToken, type AccessTokenCreateResponse, type AccessTokenCreateParams } from './access-token'; export { CamsKfintech, type LinkedHolder, @@ -10,7 +10,16 @@ export { } from './cams-kfintech'; export { Cdsl, type CdslParsePdfParams } from './cdsl/cdsl'; export { ContractNote, type ContractNoteParseResponse, type ContractNoteParseParams } from './contract-note'; -export { Credits } from './credits'; +export { Credits, type CreditCheckResponse } from './credits'; +export { + InboundEmail, + type InboundEmailCreateResponse, + type InboundEmailRetrieveResponse, + type InboundEmailListResponse, + type InboundEmailDeleteResponse, + type InboundEmailCreateParams, + type InboundEmailListParams, +} from './inbound-email'; export { Inbox, type InboxCheckConnectionStatusResponse, @@ -23,7 +32,13 @@ export { type InboxListCasFilesParams, } from './inbox'; export { Kfintech, type KfintechGenerateCasResponse, type KfintechGenerateCasParams } from './kfintech'; -export { Logs } from './logs'; +export { + Logs, + type LogCreateResponse, + type LogGetSummaryResponse, + type LogCreateParams, + type LogGetSummaryParams, +} from './logs'; export { Nsdl, type NsdlParseParams } from './nsdl'; export { Smart, type SmartParseCasPdfParams } from './smart'; -export { VerifyToken } from './verify-token'; +export { VerifyToken, type VerifyTokenVerifyResponse } from './verify-token'; diff --git a/src/resources/logs.ts b/src/resources/logs.ts index 91b1b1f..9e235bc 100644 --- a/src/resources/logs.ts +++ b/src/resources/logs.ts @@ -1,5 +1,174 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; +import { APIPromise } from '../core/api-promise'; +import { RequestOptions } from '../internal/request-options'; -export class Logs extends APIResource {} +export class Logs extends APIResource { + /** + * Retrieve detailed API usage logs for your account. + * + * Returns a list of API calls with timestamps, features used, status codes, and + * credits consumed. Useful for monitoring usage patterns and debugging. + * + * **Legacy path:** `/logs` (still supported) + * + * @example + * ```ts + * const log = await client.logs.create(); + * ``` + */ + create( + body: LogCreateParams | null | undefined = {}, + options?: RequestOptions, + ): APIPromise { + return this._client.post('/v1/usage', { body, ...options }); + } + + /** + * Get aggregated usage statistics grouped by feature. + * + * Useful for understanding which API features are being used most and tracking + * usage trends. + * + * **Legacy path:** `/logs/summary` (still supported) + * + * @example + * ```ts + * const response = await client.logs.getSummary(); + * ``` + */ + getSummary( + body: LogGetSummaryParams | null | undefined = {}, + options?: RequestOptions, + ): APIPromise { + return this._client.post('/v1/usage/summary', { body, ...options }); + } +} + +export interface LogCreateResponse { + /** + * Number of logs returned + */ + count?: number; + + logs?: Array; + + status?: string; +} + +export namespace LogCreateResponse { + export interface Log { + /** + * Credits consumed for this request + */ + credits?: number; + + /** + * API feature used + */ + feature?: string; + + /** + * API endpoint path + */ + path?: string; + + /** + * Unique request identifier + */ + request_id?: string; + + /** + * HTTP response status code + */ + status_code?: number; + + /** + * When the request was made + */ + timestamp?: string; + } +} + +export interface LogGetSummaryResponse { + status?: string; + + summary?: LogGetSummaryResponse.Summary; +} + +export namespace LogGetSummaryResponse { + export interface Summary { + /** + * Usage breakdown by feature + */ + by_feature?: Array; + + /** + * Total credits consumed in the period + */ + total_credits?: number; + + /** + * Total API requests made in the period + */ + total_requests?: number; + } + + export namespace Summary { + export interface ByFeature { + /** + * Credits consumed by this feature + */ + credits?: number; + + /** + * API feature name + */ + feature?: string; + + /** + * Number of requests for this feature + */ + requests?: number; + } + } +} + +export interface LogCreateParams { + /** + * End time filter (ISO 8601). Defaults to now. + */ + end_time?: string; + + /** + * Maximum number of logs to return + */ + limit?: number; + + /** + * Start time filter (ISO 8601). Defaults to 30 days ago. + */ + start_time?: string; +} + +export interface LogGetSummaryParams { + /** + * End time filter (ISO 8601). Defaults to now. + */ + end_time?: string; + + /** + * Start time filter (ISO 8601). Defaults to start of current month. + */ + start_time?: string; +} + +export declare namespace Logs { + export { + type LogCreateResponse as LogCreateResponse, + type LogGetSummaryResponse as LogGetSummaryResponse, + type LogCreateParams as LogCreateParams, + type LogGetSummaryParams as LogGetSummaryParams, + }; +} diff --git a/src/resources/verify-token.ts b/src/resources/verify-token.ts index 47a0821..46dfd64 100644 --- a/src/resources/verify-token.ts +++ b/src/resources/verify-token.ts @@ -1,5 +1,36 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; +import { APIPromise } from '../core/api-promise'; +import { RequestOptions } from '../internal/request-options'; -export class VerifyToken extends APIResource {} +export class VerifyToken extends APIResource { + /** + * Verify an access token and check if it's still valid. Useful for debugging token + * issues. + */ + verify(options?: RequestOptions): APIPromise { + return this._client.post('/v1/token/verify', options); + } +} + +export interface VerifyTokenVerifyResponse { + /** + * Error message (only shown if invalid) + */ + error?: string; + + /** + * Masked API key (only shown if valid) + */ + masked_api_key?: string; + + /** + * Whether the token is valid + */ + valid?: boolean; +} + +export declare namespace VerifyToken { + export { type VerifyTokenVerifyResponse as VerifyTokenVerifyResponse }; +} diff --git a/tests/api-resources/access-token.test.ts b/tests/api-resources/access-token.test.ts new file mode 100644 index 0000000..6559771 --- /dev/null +++ b/tests/api-resources/access-token.test.ts @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import CasParser from 'cas-parser-node'; + +const client = new CasParser({ + apiKey: 'My API Key', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource accessToken', () => { + // Mock server tests are disabled + test.skip('create', async () => { + const responsePromise = client.accessToken.create(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + // Mock server tests are disabled + test.skip('create: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.accessToken.create({ expiry_minutes: 60 }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(CasParser.NotFoundError); + }); +}); diff --git a/tests/api-resources/credits.test.ts b/tests/api-resources/credits.test.ts new file mode 100644 index 0000000..3567262 --- /dev/null +++ b/tests/api-resources/credits.test.ts @@ -0,0 +1,22 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import CasParser from 'cas-parser-node'; + +const client = new CasParser({ + apiKey: 'My API Key', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource credits', () => { + // Mock server tests are disabled + test.skip('check', async () => { + const responsePromise = client.credits.check(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); +}); diff --git a/tests/api-resources/inbound-email.test.ts b/tests/api-resources/inbound-email.test.ts new file mode 100644 index 0000000..6a69ced --- /dev/null +++ b/tests/api-resources/inbound-email.test.ts @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import CasParser from 'cas-parser-node'; + +const client = new CasParser({ + apiKey: 'My API Key', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource inboundEmail', () => { + // Mock server tests are disabled + test.skip('create: only required params', async () => { + const responsePromise = client.inboundEmail.create({ + callback_url: 'https://api.yourapp.com/webhooks/cas-email', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + // Mock server tests are disabled + test.skip('create: required and optional params', async () => { + const response = await client.inboundEmail.create({ + callback_url: 'https://api.yourapp.com/webhooks/cas-email', + alias: 'john-portfolio', + allowed_sources: ['cdsl', 'nsdl'], + metadata: { plan: 'premium', source: 'onboarding' }, + reference: 'user_12345', + }); + }); + + // Mock server tests are disabled + test.skip('retrieve', async () => { + const responsePromise = client.inboundEmail.retrieve('ie_a1b2c3d4e5f6'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + // Mock server tests are disabled + test.skip('list', async () => { + const responsePromise = client.inboundEmail.list(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + // Mock server tests are disabled + test.skip('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.inboundEmail.list( + { + limit: 1, + offset: 0, + status: 'active', + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(CasParser.NotFoundError); + }); + + // Mock server tests are disabled + test.skip('delete', async () => { + const responsePromise = client.inboundEmail.delete('inbound_email_id'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); +}); diff --git a/tests/api-resources/logs.test.ts b/tests/api-resources/logs.test.ts new file mode 100644 index 0000000..2d1b99a --- /dev/null +++ b/tests/api-resources/logs.test.ts @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import CasParser from 'cas-parser-node'; + +const client = new CasParser({ + apiKey: 'My API Key', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource logs', () => { + // Mock server tests are disabled + test.skip('create', async () => { + const responsePromise = client.logs.create(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + // Mock server tests are disabled + test.skip('create: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.logs.create( + { + end_time: '2026-01-31T23:59:59Z', + limit: 1, + start_time: '2026-01-01T00:00:00Z', + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(CasParser.NotFoundError); + }); + + // Mock server tests are disabled + test.skip('getSummary', async () => { + const responsePromise = client.logs.getSummary(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + // Mock server tests are disabled + test.skip('getSummary: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.logs.getSummary( + { end_time: '2019-12-27T18:11:19.117Z', start_time: '2019-12-27T18:11:19.117Z' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(CasParser.NotFoundError); + }); +}); diff --git a/tests/api-resources/verify-token.test.ts b/tests/api-resources/verify-token.test.ts new file mode 100644 index 0000000..75827c6 --- /dev/null +++ b/tests/api-resources/verify-token.test.ts @@ -0,0 +1,22 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import CasParser from 'cas-parser-node'; + +const client = new CasParser({ + apiKey: 'My API Key', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource verifyToken', () => { + // Mock server tests are disabled + test.skip('verify', async () => { + const responsePromise = client.verifyToken.verify(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); +}); From e9d319c20752644952c809d3416d44260b3530b7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Feb 2026 03:00:51 +0000 Subject: [PATCH 5/6] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index cdf3c0a..49508b3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 21 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-d9763d006969b49a1473851069fdfa429eb13133b64103a62963bb70ddb22305.yml openapi_spec_hash: 6aee689b7a759b12c85c088c15e29bc0 -config_hash: d54f39abb185904495bef7c5f8702746 +config_hash: 4ab3e1ee76a463e0ed214541260ee12e From f75044ccb9f2c510be06f3e1efaa5ef38b6aae99 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Feb 2026 03:01:06 +0000 Subject: [PATCH 6/6] release: 1.8.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 11 +++++++++++ package.json | 2 +- packages/mcp-server/manifest.json | 2 +- packages/mcp-server/package.json | 2 +- packages/mcp-server/src/server.ts | 2 +- src/version.ts | 2 +- 7 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index f2ada20..099626f 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.7.2" + ".": "1.8.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fd105c..02e2bc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## 1.8.0 (2026-02-23) + +Full Changelog: [v1.7.2...v1.8.0](https://github.com/CASParser/cas-parser-node/compare/v1.7.2...v1.8.0) + +### Features + +* **api:** api update ([58b6b46](https://github.com/CASParser/cas-parser-node/commit/58b6b46652f008b870fa189dc960c2d53e1a3887)) +* **api:** api update ([a7e9bf9](https://github.com/CASParser/cas-parser-node/commit/a7e9bf9a5e23696d476b150f3149f853994d4f6c)) +* **api:** api update ([c7c17cd](https://github.com/CASParser/cas-parser-node/commit/c7c17cd05e594d81b830765d2904c95b6387c1d1)) +* **api:** manual updates ([d666a0b](https://github.com/CASParser/cas-parser-node/commit/d666a0b46b2d37de44fd443a92fd4b883a2ba98d)) + ## 1.7.2 (2026-02-20) Full Changelog: [v1.7.1...v1.7.2](https://github.com/CASParser/cas-parser-node/compare/v1.7.1...v1.7.2) diff --git a/package.json b/package.json index 8f8f6af..9ee2bf9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cas-parser-node", - "version": "1.7.2", + "version": "1.8.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/manifest.json b/packages/mcp-server/manifest.json index da878ae..d6d4673 100644 --- a/packages/mcp-server/manifest.json +++ b/packages/mcp-server/manifest.json @@ -1,7 +1,7 @@ { "dxt_version": "0.2", "name": "cas-parser-node-mcp", - "version": "1.7.2", + "version": "1.8.0", "description": "The official MCP Server for the Cas Parser API", "author": { "name": "Cas Parser", diff --git a/packages/mcp-server/package.json b/packages/mcp-server/package.json index 5b787e2..2ef90ea 100644 --- a/packages/mcp-server/package.json +++ b/packages/mcp-server/package.json @@ -1,6 +1,6 @@ { "name": "cas-parser-node-mcp", - "version": "1.7.2", + "version": "1.8.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 9112f69..aa20a3e 100644 --- a/packages/mcp-server/src/server.ts +++ b/packages/mcp-server/src/server.ts @@ -21,7 +21,7 @@ export const newMcpServer = async (stainlessApiKey: string | undefined) => new McpServer( { name: 'cas_parser_node_api', - version: '1.7.2', + version: '1.8.0', }, { instructions: await getInstructions(stainlessApiKey), diff --git a/src/version.ts b/src/version.ts index c742ace..29d3ce7 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '1.7.2'; // x-release-please-version +export const VERSION = '1.8.0'; // x-release-please-version