/**
 * Copyright 2013-2026 the original author or authors from the JHipster project.
 *
 * This file is part of the JHipster project, see https://www.jhipster.tech/
 * for more information.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import type { ValidationType } from '../../jdl/core/built-in-options/validations.ts';

import type { Property } from './property.ts';

/** gRPC proto field mapping (from spring-grpc) */
export type ProtoField = {
  fieldDomainType?: string;
  fieldTypeUpperUnderscored?: string;
  fieldProtobufType?: string;
  isProtobufCustomType?: string;
};

type FieldEnum = {
  fieldValues: string;
  fieldTypeDocumentation?: string;
  fieldValuesJavadocs?: Record<string, string>;
};

type FieldBlob = {
  fieldTypeBlobContent: 'image' | 'any' | 'text';
};

export type Field = Partial<FieldEnum> &
  Partial<FieldBlob> &
  Partial<ProtoField> &
  Property & {
    fieldType: string;
    fieldName: string;
    options?: Record<string, boolean | string | number>;

    fieldValidateRules?: ValidationType[];
    fieldValidateRulesPattern?: string;
    fieldValidateRulesMaxlength?: number;
    fieldValidateRulesMax?: number;
    fieldValidateRulesMin?: number;
    fieldValidateRulesMinlength?: number;
    fieldValidationRequired?: boolean;
    fieldValidateRulesMaxbytes?: number;
    fieldValidateRulesMinbytes?: number;
    /** @deprecated */
    fieldTypeJavadoc?: string;
  };
