Skip to content

Commit

Permalink
(feat, typescript): send user agent header <package>/<version> (#4234)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi authored Aug 8, 2024
1 parent 5ee2d80 commit afe57fb
Show file tree
Hide file tree
Showing 248 changed files with 717 additions and 740 deletions.
70 changes: 35 additions & 35 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
2 changes: 1 addition & 1 deletion generators/typescript/express/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"devDependencies": {
"@fern-fern/generator-exec-sdk": "^0.0.898",
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/abstract-generator-cli": "workspace:*",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"dependencies": {
"@fern-api/core-utils": "workspace:*",
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/abstract-schema-generator": "workspace:*",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/abstract-error-class-generator": "workspace:*",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"dependencies": {
"@fern-api/core-utils": "workspace:*",
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/abstract-schema-generator": "workspace:*",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/abstract-schema-generator": "workspace:*",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
"@fern-typescript/resolvers": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
"@fern-typescript/resolvers": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion generators/typescript/express/generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"dependencies": {
"@fern-api/core-utils": "workspace:*",
"@fern-api/fs-utils": "workspace:*",
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
"@fern-typescript/express-endpoint-type-schemas-generator": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion generators/typescript/model/type-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
"@fern-typescript/union-generator": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/resolvers": "workspace:*",
"ts-morph": "^15.1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"dependencies": {
"@fern-api/core-utils": "workspace:*",
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
"ts-morph": "^15.1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/abstract-schema-generator": "workspace:*",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion generators/typescript/model/union-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"dependencies": {
"@fern-api/core-utils": "workspace:*",
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
"ts-morph": "^15.1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/abstract-schema-generator": "workspace:*",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
Expand Down
6 changes: 6 additions & 0 deletions generators/typescript/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ 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.38.6] - 2024-08-07

- Feature: The SDK generator now sends a `User-Agent` header on each request that is set to
`<package>/<version>`. For example if your package is called `imdb` and is versioned `0.1.0`, then
the user agent header will be `imdb/0.1.0`.

## [0.38.5] - 2024-08-07

- Fix: Addressed fetcher unit test flakiness by using a mock fetcher
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.38.5
0.38.6
2 changes: 1 addition & 1 deletion generators/typescript/sdk/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"devDependencies": {
"@fern-api/fs-utils": "workspace:*",
"@fern-api/generator-commons": "workspace:*",
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/abstract-generator-cli": "workspace:*",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"dependencies": {
"@fern-api/core-utils": "workspace:*",
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
"@fern-typescript/resolvers": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,13 @@ export class GeneratedSdkClientClassImpl implements GeneratedSdkClientClass {
);
}

if (context.ir.sdkConfig.platformHeaders.userAgent != null) {
headers.push({
header: context.ir.sdkConfig.platformHeaders.userAgent.header,
value: ts.factory.createStringLiteral(context.ir.sdkConfig.platformHeaders.userAgent.value)
});
}

const generatedVersion = context.version.getGeneratedVersion();
if (generatedVersion != null) {
const header = generatedVersion.getHeader();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
"@fern-typescript/resolvers": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
"ts-morph": "^15.1.0"
Expand Down
2 changes: 1 addition & 1 deletion generators/typescript/sdk/generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@fern-api/logging-execa": "workspace:*",
"@fern-fern/generator-cli-sdk": "0.0.56",
"@fern-fern/generator-exec-sdk": "^0.0.898",
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-fern/snippet-sdk": "^0.0.5526",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"dependencies": {
"@fern-api/core-utils": "workspace:*",
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
"ts-morph": "^15.1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"dependencies": {
"@fern-api/core-utils": "workspace:*",
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/abstract-schema-generator": "workspace:*",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion generators/typescript/sdk/sdk-error-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/abstract-error-class-generator": "workspace:*",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"dependencies": {
"@fern-api/core-utils": "workspace:*",
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/abstract-schema-generator": "workspace:*",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/abstract-schema-generator": "workspace:*",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@fern-api/generator-commons": "workspace:*",
"@fern-api/logger": "workspace:*",
"@fern-fern/generator-exec-sdk": "^0.0.898",
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*"
},
Expand Down
2 changes: 1 addition & 1 deletion generators/typescript/utils/commons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@fern-api/fs-utils": "workspace:*",
"@fern-api/logger": "workspace:*",
"@fern-api/logging-execa": "workspace:*",
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/fetcher": "workspace:*",
"@fern-typescript/zurg": "workspace:*",
"decompress": "^4.2.1",
Expand Down
2 changes: 1 addition & 1 deletion generators/typescript/utils/contexts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"dependencies": {
"@fern-api/logger": "workspace:*",
"@fern-fern/generator-exec-sdk": "^0.0.898",
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/commons": "workspace:*",
"ts-morph": "^15.1.0"
},
Expand Down
2 changes: 1 addition & 1 deletion generators/typescript/utils/resolvers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.1.0",
"@fern-fern/ir-sdk": "53.4.0",
"@fern-typescript/commons": "workspace:*"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,36 @@ export const GenerationLanguage = {
} as const;

export type GenerationLanguage = Values<typeof GenerationLanguage>;

export function getPackageName({
generatorInvocation
}: {
generatorInvocation: GeneratorInvocation;
}): string | undefined {
return generatorInvocation.outputMode._visit<string | undefined>({
downloadFiles: () => undefined,
github: (val) =>
val.publishInfo?._visit<string | undefined>({
maven: (val) => val.coordinate,
npm: (val) => val.packageName,
pypi: (val) => val.packageName,
postman: () => undefined,
rubygems: (val) => val.packageName,
nuget: (val) => val.packageName,
_other: () => undefined
}),
githubV2: (val) =>
val.publishInfo?._visit<string | undefined>({
maven: (val) => val.coordinate,
npm: (val) => val.packageName,
pypi: (val) => val.packageName,
postman: () => undefined,
rubygems: (val) => val.packageName,
nuget: (val) => val.packageName,
_other: () => undefined
}),
publish: () => undefined,
publishV2: () => undefined,
_other: () => undefined
});
}
1 change: 1 addition & 0 deletions packages/cli/configuration/src/generators-yml/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export { GENERATOR_INVOCATIONS } from "./generatorInvocations";
export { GeneratorName } from "./GeneratorName";
export {
GenerationLanguage,
getPackageName,
type GeneratorGroup,
type GeneratorInvocation,
type GeneratorsConfiguration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ export async function getIntermediateRepresentation({
audiences,
generatorInvocation,
context,
irVersionOverride
irVersionOverride,
version,
packageName
}: {
workspace: FernWorkspace;
audiences: Audiences;
generatorInvocation: generatorsYml.GeneratorInvocation;
context: TaskContext;
irVersionOverride: string | undefined;
version: string | undefined;
packageName: string | undefined;
}): Promise<unknown> {
const intermediateRepresentation = await generateIntermediateRepresentation({
workspace,
Expand All @@ -28,8 +32,8 @@ export async function getIntermediateRepresentation({
smartCasing: generatorInvocation.smartCasing,
disableExamples: generatorInvocation.disableExamples,
readme: generatorInvocation.readme,
version: undefined,
packageName: undefined
version,
packageName
});
context.logger.debug("Generated IR");
const migratedIntermediateRepresentation =
Expand Down
Loading

0 comments on commit afe57fb

Please sign in to comment.