Socket
Socket
Sign inDemoInstall

@esri/hub-discussions

Package Overview
Dependencies
Maintainers
41
Versions
284
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@esri/hub-discussions - npm Package Compare versions

Comparing version 1.0.0-beta.8 to 1.0.0-beta.9

27

dist/es2017/utils/request.js

@@ -0,1 +1,8 @@

import { RemoteServerError as _RemoteServerError } from '@esri/hub-common';
export class RemoteServerError extends _RemoteServerError {
constructor(message, url, status, error) {
super(message, url, status);
this.error = error;
}
}
/**

@@ -23,3 +30,3 @@ * returns Promise that resolves token to use in Discussions API requests

* @template T
* @param {string} url
* @param {string} route
* @param {IHubRequestOptions} options

@@ -29,3 +36,3 @@ * @param {string} [token]

*/
export function apiRequest(url, options, token) {
export function apiRequest(route, options, token) {
const headers = new Headers();

@@ -49,3 +56,3 @@ headers.append("Content-Type", "application/json");

const queryParams = new URLSearchParams(options.params).toString();
url += `?${queryParams}`;
route += `?${queryParams}`;
}

@@ -56,4 +63,16 @@ else {

}
return fetch([apiBase.replace(/\/$/, ""), url.replace(/^\//, "")].join("/"), opts).then(res => res.json());
const url = [apiBase.replace(/\/$/, ""), route.replace(/^\//, "")].join("/");
return fetch(url, opts).then(res => {
debugger;
if (res.ok) {
return res.json();
}
else {
return res.json().then(err => {
const { message, statusCode, error } = err;
throw new RemoteServerError(message, url, statusCode, error);
});
}
});
}
//# sourceMappingURL=request.js.map

@@ -0,1 +1,13 @@

import { __extends } from "tslib";
import { RemoteServerError as _RemoteServerError } from "@esri/hub-common";
var RemoteServerError = /** @class */ (function (_super) {
__extends(RemoteServerError, _super);
function RemoteServerError(message, url, status, error) {
var _this = _super.call(this, message, url, status) || this;
_this.error = error;
return _this;
}
return RemoteServerError;
}(_RemoteServerError));
export { RemoteServerError };
/**

@@ -23,3 +35,3 @@ * returns Promise that resolves token to use in Discussions API requests

* @template T
* @param {string} url
* @param {string} route
* @param {IHubRequestOptions} options

@@ -29,3 +41,3 @@ * @param {string} [token]

*/
export function apiRequest(url, options, token) {
export function apiRequest(route, options, token) {
var headers = new Headers();

@@ -49,3 +61,3 @@ headers.append("Content-Type", "application/json");

var queryParams = new URLSearchParams(options.params).toString();
url += "?" + queryParams;
route += "?" + queryParams;
}

@@ -56,4 +68,15 @@ else {

}
return fetch([apiBase.replace(/\/$/, ""), url.replace(/^\//, "")].join("/"), opts).then(function (res) { return res.json(); });
var url = [apiBase.replace(/\/$/, ""), route.replace(/^\//, "")].join("/");
return fetch(url, opts).then(function (res) {
if (res.ok) {
return res.json();
}
else {
var statusText_1 = res.statusText, status_1 = res.status;
return res.json().then(function (err) {
throw new RemoteServerError(statusText_1, url, status_1, JSON.stringify(err.message));
});
}
});
}
//# sourceMappingURL=request.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const hub_common_1 = require("@esri/hub-common");
class RemoteServerError extends hub_common_1.RemoteServerError {
constructor(message, url, status, error) {
super(message, url, status);
this.error = error;
}
}
exports.RemoteServerError = RemoteServerError;
/**

@@ -26,3 +34,3 @@ * returns Promise that resolves token to use in Discussions API requests

* @template T
* @param {string} url
* @param {string} route
* @param {IHubRequestOptions} options

@@ -32,3 +40,3 @@ * @param {string} [token]

*/
function apiRequest(url, options, token) {
function apiRequest(route, options, token) {
const headers = new Headers();

@@ -52,3 +60,3 @@ headers.append("Content-Type", "application/json");

const queryParams = new URLSearchParams(options.params).toString();
url += `?${queryParams}`;
route += `?${queryParams}`;
}

@@ -59,5 +67,16 @@ else {

}
return fetch([apiBase.replace(/\/$/, ""), url.replace(/^\//, "")].join("/"), opts).then(res => res.json());
const url = [apiBase.replace(/\/$/, ""), route.replace(/^\//, "")].join("/");
return fetch(url, opts).then(res => {
if (res.ok) {
return res.json();
}
else {
const { statusText, status } = res;
return res.json().then(err => {
throw new RemoteServerError(statusText, url, status, JSON.stringify(err.message));
});
}
});
}
exports.apiRequest = apiRequest;
//# sourceMappingURL=request.js.map

9

dist/types/utils/request.d.ts
import { IHubRequestOptions } from "../types";
import { RemoteServerError as _RemoteServerError } from "@esri/hub-common";
export declare class RemoteServerError extends _RemoteServerError {
error: string;
constructor(message: string, url: string, status: number, error: string);
}
/**

@@ -15,3 +20,3 @@ * returns Promise that resolves token to use in Discussions API requests

* @template T
* @param {string} url
* @param {string} route
* @param {IHubRequestOptions} options

@@ -21,2 +26,2 @@ * @param {string} [token]

*/
export declare function apiRequest<T>(url: string, options: IHubRequestOptions, token?: string): Promise<T>;
export declare function apiRequest<T>(route: string, options: IHubRequestOptions, token?: string): Promise<T>;
/* @preserve
* @esri/hub-discussions - v1.0.0-beta.8 - Fri Apr 09 2021 17:52:39 GMT-0400 (Eastern Daylight Time)
* @esri/hub-discussions - v1.0.0-beta.8 - Mon Apr 19 2021 14:14:49 GMT-0400 (Eastern Daylight Time)
* Copyright (c) 2021 Environmental Systems Research Institute, Inc.

@@ -8,7 +8,45 @@ * Apache-2.0

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.arcgisHub = global.arcgisHub || {}));
}(this, (function (exports) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@esri/hub-common')) :
typeof define === 'function' && define.amd ? define(['exports', '@esri/hub-common'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.arcgisHub = global.arcgisHub || {}, global.arcgisHub));
}(this, (function (exports, hubCommon) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var RemoteServerError = /** @class */ (function (_super) {
__extends(RemoteServerError, _super);
function RemoteServerError(message, url, status, error) {
var _this = _super.call(this, message, url, status) || this;
_this.error = error;
return _this;
}
return RemoteServerError;
}(hubCommon.RemoteServerError));
/**

@@ -36,3 +74,3 @@ * returns Promise that resolves token to use in Discussions API requests

* @template T
* @param {string} url
* @param {string} route
* @param {IHubRequestOptions} options

@@ -42,3 +80,3 @@ * @param {string} [token]

*/
function apiRequest(url, options, token) {
function apiRequest(route, options, token) {
var headers = new Headers();

@@ -62,3 +100,3 @@ headers.append("Content-Type", "application/json");

var queryParams = new URLSearchParams(options.params).toString();
url += "?" + queryParams;
route += "?" + queryParams;
}

@@ -69,3 +107,15 @@ else {

}
return fetch([apiBase.replace(/\/$/, ""), url.replace(/^\//, "")].join("/"), opts).then(function (res) { return res.json(); });
var url = [apiBase.replace(/\/$/, ""), route.replace(/^\//, "")].join("/");
return fetch(url, opts).then(function (res) {
debugger;
if (res.ok) {
return res.json();
}
else {
return res.json().then(function (err) {
var message = err.message, statusCode = err.statusCode, error = err.error;
throw new RemoteServerError(message, url, statusCode, error);
});
}
});
}

@@ -72,0 +122,0 @@

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).arcgisHub=e.arcgisHub||{})}(this,function(e){"use strict";function r(t,n){return function(e){var t=e.token,n=e.authentication,r=function(){return Promise.resolve(t)};return n&&(r=n.getToken.bind(n,n.portal)),r()}(n).then(function(e){return function(e,t,n){var r=new Headers;r.append("Content-Type","application/json"),n&&r.append("Authorization","Bearer "+n);var o={headers:r,method:t.httpMethod||"GET",mode:t.mode,cache:t.cache,credentials:t.credentials},s=t.hubApiUrl||"https://ingress.eks.qa.hub.geocloud.com/api/v1";return t.params&&("GET"===t.httpMethod?e+="?"+new URLSearchParams(t.params).toString():o.body=JSON.stringify(t.params)),fetch([s.replace(/\/$/,""),e.replace(/^\//,"")].join("/"),o).then(function(e){return e.json()})}(t,n,e)})}var t,n,o,s,a,c,i;(t=e.SortOrder||(e.SortOrder={})).ASC="ASC",t.DESC="DESC",(n=e.PostReaction||(e.PostReaction={})).THUMBS_UP="thumbs_up",n.THUMBS_DOWN="thumbs_down",n.THINKING="thinking",n.HEART="heart",n.ONE_HUNDRED="one_hundred",n.SAD="sad",n.LAUGH="laugh",n.SURPRISED="surprised",(o=e.SharingAccess||(e.SharingAccess={})).PUBLIC="public",o.ORG="org",o.PRIVATE="private",(s=e.PostStatus||(e.PostStatus={})).PENDING="pending",s.APPROVED="approved",s.REJECTED="rejected",s.DELETED="deleted",s.HIDDEN="hidden",(a=e.DiscussionType||(e.DiscussionType={})).DATASET="dataset",a.ITEM="item",a.GROUP="group",(c=e.DiscussionSource||(e.DiscussionSource={})).HUB="hub",c.AGO="ago",c.URBAN="urban",(i=e.PostRelation||(e.PostRelation={})).REPLIES="replies",i.REACTIONS="reactions",i.PARENT="parent",i.CHANNEL="channel",(e.ChannelRelation||(e.ChannelRelation={})).SETTINGS="settings",(e.ReactionRelation||(e.ReactionRelation={})).POST="post";var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},d=function(e,t){if(t=t.split(":")[0],!(e=+e))return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e},h=Object.prototype.hasOwnProperty;function p(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function l(e){try{return encodeURIComponent(e)}catch(e){return null}}var f={stringify:function(e,t){t=t||"";var n,r,o=[];for(r in"string"!=typeof t&&(t="?"),e)if(h.call(e,r)){if((n=e[r])||null!=n&&!isNaN(n)||(n=""),r=l(r),n=l(n),null===r||null===n)continue;o.push(r+"="+n)}return o.length?t+o.join("&"):""},parse:function(e){for(var t,n=/([^=?#&]+)=?([^&]*)/g,r={};t=n.exec(e);){var o=p(t[1]),s=p(t[2]);null===o||null===s||o in r||(r[o]=s)}return r}},m=/^[A-Za-z][A-Za-z0-9+-.]*:[\\/]+/,g=/^([a-z][a-z0-9.+-]*:)?([\\/]{1,})?([\S\s]*)/i,v=new RegExp("^[\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\xA0\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF]+");function y(e){return(e||"").toString().replace(v,"")}var b=[["#","hash"],["?","query"],function(e){return e.replace("\\","/")},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d+)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],w={hash:1,query:1};function I(e){var t,n=("undefined"!=typeof window?window:void 0!==u?u:"undefined"!=typeof self?self:{}).location||{},r={},o=typeof(e=e||n);if("blob:"===e.protocol)r=new E(unescape(e.pathname),{});else if("string"==o)for(t in r=new E(e,{}),w)delete r[t];else if("object"==o){for(t in e)t in w||(r[t]=e[t]);void 0===r.slashes&&(r.slashes=m.test(e.href))}return r}function P(e){e=y(e);var t=g.exec(e);return{protocol:t[1]?t[1].toLowerCase():"",slashes:!!(t[2]&&2<=t[2].length),rest:t[2]&&1===t[2].length?"/"+t[3]:t[3]}}function E(e,t,n){if(e=y(e),!(this instanceof E))return new E(e,t,n);var r,o,s,a,c,i,u=b.slice(),h=typeof t,p=this,l=0;for("object"!=h&&"string"!=h&&(n=t,t=null),n&&"function"!=typeof n&&(n=f.parse),t=I(t),r=!(o=P(e||"")).protocol&&!o.slashes,p.slashes=o.slashes||r&&t.slashes,p.protocol=o.protocol||t.protocol||"",e=o.rest,o.slashes||(u[3]=[/(.*)/,"pathname"]);l<u.length;l++)"function"!=typeof(a=u[l])?(s=a[0],i=a[1],s!=s?p[i]=e:"string"==typeof s?~(c=e.indexOf(s))&&(e="number"==typeof a[2]?(p[i]=e.slice(0,c),e.slice(c+a[2])):(p[i]=e.slice(c),e.slice(0,c))):(c=s.exec(e))&&(p[i]=c[1],e=e.slice(0,c.index)),p[i]=p[i]||r&&a[3]&&t[i]||"",a[4]&&(p[i]=p[i].toLowerCase())):e=a(e);n&&(p.query=n(p.query)),r&&t.slashes&&"/"!==p.pathname.charAt(0)&&(""!==p.pathname||""!==t.pathname)&&(p.pathname=function(e,t){if(""===e)return t;for(var n=(t||"/").split("/").slice(0,-1).concat(e.split("/")),r=n.length,o=n[r-1],s=!1,a=0;r--;)"."===n[r]?n.splice(r,1):".."===n[r]?(n.splice(r,1),a++):a&&(0===r&&(s=!0),n.splice(r,1),a--);return s&&n.unshift(""),"."!==o&&".."!==o||n.push(""),n.join("/")}(p.pathname,t.pathname)),"/"!==p.pathname.charAt(0)&&p.hostname&&(p.pathname="/"+p.pathname),d(p.port,p.protocol)||(p.host=p.hostname,p.port=""),p.username=p.password="",p.auth&&(a=p.auth.split(":"),p.username=a[0]||"",p.password=a[1]||""),p.origin=p.protocol&&p.host&&"file:"!==p.protocol?p.protocol+"//"+p.host:"null",p.href=p.toString()}E.prototype={set:function(e,t,n){var r=this;switch(e){case"query":"string"==typeof t&&t.length&&(t=(n||f.parse)(t)),r[e]=t;break;case"port":r[e]=t,d(t,r.protocol)?t&&(r.host=r.hostname+":"+t):(r.host=r.hostname,r[e]="");break;case"hostname":r[e]=t,r.port&&(t+=":"+r.port),r.host=t;break;case"host":r[e]=t,/:\d+$/.test(t)?(t=t.split(":"),r.port=t.pop(),r.hostname=t.join(":")):(r.hostname=t,r.port="");break;case"protocol":r.protocol=t.toLowerCase(),r.slashes=!n;break;case"pathname":case"hash":if(t){var o="pathname"===e?"/":"#";r[e]=t.charAt(0)!==o?o+t:t}else r[e]=t;break;default:r[e]=t}for(var s=0;s<b.length;s++){var a=b[s];a[4]&&(r[a[1]]=r[a[1]].toLowerCase())}return r.origin=r.protocol&&r.host&&"file:"!==r.protocol?r.protocol+"//"+r.host:"null",r.href=r.toString(),r},toString:function(e){e&&"function"==typeof e||(e=f.stringify);var t,n=this,r=n.protocol;r&&":"!==r.charAt(r.length-1)&&(r+=":");var o=r+(n.slashes?"//":"");return n.username&&(o+=n.username,n.password&&(o+=":"+n.password),o+="@"),o+=n.host+n.pathname,(t="object"==typeof n.query?e(n.query):n.query)&&(o+="?"!==t.charAt(0)?"?"+t:t),n.hash&&(o+=n.hash),o}},E.extractProtocol=P,E.location=I,E.trimLeft=y,E.qs=f;var T=E,O=Object.freeze(Object.assign(Object.create(null),T,{default:T}));function S(n){return function(e,t){return-1<n.indexOf(t.userMembership.memberType)&&e.push(t.id),e}}function R(e){return"org_admin"===e.role&&!e.roleId}function A(o,s){return function(e,t){var n=t.groups,r=e.groups.reduce(S(o),[]);return n[s?"every":"some"](function(e){return-1<r.indexOf(e)})}}function C(e,t){return 1===e.orgs.length&&-1<e.orgs.indexOf(t.orgId)}function D(e,t){return R(t)&&-1<e.orgs.indexOf(t.orgId)}e.canCreateChannel=function(e,t){return"private"===e.access?A(["owner","admin","member"],!0)(t,e):D(e,t)},e.canCreateReaction=function(e,t){var n=e.allowReaction,r=e.allowedReactions;return!!n&&(!r||-1<r.indexOf(t))},e.canModifyChannel=function(e,t){return"private"===e.access?A(["owner","admin"])(t,e):D(e,t)},e.canPostToChannel=function(e,t){return"private"===e.access?A(["owner","admin","member"])(t,e):"org"===e.access?C(e,t):"anonymous"!==t.username||e.allowAnonymous},e.canReadFromChannel=function(e,t){return"private"===e.access?A(["member","owner","admin"])(t,e):"org"!==e.access||C(e,t)},e.createChannel=function(e){return e.httpMethod="POST",r("/channels",e)},e.createPost=function(e){var t="/posts";return e.hasOwnProperty("channelId")&&(t="/channels/"+e.channelId+t),e.httpMethod="POST",r(t,e)},e.createReaction=function(e){var t=e.postId;return e.httpMethod="POST",r("/posts/"+t+"/reactions",e)},e.createReply=function(e){var t="/posts/"+e.postId+"/reply";return e.hasOwnProperty("channelId")&&(t="/channels/"+e.channelId+t),e.httpMethod="POST",r(t,e)},e.fetchChannel=function(e){return e.httpMethod="GET",r("/channels/"+e.channelId,e)},e.fetchPost=function(e){var t="/posts/"+e.postId;return e.hasOwnProperty("channelId")&&(t="/channels/"+e.channelId+t),e.httpMethod="GET",r(t,e)},e.isChannelInclusive=function(t,e){var n,r;if("private"===t.access&&1===t.groups.length?(n="private"===e.access&&e.groups[0]===t.groups[0])||(r="replies to private post must be shared to same team"):"private"===t.access?(n="private"===e.access&&e.groups.every(function(e){return-1<t.groups.indexOf(e)}))||(r="replies to shared post must be shared to subset of same teams"):"org"===t.access&&"org"===e.access?(n=e.orgs.every(function(e){return-1<t.orgs.indexOf(e)}))||(r="replies to org post must be shared to subset of same orgs"):"org"===t.access&&((n="public"!==e.access)||(r="replies to org post cannot be shared to public")),r)throw new Error(r);return n},e.isGroupDiscussable=function(e){return!0},e.isItemDiscussable=function(e){return!0},e.isOrgAdmin=R,e.parseDiscussionURI=function(e){var t=new URL(e)&&new O(e),n=t.protocol.slice(0,-1),r=t.hostname,o=t.pathname.split("/")[1].split("_"),s=o[0],a=o[1],c=void 0===a?null:a,i=new URLSearchParams(t.query);return{source:n,type:r,id:s||null,layer:c,features:i.has("id")&&i.get("id").split(",")||null,attribute:i.has("attribute")&&i.get("attribute")||null}},e.reduceByGroupMembership=S,e.removeChannel=function(e){return e.httpMethod="DELETE",r("/channels/"+e.channelId,e)},e.removePost=function(e){var t="/posts/"+e.postId;return e.hasOwnProperty("channelId")&&(t="/channels/"+e.channelId+t),e.httpMethod="DELETE",r(t,e)},e.removeReaction=function(e){var t=e.postId,n=e.reactionId;return e.httpMethod="DELETE",r("/posts/"+t+"/reactions/"+n,e)},e.searchChannels=function(e){return e.httpMethod="GET",r("/channels",e)},e.searchPosts=function(e){var t="/posts";return e.hasOwnProperty("channelId")&&(t="/channels/"+e.channelId+t),e.httpMethod="GET",r(t,e)},e.updateChannel=function(e){return e.httpMethod="PATCH",r("/channels/"+e.channelId,e)},e.updatePost=function(e){var t="/posts/"+e.postId;return e.hasOwnProperty("channelId")&&(t="/channels/"+e.channelId+t),e.httpMethod="PATCH",r(t,e)},e.updatePostSharing=function(e){var t="/posts/"+e.postId+"/sharing";return e.hasOwnProperty("channelId")&&(t="/channels/"+e.channelId+t),e.httpMethod="PATCH",r(t,e)},e.updatePostStatus=function(e){var t="/posts/"+e.postId+"/status";return e.hasOwnProperty("channelId")&&(t="/channels/"+e.channelId+t),e.httpMethod="PATCH",r(t,e)},Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@esri/hub-common")):"function"==typeof define&&define.amd?define(["exports","@esri/hub-common"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).arcgisHub=e.arcgisHub||{},e.arcgisHub)}(this,function(e,t){"use strict";var n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};var r,o,s,a,c,i,u,h,p,l,d=(s=t.RemoteServerError,n(r=m,o=s),void(r.prototype=null===o?Object.create(o):(f.prototype=o.prototype,new f)),m);function f(){this.constructor=r}function m(e,t,n,r){var o=s.call(this,e,t,n)||this;return o.error=r,o}function g(t,n){return function(e){var t=e.token,n=e.authentication,r=function(){return Promise.resolve(t)};return n&&(r=n.getToken.bind(n,n.portal)),r()}(n).then(function(e){return function(e,t,n){var r=new Headers;r.append("Content-Type","application/json"),n&&r.append("Authorization","Bearer "+n);var o={headers:r,method:t.httpMethod||"GET",mode:t.mode,cache:t.cache,credentials:t.credentials},s=t.hubApiUrl||"https://ingress.eks.qa.hub.geocloud.com/api/v1";t.params&&("GET"===t.httpMethod?e+="?"+new URLSearchParams(t.params).toString():o.body=JSON.stringify(t.params));var a=[s.replace(/\/$/,""),e.replace(/^\//,"")].join("/");return fetch(a,o).then(function(e){return e.ok?e.json():e.json().then(function(e){var t=e.message,n=e.statusCode,r=e.error;throw new d(t,a,n,r)})})}(t,n,e)})}(a=e.SortOrder||(e.SortOrder={})).ASC="ASC",a.DESC="DESC",(c=e.PostReaction||(e.PostReaction={})).THUMBS_UP="thumbs_up",c.THUMBS_DOWN="thumbs_down",c.THINKING="thinking",c.HEART="heart",c.ONE_HUNDRED="one_hundred",c.SAD="sad",c.LAUGH="laugh",c.SURPRISED="surprised",(i=e.SharingAccess||(e.SharingAccess={})).PUBLIC="public",i.ORG="org",i.PRIVATE="private",(u=e.PostStatus||(e.PostStatus={})).PENDING="pending",u.APPROVED="approved",u.REJECTED="rejected",u.DELETED="deleted",u.HIDDEN="hidden",(h=e.DiscussionType||(e.DiscussionType={})).DATASET="dataset",h.ITEM="item",h.GROUP="group",(p=e.DiscussionSource||(e.DiscussionSource={})).HUB="hub",p.AGO="ago",p.URBAN="urban",(l=e.PostRelation||(e.PostRelation={})).REPLIES="replies",l.REACTIONS="reactions",l.PARENT="parent",l.CHANNEL="channel",(e.ChannelRelation||(e.ChannelRelation={})).SETTINGS="settings",(e.ReactionRelation||(e.ReactionRelation={})).POST="post";var v="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},y=function(e,t){if(t=t.split(":")[0],!(e=+e))return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e},b=Object.prototype.hasOwnProperty;function w(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function P(e){try{return encodeURIComponent(e)}catch(e){return null}}var I={stringify:function(e,t){t=t||"";var n,r,o=[];for(r in"string"!=typeof t&&(t="?"),e)if(b.call(e,r)){if((n=e[r])||null!=n&&!isNaN(n)||(n=""),r=P(r),n=P(n),null===r||null===n)continue;o.push(r+"="+n)}return o.length?t+o.join("&"):""},parse:function(e){for(var t,n=/([^=?#&]+)=?([^&]*)/g,r={};t=n.exec(e);){var o=w(t[1]),s=w(t[2]);null===o||null===s||o in r||(r[o]=s)}return r}},E=/^[A-Za-z][A-Za-z0-9+-.]*:[\\/]+/,O=/^([a-z][a-z0-9.+-]*:)?([\\/]{1,})?([\S\s]*)/i,T=new RegExp("^[\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\xA0\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF]+");function S(e){return(e||"").toString().replace(T,"")}var R=[["#","hash"],["?","query"],function(e){return e.replace("\\","/")},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d+)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],A={hash:1,query:1};function C(e){var t,n=("undefined"!=typeof window?window:void 0!==v?v:"undefined"!=typeof self?self:{}).location||{},r={},o=typeof(e=e||n);if("blob:"===e.protocol)r=new x(unescape(e.pathname),{});else if("string"==o)for(t in r=new x(e,{}),A)delete r[t];else if("object"==o){for(t in e)t in A||(r[t]=e[t]);void 0===r.slashes&&(r.slashes=E.test(e.href))}return r}function D(e){e=S(e);var t=O.exec(e);return{protocol:t[1]?t[1].toLowerCase():"",slashes:!!(t[2]&&2<=t[2].length),rest:t[2]&&1===t[2].length?"/"+t[3]:t[3]}}function x(e,t,n){if(e=S(e),!(this instanceof x))return new x(e,t,n);var r,o,s,a,c,i,u=R.slice(),h=typeof t,p=this,l=0;for("object"!=h&&"string"!=h&&(n=t,t=null),n&&"function"!=typeof n&&(n=I.parse),t=C(t),r=!(o=D(e||"")).protocol&&!o.slashes,p.slashes=o.slashes||r&&t.slashes,p.protocol=o.protocol||t.protocol||"",e=o.rest,o.slashes||(u[3]=[/(.*)/,"pathname"]);l<u.length;l++)"function"!=typeof(a=u[l])?(s=a[0],i=a[1],s!=s?p[i]=e:"string"==typeof s?~(c=e.indexOf(s))&&(e="number"==typeof a[2]?(p[i]=e.slice(0,c),e.slice(c+a[2])):(p[i]=e.slice(c),e.slice(0,c))):(c=s.exec(e))&&(p[i]=c[1],e=e.slice(0,c.index)),p[i]=p[i]||r&&a[3]&&t[i]||"",a[4]&&(p[i]=p[i].toLowerCase())):e=a(e);n&&(p.query=n(p.query)),r&&t.slashes&&"/"!==p.pathname.charAt(0)&&(""!==p.pathname||""!==t.pathname)&&(p.pathname=function(e,t){if(""===e)return t;for(var n=(t||"/").split("/").slice(0,-1).concat(e.split("/")),r=n.length,o=n[r-1],s=!1,a=0;r--;)"."===n[r]?n.splice(r,1):".."===n[r]?(n.splice(r,1),a++):a&&(0===r&&(s=!0),n.splice(r,1),a--);return s&&n.unshift(""),"."!==o&&".."!==o||n.push(""),n.join("/")}(p.pathname,t.pathname)),"/"!==p.pathname.charAt(0)&&p.hostname&&(p.pathname="/"+p.pathname),y(p.port,p.protocol)||(p.host=p.hostname,p.port=""),p.username=p.password="",p.auth&&(a=p.auth.split(":"),p.username=a[0]||"",p.password=a[1]||""),p.origin=p.protocol&&p.host&&"file:"!==p.protocol?p.protocol+"//"+p.host:"null",p.href=p.toString()}x.prototype={set:function(e,t,n){var r=this;switch(e){case"query":"string"==typeof t&&t.length&&(t=(n||I.parse)(t)),r[e]=t;break;case"port":r[e]=t,y(t,r.protocol)?t&&(r.host=r.hostname+":"+t):(r.host=r.hostname,r[e]="");break;case"hostname":r[e]=t,r.port&&(t+=":"+r.port),r.host=t;break;case"host":r[e]=t,/:\d+$/.test(t)?(t=t.split(":"),r.port=t.pop(),r.hostname=t.join(":")):(r.hostname=t,r.port="");break;case"protocol":r.protocol=t.toLowerCase(),r.slashes=!n;break;case"pathname":case"hash":if(t){var o="pathname"===e?"/":"#";r[e]=t.charAt(0)!==o?o+t:t}else r[e]=t;break;default:r[e]=t}for(var s=0;s<R.length;s++){var a=R[s];a[4]&&(r[a[1]]=r[a[1]].toLowerCase())}return r.origin=r.protocol&&r.host&&"file:"!==r.protocol?r.protocol+"//"+r.host:"null",r.href=r.toString(),r},toString:function(e){e&&"function"==typeof e||(e=I.stringify);var t,n=this,r=n.protocol;r&&":"!==r.charAt(r.length-1)&&(r+=":");var o=r+(n.slashes?"//":"");return n.username&&(o+=n.username,n.password&&(o+=":"+n.password),o+="@"),o+=n.host+n.pathname,(t="object"==typeof n.query?e(n.query):n.query)&&(o+="?"!==t.charAt(0)?"?"+t:t),n.hash&&(o+=n.hash),o}},x.extractProtocol=D,x.location=C,x.trimLeft=S,x.qs=I;var M=x,N=Object.freeze(Object.assign(Object.create(null),M,{default:M}));function j(n){return function(e,t){return-1<n.indexOf(t.userMembership.memberType)&&e.push(t.id),e}}function _(e){return"org_admin"===e.role&&!e.roleId}function H(o,s){return function(e,t){var n=t.groups,r=e.groups.reduce(j(o),[]);return n[s?"every":"some"](function(e){return-1<r.indexOf(e)})}}function U(e,t){return 1===e.orgs.length&&-1<e.orgs.indexOf(t.orgId)}function L(e,t){return _(t)&&-1<e.orgs.indexOf(t.orgId)}e.canCreateChannel=function(e,t){return"private"===e.access?H(["owner","admin","member"],!0)(t,e):L(e,t)},e.canCreateReaction=function(e,t){var n=e.allowReaction,r=e.allowedReactions;return!!n&&(!r||-1<r.indexOf(t))},e.canModifyChannel=function(e,t){return"private"===e.access?H(["owner","admin"])(t,e):L(e,t)},e.canPostToChannel=function(e,t){return"private"===e.access?H(["owner","admin","member"])(t,e):"org"===e.access?U(e,t):"anonymous"!==t.username||e.allowAnonymous},e.canReadFromChannel=function(e,t){return"private"===e.access?H(["member","owner","admin"])(t,e):"org"!==e.access||U(e,t)},e.createChannel=function(e){return e.httpMethod="POST",g("/channels",e)},e.createPost=function(e){var t="/posts";return e.hasOwnProperty("channelId")&&(t="/channels/"+e.channelId+t),e.httpMethod="POST",g(t,e)},e.createReaction=function(e){var t=e.postId;return e.httpMethod="POST",g("/posts/"+t+"/reactions",e)},e.createReply=function(e){var t="/posts/"+e.postId+"/reply";return e.hasOwnProperty("channelId")&&(t="/channels/"+e.channelId+t),e.httpMethod="POST",g(t,e)},e.fetchChannel=function(e){return e.httpMethod="GET",g("/channels/"+e.channelId,e)},e.fetchPost=function(e){var t="/posts/"+e.postId;return e.hasOwnProperty("channelId")&&(t="/channels/"+e.channelId+t),e.httpMethod="GET",g(t,e)},e.isChannelInclusive=function(t,e){var n,r;if("private"===t.access&&1===t.groups.length?(n="private"===e.access&&e.groups[0]===t.groups[0])||(r="replies to private post must be shared to same team"):"private"===t.access?(n="private"===e.access&&e.groups.every(function(e){return-1<t.groups.indexOf(e)}))||(r="replies to shared post must be shared to subset of same teams"):"org"===t.access&&"org"===e.access?(n=e.orgs.every(function(e){return-1<t.orgs.indexOf(e)}))||(r="replies to org post must be shared to subset of same orgs"):"org"===t.access&&((n="public"!==e.access)||(r="replies to org post cannot be shared to public")),r)throw new Error(r);return n},e.isGroupDiscussable=function(e){return!0},e.isItemDiscussable=function(e){return!0},e.isOrgAdmin=_,e.parseDiscussionURI=function(e){var t=new URL(e)&&new N(e),n=t.protocol.slice(0,-1),r=t.hostname,o=t.pathname.split("/")[1].split("_"),s=o[0],a=o[1],c=void 0===a?null:a,i=new URLSearchParams(t.query);return{source:n,type:r,id:s||null,layer:c,features:i.has("id")&&i.get("id").split(",")||null,attribute:i.has("attribute")&&i.get("attribute")||null}},e.reduceByGroupMembership=j,e.removeChannel=function(e){return e.httpMethod="DELETE",g("/channels/"+e.channelId,e)},e.removePost=function(e){var t="/posts/"+e.postId;return e.hasOwnProperty("channelId")&&(t="/channels/"+e.channelId+t),e.httpMethod="DELETE",g(t,e)},e.removeReaction=function(e){var t=e.postId,n=e.reactionId;return e.httpMethod="DELETE",g("/posts/"+t+"/reactions/"+n,e)},e.searchChannels=function(e){return e.httpMethod="GET",g("/channels",e)},e.searchPosts=function(e){var t="/posts";return e.hasOwnProperty("channelId")&&(t="/channels/"+e.channelId+t),e.httpMethod="GET",g(t,e)},e.updateChannel=function(e){return e.httpMethod="PATCH",g("/channels/"+e.channelId,e)},e.updatePost=function(e){var t="/posts/"+e.postId;return e.hasOwnProperty("channelId")&&(t="/channels/"+e.channelId+t),e.httpMethod="PATCH",g(t,e)},e.updatePostSharing=function(e){var t="/posts/"+e.postId+"/sharing";return e.hasOwnProperty("channelId")&&(t="/channels/"+e.channelId+t),e.httpMethod="PATCH",g(t,e)},e.updatePostStatus=function(e){var t="/posts/"+e.postId+"/status";return e.hasOwnProperty("channelId")&&(t="/channels/"+e.channelId+t),e.httpMethod="PATCH",g(t,e)},Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=discussions.umd.min.js.map
{
"name": "@esri/hub-discussions",
"version": "1.0.0-beta.8",
"version": "1.0.0-beta.9",
"description": "Module to interact with ArcGIS Hub Discussions API in Node.js and modern browsers.",

@@ -42,4 +42,4 @@ "main": "dist/node/index.js",

"prepare": "npm run build",
"commit_this_build": "npm run build:node && npm run build:esm",
"build": "npm run build:node && npm run build:esm && npm run build:es2017 && npm run build:umd",
"build": "npm run build:node && npm run build:esm",
"local_build": "npm run build:node && npm run build:esm && npm run build:es2017 && npm run build:umd",
"build:esm": "tsc --module es2015 --target es5 --outDir ./dist/esm --declaration --declarationDir ./dist/types",

@@ -46,0 +46,0 @@ "build:es2017": "tsc --outDir ./dist/es2017",

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 not supported yet

Sorry, the diff of this file is not supported yet

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