o-spreadsheet
o-spreadsheet copied to clipboard
[Dicussion]: Possible to use formula parser as a backend library?
I see a "formulas" folder in the code:
- is it possible to extract the formula parser logic as an "own package" or does it share dependencies with the rest of the application?
- would it be possible to use the formula parser for some backend only applications, without the need of a web browser frontend ?
Hello,
For now, the formula parser logic is linked to others parts of the application, such as the list/definitions of functions in order to compile their arguments. It would require a little work to extract completely the parser, but it's possible.
I didn't try but I think it would be possible to use o-spreadsheet for backend application. You can import helpers from o-spreadsheet
and use the parser from there.
i think i will give it a try. if it is just a matter of moving dependencies around (as in moving files and folders) then that should not be a problem, but if it depends on "owl", which is a frontend library, then it is not possible.
I understand that this is not the case, right ?
owl is a frontend library but can be used in the backend. While the App
of owl is not mounted
, it should be good.
makes sense. is there any good place (doc / code / type definitions) where you would advise getting started to understand the parser's logic ?
i would like to make an initial assessment whether it would make sense to run it as server-side module
Complementary information, we tried to install the library as a backend (full nodejs app) and it cannot run as it is. the data model is relying on the owl library as well, which simply cannot run on a nodejs server because it uses the web API. Sorry for misleading you. However, we are currently considering different approaches to make the lib backend-only asap.
In the meantime, the whole parsing logic is, as @pro-odoo mentioned, related to other parts of the code, but the main logic is in https://github.com/odoo/o-spreadsheet/blob/saas-16.2/src/formulas/parser.ts.
I think you could easily rebundle the parsing on your own by extracting that file and the imports it requires.
thanks for the reply. Is there any update on this matter ?
We have are not currently working on the possibility to make the lib run as a node application. As mentionned in my previous message, you can easily rebundle the parsing by yourself.
hi there, i come back to my question, and would like to know if it would be possible to run the formula parser in the frontend, but without the need of mounting the whole spreadsheet component.
i feel like this function should act as the "entrypoint" https://github.com/odoo/o-spreadsheet/blob/saas-17.3/src/formulas/parser.ts#L225 but then how could one inject additional formulas and additional plugins as described in: https://github.com/odoo/o-spreadsheet/blob/saas-17.3/doc/add_function.md ? would this be possible with the parser alone ?