// Code generated by ent, DO NOT EDIT.

package transfer

import (
	"fmt"
	"time"

	"entgo.io/ent"
	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"github.com/google/uuid"
	"github.com/lightsparkdev/spark/so/ent/schema/schematype"
)

const (
	// Label holds the string label denoting the transfer type in the database.
	Label = "transfer"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldCreateTime holds the string denoting the create_time field in the database.
	FieldCreateTime = "create_time"
	// FieldUpdateTime holds the string denoting the update_time field in the database.
	FieldUpdateTime = "update_time"
	// FieldSenderIdentityPubkey holds the string denoting the sender_identity_pubkey field in the database.
	FieldSenderIdentityPubkey = "sender_identity_pubkey"
	// FieldReceiverIdentityPubkey holds the string denoting the receiver_identity_pubkey field in the database.
	FieldReceiverIdentityPubkey = "receiver_identity_pubkey"
	// FieldTotalValue holds the string denoting the total_value field in the database.
	FieldTotalValue = "total_value"
	// FieldStatus holds the string denoting the status field in the database.
	FieldStatus = "status"
	// FieldType holds the string denoting the type field in the database.
	FieldType = "type"
	// FieldExpiryTime holds the string denoting the expiry_time field in the database.
	FieldExpiryTime = "expiry_time"
	// FieldCompletionTime holds the string denoting the completion_time field in the database.
	FieldCompletionTime = "completion_time"
	// FieldSparkInvoiceID holds the string denoting the spark_invoice_id field in the database.
	FieldSparkInvoiceID = "spark_invoice_id"
	// EdgeTransferLeaves holds the string denoting the transfer_leaves edge name in mutations.
	EdgeTransferLeaves = "transfer_leaves"
	// EdgePaymentIntent holds the string denoting the payment_intent edge name in mutations.
	EdgePaymentIntent = "payment_intent"
	// EdgeSparkInvoice holds the string denoting the spark_invoice edge name in mutations.
	EdgeSparkInvoice = "spark_invoice"
	// EdgeCounterSwapTransfer holds the string denoting the counter_swap_transfer edge name in mutations.
	EdgeCounterSwapTransfer = "counter_swap_transfer"
	// EdgePrimarySwapTransfer holds the string denoting the primary_swap_transfer edge name in mutations.
	EdgePrimarySwapTransfer = "primary_swap_transfer"
	// Table holds the table name of the transfer in the database.
	Table = "transfers"
	// TransferLeavesTable is the table that holds the transfer_leaves relation/edge.
	TransferLeavesTable = "transfer_leafs"
	// TransferLeavesInverseTable is the table name for the TransferLeaf entity.
	// It exists in this package in order to avoid circular dependency with the "transferleaf" package.
	TransferLeavesInverseTable = "transfer_leafs"
	// TransferLeavesColumn is the table column denoting the transfer_leaves relation/edge.
	TransferLeavesColumn = "transfer_leaf_transfer"
	// PaymentIntentTable is the table that holds the payment_intent relation/edge.
	PaymentIntentTable = "transfers"
	// PaymentIntentInverseTable is the table name for the PaymentIntent entity.
	// It exists in this package in order to avoid circular dependency with the "paymentintent" package.
	PaymentIntentInverseTable = "payment_intents"
	// PaymentIntentColumn is the table column denoting the payment_intent relation/edge.
	PaymentIntentColumn = "transfer_payment_intent"
	// SparkInvoiceTable is the table that holds the spark_invoice relation/edge.
	SparkInvoiceTable = "transfers"
	// SparkInvoiceInverseTable is the table name for the SparkInvoice entity.
	// It exists in this package in order to avoid circular dependency with the "sparkinvoice" package.
	SparkInvoiceInverseTable = "spark_invoices"
	// SparkInvoiceColumn is the table column denoting the spark_invoice relation/edge.
	SparkInvoiceColumn = "spark_invoice_id"
	// CounterSwapTransferTable is the table that holds the counter_swap_transfer relation/edge.
	CounterSwapTransferTable = "transfers"
	// CounterSwapTransferColumn is the table column denoting the counter_swap_transfer relation/edge.
	CounterSwapTransferColumn = "transfer_counter_swap_transfer"
	// PrimarySwapTransferTable is the table that holds the primary_swap_transfer relation/edge.
	PrimarySwapTransferTable = "transfers"
	// PrimarySwapTransferColumn is the table column denoting the primary_swap_transfer relation/edge.
	PrimarySwapTransferColumn = "transfer_counter_swap_transfer"
)

// Columns holds all SQL columns for transfer fields.
var Columns = []string{
	FieldID,
	FieldCreateTime,
	FieldUpdateTime,
	FieldSenderIdentityPubkey,
	FieldReceiverIdentityPubkey,
	FieldTotalValue,
	FieldStatus,
	FieldType,
	FieldExpiryTime,
	FieldCompletionTime,
	FieldSparkInvoiceID,
}

// ForeignKeys holds the SQL foreign-keys that are owned by the "transfers"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
	"transfer_payment_intent",
	"transfer_counter_swap_transfer",
}

// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
	for i := range Columns {
		if column == Columns[i] {
			return true
		}
	}
	for i := range ForeignKeys {
		if column == ForeignKeys[i] {
			return true
		}
	}
	return false
}

// Note that the variables below are initialized by the runtime
// package on the initialization of the application. Therefore,
// it should be imported in the main as follows:
//
//	import _ "github.com/lightsparkdev/spark/so/ent/runtime"
var (
	Hooks [1]ent.Hook
	// DefaultCreateTime holds the default value on creation for the "create_time" field.
	DefaultCreateTime func() time.Time
	// DefaultUpdateTime holds the default value on creation for the "update_time" field.
	DefaultUpdateTime func() time.Time
	// UpdateDefaultUpdateTime holds the default value on update for the "update_time" field.
	UpdateDefaultUpdateTime func() time.Time
	// DefaultID holds the default value on creation for the "id" field.
	DefaultID func() uuid.UUID
)

// StatusValidator is a validator for the "status" field enum values. It is called by the builders before save.
func StatusValidator(s schematype.TransferStatus) error {
	switch s {
	case "SENDER_INITIATED", "SENDER_INITIATED_COORDINATOR", "SENDER_KEY_TWEAK_PENDING", "SENDER_KEY_TWEAKED", "RECEIVER_KEY_TWEAKED", "RECEIVER_KEY_TWEAK_LOCKED", "RECEIVER_REFUND_SIGNED", "COMPLETED", "EXPIRED", "RETURNED", "RECEIVER_KEY_TWEAK_APPLIED":
		return nil
	default:
		return fmt.Errorf("transfer: invalid enum value for status field: %q", s)
	}
}

// TypeValidator is a validator for the "type" field enum values. It is called by the builders before save.
func TypeValidator(_type schematype.TransferType) error {
	switch _type {
	case "PREIMAGE_SWAP", "COOPERATIVE_EXIT", "TRANSFER", "SWAP", "COUNTER_SWAP", "UTXO_SWAP":
		return nil
	default:
		return fmt.Errorf("transfer: invalid enum value for type field: %q", _type)
	}
}

// OrderOption defines the ordering options for the Transfer queries.
type OrderOption func(*sql.Selector)

// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldID, opts...).ToFunc()
}

// ByCreateTime orders the results by the create_time field.
func ByCreateTime(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldCreateTime, opts...).ToFunc()
}

// ByUpdateTime orders the results by the update_time field.
func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldUpdateTime, opts...).ToFunc()
}

// ByTotalValue orders the results by the total_value field.
func ByTotalValue(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldTotalValue, opts...).ToFunc()
}

// ByStatus orders the results by the status field.
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldStatus, opts...).ToFunc()
}

// ByType orders the results by the type field.
func ByType(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldType, opts...).ToFunc()
}

// ByExpiryTime orders the results by the expiry_time field.
func ByExpiryTime(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldExpiryTime, opts...).ToFunc()
}

// ByCompletionTime orders the results by the completion_time field.
func ByCompletionTime(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldCompletionTime, opts...).ToFunc()
}

// BySparkInvoiceID orders the results by the spark_invoice_id field.
func BySparkInvoiceID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldSparkInvoiceID, opts...).ToFunc()
}

// ByTransferLeavesCount orders the results by transfer_leaves count.
func ByTransferLeavesCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newTransferLeavesStep(), opts...)
	}
}

// ByTransferLeaves orders the results by transfer_leaves terms.
func ByTransferLeaves(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newTransferLeavesStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}

// ByPaymentIntentField orders the results by payment_intent field.
func ByPaymentIntentField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newPaymentIntentStep(), sql.OrderByField(field, opts...))
	}
}

// BySparkInvoiceField orders the results by spark_invoice field.
func BySparkInvoiceField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newSparkInvoiceStep(), sql.OrderByField(field, opts...))
	}
}

// ByCounterSwapTransferCount orders the results by counter_swap_transfer count.
func ByCounterSwapTransferCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newCounterSwapTransferStep(), opts...)
	}
}

// ByCounterSwapTransfer orders the results by counter_swap_transfer terms.
func ByCounterSwapTransfer(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newCounterSwapTransferStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}

// ByPrimarySwapTransferField orders the results by primary_swap_transfer field.
func ByPrimarySwapTransferField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newPrimarySwapTransferStep(), sql.OrderByField(field, opts...))
	}
}
func newTransferLeavesStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(TransferLeavesInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, true, TransferLeavesTable, TransferLeavesColumn),
	)
}
func newPaymentIntentStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(PaymentIntentInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, false, PaymentIntentTable, PaymentIntentColumn),
	)
}
func newSparkInvoiceStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(SparkInvoiceInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, false, SparkInvoiceTable, SparkInvoiceColumn),
	)
}
func newCounterSwapTransferStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(Table, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, CounterSwapTransferTable, CounterSwapTransferColumn),
	)
}
func newPrimarySwapTransferStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(Table, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, PrimarySwapTransferTable, PrimarySwapTransferColumn),
	)
}
