{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/beef-database-codegen/latest.json",
  "title": "JSON Schema for Beef Database code-generation (https://github.com/Avanade/Beef).",
  "x-lintel": {
    "source": "https://raw.githubusercontent.com/Avanade/Beef/master/tools/Beef.CodeGen.Core/Schema/database.beef.json",
    "sourceSha256": "33dc2b09dbae8ee401056c03c67c764dbc2a717018db55f8d0c53704d80ebb3c",
    "fileMatch": [
      "database.beef.yaml",
      "database.beef.yml",
      "database.beef.json"
    ],
    "parsers": [
      "json",
      "yaml"
    ]
  },
  "allOf": [
    {
      "$ref": "#/$defs/CodeGeneration"
    }
  ],
  "$defs": {
    "CodeGeneration": {
      "type": "object",
      "title": "'CodeGeneration' object (database-driven)",
      "description": "The 'CodeGeneration' object defines global properties that are used to drive the underlying database-driven code generation.",
      "properties": {
        "schema": {
          "type": "string",
          "title": "The name of the 'Schema' where the artefacts are defined in, or should be created in, the database.",
          "description": "This is used as the default 'Schema' for all child objects."
        },
        "columnNameIsDeleted": {
          "type": "string",
          "title": "The column name for the 'IsDeleted' capability.",
          "description": "Defaults to 'IsDeleted'."
        },
        "columnNameTenantId": {
          "type": "string",
          "title": "The column name for the 'TenantId' capability.",
          "description": "Defaults to 'TenantId'."
        },
        "columnNameOrgUnitId": {
          "type": "string",
          "title": "The column name for the 'OrgUnitId' capability.",
          "description": "Defaults to 'OrgUnitId'."
        },
        "columnNameRowVersion": {
          "type": "string",
          "title": "The column name for the 'RowVersion' capability.",
          "description": "Defaults to 'RowVersion'."
        },
        "columnNameCreatedBy": {
          "type": "string",
          "title": "The column name for the 'CreatedBy' capability.",
          "description": "Defaults to 'CreatedBy'."
        },
        "columnNameCreatedDate": {
          "type": "string",
          "title": "The column name for the 'CreatedDate' capability.",
          "description": "Defaults to 'CreatedDate'."
        },
        "columnNameUpdatedBy": {
          "type": "string",
          "title": "The column name for the 'UpdatedBy' capability.",
          "description": "Defaults to 'UpdatedBy'."
        },
        "columnNameUpdatedDate": {
          "type": "string",
          "title": "The column name for the 'UpdatedDate' capability.",
          "description": "Defaults to 'UpdatedDate'."
        },
        "columnNameDeletedBy": {
          "type": "string",
          "title": "The column name for the 'DeletedBy' capability.",
          "description": "Defaults to 'UpdatedBy'."
        },
        "columnNameDeletedDate": {
          "type": "string",
          "title": "The column name for the 'DeletedDate' capability.",
          "description": "Defaults to 'UpdatedDate'."
        },
        "orgUnitJoinSql": {
          "type": "string",
          "title": "The SQL table or function that is to be used to join against for security-based 'OrgUnitId' verification.",
          "description": "Defaults to '[Sec].[fnGetUserOrgUnits]()'."
        },
        "checkUserPermissionSql": {
          "type": "string",
          "title": "The SQL stored procedure that is to be used for 'Permission' verification.",
          "description": "Defaults to '[Sec].[spCheckUserHasPermission]'."
        },
        "getUserPermissionSql": {
          "type": "string",
          "title": "The SQL function that is to be used for 'Permission' verification.",
          "description": "Defaults to '[Sec].[fnGetUserHasPermission]'."
        },
        "cdcSchema": {
          "type": "string",
          "title": "The schema name for the generated 'CDC'-related database artefacts.",
          "description": "Defaults to 'XCdc' (literal)."
        },
        "cdcAuditTableName": {
          "type": "string",
          "title": "The table name for the 'Cdc'-Tracking.",
          "description": "Defaults to 'CdcTracking' (literal)."
        },
        "cdcIdentifierMapping": {
          "type": "boolean",
          "title": "Indicates whether to include the generation of the generic 'Cdc'-IdentifierMapping database capabilities."
        },
        "cdcIdentifierMappingTableName": {
          "type": "string",
          "title": "The table name for the 'Cdc'-IdentifierMapping.",
          "description": "Defaults to 'CdcIdentifierMapping' (literal)."
        },
        "cdcIdentifierMappingStoredProcedureName": {
          "type": "string",
          "title": "The table name for the 'Cdc'-IdentifierMapping.",
          "description": "Defaults to 'spCreateCdcIdentifierMapping' (literal)."
        },
        "cdcExcludeColumnsFromETag": {
          "type": "array",
          "title": "The default list of 'Column' names that should be excluded from the generated ETag (used for the likes of duplicate send tracking)",
          "items": {
            "type": "string"
          }
        },
        "jsonSerializer": {
          "type": "string",
          "title": "The JSON Serializer to use for JSON property attribution.",
          "description": "Defaults to 'Newtonsoft'. This can be overridden within the 'Entity'(s).",
          "enum": [
            "None",
            "Newtonsoft"
          ]
        },
        "pluralizeCollectionProperties": {
          "type": "boolean",
          "title": "Indicates whether the .NET collection properties should be pluralized."
        },
        "hasBeefDbo": {
          "type": "boolean",
          "title": "Indicates whether the database has (contains) the standard _Beef_ 'dbo' schema objects.",
          "description": "Defaults to 'true'."
        },
        "autoDotNetRename": {
          "type": "string",
          "title": "The option to automatically rename the SQL Tables and Columns for use in .NET.",
          "description": "Defaults 'SnakeKebabToPascalCase' that will remove any underscores or hyphens separating each word and capitalize the first character of each; e.g. 'internal-customer_id' would be renamed as 'InternalCustomerId'. The 'PascalCase' option will capatilize the first character only.",
          "enum": [
            "None",
            "PascalCase",
            "SnakeKebabToPascalCase"
          ]
        },
        "entityScope": {
          "type": "string",
          "title": "The entity scope option.",
          "description": "Defaults to 'Common' for backwards compatibility; 'Autonomous' is recommended. Determines where the entity is scoped/defined, being 'Common' or 'Business' (i.e. not externally visible).",
          "enum": [
            "Common",
            "Business",
            "Autonomous"
          ]
        },
        "eventSubjectRoot": {
          "type": "string",
          "title": "The root for the event name by prepending to all event subject names via CDC.",
          "description": "Used to enable the sending of messages to the likes of EventHub, Service Broker, SignalR, etc. This can be extended within the 'Entity'(s)."
        },
        "eventSubjectFormat": {
          "type": "string",
          "title": "The default formatting for the Subject when an Event is published via CDC.",
          "description": "Defaults to 'NameAndKey' (being the event subject name appended with the corresponding unique key.)'.",
          "enum": [
            "NameOnly",
            "NameAndKey"
          ]
        },
        "eventActionFormat": {
          "type": "string",
          "title": "The formatting for the Action when an Event is published via CDC.",
          "description": "Defaults to 'None' (no formatting required, i.e. as-is).",
          "enum": [
            "None",
            "PastTense"
          ]
        },
        "eventSourceRoot": {
          "type": "string",
          "title": "The URI root for the event source by prepending to all event source URIs for CDC.",
          "description": "The event source is only updated where an 'EventSourceKind' is not 'None'. This can be extended within the 'Entity'(s)."
        },
        "eventSourceKind": {
          "type": "string",
          "title": "The URI kind for the event source URIs for CDC.",
          "description": "Defaults to 'None' (being the event source is not updated).",
          "enum": [
            "None",
            "Absolute",
            "Relative",
            "RelativeOrAbsolute"
          ]
        },
        "eventSourceFormat": {
          "type": "string",
          "title": "The default formatting for the Source when an Event is published via CDC.",
          "description": "Defaults to 'NameAndKey' (being the event subject name appended with the corresponding unique key.)'.",
          "enum": [
            "NameOnly",
            "NameAndKey",
            "NameAndGlobalId"
          ]
        },
        "eventOutbox": {
          "type": "boolean",
          "title": "Indicates whether events will publish using the outbox pattern and therefore the event outbox artefacts are required."
        },
        "eventOutboxTableName": {
          "type": "string",
          "title": "The table name for the 'EventOutbox'.",
          "description": "Defaults to 'EventOutbox' (literal)."
        },
        "pathBase": {
          "type": "string",
          "title": "The base path (directory) prefix for the Database-related artefacts; other 'Path*' properties append to this value when they are not specifically overridden.",
          "description": "Defaults to 'Company' (runtime parameter) + '.' + 'AppName' (runtime parameter). For example 'Beef.Demo'."
        },
        "pathDatabaseSchema": {
          "type": "string",
          "title": "The path (directory) for the Schema Database-related artefacts.",
          "description": "Defaults to 'PathBase' + '.Database/Schema' (literal). For example 'Beef.Demo.Database/Schema'."
        },
        "pathDatabaseMigrations": {
          "type": "string",
          "title": "The path (directory) for the Schema Database-related artefacts.",
          "description": "Defaults to 'PathBase' + '.Database/Migrations' (literal). For example 'Beef.Demo.Database/Migrations'."
        },
        "pathBusiness": {
          "type": "string",
          "title": "The path (directory) for the Business-related (.NET) artefacts.",
          "description": "Defaults to 'PathBase' + '.Business' (literal). For example 'Beef.Demo.Business'."
        },
        "PathCdcPublisher": {
          "type": "string",
          "title": "The path (directory) for the CDC-related (.NET) artefacts.",
          "description": "Defaults to 'PathBase' + '.Cdc' (literal). For example 'Beef.Demo.Cdc'."
        },
        "orgUnitImmutable": {
          "type": "boolean",
          "title": "Indicates whether the 'OrgUnitId' column is considered immutable, in that it can not be changed once set.",
          "description": "This is only applicable for stored procedures."
        },
        "namespaceBase": {
          "type": "string",
          "title": "The base Namespace (root) for the .NET artefacts.",
          "description": "Defaults to 'Company' (runtime parameter) + '.' + 'AppName' (runtime parameter). For example 'Beef.Demo'."
        },
        "namespaceCommon": {
          "type": "string",
          "title": "The Namespace (root) for the Common-related .NET artefacts.",
          "description": "Defaults to 'NamespaceBase' + '.Common' (literal). For example 'Beef.Demo.Common'."
        },
        "namespaceBusiness": {
          "type": "string",
          "title": "The Namespace (root) for the Business-related .NET artefacts.",
          "description": "Defaults to 'NamespaceBase' + '.Business' (literal). For example 'Beef.Demo.Business'."
        },
        "NamespaceCdcPublisher": {
          "type": "string",
          "title": "The Namespace (root) for the CDC-related publisher .NET artefacts.",
          "description": "Defaults to 'NamespaceBase' + '.CdcPublisher' (literal). For example 'Beef.Demo.CdcPublisher'."
        },
        "tables": {
          "type": "array",
          "title": "The corresponding 'Table' collection.",
          "items": {
            "$ref": "#/$defs/Table"
          }
        },
        "queries": {
          "type": "array",
          "title": "The corresponding 'Query' collection.",
          "items": {
            "$ref": "#/$defs/Query"
          }
        }
      }
    },
    "Table": {
      "type": "object",
      "title": "'Table' object (entity-driven)",
      "description": "The 'Table' object identifies an existing database 'Table' (or 'View') and defines its code-generation characteristics.",
      "properties": {
        "name": {
          "type": "string",
          "title": "The name of the 'Table' in the database."
        },
        "schema": {
          "type": "string",
          "title": "The name of the 'Schema' where the 'Table' is defined in the database.",
          "description": "Defaults to 'CodeGeneration.Schema'."
        },
        "alias": {
          "type": "string",
          "title": "The 'Schema.Table' alias name.",
          "description": "Will automatically default where not specified."
        },
        "includeColumns": {
          "type": "array",
          "title": "The list of 'Column' names to be included in the underlying generated output.",
          "description": "Where not specified this indicates that all 'Columns' are to be included.",
          "items": {
            "type": "string"
          }
        },
        "excludeColumns": {
          "type": "array",
          "title": "The list of 'Column' names to be excluded from the underlying generated output.",
          "description": "Where not specified this indicates no 'Columns' are to be excluded.",
          "items": {
            "type": "string"
          }
        },
        "get": {
          "type": "boolean",
          "title": "Indicates whether a 'Get' stored procedure is to be automatically generated where not otherwise explicitly specified."
        },
        "getAll": {
          "type": "boolean",
          "title": "Indicates whether a 'GetAll' stored procedure is to be automatically generated where not otherwise explicitly specified.",
          "description": "The 'GetAllOrderBy' is used to specify the 'GetAll' query sort order."
        },
        "getAllOrderBy": {
          "type": "array",
          "title": "The list of 'Column' names (including sort order 'ASC'/'DESC' literal) to be used as the 'GetAll' query sort order.",
          "description": "This relates to the 'GetAll' selection.",
          "items": {
            "type": "string"
          }
        },
        "create": {
          "type": "boolean",
          "title": "Indicates whether a 'Create' stored procedure is to be automatically generated where not otherwise explicitly specified."
        },
        "update": {
          "type": "boolean",
          "title": "Indicates whether a 'Update' stored procedure is to be automatically generated where not otherwise explicitly specified."
        },
        "upsert": {
          "type": "boolean",
          "title": "Indicates whether a 'Upsert' stored procedure is to be automatically generated where not otherwise explicitly specified."
        },
        "delete": {
          "type": "boolean",
          "title": "Indicates whether a 'Delete' stored procedure is to be automatically generated where not otherwise explicitly specified."
        },
        "merge": {
          "type": "boolean",
          "title": "Indicates whether a 'Merge' (insert/update/delete of 'Udt' list) stored procedure is to be automatically generated where not otherwise explicitly specified.",
          "description": "This will also require a 'Udt' (SQL User Defined Table) and 'Tvp' (.NET Table-Valued Parameter) to function."
        },
        "efModel": {
          "type": "boolean",
          "title": "Indicates whether an 'Entity Framework' .NET (C#) model is to be generated."
        },
        "efModelName": {
          "type": "string",
          "title": "The .NET (C#) EntityFramework (EF) model name.",
          "description": "Defaults to 'Name'."
        },
        "udt": {
          "type": "boolean",
          "title": "Indicates whether a 'User Defined Table (UDT)' type should be created."
        },
        "udtExcludeColumns": {
          "type": "array",
          "title": "The list of 'Column' names to be excluded from the 'User Defined Table (UDT)'.",
          "description": "Where not specified this indicates that no 'Columns' are to be excluded.",
          "items": {
            "type": "string"
          }
        },
        "tvp": {
          "type": "string",
          "title": "The name of the .NET entity associated with the 'Udt' so that it can be expressed (created) as a Table-Valued Parameter for usage within the corresponding 'DbMapper'."
        },
        "entityScope": {
          "type": "string",
          "title": "The entity scope option.",
          "description": "Defaults to 'CodeGeneration.EntityScope'. Determines where the entity is scoped/defined, being 'Common' or 'Business' (i.e. not externally visible).",
          "enum": [
            "Common",
            "Business",
            "Autonomous"
          ]
        },
        "permission": {
          "type": "string",
          "title": "The permission (prefix) to be used for security permission checking (suffix defaults to 'Read', 'Write' or 'Delete' and can be overridden in the underlying stored procedure)."
        },
        "orgUnitImmutable": {
          "type": "boolean",
          "title": "Indicates whether the 'OrgUnitId' column is considered immutable, in that it can not be changed once set.",
          "description": "Defaults to 'CodeGeneration.OrgUnitImmutable'. This is only applicable for stored procedures."
        },
        "columnNameIsDeleted": {
          "type": "string",
          "title": "The column name for the 'IsDeleted' capability.",
          "description": "Defaults to 'CodeGeneration.IsDeleted'."
        },
        "columnNameTenantId": {
          "type": "string",
          "title": "The column name for the 'TenantId' capability.",
          "description": "Defaults to 'CodeGeneration.TenantId'."
        },
        "columnNameOrgUnitId": {
          "type": "string",
          "title": "The column name for the 'OrgUnitId' capability.",
          "description": "Defaults to 'CodeGeneration.OrgUnitId'."
        },
        "columnNameRowVersion": {
          "type": "string",
          "title": "The column name for the 'RowVersion' capability.",
          "description": "Defaults to 'CodeGeneration.RowVersion'."
        },
        "columnNameCreatedBy": {
          "type": "string",
          "title": "The column name for the 'CreatedBy' capability.",
          "description": "Defaults to 'CodeGeneration.CreatedBy'."
        },
        "columnNameCreatedDate": {
          "type": "string",
          "title": "The column name for the 'CreatedDate' capability.",
          "description": "Defaults to 'CodeGeneration.CreatedDate'."
        },
        "columnNameUpdatedBy": {
          "type": "string",
          "title": "The column name for the 'UpdatedBy' capability.",
          "description": "Defaults to 'CodeGeneration.UpdatedBy'."
        },
        "columnNameUpdatedDate": {
          "type": "string",
          "title": "The column name for the 'UpdatedDate' capability.",
          "description": "Defaults to 'CodeGeneration.UpdatedDate'."
        },
        "columnNameDeletedBy": {
          "type": "string",
          "title": "The column name for the 'DeletedBy' capability.",
          "description": "Defaults to 'CodeGeneration.UpdatedBy'."
        },
        "columnNameDeletedDate": {
          "type": "string",
          "title": "The column name for the 'DeletedDate' capability.",
          "description": "Defaults to 'CodeGeneration.UpdatedDate'."
        },
        "storedProcedures": {
          "type": "array",
          "title": "The corresponding 'StoredProcedure' collection.",
          "items": {
            "$ref": "#/$defs/StoredProcedure"
          }
        }
      },
      "required": [
        "name"
      ]
    },
    "StoredProcedure": {
      "type": "object",
      "title": "'StoredProcedure' object (database-driven)",
      "description": "The code generation for an 'StoredProcedure' is primarily driven by the 'Type' property. This encourages (enforces) a consistent implementation for the standardised **CRUD** (Create, Read, Update and Delete) actions, as well as supporting 'Upsert', 'Merge' and ad-hoc queries as required.",
      "properties": {
        "name": {
          "type": "string",
          "title": "The name of the 'StoredProcedure'; generally the verb/action, i.e. 'Get', 'Update', etc.",
          "description": "See 'StoredProcedureName' for the actual name used in the database."
        },
        "type": {
          "type": "string",
          "title": "The stored procedure operation type.",
          "description": "Defaults to 'GetColl'.",
          "enum": [
            "Get",
            "GetColl",
            "Create",
            "Update",
            "Upsert",
            "Delete",
            "Merge"
          ]
        },
        "paging": {
          "type": "boolean",
          "title": "Indicates whether standardized paging support should be added.",
          "description": "This only applies where the stored procedure operation 'Type' is 'GetColl'."
        },
        "storedProcedureName": {
          "type": "string",
          "title": "The 'StoredProcedure' name in the database.",
          "description": "Defaults to 'sp' + 'Table.Name' + 'Name'; e.g. 'spTableName' or 'spPersonGet'."
        },
        "reselectStatement": {
          "type": "string",
          "title": "The SQL statement to perform the reselect after a 'Create', 'Update' or 'Upsert' stored procedure operation 'Type'.",
          "description": "Defaults to '[{{Table.Schema}}].[sp{{Table.Name}}Get]' passing the primary key column(s)."
        },
        "intoTempTable": {
          "type": "boolean",
          "title": "Indicates whether to select into a '#TempTable' to allow other statements access to the selected data.",
          "description": "A 'Select * from #TempTable' is also performed (code-generated) where the stored procedure operation 'Type' is 'GetColl'."
        },
        "withHints": {
          "type": "string",
          "title": "the table hints using the SQL Server 'WITH()' statement; the value specified will be used as-is; e.g. 'NOLOCK' will result in 'WITH(NOLOCK)'."
        },
        "mergeOverrideIdentityColumns": {
          "type": "array",
          "title": "The list of 'Column' names to be used in the 'Merge' statement to determine whether to _insert_, _update_ or _delete_.",
          "description": "This is used to override the default behaviour of using the primary key column(s).",
          "items": {
            "type": "string"
          }
        },
        "permission": {
          "type": "string",
          "title": "The name of the 'StoredProcedure' in the database."
        },
        "orgUnitImmutable": {
          "type": "boolean",
          "title": "Indicates whether the 'OrgUnitId' column is considered immutable, in that it can not be changed once set.",
          "description": "Defaults to 'Table.OrgUnitImmutable'."
        },
        "includeColumns": {
          "type": "array",
          "title": "The list of 'Column' names to be included in the underlying generated _settable_ output (further filters 'Table.IncludeColumns').",
          "description": "Where not specified this indicates that all 'Columns' are to be included. Only filters the columns where 'Type' is 'Get', 'GetColl', 'Create', 'Update' or 'Upsert'.",
          "items": {
            "type": "string"
          }
        },
        "excludeColumns": {
          "type": "array",
          "title": "The list of 'Column' names to be excluded from the underlying generated _settable_ output (further filters 'Table.ExcludeColumns').",
          "description": "Where not specified this indicates no 'Columns' are to be excluded. Only filters the columns where 'Type' is 'Get', 'GetColl', 'Create', 'Update' or 'Upsert'.",
          "items": {
            "type": "string"
          }
        },
        "parameters": {
          "type": "array",
          "title": "The corresponding 'Parameter' collection.",
          "items": {
            "$ref": "#/$defs/Parameter"
          }
        },
        "where": {
          "type": "array",
          "title": "The corresponding 'Where' collection.",
          "items": {
            "$ref": "#/$defs/Where"
          }
        },
        "orderby": {
          "type": "array",
          "title": "The corresponding 'OrderBy' collection.",
          "items": {
            "$ref": "#/$defs/OrderBy"
          }
        },
        "execute": {
          "type": "array",
          "title": "The corresponding 'Execute' collection.",
          "items": {
            "$ref": "#/$defs/Execute"
          }
        }
      },
      "required": [
        "name"
      ]
    },
    "Parameter": {
      "type": "object",
      "title": "'Parameter' object (database-driven)",
      "description": "The 'Parameter' is used to define a stored procedure parameter and its charateristics. These are in addition to those that are automatically inferred (added) by the selected 'StoredProcedure.Type'.",
      "properties": {
        "name": {
          "type": "string",
          "title": "The parameter name (without the '@' prefix)."
        },
        "column": {
          "type": "string",
          "title": "The corresponding column name; used to infer characteristics.",
          "description": "Defaults to 'Name'."
        },
        "sqlType": {
          "type": "string",
          "title": "The SQL type definition (overrides inherited Column definition) including length/precision/scale."
        },
        "nullable": {
          "type": "boolean",
          "title": "Indicates whether the parameter is nullable.",
          "description": "Note that when the parameter value is 'NULL' it will not be included in the query."
        },
        "treatColumnNullAs": {
          "type": "boolean",
          "title": "Indicates whether the column value where NULL should be treated as the specified value; results in: 'ISNULL([x].[col], value)'."
        },
        "collection": {
          "type": "boolean",
          "title": "Indicates whether the parameter is a collection (one or more values to be included 'IN' the query)."
        },
        "operator": {
          "type": "string",
          "title": "The where clause equality operator",
          "description": "Defaults to 'EQ'.",
          "enum": [
            "EQ",
            "NE",
            "LT",
            "LE",
            "GT",
            "GE",
            "LIKE"
          ]
        }
      },
      "required": [
        "name"
      ]
    },
    "Where": {
      "type": "object",
      "title": "'Where' object (database-driven)",
      "description": "The 'Where' object defines an additional where 'Statement' to be added. This is in addition to those automatically added based on the 'StoredProcedure.Type'.",
      "properties": {
        "statement": {
          "type": "string",
          "title": "The where statement (TSQL)."
        }
      },
      "required": [
        "statement"
      ]
    },
    "OrderBy": {
      "type": "object",
      "title": "'OrderBy' object (database-driven)",
      "description": "The 'OrderBy' object defines the query order. Only valid for 'StoredProcedure.Type' of 'GetAll'.",
      "properties": {
        "name": {
          "type": "string",
          "title": "The name of the 'Column' to order by."
        },
        "order": {
          "type": "string",
          "title": "The corresponding sort order.",
          "description": "Defaults to 'Ascending'.",
          "enum": [
            "Ascending",
            "Descending"
          ]
        }
      },
      "required": [
        "name"
      ]
    },
    "Execute": {
      "type": "object",
      "title": "'Execute' object (database-driven)",
      "description": "The _Execute_ object enables additional TSQL statements to be embedded within the stored procedure.",
      "properties": {
        "statement": {
          "type": "string",
          "title": "The additional TSQL statement."
        },
        "location": {
          "type": "string",
          "title": "The location of the statement in relation to the underlying primary stored procedure statement.",
          "description": "Defaults to 'After'.",
          "enum": [
            "Before",
            "After"
          ]
        }
      },
      "required": [
        "statement"
      ]
    },
    "Query": {
      "type": "object",
      "title": "'Query' object (database-driven)",
      "description": "The 'Query' object enables the definition of more complex multi-table queries ('Joins') that would primarily result in a database _View_. The primary table 'Name' for the query is required to be specified. Multiple queries can be specified for the same table(s). The 'IncludeColumns' and 'ExcludeColumns' provide a shorthand to include or exclude selected columns; with the 'AliasColumns' providing a means to rename where required (for example duplicate name). Additional 'Where' and 'Order' configuration can also be added as required.",
      "properties": {
        "name": {
          "type": "string",
          "title": "The name of the primary table of the query."
        },
        "schema": {
          "type": "string",
          "title": "The schema name of the primary table of the view.",
          "description": "Defaults to 'CodeGeneration.dbo'."
        },
        "alias": {
          "type": "string",
          "title": "The 'Schema.Table' alias name.",
          "description": "Will automatically default where not specified."
        },
        "includeColumns": {
          "type": "array",
          "title": "The list of 'Column' names to be included in the underlying generated output.",
          "description": "Where not specified this indicates that all 'Columns' are to be included.",
          "items": {
            "type": "string"
          }
        },
        "excludeColumns": {
          "type": "array",
          "title": "The list of 'Column' names to be excluded from the underlying generated output.",
          "description": "Where not specified this indicates no 'Columns' are to be excluded.",
          "items": {
            "type": "string"
          }
        },
        "aliasColumns": {
          "type": "array",
          "title": "The list of 'Column' and 'Alias' pairs (split by a '^' lookup character) to enable column aliasing/renaming.",
          "description": "Each alias value should be formatted as 'Column' + '^' + 'Alias'; e.g. 'PCODE^ProductCode'",
          "items": {
            "type": "string"
          }
        },
        "view": {
          "type": "boolean",
          "title": "Indicates whether a 'View' is to be generated."
        },
        "viewName": {
          "type": "string",
          "title": "The 'View' name.",
          "description": "Defaults to 'vw' + 'Name'; e.g. 'vwTableName'."
        },
        "viewSchema": {
          "type": "string",
          "title": "The schema name for the 'View'.",
          "description": "Defaults to 'Schema'."
        },
        "permission": {
          "type": "string",
          "title": "The permission to be used for security permission checking.",
          "description": "The suffix is optional, and where not specified will default to '.READ'."
        },
        "columnNameIsDeleted": {
          "type": "string",
          "title": "The column name for the 'IsDeleted' capability.",
          "description": "Defaults to 'CodeGeneration.IsDeleted'."
        },
        "columnNameTenantId": {
          "type": "string",
          "title": "The column name for the 'TenantId' capability.",
          "description": "Defaults to 'CodeGeneration.TenantId'."
        },
        "columnNameOrgUnitId": {
          "type": "string",
          "title": "The column name for the 'OrgUnitId' capability.",
          "description": "Defaults to 'CodeGeneration.OrgUnitId'."
        },
        "columnNameRowVersion": {
          "type": "string",
          "title": "The column name for the 'RowVersion' capability.",
          "description": "Defaults to 'CodeGeneration.RowVersion'."
        },
        "columnNameCreatedBy": {
          "type": "string",
          "title": "The column name for the 'CreatedBy' capability.",
          "description": "Defaults to 'CodeGeneration.CreatedBy'."
        },
        "columnNameCreatedDate": {
          "type": "string",
          "title": "The column name for the 'CreatedDate' capability.",
          "description": "Defaults to 'CodeGeneration.CreatedDate'."
        },
        "columnNameUpdatedBy": {
          "type": "string",
          "title": "The column name for the 'UpdatedBy' capability.",
          "description": "Defaults to 'CodeGeneration.UpdatedBy'."
        },
        "columnNameUpdatedDate": {
          "type": "string",
          "title": "The column name for the 'UpdatedDate' capability.",
          "description": "Defaults to 'CodeGeneration.UpdatedDate'."
        },
        "columnNameDeletedBy": {
          "type": "string",
          "title": "The column name for the 'DeletedBy' capability.",
          "description": "Defaults to 'CodeGeneration.UpdatedBy'."
        },
        "columnNameDeletedDate": {
          "type": "string",
          "title": "The column name for the 'DeletedDate' capability.",
          "description": "Defaults to 'CodeGeneration.UpdatedDate'."
        },
        "joins": {
          "type": "array",
          "title": "The corresponding 'Join' collection.",
          "items": {
            "$ref": "#/$defs/QueryJoin"
          }
        },
        "order": {
          "type": "array",
          "title": "The corresponding 'Order' collection.",
          "items": {
            "$ref": "#/$defs/QueryOrder"
          }
        },
        "where": {
          "type": "array",
          "title": "The corresponding 'Where' collection.",
          "items": {
            "$ref": "#/$defs/QueryWhere"
          }
        }
      },
      "required": [
        "name"
      ]
    },
    "QueryJoin": {
      "type": "object",
      "title": "'QueryJoin' object (database-driven)",
      "description": "The 'QueryJoin' object defines a join to another (or same) table within a query. The 'Type' defines the join type, such as inner join, etc. The 'IncludeColumns' and 'ExcludeColumns' provide a shorthand to include or exclude selected columns; with the 'AliasColumns' providing a means to rename where required (for example duplicate name).",
      "properties": {
        "name": {
          "type": "string",
          "title": "The name of the table to join."
        },
        "schema": {
          "type": "string",
          "title": "The schema name of the table to join.",
          "description": "Defaults to 'Table.Schema'; i.e. same schema."
        },
        "alias": {
          "type": "string",
          "title": "The 'Schema.Table' alias name.",
          "description": "Will automatically default where not specified."
        },
        "type": {
          "type": "string",
          "title": "The SQL join type.",
          "description": "Defaults to 'Inner'.",
          "enum": [
            "Inner",
            "Left",
            "Right",
            "Full"
          ]
        },
        "includeColumns": {
          "type": "array",
          "title": "The list of 'Column' names to be included in the underlying generated output.",
          "description": "Where not specified this indicates that all 'Columns' are to be included.",
          "items": {
            "type": "string"
          }
        },
        "excludeColumns": {
          "type": "array",
          "title": "The list of 'Column' names to be excluded from the underlying generated output.",
          "description": "Where not specified this indicates no 'Columns' are to be excluded.",
          "items": {
            "type": "string"
          }
        },
        "aliasColumns": {
          "type": "array",
          "title": "The list of 'Column' and 'Alias' pairs (split by a '^' lookup character) to enable column renaming.",
          "description": "Each alias value should be formatted as 'Column' + '^' + 'Alias'; e.g. 'PCODE^ProductCode'",
          "items": {
            "type": "string"
          }
        },
        "columnNameIsDeleted": {
          "type": "string",
          "title": "The column name for the 'IsDeleted' capability.",
          "description": "Defaults to 'CodeGeneration.IsDeleted'."
        },
        "columnNameTenantId": {
          "type": "string",
          "title": "The column name for the 'TenantId' capability.",
          "description": "Defaults to 'CodeGeneration.TenantId'."
        },
        "columnNameOrgUnitId": {
          "type": "string",
          "title": "The column name for the 'OrgUnitId' capability.",
          "description": "Defaults to 'CodeGeneration.OrgUnitId'."
        },
        "columnNameRowVersion": {
          "type": "string",
          "title": "The column name for the 'RowVersion' capability.",
          "description": "Defaults to 'CodeGeneration.RowVersion'."
        },
        "columnNameCreatedBy": {
          "type": "string",
          "title": "The column name for the 'CreatedBy' capability.",
          "description": "Defaults to 'CodeGeneration.CreatedBy'."
        },
        "columnNameCreatedDate": {
          "type": "string",
          "title": "The column name for the 'CreatedDate' capability.",
          "description": "Defaults to 'CodeGeneration.CreatedDate'."
        },
        "columnNameUpdatedBy": {
          "type": "string",
          "title": "The column name for the 'UpdatedBy' capability.",
          "description": "Defaults to 'CodeGeneration.UpdatedBy'."
        },
        "columnNameUpdatedDate": {
          "type": "string",
          "title": "The column name for the 'UpdatedDate' capability.",
          "description": "Defaults to 'CodeGeneration.UpdatedDate'."
        },
        "columnNameDeletedBy": {
          "type": "string",
          "title": "The column name for the 'DeletedBy' capability.",
          "description": "Defaults to 'CodeGeneration.UpdatedBy'."
        },
        "columnNameDeletedDate": {
          "type": "string",
          "title": "The column name for the 'DeletedDate' capability.",
          "description": "Defaults to 'CodeGeneration.UpdatedDate'."
        },
        "on": {
          "type": "array",
          "title": "The corresponding 'JoinOn' collection.",
          "items": {
            "$ref": "#/$defs/QueryJoinOn"
          }
        }
      },
      "required": [
        "name"
      ]
    },
    "QueryJoinOn": {
      "type": "object",
      "title": "'QueryJoinOn' object (database-driven)",
      "description": "The 'QueryJoinOn' object defines the join on characteristics for a join within a query.",
      "properties": {
        "name": {
          "type": "string",
          "title": "The name of the join column (from the 'Join' table)."
        },
        "toSchema": {
          "type": "string",
          "title": "The name of the other join to table schema.",
          "description": "Defaults to 'Table.Schema'; i.e. same schema. See also 'ToTable' and 'ToColumn' as these all relate."
        },
        "toTable": {
          "type": "string",
          "title": "The name of the other join to table.",
          "description": "Defaults to 'Table.Name'; i.e. primary table. See also 'ToSchema' and 'ToColumn' as these all relate."
        },
        "toColumn": {
          "type": "string",
          "title": "The name of the other join to column.",
          "description": "Defaults to 'Name'; i.e. assumes same name. See also 'ToSchema' and 'ToTable' as these all relate."
        },
        "toStatement": {
          "type": "string",
          "title": "The fully qualified name ('Alias.Name') of the other column being joined to or other valid SQL (e.g. function) bypassing the corresponding 'Schema', 'Table' and 'Column' logic."
        }
      },
      "required": [
        "name"
      ]
    },
    "QueryOrder": {
      "type": "object",
      "title": "'QueryOrder' object (database-driven)",
      "description": "The 'QueryOrder' object that defines the query order.",
      "properties": {
        "name": {
          "type": "string",
          "title": "The name of the 'Column' to order by.",
          "description": "See also 'Schema' and 'Table' as these all relate."
        },
        "schema": {
          "type": "string",
          "title": "The name of order by table schema. See also 'Name' and 'Column' as these all relate.",
          "description": "Defaults to 'Query.Schema'."
        },
        "table": {
          "type": "string",
          "title": "The name of the order by table.",
          "description": "Defaults to 'Table.Name'; i.e. primary table. See also 'Schema' and 'Column' as these all relate."
        },
        "order": {
          "type": "string",
          "title": "The corresponding sort order.",
          "description": "Defaults to 'Ascending'.",
          "enum": [
            "Ascending",
            "Descending"
          ]
        }
      },
      "required": [
        "name"
      ]
    },
    "QueryWhere": {
      "type": "object",
      "title": "'QueryWhere' object (database-driven)",
      "description": "The 'QueryWhere' object defines an additional where 'Statement' to be added.",
      "properties": {
        "statement": {
          "type": "string",
          "title": "The where TSQL statement."
        }
      },
      "required": [
        "statement"
      ]
    }
  }
}
