// This file is auto-generated by @hey-api/openapi-ts

export const APIKeySchema = {
    properties: {
        id: {
            type: 'string',
            title: 'Id'
        },
        key: {
            type: 'string',
            format: 'password',
            title: 'Key',
            writeOnly: true
        }
    },
    type: 'object',
    required: ['id', 'key'],
    title: 'APIKey',
    description: 'A key-value pair for a known and supported API.'
} as const;

export const AccessSchema = {
    properties: {
        asset: {
            '$ref': '#/components/schemas/Asset'
        },
        classification: {
            anyOf: [
                {
                    '$ref': '#/components/schemas/Classification'
                },
                {
                    type: 'null'
                }
            ]
        }
    },
    type: 'object',
    required: ['asset'],
    title: 'Access',
    description: `The \`\`access\`\` block contains information related to access control for
this data object.`
} as const;

export const AccessTokenSchema = {
    properties: {
        id: {
            type: 'string',
            title: 'Id'
        },
        key: {
            type: 'string',
            format: 'password',
            title: 'Key',
            writeOnly: true
        }
    },
    type: 'object',
    required: ['id', 'key'],
    title: 'AccessToken',
    description: 'A key-value pair for a known and supported access scope.'
} as const;

export const AssetSchema = {
    properties: {
        name: {
            type: 'string',
            title: 'Name',
            examples: ['Drogon']
        }
    },
    type: 'object',
    required: ['name'],
    title: 'Asset',
    description: `The \`\`access.asset\`\` block contains information about the owner asset of
these data.`
} as const;

export const CacheContentSchema = {
    properties: {
        data: {
            additionalProperties: true,
            type: 'object',
            title: 'Data',
            description: 'Parsed JSON object for the cached resource.'
        }
    },
    type: 'object',
    required: ['data'],
    title: 'CacheContent',
    description: 'Content of a cache revision.'
} as const;

export const CacheListSchema = {
    properties: {
        revisions: {
            items: {
                type: 'string'
            },
            type: 'array',
            title: 'Revisions',
            description: 'Cache revision filenames, sorted oldest to newest.'
        }
    },
    type: 'object',
    required: ['revisions'],
    title: 'CacheList',
    description: 'List of cache revision filenames.'
} as const;

export const CacheResourceSchema = {
    type: 'string',
    enum: ['config.json', 'mappings.json'],
    title: 'CacheResource',
    description: 'Resources that can be cached and restored.'
} as const;

export const CacheRetentionSchema = {
    properties: {
        cache_max_revisions: {
            type: 'integer',
            minimum: 5,
            title: 'Cache Max Revisions',
            description: 'Maximum number of cache revisions to keep per resource.',
            default: 5
        }
    },
    type: 'object',
    title: 'CacheRetention',
    description: 'Cache retention setting for project resources.'
} as const;

export const ChangeInfoSchema = {
    properties: {
        timestamp: {
            type: 'string',
            format: 'date-time',
            title: 'Timestamp'
        },
        change_type: {
            '$ref': '#/components/schemas/ChangeType'
        },
        user: {
            type: 'string',
            title: 'User'
        },
        path: {
            type: 'string',
            format: 'path',
            title: 'Path'
        },
        change: {
            type: 'string',
            title: 'Change'
        },
        hostname: {
            type: 'string',
            title: 'Hostname'
        },
        file: {
            type: 'string',
            title: 'File'
        },
        key: {
            type: 'string',
            title: 'Key'
        }
    },
    type: 'object',
    required: ['change_type', 'user', 'path', 'change', 'hostname', 'file', 'key'],
    title: 'ChangeInfo',
    description: 'Represents a change in the changelog file.'
} as const;

export const ChangeTypeSchema = {
    type: 'string',
    enum: ['update', 'remove', 'add', 'reset', 'merge', 'copy'],
    title: 'ChangeType',
    description: 'The types of change that can be made on a file.'
} as const;

export const ClassificationSchema = {
    type: 'string',
    enum: ['asset', 'internal', 'restricted'],
    title: 'Classification',
    description: 'The security classification for a given data object.'
} as const;

export const CoordinateSystemSchema = {
    properties: {
        identifier: {
            type: 'string',
            title: 'Identifier',
            examples: ['ST_WGS84_UTM37N_P32637']
        },
        uuid: {
            type: 'string',
            format: 'uuid',
            title: 'Uuid',
            examples: ['15ce3b84-766f-4c93-9050-b154861f9100']
        }
    },
    type: 'object',
    required: ['identifier', 'uuid'],
    title: 'CoordinateSystem',
    description: `The \`\`masterdata.smda.coordinate_system\`\` block contains the coordinate
system known to SMDA.`
} as const;

export const CountryItemSchema = {
    properties: {
        identifier: {
            type: 'string',
            title: 'Identifier',
            examples: ['Norway']
        },
        uuid: {
            type: 'string',
            format: 'uuid',
            title: 'Uuid',
            examples: ['15ce3b84-766f-4c93-9050-b154861f9100']
        }
    },
    type: 'object',
    required: ['identifier', 'uuid'],
    title: 'CountryItem',
    description: `A single country in the \`\`smda.masterdata.country\`\` list of countries
known to SMDA.`
} as const;

export const DataSystemSchema = {
    type: 'string',
    enum: ['rms', 'smda', 'fmu'],
    title: 'DataSystem',
    description: 'The system or application data is being mapping to or from.'
} as const;

export const DiscoveryItemSchema = {
    properties: {
        short_identifier: {
            type: 'string',
            title: 'Short Identifier',
            examples: ['SomeDiscovery']
        },
        uuid: {
            type: 'string',
            format: 'uuid',
            title: 'Uuid',
            examples: ['15ce3b84-766f-4c93-9050-b154861f9100']
        }
    },
    type: 'object',
    required: ['short_identifier', 'uuid'],
    title: 'DiscoveryItem',
    description: `A single discovery in the \`\`masterdata.smda.discovery\`\` list of discoveries
known to SMDA.`
} as const;

export const FMUDirPathSchema = {
    properties: {
        path: {
            type: 'string',
            format: 'path',
            title: 'Path',
            description: 'Absolute path to the directory which maybe contains a .fmu directory.',
            examples: ['/path/to/project.2038.02.02']
        }
    },
    type: 'object',
    required: ['path'],
    title: 'FMUDirPath',
    description: 'Path where a .fmu directory may exist.'
} as const;

export const FMUProjectSchema = {
    properties: {
        path: {
            type: 'string',
            format: 'path',
            title: 'Path',
            description: 'Absolute path to the directory which maybe contains a .fmu directory.',
            examples: ['/path/to/project.2038.02.02']
        },
        project_dir_name: {
            type: 'string',
            title: 'Project Dir Name',
            description: 'The directory name, not the path, that contains the .fmu directory.',
            examples: ['project.2038.02.02']
        },
        config: {
            '$ref': '#/components/schemas/ProjectConfig',
            description: "The configuration of an FMU project's .fmu directory."
        }
    },
    type: 'object',
    required: ['path', 'project_dir_name', 'config'],
    title: 'FMUProject',
    description: "Information returned when 'opening' an FMU Directory."
} as const;

export const FieldItemSchema = {
    properties: {
        identifier: {
            type: 'string',
            title: 'Identifier',
            examples: ['OseFax']
        },
        uuid: {
            type: 'string',
            format: 'uuid',
            title: 'Uuid',
            examples: ['15ce3b84-766f-4c93-9050-b154861f9100']
        }
    },
    type: 'object',
    required: ['identifier', 'uuid'],
    title: 'FieldItem',
    description: `A single field in the \`\`masterdata.smda.field\`\` list of fields
known to SMDA.`
} as const;

export const GlobalConfigPathSchema = {
    properties: {
        relative_path: {
            type: 'string',
            format: 'path',
            title: 'Relative Path',
            description: 'Relative path in the project to a global config file.',
            examples: ['relative_path/to/global_config_file']
        }
    },
    type: 'object',
    required: ['relative_path'],
    title: 'GlobalConfigPath',
    description: 'A relative path to a global config file, relative to the project root.'
} as const;

export const HTTPValidationErrorSchema = {
    properties: {
        detail: {
            items: {
                '$ref': '#/components/schemas/ValidationError'
            },
            type: 'array',
            title: 'Detail'
        }
    },
    type: 'object',
    title: 'HTTPValidationError'
} as const;

export const ListFieldDiffSchema = {
    properties: {
        field_path: {
            type: 'string',
            title: 'Field Path'
        },
        added: {
            items: {
                additionalProperties: true,
                type: 'object'
            },
            type: 'array',
            title: 'Added'
        },
        removed: {
            items: {
                additionalProperties: true,
                type: 'object'
            },
            type: 'array',
            title: 'Removed'
        },
        updated: {
            items: {
                '$ref': '#/components/schemas/ListUpdatedEntry'
            },
            type: 'array',
            title: 'Updated'
        }
    },
    type: 'object',
    required: ['field_path', 'added', 'removed', 'updated'],
    title: 'ListFieldDiff',
    description: 'Diff entry for list fields with per-item changes.'
} as const;

export const ListUpdatedEntrySchema = {
    properties: {
        key: {
            title: 'Key'
        },
        before: {
            additionalProperties: true,
            type: 'object',
            title: 'Before'
        },
        after: {
            additionalProperties: true,
            type: 'object',
            title: 'After'
        }
    },
    type: 'object',
    required: ['key', 'before', 'after'],
    title: 'ListUpdatedEntry',
    description: 'Before and after values for an updated list item.'
} as const;

export const LockInfoSchema = {
    properties: {
        pid: {
            type: 'integer',
            title: 'Pid'
        },
        hostname: {
            type: 'string',
            title: 'Hostname'
        },
        user: {
            type: 'string',
            title: 'User'
        },
        acquired_at: {
            type: 'number',
            title: 'Acquired At'
        },
        expires_at: {
            type: 'number',
            title: 'Expires At'
        },
        version: {
            type: 'string',
            pattern: '(\\d+(\\.\\d+){0,2}|\\d+\\.\\d+\\.[a-z0-9]+\\+[a-z0-9.]+)',
            title: 'Version',
            default: '0.22.0'
        }
    },
    type: 'object',
    required: ['pid', 'hostname', 'user', 'acquired_at', 'expires_at'],
    title: 'LockInfo',
    description: 'Represents a .fmu directory lock file.'
} as const;

export const LockStatusSchema = {
    properties: {
        is_lock_acquired: {
            type: 'boolean',
            title: 'Is Lock Acquired',
            description: 'Whether the current session holds the write lock.'
        },
        lock_file_exists: {
            type: 'boolean',
            title: 'Lock File Exists',
            description: 'Whether a lock file exists.'
        },
        lock_info: {
            anyOf: [
                {
                    '$ref': '#/components/schemas/LockInfo'
                },
                {
                    type: 'null'
                }
            ],
            description: 'Contents of the lock file, if available and readable.'
        },
        lock_status_error: {
            anyOf: [
                {
                    type: 'string'
                },
                {
                    type: 'null'
                }
            ],
            title: 'Lock Status Error',
            description: 'Error message if checking lock status failed.'
        },
        lock_file_read_error: {
            anyOf: [
                {
                    type: 'string'
                },
                {
                    type: 'null'
                }
            ],
            title: 'Lock File Read Error',
            description: 'Error message if reading the lock file failed.'
        },
        last_lock_acquire_error: {
            anyOf: [
                {
                    type: 'string'
                },
                {
                    type: 'null'
                }
            ],
            title: 'Last Lock Acquire Error',
            description: 'Error message from the last attempt to acquire the lock.'
        },
        last_lock_release_error: {
            anyOf: [
                {
                    type: 'string'
                },
                {
                    type: 'null'
                }
            ],
            title: 'Last Lock Release Error',
            description: 'Error message from the last attempt to release the lock.'
        },
        last_lock_refresh_error: {
            anyOf: [
                {
                    type: 'string'
                },
                {
                    type: 'null'
                }
            ],
            title: 'Last Lock Refresh Error',
            description: 'Error message from the last attempt to refresh the lock.'
        }
    },
    type: 'object',
    required: ['is_lock_acquired', 'lock_file_exists'],
    title: 'LockStatus',
    description: 'Information about the project lock status.'
} as const;

export const Log_ChangeInfo_Schema = {
    items: {
        '$ref': '#/components/schemas/ChangeInfo'
    },
    type: 'array',
    title: 'Log[ChangeInfo]'
} as const;

export const MappingGroupSchema = {
    additionalProperties: true,
    type: 'object'
} as const;

export const MappingTypeSchema = {
    type: 'string',
    enum: ['stratigraphy'],
    title: 'MappingType',
    description: `The discriminator used between mapping types.

Each of these types should have their own mapping class derived from a base
mapping type, e.g. IdentifierMapping.`
} as const;

export const MasterdataSchema = {
    properties: {
        smda: {
            '$ref': '#/components/schemas/Smda'
        }
    },
    type: 'object',
    required: ['smda'],
    title: 'Masterdata',
    description: `The \`\`masterdata\`\` block contains information related to masterdata.
Currently, SMDA holds the masterdata.`
} as const;

export const MessageSchema = {
    properties: {
        message: {
            type: 'string',
            title: 'Message'
        }
    },
    type: 'object',
    required: ['message'],
    title: 'Message',
    description: 'A generic message to return to the GUI.'
} as const;

export const ModelSchema = {
    properties: {
        description: {
            anyOf: [
                {
                    items: {
                        type: 'string'
                    },
                    type: 'array'
                },
                {
                    type: 'null'
                }
            ],
            title: 'Description'
        },
        name: {
            type: 'string',
            title: 'Name',
            examples: ['Drogon']
        },
        revision: {
            type: 'string',
            title: 'Revision',
            examples: ['21.0.0.dev']
        }
    },
    type: 'object',
    required: ['name', 'revision'],
    title: 'Model',
    description: `The \`\`fmu.model\`\` block contains information about the model used.

.. note::
   Synonyms for "model" in this context are "template", "setup", etc. The term
   "model" is ultra-generic but was chosen before e.g. "template" as the latter
   deviates from daily communications and is, if possible, even more generic
   than "model".`
} as const;

export const OkSchema = {
    properties: {
        status: {
            type: 'string',
            const: 'ok',
            title: 'Status',
            default: 'ok'
        }
    },
    type: 'object',
    title: 'Ok',
    description: 'Returns "ok" if the route is functioning correctly.'
} as const;

export const ProjectConfigSchema = {
    properties: {
        version: {
            type: 'string',
            pattern: '(\\d+(\\.\\d+){0,2}|\\d+\\.\\d+\\.[a-z0-9]+\\+[a-z0-9.]+)',
            title: 'Version'
        },
        created_at: {
            type: 'string',
            format: 'date-time',
            title: 'Created At'
        },
        created_by: {
            type: 'string',
            title: 'Created By'
        },
        last_modified_at: {
            anyOf: [
                {
                    type: 'string',
                    format: 'date-time'
                },
                {
                    type: 'null'
                }
            ],
            title: 'Last Modified At'
        },
        last_modified_by: {
            anyOf: [
                {
                    type: 'string'
                },
                {
                    type: 'null'
                }
            ],
            title: 'Last Modified By'
        },
        masterdata: {
            anyOf: [
                {
                    '$ref': '#/components/schemas/Masterdata'
                },
                {
                    type: 'null'
                }
            ]
        },
        model: {
            anyOf: [
                {
                    '$ref': '#/components/schemas/Model'
                },
                {
                    type: 'null'
                }
            ]
        },
        access: {
            anyOf: [
                {
                    '$ref': '#/components/schemas/Access'
                },
                {
                    type: 'null'
                }
            ]
        },
        cache_max_revisions: {
            type: 'integer',
            minimum: 5,
            title: 'Cache Max Revisions',
            default: 5
        },
        rms: {
            anyOf: [
                {
                    '$ref': '#/components/schemas/RmsProject'
                },
                {
                    type: 'null'
                }
            ]
        }
    },
    type: 'object',
    required: ['version', 'created_at', 'created_by'],
    title: 'ProjectConfig',
    description: `The configuration file in a .fmu directory.

Stored as config.json.`
} as const;

export const RelationTypeSchema = {
    type: 'string',
    enum: ['primary', 'alias', 'equivalent'],
    title: 'RelationType',
    description: 'The kind of relation this mapping represents.'
} as const;

export const RmsCoordinateSystemSchema = {
    properties: {
        name: {
            type: 'string',
            title: 'Name'
        }
    },
    type: 'object',
    required: ['name'],
    title: 'RmsCoordinateSystem',
    description: 'The project coordinate system of an RMS project.'
} as const;

export const RmsCoordinateSystemMatchSchema = {
    properties: {
        rms_crs_sys: {
            '$ref': '#/components/schemas/RmsCoordinateSystem',
            description: 'The source coordinate system to be matched.'
        },
        smda_crs_sys: {
            '$ref': '#/components/schemas/CoordinateSystem',
            description: 'The matched target coordinate system.'
        },
        score: {
            type: 'number',
            maximum: 100,
            minimum: 0,
            title: 'Score',
            description: 'Similarity score for the coordinate systems (0-100).'
        },
        confidence: {
            type: 'string',
            enum: ['high', 'medium', 'low'],
            title: 'Confidence',
            description: `Confidence level based on score.

'high' (>80), 'medium' (50-80), 'low' (<50).`
        }
    },
    type: 'object',
    required: ['rms_crs_sys', 'smda_crs_sys', 'score', 'confidence'],
    title: 'RmsCoordinateSystemMatch',
    description: 'A matched coordinate system.'
} as const;

export const RmsHorizonSchema = {
    properties: {
        name: {
            type: 'string',
            title: 'Name'
        },
        type: {
            type: 'string',
            enum: ['calculated', 'calculated_unconformity', 'interpreted', 'interpreted_unconformity', 'interpreted_intrusion'],
            title: 'Type'
        }
    },
    type: 'object',
    required: ['name', 'type'],
    title: 'RmsHorizon',
    description: 'A horizon from an RMS project.'
} as const;

export const RmsProjectSchema = {
    properties: {
        path: {
            type: 'string',
            format: 'path',
            title: 'Path'
        },
        version: {
            type: 'string',
            title: 'Version'
        },
        coordinate_system: {
            anyOf: [
                {
                    '$ref': '#/components/schemas/RmsCoordinateSystem'
                },
                {
                    type: 'null'
                }
            ]
        },
        zones: {
            anyOf: [
                {
                    items: {
                        '$ref': '#/components/schemas/RmsStratigraphicZone'
                    },
                    type: 'array'
                },
                {
                    type: 'null'
                }
            ],
            title: 'Zones'
        },
        horizons: {
            anyOf: [
                {
                    items: {
                        '$ref': '#/components/schemas/RmsHorizon'
                    },
                    type: 'array'
                },
                {
                    type: 'null'
                }
            ],
            title: 'Horizons'
        },
        wells: {
            anyOf: [
                {
                    items: {
                        '$ref': '#/components/schemas/RmsWell'
                    },
                    type: 'array'
                },
                {
                    type: 'null'
                }
            ],
            title: 'Wells'
        }
    },
    type: 'object',
    required: ['path', 'version'],
    title: 'RmsProject',
    description: 'RMS project configuration.'
} as const;

export const RmsProjectPathSchema = {
    properties: {
        path: {
            type: 'string',
            format: 'path',
            title: 'Path',
            description: 'Absolute path to the RMS project within the FMU project.',
            examples: ['/path/to/some.project.rms.14.2.2']
        }
    },
    type: 'object',
    required: ['path'],
    title: 'RmsProjectPath',
    description: 'Path to an RMS project within the FMU project.'
} as const;

export const RmsProjectPathsResultSchema = {
    properties: {
        results: {
            items: {
                '$ref': '#/components/schemas/RmsProjectPath'
            },
            type: 'array',
            title: 'Results',
            description: 'List of absolute paths to RMS projects within the FMU project.'
        }
    },
    type: 'object',
    required: ['results'],
    title: 'RmsProjectPathsResult',
    description: 'List of RMS project paths within the FMU project.'
} as const;

export const RmsStratigraphicFrameworkSchema = {
    properties: {
        zones: {
            items: {
                '$ref': '#/components/schemas/RmsStratigraphicZone'
            },
            type: 'array',
            title: 'Zones',
            description: 'List of RMS stratigraphic zones.'
        },
        horizons: {
            items: {
                '$ref': '#/components/schemas/RmsHorizon'
            },
            type: 'array',
            title: 'Horizons',
            description: 'List of RMS horizons.'
        }
    },
    type: 'object',
    required: ['zones', 'horizons'],
    title: 'RmsStratigraphicFramework',
    description: 'RMS stratigraphic framework consisting of zones and horizons.'
} as const;

export const RmsStratigraphicZoneSchema = {
    properties: {
        name: {
            type: 'string',
            title: 'Name'
        },
        top_horizon_name: {
            type: 'string',
            title: 'Top Horizon Name'
        },
        base_horizon_name: {
            type: 'string',
            title: 'Base Horizon Name'
        },
        stratigraphic_column_name: {
            anyOf: [
                {
                    items: {
                        type: 'string'
                    },
                    type: 'array'
                },
                {
                    type: 'null'
                }
            ],
            title: 'Stratigraphic Column Name'
        }
    },
    type: 'object',
    required: ['name', 'top_horizon_name', 'base_horizon_name'],
    title: 'RmsStratigraphicZone',
    description: 'A stratigraphic zone from an RMS project.'
} as const;

export const RmsStratigraphyMatchSchema = {
    properties: {
        rms_zone: {
            '$ref': '#/components/schemas/RmsStratigraphicZone',
            description: 'The RMS stratigraphic zone.'
        },
        smda_unit: {
            '$ref': '#/components/schemas/StratigraphicUnit',
            description: 'The matched SMDA stratigraphic unit.'
        },
        score: {
            type: 'number',
            maximum: 100,
            minimum: 0,
            title: 'Score',
            description: 'Similarity score for the zone/unit names (0-100).'
        },
        confidence: {
            type: 'string',
            enum: ['high', 'medium', 'low'],
            title: 'Confidence',
            description: `Confidence level based on score.

'high' (>80), 'medium' (50-80), 'low' (<50).`
        }
    },
    type: 'object',
    required: ['rms_zone', 'smda_unit', 'score', 'confidence'],
    title: 'RmsStratigraphyMatch',
    description: 'A matched pair of RMS zone and SMDA stratigraphic unit.'
} as const;

export const RmsVersionSchema = {
    properties: {
        version: {
            type: 'string',
            title: 'Version',
            description: 'A version of RMS.',
            examples: ['14.2.2', '15.0.1.0']
        }
    },
    type: 'object',
    required: ['version'],
    title: 'RmsVersion',
    description: 'RMS version.'
} as const;

export const RmsWellSchema = {
    properties: {
        name: {
            type: 'string',
            title: 'Name'
        }
    },
    type: 'object',
    required: ['name'],
    title: 'RmsWell',
    description: 'A well from an RMS project.'
} as const;

export const ScalarFieldDiffSchema = {
    properties: {
        field_path: {
            type: 'string',
            title: 'Field Path'
        },
        before: {
            title: 'Before'
        },
        after: {
            title: 'After'
        }
    },
    type: 'object',
    required: ['field_path', 'before', 'after'],
    title: 'ScalarFieldDiff',
    description: 'Diff entry for non-list fields.'
} as const;

export const SessionResponseSchema = {
    properties: {
        id: {
            type: 'string',
            title: 'Id',
            description: 'Session identifier.'
        },
        created_at: {
            type: 'string',
            format: 'date-time',
            title: 'Created At',
            description: 'Timestamp when the session was created.'
        },
        expires_at: {
            type: 'string',
            format: 'date-time',
            title: 'Expires At',
            description: 'Timestamp when the session will expire.'
        },
        last_accessed: {
            type: 'string',
            format: 'date-time',
            title: 'Last Accessed',
            description: 'Timestamp when the session was last accessed.'
        }
    },
    type: 'object',
    required: ['id', 'created_at', 'expires_at', 'last_accessed'],
    title: 'SessionResponse',
    description: 'Serializable representation of the current session.'
} as const;

export const SmdaSchema = {
    properties: {
        coordinate_system: {
            '$ref': '#/components/schemas/CoordinateSystem'
        },
        country: {
            items: {
                '$ref': '#/components/schemas/CountryItem'
            },
            type: 'array',
            title: 'Country'
        },
        discovery: {
            items: {
                '$ref': '#/components/schemas/DiscoveryItem'
            },
            type: 'array',
            title: 'Discovery'
        },
        field: {
            items: {
                '$ref': '#/components/schemas/FieldItem'
            },
            type: 'array',
            title: 'Field'
        },
        stratigraphic_column: {
            '$ref': '#/components/schemas/StratigraphicColumn'
        }
    },
    type: 'object',
    required: ['coordinate_system', 'country', 'discovery', 'field', 'stratigraphic_column'],
    title: 'Smda',
    description: 'The ``masterdata.smda`` block contains SMDA-related attributes.'
} as const;

export const SmdaFieldSchema = {
    properties: {
        identifier: {
            type: 'string',
            title: 'Identifier',
            description: 'A field identifier (name).',
            examples: ['TROLL']
        }
    },
    type: 'object',
    required: ['identifier'],
    title: 'SmdaField',
    description: 'An identifier for a field to be searched for.'
} as const;

export const SmdaFieldSearchResultSchema = {
    properties: {
        hits: {
            type: 'integer',
            title: 'Hits',
            description: 'The number of hits from the field search.'
        },
        pages: {
            type: 'integer',
            title: 'Pages',
            description: 'The number of pages of hits.'
        },
        results: {
            items: {
                '$ref': '#/components/schemas/SmdaFieldUUID'
            },
            type: 'array',
            title: 'Results',
            description: 'A list of field identifier results from the search.'
        }
    },
    type: 'object',
    required: ['hits', 'pages', 'results'],
    title: 'SmdaFieldSearchResult',
    description: 'The search result of a field identifier result.'
} as const;

export const SmdaFieldUUIDSchema = {
    properties: {
        identifier: {
            type: 'string',
            title: 'Identifier',
            description: 'A field identifier (name).',
            examples: ['TROLL']
        },
        uuid: {
            type: 'string',
            format: 'uuid',
            title: 'Uuid',
            description: 'The SMDA UUID identifier corresponding to the field identifier.'
        }
    },
    type: 'object',
    required: ['identifier', 'uuid'],
    title: 'SmdaFieldUUID',
    description: 'Name-UUID identifier for a field as known by SMDA.'
} as const;

export const SmdaMasterdataResultSchema = {
    properties: {
        field: {
            items: {
                '$ref': '#/components/schemas/FieldItem'
            },
            type: 'array',
            title: 'Field',
            description: 'A list referring to fields known to SMDA. First item is primary.'
        },
        country: {
            items: {
                '$ref': '#/components/schemas/CountryItem'
            },
            type: 'array',
            title: 'Country',
            description: 'A list referring to countries known to SMDA. First item is primary.'
        },
        discovery: {
            items: {
                '$ref': '#/components/schemas/DiscoveryItem'
            },
            type: 'array',
            title: 'Discovery',
            description: 'A list referring to discoveries known to SMDA. First item is primary.'
        },
        stratigraphic_columns: {
            items: {
                '$ref': '#/components/schemas/StratigraphicColumn'
            },
            type: 'array',
            title: 'Stratigraphic Columns',
            description: 'Reference to stratigraphic column known to SMDA.'
        },
        field_coordinate_system: {
            '$ref': '#/components/schemas/CoordinateSystem',
            description: `The primary field's coordinate system.

This coordinate system may not be the coordinate system users use in their model.`
        },
        coordinate_systems: {
            items: {
                '$ref': '#/components/schemas/CoordinateSystem'
            },
            type: 'array',
            title: 'Coordinate Systems',
            description: `A list of all coordinate systems known to SMDA.

These are provided when the user needs to select a different coordinate system that
applies to the model they are working on.`
        }
    },
    type: 'object',
    required: ['field', 'country', 'discovery', 'stratigraphic_columns', 'field_coordinate_system', 'coordinate_systems'],
    title: 'SmdaMasterdataResult',
    description: 'Contains SMDA-related attributes.'
} as const;

export const SmdaStratColumnSchema = {
    properties: {
        strat_column_identifier: {
            type: 'string',
            title: 'Strat Column Identifier',
            description: 'A stratigraphic column identifier.',
            examples: ['LITHO_TROLL']
        }
    },
    type: 'object',
    required: ['strat_column_identifier'],
    title: 'SmdaStratColumn',
    description: 'An identifier for a stratigraphic column.'
} as const;

export const SmdaStratigraphicUnitsResultSchema = {
    properties: {
        stratigraphic_units: {
            items: {
                '$ref': '#/components/schemas/StratigraphicUnit'
            },
            type: 'array',
            title: 'Stratigraphic Units',
            description: 'List of stratigraphic units from SMDA.'
        }
    },
    type: 'object',
    required: ['stratigraphic_units'],
    title: 'SmdaStratigraphicUnitsResult',
    description: 'Result containing a list of stratigraphic units.'
} as const;

export const StratigraphicColumnSchema = {
    properties: {
        identifier: {
            type: 'string',
            title: 'Identifier',
            examples: ['DROGON_2020']
        },
        uuid: {
            type: 'string',
            format: 'uuid',
            title: 'Uuid',
            examples: ['15ce3b84-766f-4c93-9050-b154861f9100']
        }
    },
    type: 'object',
    required: ['identifier', 'uuid'],
    title: 'StratigraphicColumn',
    description: `The \`\`masterdata.smda.stratigraphic_column\`\` block contains the
stratigraphic column known to SMDA.`
} as const;

export const StratigraphicUnitSchema = {
    properties: {
        identifier: {
            type: 'string',
            title: 'Identifier',
            description: 'The stratigraphic unit identifier (name).',
            examples: ['VIKING GP.']
        },
        uuid: {
            type: 'string',
            format: 'uuid',
            title: 'Uuid',
            description: 'The SMDA UUID identifier corresponding to the stratigraphic unit.'
        },
        strat_unit_type: {
            type: 'string',
            title: 'Strat Unit Type',
            description: 'The type of stratigraphic unit.',
            examples: ['formation', 'group']
        },
        strat_unit_level: {
            type: 'integer',
            maximum: 6,
            minimum: 1,
            title: 'Strat Unit Level',
            description: 'The hierarchical level of the stratigraphic unit (1-6).'
        },
        top: {
            type: 'string',
            title: 'Top',
            description: 'The identifier (name) of the stratigraphic unit top pick (horizon).',
            examples: ['VIKING GP. Top']
        },
        base: {
            type: 'string',
            title: 'Base',
            description: 'The identifier (name) of the stratigraphic unit base pick (horizon).',
            examples: ['VIKING GP. Base']
        },
        top_age: {
            type: 'number',
            minimum: 0,
            title: 'Top Age',
            description: 'The age (in Ma) at the top of the stratigraphic unit.'
        },
        base_age: {
            type: 'number',
            minimum: 0,
            title: 'Base Age',
            description: 'The age (in Ma) at the base of the stratigraphic unit.'
        },
        strat_unit_parent: {
            anyOf: [
                {
                    type: 'string'
                },
                {
                    type: 'null'
                }
            ],
            title: 'Strat Unit Parent',
            description: 'The parent stratigraphic unit identifier, if applicable.'
        },
        strat_column_type: {
            type: 'string',
            enum: ['lithostratigraphy', 'sequence stratigraphy', 'chronostratigraphy', 'biostratigraphy'],
            title: 'Strat Column Type',
            description: 'The type of stratigraphic column this unit belongs to.'
        },
        color_html: {
            anyOf: [
                {
                    type: 'string',
                    pattern: '#[0-9a-fA-F]{6}'
                },
                {
                    type: 'null'
                }
            ],
            title: 'Color Html',
            description: 'The HTML hex color code for visualization.'
        },
        color_r: {
            anyOf: [
                {
                    type: 'integer'
                },
                {
                    type: 'null'
                }
            ],
            title: 'Color R',
            description: 'The red component of the RGB color.'
        },
        color_g: {
            anyOf: [
                {
                    type: 'integer'
                },
                {
                    type: 'null'
                }
            ],
            title: 'Color G',
            description: 'The green component of the RGB color.'
        },
        color_b: {
            anyOf: [
                {
                    type: 'integer'
                },
                {
                    type: 'null'
                }
            ],
            title: 'Color B',
            description: 'The blue component of the RGB color.'
        }
    },
    type: 'object',
    required: ['identifier', 'uuid', 'strat_unit_type', 'strat_unit_level', 'top', 'base', 'top_age', 'base_age', 'strat_unit_parent', 'strat_column_type', 'color_r', 'color_g', 'color_b'],
    title: 'StratigraphicUnit',
    description: 'Stratigraphic unit item.'
} as const;

export const StratigraphyIdentifierMappingSchema = {
    properties: {
        source_system: {
            '$ref': '#/components/schemas/DataSystem'
        },
        target_system: {
            '$ref': '#/components/schemas/DataSystem'
        },
        mapping_type: {
            type: 'string',
            const: 'stratigraphy',
            title: 'Mapping Type',
            default: 'stratigraphy'
        },
        relation_type: {
            '$ref': '#/components/schemas/RelationType'
        },
        source_id: {
            type: 'string',
            title: 'Source Id'
        },
        source_uuid: {
            anyOf: [
                {
                    type: 'string',
                    format: 'uuid'
                },
                {
                    type: 'null'
                }
            ],
            title: 'Source Uuid'
        },
        target_id: {
            type: 'string',
            title: 'Target Id'
        },
        target_uuid: {
            anyOf: [
                {
                    type: 'string',
                    format: 'uuid'
                },
                {
                    type: 'null'
                }
            ],
            title: 'Target Uuid'
        }
    },
    type: 'object',
    required: ['source_system', 'target_system', 'relation_type', 'source_id', 'target_id'],
    title: 'StratigraphyIdentifierMapping',
    description: `Represents a stratigraphy mapping.

This is a mapping from stratigraphic identifiers (tops, zones, etc.) to official
identifiers in SMDA.`
} as const;

export const SumoAssetSchema = {
    properties: {
        name: {
            type: 'string',
            title: 'Name',
            description: 'Name of the asset in Sumo.'
        },
        code: {
            type: 'string',
            title: 'Code',
            description: 'Code of the asset in Sumo.'
        },
        roleprefix: {
            type: 'string',
            title: 'Roleprefix',
            description: 'Roleprefix of the asset in Sumo.'
        }
    },
    type: 'object',
    required: ['name', 'code', 'roleprefix'],
    title: 'SumoAsset',
    description: 'A valid asset in Sumo.'
} as const;

export const UserAPIKeysSchema = {
    properties: {
        smda_subscription: {
            anyOf: [
                {
                    type: 'string'
                },
                {
                    type: 'null'
                }
            ],
            title: 'Smda Subscription'
        }
    },
    type: 'object',
    title: 'UserAPIKeys',
    description: 'Known API keys stored in a user config.'
} as const;

export const UserConfigSchema = {
    properties: {
        version: {
            type: 'string',
            pattern: '(\\d+(\\.\\d+){0,2}|\\d+\\.\\d+\\.[a-z0-9]+\\+[a-z0-9.]+)',
            title: 'Version'
        },
        created_at: {
            type: 'string',
            format: 'date-time',
            title: 'Created At'
        },
        last_modified_at: {
            anyOf: [
                {
                    type: 'string',
                    format: 'date-time'
                },
                {
                    type: 'null'
                }
            ],
            title: 'Last Modified At'
        },
        cache_max_revisions: {
            type: 'integer',
            minimum: 5,
            title: 'Cache Max Revisions',
            default: 5
        },
        user_api_keys: {
            '$ref': '#/components/schemas/UserAPIKeys'
        },
        recent_project_directories: {
            items: {
                type: 'string',
                format: 'path'
            },
            type: 'array',
            maxItems: 5,
            title: 'Recent Project Directories'
        }
    },
    type: 'object',
    required: ['version', 'created_at', 'user_api_keys', 'recent_project_directories'],
    title: 'UserConfig',
    description: `The configuration file in a $HOME/.fmu directory.

Stored as config.json.`
} as const;

export const ValidationErrorSchema = {
    properties: {
        loc: {
            items: {
                anyOf: [
                    {
                        type: 'string'
                    },
                    {
                        type: 'integer'
                    }
                ]
            },
            type: 'array',
            title: 'Location'
        },
        msg: {
            type: 'string',
            title: 'Message'
        },
        type: {
            type: 'string',
            title: 'Error Type'
        },
        input: {
            title: 'Input'
        },
        ctx: {
            type: 'object',
            title: 'Context'
        }
    },
    type: 'object',
    required: ['loc', 'msg', 'type'],
    title: 'ValidationError'
} as const;