Google Sheets backend.

Hierarchy (view full)

Constructors

Properties

accessToken: any
apiKey: any
authPopup: Window
clientId: any
data: any
options: any
permissions: any
rawData: string
ready: Promise<void>
ref: any
source: string
spreadsheet: any
user: any
_all: any[] = []
api: {
    user: {
        fields: {
            avatar: string[];
            name: string[];
            username: string;
        };
        get: string;
    };
} = ...

Type declaration

  • user: {
        fields: {
            avatar: string[];
            name: string[];
            username: string;
        };
        get: string;
    }
    • fields: {
          avatar: string[];
          name: string[];
          username: string;
      }
      • avatar: string[]
      • name: string[]
      • username: string
    • get: string
apiDomain: string = "https://sheets.googleapis.com/v4/spreadsheets/"
authProvider: string = "https://auth.madata.dev"

Auth Provider to use. This is only relevant for OAuthBackend, but specifying here as Backend is the only class users import.

capabilities: {
    auth: boolean;
    put: boolean;
} = ...

Type declaration

  • auth: boolean
  • put: boolean
defaultFormat: string = "JSON"
defaultPermissions: {
    read: boolean;
} = ...

Type declaration

  • read: boolean
hooks: Hooks = hooks
oAuth: string = "https://accounts.google.com/o/oauth2/auth"
phrases: {
    get_no_sheet: string;
    get_no_sheet_or_invalid_range: ((sheet, range, sheetIndex) => string);
    get_no_spreadsheet: ((url) => string);
    store_no_sheet: ((sheet) => string);
    store_sheet_added: ((sheet) => string);
} = ...

Type declaration

  • get_no_sheet: string
  • get_no_sheet_or_invalid_range: ((sheet, range, sheetIndex) => string)
      • (sheet, range, sheetIndex): string
      • Parameters

        • sheet: any
        • range: any
        • sheetIndex: any

        Returns string

  • get_no_spreadsheet: ((url) => string)
      • (url): string
      • Parameters

        • url: any

        Returns string

  • store_no_sheet: ((sheet) => string)
      • (sheet): string
      • Parameters

        • sheet: any

        Returns string

  • store_sheet_added: ((sheet) => string)
      • (sheet): string
      • Parameters

        • sheet: any

        Returns string

scopes: string[] = ...
urls: {
    hash: string;
    hostname: string;
    pathname: string;
}[] = ...

Type declaration

  • hash: string
  • hostname: string
  • pathname: string
useCache: boolean = false

Accessors

  • get authProviderServices(): Promise<any>
  • services.json from the auth provider will be cached here. You could also set this manually to avoid the network request.

    Returns Promise<any>

    Member

  • get host(): any
  • Return the hostname of the first URL pattern in the urls array, if not variable. This is used to facilitate relative URLs when constructing Backends directly. Subclasses with variable hostnames can override this.

    Returns any

  • get title(): string
  • Returns string

Methods

  • Get title of the sheet in the spreadsheet.

    Parameters

    • ref: any = ...

      Spreadsheet to work with.

    Returns Promise<any>

    Sheet title or title of the first visible sheet, or null if there are no (visible) sheets to work with.

  • Abstract

    Show authentication UI to the user. Must be implemented by subclasses.

    Parameters

    • o: any

    Returns Promise<any>

  • Get info about the current user, if logged in. Subclasses are generally expected to override this.

    Returns Promise<any>

    • User info
  • Is current user authenticated? Synchronous because it must not trigger any API calls, use passiveLogin() for that

    Returns boolean

  • Higher-level method for reading data from the backend. Subclasses should usually NOT override this method.

    Parameters

    • url: string

      URL to fetch, if different from that provided in the constructor

    • Rest ...args: any[]

    Returns any

    • Data from the backend as a JSON object, null if not found
  • Abstract

    Try to authenticate a previously authenticated user (i.e. without showing any login UI).

    Returns Promise<void>

  • Helper for making OAuth requests with JSON-based APIs.

    Parameters

    • call: string

      API endpoint

    • Optional data: any

      Data to send with the request

    • Optional method: string = "GET"

      HTTP method

    • Optional req: {
          headers: any;
          responseType: string;
      }

      Extra request options

      • headers: any

        Extra headers

      • responseType: string

        Response type

    Returns Promise<any>

    • JSON response
  • Higher-level method for writing data to the backend. Subclasses should usually NOT override this method.

    Parameters

    • data: any

      Data to write to the backend

    • Optional o: any = {}

      Options object

    Returns any

    • If successful, info about the stored data
  • Sync the logged in user, i.e. log in passively when another backend has logged in and log out when another backend has logged out. Generally intended to be used for backends with the same authentication mechanism. Syncing is not two-way, you need to call this on the other backend as well to make it so.

    Parameters

    Returns void

  • Update an existing backend instance with new parameters

    Parameters

    • url: string

      Same as constructor

    • o: any

      Same as constructor

    Returns void

  • Transform an array of objects to an array of arrays.

    Parameters

    • keys: Map<string, string>

      A map between column indices and object keys.

    • values: any[]

      An array of objects. Each object corresponds to an individual spreadsheet row.

    Returns any[][]

    An array of arrays. Each nested array corresponds to an individual spreadsheet row.

  • Get the range reference.

    Parameters

    • __namedParameters: string = {}

    Returns string

    The range reference in one of the supported formats: 'Sheet title'!Range, 'Sheet title', or Range.

  • Transform an array of arrays to an array of objects.

    Parameters

    • keys: Map<string, string>

      A map between column indices and object keys.

    • values: any[][]

      An array of values from a spreadsheet. Each nested array corresponds to an individual spreadsheet row.

    Returns any[]

    An array of objects. Each object corresponds to an individual spreadsheet row.

  • Return the appropriate backend(s) for this url

    Parameters

    • url: string

      URL describing the storage location

    • Optional o: {
          existing: Backend | Backend[];
      } = {}

      Options object to be passed to the backend

      • existing: Backend | Backend[]

        Existing backend object(s) to re-use if possible

    Returns any

  • Get an object key taking into account that there might be duplicates among column headers.

    Parameters

    • header: string

      Header text.

    • index: number

      Column index (zero-based).

    • headers: [string]

      Array of column headers.

    Returns string

    Object key.

Generated using TypeDoc