{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "title": "Twitter",
    "description": "Twitter is a sample application contract.",
    "generators": [
        {
            "sql-definition": {
                "roleName": "twitter_db_role",
                "grants": [
                    "SELECT",
                    "INSERT",
                    "DELETE"
                ],
                "databaseName": "twitter_db",
                "schemaName": "account"
            }
        }
    ],
    "definitions": {
        "Config": {
            "type": "object",
            "title": "Config",
            "description": "Config represents the required options for this module to work",
            "definitions": {},
            "properties": {
                "Postgres": {
                    "type": "object",
                    "title": "Postgres",
                    "description": "Postgres holds the all credentials for postgres db connection.",
                    "properties": {
                        "Port": {
                            "description": "The port number for postgres config",
                            "type": "number",
                            "format": "int64",
                            "minimum": 1024
                        },
                        "Host": {
                            "description": "Host holds the hostname for the postgres",
                            "type": "string",
                            "minLength": 4,
                            "maxLength": 24
                        },
                        "Username": {
                            "description": "Username holds the username for the postgres",
                            "type": "string",
                            "minLength": 4,
                            "maxLength": 24
                        },
                        "Password": {
                            "description": "Password holds the password for the postgres",
                            "type": "string",
                            "minLength": 4,
                            "maxLength": 24
                        },
                        "DBName": {
                            "description": "DBName holds the database name for the postgres",
                            "type": "string",
                            "minLength": 4,
                            "maxLength": 24
                        }
                    },
                    "definitions": {}
                }
            }
        },
        "Profile": {
            "type": "object",
            "title": "Profile",
            "description": "Profile represents a registered Account's Public Info",
            "generators": [
                {
                    "sql-definition": {
                        "grants": [
                            "SELECT",
                            "INSERT",
                            "DELETE"
                        ],
                        "primaryKey": [
                            "Id"
                        ]
                    }
                }
            ],
            "properties": {
                "Id": {
                    "description": "The unique identifier for a Account's Profile",
                    "type": "number",
                    "format": "int64",
                    "minimum": 1,
                    "propertyOrder": 10
                },
                "ScreenName": {
                    "description": "Full name associated with the profile. Maximum of 20 characters.",
                    "type": "string",
                    "minLength": 4,
                    "maxLength": 20,
                    "propertyOrder": 20
                },
                "URL": {
                    "description": "URL associated with the profile. Will be prepended with “http://” if not present. Maximum of 100 characters.",
                    "type": "string",
                    "minLength": 0,
                    "maxLength": 100,
                    "propertyOrder": 30
                },
                "Location": {
                    "description": "The city or country describing where the user of the account is located. The contents are not normalized or geocoded in any way. Maximum of 30 characters.",
                    "type": "string",
                    "minLength": 0,
                    "maxLength": 30,
                    "propertyOrder": 40
                },
                "Description": {
                    "description": "A description of the user owning the account. Maximum of 160 characters.",
                    "type": "string",
                    "minLength": 0,
                    "maxLength": 160,
                    "propertyOrder": 50
                },
                "LinkColor": {
                    "description": "Sets a hex value that controls the color scheme of links used on the authenticating user’s profile page on twitter.com. This must be a valid hexadecimal value, and may be either three or six characters (ex: F00 or FF0000).",
                    "type": "string",
                    "minLength": 0,
                    "maxLength": 6,
                    "default": "FF0000",
                    "propertyOrder": 60
                },
                "AvatarURL": {
                    "description": "URL of the Account's Avatar",
                    "type": "string",
                    "minLength": 0,
                    "maxLength": 2000,
                    "propertyOrder": 70
                },
                "CreatedAt": {
                    "description": "Profile's creation time",
                    "type": "string",
                    "format": "date-time",
                    "default": "now()",
                    "propertyOrder": 80
                }
            },
            "required": [
                "ScreenName"
            ],
            "functions": {
                "One": {
                    "type": "object",
                    "title": "One",
                    "properties": {
                        "incoming": {
                            "$ref": "#/definitions/Account"
                        },
                        "outgoing": {
                            "$ref": "#/definitions/Account"
                        }
                    }
                },
                "Create": {
                    "type": "object",
                    "title": "One",
                    "properties": {
                        "incoming": {
                            "$ref": "#/definitions/Account"
                        },
                        "outgoing": {
                            "$ref": "#/definitions/Account"
                        }
                    }
                },
                "Update": {
                    "type": "object",
                    "title": "One",
                    "properties": {
                        "incoming": {
                            "$ref": "#/definitions/Account"
                        },
                        "outgoing": {
                            "$ref": "#/definitions/Account"
                        }
                    }
                },
                "Delete": {
                    "type": "object",
                    "title": "One",
                    "properties": {
                        "incoming": {
                            "$ref": "#/definitions/Account"
                        },
                        "outgoing": {
                            "$ref": "#/definitions/Account"
                        }
                    }
                }
            }
        },
        "Account": {
            "type": "object",
            "title": "Account",
            "description": "Account represents a registered User",
            "generators": [
                {
                    "sql-definition": {
                        "grants": [
                            "SELECT",
                            "INSERT",
                            "DELETE"
                        ],
                        "primaryKey": [
                            "Id"
                        ],
                        "uniqueKeys": [
                            [
                                "Id"
                            ],
                            [
                                "URL"
                            ]
                        ],
                        "foreignKeys": [
                            [
                                "ProfileId",
                                "Account.Profile.Id"
                            ]
                        ]
                    }
                }
            ],
            "properties": {
                "Id": {
                    "description": "The unique identifier for a Account",
                    "type": "number",
                    "format": "int64",
                    "minimum": 1,
                    "propertyOrder": 10
                },
                "ProfileId": {
                    "description": "The unique identifier for a Account's Profile",
                    "type": "number",
                    "format": "int64",
                    "minimum": 1,
                    "propertyOrder": 20
                },
                "Password": {
                    "description": "Salted Password of the Account",
                    "type": "string",
                    "minLength": 6,
                    "propertyOrder": 30
                },
                "URL": {
                    "description": "Unique URL of the Account",
                    "type": "string",
                    "minLength": 6,
                    "propertyOrder": 40
                },
                "PasswordStatusConstant": {
                    "description": "Status of the Account's Password",
                    "type": "string",
                    "enum": [
                        "valid",
                        "needsReset",
                        "generated"
                    ],
                    "default": "valid",
                    "propertyOrder": 50
                },
                "Salt": {
                    "description": "Salt used to hash Password of the Account",
                    "type": "string",
                    "minLength": 0,
                    "maxLength": 255,
                    "propertyOrder": 60
                },
                "EmailAddress": {
                    "description": "Email Address of the Account",
                    "type": "string",
                    "format": "email",
                    "propertyOrder": 70
                },
                "EmailStatusConstant": {
                    "description": "Status of the Account's Email",
                    "type": "string",
                    "enum": [
                        "verified",
                        "notVerified"
                    ],
                    "default": "notVerified",
                    "propertyOrder": 80
                },
                "StatusConstant": {
                    "description": "Status of the Account",
                    "type": "string",
                    "enum": [
                        "registered",
                        "unregistered",
                        "needsManualVerification"
                    ],
                    "default": "registered",
                    "propertyOrder": 90
                },
                "CreatedAt": {
                    "description": "Profile's creation time",
                    "type": "string",
                    "format": "date-time",
                    "default": "now()",
                    "propertyOrder": 100
                }
            },
            "required": [
                "Password",
                "EmailAddress"
            ],
            "functions": {
                "One": {
                    "type": "object",
                    "title": "One",
                    "properties": {
                        "incoming": {
                            "$ref": "#/definitions/Account"
                        },
                        "outgoing": {
                            "$ref": "#/definitions/Account"
                        }
                    }
                },
                "Create": {
                    "type": "object",
                    "title": "One",
                    "properties": {
                        "incoming": {
                            "$ref": "#/definitions/Account"
                        },
                        "outgoing": {
                            "$ref": "#/definitions/Account"
                        }
                    }
                },
                "Update": {
                    "type": "object",
                    "title": "One",
                    "properties": {
                        "incoming": {
                            "$ref": "#/definitions/Account"
                        },
                        "outgoing": {
                            "$ref": "#/definitions/Account"
                        }
                    }
                },
                "Delete": {
                    "type": "object",
                    "title": "One",
                    "properties": {
                        "incoming": {
                            "$ref": "#/definitions/Account"
                        },
                        "outgoing": {
                            "$ref": "#/definitions/Account"
                        }
                    }
                }
            }
        },
        "Tweet": {
            "type": "object",
            "title": "Tweet",
            "description": "Tweet represents a post a user created",
            "generators": [
                {
                    "sql-definition": {
                        "roleName": "twitter_db_role",
                        "grants": [
                            "SELECT",
                            "INSERT",
                            "DELETE"
                        ],
                        "primaryKey": [
                            "Id"
                        ],
                        "uniqueKeys": [
                            [
                                "Id"
                            ],
                            [
                                "ProfileId",
                                "Body"
                            ]
                        ],
                        "databaseName": "twitter_db",
                        "schemaName": "tweet"
                    }
                }
            ],
            "properties": {
                "Id": {
                    "description": "The unique identifier for a Tweet",
                    "type": "number",
                    "format": "int64",
                    "propertyOrder": 10
                },
                "ProfileId": {
                    "description": "The unique identifier for a Account's Profile",
                    "type": "number",
                    "format": "int64",
                    "minimum": 1,
                    "propertyOrder": 20
                },
                "Body": {
                    "description": "Text of the Tweet",
                    "type": "string",
                    "minLength": 1,
                    "propertyOrder": 30
                },
                "Location": {
                    "description": "Location of the Tweet's origin",
                    "type": "string",
                    "propertyOrder": 40
                },
                "RetweetCount": {
                    "description": "Aggregated Count for re-tweets of a tweet",
                    "type": "number",
                    "format": "int32",
                    "propertyOrder": 50
                },
                "FavouritesCount": {
                    "description": "Aggregated Count for favourites of a tweet",
                    "type": "number",
                    "format": "int32",
                    "propertyOrder": 60
                },
                "PossiblySensitive": {
                    "description": "Mark tweet if it is possibly sensitive",
                    "type": "boolean",
                    "default": false,
                    "propertyOrder": 70
                },
                "CreatedAt": {
                    "description": "Tweet's creation time",
                    "type": "string",
                    "format": "date-time",
                    "default": "now()",
                    "propertyOrder": 80
                }
            },
            "required": [
                "Body",
                "ProfileId"
            ],
            "functions": {
                "One": {
                    "type": "object",
                    "title": "One",
                    "properties": {
                        "incoming": {
                            "$ref": "#/definitions/Account"
                        },
                        "outgoing": {
                            "$ref": "#/definitions/Account"
                        }
                    }
                },
                "Create": {
                    "type": "object",
                    "title": "One",
                    "properties": {
                        "incoming": {
                            "$ref": "#/definitions/Account"
                        },
                        "outgoing": {
                            "$ref": "#/definitions/Account"
                        }
                    }
                },
                "Delete": {
                    "type": "object",
                    "title": "One",
                    "properties": {
                        "incoming": {
                            "$ref": "#/definitions/Account"
                        },
                        "outgoing": {
                            "$ref": "#/definitions/Account"
                        }
                    }
                }
            }
        }
    },
    "properties": {
        "Config": {
            "$ref": "#/definitions/Config"
        },
        "Profile": {
            "$ref": "#/definitions/Profile"
        },
        "Account": {
            "$ref": "#/definitions/Account"
        },
        "Tweet": {
            "$ref": "#/definitions/Tweet"
        }
    },
    "required": [
        "Config",
        "Profile",
        "Account",
        "Tweet"
    ]
}