Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi committed Dec 12, 2024
1 parent 26b7ac8 commit 8125bd2
Show file tree
Hide file tree
Showing 50 changed files with 916 additions and 96 deletions.
2 changes: 1 addition & 1 deletion generators/typescript/codegen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"devDependencies": {
"@fern-api/core-utils": "workspace:*",
"@fern-api/base-generator": "workspace:*",
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.0.0",
"@types/jest": "^29.5.12",
"@types/node": "18.7.18",
"depcheck": "^1.4.6",
Expand Down
2 changes: 1 addition & 1 deletion generators/typescript/express/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"devDependencies": {
"@fern-fern/generator-exec-sdk": "^0.0.898",
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.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 @@ -28,7 +28,7 @@
},
"dependencies": {
"@fern-api/core-utils": "workspace:*",
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.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 @@ -196,6 +196,9 @@ export class GeneratedExpressEndpointTypeSchemasImpl implements GeneratedExpress
if (this.endpoint.response.body?.type === "text") {
throw new Error("Text response is not supported");
}
if (this.endpoint.response.body.type === "bytes") {
throw new Error("Bytes response is not supported");
}

if (!this.includeSerdeLayer) {
return referenceToParsedResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.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 @@ -28,7 +28,7 @@
},
"dependencies": {
"@fern-api/core-utils": "workspace:*",
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.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 @@ -27,7 +27,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.0.0",
"@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 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.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 @@ -27,7 +27,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.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 @@ -27,7 +27,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.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 @@ -936,6 +936,9 @@ export class GeneratedExpressServiceImpl implements GeneratedExpressService {
fileDownload: () => {
throw new Error("File download is not supported");
},
bytes: () => {
throw new Error("Bytes is not supported");
},
text: () => {
throw new Error("Text response is not supported");
},
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 @@ -30,7 +30,7 @@
"@fern-api/core-utils": "workspace:*",
"@fern-api/fs-utils": "workspace:*",
"@fern-api/logger": "workspace:*",
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.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 @@ -27,7 +27,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.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 @@ -27,7 +27,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.0.0",
"@fern-api/core-utils": "workspace:*",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/resolvers": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"dependencies": {
"@fern-api/core-utils": "workspace:*",
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.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 @@ -27,7 +27,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.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 @@ -28,7 +28,7 @@
},
"dependencies": {
"@fern-api/core-utils": "workspace:*",
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.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 @@ -27,7 +27,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.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/sdk/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"devDependencies": {
"@fern-api/fs-utils": "workspace:*",
"@fern-api/base-generator": "workspace:*",
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.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 @@ -28,7 +28,7 @@
},
"dependencies": {
"@fern-api/core-utils": "workspace:*",
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.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 @@ -210,6 +210,7 @@ export class GeneratedSdkClientClassImpl implements GeneratedSdkClientClass {
| HttpResponseBody.FileDownload
| HttpResponseBody.Text
| HttpResponseBody.Streaming
| HttpResponseBody.Bytes
| undefined;
}) => {
if (neverThrowErrors) {
Expand Down Expand Up @@ -237,7 +238,7 @@ export class GeneratedSdkClientClassImpl implements GeneratedSdkClientClass {
const getDefaultEndpointImplementation = ({
response
}: {
response: HttpResponseBody.Json | HttpResponseBody.FileDownload | HttpResponseBody.Text | undefined;
response: HttpResponseBody.Json | HttpResponseBody.FileDownload | HttpResponseBody.Text | HttpResponseBody.Bytes | undefined;
}) => {
return new GeneratedDefaultEndpointImplementation({
endpoint,
Expand Down Expand Up @@ -307,6 +308,11 @@ export class GeneratedSdkClientClassImpl implements GeneratedSdkClientClass {
retainOriginalCasing: this.retainOriginalCasing,
omitUndefined: this.omitUndefined
}),
bytes: (bytesResponse) => {
return getDefaultEndpointImplementation({
response: HttpResponseBody.bytes(bytesResponse)
});
},
text: (textResponse) => {
return getDefaultEndpointImplementation({
response: HttpResponseBody.text(textResponse)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ export class GeneratedDefaultEndpointImplementation implements GeneratedEndpoint
fetcherArgs.responseType = "text";
}

if (this.endpoint.response?.body?.type === "bytes") {
fetcherArgs.responseType = "arrayBuffer";
}

return [
ts.factory.createVariableStatement(
undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export declare namespace GeneratedNonThrowingEndpointResponse {
| HttpResponseBody.FileDownload
| HttpResponseBody.Streaming
| HttpResponseBody.Text
| HttpResponseBody.Bytes
| undefined;
errorDiscriminationStrategy: ErrorDiscriminationStrategy;
errorResolver: ErrorResolver;
Expand All @@ -37,6 +38,7 @@ export class GeneratedNonThrowingEndpointResponse implements GeneratedEndpointRe
| HttpResponseBody.FileDownload
| HttpResponseBody.Streaming
| HttpResponseBody.Text
| HttpResponseBody.Bytes
| undefined;
private errorDiscriminationStrategy: ErrorDiscriminationStrategy;
private errorResolver: ErrorResolver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export declare namespace GeneratedThrowingEndpointResponse {
| HttpResponseBody.FileDownload
| HttpResponseBody.Streaming
| HttpResponseBody.Text
| HttpResponseBody.Bytes
| undefined;
errorDiscriminationStrategy: ErrorDiscriminationStrategy;
errorResolver: ErrorResolver;
Expand All @@ -53,6 +54,7 @@ export class GeneratedThrowingEndpointResponse implements GeneratedEndpointRespo
| HttpResponseBody.FileDownload
| HttpResponseBody.Streaming
| HttpResponseBody.Text
| HttpResponseBody.Bytes
| undefined;
private errorDiscriminationStrategy: ErrorDiscriminationStrategy;
private errorResolver: ErrorResolver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export function getSuccessReturnType(
| HttpResponseBody.FileDownload
| HttpResponseBody.Streaming
| HttpResponseBody.Text
| HttpResponseBody.Bytes
| undefined,
context: SdkContext,
opts: {
Expand All @@ -27,6 +28,15 @@ export function getSuccessReturnType(
includeContentHeadersOnResponse: opts.includeContentHeadersOnResponse
});
}
case "fileDownload": {

Check failure on line 31 in generators/typescript/sdk/client-class-generator/src/endpoints/default/endpoint-response/getSuccessReturnType.ts

View workflow job for this annotation

GitHub Actions / eslint

Duplicate case label
return getFileType({
targetRuntime: context.targetRuntime,
context,
includeContentHeadersOnResponse: opts.includeContentHeadersOnResponse
});
}
case "bytes":
return ts.factory.createTypeReferenceNode("ArrayBuffer");
case "json":
return context.type.getReferenceToType(response.value.responseBodyType).typeNode;
case "text":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.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 @@ -27,7 +27,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.0.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 @@ -34,7 +34,7 @@
"@fern-api/logger": "workspace:*",
"@fern-fern/generator-cli-sdk": "0.0.17",
"@fern-fern/generator-exec-sdk": "^0.0.898",
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.0.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 @@ -28,7 +28,7 @@
},
"dependencies": {
"@fern-api/core-utils": "workspace:*",
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.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 @@ -28,7 +28,7 @@
},
"dependencies": {
"@fern-api/core-utils": "workspace:*",
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.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 @@ -268,6 +268,10 @@ export class GeneratedSdkEndpointTypeSchemasImpl implements GeneratedSdkEndpoint
}

if (this.endpoint.response.body.type === "text") {
return referenceToRawResponse;
}

if (this.endpoint.response.body.type === "bytes") {
return ts.factory.createAsExpression(
referenceToRawResponse,
context.type.getReferenceToType(TypeReference.primitive({ v1: PrimitiveTypeV1.String, v2: undefined }))
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 @@ -27,7 +27,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.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 @@ -28,7 +28,7 @@
},
"dependencies": {
"@fern-api/core-utils": "workspace:*",
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.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 @@ -27,7 +27,7 @@
"depcheck": "depcheck"
},
"dependencies": {
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.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 @@ -31,7 +31,7 @@
"@fern-api/base-generator": "workspace:*",
"@fern-api/logger": "workspace:*",
"@fern-fern/generator-exec-sdk": "^0.0.898",
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.0.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 @@ -31,7 +31,7 @@
"@fern-api/fs-utils": "workspace:*",
"@fern-api/logger": "workspace:*",
"@fern-api/logging-execa": "workspace:*",
"@fern-fern/ir-sdk": "53.23.0",
"@fern-fern/ir-sdk": "54.0.0",
"@fern-typescript/fetcher": "workspace:*",
"@fern-typescript/zurg": "workspace:*",
"decompress": "^4.2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export declare namespace Fetcher {
timeoutInSeconds: ts.Expression;
maxRetries?: ts.Expression;
requestType?: "json" | "file" | "bytes" | "other";
responseType?: "json" | "blob" | "sse" | "streaming" | "text";
responseType?: "json" | "blob" | "sse" | "streaming" | "text" | "arrayBuffer";
duplex?: ts.Expression;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class FetcherImpl extends CoreUtility implements Fetcher {
dependencyManager.addDependency("form-data", "^4.0.0");
dependencyManager.addDependency("formdata-node", "^6.0.3");
dependencyManager.addDependency("node-fetch", "2.7.0");
dependencyManager.addDependency("qs", "6.11.2");
dependencyManager.addDependency("qs", "6.13.0");
dependencyManager.addDependency("readable-stream", "^4.5.2");
dependencyManager.addDependency("@types/qs", "6.9.8", {
type: DependencyType.DEV
Expand Down
Loading

0 comments on commit 8125bd2

Please sign in to comment.