<commit_before>import R from 'ramda';
import { subtractObject } from 'xod-func-tools';

export const OPTIONAL_NODE_FIELDS = {
  boundValues: {},
  description: '',
  label: '',
};

export const OPTIONAL_PATCH_FIELDS = {
  attachments: [],
  description: '',
  impls: {},
  links: {},
  nodes: {},
};

export const OPTIONAL_PROJECT_FIELDS = {
  patches: {},
  authors: [],
  license: '', // MIT?
  version: '0.0.0',
  description: '',
};

// :: ??? -> Node
export const addMissingOptionalNodeFields = R.merge(OPTIONAL_NODE_FIELDS);

// :: ??? -> Patch
export const addMissingOptionalPatchFields = R.compose(
  R.evolve({
    nodes: R.map(addMissingOptionalNodeFields),
  }),
  R.merge(OPTIONAL_PATCH_FIELDS)
);

// :: ??? -> Project
export const addMissingOptionalProjectFields = R.compose(
  R.evolve({
    patches: R.map(addMissingOptionalPatchFields),
  }),
  R.merge(OPTIONAL_PROJECT_FIELDS)
);

// Node -> ???
export const omitEmptyOptionalNodeFields = subtractObject(OPTIONAL_NODE_FIELDS);

// :: Patch -> ???
export const omitEmptyOptionalPatchFields = R.compose(
  R.evolve({
    nodes: R.map(omitEmptyOptionalNodeFields),
  }),
  subtractObject(OPTIONAL_PATCH_FIELDS)
);

// :: Project -> ???
export const omitEmptyOptionalProjectFields = R.compose(
  R.evolve({
    patches: R.map(omitEmptyOptionalPatchFields),
  }),
  subtractObject(OPTIONAL_PROJECT_FIELDS)
);<commit_msg>chore(xod-project): cover optionalFieldsUtils with hm-def<commit_after>import R from 'ramda';
import { subtractObject } from 'xod-func-tools';

import { def } from './types';

export const OPTIONAL_NODE_FIELDS = {
  boundValues: {},
  description: '',
  label: '',
};

export const OPTIONAL_PATCH_FIELDS = {
  attachments: [],
  description: '',
  impls: {},
  links: {},
  nodes: {},
};

export const OPTIONAL_PROJECT_FIELDS = {
  patches: {},
  authors: [],
  license: '', // MIT?
  version: '0.0.0',
  description: '',
};

export const addMissingOptionalNodeFields = R.merge(OPTIONAL_NODE_FIELDS);

export const addMissingOptionalPatchFields = R.compose(
  R.evolve({
    nodes: R.map(addMissingOptionalNodeFields),
  }),
  R.merge(OPTIONAL_PATCH_FIELDS)
);

export const addMissingOptionalProjectFields = R.compose(
  R.evolve({
    patches: R.map(addMissingOptionalPatchFields),
  }),
  R.merge(OPTIONAL_PROJECT_FIELDS)
);

export const omitEmptyOptionalNodeFields = def(
  'omitEmptyOptionalNodeFields :: Node -> Object',
  subtractObject(OPTIONAL_NODE_FIELDS)
);

export const omitEmptyOptionalPatchFields = def(
  'omitEmptyOptionalPatchFields :: Patch -> Object',
  R.compose(
    R.evolve({
      nodes: R.map(omitEmptyOptionalNodeFields),
    }),
    subtractObject(OPTIONAL_PATCH_FIELDS)
  )
);

export const omitEmptyOptionalProjectFields = def(
  'omitEmptyOptionalProjectFields :: Project -> Object',
  R.compose(
    R.evolve({
      patches: R.map(omitEmptyOptionalPatchFields),
    }),
    subtractObject(OPTIONAL_PROJECT_FIELDS)
  )
);
{'fraction_non_alphanumeric': 0.14334354783792985, 'fraction_numerical': 0.0020429009193054137, 'mean_word_length': 4.553875236294896, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '6073411', 'n_tokens_mistral': 1013, 'n_tokens_neox': 1011, 'n_words': 170}