2024-11-05 16:18:04 +00:00
|
|
|
// Code generated by sqlc. DO NOT EDIT.
|
|
|
|
|
// versions:
|
2025-01-28 20:20:54 +00:00
|
|
|
// sqlc v1.28.0
|
2024-11-05 16:18:04 +00:00
|
|
|
|
|
|
|
|
package internal
|
|
|
|
|
|
|
|
|
|
import (
|
2024-12-19 21:18:15 +00:00
|
|
|
"database/sql/driver"
|
|
|
|
|
"fmt"
|
2024-11-05 16:18:04 +00:00
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/acaloiaro/frm/types"
|
|
|
|
|
)
|
|
|
|
|
|
2024-12-19 21:18:15 +00:00
|
|
|
type FormStatus string
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
FormStatusPublished FormStatus = "published"
|
|
|
|
|
FormStatusDraft FormStatus = "draft"
|
2025-02-11 21:54:17 +00:00
|
|
|
FormStatusArchived FormStatus = "archived"
|
2024-12-19 21:18:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func (e *FormStatus) Scan(src interface{}) error {
|
|
|
|
|
switch s := src.(type) {
|
|
|
|
|
case []byte:
|
|
|
|
|
*e = FormStatus(s)
|
|
|
|
|
case string:
|
|
|
|
|
*e = FormStatus(s)
|
|
|
|
|
default:
|
|
|
|
|
return fmt.Errorf("unsupported scan type for FormStatus: %T", src)
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type NullFormStatus struct {
|
|
|
|
|
FormStatus FormStatus `json:"form_status"`
|
|
|
|
|
Valid bool `json:"valid"` // Valid is true if FormStatus is not NULL
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Scan implements the Scanner interface.
|
|
|
|
|
func (ns *NullFormStatus) Scan(value interface{}) error {
|
|
|
|
|
if value == nil {
|
|
|
|
|
ns.FormStatus, ns.Valid = "", false
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
ns.Valid = true
|
|
|
|
|
return ns.FormStatus.Scan(value)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Value implements the driver Valuer interface.
|
|
|
|
|
func (ns NullFormStatus) Value() (driver.Value, error) {
|
|
|
|
|
if !ns.Valid {
|
|
|
|
|
return nil, nil
|
|
|
|
|
}
|
|
|
|
|
return string(ns.FormStatus), nil
|
2024-12-19 16:50:49 +00:00
|
|
|
}
|
|
|
|
|
|
2025-01-11 00:11:33 +00:00
|
|
|
type SubmissionStatus string
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
SubmissionStatusComplete SubmissionStatus = "complete"
|
|
|
|
|
SubmissionStatusPartial SubmissionStatus = "partial"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func (e *SubmissionStatus) Scan(src interface{}) error {
|
|
|
|
|
switch s := src.(type) {
|
|
|
|
|
case []byte:
|
|
|
|
|
*e = SubmissionStatus(s)
|
|
|
|
|
case string:
|
|
|
|
|
*e = SubmissionStatus(s)
|
|
|
|
|
default:
|
|
|
|
|
return fmt.Errorf("unsupported scan type for SubmissionStatus: %T", src)
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type NullSubmissionStatus struct {
|
|
|
|
|
SubmissionStatus SubmissionStatus `json:"submission_status"`
|
|
|
|
|
Valid bool `json:"valid"` // Valid is true if SubmissionStatus is not NULL
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Scan implements the Scanner interface.
|
|
|
|
|
func (ns *NullSubmissionStatus) Scan(value interface{}) error {
|
|
|
|
|
if value == nil {
|
|
|
|
|
ns.SubmissionStatus, ns.Valid = "", false
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
ns.Valid = true
|
|
|
|
|
return ns.SubmissionStatus.Scan(value)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Value implements the driver Valuer interface.
|
|
|
|
|
func (ns NullSubmissionStatus) Value() (driver.Value, error) {
|
|
|
|
|
if !ns.Valid {
|
|
|
|
|
return nil, nil
|
|
|
|
|
}
|
|
|
|
|
return string(ns.SubmissionStatus), nil
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-05 16:18:04 +00:00
|
|
|
// Form contains all the data necesary to render a form
|
|
|
|
|
type Form struct {
|
2024-12-19 21:18:15 +00:00
|
|
|
ID int64 `json:"id"`
|
|
|
|
|
FormID *int64 `json:"form_id"`
|
2024-11-05 16:18:04 +00:00
|
|
|
// a namespace for the form
|
2025-01-14 16:46:22 +00:00
|
|
|
WorkspaceID string `json:"workspace_id"`
|
|
|
|
|
Name string `json:"name"`
|
2024-12-17 21:15:26 +00:00
|
|
|
// all form fields are serialized to JSON, see types.FormFields for structure details
|
2024-11-05 16:18:04 +00:00
|
|
|
Fields types.FormFields `json:"fields"`
|
2024-12-19 21:18:15 +00:00
|
|
|
Status FormStatus `json:"status"`
|
2024-11-05 16:18:04 +00:00
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
}
|
2025-01-11 00:11:33 +00:00
|
|
|
|
|
|
|
|
// Respondants submit forms/fields to the collector as form_submissions
|
|
|
|
|
type FormSubmission struct {
|
2025-01-14 16:46:22 +00:00
|
|
|
ID int64 `json:"id"`
|
2025-01-23 14:31:12 +00:00
|
|
|
FormID int64 `json:"form_id"`
|
2025-01-14 16:46:22 +00:00
|
|
|
WorkspaceID string `json:"workspace_id"`
|
2025-01-22 15:54:40 +00:00
|
|
|
// identifies the subject/respondent who filled out the form
|
|
|
|
|
SubjectID *string `json:"subject_id"`
|
2025-01-11 00:11:33 +00:00
|
|
|
// all form submissions are serialized to JSON, see types.FormFieldValue for structure details
|
|
|
|
|
Fields types.FormFieldValues `json:"fields"`
|
|
|
|
|
Status SubmissionStatus `json:"status"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
}
|
2025-01-14 16:46:22 +00:00
|
|
|
|
|
|
|
|
// Short codes are short codes/names for URLs that identify the subject submitting a form
|
|
|
|
|
type ShortCode struct {
|
|
|
|
|
ID int64 `json:"id"`
|
|
|
|
|
WorkspaceID string `json:"workspace_id"`
|
|
|
|
|
FormID *int64 `json:"form_id"`
|
|
|
|
|
ShortCode string `json:"short_code"`
|
|
|
|
|
SubjectID string `json:"subject_id"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
}
|