dataSets

An async function that returns a list of data sets to make available to the user.

Parameters

We will call this function with a single argument containing the following information;

type IdentityConfig = {
  dashboardAccess: {
    accessType: 'standard' | 'admin';
 
    organisationId: string;
 
    // Unique identifier for the user
    userReference: string;
 
    // ISO 8601 format.
    expires: string;
 
    // Signature to verify this object hasn't been tampered with.
    // Use your Vizzly public key to verify this.
    signature: string;
  };
  dataAccess?: {
    dataSetIds: string[] | '*';
 
    // Secure filters which are sent with every query for
    // a given data set.
    secureFilters: {
      [dataSetId: string]: Array<Query.Filter>;
    };
 
    // ISO 8601 format.
    expires: string;
 
    // Signature to verify this object hasn't been tampered with.
    // Use your Vizzly public key to verify this.
    signature: string;
  };
};

The dataAccess object is optional, and will only be provided if your identity callback returns a data access token.

Return value

From this dataSets function, you should return an array of data sets. If there is an error, you should return null.

Array<{
  // ID of the data set.
  id: string;
 
  // Public name of the data set, displayed to your users.
  name: string;
 
  // Fields that make up the data set.
  fields: Array<{
    // Unique constant that identifies this field.
    id: string;
 
    // Public name of the field, displayed to your users.
    publicName: string;
 
    // Data type of the field
    dataType: 'number' | 'boolean' | 'string' | 'date_time' | 'string[]';
 
    // Can this field be used as a dimension? Default: true
    canBeDimension?: boolean;
 
    // Can this field be used as a measure? Default: true
    canBeMeasure?: boolean;
 
    // What date/time granularities can be used on this field
    // Note; only valid for fields with a dataType of `date_time`.
    allowedGranularities?: Array<'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year'>;
  }>;
}>;