-module(dagger@dsl@workspace). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/dagger/dsl/workspace.gleam"). -export([none/1, opt_skip_migration_check/2, opt_exclude/2, opt_include/2, opt_gitignore/2, opt_from/2, workspace/1, client_id/3, directory/3, file/2, find_up/5, id/1, root/3]). -export_type([for_find_up/0, for_directory/0, for_workspace/0, opts/1]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. -type for_find_up() :: any(). -type for_directory() :: any(). -type for_workspace() :: any(). -opaque opts(AHNL) :: {opts, gleam@option:option(boolean()), gleam@option:option(list(binary())), gleam@option:option(list(binary())), gleam@option:option(boolean()), gleam@option:option(binary())} | {gleam_phantom, AHNL}. -file("src/dagger/dsl/workspace.gleam", 24). -spec defaults() -> opts(any()). defaults() -> {opts, none, none, none, none, none}. -file("src/dagger/dsl/workspace.gleam", 34). -spec none(opts(AHNO)) -> opts(AHNO). none(Opts) -> Opts. -file("src/dagger/dsl/workspace.gleam", 38). -spec opt_skip_migration_check(opts(for_workspace()), boolean()) -> opts(for_workspace()). opt_skip_migration_check(Opts, Val) -> {opts, {some, Val}, erlang:element(3, Opts), erlang:element(4, Opts), erlang:element(5, Opts), erlang:element(6, Opts)}. -file("src/dagger/dsl/workspace.gleam", 42). -spec opt_exclude(opts(for_directory()), list(binary())) -> opts(for_directory()). opt_exclude(Opts, Val) -> {opts, erlang:element(2, Opts), {some, Val}, erlang:element(4, Opts), erlang:element(5, Opts), erlang:element(6, Opts)}. -file("src/dagger/dsl/workspace.gleam", 46). -spec opt_include(opts(for_directory()), list(binary())) -> opts(for_directory()). opt_include(Opts, Val) -> {opts, erlang:element(2, Opts), erlang:element(3, Opts), {some, Val}, erlang:element(5, Opts), erlang:element(6, Opts)}. -file("src/dagger/dsl/workspace.gleam", 50). -spec opt_gitignore(opts(for_directory()), boolean()) -> opts(for_directory()). opt_gitignore(Opts, Val) -> {opts, erlang:element(2, Opts), erlang:element(3, Opts), erlang:element(4, Opts), {some, Val}, erlang:element(6, Opts)}. -file("src/dagger/dsl/workspace.gleam", 54). -spec opt_from(opts(for_find_up()), binary()) -> opts(for_find_up()). opt_from(Opts, Val) -> {opts, erlang:element(2, Opts), erlang:element(3, Opts), erlang:element(4, Opts), erlang:element(5, Opts), {some, Val}}. -file("src/dagger/dsl/workspace.gleam", 58). -spec encode_workspace(opts(any())) -> list({binary(), dagger@types:value()}). encode_workspace(Opts) -> gleam@list:filter_map([case erlang:element(2, Opts) of {some, Val} -> {ok, {<<"skipMigrationCheck"/utf8>>, {g_bool, Val}}}; none -> {error, nil} end], fun(X) -> X end). -file("src/dagger/dsl/workspace.gleam", 67). -spec workspace(fun((opts(for_workspace())) -> opts(for_workspace()))) -> dagger@dsl@types:workspace(). workspace(With_fn) -> Opts = With_fn(defaults()), Field = {field, <<"currentWorkspace"/utf8>>, encode_workspace(Opts), []}, {workspace, {pure, [Field]}}. -file("src/dagger/dsl/workspace.gleam", 74). ?DOC(" The client ID that owns this workspace's host filesystem.\n"). -spec client_id( dagger@dsl@types:workspace(), dagger@types:client(), fun(({ok, binary()} | {error, dagger@types:query_error()}) -> AHOJ) ) -> AHOJ. client_id(Parent, Client, Handler) -> Field = {field, <<"clientId"/utf8>>, [], []}, Op = begin dagger@types:bind( erlang:element(2, Parent), fun(Q) -> Full_query = lists:append(Q, [Field]), {fetch, Full_query, {decoder, fun gleam@dynamic@decode:decode_dynamic/1}, fun(Dyn) -> Path = dagger@types:make_path(Full_query), case gleam@dynamic@decode:run( Dyn, gleam@dynamic@decode:at( Path, {decoder, fun gleam@dynamic@decode:decode_string/1} ) ) of {ok, Val} -> {pure, {ok, Val}}; {error, _} -> {pure, {error, {decoding_error, <<"clientId"/utf8>>}}} end end} end ) end, Handler(dagger@interpreter:run(Op, Client)). -file("src/dagger/dsl/workspace.gleam", 94). -spec encode_directory(opts(any())) -> list({binary(), dagger@types:value()}). encode_directory(Opts) -> gleam@list:filter_map([case erlang:element(3, Opts) of {some, Val} -> {ok, {<<"exclude"/utf8>>, {g_list, gleam@list:map(Val, fun(X) -> {g_string, X} end)}}}; none -> {error, nil} end, case erlang:element(4, Opts) of {some, Val@1} -> {ok, {<<"include"/utf8>>, {g_list, gleam@list:map( Val@1, fun(X@1) -> {g_string, X@1} end )}}}; none -> {error, nil} end, case erlang:element(5, Opts) of {some, Val@2} -> {ok, {<<"gitignore"/utf8>>, {g_bool, Val@2}}}; none -> {error, nil} end], fun(X@2) -> X@2 end). -file("src/dagger/dsl/workspace.gleam", 113). ?DOC( " Returns a Directory from the workspace.\n" " Path is relative to workspace root. Use \".\" for the root directory.\n" ). -spec directory( dagger@dsl@types:workspace(), binary(), fun((opts(for_directory())) -> opts(for_directory())) ) -> dagger@dsl@types:directory(). directory(Parent, Path, With_fn) -> Opts = With_fn(defaults()), Field = {field, <<"directory"/utf8>>, lists:append( [{<<"path"/utf8>>, {g_string, Path}}], encode_directory(Opts) ), []}, New_op = begin dagger@types:bind( erlang:element(2, Parent), fun(Q) -> {pure, lists:append(Q, [Field])} end ) end, {directory, New_op}. -file("src/dagger/dsl/workspace.gleam", 125). ?DOC( " Returns a File from the workspace.\n" " Path is relative to workspace root.\n" ). -spec file(dagger@dsl@types:workspace(), binary()) -> dagger@dsl@types:file(). file(Parent, Path) -> Field = {field, <<"file"/utf8>>, [{<<"path"/utf8>>, {g_string, Path}}], []}, New_op = begin dagger@types:bind( erlang:element(2, Parent), fun(Q) -> {pure, lists:append(Q, [Field])} end ) end, {file, New_op}. -file("src/dagger/dsl/workspace.gleam", 134). -spec encode_find_up(opts(any())) -> list({binary(), dagger@types:value()}). encode_find_up(Opts) -> gleam@list:filter_map([case erlang:element(6, Opts) of {some, Val} -> {ok, {<<"from"/utf8>>, {g_string, Val}}}; none -> {error, nil} end], fun(X) -> X end). -file("src/dagger/dsl/workspace.gleam", 146). ?DOC( " Search for a file or directory by walking up from the start path within the workspace.\n" " Returns the path relative to the workspace root if found, or null if not found.\n" " The search stops at the workspace root and will not traverse above it.\n" ). -spec find_up( dagger@dsl@types:workspace(), binary(), fun((opts(for_find_up())) -> opts(for_find_up())), dagger@types:client(), fun(({ok, binary()} | {error, dagger@types:query_error()}) -> AHOV) ) -> AHOV. find_up(Parent, Name, With_fn, Client, Handler) -> Opts = With_fn(defaults()), Field = {field, <<"findUp"/utf8>>, lists:append( [{<<"name"/utf8>>, {g_string, Name}}], encode_find_up(Opts) ), []}, Op = begin dagger@types:bind( erlang:element(2, Parent), fun(Q) -> Full_query = lists:append(Q, [Field]), {fetch, Full_query, {decoder, fun gleam@dynamic@decode:decode_dynamic/1}, fun(Dyn) -> Path = dagger@types:make_path(Full_query), case gleam@dynamic@decode:run( Dyn, gleam@dynamic@decode:at( Path, {decoder, fun gleam@dynamic@decode:decode_string/1} ) ) of {ok, Val} -> {pure, {ok, Val}}; {error, _} -> {pure, {error, {decoding_error, <<"findUp"/utf8>>}}} end end} end ) end, Handler(dagger@interpreter:run(Op, Client)). -file("src/dagger/dsl/workspace.gleam", 168). ?DOC(" A unique identifier for this Workspace.\n"). -spec id(dagger@dsl@types:workspace()) -> dagger@dsl@types:workspace(). id(Parent) -> Field = {field, <<"id"/utf8>>, [], []}, New_op = begin dagger@types:bind( erlang:element(2, Parent), fun(Q) -> {pure, lists:append(Q, [Field])} end ) end, {workspace, New_op}. -file("src/dagger/dsl/workspace.gleam", 178). ?DOC(" Absolute path to the workspace root directory.\n"). -spec root( dagger@dsl@types:workspace(), dagger@types:client(), fun(({ok, binary()} | {error, dagger@types:query_error()}) -> AHOX) ) -> AHOX. root(Parent, Client, Handler) -> Field = {field, <<"root"/utf8>>, [], []}, Op = begin dagger@types:bind( erlang:element(2, Parent), fun(Q) -> Full_query = lists:append(Q, [Field]), {fetch, Full_query, {decoder, fun gleam@dynamic@decode:decode_dynamic/1}, fun(Dyn) -> Path = dagger@types:make_path(Full_query), case gleam@dynamic@decode:run( Dyn, gleam@dynamic@decode:at( Path, {decoder, fun gleam@dynamic@decode:decode_string/1} ) ) of {ok, Val} -> {pure, {ok, Val}}; {error, _} -> {pure, {error, {decoding_error, <<"root"/utf8>>}}} end end} end ) end, Handler(dagger@interpreter:run(Op, Client)).