Contains JavaScript & TypeScript object models for Microsoft Power BI JavaScript SDK
Перейти к файлу
Noa Nutkevitch 95ea053523 Merged PR 23006: Add more filter types 2017-08-27 11:06:37 +00: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 Merged PR 23006: Add more filter types 2017-08-27 11:06:37 +00:00
test Merged PR 23006: Add more filter types 2017-08-27 11:06:37 +00: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 Update README.md with information on Date foramtting using ISO 8061 2016-09-07 17:27:49 -07:00
gulpfile.js Remove configuration parameter from tslint:test task which incorrectly attempted to add a rule but instead set only a single rule which gave false positive lint passes. 2016-09-07 17:14:59 -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-lock.json icon is optional. 2017-08-24 17:15:43 +03:00
package.json Merged PR 23006: Add more filter types 2017-08-27 11:06:37 +00:00
tsconfig.json update typescript version 2017-03-16 17:09:09 +02: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 add permissions & viewMode to loadConfig (#27) 2016-12-26 16:29:13 +02: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"
  }
);

Date Formatting

Dates should be formated using ISO 8601 standard. Example: 2016-09-08T00:15:46.861Z

This is how dates are naturally serialized to JSON:

new Date().toJSON(); //=> 2016-09-08T00:15:46.861Z

An example filter using this Date format would look like the following:

{
  "$schema": "http://powerbi.com/product/schema#advanced",
  "target": {
    "table": "Time",
    "column": "Date"
  },
  "logicalOperator": "And",
  "conditions": [
    {
      "operator": "GreaterThan",
      "value": "2014-06-01T07:00:00.000Z"
    }
  ]
}