Contains JavaScript & TypeScript object models for Microsoft Power BI JavaScript SDK
Перейти к файлу
Matt Mazzola 53e9646092 0.8.0 2016-09-06 15:23:51 -07:00
.vscode Setup tslint on build and test to enforce good practices and consistent style. (#9) 2016-08-22 09:52:58 -07:00
src Add support for validating dashboard load configuration and split models into separate report and dashboard modules. (#13) 2016-09-01 15:56:27 -07:00
test Add support for validating dashboard load configuration and split models into separate report and dashboard modules. (#13) 2016-09-01 15:56:27 -07:00
.gitignore Revert .gitignore change which excluded all dotfiles. 2016-08-30 10:27:16 -07:00
.travis.yml Add typescript and typings as devDependencies and use npm scripts for install, build, and test related actions to prevent need for global dependencies 2016-08-05 13:23:45 -07:00
CONTRIBUTING.md Add typescript and typings as devDependencies and use npm scripts for install, build, and test related actions to prevent need for global dependencies 2016-08-05 13:23:45 -07:00
LICENSE.txt Initial Commit of powerbi-models. Has interfaces which are shared between host and iframe code. 2016-06-23 11:34:44 -07:00
README.md Add code samples to README.md on how to create filters. 2016-08-18 15:20:06 -07:00
gulpfile.js Setup tslint on build and test to enforce good practices and consistent style. (#9) 2016-08-22 09:52:58 -07:00
karma.conf.js Setup tslint on build and test to enforce good practices and consistent style. (#9) 2016-08-22 09:52:58 -07:00
package.json 0.8.0 2016-09-06 15:23:51 -07:00
tsconfig.json Setup tslint on build and test to enforce good practices and consistent style. (#9) 2016-08-22 09:52:58 -07:00
tslint.json Setup tslint on build and test to enforce good practices and consistent style. (#9) 2016-08-22 09:52:58 -07:00
typings.json Initial Commit of powerbi-models. Has interfaces which are shared between host and iframe code. 2016-06-23 11:34:44 -07:00
webpack.config.js Initial Commit of powerbi-models. Has interfaces which are shared between host and iframe code. 2016-06-23 11:34:44 -07:00
webpack.test.config.js Copy powerbi-filters code into powerbi-models code. Rename test files and add more tests for settings validation. 2016-06-23 11:34:44 -07:00
webpack.test.tsconfig.json Setup tslint on build and test to enforce good practices and consistent style. (#9) 2016-08-22 09:52:58 -07:00

README.md

powerbi-models

Build Status NPM Version NPM Total Downloads NPM Monthly Downloads GitHub tag

Contains JavaScript & TypeScript object models for Microsoft Power BI JavaScript SDK.

For each model there is a TypeScript interface, a json schema definitions, and a validation function to ensure a given object is a valid model.

Documentation

https://microsoft.github.io/powerbi-models

Getting Started

Install

npm install --save powerbi-models

Import

import * as models from 'powerbi-models';

Usage

Validation:

let testObject = { x: 1 };

const errors = models.validateLoad(testObject);

if(errors) {
  console.warn(errors);
}

Would output to the console:

[
  {
    message: 'accessToken is required'
  }
]

Creating filters:

const basicFilter: models.IBasicFilter = {
  target: {
    table: "Products",
    column: "Version"
  },
  operator: "In",
  values: [
    1,
    2,
    3,
    4
  ]
};

const advancedFilter: models.IAdvancedFilter = {
  target: {
    table: "Products",
    column: "Name"
  },
  logicalOperator: "Or",
  conditions: [
    {
      operator: "Contains",
      value: "Power"
    },
    {
      operator: "Contains",
      value: "Microsoft"
    }
  ]
};

Or use the constructor methods:

const advancedFilter = new models.AdvancedFilter(
  {
    table: "Products",
    column: "Name"
  },
  "Or",
  {
    operator: "Contains",
    value: "Power"
  },
  {
    operator: "Contains",
    value: "Microsoft"
  }
);