Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
armandobelardo committed Apr 20, 2024
2 parents f8ca195 + 286dbc1 commit 1516beb
Show file tree
Hide file tree
Showing 1,945 changed files with 56,691 additions and 4,057 deletions.
96 changes: 42 additions & 54 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
13 changes: 8 additions & 5 deletions fern/apis/public-api/definition/snippets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ service:
docs: |
The SDKs for which to load snippets. If unspecified,
snippets for the latest published SDKs will be returned.
loadLevel:
type: optional<SnippetLoadLevel>
docs: |
The level of detail to load for the snippet. If unspecified,
the full snippet will be returned.
endpoint: EndpointIdentifier
example:
type: optional<unknown>
docs: |
If present, the example will be used to generate the snippet.
Otherwise, snippet generation will default to your API Definition.
If your API Definition does not have an example, the snippet
will generated using an autogenerated example.
response: list<Snippet>
examples:
- request:
Expand Down
4 changes: 4 additions & 0 deletions generators/typescript/express/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.12.0-rc0] - 2024-04-12

- Support V38 of the IR

## [0.11.0-rc0] - 2024-04-12

- Feature: Add `allowExtraFields` option to permit extra fields in the returned response.
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.11.0-rc0
0.12.0-rc0
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.748",
"@fern-fern/ir-sdk": "^37.0.0",
"@fern-fern/ir-sdk": "^38.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": "^37.0.0",
"@fern-fern/ir-sdk": "^38.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": "^37.0.0",
"@fern-fern/ir-sdk": "^38.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": "^37.0.0",
"@fern-fern/ir-sdk": "^38.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": "^37.0.0",
"@fern-fern/ir-sdk": "^38.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": "^37.0.0",
"@fern-fern/ir-sdk": "^38.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": "^37.0.0",
"@fern-fern/ir-sdk": "^38.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": "^37.0.0",
"@fern-fern/ir-sdk": "^38.0.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": "^37.0.0",
"@fern-fern/ir-sdk": "^38.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": "^37.0.0",
"@fern-fern/ir-sdk": "^38.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": "^37.0.0",
"@fern-fern/ir-sdk": "^38.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": "^37.0.0",
"@fern-fern/ir-sdk": "^38.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": "^37.0.0",
"@fern-fern/ir-sdk": "^38.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": "^37.0.0",
"@fern-fern/ir-sdk": "^38.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": "^37.0.0",
"@fern-fern/ir-sdk": "^38.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.15.0-rc0] - 2024-04-19

- Feature: Bump to v38 of IR and support server-sent events where the events are sent
with a `data: ` prefix and terminated with a new line.

## [0.14.1-rc5] - 2024-04-17

- Fix: Code snippets are generated for file upload endpoints using `fs.readStream`. Previously,
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.14.1-rc5
0.15.0-rc0
1 change: 0 additions & 1 deletion generators/typescript/sdk/cli/browser-docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ COPY generators/typescript/sdk/cli/browser-docker/cache_heavy_dependencies.sh /
RUN /cache_heavy_dependencies.sh && rm /cache_heavy_dependencies.sh

COPY generators/typescript/utils/core-utilities/fetcher/src/ /assets/fetcher
COPY generators/typescript/utils/core-utilities/stream-utils/src/ /assets/stream-utils
COPY generators/typescript/utils/core-utilities/form-data-utils/src/ /assets/form-data-utils
COPY generators/typescript/utils/core-utilities/callback-queue/src/ /assets/callback-queue
COPY generators/typescript/utils/core-utilities/auth/src/ /assets/auth
Expand Down
1 change: 0 additions & 1 deletion generators/typescript/sdk/cli/node-docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ RUN apk --no-cache add git zip \
&& git config --global user.email "[email protected]"

COPY generators/typescript/utils/core-utilities/fetcher/src/ /assets/fetcher
COPY generators/typescript/utils/core-utilities/stream-utils/src/ /assets/stream-utils
COPY generators/typescript/utils/core-utilities/form-data-utils/src/ /assets/form-data-utils
COPY generators/typescript/utils/core-utilities/callback-queue/src/ /assets/callback-queue
COPY generators/typescript/utils/core-utilities/auth/src/ /assets/auth
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 @@ -34,7 +34,7 @@
"devDependencies": {
"@fern-api/fs-utils": "workspace:*",
"@fern-api/generator-commons": "workspace:*",
"@fern-fern/ir-sdk": "^37.0.0",
"@fern-fern/ir-sdk": "^38.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": "^37.0.0",
"@fern-fern/ir-sdk": "^38.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 @@ -5,7 +5,7 @@ import {
HttpResponse,
ResponseError
} from "@fern-fern/ir-sdk/api";
import { getTextOfTsNode, PackageId } from "@fern-typescript/commons";
import { getTextOfTsNode, PackageId, StreamingFetcher } from "@fern-typescript/commons";
import { GeneratedSdkEndpointTypeSchemas, SdkContext } from "@fern-typescript/contexts";
import { ErrorResolver } from "@fern-typescript/resolvers";
import { ts } from "ts-morph";
Expand Down Expand Up @@ -148,6 +148,22 @@ export class GeneratedThrowingEndpointResponse implements GeneratedEndpointRespo
)
];
} else if (this.response?.type === "streaming") {
const eventShape = this.response.value._visit<
StreamingFetcher.MessageEventShape | StreamingFetcher.SSEEventShape
>({
sse: () => ({ type: "sse" }),
json: (json) => ({
type: "json",
messageTerminator: ts.factory.createStringLiteral(json.terminator ?? "\n")
}),

text: () => {
throw new Error("Text response type is not supported for streaming responses");
},
_other: ({ type }) => {
throw new Error(`Unknown response type: ${type}`);
}
});
return [
ts.factory.createReturnStatement(
context.coreUtilities.streamUtils.Stream._construct({
Expand All @@ -158,7 +174,7 @@ export class GeneratedThrowingEndpointResponse implements GeneratedEndpointRespo
context.coreUtilities.fetcher.APIResponse.SuccessfulResponse.body
)
),
terminator: this.response.terminator ?? "\n",
eventShape,
parse: ts.factory.createArrowFunction(
[ts.factory.createToken(ts.SyntaxKind.AsyncKeyword)],
undefined,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assertNever } from "@fern-api/core-utils";
import { HttpResponse } from "@fern-fern/ir-sdk/api";
import { HttpResponse, PrimitiveType, TypeReference } from "@fern-fern/ir-sdk/api";
import { JavaScriptRuntime, visitJavaScriptRuntime } from "@fern-typescript/commons";
import { SdkContext } from "@fern-typescript/contexts";
import { ts } from "ts-morph";
Expand All @@ -25,11 +25,15 @@ export function getSuccessReturnType(
case "json":
return context.type.getReferenceToType(response.value.responseBodyType).typeNode;
case "streaming": {
if (response.dataEventType.type === "text") {
throw new Error("Cannot deserialize non-json stream data");
}
const dataEventType = context.type.getReferenceToType(response.dataEventType.json).typeNode;
return context.coreUtilities.streamUtils.Stream._getReferenceToType(dataEventType);
const dataEventType = response.value._visit({
json: (json) => context.type.getReferenceToType(json.payload),
sse: (sse) => context.type.getReferenceToType(sse.payload),
text: () => context.type.getReferenceToType(TypeReference.primitive(PrimitiveType.String)),
_other: ({ type }) => {
throw new Error(`Encountered unknown data event type ${type}`);
}
});
return context.coreUtilities.streamUtils.Stream._getReferenceToType(dataEventType.typeNode);
}
default:
assertNever(response);
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": "^37.0.0",
"@fern-fern/ir-sdk": "^38.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": "^37.0.0",
"@fern-fern/ir-sdk": "^38.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 @@ -29,7 +29,7 @@
"@fern-api/core-utils": "workspace:*",
"@fern-api/fs-utils": "workspace:*",
"@fern-fern/generator-exec-sdk": "^0.0.748",
"@fern-fern/ir-sdk": "^37.0.0",
"@fern-fern/ir-sdk": "^38.0.0",
"@fern-typescript/commons": "workspace:*",
"@fern-typescript/contexts": "workspace:*",
"@fern-typescript/endpoint-error-union-generator": "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": "^37.0.0",
"@fern-fern/ir-sdk": "^38.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 @@
},
"dependencies": {
"@fern-api/core-utils": "workspace:*",
"@fern-fern/ir-sdk": "^37.0.0",
"@fern-fern/ir-sdk": "^38.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 @@ -104,18 +104,18 @@ export class GeneratedSdkEndpointTypeSchemasImpl implements GeneratedSdkEndpoint
}

if (endpoint.response?.type === "streaming") {
if (endpoint.response.dataEventType.type === "text") {
if (endpoint.response.value.type === "text") {
throw new Error("Non-json responses are not supportd");
}
switch (endpoint.response.dataEventType.json.type) {
switch (endpoint.response.value.payload.type) {
case "primitive":
case "container":
this.generatedStreamDataSchema = new GeneratedEndpointTypeSchemaImpl({
packageId,
service,
endpoint,
typeName: GeneratedSdkEndpointTypeSchemasImpl.STREAM_DATA_SCHEMA_NAME,
type: endpoint.response.dataEventType.json
type: endpoint.response.value.payload
});
break;
// named response bodies are not generated - consumers should
Expand All @@ -125,7 +125,7 @@ export class GeneratedSdkEndpointTypeSchemasImpl implements GeneratedSdkEndpoint
case "unknown":
break;
default:
assertNever(endpoint.response.dataEventType.json);
assertNever(endpoint.response.value.payload);
}
}

Expand Down Expand Up @@ -319,16 +319,16 @@ export class GeneratedSdkEndpointTypeSchemasImpl implements GeneratedSdkEndpoint
if (this.endpoint.response?.type !== "streaming") {
throw new Error("Cannot deserialize stream data because it's not defined");
}
if (this.endpoint.response.dataEventType.type === "text") {
if (this.endpoint.response.value.type === "text") {
throw new Error("Cannot deserialize non-json stream data");
}

switch (this.endpoint.response.dataEventType.json.type) {
switch (this.endpoint.response.value.payload.type) {
case "unknown":
return referenceToRawStreamData;
case "named":
return context.typeSchema
.getSchemaOfNamedType(this.endpoint.response.dataEventType.json, { isGeneratingSchema: false })
.getSchemaOfNamedType(this.endpoint.response.value.payload, { isGeneratingSchema: false })
.parseOrThrow(referenceToRawStreamData, {
allowUnrecognizedEnumValues: true,
allowUnrecognizedUnionMembers: true,
Expand All @@ -351,7 +351,7 @@ export class GeneratedSdkEndpointTypeSchemasImpl implements GeneratedSdkEndpoint
breadcrumbsPrefix: ["response"]
});
default:
assertNever(this.endpoint.response.dataEventType.json);
assertNever(this.endpoint.response.value.payload);
}
}
}
Loading

0 comments on commit 1516beb

Please sign in to comment.