Documentation
¶
Index ¶
- Constants
- func GetRefParametersLookups() []bson.M
- func TransformRefParameters(ctx context.Context, r []externaldata.RefParameters, ...) ([]externaldata.RefParameters, error)
- func ValidateRefParameters(sl validator.StructLevel, templateExecutor template.Executor, ...)
- type API
- type AggregationDataResult
- type AggregationResult
- type BaseColumnConfig
- type BulkDeleteRequestItem
- type Column
- type ColumnConfig
- type EditRequest
- type ErrorInfo
- type ExportFetchParameters
- type ExportRequest
- type ExportResponse
- type ImportCompleteRequest
- type ImportJob
- type ImportWorker
- type ListDataRequest
- type ListPreviewRequest
- type ListRequest
- type Parser
- type PreviewRequest
- type RefResponse
- type Row
- type Store
- type Table
- type UpdateRequest
Constants ¶
View Source
const ( ImportStatusCreated = iota ImportStatusRunning ImportStatusSucceeded ImportStatusFailed ImportStatusPreviewSucceeded ImportStatusPreviewFailed )
View Source
const ( JobTypeImport = iota JobTypePreview )
View Source
const ( // MaxStringLenStr and MaxIDLenStr are strings to avoid conversion. MaxStringLenStr = "255" MaxIDLenStr = "36" // uuid len MaxStringLen = 255 )
View Source
const ( SeparatorComma = "," SeparatorDot = "." SeparatorSpace = " " SeparatorNone = "" )
Variables ¶
This section is empty.
Functions ¶
func TransformRefParameters ¶
func TransformRefParameters(ctx context.Context, r []externaldata.RefParameters, dbCollection mongo.DbCollection) ([]externaldata.RefParameters, error)
func ValidateRefParameters ¶
func ValidateRefParameters(sl validator.StructLevel, templateExecutor template.Executor, r []externaldata.RefParameters, availableTypes []string)
Types ¶
type API ¶
type API interface {
crud.API
BulkDeleteData(c *gin.Context)
GetSchema(c *gin.Context)
Import(*gin.Context)
ImportStatus(*gin.Context)
ImportData(*gin.Context)
Preview(c *gin.Context)
ImportComplete(*gin.Context)
Export(c *gin.Context)
ExportStatus(c *gin.Context)
ExportDownload(c *gin.Context)
ListData(c *gin.Context)
GetData(c *gin.Context)
CreateData(c *gin.Context)
UpdateData(c *gin.Context)
DeleteData(c *gin.Context)
}
type AggregationDataResult ¶
type AggregationDataResult struct {
Data []map[string]any `bson:"data" json:"data"`
TotalCount int64 `bson:"total_count" json:"total_count"`
}
func (*AggregationDataResult) GetData ¶
func (r *AggregationDataResult) GetData() interface{}
func (*AggregationDataResult) GetTotal ¶
func (r *AggregationDataResult) GetTotal() int64
type AggregationResult ¶
type AggregationResult struct {
Data []Table `bson:"data" json:"data"`
TotalCount int64 `bson:"total_count" json:"total_count"`
}
func (*AggregationResult) GetData ¶
func (r *AggregationResult) GetData() interface{}
func (*AggregationResult) GetTotal ¶
func (r *AggregationResult) GetTotal() int64
type BaseColumnConfig ¶
type BaseColumnConfig struct {
Name string `bson:"name" json:"name" binding:"required"`
// Possible type values.
// * `1` - type string
// * `2` - type boolean
// * `3` - type number
// * `4` - type string_array
// * `5` - type datetime
// * `6` - type timestamp
// * `7` - type regexp
Type int `bson:"type" json:"type" binding:"required,min=1,max=7"`
// Possible thousands separator values.
// * `dot` - dot separator
// * `comma` - comma separator
// * `space` - space separator
ThousandsSeparator string `bson:"thousands_separator,omitempty" json:"thousands_separator,omitempty" binding:"oneoforempty=dot comma space"`
// Possible decimal separator values.
// * `dot` - dot separator
// * `comma` - comma separator
DecimalSeparator string `bson:"decimal_separator,omitempty" json:"decimal_separator,omitempty" binding:"oneoforempty=dot comma"`
// Possible string array types.
// * `1` - json array
// * `2` - custom separator array
StringArrayType int `bson:"string_array_type,omitempty" json:"string_array_type,omitempty" binding:"required_if=Type 4,omitempty,oneof=1 2"`
StringArraySeparator string `bson:"string_array_separator,omitempty" json:"string_array_separator,omitempty" binding:"required_if=StringArrayType 2"`
}
type BulkDeleteRequestItem ¶
type BulkDeleteRequestItem struct {
ID string `json:"_id" binding:"required"`
}
type Column ¶
type ColumnConfig ¶
type ColumnConfig struct {
BaseColumnConfig `bson:",inline"`
Tag *int `bson:"tag,omitempty" json:"tag,omitempty" binding:"omitempty,oneof=0 1 2"`
}
func (*ColumnConfig) IsRegexp ¶
func (c *ColumnConfig) IsRegexp() bool
type EditRequest ¶
type ErrorInfo ¶
type ExportFetchParameters ¶
type ExportRequest ¶
type ExportRequest struct {
ExportFetchParameters
Fields export.Fields `json:"fields"`
Separator string `json:"separator" binding:"oneoforempty=comma semicolon tab space"`
}
type ExportResponse ¶
type ImportCompleteRequest ¶
type ImportCompleteRequest struct {
ColumnTags []int `json:"column_tags" binding:"required,dive,oneof=0 1 2"`
}
type ImportJob ¶
type ImportJob struct {
ID string `bson:"_id" json:"_id"`
Status int `bson:"status" json:"status"`
Type int `bson:"type" json:"-"`
Table string `bson:"table" json:"-"`
ExternalDataTable string `bson:"exdt" json:"-"`
Separator rune `bson:"separator" json:"-"`
Filepath string `bson:"filepath" json:"-"`
Created datetime.CpsTime `bson:"created" json:"-"`
LastPing *datetime.CpsTime `bson:"last_ping" json:"-"`
Retries int64 `bson:"retries" json:"-"`
JobType int `bson:"job_type" json:"-"`
ColumnConfigs []ColumnConfig `bson:"column_configs,omitempty" json:"column_configs,omitempty"`
PrevColumnConfigs []ColumnConfig `bson:"prev_column_configs,omitempty" json:"-"`
ErrorInfo map[string]ErrorInfo `bson:"error_info,omitempty" json:"error_info,omitempty"`
FailReason string `bson:"fail_reason,omitempty" json:"fail_reason,omitempty"`
}
type ImportWorker ¶
type ImportWorker interface {
CreateImportJob(ctx context.Context, id string, separator rune, f multipart.File) (_ ImportJob, resErr error)
ProcessJob(ctx context.Context, id string) error
GetJob(ctx context.Context, id string) (ImportJob, error)
CompleteJob(ctx context.Context, id string, columnTags []int) (bool, error)
ProcessAbandonedJobs(ctx context.Context)
DeleteOldJobs(ctx context.Context)
CreatePreviewJob(ctx context.Context, id string, req PreviewRequest) (ImportJob, error)
}
func NewImportWorker ¶
func NewImportWorker( dbClient mongo.DbClient, pgPoolProvider postgres.PoolProvider, tmpImportDir string, jobPublisher workers.JobPublisher, logger zerolog.Logger, ) ImportWorker
type ListDataRequest ¶
type ListDataRequest struct {
pagination.FilteredQuery
SearchBy []string `json:"search_by" form:"search_by[]"`
SortBy string `json:"sort_by" form:"sort_by"`
}
type ListPreviewRequest ¶
type ListPreviewRequest struct {
pagination.Query
}
type ListRequest ¶
type ListRequest struct {
pagination.FilteredQuery
SortBy string `form:"sort_by" binding:"oneoforempty=_id name description type"`
IDs []string `form:"ids[]"`
}
type Parser ¶
type Parser interface {
Parse(cfg ColumnConfig, initialValue string) (any, error)
}
type PreviewRequest ¶
type PreviewRequest struct {
ColumnConfigs []ColumnConfig `json:"column_configs" binding:"required,dive"`
}
type RefResponse ¶
type RefResponse struct {
Reference string `bson:"reference" json:"reference"`
Type string `json:"type" bson:"type"`
// are used in db external data
Table Table `json:"table,omitempty" bson:"table,omitempty"`
Select map[string]string `json:"select,omitempty" bson:"select,omitempty"`
Regexp map[string]string `json:"regexp,omitempty" bson:"regexp,omitempty"`
SortBy string `json:"sort_by,omitempty" bson:"sort_by,omitempty"`
Sort string `json:"sort,omitempty" bson:"sort,omitempty" binding:"oneoforempty=asc desc"`
Optional bool `json:"optional,omitempty" bson:"optional,omitempty"`
// are used in api external data
Request *request.Parameters `bson:"request,omitempty" json:"request,omitempty"`
}
type Store ¶
type Store interface {
Find(ctx context.Context, r ListRequest) (*AggregationResult, error)
FindOne(ctx context.Context, id string) (Table, error)
Create(ctx context.Context, r EditRequest) (Table, error)
Update(ctx context.Context, r UpdateRequest) (Table, error)
Delete(ctx context.Context, id, author string) (bool, error)
FindData(ctx context.Context, tableName string, tableType int, columnConfigs []externaldata.ColumnConfig, r ListDataRequest) (*AggregationDataResult, error)
FindPreviewData(ctx context.Context, job ImportJob, r ListPreviewRequest) (*AggregationDataResult, error)
FindOneData(ctx context.Context, tableID, id string) (map[string]any, error)
CreateData(ctx context.Context, tableID string, r map[string]any) (map[string]any, error)
UpdateData(ctx context.Context, tableID, id string, r map[string]any) (map[string]any, error)
DeleteData(ctx context.Context, table Table, id string) (bool, error)
Export(ctx context.Context, t export.Task) (export.DataCursor, error)
}
type Table ¶
type Table struct {
ID string `bson:"_id" json:"_id"`
Type int `bson:"type" json:"type"`
Name string `bson:"name" json:"name"`
Description string `bson:"description" json:"description"`
ColumnConfigs []externaldata.ColumnConfig `bson:"column_configs" json:"column_configs"`
FromConfig bool `bson:"from_config" json:"from_config"`
RemovedFromConfig bool `bson:"removed_from_config" json:"removed_from_config"`
Created datetime.CpsTime `bson:"created" json:"created" swaggertype:"integer"`
Updated datetime.CpsTime `bson:"updated" json:"updated" swaggertype:"integer"`
LinkedRules map[string][]struct {
ID string `bson:"_id" json:"_id"`
Name string `bson:"name" json:"name"`
} `bson:"linked_rules,omitempty" json:"linked_rules,omitempty"`
}
type UpdateRequest ¶
type UpdateRequest struct {
EditRequest
ID string `json:"-"`
ColumnTags []int `json:"column_tags" binding:"required,dive,oneof=0 1 2"`
}
Source Files
¶
- api.go
- import_worker.go
- models.go
- parser.go
- store.go
- validator.go
Click to show internal directories.
Click to hide internal directories.