Contains JavaScript & TypeScript object models for Microsoft Power BI JavaScript SDK
Перейти к файлу
dependabot[bot] 5b557c7c93
Bump ua-parser-js from 0.7.31 to 0.7.33
Bumps [ua-parser-js](https://github.com/faisalman/ua-parser-js) from 0.7.31 to 0.7.33.
- [Release notes](https://github.com/faisalman/ua-parser-js/releases)
- [Changelog](https://github.com/faisalman/ua-parser-js/blob/master/changelog.md)
- [Commits](https://github.com/faisalman/ua-parser-js/compare/0.7.31...0.7.33)

---
updated-dependencies:
- dependency-name: ua-parser-js
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-14 06:14:15 +00:00
src Merged PR 326553: Add missing advanced filter operators 2023-01-24 11:51:12 +00:00
test Merged PR 326553: Add missing advanced filter operators 2023-01-24 11:51:12 +00:00
.eslintignore Merge remote-tracking branch 'powerbi/master' into release-1.10.1 2022-05-31 16:16:27 +03:00
.eslintrc.js Merge remote-tracking branch 'powerbi/master' into release-1.10.1 2022-05-31 16:16:27 +03:00
.gitignore Merge remote-tracking branch 'powerbi/master' into release-1.10.1 2022-05-31 16:16:27 +03:00
.travis.yml skip cleanup to ensure npm modules exists. 2017-10-15 16:16:32 +03:00
CONTRIBUTING.md Merged PR 130054: [powerbi-models]: Make master up-to-date with portal 2020-11-30 04:57:39 +00: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 Merge remote-tracking branch 'devops/master' into version_1.8.0 2021-01-06 10:46:32 +02:00
SECURITY.md merge 2021-06-20 15:02:35 +03:00
gulpfile.js Merge remote-tracking branch 'powerbi/master' into release-1.10.1 2022-05-31 16:16:27 +03:00
karma.conf.js merge 2021-06-20 15:02:35 +03:00
package-lock.json Bump ua-parser-js from 0.7.31 to 0.7.33 2023-02-14 06:14:15 +00:00
package.json Merge remote-tracking branch 'powerbi/master' into release-1.12.4 2023-01-25 09:51:58 +02:00
tsconfig.json Merged PR 130054: [powerbi-models]: Make master up-to-date with portal 2020-11-30 04:57:39 +00:00
typings.json Merged PR 130054: [powerbi-models]: Make master up-to-date with portal 2020-11-30 04:57:39 +00:00
webpack.config.js initial commit 2020-12-30 09:10:30 +02:00
webpack.test.config.js merge 2021-06-20 15:02:35 +03:00
webpack.test.tsconfig.json Merge remote-tracking branch 'powerbi/master' into release-1.10.1 2022-05-31 16:16:27 +03: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.

Issues

Power BI Support Page

Power BI Ideas

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"
    }
  ]
}