From 99bc97b104c95a74ac80da47252fc44509171dcb Mon Sep 17 00:00:00 2001 From: despiegk Date: Fri, 9 May 2025 12:42:42 +0300 Subject: [PATCH] model spec --- specs/models/base/base.v | 12 +++++++ specs/models/biz/company.v | 43 +++++++++++++++++++++++ specs/models/biz/meeting.v | 58 +++++++++++++++++++++++++++++++ specs/models/biz/product.v | 49 ++++++++++++++++++++++++++ specs/models/biz/sale.v | 41 ++++++++++++++++++++++ specs/models/biz/shareholder.v | 27 ++++++++++++++ specs/models/biz/user.v | 19 ++++++++++ specs/models/biz/vote.v | 51 +++++++++++++++++++++++++++ specs/models/circle/domainnames.v | 36 +++++++++++++++++++ specs/models/circle/group.v | 12 +++++++ specs/models/circle/user.v | 27 ++++++++++++++ specs/models/finance/account.v | 16 +++++++++ specs/models/finance/asset.v | 31 +++++++++++++++++ specs/models/mcc/calendar.v | 22 ++++++++++++ specs/models/mcc/contacts.v | 16 +++++++++ specs/models/mcc/message.v | 40 +++++++++++++++++++++ 16 files changed, 500 insertions(+) create mode 100644 specs/models/base/base.v create mode 100644 specs/models/biz/company.v create mode 100644 specs/models/biz/meeting.v create mode 100644 specs/models/biz/product.v create mode 100644 specs/models/biz/sale.v create mode 100644 specs/models/biz/shareholder.v create mode 100644 specs/models/biz/user.v create mode 100644 specs/models/biz/vote.v create mode 100644 specs/models/circle/domainnames.v create mode 100644 specs/models/circle/group.v create mode 100644 specs/models/circle/user.v create mode 100644 specs/models/finance/account.v create mode 100644 specs/models/finance/asset.v create mode 100644 specs/models/mcc/calendar.v create mode 100644 specs/models/mcc/contacts.v create mode 100644 specs/models/mcc/message.v diff --git a/specs/models/base/base.v b/specs/models/base/base.v new file mode 100644 index 0000000..ac7d24a --- /dev/null +++ b/specs/models/base/base.v @@ -0,0 +1,12 @@ +module base + +import freeflowuniverse.herolib.data.ourtime + +// our attempt to make a message object which can be used for email as well as chat +pub struct Base { +pub mut: + id u32 + creation_time ourtime.OurTime + mod_time ourtime.OurTime // Last modified time + comments []u32 +} diff --git a/specs/models/biz/company.v b/specs/models/biz/company.v new file mode 100644 index 0000000..5d44643 --- /dev/null +++ b/specs/models/biz/company.v @@ -0,0 +1,43 @@ +module biz +import base + +import freeflowuniverse.herolib.data.ourtime + + +// CompanyStatus represents the status of a company +pub enum CompanyStatus { + active + inactive + suspended +} + +// BusinessType represents the type of a business +pub enum BusinessType { + coop + single + twin + starter + global +} + +// Company represents a company registered in the Freezone +pub struct Company { + base.Base // Base struct for common fields +pub mut: + id u32 + name string + registration_number string + incorporation_date ourtime.OurTime + fiscal_year_end string + email string + phone string + website string + address string + business_type BusinessType + industry string + description string + status CompanyStatus + created_at ourtime.OurTime + updated_at ourtime.OurTime + shareholders []Shareholder +} diff --git a/specs/models/biz/meeting.v b/specs/models/biz/meeting.v new file mode 100644 index 0000000..549cbbd --- /dev/null +++ b/specs/models/biz/meeting.v @@ -0,0 +1,58 @@ +module biz +import base + +import freeflowuniverse.herolib.data.ourtime + + +// MeetingStatus represents the status of a meeting +pub enum MeetingStatus { + scheduled + completed + cancelled +} + +// AttendeeRole represents the role of an attendee in a meeting +pub enum AttendeeRole { + coordinator + member + secretary + participant + advisor + admin +} + +// AttendeeStatus represents the status of an attendee's participation +pub enum AttendeeStatus { + confirmed + pending + declined +} + +// Meeting represents a board meeting of a company or other meeting +pub struct Meeting { + base.Base // Base struct for common fields +pub mut: + id u32 + company_id u32 + title string + date ourtime.OurTime + location string + description string + status MeetingStatus + minutes string + created_at ourtime.OurTime + updated_at ourtime.OurTime + attendees []Attendee +} + +// Attendee represents an attendee of a board meeting +pub struct Attendee { +pub mut: + id u32 + meeting_id u32 + user_id u32 + name string + role AttendeeRole + status AttendeeStatus + created_at ourtime.OurTime +} diff --git a/specs/models/biz/product.v b/specs/models/biz/product.v new file mode 100644 index 0000000..3f49469 --- /dev/null +++ b/specs/models/biz/product.v @@ -0,0 +1,49 @@ +module biz +import base + +import freeflowuniverse.herolib.data.ourtime + +import freeflowuniverse.herolib.data.currency +// import freeflowuniverse.herolib.core.texttools { name_fix } + +// ProductType represents the type of a product +pub enum ProductType { + product + service +} + +// ProductStatus represents the status of a product +pub enum ProductStatus { + available + unavailable +} + +// ProductComponent represents a component of a product +pub struct ProductComponent { +pub mut: + id u32 + name string + description string + quantity int + created_at ourtime.OurTime + updated_at ourtime.OurTime +} + +// Product represents a product or service offered by the Freezone +pub struct Product { + base.Base // Base struct for common fields +pub mut: + id u32 + name string + description string + price currency.Currency + type_ ProductType + category string + status ProductStatus + created_at ourtime.OurTime + updated_at ourtime.OurTime + max_amount u16 // means allows us to define how many max of this there are + purchase_till ourtime.OurTime + active_till ourtime.OurTime // after this product no longer active if e.g. a service + components []ProductComponent +} diff --git a/specs/models/biz/sale.v b/specs/models/biz/sale.v new file mode 100644 index 0000000..1122dab --- /dev/null +++ b/specs/models/biz/sale.v @@ -0,0 +1,41 @@ +module biz +import base + +import freeflowuniverse.herolib.data.ourtime + +import freeflowuniverse.herolib.data.currency + +// SaleStatus represents the status of a sale +pub enum SaleStatus { + pending + completed + cancelled +} + +// Sale represents a sale of products or services +pub struct Sale { + base.Base // Base struct for common fields +pub mut: + id u32 + company_id u32 + buyer_name string + buyer_email string + total_amount currency.Currency + status SaleStatus + sale_date ourtime.OurTime + created_at ourtime.OurTime + updated_at ourtime.OurTime + items []SaleItem +} + +pub struct SaleItem { +pub mut: + id u32 + sale_id u32 + product_id u32 + name string + quantity int + unit_price currency.Currency + subtotal currency.Currency + active_till ourtime.OurTime // after this product no longer active if e.g. a service +} diff --git a/specs/models/biz/shareholder.v b/specs/models/biz/shareholder.v new file mode 100644 index 0000000..026a32a --- /dev/null +++ b/specs/models/biz/shareholder.v @@ -0,0 +1,27 @@ +module biz +import base + +import freeflowuniverse.herolib.data.ourtime + + +// ShareholderType represents the type of shareholder +pub enum ShareholderType { + individual + corporate +} + +// Shareholder represents a shareholder of a company +pub struct Shareholder { + base.Base // Base struct for common fields +pub mut: + id u32 + company_id u32 + user_id u32 + name string + shares f64 + percentage f64 + type_ ShareholderType + since ourtime.OurTime + created_at ourtime.OurTime + updated_at ourtime.OurTime +} diff --git a/specs/models/biz/user.v b/specs/models/biz/user.v new file mode 100644 index 0000000..d064b51 --- /dev/null +++ b/specs/models/biz/user.v @@ -0,0 +1,19 @@ +module biz +import base + +import freeflowuniverse.herolib.data.ourtime + + +// User represents a user in the Freezone Manager system +pub struct User { + base.Base // Base struct for common fields +pub mut: + id u32 + name string + email string + password string + company string // here its just a best effort + role string + created_at ourtime.OurTime + updated_at ourtime.OurTime +} diff --git a/specs/models/biz/vote.v b/specs/models/biz/vote.v new file mode 100644 index 0000000..7497944 --- /dev/null +++ b/specs/models/biz/vote.v @@ -0,0 +1,51 @@ +module biz +import base + +import freeflowuniverse.herolib.data.ourtime + + +// VoteStatus represents the status of a vote +pub enum VoteStatus { + open + closed + cancelled +} + +// Vote represents a voting item in the Freezone +pub struct Vote { + base.Base // Base struct for common fields +pub mut: + id u32 + company_id u32 + title string + description string + start_date ourtime.OurTime + end_date ourtime.OurTime + status VoteStatus + created_at ourtime.OurTime + updated_at ourtime.OurTime + options []VoteOption + ballots []Ballot + private_group []u32 // user id's only people who can vote +} + +// VoteOption represents an option in a vote +pub struct VoteOption { +pub mut: + id u8 + vote_id u32 + text string + count int + min_valid int // min votes we need to make total vote count +} + +// the vote as done by the user +pub struct Ballot { +pub mut: + id u32 + vote_id u32 + user_id u32 + vote_option_id u8 + shares_count int + created_at ourtime.OurTime +} diff --git a/specs/models/circle/domainnames.v b/specs/models/circle/domainnames.v new file mode 100644 index 0000000..228a0ea --- /dev/null +++ b/specs/models/circle/domainnames.v @@ -0,0 +1,36 @@ +module circle + +import base + +// Define the RecordType enum +pub enum RecordType { + a + aaa + cname + mx + ns + ptr + soa + srv + txt +} + +// Define the DomainNamespace struct, represents a full domain with all its records +pub struct DomainNameSpace { + base.Base +pub mut: + id u32 + domain string + description string + records []Record + admins []u32 // IDs of the admins they need to exist as user in the circle +} + +// Define the Record struct +pub struct Record { +pub mut: + name string + text string + category RecordType + addr []string +} diff --git a/specs/models/circle/group.v b/specs/models/circle/group.v new file mode 100644 index 0000000..410c3ab --- /dev/null +++ b/specs/models/circle/group.v @@ -0,0 +1,12 @@ +module circle + +import base + +// there is one group called "everyone" which is the default group for all members and their roles +pub struct Group { + base.Base +pub mut: + name string // name of the group in a circle, the one "everyone" is the default group + description string // optional description + members []u32 // pointers to the members of this group +} diff --git a/specs/models/circle/user.v b/specs/models/circle/user.v new file mode 100644 index 0000000..901eda6 --- /dev/null +++ b/specs/models/circle/user.v @@ -0,0 +1,27 @@ +module circle + +// import freeflowuniverse.herolib.data.ourtime +import base + +// Role represents the role of a member in a circle +pub enum Role { + admin + stakeholder + member + contributor + guest + external // means no right in this circle appart from we register this user +} + +// Member represents a member of a circle +pub struct User { + base.Base +pub mut: + name string // name of the member as used in this circle + description string // optional description which is relevant to this circle + role Role // role of the member in the circle + contact_ids []u32 // IDs of contacts linked to this member + wallet_ids []u32 // IDs of wallets owned by this member which are relevant to this circle + pubkey string // public key of the member as used in this circle +} + diff --git a/specs/models/finance/account.v b/specs/models/finance/account.v new file mode 100644 index 0000000..ed68423 --- /dev/null +++ b/specs/models/finance/account.v @@ -0,0 +1,16 @@ +module finance + +import base + +pub struct Account { + base.Base +pub mut: + name string // internal name of the account for the user + user_id u32 // user id of the owner of the account + description string // optional description of the account + ledger string // describes the ledger/blockchain where the account is located e.g. "ethereum", "bitcoin" or other institutions + address string // address of the account on the blockchain + pubkey string + assets []Asset +} + diff --git a/specs/models/finance/asset.v b/specs/models/finance/asset.v new file mode 100644 index 0000000..12990bf --- /dev/null +++ b/specs/models/finance/asset.v @@ -0,0 +1,31 @@ +module finance + +import base + +pub enum AssetType { + erc20 + erc721 + erc1155 + native +} + +pub struct Asset { + base.Base +pub mut: + name string + description string + amount f64 + address string // address of the asset on the blockchain or bank + asset_type AssetType // type of the asset + decimals u8 // number of decimals of the asset +} + +pub fn (self Asset) index_keys() map[string]string { + return { + 'name': self.name + } +} + +pub fn (self Asset) ftindex_keys() map[string]string { + return map[string]string{} +} diff --git a/specs/models/mcc/calendar.v b/specs/models/mcc/calendar.v new file mode 100644 index 0000000..794ebcf --- /dev/null +++ b/specs/models/mcc/calendar.v @@ -0,0 +1,22 @@ +module biz +import base + +import freeflowuniverse.herolib.data.ourtime + +// CalendarEvent represents a calendar event with all its properties +pub struct CalendarEvent { + base.Base +pub mut: + title string // Event title + description string // Event details + location string // Event location + start_time ourtime.OurTime + end_time ourtime.OurTime // End time + all_day bool // True if it's an all-day event + recurrence string // RFC 5545 Recurrence Rule (e.g., "FREQ=DAILY;COUNT=10") + attendees []u32 // List of contact id's + organizer u32 // The user (see circle) who created the event + status string // "CONFIRMED", "CANCELLED", "TENTATIVE" //TODO: make enum + color string // User-friendly color categorization, e.g., "red", "blue" //TODO: make enum + reminder []ourtime.OurTime // Reminder time before the event +} diff --git a/specs/models/mcc/contacts.v b/specs/models/mcc/contacts.v new file mode 100644 index 0000000..4cb3af6 --- /dev/null +++ b/specs/models/mcc/contacts.v @@ -0,0 +1,16 @@ +module biz +import base + +// import freeflowuniverse.herolib.data.ourtime + + +pub struct Contact { + base.Base +pub mut: + name string // name of the contact as we use in this circle + first_name string + last_name string + email []string + tel []string +} + diff --git a/specs/models/mcc/message.v b/specs/models/mcc/message.v new file mode 100644 index 0000000..d7b4926 --- /dev/null +++ b/specs/models/mcc/message.v @@ -0,0 +1,40 @@ +module biz +import base + +import freeflowuniverse.herolib.data.ourtime + +// our attempt to make a message object which can be used for email as well as chat +pub struct Message { + base.Base // Base struct for common fields +pub mut: + // Database ID + id u32 // Database ID (assigned by DBHandler) + message_id string // Unique identifier for the email + folder string // The folder this email belongs to (inbox, sent, drafts, etc.) + message string // The email body content + attachments []Attachment // Any file attachments + send_time ourtime.OurTime + + date i64 // Unix timestamp when the email was sent/received + size u32 // Size of the message in bytes + read bool // Whether the email has been read + flagged bool // Whether the email has been flagged/starred + + // Header information + subject string + from []u32 // List of user IDs (or email addresses) who sent the email user needs to exist in circle where we use this + sender []u32 + reply_to []u32 + to []u32 + cc []u32 + bcc []u32 + in_reply_to u32 +} + +// Attachment represents an email attachment +pub struct Attachment { +pub mut: + filename string + content_type string + hash string // Hash of the attachment data +}