fixed doc env vars + mongo v2 migration

This commit is contained in:
Stephan D
2026-01-31 00:26:42 +01:00
parent cbb7bd8ba6
commit 1aa7e287fb
356 changed files with 1705 additions and 1729 deletions

View File

@@ -3,7 +3,7 @@ package model
import (
"github.com/tech/sendico/pkg/db/storable"
"github.com/tech/sendico/pkg/mservice"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/v2/bson"
"golang.org/x/crypto/bcrypt"
)
@@ -49,11 +49,11 @@ func (a *Account) MatchPassword(password string) bool {
return err == nil
}
func AnonymousUserName(orgRef primitive.ObjectID) string {
func AnonymousUserName(orgRef bson.ObjectID) string {
return "anonymous@" + orgRef.Hex()
}
func AccountIsAnonymous(account *UserDataBase, orgRef primitive.ObjectID) bool {
func AccountIsAnonymous(account *UserDataBase, orgRef bson.ObjectID) bool {
if account == nil {
return false
}
@@ -61,13 +61,13 @@ func AccountIsAnonymous(account *UserDataBase, orgRef primitive.ObjectID) bool {
}
type AccountBound interface {
GetAccountRef() primitive.ObjectID
GetAccountRef() bson.ObjectID
}
type AccountBoundStorable interface {
storable.Storable
OrganizationBound
GetAccountRef() *primitive.ObjectID
GetAccountRef() *bson.ObjectID
}
const (
@@ -77,9 +77,9 @@ const (
type AccountBoundBase struct {
storable.Base `bson:",inline" json:",inline"`
OrganizationBoundBase `bson:",inline" json:",inline"`
AccountRef *primitive.ObjectID `bson:"accountRef,omitempty" json:"accountRef,omitempty"`
AccountRef *bson.ObjectID `bson:"accountRef,omitempty" json:"accountRef,omitempty"`
}
func (a *AccountBoundBase) GetAccountRef() *primitive.ObjectID {
func (a *AccountBoundBase) GetAccountRef() *bson.ObjectID {
return a.AccountRef
}

View File

@@ -3,7 +3,7 @@ package model
import (
"github.com/tech/sendico/pkg/db/storable"
"github.com/tech/sendico/pkg/mservice"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/v2/bson"
)
// Action represents a permissible action on a resource.
@@ -29,7 +29,7 @@ const (
type RoleDescription struct {
storable.Base `bson:",inline" json:",inline"` // Base fields for MongoDB documents
Describable `bson:",inline" json:",inline"` // Name and description fields
OrganizationRef primitive.ObjectID `bson:"organizationRef" json:"organizationRef"` // Organization associated with the role
OrganizationRef bson.ObjectID `bson:"organizationRef" json:"organizationRef"` // Organization associated with the role
}
// Collection specifies the MongoDB collection for RoleDescription.
@@ -39,9 +39,9 @@ func (*RoleDescription) Collection() string {
// Role represents a role assignment for an account within an organization.
type Role struct {
AccountRef primitive.ObjectID `bson:"accountRef" json:"accountRef"` // Account assigned to the role
DescriptionRef primitive.ObjectID `bson:"descriptionRef" json:"descriptionRef"` // Reference to the role's description
OrganizationRef primitive.ObjectID `bson:"organizationRef" json:"organizationRef"` // Organization where the role is applicable
AccountRef bson.ObjectID `bson:"accountRef" json:"accountRef"` // Account assigned to the role
DescriptionRef bson.ObjectID `bson:"descriptionRef" json:"descriptionRef"` // Reference to the role's description
OrganizationRef bson.ObjectID `bson:"organizationRef" json:"organizationRef"` // Organization where the role is applicable
}
// ActionEffect represents a combination of an action and its effect (allow/deny).
@@ -52,16 +52,16 @@ type ActionEffect struct {
// Policy defines access control rules for a role within an organization.
type Policy struct {
OrganizationRef primitive.ObjectID `bson:"organizationRef" json:"organizationRef"` // Organization associated with the policy
DescriptionRef primitive.ObjectID `bson:"descriptionRef" json:"descriptionRef"` // Reference to the policy's metadata
ObjectRef *primitive.ObjectID `bson:"objectRef,omitempty" json:"objectRef,omitempty"` // Target object (NilObjectID for all objects)
Effect ActionEffect `bson:"effect" json:"effect"` // Action and effect for the policy
OrganizationRef bson.ObjectID `bson:"organizationRef" json:"organizationRef"` // Organization associated with the policy
DescriptionRef bson.ObjectID `bson:"descriptionRef" json:"descriptionRef"` // Reference to the policy's metadata
ObjectRef *bson.ObjectID `bson:"objectRef,omitempty" json:"objectRef,omitempty"` // Target object (NilObjectID for all objects)
Effect ActionEffect `bson:"effect" json:"effect"` // Action and effect for the policy
}
// RolePolicy defines access control rules for a role within an organization.
type RolePolicy struct {
Policy `bson:",inline" json:",inline"`
RoleDescriptionRef primitive.ObjectID `bson:"roleDescriptionRef" json:"roleDescriptionRef"` // Reference to the associated role
RoleDescriptionRef bson.ObjectID `bson:"roleDescriptionRef" json:"roleDescriptionRef"` // Reference to the associated role
}
// PolicyDescription provides metadata for policies.
@@ -69,7 +69,7 @@ type PolicyDescription struct {
storable.Base `bson:",inline" json:",inline"` // Base fields for MongoDB documents
Describable `bson:",inline" json:",inline"` // Name and description fields
ResourceTypes *[]mservice.Type `bson:"resourceTypes,omitempty" json:"resourceTypes,omitempty"` // nil for custom policies, non-nil for built-in permissisons
OrganizationRef *primitive.ObjectID `bson:"organizationRef,omitempty" json:"organizationRef,omitempty"` // nil for built-in policies, non-nil for custom
OrganizationRef *bson.ObjectID `bson:"organizationRef,omitempty" json:"organizationRef,omitempty"` // nil for built-in policies, non-nil for custom
}
// Collection specifies the MongoDB collection for PolicyDescription.
@@ -80,5 +80,5 @@ func (*PolicyDescription) Collection() string {
// Permission ties a policy to a specific account.
type Permission struct {
RolePolicy `bson:",inline" json:",inline"` // Embedded policy definition
AccountRef primitive.ObjectID `bson:"accountRef" json:"accountRef"` // Account assigned the permission
AccountRef bson.ObjectID `bson:"accountRef" json:"accountRef"` // Account assigned the permission
}

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"github.com/tech/sendico/pkg/merrors"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/v2/bson"
)
type CardPaymentData struct {

View File

@@ -3,20 +3,20 @@ package model
import (
"github.com/tech/sendico/pkg/db/storable"
"github.com/tech/sendico/pkg/mservice"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/v2/bson"
)
type Client struct {
storable.Base `bson:",inline" json:",inline"`
ClientID string `bson:"clientId"`
ClientName string `bson:"clientName"`
ClientSecret string `bson:"clientSecret,omitempty"`
AllowedScopes []string `bson:"allowedScopes"`
RedirectURIs []string `bson:"redirectURIs"`
GrantTypes []string `bson:"grantTypes"`
TokenEndpointAuthMethod string `bson:"tokenEndpointAuthMethod"`
AccountRef *primitive.ObjectID `bson:"accountRef,omitempty"` // owner reference
IsRevoked bool `bson:"isRevoked"`
ClientID string `bson:"clientId"`
ClientName string `bson:"clientName"`
ClientSecret string `bson:"clientSecret,omitempty"`
AllowedScopes []string `bson:"allowedScopes"`
RedirectURIs []string `bson:"redirectURIs"`
GrantTypes []string `bson:"grantTypes"`
TokenEndpointAuthMethod string `bson:"tokenEndpointAuthMethod"`
AccountRef *bson.ObjectID `bson:"accountRef,omitempty"` // owner reference
IsRevoked bool `bson:"isRevoked"`
}
func (*Client) Collection() string {

View File

@@ -5,7 +5,7 @@ import (
"github.com/tech/sendico/pkg/db/storable"
"github.com/tech/sendico/pkg/mservice"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/v2/bson"
)
type ConfirmationTarget string
@@ -17,7 +17,7 @@ const (
type ConfirmationCode struct {
storable.Base `bson:",inline" json:",inline"`
AccountRef primitive.ObjectID `bson:"accountRef" json:"accountRef"`
AccountRef bson.ObjectID `bson:"accountRef" json:"accountRef"`
Destination string `bson:"destination" json:"destination"`
Target ConfirmationTarget `bson:"target" json:"target"`
CodeHash []byte `bson:"codeHash" json:"codeHash,omitempty"`

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"github.com/tech/sendico/pkg/merrors"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/v2/bson"
)
type CryptoAddressPaymentData struct {

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"github.com/tech/sendico/pkg/merrors"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/v2/bson"
)
// TokenPaymentData represents a network or gateway-issued card token.

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"github.com/tech/sendico/pkg/merrors"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/v2/bson"
)
type IbanPaymentData struct {

View File

@@ -5,7 +5,7 @@ import (
"github.com/tech/sendico/pkg/db/storable"
"github.com/tech/sendico/pkg/mservice"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/v2/bson"
)
type InvitationStatus string
@@ -31,12 +31,12 @@ func (id *invitationDesc) Collection() string {
type Invitation struct {
PermissionBound `bson:",inline" json:",inline"`
OrganizationRef primitive.ObjectID `bson:"organizationRef" json:"organizationRef"`
RoleRef primitive.ObjectID `bson:"roleRef" json:"roleRef"`
InviterRef primitive.ObjectID `bson:"inviterRef" json:"inviterRef"`
Status InvitationStatus `bson:"status" json:"status"`
ExpiresAt time.Time `bson:"expiresAt" json:"expiresAt"`
Content invitationDesc `bson:"description" json:"description"`
OrganizationRef bson.ObjectID `bson:"organizationRef" json:"organizationRef"`
RoleRef bson.ObjectID `bson:"roleRef" json:"roleRef"`
InviterRef bson.ObjectID `bson:"inviterRef" json:"inviterRef"`
Status InvitationStatus `bson:"status" json:"status"`
ExpiresAt time.Time `bson:"expiresAt" json:"expiresAt"`
Content invitationDesc `bson:"description" json:"description"`
}
func (*Invitation) Collection() string {

View File

@@ -6,7 +6,7 @@ import (
"github.com/tech/sendico/pkg/db/storable"
"github.com/tech/sendico/pkg/merrors"
"github.com/tech/sendico/pkg/mservice"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/v2/bson"
)
// AccountType defines the category of account (asset, liability, revenue, expense).
@@ -58,7 +58,7 @@ type LedgerAccount struct {
// OrganizationRef links the account to an organization.
// Must be set for organization accounts and nil for system accounts.
OrganizationRef *primitive.ObjectID `bson:"organizationRef,omitempty" json:"organizationRef,omitempty"`
OrganizationRef *bson.ObjectID `bson:"organizationRef,omitempty" json:"organizationRef,omitempty"`
// Role defines the functional purpose of the account within an organization
// (e.g., pending, operating, settlement, hold, etc.).
@@ -85,7 +85,7 @@ type LedgerAccount struct {
// OwnerRef optionally links the account to a specific owner entity
// (e.g., user or sub-entity within the organization).
OwnerRef *primitive.ObjectID `bson:"ownerRef,omitempty" json:"ownerRef,omitempty"`
OwnerRef *bson.ObjectID `bson:"ownerRef,omitempty" json:"ownerRef,omitempty"`
// Metadata holds additional arbitrary key-value attributes.
Metadata map[string]string `bson:"metadata,omitempty" json:"metadata,omitempty"`

View File

@@ -2,10 +2,10 @@ package model
import (
"github.com/tech/sendico/pkg/mservice"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/v2/bson"
)
type Link struct {
ObjectRef primitive.ObjectID `bson:"objectRef" json:"objectRef"`
Type mservice.Type `bson:"type" json:"type"`
ObjectRef bson.ObjectID `bson:"objectRef" json:"objectRef"`
Type mservice.Type `bson:"type" json:"type"`
}

View File

@@ -2,7 +2,7 @@ package model
import (
"github.com/tech/sendico/pkg/mservice"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/v2/bson"
)
type TypeBound struct {
@@ -11,10 +11,10 @@ type TypeBound struct {
type ObjectRefs struct {
TypeBound `bson:"inline" json:"inline"`
Refs []primitive.ObjectID `bson:"refs,omitempty" json:"refs,omitempty"`
Refs []bson.ObjectID `bson:"refs,omitempty" json:"refs,omitempty"`
}
type ObjectRef struct {
TypeBound `bson:"inline" json:"inline"`
Ref primitive.ObjectID `bson:"ref,omitempty" json:"ref,omitempty"`
Ref bson.ObjectID `bson:"ref,omitempty" json:"ref,omitempty"`
}

View File

@@ -2,15 +2,15 @@ package model
import (
"github.com/tech/sendico/pkg/mservice"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/v2/bson"
)
type OrganizationBase struct {
PermissionBound `bson:",inline" json:",inline"`
Describable `bson:",inline" json:",inline"`
TenantRef primitive.ObjectID `bson:"tenantRef" json:"tenantRef"`
TimeZone string `bson:"timeZone" json:"timeZone"`
LogoURL *string `bson:"logoUrl,omitempty" json:"logoUrl,omitempty"`
TenantRef bson.ObjectID `bson:"tenantRef" json:"tenantRef"`
TimeZone string `bson:"timeZone" json:"timeZone"`
LogoURL *string `bson:"logoUrl,omitempty" json:"logoUrl,omitempty"`
}
func (*OrganizationBase) Collection() string {
@@ -19,12 +19,12 @@ func (*OrganizationBase) Collection() string {
type Organization struct {
OrganizationBase `bson:",inline" json:",inline"`
Members []primitive.ObjectID `bson:"members" json:"members"`
Members []bson.ObjectID `bson:"members" json:"members"`
}
type OrganizationBound interface {
GetOrganizationRef() primitive.ObjectID
SetOrganizationRef(organizationRef primitive.ObjectID)
GetOrganizationRef() bson.ObjectID
SetOrganizationRef(organizationRef bson.ObjectID)
}
const (
@@ -32,13 +32,13 @@ const (
)
type OrganizationBoundBase struct {
OrganizationRef primitive.ObjectID `bson:"organizationRef" json:"organizationRef"`
OrganizationRef bson.ObjectID `bson:"organizationRef" json:"organizationRef"`
}
func (a *OrganizationBoundBase) GetOrganizationRef() primitive.ObjectID {
func (a *OrganizationBoundBase) GetOrganizationRef() bson.ObjectID {
return a.OrganizationRef
}
func (a *OrganizationBoundBase) SetOrganizationRef(organizationRef primitive.ObjectID) {
func (a *OrganizationBoundBase) SetOrganizationRef(organizationRef bson.ObjectID) {
a.OrganizationRef = organizationRef
}

View File

@@ -6,8 +6,7 @@ import (
"fmt"
"github.com/tech/sendico/pkg/merrors"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/v2/bson"
)
type PaymentType int
@@ -70,20 +69,20 @@ type PaymentMethod struct {
PermissionBound `bson:",inline" json:",inline"`
Describable `bson:",inline" json:",inline"`
RecipientRef primitive.ObjectID `bson:"recipientRef" json:"recipientRef"`
Type PaymentType `bson:"type" json:"type"`
Data bson.Raw `bson:"data" json:"data"`
IsMain bool `bson:"isMain" json:"isMain"`
RecipientRef bson.ObjectID `bson:"recipientRef" json:"recipientRef"`
Type PaymentType `bson:"type" json:"type"`
Data bson.Raw `bson:"data" json:"data"`
IsMain bool `bson:"isMain" json:"isMain"`
}
type paymentMethodJSON struct {
PermissionBound `json:",inline"`
Describable `json:",inline"`
RecipientRef primitive.ObjectID `json:"recipientRef"`
Type PaymentType `json:"type"`
Data json.RawMessage `json:"data"`
IsMain bool `json:"isMain"`
RecipientRef bson.ObjectID `json:"recipientRef"`
Type PaymentType `json:"type"`
Data json.RawMessage `json:"data"`
IsMain bool `json:"isMain"`
}
func (m PaymentMethod) MarshalJSON() ([]byte, error) {

View File

@@ -2,32 +2,32 @@ package model
import (
"github.com/tech/sendico/pkg/db/storable"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/v2/bson"
)
type PermissionBoundStorable interface {
storable.Storable
OrganizationBound
Archivable
GetPermissionRef() primitive.ObjectID
SetPermissionRef(permissionRef primitive.ObjectID)
GetPermissionRef() bson.ObjectID
SetPermissionRef(permissionRef bson.ObjectID)
}
type PermissionBound struct {
storable.Base `bson:",inline" json:",inline"`
ArchivableBase `bson:",inline" json:",inline"`
OrganizationBoundBase `bson:",inline" json:",inline"`
PermissionRef primitive.ObjectID `bson:"permissionRef" json:"permissionRef"`
PermissionRef bson.ObjectID `bson:"permissionRef" json:"permissionRef"`
}
func (b *PermissionBound) GetPermissionRef() primitive.ObjectID {
func (b *PermissionBound) GetPermissionRef() bson.ObjectID {
return b.PermissionRef
}
func (b *PermissionBound) GetOrganizationRef() primitive.ObjectID {
func (b *PermissionBound) GetOrganizationRef() bson.ObjectID {
return b.OrganizationRef
}
func (b *PermissionBound) SetPermissionRef(permissionRef primitive.ObjectID) {
func (b *PermissionBound) SetPermissionRef(permissionRef bson.ObjectID) {
b.PermissionRef = permissionRef
}

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"github.com/tech/sendico/pkg/merrors"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/v2/bson"
)
type RussianBankAccountPaymentData struct {

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"github.com/tech/sendico/pkg/merrors"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/v2/bson"
)
type WalletPaymentData struct {