GithubHelp home page GithubHelp logo

jfallaire / coveo-mock-conversion Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 1.0 20 KB

Mock Coveo Conversion [for Cloud V1 platform] for testing pre/post conversion scripts

License: Apache License 2.0

JavaScript 100.00%

coveo-mock-conversion's Introduction

coveo-mock-conversion

Mock Coveo Conversion [for Coveo Cloud V1 platform] for testing pre/post conversion scripts

This mock-conversion script is meant for smoke testing your post conversion script (also known as Custom Script in Coveo Cloud V1) because there is currently no way to debug or see traces within the Coveo Cloud V1 platform which can be very annoying. This script is taking 2 mandatory input parameters : your environment and your conversion script. You first need to specify a mock environment (JSON format) which will represent a list of fake indexed documents that will be used as input for the conversion script. Common conversion script tasks: Update the document extracted text and HTML, read and modify metadata, reject documents, etc.

Install

npm install

Mock conversion example usage

node mocking-script -h

Output :

Usage: mocking-script [options] <env> <script>

  Options:

    -h, --help                    output usage information
    -V, --version                 output the version number
    -c, --chdir <path>            change the working directory
    -t, --conversion-type <type>  conversion type
    -b, --show-body               printing final body
node mocking-script samples/env.sample-documents.js samples/custom-script.sample.js -b

Output :

{
  "Title": "Test 1 page",
  "URI": "http://www.perdu.com/test1",
  "Metadata": {
    "metadata1": "metadata1",
    "metadata2": "metadata2",
    "metadata3": "metadata3"
  },
  "IsValid": true,
  "SummaryConcepts": "",
  "Language": "1",
  "Source": "Sitemap - fake source"
}
Final Body >>> <html><body>This is a custom View As HTML stream set by a postconversion script!</body></html>
{
  "Title": "Test 2 page",
  "URI": "http://www.perdu.com/test2",
  "Metadata": {
    "metadata1": "metadata1",
    "metadata2": "metadata2",
    "metadata3": "metadata3"
  },
  "IsValid": true,
  "SummaryConcepts": "",
  "Language": "1",
  "Source": "Sitemap - fake source"
}
Final Body >>> <html><body>This is a custom View As HTML stream set by a postconversion script!</body></html>
{
  "Title": "Test 3 page",
  "URI": "http://www.perdu.com/test3",
  "Metadata": {
    "metadata1": "metadata1",
    "metadata2": "metadata2",
    "metadata3": "metadata3"
  },
  "IsValid": true,
  "SummaryConcepts": "",
  "Language": "1",
  "Source": "Sitemap - fake source"
}
Final Body >>> <html><body>This is a custom View As HTML stream set by a postconversion script!</body></html>
{
  "Title": "Test 4 page",
  "URI": "http://www.perdu.com/test4",
  "Metadata": {
    "metadata1": "metadata1",
    "metadata2": "metadata2",
    "metadata3": "metadata3"
  },
  "IsValid": true,
  "SummaryConcepts": "",
  "Language": "1",
  "Source": "Sitemap - fake source"
}
Final Body >>> <html><body>This is a custom View As HTML stream set by a postconversion script!</body></html>
{
  "Title": "Test 5 page",
  "URI": "http://www.perdu.com/test5",
  "Metadata": {
    "metadata1": "metadata1",
    "metadata2": "metadata2",
    "metadata3": "metadata3"
  },
  "IsValid": true,
  "SummaryConcepts": "",
  "Language": "1",
  "Source": "Sitemap - fake source"
}
Final Body >>> <html><body>This is a custom View As HTML stream set by a postconversion script!</body></html>

Example of a fake environment documents

[
    {
        "URI": "http://www.perdu.com/test1",
        "Title": "Test 1 page",
        "Source" : "Sitemap - fake source",
        "Metadata": {
        },
        "Body":"<html><body><div>this is a test page 1 html<\/div><\/body><\/html>"
    },
    {
        "URI": "http://www.perdu.com/test2",
        "Title": "Test 2 page",
        "Source" : "Sitemap - fake source",
        "Metadata": {
        },
        "Body":"<html><body><div>this is a test page 2 html<\/div><\/body><\/html>"
    },
    {
        "URI": "http://www.perdu.com/test3",
        "Title": "Test 3 page",
        "Source" : "Sitemap - fake source",
        "Metadata": {
        },
        "Body":"<html><body><div>this is a test page 3 html<\/div><\/body><\/html>"
    },
    {
        "URI": "http://www.perdu.com/test4",
        "Title": "Test 4 page",
        "Source" : "Sitemap - fake source",
        "Metadata": {
        },
        "Body":"<html><body><div>this is a test page 4 html<\/div><\/body><\/html>"
    },
    {
        "URI": "http://www.perdu.com/test5",
        "Title": "Test 5 page",
        "Source" : "Sitemap - fake source",
        "Metadata": {
        },
        "Body":"<html><body><div>this is a test page 5 html<\/div><\/body><\/html>"
    }
]

Conversion/Custom script samples

Keep in mind that Coveo conversion script are in fact only [For Coveo Cloud V1] supporting JScript language which is different than Javascript as you may think.

JScript is the Microsoft dialect of the ECMAScript scripting language specification.

JavaScript (the Netscape/Mozilla implementation of the ECMA specification), JScript, and ECMAScript are very similar >languages. In fact the name JavaScript is often used to refer to ECMAScript or JScript.

Microsoft uses the name JScript for its implementation to avoid trademark issues (JavaScript is a trademark of Oracle Corporation)

From Wikipedia: http://en.wikipedia.org/wiki/Jscript

Enjoy! Feel free to contribute :)

coveo-mock-conversion's People

Contributors

jfallaire avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

elafleur

coveo-mock-conversion's Issues

Supports option to connect to coveo cloud directly

the idea would be to pass the environment file and org id as argument, the program would ask for your credentials, then ask to choose a script into the available list of custom script for the given org.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.