Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/renderers/contentful/renderContentType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,7 @@ function renderContentTypeFields(fields: Field[], localization: boolean): string

function renderSys(sys: Sys) {
return `
sys: {
id: string;
type: string;
createdAt: string;
updatedAt: string;
locale: string;
sys: Sys & {
contentType: {
sys: {
id: '${sys.id}';
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/contentful/renderContentfulImports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function renderContentfulImports(
return `
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY IT.

import { ${localization ? "" : "Asset, "}Entry } from 'contentful'
import { ${localization ? "" : "Asset, "}Entry, Sys } from 'contentful'
${hasRichText ? "import { Document } from '@contentful/rich-text-types'" : ""}
`
}
21 changes: 3 additions & 18 deletions test/renderers/contentful/renderContentType.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,7 @@ describe("renderContentType()", () => {
}

export interface IMyContentType extends Entry<IMyContentTypeFields> {
sys: {
id: string,
type: string,
createdAt: string,
updatedAt: string,
locale: string,
sys: Sys & {
contentType: {
sys: {
id: \\"myContentType\\",
Expand All @@ -90,12 +85,7 @@ describe("renderContentType()", () => {
/** This is a description */

export interface IMyContentType extends Entry<IMyContentTypeFields> {
sys: {
id: string,
type: string,
createdAt: string,
updatedAt: string,
locale: string,
sys: Sys & {
contentType: {
sys: {
id: \\"myContentType\\",
Expand All @@ -119,12 +109,7 @@ describe("renderContentType()", () => {
}

export interface IMyContentType extends Entry<IMyContentTypeFields> {
sys: {
id: string,
type: string,
createdAt: string,
updatedAt: string,
locale: string,
sys: Sys & {
contentType: {
sys: {
id: \\"myContentType\\",
Expand Down
6 changes: 3 additions & 3 deletions test/renderers/contentful/renderContentfulImports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe("renderContentfulImports()", () => {
expect(format(renderContentfulImports())).toMatchInlineSnapshot(`
"// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY IT.

import { Asset, Entry } from \\"contentful\\";
import { Asset, Entry, Sys } from \\"contentful\\";
import { Document } from \\"@contentful/rich-text-types\\";"
`)
})
Expand All @@ -15,7 +15,7 @@ describe("renderContentfulImports()", () => {
expect(format(renderContentfulImports(true))).toMatchInlineSnapshot(`
"// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY IT.

import { Entry } from \\"contentful\\";
import { Entry, Sys } from \\"contentful\\";
import { Document } from \\"@contentful/rich-text-types\\";"
`)
})
Expand All @@ -24,7 +24,7 @@ describe("renderContentfulImports()", () => {
expect(format(renderContentfulImports(true, false))).toMatchInlineSnapshot(`
"// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY IT.

import { Entry } from \\"contentful\\";"
import { Entry, Sys } from \\"contentful\\";"
`)
})
})
36 changes: 8 additions & 28 deletions test/renderers/render.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,15 @@ describe("render()", () => {
expect(await render(contentTypes, locales)).toMatchInlineSnapshot(`
"// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY IT.

import { Asset, Entry } from \\"contentful\\"
import { Asset, Entry, Sys } from \\"contentful\\"

export interface IMyContentTypeFields {
/** Array field */
arrayField: (\\"one's\\" | \\"of\\" | \\"the\\" | \\"above\\")[]
}

export interface IMyContentType extends Entry<IMyContentTypeFields> {
sys: {
id: string
type: string
createdAt: string
updatedAt: string
locale: string
sys: Sys & {
contentType: {
sys: {
id: \\"myContentType\\"
Expand Down Expand Up @@ -121,7 +116,7 @@ describe("render()", () => {
expect(await render(contentTypes, locales)).toMatchInlineSnapshot(`
"// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY IT.

import { Asset, Entry } from \\"contentful\\"
import { Asset, Entry, Sys } from \\"contentful\\"
import { Document } from \\"@contentful/rich-text-types\\"

export interface IMyContentTypeFields {
Expand All @@ -130,12 +125,7 @@ describe("render()", () => {
}

export interface IMyContentType extends Entry<IMyContentTypeFields> {
sys: {
id: string
type: string
createdAt: string
updatedAt: string
locale: string
sys: Sys & {
contentType: {
sys: {
id: \\"myContentType\\"
Expand Down Expand Up @@ -193,20 +183,15 @@ describe("render()", () => {
expect(await render(contentTypes, locales, { localization: true })).toMatchInlineSnapshot(`
"// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY IT.

import { Entry } from \\"contentful\\"
import { Entry, Sys } from \\"contentful\\"

export interface IMyContentTypeFields {
/** Array field */
arrayField: LocalizedField<(\\"one's\\" | \\"of\\" | \\"the\\" | \\"above\\")[]>
}

export interface IMyContentType extends Entry<IMyContentTypeFields> {
sys: {
id: string
type: string
createdAt: string
updatedAt: string
locale: string
sys: Sys & {
contentType: {
sys: {
id: \\"myContentType\\"
Expand Down Expand Up @@ -256,7 +241,7 @@ describe("render()", () => {
expect(await render(contentTypes, locales, { namespace: "Codegen" })).toMatchInlineSnapshot(`
"// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY IT.

import { Asset, Entry } from \\"contentful\\"
import { Asset, Entry, Sys } from \\"contentful\\"

declare namespace Codegen {
export interface IMyContentTypeFields {
Expand All @@ -265,12 +250,7 @@ describe("render()", () => {
}

export interface IMyContentType extends Entry<IMyContentTypeFields> {
sys: {
id: string
type: string
createdAt: string
updatedAt: string
locale: string
sys: Sys & {
contentType: {
sys: {
id: \\"myContentType\\"
Expand Down