Last active
March 30, 2022 13:55
-
-
Save korsvanloon/b8e2fea9531a52bcdb7d3bf8a1f0ae87 to your computer and use it in GitHub Desktop.
Amplience Codegen snippets
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
terraform { | |
required_providers { | |
amplience = { | |
source = "labd/amplience" | |
version = “0.3.6” | |
} | |
} | |
} | |
data "amplience_content_repository" "website" { | |
id = var.variables["CONTENT_REPO_ID"] | |
} | |
resource "amplience_content_type_schema" "game" { | |
body = file("${path.module}/schemas/game.json") | |
schema_id = "https://schema-examples.com/game" | |
validation_level = "CONTENT_TYPE" | |
} | |
resource "amplience_content_type" "game" { | |
content_type_uri = amplience_content_type_schema.game.schema_id | |
label = "Game" | |
status = "ACTIVE" | |
} | |
resource "amplience_content_type_assignment" "game" { | |
content_type_id = amplience_content_type.game.id | |
repository_id = data.amplience_content_repository.website.id | |
} |
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
{ | |
"$id": "https://schema-examples.com/game", | |
"$schema": "http://json-schema.org/draft-07/schema#", | |
"allOf": [ | |
{ "$ref": "http://bigcontent.io/cms/schema/v1/core#/definitions/content" } | |
], | |
"title": "Game", | |
"description": "Game", | |
"type": "object", | |
"properties": { | |
"name": { | |
"title": "Name", | |
"type": "string" | |
}, | |
"price": { | |
"title": "Price", | |
"type": "integer" | |
}, | |
}, | |
"propertyOrder": ["name", "price"], | |
"required": ["name"] | |
} |
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
union Product = Book | Game | |
type Author { | |
name: String! | |
} | |
type Chapter { | |
startPage: Int! | |
} | |
type Book { | |
id: ID! | |
author: Author! | |
title: String! | |
subTitle: String | |
pages: Float! | |
chapters: [Chapter!]! | |
} | |
type Product { | |
title: String! | |
price: Int | |
} |
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
union Product = Book | Game | |
type Author @amplience { | |
name: String! | |
} | |
type Chapter { | |
startPage: Int! | |
text: String! @text(minLength: 100, maxLength: 1000, format: markdown) | |
} | |
type Book @amplience { | |
id: ID! | |
author: Author! | |
title: String! | |
subTitle: String | |
pages: Float! | |
chapters: [Chapter!]! | |
} | |
type Product @amplience(visualizations: true) { | |
title: String! | |
price: Int | |
} |
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
export interface Author { | |
name: string | |
} | |
export interface Chapter { | |
startPage: number | |
} | |
export interface Book { | |
id: string | |
author: Author | |
title: string | |
subTitle?: string | |
/** @float */ | |
pages: number | |
chapters: Chapter[] | |
} | |
export interface Game { | |
title: string | |
price?: number | |
} | |
export type Product = Book | Game |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment