// 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 import gleam/option.{type Option, None, Some} pub type Opts { Opts( include: Option(List(String)), exclude: Option(List(String)), gitignore: Option(Bool), ) } fn defaults() -> Opts { Opts( include: None, exclude: None, gitignore: None, ) } pub fn none(opts: Opts) -> Opts { opts } pub fn include(opts: Opts, val: List(String)) -> Opts { Opts(..opts, include: Some(val)) } pub fn exclude(opts: Opts, val: List(String)) -> Opts { Opts(..opts, exclude: Some(val)) } pub fn gitignore(opts: Opts, val: Bool) -> Opts { Opts(..opts, gitignore: Some(val)) } pub fn current_module() -> t.CurrentModule { let field = types.Field(name: "currentModule", args: [], subfields: []) t.CurrentModule(op: types.Pure([field])) } /// The dependencies of the module. pub fn dependencies(parent: t.CurrentModule, select select: fn(t.Module) -> List(types.Field), client client: Client, then handler: fn(Try(List(t.Module))) -> a) -> a { let subfields = select(t.Module(op: types.Pure([]))) let field = types.Field(name: "dependencies", 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.Module(op: types.Pure(full_query)) }))) Error(_) -> types.Pure(Error(types.DecodingError("dependencies"))) } } ) } handler(interpreter.run(op, client)) } /// The generated files and directories made on top of the module source's context directory. pub fn generated_context_directory(parent: t.CurrentModule) -> t.Directory { let field = types.Field(name: "generatedContextDirectory", args: [], subfields: []) let new_op = { use q <- types.bind(parent.op) types.Pure(list.append(q, [field])) } t.Directory(op: new_op) } fn encode_generators(opts: Opts) -> List(#(String, types.Value)) { list.filter_map([ case opts.include { Some(val) -> Ok(#("include", types.GList(list.map(val, fn(x) { types.GString(x) })))) None -> Error(Nil) } ], fn(x) { x }) } /// Return all generators defined by the module pub fn generators(parent: t.CurrentModule, with with_fn: fn(Opts) -> Opts) -> t.GeneratorGroup { let opts = with_fn(defaults()) let field = types.Field(name: "generators", args: encode_generators(opts), subfields: []) let new_op = { use q <- types.bind(parent.op) types.Pure(list.append(q, [field])) } t.GeneratorGroup(op: new_op) } /// A unique identifier for this CurrentModule. pub fn id(parent: t.CurrentModule) -> t.CurrentModule { let field = types.Field(name: "id", args: [], subfields: []) let new_op = { use q <- types.bind(parent.op) types.Pure(list.append(q, [field])) } t.CurrentModule(op: new_op) } /// The name of the module being executed in pub fn name(parent: t.CurrentModule, 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 directory containing the module's source code loaded into the engine (plus any generated code that may have been created). pub fn source(parent: t.CurrentModule) -> t.Directory { let field = types.Field(name: "source", args: [], subfields: []) let new_op = { use q <- types.bind(parent.op) types.Pure(list.append(q, [field])) } t.Directory(op: new_op) } fn encode_workdir(opts: Opts) -> List(#(String, types.Value)) { list.filter_map([ case opts.include { Some(val) -> Ok(#("include", types.GList(list.map(val, fn(x) { types.GString(x) })))) None -> Error(Nil) }, case opts.exclude { Some(val) -> Ok(#("exclude", types.GList(list.map(val, fn(x) { types.GString(x) })))) None -> Error(Nil) }, case opts.gitignore { Some(val) -> Ok(#("gitignore", types.GBool(val))) None -> Error(Nil) } ], fn(x) { x }) } /// Load a directory from the module's scratch working directory, including any changes that may have been made to it during module function execution. pub fn workdir(parent: t.CurrentModule, path path: String, with with_fn: fn(Opts) -> Opts) -> t.Directory { let opts = with_fn(defaults()) let field = types.Field(name: "workdir", args: list.append([#("path", types.GString(path))], encode_workdir(opts)), subfields: []) let new_op = { use q <- types.bind(parent.op) types.Pure(list.append(q, [field])) } t.Directory(op: new_op) } /// Load a file from the module's scratch working directory, including any changes that may have been made to it during module function execution.Load a file from the module's scratch working directory, including any changes that may have been made to it during module function execution. pub fn workdir_file(parent: t.CurrentModule, path path: String) -> t.File { let field = types.Field(name: "workdirFile", args: [#("path", types.GString(path))], subfields: []) let new_op = { use q <- types.bind(parent.op) types.Pure(list.append(q, [field])) } t.File(op: new_op) }