-
Notifications
You must be signed in to change notification settings - Fork 617
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api-headless-cms): add content entry traverser (#4072)
- Loading branch information
Showing
26 changed files
with
2,393 additions
and
1,214 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
packages/api-headless-cms/__tests__/contentTraverser/mocks/article.entry.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { richTextValue } from "./richTextValue"; | ||
|
||
export const articleEntry = { | ||
title: "Article #1", | ||
body: richTextValue, | ||
categories: [{ modelId: "category", entryId: "12345678" }], | ||
content: [ | ||
{ | ||
title: "Hero #1", | ||
_templateId: "cv2zf965v324ivdc7e1vt" | ||
}, | ||
{ | ||
_templateId: "9ht43gurhegkbdfsaafyads", | ||
settings: { | ||
title: "Title", | ||
seo: [ | ||
{ | ||
title: "title-0" | ||
}, | ||
{ | ||
title: "title-1" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
}; |
165 changes: 165 additions & 0 deletions
165
packages/api-headless-cms/__tests__/contentTraverser/mocks/article.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
import { createPrivateModel } from "~/plugins"; | ||
|
||
export const articleModel = createPrivateModel({ | ||
titleFieldId: "title", | ||
name: "Article", | ||
modelId: "article", | ||
fields: [ | ||
{ | ||
id: "title", | ||
multipleValues: false, | ||
label: "Title", | ||
type: "text", | ||
storageId: "text@title", | ||
fieldId: "title" | ||
}, | ||
{ | ||
id: "body", | ||
multipleValues: false, | ||
label: "Body", | ||
type: "rich-text", | ||
storageId: "rich-text@body", | ||
fieldId: "body" | ||
}, | ||
{ | ||
id: "categories", | ||
multipleValues: true, | ||
label: "Categories", | ||
type: "ref", | ||
storageId: "ref@categories", | ||
fieldId: "categories", | ||
settings: { | ||
models: [{ modelId: "category" }] | ||
} | ||
}, | ||
{ | ||
id: "content", | ||
fieldId: "content", | ||
storageId: "dynamicZone@content", | ||
type: "dynamicZone", | ||
label: "Content", | ||
multipleValues: true, | ||
settings: { | ||
templates: [ | ||
{ | ||
name: "Hero #1", | ||
gqlTypeName: "Hero", | ||
icon: "fas/flag", | ||
description: "The top piece of content on every page.", | ||
id: "cv2zf965v324ivdc7e1vt", | ||
fields: [ | ||
{ | ||
id: "title", | ||
fieldId: "title", | ||
label: "Title", | ||
type: "text" | ||
} | ||
] | ||
}, | ||
{ | ||
name: "Simple Text #1", | ||
gqlTypeName: "SimpleText", | ||
icon: "fas/file-text", | ||
description: "Simple paragraph of text.", | ||
id: "81qiz2v453wx9uque0gox", | ||
fields: [ | ||
{ | ||
id: "text", | ||
fieldId: "text", | ||
label: "Text", | ||
type: "long-text" | ||
} | ||
] | ||
}, | ||
{ | ||
name: "Settings", | ||
gqlTypeName: "Settings", | ||
icon: "fas/file-text", | ||
description: "Settings", | ||
id: "9ht43gurhegkbdfsaafyads", | ||
fields: [ | ||
{ | ||
id: "settings", | ||
fieldId: "settings", | ||
label: "Settings", | ||
type: "object", | ||
settings: { | ||
fields: [ | ||
{ | ||
id: "title", | ||
fieldId: "title", | ||
type: "text", | ||
label: "Title" | ||
}, | ||
{ | ||
id: "seo", | ||
fieldId: "seo", | ||
type: "object", | ||
label: "SEO", | ||
multipleValues: true, | ||
settings: { | ||
fields: [ | ||
{ | ||
id: "title", | ||
fieldId: "title", | ||
type: "text", | ||
label: "Title" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
type: "dynamicZone", | ||
settings: { | ||
templates: [ | ||
{ | ||
name: "Ad", | ||
gqlTypeName: "Ad", | ||
icon: "fab/buysellads", | ||
description: "Ad", | ||
id: "0emukbsvmzpozx2lzk883", | ||
fields: [ | ||
{ | ||
type: "ref", | ||
settings: { | ||
models: [ | ||
{ | ||
modelId: "author" | ||
} | ||
] | ||
}, | ||
multipleValues: true, | ||
label: "Authors", | ||
fieldId: "authors", | ||
id: "tuuehcqp" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
label: "DynamicZone", | ||
fieldId: "dynamicZone", | ||
id: "nli9u1rm" | ||
}, | ||
/** | ||
* Add a dynamic zone field without any templates, to test for correct schema generation. | ||
*/ | ||
{ | ||
type: "dynamicZone", | ||
settings: { | ||
templates: [] | ||
}, | ||
label: "DynamicZone", | ||
fieldId: "emptyDynamicZone", | ||
id: "lsd78slxc8" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
] | ||
}); |
Oops, something went wrong.