namespace NpgsqlRest; public class Routine { /// /// Routine type: Function, Procedure, Table, View, or other. /// public required RoutineType Type { get; init; } /// /// Schema name (parsed by quote_ident). /// public required string Schema { get; init; } /// /// PostgreSQL object name (parsed by quote_ident). /// public required string Name { get; init; } /// /// PostgreSQL object comment. /// public required string? Comment { get; init; } /// /// Strict or non-strict function. Strict functions will return NULL if any parameter is NULL. /// public required bool IsStrict { get; init; } /// /// The type of CRUD operation associated with the routine (Select, Insert, Update or Delete). /// public required CrudType CrudType { get; init; } /// /// Indicates whether the routine returns a PostgreSQL record type. /// public required bool ReturnsRecordType { get; init; } /// /// Indicates whether the routine returns a set of records or single record. /// public required bool ReturnsSet { get; init; } /// /// The number of columns returned. /// public required int ColumnCount { get; init; } /// /// The names of the returned columns. /// public required string[] OriginalColumnNames { get; init; } /// /// The converted names of the returned columns. /// public required string[] ColumnNames { get; init; } /// /// Pre-escaped JSON key strings for the returned columns (output of PgConverters.SerializeString). /// public required string[] JsonColumnNames { get; init; } /// /// The type descriptors for the returned columns. /// public required TypeDescriptor[] ColumnsTypeDescriptor { get; init; } /// /// Indicates whether the routine returns an unnamed set. /// public required bool ReturnsUnnamedSet { get; init; } /// /// Indicates whether the routine returns void. /// public required bool IsVoid { get; init; } /// /// The number of parameters. /// public required int ParamCount { get; init; } /// /// Parameters associated with the routine in the order they appear in the routine. /// public required NpgsqlRestParameter[] Parameters { get; init; } /// /// The hash of the parameters associated with the routine. /// public required HashSet ParamsHash { get; init; } /// /// The hash of the parameters associated with the routine. /// public required HashSet OriginalParamsHash { get; init; } /// /// The expression associated with the routine. /// public required string Expression { get; init; } /// /// The full definition of the routine. (Used for code-gen comments) /// public required string FullDefinition { get; init; } /// /// The simple definition of the routine. (Used for code-gen comments) /// public required string SimpleDefinition { get; init; } /// /// The format URL pattern for the routine. If used (not null), placeholder {0} is used to replace the default URL. /// public required string? FormatUrlPattern { get; init; } /// /// The tags associated with the routine. /// public required string[]? Tags { get; init; } /// /// The endpoint handler for the routine. /// public required Func? EndpointHandler { get; init; } /// /// Routine is immutable. Will return same results for same inputs. /// public bool Immutable { get; init; } = false; /// /// The meta data associated with the routine. /// public required object? Metadata { get; init; } internal bool[]? UnknownResultTypeList { get; set; } = null; /// /// When NestedJsonForCompositeTypes is enabled via comment annotation, this contains information /// about which columns are composite types and their field names/types for nested JSON serialization. /// Key: first expanded column index for the composite type /// Value: (fieldNames, fieldDescriptors, convertedColumnName, expandedColumnIndices) /// public Dictionary? CompositeColumnInfo { get; set; } = null; /// /// When NestedJsonForCompositeTypes is enabled, this contains information about columns that are /// arrays of composite types. These arrays need special serialization to convert from PostgreSQL /// tuple format {"(f1,f2,f3)"} to JSON array of objects [{"field1":f1,"field2":f2}]. /// Key: column index (0-based) /// Value: (fieldNames for the composite element type, fieldDescriptors for each field) /// public Dictionary? ArrayCompositeColumnInfo { get; set; } = null; /// /// For multi-command SQL files: per-command column metadata and command names. /// When not null, the rendering uses NpgsqlBatch + NextResult() to iterate result sets /// and wraps them in a JSON object {resultName: [rows], ...}. Void commands get null. /// public MultiCommandInfo[]? MultiCommandInfo { get; set; } = null; /// /// True if this routine uses multi-command rendering (JSON object with named result sets). /// public bool IsMultiCommand => MultiCommandInfo is not null; /// /// When true, multi-command log includes full SQL text. When false, only file path and statement count. /// public bool LogCommandText { get; set; } } /// /// Metadata for one command in a multi-command SQL file endpoint. /// public class MultiCommandInfo { /// /// Result key name in the JSON response. From positional @result annotation or default pattern. /// public required string Name { get; init; } /// /// Pre-escaped JSON key string for the result name (output of PgConverters.SerializeString). /// public required string JsonName { get; init; } /// /// The SQL statement for this command. /// public required string Statement { get; init; } /// /// Number of parameters this command uses (max $N index). /// public required int ParamCount { get; init; } /// /// Column count for this command's result set. 0 for void commands. /// public required int ColumnCount { get; init; } /// /// Column names for this command's result set (camelCase converted). /// public required string[] ColumnNames { get; init; } /// /// Pre-escaped JSON key strings for this command's result columns. /// public required string[] JsonColumnNames { get; init; } /// /// Type descriptors for this command's result columns. /// public required TypeDescriptor[] ColumnTypeDescriptors { get; init; } /// /// When true, this command returns a flat array of values instead of objects. /// public bool ReturnsUnnamedSet { get; init; } /// /// When true, only the first row of this command's result set is returned as a JSON object /// instead of a JSON array. Configured via positional @single annotation. /// public bool IsSingle { get; init; } /// /// When true, this command is executed for side effects but produces no result key /// in the JSON response. Used for transaction control, session commands, DO blocks, /// and the @skip annotation. /// public bool IsSkipped { get; init; } }