Contains JavaScript & TypeScript object models for Microsoft Power BI JavaScript SDK
Перейти к файлу
Kotana Sai 08dba6aefc Merged PR 312627: Upgrade karma to use Chrome instead of Phantom JS for powerbi-models
Upgrade karma to use Chrome instead of Phantom JS

Test Pipeline Result:
https://dev.azure.com/powerbi/Embedded/_build/results?buildId=5801379&view=results
2022-11-09 07:18:50 +00:00
.config/merlinbot Merged PR 178692: Add merlin config 2021-06-15 06:39:46 +00:00
.pipelines Merged PR 311056: Adding OneBranch pipeline YAML config file for powerbi-models-Buddy 2022-10-24 20:55:00 +00:00
src Merged PR 308101: Add new model for smart narrative output 2022-10-30 13:53:05 +00:00
test Merged PR 317384: Add displayName to column schema 2022-10-28 22:26:10 +00:00
.eslintignore Merged PR 260487: Migrate the powerbi-models library from TSLint to ESLint 2022-05-16 05:26:46 +00:00
.eslintrc.js Merged PR 267928: Fix broken powerbi-models@1.10.1 - Release version 1.10.2 2022-05-29 14:03:31 +00:00
.gitignore Merged PR 269241: Adding package-lock.json 2022-05-31 10:27:09 +00:00
.npmrc Merged PR 282079: Remediating Azure Artifacts Configuration Issues in your Repository 2022-08-31 14:55:45 +00:00
.travis.yml skip cleanup to ensure npm modules exists. 2017-10-15 16:16:32 +03:00
CONTRIBUTING.md Merged PR 265476: [powerbi-models] Fix remaining vulnerabilities 2022-05-19 09:01: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 Merged PR 130054: [powerbi-models]: Make master up-to-date with portal 2020-11-30 04:57:39 +00:00
SECURITY.md Merged PR 144019: Added SECURITY.md 2021-02-03 12:47:02 +00:00
gulpfile.js Merged PR 260487: Migrate the powerbi-models library from TSLint to ESLint 2022-05-16 05:26:46 +00:00
karma.conf.js Merged PR 312627: Upgrade karma to use Chrome instead of Phantom JS for powerbi-models 2022-11-09 07:18:50 +00:00
owners.txt Merged PR 289793: Add QuickCreate models 2022-08-18 19:13:56 +00:00
package-lock.json Merged PR 312627: Upgrade karma to use Chrome instead of Phantom JS for powerbi-models 2022-11-09 07:18:50 +00:00
package.json Merged PR 312627: Upgrade karma to use Chrome instead of Phantom JS for powerbi-models 2022-11-09 07:18:50 +00:00
tsconfig.json Merged PR 267928: Fix broken powerbi-models@1.10.1 - Release version 1.10.2 2022-05-29 14:03:31 +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 Merged PR 143202: Add capture all pages option to bookmark capture options 2021-02-02 16:05:08 +00:00
webpack.test.tsconfig.json Merged PR 267928: Fix broken powerbi-models@1.10.1 - Release version 1.10.2 2022-05-29 14:03:31 +00: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"
    }
  ]
}