Contains JavaScript & TypeScript object models for Microsoft Power BI JavaScript SDK
Перейти к файлу
Tuoheng Yu b77c97ea22 Merged PR 336581: [Quick Create]Add aggregateFunction to ColumnSchema
Add aggregateFunction to ColumnSchema

Tech spec: https://microsoft.sharepoint.com/:w:/t/PowerBI/EUmfm6Yccy9OrewTu3NtB1oBt9gQ1u9YbPxjZBv8nEn_2Q?e=AYvUyR

Related work items: #701218
2022-12-26 09:39:37 +00:00
.config/merlinbot Merged PR 328661: Remove myself from merlin 2022-11-29 08:58:04 +00:00
.pipelines Merged PR 326985: Removed revision from version to support NPM set as latest in release pipeline 2022-11-23 07:13:21 +00:00
src Merged PR 336581: [Quick Create]Add aggregateFunction to ColumnSchema 2022-12-26 09:39:37 +00:00
test Merged PR 326553: Add missing advanced filter operators 2022-11-22 10:21:00 +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 323984: version bump 1.12.3 2022-11-13 14:36:41 +00:00
package.json Merged PR 323984: version bump 1.12.3 2022-11-13 14:36:41 +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"
    }
  ]
}