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.

106 lines
4.0 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 "/author", Metadata.Author 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, :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]
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 :update_book, action: :update
define :destroy_book, action: :destroy
end
resource DecentralisedBookIndex.Metadata.Author do
define :create_author,
action: :create,
args: [:name, :description, {: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]
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 :destroy_author, action: :destroy
end
resource DecentralisedBookIndex.Metadata.DBIServer
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 :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 :update_publisher, action: :update
define :destroy_publisher, action: :destroy
end
end
end