Clojure

The Clojure API for the Pebble Stream Runtime

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

`:big-decimal?` Use BigDecimal instead of double for decimal calculations.  
`:big-decimal-precision` BigDecimal precision value.  
`:input-col-map` Map of sheet name to 0-index column to column values.  
`:input-cols` Map of sheet name to columns.  
`:input-rows-of-strings` Map of sheet name to a vector of vector of strings
  which should be coerced to the appropriate type.  
`:out-xlsx-path` File path to save results as an .xlsx file.  
`:output-worksheets` List of sheets to stitch together for the final output.  
`:pbl` The bytes of the path of the pebble to run  
`:pbl-id` The unique identifier for the executed pebble  
`:post-url` A URL to POST the results to  
`:print-classifications?` Print each sheet and its classification.  
`:print-directives?` Print each directive (e.g., stop, sort).  
`:print-inputs` Input sheets to print before rendering.  
`:print-render?` 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  
`:require-all-input-sheets?` If expected inputs are not provided, fail execution.  
`:return-output-context?` Return a context map rather than just the result.  
`:split-lazy?` SPLIT directives create lazy-seq rather than a vector. 
`:trim-directives?` Removes stop* and fail columns.

Here are the runtime functions available in the Clojure runtime:

save-values-as-xlsx

save-values-as-xlsx [{:keys [out-xlsx-path template-path values] :as context}]
Saves the map of worksheet name to rows as a .xlsx file at the provided
  filepath using the style template stored in the pebble.

context->columns

context->columns [context]
Given the pebble context returned by run-pbl context, give back a column-wise
  vector grid of Clojure values.

context->rows

context->rows [context]
Given the pebble context returned by run-pbl context, give back a vector grid
  of Clojure values.

describe-inputs-and-outputs

describe-inputs-and-outputs [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
  pebblestream:out directive. Their order is as in the original file.

get-column-dependencies

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

get-column-types

get-column-types [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.

get-dependencies

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

get-split-worksheets

get-split-worksheets [context]
Returns the names of sheets that are destinations of a split directive.

get-worksheet-hints

get-worksheet-hints [context]
Returns a map of sheet name to hint name to a vector of values.

load-pbl

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

run-pbl

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

save-values-as-xlsx

save-values-as-xlsx [{:keys [out-xlsx-path template-path values] :as context}]
Saves the map of worksheet name to rows as a .xlsx file at the provided
  filepath using the style template stored in the pebble.