Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ndustrial/contxt-sdk

Package Overview
Dependencies
Maintainers
13
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ndustrial/contxt-sdk - npm Package Compare versions

Comparing version 0.0.46 to 0.0.47

support/fixtures/factories/contxtOrganizationFeaturedApplication.js

6

CHANGELOG.md

@@ -0,1 +1,7 @@

## [v0.0.47](http://github.com/ndustrialio/contxt-sdk-js/tree/v0.0.45) (2019-04-02)
**Added**
- Added `Coordinator#getFeaturedApplications` for getting an organization's list of featured applications
## [v0.0.46](http://github.com/ndustrialio/contxt-sdk-js/tree/v0.0.46) (2019-04-01)

@@ -2,0 +8,0 @@

@@ -15,2 +15,3 @@ <a name="Coordinator"></a>

* [.getFavoriteApplications()](#Coordinator+getFavoriteApplications) ⇒ <code>Promise</code>
* [.getFeaturedApplications(organizationId)](#Coordinator+getFeaturedApplications) ⇒ <code>Promise</code>
* [.getOrganizationById(organizationId)](#Coordinator+getOrganizationById) ⇒ <code>Promise</code>

@@ -134,2 +135,27 @@ * [.getUser(userId)](#Coordinator+getUser) ⇒ <code>Promise</code>

```
<a name="Coordinator+getFeaturedApplications"></a>
### contxtSdk.coordinator.getFeaturedApplications(organizationId) ⇒ <code>Promise</code>
Gets an organization's list of featured applications
API Endpoint: '/organizations/:organizationId/applications/featured'
Method: GET
Note: Only valid for web users using auth0WebAuth session type
**Kind**: instance method of [<code>Coordinator</code>](#Coordinator)
**Fulfill**: <code>ContxtOrganizationFeaturedApplication[]</code> A list of featured applications
**Reject**: <code>Error</code>
| Param | Type | Description |
| --- | --- | --- |
| organizationId | <code>string</code> | The ID of the organization |
**Example**
```js
contxtSdk.coordinator
.getFeaturedApplications('36b8421a-cc4a-4204-b839-1397374fb16b')
.then((featuredApplications) => console.log(featuredApplications))
.catch((err) => console.log(err));
```
<a name="Coordinator+getOrganizationById"></a>

@@ -136,0 +162,0 @@

2

docs/README.md

@@ -145,2 +145,4 @@ ## Classes

<dd></dd>
<dt><a href="./Typedefs.md#ContxtOrganizationFeaturedApplication">ContxtOrganizationFeaturedApplication</a> : <code>Object</code></dt>
<dd></dd>
<dt><a href="./Typedefs.md#ContxtUser">ContxtUser</a> : <code>Object</code></dt>

@@ -147,0 +149,0 @@ <dd></dd>

@@ -255,2 +255,16 @@ <a name="Asset"></a>

<a name="ContxtOrganizationFeaturedApplication"></a>
## ContxtOrganizationFeaturedApplication : <code>Object</code>
**Kind**: global typedef
**Properties**
| Name | Type | Description |
| --- | --- | --- |
| applicationId | <code>number</code> | |
| createdAt | <code>string</code> | ISO 8601 Extended Format date/time string |
| id | <code>string</code> | |
| organizationId | <code>string</code> | |
| updatedAt | <code>string</code> | ISO 8601 Extended Format date/time string |
<a name="ContxtUser"></a>

@@ -257,0 +271,0 @@

@@ -20,2 +20,17 @@ 'use strict';

/**
* @typedef {Object} ContxtApplication
* @property {string} clientId
* @property {string} clientSecret
* @property {string} createdAt ISO 8601 Extended Format date/time string
* @property {string} currentVersionId
* @property {string} description
* @property {string} iconUrl
* @property {number} id
* @property {string} name
* @property {number} serviceId
* @property {string} type
* @property {string} updatedAt ISO 8601 Extended Format date/time string
*/
/**
* @typedef {Object} ContxtOrganization

@@ -43,2 +58,11 @@ * @property {string} createdAt ISO 8601 Extended Format date/time string

/**
* @typedef {Object} ContxtUserFavoriteApplication
* @property {number} applicationId
* @property {string} createdAt ISO 8601 Extended Format date/time string
* @property {string} id
* @property {string} updatedAt ISO 8601 Extended Format date/time string
* @property {string} userId
*/
/**
* Module that provides access to information about Contxt

@@ -66,9 +90,13 @@ *

/**
* Gets information about all contxt organizations
* Adds an application to the current user's list of favorited applications
*
* API Endpoint: '/organizations'
* Method: GET
* API Endpoint: '/applications/:applicationId/favorites'
* Method: POST
*
* Note: Only valid for web users using auth0WebAuth session type
*
* @param {number} applicationId The ID of the application
*
* @returns {Promise}
* @fulfill {ContxtOrganization[]} Information about all contxt organizations
* @fulfill {ContxtUserFavoriteApplication} Information about the contxt application favorite
* @reject {Error}

@@ -78,4 +106,4 @@ *

* contxtSdk.coordinator
* .getAllOrganizations()
* .then((orgs) => console.log(orgs))
* .createFavoriteApplication(25)
* .then((favoriteApplication) => console.log(favoriteApplication))
* .catch((err) => console.log(err));

@@ -86,2 +114,88 @@ */

_createClass(Coordinator, [{
key: 'createFavoriteApplication',
value: function createFavoriteApplication(applicationId) {
if (!applicationId) {
return Promise.reject(new Error('An application ID is required for creating a favorite application'));
}
return this._request.post(this._baseUrl + '/applications/' + applicationId + '/favorites').then(function (favoriteApplication) {
return (0, _objects.toCamelCase)(favoriteApplication);
});
}
/**
* Removes an application from the current user's list of favorited applications
*
* API Endpoint: '/applications/:applicationId/favorites'
* Method: DELETE
*
* Note: Only valid for web users using auth0WebAuth session type
*
* @param {number} applicationId The ID of the application
*
* @returns {Promise}
* @fulfill {undefined}
* @reject {Error}
*
* @example
* contxtSdk.coordinator
* .deleteFavoriteApplication(25)
* .catch((err) => console.log(err));
*/
}, {
key: 'deleteFavoriteApplication',
value: function deleteFavoriteApplication(applicationId) {
if (!applicationId) {
return Promise.reject(new Error('An application ID is required for deleting a favorite application'));
}
return this._request.delete(this._baseUrl + '/applications/' + applicationId + '/favorites');
}
/**
* Gets information about all contxt applications
*
* API Endpoint: '/applications'
* Method: GET
*
* @returns {Promise}
* @fulfill {ContxtApplication[]} Information about all contxt applications
* @reject {Error}
*
* @example
* contxtSdk.coordinator
* .getAllApplications()
* .then((apps) => console.log(apps))
* .catch((err) => console.log(err));
*/
}, {
key: 'getAllApplications',
value: function getAllApplications() {
return this._request.get(this._baseUrl + '/applications').then(function (apps) {
return apps.map(function (app) {
return (0, _objects.toCamelCase)(app);
});
});
}
/**
* Gets information about all contxt organizations
*
* API Endpoint: '/organizations'
* Method: GET
*
* @returns {Promise}
* @fulfill {ContxtOrganization[]} Information about all contxt organizations
* @reject {Error}
*
* @example
* contxtSdk.coordinator
* .getAllOrganizations()
* .then((orgs) => console.log(orgs))
* .catch((err) => console.log(err));
*/
}, {
key: 'getAllOrganizations',

@@ -97,2 +211,29 @@ value: function getAllOrganizations() {

/**
* Gets the current user's list of favorited applications
*
* API Endpoint: '/applications/favorites'
* Method: GET
*
* Note: Only valid for web users using auth0WebAuth session type
*
* @returns {Promise}
* @fulfill {ContxtUserFavoriteApplication[]} A list of favorited applications
* @reject {Error}
*
* @example
* contxtSdk.coordinator
* .getFavoriteApplications()
* .then((favoriteApplications) => console.log(favoriteApplications))
* .catch((err) => console.log(err));
*/
}, {
key: 'getFavoriteApplications',
value: function getFavoriteApplications() {
return this._request.get(this._baseUrl + '/applications/favorites').then(function (favoriteApps) {
return (0, _objects.toCamelCase)(favoriteApps);
});
}
/**
* Gets information about a contxt organization

@@ -99,0 +240,0 @@ *

2

package.json
{
"name": "@ndustrial/contxt-sdk",
"version": "0.0.46",
"version": "0.0.47",
"description": "",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -29,2 +29,11 @@ import EdgeNodes from './edgeNodes';

/**
* @typedef {Object} ContxtOrganizationFeaturedApplication
* @property {number} applicationId
* @property {string} createdAt ISO 8601 Extended Format date/time string
* @property {string} id
* @property {string} organizationId
* @property {string} updatedAt ISO 8601 Extended Format date/time string
*/
/**
* @typedef {Object} ContxtUser

@@ -207,2 +216,38 @@ * @property {string} createdAt ISO 8601 Extended Format date/time string

/**
* Gets an organization's list of featured applications
*
* API Endpoint: '/organizations/:organizationId/applications/featured'
* Method: GET
*
* Note: Only valid for web users using auth0WebAuth session type
*
* @param {string} organizationId The ID of the organization
*
* @returns {Promise}
* @fulfill {ContxtOrganizationFeaturedApplication[]} A list of featured applications
* @reject {Error}
*
* @example
* contxtSdk.coordinator
* .getFeaturedApplications('36b8421a-cc4a-4204-b839-1397374fb16b')
* .then((featuredApplications) => console.log(featuredApplications))
* .catch((err) => console.log(err));
*/
getFeaturedApplications(organizationId) {
if (!organizationId) {
return Promise.reject(
new Error(
'An organization ID is required for getting featured applications for an organization'
)
);
}
return this._request
.get(
`${this._baseUrl}/organizations/${organizationId}/applications/featured`
)
.then((featuredApplications) => toCamelCase(featuredApplications));
}
/**
* Gets information about a contxt organization

@@ -209,0 +254,0 @@ *

@@ -321,2 +321,74 @@ import Coordinator from './index';

describe('getFeaturedApplications', function() {
context('when the organization ID is provided', function() {
let expectedFeaturedApplications;
let featuredApplicationsFromServer;
let expectedOrganizationId;
let promise;
let request;
let toCamelCase;
beforeEach(function() {
expectedOrganizationId = faker.random.uuid();
expectedFeaturedApplications = fixture.buildList(
'contxtOrganizationFeaturedApplication',
faker.random.number({
min: 1,
max: 10
}),
{
organizationId: expectedOrganizationId
}
);
featuredApplicationsFromServer = expectedFeaturedApplications.map(
(app) =>
fixture.build('contxtOrganizationFeaturedApplication', app, {
fromServer: true
})
);
request = {
...baseRequest,
get: this.sandbox.stub().resolves(featuredApplicationsFromServer)
};
toCamelCase = this.sandbox
.stub(objectUtils, 'toCamelCase')
.returns(expectedFeaturedApplications);
const coordinator = new Coordinator(baseSdk, request);
coordinator._baseUrl = expectedHost;
promise = coordinator.getFeaturedApplications(expectedOrganizationId);
});
it('gets the list of featured applications from the server', function() {
expect(request.get).to.be.calledWith(
`${expectedHost}/organizations/${expectedOrganizationId}/applications/featured`
);
});
it('formats the list of featured applications', function() {
return promise.then(() => {
expect(toCamelCase).to.be.calledWith(featuredApplicationsFromServer);
});
});
it('returns a fulfilled promise with the featured applications', function() {
return expect(promise).to.be.fulfilled.and.to.eventually.deep.equal(
expectedFeaturedApplications
);
});
});
context('when the organization ID is not provided', function() {
it('throws an error', function() {
const coordinator = new Coordinator(baseSdk, baseRequest);
const promise = coordinator.getFeaturedApplications();
return expect(promise).to.be.rejectedWith(
'An organization ID is required for getting featured applications for an organization'
);
});
});
});
describe('getOrganizationById', function() {

@@ -323,0 +395,0 @@ context('the organization ID is provided', function() {

@@ -15,2 +15,3 @@ 'use strict';

require('./contxtOrganization');
require('./contxtOrganizationFeaturedApplication');
require('./contxtUser');

@@ -17,0 +18,0 @@ require('./contxtUserFavoriteApplication');

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc