Hello, I need to store Typespecs
as item of a map, like the blow code:
def system_events do
[
%__MODULE__{name: :post_before_submit, allowed_input: String.t()}
]
end
Is there a way to save them as items of a map?
Nicd
January 4, 2022, 2:31pm
2
As far as I know, typespecs are an entirely compile time construct and do not exist at runtime. As such you can’t store them into a map. You can handle the AST representing typespecs in a macro (and put the AST in a map in a macro) the same as any AST, but that AST can’t be compiled in that position (as a value), only in @type(p)
and @spec
sections.
What do you want to do with this?
3 Likes
I want to check my user custom plugins that they want to add to my CMS, then I need to check users function outputs which is allowed or not. Then each event of my CMS events has own @spec
I just wanted to force them to create a plugin like a structure.
Nicd
January 4, 2022, 2:50pm
4
Do you mean plugins that are added at compile or runtime? Do you want to run Dialyzer on the user plugins?
1 Like
Something like Dialyzer
at compile or runtime, if they break the structure; software notices them after runtime when the project is running, or break runtime and show them an error.
Nicd
January 4, 2022, 2:59pm
6
I’m not sure how difficult it would be to run Dialyzer on user supplied code. I think it’s doable but not sure if it’s reasonable. But can’t really help more on that part.
But no, you can’t store typespecs at runtime. You could store the AST and unquote it to attach it to the user supplied code, or something like that, but not really an expert on it.
1 Like
This is not how typespecs work, they are not a runtime data validation tool at all.
2 Likes
Yes, I got it.
I am trying to change my way, and also I have created many callbacks
, but I need to find a way to force my users to do my template.
This is my task to improve my elixir open-source CMS.
opened 01:51PM - 02 Jan 22 UTC
documentation
enhancement
help wanted
After talking to @pouriya, I have decided to research about `ejabberd` plugins m… anager solutions. **Then we stop doing all updates out of our issues** and start learning and implementing a basic structure of plugins manager.
> This structure should force developers to work in a prepared template, which is introduced by MishkaCMS core in its documents
---
- [x] Stop the Deadlines
- [ ] Send a post about it to Erlang new forum
- [ ] Send a post about it to Elixir forum
- [x] Create a schema and graph about implementing
- [ ] Change version 0.0.2 plans of Projects (Project [0.0.2](https://github.com/mishka-group/mishka-cms/projects/2))
- [ ] Implement plugin system
- [ ] Identify some predefined behaviors and callbacks
- [ ] Add `depends` callback, based on https://github.com/mishka-group/mishka-cms/issues/148#issuecomment-1004047170
- [ ] Specify event naming structure
- [ ] Create plugin system documents
- [ ] Put plugin caller into `API` side
- [ ] Put plugin caller into `HTML` side
- [ ] What we should do for custom installation of template?
- [ ] What we should do for custom installation of new sub-system or import new event name for new template?
- [ ] Separate some modules and convert them as a new plugin!
- [ ] New features?
```elixir
I will update this post , connect this to some pull requests
```
---
### Initial diagram
![mishka-plugin](https://user-images.githubusercontent.com/8413604/147889836-4e190ae1-6fe6-46e1-86f8-6401773e096d.png)
---
### Talks:
1. Start the proposal and the topic raised --> https://youtu.be/FPDxyX4RzZc (Persian)
---
### Refs:
1. https://github.com/processone/ejabberd/blob/master/src/gen_mod.erl#L89-L92
2. https://hexdocs.pm/plug/Plug.Conn.html
3. https://www.ejabberd.im/
4. [How to add and install deps without stopping phoenix server (hex package)](https://elixirforum.com/t/how-to-add-and-install-deps-without-stopping-phoenix-server-hex-package/44888)
5. [How to create Ecto temporary tables for test a library](https://elixirforum.com/t/how-to-create-ecto-temporary-tables-for-test-a-library/44890)
6. [Need advice to implement custom extension and template installation in an elixir CMS](https://elixirforum.com/t/need-advice-to-implement-custom-extension-and-template-installation-in-an-elixir-cms/44863/)
7. [How to check a macro was called in a module](https://elixirforum.com/t/how-to-check-a-macro-was-called-in-a-module/44674)
8. https://docs.joomla.org/Plugin/Events
9. https://developer.wordpress.org/plugins/hooks/actions/
IvanR
January 13, 2022, 10:43pm
9
When inputs and outputs are valid, there is still uncertainty about how the plugin’s code affects the system. Like: does it write something unexpected on disk, or execute other applications?
There is no good solution for sandboxing Elixir to disallow selected functions. At the same time, there is one for sandboxed LUA running inside the Elixir GitHub - rvirding/luerl: Lua in Erlang with the support of functions blacklisting.
3 Likes
lud
January 14, 2022, 12:22am
10
Do you provide your CMS as a service or as source code that users compile themselves?
In the first case it will be totally unsafe. In the latter case, I guess just providing well documented typespecs, callback specs and good documentation should be enough.
1 Like
Yes it is open-source, I changed my way and got an idea from ejabberd.im
, I am developing as a custom plugins system manager than I described it in link blow
opened 01:51PM - 02 Jan 22 UTC
closed 09:56PM - 18 Mar 22 UTC
documentation
enhancement
help wanted
After talking to @pouriya, I have decided to research about `ejabberd` plugins m… anager solutions. **Then we stop doing all updates out of our issues** and start learning and implementing a basic structure of plugins manager.
> This structure should force developers to work in a prepared template, which is introduced by MishkaCMS core in its documents
---
- [x] Stop the Deadlines
- [x] Send a post about it to Elixir forum
- [x] Create a schema and graph about implementing
- [x] Considering Joomla events → https://github.com/mishka-group/mishka-cms/issues/148#issuecomment-1008177070
- [x] Change version 0.0.2 plans of Projects (Project [0.0.2](https://github.com/mishka-group/mishka-cms/projects/2))
- [x] Register Hook v1
- [x] Start Hook v1
- [x] Restart Hook v1
- [x] Stop Hook v1
- [x] Delete Hook v1
- [x] Unregister Hook v1
- [x] Call `init` of developer's plugin functions, when server is started
- [x] Call Hook v1
- [x] `ensure_event?` Hook v1
- [x] Test Hook
- [x] Test state
- [x] Implement plugin system
- [x] mishka-group/mishka_installer#2
- [x] Start creating tests
- [x] Create `db` of plugins
- [x] mishka-group/mishka-cms#168
> It doesn't matter we should duplicate activity of mishka_content because it helps us to delete circle of `deps`
- [x] Identify some predefined behaviors and callbacks
- [x] Add `depends` callback, based on https://github.com/mishka-group/mishka-cms/issues/148#issuecomment-1004047170
- [x] Specify event naming structure
- [x] mishka-group/mishka-cms#163
- [x] mishka-group/mishka-cms#164
- [x] mishka-group/mishka-cms#165
- [x] mishka-group/mishka-cms#155
- [x] Create Genserver Supervisor
- [x] Create Genserver Binding from beginning starting server
- [x] mishka-group/mishka-cms#160
- [x] mishka-group/mishka-cms#154
- [x] mishka-group/mishka-cms#153
- [x] mishka-group/mishka-cms#161
- [x] mishka-group/mishka-cms#166
1. Register and Login sending email
2. Date converter, `Jalaali`
- [x] New features?
1. what we should do about router? (the plugins need to import routers)
2. Decide how to inform admin to update the plugins which have new versions (https://github.com/hexpm/hexpm/issues/1124)
3. Add a better way to remember all the plugin added in Application to restore them.
```elixir
I will update this post , connect this to some pull requests
```
---
### Initial diagram
![mishka-plugin](https://user-images.githubusercontent.com/8413604/147889836-4e190ae1-6fe6-46e1-86f8-6401773e096d.png)
---
### Talks:
1. Start the proposal and the topic raised --> https://youtu.be/FPDxyX4RzZc (Persian)
4. Suggestion to bind dynamic supervisor form starting server --> https://elixirforum.com/t/45419
---
### Refs:
1. https://github.com/processone/ejabberd/blob/master/src/gen_mod.erl#L89-L92
3. https://hexdocs.pm/plug/Plug.Conn.html
5. https://www.ejabberd.im/
6. [How to add and install deps without stopping phoenix server (hex package)](https://elixirforum.com/t/how-to-add-and-install-deps-without-stopping-phoenix-server-hex-package/44888)
7. [How to create Ecto temporary tables for test a library](https://elixirforum.com/t/how-to-create-ecto-temporary-tables-for-test-a-library/44890)
8. [Need advice to implement custom extension and template installation in an elixir CMS](https://elixirforum.com/t/need-advice-to-implement-custom-extension-and-template-installation-in-an-elixir-cms/44863/)
9. [How to check a macro was called in a module](https://elixirforum.com/t/how-to-check-a-macro-was-called-in-a-module/44674)
10. https://docs.joomla.org/Plugin/Events
11. https://developer.wordpress.org/plugins/hooks/actions/
12. https://elixirforum.com/t/how-to-get-ecto-stream-respond-in-exunit/46138
13. https://elixirforum.com/t/genserver-doesnt-consider-ecto-sandbox/46105
14. https://elixirforum.com/t/dynamicsupervisor-terminate-genserver-state-in-transient-restart-method/45932/2
15. https://elixirforum.com/t/genserver-terminate-strategy-and-re-bind-data/45779
16. https://elixirforum.com/t/how-to-send-sandbox-allow-for-each-dynamic-supervisor-testing/46422/4
17. https://github.com/hexpm/hexpm/issues/1124
Yes you are right, I created some optional and Necessary @callbacks
1 Like