File: service.coffee

Defined in:

Constant Summary

DEFAULT_PROTOCOL =

If the user doesn't add one on their url, assume HTTP.

"http://"
VERSION_PATH =

A list of endpoints exposed by the service.

"version"
TEMPLATES_PATH =
"templates"
RELEASE_PATH =
"version/release"
CLASSKEY_PATH =
"classkeys"
LISTS_PATH =
"lists"
MODEL_PATH =
"model"
SUMMARYFIELDS_PATH =
"summaryfields"
QUERY_RESULTS_PATH =
"query/results"
QUICKSEARCH_PATH =
"search"
WIDGETS_PATH =
"widgets"
ENRICHMENT_PATH =
"list/enrichment"
WITH_OBJ_PATH =
"listswithobject"
SUBTRACT_PATH =
'lists/subtract'
WHOAMI_PATH =
"user/whoami"
PREF_PATH =
'user/preferences'
PATH_VALUES_PATH =
'path/values'
USER_TOKENS =
'user/tokens'
ID_RESOLUTION_PATH =
'ids'
HAS_PROTOCOL =

Pattern for detecting if URI has a protocol

/^https?:\/\//i
HAS_SUFFIX =

Pattern for detecting if the URI has the necessary service suffix.

/service\/?$/i
SUFFIX =

The suffix all service URIs must end in.

"/service/"

Method Summary

Method Details

? (void) NEEDS_AUTH(path, q)

? (void) DEFAULT_ERROR_HANDLER(e)

BY DEFAULT, LOG ERRORS TO THE CONSOLE.

? (([List) getListFinder(name)

A private helper that produces a function that will read through an array of Lists, and find the first one with the given name. The returned function returns a promise to find the given list, and will be rejected if no list of that name can be found.

Parameters:

  • name (String) The name of the list to find.

Returns:

  • ([List

? (void) LIST_PIPE(service, prop = 'listName')

? (void) TO_NAMES(xs = [])

? (Promise<BufferedReader<Array<Object>>>) Service.prototype.rowByRow(q, args...)

Process the results of a query row by row.

Parameters:

  • q (Query) The query to run.
  • page (Object) The page of results to return.
  • doThis (->) A callback for each row (optional).
  • onErr (->) A callback to handle errors (optional).
  • onEnd (->) A callback to be called when all rows have been received (optional).

Options Hash: (page):

  • start (Number) The index of the first row to return (optional; default = 0)
  • size (Number) The maximum number of results to return (optional; default = null, ie. all)

Returns:

  • (Promise<BufferedReader<Array<Object>>>) — a promise to yield an iterator over the rows.

? (Promise<BufferedReader<Object>>) Service.prototype.recordByRecord(q, args...)

Process the results of a query item by item.

Parameters:

  • q (Query) The query to run.
  • page (Object) The page of results to return. It is best not to try and page object based results unless for batching reasons.
  • doThis (->) A callback for each row (optional).
  • onErr (->) A callback to handle errors (optional).
  • onEnd (->) A callback to be called when all rows have been received (optional).

Options Hash: (page):

  • start (Number) The index of the first row to return (optional; default = 0)
  • size (Number) The maximum number of results to return (optional; default = null, ie. all)

Returns:

  • (Promise<BufferedReader<Object>>) — a promise to yield an iterator over the results.

? (void) Service.flushCaches()

Static method to flush the cached models, versions and summary-field informations.

This should be used if running in a persistent process and this data is at risk of getting stale.

? (void) Service.connect(opts)

Static method for instantiation. Allows us to provide alternate implementations in the future, and pass this function around when needed.