// 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 function_call() -> t.FunctionCall { let field = types.Field(name: "currentFunctionCall", args: [], subfields: []) t.FunctionCall(op: types.Pure([field])) } /// A unique identifier for this FunctionCall. pub fn function_call_id(parent: t.FunctionCall) -> t.FunctionCall { let field = types.Field(name: "id", args: [], subfields: []) let new_op = { use q <- types.bind(parent.op) types.Pure(list.append(q, [field])) } t.FunctionCall(op: new_op) } /// The argument values the function is being invoked with. pub fn input_args(parent: t.FunctionCall, select select: fn(t.FunctionCallArgValue) -> List(types.Field), client client: Client, then handler: fn(Try(List(t.FunctionCallArgValue))) -> a) -> a { let subfields = select(t.FunctionCallArgValue(op: types.Pure([]))) let field = types.Field(name: "inputArgs", args: [], subfields: 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.list(decode.dynamic))) { Ok(items) -> types.Pure(Ok(list.map(items, fn(_) { t.FunctionCallArgValue(op: types.Pure(full_query)) }))) Error(_) -> types.Pure(Error(types.DecodingError("inputArgs"))) } } ) } handler(interpreter.run(op, client)) } /// The name of the function being called. pub fn function_call_name(parent: t.FunctionCall, 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)) } /// The value of the parent object of the function being called. If the function is top-level to the module, this is always an empty object. pub fn parent(parent: t.FunctionCall, client client: Client, then handler: fn(Try(String)) -> a) -> a { let field = types.Field(name: "parent", 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("parent"))) } } ) } handler(interpreter.run(op, client)) } /// The name of the parent object of the function being called. If the function is top-level to the module, this is the name of the module. pub fn parent_name(parent: t.FunctionCall, client client: Client, then handler: fn(Try(String)) -> a) -> a { let field = types.Field(name: "parentName", 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("parentName"))) } } ) } handler(interpreter.run(op, client)) } /// Return an error from the function. pub fn return_error(parent: t.FunctionCall, error error: t.Error, client client: Client, then handler: fn(Try(Nil)) -> a) -> a { let field = types.Field(name: "returnError", args: [#("error", types.GDeferred(error.op))], 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.dynamic)) { Ok(_) -> types.Pure(Ok(Nil)) Error(_) -> types.Pure(Error(types.DecodingError("returnError"))) } } ) } handler(interpreter.run(op, client)) } /// Set the return value of the function call to the provided value. pub fn return_value(parent: t.FunctionCall, value value: String, client client: Client, then handler: fn(Try(Nil)) -> a) -> a { let field = types.Field(name: "returnValue", args: [#("value", types.GString(value))], 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.dynamic)) { Ok(_) -> types.Pure(Ok(Nil)) Error(_) -> types.Pure(Error(types.DecodingError("returnValue"))) } } ) } handler(interpreter.run(op, client)) } pub fn function_call_arg_value(id id: t.FunctionCallArgValue) -> t.FunctionCallArgValue { let field = types.Field(name: "loadFunctionCallArgValueFromID", args: [#("id", types.GDeferred(id.op))], subfields: []) t.FunctionCallArgValue(op: types.Pure([field])) } /// A unique identifier for this FunctionCallArgValue. pub fn function_call_arg_value_id(parent: t.FunctionCallArgValue) -> t.FunctionCallArgValue { let field = types.Field(name: "id", args: [], subfields: []) let new_op = { use q <- types.bind(parent.op) types.Pure(list.append(q, [field])) } t.FunctionCallArgValue(op: new_op) } /// The name of the argument. pub fn function_call_arg_value_name(parent: t.FunctionCallArgValue, 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)) } /// The value of the argument represented as a JSON serialized string. pub fn value(parent: t.FunctionCallArgValue, client client: Client, then handler: fn(Try(String)) -> a) -> a { let field = types.Field(name: "value", 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("value"))) } } ) } handler(interpreter.run(op, client)) }