Skip to content

Commit 6e98e7e

Browse files
SDK regeneration
1 parent e66c2d9 commit 6e98e7e

File tree

84 files changed

+1296
-2198
lines changed

Some content is hidden

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

84 files changed

+1296
-2198
lines changed

.fern/metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"cliVersion": "2.2.5",
2+
"cliVersion": "2.8.1",
33
"generatorName": "fernapi/fern-typescript-sdk",
4-
"generatorVersion": "3.33.0",
4+
"generatorVersion": "3.34.0",
55
"generatorConfig": {
66
"namespaceExport": "Square",
77
"allowCustomFetcher": true,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "square",
3-
"version": "43.2.1",
3+
"version": "43.2.2",
44
"private": false,
55
"repository": "github:square/square-nodejs-sdk",
66
"license": "MIT",

src/BaseClient.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// This file was auto-generated by Fern from our API Definition.
22

3+
import { BearerAuthProvider } from "./auth/BearerAuthProvider.js";
34
import * as core from "./core";
45
import { mergeHeaders } from "./core/headers";
56
import type * as environments from "./environments";
@@ -39,13 +40,22 @@ export interface BaseRequestOptions {
3940
headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
4041
}
4142

42-
export function normalizeClientOptions<T extends BaseClientOptions>(options: T): T {
43+
export type NormalizedClientOptions<T extends BaseClientOptions> = T & {
44+
logging: core.logging.Logger;
45+
authProvider?: core.AuthProvider;
46+
};
47+
48+
export type NormalizedClientOptionsWithAuth<T extends BaseClientOptions> = NormalizedClientOptions<T> & {
49+
authProvider: core.AuthProvider;
50+
};
51+
52+
export function normalizeClientOptions<T extends BaseClientOptions>(options: T): NormalizedClientOptions<T> {
4353
const headers = mergeHeaders(
4454
{
4555
"X-Fern-Language": "JavaScript",
4656
"X-Fern-SDK-Name": "square",
47-
"X-Fern-SDK-Version": "43.2.1",
48-
"User-Agent": "square/43.2.1",
57+
"X-Fern-SDK-Version": "43.2.2",
58+
"User-Agent": "square/43.2.2",
4959
"X-Fern-Runtime": core.RUNTIME.type,
5060
"X-Fern-Runtime-Version": core.RUNTIME.version,
5161
"Square-Version": options?.version ?? "2025-10-16",
@@ -57,5 +67,13 @@ export function normalizeClientOptions<T extends BaseClientOptions>(options: T):
5767
...options,
5868
logging: core.logging.createLogger(options?.logging),
5969
headers,
60-
} as T;
70+
} as NormalizedClientOptions<T>;
71+
}
72+
73+
export function normalizeClientOptionsWithAuth<T extends BaseClientOptions>(
74+
options: T,
75+
): NormalizedClientOptionsWithAuth<T> {
76+
const normalized = normalizeClientOptions(options) as NormalizedClientOptionsWithAuth<T>;
77+
normalized.authProvider ??= new BearerAuthProvider(options);
78+
return normalized;
6179
}

src/Client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { V1TransactionsClient } from "./api/resources/v1Transactions/client/Clie
3737
import { VendorsClient } from "./api/resources/vendors/client/Client";
3838
import { WebhooksClient } from "./api/resources/webhooks/client/Client";
3939
import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient";
40-
import { normalizeClientOptions } from "./BaseClient";
40+
import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "./BaseClient";
4141

4242
export declare namespace SquareClient {
4343
export interface Options extends BaseClientOptions {}
@@ -46,7 +46,7 @@ export declare namespace SquareClient {
4646
}
4747

4848
export class SquareClient {
49-
protected readonly _options: SquareClient.Options;
49+
protected readonly _options: NormalizedClientOptionsWithAuth<SquareClient.Options>;
5050
protected _mobile: MobileClient | undefined;
5151
protected _oAuth: OAuthClient | undefined;
5252
protected _v1Transactions: V1TransactionsClient | undefined;
@@ -85,7 +85,7 @@ export class SquareClient {
8585
protected _webhooks: WebhooksClient | undefined;
8686

8787
constructor(options: SquareClient.Options = {}) {
88-
this._options = normalizeClientOptions(options);
88+
this._options = normalizeClientOptionsWithAuth(options);
8989
}
9090

9191
public get mobile(): MobileClient {

src/api/resources/applePay/client/Client.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This file was auto-generated by Fern from our API Definition.
22

33
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient";
4-
import { normalizeClientOptions } from "../../../../BaseClient";
4+
import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient";
55
import * as core from "../../../../core";
66
import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers";
77
import * as environments from "../../../../environments";
@@ -16,10 +16,10 @@ export declare namespace ApplePayClient {
1616
}
1717

1818
export class ApplePayClient {
19-
protected readonly _options: ApplePayClient.Options;
19+
protected readonly _options: NormalizedClientOptionsWithAuth<ApplePayClient.Options>;
2020

2121
constructor(options: ApplePayClient.Options = {}) {
22-
this._options = normalizeClientOptions(options);
22+
this._options = normalizeClientOptionsWithAuth(options);
2323
}
2424

2525
/**
@@ -57,12 +57,11 @@ export class ApplePayClient {
5757
request: Square.RegisterDomainRequest,
5858
requestOptions?: ApplePayClient.RequestOptions,
5959
): Promise<core.WithRawResponse<Square.RegisterDomainResponse>> {
60+
const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
6061
const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
62+
_authRequest.headers,
6163
this._options?.headers,
62-
mergeOnlyDefinedHeaders({
63-
Authorization: await this._getAuthorizationHeader(),
64-
"Square-Version": requestOptions?.version ?? "2025-10-16",
65-
}),
64+
mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }),
6665
requestOptions?.headers,
6766
);
6867
const _response = await (this._options.fetcher ?? core.fetcher)({
@@ -124,13 +123,4 @@ export class ApplePayClient {
124123
});
125124
}
126125
}
127-
128-
protected async _getAuthorizationHeader(): Promise<string | undefined> {
129-
const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN;
130-
if (bearer != null) {
131-
return `Bearer ${bearer}`;
132-
}
133-
134-
return undefined;
135-
}
136126
}

src/api/resources/bankAccounts/client/Client.ts

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This file was auto-generated by Fern from our API Definition.
22

33
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient";
4-
import { normalizeClientOptions } from "../../../../BaseClient";
4+
import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient";
55
import * as core from "../../../../core";
66
import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers";
77
import * as environments from "../../../../environments";
@@ -16,10 +16,10 @@ export declare namespace BankAccountsClient {
1616
}
1717

1818
export class BankAccountsClient {
19-
protected readonly _options: BankAccountsClient.Options;
19+
protected readonly _options: NormalizedClientOptionsWithAuth<BankAccountsClient.Options>;
2020

2121
constructor(options: BankAccountsClient.Options = {}) {
22-
this._options = normalizeClientOptions(options);
22+
this._options = normalizeClientOptionsWithAuth(options);
2323
}
2424

2525
/**
@@ -54,12 +54,11 @@ export class BankAccountsClient {
5454
if (locationId !== undefined) {
5555
_queryParams.location_id = locationId;
5656
}
57+
const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
5758
const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
59+
_authRequest.headers,
5860
this._options?.headers,
59-
mergeOnlyDefinedHeaders({
60-
Authorization: await this._getAuthorizationHeader(),
61-
"Square-Version": requestOptions?.version ?? "2025-10-16",
62-
}),
61+
mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }),
6362
requestOptions?.headers,
6463
);
6564
const _response = await (this._options.fetcher ?? core.fetcher)({
@@ -150,12 +149,11 @@ export class BankAccountsClient {
150149
requestOptions?: BankAccountsClient.RequestOptions,
151150
): Promise<core.WithRawResponse<Square.GetBankAccountByV1IdResponse>> {
152151
const { v1BankAccountId } = request;
152+
const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
153153
const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
154+
_authRequest.headers,
154155
this._options?.headers,
155-
mergeOnlyDefinedHeaders({
156-
Authorization: await this._getAuthorizationHeader(),
157-
"Square-Version": requestOptions?.version ?? "2025-10-16",
158-
}),
156+
mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }),
159157
requestOptions?.headers,
160158
);
161159
const _response = await (this._options.fetcher ?? core.fetcher)({
@@ -238,12 +236,11 @@ export class BankAccountsClient {
238236
requestOptions?: BankAccountsClient.RequestOptions,
239237
): Promise<core.WithRawResponse<Square.GetBankAccountResponse>> {
240238
const { bankAccountId } = request;
239+
const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
241240
const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
241+
_authRequest.headers,
242242
this._options?.headers,
243-
mergeOnlyDefinedHeaders({
244-
Authorization: await this._getAuthorizationHeader(),
245-
"Square-Version": requestOptions?.version ?? "2025-10-16",
246-
}),
243+
mergeOnlyDefinedHeaders({ "Square-Version": requestOptions?.version ?? "2025-10-16" }),
247244
requestOptions?.headers,
248245
);
249246
const _response = await (this._options.fetcher ?? core.fetcher)({
@@ -301,13 +298,4 @@ export class BankAccountsClient {
301298
});
302299
}
303300
}
304-
305-
protected async _getAuthorizationHeader(): Promise<string | undefined> {
306-
const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env.SQUARE_TOKEN;
307-
if (bearer != null) {
308-
return `Bearer ${bearer}`;
309-
}
310-
311-
return undefined;
312-
}
313301
}

0 commit comments

Comments
 (0)