<commit_before>import { Meteor } from 'meteor/meteor';
import types from './element-types.js';
import characteristics from './characteristics.js';

const Elements = {};

Elements.types = types;
Elements.characteristics = characteristics;

Meteor.Elements = Elements;

Elements.collection = new Meteor.Collection('Elements');

Elements.add = function add(parentId, typeName) {
  const elementId = Elements.collection.insert({
    characteristics: [],
    childIds: [],
    description: '',
    name: 'unnamed',
    parentId,
    typeName,
  });

  Elements.collection.update(
    { _id: parentId }, { $addToSet: { childIds: elementId } }
  );

  return elementId;
};

Elements.remove = function remove(elementId, parentId) {<commit_msg>Publish elements<commit_after>import { Meteor } from 'meteor/meteor';
import types from './element-types.js';
import characteristics from './characteristics.js';

const Elements = {};

Elements.types = types;
Elements.characteristics = characteristics;

Meteor.Elements = Elements;

Elements.collection = new Meteor.Collection('Elements');

if (Meteor.isServer) {
  Meteor.publish('elements', () => {
    return Elements.collection.find();
  });
}

Elements.add = function add(parentId, typeName) {
  const elementId = Elements.collection.insert({
    characteristics: [],
    childIds: [],
    description: '',
    name: 'unnamed',
    parentId,
    typeName,
  });

  Elements.collection.update(
    { _id: parentId }, { $addToSet: { childIds: elementId } }
  );

  return elementId;
};

Elements.remove = function remove(elementId, parentId) {
{'fraction_non_alphanumeric': 0.14104996837444655, 'fraction_numerical': 0.0, 'mean_word_length': 4.23841059602649, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '2114286', 'n_tokens_mistral': 485, 'n_tokens_neox': 461, 'n_words': 104}