mutation

package
v0.0.0-...-36d6306 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	// contains filtered or unexported fields
}

Context manages a mutation transaction with automatic cascade event collection. Events are collected during mutations and can be retrieved after commit for publishing. Use WithoutTX() option to skip transaction creation for publish-only mode.

func New

func New(db *sql.DB, opts ...Option) *Context

New creates a new mutation context.

func (*Context) Begin

func (c *Context) Begin(ctx context.Context) error

Begin starts a new transaction. If WithoutTX() was used, this is a no-op.

func (*Context) Commit

func (c *Context) Commit(ctx context.Context) error

Commit commits the transaction and records events for replay (dev only). If a publisher is configured, events are auto-published after successful commit. If WithoutTX() was used, this just publishes events without DB commit. Otherwise, call Events() to get collected events for manual publishing.

func (*Context) DeleteEnvironment

func (c *Context) DeleteEnvironment(ctx context.Context, envID, workspaceID idwrap.IDWrap) error

DeleteEnvironment deletes an environment and collects cascade events for all variables.

func (*Context) DeleteFile

func (c *Context) DeleteFile(ctx context.Context, file FileDeleteItem) error

DeleteFile deletes a file and the content it points to (HTTP/Flow). File -> points to -> Content, so deleting file cascades DOWN to content. This is the PUBLIC entry point for content deletion.

func (*Context) DeleteFileBatch

func (c *Context) DeleteFileBatch(ctx context.Context, items []FileDeleteItem) error

DeleteFileBatch deletes multiple files and their content.

func (*Context) DeleteFlow

func (c *Context) DeleteFlow(ctx context.Context, item FlowDeleteItem) error

DeleteFlow deletes a flow, handling File ownership. If Flow has a File owner, deletion goes through File (which cascades back to Flow). If Flow is orphaned (no File), it's deleted directly. This is the PUBLIC API - safe to call from RPC handlers.

func (*Context) DeleteFlowBatch

func (c *Context) DeleteFlowBatch(ctx context.Context, items []FlowDeleteItem) error

DeleteFlowBatch deletes multiple flows, handling File ownership. Groups items by whether they have File owners for efficient processing.

func (*Context) DeleteGraphQL

func (c *Context) DeleteGraphQL(ctx context.Context, item GraphQLDeleteItem) error

DeleteGraphQL deletes a GraphQL entry and tracks cascade events.

func (*Context) DeleteGraphQLBatch

func (c *Context) DeleteGraphQLBatch(ctx context.Context, items []GraphQLDeleteItem) error

DeleteGraphQLBatch deletes multiple GraphQL entries.

func (*Context) DeleteHTTP

func (c *Context) DeleteHTTP(ctx context.Context, item HTTPDeleteItem) error

DeleteHTTP deletes an HTTP entry, handling File ownership. If HTTP has a File owner, deletion goes through File (which cascades back to HTTP). If HTTP is orphaned (no File), it's deleted directly. This is the PUBLIC API - safe to call from RPC handlers.

func (*Context) DeleteHTTPBatch

func (c *Context) DeleteHTTPBatch(ctx context.Context, items []HTTPDeleteItem) error

DeleteHTTPBatch deletes multiple HTTP entries, handling File ownership. Groups items by whether they have File owners for efficient processing.

func (*Context) DeleteWorkspace

func (c *Context) DeleteWorkspace(ctx context.Context, workspaceID idwrap.IDWrap) error

DeleteWorkspace deletes a workspace and collects cascade events for all children. This is a deep cascade - collects events for HTTP children, Flow children, etc. Files have FK to workspace so DB CASCADE handles them.

func (*Context) Events

func (c *Context) Events() []Event

Events returns all collected events for publishing. Call this after Commit() to get events to publish.

func (*Context) InsertCredential

func (c *Context) InsertCredential(ctx context.Context, item CredentialInsertItem) error

InsertCredential inserts a credential and tracks the event.

func (*Context) InsertCredentialBatch

func (c *Context) InsertCredentialBatch(ctx context.Context, items []CredentialInsertItem) error

InsertCredentialBatch inserts multiple credentials.

func (*Context) InsertGraphQL

func (c *Context) InsertGraphQL(ctx context.Context, item GraphQLInsertItem) error

InsertGraphQL inserts a GraphQL entry and tracks the event.

func (*Context) InsertGraphQLAssert

func (c *Context) InsertGraphQLAssert(ctx context.Context, item GraphQLAssertInsertItem) error

InsertGraphQLAssert inserts a GraphQL assert and tracks the event.

func (*Context) InsertGraphQLAssertBatch

func (c *Context) InsertGraphQLAssertBatch(ctx context.Context, items []GraphQLAssertInsertItem) error

InsertGraphQLAssertBatch inserts multiple GraphQL asserts.

func (*Context) InsertGraphQLBatch

func (c *Context) InsertGraphQLBatch(ctx context.Context, items []GraphQLInsertItem) error

InsertGraphQLBatch inserts multiple GraphQL entries.

func (*Context) InsertHTTP

func (c *Context) InsertHTTP(ctx context.Context, item HTTPInsertItem) error

InsertHTTP inserts an HTTP entry and tracks the event.

func (*Context) InsertHTTPAssert

func (c *Context) InsertHTTPAssert(ctx context.Context, item HTTPAssertInsertItem) error

InsertHTTPAssert inserts an HTTP assert and tracks the event.

func (*Context) InsertHTTPAssertBatch

func (c *Context) InsertHTTPAssertBatch(ctx context.Context, items []HTTPAssertInsertItem) error

InsertHTTPAssertBatch inserts multiple HTTP asserts.

func (*Context) InsertHTTPBatch

func (c *Context) InsertHTTPBatch(ctx context.Context, items []HTTPInsertItem) error

InsertHTTPBatch inserts multiple HTTP entries.

func (*Context) InsertHTTPBodyForm

func (c *Context) InsertHTTPBodyForm(ctx context.Context, item HTTPBodyFormInsertItem) error

InsertHTTPBodyForm inserts an HTTP body form and tracks the event.

func (*Context) InsertHTTPBodyFormBatch

func (c *Context) InsertHTTPBodyFormBatch(ctx context.Context, items []HTTPBodyFormInsertItem) error

InsertHTTPBodyFormBatch inserts multiple HTTP body forms.

func (*Context) InsertHTTPBodyRaw

func (c *Context) InsertHTTPBodyRaw(ctx context.Context, item HTTPBodyRawInsertItem) error

InsertHTTPBodyRaw inserts an HTTP body raw and tracks the event.

func (*Context) InsertHTTPBodyRawBatch

func (c *Context) InsertHTTPBodyRawBatch(ctx context.Context, items []HTTPBodyRawInsertItem) error

InsertHTTPBodyRawBatch inserts multiple HTTP body raw items.

func (*Context) InsertHTTPBodyUrlEncoded

func (c *Context) InsertHTTPBodyUrlEncoded(ctx context.Context, item HTTPBodyUrlEncodedInsertItem) error

InsertHTTPBodyUrlEncoded inserts an HTTP body URL encoded and tracks the event.

func (*Context) InsertHTTPBodyUrlEncodedBatch

func (c *Context) InsertHTTPBodyUrlEncodedBatch(ctx context.Context, items []HTTPBodyUrlEncodedInsertItem) error

InsertHTTPBodyUrlEncodedBatch inserts multiple HTTP body URL encoded items.

func (*Context) InsertHTTPHeader

func (c *Context) InsertHTTPHeader(ctx context.Context, item HTTPHeaderInsertItem) error

InsertHTTPHeader inserts an HTTP header and tracks the event.

func (*Context) InsertHTTPHeaderBatch

func (c *Context) InsertHTTPHeaderBatch(ctx context.Context, items []HTTPHeaderInsertItem) error

InsertHTTPHeaderBatch inserts multiple HTTP headers.

func (*Context) InsertHTTPSearchParam

func (c *Context) InsertHTTPSearchParam(ctx context.Context, item HTTPSearchParamInsertItem) error

InsertHTTPSearchParam inserts an HTTP search param and tracks the event.

func (*Context) InsertHTTPSearchParamBatch

func (c *Context) InsertHTTPSearchParamBatch(ctx context.Context, items []HTTPSearchParamInsertItem) error

InsertHTTPSearchParamBatch inserts multiple HTTP search params.

func (*Context) IsTxFree

func (c *Context) IsTxFree() bool

IsTxFree returns true if the context is in TX-free mode.

func (*Context) Publish

func (c *Context) Publish()

Publish immediately publishes all tracked events without commit. Useful in TX-free mode for explicit publish timing.

func (*Context) Queries

func (c *Context) Queries() *gen.Queries

Queries returns the sqlc queries bound to the transaction. Returns nil in TX-free mode.

func (*Context) Reset

func (c *Context) Reset()

Reset clears collected events (useful for reuse).

func (*Context) Rollback

func (c *Context) Rollback()

Rollback aborts the transaction. If WithoutTX() was used, this just clears collected events.

func (*Context) TX

func (c *Context) TX() *sql.Tx

TX returns the underlying transaction. Returns nil in TX-free mode.

func (*Context) Track

func (c *Context) Track(evt Event)

Track adds an event to the collection (public API for leaf entities). Use this for entities without cascade children (headers, params, etc.).

func (*Context) UpdateGraphQL

func (c *Context) UpdateGraphQL(ctx context.Context, item GraphQLUpdateItem) error

UpdateGraphQL updates a GraphQL entry and tracks the event.

func (*Context) UpdateGraphQLAssert

func (c *Context) UpdateGraphQLAssert(ctx context.Context, item GraphQLAssertUpdateItem) error

UpdateGraphQLAssert updates a GraphQL assert and tracks the event.

func (*Context) UpdateGraphQLAssertBatch

func (c *Context) UpdateGraphQLAssertBatch(ctx context.Context, items []GraphQLAssertUpdateItem) error

UpdateGraphQLAssertBatch updates multiple GraphQL asserts.

func (*Context) UpdateGraphQLAssertDelta

func (c *Context) UpdateGraphQLAssertDelta(ctx context.Context, item GraphQLAssertDeltaUpdateItem) error

UpdateGraphQLAssertDelta updates a GraphQL assert delta and tracks the event.

func (*Context) UpdateGraphQLAssertDeltaBatch

func (c *Context) UpdateGraphQLAssertDeltaBatch(ctx context.Context, items []GraphQLAssertDeltaUpdateItem) error

UpdateGraphQLAssertDeltaBatch updates multiple GraphQL assert deltas.

func (*Context) UpdateGraphQLBatch

func (c *Context) UpdateGraphQLBatch(ctx context.Context, items []GraphQLUpdateItem) error

UpdateGraphQLBatch updates multiple GraphQL entries.

func (*Context) UpdateHTTP

func (c *Context) UpdateHTTP(ctx context.Context, item HTTPUpdateItem) (*HTTPUpdateResult, error)

UpdateHTTP updates an HTTP entry, tracking events. Versions are only created by HttpRun, which includes full snapshot data.

func (*Context) UpdateHTTPAssert

func (c *Context) UpdateHTTPAssert(ctx context.Context, item HTTPAssertUpdateItem) error

UpdateHTTPAssert updates an HTTP assert and tracks the event.

func (*Context) UpdateHTTPAssertBatch

func (c *Context) UpdateHTTPAssertBatch(ctx context.Context, items []HTTPAssertUpdateItem) error

UpdateHTTPAssertBatch updates multiple HTTP asserts.

func (*Context) UpdateHTTPAssertDelta

func (c *Context) UpdateHTTPAssertDelta(ctx context.Context, item HTTPAssertDeltaUpdateItem) error

UpdateHTTPAssertDelta updates an HTTP assert delta and tracks the event.

func (*Context) UpdateHTTPAssertDeltaBatch

func (c *Context) UpdateHTTPAssertDeltaBatch(ctx context.Context, items []HTTPAssertDeltaUpdateItem) error

UpdateHTTPAssertDeltaBatch updates multiple HTTP assert deltas.

func (*Context) UpdateHTTPBatch

func (c *Context) UpdateHTTPBatch(ctx context.Context, items []HTTPUpdateItem) ([]HTTPUpdateResult, error)

UpdateHTTPBatch updates multiple HTTP entries.

func (*Context) UpdateHTTPBodyForm

func (c *Context) UpdateHTTPBodyForm(ctx context.Context, item HTTPBodyFormUpdateItem) error

UpdateHTTPBodyForm updates an HTTP body form and tracks the event.

func (*Context) UpdateHTTPBodyFormBatch

func (c *Context) UpdateHTTPBodyFormBatch(ctx context.Context, items []HTTPBodyFormUpdateItem) error

UpdateHTTPBodyFormBatch updates multiple HTTP body forms.

func (*Context) UpdateHTTPBodyFormDelta

func (c *Context) UpdateHTTPBodyFormDelta(ctx context.Context, item HTTPBodyFormDeltaUpdateItem) error

UpdateHTTPBodyFormDelta updates an HTTP body form delta and tracks the event.

func (*Context) UpdateHTTPBodyFormDeltaBatch

func (c *Context) UpdateHTTPBodyFormDeltaBatch(ctx context.Context, items []HTTPBodyFormDeltaUpdateItem) error

UpdateHTTPBodyFormDeltaBatch updates multiple HTTP body form deltas.

func (*Context) UpdateHTTPBodyRaw

func (c *Context) UpdateHTTPBodyRaw(ctx context.Context, item HTTPBodyRawUpdateItem) error

UpdateHTTPBodyRaw updates an HTTP body raw and tracks the event.

func (*Context) UpdateHTTPBodyRawBatch

func (c *Context) UpdateHTTPBodyRawBatch(ctx context.Context, items []HTTPBodyRawUpdateItem) error

UpdateHTTPBodyRawBatch updates multiple HTTP body raw items.

func (*Context) UpdateHTTPBodyRawDelta

func (c *Context) UpdateHTTPBodyRawDelta(ctx context.Context, item HTTPBodyRawDeltaUpdateItem) error

UpdateHTTPBodyRawDelta updates an HTTP body raw delta and tracks the event.

func (*Context) UpdateHTTPBodyRawDeltaBatch

func (c *Context) UpdateHTTPBodyRawDeltaBatch(ctx context.Context, items []HTTPBodyRawDeltaUpdateItem) error

UpdateHTTPBodyRawDeltaBatch updates multiple HTTP body raw deltas.

func (*Context) UpdateHTTPBodyUrlEncoded

func (c *Context) UpdateHTTPBodyUrlEncoded(ctx context.Context, item HTTPBodyUrlEncodedUpdateItem) error

UpdateHTTPBodyUrlEncoded updates an HTTP body URL encoded and tracks the event.

func (*Context) UpdateHTTPBodyUrlEncodedBatch

func (c *Context) UpdateHTTPBodyUrlEncodedBatch(ctx context.Context, items []HTTPBodyUrlEncodedUpdateItem) error

UpdateHTTPBodyUrlEncodedBatch updates multiple HTTP body URL encoded items.

func (*Context) UpdateHTTPBodyUrlEncodedDelta

func (c *Context) UpdateHTTPBodyUrlEncodedDelta(ctx context.Context, item HTTPBodyUrlEncodedDeltaUpdateItem) error

UpdateHTTPBodyUrlEncodedDelta updates an HTTP body URL encoded delta and tracks the event.

func (*Context) UpdateHTTPBodyUrlEncodedDeltaBatch

func (c *Context) UpdateHTTPBodyUrlEncodedDeltaBatch(ctx context.Context, items []HTTPBodyUrlEncodedDeltaUpdateItem) error

UpdateHTTPBodyUrlEncodedDeltaBatch updates multiple HTTP body URL encoded deltas.

func (*Context) UpdateHTTPHeader

func (c *Context) UpdateHTTPHeader(ctx context.Context, item HTTPHeaderUpdateItem) error

UpdateHTTPHeader updates an HTTP header and tracks the event.

func (*Context) UpdateHTTPHeaderBatch

func (c *Context) UpdateHTTPHeaderBatch(ctx context.Context, items []HTTPHeaderUpdateItem) error

UpdateHTTPHeaderBatch updates multiple HTTP headers.

func (*Context) UpdateHTTPHeaderDelta

func (c *Context) UpdateHTTPHeaderDelta(ctx context.Context, item HTTPHeaderDeltaUpdateItem) error

UpdateHTTPHeaderDelta updates an HTTP header delta and tracks the event.

func (*Context) UpdateHTTPHeaderDeltaBatch

func (c *Context) UpdateHTTPHeaderDeltaBatch(ctx context.Context, items []HTTPHeaderDeltaUpdateItem) error

UpdateHTTPHeaderDeltaBatch updates multiple HTTP header deltas.

func (*Context) UpdateHTTPSearchParam

func (c *Context) UpdateHTTPSearchParam(ctx context.Context, item HTTPSearchParamUpdateItem) error

UpdateHTTPSearchParam updates an HTTP search param and tracks the event.

func (*Context) UpdateHTTPSearchParamBatch

func (c *Context) UpdateHTTPSearchParamBatch(ctx context.Context, items []HTTPSearchParamUpdateItem) error

UpdateHTTPSearchParamBatch updates multiple HTTP search params.

func (*Context) UpdateHTTPSearchParamDelta

func (c *Context) UpdateHTTPSearchParamDelta(ctx context.Context, item HTTPSearchParamDeltaUpdateItem) error

UpdateHTTPSearchParamDelta updates an HTTP search param delta and tracks the event.

func (*Context) UpdateHTTPSearchParamDeltaBatch

func (c *Context) UpdateHTTPSearchParamDeltaBatch(ctx context.Context, items []HTTPSearchParamDeltaUpdateItem) error

UpdateHTTPSearchParamDeltaBatch updates multiple HTTP search param deltas.

func (*Context) UpdateLastEventPayload

func (c *Context) UpdateLastEventPayload(payload any)

UpdateLastEventPayload updates the payload of the most recently tracked event.

type CredentialInsertItem

type CredentialInsertItem struct {
	Credential  *mcredential.Credential
	WorkspaceID idwrap.IDWrap
}

CredentialInsertItem represents a credential to insert.

type EntityType

type EntityType uint16

EntityType identifies the type of entity being mutated. Using uint16 for compact storage and no string comparisons at runtime.

const (
	// Workspace entities
	EntityWorkspace EntityType = iota
	EntityWorkspaceUser
	EntityEnvironment
	EntityEnvironmentValue
	EntityTag

	// HTTP entities
	EntityHTTP
	EntityHTTPHeader
	EntityHTTPParam
	EntityHTTPBodyForm
	EntityHTTPBodyURL
	EntityHTTPBodyRaw
	EntityHTTPAssert
	EntityHTTPResponse
	EntityHTTPResponseHeader
	EntityHTTPResponseAssert
	EntityHTTPVersion

	// Flow entities
	EntityFlow
	EntityFlowNode
	EntityFlowNodeHTTP
	EntityFlowNodeFor
	EntityFlowNodeForEach
	EntityFlowNodeCondition
	EntityFlowNodeJS
	EntityFlowNodeAI
	EntityFlowNodeAiProvider
	EntityFlowNodeMemory
	EntityFlowNodeGraphQL
	EntityFlowNodeWsConnection
	EntityFlowNodeWsSend
	EntityFlowNodeWait
	EntityFlowNodeSubFlowTrigger
	EntityFlowNodeSubFlowReturn
	EntityFlowNodeRunSubFlow
	EntityFlowEdge
	EntityFlowVariable
	EntityFlowTag

	// File system
	EntityFile

	// Credential entities
	EntityCredential

	// GraphQL entities
	EntityGraphQL
	EntityGraphQLHeader
	EntityGraphQLAssert
	EntityGraphQLResponse
	EntityGraphQLResponseHeader
	EntityGraphQLResponseAssert
)

type Event

type Event struct {
	Entity      EntityType
	Op          Operation
	ID          idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	ParentID    idwrap.IDWrap // For child entities - the parent ID (e.g., FlowID for nodes/edges/variables)
	IsDelta     bool
	Payload     any // For insert/update - the entity data
	Patch       any // For update - the changed fields
}

Event represents a single mutation event. Events are collected during a mutation transaction and published on commit.

type FileDeleteItem

type FileDeleteItem struct {
	ID          idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	ContentID   *idwrap.IDWrap
	ContentKind mfile.ContentType
}

FileDeleteItem represents a file to delete with its context.

type FlowDeleteItem

type FlowDeleteItem struct {
	ID          idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
}

FlowDeleteItem represents a flow to delete with its context.

type GraphQLAssertDeltaUpdateItem

type GraphQLAssertDeltaUpdateItem struct {
	ID          idwrap.IDWrap
	GraphQLID   idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	Params      gen.UpdateGraphQLAssertDeltaParams
	Patch       any
	Payload     any
}

GraphQLAssertDeltaUpdateItem represents a GraphQL assert delta to update.

type GraphQLAssertInsertItem

type GraphQLAssertInsertItem struct {
	ID          idwrap.IDWrap
	GraphQLID   idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	IsDelta     bool
	Params      gen.CreateGraphQLAssertParams
}

GraphQLAssertInsertItem represents a GraphQL assert to insert.

type GraphQLAssertUpdateItem

type GraphQLAssertUpdateItem struct {
	ID          idwrap.IDWrap
	GraphQLID   idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	IsDelta     bool
	Params      gen.UpdateGraphQLAssertParams
	Patch       patch.GraphQLAssertPatch
}

GraphQLAssertUpdateItem represents a GraphQL assert to update.

type GraphQLDeleteItem

type GraphQLDeleteItem struct {
	ID          idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
}

GraphQLDeleteItem represents a GraphQL entry to delete.

type GraphQLInsertItem

type GraphQLInsertItem struct {
	GraphQL     *mgraphql.GraphQL
	WorkspaceID idwrap.IDWrap
}

GraphQLInsertItem represents a GraphQL entry to insert.

type GraphQLUpdateItem

type GraphQLUpdateItem struct {
	GraphQL     *mgraphql.GraphQL
	WorkspaceID idwrap.IDWrap
}

GraphQLUpdateItem represents a GraphQL entry to update.

type HTTPAssertDeltaUpdateItem

type HTTPAssertDeltaUpdateItem struct {
	ID          idwrap.IDWrap
	HttpID      idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	Params      gen.UpdateHTTPAssertDeltaParams
	Patch       any
	Payload     any
}

HTTPAssertDeltaUpdateItem represents an HTTP assert delta to update.

type HTTPAssertInsertItem

type HTTPAssertInsertItem struct {
	ID          idwrap.IDWrap
	HttpID      idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	IsDelta     bool
	Params      gen.CreateHTTPAssertParams
}

HTTPAssertInsertItem represents an HTTP assert to insert.

type HTTPAssertUpdateItem

type HTTPAssertUpdateItem struct {
	ID          idwrap.IDWrap
	HttpID      idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	IsDelta     bool
	Params      gen.UpdateHTTPAssertParams
	Patch       any
	Payload     any
}

HTTPAssertUpdateItem represents an HTTP assert to update.

type HTTPBodyFormDeltaUpdateItem

type HTTPBodyFormDeltaUpdateItem struct {
	ID          idwrap.IDWrap
	HttpID      idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	Params      gen.UpdateHTTPBodyFormDeltaParams
	Patch       any
	Payload     any
}

HTTPBodyFormDeltaUpdateItem represents an HTTP body form delta to update.

type HTTPBodyFormInsertItem

type HTTPBodyFormInsertItem struct {
	ID          idwrap.IDWrap
	HttpID      idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	IsDelta     bool
	Params      gen.CreateHTTPBodyFormParams
}

HTTPBodyFormInsertItem represents an HTTP body form to insert.

type HTTPBodyFormUpdateItem

type HTTPBodyFormUpdateItem struct {
	ID          idwrap.IDWrap
	HttpID      idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	IsDelta     bool
	Params      gen.UpdateHTTPBodyFormParams
	Patch       any
	Payload     any
}

HTTPBodyFormUpdateItem represents an HTTP body form to update.

type HTTPBodyRawDeltaUpdateItem

type HTTPBodyRawDeltaUpdateItem struct {
	ID          idwrap.IDWrap
	HttpID      idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	Params      gen.UpdateHTTPBodyRawDeltaParams
	Patch       any
	Payload     any
}

HTTPBodyRawDeltaUpdateItem represents an HTTP body raw delta to update.

type HTTPBodyRawInsertItem

type HTTPBodyRawInsertItem struct {
	ID          idwrap.IDWrap
	HttpID      idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	IsDelta     bool
	Params      gen.CreateHTTPBodyRawParams
}

HTTPBodyRawInsertItem represents an HTTP body raw to insert.

type HTTPBodyRawUpdateItem

type HTTPBodyRawUpdateItem struct {
	ID          idwrap.IDWrap
	HttpID      idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	IsDelta     bool
	Params      gen.UpdateHTTPBodyRawParams
	Patch       any
	Payload     any
}

HTTPBodyRawUpdateItem represents an HTTP body raw to update.

type HTTPBodyUrlEncodedDeltaUpdateItem

type HTTPBodyUrlEncodedDeltaUpdateItem struct {
	ID          idwrap.IDWrap
	HttpID      idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	Params      gen.UpdateHTTPBodyUrlEncodedDeltaParams
	Patch       any
	Payload     any
}

HTTPBodyUrlEncodedDeltaUpdateItem represents an HTTP body URL encoded delta to update.

type HTTPBodyUrlEncodedInsertItem

type HTTPBodyUrlEncodedInsertItem struct {
	ID          idwrap.IDWrap
	HttpID      idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	IsDelta     bool
	Params      gen.CreateHTTPBodyUrlEncodedParams
}

HTTPBodyUrlEncodedInsertItem represents an HTTP body URL encoded to insert.

type HTTPBodyUrlEncodedUpdateItem

type HTTPBodyUrlEncodedUpdateItem struct {
	ID          idwrap.IDWrap
	HttpID      idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	IsDelta     bool
	Params      gen.UpdateHTTPBodyUrlEncodedParams
	Patch       any
	Payload     any
}

HTTPBodyUrlEncodedUpdateItem represents an HTTP body URL encoded to update.

type HTTPDeleteItem

type HTTPDeleteItem struct {
	ID          idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	IsDelta     bool
}

HTTPDeleteItem represents an HTTP entry to delete with its context.

type HTTPHeaderDeltaUpdateItem

type HTTPHeaderDeltaUpdateItem struct {
	ID          idwrap.IDWrap
	HttpID      idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	Params      gen.UpdateHTTPHeaderDeltaParams
	Patch       any
	Payload     any
}

HTTPHeaderDeltaUpdateItem represents an HTTP header delta to update.

type HTTPHeaderInsertItem

type HTTPHeaderInsertItem struct {
	ID          idwrap.IDWrap
	HttpID      idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	IsDelta     bool
	Params      gen.CreateHTTPHeaderParams
}

HTTPHeaderInsertItem represents an HTTP header to insert.

type HTTPHeaderUpdateItem

type HTTPHeaderUpdateItem struct {
	ID          idwrap.IDWrap
	HttpID      idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	IsDelta     bool
	Params      gen.UpdateHTTPHeaderParams
	Patch       any
	Payload     any
}

HTTPHeaderUpdateItem represents an HTTP header to update.

type HTTPInsertItem

type HTTPInsertItem struct {
	HTTP        *mhttp.HTTP   // The HTTP model to insert
	WorkspaceID idwrap.IDWrap // For event routing
	IsDelta     bool          // Whether this is a delta HTTP
}

HTTPInsertItem represents an HTTP entry to insert.

type HTTPSearchParamDeltaUpdateItem

type HTTPSearchParamDeltaUpdateItem struct {
	ID          idwrap.IDWrap
	HttpID      idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	Params      gen.UpdateHTTPSearchParamDeltaParams
	Patch       any
	Payload     any
}

HTTPSearchParamDeltaUpdateItem represents an HTTP search param delta to update.

type HTTPSearchParamInsertItem

type HTTPSearchParamInsertItem struct {
	ID          idwrap.IDWrap
	HttpID      idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	IsDelta     bool
	Params      gen.CreateHTTPSearchParamParams
}

HTTPSearchParamInsertItem represents an HTTP search param to insert.

type HTTPSearchParamUpdateItem

type HTTPSearchParamUpdateItem struct {
	ID          idwrap.IDWrap
	HttpID      idwrap.IDWrap
	WorkspaceID idwrap.IDWrap
	IsDelta     bool
	Params      gen.UpdateHTTPSearchParamParams
	Patch       any
	Payload     any
}

HTTPSearchParamUpdateItem represents an HTTP search param to update.

type HTTPUpdateItem

type HTTPUpdateItem struct {
	HTTP        *mhttp.HTTP   // The HTTP model with updated fields
	WorkspaceID idwrap.IDWrap // For event routing
	IsDelta     bool          // Whether this is a delta update
	Patch       any           // The patch object for sync (e.g., patch.HTTPDeltaPatch)
	UserID      idwrap.IDWrap // Kept for compatibility
}

HTTPUpdateItem represents an HTTP entry to update with its context.

type HTTPUpdateResult

type HTTPUpdateResult struct {
	HTTP mhttp.HTTP
}

HTTPUpdateResult contains the result of an HTTP update.

type MultiPublisher

type MultiPublisher []Publisher

MultiPublisher fans an event slice out to several publishers in order. Each underlying publisher's switch typically ignores entity types it doesn't handle, so combining domain-specific publishers (flow + http + graphql, …) just works without a central dispatch table.

func (MultiPublisher) PublishAll

func (m MultiPublisher) PublishAll(events []Event)

PublishAll forwards events to every publisher in the slice.

type Operation

type Operation uint8

Operation identifies the type of mutation.

const (
	OpInsert Operation = iota
	OpUpdate
	OpDelete
)

func (Operation) String

func (o Operation) String() string

String returns the string representation of the operation. Used for event type in sync streaming ("insert", "update", "delete").

type Option

type Option func(*Context)

Option configures a Context.

func WithPublisher

func WithPublisher(p Publisher) Option

WithPublisher sets the publisher for auto-publishing events after commit.

func WithoutTX

func WithoutTX() Option

WithoutTX configures the context to skip transaction creation. In this mode, Begin() is a no-op and Commit() just publishes events without DB commit. Use this for high-frequency operations where TX overhead is too expensive.

type Publisher

type Publisher interface {
	// PublishAll publishes all events after a successful commit.
	// Called automatically by Context.Commit() if a publisher is configured.
	PublishAll(events []Event)
}

Publisher handles automatic event publishing after commit. Implementations route events to the appropriate streamers based on entity type.

type Recorder

type Recorder interface {
	Record(events []Event) error
}

Recorder interface for event recording. In production builds, this is a no-op.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL