Skip to content

Commit

Permalink
improvement(fdr): add display name to generators table
Browse files Browse the repository at this point in the history
  • Loading branch information
armandobelardo committed Sep 12, 2024
1 parent 9f8255a commit a8a63a8
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions fern/apis/fdr/definition/generators/__package__.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ types:
Generator:
properties:
id: GeneratorId
displayName: string
generatorType: GeneratorType
generatorLanguage: optional<GeneratorLanguage>
dockerImage:
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.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
- adds displayName as nullable column to Generator
- sets displayName to id for all existing rows
- makes displayName not nullable
*/
-- AlterTable
ALTER TABLE "Generator" ADD COLUMN "displayName" TEXT;
UPDATE "Generator" SET "displayName" = "id";
ALTER TABLE "Generator" ALTER COLUMN "displayName" TEXT NOT NULL;
1 change: 1 addition & 0 deletions servers/fdr/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ enum SnippetTemplateSemanticVersion {

model Generator {
id String @id
displayName String
generatorType Bytes
dockerImage String @unique
generatorLanguage Language?
Expand Down
7 changes: 7 additions & 0 deletions servers/fdr/src/__test__/local/db/generatorDao.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ it("generator dao", async () => {
// create snippets
const generatorStarter: FdrAPI.generators.Generator = {
id: "my-cool/example",
displayName: "My Cool Example",
generatorType: { type: "sdk" },
dockerImage: "my-cool/example",
generatorLanguage: FdrAPI.generators.GeneratorLanguage.Python,
Expand All @@ -45,6 +46,7 @@ it("generator dao", async () => {
generator: {
id: "my-cool/example",
generatorType: { type: "sdk" },
displayName: "My Cool Example",
dockerImage: "changing things up",
generatorLanguage: FdrAPI.generators.GeneratorLanguage.Typescript,
},
Expand All @@ -64,6 +66,7 @@ it("generator dao non-unique", async () => {
await fdrApplication.dao.generators().upsertGenerator({
generator: {
id: "python-sdk",
displayName: "Python SDK",
generatorType: { type: "sdk" },
dockerImage: "my-cool/example",
generatorLanguage: FdrAPI.generators.GeneratorLanguage.Python,
Expand All @@ -73,6 +76,7 @@ it("generator dao non-unique", async () => {
await fdrApplication.dao.generators().upsertGenerator({
generator: {
id: "python-sdk-2",
displayName: "Python SDK",
generatorType: { type: "sdk" },
dockerImage: "my-cool/example-1",
generatorLanguage: FdrAPI.generators.GeneratorLanguage.Python,
Expand All @@ -82,6 +86,7 @@ it("generator dao non-unique", async () => {
await fdrApplication.dao.generators().upsertGenerator({
generator: {
id: "python-sdk-3",
displayName: "Python SDK",
generatorType: { type: "sdk" },
dockerImage: "my-cool/example-2",
generatorLanguage: FdrAPI.generators.GeneratorLanguage.Python,
Expand All @@ -95,6 +100,7 @@ it("generator dao non-unique", async () => {
it("generator dao image non-unique", async () => {
const generator: Generator = {
id: "python-sdk-3",
displayName: "Python SDK",
generatorType: { type: "sdk" },
dockerImage: "my-cool/example",
generatorLanguage: FdrAPI.generators.GeneratorLanguage.Python,
Expand All @@ -105,6 +111,7 @@ it("generator dao image non-unique", async () => {
await fdrApplication.dao.generators().upsertGenerator({
generator: {
id: "python-sdk-15",
displayName: "Python SDK",
generatorType: { type: "sdk" },
dockerImage: "my-cool/example",
generatorLanguage: FdrAPI.generators.GeneratorLanguage.Python,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ it("generator version dao not semver", async () => {
await fdrApplication.dao.generators().upsertGenerator({
generator: {
id: "this-fails-semver",
displayName: "An SDK",
generatorType: { type: "sdk" },
dockerImage: "this-fails-semver",
generatorLanguage: FdrAPI.generators.GeneratorLanguage.Python,
Expand All @@ -38,6 +39,7 @@ it("generator version get latest respects semver, not time", async () => {
await fdrApplication.dao.generators().upsertGenerator({
generator: {
id: "this-picks-latest",
displayName: "An SDK",
generatorType: { type: "sdk" },
dockerImage: "this-picks-latest",
generatorLanguage: FdrAPI.generators.GeneratorLanguage.Python,
Expand Down Expand Up @@ -94,6 +96,7 @@ it("generator changelog", async () => {
await fdrApplication.dao.generators().upsertGenerator({
generator: {
id: "this-gets-changelog",
displayName: "An SDK",
generatorType: { type: "sdk" },
dockerImage: "this-gets-changelog",
generatorLanguage: FdrAPI.generators.GeneratorLanguage.Python,
Expand Down Expand Up @@ -270,6 +273,7 @@ it("generator version happy path update", async () => {
await fdrApplication.dao.generators().upsertGenerator({
generator: {
id: "this-is-the-happy-path",
displayName: "An SDK",
generatorType: { type: "sdk" },
dockerImage: "this-is-the-happy-path",
generatorLanguage: FdrAPI.generators.GeneratorLanguage.Python,
Expand Down Expand Up @@ -331,6 +335,7 @@ it("get generator that works for cli version", async () => {
await fdrApplication.dao.generators().upsertGenerator({
generator: {
id: "this-is-cli-restricted",
displayName: "An SDK",
generatorType: { type: "sdk" },
dockerImage: "this-is-cli-restricted",
generatorLanguage: FdrAPI.generators.GeneratorLanguage.Python,
Expand Down Expand Up @@ -399,6 +404,7 @@ it("get generator retain major version", async () => {
await fdrApplication.dao.generators().upsertGenerator({
generator: {
id: "this-is-major-version-restricted",
displayName: "An SDK",
generatorType: { type: "sdk" },
dockerImage: "this-is-major-version-restricted",
generatorLanguage: FdrAPI.generators.GeneratorLanguage.Python,
Expand Down

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

2 changes: 2 additions & 0 deletions servers/fdr/src/db/generators/GeneratorDao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export class GeneratorsDaoImpl implements GeneratorsDao {
// We always just write over the previous entry here
const data = {
id: generator.id,
displayName: generator.displayName,
generatorType: writeBuffer(generator.generatorType),
generatorLanguage: convertGeneratorLanguage(generator.generatorLanguage),
dockerImage: generator.dockerImage,
Expand Down Expand Up @@ -155,6 +156,7 @@ function convertPrismaGenerator(generator: prisma.Generator | null): Generator |
return generator != null
? {
id: generator.id,
displayName: generator.displayName,
generatorType: readBuffer(generator.generatorType) as GeneratorType,
generatorLanguage: convertPrismaLanguage(generator.generatorLanguage),
dockerImage: generator.dockerImage,
Expand Down

0 comments on commit a8a63a8

Please sign in to comment.