all files / lib/ config.js

100% Statements 0/0
100% Branches 0/0
100% Functions 0/0
100% Lines 0/0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47                                                                                             
/*!
 * Sheetrock
 * Quickly connect to, query, and lazy-load data from Google Sheets.
 * https://chriszarate.github.io/sheetrock/
 * License: MIT
 */
 
// Defaults for Sheetrock user options.
const defaults = {
  url: '',           // String  -- Google Sheet URL
  query: '',         // String  -- Google Visualization API query
  target: null,      // DOM Element -- An element to append output to
  fetchSize: 0,      // Integer -- Number of rows to fetch (0 = all)
  labels: [],        // Array   -- Override *returned* column labels
  rowTemplate: null, // Function / Template
  callback: null,    // Function
  reset: false,      // Boolean -- Reset request status
};
 
// Map of legacy (pre-v1.0.0) option names to current user option names.
const legacyOptions = {
  sql: 'query',
  resetStatus: 'reset',
  chunkSize: 'fetchSize',
  rowHandler: 'rowTemplate',
};
 
// Google Visualization API endpoints and parameter formats.
const sheetTypes = {
  2014: {
    apiEndpoint: 'https://docs.google.com/spreadsheets/d/%key%/gviz/tq?',
    keyFormat: new RegExp('spreadsheets/d/([^/#]+)', 'i'),
    gidFormat: new RegExp('gid=([^/&#]+)', 'i'),
  },
  2010: {
    apiEndpoint: 'https://spreadsheets.google.com/tq?key=%key%&',
    keyFormat: new RegExp('key=([^&#]+)', 'i'),
    gidFormat: new RegExp('gid=([^/&#]+)', 'i'),
  },
};
 
export {
  defaults,
  legacyOptions,
  sheetTypes,
};