Skip to content

Commit

Permalink
Merge branch 'main' into chdeskur/frontmatter-logo-update
Browse files Browse the repository at this point in the history
  • Loading branch information
dannysheridan authored Jan 13, 2025
2 parents f6098d1 + bc9aa31 commit be3b1c0
Show file tree
Hide file tree
Showing 369 changed files with 3,709 additions and 813 deletions.
4 changes: 4 additions & 0 deletions generators/typescript/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.46.9] - 2025-01-13

- Fix: Expose `baseUrl` as a default Client constructor option and construct URL correctly.

## [0.46.8] - 2025-01-13

- Fix: Generate the `version.ts` file correctly
Expand Down
2 changes: 1 addition & 1 deletion generators/typescript/sdk/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.46.8
0.46.9
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export class GeneratedSdkClientClassImpl implements GeneratedSdkClientClass {
private static MAX_RETRIES_REQUEST_OPTION_PROPERTY_NAME = "maxRetries";
private static OPTIONS_INTERFACE_NAME = "Options";
private static OPTIONS_PRIVATE_MEMBER = "_options";
private static BASE_URL_OPTION_PROPERTY_NAME = "baseUrl";
private static ENVIRONMENT_OPTION_PROPERTY_NAME = "environment";
private static CUSTOM_FETCHER_PROPERTY_NAME = "fetcher";
private static AUTHORIZATION_HEADER_HELPER_METHOD_NAME = "_getAuthorizationHeader";
Expand Down Expand Up @@ -518,6 +519,20 @@ export class GeneratedSdkClientClassImpl implements GeneratedSdkClientClass {
GeneratedSdkClientClassImpl.ENVIRONMENT_OPTION_PROPERTY_NAME
)
)
),
ts.factory.createPropertyAssignment(
ts.factory.createIdentifier(
GeneratedSdkClientClassImpl.BASE_URL_OPTION_PROPERTY_NAME
),
ts.factory.createPropertyAccessExpression(
ts.factory.createPropertyAccessExpression(
ts.factory.createThis(),
GeneratedSdkClientClassImpl.OPTIONS_PRIVATE_MEMBER
),
ts.factory.createIdentifier(
GeneratedSdkClientClassImpl.BASE_URL_OPTION_PROPERTY_NAME
)
)
)
],
true
Expand Down Expand Up @@ -721,6 +736,18 @@ export class GeneratedSdkClientClassImpl implements GeneratedSdkClientClass {
return this.getCustomAuthorizationHeaders().length > 0;
}

public getBaseUrl(endpoint: HttpEndpoint, context: SdkContext): ts.Expression {
const referenceToBaseUrl = this.getReferenceToBaseUrl(context);

const environment = this.getEnvironment(endpoint, context);

return ts.factory.createBinaryExpression(
referenceToBaseUrl,
ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken),
environment
);
}

public getEnvironment(endpoint: HttpEndpoint, context: SdkContext): ts.Expression {
let referenceToEnvironmentValue = this.getReferenceToEnvironment(context);

Expand Down Expand Up @@ -1156,6 +1183,17 @@ export class GeneratedSdkClientClassImpl implements GeneratedSdkClientClass {
});
}

properties.push({
name: GeneratedSdkClientClassImpl.BASE_URL_OPTION_PROPERTY_NAME,
type: getTextOfTsNode(
context.coreUtilities.fetcher.Supplier._getReferenceToType(
ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword)
)
),
hasQuestionToken: true,
docs: ["Specify a custom URL to connect the client to."]
});

if (this.isRoot && this.oauthAuthScheme != null && context.generateOAuthClients) {
properties.push({
name: OAuthTokenProviderGenerator.OAUTH_CLIENT_ID_PROPERTY_NAME,
Expand Down Expand Up @@ -1364,6 +1402,12 @@ export class GeneratedSdkClientClassImpl implements GeneratedSdkClientClass {
);
}

private getReferenceToBaseUrl(context: SdkContext): ts.Expression {
return context.coreUtilities.fetcher.Supplier.get(
this.getReferenceToOption(GeneratedSdkClientClassImpl.BASE_URL_OPTION_PROPERTY_NAME)
);
}

public getReferenceToRequestOptions(endpoint: HttpEndpoint): ts.TypeReferenceNode {
return ts.factory.createTypeReferenceNode(
ts.factory.createQualifiedName(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ export class GeneratedFileDownloadEndpointImplementation implements GeneratedEnd
return this.request.getBuildRequestStatements(context);
}

private getReferenceToEnvironment(context: SdkContext): ts.Expression {
const referenceToEnvironment = this.generatedSdkClientClass.getEnvironment(this.endpoint, context);
private getReferenceToBaseUrl(context: SdkContext): ts.Expression {
const baseUrl = this.generatedSdkClientClass.getBaseUrl(this.endpoint, context);
const url = buildUrl({
endpoint: this.endpoint,
generatedClientClass: this.generatedSdkClientClass,
Expand All @@ -163,16 +163,16 @@ export class GeneratedFileDownloadEndpointImplementation implements GeneratedEnd
});

if (url != null) {
return context.externalDependencies.urlJoin.invoke([referenceToEnvironment, url]);
return context.externalDependencies.urlJoin.invoke([baseUrl, url]);
} else {
return referenceToEnvironment;
return baseUrl;
}
}

public invokeFetcher(context: SdkContext): ts.Statement[] {
const fetcherArgs: Fetcher.Args = {
...this.request.getFetcherRequestArgs(context),
url: this.getReferenceToEnvironment(context),
url: this.getReferenceToBaseUrl(context),
method: ts.factory.createStringLiteral(this.endpoint.method),
timeoutInSeconds: getTimeoutExpression({
defaultTimeoutInSeconds: this.defaultTimeoutInSeconds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ export class GeneratedStreamingEndpointImplementation implements GeneratedEndpoi
return this.request.getBuildRequestStatements(context);
}

private getReferenceToEnvironment(context: SdkContext): ts.Expression {
const referenceToEnvironment = this.generatedSdkClientClass.getEnvironment(this.endpoint, context);
private getReferenceToBaseUrl(context: SdkContext): ts.Expression {
const baseUrl = this.generatedSdkClientClass.getBaseUrl(this.endpoint, context);
const url = buildUrl({
endpoint: this.endpoint,
generatedClientClass: this.generatedSdkClientClass,
Expand All @@ -204,16 +204,16 @@ export class GeneratedStreamingEndpointImplementation implements GeneratedEndpoi
}
});
if (url != null) {
return context.externalDependencies.urlJoin.invoke([referenceToEnvironment, url]);
return context.externalDependencies.urlJoin.invoke([baseUrl, url]);
} else {
return referenceToEnvironment;
return baseUrl;
}
}

public invokeFetcher(context: SdkContext): ts.Statement[] {
const fetcherArgs: Fetcher.Args = {
...this.request.getFetcherRequestArgs(context),
url: this.getReferenceToEnvironment(context),
url: this.getReferenceToBaseUrl(context),
method: ts.factory.createStringLiteral(this.endpoint.method),
timeoutInSeconds: getTimeoutExpression({
defaultTimeoutInSeconds: this.defaultTimeoutInSeconds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ export class GeneratedDefaultEndpointImplementation implements GeneratedEndpoint
return [...this.invokeFetcher(context), ...this.response.getReturnResponseStatements(context)];
}

private getReferenceToEnvironment(context: SdkContext): ts.Expression {
const referenceToEnvironment = this.generatedSdkClientClass.getEnvironment(this.endpoint, context);
private getReferenceToBaseUrl(context: SdkContext): ts.Expression {
const baseUrl = this.generatedSdkClientClass.getBaseUrl(this.endpoint, context);
const url = buildUrl({
endpoint: this.endpoint,
generatedClientClass: this.generatedSdkClientClass,
Expand All @@ -399,16 +399,16 @@ export class GeneratedDefaultEndpointImplementation implements GeneratedEndpoint
}
});
if (url != null) {
return context.externalDependencies.urlJoin.invoke([referenceToEnvironment, url]);
return context.externalDependencies.urlJoin.invoke([baseUrl, url]);
} else {
return referenceToEnvironment;
return baseUrl;
}
}

private invokeFetcher(context: SdkContext): ts.Statement[] {
const fetcherArgs: Fetcher.Args = {
...this.request.getFetcherRequestArgs(context),
url: this.getReferenceToEnvironment(context),
url: this.getReferenceToBaseUrl(context),
method: ts.factory.createStringLiteral(this.endpoint.method),
timeoutInSeconds: getTimeoutExpression({
defaultTimeoutInSeconds: this.defaultTimeoutInSeconds,
Expand Down
8 changes: 7 additions & 1 deletion seed/ts-sdk/alias-extends/src/Client.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion seed/ts-sdk/alias/src/Client.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions seed/ts-sdk/any-auth/src/Client.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion seed/ts-sdk/any-auth/src/api/resources/auth/client/Client.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion seed/ts-sdk/any-auth/src/api/resources/user/client/Client.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions seed/ts-sdk/api-wide-base-path/src/Client.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions seed/ts-sdk/audiences/no-custom-config/src/Client.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit be3b1c0

Please sign in to comment.