npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

microsoft-partnercenter

v6.0.0

Published

## Getting Started

Downloads

481

Readme

Microsoft PartnerCenter and Graph API SDK for NodeJS

Getting Started

You can install the package with the following command:

npm install microsoft-partnercenter

or

yarn add microsoft-partnercenter

or

pnpm install microsoft-partnercenter

Partner Center API

Initialize with Client ID and Client Secret Auth & Partner Domain:

import { MicrosoftPartnerCenter } from "microsoft-partnercenter"

const msPartnerCenter = new MicrosoftPartnerCenter({
  partnerDomain: "partner.onmicrosoft.com",
  authentication: {
    clientId: "1",
    clientSecret: "1",
  },
})

Graph API

Initialize with Client ID, Client Secret, and Tenant ID:

import { MicrosoftGraphApi } from "microsoft-partnercenter"

const msGraphApi = new MicrosoftGraphApi({
  tenantId: "your-tenant-id",
  authentication: {
    clientId: "1",
    clientSecret: "1",
  },
})

Example Usage

Partner Center API

Get all Customers

await msPartnerCenter.getAllCustomers()

Create Order

const customerId = "123"
const billingCycle = "monthly"

const lineItems = [
  {
    offerId: "1",
    quantity: 16,
    termDuration: "P1M",
  },
]

await msPartnerCenter.createOrder(customerId, billingCycle, lineItems)

Graph API

Create a GDAP Relationship

const relationship = await msGraphApi.createGDAPRelationship({
  displayName: "My GDAP Relationship",
  partner: {
    tenantId: "partner-tenant-id",
  },
  customer: {
    tenantId: "customer-tenant-id",
  },
  accessDetails: {
    unifiedRoles: ["Directory Readers"],
  },
  duration: "P90D",
})

Get All GDAP Relationships

const relationships = await msGraphApi.getAllGDAPRelationships()

Create a Domain

const domain = await msGraphApi.createDomain("example.com")

Get All Domains

const domains = await msGraphApi.getAllDomains()

Authentication

Both the Partner Center API and Graph API support authentication using client credentials (client ID and client secret). The SDK handles token management and renewal automatically.

Error Handling

The SDK includes built-in error handling and will automatically retry on certain errors (e.g., 401 Unauthorized). You can configure retry behavior in the config object:

const msPartnerCenter = new MicrosoftPartnerCenter({
  // ... other config
  conflict: {
    retryOnConflict: true,
    retryOnConflictDelayMs: 1000,
    maximumRetries: 3,
  },
})

Documentation

For more detailed information about available methods and their parameters, please refer to the TypeScript definitions included with this package.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request