import {
  ObjectSubTypeDefinition,
  ObjectTypeDefinition,
} from '../../integration/extension.provider';
import {ROOT_CONFIGURATION_TYPE} from '../../services/root-config/root-config.const';
import {CONTENT_ENCRYPTED_OBJECT} from '../content-encrypted-object/content-encrypted-object.const';
import {
  HIDDEN_LABEL_TYPE,
  HIDDEN_NAME_TYPE,
} from '../utils-common/utils-common.const';

export const LOG_PROVIDER = 'LogProvider';

export const LOGS_TYPE: ObjectTypeDefinition = {
  name: 'Logs',
  iconView: 'fas fa-server',
  contentType: CONTENT_ENCRYPTED_OBJECT,
  inheritedTypesIds: [HIDDEN_LABEL_TYPE.name, HIDDEN_NAME_TYPE.name],
  forcedAccessRights: {create: false, delete: false, update: false},
  definition: {
    properties: {
      contentEncryptedObject: {
        type: 'object',
        title: 'Encrypted object',
        properties: {
          value: {
            properties: {
              logs: {
                type: 'array',
                items: {
                  type: 'string',
                },
                'x-schema-form': {
                  readonly: true,
                  disabled: true,
                  type: 'json',
                },
                title: 'Logs',
                default: ['no logs'],
              },
            },
            'x-schema-form': {type: ''},
          },
        },
      },
    },
  },
};

export const ROOT_CONFIGURATION_LOGS_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: ROOT_CONFIGURATION_TYPE.name,
  subTypeName: LOGS_TYPE.name,
  min: 1,
  max: 1,
};
