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

@@ -12,8 +12,8 @@ import (
ri "github.com/tech/sendico/pkg/db/repository/index"
"github.com/tech/sendico/pkg/merrors"
"github.com/tech/sendico/pkg/mlogger"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.uber.org/zap"
)
@@ -86,7 +86,7 @@ func (p *Payments) Create(ctx context.Context, payment *model.Payment) error {
if strings.TrimSpace(payment.IdempotencyKey) == "" {
return merrors.InvalidArgument("paymentsStore: empty idempotencyKey")
}
if payment.OrganizationRef == primitive.NilObjectID {
if payment.OrganizationRef == bson.NilObjectID {
return merrors.InvalidArgument("paymentsStore: organization_ref is required")
}
@@ -138,9 +138,9 @@ func (p *Payments) GetByPaymentRef(ctx context.Context, paymentRef string) (*mod
return entity, nil
}
func (p *Payments) GetByIdempotencyKey(ctx context.Context, orgRef primitive.ObjectID, idempotencyKey string) (*model.Payment, error) {
func (p *Payments) GetByIdempotencyKey(ctx context.Context, orgRef bson.ObjectID, idempotencyKey string) (*model.Payment, error) {
idempotencyKey = strings.TrimSpace(idempotencyKey)
if orgRef == primitive.NilObjectID {
if orgRef == bson.NilObjectID {
return nil, merrors.InvalidArgument("paymentsStore: organization_ref is required")
}
if idempotencyKey == "" {
@@ -208,7 +208,7 @@ func (p *Payments) List(ctx context.Context, filter *model.PaymentFilter) (*mode
}
if cursor := strings.TrimSpace(filter.Cursor); cursor != "" {
if oid, err := primitive.ObjectIDFromHex(cursor); err == nil {
if oid, err := bson.ObjectIDFromHex(cursor); err == nil {
query = query.Comparison(repository.IDField(), builder.Gt, oid)
} else {
p.logger.Warn("ignoring invalid payments cursor", zap.String("cursor", cursor), zap.Error(err))

View File

@@ -11,8 +11,8 @@ import (
ri "github.com/tech/sendico/pkg/db/repository/index"
"github.com/tech/sendico/pkg/merrors"
"github.com/tech/sendico/pkg/mlogger"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.uber.org/zap"
)
@@ -75,7 +75,7 @@ func (p *PlanTemplates) Create(ctx context.Context, template *model.PaymentPlanT
return merrors.InvalidArgument("planTemplatesStore: steps are required")
}
if template.ID.IsZero() {
template.SetID(primitive.NewObjectID())
template.SetID(bson.NewObjectID())
} else {
template.Update()
}
@@ -112,8 +112,8 @@ func (p *PlanTemplates) Update(ctx context.Context, template *model.PaymentPlanT
return nil
}
func (p *PlanTemplates) GetByID(ctx context.Context, id primitive.ObjectID) (*model.PaymentPlanTemplate, error) {
if id == primitive.NilObjectID {
func (p *PlanTemplates) GetByID(ctx context.Context, id bson.ObjectID) (*model.PaymentPlanTemplate, error) {
if id == bson.NilObjectID {
return nil, merrors.InvalidArgument("planTemplatesStore: template id is required")
}
entity := &model.PaymentPlanTemplate{}

View File

@@ -14,7 +14,7 @@ import (
"github.com/tech/sendico/pkg/merrors"
"github.com/tech/sendico/pkg/mlogger"
"github.com/tech/sendico/pkg/mutil/mzap"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/v2/bson"
"go.uber.org/zap"
)
@@ -83,7 +83,7 @@ func (q *Quotes) Create(ctx context.Context, quote *model.PaymentQuoteRecord) er
if quote.QuoteRef == "" {
return merrors.InvalidArgument("quotesStore: empty quoteRef")
}
if quote.OrganizationRef == primitive.NilObjectID {
if quote.OrganizationRef == bson.NilObjectID {
return merrors.InvalidArgument("quotesStore: organization_ref is required")
}
quote.IdempotencyKey = strings.TrimSpace(quote.IdempotencyKey)
@@ -127,12 +127,12 @@ func (q *Quotes) Create(ctx context.Context, quote *model.PaymentQuoteRecord) er
return nil
}
func (q *Quotes) GetByRef(ctx context.Context, orgRef primitive.ObjectID, quoteRef string) (*model.PaymentQuoteRecord, error) {
func (q *Quotes) GetByRef(ctx context.Context, orgRef bson.ObjectID, quoteRef string) (*model.PaymentQuoteRecord, error) {
quoteRef = strings.TrimSpace(quoteRef)
if quoteRef == "" {
return nil, merrors.InvalidArgument("quotesStore: empty quoteRef")
}
if orgRef == primitive.NilObjectID {
if orgRef == bson.NilObjectID {
return nil, merrors.InvalidArgument("quotesStore: organization_ref is required")
}
entity := &model.PaymentQuoteRecord{}
@@ -152,12 +152,12 @@ func (q *Quotes) GetByRef(ctx context.Context, orgRef primitive.ObjectID, quoteR
return entity, nil
}
func (q *Quotes) GetByIdempotencyKey(ctx context.Context, orgRef primitive.ObjectID, idempotencyKey string) (*model.PaymentQuoteRecord, error) {
func (q *Quotes) GetByIdempotencyKey(ctx context.Context, orgRef bson.ObjectID, idempotencyKey string) (*model.PaymentQuoteRecord, error) {
idempotencyKey = strings.TrimSpace(idempotencyKey)
if idempotencyKey == "" {
return nil, merrors.InvalidArgument("quotesStore: empty idempotency key")
}
if orgRef == primitive.NilObjectID {
if orgRef == bson.NilObjectID {
return nil, merrors.InvalidArgument("quotesStore: organization_ref is required")
}
entity := &model.PaymentQuoteRecord{}

View File

@@ -11,8 +11,8 @@ import (
ri "github.com/tech/sendico/pkg/db/repository/index"
"github.com/tech/sendico/pkg/merrors"
"github.com/tech/sendico/pkg/mlogger"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.uber.org/zap"
)
@@ -72,7 +72,7 @@ func (r *Routes) Create(ctx context.Context, route *model.PaymentRoute) error {
return merrors.InvalidArgument("routesStore: to_rail is required")
}
if route.ID.IsZero() {
route.SetID(primitive.NewObjectID())
route.SetID(bson.NewObjectID())
} else {
route.Update()
}
@@ -109,8 +109,8 @@ func (r *Routes) Update(ctx context.Context, route *model.PaymentRoute) error {
return nil
}
func (r *Routes) GetByID(ctx context.Context, id primitive.ObjectID) (*model.PaymentRoute, error) {
if id == primitive.NilObjectID {
func (r *Routes) GetByID(ctx context.Context, id bson.ObjectID) (*model.PaymentRoute, error) {
if id == bson.NilObjectID {
return nil, merrors.InvalidArgument("routesStore: route id is required")
}
entity := &model.PaymentRoute{}

View File

@@ -4,7 +4,7 @@ import (
"context"
"github.com/tech/sendico/payments/orchestrator/storage/model"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/v2/bson"
)
type storageError string
@@ -46,7 +46,7 @@ type PaymentsStore interface {
Create(ctx context.Context, payment *model.Payment) error
Update(ctx context.Context, payment *model.Payment) error
GetByPaymentRef(ctx context.Context, paymentRef string) (*model.Payment, error)
GetByIdempotencyKey(ctx context.Context, orgRef primitive.ObjectID, idempotencyKey string) (*model.Payment, error)
GetByIdempotencyKey(ctx context.Context, orgRef bson.ObjectID, idempotencyKey string) (*model.Payment, error)
GetByChainTransferRef(ctx context.Context, transferRef string) (*model.Payment, error)
List(ctx context.Context, filter *model.PaymentFilter) (*model.PaymentList, error)
}
@@ -54,15 +54,15 @@ type PaymentsStore interface {
// QuotesStore manages temporary stored payment quotes.
type QuotesStore interface {
Create(ctx context.Context, quote *model.PaymentQuoteRecord) error
GetByRef(ctx context.Context, orgRef primitive.ObjectID, quoteRef string) (*model.PaymentQuoteRecord, error)
GetByIdempotencyKey(ctx context.Context, orgRef primitive.ObjectID, idempotencyKey string) (*model.PaymentQuoteRecord, error)
GetByRef(ctx context.Context, orgRef bson.ObjectID, quoteRef string) (*model.PaymentQuoteRecord, error)
GetByIdempotencyKey(ctx context.Context, orgRef bson.ObjectID, idempotencyKey string) (*model.PaymentQuoteRecord, error)
}
// RoutesStore manages allowed routing transitions.
type RoutesStore interface {
Create(ctx context.Context, route *model.PaymentRoute) error
Update(ctx context.Context, route *model.PaymentRoute) error
GetByID(ctx context.Context, id primitive.ObjectID) (*model.PaymentRoute, error)
GetByID(ctx context.Context, id bson.ObjectID) (*model.PaymentRoute, error)
List(ctx context.Context, filter *model.PaymentRouteFilter) (*model.PaymentRouteList, error)
}
@@ -70,6 +70,6 @@ type RoutesStore interface {
type PlanTemplatesStore interface {
Create(ctx context.Context, template *model.PaymentPlanTemplate) error
Update(ctx context.Context, template *model.PaymentPlanTemplate) error
GetByID(ctx context.Context, id primitive.ObjectID) (*model.PaymentPlanTemplate, error)
GetByID(ctx context.Context, id bson.ObjectID) (*model.PaymentPlanTemplate, error)
List(ctx context.Context, filter *model.PaymentPlanTemplateFilter) (*model.PaymentPlanTemplateList, error)
}