-module(starflow@schema). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([string/0, string_with_format/1, number/0, integer/0, boolean/0, array/1, object/1, enum/1, required/2, optional/2]). -export_type([schema/0, property/0]). -type schema() :: {schema, gleam@json:json()}. -type property() :: {property, binary(), schema(), boolean()}. -file("/home/ethanthoma/projects/flow/src/starflow/schema.gleam", 10). -spec string() -> schema(). string() -> {schema, gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"string"/utf8>>)}] )}. -file("/home/ethanthoma/projects/flow/src/starflow/schema.gleam", 15). -spec string_with_format(binary()) -> schema(). string_with_format(Format) -> {schema, gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"string"/utf8>>)}, {<<"format"/utf8>>, gleam@json:string(Format)}] )}. -file("/home/ethanthoma/projects/flow/src/starflow/schema.gleam", 25). -spec number() -> schema(). number() -> {schema, gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"number"/utf8>>)}] )}. -file("/home/ethanthoma/projects/flow/src/starflow/schema.gleam", 30). -spec integer() -> schema(). integer() -> {schema, gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"integer"/utf8>>)}] )}. -file("/home/ethanthoma/projects/flow/src/starflow/schema.gleam", 35). -spec boolean() -> schema(). boolean() -> {schema, gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"boolean"/utf8>>)}] )}. -file("/home/ethanthoma/projects/flow/src/starflow/schema.gleam", 40). -spec array(schema()) -> schema(). array(Items) -> {schema, Items_json} = Items, {schema, gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"array"/utf8>>)}, {<<"items"/utf8>>, Items_json}] )}. -file("/home/ethanthoma/projects/flow/src/starflow/schema.gleam", 46). -spec object(list(property())) -> schema(). object(Properties) -> {Props_json, Required@1} = begin _pipe = Properties, gleam@list:fold( _pipe, {[], []}, fun(Acc, Prop) -> {Props, Reqs} = Acc, {property, Name, {schema, Schema}, Required} = Prop, case Required of true -> {[{Name, Schema} | Props], [gleam@json:string(Name) | Reqs]}; false -> {[{Name, Schema} | Props], Reqs} end end ) end, {schema, gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"object"/utf8>>)}, {<<"properties"/utf8>>, gleam@json:object(Props_json)}, {<<"required"/utf8>>, gleam@json:array(Required@1, fun(X) -> X end)}] )}. -file("/home/ethanthoma/projects/flow/src/starflow/schema.gleam", 68). -spec enum(list(binary())) -> schema(). enum(Values) -> {schema, gleam@json:object( [{<<"enum"/utf8>>, gleam@json:array(Values, fun gleam@json:string/1)}] )}. -file("/home/ethanthoma/projects/flow/src/starflow/schema.gleam", 78). -spec required(binary(), schema()) -> property(). required(Name, Schema) -> {property, Name, Schema, true}. -file("/home/ethanthoma/projects/flow/src/starflow/schema.gleam", 83). -spec optional(binary(), schema()) -> property(). optional(Name, Schema) -> {property, Name, Schema, false}.