solve schema validation conflicts
This commit is contained in:
27
pkg/plugin/definition/cache.go
Normal file
27
pkg/plugin/definition/cache.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package definition
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Cache defines the general cache interface for caching plugins.
|
||||
type Cache interface {
|
||||
// Get retrieves a value from the cache based on the given key.
|
||||
Get(ctx context.Context, key string) (string, error)
|
||||
|
||||
// Set stores a value in the cache with the given key and TTL (time-to-live) in seconds.
|
||||
Set(ctx context.Context, key, value string, ttl time.Duration) error
|
||||
|
||||
// Delete removes a value from the cache based on the given key.
|
||||
Delete(ctx context.Context, key string) error
|
||||
|
||||
// Clear removes all values from the cache.
|
||||
Clear(ctx context.Context) error
|
||||
}
|
||||
|
||||
// CacheProvider interface defines the contract for managing cache instances.
|
||||
type CacheProvider interface {
|
||||
// New initializes a new cache instance with the given configuration.
|
||||
New(ctx context.Context, config map[string]string) (Cache, func() error, error)
|
||||
}
|
||||
15
pkg/plugin/definition/decrypter.go
Normal file
15
pkg/plugin/definition/decrypter.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package definition
|
||||
|
||||
import "context"
|
||||
|
||||
// Decrypter defines the methods for decryption.
|
||||
type Decrypter interface {
|
||||
// Decrypt decrypts the given body using the provided privateKeyBase64 and publicKeyBase64.
|
||||
Decrypt(ctx context.Context, encryptedData string, privateKeyBase64, publicKeyBase64 string) (string, error)
|
||||
}
|
||||
|
||||
// DecrypterProvider initializes a new decrypter instance with the given config.
|
||||
type DecrypterProvider interface {
|
||||
// New creates a new decrypter instance based on the provided config.
|
||||
New(ctx context.Context, config map[string]string) (Decrypter, func() error, error)
|
||||
}
|
||||
15
pkg/plugin/definition/encrypter.go
Normal file
15
pkg/plugin/definition/encrypter.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package definition
|
||||
|
||||
import "context"
|
||||
|
||||
// Encrypter defines the methods for encryption.
|
||||
type Encrypter interface {
|
||||
// Encrypt encrypts the given body using the provided privateKeyBase64 and publicKeyBase64.
|
||||
Encrypt(ctx context.Context, data string, privateKeyBase64, publicKeyBase64 string) (string, error)
|
||||
}
|
||||
|
||||
// EncrypterProvider initializes a new encrypter instance with the given config.
|
||||
type EncrypterProvider interface {
|
||||
// New creates a new encrypter instance based on the provided config.
|
||||
New(ctx context.Context, config map[string]string) (Encrypter, func() error, error)
|
||||
}
|
||||
23
pkg/plugin/definition/keymanager.go
Normal file
23
pkg/plugin/definition/keymanager.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package definition
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/beckn/beckn-onix/pkg/model"
|
||||
)
|
||||
|
||||
// KeyManager defines the interface for key management operations/methods.
|
||||
type KeyManager interface {
|
||||
GenerateKeyPairs() (*model.Keyset, error)
|
||||
StorePrivateKeys(ctx context.Context, keyID string, keys *model.Keyset) error
|
||||
SigningPrivateKey(ctx context.Context, keyID string) (string, string, error)
|
||||
EncrPrivateKey(ctx context.Context, keyID string) (string, string, error)
|
||||
SigningPublicKey(ctx context.Context, subscriberID, uniqueKeyID string) (string, error)
|
||||
EncrPublicKey(ctx context.Context, subscriberID, uniqueKeyID string) (string, error)
|
||||
DeletePrivateKeys(ctx context.Context, keyID string) error
|
||||
}
|
||||
|
||||
// KeyManagerProvider initializes a new signer instance.
|
||||
type KeyManagerProvider interface {
|
||||
New(context.Context, Cache, RegistryLookup, map[string]string) (KeyManager, func() error, error)
|
||||
}
|
||||
10
pkg/plugin/definition/middleware.go
Normal file
10
pkg/plugin/definition/middleware.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package definition
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type MiddlewareProvider interface {
|
||||
New(ctx context.Context, cfg map[string]string) (func(http.Handler) http.Handler, error)
|
||||
}
|
||||
14
pkg/plugin/definition/publisher.go
Normal file
14
pkg/plugin/definition/publisher.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package definition
|
||||
|
||||
import "context"
|
||||
|
||||
// Publisher defines the general publisher interface for messaging plugins.
|
||||
type Publisher interface {
|
||||
// Publish sends a message (as a byte slice) using the underlying messaging system.
|
||||
Publish(context.Context, string, []byte) error
|
||||
}
|
||||
|
||||
type PublisherProvider interface {
|
||||
// New initializes a new publisher instance with the given configuration.
|
||||
New(ctx context.Context, config map[string]string) (Publisher, func() error, error)
|
||||
}
|
||||
11
pkg/plugin/definition/registry.go
Normal file
11
pkg/plugin/definition/registry.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package definition
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/beckn/beckn-onix/pkg/model"
|
||||
)
|
||||
|
||||
type RegistryLookup interface {
|
||||
Lookup(ctx context.Context, req *model.Subscription) ([]model.Subscription, error)
|
||||
}
|
||||
19
pkg/plugin/definition/router.go
Normal file
19
pkg/plugin/definition/router.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package definition
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
|
||||
"github.com/beckn/beckn-onix/pkg/model"
|
||||
)
|
||||
|
||||
// RouterProvider initializes the a new Router instance with the given config.
|
||||
type RouterProvider interface {
|
||||
New(ctx context.Context, config map[string]string) (Router, func() error, error)
|
||||
}
|
||||
|
||||
// Router defines the interface for routing requests.
|
||||
type Router interface {
|
||||
// Route determines the routing destination based on the request context.
|
||||
Route(ctx context.Context, url *url.URL, body []byte) (*model.Route, error)
|
||||
}
|
||||
16
pkg/plugin/definition/schemaValidator.go
Normal file
16
pkg/plugin/definition/schemaValidator.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package definition
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
// SchemaValidator interface for schema validation.
|
||||
type SchemaValidator interface {
|
||||
Validate(ctx context.Context, url *url.URL, payload []byte) error
|
||||
}
|
||||
|
||||
// SchemaValidatorProvider interface for creating validators.
|
||||
type SchemaValidatorProvider interface {
|
||||
New(ctx context.Context, config map[string]string) (SchemaValidator, func() error, error)
|
||||
}
|
||||
17
pkg/plugin/definition/signer.go
Normal file
17
pkg/plugin/definition/signer.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package definition
|
||||
|
||||
import "context"
|
||||
|
||||
// Signer defines the method for signing.
|
||||
type Signer interface {
|
||||
// Sign generates a signature for the given body and privateKeyBase64.
|
||||
// The signature is created with the given timestamps: createdAt (signature creation time)
|
||||
// and expiresAt (signature expiration time).
|
||||
Sign(ctx context.Context, body []byte, privateKeyBase64 string, createdAt, expiresAt int64) (string, error)
|
||||
}
|
||||
|
||||
// SignerProvider initializes a new signer instance with the given config.
|
||||
type SignerProvider interface {
|
||||
// New creates a new signer instance based on the provided config.
|
||||
New(ctx context.Context, config map[string]string) (Signer, func() error, error)
|
||||
}
|
||||
15
pkg/plugin/definition/signvalidator.go
Normal file
15
pkg/plugin/definition/signvalidator.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package definition
|
||||
|
||||
import "context"
|
||||
|
||||
// SignValidator defines the method for verifying signatures.
|
||||
type SignValidator interface {
|
||||
// Validate checks the validity of the signature for the given body.
|
||||
Validate(ctx context.Context, body []byte, header string, publicKeyBase64 string) error
|
||||
}
|
||||
|
||||
// SignValidatorProvider initializes a new Verifier instance with the given config.
|
||||
type SignValidatorProvider interface {
|
||||
// New creates a new Verifier instance based on the provided config.
|
||||
New(ctx context.Context, config map[string]string) (SignValidator, func() error, error)
|
||||
}
|
||||
15
pkg/plugin/definition/step.go
Normal file
15
pkg/plugin/definition/step.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package definition
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/beckn/beckn-onix/pkg/model"
|
||||
)
|
||||
|
||||
type Step interface {
|
||||
Run(ctx *model.StepContext) error
|
||||
}
|
||||
|
||||
type StepProvider interface {
|
||||
New(context.Context, map[string]string) (Step, func(), error)
|
||||
}
|
||||
Reference in New Issue
Block a user