Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Move All CMS References and behavior from MishkaIntsaller to CMS #220

Open
shahryarjb opened this issue Nov 23, 2022 · 31 comments
Open

Move All CMS References and behavior from MishkaIntsaller to CMS #220

shahryarjb opened this issue Nov 23, 2022 · 31 comments
Labels
bug Something isn't working dependencies Pull requests that update a dependency file enhancement New feature or request

Comments

@shahryarjb
Copy link
Owner

Since MishkaInstaller has become an independent plugin, we need to transfer CMS related items to the content management system itself

@shahryarjb shahryarjb added bug Something isn't working enhancement New feature or request dependencies Pull requests that update a dependency file labels Nov 23, 2022
@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnUserLogin do
  @moduledoc """

  """
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnUserLoginFailure do
  @moduledoc """
    This event is triggered whenever a user is unsuccessfully logged in. if there is any active module in this section on state,
    this module sends a request as a Task tool to the developer call function that includes `user_info()`, `ip()`, `endpoint()`.
    It should be noted; This process does not interfere with the main operation of the system.
    It is just a sender and is active for both side endpoints.
  """
  defstruct [:conn, :ip, :endpoint, :error, :extra]

  @type error() :: map() | struct() | tuple()
  @type extra() :: map() | struct() | list()
  @type conn() :: Plug.Conn.t()
  # User's IP from both side endpoints connections
  @type ip() :: String.t() | tuple()
  # API, HTML
  @type endpoint() :: :html | :api
  # Name of this event
  @type ref() :: :on_user_login_failure
  # output of state for this event
  @type reason() :: map() | String.t()
  # information about this plugin on state which was saved
  @type registerd_info() :: MishkaInstaller.PluginState.t()
  @type state() :: %__MODULE__{
          conn: conn(),
          ip: ip(),
          endpoint: endpoint(),
          error: error(),
          extra: extra()
        }
  # help developers to keep elixir style
  @type t :: state()
  @type optional_callbacks :: {:ok, ref(), registerd_info()} | {:error, ref(), reason()}

  @doc "This Callback can be used when you want to register a plugin"
  @callback initial(list()) :: {:ok, ref(), list()} | {:error, ref(), reason()}
  @doc "This Callback can be used when you want to call a plugin"
  @callback call(state()) :: {:reply, state()} | {:reply, :halt, state()}
  @doc "This Callback can be used when you want to stop a plugin"
  @callback stop(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to restart a plugin"
  @callback restart(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to start a plugin"
  @callback start(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to delete a plugin"
  @callback delete(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to unregister a plugin"
  @callback unregister(registerd_info()) :: optional_callbacks()
  # Developer can use this callbacks if he/she needs
  @optional_callbacks stop: 1, restart: 1, start: 1, delete: 1, unregister: 1
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnUserBeforeSave do
  @moduledoc """

  """
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnUserBeforeLogin do
  defstruct [:ip, :assigns, :output, :input]

  @type input() :: map()
  @type assigns() :: Phoenix.LiveView.Socket.assigns()
  @type output() :: Phoenix.LiveView.Rendered.t() | nil
  # User's IP from both side endpoints connections
  @type ip() :: String.t() | tuple()
  # Name of this event
  @type ref() :: :on_user_before_login
  # output of state for this event
  @type reason() :: map() | String.t()
  # information about this plugin on state which was saved
  @type registerd_info() :: MishkaInstaller.PluginState.t()
  @type state() :: %__MODULE__{ip: ip(), assigns: assigns(), input: input(), output: output()}
  # help developers to keep elixir style
  @type t :: state()
  @type optional_callbacks :: {:ok, ref(), registerd_info()} | {:error, ref(), reason()}

  @doc "This Callback can be used when you want to register a plugin"
  @callback initial(list()) :: {:ok, ref(), list()} | {:error, ref(), reason()}
  @doc "This Callback can be used when you want to call a plugin"
  @callback call(state()) :: {:reply, state()} | {:reply, :halt, state()}
  @doc "This Callback can be used when you want to stop a plugin"
  @callback stop(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to restart a plugin"
  @callback restart(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to start a plugin"
  @callback start(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to delete a plugin"
  @callback delete(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to unregister a plugin"
  @callback unregister(registerd_info()) :: optional_callbacks()
  # Developer can use this callbacks if he/she needs
  @optional_callbacks stop: 1, restart: 1, start: 1, delete: 1, unregister: 1
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnUserAuthorisation do
  @moduledoc """
    This event is triggered whenever a user accesses form an authorisation. if there is any active module in this section on state,
    this module sends a request as a Task tool to the developer call function that includes `user_id()`, `entries()`, `ip()`, `endpoint()`.
    It should be noted; This process does not interfere with the main operation of the system.
    It is just a sender and is active for both side endpoints.
  """
  defstruct [:conn, :user_id, :ip, :endpoint, :module, :operation, :extra]

  @type entries() :: map() | struct() | tuple()
  @type user_id() :: <<_::288>>
  @type extra() :: map() | struct() | list()
  @type conn() :: Plug.Conn.t() | Phoenix.LiveView.Socket.t()
  # User's IP from both side endpoints connections
  @type ip() :: String.t() | tuple()
  # API, HTML
  @type endpoint() :: :html | :api
  @type module_name() :: String.t()
  @type operation() :: atom()
  # Name of this event
  @type ref() :: :on_user_authorisation
  # output of state for this event
  @type reason() :: map() | String.t()
  # information about this plugin on state which was saved
  @type registerd_info() :: MishkaInstaller.PluginState.t()
  @type state() :: %__MODULE__{
          conn: conn(),
          user_id: user_id(),
          ip: ip(),
          endpoint: endpoint(),
          module: module(),
          operation: operation(),
          extra: extra()
        }
  # help developers to keep elixir style
  @type t :: state()
  @type optional_callbacks :: {:ok, ref(), registerd_info()} | {:error, ref(), reason()}

  @doc "This Callback can be used when you want to register a plugin"
  @callback initial(list()) :: {:ok, ref(), list()} | {:error, ref(), reason()}
  @doc "This Callback can be used when you want to call a plugin"
  @callback call(state()) :: {:reply, state()} | {:reply, :halt, state()}
  @doc "This Callback can be used when you want to stop a plugin"
  @callback stop(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to restart a plugin"
  @callback restart(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to start a plugin"
  @callback start(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to delete a plugin"
  @callback delete(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to unregister a plugin"
  @callback unregister(registerd_info()) :: optional_callbacks()
  # Developer can use this callbacks if he/she needs
  @optional_callbacks stop: 1, restart: 1, start: 1, delete: 1, unregister: 1
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnUserAuthorisationFailure do
  @moduledoc """
    This event is triggered whenever a user gets an error for authorisation. if there is any active module in this section on state,
    this module sends a request as a Task tool to the developer call function that includes `extra()`, `ip()`, `endpoint()`.
    It should be noted; This process does not interfere with the main operation of the system.
    It is just a sender and is active for both side endpoints.
  """
  defstruct [:conn, :ip, :endpoint, :error, :module, :operation, :extra]

  @type extra() :: map() | struct() | list()
  @type error() :: map() | struct() | tuple()
  @type conn() :: Plug.Conn.t() | Phoenix.LiveView.Socket.t()
  # User's IP from both side endpoints connections
  @type ip() :: String.t() | tuple()
  # API, HTML
  @type endpoint() :: atom()
  @type operation() :: atom()
  # Name of this event
  @type ref() :: :on_user_authorisation_failure
  # output of state for this event
  @type reason() :: map() | String.t()
  # information about this plugin on state which was saved
  @type registerd_info() :: MishkaInstaller.PluginState.t()
  @type state() :: %__MODULE__{
          conn: conn(),
          ip: ip(),
          endpoint: endpoint(),
          error: error(),
          module: module(),
          operation: operation(),
          extra: extra()
        }
  # help developers to keep elixir style
  @type t :: state()
  @type optional_callbacks :: {:ok, ref(), registerd_info()} | {:error, ref(), reason()}

  @doc "This Callback can be used when you want to register a plugin"
  @callback initial(list()) :: {:ok, ref(), list()} | {:error, ref(), reason()}
  @doc "This Callback can be used when you want to call a plugin"
  @callback call(state()) :: {:reply, state()} | {:reply, :halt, state()}
  @doc "This Callback can be used when you want to stop a plugin"
  @callback stop(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to restart a plugin"
  @callback restart(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to start a plugin"
  @callback start(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to delete a plugin"
  @callback delete(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to unregister a plugin"
  @callback unregister(registerd_info()) :: optional_callbacks()
  # Developer can use this callbacks if he/she needs
  @optional_callbacks stop: 1, restart: 1, start: 1, delete: 1, unregister: 1
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnUserAfterSave do
  @moduledoc """
    This event is triggered whenever a user is successfully added or edited. if there is any active module in this section on state,
    this module sends a request as a Task tool to the developer call function that includes `user_info()`, `ip()`, `endpoint()`.
    It should be noted; This process does not interfere with the main operation of the system.
    It is just a sender and is active for both side endpoints.
  """
  defstruct [:user_info, :ip, :endpoint, :status, :conn, :modifier_user, :extra]

  @type modifier_user() :: <<_::288>> | :self
  @type user_info() :: map()
  @type status() :: :added | :edited
  @type conn() :: Plug.Conn.t() | Phoenix.LiveView.Socket.t()
  @type extra() :: map() | struct() | list()
  # User's IP from both side endpoints connections
  @type ip() :: String.t() | tuple()
  # API, HTML
  @type endpoint() :: :html | :api
  # Name of this event
  @type ref() :: :on_user_after_save
  # output of state for this event
  @type reason() :: map() | String.t()
  # information about this plugin on state which was saved
  @type registerd_info() :: MishkaInstaller.PluginState.t()
  @type state() :: %__MODULE__{
          user_info: user_info(),
          ip: ip(),
          endpoint: endpoint(),
          status: status(),
          conn: conn(),
          modifier_user: modifier_user(),
          extra: extra()
        }
  # help developers to keep elixir style
  @type t :: state()
  @type optional_callbacks :: {:ok, ref(), registerd_info()} | {:error, ref(), reason()}

  @doc "This Callback can be used when you want to register a plugin"
  @callback initial(list()) :: {:ok, ref(), list()} | {:error, ref(), reason()}
  @doc "This Callback can be used when you want to call a plugin"
  @callback call(state()) :: {:reply, state()} | {:reply, :halt, state()}
  @doc "This Callback can be used when you want to stop a plugin"
  @callback stop(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to restart a plugin"
  @callback restart(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to start a plugin"
  @callback start(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to delete a plugin"
  @callback delete(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to unregister a plugin"
  @callback unregister(registerd_info()) :: optional_callbacks()
  # Developer can use this callbacks if he/she needs
  @optional_callbacks stop: 1, restart: 1, start: 1, delete: 1, unregister: 1
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnUserAfterSaveRole do
  @moduledoc """
    This event is triggered whenever a user's role is successfully saved or edited. if there is any active module in this section on state,
    this module sends a request as a Task tool to the developer call function that includes `user_info()`, `ip()`, `endpoint()`, `modifier_user()`.
    It should be noted; This process does not interfere with the main operation of the system.
    It is just a sender and is active for both side endpoints.
  """
  defstruct [:role_id, :ip, :endpoint, :conn]

  @type role_id() :: <<_::288>>
  @type user_id() :: role_id()
  @type conn() :: Plug.Conn.t() | Phoenix.LiveView.Socket.t()
  # User's IP from both side endpoints connections
  @type ip() :: String.t() | tuple()
  # API, HTML
  @type endpoint() :: :html | :api
  # Name of this event
  @type ref() :: :on_user_after_save_role
  # output of state for this event
  @type reason() :: map() | String.t()
  # information about this plugin on state which was saved
  @type registerd_info() :: MishkaInstaller.PluginState.t()
  @type state() :: %__MODULE__{role_id: role_id(), ip: ip(), endpoint: endpoint(), conn: conn()}
  # help developers to keep elixir style
  @type t :: state()
  @type optional_callbacks :: {:ok, ref(), registerd_info()} | {:error, ref(), reason()}

  @doc "This Callback can be used when you want to register a plugin"
  @callback initial(list()) :: {:ok, ref(), list()} | {:error, ref(), reason()}
  @doc "This Callback can be used when you want to call a plugin"
  @callback call(state()) :: {:reply, state()} | {:reply, :halt, state()}
  @doc "This Callback can be used when you want to stop a plugin"
  @callback stop(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to restart a plugin"
  @callback restart(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to start a plugin"
  @callback start(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to delete a plugin"
  @callback delete(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to unregister a plugin"
  @callback unregister(registerd_info()) :: optional_callbacks()
  # Developer can use this callbacks if he/she needs
  @optional_callbacks stop: 1, restart: 1, start: 1, delete: 1, unregister: 1
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnUserAfterSaveFailure do
  @moduledoc """
    This event is triggered whenever a user is successfully added or edited. if there is any active module in this section on state,
    this module sends a request as a Task tool to the developer call function that includes `user_info()`, `ip()`, `endpoint()`.
    It should be noted; This process does not interfere with the main operation of the system.
    It is just a sender and is active for both side endpoints.
  """
  defstruct [:error, :ip, :endpoint, :status, :conn, :modifier_user, :extra]

  @type modifier_user() :: <<_::288>> | :self
  @type error() :: map() | struct() | tuple()
  @type status() :: :added | :edited
  @type conn() :: Plug.Conn.t() | Phoenix.LiveView.Socket.t()
  @type extra() :: map() | struct() | list()
  # User's IP from both side endpoints connections
  @type ip() :: String.t() | tuple()
  # API, HTML
  @type endpoint() :: :html | :api
  # Name of this event
  @type ref() :: :on_user_after_save_failure
  # output of state for this event
  @type reason() :: map() | String.t()
  # information about this plugin on state which was saved
  @type registerd_info() :: MishkaInstaller.PluginState.t()
  @type state() :: %__MODULE__{
          error: error(),
          ip: ip(),
          endpoint: endpoint(),
          status: status(),
          conn: conn(),
          modifier_user: modifier_user(),
          extra: extra()
        }
  # help developers to keep elixir style
  @type t :: state()
  @type optional_callbacks :: {:ok, ref(), registerd_info()} | {:error, ref(), reason()}

  @doc "This Callback can be used when you want to register a plugin"
  @callback initial(list()) :: {:ok, ref(), list()} | {:error, ref(), reason()}
  @doc "This Callback can be used when you want to call a plugin"
  @callback call(state()) :: {:reply, state()} | {:reply, :halt, state()}
  @doc "This Callback can be used when you want to stop a plugin"
  @callback stop(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to restart a plugin"
  @callback restart(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to start a plugin"
  @callback start(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to delete a plugin"
  @callback delete(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to unregister a plugin"
  @callback unregister(registerd_info()) :: optional_callbacks()
  # Developer can use this callbacks if he/she needs
  @optional_callbacks stop: 1, restart: 1, start: 1, delete: 1, unregister: 1
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnUserAfterLogout do
  @moduledoc """
    This event is triggered whenever a user is successfully logged out. if there is any active module in this section on state,
    this module sends a request as a Task tool to the developer call function that includes `user_id()`, `ip()`, `endpoint()`.
    It should be noted; This process does not interfere with the main operation of the system.
    It is just a sender and is active for both side endpoints.
  """
  defstruct [:user_id, :ip, :endpoint, :conn, :extra]

  @type user_id() :: <<_::288>>
  @type extra() :: map() | struct() | list()
  # User's IP from both side endpoints connections
  @type ip() :: String.t() | tuple()
  # API, HTML
  @type endpoint() :: :html | :api
  @type conn() :: Plug.Conn.t()
  # Name of this event
  @type ref() :: :on_user_after_logout
  # output of state for this event
  @type reason() :: map() | String.t()
  # information about this plugin on state which was saved
  @type registerd_info() :: MishkaInstaller.PluginState.t()
  @type state() :: %__MODULE__{
          user_id: user_id(),
          ip: ip(),
          endpoint: endpoint(),
          conn: conn(),
          extra: extra()
        }
  # help developers to keep elixir style
  @type t :: state()
  @type optional_callbacks :: {:ok, ref(), registerd_info()} | {:error, ref(), reason()}

  @doc "This Callback can be used when you want to register a plugin"
  @callback initial(list()) :: {:ok, ref(), list()} | {:error, ref(), reason()}
  @doc "This Callback can be used when you want to call a plugin"
  @callback call(state()) :: {:reply, state()} | {:reply, :halt, state()}
  @doc "This Callback can be used when you want to stop a plugin"
  @callback stop(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to restart a plugin"
  @callback restart(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to start a plugin"
  @callback start(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to delete a plugin"
  @callback delete(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to unregister a plugin"
  @callback unregister(registerd_info()) :: optional_callbacks()
  # Developer can use this callbacks if he/she needs
  @optional_callbacks stop: 1, restart: 1, start: 1, delete: 1, unregister: 1
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnUserAfterLogin do
  @moduledoc """
    This event is triggered whenever a user is successfully logged in. if there is any active module in this section on state,
    this module sends a request as a Task tool to the developer call function that includes `user_info()`, `ip()`, `endpoint()`.
    It should be noted; This process does not interfere with the main operation of the system.
    It is just a sender and is active for both side endpoints.
  """
  defstruct [:user_info, :ip, :endpoint, :conn, :type, :extra]

  @type user_info() :: map()
  @type extra() :: map() | struct() | list()
  @type conn() :: Plug.Conn.t()
  @type type() :: :email | :username
  # User's IP from both side endpoints connections
  @type ip() :: String.t() | tuple()
  # API, HTML
  @type endpoint() :: :html | :api
  # Name of this event
  @type ref() :: :on_user_after_login
  # output of state for this event
  @type reason() :: map() | String.t()
  # information about this plugin on state which was saved
  @type registerd_info() :: MishkaInstaller.PluginState.t()
  @type state() :: %__MODULE__{
          user_info: user_info(),
          ip: ip(),
          endpoint: endpoint(),
          conn: conn(),
          type: type(),
          extra: extra()
        }
  # help developers to keep elixir style
  @type t :: state()
  @type optional_callbacks :: {:ok, ref(), registerd_info()} | {:error, ref(), reason()}

  @doc "This Callback can be used when you want to register a plugin"
  @callback initial(list()) :: {:ok, ref(), list()} | {:error, ref(), reason()}
  @doc "This Callback can be used when you want to call a plugin"
  @callback call(state()) :: {:reply, state()} | {:reply, :halt, state()}
  @doc "This Callback can be used when you want to stop a plugin"
  @callback stop(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to restart a plugin"
  @callback restart(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to start a plugin"
  @callback start(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to delete a plugin"
  @callback delete(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to unregister a plugin"
  @callback unregister(registerd_info()) :: optional_callbacks()
  # Developer can use this callbacks if he/she needs
  @optional_callbacks stop: 1, restart: 1, start: 1, delete: 1, unregister: 1
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnUserAfterDelete do
  @moduledoc """

  """
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnUserAfterDeleteRole do
  @moduledoc """
    This event is triggered whenever a user's role is successfully deleted. if there is any active module in this section on state,
    this module sends a request as a Task tool to the developer call function that includes `user_info()`, `ip()`, `endpoint()`, `modifier_user()`.
    It should be noted; This process does not interfere with the main operation of the system.
    It is just a sender and is active for both side endpoints.
  """
  defstruct [:role_id, :ip, :endpoint, :conn]

  @typedoc "This type can be used when you want to introduce what `role_id` is required"
  @type role_id() :: <<_::288>>
  @typedoc "This type can be used when you want to get a `user_id` (modifier_user)"
  @type user_id() :: role_id()
  @typedoc "This type can be used when you want to introduce the connection of a user request"
  @type conn() :: Plug.Conn.t() | Phoenix.LiveView.Socket.t()
  @typedoc "This type can be used when you want to get a user' IP"
  @type ip() :: String.t() | tuple()
  @typedoc "This type can be used when you want to introduce an endpoint module for your router"
  @type endpoint() :: :html | :api
  @typedoc "This type can be used when you want to introduce an app's reference name"
  @type ref() :: :on_user_after_delete_role
  @typedoc "This type can be used when you want to introduce a plugin output"
  @type reason() :: map() | String.t()
  @typedoc "This type can be used when you want to register an app"
  @type registerd_info() :: MishkaInstaller.PluginState.t()
  @typedoc "This type can be used when you want to introduce an app as a plugin"
  @type state() :: %__MODULE__{role_id: role_id(), ip: ip(), endpoint: endpoint(), conn: conn()}
  @typedoc "This type can be used when you want to introduce an app as a plugin"
  @type t :: state()
  @typedoc "This type can be used when you want to show the output of optional callbacks"
  @type optional_callbacks :: {:ok, ref(), registerd_info()} | {:error, ref(), reason()}

  @doc "This Callback can be used when you want to register a plugin"
  @callback initial(list()) :: {:ok, ref(), list()} | {:error, ref(), reason()}
  @doc "This Callback can be used when you want to call a plugin"
  @callback call(state()) :: {:reply, state()} | {:reply, :halt, state()}
  @doc "This Callback can be used when you want to stop a plugin"
  @callback stop(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to restart a plugin"
  @callback restart(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to start a plugin"
  @callback start(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to delete a plugin"
  @callback delete(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to unregister a plugin"
  @callback unregister(registerd_info()) :: optional_callbacks()
  # Developer can use this callbacks if he/she needs
  @optional_callbacks stop: 1, restart: 1, start: 1, delete: 1, unregister: 1
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnRouter do
  @moduledoc """

  ## elixir macros for router
  ```elixir
    live(path, live_view, action \\ nil, opts \\ [])
    live "/", TrackappWeb.Live.DepGetter

    delete(path, plug, plug_opts, options \\ [])
    delete("/events/:id", EventController, :action)

    forward(path, plug, plug_opts \\ [], router_opts \\ [])
    forward "/admin", SomeLib.AdminDashboard

    get(path, plug, plug_opts, options \\ [])
    get("/events/:id", EventController, :action)

    post(path, plug, plug_opts, options \\ [])
    post("/events/:id", EventController, :action)

    put(path, plug, plug_opts, options \\ [])
    put("/events/:id", EventController, :action)

    scope "/" do
      pipe_through :browser
      Enum.map(["1", "2"], fn x ->
        live("/x", TrackappWeb.Live.DepGetter)
      end)
    end

"""
defstruct [:action, :path, :endpoint, type: :public, plug_opts: []]

@TypeDoc "This type can be used when you want to specify which HTTP typing method is your desired"
@type action() :: :get | :post | :live | :delete | :put | :forward
@TypeDoc "This type can be used when you want to specify a path for your custom router"
@type path() :: String.t()
@type type() :: atom()
@TypeDoc "This type can be used when you want to introduce an endpoint module for your router"
@type endpoint() :: module()
@TypeDoc "This type can be used when you want to introduce an app's reference name"
@type ref() :: :on_router
@TypeDoc "This type can be used when you want to introduce a plugin output"
@type reason() :: map()
@TypeDoc "This type can be used when you want to register an app"
@type registerd_info() :: MishkaInstaller.PluginState.t()
@TypeDoc "This type can be used when you want to introduce an app as a plugin"
@type state() :: %MODULE{
action: action(),
path: path(),
endpoint: endpoint(),
type: type(),
plug_opts: list()
}
@TypeDoc "This type can be used when you want to introduce an app as a plugin"
@type t :: state()
@TypeDoc "This type can be used when you want to show the output of optional callbacks"
@type optional_callbacks :: {:ok, ref(), registerd_info()} | {:error, ref(), reason()}

@doc "This Callback can be used when you want to register a plugin"
@callback initial(list()) :: {:ok, ref(), list()} | {:error, ref(), reason()}
@doc "This Callback can be used when you want to call a plugin"
@callback call(state()) :: {:reply, state()} | {:reply, :halt, state()}
@doc "This Callback can be used when you want to stop a plugin"
@callback stop(registerd_info()) :: optional_callbacks()
@doc "This Callback can be used when you want to restart a plugin"
@callback restart(registerd_info()) :: optional_callbacks()
@doc "This Callback can be used when you want to start a plugin"
@callback start(registerd_info()) :: optional_callbacks()
@doc "This Callback can be used when you want to delete a plugin"
@callback delete(registerd_info()) :: optional_callbacks()
@doc "This Callback can be used when you want to unregister a plugin"
@callback unregister(registerd_info()) :: optional_callbacks()

Developer can use this callbacks if he/she needs

@optional_callbacks stop: 1, restart: 1, start: 1, delete: 1, unregister: 1
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnPrivacyCollectAdminCapabilities do
  @moduledoc """

  """
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnInit do
  @moduledoc """

  """
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnDisplay do
  @moduledoc """

  """
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnContentSearch do
  @moduledoc """

  """
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnContentSearchAreas do
  @moduledoc """

  """
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnContentPrepare do
  @moduledoc """

  """
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnContentPrepareForm do
  @moduledoc """

  """
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnContentPrepareData do
  @moduledoc """

  """
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnContentChangeState do
  @moduledoc """

  """
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnContentBeforeSave do
  @moduledoc """

  """
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnContentBeforeDisplay do
  @moduledoc """

  """
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnContentBeforeDelete do
  @moduledoc """

  """
end

@shahryarjb
Copy link
Owner Author

shahryarjb commented Nov 23, 2022

defmodule MishkaInstaller.Reference.OnContentAfterTitle do
  @moduledoc """

  """
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnContentAfterSave do
  @moduledoc """

  """
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnContentAfterDisplay do
  @moduledoc """

  """
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnContentAfterDelete do
  @moduledoc """
    With the help of this event, you can have information about the content that will be deleted in your plugin.
    This event has no return output. Please use the `operation: :no_return` flag.

    It is currently being renovated, and in the future it might look different.
  """
  defstruct [:section, :private, extra: %{}]

  @typedoc "This type can be used when you want to introduce what place this captcha is going to be run"
  @type section() :: atom()
  @typedoc "This type can be used when you want to introduce a user IP"
  @type user_id() :: <<_::288>>
  @typedoc "This type can be used when you want to introduce an app's reference name"
  @type ref() :: :on_content_after_delete
  @typedoc "This type can be used when you want to introduce a content output"
  @type content() :: map()
  @typedoc "This type can be used when you want to introduce a plugin output"
  @type reason() :: map() | String.t()
  @typedoc "This type can be used when you want to register an app"
  @type registerd_info() :: MishkaInstaller.PluginState.t()
  @typedoc "This type can be used when you want to introduce an IP"
  @type ip() :: String.t() | tuple()
  @typedoc "This type can be used when you want to introduce private properties"
  @type private() :: %{user_id: user_id(), content: content(), user_ip: ip()}
  @typedoc "This type can be used when you want to introduce an app as a plugin"
  @type state() :: %__MODULE__{section: section(), private: private(), extra: map()}
  @typedoc "This type can be used when you want to introduce an app as a plugin"
  @type t :: state()
  @typedoc "This type can be used when you want to show the output of optional callbacks"
  @type optional_callbacks :: {:ok, ref(), registerd_info()} | {:error, ref(), reason()}

  @doc "This Callback can be used when you want to register a plugin"
  @callback initial(list()) :: {:ok, ref(), list()} | {:error, ref(), reason()}
  @doc "This Callback can be used when you want to call a plugin"
  @callback call(state()) :: {:reply, state()} | {:reply, :halt, state()}
  @doc "This Callback can be used when you want to stop a plugin"
  @callback stop(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to restart a plugin"
  @callback restart(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to start a plugin"
  @callback start(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to delete a plugin"
  @callback delete(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to unregister a plugin"
  @callback unregister(registerd_info()) :: optional_callbacks()
  # Developer can use this callbacks if he/she needs
  @optional_callbacks stop: 1, restart: 1, start: 1, delete: 1, unregister: 1
end

@shahryarjb
Copy link
Owner Author

defmodule MishkaInstaller.Reference.OnCheckAnswer do
  @moduledoc """
    Event called to initialize the captcha you want. Do not enable more than 1 captcha.

    **Note**: This event is called directly in the html and will have an output

    It is currently being renovated, and in the future it might look different.
  """
  defstruct [:section, :private]

  @typedoc "This type can be used when you want to introduce what place this captcha is going to be run"
  @type section() :: atom()
  @typedoc "This type can be used when you want to introduce an app's reference name"
  @type ref() :: :on_check_answer
  @typedoc "This type can be used when you want to introduce a plugin output"
  @type reason() :: map() | String.t()
  @typedoc "This type can be used when you want to register an app"
  @type registerd_info() :: MishkaInstaller.PluginState.t()
  @typedoc "This type can be used when you want to introduce an IP"
  @type ip() :: String.t() | tuple()
  @typedoc "This type can be used when you want to introduce private properties"
  @type private() :: %{ip: ip()}
  @typedoc "This type can be used when you want to introduce an app as a plugin"
  @type state() :: %__MODULE__{section: section(), private: private()}
  @typedoc "This type can be used when you want to introduce an app as a plugin"
  @type t :: state()
  @typedoc "This type can be used when you want to show the output of optional callbacks"
  @type optional_callbacks :: {:ok, ref(), registerd_info()} | {:error, ref(), reason()}

  @doc "This Callback can be used when you want to register a plugin"
  @callback initial(list()) :: {:ok, ref(), list()} | {:error, ref(), reason()}
  @doc "This Callback can be used when you want to call a plugin"
  @callback call(state()) :: {:reply, state()} | {:reply, :halt, state()}
  @doc "This Callback can be used when you want to stop a plugin"
  @callback stop(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to restart a plugin"
  @callback restart(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to start a plugin"
  @callback start(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to delete a plugin"
  @callback delete(registerd_info()) :: optional_callbacks()
  @doc "This Callback can be used when you want to unregister a plugin"
  @callback unregister(registerd_info()) :: optional_callbacks()
  # Developer can use this callbacks if he/she needs
  @optional_callbacks stop: 1, restart: 1, start: 1, delete: 1, unregister: 1
end

@shahryarjb shahryarjb pinned this issue Nov 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working dependencies Pull requests that update a dependency file enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant