// Code generated by protoc-gen-go_temporal. DO NOT EDIT.
// versions:
//
//	protoc-gen-go_temporal dev (latest)
//	protoc (unknown)
//
// source: example/shoppingcart/v1/shoppingcart.proto
package shoppingcartv1

import (
	"bytes"
	"context"
	"encoding/json"
	"errors"
	"fmt"
	expression "github.com/cludden/protoc-gen-go-temporal/pkg/expression"
	helpers "github.com/cludden/protoc-gen-go-temporal/pkg/helpers"
	scheme "github.com/cludden/protoc-gen-go-temporal/pkg/scheme"
	testutil "github.com/cludden/protoc-gen-go-temporal/pkg/testutil"
	uuid "github.com/google/uuid"
	gohomedir "github.com/mitchellh/go-homedir"
	v2 "github.com/urfave/cli/v2"
	enumsv1 "go.temporal.io/api/enums/v1"
	serviceerror "go.temporal.io/api/serviceerror"
	client "go.temporal.io/sdk/client"
	converter "go.temporal.io/sdk/converter"
	temporal "go.temporal.io/sdk/temporal"
	testsuite "go.temporal.io/sdk/testsuite"
	worker "go.temporal.io/sdk/worker"
	workflow "go.temporal.io/sdk/workflow"
	protojson "google.golang.org/protobuf/encoding/protojson"
	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
	"log/slog"
	"os"
	"sort"
	"strings"
	"sync"
	"sync/atomic"
	"time"
)

// ShoppingCartTaskQueue is the default task-queue for a example.shoppingcart.v1.ShoppingCart worker
var ShoppingCartTaskQueue = "example-shoppingcart-v1"

// example.shoppingcart.v1.ShoppingCart workflow names
const (
	ShoppingCartWorkflowName = "example.shoppingcart.v1.ShoppingCart"
)

// example.shoppingcart.v1.ShoppingCart workflow id expressions
var (
	ShoppingCartIdexpression = expression.MustParseExpression("example.shoppingcart.v1.ShoppingCart/${! nanoid() }")
)

// example.shoppingcart.v1.ShoppingCart query names
const (
	DescribeQueryName = "example.shoppingcart.v1.ShoppingCart.Describe"
)

// example.shoppingcart.v1.ShoppingCart signal names
const (
	CheckoutSignalName = "example.shoppingcart.v1.ShoppingCart.Checkout"
)

// example.shoppingcart.v1.ShoppingCart update names
const (
	UpdateCartUpdateName = "example.shoppingcart.v1.ShoppingCart.UpdateCart"
)

// example.shoppingcart.v1.ShoppingCart update id expressions
var (
	UpdateCartIdexpression = expression.MustParseExpression("example.shoppingcart.v1.UpdateCart/${! nanoid() }")
)

// ShoppingCartClient describes a client for a(n) example.shoppingcart.v1.ShoppingCart worker
type ShoppingCartClient interface {
	// ShoppingCart executes a(n) example.shoppingcart.v1.ShoppingCart workflow and blocks until error or response received
	ShoppingCart(ctx context.Context, req *ShoppingCartInput, opts ...*ShoppingCartOptions) (*ShoppingCartOutput, error)

	// ShoppingCartAsync starts a(n) example.shoppingcart.v1.ShoppingCart workflow and returns a handle to the workflow run
	ShoppingCartAsync(ctx context.Context, req *ShoppingCartInput, opts ...*ShoppingCartOptions) (ShoppingCartRun, error)

	// GetShoppingCart retrieves a handle to an existing example.shoppingcart.v1.ShoppingCart workflow execution
	GetShoppingCart(ctx context.Context, workflowID string, runID string) ShoppingCartRun

	// ShoppingCartWithUpdateCart executes a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart update on a(n) example.shoppingcart.v1.ShoppingCart workflow, starting it if necessary, and blocks until update completion
	ShoppingCartWithUpdateCart(ctx context.Context, req *ShoppingCartInput, update *UpdateCartInput, opts ...*ShoppingCartWithUpdateCartOptions) (*UpdateCartOutput, ShoppingCartRun, error)
	// ShoppingCartWithUpdateCartAsync starts a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart update on a(n) example.shoppingcart.v1.ShoppingCart workflow, starting it if necessary, and returns a handle to the update execution
	ShoppingCartWithUpdateCartAsync(ctx context.Context, req *ShoppingCartInput, update *UpdateCartInput, opts ...*ShoppingCartWithUpdateCartOptions) (UpdateCartHandle, ShoppingCartRun, error)
	// CancelWorkflow requests cancellation of an existing workflow execution
	CancelWorkflow(ctx context.Context, workflowID string, runID string) error

	// TerminateWorkflow an existing workflow execution
	TerminateWorkflow(ctx context.Context, workflowID string, runID string, reason string, details ...interface{}) error

	// example.shoppingcart.v1.ShoppingCart.Describe executes a(n) example.shoppingcart.v1.ShoppingCart.Describe query
	Describe(ctx context.Context, workflowID string, runID string, query *DescribeInput) (*DescribeOutput, error)

	// example.shoppingcart.v1.ShoppingCart.Checkout sends a(n) example.shoppingcart.v1.ShoppingCart.Checkout signal
	Checkout(ctx context.Context, workflowID string, runID string, signal *CheckoutInput) error

	// UpdateCart executes a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart update and blocks until update completion
	UpdateCart(ctx context.Context, workflowID string, runID string, req *UpdateCartInput, opts ...*UpdateCartOptions) (*UpdateCartOutput, error)

	// UpdateCartAsync starts a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart update and returns a handle to the workflow update
	UpdateCartAsync(ctx context.Context, workflowID string, runID string, req *UpdateCartInput, opts ...*UpdateCartOptions) (UpdateCartHandle, error)

	// GetUpdateCart retrieves a handle to an existing example.shoppingcart.v1.ShoppingCart.UpdateCart update
	GetUpdateCart(ctx context.Context, req client.GetWorkflowUpdateHandleOptions) (UpdateCartHandle, error)
}

// shoppingCartClient implements a temporal client for a example.shoppingcart.v1.ShoppingCart service
type shoppingCartClient struct {
	client client.Client
	log    *slog.Logger
}

// NewShoppingCartClient initializes a new example.shoppingcart.v1.ShoppingCart client
func NewShoppingCartClient(c client.Client, options ...*shoppingCartClientOptions) ShoppingCartClient {
	var cfg *shoppingCartClientOptions
	if len(options) > 0 {
		cfg = options[0]
	} else {
		cfg = NewShoppingCartClientOptions()
	}
	return &shoppingCartClient{
		client: c,
		log:    cfg.getLogger(),
	}
}

// NewShoppingCartClientWithOptions initializes a new ShoppingCart client with the given options
func NewShoppingCartClientWithOptions(c client.Client, opts client.Options, options ...*shoppingCartClientOptions) (ShoppingCartClient, error) {
	var err error
	c, err = client.NewClientFromExisting(c, opts)
	if err != nil {
		return nil, fmt.Errorf("error initializing client with options: %w", err)
	}
	var cfg *shoppingCartClientOptions
	if len(options) > 0 {
		cfg = options[0]
	} else {
		cfg = NewShoppingCartClientOptions()
	}
	return &shoppingCartClient{
		client: c,
		log:    cfg.getLogger(),
	}, nil
}

// shoppingCartClientOptions describes optional runtime configuration for a ShoppingCartClient
type shoppingCartClientOptions struct {
	log *slog.Logger
}

// NewShoppingCartClientOptions initializes a new shoppingCartClientOptions value
func NewShoppingCartClientOptions() *shoppingCartClientOptions {
	return &shoppingCartClientOptions{}
}

// WithLogger can be used to override the default logger
func (opts *shoppingCartClientOptions) WithLogger(l *slog.Logger) *shoppingCartClientOptions {
	if l != nil {
		opts.log = l
	}
	return opts
}

// getLogger returns the configured logger, or the default logger
func (opts *shoppingCartClientOptions) getLogger() *slog.Logger {
	if opts != nil && opts.log != nil {
		return opts.log
	}
	return slog.Default()
}

// example.shoppingcart.v1.ShoppingCart.ShoppingCart executes a example.shoppingcart.v1.ShoppingCart workflow and blocks until error or response received
func (c *shoppingCartClient) ShoppingCart(ctx context.Context, req *ShoppingCartInput, options ...*ShoppingCartOptions) (*ShoppingCartOutput, error) {
	run, err := c.ShoppingCartAsync(ctx, req, options...)
	if err != nil {
		return nil, err
	}
	return run.Get(ctx)
}

// ShoppingCartAsync starts a(n) example.shoppingcart.v1.ShoppingCart workflow and returns a handle to the workflow run
func (c *shoppingCartClient) ShoppingCartAsync(ctx context.Context, req *ShoppingCartInput, options ...*ShoppingCartOptions) (ShoppingCartRun, error) {
	var o *ShoppingCartOptions
	if len(options) > 0 && options[0] != nil {
		o = options[0]
	} else {
		o = NewShoppingCartOptions()
	}
	opts, err := o.Build(req.ProtoReflect())
	if err != nil {
		return nil, fmt.Errorf("error initializing client.StartWorkflowOptions: %w", err)
	}
	run, err := c.client.ExecuteWorkflow(ctx, opts, ShoppingCartWorkflowName, req)
	if err != nil {
		return nil, err
	}
	if run == nil {
		return nil, errors.New("execute workflow returned nil run")
	}
	return &shoppingCartRun{
		client: c,
		run:    run,
	}, nil
}

// GetShoppingCart fetches an existing example.shoppingcart.v1.ShoppingCart execution
func (c *shoppingCartClient) GetShoppingCart(ctx context.Context, workflowID string, runID string) ShoppingCartRun {
	return &shoppingCartRun{
		client: c,
		run:    c.client.GetWorkflow(ctx, workflowID, runID),
	}
}

// ShoppingCartWithUpdateCartOptions is the options for a example.shoppingcart.v1.ShoppingCart workflow with a example.shoppingcart.v1.ShoppingCart.UpdateCart update
type ShoppingCartWithUpdateCartOptions struct {
	options         client.UpdateWithStartWorkflowOptions
	workflowOptions *ShoppingCartOptions
	updateOptions   *UpdateCartOptions
}

// NewShoppingCartWithUpdateCartOptions initializes a new ShoppingCartWithUpdateCartOptions value
func NewShoppingCartWithUpdateCartOptions() *ShoppingCartWithUpdateCartOptions {
	return &ShoppingCartWithUpdateCartOptions{}
}

// Build transforms ShoppingCartWithUpdateCartOptions into valid client.UpdateWithStartWorkflowOptions
func (o *ShoppingCartWithUpdateCartOptions) Build(ctx context.Context, op func(client.StartWorkflowOptions) client.WithStartWorkflowOperation, input *ShoppingCartInput, update *UpdateCartInput) (options client.UpdateWithStartWorkflowOptions, err error) {
	options = o.options
	if o.workflowOptions == nil {
		o.workflowOptions = NewShoppingCartOptions()
	}
	swo, err := o.workflowOptions.Build(input.ProtoReflect())
	if err != nil {
		return options, err
	}
	if swo.WorkflowIDConflictPolicy == enumsv1.WORKFLOW_ID_CONFLICT_POLICY_UNSPECIFIED {
		swo.WorkflowIDConflictPolicy = enumsv1.WORKFLOW_ID_CONFLICT_POLICY_USE_EXISTING
	}
	options.StartWorkflowOperation = op(swo)
	if o.updateOptions == nil {
		o.updateOptions = NewUpdateCartOptions()
	}
	uo, err := o.updateOptions.Build(swo.ID, "", update)
	if err != nil {
		return options, err
	}
	options.UpdateOptions = *uo
	return options, nil
}

// WithUpdateWithStartWorkflowOptions sets the UpdateWithStartWorkflowOptions
func (o *ShoppingCartWithUpdateCartOptions) WithUpdateWithStartWorkflowOptions(options client.UpdateWithStartWorkflowOptions) *ShoppingCartWithUpdateCartOptions {
	o.options = options
	return o
}

// WithShoppingCartOptions sets the WithShoppingCartOptions
func (o *ShoppingCartWithUpdateCartOptions) WithShoppingCartOptions(options *ShoppingCartOptions) *ShoppingCartWithUpdateCartOptions {
	o.workflowOptions = options
	return o
}

// WithUpdateCartOptions sets the UpdateCartOptions
func (o *ShoppingCartWithUpdateCartOptions) WithUpdateCartOptions(options *UpdateCartOptions) *ShoppingCartWithUpdateCartOptions {
	o.updateOptions = options
	return o
}

// ShoppingCartWithUpdateCart starts a(n) example.shoppingcart.v1.ShoppingCart workflow and executes a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart update in a transaction
func (c *shoppingCartClient) ShoppingCartWithUpdateCart(ctx context.Context, req *ShoppingCartInput, update *UpdateCartInput, options ...*ShoppingCartWithUpdateCartOptions) (*UpdateCartOutput, ShoppingCartRun, error) {
	updateHandle, run, err := c.ShoppingCartWithUpdateCartAsync(ctx, req, update, options...)
	if err != nil {
		return nil, run, err
	}
	out, err := updateHandle.Get(ctx)
	if err != nil {
		return nil, run, err
	}
	return out, run, nil
}

// ShoppingCartWithUpdateCartAsync starts a(n) example.shoppingcart.v1.ShoppingCart workflow and executes a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart update in a transaction
func (c *shoppingCartClient) ShoppingCartWithUpdateCartAsync(ctx context.Context, req *ShoppingCartInput, update *UpdateCartInput, options ...*ShoppingCartWithUpdateCartOptions) (UpdateCartHandle, ShoppingCartRun, error) {
	var o *ShoppingCartWithUpdateCartOptions
	if len(options) > 0 && options[0] != nil {
		o = options[0]
	} else {
		o = NewShoppingCartWithUpdateCartOptions()
	}
	opts, err := o.Build(ctx, func(swo client.StartWorkflowOptions) client.WithStartWorkflowOperation {
		return c.client.NewWithStartWorkflowOperation(swo, ShoppingCartWorkflowName, req)
	}, req, update)
	if err != nil {
		return nil, nil, fmt.Errorf("error initializing UpdateWorkflowWithOptions: %w", err)
	}
	handle, err := c.client.UpdateWithStartWorkflow(ctx, opts)
	if err != nil {
		return nil, nil, err
	}
	return &updateCartHandle{
		client: c,
		handle: handle,
	}, c.GetShoppingCart(ctx, handle.WorkflowID(), handle.RunID()), nil
}

// CancelWorkflow requests cancellation of an existing workflow execution
func (c *shoppingCartClient) CancelWorkflow(ctx context.Context, workflowID string, runID string) error {
	return c.client.CancelWorkflow(ctx, workflowID, runID)
}

// TerminateWorkflow terminates an existing workflow execution
func (c *shoppingCartClient) TerminateWorkflow(ctx context.Context, workflowID string, runID string, reason string, details ...interface{}) error {
	return c.client.TerminateWorkflow(ctx, workflowID, runID, reason, details...)
}

// example.shoppingcart.v1.ShoppingCart.Describe sends a(n) example.shoppingcart.v1.ShoppingCart.Describe query to an existing workflow
func (c *shoppingCartClient) Describe(ctx context.Context, workflowID string, runID string, query *DescribeInput) (*DescribeOutput, error) {
	var resp DescribeOutput
	if val, err := c.client.QueryWorkflow(ctx, workflowID, runID, DescribeQueryName, query); err != nil {
		return nil, err
	} else if err = val.Get(&resp); err != nil {
		return nil, err
	}
	return &resp, nil
}

// example.shoppingcart.v1.ShoppingCart.Checkout sends a(n) example.shoppingcart.v1.ShoppingCart.Checkout signal to an existing workflow
func (c *shoppingCartClient) Checkout(ctx context.Context, workflowID string, runID string, signal *CheckoutInput) error {
	return c.client.SignalWorkflow(ctx, workflowID, runID, CheckoutSignalName, signal)
}

// example.shoppingcart.v1.ShoppingCart.UpdateCart sends a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart update to an existing workflow
func (c *shoppingCartClient) UpdateCart(ctx context.Context, workflowID string, runID string, req *UpdateCartInput, opts ...*UpdateCartOptions) (*UpdateCartOutput, error) {
	// initialize update options
	o := NewUpdateCartOptions()
	if len(opts) > 0 && opts[0].Options != nil {
		o = opts[0]
	}

	// call sync update with WorkflowUpdateStageCompleted wait policy
	handle, err := c.UpdateCartAsync(ctx, workflowID, runID, req, o.WithWaitPolicy(client.WorkflowUpdateStageCompleted))
	if err != nil {
		return nil, err
	}

	// block on update completion
	return handle.Get(ctx)
}

// example.shoppingcart.v1.ShoppingCart.UpdateCart sends a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart update to an existing workflow
func (c *shoppingCartClient) UpdateCartAsync(ctx context.Context, workflowID string, runID string, req *UpdateCartInput, opts ...*UpdateCartOptions) (UpdateCartHandle, error) {
	// initialize update options
	var o *UpdateCartOptions
	if len(opts) > 0 && opts[0] != nil {
		o = opts[0]
	} else {
		o = NewUpdateCartOptions()
	}

	// build UpdateWorkflowOptions
	options, err := o.Build(workflowID, runID, req)
	if err != nil {
		return nil, fmt.Errorf("error initializing UpdateWorkflowWithOptions: %w", err)
	}

	// update workflow
	handle, err := c.client.UpdateWorkflow(ctx, *options)
	if err != nil {
		return nil, err
	}
	return &updateCartHandle{client: c, handle: handle}, nil
}

// GetUpdateCart retrieves a handle to an existing example.shoppingcart.v1.ShoppingCart.UpdateCart update
func (c *shoppingCartClient) GetUpdateCart(ctx context.Context, req client.GetWorkflowUpdateHandleOptions) (UpdateCartHandle, error) {
	return &updateCartHandle{
		client: c,
		handle: c.client.GetWorkflowUpdateHandle(req),
	}, nil
}

// ShoppingCartOptions provides configuration for a example.shoppingcart.v1.ShoppingCart workflow operation
type ShoppingCartOptions struct {
	options                  client.StartWorkflowOptions
	executionTimeout         *time.Duration
	id                       *string
	idReusePolicy            enumsv1.WorkflowIdReusePolicy
	retryPolicy              *temporal.RetryPolicy
	runTimeout               *time.Duration
	searchAttributes         map[string]any
	taskQueue                *string
	taskTimeout              *time.Duration
	workflowIdConflictPolicy enumsv1.WorkflowIdConflictPolicy
}

// NewShoppingCartOptions initializes a new ShoppingCartOptions value
func NewShoppingCartOptions() *ShoppingCartOptions {
	return &ShoppingCartOptions{}
}

// Build initializes a new go.temporal.io/sdk/client.StartWorkflowOptions value with defaults and overrides applied
func (o *ShoppingCartOptions) Build(req protoreflect.Message) (client.StartWorkflowOptions, error) {
	opts := o.options
	if v := o.id; v != nil {
		opts.ID = *v
	} else if opts.ID == "" {
		id, err := expression.EvalExpression(ShoppingCartIdexpression, req)
		if err != nil {
			return opts, fmt.Errorf("error evaluating id expression for %q workflow: %w", ShoppingCartWorkflowName, err)
		}
		opts.ID = id
	}
	if v := o.idReusePolicy; v != enumsv1.WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED {
		opts.WorkflowIDReusePolicy = v
	}
	if v := o.workflowIdConflictPolicy; v != enumsv1.WORKFLOW_ID_CONFLICT_POLICY_UNSPECIFIED {
		opts.WorkflowIDConflictPolicy = v
	}
	if v := o.taskQueue; v != nil {
		opts.TaskQueue = *v
	} else if opts.TaskQueue == "" {
		opts.TaskQueue = ShoppingCartTaskQueue
	}
	if v := o.retryPolicy; v != nil {
		opts.RetryPolicy = v
	}
	if v := o.searchAttributes; v != nil {
		opts.SearchAttributes = o.searchAttributes
	}
	if v := o.executionTimeout; v != nil {
		opts.WorkflowExecutionTimeout = *v
	}
	if v := o.runTimeout; v != nil {
		opts.WorkflowRunTimeout = *v
	}
	if v := o.taskTimeout; v != nil {
		opts.WorkflowTaskTimeout = *v
	}
	return opts, nil
}

// WithStartWorkflowOptions sets the initial go.temporal.io/sdk/client.StartWorkflowOptions
func (o *ShoppingCartOptions) WithStartWorkflowOptions(options client.StartWorkflowOptions) *ShoppingCartOptions {
	o.options = options
	return o
}

// WithExecutionTimeout sets the WorkflowExecutionTimeout value
func (o *ShoppingCartOptions) WithExecutionTimeout(d time.Duration) *ShoppingCartOptions {
	o.executionTimeout = &d
	return o
}

// WithID sets the ID value
func (o *ShoppingCartOptions) WithID(id string) *ShoppingCartOptions {
	o.id = &id
	return o
}

// WithIDReusePolicy sets the WorkflowIDReusePolicy value
func (o *ShoppingCartOptions) WithIDReusePolicy(policy enumsv1.WorkflowIdReusePolicy) *ShoppingCartOptions {
	o.idReusePolicy = policy
	return o
}

// WithRetryPolicy sets the RetryPolicy value
func (o *ShoppingCartOptions) WithRetryPolicy(policy *temporal.RetryPolicy) *ShoppingCartOptions {
	o.retryPolicy = policy
	return o
}

// WithRunTimeout sets the WorkflowRunTimeout value
func (o *ShoppingCartOptions) WithRunTimeout(d time.Duration) *ShoppingCartOptions {
	o.runTimeout = &d
	return o
}

// WithSearchAttributes sets the SearchAttributes value
func (o *ShoppingCartOptions) WithSearchAttributes(sa map[string]any) *ShoppingCartOptions {
	o.searchAttributes = sa
	return o
}

// WithTaskTimeout sets the WorkflowTaskTimeout value
func (o *ShoppingCartOptions) WithTaskTimeout(d time.Duration) *ShoppingCartOptions {
	o.taskTimeout = &d
	return o
}

// WithTaskQueue sets the TaskQueue value
func (o *ShoppingCartOptions) WithTaskQueue(tq string) *ShoppingCartOptions {
	o.taskQueue = &tq
	return o
}

// WithWorkflowIdConflictPolicy sets the WorkflowIdConflictPolicy value
func (o *ShoppingCartOptions) WithWorkflowIdConflictPolicy(policy enumsv1.WorkflowIdConflictPolicy) *ShoppingCartOptions {
	o.workflowIdConflictPolicy = policy
	return o
}

// ShoppingCartRun describes a(n) example.shoppingcart.v1.ShoppingCart workflow run
type ShoppingCartRun interface {
	// ID returns the workflow ID
	ID() string

	// RunID returns the workflow instance ID
	RunID() string

	// Run returns the inner client.WorkflowRun
	Run() client.WorkflowRun

	// Get blocks until the workflow is complete and returns the result
	Get(ctx context.Context) (*ShoppingCartOutput, error)

	// Cancel requests cancellation of a workflow in execution, returning an error if applicable
	Cancel(ctx context.Context) error

	// Terminate terminates a workflow in execution, returning an error if applicable
	Terminate(ctx context.Context, reason string, details ...interface{}) error

	// example.shoppingcart.v1.ShoppingCart.Describe executes a(n) example.shoppingcart.v1.ShoppingCart.Describe query
	Describe(ctx context.Context, req *DescribeInput) (*DescribeOutput, error)

	// example.shoppingcart.v1.ShoppingCart.Checkout sends a(n) example.shoppingcart.v1.ShoppingCart.Checkout signal
	Checkout(ctx context.Context, req *CheckoutInput) error

	// example.shoppingcart.v1.ShoppingCart.UpdateCart executes a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart update
	UpdateCart(ctx context.Context, req *UpdateCartInput, opts ...*UpdateCartOptions) (*UpdateCartOutput, error)

	// example.shoppingcart.v1.ShoppingCart.UpdateCartAsync sends a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart update to the workflow
	UpdateCartAsync(ctx context.Context, req *UpdateCartInput, opts ...*UpdateCartOptions) (UpdateCartHandle, error)
}

// shoppingCartRun provides an internal implementation of a(n) ShoppingCartRunRun
type shoppingCartRun struct {
	client *shoppingCartClient
	run    client.WorkflowRun
}

// ID returns the workflow ID
func (r *shoppingCartRun) ID() string {
	return r.run.GetID()
}

// Run returns the inner client.WorkflowRun
func (r *shoppingCartRun) Run() client.WorkflowRun {
	return r.run
}

// RunID returns the execution ID
func (r *shoppingCartRun) RunID() string {
	return r.run.GetRunID()
}

// Cancel requests cancellation of a workflow in execution, returning an error if applicable
func (r *shoppingCartRun) Cancel(ctx context.Context) error {
	return r.client.CancelWorkflow(ctx, r.ID(), r.RunID())
}

// Get blocks until the workflow is complete, returning the result if applicable
func (r *shoppingCartRun) Get(ctx context.Context) (*ShoppingCartOutput, error) {
	var resp ShoppingCartOutput
	if err := r.run.Get(ctx, &resp); err != nil {
		return nil, err
	}
	return &resp, nil
}

// Terminate terminates a workflow in execution, returning an error if applicable
func (r *shoppingCartRun) Terminate(ctx context.Context, reason string, details ...interface{}) error {
	return r.client.TerminateWorkflow(ctx, r.ID(), r.RunID(), reason, details...)
}

// example.shoppingcart.v1.ShoppingCart.Describe executes a(n) example.shoppingcart.v1.ShoppingCart.Describe query
func (r *shoppingCartRun) Describe(ctx context.Context, req *DescribeInput) (*DescribeOutput, error) {
	return r.client.Describe(ctx, r.ID(), "", req)
}

// example.shoppingcart.v1.ShoppingCart.Checkout sends a(n) example.shoppingcart.v1.ShoppingCart.Checkout signal
func (r *shoppingCartRun) Checkout(ctx context.Context, req *CheckoutInput) error {
	return r.client.Checkout(ctx, r.ID(), "", req)
}

// example.shoppingcart.v1.ShoppingCart.UpdateCart executes a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart workflow update
func (r *shoppingCartRun) UpdateCart(ctx context.Context, req *UpdateCartInput, opts ...*UpdateCartOptions) (*UpdateCartOutput, error) {
	return r.client.UpdateCart(ctx, r.ID(), r.RunID(), req, opts...)
}

// UpdateCartAsync start a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart workflow update and returns a handle to the update
func (r *shoppingCartRun) UpdateCartAsync(ctx context.Context, req *UpdateCartInput, opts ...*UpdateCartOptions) (UpdateCartHandle, error) {
	return r.client.UpdateCartAsync(ctx, r.ID(), r.RunID(), req, opts...)
}

// UpdateCartHandle describes a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart update handle
type UpdateCartHandle interface {
	// WorkflowID returns the workflow ID
	WorkflowID() string
	// RunID returns the workflow instance ID
	RunID() string
	// UpdateID returns the update ID
	UpdateID() string
	// Get blocks until the workflow is complete and returns the result
	Get(ctx context.Context) (*UpdateCartOutput, error)
}

// updateCartHandle provides an internal implementation of a(n) UpdateCartHandle
type updateCartHandle struct {
	client *shoppingCartClient
	handle client.WorkflowUpdateHandle
}

// WorkflowID returns the workflow ID
func (h *updateCartHandle) WorkflowID() string {
	return h.handle.WorkflowID()
}

// RunID returns the execution ID
func (h *updateCartHandle) RunID() string {
	return h.handle.RunID()
}

// UpdateID returns the update ID
func (h *updateCartHandle) UpdateID() string {
	return h.handle.UpdateID()
}

// Get blocks until the update wait policy is met, returning the result if applicable
func (h *updateCartHandle) Get(ctx context.Context) (*UpdateCartOutput, error) {
	var resp UpdateCartOutput
	var err error
	doneCh := make(chan struct{})
	gctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	go func() {
		for {
			var deadlineExceeded *serviceerror.DeadlineExceeded
			if err = h.handle.Get(gctx, &resp); err != nil && ctx.Err() == nil && (errors.As(err, &deadlineExceeded) || strings.Contains(err.Error(), context.DeadlineExceeded.Error())) {
				continue
			}
			break
		}
		close(doneCh)
	}()

	select {
	case <-ctx.Done():
		return nil, ctx.Err()
	case <-doneCh:
		if err != nil {
			return nil, err
		}
		return &resp, nil
	}
}

// UpdateCartOptions provides configuration for a example.shoppingcart.v1.ShoppingCart.UpdateCart update operation
type UpdateCartOptions struct {
	Options    *client.UpdateWorkflowOptions
	id         *string
	waitPolicy client.WorkflowUpdateStage
}

// NewUpdateCartOptions initializes a new UpdateCartOptions value
func NewUpdateCartOptions() *UpdateCartOptions {
	return &UpdateCartOptions{Options: &client.UpdateWorkflowOptions{}}
}

// Build initializes a new client.UpdateWorkflowOptions with defaults and overrides applied
func (o *UpdateCartOptions) Build(workflowID string, runID string, req *UpdateCartInput) (opts *client.UpdateWorkflowOptions, err error) {
	// use user-provided UpdateWorkflowOptions if exists
	if o.Options != nil {
		opts = o.Options
	} else {
		opts = &client.UpdateWorkflowOptions{}
	}

	// set constants
	opts.Args = []any{req}
	opts.RunID = runID
	opts.UpdateName = UpdateCartUpdateName
	opts.WorkflowID = workflowID

	// set UpdateID
	if v := o.id; v != nil {
		opts.UpdateID = *v
	} else if opts.UpdateID == "" {
		id, err := expression.EvalExpression(UpdateCartIdexpression, req.ProtoReflect())
		if err != nil {
			return nil, fmt.Errorf("error evaluating id expression for %q update: %w", UpdateCartUpdateName, err)
		}
		opts.UpdateID = id
	}

	// set WaitPolicy
	if v := o.waitPolicy; v != client.WorkflowUpdateStageUnspecified {
		opts.WaitForStage = v
	} else if opts.WaitForStage == client.WorkflowUpdateStageUnspecified {
		opts.WaitForStage = client.WorkflowUpdateStageAccepted
	}
	return opts, nil
}

// WithUpdateID sets the UpdateID
func (o *UpdateCartOptions) WithUpdateID(id string) *UpdateCartOptions {
	o.id = &id
	return o
}

// WithUpdateWorkflowOptions sets the initial client.UpdateWorkflowOptions
func (o *UpdateCartOptions) WithUpdateWorkflowOptions(options client.UpdateWorkflowOptions) *UpdateCartOptions {
	o.Options = &options
	return o
}

// WithWaitPolicy sets the WaitPolicy
func (o *UpdateCartOptions) WithWaitPolicy(policy client.WorkflowUpdateStage) *UpdateCartOptions {
	o.waitPolicy = policy
	return o
}

// Reference to generated workflow functions
var (
	// shoppingCartRegistrationMutex is a mutex for registering example.shoppingcart.v1.ShoppingCart workflows
	shoppingCartRegistrationMutex sync.Mutex
	// ShoppingCartFunction implements a "example.shoppingcart.v1.ShoppingCart" workflow
	ShoppingCartFunction func(workflow.Context, *ShoppingCartInput) (*ShoppingCartOutput, error)
)

// ShoppingCartWorkflowFunctions describes a mockable dependency for inlining workflows within other workflows
type (
	// ShoppingCartWorkflowFunctions describes a mockable dependency for inlining workflows within other workflows
	ShoppingCartWorkflowFunctions interface {
		// ShoppingCart executes a "example.shoppingcart.v1.ShoppingCart" workflow inline
		ShoppingCart(workflow.Context, *ShoppingCartInput) (*ShoppingCartOutput, error)
	}
	// shoppingCartWorkflowFunctions provides an internal ShoppingCartWorkflowFunctions implementation
	shoppingCartWorkflowFunctions struct{}
)

func NewShoppingCartWorkflowFunctions() ShoppingCartWorkflowFunctions {
	return &shoppingCartWorkflowFunctions{}
}

// ShoppingCart executes a "example.shoppingcart.v1.ShoppingCart" workflow inline
func (f *shoppingCartWorkflowFunctions) ShoppingCart(ctx workflow.Context, req *ShoppingCartInput) (*ShoppingCartOutput, error) {
	if ShoppingCartFunction == nil {
		return nil, errors.New("ShoppingCart requires workflow registration via RegisterShoppingCartWorkflows or RegisterShoppingCartWorkflow")
	}
	return ShoppingCartFunction(ctx, req)
}

// ShoppingCartWorkflows provides methods for initializing new example.shoppingcart.v1.ShoppingCart workflow values
type ShoppingCartWorkflows interface {
	// ShoppingCart initializes a new a(n) ShoppingCartWorkflow implementation
	ShoppingCart(ctx workflow.Context, input *ShoppingCartWorkflowInput) (ShoppingCartWorkflow, error)
}

// RegisterShoppingCartWorkflows registers example.shoppingcart.v1.ShoppingCart workflows with the given worker
func RegisterShoppingCartWorkflows(r worker.WorkflowRegistry, workflows ShoppingCartWorkflows) {
	RegisterShoppingCartWorkflow(r, workflows.ShoppingCart)
}

// RegisterShoppingCartWorkflow registers a example.shoppingcart.v1.ShoppingCart.ShoppingCart workflow with the given worker
func RegisterShoppingCartWorkflow(r worker.WorkflowRegistry, wf func(workflow.Context, *ShoppingCartWorkflowInput) (ShoppingCartWorkflow, error)) {
	shoppingCartRegistrationMutex.Lock()
	defer shoppingCartRegistrationMutex.Unlock()
	ShoppingCartFunction = buildShoppingCart(wf)
	r.RegisterWorkflowWithOptions(ShoppingCartFunction, workflow.RegisterOptions{Name: ShoppingCartWorkflowName})
}

// buildShoppingCart converts a ShoppingCart workflow struct into a valid workflow function
func buildShoppingCart(ctor func(workflow.Context, *ShoppingCartWorkflowInput) (ShoppingCartWorkflow, error)) func(workflow.Context, *ShoppingCartInput) (*ShoppingCartOutput, error) {
	return func(ctx workflow.Context, req *ShoppingCartInput) (*ShoppingCartOutput, error) {
		input := &ShoppingCartWorkflowInput{
			Req: req,
			Checkout: &CheckoutSignal{
				Channel: workflow.GetSignalChannel(ctx, CheckoutSignalName),
			},
		}
		wf, err := ctor(ctx, input)
		if err != nil {
			return nil, err
		}
		if initializable, ok := wf.(helpers.Initializable); ok {
			if err := initializable.Initialize(ctx); err != nil {
				return nil, err
			}
		}
		if err := workflow.SetQueryHandler(ctx, DescribeQueryName, wf.Describe); err != nil {
			return nil, err
		}
		{
			opts := workflow.UpdateHandlerOptions{Validator: wf.ValidateUpdateCart}
			if err := workflow.SetUpdateHandlerWithOptions(ctx, UpdateCartUpdateName, wf.UpdateCart, opts); err != nil {
				return nil, err
			}
		}
		return wf.Execute(ctx)
	}
}

// ShoppingCartWorkflowInput describes the input to a(n) example.shoppingcart.v1.ShoppingCart workflow constructor
type ShoppingCartWorkflowInput struct {
	Req      *ShoppingCartInput
	Checkout *CheckoutSignal
}

// ShoppingCartWorkflow describes a(n) example.shoppingcart.v1.ShoppingCart workflow implementation
//
// workflow details: (id: "example.shoppingcart.v1.ShoppingCart/${! nanoid() }")
type ShoppingCartWorkflow interface {
	// Execute defines the entrypoint to a(n) example.shoppingcart.v1.ShoppingCart workflow
	Execute(ctx workflow.Context) (*ShoppingCartOutput, error)

	// example.shoppingcart.v1.ShoppingCart.Describe implements a(n) example.shoppingcart.v1.ShoppingCart.Describe query handler
	Describe(*DescribeInput) (*DescribeOutput, error)

	// ValidateUpdateCart validates a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart update
	ValidateUpdateCart(workflow.Context, *UpdateCartInput) error

	// example.shoppingcart.v1.ShoppingCart.UpdateCart implements a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart update handler
	UpdateCart(workflow.Context, *UpdateCartInput) (*UpdateCartOutput, error)
}

// ShoppingCartChild executes a child example.shoppingcart.v1.ShoppingCart workflow and blocks until error or response received
func ShoppingCartChild(ctx workflow.Context, req *ShoppingCartInput, options ...*ShoppingCartChildOptions) (*ShoppingCartOutput, error) {
	childRun, err := ShoppingCartChildAsync(ctx, req, options...)
	if err != nil {
		return nil, err
	}
	return childRun.Get(ctx)
}

// ShoppingCartChildAsync starts a child example.shoppingcart.v1.ShoppingCart workflow and returns a handle to the child workflow run
func ShoppingCartChildAsync(ctx workflow.Context, req *ShoppingCartInput, options ...*ShoppingCartChildOptions) (*ShoppingCartChildRun, error) {
	var o *ShoppingCartChildOptions
	if len(options) > 0 && options[0] != nil {
		o = options[0]
	} else {
		o = NewShoppingCartChildOptions()
	}
	opts, err := o.Build(ctx, req.ProtoReflect())
	if err != nil {
		return nil, fmt.Errorf("error initializing workflow.ChildWorkflowOptions: %w", err)
	}
	ctx = workflow.WithChildOptions(ctx, opts)
	if o.dc != nil {
		ctx = workflow.WithDataConverter(ctx, o.dc)
	}
	return &ShoppingCartChildRun{Future: workflow.ExecuteChildWorkflow(ctx, ShoppingCartWorkflowName, req)}, nil
}

// ShoppingCartChildOptions provides configuration for a child example.shoppingcart.v1.ShoppingCart workflow operation
type ShoppingCartChildOptions struct {
	options                  workflow.ChildWorkflowOptions
	executionTimeout         *time.Duration
	id                       *string
	idReusePolicy            enumsv1.WorkflowIdReusePolicy
	retryPolicy              *temporal.RetryPolicy
	runTimeout               *time.Duration
	searchAttributes         map[string]any
	taskQueue                *string
	taskTimeout              *time.Duration
	workflowIdConflictPolicy enumsv1.WorkflowIdConflictPolicy
	dc                       converter.DataConverter
	parentClosePolicy        enumsv1.ParentClosePolicy
	waitForCancellation      *bool
}

// NewShoppingCartChildOptions initializes a new ShoppingCartChildOptions value
func NewShoppingCartChildOptions() *ShoppingCartChildOptions {
	return &ShoppingCartChildOptions{}
}

// Build initializes a new go.temporal.io/sdk/workflow.ChildWorkflowOptions value with defaults and overrides applied
func (o *ShoppingCartChildOptions) Build(ctx workflow.Context, req protoreflect.Message) (workflow.ChildWorkflowOptions, error) {
	opts := o.options
	if v := o.id; v != nil {
		opts.WorkflowID = *v
	} else if opts.WorkflowID == "" {
		// wrap expression evaluation in local activity
		// more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_64-expression-evaluation-local-activity
		if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_64_expression-evaluation-local-activity", workflow.DefaultVersion, 1) == 1 {
			lao := workflow.GetLocalActivityOptions(ctx)
			lao.ScheduleToCloseTimeout = time.Second * 10
			if err := workflow.ExecuteLocalActivity(workflow.WithLocalActivityOptions(ctx, lao), func(ctx context.Context) (string, error) {
				id, err := expression.EvalExpression(ShoppingCartIdexpression, req)
				if err != nil {
					return "", fmt.Errorf("error evaluating id expression for %q workflow: %w", ShoppingCartWorkflowName, err)
				}
				return id, nil
			}).Get(ctx, &opts.WorkflowID); err != nil {
				return opts, fmt.Errorf("error evaluating id expression for %q workflow: %w", ShoppingCartWorkflowName, err)
			}
		} else {
			id, err := expression.EvalExpression(ShoppingCartIdexpression, req)
			if err != nil {
				return opts, fmt.Errorf("error evaluating id expression for %q workflow: %w", ShoppingCartWorkflowName, err)
			}
			opts.WorkflowID = id
		}
	}
	if v := o.idReusePolicy; v != enumsv1.WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED {
		opts.WorkflowIDReusePolicy = v
	}
	if v := o.taskQueue; v != nil {
		opts.TaskQueue = *v
	} else if opts.TaskQueue == "" {
		opts.TaskQueue = ShoppingCartTaskQueue
	}
	if v := o.retryPolicy; v != nil {
		opts.RetryPolicy = v
	}
	if v := o.searchAttributes; v != nil {
		opts.SearchAttributes = o.searchAttributes
	}
	if v := o.executionTimeout; v != nil {
		opts.WorkflowExecutionTimeout = *v
	}
	if v := o.runTimeout; v != nil {
		opts.WorkflowRunTimeout = *v
	}
	if v := o.taskTimeout; v != nil {
		opts.WorkflowTaskTimeout = *v
	}
	if v := o.parentClosePolicy; v != enumsv1.PARENT_CLOSE_POLICY_UNSPECIFIED {
		opts.ParentClosePolicy = v
	}
	if v := o.waitForCancellation; v != nil {
		opts.WaitForCancellation = *v
	}
	return opts, nil
}

// WithChildWorkflowOptions sets the initial go.temporal.io/sdk/workflow.ChildWorkflowOptions
func (o *ShoppingCartChildOptions) WithChildWorkflowOptions(options workflow.ChildWorkflowOptions) *ShoppingCartChildOptions {
	o.options = options
	return o
}

// WithDataConverter registers a DataConverter for the child workflow
func (o *ShoppingCartChildOptions) WithDataConverter(dc converter.DataConverter) *ShoppingCartChildOptions {
	o.dc = dc
	return o
}

// WithExecutionTimeout sets the WorkflowExecutionTimeout value
func (o *ShoppingCartChildOptions) WithExecutionTimeout(d time.Duration) *ShoppingCartChildOptions {
	o.executionTimeout = &d
	return o
}

// WithID sets the WorkflowID value
func (o *ShoppingCartChildOptions) WithID(id string) *ShoppingCartChildOptions {
	o.id = &id
	return o
}

// WithIDReusePolicy sets the WorkflowIDReusePolicy value
func (o *ShoppingCartChildOptions) WithIDReusePolicy(policy enumsv1.WorkflowIdReusePolicy) *ShoppingCartChildOptions {
	o.idReusePolicy = policy
	return o
}

// WithParentClosePolicy sets the WorkflowIDReusePolicy value
func (o *ShoppingCartChildOptions) WithParentClosePolicy(policy enumsv1.ParentClosePolicy) *ShoppingCartChildOptions {
	o.parentClosePolicy = policy
	return o
}

// WithRetryPolicy sets the RetryPolicy value
func (o *ShoppingCartChildOptions) WithRetryPolicy(policy *temporal.RetryPolicy) *ShoppingCartChildOptions {
	o.retryPolicy = policy
	return o
}

// WithRunTimeout sets the WorkflowRunTimeout value
func (o *ShoppingCartChildOptions) WithRunTimeout(d time.Duration) *ShoppingCartChildOptions {
	o.runTimeout = &d
	return o
}

// WithSearchAttributes sets the SearchAttributes value
func (o *ShoppingCartChildOptions) WithSearchAttributes(sa map[string]any) *ShoppingCartChildOptions {
	o.searchAttributes = sa
	return o
}

// WithTaskTimeout sets the WorkflowTaskTimeout value
func (o *ShoppingCartChildOptions) WithTaskTimeout(d time.Duration) *ShoppingCartChildOptions {
	o.taskTimeout = &d
	return o
}

// WithTaskQueue sets the TaskQueue value
func (o *ShoppingCartChildOptions) WithTaskQueue(tq string) *ShoppingCartChildOptions {
	o.taskQueue = &tq
	return o
}

// WithWaitForCancellation sets the WaitForCancellation value
func (o *ShoppingCartChildOptions) WithWaitForCancellation(wait bool) *ShoppingCartChildOptions {
	o.waitForCancellation = &wait
	return o
}

// WithWorkflowIdConflictPolicy sets the WorkflowIdConflictPolicy value
func (o *ShoppingCartChildOptions) WithWorkflowIdConflictPolicy(policy enumsv1.WorkflowIdConflictPolicy) *ShoppingCartChildOptions {
	o.workflowIdConflictPolicy = policy
	return o
}

// ShoppingCartChildRun describes a child ShoppingCart workflow run
type ShoppingCartChildRun struct {
	Future workflow.ChildWorkflowFuture
}

// Get blocks until the workflow is completed, returning the response value
func (r *ShoppingCartChildRun) Get(ctx workflow.Context) (*ShoppingCartOutput, error) {
	var resp ShoppingCartOutput
	if err := r.Future.Get(ctx, &resp); err != nil {
		return nil, err
	}
	return &resp, nil
}

// Select adds this completion to the selector. Callback can be nil.
func (r *ShoppingCartChildRun) Select(sel workflow.Selector, fn func(*ShoppingCartChildRun)) workflow.Selector {
	return sel.AddFuture(r.Future, func(workflow.Future) {
		if fn != nil {
			fn(r)
		}
	})
}

// SelectStart adds waiting for start to the selector. Callback can be nil.
func (r *ShoppingCartChildRun) SelectStart(sel workflow.Selector, fn func(*ShoppingCartChildRun)) workflow.Selector {
	return sel.AddFuture(r.Future.GetChildWorkflowExecution(), func(workflow.Future) {
		if fn != nil {
			fn(r)
		}
	})
}

// WaitStart waits for the child workflow to start
func (r *ShoppingCartChildRun) WaitStart(ctx workflow.Context) (*workflow.Execution, error) {
	var exec workflow.Execution
	if err := r.Future.GetChildWorkflowExecution().Get(ctx, &exec); err != nil {
		return nil, err
	}
	return &exec, nil
}

// Checkout sends a(n) "example.shoppingcart.v1.ShoppingCart.Checkout" signal request to the child workflow
func (r *ShoppingCartChildRun) Checkout(ctx workflow.Context, input *CheckoutInput) error {
	return r.CheckoutAsync(ctx, input).Get(ctx, nil)
}

// CheckoutAsync sends a(n) "example.shoppingcart.v1.ShoppingCart.Checkout" signal request to the child workflow
func (r *ShoppingCartChildRun) CheckoutAsync(ctx workflow.Context, input *CheckoutInput) workflow.Future {
	return r.Future.SignalChildWorkflow(ctx, CheckoutSignalName, input)
}

// CheckoutSignal describes a(n) example.shoppingcart.v1.ShoppingCart.Checkout signal
type CheckoutSignal struct {
	Channel workflow.ReceiveChannel
}

// NewCheckoutSignal initializes a new example.shoppingcart.v1.ShoppingCart.Checkout signal wrapper
func NewCheckoutSignal(ctx workflow.Context) *CheckoutSignal {
	return &CheckoutSignal{Channel: workflow.GetSignalChannel(ctx, CheckoutSignalName)}
}

// Receive blocks until a(n) example.shoppingcart.v1.ShoppingCart.Checkout signal is received
func (s *CheckoutSignal) Receive(ctx workflow.Context) (*CheckoutInput, bool) {
	var resp CheckoutInput
	more := s.Channel.Receive(ctx, &resp)
	return &resp, more
}

// ReceiveAsync checks for a example.shoppingcart.v1.ShoppingCart.Checkout signal without blocking
func (s *CheckoutSignal) ReceiveAsync() *CheckoutInput {
	var resp CheckoutInput
	if ok := s.Channel.ReceiveAsync(&resp); !ok {
		return nil
	}
	return &resp
}

// ReceiveWithTimeout blocks until a(n) example.shoppingcart.v1.ShoppingCart.Checkout signal is received or timeout expires.
// Returns more value of false when Channel is closed.
// Returns ok value of false when no value was found in the channel for the duration of timeout or the ctx was canceled.
// resp will be nil if ok is false.
func (s *CheckoutSignal) ReceiveWithTimeout(ctx workflow.Context, timeout time.Duration) (resp *CheckoutInput, ok bool, more bool) {
	resp = &CheckoutInput{}
	if ok, more = s.Channel.ReceiveWithTimeout(ctx, timeout, &resp); !ok {
		return nil, false, more
	}
	return
}

// Select checks for a(n) example.shoppingcart.v1.ShoppingCart.Checkout signal without blocking
func (s *CheckoutSignal) Select(sel workflow.Selector, fn func(*CheckoutInput)) workflow.Selector {
	return sel.AddReceive(s.Channel, func(workflow.ReceiveChannel, bool) {
		req := s.ReceiveAsync()
		if fn != nil {
			fn(req)
		}
	})
}

// CheckoutExternal sends a(n) example.shoppingcart.v1.ShoppingCart.Checkout signal to an existing workflow
func CheckoutExternal(ctx workflow.Context, workflowID string, runID string, req *CheckoutInput) error {
	return CheckoutExternalAsync(ctx, workflowID, runID, req).Get(ctx, nil)
}

// CheckoutExternalAsync sends a(n) example.shoppingcart.v1.ShoppingCart.Checkout signal to an existing workflow
func CheckoutExternalAsync(ctx workflow.Context, workflowID string, runID string, req *CheckoutInput) workflow.Future {
	return workflow.SignalExternalWorkflow(ctx, workflowID, runID, CheckoutSignalName, req)
}

// ShoppingCartActivities describes available worker activities
type ShoppingCartActivities interface{}

// RegisterShoppingCartActivities registers activities with a worker
func RegisterShoppingCartActivities(r worker.ActivityRegistry, activities ShoppingCartActivities) {}

// TestClient provides a testsuite-compatible Client
type TestShoppingCartClient struct {
	env       *testsuite.TestWorkflowEnvironment
	workflows ShoppingCartWorkflows
}

var _ ShoppingCartClient = &TestShoppingCartClient{}

// NewTestShoppingCartClient initializes a new TestShoppingCartClient value
func NewTestShoppingCartClient(env *testsuite.TestWorkflowEnvironment, workflows ShoppingCartWorkflows, activities ShoppingCartActivities) *TestShoppingCartClient {
	if workflows != nil {
		RegisterShoppingCartWorkflows(env, workflows)
	}
	if activities != nil {
		RegisterShoppingCartActivities(env, activities)
	}
	return &TestShoppingCartClient{env, workflows}
}

// ShoppingCart executes a(n) example.shoppingcart.v1.ShoppingCart workflow in the test environment
func (c *TestShoppingCartClient) ShoppingCart(ctx context.Context, req *ShoppingCartInput, opts ...*ShoppingCartOptions) (*ShoppingCartOutput, error) {
	run, err := c.ShoppingCartAsync(ctx, req, opts...)
	if err != nil {
		return nil, err
	}
	return run.Get(ctx)
}

// ShoppingCartAsync executes a(n) example.shoppingcart.v1.ShoppingCart workflow in the test environment
func (c *TestShoppingCartClient) ShoppingCartAsync(ctx context.Context, req *ShoppingCartInput, options ...*ShoppingCartOptions) (ShoppingCartRun, error) {
	var o *ShoppingCartOptions
	if len(options) > 0 && options[0] != nil {
		o = options[0]
	} else {
		o = NewShoppingCartOptions()
	}
	opts, err := o.Build(req.ProtoReflect())
	if err != nil {
		return nil, fmt.Errorf("error initializing client.StartWorkflowOptions: %w", err)
	}
	return &testShoppingCartRun{client: c, env: c.env, opts: &opts, req: req, workflows: c.workflows}, nil
}

// GetShoppingCart is a noop
func (c *TestShoppingCartClient) GetShoppingCart(ctx context.Context, workflowID string, runID string) ShoppingCartRun {
	return &testShoppingCartRun{env: c.env, workflows: c.workflows}
}

// ShoppingCartWithUpdateCart executes a(n) example.shoppingcart.v1.ShoppingCart workflow and a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart update in the test environment
func (c *TestShoppingCartClient) ShoppingCartWithUpdateCart(ctx context.Context, input *ShoppingCartInput, update *UpdateCartInput, options ...*ShoppingCartWithUpdateCartOptions) (*UpdateCartOutput, ShoppingCartRun, error) {
	var o *ShoppingCartWithUpdateCartOptions
	if len(options) > 0 && options[0] != nil {
		o = options[0]
	} else {
		o = NewShoppingCartWithUpdateCartOptions()
	}
	handle, run, err := c.ShoppingCartWithUpdateCartAsync(ctx, input, update, o)
	if err != nil {
		return nil, run, err
	}
	run.Get(ctx)
	out, err := handle.Get(ctx)
	if err != nil {
		return nil, run, err
	}
	return out, run, nil
}

// ShoppingCartWithUpdateCartAsync executes a(n) example.shoppingcart.v1.ShoppingCart workflow and a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart update in the test environment
func (c *TestShoppingCartClient) ShoppingCartWithUpdateCartAsync(ctx context.Context, input *ShoppingCartInput, update *UpdateCartInput, options ...*ShoppingCartWithUpdateCartOptions) (UpdateCartHandle, ShoppingCartRun, error) {
	var o *ShoppingCartWithUpdateCartOptions
	if len(options) > 0 && options[0] != nil {
		o = options[0]
	} else {
		o = NewShoppingCartWithUpdateCartOptions()
	}
	if o.workflowOptions == nil {
		o.workflowOptions = NewShoppingCartOptions()
	}
	swo, err := o.workflowOptions.Build(input.ProtoReflect())
	if err != nil {
		return nil, nil, fmt.Errorf("error initializing workflowOptions: %w", err)
	}
	if o.updateOptions == nil {
		o.updateOptions = NewUpdateCartOptions()
	}
	uo, err := o.updateOptions.Build(swo.ID, "", update)
	if err != nil {
		return nil, nil, fmt.Errorf("error initializing updateOptions: %w", err)
	}
	run, err := c.ShoppingCartAsync(ctx, input)
	if err != nil {
		return nil, nil, err
	}
	uc := testutil.NewUpdateCallbacks()
	c.env.RegisterDelayedCallback(func() {
		c.env.UpdateWorkflow(UpdateCartUpdateName, uo.UpdateID, uc, update)
	}, 0)
	return &testUpdateCartHandle{
		callbacks:  uc,
		env:        c.env,
		opts:       uo,
		req:        update,
		runID:      "",
		workflowID: swo.ID,
	}, run, nil
}

// CancelWorkflow requests cancellation of an existing workflow execution
func (c *TestShoppingCartClient) CancelWorkflow(ctx context.Context, workflowID string, runID string) error {
	c.env.CancelWorkflow()
	return nil
}

// TerminateWorkflow terminates an existing workflow execution
func (c *TestShoppingCartClient) TerminateWorkflow(ctx context.Context, workflowID string, runID string, reason string, details ...interface{}) error {
	return c.CancelWorkflow(ctx, workflowID, runID)
}

// Describe executes a example.shoppingcart.v1.ShoppingCart.Describe query
func (c *TestShoppingCartClient) Describe(ctx context.Context, workflowID string, runID string, req *DescribeInput) (*DescribeOutput, error) {
	val, err := c.env.QueryWorkflow(DescribeQueryName, req)
	if err != nil {
		return nil, err
	} else if !val.HasValue() {
		return nil, nil
	} else {
		var result DescribeOutput
		if err := val.Get(&result); err != nil {
			return nil, err
		}
		return &result, nil
	}
}

// Checkout executes a example.shoppingcart.v1.ShoppingCart.Checkout signal
func (c *TestShoppingCartClient) Checkout(ctx context.Context, workflowID string, runID string, req *CheckoutInput) error {
	c.env.SignalWorkflow(CheckoutSignalName, req)
	return nil
}

// UpdateCart executes a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart update in the test environment
func (c *TestShoppingCartClient) UpdateCart(ctx context.Context, workflowID string, runID string, req *UpdateCartInput, opts ...*UpdateCartOptions) (*UpdateCartOutput, error) {
	options := NewUpdateCartOptions()
	if len(opts) > 0 && opts[0].Options != nil {
		options = opts[0]
	}
	options.Options.WaitForStage = client.WorkflowUpdateStageCompleted
	handle, err := c.UpdateCartAsync(ctx, workflowID, runID, req, options)
	if err != nil {
		return nil, err
	}
	return handle.Get(ctx)
}

// UpdateCartAsync executes a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart update in the test environment
func (c *TestShoppingCartClient) UpdateCartAsync(ctx context.Context, workflowID string, runID string, req *UpdateCartInput, opts ...*UpdateCartOptions) (UpdateCartHandle, error) {
	var o *UpdateCartOptions
	if len(opts) > 0 && opts[0] != nil {
		o = opts[0]
	} else {
		o = NewUpdateCartOptions()
	}
	options, err := o.Build(workflowID, runID, req)
	if err != nil {
		return nil, fmt.Errorf("error initializing UpdateWorkflowWithOptions: %w", err)
	}

	if options.UpdateID == "" {
		options.UpdateID = uuid.New().String()
	}

	uc := testutil.NewUpdateCallbacks()
	c.env.UpdateWorkflow(UpdateCartUpdateName, options.UpdateID, uc, req)
	return &testUpdateCartHandle{
		callbacks:  uc,
		env:        c.env,
		opts:       options,
		runID:      runID,
		workflowID: workflowID,
		req:        req,
	}, nil
}

// GetUpdateCart retrieves a handle to an existing example.shoppingcart.v1.ShoppingCart.UpdateCart update
func (c *TestShoppingCartClient) GetUpdateCart(ctx context.Context, req client.GetWorkflowUpdateHandleOptions) (UpdateCartHandle, error) {
	return nil, errors.New("unimplemented")
}

var _ UpdateCartHandle = &testUpdateCartHandle{}

// testUpdateCartHandle provides an internal implementation of a(n) UpdateCartHandle
type testUpdateCartHandle struct {
	callbacks  *testutil.UpdateCallbacks
	env        *testsuite.TestWorkflowEnvironment
	opts       *client.UpdateWorkflowOptions
	req        *UpdateCartInput
	runID      string
	workflowID string
}

// Get retrieves a test example.shoppingcart.v1.ShoppingCart.UpdateCart update result
func (h *testUpdateCartHandle) Get(ctx context.Context) (*UpdateCartOutput, error) {
	if resp, err := h.callbacks.Get(ctx); err != nil {
		return nil, err
	} else {
		return resp.(*UpdateCartOutput), nil
	}
}

// RunID implementation
func (h *testUpdateCartHandle) RunID() string {
	return h.runID
}

// UpdateID implementation
func (h *testUpdateCartHandle) UpdateID() string {
	if h.opts != nil {
		return h.opts.UpdateID
	}
	return ""
}

// WorkflowID implementation
func (h *testUpdateCartHandle) WorkflowID() string {
	return h.workflowID
}

var _ ShoppingCartRun = &testShoppingCartRun{}

// testShoppingCartRun provides convenience methods for interacting with a(n) example.shoppingcart.v1.ShoppingCart workflow in the test environment
type testShoppingCartRun struct {
	client    *TestShoppingCartClient
	env       *testsuite.TestWorkflowEnvironment
	isStarted atomic.Bool
	opts      *client.StartWorkflowOptions
	req       *ShoppingCartInput
	workflows ShoppingCartWorkflows
}

// Cancel requests cancellation of a workflow in execution, returning an error if applicable
func (r *testShoppingCartRun) Cancel(ctx context.Context) error {
	return r.client.CancelWorkflow(ctx, r.ID(), r.RunID())
}

// Get retrieves a test example.shoppingcart.v1.ShoppingCart workflow result
func (r *testShoppingCartRun) Get(context.Context) (*ShoppingCartOutput, error) {
	if r.isStarted.CompareAndSwap(false, true) {
		r.env.ExecuteWorkflow(ShoppingCartWorkflowName, r.req)
	}
	if !r.env.IsWorkflowCompleted() {
		return nil, errors.New("workflow in progress")
	}
	if err := r.env.GetWorkflowError(); err != nil {
		return nil, err
	}
	var result ShoppingCartOutput
	if err := r.env.GetWorkflowResult(&result); err != nil {
		return nil, err
	}
	return &result, nil
}

// ID returns a test example.shoppingcart.v1.ShoppingCart workflow run's workflow ID
func (r *testShoppingCartRun) ID() string {
	if r.opts != nil {
		return r.opts.ID
	}
	return ""
}

// Run noop implementation
func (r *testShoppingCartRun) Run() client.WorkflowRun {
	return nil
}

// RunID noop implementation
func (r *testShoppingCartRun) RunID() string {
	return ""
}

// Terminate terminates a workflow in execution, returning an error if applicable
func (r *testShoppingCartRun) Terminate(ctx context.Context, reason string, details ...interface{}) error {
	return r.client.TerminateWorkflow(ctx, r.ID(), r.RunID(), reason, details...)
}

// Describe executes a example.shoppingcart.v1.ShoppingCart.Describe query against a test example.shoppingcart.v1.ShoppingCart workflow
func (r *testShoppingCartRun) Describe(ctx context.Context, req *DescribeInput) (*DescribeOutput, error) {
	return r.client.Describe(ctx, r.ID(), r.RunID(), req)
}

// Checkout executes a example.shoppingcart.v1.ShoppingCart.Checkout signal against a test example.shoppingcart.v1.ShoppingCart workflow
func (r *testShoppingCartRun) Checkout(ctx context.Context, req *CheckoutInput) error {
	return r.client.Checkout(ctx, r.ID(), r.RunID(), req)
}

// UpdateCart executes a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart update against a test example.shoppingcart.v1.ShoppingCart workflow
func (r *testShoppingCartRun) UpdateCart(ctx context.Context, req *UpdateCartInput, opts ...*UpdateCartOptions) (*UpdateCartOutput, error) {
	return r.client.UpdateCart(ctx, r.ID(), r.RunID(), req, opts...)
}

// UpdateCartAsync executes a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart update against a test example.shoppingcart.v1.ShoppingCart workflow
func (r *testShoppingCartRun) UpdateCartAsync(ctx context.Context, req *UpdateCartInput, opts ...*UpdateCartOptions) (UpdateCartHandle, error) {
	return r.client.UpdateCartAsync(ctx, r.ID(), r.RunID(), req, opts...)
}

// ShoppingCartCliOptions describes runtime configuration for example.shoppingcart.v1.ShoppingCart cli
type ShoppingCartCliOptions struct {
	after            func(*v2.Context) error
	before           func(*v2.Context) error
	clientForCommand func(*v2.Context) (client.Client, error)
	worker           func(*v2.Context, client.Client) (worker.Worker, error)
}

// NewShoppingCartCliOptions initializes a new ShoppingCartCliOptions value
func NewShoppingCartCliOptions() *ShoppingCartCliOptions {
	return &ShoppingCartCliOptions{}
}

// WithAfter injects a custom After hook to be run after any command invocation
func (opts *ShoppingCartCliOptions) WithAfter(fn func(*v2.Context) error) *ShoppingCartCliOptions {
	opts.after = fn
	return opts
}

// WithBefore injects a custom Before hook to be run prior to any command invocation
func (opts *ShoppingCartCliOptions) WithBefore(fn func(*v2.Context) error) *ShoppingCartCliOptions {
	opts.before = fn
	return opts
}

// WithClient provides a Temporal client factory for use by commands
func (opts *ShoppingCartCliOptions) WithClient(fn func(*v2.Context) (client.Client, error)) *ShoppingCartCliOptions {
	opts.clientForCommand = fn
	return opts
}

// WithWorker provides an method for initializing a worker
func (opts *ShoppingCartCliOptions) WithWorker(fn func(*v2.Context, client.Client) (worker.Worker, error)) *ShoppingCartCliOptions {
	opts.worker = fn
	return opts
}

// NewShoppingCartCli initializes a cli for a(n) example.shoppingcart.v1.ShoppingCart service
func NewShoppingCartCli(options ...*ShoppingCartCliOptions) (*v2.App, error) {
	commands, err := newShoppingCartCommands(options...)
	if err != nil {
		return nil, fmt.Errorf("error initializing subcommands: %w", err)
	}
	return &v2.App{
		Name:                      "shopping-cart",
		Commands:                  commands,
		DisableSliceFlagSeparator: true,
	}, nil
}

// NewShoppingCartCliCommand initializes a cli command for a example.shoppingcart.v1.ShoppingCart service with subcommands for each query, signal, update, and workflow
func NewShoppingCartCliCommand(options ...*ShoppingCartCliOptions) (*v2.Command, error) {
	subcommands, err := newShoppingCartCommands(options...)
	if err != nil {
		return nil, fmt.Errorf("error initializing subcommands: %w", err)
	}
	return &v2.Command{
		Name:        "shopping-cart",
		Subcommands: subcommands,
	}, nil
}

// newShoppingCartCommands initializes (sub)commands for a example.shoppingcart.v1.ShoppingCart cli or command
func newShoppingCartCommands(options ...*ShoppingCartCliOptions) ([]*v2.Command, error) {
	opts := &ShoppingCartCliOptions{}
	if len(options) > 0 {
		opts = options[0]
	}
	if opts.clientForCommand == nil {
		opts.clientForCommand = func(*v2.Context) (client.Client, error) {
			return client.Dial(client.Options{})
		}
	}
	commands := []*v2.Command{
		{
			Name:                   "describe",
			Usage:                  "executes a example.shoppingcart.v1.ShoppingCart.Describe query and blocks until error or response received",
			Category:               "QUERIES",
			UseShortOptionHandling: true,
			Before:                 opts.before,
			After:                  opts.after,
			Flags: []v2.Flag{
				&v2.StringFlag{
					Name:     "workflow-id",
					Usage:    "workflow id",
					Required: true,
					Aliases:  []string{"w"},
				},
				&v2.StringFlag{
					Name:    "run-id",
					Usage:   "run id",
					Aliases: []string{"r"},
				},
				&v2.StringFlag{
					Name:     "input-file",
					Usage:    "path to json-formatted input file",
					Aliases:  []string{"f"},
					Category: "INPUT",
				},
			},
			Action: func(cmd *v2.Context) error {
				c, err := opts.clientForCommand(cmd)
				if err != nil {
					return fmt.Errorf("error initializing client for command: %w", err)
				}
				defer c.Close()
				client := NewShoppingCartClient(c)
				req, err := UnmarshalCliFlagsToDescribeInput(cmd, helpers.UnmarshalCliFlagsOptions{FromFile: "input-file"})
				if err != nil {
					return fmt.Errorf("error unmarshalling request: %w", err)
				}
				if resp, err := client.Describe(cmd.Context, cmd.String("workflow-id"), cmd.String("run-id"), req); err != nil {
					return fmt.Errorf("error executing %q query: %w", DescribeQueryName, err)
				} else {
					b, err := protojson.Marshal(resp)
					if err != nil {
						return fmt.Errorf("error serializing response json: %w", err)
					}
					var out bytes.Buffer
					if err := json.Indent(&out, b, "", "  "); err != nil {
						return fmt.Errorf("error formatting json: %w", err)
					}
					fmt.Println(out.String())
					return nil
				}
			},
		},
		{
			Name:                   "checkout",
			Usage:                  "executes a example.shoppingcart.v1.ShoppingCart.Checkout signal",
			Category:               "SIGNALS",
			UseShortOptionHandling: true,
			Before:                 opts.before,
			After:                  opts.after,
			Flags: []v2.Flag{
				&v2.StringFlag{
					Name:     "workflow-id",
					Usage:    "workflow id",
					Required: true,
					Aliases:  []string{"w"},
				},
				&v2.StringFlag{
					Name:    "run-id",
					Usage:   "run id",
					Aliases: []string{"r"},
				},
				&v2.StringFlag{
					Name:     "input-file",
					Usage:    "path to json-formatted input file",
					Aliases:  []string{"f"},
					Category: "INPUT",
				},
			},
			Action: func(cmd *v2.Context) error {
				c, err := opts.clientForCommand(cmd)
				if err != nil {
					return fmt.Errorf("error initializing client for command: %w", err)
				}
				defer c.Close()
				client := NewShoppingCartClient(c)
				req, err := UnmarshalCliFlagsToCheckoutInput(cmd, helpers.UnmarshalCliFlagsOptions{FromFile: "input-file"})
				if err != nil {
					return fmt.Errorf("error unmarshalling request: %w", err)
				}
				if err := client.Checkout(cmd.Context, cmd.String("workflow-id"), cmd.String("run-id"), req); err != nil {
					return fmt.Errorf("error sending %q signal: %w", CheckoutSignalName, err)
				}
				fmt.Println("success")
				return nil
			},
		},
		{
			Name:                   "update-cart",
			Usage:                  "executes a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart update",
			Category:               "UPDATES",
			UseShortOptionHandling: true,
			Before:                 opts.before,
			After:                  opts.after,
			Flags: []v2.Flag{
				&v2.BoolFlag{
					Name:    "detach",
					Usage:   "run workflow update in the background and print workflow, execution, and udpate id",
					Aliases: []string{"d"},
				},
				&v2.StringFlag{
					Name:     "workflow-id",
					Usage:    "workflow id",
					Required: true,
					Aliases:  []string{"w"},
				},
				&v2.StringFlag{
					Name:    "run-id",
					Usage:   "run id",
					Aliases: []string{"r"},
				},
				&v2.StringFlag{
					Name:     "input-file",
					Usage:    "path to json-formatted input file",
					Aliases:  []string{"f"},
					Category: "INPUT",
				},
				&v2.StringFlag{
					Name:     "action",
					Usage:    "set the value of the operation's \"Action\" parameter (UPDATE_CART_ACTION_UNSPECIFIED, UPDATE_CART_ACTION_ADD, UPDATE_CART_ACTION_REMOVE)",
					Category: "INPUT",
				},
				&v2.StringFlag{
					Name:     "item-id",
					Usage:    "set the value of the operation's \"ItemId\" parameter",
					Category: "INPUT",
				},
			},
			Action: func(cmd *v2.Context) error {
				c, err := opts.clientForCommand(cmd)
				if err != nil {
					return fmt.Errorf("error initializing client for command: %w", err)
				}
				defer c.Close()
				client := NewShoppingCartClient(c)
				req, err := UnmarshalCliFlagsToUpdateCartInput(cmd, helpers.UnmarshalCliFlagsOptions{FromFile: "input-file"})
				if err != nil {
					return fmt.Errorf("error unmarshalling request: %w", err)
				}
				handle, err := client.UpdateCartAsync(cmd.Context, cmd.String("workflow-id"), cmd.String("run-id"), req)
				if err != nil {
					return fmt.Errorf("error executing %s update: %w", UpdateCartUpdateName, err)
				}
				if cmd.Bool("detach") {
					fmt.Println("success")
					fmt.Printf("workflow id: %s\n", handle.WorkflowID())
					fmt.Printf("run id: %s\n", handle.RunID())
					fmt.Printf("update id: %s\n", handle.UpdateID())
					return nil
				}
				if resp, err := handle.Get(cmd.Context); err != nil {
					return err
				} else {
					b, err := protojson.Marshal(resp)
					if err != nil {
						return fmt.Errorf("error serializing response json: %w", err)
					}
					var out bytes.Buffer
					if err := json.Indent(&out, b, "", "  "); err != nil {
						return fmt.Errorf("error formatting json: %w", err)
					}
					fmt.Println(out.String())
					return nil
				}
			},
		},
		{
			Name:                   "shopping-cart",
			Usage:                  "executes a(n) example.shoppingcart.v1.ShoppingCart workflow",
			Category:               "WORKFLOWS",
			UseShortOptionHandling: true,
			Before:                 opts.before,
			After:                  opts.after,
			Flags: []v2.Flag{
				&v2.BoolFlag{
					Name:    "detach",
					Usage:   "run workflow in the background and print workflow and execution id",
					Aliases: []string{"d"},
				},
				&v2.StringFlag{
					Name:    "task-queue",
					Usage:   "task queue name",
					Aliases: []string{"t"},
					EnvVars: []string{"TEMPORAL_TASK_QUEUE_NAME", "TEMPORAL_TASK_QUEUE", "TASK_QUEUE_NAME", "TASK_QUEUE"},
					Value:   "example-shoppingcart-v1",
				},
				&v2.StringFlag{
					Name:     "input-file",
					Usage:    "path to json-formatted input file",
					Aliases:  []string{"f"},
					Category: "INPUT",
				},
				&v2.StringFlag{
					Name:     "cart",
					Usage:    "set the value of the operation's \"Cart\" parameter (json-encoded: {items: <example.shoppingcart.v1.CartState.ItemsEntry>})",
					Category: "INPUT",
				},
			},
			Action: func(cmd *v2.Context) error {
				tc, err := opts.clientForCommand(cmd)
				if err != nil {
					return fmt.Errorf("error initializing client for command: %w", err)
				}
				defer tc.Close()
				c := NewShoppingCartClient(tc)
				req, err := UnmarshalCliFlagsToShoppingCartInput(cmd, helpers.UnmarshalCliFlagsOptions{FromFile: "input-file"})
				if err != nil {
					return fmt.Errorf("error unmarshalling request: %w", err)
				}
				opts := client.StartWorkflowOptions{}
				if tq := cmd.String("task-queue"); tq != "" {
					opts.TaskQueue = tq
				}
				run, err := c.ShoppingCartAsync(cmd.Context, req, NewShoppingCartOptions().WithStartWorkflowOptions(opts))
				if err != nil {
					return fmt.Errorf("error starting %s workflow: %w", ShoppingCartWorkflowName, err)
				}
				if cmd.Bool("detach") {
					fmt.Println("success")
					fmt.Printf("workflow id: %s\n", run.ID())
					fmt.Printf("run id: %s\n", run.RunID())
					return nil
				}
				if resp, err := run.Get(cmd.Context); err != nil {
					return err
				} else {
					b, err := protojson.Marshal(resp)
					if err != nil {
						return fmt.Errorf("error serializing response json: %w", err)
					}
					var out bytes.Buffer
					if err := json.Indent(&out, b, "", "  "); err != nil {
						return fmt.Errorf("error formatting json: %w", err)
					}
					fmt.Println(out.String())
					return nil
				}
			},
		},
		// executes a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart update on a example.shoppingcart.v1.ShoppingCart.ShoppingCart workflow, starting it if necessary,
		{
			Action: func(cmd *v2.Context) error {
				c, err := opts.clientForCommand(cmd)
				if err != nil {
					return fmt.Errorf("error initializing client for command: %w", err)
				}
				defer c.Close()
				client := NewShoppingCartClient(c)
				input, err := UnmarshalCliFlagsToShoppingCartInput(cmd, helpers.UnmarshalCliFlagsOptions{FromFile: "input-file"})
				if err != nil {
					return fmt.Errorf("error unmarshalling input: %w", err)
				}
				update, err := UnmarshalCliFlagsToUpdateCartInput(cmd, helpers.UnmarshalCliFlagsOptions{FromFile: "update-file"})
				if err != nil {
					return fmt.Errorf("error unmarshalling update: %w", err)
				}
				handle, _, err := client.ShoppingCartWithUpdateCartAsync(cmd.Context, input, update)
				if err != nil {
					return fmt.Errorf("error starting workflow with update: %w", err)
				}
				if cmd.Bool("detach") {
					fmt.Println("success")
					fmt.Printf("workflow id: %s\n", handle.WorkflowID())
					fmt.Printf("run id: %s\n", handle.RunID())
					fmt.Printf("update id: %s\n", handle.UpdateID())
					return nil
				}
				if out, err := handle.Get(cmd.Context); err != nil {
					return err
				} else {
					b, err := protojson.Marshal(out)
					if err != nil {
						return fmt.Errorf("error serializing response json: %w", err)
					}
					var out bytes.Buffer
					if err := json.Indent(&out, b, "", "  "); err != nil {
						return fmt.Errorf("error formatting json: %w", err)
					}
					fmt.Println(out.String())
					return nil
				}
			},
			After:    opts.after,
			Before:   opts.before,
			Category: "WORKFLOWS",
			Flags: []v2.Flag{
				&v2.BoolFlag{
					Aliases: []string{"d"},
					Name:    "detach",
					Usage:   "run workflow update in the background and print workflow, execution, and update id",
				},
				&v2.StringFlag{
					Aliases:  []string{"f"},
					Category: "INPUT",
					Name:     "input-file",
					Usage:    "path to json-formatted input file",
				},
				&v2.StringFlag{
					Name:     "cart",
					Usage:    "set the value of the operation's \"Cart\" parameter (json-encoded: {items: <example.shoppingcart.v1.CartState.ItemsEntry>})",
					Category: "INPUT",
				},
				&v2.StringFlag{
					Aliases:  []string{"u"},
					Category: "UPDATE",
					Name:     "update-file",
					Usage:    "path to json-formatted update file",
				},
				&v2.StringFlag{
					Name:     "action",
					Usage:    "set the value of the operation's \"Action\" parameter (UPDATE_CART_ACTION_UNSPECIFIED, UPDATE_CART_ACTION_ADD, UPDATE_CART_ACTION_REMOVE)",
					Category: "UPDATE",
				},
				&v2.StringFlag{
					Name:     "item-id",
					Usage:    "set the value of the operation's \"ItemId\" parameter",
					Category: "UPDATE",
				},
			},
			Name:                   "shopping-cart-with-update-cart",
			Usage:                  "executes a(n) example.shoppingcart.v1.ShoppingCart.UpdateCart update on a example.shoppingcart.v1.ShoppingCart.ShoppingCart workflow, starting it if necessary",
			UseShortOptionHandling: true,
		},
	}
	if opts.worker != nil {
		commands = append(commands, []*v2.Command{
			{
				Name:                   "worker",
				Usage:                  "runs a example.shoppingcart.v1.ShoppingCart worker process",
				UseShortOptionHandling: true,
				Before:                 opts.before,
				After:                  opts.after,
				Action: func(cmd *v2.Context) error {
					c, err := opts.clientForCommand(cmd)
					if err != nil {
						return fmt.Errorf("error initializing client for command: %w", err)
					}
					defer c.Close()
					w, err := opts.worker(cmd, c)
					if opts.worker != nil {
						if err != nil {
							return fmt.Errorf("error initializing worker: %w", err)
						}
					}
					if err := w.Start(); err != nil {
						return fmt.Errorf("error starting worker: %w", err)
					}
					defer w.Stop()
					<-cmd.Context.Done()
					return nil
				},
			},
		}...)
	}
	sort.Slice(commands, func(i, j int) bool {
		return commands[i].Name < commands[j].Name
	})
	return commands, nil
}

// UnmarshalCliFlagsToDescribeInput unmarshals a DescribeInput from command line flags
func UnmarshalCliFlagsToDescribeInput(cmd *v2.Context, options ...helpers.UnmarshalCliFlagsOptions) (*DescribeInput, error) {
	opts := helpers.FlattenUnmarshalCliFlagsOptions(options...)
	var result DescribeInput
	if opts.FromFile != "" && cmd.IsSet(opts.FromFile) {
		f, err := gohomedir.Expand(cmd.String(opts.FromFile))
		if err != nil {
			f = cmd.String(opts.FromFile)
		}
		b, err := os.ReadFile(f)
		if err != nil {
			return nil, fmt.Errorf("error reading %s: %w", opts.FromFile, err)
		}
		if err := protojson.Unmarshal(b, &result); err != nil {
			return nil, fmt.Errorf("error parsing %s json: %w", opts.FromFile, err)
		}
	}
	return &result, nil
}

// UnmarshalCliFlagsToCheckoutInput unmarshals a CheckoutInput from command line flags
func UnmarshalCliFlagsToCheckoutInput(cmd *v2.Context, options ...helpers.UnmarshalCliFlagsOptions) (*CheckoutInput, error) {
	opts := helpers.FlattenUnmarshalCliFlagsOptions(options...)
	var result CheckoutInput
	if opts.FromFile != "" && cmd.IsSet(opts.FromFile) {
		f, err := gohomedir.Expand(cmd.String(opts.FromFile))
		if err != nil {
			f = cmd.String(opts.FromFile)
		}
		b, err := os.ReadFile(f)
		if err != nil {
			return nil, fmt.Errorf("error reading %s: %w", opts.FromFile, err)
		}
		if err := protojson.Unmarshal(b, &result); err != nil {
			return nil, fmt.Errorf("error parsing %s json: %w", opts.FromFile, err)
		}
	}
	return &result, nil
}

// UnmarshalCliFlagsToUpdateCartInput unmarshals a UpdateCartInput from command line flags
func UnmarshalCliFlagsToUpdateCartInput(cmd *v2.Context, options ...helpers.UnmarshalCliFlagsOptions) (*UpdateCartInput, error) {
	opts := helpers.FlattenUnmarshalCliFlagsOptions(options...)
	var result UpdateCartInput
	if opts.FromFile != "" && cmd.IsSet(opts.FromFile) {
		f, err := gohomedir.Expand(cmd.String(opts.FromFile))
		if err != nil {
			f = cmd.String(opts.FromFile)
		}
		b, err := os.ReadFile(f)
		if err != nil {
			return nil, fmt.Errorf("error reading %s: %w", opts.FromFile, err)
		}
		if err := protojson.Unmarshal(b, &result); err != nil {
			return nil, fmt.Errorf("error parsing %s json: %w", opts.FromFile, err)
		}
	}
	if flag := opts.FlagName("action"); cmd.IsSet(flag) {
		enumID, ok := UpdateCartAction_value[cmd.String(flag)]
		if !ok {
			return nil, fmt.Errorf("invalid value for enum field %s", "Action")
		}
		value := UpdateCartAction(enumID)
		result.Action = value
	}
	if flag := opts.FlagName("item-id"); cmd.IsSet(flag) {
		value := cmd.String(flag)
		result.ItemId = value
	}
	return &result, nil
}

// UnmarshalCliFlagsToShoppingCartInput unmarshals a ShoppingCartInput from command line flags
func UnmarshalCliFlagsToShoppingCartInput(cmd *v2.Context, options ...helpers.UnmarshalCliFlagsOptions) (*ShoppingCartInput, error) {
	opts := helpers.FlattenUnmarshalCliFlagsOptions(options...)
	var result ShoppingCartInput
	if opts.FromFile != "" && cmd.IsSet(opts.FromFile) {
		f, err := gohomedir.Expand(cmd.String(opts.FromFile))
		if err != nil {
			f = cmd.String(opts.FromFile)
		}
		b, err := os.ReadFile(f)
		if err != nil {
			return nil, fmt.Errorf("error reading %s: %w", opts.FromFile, err)
		}
		if err := protojson.Unmarshal(b, &result); err != nil {
			return nil, fmt.Errorf("error parsing %s json: %w", opts.FromFile, err)
		}
	}
	if flag := opts.FlagName("cart"); cmd.IsSet(flag) {
		var tmp CartState
		if err := protojson.Unmarshal([]byte(cmd.String(flag)), &tmp); err != nil {
			return nil, fmt.Errorf("error unmarshalling \"cart\" flag: %w", err)
		}
		value := &tmp
		result.Cart = value
	}
	return &result, nil
}

// WithShoppingCartSchemeTypes registers all ShoppingCart protobuf types with the given scheme
func WithShoppingCartSchemeTypes() scheme.Option {
	return func(s *scheme.Scheme) {
		s.RegisterType(File_example_shoppingcart_v1_shoppingcart_proto.Messages().ByName("DescribeInput"))
		s.RegisterType(File_example_shoppingcart_v1_shoppingcart_proto.Messages().ByName("DescribeOutput"))
		s.RegisterType(File_example_shoppingcart_v1_shoppingcart_proto.Messages().ByName("CheckoutInput"))
		s.RegisterType(File_example_shoppingcart_v1_shoppingcart_proto.Messages().ByName("UpdateCartInput"))
		s.RegisterType(File_example_shoppingcart_v1_shoppingcart_proto.Messages().ByName("UpdateCartOutput"))
		s.RegisterType(File_example_shoppingcart_v1_shoppingcart_proto.Messages().ByName("ShoppingCartInput"))
		s.RegisterType(File_example_shoppingcart_v1_shoppingcart_proto.Messages().ByName("ShoppingCartOutput"))
	}
}
