Skip to content

Commit 85c28f7

Browse files
SDK regeneration (#231)
Co-authored-by: fern-api[bot] <115122769+fern-api[bot]@users.noreply.github.com>
1 parent abafeac commit 85c28f7

2 files changed

Lines changed: 32 additions & 9 deletions

File tree

README.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,38 @@ await client.payments.create({
7878

7979
## Legacy SDK
8080

81-
> If you're using TypeScript, make sure that the `moduleResolution` setting in your `tsconfig.json` is equal to `node16`, `nodenext`, > or `bundler` to consume the legacy SDK.
82-
While the new SDK has a lot of improvements, we at Square understand that it takes time to upgrade when there are breaking changes. To make the migration easier, the new SDK also exports the legacy SDK as `square/legacy`. Here's an example of how you can use the legacy SDK alongside the new SDK inside a single file:
83-
```typescript import { randomUUID } from "crypto"; import { Square, SquareClient } from "square"; import { Client } from "square/legacy";
81+
## Legacy SDK
82+
83+
> If you're using TypeScript, make sure that the `moduleResolution` setting in your `tsconfig.json` is equal to `node16`, `nodenext`,
84+
> or `bundler` to consume the legacy SDK.
85+
86+
While the new SDK has a lot of improvements, we at Square understand that it takes time to upgrade when there are breaking changes.
87+
To make the migration easier, the new SDK also exports the legacy SDK as `square/legacy`. Here's an example of how you can use the
88+
legacy SDK alongside the new SDK inside a single file:
89+
90+
```typescript
91+
import { randomUUID } from "crypto";
92+
import { Square, SquareClient } from "square";
93+
import { Client } from "square/legacy";
94+
8495
const client = new SquareClient({
8596
token: process.env.SQUARE_ACCESS_TOKEN,
8697
});
98+
8799
const legacyClient = new Client({
88100
bearerAuthCredentials: {
89101
accessToken: process.env.SQUARE_ACCESS_TOKEN!,
90102
},
91103
});
104+
92105
async function getLocation(): Promise<Square.Location> {
93106
return (
94107
await client.locations.get({
95108
locationId: "YOUR_LOCATION_ID",
96109
})
97110
).location!;
98111
}
112+
99113
async function createOrder() {
100114
const location = await getLocation();
101115
await legacyClient.ordersApi.createOrder({
@@ -115,10 +129,19 @@ async function createOrder() {
115129
},
116130
});
117131
}
118-
createOrder(); ```
132+
133+
createOrder();
134+
```
135+
119136
We recommend migrating to the new SDK using the following steps:
120-
1. Upgrade the NPM module to `^40.0.0` 2. Search and replace all requires and imports from `"square"` to `"square/legacy"`
121-
- For required, replace `require("square")` with `require("square/legacy")` - For imports, replace `from "square"` with `from "square/legacy"` - For dynamic imports, replace `import("square")` with `import("square/legacy")`
137+
138+
1. Upgrade the NPM module to `^40.0.0` or later.
139+
2. Search and replace all requires and imports from `"square"` to `"square/legacy"`
140+
141+
- For required, replace `require("square")` with `require("square/legacy")`
142+
- For imports, replace `from "square"` with `from "square/legacy"`
143+
- For dynamic imports, replace `import("square")` with `import("square/legacy")`
144+
122145
3. Gradually move over to use the new SDK by importing it from the `"square"` import.
123146

124147

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,9 +1205,9 @@ asynckit@^0.4.0:
12051205
integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==
12061206

12071207
axios@^1.8.4:
1208-
version "1.13.2"
1209-
resolved "https://registry.yarnpkg.com/axios/-/axios-1.13.2.tgz#9ada120b7b5ab24509553ec3e40123521117f687"
1210-
integrity sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA==
1208+
version "1.13.3"
1209+
resolved "https://registry.yarnpkg.com/axios/-/axios-1.13.3.tgz#f123e77356630a22b0163920662556944f2be1a1"
1210+
integrity sha512-ERT8kdX7DZjtUm7IitEyV7InTHAF42iJuMArIiDIV5YtPanJkgw4hw5Dyg9fh0mihdWNn1GKaeIWErfe56UQ1g==
12111211
dependencies:
12121212
follow-redirects "^1.15.6"
12131213
form-data "^4.0.4"

0 commit comments

Comments
 (0)