Skip to content

Commit

Permalink
(fix, internal): typescript generators depend on latest ir (#3583)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi authored May 9, 2024
1 parent da58c23 commit 8ed84ba
Show file tree
Hide file tree
Showing 248 changed files with 41,237 additions and 36,727 deletions.
64 changes: 32 additions & 32 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
8 changes: 8 additions & 0 deletions generators/typescript/express/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ 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.13.0] - 2024-05-06

- Feature: Bump to v43 of IR which means that you will need `0.26.1` of the Fern CLI version. To bump your
CLI version, please run `fern upgrade`.

If you specify custom response status codes, the underlying express implementation will send that back
to the user.

## [0.12.0] - 2024-05-07

- Improvement: Support a `skipRequestValidation` configuration so that users can disable
Expand Down
2 changes: 1 addition & 1 deletion generators/typescript/express/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.12.0
0.13.0
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.763",
"@fern-fern/ir-sdk": "^38.0.0",
"@fern-fern/ir-sdk": "^43.0.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": "^38.0.0",
"@fern-fern/ir-sdk": "^43.0.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 @@ -67,16 +67,16 @@ export class GeneratedExpressEndpointTypeSchemasImpl implements GeneratedExpress
}
}

if (endpoint.response?.type === "json") {
switch (endpoint.response.value.responseBodyType.type) {
if (endpoint.response?.body?.type === "json") {
switch (endpoint.response.body.value.responseBodyType.type) {
case "primitive":
case "container":
this.generatedResponseSchema = new GeneratedEndpointTypeSchemaImpl({
packageId,
service,
endpoint,
typeName: GeneratedExpressEndpointTypeSchemasImpl.RESPONSE_SCHEMA_NAME,
type: endpoint.response.value.responseBodyType
type: endpoint.response.body.value.responseBodyType
});
break;
// named response bodies are not generated - consumers should
Expand All @@ -86,7 +86,7 @@ export class GeneratedExpressEndpointTypeSchemasImpl implements GeneratedExpress
case "unknown":
break;
default:
assertNever(endpoint.response.value.responseBodyType);
assertNever(endpoint.response.body.value.responseBodyType);
}
}
}
Expand Down Expand Up @@ -172,30 +172,32 @@ export class GeneratedExpressEndpointTypeSchemasImpl implements GeneratedExpress
}

public serializeResponse(referenceToParsedResponse: ts.Expression, context: ExpressContext): ts.Expression {
if (this.endpoint.response == null) {
throw new Error("Cannot deserialize response because it's not defined");
if (this.endpoint.response?.body == null) {
throw new Error("Cannot serialize response because it's not defined");
}

if (this.endpoint.response.type === "fileDownload") {
if (this.endpoint.response.body?.type === "fileDownload") {
throw new Error("Cannot serialize file");
}
if (this.endpoint.response.type === "streaming") {
if (this.endpoint.response.body?.type === "streaming") {
throw new Error("Streaming response is not supported");
}
if (this.endpoint.response.type === "text") {
if (this.endpoint.response.body?.type === "text") {
throw new Error("Text response is not supported");
}

if (!this.includeSerdeLayer) {
return referenceToParsedResponse;
}

switch (this.endpoint.response.value.responseBodyType.type) {
switch (this.endpoint.response.body.value.responseBodyType.type) {
case "unknown":
return referenceToParsedResponse;
case "named":
return context.typeSchema
.getSchemaOfNamedType(this.endpoint.response.value.responseBodyType, { isGeneratingSchema: false })
.getSchemaOfNamedType(this.endpoint.response.body.value.responseBodyType, {
isGeneratingSchema: false
})
.jsonOrThrow(referenceToParsedResponse, {
...getSchemaOptions({
allowExtraFields: this.allowExtraFields
Expand All @@ -214,7 +216,7 @@ export class GeneratedExpressEndpointTypeSchemasImpl implements GeneratedExpress
})
});
default:
assertNever(this.endpoint.response.value.responseBodyType);
assertNever(this.endpoint.response.body?.value.responseBodyType);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "^38.0.0",
"@fern-fern/ir-sdk": "^43.0.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": "^38.0.0",
"@fern-fern/ir-sdk": "^43.0.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": "^38.0.0",
"@fern-fern/ir-sdk": "^43.0.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": "^38.0.0",
"@fern-fern/ir-sdk": "^43.0.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": "^38.0.0",
"@fern-fern/ir-sdk": "^43.0.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": "^38.0.0",
"@fern-fern/ir-sdk": "^43.0.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 @@ -2,7 +2,7 @@ import {
HttpEndpoint,
HttpMethod,
HttpRequestBody,
HttpResponse,
HttpResponseBody,
HttpService,
Package,
PathParameter
Expand Down Expand Up @@ -221,8 +221,8 @@ export class GeneratedExpressServiceImpl implements GeneratedExpressService {
})
: undefined,
response:
endpoint.response != null
? this.getResponseBodyType(endpoint.response, context)
endpoint.response?.body != null
? this.getResponseBodyType(endpoint.response.body, context)
: undefined
})
)
Expand All @@ -237,15 +237,15 @@ export class GeneratedExpressServiceImpl implements GeneratedExpressService {
undefined,
ts.factory.createFunctionTypeNode(
undefined,
endpoint.response != null
endpoint.response?.body != null
? [
ts.factory.createParameterDeclaration(
undefined,
undefined,
undefined,
GeneratedExpressServiceImpl.RESPONSE_BODY_PARAMETER_NAME,
undefined,
this.getResponseBodyType(endpoint.response, context)
this.getResponseBodyType(endpoint.response.body, context)
)
]
: [],
Expand Down Expand Up @@ -614,7 +614,7 @@ export class GeneratedExpressServiceImpl implements GeneratedExpressService {
ts.factory.createArrowFunction(
[ts.factory.createToken(ts.SyntaxKind.AsyncKeyword)],
undefined,
endpoint.response != null
endpoint.response?.body != null
? [
ts.factory.createParameterDeclaration(
undefined,
Expand All @@ -629,7 +629,7 @@ export class GeneratedExpressServiceImpl implements GeneratedExpressService {
ts.factory.createBlock(
[
ts.factory.createExpressionStatement(
endpoint.response != null
endpoint.response?.body != null
? context.externalDependencies.express.Response.json({
referenceToExpressResponse: expressResponse,
valueToSend: context.expressEndpointTypeSchemas
Expand All @@ -642,7 +642,8 @@ export class GeneratedExpressServiceImpl implements GeneratedExpressService {
GeneratedExpressServiceImpl.RESPONSE_BODY_PARAMETER_NAME
),
context
)
),
status: endpoint.response.statusCode
})
: context.externalDependencies.express.Response.sendStatus({
referenceToExpressResponse: expressResponse,
Expand Down Expand Up @@ -909,8 +910,8 @@ export class GeneratedExpressServiceImpl implements GeneratedExpressService {
return `${this.serviceClassName}Methods`;
}

private getResponseBodyType(response: HttpResponse, context: ExpressContext): ts.TypeNode {
return HttpResponse._visit<ts.TypeNode>(response, {
private getResponseBodyType(response: HttpResponseBody, context: ExpressContext): ts.TypeNode {
return HttpResponseBody._visit<ts.TypeNode>(response, {
json: (jsonResponse) => context.type.getReferenceToType(jsonResponse.responseBodyType).typeNode,
streaming: () => {
throw new Error("Streaming is not supported");
Expand All @@ -922,7 +923,7 @@ export class GeneratedExpressServiceImpl implements GeneratedExpressService {
throw new Error("Text response is not supported");
},
_other: () => {
throw new Error("Unknown HttpResponse: " + response.type);
throw new Error("Unknown HttpResponseBody: " + response.type);
}
});
}
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": "^38.0.0",
"@fern-fern/ir-sdk": "^43.0.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": "^38.0.0",
"@fern-fern/ir-sdk": "^43.0.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": "^38.0.0",
"@fern-fern/ir-sdk": "^43.0.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": "^38.0.0",
"@fern-fern/ir-sdk": "^43.0.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": "^38.0.0",
"@fern-fern/ir-sdk": "^43.0.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": "^38.0.0",
"@fern-fern/ir-sdk": "^43.0.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": "^38.0.0",
"@fern-fern/ir-sdk": "^43.0.0",
"@fern-typescript/abstract-schema-generator": "workspace:*",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
Expand Down
5 changes: 5 additions & 0 deletions generators/typescript/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ 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.17.0] - 2024-05-06

- Internal: Bump to v43 of IR which means that you will need `0.26.1` of the Fern CLI version. To bump your
CLI version, please run `fern upgrade`.

## [0.16.0-rc8] - 2024-05-06

- Improvement: The SDK generator now supports upload endpoints that specify an array of files like so:
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.16.0-rc8
0.17.0
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": "^38.0.0",
"@fern-fern/ir-sdk": "^43.0.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": "^38.0.0",
"@fern-fern/ir-sdk": "43.0.0",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
"@fern-typescript/resolvers": "workspace:*",
Expand Down
Loading

0 comments on commit 8ed84ba

Please sign in to comment.