// AUTO-GENERATED BY DAGGER_GLEAM - DO NOT EDIT import dagger/types.{type Client, type Try} as types import dagger/interpreter import dagger/dsl/types as t import gleam/dynamic/decode import gleam/list pub fn stat(id id: t.Stat) -> t.Stat { let field = types.Field(name: "loadStatFromID", args: [#("id", types.GDeferred(id.op))], subfields: []) t.Stat(op: types.Pure([field])) } /// file type pub fn file_type(parent: t.Stat, client client: Client, then handler: fn(Try(t.FileType)) -> a) -> a { let field = types.Field(name: "fileType", args: [], subfields: []) let op = { use q <- types.bind(parent.op) let full_query = list.append(q, [field]) types.Fetch( fields: full_query, decoder: decode.dynamic, next: fn(dyn) { let path = types.make_path(full_query) case decode.run(dyn, decode.at(path, decode.map(decode.string, fn(s) { t.file_type_from_string(s) }))) { Ok(val) -> types.Pure(Ok(val)) Error(_) -> types.Pure(Error(types.DecodingError("fileType"))) } } ) } handler(interpreter.run(op, client)) } /// A unique identifier for this Stat. pub fn id(parent: t.Stat) -> t.Stat { let field = types.Field(name: "id", args: [], subfields: []) let new_op = { use q <- types.bind(parent.op) types.Pure(list.append(q, [field])) } t.Stat(op: new_op) } /// file name pub fn name(parent: t.Stat, client client: Client, then handler: fn(Try(String)) -> a) -> a { let field = types.Field(name: "name", args: [], subfields: []) let op = { use q <- types.bind(parent.op) let full_query = list.append(q, [field]) types.Fetch( fields: full_query, decoder: decode.dynamic, next: fn(dyn) { let path = types.make_path(full_query) case decode.run(dyn, decode.at(path, decode.string)) { Ok(val) -> types.Pure(Ok(val)) Error(_) -> types.Pure(Error(types.DecodingError("name"))) } } ) } handler(interpreter.run(op, client)) } /// permission bits pub fn permissions(parent: t.Stat, client client: Client, then handler: fn(Try(Int)) -> a) -> a { let field = types.Field(name: "permissions", args: [], subfields: []) let op = { use q <- types.bind(parent.op) let full_query = list.append(q, [field]) types.Fetch( fields: full_query, decoder: decode.dynamic, next: fn(dyn) { let path = types.make_path(full_query) case decode.run(dyn, decode.at(path, decode.int)) { Ok(val) -> types.Pure(Ok(val)) Error(_) -> types.Pure(Error(types.DecodingError("permissions"))) } } ) } handler(interpreter.run(op, client)) } /// file size pub fn size(parent: t.Stat, client client: Client, then handler: fn(Try(Int)) -> a) -> a { let field = types.Field(name: "size", args: [], subfields: []) let op = { use q <- types.bind(parent.op) let full_query = list.append(q, [field]) types.Fetch( fields: full_query, decoder: decode.dynamic, next: fn(dyn) { let path = types.make_path(full_query) case decode.run(dyn, decode.at(path, decode.int)) { Ok(val) -> types.Pure(Ok(val)) Error(_) -> types.Pure(Error(types.DecodingError("size"))) } } ) } handler(interpreter.run(op, client)) }