You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

150 lines
5.3 KiB

defmodule DecentralisedBookIndex.Metadata do
use Ash.Domain, otp_app: :decentralised_book_index, extensions: [AshJsonApi.Domain, AshPhoenix]
alias DecentralisedBookIndex.Metadata
json_api do
routes do
base_route "/books", Metadata.Book do
get :read
index :search
related :bids, :read, primary?: true
related :author_roles, :read, primary?: true
related :publisher, :read, primary?: true
end
base_route "/authors", Metadata.Author do
get :read
index :search
end
base_route "/publishers", Metadata.Publisher do
get :read
index :search
end
end
end
resources do
resource DecentralisedBookIndex.Metadata.Book do
define :create_book,
action: :create,
args: [
:title,
:description,
:language,
:format,
:page_count,
:published,
:bids,
:author_roles,
:publisher_id,
{:optional, :cover_image_url},
{:optional, :book_editions_registry_id}
]
define :add_book_to_related_editions_registry,
action: :add_book_to_related_editions_registry,
args: [
:title,
:description,
:language,
:format,
:page_count,
:published,
:bids,
:author_roles,
:publisher_id,
:related_book_id,
{:optional, :cover_image_url}
]
define :list_books, action: :read
define :get_book_by_id, args: [:id], action: :by_id
define :get_book_by_bid, args: [:type, :bid], action: :by_bid
define :get_book_alternative_editions, args: [:book], action: :get_alternative_editions
define :get_author_books, args: [:author], action: :get_author_books
define :search_book, action: :search, args: [:query]
define :search_book_by_bid, action: :search_by_bid, args: [:type, :bid]
define :update_book, action: :update
define :assign_book_cover_image, args: [:cover_image_url], action: :assign_cover_image
define :destroy_book, action: :destroy
end
resource DecentralisedBookIndex.Metadata.Author do
define :create_author,
action: :create,
args: [
:name,
:description,
{:optional, :avatar_url},
{:optional, :author_alias_registry_id}
]
define :add_author_to_related_alias_registry,
action: :add_author_to_related_alias_registry,
args: [:name, :description, :related_author_id, {:optional, :avatar_url}]
define :list_authors, action: :read
define :get_author_by_id, args: [:id], action: :by_id
define :get_author_ids, args: [:author], action: :get_author_ids
define :get_author_alternative_names, args: [:author], action: :get_alternative_names
define :search_author, action: :search, args: [:name]
define :update_author, action: :update
define :assign_author_avatar_image, args: [:avatar_url], action: :assign_avatar_image
define :destroy_author, action: :destroy
end
resource DecentralisedBookIndex.Metadata.DBIServer do
define :create_dbi_server, action: :create
define :list_dbi_server, action: :read
define :get_dbi_server_by_id, args: [:id], action: :by_id
define :update_dbi_server, action: :update
define :destroy_dbi_server, action: :destroy
end
resource DecentralisedBookIndex.Metadata.AuthorAliasRegistry do
define :create_author_alias_registry, action: :create
define :list_author_alias_registries, action: :read
define :get_author_alias_registry_by_id, args: [:id], action: :by_id
define :update_author_alias_registry, action: :update
define :destroy_author_alias_registry, action: :destroy
end
resource DecentralisedBookIndex.Metadata.BookEditionsRegistry do
define :create_book_editions_registry, action: :create
define :list_book_editions_registries, action: :read
define :get_book_editions_registry_by_id, args: [:id], action: :by_id
define :update_book_editions_registry, action: :update
define :destroy_book_editions_registry, action: :destroy
end
resource DecentralisedBookIndex.Metadata.AuthorRole do
define :create_author_role, action: :create, args: [:author_id, :order, :role]
define :list_author_roles, action: :read
define :get_author_role_by_id, args: [:id], action: :by_id
define :get_author_roles_by_book_id, args: [:book_id], action: :by_book_id
define :update_author_role, action: :update
define :destroy_author_role, action: :destroy
end
resource DecentralisedBookIndex.Metadata.BookId do
define :create_book_id, action: :create, args: [:type, :bid, :order]
define :list_book_ids, action: :read
define :get_book_id_by_id, args: [:id], action: :by_id
define :update_book_id, action: :update
define :destroy_book_id, action: :destroy
end
resource DecentralisedBookIndex.Metadata.Publisher do
define :create_publisher, action: :create, args: [:name]
define :list_publishers, action: :read
define :get_publisher_by_id, args: [:id], action: :by_id
define :search_publisher, action: :search, args: [:name]
define :update_publisher, action: :update
define :destroy_publisher, action: :destroy
end
end
end