Skip to main content Link Search Menu Expand Document (external link)

Parser Registry Plug-in

The parser registry plug-in adds a custom interface that allows:

  • email parsers to be added to Jancy that can be used to locate and parse different types of emails using either the gmail or imap resolver.
  • sms parsers to be added to Jancy that can be used to parse text messages from various services captured by SMS providers (e.g. seatheros, textchest)
  • adds a custom Jancy page at jancy://parsers that, if visited in Jancy, will display all the registed email parsers.

A handle to the parser registry can be retrieved via jancy.getInterface('parserRegistry').

Parser Registry Interface Methods

parserRegistry.registerParser(type, key, parser)

  • type (string) – can either be "email" or "sms"
  • key (string)
  • parser (object)

Registers a specialized parser object that customizes how either email profile resolvers will find emails and parse their contents or how sms profile resolvers will parse text messages.

The parser object when type is email needs to have the following functions defined on it.

  • canRun(jancy, args)

    canRun should return true if the parser can run based on args or false otherwise

canRun(jancy, args) {
   return (args.resolverName === 'gmail' || args.resolverName === 'imap') && args.profile?.email && args.site === 'ticketmaster'
}
getQuery(jancy, args) {
  if (args.resolverName === 'gmail') {
    return `{subject:"Here's Your Authentication Code" subject:"Your request to reset password"} to:${ args.profile.email }`
  }

  // args.resolverName === 'imap'
  return {
    to: args.profile.email,
    or: [
      { subject: "Here's Your Authentication Code" },
      { subject: "Your request to reset password" }
    ]
  }
}
  • parseMessage(jancy, args, msg)

    parseMessage will get a the first email found by the query returned by getQuery. parseMessage should attempt to parse the contents of the given message and return a string that will be used as the resolved value for the profile resolver.

The parser object when type is sms needs to have the following functions defined on it.

parseMessage should attempt to parse the contents of the given message and return a string that will be used as the resolved value for the profile resolver.

emailParserRegistry.unregisterParser(key)

  • type (string) – can either be "email" or "sms"
  • key (string)

Unregisters a previously registered parser.