@@ -297,17 +297,89 @@ func (f *CookieBannerFilter) SQLArguments() pgx.StrictNamedArgs {
|
||||
|
||||
For complex multi-field filters, use `CASE WHEN` in SQL and always declare all argument keys in every code path (use `nil` for inactive ones).
|
||||
|
||||
## Order fields
|
||||
## Enums
|
||||
|
||||
String-based enums with `Column()`, `IsValid()`, `String()`, and `MarshalText`/`UnmarshalText`:
|
||||
Coredata enums are always `type X string` with a single validation source of truth (`IsValid`) and text marshalling support for pgx/JSON wiring.
|
||||
|
||||
```go
|
||||
type AssetOrderField string
|
||||
type XXXType string
|
||||
|
||||
const (
|
||||
AssetOrderFieldCreatedAt AssetOrderField = "CREATED_AT"
|
||||
AssetOrderFieldName AssetOrderField = "NAME"
|
||||
XXXTypeAlpha XXXType = "ALPHA"
|
||||
XXXTypeBeta XXXType = "BETA"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = XXXType("")
|
||||
_ encoding.TextMarshaler = XXXType("")
|
||||
_ encoding.TextUnmarshaler = (*XXXType)(nil)
|
||||
)
|
||||
|
||||
func XXXTypes() []XXXType {
|
||||
return []XXXType{
|
||||
XXXTypeAlpha,
|
||||
XXXTypeBeta,
|
||||
}
|
||||
}
|
||||
|
||||
func (v XXXType) IsValid() bool {
|
||||
switch v {
|
||||
case XXXTypeAlpha, XXXTypeBeta:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v XXXType) String() string { return string(v) }
|
||||
|
||||
func (v XXXType) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *XXXType) UnmarshalText(text []byte) error {
|
||||
val := XXXType(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid XXXType value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
return nil
|
||||
}
|
||||
```
|
||||
|
||||
Rules:
|
||||
|
||||
- Keep enums as string types only (no iota/int enums).
|
||||
- `UnmarshalText` must validate via `IsValid`; do not duplicate validation switches in `Scan`/`Value`.
|
||||
- Do not implement `database/sql` `Scan`/`Value` on singular enums in coredata; pgx uses `MarshalText` / `UnmarshalText`.
|
||||
- Add compile-time interface checks in a `var` block for every enum (`fmt.Stringer`, `encoding.TextMarshaler`, `encoding.TextUnmarshaler`).
|
||||
- Keep a `Values()` helper named as the pluralized enum type when there is no naming conflict.
|
||||
|
||||
Collection enum wrappers (`OAuth2Scopes`, `CountryCodes`, etc.) may keep custom parsing/encoding methods when wire format differs from a single enum token.
|
||||
|
||||
## Order fields
|
||||
|
||||
Order-field enums follow the same enum rules and additionally implement `Column()` and `page.OrderField`:
|
||||
|
||||
```go
|
||||
type XXXOrderField string
|
||||
|
||||
const (
|
||||
XXXOrderFieldCreatedAt XXXOrderField = "CREATED_AT"
|
||||
XXXOrderFieldName XXXOrderField = "NAME"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = XXXOrderField("")
|
||||
_ fmt.Stringer = XXXOrderField("")
|
||||
_ encoding.TextMarshaler = XXXOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*XXXOrderField)(nil)
|
||||
)
|
||||
|
||||
func (f XXXOrderField) Column() string {
|
||||
return string(f)
|
||||
}
|
||||
```
|
||||
|
||||
Each entity implements `CursorKey(field)` returning `page.NewCursorKey(entity.ID, sortValue)`, with a `panic` on unknown fields.
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -26,6 +26,12 @@ const (
|
||||
AccessEntryAccountTypeServiceAccount AccessEntryAccountType = "SERVICE_ACCOUNT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = AccessEntryAccountType("")
|
||||
_ encoding.TextMarshaler = AccessEntryAccountType("")
|
||||
_ encoding.TextUnmarshaler = (*AccessEntryAccountType)(nil)
|
||||
)
|
||||
|
||||
func AccessEntryAccountTypes() []AccessEntryAccountType {
|
||||
return []AccessEntryAccountType{
|
||||
AccessEntryAccountTypeUser,
|
||||
@@ -33,34 +39,32 @@ func AccessEntryAccountTypes() []AccessEntryAccountType {
|
||||
}
|
||||
}
|
||||
|
||||
func (a AccessEntryAccountType) String() string {
|
||||
return string(a)
|
||||
func (v AccessEntryAccountType) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
AccessEntryAccountTypeUser,
|
||||
AccessEntryAccountTypeServiceAccount:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (a *AccessEntryAccountType) Scan(value any) error {
|
||||
var str string
|
||||
func (v AccessEntryAccountType) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
str = v
|
||||
case []byte:
|
||||
str = string(v)
|
||||
default:
|
||||
return fmt.Errorf("cannot scan AccessEntryAccountType: unsupported type %T", value)
|
||||
func (v AccessEntryAccountType) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *AccessEntryAccountType) UnmarshalText(text []byte) error {
|
||||
val := AccessEntryAccountType(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid AccessEntryAccountType value: %q", string(text))
|
||||
}
|
||||
|
||||
switch str {
|
||||
case "USER":
|
||||
*a = AccessEntryAccountTypeUser
|
||||
case "SERVICE_ACCOUNT":
|
||||
*a = AccessEntryAccountTypeServiceAccount
|
||||
default:
|
||||
return fmt.Errorf("cannot parse AccessEntryAccountType: invalid value %q", str)
|
||||
}
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a AccessEntryAccountType) Value() (driver.Value, error) {
|
||||
return a.String(), nil
|
||||
}
|
||||
|
||||
@@ -16,56 +16,63 @@ package coredata
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestAccessEntryAccountTypeScan(t *testing.T) {
|
||||
func TestAccessEntryAccountTypeIsValid(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
input any
|
||||
want AccessEntryAccountType
|
||||
wantErr bool
|
||||
}{
|
||||
{name: "user string", input: "USER", want: AccessEntryAccountTypeUser},
|
||||
{name: "service_account bytes", input: []byte("SERVICE_ACCOUNT"), want: AccessEntryAccountTypeServiceAccount},
|
||||
{name: "invalid value", input: "BOGUS", wantErr: true},
|
||||
{name: "unsupported type", input: 42, wantErr: true},
|
||||
for _, value := range AccessEntryAccountTypes() {
|
||||
if !value.IsValid() {
|
||||
t.Fatalf("IsValid() = false for %q", value)
|
||||
}
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if AccessEntryAccountType("BOGUS").IsValid() {
|
||||
t.Fatal("IsValid() = true for invalid value")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAccessEntryAccountTypeUnmarshalText(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, value := range AccessEntryAccountTypes() {
|
||||
t.Run(string(value), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var got AccessEntryAccountType
|
||||
|
||||
err := got.Scan(tt.input)
|
||||
if tt.wantErr {
|
||||
if err == nil {
|
||||
t.Fatalf("Scan(%v) expected error", tt.input)
|
||||
}
|
||||
|
||||
return
|
||||
if err := got.UnmarshalText([]byte(value)); err != nil {
|
||||
t.Fatalf("UnmarshalText(%q) returned error: %v", value, err)
|
||||
}
|
||||
|
||||
if got != value {
|
||||
t.Fatalf("UnmarshalText(%q) = %q, want %q", value, got, value)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
t.Run("invalid", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var got AccessEntryAccountType
|
||||
if err := got.UnmarshalText([]byte("BOGUS")); err == nil {
|
||||
t.Fatal("UnmarshalText(BOGUS) expected error")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccessEntryAccountTypeMarshalText(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, value := range AccessEntryAccountTypes() {
|
||||
t.Run(string(value), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
got, err := value.MarshalText()
|
||||
if err != nil {
|
||||
t.Fatalf("Scan(%v) returned error: %v", tt.input, err)
|
||||
t.Fatalf("MarshalText() returned error: %v", err)
|
||||
}
|
||||
|
||||
if got != tt.want {
|
||||
t.Fatalf("Scan(%v) = %q, want %q", tt.input, got, tt.want)
|
||||
if string(got) != value.String() {
|
||||
t.Fatalf("MarshalText() = %q, want %q", string(got), value.String())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestAccessEntryAccountTypeValue(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
got, err := AccessEntryAccountTypeUser.Value()
|
||||
if err != nil {
|
||||
t.Fatalf("Value() returned error: %v", err)
|
||||
}
|
||||
|
||||
if got != "USER" {
|
||||
t.Fatalf("Value() = %q, want %q", got, "USER")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -29,40 +29,51 @@ const (
|
||||
AccessEntryDecisionEscalate AccessEntryDecision = "ESCALATE"
|
||||
)
|
||||
|
||||
func (d AccessEntryDecision) String() string {
|
||||
return string(d)
|
||||
var (
|
||||
_ fmt.Stringer = AccessEntryDecision("")
|
||||
_ encoding.TextMarshaler = AccessEntryDecision("")
|
||||
_ encoding.TextUnmarshaler = (*AccessEntryDecision)(nil)
|
||||
)
|
||||
|
||||
func AccessEntryDecisions() []AccessEntryDecision {
|
||||
return []AccessEntryDecision{
|
||||
AccessEntryDecisionPending,
|
||||
AccessEntryDecisionApproved,
|
||||
AccessEntryDecisionRevoke,
|
||||
AccessEntryDecisionDefer,
|
||||
AccessEntryDecisionEscalate,
|
||||
}
|
||||
}
|
||||
|
||||
func (d *AccessEntryDecision) Scan(value any) error {
|
||||
var str string
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
str = v
|
||||
case []byte:
|
||||
str = string(v)
|
||||
default:
|
||||
return fmt.Errorf("cannot scan AccessEntryDecision: unsupported type %T", value)
|
||||
func (v AccessEntryDecision) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
AccessEntryDecisionPending,
|
||||
AccessEntryDecisionApproved,
|
||||
AccessEntryDecisionRevoke,
|
||||
AccessEntryDecisionDefer,
|
||||
AccessEntryDecisionEscalate:
|
||||
return true
|
||||
}
|
||||
|
||||
switch str {
|
||||
case "PENDING":
|
||||
*d = AccessEntryDecisionPending
|
||||
case "APPROVED":
|
||||
*d = AccessEntryDecisionApproved
|
||||
case "REVOKE":
|
||||
*d = AccessEntryDecisionRevoke
|
||||
case "DEFER":
|
||||
*d = AccessEntryDecisionDefer
|
||||
case "ESCALATE":
|
||||
*d = AccessEntryDecisionEscalate
|
||||
default:
|
||||
return fmt.Errorf("cannot parse AccessEntryDecision: invalid value %q", str)
|
||||
return false
|
||||
}
|
||||
|
||||
func (v AccessEntryDecision) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v AccessEntryDecision) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *AccessEntryDecision) UnmarshalText(text []byte) error {
|
||||
val := AccessEntryDecision(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid AccessEntryDecision value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d AccessEntryDecision) Value() (driver.Value, error) {
|
||||
return d.String(), nil
|
||||
}
|
||||
|
||||
@@ -16,74 +16,62 @@ package coredata
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestAccessEntryDecisionScan(t *testing.T) {
|
||||
func TestAccessEntryDecisionIsValid(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
input any
|
||||
want AccessEntryDecision
|
||||
wantErr bool
|
||||
}{
|
||||
{name: "pending string", input: "PENDING", want: AccessEntryDecisionPending},
|
||||
{name: "approved string", input: "APPROVED", want: AccessEntryDecisionApproved},
|
||||
{name: "revoke string", input: "REVOKE", want: AccessEntryDecisionRevoke},
|
||||
{name: "defer bytes", input: []byte("DEFER"), want: AccessEntryDecisionDefer},
|
||||
{name: "escalate string", input: "ESCALATE", want: AccessEntryDecisionEscalate},
|
||||
{name: "invalid value", input: "BOGUS", wantErr: true},
|
||||
{name: "unsupported type", input: 42, wantErr: true},
|
||||
for _, value := range AccessEntryDecisions() {
|
||||
if !value.IsValid() {
|
||||
t.Fatalf("IsValid() = false for %q", value)
|
||||
}
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if AccessEntryDecision("BOGUS").IsValid() {
|
||||
t.Fatal("IsValid() = true for invalid value")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAccessEntryDecisionUnmarshalText(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, value := range AccessEntryDecisions() {
|
||||
t.Run(string(value), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var got AccessEntryDecision
|
||||
|
||||
err := got.Scan(tt.input)
|
||||
if tt.wantErr {
|
||||
if err == nil {
|
||||
t.Fatalf("Scan(%v) expected error", tt.input)
|
||||
}
|
||||
|
||||
return
|
||||
if err := got.UnmarshalText([]byte(value)); err != nil {
|
||||
t.Fatalf("UnmarshalText(%q) returned error: %v", value, err)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("Scan(%v) returned error: %v", tt.input, err)
|
||||
}
|
||||
|
||||
if got != tt.want {
|
||||
t.Fatalf("Scan(%v) = %q, want %q", tt.input, got, tt.want)
|
||||
if got != value {
|
||||
t.Fatalf("UnmarshalText(%q) = %q, want %q", value, got, value)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
t.Run("invalid", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var got AccessEntryDecision
|
||||
if err := got.UnmarshalText([]byte("BOGUS")); err == nil {
|
||||
t.Fatal("UnmarshalText(BOGUS) expected error")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccessEntryDecisionValue(t *testing.T) {
|
||||
func TestAccessEntryDecisionMarshalText(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
decision AccessEntryDecision
|
||||
want string
|
||||
}{
|
||||
{name: "pending", decision: AccessEntryDecisionPending, want: "PENDING"},
|
||||
{name: "approved", decision: AccessEntryDecisionApproved, want: "APPROVED"},
|
||||
{name: "revoke", decision: AccessEntryDecisionRevoke, want: "REVOKE"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
for _, value := range AccessEntryDecisions() {
|
||||
t.Run(string(value), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
got, err := tt.decision.Value()
|
||||
got, err := value.MarshalText()
|
||||
if err != nil {
|
||||
t.Fatalf("Value() returned error: %v", err)
|
||||
t.Fatalf("MarshalText() returned error: %v", err)
|
||||
}
|
||||
|
||||
if got != tt.want {
|
||||
t.Fatalf("Value() = %q, want %q", got, tt.want)
|
||||
if string(got) != value.String() {
|
||||
t.Fatalf("MarshalText() = %q, want %q", string(got), value.String())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -39,60 +39,71 @@ const (
|
||||
AccessEntryFlagSharedAccount AccessEntryFlag = "SHARED_ACCOUNT"
|
||||
)
|
||||
|
||||
func (f AccessEntryFlag) String() string {
|
||||
return string(f)
|
||||
var (
|
||||
_ fmt.Stringer = AccessEntryFlag("")
|
||||
_ encoding.TextMarshaler = AccessEntryFlag("")
|
||||
_ encoding.TextUnmarshaler = (*AccessEntryFlag)(nil)
|
||||
)
|
||||
|
||||
func AccessEntryFlags() []AccessEntryFlag {
|
||||
return []AccessEntryFlag{
|
||||
AccessEntryFlagNone,
|
||||
AccessEntryFlagOrphaned,
|
||||
AccessEntryFlagInactive,
|
||||
AccessEntryFlagExcessive,
|
||||
AccessEntryFlagRoleMismatch,
|
||||
AccessEntryFlagNew,
|
||||
AccessEntryFlagDormant,
|
||||
AccessEntryFlagTerminatedUser,
|
||||
AccessEntryFlagContractorExpired,
|
||||
AccessEntryFlagSoDConflict,
|
||||
AccessEntryFlagPrivilegedAccess,
|
||||
AccessEntryFlagRoleCreep,
|
||||
AccessEntryFlagNoBusinessJustification,
|
||||
AccessEntryFlagOutOfDepartment,
|
||||
AccessEntryFlagSharedAccount,
|
||||
}
|
||||
}
|
||||
|
||||
func (f *AccessEntryFlag) Scan(value any) error {
|
||||
var str string
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
str = v
|
||||
case []byte:
|
||||
str = string(v)
|
||||
default:
|
||||
return fmt.Errorf("cannot scan AccessEntryFlag: unsupported type %T", value)
|
||||
func (v AccessEntryFlag) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
AccessEntryFlagNone,
|
||||
AccessEntryFlagOrphaned,
|
||||
AccessEntryFlagInactive,
|
||||
AccessEntryFlagExcessive,
|
||||
AccessEntryFlagRoleMismatch,
|
||||
AccessEntryFlagNew,
|
||||
AccessEntryFlagDormant,
|
||||
AccessEntryFlagTerminatedUser,
|
||||
AccessEntryFlagContractorExpired,
|
||||
AccessEntryFlagSoDConflict,
|
||||
AccessEntryFlagPrivilegedAccess,
|
||||
AccessEntryFlagRoleCreep,
|
||||
AccessEntryFlagNoBusinessJustification,
|
||||
AccessEntryFlagOutOfDepartment,
|
||||
AccessEntryFlagSharedAccount:
|
||||
return true
|
||||
}
|
||||
|
||||
switch str {
|
||||
case "NONE":
|
||||
*f = AccessEntryFlagNone
|
||||
case "ORPHANED":
|
||||
*f = AccessEntryFlagOrphaned
|
||||
case "INACTIVE":
|
||||
*f = AccessEntryFlagInactive
|
||||
case "EXCESSIVE":
|
||||
*f = AccessEntryFlagExcessive
|
||||
case "ROLE_MISMATCH":
|
||||
*f = AccessEntryFlagRoleMismatch
|
||||
case "NEW":
|
||||
*f = AccessEntryFlagNew
|
||||
case "DORMANT":
|
||||
*f = AccessEntryFlagDormant
|
||||
case "TERMINATED_USER":
|
||||
*f = AccessEntryFlagTerminatedUser
|
||||
case "CONTRACTOR_EXPIRED":
|
||||
*f = AccessEntryFlagContractorExpired
|
||||
case "SOD_CONFLICT":
|
||||
*f = AccessEntryFlagSoDConflict
|
||||
case "PRIVILEGED_ACCESS":
|
||||
*f = AccessEntryFlagPrivilegedAccess
|
||||
case "ROLE_CREEP":
|
||||
*f = AccessEntryFlagRoleCreep
|
||||
case "NO_BUSINESS_JUSTIFICATION":
|
||||
*f = AccessEntryFlagNoBusinessJustification
|
||||
case "OUT_OF_DEPARTMENT":
|
||||
*f = AccessEntryFlagOutOfDepartment
|
||||
case "SHARED_ACCOUNT":
|
||||
*f = AccessEntryFlagSharedAccount
|
||||
default:
|
||||
return fmt.Errorf("cannot parse AccessEntryFlag: invalid value %q", str)
|
||||
return false
|
||||
}
|
||||
|
||||
func (v AccessEntryFlag) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v AccessEntryFlag) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *AccessEntryFlag) UnmarshalText(text []byte) error {
|
||||
val := AccessEntryFlag(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid AccessEntryFlag value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f AccessEntryFlag) Value() (driver.Value, error) {
|
||||
return f.String(), nil
|
||||
}
|
||||
|
||||
@@ -16,60 +16,63 @@ package coredata
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestAccessEntryFlagScan(t *testing.T) {
|
||||
func TestAccessEntryFlagIsValid(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
input any
|
||||
want AccessEntryFlag
|
||||
wantErr bool
|
||||
}{
|
||||
{name: "none string", input: "NONE", want: AccessEntryFlagNone},
|
||||
{name: "orphaned string", input: "ORPHANED", want: AccessEntryFlagOrphaned},
|
||||
{name: "inactive string", input: "INACTIVE", want: AccessEntryFlagInactive},
|
||||
{name: "excessive string", input: "EXCESSIVE", want: AccessEntryFlagExcessive},
|
||||
{name: "role_mismatch bytes", input: []byte("ROLE_MISMATCH"), want: AccessEntryFlagRoleMismatch},
|
||||
{name: "new string", input: "NEW", want: AccessEntryFlagNew},
|
||||
{name: "invalid value", input: "BOGUS", wantErr: true},
|
||||
{name: "unsupported type", input: 42, wantErr: true},
|
||||
for _, value := range AccessEntryFlags() {
|
||||
if !value.IsValid() {
|
||||
t.Fatalf("IsValid() = false for %q", value)
|
||||
}
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if AccessEntryFlag("BOGUS").IsValid() {
|
||||
t.Fatal("IsValid() = true for invalid value")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAccessEntryFlagUnmarshalText(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, value := range AccessEntryFlags() {
|
||||
t.Run(string(value), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var got AccessEntryFlag
|
||||
|
||||
err := got.Scan(tt.input)
|
||||
if tt.wantErr {
|
||||
if err == nil {
|
||||
t.Fatalf("Scan(%v) expected error", tt.input)
|
||||
}
|
||||
|
||||
return
|
||||
if err := got.UnmarshalText([]byte(value)); err != nil {
|
||||
t.Fatalf("UnmarshalText(%q) returned error: %v", value, err)
|
||||
}
|
||||
|
||||
if got != value {
|
||||
t.Fatalf("UnmarshalText(%q) = %q, want %q", value, got, value)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
t.Run("invalid", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var got AccessEntryFlag
|
||||
if err := got.UnmarshalText([]byte("BOGUS")); err == nil {
|
||||
t.Fatal("UnmarshalText(BOGUS) expected error")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccessEntryFlagMarshalText(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, value := range AccessEntryFlags() {
|
||||
t.Run(string(value), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
got, err := value.MarshalText()
|
||||
if err != nil {
|
||||
t.Fatalf("Scan(%v) returned error: %v", tt.input, err)
|
||||
t.Fatalf("MarshalText() returned error: %v", err)
|
||||
}
|
||||
|
||||
if got != tt.want {
|
||||
t.Fatalf("Scan(%v) = %q, want %q", tt.input, got, tt.want)
|
||||
if string(got) != value.String() {
|
||||
t.Fatalf("MarshalText() = %q, want %q", string(got), value.String())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestAccessEntryFlagValue(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
got, err := AccessEntryFlagNone.Value()
|
||||
if err != nil {
|
||||
t.Fatalf("Value() returned error: %v", err)
|
||||
}
|
||||
|
||||
if got != "NONE" {
|
||||
t.Fatalf("Value() = %q, want %q", got, "NONE")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -27,36 +27,47 @@ const (
|
||||
AccessEntryIncrementalTagUnchanged AccessEntryIncrementalTag = "UNCHANGED"
|
||||
)
|
||||
|
||||
func (t AccessEntryIncrementalTag) String() string {
|
||||
return string(t)
|
||||
var (
|
||||
_ fmt.Stringer = AccessEntryIncrementalTag("")
|
||||
_ encoding.TextMarshaler = AccessEntryIncrementalTag("")
|
||||
_ encoding.TextUnmarshaler = (*AccessEntryIncrementalTag)(nil)
|
||||
)
|
||||
|
||||
func AccessEntryIncrementalTags() []AccessEntryIncrementalTag {
|
||||
return []AccessEntryIncrementalTag{
|
||||
AccessEntryIncrementalTagNew,
|
||||
AccessEntryIncrementalTagRemoved,
|
||||
AccessEntryIncrementalTagUnchanged,
|
||||
}
|
||||
}
|
||||
|
||||
func (t *AccessEntryIncrementalTag) Scan(value any) error {
|
||||
var str string
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
str = v
|
||||
case []byte:
|
||||
str = string(v)
|
||||
default:
|
||||
return fmt.Errorf("cannot scan AccessEntryIncrementalTag: unsupported type %T", value)
|
||||
func (v AccessEntryIncrementalTag) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
AccessEntryIncrementalTagNew,
|
||||
AccessEntryIncrementalTagRemoved,
|
||||
AccessEntryIncrementalTagUnchanged:
|
||||
return true
|
||||
}
|
||||
|
||||
switch str {
|
||||
case "NEW":
|
||||
*t = AccessEntryIncrementalTagNew
|
||||
case "REMOVED":
|
||||
*t = AccessEntryIncrementalTagRemoved
|
||||
case "UNCHANGED":
|
||||
*t = AccessEntryIncrementalTagUnchanged
|
||||
default:
|
||||
return fmt.Errorf("cannot parse AccessEntryIncrementalTag: invalid value %q", str)
|
||||
return false
|
||||
}
|
||||
|
||||
func (v AccessEntryIncrementalTag) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v AccessEntryIncrementalTag) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *AccessEntryIncrementalTag) UnmarshalText(text []byte) error {
|
||||
val := AccessEntryIncrementalTag(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid AccessEntryIncrementalTag value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t AccessEntryIncrementalTag) Value() (driver.Value, error) {
|
||||
return t.String(), nil
|
||||
}
|
||||
|
||||
@@ -16,57 +16,63 @@ package coredata
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestAccessEntryIncrementalTagScan(t *testing.T) {
|
||||
func TestAccessEntryIncrementalTagIsValid(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
input any
|
||||
want AccessEntryIncrementalTag
|
||||
wantErr bool
|
||||
}{
|
||||
{name: "new string", input: "NEW", want: AccessEntryIncrementalTagNew},
|
||||
{name: "removed bytes", input: []byte("REMOVED"), want: AccessEntryIncrementalTagRemoved},
|
||||
{name: "unchanged string", input: "UNCHANGED", want: AccessEntryIncrementalTagUnchanged},
|
||||
{name: "invalid value", input: "BOGUS", wantErr: true},
|
||||
{name: "unsupported type", input: 42, wantErr: true},
|
||||
for _, value := range AccessEntryIncrementalTags() {
|
||||
if !value.IsValid() {
|
||||
t.Fatalf("IsValid() = false for %q", value)
|
||||
}
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if AccessEntryIncrementalTag("BOGUS").IsValid() {
|
||||
t.Fatal("IsValid() = true for invalid value")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAccessEntryIncrementalTagUnmarshalText(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, value := range AccessEntryIncrementalTags() {
|
||||
t.Run(string(value), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var got AccessEntryIncrementalTag
|
||||
|
||||
err := got.Scan(tt.input)
|
||||
if tt.wantErr {
|
||||
if err == nil {
|
||||
t.Fatalf("Scan(%v) expected error", tt.input)
|
||||
}
|
||||
|
||||
return
|
||||
if err := got.UnmarshalText([]byte(value)); err != nil {
|
||||
t.Fatalf("UnmarshalText(%q) returned error: %v", value, err)
|
||||
}
|
||||
|
||||
if got != value {
|
||||
t.Fatalf("UnmarshalText(%q) = %q, want %q", value, got, value)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
t.Run("invalid", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var got AccessEntryIncrementalTag
|
||||
if err := got.UnmarshalText([]byte("BOGUS")); err == nil {
|
||||
t.Fatal("UnmarshalText(BOGUS) expected error")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccessEntryIncrementalTagMarshalText(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, value := range AccessEntryIncrementalTags() {
|
||||
t.Run(string(value), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
got, err := value.MarshalText()
|
||||
if err != nil {
|
||||
t.Fatalf("Scan(%v) returned error: %v", tt.input, err)
|
||||
t.Fatalf("MarshalText() returned error: %v", err)
|
||||
}
|
||||
|
||||
if got != tt.want {
|
||||
t.Fatalf("Scan(%v) = %q, want %q", tt.input, got, tt.want)
|
||||
if string(got) != value.String() {
|
||||
t.Fatalf("MarshalText() = %q, want %q", string(got), value.String())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestAccessEntryIncrementalTagValue(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
got, err := AccessEntryIncrementalTagNew.Value()
|
||||
if err != nil {
|
||||
t.Fatalf("Value() returned error: %v", err)
|
||||
}
|
||||
|
||||
if got != "NEW" {
|
||||
t.Fatalf("Value() = %q, want %q", got, "NEW")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,12 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
AccessEntryOrderField string
|
||||
@@ -24,6 +29,48 @@ const (
|
||||
AccessEntryOrderFieldCreatedAt AccessEntryOrderField = "CREATED_AT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = AccessEntryOrderField("")
|
||||
_ fmt.Stringer = AccessEntryOrderField("")
|
||||
_ encoding.TextMarshaler = AccessEntryOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*AccessEntryOrderField)(nil)
|
||||
)
|
||||
|
||||
func AccessEntryOrderFields() []AccessEntryOrderField {
|
||||
return []AccessEntryOrderField{
|
||||
AccessEntryOrderFieldCreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v AccessEntryOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
AccessEntryOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v AccessEntryOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v AccessEntryOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *AccessEntryOrderField) UnmarshalText(text []byte) error {
|
||||
val := AccessEntryOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid AccessEntryOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p AccessEntryOrderField) Column() string {
|
||||
switch p {
|
||||
case AccessEntryOrderFieldCreatedAt:
|
||||
@@ -32,29 +79,3 @@ func (p AccessEntryOrderField) Column() string {
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", p))
|
||||
}
|
||||
|
||||
func (p AccessEntryOrderField) IsValid() bool {
|
||||
switch p {
|
||||
case AccessEntryOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (p AccessEntryOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p AccessEntryOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *AccessEntryOrderField) UnmarshalText(text []byte) error {
|
||||
*p = AccessEntryOrderField(text)
|
||||
if !p.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid AccessEntryOrderField", string(text))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -14,7 +14,12 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
AccessReviewCampaignOrderField string
|
||||
@@ -24,6 +29,48 @@ const (
|
||||
AccessReviewCampaignOrderFieldCreatedAt AccessReviewCampaignOrderField = "CREATED_AT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = AccessReviewCampaignOrderField("")
|
||||
_ fmt.Stringer = AccessReviewCampaignOrderField("")
|
||||
_ encoding.TextMarshaler = AccessReviewCampaignOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*AccessReviewCampaignOrderField)(nil)
|
||||
)
|
||||
|
||||
func AccessReviewCampaignOrderFields() []AccessReviewCampaignOrderField {
|
||||
return []AccessReviewCampaignOrderField{
|
||||
AccessReviewCampaignOrderFieldCreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v AccessReviewCampaignOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
AccessReviewCampaignOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v AccessReviewCampaignOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v AccessReviewCampaignOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *AccessReviewCampaignOrderField) UnmarshalText(text []byte) error {
|
||||
val := AccessReviewCampaignOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid AccessReviewCampaignOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p AccessReviewCampaignOrderField) Column() string {
|
||||
switch p {
|
||||
case AccessReviewCampaignOrderFieldCreatedAt:
|
||||
@@ -32,29 +79,3 @@ func (p AccessReviewCampaignOrderField) Column() string {
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", p))
|
||||
}
|
||||
|
||||
func (p AccessReviewCampaignOrderField) IsValid() bool {
|
||||
switch p {
|
||||
case AccessReviewCampaignOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (p AccessReviewCampaignOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p AccessReviewCampaignOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *AccessReviewCampaignOrderField) UnmarshalText(text []byte) error {
|
||||
*p = AccessReviewCampaignOrderField(text)
|
||||
if !p.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid AccessReviewCampaignOrderField", string(text))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -28,42 +28,53 @@ const (
|
||||
AccessReviewCampaignSourceFetchStatusFailed AccessReviewCampaignSourceFetchStatus = "FAILED"
|
||||
)
|
||||
|
||||
func (s AccessReviewCampaignSourceFetchStatus) IsTerminal() bool {
|
||||
return s == AccessReviewCampaignSourceFetchStatusSuccess || s == AccessReviewCampaignSourceFetchStatusFailed
|
||||
var (
|
||||
_ fmt.Stringer = AccessReviewCampaignSourceFetchStatus("")
|
||||
_ encoding.TextMarshaler = AccessReviewCampaignSourceFetchStatus("")
|
||||
_ encoding.TextUnmarshaler = (*AccessReviewCampaignSourceFetchStatus)(nil)
|
||||
)
|
||||
|
||||
func AccessReviewCampaignSourceFetchStatuses() []AccessReviewCampaignSourceFetchStatus {
|
||||
return []AccessReviewCampaignSourceFetchStatus{
|
||||
AccessReviewCampaignSourceFetchStatusQueued,
|
||||
AccessReviewCampaignSourceFetchStatusFetching,
|
||||
AccessReviewCampaignSourceFetchStatusSuccess,
|
||||
AccessReviewCampaignSourceFetchStatusFailed,
|
||||
}
|
||||
}
|
||||
|
||||
func (s AccessReviewCampaignSourceFetchStatus) String() string {
|
||||
return string(s)
|
||||
func (v AccessReviewCampaignSourceFetchStatus) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
AccessReviewCampaignSourceFetchStatusQueued,
|
||||
AccessReviewCampaignSourceFetchStatusFetching,
|
||||
AccessReviewCampaignSourceFetchStatusSuccess,
|
||||
AccessReviewCampaignSourceFetchStatusFailed:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *AccessReviewCampaignSourceFetchStatus) Scan(value any) error {
|
||||
var str string
|
||||
func (v AccessReviewCampaignSourceFetchStatus) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
str = v
|
||||
case []byte:
|
||||
str = string(v)
|
||||
default:
|
||||
return fmt.Errorf("cannot scan AccessReviewCampaignSourceFetchStatus: unsupported type %T", value)
|
||||
func (v AccessReviewCampaignSourceFetchStatus) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *AccessReviewCampaignSourceFetchStatus) UnmarshalText(text []byte) error {
|
||||
val := AccessReviewCampaignSourceFetchStatus(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid AccessReviewCampaignSourceFetchStatus value: %q", string(text))
|
||||
}
|
||||
|
||||
switch str {
|
||||
case "QUEUED":
|
||||
*s = AccessReviewCampaignSourceFetchStatusQueued
|
||||
case "FETCHING":
|
||||
*s = AccessReviewCampaignSourceFetchStatusFetching
|
||||
case "SUCCESS":
|
||||
*s = AccessReviewCampaignSourceFetchStatusSuccess
|
||||
case "FAILED":
|
||||
*s = AccessReviewCampaignSourceFetchStatusFailed
|
||||
default:
|
||||
return fmt.Errorf("cannot parse AccessReviewCampaignSourceFetchStatus: invalid value %q", str)
|
||||
}
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s AccessReviewCampaignSourceFetchStatus) Value() (driver.Value, error) {
|
||||
return s.String(), nil
|
||||
func (s AccessReviewCampaignSourceFetchStatus) IsTerminal() bool {
|
||||
return s == AccessReviewCampaignSourceFetchStatusSuccess || s == AccessReviewCampaignSourceFetchStatusFailed
|
||||
}
|
||||
|
||||
@@ -36,53 +36,62 @@ func TestAccessReviewCampaignSourceFetchStatusIsTerminal(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAccessReviewCampaignSourceFetchStatusScan(t *testing.T) {
|
||||
func TestAccessReviewCampaignSourceFetchStatusIsValid(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
input any
|
||||
want AccessReviewCampaignSourceFetchStatus
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "queued string",
|
||||
input: "QUEUED",
|
||||
want: AccessReviewCampaignSourceFetchStatusQueued,
|
||||
},
|
||||
{
|
||||
name: "fetching bytes",
|
||||
input: []byte("FETCHING"),
|
||||
want: AccessReviewCampaignSourceFetchStatusFetching,
|
||||
},
|
||||
{
|
||||
name: "invalid value",
|
||||
input: "BOGUS",
|
||||
wantErr: true,
|
||||
},
|
||||
for _, value := range AccessReviewCampaignSourceFetchStatuses() {
|
||||
if !value.IsValid() {
|
||||
t.Fatalf("IsValid() = false for %q", value)
|
||||
}
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if AccessReviewCampaignSourceFetchStatus("BOGUS").IsValid() {
|
||||
t.Fatal("IsValid() = true for invalid value")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAccessReviewCampaignSourceFetchStatusUnmarshalText(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, value := range AccessReviewCampaignSourceFetchStatuses() {
|
||||
t.Run(string(value), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var got AccessReviewCampaignSourceFetchStatus
|
||||
|
||||
err := got.Scan(tt.input)
|
||||
if tt.wantErr {
|
||||
if err == nil {
|
||||
t.Fatalf("Scan(%v) expected error", tt.input)
|
||||
}
|
||||
|
||||
return
|
||||
if err := got.UnmarshalText([]byte(value)); err != nil {
|
||||
t.Fatalf("UnmarshalText(%q) returned error: %v", value, err)
|
||||
}
|
||||
|
||||
if got != value {
|
||||
t.Fatalf("UnmarshalText(%q) = %q, want %q", value, got, value)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
t.Run("invalid", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var got AccessReviewCampaignSourceFetchStatus
|
||||
if err := got.UnmarshalText([]byte("BOGUS")); err == nil {
|
||||
t.Fatal("UnmarshalText(BOGUS) expected error")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccessReviewCampaignSourceFetchStatusMarshalText(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, value := range AccessReviewCampaignSourceFetchStatuses() {
|
||||
t.Run(string(value), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
got, err := value.MarshalText()
|
||||
if err != nil {
|
||||
t.Fatalf("Scan(%v) returned error: %v", tt.input, err)
|
||||
t.Fatalf("MarshalText() returned error: %v", err)
|
||||
}
|
||||
|
||||
if got != tt.want {
|
||||
t.Fatalf("Scan(%v) = %q, want %q", tt.input, got, tt.want)
|
||||
if string(got) != value.String() {
|
||||
t.Fatalf("MarshalText() = %q, want %q", string(got), value.String())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -29,40 +29,51 @@ const (
|
||||
AccessReviewCampaignStatusCancelled AccessReviewCampaignStatus = "CANCELLED"
|
||||
)
|
||||
|
||||
func (s AccessReviewCampaignStatus) String() string {
|
||||
return string(s)
|
||||
var (
|
||||
_ fmt.Stringer = AccessReviewCampaignStatus("")
|
||||
_ encoding.TextMarshaler = AccessReviewCampaignStatus("")
|
||||
_ encoding.TextUnmarshaler = (*AccessReviewCampaignStatus)(nil)
|
||||
)
|
||||
|
||||
func AccessReviewCampaignStatuses() []AccessReviewCampaignStatus {
|
||||
return []AccessReviewCampaignStatus{
|
||||
AccessReviewCampaignStatusDraft,
|
||||
AccessReviewCampaignStatusInProgress,
|
||||
AccessReviewCampaignStatusPendingActions,
|
||||
AccessReviewCampaignStatusCompleted,
|
||||
AccessReviewCampaignStatusCancelled,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *AccessReviewCampaignStatus) Scan(value any) error {
|
||||
var str string
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
str = v
|
||||
case []byte:
|
||||
str = string(v)
|
||||
default:
|
||||
return fmt.Errorf("cannot scan AccessReviewCampaignStatus: unsupported type %T", value)
|
||||
func (v AccessReviewCampaignStatus) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
AccessReviewCampaignStatusDraft,
|
||||
AccessReviewCampaignStatusInProgress,
|
||||
AccessReviewCampaignStatusPendingActions,
|
||||
AccessReviewCampaignStatusCompleted,
|
||||
AccessReviewCampaignStatusCancelled:
|
||||
return true
|
||||
}
|
||||
|
||||
switch str {
|
||||
case "DRAFT":
|
||||
*s = AccessReviewCampaignStatusDraft
|
||||
case "IN_PROGRESS":
|
||||
*s = AccessReviewCampaignStatusInProgress
|
||||
case "PENDING_ACTIONS":
|
||||
*s = AccessReviewCampaignStatusPendingActions
|
||||
case "COMPLETED":
|
||||
*s = AccessReviewCampaignStatusCompleted
|
||||
case "CANCELLED":
|
||||
*s = AccessReviewCampaignStatusCancelled
|
||||
default:
|
||||
return fmt.Errorf("cannot parse AccessReviewCampaignStatus: invalid value %q", str)
|
||||
return false
|
||||
}
|
||||
|
||||
func (v AccessReviewCampaignStatus) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v AccessReviewCampaignStatus) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *AccessReviewCampaignStatus) UnmarshalText(text []byte) error {
|
||||
val := AccessReviewCampaignStatus(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid AccessReviewCampaignStatus value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s AccessReviewCampaignStatus) Value() (driver.Value, error) {
|
||||
return s.String(), nil
|
||||
}
|
||||
|
||||
@@ -16,74 +16,62 @@ package coredata
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestAccessReviewCampaignStatusScan(t *testing.T) {
|
||||
func TestAccessReviewCampaignStatusIsValid(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
input any
|
||||
want AccessReviewCampaignStatus
|
||||
wantErr bool
|
||||
}{
|
||||
{name: "draft string", input: "DRAFT", want: AccessReviewCampaignStatusDraft},
|
||||
{name: "in_progress string", input: "IN_PROGRESS", want: AccessReviewCampaignStatusInProgress},
|
||||
{name: "pending_actions string", input: "PENDING_ACTIONS", want: AccessReviewCampaignStatusPendingActions},
|
||||
{name: "completed string", input: "COMPLETED", want: AccessReviewCampaignStatusCompleted},
|
||||
{name: "cancelled bytes", input: []byte("CANCELLED"), want: AccessReviewCampaignStatusCancelled},
|
||||
{name: "invalid value", input: "BOGUS", wantErr: true},
|
||||
{name: "unsupported type", input: 42, wantErr: true},
|
||||
for _, value := range AccessReviewCampaignStatuses() {
|
||||
if !value.IsValid() {
|
||||
t.Fatalf("IsValid() = false for %q", value)
|
||||
}
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if AccessReviewCampaignStatus("BOGUS").IsValid() {
|
||||
t.Fatal("IsValid() = true for invalid value")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAccessReviewCampaignStatusUnmarshalText(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, value := range AccessReviewCampaignStatuses() {
|
||||
t.Run(string(value), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var got AccessReviewCampaignStatus
|
||||
|
||||
err := got.Scan(tt.input)
|
||||
if tt.wantErr {
|
||||
if err == nil {
|
||||
t.Fatalf("Scan(%v) expected error", tt.input)
|
||||
}
|
||||
|
||||
return
|
||||
if err := got.UnmarshalText([]byte(value)); err != nil {
|
||||
t.Fatalf("UnmarshalText(%q) returned error: %v", value, err)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("Scan(%v) returned error: %v", tt.input, err)
|
||||
}
|
||||
|
||||
if got != tt.want {
|
||||
t.Fatalf("Scan(%v) = %q, want %q", tt.input, got, tt.want)
|
||||
if got != value {
|
||||
t.Fatalf("UnmarshalText(%q) = %q, want %q", value, got, value)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
t.Run("invalid", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var got AccessReviewCampaignStatus
|
||||
if err := got.UnmarshalText([]byte("BOGUS")); err == nil {
|
||||
t.Fatal("UnmarshalText(BOGUS) expected error")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccessReviewCampaignStatusValue(t *testing.T) {
|
||||
func TestAccessReviewCampaignStatusMarshalText(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
status AccessReviewCampaignStatus
|
||||
want string
|
||||
}{
|
||||
{name: "draft", status: AccessReviewCampaignStatusDraft, want: "DRAFT"},
|
||||
{name: "in_progress", status: AccessReviewCampaignStatusInProgress, want: "IN_PROGRESS"},
|
||||
{name: "completed", status: AccessReviewCampaignStatusCompleted, want: "COMPLETED"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
for _, value := range AccessReviewCampaignStatuses() {
|
||||
t.Run(string(value), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
got, err := tt.status.Value()
|
||||
got, err := value.MarshalText()
|
||||
if err != nil {
|
||||
t.Fatalf("Value() returned error: %v", err)
|
||||
t.Fatalf("MarshalText() returned error: %v", err)
|
||||
}
|
||||
|
||||
if got != tt.want {
|
||||
t.Fatalf("Value() = %q, want %q", got, tt.want)
|
||||
if string(got) != value.String() {
|
||||
t.Fatalf("MarshalText() = %q, want %q", string(got), value.String())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -28,6 +28,12 @@ const (
|
||||
AccessSourceCategoryOther AccessSourceCategory = "OTHER"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = AccessSourceCategory("")
|
||||
_ encoding.TextMarshaler = AccessSourceCategory("")
|
||||
_ encoding.TextUnmarshaler = (*AccessSourceCategory)(nil)
|
||||
)
|
||||
|
||||
func AccessSourceCategories() []AccessSourceCategory {
|
||||
return []AccessSourceCategory{
|
||||
AccessSourceCategorySaaS,
|
||||
@@ -37,38 +43,34 @@ func AccessSourceCategories() []AccessSourceCategory {
|
||||
}
|
||||
}
|
||||
|
||||
func (c AccessSourceCategory) String() string {
|
||||
return string(c)
|
||||
func (v AccessSourceCategory) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
AccessSourceCategorySaaS,
|
||||
AccessSourceCategoryCloudInfra,
|
||||
AccessSourceCategorySourceCode,
|
||||
AccessSourceCategoryOther:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (c *AccessSourceCategory) Scan(value any) error {
|
||||
var str string
|
||||
func (v AccessSourceCategory) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
str = v
|
||||
case []byte:
|
||||
str = string(v)
|
||||
default:
|
||||
return fmt.Errorf("cannot scan AccessSourceCategory: unsupported type %T", value)
|
||||
func (v AccessSourceCategory) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *AccessSourceCategory) UnmarshalText(text []byte) error {
|
||||
val := AccessSourceCategory(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid AccessSourceCategory value: %q", string(text))
|
||||
}
|
||||
|
||||
switch str {
|
||||
case "SAAS":
|
||||
*c = AccessSourceCategorySaaS
|
||||
case "CLOUD_INFRA":
|
||||
*c = AccessSourceCategoryCloudInfra
|
||||
case "SOURCE_CODE":
|
||||
*c = AccessSourceCategorySourceCode
|
||||
case "OTHER":
|
||||
*c = AccessSourceCategoryOther
|
||||
default:
|
||||
return fmt.Errorf("cannot parse AccessSourceCategory: invalid value %q", str)
|
||||
}
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c AccessSourceCategory) Value() (driver.Value, error) {
|
||||
return c.String(), nil
|
||||
}
|
||||
|
||||
@@ -16,58 +16,63 @@ package coredata
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestAccessSourceCategoryScan(t *testing.T) {
|
||||
func TestAccessSourceCategoryIsValid(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
input any
|
||||
want AccessSourceCategory
|
||||
wantErr bool
|
||||
}{
|
||||
{name: "saas string", input: "SAAS", want: AccessSourceCategorySaaS},
|
||||
{name: "cloud_infra string", input: "CLOUD_INFRA", want: AccessSourceCategoryCloudInfra},
|
||||
{name: "source_code bytes", input: []byte("SOURCE_CODE"), want: AccessSourceCategorySourceCode},
|
||||
{name: "other string", input: "OTHER", want: AccessSourceCategoryOther},
|
||||
{name: "invalid value", input: "BOGUS", wantErr: true},
|
||||
{name: "unsupported type", input: 42, wantErr: true},
|
||||
for _, value := range AccessSourceCategories() {
|
||||
if !value.IsValid() {
|
||||
t.Fatalf("IsValid() = false for %q", value)
|
||||
}
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if AccessSourceCategory("BOGUS").IsValid() {
|
||||
t.Fatal("IsValid() = true for invalid value")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAccessSourceCategoryUnmarshalText(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, value := range AccessSourceCategories() {
|
||||
t.Run(string(value), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var got AccessSourceCategory
|
||||
|
||||
err := got.Scan(tt.input)
|
||||
if tt.wantErr {
|
||||
if err == nil {
|
||||
t.Fatalf("Scan(%v) expected error", tt.input)
|
||||
}
|
||||
|
||||
return
|
||||
if err := got.UnmarshalText([]byte(value)); err != nil {
|
||||
t.Fatalf("UnmarshalText(%q) returned error: %v", value, err)
|
||||
}
|
||||
|
||||
if got != value {
|
||||
t.Fatalf("UnmarshalText(%q) = %q, want %q", value, got, value)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
t.Run("invalid", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var got AccessSourceCategory
|
||||
if err := got.UnmarshalText([]byte("BOGUS")); err == nil {
|
||||
t.Fatal("UnmarshalText(BOGUS) expected error")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccessSourceCategoryMarshalText(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, value := range AccessSourceCategories() {
|
||||
t.Run(string(value), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
got, err := value.MarshalText()
|
||||
if err != nil {
|
||||
t.Fatalf("Scan(%v) returned error: %v", tt.input, err)
|
||||
t.Fatalf("MarshalText() returned error: %v", err)
|
||||
}
|
||||
|
||||
if got != tt.want {
|
||||
t.Fatalf("Scan(%v) = %q, want %q", tt.input, got, tt.want)
|
||||
if string(got) != value.String() {
|
||||
t.Fatalf("MarshalText() = %q, want %q", string(got), value.String())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestAccessSourceCategoryValue(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
got, err := AccessSourceCategorySaaS.Value()
|
||||
if err != nil {
|
||||
t.Fatalf("Value() returned error: %v", err)
|
||||
}
|
||||
|
||||
if got != "SAAS" {
|
||||
t.Fatalf("Value() = %q, want %q", got, "SAAS")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,12 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
AccessSourceOrderField string
|
||||
@@ -24,6 +29,48 @@ const (
|
||||
AccessSourceOrderFieldCreatedAt AccessSourceOrderField = "CREATED_AT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = AccessSourceOrderField("")
|
||||
_ fmt.Stringer = AccessSourceOrderField("")
|
||||
_ encoding.TextMarshaler = AccessSourceOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*AccessSourceOrderField)(nil)
|
||||
)
|
||||
|
||||
func AccessSourceOrderFields() []AccessSourceOrderField {
|
||||
return []AccessSourceOrderField{
|
||||
AccessSourceOrderFieldCreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v AccessSourceOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
AccessSourceOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v AccessSourceOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v AccessSourceOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *AccessSourceOrderField) UnmarshalText(text []byte) error {
|
||||
val := AccessSourceOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid AccessSourceOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p AccessSourceOrderField) Column() string {
|
||||
switch p {
|
||||
case AccessSourceOrderFieldCreatedAt:
|
||||
@@ -32,29 +79,3 @@ func (p AccessSourceOrderField) Column() string {
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", p))
|
||||
}
|
||||
|
||||
func (p AccessSourceOrderField) IsValid() bool {
|
||||
switch p {
|
||||
case AccessSourceOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (p AccessSourceOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p AccessSourceOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *AccessSourceOrderField) UnmarshalText(text []byte) error {
|
||||
*p = AccessSourceOrderField(text)
|
||||
if !p.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid AccessSourceOrderField", string(text))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package coredata
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -60,6 +61,57 @@ const (
|
||||
AgentRunStatusFailed AgentRunStatus = "FAILED"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = AgentRunStatus("")
|
||||
_ encoding.TextMarshaler = AgentRunStatus("")
|
||||
_ encoding.TextUnmarshaler = (*AgentRunStatus)(nil)
|
||||
)
|
||||
|
||||
func AgentRunStatuses() []AgentRunStatus {
|
||||
return []AgentRunStatus{
|
||||
AgentRunStatusPending,
|
||||
AgentRunStatusRunning,
|
||||
AgentRunStatusSuspended,
|
||||
AgentRunStatusAwaitingApproval,
|
||||
AgentRunStatusCompleted,
|
||||
AgentRunStatusFailed,
|
||||
}
|
||||
}
|
||||
|
||||
func (v AgentRunStatus) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
AgentRunStatusPending,
|
||||
AgentRunStatusRunning,
|
||||
AgentRunStatusSuspended,
|
||||
AgentRunStatusAwaitingApproval,
|
||||
AgentRunStatusCompleted,
|
||||
AgentRunStatusFailed:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v AgentRunStatus) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v AgentRunStatus) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *AgentRunStatus) UnmarshalText(text []byte) error {
|
||||
val := AgentRunStatus(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid AgentRunStatus value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e AgentRun) CursorKey(orderBy AgentRunOrderField) page.CursorKey {
|
||||
switch orderBy {
|
||||
case AgentRunOrderFieldCreatedAt:
|
||||
|
||||
@@ -14,7 +14,12 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
AgentRunOrderField string
|
||||
@@ -24,6 +29,48 @@ const (
|
||||
AgentRunOrderFieldCreatedAt AgentRunOrderField = "CREATED_AT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = AgentRunOrderField("")
|
||||
_ fmt.Stringer = AgentRunOrderField("")
|
||||
_ encoding.TextMarshaler = AgentRunOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*AgentRunOrderField)(nil)
|
||||
)
|
||||
|
||||
func AgentRunOrderFields() []AgentRunOrderField {
|
||||
return []AgentRunOrderField{
|
||||
AgentRunOrderFieldCreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v AgentRunOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
AgentRunOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v AgentRunOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v AgentRunOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *AgentRunOrderField) UnmarshalText(text []byte) error {
|
||||
val := AgentRunOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid AgentRunOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p AgentRunOrderField) Column() string {
|
||||
switch p {
|
||||
case AgentRunOrderFieldCreatedAt:
|
||||
@@ -32,29 +79,3 @@ func (p AgentRunOrderField) Column() string {
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", p))
|
||||
}
|
||||
|
||||
func (p AgentRunOrderField) IsValid() bool {
|
||||
switch p {
|
||||
case AgentRunOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (p AgentRunOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p *AgentRunOrderField) UnmarshalText(text []byte) error {
|
||||
*p = AgentRunOrderField(text)
|
||||
if !p.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid AgentRunOrderField", string(text))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p AgentRunOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,10 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type ApplicabilityStatementOrderField string
|
||||
@@ -25,6 +28,50 @@ const (
|
||||
ApplicabilityStatementOrderFieldControlSectionTitle ApplicabilityStatementOrderField = "CONTROL_SECTION_TITLE"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = ApplicabilityStatementOrderField("")
|
||||
_ fmt.Stringer = ApplicabilityStatementOrderField("")
|
||||
_ encoding.TextMarshaler = ApplicabilityStatementOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*ApplicabilityStatementOrderField)(nil)
|
||||
)
|
||||
|
||||
func ApplicabilityStatementOrderFields() []ApplicabilityStatementOrderField {
|
||||
return []ApplicabilityStatementOrderField{
|
||||
ApplicabilityStatementOrderFieldCreatedAt,
|
||||
ApplicabilityStatementOrderFieldControlSectionTitle,
|
||||
}
|
||||
}
|
||||
|
||||
func (v ApplicabilityStatementOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
ApplicabilityStatementOrderFieldCreatedAt,
|
||||
ApplicabilityStatementOrderFieldControlSectionTitle:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v ApplicabilityStatementOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v ApplicabilityStatementOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *ApplicabilityStatementOrderField) UnmarshalText(text []byte) error {
|
||||
val := ApplicabilityStatementOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid ApplicabilityStatementOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p ApplicabilityStatementOrderField) Column() string {
|
||||
switch p {
|
||||
case ApplicabilityStatementOrderFieldCreatedAt:
|
||||
@@ -35,23 +82,3 @@ func (p ApplicabilityStatementOrderField) Column() string {
|
||||
|
||||
panic("unknown ApplicabilityStatementOrderField")
|
||||
}
|
||||
|
||||
func (p ApplicabilityStatementOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p ApplicabilityStatementOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *ApplicabilityStatementOrderField) UnmarshalText(text []byte) error {
|
||||
val := string(text)
|
||||
switch val {
|
||||
case string(ApplicabilityStatementOrderFieldCreatedAt),
|
||||
string(ApplicabilityStatementOrderFieldControlSectionTitle):
|
||||
*p = ApplicabilityStatementOrderField(val)
|
||||
return nil
|
||||
}
|
||||
|
||||
return fmt.Errorf("invalid ApplicabilityStatementOrderField value: %q", val)
|
||||
}
|
||||
|
||||
@@ -14,6 +14,13 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type AssetOrderField string
|
||||
|
||||
const (
|
||||
@@ -22,10 +29,52 @@ const (
|
||||
AssetOrderFieldName AssetOrderField = "NAME"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = AssetOrderField("")
|
||||
_ fmt.Stringer = AssetOrderField("")
|
||||
_ encoding.TextMarshaler = AssetOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*AssetOrderField)(nil)
|
||||
)
|
||||
|
||||
func AssetOrderFields() []AssetOrderField {
|
||||
return []AssetOrderField{
|
||||
AssetOrderFieldCreatedAt,
|
||||
AssetOrderFieldAmount,
|
||||
AssetOrderFieldName,
|
||||
}
|
||||
}
|
||||
|
||||
func (v AssetOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
AssetOrderFieldCreatedAt,
|
||||
AssetOrderFieldAmount,
|
||||
AssetOrderFieldName:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v AssetOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v AssetOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *AssetOrderField) UnmarshalText(text []byte) error {
|
||||
val := AssetOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid AssetOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p AssetOrderField) Column() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p AssetOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -28,6 +28,12 @@ const (
|
||||
AssetTypeVirtual AssetType = "VIRTUAL"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = AssetType("")
|
||||
_ encoding.TextMarshaler = AssetType("")
|
||||
_ encoding.TextUnmarshaler = (*AssetType)(nil)
|
||||
)
|
||||
|
||||
func AssetTypes() []AssetType {
|
||||
return []AssetType{
|
||||
AssetTypePhysical,
|
||||
@@ -35,38 +41,32 @@ func AssetTypes() []AssetType {
|
||||
}
|
||||
}
|
||||
|
||||
func (at AssetType) MarshalText() ([]byte, error) {
|
||||
return []byte(at.String()), nil
|
||||
func (v AssetType) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
AssetTypePhysical,
|
||||
AssetTypeVirtual:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (at *AssetType) UnmarshalText(data []byte) error {
|
||||
val := string(data)
|
||||
func (v AssetType) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
switch val {
|
||||
case AssetTypePhysical.String():
|
||||
*at = AssetTypePhysical
|
||||
case AssetTypeVirtual.String():
|
||||
*at = AssetTypeVirtual
|
||||
default:
|
||||
return fmt.Errorf("invalid AssetType value: %q", val)
|
||||
func (v AssetType) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *AssetType) UnmarshalText(text []byte) error {
|
||||
val := AssetType(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid AssetType value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (at AssetType) String() string {
|
||||
return string(at)
|
||||
}
|
||||
|
||||
func (at *AssetType) Scan(value any) error {
|
||||
val, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid scan source for AssetType, expected string got %T", value)
|
||||
}
|
||||
|
||||
return at.UnmarshalText([]byte(val))
|
||||
}
|
||||
|
||||
func (at AssetType) Value() (driver.Value, error) {
|
||||
return at.String(), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -27,47 +27,47 @@ const (
|
||||
AuditLogActorTypeSystem AuditLogActorType = "SYSTEM"
|
||||
)
|
||||
|
||||
func (a AuditLogActorType) String() string {
|
||||
return string(a)
|
||||
var (
|
||||
_ fmt.Stringer = AuditLogActorType("")
|
||||
_ encoding.TextMarshaler = AuditLogActorType("")
|
||||
_ encoding.TextUnmarshaler = (*AuditLogActorType)(nil)
|
||||
)
|
||||
|
||||
func AuditLogActorTypes() []AuditLogActorType {
|
||||
return []AuditLogActorType{
|
||||
AuditLogActorTypeUser,
|
||||
AuditLogActorTypeAPIKey,
|
||||
AuditLogActorTypeSystem,
|
||||
}
|
||||
}
|
||||
|
||||
func (a AuditLogActorType) IsValid() bool {
|
||||
switch a {
|
||||
case AuditLogActorTypeUser, AuditLogActorTypeAPIKey, AuditLogActorTypeSystem:
|
||||
func (v AuditLogActorType) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
AuditLogActorTypeUser,
|
||||
AuditLogActorTypeAPIKey,
|
||||
AuditLogActorTypeSystem:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (a AuditLogActorType) MarshalText() ([]byte, error) {
|
||||
return []byte(a.String()), nil
|
||||
func (v AuditLogActorType) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (a *AuditLogActorType) UnmarshalText(text []byte) error {
|
||||
*a = AuditLogActorType(text)
|
||||
if !a.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid AuditLogActorType", string(text))
|
||||
func (v AuditLogActorType) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *AuditLogActorType) UnmarshalText(text []byte) error {
|
||||
val := AuditLogActorType(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid AuditLogActorType value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *AuditLogActorType) Scan(value any) error {
|
||||
var s string
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
s = v
|
||||
case []byte:
|
||||
s = string(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for AuditLogActorType: %T", value)
|
||||
}
|
||||
|
||||
return a.UnmarshalText([]byte(s))
|
||||
}
|
||||
|
||||
func (a AuditLogActorType) Value() (driver.Value, error) {
|
||||
return a.String(), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,10 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type AuditLogEntryOrderField string
|
||||
@@ -24,6 +27,48 @@ const (
|
||||
AuditLogEntryOrderFieldCreatedAt AuditLogEntryOrderField = "CREATED_AT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = AuditLogEntryOrderField("")
|
||||
_ fmt.Stringer = AuditLogEntryOrderField("")
|
||||
_ encoding.TextMarshaler = AuditLogEntryOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*AuditLogEntryOrderField)(nil)
|
||||
)
|
||||
|
||||
func AuditLogEntryOrderFields() []AuditLogEntryOrderField {
|
||||
return []AuditLogEntryOrderField{
|
||||
AuditLogEntryOrderFieldCreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v AuditLogEntryOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
AuditLogEntryOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v AuditLogEntryOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v AuditLogEntryOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *AuditLogEntryOrderField) UnmarshalText(text []byte) error {
|
||||
val := AuditLogEntryOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid AuditLogEntryOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p AuditLogEntryOrderField) Column() string {
|
||||
switch p {
|
||||
case AuditLogEntryOrderFieldCreatedAt:
|
||||
@@ -32,29 +77,3 @@ func (p AuditLogEntryOrderField) Column() string {
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", p))
|
||||
}
|
||||
|
||||
func (p AuditLogEntryOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p AuditLogEntryOrderField) IsValid() bool {
|
||||
switch p {
|
||||
case AuditLogEntryOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (p AuditLogEntryOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *AuditLogEntryOrderField) UnmarshalText(text []byte) error {
|
||||
*p = AuditLogEntryOrderField(text)
|
||||
if !p.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid AuditLogEntryOrderField", string(text))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,10 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type AuditOrderField string
|
||||
@@ -27,28 +30,54 @@ const (
|
||||
AuditOrderFieldState AuditOrderField = "STATE"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = AuditOrderField("")
|
||||
_ fmt.Stringer = AuditOrderField("")
|
||||
_ encoding.TextMarshaler = AuditOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*AuditOrderField)(nil)
|
||||
)
|
||||
|
||||
func AuditOrderFields() []AuditOrderField {
|
||||
return []AuditOrderField{
|
||||
AuditOrderFieldCreatedAt,
|
||||
AuditOrderFieldValidFrom,
|
||||
AuditOrderFieldValidUntil,
|
||||
AuditOrderFieldState,
|
||||
}
|
||||
}
|
||||
|
||||
func (v AuditOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
AuditOrderFieldCreatedAt,
|
||||
AuditOrderFieldValidFrom,
|
||||
AuditOrderFieldValidUntil,
|
||||
AuditOrderFieldState:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v AuditOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v AuditOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *AuditOrderField) UnmarshalText(text []byte) error {
|
||||
val := AuditOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid AuditOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p AuditOrderField) Column() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p AuditOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p AuditOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *AuditOrderField) UnmarshalText(text []byte) error {
|
||||
val := string(text)
|
||||
switch val {
|
||||
case string(AuditOrderFieldCreatedAt),
|
||||
string(AuditOrderFieldValidFrom),
|
||||
string(AuditOrderFieldValidUntil),
|
||||
string(AuditOrderFieldState):
|
||||
*p = AuditOrderField(val)
|
||||
return nil
|
||||
}
|
||||
|
||||
return fmt.Errorf("invalid AuditOrderField value: %q", val)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -29,6 +29,12 @@ const (
|
||||
AuditStateOutdated AuditState = "OUTDATED"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = AuditState("")
|
||||
_ encoding.TextMarshaler = AuditState("")
|
||||
_ encoding.TextUnmarshaler = (*AuditState)(nil)
|
||||
)
|
||||
|
||||
func AuditStates() []AuditState {
|
||||
return []AuditState{
|
||||
AuditStateNotStarted,
|
||||
@@ -39,40 +45,35 @@ func AuditStates() []AuditState {
|
||||
}
|
||||
}
|
||||
|
||||
func (as AuditState) String() string {
|
||||
return string(as)
|
||||
func (v AuditState) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
AuditStateNotStarted,
|
||||
AuditStateInProgress,
|
||||
AuditStateCompleted,
|
||||
AuditStateRejected,
|
||||
AuditStateOutdated:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (as *AuditState) Scan(value any) error {
|
||||
var s string
|
||||
func (v AuditState) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
s = v
|
||||
case []byte:
|
||||
s = string(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for AuditState: %T", value)
|
||||
func (v AuditState) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *AuditState) UnmarshalText(text []byte) error {
|
||||
val := AuditState(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid AuditState value: %q", string(text))
|
||||
}
|
||||
|
||||
switch s {
|
||||
case "NOT_STARTED":
|
||||
*as = AuditStateNotStarted
|
||||
case "IN_PROGRESS":
|
||||
*as = AuditStateInProgress
|
||||
case "COMPLETED":
|
||||
*as = AuditStateCompleted
|
||||
case "REJECTED":
|
||||
*as = AuditStateRejected
|
||||
case "OUTDATED":
|
||||
*as = AuditStateOutdated
|
||||
default:
|
||||
return fmt.Errorf("invalid AuditState value: %q", s)
|
||||
}
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (as AuditState) Value() (driver.Value, error) {
|
||||
return as.String(), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -29,6 +29,12 @@ const (
|
||||
AccessEntryAuthMethodUnknown AccessEntryAuthMethod = "UNKNOWN"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = AccessEntryAuthMethod("")
|
||||
_ encoding.TextMarshaler = AccessEntryAuthMethod("")
|
||||
_ encoding.TextUnmarshaler = (*AccessEntryAuthMethod)(nil)
|
||||
)
|
||||
|
||||
func AccessEntryAuthMethods() []AccessEntryAuthMethod {
|
||||
return []AccessEntryAuthMethod{
|
||||
AccessEntryAuthMethodSSO,
|
||||
@@ -39,40 +45,35 @@ func AccessEntryAuthMethods() []AccessEntryAuthMethod {
|
||||
}
|
||||
}
|
||||
|
||||
func (a AccessEntryAuthMethod) String() string {
|
||||
return string(a)
|
||||
func (v AccessEntryAuthMethod) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
AccessEntryAuthMethodSSO,
|
||||
AccessEntryAuthMethodPassword,
|
||||
AccessEntryAuthMethodAPIKey,
|
||||
AccessEntryAuthMethodServiceAccount,
|
||||
AccessEntryAuthMethodUnknown:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (a *AccessEntryAuthMethod) Scan(value any) error {
|
||||
var str string
|
||||
func (v AccessEntryAuthMethod) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
str = v
|
||||
case []byte:
|
||||
str = string(v)
|
||||
default:
|
||||
return fmt.Errorf("cannot scan AccessEntryAuthMethod: unsupported type %T", value)
|
||||
func (v AccessEntryAuthMethod) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *AccessEntryAuthMethod) UnmarshalText(text []byte) error {
|
||||
val := AccessEntryAuthMethod(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid AccessEntryAuthMethod value: %q", string(text))
|
||||
}
|
||||
|
||||
switch str {
|
||||
case "SSO":
|
||||
*a = AccessEntryAuthMethodSSO
|
||||
case "PASSWORD":
|
||||
*a = AccessEntryAuthMethodPassword
|
||||
case "API_KEY":
|
||||
*a = AccessEntryAuthMethodAPIKey
|
||||
case "SERVICE_ACCOUNT":
|
||||
*a = AccessEntryAuthMethodServiceAccount
|
||||
case "UNKNOWN":
|
||||
*a = AccessEntryAuthMethodUnknown
|
||||
default:
|
||||
return fmt.Errorf("cannot parse AccessEntryAuthMethod: invalid value %q", str)
|
||||
}
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a AccessEntryAuthMethod) Value() (driver.Value, error) {
|
||||
return a.String(), nil
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -29,6 +28,12 @@ const (
|
||||
BusinessImpactCritical BusinessImpact = "CRITICAL"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = BusinessImpact("")
|
||||
_ encoding.TextMarshaler = BusinessImpact("")
|
||||
_ encoding.TextUnmarshaler = (*BusinessImpact)(nil)
|
||||
)
|
||||
|
||||
func BusinessImpacts() []BusinessImpact {
|
||||
return []BusinessImpact{
|
||||
BusinessImpactLow,
|
||||
@@ -38,76 +43,34 @@ func BusinessImpacts() []BusinessImpact {
|
||||
}
|
||||
}
|
||||
|
||||
func (i BusinessImpact) String() string {
|
||||
return string(i)
|
||||
func (v BusinessImpact) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
BusinessImpactLow,
|
||||
BusinessImpactMedium,
|
||||
BusinessImpactHigh,
|
||||
BusinessImpactCritical:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (i *BusinessImpact) Scan(value any) error {
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
switch v {
|
||||
case "LOW":
|
||||
*i = BusinessImpactLow
|
||||
case "MEDIUM":
|
||||
*i = BusinessImpactMedium
|
||||
case "HIGH":
|
||||
*i = BusinessImpactHigh
|
||||
case "CRITICAL":
|
||||
*i = BusinessImpactCritical
|
||||
default:
|
||||
return fmt.Errorf("invalid BusinessImpact value: %q", v)
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for BusinessImpact: %T", value)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i BusinessImpact) Value() (driver.Value, error) {
|
||||
return i.String(), nil
|
||||
}
|
||||
|
||||
func (i BusinessImpact) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(i.String())
|
||||
}
|
||||
|
||||
func (i *BusinessImpact) UnmarshalJSON(data []byte) error {
|
||||
var s string
|
||||
if err := json.Unmarshal(data, &s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch s {
|
||||
case "LOW":
|
||||
*i = BusinessImpactLow
|
||||
case "MEDIUM":
|
||||
*i = BusinessImpactMedium
|
||||
case "HIGH":
|
||||
*i = BusinessImpactHigh
|
||||
case "CRITICAL":
|
||||
*i = BusinessImpactCritical
|
||||
default:
|
||||
return fmt.Errorf("invalid BusinessImpact value: %q", s)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *BusinessImpact) UnmarshalText(text []byte) error {
|
||||
s := string(text)
|
||||
switch s {
|
||||
case "LOW":
|
||||
*i = BusinessImpactLow
|
||||
case "MEDIUM":
|
||||
*i = BusinessImpactMedium
|
||||
case "HIGH":
|
||||
*i = BusinessImpactHigh
|
||||
case "CRITICAL":
|
||||
*i = BusinessImpactCritical
|
||||
default:
|
||||
return fmt.Errorf("invalid BusinessImpact value: %q", s)
|
||||
func (v BusinessImpact) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v BusinessImpact) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *BusinessImpact) UnmarshalText(text []byte) error {
|
||||
val := BusinessImpact(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid BusinessImpact value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -14,6 +14,13 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
ComplianceExternalURLOrderField string
|
||||
)
|
||||
@@ -23,6 +30,50 @@ const (
|
||||
ComplianceExternalURLOrderFieldRank ComplianceExternalURLOrderField = "RANK"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = ComplianceExternalURLOrderField("")
|
||||
_ fmt.Stringer = ComplianceExternalURLOrderField("")
|
||||
_ encoding.TextMarshaler = ComplianceExternalURLOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*ComplianceExternalURLOrderField)(nil)
|
||||
)
|
||||
|
||||
func ComplianceExternalURLOrderFields() []ComplianceExternalURLOrderField {
|
||||
return []ComplianceExternalURLOrderField{
|
||||
ComplianceExternalURLOrderFieldCreatedAt,
|
||||
ComplianceExternalURLOrderFieldRank,
|
||||
}
|
||||
}
|
||||
|
||||
func (v ComplianceExternalURLOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
ComplianceExternalURLOrderFieldCreatedAt,
|
||||
ComplianceExternalURLOrderFieldRank:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v ComplianceExternalURLOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v ComplianceExternalURLOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *ComplianceExternalURLOrderField) UnmarshalText(text []byte) error {
|
||||
val := ComplianceExternalURLOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid ComplianceExternalURLOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p ComplianceExternalURLOrderField) Column() string {
|
||||
switch p {
|
||||
case ComplianceExternalURLOrderFieldCreatedAt:
|
||||
@@ -33,16 +84,3 @@ func (p ComplianceExternalURLOrderField) Column() string {
|
||||
return string(p)
|
||||
}
|
||||
}
|
||||
|
||||
func (p ComplianceExternalURLOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p ComplianceExternalURLOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *ComplianceExternalURLOrderField) UnmarshalText(text []byte) error {
|
||||
*p = ComplianceExternalURLOrderField(text)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -14,6 +14,13 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
ComplianceFrameworkOrderField string
|
||||
)
|
||||
@@ -23,6 +30,50 @@ const (
|
||||
ComplianceFrameworkOrderFieldRank ComplianceFrameworkOrderField = "RANK"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = ComplianceFrameworkOrderField("")
|
||||
_ fmt.Stringer = ComplianceFrameworkOrderField("")
|
||||
_ encoding.TextMarshaler = ComplianceFrameworkOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*ComplianceFrameworkOrderField)(nil)
|
||||
)
|
||||
|
||||
func ComplianceFrameworkOrderFields() []ComplianceFrameworkOrderField {
|
||||
return []ComplianceFrameworkOrderField{
|
||||
ComplianceFrameworkOrderFieldCreatedAt,
|
||||
ComplianceFrameworkOrderFieldRank,
|
||||
}
|
||||
}
|
||||
|
||||
func (v ComplianceFrameworkOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
ComplianceFrameworkOrderFieldCreatedAt,
|
||||
ComplianceFrameworkOrderFieldRank:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v ComplianceFrameworkOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v ComplianceFrameworkOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *ComplianceFrameworkOrderField) UnmarshalText(text []byte) error {
|
||||
val := ComplianceFrameworkOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid ComplianceFrameworkOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p ComplianceFrameworkOrderField) Column() string {
|
||||
switch p {
|
||||
case ComplianceFrameworkOrderFieldCreatedAt:
|
||||
@@ -33,16 +84,3 @@ func (p ComplianceFrameworkOrderField) Column() string {
|
||||
return string(p)
|
||||
}
|
||||
}
|
||||
|
||||
func (p ComplianceFrameworkOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p ComplianceFrameworkOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *ComplianceFrameworkOrderField) UnmarshalText(text []byte) error {
|
||||
*p = ComplianceFrameworkOrderField(text)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -14,6 +14,11 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ComplianceFrameworkVisibility string
|
||||
|
||||
const (
|
||||
@@ -21,6 +26,45 @@ const (
|
||||
ComplianceFrameworkVisibilityPublic ComplianceFrameworkVisibility = "PUBLIC"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = ComplianceFrameworkVisibility("")
|
||||
_ encoding.TextMarshaler = ComplianceFrameworkVisibility("")
|
||||
_ encoding.TextUnmarshaler = (*ComplianceFrameworkVisibility)(nil)
|
||||
)
|
||||
|
||||
func ComplianceFrameworkVisibilities() []ComplianceFrameworkVisibility {
|
||||
return []ComplianceFrameworkVisibility{
|
||||
ComplianceFrameworkVisibilityNone,
|
||||
ComplianceFrameworkVisibilityPublic,
|
||||
}
|
||||
}
|
||||
|
||||
func (v ComplianceFrameworkVisibility) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
ComplianceFrameworkVisibilityNone,
|
||||
ComplianceFrameworkVisibilityPublic:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v ComplianceFrameworkVisibility) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v ComplianceFrameworkVisibility) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *ComplianceFrameworkVisibility) UnmarshalText(text []byte) error {
|
||||
val := ComplianceFrameworkVisibility(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid ComplianceFrameworkVisibility value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -14,6 +14,13 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
ConnectorOrderField string
|
||||
)
|
||||
@@ -23,19 +30,50 @@ const (
|
||||
ConnectorOrderFieldProvider ConnectorOrderField = "PROVIDER"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = ConnectorOrderField("")
|
||||
_ fmt.Stringer = ConnectorOrderField("")
|
||||
_ encoding.TextMarshaler = ConnectorOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*ConnectorOrderField)(nil)
|
||||
)
|
||||
|
||||
func ConnectorOrderFields() []ConnectorOrderField {
|
||||
return []ConnectorOrderField{
|
||||
ConnectorOrderFieldCreatedAt,
|
||||
ConnectorOrderFieldProvider,
|
||||
}
|
||||
}
|
||||
|
||||
func (v ConnectorOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
ConnectorOrderFieldCreatedAt,
|
||||
ConnectorOrderFieldProvider:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v ConnectorOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v ConnectorOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *ConnectorOrderField) UnmarshalText(text []byte) error {
|
||||
val := ConnectorOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid ConnectorOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p ConnectorOrderField) Column() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p ConnectorOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p ConnectorOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *ConnectorOrderField) UnmarshalText(text []byte) error {
|
||||
*p = ConnectorOrderField(text)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -26,6 +26,12 @@ const (
|
||||
ConnectorProtocolAPIKey ConnectorProtocol = "API_KEY"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = ConnectorProtocol("")
|
||||
_ encoding.TextMarshaler = ConnectorProtocol("")
|
||||
_ encoding.TextUnmarshaler = (*ConnectorProtocol)(nil)
|
||||
)
|
||||
|
||||
func ConnectorProtocols() []ConnectorProtocol {
|
||||
return []ConnectorProtocol{
|
||||
ConnectorProtocolOAuth2,
|
||||
@@ -33,34 +39,32 @@ func ConnectorProtocols() []ConnectorProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func (cp ConnectorProtocol) String() string {
|
||||
return string(cp)
|
||||
func (v ConnectorProtocol) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
ConnectorProtocolOAuth2,
|
||||
ConnectorProtocolAPIKey:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (cp *ConnectorProtocol) Scan(value any) error {
|
||||
var s string
|
||||
func (v ConnectorProtocol) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
s = v
|
||||
case []byte:
|
||||
s = string(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for ConnectorProtocol: %T", value)
|
||||
func (v ConnectorProtocol) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *ConnectorProtocol) UnmarshalText(text []byte) error {
|
||||
val := ConnectorProtocol(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid ConnectorProtocol value: %q", string(text))
|
||||
}
|
||||
|
||||
switch s {
|
||||
case "OAUTH2":
|
||||
*cp = ConnectorProtocolOAuth2
|
||||
case "API_KEY":
|
||||
*cp = ConnectorProtocolAPIKey
|
||||
default:
|
||||
return fmt.Errorf("invalid ConnectorProtocol value: %q", s)
|
||||
}
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cp ConnectorProtocol) Value() (driver.Value, error) {
|
||||
return cp.String(), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -51,6 +51,12 @@ const (
|
||||
ConnectorProviderMonday ConnectorProvider = "MONDAY"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = ConnectorProvider("")
|
||||
_ encoding.TextMarshaler = ConnectorProvider("")
|
||||
_ encoding.TextUnmarshaler = (*ConnectorProvider)(nil)
|
||||
)
|
||||
|
||||
func ConnectorProviders() []ConnectorProvider {
|
||||
return []ConnectorProvider{
|
||||
ConnectorProviderSlack,
|
||||
@@ -82,82 +88,56 @@ func ConnectorProviders() []ConnectorProvider {
|
||||
}
|
||||
}
|
||||
|
||||
func (cp ConnectorProvider) String() string {
|
||||
return string(cp)
|
||||
func (v ConnectorProvider) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
ConnectorProviderSlack,
|
||||
ConnectorProviderGoogleWorkspace,
|
||||
ConnectorProviderLinear,
|
||||
ConnectorProviderOnePassword,
|
||||
ConnectorProviderHubSpot,
|
||||
ConnectorProviderDocuSign,
|
||||
ConnectorProviderNotion,
|
||||
ConnectorProviderBrex,
|
||||
ConnectorProviderTally,
|
||||
ConnectorProviderCloudflare,
|
||||
ConnectorProviderOpenAI,
|
||||
ConnectorProviderSentry,
|
||||
ConnectorProviderSupabase,
|
||||
ConnectorProviderGitHub,
|
||||
ConnectorProviderIntercom,
|
||||
ConnectorProviderResend,
|
||||
ConnectorProviderMicrosoft365,
|
||||
ConnectorProviderGitLab,
|
||||
ConnectorProviderBitbucket,
|
||||
ConnectorProviderHeroku,
|
||||
ConnectorProviderPagerDuty,
|
||||
ConnectorProviderAsana,
|
||||
ConnectorProviderNetlify,
|
||||
ConnectorProviderClickUp,
|
||||
ConnectorProviderVercel,
|
||||
ConnectorProviderMonday:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (cp *ConnectorProvider) Scan(value any) error {
|
||||
var s string
|
||||
func (v ConnectorProvider) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
s = v
|
||||
case []byte:
|
||||
s = string(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for ConnectorProvider: %T", value)
|
||||
func (v ConnectorProvider) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *ConnectorProvider) UnmarshalText(text []byte) error {
|
||||
val := ConnectorProvider(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid ConnectorProvider value: %q", string(text))
|
||||
}
|
||||
|
||||
switch s {
|
||||
case "SLACK":
|
||||
*cp = ConnectorProviderSlack
|
||||
case "GOOGLE_WORKSPACE":
|
||||
*cp = ConnectorProviderGoogleWorkspace
|
||||
case "LINEAR":
|
||||
*cp = ConnectorProviderLinear
|
||||
case "ONE_PASSWORD":
|
||||
*cp = ConnectorProviderOnePassword
|
||||
case "HUBSPOT":
|
||||
*cp = ConnectorProviderHubSpot
|
||||
case "DOCUSIGN":
|
||||
*cp = ConnectorProviderDocuSign
|
||||
case "NOTION":
|
||||
*cp = ConnectorProviderNotion
|
||||
case "BREX":
|
||||
*cp = ConnectorProviderBrex
|
||||
case "TALLY":
|
||||
*cp = ConnectorProviderTally
|
||||
case "CLOUDFLARE":
|
||||
*cp = ConnectorProviderCloudflare
|
||||
case "OPENAI":
|
||||
*cp = ConnectorProviderOpenAI
|
||||
case "SENTRY":
|
||||
*cp = ConnectorProviderSentry
|
||||
case "SUPABASE":
|
||||
*cp = ConnectorProviderSupabase
|
||||
case "GITHUB":
|
||||
*cp = ConnectorProviderGitHub
|
||||
case "INTERCOM":
|
||||
*cp = ConnectorProviderIntercom
|
||||
case "RESEND":
|
||||
*cp = ConnectorProviderResend
|
||||
case "MICROSOFT_365":
|
||||
*cp = ConnectorProviderMicrosoft365
|
||||
case "GITLAB":
|
||||
*cp = ConnectorProviderGitLab
|
||||
case "BITBUCKET":
|
||||
*cp = ConnectorProviderBitbucket
|
||||
case "HEROKU":
|
||||
*cp = ConnectorProviderHeroku
|
||||
case "PAGERDUTY":
|
||||
*cp = ConnectorProviderPagerDuty
|
||||
case "ASANA":
|
||||
*cp = ConnectorProviderAsana
|
||||
case "NETLIFY":
|
||||
*cp = ConnectorProviderNetlify
|
||||
case "CLICKUP":
|
||||
*cp = ConnectorProviderClickUp
|
||||
case "VERCEL":
|
||||
*cp = ConnectorProviderVercel
|
||||
case "MONDAY":
|
||||
*cp = ConnectorProviderMonday
|
||||
default:
|
||||
return fmt.Errorf("invalid ConnectorProvider value: %q", s)
|
||||
}
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cp ConnectorProvider) Value() (driver.Value, error) {
|
||||
return cp.String(), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -32,6 +32,12 @@ const (
|
||||
ControlMaturityLevelOptimizing ControlMaturityLevel = "OPTIMIZING"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = ControlMaturityLevel("")
|
||||
_ encoding.TextMarshaler = ControlMaturityLevel("")
|
||||
_ encoding.TextUnmarshaler = (*ControlMaturityLevel)(nil)
|
||||
)
|
||||
|
||||
func ControlMaturityLevels() []ControlMaturityLevel {
|
||||
return []ControlMaturityLevel{
|
||||
ControlMaturityLevelNone,
|
||||
@@ -43,9 +49,10 @@ func ControlMaturityLevels() []ControlMaturityLevel {
|
||||
}
|
||||
}
|
||||
|
||||
func (l ControlMaturityLevel) IsValid() bool {
|
||||
switch l {
|
||||
case ControlMaturityLevelNone,
|
||||
func (v ControlMaturityLevel) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
ControlMaturityLevelNone,
|
||||
ControlMaturityLevelInitial,
|
||||
ControlMaturityLevelManaged,
|
||||
ControlMaturityLevelDefined,
|
||||
@@ -57,34 +64,21 @@ func (l ControlMaturityLevel) IsValid() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (l ControlMaturityLevel) String() string {
|
||||
return string(l)
|
||||
func (v ControlMaturityLevel) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (l ControlMaturityLevel) MarshalText() ([]byte, error) {
|
||||
return []byte(l.String()), nil
|
||||
func (v ControlMaturityLevel) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (l *ControlMaturityLevel) UnmarshalText(data []byte) error {
|
||||
val := ControlMaturityLevel(data)
|
||||
func (v *ControlMaturityLevel) UnmarshalText(text []byte) error {
|
||||
val := ControlMaturityLevel(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid ControlMaturityLevel value: %q", string(data))
|
||||
return fmt.Errorf("invalid ControlMaturityLevel value: %q", string(text))
|
||||
}
|
||||
|
||||
*l = val
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *ControlMaturityLevel) Scan(value any) error {
|
||||
val, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid scan source for ControlMaturityLevel, expected string got %T", value)
|
||||
}
|
||||
|
||||
return l.UnmarshalText([]byte(val))
|
||||
}
|
||||
|
||||
func (l ControlMaturityLevel) Value() (driver.Value, error) {
|
||||
return l.String(), nil
|
||||
}
|
||||
|
||||
@@ -45,83 +45,6 @@ func TestControlMaturityLevelIsValid(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestControlMaturityLevelScan(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
input any
|
||||
want ControlMaturityLevel
|
||||
wantErr bool
|
||||
}{
|
||||
{name: "none string", input: "NONE", want: ControlMaturityLevelNone},
|
||||
{name: "initial string", input: "INITIAL", want: ControlMaturityLevelInitial},
|
||||
{name: "managed string", input: "MANAGED", want: ControlMaturityLevelManaged},
|
||||
{name: "defined string", input: "DEFINED", want: ControlMaturityLevelDefined},
|
||||
{name: "quantitatively managed string", input: "QUANTITATIVELY_MANAGED", want: ControlMaturityLevelQuantitativelyManaged},
|
||||
{name: "optimizing string", input: "OPTIMIZING", want: ControlMaturityLevelOptimizing},
|
||||
{name: "invalid value", input: "BOGUS", wantErr: true},
|
||||
{name: "unsupported type", input: 42, wantErr: true},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var got ControlMaturityLevel
|
||||
|
||||
err := got.Scan(tt.input)
|
||||
if tt.wantErr {
|
||||
if err == nil {
|
||||
t.Fatalf("Scan(%v) expected error", tt.input)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("Scan(%v) returned error: %v", tt.input, err)
|
||||
}
|
||||
|
||||
if got != tt.want {
|
||||
t.Fatalf("Scan(%v) = %q, want %q", tt.input, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestControlMaturityLevelValue(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
level ControlMaturityLevel
|
||||
want string
|
||||
}{
|
||||
{name: "none", level: ControlMaturityLevelNone, want: "NONE"},
|
||||
{name: "initial", level: ControlMaturityLevelInitial, want: "INITIAL"},
|
||||
{name: "managed", level: ControlMaturityLevelManaged, want: "MANAGED"},
|
||||
{name: "defined", level: ControlMaturityLevelDefined, want: "DEFINED"},
|
||||
{name: "quantitatively managed", level: ControlMaturityLevelQuantitativelyManaged, want: "QUANTITATIVELY_MANAGED"},
|
||||
{name: "optimizing", level: ControlMaturityLevelOptimizing, want: "OPTIMIZING"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
got, err := tt.level.Value()
|
||||
if err != nil {
|
||||
t.Fatalf("Value() returned error: %v", err)
|
||||
}
|
||||
|
||||
if got != tt.want {
|
||||
t.Fatalf("Value() = %q, want %q", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestControlMaturityLevelMarshalUnmarshalText(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -14,6 +14,13 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
ControlOrderField string
|
||||
)
|
||||
@@ -23,6 +30,50 @@ const (
|
||||
ControlOrderFieldSectionTitle ControlOrderField = "SECTION_TITLE"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = ControlOrderField("")
|
||||
_ fmt.Stringer = ControlOrderField("")
|
||||
_ encoding.TextMarshaler = ControlOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*ControlOrderField)(nil)
|
||||
)
|
||||
|
||||
func ControlOrderFields() []ControlOrderField {
|
||||
return []ControlOrderField{
|
||||
ControlOrderFieldCreatedAt,
|
||||
ControlOrderFieldSectionTitle,
|
||||
}
|
||||
}
|
||||
|
||||
func (v ControlOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
ControlOrderFieldCreatedAt,
|
||||
ControlOrderFieldSectionTitle:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v ControlOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v ControlOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *ControlOrderField) UnmarshalText(text []byte) error {
|
||||
val := ControlOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid ControlOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p ControlOrderField) Column() string {
|
||||
switch p {
|
||||
case ControlOrderFieldCreatedAt:
|
||||
@@ -33,16 +84,3 @@ func (p ControlOrderField) Column() string {
|
||||
return string(p)
|
||||
}
|
||||
}
|
||||
|
||||
func (p ControlOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p ControlOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *ControlOrderField) UnmarshalText(text []byte) error {
|
||||
*p = ControlOrderField(text)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -14,7 +14,12 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type CookieBannerOrderField string
|
||||
|
||||
@@ -22,6 +27,48 @@ const (
|
||||
CookieBannerOrderFieldCreatedAt CookieBannerOrderField = "CREATED_AT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = CookieBannerOrderField("")
|
||||
_ fmt.Stringer = CookieBannerOrderField("")
|
||||
_ encoding.TextMarshaler = CookieBannerOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*CookieBannerOrderField)(nil)
|
||||
)
|
||||
|
||||
func CookieBannerOrderFields() []CookieBannerOrderField {
|
||||
return []CookieBannerOrderField{
|
||||
CookieBannerOrderFieldCreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v CookieBannerOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
CookieBannerOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v CookieBannerOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v CookieBannerOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *CookieBannerOrderField) UnmarshalText(text []byte) error {
|
||||
val := CookieBannerOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid CookieBannerOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p CookieBannerOrderField) Column() string {
|
||||
switch p {
|
||||
case CookieBannerOrderFieldCreatedAt:
|
||||
@@ -30,29 +77,3 @@ func (p CookieBannerOrderField) Column() string {
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", p))
|
||||
}
|
||||
|
||||
func (p CookieBannerOrderField) IsValid() bool {
|
||||
switch p {
|
||||
case CookieBannerOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (p CookieBannerOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p *CookieBannerOrderField) UnmarshalText(text []byte) error {
|
||||
*p = CookieBannerOrderField(text)
|
||||
if !p.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid CookieBannerOrderField", string(text))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p CookieBannerOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -26,6 +26,12 @@ const (
|
||||
CookieBannerStateInactive CookieBannerState = "INACTIVE"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = CookieBannerState("")
|
||||
_ encoding.TextMarshaler = CookieBannerState("")
|
||||
_ encoding.TextUnmarshaler = (*CookieBannerState)(nil)
|
||||
)
|
||||
|
||||
func CookieBannerStates() []CookieBannerState {
|
||||
return []CookieBannerState{
|
||||
CookieBannerStateActive,
|
||||
@@ -33,40 +39,32 @@ func CookieBannerStates() []CookieBannerState {
|
||||
}
|
||||
}
|
||||
|
||||
func (s CookieBannerState) String() string {
|
||||
return string(s)
|
||||
func (v CookieBannerState) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
CookieBannerStateActive,
|
||||
CookieBannerStateInactive:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *CookieBannerState) Scan(value any) error {
|
||||
var v string
|
||||
func (v CookieBannerState) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
switch val := value.(type) {
|
||||
case string:
|
||||
v = val
|
||||
case []byte:
|
||||
v = string(val)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for CookieBannerState: %T", value)
|
||||
func (v CookieBannerState) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *CookieBannerState) UnmarshalText(text []byte) error {
|
||||
val := CookieBannerState(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid CookieBannerState value: %q", string(text))
|
||||
}
|
||||
|
||||
switch CookieBannerState(v) {
|
||||
case CookieBannerStateActive:
|
||||
*s = CookieBannerStateActive
|
||||
case CookieBannerStateInactive:
|
||||
*s = CookieBannerStateInactive
|
||||
default:
|
||||
return fmt.Errorf("invalid CookieBannerState value: %q", v)
|
||||
}
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s CookieBannerState) Value() (driver.Value, error) {
|
||||
switch s {
|
||||
case CookieBannerStateActive,
|
||||
CookieBannerStateInactive:
|
||||
return string(s), nil
|
||||
default:
|
||||
return nil, fmt.Errorf("invalid CookieBannerState: %s", s)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,12 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type CookieBannerVersionOrderField string
|
||||
|
||||
@@ -22,6 +27,48 @@ const (
|
||||
CookieBannerVersionOrderFieldCreatedAt CookieBannerVersionOrderField = "CREATED_AT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = CookieBannerVersionOrderField("")
|
||||
_ fmt.Stringer = CookieBannerVersionOrderField("")
|
||||
_ encoding.TextMarshaler = CookieBannerVersionOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*CookieBannerVersionOrderField)(nil)
|
||||
)
|
||||
|
||||
func CookieBannerVersionOrderFields() []CookieBannerVersionOrderField {
|
||||
return []CookieBannerVersionOrderField{
|
||||
CookieBannerVersionOrderFieldCreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v CookieBannerVersionOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
CookieBannerVersionOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v CookieBannerVersionOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v CookieBannerVersionOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *CookieBannerVersionOrderField) UnmarshalText(text []byte) error {
|
||||
val := CookieBannerVersionOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid CookieBannerVersionOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p CookieBannerVersionOrderField) Column() string {
|
||||
switch p {
|
||||
case CookieBannerVersionOrderFieldCreatedAt:
|
||||
@@ -30,29 +77,3 @@ func (p CookieBannerVersionOrderField) Column() string {
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", p))
|
||||
}
|
||||
|
||||
func (p CookieBannerVersionOrderField) IsValid() bool {
|
||||
switch p {
|
||||
case CookieBannerVersionOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (p CookieBannerVersionOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p *CookieBannerVersionOrderField) UnmarshalText(text []byte) error {
|
||||
*p = CookieBannerVersionOrderField(text)
|
||||
if !p.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid CookieBannerVersionOrderField", string(text))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p CookieBannerVersionOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -26,6 +26,12 @@ const (
|
||||
CookieBannerVersionStatePublished CookieBannerVersionState = "PUBLISHED"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = CookieBannerVersionState("")
|
||||
_ encoding.TextMarshaler = CookieBannerVersionState("")
|
||||
_ encoding.TextUnmarshaler = (*CookieBannerVersionState)(nil)
|
||||
)
|
||||
|
||||
func CookieBannerVersionStates() []CookieBannerVersionState {
|
||||
return []CookieBannerVersionState{
|
||||
CookieBannerVersionStateDraft,
|
||||
@@ -33,40 +39,32 @@ func CookieBannerVersionStates() []CookieBannerVersionState {
|
||||
}
|
||||
}
|
||||
|
||||
func (s CookieBannerVersionState) String() string {
|
||||
return string(s)
|
||||
func (v CookieBannerVersionState) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
CookieBannerVersionStateDraft,
|
||||
CookieBannerVersionStatePublished:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *CookieBannerVersionState) Scan(value any) error {
|
||||
var v string
|
||||
func (v CookieBannerVersionState) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
switch val := value.(type) {
|
||||
case string:
|
||||
v = val
|
||||
case []byte:
|
||||
v = string(val)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for CookieBannerVersionState: %T", value)
|
||||
func (v CookieBannerVersionState) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *CookieBannerVersionState) UnmarshalText(text []byte) error {
|
||||
val := CookieBannerVersionState(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid CookieBannerVersionState value: %q", string(text))
|
||||
}
|
||||
|
||||
switch CookieBannerVersionState(v) {
|
||||
case CookieBannerVersionStateDraft:
|
||||
*s = CookieBannerVersionStateDraft
|
||||
case CookieBannerVersionStatePublished:
|
||||
*s = CookieBannerVersionStatePublished
|
||||
default:
|
||||
return fmt.Errorf("invalid CookieBannerVersionState value: %q", v)
|
||||
}
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s CookieBannerVersionState) Value() (driver.Value, error) {
|
||||
switch s {
|
||||
case CookieBannerVersionStateDraft,
|
||||
CookieBannerVersionStatePublished:
|
||||
return string(s), nil
|
||||
default:
|
||||
return nil, fmt.Errorf("invalid CookieBannerVersionState: %s", s)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,11 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type CookieCategoryKind string
|
||||
|
||||
const (
|
||||
@@ -22,6 +27,51 @@ const (
|
||||
CookieCategoryKindUncategorised CookieCategoryKind = "UNCATEGORISED"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = CookieCategoryKind("")
|
||||
_ encoding.TextMarshaler = CookieCategoryKind("")
|
||||
_ encoding.TextUnmarshaler = (*CookieCategoryKind)(nil)
|
||||
)
|
||||
|
||||
func CookieCategoryKinds() []CookieCategoryKind {
|
||||
return []CookieCategoryKind{
|
||||
CookieCategoryKindNormal,
|
||||
CookieCategoryKindNecessary,
|
||||
CookieCategoryKindUncategorised,
|
||||
}
|
||||
}
|
||||
|
||||
func (v CookieCategoryKind) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
CookieCategoryKindNormal,
|
||||
CookieCategoryKindNecessary,
|
||||
CookieCategoryKindUncategorised:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v CookieCategoryKind) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v CookieCategoryKind) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *CookieCategoryKind) UnmarshalText(text []byte) error {
|
||||
val := CookieCategoryKind(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid CookieCategoryKind value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (k CookieCategoryKind) IsRequired() bool {
|
||||
return k == CookieCategoryKindNecessary
|
||||
}
|
||||
|
||||
@@ -14,7 +14,12 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type CookieCategoryOrderField string
|
||||
|
||||
@@ -22,6 +27,48 @@ const (
|
||||
CookieCategoryOrderFieldRank CookieCategoryOrderField = "RANK"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = CookieCategoryOrderField("")
|
||||
_ fmt.Stringer = CookieCategoryOrderField("")
|
||||
_ encoding.TextMarshaler = CookieCategoryOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*CookieCategoryOrderField)(nil)
|
||||
)
|
||||
|
||||
func CookieCategoryOrderFields() []CookieCategoryOrderField {
|
||||
return []CookieCategoryOrderField{
|
||||
CookieCategoryOrderFieldRank,
|
||||
}
|
||||
}
|
||||
|
||||
func (v CookieCategoryOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
CookieCategoryOrderFieldRank:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v CookieCategoryOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v CookieCategoryOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *CookieCategoryOrderField) UnmarshalText(text []byte) error {
|
||||
val := CookieCategoryOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid CookieCategoryOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p CookieCategoryOrderField) Column() string {
|
||||
switch p {
|
||||
case CookieCategoryOrderFieldRank:
|
||||
@@ -30,29 +77,3 @@ func (p CookieCategoryOrderField) Column() string {
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", p))
|
||||
}
|
||||
|
||||
func (p CookieCategoryOrderField) IsValid() bool {
|
||||
switch p {
|
||||
case CookieCategoryOrderFieldRank:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (p CookieCategoryOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p *CookieCategoryOrderField) UnmarshalText(text []byte) error {
|
||||
*p = CookieCategoryOrderField(text)
|
||||
if !p.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid CookieCategoryOrderField", string(text))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p CookieCategoryOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -29,6 +29,12 @@ const (
|
||||
CookieConsentActionGPC CookieConsentAction = "GPC"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = CookieConsentAction("")
|
||||
_ encoding.TextMarshaler = CookieConsentAction("")
|
||||
_ encoding.TextUnmarshaler = (*CookieConsentAction)(nil)
|
||||
)
|
||||
|
||||
func CookieConsentActions() []CookieConsentAction {
|
||||
return []CookieConsentAction{
|
||||
CookieConsentActionAcceptAll,
|
||||
@@ -38,46 +44,34 @@ func CookieConsentActions() []CookieConsentAction {
|
||||
}
|
||||
}
|
||||
|
||||
func (a CookieConsentAction) String() string {
|
||||
return string(a)
|
||||
}
|
||||
|
||||
func (a *CookieConsentAction) Scan(value any) error {
|
||||
var v string
|
||||
|
||||
switch val := value.(type) {
|
||||
case string:
|
||||
v = val
|
||||
case []byte:
|
||||
v = string(val)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for CookieConsentAction: %T", value)
|
||||
}
|
||||
|
||||
switch CookieConsentAction(v) {
|
||||
case CookieConsentActionAcceptAll:
|
||||
*a = CookieConsentActionAcceptAll
|
||||
case CookieConsentActionRejectAll:
|
||||
*a = CookieConsentActionRejectAll
|
||||
case CookieConsentActionCustomize:
|
||||
*a = CookieConsentActionCustomize
|
||||
case CookieConsentActionGPC:
|
||||
*a = CookieConsentActionGPC
|
||||
default:
|
||||
return fmt.Errorf("invalid CookieConsentAction value: %q", v)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a CookieConsentAction) Value() (driver.Value, error) {
|
||||
switch a {
|
||||
case CookieConsentActionAcceptAll,
|
||||
func (v CookieConsentAction) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
CookieConsentActionAcceptAll,
|
||||
CookieConsentActionRejectAll,
|
||||
CookieConsentActionCustomize,
|
||||
CookieConsentActionGPC:
|
||||
return string(a), nil
|
||||
default:
|
||||
return nil, fmt.Errorf("invalid CookieConsentAction: %s", a)
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v CookieConsentAction) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v CookieConsentAction) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *CookieConsentAction) UnmarshalText(text []byte) error {
|
||||
val := CookieConsentAction(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid CookieConsentAction value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -26,6 +26,12 @@ const (
|
||||
CookieConsentModeOptOut CookieConsentMode = "OPT_OUT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = CookieConsentMode("")
|
||||
_ encoding.TextMarshaler = CookieConsentMode("")
|
||||
_ encoding.TextUnmarshaler = (*CookieConsentMode)(nil)
|
||||
)
|
||||
|
||||
func CookieConsentModes() []CookieConsentMode {
|
||||
return []CookieConsentMode{
|
||||
CookieConsentModeOptIn,
|
||||
@@ -33,40 +39,32 @@ func CookieConsentModes() []CookieConsentMode {
|
||||
}
|
||||
}
|
||||
|
||||
func (m CookieConsentMode) String() string {
|
||||
return string(m)
|
||||
func (v CookieConsentMode) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
CookieConsentModeOptIn,
|
||||
CookieConsentModeOptOut:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *CookieConsentMode) Scan(value any) error {
|
||||
var v string
|
||||
func (v CookieConsentMode) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
switch val := value.(type) {
|
||||
case string:
|
||||
v = val
|
||||
case []byte:
|
||||
v = string(val)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for CookieConsentMode: %T", value)
|
||||
func (v CookieConsentMode) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *CookieConsentMode) UnmarshalText(text []byte) error {
|
||||
val := CookieConsentMode(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid CookieConsentMode value: %q", string(text))
|
||||
}
|
||||
|
||||
switch CookieConsentMode(v) {
|
||||
case CookieConsentModeOptIn:
|
||||
*m = CookieConsentModeOptIn
|
||||
case CookieConsentModeOptOut:
|
||||
*m = CookieConsentModeOptOut
|
||||
default:
|
||||
return fmt.Errorf("invalid CookieConsentMode value: %q", v)
|
||||
}
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m CookieConsentMode) Value() (driver.Value, error) {
|
||||
switch m {
|
||||
case CookieConsentModeOptIn,
|
||||
CookieConsentModeOptOut:
|
||||
return string(m), nil
|
||||
default:
|
||||
return nil, fmt.Errorf("invalid CookieConsentMode: %s", m)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,12 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type CookieConsentRecordOrderField string
|
||||
|
||||
@@ -22,6 +27,48 @@ const (
|
||||
CookieConsentRecordOrderFieldCreatedAt CookieConsentRecordOrderField = "CREATED_AT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = CookieConsentRecordOrderField("")
|
||||
_ fmt.Stringer = CookieConsentRecordOrderField("")
|
||||
_ encoding.TextMarshaler = CookieConsentRecordOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*CookieConsentRecordOrderField)(nil)
|
||||
)
|
||||
|
||||
func CookieConsentRecordOrderFields() []CookieConsentRecordOrderField {
|
||||
return []CookieConsentRecordOrderField{
|
||||
CookieConsentRecordOrderFieldCreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v CookieConsentRecordOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
CookieConsentRecordOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v CookieConsentRecordOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v CookieConsentRecordOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *CookieConsentRecordOrderField) UnmarshalText(text []byte) error {
|
||||
val := CookieConsentRecordOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid CookieConsentRecordOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p CookieConsentRecordOrderField) Column() string {
|
||||
switch p {
|
||||
case CookieConsentRecordOrderFieldCreatedAt:
|
||||
@@ -30,29 +77,3 @@ func (p CookieConsentRecordOrderField) Column() string {
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", p))
|
||||
}
|
||||
|
||||
func (p CookieConsentRecordOrderField) IsValid() bool {
|
||||
switch p {
|
||||
case CookieConsentRecordOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (p CookieConsentRecordOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p *CookieConsentRecordOrderField) UnmarshalText(text []byte) error {
|
||||
*p = CookieConsentRecordOrderField(text)
|
||||
if !p.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid CookieConsentRecordOrderField", string(text))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p CookieConsentRecordOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -27,6 +27,12 @@ const (
|
||||
CookieSourceHTTP CookieSource = "HTTP"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = CookieSource("")
|
||||
_ encoding.TextMarshaler = CookieSource("")
|
||||
_ encoding.TextUnmarshaler = (*CookieSource)(nil)
|
||||
)
|
||||
|
||||
func CookieSources() []CookieSource {
|
||||
return []CookieSource{
|
||||
CookieSourceScript,
|
||||
@@ -35,43 +41,33 @@ func CookieSources() []CookieSource {
|
||||
}
|
||||
}
|
||||
|
||||
func (s CookieSource) String() string {
|
||||
return string(s)
|
||||
func (v CookieSource) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
CookieSourceScript,
|
||||
CookieSourcePreExisting,
|
||||
CookieSourceHTTP:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *CookieSource) Scan(value any) error {
|
||||
var v string
|
||||
func (v CookieSource) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
switch val := value.(type) {
|
||||
case string:
|
||||
v = val
|
||||
case []byte:
|
||||
v = string(val)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for CookieSource: %T", value)
|
||||
func (v CookieSource) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *CookieSource) UnmarshalText(text []byte) error {
|
||||
val := CookieSource(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid CookieSource value: %q", string(text))
|
||||
}
|
||||
|
||||
switch CookieSource(v) {
|
||||
case CookieSourceScript:
|
||||
*s = CookieSourceScript
|
||||
case CookieSourcePreExisting:
|
||||
*s = CookieSourcePreExisting
|
||||
case CookieSourceHTTP:
|
||||
*s = CookieSourceHTTP
|
||||
default:
|
||||
return fmt.Errorf("invalid CookieSource value: %q", v)
|
||||
}
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s CookieSource) Value() (driver.Value, error) {
|
||||
switch s {
|
||||
case CookieSourceScript,
|
||||
CookieSourcePreExisting,
|
||||
CookieSourceHTTP:
|
||||
return string(s), nil
|
||||
default:
|
||||
return nil, fmt.Errorf("invalid CookieSource: %s", s)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
@@ -276,530 +277,289 @@ const (
|
||||
CountryCodeZW CountryCode = "ZW"
|
||||
)
|
||||
|
||||
func (ct CountryCode) String() string {
|
||||
return string(ct)
|
||||
var (
|
||||
_ fmt.Stringer = CountryCode("")
|
||||
_ encoding.TextMarshaler = CountryCode("")
|
||||
_ encoding.TextUnmarshaler = (*CountryCode)(nil)
|
||||
)
|
||||
|
||||
func (v CountryCode) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
CountryCodeAD,
|
||||
CountryCodeAE,
|
||||
CountryCodeAF,
|
||||
CountryCodeAG,
|
||||
CountryCodeAI,
|
||||
CountryCodeAL,
|
||||
CountryCodeAM,
|
||||
CountryCodeAO,
|
||||
CountryCodeAQ,
|
||||
CountryCodeAR,
|
||||
CountryCodeAS,
|
||||
CountryCodeAT,
|
||||
CountryCodeAU,
|
||||
CountryCodeAW,
|
||||
CountryCodeAX,
|
||||
CountryCodeAZ,
|
||||
CountryCodeBA,
|
||||
CountryCodeBB,
|
||||
CountryCodeBD,
|
||||
CountryCodeBE,
|
||||
CountryCodeBF,
|
||||
CountryCodeBG,
|
||||
CountryCodeBH,
|
||||
CountryCodeBI,
|
||||
CountryCodeBJ,
|
||||
CountryCodeBL,
|
||||
CountryCodeBM,
|
||||
CountryCodeBN,
|
||||
CountryCodeBO,
|
||||
CountryCodeBQ,
|
||||
CountryCodeBR,
|
||||
CountryCodeBS,
|
||||
CountryCodeBT,
|
||||
CountryCodeBV,
|
||||
CountryCodeBW,
|
||||
CountryCodeBY,
|
||||
CountryCodeBZ,
|
||||
CountryCodeCA,
|
||||
CountryCodeCC,
|
||||
CountryCodeCD,
|
||||
CountryCodeCF,
|
||||
CountryCodeCG,
|
||||
CountryCodeCH,
|
||||
CountryCodeCI,
|
||||
CountryCodeCK,
|
||||
CountryCodeCL,
|
||||
CountryCodeCM,
|
||||
CountryCodeCN,
|
||||
CountryCodeCO,
|
||||
CountryCodeCR,
|
||||
CountryCodeCU,
|
||||
CountryCodeCV,
|
||||
CountryCodeCW,
|
||||
CountryCodeCX,
|
||||
CountryCodeCY,
|
||||
CountryCodeCZ,
|
||||
CountryCodeDE,
|
||||
CountryCodeDJ,
|
||||
CountryCodeDK,
|
||||
CountryCodeDM,
|
||||
CountryCodeDO,
|
||||
CountryCodeDZ,
|
||||
CountryCodeEC,
|
||||
CountryCodeEE,
|
||||
CountryCodeEG,
|
||||
CountryCodeEH,
|
||||
CountryCodeER,
|
||||
CountryCodeES,
|
||||
CountryCodeET,
|
||||
CountryCodeEU,
|
||||
CountryCodeFI,
|
||||
CountryCodeFJ,
|
||||
CountryCodeFK,
|
||||
CountryCodeFM,
|
||||
CountryCodeFO,
|
||||
CountryCodeFR,
|
||||
CountryCodeGA,
|
||||
CountryCodeGB,
|
||||
CountryCodeGD,
|
||||
CountryCodeGE,
|
||||
CountryCodeGF,
|
||||
CountryCodeGG,
|
||||
CountryCodeGH,
|
||||
CountryCodeGI,
|
||||
CountryCodeGL,
|
||||
CountryCodeGM,
|
||||
CountryCodeGN,
|
||||
CountryCodeGP,
|
||||
CountryCodeGQ,
|
||||
CountryCodeGR,
|
||||
CountryCodeGT,
|
||||
CountryCodeGU,
|
||||
CountryCodeGW,
|
||||
CountryCodeGY,
|
||||
CountryCodeHK,
|
||||
CountryCodeHM,
|
||||
CountryCodeHN,
|
||||
CountryCodeHR,
|
||||
CountryCodeHT,
|
||||
CountryCodeHU,
|
||||
CountryCodeID,
|
||||
CountryCodeIE,
|
||||
CountryCodeIL,
|
||||
CountryCodeIM,
|
||||
CountryCodeIN,
|
||||
CountryCodeIO,
|
||||
CountryCodeIQ,
|
||||
CountryCodeIR,
|
||||
CountryCodeIS,
|
||||
CountryCodeIT,
|
||||
CountryCodeJE,
|
||||
CountryCodeJM,
|
||||
CountryCodeJO,
|
||||
CountryCodeJP,
|
||||
CountryCodeKE,
|
||||
CountryCodeKG,
|
||||
CountryCodeKH,
|
||||
CountryCodeKI,
|
||||
CountryCodeKM,
|
||||
CountryCodeKN,
|
||||
CountryCodeKP,
|
||||
CountryCodeKR,
|
||||
CountryCodeKW,
|
||||
CountryCodeKY,
|
||||
CountryCodeKZ,
|
||||
CountryCodeLA,
|
||||
CountryCodeLB,
|
||||
CountryCodeLC,
|
||||
CountryCodeLI,
|
||||
CountryCodeLK,
|
||||
CountryCodeLR,
|
||||
CountryCodeLS,
|
||||
CountryCodeLT,
|
||||
CountryCodeLU,
|
||||
CountryCodeLV,
|
||||
CountryCodeLY,
|
||||
CountryCodeMA,
|
||||
CountryCodeMC,
|
||||
CountryCodeMD,
|
||||
CountryCodeME,
|
||||
CountryCodeMF,
|
||||
CountryCodeMG,
|
||||
CountryCodeMH,
|
||||
CountryCodeMK,
|
||||
CountryCodeML,
|
||||
CountryCodeMM,
|
||||
CountryCodeMN,
|
||||
CountryCodeMO,
|
||||
CountryCodeMP,
|
||||
CountryCodeMQ,
|
||||
CountryCodeMR,
|
||||
CountryCodeMS,
|
||||
CountryCodeMT,
|
||||
CountryCodeMU,
|
||||
CountryCodeMV,
|
||||
CountryCodeMW,
|
||||
CountryCodeMX,
|
||||
CountryCodeMY,
|
||||
CountryCodeMZ,
|
||||
CountryCodeNA,
|
||||
CountryCodeNC,
|
||||
CountryCodeNE,
|
||||
CountryCodeNF,
|
||||
CountryCodeNG,
|
||||
CountryCodeNI,
|
||||
CountryCodeNL,
|
||||
CountryCodeNO,
|
||||
CountryCodeNP,
|
||||
CountryCodeNR,
|
||||
CountryCodeNU,
|
||||
CountryCodeNZ,
|
||||
CountryCodeOM,
|
||||
CountryCodePA,
|
||||
CountryCodePE,
|
||||
CountryCodePF,
|
||||
CountryCodePG,
|
||||
CountryCodePH,
|
||||
CountryCodePK,
|
||||
CountryCodePL,
|
||||
CountryCodePM,
|
||||
CountryCodePN,
|
||||
CountryCodePR,
|
||||
CountryCodePS,
|
||||
CountryCodePT,
|
||||
CountryCodePW,
|
||||
CountryCodePY,
|
||||
CountryCodeQA,
|
||||
CountryCodeRE,
|
||||
CountryCodeRO,
|
||||
CountryCodeRS,
|
||||
CountryCodeRU,
|
||||
CountryCodeRW,
|
||||
CountryCodeSA,
|
||||
CountryCodeSB,
|
||||
CountryCodeSC,
|
||||
CountryCodeSD,
|
||||
CountryCodeSE,
|
||||
CountryCodeSG,
|
||||
CountryCodeSH,
|
||||
CountryCodeSI,
|
||||
CountryCodeSJ,
|
||||
CountryCodeSK,
|
||||
CountryCodeSL,
|
||||
CountryCodeSM,
|
||||
CountryCodeSN,
|
||||
CountryCodeSO,
|
||||
CountryCodeSR,
|
||||
CountryCodeSS,
|
||||
CountryCodeST,
|
||||
CountryCodeSV,
|
||||
CountryCodeSX,
|
||||
CountryCodeSY,
|
||||
CountryCodeSZ,
|
||||
CountryCodeTC,
|
||||
CountryCodeTD,
|
||||
CountryCodeTF,
|
||||
CountryCodeTG,
|
||||
CountryCodeTH,
|
||||
CountryCodeTJ,
|
||||
CountryCodeTK,
|
||||
CountryCodeTL,
|
||||
CountryCodeTM,
|
||||
CountryCodeTN,
|
||||
CountryCodeTO,
|
||||
CountryCodeTR,
|
||||
CountryCodeTT,
|
||||
CountryCodeTV,
|
||||
CountryCodeTW,
|
||||
CountryCodeTZ,
|
||||
CountryCodeUA,
|
||||
CountryCodeUG,
|
||||
CountryCodeUM,
|
||||
CountryCodeUS,
|
||||
CountryCodeUY,
|
||||
CountryCodeUZ,
|
||||
CountryCodeVA,
|
||||
CountryCodeVC,
|
||||
CountryCodeVE,
|
||||
CountryCodeVG,
|
||||
CountryCodeVI,
|
||||
CountryCodeVN,
|
||||
CountryCodeVU,
|
||||
CountryCodeWF,
|
||||
CountryCodeWS,
|
||||
CountryCodeYE,
|
||||
CountryCodeYT,
|
||||
CountryCodeZA,
|
||||
CountryCodeZM,
|
||||
CountryCodeZW:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (ct *CountryCode) Scan(value any) error {
|
||||
var s string
|
||||
func (v CountryCode) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
s = v
|
||||
case []byte:
|
||||
s = string(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for CountryCode: %T", value)
|
||||
func (v CountryCode) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *CountryCode) UnmarshalText(text []byte) error {
|
||||
val := CountryCode(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid CountryCode value: %q", string(text))
|
||||
}
|
||||
|
||||
switch s {
|
||||
case CountryCodeAD.String():
|
||||
*ct = CountryCodeAD
|
||||
case CountryCodeAE.String():
|
||||
*ct = CountryCodeAE
|
||||
case CountryCodeAF.String():
|
||||
*ct = CountryCodeAF
|
||||
case CountryCodeAG.String():
|
||||
*ct = CountryCodeAG
|
||||
case CountryCodeAI.String():
|
||||
*ct = CountryCodeAI
|
||||
case CountryCodeAL.String():
|
||||
*ct = CountryCodeAL
|
||||
case CountryCodeAM.String():
|
||||
*ct = CountryCodeAM
|
||||
case CountryCodeAO.String():
|
||||
*ct = CountryCodeAO
|
||||
case CountryCodeAQ.String():
|
||||
*ct = CountryCodeAQ
|
||||
case CountryCodeAR.String():
|
||||
*ct = CountryCodeAR
|
||||
case CountryCodeAS.String():
|
||||
*ct = CountryCodeAS
|
||||
case CountryCodeAT.String():
|
||||
*ct = CountryCodeAT
|
||||
case CountryCodeAU.String():
|
||||
*ct = CountryCodeAU
|
||||
case CountryCodeAW.String():
|
||||
*ct = CountryCodeAW
|
||||
case CountryCodeAX.String():
|
||||
*ct = CountryCodeAX
|
||||
case CountryCodeAZ.String():
|
||||
*ct = CountryCodeAZ
|
||||
case CountryCodeBA.String():
|
||||
*ct = CountryCodeBA
|
||||
case CountryCodeBB.String():
|
||||
*ct = CountryCodeBB
|
||||
case CountryCodeBD.String():
|
||||
*ct = CountryCodeBD
|
||||
case CountryCodeBE.String():
|
||||
*ct = CountryCodeBE
|
||||
case CountryCodeBF.String():
|
||||
*ct = CountryCodeBF
|
||||
case CountryCodeBG.String():
|
||||
*ct = CountryCodeBG
|
||||
case CountryCodeBH.String():
|
||||
*ct = CountryCodeBH
|
||||
case CountryCodeBI.String():
|
||||
*ct = CountryCodeBI
|
||||
case CountryCodeBJ.String():
|
||||
*ct = CountryCodeBJ
|
||||
case CountryCodeBL.String():
|
||||
*ct = CountryCodeBL
|
||||
case CountryCodeBM.String():
|
||||
*ct = CountryCodeBM
|
||||
case CountryCodeBN.String():
|
||||
*ct = CountryCodeBN
|
||||
case CountryCodeBO.String():
|
||||
*ct = CountryCodeBO
|
||||
case CountryCodeBQ.String():
|
||||
*ct = CountryCodeBQ
|
||||
case CountryCodeBR.String():
|
||||
*ct = CountryCodeBR
|
||||
case CountryCodeBS.String():
|
||||
*ct = CountryCodeBS
|
||||
case CountryCodeBT.String():
|
||||
*ct = CountryCodeBT
|
||||
case CountryCodeBV.String():
|
||||
*ct = CountryCodeBV
|
||||
case CountryCodeBW.String():
|
||||
*ct = CountryCodeBW
|
||||
case CountryCodeBY.String():
|
||||
*ct = CountryCodeBY
|
||||
case CountryCodeBZ.String():
|
||||
*ct = CountryCodeBZ
|
||||
case CountryCodeCA.String():
|
||||
*ct = CountryCodeCA
|
||||
case CountryCodeCC.String():
|
||||
*ct = CountryCodeCC
|
||||
case CountryCodeCD.String():
|
||||
*ct = CountryCodeCD
|
||||
case CountryCodeCF.String():
|
||||
*ct = CountryCodeCF
|
||||
case CountryCodeCG.String():
|
||||
*ct = CountryCodeCG
|
||||
case CountryCodeCH.String():
|
||||
*ct = CountryCodeCH
|
||||
case CountryCodeCI.String():
|
||||
*ct = CountryCodeCI
|
||||
case CountryCodeCK.String():
|
||||
*ct = CountryCodeCK
|
||||
case CountryCodeCL.String():
|
||||
*ct = CountryCodeCL
|
||||
case CountryCodeCM.String():
|
||||
*ct = CountryCodeCM
|
||||
case CountryCodeCN.String():
|
||||
*ct = CountryCodeCN
|
||||
case CountryCodeCO.String():
|
||||
*ct = CountryCodeCO
|
||||
case CountryCodeCR.String():
|
||||
*ct = CountryCodeCR
|
||||
case CountryCodeCU.String():
|
||||
*ct = CountryCodeCU
|
||||
case CountryCodeCV.String():
|
||||
*ct = CountryCodeCV
|
||||
case CountryCodeCW.String():
|
||||
*ct = CountryCodeCW
|
||||
case CountryCodeCX.String():
|
||||
*ct = CountryCodeCX
|
||||
case CountryCodeCY.String():
|
||||
*ct = CountryCodeCY
|
||||
case CountryCodeCZ.String():
|
||||
*ct = CountryCodeCZ
|
||||
case CountryCodeDE.String():
|
||||
*ct = CountryCodeDE
|
||||
case CountryCodeDJ.String():
|
||||
*ct = CountryCodeDJ
|
||||
case CountryCodeDK.String():
|
||||
*ct = CountryCodeDK
|
||||
case CountryCodeDM.String():
|
||||
*ct = CountryCodeDM
|
||||
case CountryCodeDO.String():
|
||||
*ct = CountryCodeDO
|
||||
case CountryCodeDZ.String():
|
||||
*ct = CountryCodeDZ
|
||||
case CountryCodeEC.String():
|
||||
*ct = CountryCodeEC
|
||||
case CountryCodeEE.String():
|
||||
*ct = CountryCodeEE
|
||||
case CountryCodeEG.String():
|
||||
*ct = CountryCodeEG
|
||||
case CountryCodeEH.String():
|
||||
*ct = CountryCodeEH
|
||||
case CountryCodeER.String():
|
||||
*ct = CountryCodeER
|
||||
case CountryCodeES.String():
|
||||
*ct = CountryCodeES
|
||||
case CountryCodeET.String():
|
||||
*ct = CountryCodeET
|
||||
case CountryCodeEU.String():
|
||||
*ct = CountryCodeEU
|
||||
case CountryCodeFI.String():
|
||||
*ct = CountryCodeFI
|
||||
case CountryCodeFJ.String():
|
||||
*ct = CountryCodeFJ
|
||||
case CountryCodeFK.String():
|
||||
*ct = CountryCodeFK
|
||||
case CountryCodeFM.String():
|
||||
*ct = CountryCodeFM
|
||||
case CountryCodeFO.String():
|
||||
*ct = CountryCodeFO
|
||||
case CountryCodeFR.String():
|
||||
*ct = CountryCodeFR
|
||||
case CountryCodeGA.String():
|
||||
*ct = CountryCodeGA
|
||||
case CountryCodeGB.String():
|
||||
*ct = CountryCodeGB
|
||||
case CountryCodeGD.String():
|
||||
*ct = CountryCodeGD
|
||||
case CountryCodeGE.String():
|
||||
*ct = CountryCodeGE
|
||||
case CountryCodeGF.String():
|
||||
*ct = CountryCodeGF
|
||||
case CountryCodeGG.String():
|
||||
*ct = CountryCodeGG
|
||||
case CountryCodeGH.String():
|
||||
*ct = CountryCodeGH
|
||||
case CountryCodeGI.String():
|
||||
*ct = CountryCodeGI
|
||||
case CountryCodeGL.String():
|
||||
*ct = CountryCodeGL
|
||||
case CountryCodeGM.String():
|
||||
*ct = CountryCodeGM
|
||||
case CountryCodeGN.String():
|
||||
*ct = CountryCodeGN
|
||||
case CountryCodeGP.String():
|
||||
*ct = CountryCodeGP
|
||||
case CountryCodeGQ.String():
|
||||
*ct = CountryCodeGQ
|
||||
case CountryCodeGR.String():
|
||||
*ct = CountryCodeGR
|
||||
case CountryCodeGT.String():
|
||||
*ct = CountryCodeGT
|
||||
case CountryCodeGU.String():
|
||||
*ct = CountryCodeGU
|
||||
case CountryCodeGW.String():
|
||||
*ct = CountryCodeGW
|
||||
case CountryCodeGY.String():
|
||||
*ct = CountryCodeGY
|
||||
case CountryCodeHK.String():
|
||||
*ct = CountryCodeHK
|
||||
case CountryCodeHM.String():
|
||||
*ct = CountryCodeHM
|
||||
case CountryCodeHN.String():
|
||||
*ct = CountryCodeHN
|
||||
case CountryCodeHR.String():
|
||||
*ct = CountryCodeHR
|
||||
case CountryCodeHT.String():
|
||||
*ct = CountryCodeHT
|
||||
case CountryCodeHU.String():
|
||||
*ct = CountryCodeHU
|
||||
case CountryCodeID.String():
|
||||
*ct = CountryCodeID
|
||||
case CountryCodeIE.String():
|
||||
*ct = CountryCodeIE
|
||||
case CountryCodeIL.String():
|
||||
*ct = CountryCodeIL
|
||||
case CountryCodeIM.String():
|
||||
*ct = CountryCodeIM
|
||||
case CountryCodeIN.String():
|
||||
*ct = CountryCodeIN
|
||||
case CountryCodeIO.String():
|
||||
*ct = CountryCodeIO
|
||||
case CountryCodeIQ.String():
|
||||
*ct = CountryCodeIQ
|
||||
case CountryCodeIR.String():
|
||||
*ct = CountryCodeIR
|
||||
case CountryCodeIS.String():
|
||||
*ct = CountryCodeIS
|
||||
case CountryCodeIT.String():
|
||||
*ct = CountryCodeIT
|
||||
case CountryCodeJE.String():
|
||||
*ct = CountryCodeJE
|
||||
case CountryCodeJM.String():
|
||||
*ct = CountryCodeJM
|
||||
case CountryCodeJO.String():
|
||||
*ct = CountryCodeJO
|
||||
case CountryCodeJP.String():
|
||||
*ct = CountryCodeJP
|
||||
case CountryCodeKE.String():
|
||||
*ct = CountryCodeKE
|
||||
case CountryCodeKG.String():
|
||||
*ct = CountryCodeKG
|
||||
case CountryCodeKH.String():
|
||||
*ct = CountryCodeKH
|
||||
case CountryCodeKI.String():
|
||||
*ct = CountryCodeKI
|
||||
case CountryCodeKM.String():
|
||||
*ct = CountryCodeKM
|
||||
case CountryCodeKN.String():
|
||||
*ct = CountryCodeKN
|
||||
case CountryCodeKP.String():
|
||||
*ct = CountryCodeKP
|
||||
case CountryCodeKR.String():
|
||||
*ct = CountryCodeKR
|
||||
case CountryCodeKW.String():
|
||||
*ct = CountryCodeKW
|
||||
case CountryCodeKY.String():
|
||||
*ct = CountryCodeKY
|
||||
case CountryCodeKZ.String():
|
||||
*ct = CountryCodeKZ
|
||||
case CountryCodeLA.String():
|
||||
*ct = CountryCodeLA
|
||||
case CountryCodeLB.String():
|
||||
*ct = CountryCodeLB
|
||||
case CountryCodeLC.String():
|
||||
*ct = CountryCodeLC
|
||||
case CountryCodeLI.String():
|
||||
*ct = CountryCodeLI
|
||||
case CountryCodeLK.String():
|
||||
*ct = CountryCodeLK
|
||||
case CountryCodeLR.String():
|
||||
*ct = CountryCodeLR
|
||||
case CountryCodeLS.String():
|
||||
*ct = CountryCodeLS
|
||||
case CountryCodeLT.String():
|
||||
*ct = CountryCodeLT
|
||||
case CountryCodeLU.String():
|
||||
*ct = CountryCodeLU
|
||||
case CountryCodeLV.String():
|
||||
*ct = CountryCodeLV
|
||||
case CountryCodeLY.String():
|
||||
*ct = CountryCodeLY
|
||||
case CountryCodeMA.String():
|
||||
*ct = CountryCodeMA
|
||||
case CountryCodeMC.String():
|
||||
*ct = CountryCodeMC
|
||||
case CountryCodeMD.String():
|
||||
*ct = CountryCodeMD
|
||||
case CountryCodeME.String():
|
||||
*ct = CountryCodeME
|
||||
case CountryCodeMF.String():
|
||||
*ct = CountryCodeMF
|
||||
case CountryCodeMG.String():
|
||||
*ct = CountryCodeMG
|
||||
case CountryCodeMH.String():
|
||||
*ct = CountryCodeMH
|
||||
case CountryCodeMK.String():
|
||||
*ct = CountryCodeMK
|
||||
case CountryCodeML.String():
|
||||
*ct = CountryCodeML
|
||||
case CountryCodeMM.String():
|
||||
*ct = CountryCodeMM
|
||||
case CountryCodeMN.String():
|
||||
*ct = CountryCodeMN
|
||||
case CountryCodeMO.String():
|
||||
*ct = CountryCodeMO
|
||||
case CountryCodeMP.String():
|
||||
*ct = CountryCodeMP
|
||||
case CountryCodeMQ.String():
|
||||
*ct = CountryCodeMQ
|
||||
case CountryCodeMR.String():
|
||||
*ct = CountryCodeMR
|
||||
case CountryCodeMS.String():
|
||||
*ct = CountryCodeMS
|
||||
case CountryCodeMT.String():
|
||||
*ct = CountryCodeMT
|
||||
case CountryCodeMU.String():
|
||||
*ct = CountryCodeMU
|
||||
case CountryCodeMV.String():
|
||||
*ct = CountryCodeMV
|
||||
case CountryCodeMW.String():
|
||||
*ct = CountryCodeMW
|
||||
case CountryCodeMX.String():
|
||||
*ct = CountryCodeMX
|
||||
case CountryCodeMY.String():
|
||||
*ct = CountryCodeMY
|
||||
case CountryCodeMZ.String():
|
||||
*ct = CountryCodeMZ
|
||||
case CountryCodeNA.String():
|
||||
*ct = CountryCodeNA
|
||||
case CountryCodeNC.String():
|
||||
*ct = CountryCodeNC
|
||||
case CountryCodeNE.String():
|
||||
*ct = CountryCodeNE
|
||||
case CountryCodeNF.String():
|
||||
*ct = CountryCodeNF
|
||||
case CountryCodeNG.String():
|
||||
*ct = CountryCodeNG
|
||||
case CountryCodeNI.String():
|
||||
*ct = CountryCodeNI
|
||||
case CountryCodeNL.String():
|
||||
*ct = CountryCodeNL
|
||||
case CountryCodeNO.String():
|
||||
*ct = CountryCodeNO
|
||||
case CountryCodeNP.String():
|
||||
*ct = CountryCodeNP
|
||||
case CountryCodeNR.String():
|
||||
*ct = CountryCodeNR
|
||||
case CountryCodeNU.String():
|
||||
*ct = CountryCodeNU
|
||||
case CountryCodeNZ.String():
|
||||
*ct = CountryCodeNZ
|
||||
case CountryCodeOM.String():
|
||||
*ct = CountryCodeOM
|
||||
case CountryCodePA.String():
|
||||
*ct = CountryCodePA
|
||||
case CountryCodePE.String():
|
||||
*ct = CountryCodePE
|
||||
case CountryCodePF.String():
|
||||
*ct = CountryCodePF
|
||||
case CountryCodePG.String():
|
||||
*ct = CountryCodePG
|
||||
case CountryCodePH.String():
|
||||
*ct = CountryCodePH
|
||||
case CountryCodePK.String():
|
||||
*ct = CountryCodePK
|
||||
case CountryCodePL.String():
|
||||
*ct = CountryCodePL
|
||||
case CountryCodePM.String():
|
||||
*ct = CountryCodePM
|
||||
case CountryCodePN.String():
|
||||
*ct = CountryCodePN
|
||||
case CountryCodePR.String():
|
||||
*ct = CountryCodePR
|
||||
case CountryCodePS.String():
|
||||
*ct = CountryCodePS
|
||||
case CountryCodePT.String():
|
||||
*ct = CountryCodePT
|
||||
case CountryCodePW.String():
|
||||
*ct = CountryCodePW
|
||||
case CountryCodePY.String():
|
||||
*ct = CountryCodePY
|
||||
case CountryCodeQA.String():
|
||||
*ct = CountryCodeQA
|
||||
case CountryCodeRE.String():
|
||||
*ct = CountryCodeRE
|
||||
case CountryCodeRO.String():
|
||||
*ct = CountryCodeRO
|
||||
case CountryCodeRS.String():
|
||||
*ct = CountryCodeRS
|
||||
case CountryCodeRU.String():
|
||||
*ct = CountryCodeRU
|
||||
case CountryCodeRW.String():
|
||||
*ct = CountryCodeRW
|
||||
case CountryCodeSA.String():
|
||||
*ct = CountryCodeSA
|
||||
case CountryCodeSB.String():
|
||||
*ct = CountryCodeSB
|
||||
case CountryCodeSC.String():
|
||||
*ct = CountryCodeSC
|
||||
case CountryCodeSD.String():
|
||||
*ct = CountryCodeSD
|
||||
case CountryCodeSE.String():
|
||||
*ct = CountryCodeSE
|
||||
case CountryCodeSG.String():
|
||||
*ct = CountryCodeSG
|
||||
case CountryCodeSH.String():
|
||||
*ct = CountryCodeSH
|
||||
case CountryCodeSI.String():
|
||||
*ct = CountryCodeSI
|
||||
case CountryCodeSJ.String():
|
||||
*ct = CountryCodeSJ
|
||||
case CountryCodeSK.String():
|
||||
*ct = CountryCodeSK
|
||||
case CountryCodeSL.String():
|
||||
*ct = CountryCodeSL
|
||||
case CountryCodeSM.String():
|
||||
*ct = CountryCodeSM
|
||||
case CountryCodeSN.String():
|
||||
*ct = CountryCodeSN
|
||||
case CountryCodeSO.String():
|
||||
*ct = CountryCodeSO
|
||||
case CountryCodeSR.String():
|
||||
*ct = CountryCodeSR
|
||||
case CountryCodeSS.String():
|
||||
*ct = CountryCodeSS
|
||||
case CountryCodeST.String():
|
||||
*ct = CountryCodeST
|
||||
case CountryCodeSV.String():
|
||||
*ct = CountryCodeSV
|
||||
case CountryCodeSY.String():
|
||||
*ct = CountryCodeSY
|
||||
case CountryCodeSZ.String():
|
||||
*ct = CountryCodeSZ
|
||||
case CountryCodeTC.String():
|
||||
*ct = CountryCodeTC
|
||||
case CountryCodeTD.String():
|
||||
*ct = CountryCodeTD
|
||||
case CountryCodeTF.String():
|
||||
*ct = CountryCodeTF
|
||||
case CountryCodeTG.String():
|
||||
*ct = CountryCodeTG
|
||||
case CountryCodeTH.String():
|
||||
*ct = CountryCodeTH
|
||||
case CountryCodeTJ.String():
|
||||
*ct = CountryCodeTJ
|
||||
case CountryCodeTK.String():
|
||||
*ct = CountryCodeTK
|
||||
case CountryCodeTL.String():
|
||||
*ct = CountryCodeTL
|
||||
case CountryCodeTM.String():
|
||||
*ct = CountryCodeTM
|
||||
case CountryCodeTN.String():
|
||||
*ct = CountryCodeTN
|
||||
case CountryCodeTO.String():
|
||||
*ct = CountryCodeTO
|
||||
case CountryCodeTR.String():
|
||||
*ct = CountryCodeTR
|
||||
case CountryCodeTT.String():
|
||||
*ct = CountryCodeTT
|
||||
case CountryCodeTV.String():
|
||||
*ct = CountryCodeTV
|
||||
case CountryCodeTW.String():
|
||||
*ct = CountryCodeTW
|
||||
case CountryCodeTZ.String():
|
||||
*ct = CountryCodeTZ
|
||||
case CountryCodeUA.String():
|
||||
*ct = CountryCodeUA
|
||||
case CountryCodeUG.String():
|
||||
*ct = CountryCodeUG
|
||||
case CountryCodeUM.String():
|
||||
*ct = CountryCodeUM
|
||||
case CountryCodeUS.String():
|
||||
*ct = CountryCodeUS
|
||||
case CountryCodeUY.String():
|
||||
*ct = CountryCodeUY
|
||||
case CountryCodeUZ.String():
|
||||
*ct = CountryCodeUZ
|
||||
case CountryCodeVA.String():
|
||||
*ct = CountryCodeVA
|
||||
case CountryCodeVC.String():
|
||||
*ct = CountryCodeVC
|
||||
case CountryCodeVE.String():
|
||||
*ct = CountryCodeVE
|
||||
case CountryCodeVG.String():
|
||||
*ct = CountryCodeVG
|
||||
case CountryCodeVI.String():
|
||||
*ct = CountryCodeVI
|
||||
case CountryCodeVN.String():
|
||||
*ct = CountryCodeVN
|
||||
case CountryCodeVU.String():
|
||||
*ct = CountryCodeVU
|
||||
case CountryCodeWF.String():
|
||||
*ct = CountryCodeWF
|
||||
case CountryCodeWS.String():
|
||||
*ct = CountryCodeWS
|
||||
case CountryCodeYE.String():
|
||||
*ct = CountryCodeYE
|
||||
case CountryCodeYT.String():
|
||||
*ct = CountryCodeYT
|
||||
case CountryCodeZA.String():
|
||||
*ct = CountryCodeZA
|
||||
case CountryCodeZM.String():
|
||||
*ct = CountryCodeZM
|
||||
case CountryCodeZW.String():
|
||||
*ct = CountryCodeZW
|
||||
default:
|
||||
return fmt.Errorf("invalid CountryCode value: %q", s)
|
||||
}
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (st CountryCode) Value() (driver.Value, error) {
|
||||
return st.String(), nil
|
||||
}
|
||||
|
||||
type CountryCodes []CountryCode
|
||||
|
||||
func (s *CountryCodes) Scan(value any) error {
|
||||
@@ -835,7 +595,7 @@ func (s *CountryCodes) scanFromString(str string) error {
|
||||
}
|
||||
|
||||
var ct CountryCode
|
||||
if err := ct.Scan(part); err != nil {
|
||||
if err := ct.UnmarshalText([]byte(part)); err != nil {
|
||||
return fmt.Errorf("invalid country code in array: %s", part)
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,12 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type CustomDomainOrderField string
|
||||
|
||||
@@ -24,6 +29,52 @@ const (
|
||||
CustomDomainOrderFieldUpdatedAt CustomDomainOrderField = "UPDATED_AT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = CustomDomainOrderField("")
|
||||
_ fmt.Stringer = CustomDomainOrderField("")
|
||||
_ encoding.TextMarshaler = CustomDomainOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*CustomDomainOrderField)(nil)
|
||||
)
|
||||
|
||||
func CustomDomainOrderFields() []CustomDomainOrderField {
|
||||
return []CustomDomainOrderField{
|
||||
CustomDomainOrderFieldCreatedAt,
|
||||
CustomDomainOrderFieldDomain,
|
||||
CustomDomainOrderFieldUpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v CustomDomainOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
CustomDomainOrderFieldCreatedAt,
|
||||
CustomDomainOrderFieldDomain,
|
||||
CustomDomainOrderFieldUpdatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v CustomDomainOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v CustomDomainOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *CustomDomainOrderField) UnmarshalText(text []byte) error {
|
||||
val := CustomDomainOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid CustomDomainOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f CustomDomainOrderField) Column() string {
|
||||
switch f {
|
||||
case CustomDomainOrderFieldCreatedAt:
|
||||
@@ -36,7 +87,3 @@ func (f CustomDomainOrderField) Column() string {
|
||||
panic(fmt.Sprintf("unsupported order by: %s", f))
|
||||
}
|
||||
}
|
||||
|
||||
func (f CustomDomainOrderField) String() string {
|
||||
return string(f)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -30,46 +30,53 @@ const (
|
||||
CustomDomainSSLStatusFailed CustomDomainSSLStatus = "FAILED"
|
||||
)
|
||||
|
||||
func (s CustomDomainSSLStatus) MarshalText() ([]byte, error) {
|
||||
return []byte(s.String()), nil
|
||||
var (
|
||||
_ fmt.Stringer = CustomDomainSSLStatus("")
|
||||
_ encoding.TextMarshaler = CustomDomainSSLStatus("")
|
||||
_ encoding.TextUnmarshaler = (*CustomDomainSSLStatus)(nil)
|
||||
)
|
||||
|
||||
func CustomDomainSSLStatuses() []CustomDomainSSLStatus {
|
||||
return []CustomDomainSSLStatus{
|
||||
CustomDomainSSLStatusPending,
|
||||
CustomDomainSSLStatusProvisioning,
|
||||
CustomDomainSSLStatusActive,
|
||||
CustomDomainSSLStatusRenewing,
|
||||
CustomDomainSSLStatusExpired,
|
||||
CustomDomainSSLStatusFailed,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *CustomDomainSSLStatus) UnmarshalText(data []byte) error {
|
||||
val := string(data)
|
||||
|
||||
switch val {
|
||||
case CustomDomainSSLStatusPending.String():
|
||||
*s = CustomDomainSSLStatusPending
|
||||
case CustomDomainSSLStatusProvisioning.String():
|
||||
*s = CustomDomainSSLStatusProvisioning
|
||||
case CustomDomainSSLStatusActive.String():
|
||||
*s = CustomDomainSSLStatusActive
|
||||
case CustomDomainSSLStatusRenewing.String():
|
||||
*s = CustomDomainSSLStatusRenewing
|
||||
case CustomDomainSSLStatusExpired.String():
|
||||
*s = CustomDomainSSLStatusExpired
|
||||
case CustomDomainSSLStatusFailed.String():
|
||||
*s = CustomDomainSSLStatusFailed
|
||||
default:
|
||||
return fmt.Errorf("invalid CustomDomainSSLStatus value: %q", val)
|
||||
func (v CustomDomainSSLStatus) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
CustomDomainSSLStatusPending,
|
||||
CustomDomainSSLStatusProvisioning,
|
||||
CustomDomainSSLStatusActive,
|
||||
CustomDomainSSLStatusRenewing,
|
||||
CustomDomainSSLStatusExpired,
|
||||
CustomDomainSSLStatusFailed:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v CustomDomainSSLStatus) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v CustomDomainSSLStatus) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *CustomDomainSSLStatus) UnmarshalText(text []byte) error {
|
||||
val := CustomDomainSSLStatus(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid CustomDomainSSLStatus value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s CustomDomainSSLStatus) String() string {
|
||||
return string(s)
|
||||
}
|
||||
|
||||
func (s *CustomDomainSSLStatus) Scan(value any) error {
|
||||
val, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid scan source for CustomDomainSSLStatus, expected string got %T", value)
|
||||
}
|
||||
|
||||
return s.UnmarshalText([]byte(val))
|
||||
}
|
||||
|
||||
func (s CustomDomainSSLStatus) Value() (driver.Value, error) {
|
||||
return s.String(), nil
|
||||
}
|
||||
|
||||
@@ -14,6 +14,11 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type CustomDomainVerificationStatus string
|
||||
|
||||
const (
|
||||
@@ -21,3 +26,48 @@ const (
|
||||
CustomDomainVerificationStatusVerified CustomDomainVerificationStatus = "VERIFIED"
|
||||
CustomDomainVerificationStatusFailed CustomDomainVerificationStatus = "FAILED"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = CustomDomainVerificationStatus("")
|
||||
_ encoding.TextMarshaler = CustomDomainVerificationStatus("")
|
||||
_ encoding.TextUnmarshaler = (*CustomDomainVerificationStatus)(nil)
|
||||
)
|
||||
|
||||
func CustomDomainVerificationStatuses() []CustomDomainVerificationStatus {
|
||||
return []CustomDomainVerificationStatus{
|
||||
CustomDomainVerificationStatusPending,
|
||||
CustomDomainVerificationStatusVerified,
|
||||
CustomDomainVerificationStatusFailed,
|
||||
}
|
||||
}
|
||||
|
||||
func (v CustomDomainVerificationStatus) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
CustomDomainVerificationStatusPending,
|
||||
CustomDomainVerificationStatusVerified,
|
||||
CustomDomainVerificationStatusFailed:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v CustomDomainVerificationStatus) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v CustomDomainVerificationStatus) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *CustomDomainVerificationStatus) UnmarshalText(text []byte) error {
|
||||
val := CustomDomainVerificationStatus(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid CustomDomainVerificationStatus value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -14,6 +14,11 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type DataClassification string
|
||||
|
||||
const (
|
||||
@@ -23,6 +28,12 @@ const (
|
||||
DataClassificationSecret DataClassification = "SECRET"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = DataClassification("")
|
||||
_ encoding.TextMarshaler = DataClassification("")
|
||||
_ encoding.TextUnmarshaler = (*DataClassification)(nil)
|
||||
)
|
||||
|
||||
func DataClassifications() []DataClassification {
|
||||
return []DataClassification{
|
||||
DataClassificationPublic,
|
||||
@@ -31,3 +42,35 @@ func DataClassifications() []DataClassification {
|
||||
DataClassificationSecret,
|
||||
}
|
||||
}
|
||||
|
||||
func (v DataClassification) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
DataClassificationPublic,
|
||||
DataClassificationInternal,
|
||||
DataClassificationConfidential,
|
||||
DataClassificationSecret:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v DataClassification) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v DataClassification) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *DataClassification) UnmarshalText(text []byte) error {
|
||||
val := DataClassification(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid DataClassification value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -14,7 +14,12 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type DataProtectionImpactAssessmentOrderField string
|
||||
|
||||
@@ -22,25 +27,48 @@ const (
|
||||
DataProtectionImpactAssessmentOrderFieldCreatedAt DataProtectionImpactAssessmentOrderField = "CREATED_AT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = DataProtectionImpactAssessmentOrderField("")
|
||||
_ fmt.Stringer = DataProtectionImpactAssessmentOrderField("")
|
||||
_ encoding.TextMarshaler = DataProtectionImpactAssessmentOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*DataProtectionImpactAssessmentOrderField)(nil)
|
||||
)
|
||||
|
||||
func DataProtectionImpactAssessmentOrderFields() []DataProtectionImpactAssessmentOrderField {
|
||||
return []DataProtectionImpactAssessmentOrderField{
|
||||
DataProtectionImpactAssessmentOrderFieldCreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v DataProtectionImpactAssessmentOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
DataProtectionImpactAssessmentOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v DataProtectionImpactAssessmentOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v DataProtectionImpactAssessmentOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *DataProtectionImpactAssessmentOrderField) UnmarshalText(text []byte) error {
|
||||
val := DataProtectionImpactAssessmentOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid DataProtectionImpactAssessmentOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p DataProtectionImpactAssessmentOrderField) Column() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p DataProtectionImpactAssessmentOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p DataProtectionImpactAssessmentOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *DataProtectionImpactAssessmentOrderField) UnmarshalText(text []byte) error {
|
||||
val := string(text)
|
||||
switch val {
|
||||
case string(DataProtectionImpactAssessmentOrderFieldCreatedAt):
|
||||
*p = DataProtectionImpactAssessmentOrderFieldCreatedAt
|
||||
return nil
|
||||
}
|
||||
|
||||
return fmt.Errorf("invalid DataProtectionImpactAssessmentOrderField value: %q", val)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -27,6 +27,12 @@ const (
|
||||
DataProtectionImpactAssessmentResidualRiskHigh DataProtectionImpactAssessmentResidualRisk = "HIGH"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = DataProtectionImpactAssessmentResidualRisk("")
|
||||
_ encoding.TextMarshaler = DataProtectionImpactAssessmentResidualRisk("")
|
||||
_ encoding.TextUnmarshaler = (*DataProtectionImpactAssessmentResidualRisk)(nil)
|
||||
)
|
||||
|
||||
func DataProtectionImpactAssessmentResidualRisks() []DataProtectionImpactAssessmentResidualRisk {
|
||||
return []DataProtectionImpactAssessmentResidualRisk{
|
||||
DataProtectionImpactAssessmentResidualRiskLow,
|
||||
@@ -35,36 +41,33 @@ func DataProtectionImpactAssessmentResidualRisks() []DataProtectionImpactAssessm
|
||||
}
|
||||
}
|
||||
|
||||
func (p DataProtectionImpactAssessmentResidualRisk) String() string {
|
||||
return string(p)
|
||||
func (v DataProtectionImpactAssessmentResidualRisk) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
DataProtectionImpactAssessmentResidualRiskLow,
|
||||
DataProtectionImpactAssessmentResidualRiskMedium,
|
||||
DataProtectionImpactAssessmentResidualRiskHigh:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (p *DataProtectionImpactAssessmentResidualRisk) Scan(value any) error {
|
||||
var s string
|
||||
func (v DataProtectionImpactAssessmentResidualRisk) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
s = v
|
||||
case []byte:
|
||||
s = string(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for DataProtectionImpactAssessmentResidualRisk: %T", value)
|
||||
func (v DataProtectionImpactAssessmentResidualRisk) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *DataProtectionImpactAssessmentResidualRisk) UnmarshalText(text []byte) error {
|
||||
val := DataProtectionImpactAssessmentResidualRisk(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid DataProtectionImpactAssessmentResidualRisk value: %q", string(text))
|
||||
}
|
||||
|
||||
switch s {
|
||||
case "LOW":
|
||||
*p = DataProtectionImpactAssessmentResidualRiskLow
|
||||
case "MEDIUM":
|
||||
*p = DataProtectionImpactAssessmentResidualRiskMedium
|
||||
case "HIGH":
|
||||
*p = DataProtectionImpactAssessmentResidualRiskHigh
|
||||
default:
|
||||
return fmt.Errorf("invalid DataProtectionImpactAssessmentResidualRisk value: %q", s)
|
||||
}
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p DataProtectionImpactAssessmentResidualRisk) Value() (driver.Value, error) {
|
||||
return p.String(), nil
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -30,6 +29,12 @@ const (
|
||||
DataSensitivityCritical DataSensitivity = "CRITICAL"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = DataSensitivity("")
|
||||
_ encoding.TextMarshaler = DataSensitivity("")
|
||||
_ encoding.TextUnmarshaler = (*DataSensitivity)(nil)
|
||||
)
|
||||
|
||||
func DataSensitivities() []DataSensitivity {
|
||||
return []DataSensitivity{
|
||||
DataSensitivityNone,
|
||||
@@ -40,86 +45,35 @@ func DataSensitivities() []DataSensitivity {
|
||||
}
|
||||
}
|
||||
|
||||
func (i DataSensitivity) String() string {
|
||||
return string(i)
|
||||
func (v DataSensitivity) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
DataSensitivityNone,
|
||||
DataSensitivityLow,
|
||||
DataSensitivityMedium,
|
||||
DataSensitivityHigh,
|
||||
DataSensitivityCritical:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (i *DataSensitivity) Scan(value any) error {
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
switch v {
|
||||
case "NONE":
|
||||
*i = DataSensitivityNone
|
||||
case "LOW":
|
||||
*i = DataSensitivityLow
|
||||
case "MEDIUM":
|
||||
*i = DataSensitivityMedium
|
||||
case "HIGH":
|
||||
*i = DataSensitivityHigh
|
||||
case "CRITICAL":
|
||||
*i = DataSensitivityCritical
|
||||
default:
|
||||
return fmt.Errorf("invalid DataSensitivity value: %q", v)
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for DataSensitivity: %T", value)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i DataSensitivity) Value() (driver.Value, error) {
|
||||
return i.String(), nil
|
||||
}
|
||||
|
||||
func (i DataSensitivity) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(i.String())
|
||||
}
|
||||
|
||||
func (i *DataSensitivity) UnmarshalJSON(data []byte) error {
|
||||
var s string
|
||||
if err := json.Unmarshal(data, &s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch s {
|
||||
case "NONE":
|
||||
*i = DataSensitivityNone
|
||||
case "LOW":
|
||||
*i = DataSensitivityLow
|
||||
case "MEDIUM":
|
||||
*i = DataSensitivityMedium
|
||||
case "HIGH":
|
||||
*i = DataSensitivityHigh
|
||||
case "CRITICAL":
|
||||
*i = DataSensitivityCritical
|
||||
default:
|
||||
return fmt.Errorf("invalid DataSensitivity value: %q", s)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *DataSensitivity) UnmarshalText(text []byte) error {
|
||||
var s string
|
||||
if err := json.Unmarshal(text, &s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch s {
|
||||
case "NONE":
|
||||
*i = DataSensitivityNone
|
||||
case "LOW":
|
||||
*i = DataSensitivityLow
|
||||
case "MEDIUM":
|
||||
*i = DataSensitivityMedium
|
||||
case "HIGH":
|
||||
*i = DataSensitivityHigh
|
||||
case "CRITICAL":
|
||||
*i = DataSensitivityCritical
|
||||
default:
|
||||
return fmt.Errorf("invalid DataSensitivity value: %q", s)
|
||||
func (v DataSensitivity) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v DataSensitivity) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *DataSensitivity) UnmarshalText(text []byte) error {
|
||||
val := DataSensitivity(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid DataSensitivity value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,10 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type DatumOrderField string
|
||||
@@ -26,27 +29,52 @@ const (
|
||||
DatumOrderFieldDataClassification DatumOrderField = "DATA_CLASSIFICATION"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = DatumOrderField("")
|
||||
_ fmt.Stringer = DatumOrderField("")
|
||||
_ encoding.TextMarshaler = DatumOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*DatumOrderField)(nil)
|
||||
)
|
||||
|
||||
func DatumOrderFields() []DatumOrderField {
|
||||
return []DatumOrderField{
|
||||
DatumOrderFieldCreatedAt,
|
||||
DatumOrderFieldName,
|
||||
DatumOrderFieldDataClassification,
|
||||
}
|
||||
}
|
||||
|
||||
func (v DatumOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
DatumOrderFieldCreatedAt,
|
||||
DatumOrderFieldName,
|
||||
DatumOrderFieldDataClassification:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v DatumOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v DatumOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *DatumOrderField) UnmarshalText(text []byte) error {
|
||||
val := DatumOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid DatumOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p DatumOrderField) Column() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p DatumOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p DatumOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *DatumOrderField) UnmarshalText(text []byte) error {
|
||||
val := string(text)
|
||||
switch val {
|
||||
case string(DatumOrderFieldCreatedAt),
|
||||
string(DatumOrderFieldName),
|
||||
string(DatumOrderFieldDataClassification):
|
||||
*p = DatumOrderField(val)
|
||||
return nil
|
||||
}
|
||||
|
||||
return fmt.Errorf("invalid DatumOrderField value: %q", val)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -28,6 +28,12 @@ const (
|
||||
DocumentClassificationSecret DocumentClassification = "SECRET"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = DocumentClassification("")
|
||||
_ encoding.TextMarshaler = DocumentClassification("")
|
||||
_ encoding.TextUnmarshaler = (*DocumentClassification)(nil)
|
||||
)
|
||||
|
||||
func DocumentClassifications() []DocumentClassification {
|
||||
return []DocumentClassification{
|
||||
DocumentClassificationPublic,
|
||||
@@ -37,44 +43,37 @@ func DocumentClassifications() []DocumentClassification {
|
||||
}
|
||||
}
|
||||
|
||||
func (dc DocumentClassification) String() string {
|
||||
switch dc {
|
||||
case DocumentClassificationPublic:
|
||||
return "PUBLIC"
|
||||
case DocumentClassificationInternal:
|
||||
return "INTERNAL"
|
||||
case DocumentClassificationConfidential:
|
||||
return "CONFIDENTIAL"
|
||||
case DocumentClassificationSecret:
|
||||
return "SECRET"
|
||||
func (v DocumentClassification) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
DocumentClassificationPublic,
|
||||
DocumentClassificationInternal,
|
||||
DocumentClassificationConfidential,
|
||||
DocumentClassificationSecret:
|
||||
return true
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("invalid DocumentClassification value: %s", string(dc)))
|
||||
return false
|
||||
}
|
||||
|
||||
// Scan implements the sql.Scanner interface for database deserialization.
|
||||
func (dc *DocumentClassification) Scan(value any) error {
|
||||
if value == nil {
|
||||
return nil
|
||||
func (v DocumentClassification) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v DocumentClassification) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *DocumentClassification) UnmarshalText(text []byte) error {
|
||||
val := DocumentClassification(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid DocumentClassification value: %q", string(text))
|
||||
}
|
||||
|
||||
var sv string
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
sv = v
|
||||
case []byte:
|
||||
sv = string(v)
|
||||
default:
|
||||
return fmt.Errorf("cannot scan DocumentClassification: expected string or []byte, got %T", value)
|
||||
}
|
||||
|
||||
*dc = DocumentClassification(sv)
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Scan implements the sql.Scanner interface for database deserialization.
|
||||
// Value implements the driver.Valuer interface for database serialization.
|
||||
func (dc DocumentClassification) Value() (driver.Value, error) {
|
||||
return string(dc), nil
|
||||
}
|
||||
|
||||
@@ -14,7 +14,12 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
DocumentOrderField string
|
||||
@@ -27,6 +32,54 @@ const (
|
||||
DocumentOrderFieldDocumentType DocumentOrderField = "DOCUMENT_TYPE"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = DocumentOrderField("")
|
||||
_ fmt.Stringer = DocumentOrderField("")
|
||||
_ encoding.TextMarshaler = DocumentOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*DocumentOrderField)(nil)
|
||||
)
|
||||
|
||||
func DocumentOrderFields() []DocumentOrderField {
|
||||
return []DocumentOrderField{
|
||||
DocumentOrderFieldCreatedAt,
|
||||
DocumentOrderFieldUpdatedAt,
|
||||
DocumentOrderFieldTitle,
|
||||
DocumentOrderFieldDocumentType,
|
||||
}
|
||||
}
|
||||
|
||||
func (v DocumentOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
DocumentOrderFieldCreatedAt,
|
||||
DocumentOrderFieldUpdatedAt,
|
||||
DocumentOrderFieldTitle,
|
||||
DocumentOrderFieldDocumentType:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v DocumentOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v DocumentOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *DocumentOrderField) UnmarshalText(text []byte) error {
|
||||
val := DocumentOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid DocumentOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p DocumentOrderField) Column() string {
|
||||
switch p {
|
||||
case DocumentOrderFieldCreatedAt:
|
||||
@@ -41,32 +94,3 @@ func (p DocumentOrderField) Column() string {
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", p))
|
||||
}
|
||||
|
||||
func (p DocumentOrderField) IsValid() bool {
|
||||
switch p {
|
||||
case DocumentOrderFieldCreatedAt,
|
||||
DocumentOrderFieldUpdatedAt,
|
||||
DocumentOrderFieldTitle,
|
||||
DocumentOrderFieldDocumentType:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (p DocumentOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p DocumentOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *DocumentOrderField) UnmarshalText(text []byte) error {
|
||||
*p = DocumentOrderField(text)
|
||||
if !p.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid DocumentOrderField", string(text))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -26,39 +26,45 @@ const (
|
||||
DocumentStatusArchived DocumentStatus = "ARCHIVED"
|
||||
)
|
||||
|
||||
func (s DocumentStatus) IsValid() bool {
|
||||
switch s {
|
||||
case DocumentStatusActive, DocumentStatusArchived:
|
||||
var (
|
||||
_ fmt.Stringer = DocumentStatus("")
|
||||
_ encoding.TextMarshaler = DocumentStatus("")
|
||||
_ encoding.TextUnmarshaler = (*DocumentStatus)(nil)
|
||||
)
|
||||
|
||||
func DocumentStatuses() []DocumentStatus {
|
||||
return []DocumentStatus{
|
||||
DocumentStatusActive,
|
||||
DocumentStatusArchived,
|
||||
}
|
||||
}
|
||||
|
||||
func (v DocumentStatus) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
DocumentStatusActive,
|
||||
DocumentStatusArchived:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (s DocumentStatus) String() string { return string(s) }
|
||||
func (v DocumentStatus) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (s *DocumentStatus) UnmarshalText(text []byte) error {
|
||||
*s = DocumentStatus(text)
|
||||
if !s.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid DocumentStatus", string(text))
|
||||
func (v DocumentStatus) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *DocumentStatus) UnmarshalText(text []byte) error {
|
||||
val := DocumentStatus(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid DocumentStatus value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s DocumentStatus) MarshalText() ([]byte, error) {
|
||||
return []byte(s.String()), nil
|
||||
}
|
||||
|
||||
func (s *DocumentStatus) Scan(value any) error {
|
||||
val, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid scan source for DocumentStatus, expected string got %T", value)
|
||||
}
|
||||
|
||||
return s.UnmarshalText([]byte(val))
|
||||
}
|
||||
|
||||
func (s DocumentStatus) Value() (driver.Value, error) {
|
||||
return s.String(), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -36,6 +36,12 @@ const (
|
||||
DocumentTypeStatementOfApplicability DocumentType = "STATEMENT_OF_APPLICABILITY"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = DocumentType("")
|
||||
_ encoding.TextMarshaler = DocumentType("")
|
||||
_ encoding.TextUnmarshaler = (*DocumentType)(nil)
|
||||
)
|
||||
|
||||
func DocumentTypes() []DocumentType {
|
||||
return []DocumentType{
|
||||
DocumentTypeOther,
|
||||
@@ -51,54 +57,40 @@ func DocumentTypes() []DocumentType {
|
||||
}
|
||||
}
|
||||
|
||||
func (dt DocumentType) MarshalText() ([]byte, error) {
|
||||
return []byte(dt.String()), nil
|
||||
func (v DocumentType) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
DocumentTypeOther,
|
||||
DocumentTypeGovernance,
|
||||
DocumentTypePolicy,
|
||||
DocumentTypeProcedure,
|
||||
DocumentTypePlan,
|
||||
DocumentTypeRegister,
|
||||
DocumentTypeRecord,
|
||||
DocumentTypeReport,
|
||||
DocumentTypeTemplate,
|
||||
DocumentTypeStatementOfApplicability:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (dt *DocumentType) UnmarshalText(data []byte) error {
|
||||
val := string(data)
|
||||
func (v DocumentType) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
switch val {
|
||||
case DocumentTypeOther.String():
|
||||
*dt = DocumentTypeOther
|
||||
case DocumentTypeGovernance.String():
|
||||
*dt = DocumentTypeGovernance
|
||||
case DocumentTypePolicy.String():
|
||||
*dt = DocumentTypePolicy
|
||||
case DocumentTypeProcedure.String():
|
||||
*dt = DocumentTypeProcedure
|
||||
case DocumentTypePlan.String():
|
||||
*dt = DocumentTypePlan
|
||||
case DocumentTypeRegister.String():
|
||||
*dt = DocumentTypeRegister
|
||||
case DocumentTypeRecord.String():
|
||||
*dt = DocumentTypeRecord
|
||||
case DocumentTypeReport.String():
|
||||
*dt = DocumentTypeReport
|
||||
case DocumentTypeTemplate.String():
|
||||
*dt = DocumentTypeTemplate
|
||||
case DocumentTypeStatementOfApplicability.String():
|
||||
*dt = DocumentTypeStatementOfApplicability
|
||||
default:
|
||||
return fmt.Errorf("invalid DocumentType value: %q", val)
|
||||
func (v DocumentType) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *DocumentType) UnmarshalText(text []byte) error {
|
||||
val := DocumentType(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid DocumentType value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dt DocumentType) String() string {
|
||||
return string(dt)
|
||||
}
|
||||
|
||||
func (dt *DocumentType) Scan(value any) error {
|
||||
val, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid scan source for DocumentType, expected string got %T", value)
|
||||
}
|
||||
|
||||
return dt.UnmarshalText([]byte(val))
|
||||
}
|
||||
|
||||
func (dt DocumentType) Value() (driver.Value, error) {
|
||||
return dt.String(), nil
|
||||
}
|
||||
|
||||
@@ -14,7 +14,12 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
DocumentVersionApprovalDecisionOrderField string
|
||||
@@ -24,6 +29,48 @@ const (
|
||||
DocumentVersionApprovalDecisionOrderFieldCreatedAt DocumentVersionApprovalDecisionOrderField = "CREATED_AT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = DocumentVersionApprovalDecisionOrderField("")
|
||||
_ fmt.Stringer = DocumentVersionApprovalDecisionOrderField("")
|
||||
_ encoding.TextMarshaler = DocumentVersionApprovalDecisionOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*DocumentVersionApprovalDecisionOrderField)(nil)
|
||||
)
|
||||
|
||||
func DocumentVersionApprovalDecisionOrderFields() []DocumentVersionApprovalDecisionOrderField {
|
||||
return []DocumentVersionApprovalDecisionOrderField{
|
||||
DocumentVersionApprovalDecisionOrderFieldCreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v DocumentVersionApprovalDecisionOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
DocumentVersionApprovalDecisionOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v DocumentVersionApprovalDecisionOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v DocumentVersionApprovalDecisionOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *DocumentVersionApprovalDecisionOrderField) UnmarshalText(text []byte) error {
|
||||
val := DocumentVersionApprovalDecisionOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid DocumentVersionApprovalDecisionOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e DocumentVersionApprovalDecisionOrderField) Column() string {
|
||||
switch e {
|
||||
case DocumentVersionApprovalDecisionOrderFieldCreatedAt:
|
||||
@@ -32,27 +79,3 @@ func (e DocumentVersionApprovalDecisionOrderField) Column() string {
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", e))
|
||||
}
|
||||
|
||||
func (e DocumentVersionApprovalDecisionOrderField) IsValid() bool {
|
||||
switch e {
|
||||
case DocumentVersionApprovalDecisionOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (e DocumentVersionApprovalDecisionOrderField) String() string { return string(e) }
|
||||
|
||||
func (e *DocumentVersionApprovalDecisionOrderField) UnmarshalText(text []byte) error {
|
||||
*e = DocumentVersionApprovalDecisionOrderField(text)
|
||||
if !e.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid DocumentVersionApprovalDecisionOrderField", string(text))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e DocumentVersionApprovalDecisionOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(e.String()), nil
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
@@ -32,61 +33,44 @@ const (
|
||||
DocumentVersionApprovalDecisionStateVoided DocumentVersionApprovalDecisionState = "VOIDED"
|
||||
)
|
||||
|
||||
func (s DocumentVersionApprovalDecisionState) MarshalText() ([]byte, error) {
|
||||
return []byte(s.String()), nil
|
||||
var (
|
||||
_ fmt.Stringer = DocumentVersionApprovalDecisionState("")
|
||||
_ encoding.TextMarshaler = DocumentVersionApprovalDecisionState("")
|
||||
_ encoding.TextUnmarshaler = (*DocumentVersionApprovalDecisionState)(nil)
|
||||
)
|
||||
|
||||
func (v DocumentVersionApprovalDecisionState) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
DocumentVersionApprovalDecisionStatePending,
|
||||
DocumentVersionApprovalDecisionStateApproved,
|
||||
DocumentVersionApprovalDecisionStateRejected,
|
||||
DocumentVersionApprovalDecisionStateVoided:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *DocumentVersionApprovalDecisionState) UnmarshalText(data []byte) error {
|
||||
val := string(data)
|
||||
func (v DocumentVersionApprovalDecisionState) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
switch val {
|
||||
case DocumentVersionApprovalDecisionStatePending.String():
|
||||
*s = DocumentVersionApprovalDecisionStatePending
|
||||
case DocumentVersionApprovalDecisionStateApproved.String():
|
||||
*s = DocumentVersionApprovalDecisionStateApproved
|
||||
case DocumentVersionApprovalDecisionStateRejected.String():
|
||||
*s = DocumentVersionApprovalDecisionStateRejected
|
||||
case DocumentVersionApprovalDecisionStateVoided.String():
|
||||
*s = DocumentVersionApprovalDecisionStateVoided
|
||||
default:
|
||||
return fmt.Errorf("invalid DocumentVersionApprovalDecisionState value: %q", val)
|
||||
func (v DocumentVersionApprovalDecisionState) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *DocumentVersionApprovalDecisionState) UnmarshalText(text []byte) error {
|
||||
val := DocumentVersionApprovalDecisionState(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid DocumentVersionApprovalDecisionState value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s DocumentVersionApprovalDecisionState) String() string {
|
||||
var val string
|
||||
|
||||
switch s {
|
||||
case DocumentVersionApprovalDecisionStatePending:
|
||||
val = "PENDING"
|
||||
case DocumentVersionApprovalDecisionStateApproved:
|
||||
val = "APPROVED"
|
||||
case DocumentVersionApprovalDecisionStateRejected:
|
||||
val = "REJECTED"
|
||||
case DocumentVersionApprovalDecisionStateVoided:
|
||||
val = "VOIDED"
|
||||
default:
|
||||
panic(fmt.Errorf("invalid DocumentVersionApprovalDecisionState value: %q", string(s)))
|
||||
}
|
||||
|
||||
return val
|
||||
}
|
||||
|
||||
func (s *DocumentVersionApprovalDecisionState) Scan(value any) error {
|
||||
val, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid scan source for DocumentVersionApprovalDecisionState, expected string got %T", value)
|
||||
}
|
||||
|
||||
return s.UnmarshalText([]byte(val))
|
||||
}
|
||||
|
||||
func (s DocumentVersionApprovalDecisionState) Value() (driver.Value, error) {
|
||||
return s.String(), nil
|
||||
}
|
||||
|
||||
func (states DocumentVersionApprovalDecisionStates) Value() (driver.Value, error) {
|
||||
if len(states) == 0 {
|
||||
return nil, nil
|
||||
|
||||
@@ -14,7 +14,12 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
DocumentVersionApprovalQuorumOrderField string
|
||||
@@ -24,6 +29,48 @@ const (
|
||||
DocumentVersionApprovalQuorumOrderFieldCreatedAt DocumentVersionApprovalQuorumOrderField = "CREATED_AT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = DocumentVersionApprovalQuorumOrderField("")
|
||||
_ fmt.Stringer = DocumentVersionApprovalQuorumOrderField("")
|
||||
_ encoding.TextMarshaler = DocumentVersionApprovalQuorumOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*DocumentVersionApprovalQuorumOrderField)(nil)
|
||||
)
|
||||
|
||||
func DocumentVersionApprovalQuorumOrderFields() []DocumentVersionApprovalQuorumOrderField {
|
||||
return []DocumentVersionApprovalQuorumOrderField{
|
||||
DocumentVersionApprovalQuorumOrderFieldCreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v DocumentVersionApprovalQuorumOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
DocumentVersionApprovalQuorumOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v DocumentVersionApprovalQuorumOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v DocumentVersionApprovalQuorumOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *DocumentVersionApprovalQuorumOrderField) UnmarshalText(text []byte) error {
|
||||
val := DocumentVersionApprovalQuorumOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid DocumentVersionApprovalQuorumOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e DocumentVersionApprovalQuorumOrderField) Column() string {
|
||||
switch e {
|
||||
case DocumentVersionApprovalQuorumOrderFieldCreatedAt:
|
||||
@@ -32,27 +79,3 @@ func (e DocumentVersionApprovalQuorumOrderField) Column() string {
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", e))
|
||||
}
|
||||
|
||||
func (e DocumentVersionApprovalQuorumOrderField) IsValid() bool {
|
||||
switch e {
|
||||
case DocumentVersionApprovalQuorumOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (e DocumentVersionApprovalQuorumOrderField) String() string { return string(e) }
|
||||
|
||||
func (e *DocumentVersionApprovalQuorumOrderField) UnmarshalText(text []byte) error {
|
||||
*e = DocumentVersionApprovalQuorumOrderField(text)
|
||||
if !e.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid DocumentVersionApprovalQuorumOrderField", string(text))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e DocumentVersionApprovalQuorumOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(e.String()), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -28,57 +28,49 @@ const (
|
||||
DocumentVersionApprovalQuorumStatusVoided DocumentVersionApprovalQuorumStatus = "VOIDED"
|
||||
)
|
||||
|
||||
func (s DocumentVersionApprovalQuorumStatus) MarshalText() ([]byte, error) {
|
||||
return []byte(s.String()), nil
|
||||
var (
|
||||
_ fmt.Stringer = DocumentVersionApprovalQuorumStatus("")
|
||||
_ encoding.TextMarshaler = DocumentVersionApprovalQuorumStatus("")
|
||||
_ encoding.TextUnmarshaler = (*DocumentVersionApprovalQuorumStatus)(nil)
|
||||
)
|
||||
|
||||
func DocumentVersionApprovalQuorumStatuses() []DocumentVersionApprovalQuorumStatus {
|
||||
return []DocumentVersionApprovalQuorumStatus{
|
||||
DocumentVersionApprovalQuorumStatusPending,
|
||||
DocumentVersionApprovalQuorumStatusApproved,
|
||||
DocumentVersionApprovalQuorumStatusRejected,
|
||||
DocumentVersionApprovalQuorumStatusVoided,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DocumentVersionApprovalQuorumStatus) UnmarshalText(data []byte) error {
|
||||
val := string(data)
|
||||
|
||||
switch val {
|
||||
case DocumentVersionApprovalQuorumStatusPending.String():
|
||||
*s = DocumentVersionApprovalQuorumStatusPending
|
||||
case DocumentVersionApprovalQuorumStatusApproved.String():
|
||||
*s = DocumentVersionApprovalQuorumStatusApproved
|
||||
case DocumentVersionApprovalQuorumStatusRejected.String():
|
||||
*s = DocumentVersionApprovalQuorumStatusRejected
|
||||
case DocumentVersionApprovalQuorumStatusVoided.String():
|
||||
*s = DocumentVersionApprovalQuorumStatusVoided
|
||||
default:
|
||||
return fmt.Errorf("invalid DocumentVersionApprovalQuorumStatus value: %q", val)
|
||||
func (v DocumentVersionApprovalQuorumStatus) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
DocumentVersionApprovalQuorumStatusPending,
|
||||
DocumentVersionApprovalQuorumStatusApproved,
|
||||
DocumentVersionApprovalQuorumStatusRejected,
|
||||
DocumentVersionApprovalQuorumStatusVoided:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v DocumentVersionApprovalQuorumStatus) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v DocumentVersionApprovalQuorumStatus) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *DocumentVersionApprovalQuorumStatus) UnmarshalText(text []byte) error {
|
||||
val := DocumentVersionApprovalQuorumStatus(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid DocumentVersionApprovalQuorumStatus value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s DocumentVersionApprovalQuorumStatus) String() string {
|
||||
var val string
|
||||
|
||||
switch s {
|
||||
case DocumentVersionApprovalQuorumStatusPending:
|
||||
val = "PENDING"
|
||||
case DocumentVersionApprovalQuorumStatusApproved:
|
||||
val = "APPROVED"
|
||||
case DocumentVersionApprovalQuorumStatusRejected:
|
||||
val = "REJECTED"
|
||||
case DocumentVersionApprovalQuorumStatusVoided:
|
||||
val = "VOIDED"
|
||||
default:
|
||||
panic(fmt.Errorf("invalid DocumentVersionApprovalQuorumStatus value: %q", string(s)))
|
||||
}
|
||||
|
||||
return val
|
||||
}
|
||||
|
||||
func (s *DocumentVersionApprovalQuorumStatus) Scan(value any) error {
|
||||
val, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid scan source for DocumentVersionApprovalQuorumStatus, expected string got %T", value)
|
||||
}
|
||||
|
||||
return s.UnmarshalText([]byte(val))
|
||||
}
|
||||
|
||||
func (s DocumentVersionApprovalQuorumStatus) Value() (driver.Value, error) {
|
||||
return s.String(), nil
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
)
|
||||
@@ -26,6 +29,49 @@ const (
|
||||
EmployeeFilterModeApproval EmployeeFilterMode = "approval"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = EmployeeFilterMode("")
|
||||
_ encoding.TextMarshaler = EmployeeFilterMode("")
|
||||
_ encoding.TextUnmarshaler = (*EmployeeFilterMode)(nil)
|
||||
)
|
||||
|
||||
func EmployeeFilterModes() []EmployeeFilterMode {
|
||||
return []EmployeeFilterMode{
|
||||
EmployeeFilterModeSignature,
|
||||
EmployeeFilterModeApproval,
|
||||
}
|
||||
}
|
||||
|
||||
func (v EmployeeFilterMode) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
EmployeeFilterModeSignature,
|
||||
EmployeeFilterModeApproval:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v EmployeeFilterMode) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v EmployeeFilterMode) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *EmployeeFilterMode) UnmarshalText(text []byte) error {
|
||||
val := EmployeeFilterMode(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid EmployeeFilterMode value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type (
|
||||
DocumentVersionFilter struct {
|
||||
statuses []DocumentVersionStatus
|
||||
|
||||
@@ -14,6 +14,13 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
DocumentVersionOrderField string
|
||||
)
|
||||
@@ -22,19 +29,48 @@ const (
|
||||
DocumentVersionOrderFieldCreatedAt DocumentVersionOrderField = "CREATED_AT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = DocumentVersionOrderField("")
|
||||
_ fmt.Stringer = DocumentVersionOrderField("")
|
||||
_ encoding.TextMarshaler = DocumentVersionOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*DocumentVersionOrderField)(nil)
|
||||
)
|
||||
|
||||
func DocumentVersionOrderFields() []DocumentVersionOrderField {
|
||||
return []DocumentVersionOrderField{
|
||||
DocumentVersionOrderFieldCreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v DocumentVersionOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
DocumentVersionOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v DocumentVersionOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v DocumentVersionOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *DocumentVersionOrderField) UnmarshalText(text []byte) error {
|
||||
val := DocumentVersionOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid DocumentVersionOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p DocumentVersionOrderField) Column() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p DocumentVersionOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p DocumentVersionOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *DocumentVersionOrderField) UnmarshalText(text []byte) error {
|
||||
*p = DocumentVersionOrderField(text)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -28,6 +28,12 @@ const (
|
||||
DocumentVersionOrientationLandscape DocumentVersionOrientation = "LANDSCAPE"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = DocumentVersionOrientation("")
|
||||
_ encoding.TextMarshaler = DocumentVersionOrientation("")
|
||||
_ encoding.TextUnmarshaler = (*DocumentVersionOrientation)(nil)
|
||||
)
|
||||
|
||||
func DocumentVersionOrientations() []DocumentVersionOrientation {
|
||||
return []DocumentVersionOrientation{
|
||||
DocumentVersionOrientationPortrait,
|
||||
@@ -35,38 +41,32 @@ func DocumentVersionOrientations() []DocumentVersionOrientation {
|
||||
}
|
||||
}
|
||||
|
||||
func (o DocumentVersionOrientation) MarshalText() ([]byte, error) {
|
||||
return []byte(o.String()), nil
|
||||
func (v DocumentVersionOrientation) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
DocumentVersionOrientationPortrait,
|
||||
DocumentVersionOrientationLandscape:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (o *DocumentVersionOrientation) UnmarshalText(data []byte) error {
|
||||
val := string(data)
|
||||
func (v DocumentVersionOrientation) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
switch val {
|
||||
case DocumentVersionOrientationPortrait.String():
|
||||
*o = DocumentVersionOrientationPortrait
|
||||
case DocumentVersionOrientationLandscape.String():
|
||||
*o = DocumentVersionOrientationLandscape
|
||||
default:
|
||||
return fmt.Errorf("invalid DocumentVersionOrientation value: %q", val)
|
||||
func (v DocumentVersionOrientation) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *DocumentVersionOrientation) UnmarshalText(text []byte) error {
|
||||
val := DocumentVersionOrientation(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid DocumentVersionOrientation value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o DocumentVersionOrientation) String() string {
|
||||
return string(o)
|
||||
}
|
||||
|
||||
func (o *DocumentVersionOrientation) Scan(value any) error {
|
||||
val, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid scan source for DocumentVersionOrientation, expected string got %T", value)
|
||||
}
|
||||
|
||||
return o.UnmarshalText([]byte(val))
|
||||
}
|
||||
|
||||
func (o DocumentVersionOrientation) Value() (driver.Value, error) {
|
||||
return o.String(), nil
|
||||
}
|
||||
|
||||
@@ -14,6 +14,13 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
DocumentVersionSignatureOrderField string
|
||||
)
|
||||
@@ -23,19 +30,50 @@ const (
|
||||
DocumentVersionSignatureOrderFieldSignedAt DocumentVersionSignatureOrderField = "SIGNED_AT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = DocumentVersionSignatureOrderField("")
|
||||
_ fmt.Stringer = DocumentVersionSignatureOrderField("")
|
||||
_ encoding.TextMarshaler = DocumentVersionSignatureOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*DocumentVersionSignatureOrderField)(nil)
|
||||
)
|
||||
|
||||
func DocumentVersionSignatureOrderFields() []DocumentVersionSignatureOrderField {
|
||||
return []DocumentVersionSignatureOrderField{
|
||||
DocumentVersionSignatureOrderFieldCreatedAt,
|
||||
DocumentVersionSignatureOrderFieldSignedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v DocumentVersionSignatureOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
DocumentVersionSignatureOrderFieldCreatedAt,
|
||||
DocumentVersionSignatureOrderFieldSignedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v DocumentVersionSignatureOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v DocumentVersionSignatureOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *DocumentVersionSignatureOrderField) UnmarshalText(text []byte) error {
|
||||
val := DocumentVersionSignatureOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid DocumentVersionSignatureOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p DocumentVersionSignatureOrderField) Column() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p DocumentVersionSignatureOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p DocumentVersionSignatureOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *DocumentVersionSignatureOrderField) UnmarshalText(text []byte) error {
|
||||
*p = DocumentVersionSignatureOrderField(text)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
@@ -30,53 +31,42 @@ const (
|
||||
DocumentVersionSignatureStateSigned DocumentVersionSignatureState = "SIGNED"
|
||||
)
|
||||
|
||||
func (pvs DocumentVersionSignatureState) MarshalText() ([]byte, error) {
|
||||
return []byte(pvs.String()), nil
|
||||
var (
|
||||
_ fmt.Stringer = DocumentVersionSignatureState("")
|
||||
_ encoding.TextMarshaler = DocumentVersionSignatureState("")
|
||||
_ encoding.TextUnmarshaler = (*DocumentVersionSignatureState)(nil)
|
||||
)
|
||||
|
||||
func (v DocumentVersionSignatureState) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
DocumentVersionSignatureStateRequested,
|
||||
DocumentVersionSignatureStateSigned:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (pvs *DocumentVersionSignatureState) UnmarshalText(data []byte) error {
|
||||
val := string(data)
|
||||
func (v DocumentVersionSignatureState) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
switch val {
|
||||
case DocumentVersionSignatureStateRequested.String():
|
||||
*pvs = DocumentVersionSignatureStateRequested
|
||||
case DocumentVersionSignatureStateSigned.String():
|
||||
*pvs = DocumentVersionSignatureStateSigned
|
||||
default:
|
||||
return fmt.Errorf("invalid DocumentVersionSignatureState value: %q", val)
|
||||
func (v DocumentVersionSignatureState) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *DocumentVersionSignatureState) UnmarshalText(text []byte) error {
|
||||
val := DocumentVersionSignatureState(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid DocumentVersionSignatureState value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pvs DocumentVersionSignatureState) String() string {
|
||||
var val string
|
||||
|
||||
switch pvs {
|
||||
case DocumentVersionSignatureStateRequested:
|
||||
val = "REQUESTED"
|
||||
case DocumentVersionSignatureStateSigned:
|
||||
val = "SIGNED"
|
||||
default:
|
||||
panic(fmt.Errorf("invalid DocumentVersionSignatureState value: %q", string(pvs)))
|
||||
}
|
||||
|
||||
return val
|
||||
}
|
||||
|
||||
func (pvs *DocumentVersionSignatureState) Scan(value any) error {
|
||||
val, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid scan source for DocumentVersionSignatureState, expected string got %T", value)
|
||||
}
|
||||
|
||||
return pvs.UnmarshalText([]byte(val))
|
||||
}
|
||||
|
||||
func (pvs DocumentVersionSignatureState) Value() (driver.Value, error) {
|
||||
return pvs.String(), nil
|
||||
}
|
||||
|
||||
func (states DocumentVersionSignatureStates) Value() (driver.Value, error) {
|
||||
if len(states) == 0 {
|
||||
return nil, nil
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -29,49 +29,47 @@ const (
|
||||
DocumentVersionStatusPublished DocumentVersionStatus = "PUBLISHED"
|
||||
)
|
||||
|
||||
func (ps DocumentVersionStatus) MarshalText() ([]byte, error) {
|
||||
return []byte(ps.String()), nil
|
||||
var (
|
||||
_ fmt.Stringer = DocumentVersionStatus("")
|
||||
_ encoding.TextMarshaler = DocumentVersionStatus("")
|
||||
_ encoding.TextUnmarshaler = (*DocumentVersionStatus)(nil)
|
||||
)
|
||||
|
||||
func DocumentVersionStatuses() []DocumentVersionStatus {
|
||||
return []DocumentVersionStatus{
|
||||
DocumentVersionStatusDraft,
|
||||
DocumentVersionStatusPendingApproval,
|
||||
DocumentVersionStatusPublished,
|
||||
}
|
||||
}
|
||||
|
||||
func (ps *DocumentVersionStatus) UnmarshalText(data []byte) error {
|
||||
val := string(data)
|
||||
|
||||
switch val {
|
||||
case DocumentVersionStatusDraft.String():
|
||||
*ps = DocumentVersionStatusDraft
|
||||
case DocumentVersionStatusPendingApproval.String():
|
||||
*ps = DocumentVersionStatusPendingApproval
|
||||
case DocumentVersionStatusPublished.String():
|
||||
*ps = DocumentVersionStatusPublished
|
||||
default:
|
||||
return fmt.Errorf("invalid DocumentVersionStatus value: %q", val)
|
||||
func (v DocumentVersionStatus) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
DocumentVersionStatusDraft,
|
||||
DocumentVersionStatusPendingApproval,
|
||||
DocumentVersionStatusPublished:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v DocumentVersionStatus) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v DocumentVersionStatus) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *DocumentVersionStatus) UnmarshalText(text []byte) error {
|
||||
val := DocumentVersionStatus(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid DocumentVersionStatus value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ps DocumentVersionStatus) String() string {
|
||||
switch ps {
|
||||
case DocumentVersionStatusDraft:
|
||||
return "DRAFT"
|
||||
case DocumentVersionStatusPendingApproval:
|
||||
return "PENDING_APPROVAL"
|
||||
case DocumentVersionStatusPublished:
|
||||
return "PUBLISHED"
|
||||
default:
|
||||
panic(fmt.Errorf("invalid DocumentVersionStatus value: %q", string(ps)))
|
||||
}
|
||||
}
|
||||
|
||||
func (ps *DocumentVersionStatus) Scan(value any) error {
|
||||
val, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid scan source for DocumentVersionStatus, expected string got %T", value)
|
||||
}
|
||||
|
||||
return ps.UnmarshalText([]byte(val))
|
||||
}
|
||||
|
||||
func (ps DocumentVersionStatus) Value() (driver.Value, error) {
|
||||
return ps.String(), nil
|
||||
}
|
||||
|
||||
@@ -14,7 +14,10 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type (
|
||||
DocumentWriteMode string
|
||||
@@ -25,26 +28,45 @@ const (
|
||||
DocumentWriteModeGenerated DocumentWriteMode = "GENERATED"
|
||||
)
|
||||
|
||||
func (e DocumentWriteMode) IsValid() bool {
|
||||
switch e {
|
||||
case DocumentWriteModeAuthored, DocumentWriteModeGenerated:
|
||||
var (
|
||||
_ fmt.Stringer = DocumentWriteMode("")
|
||||
_ encoding.TextMarshaler = DocumentWriteMode("")
|
||||
_ encoding.TextUnmarshaler = (*DocumentWriteMode)(nil)
|
||||
)
|
||||
|
||||
func DocumentWriteModes() []DocumentWriteMode {
|
||||
return []DocumentWriteMode{
|
||||
DocumentWriteModeAuthored,
|
||||
DocumentWriteModeGenerated,
|
||||
}
|
||||
}
|
||||
|
||||
func (v DocumentWriteMode) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
DocumentWriteModeAuthored,
|
||||
DocumentWriteModeGenerated:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (e DocumentWriteMode) String() string { return string(e) }
|
||||
func (v DocumentWriteMode) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (e *DocumentWriteMode) UnmarshalText(text []byte) error {
|
||||
*e = DocumentWriteMode(text)
|
||||
if !e.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid DocumentWriteMode", string(text))
|
||||
func (v DocumentWriteMode) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *DocumentWriteMode) UnmarshalText(text []byte) error {
|
||||
val := DocumentWriteMode(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid DocumentWriteMode value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e DocumentWriteMode) MarshalText() ([]byte, error) {
|
||||
return []byte(e.String()), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -45,6 +45,12 @@ const (
|
||||
ESignProcessConsentText = "By typing my full name and clicking Accept, I consent to sign this document electronically and agree that my electronic signature has the same legal validity as a handwritten signature."
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = ElectronicSignatureDocumentType("")
|
||||
_ encoding.TextMarshaler = ElectronicSignatureDocumentType("")
|
||||
_ encoding.TextUnmarshaler = (*ElectronicSignatureDocumentType)(nil)
|
||||
)
|
||||
|
||||
func ElectronicSignatureDocumentTypes() []ElectronicSignatureDocumentType {
|
||||
return []ElectronicSignatureDocumentType{
|
||||
ElectronicSignatureDocumentTypeNDA,
|
||||
@@ -67,72 +73,51 @@ func ElectronicSignatureDocumentTypes() []ElectronicSignatureDocumentType {
|
||||
}
|
||||
}
|
||||
|
||||
func (dt ElectronicSignatureDocumentType) MarshalText() ([]byte, error) {
|
||||
return []byte(dt.String()), nil
|
||||
func (v ElectronicSignatureDocumentType) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
ElectronicSignatureDocumentTypeNDA,
|
||||
ElectronicSignatureDocumentTypeDPA,
|
||||
ElectronicSignatureDocumentTypeMSA,
|
||||
ElectronicSignatureDocumentTypeSOW,
|
||||
ElectronicSignatureDocumentTypeSLA,
|
||||
ElectronicSignatureDocumentTypeTOS,
|
||||
ElectronicSignatureDocumentTypePrivacyPolicy,
|
||||
ElectronicSignatureDocumentTypeGovernance,
|
||||
ElectronicSignatureDocumentTypePolicy,
|
||||
ElectronicSignatureDocumentTypeProcedure,
|
||||
ElectronicSignatureDocumentTypePlan,
|
||||
ElectronicSignatureDocumentTypeRegister,
|
||||
ElectronicSignatureDocumentTypeRecord,
|
||||
ElectronicSignatureDocumentTypeReport,
|
||||
ElectronicSignatureDocumentTypeTemplate,
|
||||
ElectronicSignatureDocumentTypeStatementOfApplicability,
|
||||
ElectronicSignatureDocumentTypeOther:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (dt *ElectronicSignatureDocumentType) UnmarshalText(data []byte) error {
|
||||
val := string(data)
|
||||
func (v ElectronicSignatureDocumentType) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
switch val {
|
||||
case ElectronicSignatureDocumentTypeNDA.String():
|
||||
*dt = ElectronicSignatureDocumentTypeNDA
|
||||
case ElectronicSignatureDocumentTypeDPA.String():
|
||||
*dt = ElectronicSignatureDocumentTypeDPA
|
||||
case ElectronicSignatureDocumentTypeMSA.String():
|
||||
*dt = ElectronicSignatureDocumentTypeMSA
|
||||
case ElectronicSignatureDocumentTypeSOW.String():
|
||||
*dt = ElectronicSignatureDocumentTypeSOW
|
||||
case ElectronicSignatureDocumentTypeSLA.String():
|
||||
*dt = ElectronicSignatureDocumentTypeSLA
|
||||
case ElectronicSignatureDocumentTypeTOS.String():
|
||||
*dt = ElectronicSignatureDocumentTypeTOS
|
||||
case ElectronicSignatureDocumentTypePrivacyPolicy.String():
|
||||
*dt = ElectronicSignatureDocumentTypePrivacyPolicy
|
||||
case ElectronicSignatureDocumentTypeGovernance.String():
|
||||
*dt = ElectronicSignatureDocumentTypeGovernance
|
||||
case ElectronicSignatureDocumentTypePolicy.String():
|
||||
*dt = ElectronicSignatureDocumentTypePolicy
|
||||
case ElectronicSignatureDocumentTypeProcedure.String():
|
||||
*dt = ElectronicSignatureDocumentTypeProcedure
|
||||
case ElectronicSignatureDocumentTypePlan.String():
|
||||
*dt = ElectronicSignatureDocumentTypePlan
|
||||
case ElectronicSignatureDocumentTypeRegister.String():
|
||||
*dt = ElectronicSignatureDocumentTypeRegister
|
||||
case ElectronicSignatureDocumentTypeRecord.String():
|
||||
*dt = ElectronicSignatureDocumentTypeRecord
|
||||
case ElectronicSignatureDocumentTypeReport.String():
|
||||
*dt = ElectronicSignatureDocumentTypeReport
|
||||
case ElectronicSignatureDocumentTypeTemplate.String():
|
||||
*dt = ElectronicSignatureDocumentTypeTemplate
|
||||
case ElectronicSignatureDocumentTypeStatementOfApplicability.String():
|
||||
*dt = ElectronicSignatureDocumentTypeStatementOfApplicability
|
||||
case ElectronicSignatureDocumentTypeOther.String():
|
||||
*dt = ElectronicSignatureDocumentTypeOther
|
||||
default:
|
||||
return fmt.Errorf("cannot unmarshal ElectronicSignatureDocumentType: invalid value %q", val)
|
||||
func (v ElectronicSignatureDocumentType) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *ElectronicSignatureDocumentType) UnmarshalText(text []byte) error {
|
||||
val := ElectronicSignatureDocumentType(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid ElectronicSignatureDocumentType value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dt ElectronicSignatureDocumentType) String() string {
|
||||
return string(dt)
|
||||
}
|
||||
|
||||
func (dt *ElectronicSignatureDocumentType) Scan(value any) error {
|
||||
val, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot scan ElectronicSignatureDocumentType: expected string, got %T", value)
|
||||
}
|
||||
|
||||
return dt.UnmarshalText([]byte(val))
|
||||
}
|
||||
|
||||
func (dt ElectronicSignatureDocumentType) Value() (driver.Value, error) {
|
||||
return dt.String(), nil
|
||||
}
|
||||
|
||||
func (dt ElectronicSignatureDocumentType) DisplayName() string {
|
||||
switch dt {
|
||||
case ElectronicSignatureDocumentTypeNDA:
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -28,38 +28,45 @@ const (
|
||||
ElectronicSignatureEventSourceServer ElectronicSignatureEventSource = "SERVER"
|
||||
)
|
||||
|
||||
func (s ElectronicSignatureEventSource) MarshalText() ([]byte, error) {
|
||||
return []byte(s.String()), nil
|
||||
var (
|
||||
_ fmt.Stringer = ElectronicSignatureEventSource("")
|
||||
_ encoding.TextMarshaler = ElectronicSignatureEventSource("")
|
||||
_ encoding.TextUnmarshaler = (*ElectronicSignatureEventSource)(nil)
|
||||
)
|
||||
|
||||
func ElectronicSignatureEventSources() []ElectronicSignatureEventSource {
|
||||
return []ElectronicSignatureEventSource{
|
||||
ElectronicSignatureEventSourceClient,
|
||||
ElectronicSignatureEventSourceServer,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ElectronicSignatureEventSource) UnmarshalText(data []byte) error {
|
||||
val := string(data)
|
||||
|
||||
switch val {
|
||||
case ElectronicSignatureEventSourceClient.String():
|
||||
*s = ElectronicSignatureEventSourceClient
|
||||
case ElectronicSignatureEventSourceServer.String():
|
||||
*s = ElectronicSignatureEventSourceServer
|
||||
default:
|
||||
return fmt.Errorf("invalid ElectronicSignatureEventSource value: %q", val)
|
||||
func (v ElectronicSignatureEventSource) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
ElectronicSignatureEventSourceClient,
|
||||
ElectronicSignatureEventSourceServer:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v ElectronicSignatureEventSource) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v ElectronicSignatureEventSource) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *ElectronicSignatureEventSource) UnmarshalText(text []byte) error {
|
||||
val := ElectronicSignatureEventSource(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid ElectronicSignatureEventSource value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s ElectronicSignatureEventSource) String() string {
|
||||
return string(s)
|
||||
}
|
||||
|
||||
func (s *ElectronicSignatureEventSource) Scan(value any) error {
|
||||
val, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid scan source for ElectronicSignatureEventSource, expected string got %T", value)
|
||||
}
|
||||
|
||||
return s.UnmarshalText([]byte(val))
|
||||
}
|
||||
|
||||
func (s ElectronicSignatureEventSource) Value() (driver.Value, error) {
|
||||
return s.String(), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -35,58 +35,59 @@ const (
|
||||
ElectronicSignatureEventTypeProcessingError ElectronicSignatureEventType = "PROCESSING_ERROR"
|
||||
)
|
||||
|
||||
func (t ElectronicSignatureEventType) MarshalText() ([]byte, error) {
|
||||
return []byte(t.String()), nil
|
||||
var (
|
||||
_ fmt.Stringer = ElectronicSignatureEventType("")
|
||||
_ encoding.TextMarshaler = ElectronicSignatureEventType("")
|
||||
_ encoding.TextUnmarshaler = (*ElectronicSignatureEventType)(nil)
|
||||
)
|
||||
|
||||
func ElectronicSignatureEventTypes() []ElectronicSignatureEventType {
|
||||
return []ElectronicSignatureEventType{
|
||||
ElectronicSignatureEventTypeDocumentViewed,
|
||||
ElectronicSignatureEventTypeConsentGiven,
|
||||
ElectronicSignatureEventTypeFullNameTyped,
|
||||
ElectronicSignatureEventTypeSignatureAccepted,
|
||||
ElectronicSignatureEventTypeSignatureCompleted,
|
||||
ElectronicSignatureEventTypeSealComputed,
|
||||
ElectronicSignatureEventTypeTimestampRequested,
|
||||
ElectronicSignatureEventTypeCertificateGenerated,
|
||||
ElectronicSignatureEventTypeProcessingError,
|
||||
}
|
||||
}
|
||||
|
||||
func (t *ElectronicSignatureEventType) UnmarshalText(data []byte) error {
|
||||
val := string(data)
|
||||
|
||||
switch val {
|
||||
case ElectronicSignatureEventTypeDocumentViewed.String():
|
||||
*t = ElectronicSignatureEventTypeDocumentViewed
|
||||
case ElectronicSignatureEventTypeConsentGiven.String():
|
||||
*t = ElectronicSignatureEventTypeConsentGiven
|
||||
case ElectronicSignatureEventTypeFullNameTyped.String():
|
||||
*t = ElectronicSignatureEventTypeFullNameTyped
|
||||
case ElectronicSignatureEventTypeSignatureAccepted.String():
|
||||
*t = ElectronicSignatureEventTypeSignatureAccepted
|
||||
case ElectronicSignatureEventTypeSignatureCompleted.String():
|
||||
*t = ElectronicSignatureEventTypeSignatureCompleted
|
||||
case ElectronicSignatureEventTypeSealComputed.String():
|
||||
*t = ElectronicSignatureEventTypeSealComputed
|
||||
case ElectronicSignatureEventTypeTimestampRequested.String():
|
||||
*t = ElectronicSignatureEventTypeTimestampRequested
|
||||
case ElectronicSignatureEventTypeCertificateGenerated.String():
|
||||
*t = ElectronicSignatureEventTypeCertificateGenerated
|
||||
case ElectronicSignatureEventTypeProcessingError.String():
|
||||
*t = ElectronicSignatureEventTypeProcessingError
|
||||
default:
|
||||
return fmt.Errorf("invalid ElectronicSignatureEventType value: %q", val)
|
||||
func (v ElectronicSignatureEventType) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
ElectronicSignatureEventTypeDocumentViewed,
|
||||
ElectronicSignatureEventTypeConsentGiven,
|
||||
ElectronicSignatureEventTypeFullNameTyped,
|
||||
ElectronicSignatureEventTypeSignatureAccepted,
|
||||
ElectronicSignatureEventTypeSignatureCompleted,
|
||||
ElectronicSignatureEventTypeSealComputed,
|
||||
ElectronicSignatureEventTypeTimestampRequested,
|
||||
ElectronicSignatureEventTypeCertificateGenerated,
|
||||
ElectronicSignatureEventTypeProcessingError:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v ElectronicSignatureEventType) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v ElectronicSignatureEventType) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *ElectronicSignatureEventType) UnmarshalText(text []byte) error {
|
||||
val := ElectronicSignatureEventType(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid ElectronicSignatureEventType value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t ElectronicSignatureEventType) String() string {
|
||||
return string(t)
|
||||
}
|
||||
|
||||
func (t *ElectronicSignatureEventType) Scan(value any) error {
|
||||
var s string
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
s = v
|
||||
case []byte:
|
||||
s = string(v)
|
||||
default:
|
||||
return fmt.Errorf("invalid scan source for ElectronicSignatureEventType, expected string or []byte got %T", value)
|
||||
}
|
||||
|
||||
return t.UnmarshalText([]byte(s))
|
||||
}
|
||||
|
||||
func (t ElectronicSignatureEventType) Value() (driver.Value, error) {
|
||||
return t.String(), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -31,44 +31,51 @@ const (
|
||||
ElectronicSignatureStatusFailed ElectronicSignatureStatus = "FAILED"
|
||||
)
|
||||
|
||||
func (s ElectronicSignatureStatus) MarshalText() ([]byte, error) {
|
||||
return []byte(s.String()), nil
|
||||
var (
|
||||
_ fmt.Stringer = ElectronicSignatureStatus("")
|
||||
_ encoding.TextMarshaler = ElectronicSignatureStatus("")
|
||||
_ encoding.TextUnmarshaler = (*ElectronicSignatureStatus)(nil)
|
||||
)
|
||||
|
||||
func ElectronicSignatureStatuses() []ElectronicSignatureStatus {
|
||||
return []ElectronicSignatureStatus{
|
||||
ElectronicSignatureStatusPending,
|
||||
ElectronicSignatureStatusAccepted,
|
||||
ElectronicSignatureStatusProcessing,
|
||||
ElectronicSignatureStatusCompleted,
|
||||
ElectronicSignatureStatusFailed,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ElectronicSignatureStatus) UnmarshalText(data []byte) error {
|
||||
val := string(data)
|
||||
|
||||
switch val {
|
||||
case ElectronicSignatureStatusPending.String():
|
||||
*s = ElectronicSignatureStatusPending
|
||||
case ElectronicSignatureStatusAccepted.String():
|
||||
*s = ElectronicSignatureStatusAccepted
|
||||
case ElectronicSignatureStatusProcessing.String():
|
||||
*s = ElectronicSignatureStatusProcessing
|
||||
case ElectronicSignatureStatusCompleted.String():
|
||||
*s = ElectronicSignatureStatusCompleted
|
||||
case ElectronicSignatureStatusFailed.String():
|
||||
*s = ElectronicSignatureStatusFailed
|
||||
default:
|
||||
return fmt.Errorf("invalid ElectronicSignatureStatus value: %q", val)
|
||||
func (v ElectronicSignatureStatus) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
ElectronicSignatureStatusPending,
|
||||
ElectronicSignatureStatusAccepted,
|
||||
ElectronicSignatureStatusProcessing,
|
||||
ElectronicSignatureStatusCompleted,
|
||||
ElectronicSignatureStatusFailed:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v ElectronicSignatureStatus) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v ElectronicSignatureStatus) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *ElectronicSignatureStatus) UnmarshalText(text []byte) error {
|
||||
val := ElectronicSignatureStatus(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid ElectronicSignatureStatus value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s ElectronicSignatureStatus) String() string {
|
||||
return string(s)
|
||||
}
|
||||
|
||||
func (s *ElectronicSignatureStatus) Scan(value any) error {
|
||||
val, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid scan source for ElectronicSignatureStatus, expected string got %T", value)
|
||||
}
|
||||
|
||||
return s.UnmarshalText([]byte(val))
|
||||
}
|
||||
|
||||
func (s ElectronicSignatureStatus) Value() (driver.Value, error) {
|
||||
return s.String(), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -30,44 +30,49 @@ const (
|
||||
EmailStatusFailed EmailStatus = "FAILED"
|
||||
)
|
||||
|
||||
func (s EmailStatus) MarshalText() ([]byte, error) {
|
||||
return []byte(s.String()), nil
|
||||
var (
|
||||
_ fmt.Stringer = EmailStatus("")
|
||||
_ encoding.TextMarshaler = EmailStatus("")
|
||||
_ encoding.TextUnmarshaler = (*EmailStatus)(nil)
|
||||
)
|
||||
|
||||
func EmailStatuses() []EmailStatus {
|
||||
return []EmailStatus{
|
||||
EmailStatusPending,
|
||||
EmailStatusProcessing,
|
||||
EmailStatusSent,
|
||||
EmailStatusFailed,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *EmailStatus) UnmarshalText(data []byte) error {
|
||||
val := string(data)
|
||||
|
||||
switch val {
|
||||
case EmailStatusPending.String():
|
||||
*s = EmailStatusPending
|
||||
case EmailStatusProcessing.String():
|
||||
*s = EmailStatusProcessing
|
||||
case EmailStatusSent.String():
|
||||
*s = EmailStatusSent
|
||||
case EmailStatusFailed.String():
|
||||
*s = EmailStatusFailed
|
||||
default:
|
||||
return fmt.Errorf("invalid EmailStatus value: %q", val)
|
||||
func (v EmailStatus) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
EmailStatusPending,
|
||||
EmailStatusProcessing,
|
||||
EmailStatusSent,
|
||||
EmailStatusFailed:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v EmailStatus) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v EmailStatus) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *EmailStatus) UnmarshalText(text []byte) error {
|
||||
val := EmailStatus(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid EmailStatus value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s EmailStatus) String() string {
|
||||
return string(s)
|
||||
}
|
||||
|
||||
func (s *EmailStatus) Scan(value any) error {
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
return s.UnmarshalText([]byte(v))
|
||||
case []byte:
|
||||
return s.UnmarshalText(v)
|
||||
default:
|
||||
return fmt.Errorf("invalid scan source for EmailStatus, expected string or []byte got %T", value)
|
||||
}
|
||||
}
|
||||
|
||||
func (s EmailStatus) Value() (driver.Value, error) {
|
||||
return s.String(), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -30,42 +30,49 @@ const (
|
||||
EvidenceDescriptionStatusFailed EvidenceDescriptionStatus = "FAILED"
|
||||
)
|
||||
|
||||
func (s EvidenceDescriptionStatus) MarshalText() ([]byte, error) {
|
||||
return []byte(s.String()), nil
|
||||
var (
|
||||
_ fmt.Stringer = EvidenceDescriptionStatus("")
|
||||
_ encoding.TextMarshaler = EvidenceDescriptionStatus("")
|
||||
_ encoding.TextUnmarshaler = (*EvidenceDescriptionStatus)(nil)
|
||||
)
|
||||
|
||||
func EvidenceDescriptionStatuses() []EvidenceDescriptionStatus {
|
||||
return []EvidenceDescriptionStatus{
|
||||
EvidenceDescriptionStatusPending,
|
||||
EvidenceDescriptionStatusProcessing,
|
||||
EvidenceDescriptionStatusCompleted,
|
||||
EvidenceDescriptionStatusFailed,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *EvidenceDescriptionStatus) UnmarshalText(data []byte) error {
|
||||
val := string(data)
|
||||
|
||||
switch val {
|
||||
case EvidenceDescriptionStatusPending.String():
|
||||
*s = EvidenceDescriptionStatusPending
|
||||
case EvidenceDescriptionStatusProcessing.String():
|
||||
*s = EvidenceDescriptionStatusProcessing
|
||||
case EvidenceDescriptionStatusCompleted.String():
|
||||
*s = EvidenceDescriptionStatusCompleted
|
||||
case EvidenceDescriptionStatusFailed.String():
|
||||
*s = EvidenceDescriptionStatusFailed
|
||||
default:
|
||||
return fmt.Errorf("invalid EvidenceDescriptionStatus value: %q", val)
|
||||
func (v EvidenceDescriptionStatus) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
EvidenceDescriptionStatusPending,
|
||||
EvidenceDescriptionStatusProcessing,
|
||||
EvidenceDescriptionStatusCompleted,
|
||||
EvidenceDescriptionStatusFailed:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v EvidenceDescriptionStatus) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v EvidenceDescriptionStatus) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *EvidenceDescriptionStatus) UnmarshalText(text []byte) error {
|
||||
val := EvidenceDescriptionStatus(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid EvidenceDescriptionStatus value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s EvidenceDescriptionStatus) String() string {
|
||||
return string(s)
|
||||
}
|
||||
|
||||
func (s *EvidenceDescriptionStatus) Scan(value any) error {
|
||||
val, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid scan source for EvidenceDescriptionStatus, expected string got %T", value)
|
||||
}
|
||||
|
||||
return s.UnmarshalText([]byte(val))
|
||||
}
|
||||
|
||||
func (s EvidenceDescriptionStatus) Value() (driver.Value, error) {
|
||||
return s.String(), nil
|
||||
}
|
||||
|
||||
@@ -14,6 +14,13 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
EvidenceOrderField string
|
||||
)
|
||||
@@ -22,19 +29,48 @@ const (
|
||||
EvidenceOrderFieldCreatedAt EvidenceOrderField = "CREATED_AT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = EvidenceOrderField("")
|
||||
_ fmt.Stringer = EvidenceOrderField("")
|
||||
_ encoding.TextMarshaler = EvidenceOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*EvidenceOrderField)(nil)
|
||||
)
|
||||
|
||||
func EvidenceOrderFields() []EvidenceOrderField {
|
||||
return []EvidenceOrderField{
|
||||
EvidenceOrderFieldCreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v EvidenceOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
EvidenceOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v EvidenceOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v EvidenceOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *EvidenceOrderField) UnmarshalText(text []byte) error {
|
||||
val := EvidenceOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid EvidenceOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p EvidenceOrderField) Column() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p EvidenceOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p EvidenceOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *EvidenceOrderField) UnmarshalText(text []byte) error {
|
||||
*p = EvidenceOrderField(text)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -28,36 +28,45 @@ const (
|
||||
EvidenceStateFulfilled EvidenceState = "FULFILLED"
|
||||
)
|
||||
|
||||
func (es EvidenceState) MarshalText() ([]byte, error) {
|
||||
return []byte(es), nil
|
||||
var (
|
||||
_ fmt.Stringer = EvidenceState("")
|
||||
_ encoding.TextMarshaler = EvidenceState("")
|
||||
_ encoding.TextUnmarshaler = (*EvidenceState)(nil)
|
||||
)
|
||||
|
||||
func EvidenceStates() []EvidenceState {
|
||||
return []EvidenceState{
|
||||
EvidenceStateRequested,
|
||||
EvidenceStateFulfilled,
|
||||
}
|
||||
}
|
||||
|
||||
func (es *EvidenceState) UnmarshalText(data []byte) error {
|
||||
val := EvidenceState(data)
|
||||
|
||||
switch val {
|
||||
case EvidenceStateRequested, EvidenceStateFulfilled:
|
||||
*es = val
|
||||
default:
|
||||
return fmt.Errorf("invalid EvidenceState value: %q", val)
|
||||
func (v EvidenceState) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
EvidenceStateRequested,
|
||||
EvidenceStateFulfilled:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v EvidenceState) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v EvidenceState) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *EvidenceState) UnmarshalText(text []byte) error {
|
||||
val := EvidenceState(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid EvidenceState value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (es EvidenceState) String() string {
|
||||
return string(es)
|
||||
}
|
||||
|
||||
func (es *EvidenceState) Scan(value any) error {
|
||||
val, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid scan source for EvidenceState, expected string got %T", value)
|
||||
}
|
||||
|
||||
return es.UnmarshalText([]byte(val))
|
||||
}
|
||||
|
||||
func (es EvidenceState) Value() (driver.Value, error) {
|
||||
return string(es), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -28,36 +28,45 @@ const (
|
||||
EvidenceTypeLink EvidenceType = "LINK"
|
||||
)
|
||||
|
||||
func (et EvidenceType) MarshalText() ([]byte, error) {
|
||||
return []byte(et), nil
|
||||
var (
|
||||
_ fmt.Stringer = EvidenceType("")
|
||||
_ encoding.TextMarshaler = EvidenceType("")
|
||||
_ encoding.TextUnmarshaler = (*EvidenceType)(nil)
|
||||
)
|
||||
|
||||
func EvidenceTypes() []EvidenceType {
|
||||
return []EvidenceType{
|
||||
EvidenceTypeFile,
|
||||
EvidenceTypeLink,
|
||||
}
|
||||
}
|
||||
|
||||
func (et *EvidenceType) UnmarshalText(data []byte) error {
|
||||
val := EvidenceType(data)
|
||||
|
||||
switch val {
|
||||
case EvidenceTypeFile, EvidenceTypeLink:
|
||||
*et = val
|
||||
default:
|
||||
return fmt.Errorf("invalid EvidenceType value: %q", val)
|
||||
func (v EvidenceType) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
EvidenceTypeFile,
|
||||
EvidenceTypeLink:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v EvidenceType) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v EvidenceType) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *EvidenceType) UnmarshalText(text []byte) error {
|
||||
val := EvidenceType(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid EvidenceType value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (et EvidenceType) String() string {
|
||||
return string(et)
|
||||
}
|
||||
|
||||
func (et *EvidenceType) Scan(value any) error {
|
||||
val, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid scan source for EvidenceType, expected string got %T", value)
|
||||
}
|
||||
|
||||
return et.UnmarshalText([]byte(val))
|
||||
}
|
||||
|
||||
func (et EvidenceType) Value() (driver.Value, error) {
|
||||
return string(et), nil
|
||||
}
|
||||
|
||||
@@ -14,6 +14,11 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type (
|
||||
ExpireReason string
|
||||
)
|
||||
@@ -23,3 +28,48 @@ const (
|
||||
ExpireReasonRevoked ExpireReason = "revoked"
|
||||
ExpireReasonClosed ExpireReason = "closed"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = ExpireReason("")
|
||||
_ encoding.TextMarshaler = ExpireReason("")
|
||||
_ encoding.TextUnmarshaler = (*ExpireReason)(nil)
|
||||
)
|
||||
|
||||
func ExpireReasons() []ExpireReason {
|
||||
return []ExpireReason{
|
||||
ExpireReasonIdleTimeout,
|
||||
ExpireReasonRevoked,
|
||||
ExpireReasonClosed,
|
||||
}
|
||||
}
|
||||
|
||||
func (v ExpireReason) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
ExpireReasonIdleTimeout,
|
||||
ExpireReasonRevoked,
|
||||
ExpireReasonClosed:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v ExpireReason) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v ExpireReason) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *ExpireReason) UnmarshalText(text []byte) error {
|
||||
val := ExpireReason(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid ExpireReason value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -30,38 +30,49 @@ const (
|
||||
ExportJobStatusFailed ExportJobStatus = "FAILED"
|
||||
)
|
||||
|
||||
func (ejs ExportJobStatus) String() string {
|
||||
return string(ejs)
|
||||
var (
|
||||
_ fmt.Stringer = ExportJobStatus("")
|
||||
_ encoding.TextMarshaler = ExportJobStatus("")
|
||||
_ encoding.TextUnmarshaler = (*ExportJobStatus)(nil)
|
||||
)
|
||||
|
||||
func ExportJobStatuses() []ExportJobStatus {
|
||||
return []ExportJobStatus{
|
||||
ExportJobStatusPending,
|
||||
ExportJobStatusProcessing,
|
||||
ExportJobStatusCompleted,
|
||||
ExportJobStatusFailed,
|
||||
}
|
||||
}
|
||||
|
||||
func (ejs *ExportJobStatus) Scan(value any) error {
|
||||
var s string
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
s = v
|
||||
case []byte:
|
||||
s = string(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for ExportJobStatus: %T", value)
|
||||
func (v ExportJobStatus) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
ExportJobStatusPending,
|
||||
ExportJobStatusProcessing,
|
||||
ExportJobStatusCompleted,
|
||||
ExportJobStatusFailed:
|
||||
return true
|
||||
}
|
||||
|
||||
switch s {
|
||||
case ExportJobStatusPending.String():
|
||||
*ejs = ExportJobStatusPending
|
||||
case ExportJobStatusProcessing.String():
|
||||
*ejs = ExportJobStatusProcessing
|
||||
case ExportJobStatusCompleted.String():
|
||||
*ejs = ExportJobStatusCompleted
|
||||
case ExportJobStatusFailed.String():
|
||||
*ejs = ExportJobStatusFailed
|
||||
default:
|
||||
return fmt.Errorf("invalid ExportJobStatus value: %q", s)
|
||||
return false
|
||||
}
|
||||
|
||||
func (v ExportJobStatus) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v ExportJobStatus) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *ExportJobStatus) UnmarshalText(text []byte) error {
|
||||
val := ExportJobStatus(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid ExportJobStatus value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ejs ExportJobStatus) Value() (driver.Value, error) {
|
||||
return ejs.String(), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -28,34 +28,45 @@ const (
|
||||
ExportJobTypeDocument ExportJobType = "DOCUMENT"
|
||||
)
|
||||
|
||||
func (ejt ExportJobType) String() string {
|
||||
return string(ejt)
|
||||
var (
|
||||
_ fmt.Stringer = ExportJobType("")
|
||||
_ encoding.TextMarshaler = ExportJobType("")
|
||||
_ encoding.TextUnmarshaler = (*ExportJobType)(nil)
|
||||
)
|
||||
|
||||
func ExportJobTypes() []ExportJobType {
|
||||
return []ExportJobType{
|
||||
ExportJobTypeFramework,
|
||||
ExportJobTypeDocument,
|
||||
}
|
||||
}
|
||||
|
||||
func (ejt *ExportJobType) Scan(value any) error {
|
||||
var s string
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
s = v
|
||||
case []byte:
|
||||
s = string(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for ExportJobType: %T", value)
|
||||
func (v ExportJobType) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
ExportJobTypeFramework,
|
||||
ExportJobTypeDocument:
|
||||
return true
|
||||
}
|
||||
|
||||
switch s {
|
||||
case ExportJobTypeFramework.String():
|
||||
*ejt = ExportJobTypeFramework
|
||||
case ExportJobTypeDocument.String():
|
||||
*ejt = ExportJobTypeDocument
|
||||
default:
|
||||
return fmt.Errorf("invalid ExportJobType value: %q", s)
|
||||
return false
|
||||
}
|
||||
|
||||
func (v ExportJobType) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v ExportJobType) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *ExportJobType) UnmarshalText(text []byte) error {
|
||||
val := ExportJobType(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid ExportJobType value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ejt ExportJobType) Value() (driver.Value, error) {
|
||||
return ejt.String(), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -26,34 +26,45 @@ const (
|
||||
FileVisibilityPublic FileVisibility = "PUBLIC"
|
||||
)
|
||||
|
||||
func (fv FileVisibility) String() string {
|
||||
return string(fv)
|
||||
var (
|
||||
_ fmt.Stringer = FileVisibility("")
|
||||
_ encoding.TextMarshaler = FileVisibility("")
|
||||
_ encoding.TextUnmarshaler = (*FileVisibility)(nil)
|
||||
)
|
||||
|
||||
func FileVisibilities() []FileVisibility {
|
||||
return []FileVisibility{
|
||||
FileVisibilityPrivate,
|
||||
FileVisibilityPublic,
|
||||
}
|
||||
}
|
||||
|
||||
func (fv *FileVisibility) Scan(value any) error {
|
||||
var s string
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
s = v
|
||||
case []byte:
|
||||
s = string(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for FileVisibility: %T", value)
|
||||
func (v FileVisibility) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
FileVisibilityPrivate,
|
||||
FileVisibilityPublic:
|
||||
return true
|
||||
}
|
||||
|
||||
switch s {
|
||||
case "PRIVATE":
|
||||
*fv = FileVisibilityPrivate
|
||||
case "PUBLIC":
|
||||
*fv = FileVisibilityPublic
|
||||
default:
|
||||
return fmt.Errorf("invalid FileVisibility value: %q", s)
|
||||
return false
|
||||
}
|
||||
|
||||
func (v FileVisibility) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v FileVisibility) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *FileVisibility) UnmarshalText(text []byte) error {
|
||||
val := FileVisibility(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid FileVisibility value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fv FileVisibility) Value() (driver.Value, error) {
|
||||
return fv.String(), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -28,6 +28,12 @@ const (
|
||||
FindingKindException FindingKind = "EXCEPTION"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = FindingKind("")
|
||||
_ encoding.TextMarshaler = FindingKind("")
|
||||
_ encoding.TextUnmarshaler = (*FindingKind)(nil)
|
||||
)
|
||||
|
||||
func FindingKinds() []FindingKind {
|
||||
return []FindingKind{
|
||||
FindingKindMinorNonconformity,
|
||||
@@ -37,38 +43,34 @@ func FindingKinds() []FindingKind {
|
||||
}
|
||||
}
|
||||
|
||||
func (fk FindingKind) String() string {
|
||||
return string(fk)
|
||||
func (v FindingKind) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
FindingKindMinorNonconformity,
|
||||
FindingKindMajorNonconformity,
|
||||
FindingKindObservation,
|
||||
FindingKindException:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (fk *FindingKind) Scan(value any) error {
|
||||
var s string
|
||||
func (v FindingKind) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
s = v
|
||||
case []byte:
|
||||
s = string(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for FindingKind: %T", value)
|
||||
func (v FindingKind) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *FindingKind) UnmarshalText(text []byte) error {
|
||||
val := FindingKind(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid FindingKind value: %q", string(text))
|
||||
}
|
||||
|
||||
switch s {
|
||||
case "MINOR_NONCONFORMITY":
|
||||
*fk = FindingKindMinorNonconformity
|
||||
case "MAJOR_NONCONFORMITY":
|
||||
*fk = FindingKindMajorNonconformity
|
||||
case "OBSERVATION":
|
||||
*fk = FindingKindObservation
|
||||
case "EXCEPTION":
|
||||
*fk = FindingKindException
|
||||
default:
|
||||
return fmt.Errorf("invalid FindingKind value: %q", s)
|
||||
}
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fk FindingKind) Value() (driver.Value, error) {
|
||||
return fk.String(), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,10 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type FindingOrderField string
|
||||
@@ -30,31 +33,60 @@ const (
|
||||
FindingOrderFieldKind FindingOrderField = "KIND"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = FindingOrderField("")
|
||||
_ fmt.Stringer = FindingOrderField("")
|
||||
_ encoding.TextMarshaler = FindingOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*FindingOrderField)(nil)
|
||||
)
|
||||
|
||||
func FindingOrderFields() []FindingOrderField {
|
||||
return []FindingOrderField{
|
||||
FindingOrderFieldCreatedAt,
|
||||
FindingOrderFieldIdentifiedOn,
|
||||
FindingOrderFieldDueDate,
|
||||
FindingOrderFieldStatus,
|
||||
FindingOrderFieldPriority,
|
||||
FindingOrderFieldReferenceId,
|
||||
FindingOrderFieldKind,
|
||||
}
|
||||
}
|
||||
|
||||
func (v FindingOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
FindingOrderFieldCreatedAt,
|
||||
FindingOrderFieldIdentifiedOn,
|
||||
FindingOrderFieldDueDate,
|
||||
FindingOrderFieldStatus,
|
||||
FindingOrderFieldPriority,
|
||||
FindingOrderFieldReferenceId,
|
||||
FindingOrderFieldKind:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v FindingOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v FindingOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *FindingOrderField) UnmarshalText(text []byte) error {
|
||||
val := FindingOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid FindingOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p FindingOrderField) Column() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p FindingOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p FindingOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *FindingOrderField) UnmarshalText(text []byte) error {
|
||||
val := string(text)
|
||||
switch val {
|
||||
case string(FindingOrderFieldCreatedAt),
|
||||
string(FindingOrderFieldIdentifiedOn),
|
||||
string(FindingOrderFieldDueDate),
|
||||
string(FindingOrderFieldStatus),
|
||||
string(FindingOrderFieldPriority),
|
||||
string(FindingOrderFieldReferenceId),
|
||||
string(FindingOrderFieldKind):
|
||||
*p = FindingOrderField(val)
|
||||
return nil
|
||||
}
|
||||
|
||||
return fmt.Errorf("invalid FindingOrderField value: %q", val)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -27,6 +27,12 @@ const (
|
||||
FindingPriorityHigh FindingPriority = "HIGH"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = FindingPriority("")
|
||||
_ encoding.TextMarshaler = FindingPriority("")
|
||||
_ encoding.TextUnmarshaler = (*FindingPriority)(nil)
|
||||
)
|
||||
|
||||
func FindingPriorities() []FindingPriority {
|
||||
return []FindingPriority{
|
||||
FindingPriorityLow,
|
||||
@@ -35,36 +41,33 @@ func FindingPriorities() []FindingPriority {
|
||||
}
|
||||
}
|
||||
|
||||
func (fp FindingPriority) String() string {
|
||||
return string(fp)
|
||||
func (v FindingPriority) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
FindingPriorityLow,
|
||||
FindingPriorityMedium,
|
||||
FindingPriorityHigh:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (fp *FindingPriority) Scan(value any) error {
|
||||
var s string
|
||||
func (v FindingPriority) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
s = v
|
||||
case []byte:
|
||||
s = string(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for FindingPriority: %T", value)
|
||||
func (v FindingPriority) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *FindingPriority) UnmarshalText(text []byte) error {
|
||||
val := FindingPriority(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid FindingPriority value: %q", string(text))
|
||||
}
|
||||
|
||||
switch s {
|
||||
case "LOW":
|
||||
*fp = FindingPriorityLow
|
||||
case "MEDIUM":
|
||||
*fp = FindingPriorityMedium
|
||||
case "HIGH":
|
||||
*fp = FindingPriorityHigh
|
||||
default:
|
||||
return fmt.Errorf("invalid FindingPriority value: %q", s)
|
||||
}
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fp FindingPriority) Value() (driver.Value, error) {
|
||||
return fp.String(), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -30,6 +30,12 @@ const (
|
||||
FindingStatusFalsePositive FindingStatus = "FALSE_POSITIVE"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = FindingStatus("")
|
||||
_ encoding.TextMarshaler = FindingStatus("")
|
||||
_ encoding.TextUnmarshaler = (*FindingStatus)(nil)
|
||||
)
|
||||
|
||||
func FindingStatuses() []FindingStatus {
|
||||
return []FindingStatus{
|
||||
FindingStatusOpen,
|
||||
@@ -41,42 +47,36 @@ func FindingStatuses() []FindingStatus {
|
||||
}
|
||||
}
|
||||
|
||||
func (fs FindingStatus) String() string {
|
||||
return string(fs)
|
||||
func (v FindingStatus) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
FindingStatusOpen,
|
||||
FindingStatusInProgress,
|
||||
FindingStatusClosed,
|
||||
FindingStatusRiskAccepted,
|
||||
FindingStatusMitigated,
|
||||
FindingStatusFalsePositive:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (fs *FindingStatus) Scan(value any) error {
|
||||
var s string
|
||||
func (v FindingStatus) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
s = v
|
||||
case []byte:
|
||||
s = string(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for FindingStatus: %T", value)
|
||||
func (v FindingStatus) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *FindingStatus) UnmarshalText(text []byte) error {
|
||||
val := FindingStatus(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid FindingStatus value: %q", string(text))
|
||||
}
|
||||
|
||||
switch s {
|
||||
case "OPEN":
|
||||
*fs = FindingStatusOpen
|
||||
case "IN_PROGRESS":
|
||||
*fs = FindingStatusInProgress
|
||||
case "CLOSED":
|
||||
*fs = FindingStatusClosed
|
||||
case "RISK_ACCEPTED":
|
||||
*fs = FindingStatusRiskAccepted
|
||||
case "MITIGATED":
|
||||
*fs = FindingStatusMitigated
|
||||
case "FALSE_POSITIVE":
|
||||
*fs = FindingStatusFalsePositive
|
||||
default:
|
||||
return fmt.Errorf("invalid FindingStatus value: %q", s)
|
||||
}
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fs FindingStatus) Value() (driver.Value, error) {
|
||||
return fs.String(), nil
|
||||
}
|
||||
|
||||
@@ -14,6 +14,13 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
FrameworkOrderField string
|
||||
)
|
||||
@@ -22,19 +29,48 @@ const (
|
||||
FrameworkOrderFieldCreatedAt FrameworkOrderField = "CREATED_AT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = FrameworkOrderField("")
|
||||
_ fmt.Stringer = FrameworkOrderField("")
|
||||
_ encoding.TextMarshaler = FrameworkOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*FrameworkOrderField)(nil)
|
||||
)
|
||||
|
||||
func FrameworkOrderFields() []FrameworkOrderField {
|
||||
return []FrameworkOrderField{
|
||||
FrameworkOrderFieldCreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v FrameworkOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
FrameworkOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v FrameworkOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v FrameworkOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *FrameworkOrderField) UnmarshalText(text []byte) error {
|
||||
val := FrameworkOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid FrameworkOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p FrameworkOrderField) Column() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p FrameworkOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p FrameworkOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *FrameworkOrderField) UnmarshalText(text []byte) error {
|
||||
*p = FrameworkOrderField(text)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -14,6 +14,13 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
IdentityOrderField string
|
||||
)
|
||||
@@ -22,19 +29,48 @@ const (
|
||||
IdentityOrderFieldCreatedAt IdentityOrderField = "CREATED_AT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = IdentityOrderField("")
|
||||
_ fmt.Stringer = IdentityOrderField("")
|
||||
_ encoding.TextMarshaler = IdentityOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*IdentityOrderField)(nil)
|
||||
)
|
||||
|
||||
func IdentityOrderFields() []IdentityOrderField {
|
||||
return []IdentityOrderField{
|
||||
IdentityOrderFieldCreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v IdentityOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
IdentityOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v IdentityOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v IdentityOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *IdentityOrderField) UnmarshalText(text []byte) error {
|
||||
val := IdentityOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid IdentityOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p IdentityOrderField) Column() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p IdentityOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p IdentityOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *IdentityOrderField) UnmarshalText(text []byte) error {
|
||||
*p = IdentityOrderField(text)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -14,7 +14,12 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
// InvitationOrderField defines the fields that can be used to order invitations
|
||||
type InvitationOrderField string
|
||||
@@ -24,6 +29,48 @@ const (
|
||||
InvitationOrderFieldCreatedAt InvitationOrderField = "CREATED_AT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = InvitationOrderField("")
|
||||
_ fmt.Stringer = InvitationOrderField("")
|
||||
_ encoding.TextMarshaler = InvitationOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*InvitationOrderField)(nil)
|
||||
)
|
||||
|
||||
func InvitationOrderFields() []InvitationOrderField {
|
||||
return []InvitationOrderField{
|
||||
InvitationOrderFieldCreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v InvitationOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
InvitationOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v InvitationOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v InvitationOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *InvitationOrderField) UnmarshalText(text []byte) error {
|
||||
val := InvitationOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid InvitationOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p InvitationOrderField) Column() string {
|
||||
switch p {
|
||||
case InvitationOrderFieldCreatedAt:
|
||||
@@ -32,29 +79,3 @@ func (p InvitationOrderField) Column() string {
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", p))
|
||||
}
|
||||
|
||||
func (e InvitationOrderField) IsValid() bool {
|
||||
switch e {
|
||||
case InvitationOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (e InvitationOrderField) String() string {
|
||||
return string(e)
|
||||
}
|
||||
|
||||
func (e *InvitationOrderField) UnmarshalText(text []byte) error {
|
||||
*e = InvitationOrderField(text)
|
||||
if !e.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid InvitationOrderField", string(text))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e InvitationOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(e.String()), nil
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
@@ -31,40 +32,43 @@ const (
|
||||
InvitationStatusExpired InvitationStatus = "EXPIRED"
|
||||
)
|
||||
|
||||
func (tcv InvitationStatus) String() string {
|
||||
return string(tcv)
|
||||
var (
|
||||
_ fmt.Stringer = InvitationStatus("")
|
||||
_ encoding.TextMarshaler = InvitationStatus("")
|
||||
_ encoding.TextUnmarshaler = (*InvitationStatus)(nil)
|
||||
)
|
||||
|
||||
func (v InvitationStatus) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
InvitationStatusPending,
|
||||
InvitationStatusAccepted,
|
||||
InvitationStatusExpired:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (tcv *InvitationStatus) Scan(value any) error {
|
||||
var s string
|
||||
func (v InvitationStatus) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
s = v
|
||||
case []byte:
|
||||
s = string(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for TrustCenterVisibility: %T", value)
|
||||
func (v InvitationStatus) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *InvitationStatus) UnmarshalText(text []byte) error {
|
||||
val := InvitationStatus(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid InvitationStatus value: %q", string(text))
|
||||
}
|
||||
|
||||
switch s {
|
||||
case "PENDING":
|
||||
*tcv = InvitationStatusPending
|
||||
case "ACCEPTED":
|
||||
*tcv = InvitationStatusAccepted
|
||||
case "EXPIRED":
|
||||
*tcv = InvitationStatusExpired
|
||||
default:
|
||||
return fmt.Errorf("invalid InvitationStatus value: %q", s)
|
||||
}
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tcv InvitationStatus) Value() (driver.Value, error) {
|
||||
return tcv.String(), nil
|
||||
}
|
||||
|
||||
func (statuses InvitationStatuses) Value() (driver.Value, error) {
|
||||
if len(statuses) == 0 {
|
||||
return nil, nil
|
||||
|
||||
@@ -14,7 +14,12 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type MailingListSubscriberOrderField string
|
||||
|
||||
@@ -22,8 +27,46 @@ const (
|
||||
MailingListSubscriberOrderFieldCreatedAt MailingListSubscriberOrderField = "CREATED_AT"
|
||||
)
|
||||
|
||||
func (f MailingListSubscriberOrderField) String() string {
|
||||
return string(f)
|
||||
var (
|
||||
_ page.OrderField = MailingListSubscriberOrderField("")
|
||||
_ fmt.Stringer = MailingListSubscriberOrderField("")
|
||||
_ encoding.TextMarshaler = MailingListSubscriberOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*MailingListSubscriberOrderField)(nil)
|
||||
)
|
||||
|
||||
func MailingListSubscriberOrderFields() []MailingListSubscriberOrderField {
|
||||
return []MailingListSubscriberOrderField{
|
||||
MailingListSubscriberOrderFieldCreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v MailingListSubscriberOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
MailingListSubscriberOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v MailingListSubscriberOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v MailingListSubscriberOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *MailingListSubscriberOrderField) UnmarshalText(text []byte) error {
|
||||
val := MailingListSubscriberOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid MailingListSubscriberOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f MailingListSubscriberOrderField) Column() string {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -26,34 +26,45 @@ const (
|
||||
MailingListSubscriberStatusConfirmed MailingListSubscriberStatus = "CONFIRMED"
|
||||
)
|
||||
|
||||
func (s MailingListSubscriberStatus) String() string {
|
||||
return string(s)
|
||||
var (
|
||||
_ fmt.Stringer = MailingListSubscriberStatus("")
|
||||
_ encoding.TextMarshaler = MailingListSubscriberStatus("")
|
||||
_ encoding.TextUnmarshaler = (*MailingListSubscriberStatus)(nil)
|
||||
)
|
||||
|
||||
func MailingListSubscriberStatuses() []MailingListSubscriberStatus {
|
||||
return []MailingListSubscriberStatus{
|
||||
MailingListSubscriberStatusPending,
|
||||
MailingListSubscriberStatusConfirmed,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *MailingListSubscriberStatus) Scan(value any) error {
|
||||
var str string
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
str = v
|
||||
case []byte:
|
||||
str = string(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for MailingListSubscriberStatus: %T", value)
|
||||
func (v MailingListSubscriberStatus) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
MailingListSubscriberStatusPending,
|
||||
MailingListSubscriberStatusConfirmed:
|
||||
return true
|
||||
}
|
||||
|
||||
switch str {
|
||||
case "PENDING":
|
||||
*s = MailingListSubscriberStatusPending
|
||||
case "CONFIRMED":
|
||||
*s = MailingListSubscriberStatusConfirmed
|
||||
default:
|
||||
return fmt.Errorf("invalid MailingListSubscriberStatus value: %q", str)
|
||||
return false
|
||||
}
|
||||
|
||||
func (v MailingListSubscriberStatus) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v MailingListSubscriberStatus) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *MailingListSubscriberStatus) UnmarshalText(text []byte) error {
|
||||
val := MailingListSubscriberStatus(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid MailingListSubscriberStatus value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s MailingListSubscriberStatus) Value() (driver.Value, error) {
|
||||
return s.String(), nil
|
||||
}
|
||||
|
||||
@@ -14,7 +14,12 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type MailingListUpdateOrderField string
|
||||
|
||||
@@ -23,8 +28,48 @@ const (
|
||||
MailingListUpdateOrderFieldUpdatedAt MailingListUpdateOrderField = "UPDATED_AT"
|
||||
)
|
||||
|
||||
func (f MailingListUpdateOrderField) String() string {
|
||||
return string(f)
|
||||
var (
|
||||
_ page.OrderField = MailingListUpdateOrderField("")
|
||||
_ fmt.Stringer = MailingListUpdateOrderField("")
|
||||
_ encoding.TextMarshaler = MailingListUpdateOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*MailingListUpdateOrderField)(nil)
|
||||
)
|
||||
|
||||
func MailingListUpdateOrderFields() []MailingListUpdateOrderField {
|
||||
return []MailingListUpdateOrderField{
|
||||
MailingListUpdateOrderFieldCreatedAt,
|
||||
MailingListUpdateOrderFieldUpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v MailingListUpdateOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
MailingListUpdateOrderFieldCreatedAt,
|
||||
MailingListUpdateOrderFieldUpdatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v MailingListUpdateOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v MailingListUpdateOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *MailingListUpdateOrderField) UnmarshalText(text []byte) error {
|
||||
val := MailingListUpdateOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid MailingListUpdateOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f MailingListUpdateOrderField) Column() string {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -28,38 +28,49 @@ const (
|
||||
MailingListUpdateStatusSent MailingListUpdateStatus = "SENT"
|
||||
)
|
||||
|
||||
func (s MailingListUpdateStatus) String() string {
|
||||
return string(s)
|
||||
var (
|
||||
_ fmt.Stringer = MailingListUpdateStatus("")
|
||||
_ encoding.TextMarshaler = MailingListUpdateStatus("")
|
||||
_ encoding.TextUnmarshaler = (*MailingListUpdateStatus)(nil)
|
||||
)
|
||||
|
||||
func MailingListUpdateStatuses() []MailingListUpdateStatus {
|
||||
return []MailingListUpdateStatus{
|
||||
MailingListUpdateStatusDraft,
|
||||
MailingListUpdateStatusEnqueued,
|
||||
MailingListUpdateStatusProcessing,
|
||||
MailingListUpdateStatusSent,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *MailingListUpdateStatus) Scan(value any) error {
|
||||
var str string
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
str = v
|
||||
case []byte:
|
||||
str = string(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for MailingListUpdateStatus: %T", value)
|
||||
func (v MailingListUpdateStatus) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
MailingListUpdateStatusDraft,
|
||||
MailingListUpdateStatusEnqueued,
|
||||
MailingListUpdateStatusProcessing,
|
||||
MailingListUpdateStatusSent:
|
||||
return true
|
||||
}
|
||||
|
||||
switch str {
|
||||
case "DRAFT":
|
||||
*s = MailingListUpdateStatusDraft
|
||||
case "ENQUEUED":
|
||||
*s = MailingListUpdateStatusEnqueued
|
||||
case "PROCESSING":
|
||||
*s = MailingListUpdateStatusProcessing
|
||||
case "SENT":
|
||||
*s = MailingListUpdateStatusSent
|
||||
default:
|
||||
return fmt.Errorf("invalid MailingListUpdateStatus value: %q", str)
|
||||
return false
|
||||
}
|
||||
|
||||
func (v MailingListUpdateStatus) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v MailingListUpdateStatus) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *MailingListUpdateStatus) UnmarshalText(text []byte) error {
|
||||
val := MailingListUpdateStatus(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid MailingListUpdateStatus value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s MailingListUpdateStatus) Value() (driver.Value, error) {
|
||||
return s.String(), nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -29,40 +29,51 @@ const (
|
||||
MembershipRoleAuditor MembershipRole = "AUDITOR"
|
||||
)
|
||||
|
||||
func (r MembershipRole) String() string {
|
||||
return string(r)
|
||||
var (
|
||||
_ fmt.Stringer = MembershipRole("")
|
||||
_ encoding.TextMarshaler = MembershipRole("")
|
||||
_ encoding.TextUnmarshaler = (*MembershipRole)(nil)
|
||||
)
|
||||
|
||||
func MembershipRoles() []MembershipRole {
|
||||
return []MembershipRole{
|
||||
MembershipRoleOwner,
|
||||
MembershipRoleAdmin,
|
||||
MembershipRoleEmployee,
|
||||
MembershipRoleViewer,
|
||||
MembershipRoleAuditor,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *MembershipRole) Scan(value any) error {
|
||||
var s string
|
||||
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
s = v
|
||||
case []byte:
|
||||
s = string(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for MembershipRole: %T", value)
|
||||
func (v MembershipRole) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
MembershipRoleOwner,
|
||||
MembershipRoleAdmin,
|
||||
MembershipRoleEmployee,
|
||||
MembershipRoleViewer,
|
||||
MembershipRoleAuditor:
|
||||
return true
|
||||
}
|
||||
|
||||
switch s {
|
||||
case "OWNER":
|
||||
*r = MembershipRoleOwner
|
||||
case "ADMIN":
|
||||
*r = MembershipRoleAdmin
|
||||
case "EMPLOYEE":
|
||||
*r = MembershipRoleEmployee
|
||||
case "VIEWER":
|
||||
*r = MembershipRoleViewer
|
||||
case "AUDITOR":
|
||||
*r = MembershipRoleAuditor
|
||||
default:
|
||||
return fmt.Errorf("invalid MembershipRole value: %q", s)
|
||||
return false
|
||||
}
|
||||
|
||||
func (v MembershipRole) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v MembershipRole) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *MembershipRole) UnmarshalText(text []byte) error {
|
||||
val := MembershipRole(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid MembershipRole value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r MembershipRole) Value() (driver.Value, error) {
|
||||
return r.String(), nil
|
||||
}
|
||||
|
||||
@@ -14,6 +14,13 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
MembershipOrderField string
|
||||
)
|
||||
@@ -26,6 +33,56 @@ const (
|
||||
MembershipOrderFieldCreatedAt MembershipOrderField = "CREATED_AT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = MembershipOrderField("")
|
||||
_ fmt.Stringer = MembershipOrderField("")
|
||||
_ encoding.TextMarshaler = MembershipOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*MembershipOrderField)(nil)
|
||||
)
|
||||
|
||||
func MembershipOrderFields() []MembershipOrderField {
|
||||
return []MembershipOrderField{
|
||||
MembershipOrderFieldOrganizationName,
|
||||
MembershipOrderFieldFullName,
|
||||
MembershipOrderFieldEmailAddress,
|
||||
MembershipOrderFieldRole,
|
||||
MembershipOrderFieldCreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v MembershipOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
MembershipOrderFieldOrganizationName,
|
||||
MembershipOrderFieldFullName,
|
||||
MembershipOrderFieldEmailAddress,
|
||||
MembershipOrderFieldRole,
|
||||
MembershipOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v MembershipOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v MembershipOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *MembershipOrderField) UnmarshalText(text []byte) error {
|
||||
val := MembershipOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid MembershipOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p MembershipOrderField) Column() string {
|
||||
switch p {
|
||||
case MembershipOrderFieldOrganizationName:
|
||||
@@ -42,16 +99,3 @@ func (p MembershipOrderField) Column() string {
|
||||
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p MembershipOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p MembershipOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *MembershipOrderField) UnmarshalText(text []byte) error {
|
||||
*p = MembershipOrderField(text)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -14,6 +14,13 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
MembershipProfileOrderField string
|
||||
)
|
||||
@@ -26,19 +33,56 @@ const (
|
||||
MembershipProfileOrderFieldState MembershipProfileOrderField = "STATE"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = MembershipProfileOrderField("")
|
||||
_ fmt.Stringer = MembershipProfileOrderField("")
|
||||
_ encoding.TextMarshaler = MembershipProfileOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*MembershipProfileOrderField)(nil)
|
||||
)
|
||||
|
||||
func MembershipProfileOrderFields() []MembershipProfileOrderField {
|
||||
return []MembershipProfileOrderField{
|
||||
MembershipProfileOrderFieldCreatedAt,
|
||||
MembershipProfileOrderFieldFullName,
|
||||
MembershipProfileOrderFieldKind,
|
||||
MembershipProfileOrderFieldOrganizationName,
|
||||
MembershipProfileOrderFieldState,
|
||||
}
|
||||
}
|
||||
|
||||
func (v MembershipProfileOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
MembershipProfileOrderFieldCreatedAt,
|
||||
MembershipProfileOrderFieldFullName,
|
||||
MembershipProfileOrderFieldKind,
|
||||
MembershipProfileOrderFieldOrganizationName,
|
||||
MembershipProfileOrderFieldState:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v MembershipProfileOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v MembershipProfileOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *MembershipProfileOrderField) UnmarshalText(text []byte) error {
|
||||
val := MembershipProfileOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid MembershipProfileOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p MembershipProfileOrderField) Column() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p MembershipProfileOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p MembershipProfileOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *MembershipProfileOrderField) UnmarshalText(text []byte) error {
|
||||
*p = MembershipProfileOrderField(text)
|
||||
return nil
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user