Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into modernize-node-18
Browse files Browse the repository at this point in the history
  • Loading branch information
remorses committed Dec 27, 2024
2 parents 29b119a + b679c79 commit 83ab102
Show file tree
Hide file tree
Showing 2,471 changed files with 4,299 additions and 4,249 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export class GeneratedEndpointTypeSchemaImpl extends AbstractGeneratedEndpointTy
protected generateRawTypeDeclaration(context: ExpressContext, module: ModuleDeclaration): void {
module.addTypeAlias({
name: AbstractGeneratedSchema.RAW_TYPE_NAME,
type: getTextOfTsNode(context.typeSchema.getReferenceToRawType(this.type).typeNode)
type: getTextOfTsNode(context.typeSchema.getReferenceToRawType(this.type).typeNode),
isExported: true
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ export class GeneratedExpressErrorSchemaImpl
protected generateRawTypeDeclaration(context: ExpressContext, module: ModuleDeclaration): void {
module.addTypeAlias({
name: AbstractGeneratedSchema.RAW_TYPE_NAME,
type: getTextOfTsNode(context.typeSchema.getReferenceToRawType(this.type).typeNode)
type: getTextOfTsNode(context.typeSchema.getReferenceToRawType(this.type).typeNode),
isExported: true
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export class GeneratedExpressInlinedRequestBodySchemaImpl
protected generateRawTypeDeclaration(context: ExpressContext, module: ModuleDeclaration): void {
module.addInterface({
name: AbstractGeneratedSchema.RAW_TYPE_NAME,
isExported: true,
properties: this.inlinedRequestBody.properties.map((property) => {
const type = context.typeSchema.getReferenceToRawType(property.valueType);
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
GetReferenceOpts,
getTextOfTsNode,
getWriterForMultiLineUnionType,
maybeAddDocsNode,
maybeAddDocsStructure
} from "@fern-typescript/commons";
import { BaseContext, GeneratedEnumType } from "@fern-typescript/contexts";
Expand Down Expand Up @@ -251,7 +250,8 @@ export class GeneratedEnumTypeImpl<Context extends BaseContext>
)
)
}
]
],
isExported: true
}
]
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export class GeneratedAliasTypeSchemaImpl<Context extends ModelContext>
protected override generateRawTypeDeclaration(context: Context, module: ModuleDeclaration): void {
module.addTypeAlias({
name: AbstractGeneratedSchema.RAW_TYPE_NAME,
type: getTextOfTsNode(context.typeSchema.getReferenceToRawType(this.shape.aliasOf).typeNode)
type: getTextOfTsNode(context.typeSchema.getReferenceToRawType(this.shape.aliasOf).typeNode),
isExported: true
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export class GeneratedEnumTypeSchemaImpl<Context extends BaseContext>
ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(value.name.wireValue))
)
)
)
),
isExported: true
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ export class GeneratedObjectTypeSchemaImpl<Context extends ModelContext>
}
]
: [])
]
],
isExported: true
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export class GeneratedUndiscriminatedUnionTypeSchemaImpl<Context extends ModelCo
ts.factory.createUnionTypeNode(
this.shape.members.map((value) => context.typeSchema.getReferenceToRawType(value.type).typeNode)
)
)
),
isExported: true
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ export class GeneratedUnionImpl<Context extends ModelContext> implements Generat
name: GeneratedUnionImpl.VISIT_UTIL_PROPERTY_NAME,
type: getTextOfTsNode(this.getVisitSignature(context))
}
]
],
isExported: true
};
}

Expand All @@ -383,7 +384,8 @@ export class GeneratedUnionImpl<Context extends ModelContext> implements Generat
type: getTextOfTsNode(this.noOptionalProperties ? type.typeNode : type.typeNodeWithoutUndefined),
hasQuestionToken: !this.noOptionalProperties && type.isOptional
};
})
}),
isExported: true
};
}

Expand Down Expand Up @@ -428,7 +430,8 @@ export class GeneratedUnionImpl<Context extends ModelContext> implements Generat
name: singleUnionType.getVisitorKey(),
type: getTextOfTsNode(singleUnionType.getVisitMethodSignature(context, this))
})
)
),
isExported: true
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export abstract class AbstractRawSingleUnionType<Context> implements RawSingleUn
type: `"${this.discriminantValue}"`
},
...this.getNonDiscriminantPropertiesForInterface(context)
]
],
isExported: true
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ export class GeneratedUnionSchema<Context extends ModelContext> extends Abstract
)
)
)
)
),
isExported: true
});

for (const interfaceStructure of interfaces) {
Expand All @@ -85,7 +86,8 @@ export class GeneratedUnionSchema<Context extends ModelContext> extends Abstract
type: getTextOfTsNode(type.typeNodeWithoutUndefined),
hasQuestionToken: type.isOptional
};
})
}),
isExported: true
});
}
}
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 @@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.46.0] - 2024-12-27

- Feat: Remove `node-fetch` from generated SDK dependencies and always use the global fetch function instead, this lets you bundle the SDK for the browser with tools like Vite and Rollup without marking node-fetch as external.
## [0.45.1] - 2024-12-27

- Fix: Export everything inside of TypeScript namespaces that used to be ambient.

For the `enableInlineTypes` feature, some namespaces were no longer declared (ambient), and types and interfaces inside the namespace would no longer be automatically exported without the `export` keyword. This fix exports everything that's inside these namespaces and also declared namespaces for good measure (in case they are not declared in the future).

## [0.45.0] - 2024-12-26

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,8 @@ export class GeneratedSdkClientClassImpl implements GeneratedSdkClientClass {
hasQuestionToken: true,
docs: ["Additional headers to include in the request."]
}
]
],
isExported: true
};

const generatedVersion = context.versionContext.getGeneratedVersion();
Expand Down Expand Up @@ -1033,7 +1034,8 @@ export class GeneratedSdkClientClassImpl implements GeneratedSdkClientClass {
kind: StructureKind.Interface,
name: GeneratedSdkClientClassImpl.IDEMPOTENT_REQUEST_OPTIONS_INTERFACE_NAME,
extends: [GeneratedSdkClientClassImpl.REQUEST_OPTIONS_INTERFACE_NAME],
properties
properties,
isExported: true
};
}

Expand Down Expand Up @@ -1336,7 +1338,8 @@ export class GeneratedSdkClientClassImpl implements GeneratedSdkClientClass {
return {
kind: StructureKind.Interface,
name: GeneratedSdkClientClassImpl.OPTIONS_INTERFACE_NAME,
properties
properties,
isExported: true
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export class GeneratedEndpointTypeSchemaImpl extends AbstractGeneratedEndpointTy
protected generateRawTypeDeclaration(context: SdkContext, module: ModuleDeclaration): void {
module.addTypeAlias({
name: AbstractGeneratedSchema.RAW_TYPE_NAME,
type: getTextOfTsNode(context.typeSchema.getReferenceToRawType(this.type).typeNode)
type: getTextOfTsNode(context.typeSchema.getReferenceToRawType(this.type).typeNode),
isExported: true
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ export class GeneratedSdkErrorSchemaImpl
protected generateRawTypeDeclaration(context: SdkContext, module: ModuleDeclaration): void {
module.addTypeAlias({
name: AbstractGeneratedSchema.RAW_TYPE_NAME,
type: getTextOfTsNode(context.typeSchema.getReferenceToRawType(this.type).typeNode)
type: getTextOfTsNode(context.typeSchema.getReferenceToRawType(this.type).typeNode),
isExported: true
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ export class GeneratedSdkInlinedRequestBodySchemaImpl
}),
extends: this.inlinedRequestBody.extends.map((extension) =>
getTextOfTsNode(context.typeSchema.getReferenceToRawNamedType(extension).getTypeNode())
)
),
isExported: true
});
}

Expand Down
7 changes: 7 additions & 0 deletions packages/cli/cli/versions.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
- changelogEntry:
- summary: |
Fixed issue where user specified examples would be omitted in favor of autogenerated examples.
type: fix
irVersion: 53
version: 0.46.15

- changelogEntry:
- summary: |
Boolean default values are now propagated from the Fern Definition through to docs generation.
Expand Down
65 changes: 37 additions & 28 deletions packages/cli/register/src/ir-to-fdr-converter/convertPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,28 @@ function convertService(
for (const irEndpoint of irService.endpoints) {
const autogeneratedExample = irEndpoint.autogeneratedExamples[0];
const examples: FdrCjsSdk.api.v1.register.ExampleEndpointCall[] = [];
if (irEndpoint.userSpecifiedExamples.length > 0 && autogeneratedExample != null) {
if (irEndpoint.userSpecifiedExamples.length > 0) {
examples.push(
...irEndpoint.userSpecifiedExamples.map((userSpecifiedExample) =>
convertHttpEndpointExample({
autogeneratedExample,
userSpecifiedExample,
irEndpoint,
ir
})
)
...irEndpoint.userSpecifiedExamples
.map((userSpecifiedExample) =>
convertHttpEndpointExample({
userSpecifiedExample,
...(autogeneratedExample != null && { autogeneratedExample }),
irEndpoint,
ir
})
)
.filter(isNonNullish)
);
} else if (autogeneratedExample != null) {
examples.push(
convertHttpEndpointExample({
autogeneratedExample,
irEndpoint,
ir
})
);
const endpointExample = convertHttpEndpointExample({
autogeneratedExample,
irEndpoint,
ir
});
if (endpointExample != null) {
examples.push(endpointExample);
}
} else if (irEndpoint.response?.body?.type === "fileDownload") {
const example = generateEndpointExample({
ir,
Expand All @@ -99,15 +102,18 @@ function convertService(
generationResponse: { type: "success" }
});
if (example.type === "success") {
const convertedExample: FdrCjsSdk.api.v1.register.ExampleEndpointCall = {
...convertHttpEndpointExample({
autogeneratedExample: example,
irEndpoint,
ir
}),
responseBodyV3: { type: "filename", value: "<bytes>" }
};
examples.push(convertedExample);
const endpointExample = convertHttpEndpointExample({
autogeneratedExample: example,
irEndpoint,
ir
});
if (endpointExample != null) {
const convertedExample: FdrCjsSdk.api.v1.register.ExampleEndpointCall = {
...endpointExample,
responseBodyV3: { type: "filename", value: "<bytes>" }
};
examples.push(convertedExample);
}
}
}
const endpoint = {
Expand Down Expand Up @@ -653,10 +659,10 @@ function convertHttpEndpointExample({
ir
}: {
userSpecifiedExample?: UserSpecifiedEndpointExample;
autogeneratedExample: AutogeneratedEndpointExample;
autogeneratedExample?: AutogeneratedEndpointExample;
irEndpoint: Ir.http.HttpEndpoint;
ir: Ir.ir.IntermediateRepresentation;
}): FdrCjsSdk.api.v1.register.ExampleEndpointCall {
}): FdrCjsSdk.api.v1.register.ExampleEndpointCall | undefined {
const requiredGlobalHeaders: Ir.ExampleHeader[] = ir.headers
.map((header) => {
const value =
Expand All @@ -679,7 +685,10 @@ function convertHttpEndpointExample({
return undefined;
})
.filter(isNonNullish);
const example = userSpecifiedExample?.example ?? autogeneratedExample.example;
const example = userSpecifiedExample?.example ?? autogeneratedExample?.example;
if (example == null) {
return undefined;
}
const { codeSamples } = userSpecifiedExample ?? { codeSamples: [] };
return {
name: example.name?.originalName,
Expand Down

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: 1 addition & 1 deletion seed/ts-express/alias-extends/serialization/types/Child.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: 1 addition & 1 deletion seed/ts-express/alias/serialization/types/Object_.ts

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

2 changes: 1 addition & 1 deletion seed/ts-express/alias/serialization/types/Type.ts

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

2 changes: 1 addition & 1 deletion seed/ts-express/alias/serialization/types/TypeId.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.

Loading

0 comments on commit 83ab102

Please sign in to comment.