Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 8 additions & 3 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"cliVersion": "3.98.5",
"cliVersion": "5.55.1",
"generatorName": "fernapi/fern-typescript-sdk",
"generatorVersion": "3.43.8",
"generatorVersion": "3.73.4",
"generatorConfig": {
"namespaceExport": "Square",
"allowCustomFetcher": true,
Expand Down Expand Up @@ -54,5 +54,10 @@
}
}
},
"sdkVersion": "44.2.0"
"originGitCommit": "d93545d18ea2da3477384a0d47d4a3223daf24d5",
"originGitCommitIsDirty": false,
"invokedBy": "ci",
"requestedVersion": "44.1.1",
"ciProvider": "github",
"sdkVersion": "44.1.1"
}
5 changes: 5 additions & 0 deletions .fern/verify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
set -euo pipefail
yarn install
yarn build
yarn test
85 changes: 70 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,24 @@ The Square TypeScript library provides convenient access to the Square APIs from
- [Versioning](#versioning)
- [Usage](#usage)
- [Legacy Sdk](#legacy-sdk)
- [Environments](#environments)
- [Request and Response Types](#request-and-response-types)
- [Exception Handling](#exception-handling)
- [File Uploads](#file-uploads)
- [Pagination](#pagination)
- [Webhook Signature Verification](#webhook-signature-verification)
- [Reporting API](#reporting-api)
- [Reporting Api](#reporting-api)
- [Advanced](#advanced)
- [Subpackage Exports](#subpackage-exports)
- [Additional Headers](#additional-headers)
- [Additional Query String Parameters](#additional-query-string-parameters)
- [Retries](#retries)
- [Timeouts](#timeouts)
- [Aborting Requests](#aborting-requests)
- [Access Raw Response Data](#access-raw-response-data)
- [Logging](#logging)
- [Custom Fetch](#custom-fetch)
- [Custom Fetcher](#custom-fetcher)
- [Runtime Compatibility](#runtime-compatibility)
- [Contributing](#contributing)

Expand Down Expand Up @@ -146,6 +150,18 @@ We recommend migrating to the new SDK using the following steps:
3. Gradually move over to use the new SDK by importing it from the `"square"` import.


## Environments

This SDK allows you to configure different environments for API requests.

```typescript
import { SquareClient, SquareEnvironment } from "square";

const client = new SquareClient({
environment: SquareEnvironment.Production,
});
```

## Request and Response Types

The SDK exports all request and response types as TypeScript interfaces. Simply import them with the
Expand Down Expand Up @@ -330,6 +346,16 @@ const response = await ReportingHelper.loadAndWait(

## Advanced

### Subpackage Exports

This SDK supports direct imports of subpackage clients, which allows JavaScript bundlers to tree-shake and include only the imported subpackage code. This results in much smaller bundle sizes.

```typescript
import { OAuthClient } from 'square/oAuth';

const client = new OAuthClient({...});
```

### Additional Headers

If you would like to send additional headers as part of the request, use the `headers` request option.
Expand Down Expand Up @@ -369,11 +395,19 @@ The SDK is instrumented with automatic retries with exponential backoff. A reque
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
retry limit (default: 2).

A request is deemed retryable when any of the following HTTP status codes is returned:
Which status codes are retried depends on the `retryStatusCodes` generator configuration:

**`legacy`** (current default): retries on
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses) (All server errors, including 500)

**`recommended`**: retries on
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
- [502](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502) (Bad Gateway)
- [503](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503) (Service Unavailable)
- [504](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504) (Gateway Timeout)

Use the `maxRetries` request option to configure this behavior.

Expand Down Expand Up @@ -480,22 +514,27 @@ const logger: logging.ILogger = {
</details>


### Runtime Compatibility


The SDK defaults to `node-fetch` but will use the global fetch client if present. The SDK works in the following
runtimes:
### Custom Fetch

The SDK provides a low-level `fetch` method for making custom HTTP requests while still
benefiting from SDK-level configuration like authentication, retries, timeouts, and logging.
This is useful for calling API endpoints not yet supported in the SDK.

```typescript
const response = await client.fetch("/v1/custom/endpoint", {
method: "GET",
}, {
timeoutInSeconds: 30,
maxRetries: 3,
headers: {
"X-Custom-Header": "custom-value",
},
});

- Node.js 18+
- Vercel
- Cloudflare Workers
- Deno v1.25+
- Bun 1.0+
- React Native
const data = await response.json();
```

### Customizing Fetch Client
### Custom Fetcher

The SDK provides a way for you to customize the underlying HTTP client / Fetch function. If you're running in an
unsupported environment, this provides a way for you to break glass and ensure the SDK works.
Expand All @@ -509,6 +548,22 @@ const client = new SquareClient({
});
```

### Runtime Compatibility


The SDK defaults to `node-fetch` but will use the global fetch client if present. The SDK works in the following
runtimes:



- Node.js 18+
- Vercel
- Cloudflare Workers
- Deno v1.25+
- Bun 1.0+
- React Native


## Contributing

While we value open-source contributions to this SDK, this library is generated programmatically.
Expand Down
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/2.3.1/schema.json",
"$schema": "https://biomejs.dev/schemas/2.4.10/schema.json",
"root": true,
"vcs": {
"enabled": false
Expand Down
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "square",
"version": "44.2.0",
"version": "44.1.1",
"private": false,
"repository": {
"type": "git",
Expand All @@ -24,33 +24,34 @@
"test:integration": "jest --selectProjects integration"
},
"dependencies": {
"form-data": "^4.0.4",
"form-data": "^4.0.6",
"formdata-node": "^6.0.3",
"node-fetch": "^2.7.0",
"readable-stream": "^4.5.2",
"form-data-encoder": "^4.0.2",
"readable-stream": "^4.7.0",
"form-data-encoder": "^4.1.0",
"square-legacy": "npm:square@^39.1.1"
},
"devDependencies": {
"@types/node-fetch": "^2.6.12",
"@types/readable-stream": "^4.0.18",
"webpack": "^5.97.1",
"ts-loader": "^9.5.1",
"@types/readable-stream": "^4.0.23",
"webpack": "^5.105.4",
"ts-loader": "^9.5.4",
"jest": "^29.7.0",
"@jest/globals": "^29.7.0",
"@types/jest": "^29.5.14",
"ts-jest": "^29.3.4",
"jest-environment-jsdom": "^29.7.0",
"msw": "2.11.2",
"@types/node": "^18.19.70",
"typescript": "~5.7.2",
"@biomejs/biome": "2.3.1"
"@types/node": "^20.0.0",
"typescript": "~5.9.3",
"@biomejs/biome": "2.4.10"
},
"browser": {
"fs": false,
"os": false,
"path": false,
"stream": false
"stream": false,
"crypto": false
},
"packageManager": "yarn@1.22.22",
"engines": {
Expand Down
Loading
Loading