cas-parser-node 1.4.1 → 1.6.2
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/CHANGELOG.md +104 -0
- package/LICENSE +1 -1
- package/README.md +30 -32
- package/client.d.mts +51 -7
- package/client.d.mts.map +1 -1
- package/client.d.ts +51 -7
- package/client.d.ts.map +1 -1
- package/client.js +56 -12
- package/client.js.map +1 -1
- package/client.mjs +56 -12
- package/client.mjs.map +1 -1
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +5 -0
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +5 -0
- package/internal/parse.mjs.map +1 -1
- package/internal/to-file.d.mts +1 -1
- package/internal/to-file.d.ts +1 -1
- package/internal/to-file.js +1 -1
- package/internal/to-file.mjs +1 -1
- package/internal/tslib.js +17 -17
- package/package.json +9 -10
- package/resources/access-token.d.mts +48 -0
- package/resources/access-token.d.mts.map +1 -0
- package/resources/access-token.d.ts +48 -0
- package/resources/access-token.d.ts.map +1 -0
- package/resources/access-token.js +30 -0
- package/resources/access-token.js.map +1 -0
- package/resources/access-token.mjs +26 -0
- package/resources/access-token.mjs.map +1 -0
- package/resources/{cas-parser.d.mts → cams-kfintech.d.mts} +282 -105
- package/resources/cams-kfintech.d.mts.map +1 -0
- package/resources/{cas-parser.d.ts → cams-kfintech.d.ts} +282 -105
- package/resources/cams-kfintech.d.ts.map +1 -0
- package/resources/cams-kfintech.js +18 -0
- package/resources/cams-kfintech.js.map +1 -0
- package/resources/cams-kfintech.mjs +14 -0
- package/resources/cams-kfintech.mjs.map +1 -0
- package/resources/cdsl/cdsl.d.mts +39 -0
- package/resources/cdsl/cdsl.d.mts.map +1 -0
- package/resources/cdsl/cdsl.d.ts +39 -0
- package/resources/cdsl/cdsl.d.ts.map +1 -0
- package/resources/cdsl/cdsl.js +31 -0
- package/resources/cdsl/cdsl.js.map +1 -0
- package/resources/cdsl/cdsl.mjs +26 -0
- package/resources/cdsl/cdsl.mjs.map +1 -0
- package/resources/cdsl/fetch.d.mts +91 -0
- package/resources/cdsl/fetch.d.mts.map +1 -0
- package/resources/cdsl/fetch.d.ts +91 -0
- package/resources/cdsl/fetch.d.ts.map +1 -0
- package/resources/cdsl/fetch.js +50 -0
- package/resources/cdsl/fetch.js.map +1 -0
- package/resources/cdsl/fetch.mjs +46 -0
- package/resources/cdsl/fetch.mjs.map +1 -0
- package/resources/cdsl/index.d.mts +3 -0
- package/resources/cdsl/index.d.mts.map +1 -0
- package/resources/cdsl/index.d.ts +3 -0
- package/resources/cdsl/index.d.ts.map +1 -0
- package/resources/cdsl/index.js +9 -0
- package/resources/cdsl/index.js.map +1 -0
- package/resources/cdsl/index.mjs +4 -0
- package/resources/cdsl/index.mjs.map +1 -0
- package/resources/cdsl.d.mts +2 -0
- package/resources/cdsl.d.mts.map +1 -0
- package/resources/cdsl.d.ts +2 -0
- package/resources/cdsl.d.ts.map +1 -0
- package/resources/cdsl.js +6 -0
- package/resources/cdsl.js.map +1 -0
- package/resources/cdsl.mjs +3 -0
- package/resources/cdsl.mjs.map +1 -0
- package/resources/contract-note.d.mts +323 -0
- package/resources/contract-note.d.mts.map +1 -0
- package/resources/contract-note.d.ts +323 -0
- package/resources/contract-note.d.ts.map +1 -0
- package/resources/contract-note.js +49 -0
- package/resources/contract-note.js.map +1 -0
- package/resources/contract-note.mjs +45 -0
- package/resources/contract-note.mjs.map +1 -0
- package/resources/credits.d.mts +47 -0
- package/resources/credits.d.mts.map +1 -0
- package/resources/credits.d.ts +47 -0
- package/resources/credits.d.ts.map +1 -0
- package/resources/credits.js +23 -0
- package/resources/credits.js.map +1 -0
- package/resources/credits.mjs +19 -0
- package/resources/credits.mjs.map +1 -0
- package/resources/inbox.d.mts +206 -0
- package/resources/inbox.d.mts.map +1 -0
- package/resources/inbox.d.ts +206 -0
- package/resources/inbox.d.ts.map +1 -0
- package/resources/inbox.js +109 -0
- package/resources/inbox.js.map +1 -0
- package/resources/inbox.mjs +105 -0
- package/resources/inbox.mjs.map +1 -0
- package/resources/index.d.mts +11 -2
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +11 -2
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +23 -5
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +11 -2
- package/resources/index.mjs.map +1 -1
- package/resources/kfintech.d.mts +53 -0
- package/resources/kfintech.d.mts.map +1 -0
- package/resources/kfintech.d.ts +53 -0
- package/resources/kfintech.d.ts.map +1 -0
- package/resources/kfintech.js +29 -0
- package/resources/kfintech.js.map +1 -0
- package/resources/kfintech.mjs +25 -0
- package/resources/kfintech.mjs.map +1 -0
- package/resources/logs.d.mts +129 -0
- package/resources/logs.d.mts.map +1 -0
- package/resources/logs.d.ts +129 -0
- package/resources/logs.d.ts.map +1 -0
- package/resources/logs.js +37 -0
- package/resources/logs.js.map +1 -0
- package/resources/logs.mjs +33 -0
- package/resources/logs.mjs.map +1 -0
- package/resources/nsdl.d.mts +30 -0
- package/resources/nsdl.d.mts.map +1 -0
- package/resources/nsdl.d.ts +30 -0
- package/resources/nsdl.d.ts.map +1 -0
- package/resources/nsdl.js +18 -0
- package/resources/nsdl.js.map +1 -0
- package/resources/nsdl.mjs +14 -0
- package/resources/nsdl.mjs.map +1 -0
- package/resources/smart.d.mts +31 -0
- package/resources/smart.d.mts.map +1 -0
- package/resources/smart.d.ts +31 -0
- package/resources/smart.d.ts.map +1 -0
- package/resources/smart.js +19 -0
- package/resources/smart.js.map +1 -0
- package/resources/smart.mjs +15 -0
- package/resources/smart.mjs.map +1 -0
- package/resources/verify-token.d.mts +28 -0
- package/resources/verify-token.d.mts.map +1 -0
- package/resources/verify-token.d.ts +28 -0
- package/resources/verify-token.d.ts.map +1 -0
- package/resources/verify-token.js +16 -0
- package/resources/verify-token.js.map +1 -0
- package/resources/verify-token.mjs +12 -0
- package/resources/verify-token.mjs.map +1 -0
- package/src/client.ts +143 -31
- package/src/internal/parse.ts +6 -0
- package/src/internal/to-file.ts +1 -1
- package/src/resources/access-token.ts +63 -0
- package/src/resources/{cas-parser.ts → cams-kfintech.ts} +340 -130
- package/src/resources/cdsl/cdsl.ts +67 -0
- package/src/resources/cdsl/fetch.ts +122 -0
- package/src/resources/cdsl/index.ts +10 -0
- package/src/resources/cdsl.ts +3 -0
- package/src/resources/contract-note.ts +402 -0
- package/src/resources/credits.ts +58 -0
- package/src/resources/inbox.ts +283 -0
- package/src/resources/index.ts +31 -11
- package/src/resources/kfintech.ts +71 -0
- package/src/resources/logs.ts +170 -0
- package/src/resources/nsdl.ts +42 -0
- package/src/resources/smart.ts +46 -0
- package/src/resources/verify-token.ts +36 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/resources/cas-generator.d.mts +0 -56
- package/resources/cas-generator.d.mts.map +0 -1
- package/resources/cas-generator.d.ts +0 -56
- package/resources/cas-generator.d.ts.map +0 -1
- package/resources/cas-generator.js +0 -27
- package/resources/cas-generator.js.map +0 -1
- package/resources/cas-generator.mjs +0 -23
- package/resources/cas-generator.mjs.map +0 -1
- package/resources/cas-parser.d.mts.map +0 -1
- package/resources/cas-parser.d.ts.map +0 -1
- package/resources/cas-parser.js +0 -43
- package/resources/cas-parser.js.map +0 -1
- package/resources/cas-parser.mjs +0 -39
- package/resources/cas-parser.mjs.map +0 -1
- package/src/resources/cas-generator.ts +0 -75
package/src/client.ts
CHANGED
|
@@ -16,19 +16,39 @@ import * as Errors from './core/error';
|
|
|
16
16
|
import * as Uploads from './core/uploads';
|
|
17
17
|
import * as API from './resources/index';
|
|
18
18
|
import { APIPromise } from './core/api-promise';
|
|
19
|
+
import { AccessToken, AccessTokenCreateParams, AccessTokenCreateResponse } from './resources/access-token';
|
|
19
20
|
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
import {
|
|
25
|
-
CasParserCamsKfintechParams,
|
|
26
|
-
CasParserCdslParams,
|
|
27
|
-
CasParserNsdlParams,
|
|
28
|
-
CasParserResource,
|
|
29
|
-
CasParserSmartParseParams,
|
|
21
|
+
CamsKfintech,
|
|
22
|
+
CamsKfintechParseParams,
|
|
23
|
+
LinkedHolder,
|
|
24
|
+
Transaction,
|
|
30
25
|
UnifiedResponse,
|
|
31
|
-
} from './resources/
|
|
26
|
+
} from './resources/cams-kfintech';
|
|
27
|
+
import { ContractNote, ContractNoteParseParams, ContractNoteParseResponse } from './resources/contract-note';
|
|
28
|
+
import { CreditCheckResponse, Credits } from './resources/credits';
|
|
29
|
+
import {
|
|
30
|
+
Inbox,
|
|
31
|
+
InboxCheckConnectionStatusParams,
|
|
32
|
+
InboxCheckConnectionStatusResponse,
|
|
33
|
+
InboxConnectEmailParams,
|
|
34
|
+
InboxConnectEmailResponse,
|
|
35
|
+
InboxDisconnectEmailParams,
|
|
36
|
+
InboxDisconnectEmailResponse,
|
|
37
|
+
InboxListCasFilesParams,
|
|
38
|
+
InboxListCasFilesResponse,
|
|
39
|
+
} from './resources/inbox';
|
|
40
|
+
import { Kfintech, KfintechGenerateCasParams, KfintechGenerateCasResponse } from './resources/kfintech';
|
|
41
|
+
import {
|
|
42
|
+
LogCreateParams,
|
|
43
|
+
LogCreateResponse,
|
|
44
|
+
LogGetSummaryParams,
|
|
45
|
+
LogGetSummaryResponse,
|
|
46
|
+
Logs,
|
|
47
|
+
} from './resources/logs';
|
|
48
|
+
import { Nsdl, NsdlParseParams } from './resources/nsdl';
|
|
49
|
+
import { Smart, SmartParseCasPdfParams } from './resources/smart';
|
|
50
|
+
import { VerifyToken, VerifyTokenVerifyResponse } from './resources/verify-token';
|
|
51
|
+
import { Cdsl, CdslParsePdfParams } from './resources/cdsl/cdsl';
|
|
32
52
|
import { type Fetch } from './internal/builtin-types';
|
|
33
53
|
import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
|
|
34
54
|
import { FinalRequestOptions, RequestOptions } from './internal/request-options';
|
|
@@ -42,6 +62,13 @@ import {
|
|
|
42
62
|
} from './internal/utils/log';
|
|
43
63
|
import { isEmptyObj } from './internal/utils/values';
|
|
44
64
|
|
|
65
|
+
const environments = {
|
|
66
|
+
production: 'https://portfolio-parser.api.casparser.in',
|
|
67
|
+
environment_1: 'https://client-apis.casparser.in',
|
|
68
|
+
environment_2: 'http://localhost:5000',
|
|
69
|
+
};
|
|
70
|
+
type Environment = keyof typeof environments;
|
|
71
|
+
|
|
45
72
|
export interface ClientOptions {
|
|
46
73
|
/**
|
|
47
74
|
* Your API key for authentication.
|
|
@@ -50,6 +77,16 @@ export interface ClientOptions {
|
|
|
50
77
|
*/
|
|
51
78
|
apiKey?: string | undefined;
|
|
52
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Specifies the environment to use for the API.
|
|
82
|
+
*
|
|
83
|
+
* Each environment maps to a different base URL:
|
|
84
|
+
* - `production` corresponds to `https://portfolio-parser.api.casparser.in`
|
|
85
|
+
* - `environment_1` corresponds to `https://client-apis.casparser.in`
|
|
86
|
+
* - `environment_2` corresponds to `http://localhost:5000`
|
|
87
|
+
*/
|
|
88
|
+
environment?: Environment | undefined;
|
|
89
|
+
|
|
53
90
|
/**
|
|
54
91
|
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
55
92
|
*
|
|
@@ -128,7 +165,7 @@ export class CasParser {
|
|
|
128
165
|
baseURL: string;
|
|
129
166
|
maxRetries: number;
|
|
130
167
|
timeout: number;
|
|
131
|
-
logger: Logger
|
|
168
|
+
logger: Logger;
|
|
132
169
|
logLevel: LogLevel | undefined;
|
|
133
170
|
fetchOptions: MergedRequestInit | undefined;
|
|
134
171
|
|
|
@@ -141,6 +178,7 @@ export class CasParser {
|
|
|
141
178
|
* API Client for interfacing with the Cas Parser API.
|
|
142
179
|
*
|
|
143
180
|
* @param {string | undefined} [opts.apiKey=process.env['CAS_PARSER_API_KEY'] ?? undefined]
|
|
181
|
+
* @param {Environment} [opts.environment=production] - Specifies the environment URL to use for the API.
|
|
144
182
|
* @param {string} [opts.baseURL=process.env['CAS_PARSER_BASE_URL'] ?? https://portfolio-parser.api.casparser.in] - Override the default base URL for the API.
|
|
145
183
|
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
146
184
|
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
@@ -163,10 +201,17 @@ export class CasParser {
|
|
|
163
201
|
const options: ClientOptions = {
|
|
164
202
|
apiKey,
|
|
165
203
|
...opts,
|
|
166
|
-
baseURL
|
|
204
|
+
baseURL,
|
|
205
|
+
environment: opts.environment ?? 'production',
|
|
167
206
|
};
|
|
168
207
|
|
|
169
|
-
|
|
208
|
+
if (baseURL && opts.environment) {
|
|
209
|
+
throw new Errors.CasParserError(
|
|
210
|
+
'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',
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
this.baseURL = options.baseURL || environments[options.environment || 'production'];
|
|
170
215
|
this.timeout = options.timeout ?? CasParser.DEFAULT_TIMEOUT /* 1 minute */;
|
|
171
216
|
this.logger = options.logger ?? console;
|
|
172
217
|
const defaultLogLevel = 'warn';
|
|
@@ -192,7 +237,8 @@ export class CasParser {
|
|
|
192
237
|
withOptions(options: Partial<ClientOptions>): this {
|
|
193
238
|
const client = new (this.constructor as any as new (props: ClientOptions) => typeof this)({
|
|
194
239
|
...this._options,
|
|
195
|
-
|
|
240
|
+
environment: options.environment ? options.environment : undefined,
|
|
241
|
+
baseURL: options.environment ? undefined : this.baseURL,
|
|
196
242
|
maxRetries: this.maxRetries,
|
|
197
243
|
timeout: this.timeout,
|
|
198
244
|
logger: this.logger,
|
|
@@ -209,7 +255,7 @@ export class CasParser {
|
|
|
209
255
|
* Check whether the base URL is set to its default.
|
|
210
256
|
*/
|
|
211
257
|
#baseURLOverridden(): boolean {
|
|
212
|
-
return this.baseURL !==
|
|
258
|
+
return this.baseURL !== environments[this._options.environment || 'production'];
|
|
213
259
|
}
|
|
214
260
|
|
|
215
261
|
protected defaultQuery(): Record<string, string | undefined> | undefined {
|
|
@@ -462,7 +508,7 @@ export class CasParser {
|
|
|
462
508
|
loggerFor(this).info(`${responseInfo} - ${retryMessage}`);
|
|
463
509
|
|
|
464
510
|
const errText = await response.text().catch((err: any) => castToError(err).message);
|
|
465
|
-
const errJSON = safeJSON(errText);
|
|
511
|
+
const errJSON = safeJSON(errText) as any;
|
|
466
512
|
const errMessage = errJSON ? undefined : errText;
|
|
467
513
|
|
|
468
514
|
loggerFor(this).debug(
|
|
@@ -503,9 +549,10 @@ export class CasParser {
|
|
|
503
549
|
controller: AbortController,
|
|
504
550
|
): Promise<Response> {
|
|
505
551
|
const { signal, method, ...options } = init || {};
|
|
506
|
-
|
|
552
|
+
const abort = this._makeAbort(controller);
|
|
553
|
+
if (signal) signal.addEventListener('abort', abort, { once: true });
|
|
507
554
|
|
|
508
|
-
const timeout = setTimeout(
|
|
555
|
+
const timeout = setTimeout(abort, ms);
|
|
509
556
|
|
|
510
557
|
const isReadableBody =
|
|
511
558
|
((globalThis as any).ReadableStream && options.body instanceof (globalThis as any).ReadableStream) ||
|
|
@@ -672,6 +719,12 @@ export class CasParser {
|
|
|
672
719
|
return headers.values;
|
|
673
720
|
}
|
|
674
721
|
|
|
722
|
+
private _makeAbort(controller: AbortController) {
|
|
723
|
+
// note: we can't just inline this method inside `fetchWithTimeout()` because then the closure
|
|
724
|
+
// would capture all request options, and cause a memory leak.
|
|
725
|
+
return () => controller.abort();
|
|
726
|
+
}
|
|
727
|
+
|
|
675
728
|
private buildBody({ options: { body, headers: rawHeaders } }: { options: FinalRequestOptions }): {
|
|
676
729
|
bodyHeaders: HeadersLike;
|
|
677
730
|
body: BodyInit | undefined;
|
|
@@ -728,28 +781,87 @@ export class CasParser {
|
|
|
728
781
|
|
|
729
782
|
static toFile = Uploads.toFile;
|
|
730
783
|
|
|
731
|
-
|
|
732
|
-
|
|
784
|
+
credits: API.Credits = new API.Credits(this);
|
|
785
|
+
logs: API.Logs = new API.Logs(this);
|
|
786
|
+
accessToken: API.AccessToken = new API.AccessToken(this);
|
|
787
|
+
verifyToken: API.VerifyToken = new API.VerifyToken(this);
|
|
788
|
+
camsKfintech: API.CamsKfintech = new API.CamsKfintech(this);
|
|
789
|
+
cdsl: API.Cdsl = new API.Cdsl(this);
|
|
790
|
+
contractNote: API.ContractNote = new API.ContractNote(this);
|
|
791
|
+
inbox: API.Inbox = new API.Inbox(this);
|
|
792
|
+
kfintech: API.Kfintech = new API.Kfintech(this);
|
|
793
|
+
nsdl: API.Nsdl = new API.Nsdl(this);
|
|
794
|
+
smart: API.Smart = new API.Smart(this);
|
|
733
795
|
}
|
|
734
796
|
|
|
735
|
-
CasParser.
|
|
736
|
-
CasParser.
|
|
797
|
+
CasParser.Credits = Credits;
|
|
798
|
+
CasParser.Logs = Logs;
|
|
799
|
+
CasParser.AccessToken = AccessToken;
|
|
800
|
+
CasParser.VerifyToken = VerifyToken;
|
|
801
|
+
CasParser.CamsKfintech = CamsKfintech;
|
|
802
|
+
CasParser.Cdsl = Cdsl;
|
|
803
|
+
CasParser.ContractNote = ContractNote;
|
|
804
|
+
CasParser.Inbox = Inbox;
|
|
805
|
+
CasParser.Kfintech = Kfintech;
|
|
806
|
+
CasParser.Nsdl = Nsdl;
|
|
807
|
+
CasParser.Smart = Smart;
|
|
737
808
|
|
|
738
809
|
export declare namespace CasParser {
|
|
739
810
|
export type RequestOptions = Opts.RequestOptions;
|
|
740
811
|
|
|
812
|
+
export { Credits as Credits, type CreditCheckResponse as CreditCheckResponse };
|
|
813
|
+
|
|
741
814
|
export {
|
|
742
|
-
|
|
815
|
+
Logs as Logs,
|
|
816
|
+
type LogCreateResponse as LogCreateResponse,
|
|
817
|
+
type LogGetSummaryResponse as LogGetSummaryResponse,
|
|
818
|
+
type LogCreateParams as LogCreateParams,
|
|
819
|
+
type LogGetSummaryParams as LogGetSummaryParams,
|
|
820
|
+
};
|
|
821
|
+
|
|
822
|
+
export {
|
|
823
|
+
AccessToken as AccessToken,
|
|
824
|
+
type AccessTokenCreateResponse as AccessTokenCreateResponse,
|
|
825
|
+
type AccessTokenCreateParams as AccessTokenCreateParams,
|
|
826
|
+
};
|
|
827
|
+
|
|
828
|
+
export { VerifyToken as VerifyToken, type VerifyTokenVerifyResponse as VerifyTokenVerifyResponse };
|
|
829
|
+
|
|
830
|
+
export {
|
|
831
|
+
CamsKfintech as CamsKfintech,
|
|
832
|
+
type LinkedHolder as LinkedHolder,
|
|
833
|
+
type Transaction as Transaction,
|
|
743
834
|
type UnifiedResponse as UnifiedResponse,
|
|
744
|
-
type
|
|
745
|
-
type CasParserCdslParams as CasParserCdslParams,
|
|
746
|
-
type CasParserNsdlParams as CasParserNsdlParams,
|
|
747
|
-
type CasParserSmartParseParams as CasParserSmartParseParams,
|
|
835
|
+
type CamsKfintechParseParams as CamsKfintechParseParams,
|
|
748
836
|
};
|
|
749
837
|
|
|
838
|
+
export { Cdsl as Cdsl, type CdslParsePdfParams as CdslParsePdfParams };
|
|
839
|
+
|
|
750
840
|
export {
|
|
751
|
-
|
|
752
|
-
type
|
|
753
|
-
type
|
|
841
|
+
ContractNote as ContractNote,
|
|
842
|
+
type ContractNoteParseResponse as ContractNoteParseResponse,
|
|
843
|
+
type ContractNoteParseParams as ContractNoteParseParams,
|
|
754
844
|
};
|
|
845
|
+
|
|
846
|
+
export {
|
|
847
|
+
Inbox as Inbox,
|
|
848
|
+
type InboxCheckConnectionStatusResponse as InboxCheckConnectionStatusResponse,
|
|
849
|
+
type InboxConnectEmailResponse as InboxConnectEmailResponse,
|
|
850
|
+
type InboxDisconnectEmailResponse as InboxDisconnectEmailResponse,
|
|
851
|
+
type InboxListCasFilesResponse as InboxListCasFilesResponse,
|
|
852
|
+
type InboxCheckConnectionStatusParams as InboxCheckConnectionStatusParams,
|
|
853
|
+
type InboxConnectEmailParams as InboxConnectEmailParams,
|
|
854
|
+
type InboxDisconnectEmailParams as InboxDisconnectEmailParams,
|
|
855
|
+
type InboxListCasFilesParams as InboxListCasFilesParams,
|
|
856
|
+
};
|
|
857
|
+
|
|
858
|
+
export {
|
|
859
|
+
Kfintech as Kfintech,
|
|
860
|
+
type KfintechGenerateCasResponse as KfintechGenerateCasResponse,
|
|
861
|
+
type KfintechGenerateCasParams as KfintechGenerateCasParams,
|
|
862
|
+
};
|
|
863
|
+
|
|
864
|
+
export { Nsdl as Nsdl, type NsdlParseParams as NsdlParseParams };
|
|
865
|
+
|
|
866
|
+
export { Smart as Smart, type SmartParseCasPdfParams as SmartParseCasPdfParams };
|
|
755
867
|
}
|
package/src/internal/parse.ts
CHANGED
|
@@ -29,6 +29,12 @@ export async function defaultParseResponse<T>(client: CasParser, props: APIRespo
|
|
|
29
29
|
const mediaType = contentType?.split(';')[0]?.trim();
|
|
30
30
|
const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
|
|
31
31
|
if (isJSON) {
|
|
32
|
+
const contentLength = response.headers.get('content-length');
|
|
33
|
+
if (contentLength === '0') {
|
|
34
|
+
// if there is no content we can't do anything
|
|
35
|
+
return undefined as T;
|
|
36
|
+
}
|
|
37
|
+
|
|
32
38
|
const json = await response.json();
|
|
33
39
|
return json as T;
|
|
34
40
|
}
|
package/src/internal/to-file.ts
CHANGED
|
@@ -73,7 +73,7 @@ export type ToFileInput =
|
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
75
|
* Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats
|
|
76
|
-
* @param value the raw content of the file.
|
|
76
|
+
* @param value the raw content of the file. Can be an {@link Uploadable}, BlobLikePart, or AsyncIterable of BlobLikeParts
|
|
77
77
|
* @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible
|
|
78
78
|
* @param {Object=} options additional properties
|
|
79
79
|
* @param {string=} options.type the MIME type of the content
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../core/resource';
|
|
4
|
+
import { APIPromise } from '../core/api-promise';
|
|
5
|
+
import { RequestOptions } from '../internal/request-options';
|
|
6
|
+
|
|
7
|
+
export class AccessToken extends APIResource {
|
|
8
|
+
/**
|
|
9
|
+
* Generate a short-lived access token from your API key.
|
|
10
|
+
*
|
|
11
|
+
* **Use this endpoint from your backend** to create tokens that can be safely
|
|
12
|
+
* passed to frontend/SDK.
|
|
13
|
+
*
|
|
14
|
+
* Access tokens:
|
|
15
|
+
*
|
|
16
|
+
* - Are prefixed with `at_` for easy identification
|
|
17
|
+
* - Valid for up to 60 minutes
|
|
18
|
+
* - Can be used in place of API keys on all v4 endpoints
|
|
19
|
+
* - Cannot be used to generate other access tokens
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* const accessToken = await client.accessToken.create();
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
create(
|
|
27
|
+
body: AccessTokenCreateParams | null | undefined = {},
|
|
28
|
+
options?: RequestOptions,
|
|
29
|
+
): APIPromise<AccessTokenCreateResponse> {
|
|
30
|
+
return this._client.post('/v1/access-token', { body, ...options });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface AccessTokenCreateResponse {
|
|
35
|
+
/**
|
|
36
|
+
* The at\_ prefixed access token
|
|
37
|
+
*/
|
|
38
|
+
access_token?: string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Token validity in seconds
|
|
42
|
+
*/
|
|
43
|
+
expires_in?: number;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Always "api_key" - token is a drop-in replacement for x-api-key header
|
|
47
|
+
*/
|
|
48
|
+
token_type?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface AccessTokenCreateParams {
|
|
52
|
+
/**
|
|
53
|
+
* Token validity in minutes (max 60)
|
|
54
|
+
*/
|
|
55
|
+
expiry_minutes?: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export declare namespace AccessToken {
|
|
59
|
+
export {
|
|
60
|
+
type AccessTokenCreateResponse as AccessTokenCreateResponse,
|
|
61
|
+
type AccessTokenCreateParams as AccessTokenCreateParams,
|
|
62
|
+
};
|
|
63
|
+
}
|