@@ -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).
|
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
|
```go
|
||||||
type AssetOrderField string
|
type XXXType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
AssetOrderFieldCreatedAt AssetOrderField = "CREATED_AT"
|
XXXTypeAlpha XXXType = "ALPHA"
|
||||||
AssetOrderFieldName AssetOrderField = "NAME"
|
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.
|
Each entity implements `CursorKey(field)` returning `page.NewCursorKey(entity.ID, sortValue)`, with a `panic` on unknown fields.
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -26,6 +26,12 @@ const (
|
|||||||
AccessEntryAccountTypeServiceAccount AccessEntryAccountType = "SERVICE_ACCOUNT"
|
AccessEntryAccountTypeServiceAccount AccessEntryAccountType = "SERVICE_ACCOUNT"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Stringer = AccessEntryAccountType("")
|
||||||
|
_ encoding.TextMarshaler = AccessEntryAccountType("")
|
||||||
|
_ encoding.TextUnmarshaler = (*AccessEntryAccountType)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func AccessEntryAccountTypes() []AccessEntryAccountType {
|
func AccessEntryAccountTypes() []AccessEntryAccountType {
|
||||||
return []AccessEntryAccountType{
|
return []AccessEntryAccountType{
|
||||||
AccessEntryAccountTypeUser,
|
AccessEntryAccountTypeUser,
|
||||||
@@ -33,34 +39,32 @@ func AccessEntryAccountTypes() []AccessEntryAccountType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a AccessEntryAccountType) String() string {
|
func (v AccessEntryAccountType) IsValid() bool {
|
||||||
return string(a)
|
switch v {
|
||||||
|
case
|
||||||
|
AccessEntryAccountTypeUser,
|
||||||
|
AccessEntryAccountTypeServiceAccount:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AccessEntryAccountType) Scan(value any) error {
|
func (v AccessEntryAccountType) String() string {
|
||||||
var str string
|
return string(v)
|
||||||
|
}
|
||||||
|
|
||||||
switch v := value.(type) {
|
func (v AccessEntryAccountType) MarshalText() ([]byte, error) {
|
||||||
case string:
|
return []byte(v.String()), nil
|
||||||
str = v
|
}
|
||||||
case []byte:
|
|
||||||
str = string(v)
|
func (v *AccessEntryAccountType) UnmarshalText(text []byte) error {
|
||||||
default:
|
val := AccessEntryAccountType(text)
|
||||||
return fmt.Errorf("cannot scan AccessEntryAccountType: unsupported type %T", value)
|
if !val.IsValid() {
|
||||||
|
return fmt.Errorf("invalid AccessEntryAccountType value: %q", string(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
switch str {
|
*v = val
|
||||||
case "USER":
|
|
||||||
*a = AccessEntryAccountTypeUser
|
|
||||||
case "SERVICE_ACCOUNT":
|
|
||||||
*a = AccessEntryAccountTypeServiceAccount
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("cannot parse AccessEntryAccountType: invalid value %q", str)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a AccessEntryAccountType) Value() (driver.Value, error) {
|
|
||||||
return a.String(), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,56 +16,63 @@ package coredata
|
|||||||
|
|
||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
func TestAccessEntryAccountTypeScan(t *testing.T) {
|
func TestAccessEntryAccountTypeIsValid(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tests := []struct {
|
for _, value := range AccessEntryAccountTypes() {
|
||||||
name string
|
if !value.IsValid() {
|
||||||
input any
|
t.Fatalf("IsValid() = false for %q", value)
|
||||||
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 _, tt := range tests {
|
if AccessEntryAccountType("BOGUS").IsValid() {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
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()
|
t.Parallel()
|
||||||
|
|
||||||
var got AccessEntryAccountType
|
var got AccessEntryAccountType
|
||||||
|
if err := got.UnmarshalText([]byte(value)); err != nil {
|
||||||
err := got.Scan(tt.input)
|
t.Fatalf("UnmarshalText(%q) returned error: %v", value, err)
|
||||||
if tt.wantErr {
|
|
||||||
if err == nil {
|
|
||||||
t.Fatalf("Scan(%v) expected error", tt.input)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
if err != nil {
|
||||||
t.Fatalf("Scan(%v) returned error: %v", tt.input, err)
|
t.Fatalf("MarshalText() returned error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if got != tt.want {
|
if string(got) != value.String() {
|
||||||
t.Fatalf("Scan(%v) = %q, want %q", tt.input, got, tt.want)
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -29,40 +29,51 @@ const (
|
|||||||
AccessEntryDecisionEscalate AccessEntryDecision = "ESCALATE"
|
AccessEntryDecisionEscalate AccessEntryDecision = "ESCALATE"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (d AccessEntryDecision) String() string {
|
var (
|
||||||
return string(d)
|
_ 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 {
|
func (v AccessEntryDecision) IsValid() bool {
|
||||||
var str string
|
switch v {
|
||||||
|
case
|
||||||
switch v := value.(type) {
|
AccessEntryDecisionPending,
|
||||||
case string:
|
AccessEntryDecisionApproved,
|
||||||
str = v
|
AccessEntryDecisionRevoke,
|
||||||
case []byte:
|
AccessEntryDecisionDefer,
|
||||||
str = string(v)
|
AccessEntryDecisionEscalate:
|
||||||
default:
|
return true
|
||||||
return fmt.Errorf("cannot scan AccessEntryDecision: unsupported type %T", value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch str {
|
return false
|
||||||
case "PENDING":
|
}
|
||||||
*d = AccessEntryDecisionPending
|
|
||||||
case "APPROVED":
|
func (v AccessEntryDecision) String() string {
|
||||||
*d = AccessEntryDecisionApproved
|
return string(v)
|
||||||
case "REVOKE":
|
}
|
||||||
*d = AccessEntryDecisionRevoke
|
|
||||||
case "DEFER":
|
func (v AccessEntryDecision) MarshalText() ([]byte, error) {
|
||||||
*d = AccessEntryDecisionDefer
|
return []byte(v.String()), nil
|
||||||
case "ESCALATE":
|
}
|
||||||
*d = AccessEntryDecisionEscalate
|
|
||||||
default:
|
func (v *AccessEntryDecision) UnmarshalText(text []byte) error {
|
||||||
return fmt.Errorf("cannot parse AccessEntryDecision: invalid value %q", str)
|
val := AccessEntryDecision(text)
|
||||||
|
if !val.IsValid() {
|
||||||
|
return fmt.Errorf("invalid AccessEntryDecision value: %q", string(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*v = val
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d AccessEntryDecision) Value() (driver.Value, error) {
|
|
||||||
return d.String(), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,74 +16,62 @@ package coredata
|
|||||||
|
|
||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
func TestAccessEntryDecisionScan(t *testing.T) {
|
func TestAccessEntryDecisionIsValid(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tests := []struct {
|
for _, value := range AccessEntryDecisions() {
|
||||||
name string
|
if !value.IsValid() {
|
||||||
input any
|
t.Fatalf("IsValid() = false for %q", value)
|
||||||
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 _, tt := range tests {
|
if AccessEntryDecision("BOGUS").IsValid() {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
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()
|
t.Parallel()
|
||||||
|
|
||||||
var got AccessEntryDecision
|
var got AccessEntryDecision
|
||||||
|
if err := got.UnmarshalText([]byte(value)); err != nil {
|
||||||
err := got.Scan(tt.input)
|
t.Fatalf("UnmarshalText(%q) returned error: %v", value, err)
|
||||||
if tt.wantErr {
|
|
||||||
if err == nil {
|
|
||||||
t.Fatalf("Scan(%v) expected error", tt.input)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if got != value {
|
||||||
t.Fatalf("Scan(%v) returned error: %v", tt.input, err)
|
t.Fatalf("UnmarshalText(%q) = %q, want %q", value, got, value)
|
||||||
}
|
|
||||||
|
|
||||||
if got != tt.want {
|
|
||||||
t.Fatalf("Scan(%v) = %q, want %q", tt.input, got, tt.want)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
t.Parallel()
|
||||||
|
|
||||||
tests := []struct {
|
for _, value := range AccessEntryDecisions() {
|
||||||
name string
|
t.Run(string(value), func(t *testing.T) {
|
||||||
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) {
|
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
got, err := tt.decision.Value()
|
got, err := value.MarshalText()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Value() returned error: %v", err)
|
t.Fatalf("MarshalText() returned error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if got != tt.want {
|
if string(got) != value.String() {
|
||||||
t.Fatalf("Value() = %q, want %q", got, tt.want)
|
t.Fatalf("MarshalText() = %q, want %q", string(got), value.String())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -39,60 +39,71 @@ const (
|
|||||||
AccessEntryFlagSharedAccount AccessEntryFlag = "SHARED_ACCOUNT"
|
AccessEntryFlagSharedAccount AccessEntryFlag = "SHARED_ACCOUNT"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (f AccessEntryFlag) String() string {
|
var (
|
||||||
return string(f)
|
_ 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 {
|
func (v AccessEntryFlag) IsValid() bool {
|
||||||
var str string
|
switch v {
|
||||||
|
case
|
||||||
switch v := value.(type) {
|
AccessEntryFlagNone,
|
||||||
case string:
|
AccessEntryFlagOrphaned,
|
||||||
str = v
|
AccessEntryFlagInactive,
|
||||||
case []byte:
|
AccessEntryFlagExcessive,
|
||||||
str = string(v)
|
AccessEntryFlagRoleMismatch,
|
||||||
default:
|
AccessEntryFlagNew,
|
||||||
return fmt.Errorf("cannot scan AccessEntryFlag: unsupported type %T", value)
|
AccessEntryFlagDormant,
|
||||||
|
AccessEntryFlagTerminatedUser,
|
||||||
|
AccessEntryFlagContractorExpired,
|
||||||
|
AccessEntryFlagSoDConflict,
|
||||||
|
AccessEntryFlagPrivilegedAccess,
|
||||||
|
AccessEntryFlagRoleCreep,
|
||||||
|
AccessEntryFlagNoBusinessJustification,
|
||||||
|
AccessEntryFlagOutOfDepartment,
|
||||||
|
AccessEntryFlagSharedAccount:
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
switch str {
|
return false
|
||||||
case "NONE":
|
}
|
||||||
*f = AccessEntryFlagNone
|
|
||||||
case "ORPHANED":
|
func (v AccessEntryFlag) String() string {
|
||||||
*f = AccessEntryFlagOrphaned
|
return string(v)
|
||||||
case "INACTIVE":
|
}
|
||||||
*f = AccessEntryFlagInactive
|
|
||||||
case "EXCESSIVE":
|
func (v AccessEntryFlag) MarshalText() ([]byte, error) {
|
||||||
*f = AccessEntryFlagExcessive
|
return []byte(v.String()), nil
|
||||||
case "ROLE_MISMATCH":
|
}
|
||||||
*f = AccessEntryFlagRoleMismatch
|
|
||||||
case "NEW":
|
func (v *AccessEntryFlag) UnmarshalText(text []byte) error {
|
||||||
*f = AccessEntryFlagNew
|
val := AccessEntryFlag(text)
|
||||||
case "DORMANT":
|
if !val.IsValid() {
|
||||||
*f = AccessEntryFlagDormant
|
return fmt.Errorf("invalid AccessEntryFlag value: %q", string(text))
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*v = val
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f AccessEntryFlag) Value() (driver.Value, error) {
|
|
||||||
return f.String(), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,60 +16,63 @@ package coredata
|
|||||||
|
|
||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
func TestAccessEntryFlagScan(t *testing.T) {
|
func TestAccessEntryFlagIsValid(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tests := []struct {
|
for _, value := range AccessEntryFlags() {
|
||||||
name string
|
if !value.IsValid() {
|
||||||
input any
|
t.Fatalf("IsValid() = false for %q", value)
|
||||||
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 _, tt := range tests {
|
if AccessEntryFlag("BOGUS").IsValid() {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
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()
|
t.Parallel()
|
||||||
|
|
||||||
var got AccessEntryFlag
|
var got AccessEntryFlag
|
||||||
|
if err := got.UnmarshalText([]byte(value)); err != nil {
|
||||||
err := got.Scan(tt.input)
|
t.Fatalf("UnmarshalText(%q) returned error: %v", value, err)
|
||||||
if tt.wantErr {
|
|
||||||
if err == nil {
|
|
||||||
t.Fatalf("Scan(%v) expected error", tt.input)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
if err != nil {
|
||||||
t.Fatalf("Scan(%v) returned error: %v", tt.input, err)
|
t.Fatalf("MarshalText() returned error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if got != tt.want {
|
if string(got) != value.String() {
|
||||||
t.Fatalf("Scan(%v) = %q, want %q", tt.input, got, tt.want)
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -27,36 +27,47 @@ const (
|
|||||||
AccessEntryIncrementalTagUnchanged AccessEntryIncrementalTag = "UNCHANGED"
|
AccessEntryIncrementalTagUnchanged AccessEntryIncrementalTag = "UNCHANGED"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (t AccessEntryIncrementalTag) String() string {
|
var (
|
||||||
return string(t)
|
_ 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 {
|
func (v AccessEntryIncrementalTag) IsValid() bool {
|
||||||
var str string
|
switch v {
|
||||||
|
case
|
||||||
switch v := value.(type) {
|
AccessEntryIncrementalTagNew,
|
||||||
case string:
|
AccessEntryIncrementalTagRemoved,
|
||||||
str = v
|
AccessEntryIncrementalTagUnchanged:
|
||||||
case []byte:
|
return true
|
||||||
str = string(v)
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("cannot scan AccessEntryIncrementalTag: unsupported type %T", value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch str {
|
return false
|
||||||
case "NEW":
|
}
|
||||||
*t = AccessEntryIncrementalTagNew
|
|
||||||
case "REMOVED":
|
func (v AccessEntryIncrementalTag) String() string {
|
||||||
*t = AccessEntryIncrementalTagRemoved
|
return string(v)
|
||||||
case "UNCHANGED":
|
}
|
||||||
*t = AccessEntryIncrementalTagUnchanged
|
|
||||||
default:
|
func (v AccessEntryIncrementalTag) MarshalText() ([]byte, error) {
|
||||||
return fmt.Errorf("cannot parse AccessEntryIncrementalTag: invalid value %q", str)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t AccessEntryIncrementalTag) Value() (driver.Value, error) {
|
|
||||||
return t.String(), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,57 +16,63 @@ package coredata
|
|||||||
|
|
||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
func TestAccessEntryIncrementalTagScan(t *testing.T) {
|
func TestAccessEntryIncrementalTagIsValid(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tests := []struct {
|
for _, value := range AccessEntryIncrementalTags() {
|
||||||
name string
|
if !value.IsValid() {
|
||||||
input any
|
t.Fatalf("IsValid() = false for %q", value)
|
||||||
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 _, tt := range tests {
|
if AccessEntryIncrementalTag("BOGUS").IsValid() {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
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()
|
t.Parallel()
|
||||||
|
|
||||||
var got AccessEntryIncrementalTag
|
var got AccessEntryIncrementalTag
|
||||||
|
if err := got.UnmarshalText([]byte(value)); err != nil {
|
||||||
err := got.Scan(tt.input)
|
t.Fatalf("UnmarshalText(%q) returned error: %v", value, err)
|
||||||
if tt.wantErr {
|
|
||||||
if err == nil {
|
|
||||||
t.Fatalf("Scan(%v) expected error", tt.input)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
if err != nil {
|
||||||
t.Fatalf("Scan(%v) returned error: %v", tt.input, err)
|
t.Fatalf("MarshalText() returned error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if got != tt.want {
|
if string(got) != value.String() {
|
||||||
t.Fatalf("Scan(%v) = %q, want %q", tt.input, got, tt.want)
|
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
|
package coredata
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
AccessEntryOrderField string
|
AccessEntryOrderField string
|
||||||
@@ -24,6 +29,48 @@ const (
|
|||||||
AccessEntryOrderFieldCreatedAt AccessEntryOrderField = "CREATED_AT"
|
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 {
|
func (p AccessEntryOrderField) Column() string {
|
||||||
switch p {
|
switch p {
|
||||||
case AccessEntryOrderFieldCreatedAt:
|
case AccessEntryOrderFieldCreatedAt:
|
||||||
@@ -32,29 +79,3 @@ func (p AccessEntryOrderField) Column() string {
|
|||||||
|
|
||||||
panic(fmt.Sprintf("unsupported order by: %s", p))
|
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
|
package coredata
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
AccessReviewCampaignOrderField string
|
AccessReviewCampaignOrderField string
|
||||||
@@ -24,6 +29,48 @@ const (
|
|||||||
AccessReviewCampaignOrderFieldCreatedAt AccessReviewCampaignOrderField = "CREATED_AT"
|
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 {
|
func (p AccessReviewCampaignOrderField) Column() string {
|
||||||
switch p {
|
switch p {
|
||||||
case AccessReviewCampaignOrderFieldCreatedAt:
|
case AccessReviewCampaignOrderFieldCreatedAt:
|
||||||
@@ -32,29 +79,3 @@ func (p AccessReviewCampaignOrderField) Column() string {
|
|||||||
|
|
||||||
panic(fmt.Sprintf("unsupported order by: %s", p))
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,42 +28,53 @@ const (
|
|||||||
AccessReviewCampaignSourceFetchStatusFailed AccessReviewCampaignSourceFetchStatus = "FAILED"
|
AccessReviewCampaignSourceFetchStatusFailed AccessReviewCampaignSourceFetchStatus = "FAILED"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s AccessReviewCampaignSourceFetchStatus) IsTerminal() bool {
|
var (
|
||||||
return s == AccessReviewCampaignSourceFetchStatusSuccess || s == AccessReviewCampaignSourceFetchStatusFailed
|
_ fmt.Stringer = AccessReviewCampaignSourceFetchStatus("")
|
||||||
|
_ encoding.TextMarshaler = AccessReviewCampaignSourceFetchStatus("")
|
||||||
|
_ encoding.TextUnmarshaler = (*AccessReviewCampaignSourceFetchStatus)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
func AccessReviewCampaignSourceFetchStatuses() []AccessReviewCampaignSourceFetchStatus {
|
||||||
|
return []AccessReviewCampaignSourceFetchStatus{
|
||||||
|
AccessReviewCampaignSourceFetchStatusQueued,
|
||||||
|
AccessReviewCampaignSourceFetchStatusFetching,
|
||||||
|
AccessReviewCampaignSourceFetchStatusSuccess,
|
||||||
|
AccessReviewCampaignSourceFetchStatusFailed,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s AccessReviewCampaignSourceFetchStatus) String() string {
|
func (v AccessReviewCampaignSourceFetchStatus) IsValid() bool {
|
||||||
return string(s)
|
switch v {
|
||||||
|
case
|
||||||
|
AccessReviewCampaignSourceFetchStatusQueued,
|
||||||
|
AccessReviewCampaignSourceFetchStatusFetching,
|
||||||
|
AccessReviewCampaignSourceFetchStatusSuccess,
|
||||||
|
AccessReviewCampaignSourceFetchStatusFailed:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *AccessReviewCampaignSourceFetchStatus) Scan(value any) error {
|
func (v AccessReviewCampaignSourceFetchStatus) String() string {
|
||||||
var str string
|
return string(v)
|
||||||
|
}
|
||||||
|
|
||||||
switch v := value.(type) {
|
func (v AccessReviewCampaignSourceFetchStatus) MarshalText() ([]byte, error) {
|
||||||
case string:
|
return []byte(v.String()), nil
|
||||||
str = v
|
}
|
||||||
case []byte:
|
|
||||||
str = string(v)
|
func (v *AccessReviewCampaignSourceFetchStatus) UnmarshalText(text []byte) error {
|
||||||
default:
|
val := AccessReviewCampaignSourceFetchStatus(text)
|
||||||
return fmt.Errorf("cannot scan AccessReviewCampaignSourceFetchStatus: unsupported type %T", value)
|
if !val.IsValid() {
|
||||||
|
return fmt.Errorf("invalid AccessReviewCampaignSourceFetchStatus value: %q", string(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
switch str {
|
*v = val
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s AccessReviewCampaignSourceFetchStatus) Value() (driver.Value, error) {
|
func (s AccessReviewCampaignSourceFetchStatus) IsTerminal() bool {
|
||||||
return s.String(), nil
|
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()
|
t.Parallel()
|
||||||
|
|
||||||
tests := []struct {
|
for _, value := range AccessReviewCampaignSourceFetchStatuses() {
|
||||||
name string
|
if !value.IsValid() {
|
||||||
input any
|
t.Fatalf("IsValid() = false for %q", value)
|
||||||
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 _, tt := range tests {
|
if AccessReviewCampaignSourceFetchStatus("BOGUS").IsValid() {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
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()
|
t.Parallel()
|
||||||
|
|
||||||
var got AccessReviewCampaignSourceFetchStatus
|
var got AccessReviewCampaignSourceFetchStatus
|
||||||
|
if err := got.UnmarshalText([]byte(value)); err != nil {
|
||||||
err := got.Scan(tt.input)
|
t.Fatalf("UnmarshalText(%q) returned error: %v", value, err)
|
||||||
if tt.wantErr {
|
|
||||||
if err == nil {
|
|
||||||
t.Fatalf("Scan(%v) expected error", tt.input)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
if err != nil {
|
||||||
t.Fatalf("Scan(%v) returned error: %v", tt.input, err)
|
t.Fatalf("MarshalText() returned error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if got != tt.want {
|
if string(got) != value.String() {
|
||||||
t.Fatalf("Scan(%v) = %q, want %q", tt.input, got, tt.want)
|
t.Fatalf("MarshalText() = %q, want %q", string(got), value.String())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -29,40 +29,51 @@ const (
|
|||||||
AccessReviewCampaignStatusCancelled AccessReviewCampaignStatus = "CANCELLED"
|
AccessReviewCampaignStatusCancelled AccessReviewCampaignStatus = "CANCELLED"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s AccessReviewCampaignStatus) String() string {
|
var (
|
||||||
return string(s)
|
_ 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 {
|
func (v AccessReviewCampaignStatus) IsValid() bool {
|
||||||
var str string
|
switch v {
|
||||||
|
case
|
||||||
switch v := value.(type) {
|
AccessReviewCampaignStatusDraft,
|
||||||
case string:
|
AccessReviewCampaignStatusInProgress,
|
||||||
str = v
|
AccessReviewCampaignStatusPendingActions,
|
||||||
case []byte:
|
AccessReviewCampaignStatusCompleted,
|
||||||
str = string(v)
|
AccessReviewCampaignStatusCancelled:
|
||||||
default:
|
return true
|
||||||
return fmt.Errorf("cannot scan AccessReviewCampaignStatus: unsupported type %T", value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch str {
|
return false
|
||||||
case "DRAFT":
|
}
|
||||||
*s = AccessReviewCampaignStatusDraft
|
|
||||||
case "IN_PROGRESS":
|
func (v AccessReviewCampaignStatus) String() string {
|
||||||
*s = AccessReviewCampaignStatusInProgress
|
return string(v)
|
||||||
case "PENDING_ACTIONS":
|
}
|
||||||
*s = AccessReviewCampaignStatusPendingActions
|
|
||||||
case "COMPLETED":
|
func (v AccessReviewCampaignStatus) MarshalText() ([]byte, error) {
|
||||||
*s = AccessReviewCampaignStatusCompleted
|
return []byte(v.String()), nil
|
||||||
case "CANCELLED":
|
}
|
||||||
*s = AccessReviewCampaignStatusCancelled
|
|
||||||
default:
|
func (v *AccessReviewCampaignStatus) UnmarshalText(text []byte) error {
|
||||||
return fmt.Errorf("cannot parse AccessReviewCampaignStatus: invalid value %q", str)
|
val := AccessReviewCampaignStatus(text)
|
||||||
|
if !val.IsValid() {
|
||||||
|
return fmt.Errorf("invalid AccessReviewCampaignStatus value: %q", string(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*v = val
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s AccessReviewCampaignStatus) Value() (driver.Value, error) {
|
|
||||||
return s.String(), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,74 +16,62 @@ package coredata
|
|||||||
|
|
||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
func TestAccessReviewCampaignStatusScan(t *testing.T) {
|
func TestAccessReviewCampaignStatusIsValid(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tests := []struct {
|
for _, value := range AccessReviewCampaignStatuses() {
|
||||||
name string
|
if !value.IsValid() {
|
||||||
input any
|
t.Fatalf("IsValid() = false for %q", value)
|
||||||
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 _, tt := range tests {
|
if AccessReviewCampaignStatus("BOGUS").IsValid() {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
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()
|
t.Parallel()
|
||||||
|
|
||||||
var got AccessReviewCampaignStatus
|
var got AccessReviewCampaignStatus
|
||||||
|
if err := got.UnmarshalText([]byte(value)); err != nil {
|
||||||
err := got.Scan(tt.input)
|
t.Fatalf("UnmarshalText(%q) returned error: %v", value, err)
|
||||||
if tt.wantErr {
|
|
||||||
if err == nil {
|
|
||||||
t.Fatalf("Scan(%v) expected error", tt.input)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if got != value {
|
||||||
t.Fatalf("Scan(%v) returned error: %v", tt.input, err)
|
t.Fatalf("UnmarshalText(%q) = %q, want %q", value, got, value)
|
||||||
}
|
|
||||||
|
|
||||||
if got != tt.want {
|
|
||||||
t.Fatalf("Scan(%v) = %q, want %q", tt.input, got, tt.want)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
t.Parallel()
|
||||||
|
|
||||||
tests := []struct {
|
for _, value := range AccessReviewCampaignStatuses() {
|
||||||
name string
|
t.Run(string(value), func(t *testing.T) {
|
||||||
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) {
|
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
got, err := tt.status.Value()
|
got, err := value.MarshalText()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Value() returned error: %v", err)
|
t.Fatalf("MarshalText() returned error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if got != tt.want {
|
if string(got) != value.String() {
|
||||||
t.Fatalf("Value() = %q, want %q", got, tt.want)
|
t.Fatalf("MarshalText() = %q, want %q", string(got), value.String())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,6 +28,12 @@ const (
|
|||||||
AccessSourceCategoryOther AccessSourceCategory = "OTHER"
|
AccessSourceCategoryOther AccessSourceCategory = "OTHER"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Stringer = AccessSourceCategory("")
|
||||||
|
_ encoding.TextMarshaler = AccessSourceCategory("")
|
||||||
|
_ encoding.TextUnmarshaler = (*AccessSourceCategory)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func AccessSourceCategories() []AccessSourceCategory {
|
func AccessSourceCategories() []AccessSourceCategory {
|
||||||
return []AccessSourceCategory{
|
return []AccessSourceCategory{
|
||||||
AccessSourceCategorySaaS,
|
AccessSourceCategorySaaS,
|
||||||
@@ -37,38 +43,34 @@ func AccessSourceCategories() []AccessSourceCategory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c AccessSourceCategory) String() string {
|
func (v AccessSourceCategory) IsValid() bool {
|
||||||
return string(c)
|
switch v {
|
||||||
|
case
|
||||||
|
AccessSourceCategorySaaS,
|
||||||
|
AccessSourceCategoryCloudInfra,
|
||||||
|
AccessSourceCategorySourceCode,
|
||||||
|
AccessSourceCategoryOther:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *AccessSourceCategory) Scan(value any) error {
|
func (v AccessSourceCategory) String() string {
|
||||||
var str string
|
return string(v)
|
||||||
|
}
|
||||||
|
|
||||||
switch v := value.(type) {
|
func (v AccessSourceCategory) MarshalText() ([]byte, error) {
|
||||||
case string:
|
return []byte(v.String()), nil
|
||||||
str = v
|
}
|
||||||
case []byte:
|
|
||||||
str = string(v)
|
func (v *AccessSourceCategory) UnmarshalText(text []byte) error {
|
||||||
default:
|
val := AccessSourceCategory(text)
|
||||||
return fmt.Errorf("cannot scan AccessSourceCategory: unsupported type %T", value)
|
if !val.IsValid() {
|
||||||
|
return fmt.Errorf("invalid AccessSourceCategory value: %q", string(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
switch str {
|
*v = val
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c AccessSourceCategory) Value() (driver.Value, error) {
|
|
||||||
return c.String(), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,58 +16,63 @@ package coredata
|
|||||||
|
|
||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
func TestAccessSourceCategoryScan(t *testing.T) {
|
func TestAccessSourceCategoryIsValid(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tests := []struct {
|
for _, value := range AccessSourceCategories() {
|
||||||
name string
|
if !value.IsValid() {
|
||||||
input any
|
t.Fatalf("IsValid() = false for %q", value)
|
||||||
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 _, tt := range tests {
|
if AccessSourceCategory("BOGUS").IsValid() {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
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()
|
t.Parallel()
|
||||||
|
|
||||||
var got AccessSourceCategory
|
var got AccessSourceCategory
|
||||||
|
if err := got.UnmarshalText([]byte(value)); err != nil {
|
||||||
err := got.Scan(tt.input)
|
t.Fatalf("UnmarshalText(%q) returned error: %v", value, err)
|
||||||
if tt.wantErr {
|
|
||||||
if err == nil {
|
|
||||||
t.Fatalf("Scan(%v) expected error", tt.input)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
if err != nil {
|
||||||
t.Fatalf("Scan(%v) returned error: %v", tt.input, err)
|
t.Fatalf("MarshalText() returned error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if got != tt.want {
|
if string(got) != value.String() {
|
||||||
t.Fatalf("Scan(%v) = %q, want %q", tt.input, got, tt.want)
|
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
|
package coredata
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
AccessSourceOrderField string
|
AccessSourceOrderField string
|
||||||
@@ -24,6 +29,48 @@ const (
|
|||||||
AccessSourceOrderFieldCreatedAt AccessSourceOrderField = "CREATED_AT"
|
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 {
|
func (p AccessSourceOrderField) Column() string {
|
||||||
switch p {
|
switch p {
|
||||||
case AccessSourceOrderFieldCreatedAt:
|
case AccessSourceOrderFieldCreatedAt:
|
||||||
@@ -32,29 +79,3 @@ func (p AccessSourceOrderField) Column() string {
|
|||||||
|
|
||||||
panic(fmt.Sprintf("unsupported order by: %s", p))
|
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 (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -60,6 +61,57 @@ const (
|
|||||||
AgentRunStatusFailed AgentRunStatus = "FAILED"
|
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 {
|
func (e AgentRun) CursorKey(orderBy AgentRunOrderField) page.CursorKey {
|
||||||
switch orderBy {
|
switch orderBy {
|
||||||
case AgentRunOrderFieldCreatedAt:
|
case AgentRunOrderFieldCreatedAt:
|
||||||
|
|||||||
@@ -14,7 +14,12 @@
|
|||||||
|
|
||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
AgentRunOrderField string
|
AgentRunOrderField string
|
||||||
@@ -24,6 +29,48 @@ const (
|
|||||||
AgentRunOrderFieldCreatedAt AgentRunOrderField = "CREATED_AT"
|
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 {
|
func (p AgentRunOrderField) Column() string {
|
||||||
switch p {
|
switch p {
|
||||||
case AgentRunOrderFieldCreatedAt:
|
case AgentRunOrderFieldCreatedAt:
|
||||||
@@ -32,29 +79,3 @@ func (p AgentRunOrderField) Column() string {
|
|||||||
|
|
||||||
panic(fmt.Sprintf("unsupported order by: %s", p))
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ApplicabilityStatementOrderField string
|
type ApplicabilityStatementOrderField string
|
||||||
@@ -25,6 +28,50 @@ const (
|
|||||||
ApplicabilityStatementOrderFieldControlSectionTitle ApplicabilityStatementOrderField = "CONTROL_SECTION_TITLE"
|
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 {
|
func (p ApplicabilityStatementOrderField) Column() string {
|
||||||
switch p {
|
switch p {
|
||||||
case ApplicabilityStatementOrderFieldCreatedAt:
|
case ApplicabilityStatementOrderFieldCreatedAt:
|
||||||
@@ -35,23 +82,3 @@ func (p ApplicabilityStatementOrderField) Column() string {
|
|||||||
|
|
||||||
panic("unknown ApplicabilityStatementOrderField")
|
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
|
package coredata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type AssetOrderField string
|
type AssetOrderField string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -22,10 +29,52 @@ const (
|
|||||||
AssetOrderFieldName AssetOrderField = "NAME"
|
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 {
|
func (p AssetOrderField) Column() string {
|
||||||
return string(p)
|
return string(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p AssetOrderField) String() string {
|
|
||||||
return string(p)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,6 +28,12 @@ const (
|
|||||||
AssetTypeVirtual AssetType = "VIRTUAL"
|
AssetTypeVirtual AssetType = "VIRTUAL"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Stringer = AssetType("")
|
||||||
|
_ encoding.TextMarshaler = AssetType("")
|
||||||
|
_ encoding.TextUnmarshaler = (*AssetType)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func AssetTypes() []AssetType {
|
func AssetTypes() []AssetType {
|
||||||
return []AssetType{
|
return []AssetType{
|
||||||
AssetTypePhysical,
|
AssetTypePhysical,
|
||||||
@@ -35,38 +41,32 @@ func AssetTypes() []AssetType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (at AssetType) MarshalText() ([]byte, error) {
|
func (v AssetType) IsValid() bool {
|
||||||
return []byte(at.String()), nil
|
switch v {
|
||||||
|
case
|
||||||
|
AssetTypePhysical,
|
||||||
|
AssetTypeVirtual:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (at *AssetType) UnmarshalText(data []byte) error {
|
func (v AssetType) String() string {
|
||||||
val := string(data)
|
return string(v)
|
||||||
|
}
|
||||||
|
|
||||||
switch val {
|
func (v AssetType) MarshalText() ([]byte, error) {
|
||||||
case AssetTypePhysical.String():
|
return []byte(v.String()), nil
|
||||||
*at = AssetTypePhysical
|
}
|
||||||
case AssetTypeVirtual.String():
|
|
||||||
*at = AssetTypeVirtual
|
func (v *AssetType) UnmarshalText(text []byte) error {
|
||||||
default:
|
val := AssetType(text)
|
||||||
return fmt.Errorf("invalid AssetType value: %q", val)
|
if !val.IsValid() {
|
||||||
|
return fmt.Errorf("invalid AssetType value: %q", string(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*v = val
|
||||||
|
|
||||||
return nil
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -27,47 +27,47 @@ const (
|
|||||||
AuditLogActorTypeSystem AuditLogActorType = "SYSTEM"
|
AuditLogActorTypeSystem AuditLogActorType = "SYSTEM"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (a AuditLogActorType) String() string {
|
var (
|
||||||
return string(a)
|
_ fmt.Stringer = AuditLogActorType("")
|
||||||
|
_ encoding.TextMarshaler = AuditLogActorType("")
|
||||||
|
_ encoding.TextUnmarshaler = (*AuditLogActorType)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
func AuditLogActorTypes() []AuditLogActorType {
|
||||||
|
return []AuditLogActorType{
|
||||||
|
AuditLogActorTypeUser,
|
||||||
|
AuditLogActorTypeAPIKey,
|
||||||
|
AuditLogActorTypeSystem,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a AuditLogActorType) IsValid() bool {
|
func (v AuditLogActorType) IsValid() bool {
|
||||||
switch a {
|
switch v {
|
||||||
case AuditLogActorTypeUser, AuditLogActorTypeAPIKey, AuditLogActorTypeSystem:
|
case
|
||||||
|
AuditLogActorTypeUser,
|
||||||
|
AuditLogActorTypeAPIKey,
|
||||||
|
AuditLogActorTypeSystem:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a AuditLogActorType) MarshalText() ([]byte, error) {
|
func (v AuditLogActorType) String() string {
|
||||||
return []byte(a.String()), nil
|
return string(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AuditLogActorType) UnmarshalText(text []byte) error {
|
func (v AuditLogActorType) MarshalText() ([]byte, error) {
|
||||||
*a = AuditLogActorType(text)
|
return []byte(v.String()), nil
|
||||||
if !a.IsValid() {
|
}
|
||||||
return fmt.Errorf("%s is not a valid AuditLogActorType", string(text))
|
|
||||||
|
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
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AuditLogEntryOrderField string
|
type AuditLogEntryOrderField string
|
||||||
@@ -24,6 +27,48 @@ const (
|
|||||||
AuditLogEntryOrderFieldCreatedAt AuditLogEntryOrderField = "CREATED_AT"
|
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 {
|
func (p AuditLogEntryOrderField) Column() string {
|
||||||
switch p {
|
switch p {
|
||||||
case AuditLogEntryOrderFieldCreatedAt:
|
case AuditLogEntryOrderFieldCreatedAt:
|
||||||
@@ -32,29 +77,3 @@ func (p AuditLogEntryOrderField) Column() string {
|
|||||||
|
|
||||||
panic(fmt.Sprintf("unsupported order by: %s", p))
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AuditOrderField string
|
type AuditOrderField string
|
||||||
@@ -27,28 +30,54 @@ const (
|
|||||||
AuditOrderFieldState AuditOrderField = "STATE"
|
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 {
|
func (p AuditOrderField) Column() string {
|
||||||
return string(p)
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -29,6 +29,12 @@ const (
|
|||||||
AuditStateOutdated AuditState = "OUTDATED"
|
AuditStateOutdated AuditState = "OUTDATED"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Stringer = AuditState("")
|
||||||
|
_ encoding.TextMarshaler = AuditState("")
|
||||||
|
_ encoding.TextUnmarshaler = (*AuditState)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func AuditStates() []AuditState {
|
func AuditStates() []AuditState {
|
||||||
return []AuditState{
|
return []AuditState{
|
||||||
AuditStateNotStarted,
|
AuditStateNotStarted,
|
||||||
@@ -39,40 +45,35 @@ func AuditStates() []AuditState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (as AuditState) String() string {
|
func (v AuditState) IsValid() bool {
|
||||||
return string(as)
|
switch v {
|
||||||
|
case
|
||||||
|
AuditStateNotStarted,
|
||||||
|
AuditStateInProgress,
|
||||||
|
AuditStateCompleted,
|
||||||
|
AuditStateRejected,
|
||||||
|
AuditStateOutdated:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (as *AuditState) Scan(value any) error {
|
func (v AuditState) String() string {
|
||||||
var s string
|
return string(v)
|
||||||
|
}
|
||||||
|
|
||||||
switch v := value.(type) {
|
func (v AuditState) MarshalText() ([]byte, error) {
|
||||||
case string:
|
return []byte(v.String()), nil
|
||||||
s = v
|
}
|
||||||
case []byte:
|
|
||||||
s = string(v)
|
func (v *AuditState) UnmarshalText(text []byte) error {
|
||||||
default:
|
val := AuditState(text)
|
||||||
return fmt.Errorf("unsupported type for AuditState: %T", value)
|
if !val.IsValid() {
|
||||||
|
return fmt.Errorf("invalid AuditState value: %q", string(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
switch s {
|
*v = val
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (as AuditState) Value() (driver.Value, error) {
|
|
||||||
return as.String(), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -29,6 +29,12 @@ const (
|
|||||||
AccessEntryAuthMethodUnknown AccessEntryAuthMethod = "UNKNOWN"
|
AccessEntryAuthMethodUnknown AccessEntryAuthMethod = "UNKNOWN"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Stringer = AccessEntryAuthMethod("")
|
||||||
|
_ encoding.TextMarshaler = AccessEntryAuthMethod("")
|
||||||
|
_ encoding.TextUnmarshaler = (*AccessEntryAuthMethod)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func AccessEntryAuthMethods() []AccessEntryAuthMethod {
|
func AccessEntryAuthMethods() []AccessEntryAuthMethod {
|
||||||
return []AccessEntryAuthMethod{
|
return []AccessEntryAuthMethod{
|
||||||
AccessEntryAuthMethodSSO,
|
AccessEntryAuthMethodSSO,
|
||||||
@@ -39,40 +45,35 @@ func AccessEntryAuthMethods() []AccessEntryAuthMethod {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a AccessEntryAuthMethod) String() string {
|
func (v AccessEntryAuthMethod) IsValid() bool {
|
||||||
return string(a)
|
switch v {
|
||||||
|
case
|
||||||
|
AccessEntryAuthMethodSSO,
|
||||||
|
AccessEntryAuthMethodPassword,
|
||||||
|
AccessEntryAuthMethodAPIKey,
|
||||||
|
AccessEntryAuthMethodServiceAccount,
|
||||||
|
AccessEntryAuthMethodUnknown:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AccessEntryAuthMethod) Scan(value any) error {
|
func (v AccessEntryAuthMethod) String() string {
|
||||||
var str string
|
return string(v)
|
||||||
|
}
|
||||||
|
|
||||||
switch v := value.(type) {
|
func (v AccessEntryAuthMethod) MarshalText() ([]byte, error) {
|
||||||
case string:
|
return []byte(v.String()), nil
|
||||||
str = v
|
}
|
||||||
case []byte:
|
|
||||||
str = string(v)
|
func (v *AccessEntryAuthMethod) UnmarshalText(text []byte) error {
|
||||||
default:
|
val := AccessEntryAuthMethod(text)
|
||||||
return fmt.Errorf("cannot scan AccessEntryAuthMethod: unsupported type %T", value)
|
if !val.IsValid() {
|
||||||
|
return fmt.Errorf("invalid AccessEntryAuthMethod value: %q", string(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
switch str {
|
*v = val
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a AccessEntryAuthMethod) Value() (driver.Value, error) {
|
|
||||||
return a.String(), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,8 +15,7 @@
|
|||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -29,6 +28,12 @@ const (
|
|||||||
BusinessImpactCritical BusinessImpact = "CRITICAL"
|
BusinessImpactCritical BusinessImpact = "CRITICAL"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Stringer = BusinessImpact("")
|
||||||
|
_ encoding.TextMarshaler = BusinessImpact("")
|
||||||
|
_ encoding.TextUnmarshaler = (*BusinessImpact)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func BusinessImpacts() []BusinessImpact {
|
func BusinessImpacts() []BusinessImpact {
|
||||||
return []BusinessImpact{
|
return []BusinessImpact{
|
||||||
BusinessImpactLow,
|
BusinessImpactLow,
|
||||||
@@ -38,76 +43,34 @@ func BusinessImpacts() []BusinessImpact {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i BusinessImpact) String() string {
|
func (v BusinessImpact) IsValid() bool {
|
||||||
return string(i)
|
switch v {
|
||||||
|
case
|
||||||
|
BusinessImpactLow,
|
||||||
|
BusinessImpactMedium,
|
||||||
|
BusinessImpactHigh,
|
||||||
|
BusinessImpactCritical:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *BusinessImpact) Scan(value any) error {
|
func (v BusinessImpact) String() string {
|
||||||
switch v := value.(type) {
|
return string(v)
|
||||||
case string:
|
}
|
||||||
switch v {
|
|
||||||
case "LOW":
|
func (v BusinessImpact) MarshalText() ([]byte, error) {
|
||||||
*i = BusinessImpactLow
|
return []byte(v.String()), nil
|
||||||
case "MEDIUM":
|
}
|
||||||
*i = BusinessImpactMedium
|
|
||||||
case "HIGH":
|
func (v *BusinessImpact) UnmarshalText(text []byte) error {
|
||||||
*i = BusinessImpactHigh
|
val := BusinessImpact(text)
|
||||||
case "CRITICAL":
|
if !val.IsValid() {
|
||||||
*i = BusinessImpactCritical
|
return fmt.Errorf("invalid BusinessImpact value: %q", string(text))
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*v = val
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,13 @@
|
|||||||
|
|
||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
ComplianceExternalURLOrderField string
|
ComplianceExternalURLOrderField string
|
||||||
)
|
)
|
||||||
@@ -23,6 +30,50 @@ const (
|
|||||||
ComplianceExternalURLOrderFieldRank ComplianceExternalURLOrderField = "RANK"
|
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 {
|
func (p ComplianceExternalURLOrderField) Column() string {
|
||||||
switch p {
|
switch p {
|
||||||
case ComplianceExternalURLOrderFieldCreatedAt:
|
case ComplianceExternalURLOrderFieldCreatedAt:
|
||||||
@@ -33,16 +84,3 @@ func (p ComplianceExternalURLOrderField) Column() string {
|
|||||||
return string(p)
|
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
|
package coredata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
ComplianceFrameworkOrderField string
|
ComplianceFrameworkOrderField string
|
||||||
)
|
)
|
||||||
@@ -23,6 +30,50 @@ const (
|
|||||||
ComplianceFrameworkOrderFieldRank ComplianceFrameworkOrderField = "RANK"
|
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 {
|
func (p ComplianceFrameworkOrderField) Column() string {
|
||||||
switch p {
|
switch p {
|
||||||
case ComplianceFrameworkOrderFieldCreatedAt:
|
case ComplianceFrameworkOrderFieldCreatedAt:
|
||||||
@@ -33,16 +84,3 @@ func (p ComplianceFrameworkOrderField) Column() string {
|
|||||||
return string(p)
|
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
|
package coredata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
type ComplianceFrameworkVisibility string
|
type ComplianceFrameworkVisibility string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -21,6 +26,45 @@ const (
|
|||||||
ComplianceFrameworkVisibilityPublic ComplianceFrameworkVisibility = "PUBLIC"
|
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 {
|
func (v ComplianceFrameworkVisibility) String() string {
|
||||||
return string(v)
|
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
|
package coredata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
ConnectorOrderField string
|
ConnectorOrderField string
|
||||||
)
|
)
|
||||||
@@ -23,19 +30,50 @@ const (
|
|||||||
ConnectorOrderFieldProvider ConnectorOrderField = "PROVIDER"
|
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 {
|
func (p ConnectorOrderField) Column() string {
|
||||||
return string(p)
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -26,6 +26,12 @@ const (
|
|||||||
ConnectorProtocolAPIKey ConnectorProtocol = "API_KEY"
|
ConnectorProtocolAPIKey ConnectorProtocol = "API_KEY"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Stringer = ConnectorProtocol("")
|
||||||
|
_ encoding.TextMarshaler = ConnectorProtocol("")
|
||||||
|
_ encoding.TextUnmarshaler = (*ConnectorProtocol)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func ConnectorProtocols() []ConnectorProtocol {
|
func ConnectorProtocols() []ConnectorProtocol {
|
||||||
return []ConnectorProtocol{
|
return []ConnectorProtocol{
|
||||||
ConnectorProtocolOAuth2,
|
ConnectorProtocolOAuth2,
|
||||||
@@ -33,34 +39,32 @@ func ConnectorProtocols() []ConnectorProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cp ConnectorProtocol) String() string {
|
func (v ConnectorProtocol) IsValid() bool {
|
||||||
return string(cp)
|
switch v {
|
||||||
|
case
|
||||||
|
ConnectorProtocolOAuth2,
|
||||||
|
ConnectorProtocolAPIKey:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cp *ConnectorProtocol) Scan(value any) error {
|
func (v ConnectorProtocol) String() string {
|
||||||
var s string
|
return string(v)
|
||||||
|
}
|
||||||
|
|
||||||
switch v := value.(type) {
|
func (v ConnectorProtocol) MarshalText() ([]byte, error) {
|
||||||
case string:
|
return []byte(v.String()), nil
|
||||||
s = v
|
}
|
||||||
case []byte:
|
|
||||||
s = string(v)
|
func (v *ConnectorProtocol) UnmarshalText(text []byte) error {
|
||||||
default:
|
val := ConnectorProtocol(text)
|
||||||
return fmt.Errorf("unsupported type for ConnectorProtocol: %T", value)
|
if !val.IsValid() {
|
||||||
|
return fmt.Errorf("invalid ConnectorProtocol value: %q", string(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
switch s {
|
*v = val
|
||||||
case "OAUTH2":
|
|
||||||
*cp = ConnectorProtocolOAuth2
|
|
||||||
case "API_KEY":
|
|
||||||
*cp = ConnectorProtocolAPIKey
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("invalid ConnectorProtocol value: %q", s)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cp ConnectorProtocol) Value() (driver.Value, error) {
|
|
||||||
return cp.String(), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -51,6 +51,12 @@ const (
|
|||||||
ConnectorProviderMonday ConnectorProvider = "MONDAY"
|
ConnectorProviderMonday ConnectorProvider = "MONDAY"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Stringer = ConnectorProvider("")
|
||||||
|
_ encoding.TextMarshaler = ConnectorProvider("")
|
||||||
|
_ encoding.TextUnmarshaler = (*ConnectorProvider)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func ConnectorProviders() []ConnectorProvider {
|
func ConnectorProviders() []ConnectorProvider {
|
||||||
return []ConnectorProvider{
|
return []ConnectorProvider{
|
||||||
ConnectorProviderSlack,
|
ConnectorProviderSlack,
|
||||||
@@ -82,82 +88,56 @@ func ConnectorProviders() []ConnectorProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cp ConnectorProvider) String() string {
|
func (v ConnectorProvider) IsValid() bool {
|
||||||
return string(cp)
|
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 {
|
func (v ConnectorProvider) String() string {
|
||||||
var s string
|
return string(v)
|
||||||
|
}
|
||||||
|
|
||||||
switch v := value.(type) {
|
func (v ConnectorProvider) MarshalText() ([]byte, error) {
|
||||||
case string:
|
return []byte(v.String()), nil
|
||||||
s = v
|
}
|
||||||
case []byte:
|
|
||||||
s = string(v)
|
func (v *ConnectorProvider) UnmarshalText(text []byte) error {
|
||||||
default:
|
val := ConnectorProvider(text)
|
||||||
return fmt.Errorf("unsupported type for ConnectorProvider: %T", value)
|
if !val.IsValid() {
|
||||||
|
return fmt.Errorf("invalid ConnectorProvider value: %q", string(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
switch s {
|
*v = val
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cp ConnectorProvider) Value() (driver.Value, error) {
|
|
||||||
return cp.String(), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -32,6 +32,12 @@ const (
|
|||||||
ControlMaturityLevelOptimizing ControlMaturityLevel = "OPTIMIZING"
|
ControlMaturityLevelOptimizing ControlMaturityLevel = "OPTIMIZING"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Stringer = ControlMaturityLevel("")
|
||||||
|
_ encoding.TextMarshaler = ControlMaturityLevel("")
|
||||||
|
_ encoding.TextUnmarshaler = (*ControlMaturityLevel)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func ControlMaturityLevels() []ControlMaturityLevel {
|
func ControlMaturityLevels() []ControlMaturityLevel {
|
||||||
return []ControlMaturityLevel{
|
return []ControlMaturityLevel{
|
||||||
ControlMaturityLevelNone,
|
ControlMaturityLevelNone,
|
||||||
@@ -43,9 +49,10 @@ func ControlMaturityLevels() []ControlMaturityLevel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l ControlMaturityLevel) IsValid() bool {
|
func (v ControlMaturityLevel) IsValid() bool {
|
||||||
switch l {
|
switch v {
|
||||||
case ControlMaturityLevelNone,
|
case
|
||||||
|
ControlMaturityLevelNone,
|
||||||
ControlMaturityLevelInitial,
|
ControlMaturityLevelInitial,
|
||||||
ControlMaturityLevelManaged,
|
ControlMaturityLevelManaged,
|
||||||
ControlMaturityLevelDefined,
|
ControlMaturityLevelDefined,
|
||||||
@@ -57,34 +64,21 @@ func (l ControlMaturityLevel) IsValid() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l ControlMaturityLevel) String() string {
|
func (v ControlMaturityLevel) String() string {
|
||||||
return string(l)
|
return string(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l ControlMaturityLevel) MarshalText() ([]byte, error) {
|
func (v ControlMaturityLevel) MarshalText() ([]byte, error) {
|
||||||
return []byte(l.String()), nil
|
return []byte(v.String()), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *ControlMaturityLevel) UnmarshalText(data []byte) error {
|
func (v *ControlMaturityLevel) UnmarshalText(text []byte) error {
|
||||||
val := ControlMaturityLevel(data)
|
val := ControlMaturityLevel(text)
|
||||||
if !val.IsValid() {
|
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
|
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) {
|
func TestControlMaturityLevelMarshalUnmarshalText(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,13 @@
|
|||||||
|
|
||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
ControlOrderField string
|
ControlOrderField string
|
||||||
)
|
)
|
||||||
@@ -23,6 +30,50 @@ const (
|
|||||||
ControlOrderFieldSectionTitle ControlOrderField = "SECTION_TITLE"
|
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 {
|
func (p ControlOrderField) Column() string {
|
||||||
switch p {
|
switch p {
|
||||||
case ControlOrderFieldCreatedAt:
|
case ControlOrderFieldCreatedAt:
|
||||||
@@ -33,16 +84,3 @@ func (p ControlOrderField) Column() string {
|
|||||||
return string(p)
|
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
|
package coredata
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type CookieBannerOrderField string
|
type CookieBannerOrderField string
|
||||||
|
|
||||||
@@ -22,6 +27,48 @@ const (
|
|||||||
CookieBannerOrderFieldCreatedAt CookieBannerOrderField = "CREATED_AT"
|
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 {
|
func (p CookieBannerOrderField) Column() string {
|
||||||
switch p {
|
switch p {
|
||||||
case CookieBannerOrderFieldCreatedAt:
|
case CookieBannerOrderFieldCreatedAt:
|
||||||
@@ -30,29 +77,3 @@ func (p CookieBannerOrderField) Column() string {
|
|||||||
|
|
||||||
panic(fmt.Sprintf("unsupported order by: %s", p))
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -26,6 +26,12 @@ const (
|
|||||||
CookieBannerStateInactive CookieBannerState = "INACTIVE"
|
CookieBannerStateInactive CookieBannerState = "INACTIVE"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Stringer = CookieBannerState("")
|
||||||
|
_ encoding.TextMarshaler = CookieBannerState("")
|
||||||
|
_ encoding.TextUnmarshaler = (*CookieBannerState)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func CookieBannerStates() []CookieBannerState {
|
func CookieBannerStates() []CookieBannerState {
|
||||||
return []CookieBannerState{
|
return []CookieBannerState{
|
||||||
CookieBannerStateActive,
|
CookieBannerStateActive,
|
||||||
@@ -33,40 +39,32 @@ func CookieBannerStates() []CookieBannerState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s CookieBannerState) String() string {
|
func (v CookieBannerState) IsValid() bool {
|
||||||
return string(s)
|
switch v {
|
||||||
|
case
|
||||||
|
CookieBannerStateActive,
|
||||||
|
CookieBannerStateInactive:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *CookieBannerState) Scan(value any) error {
|
func (v CookieBannerState) String() string {
|
||||||
var v string
|
return string(v)
|
||||||
|
}
|
||||||
|
|
||||||
switch val := value.(type) {
|
func (v CookieBannerState) MarshalText() ([]byte, error) {
|
||||||
case string:
|
return []byte(v.String()), nil
|
||||||
v = val
|
}
|
||||||
case []byte:
|
|
||||||
v = string(val)
|
func (v *CookieBannerState) UnmarshalText(text []byte) error {
|
||||||
default:
|
val := CookieBannerState(text)
|
||||||
return fmt.Errorf("unsupported type for CookieBannerState: %T", value)
|
if !val.IsValid() {
|
||||||
|
return fmt.Errorf("invalid CookieBannerState value: %q", string(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
switch CookieBannerState(v) {
|
*v = val
|
||||||
case CookieBannerStateActive:
|
|
||||||
*s = CookieBannerStateActive
|
|
||||||
case CookieBannerStateInactive:
|
|
||||||
*s = CookieBannerStateInactive
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("invalid CookieBannerState value: %q", v)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
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
|
package coredata
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type CookieBannerVersionOrderField string
|
type CookieBannerVersionOrderField string
|
||||||
|
|
||||||
@@ -22,6 +27,48 @@ const (
|
|||||||
CookieBannerVersionOrderFieldCreatedAt CookieBannerVersionOrderField = "CREATED_AT"
|
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 {
|
func (p CookieBannerVersionOrderField) Column() string {
|
||||||
switch p {
|
switch p {
|
||||||
case CookieBannerVersionOrderFieldCreatedAt:
|
case CookieBannerVersionOrderFieldCreatedAt:
|
||||||
@@ -30,29 +77,3 @@ func (p CookieBannerVersionOrderField) Column() string {
|
|||||||
|
|
||||||
panic(fmt.Sprintf("unsupported order by: %s", p))
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -26,6 +26,12 @@ const (
|
|||||||
CookieBannerVersionStatePublished CookieBannerVersionState = "PUBLISHED"
|
CookieBannerVersionStatePublished CookieBannerVersionState = "PUBLISHED"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Stringer = CookieBannerVersionState("")
|
||||||
|
_ encoding.TextMarshaler = CookieBannerVersionState("")
|
||||||
|
_ encoding.TextUnmarshaler = (*CookieBannerVersionState)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func CookieBannerVersionStates() []CookieBannerVersionState {
|
func CookieBannerVersionStates() []CookieBannerVersionState {
|
||||||
return []CookieBannerVersionState{
|
return []CookieBannerVersionState{
|
||||||
CookieBannerVersionStateDraft,
|
CookieBannerVersionStateDraft,
|
||||||
@@ -33,40 +39,32 @@ func CookieBannerVersionStates() []CookieBannerVersionState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s CookieBannerVersionState) String() string {
|
func (v CookieBannerVersionState) IsValid() bool {
|
||||||
return string(s)
|
switch v {
|
||||||
|
case
|
||||||
|
CookieBannerVersionStateDraft,
|
||||||
|
CookieBannerVersionStatePublished:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *CookieBannerVersionState) Scan(value any) error {
|
func (v CookieBannerVersionState) String() string {
|
||||||
var v string
|
return string(v)
|
||||||
|
}
|
||||||
|
|
||||||
switch val := value.(type) {
|
func (v CookieBannerVersionState) MarshalText() ([]byte, error) {
|
||||||
case string:
|
return []byte(v.String()), nil
|
||||||
v = val
|
}
|
||||||
case []byte:
|
|
||||||
v = string(val)
|
func (v *CookieBannerVersionState) UnmarshalText(text []byte) error {
|
||||||
default:
|
val := CookieBannerVersionState(text)
|
||||||
return fmt.Errorf("unsupported type for CookieBannerVersionState: %T", value)
|
if !val.IsValid() {
|
||||||
|
return fmt.Errorf("invalid CookieBannerVersionState value: %q", string(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
switch CookieBannerVersionState(v) {
|
*v = val
|
||||||
case CookieBannerVersionStateDraft:
|
|
||||||
*s = CookieBannerVersionStateDraft
|
|
||||||
case CookieBannerVersionStatePublished:
|
|
||||||
*s = CookieBannerVersionStatePublished
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("invalid CookieBannerVersionState value: %q", v)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
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
|
package coredata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
type CookieCategoryKind string
|
type CookieCategoryKind string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -22,6 +27,51 @@ const (
|
|||||||
CookieCategoryKindUncategorised CookieCategoryKind = "UNCATEGORISED"
|
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 {
|
func (k CookieCategoryKind) IsRequired() bool {
|
||||||
return k == CookieCategoryKindNecessary
|
return k == CookieCategoryKindNecessary
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,12 @@
|
|||||||
|
|
||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type CookieCategoryOrderField string
|
type CookieCategoryOrderField string
|
||||||
|
|
||||||
@@ -22,6 +27,48 @@ const (
|
|||||||
CookieCategoryOrderFieldRank CookieCategoryOrderField = "RANK"
|
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 {
|
func (p CookieCategoryOrderField) Column() string {
|
||||||
switch p {
|
switch p {
|
||||||
case CookieCategoryOrderFieldRank:
|
case CookieCategoryOrderFieldRank:
|
||||||
@@ -30,29 +77,3 @@ func (p CookieCategoryOrderField) Column() string {
|
|||||||
|
|
||||||
panic(fmt.Sprintf("unsupported order by: %s", p))
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -29,6 +29,12 @@ const (
|
|||||||
CookieConsentActionGPC CookieConsentAction = "GPC"
|
CookieConsentActionGPC CookieConsentAction = "GPC"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Stringer = CookieConsentAction("")
|
||||||
|
_ encoding.TextMarshaler = CookieConsentAction("")
|
||||||
|
_ encoding.TextUnmarshaler = (*CookieConsentAction)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func CookieConsentActions() []CookieConsentAction {
|
func CookieConsentActions() []CookieConsentAction {
|
||||||
return []CookieConsentAction{
|
return []CookieConsentAction{
|
||||||
CookieConsentActionAcceptAll,
|
CookieConsentActionAcceptAll,
|
||||||
@@ -38,46 +44,34 @@ func CookieConsentActions() []CookieConsentAction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a CookieConsentAction) String() string {
|
func (v CookieConsentAction) IsValid() bool {
|
||||||
return string(a)
|
switch v {
|
||||||
}
|
case
|
||||||
|
CookieConsentActionAcceptAll,
|
||||||
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,
|
|
||||||
CookieConsentActionRejectAll,
|
CookieConsentActionRejectAll,
|
||||||
CookieConsentActionCustomize,
|
CookieConsentActionCustomize,
|
||||||
CookieConsentActionGPC:
|
CookieConsentActionGPC:
|
||||||
return string(a), nil
|
return true
|
||||||
default:
|
|
||||||
return nil, fmt.Errorf("invalid CookieConsentAction: %s", a)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -26,6 +26,12 @@ const (
|
|||||||
CookieConsentModeOptOut CookieConsentMode = "OPT_OUT"
|
CookieConsentModeOptOut CookieConsentMode = "OPT_OUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Stringer = CookieConsentMode("")
|
||||||
|
_ encoding.TextMarshaler = CookieConsentMode("")
|
||||||
|
_ encoding.TextUnmarshaler = (*CookieConsentMode)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func CookieConsentModes() []CookieConsentMode {
|
func CookieConsentModes() []CookieConsentMode {
|
||||||
return []CookieConsentMode{
|
return []CookieConsentMode{
|
||||||
CookieConsentModeOptIn,
|
CookieConsentModeOptIn,
|
||||||
@@ -33,40 +39,32 @@ func CookieConsentModes() []CookieConsentMode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m CookieConsentMode) String() string {
|
func (v CookieConsentMode) IsValid() bool {
|
||||||
return string(m)
|
switch v {
|
||||||
|
case
|
||||||
|
CookieConsentModeOptIn,
|
||||||
|
CookieConsentModeOptOut:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *CookieConsentMode) Scan(value any) error {
|
func (v CookieConsentMode) String() string {
|
||||||
var v string
|
return string(v)
|
||||||
|
}
|
||||||
|
|
||||||
switch val := value.(type) {
|
func (v CookieConsentMode) MarshalText() ([]byte, error) {
|
||||||
case string:
|
return []byte(v.String()), nil
|
||||||
v = val
|
}
|
||||||
case []byte:
|
|
||||||
v = string(val)
|
func (v *CookieConsentMode) UnmarshalText(text []byte) error {
|
||||||
default:
|
val := CookieConsentMode(text)
|
||||||
return fmt.Errorf("unsupported type for CookieConsentMode: %T", value)
|
if !val.IsValid() {
|
||||||
|
return fmt.Errorf("invalid CookieConsentMode value: %q", string(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
switch CookieConsentMode(v) {
|
*v = val
|
||||||
case CookieConsentModeOptIn:
|
|
||||||
*m = CookieConsentModeOptIn
|
|
||||||
case CookieConsentModeOptOut:
|
|
||||||
*m = CookieConsentModeOptOut
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("invalid CookieConsentMode value: %q", v)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
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
|
package coredata
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type CookieConsentRecordOrderField string
|
type CookieConsentRecordOrderField string
|
||||||
|
|
||||||
@@ -22,6 +27,48 @@ const (
|
|||||||
CookieConsentRecordOrderFieldCreatedAt CookieConsentRecordOrderField = "CREATED_AT"
|
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 {
|
func (p CookieConsentRecordOrderField) Column() string {
|
||||||
switch p {
|
switch p {
|
||||||
case CookieConsentRecordOrderFieldCreatedAt:
|
case CookieConsentRecordOrderFieldCreatedAt:
|
||||||
@@ -30,29 +77,3 @@ func (p CookieConsentRecordOrderField) Column() string {
|
|||||||
|
|
||||||
panic(fmt.Sprintf("unsupported order by: %s", p))
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -27,6 +27,12 @@ const (
|
|||||||
CookieSourceHTTP CookieSource = "HTTP"
|
CookieSourceHTTP CookieSource = "HTTP"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Stringer = CookieSource("")
|
||||||
|
_ encoding.TextMarshaler = CookieSource("")
|
||||||
|
_ encoding.TextUnmarshaler = (*CookieSource)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func CookieSources() []CookieSource {
|
func CookieSources() []CookieSource {
|
||||||
return []CookieSource{
|
return []CookieSource{
|
||||||
CookieSourceScript,
|
CookieSourceScript,
|
||||||
@@ -35,43 +41,33 @@ func CookieSources() []CookieSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s CookieSource) String() string {
|
func (v CookieSource) IsValid() bool {
|
||||||
return string(s)
|
switch v {
|
||||||
|
case
|
||||||
|
CookieSourceScript,
|
||||||
|
CookieSourcePreExisting,
|
||||||
|
CookieSourceHTTP:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *CookieSource) Scan(value any) error {
|
func (v CookieSource) String() string {
|
||||||
var v string
|
return string(v)
|
||||||
|
}
|
||||||
|
|
||||||
switch val := value.(type) {
|
func (v CookieSource) MarshalText() ([]byte, error) {
|
||||||
case string:
|
return []byte(v.String()), nil
|
||||||
v = val
|
}
|
||||||
case []byte:
|
|
||||||
v = string(val)
|
func (v *CookieSource) UnmarshalText(text []byte) error {
|
||||||
default:
|
val := CookieSource(text)
|
||||||
return fmt.Errorf("unsupported type for CookieSource: %T", value)
|
if !val.IsValid() {
|
||||||
|
return fmt.Errorf("invalid CookieSource value: %q", string(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
switch CookieSource(v) {
|
*v = val
|
||||||
case CookieSourceScript:
|
|
||||||
*s = CookieSourceScript
|
|
||||||
case CookieSourcePreExisting:
|
|
||||||
*s = CookieSourcePreExisting
|
|
||||||
case CookieSourceHTTP:
|
|
||||||
*s = CookieSourceHTTP
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("invalid CookieSource value: %q", v)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
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 (
|
import (
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@@ -276,530 +277,289 @@ const (
|
|||||||
CountryCodeZW CountryCode = "ZW"
|
CountryCodeZW CountryCode = "ZW"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (ct CountryCode) String() string {
|
var (
|
||||||
return string(ct)
|
_ 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 {
|
func (v CountryCode) String() string {
|
||||||
var s string
|
return string(v)
|
||||||
|
}
|
||||||
|
|
||||||
switch v := value.(type) {
|
func (v CountryCode) MarshalText() ([]byte, error) {
|
||||||
case string:
|
return []byte(v.String()), nil
|
||||||
s = v
|
}
|
||||||
case []byte:
|
|
||||||
s = string(v)
|
func (v *CountryCode) UnmarshalText(text []byte) error {
|
||||||
default:
|
val := CountryCode(text)
|
||||||
return fmt.Errorf("unsupported type for CountryCode: %T", value)
|
if !val.IsValid() {
|
||||||
|
return fmt.Errorf("invalid CountryCode value: %q", string(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
switch s {
|
*v = val
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (st CountryCode) Value() (driver.Value, error) {
|
|
||||||
return st.String(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type CountryCodes []CountryCode
|
type CountryCodes []CountryCode
|
||||||
|
|
||||||
func (s *CountryCodes) Scan(value any) error {
|
func (s *CountryCodes) Scan(value any) error {
|
||||||
@@ -835,7 +595,7 @@ func (s *CountryCodes) scanFromString(str string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var ct CountryCode
|
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)
|
return fmt.Errorf("invalid country code in array: %s", part)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,12 @@
|
|||||||
|
|
||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type CustomDomainOrderField string
|
type CustomDomainOrderField string
|
||||||
|
|
||||||
@@ -24,6 +29,52 @@ const (
|
|||||||
CustomDomainOrderFieldUpdatedAt CustomDomainOrderField = "UPDATED_AT"
|
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 {
|
func (f CustomDomainOrderField) Column() string {
|
||||||
switch f {
|
switch f {
|
||||||
case CustomDomainOrderFieldCreatedAt:
|
case CustomDomainOrderFieldCreatedAt:
|
||||||
@@ -36,7 +87,3 @@ func (f CustomDomainOrderField) Column() string {
|
|||||||
panic(fmt.Sprintf("unsupported order by: %s", f))
|
panic(fmt.Sprintf("unsupported order by: %s", f))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f CustomDomainOrderField) String() string {
|
|
||||||
return string(f)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,46 +30,53 @@ const (
|
|||||||
CustomDomainSSLStatusFailed CustomDomainSSLStatus = "FAILED"
|
CustomDomainSSLStatusFailed CustomDomainSSLStatus = "FAILED"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s CustomDomainSSLStatus) MarshalText() ([]byte, error) {
|
var (
|
||||||
return []byte(s.String()), nil
|
_ 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 {
|
func (v CustomDomainSSLStatus) IsValid() bool {
|
||||||
val := string(data)
|
switch v {
|
||||||
|
case
|
||||||
switch val {
|
CustomDomainSSLStatusPending,
|
||||||
case CustomDomainSSLStatusPending.String():
|
CustomDomainSSLStatusProvisioning,
|
||||||
*s = CustomDomainSSLStatusPending
|
CustomDomainSSLStatusActive,
|
||||||
case CustomDomainSSLStatusProvisioning.String():
|
CustomDomainSSLStatusRenewing,
|
||||||
*s = CustomDomainSSLStatusProvisioning
|
CustomDomainSSLStatusExpired,
|
||||||
case CustomDomainSSLStatusActive.String():
|
CustomDomainSSLStatusFailed:
|
||||||
*s = CustomDomainSSLStatusActive
|
return true
|
||||||
case CustomDomainSSLStatusRenewing.String():
|
|
||||||
*s = CustomDomainSSLStatusRenewing
|
|
||||||
case CustomDomainSSLStatusExpired.String():
|
|
||||||
*s = CustomDomainSSLStatusExpired
|
|
||||||
case CustomDomainSSLStatusFailed.String():
|
|
||||||
*s = CustomDomainSSLStatusFailed
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("invalid CustomDomainSSLStatus value: %q", val)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
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
|
package coredata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
type CustomDomainVerificationStatus string
|
type CustomDomainVerificationStatus string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -21,3 +26,48 @@ const (
|
|||||||
CustomDomainVerificationStatusVerified CustomDomainVerificationStatus = "VERIFIED"
|
CustomDomainVerificationStatusVerified CustomDomainVerificationStatus = "VERIFIED"
|
||||||
CustomDomainVerificationStatusFailed CustomDomainVerificationStatus = "FAILED"
|
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
|
package coredata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
type DataClassification string
|
type DataClassification string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -23,6 +28,12 @@ const (
|
|||||||
DataClassificationSecret DataClassification = "SECRET"
|
DataClassificationSecret DataClassification = "SECRET"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Stringer = DataClassification("")
|
||||||
|
_ encoding.TextMarshaler = DataClassification("")
|
||||||
|
_ encoding.TextUnmarshaler = (*DataClassification)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func DataClassifications() []DataClassification {
|
func DataClassifications() []DataClassification {
|
||||||
return []DataClassification{
|
return []DataClassification{
|
||||||
DataClassificationPublic,
|
DataClassificationPublic,
|
||||||
@@ -31,3 +42,35 @@ func DataClassifications() []DataClassification {
|
|||||||
DataClassificationSecret,
|
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
|
package coredata
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type DataProtectionImpactAssessmentOrderField string
|
type DataProtectionImpactAssessmentOrderField string
|
||||||
|
|
||||||
@@ -22,25 +27,48 @@ const (
|
|||||||
DataProtectionImpactAssessmentOrderFieldCreatedAt DataProtectionImpactAssessmentOrderField = "CREATED_AT"
|
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 {
|
func (p DataProtectionImpactAssessmentOrderField) Column() string {
|
||||||
return string(p)
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -27,6 +27,12 @@ const (
|
|||||||
DataProtectionImpactAssessmentResidualRiskHigh DataProtectionImpactAssessmentResidualRisk = "HIGH"
|
DataProtectionImpactAssessmentResidualRiskHigh DataProtectionImpactAssessmentResidualRisk = "HIGH"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Stringer = DataProtectionImpactAssessmentResidualRisk("")
|
||||||
|
_ encoding.TextMarshaler = DataProtectionImpactAssessmentResidualRisk("")
|
||||||
|
_ encoding.TextUnmarshaler = (*DataProtectionImpactAssessmentResidualRisk)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func DataProtectionImpactAssessmentResidualRisks() []DataProtectionImpactAssessmentResidualRisk {
|
func DataProtectionImpactAssessmentResidualRisks() []DataProtectionImpactAssessmentResidualRisk {
|
||||||
return []DataProtectionImpactAssessmentResidualRisk{
|
return []DataProtectionImpactAssessmentResidualRisk{
|
||||||
DataProtectionImpactAssessmentResidualRiskLow,
|
DataProtectionImpactAssessmentResidualRiskLow,
|
||||||
@@ -35,36 +41,33 @@ func DataProtectionImpactAssessmentResidualRisks() []DataProtectionImpactAssessm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p DataProtectionImpactAssessmentResidualRisk) String() string {
|
func (v DataProtectionImpactAssessmentResidualRisk) IsValid() bool {
|
||||||
return string(p)
|
switch v {
|
||||||
|
case
|
||||||
|
DataProtectionImpactAssessmentResidualRiskLow,
|
||||||
|
DataProtectionImpactAssessmentResidualRiskMedium,
|
||||||
|
DataProtectionImpactAssessmentResidualRiskHigh:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *DataProtectionImpactAssessmentResidualRisk) Scan(value any) error {
|
func (v DataProtectionImpactAssessmentResidualRisk) String() string {
|
||||||
var s string
|
return string(v)
|
||||||
|
}
|
||||||
|
|
||||||
switch v := value.(type) {
|
func (v DataProtectionImpactAssessmentResidualRisk) MarshalText() ([]byte, error) {
|
||||||
case string:
|
return []byte(v.String()), nil
|
||||||
s = v
|
}
|
||||||
case []byte:
|
|
||||||
s = string(v)
|
func (v *DataProtectionImpactAssessmentResidualRisk) UnmarshalText(text []byte) error {
|
||||||
default:
|
val := DataProtectionImpactAssessmentResidualRisk(text)
|
||||||
return fmt.Errorf("unsupported type for DataProtectionImpactAssessmentResidualRisk: %T", value)
|
if !val.IsValid() {
|
||||||
|
return fmt.Errorf("invalid DataProtectionImpactAssessmentResidualRisk value: %q", string(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
switch s {
|
*v = val
|
||||||
case "LOW":
|
|
||||||
*p = DataProtectionImpactAssessmentResidualRiskLow
|
|
||||||
case "MEDIUM":
|
|
||||||
*p = DataProtectionImpactAssessmentResidualRiskMedium
|
|
||||||
case "HIGH":
|
|
||||||
*p = DataProtectionImpactAssessmentResidualRiskHigh
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("invalid DataProtectionImpactAssessmentResidualRisk value: %q", s)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p DataProtectionImpactAssessmentResidualRisk) Value() (driver.Value, error) {
|
|
||||||
return p.String(), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,8 +15,7 @@
|
|||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,6 +29,12 @@ const (
|
|||||||
DataSensitivityCritical DataSensitivity = "CRITICAL"
|
DataSensitivityCritical DataSensitivity = "CRITICAL"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Stringer = DataSensitivity("")
|
||||||
|
_ encoding.TextMarshaler = DataSensitivity("")
|
||||||
|
_ encoding.TextUnmarshaler = (*DataSensitivity)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func DataSensitivities() []DataSensitivity {
|
func DataSensitivities() []DataSensitivity {
|
||||||
return []DataSensitivity{
|
return []DataSensitivity{
|
||||||
DataSensitivityNone,
|
DataSensitivityNone,
|
||||||
@@ -40,86 +45,35 @@ func DataSensitivities() []DataSensitivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i DataSensitivity) String() string {
|
func (v DataSensitivity) IsValid() bool {
|
||||||
return string(i)
|
switch v {
|
||||||
|
case
|
||||||
|
DataSensitivityNone,
|
||||||
|
DataSensitivityLow,
|
||||||
|
DataSensitivityMedium,
|
||||||
|
DataSensitivityHigh,
|
||||||
|
DataSensitivityCritical:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *DataSensitivity) Scan(value any) error {
|
func (v DataSensitivity) String() string {
|
||||||
switch v := value.(type) {
|
return string(v)
|
||||||
case string:
|
}
|
||||||
switch v {
|
|
||||||
case "NONE":
|
func (v DataSensitivity) MarshalText() ([]byte, error) {
|
||||||
*i = DataSensitivityNone
|
return []byte(v.String()), nil
|
||||||
case "LOW":
|
}
|
||||||
*i = DataSensitivityLow
|
|
||||||
case "MEDIUM":
|
func (v *DataSensitivity) UnmarshalText(text []byte) error {
|
||||||
*i = DataSensitivityMedium
|
val := DataSensitivity(text)
|
||||||
case "HIGH":
|
if !val.IsValid() {
|
||||||
*i = DataSensitivityHigh
|
return fmt.Errorf("invalid DataSensitivity value: %q", string(text))
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*v = val
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,10 @@
|
|||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DatumOrderField string
|
type DatumOrderField string
|
||||||
@@ -26,27 +29,52 @@ const (
|
|||||||
DatumOrderFieldDataClassification DatumOrderField = "DATA_CLASSIFICATION"
|
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 {
|
func (p DatumOrderField) Column() string {
|
||||||
return string(p)
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,6 +28,12 @@ const (
|
|||||||
DocumentClassificationSecret DocumentClassification = "SECRET"
|
DocumentClassificationSecret DocumentClassification = "SECRET"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Stringer = DocumentClassification("")
|
||||||
|
_ encoding.TextMarshaler = DocumentClassification("")
|
||||||
|
_ encoding.TextUnmarshaler = (*DocumentClassification)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func DocumentClassifications() []DocumentClassification {
|
func DocumentClassifications() []DocumentClassification {
|
||||||
return []DocumentClassification{
|
return []DocumentClassification{
|
||||||
DocumentClassificationPublic,
|
DocumentClassificationPublic,
|
||||||
@@ -37,44 +43,37 @@ func DocumentClassifications() []DocumentClassification {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dc DocumentClassification) String() string {
|
func (v DocumentClassification) IsValid() bool {
|
||||||
switch dc {
|
switch v {
|
||||||
case DocumentClassificationPublic:
|
case
|
||||||
return "PUBLIC"
|
DocumentClassificationPublic,
|
||||||
case DocumentClassificationInternal:
|
DocumentClassificationInternal,
|
||||||
return "INTERNAL"
|
DocumentClassificationConfidential,
|
||||||
case DocumentClassificationConfidential:
|
DocumentClassificationSecret:
|
||||||
return "CONFIDENTIAL"
|
return true
|
||||||
case DocumentClassificationSecret:
|
|
||||||
return "SECRET"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
panic(fmt.Errorf("invalid DocumentClassification value: %s", string(dc)))
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan implements the sql.Scanner interface for database deserialization.
|
func (v DocumentClassification) String() string {
|
||||||
func (dc *DocumentClassification) Scan(value any) error {
|
return string(v)
|
||||||
if value == nil {
|
}
|
||||||
return nil
|
|
||||||
|
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
|
*v = val
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Scan implements the sql.Scanner interface for database deserialization.
|
||||||
// Value implements the driver.Valuer interface for database serialization.
|
// 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
|
package coredata
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
DocumentOrderField string
|
DocumentOrderField string
|
||||||
@@ -27,6 +32,54 @@ const (
|
|||||||
DocumentOrderFieldDocumentType DocumentOrderField = "DOCUMENT_TYPE"
|
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 {
|
func (p DocumentOrderField) Column() string {
|
||||||
switch p {
|
switch p {
|
||||||
case DocumentOrderFieldCreatedAt:
|
case DocumentOrderFieldCreatedAt:
|
||||||
@@ -41,32 +94,3 @@ func (p DocumentOrderField) Column() string {
|
|||||||
|
|
||||||
panic(fmt.Sprintf("unsupported order by: %s", p))
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -26,39 +26,45 @@ const (
|
|||||||
DocumentStatusArchived DocumentStatus = "ARCHIVED"
|
DocumentStatusArchived DocumentStatus = "ARCHIVED"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s DocumentStatus) IsValid() bool {
|
var (
|
||||||
switch s {
|
_ fmt.Stringer = DocumentStatus("")
|
||||||
case DocumentStatusActive, DocumentStatusArchived:
|
_ 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 true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
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 {
|
func (v DocumentStatus) MarshalText() ([]byte, error) {
|
||||||
*s = DocumentStatus(text)
|
return []byte(v.String()), nil
|
||||||
if !s.IsValid() {
|
}
|
||||||
return fmt.Errorf("%s is not a valid DocumentStatus", string(text))
|
|
||||||
|
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
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -36,6 +36,12 @@ const (
|
|||||||
DocumentTypeStatementOfApplicability DocumentType = "STATEMENT_OF_APPLICABILITY"
|
DocumentTypeStatementOfApplicability DocumentType = "STATEMENT_OF_APPLICABILITY"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Stringer = DocumentType("")
|
||||||
|
_ encoding.TextMarshaler = DocumentType("")
|
||||||
|
_ encoding.TextUnmarshaler = (*DocumentType)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func DocumentTypes() []DocumentType {
|
func DocumentTypes() []DocumentType {
|
||||||
return []DocumentType{
|
return []DocumentType{
|
||||||
DocumentTypeOther,
|
DocumentTypeOther,
|
||||||
@@ -51,54 +57,40 @@ func DocumentTypes() []DocumentType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dt DocumentType) MarshalText() ([]byte, error) {
|
func (v DocumentType) IsValid() bool {
|
||||||
return []byte(dt.String()), nil
|
switch v {
|
||||||
|
case
|
||||||
|
DocumentTypeOther,
|
||||||
|
DocumentTypeGovernance,
|
||||||
|
DocumentTypePolicy,
|
||||||
|
DocumentTypeProcedure,
|
||||||
|
DocumentTypePlan,
|
||||||
|
DocumentTypeRegister,
|
||||||
|
DocumentTypeRecord,
|
||||||
|
DocumentTypeReport,
|
||||||
|
DocumentTypeTemplate,
|
||||||
|
DocumentTypeStatementOfApplicability:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dt *DocumentType) UnmarshalText(data []byte) error {
|
func (v DocumentType) String() string {
|
||||||
val := string(data)
|
return string(v)
|
||||||
|
}
|
||||||
|
|
||||||
switch val {
|
func (v DocumentType) MarshalText() ([]byte, error) {
|
||||||
case DocumentTypeOther.String():
|
return []byte(v.String()), nil
|
||||||
*dt = DocumentTypeOther
|
}
|
||||||
case DocumentTypeGovernance.String():
|
|
||||||
*dt = DocumentTypeGovernance
|
func (v *DocumentType) UnmarshalText(text []byte) error {
|
||||||
case DocumentTypePolicy.String():
|
val := DocumentType(text)
|
||||||
*dt = DocumentTypePolicy
|
if !val.IsValid() {
|
||||||
case DocumentTypeProcedure.String():
|
return fmt.Errorf("invalid DocumentType value: %q", string(text))
|
||||||
*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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*v = val
|
||||||
|
|
||||||
return nil
|
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
|
package coredata
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
DocumentVersionApprovalDecisionOrderField string
|
DocumentVersionApprovalDecisionOrderField string
|
||||||
@@ -24,6 +29,48 @@ const (
|
|||||||
DocumentVersionApprovalDecisionOrderFieldCreatedAt DocumentVersionApprovalDecisionOrderField = "CREATED_AT"
|
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 {
|
func (e DocumentVersionApprovalDecisionOrderField) Column() string {
|
||||||
switch e {
|
switch e {
|
||||||
case DocumentVersionApprovalDecisionOrderFieldCreatedAt:
|
case DocumentVersionApprovalDecisionOrderFieldCreatedAt:
|
||||||
@@ -32,27 +79,3 @@ func (e DocumentVersionApprovalDecisionOrderField) Column() string {
|
|||||||
|
|
||||||
panic(fmt.Sprintf("unsupported order by: %s", e))
|
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 (
|
import (
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@@ -32,61 +33,44 @@ const (
|
|||||||
DocumentVersionApprovalDecisionStateVoided DocumentVersionApprovalDecisionState = "VOIDED"
|
DocumentVersionApprovalDecisionStateVoided DocumentVersionApprovalDecisionState = "VOIDED"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s DocumentVersionApprovalDecisionState) MarshalText() ([]byte, error) {
|
var (
|
||||||
return []byte(s.String()), nil
|
_ 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 {
|
func (v DocumentVersionApprovalDecisionState) String() string {
|
||||||
val := string(data)
|
return string(v)
|
||||||
|
}
|
||||||
|
|
||||||
switch val {
|
func (v DocumentVersionApprovalDecisionState) MarshalText() ([]byte, error) {
|
||||||
case DocumentVersionApprovalDecisionStatePending.String():
|
return []byte(v.String()), nil
|
||||||
*s = DocumentVersionApprovalDecisionStatePending
|
}
|
||||||
case DocumentVersionApprovalDecisionStateApproved.String():
|
|
||||||
*s = DocumentVersionApprovalDecisionStateApproved
|
func (v *DocumentVersionApprovalDecisionState) UnmarshalText(text []byte) error {
|
||||||
case DocumentVersionApprovalDecisionStateRejected.String():
|
val := DocumentVersionApprovalDecisionState(text)
|
||||||
*s = DocumentVersionApprovalDecisionStateRejected
|
if !val.IsValid() {
|
||||||
case DocumentVersionApprovalDecisionStateVoided.String():
|
return fmt.Errorf("invalid DocumentVersionApprovalDecisionState value: %q", string(text))
|
||||||
*s = DocumentVersionApprovalDecisionStateVoided
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("invalid DocumentVersionApprovalDecisionState value: %q", val)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*v = val
|
||||||
|
|
||||||
return nil
|
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) {
|
func (states DocumentVersionApprovalDecisionStates) Value() (driver.Value, error) {
|
||||||
if len(states) == 0 {
|
if len(states) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|||||||
@@ -14,7 +14,12 @@
|
|||||||
|
|
||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
DocumentVersionApprovalQuorumOrderField string
|
DocumentVersionApprovalQuorumOrderField string
|
||||||
@@ -24,6 +29,48 @@ const (
|
|||||||
DocumentVersionApprovalQuorumOrderFieldCreatedAt DocumentVersionApprovalQuorumOrderField = "CREATED_AT"
|
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 {
|
func (e DocumentVersionApprovalQuorumOrderField) Column() string {
|
||||||
switch e {
|
switch e {
|
||||||
case DocumentVersionApprovalQuorumOrderFieldCreatedAt:
|
case DocumentVersionApprovalQuorumOrderFieldCreatedAt:
|
||||||
@@ -32,27 +79,3 @@ func (e DocumentVersionApprovalQuorumOrderField) Column() string {
|
|||||||
|
|
||||||
panic(fmt.Sprintf("unsupported order by: %s", e))
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,57 +28,49 @@ const (
|
|||||||
DocumentVersionApprovalQuorumStatusVoided DocumentVersionApprovalQuorumStatus = "VOIDED"
|
DocumentVersionApprovalQuorumStatusVoided DocumentVersionApprovalQuorumStatus = "VOIDED"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s DocumentVersionApprovalQuorumStatus) MarshalText() ([]byte, error) {
|
var (
|
||||||
return []byte(s.String()), nil
|
_ 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 {
|
func (v DocumentVersionApprovalQuorumStatus) IsValid() bool {
|
||||||
val := string(data)
|
switch v {
|
||||||
|
case
|
||||||
switch val {
|
DocumentVersionApprovalQuorumStatusPending,
|
||||||
case DocumentVersionApprovalQuorumStatusPending.String():
|
DocumentVersionApprovalQuorumStatusApproved,
|
||||||
*s = DocumentVersionApprovalQuorumStatusPending
|
DocumentVersionApprovalQuorumStatusRejected,
|
||||||
case DocumentVersionApprovalQuorumStatusApproved.String():
|
DocumentVersionApprovalQuorumStatusVoided:
|
||||||
*s = DocumentVersionApprovalQuorumStatusApproved
|
return true
|
||||||
case DocumentVersionApprovalQuorumStatusRejected.String():
|
|
||||||
*s = DocumentVersionApprovalQuorumStatusRejected
|
|
||||||
case DocumentVersionApprovalQuorumStatusVoided.String():
|
|
||||||
*s = DocumentVersionApprovalQuorumStatusVoided
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("invalid DocumentVersionApprovalQuorumStatus value: %q", val)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/jackc/pgx/v5"
|
"github.com/jackc/pgx/v5"
|
||||||
"go.probo.inc/probo/pkg/gid"
|
"go.probo.inc/probo/pkg/gid"
|
||||||
)
|
)
|
||||||
@@ -26,6 +29,49 @@ const (
|
|||||||
EmployeeFilterModeApproval EmployeeFilterMode = "approval"
|
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 (
|
type (
|
||||||
DocumentVersionFilter struct {
|
DocumentVersionFilter struct {
|
||||||
statuses []DocumentVersionStatus
|
statuses []DocumentVersionStatus
|
||||||
|
|||||||
@@ -14,6 +14,13 @@
|
|||||||
|
|
||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
DocumentVersionOrderField string
|
DocumentVersionOrderField string
|
||||||
)
|
)
|
||||||
@@ -22,19 +29,48 @@ const (
|
|||||||
DocumentVersionOrderFieldCreatedAt DocumentVersionOrderField = "CREATED_AT"
|
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 {
|
func (p DocumentVersionOrderField) Column() string {
|
||||||
return string(p)
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,6 +28,12 @@ const (
|
|||||||
DocumentVersionOrientationLandscape DocumentVersionOrientation = "LANDSCAPE"
|
DocumentVersionOrientationLandscape DocumentVersionOrientation = "LANDSCAPE"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Stringer = DocumentVersionOrientation("")
|
||||||
|
_ encoding.TextMarshaler = DocumentVersionOrientation("")
|
||||||
|
_ encoding.TextUnmarshaler = (*DocumentVersionOrientation)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func DocumentVersionOrientations() []DocumentVersionOrientation {
|
func DocumentVersionOrientations() []DocumentVersionOrientation {
|
||||||
return []DocumentVersionOrientation{
|
return []DocumentVersionOrientation{
|
||||||
DocumentVersionOrientationPortrait,
|
DocumentVersionOrientationPortrait,
|
||||||
@@ -35,38 +41,32 @@ func DocumentVersionOrientations() []DocumentVersionOrientation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o DocumentVersionOrientation) MarshalText() ([]byte, error) {
|
func (v DocumentVersionOrientation) IsValid() bool {
|
||||||
return []byte(o.String()), nil
|
switch v {
|
||||||
|
case
|
||||||
|
DocumentVersionOrientationPortrait,
|
||||||
|
DocumentVersionOrientationLandscape:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *DocumentVersionOrientation) UnmarshalText(data []byte) error {
|
func (v DocumentVersionOrientation) String() string {
|
||||||
val := string(data)
|
return string(v)
|
||||||
|
}
|
||||||
|
|
||||||
switch val {
|
func (v DocumentVersionOrientation) MarshalText() ([]byte, error) {
|
||||||
case DocumentVersionOrientationPortrait.String():
|
return []byte(v.String()), nil
|
||||||
*o = DocumentVersionOrientationPortrait
|
}
|
||||||
case DocumentVersionOrientationLandscape.String():
|
|
||||||
*o = DocumentVersionOrientationLandscape
|
func (v *DocumentVersionOrientation) UnmarshalText(text []byte) error {
|
||||||
default:
|
val := DocumentVersionOrientation(text)
|
||||||
return fmt.Errorf("invalid DocumentVersionOrientation value: %q", val)
|
if !val.IsValid() {
|
||||||
|
return fmt.Errorf("invalid DocumentVersionOrientation value: %q", string(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*v = val
|
||||||
|
|
||||||
return nil
|
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
|
package coredata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
DocumentVersionSignatureOrderField string
|
DocumentVersionSignatureOrderField string
|
||||||
)
|
)
|
||||||
@@ -23,19 +30,50 @@ const (
|
|||||||
DocumentVersionSignatureOrderFieldSignedAt DocumentVersionSignatureOrderField = "SIGNED_AT"
|
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 {
|
func (p DocumentVersionSignatureOrderField) Column() string {
|
||||||
return string(p)
|
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 (
|
import (
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@@ -30,53 +31,42 @@ const (
|
|||||||
DocumentVersionSignatureStateSigned DocumentVersionSignatureState = "SIGNED"
|
DocumentVersionSignatureStateSigned DocumentVersionSignatureState = "SIGNED"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (pvs DocumentVersionSignatureState) MarshalText() ([]byte, error) {
|
var (
|
||||||
return []byte(pvs.String()), nil
|
_ 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 {
|
func (v DocumentVersionSignatureState) String() string {
|
||||||
val := string(data)
|
return string(v)
|
||||||
|
}
|
||||||
|
|
||||||
switch val {
|
func (v DocumentVersionSignatureState) MarshalText() ([]byte, error) {
|
||||||
case DocumentVersionSignatureStateRequested.String():
|
return []byte(v.String()), nil
|
||||||
*pvs = DocumentVersionSignatureStateRequested
|
}
|
||||||
case DocumentVersionSignatureStateSigned.String():
|
|
||||||
*pvs = DocumentVersionSignatureStateSigned
|
func (v *DocumentVersionSignatureState) UnmarshalText(text []byte) error {
|
||||||
default:
|
val := DocumentVersionSignatureState(text)
|
||||||
return fmt.Errorf("invalid DocumentVersionSignatureState value: %q", val)
|
if !val.IsValid() {
|
||||||
|
return fmt.Errorf("invalid DocumentVersionSignatureState value: %q", string(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*v = val
|
||||||
|
|
||||||
return nil
|
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) {
|
func (states DocumentVersionSignatureStates) Value() (driver.Value, error) {
|
||||||
if len(states) == 0 {
|
if len(states) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -29,49 +29,47 @@ const (
|
|||||||
DocumentVersionStatusPublished DocumentVersionStatus = "PUBLISHED"
|
DocumentVersionStatusPublished DocumentVersionStatus = "PUBLISHED"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (ps DocumentVersionStatus) MarshalText() ([]byte, error) {
|
var (
|
||||||
return []byte(ps.String()), nil
|
_ 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 {
|
func (v DocumentVersionStatus) IsValid() bool {
|
||||||
val := string(data)
|
switch v {
|
||||||
|
case
|
||||||
switch val {
|
DocumentVersionStatusDraft,
|
||||||
case DocumentVersionStatusDraft.String():
|
DocumentVersionStatusPendingApproval,
|
||||||
*ps = DocumentVersionStatusDraft
|
DocumentVersionStatusPublished:
|
||||||
case DocumentVersionStatusPendingApproval.String():
|
return true
|
||||||
*ps = DocumentVersionStatusPendingApproval
|
|
||||||
case DocumentVersionStatusPublished.String():
|
|
||||||
*ps = DocumentVersionStatusPublished
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("invalid DocumentVersionStatus value: %q", val)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
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
|
package coredata
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
DocumentWriteMode string
|
DocumentWriteMode string
|
||||||
@@ -25,26 +28,45 @@ const (
|
|||||||
DocumentWriteModeGenerated DocumentWriteMode = "GENERATED"
|
DocumentWriteModeGenerated DocumentWriteMode = "GENERATED"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (e DocumentWriteMode) IsValid() bool {
|
var (
|
||||||
switch e {
|
_ fmt.Stringer = DocumentWriteMode("")
|
||||||
case DocumentWriteModeAuthored, DocumentWriteModeGenerated:
|
_ 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 true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
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 {
|
func (v DocumentWriteMode) MarshalText() ([]byte, error) {
|
||||||
*e = DocumentWriteMode(text)
|
return []byte(v.String()), nil
|
||||||
if !e.IsValid() {
|
}
|
||||||
return fmt.Errorf("%s is not a valid DocumentWriteMode", string(text))
|
|
||||||
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e DocumentWriteMode) MarshalText() ([]byte, error) {
|
|
||||||
return []byte(e.String()), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"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."
|
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 {
|
func ElectronicSignatureDocumentTypes() []ElectronicSignatureDocumentType {
|
||||||
return []ElectronicSignatureDocumentType{
|
return []ElectronicSignatureDocumentType{
|
||||||
ElectronicSignatureDocumentTypeNDA,
|
ElectronicSignatureDocumentTypeNDA,
|
||||||
@@ -67,72 +73,51 @@ func ElectronicSignatureDocumentTypes() []ElectronicSignatureDocumentType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dt ElectronicSignatureDocumentType) MarshalText() ([]byte, error) {
|
func (v ElectronicSignatureDocumentType) IsValid() bool {
|
||||||
return []byte(dt.String()), nil
|
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 {
|
func (v ElectronicSignatureDocumentType) String() string {
|
||||||
val := string(data)
|
return string(v)
|
||||||
|
}
|
||||||
|
|
||||||
switch val {
|
func (v ElectronicSignatureDocumentType) MarshalText() ([]byte, error) {
|
||||||
case ElectronicSignatureDocumentTypeNDA.String():
|
return []byte(v.String()), nil
|
||||||
*dt = ElectronicSignatureDocumentTypeNDA
|
}
|
||||||
case ElectronicSignatureDocumentTypeDPA.String():
|
|
||||||
*dt = ElectronicSignatureDocumentTypeDPA
|
func (v *ElectronicSignatureDocumentType) UnmarshalText(text []byte) error {
|
||||||
case ElectronicSignatureDocumentTypeMSA.String():
|
val := ElectronicSignatureDocumentType(text)
|
||||||
*dt = ElectronicSignatureDocumentTypeMSA
|
if !val.IsValid() {
|
||||||
case ElectronicSignatureDocumentTypeSOW.String():
|
return fmt.Errorf("invalid ElectronicSignatureDocumentType value: %q", string(text))
|
||||||
*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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*v = val
|
||||||
|
|
||||||
return nil
|
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 {
|
func (dt ElectronicSignatureDocumentType) DisplayName() string {
|
||||||
switch dt {
|
switch dt {
|
||||||
case ElectronicSignatureDocumentTypeNDA:
|
case ElectronicSignatureDocumentTypeNDA:
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,38 +28,45 @@ const (
|
|||||||
ElectronicSignatureEventSourceServer ElectronicSignatureEventSource = "SERVER"
|
ElectronicSignatureEventSourceServer ElectronicSignatureEventSource = "SERVER"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s ElectronicSignatureEventSource) MarshalText() ([]byte, error) {
|
var (
|
||||||
return []byte(s.String()), nil
|
_ fmt.Stringer = ElectronicSignatureEventSource("")
|
||||||
|
_ encoding.TextMarshaler = ElectronicSignatureEventSource("")
|
||||||
|
_ encoding.TextUnmarshaler = (*ElectronicSignatureEventSource)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
func ElectronicSignatureEventSources() []ElectronicSignatureEventSource {
|
||||||
|
return []ElectronicSignatureEventSource{
|
||||||
|
ElectronicSignatureEventSourceClient,
|
||||||
|
ElectronicSignatureEventSourceServer,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ElectronicSignatureEventSource) UnmarshalText(data []byte) error {
|
func (v ElectronicSignatureEventSource) IsValid() bool {
|
||||||
val := string(data)
|
switch v {
|
||||||
|
case
|
||||||
switch val {
|
ElectronicSignatureEventSourceClient,
|
||||||
case ElectronicSignatureEventSourceClient.String():
|
ElectronicSignatureEventSourceServer:
|
||||||
*s = ElectronicSignatureEventSourceClient
|
return true
|
||||||
case ElectronicSignatureEventSourceServer.String():
|
|
||||||
*s = ElectronicSignatureEventSourceServer
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("invalid ElectronicSignatureEventSource value: %q", val)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -35,58 +35,59 @@ const (
|
|||||||
ElectronicSignatureEventTypeProcessingError ElectronicSignatureEventType = "PROCESSING_ERROR"
|
ElectronicSignatureEventTypeProcessingError ElectronicSignatureEventType = "PROCESSING_ERROR"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (t ElectronicSignatureEventType) MarshalText() ([]byte, error) {
|
var (
|
||||||
return []byte(t.String()), nil
|
_ 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 {
|
func (v ElectronicSignatureEventType) IsValid() bool {
|
||||||
val := string(data)
|
switch v {
|
||||||
|
case
|
||||||
switch val {
|
ElectronicSignatureEventTypeDocumentViewed,
|
||||||
case ElectronicSignatureEventTypeDocumentViewed.String():
|
ElectronicSignatureEventTypeConsentGiven,
|
||||||
*t = ElectronicSignatureEventTypeDocumentViewed
|
ElectronicSignatureEventTypeFullNameTyped,
|
||||||
case ElectronicSignatureEventTypeConsentGiven.String():
|
ElectronicSignatureEventTypeSignatureAccepted,
|
||||||
*t = ElectronicSignatureEventTypeConsentGiven
|
ElectronicSignatureEventTypeSignatureCompleted,
|
||||||
case ElectronicSignatureEventTypeFullNameTyped.String():
|
ElectronicSignatureEventTypeSealComputed,
|
||||||
*t = ElectronicSignatureEventTypeFullNameTyped
|
ElectronicSignatureEventTypeTimestampRequested,
|
||||||
case ElectronicSignatureEventTypeSignatureAccepted.String():
|
ElectronicSignatureEventTypeCertificateGenerated,
|
||||||
*t = ElectronicSignatureEventTypeSignatureAccepted
|
ElectronicSignatureEventTypeProcessingError:
|
||||||
case ElectronicSignatureEventTypeSignatureCompleted.String():
|
return true
|
||||||
*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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -31,44 +31,51 @@ const (
|
|||||||
ElectronicSignatureStatusFailed ElectronicSignatureStatus = "FAILED"
|
ElectronicSignatureStatusFailed ElectronicSignatureStatus = "FAILED"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s ElectronicSignatureStatus) MarshalText() ([]byte, error) {
|
var (
|
||||||
return []byte(s.String()), nil
|
_ 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 {
|
func (v ElectronicSignatureStatus) IsValid() bool {
|
||||||
val := string(data)
|
switch v {
|
||||||
|
case
|
||||||
switch val {
|
ElectronicSignatureStatusPending,
|
||||||
case ElectronicSignatureStatusPending.String():
|
ElectronicSignatureStatusAccepted,
|
||||||
*s = ElectronicSignatureStatusPending
|
ElectronicSignatureStatusProcessing,
|
||||||
case ElectronicSignatureStatusAccepted.String():
|
ElectronicSignatureStatusCompleted,
|
||||||
*s = ElectronicSignatureStatusAccepted
|
ElectronicSignatureStatusFailed:
|
||||||
case ElectronicSignatureStatusProcessing.String():
|
return true
|
||||||
*s = ElectronicSignatureStatusProcessing
|
|
||||||
case ElectronicSignatureStatusCompleted.String():
|
|
||||||
*s = ElectronicSignatureStatusCompleted
|
|
||||||
case ElectronicSignatureStatusFailed.String():
|
|
||||||
*s = ElectronicSignatureStatusFailed
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("invalid ElectronicSignatureStatus value: %q", val)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,44 +30,49 @@ const (
|
|||||||
EmailStatusFailed EmailStatus = "FAILED"
|
EmailStatusFailed EmailStatus = "FAILED"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s EmailStatus) MarshalText() ([]byte, error) {
|
var (
|
||||||
return []byte(s.String()), nil
|
_ 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 {
|
func (v EmailStatus) IsValid() bool {
|
||||||
val := string(data)
|
switch v {
|
||||||
|
case
|
||||||
switch val {
|
EmailStatusPending,
|
||||||
case EmailStatusPending.String():
|
EmailStatusProcessing,
|
||||||
*s = EmailStatusPending
|
EmailStatusSent,
|
||||||
case EmailStatusProcessing.String():
|
EmailStatusFailed:
|
||||||
*s = EmailStatusProcessing
|
return true
|
||||||
case EmailStatusSent.String():
|
|
||||||
*s = EmailStatusSent
|
|
||||||
case EmailStatusFailed.String():
|
|
||||||
*s = EmailStatusFailed
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("invalid EmailStatus value: %q", val)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,42 +30,49 @@ const (
|
|||||||
EvidenceDescriptionStatusFailed EvidenceDescriptionStatus = "FAILED"
|
EvidenceDescriptionStatusFailed EvidenceDescriptionStatus = "FAILED"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s EvidenceDescriptionStatus) MarshalText() ([]byte, error) {
|
var (
|
||||||
return []byte(s.String()), nil
|
_ 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 {
|
func (v EvidenceDescriptionStatus) IsValid() bool {
|
||||||
val := string(data)
|
switch v {
|
||||||
|
case
|
||||||
switch val {
|
EvidenceDescriptionStatusPending,
|
||||||
case EvidenceDescriptionStatusPending.String():
|
EvidenceDescriptionStatusProcessing,
|
||||||
*s = EvidenceDescriptionStatusPending
|
EvidenceDescriptionStatusCompleted,
|
||||||
case EvidenceDescriptionStatusProcessing.String():
|
EvidenceDescriptionStatusFailed:
|
||||||
*s = EvidenceDescriptionStatusProcessing
|
return true
|
||||||
case EvidenceDescriptionStatusCompleted.String():
|
|
||||||
*s = EvidenceDescriptionStatusCompleted
|
|
||||||
case EvidenceDescriptionStatusFailed.String():
|
|
||||||
*s = EvidenceDescriptionStatusFailed
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("invalid EvidenceDescriptionStatus value: %q", val)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
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
|
package coredata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
EvidenceOrderField string
|
EvidenceOrderField string
|
||||||
)
|
)
|
||||||
@@ -22,19 +29,48 @@ const (
|
|||||||
EvidenceOrderFieldCreatedAt EvidenceOrderField = "CREATED_AT"
|
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 {
|
func (p EvidenceOrderField) Column() string {
|
||||||
return string(p)
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,36 +28,45 @@ const (
|
|||||||
EvidenceStateFulfilled EvidenceState = "FULFILLED"
|
EvidenceStateFulfilled EvidenceState = "FULFILLED"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (es EvidenceState) MarshalText() ([]byte, error) {
|
var (
|
||||||
return []byte(es), nil
|
_ fmt.Stringer = EvidenceState("")
|
||||||
|
_ encoding.TextMarshaler = EvidenceState("")
|
||||||
|
_ encoding.TextUnmarshaler = (*EvidenceState)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
func EvidenceStates() []EvidenceState {
|
||||||
|
return []EvidenceState{
|
||||||
|
EvidenceStateRequested,
|
||||||
|
EvidenceStateFulfilled,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (es *EvidenceState) UnmarshalText(data []byte) error {
|
func (v EvidenceState) IsValid() bool {
|
||||||
val := EvidenceState(data)
|
switch v {
|
||||||
|
case
|
||||||
switch val {
|
EvidenceStateRequested,
|
||||||
case EvidenceStateRequested, EvidenceStateFulfilled:
|
EvidenceStateFulfilled:
|
||||||
*es = val
|
return true
|
||||||
default:
|
|
||||||
return fmt.Errorf("invalid EvidenceState value: %q", val)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,36 +28,45 @@ const (
|
|||||||
EvidenceTypeLink EvidenceType = "LINK"
|
EvidenceTypeLink EvidenceType = "LINK"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (et EvidenceType) MarshalText() ([]byte, error) {
|
var (
|
||||||
return []byte(et), nil
|
_ fmt.Stringer = EvidenceType("")
|
||||||
|
_ encoding.TextMarshaler = EvidenceType("")
|
||||||
|
_ encoding.TextUnmarshaler = (*EvidenceType)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
func EvidenceTypes() []EvidenceType {
|
||||||
|
return []EvidenceType{
|
||||||
|
EvidenceTypeFile,
|
||||||
|
EvidenceTypeLink,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (et *EvidenceType) UnmarshalText(data []byte) error {
|
func (v EvidenceType) IsValid() bool {
|
||||||
val := EvidenceType(data)
|
switch v {
|
||||||
|
case
|
||||||
switch val {
|
EvidenceTypeFile,
|
||||||
case EvidenceTypeFile, EvidenceTypeLink:
|
EvidenceTypeLink:
|
||||||
*et = val
|
return true
|
||||||
default:
|
|
||||||
return fmt.Errorf("invalid EvidenceType value: %q", val)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
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
|
package coredata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
ExpireReason string
|
ExpireReason string
|
||||||
)
|
)
|
||||||
@@ -23,3 +28,48 @@ const (
|
|||||||
ExpireReasonRevoked ExpireReason = "revoked"
|
ExpireReasonRevoked ExpireReason = "revoked"
|
||||||
ExpireReasonClosed ExpireReason = "closed"
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,38 +30,49 @@ const (
|
|||||||
ExportJobStatusFailed ExportJobStatus = "FAILED"
|
ExportJobStatusFailed ExportJobStatus = "FAILED"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (ejs ExportJobStatus) String() string {
|
var (
|
||||||
return string(ejs)
|
_ 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 {
|
func (v ExportJobStatus) IsValid() bool {
|
||||||
var s string
|
switch v {
|
||||||
|
case
|
||||||
switch v := value.(type) {
|
ExportJobStatusPending,
|
||||||
case string:
|
ExportJobStatusProcessing,
|
||||||
s = v
|
ExportJobStatusCompleted,
|
||||||
case []byte:
|
ExportJobStatusFailed:
|
||||||
s = string(v)
|
return true
|
||||||
default:
|
|
||||||
return fmt.Errorf("unsupported type for ExportJobStatus: %T", value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch s {
|
return false
|
||||||
case ExportJobStatusPending.String():
|
}
|
||||||
*ejs = ExportJobStatusPending
|
|
||||||
case ExportJobStatusProcessing.String():
|
func (v ExportJobStatus) String() string {
|
||||||
*ejs = ExportJobStatusProcessing
|
return string(v)
|
||||||
case ExportJobStatusCompleted.String():
|
}
|
||||||
*ejs = ExportJobStatusCompleted
|
|
||||||
case ExportJobStatusFailed.String():
|
func (v ExportJobStatus) MarshalText() ([]byte, error) {
|
||||||
*ejs = ExportJobStatusFailed
|
return []byte(v.String()), nil
|
||||||
default:
|
}
|
||||||
return fmt.Errorf("invalid ExportJobStatus value: %q", s)
|
|
||||||
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ejs ExportJobStatus) Value() (driver.Value, error) {
|
|
||||||
return ejs.String(), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,34 +28,45 @@ const (
|
|||||||
ExportJobTypeDocument ExportJobType = "DOCUMENT"
|
ExportJobTypeDocument ExportJobType = "DOCUMENT"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (ejt ExportJobType) String() string {
|
var (
|
||||||
return string(ejt)
|
_ fmt.Stringer = ExportJobType("")
|
||||||
|
_ encoding.TextMarshaler = ExportJobType("")
|
||||||
|
_ encoding.TextUnmarshaler = (*ExportJobType)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
func ExportJobTypes() []ExportJobType {
|
||||||
|
return []ExportJobType{
|
||||||
|
ExportJobTypeFramework,
|
||||||
|
ExportJobTypeDocument,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ejt *ExportJobType) Scan(value any) error {
|
func (v ExportJobType) IsValid() bool {
|
||||||
var s string
|
switch v {
|
||||||
|
case
|
||||||
switch v := value.(type) {
|
ExportJobTypeFramework,
|
||||||
case string:
|
ExportJobTypeDocument:
|
||||||
s = v
|
return true
|
||||||
case []byte:
|
|
||||||
s = string(v)
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("unsupported type for ExportJobType: %T", value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch s {
|
return false
|
||||||
case ExportJobTypeFramework.String():
|
}
|
||||||
*ejt = ExportJobTypeFramework
|
|
||||||
case ExportJobTypeDocument.String():
|
func (v ExportJobType) String() string {
|
||||||
*ejt = ExportJobTypeDocument
|
return string(v)
|
||||||
default:
|
}
|
||||||
return fmt.Errorf("invalid ExportJobType value: %q", s)
|
|
||||||
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ejt ExportJobType) Value() (driver.Value, error) {
|
|
||||||
return ejt.String(), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -26,34 +26,45 @@ const (
|
|||||||
FileVisibilityPublic FileVisibility = "PUBLIC"
|
FileVisibilityPublic FileVisibility = "PUBLIC"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (fv FileVisibility) String() string {
|
var (
|
||||||
return string(fv)
|
_ fmt.Stringer = FileVisibility("")
|
||||||
|
_ encoding.TextMarshaler = FileVisibility("")
|
||||||
|
_ encoding.TextUnmarshaler = (*FileVisibility)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
func FileVisibilities() []FileVisibility {
|
||||||
|
return []FileVisibility{
|
||||||
|
FileVisibilityPrivate,
|
||||||
|
FileVisibilityPublic,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fv *FileVisibility) Scan(value any) error {
|
func (v FileVisibility) IsValid() bool {
|
||||||
var s string
|
switch v {
|
||||||
|
case
|
||||||
switch v := value.(type) {
|
FileVisibilityPrivate,
|
||||||
case string:
|
FileVisibilityPublic:
|
||||||
s = v
|
return true
|
||||||
case []byte:
|
|
||||||
s = string(v)
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("unsupported type for FileVisibility: %T", value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch s {
|
return false
|
||||||
case "PRIVATE":
|
}
|
||||||
*fv = FileVisibilityPrivate
|
|
||||||
case "PUBLIC":
|
func (v FileVisibility) String() string {
|
||||||
*fv = FileVisibilityPublic
|
return string(v)
|
||||||
default:
|
}
|
||||||
return fmt.Errorf("invalid FileVisibility value: %q", s)
|
|
||||||
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fv FileVisibility) Value() (driver.Value, error) {
|
|
||||||
return fv.String(), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,6 +28,12 @@ const (
|
|||||||
FindingKindException FindingKind = "EXCEPTION"
|
FindingKindException FindingKind = "EXCEPTION"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Stringer = FindingKind("")
|
||||||
|
_ encoding.TextMarshaler = FindingKind("")
|
||||||
|
_ encoding.TextUnmarshaler = (*FindingKind)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func FindingKinds() []FindingKind {
|
func FindingKinds() []FindingKind {
|
||||||
return []FindingKind{
|
return []FindingKind{
|
||||||
FindingKindMinorNonconformity,
|
FindingKindMinorNonconformity,
|
||||||
@@ -37,38 +43,34 @@ func FindingKinds() []FindingKind {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fk FindingKind) String() string {
|
func (v FindingKind) IsValid() bool {
|
||||||
return string(fk)
|
switch v {
|
||||||
|
case
|
||||||
|
FindingKindMinorNonconformity,
|
||||||
|
FindingKindMajorNonconformity,
|
||||||
|
FindingKindObservation,
|
||||||
|
FindingKindException:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fk *FindingKind) Scan(value any) error {
|
func (v FindingKind) String() string {
|
||||||
var s string
|
return string(v)
|
||||||
|
}
|
||||||
|
|
||||||
switch v := value.(type) {
|
func (v FindingKind) MarshalText() ([]byte, error) {
|
||||||
case string:
|
return []byte(v.String()), nil
|
||||||
s = v
|
}
|
||||||
case []byte:
|
|
||||||
s = string(v)
|
func (v *FindingKind) UnmarshalText(text []byte) error {
|
||||||
default:
|
val := FindingKind(text)
|
||||||
return fmt.Errorf("unsupported type for FindingKind: %T", value)
|
if !val.IsValid() {
|
||||||
|
return fmt.Errorf("invalid FindingKind value: %q", string(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
switch s {
|
*v = val
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fk FindingKind) Value() (driver.Value, error) {
|
|
||||||
return fk.String(), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,7 +15,10 @@
|
|||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FindingOrderField string
|
type FindingOrderField string
|
||||||
@@ -30,31 +33,60 @@ const (
|
|||||||
FindingOrderFieldKind FindingOrderField = "KIND"
|
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 {
|
func (p FindingOrderField) Column() string {
|
||||||
return string(p)
|
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
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -27,6 +27,12 @@ const (
|
|||||||
FindingPriorityHigh FindingPriority = "HIGH"
|
FindingPriorityHigh FindingPriority = "HIGH"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Stringer = FindingPriority("")
|
||||||
|
_ encoding.TextMarshaler = FindingPriority("")
|
||||||
|
_ encoding.TextUnmarshaler = (*FindingPriority)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func FindingPriorities() []FindingPriority {
|
func FindingPriorities() []FindingPriority {
|
||||||
return []FindingPriority{
|
return []FindingPriority{
|
||||||
FindingPriorityLow,
|
FindingPriorityLow,
|
||||||
@@ -35,36 +41,33 @@ func FindingPriorities() []FindingPriority {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fp FindingPriority) String() string {
|
func (v FindingPriority) IsValid() bool {
|
||||||
return string(fp)
|
switch v {
|
||||||
|
case
|
||||||
|
FindingPriorityLow,
|
||||||
|
FindingPriorityMedium,
|
||||||
|
FindingPriorityHigh:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fp *FindingPriority) Scan(value any) error {
|
func (v FindingPriority) String() string {
|
||||||
var s string
|
return string(v)
|
||||||
|
}
|
||||||
|
|
||||||
switch v := value.(type) {
|
func (v FindingPriority) MarshalText() ([]byte, error) {
|
||||||
case string:
|
return []byte(v.String()), nil
|
||||||
s = v
|
}
|
||||||
case []byte:
|
|
||||||
s = string(v)
|
func (v *FindingPriority) UnmarshalText(text []byte) error {
|
||||||
default:
|
val := FindingPriority(text)
|
||||||
return fmt.Errorf("unsupported type for FindingPriority: %T", value)
|
if !val.IsValid() {
|
||||||
|
return fmt.Errorf("invalid FindingPriority value: %q", string(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
switch s {
|
*v = val
|
||||||
case "LOW":
|
|
||||||
*fp = FindingPriorityLow
|
|
||||||
case "MEDIUM":
|
|
||||||
*fp = FindingPriorityMedium
|
|
||||||
case "HIGH":
|
|
||||||
*fp = FindingPriorityHigh
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("invalid FindingPriority value: %q", s)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fp FindingPriority) Value() (driver.Value, error) {
|
|
||||||
return fp.String(), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,6 +30,12 @@ const (
|
|||||||
FindingStatusFalsePositive FindingStatus = "FALSE_POSITIVE"
|
FindingStatusFalsePositive FindingStatus = "FALSE_POSITIVE"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Stringer = FindingStatus("")
|
||||||
|
_ encoding.TextMarshaler = FindingStatus("")
|
||||||
|
_ encoding.TextUnmarshaler = (*FindingStatus)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func FindingStatuses() []FindingStatus {
|
func FindingStatuses() []FindingStatus {
|
||||||
return []FindingStatus{
|
return []FindingStatus{
|
||||||
FindingStatusOpen,
|
FindingStatusOpen,
|
||||||
@@ -41,42 +47,36 @@ func FindingStatuses() []FindingStatus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs FindingStatus) String() string {
|
func (v FindingStatus) IsValid() bool {
|
||||||
return string(fs)
|
switch v {
|
||||||
|
case
|
||||||
|
FindingStatusOpen,
|
||||||
|
FindingStatusInProgress,
|
||||||
|
FindingStatusClosed,
|
||||||
|
FindingStatusRiskAccepted,
|
||||||
|
FindingStatusMitigated,
|
||||||
|
FindingStatusFalsePositive:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs *FindingStatus) Scan(value any) error {
|
func (v FindingStatus) String() string {
|
||||||
var s string
|
return string(v)
|
||||||
|
}
|
||||||
|
|
||||||
switch v := value.(type) {
|
func (v FindingStatus) MarshalText() ([]byte, error) {
|
||||||
case string:
|
return []byte(v.String()), nil
|
||||||
s = v
|
}
|
||||||
case []byte:
|
|
||||||
s = string(v)
|
func (v *FindingStatus) UnmarshalText(text []byte) error {
|
||||||
default:
|
val := FindingStatus(text)
|
||||||
return fmt.Errorf("unsupported type for FindingStatus: %T", value)
|
if !val.IsValid() {
|
||||||
|
return fmt.Errorf("invalid FindingStatus value: %q", string(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
switch s {
|
*v = val
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs FindingStatus) Value() (driver.Value, error) {
|
|
||||||
return fs.String(), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -14,6 +14,13 @@
|
|||||||
|
|
||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
FrameworkOrderField string
|
FrameworkOrderField string
|
||||||
)
|
)
|
||||||
@@ -22,19 +29,48 @@ const (
|
|||||||
FrameworkOrderFieldCreatedAt FrameworkOrderField = "CREATED_AT"
|
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 {
|
func (p FrameworkOrderField) Column() string {
|
||||||
return string(p)
|
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
|
package coredata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
IdentityOrderField string
|
IdentityOrderField string
|
||||||
)
|
)
|
||||||
@@ -22,19 +29,48 @@ const (
|
|||||||
IdentityOrderFieldCreatedAt IdentityOrderField = "CREATED_AT"
|
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 {
|
func (p IdentityOrderField) Column() string {
|
||||||
return string(p)
|
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
|
package coredata
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
// InvitationOrderField defines the fields that can be used to order invitations
|
// InvitationOrderField defines the fields that can be used to order invitations
|
||||||
type InvitationOrderField string
|
type InvitationOrderField string
|
||||||
@@ -24,6 +29,48 @@ const (
|
|||||||
InvitationOrderFieldCreatedAt InvitationOrderField = "CREATED_AT"
|
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 {
|
func (p InvitationOrderField) Column() string {
|
||||||
switch p {
|
switch p {
|
||||||
case InvitationOrderFieldCreatedAt:
|
case InvitationOrderFieldCreatedAt:
|
||||||
@@ -32,29 +79,3 @@ func (p InvitationOrderField) Column() string {
|
|||||||
|
|
||||||
panic(fmt.Sprintf("unsupported order by: %s", p))
|
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 (
|
import (
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@@ -31,40 +32,43 @@ const (
|
|||||||
InvitationStatusExpired InvitationStatus = "EXPIRED"
|
InvitationStatusExpired InvitationStatus = "EXPIRED"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (tcv InvitationStatus) String() string {
|
var (
|
||||||
return string(tcv)
|
_ 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 {
|
func (v InvitationStatus) String() string {
|
||||||
var s string
|
return string(v)
|
||||||
|
}
|
||||||
|
|
||||||
switch v := value.(type) {
|
func (v InvitationStatus) MarshalText() ([]byte, error) {
|
||||||
case string:
|
return []byte(v.String()), nil
|
||||||
s = v
|
}
|
||||||
case []byte:
|
|
||||||
s = string(v)
|
func (v *InvitationStatus) UnmarshalText(text []byte) error {
|
||||||
default:
|
val := InvitationStatus(text)
|
||||||
return fmt.Errorf("unsupported type for TrustCenterVisibility: %T", value)
|
if !val.IsValid() {
|
||||||
|
return fmt.Errorf("invalid InvitationStatus value: %q", string(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
switch s {
|
*v = val
|
||||||
case "PENDING":
|
|
||||||
*tcv = InvitationStatusPending
|
|
||||||
case "ACCEPTED":
|
|
||||||
*tcv = InvitationStatusAccepted
|
|
||||||
case "EXPIRED":
|
|
||||||
*tcv = InvitationStatusExpired
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("invalid InvitationStatus value: %q", s)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tcv InvitationStatus) Value() (driver.Value, error) {
|
|
||||||
return tcv.String(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (statuses InvitationStatuses) Value() (driver.Value, error) {
|
func (statuses InvitationStatuses) Value() (driver.Value, error) {
|
||||||
if len(statuses) == 0 {
|
if len(statuses) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|||||||
@@ -14,7 +14,12 @@
|
|||||||
|
|
||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type MailingListSubscriberOrderField string
|
type MailingListSubscriberOrderField string
|
||||||
|
|
||||||
@@ -22,8 +27,46 @@ const (
|
|||||||
MailingListSubscriberOrderFieldCreatedAt MailingListSubscriberOrderField = "CREATED_AT"
|
MailingListSubscriberOrderFieldCreatedAt MailingListSubscriberOrderField = "CREATED_AT"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (f MailingListSubscriberOrderField) String() string {
|
var (
|
||||||
return string(f)
|
_ 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 {
|
func (f MailingListSubscriberOrderField) Column() string {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -26,34 +26,45 @@ const (
|
|||||||
MailingListSubscriberStatusConfirmed MailingListSubscriberStatus = "CONFIRMED"
|
MailingListSubscriberStatusConfirmed MailingListSubscriberStatus = "CONFIRMED"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s MailingListSubscriberStatus) String() string {
|
var (
|
||||||
return string(s)
|
_ fmt.Stringer = MailingListSubscriberStatus("")
|
||||||
|
_ encoding.TextMarshaler = MailingListSubscriberStatus("")
|
||||||
|
_ encoding.TextUnmarshaler = (*MailingListSubscriberStatus)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
func MailingListSubscriberStatuses() []MailingListSubscriberStatus {
|
||||||
|
return []MailingListSubscriberStatus{
|
||||||
|
MailingListSubscriberStatusPending,
|
||||||
|
MailingListSubscriberStatusConfirmed,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MailingListSubscriberStatus) Scan(value any) error {
|
func (v MailingListSubscriberStatus) IsValid() bool {
|
||||||
var str string
|
switch v {
|
||||||
|
case
|
||||||
switch v := value.(type) {
|
MailingListSubscriberStatusPending,
|
||||||
case string:
|
MailingListSubscriberStatusConfirmed:
|
||||||
str = v
|
return true
|
||||||
case []byte:
|
|
||||||
str = string(v)
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("unsupported type for MailingListSubscriberStatus: %T", value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch str {
|
return false
|
||||||
case "PENDING":
|
}
|
||||||
*s = MailingListSubscriberStatusPending
|
|
||||||
case "CONFIRMED":
|
func (v MailingListSubscriberStatus) String() string {
|
||||||
*s = MailingListSubscriberStatusConfirmed
|
return string(v)
|
||||||
default:
|
}
|
||||||
return fmt.Errorf("invalid MailingListSubscriberStatus value: %q", str)
|
|
||||||
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s MailingListSubscriberStatus) Value() (driver.Value, error) {
|
|
||||||
return s.String(), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -14,7 +14,12 @@
|
|||||||
|
|
||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type MailingListUpdateOrderField string
|
type MailingListUpdateOrderField string
|
||||||
|
|
||||||
@@ -23,8 +28,48 @@ const (
|
|||||||
MailingListUpdateOrderFieldUpdatedAt MailingListUpdateOrderField = "UPDATED_AT"
|
MailingListUpdateOrderFieldUpdatedAt MailingListUpdateOrderField = "UPDATED_AT"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (f MailingListUpdateOrderField) String() string {
|
var (
|
||||||
return string(f)
|
_ 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 {
|
func (f MailingListUpdateOrderField) Column() string {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,38 +28,49 @@ const (
|
|||||||
MailingListUpdateStatusSent MailingListUpdateStatus = "SENT"
|
MailingListUpdateStatusSent MailingListUpdateStatus = "SENT"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s MailingListUpdateStatus) String() string {
|
var (
|
||||||
return string(s)
|
_ 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 {
|
func (v MailingListUpdateStatus) IsValid() bool {
|
||||||
var str string
|
switch v {
|
||||||
|
case
|
||||||
switch v := value.(type) {
|
MailingListUpdateStatusDraft,
|
||||||
case string:
|
MailingListUpdateStatusEnqueued,
|
||||||
str = v
|
MailingListUpdateStatusProcessing,
|
||||||
case []byte:
|
MailingListUpdateStatusSent:
|
||||||
str = string(v)
|
return true
|
||||||
default:
|
|
||||||
return fmt.Errorf("unsupported type for MailingListUpdateStatus: %T", value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch str {
|
return false
|
||||||
case "DRAFT":
|
}
|
||||||
*s = MailingListUpdateStatusDraft
|
|
||||||
case "ENQUEUED":
|
func (v MailingListUpdateStatus) String() string {
|
||||||
*s = MailingListUpdateStatusEnqueued
|
return string(v)
|
||||||
case "PROCESSING":
|
}
|
||||||
*s = MailingListUpdateStatusProcessing
|
|
||||||
case "SENT":
|
func (v MailingListUpdateStatus) MarshalText() ([]byte, error) {
|
||||||
*s = MailingListUpdateStatusSent
|
return []byte(v.String()), nil
|
||||||
default:
|
}
|
||||||
return fmt.Errorf("invalid MailingListUpdateStatus value: %q", str)
|
|
||||||
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s MailingListUpdateStatus) Value() (driver.Value, error) {
|
|
||||||
return s.String(), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -29,40 +29,51 @@ const (
|
|||||||
MembershipRoleAuditor MembershipRole = "AUDITOR"
|
MembershipRoleAuditor MembershipRole = "AUDITOR"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r MembershipRole) String() string {
|
var (
|
||||||
return string(r)
|
_ 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 {
|
func (v MembershipRole) IsValid() bool {
|
||||||
var s string
|
switch v {
|
||||||
|
case
|
||||||
switch v := value.(type) {
|
MembershipRoleOwner,
|
||||||
case string:
|
MembershipRoleAdmin,
|
||||||
s = v
|
MembershipRoleEmployee,
|
||||||
case []byte:
|
MembershipRoleViewer,
|
||||||
s = string(v)
|
MembershipRoleAuditor:
|
||||||
default:
|
return true
|
||||||
return fmt.Errorf("unsupported type for MembershipRole: %T", value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch s {
|
return false
|
||||||
case "OWNER":
|
}
|
||||||
*r = MembershipRoleOwner
|
|
||||||
case "ADMIN":
|
func (v MembershipRole) String() string {
|
||||||
*r = MembershipRoleAdmin
|
return string(v)
|
||||||
case "EMPLOYEE":
|
}
|
||||||
*r = MembershipRoleEmployee
|
|
||||||
case "VIEWER":
|
func (v MembershipRole) MarshalText() ([]byte, error) {
|
||||||
*r = MembershipRoleViewer
|
return []byte(v.String()), nil
|
||||||
case "AUDITOR":
|
}
|
||||||
*r = MembershipRoleAuditor
|
|
||||||
default:
|
func (v *MembershipRole) UnmarshalText(text []byte) error {
|
||||||
return fmt.Errorf("invalid MembershipRole value: %q", s)
|
val := MembershipRole(text)
|
||||||
|
if !val.IsValid() {
|
||||||
|
return fmt.Errorf("invalid MembershipRole value: %q", string(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*v = val
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r MembershipRole) Value() (driver.Value, error) {
|
|
||||||
return r.String(), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -14,6 +14,13 @@
|
|||||||
|
|
||||||
package coredata
|
package coredata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
MembershipOrderField string
|
MembershipOrderField string
|
||||||
)
|
)
|
||||||
@@ -26,6 +33,56 @@ const (
|
|||||||
MembershipOrderFieldCreatedAt MembershipOrderField = "CREATED_AT"
|
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 {
|
func (p MembershipOrderField) Column() string {
|
||||||
switch p {
|
switch p {
|
||||||
case MembershipOrderFieldOrganizationName:
|
case MembershipOrderFieldOrganizationName:
|
||||||
@@ -42,16 +99,3 @@ func (p MembershipOrderField) Column() string {
|
|||||||
|
|
||||||
return string(p)
|
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
|
package coredata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.probo.inc/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
MembershipProfileOrderField string
|
MembershipProfileOrderField string
|
||||||
)
|
)
|
||||||
@@ -26,19 +33,56 @@ const (
|
|||||||
MembershipProfileOrderFieldState MembershipProfileOrderField = "STATE"
|
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 {
|
func (p MembershipProfileOrderField) Column() string {
|
||||||
return string(p)
|
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