Skip to content

Commit ec33845

Browse files
Merge pull request #2 from stainless-sdks/next
Next
2 parents 3eb17e8 + 70168fa commit ec33845

63 files changed

Lines changed: 1978 additions & 534 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
- 'integrated/**'
88
- 'stl-preview-head/**'
99
- 'stl-preview-base/**'
10+
pull_request:
11+
branches-ignore:
12+
- 'stl-preview-head/**'
13+
- 'stl-preview-base/**'
1014

1115
jobs:
1216
lint:

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 17
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/scan-documents%2Fscan-documents-41af66c2f2ba90b745f6c36d89d31281f16d916521b98a8f510ec3a8f90a1efb.yml
3-
openapi_spec_hash: 0c629cd46c640a055b0cfa5d88aad337
4-
config_hash: ee078a284af580362c78b746a0c811c2
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/scan-documents%2Fscan-documents-42f9aa9c3b2769584f60fa3742f3a004bdf2e3b5ba30a44535b0191654b1a51e.yml
3+
openapi_spec_hash: a0bab3e1411b24d8a662df98d227049a
4+
config_hash: 4f1180f734cbc7323ff2ed85a9cd510d

README.md

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Scan Documents TypeScript API Library
22

3-
[![NPM version](https://img.shields.io/npm/v/scan-documents.svg)](https://npmjs.org/package/scan-documents) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/scan-documents)
3+
[![NPM version](<https://img.shields.io/npm/v/scan-documents.svg?label=npm%20(stable)>)](https://npmjs.org/package/scan-documents) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/scan-documents)
44

55
This library provides convenient access to the Scan Documents REST API from server-side TypeScript or JavaScript.
66

@@ -26,11 +26,7 @@ const client = new ScanDocuments({
2626
apiKey: process.env['SCAN_DOCUMENTS_API_KEY'], // This is the default and can be omitted
2727
});
2828

29-
async function main() {
30-
const file = await client.files.upload({ file: fs.createReadStream('path/to/file'), name: 'REPLACE_ME' });
31-
}
32-
33-
main();
29+
const file = await client.files.upload({ file: fs.createReadStream('path/to/file'), name: 'REPLACE_ME' });
3430
```
3531

3632
### Request & Response types
@@ -45,15 +41,11 @@ const client = new ScanDocuments({
4541
apiKey: process.env['SCAN_DOCUMENTS_API_KEY'], // This is the default and can be omitted
4642
});
4743

48-
async function main() {
49-
const params: ScanDocuments.FileUploadParams = {
50-
file: fs.createReadStream('path/to/file'),
51-
name: 'REPLACE_ME',
52-
};
53-
const file: ScanDocuments.File = await client.files.upload(params);
54-
}
55-
56-
main();
44+
const params: ScanDocuments.FileUploadParams = {
45+
file: fs.createReadStream('path/to/file'),
46+
name: 'REPLACE_ME',
47+
};
48+
const file: ScanDocuments.File = await client.files.upload(params);
5749
```
5850

5951
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
@@ -115,21 +107,17 @@ a subclass of `APIError` will be thrown:
115107

116108
<!-- prettier-ignore -->
117109
```ts
118-
async function main() {
119-
const file = await client.files
120-
.upload({ file: fs.createReadStream('path/to/file'), name: 'REPLACE_ME' })
121-
.catch(async (err) => {
122-
if (err instanceof ScanDocuments.APIError) {
123-
console.log(err.status); // 400
124-
console.log(err.name); // BadRequestError
125-
console.log(err.headers); // {server: 'nginx', ...}
126-
} else {
127-
throw err;
128-
}
129-
});
130-
}
131-
132-
main();
110+
const file = await client.files
111+
.upload({ file: fs.createReadStream('path/to/file'), name: 'REPLACE_ME' })
112+
.catch(async (err) => {
113+
if (err instanceof ScanDocuments.APIError) {
114+
console.log(err.status); // 400
115+
console.log(err.name); // BadRequestError
116+
console.log(err.headers); // {server: 'nginx', ...}
117+
} else {
118+
throw err;
119+
}
120+
});
133121
```
134122

135123
Error codes are as follows:
@@ -291,9 +279,8 @@ parameter. This library doesn't validate at runtime that the request matches the
291279
send will be sent as-is.
292280

293281
```ts
294-
client.foo.create({
295-
foo: 'my_param',
296-
bar: 12,
282+
client.files.upload({
283+
// ...
297284
// @ts-expect-error baz is not yet public
298285
baz: 'undocumented option',
299286
});

SECURITY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ before making any information public.
1616
## Reporting Non-SDK Related Security Issues
1717

1818
If you encounter security issues that are not directly related to SDKs but pertain to the services
19-
or products provided by Scan Documents please follow the respective company's security reporting guidelines.
19+
or products provided by Scan Documents, please follow the respective company's security reporting guidelines.
2020

2121
### Scan Documents Terms and Policies
2222

23-
Please contact support@scan-documents.com for any questions or concerns regarding security of our services.
23+
Please contact support@scan-documents.com for any questions or concerns regarding the security of our services.
2424

2525
---
2626

api.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Shared
2+
3+
Types:
4+
5+
- <code><a href="./src/resources/shared.ts">JsonSchemaSpec</a></code>
6+
17
# Files
28

39
Types:
@@ -48,7 +54,6 @@ Types:
4854
- <code><a href="./src/resources/image-operations.ts">ExtractTextRequest</a></code>
4955
- <code><a href="./src/resources/image-operations.ts">ExtractTextResponse</a></code>
5056
- <code><a href="./src/resources/image-operations.ts">ImageFromTaskResponse</a></code>
51-
- <code><a href="./src/resources/image-operations.ts">JsonSchemaSpec</a></code>
5257
- <code><a href="./src/resources/image-operations.ts">WarpRequest</a></code>
5358
- <code><a href="./src/resources/image-operations.ts">WarpResponse</a></code>
5459

bin/publish-npm

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,55 @@ set -eux
44

55
npm config set '//registry.npmjs.org/:_authToken' "$NPM_TOKEN"
66

7-
# Build the project
87
yarn build
9-
10-
# Navigate to the dist directory
118
cd dist
129

13-
# Get the version from package.json
14-
VERSION="$(node -p "require('./package.json').version")"
10+
# Get package name and version from package.json
11+
PACKAGE_NAME="$(jq -r -e '.name' ./package.json)"
12+
VERSION="$(jq -r -e '.version' ./package.json)"
13+
14+
# Get latest version from npm
15+
#
16+
# If the package doesn't exist, npm will return:
17+
# {
18+
# "error": {
19+
# "code": "E404",
20+
# "summary": "Unpublished on 2025-06-05T09:54:53.528Z",
21+
# "detail": "'the_package' is not in this registry..."
22+
# }
23+
# }
24+
NPM_INFO="$(npm view "$PACKAGE_NAME" version --json 2>/dev/null || true)"
25+
26+
# Check if we got an E404 error
27+
if echo "$NPM_INFO" | jq -e '.error.code == "E404"' > /dev/null 2>&1; then
28+
# Package doesn't exist yet, no last version
29+
LAST_VERSION=""
30+
elif echo "$NPM_INFO" | jq -e '.error' > /dev/null 2>&1; then
31+
# Report other errors
32+
echo "ERROR: npm returned unexpected data:"
33+
echo "$NPM_INFO"
34+
exit 1
35+
else
36+
# Success - get the version
37+
LAST_VERSION=$(echo "$NPM_INFO" | jq -r '.') # strip quotes
38+
fi
1539

16-
# Extract the pre-release tag if it exists
40+
# Check if current version is pre-release (e.g. alpha / beta / rc)
41+
CURRENT_IS_PRERELEASE=false
1742
if [[ "$VERSION" =~ -([a-zA-Z]+) ]]; then
18-
# Extract the part before any dot in the pre-release identifier
19-
TAG="${BASH_REMATCH[1]}"
43+
CURRENT_IS_PRERELEASE=true
44+
CURRENT_TAG="${BASH_REMATCH[1]}"
45+
fi
46+
47+
# Check if last version is a stable release
48+
LAST_IS_STABLE_RELEASE=true
49+
if [[ -z "$LAST_VERSION" || "$LAST_VERSION" =~ -([a-zA-Z]+) ]]; then
50+
LAST_IS_STABLE_RELEASE=false
51+
fi
52+
53+
# Use a corresponding alpha/beta tag if there already is a stable release and we're publishing a prerelease.
54+
if $CURRENT_IS_PRERELEASE && $LAST_IS_STABLE_RELEASE; then
55+
TAG="$CURRENT_TAG"
2056
else
2157
TAG="latest"
2258
fi

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default tseslint.config(
1010
parserOptions: { sourceType: 'module' },
1111
},
1212
files: ['**/*.ts', '**/*.mts', '**/*.cts', '**/*.js', '**/*.mjs', '**/*.cjs'],
13-
ignores: ['dist/**'],
13+
ignores: ['dist/'],
1414
plugins: {
1515
'@typescript-eslint': tseslint.plugin,
1616
'unused-imports': unusedImports,

jest.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const config: JestConfigWithTsJest = {
1515
'<rootDir>/dist/',
1616
'<rootDir>/deno/',
1717
'<rootDir>/deno_tests/',
18+
'<rootDir>/packages/',
1819
],
1920
testPathIgnorePatterns: ['scripts'],
2021
};

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,18 @@
3434
"@typescript-eslint/eslint-plugin": "8.31.1",
3535
"@typescript-eslint/parser": "8.31.1",
3636
"eslint": "^9.20.1",
37-
"eslint-plugin-prettier": "^5.2.3",
37+
"eslint-plugin-prettier": "^5.4.1",
3838
"eslint-plugin-unused-imports": "^4.1.4",
3939
"iconv-lite": "^0.6.3",
4040
"jest": "^29.4.0",
4141
"prettier": "^3.0.0",
4242
"publint": "^0.2.12",
4343
"ts-jest": "^29.1.0",
4444
"ts-node": "^10.5.0",
45-
"tsc-multi": "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.4/tsc-multi-1.1.4.tgz",
45+
"tsc-multi": "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.8/tsc-multi.tgz",
4646
"tsconfig-paths": "^4.0.0",
4747
"typescript": "5.8.3"
4848
},
49-
"resolutions": {
50-
"synckit": "0.8.8"
51-
},
5249
"imports": {
5350
"scan-documents": ".",
5451
"scan-documents/*": "./src/*"

packages/mcp-server/build

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,10 @@ PKG_JSON_PATH=../../packages/mcp-server/package.json node ../../scripts/utils/ma
2323
node scripts/postprocess-dist-package-json.cjs
2424

2525
# build to .js/.mjs/.d.ts files
26-
npm exec tsc-multi
26+
./node_modules/.bin/tsc-multi
2727

2828
cp tsconfig.dist-src.json dist/src/tsconfig.json
2929

30-
# Add proper Node.js shebang to the top of the file
31-
sed -i.bak '1s;^;#!/usr/bin/env node\n;' dist/index.js
32-
rm dist/index.js.bak
33-
3430
chmod +x dist/index.js
3531

3632
DIST_PATH=./dist PKG_IMPORT_PATH=scan-documents-mcp/ node ../../scripts/utils/postprocess-files.cjs

0 commit comments

Comments
 (0)