// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.29.0
// source: ontology.sql

package sqlcgen

import (
	"context"
)

const getLifecycleForType = `-- name: GetLifecycleForType :one
SELECT ld.id, ld.states, ld.default_state, ld.terminal_states, ld.transitions, ld.created_at FROM lifecycle_defs ld
JOIN entity_types et ON et.lifecycle_id = ld.id
WHERE et.name = $1
`

func (q *Queries) GetLifecycleForType(ctx context.Context, name string) (LifecycleDef, error) {
	row := q.db.QueryRow(ctx, getLifecycleForType, name)
	var i LifecycleDef
	err := row.Scan(
		&i.ID,
		&i.States,
		&i.DefaultState,
		&i.TerminalStates,
		&i.Transitions,
		&i.CreatedAt,
	)
	return i, err
}

const listEntityTypes = `-- name: ListEntityTypes :many
SELECT name, parent_type, is_abstract, domain, layer, description, lifecycle_id, attribute_schema, schema_version, status, created_at, updated_at, monitoring_spec FROM entity_types ORDER BY name
`

func (q *Queries) ListEntityTypes(ctx context.Context) ([]EntityType, error) {
	rows, err := q.db.Query(ctx, listEntityTypes)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	var items []EntityType
	for rows.Next() {
		var i EntityType
		if err := rows.Scan(
			&i.Name,
			&i.ParentType,
			&i.IsAbstract,
			&i.Domain,
			&i.Layer,
			&i.Description,
			&i.LifecycleID,
			&i.AttributeSchema,
			&i.SchemaVersion,
			&i.Status,
			&i.CreatedAt,
			&i.UpdatedAt,
			&i.MonitoringSpec,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const listLifecycleDefs = `-- name: ListLifecycleDefs :many
SELECT id, states, default_state, terminal_states, transitions, created_at FROM lifecycle_defs ORDER BY id
`

func (q *Queries) ListLifecycleDefs(ctx context.Context) ([]LifecycleDef, error) {
	rows, err := q.db.Query(ctx, listLifecycleDefs)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	var items []LifecycleDef
	for rows.Next() {
		var i LifecycleDef
		if err := rows.Scan(
			&i.ID,
			&i.States,
			&i.DefaultState,
			&i.TerminalStates,
			&i.Transitions,
			&i.CreatedAt,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const listRelationshipTypes = `-- name: ListRelationshipTypes :many
SELECT name, inverse, source_type, target_type, cardinality, description, created_at, blast_direction FROM relationship_types ORDER BY name
`

func (q *Queries) ListRelationshipTypes(ctx context.Context) ([]RelationshipType, error) {
	rows, err := q.db.Query(ctx, listRelationshipTypes)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	var items []RelationshipType
	for rows.Next() {
		var i RelationshipType
		if err := rows.Scan(
			&i.Name,
			&i.Inverse,
			&i.SourceType,
			&i.TargetType,
			&i.Cardinality,
			&i.Description,
			&i.CreatedAt,
			&i.BlastDirection,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}
