Skip to content

Commit 1e6c39a

Browse files
feat(api): manual updates
1 parent 245bd3d commit 1e6c39a

File tree

11 files changed

+60
-24
lines changed

11 files changed

+60
-24
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 5
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-b7fdba3d3f97c7debc22c7ca30b828bce81bcd64648df8c94029b27a3321ebb9.yml
3-
openapi_spec_hash: 03f1315f1d32ada42445ca920f047dff
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-33841d833a48438cd79a13b2e70eeb61551b67e954ed788209ece1b0f5886e15.yml
3+
openapi_spec_hash: 6a784691ea7c8cf7c2987c93f6a2ab25
44
config_hash: e038b1acdad8015d8d29b65c78c345fa

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,35 @@ const unifiedResponse: CasParser.UnifiedResponse = await client.casParser.camsKf
5353

5454
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
5555

56+
## File uploads
57+
58+
Request parameters that correspond to file uploads can be passed in many different forms:
59+
60+
- `File` (or an object with the same structure)
61+
- a `fetch` `Response` (or an object with the same structure)
62+
- an `fs.ReadStream`
63+
- the return value of our `toFile` helper
64+
65+
```ts
66+
import fs from 'fs';
67+
import CasParser, { toFile } from 'cas-parser';
68+
69+
const client = new CasParser();
70+
71+
// If you have access to Node `fs` we recommend using `fs.createReadStream()`:
72+
await client.casParser.camsKfintech({ pdf_file: fs.createReadStream('/path/to/file') });
73+
74+
// Or if you have the web `File` API you can pass a `File` instance:
75+
await client.casParser.camsKfintech({ pdf_file: new File(['my bytes'], 'file') });
76+
77+
// You can also pass a `fetch` `Response`:
78+
await client.casParser.camsKfintech({ pdf_file: await fetch('https://somesite/file') });
79+
80+
// Finally, if none of the above are convenient, you can use our `toFile` helper:
81+
await client.casParser.camsKfintech({ pdf_file: await toFile(Buffer.from('my bytes'), 'file') });
82+
await client.casParser.camsKfintech({ pdf_file: await toFile(new Uint8Array([0, 1, 2]), 'file') });
83+
```
84+
5685
## Handling errors
5786

5887
When the library is unable to connect to the API,

bin/publish-npm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ else
5858
fi
5959

6060
# Publish with the appropriate tag
61-
yarn publish --access public --tag "$TAG"
61+
yarn publish --tag "$TAG"

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
"**/*"
1414
],
1515
"private": false,
16+
"publishConfig": {
17+
"access": "public"
18+
},
1619
"scripts": {
1720
"test": "./scripts/test",
1821
"build": "./scripts/build",

scripts/mock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ echo "==> Starting mock server with URL ${URL}"
2121

2222
# Run prism mock on the given spec
2323
if [ "$1" == "--daemon" ]; then
24-
npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL" &> .prism.log &
24+
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log &
2525

2626
# Wait for server to come online
2727
echo -n "Waiting for server"
@@ -37,5 +37,5 @@ if [ "$1" == "--daemon" ]; then
3737

3838
echo
3939
else
40-
npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL"
40+
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL"
4141
fi

scripts/test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ elif ! prism_is_running ; then
4343
echo -e "To run the server, pass in the path or url of your OpenAPI"
4444
echo -e "spec to the prism command:"
4545
echo
46-
echo -e " \$ ${YELLOW}npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock path/to/your.openapi.yml${NC}"
46+
echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}"
4747
echo
4848

4949
exit 1

src/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,8 +755,10 @@ export class CasParser {
755755
casParser: API.CasParserResource = new API.CasParserResource(this);
756756
casGenerator: API.CasGenerator = new API.CasGenerator(this);
757757
}
758+
758759
CasParser.CasParserResource = CasParserResource;
759760
CasParser.CasGenerator = CasGenerator;
761+
760762
export declare namespace CasParser {
761763
export type RequestOptions = Opts.RequestOptions;
762764

src/resources/cas-parser.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { APIResource } from '../core/resource';
44
import { APIPromise } from '../core/api-promise';
5+
import { type Uploadable } from '../core/uploads';
56
import { RequestOptions } from '../internal/request-options';
67
import { maybeMultipartFormRequestOptions } from '../internal/uploads';
78

@@ -682,7 +683,7 @@ export interface CasParserCamsKfintechParams {
682683
/**
683684
* Base64 encoded CAS PDF file
684685
*/
685-
pdf_file?: string;
686+
pdf_file?: Uploadable;
686687

687688
/**
688689
* URL to the CAS PDF file
@@ -699,7 +700,7 @@ export interface CasParserCdslParams {
699700
/**
700701
* Base64 encoded CAS PDF file
701702
*/
702-
pdf_file?: string;
703+
pdf_file?: Uploadable;
703704

704705
/**
705706
* URL to the CAS PDF file
@@ -716,7 +717,7 @@ export interface CasParserNsdlParams {
716717
/**
717718
* Base64 encoded CAS PDF file
718719
*/
719-
pdf_file?: string;
720+
pdf_file?: Uploadable;
720721

721722
/**
722723
* URL to the CAS PDF file
@@ -733,7 +734,7 @@ export interface CasParserSmartParseParams {
733734
/**
734735
* Base64 encoded CAS PDF file
735736
*/
736-
pdf_file?: string;
737+
pdf_file?: Uploadable;
737738

738739
/**
739740
* URL to the CAS PDF file

tests/api-resources/cas-generator.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const client = new CasParser({
88
});
99

1010
describe('resource casGenerator', () => {
11-
// skipped: tests are disabled for the time being
11+
// Prism tests are disabled
1212
test.skip('generateCas: only required params', async () => {
1313
const responsePromise = client.casGenerator.generateCas({
1414
@@ -25,7 +25,7 @@ describe('resource casGenerator', () => {
2525
expect(dataAndResponse.response).toBe(rawResponse);
2626
});
2727

28-
// skipped: tests are disabled for the time being
28+
// Prism tests are disabled
2929
test.skip('generateCas: required and optional params', async () => {
3030
const response = await client.casGenerator.generateCas({
3131

tests/api-resources/cas-parser.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const client = new CasParser({
88
});
99

1010
describe('resource casParser', () => {
11-
// skipped: tests are disabled for the time being
11+
// Prism tests are disabled
1212
test.skip('camsKfintech', async () => {
1313
const responsePromise = client.casParser.camsKfintech({});
1414
const rawResponse = await responsePromise.asResponse();
@@ -20,7 +20,7 @@ describe('resource casParser', () => {
2020
expect(dataAndResponse.response).toBe(rawResponse);
2121
});
2222

23-
// skipped: tests are disabled for the time being
23+
// Prism tests are disabled
2424
test.skip('cdsl', async () => {
2525
const responsePromise = client.casParser.cdsl({});
2626
const rawResponse = await responsePromise.asResponse();
@@ -32,7 +32,7 @@ describe('resource casParser', () => {
3232
expect(dataAndResponse.response).toBe(rawResponse);
3333
});
3434

35-
// skipped: tests are disabled for the time being
35+
// Prism tests are disabled
3636
test.skip('nsdl', async () => {
3737
const responsePromise = client.casParser.nsdl({});
3838
const rawResponse = await responsePromise.asResponse();
@@ -44,7 +44,7 @@ describe('resource casParser', () => {
4444
expect(dataAndResponse.response).toBe(rawResponse);
4545
});
4646

47-
// skipped: tests are disabled for the time being
47+
// Prism tests are disabled
4848
test.skip('smartParse', async () => {
4949
const responsePromise = client.casParser.smartParse({});
5050
const rawResponse = await responsePromise.asResponse();

0 commit comments

Comments
 (0)