Hierarchy

  • DataLibraryPowers

Index

Methods

Static get

  • get<T>(reportKey: string): Promise<T[]>
  • Retrieve data from data library.

    throws

    {TypeError} when reportKey is missing.

    example

    Getting data library report data from within your skill code

    // Ensure you import DataLibraryPowers
    import { DataLibraryPowers } from "@andi/powers";
    
    // getting data library report rows assuming that data library report has these fields as header
    type MyRow = {
        id: string;
        city: string;
        zip: string;
    };
    const rows = await DataLibraryPowers.get<MyRow>("my-test-report-key");
    // access first row
    const id = rows[0].id;
    
    // get data library report rows as dynamic type and then refer a particular column that may have space in it's name
    const rows = await DataLibraryPowers.get<any>("my-test-report-key");
    * // access first row
    const data = rows[0]["my column name"];

    Type parameters

    • T = unknown

    Parameters

    • reportKey: string

      Name of key for data library report.

    Returns Promise<T[]>

    • T[] if report data is available.

Static getVisualization

  • getVisualization(reportKey: string): Promise<string>
  • Retrieve visualization from data library.

    throws

    {TypeError} when reportKey is missing.

    example

    Getting data library report visualization from within your skill code

    // Ensure you import DataLibraryPowers
    import { DataLibraryPowers } from "@andi/powers";
    
    // get data library report visualization, if no visualization is found it returns null
    // visualization is in html string format
    const html = await DataLibraryPowers.getVisualization("my-test-report-key");

    Parameters

    • reportKey: string

      Name of key for data library report.

    Returns Promise<string>

    • Html string Or null.

Static search

  • search<T>(reportKey: string, options: SearchOptions): Promise<T[]>
  • Search data library report based on search criteria in options.

    throws

    {TypeError} when reportKey is missing.

    throws

    {TypeError} when searchOptions is missing.

    example

    Searching data library report rows from within a skill code

    // Ensure you import DataLibraryPowers
    import { DataLibraryPowers, Condition, Operator } from "@andi/powers";
    
    // searching data library report rows assuming that data library report has these fields as header
    type MyRow = {
        id: string;
        city: string;
        zip: string;
    };
    const condition: Condition = { key: "zip", operator: Operator.Equals, value: "34609" };
    const searchOptions: SearchOptions = { where: condition };
    const rows = await DataLibraryPowers.search<MyRow>("my-test-report-key", searchOptions);
    // access first row assuming search criteria returned data so that rows.length is greater than 0
    const id = rows[0].id;
    
    // assuming data library report has these headers : "rateType", "rate", "region name"
    const condition: Condition = { key: "region name", operator: Operator.Equals, value: "FL" };
    const searchOptions: SearchOptions = { where: condition, select: ["rateType", "region name"]};
    const results = await DataLibraryPowers.search<any>("my-test-report-key", searchOptions);
    // your results array will look like [{"rateType": "floating", "region name": "FL"}, {rateType: "fixed", "region name": "NC"}]
    // access first row assuming search criteria returned data so that results.length is greater than 0
    const data = results[0]["region name"];

    Type parameters

    • T = unknown

    Parameters

    • reportKey: string

      Name of key for data library report.

    • options: SearchOptions

      SearchOptions.

    Returns Promise<T[]>

    • T[]. Empty array when no search match is found.

Generated using TypeDoc