<commit_before>import R from 'ramda';
import { types, enumType, initializeTypes } from './TypesService';
import { boolAllowedValue, fromEnum } from './EditorMetaAllowedValuesService';

export default class EditorMetaService {

  static _instance;

  static get instance() {
    if (!EditorMetaService._instance) {
      EditorMetaService._instance = new EditorMetaService();
    }

    return EditorMetaService._instance;
  }

  static async initialize() {
    const initPromise = initializeTypes();

    initPromise.then(() => EditorMetaService.instance._initializeMeta());

    return initPromise;
  }

  getFieldMeta(field) {
    if (field === '') return { type: 'empty' };

    try {
      const [identity, property] = field.split('.');

      const fieldMeta = this.meta.fields[identity][property];
      if (!fieldMeta) {
        throw 'unsupported field meta: ' + field;
      }

      return fieldMeta;
    }
    catch (exp) {
      console.log('error occurd getting field meta', exp.message);
      return { type: 'string' };
    }
  }

  getKeyMeta(key) {

  }

  getIdentities() {
    return Object.keys(this.meta.identities);
  }

  getSuggestions({ type, query }) {
    if (type === 'MatcherProperty') {
      return R.reduce(R.concat, [])(R.keys(this.meta.identities).map(identity => R.toPairs(this.meta.fields[identity]).map(([field, meta]) => ({ label: `${field}`, value: `${identity}.${field}`, meta })))
      );
    }
    else {
      return [];
    }
  }

  _initializeMeta() {
    this.meta = {
      identities: {
        device: {},
        technician: {},
      },
      fields: {
        device: {
          '@@id': {
            multipleValues: true,
            description: "device id",
            ...types.string,
          },
          PartnerBrandId: {
            multipleValues: true,
            description: "The name of the partner",
            ...types.string,
          },
          DeviceOsType: {
            multipleValues: true,
            description: "Device operation system name",
            ...enumType('string'),
            allowedValues: fromEnum('Android', 'Ios'),
          },
          SubscriptionType: {
            multipleValues: true,
            description: "The home tier subscription of the device",
            ...enumType('string'),
            allowedValues: fromEnum('Evaluation', 'Free', 'Insurance', 'InsuranceAndSupport', 'HomeSupport', 'DefaultFree'),
          },
          AgentVersion: {
            multipleValues: true,
            defaultValue: '1.0.0.0',
            ...types.version
          },
          DeviceOsVersion: {
            multipleValues: true,
            ...types.version
          },
          DeviceVendor: {
            multipleValues: true,
            description: "Device vendor",
            ...types.string,
          },
          CountryCode: {
            multipleValues: true,
            description: "Country code",
            type: "string",
          },
          DeviceModel: {
            multipleValues: true,
            description: "device model",
            ...types.string,
          },
          InstallationSource: {
            multipleValues: true,
            description: "Installation source",
            ...types.string,
          },
          IsInGroup: {
            multipleValues: true,
            description: "Is in group",
            defaultValue: false,
            ...types.bool,
            allowedValues: boolAllowedValue,
          },
          CreatedAt: {
            multipleValues: true,
            description: "Created at",
            ...types.string,
          },
          DeviceType: {
            multipleValues: true,
            description: "Device type",
            ...enumType('string'),
            allowedValues: fromEnum('Unknown',
              'Desktop',
              'Laptop',
              'Tablet',
              'Mobile',
              'WinServer',
              'Car',
              'Television',
              'PrinterFax',
              'Bike',
              'ChildItem',
              'KitchenAppliance',
              'CleaningAppliance',
              'VideoGamingDevice',
              'HomeTheaterDevice',
              'Computer',
              'Other'
            ),
          },
        },
      },
    };
    
    EditorMetaService.isLoaded = true;
  }
}
<commit_msg>add EngagementLevel to meta<commit_after>import R from 'ramda';
import { types, enumType, initializeTypes } from './TypesService';
import { boolAllowedValue, fromEnum } from './EditorMetaAllowedValuesService';

export default class EditorMetaService {

  static _instance;

  static get instance() {
    if (!EditorMetaService._instance) {
      EditorMetaService._instance = new EditorMetaService();
    }

    return EditorMetaService._instance;
  }

  static async initialize() {
    const initPromise = initializeTypes();

    initPromise.then(() => EditorMetaService.instance._initializeMeta());

    return initPromise;
  }

  getFieldMeta(field) {
    if (field === '') return { type: 'empty' };

    try {
      const [identity, property] = field.split('.');

      const fieldMeta = this.meta.fields[identity][property];
      if (!fieldMeta) {
        throw 'unsupported field meta: ' + field;
      }

      return fieldMeta;
    }
    catch (exp) {
      console.log('error occurd getting field meta', exp.message);
      return { type: 'string' };
    }
  }

  getKeyMeta(key) {

  }

  getIdentities() {
    return Object.keys(this.meta.identities);
  }

  getSuggestions({ type, query }) {
    if (type === 'MatcherProperty') {
      return R.reduce(R.concat, [])(R.keys(this.meta.identities).map(identity => R.toPairs(this.meta.fields[identity]).map(([field, meta]) => ({ label: `${field}`, value: `${identity}.${field}`, meta })))
      );
    }
    else {
      return [];
    }
  }

  _initializeMeta() {
    this.meta = {
      identities: {
        device: {},
        technician: {},
      },
      fields: {
        device: {
          '@@id': {
            multipleValues: true,
            description: "device id",
            ...types.string,
          },
          PartnerBrandId: {
            multipleValues: true,
            description: "The name of the partner",
            ...types.string,
          },
          DeviceOsType: {
            multipleValues: true,
            description: "Device operation system name",
            ...enumType('string'),
            allowedValues: fromEnum('Android', 'Ios'),
          },
          SubscriptionType: {
            multipleValues: true,
            description: "The home tier subscription of the device",
            ...enumType('string'),
            allowedValues: fromEnum('Evaluation', 'Free', 'Insurance', 'InsuranceAndSupport', 'HomeSupport', 'DefaultFree'),
          },
          AgentVersion: {
            multipleValues: true,
            defaultValue: '1.0.0.0',
            ...types.version
          },
          DeviceOsVersion: {
            multipleValues: true,
            ...types.version
          },
          DeviceVendor: {
            multipleValues: true,
            description: "Device vendor",
            ...types.string,
          },
          CountryCode: {
            multipleValues: true,
            description: "Country code",
            type: "string",
          },
          DeviceModel: {
            multipleValues: true,
            description: "device model",
            ...types.string,
          },
          InstallationSource: {
            multipleValues: true,
            description: "Installation source",
            ...types.string,
          },
          IsInGroup: {
            multipleValues: true,
            description: "Is in group",
            defaultValue: false,
            ...types.bool,
            allowedValues: boolAllowedValue,
          },
          CreatedAt: {
            multipleValues: true,
            description: "Created at",
            ...types.string,
          },
          EngagementLevel: {
            multipleValues: true,
            description: "Engagement Level",
            ...types.string,
          },
          DeviceType: {
            multipleValues: true,
            description: "Device type",
            ...enumType('string'),
            allowedValues: fromEnum('Unknown',
              'Desktop',
              'Laptop',
              'Tablet',
              'Mobile',
              'WinServer',
              'Car',
              'Television',
              'PrinterFax',
              'Bike',
              'ChildItem',
              'KitchenAppliance',
              'CleaningAppliance',
              'VideoGamingDevice',
              'HomeTheaterDevice',
              'Computer',
              'Other'
            ),
          },
        },
      },
    };
    
    EditorMetaService.isLoaded = true;
  }
}

{'fraction_non_alphanumeric': 0.12547914317925593, 'fraction_numerical': 0.0009019165727170237, 'mean_word_length': 1.5870516185476815, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '363747', 'n_tokens_mistral': 2285, 'n_tokens_neox': 2248, 'n_words': 484}