class UserSchema(typesystem.Schema): name = typesystem.String(title="Name") email = typesystem.String(title="E-mail") email_verified = typesystem.Boolean(title="E-mail verified?", default=False) given_name = typesystem.String(title="Given name", allow_null=True) middle_name = typesystem.String(title="Middle name", allow_null=True) family_name = typesystem.String(title="Family name", allow_null=True) nickname = typesystem.String(title="Nick name", allow_null=True) preferred_username = typesystem.String(title="Preferred user name", allow_null=True) profile = typesystem.String(title="Profile", allow_null=True) website = typesystem.String(title="Website", allow_null=True) gender = typesystem.String(title="Gender", allow_null=True) birthdate = typesystem.Date(title="Birthdate", allow_null=True) zoneinfo = typesystem.String(title="Zone info", allow_null=True) locale = typesystem.String(title="Locale", allow_null=True) phone_number = typesystem.String(title="Phone number", format="tel", allow_null=True) phone_number_verified = typesystem.Boolean(title="Phone number verified?", allow_null=True) address = typesystem.String(title="Address", allow_null=True) cognito_mfa_enabled = typesystem.Boolean(title="MFA enabled?", default=True)
class TriggerSchema(typesystem.Schema): """ Schema to define the structure of a Trigger """ description = typesystem.String(title="Description", max_length=200) rss_url = typesystem.String(title="RSS URL", max_length=255) joplin_folder = typesystem.String(title="Joplin Folder", max_length=80, allow_null=True) reddit = typesystem.String(title="Subreddit", max_length=80, allow_null=True) mail = typesystem.Boolean(title="Send a mail ?", default=False) mastodon = typesystem.Boolean(title="Publish on Mastodon ?", default=False) localstorage = typesystem.String(title="Markdown Folder") status = typesystem.Boolean(title="Status", default=False)
class Cuisine(typesystem.Schema): active = typesystem.Boolean(default=True) aliases = typesystem.Array(allow_null=True, default=list, items=typesystem.String(allow_blank=True)) description = typesystem.String(allow_blank=True) name = typesystem.String() redirect_from = typesystem.Array(allow_null=True, default=list, items=typesystem.String(allow_blank=True)) sitemap = typesystem.Boolean(default=True) slug = typesystem.String() title = typesystem.String(allow_blank=True)
class UserPoolSchema(typesystem.Schema): name = typesystem.String(title="Name") alias_attributes = typesystem.Array( Choice(title="Alias attributes", choices=UserIdentityAttribute), unique_items=True, default=[], ) auto_verified_attributes = typesystem.Array( Choice(title="Auto-verified attributes", choices=AuxiliaryIdentityAttribute), unique_items=True, default=[], ) username_attributes = typesystem.Array( Choice( title= "Username attributes (if none selected, username will be used)", choices=AuxiliaryIdentityAttribute, ), unique_items=True, default=[], ) username_case_sensitiveness = typesystem.Boolean( title=("User names are case sensitive" "(e-mail addresses are treated insensitively by default)"))
class RecaptchaResponse(typesystem.Schema): success = typesystem.Boolean(default=False) challenge_ts = typesystem.String(allow_null=True) hostname = typesystem.String(allow_null=True) score = typesystem.Float(allow_null=True) action = typesystem.String(allow_blank=True) error_codes = typesystem.Array( title="error-codes", items=typesystem.String(), allow_null=True )
class Booking(typesystem.Schema): start_date = typesystem.Date() end_date = typesystem.Date() room = typesystem.Choice(choices=[ ("double", "Double room"), ("twin", "Twin room"), ("single", "Single room"), ]) include_breakfast = typesystem.Boolean(title="Include breakfast", default=False)
class Settings(BaseSchema): enforce_https = typesystem.Boolean(default=False) mode = typesystem.Choice( choices=( ("proxy", "Proxy"), ("redirect", "Redirect"), ), default="proxy", ) certificate_path = typesystem.String(allow_null=True) key_path = typesystem.String(allow_null=True)
class Settings(BaseSchema): enforce_https = typesystem.Boolean(default=False) mode = typesystem.Choice( choices=( ("proxy", "Proxy"), ("redirect", "Redirect"), ), default="proxy", ) headers = typesystem.Object(default={}, properties=typesystem.String(max_length=100)) ttl = typesystem.Integer(allow_null=True) certificate_path = typesystem.String(allow_null=True) key_path = typesystem.String(allow_null=True)
class Place(typesystem.Schema): active = typesystem.Boolean() address = typesystem.String(allow_null=True) cuisine = typesystem.String(allow_null=True) cuisine_slugs = typesystem.Array(allow_null=True, items=typesystem.String(allow_null=True)) cuisines = typesystem.Array(allow_null=True, items=typesystem.String(allow_null=True)) curbside = typesystem.Boolean(default=False) curbside_instructions = typesystem.String(allow_null=True) delivery = typesystem.Boolean(default=False) delivery_service_websites = typesystem.String(allow_null=True) dinein = typesystem.Boolean(default=False) facebook_url = typesystem.String(allow_null=True) featured = typesystem.Boolean(default=False) food_urls = typesystem.Array(allow_null=True, items=typesystem.Reference(allow_null=True, to=Url)) giftcard = typesystem.Boolean(default=False) giftcard_notes = typesystem.String(allow_null=True) giftcard_url = typesystem.String(allow_null=True) hours = typesystem.String(allow_null=True) instagram_url = typesystem.String(allow_null=True) locality = typesystem.String( allow_null=True) # set default to a variable like "Lawrence" name = typesystem.String() neighborhood = typesystem.String(allow_null=True) neighborhood_slug = typesystem.String(allow_null=True) notes = typesystem.String(allow_blank=True) perma_closed = typesystem.Boolean(allow_null=True) place_type = typesystem.String(allow_null=True) region = typesystem.String(allow_null=True) restaurant_phone = typesystem.String(allow_null=True) sitemap = typesystem.Boolean() slug = typesystem.String() takeout = typesystem.Boolean(default=False) twitch_url = typesystem.String(allow_null=True) twitter_url = typesystem.String(allow_null=True) website = typesystem.String(allow_null=True)
class BookingSchema(typesystem.Schema): start_date = typesystem.Date(title="Start date") end_date = typesystem.Date(title="End date") room = typesystem.Choice( title="Room type", choices=[ ("double", "Double room"), ("twin", "Twin room"), ("single", "Single room"), ], ) include_breakfast = typesystem.Boolean(title="Include breakfast", default=False) def __str__(self): breakfast = ("(with breakfast)" if self.include_breakfast else "(without breakfast)") return f"Booking for {self.room} from {self.start_date} to {self.end_date}"
def app(): users = dashboard.MockDataSource( schema=typesystem.Schema( fields={ "pk": typesystem.Integer(title="Identity", read_only=True, default=dashboard.autoincrement()), "username": typesystem.String(title="Username", max_length=100), "is_admin": typesystem.Boolean(title="Is Admin", default=False), "joined": typesystem.DateTime(title="Joined", read_only=True, default=datetime.datetime.now), }), initial=[{ "username": f"user{i}@example.org", "is_admin": False, } for i in range(123)], ) user_table = dashboard.DashboardTable(ident="users", title="Users", datasource=users) admin = dashboard.Dashboard(tables=[user_table]) return Starlette(routes=[ Mount( "/admin", admin, name="dashboard", ), Mount("/statics", ..., name="static"), ])
class Todo(typesystem.Schema): title = typesystem.String(max_length=20) done = typesystem.Boolean(default=False)
class Poll(typesystem.Schema): title = typesystem.String(max_length=100) options = typesystem.Array(items=typesystem.String(), unique_items=True) multi = typesystem.Boolean(default=False) suspended = typesystem.Boolean(default=False) creator = typesystem.String(allow_null=True)
"multipleOf": typesystem.Number(exclusive_minimum=0), # Object "properties": typesystem.Object(additional_properties=typesystem.Reference( "JSONSchema", definitions=definitions)), "minProperties": typesystem.Integer(minimum=0), "maxProperties": typesystem.Integer(minimum=0), "patternProperties": typesystem.Object(additional_properties=typesystem.Reference( "JSONSchema", definitions=definitions)), "additionalProperties": ( typesystem.Reference("JSONSchema", definitions=definitions) | typesystem.Boolean()), "required": typesystem.Array(items=typesystem.String(), unique_items=True), # Array "items": ( typesystem.Reference("JSONSchema", definitions=definitions) | typesystem.Array( items=typesystem.Reference("JSONSchema", definitions=definitions), min_items=1, )), "additionalItems": ( typesystem.Reference("JSONSchema", definitions=definitions) | typesystem.Boolean()), "minItems": typesystem.Integer(minimum=0),
class Schema(typesystem.Schema): active = typesystem.Boolean(default=True) name = typesystem.String() sitemap = typesystem.Boolean(default=False) slug = typesystem.String() title = typesystem.String()
"summary": typesystem.String(allow_blank=True), "description": typesystem.Text(allow_blank=True), "externalDocs": typesystem.Reference( "ExternalDocumentation", definitions=definitions ), "operationId": typesystem.String(), "parameters": typesystem.Array( items=typesystem.Reference("Parameter", definitions=definitions) ), # TODO: | ReferenceObject "requestBody": REQUESTBODY_REF | typesystem.Reference( "RequestBody", definitions=definitions ), # TODO: RequestBody | ReferenceObject "responses": typesystem.Reference("Responses", definitions=definitions), # TODO: 'callbacks' "deprecated": typesystem.Boolean(), "security": typesystem.Array( typesystem.Reference("SecurityRequirement", definitions=definitions) ), "servers": typesystem.Array( items=typesystem.Reference("Server", definitions=definitions) ), }, pattern_properties={"^x-": typesystem.Any()}, additional_properties=False, ) definitions["ExternalDocumentation"] = typesystem.Object( properties={ "description": typesystem.Text(allow_blank=True), "url": typesystem.String(format="url"),
class NoteSchema(typesystem.Schema): text = typesystem.String() completed = typesystem.Boolean()
class Rule(ts.Schema): id = ts.Integer() pattern = ts.String() is_regex = ts.Boolean()
class Neighborhood(typesystem.Schema): active = typesystem.Boolean(default=True) name = typesystem.String() sitemap = typesystem.Boolean(default=True) slug = typesystem.String() title = typesystem.String()
class RuleCreate(ts.Schema): pattern = ts.String() is_regex = ts.Boolean(default=False)
class Contact(typesystem.Schema): a = typesystem.Boolean() b = typesystem.String(max_length=10) c = typesystem.Text() d = typesystem.Choice(choices=[("abc", "Abc"), ("def", "Def"), ("ghi", "Ghi")])
class User(BaseUser, typesystem.Schema): username = typesystem.String(max_length=100) is_admin = typesystem.Boolean(default=False)
class Contact(typesystem.Schema): a = typesystem.Boolean() b = typesystem.String(max_length=10) c = typesystem.Text() d = typesystem.Choice(choices=["abc", "def", "ghi"])
def get_validator(self, **kwargs) -> typesystem.Field: return typesystem.Boolean(**kwargs)
def isinstance(self, datum): if not isinstance(datum, numpy.generic): # if not Numpy, check as pure Python return typesystem.Boolean().isinstance(datum) return isinstance(datum, numpy.bool_)