<commit_before>package io.corbel.resources.cli.dsl

import io.corbel.lib.cli.console.Description
import io.corbel.lib.cli.console.Shell
import io.corbel.resources.rem.model.ResourceUri
import io.corbel.resources.rem.model.SearchResource
import io.corbel.resources.rem.search.ElasticSearchService;
import io.corbel.resources.rem.service.ResmiService

import org.springframework.data.mongodb.core.index.Index

import com.google.gson.JsonObject
import com.google.gson.JsonParser

@Shell("resmi")
class ResmiShell {

    ResmiService resmiService
    ElasticSearchService elasticSearchService

    @Description("Creates a mongo expiration index named \"_expireAt\" on the specified collection .")
    def ensureExpireIndex(String collection) {
        resmiService.ensureExpireIndex(new ResourceUri(collection))
    }

    @Description("Creates a mongo index on the specified collection. See <> for documentation on index syntax")
    def ensureIndex(String collection, Index index) {
        resmiService.ensureIndex(new ResourceUri(collection), index)
    }

    @Description("Creates a mongo index on the specified relation. See <> for documentation on index syntax")
    def ensureIndex(String collection, String relation, Index index) {
        resmiService.ensureIndex(new ResourceUri(collection).setRelation(relation), index)
    }

    @Description("Upsert a resource in RESMI.")
    def upsert(String type, JsonObject json) {
        resmiService.saveResource(new ResourceUri(type), json, Optional.empty())
    }

    @Description("Construct a json object from string. Example: resmi.json('{\"a\", \"b\"}')")
    def json(String json) {
        new JsonParser().parse(json)
    }

    @Description("Full text search fields in a type.")
    def searchableFields(String type, String... fields) {
        assert type: "type is required"
        assert fields: "fields is required"
        resmiService.addSearchableFields(new SearchResource(type, fields.collect().toSet()))
    }

    @Description("Full text search fields in a type.")
    def searchableRelationFields(String type, String relation, String... fields) {
        assert type: "type is required"
        assert relation: "relation is required"
        assert fields: "fields is required"
        resmiService.addSearchableFields(new SearchResource(type, relation, fields.collect().toSet()))
    }

    @Description("Defines an index settings.")
    def createIndex(String name, String settings) {
        assert name: "name is required"<commit_msg>delete unused shell methods<commit_after>package io.corbel.resources.cli.dsl

import io.corbel.lib.cli.console.Description
import io.corbel.lib.cli.console.Shell
import io.corbel.resources.rem.model.ResourceUri
import io.corbel.resources.rem.search.ElasticSearchService
import io.corbel.resources.rem.service.ResmiService

import org.springframework.data.mongodb.core.index.Index

import com.google.gson.JsonObject
import com.google.gson.JsonParser

@Shell("resmi")
class ResmiShell {

    ResmiService resmiService
    ElasticSearchService elasticSearchService

    @Description("Creates a mongo expiration index named \"_expireAt\" on the specified collection .")
    def ensureExpireIndex(String collection) {
        resmiService.ensureExpireIndex(new ResourceUri(collection))
    }

    @Description("Creates a mongo index on the specified collection. See <> for documentation on index syntax")
    def ensureIndex(String collection, Index index) {
        resmiService.ensureIndex(new ResourceUri(collection), index)
    }

    @Description("Creates a mongo index on the specified relation. See <> for documentation on index syntax")
    def ensureIndex(String collection, String relation, Index index) {
        resmiService.ensureIndex(new ResourceUri(collection).setRelation(relation), index)
    }

    @Description("Upsert a resource in RESMI.")
    def upsert(String type, JsonObject json) {
        resmiService.saveResource(new ResourceUri(type), json, Optional.empty())
    }

    @Description("Construct a json object from string. Example: resmi.json('{\"a\", \"b\"}')")
    def json(String json) {
        new JsonParser().parse(json)
    }

    @Description("Defines an index settings.")
    def createIndex(String name, String settings) {
        assert name: "name is required"
{'fraction_non_alphanumeric': 0.09953596287703016, 'fraction_numerical': 0.0, 'mean_word_length': 4.089728453364817, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '533275', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1156, 'n_words': 320}