// Code generated by ent, DO NOT EDIT.

package tokenoutput

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 tokenoutput type in the database.
	Label = "token_output"
	// 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"
	// FieldStatus holds the string denoting the status field in the database.
	FieldStatus = "status"
	// FieldOwnerPublicKey holds the string denoting the owner_public_key field in the database.
	FieldOwnerPublicKey = "owner_public_key"
	// FieldWithdrawBondSats holds the string denoting the withdraw_bond_sats field in the database.
	FieldWithdrawBondSats = "withdraw_bond_sats"
	// FieldWithdrawRelativeBlockLocktime holds the string denoting the withdraw_relative_block_locktime field in the database.
	FieldWithdrawRelativeBlockLocktime = "withdraw_relative_block_locktime"
	// FieldWithdrawRevocationCommitment holds the string denoting the withdraw_revocation_commitment field in the database.
	FieldWithdrawRevocationCommitment = "withdraw_revocation_commitment"
	// FieldTokenPublicKey holds the string denoting the token_public_key field in the database.
	FieldTokenPublicKey = "token_public_key"
	// FieldTokenAmount holds the string denoting the token_amount field in the database.
	FieldTokenAmount = "token_amount"
	// FieldCreatedTransactionOutputVout holds the string denoting the created_transaction_output_vout field in the database.
	FieldCreatedTransactionOutputVout = "created_transaction_output_vout"
	// FieldSpentOwnershipSignature holds the string denoting the spent_ownership_signature field in the database.
	FieldSpentOwnershipSignature = "spent_ownership_signature"
	// FieldSpentOperatorSpecificOwnershipSignature holds the string denoting the spent_operator_specific_ownership_signature field in the database.
	FieldSpentOperatorSpecificOwnershipSignature = "spent_operator_specific_ownership_signature"
	// FieldSpentTransactionInputVout holds the string denoting the spent_transaction_input_vout field in the database.
	FieldSpentTransactionInputVout = "spent_transaction_input_vout"
	// FieldSpentRevocationSecret holds the string denoting the spent_revocation_secret field in the database.
	FieldSpentRevocationSecret = "spent_revocation_secret"
	// FieldConfirmedWithdrawBlockHash holds the string denoting the confirmed_withdraw_block_hash field in the database.
	FieldConfirmedWithdrawBlockHash = "confirmed_withdraw_block_hash"
	// FieldNetwork holds the string denoting the network field in the database.
	FieldNetwork = "network"
	// FieldTokenIdentifier holds the string denoting the token_identifier field in the database.
	FieldTokenIdentifier = "token_identifier"
	// FieldTokenCreateID holds the string denoting the token_create_id field in the database.
	FieldTokenCreateID = "token_create_id"
	// EdgeRevocationKeyshare holds the string denoting the revocation_keyshare edge name in mutations.
	EdgeRevocationKeyshare = "revocation_keyshare"
	// EdgeOutputCreatedTokenTransaction holds the string denoting the output_created_token_transaction edge name in mutations.
	EdgeOutputCreatedTokenTransaction = "output_created_token_transaction"
	// EdgeOutputSpentTokenTransaction holds the string denoting the output_spent_token_transaction edge name in mutations.
	EdgeOutputSpentTokenTransaction = "output_spent_token_transaction"
	// EdgeOutputSpentStartedTokenTransactions holds the string denoting the output_spent_started_token_transactions edge name in mutations.
	EdgeOutputSpentStartedTokenTransactions = "output_spent_started_token_transactions"
	// EdgeTokenPartialRevocationSecretShares holds the string denoting the token_partial_revocation_secret_shares edge name in mutations.
	EdgeTokenPartialRevocationSecretShares = "token_partial_revocation_secret_shares"
	// EdgeTokenCreate holds the string denoting the token_create edge name in mutations.
	EdgeTokenCreate = "token_create"
	// Table holds the table name of the tokenoutput in the database.
	Table = "token_outputs"
	// RevocationKeyshareTable is the table that holds the revocation_keyshare relation/edge.
	RevocationKeyshareTable = "token_outputs"
	// RevocationKeyshareInverseTable is the table name for the SigningKeyshare entity.
	// It exists in this package in order to avoid circular dependency with the "signingkeyshare" package.
	RevocationKeyshareInverseTable = "signing_keyshares"
	// RevocationKeyshareColumn is the table column denoting the revocation_keyshare relation/edge.
	RevocationKeyshareColumn = "token_output_revocation_keyshare"
	// OutputCreatedTokenTransactionTable is the table that holds the output_created_token_transaction relation/edge.
	OutputCreatedTokenTransactionTable = "token_outputs"
	// OutputCreatedTokenTransactionInverseTable is the table name for the TokenTransaction entity.
	// It exists in this package in order to avoid circular dependency with the "tokentransaction" package.
	OutputCreatedTokenTransactionInverseTable = "token_transactions"
	// OutputCreatedTokenTransactionColumn is the table column denoting the output_created_token_transaction relation/edge.
	OutputCreatedTokenTransactionColumn = "token_output_output_created_token_transaction"
	// OutputSpentTokenTransactionTable is the table that holds the output_spent_token_transaction relation/edge.
	OutputSpentTokenTransactionTable = "token_outputs"
	// OutputSpentTokenTransactionInverseTable is the table name for the TokenTransaction entity.
	// It exists in this package in order to avoid circular dependency with the "tokentransaction" package.
	OutputSpentTokenTransactionInverseTable = "token_transactions"
	// OutputSpentTokenTransactionColumn is the table column denoting the output_spent_token_transaction relation/edge.
	OutputSpentTokenTransactionColumn = "token_output_output_spent_token_transaction"
	// OutputSpentStartedTokenTransactionsTable is the table that holds the output_spent_started_token_transactions relation/edge. The primary key declared below.
	OutputSpentStartedTokenTransactionsTable = "token_output_output_spent_started_token_transactions"
	// OutputSpentStartedTokenTransactionsInverseTable is the table name for the TokenTransaction entity.
	// It exists in this package in order to avoid circular dependency with the "tokentransaction" package.
	OutputSpentStartedTokenTransactionsInverseTable = "token_transactions"
	// TokenPartialRevocationSecretSharesTable is the table that holds the token_partial_revocation_secret_shares relation/edge.
	TokenPartialRevocationSecretSharesTable = "token_partial_revocation_secret_shares"
	// TokenPartialRevocationSecretSharesInverseTable is the table name for the TokenPartialRevocationSecretShare entity.
	// It exists in this package in order to avoid circular dependency with the "tokenpartialrevocationsecretshare" package.
	TokenPartialRevocationSecretSharesInverseTable = "token_partial_revocation_secret_shares"
	// TokenPartialRevocationSecretSharesColumn is the table column denoting the token_partial_revocation_secret_shares relation/edge.
	TokenPartialRevocationSecretSharesColumn = "token_output_token_partial_revocation_secret_shares"
	// TokenCreateTable is the table that holds the token_create relation/edge.
	TokenCreateTable = "token_outputs"
	// TokenCreateInverseTable is the table name for the TokenCreate entity.
	// It exists in this package in order to avoid circular dependency with the "tokencreate" package.
	TokenCreateInverseTable = "token_creates"
	// TokenCreateColumn is the table column denoting the token_create relation/edge.
	TokenCreateColumn = "token_create_id"
)

// Columns holds all SQL columns for tokenoutput fields.
var Columns = []string{
	FieldID,
	FieldCreateTime,
	FieldUpdateTime,
	FieldStatus,
	FieldOwnerPublicKey,
	FieldWithdrawBondSats,
	FieldWithdrawRelativeBlockLocktime,
	FieldWithdrawRevocationCommitment,
	FieldTokenPublicKey,
	FieldTokenAmount,
	FieldCreatedTransactionOutputVout,
	FieldSpentOwnershipSignature,
	FieldSpentOperatorSpecificOwnershipSignature,
	FieldSpentTransactionInputVout,
	FieldSpentRevocationSecret,
	FieldConfirmedWithdrawBlockHash,
	FieldNetwork,
	FieldTokenIdentifier,
	FieldTokenCreateID,
}

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

var (
	// OutputSpentStartedTokenTransactionsPrimaryKey and OutputSpentStartedTokenTransactionsColumn2 are the table columns denoting the
	// primary key for the output_spent_started_token_transactions relation (M2M).
	OutputSpentStartedTokenTransactionsPrimaryKey = []string{"token_output_id", "token_transaction_id"}
)

// 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
	// TokenAmountValidator is a validator for the "token_amount" field. It is called by the builders before save.
	TokenAmountValidator func([]byte) error
	// 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.TokenOutputStatus) error {
	switch s {
	case "CREATED_STARTED", "CREATED_STARTED_CANCELLED", "CREATED_SIGNED", "CREATED_SIGNED_CANCELLED", "CREATED_FINALIZED", "SPENT_STARTED", "SPENT_SIGNED", "SPENT_FINALIZED":
		return nil
	default:
		return fmt.Errorf("tokenoutput: invalid enum value for status field: %q", s)
	}
}

// NetworkValidator is a validator for the "network" field enum values. It is called by the builders before save.
func NetworkValidator(n schematype.Network) error {
	switch n {
	case "UNSPECIFIED", "MAINNET", "REGTEST", "TESTNET", "SIGNET":
		return nil
	default:
		return fmt.Errorf("tokenoutput: invalid enum value for network field: %q", n)
	}
}

// OrderOption defines the ordering options for the TokenOutput 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()
}

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

// ByWithdrawBondSats orders the results by the withdraw_bond_sats field.
func ByWithdrawBondSats(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldWithdrawBondSats, opts...).ToFunc()
}

// ByWithdrawRelativeBlockLocktime orders the results by the withdraw_relative_block_locktime field.
func ByWithdrawRelativeBlockLocktime(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldWithdrawRelativeBlockLocktime, opts...).ToFunc()
}

// ByCreatedTransactionOutputVout orders the results by the created_transaction_output_vout field.
func ByCreatedTransactionOutputVout(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldCreatedTransactionOutputVout, opts...).ToFunc()
}

// BySpentTransactionInputVout orders the results by the spent_transaction_input_vout field.
func BySpentTransactionInputVout(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldSpentTransactionInputVout, opts...).ToFunc()
}

// ByNetwork orders the results by the network field.
func ByNetwork(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldNetwork, opts...).ToFunc()
}

// ByTokenCreateID orders the results by the token_create_id field.
func ByTokenCreateID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldTokenCreateID, opts...).ToFunc()
}

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

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

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

// ByOutputSpentStartedTokenTransactionsCount orders the results by output_spent_started_token_transactions count.
func ByOutputSpentStartedTokenTransactionsCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newOutputSpentStartedTokenTransactionsStep(), opts...)
	}
}

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

// ByTokenPartialRevocationSecretSharesCount orders the results by token_partial_revocation_secret_shares count.
func ByTokenPartialRevocationSecretSharesCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newTokenPartialRevocationSecretSharesStep(), opts...)
	}
}

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

// ByTokenCreateField orders the results by token_create field.
func ByTokenCreateField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newTokenCreateStep(), sql.OrderByField(field, opts...))
	}
}
func newRevocationKeyshareStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(RevocationKeyshareInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, false, RevocationKeyshareTable, RevocationKeyshareColumn),
	)
}
func newOutputCreatedTokenTransactionStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(OutputCreatedTokenTransactionInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, false, OutputCreatedTokenTransactionTable, OutputCreatedTokenTransactionColumn),
	)
}
func newOutputSpentTokenTransactionStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(OutputSpentTokenTransactionInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, false, OutputSpentTokenTransactionTable, OutputSpentTokenTransactionColumn),
	)
}
func newOutputSpentStartedTokenTransactionsStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(OutputSpentStartedTokenTransactionsInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2M, false, OutputSpentStartedTokenTransactionsTable, OutputSpentStartedTokenTransactionsPrimaryKey...),
	)
}
func newTokenPartialRevocationSecretSharesStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(TokenPartialRevocationSecretSharesInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, TokenPartialRevocationSecretSharesTable, TokenPartialRevocationSecretSharesColumn),
	)
}
func newTokenCreateStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(TokenCreateInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, TokenCreateTable, TokenCreateColumn),
	)
}
