diff --git a/.gitignore b/.gitignore index 8b93f97..35dfded 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,8 @@ target/ herovm_build/ test_db +.env + # Node.js **/node_modules/ **/dist/ diff --git a/acldb/Cargo.lock b/_archive/acldb/Cargo.lock similarity index 100% rename from acldb/Cargo.lock rename to _archive/acldb/Cargo.lock diff --git a/acldb/Cargo.toml b/_archive/acldb/Cargo.toml similarity index 100% rename from acldb/Cargo.toml rename to _archive/acldb/Cargo.toml diff --git a/acldb/README.md b/_archive/acldb/README.md similarity index 100% rename from acldb/README.md rename to _archive/acldb/README.md diff --git a/acldb/src/acl.rs b/_archive/acldb/src/acl.rs similarity index 100% rename from acldb/src/acl.rs rename to _archive/acldb/src/acl.rs diff --git a/acldb/src/error.rs b/_archive/acldb/src/error.rs similarity index 100% rename from acldb/src/error.rs rename to _archive/acldb/src/error.rs diff --git a/acldb/src/lib.rs b/_archive/acldb/src/lib.rs similarity index 100% rename from acldb/src/lib.rs rename to _archive/acldb/src/lib.rs diff --git a/acldb/src/main.rs b/_archive/acldb/src/main.rs similarity index 100% rename from acldb/src/main.rs rename to _archive/acldb/src/main.rs diff --git a/acldb/src/rpc.rs b/_archive/acldb/src/rpc.rs similarity index 100% rename from acldb/src/rpc.rs rename to _archive/acldb/src/rpc.rs diff --git a/acldb/src/server.rs b/_archive/acldb/src/server.rs similarity index 100% rename from acldb/src/server.rs rename to _archive/acldb/src/server.rs diff --git a/acldb/src/topic.rs b/_archive/acldb/src/topic.rs similarity index 100% rename from acldb/src/topic.rs rename to _archive/acldb/src/topic.rs diff --git a/acldb/src/utils.rs b/_archive/acldb/src/utils.rs similarity index 100% rename from acldb/src/utils.rs rename to _archive/acldb/src/utils.rs diff --git a/acldb/static/openapi.json b/_archive/acldb/static/openapi.json similarity index 100% rename from acldb/static/openapi.json rename to _archive/acldb/static/openapi.json diff --git a/acldb/static/swagger-ui.html b/_archive/acldb/static/swagger-ui.html similarity index 100% rename from acldb/static/swagger-ui.html rename to _archive/acldb/static/swagger-ui.html diff --git a/herodb_old/.gitignore b/_archive/herodb_old/.gitignore similarity index 100% rename from herodb_old/.gitignore rename to _archive/herodb_old/.gitignore diff --git a/herodb_old/Cargo.lock b/_archive/herodb_old/Cargo.lock similarity index 100% rename from herodb_old/Cargo.lock rename to _archive/herodb_old/Cargo.lock diff --git a/herodb_old/Cargo.toml b/_archive/herodb_old/Cargo.toml similarity index 100% rename from herodb_old/Cargo.toml rename to _archive/herodb_old/Cargo.toml diff --git a/herodb_old/README.md b/_archive/herodb_old/README.md similarity index 100% rename from herodb_old/README.md rename to _archive/herodb_old/README.md diff --git a/herodb_old/aiprompts/builderparadigm.md b/_archive/herodb_old/aiprompts/builderparadigm.md similarity index 100% rename from herodb_old/aiprompts/builderparadigm.md rename to _archive/herodb_old/aiprompts/builderparadigm.md diff --git a/herodb_old/aiprompts/moduledocu.md b/_archive/herodb_old/aiprompts/moduledocu.md similarity index 100% rename from herodb_old/aiprompts/moduledocu.md rename to _archive/herodb_old/aiprompts/moduledocu.md diff --git a/herodb_old/aiprompts/rhaiwrapping.md b/_archive/herodb_old/aiprompts/rhaiwrapping.md similarity index 100% rename from herodb_old/aiprompts/rhaiwrapping.md rename to _archive/herodb_old/aiprompts/rhaiwrapping.md diff --git a/herodb_old/aiprompts/rhaiwrapping_advanced.md b/_archive/herodb_old/aiprompts/rhaiwrapping_advanced.md similarity index 100% rename from herodb_old/aiprompts/rhaiwrapping_advanced.md rename to _archive/herodb_old/aiprompts/rhaiwrapping_advanced.md diff --git a/herodb_old/aiprompts/rhaiwrapping_best_practices.md b/_archive/herodb_old/aiprompts/rhaiwrapping_best_practices.md similarity index 100% rename from herodb_old/aiprompts/rhaiwrapping_best_practices.md rename to _archive/herodb_old/aiprompts/rhaiwrapping_best_practices.md diff --git a/herodb_old/examples/business_models_demo.rs b/_archive/herodb_old/examples/business_models_demo.rs similarity index 100% rename from herodb_old/examples/business_models_demo.rs rename to _archive/herodb_old/examples/business_models_demo.rs diff --git a/herodb_old/examples/circle_basic_demo.rs b/_archive/herodb_old/examples/circle_basic_demo.rs similarity index 100% rename from herodb_old/examples/circle_basic_demo.rs rename to _archive/herodb_old/examples/circle_basic_demo.rs diff --git a/herodb_old/examples/circle_models_demo.rs b/_archive/herodb_old/examples/circle_models_demo.rs similarity index 100% rename from herodb_old/examples/circle_models_demo.rs rename to _archive/herodb_old/examples/circle_models_demo.rs diff --git a/herodb_old/examples/circle_standalone.rs b/_archive/herodb_old/examples/circle_standalone.rs similarity index 100% rename from herodb_old/examples/circle_standalone.rs rename to _archive/herodb_old/examples/circle_standalone.rs diff --git a/herodb_old/examples/ourdb_example.rs b/_archive/herodb_old/examples/ourdb_example.rs similarity index 100% rename from herodb_old/examples/ourdb_example.rs rename to _archive/herodb_old/examples/ourdb_example.rs diff --git a/herodb_old/examples/tst_index_example.rs b/_archive/herodb_old/examples/tst_index_example.rs similarity index 100% rename from herodb_old/examples/tst_index_example.rs rename to _archive/herodb_old/examples/tst_index_example.rs diff --git a/herodb_old/src/cmd/dbexample_biz/README.md b/_archive/herodb_old/src/cmd/dbexample_biz/README.md similarity index 100% rename from herodb_old/src/cmd/dbexample_biz/README.md rename to _archive/herodb_old/src/cmd/dbexample_biz/README.md diff --git a/herodb_old/src/cmd/dbexample_biz/main.rs b/_archive/herodb_old/src/cmd/dbexample_biz/main.rs similarity index 100% rename from herodb_old/src/cmd/dbexample_biz/main.rs rename to _archive/herodb_old/src/cmd/dbexample_biz/main.rs diff --git a/herodb_old/src/cmd/dbexample_biz/mod.rs b/_archive/herodb_old/src/cmd/dbexample_biz/mod.rs similarity index 100% rename from herodb_old/src/cmd/dbexample_biz/mod.rs rename to _archive/herodb_old/src/cmd/dbexample_biz/mod.rs diff --git a/herodb_old/src/cmd/dbexample_gov/main.rs b/_archive/herodb_old/src/cmd/dbexample_gov/main.rs similarity index 100% rename from herodb_old/src/cmd/dbexample_gov/main.rs rename to _archive/herodb_old/src/cmd/dbexample_gov/main.rs diff --git a/herodb_old/src/cmd/dbexample_mcc/main.rs b/_archive/herodb_old/src/cmd/dbexample_mcc/main.rs similarity index 100% rename from herodb_old/src/cmd/dbexample_mcc/main.rs rename to _archive/herodb_old/src/cmd/dbexample_mcc/main.rs diff --git a/herodb_old/src/cmd/dbexample_prod/main.rs b/_archive/herodb_old/src/cmd/dbexample_prod/main.rs similarity index 100% rename from herodb_old/src/cmd/dbexample_prod/main.rs rename to _archive/herodb_old/src/cmd/dbexample_prod/main.rs diff --git a/herodb_old/src/cmd/mod.rs b/_archive/herodb_old/src/cmd/mod.rs similarity index 100% rename from herodb_old/src/cmd/mod.rs rename to _archive/herodb_old/src/cmd/mod.rs diff --git a/herodb_old/src/db/db.rs b/_archive/herodb_old/src/db/db.rs similarity index 100% rename from herodb_old/src/db/db.rs rename to _archive/herodb_old/src/db/db.rs diff --git a/herodb_old/src/db/error.rs b/_archive/herodb_old/src/db/error.rs similarity index 100% rename from herodb_old/src/db/error.rs rename to _archive/herodb_old/src/db/error.rs diff --git a/herodb_old/src/db/generic_store.rs b/_archive/herodb_old/src/db/generic_store.rs similarity index 100% rename from herodb_old/src/db/generic_store.rs rename to _archive/herodb_old/src/db/generic_store.rs diff --git a/herodb_old/src/db/macros.rs b/_archive/herodb_old/src/db/macros.rs similarity index 100% rename from herodb_old/src/db/macros.rs rename to _archive/herodb_old/src/db/macros.rs diff --git a/herodb_old/src/db/mod.rs b/_archive/herodb_old/src/db/mod.rs similarity index 100% rename from herodb_old/src/db/mod.rs rename to _archive/herodb_old/src/db/mod.rs diff --git a/herodb_old/src/db/model.rs b/_archive/herodb_old/src/db/model.rs similarity index 100% rename from herodb_old/src/db/model.rs rename to _archive/herodb_old/src/db/model.rs diff --git a/herodb_old/src/db/model_methods.rs b/_archive/herodb_old/src/db/model_methods.rs similarity index 100% rename from herodb_old/src/db/model_methods.rs rename to _archive/herodb_old/src/db/model_methods.rs diff --git a/herodb_old/src/db/store.rs b/_archive/herodb_old/src/db/store.rs similarity index 100% rename from herodb_old/src/db/store.rs rename to _archive/herodb_old/src/db/store.rs diff --git a/herodb_old/src/db/tests.rs b/_archive/herodb_old/src/db/tests.rs similarity index 100% rename from herodb_old/src/db/tests.rs rename to _archive/herodb_old/src/db/tests.rs diff --git a/herodb_old/src/db/tst_index.rs b/_archive/herodb_old/src/db/tst_index.rs similarity index 100% rename from herodb_old/src/db/tst_index.rs rename to _archive/herodb_old/src/db/tst_index.rs diff --git a/herodb_old/src/error.rs b/_archive/herodb_old/src/error.rs similarity index 100% rename from herodb_old/src/error.rs rename to _archive/herodb_old/src/error.rs diff --git a/herodb_old/src/instructions.md b/_archive/herodb_old/src/instructions.md similarity index 100% rename from herodb_old/src/instructions.md rename to _archive/herodb_old/src/instructions.md diff --git a/herodb_old/src/lib.rs b/_archive/herodb_old/src/lib.rs similarity index 100% rename from herodb_old/src/lib.rs rename to _archive/herodb_old/src/lib.rs diff --git a/herodb_old/src/mod.rs b/_archive/herodb_old/src/mod.rs similarity index 100% rename from herodb_old/src/mod.rs rename to _archive/herodb_old/src/mod.rs diff --git a/herodb_old/src/models/biz/README.md b/_archive/herodb_old/src/models/biz/README.md similarity index 100% rename from herodb_old/src/models/biz/README.md rename to _archive/herodb_old/src/models/biz/README.md diff --git a/herodb_old/src/models/biz/contract.rs b/_archive/herodb_old/src/models/biz/contract.rs similarity index 100% rename from herodb_old/src/models/biz/contract.rs rename to _archive/herodb_old/src/models/biz/contract.rs diff --git a/herodb_old/src/models/biz/currency.rs b/_archive/herodb_old/src/models/biz/currency.rs similarity index 100% rename from herodb_old/src/models/biz/currency.rs rename to _archive/herodb_old/src/models/biz/currency.rs diff --git a/herodb_old/src/models/biz/customer.rs b/_archive/herodb_old/src/models/biz/customer.rs similarity index 100% rename from herodb_old/src/models/biz/customer.rs rename to _archive/herodb_old/src/models/biz/customer.rs diff --git a/herodb_old/src/models/biz/exchange_rate.rs b/_archive/herodb_old/src/models/biz/exchange_rate.rs similarity index 100% rename from herodb_old/src/models/biz/exchange_rate.rs rename to _archive/herodb_old/src/models/biz/exchange_rate.rs diff --git a/herodb_old/src/models/biz/invoice.rs b/_archive/herodb_old/src/models/biz/invoice.rs similarity index 100% rename from herodb_old/src/models/biz/invoice.rs rename to _archive/herodb_old/src/models/biz/invoice.rs diff --git a/herodb_old/src/models/biz/lib.rs b/_archive/herodb_old/src/models/biz/lib.rs similarity index 100% rename from herodb_old/src/models/biz/lib.rs rename to _archive/herodb_old/src/models/biz/lib.rs diff --git a/herodb_old/src/models/biz/mod.rs b/_archive/herodb_old/src/models/biz/mod.rs similarity index 100% rename from herodb_old/src/models/biz/mod.rs rename to _archive/herodb_old/src/models/biz/mod.rs diff --git a/herodb_old/src/models/biz/product.rs b/_archive/herodb_old/src/models/biz/product.rs similarity index 100% rename from herodb_old/src/models/biz/product.rs rename to _archive/herodb_old/src/models/biz/product.rs diff --git a/herodb_old/src/models/biz/rhai/Cargo.lock b/_archive/herodb_old/src/models/biz/rhai/Cargo.lock similarity index 100% rename from herodb_old/src/models/biz/rhai/Cargo.lock rename to _archive/herodb_old/src/models/biz/rhai/Cargo.lock diff --git a/herodb_old/src/models/biz/rhai/Cargo.toml b/_archive/herodb_old/src/models/biz/rhai/Cargo.toml similarity index 100% rename from herodb_old/src/models/biz/rhai/Cargo.toml rename to _archive/herodb_old/src/models/biz/rhai/Cargo.toml diff --git a/herodb_old/src/models/biz/rhai/examples/example.rhai b/_archive/herodb_old/src/models/biz/rhai/examples/example.rhai similarity index 100% rename from herodb_old/src/models/biz/rhai/examples/example.rhai rename to _archive/herodb_old/src/models/biz/rhai/examples/example.rhai diff --git a/herodb_old/src/models/biz/rhai/examples/example.rs b/_archive/herodb_old/src/models/biz/rhai/examples/example.rs similarity index 100% rename from herodb_old/src/models/biz/rhai/examples/example.rs rename to _archive/herodb_old/src/models/biz/rhai/examples/example.rs diff --git a/herodb_old/src/models/biz/rhai/src/engine.rs b/_archive/herodb_old/src/models/biz/rhai/src/engine.rs similarity index 100% rename from herodb_old/src/models/biz/rhai/src/engine.rs rename to _archive/herodb_old/src/models/biz/rhai/src/engine.rs diff --git a/herodb_old/src/models/biz/rhai/src/generic_wrapper.rs b/_archive/herodb_old/src/models/biz/rhai/src/generic_wrapper.rs similarity index 100% rename from herodb_old/src/models/biz/rhai/src/generic_wrapper.rs rename to _archive/herodb_old/src/models/biz/rhai/src/generic_wrapper.rs diff --git a/herodb_old/src/models/biz/rhai/src/lib.rs b/_archive/herodb_old/src/models/biz/rhai/src/lib.rs similarity index 100% rename from herodb_old/src/models/biz/rhai/src/lib.rs rename to _archive/herodb_old/src/models/biz/rhai/src/lib.rs diff --git a/herodb_old/src/models/biz/rhai/src/wrapper.rs b/_archive/herodb_old/src/models/biz/rhai/src/wrapper.rs similarity index 100% rename from herodb_old/src/models/biz/rhai/src/wrapper.rs rename to _archive/herodb_old/src/models/biz/rhai/src/wrapper.rs diff --git a/herodb_old/src/models/biz/sale.rs b/_archive/herodb_old/src/models/biz/sale.rs similarity index 100% rename from herodb_old/src/models/biz/sale.rs rename to _archive/herodb_old/src/models/biz/sale.rs diff --git a/herodb_old/src/models/biz/service.rs b/_archive/herodb_old/src/models/biz/service.rs similarity index 100% rename from herodb_old/src/models/biz/service.rs rename to _archive/herodb_old/src/models/biz/service.rs diff --git a/herodb_old/src/models/circle/README.md b/_archive/herodb_old/src/models/circle/README.md similarity index 100% rename from herodb_old/src/models/circle/README.md rename to _archive/herodb_old/src/models/circle/README.md diff --git a/herodb_old/src/models/circle/circle.rs b/_archive/herodb_old/src/models/circle/circle.rs similarity index 100% rename from herodb_old/src/models/circle/circle.rs rename to _archive/herodb_old/src/models/circle/circle.rs diff --git a/herodb_old/src/models/circle/lib.rs b/_archive/herodb_old/src/models/circle/lib.rs similarity index 100% rename from herodb_old/src/models/circle/lib.rs rename to _archive/herodb_old/src/models/circle/lib.rs diff --git a/herodb_old/src/models/circle/member.rs b/_archive/herodb_old/src/models/circle/member.rs similarity index 100% rename from herodb_old/src/models/circle/member.rs rename to _archive/herodb_old/src/models/circle/member.rs diff --git a/herodb_old/src/models/circle/mod.rs b/_archive/herodb_old/src/models/circle/mod.rs similarity index 100% rename from herodb_old/src/models/circle/mod.rs rename to _archive/herodb_old/src/models/circle/mod.rs diff --git a/herodb_old/src/models/circle/name.rs b/_archive/herodb_old/src/models/circle/name.rs similarity index 100% rename from herodb_old/src/models/circle/name.rs rename to _archive/herodb_old/src/models/circle/name.rs diff --git a/herodb_old/src/models/circle/wallet.rs b/_archive/herodb_old/src/models/circle/wallet.rs similarity index 100% rename from herodb_old/src/models/circle/wallet.rs rename to _archive/herodb_old/src/models/circle/wallet.rs diff --git a/herodb_old/src/models/gov/README.md b/_archive/herodb_old/src/models/gov/README.md similarity index 100% rename from herodb_old/src/models/gov/README.md rename to _archive/herodb_old/src/models/gov/README.md diff --git a/herodb_old/src/models/gov/committee.rs b/_archive/herodb_old/src/models/gov/committee.rs similarity index 100% rename from herodb_old/src/models/gov/committee.rs rename to _archive/herodb_old/src/models/gov/committee.rs diff --git a/herodb_old/src/models/gov/company.rs b/_archive/herodb_old/src/models/gov/company.rs similarity index 100% rename from herodb_old/src/models/gov/company.rs rename to _archive/herodb_old/src/models/gov/company.rs diff --git a/herodb_old/src/models/gov/meeting.rs b/_archive/herodb_old/src/models/gov/meeting.rs similarity index 100% rename from herodb_old/src/models/gov/meeting.rs rename to _archive/herodb_old/src/models/gov/meeting.rs diff --git a/herodb_old/src/models/gov/mod.rs b/_archive/herodb_old/src/models/gov/mod.rs similarity index 100% rename from herodb_old/src/models/gov/mod.rs rename to _archive/herodb_old/src/models/gov/mod.rs diff --git a/herodb_old/src/models/gov/resolution.rs b/_archive/herodb_old/src/models/gov/resolution.rs similarity index 100% rename from herodb_old/src/models/gov/resolution.rs rename to _archive/herodb_old/src/models/gov/resolution.rs diff --git a/herodb_old/src/models/gov/shareholder.rs b/_archive/herodb_old/src/models/gov/shareholder.rs similarity index 100% rename from herodb_old/src/models/gov/shareholder.rs rename to _archive/herodb_old/src/models/gov/shareholder.rs diff --git a/herodb_old/src/models/gov/user.rs b/_archive/herodb_old/src/models/gov/user.rs similarity index 100% rename from herodb_old/src/models/gov/user.rs rename to _archive/herodb_old/src/models/gov/user.rs diff --git a/herodb_old/src/models/gov/vote.rs b/_archive/herodb_old/src/models/gov/vote.rs similarity index 100% rename from herodb_old/src/models/gov/vote.rs rename to _archive/herodb_old/src/models/gov/vote.rs diff --git a/herodb_old/src/models/instructions.md b/_archive/herodb_old/src/models/instructions.md similarity index 100% rename from herodb_old/src/models/instructions.md rename to _archive/herodb_old/src/models/instructions.md diff --git a/herodb_old/src/models/mcc/README.md b/_archive/herodb_old/src/models/mcc/README.md similarity index 100% rename from herodb_old/src/models/mcc/README.md rename to _archive/herodb_old/src/models/mcc/README.md diff --git a/herodb_old/src/models/mcc/calendar.rs b/_archive/herodb_old/src/models/mcc/calendar.rs similarity index 100% rename from herodb_old/src/models/mcc/calendar.rs rename to _archive/herodb_old/src/models/mcc/calendar.rs diff --git a/herodb_old/src/models/mcc/contacts.rs b/_archive/herodb_old/src/models/mcc/contacts.rs similarity index 100% rename from herodb_old/src/models/mcc/contacts.rs rename to _archive/herodb_old/src/models/mcc/contacts.rs diff --git a/herodb_old/src/models/mcc/event.rs b/_archive/herodb_old/src/models/mcc/event.rs similarity index 100% rename from herodb_old/src/models/mcc/event.rs rename to _archive/herodb_old/src/models/mcc/event.rs diff --git a/herodb_old/src/models/mcc/lib.rs b/_archive/herodb_old/src/models/mcc/lib.rs similarity index 100% rename from herodb_old/src/models/mcc/lib.rs rename to _archive/herodb_old/src/models/mcc/lib.rs diff --git a/herodb_old/src/models/mcc/mail.rs b/_archive/herodb_old/src/models/mcc/mail.rs similarity index 100% rename from herodb_old/src/models/mcc/mail.rs rename to _archive/herodb_old/src/models/mcc/mail.rs diff --git a/herodb_old/src/models/mcc/message.rs b/_archive/herodb_old/src/models/mcc/message.rs similarity index 100% rename from herodb_old/src/models/mcc/message.rs rename to _archive/herodb_old/src/models/mcc/message.rs diff --git a/herodb_old/src/models/mcc/mod.rs b/_archive/herodb_old/src/models/mcc/mod.rs similarity index 100% rename from herodb_old/src/models/mcc/mod.rs rename to _archive/herodb_old/src/models/mcc/mod.rs diff --git a/herodb_old/src/models/mod.rs b/_archive/herodb_old/src/models/mod.rs similarity index 100% rename from herodb_old/src/models/mod.rs rename to _archive/herodb_old/src/models/mod.rs diff --git a/herodb_old/src/models/py/README.md b/_archive/herodb_old/src/models/py/README.md similarity index 100% rename from herodb_old/src/models/py/README.md rename to _archive/herodb_old/src/models/py/README.md diff --git a/herodb_old/src/models/py/__init__.py b/_archive/herodb_old/src/models/py/__init__.py similarity index 100% rename from herodb_old/src/models/py/__init__.py rename to _archive/herodb_old/src/models/py/__init__.py diff --git a/herodb_old/src/models/py/__pycache__/api.cpython-312.pyc b/_archive/herodb_old/src/models/py/__pycache__/api.cpython-312.pyc similarity index 100% rename from herodb_old/src/models/py/__pycache__/api.cpython-312.pyc rename to _archive/herodb_old/src/models/py/__pycache__/api.cpython-312.pyc diff --git a/herodb_old/src/models/py/__pycache__/models.cpython-312.pyc b/_archive/herodb_old/src/models/py/__pycache__/models.cpython-312.pyc similarity index 100% rename from herodb_old/src/models/py/__pycache__/models.cpython-312.pyc rename to _archive/herodb_old/src/models/py/__pycache__/models.cpython-312.pyc diff --git a/herodb_old/src/models/py/api.py b/_archive/herodb_old/src/models/py/api.py similarity index 100% rename from herodb_old/src/models/py/api.py rename to _archive/herodb_old/src/models/py/api.py diff --git a/herodb_old/src/models/py/business.db b/_archive/herodb_old/src/models/py/business.db similarity index 100% rename from herodb_old/src/models/py/business.db rename to _archive/herodb_old/src/models/py/business.db diff --git a/herodb_old/src/models/py/example.py b/_archive/herodb_old/src/models/py/example.py similarity index 100% rename from herodb_old/src/models/py/example.py rename to _archive/herodb_old/src/models/py/example.py diff --git a/herodb_old/src/models/py/install_and_run.sh b/_archive/herodb_old/src/models/py/install_and_run.sh similarity index 100% rename from herodb_old/src/models/py/install_and_run.sh rename to _archive/herodb_old/src/models/py/install_and_run.sh diff --git a/herodb_old/src/models/py/models.py b/_archive/herodb_old/src/models/py/models.py similarity index 100% rename from herodb_old/src/models/py/models.py rename to _archive/herodb_old/src/models/py/models.py diff --git a/herodb_old/src/models/py/server.sh b/_archive/herodb_old/src/models/py/server.sh similarity index 100% rename from herodb_old/src/models/py/server.sh rename to _archive/herodb_old/src/models/py/server.sh diff --git a/herodb_old/src/rhaiengine/engine.rs b/_archive/herodb_old/src/rhaiengine/engine.rs similarity index 100% rename from herodb_old/src/rhaiengine/engine.rs rename to _archive/herodb_old/src/rhaiengine/engine.rs diff --git a/herodb_old/src/rhaiengine/mod.rs b/_archive/herodb_old/src/rhaiengine/mod.rs similarity index 100% rename from herodb_old/src/rhaiengine/mod.rs rename to _archive/herodb_old/src/rhaiengine/mod.rs diff --git a/instructions.md b/_archive/instructions.md similarity index 100% rename from instructions.md rename to _archive/instructions.md diff --git a/websocket/architecture.md b/_archive/websocket/architecture.md similarity index 100% rename from websocket/architecture.md rename to _archive/websocket/architecture.md diff --git a/heromodels/.DS_Store b/heromodels/.DS_Store index f4f8c5d..f707310 100644 Binary files a/heromodels/.DS_Store and b/heromodels/.DS_Store differ diff --git a/heromodels/data/0.db b/heromodels/data/0.db deleted file mode 100644 index 531af47..0000000 Binary files a/heromodels/data/0.db and /dev/null differ diff --git a/heromodels/data/lookup/data b/heromodels/data/lookup/data deleted file mode 100644 index bdcc1ae..0000000 Binary files a/heromodels/data/lookup/data and /dev/null differ diff --git a/herodb_ourdb_migration_plan.md b/heromodels/docs/herodb_ourdb_migration_plan.md similarity index 100% rename from herodb_ourdb_migration_plan.md rename to heromodels/docs/herodb_ourdb_migration_plan.md diff --git a/mcc_models_standalone_plan.md b/heromodels/docs/mcc_models_standalone_plan.md similarity index 100% rename from mcc_models_standalone_plan.md rename to heromodels/docs/mcc_models_standalone_plan.md diff --git a/model_trait_unification_plan.md b/heromodels/docs/model_trait_unification_plan.md similarity index 100% rename from model_trait_unification_plan.md rename to heromodels/docs/model_trait_unification_plan.md diff --git a/heromodels/payment_usage.md b/heromodels/docs/payment_usage.md similarity index 100% rename from heromodels/payment_usage.md rename to heromodels/docs/payment_usage.md diff --git a/prompts/new_rhai_rs_gen.md b/heromodels/docs/prompts/new_rhai_rs_gen.md similarity index 100% rename from prompts/new_rhai_rs_gen.md rename to heromodels/docs/prompts/new_rhai_rs_gen.md diff --git a/prompts/rhai_rs_generation_prompt.md b/heromodels/docs/prompts/rhai_rs_generation_prompt.md similarity index 100% rename from prompts/rhai_rs_generation_prompt.md rename to heromodels/docs/prompts/rhai_rs_generation_prompt.md diff --git a/sigsocket_architecture.md b/heromodels/docs/sigsocket_architecture.md similarity index 100% rename from sigsocket_architecture.md rename to heromodels/docs/sigsocket_architecture.md diff --git a/tst_implementation_plan.md b/heromodels/docs/tst_implementation_plan.md similarity index 100% rename from tst_implementation_plan.md rename to heromodels/docs/tst_implementation_plan.md diff --git a/tst_integration_plan.md b/heromodels/docs/tst_integration_plan.md similarity index 100% rename from tst_integration_plan.md rename to heromodels/docs/tst_integration_plan.md diff --git a/heromodels/examples/marketplace_example.rs b/heromodels/examples/marketplace_example.rs index f60c087..cf5f952 100644 --- a/heromodels/examples/marketplace_example.rs +++ b/heromodels/examples/marketplace_example.rs @@ -1,7 +1,7 @@ use chrono::{Duration, Utc}; use heromodels::db::{Collection, Db}; -use heromodels::models::finance::marketplace::{Bid, Listing, ListingType}; use heromodels::models::finance::asset::AssetType; +use heromodels::models::finance::marketplace::{Bid, Listing, ListingType}; use heromodels_core::Model; // Helper function to print listing details @@ -16,32 +16,32 @@ fn print_listing_details(listing: &Listing) { println!("Price: {} {}", listing.price, listing.currency); println!("Listing Type: {:?}", listing.listing_type); println!("Status: {:?}", listing.status); - + if let Some(expires_at) = listing.expires_at { println!("Expires At: {}", expires_at); } else { println!("Expires At: Never"); } - + if let Some(sold_at) = listing.sold_at { println!("Sold At: {}", sold_at); } - + if let Some(buyer_id) = &listing.buyer_id { println!("Buyer ID: {}", buyer_id); } - + if let Some(sale_price) = listing.sale_price { println!("Sale Price: {} {}", sale_price, listing.currency); } - + println!("Bids: {}", listing.bids.len()); println!("Tags: {:?}", listing.tags); - + if let Some(image_url) = &listing.image_url { println!("Image URL: {}", image_url); } - + println!("Created At: {}", listing.base_data.created_at); println!("Modified At: {}", listing.base_data.modified_at); } @@ -77,7 +77,11 @@ fn main() { "USD", ListingType::FixedPrice, Some(Utc::now() + Duration::days(30)), // Expires in 30 days - vec!["music".to_string(), "instrument".to_string(), "vintage".to_string()], + vec![ + "music".to_string(), + "instrument".to_string(), + "vintage".to_string(), + ], Some("https://example.com/images/vintage_guitar.jpg"), ); @@ -93,7 +97,11 @@ fn main() { "USD", ListingType::Auction, Some(Utc::now() + Duration::days(7)), // Auction ends in 7 days - vec!["art".to_string(), "painting".to_string(), "antique".to_string()], + vec![ + "art".to_string(), + "painting".to_string(), + "antique".to_string(), + ], Some("https://example.com/images/rare_painting.jpg"), ); @@ -114,9 +122,21 @@ fn main() { ); // Save all listings to database and get their assigned IDs and updated models - let (fixed_price_id, db_fixed_price) = db.collection().expect("can open listing collection").set(&fixed_price_listing).expect("can set listing"); - let (auction_id, db_auction) = db.collection().expect("can open listing collection").set(&auction_listing).expect("can set listing"); - let (exchange_id, db_exchange) = db.collection().expect("can open listing collection").set(&exchange_listing).expect("can set listing"); + let (fixed_price_id, db_fixed_price) = db + .collection() + .expect("can open listing collection") + .set(&fixed_price_listing) + .expect("can set listing"); + let (auction_id, db_auction) = db + .collection() + .expect("can open listing collection") + .set(&auction_listing) + .expect("can set listing"); + let (exchange_id, db_exchange) = db + .collection() + .expect("can open listing collection") + .set(&exchange_listing) + .expect("can set listing"); println!("Fixed Price Listing assigned ID: {}", fixed_price_id); println!("Auction Listing assigned ID: {}", auction_id); @@ -138,17 +158,13 @@ fn main() { // Create bids for the auction listing let bid1 = Bid::new( - auction_id, - 101, // Bidder ID - 5200.0, - "USD", + auction_id, 101, // Bidder ID + 5200.0, "USD", ); let bid2 = Bid::new( - auction_id, - 102, // Bidder ID - 5500.0, - "USD", + auction_id, 102, // Bidder ID + 5500.0, "USD", ); // Print the bids @@ -166,7 +182,8 @@ fn main() { .expect("can add second bid"); // Save the updated auction listing - let (_, db_updated_auction) = db.collection() + let (_, db_updated_auction) = db + .collection() .expect("can open listing collection") .set(&updated_auction) .expect("can set updated auction"); @@ -189,7 +206,8 @@ fn main() { .expect("can complete sale"); // Save the updated listing - let (_, db_completed_fixed_price) = db.collection() + let (_, db_completed_fixed_price) = db + .collection() .expect("can open listing collection") .set(&completed_fixed_price) .expect("can set completed listing"); @@ -204,14 +222,15 @@ fn main() { // Store the bidder_id and amount before moving db_updated_auction let bidder_id = db_updated_auction.highest_bid().unwrap().bidder_id; let amount = db_updated_auction.highest_bid().unwrap().amount; - + // Now complete the sale let completed_auction = db_updated_auction .complete_sale(bidder_id.to_string(), amount) .expect("can complete auction"); // Save the updated auction listing - let (_, db_completed_auction) = db.collection() + let (_, db_completed_auction) = db + .collection() .expect("can open listing collection") .set(&completed_auction) .expect("can set completed auction"); @@ -223,12 +242,11 @@ fn main() { println!("\n--- Cancelling a Listing ---"); // Cancel the exchange listing - let cancelled_exchange = db_exchange - .cancel() - .expect("can cancel listing"); + let cancelled_exchange = db_exchange.cancel().expect("can cancel listing"); // Save the updated listing - let (_, db_cancelled_exchange) = db.collection() + let (_, db_cancelled_exchange) = db + .collection() .expect("can open listing collection") .set(&cancelled_exchange) .expect("can set cancelled listing"); @@ -256,7 +274,8 @@ fn main() { ); // Save the expired listing - let (expired_id, db_expired) = db.collection() + let (expired_id, db_expired) = db + .collection() .expect("can open listing collection") .set(&expired_listing) .expect("can set expired listing"); @@ -267,7 +286,8 @@ fn main() { let checked_expired = db_expired.check_expiration(); // Save the checked listing - let (_, db_checked_expired) = db.collection() + let (_, db_checked_expired) = db + .collection() .expect("can open listing collection") .set(&checked_expired) .expect("can set checked listing"); @@ -295,7 +315,8 @@ fn main() { ); // Save the listing - let (update_id, db_to_update) = db.collection() + let (update_id, db_to_update) = db + .collection() .expect("can open listing collection") .set(&listing_to_update) .expect("can set listing to update"); @@ -315,7 +336,8 @@ fn main() { .add_tags(vec!["updated".to_string(), "premium".to_string()]); // Save the updated listing - let (_, db_updated_listing) = db.collection() + let (_, db_updated_listing) = db + .collection() .expect("can open listing collection") .set(&updated_listing) .expect("can set updated listing"); diff --git a/heromodels/examples/test_reminder_functionality.rs b/heromodels/examples/test_reminder_functionality.rs index b4954fd..d416658 100644 --- a/heromodels/examples/test_reminder_functionality.rs +++ b/heromodels/examples/test_reminder_functionality.rs @@ -19,7 +19,7 @@ fn main() { "Test User".to_string(), "test@example.com".to_string(), ); - + println!(" Signer created: {}", signer.name); println!(" Last reminder: {:?}", signer.last_reminder_mail_sent_at); assert_eq!(signer.last_reminder_mail_sent_at, None); @@ -44,7 +44,10 @@ fn main() { println!("Test 4: Mark reminder as sent"); signer.mark_reminder_sent(current_time); println!(" Reminder marked as sent at: {}", current_time); - println!(" Last reminder timestamp: {:?}", signer.last_reminder_mail_sent_at); + println!( + " Last reminder timestamp: {:?}", + signer.last_reminder_mail_sent_at + ); assert_eq!(signer.last_reminder_mail_sent_at, Some(current_time)); println!(" ✓ Reminder timestamp updated correctly\n"); @@ -86,9 +89,15 @@ fn main() { .comments("Test signer with reminder"); println!(" Signer: {}", signer_with_reminder.name); - println!(" Last reminder: {:?}", signer_with_reminder.last_reminder_mail_sent_at); - println!(" Can send reminder: {}", signer_with_reminder.can_send_reminder(current_time)); - + println!( + " Last reminder: {:?}", + signer_with_reminder.last_reminder_mail_sent_at + ); + println!( + " Can send reminder: {}", + signer_with_reminder.can_send_reminder(current_time) + ); + let remaining = signer_with_reminder.reminder_cooldown_remaining(current_time); println!(" Cooldown remaining: {:?} seconds", remaining); assert_eq!(remaining, Some(10 * 60)); // 10 minutes remaining @@ -97,8 +106,14 @@ fn main() { // Test 9: Test clear reminder timestamp println!("Test 9: Clear reminder timestamp"); let cleared_signer = signer_with_reminder.clear_last_reminder_mail_sent_at(); - println!(" Last reminder after clear: {:?}", cleared_signer.last_reminder_mail_sent_at); - println!(" Can send reminder: {}", cleared_signer.can_send_reminder(current_time)); + println!( + " Last reminder after clear: {:?}", + cleared_signer.last_reminder_mail_sent_at + ); + println!( + " Can send reminder: {}", + cleared_signer.can_send_reminder(current_time) + ); assert_eq!(cleared_signer.last_reminder_mail_sent_at, None); assert!(cleared_signer.can_send_reminder(current_time)); println!(" ✓ Clear reminder timestamp works correctly\n"); diff --git a/heromodels/examples/test_signature_functionality.rs b/heromodels/examples/test_signature_functionality.rs index 49ef5aa..a355fe3 100644 --- a/heromodels/examples/test_signature_functionality.rs +++ b/heromodels/examples/test_signature_functionality.rs @@ -11,7 +11,7 @@ fn main() { "Test User".to_string(), "test@example.com".to_string(), ); - + println!(" Signer created: {}", signer.name); println!(" Status: {:?}", signer.status); println!(" Signature data: {:?}", signer.signature_data); @@ -23,14 +23,17 @@ fn main() { println!("Test 2: Sign with signature data"); let signature_data = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==".to_string(); let comments = "I agree to all terms and conditions.".to_string(); - + signer.sign(Some(signature_data.clone()), Some(comments.clone())); - + println!(" Status after signing: {:?}", signer.status); println!(" Signed at: {:?}", signer.signed_at); println!(" Comments: {:?}", signer.comments); - println!(" Signature data length: {}", signer.signature_data.as_ref().unwrap().len()); - + println!( + " Signature data length: {}", + signer.signature_data.as_ref().unwrap().len() + ); + assert_eq!(signer.status, SignerStatus::Signed); assert!(signer.signed_at.is_some()); assert_eq!(signer.signature_data, Some(signature_data)); @@ -44,13 +47,16 @@ fn main() { "Test User 2".to_string(), "test2@example.com".to_string(), ); - - signer2.sign(None, Some("Electronic signature without visual data".to_string())); - + + signer2.sign( + None, + Some("Electronic signature without visual data".to_string()), + ); + println!(" Status: {:?}", signer2.status); println!(" Signature data: {:?}", signer2.signature_data); println!(" Comments: {:?}", signer2.comments); - + assert_eq!(signer2.status, SignerStatus::Signed); assert_eq!(signer2.signature_data, None); assert!(signer2.comments.is_some()); @@ -63,13 +69,13 @@ fn main() { "Test User 3".to_string(), "test3@example.com".to_string(), ); - + signer3.sign(None, None); - + println!(" Status: {:?}", signer3.status); println!(" Signature data: {:?}", signer3.signature_data); println!(" Comments: {:?}", signer3.comments); - + assert_eq!(signer3.status, SignerStatus::Signed); assert_eq!(signer3.signature_data, None); assert_eq!(signer3.comments, None); @@ -88,16 +94,25 @@ fn main() { println!(" Signer: {}", signer_with_signature.name); println!(" Status: {:?}", signer_with_signature.status); - println!(" Signature data: {:?}", signer_with_signature.signature_data); + println!( + " Signature data: {:?}", + signer_with_signature.signature_data + ); println!(" Comments: {:?}", signer_with_signature.comments); - - assert_eq!(signer_with_signature.signature_data, Some("data:image/png;base64,example".to_string())); + + assert_eq!( + signer_with_signature.signature_data, + Some("data:image/png;base64,example".to_string()) + ); println!(" ✓ Builder pattern with signature data works correctly\n"); // Test 6: Clear signature data println!("Test 6: Clear signature data"); let cleared_signer = signer_with_signature.clear_signature_data(); - println!(" Signature data after clear: {:?}", cleared_signer.signature_data); + println!( + " Signature data after clear: {:?}", + cleared_signer.signature_data + ); assert_eq!(cleared_signer.signature_data, None); println!(" ✓ Clear signature data works correctly\n"); @@ -114,14 +129,24 @@ fn main() { // Serialize to JSON let json = serde_json::to_string(&original_signer).expect("Failed to serialize"); println!(" Serialized JSON length: {} characters", json.len()); - + // Deserialize from JSON - let deserialized_signer: ContractSigner = serde_json::from_str(&json).expect("Failed to deserialize"); - - println!(" Original signature data: {:?}", original_signer.signature_data); - println!(" Deserialized signature data: {:?}", deserialized_signer.signature_data); - - assert_eq!(original_signer.signature_data, deserialized_signer.signature_data); + let deserialized_signer: ContractSigner = + serde_json::from_str(&json).expect("Failed to deserialize"); + + println!( + " Original signature data: {:?}", + original_signer.signature_data + ); + println!( + " Deserialized signature data: {:?}", + deserialized_signer.signature_data + ); + + assert_eq!( + original_signer.signature_data, + deserialized_signer.signature_data + ); assert_eq!(original_signer.name, deserialized_signer.name); assert_eq!(original_signer.email, deserialized_signer.email); println!(" ✓ Serialization/Deserialization works correctly\n"); @@ -138,17 +163,21 @@ fn main() { "comments": null, "last_reminder_mail_sent_at": null }"#; - - let old_signer: ContractSigner = serde_json::from_str(old_json).expect("Failed to deserialize old format"); + + let old_signer: ContractSigner = + serde_json::from_str(old_json).expect("Failed to deserialize old format"); println!(" Old signer name: {}", old_signer.name); - println!(" Old signer signature data: {:?}", old_signer.signature_data); - + println!( + " Old signer signature data: {:?}", + old_signer.signature_data + ); + assert_eq!(old_signer.signature_data, None); println!(" ✓ Backward compatibility works correctly\n"); println!("All tests passed! ✅"); println!("ContractSigner signature functionality is working correctly."); - + // Summary println!("\n📋 Summary of Features Tested:"); println!(" ✅ New signer creation (signature_data: None)"); diff --git a/heromodels/expanded_calendar_example.rs b/heromodels/expanded_calendar_example.rs deleted file mode 100644 index e69de29..0000000 diff --git a/heromodels/index/0.db b/heromodels/index/0.db deleted file mode 100644 index 7f8214c..0000000 Binary files a/heromodels/index/0.db and /dev/null differ diff --git a/heromodels/index/lookup/.inc b/heromodels/index/lookup/.inc deleted file mode 100644 index 0aeb548..0000000 --- a/heromodels/index/lookup/.inc +++ /dev/null @@ -1 +0,0 @@ -74 \ No newline at end of file diff --git a/heromodels/index/lookup/data b/heromodels/index/lookup/data deleted file mode 100644 index 708d4df..0000000 Binary files a/heromodels/index/lookup/data and /dev/null differ diff --git a/heromodels/src/db/hero.rs b/heromodels/src/db/hero.rs index 4aefc14..61beb2f 100644 --- a/heromodels/src/db/hero.rs +++ b/heromodels/src/db/hero.rs @@ -323,16 +323,6 @@ where assigned_id }; - // Always create a primary key index entry for this model type - // This ensures get_all() can find all objects of this type, even if they have no explicit indexed fields - let primary_index_key = format!("{}::primary", M::db_prefix()); - let mut primary_ids: HashSet = - Self::get_tst_value(&mut index_db, &primary_index_key)? - .unwrap_or_else(HashSet::new); - primary_ids.insert(assigned_id); - let raw_primary_ids = bincode::serde::encode_to_vec(&primary_ids, BINCODE_CONFIG)?; - index_db.set(&primary_index_key, raw_primary_ids)?; - // Now add the new indices for index_key in indices_to_add { let key = Self::index_key(M::db_prefix(), index_key.name, &index_key.value); @@ -430,22 +420,6 @@ where } } - // Also remove from the primary key index - let primary_index_key = format!("{}::primary", M::db_prefix()); - if let Some(mut primary_ids) = - Self::get_tst_value::>(&mut index_db, &primary_index_key)? - { - primary_ids.remove(&id); - if primary_ids.is_empty() { - // This was the last object of this type, remove the primary index entirely - index_db.delete(&primary_index_key)?; - } else { - // There are still other objects of this type, write back updated set - let raw_primary_ids = bincode::serde::encode_to_vec(&primary_ids, BINCODE_CONFIG)?; - index_db.set(&primary_index_key, raw_primary_ids)?; - } - } - // Finally delete the object itself Ok(data_db.delete(id)?) } @@ -476,7 +450,18 @@ where } } } - }; + } + Err(tst::Error::PrefixNotFound(_)) => { + // No index entries found for this prefix, meaning no objects of this type exist. + // Note: tst::getall might return Ok(vec![]) in this case instead of PrefixNotFound. + // Depending on tst implementation, this arm might be redundant if getall returns empty vec. + return Ok(Vec::new()); + } + Err(e) => { + // Other TST errors. + return Err(super::Error::DB(e)); + } + } let mut results: Vec = Vec::with_capacity(all_object_ids.len()); for obj_id in all_object_ids { diff --git a/heromodels/src/models/access/README.md b/heromodels/src/models/access/README.md new file mode 100644 index 0000000..47858f8 --- /dev/null +++ b/heromodels/src/models/access/README.md @@ -0,0 +1,65 @@ +# Access Control Model + +The `access` model provides a system for managing permissions, defining which users or groups can access specific resources (objects) within the application. + +## `Access` Struct + +The core of this module is the `Access` struct, which acts as an Access Control Entry (ACE). It creates a link between a resource and an entity being granted permission. + +### Fields + +- `base_data`: Standard `BaseModelData` for a unique ID and timestamps. +- `object_type`: A `String` identifying the type of the resource (e.g., `"Project"`, `"Document"`). +- `object_id`: The `u32` unique ID of the resource instance. +- `circle_pk`: The public key (`String`) of the user or entity being granted access. +- `contact_id`: The ID of a `Contact` being granted access. +- `group_id`: The ID of a `Group` being granted access. +- `expires_at`: An optional `u64` timestamp for when the access grant expires. + +All key fields are indexed for efficient lookups. + +## Core Functions + +The module provides functions to check permissions based on the created `Access` records. + +- `can_access_resource(db, public_key, object_id, object_type) -> bool`: + This is the primary function for permission checking. It determines if a user, identified by their `public_key`, can access a given object. The current logic is as follows: + 1. It first checks if the `public_key` belongs to a member of a globally defined `Circle`. If so, access is granted (this acts as a super-admin or owner role). + 2. If the user is not a global member, it queries for all `Access` records associated with the `object_id`. + 3. It returns `true` if it finds any `Access` record where the `circle_pk` matches the user's `public_key`. + +- `is_circle_member(db, public_key) -> bool`: + A helper function that checks if a user is part of the global `Circle`, effectively checking for super-admin privileges. + +## Usage Example + +Here is a conceptual walkthrough of how to grant and check access: + +1. **A resource is created**, for example, a `Project` with ID `789`. + +2. **To grant access** to a user with the public key `"pubkey_of_user_b"`, you create an `Access` record: + + ```rust + use heromodels::models::access::Access; + + let access_grant = Access::new() + .object_type("Project".to_string()) + .object_id(789) + .circle_pk("pubkey_of_user_b".to_string()); + + // This record would then be saved to the database. + ``` + +3. **To check access**, when `user_b` attempts to view the project, the application would call `can_access_resource`: + + ```rust + // let can_access = can_access_resource( + // db_connection, + // "pubkey_of_user_b", + // 789, + // "Project" + // ); + // assert!(can_access); + ``` + +This system allows for flexible, object-by-object permission management. diff --git a/heromodels/src/models/access/access.rs b/heromodels/src/models/access/access.rs index f374269..16fd63e 100644 --- a/heromodels/src/models/access/access.rs +++ b/heromodels/src/models/access/access.rs @@ -1,8 +1,8 @@ -use std::sync::Arc; +use crate::db::{Collection, Db, hero::OurDB}; use crate::models::Circle; -use crate::db::{hero::OurDB, Collection, Db}; use heromodels_core::BaseModelData; use heromodels_derive::model; +use std::sync::Arc; // Temporarily removed to fix compilation issues // use rhai_autobind_macros::rhai_model_export; use rhai::{CustomType, TypeBuilder}; @@ -71,17 +71,16 @@ impl Access { } } - /// Checks if a caller has permission to access a specific resource. /// Access is granted if the caller is a super admin or if an `Access` record exists /// granting them `can_access = true` for the given resource type and ID. -/// +/// /// # Arguments /// * `db`: An `Arc` for database interaction. /// * `public_key`: The public key of the caller. /// * `_resource_id_to_check`: The ID of the resource being accessed (now unused). /// * `_resource_type_to_check`: The type of the resource (e.g., "Collection", "Image") (now unused). -/// +/// /// # Errors /// Returns `Err(EvalAltResult::ErrorRuntime)` if there's a database error during the check. pub fn can_access_resource( @@ -94,7 +93,8 @@ pub fn can_access_resource( .collection::() .expect("Failed to get Circle collection") .get_all() - .unwrap()[0].clone(); + .unwrap()[0] + .clone(); // Circle members can access everything if circle.members.contains(&public_key.to_string()) { @@ -121,18 +121,18 @@ pub fn can_access_resource( println!("Access records: {:#?}", access_records); // if circle_pk is in access records true - return access_records.iter().any(|record| record.circle_pk == public_key) + return access_records + .iter() + .any(|record| record.circle_pk == public_key); } -pub fn is_circle_member( - db: Arc, - public_key: &str, -) -> bool { +pub fn is_circle_member(db: Arc, public_key: &str) -> bool { let circle = db .collection::() .expect("Failed to get Circle collection") .get_all() - .unwrap()[0].clone(); + .unwrap()[0] + .clone(); // Circle members can access everything if circle.members.contains(&public_key.to_string()) { diff --git a/heromodels/src/models/biz/README.md b/heromodels/src/models/biz/README.md new file mode 100644 index 0000000..89d7907 --- /dev/null +++ b/heromodels/src/models/biz/README.md @@ -0,0 +1,58 @@ +# Business Models (`biz`) + +The `biz` module provides a suite of models for handling core business operations, including company management, product catalogs, sales, payments, and shareholder records. + +## Core Models + +### `Company` + +The `Company` struct is the central model, representing a business entity. + +- **Key Fields**: `name`, `registration_number`, `incorporation_date`, `address`, `business_type`, and `status`. +- **Enums**: + - `CompanyStatus`: Tracks the company's state (`PendingPayment`, `Active`, `Suspended`, `Inactive`). + - `BusinessType`: Categorizes the company (e.g., `Coop`, `Single`, `Global`). +- **Functionality**: Provides a foundation for linking other business models like products, sales, and shareholders. + +### `Product` + +The `Product` model defines goods or services offered by a company. + +- **Key Fields**: `name`, `description`, `price`, `category`, `status`, and `components`. +- **Nested Struct**: `ProductComponent` allows for defining complex products with sub-parts. +- **Enums**: + - `ProductType`: Differentiates between a `Product` and a `Service`. + - `ProductStatus`: Indicates if a product is `Available` or `Unavailable`. + +### `Sale` + +The `Sale` struct records a transaction, linking a buyer to products. + +- **Key Fields**: `company_id`, `buyer_id`, `total_amount`, `sale_date`, and `status`. +- **Nested Struct**: `SaleItem` captures a snapshot of each product at the time of sale, including `product_id`, `quantity`, and `unit_price`. +- **Enum**: `SaleStatus` tracks the state of the sale (`Pending`, `Completed`, `Cancelled`). + +### `Payment` + +The `Payment` model handles financial transactions, often linked to sales or subscriptions. + +- **Key Fields**: `payment_intent_id` (e.g., for Stripe), `company_id`, `total_amount`, `currency`, and `status`. +- **Functionality**: Includes methods to manage the payment lifecycle (`process_payment`, `complete_payment`, `fail_payment`, `refund_payment`). +- **Enum**: `PaymentStatus` provides a detailed state of the payment (`Pending`, `Processing`, `Completed`, `Failed`, `Refunded`). + +### `Shareholder` + +The `Shareholder` model tracks ownership of a company. + +- **Key Fields**: `company_id`, `user_id`, `name`, `shares`, and `percentage`. +- **Enum**: `ShareholderType` distinguishes between `Individual` and `Corporate` shareholders. + +## Workflow Example + +1. A `Company` is created. +2. The company defines several `Product` models representing its offerings. +3. A customer (buyer) initiates a purchase, which creates a `Sale` record containing multiple `SaleItem`s. +4. A `Payment` record is generated to process the transaction for the `Sale`'s total amount. +5. As the company grows, `Shareholder` records are created to track equity distribution. + +All models use the builder pattern for easy and readable instance creation. diff --git a/heromodels/src/models/biz/mod.rs b/heromodels/src/models/biz/mod.rs index 15ace26..7cef9e9 100644 --- a/heromodels/src/models/biz/mod.rs +++ b/heromodels/src/models/biz/mod.rs @@ -17,10 +17,3 @@ pub use shareholder::{Shareholder, ShareholderType}; pub mod sale; pub use sale::{Sale, SaleItem, SaleStatus}; - -// pub use user::{User}; // Assuming a simple User model for now - -#[cfg(feature = "rhai")] -pub mod rhai; -#[cfg(feature = "rhai")] -pub use rhai::register_biz_rhai_module; diff --git a/heromodels/src/models/biz/product.rs b/heromodels/src/models/biz/product.rs index 5a498d9..9a43b2f 100644 --- a/heromodels/src/models/biz/product.rs +++ b/heromodels/src/models/biz/product.rs @@ -1,6 +1,6 @@ use heromodels_core::BaseModelData; -use rhai::{CustomType, TypeBuilder}; use heromodels_derive::model; +use rhai::{CustomType, TypeBuilder}; use serde::{Deserialize, Serialize}; // ProductType represents the type of a product diff --git a/heromodels/src/models/calendar/README.md b/heromodels/src/models/calendar/README.md new file mode 100644 index 0000000..fb6f42d --- /dev/null +++ b/heromodels/src/models/calendar/README.md @@ -0,0 +1,70 @@ +# Calendar Model + +The `calendar` model provides the data structures for managing calendars, events, and attendees. + +## Core Components + +### 1. `Calendar` + +Represents a calendar, which is a collection of events. Each calendar has a name, an optional description, and a list of event IDs. + +- `name`: The name of the calendar (e.g., "Work Calendar", "Personal Calendar"). +- `description`: An optional text description for the calendar. +- `events`: A `Vec` containing the IDs of the `Event` models associated with this calendar. +- `owner_id`: The ID of the user who owns the calendar. +- `is_public`: A boolean indicating if the calendar is visible to others. + +### 2. `Event` + +Represents a single event within a calendar. It contains all the details for a specific appointment or occasion. + +- `title`: The title of the event. +- `description`: An optional detailed description. +- `start_time` & `end_time`: Unix timestamps for when the event begins and ends. +- `attendees`: A `Vec` listing who is invited to the event and their status. +- `location`: The physical or virtual location of the event. +- `status`: The current state of the event, defined by the `EventStatus` enum. + +### 3. `Attendee` + +Represents a person invited to an `Event`. + +- `contact_id`: The ID of the user or contact who is the attendee. +- `status`: The attendee's response to the invitation, defined by the `AttendanceStatus` enum. + +## Enums + +### `EventStatus` + +Defines the lifecycle of an `Event`: +- `Draft`: The event is being planned and is not yet visible to attendees. +- `Published`: The event is confirmed and visible. +- `Cancelled`: The event has been cancelled. + +### `AttendanceStatus` + +Defines the status of an `Attendee` for an event: +- `Accepted`: The attendee has confirmed they will attend. +- `Declined`: The attendee has declined the invitation. +- `Tentative`: The attendee is unsure if they will attend. +- `NoResponse`: The attendee has not yet responded. + +## Usage + +The `Calendar` model uses a builder pattern for creating and modifying instances. You can create a new `Calendar` or `Event` and chain methods to set its properties. + +```rust +use heromodels::models::calendar::{Calendar, Event, Attendee, AttendanceStatus}; + +// Create a new event +let event = Event::new() + .title("Team Meeting") + .description("Weekly sync-up.") + .reschedule(1672531200, 1672534800) // Set start and end times + .add_attendee(Attendee::new(101).status(AttendanceStatus::Accepted)); + +// Create a new calendar and add the event to it (assuming event has been saved and has an ID) +let calendar = Calendar::new(None, "Work Events") + .owner_id(1) + .add_event(event.base_data.id); // Add event by ID +``` diff --git a/heromodels/src/models/calendar/calendar.rs b/heromodels/src/models/calendar/calendar.rs index c88069d..a5cccbb 100644 --- a/heromodels/src/models/calendar/calendar.rs +++ b/heromodels/src/models/calendar/calendar.rs @@ -1,12 +1,12 @@ use heromodels_core::BaseModelData; use heromodels_derive::model; use rhai::{CustomType, TypeBuilder}; -use rhai_autobind_macros::rhai_model_export; use serde::{Deserialize, Serialize}; /// Represents the status of an attendee for an event #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)] pub enum AttendanceStatus { + #[default] Accepted = 0, Declined = 1, Tentative = 2, @@ -14,8 +14,9 @@ pub enum AttendanceStatus { } /// Represents the status of an event -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)] pub enum EventStatus { + #[default] Draft = 0, Published = 1, Cancelled = 2, @@ -87,7 +88,7 @@ impl Attendee { /// Represents an event in a calendar #[model] -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, CustomType)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, CustomType, Default)] pub struct Event { /// Base model data pub base_data: BaseModelData, @@ -224,10 +225,14 @@ impl Event { } /// Adds an attendee ID to the event - pub fn add_attendee(mut self, attendee_id: u32) -> Self { + pub fn add_attendee(mut self, attendee: Attendee) -> Self { // Prevent duplicate attendees by ID - if !self.attendees.iter().any(|&a_id| a_id == attendee_id) { - self.attendees.push(attendee_id); + if !self + .attendees + .iter() + .any(|a| a.contact_id == attendee.contact_id) + { + self.attendees.push(attendee); } self } diff --git a/heromodels/src/models/calendar/mod.rs b/heromodels/src/models/calendar/mod.rs index 4bce0ce..16e0678 100644 --- a/heromodels/src/models/calendar/mod.rs +++ b/heromodels/src/models/calendar/mod.rs @@ -2,4 +2,4 @@ pub mod calendar; // Re-export Calendar, Event, Attendee, AttendanceStatus, and EventStatus from the inner calendar module (calendar.rs) within src/models/calendar/mod.rs -pub use self::calendar::{AttendanceStatus, Attendee, Calendar, Event, EventStatus}; \ No newline at end of file +pub use self::calendar::{AttendanceStatus, Attendee, Calendar, Event, EventStatus}; diff --git a/heromodels/src/models/circle/README.md b/heromodels/src/models/circle/README.md new file mode 100644 index 0000000..2bad370 --- /dev/null +++ b/heromodels/src/models/circle/README.md @@ -0,0 +1,59 @@ +# Circle Model + +The `circle` model defines a `Circle` struct, which represents a group or community of members. It includes metadata for customization and relationship mapping between different circles. + +## `Circle` Struct + +The `Circle` struct is the primary model in this module. + +### Fields + +- `base_data`: Standard `BaseModelData` for a unique ID and timestamps. +- `title`: The name of the circle. +- `ws_url`: A WebSocket URL associated with the circle. +- `description`: An optional, longer description of the circle's purpose. +- `logo`: An optional URL or symbol for the circle's logo. +- `members`: A `Vec` containing the public keys of the members of the circle. +- `circles`: A `Vec` containing the titles or IDs of other related circles, allowing for a network of circles. +- `theme`: A `ThemeData` struct for customizing the visual appearance of the circle. + +### `ThemeData` Struct + +This struct holds visual customization options for a circle: + +- `primary_color`: The primary color for the circle's theme. +- `background_color`: The background color. +- `background_pattern`: A pattern for the background. +- `logo_symbol`: A symbol to use for the logo. +- `logo_url`: A URL for the logo image. +- `nav_dashboard_visible`: A boolean to control the visibility of the dashboard navigation. +- `nav_timeline_visible`: A boolean to control the visibility of the timeline navigation. + +## Usage Example + +Here's how you might create a new circle and add members to it: + +```rust +use heromodels::models::circle::{Circle, ThemeData}; + +let mut my_circle = Circle::new() + .title("My Awesome Circle".to_string()) + .description("A circle for awesome people.".to_string()) + .ws_url("wss://example.com/my_circle".to_string()); + +my_circle = my_circle.add_member("pubkey_of_member_1".to_string()); +my_circle = my_circle.add_member("pubkey_of_member_2".to_string()); + +let theme = ThemeData { + primary_color: "#FF5733".to_string(), + background_color: "#FFFFFF".to_string(), + // ... other theme fields + ..Default::default() +}; + +my_circle = my_circle.theme(theme); + +// The circle is now ready to be saved to the database. +``` + +The `Circle` model is useful for creating social groups, teams, or any other collection of users who need to be grouped together. diff --git a/heromodels/src/models/contact/README.md b/heromodels/src/models/contact/README.md new file mode 100644 index 0000000..72cd6ca --- /dev/null +++ b/heromodels/src/models/contact/README.md @@ -0,0 +1,66 @@ +# Contact and Group Models + +The `contact` module provides models for managing a personal or organizational address book. It includes the `Contact` struct for individual entries and the `Group` struct for organizing contacts. + +## `Contact` Struct + +The `Contact` model stores detailed information about a single contact. + +### Fields + +- `base_data`: Standard `BaseModelData` for a unique ID and timestamps. +- `name`: The contact's name (indexed for easy searching). +- `description`: An optional, longer description. +- `address`: The physical or mailing address. +- `phone`: The contact's phone number. +- `email`: The contact's email address. +- `notes`: Optional field for any additional notes. +- `circle`: A `String` to associate the contact with a specific `Circle` or social group. + +## `Group` Struct + +The `Group` model allows for the creation of contact lists, making it easy to manage related contacts together. + +### Fields + +- `base_data`: Standard `BaseModelData`. +- `name`: The name of the group (e.g., "Family", "Work Colleagues"). +- `description`: An optional description of the group. +- `contacts`: A `Vec` containing the unique IDs of the `Contact` models that belong to this group. + +## Usage Example + +Here is a conceptual example of how to create contacts and organize them into a group: + +1. **Create individual contacts**: + + ```rust + use heromodels::models::contact::Contact; + + let contact1 = Contact::new() + .name("Alice") + .email("alice@example.com"); + + let contact2 = Contact::new() + .name("Bob") + .email("bob@example.com"); + + // Save contact1 and contact2 to the database and get their IDs (e.g., 1 and 2). + ``` + +2. **Create a group and add the contacts**: + + ```rust + use heromodels::models::contact::Group; + + let mut friends_group = Group::new() + .name("Friends") + .description("My closest friends."); + + friends_group = friends_group.add_contact(1); // Add Alice's ID + friends_group = friends_group.add_contact(2); // Add Bob's ID + + // Save the group to the database. + ``` + +Both models use the builder pattern, providing a fluent and readable way to construct instances. diff --git a/heromodels/src/models/core/README.md b/heromodels/src/models/core/README.md new file mode 100644 index 0000000..5f3a724 --- /dev/null +++ b/heromodels/src/models/core/README.md @@ -0,0 +1,50 @@ +# Core Model + +The `core` model contains fundamental, reusable components that are shared across various other models in the `heromodels` library. The primary component in this module is the `Comment` struct. + +## `Comment` Struct + +The `Comment` struct is designed to provide a generic commenting functionality that can be associated with any other model. It supports threaded conversations. + +### Fields + +- `base_data`: The standard `BaseModelData`, which provides a unique ID and timestamps for each comment. +- `user_id`: The ID of the user who posted the comment. This field is indexed. +- `content`: The text content of the comment. +- `parent_comment_id`: An `Option` that holds the ID of the parent comment. If this is `None`, the comment is a top-level comment. If it contains an ID, it is a reply to another comment. + +## Usage + +The `Comment` model uses a builder pattern for easy instantiation. You can create top-level comments or replies. + +### Creating a Top-Level Comment + +```rust +use heromodels::models::core::Comment; + +let top_level_comment = Comment::new() + .user_id(101) // ID of the user posting + .content("This is the first comment on the topic."); + +assert!(top_level_comment.parent_comment_id.is_none()); +``` + +### Creating a Threaded Reply + +To create a reply, you set the `parent_comment_id` to the ID of the comment you are replying to. + +```rust +use heromodels::models::core::Comment; + +// Assume the top_level_comment from the previous example was saved and has ID 1 +let top_level_comment_id = 1; + +let reply_comment = Comment::new() + .user_id(102) + .content("This is a reply to the first comment.") + .parent_comment_id(Some(top_level_comment_id)); + +assert_eq!(reply_comment.parent_comment_id, Some(1)); +``` + +This `Comment` model can be linked from other models (like `User`, `Article`, `Project`, etc.) by storing a `Vec` of comment IDs within them, as demonstrated by the `add_comment` method in the `userexample` model. diff --git a/heromodels/src/models/finance/README.md b/heromodels/src/models/finance/README.md new file mode 100644 index 0000000..498ece1 --- /dev/null +++ b/heromodels/src/models/finance/README.md @@ -0,0 +1,89 @@ +# Finance Model + +The `finance` model provides a suite of data structures for managing financial accounts, digital assets, and a marketplace for trading them. + +## Core Components + +### 1. `Account` + +Represents a financial account, typically owned by a user. It acts as a container for various assets. + +- `name`: An internal name for the account (e.g., "My Savings"). +- `user_id`: The ID of the user who owns the account. +- `ledger`: The blockchain or financial system where the account exists (e.g., "Ethereum"). +- `address`: The account's public address. +- `assets`: A `Vec` of asset IDs associated with this account. + +### 2. `Asset` + +Represents a digital or tokenized asset. + +- `name`: The name of the asset (e.g., "Bitcoin", "MyToken"). +- `amount`: The quantity of the asset held. +- `asset_type`: The type of the asset, defined by the `AssetType` enum. +- `address`: The contract address of the token (if applicable). + +### 3. `Marketplace` + +The marketplace components facilitate the trading of assets. + +- **`Listing`**: Represents an asset listed for sale. It can be a fixed-price sale, an auction, or an exchange. + - `title`: The title of the listing. + - `asset_id`: The ID of the asset being sold. + - `seller_id`: The ID of the user selling the asset. + - `price`: The asking price or starting bid. + - `listing_type`: The type of sale, defined by `ListingType`. + - `status`: The current state of the listing, defined by `ListingStatus`. + +- **`Bid`**: Represents a bid made on an auction-style `Listing`. + - `bidder_id`: The ID of the user placing the bid. + - `amount`: The value of the bid. + - `status`: The current state of the bid, defined by `BidStatus`. + +## Enums + +### `AssetType` +- `Erc20`, `Erc721`, `Erc1155`: Standard Ethereum token types. +- `Native`: The native currency of a blockchain (e.g., ETH). + +### `ListingType` +- `FixedPrice`: The asset is sold for a set price. +- `Auction`: The asset is sold to the highest bidder. +- `Exchange`: The asset is offered in trade for other assets. + +### `ListingStatus` +- `Active`, `Sold`, `Cancelled`, `Expired`: Defines the lifecycle of a listing. + +### `BidStatus` +- `Active`, `Accepted`, `Rejected`, `Cancelled`: Defines the lifecycle of a bid. + +## Usage + +The models use a builder pattern for easy instantiation. + +```rust +use heromodels::models::finance::{Account, Asset, Listing, ListingType}; + +// 1. Create a user account +let account = Account::new() + .name("Trading Account") + .user_id(101) + .ledger("Ethereum") + .address("0x123..."); + +// 2. Create an asset (assuming it's saved and has an ID) +let asset = Asset::new() + .name("Hero Token") + .amount(1000.0); +// In a real scenario, you would save the asset to get an ID. +let asset_id = asset.base_data.id.to_string(); + +// 3. Create a marketplace listing for the asset +let listing = Listing::new() + .title("1000 Hero Tokens for Sale") + .asset_id(asset_id) + .seller_id(account.user_id.to_string()) + .price(0.5) + .currency("USD") + .listing_type(ListingType::FixedPrice); +``` diff --git a/heromodels/src/models/flow/README.md b/heromodels/src/models/flow/README.md new file mode 100644 index 0000000..c068954 --- /dev/null +++ b/heromodels/src/models/flow/README.md @@ -0,0 +1,60 @@ +# Flow Model + +The `flow` model provides a framework for creating and managing multi-step workflows, particularly those requiring digital signatures. It is designed to orchestrate a sequence of actions that must be completed in a specific order. + +## Core Components + +### 1. `Flow` + +The top-level container for a workflow. + +- `flow_uuid`: A unique identifier for the entire flow, used for external references. +- `name`: A human-readable name for the flow (e.g., "Document Approval Process"). +- `status`: The overall status of the flow (e.g., "Pending", "InProgress", "Completed"). +- `steps`: A `Vec` that defines the sequence of steps in the workflow. + +### 2. `FlowStep` + +Represents a single, distinct step within a `Flow`. + +- `step_order`: A `u32` that determines the position of this step in the sequence. +- `description`: An optional text description of what this step entails. +- `status`: The status of this individual step. + +### 3. `SignatureRequirement` + +Defines a requirement for a digital signature within a `FlowStep`. A single step can have multiple signature requirements. + +- `flow_step_id`: A foreign key linking the requirement to its parent `FlowStep`. +- `public_key`: The public key of the entity that is required to sign. +- `message`: The plaintext message that needs to be signed. +- `signature`: The resulting signature, once provided. +- `status`: The status of the signature requirement (e.g., "Pending", "Signed", "Failed"). + +## Usage + +The models use a builder pattern to construct complex flows. You create a `Flow`, add `FlowStep`s to it, and associate `SignatureRequirement`s with each step. + +```rust +use heromodels::models::flow::{Flow, FlowStep, SignatureRequirement}; +use uuid::Uuid; + +// 1. Define a signature requirement +let requirement = SignatureRequirement::new( + 0, // ID is managed by the database + 1, // Belongs to flow step 1 + "0xPublicKey1...", + "I approve this document." +); + +// 2. Create a flow step +// In a real application, you would add the signature requirement to the step. +let step1 = FlowStep::new(0, 1) // ID, step_order + .description("Initial review and approval"); + +// 3. Create the main flow and add the step +let flow = Flow::new(Uuid::new_v4().to_string()) + .name("Contract Signing Flow") + .add_step(step1); + +``` diff --git a/heromodels/src/models/flow/flow.rs b/heromodels/src/models/flow/flow.rs index 0eec251..986703e 100644 --- a/heromodels/src/models/flow/flow.rs +++ b/heromodels/src/models/flow/flow.rs @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize}; #[model] pub struct Flow { /// Base model data (id, created_at, updated_at). - #[rhai_type(skip)] + #[rhai_type(skip)] pub base_data: BaseModelData, /// A unique UUID for the flow, for external reference. diff --git a/heromodels/src/models/flow/flow_step.rs b/heromodels/src/models/flow/flow_step.rs index e5bc2b6..757360f 100644 --- a/heromodels/src/models/flow/flow_step.rs +++ b/heromodels/src/models/flow/flow_step.rs @@ -9,7 +9,7 @@ use std::default::Default; #[model] pub struct FlowStep { /// Base model data. - #[rhai_type(skip)] + #[rhai_type(skip)] pub base_data: BaseModelData, /// Optional description for the step. diff --git a/heromodels/src/models/flow/mod.rs b/heromodels/src/models/flow/mod.rs index fd3cb68..8484448 100644 --- a/heromodels/src/models/flow/mod.rs +++ b/heromodels/src/models/flow/mod.rs @@ -6,4 +6,4 @@ pub mod signature_requirement; // Re-export key types for convenience pub use flow::Flow; pub use flow_step::FlowStep; -pub use signature_requirement::SignatureRequirement; \ No newline at end of file +pub use signature_requirement::SignatureRequirement; diff --git a/heromodels/src/models/flow/signature_requirement.rs b/heromodels/src/models/flow/signature_requirement.rs index 318b8a5..33bcdae 100644 --- a/heromodels/src/models/flow/signature_requirement.rs +++ b/heromodels/src/models/flow/signature_requirement.rs @@ -9,7 +9,7 @@ use std::default::Default; #[model] pub struct SignatureRequirement { /// Base model data. - #[rhai_type(skip)] + #[rhai_type(skip)] pub base_data: BaseModelData, /// Foreign key to the FlowStep this requirement belongs to. diff --git a/heromodels/src/models/gov/README.md b/heromodels/src/models/gov/README.md new file mode 100644 index 0000000..bbb855b --- /dev/null +++ b/heromodels/src/models/gov/README.md @@ -0,0 +1,64 @@ +# Corporate Governance (`gov`) Model + +The `gov` module provides a comprehensive suite of models for managing corporate governance structures and processes. It allows for the detailed representation of companies, their ownership, governing bodies, and decision-making workflows. + +## Core Models + +### `Company` + +The `Company` struct is the central entity in this module. It is similar to the `Company` model in the `biz` module but is specifically tailored for governance, with direct implementation of the `Model` trait for database interaction. + +- **Key Fields**: `name`, `registration_number`, `incorporation_date`, `status`, `business_type`. +- **Enums**: `CompanyStatus`, `BusinessType`. + +### `Shareholder` + +The `Shareholder` model is used to track ownership of a company. + +- **Key Fields**: `company_id`, `name`, `shares`, `percentage`, `shareholder_type`. +- **Enums**: `ShareholderType` (e.g., Individual, Corporate). + +### `Committee` + +Companies can have `Committee`s to oversee specific functions (e.g., Audit Committee, Compensation Committee). Each committee is composed of `CommitteeMember`s. + +- **`Committee` Fields**: `company_id`, `name`, `description`, `members`. +- **`CommitteeMember` Fields**: `user_id`, `name`, `role`. +- **Enums**: `CommitteeRole` (e.g., Chair, Member, Advisor). + +### `Meeting` + +The `Meeting` model is used to schedule and document official meetings for a company or its committees. + +- **Key Fields**: `company_id`, `title`, `meeting_type`, `status`, `start_time`, `end_time`, `agenda`, `minutes`, `attendees`. +- **`Attendee` Fields**: `user_id`, `name`, `status`. +- **Enums**: `MeetingStatus`, `MeetingType`, `AttendanceStatus`. + +### `Resolution` + +A `Resolution` represents a formal proposal or decision that requires a vote. + +- **Key Fields**: `company_id`, `title`, `description`, `resolution_type`, `status`, `proposed_date`, `effective_date`. +- **Enums**: `ResolutionStatus`, `ResolutionType` (e.g., Ordinary, Special). + +### `Vote` and `Ballot` + +The `Vote` model facilitates the voting process for a specific `Resolution`. Each `Vote` consists of multiple `Ballot`s cast by voters. + +- **`Vote` Fields**: `company_id`, `resolution_id`, `title`, `status`, `start_date`, `end_date`, `ballots`. +- **`Ballot` Fields**: `user_id`, `option`, `weight`, `cast_at`. +- **Enums**: `VoteStatus`, `VoteOption` (Yes, No, Abstain). + +## Workflow Example + +A typical governance workflow might look like this: + +1. A `Company` is established with several `Shareholder`s. +2. A `Committee` (e.g., the Board of Directors) is formed by adding `CommitteeMember`s. +3. The committee proposes a `Resolution` to approve the annual budget. +4. A `Vote` is created for this resolution, with a defined start and end date. +5. A `Meeting` is scheduled to discuss the resolution. +6. During the voting period, shareholders or committee members cast their `Ballot`s. +7. Once the `Vote` is closed, the results are tallied, and the `Resolution` status is updated to `Approved` or `Rejected`. + +This module provides the foundational data structures for building robust corporate governance applications. diff --git a/heromodels/src/models/governance/README.md b/heromodels/src/models/governance/README.md new file mode 100644 index 0000000..7cf8dd6 --- /dev/null +++ b/heromodels/src/models/governance/README.md @@ -0,0 +1,79 @@ +# Governance Model + +The `governance` model provides a robust framework for managing decentralized governance processes, including proposals, voting, and activity tracking. + +## Core Components + +### 1. `Proposal` + +The central element of the governance model. A `Proposal` represents a formal suggestion submitted to the community for a vote. + +- `title` & `description`: The substance of the proposal. +- `creator_id`: The ID of the user who submitted the proposal. +- `status`: The current state of the proposal (e.g., `Draft`, `Active`, `Approved`), defined by the `ProposalStatus` enum. +- `options`: A `Vec` defining the choices voters can select (e.g., "For", "Against", "Abstain"). +- `vote_start_date` & `vote_end_date`: Timestamps that define the voting period. + +### 2. `Ballot` + +Represents a single vote cast by a user on a specific `Proposal`. + +- `user_id`: The ID of the voter. +- `vote_option_id`: The specific `VoteOption` the user selected. +- `shares_count`: The voting power or weight of the vote. +- `comment`: An optional comment from the voter. + +### 3. `GovernanceActivity` + +A detailed record of every significant event that occurs within the governance system. This is crucial for transparency and auditing. + +- `activity_type`: The type of event that occurred (e.g., `ProposalCreated`, `VoteCast`), defined by the `ActivityType` enum. +- `actor_id` & `actor_name`: Who performed the action. +- `target_id` & `target_type`: The object the action was performed on (e.g., a `Proposal`). +- `title` & `description`: A summary of the activity. + +### 4. `AttachedFile` + +A simple struct to link external documents or files to a proposal, such as technical specifications or legal drafts. + +## Enums + +The model includes several enums to manage the state of proposals, voting, and activities: + +- `ProposalStatus`: Tracks the lifecycle of a proposal (`Draft`, `Active`, `Approved`, `Rejected`). +- `VoteEventStatus`: Tracks the status of the voting period (`Upcoming`, `Open`, `Closed`). +- `ActivityType`: Categorizes different governance actions. +- `ActivityStatus`: Tracks the status of a recorded activity (`Pending`, `Completed`, `Failed`). + +## Usage + +```rust +use heromodels::models::governance::{Proposal, Ballot, VoteOption, ProposalStatus}; +use chrono::Utc; + +// 1. Create a new proposal +let mut proposal = Proposal::new( + None, // ID is managed by the database + "user-123".to_string(), + "Alice".to_string(), + "Adopt New Logo".to_string(), + "Proposal to update the community logo.".to_string(), + ProposalStatus::Draft, + vec![], + None +); + +// 2. Add voting options +proposal = proposal.add_option(1, "Approve New Logo", None); +proposal = proposal.add_option(2, "Reject New Logo", None); + +// 3. An eligible user casts a vote +// This would typically be done by finding the proposal and then calling cast_vote. +let proposal_after_vote = proposal.cast_vote( + None, // Ballot ID + 456, // Voter's user_id + 1, // Voting for option 1 + 100 // With 100 shares/votes +); + +``` diff --git a/heromodels/src/models/governance/activity.rs b/heromodels/src/models/governance/activity.rs index 69d0214..b05d4d2 100644 --- a/heromodels/src/models/governance/activity.rs +++ b/heromodels/src/models/governance/activity.rs @@ -3,7 +3,6 @@ use chrono::{DateTime, Utc}; use heromodels_derive::model; use rhai::{CustomType, TypeBuilder}; -use rhai_autobind_macros::rhai_model_export; use serde::{Deserialize, Serialize}; // use std::collections::HashMap; @@ -47,7 +46,6 @@ impl Default for ActivityStatus { /// GovernanceActivity represents a single activity or event in the governance system /// This model tracks all significant actions and changes for audit and transparency purposes #[derive(Debug, Clone, Serialize, Deserialize, CustomType)] -#[rhai_model_export(db_type = "std::sync::Arc")] #[model] pub struct GovernanceActivity { pub base_data: BaseModelData, diff --git a/heromodels/src/models/governance/mod.rs b/heromodels/src/models/governance/mod.rs index 4e744bc..8643ddf 100644 --- a/heromodels/src/models/governance/mod.rs +++ b/heromodels/src/models/governance/mod.rs @@ -1,7 +1,9 @@ // heromodels/src/models/governance/mod.rs // This module will contain the Proposal model and related types. pub mod activity; +pub mod attached_file; pub mod proposal; pub use self::activity::{ActivityStatus, ActivityType, GovernanceActivity}; +pub use self::attached_file::AttachedFile; pub use self::proposal::{Ballot, Proposal, ProposalStatus, VoteEventStatus, VoteOption}; diff --git a/heromodels/src/models/governance/proposal.rs b/heromodels/src/models/governance/proposal.rs index 2be8cab..42124a3 100644 --- a/heromodels/src/models/governance/proposal.rs +++ b/heromodels/src/models/governance/proposal.rs @@ -343,7 +343,6 @@ impl ToString for ActivityType { /// Represents a governance activity in the system #[derive(Debug, Clone, Serialize, Deserialize, CustomType)] -#[rhai_model_export(db_type = "std::sync::Arc")] #[model] // Has base.Base in V spec pub struct Activity { /// Base model data diff --git a/heromodels/src/models/legal/README.md b/heromodels/src/models/legal/README.md new file mode 100644 index 0000000..ae899f8 --- /dev/null +++ b/heromodels/src/models/legal/README.md @@ -0,0 +1,79 @@ +# Legal Model + +The `legal` model provides a structured way to create, manage, and track the lifecycle of digital contracts. + +## Core Components + +### 1. `Contract` + +The main struct representing a legal agreement. It serves as a container for all contract-related data. + +- `contract_id`: A unique identifier for the contract. +- `title` & `description`: A summary of the contract's purpose. +- `status`: The current state of the contract (e.g., `Draft`, `Active`), managed by the `ContractStatus` enum. +- `signers`: A `Vec` listing all parties required to sign. +- `revisions`: A `Vec` that provides a history of the contract's content, allowing for version control. +- `current_version`: The active version of the contract. + +### 2. `ContractSigner` + +Represents an individual or entity required to sign the contract. + +- `id`, `name`, `email`: Identifying information for the signer. +- `status`: The signer's current status (`Pending`, `Signed`, `Rejected`), defined by the `SignerStatus` enum. +- `signed_at`: A timestamp indicating when the signature was provided. +- `signature_data`: Stores the actual signature, for example, as a Base64 encoded image. + +### 3. `ContractRevision` + +Represents a specific version of the contract's text. + +- `version`: A number identifying the revision. +- `content`: The full text of the contract for that version. +- `created_at` & `created_by`: Audit fields to track who created the revision and when. + +## Enums + +The model uses two key enums to manage state: + +- `ContractStatus`: Defines the lifecycle of the entire contract, from `Draft` to `PendingSignatures`, `Active`, `Expired`, or `Cancelled`. +- `SignerStatus`: Tracks the state of each individual signer (`Pending`, `Signed`, `Rejected`). + +## Usage + +The models are constructed using a builder pattern, allowing for clear and flexible creation of complex contracts. + +```rust +use heromodels::models::legal::{Contract, ContractSigner, ContractRevision, ContractStatus}; +use std::time::{SystemTime, UNIX_EPOCH}; + +fn current_timestamp_secs() -> u64 { + SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap_or_default() + .as_secs() +} + +// 1. Create a signer +let signer1 = ContractSigner::new( + "signer-uuid-1".to_string(), + "Alice".to_string(), + "alice@example.com".to_string() +); + +// 2. Create a revision +let revision1 = ContractRevision::new( + 1, + "This is the first version of the contract...".to_string(), + current_timestamp_secs(), + "creator-uuid-1".to_string() +); + +// 3. Create the contract +let contract = Contract::new(1, "contract-uuid-1".to_string()) + .title("Service Agreement") + .status(ContractStatus::PendingSignatures) + .add_signer(signer1) + .add_revision(revision1) + .current_version(1); +``` diff --git a/heromodels/src/models/library/README.md b/heromodels/src/models/library/README.md new file mode 100644 index 0000000..89fc763 --- /dev/null +++ b/heromodels/src/models/library/README.md @@ -0,0 +1,49 @@ +# Library Model + +The `library` model provides a flexible system for managing various types of digital assets and organizing them into collections. + +## Library Item Types + +The model supports several distinct types of library items, each with its own specific metadata: + +- `Image`: Represents an image file with properties like `title`, `url`, `width`, and `height`. +- `Pdf`: Represents a PDF document with a `title`, `url`, and `page_count`. +- `Markdown`: Represents a text document written in Markdown, with `title` and `content`. +- `Book`: A more complex item that consists of a `title`, a `table_of_contents` (a nested structure of `TocEntry` items), and a `Vec` of pages (in Markdown). +- `Slideshow`: Represents a presentation, containing a `title` and a `Vec`, where each slide has an `image_url` and optional text. + +All items share a common `BaseModelData` field, providing them with a unique ID and timestamps. + +## `Collection` + +The `Collection` struct is used to group various library items together. It does not store the items directly but rather holds vectors of their unique IDs. + +- `title` & `description`: To name and describe the collection. +- `images`: A `Vec` of `Image` item IDs. +- `pdfs`: A `Vec` of `Pdf` item IDs. +- `markdowns`: A `Vec` of `Markdown` item IDs. +- `books`: A `Vec` of `Book` item IDs. +- `slides`: A `Vec` of `Slideshow` item IDs. + +## Usage + +First, you create individual library items. Then, you create a collection and add the IDs of those items to it. + +```rust +use heromodels::models::library::{Image, Collection}; + +// 1. Create a library item (e.g., an Image) +let image1 = Image::new() + .title("Company Logo") + .url("https://example.com/logo.png"); +// In a real app, this would be saved to a database, and we'd get an ID. +let image1_id = image1.id(); // Assuming this ID is now 1 + +// 2. Create a collection +let mut marketing_assets = Collection::new() + .title("Marketing Assets"); + +// 3. Add the item's ID to the collection +marketing_assets = marketing_assets.add_image(image1_id); + +``` diff --git a/heromodels/src/models/library/items.rs b/heromodels/src/models/library/items.rs index 47fb6fe..f4a697c 100644 --- a/heromodels/src/models/library/items.rs +++ b/heromodels/src/models/library/items.rs @@ -112,10 +112,10 @@ impl Pdf { Self::default() } - /// Gets the ID of the image. - pub fn id(&self) -> u32 { - self.base_data.id - } + /// Gets the ID of the image. + pub fn id(&self) -> u32 { + self.base_data.id + } /// Sets the title of the PDF. pub fn title(mut self, title: impl Into) -> Self { @@ -163,10 +163,10 @@ impl Markdown { Self::default() } - /// Gets the ID of the image. - pub fn id(&self) -> u32 { - self.base_data.id - } + /// Gets the ID of the image. + pub fn id(&self) -> u32 { + self.base_data.id + } /// Sets the title of the document. pub fn title(mut self, title: impl Into) -> Self { diff --git a/heromodels/src/models/log/README.md b/heromodels/src/models/log/README.md index 472a8e7..ba6ca45 100644 --- a/heromodels/src/models/log/README.md +++ b/heromodels/src/models/log/README.md @@ -1,3 +1,36 @@ -## Object Model +# Log Model -This is a generic object model mostly used for testing purposes. \ No newline at end of file +The `log` model provides a generic `Log` struct for creating audit trails, recording events, or tracking activities within the system. It is designed to be flexible, linking a subject (who performed the action) to an object (what was affected). + +## `Log` Struct + +The `Log` struct is the core of this module. + +### Fields + +- `base_data`: Standard `BaseModelData` for a unique ID and timestamps. +- `title`: A short, descriptive title for the log entry (e.g., "User Login", "File Deletion"). This field is indexed. +- `description`: A more detailed description of the event. +- `subject_pk`: The public key of the user or entity that initiated the event. This field is indexed. +- `object_id`: The unique ID of the object or resource that was the target of the event. This field is indexed. + +## Usage Example + +Here is how you might create a log entry when a user updates a contact: + +```rust +use heromodels::models::log::Log; + +let user_public_key = "pubkey_of_acting_user"; +let updated_contact_id = 123; + +let log_entry = Log::new() + .title("Contact Updated".to_string()) + .description(format!("User {} updated contact with ID {}.", user_public_key, updated_contact_id)) + .subject_pk(user_public_key.to_string()) + .object_id(updated_contact_id); + +// Save the log_entry to the database. +``` + +By indexing `title`, `subject_pk`, and `object_id`, the `Log` model allows for efficient querying of activities, such as retrieving all actions performed by a specific user or all events related to a particular object. \ No newline at end of file diff --git a/heromodels/src/models/mod.rs b/heromodels/src/models/mod.rs index b65f030..a71e98a 100644 --- a/heromodels/src/models/mod.rs +++ b/heromodels/src/models/mod.rs @@ -21,15 +21,15 @@ pub use userexample::User; // pub use productexample::Product; // Temporarily remove pub use biz::{Payment, PaymentStatus, Sale, SaleItem, SaleStatus}; pub use calendar::{AttendanceStatus, Attendee, Calendar, Event}; +pub use circle::{Circle, ThemeData}; pub use finance::marketplace::{Bid, BidStatus, Listing, ListingStatus, ListingType}; pub use finance::{Account, Asset, AssetType}; pub use flow::{Flow, FlowStep, SignatureRequirement}; -pub use legal::{Contract, ContractRevision, ContractSigner, ContractStatus, SignerStatus}; -pub use library::collection::Collection; -pub use library::items::{Image, Markdown, Pdf}; -pub use projects::{Project, ProjectStatus}; pub use governance::{ ActivityStatus, ActivityType, Ballot, GovernanceActivity, Proposal, ProposalStatus, VoteEventStatus, VoteOption, }; -pub use circle::{Circle, ThemeData}; +pub use legal::{Contract, ContractRevision, ContractSigner, ContractStatus, SignerStatus}; +pub use library::collection::Collection; +pub use library::items::{Image, Markdown, Pdf}; +pub use projects::{Project, Status}; diff --git a/heromodels/src/models/object/README.md b/heromodels/src/models/object/README.md index 472a8e7..13397af 100644 --- a/heromodels/src/models/object/README.md +++ b/heromodels/src/models/object/README.md @@ -1,3 +1,27 @@ -## Object Model +# Object Model -This is a generic object model mostly used for testing purposes. \ No newline at end of file +The `object` model provides a simple, generic `Object` struct. It is intended for use in situations where a basic, identifiable data container is needed, such as for testing, prototyping, or representing simple items that do not require a more complex, specific model. + +## `Object` Struct + +The `Object` struct contains the following fields: + +- `base_data`: Standard `BaseModelData` for a unique ID and timestamps. +- `title`: A string for the object's title or name. This field is indexed for efficient lookups. +- `description`: A string for a more detailed description of the object. + +## Usage Example + +Creating a new `Object` is straightforward using the builder pattern: + +```rust +use heromodels::models::object::Object; + +let my_object = Object::new() + .title("My Test Object".to_string()) + .description("This is an object created for a test scenario.".to_string()); + +// The object is now ready to be saved to the database. +``` + +Due to its simplicity, the `Object` model is a versatile tool for various development and testing needs. \ No newline at end of file diff --git a/heromodels/src/models/object/object.rs b/heromodels/src/models/object/object.rs index 8ebca6d..88c4228 100644 --- a/heromodels/src/models/object/object.rs +++ b/heromodels/src/models/object/object.rs @@ -1,9 +1,9 @@ use heromodels_core::BaseModelData; use heromodels_derive::model; use rhai::CustomType; +use rhai::TypeBuilder; use rhailib_derive::RhaiApi; use serde::{Deserialize, Serialize}; -use rhai::TypeBuilder; /// Represents an event in a contact #[model] @@ -13,7 +13,7 @@ pub struct Object { pub base_data: BaseModelData, #[index] pub title: String, - pub description: String + pub description: String, } impl Object { @@ -28,7 +28,7 @@ impl Object { pub fn id(&self) -> u32 { self.base_data.id } - + pub fn title(mut self, title: String) -> Self { self.title = title; self @@ -38,4 +38,4 @@ impl Object { self.description = description; self } -} \ No newline at end of file +} diff --git a/heromodels/src/models/projects/README.md b/heromodels/src/models/projects/README.md new file mode 100644 index 0000000..ab99e06 --- /dev/null +++ b/heromodels/src/models/projects/README.md @@ -0,0 +1,76 @@ +# Projects Model + +The `projects` model provides a comprehensive suite of tools for managing software development projects, based on common agile methodologies. + +## Core Components + +The model is built around a hierarchy of work items: + +- **`Project`**: The highest-level container. A `Project` holds information about its members, and contains lists of IDs for associated epics, sprints, and boards. + +- **`Epic`**: Represents a large body of work or a major feature. An `Epic` is broken down into smaller tasks and can be associated with a project. It tracks its own status, start/due dates, and a list of `child_task_ids`. + +- **`Sprint`**: A time-boxed iteration (e.g., two weeks) during which a team works to complete a set of tasks. A `Sprint` has a goal, a start and end date, its own status (`Planned`, `Active`, `Completed`), and a list of `task_ids`. + +- **`Task`**: The most granular unit of work. A `Task` has a title, description, status, priority, and can be assigned to a user. It can be linked to a parent `Project`, `Epic`, and `Sprint`. Tasks can also be nested using the `parent_task_id` field. + +- **`Label`**: A simple struct for creating tags with a name and a color, which can be used to categorize items. + +## Enums and Statuses + +The model uses several enums to manage the state of work items: + +- **`Priority`**: A general enum (`Critical`, `High`, `Medium`, `Low`) used across different models. +- **`Status`**: A general status enum (`Todo`, `InProgress`, `Done`, etc.) for projects. +- **`ItemType`**: Describes the type of work item (`Epic`, `Story`, `Task`, `Bug`). +- **`SprintStatus`**: Specific statuses for sprints (`Planned`, `Active`, `Completed`). +- **`TaskStatus`** and **`TaskPriority`**: Specific enums for the detailed states and priorities of individual tasks. + +## Usage + +The typical workflow involves creating a `Project`, then populating it with `Epic`s and `Sprint`s. `Task`s are then created and associated with these epics and sprints. + +```rust +use heromodels::models::projects::{Project, Epic, Sprint, Task, task_enums::{TaskStatus, TaskPriority}}; + +// 1. Create a Project +let project = Project::new(1, "New Website".to_string(), "Build a new company website".to_string(), 101); + +// 2. Create an Epic for a major feature +let mut epic = Epic::new( + "User Authentication".to_string(), + Some("Implement login, registration, and profile management".to_string()), + Default::default(), + Some(project.get_id()), + None, None, vec![] +); + +// 3. Create a Sprint +let mut sprint = Sprint::new( + "Sprint 1".to_string(), + None, + Default::default(), + Some("Focus on core auth endpoints".to_string()), + Some(project.get_id()), + None, None +); + +// 4. Create a Task and link it to the Epic and Sprint +let task = Task::new( + "Create login endpoint".to_string(), + None, + TaskStatus::Todo, + TaskPriority::High, + Some(102), // assignee_id + Some(101), // reporter_id + None, // parent_task_id + Some(epic.get_id()), + Some(sprint.get_id()), + Some(project.get_id()), + None, None, None, vec!["backend".to_string()] +); + +// 5. Add the task ID to the epic and sprint +epic = epic.add_task_id(task.get_id()); +sprint = sprint.add_task_id(task.get_id()); +``` diff --git a/heromodels/src/models/userexample/README.md b/heromodels/src/models/userexample/README.md new file mode 100644 index 0000000..548bd03 --- /dev/null +++ b/heromodels/src/models/userexample/README.md @@ -0,0 +1,55 @@ +# User Example Model + +The `userexample` model provides a basic but complete example of a model within the `heromodels` ecosystem. It defines a `User` struct that can be used as a template or reference for creating more complex models. + +## `User` Struct + +The `User` struct represents a user in the system and contains the following fields: + +- `base_data`: The standard `BaseModelData` struct, providing a unique ID, timestamps, and comment tracking. +- `username`: The user's unique username. +- `email`: The user's email address. +- `full_name`: The user's full name. +- `is_active`: A boolean flag to indicate if the user's account is active. + +The `username`, `email`, and `is_active` fields are indexed for efficient database lookups. + +## Usage + +The `User` model uses the builder pattern for easy and readable instance creation and modification. + +### Creating a User + +You can create a new user and set their properties fluently. + +```rust +use heromodels::models::userexample::User; + +// Create a new user and set their details +let mut user = User::new() + .username("jdoe") + .email("jdoe@example.com") + .full_name("John Doe"); + +// The user is active by default +assert_eq!(user.is_active, true); + +// Deactivate the user +user.deactivate(); +assert_eq!(user.is_active, false); + +// Activate the user again +user.activate(); +assert_eq!(user.is_active, true); +``` + +### Adding Comments + +The model also demonstrates how to interact with the underlying `BaseModelData` to add associated comment IDs. + +```rust +use heromodels::models::userexample::User; + +let mut user = User::new().username("jdoe"); +user = user.add_comment(101); // Add the ID of a comment +``` diff --git a/heromodels/temp_calendar_db/data/lookup/.inc b/heromodels/temp_calendar_db/data/lookup/.inc deleted file mode 100644 index 56a6051..0000000 --- a/heromodels/temp_calendar_db/data/lookup/.inc +++ /dev/null @@ -1 +0,0 @@ -1 \ No newline at end of file diff --git a/heromodels/temp_calendar_db/data/lookup/data b/heromodels/temp_calendar_db/data/lookup/data deleted file mode 100644 index fe77ee9..0000000 Binary files a/heromodels/temp_calendar_db/data/lookup/data and /dev/null differ diff --git a/heromodels/temp_calendar_db/index/0.db b/heromodels/temp_calendar_db/index/0.db deleted file mode 100644 index 0ad682e..0000000 Binary files a/heromodels/temp_calendar_db/index/0.db and /dev/null differ diff --git a/heromodels/temp_calendar_db/index/lookup/.inc b/heromodels/temp_calendar_db/index/lookup/.inc deleted file mode 100644 index d8263ee..0000000 --- a/heromodels/temp_calendar_db/index/lookup/.inc +++ /dev/null @@ -1 +0,0 @@ -2 \ No newline at end of file diff --git a/heromodels/temp_calendar_db/index/lookup/data b/heromodels/temp_calendar_db/index/lookup/data deleted file mode 100644 index 92d764d..0000000 Binary files a/heromodels/temp_calendar_db/index/lookup/data and /dev/null differ diff --git a/heromodels/temp_governance_db/data/lookup/.inc b/heromodels/temp_governance_db/data/lookup/.inc deleted file mode 100644 index 56a6051..0000000 --- a/heromodels/temp_governance_db/data/lookup/.inc +++ /dev/null @@ -1 +0,0 @@ -1 \ No newline at end of file diff --git a/heromodels/temp_governance_db/data/lookup/data b/heromodels/temp_governance_db/data/lookup/data deleted file mode 100644 index fe77ee9..0000000 Binary files a/heromodels/temp_governance_db/data/lookup/data and /dev/null differ diff --git a/heromodels/temp_governance_db/index/0.db b/heromodels/temp_governance_db/index/0.db deleted file mode 100644 index 0ad682e..0000000 Binary files a/heromodels/temp_governance_db/index/0.db and /dev/null differ diff --git a/heromodels/temp_governance_db/index/lookup/.inc b/heromodels/temp_governance_db/index/lookup/.inc deleted file mode 100644 index d8263ee..0000000 --- a/heromodels/temp_governance_db/index/lookup/.inc +++ /dev/null @@ -1 +0,0 @@ -2 \ No newline at end of file diff --git a/heromodels/temp_governance_db/index/lookup/data b/heromodels/temp_governance_db/index/lookup/data deleted file mode 100644 index 92d764d..0000000 Binary files a/heromodels/temp_governance_db/index/lookup/data and /dev/null differ diff --git a/heromodels/test_rhai_db/data/lookup/data b/heromodels/test_rhai_db/data/lookup/data deleted file mode 100644 index fe77ee9..0000000 Binary files a/heromodels/test_rhai_db/data/lookup/data and /dev/null differ diff --git a/heromodels/test_rhai_db/index/0.db b/heromodels/test_rhai_db/index/0.db deleted file mode 100644 index 0ad682e..0000000 Binary files a/heromodels/test_rhai_db/index/0.db and /dev/null differ diff --git a/heromodels/test_rhai_db/index/lookup/.inc b/heromodels/test_rhai_db/index/lookup/.inc deleted file mode 100644 index d8263ee..0000000 --- a/heromodels/test_rhai_db/index/lookup/.inc +++ /dev/null @@ -1 +0,0 @@ -2 \ No newline at end of file diff --git a/heromodels/test_rhai_db/index/lookup/data b/heromodels/test_rhai_db/index/lookup/data deleted file mode 100644 index 92d764d..0000000 Binary files a/heromodels/test_rhai_db/index/lookup/data and /dev/null differ diff --git a/heromodels/tmp/event_test_db/index/0.db b/heromodels/tmp/event_test_db/index/0.db deleted file mode 100644 index 0ad682e..0000000 Binary files a/heromodels/tmp/event_test_db/index/0.db and /dev/null differ diff --git a/heromodels/tmp/event_test_db/index/lookup/.inc b/heromodels/tmp/event_test_db/index/lookup/.inc deleted file mode 100644 index d8263ee..0000000 --- a/heromodels/tmp/event_test_db/index/lookup/.inc +++ /dev/null @@ -1 +0,0 @@ -2 \ No newline at end of file diff --git a/standalone_ourdb_example.rs b/ourdb/examples/standalone_ourdb_example.rs similarity index 87% rename from standalone_ourdb_example.rs rename to ourdb/examples/standalone_ourdb_example.rs index f9f5cb2..546eff1 100644 --- a/standalone_ourdb_example.rs +++ b/ourdb/examples/standalone_ourdb_example.rs @@ -13,9 +13,9 @@ fn main() -> Result<(), Box> { .as_secs(); let db_path = temp_dir().join(format!("ourdb_example_{}", timestamp)); std::fs::create_dir_all(&db_path)?; - + println!("Creating database at: {}", db_path.display()); - + // Create a new OurDB instance let config = OurDBConfig { path: db_path.clone(), @@ -24,51 +24,60 @@ fn main() -> Result<(), Box> { keysize: None, reset: Some(false), }; - + let mut db = OurDB::new(config)?; println!("Database created successfully"); - + // Store some data let test_data = b"Hello, OurDB!"; - let id = db.set(OurDBSetArgs { id: None, data: test_data })?; + let id = db.set(OurDBSetArgs { + id: None, + data: test_data, + })?; println!("\nStored data with ID: {}", id); - + // Retrieve the data let retrieved = db.get(id)?; println!("Retrieved data: {}", String::from_utf8_lossy(&retrieved)); - + // Update the data let updated_data = b"Updated data in OurDB!"; - db.set(OurDBSetArgs { id: Some(id), data: updated_data })?; + db.set(OurDBSetArgs { + id: Some(id), + data: updated_data, + })?; println!("\nUpdated data with ID: {}", id); - + // Retrieve the updated data let retrieved = db.get(id)?; - println!("Retrieved updated data: {}", String::from_utf8_lossy(&retrieved)); - + println!( + "Retrieved updated data: {}", + String::from_utf8_lossy(&retrieved) + ); + // Get history let history = db.get_history(id, 2)?; println!("\nHistory for ID {}:", id); for (i, data) in history.iter().enumerate() { println!(" Version {}: {}", i + 1, String::from_utf8_lossy(data)); } - + // Delete the data db.delete(id)?; println!("\nDeleted data with ID: {}", id); - + // Try to retrieve the deleted data (should fail) match db.get(id) { Ok(_) => println!("Data still exists (unexpected)"), Err(e) => println!("Verified deletion: {}", e), } - + println!("\nExample completed successfully!"); - + // Clean up db.close()?; std::fs::remove_dir_all(&db_path)?; println!("Cleaned up database directory"); - + Ok(()) -} \ No newline at end of file +}