♻️ Refactor keybinding service

This commit is contained in:
2025-12-20 16:43:04 +08:00
parent 401eb3ab39
commit 7b746155f7
60 changed files with 4526 additions and 1816 deletions

View File

@@ -103,6 +103,9 @@ type EditingConfig struct {
TabSize int `json:"tabSize"` // Tab大小
TabType TabType `json:"tabType"` // Tab类型空格或Tab
// 快捷键模式
KeymapMode KeyBindingType `json:"keymapMode"` // 快捷键模式standard 或 emacs
// 保存选项
AutoSaveDelay int `json:"autoSaveDelay"` // 自动保存延迟(毫秒)
}
@@ -203,6 +206,8 @@ func NewDefaultAppConfig() *AppConfig {
EnableTabIndent: true,
TabSize: 4,
TabType: TabTypeTab,
// 快捷键模式
KeymapMode: Standard, // 默认使用标准模式
// 保存选项
AutoSaveDelay: 2000,
},

View File

@@ -17,7 +17,7 @@ type Document struct {
// ID of the ent.
ID int `json:"id,omitempty"`
// UUID for cross-device sync (UUIDv7)
UUID *string `json:"uuid"`
UUID string `json:"uuid"`
// creation time
CreatedAt string `json:"created_at"`
// update time
@@ -69,8 +69,7 @@ func (_m *Document) assignValues(columns []string, values []any) error {
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field uuid", values[i])
} else if value.Valid {
_m.UUID = new(string)
*_m.UUID = value.String
_m.UUID = value.String
}
case document.FieldCreatedAt:
if value, ok := values[i].(*sql.NullString); !ok {
@@ -145,10 +144,8 @@ func (_m *Document) String() string {
var builder strings.Builder
builder.WriteString("Document(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
if v := _m.UUID; v != nil {
builder.WriteString("uuid=")
builder.WriteString(*v)
}
builder.WriteString("uuid=")
builder.WriteString(_m.UUID)
builder.WriteString(", ")
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt)

View File

@@ -143,16 +143,6 @@ func UUIDHasSuffix(v string) predicate.Document {
return predicate.Document(sql.FieldHasSuffix(FieldUUID, v))
}
// UUIDIsNil applies the IsNil predicate on the "uuid" field.
func UUIDIsNil() predicate.Document {
return predicate.Document(sql.FieldIsNull(FieldUUID))
}
// UUIDNotNil applies the NotNil predicate on the "uuid" field.
func UUIDNotNil() predicate.Document {
return predicate.Document(sql.FieldNotNull(FieldUUID))
}
// UUIDEqualFold applies the EqualFold predicate on the "uuid" field.
func UUIDEqualFold(v string) predicate.Document {
return predicate.Document(sql.FieldEqualFold(FieldUUID, v))

View File

@@ -180,6 +180,9 @@ func (_c *DocumentCreate) defaults() error {
// check runs all checks and user-defined validators on the builder.
func (_c *DocumentCreate) check() error {
if _, ok := _c.mutation.UUID(); !ok {
return &ValidationError{Name: "uuid", err: errors.New(`ent: missing required field "Document.uuid"`)}
}
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Document.created_at"`)}
}
@@ -225,7 +228,7 @@ func (_c *DocumentCreate) createSpec() (*Document, *sqlgraph.CreateSpec) {
)
if value, ok := _c.mutation.UUID(); ok {
_spec.SetField(document.FieldUUID, field.TypeString, value)
_node.UUID = &value
_node.UUID = value
}
if value, ok := _c.mutation.CreatedAt(); ok {
_spec.SetField(document.FieldCreatedAt, field.TypeString, value)

View File

@@ -170,9 +170,6 @@ func (_u *DocumentUpdate) sqlSave(ctx context.Context) (_node int, err error) {
}
}
}
if _u.mutation.UUIDCleared() {
_spec.ClearField(document.FieldUUID, field.TypeString)
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(document.FieldUpdatedAt, field.TypeString, value)
}
@@ -388,9 +385,6 @@ func (_u *DocumentUpdateOne) sqlSave(ctx context.Context) (_node *Document, err
}
}
}
if _u.mutation.UUIDCleared() {
_spec.ClearField(document.FieldUUID, field.TypeString)
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(document.FieldUpdatedAt, field.TypeString, value)
}

View File

@@ -52,7 +52,7 @@ var schemaGraph = func() *sqlgraph.Schema {
extension.FieldCreatedAt: {Type: field.TypeString, Column: extension.FieldCreatedAt},
extension.FieldUpdatedAt: {Type: field.TypeString, Column: extension.FieldUpdatedAt},
extension.FieldDeletedAt: {Type: field.TypeString, Column: extension.FieldDeletedAt},
extension.FieldKey: {Type: field.TypeString, Column: extension.FieldKey},
extension.FieldName: {Type: field.TypeString, Column: extension.FieldName},
extension.FieldEnabled: {Type: field.TypeBool, Column: extension.FieldEnabled},
extension.FieldConfig: {Type: field.TypeJSON, Column: extension.FieldConfig},
},
@@ -68,14 +68,20 @@ var schemaGraph = func() *sqlgraph.Schema {
},
Type: "KeyBinding",
Fields: map[string]*sqlgraph.FieldSpec{
keybinding.FieldUUID: {Type: field.TypeString, Column: keybinding.FieldUUID},
keybinding.FieldCreatedAt: {Type: field.TypeString, Column: keybinding.FieldCreatedAt},
keybinding.FieldUpdatedAt: {Type: field.TypeString, Column: keybinding.FieldUpdatedAt},
keybinding.FieldDeletedAt: {Type: field.TypeString, Column: keybinding.FieldDeletedAt},
keybinding.FieldKey: {Type: field.TypeString, Column: keybinding.FieldKey},
keybinding.FieldCommand: {Type: field.TypeString, Column: keybinding.FieldCommand},
keybinding.FieldExtension: {Type: field.TypeString, Column: keybinding.FieldExtension},
keybinding.FieldEnabled: {Type: field.TypeBool, Column: keybinding.FieldEnabled},
keybinding.FieldUUID: {Type: field.TypeString, Column: keybinding.FieldUUID},
keybinding.FieldCreatedAt: {Type: field.TypeString, Column: keybinding.FieldCreatedAt},
keybinding.FieldUpdatedAt: {Type: field.TypeString, Column: keybinding.FieldUpdatedAt},
keybinding.FieldDeletedAt: {Type: field.TypeString, Column: keybinding.FieldDeletedAt},
keybinding.FieldName: {Type: field.TypeString, Column: keybinding.FieldName},
keybinding.FieldType: {Type: field.TypeString, Column: keybinding.FieldType},
keybinding.FieldKey: {Type: field.TypeString, Column: keybinding.FieldKey},
keybinding.FieldMacos: {Type: field.TypeString, Column: keybinding.FieldMacos},
keybinding.FieldWindows: {Type: field.TypeString, Column: keybinding.FieldWindows},
keybinding.FieldLinux: {Type: field.TypeString, Column: keybinding.FieldLinux},
keybinding.FieldExtension: {Type: field.TypeString, Column: keybinding.FieldExtension},
keybinding.FieldEnabled: {Type: field.TypeBool, Column: keybinding.FieldEnabled},
keybinding.FieldPreventDefault: {Type: field.TypeBool, Column: keybinding.FieldPreventDefault},
keybinding.FieldScope: {Type: field.TypeString, Column: keybinding.FieldScope},
},
}
graph.Nodes[3] = &sqlgraph.Node{
@@ -93,7 +99,7 @@ var schemaGraph = func() *sqlgraph.Schema {
theme.FieldCreatedAt: {Type: field.TypeString, Column: theme.FieldCreatedAt},
theme.FieldUpdatedAt: {Type: field.TypeString, Column: theme.FieldUpdatedAt},
theme.FieldDeletedAt: {Type: field.TypeString, Column: theme.FieldDeletedAt},
theme.FieldKey: {Type: field.TypeString, Column: theme.FieldKey},
theme.FieldName: {Type: field.TypeString, Column: theme.FieldName},
theme.FieldType: {Type: field.TypeEnum, Column: theme.FieldType},
theme.FieldColors: {Type: field.TypeJSON, Column: theme.FieldColors},
},
@@ -242,9 +248,9 @@ func (f *ExtensionFilter) WhereDeletedAt(p entql.StringP) {
f.Where(p.Field(extension.FieldDeletedAt))
}
// WhereKey applies the entql string predicate on the key field.
func (f *ExtensionFilter) WhereKey(p entql.StringP) {
f.Where(p.Field(extension.FieldKey))
// WhereName applies the entql string predicate on the name field.
func (f *ExtensionFilter) WhereName(p entql.StringP) {
f.Where(p.Field(extension.FieldName))
}
// WhereEnabled applies the entql bool predicate on the enabled field.
@@ -317,14 +323,34 @@ func (f *KeyBindingFilter) WhereDeletedAt(p entql.StringP) {
f.Where(p.Field(keybinding.FieldDeletedAt))
}
// WhereName applies the entql string predicate on the name field.
func (f *KeyBindingFilter) WhereName(p entql.StringP) {
f.Where(p.Field(keybinding.FieldName))
}
// WhereType applies the entql string predicate on the type field.
func (f *KeyBindingFilter) WhereType(p entql.StringP) {
f.Where(p.Field(keybinding.FieldType))
}
// WhereKey applies the entql string predicate on the key field.
func (f *KeyBindingFilter) WhereKey(p entql.StringP) {
f.Where(p.Field(keybinding.FieldKey))
}
// WhereCommand applies the entql string predicate on the command field.
func (f *KeyBindingFilter) WhereCommand(p entql.StringP) {
f.Where(p.Field(keybinding.FieldCommand))
// WhereMacos applies the entql string predicate on the macos field.
func (f *KeyBindingFilter) WhereMacos(p entql.StringP) {
f.Where(p.Field(keybinding.FieldMacos))
}
// WhereWindows applies the entql string predicate on the windows field.
func (f *KeyBindingFilter) WhereWindows(p entql.StringP) {
f.Where(p.Field(keybinding.FieldWindows))
}
// WhereLinux applies the entql string predicate on the linux field.
func (f *KeyBindingFilter) WhereLinux(p entql.StringP) {
f.Where(p.Field(keybinding.FieldLinux))
}
// WhereExtension applies the entql string predicate on the extension field.
@@ -337,6 +363,16 @@ func (f *KeyBindingFilter) WhereEnabled(p entql.BoolP) {
f.Where(p.Field(keybinding.FieldEnabled))
}
// WherePreventDefault applies the entql bool predicate on the prevent_default field.
func (f *KeyBindingFilter) WherePreventDefault(p entql.BoolP) {
f.Where(p.Field(keybinding.FieldPreventDefault))
}
// WhereScope applies the entql string predicate on the scope field.
func (f *KeyBindingFilter) WhereScope(p entql.StringP) {
f.Where(p.Field(keybinding.FieldScope))
}
// addPredicate implements the predicateAdder interface.
func (_q *ThemeQuery) addPredicate(pred func(s *sql.Selector)) {
_q.predicates = append(_q.predicates, pred)
@@ -397,9 +433,9 @@ func (f *ThemeFilter) WhereDeletedAt(p entql.StringP) {
f.Where(p.Field(theme.FieldDeletedAt))
}
// WhereKey applies the entql string predicate on the key field.
func (f *ThemeFilter) WhereKey(p entql.StringP) {
f.Where(p.Field(theme.FieldKey))
// WhereName applies the entql string predicate on the name field.
func (f *ThemeFilter) WhereName(p entql.StringP) {
f.Where(p.Field(theme.FieldName))
}
// WhereType applies the entql string predicate on the type field.

View File

@@ -18,15 +18,15 @@ type Extension struct {
// ID of the ent.
ID int `json:"id,omitempty"`
// UUID for cross-device sync (UUIDv7)
UUID *string `json:"uuid"`
UUID string `json:"uuid"`
// creation time
CreatedAt string `json:"created_at"`
// update time
UpdatedAt string `json:"updated_at"`
// deleted at
DeletedAt *string `json:"deleted_at,omitempty"`
// extension key
Key string `json:"key"`
// extension name
Name string `json:"name"`
// extension enabled or not
Enabled bool `json:"enabled"`
// extension config
@@ -45,7 +45,7 @@ func (*Extension) scanValues(columns []string) ([]any, error) {
values[i] = new(sql.NullBool)
case extension.FieldID:
values[i] = new(sql.NullInt64)
case extension.FieldUUID, extension.FieldCreatedAt, extension.FieldUpdatedAt, extension.FieldDeletedAt, extension.FieldKey:
case extension.FieldUUID, extension.FieldCreatedAt, extension.FieldUpdatedAt, extension.FieldDeletedAt, extension.FieldName:
values[i] = new(sql.NullString)
default:
values[i] = new(sql.UnknownType)
@@ -72,8 +72,7 @@ func (_m *Extension) assignValues(columns []string, values []any) error {
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field uuid", values[i])
} else if value.Valid {
_m.UUID = new(string)
*_m.UUID = value.String
_m.UUID = value.String
}
case extension.FieldCreatedAt:
if value, ok := values[i].(*sql.NullString); !ok {
@@ -94,11 +93,11 @@ func (_m *Extension) assignValues(columns []string, values []any) error {
_m.DeletedAt = new(string)
*_m.DeletedAt = value.String
}
case extension.FieldKey:
case extension.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field key", values[i])
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
_m.Key = value.String
_m.Name = value.String
}
case extension.FieldEnabled:
if value, ok := values[i].(*sql.NullBool); !ok {
@@ -150,10 +149,8 @@ func (_m *Extension) String() string {
var builder strings.Builder
builder.WriteString("Extension(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
if v := _m.UUID; v != nil {
builder.WriteString("uuid=")
builder.WriteString(*v)
}
builder.WriteString("uuid=")
builder.WriteString(_m.UUID)
builder.WriteString(", ")
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt)
@@ -166,8 +163,8 @@ func (_m *Extension) String() string {
builder.WriteString(*v)
}
builder.WriteString(", ")
builder.WriteString("key=")
builder.WriteString(_m.Key)
builder.WriteString("name=")
builder.WriteString(_m.Name)
builder.WriteString(", ")
builder.WriteString("enabled=")
builder.WriteString(fmt.Sprintf("%v", _m.Enabled))

View File

@@ -20,8 +20,8 @@ const (
FieldUpdatedAt = "updated_at"
// FieldDeletedAt holds the string denoting the deleted_at field in the database.
FieldDeletedAt = "deleted_at"
// FieldKey holds the string denoting the key field in the database.
FieldKey = "key"
// FieldName holds the string denoting the name field in the database.
FieldName = "name"
// FieldEnabled holds the string denoting the enabled field in the database.
FieldEnabled = "enabled"
// FieldConfig holds the string denoting the config field in the database.
@@ -37,7 +37,7 @@ var Columns = []string{
FieldCreatedAt,
FieldUpdatedAt,
FieldDeletedAt,
FieldKey,
FieldName,
FieldEnabled,
FieldConfig,
}
@@ -66,8 +66,8 @@ var (
DefaultCreatedAt func() string
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
DefaultUpdatedAt func() string
// KeyValidator is a validator for the "key" field. It is called by the builders before save.
KeyValidator func(string) error
// NameValidator is a validator for the "name" field. It is called by the builders before save.
NameValidator func(string) error
// DefaultEnabled holds the default value on creation for the "enabled" field.
DefaultEnabled bool
)
@@ -100,9 +100,9 @@ func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
}
// ByKey orders the results by the key field.
func ByKey(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldKey, opts...).ToFunc()
// ByName orders the results by the name field.
func ByName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldName, opts...).ToFunc()
}
// ByEnabled orders the results by the enabled field.

View File

@@ -73,9 +73,9 @@ func DeletedAt(v string) predicate.Extension {
return predicate.Extension(sql.FieldEQ(FieldDeletedAt, v))
}
// Key applies equality check predicate on the "key" field. It's identical to KeyEQ.
func Key(v string) predicate.Extension {
return predicate.Extension(sql.FieldEQ(FieldKey, v))
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
func Name(v string) predicate.Extension {
return predicate.Extension(sql.FieldEQ(FieldName, v))
}
// Enabled applies equality check predicate on the "enabled" field. It's identical to EnabledEQ.
@@ -138,16 +138,6 @@ func UUIDHasSuffix(v string) predicate.Extension {
return predicate.Extension(sql.FieldHasSuffix(FieldUUID, v))
}
// UUIDIsNil applies the IsNil predicate on the "uuid" field.
func UUIDIsNil() predicate.Extension {
return predicate.Extension(sql.FieldIsNull(FieldUUID))
}
// UUIDNotNil applies the NotNil predicate on the "uuid" field.
func UUIDNotNil() predicate.Extension {
return predicate.Extension(sql.FieldNotNull(FieldUUID))
}
// UUIDEqualFold applies the EqualFold predicate on the "uuid" field.
func UUIDEqualFold(v string) predicate.Extension {
return predicate.Extension(sql.FieldEqualFold(FieldUUID, v))
@@ -363,69 +353,69 @@ func DeletedAtContainsFold(v string) predicate.Extension {
return predicate.Extension(sql.FieldContainsFold(FieldDeletedAt, v))
}
// KeyEQ applies the EQ predicate on the "key" field.
func KeyEQ(v string) predicate.Extension {
return predicate.Extension(sql.FieldEQ(FieldKey, v))
// NameEQ applies the EQ predicate on the "name" field.
func NameEQ(v string) predicate.Extension {
return predicate.Extension(sql.FieldEQ(FieldName, v))
}
// KeyNEQ applies the NEQ predicate on the "key" field.
func KeyNEQ(v string) predicate.Extension {
return predicate.Extension(sql.FieldNEQ(FieldKey, v))
// NameNEQ applies the NEQ predicate on the "name" field.
func NameNEQ(v string) predicate.Extension {
return predicate.Extension(sql.FieldNEQ(FieldName, v))
}
// KeyIn applies the In predicate on the "key" field.
func KeyIn(vs ...string) predicate.Extension {
return predicate.Extension(sql.FieldIn(FieldKey, vs...))
// NameIn applies the In predicate on the "name" field.
func NameIn(vs ...string) predicate.Extension {
return predicate.Extension(sql.FieldIn(FieldName, vs...))
}
// KeyNotIn applies the NotIn predicate on the "key" field.
func KeyNotIn(vs ...string) predicate.Extension {
return predicate.Extension(sql.FieldNotIn(FieldKey, vs...))
// NameNotIn applies the NotIn predicate on the "name" field.
func NameNotIn(vs ...string) predicate.Extension {
return predicate.Extension(sql.FieldNotIn(FieldName, vs...))
}
// KeyGT applies the GT predicate on the "key" field.
func KeyGT(v string) predicate.Extension {
return predicate.Extension(sql.FieldGT(FieldKey, v))
// NameGT applies the GT predicate on the "name" field.
func NameGT(v string) predicate.Extension {
return predicate.Extension(sql.FieldGT(FieldName, v))
}
// KeyGTE applies the GTE predicate on the "key" field.
func KeyGTE(v string) predicate.Extension {
return predicate.Extension(sql.FieldGTE(FieldKey, v))
// NameGTE applies the GTE predicate on the "name" field.
func NameGTE(v string) predicate.Extension {
return predicate.Extension(sql.FieldGTE(FieldName, v))
}
// KeyLT applies the LT predicate on the "key" field.
func KeyLT(v string) predicate.Extension {
return predicate.Extension(sql.FieldLT(FieldKey, v))
// NameLT applies the LT predicate on the "name" field.
func NameLT(v string) predicate.Extension {
return predicate.Extension(sql.FieldLT(FieldName, v))
}
// KeyLTE applies the LTE predicate on the "key" field.
func KeyLTE(v string) predicate.Extension {
return predicate.Extension(sql.FieldLTE(FieldKey, v))
// NameLTE applies the LTE predicate on the "name" field.
func NameLTE(v string) predicate.Extension {
return predicate.Extension(sql.FieldLTE(FieldName, v))
}
// KeyContains applies the Contains predicate on the "key" field.
func KeyContains(v string) predicate.Extension {
return predicate.Extension(sql.FieldContains(FieldKey, v))
// NameContains applies the Contains predicate on the "name" field.
func NameContains(v string) predicate.Extension {
return predicate.Extension(sql.FieldContains(FieldName, v))
}
// KeyHasPrefix applies the HasPrefix predicate on the "key" field.
func KeyHasPrefix(v string) predicate.Extension {
return predicate.Extension(sql.FieldHasPrefix(FieldKey, v))
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
func NameHasPrefix(v string) predicate.Extension {
return predicate.Extension(sql.FieldHasPrefix(FieldName, v))
}
// KeyHasSuffix applies the HasSuffix predicate on the "key" field.
func KeyHasSuffix(v string) predicate.Extension {
return predicate.Extension(sql.FieldHasSuffix(FieldKey, v))
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
func NameHasSuffix(v string) predicate.Extension {
return predicate.Extension(sql.FieldHasSuffix(FieldName, v))
}
// KeyEqualFold applies the EqualFold predicate on the "key" field.
func KeyEqualFold(v string) predicate.Extension {
return predicate.Extension(sql.FieldEqualFold(FieldKey, v))
// NameEqualFold applies the EqualFold predicate on the "name" field.
func NameEqualFold(v string) predicate.Extension {
return predicate.Extension(sql.FieldEqualFold(FieldName, v))
}
// KeyContainsFold applies the ContainsFold predicate on the "key" field.
func KeyContainsFold(v string) predicate.Extension {
return predicate.Extension(sql.FieldContainsFold(FieldKey, v))
// NameContainsFold applies the ContainsFold predicate on the "name" field.
func NameContainsFold(v string) predicate.Extension {
return predicate.Extension(sql.FieldContainsFold(FieldName, v))
}
// EnabledEQ applies the EQ predicate on the "enabled" field.

View File

@@ -75,9 +75,9 @@ func (_c *ExtensionCreate) SetNillableDeletedAt(v *string) *ExtensionCreate {
return _c
}
// SetKey sets the "key" field.
func (_c *ExtensionCreate) SetKey(v string) *ExtensionCreate {
_c.mutation.SetKey(v)
// SetName sets the "name" field.
func (_c *ExtensionCreate) SetName(v string) *ExtensionCreate {
_c.mutation.SetName(v)
return _c
}
@@ -168,18 +168,21 @@ func (_c *ExtensionCreate) defaults() error {
// check runs all checks and user-defined validators on the builder.
func (_c *ExtensionCreate) check() error {
if _, ok := _c.mutation.UUID(); !ok {
return &ValidationError{Name: "uuid", err: errors.New(`ent: missing required field "Extension.uuid"`)}
}
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Extension.created_at"`)}
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Extension.updated_at"`)}
}
if _, ok := _c.mutation.Key(); !ok {
return &ValidationError{Name: "key", err: errors.New(`ent: missing required field "Extension.key"`)}
if _, ok := _c.mutation.Name(); !ok {
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Extension.name"`)}
}
if v, ok := _c.mutation.Key(); ok {
if err := extension.KeyValidator(v); err != nil {
return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "Extension.key": %w`, err)}
if v, ok := _c.mutation.Name(); ok {
if err := extension.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Extension.name": %w`, err)}
}
}
if _, ok := _c.mutation.Enabled(); !ok {
@@ -213,7 +216,7 @@ func (_c *ExtensionCreate) createSpec() (*Extension, *sqlgraph.CreateSpec) {
)
if value, ok := _c.mutation.UUID(); ok {
_spec.SetField(extension.FieldUUID, field.TypeString, value)
_node.UUID = &value
_node.UUID = value
}
if value, ok := _c.mutation.CreatedAt(); ok {
_spec.SetField(extension.FieldCreatedAt, field.TypeString, value)
@@ -227,9 +230,9 @@ func (_c *ExtensionCreate) createSpec() (*Extension, *sqlgraph.CreateSpec) {
_spec.SetField(extension.FieldDeletedAt, field.TypeString, value)
_node.DeletedAt = &value
}
if value, ok := _c.mutation.Key(); ok {
_spec.SetField(extension.FieldKey, field.TypeString, value)
_node.Key = value
if value, ok := _c.mutation.Name(); ok {
_spec.SetField(extension.FieldName, field.TypeString, value)
_node.Name = value
}
if value, ok := _c.mutation.Enabled(); ok {
_spec.SetField(extension.FieldEnabled, field.TypeBool, value)

View File

@@ -62,16 +62,16 @@ func (_u *ExtensionUpdate) ClearDeletedAt() *ExtensionUpdate {
return _u
}
// SetKey sets the "key" field.
func (_u *ExtensionUpdate) SetKey(v string) *ExtensionUpdate {
_u.mutation.SetKey(v)
// SetName sets the "name" field.
func (_u *ExtensionUpdate) SetName(v string) *ExtensionUpdate {
_u.mutation.SetName(v)
return _u
}
// SetNillableKey sets the "key" field if the given value is not nil.
func (_u *ExtensionUpdate) SetNillableKey(v *string) *ExtensionUpdate {
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *ExtensionUpdate) SetNillableName(v *string) *ExtensionUpdate {
if v != nil {
_u.SetKey(*v)
_u.SetName(*v)
}
return _u
}
@@ -136,9 +136,9 @@ func (_u *ExtensionUpdate) ExecX(ctx context.Context) {
// check runs all checks and user-defined validators on the builder.
func (_u *ExtensionUpdate) check() error {
if v, ok := _u.mutation.Key(); ok {
if err := extension.KeyValidator(v); err != nil {
return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "Extension.key": %w`, err)}
if v, ok := _u.mutation.Name(); ok {
if err := extension.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Extension.name": %w`, err)}
}
}
return nil
@@ -162,9 +162,6 @@ func (_u *ExtensionUpdate) sqlSave(ctx context.Context) (_node int, err error) {
}
}
}
if _u.mutation.UUIDCleared() {
_spec.ClearField(extension.FieldUUID, field.TypeString)
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(extension.FieldUpdatedAt, field.TypeString, value)
}
@@ -174,8 +171,8 @@ func (_u *ExtensionUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if _u.mutation.DeletedAtCleared() {
_spec.ClearField(extension.FieldDeletedAt, field.TypeString)
}
if value, ok := _u.mutation.Key(); ok {
_spec.SetField(extension.FieldKey, field.TypeString, value)
if value, ok := _u.mutation.Name(); ok {
_spec.SetField(extension.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.Enabled(); ok {
_spec.SetField(extension.FieldEnabled, field.TypeBool, value)
@@ -242,16 +239,16 @@ func (_u *ExtensionUpdateOne) ClearDeletedAt() *ExtensionUpdateOne {
return _u
}
// SetKey sets the "key" field.
func (_u *ExtensionUpdateOne) SetKey(v string) *ExtensionUpdateOne {
_u.mutation.SetKey(v)
// SetName sets the "name" field.
func (_u *ExtensionUpdateOne) SetName(v string) *ExtensionUpdateOne {
_u.mutation.SetName(v)
return _u
}
// SetNillableKey sets the "key" field if the given value is not nil.
func (_u *ExtensionUpdateOne) SetNillableKey(v *string) *ExtensionUpdateOne {
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *ExtensionUpdateOne) SetNillableName(v *string) *ExtensionUpdateOne {
if v != nil {
_u.SetKey(*v)
_u.SetName(*v)
}
return _u
}
@@ -329,9 +326,9 @@ func (_u *ExtensionUpdateOne) ExecX(ctx context.Context) {
// check runs all checks and user-defined validators on the builder.
func (_u *ExtensionUpdateOne) check() error {
if v, ok := _u.mutation.Key(); ok {
if err := extension.KeyValidator(v); err != nil {
return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "Extension.key": %w`, err)}
if v, ok := _u.mutation.Name(); ok {
if err := extension.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Extension.name": %w`, err)}
}
}
return nil
@@ -372,9 +369,6 @@ func (_u *ExtensionUpdateOne) sqlSave(ctx context.Context) (_node *Extension, er
}
}
}
if _u.mutation.UUIDCleared() {
_spec.ClearField(extension.FieldUUID, field.TypeString)
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(extension.FieldUpdatedAt, field.TypeString, value)
}
@@ -384,8 +378,8 @@ func (_u *ExtensionUpdateOne) sqlSave(ctx context.Context) (_node *Extension, er
if _u.mutation.DeletedAtCleared() {
_spec.ClearField(extension.FieldDeletedAt, field.TypeString)
}
if value, ok := _u.mutation.Key(); ok {
_spec.SetField(extension.FieldKey, field.TypeString, value)
if value, ok := _u.mutation.Name(); ok {
_spec.SetField(extension.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.Enabled(); ok {
_spec.SetField(extension.FieldEnabled, field.TypeBool, value)

View File

@@ -17,21 +17,33 @@ type KeyBinding struct {
// ID of the ent.
ID int `json:"id,omitempty"`
// UUID for cross-device sync (UUIDv7)
UUID *string `json:"uuid"`
UUID string `json:"uuid"`
// creation time
CreatedAt string `json:"created_at"`
// update time
UpdatedAt string `json:"updated_at"`
// deleted at
DeletedAt *string `json:"deleted_at,omitempty"`
// key binding key
Key string `json:"key"`
// key binding command
Command string `json:"command"`
// key binding extension
Extension string `json:"extension,omitempty"`
// key binding enabled
Enabled bool `json:"enabled"`
// command identifier
Name string `json:"name"`
// keybinding type: standard or emacs
Type string `json:"type"`
// universal keybinding (cross-platform)
Key string `json:"key,omitempty"`
// macOS specific keybinding
Macos string `json:"macos,omitempty"`
// Windows specific keybinding
Windows string `json:"windows,omitempty"`
// Linux specific keybinding
Linux string `json:"linux,omitempty"`
// extension name (functional category)
Extension string `json:"extension"`
// whether this keybinding is enabled
Enabled bool `json:"enabled"`
// prevent browser default behavior
PreventDefault bool `json:"preventDefault"`
// keybinding scope (default: editor)
Scope string `json:"scope,omitempty"`
selectValues sql.SelectValues
}
@@ -40,11 +52,11 @@ func (*KeyBinding) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case keybinding.FieldEnabled:
case keybinding.FieldEnabled, keybinding.FieldPreventDefault:
values[i] = new(sql.NullBool)
case keybinding.FieldID:
values[i] = new(sql.NullInt64)
case keybinding.FieldUUID, keybinding.FieldCreatedAt, keybinding.FieldUpdatedAt, keybinding.FieldDeletedAt, keybinding.FieldKey, keybinding.FieldCommand, keybinding.FieldExtension:
case keybinding.FieldUUID, keybinding.FieldCreatedAt, keybinding.FieldUpdatedAt, keybinding.FieldDeletedAt, keybinding.FieldName, keybinding.FieldType, keybinding.FieldKey, keybinding.FieldMacos, keybinding.FieldWindows, keybinding.FieldLinux, keybinding.FieldExtension, keybinding.FieldScope:
values[i] = new(sql.NullString)
default:
values[i] = new(sql.UnknownType)
@@ -71,8 +83,7 @@ func (_m *KeyBinding) assignValues(columns []string, values []any) error {
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field uuid", values[i])
} else if value.Valid {
_m.UUID = new(string)
*_m.UUID = value.String
_m.UUID = value.String
}
case keybinding.FieldCreatedAt:
if value, ok := values[i].(*sql.NullString); !ok {
@@ -93,17 +104,41 @@ func (_m *KeyBinding) assignValues(columns []string, values []any) error {
_m.DeletedAt = new(string)
*_m.DeletedAt = value.String
}
case keybinding.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
_m.Name = value.String
}
case keybinding.FieldType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field type", values[i])
} else if value.Valid {
_m.Type = value.String
}
case keybinding.FieldKey:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field key", values[i])
} else if value.Valid {
_m.Key = value.String
}
case keybinding.FieldCommand:
case keybinding.FieldMacos:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field command", values[i])
return fmt.Errorf("unexpected type %T for field macos", values[i])
} else if value.Valid {
_m.Command = value.String
_m.Macos = value.String
}
case keybinding.FieldWindows:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field windows", values[i])
} else if value.Valid {
_m.Windows = value.String
}
case keybinding.FieldLinux:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field linux", values[i])
} else if value.Valid {
_m.Linux = value.String
}
case keybinding.FieldExtension:
if value, ok := values[i].(*sql.NullString); !ok {
@@ -117,6 +152,18 @@ func (_m *KeyBinding) assignValues(columns []string, values []any) error {
} else if value.Valid {
_m.Enabled = value.Bool
}
case keybinding.FieldPreventDefault:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field prevent_default", values[i])
} else if value.Valid {
_m.PreventDefault = value.Bool
}
case keybinding.FieldScope:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field scope", values[i])
} else if value.Valid {
_m.Scope = value.String
}
default:
_m.selectValues.Set(columns[i], values[i])
}
@@ -153,10 +200,8 @@ func (_m *KeyBinding) String() string {
var builder strings.Builder
builder.WriteString("KeyBinding(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
if v := _m.UUID; v != nil {
builder.WriteString("uuid=")
builder.WriteString(*v)
}
builder.WriteString("uuid=")
builder.WriteString(_m.UUID)
builder.WriteString(", ")
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt)
@@ -169,17 +214,35 @@ func (_m *KeyBinding) String() string {
builder.WriteString(*v)
}
builder.WriteString(", ")
builder.WriteString("name=")
builder.WriteString(_m.Name)
builder.WriteString(", ")
builder.WriteString("type=")
builder.WriteString(_m.Type)
builder.WriteString(", ")
builder.WriteString("key=")
builder.WriteString(_m.Key)
builder.WriteString(", ")
builder.WriteString("command=")
builder.WriteString(_m.Command)
builder.WriteString("macos=")
builder.WriteString(_m.Macos)
builder.WriteString(", ")
builder.WriteString("windows=")
builder.WriteString(_m.Windows)
builder.WriteString(", ")
builder.WriteString("linux=")
builder.WriteString(_m.Linux)
builder.WriteString(", ")
builder.WriteString("extension=")
builder.WriteString(_m.Extension)
builder.WriteString(", ")
builder.WriteString("enabled=")
builder.WriteString(fmt.Sprintf("%v", _m.Enabled))
builder.WriteString(", ")
builder.WriteString("prevent_default=")
builder.WriteString(fmt.Sprintf("%v", _m.PreventDefault))
builder.WriteString(", ")
builder.WriteString("scope=")
builder.WriteString(_m.Scope)
builder.WriteByte(')')
return builder.String()
}

View File

@@ -20,14 +20,26 @@ const (
FieldUpdatedAt = "updated_at"
// FieldDeletedAt holds the string denoting the deleted_at field in the database.
FieldDeletedAt = "deleted_at"
// FieldName holds the string denoting the name field in the database.
FieldName = "name"
// FieldType holds the string denoting the type field in the database.
FieldType = "type"
// FieldKey holds the string denoting the key field in the database.
FieldKey = "key"
// FieldCommand holds the string denoting the command field in the database.
FieldCommand = "command"
// FieldMacos holds the string denoting the macos field in the database.
FieldMacos = "macos"
// FieldWindows holds the string denoting the windows field in the database.
FieldWindows = "windows"
// FieldLinux holds the string denoting the linux field in the database.
FieldLinux = "linux"
// FieldExtension holds the string denoting the extension field in the database.
FieldExtension = "extension"
// FieldEnabled holds the string denoting the enabled field in the database.
FieldEnabled = "enabled"
// FieldPreventDefault holds the string denoting the prevent_default field in the database.
FieldPreventDefault = "prevent_default"
// FieldScope holds the string denoting the scope field in the database.
FieldScope = "scope"
// Table holds the table name of the keybinding in the database.
Table = "key_bindings"
)
@@ -39,10 +51,16 @@ var Columns = []string{
FieldCreatedAt,
FieldUpdatedAt,
FieldDeletedAt,
FieldName,
FieldType,
FieldKey,
FieldCommand,
FieldMacos,
FieldWindows,
FieldLinux,
FieldExtension,
FieldEnabled,
FieldPreventDefault,
FieldScope,
}
// ValidColumn reports if the column name is valid (part of the table columns).
@@ -69,14 +87,30 @@ var (
DefaultCreatedAt func() string
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
DefaultUpdatedAt func() string
// NameValidator is a validator for the "name" field. It is called by the builders before save.
NameValidator func(string) error
// DefaultType holds the default value on creation for the "type" field.
DefaultType string
// TypeValidator is a validator for the "type" field. It is called by the builders before save.
TypeValidator func(string) error
// KeyValidator is a validator for the "key" field. It is called by the builders before save.
KeyValidator func(string) error
// CommandValidator is a validator for the "command" field. It is called by the builders before save.
CommandValidator func(string) error
// MacosValidator is a validator for the "macos" field. It is called by the builders before save.
MacosValidator func(string) error
// WindowsValidator is a validator for the "windows" field. It is called by the builders before save.
WindowsValidator func(string) error
// LinuxValidator is a validator for the "linux" field. It is called by the builders before save.
LinuxValidator func(string) error
// ExtensionValidator is a validator for the "extension" field. It is called by the builders before save.
ExtensionValidator func(string) error
// DefaultEnabled holds the default value on creation for the "enabled" field.
DefaultEnabled bool
// DefaultPreventDefault holds the default value on creation for the "prevent_default" field.
DefaultPreventDefault bool
// DefaultScope holds the default value on creation for the "scope" field.
DefaultScope string
// ScopeValidator is a validator for the "scope" field. It is called by the builders before save.
ScopeValidator func(string) error
)
// OrderOption defines the ordering options for the KeyBinding queries.
@@ -107,14 +141,34 @@ func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
}
// ByName orders the results by the name field.
func ByName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldName, opts...).ToFunc()
}
// ByType orders the results by the type field.
func ByType(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldType, opts...).ToFunc()
}
// ByKey orders the results by the key field.
func ByKey(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldKey, opts...).ToFunc()
}
// ByCommand orders the results by the command field.
func ByCommand(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCommand, opts...).ToFunc()
// ByMacos orders the results by the macos field.
func ByMacos(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMacos, opts...).ToFunc()
}
// ByWindows orders the results by the windows field.
func ByWindows(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldWindows, opts...).ToFunc()
}
// ByLinux orders the results by the linux field.
func ByLinux(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLinux, opts...).ToFunc()
}
// ByExtension orders the results by the extension field.
@@ -126,3 +180,13 @@ func ByExtension(opts ...sql.OrderTermOption) OrderOption {
func ByEnabled(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldEnabled, opts...).ToFunc()
}
// ByPreventDefault orders the results by the prevent_default field.
func ByPreventDefault(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPreventDefault, opts...).ToFunc()
}
// ByScope orders the results by the scope field.
func ByScope(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldScope, opts...).ToFunc()
}

View File

@@ -73,14 +73,34 @@ func DeletedAt(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEQ(FieldDeletedAt, v))
}
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
func Name(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEQ(FieldName, v))
}
// Type applies equality check predicate on the "type" field. It's identical to TypeEQ.
func Type(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEQ(FieldType, v))
}
// Key applies equality check predicate on the "key" field. It's identical to KeyEQ.
func Key(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEQ(FieldKey, v))
}
// Command applies equality check predicate on the "command" field. It's identical to CommandEQ.
func Command(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEQ(FieldCommand, v))
// Macos applies equality check predicate on the "macos" field. It's identical to MacosEQ.
func Macos(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEQ(FieldMacos, v))
}
// Windows applies equality check predicate on the "windows" field. It's identical to WindowsEQ.
func Windows(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEQ(FieldWindows, v))
}
// Linux applies equality check predicate on the "linux" field. It's identical to LinuxEQ.
func Linux(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEQ(FieldLinux, v))
}
// Extension applies equality check predicate on the "extension" field. It's identical to ExtensionEQ.
@@ -93,6 +113,16 @@ func Enabled(v bool) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEQ(FieldEnabled, v))
}
// PreventDefault applies equality check predicate on the "prevent_default" field. It's identical to PreventDefaultEQ.
func PreventDefault(v bool) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEQ(FieldPreventDefault, v))
}
// Scope applies equality check predicate on the "scope" field. It's identical to ScopeEQ.
func Scope(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEQ(FieldScope, v))
}
// UUIDEQ applies the EQ predicate on the "uuid" field.
func UUIDEQ(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEQ(FieldUUID, v))
@@ -148,16 +178,6 @@ func UUIDHasSuffix(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldHasSuffix(FieldUUID, v))
}
// UUIDIsNil applies the IsNil predicate on the "uuid" field.
func UUIDIsNil() predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldIsNull(FieldUUID))
}
// UUIDNotNil applies the NotNil predicate on the "uuid" field.
func UUIDNotNil() predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldNotNull(FieldUUID))
}
// UUIDEqualFold applies the EqualFold predicate on the "uuid" field.
func UUIDEqualFold(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEqualFold(FieldUUID, v))
@@ -373,6 +393,136 @@ func DeletedAtContainsFold(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldContainsFold(FieldDeletedAt, v))
}
// NameEQ applies the EQ predicate on the "name" field.
func NameEQ(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEQ(FieldName, v))
}
// NameNEQ applies the NEQ predicate on the "name" field.
func NameNEQ(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldNEQ(FieldName, v))
}
// NameIn applies the In predicate on the "name" field.
func NameIn(vs ...string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldIn(FieldName, vs...))
}
// NameNotIn applies the NotIn predicate on the "name" field.
func NameNotIn(vs ...string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldNotIn(FieldName, vs...))
}
// NameGT applies the GT predicate on the "name" field.
func NameGT(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldGT(FieldName, v))
}
// NameGTE applies the GTE predicate on the "name" field.
func NameGTE(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldGTE(FieldName, v))
}
// NameLT applies the LT predicate on the "name" field.
func NameLT(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldLT(FieldName, v))
}
// NameLTE applies the LTE predicate on the "name" field.
func NameLTE(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldLTE(FieldName, v))
}
// NameContains applies the Contains predicate on the "name" field.
func NameContains(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldContains(FieldName, v))
}
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
func NameHasPrefix(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldHasPrefix(FieldName, v))
}
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
func NameHasSuffix(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldHasSuffix(FieldName, v))
}
// NameEqualFold applies the EqualFold predicate on the "name" field.
func NameEqualFold(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEqualFold(FieldName, v))
}
// NameContainsFold applies the ContainsFold predicate on the "name" field.
func NameContainsFold(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldContainsFold(FieldName, v))
}
// TypeEQ applies the EQ predicate on the "type" field.
func TypeEQ(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEQ(FieldType, v))
}
// TypeNEQ applies the NEQ predicate on the "type" field.
func TypeNEQ(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldNEQ(FieldType, v))
}
// TypeIn applies the In predicate on the "type" field.
func TypeIn(vs ...string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldIn(FieldType, vs...))
}
// TypeNotIn applies the NotIn predicate on the "type" field.
func TypeNotIn(vs ...string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldNotIn(FieldType, vs...))
}
// TypeGT applies the GT predicate on the "type" field.
func TypeGT(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldGT(FieldType, v))
}
// TypeGTE applies the GTE predicate on the "type" field.
func TypeGTE(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldGTE(FieldType, v))
}
// TypeLT applies the LT predicate on the "type" field.
func TypeLT(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldLT(FieldType, v))
}
// TypeLTE applies the LTE predicate on the "type" field.
func TypeLTE(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldLTE(FieldType, v))
}
// TypeContains applies the Contains predicate on the "type" field.
func TypeContains(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldContains(FieldType, v))
}
// TypeHasPrefix applies the HasPrefix predicate on the "type" field.
func TypeHasPrefix(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldHasPrefix(FieldType, v))
}
// TypeHasSuffix applies the HasSuffix predicate on the "type" field.
func TypeHasSuffix(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldHasSuffix(FieldType, v))
}
// TypeEqualFold applies the EqualFold predicate on the "type" field.
func TypeEqualFold(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEqualFold(FieldType, v))
}
// TypeContainsFold applies the ContainsFold predicate on the "type" field.
func TypeContainsFold(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldContainsFold(FieldType, v))
}
// KeyEQ applies the EQ predicate on the "key" field.
func KeyEQ(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEQ(FieldKey, v))
@@ -428,6 +578,16 @@ func KeyHasSuffix(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldHasSuffix(FieldKey, v))
}
// KeyIsNil applies the IsNil predicate on the "key" field.
func KeyIsNil() predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldIsNull(FieldKey))
}
// KeyNotNil applies the NotNil predicate on the "key" field.
func KeyNotNil() predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldNotNull(FieldKey))
}
// KeyEqualFold applies the EqualFold predicate on the "key" field.
func KeyEqualFold(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEqualFold(FieldKey, v))
@@ -438,69 +598,229 @@ func KeyContainsFold(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldContainsFold(FieldKey, v))
}
// CommandEQ applies the EQ predicate on the "command" field.
func CommandEQ(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEQ(FieldCommand, v))
// MacosEQ applies the EQ predicate on the "macos" field.
func MacosEQ(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEQ(FieldMacos, v))
}
// CommandNEQ applies the NEQ predicate on the "command" field.
func CommandNEQ(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldNEQ(FieldCommand, v))
// MacosNEQ applies the NEQ predicate on the "macos" field.
func MacosNEQ(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldNEQ(FieldMacos, v))
}
// CommandIn applies the In predicate on the "command" field.
func CommandIn(vs ...string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldIn(FieldCommand, vs...))
// MacosIn applies the In predicate on the "macos" field.
func MacosIn(vs ...string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldIn(FieldMacos, vs...))
}
// CommandNotIn applies the NotIn predicate on the "command" field.
func CommandNotIn(vs ...string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldNotIn(FieldCommand, vs...))
// MacosNotIn applies the NotIn predicate on the "macos" field.
func MacosNotIn(vs ...string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldNotIn(FieldMacos, vs...))
}
// CommandGT applies the GT predicate on the "command" field.
func CommandGT(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldGT(FieldCommand, v))
// MacosGT applies the GT predicate on the "macos" field.
func MacosGT(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldGT(FieldMacos, v))
}
// CommandGTE applies the GTE predicate on the "command" field.
func CommandGTE(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldGTE(FieldCommand, v))
// MacosGTE applies the GTE predicate on the "macos" field.
func MacosGTE(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldGTE(FieldMacos, v))
}
// CommandLT applies the LT predicate on the "command" field.
func CommandLT(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldLT(FieldCommand, v))
// MacosLT applies the LT predicate on the "macos" field.
func MacosLT(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldLT(FieldMacos, v))
}
// CommandLTE applies the LTE predicate on the "command" field.
func CommandLTE(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldLTE(FieldCommand, v))
// MacosLTE applies the LTE predicate on the "macos" field.
func MacosLTE(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldLTE(FieldMacos, v))
}
// CommandContains applies the Contains predicate on the "command" field.
func CommandContains(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldContains(FieldCommand, v))
// MacosContains applies the Contains predicate on the "macos" field.
func MacosContains(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldContains(FieldMacos, v))
}
// CommandHasPrefix applies the HasPrefix predicate on the "command" field.
func CommandHasPrefix(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldHasPrefix(FieldCommand, v))
// MacosHasPrefix applies the HasPrefix predicate on the "macos" field.
func MacosHasPrefix(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldHasPrefix(FieldMacos, v))
}
// CommandHasSuffix applies the HasSuffix predicate on the "command" field.
func CommandHasSuffix(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldHasSuffix(FieldCommand, v))
// MacosHasSuffix applies the HasSuffix predicate on the "macos" field.
func MacosHasSuffix(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldHasSuffix(FieldMacos, v))
}
// CommandEqualFold applies the EqualFold predicate on the "command" field.
func CommandEqualFold(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEqualFold(FieldCommand, v))
// MacosIsNil applies the IsNil predicate on the "macos" field.
func MacosIsNil() predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldIsNull(FieldMacos))
}
// CommandContainsFold applies the ContainsFold predicate on the "command" field.
func CommandContainsFold(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldContainsFold(FieldCommand, v))
// MacosNotNil applies the NotNil predicate on the "macos" field.
func MacosNotNil() predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldNotNull(FieldMacos))
}
// MacosEqualFold applies the EqualFold predicate on the "macos" field.
func MacosEqualFold(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEqualFold(FieldMacos, v))
}
// MacosContainsFold applies the ContainsFold predicate on the "macos" field.
func MacosContainsFold(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldContainsFold(FieldMacos, v))
}
// WindowsEQ applies the EQ predicate on the "windows" field.
func WindowsEQ(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEQ(FieldWindows, v))
}
// WindowsNEQ applies the NEQ predicate on the "windows" field.
func WindowsNEQ(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldNEQ(FieldWindows, v))
}
// WindowsIn applies the In predicate on the "windows" field.
func WindowsIn(vs ...string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldIn(FieldWindows, vs...))
}
// WindowsNotIn applies the NotIn predicate on the "windows" field.
func WindowsNotIn(vs ...string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldNotIn(FieldWindows, vs...))
}
// WindowsGT applies the GT predicate on the "windows" field.
func WindowsGT(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldGT(FieldWindows, v))
}
// WindowsGTE applies the GTE predicate on the "windows" field.
func WindowsGTE(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldGTE(FieldWindows, v))
}
// WindowsLT applies the LT predicate on the "windows" field.
func WindowsLT(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldLT(FieldWindows, v))
}
// WindowsLTE applies the LTE predicate on the "windows" field.
func WindowsLTE(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldLTE(FieldWindows, v))
}
// WindowsContains applies the Contains predicate on the "windows" field.
func WindowsContains(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldContains(FieldWindows, v))
}
// WindowsHasPrefix applies the HasPrefix predicate on the "windows" field.
func WindowsHasPrefix(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldHasPrefix(FieldWindows, v))
}
// WindowsHasSuffix applies the HasSuffix predicate on the "windows" field.
func WindowsHasSuffix(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldHasSuffix(FieldWindows, v))
}
// WindowsIsNil applies the IsNil predicate on the "windows" field.
func WindowsIsNil() predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldIsNull(FieldWindows))
}
// WindowsNotNil applies the NotNil predicate on the "windows" field.
func WindowsNotNil() predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldNotNull(FieldWindows))
}
// WindowsEqualFold applies the EqualFold predicate on the "windows" field.
func WindowsEqualFold(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEqualFold(FieldWindows, v))
}
// WindowsContainsFold applies the ContainsFold predicate on the "windows" field.
func WindowsContainsFold(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldContainsFold(FieldWindows, v))
}
// LinuxEQ applies the EQ predicate on the "linux" field.
func LinuxEQ(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEQ(FieldLinux, v))
}
// LinuxNEQ applies the NEQ predicate on the "linux" field.
func LinuxNEQ(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldNEQ(FieldLinux, v))
}
// LinuxIn applies the In predicate on the "linux" field.
func LinuxIn(vs ...string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldIn(FieldLinux, vs...))
}
// LinuxNotIn applies the NotIn predicate on the "linux" field.
func LinuxNotIn(vs ...string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldNotIn(FieldLinux, vs...))
}
// LinuxGT applies the GT predicate on the "linux" field.
func LinuxGT(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldGT(FieldLinux, v))
}
// LinuxGTE applies the GTE predicate on the "linux" field.
func LinuxGTE(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldGTE(FieldLinux, v))
}
// LinuxLT applies the LT predicate on the "linux" field.
func LinuxLT(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldLT(FieldLinux, v))
}
// LinuxLTE applies the LTE predicate on the "linux" field.
func LinuxLTE(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldLTE(FieldLinux, v))
}
// LinuxContains applies the Contains predicate on the "linux" field.
func LinuxContains(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldContains(FieldLinux, v))
}
// LinuxHasPrefix applies the HasPrefix predicate on the "linux" field.
func LinuxHasPrefix(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldHasPrefix(FieldLinux, v))
}
// LinuxHasSuffix applies the HasSuffix predicate on the "linux" field.
func LinuxHasSuffix(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldHasSuffix(FieldLinux, v))
}
// LinuxIsNil applies the IsNil predicate on the "linux" field.
func LinuxIsNil() predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldIsNull(FieldLinux))
}
// LinuxNotNil applies the NotNil predicate on the "linux" field.
func LinuxNotNil() predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldNotNull(FieldLinux))
}
// LinuxEqualFold applies the EqualFold predicate on the "linux" field.
func LinuxEqualFold(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEqualFold(FieldLinux, v))
}
// LinuxContainsFold applies the ContainsFold predicate on the "linux" field.
func LinuxContainsFold(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldContainsFold(FieldLinux, v))
}
// ExtensionEQ applies the EQ predicate on the "extension" field.
@@ -558,16 +878,6 @@ func ExtensionHasSuffix(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldHasSuffix(FieldExtension, v))
}
// ExtensionIsNil applies the IsNil predicate on the "extension" field.
func ExtensionIsNil() predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldIsNull(FieldExtension))
}
// ExtensionNotNil applies the NotNil predicate on the "extension" field.
func ExtensionNotNil() predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldNotNull(FieldExtension))
}
// ExtensionEqualFold applies the EqualFold predicate on the "extension" field.
func ExtensionEqualFold(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEqualFold(FieldExtension, v))
@@ -588,6 +898,81 @@ func EnabledNEQ(v bool) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldNEQ(FieldEnabled, v))
}
// PreventDefaultEQ applies the EQ predicate on the "prevent_default" field.
func PreventDefaultEQ(v bool) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEQ(FieldPreventDefault, v))
}
// PreventDefaultNEQ applies the NEQ predicate on the "prevent_default" field.
func PreventDefaultNEQ(v bool) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldNEQ(FieldPreventDefault, v))
}
// ScopeEQ applies the EQ predicate on the "scope" field.
func ScopeEQ(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEQ(FieldScope, v))
}
// ScopeNEQ applies the NEQ predicate on the "scope" field.
func ScopeNEQ(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldNEQ(FieldScope, v))
}
// ScopeIn applies the In predicate on the "scope" field.
func ScopeIn(vs ...string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldIn(FieldScope, vs...))
}
// ScopeNotIn applies the NotIn predicate on the "scope" field.
func ScopeNotIn(vs ...string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldNotIn(FieldScope, vs...))
}
// ScopeGT applies the GT predicate on the "scope" field.
func ScopeGT(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldGT(FieldScope, v))
}
// ScopeGTE applies the GTE predicate on the "scope" field.
func ScopeGTE(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldGTE(FieldScope, v))
}
// ScopeLT applies the LT predicate on the "scope" field.
func ScopeLT(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldLT(FieldScope, v))
}
// ScopeLTE applies the LTE predicate on the "scope" field.
func ScopeLTE(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldLTE(FieldScope, v))
}
// ScopeContains applies the Contains predicate on the "scope" field.
func ScopeContains(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldContains(FieldScope, v))
}
// ScopeHasPrefix applies the HasPrefix predicate on the "scope" field.
func ScopeHasPrefix(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldHasPrefix(FieldScope, v))
}
// ScopeHasSuffix applies the HasSuffix predicate on the "scope" field.
func ScopeHasSuffix(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldHasSuffix(FieldScope, v))
}
// ScopeEqualFold applies the EqualFold predicate on the "scope" field.
func ScopeEqualFold(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldEqualFold(FieldScope, v))
}
// ScopeContainsFold applies the ContainsFold predicate on the "scope" field.
func ScopeContainsFold(v string) predicate.KeyBinding {
return predicate.KeyBinding(sql.FieldContainsFold(FieldScope, v))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.KeyBinding) predicate.KeyBinding {
return predicate.KeyBinding(sql.AndPredicates(predicates...))

View File

@@ -75,15 +75,79 @@ func (_c *KeyBindingCreate) SetNillableDeletedAt(v *string) *KeyBindingCreate {
return _c
}
// SetName sets the "name" field.
func (_c *KeyBindingCreate) SetName(v string) *KeyBindingCreate {
_c.mutation.SetName(v)
return _c
}
// SetType sets the "type" field.
func (_c *KeyBindingCreate) SetType(v string) *KeyBindingCreate {
_c.mutation.SetType(v)
return _c
}
// SetNillableType sets the "type" field if the given value is not nil.
func (_c *KeyBindingCreate) SetNillableType(v *string) *KeyBindingCreate {
if v != nil {
_c.SetType(*v)
}
return _c
}
// SetKey sets the "key" field.
func (_c *KeyBindingCreate) SetKey(v string) *KeyBindingCreate {
_c.mutation.SetKey(v)
return _c
}
// SetCommand sets the "command" field.
func (_c *KeyBindingCreate) SetCommand(v string) *KeyBindingCreate {
_c.mutation.SetCommand(v)
// SetNillableKey sets the "key" field if the given value is not nil.
func (_c *KeyBindingCreate) SetNillableKey(v *string) *KeyBindingCreate {
if v != nil {
_c.SetKey(*v)
}
return _c
}
// SetMacos sets the "macos" field.
func (_c *KeyBindingCreate) SetMacos(v string) *KeyBindingCreate {
_c.mutation.SetMacos(v)
return _c
}
// SetNillableMacos sets the "macos" field if the given value is not nil.
func (_c *KeyBindingCreate) SetNillableMacos(v *string) *KeyBindingCreate {
if v != nil {
_c.SetMacos(*v)
}
return _c
}
// SetWindows sets the "windows" field.
func (_c *KeyBindingCreate) SetWindows(v string) *KeyBindingCreate {
_c.mutation.SetWindows(v)
return _c
}
// SetNillableWindows sets the "windows" field if the given value is not nil.
func (_c *KeyBindingCreate) SetNillableWindows(v *string) *KeyBindingCreate {
if v != nil {
_c.SetWindows(*v)
}
return _c
}
// SetLinux sets the "linux" field.
func (_c *KeyBindingCreate) SetLinux(v string) *KeyBindingCreate {
_c.mutation.SetLinux(v)
return _c
}
// SetNillableLinux sets the "linux" field if the given value is not nil.
func (_c *KeyBindingCreate) SetNillableLinux(v *string) *KeyBindingCreate {
if v != nil {
_c.SetLinux(*v)
}
return _c
}
@@ -93,14 +157,6 @@ func (_c *KeyBindingCreate) SetExtension(v string) *KeyBindingCreate {
return _c
}
// SetNillableExtension sets the "extension" field if the given value is not nil.
func (_c *KeyBindingCreate) SetNillableExtension(v *string) *KeyBindingCreate {
if v != nil {
_c.SetExtension(*v)
}
return _c
}
// SetEnabled sets the "enabled" field.
func (_c *KeyBindingCreate) SetEnabled(v bool) *KeyBindingCreate {
_c.mutation.SetEnabled(v)
@@ -115,6 +171,34 @@ func (_c *KeyBindingCreate) SetNillableEnabled(v *bool) *KeyBindingCreate {
return _c
}
// SetPreventDefault sets the "prevent_default" field.
func (_c *KeyBindingCreate) SetPreventDefault(v bool) *KeyBindingCreate {
_c.mutation.SetPreventDefault(v)
return _c
}
// SetNillablePreventDefault sets the "prevent_default" field if the given value is not nil.
func (_c *KeyBindingCreate) SetNillablePreventDefault(v *bool) *KeyBindingCreate {
if v != nil {
_c.SetPreventDefault(*v)
}
return _c
}
// SetScope sets the "scope" field.
func (_c *KeyBindingCreate) SetScope(v string) *KeyBindingCreate {
_c.mutation.SetScope(v)
return _c
}
// SetNillableScope sets the "scope" field if the given value is not nil.
func (_c *KeyBindingCreate) SetNillableScope(v *string) *KeyBindingCreate {
if v != nil {
_c.SetScope(*v)
}
return _c
}
// Mutation returns the KeyBindingMutation object of the builder.
func (_c *KeyBindingCreate) Mutation() *KeyBindingMutation {
return _c.mutation
@@ -173,37 +257,75 @@ func (_c *KeyBindingCreate) defaults() error {
v := keybinding.DefaultUpdatedAt()
_c.mutation.SetUpdatedAt(v)
}
if _, ok := _c.mutation.GetType(); !ok {
v := keybinding.DefaultType
_c.mutation.SetType(v)
}
if _, ok := _c.mutation.Enabled(); !ok {
v := keybinding.DefaultEnabled
_c.mutation.SetEnabled(v)
}
if _, ok := _c.mutation.PreventDefault(); !ok {
v := keybinding.DefaultPreventDefault
_c.mutation.SetPreventDefault(v)
}
if _, ok := _c.mutation.Scope(); !ok {
v := keybinding.DefaultScope
_c.mutation.SetScope(v)
}
return nil
}
// check runs all checks and user-defined validators on the builder.
func (_c *KeyBindingCreate) check() error {
if _, ok := _c.mutation.UUID(); !ok {
return &ValidationError{Name: "uuid", err: errors.New(`ent: missing required field "KeyBinding.uuid"`)}
}
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "KeyBinding.created_at"`)}
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "KeyBinding.updated_at"`)}
}
if _, ok := _c.mutation.Key(); !ok {
return &ValidationError{Name: "key", err: errors.New(`ent: missing required field "KeyBinding.key"`)}
if _, ok := _c.mutation.Name(); !ok {
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "KeyBinding.name"`)}
}
if v, ok := _c.mutation.Name(); ok {
if err := keybinding.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.name": %w`, err)}
}
}
if _, ok := _c.mutation.GetType(); !ok {
return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "KeyBinding.type"`)}
}
if v, ok := _c.mutation.GetType(); ok {
if err := keybinding.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.type": %w`, err)}
}
}
if v, ok := _c.mutation.Key(); ok {
if err := keybinding.KeyValidator(v); err != nil {
return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.key": %w`, err)}
}
}
if _, ok := _c.mutation.Command(); !ok {
return &ValidationError{Name: "command", err: errors.New(`ent: missing required field "KeyBinding.command"`)}
}
if v, ok := _c.mutation.Command(); ok {
if err := keybinding.CommandValidator(v); err != nil {
return &ValidationError{Name: "command", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.command": %w`, err)}
if v, ok := _c.mutation.Macos(); ok {
if err := keybinding.MacosValidator(v); err != nil {
return &ValidationError{Name: "macos", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.macos": %w`, err)}
}
}
if v, ok := _c.mutation.Windows(); ok {
if err := keybinding.WindowsValidator(v); err != nil {
return &ValidationError{Name: "windows", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.windows": %w`, err)}
}
}
if v, ok := _c.mutation.Linux(); ok {
if err := keybinding.LinuxValidator(v); err != nil {
return &ValidationError{Name: "linux", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.linux": %w`, err)}
}
}
if _, ok := _c.mutation.Extension(); !ok {
return &ValidationError{Name: "extension", err: errors.New(`ent: missing required field "KeyBinding.extension"`)}
}
if v, ok := _c.mutation.Extension(); ok {
if err := keybinding.ExtensionValidator(v); err != nil {
return &ValidationError{Name: "extension", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.extension": %w`, err)}
@@ -212,6 +334,17 @@ func (_c *KeyBindingCreate) check() error {
if _, ok := _c.mutation.Enabled(); !ok {
return &ValidationError{Name: "enabled", err: errors.New(`ent: missing required field "KeyBinding.enabled"`)}
}
if _, ok := _c.mutation.PreventDefault(); !ok {
return &ValidationError{Name: "prevent_default", err: errors.New(`ent: missing required field "KeyBinding.prevent_default"`)}
}
if _, ok := _c.mutation.Scope(); !ok {
return &ValidationError{Name: "scope", err: errors.New(`ent: missing required field "KeyBinding.scope"`)}
}
if v, ok := _c.mutation.Scope(); ok {
if err := keybinding.ScopeValidator(v); err != nil {
return &ValidationError{Name: "scope", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.scope": %w`, err)}
}
}
return nil
}
@@ -240,7 +373,7 @@ func (_c *KeyBindingCreate) createSpec() (*KeyBinding, *sqlgraph.CreateSpec) {
)
if value, ok := _c.mutation.UUID(); ok {
_spec.SetField(keybinding.FieldUUID, field.TypeString, value)
_node.UUID = &value
_node.UUID = value
}
if value, ok := _c.mutation.CreatedAt(); ok {
_spec.SetField(keybinding.FieldCreatedAt, field.TypeString, value)
@@ -254,13 +387,29 @@ func (_c *KeyBindingCreate) createSpec() (*KeyBinding, *sqlgraph.CreateSpec) {
_spec.SetField(keybinding.FieldDeletedAt, field.TypeString, value)
_node.DeletedAt = &value
}
if value, ok := _c.mutation.Name(); ok {
_spec.SetField(keybinding.FieldName, field.TypeString, value)
_node.Name = value
}
if value, ok := _c.mutation.GetType(); ok {
_spec.SetField(keybinding.FieldType, field.TypeString, value)
_node.Type = value
}
if value, ok := _c.mutation.Key(); ok {
_spec.SetField(keybinding.FieldKey, field.TypeString, value)
_node.Key = value
}
if value, ok := _c.mutation.Command(); ok {
_spec.SetField(keybinding.FieldCommand, field.TypeString, value)
_node.Command = value
if value, ok := _c.mutation.Macos(); ok {
_spec.SetField(keybinding.FieldMacos, field.TypeString, value)
_node.Macos = value
}
if value, ok := _c.mutation.Windows(); ok {
_spec.SetField(keybinding.FieldWindows, field.TypeString, value)
_node.Windows = value
}
if value, ok := _c.mutation.Linux(); ok {
_spec.SetField(keybinding.FieldLinux, field.TypeString, value)
_node.Linux = value
}
if value, ok := _c.mutation.Extension(); ok {
_spec.SetField(keybinding.FieldExtension, field.TypeString, value)
@@ -270,6 +419,14 @@ func (_c *KeyBindingCreate) createSpec() (*KeyBinding, *sqlgraph.CreateSpec) {
_spec.SetField(keybinding.FieldEnabled, field.TypeBool, value)
_node.Enabled = value
}
if value, ok := _c.mutation.PreventDefault(); ok {
_spec.SetField(keybinding.FieldPreventDefault, field.TypeBool, value)
_node.PreventDefault = value
}
if value, ok := _c.mutation.Scope(); ok {
_spec.SetField(keybinding.FieldScope, field.TypeString, value)
_node.Scope = value
}
return _node, _spec
}

View File

@@ -62,6 +62,34 @@ func (_u *KeyBindingUpdate) ClearDeletedAt() *KeyBindingUpdate {
return _u
}
// SetName sets the "name" field.
func (_u *KeyBindingUpdate) SetName(v string) *KeyBindingUpdate {
_u.mutation.SetName(v)
return _u
}
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *KeyBindingUpdate) SetNillableName(v *string) *KeyBindingUpdate {
if v != nil {
_u.SetName(*v)
}
return _u
}
// SetType sets the "type" field.
func (_u *KeyBindingUpdate) SetType(v string) *KeyBindingUpdate {
_u.mutation.SetType(v)
return _u
}
// SetNillableType sets the "type" field if the given value is not nil.
func (_u *KeyBindingUpdate) SetNillableType(v *string) *KeyBindingUpdate {
if v != nil {
_u.SetType(*v)
}
return _u
}
// SetKey sets the "key" field.
func (_u *KeyBindingUpdate) SetKey(v string) *KeyBindingUpdate {
_u.mutation.SetKey(v)
@@ -76,20 +104,72 @@ func (_u *KeyBindingUpdate) SetNillableKey(v *string) *KeyBindingUpdate {
return _u
}
// SetCommand sets the "command" field.
func (_u *KeyBindingUpdate) SetCommand(v string) *KeyBindingUpdate {
_u.mutation.SetCommand(v)
// ClearKey clears the value of the "key" field.
func (_u *KeyBindingUpdate) ClearKey() *KeyBindingUpdate {
_u.mutation.ClearKey()
return _u
}
// SetNillableCommand sets the "command" field if the given value is not nil.
func (_u *KeyBindingUpdate) SetNillableCommand(v *string) *KeyBindingUpdate {
// SetMacos sets the "macos" field.
func (_u *KeyBindingUpdate) SetMacos(v string) *KeyBindingUpdate {
_u.mutation.SetMacos(v)
return _u
}
// SetNillableMacos sets the "macos" field if the given value is not nil.
func (_u *KeyBindingUpdate) SetNillableMacos(v *string) *KeyBindingUpdate {
if v != nil {
_u.SetCommand(*v)
_u.SetMacos(*v)
}
return _u
}
// ClearMacos clears the value of the "macos" field.
func (_u *KeyBindingUpdate) ClearMacos() *KeyBindingUpdate {
_u.mutation.ClearMacos()
return _u
}
// SetWindows sets the "windows" field.
func (_u *KeyBindingUpdate) SetWindows(v string) *KeyBindingUpdate {
_u.mutation.SetWindows(v)
return _u
}
// SetNillableWindows sets the "windows" field if the given value is not nil.
func (_u *KeyBindingUpdate) SetNillableWindows(v *string) *KeyBindingUpdate {
if v != nil {
_u.SetWindows(*v)
}
return _u
}
// ClearWindows clears the value of the "windows" field.
func (_u *KeyBindingUpdate) ClearWindows() *KeyBindingUpdate {
_u.mutation.ClearWindows()
return _u
}
// SetLinux sets the "linux" field.
func (_u *KeyBindingUpdate) SetLinux(v string) *KeyBindingUpdate {
_u.mutation.SetLinux(v)
return _u
}
// SetNillableLinux sets the "linux" field if the given value is not nil.
func (_u *KeyBindingUpdate) SetNillableLinux(v *string) *KeyBindingUpdate {
if v != nil {
_u.SetLinux(*v)
}
return _u
}
// ClearLinux clears the value of the "linux" field.
func (_u *KeyBindingUpdate) ClearLinux() *KeyBindingUpdate {
_u.mutation.ClearLinux()
return _u
}
// SetExtension sets the "extension" field.
func (_u *KeyBindingUpdate) SetExtension(v string) *KeyBindingUpdate {
_u.mutation.SetExtension(v)
@@ -104,12 +184,6 @@ func (_u *KeyBindingUpdate) SetNillableExtension(v *string) *KeyBindingUpdate {
return _u
}
// ClearExtension clears the value of the "extension" field.
func (_u *KeyBindingUpdate) ClearExtension() *KeyBindingUpdate {
_u.mutation.ClearExtension()
return _u
}
// SetEnabled sets the "enabled" field.
func (_u *KeyBindingUpdate) SetEnabled(v bool) *KeyBindingUpdate {
_u.mutation.SetEnabled(v)
@@ -124,6 +198,34 @@ func (_u *KeyBindingUpdate) SetNillableEnabled(v *bool) *KeyBindingUpdate {
return _u
}
// SetPreventDefault sets the "prevent_default" field.
func (_u *KeyBindingUpdate) SetPreventDefault(v bool) *KeyBindingUpdate {
_u.mutation.SetPreventDefault(v)
return _u
}
// SetNillablePreventDefault sets the "prevent_default" field if the given value is not nil.
func (_u *KeyBindingUpdate) SetNillablePreventDefault(v *bool) *KeyBindingUpdate {
if v != nil {
_u.SetPreventDefault(*v)
}
return _u
}
// SetScope sets the "scope" field.
func (_u *KeyBindingUpdate) SetScope(v string) *KeyBindingUpdate {
_u.mutation.SetScope(v)
return _u
}
// SetNillableScope sets the "scope" field if the given value is not nil.
func (_u *KeyBindingUpdate) SetNillableScope(v *string) *KeyBindingUpdate {
if v != nil {
_u.SetScope(*v)
}
return _u
}
// Mutation returns the KeyBindingMutation object of the builder.
func (_u *KeyBindingUpdate) Mutation() *KeyBindingMutation {
return _u.mutation
@@ -158,14 +260,34 @@ func (_u *KeyBindingUpdate) ExecX(ctx context.Context) {
// check runs all checks and user-defined validators on the builder.
func (_u *KeyBindingUpdate) check() error {
if v, ok := _u.mutation.Name(); ok {
if err := keybinding.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.name": %w`, err)}
}
}
if v, ok := _u.mutation.GetType(); ok {
if err := keybinding.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.type": %w`, err)}
}
}
if v, ok := _u.mutation.Key(); ok {
if err := keybinding.KeyValidator(v); err != nil {
return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.key": %w`, err)}
}
}
if v, ok := _u.mutation.Command(); ok {
if err := keybinding.CommandValidator(v); err != nil {
return &ValidationError{Name: "command", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.command": %w`, err)}
if v, ok := _u.mutation.Macos(); ok {
if err := keybinding.MacosValidator(v); err != nil {
return &ValidationError{Name: "macos", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.macos": %w`, err)}
}
}
if v, ok := _u.mutation.Windows(); ok {
if err := keybinding.WindowsValidator(v); err != nil {
return &ValidationError{Name: "windows", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.windows": %w`, err)}
}
}
if v, ok := _u.mutation.Linux(); ok {
if err := keybinding.LinuxValidator(v); err != nil {
return &ValidationError{Name: "linux", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.linux": %w`, err)}
}
}
if v, ok := _u.mutation.Extension(); ok {
@@ -173,6 +295,11 @@ func (_u *KeyBindingUpdate) check() error {
return &ValidationError{Name: "extension", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.extension": %w`, err)}
}
}
if v, ok := _u.mutation.Scope(); ok {
if err := keybinding.ScopeValidator(v); err != nil {
return &ValidationError{Name: "scope", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.scope": %w`, err)}
}
}
return nil
}
@@ -194,9 +321,6 @@ func (_u *KeyBindingUpdate) sqlSave(ctx context.Context) (_node int, err error)
}
}
}
if _u.mutation.UUIDCleared() {
_spec.ClearField(keybinding.FieldUUID, field.TypeString)
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(keybinding.FieldUpdatedAt, field.TypeString, value)
}
@@ -206,21 +330,48 @@ func (_u *KeyBindingUpdate) sqlSave(ctx context.Context) (_node int, err error)
if _u.mutation.DeletedAtCleared() {
_spec.ClearField(keybinding.FieldDeletedAt, field.TypeString)
}
if value, ok := _u.mutation.Name(); ok {
_spec.SetField(keybinding.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.GetType(); ok {
_spec.SetField(keybinding.FieldType, field.TypeString, value)
}
if value, ok := _u.mutation.Key(); ok {
_spec.SetField(keybinding.FieldKey, field.TypeString, value)
}
if value, ok := _u.mutation.Command(); ok {
_spec.SetField(keybinding.FieldCommand, field.TypeString, value)
if _u.mutation.KeyCleared() {
_spec.ClearField(keybinding.FieldKey, field.TypeString)
}
if value, ok := _u.mutation.Macos(); ok {
_spec.SetField(keybinding.FieldMacos, field.TypeString, value)
}
if _u.mutation.MacosCleared() {
_spec.ClearField(keybinding.FieldMacos, field.TypeString)
}
if value, ok := _u.mutation.Windows(); ok {
_spec.SetField(keybinding.FieldWindows, field.TypeString, value)
}
if _u.mutation.WindowsCleared() {
_spec.ClearField(keybinding.FieldWindows, field.TypeString)
}
if value, ok := _u.mutation.Linux(); ok {
_spec.SetField(keybinding.FieldLinux, field.TypeString, value)
}
if _u.mutation.LinuxCleared() {
_spec.ClearField(keybinding.FieldLinux, field.TypeString)
}
if value, ok := _u.mutation.Extension(); ok {
_spec.SetField(keybinding.FieldExtension, field.TypeString, value)
}
if _u.mutation.ExtensionCleared() {
_spec.ClearField(keybinding.FieldExtension, field.TypeString)
}
if value, ok := _u.mutation.Enabled(); ok {
_spec.SetField(keybinding.FieldEnabled, field.TypeBool, value)
}
if value, ok := _u.mutation.PreventDefault(); ok {
_spec.SetField(keybinding.FieldPreventDefault, field.TypeBool, value)
}
if value, ok := _u.mutation.Scope(); ok {
_spec.SetField(keybinding.FieldScope, field.TypeString, value)
}
_spec.AddModifiers(_u.modifiers...)
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
@@ -277,6 +428,34 @@ func (_u *KeyBindingUpdateOne) ClearDeletedAt() *KeyBindingUpdateOne {
return _u
}
// SetName sets the "name" field.
func (_u *KeyBindingUpdateOne) SetName(v string) *KeyBindingUpdateOne {
_u.mutation.SetName(v)
return _u
}
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *KeyBindingUpdateOne) SetNillableName(v *string) *KeyBindingUpdateOne {
if v != nil {
_u.SetName(*v)
}
return _u
}
// SetType sets the "type" field.
func (_u *KeyBindingUpdateOne) SetType(v string) *KeyBindingUpdateOne {
_u.mutation.SetType(v)
return _u
}
// SetNillableType sets the "type" field if the given value is not nil.
func (_u *KeyBindingUpdateOne) SetNillableType(v *string) *KeyBindingUpdateOne {
if v != nil {
_u.SetType(*v)
}
return _u
}
// SetKey sets the "key" field.
func (_u *KeyBindingUpdateOne) SetKey(v string) *KeyBindingUpdateOne {
_u.mutation.SetKey(v)
@@ -291,20 +470,72 @@ func (_u *KeyBindingUpdateOne) SetNillableKey(v *string) *KeyBindingUpdateOne {
return _u
}
// SetCommand sets the "command" field.
func (_u *KeyBindingUpdateOne) SetCommand(v string) *KeyBindingUpdateOne {
_u.mutation.SetCommand(v)
// ClearKey clears the value of the "key" field.
func (_u *KeyBindingUpdateOne) ClearKey() *KeyBindingUpdateOne {
_u.mutation.ClearKey()
return _u
}
// SetNillableCommand sets the "command" field if the given value is not nil.
func (_u *KeyBindingUpdateOne) SetNillableCommand(v *string) *KeyBindingUpdateOne {
// SetMacos sets the "macos" field.
func (_u *KeyBindingUpdateOne) SetMacos(v string) *KeyBindingUpdateOne {
_u.mutation.SetMacos(v)
return _u
}
// SetNillableMacos sets the "macos" field if the given value is not nil.
func (_u *KeyBindingUpdateOne) SetNillableMacos(v *string) *KeyBindingUpdateOne {
if v != nil {
_u.SetCommand(*v)
_u.SetMacos(*v)
}
return _u
}
// ClearMacos clears the value of the "macos" field.
func (_u *KeyBindingUpdateOne) ClearMacos() *KeyBindingUpdateOne {
_u.mutation.ClearMacos()
return _u
}
// SetWindows sets the "windows" field.
func (_u *KeyBindingUpdateOne) SetWindows(v string) *KeyBindingUpdateOne {
_u.mutation.SetWindows(v)
return _u
}
// SetNillableWindows sets the "windows" field if the given value is not nil.
func (_u *KeyBindingUpdateOne) SetNillableWindows(v *string) *KeyBindingUpdateOne {
if v != nil {
_u.SetWindows(*v)
}
return _u
}
// ClearWindows clears the value of the "windows" field.
func (_u *KeyBindingUpdateOne) ClearWindows() *KeyBindingUpdateOne {
_u.mutation.ClearWindows()
return _u
}
// SetLinux sets the "linux" field.
func (_u *KeyBindingUpdateOne) SetLinux(v string) *KeyBindingUpdateOne {
_u.mutation.SetLinux(v)
return _u
}
// SetNillableLinux sets the "linux" field if the given value is not nil.
func (_u *KeyBindingUpdateOne) SetNillableLinux(v *string) *KeyBindingUpdateOne {
if v != nil {
_u.SetLinux(*v)
}
return _u
}
// ClearLinux clears the value of the "linux" field.
func (_u *KeyBindingUpdateOne) ClearLinux() *KeyBindingUpdateOne {
_u.mutation.ClearLinux()
return _u
}
// SetExtension sets the "extension" field.
func (_u *KeyBindingUpdateOne) SetExtension(v string) *KeyBindingUpdateOne {
_u.mutation.SetExtension(v)
@@ -319,12 +550,6 @@ func (_u *KeyBindingUpdateOne) SetNillableExtension(v *string) *KeyBindingUpdate
return _u
}
// ClearExtension clears the value of the "extension" field.
func (_u *KeyBindingUpdateOne) ClearExtension() *KeyBindingUpdateOne {
_u.mutation.ClearExtension()
return _u
}
// SetEnabled sets the "enabled" field.
func (_u *KeyBindingUpdateOne) SetEnabled(v bool) *KeyBindingUpdateOne {
_u.mutation.SetEnabled(v)
@@ -339,6 +564,34 @@ func (_u *KeyBindingUpdateOne) SetNillableEnabled(v *bool) *KeyBindingUpdateOne
return _u
}
// SetPreventDefault sets the "prevent_default" field.
func (_u *KeyBindingUpdateOne) SetPreventDefault(v bool) *KeyBindingUpdateOne {
_u.mutation.SetPreventDefault(v)
return _u
}
// SetNillablePreventDefault sets the "prevent_default" field if the given value is not nil.
func (_u *KeyBindingUpdateOne) SetNillablePreventDefault(v *bool) *KeyBindingUpdateOne {
if v != nil {
_u.SetPreventDefault(*v)
}
return _u
}
// SetScope sets the "scope" field.
func (_u *KeyBindingUpdateOne) SetScope(v string) *KeyBindingUpdateOne {
_u.mutation.SetScope(v)
return _u
}
// SetNillableScope sets the "scope" field if the given value is not nil.
func (_u *KeyBindingUpdateOne) SetNillableScope(v *string) *KeyBindingUpdateOne {
if v != nil {
_u.SetScope(*v)
}
return _u
}
// Mutation returns the KeyBindingMutation object of the builder.
func (_u *KeyBindingUpdateOne) Mutation() *KeyBindingMutation {
return _u.mutation
@@ -386,14 +639,34 @@ func (_u *KeyBindingUpdateOne) ExecX(ctx context.Context) {
// check runs all checks and user-defined validators on the builder.
func (_u *KeyBindingUpdateOne) check() error {
if v, ok := _u.mutation.Name(); ok {
if err := keybinding.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.name": %w`, err)}
}
}
if v, ok := _u.mutation.GetType(); ok {
if err := keybinding.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.type": %w`, err)}
}
}
if v, ok := _u.mutation.Key(); ok {
if err := keybinding.KeyValidator(v); err != nil {
return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.key": %w`, err)}
}
}
if v, ok := _u.mutation.Command(); ok {
if err := keybinding.CommandValidator(v); err != nil {
return &ValidationError{Name: "command", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.command": %w`, err)}
if v, ok := _u.mutation.Macos(); ok {
if err := keybinding.MacosValidator(v); err != nil {
return &ValidationError{Name: "macos", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.macos": %w`, err)}
}
}
if v, ok := _u.mutation.Windows(); ok {
if err := keybinding.WindowsValidator(v); err != nil {
return &ValidationError{Name: "windows", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.windows": %w`, err)}
}
}
if v, ok := _u.mutation.Linux(); ok {
if err := keybinding.LinuxValidator(v); err != nil {
return &ValidationError{Name: "linux", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.linux": %w`, err)}
}
}
if v, ok := _u.mutation.Extension(); ok {
@@ -401,6 +674,11 @@ func (_u *KeyBindingUpdateOne) check() error {
return &ValidationError{Name: "extension", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.extension": %w`, err)}
}
}
if v, ok := _u.mutation.Scope(); ok {
if err := keybinding.ScopeValidator(v); err != nil {
return &ValidationError{Name: "scope", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.scope": %w`, err)}
}
}
return nil
}
@@ -439,9 +717,6 @@ func (_u *KeyBindingUpdateOne) sqlSave(ctx context.Context) (_node *KeyBinding,
}
}
}
if _u.mutation.UUIDCleared() {
_spec.ClearField(keybinding.FieldUUID, field.TypeString)
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(keybinding.FieldUpdatedAt, field.TypeString, value)
}
@@ -451,21 +726,48 @@ func (_u *KeyBindingUpdateOne) sqlSave(ctx context.Context) (_node *KeyBinding,
if _u.mutation.DeletedAtCleared() {
_spec.ClearField(keybinding.FieldDeletedAt, field.TypeString)
}
if value, ok := _u.mutation.Name(); ok {
_spec.SetField(keybinding.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.GetType(); ok {
_spec.SetField(keybinding.FieldType, field.TypeString, value)
}
if value, ok := _u.mutation.Key(); ok {
_spec.SetField(keybinding.FieldKey, field.TypeString, value)
}
if value, ok := _u.mutation.Command(); ok {
_spec.SetField(keybinding.FieldCommand, field.TypeString, value)
if _u.mutation.KeyCleared() {
_spec.ClearField(keybinding.FieldKey, field.TypeString)
}
if value, ok := _u.mutation.Macos(); ok {
_spec.SetField(keybinding.FieldMacos, field.TypeString, value)
}
if _u.mutation.MacosCleared() {
_spec.ClearField(keybinding.FieldMacos, field.TypeString)
}
if value, ok := _u.mutation.Windows(); ok {
_spec.SetField(keybinding.FieldWindows, field.TypeString, value)
}
if _u.mutation.WindowsCleared() {
_spec.ClearField(keybinding.FieldWindows, field.TypeString)
}
if value, ok := _u.mutation.Linux(); ok {
_spec.SetField(keybinding.FieldLinux, field.TypeString, value)
}
if _u.mutation.LinuxCleared() {
_spec.ClearField(keybinding.FieldLinux, field.TypeString)
}
if value, ok := _u.mutation.Extension(); ok {
_spec.SetField(keybinding.FieldExtension, field.TypeString, value)
}
if _u.mutation.ExtensionCleared() {
_spec.ClearField(keybinding.FieldExtension, field.TypeString)
}
if value, ok := _u.mutation.Enabled(); ok {
_spec.SetField(keybinding.FieldEnabled, field.TypeBool, value)
}
if value, ok := _u.mutation.PreventDefault(); ok {
_spec.SetField(keybinding.FieldPreventDefault, field.TypeBool, value)
}
if value, ok := _u.mutation.Scope(); ok {
_spec.SetField(keybinding.FieldScope, field.TypeString, value)
}
_spec.AddModifiers(_u.modifiers...)
_node = &KeyBinding{config: _u.config}
_spec.Assign = _node.assignValues

View File

@@ -12,7 +12,7 @@ var (
// DocumentsColumns holds the columns for the "documents" table.
DocumentsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "uuid", Type: field.TypeString, Unique: true, Nullable: true},
{Name: "uuid", Type: field.TypeString, Unique: true},
{Name: "created_at", Type: field.TypeString},
{Name: "updated_at", Type: field.TypeString},
{Name: "deleted_at", Type: field.TypeString, Nullable: true},
@@ -56,11 +56,11 @@ var (
// ExtensionsColumns holds the columns for the "extensions" table.
ExtensionsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "uuid", Type: field.TypeString, Unique: true, Nullable: true},
{Name: "uuid", Type: field.TypeString, Unique: true},
{Name: "created_at", Type: field.TypeString},
{Name: "updated_at", Type: field.TypeString},
{Name: "deleted_at", Type: field.TypeString, Nullable: true},
{Name: "key", Type: field.TypeString, Unique: true, Size: 100},
{Name: "name", Type: field.TypeString, Unique: true, Size: 100},
{Name: "enabled", Type: field.TypeBool, Default: true},
{Name: "config", Type: field.TypeJSON, Nullable: true},
}
@@ -90,14 +90,20 @@ var (
// KeyBindingsColumns holds the columns for the "key_bindings" table.
KeyBindingsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "uuid", Type: field.TypeString, Unique: true, Nullable: true},
{Name: "uuid", Type: field.TypeString, Unique: true},
{Name: "created_at", Type: field.TypeString},
{Name: "updated_at", Type: field.TypeString},
{Name: "deleted_at", Type: field.TypeString, Nullable: true},
{Name: "key", Type: field.TypeString, Unique: true, Size: 100},
{Name: "command", Type: field.TypeString, Size: 100},
{Name: "extension", Type: field.TypeString, Nullable: true, Size: 100},
{Name: "name", Type: field.TypeString, Size: 100},
{Name: "type", Type: field.TypeString, Size: 20, Default: "standard"},
{Name: "key", Type: field.TypeString, Nullable: true, Size: 100},
{Name: "macos", Type: field.TypeString, Nullable: true, Size: 100},
{Name: "windows", Type: field.TypeString, Nullable: true, Size: 100},
{Name: "linux", Type: field.TypeString, Nullable: true, Size: 100},
{Name: "extension", Type: field.TypeString, Size: 100},
{Name: "enabled", Type: field.TypeBool, Default: true},
{Name: "prevent_default", Type: field.TypeBool, Default: true},
{Name: "scope", Type: field.TypeString, Size: 100, Default: "editor"},
}
// KeyBindingsTable holds the schema information for the "key_bindings" table.
KeyBindingsTable = &schema.Table{
@@ -115,26 +121,41 @@ var (
Unique: false,
Columns: []*schema.Column{KeyBindingsColumns[4]},
},
{
Name: "keybinding_name",
Unique: false,
Columns: []*schema.Column{KeyBindingsColumns[5]},
},
{
Name: "keybinding_type",
Unique: false,
Columns: []*schema.Column{KeyBindingsColumns[6]},
},
{
Name: "keybinding_type_name",
Unique: true,
Columns: []*schema.Column{KeyBindingsColumns[6], KeyBindingsColumns[5]},
},
{
Name: "keybinding_extension",
Unique: false,
Columns: []*schema.Column{KeyBindingsColumns[7]},
Columns: []*schema.Column{KeyBindingsColumns[11]},
},
{
Name: "keybinding_enabled",
Unique: false,
Columns: []*schema.Column{KeyBindingsColumns[8]},
Columns: []*schema.Column{KeyBindingsColumns[12]},
},
},
}
// ThemesColumns holds the columns for the "themes" table.
ThemesColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "uuid", Type: field.TypeString, Unique: true, Nullable: true},
{Name: "uuid", Type: field.TypeString, Unique: true},
{Name: "created_at", Type: field.TypeString},
{Name: "updated_at", Type: field.TypeString},
{Name: "deleted_at", Type: field.TypeString, Nullable: true},
{Name: "key", Type: field.TypeString, Unique: true, Size: 100},
{Name: "name", Type: field.TypeString, Unique: true, Size: 100},
{Name: "type", Type: field.TypeEnum, Enums: []string{"dark", "light"}},
{Name: "colors", Type: field.TypeJSON, Nullable: true},
}

File diff suppressed because it is too large Load Diff

View File

@@ -90,18 +90,18 @@ func init() {
extensionDescUpdatedAt := extensionMixinFields1[1].Descriptor()
// extension.DefaultUpdatedAt holds the default value on creation for the updated_at field.
extension.DefaultUpdatedAt = extensionDescUpdatedAt.Default.(func() string)
// extensionDescKey is the schema descriptor for key field.
extensionDescKey := extensionFields[0].Descriptor()
// extension.KeyValidator is a validator for the "key" field. It is called by the builders before save.
extension.KeyValidator = func() func(string) error {
validators := extensionDescKey.Validators
// extensionDescName is the schema descriptor for name field.
extensionDescName := extensionFields[0].Descriptor()
// extension.NameValidator is a validator for the "name" field. It is called by the builders before save.
extension.NameValidator = func() func(string) error {
validators := extensionDescName.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(key string) error {
return func(name string) error {
for _, fn := range fns {
if err := fn(key); err != nil {
if err := fn(name); err != nil {
return err
}
}
@@ -137,50 +137,78 @@ func init() {
keybindingDescUpdatedAt := keybindingMixinFields1[1].Descriptor()
// keybinding.DefaultUpdatedAt holds the default value on creation for the updated_at field.
keybinding.DefaultUpdatedAt = keybindingDescUpdatedAt.Default.(func() string)
// keybindingDescName is the schema descriptor for name field.
keybindingDescName := keybindingFields[0].Descriptor()
// keybinding.NameValidator is a validator for the "name" field. It is called by the builders before save.
keybinding.NameValidator = func() func(string) error {
validators := keybindingDescName.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(name string) error {
for _, fn := range fns {
if err := fn(name); err != nil {
return err
}
}
return nil
}
}()
// keybindingDescType is the schema descriptor for type field.
keybindingDescType := keybindingFields[1].Descriptor()
// keybinding.DefaultType holds the default value on creation for the type field.
keybinding.DefaultType = keybindingDescType.Default.(string)
// keybinding.TypeValidator is a validator for the "type" field. It is called by the builders before save.
keybinding.TypeValidator = keybindingDescType.Validators[0].(func(string) error)
// keybindingDescKey is the schema descriptor for key field.
keybindingDescKey := keybindingFields[0].Descriptor()
keybindingDescKey := keybindingFields[2].Descriptor()
// keybinding.KeyValidator is a validator for the "key" field. It is called by the builders before save.
keybinding.KeyValidator = func() func(string) error {
validators := keybindingDescKey.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(key string) error {
for _, fn := range fns {
if err := fn(key); err != nil {
return err
}
}
return nil
}
}()
// keybindingDescCommand is the schema descriptor for command field.
keybindingDescCommand := keybindingFields[1].Descriptor()
// keybinding.CommandValidator is a validator for the "command" field. It is called by the builders before save.
keybinding.CommandValidator = func() func(string) error {
validators := keybindingDescCommand.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(command string) error {
for _, fn := range fns {
if err := fn(command); err != nil {
return err
}
}
return nil
}
}()
keybinding.KeyValidator = keybindingDescKey.Validators[0].(func(string) error)
// keybindingDescMacos is the schema descriptor for macos field.
keybindingDescMacos := keybindingFields[3].Descriptor()
// keybinding.MacosValidator is a validator for the "macos" field. It is called by the builders before save.
keybinding.MacosValidator = keybindingDescMacos.Validators[0].(func(string) error)
// keybindingDescWindows is the schema descriptor for windows field.
keybindingDescWindows := keybindingFields[4].Descriptor()
// keybinding.WindowsValidator is a validator for the "windows" field. It is called by the builders before save.
keybinding.WindowsValidator = keybindingDescWindows.Validators[0].(func(string) error)
// keybindingDescLinux is the schema descriptor for linux field.
keybindingDescLinux := keybindingFields[5].Descriptor()
// keybinding.LinuxValidator is a validator for the "linux" field. It is called by the builders before save.
keybinding.LinuxValidator = keybindingDescLinux.Validators[0].(func(string) error)
// keybindingDescExtension is the schema descriptor for extension field.
keybindingDescExtension := keybindingFields[2].Descriptor()
keybindingDescExtension := keybindingFields[6].Descriptor()
// keybinding.ExtensionValidator is a validator for the "extension" field. It is called by the builders before save.
keybinding.ExtensionValidator = keybindingDescExtension.Validators[0].(func(string) error)
keybinding.ExtensionValidator = func() func(string) error {
validators := keybindingDescExtension.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(extension string) error {
for _, fn := range fns {
if err := fn(extension); err != nil {
return err
}
}
return nil
}
}()
// keybindingDescEnabled is the schema descriptor for enabled field.
keybindingDescEnabled := keybindingFields[3].Descriptor()
keybindingDescEnabled := keybindingFields[7].Descriptor()
// keybinding.DefaultEnabled holds the default value on creation for the enabled field.
keybinding.DefaultEnabled = keybindingDescEnabled.Default.(bool)
// keybindingDescPreventDefault is the schema descriptor for prevent_default field.
keybindingDescPreventDefault := keybindingFields[8].Descriptor()
// keybinding.DefaultPreventDefault holds the default value on creation for the prevent_default field.
keybinding.DefaultPreventDefault = keybindingDescPreventDefault.Default.(bool)
// keybindingDescScope is the schema descriptor for scope field.
keybindingDescScope := keybindingFields[9].Descriptor()
// keybinding.DefaultScope holds the default value on creation for the scope field.
keybinding.DefaultScope = keybindingDescScope.Default.(string)
// keybinding.ScopeValidator is a validator for the "scope" field. It is called by the builders before save.
keybinding.ScopeValidator = keybindingDescScope.Validators[0].(func(string) error)
themeMixin := schema.Theme{}.Mixin()
themeMixinHooks1 := themeMixin[1].Hooks()
themeMixinHooks2 := themeMixin[2].Hooks()
@@ -206,18 +234,18 @@ func init() {
themeDescUpdatedAt := themeMixinFields1[1].Descriptor()
// theme.DefaultUpdatedAt holds the default value on creation for the updated_at field.
theme.DefaultUpdatedAt = themeDescUpdatedAt.Default.(func() string)
// themeDescKey is the schema descriptor for key field.
themeDescKey := themeFields[0].Descriptor()
// theme.KeyValidator is a validator for the "key" field. It is called by the builders before save.
theme.KeyValidator = func() func(string) error {
validators := themeDescKey.Validators
// themeDescName is the schema descriptor for name field.
themeDescName := themeFields[0].Descriptor()
// theme.NameValidator is a validator for the "name" field. It is called by the builders before save.
theme.NameValidator = func() func(string) error {
validators := themeDescName.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(key string) error {
return func(name string) error {
for _, fn := range fns {
if err := fn(key); err != nil {
if err := fn(name); err != nil {
return err
}
}

View File

@@ -18,15 +18,15 @@ type Theme struct {
// ID of the ent.
ID int `json:"id,omitempty"`
// UUID for cross-device sync (UUIDv7)
UUID *string `json:"uuid"`
UUID string `json:"uuid"`
// creation time
CreatedAt string `json:"created_at"`
// update time
UpdatedAt string `json:"updated_at"`
// deleted at
DeletedAt *string `json:"deleted_at,omitempty"`
// theme key
Key string `json:"key"`
// theme name
Name string `json:"name"`
// theme type
Type theme.Type `json:"type"`
// theme colors
@@ -43,7 +43,7 @@ func (*Theme) scanValues(columns []string) ([]any, error) {
values[i] = new([]byte)
case theme.FieldID:
values[i] = new(sql.NullInt64)
case theme.FieldUUID, theme.FieldCreatedAt, theme.FieldUpdatedAt, theme.FieldDeletedAt, theme.FieldKey, theme.FieldType:
case theme.FieldUUID, theme.FieldCreatedAt, theme.FieldUpdatedAt, theme.FieldDeletedAt, theme.FieldName, theme.FieldType:
values[i] = new(sql.NullString)
default:
values[i] = new(sql.UnknownType)
@@ -70,8 +70,7 @@ func (_m *Theme) assignValues(columns []string, values []any) error {
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field uuid", values[i])
} else if value.Valid {
_m.UUID = new(string)
*_m.UUID = value.String
_m.UUID = value.String
}
case theme.FieldCreatedAt:
if value, ok := values[i].(*sql.NullString); !ok {
@@ -92,11 +91,11 @@ func (_m *Theme) assignValues(columns []string, values []any) error {
_m.DeletedAt = new(string)
*_m.DeletedAt = value.String
}
case theme.FieldKey:
case theme.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field key", values[i])
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
_m.Key = value.String
_m.Name = value.String
}
case theme.FieldType:
if value, ok := values[i].(*sql.NullString); !ok {
@@ -148,10 +147,8 @@ func (_m *Theme) String() string {
var builder strings.Builder
builder.WriteString("Theme(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
if v := _m.UUID; v != nil {
builder.WriteString("uuid=")
builder.WriteString(*v)
}
builder.WriteString("uuid=")
builder.WriteString(_m.UUID)
builder.WriteString(", ")
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt)
@@ -164,8 +161,8 @@ func (_m *Theme) String() string {
builder.WriteString(*v)
}
builder.WriteString(", ")
builder.WriteString("key=")
builder.WriteString(_m.Key)
builder.WriteString("name=")
builder.WriteString(_m.Name)
builder.WriteString(", ")
builder.WriteString("type=")
builder.WriteString(fmt.Sprintf("%v", _m.Type))

View File

@@ -22,8 +22,8 @@ const (
FieldUpdatedAt = "updated_at"
// FieldDeletedAt holds the string denoting the deleted_at field in the database.
FieldDeletedAt = "deleted_at"
// FieldKey holds the string denoting the key field in the database.
FieldKey = "key"
// FieldName holds the string denoting the name field in the database.
FieldName = "name"
// FieldType holds the string denoting the type field in the database.
FieldType = "type"
// FieldColors holds the string denoting the colors field in the database.
@@ -39,7 +39,7 @@ var Columns = []string{
FieldCreatedAt,
FieldUpdatedAt,
FieldDeletedAt,
FieldKey,
FieldName,
FieldType,
FieldColors,
}
@@ -68,8 +68,8 @@ var (
DefaultCreatedAt func() string
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
DefaultUpdatedAt func() string
// KeyValidator is a validator for the "key" field. It is called by the builders before save.
KeyValidator func(string) error
// NameValidator is a validator for the "name" field. It is called by the builders before save.
NameValidator func(string) error
)
// Type defines the type for the "type" enum field.
@@ -123,9 +123,9 @@ func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
}
// ByKey orders the results by the key field.
func ByKey(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldKey, opts...).ToFunc()
// ByName orders the results by the name field.
func ByName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldName, opts...).ToFunc()
}
// ByType orders the results by the type field.

View File

@@ -73,9 +73,9 @@ func DeletedAt(v string) predicate.Theme {
return predicate.Theme(sql.FieldEQ(FieldDeletedAt, v))
}
// Key applies equality check predicate on the "key" field. It's identical to KeyEQ.
func Key(v string) predicate.Theme {
return predicate.Theme(sql.FieldEQ(FieldKey, v))
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
func Name(v string) predicate.Theme {
return predicate.Theme(sql.FieldEQ(FieldName, v))
}
// UUIDEQ applies the EQ predicate on the "uuid" field.
@@ -133,16 +133,6 @@ func UUIDHasSuffix(v string) predicate.Theme {
return predicate.Theme(sql.FieldHasSuffix(FieldUUID, v))
}
// UUIDIsNil applies the IsNil predicate on the "uuid" field.
func UUIDIsNil() predicate.Theme {
return predicate.Theme(sql.FieldIsNull(FieldUUID))
}
// UUIDNotNil applies the NotNil predicate on the "uuid" field.
func UUIDNotNil() predicate.Theme {
return predicate.Theme(sql.FieldNotNull(FieldUUID))
}
// UUIDEqualFold applies the EqualFold predicate on the "uuid" field.
func UUIDEqualFold(v string) predicate.Theme {
return predicate.Theme(sql.FieldEqualFold(FieldUUID, v))
@@ -358,69 +348,69 @@ func DeletedAtContainsFold(v string) predicate.Theme {
return predicate.Theme(sql.FieldContainsFold(FieldDeletedAt, v))
}
// KeyEQ applies the EQ predicate on the "key" field.
func KeyEQ(v string) predicate.Theme {
return predicate.Theme(sql.FieldEQ(FieldKey, v))
// NameEQ applies the EQ predicate on the "name" field.
func NameEQ(v string) predicate.Theme {
return predicate.Theme(sql.FieldEQ(FieldName, v))
}
// KeyNEQ applies the NEQ predicate on the "key" field.
func KeyNEQ(v string) predicate.Theme {
return predicate.Theme(sql.FieldNEQ(FieldKey, v))
// NameNEQ applies the NEQ predicate on the "name" field.
func NameNEQ(v string) predicate.Theme {
return predicate.Theme(sql.FieldNEQ(FieldName, v))
}
// KeyIn applies the In predicate on the "key" field.
func KeyIn(vs ...string) predicate.Theme {
return predicate.Theme(sql.FieldIn(FieldKey, vs...))
// NameIn applies the In predicate on the "name" field.
func NameIn(vs ...string) predicate.Theme {
return predicate.Theme(sql.FieldIn(FieldName, vs...))
}
// KeyNotIn applies the NotIn predicate on the "key" field.
func KeyNotIn(vs ...string) predicate.Theme {
return predicate.Theme(sql.FieldNotIn(FieldKey, vs...))
// NameNotIn applies the NotIn predicate on the "name" field.
func NameNotIn(vs ...string) predicate.Theme {
return predicate.Theme(sql.FieldNotIn(FieldName, vs...))
}
// KeyGT applies the GT predicate on the "key" field.
func KeyGT(v string) predicate.Theme {
return predicate.Theme(sql.FieldGT(FieldKey, v))
// NameGT applies the GT predicate on the "name" field.
func NameGT(v string) predicate.Theme {
return predicate.Theme(sql.FieldGT(FieldName, v))
}
// KeyGTE applies the GTE predicate on the "key" field.
func KeyGTE(v string) predicate.Theme {
return predicate.Theme(sql.FieldGTE(FieldKey, v))
// NameGTE applies the GTE predicate on the "name" field.
func NameGTE(v string) predicate.Theme {
return predicate.Theme(sql.FieldGTE(FieldName, v))
}
// KeyLT applies the LT predicate on the "key" field.
func KeyLT(v string) predicate.Theme {
return predicate.Theme(sql.FieldLT(FieldKey, v))
// NameLT applies the LT predicate on the "name" field.
func NameLT(v string) predicate.Theme {
return predicate.Theme(sql.FieldLT(FieldName, v))
}
// KeyLTE applies the LTE predicate on the "key" field.
func KeyLTE(v string) predicate.Theme {
return predicate.Theme(sql.FieldLTE(FieldKey, v))
// NameLTE applies the LTE predicate on the "name" field.
func NameLTE(v string) predicate.Theme {
return predicate.Theme(sql.FieldLTE(FieldName, v))
}
// KeyContains applies the Contains predicate on the "key" field.
func KeyContains(v string) predicate.Theme {
return predicate.Theme(sql.FieldContains(FieldKey, v))
// NameContains applies the Contains predicate on the "name" field.
func NameContains(v string) predicate.Theme {
return predicate.Theme(sql.FieldContains(FieldName, v))
}
// KeyHasPrefix applies the HasPrefix predicate on the "key" field.
func KeyHasPrefix(v string) predicate.Theme {
return predicate.Theme(sql.FieldHasPrefix(FieldKey, v))
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
func NameHasPrefix(v string) predicate.Theme {
return predicate.Theme(sql.FieldHasPrefix(FieldName, v))
}
// KeyHasSuffix applies the HasSuffix predicate on the "key" field.
func KeyHasSuffix(v string) predicate.Theme {
return predicate.Theme(sql.FieldHasSuffix(FieldKey, v))
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
func NameHasSuffix(v string) predicate.Theme {
return predicate.Theme(sql.FieldHasSuffix(FieldName, v))
}
// KeyEqualFold applies the EqualFold predicate on the "key" field.
func KeyEqualFold(v string) predicate.Theme {
return predicate.Theme(sql.FieldEqualFold(FieldKey, v))
// NameEqualFold applies the EqualFold predicate on the "name" field.
func NameEqualFold(v string) predicate.Theme {
return predicate.Theme(sql.FieldEqualFold(FieldName, v))
}
// KeyContainsFold applies the ContainsFold predicate on the "key" field.
func KeyContainsFold(v string) predicate.Theme {
return predicate.Theme(sql.FieldContainsFold(FieldKey, v))
// NameContainsFold applies the ContainsFold predicate on the "name" field.
func NameContainsFold(v string) predicate.Theme {
return predicate.Theme(sql.FieldContainsFold(FieldName, v))
}
// TypeEQ applies the EQ predicate on the "type" field.

View File

@@ -75,9 +75,9 @@ func (_c *ThemeCreate) SetNillableDeletedAt(v *string) *ThemeCreate {
return _c
}
// SetKey sets the "key" field.
func (_c *ThemeCreate) SetKey(v string) *ThemeCreate {
_c.mutation.SetKey(v)
// SetName sets the "name" field.
func (_c *ThemeCreate) SetName(v string) *ThemeCreate {
_c.mutation.SetName(v)
return _c
}
@@ -156,18 +156,21 @@ func (_c *ThemeCreate) defaults() error {
// check runs all checks and user-defined validators on the builder.
func (_c *ThemeCreate) check() error {
if _, ok := _c.mutation.UUID(); !ok {
return &ValidationError{Name: "uuid", err: errors.New(`ent: missing required field "Theme.uuid"`)}
}
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Theme.created_at"`)}
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Theme.updated_at"`)}
}
if _, ok := _c.mutation.Key(); !ok {
return &ValidationError{Name: "key", err: errors.New(`ent: missing required field "Theme.key"`)}
if _, ok := _c.mutation.Name(); !ok {
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Theme.name"`)}
}
if v, ok := _c.mutation.Key(); ok {
if err := theme.KeyValidator(v); err != nil {
return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "Theme.key": %w`, err)}
if v, ok := _c.mutation.Name(); ok {
if err := theme.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Theme.name": %w`, err)}
}
}
if _, ok := _c.mutation.GetType(); !ok {
@@ -206,7 +209,7 @@ func (_c *ThemeCreate) createSpec() (*Theme, *sqlgraph.CreateSpec) {
)
if value, ok := _c.mutation.UUID(); ok {
_spec.SetField(theme.FieldUUID, field.TypeString, value)
_node.UUID = &value
_node.UUID = value
}
if value, ok := _c.mutation.CreatedAt(); ok {
_spec.SetField(theme.FieldCreatedAt, field.TypeString, value)
@@ -220,9 +223,9 @@ func (_c *ThemeCreate) createSpec() (*Theme, *sqlgraph.CreateSpec) {
_spec.SetField(theme.FieldDeletedAt, field.TypeString, value)
_node.DeletedAt = &value
}
if value, ok := _c.mutation.Key(); ok {
_spec.SetField(theme.FieldKey, field.TypeString, value)
_node.Key = value
if value, ok := _c.mutation.Name(); ok {
_spec.SetField(theme.FieldName, field.TypeString, value)
_node.Name = value
}
if value, ok := _c.mutation.GetType(); ok {
_spec.SetField(theme.FieldType, field.TypeEnum, value)

View File

@@ -62,16 +62,16 @@ func (_u *ThemeUpdate) ClearDeletedAt() *ThemeUpdate {
return _u
}
// SetKey sets the "key" field.
func (_u *ThemeUpdate) SetKey(v string) *ThemeUpdate {
_u.mutation.SetKey(v)
// SetName sets the "name" field.
func (_u *ThemeUpdate) SetName(v string) *ThemeUpdate {
_u.mutation.SetName(v)
return _u
}
// SetNillableKey sets the "key" field if the given value is not nil.
func (_u *ThemeUpdate) SetNillableKey(v *string) *ThemeUpdate {
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *ThemeUpdate) SetNillableName(v *string) *ThemeUpdate {
if v != nil {
_u.SetKey(*v)
_u.SetName(*v)
}
return _u
}
@@ -136,9 +136,9 @@ func (_u *ThemeUpdate) ExecX(ctx context.Context) {
// check runs all checks and user-defined validators on the builder.
func (_u *ThemeUpdate) check() error {
if v, ok := _u.mutation.Key(); ok {
if err := theme.KeyValidator(v); err != nil {
return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "Theme.key": %w`, err)}
if v, ok := _u.mutation.Name(); ok {
if err := theme.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Theme.name": %w`, err)}
}
}
if v, ok := _u.mutation.GetType(); ok {
@@ -167,9 +167,6 @@ func (_u *ThemeUpdate) sqlSave(ctx context.Context) (_node int, err error) {
}
}
}
if _u.mutation.UUIDCleared() {
_spec.ClearField(theme.FieldUUID, field.TypeString)
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(theme.FieldUpdatedAt, field.TypeString, value)
}
@@ -179,8 +176,8 @@ func (_u *ThemeUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if _u.mutation.DeletedAtCleared() {
_spec.ClearField(theme.FieldDeletedAt, field.TypeString)
}
if value, ok := _u.mutation.Key(); ok {
_spec.SetField(theme.FieldKey, field.TypeString, value)
if value, ok := _u.mutation.Name(); ok {
_spec.SetField(theme.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.GetType(); ok {
_spec.SetField(theme.FieldType, field.TypeEnum, value)
@@ -247,16 +244,16 @@ func (_u *ThemeUpdateOne) ClearDeletedAt() *ThemeUpdateOne {
return _u
}
// SetKey sets the "key" field.
func (_u *ThemeUpdateOne) SetKey(v string) *ThemeUpdateOne {
_u.mutation.SetKey(v)
// SetName sets the "name" field.
func (_u *ThemeUpdateOne) SetName(v string) *ThemeUpdateOne {
_u.mutation.SetName(v)
return _u
}
// SetNillableKey sets the "key" field if the given value is not nil.
func (_u *ThemeUpdateOne) SetNillableKey(v *string) *ThemeUpdateOne {
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *ThemeUpdateOne) SetNillableName(v *string) *ThemeUpdateOne {
if v != nil {
_u.SetKey(*v)
_u.SetName(*v)
}
return _u
}
@@ -334,9 +331,9 @@ func (_u *ThemeUpdateOne) ExecX(ctx context.Context) {
// check runs all checks and user-defined validators on the builder.
func (_u *ThemeUpdateOne) check() error {
if v, ok := _u.mutation.Key(); ok {
if err := theme.KeyValidator(v); err != nil {
return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "Theme.key": %w`, err)}
if v, ok := _u.mutation.Name(); ok {
if err := theme.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Theme.name": %w`, err)}
}
}
if v, ok := _u.mutation.GetType(); ok {
@@ -382,9 +379,6 @@ func (_u *ThemeUpdateOne) sqlSave(ctx context.Context) (_node *Theme, err error)
}
}
}
if _u.mutation.UUIDCleared() {
_spec.ClearField(theme.FieldUUID, field.TypeString)
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(theme.FieldUpdatedAt, field.TypeString, value)
}
@@ -394,8 +388,8 @@ func (_u *ThemeUpdateOne) sqlSave(ctx context.Context) (_node *Theme, err error)
if _u.mutation.DeletedAtCleared() {
_spec.ClearField(theme.FieldDeletedAt, field.TypeString)
}
if value, ok := _u.mutation.Key(); ok {
_spec.SetField(theme.FieldKey, field.TypeString, value)
if value, ok := _u.mutation.Name(); ok {
_spec.SetField(theme.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.GetType(); ok {
_spec.SetField(theme.FieldType, field.TypeEnum, value)

View File

@@ -3,31 +3,30 @@ package models
// ExtensionConfig 扩展配置项
type ExtensionConfig map[string]interface{}
// ExtensionKey 扩展标识符
type ExtensionKey string
// ExtensionName 扩展标识符
type ExtensionName string
// Extension 扩展配置
type Extension struct {
Key ExtensionKey `json:"key"`
Name ExtensionName `json:"key"`
Enabled bool `json:"enabled"`
Config ExtensionConfig `json:"config"`
}
const (
// 编辑增强扩展
ExtensionRainbowBrackets ExtensionKey = "rainbowBrackets" // 彩虹括号
ExtensionHyperlink ExtensionKey = "hyperlink" // 超链接
ExtensionColorSelector ExtensionKey = "colorSelector" // 颜色选择器
ExtensionFold ExtensionKey = "fold" // 代码折叠
ExtensionTranslator ExtensionKey = "translator" // 划词翻译
ExtensionMarkdown ExtensionKey = "markdown" // Markdown渲染
ExtensionHighlightWhitespace ExtensionKey = "highlightWhitespace" // 显示空白字符
ExtensionHighlightTrailingWhitespace ExtensionKey = "highlightTrailingWhitespace" // 高亮行尾空白
ExtensionMinimap ExtensionKey = "minimap" // 小地图
ExtensionLineNumbers ExtensionKey = "lineNumbers" // 行号显示
ExtensionContextMenu ExtensionKey = "contextMenu" // 上下文菜单
ExtensionSearch ExtensionKey = "search" // 搜索功能
ExtensionHttpClient ExtensionKey = "httpClient" // HTTP 客户端
RainbowBrackets ExtensionName = "rainbowBrackets" // 彩虹括号
Hyperlink ExtensionName = "hyperlink" // 超链接
ColorSelector ExtensionName = "colorSelector" // 颜色选择器
Fold ExtensionName = "fold" // 代码折叠
Translator ExtensionName = "translator" // 划词翻译
Markdown ExtensionName = "markdown" // Markdown渲染
HighlightWhitespace ExtensionName = "highlightWhitespace" // 显示空白字符
HighlightTrailingWhitespace ExtensionName = "highlightTrailingWhitespace" // 高亮行尾空白
Minimap ExtensionName = "minimap" // 小地图
LineNumbers ExtensionName = "lineNumbers" // 行号显示
ContextMenu ExtensionName = "contextMenu" // 上下文菜单
Search ExtensionName = "search" // 搜索功能
HttpClient ExtensionName = "httpClient" // HTTP 客户端
)
// NewDefaultExtensions 创建默认扩展配置
@@ -35,49 +34,49 @@ func NewDefaultExtensions() []Extension {
return []Extension{
// 编辑增强扩展
{
Key: ExtensionRainbowBrackets,
Name: RainbowBrackets,
Enabled: true,
Config: ExtensionConfig{},
},
{
Key: ExtensionHyperlink,
Name: Hyperlink,
Enabled: true,
Config: ExtensionConfig{},
},
{
Key: ExtensionColorSelector,
Name: ColorSelector,
Enabled: true,
Config: ExtensionConfig{},
},
{
Key: ExtensionFold,
Name: Fold,
Enabled: true,
Config: ExtensionConfig{},
},
{
Key: ExtensionTranslator,
Name: Translator,
Enabled: true,
Config: ExtensionConfig{},
},
{
Key: ExtensionMarkdown,
Name: Markdown,
Enabled: true,
Config: ExtensionConfig{},
},
{
Key: ExtensionHighlightWhitespace,
Name: HighlightWhitespace,
Enabled: true,
Config: ExtensionConfig{},
},
{
Key: ExtensionHighlightTrailingWhitespace,
Name: HighlightTrailingWhitespace,
Enabled: true,
Config: ExtensionConfig{},
},
// UI增强扩展
{
Key: ExtensionMinimap,
Name: Minimap,
Enabled: true,
Config: ExtensionConfig{
"displayText": "characters",
@@ -86,24 +85,24 @@ func NewDefaultExtensions() []Extension {
},
},
{
Key: ExtensionLineNumbers,
Name: LineNumbers,
Enabled: true,
Config: ExtensionConfig{},
},
{
Key: ExtensionContextMenu,
Name: ContextMenu,
Enabled: true,
Config: ExtensionConfig{},
},
// 工具扩展
{
Key: ExtensionSearch,
Name: Search,
Enabled: true,
Config: ExtensionConfig{},
},
{
Key: ExtensionHttpClient,
Name: HttpClient,
Enabled: true,
Config: ExtensionConfig{},
},

File diff suppressed because it is too large Load Diff

View File

@@ -34,12 +34,12 @@ func (Extension) Mixin() []ent.Mixin {
// Fields of the Extension.
func (Extension) Fields() []ent.Field {
return []ent.Field{
field.String("key").
field.String("name").
MaxLen(100).
NotEmpty().
Unique().
StructTag(`json:"key"`).
Comment("extension key"),
StructTag(`json:"name"`).
Comment("extension name"),
field.Bool("enabled").
Default(true).
StructTag(`json:"enabled"`).

View File

@@ -34,26 +34,58 @@ func (KeyBinding) Mixin() []ent.Mixin {
// Fields of the KeyBinding.
func (KeyBinding) Fields() []ent.Field {
return []ent.Field{
field.String("name").
MaxLen(100).
NotEmpty().
StructTag(`json:"name"`).
Comment("command identifier"),
field.String("type").
MaxLen(20).
Default("standard").
StructTag(`json:"type"`).
Comment("keybinding type: standard or emacs"),
field.String("key").
MaxLen(100).
NotEmpty().
Unique().
StructTag(`json:"key"`).
Comment("key binding key"),
field.String("command").
MaxLen(100).
NotEmpty().
StructTag(`json:"command"`).
Comment("key binding command"),
field.String("extension").
Optional().
StructTag(`json:"key,omitempty"`).
Comment("universal keybinding (cross-platform)"),
field.String("macos").
MaxLen(100).
Optional().
StructTag(`json:"extension,omitempty"`).
Comment("key binding extension"),
StructTag(`json:"macos,omitempty"`).
Comment("macOS specific keybinding"),
field.String("windows").
MaxLen(100).
Optional().
StructTag(`json:"windows,omitempty"`).
Comment("Windows specific keybinding"),
field.String("linux").
MaxLen(100).
Optional().
StructTag(`json:"linux,omitempty"`).
Comment("Linux specific keybinding"),
field.String("extension").
MaxLen(100).
NotEmpty().
StructTag(`json:"extension"`).
Comment("extension name (functional category)"),
field.Bool("enabled").
Default(true).
StructTag(`json:"enabled"`).
Comment("key binding enabled"),
Comment("whether this keybinding is enabled"),
field.Bool("prevent_default").
Default(true).
StructTag(`json:"preventDefault"`).
Comment("prevent browser default behavior"),
field.String("scope").
MaxLen(100).
Default("editor").
StructTag(`json:"scope,omitempty"`).
Comment("keybinding scope (default: editor)"),
}
}
@@ -65,7 +97,10 @@ func (KeyBinding) Edges() []ent.Edge {
// Indexes of the KeyBinding.
func (KeyBinding) Indexes() []ent.Index {
return []ent.Index{
index.Fields("extension"),
index.Fields("enabled"),
index.Fields("name"), // 命令标识符索引
index.Fields("type"), // 类型索引
index.Fields("type", "name").Unique(), // 类型+命令的联合唯一索引
index.Fields("extension"), // 扩展索引
index.Fields("enabled"), // 启用状态索引
}
}

View File

@@ -33,12 +33,12 @@ func (Theme) Mixin() []ent.Mixin {
// Fields of the Theme.
func (Theme) Fields() []ent.Field {
return []ent.Field{
field.String("key").
field.String("name").
MaxLen(100).
NotEmpty().
Unique().
StructTag(`json:"key"`).
Comment("theme key"),
StructTag(`json:"name"`).
Comment("theme name"),
field.Enum("type").
Values("dark", "light").
StructTag(`json:"type"`).