Skip to content

Commit

Permalink
feat(hub-discussions): adds Discussions package to Hub.js (#479)
Browse files Browse the repository at this point in the history
adds "discussions" package for interfacing with hub-discussions api (in beta)
  • Loading branch information
Chase Gruber committed Jul 7, 2021
1 parent a64b488 commit 6117cb3
Show file tree
Hide file tree
Showing 25 changed files with 11,594 additions and 8,761 deletions.
17,766 changes: 9,005 additions & 8,761 deletions package-lock.json

Large diffs are not rendered by default.

72 changes: 72 additions & 0 deletions packages/discussions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[![npm version][npm-img]][npm-url]
[![build status][travis-img]][travis-url]
[![gzip bundle size][gzip-image]][npm-url]
[![Coverage Status][coverage-img]][coverage-url]
[![apache licensed](https://img.shields.io/badge/license-Apache-green.svg?style=flat-square)](https://raw.githubusercontent.com/Esri/hub.js/master/LICENSE)

[npm-img]: https://img.shields.io/npm/v/@esri/hub-discussions.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/@esri/hub-discussions
[travis-img]: https://img.shields.io/travis/Esri/hub.js/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/Esri/hub.js
[gzip-image]: https://img.badgesize.io/https://unpkg.com/@esri/hub-discussions/dist/umd/discussions.umd.min.js?compression=gzip
[coverage-img]: https://codecov.io/gh/Esri/hub.js/branch/master/graph/badge.svg
[coverage-url]: https://codecov.io/gh/Esri/hub.js

# THIS PACKAGE IS ACTIVELY UNDER DEVELOPMENT AND IS NOT TO BE USED IN A PRODUCTION ENVIRONMENT
# @esri/hub-discussions

> Module to interact with ArcGIS Hub Discussions API in Node.js and modern browsers.
### Example

```bash
npm install @esri/hub-discussions @esri/arcgis-rest-auth @esri/arcgis-rest-request @esri/hub-common
```
```js
import { searchPosts } from "@esri/hub-discussions";

// get posts for org
searchPosts({ access: ['org'], orgs: ['3ef']}).then(response => {
return response.items;
// [
// IPost{},
// ...
// ]
});
```

## [API Reference](https://esri.github.io/hub.js/api/discussions/)

### Issues

If something isn't working the way you expected, please take a look at [previously logged issues](https://github.com/Esri/hub.js/issues) first. Have you found a new bug? Want to request a new feature? We'd [**love**](https://github.com/Esri/hub.js/issues/new) to hear from you.

If you're looking for help you can also post issues on [GIS Stackexchange](http://gis.stackexchange.com/questions/ask?tags=esri-oss).

### Versioning

For transparency into the release cycle and in striving to maintain backward compatibility, @esri/hub.js is maintained under Semantic Versioning guidelines and will adhere to these rules whenever possible.

For more information on SemVer, please visit <http://semver.org/>.

### Contributing

Esri welcomes contributions from anyone and everyone. Please see our [guidelines for contributing](CONTRIBUTING.md).

### License

Copyright &copy; 2021 Esri

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

> http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

A copy of the license is available in the repository's [LICENSE](../../LICENSE) file.
39 changes: 39 additions & 0 deletions packages/discussions/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 74 additions & 0 deletions packages/discussions/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"name": "@esri/hub-discussions",
"version": "8.8.2",
"description": "Module to interact with ArcGIS Hub Discussions API in Node.js and modern browsers.",
"main": "dist/node/index.js",
"unpkg": "dist/umd/discussions.umd.js",
"module": "dist/esm/index.js",
"es2017": "dist/es2017/index.js",
"sideEffects": false,
"types": "dist/types/index.d.ts",
"license": "Apache-2.0",
"dependencies": {
"tslib": "^1.13.0",
"url-parse": "^1.5.1"
},
"peerDependencies": {
"@esri/arcgis-rest-auth": "^2.13.0 || 3",
"@esri/arcgis-rest-request": "^2.13.0 || 3",
"@esri/hub-common": "^7.0.1"
},
"devDependencies": {
"@esri/arcgis-rest-auth": "^2.21.0",
"@esri/arcgis-rest-request": "^2.21.0",
"@esri/arcgis-rest-types": "^2.15.0",
"@esri/hub-common": "^7.3.0",
"@rollup/plugin-commonjs": "^15.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"@types/geojson": "^7946.0.7",
"@types/url-parse": "^1.4.3",
"rollup": "^2.26.5",
"rollup-plugin-filesize": "^9.0.2",
"rollup-plugin-typescript2": "^0.27.2",
"rollup-plugin-uglify": "^6.0.4",
"typescript": "^3.8.1"
},
"files": [
"dist/**"
],
"scripts": {
"prepare": "npm run build",
"build": "npm run build:node && npm run build:esm",
"local_build": "npm run build:node && npm run build:esm && npm run build:umd",
"build:esm": "tsc --outDir ./dist/es2017 --declaration --declarationDir ./dist/types",
"build:esm:es5": "tsc --module es2015 --target es5 --outDir ./dist/esm",
"build:umd": "rollup -c ../../umd-base-profile.js && rollup -c ../../umd-production-profile.js",
"build:node": "tsc --module commonjs --outDir ./dist/node",
"dev:esm": "npm run build:esm -- -w",
"dev:node": "npm run build:node -- -w",
"format": "prettier --write ./{src,test}/**/*.ts",
"format:check": "prettier --check ./{src,test}/**/*.ts"
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Esri/hub.js.git"
},
"contributors": [
{
"name": "Chase Gruber",
"email": "[email protected]"
}
],
"bugs": {
"url": "https://github.com/Esri/hub.js/issues"
},
"homepage": "https://github.com/Esri/hub.js#readme",
"gitHead": "37f3a4e0e1c26399f6597697601d115d727540d9",
"volta": {
"extends": "../../package.json"
}
}
81 changes: 81 additions & 0 deletions packages/discussions/src/channels.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { request } from "./request";
import {
ISearchChannelsOptions,
ICreateChannelOptions,
IFetchChannelOptions,
IUpdateChannelOptions,
IRemoveChannelOptions,
IChannel,
IPagedResponse,
IRemoveChannelResponse
} from "./types";

/**
* search channels
*
* @export
* @param {ISearchChannelsOptions} options
* @return {*} {Promise<IPagedResponse<IChannel>>}
*/
export function searchChannels(
options: ISearchChannelsOptions
): Promise<IPagedResponse<IChannel>> {
options.httpMethod = "GET";
return request(`/channels`, options);
}

/**
* create channel
*
* @export
* @param {ICreateChannelOptions} options
* @return {*} {Promise<IChannel>}
*/
export function createChannel(
options: ICreateChannelOptions
): Promise<IChannel> {
options.httpMethod = "POST";
return request(`/channels`, options);
}

/**
* fetch channel
*
* @export
* @param {IFetchChannelOptions} options
* @return {*} {Promise<IChannel>}
*/
export function fetchChannel(options: IFetchChannelOptions): Promise<IChannel> {
options.httpMethod = "GET";
return request(`/channels/${options.channelId}`, options);
}

/**
* update channel
* NOTE: only updates channel settings properties (softDelete, allowedReactions, etc). A Channel's
* access and groups cannot be updated.
*
* @export
* @param {IUpdateChannelOptions} options
* @return {*} {Promise<IChannel>}
*/
export function updateChannel(
options: IUpdateChannelOptions
): Promise<IChannel> {
options.httpMethod = "PATCH";
return request(`/channels/${options.channelId}`, options);
}

/**
* remove channel
*
* @export
* @param {IRemoveChannelOptions} options
* @return {*}
*/
export function removeChannel(
options: IRemoveChannelOptions
): Promise<IRemoveChannelResponse> {
options.httpMethod = "DELETE";
return request(`/channels/${options.channelId}`, options);
}
12 changes: 12 additions & 0 deletions packages/discussions/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
* Apache-2.0 */

export * from "./posts";
export * from "./channels";
export * from "./reactions";
export * from "./types";

export * from "./utils/posts";
export * from "./utils/channels";
export * from "./utils/reactions";
export * from "./utils/platform";
Loading

0 comments on commit 6117cb3

Please sign in to comment.