JavaScript

The JavaScript API for the Pebble Stream Runtime

Many of the Pebble Stream Runtime API functions expect a context object as input. Pebble Stream Runtime functions do not use every key in the context object. Here are the defined keys of this context object:

`inputColMap` Map of sheet name to 0-index column to column values.
`inputCols` Map of sheet name to columns.
`inputRowsOfStrings` Map of sheet name to a vector of vector of strings
  which should be coerced to the appropriate type.
`outXlsxPath` File path to save results as an .xlsx file.
`outputWorksheets` List of sheets to stitch together for the final output.
`pbl` The bytes of the path of the pebble to run
`pblId` The unique identifier for the executed pebble
`postUrl` A URL to POST the results to
`printClassifications` Print each sheet and its classification.
`printDirectives` Print each directive (e.g., stop, sort).
`printInputs` Input sheets to print before rendering.
`printRender` Print each worksheet and cell as Pebble Stream runtime renders it.
`reload` Don't check the cache for the pebble before loading and caching it
`requireAllInputSheets` If expected inputs are not provided, fail execution.
`returnOutputContext` Return a context object rather than just the result.
`splitLazy` SPLIT directives create lazySeq rather than a vector.
`trimDirectives` Removes stop* and fail columns.

Here are the runtime functions available in the javascript runtime:

contextToColumns

contextToColumns [context]
Given the pebble context returned by runPbl context, give back a column-wise
  vector grid of Clojure values.

contextToRows

contextToRows [context]
Given the pebble context returned by runPbl context, give back a vector grid
  of Clojure values.

describeInputsAndOutputs

describeInputsAndOutputs [context]
Returns
  ```edn
  {inputs:
   [{name: 'Sheet1'
     columns: [{headers: ['count'] types: #{'number'}}
               {headers: ['Enrolled'] types: #{'boolean'}}
               {headers: ['State'] types: #{'blank' 'string'}}]}
    ...]
   outputs: [...]}
   
  where "outputs" is the union of 'final' worksheets and those set with the
  :pebblestreamout directive. Their order is as in the original file.

getColumnDependencies

getColumnDependencies [context]
Return a map of `sheet -> col -> #{[sheet col] ...}` representing columns that
  column depends on.

getColumnTypes

getColumnTypes [context]
Returns the map of sheet name to an array of set of types where each index in
  said array is its corresponding column's set of seen types in the original
  worksheet.

getDependencies

# getDependencies [context]
Returns a map from sheet name to the set of sheet names on which it depends.

getSplitWorksheets

getSplitWorksheets [context]
Returns the names of sheets that are destinations of a split directive.

getWorksheetHints

getWorksheetHints [context]
Returns a map of sheet name to hint name to a vector of values.

loadPbl

loadPbl [context]
Loads the pebble into the cache, so future uses of it should be fast.

runPbl

runPbl [context]
Run the pebble stored in pbl using the value grids of inputRows as
  the data for the corresponding key input name, returning the stitched
  spreadsheet object with the results.

saveValuesAsXlsx

saveValuesAsXlsx [{:keys [outXlsxPath templatePath values] :as context}]
Saves the object of worksheet name to rows as a .xlsx file at the provided
  filepath using the style template stored in the pebble.