From 690af291b553c05a5b92df0cda3a5a97c8287ea6 Mon Sep 17 00:00:00 2001 From: despiegk Date: Mon, 1 Dec 2025 20:53:20 +0100 Subject: [PATCH] ... --- aiprompts/v_core/orm/orm.md | 133 +++---- aiprompts/v_core/orm/orm_cheat.md | 282 ++++++++++++++ lib/hero/db/core_models.v | 4 +- lib/hero/db/decode.v | 11 + .../grid3/deploy_tosort/deployment.v | 0 .../grid3/deployer/.heroscript | 0 .../grid3/deployer/contracts.v | 0 .../grid3/deployer/deployer.v | 0 .../grid3/deployer/deployer_factory_.v | 0 .../grid3/deployer/deployer_model.v | 0 .../grid3/deployer/deployment.v | 0 .../grid3/deployer/deployment_setup.v | 0 .../grid3/deployer/filter.v | 0 .../grid3/deployer/kvstore.v | 0 .../grid3/deployer/network.v | 0 .../grid3/deployer/readme.md | 0 .../grid3/deployer/rmb.v | 0 .../grid3/deployer/utils.v | 0 .../grid3/deployer/vmachine.v | 0 .../grid3/deployer/webnames.v | 0 .../grid3/deployer/zdbs.v | 0 .../grid3/deployer2_sort/README.md | 0 .../grid3/deployer2_sort/deployment_state.v | 0 .../grid3/deployer2_sort/factory.v | 0 .../grid3/deployer2_sort/graphql.v | 0 .../grid3/deployer2_sort/vm.v | 0 .../grid3/deployer2_sort/vm_test.v | 0 .../grid3/deployer2_sort/zdb.v | 0 .../grid3/griddriver/client.v | 0 .../grid3/griddriver/rmb.v | 0 .../grid3/griddriver/substrate.v | 0 .../grid3/griddriver/utils.v | 0 .../grid3/gridproxy/README.md | 0 .../grid3/gridproxy/gridproxy_core.v | 0 .../grid3/gridproxy/gridproxy_factory.v | 0 .../grid3/gridproxy/gridproxy_highlevel.v | 0 .../grid3/gridproxy/gridproxy_test.v | 0 .../grid3/gridproxy/model/contract.v | 0 .../grid3/gridproxy/model/farm.v | 0 .../grid3/gridproxy/model/filter.v | 0 .../grid3/gridproxy/model/iterators.v | 0 .../grid3/gridproxy/model/model.v | 0 .../grid3/gridproxy/model/node.v | 0 .../grid3/gridproxy/model/stats.v | 0 .../grid3/gridproxy/model/twin.v | 0 .../grid3/models/computecapacity.v | 0 .../grid3/models/deployment.v | 0 .../grid3/models/gw_fqdn.v | 0 .../grid3/models/gw_name.v | 0 lib/{threefold => mycelium}/grid3/models/ip.v | 0 .../grid3/models/qsfs_notimplemented.v | 0 .../grid3/models/workload.v | 0 .../grid3/models/zdb.v | 0 .../grid3/models/zlogs.v | 0 .../grid3/models/zmachine.v | 0 .../grid3/models/zmount.v | 0 .../grid3/models/znet.v | 0 .../grid3/rmb/model_rmb.v | 0 .../grid3/rmb/readme.md | 0 .../grid3/rmb/rmb_calls_zos.v | 0 .../grid3/rmb/rmb_calls_zos_statistics.v | 0 .../grid3/rmb/rmb_calls_zos_storagepools.v | 0 .../grid3/rmb/rmb_client.v | 0 .../grid3/rmb/rmb_request.v | 0 .../grid3/rmb/rmb_test.v | 0 .../grid3/tfrobot/README.md | 0 .../grid3/tfrobot/cancel.v | 0 .../grid3/tfrobot/cancel_test.v | 0 .../grid3/tfrobot/deploy.v | 0 .../grid3/tfrobot/deploy_test.v | 0 .../grid3/tfrobot/factory.v | 0 .../grid3/tfrobot/factory_test.v | 0 .../grid3/tfrobot/job.v | 0 .../grid3/tfrobot/job_test.v | 0 .../grid3/tfrobot/templates/config.json | 0 .../grid3/tfrobot/templates/config.yaml | 0 .../grid3/tfrobot/tfrobot_redis.v | 0 .../grid3/tfrobot/vm.v | 0 .../grid3/tfrobot/vm_deploy.v | 0 .../grid3/tfrobot/vm_deploy_test.v | 0 .../grid3/tokens/readme.md | 0 .../grid3/tokens/tokens_fetch.v | 0 .../grid3/zerohub/flist.v | 0 .../grid3/zerohub/readme.md | 0 .../grid3/zerohub/zerohub.v | 0 .../grid3/zerohub/zerohub_test.v | 0 .../grid4/datamodel/README.md | 0 .../grid4/datamodel/model_bid.v | 0 .../grid4/datamodel/model_node.v | 0 .../grid4/datamodel/model_nodegroup.v | 0 .../grid4/datamodel/model_reservation.v | 0 .../grid4/datamodel/play.v | 0 .../grid4/datamodelsimulator/README.md | 0 .../grid4/datamodelsimulator/loader.v | 0 .../datamodelsimulator/model_aggregated.v | 0 .../datamodelsimulator/model_simulations.v | 0 .../grid4/datamodelsimulator/play.v | 0 .../grid4/farmingsimulator/factory.v | 0 .../grid4/farmingsimulator/model_capacity.v | 0 .../grid4/farmingsimulator/model_nodesbatch.v | 0 .../farmingsimulator/model_nodetemplate.v | 0 .../grid4/farmingsimulator/model_params.v | 0 .../farmingsimulator/model_regionalinternet.v | 0 .../grid4/farmingsimulator/model_simulator.v | 0 .../grid4/farmingsimulator/play.v | 0 .../grid4/farmingsimulator/playmacro.v | 0 .../templates/node_template.md | 0 .../templates/regionalinternet_template.md | 0 .../farmingsimulator/token_cultivation.v | 0 .../grid4/farmingsimulator/token_farming.v | 0 .../grid4/farmingsimulator/wiki.v | 0 .../grid4/gridsimulator/factory.v | 0 .../grid4/gridsimulator/manual/.collection | 0 .../grid4/gridsimulator/manual/home.md | 0 .../grid4/gridsimulator/manual/macros.md | 0 .../grid4/gridsimulator/play.v | 0 .../grid4/gridsimulator/readme.md | 0 lib/{threefold => mycelium}/incatokens/amm.v | 0 .../incatokens/amm_test.v | 0 .../incatokens/auction.v | 0 .../incatokens/auction_test.v | 0 .../incatokens/charts.v | 0 .../incatokens/export.v | 0 .../incatokens/factory.v | 0 .../incatokens/incatokens_test.v | 0 .../incatokens/params.v | 0 lib/{threefold => mycelium}/incatokens/play.v | 0 .../incatokens/readme.md | 0 .../incatokens/simulation.v | 0 .../incatokens/templates/report copy.md | 0 .../incatokens/templates/report.md | 0 .../incatokens/types.v | 0 .../incatokens/vesting.v | 0 .../models_ledger/account.v | 83 +---- lib/mycelium/models_ledger/account_model.v | 77 ++++ .../models_ledger/account_test.v | 0 .../models_ledger/asset.v | 8 +- .../models_ledger/asset_test.v | 2 +- .../models_ledger/dnszone.v | 0 .../models_ledger/dnszone_test.v | 0 .../models_ledger/group.v | 0 .../models_ledger/member.v | 0 .../models_ledger/models_factory.v | 0 .../models_ledger/notary.v | 0 .../models_ledger/signature.v | 0 .../models_ledger/test_utils.v | 0 .../models_ledger/transaction.v | 8 +- .../models_ledger/user.v | 0 .../models_ledger/userkvs.v | 0 .../models_ledger/userkvsitem.v | 2 - .../models_tfgrid/bid.v | 0 .../models_tfgrid/contract.v | 0 .../models_tfgrid/models_tfgrid_test.v | 0 .../models_tfgrid/node.v | 0 .../models_tfgrid/nodegroup.v | 0 .../models_tfgrid/readme.md | 0 .../models_tfgrid/reputation.v | 0 .../models_to_move/README.md | 0 .../models_to_move/ai_instruction.md | 0 .../models_to_move/business/company.v | 0 .../models_to_move/business/payment.v | 0 .../models_to_move/business/product.v | 0 .../models_to_move/business/sale.v | 0 .../models_to_move/finance/account.v | 0 .../models_to_move/finance/asset.v | 0 .../models_to_move/finance/marketplace.v | 0 .../models_to_move/flow/flow.v | 0 .../models_to_move/flow/flow_step.v | 0 .../flow/signature_requirement.v | 0 .../models_to_move/identity/kyc.v | 0 .../models_to_move/legal/contract.v | 0 .../models_to_move/library/collection.v | 0 .../models_to_move/library/items.v | 0 .../models_to_move/location/address.v | 0 .../models_to_move/payment/stripe.v | 0 lib/threefold/models_ledger/.goosehints | 14 - lib/threefold/models_ledger/README_TESTS.md | 181 --------- lib/threefold/models_ledger/fix.md | 346 ------------------ .../models_ledger/implementation_summary.md | 105 ------ lib/web/doctree/client/model.v | 10 + lib/web/doctree/core/collection_process.v | 15 + lib/web/doctree/core/export.v | 1 + lib/web/doctree/core/page.v | 11 +- lib/web/doctree/meta/model_page.v | 20 +- lib/web/doctree/meta/utils.v | 2 - 185 files changed, 466 insertions(+), 849 deletions(-) create mode 100644 aiprompts/v_core/orm/orm_cheat.md rename lib/{threefold => mycelium}/grid3/deploy_tosort/deployment.v (100%) rename lib/{threefold => mycelium}/grid3/deployer/.heroscript (100%) rename lib/{threefold => mycelium}/grid3/deployer/contracts.v (100%) rename lib/{threefold => mycelium}/grid3/deployer/deployer.v (100%) rename lib/{threefold => mycelium}/grid3/deployer/deployer_factory_.v (100%) rename lib/{threefold => mycelium}/grid3/deployer/deployer_model.v (100%) rename lib/{threefold => mycelium}/grid3/deployer/deployment.v (100%) rename lib/{threefold => mycelium}/grid3/deployer/deployment_setup.v (100%) rename lib/{threefold => mycelium}/grid3/deployer/filter.v (100%) rename lib/{threefold => mycelium}/grid3/deployer/kvstore.v (100%) rename lib/{threefold => mycelium}/grid3/deployer/network.v (100%) rename lib/{threefold => mycelium}/grid3/deployer/readme.md (100%) rename lib/{threefold => mycelium}/grid3/deployer/rmb.v (100%) rename lib/{threefold => mycelium}/grid3/deployer/utils.v (100%) rename lib/{threefold => mycelium}/grid3/deployer/vmachine.v (100%) rename lib/{threefold => mycelium}/grid3/deployer/webnames.v (100%) rename lib/{threefold => mycelium}/grid3/deployer/zdbs.v (100%) rename lib/{threefold => mycelium}/grid3/deployer2_sort/README.md (100%) rename lib/{threefold => mycelium}/grid3/deployer2_sort/deployment_state.v (100%) rename lib/{threefold => mycelium}/grid3/deployer2_sort/factory.v (100%) rename lib/{threefold => mycelium}/grid3/deployer2_sort/graphql.v (100%) rename lib/{threefold => mycelium}/grid3/deployer2_sort/vm.v (100%) rename lib/{threefold => mycelium}/grid3/deployer2_sort/vm_test.v (100%) rename lib/{threefold => mycelium}/grid3/deployer2_sort/zdb.v (100%) rename lib/{threefold => mycelium}/grid3/griddriver/client.v (100%) rename lib/{threefold => mycelium}/grid3/griddriver/rmb.v (100%) rename lib/{threefold => mycelium}/grid3/griddriver/substrate.v (100%) rename lib/{threefold => mycelium}/grid3/griddriver/utils.v (100%) rename lib/{threefold => mycelium}/grid3/gridproxy/README.md (100%) rename lib/{threefold => mycelium}/grid3/gridproxy/gridproxy_core.v (100%) rename lib/{threefold => mycelium}/grid3/gridproxy/gridproxy_factory.v (100%) rename lib/{threefold => mycelium}/grid3/gridproxy/gridproxy_highlevel.v (100%) rename lib/{threefold => mycelium}/grid3/gridproxy/gridproxy_test.v (100%) rename lib/{threefold => mycelium}/grid3/gridproxy/model/contract.v (100%) rename lib/{threefold => mycelium}/grid3/gridproxy/model/farm.v (100%) rename lib/{threefold => mycelium}/grid3/gridproxy/model/filter.v (100%) rename lib/{threefold => mycelium}/grid3/gridproxy/model/iterators.v (100%) rename lib/{threefold => mycelium}/grid3/gridproxy/model/model.v (100%) rename lib/{threefold => mycelium}/grid3/gridproxy/model/node.v (100%) rename lib/{threefold => mycelium}/grid3/gridproxy/model/stats.v (100%) rename lib/{threefold => mycelium}/grid3/gridproxy/model/twin.v (100%) rename lib/{threefold => mycelium}/grid3/models/computecapacity.v (100%) rename lib/{threefold => mycelium}/grid3/models/deployment.v (100%) rename lib/{threefold => mycelium}/grid3/models/gw_fqdn.v (100%) rename lib/{threefold => mycelium}/grid3/models/gw_name.v (100%) rename lib/{threefold => mycelium}/grid3/models/ip.v (100%) rename lib/{threefold => mycelium}/grid3/models/qsfs_notimplemented.v (100%) rename lib/{threefold => mycelium}/grid3/models/workload.v (100%) rename lib/{threefold => mycelium}/grid3/models/zdb.v (100%) rename lib/{threefold => mycelium}/grid3/models/zlogs.v (100%) rename lib/{threefold => mycelium}/grid3/models/zmachine.v (100%) rename lib/{threefold => mycelium}/grid3/models/zmount.v (100%) rename lib/{threefold => mycelium}/grid3/models/znet.v (100%) rename lib/{threefold => mycelium}/grid3/rmb/model_rmb.v (100%) rename lib/{threefold => mycelium}/grid3/rmb/readme.md (100%) rename lib/{threefold => mycelium}/grid3/rmb/rmb_calls_zos.v (100%) rename lib/{threefold => mycelium}/grid3/rmb/rmb_calls_zos_statistics.v (100%) rename lib/{threefold => mycelium}/grid3/rmb/rmb_calls_zos_storagepools.v (100%) rename lib/{threefold => mycelium}/grid3/rmb/rmb_client.v (100%) rename lib/{threefold => mycelium}/grid3/rmb/rmb_request.v (100%) rename lib/{threefold => mycelium}/grid3/rmb/rmb_test.v (100%) rename lib/{threefold => mycelium}/grid3/tfrobot/README.md (100%) rename lib/{threefold => mycelium}/grid3/tfrobot/cancel.v (100%) rename lib/{threefold => mycelium}/grid3/tfrobot/cancel_test.v (100%) rename lib/{threefold => mycelium}/grid3/tfrobot/deploy.v (100%) rename lib/{threefold => mycelium}/grid3/tfrobot/deploy_test.v (100%) rename lib/{threefold => mycelium}/grid3/tfrobot/factory.v (100%) rename lib/{threefold => mycelium}/grid3/tfrobot/factory_test.v (100%) rename lib/{threefold => mycelium}/grid3/tfrobot/job.v (100%) rename lib/{threefold => mycelium}/grid3/tfrobot/job_test.v (100%) rename lib/{threefold => mycelium}/grid3/tfrobot/templates/config.json (100%) rename lib/{threefold => mycelium}/grid3/tfrobot/templates/config.yaml (100%) rename lib/{threefold => mycelium}/grid3/tfrobot/tfrobot_redis.v (100%) rename lib/{threefold => mycelium}/grid3/tfrobot/vm.v (100%) rename lib/{threefold => mycelium}/grid3/tfrobot/vm_deploy.v (100%) rename lib/{threefold => mycelium}/grid3/tfrobot/vm_deploy_test.v (100%) rename lib/{threefold => mycelium}/grid3/tokens/readme.md (100%) rename lib/{threefold => mycelium}/grid3/tokens/tokens_fetch.v (100%) rename lib/{threefold => mycelium}/grid3/zerohub/flist.v (100%) rename lib/{threefold => mycelium}/grid3/zerohub/readme.md (100%) rename lib/{threefold => mycelium}/grid3/zerohub/zerohub.v (100%) rename lib/{threefold => mycelium}/grid3/zerohub/zerohub_test.v (100%) rename lib/{threefold => mycelium}/grid4/datamodel/README.md (100%) rename lib/{threefold => mycelium}/grid4/datamodel/model_bid.v (100%) rename lib/{threefold => mycelium}/grid4/datamodel/model_node.v (100%) rename lib/{threefold => mycelium}/grid4/datamodel/model_nodegroup.v (100%) rename lib/{threefold => mycelium}/grid4/datamodel/model_reservation.v (100%) rename lib/{threefold => mycelium}/grid4/datamodel/play.v (100%) rename lib/{threefold => mycelium}/grid4/datamodelsimulator/README.md (100%) rename lib/{threefold => mycelium}/grid4/datamodelsimulator/loader.v (100%) rename lib/{threefold => mycelium}/grid4/datamodelsimulator/model_aggregated.v (100%) rename lib/{threefold => mycelium}/grid4/datamodelsimulator/model_simulations.v (100%) rename lib/{threefold => mycelium}/grid4/datamodelsimulator/play.v (100%) rename lib/{threefold => mycelium}/grid4/farmingsimulator/factory.v (100%) rename lib/{threefold => mycelium}/grid4/farmingsimulator/model_capacity.v (100%) rename lib/{threefold => mycelium}/grid4/farmingsimulator/model_nodesbatch.v (100%) rename lib/{threefold => mycelium}/grid4/farmingsimulator/model_nodetemplate.v (100%) rename lib/{threefold => mycelium}/grid4/farmingsimulator/model_params.v (100%) rename lib/{threefold => mycelium}/grid4/farmingsimulator/model_regionalinternet.v (100%) rename lib/{threefold => mycelium}/grid4/farmingsimulator/model_simulator.v (100%) rename lib/{threefold => mycelium}/grid4/farmingsimulator/play.v (100%) rename lib/{threefold => mycelium}/grid4/farmingsimulator/playmacro.v (100%) rename lib/{threefold => mycelium}/grid4/farmingsimulator/templates/node_template.md (100%) rename lib/{threefold => mycelium}/grid4/farmingsimulator/templates/regionalinternet_template.md (100%) rename lib/{threefold => mycelium}/grid4/farmingsimulator/token_cultivation.v (100%) rename lib/{threefold => mycelium}/grid4/farmingsimulator/token_farming.v (100%) rename lib/{threefold => mycelium}/grid4/farmingsimulator/wiki.v (100%) rename lib/{threefold => mycelium}/grid4/gridsimulator/factory.v (100%) rename lib/{threefold => mycelium}/grid4/gridsimulator/manual/.collection (100%) rename lib/{threefold => mycelium}/grid4/gridsimulator/manual/home.md (100%) rename lib/{threefold => mycelium}/grid4/gridsimulator/manual/macros.md (100%) rename lib/{threefold => mycelium}/grid4/gridsimulator/play.v (100%) rename lib/{threefold => mycelium}/grid4/gridsimulator/readme.md (100%) rename lib/{threefold => mycelium}/incatokens/amm.v (100%) rename lib/{threefold => mycelium}/incatokens/amm_test.v (100%) rename lib/{threefold => mycelium}/incatokens/auction.v (100%) rename lib/{threefold => mycelium}/incatokens/auction_test.v (100%) rename lib/{threefold => mycelium}/incatokens/charts.v (100%) rename lib/{threefold => mycelium}/incatokens/export.v (100%) rename lib/{threefold => mycelium}/incatokens/factory.v (100%) rename lib/{threefold => mycelium}/incatokens/incatokens_test.v (100%) rename lib/{threefold => mycelium}/incatokens/params.v (100%) rename lib/{threefold => mycelium}/incatokens/play.v (100%) rename lib/{threefold => mycelium}/incatokens/readme.md (100%) rename lib/{threefold => mycelium}/incatokens/simulation.v (100%) rename lib/{threefold => mycelium}/incatokens/templates/report copy.md (100%) rename lib/{threefold => mycelium}/incatokens/templates/report.md (100%) rename lib/{threefold => mycelium}/incatokens/types.v (100%) rename lib/{threefold => mycelium}/incatokens/vesting.v (100%) rename lib/{threefold => mycelium}/models_ledger/account.v (83%) create mode 100644 lib/mycelium/models_ledger/account_model.v rename lib/{threefold => mycelium}/models_ledger/account_test.v (100%) rename lib/{threefold => mycelium}/models_ledger/asset.v (98%) rename lib/{threefold => mycelium}/models_ledger/asset_test.v (99%) rename lib/{threefold => mycelium}/models_ledger/dnszone.v (100%) rename lib/{threefold => mycelium}/models_ledger/dnszone_test.v (100%) rename lib/{threefold => mycelium}/models_ledger/group.v (100%) rename lib/{threefold => mycelium}/models_ledger/member.v (100%) rename lib/{threefold => mycelium}/models_ledger/models_factory.v (100%) rename lib/{threefold => mycelium}/models_ledger/notary.v (100%) rename lib/{threefold => mycelium}/models_ledger/signature.v (100%) rename lib/{threefold => mycelium}/models_ledger/test_utils.v (100%) rename lib/{threefold => mycelium}/models_ledger/transaction.v (98%) rename lib/{threefold => mycelium}/models_ledger/user.v (100%) rename lib/{threefold => mycelium}/models_ledger/userkvs.v (100%) rename lib/{threefold => mycelium}/models_ledger/userkvsitem.v (98%) rename lib/{threefold => mycelium}/models_tfgrid/bid.v (100%) rename lib/{threefold => mycelium}/models_tfgrid/contract.v (100%) rename lib/{threefold => mycelium}/models_tfgrid/models_tfgrid_test.v (100%) rename lib/{threefold => mycelium}/models_tfgrid/node.v (100%) rename lib/{threefold => mycelium}/models_tfgrid/nodegroup.v (100%) rename lib/{threefold => mycelium}/models_tfgrid/readme.md (100%) rename lib/{threefold => mycelium}/models_tfgrid/reputation.v (100%) rename lib/{threefold => mycelium}/models_to_move/README.md (100%) rename lib/{threefold => mycelium}/models_to_move/ai_instruction.md (100%) rename lib/{threefold => mycelium}/models_to_move/business/company.v (100%) rename lib/{threefold => mycelium}/models_to_move/business/payment.v (100%) rename lib/{threefold => mycelium}/models_to_move/business/product.v (100%) rename lib/{threefold => mycelium}/models_to_move/business/sale.v (100%) rename lib/{threefold => mycelium}/models_to_move/finance/account.v (100%) rename lib/{threefold => mycelium}/models_to_move/finance/asset.v (100%) rename lib/{threefold => mycelium}/models_to_move/finance/marketplace.v (100%) rename lib/{threefold => mycelium}/models_to_move/flow/flow.v (100%) rename lib/{threefold => mycelium}/models_to_move/flow/flow_step.v (100%) rename lib/{threefold => mycelium}/models_to_move/flow/signature_requirement.v (100%) rename lib/{threefold => mycelium}/models_to_move/identity/kyc.v (100%) rename lib/{threefold => mycelium}/models_to_move/legal/contract.v (100%) rename lib/{threefold => mycelium}/models_to_move/library/collection.v (100%) rename lib/{threefold => mycelium}/models_to_move/library/items.v (100%) rename lib/{threefold => mycelium}/models_to_move/location/address.v (100%) rename lib/{threefold => mycelium}/models_to_move/payment/stripe.v (100%) delete mode 100644 lib/threefold/models_ledger/.goosehints delete mode 100644 lib/threefold/models_ledger/README_TESTS.md delete mode 100644 lib/threefold/models_ledger/fix.md delete mode 100644 lib/threefold/models_ledger/implementation_summary.md delete mode 100644 lib/web/doctree/meta/utils.v diff --git a/aiprompts/v_core/orm/orm.md b/aiprompts/v_core/orm/orm.md index a53b8fac..77617d3a 100644 --- a/aiprompts/v_core/orm/orm.md +++ b/aiprompts/v_core/orm/orm.md @@ -1,51 +1,10 @@ # module orm - -## Contents -- [Constants](#Constants) -- [new_query](#new_query) -- [orm_select_gen](#orm_select_gen) -- [orm_stmt_gen](#orm_stmt_gen) -- [orm_table_gen](#orm_table_gen) -- [Connection](#Connection) -- [Primitive](#Primitive) -- [QueryBuilder[T]](#QueryBuilder[T]) - - [reset](#reset) - - [where](#where) - - [or_where](#or_where) - - [order](#order) - - [limit](#limit) - - [offset](#offset) - - [select](#select) - - [set](#set) - - [query](#query) - - [count](#count) - - [insert](#insert) - - [insert_many](#insert_many) - - [update](#update) - - [delete](#delete) - - [create](#create) - - [drop](#drop) - - [last_id](#last_id) -- [MathOperationKind](#MathOperationKind) -- [OperationKind](#OperationKind) -- [OrderType](#OrderType) -- [SQLDialect](#SQLDialect) -- [StmtKind](#StmtKind) -- [InfixType](#InfixType) -- [Null](#Null) -- [QueryBuilder](#QueryBuilder) -- [QueryData](#QueryData) -- [SelectConfig](#SelectConfig) -- [Table](#Table) -- [TableField](#TableField) - -## Constants ```v const num64 = [typeof[i64]().idx, typeof[u64]().idx] ``` -[[Return to contents]](#Contents) + ```v const nums = [ @@ -59,7 +18,7 @@ const nums = [ ] ``` -[[Return to contents]](#Contents) + ```v const float = [ @@ -68,31 +27,31 @@ const float = [ ] ``` -[[Return to contents]](#Contents) + ```v const type_string = typeof[string]().idx ``` -[[Return to contents]](#Contents) + ```v const serial = -1 ``` -[[Return to contents]](#Contents) + ```v const time_ = -2 ``` -[[Return to contents]](#Contents) + ```v const enum_ = -3 ``` -[[Return to contents]](#Contents) + ```v const type_idx = { @@ -111,19 +70,19 @@ const type_idx = { } ``` -[[Return to contents]](#Contents) + ```v const string_max_len = 2048 ``` -[[Return to contents]](#Contents) + ```v const null_primitive = Primitive(Null{}) ``` -[[Return to contents]](#Contents) + ## new_query ```v @@ -132,7 +91,7 @@ fn new_query[T](conn Connection) &QueryBuilder[T] new_query create a new query object for struct `T` -[[Return to contents]](#Contents) + ## orm_select_gen ```v @@ -141,7 +100,7 @@ fn orm_select_gen(cfg SelectConfig, q string, num bool, qm string, start_pos int Generates an sql select stmt, from universal parameter orm - See SelectConfig q, num, qm, start_pos - see orm_stmt_gen where - See QueryData -[[Return to contents]](#Contents) + ## orm_stmt_gen ```v @@ -151,7 +110,7 @@ fn orm_stmt_gen(sql_dialect SQLDialect, table Table, q string, kind StmtKind, nu Generates an sql stmt, from universal parameter q - The quotes character, which can be different in every type, so it's variable num - Stmt uses nums at prepared statements (? or ?1) qm - Character for prepared statement (qm for question mark, as in sqlite) start_pos - When num is true, it's the start position of the counter -[[Return to contents]](#Contents) + ## orm_table_gen ```v @@ -161,7 +120,7 @@ fn orm_table_gen(sql_dialect SQLDialect, table Table, q string, defaults bool, d Generates an sql table stmt, from universal parameter table - Table struct q - see orm_stmt_gen defaults - enables default values in stmt def_unique_len - sets default unique length for texts fields - See TableField sql_from_v - Function which maps type indices to sql type names alternative - Needed for msdb -[[Return to contents]](#Contents) + ## Connection ```v @@ -181,7 +140,7 @@ Interfaces gets called from the backend and can be implemented Since the orm sup Every function without last_id() returns an optional, which returns an error if present last_id returns the last inserted id of the db -[[Return to contents]](#Contents) + ## Primitive ```v @@ -203,7 +162,7 @@ type Primitive = InfixType | []Primitive ``` -[[Return to contents]](#Contents) + ## QueryBuilder[T] ## reset @@ -213,7 +172,7 @@ fn (qb_ &QueryBuilder[T]) reset() &QueryBuilder[T] reset reset a query object, but keep the connection and table name -[[Return to contents]](#Contents) + ## where ```v @@ -222,7 +181,7 @@ fn (qb_ &QueryBuilder[T]) where(condition string, params ...Primitive) !&QueryBu where create a `where` clause, it will `AND` with previous `where` clause. valid token in the `condition` include: `field's names`, `operator`, `(`, `)`, `?`, `AND`, `OR`, `||`, `&&`, valid `operator` incldue: `=`, `!=`, `<>`, `>=`, `<=`, `>`, `<`, `LIKE`, `ILIKE`, `IS NULL`, `IS NOT NULL`, `IN`, `NOT IN` example: `where('(a > ? AND b <= ?) OR (c <> ? AND (x = ? OR y = ?))', a, b, c, x, y)` -[[Return to contents]](#Contents) + ## or_where ```v @@ -231,7 +190,7 @@ fn (qb_ &QueryBuilder[T]) or_where(condition string, params ...Primitive) !&Quer or_where create a `where` clause, it will `OR` with previous `where` clause. -[[Return to contents]](#Contents) + ## order ```v @@ -240,7 +199,7 @@ fn (qb_ &QueryBuilder[T]) order(order_type OrderType, field string) !&QueryBuild order create a `order` clause -[[Return to contents]](#Contents) + ## limit ```v @@ -249,7 +208,7 @@ fn (qb_ &QueryBuilder[T]) limit(limit int) !&QueryBuilder[T] limit create a `limit` clause -[[Return to contents]](#Contents) + ## offset ```v @@ -258,7 +217,7 @@ fn (qb_ &QueryBuilder[T]) offset(offset int) !&QueryBuilder[T] offset create a `offset` clause -[[Return to contents]](#Contents) + ## select ```v @@ -267,7 +226,7 @@ fn (qb_ &QueryBuilder[T]) select(fields ...string) !&QueryBuilder[T] select create a `select` clause -[[Return to contents]](#Contents) + ## set ```v @@ -276,7 +235,7 @@ fn (qb_ &QueryBuilder[T]) set(assign string, values ...Primitive) !&QueryBuilder set create a `set` clause for `update` -[[Return to contents]](#Contents) + ## query ```v @@ -285,7 +244,7 @@ fn (qb_ &QueryBuilder[T]) query() ![]T query start a query and return result in struct `T` -[[Return to contents]](#Contents) + ## count ```v @@ -294,7 +253,7 @@ fn (qb_ &QueryBuilder[T]) count() !int count start a count query and return result -[[Return to contents]](#Contents) + ## insert ```v @@ -303,7 +262,7 @@ fn (qb_ &QueryBuilder[T]) insert[T](value T) !&QueryBuilder[T] insert insert a record into the database -[[Return to contents]](#Contents) + ## insert_many ```v @@ -312,7 +271,7 @@ fn (qb_ &QueryBuilder[T]) insert_many[T](values []T) !&QueryBuilder[T] insert_many insert records into the database -[[Return to contents]](#Contents) + ## update ```v @@ -321,7 +280,7 @@ fn (qb_ &QueryBuilder[T]) update() !&QueryBuilder[T] update update record(s) in the database -[[Return to contents]](#Contents) + ## delete ```v @@ -330,7 +289,7 @@ fn (qb_ &QueryBuilder[T]) delete() !&QueryBuilder[T] delete delete record(s) in the database -[[Return to contents]](#Contents) + ## create ```v @@ -339,7 +298,7 @@ fn (qb_ &QueryBuilder[T]) create() !&QueryBuilder[T] create create a table -[[Return to contents]](#Contents) + ## drop ```v @@ -348,7 +307,7 @@ fn (qb_ &QueryBuilder[T]) drop() !&QueryBuilder[T] drop drop a table -[[Return to contents]](#Contents) + ## last_id ```v @@ -357,7 +316,7 @@ fn (qb_ &QueryBuilder[T]) last_id() int last_id returns the last inserted id of the db -[[Return to contents]](#Contents) + ## MathOperationKind ```v @@ -369,7 +328,7 @@ enum MathOperationKind { } ``` -[[Return to contents]](#Contents) + ## OperationKind ```v @@ -389,7 +348,7 @@ enum OperationKind { } ``` -[[Return to contents]](#Contents) + ## OrderType ```v @@ -399,7 +358,7 @@ enum OrderType { } ``` -[[Return to contents]](#Contents) + ## SQLDialect ```v @@ -411,7 +370,7 @@ enum SQLDialect { } ``` -[[Return to contents]](#Contents) + ## StmtKind ```v @@ -422,7 +381,7 @@ enum StmtKind { } ``` -[[Return to contents]](#Contents) + ## InfixType ```v @@ -434,14 +393,14 @@ pub: } ``` -[[Return to contents]](#Contents) + ## Null ```v struct Null {} ``` -[[Return to contents]](#Contents) + ## QueryBuilder ```v @@ -456,7 +415,7 @@ pub mut: } ``` -[[Return to contents]](#Contents) + ## QueryData ```v @@ -474,7 +433,7 @@ pub mut: Examples for QueryData in SQL: abc == 3 && b == 'test' => fields[abc, b]; data[3, 'test']; types[index of int, index of string]; kinds[.eq, .eq]; is_and[true]; Every field, data, type & kind of operation in the expr share the same index in the arrays is_and defines how they're addicted to each other either and or or parentheses defines which fields will be inside () auto_fields are indexes of fields where db should generate a value when absent in an insert -[[Return to contents]](#Contents) + ## SelectConfig ```v @@ -496,7 +455,7 @@ pub mut: table - Table struct is_count - Either the data will be returned or an integer with the count has_where - Select all or use a where expr has_order - Order the results order - Name of the column which will be ordered order_type - Type of order (asc, desc) has_limit - Limits the output data primary - Name of the primary field has_offset - Add an offset to the result fields - Fields to select types - Types to select -[[Return to contents]](#Contents) + ## Table ```v @@ -507,7 +466,7 @@ pub mut: } ``` -[[Return to contents]](#Contents) + ## TableField ```v @@ -521,7 +480,3 @@ pub mut: is_arr bool } ``` - -[[Return to contents]](#Contents) - -#### Powered by vdoc. Generated on: 2 Sep 2025 07:19:37 diff --git a/aiprompts/v_core/orm/orm_cheat.md b/aiprompts/v_core/orm/orm_cheat.md new file mode 100644 index 00000000..60c26762 --- /dev/null +++ b/aiprompts/v_core/orm/orm_cheat.md @@ -0,0 +1,282 @@ + +# V ORM — Developer Cheat Sheet + +*Fast reference for Struct Mapping, CRUD, Attributes, Query Builder, and Usage Patterns* + +--- + +## 1. What V ORM Is + +* Built-in ORM for **SQLite**, **MySQL**, **PostgreSQL** +* Unified V-syntax; no SQL string building +* Automatic query sanitization +* Compile-time type & field checks +* Structs map directly to tables + +--- + +## 2. Define Models (Struct ↔ Table) + +### Basic Example + +```v +struct User { + id int @[primary; sql: serial] + name string + email string @[unique] +} +``` + +### Nullable Fields + +```v +age ?int // allows NULL +``` + +--- + +## 3. Struct Attributes + +### Table-level + +| Attribute | Meaning | +| ---------------------------- | ------------------------- | +| `@[table: 'custom_name']` | Override table name | +| `@[comment: '...']` | Table comment | +| `@[index: 'field1, field2']` | Creates multi-field index | + +--- + +## 4. Field Attributes + +| Attribute | Description | +| ------------------------------------------------ | ---------------------------- | +| `@[primary]` | Primary key | +| `@[unique]` | UNIQUE constraint | +| `@[unique: 'group']` | Composite unique group | +| `@[skip]` / `@[sql: '-']` | Ignore field | +| `@[sql: serial]` | Auto-increment key | +| `@[sql: 'col_name']` | Rename column | +| `@[sql_type: 'BIGINT']` | Force SQL type | +| `@[default: 'CURRENT_TIMESTAMP']` | Raw SQL default | +| `@[fkey: 'field']` | Foreign key on a child array | +| `@[references]`, `@[references: 'table(field)']` | FK relationship | +| `@[index]` | Index on field | +| `@[comment: '...']` | Column comment | + +### Example + +```v +struct Post { + id int @[primary; sql: serial] + title string + body string + author_id int @[references: 'users(id)'] +} +``` + +--- + +## 5. ORM SQL Block (Primary API) + +### Create Table + +```v +sql db { + create table User +}! +``` + +### Drop Table + +```v +sql db { + drop table User +}! +``` + +### Insert + +```v +id := sql db { + insert new_user into User +}! +``` + +### Select + +```v +users := sql db { + select from User where age > 18 && name != 'Tom' + order by id desc + limit 10 +}! +``` + +### Update + +```v +sql db { + update User set name = 'Alice' where id == 1 +}! +``` + +### Delete + +```v +sql db { + delete from User where id > 100 +}! +``` + +--- + +## 6. Relationships + +### One-to-Many + +```v +struct Parent { + id int @[primary; sql: serial] + children []Child @[fkey: 'parent_id'] +} + +struct Child { + id int @[primary; sql: serial] + parent_id int +} +``` + +--- + +## 7. Notes on `time.Time` + +* Stored as integer timestamps +* SQL defaults like `NOW()` / `CURRENT_TIMESTAMP` **don’t work** for `time.Time` with V ORM defaults +* Use `@[default: 'CURRENT_TIMESTAMP']` only with custom SQL types + +--- + +## 8. Query Builder API (Dynamic Queries) + +### Create Builder + +```v +mut qb := orm.new_query[User](db) +``` + +### Create Table + +```v +qb.create()! +``` + +### Insert Many + +```v +qb.insert_many(users)! +``` + +### Select + +```v +results := qb + .select('id, name')! + .where('age > ?', 18)! + .order('id DESC')! + .limit(20)! + .query()! +``` + +### Update + +```v +qb + .set('name = ?', 'NewName')! + .where('id = ?', 1)! + .update()! +``` + +### Delete + +```v +qb.where('created_at IS NULL')!.delete()! +``` + +### Complex WHERE + +```v +qb.where( + '(salary > ? AND age < ?) OR (role LIKE ?)', + 3000, 40, '%engineer%' +)! +``` + +--- + +## 9. Connecting to Databases + +### SQLite + +```v +import db.sqlite +db := sqlite.connect('db.sqlite')! +``` + +### MySQL + +```v +import db.mysql +db := mysql.connect(host: 'localhost', user: 'root', password: '', dbname: 'test')! +``` + +### PostgreSQL + +```v +import db.pg +db := pg.connect(conn_str)! +``` + +--- + +## 10. Full Example (Complete CRUD) + +```v +import db.sqlite + +struct Customer { + id int @[primary; sql: serial] + name string + email string @[unique] +} + +fn main() { + db := sqlite.connect('customers.db')! + + sql db { create table Customer }! + + new_c := Customer{name: 'Alice', email: 'alice@x.com'} + + id := sql db { insert new_c into Customer }! + println(id) + + list := sql db { select from Customer where name == 'Alice' }! + println(list) + + sql db { update Customer set name = 'Alicia' where id == id }! + + sql db { delete from Customer where id == id }! +} +``` + +--- + +## 11. Best Practices + +* Always use `sql db { ... }` for static queries +* Use QueryBuilder for dynamic conditions +* Prefer `sql: serial` for primary keys +* Explicitly define foreign keys +* Use `?T` for nullable fields +* Keep struct names identical to table names unless overridden + diff --git a/lib/hero/db/core_models.v b/lib/hero/db/core_models.v index 7188313c..6f2989ab 100644 --- a/lib/hero/db/core_models.v +++ b/lib/hero/db/core_models.v @@ -5,8 +5,8 @@ pub mut: id u32 name string description string - created_at i64 - updated_at i64 + created_at u32 + updated_at u32 securitypolicy u32 tags u32 // when we set/get we always do as []string but this can then be sorted and md5ed this gies the unique id of tags messages []u32 diff --git a/lib/hero/db/decode.v b/lib/hero/db/decode.v index 7268213c..1a7edf85 100644 --- a/lib/hero/db/decode.v +++ b/lib/hero/db/decode.v @@ -30,6 +30,17 @@ pub fn decode_u32(data string) !u32 { return u32(parsed_uint) } +pub fn u32_ourtime(t u32) ourtime.OurTime { + return ourtime.OurTime{ + unixt: i64(t) + } +} + +pub fn ourtime_u32(t ourtime.OurTime) u32 { + return u32(t.unixt) // Convert unix time to u32 +} + + pub fn decode_string(data string) !string { // Try JSON decode first (for proper JSON strings) // if result := json2.decode[string](data) { diff --git a/lib/threefold/grid3/deploy_tosort/deployment.v b/lib/mycelium/grid3/deploy_tosort/deployment.v similarity index 100% rename from lib/threefold/grid3/deploy_tosort/deployment.v rename to lib/mycelium/grid3/deploy_tosort/deployment.v diff --git a/lib/threefold/grid3/deployer/.heroscript b/lib/mycelium/grid3/deployer/.heroscript similarity index 100% rename from lib/threefold/grid3/deployer/.heroscript rename to lib/mycelium/grid3/deployer/.heroscript diff --git a/lib/threefold/grid3/deployer/contracts.v b/lib/mycelium/grid3/deployer/contracts.v similarity index 100% rename from lib/threefold/grid3/deployer/contracts.v rename to lib/mycelium/grid3/deployer/contracts.v diff --git a/lib/threefold/grid3/deployer/deployer.v b/lib/mycelium/grid3/deployer/deployer.v similarity index 100% rename from lib/threefold/grid3/deployer/deployer.v rename to lib/mycelium/grid3/deployer/deployer.v diff --git a/lib/threefold/grid3/deployer/deployer_factory_.v b/lib/mycelium/grid3/deployer/deployer_factory_.v similarity index 100% rename from lib/threefold/grid3/deployer/deployer_factory_.v rename to lib/mycelium/grid3/deployer/deployer_factory_.v diff --git a/lib/threefold/grid3/deployer/deployer_model.v b/lib/mycelium/grid3/deployer/deployer_model.v similarity index 100% rename from lib/threefold/grid3/deployer/deployer_model.v rename to lib/mycelium/grid3/deployer/deployer_model.v diff --git a/lib/threefold/grid3/deployer/deployment.v b/lib/mycelium/grid3/deployer/deployment.v similarity index 100% rename from lib/threefold/grid3/deployer/deployment.v rename to lib/mycelium/grid3/deployer/deployment.v diff --git a/lib/threefold/grid3/deployer/deployment_setup.v b/lib/mycelium/grid3/deployer/deployment_setup.v similarity index 100% rename from lib/threefold/grid3/deployer/deployment_setup.v rename to lib/mycelium/grid3/deployer/deployment_setup.v diff --git a/lib/threefold/grid3/deployer/filter.v b/lib/mycelium/grid3/deployer/filter.v similarity index 100% rename from lib/threefold/grid3/deployer/filter.v rename to lib/mycelium/grid3/deployer/filter.v diff --git a/lib/threefold/grid3/deployer/kvstore.v b/lib/mycelium/grid3/deployer/kvstore.v similarity index 100% rename from lib/threefold/grid3/deployer/kvstore.v rename to lib/mycelium/grid3/deployer/kvstore.v diff --git a/lib/threefold/grid3/deployer/network.v b/lib/mycelium/grid3/deployer/network.v similarity index 100% rename from lib/threefold/grid3/deployer/network.v rename to lib/mycelium/grid3/deployer/network.v diff --git a/lib/threefold/grid3/deployer/readme.md b/lib/mycelium/grid3/deployer/readme.md similarity index 100% rename from lib/threefold/grid3/deployer/readme.md rename to lib/mycelium/grid3/deployer/readme.md diff --git a/lib/threefold/grid3/deployer/rmb.v b/lib/mycelium/grid3/deployer/rmb.v similarity index 100% rename from lib/threefold/grid3/deployer/rmb.v rename to lib/mycelium/grid3/deployer/rmb.v diff --git a/lib/threefold/grid3/deployer/utils.v b/lib/mycelium/grid3/deployer/utils.v similarity index 100% rename from lib/threefold/grid3/deployer/utils.v rename to lib/mycelium/grid3/deployer/utils.v diff --git a/lib/threefold/grid3/deployer/vmachine.v b/lib/mycelium/grid3/deployer/vmachine.v similarity index 100% rename from lib/threefold/grid3/deployer/vmachine.v rename to lib/mycelium/grid3/deployer/vmachine.v diff --git a/lib/threefold/grid3/deployer/webnames.v b/lib/mycelium/grid3/deployer/webnames.v similarity index 100% rename from lib/threefold/grid3/deployer/webnames.v rename to lib/mycelium/grid3/deployer/webnames.v diff --git a/lib/threefold/grid3/deployer/zdbs.v b/lib/mycelium/grid3/deployer/zdbs.v similarity index 100% rename from lib/threefold/grid3/deployer/zdbs.v rename to lib/mycelium/grid3/deployer/zdbs.v diff --git a/lib/threefold/grid3/deployer2_sort/README.md b/lib/mycelium/grid3/deployer2_sort/README.md similarity index 100% rename from lib/threefold/grid3/deployer2_sort/README.md rename to lib/mycelium/grid3/deployer2_sort/README.md diff --git a/lib/threefold/grid3/deployer2_sort/deployment_state.v b/lib/mycelium/grid3/deployer2_sort/deployment_state.v similarity index 100% rename from lib/threefold/grid3/deployer2_sort/deployment_state.v rename to lib/mycelium/grid3/deployer2_sort/deployment_state.v diff --git a/lib/threefold/grid3/deployer2_sort/factory.v b/lib/mycelium/grid3/deployer2_sort/factory.v similarity index 100% rename from lib/threefold/grid3/deployer2_sort/factory.v rename to lib/mycelium/grid3/deployer2_sort/factory.v diff --git a/lib/threefold/grid3/deployer2_sort/graphql.v b/lib/mycelium/grid3/deployer2_sort/graphql.v similarity index 100% rename from lib/threefold/grid3/deployer2_sort/graphql.v rename to lib/mycelium/grid3/deployer2_sort/graphql.v diff --git a/lib/threefold/grid3/deployer2_sort/vm.v b/lib/mycelium/grid3/deployer2_sort/vm.v similarity index 100% rename from lib/threefold/grid3/deployer2_sort/vm.v rename to lib/mycelium/grid3/deployer2_sort/vm.v diff --git a/lib/threefold/grid3/deployer2_sort/vm_test.v b/lib/mycelium/grid3/deployer2_sort/vm_test.v similarity index 100% rename from lib/threefold/grid3/deployer2_sort/vm_test.v rename to lib/mycelium/grid3/deployer2_sort/vm_test.v diff --git a/lib/threefold/grid3/deployer2_sort/zdb.v b/lib/mycelium/grid3/deployer2_sort/zdb.v similarity index 100% rename from lib/threefold/grid3/deployer2_sort/zdb.v rename to lib/mycelium/grid3/deployer2_sort/zdb.v diff --git a/lib/threefold/grid3/griddriver/client.v b/lib/mycelium/grid3/griddriver/client.v similarity index 100% rename from lib/threefold/grid3/griddriver/client.v rename to lib/mycelium/grid3/griddriver/client.v diff --git a/lib/threefold/grid3/griddriver/rmb.v b/lib/mycelium/grid3/griddriver/rmb.v similarity index 100% rename from lib/threefold/grid3/griddriver/rmb.v rename to lib/mycelium/grid3/griddriver/rmb.v diff --git a/lib/threefold/grid3/griddriver/substrate.v b/lib/mycelium/grid3/griddriver/substrate.v similarity index 100% rename from lib/threefold/grid3/griddriver/substrate.v rename to lib/mycelium/grid3/griddriver/substrate.v diff --git a/lib/threefold/grid3/griddriver/utils.v b/lib/mycelium/grid3/griddriver/utils.v similarity index 100% rename from lib/threefold/grid3/griddriver/utils.v rename to lib/mycelium/grid3/griddriver/utils.v diff --git a/lib/threefold/grid3/gridproxy/README.md b/lib/mycelium/grid3/gridproxy/README.md similarity index 100% rename from lib/threefold/grid3/gridproxy/README.md rename to lib/mycelium/grid3/gridproxy/README.md diff --git a/lib/threefold/grid3/gridproxy/gridproxy_core.v b/lib/mycelium/grid3/gridproxy/gridproxy_core.v similarity index 100% rename from lib/threefold/grid3/gridproxy/gridproxy_core.v rename to lib/mycelium/grid3/gridproxy/gridproxy_core.v diff --git a/lib/threefold/grid3/gridproxy/gridproxy_factory.v b/lib/mycelium/grid3/gridproxy/gridproxy_factory.v similarity index 100% rename from lib/threefold/grid3/gridproxy/gridproxy_factory.v rename to lib/mycelium/grid3/gridproxy/gridproxy_factory.v diff --git a/lib/threefold/grid3/gridproxy/gridproxy_highlevel.v b/lib/mycelium/grid3/gridproxy/gridproxy_highlevel.v similarity index 100% rename from lib/threefold/grid3/gridproxy/gridproxy_highlevel.v rename to lib/mycelium/grid3/gridproxy/gridproxy_highlevel.v diff --git a/lib/threefold/grid3/gridproxy/gridproxy_test.v b/lib/mycelium/grid3/gridproxy/gridproxy_test.v similarity index 100% rename from lib/threefold/grid3/gridproxy/gridproxy_test.v rename to lib/mycelium/grid3/gridproxy/gridproxy_test.v diff --git a/lib/threefold/grid3/gridproxy/model/contract.v b/lib/mycelium/grid3/gridproxy/model/contract.v similarity index 100% rename from lib/threefold/grid3/gridproxy/model/contract.v rename to lib/mycelium/grid3/gridproxy/model/contract.v diff --git a/lib/threefold/grid3/gridproxy/model/farm.v b/lib/mycelium/grid3/gridproxy/model/farm.v similarity index 100% rename from lib/threefold/grid3/gridproxy/model/farm.v rename to lib/mycelium/grid3/gridproxy/model/farm.v diff --git a/lib/threefold/grid3/gridproxy/model/filter.v b/lib/mycelium/grid3/gridproxy/model/filter.v similarity index 100% rename from lib/threefold/grid3/gridproxy/model/filter.v rename to lib/mycelium/grid3/gridproxy/model/filter.v diff --git a/lib/threefold/grid3/gridproxy/model/iterators.v b/lib/mycelium/grid3/gridproxy/model/iterators.v similarity index 100% rename from lib/threefold/grid3/gridproxy/model/iterators.v rename to lib/mycelium/grid3/gridproxy/model/iterators.v diff --git a/lib/threefold/grid3/gridproxy/model/model.v b/lib/mycelium/grid3/gridproxy/model/model.v similarity index 100% rename from lib/threefold/grid3/gridproxy/model/model.v rename to lib/mycelium/grid3/gridproxy/model/model.v diff --git a/lib/threefold/grid3/gridproxy/model/node.v b/lib/mycelium/grid3/gridproxy/model/node.v similarity index 100% rename from lib/threefold/grid3/gridproxy/model/node.v rename to lib/mycelium/grid3/gridproxy/model/node.v diff --git a/lib/threefold/grid3/gridproxy/model/stats.v b/lib/mycelium/grid3/gridproxy/model/stats.v similarity index 100% rename from lib/threefold/grid3/gridproxy/model/stats.v rename to lib/mycelium/grid3/gridproxy/model/stats.v diff --git a/lib/threefold/grid3/gridproxy/model/twin.v b/lib/mycelium/grid3/gridproxy/model/twin.v similarity index 100% rename from lib/threefold/grid3/gridproxy/model/twin.v rename to lib/mycelium/grid3/gridproxy/model/twin.v diff --git a/lib/threefold/grid3/models/computecapacity.v b/lib/mycelium/grid3/models/computecapacity.v similarity index 100% rename from lib/threefold/grid3/models/computecapacity.v rename to lib/mycelium/grid3/models/computecapacity.v diff --git a/lib/threefold/grid3/models/deployment.v b/lib/mycelium/grid3/models/deployment.v similarity index 100% rename from lib/threefold/grid3/models/deployment.v rename to lib/mycelium/grid3/models/deployment.v diff --git a/lib/threefold/grid3/models/gw_fqdn.v b/lib/mycelium/grid3/models/gw_fqdn.v similarity index 100% rename from lib/threefold/grid3/models/gw_fqdn.v rename to lib/mycelium/grid3/models/gw_fqdn.v diff --git a/lib/threefold/grid3/models/gw_name.v b/lib/mycelium/grid3/models/gw_name.v similarity index 100% rename from lib/threefold/grid3/models/gw_name.v rename to lib/mycelium/grid3/models/gw_name.v diff --git a/lib/threefold/grid3/models/ip.v b/lib/mycelium/grid3/models/ip.v similarity index 100% rename from lib/threefold/grid3/models/ip.v rename to lib/mycelium/grid3/models/ip.v diff --git a/lib/threefold/grid3/models/qsfs_notimplemented.v b/lib/mycelium/grid3/models/qsfs_notimplemented.v similarity index 100% rename from lib/threefold/grid3/models/qsfs_notimplemented.v rename to lib/mycelium/grid3/models/qsfs_notimplemented.v diff --git a/lib/threefold/grid3/models/workload.v b/lib/mycelium/grid3/models/workload.v similarity index 100% rename from lib/threefold/grid3/models/workload.v rename to lib/mycelium/grid3/models/workload.v diff --git a/lib/threefold/grid3/models/zdb.v b/lib/mycelium/grid3/models/zdb.v similarity index 100% rename from lib/threefold/grid3/models/zdb.v rename to lib/mycelium/grid3/models/zdb.v diff --git a/lib/threefold/grid3/models/zlogs.v b/lib/mycelium/grid3/models/zlogs.v similarity index 100% rename from lib/threefold/grid3/models/zlogs.v rename to lib/mycelium/grid3/models/zlogs.v diff --git a/lib/threefold/grid3/models/zmachine.v b/lib/mycelium/grid3/models/zmachine.v similarity index 100% rename from lib/threefold/grid3/models/zmachine.v rename to lib/mycelium/grid3/models/zmachine.v diff --git a/lib/threefold/grid3/models/zmount.v b/lib/mycelium/grid3/models/zmount.v similarity index 100% rename from lib/threefold/grid3/models/zmount.v rename to lib/mycelium/grid3/models/zmount.v diff --git a/lib/threefold/grid3/models/znet.v b/lib/mycelium/grid3/models/znet.v similarity index 100% rename from lib/threefold/grid3/models/znet.v rename to lib/mycelium/grid3/models/znet.v diff --git a/lib/threefold/grid3/rmb/model_rmb.v b/lib/mycelium/grid3/rmb/model_rmb.v similarity index 100% rename from lib/threefold/grid3/rmb/model_rmb.v rename to lib/mycelium/grid3/rmb/model_rmb.v diff --git a/lib/threefold/grid3/rmb/readme.md b/lib/mycelium/grid3/rmb/readme.md similarity index 100% rename from lib/threefold/grid3/rmb/readme.md rename to lib/mycelium/grid3/rmb/readme.md diff --git a/lib/threefold/grid3/rmb/rmb_calls_zos.v b/lib/mycelium/grid3/rmb/rmb_calls_zos.v similarity index 100% rename from lib/threefold/grid3/rmb/rmb_calls_zos.v rename to lib/mycelium/grid3/rmb/rmb_calls_zos.v diff --git a/lib/threefold/grid3/rmb/rmb_calls_zos_statistics.v b/lib/mycelium/grid3/rmb/rmb_calls_zos_statistics.v similarity index 100% rename from lib/threefold/grid3/rmb/rmb_calls_zos_statistics.v rename to lib/mycelium/grid3/rmb/rmb_calls_zos_statistics.v diff --git a/lib/threefold/grid3/rmb/rmb_calls_zos_storagepools.v b/lib/mycelium/grid3/rmb/rmb_calls_zos_storagepools.v similarity index 100% rename from lib/threefold/grid3/rmb/rmb_calls_zos_storagepools.v rename to lib/mycelium/grid3/rmb/rmb_calls_zos_storagepools.v diff --git a/lib/threefold/grid3/rmb/rmb_client.v b/lib/mycelium/grid3/rmb/rmb_client.v similarity index 100% rename from lib/threefold/grid3/rmb/rmb_client.v rename to lib/mycelium/grid3/rmb/rmb_client.v diff --git a/lib/threefold/grid3/rmb/rmb_request.v b/lib/mycelium/grid3/rmb/rmb_request.v similarity index 100% rename from lib/threefold/grid3/rmb/rmb_request.v rename to lib/mycelium/grid3/rmb/rmb_request.v diff --git a/lib/threefold/grid3/rmb/rmb_test.v b/lib/mycelium/grid3/rmb/rmb_test.v similarity index 100% rename from lib/threefold/grid3/rmb/rmb_test.v rename to lib/mycelium/grid3/rmb/rmb_test.v diff --git a/lib/threefold/grid3/tfrobot/README.md b/lib/mycelium/grid3/tfrobot/README.md similarity index 100% rename from lib/threefold/grid3/tfrobot/README.md rename to lib/mycelium/grid3/tfrobot/README.md diff --git a/lib/threefold/grid3/tfrobot/cancel.v b/lib/mycelium/grid3/tfrobot/cancel.v similarity index 100% rename from lib/threefold/grid3/tfrobot/cancel.v rename to lib/mycelium/grid3/tfrobot/cancel.v diff --git a/lib/threefold/grid3/tfrobot/cancel_test.v b/lib/mycelium/grid3/tfrobot/cancel_test.v similarity index 100% rename from lib/threefold/grid3/tfrobot/cancel_test.v rename to lib/mycelium/grid3/tfrobot/cancel_test.v diff --git a/lib/threefold/grid3/tfrobot/deploy.v b/lib/mycelium/grid3/tfrobot/deploy.v similarity index 100% rename from lib/threefold/grid3/tfrobot/deploy.v rename to lib/mycelium/grid3/tfrobot/deploy.v diff --git a/lib/threefold/grid3/tfrobot/deploy_test.v b/lib/mycelium/grid3/tfrobot/deploy_test.v similarity index 100% rename from lib/threefold/grid3/tfrobot/deploy_test.v rename to lib/mycelium/grid3/tfrobot/deploy_test.v diff --git a/lib/threefold/grid3/tfrobot/factory.v b/lib/mycelium/grid3/tfrobot/factory.v similarity index 100% rename from lib/threefold/grid3/tfrobot/factory.v rename to lib/mycelium/grid3/tfrobot/factory.v diff --git a/lib/threefold/grid3/tfrobot/factory_test.v b/lib/mycelium/grid3/tfrobot/factory_test.v similarity index 100% rename from lib/threefold/grid3/tfrobot/factory_test.v rename to lib/mycelium/grid3/tfrobot/factory_test.v diff --git a/lib/threefold/grid3/tfrobot/job.v b/lib/mycelium/grid3/tfrobot/job.v similarity index 100% rename from lib/threefold/grid3/tfrobot/job.v rename to lib/mycelium/grid3/tfrobot/job.v diff --git a/lib/threefold/grid3/tfrobot/job_test.v b/lib/mycelium/grid3/tfrobot/job_test.v similarity index 100% rename from lib/threefold/grid3/tfrobot/job_test.v rename to lib/mycelium/grid3/tfrobot/job_test.v diff --git a/lib/threefold/grid3/tfrobot/templates/config.json b/lib/mycelium/grid3/tfrobot/templates/config.json similarity index 100% rename from lib/threefold/grid3/tfrobot/templates/config.json rename to lib/mycelium/grid3/tfrobot/templates/config.json diff --git a/lib/threefold/grid3/tfrobot/templates/config.yaml b/lib/mycelium/grid3/tfrobot/templates/config.yaml similarity index 100% rename from lib/threefold/grid3/tfrobot/templates/config.yaml rename to lib/mycelium/grid3/tfrobot/templates/config.yaml diff --git a/lib/threefold/grid3/tfrobot/tfrobot_redis.v b/lib/mycelium/grid3/tfrobot/tfrobot_redis.v similarity index 100% rename from lib/threefold/grid3/tfrobot/tfrobot_redis.v rename to lib/mycelium/grid3/tfrobot/tfrobot_redis.v diff --git a/lib/threefold/grid3/tfrobot/vm.v b/lib/mycelium/grid3/tfrobot/vm.v similarity index 100% rename from lib/threefold/grid3/tfrobot/vm.v rename to lib/mycelium/grid3/tfrobot/vm.v diff --git a/lib/threefold/grid3/tfrobot/vm_deploy.v b/lib/mycelium/grid3/tfrobot/vm_deploy.v similarity index 100% rename from lib/threefold/grid3/tfrobot/vm_deploy.v rename to lib/mycelium/grid3/tfrobot/vm_deploy.v diff --git a/lib/threefold/grid3/tfrobot/vm_deploy_test.v b/lib/mycelium/grid3/tfrobot/vm_deploy_test.v similarity index 100% rename from lib/threefold/grid3/tfrobot/vm_deploy_test.v rename to lib/mycelium/grid3/tfrobot/vm_deploy_test.v diff --git a/lib/threefold/grid3/tokens/readme.md b/lib/mycelium/grid3/tokens/readme.md similarity index 100% rename from lib/threefold/grid3/tokens/readme.md rename to lib/mycelium/grid3/tokens/readme.md diff --git a/lib/threefold/grid3/tokens/tokens_fetch.v b/lib/mycelium/grid3/tokens/tokens_fetch.v similarity index 100% rename from lib/threefold/grid3/tokens/tokens_fetch.v rename to lib/mycelium/grid3/tokens/tokens_fetch.v diff --git a/lib/threefold/grid3/zerohub/flist.v b/lib/mycelium/grid3/zerohub/flist.v similarity index 100% rename from lib/threefold/grid3/zerohub/flist.v rename to lib/mycelium/grid3/zerohub/flist.v diff --git a/lib/threefold/grid3/zerohub/readme.md b/lib/mycelium/grid3/zerohub/readme.md similarity index 100% rename from lib/threefold/grid3/zerohub/readme.md rename to lib/mycelium/grid3/zerohub/readme.md diff --git a/lib/threefold/grid3/zerohub/zerohub.v b/lib/mycelium/grid3/zerohub/zerohub.v similarity index 100% rename from lib/threefold/grid3/zerohub/zerohub.v rename to lib/mycelium/grid3/zerohub/zerohub.v diff --git a/lib/threefold/grid3/zerohub/zerohub_test.v b/lib/mycelium/grid3/zerohub/zerohub_test.v similarity index 100% rename from lib/threefold/grid3/zerohub/zerohub_test.v rename to lib/mycelium/grid3/zerohub/zerohub_test.v diff --git a/lib/threefold/grid4/datamodel/README.md b/lib/mycelium/grid4/datamodel/README.md similarity index 100% rename from lib/threefold/grid4/datamodel/README.md rename to lib/mycelium/grid4/datamodel/README.md diff --git a/lib/threefold/grid4/datamodel/model_bid.v b/lib/mycelium/grid4/datamodel/model_bid.v similarity index 100% rename from lib/threefold/grid4/datamodel/model_bid.v rename to lib/mycelium/grid4/datamodel/model_bid.v diff --git a/lib/threefold/grid4/datamodel/model_node.v b/lib/mycelium/grid4/datamodel/model_node.v similarity index 100% rename from lib/threefold/grid4/datamodel/model_node.v rename to lib/mycelium/grid4/datamodel/model_node.v diff --git a/lib/threefold/grid4/datamodel/model_nodegroup.v b/lib/mycelium/grid4/datamodel/model_nodegroup.v similarity index 100% rename from lib/threefold/grid4/datamodel/model_nodegroup.v rename to lib/mycelium/grid4/datamodel/model_nodegroup.v diff --git a/lib/threefold/grid4/datamodel/model_reservation.v b/lib/mycelium/grid4/datamodel/model_reservation.v similarity index 100% rename from lib/threefold/grid4/datamodel/model_reservation.v rename to lib/mycelium/grid4/datamodel/model_reservation.v diff --git a/lib/threefold/grid4/datamodel/play.v b/lib/mycelium/grid4/datamodel/play.v similarity index 100% rename from lib/threefold/grid4/datamodel/play.v rename to lib/mycelium/grid4/datamodel/play.v diff --git a/lib/threefold/grid4/datamodelsimulator/README.md b/lib/mycelium/grid4/datamodelsimulator/README.md similarity index 100% rename from lib/threefold/grid4/datamodelsimulator/README.md rename to lib/mycelium/grid4/datamodelsimulator/README.md diff --git a/lib/threefold/grid4/datamodelsimulator/loader.v b/lib/mycelium/grid4/datamodelsimulator/loader.v similarity index 100% rename from lib/threefold/grid4/datamodelsimulator/loader.v rename to lib/mycelium/grid4/datamodelsimulator/loader.v diff --git a/lib/threefold/grid4/datamodelsimulator/model_aggregated.v b/lib/mycelium/grid4/datamodelsimulator/model_aggregated.v similarity index 100% rename from lib/threefold/grid4/datamodelsimulator/model_aggregated.v rename to lib/mycelium/grid4/datamodelsimulator/model_aggregated.v diff --git a/lib/threefold/grid4/datamodelsimulator/model_simulations.v b/lib/mycelium/grid4/datamodelsimulator/model_simulations.v similarity index 100% rename from lib/threefold/grid4/datamodelsimulator/model_simulations.v rename to lib/mycelium/grid4/datamodelsimulator/model_simulations.v diff --git a/lib/threefold/grid4/datamodelsimulator/play.v b/lib/mycelium/grid4/datamodelsimulator/play.v similarity index 100% rename from lib/threefold/grid4/datamodelsimulator/play.v rename to lib/mycelium/grid4/datamodelsimulator/play.v diff --git a/lib/threefold/grid4/farmingsimulator/factory.v b/lib/mycelium/grid4/farmingsimulator/factory.v similarity index 100% rename from lib/threefold/grid4/farmingsimulator/factory.v rename to lib/mycelium/grid4/farmingsimulator/factory.v diff --git a/lib/threefold/grid4/farmingsimulator/model_capacity.v b/lib/mycelium/grid4/farmingsimulator/model_capacity.v similarity index 100% rename from lib/threefold/grid4/farmingsimulator/model_capacity.v rename to lib/mycelium/grid4/farmingsimulator/model_capacity.v diff --git a/lib/threefold/grid4/farmingsimulator/model_nodesbatch.v b/lib/mycelium/grid4/farmingsimulator/model_nodesbatch.v similarity index 100% rename from lib/threefold/grid4/farmingsimulator/model_nodesbatch.v rename to lib/mycelium/grid4/farmingsimulator/model_nodesbatch.v diff --git a/lib/threefold/grid4/farmingsimulator/model_nodetemplate.v b/lib/mycelium/grid4/farmingsimulator/model_nodetemplate.v similarity index 100% rename from lib/threefold/grid4/farmingsimulator/model_nodetemplate.v rename to lib/mycelium/grid4/farmingsimulator/model_nodetemplate.v diff --git a/lib/threefold/grid4/farmingsimulator/model_params.v b/lib/mycelium/grid4/farmingsimulator/model_params.v similarity index 100% rename from lib/threefold/grid4/farmingsimulator/model_params.v rename to lib/mycelium/grid4/farmingsimulator/model_params.v diff --git a/lib/threefold/grid4/farmingsimulator/model_regionalinternet.v b/lib/mycelium/grid4/farmingsimulator/model_regionalinternet.v similarity index 100% rename from lib/threefold/grid4/farmingsimulator/model_regionalinternet.v rename to lib/mycelium/grid4/farmingsimulator/model_regionalinternet.v diff --git a/lib/threefold/grid4/farmingsimulator/model_simulator.v b/lib/mycelium/grid4/farmingsimulator/model_simulator.v similarity index 100% rename from lib/threefold/grid4/farmingsimulator/model_simulator.v rename to lib/mycelium/grid4/farmingsimulator/model_simulator.v diff --git a/lib/threefold/grid4/farmingsimulator/play.v b/lib/mycelium/grid4/farmingsimulator/play.v similarity index 100% rename from lib/threefold/grid4/farmingsimulator/play.v rename to lib/mycelium/grid4/farmingsimulator/play.v diff --git a/lib/threefold/grid4/farmingsimulator/playmacro.v b/lib/mycelium/grid4/farmingsimulator/playmacro.v similarity index 100% rename from lib/threefold/grid4/farmingsimulator/playmacro.v rename to lib/mycelium/grid4/farmingsimulator/playmacro.v diff --git a/lib/threefold/grid4/farmingsimulator/templates/node_template.md b/lib/mycelium/grid4/farmingsimulator/templates/node_template.md similarity index 100% rename from lib/threefold/grid4/farmingsimulator/templates/node_template.md rename to lib/mycelium/grid4/farmingsimulator/templates/node_template.md diff --git a/lib/threefold/grid4/farmingsimulator/templates/regionalinternet_template.md b/lib/mycelium/grid4/farmingsimulator/templates/regionalinternet_template.md similarity index 100% rename from lib/threefold/grid4/farmingsimulator/templates/regionalinternet_template.md rename to lib/mycelium/grid4/farmingsimulator/templates/regionalinternet_template.md diff --git a/lib/threefold/grid4/farmingsimulator/token_cultivation.v b/lib/mycelium/grid4/farmingsimulator/token_cultivation.v similarity index 100% rename from lib/threefold/grid4/farmingsimulator/token_cultivation.v rename to lib/mycelium/grid4/farmingsimulator/token_cultivation.v diff --git a/lib/threefold/grid4/farmingsimulator/token_farming.v b/lib/mycelium/grid4/farmingsimulator/token_farming.v similarity index 100% rename from lib/threefold/grid4/farmingsimulator/token_farming.v rename to lib/mycelium/grid4/farmingsimulator/token_farming.v diff --git a/lib/threefold/grid4/farmingsimulator/wiki.v b/lib/mycelium/grid4/farmingsimulator/wiki.v similarity index 100% rename from lib/threefold/grid4/farmingsimulator/wiki.v rename to lib/mycelium/grid4/farmingsimulator/wiki.v diff --git a/lib/threefold/grid4/gridsimulator/factory.v b/lib/mycelium/grid4/gridsimulator/factory.v similarity index 100% rename from lib/threefold/grid4/gridsimulator/factory.v rename to lib/mycelium/grid4/gridsimulator/factory.v diff --git a/lib/threefold/grid4/gridsimulator/manual/.collection b/lib/mycelium/grid4/gridsimulator/manual/.collection similarity index 100% rename from lib/threefold/grid4/gridsimulator/manual/.collection rename to lib/mycelium/grid4/gridsimulator/manual/.collection diff --git a/lib/threefold/grid4/gridsimulator/manual/home.md b/lib/mycelium/grid4/gridsimulator/manual/home.md similarity index 100% rename from lib/threefold/grid4/gridsimulator/manual/home.md rename to lib/mycelium/grid4/gridsimulator/manual/home.md diff --git a/lib/threefold/grid4/gridsimulator/manual/macros.md b/lib/mycelium/grid4/gridsimulator/manual/macros.md similarity index 100% rename from lib/threefold/grid4/gridsimulator/manual/macros.md rename to lib/mycelium/grid4/gridsimulator/manual/macros.md diff --git a/lib/threefold/grid4/gridsimulator/play.v b/lib/mycelium/grid4/gridsimulator/play.v similarity index 100% rename from lib/threefold/grid4/gridsimulator/play.v rename to lib/mycelium/grid4/gridsimulator/play.v diff --git a/lib/threefold/grid4/gridsimulator/readme.md b/lib/mycelium/grid4/gridsimulator/readme.md similarity index 100% rename from lib/threefold/grid4/gridsimulator/readme.md rename to lib/mycelium/grid4/gridsimulator/readme.md diff --git a/lib/threefold/incatokens/amm.v b/lib/mycelium/incatokens/amm.v similarity index 100% rename from lib/threefold/incatokens/amm.v rename to lib/mycelium/incatokens/amm.v diff --git a/lib/threefold/incatokens/amm_test.v b/lib/mycelium/incatokens/amm_test.v similarity index 100% rename from lib/threefold/incatokens/amm_test.v rename to lib/mycelium/incatokens/amm_test.v diff --git a/lib/threefold/incatokens/auction.v b/lib/mycelium/incatokens/auction.v similarity index 100% rename from lib/threefold/incatokens/auction.v rename to lib/mycelium/incatokens/auction.v diff --git a/lib/threefold/incatokens/auction_test.v b/lib/mycelium/incatokens/auction_test.v similarity index 100% rename from lib/threefold/incatokens/auction_test.v rename to lib/mycelium/incatokens/auction_test.v diff --git a/lib/threefold/incatokens/charts.v b/lib/mycelium/incatokens/charts.v similarity index 100% rename from lib/threefold/incatokens/charts.v rename to lib/mycelium/incatokens/charts.v diff --git a/lib/threefold/incatokens/export.v b/lib/mycelium/incatokens/export.v similarity index 100% rename from lib/threefold/incatokens/export.v rename to lib/mycelium/incatokens/export.v diff --git a/lib/threefold/incatokens/factory.v b/lib/mycelium/incatokens/factory.v similarity index 100% rename from lib/threefold/incatokens/factory.v rename to lib/mycelium/incatokens/factory.v diff --git a/lib/threefold/incatokens/incatokens_test.v b/lib/mycelium/incatokens/incatokens_test.v similarity index 100% rename from lib/threefold/incatokens/incatokens_test.v rename to lib/mycelium/incatokens/incatokens_test.v diff --git a/lib/threefold/incatokens/params.v b/lib/mycelium/incatokens/params.v similarity index 100% rename from lib/threefold/incatokens/params.v rename to lib/mycelium/incatokens/params.v diff --git a/lib/threefold/incatokens/play.v b/lib/mycelium/incatokens/play.v similarity index 100% rename from lib/threefold/incatokens/play.v rename to lib/mycelium/incatokens/play.v diff --git a/lib/threefold/incatokens/readme.md b/lib/mycelium/incatokens/readme.md similarity index 100% rename from lib/threefold/incatokens/readme.md rename to lib/mycelium/incatokens/readme.md diff --git a/lib/threefold/incatokens/simulation.v b/lib/mycelium/incatokens/simulation.v similarity index 100% rename from lib/threefold/incatokens/simulation.v rename to lib/mycelium/incatokens/simulation.v diff --git a/lib/threefold/incatokens/templates/report copy.md b/lib/mycelium/incatokens/templates/report copy.md similarity index 100% rename from lib/threefold/incatokens/templates/report copy.md rename to lib/mycelium/incatokens/templates/report copy.md diff --git a/lib/threefold/incatokens/templates/report.md b/lib/mycelium/incatokens/templates/report.md similarity index 100% rename from lib/threefold/incatokens/templates/report.md rename to lib/mycelium/incatokens/templates/report.md diff --git a/lib/threefold/incatokens/types.v b/lib/mycelium/incatokens/types.v similarity index 100% rename from lib/threefold/incatokens/types.v rename to lib/mycelium/incatokens/types.v diff --git a/lib/threefold/incatokens/vesting.v b/lib/mycelium/incatokens/vesting.v similarity index 100% rename from lib/threefold/incatokens/vesting.v rename to lib/mycelium/incatokens/vesting.v diff --git a/lib/threefold/models_ledger/account.v b/lib/mycelium/models_ledger/account.v similarity index 83% rename from lib/threefold/models_ledger/account.v rename to lib/mycelium/models_ledger/account.v index 5da93dba..7a59dd48 100644 --- a/lib/threefold/models_ledger/account.v +++ b/lib/mycelium/models_ledger/account.v @@ -1,53 +1,5 @@ module models_ledger -import incubaid.herolib.data.encoder -import incubaid.herolib.data.ourtime -import incubaid.herolib.hero.db -import json - -// AccountStatus represents the status of an account -pub enum AccountStatus { - active - inactive - suspended - archived -} - -// Account represents an account in the financial system -@[heap] -pub struct Account { - db.Base -pub mut: - owner_id u32 // link to user - location_id u32 // link to location, 0 is none - accountpolicies []AccountPolicy - assets []AccountAsset - assetid u32 - last_activity u64 - administrators []u32 -} - -// AccountPolicy represents a set of rules for an account - -pub struct AccountPolicy { -pub mut: - policy_id u32 @[index] - admins []u32 // people who can transfer money out - min_signatures u8 // nr of people who need to sign - limits []AccountLimit - whitelist_out []u32 // where money can go to - whitelist_in []u32 // where money can come from - lock_till u64 // date in epoch till no money can be transfered, only after - admin_lock_type LockType - admin_lock_till u64 // date in epoch when admin can unlock (0 means its free), this is unlock for changing this policy - admin_unlock []u32 // users who can unlock the admin policy - admin_unlock_min_signature u8 // nr of signatures from the adminunlock - clawback_accounts []u32 // account(s) which can clawback - clawback_min_signatures u8 - clawback_from u64 // from epoch money can be clawed back, 0 is always - clawback_till u64 // till which date -} - pub fn (self AccountPolicy) dump(mut e encoder.Encoder) ! { e.add_u32(self.policy_id) e.add_list_u32(self.admins) @@ -93,54 +45,27 @@ fn (mut self AccountPolicy) load(mut e encoder.Decoder) ! { self.clawback_till = e.get_u64()! } -pub enum LockType { - locked_till - locked - free -} - -pub struct AccountLimit { -pub mut: - amount f64 - asset_id u32 - period AccountLimitPeriodLimit -} - pub fn (self AccountLimit) dump(mut e encoder.Encoder) ! { - e.add_f64(self.amount) + e.add_u64(self.amount) e.add_u32(self.asset_id) e.add_u8(u8(self.period)) } fn (mut self AccountLimit) load(mut e encoder.Decoder) ! { - self.amount = e.get_f64()! + self.amount = e.get_u64()! self.asset_id = e.get_u32()! self.period = unsafe { AccountLimitPeriodLimit(e.get_u8()!) } } -pub enum AccountLimitPeriodLimit { - daily - weekly - monthly -} - -pub struct AccountAsset { - db.Base -pub mut: - assetid u32 - balance f64 - metadata map[string]string -} - pub fn (self AccountAsset) dump(mut e encoder.Encoder) ! { e.add_u32(self.assetid) - e.add_f64(self.balance) + e.add_u64(self.balance) e.add_map_string(self.metadata) } fn (mut self AccountAsset) load(mut e encoder.Decoder) ! { self.assetid = e.get_u32()! - self.balance = e.get_f64()! + self.balance = e.get_u64()! self.metadata = e.get_map_string()! } diff --git a/lib/mycelium/models_ledger/account_model.v b/lib/mycelium/models_ledger/account_model.v new file mode 100644 index 00000000..80fdf929 --- /dev/null +++ b/lib/mycelium/models_ledger/account_model.v @@ -0,0 +1,77 @@ +module models_ledger + +import incubaid.herolib.data.ourtime +import incubaid.herolib.hero.db +import json + + +// Account represents an account in the financial system +@[heap] +pub struct Account { + db.Base +pub mut: + owner_id u32 // link to user, o is not defined + location_id u32 // link to location, 0 is none + accountpolicies []AccountPolicy + assets []AccountAsset + assetid u32 + last_activity u64 + administrators []u32 + status AccountStatus +} + +// AccountStatus represents the status of an account +pub enum AccountStatus { + active + inactive + suspended + archived +} + +// AccountPolicy represents a set of rules for an account +pub struct AccountPolicy { +pub mut: + policy_id u32 @[index] + admins []u32 // people who can transfer money out + min_signatures u8 // nr of people who need to sign + limits []AccountLimit + whitelist_out []u32 // where money can go to + whitelist_in []u32 // where money can come from + lock_till u64 // date in epoch till no money can be transfered, only after + admin_lock_type LockType + admin_lock_till u64 // date in epoch when admin can unlock (0 means its free), this is unlock for changing this policy + admin_unlock []u32 // users who can unlock the admin policy + admin_unlock_min_signature u8 // nr of signatures from the adminunlock + clawback_accounts []u32 // account(s) which can clawback + clawback_min_signatures u8 + clawback_from ourtime.OurTime // from epoch money can be clawed back, 0 is always + clawback_till u64 // till which date +} + + +pub enum LockType { + locked_till + locked + free +} + +pub struct AccountLimit { +pub mut: + amount u64 //in smallest unit + asset_id u32 + period AccountLimitPeriodLimit +} + + +pub enum AccountLimitPeriodLimit { + daily + weekly + monthly +} + +pub struct AccountAsset { +pub mut: + assetid u32 + balance u64 + metadata map[string]string +} diff --git a/lib/threefold/models_ledger/account_test.v b/lib/mycelium/models_ledger/account_test.v similarity index 100% rename from lib/threefold/models_ledger/account_test.v rename to lib/mycelium/models_ledger/account_test.v diff --git a/lib/threefold/models_ledger/asset.v b/lib/mycelium/models_ledger/asset.v similarity index 98% rename from lib/threefold/models_ledger/asset.v rename to lib/mycelium/models_ledger/asset.v index 73269942..e7b85159 100644 --- a/lib/threefold/models_ledger/asset.v +++ b/lib/mycelium/models_ledger/asset.v @@ -14,7 +14,7 @@ pub mut: address string @[index; required] // The unique address or identifier for the asset. asset_type string @[required] // The type of the asset (e.g., 'token', 'nft'). issuer u32 @[required] // The user ID of the issuer of the asset. - supply f64 // The total supply of the asset. + supply u64 // The total supply of the asset. decimals u8 // The number of decimal places for the asset's value. is_frozen bool // Indicates if the asset is currently frozen and cannot be transferred. metadata map[string]string // A map for storing arbitrary metadata as key-value pairs. @@ -61,7 +61,7 @@ pub fn (self Asset) dump(mut e encoder.Encoder) ! { e.add_string(self.address) e.add_string(self.asset_type) e.add_u32(self.issuer) - e.add_f64(self.supply) + e.add_u64(self.supply) e.add_u8(self.decimals) e.add_bool(self.is_frozen) @@ -74,7 +74,7 @@ fn (mut self DBAsset) load(mut o Asset, mut e encoder.Decoder) ! { o.address = e.get_string()! o.asset_type = e.get_string()! o.issuer = e.get_u32()! - o.supply = e.get_f64()! + o.supply = e.get_u64()! o.decimals = e.get_u8()! o.is_frozen = e.get_bool()! @@ -91,7 +91,7 @@ pub mut: address string asset_type string issuer u32 - supply f64 + supply u64 decimals u8 is_frozen bool metadata map[string]string diff --git a/lib/threefold/models_ledger/asset_test.v b/lib/mycelium/models_ledger/asset_test.v similarity index 99% rename from lib/threefold/models_ledger/asset_test.v rename to lib/mycelium/models_ledger/asset_test.v index 892fa624..ca45384e 100644 --- a/lib/threefold/models_ledger/asset_test.v +++ b/lib/mycelium/models_ledger/asset_test.v @@ -77,7 +77,7 @@ fn test_asset_list_filtering() ! { address: 'ADDR${i}' asset_type: if i < 3 { 'token' } else { 'nft' } issuer: if i % 2 == 0 { u32(1) } else { u32(2) } - supply: 1000.0 * f64(i + 1) + supply: 1000.0 * u64(i + 1) decimals: 8 is_frozen: i >= 3 } diff --git a/lib/threefold/models_ledger/dnszone.v b/lib/mycelium/models_ledger/dnszone.v similarity index 100% rename from lib/threefold/models_ledger/dnszone.v rename to lib/mycelium/models_ledger/dnszone.v diff --git a/lib/threefold/models_ledger/dnszone_test.v b/lib/mycelium/models_ledger/dnszone_test.v similarity index 100% rename from lib/threefold/models_ledger/dnszone_test.v rename to lib/mycelium/models_ledger/dnszone_test.v diff --git a/lib/threefold/models_ledger/group.v b/lib/mycelium/models_ledger/group.v similarity index 100% rename from lib/threefold/models_ledger/group.v rename to lib/mycelium/models_ledger/group.v diff --git a/lib/threefold/models_ledger/member.v b/lib/mycelium/models_ledger/member.v similarity index 100% rename from lib/threefold/models_ledger/member.v rename to lib/mycelium/models_ledger/member.v diff --git a/lib/threefold/models_ledger/models_factory.v b/lib/mycelium/models_ledger/models_factory.v similarity index 100% rename from lib/threefold/models_ledger/models_factory.v rename to lib/mycelium/models_ledger/models_factory.v diff --git a/lib/threefold/models_ledger/notary.v b/lib/mycelium/models_ledger/notary.v similarity index 100% rename from lib/threefold/models_ledger/notary.v rename to lib/mycelium/models_ledger/notary.v diff --git a/lib/threefold/models_ledger/signature.v b/lib/mycelium/models_ledger/signature.v similarity index 100% rename from lib/threefold/models_ledger/signature.v rename to lib/mycelium/models_ledger/signature.v diff --git a/lib/threefold/models_ledger/test_utils.v b/lib/mycelium/models_ledger/test_utils.v similarity index 100% rename from lib/threefold/models_ledger/test_utils.v rename to lib/mycelium/models_ledger/test_utils.v diff --git a/lib/threefold/models_ledger/transaction.v b/lib/mycelium/models_ledger/transaction.v similarity index 98% rename from lib/threefold/models_ledger/transaction.v rename to lib/mycelium/models_ledger/transaction.v index c5ca62d5..38b9a301 100644 --- a/lib/threefold/models_ledger/transaction.v +++ b/lib/mycelium/models_ledger/transaction.v @@ -14,7 +14,7 @@ pub mut: source u32 destination u32 assetid u32 - amount f64 + amount u64 timestamp u64 status string memo string @@ -100,7 +100,7 @@ pub fn (self Transaction) dump(mut e encoder.Encoder) ! { e.add_u32(self.source) e.add_u32(self.destination) e.add_u32(self.assetid) - e.add_f64(self.amount) + e.add_u64(self.amount) e.add_u64(self.timestamp) e.add_string(self.status) e.add_string(self.memo) @@ -120,7 +120,7 @@ fn (mut self DBTransaction) load(mut o Transaction, mut e encoder.Decoder) ! { o.source = e.get_u32()! o.destination = e.get_u32()! o.assetid = e.get_u32()! - o.amount = e.get_f64()! + o.amount = e.get_u64()! o.timestamp = e.get_u64()! o.status = e.get_string()! o.memo = e.get_string()! @@ -148,7 +148,7 @@ pub mut: source u32 destination u32 assetid u32 - amount f64 + amount u64 timestamp u64 status string memo string diff --git a/lib/threefold/models_ledger/user.v b/lib/mycelium/models_ledger/user.v similarity index 100% rename from lib/threefold/models_ledger/user.v rename to lib/mycelium/models_ledger/user.v diff --git a/lib/threefold/models_ledger/userkvs.v b/lib/mycelium/models_ledger/userkvs.v similarity index 100% rename from lib/threefold/models_ledger/userkvs.v rename to lib/mycelium/models_ledger/userkvs.v diff --git a/lib/threefold/models_ledger/userkvsitem.v b/lib/mycelium/models_ledger/userkvsitem.v similarity index 98% rename from lib/threefold/models_ledger/userkvsitem.v rename to lib/mycelium/models_ledger/userkvsitem.v index c2b1c11e..02cb8a98 100644 --- a/lib/threefold/models_ledger/userkvsitem.v +++ b/lib/mycelium/models_ledger/userkvsitem.v @@ -1,7 +1,6 @@ module models_ledger import incubaid.herolib.data.encoder -import incubaid.herolib.data.ourtime import incubaid.herolib.hero.db // UserKVSItem represents a single item in a user's key-value store @@ -12,7 +11,6 @@ pub mut: kvs_id u32 @[index] key string @[index] value string - timestamp u64 } pub struct DBUserKVSItem { diff --git a/lib/threefold/models_tfgrid/bid.v b/lib/mycelium/models_tfgrid/bid.v similarity index 100% rename from lib/threefold/models_tfgrid/bid.v rename to lib/mycelium/models_tfgrid/bid.v diff --git a/lib/threefold/models_tfgrid/contract.v b/lib/mycelium/models_tfgrid/contract.v similarity index 100% rename from lib/threefold/models_tfgrid/contract.v rename to lib/mycelium/models_tfgrid/contract.v diff --git a/lib/threefold/models_tfgrid/models_tfgrid_test.v b/lib/mycelium/models_tfgrid/models_tfgrid_test.v similarity index 100% rename from lib/threefold/models_tfgrid/models_tfgrid_test.v rename to lib/mycelium/models_tfgrid/models_tfgrid_test.v diff --git a/lib/threefold/models_tfgrid/node.v b/lib/mycelium/models_tfgrid/node.v similarity index 100% rename from lib/threefold/models_tfgrid/node.v rename to lib/mycelium/models_tfgrid/node.v diff --git a/lib/threefold/models_tfgrid/nodegroup.v b/lib/mycelium/models_tfgrid/nodegroup.v similarity index 100% rename from lib/threefold/models_tfgrid/nodegroup.v rename to lib/mycelium/models_tfgrid/nodegroup.v diff --git a/lib/threefold/models_tfgrid/readme.md b/lib/mycelium/models_tfgrid/readme.md similarity index 100% rename from lib/threefold/models_tfgrid/readme.md rename to lib/mycelium/models_tfgrid/readme.md diff --git a/lib/threefold/models_tfgrid/reputation.v b/lib/mycelium/models_tfgrid/reputation.v similarity index 100% rename from lib/threefold/models_tfgrid/reputation.v rename to lib/mycelium/models_tfgrid/reputation.v diff --git a/lib/threefold/models_to_move/README.md b/lib/mycelium/models_to_move/README.md similarity index 100% rename from lib/threefold/models_to_move/README.md rename to lib/mycelium/models_to_move/README.md diff --git a/lib/threefold/models_to_move/ai_instruction.md b/lib/mycelium/models_to_move/ai_instruction.md similarity index 100% rename from lib/threefold/models_to_move/ai_instruction.md rename to lib/mycelium/models_to_move/ai_instruction.md diff --git a/lib/threefold/models_to_move/business/company.v b/lib/mycelium/models_to_move/business/company.v similarity index 100% rename from lib/threefold/models_to_move/business/company.v rename to lib/mycelium/models_to_move/business/company.v diff --git a/lib/threefold/models_to_move/business/payment.v b/lib/mycelium/models_to_move/business/payment.v similarity index 100% rename from lib/threefold/models_to_move/business/payment.v rename to lib/mycelium/models_to_move/business/payment.v diff --git a/lib/threefold/models_to_move/business/product.v b/lib/mycelium/models_to_move/business/product.v similarity index 100% rename from lib/threefold/models_to_move/business/product.v rename to lib/mycelium/models_to_move/business/product.v diff --git a/lib/threefold/models_to_move/business/sale.v b/lib/mycelium/models_to_move/business/sale.v similarity index 100% rename from lib/threefold/models_to_move/business/sale.v rename to lib/mycelium/models_to_move/business/sale.v diff --git a/lib/threefold/models_to_move/finance/account.v b/lib/mycelium/models_to_move/finance/account.v similarity index 100% rename from lib/threefold/models_to_move/finance/account.v rename to lib/mycelium/models_to_move/finance/account.v diff --git a/lib/threefold/models_to_move/finance/asset.v b/lib/mycelium/models_to_move/finance/asset.v similarity index 100% rename from lib/threefold/models_to_move/finance/asset.v rename to lib/mycelium/models_to_move/finance/asset.v diff --git a/lib/threefold/models_to_move/finance/marketplace.v b/lib/mycelium/models_to_move/finance/marketplace.v similarity index 100% rename from lib/threefold/models_to_move/finance/marketplace.v rename to lib/mycelium/models_to_move/finance/marketplace.v diff --git a/lib/threefold/models_to_move/flow/flow.v b/lib/mycelium/models_to_move/flow/flow.v similarity index 100% rename from lib/threefold/models_to_move/flow/flow.v rename to lib/mycelium/models_to_move/flow/flow.v diff --git a/lib/threefold/models_to_move/flow/flow_step.v b/lib/mycelium/models_to_move/flow/flow_step.v similarity index 100% rename from lib/threefold/models_to_move/flow/flow_step.v rename to lib/mycelium/models_to_move/flow/flow_step.v diff --git a/lib/threefold/models_to_move/flow/signature_requirement.v b/lib/mycelium/models_to_move/flow/signature_requirement.v similarity index 100% rename from lib/threefold/models_to_move/flow/signature_requirement.v rename to lib/mycelium/models_to_move/flow/signature_requirement.v diff --git a/lib/threefold/models_to_move/identity/kyc.v b/lib/mycelium/models_to_move/identity/kyc.v similarity index 100% rename from lib/threefold/models_to_move/identity/kyc.v rename to lib/mycelium/models_to_move/identity/kyc.v diff --git a/lib/threefold/models_to_move/legal/contract.v b/lib/mycelium/models_to_move/legal/contract.v similarity index 100% rename from lib/threefold/models_to_move/legal/contract.v rename to lib/mycelium/models_to_move/legal/contract.v diff --git a/lib/threefold/models_to_move/library/collection.v b/lib/mycelium/models_to_move/library/collection.v similarity index 100% rename from lib/threefold/models_to_move/library/collection.v rename to lib/mycelium/models_to_move/library/collection.v diff --git a/lib/threefold/models_to_move/library/items.v b/lib/mycelium/models_to_move/library/items.v similarity index 100% rename from lib/threefold/models_to_move/library/items.v rename to lib/mycelium/models_to_move/library/items.v diff --git a/lib/threefold/models_to_move/location/address.v b/lib/mycelium/models_to_move/location/address.v similarity index 100% rename from lib/threefold/models_to_move/location/address.v rename to lib/mycelium/models_to_move/location/address.v diff --git a/lib/threefold/models_to_move/payment/stripe.v b/lib/mycelium/models_to_move/payment/stripe.v similarity index 100% rename from lib/threefold/models_to_move/payment/stripe.v rename to lib/mycelium/models_to_move/payment/stripe.v diff --git a/lib/threefold/models_ledger/.goosehints b/lib/threefold/models_ledger/.goosehints deleted file mode 100644 index 7738f1af..00000000 --- a/lib/threefold/models_ledger/.goosehints +++ /dev/null @@ -1,14 +0,0 @@ - -use @aiprompts/heromodel_instruct.md -as instructions how this directory needs to be coded, check all instructions carefully - -when a test file is created for a model, its $modelname_test.v - -test this file by running: - vtest $modelname_test.v - -always cd to the directory where the test file is, not to the root of the project - -check the issues and fix them accordingly. - -when doing implementation or tests do file per file, do not do all files at once. \ No newline at end of file diff --git a/lib/threefold/models_ledger/README_TESTS.md b/lib/threefold/models_ledger/README_TESTS.md deleted file mode 100644 index 1b58b2a7..00000000 --- a/lib/threefold/models_ledger/README_TESTS.md +++ /dev/null @@ -1,181 +0,0 @@ -# Models Ledger Tests - -This directory contains comprehensive tests for all models in the `models_ledger` module. The tests focus primarily on encoding/decoding functionality to ensure data integrity through the database layer. - -## Test Structure - -Each model has its own test file following the naming convention `{model}_test.v`: - -- `account_test.v` - Tests for Account model with complex nested structures -- `asset_test.v` - Tests for Asset model with metadata maps -- `user_test.v` - Tests for User model with SecretBox arrays -- `transaction_test.v` - Tests for Transaction model with signature arrays -- `dnszone_test.v` - Tests for DNSZone model with DNS records and SOA records -- `group_test.v` - Tests for Group model with configuration structs -- `member_test.v` - Tests for Member model with enums -- `notary_test.v` - Tests for Notary model -- `signature_test.v` - Tests for Signature model -- `userkvs_test.v` - Tests for UserKVS model -- `userkvsitem_test.v` - Tests for UserKVSItem model -- `models_test.v` - Integration tests for all models together - -## Test Categories - -### 1. Model Creation (`test_{model}_new`) -Tests the creation of new model instances with all field types: -- Required fields -- Optional fields -- Default values -- Complex nested structures -- Arrays and maps - -### 2. Encoding/Decoding (`test_{model}_encoding_decoding`) -**Primary focus** - Tests the serialization and deserialization: -- Encoding to binary format using `dump(mut encoder.Encoder)` -- Decoding from binary format using `load(mut decoder.Decoder)` -- Field-by-field verification after roundtrip -- Complex data structures (nested structs, arrays, maps) -- Edge cases (empty data, large data) - -### 3. Database Operations (`test_{model}_set_and_get`) -Tests CRUD operations through the database layer: -- Create and save (`set`) -- Retrieve (`get`) -- ID assignment -- Data persistence through database roundtrip - -### 4. Update Operations (`test_{model}_update`) -Tests updating existing records: -- Modify fields -- Save changes -- Verify updates persist -- ID and created_at preservation - -### 5. Existence and Deletion (`test_{model}_exist_and_delete`) -Tests existence checking and deletion: -- Check non-existent records -- Create and verify existence -- Delete records -- Verify deletion - -### 6. List Operations (`test_{model}_list`) -Tests listing all records: -- Initial empty state -- Create multiple records -- List and count verification -- Find specific records in lists - -### 7. Edge Cases (`test_{model}_edge_cases`) -Tests boundary conditions: -- Empty/minimal data -- Very large data -- Special characters -- Unicode handling -- Maximum array sizes - -## Key Features Tested - -### Encoding/Decoding Integrity -- **Primitive types**: strings, integers, floats, booleans -- **Arrays**: `[]u32`, `[]string`, `[]SecretBox`, etc. -- **Maps**: `map[string]string` for metadata -- **Enums**: All enum types with proper conversion -- **Nested structs**: Complex hierarchical data -- **Binary data**: Encrypted data in SecretBox - -### Complex Data Structures -- **Account**: Nested AccountPolicy and AccountAsset arrays -- **DNSZone**: DNS records with different types and SOA records -- **User**: Encrypted data arrays (userprofile, kyc) -- **Transaction**: Signature arrays with timestamps -- **Group**: Configuration structs with multiple fields - -### Performance Considerations -- Large array handling (1000+ elements) -- Large binary data (10KB+ encrypted data) -- Complex nested structures -- Memory efficiency during encoding/decoding - -## Running Tests - -Run all model tests: -```bash -vtest ~/code/github/incubaid/herolib/lib/threefold/models_ledger/ -``` - -Run specific model tests: -```bash -vtest ~/code/github/incubaid/herolib/lib/threefold/models_ledger/account_test.v -vtest ~/code/github/incubaid/herolib/lib/threefold/models_ledger/user_test.v -``` - -Run integration tests: -```bash -vtest ~/code/github/incubaid/herolib/lib/threefold/models_ledger/models_test.v -``` - -## Common Test Patterns - -### Setup -Each test file uses a common setup function: -```v -fn setup_test_db() !db.DB { - return db.new(path: ':memory:')! -} -``` - -### Encoding/Decoding Pattern -```v -// Test encoding -mut encoder_obj := encoder.encoder_new() -original_object.dump(mut encoder_obj)! -encoded_data := encoder_obj.data - -// Test decoding -mut decoder_obj := encoder.decoder_new(encoded_data) -mut decoded_object := ObjectType{} -object_db.load(mut decoded_object, mut decoder_obj)! - -// Verify all fields match -assert decoded_object.field == original_object.field -``` - -### CRUD Pattern -```v -// Create -mut object := object_db.new(args)! - -// Save -object = object_db.set(object)! -assert object.id > 0 - -// Get -retrieved := object_db.get(object.id)! -assert retrieved.field == object.field - -// Update -object.field = new_value -object = object_db.set(object)! - -// Delete -object_db.delete(object.id)! -assert object_db.exist(object.id)! == false -``` - -## Error Conditions - -Tests verify proper error handling for: -- Non-existent record retrieval -- Invalid data encoding/decoding -- Database constraint violations -- Memory allocation failures - -## Performance Metrics - -Integration tests include performance verification: -- Large data encoding/decoding speed -- Memory usage with complex structures -- Database roundtrip efficiency -- Array and map handling performance - -The tests ensure that all models can handle real-world usage scenarios with proper data integrity and performance characteristics. \ No newline at end of file diff --git a/lib/threefold/models_ledger/fix.md b/lib/threefold/models_ledger/fix.md deleted file mode 100644 index 86d287fc..00000000 --- a/lib/threefold/models_ledger/fix.md +++ /dev/null @@ -1,346 +0,0 @@ -# Issues and Fixes for models_ledger Package - -After reviewing the code in the models_ledger package, the following issues need to be fixed to align with the guidelines in the HeroModel instructions. - -## 1. Missing API Description and Example Methods - -### Issue -All model structs are missing the required `description()` and `example()` methods that are necessary for API documentation and testing. - -### Fix -Add the following methods to each model struct (Account, Asset, DNSZone, Group, Member, Notary, Signature, Transaction, User, UserKVS, UserKVSItem): - -```v -// API description method -pub fn (self ModelName) description(methodname string) string { - match methodname { - 'set' { return 'Create or update a [model]. Returns the ID of the [model].' } - 'get' { return 'Retrieve a [model] by ID. Returns the [model] object.' } - 'delete' { return 'Delete a [model] by ID.' } - 'exist' { return 'Check if a [model] exists by ID. Returns true or false.' } - 'list' { return 'List all [models]. Returns an array of [model] objects.' } - else { return 'This is a method for [model] object' } - } -} - -// API example method -pub fn (self ModelName) example(methodname string) (string, string) { - match methodname { - 'set' { - return '{"model": {...}}', '1' - } - 'get' { - return '{"id": 1}', '{...}' - } - 'delete' { - return '{"id": 1}', 'true' - } - 'exist' { - return '{"id": 1}', 'true' - } - 'list' { - return '{}', '[{...}]' - } - else { - return '{}', '{}' - } - } -} -``` - -Replace `[model]` and fill in the example data with appropriate values for each model. - -## 2. Missing API Handler Functions - -### Issue -Each model requires an API handler function that processes RPC requests. These are missing for all models. - -### Fix -Add handler functions for each model following this pattern: - -```v -pub fn modelname_handle(mut f ModelsFactory, rpcid int, servercontext map[string]string, userref UserRef, method string, params string) !Response { - match method { - 'get' { - id := db.decode_u32(params)! - res := f.modelname.get(id)! - return new_response(rpcid, json.encode_pretty(res)) - } - 'set' { - mut args := db.decode_generic[ModelNameArg](params)! - mut o := f.modelname.new(args)! - if args.id != 0 { - o.id = args.id - } - o = f.modelname.set(o)! - return new_response_int(rpcid, int(o.id)) - } - 'delete' { - id := db.decode_u32(params)! - f.modelname.delete(id)! - return new_response_true(rpcid) - } - 'exist' { - id := db.decode_u32(params)! - if f.modelname.exist(id)! { - return new_response_true(rpcid) - } else { - return new_response_false(rpcid) - } - } - 'list' { - ids := f.modelname.list()! - mut result := []ModelName{} - for id in ids { - result << f.modelname.get(id)! - } - return new_response(rpcid, json.encode_pretty(result)) - } - else { - return new_error(rpcid, - code: 32601 - message: 'Method ${method} not found on modelname' - ) - } - } -} -``` - -## 3. Missing Import for json Module - -### Issue -The API handler functions require the json module for encoding responses, but this import is missing. - -### Fix -Add the following import to each model file: -```v -import json -``` - -## 4. Incomplete List Method Implementation - -### Issue -The current list method simply returns all models without filtering capabilities or pagination. - -### Fix -Update the list method to support filtering and pagination: - -```v -@[params] -pub struct ModelNameListArg { -pub mut: - filter string - status int = -1 - limit int = 20 - offset int = 0 -} - -pub fn (mut self DBModelName) list(args ModelNameListArg) ![]ModelName { - mut all_models := self.db.list[ModelName]()!.map(self.get(it)!) - mut filtered_models := []ModelName{} - - for model in all_models { - // Add filter logic based on model properties - if args.filter != '' && !model.name.contains(args.filter) && !model.description.contains(args.filter) { - continue - } - - if args.status >= 0 && int(model.status) != args.status { - continue - } - - filtered_models << model - } - - // Apply pagination - mut start := args.offset - if start >= filtered_models.len { - start = 0 - } - - mut limit := args.limit - if limit > 100 { - limit = 100 - } - - if start + limit > filtered_models.len { - limit = filtered_models.len - start - } - - if limit <= 0 { - return []ModelName{} - } - - return filtered_models[start..start+limit] -} -``` - -Adapt the filtering logic based on the specific fields of each model. - -## 5. Missing or Incomplete Tests - -### Issue -The test_utils.v file exists but there are no actual test files for the models. - -### Fix -Create test files for each model following the patterns described in README_TESTS.md: - -1. Create files named `modelname_test.v` for each model -2. Implement CRUD tests for each model -3. Implement encoding/decoding tests -4. Add error handling tests -5. Add performance tests for complex models - -Example test file structure: -```v -module models_ledger - -fn test_modelname_crud() { - mut db := setup_test_db()! - mut model_db := DBModelName{db: db} - - // Create test - mut model := model_db.new(ModelNameArg{...})! - model = model_db.set(model)! - assert model.id > 0 - - // Get test - retrieved := model_db.get(model.id)! - assert retrieved.field == model.field - - // Update test - model.field = new_value - model = model_db.set(model)! - retrieved = model_db.get(model.id)! - assert retrieved.field == new_value - - // Delete test - model_db.delete(model.id)! - assert model_db.exist(model.id)! == false -} -``` - -## 6. Missing ModelsFactory Integration - -### Issue -There's no ModelsFactory implementation to initialize and manage all models together. - -### Fix -Create a `models_factory.v` file with the following structure: - -```v -module models_ledger - -import incubaid.herolib.hero.db - -pub struct ModelsFactory { -pub mut: - db &db.DB - account &DBAccount - asset &DBAsset - dnszone &DBDNSZone - group &DBGroup - member &DBMember - notary &DBNotary - signature &DBSignature - transaction &DBTransaction - user &DBUser - userkvs &DBUserKVS - userkvsitem &DBUserKVSItem -} - -pub fn new_models_factory(mut database db.DB) !&ModelsFactory { - mut factory := &ModelsFactory{ - db: database - } - - factory.account = &DBAccount{db: database} - factory.asset = &DBAsset{db: database} - factory.dnszone = &DBDNSZone{db: database} - factory.group = &DBGroup{db: database} - factory.member = &DBMember{db: database} - factory.notary = &DBNotary{db: database} - factory.signature = &DBSignature{db: database} - factory.transaction = &DBTransaction{db: database} - factory.user = &DBUser{db: database} - factory.userkvs = &DBUserKVS{db: database} - factory.userkvsitem = &DBUserKVSItem{db: database} - - return factory -} -``` - -## 7. Update delete() Method Return Type - -### Issue -Current delete() methods don't return a boolean value indicating success, which is needed for API handlers. - -### Fix -Update the delete() method in all models: - -```v -pub fn (mut self DBModelName) delete(id u32) !bool { - if !self.db.exists[ModelName](id)! { - return false - } - self.db.delete[ModelName](id)! - return true -} -``` - -## 8. Missing Validation in Model Creation - -### Issue -The new() methods don't validate input data before creating models. - -### Fix -Add validation logic to each new() method: - -```v -pub fn (mut self DBModelName) new(args ModelNameArg) !ModelName { - // Validate required fields - if args.required_field.trim_space() == '' { - return error('required_field cannot be empty') - } - - // Validate numeric ranges - if args.numeric_field < min_value || args.numeric_field > max_value { - return error('numeric_field must be between ${min_value} and ${max_value}') - } - - // Create the object - mut o := ModelName{...} - - return o -} -``` - -## 9. Fix Imports in test_utils.v - -### Issue -The test_utils.v file uses a simplified db.new() call that may not work correctly. - -### Fix -Update the setup_test_db() function: - -```v -fn setup_test_db() !db.DB { - return db.new(path: ':memory:')! -} -``` - -## Implementation Plan - -1. First, fix test_utils.v to ensure tests can run properly -2. Create a models_factory.v file -3. Update each model file to: - - Add missing imports - - Add description() and example() methods - - Update the list() method with filtering capabilities - - Fix the delete() method return type - - Add validation to new() methods -4. Create test files for each model -5. Create API handler functions for each model -6. Create an integration test file to test the entire models factory - -This approach ensures all models are consistent with the required patterns and properly integrated. diff --git a/lib/threefold/models_ledger/implementation_summary.md b/lib/threefold/models_ledger/implementation_summary.md deleted file mode 100644 index c30a6f66..00000000 --- a/lib/threefold/models_ledger/implementation_summary.md +++ /dev/null @@ -1,105 +0,0 @@ -# Implementation Summary for models_ledger Fixes - -## Testing Note - -The tests created for the models require proper module setup to work correctly. There appears to be an issue with the import paths in the test environment. The actual functionality of the models should be tested through the herolib test infrastructure. - -To properly test these changes: - -1. Make sure all herolib modules are properly setup in the project. -2. Run tests using `vtest` which is the recommended approach according to the herolib guidelines: - -```bash -vtest ~/code/github/incubaid/herolib/lib/threefold/models_ledger/account_test.v -``` - -The implementation is still valid, but the test environment needs additional configuration to run properly. - -This document summarizes the changes made to implement the fixes described in `fix.md`. Not all model files have been modified yet, but the pattern established can be applied to the remaining models. - -## Completed Changes - -1. **Fixed test_utils.v** - - Updated the `setup_test_db()` function to use the proper DB initialization pattern with `:memory:` parameter. - -2. **Created models_factory.v** - - Implemented the `ModelsFactory` struct that holds references to all model DBs. - - Added a constructor function `new_models_factory()` to initialize the factory. - -3. **Updated Account Model** - - Added JSON import - - Modified the `delete()` method to return a boolean value - - Added an enhanced `list()` method with filtering and pagination capabilities - - Added Response structs and helper functions for API responses - - Implemented the `account_handle()` function for API interaction - - Created a test file with CRUD and API handler tests - -4. **Updated Asset Model** - - Added JSON import - - Modified the `delete()` method to return a boolean value - - Added an enhanced `list()` method with filtering and pagination capabilities - - Implemented the `asset_handle()` function for API interaction - - Created a test file with CRUD, filtering, and API handler tests - -## Remaining Tasks - -To fully implement the fixes described in `fix.md`, the following tasks should be completed for each remaining model: - -1. **For each model file (dnszone.v, group.v, member.v, notary.v, signature.v, transaction.v, user.v, userkvs.v, userkvsitem.v):** - - Add JSON import - - Update the `delete()` method to return a boolean value - - Add an enhanced `list()` method with filtering and pagination capabilities - - Implement the handler function for API interaction - - Create test files with CRUD, filtering, and API handler tests - -2. **Create an integration test for the models factory** - - Test the interaction between multiple models - - Test the factory initialization - - Test API handlers working together - -## Implementation Guidelines - -For each model file, follow the pattern established for Account and Asset: - -1. **Add imports**: -```v -import json -``` - -2. **Fix delete method**: -```v -pub fn (mut self DBModelName) delete(id u32) !bool { - if !self.db.exists[ModelName](id)! { - return false - } - self.db.delete[ModelName](id)! - return true -} -``` - -3. **Add enhanced list method with filtering**: -```v -@[params] -pub struct ModelNameListArg { -pub mut: - filter string - // Add model-specific filters - limit int = 20 - offset int = 0 -} - -pub fn (mut self DBModelName) list(args ModelNameListArg) ![]ModelName { - // Implement filtering and pagination -} -``` - -4. **Add API handler function**: -```v -pub fn modelname_handle(mut f ModelsFactory, rpcid int, servercontext map[string]string, userref UserRef, method string, params string) !Response { - // Implement handler methods -} -``` - -5. **Create test file** with CRUD tests, filtering tests, and API handler tests - -This approach will ensure all models are consistent and properly integrated with the factory. diff --git a/lib/web/doctree/client/model.v b/lib/web/doctree/client/model.v index eb727003..12de934d 100644 --- a/lib/web/doctree/client/model.v +++ b/lib/web/doctree/client/model.v @@ -22,6 +22,16 @@ pub mut: path string collection_name string links []LinkMetadata + title string + description string + questions []Question + +} + +pub struct Question { +pub mut: + question string + answer string } pub struct FileMetadata { diff --git a/lib/web/doctree/core/collection_process.v b/lib/web/doctree/core/collection_process.v index 5ee7ca10..7ce185f2 100644 --- a/lib/web/doctree/core/collection_process.v +++ b/lib/web/doctree/core/collection_process.v @@ -2,6 +2,7 @@ module core import incubaid.herolib.develop.gittools import os +import incubaid.herolib.data.markdown.tools as markdowntools // Validate all links in collection fn (mut c Collection) find_links() ! { @@ -25,9 +26,23 @@ fn (mut c Collection) fix_links() ! { mut p := page.path()! p.write(fixed_content)! } + } +} + + +pub fn (mut c Collection) title_descriptions() ! { + for _, mut p in c.pages { + if p.title == '' { + p.title = markdowntools.extract_title(p.content(include: true)!) + } + // TODO in future should do AI + if p.description == '' { + p.description = p.title + } } } + // Detect git repository URL for a collection fn (mut c Collection) init_git_info() ! { mut current_path := c.path()! diff --git a/lib/web/doctree/core/export.v b/lib/web/doctree/core/export.v index 8f7df7bc..09e17b77 100644 --- a/lib/web/doctree/core/export.v +++ b/lib/web/doctree/core/export.v @@ -26,6 +26,7 @@ pub fn (mut a DocTree) export(args ExportArgs) ! { for _, mut col in a.collections { col.find_links()! col.init_git_info()! + col.title_descriptions()! } for _, mut col in a.collections { diff --git a/lib/web/doctree/core/page.v b/lib/web/doctree/core/page.v index 5289f910..757151b9 100644 --- a/lib/web/doctree/core/page.v +++ b/lib/web/doctree/core/page.v @@ -11,9 +11,18 @@ pub mut: collection_name string links []Link // macros []Macro + title string + description string + questions []Question collection &Collection @[skip; str: skip] // Reference to parent collection } +pub struct Question { +pub mut: + question string + answer string +} + @[params] pub struct NewPageArgs { pub: @@ -36,7 +45,7 @@ pub mut: include bool } -// Read content without processing includes +// Read content can be with or without processing includes pub fn (mut p Page) content(args ReadContentArgs) !string { mut mypath := p.path()! mut content := mypath.read()! diff --git a/lib/web/doctree/meta/model_page.v b/lib/web/doctree/meta/model_page.v index 87bf63d1..788806cf 100644 --- a/lib/web/doctree/meta/model_page.v +++ b/lib/web/doctree/meta/model_page.v @@ -1,7 +1,7 @@ module meta import incubaid.herolib.web.doctree.client as doctree_client -import incubaid.herolib.data.markdown.tools as markdowntools + // Page represents a single documentation page pub struct Page { @@ -9,24 +9,6 @@ pub mut: id string // Unique identifier: "collection:page_name" title string // Display title (optional, extracted from markdown if empty) description string // Brief description for metadata - questions []Question } -pub struct Question { -pub mut: - question string - answer string -} -pub fn (mut p Page) content(client doctree_client.DocTreeClient) !string { - mut c := client.get_page_content(p.id)! - - if p.title == '' { - p.title = markdowntools.extract_title(c) - } - // TODO in future should do AI - if p.description == '' { - p.description = p.title - } - return c -} diff --git a/lib/web/doctree/meta/utils.v b/lib/web/doctree/meta/utils.v deleted file mode 100644 index 3a10193b..00000000 --- a/lib/web/doctree/meta/utils.v +++ /dev/null @@ -1,2 +0,0 @@ -module meta -