Socket
Socket
Sign inDemoInstall

@esri/hub-discussions

Package Overview
Dependencies
Maintainers
42
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 8.11.1 to 8.12.0

9

dist/es2017/utils/posts.js
import * as UrlParse from "url-parse";
import { parseDatasetId } from "@esri/hub-common";
/**

@@ -15,3 +16,7 @@ * Utility that parses a discussion URI string into its component parts

const [, identifier] = uri.pathname.split("/");
const [id, layer = null] = identifier.split("_");
let id, layer;
if (identifier) {
const { itemId, layerId } = parseDatasetId(identifier);
[id, layer] = [itemId, layerId];
}
const searchParams = new URLSearchParams(uri.query);

@@ -24,3 +29,3 @@ const features = (searchParams.has("id") && searchParams.get("id").split(",")) || null;

id: id || null,
layer,
layer: layer || null,
features,

@@ -27,0 +32,0 @@ attribute

import * as UrlParse from "url-parse";
import { parseDatasetId } from "@esri/hub-common";
/**

@@ -10,2 +11,3 @@ * Utility that parses a discussion URI string into its component parts

export function parseDiscussionURI(discussion) {
var _a;
// pass it through browser/node URL to invalidate plain strings

@@ -15,4 +17,8 @@ var uri = new URL(discussion) && new UrlParse(discussion);

var type = uri.hostname;
var _a = uri.pathname.split("/"), identifier = _a[1];
var _b = identifier.split("_"), id = _b[0], _c = _b[1], layer = _c === void 0 ? null : _c;
var _b = uri.pathname.split("/"), identifier = _b[1];
var id, layer;
if (identifier) {
var _c = parseDatasetId(identifier), itemId = _c.itemId, layerId = _c.layerId;
_a = [itemId, layerId], id = _a[0], layer = _a[1];
}
var searchParams = new URLSearchParams(uri.query);

@@ -25,3 +31,3 @@ var features = (searchParams.has("id") && searchParams.get("id").split(",")) || null;

id: id || null,
layer: layer,
layer: layer || null,
features: features,

@@ -28,0 +34,0 @@ attribute: attribute

@@ -5,2 +5,3 @@ "use strict";

const UrlParse = require("url-parse");
const hub_common_1 = require("@esri/hub-common");
/**

@@ -19,3 +20,7 @@ * Utility that parses a discussion URI string into its component parts

const [, identifier] = uri.pathname.split("/");
const [id, layer = null] = identifier.split("_");
let id, layer;
if (identifier) {
const { itemId, layerId } = hub_common_1.parseDatasetId(identifier);
[id, layer] = [itemId, layerId];
}
const searchParams = new URLSearchParams(uri.query);

@@ -28,3 +33,3 @@ const features = (searchParams.has("id") && searchParams.get("id").split(",")) || null;

id: id || null,
layer,
layer: layer || null,
features,

@@ -31,0 +36,0 @@ attribute

/* @preserve
* @esri/hub-discussions - v8.11.0 - Thu Jul 22 2021 16:53:43 GMT-0600 (Mountain Daylight Time)
* @esri/hub-discussions - v8.11.1 - Mon Jul 26 2021 12:46:55 GMT-0600 (Mountain Daylight Time)
* Copyright (c) 2021 Environmental Systems Research Institute, Inc.

@@ -592,4 +592,5 @@ * Apache-2.0

var slashes = /^[A-Za-z][A-Za-z0-9+-.]*:[\\/]+/
, protocolre = /^([a-z][a-z0-9.+-]*:)?([\\/]{1,})?([\S\s]*)/i
var slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//
, protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i
, windowsDriveLetter = /^[a-zA-Z]:/
, whitespace = '[\\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]'

@@ -623,4 +624,4 @@ , left = new RegExp('^'+ whitespace +'+');

['?', 'query'], // Extract from the back.
function sanitize(address) { // Sanitize what is left of the address
return address.replace('\\', '/');
function sanitize(address, url) { // Sanitize what is left of the address
return isSpecial(url.protocol) ? address.replace(/\\/g, '/') : address;
},

@@ -691,2 +692,20 @@ ['/', 'pathname'], // Extract from the back.

/**
* Check whether a protocol scheme is special.
*
* @param {String} The protocol scheme of the URL
* @return {Boolean} `true` if the protocol scheme is special, else `false`
* @private
*/
function isSpecial(scheme) {
return (
scheme === 'file:' ||
scheme === 'ftp:' ||
scheme === 'http:' ||
scheme === 'https:' ||
scheme === 'ws:' ||
scheme === 'wss:'
);
}
/**
* @typedef ProtocolExtract

@@ -703,16 +722,52 @@ * @type Object

* @param {String} address URL we want to extract from.
* @param {Object} location
* @return {ProtocolExtract} Extracted information.
* @private
*/
function extractProtocol(address) {
function extractProtocol(address, location) {
address = trimLeft(address);
location = location || {};
var match = protocolre.exec(address)
, protocol = match[1] ? match[1].toLowerCase() : ''
, slashes = !!(match[2] && match[2].length >= 2)
, rest = match[2] && match[2].length === 1 ? '/' + match[3] : match[3];
var match = protocolre.exec(address);
var protocol = match[1] ? match[1].toLowerCase() : '';
var forwardSlashes = !!match[2];
var otherSlashes = !!match[3];
var slashesCount = 0;
var rest;
if (forwardSlashes) {
if (otherSlashes) {
rest = match[2] + match[3] + match[4];
slashesCount = match[2].length + match[3].length;
} else {
rest = match[2] + match[4];
slashesCount = match[2].length;
}
} else {
if (otherSlashes) {
rest = match[3] + match[4];
slashesCount = match[3].length;
} else {
rest = match[4];
}
}
if (protocol === 'file:') {
if (slashesCount >= 2) {
rest = rest.slice(2);
}
} else if (isSpecial(protocol)) {
rest = match[4];
} else if (protocol) {
if (forwardSlashes) {
rest = rest.slice(2);
}
} else if (slashesCount >= 2 && isSpecial(location.protocol)) {
rest = match[4];
}
return {
protocol: protocol,
slashes: slashes,
slashes: forwardSlashes || isSpecial(protocol),
slashesCount: slashesCount,
rest: rest

@@ -808,3 +863,3 @@ };

//
extracted = extractProtocol(address || '');
extracted = extractProtocol(address || '', location);
relative = !extracted.protocol && !extracted.slashes;

@@ -819,3 +874,12 @@ url.slashes = extracted.slashes || relative && location.slashes;

//
if (!extracted.slashes) instructions[3] = [/(.*)/, 'pathname'];
if (
extracted.protocol === 'file:' && (
extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) ||
(!extracted.slashes &&
(extracted.protocol ||
extracted.slashesCount < 2 ||
!isSpecial(url.protocol)))
) {
instructions[3] = [/(.*)/, 'pathname'];
}

@@ -826,3 +890,3 @@ for (; i < instructions.length; i++) {

if (typeof instruction === 'function') {
address = instruction(address);
address = instruction(address, url);
continue;

@@ -885,3 +949,3 @@ }

//
if (url.pathname.charAt(0) !== '/' && url.hostname) {
if (url.pathname.charAt(0) !== '/' && isSpecial(url.protocol)) {
url.pathname = '/' + url.pathname;

@@ -910,3 +974,3 @@ }

url.origin = url.protocol && url.host && url.protocol !== 'file:'
url.origin = url.protocol !== 'file:' && isSpecial(url.protocol) && url.host
? url.protocol +'//'+ url.host

@@ -1004,3 +1068,3 @@ : 'null';

url.origin = url.protocol && url.host && url.protocol !== 'file:'
url.origin = url.protocol !== 'file:' && isSpecial(url.protocol) && url.host
? url.protocol +'//'+ url.host

@@ -1030,3 +1094,3 @@ : 'null';

var result = protocol + (url.slashes ? '//' : '');
var result = protocol + (url.slashes || isSpecial(url.protocol) ? '//' : '');

@@ -1074,2 +1138,3 @@ if (url.username) {

function parseDiscussionURI(discussion) {
var _a;
// pass it through browser/node URL to invalidate plain strings

@@ -1079,4 +1144,8 @@ var uri = new URL(discussion) && new UrlParse(discussion);

var type = uri.hostname;
var _a = uri.pathname.split("/"), identifier = _a[1];
var _b = identifier.split("_"), id = _b[0], _c = _b[1], layer = _c === void 0 ? null : _c;
var _b = uri.pathname.split("/"), identifier = _b[1];
var id, layer;
if (identifier) {
var _c = hubCommon.parseDatasetId(identifier), itemId = _c.itemId, layerId = _c.layerId;
_a = [itemId, layerId], id = _a[0], layer = _a[1];
}
var searchParams = new URLSearchParams(uri.query);

@@ -1089,3 +1158,3 @@ var features = (searchParams.has("id") && searchParams.get("id").split(",")) || null;

id: id || null,
layer: layer,
layer: layer || null,
features: features,

@@ -1092,0 +1161,0 @@ attribute: attribute

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

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

@@ -25,3 +25,3 @@ "main": "dist/node/index.js",

"@esri/arcgis-rest-types": "^3.1.1",
"@esri/hub-common": "^8.11.1",
"@esri/hub-common": "^8.12.0",
"@rollup/plugin-commonjs": "^15.0.0",

@@ -73,3 +73,3 @@ "@rollup/plugin-json": "^4.1.0",

"homepage": "https://github.com/Esri/hub.js#readme",
"gitHead": "5361a7a1120aad87fbf0b83fc65076d58c3d93fd",
"gitHead": "6fa9f9e9f715bf9151d6a6ee7db8013398a28a58",
"volta": {

@@ -76,0 +76,0 @@ "extends": "../../package.json"

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