Skip to content

Commit 8db2888

Browse files
committed
style(rpc): format json manifest generator
1 parent 5c969eb commit 8db2888

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

lib/ash_typescript/rpc/codegen/json_manifest_generator.ex

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ defmodule AshTypescript.Rpc.Codegen.JsonManifestGenerator do
3737
typed_controller_routes = build_typed_controller_routes()
3838

3939
manifest = %{
40-
"$schema" => "https://github.com/ash-project/ash_typescript/blob/main/json-manifest-schema.json",
40+
"$schema" =>
41+
"https://github.com/ash-project/ash_typescript/blob/main/json-manifest-schema.json",
4142
"version" => @manifest_version,
4243
"generatedAt" => Date.utc_today() |> Date.to_string(),
4344
"files" => build_files(manifest_path),
@@ -83,7 +84,8 @@ defmodule AshTypescript.Rpc.Codegen.JsonManifestGenerator do
8384
files
8485

8586
path ->
86-
if AshTypescript.TypedController.Codegen.RouteConfigCollector.get_typed_controllers() != [] do
87+
if AshTypescript.TypedController.Codegen.RouteConfigCollector.get_typed_controllers() !=
88+
[] do
8789
Map.put(files, "routes", file_entry(manifest_path, path))
8890
else
8991
files
@@ -164,7 +166,8 @@ defmodule AshTypescript.Rpc.Codegen.JsonManifestGenerator do
164166
(rpc_action.see || [])
165167
|> Enum.map(&Helpers.format_output_field/1),
166168
"input" => build_input_info(input_requirement),
167-
"types" => build_types(pascal_name, resource, action, rpc_action, has_fields, is_optional_pagination),
169+
"types" =>
170+
build_types(pascal_name, resource, action, rpc_action, has_fields, is_optional_pagination),
168171
"pagination" => build_pagination(action, is_get_action),
169172
"enableFilter" => Map.get(rpc_action, :enable_filter?, true),
170173
"enableSort" => Map.get(rpc_action, :enable_sort?, true),
@@ -173,7 +176,8 @@ defmodule AshTypescript.Rpc.Codegen.JsonManifestGenerator do
173176
"zod" => show_zod,
174177
"channel" => show_channel
175178
},
176-
"variantNames" => build_variant_names(rpc_action_name, show_validation, show_zod, show_channel)
179+
"variantNames" =>
180+
build_variant_names(rpc_action_name, show_validation, show_zod, show_channel)
177181
}
178182
end
179183

@@ -226,9 +230,15 @@ defmodule AshTypescript.Rpc.Codegen.JsonManifestGenerator do
226230
"supported" => supports,
227231
"required" => ActionIntrospection.action_requires_pagination?(action),
228232
"offset" =>
229-
if(supports, do: ActionIntrospection.action_supports_offset_pagination?(action), else: false),
233+
if(supports,
234+
do: ActionIntrospection.action_supports_offset_pagination?(action),
235+
else: false
236+
),
230237
"keyset" =>
231-
if(supports, do: ActionIntrospection.action_supports_keyset_pagination?(action), else: false),
238+
if(supports,
239+
do: ActionIntrospection.action_supports_keyset_pagination?(action),
240+
else: false
241+
),
232242
"get" => is_get_action
233243
}
234244
end
@@ -289,17 +299,24 @@ defmodule AshTypescript.Rpc.Codegen.JsonManifestGenerator do
289299
defp default_description(:create, resource_name), do: "Create a new #{resource_name}"
290300
defp default_description(:update, resource_name), do: "Update an existing #{resource_name}"
291301
defp default_description(:destroy, resource_name), do: "Delete a #{resource_name}"
292-
defp default_description(:action, resource_name), do: "Execute generic action on #{resource_name}"
302+
303+
defp default_description(:action, resource_name),
304+
do: "Execute generic action on #{resource_name}"
293305

294306
# Mirrors Rpc.Codegen.augment_action_with_rpc_settings/3
295307
defp augment_action_with_rpc_settings(action, rpc_action) do
296308
rpc_get? = Map.get(rpc_action, :get?, false)
297309
rpc_get_by = Map.get(rpc_action, :get_by) || []
298310

299311
cond do
300-
rpc_get? -> Map.put(action, :get?, true)
301-
rpc_get_by != [] -> action |> Map.put(:get?, true) |> Map.put(:rpc_get_by_fields, rpc_get_by)
302-
true -> action
312+
rpc_get? ->
313+
Map.put(action, :get?, true)
314+
315+
rpc_get_by != [] ->
316+
action |> Map.put(:get?, true) |> Map.put(:rpc_get_by_fields, rpc_get_by)
317+
318+
true ->
319+
action
303320
end
304321
end
305322

0 commit comments

Comments
 (0)