File size: 2,170 Bytes
b110593
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//                           _       _
// __      _____  __ ___   ___  __ _| |_ ___
// \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
//  \ V  V /  __/ (_| |\ V /| | (_| | ||  __/
//   \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
//
//  Copyright © 2016 - 2024 Weaviate B.V. All rights reserved.
//
//  CONTACT: [email protected]
//

package modulecapabilities

import (
	"context"

	"github.com/weaviate/weaviate/entities/models"
	"github.com/weaviate/weaviate/entities/moduletools"
	"github.com/weaviate/weaviate/entities/schema"
)

// ClassConfigurator is an optional capability interface which a module MAY
// implement. If it is implemented, all methods will be called when the user
// adds or updates a class which has the module set as the vectorizer
type ClassConfigurator interface {
	// ClassDefaults provides the defaults for a per-class module config. The
	// module provider will merge the props into the user-specified config with
	// the user-provided values taking precedence
	ClassConfigDefaults() map[string]interface{}

	// PropertyConfigDefaults provides the defaults for a per-property module
	// config. The module provider will merge the props into the user-specified
	// config with the user-provided values taking precedence. The property's
	// dataType MAY be taken into consideration when deciding defaults.
	// dataType is not guaranteed to be non-nil, it might be nil in the case a
	// user specified an invalid dataType, as some validation only occurs after
	// defaults are set.
	PropertyConfigDefaults(dataType *schema.DataType) map[string]interface{}

	// ValidateClass MAY validate anything about the class, except the config of
	// another module. The specified ClassConfig can be used to easily retrieve
	// the config specific for the module. For example, a module could iterate
	// over class.Properties and call classConfig.Property(prop.Name) to validate
	// the per-property config. A module MUST NOT extract another module's config
	// from class.ModuleConfig["other-modules-name"].
	ValidateClass(ctx context.Context, class *models.Class,
		classConfig moduletools.ClassConfig) error
}