Documentation
¶
Overview ¶
Package providerkit provides shared helpers used by integration definition implementations which assist in building consistent and robust integrations while reducing boilerplate. This includes common patterns for credential management, auth flows, and webhook handling.
Index ¶
- Variables
- func CelMapExpr(entries []CelMapEntry) string
- func CredentialSchema[T any]() (json.RawMessage, types.CredentialRef[T])
- func EncodeResult(value any, encodeErr error) (json.RawMessage, error)
- func EvalFilter(ctx context.Context, expr string, envelope types.MappingEnvelope) (bool, error)
- func EvalMap(ctx context.Context, expr string, envelope types.MappingEnvelope) (json.RawMessage, error)
- func MarshalEnvelope(resource string, payload any, encodeErr error) (types.MappingEnvelope, error)
- func MarshalEnvelopeVariant(variant string, resource string, payload any, encodeErr error) (types.MappingEnvelope, error)
- func OperationSchema[T any]() (json.RawMessage, types.OperationRef[T])
- func RawEnvelope(resource string, payload json.RawMessage) types.MappingEnvelope
- func RawEnvelopeVariant(variant string, resource string, payload json.RawMessage) types.MappingEnvelope
- func SchemaFrom[T any]() json.RawMessage
- func SchemaID(schema json.RawMessage) string
- func StaticHandler(run func() (json.RawMessage, error)) types.OperationHandler
- func WebhookEventSchema[T any]() (json.RawMessage, types.WebhookEventRef[T])
- func WithClient[C, R any](ref types.ClientRef[C], run func(context.Context, C) (R, error)) func(context.Context, types.OperationRequest) (R, error)
- func WithClientConfig[C, Config, R any](ref types.ClientRef[C], op types.OperationRef[Config], configErr error, ...) func(context.Context, types.OperationRequest) (R, error)
- func WithClientRequest[C, R any](ref types.ClientRef[C], ...) func(context.Context, types.OperationRequest) (R, error)
- func WithClientRequestConfig[C, Config, R any](ref types.ClientRef[C], op types.OperationRef[Config], configErr error, ...) func(context.Context, types.OperationRequest) (R, error)
- type CelMapEntry
Constants ¶
This section is empty.
Variables ¶
var ( // ErrFilterExprEval is returned when a filter CEL expression fails during evaluation ErrFilterExprEval = errors.New("filter expression evaluation failed") // ErrMapExprEval is returned when a map CEL expression fails during evaluation ErrMapExprEval = errors.New("map expression evaluation failed") )
Functions ¶
func CelMapExpr ¶
func CelMapExpr(entries []CelMapEntry) string
CelMapExpr renders a slice of CelMapEntry values into a CEL object literal string
func CredentialSchema ¶
func CredentialSchema[T any]() (json.RawMessage, types.CredentialRef[T])
CredentialSchema reflects a credential schema type and returns both the JSON schema and a typed credential ref whose slot identity is derived from the schema definition key
func EncodeResult ¶
func EncodeResult(value any, encodeErr error) (json.RawMessage, error)
EncodeResult serializes an operation result and maps any encode failure to the caller-supplied error
func EvalFilter ¶
EvalFilter evaluates a CEL filter expression against a MappingEnvelope An empty expr returns true (pass-through). Returns false when the expression excludes the envelope, or a wrapped ErrFilterExprEval on evaluation failure
func EvalMap ¶
func EvalMap(ctx context.Context, expr string, envelope types.MappingEnvelope) (json.RawMessage, error)
EvalMap evaluates a CEL map expression against a MappingEnvelope and returns a JSON payload An empty expr returns the original envelope.Payload (pass-through) Returns a wrapped ErrMapExprEval on failure
func MarshalEnvelope ¶
MarshalEnvelope serializes a provider payload into one mapping envelope
func MarshalEnvelopeVariant ¶
func MarshalEnvelopeVariant(variant string, resource string, payload any, encodeErr error) (types.MappingEnvelope, error)
MarshalEnvelopeVariant serializes a provider payload into one mapping envelope for a specific variant
func OperationSchema ¶
func OperationSchema[T any]() (json.RawMessage, types.OperationRef[T])
OperationSchema reflects an operation config type and returns both the JSON schema and a typed operation ref whose name is derived from the schema definition key
func RawEnvelope ¶
func RawEnvelope(resource string, payload json.RawMessage) types.MappingEnvelope
RawEnvelope wraps an already-serialized provider payload in a mapping envelope
func RawEnvelopeVariant ¶
func RawEnvelopeVariant(variant string, resource string, payload json.RawMessage) types.MappingEnvelope
RawEnvelopeVariant wraps an already-serialized provider payload in a variant-specific mapping envelope
func SchemaFrom ¶
func SchemaFrom[T any]() json.RawMessage
SchemaFrom reflects a JSON schema from a Go type and returns it as raw JSON
func SchemaID ¶
func SchemaID(schema json.RawMessage) string
SchemaID extracts the definition key from a reflected JSON schema's $ref path
func StaticHandler ¶
func StaticHandler(run func() (json.RawMessage, error)) types.OperationHandler
StaticHandler wraps a function that needs no context or request into an OperationHandler
func WebhookEventSchema ¶
func WebhookEventSchema[T any]() (json.RawMessage, types.WebhookEventRef[T])
WebhookEventSchema reflects a webhook event payload type and returns both the JSON schema and a typed webhook event ref whose name is derived from the schema definition key
func WithClient ¶
func WithClient[C, R any](ref types.ClientRef[C], run func(context.Context, C) (R, error)) func(context.Context, types.OperationRequest) (R, error)
WithClient adapts a typed client-backed function to a request handler with an ugly signature but saves the call sites
func WithClientConfig ¶
func WithClientConfig[C, Config, R any](ref types.ClientRef[C], op types.OperationRef[Config], configErr error, run func(context.Context, C, Config) (R, error)) func(context.Context, types.OperationRequest) (R, error)
WithClientConfig adapts a typed client-backed function that also decodes typed config
func WithClientRequest ¶
func WithClientRequest[C, R any](ref types.ClientRef[C], run func(context.Context, types.OperationRequest, C) (R, error)) func(context.Context, types.OperationRequest) (R, error)
WithClientRequest adapts a typed client-backed function + takes the full operation request (also ugly, but good for call sites)
func WithClientRequestConfig ¶
func WithClientRequestConfig[C, Config, R any](ref types.ClientRef[C], op types.OperationRef[Config], configErr error, run func(context.Context, types.OperationRequest, C, Config) (R, error)) func(context.Context, types.OperationRequest) (R, error)
WithClientRequestConfig adapts a typed client-backed function that needs the full request and typed config
Types ¶
type CelMapEntry ¶
type CelMapEntry struct {
// Key is the target field name in the mapped output document
Key string
// Expr is the CEL expression that produces the value for Key
Expr string
}
CelMapEntry holds one key-expression pair for building CEL object literal mapping expressions